ptp: Fix management packet fields

`bp` was modified inside the function but the change was not
reflected back outside, resulting in the fields afterwards accessing
the wrong part of the packet.

Signed-off-by: Casper Andersson <casper.casan@gmail.com>
This commit is contained in:
Casper Andersson 2024-03-11 18:06:11 +01:00 committed by fxlb
parent 40c29b66d7
commit 487405e871

View File

@ -292,10 +292,10 @@ static void ptp_print_2(netdissect_options *ndo, const u_char *bp, u_int len);
static void ptp_print_timestamp(netdissect_options *ndo, const u_char *bp, u_int *len, const char *stype);
static void ptp_print_timestamp_identity(netdissect_options *ndo, const u_char *bp, u_int *len, const char *ttype);
static void ptp_print_announce_msg(netdissect_options *ndo, const u_char *bp, u_int *len);
static void ptp_print_port_id(netdissect_options *ndo, const u_char *bp, u_int *len);
static const u_char *ptp_print_port_id(netdissect_options *ndo, const u_char *bp, u_int *len);
static void ptp_print_mgmt_msg(netdissect_options *ndo, const u_char *bp, u_int *len);
static void
static const u_char *
print_field(netdissect_options *ndo, const char *st, uint32_t flen,
const u_char *bp, u_int *len, uint8_t hex)
{
@ -344,6 +344,8 @@ print_field(netdissect_options *ndo, const char *st, uint32_t flen,
default:
break;
}
return bp;
}
static void
@ -615,7 +617,8 @@ ptp_print_announce_msg(netdissect_options *ndo, const u_char *bp, u_int *len)
bp += 1;
}
static void
static const u_char *
ptp_print_port_id(netdissect_options *ndo, const u_char *bp, u_int *len)
{
uint16_t port_id;
@ -633,14 +636,15 @@ ptp_print_port_id(netdissect_options *ndo, const u_char *bp, u_int *len)
*len -= 2;
bp += 2;
return bp;
}
static void
ptp_print_mgmt_msg(netdissect_options *ndo, const u_char *bp, u_int *len)
{
ptp_print_port_id(ndo, bp, len);
print_field(ndo, ", start boundary hops ", PTP_UCHAR_LEN, bp, len, PTP_FALSE);
print_field(ndo, ", boundary hops ", PTP_UCHAR_LEN, bp, len, PTP_FALSE);
print_field(ndo, ", flags ", PTP_UCHAR_LEN, bp, len, PTP_TRUE);
print_field(ndo, ", reserved ", PTP_UCHAR_LEN, bp, len, PTP_TRUE);
bp = ptp_print_port_id(ndo, bp, len);
bp = print_field(ndo, "start boundary hops:", PTP_UCHAR_LEN, bp, len, PTP_FALSE);
bp = print_field(ndo, "boundary hops:", PTP_UCHAR_LEN, bp, len, PTP_FALSE);
bp = print_field(ndo, "flags:", PTP_UCHAR_LEN, bp, len, PTP_TRUE);
bp = print_field(ndo, "reserved:", PTP_UCHAR_LEN, bp, len, PTP_TRUE);
}