l2tpd: move next_l_sess_id into l2tp_instance
the sessions are unique to the daemon. E.g. data packets only contain a session id and no connection id
This commit is contained in:
parent
0cd2a3d8bd
commit
7916154136
|
@ -99,8 +99,11 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
l2i = talloc_zero(tall_l2tp_ctx, struct l2tpd_instance);
|
l2i = talloc_zero(tall_l2tp_ctx, struct l2tpd_instance);
|
||||||
l2i->cfg.bind_ip = "0.0.0.0";
|
l2i->cfg.bind_ip = "0.0.0.0";
|
||||||
/* important must not 0 */
|
/* connection id starts with 1 */
|
||||||
l2i->next_l_cc_id = 1;
|
l2i->next_l_cc_id = 1;
|
||||||
|
/* session id starts with 1 */
|
||||||
|
l2i->next_l_sess_id = 1;
|
||||||
|
|
||||||
|
|
||||||
rc = l2tpd_instance_start(l2i);
|
rc = l2tpd_instance_start(l2i);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
|
|
|
@ -42,8 +42,6 @@ struct l2tpd_connection {
|
||||||
uint16_t next_tx_seq_nr;
|
uint16_t next_tx_seq_nr;
|
||||||
/* seq nr of expected next Rx frame */
|
/* seq nr of expected next Rx frame */
|
||||||
uint16_t next_rx_seq_nr;
|
uint16_t next_rx_seq_nr;
|
||||||
/* next local session id */
|
|
||||||
uint32_t next_l_sess_id;
|
|
||||||
/* finite state machine for connection */
|
/* finite state machine for connection */
|
||||||
struct osmo_fsm_inst *fsm;
|
struct osmo_fsm_inst *fsm;
|
||||||
/* finite state machine for traffic channels */
|
/* finite state machine for traffic channels */
|
||||||
|
@ -78,7 +76,11 @@ struct l2tpd_session {
|
||||||
struct l2tpd_instance {
|
struct l2tpd_instance {
|
||||||
/* list of l2tpd_connection */
|
/* list of l2tpd_connection */
|
||||||
struct llist_head connections;
|
struct llist_head connections;
|
||||||
|
/* next connection id */
|
||||||
uint32_t next_l_cc_id;
|
uint32_t next_l_cc_id;
|
||||||
|
/* next local session id */
|
||||||
|
uint32_t next_l_sess_id;
|
||||||
|
|
||||||
|
|
||||||
struct osmo_fd l2tp_ofd;
|
struct osmo_fd l2tp_ofd;
|
||||||
|
|
||||||
|
|
|
@ -79,19 +79,17 @@ l2tpd_cc_alloc(struct l2tpd_instance *l2i)
|
||||||
llist_add(&l2c->list, &l2i->connections);
|
llist_add(&l2c->list, &l2i->connections);
|
||||||
l2c->fsm = osmo_fsm_inst_alloc(&l2tp_cc_fsm, l2c, l2c, LOGL_DEBUG, id_str);
|
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);
|
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;
|
return l2c;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct l2tpd_session *
|
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);
|
struct l2tpd_session *l2s = talloc_zero(conn, struct l2tpd_session);
|
||||||
char id_str[12] = {0};
|
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);
|
snprintf(id_str, 12, "%d", l2s->l_sess_id);
|
||||||
|
|
||||||
llist_add(&l2s->list, &conn->sessions);
|
llist_add(&l2s->list, &conn->sessions);
|
||||||
|
|
|
@ -16,7 +16,7 @@ l2tpd_cc_alloc(struct l2tpd_instance *inst);
|
||||||
|
|
||||||
/* l2tp session */
|
/* l2tp session */
|
||||||
struct l2tpd_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 *
|
struct l2tpd_session *
|
||||||
l2tpd_sess_find_by_l_s_id(struct l2tpd_connection *conn, uint32_t session_id);
|
l2tpd_sess_find_by_l_s_id(struct l2tpd_connection *conn, uint32_t session_id);
|
||||||
|
|
Loading…
Reference in New Issue