X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=zebra%2Firdp_interface.c;h=8742b62b8cc8572a9a1af508ea55037af9636449;hb=271ee735ed3a42a1fe52f6401ddf72bd5d3e4f10;hp=5f913856b5455cd1621984c57a3ef6c6cf23d2ec;hpb=2da40f4919f6268d4935c42a358739ffdf3a48dc;p=mirror_frr.git diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index 5f913856b..8742b62b8 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -65,14 +65,19 @@ /* Master of threads. */ extern struct zebra_t zebrad; -int in_cksum (void *ptr, int nbytes); extern int irdp_sock; -int irdp_send_thread(struct thread *t_advert); -char *inet_2a(u_int32_t a, char *b); -void irdp_advert_off(struct interface *ifp); +static const char * +inet_2a(u_int32_t a, char *b) +{ + sprintf(b, "%u.%u.%u.%u", + (a ) & 0xFF, + (a>> 8) & 0xFF, + (a>>16) & 0xFF, + (a>>24) & 0xFF); + return b; +} -char b1[16], b2[16], b3[16], b4[16]; /* For inet_2a */ static struct prefix * irdp_get_prefix(struct interface *ifp) @@ -81,7 +86,7 @@ irdp_get_prefix(struct interface *ifp) struct connected *ifc; if (ifp->connected) - LIST_LOOP (ifp->connected, ifc, node) + for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc)) return ifc->address; return NULL; @@ -98,10 +103,11 @@ if_group (struct interface *ifp, struct ip_mreq m; struct prefix *p; int ret; + char b1[INET_ADDRSTRLEN]; zi = ifp->info; - bzero (&m, sizeof (m)); + memset (&m, 0, sizeof (m)); m.imr_multiaddr.s_addr = htonl (group); p = irdp_get_prefix(ifp); @@ -117,8 +123,8 @@ if_group (struct interface *ifp, if (ret < 0) zlog_warn ("IRDP: %s can't setsockopt %s: %s", add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group", - inet_2a(group, b1), - safe_strerror (errno)); + inet_2a(group, b1), + safe_strerror (errno)); return ret; } @@ -129,6 +135,7 @@ if_add_group (struct interface *ifp) struct zebra_if *zi= ifp->info; struct irdp_interface *irdp = &zi->irdp; int ret; + char b1[INET_ADDRSTRLEN]; ret = if_group (ifp, irdp_sock, INADDR_ALLRTRS_GROUP, IP_ADD_MEMBERSHIP); if (ret < 0) { @@ -148,6 +155,7 @@ if_drop_group (struct interface *ifp) struct zebra_if *zi= ifp->info; struct irdp_interface *irdp = &zi->irdp; int ret; + char b1[INET_ADDRSTRLEN]; ret = if_group (ifp, irdp_sock, INADDR_ALLRTRS_GROUP, IP_DROP_MEMBERSHIP); if (ret < 0) @@ -173,12 +181,9 @@ if_set_defaults(struct interface *ifp) } -struct Adv *Adv_new (void) +static struct Adv *Adv_new (void) { - struct Adv *new; - new = XMALLOC (MTYPE_TMP, sizeof (struct Adv)); - memset (new, 0, sizeof (struct Adv)); - return new; + return XCALLOC (MTYPE_TMP, sizeof (struct Adv)); } static void @@ -235,7 +240,7 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults) seed = 0; if( ifp->connected) - LIST_LOOP (ifp->connected, ifc, node) + for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc)) { seed = ifc->address->u.prefix4.s_addr; break; @@ -341,6 +346,7 @@ void irdp_config_write (struct vty *vty, struct interface *ifp) struct irdp_interface *irdp=&zi->irdp; struct Adv *adv; struct listnode *node; + char b1[INET_ADDRSTRLEN]; if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) { @@ -355,7 +361,7 @@ void irdp_config_write (struct vty *vty, struct interface *ifp) vty_out (vty, " ip irdp preference %ld%s", irdp->Preference, VTY_NEWLINE); - LIST_LOOP (irdp->AdvPrefList, adv, node) + for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv)) vty_out (vty, " ip irdp address %s preference %d%s", inet_2a(adv->ip.s_addr, b1), adv->pref, @@ -610,7 +616,7 @@ DEFUN (ip_irdp_address_preference, pref = atoi(argv[1]); - LIST_LOOP (irdp->AdvPrefList, adv, node) + for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv)) if(adv->ip.s_addr == ip.s_addr) return CMD_SUCCESS; @@ -656,11 +662,8 @@ DEFUN (no_ip_irdp_address_preference, pref = atoi(argv[1]); - for (node = listhead (irdp->AdvPrefList); node; node = nnode) + for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv)) { - nnode = node->next; - adv = getdata (node); - if(adv->ip.s_addr == ip.s_addr ) { listnode_delete(irdp->AdvPrefList, adv);