From 4cc78c5082344f0d237a5cdfb05e53dfd04ffd8b Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 1 Jun 1998 21:41:11 +0000 Subject: - Rewrote whole interface logic. Removed support for multiple addresses per interface since it makes much trouble everywhere. Instead, we understand secondary addresses as subinterfaces. - In case interface addresses or basic flags change, we simply convert it to a down/up sequence. - Implemented the universal neighbour cache. (Just forget what did previous includes say of neighbour caching, this one is brand new.) --- nest/iface.h | 57 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 15 deletions(-) (limited to 'nest/iface.h') diff --git a/nest/iface.h b/nest/iface.h index 4df9873..c359449 100644 --- a/nest/iface.h +++ b/nest/iface.h @@ -18,8 +18,13 @@ struct iface { char name[16]; unsigned flags; unsigned mtu; - struct ifa *ifa; /* First address is primary */ unsigned index; /* OS-dependent interface index */ + ip_addr ip; /* IP address of this host */ + ip_addr prefix; /* Network prefix */ + unsigned pxlen; /* Prefix length */ + ip_addr brd; /* Broadcast address */ + ip_addr opposite; /* Opposite end of a point-to-point link */ + struct neighbor *neigh; /* List of neighbors on this interface */ }; #define IF_UP 1 @@ -33,25 +38,12 @@ struct iface { #define IF_IGNORE 256 #define IF_UPDATED 0x1000 /* Touched in last scan */ -/* Interface address */ - -struct ifa { - struct ifa *next; - ip_addr ip; /* IP address of this host */ - ip_addr prefix; /* Network prefix */ - unsigned pxlen; /* Prefix length */ - ip_addr brd; /* Broadcast address */ - ip_addr opposite; /* Opposite end of a point-to-point link */ - struct neighbor *neigh; /* List of neighbors on this interface */ -}; - /* Interface change events */ #define IF_CHANGE_UP 1 #define IF_CHANGE_DOWN 2 -#define IF_CHANGE_FLAGS 4 +#define IF_CHANGE_FLAGS 4 /* Can be converted to down/up internally */ #define IF_CHANGE_MTU 8 -#define IF_CHANGE_ADDR 16 void if_init(void); void if_dump(struct iface *); @@ -59,4 +51,39 @@ void if_dump_all(void); void if_update(struct iface *); void if_end_update(void); +/* + * Neighbor Cache. We hold (direct neighbor, protocol) pairs we've seen + * along with pointer to protocol-specific data. + * + * The primary goal of this cache is to quickly validate all incoming + * packets if their have been sent by our neighbors and to notify + * protocols about lost neighbors when an interface goes down. + * + * Anyway, it can also contain `sticky' entries for currently unreachable + * addresses which cause notification when the address becomes a neighbor. + */ + +typedef struct neighbor { + node n; /* Node in global neighbor list */ + ip_addr addr; /* Address of the neighbor */ + struct iface *iface; /* Interface address it's connected to */ + struct neighbor *sibling; /* Next in per-device chain */ + struct proto *proto; /* Protocol this belongs to */ + void *data; /* Protocol-specific data */ + unsigned flags; +} neighbor; + +#define NEF_STICKY 1 + +/* + * Find neighbor or return NULL if it doesn't exist. + * If you specify flags == NEF_STICKY, a sticky entry is created if the + * address is not a neighbor, but NULL can still be returned if the address + * given is invalid. + */ +neighbor *neigh_find(struct proto *, ip_addr *, unsigned flags); + +void neigh_dump(neighbor *); +void neigh_dump_all(void); + #endif -- cgit v1.2.3