diff options
Diffstat (limited to 'sys/netinet/if_ether.h')
-rw-r--r-- | sys/netinet/if_ether.h | 100 |
1 files changed, 98 insertions, 2 deletions
diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index 787b561e6fdf..fdf595924c43 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)if_ether.h 7.5 (Berkeley) 6/28/90 - * $Id: if_ether.h,v 1.4 1993/11/25 01:35:01 wollman Exp $ + * $Id: if_ether.h,v 1.5 1994/05/17 22:31:02 jkh Exp $ */ #ifndef _NETINET_IF_ETHER_H_ @@ -61,6 +61,25 @@ struct ether_header { #define ETHERMTU 1500 #define ETHERMIN (60-14) +#ifdef KERNEL +/* + * Macro to map an IP multicast address to an Ethernet multicast address. + * The high-order 25 bites of the Ethernet address are staticall assigned, + * and the low-rder 23 bites are taken from the low end of the IP address. + */ +#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ + /* struct in_addr *ipaddr; */ \ + /* u_char enaddr[6]; */ \ +{ \ + (enaddr)[0] = 0x01; \ + (enaddr)[1] = 0x00; \ + (enaddr)[2] = 0x5e; \ + (enaddr)[3] = ((u_char *)ipaddr)[1] & 0x7f; \ + (enaddr)[4] = ((u_char *)ipaddr)[2]; \ + (enaddr)[5] = ((u_char *)ipaddr)[3]; \ +} +#endif + /* * Ethernet Address Resolution Protocol. * @@ -91,8 +110,11 @@ struct arpcom { struct ifnet ac_if; /* network-visible interface */ u_char ac_enaddr[6]; /* ethernet hardware address */ struct in_addr ac_ipaddr; /* copy of ip address- XXX */ + struct ether_multi *ac_multiaddrs; /* list of ether m'cast addrs */ + int ac_multicnt; /* length of ac_multiaddrs list */ }; + /* * Internet to ethernet address resolution table. */ @@ -106,10 +128,84 @@ struct arptab { #ifdef KERNEL extern u_char etherbroadcastaddr[6]; /* defined in net/if_ethersubr.c */ +#if defined(ISO) && !defined(MULTICAST) +#define MULTICAST 1 +#endif +#ifdef MULTICAST +u_char ether_ipmulticast_min[6]; +u_char ether_ipmulticast_max[6]; +#endif struct arptab *arptnew(); extern void ether_input(struct ifnet *, struct ether_header *, struct mbuf *); extern char *ether_sprintf(u_char *); -#endif +#ifdef MULTICAST +/* + * Ethernet multicast address structure. There is one of these for each + * multicast address or range of multicast addresses that we are supposed + * to listen to on a particular interface. They are kept in a linked list, + * rooted in the interface's arpcom structure. (This really has nothing to + * do with ARP, or with the Internet address family, but this appears to be + * the minimally-disrupting place to put it.) + */ +struct ether_multi { + u_char enm_addrlo[6]; /* low or only address of range */ + u_char enm_addrhi[6]; /* high or only address of range */ + struct arpcom *enm_ac; /* back point to arpcom */ + u_int enm_refcount; /* no. claims to this addr/range */ + struct ether_multi *enm_next; /* ptr to next ether_multi */ +} ; + +/* + * Structure used by macros below to remember position when stepping through + * all of the ether_multi records. + */ +struct ether_multistep { + struct ether_multi *e_enm; +}; + +/* + * Macro for looking up the ether_multi record for a given range of Ethernet + * multicast addresses connected to a given arpcom structure. If no matching + * record is found, "enm" returns NULL. + */ +#define ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm) \ + /* u_char addrlo[6]; */ \ + /* u_char addrhi[6]; */ \ + /* struct arpcom *ac; */ \ + /* struct ether_multi *enm; */ \ +{ \ + for ((enm) = (ac)->ac_multiaddrs; \ + (enm) != NULL && \ + (bcmp((enm)->enm_addrlo, (addrlo), 6) != 0 || \ + bcmp((enm)->enm_addrhi, (addrhi), 6) != 0); \ + (enm) = (enm)->enm_next); \ +} + +/* + * Macro to step through all of the ether_multi records, one at a time. + * The current position is remembered in "step", which the caller must + * provide. ETHER_FIRST_MULTI(), below, must be called to initialize "step" + * and get the first record. Both macros return a NULL "enm" when there + * are no remaining records. + */ +#define ETHER_NEXT_MULTI(step, enm) \ + /* struct ether_multistep step; */ \ + /* struct ether_multi *enm; */ \ +{ \ + if (((enm) = (step).e_enm) != NULL) \ + (step).e_enm = (enm)->enm_next; \ +} + +#define ETHER_FIRST_MULTI(step, ac, enm) \ + /* struct ether_multistep step; */ \ + /* struct arpcom *ac; */ \ + /* struct ether_multi *enm; */ \ +{ \ + (step).e_enm = (ac)->ac_multiaddrs; \ + ETHER_NEXT_MULTI((step), (enm)); \ +} +#endif /* _MULTICAST */ +#endif /* KERNEL */ #endif /* _NETINET_IF_ETHER_H_ */ |