diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2013-07-26 10:46:55 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2013-07-26 10:46:55 +0400 |
commit | 56b69f5f1a585b32bb2fd0a89c9310ba98d7e86d (patch) | |
tree | 8394ceed00a32fe12c9a6cbfa90f38c455454e7a /accel-pppd/ctrl | |
parent | 8f8b893405d2e2b792885c4875eb8bdc77ce9d2f (diff) | |
parent | 37e2a417a6cb6a981c85dfdcd3245a48f99a4165 (diff) | |
download | accel-ppp-xebd-56b69f5f1a585b32bb2fd0a89c9310ba98d7e86d.tar.gz accel-ppp-xebd-56b69f5f1a585b32bb2fd0a89c9310ba98d7e86d.zip |
Merge branch 'master' of ssh://git.code.sf.net/p/accel-ppp/code
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 7 | ||||
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 71 | ||||
-rw-r--r-- | accel-pppd/ctrl/pppoe/pppoe.c | 2 |
3 files changed, 37 insertions, 43 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index e553719..7f92501 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -427,6 +427,9 @@ static void ipoe_session_start(struct ipoe_session *ses) } } + log_ppp_info1("%s: authentication succeeded\n", ses->ses.username); + triton_event_fire(EV_SES_AUTHORIZED, &ses->ses); + if (ses->serv->opt_nat) ses->ses.ipv4 = ipdb_get_ipv4(&ses->ses); @@ -841,6 +844,8 @@ static void ipoe_session_finished(struct ap_session *s) if (ses->dhcpv4) dhcpv4_free(ses->dhcpv4); + + triton_event_fire(EV_CTRL_FINISHED, s); triton_context_call(&ses->ctx, (triton_event_func)ipoe_session_free, ses); } @@ -870,7 +875,7 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s { struct ipoe_session *ses; int dlen = 0; - uint8_t *ptr; + uint8_t *ptr = NULL; ses = mempool_alloc(ses_pool); if (!ses) { diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 5f73193..b4b20b7 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -48,11 +48,14 @@ #define STATE_FIN 9 #define STATE_CLOSE 0 +#define DEFAULT_PPP_MAX_MTU 1420 + int conf_verbose = 0; int conf_hide_avps = 0; int conf_avp_permissive = 0; +static int conf_ppp_max_mtu = DEFAULT_PPP_MAX_MTU; static int conf_port = L2TP_PORT; -static int conf_ephemeral_ports = 1; +static int conf_ephemeral_ports = 0; static int conf_timeout = 60; static int conf_rtimeout = 5; static int conf_retransmit = 5; @@ -97,8 +100,6 @@ struct l2tp_conn_t struct triton_timer_t rtimeout_timer; struct triton_timer_t hello_timer; - int tunnel_fd; - struct sockaddr_in peer_addr; struct sockaddr_in host_addr; uint16_t tid; @@ -706,9 +707,6 @@ static void l2tp_tunnel_free(struct l2tp_conn_t *conn) l2tp_conn[conn->tid] = NULL; pthread_mutex_unlock(&l2tp_lock); - if (conn->tunnel_fd != -1) - close(conn->tunnel_fd); - if (conn->ctx.tpd) triton_context_unregister(&conn->ctx); @@ -883,7 +881,7 @@ static struct l2tp_sess_t *l2tp_tunnel_alloc_session(struct l2tp_conn_t *conn) sess->ctrl.started = l2tp_ppp_started; sess->ctrl.finished = l2tp_ppp_finished; sess->ctrl.terminate = ppp_terminate; - sess->ctrl.max_mtu = 1420; + sess->ctrl.max_mtu = conf_ppp_max_mtu; sess->ctrl.mppe = conf_mppe; sess->ctrl.calling_station_id = _malloc(17); sess->ctrl.called_station_id = _malloc(17); @@ -1123,8 +1121,6 @@ static struct l2tp_conn_t *l2tp_tunnel_alloc(const struct sockaddr_in *peer, conn->hello_timer.expire = l2tp_send_HELLO; conn->hello_timer.period = conf_hello_interval * 1000; - conn->tunnel_fd = -1; - conn->sessions = NULL; conn->sess_count = 0; conn->lns_mode = lns_mode; @@ -1164,7 +1160,6 @@ static int l2tp_session_connect(struct l2tp_sess_t *sess) struct l2tp_conn_t *conn = sess->paren_conn; int lns_mode = sess->lns_mode; int flg; - int chan_sz; uint16_t peer_port; char addr[17]; @@ -1216,23 +1211,10 @@ static int l2tp_session_connect(struct l2tp_sess_t *sess) u_inet_ntoa(conn->peer_addr.sin_addr.s_addr, addr); peer_port = ntohs(conn->peer_addr.sin_port); - chan_sz = snprintf(NULL, 0, "%s:%i session %i", - addr, peer_port, sess->peer_sid); - if (chan_sz < 0) { - log_session(log_error, sess, "impossible to connect session:" - " snprintf() failed: %s\n", strerror(errno)); - goto out_err; - } - sess->ppp.ses.chan_name = _malloc(chan_sz + 1); - if (sess->ppp.ses.chan_name == NULL) { - log_session(log_error, sess, "impossible to connect session:" - " memory allocation failed\n"); - goto out_err; - } - if (snprintf(sess->ppp.ses.chan_name, chan_sz + 1, "%s:%i session %i", - addr, peer_port, sess->peer_sid) < 0) { + if (_asprintf(&sess->ppp.ses.chan_name, "%s:%i session %i", + addr, peer_port, sess->peer_sid) < 0) { log_session(log_error, sess, "impossible to connect session:" - " snprintf(%i) failed\n", chan_sz + 1); + " setting session's channel name failed\n"); goto out_err; } @@ -1269,6 +1251,7 @@ out_err: static int l2tp_tunnel_connect(struct l2tp_conn_t *conn) { struct sockaddr_pppol2tp pppox_addr; + int tunnel_fd; int flg; memset(&pppox_addr, 0, sizeof(pppox_addr)); @@ -1280,31 +1263,31 @@ static int l2tp_tunnel_connect(struct l2tp_conn_t *conn) pppox_addr.pppol2tp.s_tunnel = conn->tid; pppox_addr.pppol2tp.d_tunnel = conn->peer_tid; - conn->tunnel_fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP); - if (conn->tunnel_fd < 0) { + tunnel_fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP); + if (tunnel_fd < 0) { log_tunnel(log_error, conn, "impossible to connect tunnel:" " socket(AF_PPPOX) failed: %s\n", strerror(errno)); - goto out_err; + goto err; } - flg = fcntl(conn->tunnel_fd, F_GETFD); + flg = fcntl(tunnel_fd, F_GETFD); if (flg < 0) { log_tunnel(log_error, conn, "impossible to connect tunnel:" " fcntl(F_GETFD) failed: %s\n", strerror(errno)); - goto out_err; + goto err_fd; } - flg = fcntl(conn->tunnel_fd, F_SETFD, flg | FD_CLOEXEC); + flg = fcntl(tunnel_fd, F_SETFD, flg | FD_CLOEXEC); if (flg < 0) { log_tunnel(log_error, conn, "impossible to connect tunnel:" " fcntl(F_SETFD) failed: %s\n", strerror(errno)); - goto out_err; + goto err_fd; } - if (connect(conn->tunnel_fd, + if (connect(tunnel_fd, (struct sockaddr *)&pppox_addr, sizeof(pppox_addr)) < 0) { log_tunnel(log_error, conn, "impossible to connect tunnel:" " connect() failed: %s\n", strerror(errno)); - goto out_err; + goto err_fd; } if (conf_hello_interval) @@ -1312,19 +1295,19 @@ static int l2tp_tunnel_connect(struct l2tp_conn_t *conn) log_tunnel(log_error, conn, "impossible to connect tunnel:" " setting HELLO timer failed\n"); - goto out_err; + goto err_fd; } if (conn->timeout_timer.tpd) triton_timer_del(&conn->timeout_timer); + close(tunnel_fd); + return 0; -out_err: - if (conn->tunnel_fd >= 0) { - close(conn->tunnel_fd); - conn->tunnel_fd = -1; - } +err_fd: + close(tunnel_fd); +err: return -1; } @@ -3833,6 +3816,12 @@ static void load_config(void) if (opt && atoi(opt) > 0) conf_retransmit = atoi(opt); + opt = conf_get_opt("l2tp", "ppp-max-mtu"); + if (opt && atoi(opt) > 0) + conf_ppp_max_mtu = atoi(opt); + else + conf_ppp_max_mtu = DEFAULT_PPP_MAX_MTU; + opt = conf_get_opt("l2tp", "host-name"); if (opt) conf_host_name = opt; diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index b01369d..21051ed 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -1478,7 +1478,7 @@ static void load_config(void) conf_padi_limit = atoi(opt); conf_mppe = MPPE_UNSET; - opt = conf_get_opt("l2tp", "mppe"); + opt = conf_get_opt("pppoe", "mppe"); if (opt) { if (strcmp(opt, "deny") == 0) conf_mppe = MPPE_DENY; |