X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/9d046ee0503d4c8cbfcb200c88986de876f6cae7..d9a787e4995b4b5101e410ed1e93367907ab9fe2:/print-ptp.c diff --git a/print-ptp.c b/print-ptp.c index 71a82042..6f12b90a 100644 --- a/print-ptp.c +++ b/print-ptp.c @@ -24,7 +24,6 @@ #include "netdissect-stdinc.h" #include "netdissect.h" #include "extract.h" -#include /* * PTP header @@ -259,9 +258,9 @@ static const struct tok ptp_flag_values[] = { ND_PRINT("(%s)", tok2str(ptp_msg_type, "unknown", e)); \ } -const char *p_porigin_ts = "preciseOriginTimeStamp"; -const char *p_origin_ts = "originTimeStamp"; -const char *p_recv_ts = "receiveTimeStamp"; +static const char *p_porigin_ts = "preciseOriginTimeStamp"; +static const char *p_origin_ts = "originTimeStamp"; +static const char *p_recv_ts = "receiveTimeStamp"; #define PTP_VER_1 0x1 #define PTP_VER_2 0x2 @@ -340,7 +339,8 @@ ptp_print_1(netdissect_options *ndo) ND_PRINT(" (not implemented)"); } -static void ptp_print_2(netdissect_options *ndo, const u_char *bp, u_int length) +static void +ptp_print_2(netdissect_options *ndo, const u_char *bp, u_int length) { u_int len = length; uint16_t msg_len, flags, port_id, seq_id; @@ -358,7 +358,7 @@ static void ptp_print_2(netdissect_options *ndo, const u_char *bp, u_int length) len -= 2; bp += 2; msg_len = GET_BE_U_2(bp); ND_PRINT(", length : %u", msg_len); /* domain */ - len -= 2; bp += 2; domain_no = GET_BE_U_2(bp) & PTP_DOMAIN_MASK; ND_PRINT(", domain : %u", domain_no); + len -= 2; bp += 2; domain_no = (GET_BE_U_2(bp) & PTP_DOMAIN_MASK) >> 8; ND_PRINT(", domain : %u", domain_no); /* rsvd 1*/ rsvd1 = GET_BE_U_2(bp) & PTP_RSVD1_MASK; @@ -456,7 +456,6 @@ ptp_print(netdissect_options *ndo, const u_char *bp, u_int len) trunc: nd_print_trunc(ndo); - return; } static void @@ -467,7 +466,7 @@ ptp_print_timestamp(netdissect_options *ndo, const u_char *bp, u_int *len, const ND_PRINT(", %s :", stype); /* sec time stamp 6 bytes */ - secs = GET_BE_U_2(bp) + GET_BE_U_4(bp+2); + secs = GET_BE_U_6(bp); ND_PRINT(" %"PRIu64" seconds,", secs); *len -= 6; bp += 6; @@ -489,7 +488,7 @@ ptp_print_timestamp_identity(netdissect_options *ndo, ND_PRINT(", %s :", ttype); /* sec time stamp 6 bytes */ - secs = GET_BE_U_2(bp) + GET_BE_U_4(bp+2); + secs = GET_BE_U_6(bp); ND_PRINT(" %"PRIu64" seconds,", secs); *len -= 6; bp += 6; @@ -523,7 +522,7 @@ ptp_print_announce_msg(netdissect_options *ndo, const u_char *bp, u_int *len) ND_PRINT(", %s :", p_origin_ts); /* sec time stamp 6 bytes */ - secs = GET_BE_U_2(bp) + GET_BE_U_4(bp+2); + secs = GET_BE_U_6(bp); ND_PRINT(" %"PRIu64" seconds", secs); *len -= 6; bp += 6;