diff options
author | Frank A. Stevenson <frank@hvitehus.no> | 2012-12-01 14:48:52 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-12-01 14:48:52 +0100 |
commit | 6430bdeb5ffe7194917843fa9c88f92f1b7a52db (patch) | |
tree | f60d8b56d19179373b4556bd041a0c59ff30e986 | |
parent | 1594e170bcf157c55dcbbe3b4dfd8fcb9d41bd69 (diff) |
fix some global ugliness
This removes a static global variable which will only work if you only
have once instance of the tetra receiver.
-rw-r--r-- | src/tetra_common.h | 3 | ||||
-rw-r--r-- | src/tetra_upper_mac.c | 13 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/tetra_common.h b/src/tetra_common.h index 3169b8a..3207c0d 100644 --- a/src/tetra_common.h +++ b/src/tetra_common.h @@ -2,7 +2,7 @@ #define TETRA_COMMON_H #include <stdint.h> - +#include "tetra_mac_pdu.h" #include <osmocom/core/linuxlist.h> #ifdef DEBUG @@ -47,6 +47,7 @@ struct tetra_mac_state { struct { int is_traffic; } cur_burst; + struct tetra_si_decoded last_sid; }; void tetra_mac_state_init(struct tetra_mac_state *tms); diff --git a/src/tetra_upper_mac.c b/src/tetra_upper_mac.c index 0bfc0e1..e5b9f30 100644 --- a/src/tetra_upper_mac.c +++ b/src/tetra_upper_mac.c @@ -40,9 +40,6 @@ static int rx_tm_sdu(struct tetra_mac_state *tms, struct msgb *msg, unsigned int len); -/* FIXME: this is ugly */ -static struct tetra_si_decoded g_last_sid; - static void rx_bcast(struct tetra_tmvsap_prim *tmvp, struct tetra_mac_state *tms) { struct msgb *msg = tmvp->oph.msg; @@ -74,10 +71,10 @@ static void rx_bcast(struct tetra_tmvsap_prim *tmvp, struct tetra_mac_state *tms printf("\t%s: %u\n", tetra_get_bs_serv_det_name(1 << i), sid.mle_si.bs_service_details & (1 << i) ? 1 : 0); - memcpy(&g_last_sid, &sid, sizeof(sid)); + memcpy(&tms->last_sid, &sid, sizeof(sid)); } -const char *tetra_alloc_dump(const struct tetra_chan_alloc_decoded *cad) +const char *tetra_alloc_dump(const struct tetra_chan_alloc_decoded *cad, struct tetra_mac_state *tms) { static char buf[64]; char *cur = buf; @@ -87,8 +84,8 @@ const char *tetra_alloc_dump(const struct tetra_chan_alloc_decoded *cad) freq_band = cad->ext_carr.freq_band; freq_offset = cad->ext_carr.freq_offset; } else { - freq_band = g_last_sid.freq_band; - freq_offset = g_last_sid.freq_offset; + freq_band = tms->last_sid.freq_band; + freq_offset = tms->last_sid.freq_offset; } cur += sprintf(cur, "%s (TN%u/%s/%uHz)", @@ -170,7 +167,7 @@ static void rx_resrc(struct tetra_tmvsap_prim *tmvp, struct tetra_mac_state *tms goto out; if (rsd.chan_alloc_pres) - printf("ChanAlloc=%s ", tetra_alloc_dump(&rsd.cad)); + printf("ChanAlloc=%s ", tetra_alloc_dump(&rsd.cad, tms)); if (rsd.slot_granting.pres) printf("SlotGrant=%u/%u ", rsd.slot_granting.nr_slots, |