Diff for /embedaddon/quagga/lib/prefix.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2012/10/09 09:22:28 version 1.1.1.3, 2016/11/02 10:09:11
Line 27 Line 27
 #include "sockunion.h"  #include "sockunion.h"
 #include "memory.h"  #include "memory.h"
 #include "log.h"  #include "log.h"
 /* Maskbit. */  /* Maskbit. */
 static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,  static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
                                  0xf8, 0xfc, 0xfe, 0xff};                                   0xf8, 0xfc, 0xfe, 0xff};
Line 186  prefix6_bit (const struct in6_addr *prefix, const u_ch Line 186  prefix6_bit (const struct in6_addr *prefix, const u_ch
 {  {
   return prefix_bit((const u_char *) &prefix->s6_addr, prefixlen);    return prefix_bit((const u_char *) &prefix->s6_addr, prefixlen);
 }  }
 int
 str2family(const char *string)
 {
   if (!strcmp("ipv4", string))
     return AF_INET;
   else if (!strcmp("ipv6", string))
     return AF_INET6;
   else
     return -1;
 }
 
 /* Address Famiy Identifier to Address Family converter. */  /* Address Famiy Identifier to Address Family converter. */
 int  int
 afi2family (afi_t afi)  afi2family (afi_t afi)
Line 212  family2afi (int family) Line 223  family2afi (int family)
   return 0;    return 0;
 }  }
   
   const char *
   safi2str(safi_t safi)
   {
     switch (safi) {
       case SAFI_UNICAST:
           return "unicast";
       case SAFI_MULTICAST:
           return "multicast";
       case SAFI_ENCAP:
           return "encap";
       case SAFI_MPLS_VPN:
           return "vpn";
     }
     return NULL;
   }
   
 /* If n includes p prefix then return 1 else return 0. */  /* If n includes p prefix then return 1 else return 0. */
 int  int
 prefix_match (const struct prefix *n, const struct prefix *p)  prefix_match (const struct prefix *n, const struct prefix *p)
Line 494  prefix_ipv4_any (const struct prefix_ipv4 *p) Line 521  prefix_ipv4_any (const struct prefix_ipv4 *p)
 {  {
   return (p->prefix.s_addr == 0 && p->prefixlen == 0);    return (p->prefix.s_addr == 0 && p->prefixlen == 0);
 }  }
 #ifdef HAVE_IPV6  #ifdef HAVE_IPV6
   
 /* Allocate a new ip version 6 route */  /* Allocate a new ip version 6 route */
Line 681  sockunion2prefix (const union sockunion *dest, Line 708  sockunion2prefix (const union sockunion *dest,
   
 /* Utility function of convert between struct prefix <=> union sockunion. */  /* Utility function of convert between struct prefix <=> union sockunion. */
 struct prefix *  struct prefix *
sockunion2hostprefix (const union sockunion *su)sockunion2hostprefix (const union sockunion *su, struct prefix *prefix)
 {  {
   if (su->sa.sa_family == AF_INET)    if (su->sa.sa_family == AF_INET)
     {      {
       struct prefix_ipv4 *p;        struct prefix_ipv4 *p;
   
      p = prefix_ipv4_new ();      p = prefix ? (struct prefix_ipv4 *) prefix : prefix_ipv4_new ();
       p->family = AF_INET;        p->family = AF_INET;
       p->prefix = su->sin.sin_addr;        p->prefix = su->sin.sin_addr;
       p->prefixlen = IPV4_MAX_BITLEN;        p->prefixlen = IPV4_MAX_BITLEN;
Line 698  sockunion2hostprefix (const union sockunion *su) Line 725  sockunion2hostprefix (const union sockunion *su)
     {      {
       struct prefix_ipv6 *p;        struct prefix_ipv6 *p;
   
      p = prefix_ipv6_new ();      p = prefix ? (struct prefix_ipv6 *) prefix : prefix_ipv6_new ();
       p->family = AF_INET6;        p->family = AF_INET6;
       p->prefixlen = IPV6_MAX_BITLEN;        p->prefixlen = IPV6_MAX_BITLEN;
       memcpy (&p->prefix, &su->sin6.sin6_addr, sizeof (struct in6_addr));        memcpy (&p->prefix, &su->sin6.sin6_addr, sizeof (struct in6_addr));
Line 760  str2prefix (const char *str, struct prefix *p) Line 787  str2prefix (const char *str, struct prefix *p)
   return 0;    return 0;
 }  }
   
intconst char *
prefix2str (const struct prefix *p, char *str, int size)prefix2str (union prefix46constptr pu, char *str, int size)
 {  {
     const struct prefix *p = pu.p;
   char buf[BUFSIZ];    char buf[BUFSIZ];
   
   inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ);    inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ);
   snprintf (str, size, "%s/%d", buf, p->prefixlen);    snprintf (str, size, "%s/%d", buf, p->prefixlen);
  return 0;  return str;
 }  }
   
 struct prefix *  struct prefix *

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>