X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/fc6f112b40b9da56286ebc125f109e2889f5ebdb..c632b5f3d1251b4c4f16171d0963d92b6689d41b:/print-rsvp.c diff --git a/print-rsvp.c b/print-rsvp.c index e869b970..6c807fe7 100644 --- a/print-rsvp.c +++ b/print-rsvp.c @@ -15,14 +15,13 @@ * Original code by Hannes Gredler (hannes@juniper.net) */ -#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include -#include "interface.h" +#include "netdissect.h" #include "extract.h" #include "addrtoname.h" #include "ethertype.h" @@ -43,12 +42,12 @@ */ struct rsvp_common_header { - u_int8_t version_flags; - u_int8_t msg_type; - u_int8_t checksum[2]; - u_int8_t ttl; - u_int8_t reserved; - u_int8_t length[2]; + uint8_t version_flags; + uint8_t msg_type; + uint8_t checksum[2]; + uint8_t ttl; + uint8_t reserved; + uint8_t length[2]; }; /* @@ -66,9 +65,9 @@ struct rsvp_common_header { */ struct rsvp_object_header { - u_int8_t length[2]; - u_int8_t class_num; - u_int8_t ctype; + uint8_t length[2]; + uint8_t class_num; + uint8_t ctype; }; #define RSVP_VERSION 1 @@ -292,11 +291,11 @@ static const struct tok rsvp_ctype_values[] = { }; struct rsvp_obj_integrity_t { - u_int8_t flags; - u_int8_t res; - u_int8_t key_id[6]; - u_int8_t sequence[8]; - u_int8_t digest[16]; + uint8_t flags; + uint8_t res; + uint8_t key_id[6]; + uint8_t sequence[8]; + uint8_t digest[16]; }; static const struct tok rsvp_obj_integrity_flag_values[] = { @@ -305,14 +304,14 @@ static const struct tok rsvp_obj_integrity_flag_values[] = { }; struct rsvp_obj_frr_t { - u_int8_t setup_prio; - u_int8_t hold_prio; - u_int8_t hop_limit; - u_int8_t flags; - u_int8_t bandwidth[4]; - u_int8_t include_any[4]; - u_int8_t exclude_any[4]; - u_int8_t include_all[4]; + uint8_t setup_prio; + uint8_t hold_prio; + uint8_t hop_limit; + uint8_t flags; + uint8_t bandwidth[4]; + uint8_t include_any[4]; + uint8_t exclude_any[4]; + uint8_t include_all[4]; }; @@ -486,12 +485,12 @@ static const struct tok rsvp_obj_generalized_uni_values[] = { */ static int rsvp_intserv_print(netdissect_options *ndo, - const u_char *tptr, u_short obj_tlen) { - + const u_char *tptr, u_short obj_tlen) +{ int parameter_id,parameter_length; union { float f; - u_int32_t i; + uint32_t i; } bw; if (obj_tlen < 4) @@ -637,8 +636,8 @@ _U_ _U_ #endif , const u_char *tptr, - const char *ident, u_int tlen) { - + const char *ident, u_int tlen) +{ const struct rsvp_object_header *rsvp_obj_header; const u_char *obj_tptr; union { @@ -650,16 +649,15 @@ _U_ int hexdump,processed,padbytes,error_code,error_value,i,sigcheck; union { float f; - u_int32_t i; + uint32_t i; } bw; - u_int8_t namelen; + uint8_t namelen; u_int action, subchannel; while(tlen>=sizeof(struct rsvp_object_header)) { /* did we capture enough for fully decoding the object header ? */ - if (!ND_TTEST2(*tptr, sizeof(struct rsvp_object_header))) - goto trunc; + ND_TCHECK2(*tptr, sizeof(struct rsvp_object_header)); rsvp_obj_header = (const struct rsvp_object_header *)tptr; rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length); @@ -715,7 +713,7 @@ _U_ return -1; ND_PRINT((ndo, "%s IPv4 DestAddress: %s, Protocol ID: 0x%02x", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), *(obj_tptr + sizeof(struct in_addr)))); ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u", ident, @@ -724,13 +722,12 @@ _U_ obj_tlen-=8; obj_tptr+=8; break; -#ifdef INET6 case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return -1; ND_PRINT((ndo, "%s IPv6 DestAddress: %s, Protocol ID: 0x%02x", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), *(obj_tptr + sizeof(struct in6_addr)))); ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u", ident, @@ -745,9 +742,9 @@ _U_ return -1; ND_PRINT((ndo, "%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+18), - ip6addr_string(obj_tptr + 20))); + ip6addr_string(ndo, obj_tptr + 20))); obj_tlen-=36; obj_tptr+=36; break; @@ -759,19 +756,18 @@ _U_ ident, EXTRACT_32BITS(obj_tptr), EXTRACT_16BITS(obj_tptr+6), - ip6addr_string(obj_tptr + 8))); + ip6addr_string(ndo, obj_tptr + 8))); obj_tlen-=26; obj_tptr+=26; break; -#endif case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */ if (obj_tlen < 12) return -1; ND_PRINT((ndo, "%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+6), - ipaddr_string(obj_tptr + 8))); + ipaddr_string(ndo, obj_tptr + 8))); obj_tlen-=12; obj_tptr+=12; break; @@ -781,9 +777,9 @@ _U_ return -1; ND_PRINT((ndo, "%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+6), - ipaddr_string(obj_tptr + 8))); + ipaddr_string(ndo, obj_tptr + 8))); obj_tlen-=12; obj_tptr+=12; break; @@ -799,21 +795,19 @@ _U_ return -1; ND_PRINT((ndo, "%s IPv4 Receiver Address: %s", ident, - ipaddr_string(obj_tptr))); + ipaddr_string(ndo, obj_tptr))); obj_tlen-=sizeof(struct in_addr); obj_tptr+=sizeof(struct in_addr); break; -#ifdef INET6 case RSVP_CTYPE_IPV6: if (obj_tlen < sizeof(struct in6_addr)) return -1; ND_PRINT((ndo, "%s IPv6 Receiver Address: %s", ident, - ip6addr_string(obj_tptr))); + ip6addr_string(ndo, obj_tptr))); obj_tlen-=sizeof(struct in6_addr); obj_tptr+=sizeof(struct in6_addr); break; -#endif default: hexdump=TRUE; } @@ -826,21 +820,19 @@ _U_ return -1; ND_PRINT((ndo, "%s IPv4 Notify Node Address: %s", ident, - ipaddr_string(obj_tptr))); + ipaddr_string(ndo, obj_tptr))); obj_tlen-=sizeof(struct in_addr); obj_tptr+=sizeof(struct in_addr); break; -#ifdef INET6 case RSVP_CTYPE_IPV6: if (obj_tlen < sizeof(struct in6_addr)) return-1; ND_PRINT((ndo, "%s IPv6 Notify Node Address: %s", ident, - ip6addr_string(obj_tptr))); + ip6addr_string(ndo, obj_tptr))); obj_tlen-=sizeof(struct in6_addr); obj_tptr+=sizeof(struct in6_addr); break; -#endif default: hexdump=TRUE; } @@ -910,18 +902,17 @@ _U_ return-1; ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; break; -#ifdef INET6 case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return-1; ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 18))); obj_tlen-=20; obj_tptr+=20; @@ -932,21 +923,20 @@ _U_ ND_PRINT((ndo, "%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x" "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+18), ident, - ip6addr_string(obj_tptr+20), + ip6addr_string(ndo, obj_tptr+20), EXTRACT_16BITS(obj_tptr + 38))); obj_tlen-=40; obj_tptr+=40; break; -#endif case RSVP_CTYPE_TUNNEL_IPV4: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; @@ -957,10 +947,10 @@ _U_ ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x" "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+6), ident, - ipaddr_string(obj_tptr+8), + ipaddr_string(ndo, obj_tptr+8), EXTRACT_16BITS(obj_tptr + 12))); obj_tlen-=16; obj_tptr+=16; @@ -1068,7 +1058,7 @@ _U_ case RSVP_OBJ_XRO_IPV4: ND_PRINT((ndo, ", %s, %s/%u, Flags: [%s]", RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict", - ipaddr_string(obj_tptr+2), + ipaddr_string(ndo, obj_tptr+2), *(obj_tptr+6), bittok2str(rsvp_obj_rro_flag_values, "none", @@ -1189,16 +1179,14 @@ _U_ if (subobj_len < 8) return -1; ND_PRINT((ndo, "%s UNI IPv4 TNA address: %s", - ident, ipaddr_string(obj_tptr + 4))); + ident, ipaddr_string(ndo, obj_tptr + 4))); break; -#ifdef INET6 case AFNUM_INET6: if (subobj_len < 20) return -1; ND_PRINT((ndo, "%s UNI IPv6 TNA address: %s", - ident, ip6addr_string(obj_tptr + 4))); + ident, ip6addr_string(ndo, obj_tptr + 4))); break; -#endif case AFNUM_NSAP: if (subobj_len) { /* unless we have a TLV parser lets just hexdump */ @@ -1265,27 +1253,25 @@ _U_ return-1; ND_PRINT((ndo, "%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_32BITS(obj_tptr + 4))); obj_tlen-=8; obj_tptr+=8; if (obj_tlen) hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ break; -#ifdef INET6 case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return-1; ND_PRINT((ndo, "%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), EXTRACT_32BITS(obj_tptr + 16))); obj_tlen-=20; obj_tptr+=20; hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ break; -#endif default: hexdump=TRUE; } @@ -1356,18 +1342,17 @@ _U_ return-1; ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; break; -#ifdef INET6 case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return-1; ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 18))); obj_tlen-=20; obj_tptr+=20; @@ -1377,7 +1362,7 @@ _U_ return-1; ND_PRINT((ndo, "%s Source Address: %s, Flow Label: %u", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), EXTRACT_24BITS(obj_tptr + 17))); obj_tlen-=20; obj_tptr+=20; @@ -1387,7 +1372,7 @@ _U_ return-1; ND_PRINT((ndo, "%s Source Address: %s, LSP-ID: 0x%04x", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 18))); obj_tlen-=20; obj_tptr+=20; @@ -1398,21 +1383,20 @@ _U_ ND_PRINT((ndo, "%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x" "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+18), ident, - ip6addr_string(obj_tptr+20), + ip6addr_string(ndo, obj_tptr+20), EXTRACT_16BITS(obj_tptr + 38))); obj_tlen-=40; obj_tptr+=40; break; -#endif case RSVP_CTYPE_TUNNEL_IPV4: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s Source Address: %s, LSP-ID: 0x%04x", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; @@ -1423,10 +1407,10 @@ _U_ ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x" "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+6), ident, - ipaddr_string(obj_tptr+8), + ipaddr_string(ndo, obj_tptr+8), EXTRACT_16BITS(obj_tptr + 12))); obj_tlen-=16; obj_tptr+=16; @@ -1488,8 +1472,8 @@ _U_ while(obj_tlen >= 8) { ND_PRINT((ndo, "%s PLR-ID: %s, Avoid-Node-ID: %s", ident, - ipaddr_string(obj_tptr), - ipaddr_string(obj_tptr + 4))); + ipaddr_string(ndo, obj_tptr), + ipaddr_string(ndo, obj_tptr + 4))); obj_tlen-=8; obj_tptr+=8; } @@ -1524,7 +1508,7 @@ _U_ error_value=EXTRACT_16BITS(obj_tptr+6); ND_PRINT((ndo, "%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)", ident, - ipaddr_string(obj_tptr), + ipaddr_string(ndo, obj_tptr), *(obj_tptr+4), ident, tok2str(rsvp_obj_error_code_values,"unknown",error_code), @@ -1548,7 +1532,6 @@ _U_ obj_tlen-=8; obj_tptr+=8; break; -#ifdef INET6 case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ case RSVP_CTYPE_IPV6: if (obj_tlen < 20) @@ -1557,7 +1540,7 @@ _U_ error_value=EXTRACT_16BITS(obj_tptr+18); ND_PRINT((ndo, "%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)", ident, - ip6addr_string(obj_tptr), + ip6addr_string(ndo, obj_tptr), *(obj_tptr+16), ident, tok2str(rsvp_obj_error_code_values,"unknown",error_code), @@ -1575,7 +1558,6 @@ _U_ obj_tlen-=20; obj_tptr+=20; break; -#endif default: hexdump=TRUE; } @@ -1666,7 +1648,7 @@ _U_ EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12))); #ifdef HAVE_LIBCRYPTO - sigcheck = signature_verify(pptr, plen, (unsigned char *)obj_ptr.\ + sigcheck = signature_verify(ndo, pptr, plen, (unsigned char *)obj_ptr.\ rsvp_obj_integrity->digest); #else sigcheck = CANT_CHECK_SIGNATURE; @@ -1746,22 +1728,20 @@ _U_ if (obj_tlen < 4) return-1; ND_PRINT((ndo, "%s Sub-LSP destination address: %s", - ident, ipaddr_string(obj_tptr))); + ident, ipaddr_string(ndo, obj_tptr))); obj_tlen-=4; obj_tptr+=4; break; -#ifdef INET6 case RSVP_CTYPE_IPV6: if (obj_tlen < 16) return-1; ND_PRINT((ndo, "%s Sub-LSP destination address: %s", - ident, ip6addr_string(obj_tptr))); + ident, ip6addr_string(ndo, obj_tptr))); obj_tlen-=16; obj_tptr+=16; break; -#endif default: hexdump=TRUE; } @@ -1796,8 +1776,8 @@ trunc: void rsvp_print(netdissect_options *ndo, - register const u_char *pptr, register u_int len) { - + register const u_char *pptr, register u_int len) +{ struct rsvp_common_header *rsvp_com_header; const u_char *tptr,*subtptr; u_short plen, tlen, subtlen;