]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - include/net/neighbour.h
[NEIGH]: Use rtnl registration interface
[net-next-2.6.git] / include / net / neighbour.h
index 4901ee446879e59795f0df8d57a1c18ce9c7ce92..a4f26187fc1aae78249d88846a5d896d2fbcadd7 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _NET_NEIGHBOUR_H
 #define _NET_NEIGHBOUR_H
 
+#include <linux/neighbour.h>
+
 /*
  *     Generic neighbour manipulation
  *
  *             - Add neighbour cache statistics like rtstat
  */
 
-/* The following flags & states are exported to user space,
-   so that they should be moved to include/linux/ directory.
- */
-
-/*
- *     Neighbor Cache Entry Flags
- */
-
-#define NTF_PROXY      0x08    /* == ATF_PUBL */
-#define NTF_ROUTER     0x80
-
-/*
- *     Neighbor Cache Entry States.
- */
-
-#define NUD_INCOMPLETE 0x01
-#define NUD_REACHABLE  0x02
-#define NUD_STALE      0x04
-#define NUD_DELAY      0x08
-#define NUD_PROBE      0x10
-#define NUD_FAILED     0x20
-
-/* Dummy states */
-#define NUD_NOARP      0x40
-#define NUD_PERMANENT  0x80
-#define NUD_NONE       0x00
-
-/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change
-   and make no address resolution or NUD.
-   NUD_PERMANENT is also cannot be deleted by garbage collectors.
- */
-
-#ifdef __KERNEL__
-
 #include <asm/atomic.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
@@ -56,6 +24,7 @@
 
 #include <linux/err.h>
 #include <linux/sysctl.h>
+#include <net/rtnetlink.h>
 
 #define NUD_IN_TIMER   (NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE)
 #define NUD_VALID      (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY)
@@ -68,7 +37,7 @@ struct neigh_parms
        struct net_device *dev;
        struct neigh_parms *next;
        int     (*neigh_setup)(struct neighbour *);
-       void    (*neigh_destructor)(struct neighbour *);
+       void    (*neigh_cleanup)(struct neighbour *);
        struct neigh_table *tbl;
 
        void    *sysctl_table;
@@ -133,7 +102,7 @@ struct neighbour
        __u8                    dead;
        atomic_t                probes;
        rwlock_t                lock;
-       unsigned char           ha[(MAX_ADDR_LEN+sizeof(unsigned long)-1)&~(sizeof(unsigned long)-1)];
+       unsigned char           ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))];
        struct hh_cache         *hh;
        atomic_t                refcnt;
        int                     (*output)(struct sk_buff *skb);
@@ -158,6 +127,7 @@ struct pneigh_entry
 {
        struct pneigh_entry     *next;
        struct net_device               *dev;
+       u8                      flags;
        u8                      key[0];
 };
 
@@ -191,7 +161,7 @@ struct neigh_table
        atomic_t                entries;
        rwlock_t                lock;
        unsigned long           last_rand;
-       kmem_cache_t            *kmem_cachep;
+       struct kmem_cache               *kmem_cachep;
        struct neigh_statistics *stats;
        struct neighbour        **hash_buckets;
        unsigned int            hash_mask;
@@ -244,16 +214,7 @@ extern void                        pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
 extern struct pneigh_entry     *pneigh_lookup(struct neigh_table *tbl, const void *key, struct net_device *dev, int creat);
 extern int                     pneigh_delete(struct neigh_table *tbl, const void *key, struct net_device *dev);
 
-struct netlink_callback;
-struct nlmsghdr;
-extern int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb);
-extern int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
-extern int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
 extern void neigh_app_ns(struct neighbour *n);
-
-extern int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb);
-extern int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
-
 extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie);
 extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *));
 extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *));
@@ -340,6 +301,24 @@ static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
        return 0;
 }
 
+static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb)
+{
+       unsigned seq;
+       int hh_len;
+
+       do {
+               int hh_alen;
+
+               seq = read_seqbegin(&hh->hh_lock);
+               hh_len = hh->hh_len;
+               hh_alen = HH_DATA_ALIGN(hh_len);
+               memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
+       } while (read_seqretry(&hh->hh_lock, seq));
+
+       skb_push(skb, hh_len);
+       return hh->hh_output(skb);
+}
+
 static inline struct neighbour *
 __neigh_lookup(struct neigh_table *tbl, const void *pkey, struct net_device *dev, int creat)
 {
@@ -374,6 +353,3 @@ struct neighbour_cb {
 #define NEIGH_CB(skb)  ((struct neighbour_cb *)(skb)->cb)
 
 #endif
-#endif
-
-