From 3a2ce6a14e3e302c3fdca2ff99143cfd06b145e6 Mon Sep 17 00:00:00 2001 From: hasso Date: Fri, 8 Apr 2005 01:30:51 +0000 Subject: * prefix.[hc]: Pass argument to the inet6_ntoa by value making it more inet_ntoa alike. * ripngd.[hc], ripng_interface.c, ripng_peer.c: inet6_ntoa() takes argument now by value. --- lib/ChangeLog | 5 +++ lib/prefix.c | 4 +-- lib/prefix.h | 2 +- ripngd/ChangeLog | 5 +++ ripngd/ripng_interface.c | 2 +- ripngd/ripng_peer.c | 2 +- ripngd/ripngd.c | 88 ++++++++++++++++++++++++------------------------ 7 files changed, 59 insertions(+), 49 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 3473257a..1d3d3e6d 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2005-04-08 Hasso Tepper + + * prefix.[hc]: Pass argument to the inet6_ntoa by value making it more + inet_ntoa alike. + 2005-04-07 Paul Jakma * linklist.h: Add usage comments. diff --git a/lib/prefix.c b/lib/prefix.c index 56539fc9..2e594aa0 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -738,11 +738,11 @@ netmask_str2prefix_str (const char *net_str, const char *mask_str, #ifdef HAVE_IPV6 /* Utility function for making IPv6 address string. */ const char * -inet6_ntoa (struct in6_addr *addr) +inet6_ntoa (struct in6_addr addr) { static char buf[INET6_ADDRSTRLEN]; - inet_ntop (AF_INET6, addr, buf, INET6_ADDRSTRLEN); + inet_ntop (AF_INET6, &addr, buf, INET6_ADDRSTRLEN); return buf; } #endif /* HAVE_IPV6 */ diff --git a/lib/prefix.h b/lib/prefix.h index 7ef53473..506d644e 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -173,7 +173,7 @@ int ip6_masklen (struct in6_addr); void masklen2ip6 (int, struct in6_addr *); void str2in6_addr (const char *, struct in6_addr *); -const char *inet6_ntoa (struct in6_addr *); +const char *inet6_ntoa (struct in6_addr); #endif /* HAVE_IPV6 */ diff --git a/ripngd/ChangeLog b/ripngd/ChangeLog index 78e1107f..ee13c927 100644 --- a/ripngd/ChangeLog +++ b/ripngd/ChangeLog @@ -1,3 +1,8 @@ +2005-04-08 Hasso Tepper + + * ripngd.[hc], ripng_interface.c, ripng_peer.c: inet6_ntoa() takes + argument now by value. + 2005-04-05 Hasso Tepper * ripngd.[hc]: Remove inet6_ntop() and any usage of it. inet6_ntoa() diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index d2fa3d60..52a1fe24 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -437,7 +437,7 @@ ripng_interface_address_add (int command, struct zclient *zclient, { if (IS_RIPNG_DEBUG_ZEBRA) zlog_debug ("RIPng connected address %s/%d add", - inet6_ntoa(&p->u.prefix6), + inet6_ntoa(p->u.prefix6), p->prefixlen); /* Check is this prefix needs to be redistributed. */ diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index bfbade50..34f5ac6c 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -197,7 +197,7 @@ ripng_peer_display (struct vty *vty) for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer)) { - vty_out (vty, " %s %s%14s %10d %10d %10d %s%s", inet6_ntoa (&peer->addr), + vty_out (vty, " %s %s%14s %10d %10d %10d %s%s", inet6_ntoa (peer->addr), VTY_NEWLINE, " ", peer->recv_badpackets, peer->recv_badroutes, ZEBRA_RIPNG_DISTANCE_DEFAULT, diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index ec6c4d04..453637c3 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -165,7 +165,7 @@ ripng_send_packet (caddr_t buf, int bufsize, struct sockaddr_in6 *to, if (IS_RIPNG_DEBUG_SEND) { if (to) - zlog_debug ("send to %s", inet6_ntoa (&to->sin6_addr)); + zlog_debug ("send to %s", inet6_ntoa (to->sin6_addr)); zlog_debug (" send interface %s", ifp->name); zlog_debug (" send packet size %d", bufsize); } @@ -213,7 +213,7 @@ ripng_send_packet (caddr_t buf, int bufsize, struct sockaddr_in6 *to, if (ret < 0) { if (to) zlog_err ("RIPng send fail on %s to %s: %s", ifp->name, - inet6_ntoa (&to->sin6_addr), safe_strerror (errno)); + inet6_ntoa (to->sin6_addr), safe_strerror (errno)); else zlog_err ("RIPng send fail on %s: %s", ifp->name, safe_strerror (errno)); } @@ -309,10 +309,10 @@ ripng_packet_dump (struct ripng_packet *packet, int size, const char *sndrcv) for (lim = (caddr_t) packet + size; (caddr_t) rte < lim; rte++) { if (rte->metric == RIPNG_METRIC_NEXTHOP) - zlog_debug (" nexthop %s/%d", inet6_ntoa (&rte->addr), rte->prefixlen); + zlog_debug (" nexthop %s/%d", inet6_ntoa (rte->addr), rte->prefixlen); else zlog_debug (" %s/%d metric %d tag %d", - inet6_ntoa (&rte->addr), rte->prefixlen, + inet6_ntoa (rte->addr), rte->prefixlen, rte->metric, ntohs (rte->tag)); } } @@ -328,18 +328,18 @@ ripng_nexthop_rte (struct rte *rte, /* Logging before checking RTE. */ if (IS_RIPNG_DEBUG_RECV) zlog_debug ("RIPng nexthop RTE address %s tag %d prefixlen %d", - inet6_ntoa (&rte->addr), ntohs (rte->tag), rte->prefixlen); + inet6_ntoa (rte->addr), ntohs (rte->tag), rte->prefixlen); /* RFC2080 2.1.1 Next Hop: The route tag and prefix length in the next hop RTE must be set to zero on sending and ignored on receiption. */ if (ntohs (rte->tag) != 0) zlog_warn ("RIPng nexthop RTE with non zero tag value %d from %s", - ntohs (rte->tag), inet6_ntoa (&from->sin6_addr)); + ntohs (rte->tag), inet6_ntoa (from->sin6_addr)); if (rte->prefixlen != 0) zlog_warn ("RIPng nexthop RTE with non zero prefixlen value %d from %s", - rte->prefixlen, inet6_ntoa (&from->sin6_addr)); + rte->prefixlen, inet6_ntoa (from->sin6_addr)); /* Specifying a value of 0:0:0:0:0:0:0:0 in the prefix field of a next hop RTE indicates that the next hop address should be the @@ -367,7 +367,7 @@ ripng_nexthop_rte (struct rte *rte, valid, route may be taken. If the received next hop address is not a link-local address, it should be treated as 0:0:0:0:0:0:0:0. */ zlog_warn ("RIPng nexthop RTE with non link-local address %s from %s", - inet6_ntoa (&rte->addr), + inet6_ntoa (rte->addr), inet_ntop (AF_INET6, &from->sin6_addr, buf, INET6_BUFSIZ)); nexthop->flag = RIPNG_NEXTHOP_UNSPEC; @@ -485,7 +485,7 @@ ripng_incoming_filter (struct prefix_ipv6 *p, struct ripng_interface *ri) { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d filtered by distribute in", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); return -1; } } @@ -496,7 +496,7 @@ ripng_incoming_filter (struct prefix_ipv6 *p, struct ripng_interface *ri) { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d filtered by prefix-list in", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); return -1; } } @@ -516,7 +516,7 @@ ripng_incoming_filter (struct prefix_ipv6 *p, struct ripng_interface *ri) { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d filtered by distribute in", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); return -1; } } @@ -532,7 +532,7 @@ ripng_incoming_filter (struct prefix_ipv6 *p, struct ripng_interface *ri) { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d filtered by prefix-list in", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); return -1; } } @@ -555,7 +555,7 @@ ripng_outgoing_filter (struct prefix_ipv6 *p, struct ripng_interface *ri) { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d is filtered by distribute out", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); return -1; } } @@ -566,7 +566,7 @@ ripng_outgoing_filter (struct prefix_ipv6 *p, struct ripng_interface *ri) { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d is filtered by prefix-list out", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); return -1; } } @@ -586,7 +586,7 @@ ripng_outgoing_filter (struct prefix_ipv6 *p, struct ripng_interface *ri) { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d filtered by distribute out", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); return -1; } } @@ -602,7 +602,7 @@ ripng_outgoing_filter (struct prefix_ipv6 *p, struct ripng_interface *ri) { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("%s/%d filtered by prefix-list out", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); return -1; } } @@ -671,7 +671,7 @@ ripng_route_process (struct rte *rte, struct sockaddr_in6 *from, { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("RIPng %s/%d is filtered by route-map in", - inet6_ntoa (&p.prefix), p.prefixlen); + inet6_ntoa (p.prefix), p.prefixlen); return; } @@ -993,11 +993,11 @@ ripng_redistribute_add (int type, int sub_type, struct prefix_ipv6 *p, if (IS_RIPNG_DEBUG_EVENT) { if (!nexthop) zlog_debug ("Redistribute new prefix %s/%d on the interface %s", - inet6_ntoa(&p->prefix), p->prefixlen, + inet6_ntoa(p->prefix), p->prefixlen, ifindex2ifname(ifindex)); else zlog_debug ("Redistribute new prefix %s/%d with nexthop %s on the interface %s", - inet6_ntoa(&p->prefix), p->prefixlen, inet6_ntoa(nexthop), + inet6_ntoa(p->prefix), p->prefixlen, inet6_ntoa(*nexthop), ifindex2ifname(ifindex)); } @@ -1050,7 +1050,7 @@ ripng_redistribute_delete (int type, int sub_type, struct prefix_ipv6 *p, if (IS_RIPNG_DEBUG_EVENT) zlog_debug ("Poisone %s/%d on the interface %s with an infinity metric [delete]", - inet6_ntoa(&p->prefix), p->prefixlen, + inet6_ntoa(p->prefix), p->prefixlen, ifindex2ifname(ifindex)); ripng_event (RIPNG_TRIGGERED_UPDATE, 0); @@ -1089,7 +1089,7 @@ ripng_redistribute_withdraw (int type) struct prefix_ipv6 *p = (struct prefix_ipv6 *) &rp->p; zlog_debug ("Poisone %s/%d on the interface %s [withdraw]", - inet6_ntoa(&p->prefix), p->prefixlen, + inet6_ntoa(p->prefix), p->prefixlen, ifindex2ifname(rinfo->ifindex)); } @@ -1113,7 +1113,7 @@ ripng_response_process (struct ripng_packet *packet, int size, if (ntohs (from->sin6_port) != RIPNG_PORT_DEFAULT) { zlog_warn ("RIPng packet comes from non RIPng port %d from %s", - ntohs (from->sin6_port), inet6_ntoa (&from->sin6_addr)); + ntohs (from->sin6_port), inet6_ntoa (from->sin6_addr)); ripng_peer_bad_packet (from); return; } @@ -1124,7 +1124,7 @@ ripng_response_process (struct ripng_packet *packet, int size, if (! IN6_IS_ADDR_LINKLOCAL(&from->sin6_addr)) { zlog_warn ("RIPng packet comes from non link local address %s", - inet6_ntoa (&from->sin6_addr)); + inet6_ntoa (from->sin6_addr)); ripng_peer_bad_packet (from); return; } @@ -1137,7 +1137,7 @@ ripng_response_process (struct ripng_packet *packet, int size, if (ripng_lladdr_check (ifp, &from->sin6_addr)) { zlog_warn ("RIPng packet comes from my own link local address %s", - inet6_ntoa (&from->sin6_addr)); + inet6_ntoa (from->sin6_addr)); ripng_peer_bad_packet (from); return; } @@ -1149,7 +1149,7 @@ ripng_response_process (struct ripng_packet *packet, int size, if (hoplimit >= 0 && hoplimit != 255) { zlog_warn ("RIPng packet comes with non 255 hop count %d from %s", - hoplimit, inet6_ntoa (&from->sin6_addr)); + hoplimit, inet6_ntoa (from->sin6_addr)); ripng_peer_bad_packet (from); return; } @@ -1183,21 +1183,21 @@ ripng_response_process (struct ripng_packet *packet, int size, if (IN6_IS_ADDR_MULTICAST (&rte->addr)) { zlog_warn ("Destination prefix is a multicast address %s/%d [%d]", - inet6_ntoa (&rte->addr), rte->prefixlen, rte->metric); + inet6_ntoa (rte->addr), rte->prefixlen, rte->metric); ripng_peer_bad_route (from); continue; } if (IN6_IS_ADDR_LINKLOCAL (&rte->addr)) { zlog_warn ("Destination prefix is a link-local address %s/%d [%d]", - inet6_ntoa (&rte->addr), rte->prefixlen, rte->metric); + inet6_ntoa (rte->addr), rte->prefixlen, rte->metric); ripng_peer_bad_route (from); continue; } if (IN6_IS_ADDR_LOOPBACK (&rte->addr)) { zlog_warn ("Destination prefix is a loopback address %s/%d [%d]", - inet6_ntoa (&rte->addr), rte->prefixlen, rte->metric); + inet6_ntoa (rte->addr), rte->prefixlen, rte->metric); ripng_peer_bad_route (from); continue; } @@ -1207,8 +1207,8 @@ ripng_response_process (struct ripng_packet *packet, int size, if (rte->prefixlen > 128) { zlog_warn ("Invalid prefix length %s/%d from %s%%%s", - inet6_ntoa (&rte->addr), rte->prefixlen, - inet6_ntoa (&from->sin6_addr), ifp->name); + inet6_ntoa (rte->addr), rte->prefixlen, + inet6_ntoa (from->sin6_addr), ifp->name); ripng_peer_bad_route (from); continue; } @@ -1217,7 +1217,7 @@ ripng_response_process (struct ripng_packet *packet, int size, if (! (rte->metric >= 1 && rte->metric <= 16)) { zlog_warn ("Invalid metric %d from %s%%%s", rte->metric, - inet6_ntoa (&from->sin6_addr), ifp->name); + inet6_ntoa (from->sin6_addr), ifp->name); ripng_peer_bad_route (from); continue; } @@ -1357,7 +1357,7 @@ ripng_read (struct thread *thread) if (((len - 4) % 20) != 0) { zlog_warn ("RIPng invalid packet size %d from %s", len, - inet6_ntoa (&from.sin6_addr)); + inet6_ntoa (from.sin6_addr)); ripng_peer_bad_packet (&from); return 0; } @@ -1368,7 +1368,7 @@ ripng_read (struct thread *thread) /* RIPng packet received. */ if (IS_RIPNG_DEBUG_EVENT) zlog_debug ("RIPng packet received from %s port %d on %s", - inet6_ntoa (&from.sin6_addr), ntohs (from.sin6_port), + inet6_ntoa (from.sin6_addr), ntohs (from.sin6_port), ifp ? ifp->name : "unknown"); /* Logging before packet checking. */ @@ -1600,7 +1600,7 @@ ripng_output_process (struct interface *ifp, struct sockaddr_in6 *to, if (IS_RIPNG_DEBUG_EVENT) { if (to) zlog_debug ("RIPng update routes to neighbor %s", - inet6_ntoa(&to->sin6_addr)); + inet6_ntoa(to->sin6_addr)); else zlog_debug ("RIPng update routes on interface %s", ifp->name); } @@ -1669,7 +1669,7 @@ ripng_output_process (struct interface *ifp, struct sockaddr_in6 *to, { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("RIPng %s/%d is filtered by route-map out", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); continue; } @@ -1688,7 +1688,7 @@ ripng_output_process (struct interface *ifp, struct sockaddr_in6 *to, { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("RIPng %s/%d is filtered by route-map", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); continue; } } @@ -1774,7 +1774,7 @@ ripng_output_process (struct interface *ifp, struct sockaddr_in6 *to, { if (IS_RIPNG_DEBUG_PACKET) zlog_debug ("RIPng %s/%d is filtered by route-map out", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); continue; } @@ -2039,10 +2039,10 @@ DEFUN (show_ipv6_ripng, #ifdef DEBUG len = vty_out (vty, "R(a) %d/%d %s/%d ", aggregate->count, aggregate->suppress, - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); #else len = vty_out (vty, "R(a) %s/%d ", - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); #endif /* DEBUG */ vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "%*s", 18, " "); @@ -2062,16 +2062,16 @@ DEFUN (show_ipv6_ripng, route_info[rinfo->type].str, ripng_route_subtype_print(rinfo), rinfo->suppress, - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); #else len = vty_out (vty, "%s(%s) %s/%d ", route_info[rinfo->type].str, ripng_route_subtype_print(rinfo), - inet6_ntoa (&p->prefix), p->prefixlen); + inet6_ntoa (p->prefix), p->prefixlen); #endif /* DEBUG */ vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "%*s", 18, " "); - len = vty_out (vty, "%s", inet6_ntoa (&rinfo->nexthop)); + len = vty_out (vty, "%s", inet6_ntoa (rinfo->nexthop)); len = 28 - len; if (len > 0) @@ -2673,7 +2673,7 @@ ripng_config_write (struct vty *vty) for (rp = route_top (ripng->aggregate); rp; rp = route_next (rp)) if (rp->info != NULL) vty_out (vty, " aggregate-address %s/%d%s", - inet6_ntoa (&rp->p.u.prefix6), + inet6_ntoa (rp->p.u.prefix6), rp->p.prefixlen, VTY_NEWLINE); @@ -2681,7 +2681,7 @@ ripng_config_write (struct vty *vty) /* RIPng static routes. */ for (rp = route_top (ripng->route); rp; rp = route_next (rp)) if (rp->info != NULL) - vty_out (vty, " route %s/%d%s", inet6_ntoa (&rp->p.u.prefix6), + vty_out (vty, " route %s/%d%s", inet6_ntoa (rp->p.u.prefix6), rp->p.prefixlen, VTY_NEWLINE); -- cgit v1.2.1