summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/l2tp
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2013-03-15 21:47:39 +0100
committerKozlov Dmitry <xeb@mail.ru>2013-03-16 08:34:46 +0400
commit26064c2ef465821de6e2866bdcedd2774e6993e5 (patch)
tree5bf0d4d3d6a9e599cb4d10c8f446c2e459f45e8f /accel-pppd/ctrl/l2tp
parentc4fc028fafec4ec0a550ae73c8d9ef7184cf3845 (diff)
downloadaccel-ppp-26064c2ef465821de6e2866bdcedd2774e6993e5.tar.gz
accel-ppp-26064c2ef465821de6e2866bdcedd2774e6993e5.zip
l2tp: Dedicated function for replying to incomming calls
Define l2tp_session_incall_reply() which can be used as parameter for l2tp_tunnel_start_session(). This removes the need for updating session's state in l2tp_send_ICRP() and normalises the way incomming and outgoing sessions are handled. Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/ctrl/l2tp')
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 1eeb753..586a252 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -1693,8 +1693,6 @@ static int l2tp_send_ICRP(struct l2tp_sess_t *sess)
else
triton_timer_mod(&sess->timeout_timer, 0);
- sess->state1 = STATE_WAIT_ICCN;
-
return 0;
out_err:
@@ -2311,6 +2309,23 @@ static int l2tp_recv_HELLO(struct l2tp_conn_t *conn,
return 0;
}
+static void l2tp_session_incall_reply(void *data)
+{
+ struct l2tp_sess_t *sess = data;
+
+ if (l2tp_send_ICRP(sess) < 0) {
+ log_session(log_error, sess,
+ "impossible to reply to incoming call:"
+ " sending ICRP failed, disconnecting session\n");
+ if (l2tp_session_disconnect(sess, 2, 6) < 0)
+ log_session(log_error, sess,
+ "session disconnection failed\n");
+ return;
+ }
+
+ sess->state1 = STATE_WAIT_ICCN;
+}
+
static int l2tp_recv_ICRQ(struct l2tp_conn_t *conn,
const struct l2tp_packet_t *pack)
{
@@ -2387,7 +2402,8 @@ static int l2tp_recv_ICRQ(struct l2tp_conn_t *conn,
goto out_reject;
}
- if (l2tp_tunnel_start_session(sess, l2tp_send_ICRP, sess) < 0) {
+ if (l2tp_tunnel_start_session(sess, l2tp_session_incall_reply,
+ sess) < 0) {
log_tunnel(log_error, conn, "impossible to handle ICRQ:"
" starting session failed,"
" disconnecting session\n");