2 * The mrouted program is covered by the license in the accompanying file
3 * named "LICENSE". Use of the mrouted program represents acceptance of
4 * the terms and conditions listed in that file.
6 * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
7 * Leland Stanford Junior University.
10 * vif.c,v 3.8.4.56.2.1 1999/01/20 05:18:50 fenner Exp
12 * $FreeBSD: src/usr.sbin/mrouted/vif.c,v 1.15 1999/08/28 01:17:09 peter Exp $
13 * $DragonFly: src/usr.sbin/mrouted/vif.c,v 1.3 2003/11/03 19:31:38 eirikn Exp $
22 struct uvif uvifs[MAXVIFS]; /* array of virtual interfaces */
23 vifi_t numvifs; /* number of vifs in use */
24 int vifs_down; /* 1=>some interfaces are down */
25 int phys_vif; /* An enabled vif */
26 int udp_socket; /* Since the honkin' kernel doesn't support */
27 /* ioctls on raw IP sockets, we need a UDP */
28 /* socket as well as our IGMP (raw) socket. */
30 int vifs_with_neighbors; /* == 1 if I am a leaf */
35 struct listaddr *nbrs[MAXNBRS]; /* array of neighbors */
44 * Forward declarations.
46 static void start_vif(vifi_t vifi);
47 static void start_vif2(vifi_t vifi);
48 static void stop_vif(vifi_t vifi);
49 static void age_old_hosts(void);
50 static void send_probe_on_vif(struct uvif *v);
51 static void send_query(struct uvif *v);
52 static int info_version(char *p, int plen);
53 static void DelVif(void *arg);
54 static int SetTimer(int vifi, struct listaddr *g);
55 static int DeleteTimer(int id);
56 static void SendQuery(void *arg);
57 static int SetQueryTimer(struct listaddr *g, vifi_t vifi, int to_expire,
62 * Initialize the virtual interfaces, but do not install
63 * them in the kernel. Start routing on all vifs that are
64 * not down or disabled.
71 int enabled_vifs, enabled_phyints;
72 extern char *configfilename;
75 vifs_with_neighbors = 0;
79 * Configure the vifs based on the interface configuration of the
80 * the kernel and the contents of the configuration file.
81 * (Open a UDP socket for ioctl use in the config procedures if
82 * the kernel can't handle IOCTL's on the IGMP socket.)
84 #ifdef IOCTL_OK_ON_RAW_SOCKET
85 udp_socket = igmp_socket;
87 if ((udp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
88 log(LOG_ERR, errno, "UDP socket");
90 log(LOG_INFO,0,"Getting vifs from kernel interfaces");
91 config_vifs_from_kernel();
92 log(LOG_INFO,0,"Getting vifs from %s",configfilename);
93 config_vifs_from_file();
96 * Quit if there are fewer than two enabled vifs.
101 for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
102 if (!(v->uv_flags & VIFF_DISABLED)) {
104 if (!(v->uv_flags & VIFF_TUNNEL)) {
111 if (enabled_vifs < 2)
112 log(LOG_ERR, 0, "can't forward: %s",
113 enabled_vifs == 0 ? "no enabled vifs" : "only one enabled vif");
115 if (enabled_phyints == 0)
117 "no enabled interfaces, forwarding via tunnels only");
119 log(LOG_INFO, 0, "Installing vifs in mrouted...");
120 for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
121 if (!(v->uv_flags & VIFF_DISABLED)) {
122 if (!(v->uv_flags & VIFF_DOWN)) {
123 if (v->uv_flags & VIFF_TUNNEL)
124 log(LOG_INFO, 0, "vif #%d, tunnel %s -> %s", vifi,
125 inet_fmt(v->uv_lcl_addr, s1),
126 inet_fmt(v->uv_rmt_addr, s2));
128 log(LOG_INFO, 0, "vif #%d, phyint %s", vifi,
129 inet_fmt(v->uv_lcl_addr, s1));
131 } else log(LOG_INFO, 0,
132 "%s is not yet up; vif #%u not in service",
139 * Initialize the passed vif with all appropriate default values.
140 * "t" is true if a tunnel, or false if a phyint.
148 v->uv_metric = DEFAULT_METRIC;
150 v->uv_threshold = DEFAULT_THRESHOLD;
151 v->uv_rate_limit = t ? DEFAULT_TUN_RATE_LIMIT : DEFAULT_PHY_RATE_LIMIT;
154 v->uv_dst_addr = t ? 0 : dvmrp_group;
156 v->uv_subnetmask = 0;
157 v->uv_subnetbcast = 0;
158 v->uv_name[0] = '\0';
160 v->uv_neighbors = NULL;
161 NBRM_CLRALL(v->uv_nbrmap);
162 v->uv_querier = NULL;
163 v->uv_igmpv1_warn = 0;
164 v->uv_prune_lifetime = 0;
165 v->uv_leaf_timer = 0;
169 v->uv_blasterbuf = NULL;
170 v->uv_blastercur = NULL;
171 v->uv_blasterend = NULL;
172 v->uv_blasterlen = 0;
173 v->uv_blastertimer = 0;
180 * Start routing on all virtual interfaces that are not down or
181 * administratively disabled.
189 log(LOG_INFO, 0, "Installing vifs in kernel...");
190 for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
191 if (!(v->uv_flags & VIFF_DISABLED)) {
192 if (!(v->uv_flags & VIFF_DOWN)) {
193 if (v->uv_flags & VIFF_TUNNEL)
194 log(LOG_INFO, 0, "vif #%d, tunnel %s -> %s", vifi,
195 inet_fmt(v->uv_lcl_addr, s1),
196 inet_fmt(v->uv_rmt_addr, s2));
198 log(LOG_INFO, 0, "vif #%d, phyint %s", vifi,
199 inet_fmt(v->uv_lcl_addr, s1));
200 k_add_vif(vifi, &uvifs[vifi]);
201 } else log(LOG_INFO, 0,
202 "%s is not yet up; vif #%u not in service",
209 * See if any interfaces have changed from up state to down, or vice versa,
210 * including any non-multicast-capable interfaces that are in use as local
211 * tunnel end-points. Ignore interfaces that have been administratively
217 register vifi_t vifi;
218 register struct uvif *v;
220 static int checking_vifs = 0;
223 * If we get an error while checking, (e.g. two interfaces go down
224 * at once, and we decide to send a prune out one of the failed ones)
225 * then don't go into an infinite loop!
232 for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
234 if (v->uv_flags & VIFF_DISABLED) continue;
236 strncpy(ifr.ifr_name, v->uv_name, IFNAMSIZ);
237 if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ifr) < 0)
239 "ioctl SIOCGIFFLAGS for %s", ifr.ifr_name);
241 if (v->uv_flags & VIFF_DOWN) {
242 if (ifr.ifr_flags & IFF_UP) {
244 "%s has come up; vif #%u now in service",
246 v->uv_flags &= ~VIFF_DOWN;
249 else vifs_down = TRUE;
252 if (!(ifr.ifr_flags & IFF_UP)) {
254 "%s has gone down; vif #%u taken out of service",
257 v->uv_flags |= VIFF_DOWN;
266 * Send a DVMRP message on the specified vif. If DVMRP messages are
267 * to be encapsulated and sent "inside" the tunnel, use the special
268 * encapsulator. If it's not a tunnel or DVMRP messages are to be
269 * sent "beside" the tunnel, as required by earlier versions of mrouted,
270 * then just send the message.
273 send_on_vif(v, dst, code, datalen)
274 register struct uvif *v;
279 u_int32 group = htonl(MROUTED_LEVEL |
280 ((v->uv_flags & VIFF_LEAF) ? 0 : LEAF_FLAGS));
283 * The UNIX kernel will not decapsulate unicasts.
284 * Therefore, we don't send encapsulated unicasts.
286 if ((v->uv_flags & (VIFF_TUNNEL|VIFF_OTUNNEL)) == VIFF_TUNNEL &&
287 ((dst == 0) || IN_MULTICAST(ntohl(dst))))
288 send_ipip(v->uv_lcl_addr, dst ? dst : dvmrp_group, IGMP_DVMRP,
289 code, group, datalen, v);
291 send_igmp(v->uv_lcl_addr, dst ? dst : v->uv_dst_addr, IGMP_DVMRP,
292 code, group, datalen);
297 * Send a probe message on vif v
301 register struct uvif *v;
304 register int datalen = 0;
305 struct listaddr *nbr;
308 if ((v->uv_flags & VIFF_PASSIVE && v->uv_neighbors == NULL) ||
309 (v->uv_flags & VIFF_FORCE_LEAF))
312 p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
314 for (i = 0; i < 4; i++)
315 *p++ = ((char *)&(dvmrp_genid))[i];
319 * add the neighbor list on the interface to the message
321 nbr = v->uv_neighbors;
324 for (i = 0; i < 4; i++)
325 *p++ = ((char *)&nbr->al_addr)[i];
330 send_on_vif(v, 0, DVMRP_PROBE, datalen);
335 register struct uvif *v;
338 log(LOG_DEBUG, 0, "sending %squery on vif %d",
339 (v->uv_flags & VIFF_IGMPV1) ? "v1 " : "",
341 send_igmp(v->uv_lcl_addr, allhosts_group,
342 IGMP_MEMBERSHIP_QUERY,
343 (v->uv_flags & VIFF_IGMPV1) ? 0 :
344 IGMP_MAX_HOST_REPORT_DELAY * IGMP_TIMER_SCALE, 0, 0);
348 * Add a vifi to the kernel and start routing on it.
355 * Install the interface in the kernel's vif structure.
357 k_add_vif(vifi, &uvifs[vifi]);
363 * Add a vifi to all the user-level data structures but don't add
364 * it to the kernel yet.
375 src = v->uv_lcl_addr;
378 * Update the existing route entries to take into account the new vif.
380 add_vif_to_routes(vifi);
382 if (!(v->uv_flags & VIFF_TUNNEL)) {
384 * Join the DVMRP multicast group on the interface.
385 * (This is not strictly necessary, since the kernel promiscuously
386 * receives IGMP packets addressed to ANY IP multicast group while
387 * multicast routing is enabled. However, joining the group allows
388 * this host to receive non-IGMP packets as well, such as 'pings'.)
390 k_join(dvmrp_group, src);
393 * Join the ALL-ROUTERS multicast group on the interface.
394 * This allows mtrace requests to loop back if they are run
395 * on the multicast router.
397 k_join(allrtrs_group, src);
400 * Install an entry in the routing table for the subnet to which
401 * the interface is connected.
403 start_route_updates();
404 update_route(v->uv_subnet, v->uv_subnetmask, 0, 0, vifi, NULL);
405 for (p = v->uv_addrs; p; p = p->pa_next) {
406 start_route_updates();
407 update_route(p->pa_subnet, p->pa_subnetmask, 0, 0, vifi, NULL);
411 * Until neighbors are discovered, assume responsibility for sending
412 * periodic group membership queries to the subnet. Send the first
415 v->uv_flags |= VIFF_QUERIER;
417 log(LOG_DEBUG, 0, "assuming querier duties on vif %d", vifi);
421 v->uv_leaf_timer = LEAF_CONFIRMATION_TIME;
424 * Send a probe via the new vif to look for neighbors.
426 send_probe_on_vif(v);
430 * Stop routing on the specified virtual interface.
442 if (!(v->uv_flags & VIFF_TUNNEL)) {
444 * Depart from the DVMRP multicast group on the interface.
446 k_leave(dvmrp_group, v->uv_lcl_addr);
449 * Depart from the ALL-ROUTERS multicast group on the interface.
451 k_leave(allrtrs_group, v->uv_lcl_addr);
454 * Update the entry in the routing table for the subnet to which
455 * the interface is connected, to take into account the interface
458 start_route_updates();
459 update_route(v->uv_subnet, v->uv_subnetmask, UNREACHABLE, 0, vifi, NULL);
460 for (p = v->uv_addrs; p; p = p->pa_next) {
461 start_route_updates();
462 update_route(p->pa_subnet, p->pa_subnetmask, UNREACHABLE, 0, vifi, NULL);
466 * Discard all group addresses. (No need to tell kernel;
467 * the k_del_vif() call, below, will clean up kernel state.)
469 while (v->uv_groups != NULL) {
471 v->uv_groups = a->al_next;
476 log(LOG_DEBUG, 0, "releasing querier duties on vif %d", vifi);
477 v->uv_flags &= ~VIFF_QUERIER;
481 * Update the existing route entries to take into account the vif failure.
483 delete_vif_from_routes(vifi);
486 * Delete the interface from the kernel's vif structure.
491 * Discard all neighbor addresses.
493 if (!NBRM_ISEMPTY(v->uv_nbrmap))
494 vifs_with_neighbors--;
496 while (v->uv_neighbors != NULL) {
498 v->uv_neighbors = a->al_next;
499 nbrs[a->al_index] = NULL;
502 NBRM_CLRALL(v->uv_nbrmap);
507 * stop routing on all vifs
517 for (vifi = 0; vifi < numvifs; vifi++) {
519 while (v->uv_groups != NULL) {
521 v->uv_groups = a->al_next;
524 while (v->uv_neighbors != NULL) {
526 v->uv_neighbors = a->al_next;
527 nbrs[a->al_index] = NULL;
530 while (v->uv_acl != NULL) {
532 v->uv_acl = acl->acl_next;
540 * Find the virtual interface from which an incoming packet arrived,
541 * based on the packet's source and destination IP addresses.
545 register u_int32 src;
546 register u_int32 dst;
548 register vifi_t vifi;
549 register struct uvif *v;
550 register struct phaddr *p;
552 for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
553 if (!(v->uv_flags & (VIFF_DOWN|VIFF_DISABLED))) {
554 if (v->uv_flags & VIFF_TUNNEL) {
555 if (src == v->uv_rmt_addr && (dst == v->uv_lcl_addr ||
560 if ((src & v->uv_subnetmask) == v->uv_subnet &&
561 ((v->uv_subnetmask == 0xffffffff) ||
562 (src != v->uv_subnetbcast)))
564 for (p=v->uv_addrs; p; p=p->pa_next) {
565 if ((src & p->pa_subnetmask) == p->pa_subnet &&
566 ((p->pa_subnetmask == 0xffffffff) ||
567 (src != p->pa_subnetbcast)))
579 register vifi_t vifi;
580 register struct uvif *v;
581 register struct listaddr *g;
584 * Decrement the old-hosts-present timer for each
585 * active group on each vif.
587 for (vifi = 0, v = uvifs; vifi < numvifs; vifi++, v++)
588 for (g = v->uv_groups; g != NULL; g = g->al_next)
595 * Send group membership queries on each interface for which I am querier.
596 * Note that technically, there should be a timer per interface, as the
597 * dynamics of querier election can cause the "right" time to send a
598 * query to be different on different interfaces. However, this simple
599 * implementation only ever sends queries sooner than the "right" time,
600 * so can not cause loss of membership (but can send more packets than
606 register vifi_t vifi;
607 register struct uvif *v;
609 for (vifi = 0, v = uvifs; vifi < numvifs; vifi++, v++) {
610 if (v->uv_flags & VIFF_QUERIER) {
618 * Process an incoming host membership query. Warn about
619 * IGMP version mismatches, perform querier election, and
620 * handle group-specific queries when we're not the querier.
623 accept_membership_query(src, dst, group, tmo)
624 u_int32 src, dst, group;
627 register vifi_t vifi;
628 register struct uvif *v;
630 if ((vifi = find_vif(src, dst)) == NO_VIF ||
631 (uvifs[vifi].uv_flags & VIFF_TUNNEL)) {
633 "ignoring group membership query from non-adjacent host %s",
640 if ((tmo == 0 && !(v->uv_flags & VIFF_IGMPV1)) ||
641 (tmo != 0 && (v->uv_flags & VIFF_IGMPV1))) {
645 * Exponentially back-off warning rate
647 i = ++v->uv_igmpv1_warn;
648 while (i && !(i & 1))
651 log(LOG_WARNING, 0, "%s %s on vif %d, %s",
652 tmo == 0 ? "Received IGMPv1 report from"
653 : "Received IGMPv2 report from",
656 tmo == 0 ? "please configure vif for IGMPv1"
657 : "but I am configured for IGMPv1");
660 if (v->uv_querier == NULL || v->uv_querier->al_addr != src) {
663 * - A query from a new querier, with a lower source address
664 * than the current querier (who might be me)
665 * - A query from a new router that just started up and doesn't
666 * know who the querier is.
668 if (ntohl(src) < (v->uv_querier ? ntohl(v->uv_querier->al_addr)
669 : ntohl(v->uv_lcl_addr))) {
671 log(LOG_DEBUG, 0, "new querier %s (was %s) on vif %d",
673 v->uv_querier ? inet_fmt(v->uv_querier->al_addr, s2) :
675 if (!v->uv_querier) {
676 v->uv_querier = (struct listaddr *)
677 malloc(sizeof(struct listaddr));
678 v->uv_flags &= ~VIFF_QUERIER;
680 time(&v->uv_querier->al_ctime);
681 v->uv_querier->al_addr = src;
684 log(LOG_DEBUG, 0, "ignoring query from %s; querier on vif %d is still %s",
685 inet_fmt(src, s1), vifi,
686 v->uv_querier ? inet_fmt(v->uv_querier->al_addr, s2) :
694 * Reset the timer since we've received a query.
696 if (v->uv_querier && src == v->uv_querier->al_addr)
697 v->uv_querier->al_timer = 0;
700 * If this is a Group-Specific query which we did not source,
701 * we must set our membership timer to [Last Member Query Count] *
702 * the [Max Response Time] in the packet.
704 if (!(v->uv_flags & (VIFF_IGMPV1|VIFF_QUERIER)) && group != 0 &&
705 src != v->uv_lcl_addr) {
706 register struct listaddr *g;
710 "%s for %s from %s on vif %d, timer %d",
711 "Group-specific membership query",
712 inet_fmt(group, s2), inet_fmt(src, s1), vifi, tmo);
714 for (g = v->uv_groups; g != NULL; g = g->al_next) {
715 if (group == g->al_addr && g->al_query == 0) {
716 /* setup a timeout to remove the group membership */
718 g->al_timerid = DeleteTimer(g->al_timerid);
719 g->al_timer = IGMP_LAST_MEMBER_QUERY_COUNT *
720 tmo / IGMP_TIMER_SCALE;
721 /* use al_query to record our presence in last-member state */
723 g->al_timerid = SetTimer(vifi, g);
726 "timer for grp %s on vif %d set to %d",
727 inet_fmt(group, s2), vifi, g->al_timer);
735 * Process an incoming group membership report.
738 accept_group_report(src, dst, group, r_type)
739 u_int32 src, dst, group;
742 register vifi_t vifi;
743 register struct uvif *v;
744 register struct listaddr *g;
746 if ((vifi = find_vif(src, dst)) == NO_VIF ||
747 (uvifs[vifi].uv_flags & VIFF_TUNNEL)) {
749 "ignoring group membership report from non-adjacent host %s",
757 * Look for the group in our group list; if found, reset its timer.
759 for (g = v->uv_groups; g != NULL; g = g->al_next) {
760 if (group == g->al_addr) {
761 if (r_type == IGMP_V1_MEMBERSHIP_REPORT)
762 g->al_old = OLD_AGE_THRESHOLD;
764 g->al_reporter = src;
766 /** delete old timers, set a timer for expiration **/
767 g->al_timer = IGMP_GROUP_MEMBERSHIP_INTERVAL;
769 g->al_query = DeleteTimer(g->al_query);
771 g->al_timerid = DeleteTimer(g->al_timerid);
772 g->al_timerid = SetTimer(vifi, g);
778 * If not found, add it to the list and update kernel cache.
781 g = (struct listaddr *)malloc(sizeof(struct listaddr));
783 log(LOG_ERR, 0, "ran out of memory"); /* fatal */
786 if (r_type == IGMP_V1_MEMBERSHIP_REPORT)
787 g->al_old = OLD_AGE_THRESHOLD;
791 /** set a timer for expiration **/
793 g->al_timer = IGMP_GROUP_MEMBERSHIP_INTERVAL;
794 g->al_reporter = src;
795 g->al_timerid = SetTimer(vifi, g);
796 g->al_next = v->uv_groups;
800 update_lclgrp(vifi, group);
804 * Check if a graft is necessary for this group
806 chkgrp_graft(vifi, group);
810 * Process an incoming IGMPv2 Leave Group message.
813 accept_leave_message(src, dst, group)
814 u_int32 src, dst, group;
816 register vifi_t vifi;
817 register struct uvif *v;
818 register struct listaddr *g;
820 if ((vifi = find_vif(src, dst)) == NO_VIF ||
821 (uvifs[vifi].uv_flags & VIFF_TUNNEL)) {
823 "ignoring group leave report from non-adjacent host %s",
830 if (!(v->uv_flags & VIFF_QUERIER) || (v->uv_flags & VIFF_IGMPV1))
834 * Look for the group in our group list in order to set up a short-timeout
837 for (g = v->uv_groups; g != NULL; g = g->al_next) {
838 if (group == g->al_addr) {
841 "[vif.c, _accept_leave_message] %d %d \n",
842 g->al_old, g->al_query);
844 /* Ignore the leave message if there are old hosts present */
848 /* still waiting for a reply to a query, ignore the leave */
852 /** delete old timer set a timer for expiration **/
854 g->al_timerid = DeleteTimer(g->al_timerid);
856 #if IGMP_LAST_MEMBER_QUERY_COUNT != 2
857 This code needs to be updated to keep a counter of the number
858 of queries remaining.
860 /** send a group specific querry **/
861 g->al_timer = IGMP_LAST_MEMBER_QUERY_INTERVAL *
862 (IGMP_LAST_MEMBER_QUERY_COUNT + 1);
863 send_igmp(v->uv_lcl_addr, g->al_addr,
864 IGMP_MEMBERSHIP_QUERY,
865 IGMP_LAST_MEMBER_QUERY_INTERVAL * IGMP_TIMER_SCALE,
867 g->al_query = SetQueryTimer(g, vifi,
868 IGMP_LAST_MEMBER_QUERY_INTERVAL,
869 IGMP_LAST_MEMBER_QUERY_INTERVAL * IGMP_TIMER_SCALE);
870 g->al_timerid = SetTimer(vifi, g);
878 * Send a periodic probe on all vifs.
879 * Useful to determine one-way interfaces.
880 * Detect neighbor loss faster.
883 probe_for_neighbors()
885 register vifi_t vifi;
886 register struct uvif *v;
888 for (vifi = 0, v = uvifs; vifi < numvifs; vifi++, v++) {
889 if (!(v->uv_flags & (VIFF_DOWN|VIFF_DISABLED))) {
890 send_probe_on_vif(v);
897 * Send a list of all of our neighbors to the requestor, `src'.
900 accept_neighbor_request(src, dst)
908 u_int32 temp_addr, them = src;
910 #define PUT_ADDR(a) temp_addr = ntohl(a); \
911 *p++ = temp_addr >> 24; \
912 *p++ = (temp_addr >> 16) & 0xFF; \
913 *p++ = (temp_addr >> 8) & 0xFF; \
914 *p++ = temp_addr & 0xFF;
916 p = (u_char *) (send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN);
919 for (vifi = 0, v = uvifs; vifi < numvifs; vifi++, v++) {
920 if (v->uv_flags & VIFF_DISABLED)
925 for (la = v->uv_neighbors; la; la = la->al_next) {
927 /* Make sure that there's room for this neighbor... */
928 if (datalen + (ncount == 0 ? 4 + 3 + 4 : 4) > MAX_DVMRP_DATA_LEN) {
929 send_igmp(INADDR_ANY, them, IGMP_DVMRP, DVMRP_NEIGHBORS,
930 htonl(MROUTED_LEVEL), datalen);
931 p = (u_char *) (send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN);
936 /* Put out the header for this neighbor list... */
938 PUT_ADDR(v->uv_lcl_addr);
940 *p++ = v->uv_threshold;
946 PUT_ADDR(la->al_addr);
953 send_igmp(INADDR_ANY, them, IGMP_DVMRP, DVMRP_NEIGHBORS,
954 htonl(MROUTED_LEVEL), datalen);
958 * Send a list of all of our neighbors to the requestor, `src'.
961 accept_neighbor_request2(src, dst)
971 p = (u_char *) (send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN);
974 for (vifi = 0, v = uvifs; vifi < numvifs; vifi++, v++) {
975 register u_short vflags = v->uv_flags;
976 register u_char rflags = 0;
977 if (vflags & VIFF_TUNNEL)
978 rflags |= DVMRP_NF_TUNNEL;
979 if (vflags & VIFF_SRCRT)
980 rflags |= DVMRP_NF_SRCRT;
981 if (vflags & VIFF_DOWN)
982 rflags |= DVMRP_NF_DOWN;
983 if (vflags & VIFF_DISABLED)
984 rflags |= DVMRP_NF_DISABLED;
985 if (vflags & VIFF_QUERIER)
986 rflags |= DVMRP_NF_QUERIER;
987 if (vflags & VIFF_LEAF)
988 rflags |= DVMRP_NF_LEAF;
990 la = v->uv_neighbors;
993 * include down & disabled interfaces and interfaces on
996 if (rflags & DVMRP_NF_TUNNEL)
997 rflags |= DVMRP_NF_DOWN;
998 if (datalen > MAX_DVMRP_DATA_LEN - 12) {
999 send_igmp(INADDR_ANY, them, IGMP_DVMRP, DVMRP_NEIGHBORS2,
1000 htonl(MROUTED_LEVEL), datalen);
1001 p = (u_char *) (send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN);
1004 *(u_int*)p = v->uv_lcl_addr;
1006 *p++ = v->uv_metric;
1007 *p++ = v->uv_threshold;
1010 *(u_int*)p = v->uv_rmt_addr;
1014 for ( ; la; la = la->al_next) {
1015 /* Make sure that there's room for this neighbor... */
1016 if (datalen + (ncount == 0 ? 4+4+4 : 4) > MAX_DVMRP_DATA_LEN) {
1017 send_igmp(INADDR_ANY, them, IGMP_DVMRP, DVMRP_NEIGHBORS2,
1018 htonl(MROUTED_LEVEL), datalen);
1019 p = (u_char *) (send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN);
1023 /* Put out the header for this neighbor list... */
1025 /* If it's a one-way tunnel, mark it down. */
1026 if (rflags & DVMRP_NF_TUNNEL && la->al_flags & NBRF_ONEWAY)
1027 rflags |= DVMRP_NF_DOWN;
1028 *(u_int*)p = v->uv_lcl_addr;
1030 *p++ = v->uv_metric;
1031 *p++ = v->uv_threshold;
1037 /* Don't report one-way peering on phyint at all */
1038 if (!(rflags & DVMRP_NF_TUNNEL) && la->al_flags & NBRF_ONEWAY)
1040 *(u_int*)p = la->al_addr;
1046 *(u_int*)p = v->uv_rmt_addr;
1054 send_igmp(INADDR_ANY, them, IGMP_DVMRP, DVMRP_NEIGHBORS2,
1055 htonl(MROUTED_LEVEL), datalen);
1059 accept_info_request(src, dst, p, datalen)
1068 q = (u_char *) (send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN);
1070 /* To be general, this must deal properly with breaking up over-sized
1071 * packets. That implies passing a length to each function, and
1072 * allowing each function to request to be called again. Right now,
1073 * we're only implementing the one thing we are positive will fit into
1074 * a single packet, so we wimp out.
1076 while (datalen > 0) {
1079 case DVMRP_INFO_VERSION:
1080 len = info_version(q, RECV_BUF_SIZE-(q-(u_char *)send_buf));
1083 case DVMRP_INFO_NEIGHBORS:
1085 log(LOG_INFO, 0, "ignoring unknown info type %d", *p);
1091 len = (*(p+1) + 1) * 4;
1097 send_igmp(INADDR_ANY, src, IGMP_DVMRP, DVMRP_INFO_REPLY,
1098 htonl(MROUTED_LEVEL), outlen);
1102 * Information response -- return version string
1105 info_version(p, plen)
1110 extern char versionstring[];
1112 *p++ = DVMRP_INFO_VERSION;
1113 p++; /* skip over length */
1114 *p++ = 0; /* zero out */
1115 *p++ = 0; /* reserved fields */
1116 strncpy(p, versionstring, plen - 4);
1119 len = strlen(versionstring);
1120 return ((len + 3) / 4);
1124 * Process an incoming neighbor-list message.
1127 accept_neighbors(src, dst, p, datalen, level)
1128 u_int32 src, dst, level;
1132 log(LOG_INFO, 0, "ignoring spurious DVMRP neighbor list from %s to %s",
1133 inet_fmt(src, s1), inet_fmt(dst, s2));
1138 * Process an incoming neighbor-list message.
1141 accept_neighbors2(src, dst, p, datalen, level)
1142 u_int32 src, dst, level;
1147 log(LOG_DEBUG, 0, "ignoring spurious DVMRP neighbor list2 from %s to %s",
1148 inet_fmt(src, s1), inet_fmt(dst, s2));
1152 * Process an incoming info reply message.
1155 accept_info_reply(src, dst, p, datalen)
1161 log(LOG_DEBUG, 0, "ignoring spurious DVMRP info reply from %s to %s",
1162 inet_fmt(src, s1), inet_fmt(dst, s2));
1167 * Update the neighbor entry for neighbor 'addr' on vif 'vifi'.
1168 * 'msgtype' is the type of DVMRP message received from the neighbor.
1169 * Return the neighbor entry if 'addr' is a valid neighbor, FALSE otherwise.
1172 update_neighbor(vifi, addr, msgtype, p, datalen, level)
1180 register struct uvif *v;
1181 register struct listaddr *n;
1182 int pv = level & 0xff;
1183 int mv = (level >> 8) & 0xff;
1185 int in_router_list = 0;
1188 u_int32 send_tables = 0;
1190 int do_reset = FALSE;
1195 * Confirm that 'addr' is a valid neighbor address on vif 'vifi'.
1196 * IT IS ASSUMED that this was preceded by a call to find_vif(), which
1197 * checks that 'addr' is either a valid remote tunnel endpoint or a
1198 * non-broadcast address belonging to a directly-connected subnet.
1199 * Therefore, here we check only that 'addr' is not our own address
1200 * (due to an impostor or erroneous loopback) or an address of the form
1201 * {subnet,0} ("the unknown host"). These checks are not performed in
1202 * find_vif() because those types of address are acceptable for some
1203 * types of IGMP message (such as group membership reports).
1205 if (!(v->uv_flags & VIFF_TUNNEL) &&
1206 (addr == v->uv_lcl_addr ||
1207 addr == v->uv_subnet )) {
1209 "received DVMRP message from %s: %s",
1210 (addr == v->uv_lcl_addr) ? "self (check device loopback)" :
1211 "'the unknown host'",
1212 inet_fmt(addr, s1));
1217 * Ignore all neighbors on vifs forced into leaf mode
1219 if (v->uv_flags & VIFF_FORCE_LEAF) {
1224 * mrouted's version 3.3 and later include the generation ID
1225 * and the list of neighbors on the vif in their probe messages.
1227 if (msgtype == DVMRP_PROBE && ((pv == 3 && mv > 2) ||
1228 (pv > 3 && pv < 10))) {
1231 IF_DEBUG(DEBUG_PEER)
1232 log(LOG_DEBUG, 0, "checking probe from %s (%d.%d) on vif %d",
1233 inet_fmt(addr, s1), pv, mv, vifi);
1237 "received truncated probe message from %s (len %d)",
1238 inet_fmt(addr, s1), datalen);
1244 for (i = 0; i < 4; i++)
1245 ((char *)&genid)[i] = *p++;
1248 while (datalen > 0) {
1251 "received truncated probe message from %s (len %d)",
1252 inet_fmt(addr, s1), datalen);
1255 for (i = 0; i < 4; i++)
1256 ((char *)&router)[i] = *p++;
1259 if (router == v->uv_lcl_addr) {
1266 if ((pv == 3 && mv == 255) || (pv > 3 && pv < 10))
1270 * Look for addr in list of neighbors.
1272 for (n = v->uv_neighbors; n != NULL; n = n->al_next) {
1273 if (addr == n->al_addr) {
1282 * If this neighbor follows the DVMRP spec, start the probe
1283 * handshake. If not, then it doesn't require the probe
1284 * handshake, so establish the peering immediately.
1286 if (dvmrpspec && (msgtype != DVMRP_PROBE))
1289 for (i = 0; i < MAXNBRS; i++)
1290 if (nbrs[i] == NULL)
1294 /* XXX This is a severe new restriction. */
1295 /* XXX want extensible bitmaps! */
1296 log(LOG_ERR, 0, "Can't handle %dth neighbor %s on vif %d!",
1297 MAXNBRS, inet_fmt(addr, s1), vifi);
1302 * Add it to our list of neighbors.
1304 IF_DEBUG(DEBUG_PEER)
1305 log(LOG_DEBUG, 0, "New neighbor %s on vif %d v%d.%d nf 0x%02x idx %d",
1306 inet_fmt(addr, s1), vifi, level & 0xff, (level >> 8) & 0xff,
1307 (level >> 16) & 0xff, i);
1309 n = (struct listaddr *)malloc(sizeof(struct listaddr));
1311 log(LOG_ERR, 0, "ran out of memory"); /* fatal */
1316 n->al_genid = has_genid ? genid : 0;
1322 n->al_flags = has_genid ? NBRF_GENID : 0;
1323 n->al_next = v->uv_neighbors;
1324 v->uv_neighbors = n;
1327 * If we are not configured to peer with non-pruning routers,
1328 * check the deprecated "I-know-how-to-prune" bit. This bit
1329 * was MBZ in early mrouted implementations (<3.5) and is required
1330 * to be set by the DVMRPv3 specification.
1332 if (!(v->uv_flags & VIFF_ALLOW_NONPRUNERS) &&
1333 !((level & 0x020000) || (pv == 3 && mv < 5))) {
1334 n->al_flags |= NBRF_TOOOLD;
1338 * If this router implements the DVMRPv3 spec, then don't peer
1339 * with him if we haven't yet established a bidirectional connection.
1342 if (!in_router_list) {
1343 IF_DEBUG(DEBUG_PEER)
1344 log(LOG_DEBUG, 0, "waiting for probe from %s with my addr",
1345 inet_fmt(addr, s1));
1346 n->al_flags |= NBRF_WAITING;
1351 if (n->al_flags & NBRF_DONTPEER) {
1352 IF_DEBUG(DEBUG_PEER)
1353 log(LOG_DEBUG, 0, "not peering with %s on vif %d because %x",
1354 inet_fmt(addr, s1), vifi, n->al_flags & NBRF_DONTPEER);
1359 * If we thought that we had no neighbors on this vif, send a route
1360 * report to the vif. If this is just a new neighbor on the same
1361 * vif, send the route report just to the new neighbor.
1363 if (NBRM_ISEMPTY(v->uv_nbrmap)) {
1364 send_tables = v->uv_dst_addr;
1365 vifs_with_neighbors++;
1371 NBRM_SET(i, v->uv_nbrmap);
1372 add_neighbor_to_routes(vifi, i);
1375 * Found it. Reset its timer.
1379 if (n->al_flags & NBRF_WAITING && msgtype == DVMRP_PROBE) {
1380 n->al_flags &= ~NBRF_WAITING;
1381 if (!in_router_list) {
1382 log(LOG_WARNING, 0, "possible one-way peering with %s on vif %d",
1383 inet_fmt(addr, s1), vifi);
1384 n->al_flags |= NBRF_ONEWAY;
1387 if (NBRM_ISEMPTY(v->uv_nbrmap)) {
1388 send_tables = v->uv_dst_addr;
1389 vifs_with_neighbors++;
1393 NBRM_SET(n->al_index, v->uv_nbrmap);
1394 add_neighbor_to_routes(vifi, n->al_index);
1395 IF_DEBUG(DEBUG_PEER)
1396 log(LOG_DEBUG, 0, "%s on vif %d exits WAITING",
1397 inet_fmt(addr, s1), vifi);
1401 if (n->al_flags & NBRF_ONEWAY && msgtype == DVMRP_PROBE) {
1402 if (in_router_list) {
1403 if (NBRM_ISEMPTY(v->uv_nbrmap))
1404 vifs_with_neighbors++;
1405 NBRM_SET(n->al_index, v->uv_nbrmap);
1406 add_neighbor_to_routes(vifi, n->al_index);
1407 log(LOG_NOTICE, 0, "peering with %s on vif %d is no longer one-way",
1408 inet_fmt(addr, s1), vifi);
1409 n->al_flags &= ~NBRF_ONEWAY;
1411 /* XXX rate-limited warning message? */
1412 IF_DEBUG(DEBUG_PEER)
1413 log(LOG_DEBUG, 0, "%s on vif %d is still ONEWAY",
1414 inet_fmt(addr, s1), vifi);
1419 * When peering with a genid-capable but pre-DVMRP spec peer,
1420 * we might bring up the peering with a route report and not
1421 * remember his genid. Assume that he doesn't send a route
1422 * report and then reboot before sending a probe.
1424 if (has_genid && !(n->al_flags & NBRF_GENID)) {
1425 n->al_flags |= NBRF_GENID;
1426 n->al_genid = genid;
1430 * update the neighbors version and protocol number and genid
1431 * if changed => router went down and came up,
1432 * so take action immediately.
1434 if ((n->al_pv != pv) ||
1436 (has_genid && n->al_genid != genid)) {
1439 IF_DEBUG(DEBUG_PEER)
1441 "version/genid change neighbor %s [old:%d.%d/%8x, new:%d.%d/%8x]",
1443 n->al_pv, n->al_mv, n->al_genid, pv, mv, genid);
1447 n->al_genid = genid;
1451 if ((pv == 3 && mv > 2) || (pv > 3 && pv < 10)) {
1452 if (!(n->al_flags & VIFF_ONEWAY) && has_genid && !in_router_list &&
1453 (time(NULL) - n->al_ctime > 20)) {
1454 if (NBRM_ISSET(n->al_index, v->uv_nbrmap)) {
1455 NBRM_CLR(n->al_index, v->uv_nbrmap);
1456 if (NBRM_ISEMPTY(v->uv_nbrmap))
1457 vifs_with_neighbors--;
1459 delete_neighbor_from_routes(addr, vifi, n->al_index);
1460 reset_neighbor_state(vifi, addr);
1461 log(LOG_WARNING, 0, "peering with %s on vif %d is one-way",
1462 inet_fmt(addr, s1), vifi);
1463 n->al_flags |= NBRF_ONEWAY;
1467 if (n->al_flags & NBRF_DONTPEER) {
1468 IF_DEBUG(DEBUG_PEER)
1469 log(LOG_DEBUG, 0, "not peering with %s on vif %d because %x",
1470 inet_fmt(addr, s1), vifi, n->al_flags & NBRF_DONTPEER);
1474 /* check "leaf" flag */
1477 reset_neighbor_state(vifi, addr);
1482 send_probe_on_vif(v);
1483 report(ALL_ROUTES, vifi, send_tables);
1485 v->uv_leaf_timer = 0;
1486 v->uv_flags &= ~VIFF_LEAF;
1493 * On every timer interrupt, advance the timer in each neighbor and
1494 * group entry on every vif.
1499 register vifi_t vifi;
1500 register struct uvif *v;
1501 register struct listaddr *a, *prev_a;
1502 register u_int32 addr;
1504 for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v ) {
1505 if (v->uv_leaf_timer && (v->uv_leaf_timer -= TIMER_INTERVAL == 0)) {
1506 v->uv_flags |= VIFF_LEAF;
1509 for (prev_a = (struct listaddr *)&(v->uv_neighbors),
1510 a = v->uv_neighbors;
1512 prev_a = a, a = a->al_next) {
1516 if (((a->al_pv == 3) && (a->al_mv >= 3)) ||
1517 ((a->al_pv > 3) && (a->al_pv < 10)))
1518 exp_time = NEIGHBOR_EXPIRE_TIME;
1520 exp_time = OLD_NEIGHBOR_EXPIRE_TIME;
1522 if ((a->al_timer += TIMER_INTERVAL) < exp_time)
1525 IF_DEBUG(DEBUG_PEER)
1526 log(LOG_DEBUG, 0, "Neighbor %s (%d.%d) expired after %d seconds",
1527 inet_fmt(a->al_addr, s1), a->al_pv, a->al_mv, exp_time);
1530 * Neighbor has expired; delete it from the neighbor list,
1531 * delete it from the 'dominants' and 'subordinates arrays of
1532 * any route entries.
1534 NBRM_CLR(a->al_index, v->uv_nbrmap);
1535 nbrs[a->al_index] = NULL; /* XXX is it a good idea to reuse indxs? */
1538 prev_a->al_next = a->al_next;
1540 a = prev_a;/*XXX use ** */
1542 delete_neighbor_from_routes(addr, vifi, idx);
1543 reset_neighbor_state(vifi, addr);
1545 if (NBRM_ISEMPTY(v->uv_nbrmap))
1546 vifs_with_neighbors--;
1548 v->uv_leaf_timer = LEAF_CONFIRMATION_TIME;
1551 if (v->uv_querier &&
1552 (v->uv_querier->al_timer += TIMER_INTERVAL) >
1553 IGMP_OTHER_QUERIER_PRESENT_INTERVAL) {
1555 * The current querier has timed out. We must become the
1558 IF_DEBUG(DEBUG_IGMP)
1559 log(LOG_DEBUG, 0, "querier %s timed out",
1560 inet_fmt(v->uv_querier->al_addr, s1));
1561 free(v->uv_querier);
1562 v->uv_querier = NULL;
1563 v->uv_flags |= VIFF_QUERIER;
1570 * Returns the neighbor info struct for a given neighbor
1573 neighbor_info(vifi, addr)
1579 for (u = uvifs[vifi].uv_neighbors; u; u = u->al_next)
1580 if (u->al_addr == addr)
1586 static struct vnflags {
1590 { VIFF_DOWN, "down" },
1591 { VIFF_DISABLED, "disabled" },
1592 { VIFF_QUERIER, "querier" },
1593 { VIFF_ONEWAY, "one-way" },
1594 { VIFF_LEAF, "leaf" },
1595 { VIFF_IGMPV1, "IGMPv1" },
1596 { VIFF_REXMIT_PRUNES, "rexmit_prunes" },
1597 { VIFF_PASSIVE, "passive" },
1598 { VIFF_ALLOW_NONPRUNERS,"allow_nonpruners" },
1599 { VIFF_NOFLOOD, "noflood" },
1600 { VIFF_NOTRANSIT, "notransit" },
1601 { VIFF_BLASTER, "blaster" },
1602 { VIFF_FORCE_LEAF, "force_leaf" },
1603 { VIFF_OTUNNEL, "old-tunnel" },
1606 static struct vnflags nbrflags[] = {
1607 { NBRF_LEAF, "leaf" },
1608 { NBRF_GENID, "have-genid" },
1609 { NBRF_WAITING, "waiting" },
1610 { NBRF_ONEWAY, "one-way" },
1611 { NBRF_TOOOLD, "too old" },
1612 { NBRF_TOOMANYROUTES, "too many routes" },
1613 { NBRF_NOTPRUNING, "not pruning?" },
1617 * Print the contents of the uvifs array on file 'fp'.
1623 register vifi_t vifi;
1624 register struct uvif *v;
1625 register struct listaddr *a;
1626 register struct phaddr *p;
1627 register struct vif_acl *acl;
1629 struct sioc_vif_req v_req;
1634 fprintf(fp, "vifs_with_neighbors = %d\n", vifs_with_neighbors);
1636 if (vifs_with_neighbors == 1)
1637 fprintf(fp,"[This host is a leaf]\n\n");
1640 "\nVirtual Interface Table\n%s",
1641 "Vif Name Local-Address ");
1643 "M Thr Rate Flags\n");
1645 for (vifi = 0, v = uvifs; vifi < numvifs; vifi++, v++) {
1647 fprintf(fp, "%2u %6s %-15s %6s: %-18s %2u %3u %5u ",
1650 inet_fmt(v->uv_lcl_addr, s1),
1651 (v->uv_flags & VIFF_TUNNEL) ?
1654 (v->uv_flags & VIFF_TUNNEL) ?
1655 inet_fmt(v->uv_rmt_addr, s2) :
1656 inet_fmts(v->uv_subnet, v->uv_subnetmask, s3),
1661 for (i = 0; i < sizeof(vifflags) / sizeof(struct vnflags); i++)
1662 if (v->uv_flags & vifflags[i].vn_flag)
1663 fprintf(fp, " %s", vifflags[i].vn_name);
1667 fprintf(fp, " #routes: %d\n", v->uv_nroutes);
1669 if (v->uv_admetric != 0)
1670 fprintf(fp, " advert-metric %2u\n",
1673 label = "alternate subnets:";
1674 for (p = v->uv_addrs; p; p = p->pa_next) {
1675 fprintf(fp, " %18s %s\n", label,
1676 inet_fmts(p->pa_subnet, p->pa_subnetmask, s1));
1681 for (a = v->uv_neighbors; a != NULL; a = a->al_next) {
1682 fprintf(fp, " %6s %s (%d.%d) [%d]",
1683 label, inet_fmt(a->al_addr, s1), a->al_pv, a->al_mv,
1685 for (i = 0; i < sizeof(nbrflags) / sizeof(struct vnflags); i++)
1686 if (a->al_flags & nbrflags[i].vn_flag)
1687 fprintf(fp, " %s", nbrflags[i].vn_name);
1688 fprintf(fp, " up %s\n", scaletime(now - a->al_ctime));
1689 /*fprintf(fp, " #routes %d\n", a->al_nroutes);*/
1693 label = "group host (time left):";
1694 for (a = v->uv_groups; a != NULL; a = a->al_next) {
1695 fprintf(fp, " %23s %-15s %-15s (%s)\n",
1697 inet_fmt(a->al_addr, s1),
1698 inet_fmt(a->al_reporter, s2),
1699 scaletime(timer_leftTimer(a->al_timerid)));
1702 label = "boundaries:";
1703 for (acl = v->uv_acl; acl != NULL; acl = acl->acl_next) {
1704 fprintf(fp, " %11s %-18s\n", label,
1705 inet_fmts(acl->acl_addr, acl->acl_mask, s1));
1709 struct vf_element *vfe;
1712 sprintf(lbuf, "%5s %7s filter:",
1713 v->uv_filter->vf_flags & VFF_BIDIR ? "bidir"
1715 v->uv_filter->vf_type == VFT_ACCEPT ? "accept"
1718 for (vfe = v->uv_filter->vf_filter;
1719 vfe != NULL; vfe = vfe->vfe_next) {
1720 fprintf(fp, " %23s %-18s%s\n",
1722 inet_fmts(vfe->vfe_addr, vfe->vfe_mask, s1),
1723 vfe->vfe_flags & VFEF_EXACT ? " (exact)" : "");
1727 if (!(v->uv_flags & (VIFF_TUNNEL|VIFF_DOWN|VIFF_DISABLED))) {
1728 fprintf(fp, " IGMP querier: ");
1729 if (v->uv_querier == NULL)
1730 if (v->uv_flags & VIFF_QUERIER)
1731 fprintf(fp, "%-18s (this system)\n",
1732 inet_fmt(v->uv_lcl_addr, s1));
1734 fprintf(fp, "NONE - querier election failure?\n");
1736 fprintf(fp, "%-18s up %s last heard %s ago\n",
1737 inet_fmt(v->uv_querier->al_addr, s1),
1738 scaletime(now - v->uv_querier->al_ctime),
1739 scaletime(v->uv_querier->al_timer));
1741 if (v->uv_flags & VIFF_BLASTER)
1742 fprintf(fp, " blasterbuf size: %dk\n",
1743 v->uv_blasterlen / 1024);
1744 fprintf(fp, " Nbr bitmaps: 0x%08lx%08lx\n",/*XXX*/
1745 v->uv_nbrmap.hi, v->uv_nbrmap.lo);
1746 if (v->uv_prune_lifetime != 0)
1747 fprintf(fp, " Prune Lifetime: %d seconds\n",
1748 v->uv_prune_lifetime);
1752 if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) < 0) {
1753 log(LOG_WARNING, errno,
1754 "SIOCGETVIFCNT fails on vif %d", vifi);
1756 fprintf(fp, " pkts/bytes in : %lu/%lu\n",
1757 v_req.icount, v_req.ibytes);
1758 fprintf(fp, " pkts/bytes out: %lu/%lu\n",
1759 v_req.ocount, v_req.obytes);
1767 * Time out record of a group membership on a vif
1773 cbk_t *cbk = (cbk_t *)arg;
1774 vifi_t vifi = cbk->vifi;
1775 struct uvif *v = &uvifs[vifi];
1776 struct listaddr *a, **anp, *g = cbk->g;
1780 * delete all kernel cache entries with this group
1783 DeleteTimer(g->al_query);
1785 delete_lclgrp(vifi, g->al_addr);
1787 anp = &(v->uv_groups);
1788 while ((a = *anp) != NULL) {
1801 * Set a timer to delete the record of a group membership on a vif.
1810 cbk = (cbk_t *) malloc(sizeof(cbk_t));
1813 return timer_setTimer(g->al_timer, DelVif, cbk);
1817 * Delete a timer that was set above.
1823 timer_clearTimer(id);
1828 * Send a group-specific query.
1834 cbk_t *cbk = (cbk_t *)arg;
1835 register struct uvif *v = &uvifs[cbk->vifi];
1837 send_igmp(v->uv_lcl_addr, cbk->g->al_addr,
1838 IGMP_MEMBERSHIP_QUERY,
1839 cbk->q_time, cbk->g->al_addr, 0);
1840 cbk->g->al_query = 0;
1845 * Set a timer to send a group-specific query.
1848 SetQueryTimer(g, vifi, to_expire, q_time)
1851 int to_expire, q_time;
1855 cbk = (cbk_t *) malloc(sizeof(cbk_t));
1857 cbk->q_time = q_time;
1859 return timer_setTimer(to_expire, SendQuery, cbk);