X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fplugins%2Fpppoe%2Fdiscovery.c;fp=pppd%2Fplugins%2Fpppoe%2Fdiscovery.c;h=86ea20715eac0def559f80decbfb79998a4428df;hp=1d3d12ba5884ad39099dcddc4c70c3e478b90951;hb=1c082acf77e6256d9e47a3c9490b7615d591e67b;hpb=af622602ca55d368c03b0ea912479dc84ad543c0 diff --git a/pppd/plugins/pppoe/discovery.c b/pppd/plugins/pppoe/discovery.c index 1d3d12b..86ea207 100644 --- a/pppd/plugins/pppoe/discovery.c +++ b/pppd/plugins/pppoe/discovery.c @@ -148,26 +148,56 @@ parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data, break; case TAG_SERVICE_NAME: pc->seenServiceName = 1; + if (pppoe_verbose >= 1 && len > 0) { + info("Service-Name: %.*s", (int) len, data); + } if (conn->serviceName && len == strlen(conn->serviceName) && !strncmp((char *) data, conn->serviceName, len)) { pc->serviceNameOK = 1; } break; case TAG_AC_COOKIE: - conn->cookie.type = htons(type); - conn->cookie.length = htons(len); - memcpy(conn->cookie.payload, data, len); + if (pppoe_verbose >= 1) { + char buffer[100]; + char *ptr = buffer; + ptr += sprintf(ptr, "Cookie:"); + /* Print first 20 bytes of cookie */ + for (i=0; idiscoveryState != STATE_RECEIVED_PADO) { + conn->cookie.type = htons(type); + conn->cookie.length = htons(len); + memcpy(conn->cookie.payload, data, len); + } break; case TAG_RELAY_SESSION_ID: - conn->relayId.type = htons(type); - conn->relayId.length = htons(len); - memcpy(conn->relayId.payload, data, len); + if (pppoe_verbose >= 1) { + char buffer[100]; + char *ptr = buffer; + ptr += sprintf(ptr, "Relay-ID:"); + /* Print first 20 bytes of relay ID */ + for (i=0; idiscoveryState != STATE_RECEIVED_PADO) { + conn->relayId.type = htons(type); + conn->relayId.length = htons(len); + memcpy(conn->relayId.payload, data, len); + } break; case TAG_PPP_MAX_PAYLOAD: if (len == sizeof(mru)) { memcpy(&mru, data, sizeof(mru)); mru = ntohs(mru); - if (mru >= ETH_PPPOE_MTU) { + info("Max-Payload: %u", (unsigned) mru); + if (mru >= ETH_PPPOE_MTU && conn->discoveryState != STATE_RECEIVED_PADO) { if (conn->mtu > mru) conn->mtu = mru; if (conn->mru > mru) @@ -211,7 +241,9 @@ parsePADSTags(UINT16_t type, UINT16_t len, unsigned char *data, UINT16_t mru; switch(type) { case TAG_SERVICE_NAME: - dbglog("PADS: Service-Name: '%.*s'", (int) len, data); + if (pppoe_verbose >= 1 && len > 0) { + info("PADS: Service-Name: '%.*s'", (int) len, data); + } break; case TAG_PPP_MAX_PAYLOAD: if (len == sizeof(mru)) { @@ -351,7 +383,6 @@ waitForPADO(PPPoEConnection *conn, int timeout) pc.seenACName = 0; pc.seenServiceName = 0; conn->seenMaxPayload = 0; - conn->error = 0; if (get_time(&expire_at) < 0) { error("get_time (waitForPADO): %m"); @@ -379,6 +410,7 @@ waitForPADO(PPPoEConnection *conn, int timeout) return; /* Timed out */ } + conn->error = 0; /* Get the packet */ receivePacket(conn->discoverySocket, &packet, &len); @@ -408,9 +440,9 @@ waitForPADO(PPPoEConnection *conn, int timeout) continue; } if (parsePacket(&packet, parsePADOTags, &pc) < 0) - return; + continue; if (conn->error) - return; + continue; if (!pc.seenACName) { error("Ignoring PADO packet with no AC-Name tag"); continue; @@ -419,14 +451,23 @@ waitForPADO(PPPoEConnection *conn, int timeout) error("Ignoring PADO packet with no Service-Name tag"); continue; } + if (pppoe_verbose >= 1) { + info("AC-Ethernet-Address: %02x:%02x:%02x:%02x:%02x:%02x", + (unsigned) packet.ethHdr.h_source[0], + (unsigned) packet.ethHdr.h_source[1], + (unsigned) packet.ethHdr.h_source[2], + (unsigned) packet.ethHdr.h_source[3], + (unsigned) packet.ethHdr.h_source[4], + (unsigned) packet.ethHdr.h_source[5]); + info("--------------------------------------------------"); + } conn->numPADOs++; - if (pc.acNameOK && pc.serviceNameOK) { + if (pc.acNameOK && pc.serviceNameOK && conn->discoveryState != STATE_RECEIVED_PADO) { memcpy(conn->peerEth, packet.ethHdr.h_source, ETH_ALEN); conn->discoveryState = STATE_RECEIVED_PADO; - break; } } - } while (conn->discoveryState != STATE_RECEIVED_PADO); + } while (pppoe_verbose >= 1 || conn->discoveryState != STATE_RECEIVED_PADO); } /***********************************************************************