Diff for /embedaddon/quagga/lib/prefix.h between versions 1.1 and 1.1.1.3

version 1.1, 2012/02/21 17:26:12 version 1.1.1.3, 2016/11/02 10:09:10
Line 52  struct prefix Line 52  struct prefix
       struct in_addr adv_router;        struct in_addr adv_router;
     } lp;      } lp;
     u_char val[8];      u_char val[8];
       uintptr_t ptr;
   } u __attribute__ ((aligned (8)));    } u __attribute__ ((aligned (8)));
 };  };
   
Line 89  struct prefix_rd Line 90  struct prefix_rd
   u_char val[8] __attribute__ ((aligned (8)));    u_char val[8] __attribute__ ((aligned (8)));
 };  };
   
   /* Prefix for a generic pointer */
   struct prefix_ptr
   {
     u_char family;
     u_char prefixlen;
     uintptr_t prefix __attribute__ ((aligned (8)));
   };
   
   /* helper to get type safety/avoid casts on calls
    * (w/o this, functions accepting all prefix types need casts on the caller
    * side, which strips type safety since the cast will accept any pointer
    * type.)
    */
   union prefix46ptr
   {
     struct prefix *p;
     struct prefix_ipv4 *p4;
     struct prefix_ipv6 *p6;
   } __attribute__ ((transparent_union));
   
   union prefix46constptr
   {
     const struct prefix *p;
     const struct prefix_ipv4 *p4;
     const struct prefix_ipv6 *p6;
   } __attribute__ ((transparent_union));
   
 #ifndef INET_ADDRSTRLEN  #ifndef INET_ADDRSTRLEN
 #define INET_ADDRSTRLEN 16  #define INET_ADDRSTRLEN 16
 #endif /* INET_ADDRSTRLEN */  #endif /* INET_ADDRSTRLEN */
Line 101  struct prefix_rd Line 129  struct prefix_rd
 #define INET6_BUFSIZ 51  #define INET6_BUFSIZ 51
 #endif /* INET6_BUFSIZ */  #endif /* INET6_BUFSIZ */
   
   /* Maximum prefix string length (IPv6) */
   #define PREFIX_STRLEN 51
   
 /* Max bit/byte length of IPv4 address. */  /* Max bit/byte length of IPv4 address. */
 #define IPV4_MAX_BYTELEN    4  #define IPV4_MAX_BYTELEN    4
 #define IPV4_MAX_BITLEN    32  #define IPV4_MAX_BITLEN    32
Line 112  struct prefix_rd Line 143  struct prefix_rd
 #define IPV4_NET0(a)    ((((u_int32_t) (a)) & 0xff000000) == 0x00000000)  #define IPV4_NET0(a)    ((((u_int32_t) (a)) & 0xff000000) == 0x00000000)
 #define IPV4_NET127(a)  ((((u_int32_t) (a)) & 0xff000000) == 0x7f000000)  #define IPV4_NET127(a)  ((((u_int32_t) (a)) & 0xff000000) == 0x7f000000)
 #define IPV4_LINKLOCAL(a) ((((u_int32_t) (a)) & 0xffff0000) == 0xa9fe0000)  #define IPV4_LINKLOCAL(a) ((((u_int32_t) (a)) & 0xffff0000) == 0xa9fe0000)
   #define IPV4_CLASS_DE(a)  ((((u_int32_t) (a)) & 0xe0000000) == 0xe0000000)
   
 /* Max bit/byte length of IPv6 address. */  /* Max bit/byte length of IPv6 address. */
 #define IPV6_MAX_BYTELEN    16  #define IPV6_MAX_BYTELEN    16
Line 127  struct prefix_rd Line 159  struct prefix_rd
 /* Prefix's family member. */  /* Prefix's family member. */
 #define PREFIX_FAMILY(p)  ((p)->family)  #define PREFIX_FAMILY(p)  ((p)->family)
   
/* Check bit of the prefix. *//* glibc defines s6_addr32 to __in6_u.__u6_addr32 if __USE_{MISC || GNU} */
static inline unsigned int#ifndef s6_addr32
prefix_bit (const u_char *prefix, const u_char prefixlen)#if defined(SUNOS_5)
{/* Some SunOS define s6_addr32 only to kernel */
  unsigned int offset = prefixlen / 8;#define s6_addr32 _S6_un._S6_u32
  unsigned int shift  = 7 - (prefixlen % 8);#else
 #define s6_addr32 __u6_addr.__u6_addr32
 #endif /* SUNOS_5 */
 #endif /*s6_addr32*/
   
   return (prefix[offset] >> shift) & 1;  
 }  
   
 static inline unsigned int  
 prefix6_bit (const struct in6_addr *prefix, const u_char prefixlen)  
 {  
   return prefix_bit((const u_char *) &prefix->s6_addr, prefixlen);  
 }  
   
 /* Prototypes. */  /* Prototypes. */
   extern int str2family(const char *);
 extern int afi2family (afi_t);  extern int afi2family (afi_t);
 extern afi_t family2afi (int);  extern afi_t family2afi (int);
   extern const char *safi2str(safi_t safi);
   
   /* Check bit of the prefix. */
   extern unsigned int prefix_bit (const u_char *prefix, const u_char prefixlen);
   extern unsigned int prefix6_bit (const struct in6_addr *prefix, const u_char prefixlen);
   
 extern struct prefix *prefix_new (void);  extern struct prefix *prefix_new (void);
 extern void prefix_free (struct prefix *);  extern void prefix_free (struct prefix *);
 extern const char *prefix_family_str (const struct prefix *);  extern const char *prefix_family_str (const struct prefix *);
 extern int prefix_blen (const struct prefix *);  extern int prefix_blen (const struct prefix *);
 extern int str2prefix (const char *, struct prefix *);  extern int str2prefix (const char *, struct prefix *);
