summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/l2tp
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2013-03-15 21:47:32 +0100
committerKozlov Dmitry <xeb@mail.ru>2013-03-16 08:34:46 +0400
commitc4fc028fafec4ec0a550ae73c8d9ef7184cf3845 (patch)
tree1e3067acf5bbfe4c88632a2ec6c6bf5611d19616 /accel-pppd/ctrl/l2tp
parentf27c0f86d0a8137a8ce416b03581e88f651428d1 (diff)
downloadaccel-ppp-c4fc028fafec4ec0a550ae73c8d9ef7184cf3845.tar.gz
accel-ppp-c4fc028fafec4ec0a550ae73c8d9ef7184cf3845.zip
l2tp: Merge incomming and outgoing session starting
Define l2tp_session_place_call() which can start either an incomming or outgoing session depending on the 'sess->lns_mode' flag. This removes the need for testing session mode before calling l2tp_tunnel_start_session(). Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/ctrl/l2tp')
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 91057e2..1eeb753 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -2799,38 +2799,43 @@ static int l2tp_recv_SLI(struct l2tp_conn_t *conn,
const struct l2tp_packet_t *pack)
{
if (conn->lns_mode) {
- l2tp_conn_log(log_warn, conn);
- log_warn("l2tp: unexpected SLI\n");
+ log_tunnel(log_warn, conn, "discarding unexpected SLI\n");
+ return 0;
}
+ if (conf_verbose)
+ log_tunnel(log_info1, conn, "handling SLI\n");
+
if (l2tp_send_ZLB(conn) < 0)
log_tunnel(log_error, conn, "acknowledging SLI failed\n");
return 0;
}
-static void l2tp_session_incall(void *data)
+static void l2tp_session_place_call(void *data)
{
struct l2tp_sess_t *sess = data;
+ int res;
- if (l2tp_send_ICRQ(sess) < 0) {
- log_ppp_error("l2tp: impossible to place call:"
- " error while sending ICRQ\n");
- return;
- }
- sess->state1 = STATE_WAIT_ICRP;
-}
-
-static void l2tp_session_outcall(void *data)
-{
- struct l2tp_sess_t *sess = data;
+ if (sess->lns_mode)
+ res = l2tp_send_OCRQ(sess);
+ else
+ res = l2tp_send_ICRQ(sess);
- if (l2tp_send_OCRQ(sess) < 0) {
- log_ppp_error("l2tp: impossible to place call:"
- " error while sending OCRQ\n");
+ if (res < 0) {
+ log_session(log_error, sess,
+ "impossible to place %s call:"
+ " sending %cCRQ failed, freeing session\n",
+ sess->lns_mode ? "outgoing" : "incoming",
+ sess->lns_mode ? 'O' : 'I');
+ if (l2tp_session_free(sess) < 0)
+ log_session(log_error, sess,
+ "impossible to free session,"
+ " session data have been kept\n");
return;
}
- sess->state1 = STATE_WAIT_OCRP;
+
+ sess->state1 = sess->lns_mode ? STATE_WAIT_OCRP : STATE_WAIT_ICRP;
}
static void l2tp_tunnel_create_session(void *data)
@@ -2852,7 +2857,7 @@ static void l2tp_tunnel_create_session(void *data)
}
if (l2tp_tunnel_start_session(sess,
- conn->lns_mode ? l2tp_session_outcall : l2tp_session_incall, sess) < 0) {
+ l2tp_session_place_call, sess) < 0) {
log_tunnel(log_error, conn, "impossible to create session:"
" starting session failed\n");
l2tp_tunnel_cancel_session(sess);