X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/e2982e7f6f0b624a773ec5a58885ee80fab46d34..a24cccfd4abcda51db9f73f46d425c7c1e357a87:/print-rsvp.c diff --git a/print-rsvp.c b/print-rsvp.c index 8d89abf4..421f4ac8 100644 --- a/print-rsvp.c +++ b/print-rsvp.c @@ -20,10 +20,10 @@ /* specification: RFC 2205 */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif -#include +#include "netdissect-stdinc.h" #include "netdissect.h" #include "extract.h" @@ -33,7 +33,6 @@ #include "af.h" #include "signature.h" -static const char tstr[] = " [|rsvp]"; /* * RFC 2205 common header @@ -643,7 +642,7 @@ rsvp_intserv_print(netdissect_options *ndo, return (parameter_length+4); /* header length 4 bytes */ trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); return 0; } @@ -730,8 +729,7 @@ rsvp_obj_print(netdissect_options *ndo, obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header); /* did we capture enough for fully decoding the object ? */ - if (!ND_TTEST_LEN(tptr, rsvp_obj_len)) - return -1; + ND_TCHECK_LEN(tptr, rsvp_obj_len); hexdump=FALSE; switch(rsvp_obj_class_num) { @@ -743,7 +741,7 @@ rsvp_obj_print(netdissect_options *ndo, ND_PRINT("%s IPv4 DestAddress: %s, Protocol ID: 0x%02x", indent, ipaddr_string(ndo, obj_tptr), - EXTRACT_U_1(obj_tptr + sizeof(struct in_addr))); + EXTRACT_U_1(obj_tptr + sizeof(nd_ipv4))); ND_PRINT("%s Flags: [0x%02x], DestPort %u", indent, EXTRACT_U_1((obj_tptr + 5)), @@ -757,11 +755,11 @@ rsvp_obj_print(netdissect_options *ndo, ND_PRINT("%s IPv6 DestAddress: %s, Protocol ID: 0x%02x", indent, ip6addr_string(ndo, obj_tptr), - EXTRACT_U_1(obj_tptr + sizeof(struct in6_addr))); + EXTRACT_U_1(obj_tptr + sizeof(nd_ipv6))); ND_PRINT("%s Flags: [0x%02x], DestPort %u", indent, - EXTRACT_U_1((obj_tptr + sizeof(struct in6_addr) + 1)), - EXTRACT_BE_U_2(obj_tptr + sizeof(struct in6_addr) + 2)); + EXTRACT_U_1((obj_tptr + sizeof(nd_ipv6) + 1)), + EXTRACT_BE_U_2(obj_tptr + sizeof(nd_ipv6) + 2)); obj_tlen-=20; obj_tptr+=20; break; @@ -820,22 +818,22 @@ rsvp_obj_print(netdissect_options *ndo, case RSVP_OBJ_CONFIRM: switch(rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: - if (obj_tlen < sizeof(struct in_addr)) + if (obj_tlen < sizeof(nd_ipv4)) return -1; ND_PRINT("%s IPv4 Receiver Address: %s", indent, ipaddr_string(ndo, obj_tptr)); - obj_tlen-=sizeof(struct in_addr); - obj_tptr+=sizeof(struct in_addr); + obj_tlen-=sizeof(nd_ipv4); + obj_tptr+=sizeof(nd_ipv4); break; case RSVP_CTYPE_IPV6: - if (obj_tlen < sizeof(struct in6_addr)) + if (obj_tlen < sizeof(nd_ipv6)) return -1; ND_PRINT("%s IPv6 Receiver Address: %s", indent, ip6addr_string(ndo, obj_tptr)); - obj_tlen-=sizeof(struct in6_addr); - obj_tptr+=sizeof(struct in6_addr); + obj_tlen-=sizeof(nd_ipv6); + obj_tptr+=sizeof(nd_ipv6); break; default: hexdump=TRUE; @@ -845,22 +843,22 @@ rsvp_obj_print(netdissect_options *ndo, case RSVP_OBJ_NOTIFY_REQ: switch(rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: - if (obj_tlen < sizeof(struct in_addr)) + if (obj_tlen < sizeof(nd_ipv4)) return -1; ND_PRINT("%s IPv4 Notify Node Address: %s", indent, ipaddr_string(ndo, obj_tptr)); - obj_tlen-=sizeof(struct in_addr); - obj_tptr+=sizeof(struct in_addr); + obj_tlen-=sizeof(nd_ipv4); + obj_tptr+=sizeof(nd_ipv4); break; case RSVP_CTYPE_IPV6: - if (obj_tlen < sizeof(struct in6_addr)) + if (obj_tlen < sizeof(nd_ipv6)) return-1; ND_PRINT("%s IPv6 Notify Node Address: %s", indent, ip6addr_string(ndo, obj_tptr)); - obj_tlen-=sizeof(struct in6_addr); - obj_tptr+=sizeof(struct in6_addr); + obj_tlen-=sizeof(nd_ipv6); + obj_tptr+=sizeof(nd_ipv6); break; default: hexdump=TRUE; @@ -1084,7 +1082,7 @@ rsvp_obj_print(netdissect_options *ndo, if (obj_tlen < length) { ND_PRINT("%s ERROR: ERO subobject length > object length", indent); break; - }; + } if (length == 0) { /* prevent infinite loops */ ND_PRINT("%s ERROR: zero length ERO subtype", indent); @@ -1185,7 +1183,7 @@ rsvp_obj_print(netdissect_options *ndo, return-1; ND_PRINT("%s Session Name: ", indent); for (i = 0; i < namelen; i++) - safeputchar(ndo, EXTRACT_U_1(obj_tptr + 4 + i)); + fn_print_char(ndo, EXTRACT_U_1(obj_tptr + 4 + i)); ND_PRINT("%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)", indent, EXTRACT_U_1(obj_tptr), @@ -1329,11 +1327,6 @@ rsvp_obj_print(netdissect_options *ndo, obj_tptr+=subobj_len; obj_tlen+=subobj_len; } - - if (total_subobj_len) { - /* unless we have a TLV parser lets just hexdump */ - hexdump=TRUE; - } break; default: @@ -1784,7 +1777,7 @@ rsvp_obj_print(netdissect_options *ndo, ND_PRINT("%s Action: %s (%u), Label type: %u", indent, tok2str(rsvp_obj_label_set_action_values, "Unknown", action), - action, ((EXTRACT_BE_U_4(obj_tptr) & 0x7F))); + action, (EXTRACT_BE_U_4(obj_tptr) & 0x7F)); switch (action) { case LABEL_SET_INCLUSIVE_RANGE: @@ -1868,11 +1861,10 @@ rsvp_obj_print(netdissect_options *ndo, } return 0; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return -1; trunc: - ND_PRINT("\n\t\t"); - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); return -1; } @@ -1885,6 +1877,7 @@ rsvp_print(netdissect_options *ndo, const u_char *tptr; u_short plen, tlen; + ndo->ndo_protocol = "rsvp"; tptr=pptr; rsvp_com_header = (const struct rsvp_common_header *)pptr; @@ -2024,6 +2017,5 @@ rsvp_print(netdissect_options *ndo, return; trunc: - ND_PRINT("\n\t\t"); - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); }