gsm_04_08.c: Kill duplication pointed out by Andreas Eversberg
Introduce the internal gsm0408_authorize that will determine if we allow the user into our network. If allowed a new tmsi will be allocated, the subscr_update will be called, the loc_operation released, and the accept sent. Otherwise just return 0. The code was copied from mm_rx_id_resp.
This commit is contained in:
parent
7a12faa195
commit
d51524f654
|
@ -118,6 +118,7 @@ static const char *rr_cause_name(u_int8_t cause)
|
||||||
return strbuf;
|
return strbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gsm0408_loc_upd_acc(struct gsm_lchan *lchan, u_int32_t tmsi);
|
||||||
static int gsm48_tx_simple(struct gsm_lchan *lchan,
|
static int gsm48_tx_simple(struct gsm_lchan *lchan,
|
||||||
u_int8_t pdisc, u_int8_t msg_type);
|
u_int8_t pdisc, u_int8_t msg_type);
|
||||||
static void schedule_reject(struct gsm_lchan *lchan);
|
static void schedule_reject(struct gsm_lchan *lchan);
|
||||||
|
@ -182,6 +183,21 @@ static void allocate_loc_updating_req(struct gsm_lchan *lchan)
|
||||||
memset(lchan->loc_operation, 0, sizeof(*lchan->loc_operation));
|
memset(lchan->loc_operation, 0, sizeof(*lchan->loc_operation));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int gsm0408_authorize(struct gsm_lchan *lchan, struct msgb *msg)
|
||||||
|
{
|
||||||
|
u_int32_t tmsi;
|
||||||
|
|
||||||
|
if (authorize_subscriber(lchan->loc_operation, lchan->subscr)) {
|
||||||
|
db_subscriber_alloc_tmsi(lchan->subscr);
|
||||||
|
subscr_update(lchan->subscr, msg->trx->bts, GSM_SUBSCRIBER_UPDATE_ATTACHED);
|
||||||
|
tmsi = strtoul(lchan->subscr->tmsi, NULL, 10);
|
||||||
|
release_loc_updating_req(lchan);
|
||||||
|
return gsm0408_loc_upd_acc(msg->lchan, tmsi);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int gsm0408_handle_lchan_signal(unsigned int subsys, unsigned int signal,
|
static int gsm0408_handle_lchan_signal(unsigned int subsys, unsigned int signal,
|
||||||
void *handler_data, void *signal_data)
|
void *handler_data, void *signal_data)
|
||||||
{
|
{
|
||||||
|
@ -500,7 +516,6 @@ static int mm_rx_id_resp(struct msgb *msg)
|
||||||
struct gsm_lchan *lchan = msg->lchan;
|
struct gsm_lchan *lchan = msg->lchan;
|
||||||
u_int8_t mi_type = gh->data[1] & GSM_MI_TYPE_MASK;
|
u_int8_t mi_type = gh->data[1] & GSM_MI_TYPE_MASK;
|
||||||
char mi_string[MI_SIZE];
|
char mi_string[MI_SIZE];
|
||||||
u_int32_t tmsi;
|
|
||||||
|
|
||||||
mi_to_string(mi_string, sizeof(mi_string), &gh->data[1], gh->data[0]);
|
mi_to_string(mi_string, sizeof(mi_string), &gh->data[1], gh->data[0]);
|
||||||
DEBUGP(DMM, "IDENTITY RESPONSE: mi_type=0x%02x MI(%s)\n",
|
DEBUGP(DMM, "IDENTITY RESPONSE: mi_type=0x%02x MI(%s)\n",
|
||||||
|
@ -529,15 +544,7 @@ static int mm_rx_id_resp(struct msgb *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we can let the mobile station enter */
|
/* Check if we can let the mobile station enter */
|
||||||
if (authorize_subscriber(lchan->loc_operation, lchan->subscr)) {
|
return gsm0408_authorize(lchan, msg);
|
||||||
db_subscriber_alloc_tmsi(lchan->subscr);
|
|
||||||
subscr_update(lchan->subscr, msg->trx->bts, GSM_SUBSCRIBER_UPDATE_ATTACHED);
|
|
||||||
tmsi = strtoul(lchan->subscr->tmsi, NULL, 10);
|
|
||||||
release_loc_updating_req(lchan);
|
|
||||||
return gsm0408_loc_upd_acc(msg->lchan, tmsi);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -576,12 +583,10 @@ static const char *lupd_name(u_int8_t type)
|
||||||
static int mm_rx_loc_upd_req(struct msgb *msg)
|
static int mm_rx_loc_upd_req(struct msgb *msg)
|
||||||
{
|
{
|
||||||
struct gsm48_hdr *gh = msgb_l3(msg);
|
struct gsm48_hdr *gh = msgb_l3(msg);
|
||||||
struct gsm_bts *bts = msg->trx->bts;
|
|
||||||
struct gsm48_loc_upd_req *lu;
|
struct gsm48_loc_upd_req *lu;
|
||||||
struct gsm_subscriber *subscr;
|
struct gsm_subscriber *subscr;
|
||||||
struct gsm_lchan *lchan = msg->lchan;
|
struct gsm_lchan *lchan = msg->lchan;
|
||||||
u_int8_t mi_type;
|
u_int8_t mi_type;
|
||||||
u_int32_t tmsi;
|
|
||||||
char mi_string[MI_SIZE];
|
char mi_string[MI_SIZE];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -650,16 +655,7 @@ static int mm_rx_loc_upd_req(struct msgb *msg)
|
||||||
* for identity responses.
|
* for identity responses.
|
||||||
*/
|
*/
|
||||||
schedule_reject(lchan);
|
schedule_reject(lchan);
|
||||||
if (!authorize_subscriber(lchan->loc_operation, subscr))
|
return gsm0408_authorize(lchan, msg);
|
||||||
return 0;
|
|
||||||
|
|
||||||
db_subscriber_alloc_tmsi(subscr);
|
|
||||||
subscr_update(subscr, bts, GSM_SUBSCRIBER_UPDATE_ATTACHED);
|
|
||||||
|
|
||||||
tmsi = strtoul(subscr->tmsi, NULL, 10);
|
|
||||||
|
|
||||||
release_loc_updating_req(lchan);
|
|
||||||
return gsm0408_loc_upd_acc(lchan, tmsi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 9.1.5 Channel mode modify */
|
/* 9.1.5 Channel mode modify */
|
||||||
|
|
Loading…
Reference in New Issue