From 2c4bd7162fb05af23242f44b64c9039b05d0e8b6 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 2 Jun 2012 02:07:49 +0200 Subject: [PATCH] print packet functions are now optional --- src/netif/ppp/ccp.c | 6 ++++++ src/netif/ppp/chap-new.c | 6 ++++++ src/netif/ppp/eap.c | 7 +++++++ src/netif/ppp/ecp.c | 6 ++++++ src/netif/ppp/ipcp.c | 8 +++++++- src/netif/ppp/lcp.c | 6 ++++++ src/netif/ppp/pppd.h | 2 ++ src/netif/ppp/upap.c | 6 ++++++ src/netif/ppp/utils.c | 6 ++++++ 9 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/netif/ppp/ccp.c b/src/netif/ppp/ccp.c index 3cc8d8f3..6c3aa63a 100644 --- a/src/netif/ppp/ccp.c +++ b/src/netif/ppp/ccp.c @@ -176,9 +176,11 @@ static void ccp_lowerup __P((int unit)); static void ccp_lowerdown __P((int)); static void ccp_input __P((int unit, u_char *pkt, int len)); static void ccp_protrej __P((int unit)); +#if PRINTPKT_SUPPORT static int ccp_printpkt __P((u_char *pkt, int len, void (*printer) __P((void *, char *, ...)), void *arg)); +#endif /* PRINTPKT_SUPPORT */ static void ccp_datainput __P((int unit, u_char *pkt, int len)); struct protent ccp_protent = { @@ -190,7 +192,9 @@ struct protent ccp_protent = { ccp_lowerdown, ccp_open, ccp_close, +#if PRINTPKT_SUPPORT ccp_printpkt, +#endif /* PRINTPKT_SUPPORT */ ccp_datainput, 1, "CCP", @@ -1484,6 +1488,7 @@ ccp_down(f) #endif } +#if PRINTPKT_SUPPORT /* * Print the contents of a CCP packet. */ @@ -1614,6 +1619,7 @@ ccp_printpkt(p, plen, printer, arg) return p - p0; } +#endif /* PRINTPKT_SUPPORT */ /* * We have received a packet that the decompressor failed to diff --git a/src/netif/ppp/chap-new.c b/src/netif/ppp/chap-new.c index a517b23d..fbb73da4 100644 --- a/src/netif/ppp/chap-new.c +++ b/src/netif/ppp/chap-new.c @@ -135,8 +135,10 @@ static void chap_handle_status(struct chap_client_state *cs, int code, int id, unsigned char *pkt, int len); static void chap_protrej(int unit); static void chap_input(int unit, unsigned char *pkt, int pktlen); +#if PRINTPKT_SUPPORT static int chap_print_pkt(unsigned char *p, int plen, void (*printer) __P((void *, char *, ...)), void *arg); +#endif /* PRINTPKT_SUPPORT */ /* List of digest types that we know about */ static struct chap_digest_type *chap_digests; @@ -589,6 +591,7 @@ chap_protrej(int unit) } } +#if PRINTPKT_SUPPORT /* * chap_print_pkt - print the contents of a CHAP packet. */ @@ -650,6 +653,7 @@ chap_print_pkt(unsigned char *p, int plen, return len + CHAP_HDRLEN; } +#endif /* PRINTPKT_SUPPORT */ struct protent chap_protent = { PPP_CHAP, @@ -660,7 +664,9 @@ struct protent chap_protent = { chap_lowerdown, NULL, /* open */ NULL, /* close */ +#if PRINTPKT_SUPPORT chap_print_pkt, +#endif /* PRINTPKT_SUPPORT */ NULL, /* datainput */ 1, /* enabled_flag */ "CHAP", /* name */ diff --git a/src/netif/ppp/eap.c b/src/netif/ppp/eap.c index b08f6c68..06aac356 100644 --- a/src/netif/ppp/eap.c +++ b/src/netif/ppp/eap.c @@ -101,8 +101,10 @@ static void eap_input __P((int unit, u_char *inp, int inlen)); static void eap_protrej __P((int unit)); static void eap_lowerup __P((int unit)); static void eap_lowerdown __P((int unit)); +#if PRINTPKT_SUPPORT static int eap_printpkt __P((u_char *inp, int inlen, void (*)(void *arg, char *fmt, ...), void *arg)); +#endif /* PRINTPKT_SUPPORT */ struct protent eap_protent = { PPP_EAP, /* protocol number */ @@ -113,7 +115,9 @@ struct protent eap_protent = { eap_lowerdown, /* lower layer has gone down */ NULL, /* open the protocol */ NULL, /* close the protocol */ +#if PRINTPKT_SUPPORT eap_printpkt, /* print a packet in readable form */ +#endif /* PRINTPKT_SUPPORT */ NULL, /* process a received data packet */ 1, /* protocol enabled */ "EAP", /* text name of protocol */ @@ -2122,6 +2126,7 @@ int inlen; } } +#if PRINTPKT_SUPPORT /* * eap_printpkt - print the contents of an EAP packet. */ @@ -2423,4 +2428,6 @@ void *arg; return (inp - pstart); } +#endif /* PRINTPKT_SUPPORT */ + #endif /* PPP_SUPPORT && EAP_SUPPORT */ diff --git a/src/netif/ppp/ecp.c b/src/netif/ppp/ecp.c index ef20e791..a8c7ce67 100644 --- a/src/netif/ppp/ecp.c +++ b/src/netif/ppp/ecp.c @@ -93,9 +93,11 @@ static void ecp_lowerdown __P((int)); static void ecp_input __P((int unit, u_char *pkt, int len)); static void ecp_protrej __P((int unit)); */ +#if PRINTPKT_SUPPORT static int ecp_printpkt __P((u_char *pkt, int len, void (*printer) __P((void *, char *, ...)), void *arg)); +#endif /* PRINTPKT_SUPPORT */ /* static void ecp_datainput __P((int unit, u_char *pkt, int len)); */ @@ -109,7 +111,9 @@ struct protent ecp_protent = { NULL, /* ecp_lowerdown, */ NULL, /* ecp_open, */ NULL, /* ecp_close, */ +#if PRINTPKT_SUPPORT ecp_printpkt, +#endif /* PRINTPKT_SUPPORT */ NULL, /* ecp_datainput, */ 0, "ECP", @@ -170,6 +174,7 @@ ecp_init(unit) } +#if PRINTPKT_SUPPORT static int ecp_printpkt(p, plen, printer, arg) u_char *p; @@ -179,5 +184,6 @@ ecp_printpkt(p, plen, printer, arg) { return 0; } +#endif /* PRINTPKT_SUPPORT */ #endif /* PPP_SUPPORT && ECP_SUPPORT */ diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index 646f52ac..40343ab0 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -256,8 +256,10 @@ static void ipcp_lowerup __P((int)); static void ipcp_lowerdown __P((int)); static void ipcp_input __P((int, u_char *, int)); static void ipcp_protrej __P((int)); +#if PRINTPKT_SUPPORT static int ipcp_printpkt __P((u_char *, int, void (*) __P((void *, char *, ...)), void *)); +#endif /* PRINTPKT_SUPPORT */ static void ip_check_options __P((void)); #if DEMAND_SUPPORT static int ip_demand_conf __P((int)); @@ -274,7 +276,9 @@ struct protent ipcp_protent = { ipcp_lowerdown, ipcp_open, ipcp_close, +#if PRINTPKT_SUPPORT ipcp_printpkt, +#endif /* PRINTPKT_SUPPORT */ NULL, 1, "IPCP", @@ -2059,6 +2063,7 @@ create_resolv(peerdns1, peerdns2) /* FIXME: do we need to set here the DNS servers ? */ } +#if PRINTPKT_SUPPORT /* * ipcp_printpkt - print the contents of an IPCP packet. */ @@ -2185,7 +2190,9 @@ ipcp_printpkt(p, plen, printer, arg) return p - pstart; } +#endif /* PRINTPKT_SUPPORT */ +#if DEMAND_SUPPORT /* * ip_active_pkt - see if this IP packet is worth bringing the link up for. * We don't bring the link up for IP fragments or for TCP FIN packets @@ -2199,7 +2206,6 @@ ipcp_printpkt(p, plen, printer, arg) #define TCP_HDRLEN 20 #define TH_FIN 0x01 -#if DEMAND_SUPPORT /* * We use these macros because the IP header may be at an odd address, * and some compilers might use word loads to get th_off or ip_hl. diff --git a/src/netif/ppp/lcp.c b/src/netif/ppp/lcp.c index cc83f528..4f8f17cb 100644 --- a/src/netif/ppp/lcp.c +++ b/src/netif/ppp/lcp.c @@ -264,8 +264,10 @@ static fsm_callbacks lcp_callbacks = { /* LCP callback routines */ static void lcp_init __P((int)); static void lcp_input __P((int, u_char *, int)); static void lcp_protrej __P((int)); +#if PRINTPKT_SUPPORT static int lcp_printpkt __P((u_char *, int, void (*) __P((void *, char *, ...)), void *)); +#endif /* PRINTPKT_SUPPORT */ struct protent lcp_protent = { PPP_LCP, @@ -276,7 +278,9 @@ struct protent lcp_protent = { lcp_lowerdown, lcp_open, lcp_close, +#if PRINTPKT_SUPPORT lcp_printpkt, +#endif /* PRINTPKT_SUPPORT */ NULL, 1, "LCP", @@ -2249,6 +2253,7 @@ lcp_finished(f) } +#if PRINTPKT_SUPPORT /* * lcp_printpkt - print the contents of an LCP packet. */ @@ -2503,6 +2508,7 @@ lcp_printpkt(p, plen, printer, arg) return p - pstart; } +#endif /* PRINTPKT_SUPPORT */ /* * Time to shut down the link because there is nothing out there. diff --git a/src/netif/ppp/pppd.h b/src/netif/ppp/pppd.h index 8056c74b..6bf117d4 100644 --- a/src/netif/ppp/pppd.h +++ b/src/netif/ppp/pppd.h @@ -422,10 +422,12 @@ struct protent { void (*open) __P((int unit)); /* Close the protocol */ void (*close) __P((int unit, char *reason)); +#if PRINTPKT_SUPPORT /* Print a packet in readable form */ int (*printpkt) __P((u_char *pkt, int len, void (*printer) __P((void *, char *, ...)), void *arg)); +#endif /* PRINTPKT_SUPPORT */ /* Process a received data packet */ void (*datainput) __P((int unit, u_char *pkt, int len)); bool enabled_flag; /* 0 iff protocol is disabled */ diff --git a/src/netif/ppp/upap.c b/src/netif/ppp/upap.c index e989a430..239eae11 100644 --- a/src/netif/ppp/upap.c +++ b/src/netif/ppp/upap.c @@ -84,8 +84,10 @@ static void upap_lowerup __P((int)); static void upap_lowerdown __P((int)); static void upap_input __P((int, u_char *, int)); static void upap_protrej __P((int)); +#if PRINTPKT_SUPPORT static int upap_printpkt __P((u_char *, int, void (*) __P((void *, char *, ...)), void *)); +#endif /* PRINTPKT_SUPPORT */ struct protent pap_protent = { PPP_PAP, @@ -96,7 +98,9 @@ struct protent pap_protent = { upap_lowerdown, NULL, NULL, +#if PRINTPKT_SUPPORT upap_printpkt, +#endif /* PRINTPKT_SUPPORT */ NULL, 1, "PAP", @@ -612,6 +616,7 @@ upap_sresp(u, code, id, msg, msglen) output(u->us_unit, outpacket_buf, outlen + PPP_HDRLEN); } +#if PRINTPKT_SUPPORT /* * upap_printpkt - print the contents of a PAP packet. */ @@ -691,5 +696,6 @@ upap_printpkt(p, plen, printer, arg) return p - pstart; } +#endif /* PRINTPKT_SUPPORT */ #endif /* PPP_SUPPORT && PAP_SUPPORT */ diff --git a/src/netif/ppp/utils.c b/src/netif/ppp/utils.c index 885f3bd7..21fb4e5b 100644 --- a/src/netif/ppp/utils.c +++ b/src/netif/ppp/utils.c @@ -70,8 +70,10 @@ extern char *strerror(); static void logit __P((int, char *, va_list)); static void log_write __P((int, char *)); static void vslp_printer __P((void *, char *, ...)); +#if PRINTPKT_SUPPORT static void format_packet __P((u_char *, int, void (*) (void *, char *, ...), void *)); +#endif /* PRINTPKT_SUPPORT */ struct buffer_info { char *ptr; @@ -354,6 +356,7 @@ vslprintf(buf, buflen, fmt, args) OUTCHAR(c); } continue; +#if PRINTPKT_SUPPORT case 'P': /* print PPP packet */ bufinfo.ptr = buf; bufinfo.len = buflen + 1; @@ -363,6 +366,7 @@ vslprintf(buf, buflen, fmt, args) buf = bufinfo.ptr; buflen = bufinfo.len - 1; continue; +#endif /* PRINTPKT_SUPPORT */ case 'B': p = va_arg(args, unsigned char *); for (n = prec; n > 0; --n) { @@ -469,6 +473,7 @@ log_packet(p, len, prefix, level) } #endif /* unused */ +#if PRINTPKT_SUPPORT /* * format_packet - make a readable representation of a packet, * calling `printer(arg, format, ...)' to output it. @@ -518,6 +523,7 @@ format_packet(p, len, printer, arg) else printer(arg, "%.*B", len, p); } +#endif /* PRINTPKT_SUPPORT */ /* * init_pr_log, end_pr_log - initialize and finish use of pr_log.