summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-01-30 22:43:38 +0300
committerHarald Welte <laforge@gnumonks.org>2011-01-30 22:43:38 +0300
commit584b917ced1a3147b50bfb4f0dd780a93147d860 (patch)
tree17c854a89ecff858e79412d020ace8169a091024
parentae55484c1f2a05ffa242c708da7a3ac751626230 (diff)
[mobile] replace 3 different gsm322_makesend_* functions with one
The new function is gsm322_event_input() and uses the event type as a function argument.
-rw-r--r--src/host/layer23/include/osmocom/bb/mobile/gsm322.h12
-rw-r--r--src/host/layer23/src/mobile/app_mobile.c8
-rw-r--r--src/host/layer23/src/mobile/gsm322.c56
-rw-r--r--src/host/layer23/src/mobile/gsm48_mm.c34
-rw-r--r--src/host/layer23/src/mobile/gsm48_rr.c9
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c9
6 files changed, 57 insertions, 71 deletions
diff --git a/src/host/layer23/include/osmocom/bb/mobile/gsm322.h b/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
index 3cd275f8..30d96ee7 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
@@ -32,6 +32,13 @@
#define GSM322_PLMN_SEARCH 10
#define GSM322_HPLMN_SEARCH 11
+/* GSM 03.22 event types */
+enum gsm322_evt_type {
+ GSM322_EVT_C, /* direct cell event, no queue */
+ GSM322_EVT_CS, /* enqueue cs->event_queue */
+ GSM322_EVT_PLMN, /* enqueue plmn->event_queue */
+};
+
/* GSM 03.22 events */
#define GSM322_EVENT_SWITCH_ON 1
#define GSM322_EVENT_SWITCH_OFF 2
@@ -172,9 +179,8 @@ struct gsm322_msg {
int gsm322_init(struct osmocom_ms *ms);
int gsm322_exit(struct osmocom_ms *ms);
-int gsm322_makesend_plmn_msg(struct osmocom_ms *ms, int msg_type, uint8_t *data, unsigned int len);
-int gsm322_makesend_cs_event(struct osmocom_ms *ms, int msg_type, uint8_t *data, unsigned int len);
-int gsm322_makesend_c_event(struct osmocom_ms *ms, int msg_type, uint8_t *data, unsigned int len);
+int gsm322_event_input(struct osmocom_ms *ms, enum gsm322_evt_type type,
+ int msg_type, uint8_t *data, unsigned int len);
int gsm322_plmn_dequeue(struct osmocom_ms *ms);
int gsm322_cs_dequeue(struct osmocom_ms *ms);
int gsm322_add_forbidden_la(struct osmocom_ms *ms, uint16_t mcc,
diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c
index 3d2100c1..b3c32847 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -104,10 +104,10 @@ int mobile_signal_cb(unsigned int subsys, unsigned int signal,
break;
default:
/* no SIM, trigger PLMN selection process */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_SWITCH_ON,
- NULL, 0);
- gsm322_makesend_cs_event(ms, GSM322_EVENT_SWITCH_ON,
- NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_SWITCH_ON, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_CS,
+ GSM322_EVENT_SWITCH_ON, NULL, 0);
}
ms->started = 1;
diff --git a/src/host/layer23/src/mobile/gsm322.c b/src/host/layer23/src/mobile/gsm322.c
index 14297371..3243afc3 100644
--- a/src/host/layer23/src/mobile/gsm322.c
+++ b/src/host/layer23/src/mobile/gsm322.c
@@ -3604,8 +3604,8 @@ int gsm322_exit(struct osmocom_ms *ms)
return 0;
}
-int gsm322_makesend_c_event(struct osmocom_ms *ms, int msg_type,
- uint8_t *data, unsigned int len)
+int gsm322_event_input(struct osmocom_ms *ms, enum gsm322_evt_type type,
+ int msg_type, uint8_t *data, unsigned int len)
{
struct msgb *nmsg = gsm322_msgb_alloc(msg_type);
int rc;
@@ -3621,46 +3621,18 @@ int gsm322_makesend_c_event(struct osmocom_ms *ms, int msg_type,
}
memcpy(cur, data, len);
}
- rc = gsm322_c_event(ms, nmsg);
- msgb_free(nmsg);
-
- return rc;
-}
-
-int gsm322_makesend_cs_event(struct osmocom_ms *ms, int msg_type,
- uint8_t *data, unsigned int len)
-{
- struct msgb *nmsg = gsm322_msgb_alloc(msg_type);
-
- if (!nmsg)
- return -ENOMEM;
-
- if (data && len) {
- uint8_t *cur = msgb_push(nmsg, len);
- if (!cur) {
- msgb_free(nmsg);
- return -EIO;
- }
- memcpy(cur, data, len);
+ switch (type) {
+ case GSM322_EVT_C:
+ rc = gsm322_c_event(ms, nmsg);
+ msgb_free(nmsg);
+ break;
+ case GSM322_EVT_CS:
+ rc = gsm322_cs_sendmsg(ms, nmsg);
+ break;
+ case GSM322_EVT_PLMN:
+ rc = gsm322_plmn_sendmsg(ms, nmsg);
+ break;
}
- return gsm322_cs_sendmsg(ms, nmsg);
-}
-
-int gsm322_makesend_plmn_msg(struct osmocom_ms *ms, int msg_type,
- uint8_t *data, unsigned int len)
-{
- struct msgb *nmsg = gsm322_msgb_alloc(msg_type);
-
- if (!nmsg)
- return -ENOMEM;
- if (data && len) {
- uint8_t *cur = msgb_push(nmsg, len);
- if (!cur) {
- msgb_free(nmsg);
- return -EIO;
- }
- memcpy(cur, data, len);
- }
- return gsm322_plmn_sendmsg(ms, nmsg);
+ return rc;
}
diff --git a/src/host/layer23/src/mobile/gsm48_mm.c b/src/host/layer23/src/mobile/gsm48_mm.c
index 58253bd8..4652f34e 100644
--- a/src/host/layer23/src/mobile/gsm48_mm.c
+++ b/src/host/layer23/src/mobile/gsm48_mm.c
@@ -1123,8 +1123,8 @@ static int gsm48_mm_cell_selected(struct osmocom_ms *ms, struct msgb *msg)
GSM48_MM_SST_NORMAL_SERVICE);
/* send message to PLMN search process */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_REG_SUCCESS,
- NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_REG_SUCCESS, NULL, 0);
return 0;
}
if (!s->att_allowed) {
@@ -1133,8 +1133,8 @@ static int gsm48_mm_cell_selected(struct osmocom_ms *ms, struct msgb *msg)
GSM48_MM_SST_NORMAL_SERVICE);
/* send message to PLMN search process */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_REG_SUCCESS,
- NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_REG_SUCCESS, NULL, 0);
return 0;
}
/* else, continue */
@@ -1150,8 +1150,8 @@ static int gsm48_mm_cell_selected(struct osmocom_ms *ms, struct msgb *msg)
GSM48_MM_SST_LIMITED_SERVICE);
/* send message to PLMN search process */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_ROAMING_NA,
- NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_ROAMING_NA, NULL, 0);
return 0;
}
@@ -1165,7 +1165,8 @@ static int gsm48_mm_cell_selected(struct osmocom_ms *ms, struct msgb *msg)
GSM48_MM_SST_LIMITED_SERVICE);
/* send message to PLMN search process */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_REG_FAILED, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_REG_FAILED, NULL, 0);
return 0;
}
@@ -1733,7 +1734,8 @@ static int gsm48_mm_imsi_detach_end(struct osmocom_ms *ms, struct msgb *msg)
}
/* send SIM remove event to gsm322 */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_SIM_REMOVE, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_SIM_REMOVE, NULL, 0);
/* CS process will trigger return to MM IDLE / No SIM */
return 0;
@@ -1993,7 +1995,7 @@ static int gsm48_mm_loc_upd(struct osmocom_ms *ms, struct msgb *msg)
_stop:
mm->lupd_pending = 0;
/* send message to PLMN search process */
- gsm322_makesend_plmn_msg(ms, msg_type, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN, msg_type, NULL, 0);
return 0;
}
@@ -2062,7 +2064,8 @@ static int gsm48_mm_loc_upd_normal(struct osmocom_ms *ms, struct msgb *msg)
LOGP(DMM, LOGL_INFO, "Loc. upd. not allowed.\n");
/* send message to PLMN search process */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_REG_FAILED, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_REG_FAILED, NULL, 0);
return 0;
}
@@ -2083,7 +2086,8 @@ static int gsm48_mm_loc_upd_normal(struct osmocom_ms *ms, struct msgb *msg)
GSM48_MM_SST_NORMAL_SERVICE);
/* send message to PLMN search process */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_REG_SUCCESS, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_REG_SUCCESS, NULL, 0);
return 0;
}
@@ -2318,7 +2322,8 @@ static int gsm48_mm_rx_loc_upd_acc(struct osmocom_ms *ms, struct msgb *msg)
}
/* send message to PLMN search process */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_REG_SUCCESS, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_REG_SUCCESS, NULL, 0);
/* follow on proceed */
if (TLVP_PRESENT(&tp, GSM48_IE_MOBILE_ID))
@@ -2426,7 +2431,7 @@ static int gsm48_mm_rel_loc_upd_rej(struct osmocom_ms *ms, struct msgb *msg)
}
memset(&ngm, 0, sizeof(ngm));
ngm.reject = mm->lupd_rej_cause;
- gsm322_makesend_plmn_msg(ms, msg_type, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN, msg_type, &ngm, sizeof(ngm));
/* forbidden list */
switch (mm->lupd_rej_cause) {
@@ -4068,7 +4073,8 @@ static int gsm48_mmr_reg_req(struct osmocom_ms *ms)
struct gsm48_mmlayer *mm = &ms->mmlayer;
/* schedule insertion of SIM */
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_SIM_INSERT, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_SIM_INSERT, NULL, 0);
/* 4.2.1.2 SIM is inserted in state NO IMSI */
if (mm->state == GSM48_MM_ST_MM_IDLE
diff --git a/src/host/layer23/src/mobile/gsm48_rr.c b/src/host/layer23/src/mobile/gsm48_rr.c
index 4a48dc84..177b2722 100644
--- a/src/host/layer23/src/mobile/gsm48_rr.c
+++ b/src/host/layer23/src/mobile/gsm48_rr.c
@@ -408,8 +408,8 @@ static void new_rr_state(struct gsm48_rrlayer *rr, int state)
memset(&em, 0, sizeof(em));
em.same_cell = 1;
}
- gsm322_makesend_c_event(rr->ms, GSM322_EVENT_RET_IDLE,
- (uint8_t *)&em, sizeof(em));
+ gsm322_event_input(rr->ms, GSM322_EVT_C, GSM322_EVENT_RET_IDLE,
+ (uint8_t *)&em, sizeof(em));
/* reset any BA range */
rr->ba_ranges = 0;
}
@@ -1189,7 +1189,8 @@ static int gsm48_rr_chan_req(struct osmocom_ms *ms, int cause, int paging)
* NOTE: this must be sent unbuffered, because the state may not
* change until idle mode is left
*/
- rc = gsm322_makesend_c_event(ms, GSM322_EVENT_LEAVE_IDLE, NULL, 0);
+ rc = gsm322_event_input(ms, GSM322_EVT_C, GSM322_EVENT_LEAVE_IDLE,
+ NULL, 0);
if (rc) {
if (paging)
return rc;
@@ -1595,7 +1596,7 @@ static int gsm48_new_sysinfo(struct osmocom_ms *ms, uint8_t type)
/* send sysinfo event to other layers */
memset(&em, 0, sizeof(em));
em.sysinfo = type;
- gsm322_makesend_cs_event(ms, GSM322_EVENT_SYSINFO,
+ gsm322_event_input(ms, GSM322_EVT_CS, GSM322_EVENT_SYSINFO,
(uint8_t *)&em, sizeof(em));
/* send timer info to location update process */
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index e3e7c475..d83dae87 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -689,8 +689,8 @@ DEFUN(network_select, network_select_cmd, "network select MS_NAME MCC MNC",
memset(&ngm, 0, sizeof(ngm));
ngm.mcc = mcc;
ngm.mnc = mnc;
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_CHOOSE_PLMN,
- (uint8_t *)&ngm, sizeof(ngm));
+ gsm322_event_input(ms, GSM322_EVT_PLMN, GSM322_EVENT_CHOOSE_PLMN,
+ (uint8_t *)&ngm, sizeof(ngm));
return CMD_SUCCESS;
}
@@ -820,7 +820,8 @@ DEFUN(network_search, network_search_cmd, "network search MS_NAME",
if (!ms)
return CMD_WARNING;
- gsm322_makesend_plmn_msg(ms, GSM322_EVENT_USER_RESEL, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN,
+ GSM322_EVENT_USER_RESEL, NULL, 0);
return CMD_SUCCESS;
}
@@ -1265,7 +1266,7 @@ DEFUN(cfg_ms_mode, cfg_ms_mode_cmd, "network-selection-mode (auto|manual)",
msg_type = GSM322_EVENT_SEL_MANUAL;
if (msg_type < 0)
return CMD_WARNING;
- gsm322_makesend_plmn_msg(ms, msg_type, NULL, 0);
+ gsm322_event_input(ms, GSM322_EVT_PLMN, msg_type, NULL, 0);
return CMD_SUCCESS;
}