summaryrefslogtreecommitdiff
path: root/nest/iface.h
diff options
context:
space:
mode:
Diffstat (limited to 'nest/iface.h')
-rw-r--r--nest/iface.h87
1 files changed, 81 insertions, 6 deletions
diff --git a/nest/iface.h b/nest/iface.h
index 1189cdd4..05898a55 100644
--- a/nest/iface.h
+++ b/nest/iface.h
@@ -9,11 +9,12 @@
#ifndef _BIRD_IFACE_H_
#define _BIRD_IFACE_H_
+#include "lib/locking.h"
+#include "lib/event.h"
#include "lib/lists.h"
+#include "lib/tlists.h"
#include "lib/ip.h"
-extern list iface_list;
-
struct proto;
struct pool;
@@ -26,8 +27,11 @@ struct ifa { /* Interface address */
ip_addr opposite; /* Opposite end of a point-to-point link */
unsigned scope; /* Interface address scope */
unsigned flags; /* Analogous to iface->flags */
+ unsigned uc; /* Use (link) count */
};
+extern struct iface default_vrf;
+
struct iface {
node n;
char name[16];
@@ -42,6 +46,7 @@ struct iface {
struct ifa *llv6; /* Primary link-local address for IPv6 */
ip4_addr sysdep; /* Arbitrary IPv4 address for internal sysdep use */
list neighbors; /* All neighbors on this interface */
+ unsigned uc; /* Use (link) count */
};
#define IF_UP 1 /* Currently just IF_ADMIN_UP */
@@ -106,25 +111,31 @@ void ifa_dump(struct ifa *);
void if_show(void);
void if_show_summary(void);
struct iface *if_update(struct iface *);
+struct iface *if_update_locked(struct iface *);
void if_delete(struct iface *old);
struct ifa *ifa_update(struct ifa *);
void ifa_delete(struct ifa *);
void if_start_update(void);
void if_end_partial_update(struct iface *);
void if_end_update(void);
-void if_flush_ifaces(struct proto *p);
-void if_feed_baby(struct proto *);
struct iface *if_find_by_index(unsigned);
+struct iface *if_find_by_index_locked(unsigned);
struct iface *if_find_by_name(const char *);
struct iface *if_get_by_name(const char *);
void if_recalc_all_preferred_addresses(void);
+struct iface *if_walk_first(void);
+struct iface *if_walk_next(struct iface *);
+void if_walk_done(void);
+
+#define IFACE_WALK(_i) for (struct iface *_i = if_walk_first(); _i || (if_walk_done(), 0); _i = if_walk_next(_i))
/* The Neighbor Cache */
typedef struct neighbor {
node n; /* Node in neighbor hash table chain */
node if_n; /* Node in per-interface neighbor list */
+ TLIST_NODE(proto_neigh, struct neighbor) proto_n;
ip_addr addr; /* Address of the neighbor */
struct ifa *ifa; /* Ifa on related iface */
struct iface *iface; /* Interface it's connected to */
@@ -135,8 +146,16 @@ typedef struct neighbor {
u16 flags; /* NEF_* flags */
s16 scope; /* Address scope, -1 for unreachable neighbors,
SCOPE_HOST when it's our own address */
+ uint uc; /* Use (link) count */
} neighbor;
+#define TLIST_PREFIX proto_neigh
+#define TLIST_TYPE struct neighbor
+#define TLIST_ITEM proto_n
+#define TLIST_WANT_WALK
+#define TLIST_WANT_ADD_TAIL
+#include "lib/tlists.h"
+
#define NEF_STICKY 1
#define NEF_ONLINK 2
#define NEF_IFACE 4 /* Entry for whole iface */
@@ -144,9 +163,7 @@ typedef struct neighbor {
neighbor *neigh_find(struct proto *p, ip_addr a, struct iface *ifa, uint flags);
-void neigh_dump(neighbor *);
void neigh_dump_all(void);
-void neigh_prune(void);
void neigh_if_up(struct iface *);
void neigh_if_down(struct iface *);
void neigh_if_link(struct iface *);
@@ -154,6 +171,64 @@ void neigh_ifa_up(struct ifa *a);
void neigh_ifa_down(struct ifa *a);
void neigh_init(struct pool *);
+void neigh_link(neighbor *);
+void neigh_unlink(neighbor *);
+
+/*
+ * Notification mechanism
+ */
+
+#define TLIST_PREFIX ifnot
+#define TLIST_TYPE struct iface_notification
+#define TLIST_ITEM nn
+#define TLIST_WANT_WALK
+#define TLIST_WANT_ADD_TAIL
+
+struct iface_notification {
+ TLIST_DEFAULT_NODE;
+ enum {
+ IFNOT_INVALID,
+ IFNOT_ADDRESS,
+ IFNOT_INTERFACE,
+ IFNOT_NEIGHBOR,
+ } type;
+ unsigned flags;
+ union {
+ struct ifa *a;
+ struct iface *i;
+ neighbor *n;
+ };
+};
+
+#include "lib/tlists.h"
+
+#define TLIST_PREFIX ifsub
+#define TLIST_TYPE struct iface_subscription
+#define TLIST_ITEM n
+#define TLIST_WANT_WALK
+#define TLIST_WANT_ADD_TAIL
+
+struct iface_subscription {
+ TLIST_DEFAULT_NODE;
+
+ event event;
+ event_list *target;
+ TLIST_LIST(ifnot) queue;
+
+ void (*if_notify)(struct proto *, unsigned flags, struct iface *i);
+ void (*ifa_notify)(struct proto *, unsigned flags, struct ifa *a);
+ void (*neigh_notify)(struct neighbor *neigh);
+};
+
+#include "lib/tlists.h"
+
+void if_enqueue_notify(struct iface_notification);
+void if_enqueue_notify_to(struct iface_notification x, struct iface_subscription *s);
+
+void iface_flush_notifications(struct iface_subscription *);
+void iface_subscribe(struct iface_subscription *);
+void iface_unsubscribe(struct iface_subscription *);
+
/*
* Interface Pattern Lists
*/