X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/c422d3ab0f6de2d38512a4566637bc47df291e74..ffa1470e5c7ff0e50028d085a481dc797b0b51ed:/print-egp.c diff --git a/print-egp.c b/print-egp.c index 5ad20f02..46c276c7 100644 --- a/print-egp.c +++ b/print-egp.c @@ -19,8 +19,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.32 2002-09-05 21:25:40 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.37 2005-01-12 11:19:09 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -33,19 +33,20 @@ static const char rcsid[] = #include "interface.h" #include "addrtoname.h" +#include "extract.h" #include "ip.h" struct egp_packet { - u_char egp_version; + u_int8_t egp_version; #define EGP_VERSION 2 - u_char egp_type; + u_int8_t egp_type; #define EGPT_ACQUIRE 3 #define EGPT_REACH 5 #define EGPT_POLL 2 #define EGPT_UPDATE 1 #define EGPT_ERROR 8 - u_char egp_code; + u_int8_t egp_code; #define EGPC_REQUEST 0 #define EGPC_CONFIRM 1 #define EGPC_REFUSE 2 @@ -53,7 +54,7 @@ struct egp_packet { #define EGPC_CEASEACK 4 #define EGPC_HELLO 0 #define EGPC_HEARDU 1 - u_char egp_status; + u_int8_t egp_status; #define EGPS_UNSPEC 0 #define EGPS_ACTIVE 1 #define EGPS_PASSIVE 2 @@ -66,13 +67,13 @@ struct egp_packet { #define EGPS_UP 1 #define EGPS_DOWN 2 #define EGPS_UNSOL 0x80 - u_short egp_checksum; - u_short egp_as; - u_short egp_sequence; + u_int16_t egp_checksum; + u_int16_t egp_as; + u_int16_t egp_sequence; union { - u_short egpu_hello; - u_char egpu_gws[2]; - u_short egpu_reason; + u_int16_t egpu_hello; + u_int8_t egpu_gws[2]; + u_int16_t egpu_reason; #define EGPR_UNSPEC 0 #define EGPR_BADHEAD 1 #define EGPR_BADDATA 2 @@ -86,7 +87,7 @@ struct egp_packet { #define egp_extgw egp_handg.egpu_gws[1] #define egp_reason egp_handg.egpu_reason union { - u_short egpu_poll; + u_int16_t egpu_poll; u_int32_t egpu_sourcenet; } egp_pands; #define egp_poll egp_pands.egpu_poll @@ -136,7 +137,7 @@ const char *egp_reasons[] = { static void egpnrprint(register const struct egp_packet *egp) { - register const u_char *cp; + register const u_int8_t *cp; u_int32_t addr; register u_int32_t net; register u_int netlen; @@ -158,7 +159,7 @@ egpnrprint(register const struct egp_packet *egp) net = 0; netlen = 0; } - cp = (u_char *)(egp + 1); + cp = (u_int8_t *)(egp + 1); t_gateways = egp->egp_intgw + egp->egp_extgw; for (gateways = 0; gateways < t_gateways; ++gateways) { @@ -213,7 +214,7 @@ trunc: } void -egp_print(register const u_char *bp) +egp_print(register const u_int8_t *bp, register u_int length) { register const struct egp_packet *egp; register int status; @@ -221,7 +222,7 @@ egp_print(register const u_char *bp) register int type; egp = (struct egp_packet *)bp; - if (!TTEST(*egp)) { + if (!TTEST2(*egp, length)) { printf("[|egp]"); return; } @@ -231,7 +232,7 @@ egp_print(register const u_char *bp) printf("[version %d]", egp->egp_version); return; } - printf("as:%d seq:%d", ntohs(egp->egp_as), ntohs(egp->egp_sequence)); + printf("as:%d seq:%d", EXTRACT_16BITS(&egp->egp_as), EXTRACT_16BITS(&egp->egp_sequence)); type = egp->egp_type; code = egp->egp_code; @@ -256,8 +257,8 @@ egp_print(register const u_char *bp) break; } printf(" hello:%d poll:%d", - ntohs(egp->egp_hello), - ntohs(egp->egp_poll)); + EXTRACT_16BITS(&egp->egp_hello), + EXTRACT_16BITS(&egp->egp_poll)); break; case EGPC_REFUSE: @@ -338,10 +339,10 @@ egp_print(register const u_char *bp) else printf(" [status %d]", status); - if (ntohs(egp->egp_reason) <= EGPR_UVERSION) - printf(" %s", egp_reasons[ntohs(egp->egp_reason)]); + if (EXTRACT_16BITS(&egp->egp_reason) <= EGPR_UVERSION) + printf(" %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]); else - printf(" [reason %d]", ntohs(egp->egp_reason)); + printf(" [reason %d]", EXTRACT_16BITS(&egp->egp_reason)); break; default: