summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-egp.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tcpdump/print-egp.c')
-rw-r--r--contrib/tcpdump/print-egp.c65
1 files changed, 31 insertions, 34 deletions
diff --git a/contrib/tcpdump/print-egp.c b/contrib/tcpdump/print-egp.c
index a60d438..6cfaa30 100644
--- a/contrib/tcpdump/print-egp.c
+++ b/contrib/tcpdump/print-egp.c
@@ -19,38 +19,34 @@
*/
#ifndef lint
-static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.28.4.1 2002/06/01 23:51:12 guy Exp $ (LBL)";
+static const char rcsid[] _U_ =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.34.2.2 2003/11/16 08:51:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/socket.h>
+#include <tcpdump-stdinc.h>
-#include <netinet/in.h>
-
-#include <netdb.h>
#include <stdio.h>
#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
@@ -58,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
@@ -71,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
@@ -91,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
@@ -139,15 +135,15 @@ const char *egp_reasons[] = {
};
static void
-egpnrprint(register const struct egp_packet *egp, register u_int length)
+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;
int gateways, distances, networks;
int t_gateways;
- char *comma;
+ const char *comma;
addr = egp->egp_sourcenet;
if (IN_CLASSA(addr)) {
@@ -163,7 +159,7 @@ egpnrprint(register const struct egp_packet *egp, register u_int length)
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) {
@@ -218,24 +214,25 @@ trunc:
}
void
-egp_print(register const u_char *bp, register u_int length,
- register const u_char *bp2)
+egp_print(register const u_int8_t *bp)
{
register const struct egp_packet *egp;
- register const struct ip *ip;
register int status;
register int code;
register int type;
egp = (struct egp_packet *)bp;
- ip = (struct ip *)bp2;
+ if (!TTEST(*egp)) {
+ printf("[|egp]");
+ return;
+ }
(void)printf("egp: ");
if (egp->egp_version != EGP_VERSION) {
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;
@@ -260,8 +257,8 @@ egp_print(register const u_char *bp, register u_int length,
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:
@@ -332,7 +329,7 @@ egp_print(register const u_char *bp, register u_int length,
egp->egp_intgw,
egp->egp_extgw);
if (vflag)
- egpnrprint(egp, length);
+ egpnrprint(egp);
break;
case EGPT_ERROR:
@@ -342,10 +339,10 @@ egp_print(register const u_char *bp, register u_int length,
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:
OpenPOWER on IntegriCloud