diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-03-27 21:13:34 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-03-27 21:13:34 +0200 |
commit | d7c0a89a3a5697783a6dd89333ab660074790890 (patch) | |
tree | eefa73e502f919b524b8a345437260d4acc23083 /lib/prefix.c | |
parent | tools, doc: update checkpatch for u_int_* (diff) | |
download | frr-d7c0a89a3a5697783a6dd89333ab660074790890.tar.xz frr-d7c0a89a3a5697783a6dd89333ab660074790890.zip |
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t
Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/prefix.c')
-rw-r--r-- | lib/prefix.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 134403949..003ce992b 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -31,8 +31,8 @@ DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix") /* Maskbit. */ -static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, - 0xf8, 0xfc, 0xfe, 0xff}; +static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, + 0xf8, 0xfc, 0xfe, 0xff}; static const struct in6_addr maskbytes6[] = { /* /0 */ {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -441,7 +441,7 @@ int is_zero_mac(struct ethaddr *mac) return 1; } -unsigned int prefix_bit(const u_char *prefix, const u_char prefixlen) +unsigned int prefix_bit(const uint8_t *prefix, const uint8_t prefixlen) { unsigned int offset = prefixlen / 8; unsigned int shift = 7 - (prefixlen % 8); @@ -449,9 +449,9 @@ unsigned int prefix_bit(const u_char *prefix, const u_char prefixlen) return (prefix[offset] >> shift) & 1; } -unsigned int prefix6_bit(const struct in6_addr *prefix, const u_char prefixlen) +unsigned int prefix6_bit(const struct in6_addr *prefix, const uint8_t prefixlen) { - return prefix_bit((const u_char *)&prefix->s6_addr, prefixlen); + return prefix_bit((const uint8_t *)&prefix->s6_addr, prefixlen); } int str2family(const char *string) @@ -533,15 +533,15 @@ int prefix_match(const struct prefix *n, const struct prefix *p) { int offset; int shift; - const u_char *np, *pp; + const uint8_t *np, *pp; /* If n's prefix is longer than p's one return 0. */ if (n->prefixlen > p->prefixlen) return 0; /* Set both prefix's head pointer. */ - np = (const u_char *)&n->u.prefix; - pp = (const u_char *)&p->u.prefix; + np = (const uint8_t *)&n->u.prefix; + pp = (const uint8_t *)&p->u.prefix; offset = n->prefixlen / PNBBY; shift = n->prefixlen % PNBBY; @@ -562,11 +562,11 @@ int prefix_match_network_statement(const struct prefix *n, { int offset; int shift; - const u_char *np, *pp; + const uint8_t *np, *pp; /* Set both prefix's head pointer. */ - np = (const u_char *)&n->u.prefix; - pp = (const u_char *)&p->u.prefix; + np = (const uint8_t *)&n->u.prefix; + pp = (const uint8_t *)&p->u.prefix; offset = n->prefixlen / PNBBY; shift = n->prefixlen % PNBBY; @@ -659,8 +659,8 @@ int prefix_cmp(const struct prefix *p1, const struct prefix *p2) int shift; /* Set both prefix's head pointer. */ - const u_char *pp1 = (const u_char *)&p1->u.prefix; - const u_char *pp2 = (const u_char *)&p2->u.prefix; + const uint8_t *pp1 = (const uint8_t *)&p1->u.prefix; + const uint8_t *pp2 = (const uint8_t *)&p2->u.prefix; if (p1->family != p2->family || p1->prefixlen != p2->prefixlen) return 1; @@ -689,11 +689,11 @@ int prefix_common_bits(const struct prefix *p1, const struct prefix *p2) { int pos, bit; int length = 0; - u_char xor ; + uint8_t xor ; /* Set both prefix's head pointer. */ - const u_char *pp1 = (const u_char *)&p1->u.prefix; - const u_char *pp2 = (const u_char *)&p2->u.prefix; + const uint8_t *pp1 = (const uint8_t *)&p1->u.prefix; + const uint8_t *pp2 = (const uint8_t *)&p2->u.prefix; if (p1->family == AF_INET) length = IPV4_MAX_BYTELEN; @@ -787,7 +787,7 @@ int str2prefix_ipv4(const char *str, struct prefix_ipv4 *p) XFREE(MTYPE_TMP, cp); /* Get prefix length. */ - plen = (u_char)atoi(++pnt); + plen = (uint8_t)atoi(++pnt); if (plen > IPV4_MAX_PREFIXLEN) return 0; @@ -821,7 +821,7 @@ int str2prefix_eth(const char *str, struct prefix_eth *p) if (pnt) { /* Get prefix length. */ - plen = (u_char)atoi(++pnt); + plen = (uint8_t)atoi(++pnt); if (plen > 48) { ret = 0; goto done; @@ -883,7 +883,7 @@ void masklen2ip(const int masklen, struct in_addr *netmask) /* Convert IP address's netmask into integer. We assume netmask is sequential one. Argument netmask should be network byte order. */ -u_char ip_masklen(struct in_addr netmask) +uint8_t ip_masklen(struct in_addr netmask) { uint32_t tmp = ~ntohl(netmask.s_addr); if (tmp) @@ -953,7 +953,7 @@ int str2prefix_ipv6(const char *str, struct prefix_ipv6 *p) XFREE(MTYPE_TMP, cp); if (ret == 0) return 0; - plen = (u_char)atoi(++pnt); + plen = (uint8_t)atoi(++pnt); if (plen > IPV6_MAX_BITLEN) return 0; p->prefixlen = plen; @@ -964,7 +964,7 @@ int str2prefix_ipv6(const char *str, struct prefix_ipv6 *p) } /* Convert struct in6_addr netmask into integer. - * FIXME return u_char as ip_maskleni() does. */ + * FIXME return uint8_t as ip_maskleni() does. */ int ip6_masklen(struct in6_addr netmask) { int len = 0; @@ -996,14 +996,14 @@ void masklen2ip6(const int masklen, struct in6_addr *netmask) void apply_mask_ipv6(struct prefix_ipv6 *p) { - u_char *pnt; + uint8_t *pnt; int index; int offset; index = p->prefixlen / 8; if (index < 16) { - pnt = (u_char *)&p->prefix; + pnt = (uint8_t *)&p->prefix; offset = p->prefixlen % 8; pnt[index] &= maskbit[offset]; @@ -1135,7 +1135,7 @@ int str2prefix(const char *str, struct prefix *p) static const char *prefixevpn2str(const struct prefix *p, char *str, int size) { - u_char family; + uint8_t family; char buf[PREFIX2STR_BUFFER]; char buf2[ETHER_ADDR_STRLEN]; @@ -1244,7 +1244,7 @@ int all_digit(const char *str) void apply_classful_mask_ipv4(struct prefix_ipv4 *p) { - u_int32_t destination; + uint32_t destination; destination = ntohl(p->prefix.s_addr); @@ -1292,8 +1292,8 @@ int netmask_str2prefix_str(const char *net_str, const char *mask_str, { struct in_addr network; struct in_addr mask; - u_char prefixlen; - u_int32_t destination; + uint8_t prefixlen; + uint32_t destination; int ret; ret = inet_aton(net_str, &network); |