Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass remotenumber to pppd. #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/l2tpd.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
; rx bps = 10000000 ; Receive tunnel speed
; tx bps = 10000000 ; Transmit tunnel speed
; bps = 100000 ; Define both receive and transmit speed in one option
; trust remotenumber = no ; Trust dialing number AVP?

; [lac marko] ; Example VPN LAC definition
; lns = lns.marko.net ; * Who is our LNS?
Expand Down
6 changes: 6 additions & 0 deletions doc/xl2tpd.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ This will enable the debug for pppd.
.B pass peer
Pass the peer's IP address to pppd as ipparam. Enabled by default.

.TP
.B trust remotenumber
When this is set to yes xl2tpd will trust the dialing number AVP and provide
that as the remotenumber to pppd rather than the peer's IP address. Default is
not trusted.

.TP
.B pppoptfile
Specify the path for a file which contains pppd configuration parameters
Expand Down
17 changes: 17 additions & 0 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,22 @@ int set_pass_peer (char *word, char *value, int context, void *item)
return 0;
}

int set_trust_remotenumber (char *word, char *value, int context, void *item)
{
switch (context & ~CONTEXT_DEFAULT)
{
case CONTEXT_LNS:
if (set_boolean (word, value, &(((struct lns *) item)->trust_remotenumber)))
return -1;
break;
default:
snprintf (filerr, sizeof (filerr), "'%s' not valid in this context\n",
word);
return -1;
}
return 0;
}

int set_pppoptfile (char *word, char *value, int context, void *item)
{
struct lac *l = (struct lac *) item;
Expand Down Expand Up @@ -1611,6 +1627,7 @@ struct keyword words[] = {
{"hostname", &set_hostname},
{"ppp debug", &set_debug},
{"pass peer", &set_pass_peer},
{"trust remotenumber", &set_trust_remotenumber},
{"pppoptfile", &set_pppoptfile},
{"call rws", &set_rws},
{"tunnel rws", &set_rws},
Expand Down
1 change: 1 addition & 0 deletions file.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct lns
int proxyauth; /* Allow proxy authentication? */
int debug; /* Debug PPP? */
int pass_peer; /* Pass peer IP to pppd as ipparam? */
int trust_remotenumber; /* Whether or not to trust remotely supplied "Dialing Number" AVP */
char pppoptfile[STRLEN]; /* File containing PPP options */
struct tunnel *t; /* Tunnel of this, if it's ready */
};
Expand Down
8 changes: 8 additions & 0 deletions xl2tpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,14 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
}

{
stropt[pos++] = strdup("remotenumber");
if (c->dialing[0] && (!c->lns || c->lns->trust_remotenumber)) {
/* if a remotenumber is available, and we're a LAC or the remote "dialing number" AVP is trusted */
stropt[pos++] = strdup(c->dialing);
} else {
stropt[pos++] = strdup(IPADDY(c->container->peer.sin_addr));
}

struct ppp_opts *p = opts;
int maxn_opts = sizeof(stropt) / sizeof(stropt[0]) - 1;
while (p && pos < maxn_opts)
Expand Down