extern int prefix2str (const struct prefix *, char *, int);extern const char *prefix2str (union prefix46constptr, char *, int);
 extern int prefix_match (const struct prefix *, const struct prefix *);  extern int prefix_match (const struct prefix *, const struct prefix *);
 extern int prefix_same (const struct prefix *, const struct prefix *);  extern int prefix_same (const struct prefix *, const struct prefix *);
 extern int prefix_cmp (const struct prefix *, const struct prefix *);  extern int prefix_cmp (const struct prefix *, const struct prefix *);
   extern int prefix_common_bits (const struct prefix *, const struct prefix *);
 extern void prefix_copy (struct prefix *dest, const struct prefix *src);  extern void prefix_copy (struct prefix *dest, const struct prefix *src);
 extern void apply_mask (struct prefix *);  extern void apply_mask (struct prefix *);
   
 extern struct prefix *sockunion2prefix (const union sockunion *dest,  extern struct prefix *sockunion2prefix (const union sockunion *dest,
                                         const union sockunion *mask);                                          const union sockunion *mask);
extern struct prefix *sockunion2hostprefix (const union sockunion *);extern struct prefix *sockunion2hostprefix (const union sockunion *, struct prefix *p);
 extern void prefix2sockunion (const struct prefix *, union sockunion *);
   
 extern struct prefix_ipv4 *prefix_ipv4_new (void);  extern struct prefix_ipv4 *prefix_ipv4_new (void);
 extern void prefix_ipv4_free (struct prefix_ipv4 *);  extern void prefix_ipv4_free (struct prefix_ipv4 *);
Line 175  extern int prefix_ipv4_any (const struct prefix_ipv4 * Line 209  extern int prefix_ipv4_any (const struct prefix_ipv4 *
 extern void apply_classful_mask_ipv4 (struct prefix_ipv4 *);  extern void apply_classful_mask_ipv4 (struct prefix_ipv4 *);
   
 extern u_char ip_masklen (struct in_addr);  extern u_char ip_masklen (struct in_addr);
extern void masklen2ip (int, struct in_addr *);extern void masklen2ip (const int, struct in_addr *);
 /* returns the network portion of the host address */  /* returns the network portion of the host address */
 extern in_addr_t ipv4_network_addr (in_addr_t hostaddr, int masklen);  extern in_addr_t ipv4_network_addr (in_addr_t hostaddr, int masklen);
 /* given the address of a host on a network and the network mask length,  /* given the address of a host on a network and the network mask length,
Line 196  extern void apply_mask_ipv6 (struct prefix_ipv6 *); Line 230  extern void apply_mask_ipv6 (struct prefix_ipv6 *);
         *((struct prefix_ipv6 *)(DST)) = *((const struct prefix_ipv6 *)(SRC));          *((struct prefix_ipv6 *)(DST)) = *((const struct prefix_ipv6 *)(SRC));
   
 extern int ip6_masklen (struct in6_addr);  extern int ip6_masklen (struct in6_addr);
extern void masklen2ip6 (int, struct in6_addr *);extern void masklen2ip6 (const int, struct in6_addr *);
   
 extern void str2in6_addr (const char *, struct in6_addr *);  extern void str2in6_addr (const char *, struct in6_addr *);
 extern const char *inet6_ntoa (struct in6_addr);  extern const char *inet6_ntoa (struct in6_addr);
Line 204  extern const char *inet6_ntoa (struct in6_addr); Line 238  extern const char *inet6_ntoa (struct in6_addr);
 #endif /* HAVE_IPV6 */  #endif /* HAVE_IPV6 */
   
 extern int all_digit (const char *);  extern int all_digit (const char *);
   
   static inline int ipv4_martian (struct in_addr *addr)
   {
     in_addr_t ip = addr->s_addr;
   
     if (IPV4_NET0(ip) || IPV4_NET127(ip) || IPV4_CLASS_DE(ip)) {
       return 1;
     }
     return 0;
   }
   
 #endif /* _ZEBRA_PREFIX_H */  #endif /* _ZEBRA_PREFIX_H */

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


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