X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Fpppoe%2Fplugin.c;h=e9353eb009b4a63dabdb22a2845d5c6960090f7c;hb=af622602ca55d368c03b0ea912479dc84ad543c0;hp=e840bef6b43b3b5bb4ea9cb12c4241cf2eb96da5;hpb=b2c36e6c0e1655aea9b1b0a03a8160f42a26c884;p=ppp.git diff --git a/pppd/plugins/pppoe/plugin.c b/pppd/plugins/pppoe/plugin.c index e840bef..e9353eb 100644 --- a/pppd/plugins/pppoe/plugin.c +++ b/pppd/plugins/pppoe/plugin.c @@ -64,10 +64,10 @@ 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 *host_uniq; +static char *pppoe_host_uniq; static int pppoe_padi_timeout = PADI_TIMEOUT; static int pppoe_padi_attempts = MAX_PADI_ATTEMPTS; @@ -77,18 +77,28 @@ static option_t Options[] = { "PPPoE device name", OPT_DEVNAM | OPT_PRIVFIX | OPT_NOARG | OPT_A2STRVAL | OPT_STATIC, devnam}, - { "rp_pppoe_service", o_string, &pppd_pppoe_service, + { "pppoe-service", o_string, &pppd_pppoe_service, "Desired PPPoE service name" }, - { "rp_pppoe_ac", o_string, &acName, + { "rp_pppoe_service", o_string, &pppd_pppoe_service, + "Legacy alias for pppoe-service", OPT_ALIAS }, + { "pppoe-ac", o_string, &acName, "Desired PPPoE access concentrator name" }, - { "rp_pppoe_sess", o_string, &existingSession, + { "rp_pppoe_ac", o_string, &acName, + "Legacy alias for pppoe-ac", OPT_ALIAS }, + { "pppoe-sess", o_string, &existingSession, "Attach to existing session (sessid:macaddr)" }, - { "rp_pppoe_verbose", o_int, &printACNames, - "Be verbose about discovered access concentrators"}, + { "rp_pppoe_sess", o_string, &existingSession, + "Legacy alias for pppoe-sess", OPT_ALIAS }, + { "pppoe-verbose", o_int, &pppoe_verbose, + "Be verbose about discovered access concentrators" }, + { "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" }, - { "host-uniq", o_string, &host_uniq, + { "pppoe-host-uniq", o_string, &pppoe_host_uniq, "Set the Host-Uniq to the supplied hex string" }, + { "host-uniq", o_string, &pppoe_host_uniq, + "Legacy alias for pppoe-host-uniq", OPT_ALIAS }, { "pppoe-padi-timeout", o_int, &pppoe_padi_timeout, "Initial timeout for discovery packets in seconds" }, { "pppoe-padi-attempts", o_int, &pppoe_padi_attempts, @@ -118,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; @@ -152,8 +161,8 @@ PPPOEConnectDevice(void) } /* Restore configuration */ - lcp_allowoptions[0].mru = conn->mtu; - lcp_wantoptions[0].mru = conn->mru; + lcp_allowoptions[0].mru = conn->mtu = conn->storedmtu; + lcp_wantoptions[0].mru = conn->mru = conn->storedmru; /* Update maximum MRU */ s = socket(AF_INET, SOCK_DGRAM, 0); @@ -170,13 +179,13 @@ PPPOEConnectDevice(void) close(s); if (lcp_allowoptions[0].mru > ifr.ifr_mtu - TOTAL_OVERHEAD) - lcp_allowoptions[0].mru = ifr.ifr_mtu - TOTAL_OVERHEAD; + lcp_allowoptions[0].mru = conn->mtu = ifr.ifr_mtu - TOTAL_OVERHEAD; if (lcp_wantoptions[0].mru > ifr.ifr_mtu - TOTAL_OVERHEAD) - lcp_wantoptions[0].mru = ifr.ifr_mtu - TOTAL_OVERHEAD; + lcp_wantoptions[0].mru = conn->mru = ifr.ifr_mtu - TOTAL_OVERHEAD; - if (host_uniq) { - if (!parseHostUniq(host_uniq, &conn->hostUniq)) - fatal("Illegal value for host-uniq option"); + if (pppoe_host_uniq) { + if (!parseHostUniq(pppoe_host_uniq, &conn->hostUniq)) + fatal("Illegal value for pppoe-host-uniq option"); } else { /* if a custom host-uniq is not supplied, use our PID */ pid_t pid = getpid(); @@ -194,7 +203,7 @@ PPPOEConnectDevice(void) if (sscanf(existingSession, "%d:%x:%x:%x:%x:%x:%x", &ses, &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) != 7) { - fatal("Illegal value for rp_pppoe_sess option"); + fatal("Illegal value for pppoe-sess option"); } conn->session = htons(ses); for (i=0; idiscoverySocket = openInterface(conn->ifName, Eth_PPPOE_Discovery, conn->myEth); - discovery(conn); + if (conn->discoverySocket < 0) { + error("Failed to create PPPoE discovery socket: %m"); + goto errout; + } + discovery1(conn); + /* discovery1() may update conn->mtu and conn->mru */ + lcp_allowoptions[0].mru = conn->mtu; + lcp_wantoptions[0].mru = conn->mru; + if (conn->discoveryState != STATE_RECEIVED_PADO) { + error("Unable to complete PPPoE Discovery phase 1"); + goto errout; + } + discovery2(conn); + /* discovery2() may update conn->mtu and conn->mru */ + lcp_allowoptions[0].mru = conn->mtu; + lcp_wantoptions[0].mru = conn->mru; if (conn->discoveryState != STATE_SESSION) { - error("Unable to complete PPPoE Discovery"); + error("Unable to complete PPPoE Discovery phase 2"); goto errout; } } @@ -434,8 +458,8 @@ void pppoe_check_options(void) lcp_wantoptions[0].mru = MAX_PPPOE_MTU; /* Save configuration */ - conn->mtu = lcp_allowoptions[0].mru; - conn->mru = lcp_wantoptions[0].mru; + conn->storedmtu = lcp_allowoptions[0].mru; + conn->storedmru = lcp_wantoptions[0].mru; ccp_allowoptions[0].deflate = 0; ccp_wantoptions[0].deflate = 0;