summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhasso <hasso>2005-04-05 14:36:49 +0000
committerhasso <hasso>2005-04-05 14:36:49 +0000
commit5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (patch)
treed91dd49e4ed2c03cd0c007660232716f11172a56
parent6a52470660000bb6ddba971dc5c40b3422ab49bc (diff)
* lib/prefix.[hc]: inet6_ntoa utility function copied from
ripngd/ripngd.c (inet6_ntop). * ripngd.[hc]: Remove inet6_ntop() and any usage of it. inet6_ntoa() from lib is used now. * ripng_interface.c: inet6_ntop() -> inet6_ntoa(). * ripng_peer.c: inet6_ntop() -> inet6_ntoa().
-rw-r--r--lib/ChangeLog5
-rw-r--r--lib/prefix.c11
-rw-r--r--lib/prefix.h2
-rw-r--r--ripngd/ChangeLog7
-rw-r--r--ripngd/ripng_interface.c2
-rw-r--r--ripngd/ripng_peer.c2
-rw-r--r--ripngd/ripngd.c99
-rw-r--r--ripngd/ripngd.h2
8 files changed, 71 insertions, 59 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 57bb3d1c..ee20de84 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2004-04-05 Hasso Tepper <hasso at quagga.net>
+
+ * lib/prefix.[hc]: inet6_ntoa utility function copied from
+ ripngd/ripngd.c (inet6_ntop).
+
2004-04-05 Paul Jakma <paul@dishone.st>
* vty.c: Improve logging of failures to open vty socket(s).
diff --git a/lib/prefix.c b/lib/prefix.c
index 82075442..56539fc9 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -735,3 +735,14 @@ netmask_str2prefix_str (const char *net_str, const char *mask_str,
return 1;
}
+#ifdef HAVE_IPV6
+/* Utility function for making IPv6 address string. */
+const char *
+inet6_ntoa (struct in6_addr *addr)
+{
+ static char 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 0546095b..7ef53473 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -173,6 +173,8 @@ 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 *);
+
#endif /* HAVE_IPV6 */
int all_digit (const char *);
diff --git a/ripngd/ChangeLog b/ripngd/ChangeLog
index 7c6176c5..78e1107f 100644
--- a/ripngd/ChangeLog
+++ b/ripngd/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-05 Hasso Tepper <hasso at quagga.net>
+
+ * ripngd.[hc]: Remove inet6_ntop() and any usage of it. inet6_ntoa()
+ from lib is used now.
+ * ripng_interface.c: inet6_ntop() -> inet6_ntoa().
+ * ripng_peer.c: inet6_ntop() -> inet6_ntoa().
+
2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ripng_interface.c: (ripng_interface_delete) After deleting, set
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 477bfd7f..6d5d468c 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -441,7 +441,7 @@ ripng_interface_address_add (int command, struct zclient *zclient,
{
if (IS_RIPNG_DEBUG_ZEBRA)
zlog_debug ("RIPng connected address %s/%d add",
- inet6_ntop(&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 b9af930c..66282614 100644
--- a/ripngd/ripng_peer.c
+++ b/ripngd/ripng_peer.c
@@ -197,7 +197,7 @@ ripng_peer_display (struct vty *vty)
LIST_LOOP (peer_list, peer, nn)
{
- vty_out (vty, " %s %s%14s %10d %10d %10d %s%s", inet6_ntop (&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 34282b8e..b6b5f5ae 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -72,17 +72,6 @@ struct ripng_nexthop
} flag;
struct in6_addr address;
};
-
-/* Utility function for making IPv6 address string. */
-const char *
-inet6_ntop (struct in6_addr *p)
-{
- static char buf[INET6_ADDRSTRLEN];
-
- inet_ntop (AF_INET6, p, buf, INET6_ADDRSTRLEN);
-
- return buf;
-}
int
ripng_route_rte (struct ripng_info *rinfo)
@@ -176,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_ntop (&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);
}
@@ -224,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_ntop (&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));
}
@@ -320,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_ntop (&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_ntop (&rte->addr), rte->prefixlen,
+ inet6_ntoa (&rte->addr), rte->prefixlen,
rte->metric, ntohs (rte->tag));
}
}
@@ -339,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_ntop (&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_ntop (&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_ntop (&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
@@ -378,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_ntop (&rte->addr),
+ inet6_ntoa (&rte->addr),
inet_ntop (AF_INET6, &from->sin6_addr, buf, INET6_BUFSIZ));
nexthop->flag = RIPNG_NEXTHOP_UNSPEC;
@@ -497,7 +486,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
return -1;
}
}
@@ -508,7 +497,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
return -1;
}
}
@@ -528,7 +517,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
return -1;
}
}
@@ -544,7 +533,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
return -1;
}
}
@@ -567,7 +556,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
return -1;
}
}
@@ -578,7 +567,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
return -1;
}
}
@@ -598,7 +587,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
return -1;
}
}
@@ -614,7 +603,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
return -1;
}
}
@@ -683,7 +672,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_ntop (&p.prefix), p.prefixlen);
+ inet6_ntoa (&p.prefix), p.prefixlen);
return;
}
@@ -1005,11 +994,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_ntop(&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_ntop(&p->prefix), p->prefixlen, inet6_ntop(nexthop),
+ inet6_ntoa(&p->prefix), p->prefixlen, inet6_ntoa(nexthop),
ifindex2ifname(ifindex));
}
@@ -1062,7 +1051,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_ntop(&p->prefix), p->prefixlen,
+ inet6_ntoa(&p->prefix), p->prefixlen,
ifindex2ifname(ifindex));
ripng_event (RIPNG_TRIGGERED_UPDATE, 0);
@@ -1101,7 +1090,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_ntop(&p->prefix), p->prefixlen,
+ inet6_ntoa(&p->prefix), p->prefixlen,
ifindex2ifname(rinfo->ifindex));
}
@@ -1125,7 +1114,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_ntop (&from->sin6_addr));
+ ntohs (from->sin6_port), inet6_ntoa (&from->sin6_addr));
ripng_peer_bad_packet (from);
return;
}
@@ -1136,7 +1125,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_ntop (&from->sin6_addr));
+ inet6_ntoa (&from->sin6_addr));
ripng_peer_bad_packet (from);
return;
}
@@ -1149,7 +1138,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_ntop (&from->sin6_addr));
+ inet6_ntoa (&from->sin6_addr));
ripng_peer_bad_packet (from);
return;
}
@@ -1161,7 +1150,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_ntop (&from->sin6_addr));
+ hoplimit, inet6_ntoa (&from->sin6_addr));
ripng_peer_bad_packet (from);
return;
}
@@ -1195,21 +1184,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_ntop (&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_ntop (&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_ntop (&rte->addr), rte->prefixlen, rte->metric);
+ inet6_ntoa (&rte->addr), rte->prefixlen, rte->metric);
ripng_peer_bad_route (from);
continue;
}
@@ -1219,8 +1208,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_ntop (&rte->addr), rte->prefixlen,
- inet6_ntop (&from->sin6_addr), ifp->name);
+ inet6_ntoa (&rte->addr), rte->prefixlen,
+ inet6_ntoa (&from->sin6_addr), ifp->name);
ripng_peer_bad_route (from);
continue;
}
@@ -1229,7 +1218,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_ntop (&from->sin6_addr), ifp->name);
+ inet6_ntoa (&from->sin6_addr), ifp->name);
ripng_peer_bad_route (from);
continue;
}
@@ -1369,7 +1358,7 @@ ripng_read (struct thread *thread)
if (((len - 4) % 20) != 0)
{
zlog_warn ("RIPng invalid packet size %d from %s", len,
- inet6_ntop (&from.sin6_addr));
+ inet6_ntoa (&from.sin6_addr));
ripng_peer_bad_packet (&from);
return 0;
}
@@ -1380,7 +1369,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_ntop (&from.sin6_addr), ntohs (from.sin6_port),
+ inet6_ntoa (&from.sin6_addr), ntohs (from.sin6_port),
ifp ? ifp->name : "unknown");
/* Logging before packet checking. */
@@ -1614,7 +1603,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_ntop(&to->sin6_addr));
+ inet6_ntoa(&to->sin6_addr));
else
zlog_debug ("RIPng update routes on interface %s", ifp->name);
}
@@ -1683,7 +1672,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
continue;
}
@@ -1702,7 +1691,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
continue;
}
}
@@ -1788,7 +1777,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_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
continue;
}
@@ -2053,10 +2042,10 @@ DEFUN (show_ipv6_ripng,
#ifdef DEBUG
len = vty_out (vty, "R(a) %d/%d %s/%d ",
aggregate->count, aggregate->suppress,
- inet6_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
#else
len = vty_out (vty, "R(a) %s/%d ",
- inet6_ntop (&p->prefix), p->prefixlen);
+ inet6_ntoa (&p->prefix), p->prefixlen);
#endif /* DEBUG */
vty_out (vty, "%s", VTY_NEWLINE);
vty_out (vty, "%*s", 18, " ");
@@ -2076,16 +2065,16 @@ DEFUN (show_ipv6_ripng,
route_info[rinfo->type].str,
ripng_route_subtype_print(rinfo),
rinfo->suppress,
- inet6_ntop (&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_ntop (&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_ntop (&rinfo->nexthop));
+ len = vty_out (vty, "%s", inet6_ntoa (&rinfo->nexthop));
len = 28 - len;
if (len > 0)
@@ -2688,7 +2677,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_ntop (&rp->p.u.prefix6),
+ inet6_ntoa (&rp->p.u.prefix6),
rp->p.prefixlen,
VTY_NEWLINE);
@@ -2696,7 +2685,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_ntop (&rp->p.u.prefix6),
+ vty_out (vty, " route %s/%d%s", inet6_ntoa (&rp->p.u.prefix6),
rp->p.prefixlen,
VTY_NEWLINE);
diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h
index bf69af44..68da71da 100644
--- a/ripngd/ripngd.h
+++ b/ripngd/ripngd.h
@@ -388,8 +388,6 @@ void ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop, u
void ripng_redistribute_clean ();
-const char *inet6_ntop (struct in6_addr *p);
-
int ripng_write_rte (int num, struct stream *s, struct prefix_ipv6 *p,
struct in6_addr *nexthop, u_int16_t tag, u_char metric);
int ripng_send_packet (caddr_t buf, int bufsize, struct sockaddr_in6 *to,