]> git.ozlabs.org Git - ppp.git/commitdiff
pppoe: Split function discovery() into phases discovery1() and discovery2()
authorPali Rohár <pali@kernel.org>
Fri, 1 Jan 2021 15:28:22 +0000 (16:28 +0100)
committerPali Rohár <pali@kernel.org>
Mon, 4 Jan 2021 23:43:56 +0000 (00:43 +0100)
pppoe-discovery.c needs to call only the first phase of discovery.

Signed-off-by: Pali Rohár <pali@kernel.org>
pppd/plugins/pppoe/discovery.c
pppd/plugins/pppoe/plugin.c
pppd/plugins/pppoe/pppoe.h

index 5569f3e06898c240c894da2454039349c468f54a..1c55b3680521e6501e25caf2db967cb173e7bedf 100644 (file)
@@ -605,19 +605,18 @@ waitForPADS(PPPoEConnection *conn, int timeout)
 }
 
 /**********************************************************************
-*%FUNCTION: discovery
+*%FUNCTION: discovery1
 *%ARGUMENTS:
 * conn -- PPPoE connection info structure
 *%RETURNS:
 * Nothing
 *%DESCRIPTION:
-* Performs the PPPoE discovery phase
+* Performs the PPPoE discovery phase 1
 ***********************************************************************/
 void
-discovery(PPPoEConnection *conn)
+discovery1(PPPoEConnection *conn)
 {
     int padiAttempts = 0;
-    int padrAttempts = 0;
     int timeout = conn->discoveryTimeout;
 
     do {
@@ -634,8 +633,23 @@ discovery(PPPoEConnection *conn)
 
        timeout *= 2;
     } while (conn->discoveryState == STATE_SENT_PADI);
+}
+
+/**********************************************************************
+*%FUNCTION: discovery2
+*%ARGUMENTS:
+* conn -- PPPoE connection info structure
+*%RETURNS:
+* Nothing
+*%DESCRIPTION:
+* Performs the PPPoE discovery phase 2
+***********************************************************************/
+void
+discovery2(PPPoEConnection *conn)
+{
+    int padrAttempts = 0;
+    int timeout = conn->discoveryTimeout;
 
-    timeout = conn->discoveryTimeout;
     do {
        padrAttempts++;
        if (got_sigterm || padrAttempts > conn->discoveryAttempts) {
index d7c5be1d9ee6f77f00968bd45d76b21e4ef2ac38..57324607d9e9acc7226a802b8d019544602c2f90 100644 (file)
@@ -216,9 +216,14 @@ PPPOEConnectDevice(void)
            error("Failed to create PPPoE discovery socket: %m");
            goto errout;
        }
-       discovery(conn);
+       discovery1(conn);
+       if (conn->discoveryState != STATE_RECEIVED_PADO) {
+           error("Unable to complete PPPoE Discovery phase 1");
+           goto errout;
+       }
+       discovery2(conn);
        if (conn->discoveryState != STATE_SESSION) {
-           error("Unable to complete PPPoE Discovery");
+           error("Unable to complete PPPoE Discovery phase 2");
            goto errout;
        }
     }
index 82ae01d2d0ce4e3aa0d5f9a7c6b6a14a7f05b14a..a72454e532943aba9384cbda106e5c97e275077f 100644 (file)
@@ -277,7 +277,8 @@ void initPPP(void);
 void clampMSS(PPPoEPacket *packet, char const *dir, int clampMss);
 UINT16_t computeTCPChecksum(unsigned char *ipHdr, unsigned char *tcpHdr);
 UINT16_t pppFCS16(UINT16_t fcs, unsigned char *cp, int len);
-void discovery(PPPoEConnection *conn);
+void discovery1(PPPoEConnection *conn);
+void discovery2(PPPoEConnection *conn);
 unsigned char *findTag(PPPoEPacket *packet, UINT16_t tagType,
                       PPPoETag *tag);