version 1.1.1.2, 2012/10/09 09:22:28
|
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 128 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) |
|
|
|
/* glibc defines s6_addr32 to __in6_u.__u6_addr32 if __USE_{MISC || GNU} */ |
|
#ifndef s6_addr32 |
|
#if defined(SUNOS_5) |
|
/* Some SunOS define s6_addr32 only to kernel */ |
|
#define s6_addr32 _S6_un._S6_u32 |
|
#else |
|
#define s6_addr32 __u6_addr.__u6_addr32 |
|
#endif /* SUNOS_5 */ |
|
#endif /*s6_addr32*/ |
|
|
/* 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. */ |
/* Check bit of the prefix. */ |
extern unsigned int prefix_bit (const u_char *prefix, const u_char prefixlen); |
extern unsigned int prefix_bit (const u_char *prefix, const u_char prefixlen); |
Line 141 extern void prefix_free (struct prefix *);
|
Line 184 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 *); |
Line 151 extern void apply_mask (struct prefix *);
|
Line 194 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 void prefix2sockunion (const struct prefix *, union sockunion *); |
|
|
extern struct prefix_ipv4 *prefix_ipv4_new (void); |
extern struct prefix_ipv4 *prefix_ipv4_new (void); |
Line 195 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 */ |