diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-01-13 14:45:03 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-01-16 10:30:56 +0100 |
commit | fb030a8897e33fdfef2eee25170981e1c04ee74a (patch) | |
tree | b2f4e9d3e9e0648c7d9068b368864e458e9ce204 | |
parent | 9010a6be52f2d257b41be4a2766aafc851125680 (diff) |
layer23: Initialize osmocom_ms further in common code
Change-Id: Ic629cf229167ddd4c533a2abf1b82ad78d1144a9
-rw-r--r-- | src/host/layer23/include/osmocom/bb/common/ms.h | 2 | ||||
-rw-r--r-- | src/host/layer23/src/common/main.c | 3 | ||||
-rw-r--r-- | src/host/layer23/src/common/ms.c | 13 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/app_mobile.c | 10 |
4 files changed, 14 insertions, 14 deletions
diff --git a/src/host/layer23/include/osmocom/bb/common/ms.h b/src/host/layer23/include/osmocom/bb/common/ms.h index b9c9276a..bbb5491e 100644 --- a/src/host/layer23/include/osmocom/bb/common/ms.h +++ b/src/host/layer23/include/osmocom/bb/common/ms.h @@ -99,4 +99,4 @@ struct osmocom_ms { char *lua_script; }; -struct osmocom_ms *osmocom_ms_alloc(void *ctx); +struct osmocom_ms *osmocom_ms_alloc(void *ctx, const char *name); diff --git a/src/host/layer23/src/common/main.c b/src/host/layer23/src/common/main.c index 61a8604a..8017898e 100644 --- a/src/host/layer23/src/common/main.c +++ b/src/host/layer23/src/common/main.c @@ -268,9 +268,8 @@ int main(int argc, char **argv) print_copyright(); - ms = osmocom_ms_alloc(l23_ctx); + ms = osmocom_ms_alloc(l23_ctx, "1"); OSMO_ASSERT(ms); - llist_add_tail(&ms->entity, &ms_list); rc = l23_app_init(ms); if (rc < 0) { diff --git a/src/host/layer23/src/common/ms.c b/src/host/layer23/src/common/ms.c index 0b1ccb85..74dabc2f 100644 --- a/src/host/layer23/src/common/ms.c +++ b/src/host/layer23/src/common/ms.c @@ -19,15 +19,18 @@ #include <osmocom/bb/common/ms.h> -struct osmocom_ms *osmocom_ms_alloc(void *ctx) +extern struct llist_head ms_list; + +struct osmocom_ms *osmocom_ms_alloc(void *ctx, const char *name) { struct osmocom_ms *ms; ms = talloc_zero(ctx, struct osmocom_ms); if (!ms) return NULL; + talloc_set_name(ms, "ms_%s", name); - ms->name = talloc_strdup(ms, "1"); + ms->name = talloc_strdup(ms, name); ms->test_arfcn = 871; ms->lapdm_channel.lapdm_dcch.l1_ctx = ms; ms->lapdm_channel.lapdm_dcch.l3_ctx = ms; @@ -36,5 +39,11 @@ struct osmocom_ms *osmocom_ms_alloc(void *ctx) lapdm_channel_init(&ms->lapdm_channel, LAPDM_MODE_MS); lapdm_channel_set_l1(&ms->lapdm_channel, l1ctl_ph_prim_cb, ms); + ms->l2_wq.bfd.fd = -1; + ms->sap_wq.bfd.fd = -1; + + /* Register a new MS */ + llist_add_tail(&ms->entity, &ms_list); + return ms; } diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c index 5bf765a7..b2133f7f 100644 --- a/src/host/layer23/src/mobile/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -335,20 +335,12 @@ struct osmocom_ms *mobile_new(char *name) { static struct osmocom_ms *ms; - ms = talloc_zero(l23_ctx, struct osmocom_ms); + ms = osmocom_ms_alloc(l23_ctx, name); if (!ms) { LOGP(DMOB, LOGL_ERROR, "Failed to allocate MS: %s\n", name); return NULL; } - talloc_set_name(ms, "ms_%s", name); - ms->name = talloc_strdup(ms, name); - ms->l2_wq.bfd.fd = -1; - ms->sap_wq.bfd.fd = -1; - - /* Register a new MS */ - llist_add_tail(&ms->entity, &ms_list); - gsm_support_init(ms); gsm_settings_init(ms); |