X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Frp-pppoe%2Fplugin.c;h=9e838d30d58b81208b9289ff239acfb9937f03fb;hb=3202f8916306cc42bcabbae48ae45d0e18ab0826;hp=48fcea832917561bccb9c7fa1deae2d14eb43fe4;hpb=fcb076c2b24bd8dd73f4be7a9e1712d3a352a376;p=ppp.git diff --git a/pppd/plugins/rp-pppoe/plugin.c b/pppd/plugins/rp-pppoe/plugin.c index 48fcea8..9e838d3 100644 --- a/pppd/plugins/rp-pppoe/plugin.c +++ b/pppd/plugins/rp-pppoe/plugin.c @@ -68,6 +68,9 @@ static char *existingSession = NULL; static int printACNames = 0; static char *pppoe_reqd_mac = NULL; unsigned char pppoe_reqd_mac_addr[6]; +static char *host_uniq; +static int pppoe_padi_timeout = PADI_TIMEOUT; +static int pppoe_padi_attempts = MAX_PADI_ATTEMPTS; static int PPPoEDevnameHook(char *cmd, char **argv, int doit); static option_t Options[] = { @@ -85,6 +88,12 @@ static option_t Options[] = { "Be verbose about discovered access concentrators"}, { "pppoe-mac", o_string, &pppoe_reqd_mac, "Only connect to specified MAC address" }, + { "host-uniq", o_string, &host_uniq, + "Set the Host-Uniq to the supplied hex string" }, + { "pppoe-padi-timeout", o_int, &pppoe_padi_timeout, + "Initial timeout for discovery packets in seconds" }, + { "pppoe-padi-attempts", o_int, &pppoe_padi_attempts, + "Number of discovery attempts" }, { NULL } }; int (*OldDevnameHook)(char *cmd, char **argv, int doit) = NULL; @@ -110,9 +119,9 @@ PPPOEInitDevice(void) conn->ifName = devnam; conn->discoverySocket = -1; conn->sessionSocket = -1; - conn->useHostUniq = 1; conn->printACNames = printACNames; - conn->discoveryTimeout = PADI_TIMEOUT; + conn->discoveryTimeout = pppoe_padi_timeout; + conn->discoveryAttempts = pppoe_padi_attempts; return 1; } @@ -166,6 +175,17 @@ PPPOEConnectDevice(void) if (lcp_wantoptions[0].mru > ifr.ifr_mtu - TOTAL_OVERHEAD) lcp_wantoptions[0].mru = ifr.ifr_mtu - TOTAL_OVERHEAD; + if (host_uniq) { + if (!parseHostUniq(host_uniq, &conn->hostUniq)) + fatal("Illegal value for host-uniq option"); + } else { + /* if a custom host-uniq is not supplied, use our PID */ + pid_t pid = getpid(); + conn->hostUniq.type = htons(TAG_HOST_UNIQ); + conn->hostUniq.length = htons(sizeof(pid)); + memcpy(conn->hostUniq.payload, &pid, sizeof(pid)); + } + conn->acName = acName; conn->serviceName = pppd_pppoe_service; strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam));