X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/ed85e20e4d6a27d5405f37366dd34b64c10a9211..96afbce6fc40e89e4f215db5838ae00979185e11:/print-timed.c diff --git a/print-timed.c b/print-timed.c index dc2b24a4..34eb6168 100644 --- a/print-timed.c +++ b/print-timed.c @@ -19,18 +19,21 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define NETDISSECT_REWORKED +/* \summary: BSD time daemon protocol printer */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include -#include "interface.h" +#include "netdissect.h" #include "extract.h" /* * Time Synchronization Protocol + * + * http://docs.freebsd.org/44doc/smm/12.timed/paper.pdf */ struct tsp_timeval { @@ -39,8 +42,8 @@ struct tsp_timeval { }; struct tsp { - uint8_t tsp_type; - uint8_t tsp_vers; + uint8_t tsp_type; + uint8_t tsp_vers; uint16_t tsp_seq; union { struct tsp_timeval tspu_time; @@ -93,9 +96,9 @@ static const char *tsptype[TSPTYPENUMBER] = void timed_print(netdissect_options *ndo, - register const u_char *bp) + const u_char *bp) { - struct tsp *tsp = (struct tsp *)bp; + const struct tsp *tsp = (const struct tsp *)bp; long sec, usec; ND_TCHECK(tsp->tsp_type); @@ -120,11 +123,11 @@ timed_print(netdissect_options *ndo, case TSP_SETDATE: case TSP_SETDATEREQ: ND_TCHECK(tsp->tsp_time); - sec = EXTRACT_32BITS(&tsp->tsp_time.tv_sec); - usec = EXTRACT_32BITS(&tsp->tsp_time.tv_usec); + sec = EXTRACT_BE_U_4(&tsp->tsp_time.tv_sec); + usec = EXTRACT_BE_U_4(&tsp->tsp_time.tv_usec); /* XXX The comparison below is always false? */ if (usec < 0) - /* corrupt, skip the rest of the packet */ + /* invalid, skip the rest of the packet */ return; ND_PRINT((ndo, " time ")); if (sec < 0 && usec != 0) { @@ -138,7 +141,7 @@ timed_print(netdissect_options *ndo, } ND_TCHECK(tsp->tsp_name); ND_PRINT((ndo, " name ")); - if (fn_print(ndo, (u_char *)tsp->tsp_name, (u_char *)tsp->tsp_name + sizeof(tsp->tsp_name))) + if (fn_print(ndo, (const u_char *)tsp->tsp_name, (const u_char *)tsp->tsp_name + sizeof(tsp->tsp_name))) goto trunc; return;