From caba7fc493f96e157f7c6ba7b82b82b2c781c7a0 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 1 Aug 2022 20:46:38 +0200 Subject: [PATCH] cbsp/sbcap: Set link fsm id with peer's name Otherwise the id is left unset. Change-Id: I8a6850293cbe01c66e4fb545d646d63743ddaecb --- src/cbsp_link.c | 6 +++++- src/sbcap_link.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cbsp_link.c b/src/cbsp_link.c index 564e134..564df3f 100644 --- a/src/cbsp_link.c +++ b/src/cbsp_link.c @@ -41,6 +41,7 @@ struct cbc_cbsp_link *cbc_cbsp_link_alloc(struct cbc_cbsp_mgr *cbc, struct cbc_peer *peer) { struct cbc_cbsp_link *link; + char *name; link = talloc_zero(cbc, struct cbc_cbsp_link); OSMO_ASSERT(link); @@ -48,12 +49,15 @@ struct cbc_cbsp_link *cbc_cbsp_link_alloc(struct cbc_cbsp_mgr *cbc, struct cbc_p link->peer = peer; link->is_client = (peer->link_mode == CBC_PEER_LINK_MODE_CLIENT); - link->fi = osmo_fsm_inst_alloc(&cbsp_link_fsm, link, link, LOGL_DEBUG, NULL); + name = talloc_strdup(link, peer->name); + osmo_identifier_sanitize_buf(name, NULL, '_'); + link->fi = osmo_fsm_inst_alloc(&cbsp_link_fsm, link, link, LOGL_DEBUG, name); if (!link->fi) { LOGPCC(link, LOGL_ERROR, "Unable to allocate FSM\n"); talloc_free(link); return NULL; } + talloc_free(name); llist_add_tail(&link->list, &cbc->links); return link; diff --git a/src/sbcap_link.c b/src/sbcap_link.c index 9af842f..3f5d792 100644 --- a/src/sbcap_link.c +++ b/src/sbcap_link.c @@ -46,6 +46,7 @@ struct cbc_sbcap_link *cbc_sbcap_link_alloc(struct cbc_sbcap_mgr *cbc, struct cbc_peer *peer) { struct cbc_sbcap_link *link; + char *name; link = talloc_zero(cbc, struct cbc_sbcap_link); OSMO_ASSERT(link); @@ -53,12 +54,15 @@ struct cbc_sbcap_link *cbc_sbcap_link_alloc(struct cbc_sbcap_mgr *cbc, struct cb link->peer = peer; link->is_client = (peer->link_mode == CBC_PEER_LINK_MODE_CLIENT); - link->fi = osmo_fsm_inst_alloc(&sbcap_link_fsm, link, link, LOGL_DEBUG, NULL); + name = talloc_strdup(link, peer->name); + osmo_identifier_sanitize_buf(name, NULL, '_'); + link->fi = osmo_fsm_inst_alloc(&sbcap_link_fsm, link, link, LOGL_DEBUG, name); if (!link->fi) { LOGPSBCAPC(link, LOGL_ERROR, "Unable to allocate FSM\n"); talloc_free(link); return NULL; } + talloc_free(name); llist_add_tail(&link->list, &cbc->links); return link;