From: Pali Rohár Date: Fri, 1 Jan 2021 15:38:03 +0000 (+0100) Subject: pppoe: Dump discovery packets when pppoe-verbose option is set to >= 2 X-Git-Tag: ppp-2.5.0~50^2~4 X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=379943e12ea96f9133f3765e5c36c3405babada2;ds=sidebyside pppoe: Dump discovery packets when pppoe-verbose option is set to >= 2 Signed-off-by: Pali Rohár --- diff --git a/pppd/plugins/pppoe/common.c b/pppd/plugins/pppoe/common.c index 9ea7fd6..9140ea9 100644 --- a/pppd/plugins/pppoe/common.c +++ b/pppd/plugins/pppoe/common.c @@ -160,6 +160,42 @@ sendPADT(PPPoEConnection *conn, char const *msg) info("Sent PADT"); } +static void +pppoe_printpkt_hex(void (*printer)(void *, char *, ...), void *arg, unsigned char const *buf, int len) +{ + int i; + int base; + + /* do NOT dump PAP packets */ + if (len >= 2 && buf[0] == 0xC0 && buf[1] == 0x23) { + printer(arg, "(PAP Authentication Frame -- Contents not dumped)\n"); + return; + } + + for (base=0; baseethHdr.h_dest)); printer(arg, " src %02x:%02x:%02x:%02x:%02x:%02x\n", EH(packet->ethHdr.h_source)); + if (pppoe_verbose >= 2) + pppoe_printpkt_hex(printer, arg, packet->payload, ntohs(packet->length)); if (ntohs(packet->ethHdr.h_proto) != ETH_PPPOE_DISCOVERY) return; diff --git a/pppd/pppd.8 b/pppd/pppd.8 index 36156d6..cbbcb45 100644 --- a/pppd/pppd.8 +++ b/pppd/pppd.8 @@ -1243,8 +1243,9 @@ Attach to existing PPPoE session. For backward compatibility also \fBrp_pppoe_sess\fP option name is supported. .TP .B pppoe-verbose \fIn -Be verbose about discovered access concentrators. For backward -compatibility also \fBrp_pppoe_verbose\fP option name is supported. +Be verbose about discovered access concentrators. When set to 2 or bigger +value then dump also discovery packets. For backward compatibility also +\fBrp_pppoe_verbose\fP option name is supported. .TP .B pppoe-mac \fImacaddr Connect to specified MAC address.