diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2013-05-31 16:12:26 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2013-05-31 16:12:26 +0400 |
commit | 05bb68599ae85b84bf793bb1600b17555dd0f9d2 (patch) | |
tree | c95487f1ec8d390cf5b671799d24293949a47d9f /accel-pppd/ctrl | |
parent | 405e580905790f22f17f736e996a4cea3635d800 (diff) | |
download | accel-ppp-05bb68599ae85b84bf793bb1600b17555dd0f9d2.tar.gz accel-ppp-05bb68599ae85b84bf793bb1600b17555dd0f9d2.zip |
pptp,l2tp: bind to port options
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 13 | ||||
-rw-r--r-- | accel-pppd/ctrl/pptp/pptp.c | 7 |
2 files changed, 15 insertions, 5 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 79d003e..0d27f50 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -48,6 +48,7 @@ #define STATE_FIN 9 #define STATE_CLOSE 0 +int conf_port = L2TP_PORT; int conf_verbose = 0; int conf_hide_avps = 0; int conf_avp_permissive = 0; @@ -2053,7 +2054,7 @@ static int l2tp_recv_SCCRQ(const struct l2tp_serv_t *serv, host_addr.sin_family = AF_INET; host_addr.sin_addr = pkt_info->ipi_addr; - host_addr.sin_port = 0; + host_addr.sin_port = htons(conf_port); conn = l2tp_tunnel_alloc(&pack->addr, &host_addr, framing_cap->val.uint32, 1, 1, @@ -3503,7 +3504,6 @@ static int start_udp_server(void) memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; - addr.sin_port = htons(L2TP_PORT); opt = conf_get_opt("l2tp", "bind"); if (opt) @@ -3511,6 +3511,11 @@ static int start_udp_server(void) else addr.sin_addr.s_addr = htonl(INADDR_ANY); + opt = conf_get_opt("l2tp", "port"); + if (opt && atoi(opt) > 0) + conf_port = atoi(opt); + addr.sin_port = htons(conf_port); + if (setsockopt(udp_serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &udp_serv.hnd.fd, sizeof(udp_serv.hnd.fd)) < 0) { log_error("l2tp: impossible to start L2TP server:" @@ -3616,7 +3621,7 @@ static int l2tp_create_tunnel_exec(const char *cmd, char * const *fields, if (opt) if (inet_aton(opt, &host.sin_addr) == 0) { host.sin_family = AF_INET; - host.sin_port = 0; + host.sin_port = htons(conf_port); } for (indx = 3; indx + 1 < fields_cnt; ++indx) { @@ -3644,7 +3649,7 @@ static int l2tp_create_tunnel_exec(const char *cmd, char * const *fields, } else if (strcmp("host-addr", fields[indx]) == 0) { host_indx = ++indx; host.sin_family = AF_INET; - host.sin_port = 0; + host.sin_port = htons(conf_port); if (inet_aton(fields[indx], &host.sin_addr) == 0) { cli_sendv(client, "invalid host address: \"%s\"\r\n", diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c index e735c72..d5b96c1 100644 --- a/accel-pppd/ctrl/pptp/pptp.c +++ b/accel-pppd/ctrl/pptp/pptp.c @@ -778,13 +778,18 @@ static void pptp_init(void) fcntl(serv.hnd.fd, F_SETFD, fcntl(serv.hnd.fd, F_GETFD) | FD_CLOEXEC); addr.sin_family = AF_INET; - addr.sin_port = htons(PPTP_PORT); opt = conf_get_opt("pptp", "bind"); if (opt) addr.sin_addr.s_addr = inet_addr(opt); else addr.sin_addr.s_addr = htonl(INADDR_ANY); + + opt = conf_get_opt("pptp", "port"); + if (opt && atoi(opt) > 0) + addr.sin_port = htons(atoi(opt)); + else + addr.sin_port = htons(PPTP_PORT); setsockopt(serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv.hnd.fd, 4); if (bind (serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) { |