X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/e2982e7f6f0b624a773ec5a58885ee80fab46d34..10ac80fdecfa9b9b7d259d8f50d0b72ef1b18f12:/print-rrcp.c diff --git a/print-rrcp.c b/print-rrcp.c index 94406f9f..831809f0 100644 --- a/print-rrcp.c +++ b/print-rrcp.c @@ -41,10 +41,10 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif -#include +#include "netdissect-stdinc.h" #include "netdissect.h" #include "addrtoname.h" @@ -96,10 +96,10 @@ rrcp_print(netdissect_options *ndo, uint8_t rrcp_proto; uint8_t rrcp_opcode; - ND_TCHECK_1(cp + RRCP_PROTO_OFFSET); - rrcp_proto = EXTRACT_U_1(cp + RRCP_PROTO_OFFSET); + ndo->ndo_protocol = "rrcp"; + rrcp_proto = GET_U_1(cp + RRCP_PROTO_OFFSET); ND_TCHECK_1(cp + RRCP_OPCODE_ISREPLY_OFFSET); - rrcp_opcode = EXTRACT_U_1((cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK; + rrcp_opcode = GET_U_1((cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK; if (src != NULL && dst != NULL) { ND_PRINT("%s > %s, ", (src->addr_string)(ndo, src->addr), @@ -107,7 +107,7 @@ rrcp_print(netdissect_options *ndo, } ND_PRINT("%s %s", tok2str(proto_values,"RRCP-0x%02x",rrcp_proto), - ((EXTRACT_U_1(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"); + ((GET_U_1(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"); if (rrcp_proto==1){ ND_PRINT(": %s", tok2str(opcode_values,"unknown opcode (0x%02x)",rrcp_opcode)); @@ -115,31 +115,28 @@ rrcp_print(netdissect_options *ndo, if (rrcp_opcode==1 || rrcp_opcode==2){ ND_TCHECK_6(cp + RRCP_REG_ADDR_OFFSET); ND_PRINT(" addr=0x%04x, data=0x%08x", - EXTRACT_LE_U_2(cp + RRCP_REG_ADDR_OFFSET), - EXTRACT_LE_U_4(cp + RRCP_REG_DATA_OFFSET)); + GET_LE_U_2(cp + RRCP_REG_ADDR_OFFSET), + GET_LE_U_4(cp + RRCP_REG_DATA_OFFSET)); } if (rrcp_proto==1){ - ND_TCHECK_2(cp + RRCP_AUTHKEY_OFFSET); ND_PRINT(", auth=0x%04x", - EXTRACT_BE_U_2(cp + RRCP_AUTHKEY_OFFSET)); + GET_BE_U_2(cp + RRCP_AUTHKEY_OFFSET)); } if (rrcp_proto==1 && rrcp_opcode==0 && - ((EXTRACT_U_1(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY)){ - ND_TCHECK_4(cp + RRCP_VENDOR_ID_OFFSET); - ND_PRINT(" downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ", - EXTRACT_U_1(cp + RRCP_DOWNLINK_PORT_OFFSET), - EXTRACT_U_1(cp + RRCP_UPLINK_PORT_OFFSET), - etheraddr_string(ndo, cp + RRCP_UPLINK_MAC_OFFSET), - EXTRACT_BE_U_4(cp + RRCP_VENDOR_ID_OFFSET), - EXTRACT_BE_U_2(cp + RRCP_CHIP_ID_OFFSET)); + ((GET_U_1(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY)){ + ND_PRINT(" downlink_port=%u, uplink_port=%u, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ", + GET_U_1(cp + RRCP_DOWNLINK_PORT_OFFSET), + GET_U_1(cp + RRCP_UPLINK_PORT_OFFSET), + GET_ETHERADDR_STRING(cp + RRCP_UPLINK_MAC_OFFSET), + GET_BE_U_4(cp + RRCP_VENDOR_ID_OFFSET), + GET_BE_U_2(cp + RRCP_CHIP_ID_OFFSET)); }else if (rrcp_opcode==1 || rrcp_opcode==2 || rrcp_proto==2){ - ND_TCHECK_4(cp + RRCP_COOKIE2_OFFSET); ND_PRINT(", cookie=0x%08x%08x ", - EXTRACT_BE_U_4(cp + RRCP_COOKIE2_OFFSET), - EXTRACT_BE_U_4(cp + RRCP_COOKIE1_OFFSET)); + GET_BE_U_4(cp + RRCP_COOKIE2_OFFSET), + GET_BE_U_4(cp + RRCP_COOKIE1_OFFSET)); } return; trunc: - ND_PRINT("[|rrcp]"); + nd_print_trunc(ndo); }