summaryrefslogtreecommitdiff
path: root/pppd
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-01-01 16:28:22 +0100
committerPali Rohár <pali@kernel.org>2021-01-05 00:43:56 +0100
commita37b5cf877d2fe21370958d5a44e61c621c1adb7 (patch)
tree6d277f93dae71b95bd80e68879750a02c2720bbb /pppd
parenta352af45cf46af5de0c2b2377f0ca8e33776ad6c (diff)
downloadppp-a37b5cf877d2fe21370958d5a44e61c621c1adb7.tar.gz
pppoe: Split function discovery() into phases discovery1() and discovery2()
pppoe-discovery.c needs to call only the first phase of discovery. Signed-off-by: Pali Rohár <pali@kernel.org>
Diffstat (limited to 'pppd')
-rw-r--r--pppd/plugins/pppoe/discovery.c24
-rw-r--r--pppd/plugins/pppoe/plugin.c9
-rw-r--r--pppd/plugins/pppoe/pppoe.h3
3 files changed, 28 insertions, 8 deletions
diff --git a/pppd/plugins/pppoe/discovery.c b/pppd/plugins/pppoe/discovery.c
index 5569f3e..1c55b36 100644
--- a/pppd/plugins/pppoe/discovery.c
+++ b/pppd/plugins/pppoe/discovery.c
@@ -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) {
diff --git a/pppd/plugins/pppoe/plugin.c b/pppd/plugins/pppoe/plugin.c
index d7c5be1..5732460 100644
--- a/pppd/plugins/pppoe/plugin.c
+++ b/pppd/plugins/pppoe/plugin.c
@@ -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;
}
}
diff --git a/pppd/plugins/pppoe/pppoe.h b/pppd/plugins/pppoe/pppoe.h
index 82ae01d..a72454e 100644
--- a/pppd/plugins/pppoe/pppoe.h
+++ b/pppd/plugins/pppoe/pppoe.h
@@ -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);