X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/ee68aa36460d7efeca48747f33b7f2adc0900bfb..HEAD:/print-lmp.c?ds=sidebyside diff --git a/print-lmp.c b/print-lmp.c index 1e2d4b98..bfb0798e 100644 --- a/print-lmp.c +++ b/print-lmp.c @@ -18,14 +18,13 @@ /* \summary: Link Management Protocol (LMP) printer */ /* specification: RFC 4204 */ -/* OIF UNI 1.0: http://www.oiforum.com/public/documents/OIF-UNI-01.0.pdf */ +/* OIF UNI 1.0: https://web.archive.org/web/20160401194747/http://www.oiforum.com/public/documents/OIF-UNI-01.0.pdf */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" #include "addrtoname.h" @@ -362,11 +361,6 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr, int hexdump = FALSE; int subobj_type, subobj_len; - union { /* int to float conversion buffer */ - float f; - uint32_t i; - } bw; - while (total_subobj_len > 0 && hexdump == FALSE ) { subobj_type = GET_U_1(obj_tptr + offset); subobj_len = GET_U_1(obj_tptr + offset + 1); @@ -400,12 +394,10 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr, "Unknown", GET_U_1(obj_tptr + offset + 3)), GET_U_1(obj_tptr + offset + 3)); - bw.i = GET_BE_U_4(obj_tptr + offset + 4); ND_PRINT("\n\t Min Reservable Bandwidth: %.3f Mbps", - bw.f*8/1000000); - bw.i = GET_BE_U_4(obj_tptr + offset + 8); + GET_BE_F_4(obj_tptr + offset + 4)*8/1000000); ND_PRINT("\n\t Max Reservable Bandwidth: %.3f Mbps", - bw.f*8/1000000); + GET_BE_F_4(obj_tptr + offset + 8)*8/1000000); break; case WAVELENGTH_SUBOBJ: ND_PRINT("\n\t Wavelength: %u", @@ -427,18 +419,12 @@ lmp_print(netdissect_options *ndo, const u_char *pptr, u_int length) { const struct lmp_common_header *lmp_com_header; - const struct lmp_object_header *lmp_obj_header; const u_char *tptr,*obj_tptr; u_int version_res, tlen, lmp_obj_len, lmp_obj_ctype, obj_tlen; int hexdump; u_int offset; u_int link_type; - union { /* int to float conversion buffer */ - float f; - uint32_t i; - } bw; - ndo->ndo_protocol = "lmp"; tptr=pptr; lmp_com_header = (const struct lmp_common_header *)pptr; @@ -485,11 +471,9 @@ lmp_print(netdissect_options *ndo, tptr+=sizeof(struct lmp_common_header); tlen-=sizeof(struct lmp_common_header); - while(tlen>0) { - /* did we capture enough for fully decoding the object header ? */ - ND_TCHECK_LEN(tptr, sizeof(struct lmp_object_header)); - - lmp_obj_header = (const struct lmp_object_header *)tptr; + while(tlen != 0) { + const struct lmp_object_header *lmp_obj_header = + (const struct lmp_object_header *)tptr; lmp_obj_len=GET_BE_U_2(lmp_obj_header->length); lmp_obj_ctype=GET_U_1(lmp_obj_header->ctype)&0x7f; @@ -551,7 +535,7 @@ lmp_print(netdissect_options *ndo, break; } ND_PRINT("\n\t IPv4 Link ID: %s (0x%08x)", - ipaddr_string(ndo, obj_tptr), + GET_IPADDR_STRING(obj_tptr), GET_BE_U_4(obj_tptr)); break; case LMP_CTYPE_IPV6_LOC: @@ -561,7 +545,7 @@ lmp_print(netdissect_options *ndo, break; } ND_PRINT("\n\t IPv6 Link ID: %s (0x%08x)", - ip6addr_string(ndo, obj_tptr), + GET_IP6ADDR_STRING(obj_tptr), GET_BE_U_4(obj_tptr)); break; case LMP_CTYPE_UNMD_LOC: @@ -613,7 +597,7 @@ lmp_print(netdissect_options *ndo, break; } ND_PRINT("\n\t Node ID: %s (0x%08x)", - ipaddr_string(ndo, obj_tptr), + GET_IPADDR_STRING(obj_tptr), GET_BE_U_4(obj_tptr)); break; @@ -670,9 +654,9 @@ lmp_print(netdissect_options *ndo, ND_PRINT("\n\t Local Link-ID: %s (0x%08x)" "\n\t Remote Link-ID: %s (0x%08x)", - ipaddr_string(ndo, obj_tptr+4), + GET_IPADDR_STRING(obj_tptr+4), GET_BE_U_4(obj_tptr + 4), - ipaddr_string(ndo, obj_tptr+8), + GET_IPADDR_STRING(obj_tptr+8), GET_BE_U_4(obj_tptr + 8)); break; @@ -688,9 +672,9 @@ lmp_print(netdissect_options *ndo, ND_PRINT("\n\t Local Link-ID: %s (0x%08x)" "\n\t Remote Link-ID: %s (0x%08x)", - ip6addr_string(ndo, obj_tptr+4), + GET_IP6ADDR_STRING(obj_tptr+4), GET_BE_U_4(obj_tptr + 4), - ip6addr_string(ndo, obj_tptr+20), + GET_IP6ADDR_STRING(obj_tptr+20), GET_BE_U_4(obj_tptr + 20)); break; @@ -730,9 +714,9 @@ lmp_print(netdissect_options *ndo, GET_U_1(obj_tptr))); ND_PRINT("\n\t Local Interface ID: %s (0x%08x)" "\n\t Remote Interface ID: %s (0x%08x)", - ipaddr_string(ndo, obj_tptr+4), + GET_IPADDR_STRING(obj_tptr+4), GET_BE_U_4(obj_tptr + 4), - ipaddr_string(ndo, obj_tptr+8), + GET_IPADDR_STRING(obj_tptr+8), GET_BE_U_4(obj_tptr + 8)); if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12)) @@ -750,9 +734,9 @@ lmp_print(netdissect_options *ndo, GET_U_1(obj_tptr))); ND_PRINT("\n\t Local Interface ID: %s (0x%08x)" "\n\t Remote Interface ID: %s (0x%08x)", - ip6addr_string(ndo, obj_tptr+4), + GET_IP6ADDR_STRING(obj_tptr+4), GET_BE_U_4(obj_tptr + 4), - ip6addr_string(ndo, obj_tptr+20), + GET_IP6ADDR_STRING(obj_tptr+20), GET_BE_U_4(obj_tptr + 20)); if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 36, 36)) @@ -805,8 +789,8 @@ lmp_print(netdissect_options *ndo, GET_BE_U_2(obj_tptr + 10), GET_BE_U_2(obj_tptr + 10), GET_BE_U_2(obj_tptr + 10)&8000 ? " (Payload test messages capable)" : ""); - bw.i = GET_BE_U_4(obj_tptr + 12); - ND_PRINT("\n\t Transmission Rate: %.3f Mbps",bw.f*8/1000000); + ND_PRINT("\n\t Transmission Rate: %.3f Mbps", + GET_BE_F_4(obj_tptr + 12)*8/1000000); ND_PRINT("\n\t Wavelength: %u", GET_BE_U_4(obj_tptr + 16)); break; @@ -857,7 +841,7 @@ lmp_print(netdissect_options *ndo, /* Decode pairs: */ while (offset+8 <= obj_tlen) { ND_PRINT("\n\t Interface ID: %s (0x%08x)", - ipaddr_string(ndo, obj_tptr+offset), + GET_IPADDR_STRING(obj_tptr+offset), GET_BE_U_4(obj_tptr + offset)); ND_PRINT("\n\t\t Active: %s (%u)", @@ -884,7 +868,7 @@ lmp_print(netdissect_options *ndo, /* Decode pairs: */ while (offset+20 <= obj_tlen) { ND_PRINT("\n\t Interface ID: %s (0x%08x)", - ip6addr_string(ndo, obj_tptr+offset), + GET_IP6ADDR_STRING(obj_tptr+offset), GET_BE_U_4(obj_tptr + offset)); ND_PRINT("\n\t\t Active: %s (%u)", @@ -944,7 +928,7 @@ lmp_print(netdissect_options *ndo, offset = 0; while (offset+4 <= obj_tlen) { ND_PRINT("\n\t Interface ID: %s (0x%08x)", - ipaddr_string(ndo, obj_tptr+offset), + GET_IPADDR_STRING(obj_tptr+offset), GET_BE_U_4(obj_tptr + offset)); offset+=4; } @@ -954,7 +938,7 @@ lmp_print(netdissect_options *ndo, offset = 0; while (offset+16 <= obj_tlen) { ND_PRINT("\n\t Interface ID: %s (0x%08x)", - ip6addr_string(ndo, obj_tptr+offset), + GET_IP6ADDR_STRING(obj_tptr+offset), GET_BE_U_4(obj_tptr + offset)); offset+=16; } @@ -1074,7 +1058,7 @@ lmp_print(netdissect_options *ndo, GET_BE_U_2(obj_tptr + 10)); ND_PRINT("\n\t Local Interface ID: %s (0x%08x)", - ipaddr_string(ndo, obj_tptr+12), + GET_IPADDR_STRING(obj_tptr+12), GET_BE_U_4(obj_tptr + 12)); break; @@ -1136,7 +1120,4 @@ lmp_print(netdissect_options *ndo, tptr+=lmp_obj_len; tlen-=lmp_obj_len; } - return; -trunc: - nd_print_trunc(ndo); }