#include "l2vpn.h"
struct bgp {
- u_int8_t bgp_marker[16];
- u_int16_t bgp_len;
- u_int8_t bgp_type;
+ uint8_t bgp_marker[16];
+ uint16_t bgp_len;
+ uint8_t bgp_type;
};
#define BGP_SIZE 19 /* unaligned */
};
struct bgp_open {
- u_int8_t bgpo_marker[16];
- u_int16_t bgpo_len;
- u_int8_t bgpo_type;
- u_int8_t bgpo_version;
- u_int16_t bgpo_myas;
- u_int16_t bgpo_holdtime;
- u_int32_t bgpo_id;
- u_int8_t bgpo_optlen;
+ uint8_t bgpo_marker[16];
+ uint16_t bgpo_len;
+ uint8_t bgpo_type;
+ uint8_t bgpo_version;
+ uint16_t bgpo_myas;
+ uint16_t bgpo_holdtime;
+ uint32_t bgpo_id;
+ uint8_t bgpo_optlen;
/* options should follow */
};
#define BGP_OPEN_SIZE 29 /* unaligned */
struct bgp_opt {
- u_int8_t bgpopt_type;
- u_int8_t bgpopt_len;
+ uint8_t bgpopt_type;
+ uint8_t bgpopt_len;
/* variable length */
};
#define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */
#define BGP_CAP_HEADER_SIZE 2 /* some compilers may pad to 4 bytes */
struct bgp_notification {
- u_int8_t bgpn_marker[16];
- u_int16_t bgpn_len;
- u_int8_t bgpn_type;
- u_int8_t bgpn_major;
- u_int8_t bgpn_minor;
+ uint8_t bgpn_marker[16];
+ uint16_t bgpn_len;
+ uint8_t bgpn_type;
+ uint8_t bgpn_major;
+ uint8_t bgpn_minor;
};
#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
struct bgp_route_refresh {
- u_int8_t bgp_marker[16];
- u_int16_t len;
- u_int8_t type;
- u_int8_t afi[2]; /* the compiler messes this structure up */
- u_int8_t res; /* when doing misaligned sequences of int8 and int16 */
- u_int8_t safi; /* afi should be int16 - so we have to access it using */
+ uint8_t bgp_marker[16];
+ uint16_t len;
+ uint8_t type;
+ uint8_t afi[2]; /* the compiler messes this structure up */
+ uint8_t res; /* when doing misaligned sequences of int8 and int16 */
+ uint8_t safi; /* afi should be int16 - so we have to access it using */
}; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */
#define BGP_ROUTE_REFRESH_SIZE 23
((u_char *)&addr)[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", getname(ndo, (u_char *)&addr), plen);
return 1 + plenbytes;
trunc:
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname((u_char *)&addr),
+ getname(ndo, (u_char *)&addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
switch(addr_length) {
case (sizeof(struct in_addr) << 3): /* 32 */
ND_TCHECK2(pptr[0], sizeof(struct in_addr));
- snprintf(pos, sizeof(addr), "%s", ipaddr_string(pptr));
+ snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr));
break;
#ifdef INET6
case (sizeof(struct in6_addr) << 3): /* 128 */
ND_TCHECK2(pptr[0], sizeof(struct in6_addr));
- snprintf(pos, sizeof(addr), "%s", ip6addr_string(pptr));
+ snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
break;
#endif
default:
bgp_vpn_sg_print(netdissect_options *ndo,
const u_char *pptr, char *buf, u_int buflen) {
- u_int8_t addr_length;
+ uint8_t addr_length;
u_int total_length, offset;
total_length = 0;
decode_rt_routing_info(netdissect_options *ndo,
const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t route_target[8];
+ uint8_t route_target[8];
u_int plen;
ND_TCHECK(pptr[0]);
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
bgp_vpn_rd_print(ndo, pptr+4),
- getname((u_char *)&addr),
+ getname(ndo, (u_char *)&addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
ND_TCHECK(pptr[0]);
/* if the NLRI is not predefined length, quit.*/
- if (*pptr != MDT_VPN_NLRI_LEN * NBBY)
+ if (*pptr != MDT_VPN_NLRI_LEN * 8)
return -1;
pptr++;
ND_TCHECK2(pptr[0], sizeof(struct in_addr));
snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
- bgp_vpn_rd_print(ndo, rd), ipaddr_string(vpn_ip), ipaddr_string(pptr));
+ bgp_vpn_rd_print(ndo, rd), ipaddr_string(ndo, vpn_ip), ipaddr_string(ndo, pptr));
return MDT_VPN_NLRI_LEN + 1;
decode_multicast_vpn(netdissect_options *ndo,
const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t route_type, route_length, addr_length, sg_length;
+ uint8_t route_type, route_length, addr_length, sg_length;
u_int offset;
ND_TCHECK2(pptr[0], 2);
buf[0]='\0';
strlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
bgp_vpn_rd_print(ndo, pptr),
- /* need something like getname() here */
- getname(pptr+8)
+ /* need something like getname(ndo, ) here */
+ getname(ndo, pptr+8)
);
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
pptr+=12;
addr.s6_addr[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", getname6(ndo, (u_char *)&addr), plen);
return 1 + plenbytes;
trunc:
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname6((u_char *)&addr),
+ getname6(ndo, (u_char *)&addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
bgp_vpn_rd_print(ndo, pptr+4),
- getname6((u_char *)&addr),
+ getname6(ndo, (u_char *)&addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
decode_clnp_prefix(netdissect_options *ndo,
const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t addr[19];
+ uint8_t addr[19];
u_int plen;
ND_TCHECK(pptr[0]);
decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t addr[19];
+ uint8_t addr[19];
u_int plen;
ND_TCHECK(pptr[0]);
*/
static int
bgp_attr_get_as_size(netdissect_options *ndo,
- u_int8_t bgpa_type, const u_char *pptr, int len)
+ uint8_t bgpa_type, const u_char *pptr, int len)
{
const u_char *tptr = pptr;
u_int atype, const u_char *pptr, u_int len)
{
int i;
- u_int16_t af;
- u_int8_t safi, snpa, nhlen;
+ uint16_t af;
+ uint8_t safi, snpa, nhlen;
union { /* copy buffer for bandwidth values */
float f;
- u_int32_t i;
+ uint32_t i;
} bw;
int advance;
u_int tlen;
ND_PRINT((ndo, "invalid len"));
else {
ND_TCHECK2(tptr[0], 4);
- ND_PRINT((ndo, "%s", getname(tptr)));
+ ND_PRINT((ndo, "%s", getname(ndo, tptr)));
}
break;
case BGPTYPE_MULTI_EXIT_DISC:
if (len == 6) {
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
- getname(tptr + 2)));
+ getname(ndo, tptr + 2)));
} else {
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr),
- EXTRACT_32BITS(tptr)), getname(tptr + 4)));
+ EXTRACT_32BITS(tptr)), getname(ndo, tptr + 4)));
}
break;
case BGPTYPE_AGGREGATOR4:
ND_TCHECK2(tptr[0], 8);
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
- getname(tptr + 4)));
+ getname(ndo, tptr + 4)));
break;
case BGPTYPE_COMMUNITIES:
if (len % 4) {
break;
}
while (tlen>0) {
- u_int32_t comm;
+ uint32_t comm;
ND_TCHECK2(tptr[0], 4);
comm = EXTRACT_32BITS(tptr);
switch (comm) {
break;
}
ND_TCHECK2(tptr[0], 4);
- ND_PRINT((ndo, "%s",getname(tptr)));
+ ND_PRINT((ndo, "%s",getname(ndo, tptr)));
break;
case BGPTYPE_CLUSTER_LIST:
if (len % 4) {
while (tlen>0) {
ND_TCHECK2(tptr[0], 4);
ND_PRINT((ndo, "%s%s",
- getname(tptr),
+ getname(ndo, tptr),
(tlen>4) ? ", " : ""));
tlen -=4;
tptr +=4;
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in_addr));
- ND_PRINT((ndo, "%s",getname(tptr)));
+ ND_PRINT((ndo, "%s",getname(ndo, tptr)));
tlen -= sizeof(struct in_addr);
tptr += sizeof(struct in_addr);
}
ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
ND_PRINT((ndo, "RD: %s, %s",
bgp_vpn_rd_print(ndo, tptr),
- getname(tptr+BGP_VPN_RD_LEN)));
+ getname(ndo, tptr+BGP_VPN_RD_LEN)));
tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
}
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in6_addr));
- ND_PRINT((ndo, "%s", getname6(tptr)));
+ ND_PRINT((ndo, "%s", getname6(ndo, tptr)));
tlen -= sizeof(struct in6_addr);
tptr += sizeof(struct in6_addr);
}
ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
ND_PRINT((ndo, "RD: %s, %s",
bgp_vpn_rd_print(ndo, tptr),
- getname6(tptr+BGP_VPN_RD_LEN)));
+ getname6(ndo, tptr+BGP_VPN_RD_LEN)));
tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
}
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in_addr));
- ND_PRINT((ndo, "%s", getname(tptr)));
+ ND_PRINT((ndo, "%s", getname(ndo, tptr)));
tlen -= (sizeof(struct in_addr));
tptr += (sizeof(struct in_addr));
}
isonsap_string(tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
/* rfc986 mapped IPv4 address ? */
if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601)
- ND_PRINT((ndo, " = %s", getname(tptr+BGP_VPN_RD_LEN+4)));
+ ND_PRINT((ndo, " = %s", getname(ndo, tptr+BGP_VPN_RD_LEN+4)));
#ifdef INET6
/* rfc1888 mapped IPv6 address ? */
else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000)
- ND_PRINT((ndo, " = %s", getname6(tptr+BGP_VPN_RD_LEN+3)));
+ ND_PRINT((ndo, " = %s", getname6(ndo, tptr+BGP_VPN_RD_LEN+3)));
#endif
tptr += tlen;
tlen = 0;
break;
}
while (tlen>0) {
- u_int16_t extd_comm;
+ uint16_t extd_comm;
ND_TCHECK2(tptr[0], 2);
extd_comm=EXTRACT_16BITS(tptr);
ND_PRINT((ndo, ": %u:%u (= %s)",
EXTRACT_16BITS(tptr+2),
EXTRACT_32BITS(tptr+4),
- getname(tptr+4)));
+ getname(ndo, tptr+4)));
break;
case BGP_EXT_COM_RT_1:
case BGP_EXT_COM_RO_1:
case BGP_EXT_COM_L2VPN_RT_1:
case BGP_EXT_COM_VRF_RT_IMP:
ND_PRINT((ndo, ": %s:%u",
- getname(tptr+2),
+ getname(ndo, tptr+2),
EXTRACT_16BITS(tptr+6)));
break;
case BGP_EXT_COM_RT_2:
case BGP_EXT_COM_VPN_ORIGIN4:
case BGP_EXT_COM_OSPF_RID:
case BGP_EXT_COM_OSPF_RID2:
- ND_PRINT((ndo, "%s", getname(tptr+2)));
+ ND_PRINT((ndo, "%s", getname(ndo, tptr+2)));
break;
case BGP_EXT_COM_OSPF_RTYPE:
case BGP_EXT_COM_OSPF_RTYPE2:
ND_PRINT((ndo, ": area:%s, router-type:%s, metric-type:%s%s",
- getname(tptr+2),
+ getname(ndo, tptr+2),
tok2strbuf(bgp_extd_comm_ospf_rtype_values,
"unknown (0x%02x)",
*(tptr+6),
case BGPTYPE_PMSI_TUNNEL:
{
- u_int8_t tunnel_type, flags;
+ uint8_t tunnel_type, flags;
tunnel_type = *(tptr+1);
flags = *tptr;
case BGP_PMSI_TUNNEL_PIM_BIDIR:
ND_TCHECK2(tptr[0], 8);
ND_PRINT((ndo, "\n\t Sender %s, P-Group %s",
- ipaddr_string(tptr),
- ipaddr_string(tptr+4)));
+ ipaddr_string(ndo, tptr),
+ ipaddr_string(ndo, tptr+4)));
break;
case BGP_PMSI_TUNNEL_PIM_SSM:
ND_TCHECK2(tptr[0], 8);
ND_PRINT((ndo, "\n\t Root-Node %s, P-Group %s",
- ipaddr_string(tptr),
- ipaddr_string(tptr+4)));
+ ipaddr_string(ndo, tptr),
+ ipaddr_string(ndo, tptr+4)));
break;
case BGP_PMSI_TUNNEL_INGRESS:
ND_TCHECK2(tptr[0], 4);
ND_PRINT((ndo, "\n\t Tunnel-Endpoint %s",
- ipaddr_string(tptr)));
+ ipaddr_string(ndo, tptr)));
break;
case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */
case BGP_PMSI_TUNNEL_LDP_MP2MP:
ND_TCHECK2(tptr[0], 8);
ND_PRINT((ndo, "\n\t Root-Node %s, LSP-ID 0x%08x",
- ipaddr_string(tptr),
+ ipaddr_string(ndo, tptr),
EXTRACT_32BITS(tptr+4)));
break;
case BGP_PMSI_TUNNEL_RSVP_P2MP:
ND_TCHECK2(tptr[0], 8);
ND_PRINT((ndo, "\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x",
- ipaddr_string(tptr),
+ ipaddr_string(ndo, tptr),
EXTRACT_32BITS(tptr+4)));
break;
default:
ND_PRINT((ndo, "my AS %s, ",
as_printf(ndo, astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas))));
ND_PRINT((ndo, "Holdtime %us, ", ntohs(bgpo.bgpo_holdtime)));
- ND_PRINT((ndo, "ID %s", getname((u_char *)&bgpo.bgpo_id)));
+ ND_PRINT((ndo, "ID %s", getname(ndo, (u_char *)&bgpo.bgpo_id)));
ND_PRINT((ndo, "\n\t Optional parameters, length: %u", bgpo.bgpo_optlen));
/* some little sanity checking */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
struct bgp bgp;
- u_int16_t hlen;
+ uint16_t hlen;
char tokbuf[TOKBUFSIZE];
ep = dat + length;