/* specification: RFC 4271 */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include "netdissect-stdinc.h"
#define BGP_NOTIFY_MAJOR_HOLDTIME 4
#define BGP_NOTIFY_MAJOR_FSM 5
#define BGP_NOTIFY_MAJOR_CEASE 6
-#define BGP_NOTIFY_MAJOR_CAP 7
+#define BGP_NOTIFY_MAJOR_ROUTEREFRESH 7
+#define BGP_NOTIFY_MAJOR_SENDHOLDTIME 8
static const struct tok bgp_notify_major_values[] = {
{ BGP_NOTIFY_MAJOR_MSG, "Message Header Error"},
{ BGP_NOTIFY_MAJOR_HOLDTIME,"Hold Timer Expired"},
{ BGP_NOTIFY_MAJOR_FSM, "Finite State Machine Error"},
{ BGP_NOTIFY_MAJOR_CEASE, "Cease"},
- { BGP_NOTIFY_MAJOR_CAP, "Capability Message Error"},
+ { BGP_NOTIFY_MAJOR_ROUTEREFRESH, "ROUTE-REFRESH Message Error"},
+ { BGP_NOTIFY_MAJOR_SENDHOLDTIME, "Send Hold Timer Expired"},
{ 0, NULL}
};
{ 0, NULL }
};
-static const struct tok bgp_notify_minor_cap_values[] = {
- { 1, "Invalid Action Value" },
- { 2, "Invalid Capability Length" },
- { 3, "Malformed Capability Value" },
- { 4, "Unsupported Capability Code" },
+static const struct tok bgp_notify_minor_routerefresh_values[] = {
+ { 1, "Invalid Message Length" },
{ 0, NULL }
};
}
static int
-decode_labeled_prefix4(netdissect_options *ndo,
- const u_char *pptr, u_int itemlen, char *buf,
- size_t buflen)
+print_labeled_prefix4(netdissect_options *ndo,
+ const u_char *pptr, u_int itemlen)
{
nd_ipv4 addr;
u_int plen, plenbytes;
*/
if (24 > plen)
- return -1;
+ goto badplen;
plen-=24; /* adjust prefixlen - labellength */
if (32 < plen)
- return -1;
+ goto badplen;
itemlen -= 4;
memset(&addr, 0, sizeof(addr));
((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "%s/%u, label:%u %s",
+ ND_PRINT("\n\t %s/%u, label:%u %s",
ipaddr_string(ndo, (const u_char *)&addr),
plen,
GET_BE_U_3(pptr + 1)>>4,
return 4 + plenbytes;
+badplen:
+ ND_PRINT("\n\t (illegal prefix length)");
+ return -1;
+
trunc:
return -2;
* return the number of bytes read from the wire.
*/
static u_int
-bgp_vpn_sg_print(netdissect_options *ndo,
- const u_char *pptr, char *buf, size_t buflen)
+bgp_vpn_sg_print(netdissect_options *ndo, const u_char *pptr)
{
uint8_t addr_length;
- u_int total_length, offset;
+ u_int total_length;
total_length = 0;
/* Source address */
ND_TCHECK_LEN(pptr, (addr_length >> 3));
total_length += (addr_length >> 3) + 1;
- offset = (u_int)strlen(buf);
if (addr_length) {
- snprintf(buf + offset, buflen - offset, ", Source %s",
- bgp_vpn_ip_print(ndo, pptr, addr_length));
+ ND_PRINT(", Source %s",
+ bgp_vpn_ip_print(ndo, pptr, addr_length));
pptr += (addr_length >> 3);
}
/* Group address */
ND_TCHECK_LEN(pptr, (addr_length >> 3));
total_length += (addr_length >> 3) + 1;
- offset = (u_int)strlen(buf);
if (addr_length) {
- snprintf(buf + offset, buflen - offset, ", Group %s",
- bgp_vpn_ip_print(ndo, pptr, addr_length));
+ ND_PRINT(", Group %s",
+ bgp_vpn_ip_print(ndo, pptr, addr_length));
pptr += (addr_length >> 3);
}
/* Print an RFC 4364 Route Distinguisher */
const char *
-bgp_vpn_rd_print(netdissect_options *ndo,
- const u_char *pptr)
+bgp_vpn_rd_print(netdissect_options *ndo, const u_char *pptr)
{
/* allocate space for the largest possible string */
static char rd[sizeof("xxxxx.xxxxx:xxxxx (xxx.xxx.xxx.xxx:xxxxx)")];
bgp_extended_community_print(netdissect_options *ndo,
const u_char *pptr)
{
- union { /* copy buffer for bandwidth values */
- float f;
- uint32_t i;
- } bw;
/* allocate space for the largest possible string */
char astostr[AS_STR_SIZE];
break;
case BGP_EXT_COM_LINKBAND:
- bw.i = GET_BE_U_4(pptr + 4);
ND_PRINT("bandwidth: %.3f Mbps",
- bw.f*8/1000000);
+ GET_BE_F_4(pptr + 4)*8/1000000);
break;
case BGP_EXT_COM_OVS:
/* RFC 4684 */
static int
-decode_rt_routing_info(netdissect_options *ndo,
- const u_char *pptr)
+print_rt_routing_info(netdissect_options *ndo, const u_char *pptr)
{
uint8_t route_target[8];
u_int plen;
}
static int
-decode_labeled_vpn_prefix4(netdissect_options *ndo,
- const u_char *pptr, char *buf, size_t buflen)
+print_labeled_vpn_prefix4(netdissect_options *ndo, const u_char *pptr)
{
nd_ipv4 addr;
u_int plen;
plen = GET_U_1(pptr); /* get prefix length */
if ((24+64) > plen)
- return -1;
+ goto badplen;
plen -= (24+64); /* adjust prefixlen - labellength - RD len*/
if (32 < plen)
- return -1;
+ goto badplen;
memset(&addr, 0, sizeof(addr));
GET_CPY_BYTES(&addr, pptr + 12, (plen + 7) / 8);
((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+ ND_PRINT("\n\t RD: %s, %s/%u, label:%u %s",
bgp_vpn_rd_print(ndo, pptr+4),
ipaddr_string(ndo, (const u_char *)&addr),
plen,
((GET_U_1(pptr + 3) & 1) == 0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
return 12 + (plen + 7) / 8;
+
+badplen:
+ ND_PRINT("\n\t (illegal prefix length)");
+ return -1;
}
/*
#define MDT_VPN_NLRI_LEN 16
static int
-decode_mdt_vpn_nlri(netdissect_options *ndo,
- const u_char *pptr, char *buf, size_t buflen)
+print_mdt_vpn_nlri(netdissect_options *ndo, const u_char *pptr)
{
const u_char *rd;
const u_char *vpn_ip;
/* if the NLRI is not predefined length, quit.*/
- if (GET_U_1(pptr) != MDT_VPN_NLRI_LEN * 8)
+ if (GET_U_1(pptr) != MDT_VPN_NLRI_LEN * 8) {
+ ND_PRINT("\n\t (illegal prefix length)");
return -1;
+ }
pptr++;
/* RD */
pptr += sizeof(nd_ipv4);
/* MDT Group Address */
- snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
- bgp_vpn_rd_print(ndo, rd), GET_IPADDR_STRING(vpn_ip), GET_IPADDR_STRING(pptr));
+ ND_PRINT("\n\t RD: %s, VPN IP Address: %s, MC Group Address: %s",
+ bgp_vpn_rd_print(ndo, rd),
+ GET_IPADDR_STRING(vpn_ip),
+ GET_IPADDR_STRING(pptr));
return MDT_VPN_NLRI_LEN + 1;
};
static int
-decode_multicast_vpn(netdissect_options *ndo,
- const u_char *pptr, char *buf, size_t buflen)
+print_multicast_vpn(netdissect_options *ndo, const u_char *pptr)
{
/* allocate space for the largest possible string */
char astostr[AS_STR_SIZE];
uint8_t route_type, route_length;
u_int addr_length, sg_length;
- u_int offset;
route_type = GET_U_1(pptr);
pptr++;
route_length = GET_U_1(pptr);
pptr++;
- snprintf(buf, buflen, "Route-Type: %s (%u), length: %u",
+ ND_PRINT("\n\t Route-Type: %s (%u), length: %u",
tok2str(bgp_multicast_vpn_route_type_values,
"Unknown", route_type),
route_type, route_length);
switch(route_type) {
case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
- offset = (u_int)strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s",
+ if (route_length < BGP_VPN_RD_LEN)
+ goto trunc;
+ ND_PRINT(", RD: %s, Originator %s",
bgp_vpn_rd_print(ndo, pptr),
bgp_vpn_ip_print(ndo, pptr + BGP_VPN_RD_LEN,
(route_length - BGP_VPN_RD_LEN) << 3));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN + 4);
- offset = (u_int)strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
- bgp_vpn_rd_print(ndo, pptr),
- as_printf(ndo, astostr, sizeof(astostr),
- GET_BE_U_4(pptr + BGP_VPN_RD_LEN)));
+ ND_PRINT(", RD: %s, Source-AS %s",
+ bgp_vpn_rd_print(ndo, pptr),
+ as_printf(ndo, astostr, sizeof(astostr),
+ GET_BE_U_4(pptr + BGP_VPN_RD_LEN)));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
- offset = (u_int)strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s",
- bgp_vpn_rd_print(ndo, pptr));
+ ND_PRINT(", RD: %s", bgp_vpn_rd_print(ndo, pptr));
pptr += BGP_VPN_RD_LEN;
- sg_length = bgp_vpn_sg_print(ndo, pptr, buf, buflen);
+ sg_length = bgp_vpn_sg_print(ndo, pptr);
addr_length = route_length - sg_length;
ND_TCHECK_LEN(pptr, addr_length);
- offset = (u_int)strlen(buf);
- snprintf(buf + offset, buflen - offset, ", Originator %s",
- bgp_vpn_ip_print(ndo, pptr, addr_length << 3));
+ ND_PRINT(", Originator %s",
+ bgp_vpn_ip_print(ndo, pptr, addr_length << 3));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
- offset = (u_int)strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s",
- bgp_vpn_rd_print(ndo, pptr));
+ ND_PRINT(", RD: %s", bgp_vpn_rd_print(ndo, pptr));
pptr += BGP_VPN_RD_LEN;
- bgp_vpn_sg_print(ndo, pptr, buf, buflen);
+ bgp_vpn_sg_print(ndo, pptr);
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN: /* fall through */
case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN + 4);
- offset = (u_int)strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
- bgp_vpn_rd_print(ndo, pptr),
- as_printf(ndo, astostr, sizeof(astostr),
- GET_BE_U_4(pptr + BGP_VPN_RD_LEN)));
+ ND_PRINT(", RD: %s, Source-AS %s",
+ bgp_vpn_rd_print(ndo, pptr),
+ as_printf(ndo, astostr, sizeof(astostr),
+ GET_BE_U_4(pptr + BGP_VPN_RD_LEN)));
pptr += BGP_VPN_RD_LEN + 4;
- bgp_vpn_sg_print(ndo, pptr, buf, buflen);
+ bgp_vpn_sg_print(ndo, pptr);
break;
/*
return -2;
}
-/*
- * As I remember, some versions of systems have an snprintf() that
- * returns -1 if the buffer would have overflowed. If the return
- * value is negative, set buflen to 0, to indicate that we've filled
- * the buffer up.
- *
- * If the return value is greater than buflen, that means that
- * the buffer would have overflowed; again, set buflen to 0 in
- * that case.
- */
-#define UPDATE_BUF_BUFLEN(buf, buflen, stringlen) \
- if (stringlen<0) \
- buflen=0; \
- else if ((u_int)stringlen>buflen) \
- buflen=0; \
- else { \
- buflen-=stringlen; \
- buf+=stringlen; \
- }
-
static int
-decode_labeled_vpn_l2(netdissect_options *ndo,
- const u_char *pptr, char *buf, size_t buflen)
+print_labeled_vpn_l2(netdissect_options *ndo, const u_char *pptr)
{
u_int plen, tlen, tlv_type, tlv_len, ttlv_len;
- int stringlen;
plen = GET_BE_U_2(pptr);
tlen = plen;
if (plen == 12) {
/* assume AD-only with RD, BGPNH */
ND_TCHECK_LEN(pptr, 12);
- buf[0] = '\0';
- stringlen = snprintf(buf, buflen, "RD: %s, BGPNH: %s",
+ ND_PRINT("\n\t RD: %s, BGPNH: %s",
bgp_vpn_rd_print(ndo, pptr),
GET_IPADDR_STRING(pptr+8));
- UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
- pptr += 12;
- tlen -= 12;
return plen + 2;
} else if (plen > 17) {
/* assume old format */
/* RD, ID, LBLKOFF, LBLBASE */
ND_TCHECK_LEN(pptr, 15);
- buf[0] = '\0';
- stringlen = snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
+ ND_PRINT("\n\t RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
bgp_vpn_rd_print(ndo, pptr),
GET_BE_U_2(pptr + 8),
GET_BE_U_2(pptr + 10),
GET_BE_U_3(pptr + 12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
- UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
pptr += 15;
tlen -= 15;
/* ok now the variable part - lets read out TLVs*/
while (tlen != 0) {
if (tlen < 3) {
- if (buflen != 0) {
- stringlen=snprintf(buf,buflen, "\n\t\tran past the end");
- UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
- }
+ ND_PRINT("\n\t\tran past the end");
return plen + 2;
}
tlv_type = GET_U_1(pptr);
switch(tlv_type) {
case 1:
- if (buflen != 0) {
- stringlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
- tlv_type,
- tlv_len);
- UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
- }
+ ND_PRINT("\n\t\tcircuit status vector (%u) length: %u: 0x",
+ tlv_type,
+ tlv_len);
while (ttlv_len != 0) {
if (tlen < 1) {
- if (buflen != 0) {
- stringlen=snprintf(buf,buflen, " (ran past the end)");
- UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
- }
+ ND_PRINT(" (ran past the end)");
return plen + 2;
}
ND_TCHECK_1(pptr);
- if (buflen != 0) {
- stringlen=snprintf(buf,buflen, "%02x",
- GET_U_1(pptr));
- pptr++;
- UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
- }
+ ND_PRINT("%02x", GET_U_1(pptr));
+ pptr++;
ttlv_len--;
tlen--;
}
break;
default:
- if (buflen != 0) {
- stringlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
- tlv_type,
- tlv_len);
- UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
- }
+ ND_PRINT("\n\t\tunknown TLV #%u, length: %u",
+ tlv_type,
+ tlv_len);
if (tlen < ttlv_len) {
- if (buflen != 0) {
- stringlen=snprintf(buf,buflen, " (ran past the end)");
- UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
- }
+ ND_PRINT(" (ran past the end)");
return plen + 2;
}
tlen -= ttlv_len;
}
static int
-decode_labeled_prefix6(netdissect_options *ndo,
- const u_char *pptr, u_int itemlen, char *buf, size_t buflen)
+print_labeled_prefix6(netdissect_options *ndo,
+ const u_char *pptr, u_int itemlen)
{
nd_ipv6 addr;
u_int plen, plenbytes;
plen = GET_U_1(pptr); /* get prefix length */
if (24 > plen)
- return -1;
+ goto badplen;
plen -= 24; /* adjust prefixlen - labellength */
if (128 < plen)
- return -1;
+ goto badplen;
itemlen -= 4;
memset(&addr, 0, sizeof(addr));
((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "%s/%u, label:%u %s",
+ ND_PRINT("\n\t %s/%u, label:%u %s",
ip6addr_string(ndo, (const u_char *)&addr),
plen,
GET_BE_U_3(pptr + 1)>>4,
return 4 + plenbytes;
+badplen:
+ ND_PRINT("\n\t (illegal prefix length)");
+ return -1;
+
trunc:
return -2;
}
static int
-decode_labeled_vpn_prefix6(netdissect_options *ndo,
- const u_char *pptr, char *buf, size_t buflen)
+print_labeled_vpn_prefix6(netdissect_options *ndo, const u_char *pptr)
{
nd_ipv6 addr;
u_int plen;
plen = GET_U_1(pptr); /* get prefix length */
if ((24+64) > plen)
- return -1;
+ goto badplen;
plen -= (24+64); /* adjust prefixlen - labellength - RD len*/
if (128 < plen)
- return -1;
+ goto badplen;
memset(&addr, 0, sizeof(addr));
GET_CPY_BYTES(&addr, pptr + 12, (plen + 7) / 8);
((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+ ND_PRINT("\n\t RD: %s, %s/%u, label:%u %s",
bgp_vpn_rd_print(ndo, pptr+4),
ip6addr_string(ndo, (const u_char *)&addr),
plen,
((GET_U_1(pptr + 3) & 1) == 0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
return 12 + (plen + 7) / 8;
+
+badplen:
+ ND_PRINT("\n\t (illegal prefix length)");
+ return -1;
}
static int
-decode_clnp_prefix(netdissect_options *ndo,
- const u_char *pptr, char *buf, size_t buflen)
+print_clnp_prefix(netdissect_options *ndo, const u_char *pptr)
{
uint8_t addr[19];
u_int plen;
plen = GET_U_1(pptr); /* get prefix length */
if (152 < plen)
- return -1;
+ goto badplen;
memset(&addr, 0, sizeof(addr));
GET_CPY_BYTES(&addr, pptr + 4, (plen + 7) / 8);
((0xff00 >> (plen % 8)) & 0xff);
}
/* Cannot use GET_ISONSAP_STRING (not packet buffer pointer) */
- snprintf(buf, buflen, "%s/%u",
+ ND_PRINT("\n\t %s/%u",
isonsap_string(ndo, addr,(plen + 7) / 8),
plen);
return 1 + (plen + 7) / 8;
+
+badplen:
+ ND_PRINT("\n\t (illegal prefix length)");
+ return -1;
}
static int
-decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
- const u_char *pptr, char *buf, size_t buflen)
+print_labeled_vpn_clnp_prefix(netdissect_options *ndo, const u_char *pptr)
{
uint8_t addr[19];
u_int plen;
plen = GET_U_1(pptr); /* get prefix length */
if ((24+64) > plen)
- return -1;
+ goto badplen;
plen -= (24+64); /* adjust prefixlen - labellength - RD len*/
if (152 < plen)
- return -1;
+ goto badplen;
memset(&addr, 0, sizeof(addr));
GET_CPY_BYTES(&addr, pptr + 12, (plen + 7) / 8);
}
/* the label may get offsetted by 4 bits so lets shift it right */
/* Cannot use GET_ISONSAP_STRING (not packet buffer pointer) */
- snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+ ND_PRINT("\n\t RD: %s, %s/%u, label:%u %s",
bgp_vpn_rd_print(ndo, pptr+4),
isonsap_string(ndo, addr,(plen + 7) / 8),
plen,
((GET_U_1(pptr + 3) & 1) == 0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
return 12 + (plen + 7) / 8;
+
+badplen:
+ ND_PRINT("\n\t (illegal prefix length)");
+ return -1;
}
/*
/*
* We can come here, either we did not have enough data, or if we
* try to decode 4 byte ASs in 2 byte format. Either way, return 4,
- * so that calller can try to decode each AS as of 4 bytes. If indeed
+ * so that caller can try to decode each AS as of 4 bytes. If indeed
* there was not enough data, it will crib and end the parse anyways.
*/
return 4;
}
/*
- * Scan through the NLRI information under the assumpetion that
+ * Scan through the NLRI information under the assumption that
* it doesn't have path IDs.
*/
for (offset = 0; offset < length;) {
safi);
switch(af<<8 | safi) {
- case (AFNUM_INET<<8 | SAFNUM_UNICAST):
- case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
- case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
- case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
- case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
- case (AFNUM_INET<<8 | SAFNUM_MDT):
- case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
- case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
- case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
- case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
- case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
- case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
- case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_UNICAST):
+ case (AFNUM_IP<<8 | SAFNUM_MULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_UNIMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_LABUNICAST):
+ case (AFNUM_IP<<8 | SAFNUM_RT_ROUTING_INFO):
+ case (AFNUM_IP<<8 | SAFNUM_VPNUNICAST):
+ case (AFNUM_IP<<8 | SAFNUM_VPNMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_VPNUNIMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_MULTICAST_VPN):
+ case (AFNUM_IP<<8 | SAFNUM_MDT):
+ case (AFNUM_IP6<<8 | SAFNUM_UNICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_MULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_UNIMULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_LABUNICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_VPNUNICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_VPNMULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_VPNUNIMULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
static int
bgp_nlri_print(netdissect_options *ndo, uint16_t af, uint8_t safi,
const u_char *tptr, u_int len,
- char *buf, size_t buflen,
int add_path4, int add_path6)
{
int advance;
u_int path_id = 0;
+ char buf[512];
switch (af<<8 | safi) {
- case (AFNUM_INET<<8 | SAFNUM_UNICAST):
- case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_UNICAST):
+ case (AFNUM_IP<<8 | SAFNUM_MULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_UNIMULTICAST):
if (add_path4) {
path_id = GET_BE_U_4(tptr);
tptr += 4;
}
- advance = decode_prefix4(ndo, tptr, len, buf, buflen);
+ advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
ND_PRINT("\n\t (illegal prefix length)");
else if (advance == -2)
advance += 4;
}
break;
- case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix4(ndo, tptr, len, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal prefix length)");
- else if (advance == -2)
+ case (AFNUM_IP<<8 | SAFNUM_LABUNICAST):
+ advance = print_labeled_prefix4(ndo, tptr, len);
+ if (advance == -2)
goto trunc;
- else if (advance == -3)
- break; /* bytes left, but not enough */
- else
- ND_PRINT("\n\t %s", buf);
break;
- case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
- case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal prefix length)");
- else
- ND_PRINT("\n\t %s", buf);
+ case (AFNUM_IP<<8 | SAFNUM_VPNUNICAST):
+ case (AFNUM_IP<<8 | SAFNUM_VPNMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_VPNUNIMULTICAST):
+ advance = print_labeled_vpn_prefix4(ndo, tptr);
break;
- case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
- advance = decode_rt_routing_info(ndo, tptr);
+ case (AFNUM_IP<<8 | SAFNUM_RT_ROUTING_INFO):
+ advance = print_rt_routing_info(ndo, tptr);
break;
- case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */
- case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN):
- advance = decode_multicast_vpn(ndo, tptr, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal prefix length)");
- else if (advance == -2)
+ case (AFNUM_IP<<8 | SAFNUM_MULTICAST_VPN): /* fall through */
+ case (AFNUM_IP6<<8 | SAFNUM_MULTICAST_VPN):
+ advance = print_multicast_vpn(ndo, tptr);
+ if (advance == -2)
goto trunc;
- else
- ND_PRINT("\n\t %s", buf);
break;
- case (AFNUM_INET<<8 | SAFNUM_MDT):
- advance = decode_mdt_vpn_nlri(ndo, tptr, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal prefix length)");
- else if (advance == -2)
+ case (AFNUM_IP<<8 | SAFNUM_MDT):
+ advance = print_mdt_vpn_nlri(ndo, tptr);
+ if (advance == -2)
goto trunc;
- else
- ND_PRINT("\n\t %s", buf);
break;
- case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
- case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
- case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_UNICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_MULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_UNIMULTICAST):
if (add_path6) {
path_id = GET_BE_U_4(tptr);
tptr += 4;
}
- advance = decode_prefix6(ndo, tptr, len, buf, buflen);
+ advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
ND_PRINT("\n\t (illegal prefix length)");
else if (advance == -2)
advance += 4;
}
break;
- case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix6(ndo, tptr, len, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal prefix length)");
- else if (advance == -2)
+ case (AFNUM_IP6<<8 | SAFNUM_LABUNICAST):
+ advance = print_labeled_prefix6(ndo, tptr, len);
+ if (advance == -2)
goto trunc;
- else if (advance == -3)
- break; /* bytes left, but not enough */
- else
- ND_PRINT("\n\t %s", buf);
break;
- case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
- case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
- case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal prefix length)");
- else
- ND_PRINT("\n\t %s", buf);
+ case (AFNUM_IP6<<8 | SAFNUM_VPNUNICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_VPNMULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_VPNUNIMULTICAST):
+ advance = print_labeled_vpn_prefix6(ndo, tptr);
break;
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_l2(ndo, tptr, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal length)");
- else if (advance == -2)
+ advance = print_labeled_vpn_l2(ndo, tptr);
+ if (advance == -2)
goto trunc;
- else
- ND_PRINT("\n\t %s", buf);
break;
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_clnp_prefix(ndo, tptr, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal prefix length)");
- else
- ND_PRINT("\n\t %s", buf);
+ advance = print_clnp_prefix(ndo, tptr);
break;
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, buflen);
- if (advance == -1)
- ND_PRINT("\n\t (illegal prefix length)");
- else
- ND_PRINT("\n\t %s", buf);
+ advance = print_labeled_vpn_clnp_prefix(ndo, tptr);
break;
default:
/*
int advance;
u_int tlen;
const u_char *tptr;
- char buf[MAXHOSTNAMELEN + 100];
u_int as_size;
int add_path4, add_path6;
int ret;
ND_PRINT(", " );
}
switch(af<<8 | safi) {
- case (AFNUM_INET<<8 | SAFNUM_UNICAST):
- case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
- case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
- case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
- case (AFNUM_INET<<8 | SAFNUM_MDT):
+ case (AFNUM_IP<<8 | SAFNUM_UNICAST):
+ case (AFNUM_IP<<8 | SAFNUM_MULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_UNIMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_LABUNICAST):
+ case (AFNUM_IP<<8 | SAFNUM_RT_ROUTING_INFO):
+ case (AFNUM_IP<<8 | SAFNUM_MULTICAST_VPN):
+ case (AFNUM_IP<<8 | SAFNUM_MDT):
if (tnhlen < sizeof(nd_ipv4)) {
ND_PRINT("invalid len");
tptr += tnhlen;
tlen -= sizeof(nd_ipv4);
}
break;
- case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
- case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
- case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_VPNUNICAST):
+ case (AFNUM_IP<<8 | SAFNUM_VPNMULTICAST):
+ case (AFNUM_IP<<8 | SAFNUM_VPNUNIMULTICAST):
if (tnhlen < sizeof(nd_ipv4)+BGP_VPN_RD_LEN) {
ND_PRINT("invalid len");
tptr += tnhlen;
tnhlen -= (sizeof(nd_ipv4)+BGP_VPN_RD_LEN);
}
break;
- case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
- case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
- case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
- case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_UNICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_MULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_UNIMULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_LABUNICAST):
if (tnhlen < sizeof(nd_ipv6)) {
ND_PRINT("invalid len");
tptr += tnhlen;
tnhlen -= sizeof(nd_ipv6);
}
break;
- case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
- case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
- case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_VPNUNICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_VPNMULTICAST):
+ case (AFNUM_IP6<<8 | SAFNUM_VPNUNIMULTICAST):
if (tnhlen < sizeof(nd_ipv6)+BGP_VPN_RD_LEN) {
ND_PRINT("invalid len");
tptr += tnhlen;
tlen -= tnhlen;
tnhlen = 0;
goto done;
- break;
}
}
}
ND_PRINT("\n\t %u SNPA", snpa);
for (/*nothing*/; snpa != 0; snpa--) {
uint8_t snpalen;
- if (tlen < 1)
- goto trunc;
+ if (tlen < 1)
+ goto trunc;
snpalen = GET_U_1(tptr);
ND_PRINT("\n\t %u bytes", snpalen);
tptr++;
ND_PRINT(", no SNPA");
}
- add_path4 = check_add_path(ndo, tptr, (len-ND_BYTES_BETWEEN(tptr, pptr)), 32);
- add_path6 = check_add_path(ndo, tptr, (len-ND_BYTES_BETWEEN(tptr, pptr)), 128);
+ add_path4 = check_add_path(ndo, tptr,
+ (len-ND_BYTES_BETWEEN(pptr, tptr)), 32);
+ add_path6 = check_add_path(ndo, tptr,
+ (len-ND_BYTES_BETWEEN(pptr, tptr)), 128);
while (tptr < pptr + len) {
- advance = bgp_nlri_print(ndo, af, safi, tptr, len, buf, sizeof(buf),
+ advance = bgp_nlri_print(ndo, af, safi, tptr, len,
add_path4, add_path6);
if (advance == -2)
goto trunc;
tptr += 3;
- add_path4 = check_add_path(ndo, tptr, (len-ND_BYTES_BETWEEN(tptr, pptr)), 32);
- add_path6 = check_add_path(ndo, tptr, (len-ND_BYTES_BETWEEN(tptr, pptr)), 128);
+ add_path4 = check_add_path(ndo, tptr,
+ (len-ND_BYTES_BETWEEN(pptr, tptr)), 32);
+ add_path6 = check_add_path(ndo, tptr,
+ (len-ND_BYTES_BETWEEN(pptr, tptr)), 128);
while (tptr < pptr + len) {
- advance = bgp_nlri_print(ndo, af, safi, tptr, len, buf, sizeof(buf),
+ advance = bgp_nlri_print(ndo, af, safi, tptr, len,
add_path4, add_path6);
if (advance == -2)
goto trunc;
tptr += 3;
sblen -= 3;
/* Parse signature segments */
- while (sblen > 0) {
+ while (sblen != 0) {
uint16_t siglen;
ND_PRINT("\n\t Signature Segment:\n\t SKI: ");
{
const u_char *p;
u_int withdrawn_routes_len;
- char buf[MAXHOSTNAMELEN + 100];
+ char buf[512];
int wpfx;
u_int len;
int i;
bgpn_minor),
bgpn_minor);
break;
- case BGP_NOTIFY_MAJOR_CAP:
+ case BGP_NOTIFY_MAJOR_ROUTEREFRESH:
ND_PRINT(" subcode %s (%u)",
- tok2str(bgp_notify_minor_cap_values, "Unknown",
+ tok2str(bgp_notify_minor_routerefresh_values, "Unknown",
bgpn_minor),
bgpn_minor);
break;
/* garbage, hexdump it all */
if (shutdown_comm_length > length - 1) {
ND_PRINT(", invalid Shutdown Communication length");
- }
- else if (shutdown_comm_length == 0) {
+ } else if (shutdown_comm_length == 0) {
ND_PRINT(", empty Shutdown Communication");
remainder_offset += 1;
}