From a352af45cf46af5de0c2b2377f0ca8e33776ad6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Fri, 1 Jan 2021 16:24:57 +0100 Subject: [PATCH 1/1] pppoe: Rename variable printACNames to pppoe_verbose to match cmdline option MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Pali Rohár --- pppd/plugins/pppoe/discovery.c | 2 +- pppd/plugins/pppoe/plugin.c | 7 +++---- pppd/plugins/pppoe/pppoe-discovery.c | 22 ++++++++++++---------- pppd/plugins/pppoe/pppoe.h | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pppd/plugins/pppoe/discovery.c b/pppd/plugins/pppoe/discovery.c index 23089df..5569f3e 100644 --- a/pppd/plugins/pppoe/discovery.c +++ b/pppd/plugins/pppoe/discovery.c @@ -138,7 +138,7 @@ parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data, switch(type) { case TAG_AC_NAME: pc->seenACName = 1; - if (conn->printACNames) { + if (pppoe_verbose >= 1) { info("Access-Concentrator: %.*s", (int) len, data); } if (conn->acName && len == strlen(conn->acName) && diff --git a/pppd/plugins/pppoe/plugin.c b/pppd/plugins/pppoe/plugin.c index de9b816..d7c5be1 100644 --- a/pppd/plugins/pppoe/plugin.c +++ b/pppd/plugins/pppoe/plugin.c @@ -64,7 +64,7 @@ extern int new_style_driver; char *pppd_pppoe_service = NULL; static char *acName = NULL; static char *existingSession = NULL; -static int printACNames = 0; +int pppoe_verbose = 0; static char *pppoe_reqd_mac = NULL; unsigned char pppoe_reqd_mac_addr[6]; static char *pppoe_host_uniq; @@ -89,9 +89,9 @@ static option_t Options[] = { "Attach to existing session (sessid:macaddr)" }, { "rp_pppoe_sess", o_string, &existingSession, "Legacy alias for pppoe-sess", OPT_ALIAS }, - { "pppoe-verbose", o_int, &printACNames, + { "pppoe-verbose", o_int, &pppoe_verbose, "Be verbose about discovered access concentrators" }, - { "rp_pppoe_verbose", o_int, &printACNames, + { "rp_pppoe_verbose", o_int, &pppoe_verbose, "Legacy alias for pppoe-verbose", OPT_ALIAS }, { "pppoe-mac", o_string, &pppoe_reqd_mac, "Only connect to specified MAC address" }, @@ -128,7 +128,6 @@ PPPOEInitDevice(void) conn->ifName = devnam; conn->discoverySocket = -1; conn->sessionSocket = -1; - conn->printACNames = printACNames; conn->discoveryTimeout = pppoe_padi_timeout; conn->discoveryAttempts = pppoe_padi_attempts; return 1; diff --git a/pppd/plugins/pppoe/pppoe-discovery.c b/pppd/plugins/pppoe/pppoe-discovery.c index e41d286..6f01790 100644 --- a/pppd/plugins/pppoe/pppoe-discovery.c +++ b/pppd/plugins/pppoe/pppoe-discovery.c @@ -45,6 +45,8 @@ #include #endif +int pppoe_verbose; + char *xstrdup(const char *s); void usage(void); @@ -375,7 +377,7 @@ parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data, switch(type) { case TAG_AC_NAME: pc->seenACName = 1; - if (conn->printACNames) { + if (pppoe_verbose >= 1) { printf("Access-Concentrator: %.*s\n", (int) len, data); } if (conn->acName && len == strlen(conn->acName) && @@ -385,7 +387,7 @@ parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data, break; case TAG_SERVICE_NAME: pc->seenServiceName = 1; - if (conn->printACNames && len > 0) { + if (pppoe_verbose >= 1 && len > 0) { printf(" Service-Name: %.*s\n", (int) len, data); } if (conn->serviceName && len == strlen(conn->serviceName) && @@ -394,7 +396,7 @@ parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data, } break; case TAG_AC_COOKIE: - if (conn->printACNames) { + if (pppoe_verbose >= 1) { printf("Got a cookie:"); /* Print first 20 bytes of cookie */ for (i=0; icookie.payload, data, len); break; case TAG_RELAY_SESSION_ID: - if (conn->printACNames) { + if (pppoe_verbose >= 1) { printf("Got a Relay-ID:"); /* Print first 20 bytes of relay ID */ for (i=0; irelayId.payload, data, len); break; case TAG_SERVICE_NAME_ERROR: - if (conn->printACNames) { + if (pppoe_verbose >= 1) { printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data); } break; case TAG_AC_SYSTEM_ERROR: - if (conn->printACNames) { + if (pppoe_verbose >= 1) { printf("Got a System-Error tag: %.*s\n", (int) len, data); } break; case TAG_GENERIC_ERROR: - if (conn->printACNames) { + if (pppoe_verbose >= 1) { printf("Got a Generic-Error tag: %.*s\n", (int) len, data); } break; @@ -588,7 +590,7 @@ waitForPADO(PPPoEConnection *conn, int timeout) conn->numPADOs++; if (pc.acNameOK && pc.serviceNameOK) { memcpy(conn->peerEth, packet.ethHdr.h_source, ETH_ALEN); - if (conn->printACNames) { + if (pppoe_verbose >= 1) { printf("AC-Ethernet-Address: %02x:%02x:%02x:%02x:%02x:%02x\n", (unsigned) conn->peerEth[0], (unsigned) conn->peerEth[1], @@ -649,7 +651,7 @@ int main(int argc, char *argv[]) memset(conn, 0, sizeof(PPPoEConnection)); - conn->printACNames = 1; + pppoe_verbose = 1; conn->discoveryTimeout = PADI_TIMEOUT; conn->discoveryAttempts = MAX_PADI_ATTEMPTS; @@ -713,7 +715,7 @@ int main(int argc, char *argv[]) conn->ifName = xstrdup(optarg); break; case 'Q': - conn->printACNames = 0; + pppoe_verbose = 0; break; case 'V': case 'h': diff --git a/pppd/plugins/pppoe/pppoe.h b/pppd/plugins/pppoe/pppoe.h index 4e19720..82ae01d 100644 --- a/pppd/plugins/pppoe/pppoe.h +++ b/pppd/plugins/pppoe/pppoe.h @@ -233,7 +233,6 @@ typedef struct PPPoEConnectionStruct { char *acName; /* Desired AC name, if any */ int synchronous; /* Use synchronous PPP */ PPPoETag hostUniq; /* Use Host-Uniq tag */ - int printACNames; /* Just print AC names */ FILE *debugFile; /* Debug file for dumping packets */ int numPADOs; /* Number of PADO packets received */ PPPoETag cookie; /* We have to send this if we get it */ @@ -282,6 +281,7 @@ void discovery(PPPoEConnection *conn); unsigned char *findTag(PPPoEPacket *packet, UINT16_t tagType, PPPoETag *tag); +extern int pppoe_verbose; void pppoe_printpkt(PPPoEPacket *packet, void (*printer)(void *, char *, ...), void *arg); void pppoe_log_packet(const char *prefix, PPPoEPacket *packet); -- 2.39.2