diff --git a/siu/l2tp/l2tpd.c b/siu/l2tp/l2tpd.c index 2061c4b..f37fd31 100644 --- a/siu/l2tp/l2tpd.c +++ b/siu/l2tp/l2tpd.c @@ -99,8 +99,11 @@ int main(int argc, char **argv) l2i = talloc_zero(tall_l2tp_ctx, struct l2tpd_instance); l2i->cfg.bind_ip = "0.0.0.0"; - /* important must not 0 */ + /* connection id starts with 1 */ l2i->next_l_cc_id = 1; + /* session id starts with 1 */ + l2i->next_l_sess_id = 1; + rc = l2tpd_instance_start(l2i); if (rc < 0) diff --git a/siu/l2tp/l2tpd.h b/siu/l2tp/l2tpd.h index d0fa2ff..e646d63 100644 --- a/siu/l2tp/l2tpd.h +++ b/siu/l2tp/l2tpd.h @@ -42,8 +42,6 @@ struct l2tpd_connection { uint16_t next_tx_seq_nr; /* seq nr of expected next Rx frame */ uint16_t next_rx_seq_nr; - /* next local session id */ - uint32_t next_l_sess_id; /* finite state machine for connection */ struct osmo_fsm_inst *fsm; /* finite state machine for traffic channels */ @@ -78,7 +76,11 @@ struct l2tpd_session { struct l2tpd_instance { /* list of l2tpd_connection */ struct llist_head connections; + /* next connection id */ uint32_t next_l_cc_id; + /* next local session id */ + uint32_t next_l_sess_id; + struct osmo_fd l2tp_ofd; diff --git a/siu/l2tp/l2tpd_data.c b/siu/l2tp/l2tpd_data.c index 0f36eb1..b9be352 100644 --- a/siu/l2tp/l2tpd_data.c +++ b/siu/l2tp/l2tpd_data.c @@ -79,19 +79,17 @@ l2tpd_cc_alloc(struct l2tpd_instance *l2i) llist_add(&l2c->list, &l2i->connections); l2c->fsm = osmo_fsm_inst_alloc(&l2tp_cc_fsm, l2c, l2c, LOGL_DEBUG, id_str); l2c->conf_fsm = osmo_fsm_inst_alloc(&l2tp_conf_fsm, l2c, l2c, LOGL_DEBUG, id_str); - /* session id starts with 1 */ - l2c->next_l_sess_id = 1; return l2c; } struct l2tpd_session * -l2tpd_sess_alloc(struct l2tpd_connection *conn) +l2tpd_sess_alloc(struct l2tpd_instance *l2i, struct l2tpd_connection *conn) { struct l2tpd_session *l2s = talloc_zero(conn, struct l2tpd_session); char id_str[12] = {0}; - l2s->l_sess_id = conn->next_l_sess_id++; + l2s->l_sess_id = l2i->next_l_sess_id++; snprintf(id_str, 12, "%d", l2s->l_sess_id); llist_add(&l2s->list, &conn->sessions); diff --git a/siu/l2tp/l2tpd_data.h b/siu/l2tp/l2tpd_data.h index c37680f..d546407 100644 --- a/siu/l2tp/l2tpd_data.h +++ b/siu/l2tp/l2tpd_data.h @@ -16,7 +16,7 @@ l2tpd_cc_alloc(struct l2tpd_instance *inst); /* l2tp session */ struct l2tpd_session * -l2tpd_sess_alloc(struct l2tpd_connection *conn); +l2tpd_sess_alloc(struct l2tpd_instance *inst, struct l2tpd_connection *conn); struct l2tpd_session * l2tpd_sess_find_by_l_s_id(struct l2tpd_connection *conn, uint32_t session_id);