diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2013-02-11 21:02:35 +0100 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2013-02-12 00:12:48 +0400 |
commit | 9c9ff616d53127f6018143154aa53ad16bec9eca (patch) | |
tree | 528ab9c7d989633b80993233300ae59c05ace99f /accel-pppd/ctrl/l2tp | |
parent | da4739b14071ef71f99c747ac2118924d525c3d5 (diff) | |
download | accel-ppp-9c9ff616d53127f6018143154aa53ad16bec9eca.tar.gz accel-ppp-9c9ff616d53127f6018143154aa53ad16bec9eca.zip |
l2tp: Set LNS address with the one really bound to
When allocating tunnels, set the lns_addr field of tunnels using
getsockname() instead of using the "host" parameter. This will allow
the caller to pass an unspecified port in "host" (for binding to
any source port) and to set the lns_addr field with the address really
bound to.
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/ctrl/l2tp')
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 9dc0d26..ef818c2 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -793,6 +793,7 @@ static struct l2tp_conn_t *l2tp_tunnel_alloc(const struct sockaddr_in *peer, uint32_t framing_cap) { struct l2tp_conn_t *conn; + socklen_t lnsaddrlen = sizeof(conn->lns_addr); uint16_t tid; int flag; @@ -871,8 +872,17 @@ static struct l2tp_conn_t *l2tp_tunnel_alloc(const struct sockaddr_in *peer, goto out_err; } + if (getsockname(conn->hnd.fd, &conn->lns_addr, &lnsaddrlen) < 0) { + log_error("l2tp: getsockname: %s\n", strerror(errno)); + goto out_err; + } + if (lnsaddrlen != sizeof(conn->lns_addr)) { + log_error("l2tp: getsockname: invalid address length: %i\n", + lnsaddrlen); + goto out_err; + } + memcpy(&conn->lac_addr, peer, sizeof(*peer)); - memcpy(&conn->lns_addr, host, sizeof(*host)); conn->framing_cap = framing_cap; conn->ctx.before_switch = log_switch; |