Fixed of bugs while testing layer 2.
authorAndreas.Eversberg <jolly@eversberg.eu>
Sat, 5 Jun 2010 19:46:10 +0000 (19:46 +0000)
committerAndreas.Eversberg <jolly@eversberg.eu>
Sat, 5 Jun 2010 19:46:10 +0000 (19:46 +0000)
src/host/layer23/src/app_mobile.c
src/host/layer23/src/gsm322.c
src/host/layer23/src/gsm48_mm.c
src/host/layer23/src/gsm48_rr.c

index b1e1507..46e0e06 100644 (file)
@@ -139,7 +139,7 @@ int l23_app_init(struct osmocom_ms *ms)
 {
        int rc;
 
-       log_parse_category_mask(stderr_target, "DCS:DPLMN:DRR:DMM:DCC:DMNCC:DPAG");
+       log_parse_category_mask(stderr_target, "DRSL:DLAPDM:DCS:DPLMN:DRR:DMM:DCC:DMNCC:DPAG");
 
        srand(time(NULL));
 
index aa46942..da01258 100644 (file)
@@ -2311,6 +2311,7 @@ static int gsm322_l1_signal(unsigned int subsys, unsigned int signal,
                }
                break;
        case S_L1CTL_FBSB_ERR:
+               LOGP(DCS, LOGL_INFO, "Channel sync error.\n");
                ms = signal_data;
                cs = &ms->cellsel;
 
@@ -2739,6 +2740,8 @@ static int gsm322_c_conn_mode_1(struct osmocom_ms *ms, struct msgb *msg)
        cs->ccch_state = GSM322_CCCH_ST_INIT;
        l1ctl_tx_fbsb_req(ms, cs->arfcn, L1CTL_FBSB_F_FB01SB, 100, 0);
        cs->si = cs->list[cs->arfcn].sysinfo;
+#warning TESTING: laforge must fix the sync error when sending fbsb request too close to each other. also we must get a response with arfcn or a confirm, so we know where the response belongs to.
+usleep(300000);
 
        return 0;
 }
index d1dc65a..f424dd3 100644 (file)
@@ -272,9 +272,11 @@ int gsm48_encode_mi(uint8_t *buf, struct msgb *msg, struct osmocom_ms *ms,
        default:
                buf[0] = GSM48_IE_MOBILE_ID;
                buf[1] = 1;
-               buf[2] = 0xf0 | GSM_MI_TYPE_NONE;
+               buf[2] = 0xf0;
                break;
        }
+       /* alter MI type */
+       buf[2] = (buf[2] & 0xf8) | mi_type;
 
        if (msg) {
                /* MI as LV */
@@ -1595,6 +1597,7 @@ static int gsm48_mm_rx_id_req(struct osmocom_ms *ms, struct msgb *msg)
                return gsm48_mm_tx_mm_status(ms,
                        GSM48_REJECT_MSG_NOT_COMPATIBLE);
        }
+       LOGP(DMM, LOGL_INFO, "IDENTITY REQUEST (mi_type %d)\n", mi_type);
 
        return gsm48_mm_tx_id_rsp(ms, mi_type);
 }
@@ -1860,12 +1863,12 @@ static int gsm48_mm_rx_info(struct osmocom_ms *ms, struct msgb *msg)
        /* long name */
        if (TLVP_PRESENT(&tp, GSM48_IE_NAME_LONG)) {
                decode_network_name(mm->name_long, sizeof(mm->name_long),
-                               TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
+                               TLVP_VAL(&tp, GSM48_IE_NAME_LONG)-1);
        }
        /* short name */
        if (TLVP_PRESENT(&tp, GSM48_IE_NAME_SHORT)) {
                decode_network_name(mm->name_short, sizeof(mm->name_short),
-                               TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
+                               TLVP_VAL(&tp, GSM48_IE_NAME_SHORT)-1);
        }
 
        return 0;
@@ -2210,7 +2213,7 @@ static int gsm48_mm_rx_loc_upd_acc(struct osmocom_ms *ms, struct msgb *msg)
                uint8_t mi_type;
                uint32_t tmsi;
 
-               mi = TLVP_VAL(&tp, GSM48_IE_FACILITY)-1;
+               mi = TLVP_VAL(&tp, GSM48_IE_MOBILE_ID)-1;
                if (mi[0] < 1)
                        goto short_read;
                mi_type = mi[1] & GSM_MI_TYPE_MASK;
index f355a65..06318b5 100644 (file)
@@ -2839,6 +2839,7 @@ static int gsm48_rr_estab_cnf(struct osmocom_ms *ms, struct msgb *msg)
 {
        struct gsm48_rrlayer *rr = &ms->rrlayer;
        struct msgb *nmsg;
+       uint8_t *mode;
 
        /* if MM has releases before confirm, we start release */
        if (rr->state == GSM48_RR_ST_IDLE) {
@@ -2847,6 +2848,9 @@ static int gsm48_rr_estab_cnf(struct osmocom_ms *ms, struct msgb *msg)
                nmsg = gsm48_l3_msgb_alloc();
                if (!nmsg)
                        return -ENOMEM;
+               mode = msgb_put(nmsg, 2);
+               mode[0] = RSL_IE_RELEASE_MODE;
+               mode[1] = 0; /* normal release */
                /* start release */
                return gsm48_send_rsl(ms, RSL_MT_REL_REQ, nmsg);
        }
@@ -3234,37 +3238,36 @@ for(i=0;i<msgb_l3len(msg);i++)
 static struct dldatastate {
        uint32_t        states;
        int             type;
-       const char      *type_name;
        int             (*rout) (struct osmocom_ms *ms, struct msgb *msg);
 } dldatastatelist[] = {
        {SBIT(GSM48_RR_ST_IDLE) | SBIT(GSM48_RR_ST_CONN_PEND) |
         SBIT(GSM48_RR_ST_DEDICATED),
-        RSL_MT_UNIT_DATA_IND, "UNIT_DATA_IND", gsm48_rr_unit_data_ind},
+        RSL_MT_UNIT_DATA_IND, gsm48_rr_unit_data_ind},
        {SBIT(GSM48_RR_ST_DEDICATED), /* 3.4.2 */
-        RSL_MT_DATA_IND, "DATA_IND", gsm48_rr_data_ind},
+        RSL_MT_DATA_IND, gsm48_rr_data_ind},
        {SBIT(GSM48_RR_ST_IDLE) | SBIT(GSM48_RR_ST_CONN_PEND),
-        RSL_MT_EST_CONF, "EST_CONF", gsm48_rr_estab_cnf},
+        RSL_MT_EST_CONF, gsm48_rr_estab_cnf},
 #if 0
        {SBIT(GSM48_RR_ST_DEDICATED),
-        RSL_MT_EST_CONF, "EST_CONF", gsm48_rr_estab_cnf_dedicated},
+        RSL_MT_EST_CONF, gsm48_rr_estab_cnf_dedicated},
        {SBIT(GSM_RRSTATE),
-        RSL_MT_CONNECT_CNF, "CONNECT_CNF", gsm48_rr_connect_cnf},
+        RSL_MT_CONNECT_CNF, gsm48_rr_connect_cnf},
        {SBIT(GSM_RRSTATE),
-        RSL_MT_RELEASE_IND, "REL_IND", gsm48_rr_rel_ind},
+        RSL_MT_RELEASE_IND, gsm48_rr_rel_ind},
 #endif
        {SBIT(GSM48_RR_ST_IDLE) | SBIT(GSM48_RR_ST_CONN_PEND),
-        RSL_MT_REL_CONF, "REL_CONF", gsm48_rr_rel_cnf},
+        RSL_MT_REL_CONF, gsm48_rr_rel_cnf},
 #if 0
        {SBIT(GSM48_RR_ST_DEDICATED),
-        RSL_MT_REL_CONF, "REL_CONF", gsm48_rr_rel_cnf_dedicated},
+        RSL_MT_REL_CONF, gsm48_rr_rel_cnf_dedicated},
 #endif
        {SBIT(GSM48_RR_ST_CONN_PEND), /* 3.3.1.1.2 */
-        RSL_MT_CHAN_CNF, "CHAN_CNF", gsm48_rr_tx_rand_acc},
+        RSL_MT_CHAN_CNF, gsm48_rr_tx_rand_acc},
 #if 0
        {SBIT(GSM48_RR_ST_DEDICATED),
-        RSL_MT_CHAN_CNF, "CHAN_CNF", gsm48_rr_rand_acc_cnf_dedicated},
+        RSL_MT_CHAN_CNF, gsm48_rr_rand_acc_cnf_dedicated},
        {SBIT(GSM_RRSTATE),
-        RSL_MT_MDL_ERROR_IND, "MDL_ERROR_IND", gsm48_rr_mdl_error_ind},
+        RSL_MT_MDL_ERROR_IND, gsm48_rr_mdl_error_ind},
 #endif
 };
 
@@ -3279,24 +3282,22 @@ static int gsm48_rcv_rsl(struct osmocom_ms *ms, struct msgb *msg)
        int i;
        int rc;
 
+       if (msg_type != RSL_MT_UNIT_DATA_IND) {
+               LOGP(DRSL, LOGL_INFO, "(ms %s) Received '%s' from L2 in state "
+                       "%s\n", ms->name, get_rsl_name(msg_type),
+                       gsm48_rr_state_names[rr->state]);
+       }
+
        /* find function for current state and message */
        for (i = 0; i < DLDATASLLEN; i++)
                if ((msg_type == dldatastatelist[i].type)
                 && ((1 << rr->state) & dldatastatelist[i].states))
                        break;
        if (i == DLDATASLLEN) {
-               LOGP(DRSL, LOGL_NOTICE, "RSLms message 0x%02x unhandled at "
-               "state %s.\n", msg_type, gsm48_rr_state_names[rr->state]);
+               LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
                msgb_free(msg);
                return 0;
        }
-       LOGP(DRSL, LOGL_INFO, "(ms %s) Received 'RSL_MT_%s' from RSL in state "
-               "%s\n", ms->name, dldatastatelist[i].type_name,
-               gsm48_rr_state_names[rr->state]);
-       if (dldatastatelist[i].rout != gsm48_rr_unit_data_ind)
-               LOGP(DRR, LOGL_INFO, "(ms %s) Received 'RSL_MT_%s' from in "
-                       "state %s\n", ms->name, dldatastatelist[i].type_name,
-                       gsm48_rr_state_names[rr->state]);
 
        rc = dldatastatelist[i].rout(ms, msg);
 
@@ -3458,11 +3459,17 @@ they queue must be flushed when rr fails
 static int gsm48_rr_abort_req(struct osmocom_ms *ms, struct gsm48_rr *rrmsg)
 {
        struct gsm48_rrlayer *rr = ms->rrlayer;
+       uint8_t *mode;
+
        stop_rr_t3126(rr);
        if (rr->state == GSM48_RR_ST_DEDICATED) {
-               struct gsm_dl dlmsg;
-
-               memset(&dlmsg, 0, sizeof(dlmsg));
+               /* release message */
+               nmsg = gsm48_l3_msgb_alloc();
+               if (!nmsg)
+                       return -ENOMEM;
+               mode = msgb_put(nmsg, 2);
+               mode[0] = RSL_IE_RELEASE_MODE;
+               mode[1] = 0; /* normal release */
                return gsm48_send_rsl(ms, RSL_MT_REL_REQ, nmsg);
        }
        new_rr_state(rr, GSM48_RR_ST_IDLE);
@@ -3681,12 +3688,12 @@ static int gsm48_rr_rx_hando_cmd(struct osmocom_ms *ms, struct msgb *msg)
        /* Synchronization Indication */
        if (TLVP_PRESENT(&tp, GSM48_IE_SYNC_IND))
                gsm48_decode_sync_ind(rr,
-                       TLVP_VAL(&tp, GSM48_IE_MOBILE_ALLOC)-1, &cd);
+                       TLVP_VAL(&tp, GSM48_IE_SYNC_IND)-1, &cd);
        /* Frequency Sort List */
        if (TLVP_PRESENT(&tp, GSM48_IE_FREQ_SHORT_LIST))
                gsm48_decode_freq_list(&ms->support, s->freq,
-                       TLVP_VAL(&tp, GSM48_IE_MOBILE_ALLOC),
-                       *(TLVP_VAL(&tp, GSM48_IE_MOBILE_ALLOC)-1),
+                       TLVP_VAL(&tp, GSM48_IE_FREQ_SHORT_LIST),
+                       *(TLVP_VAL(&tp, GSM48_IE_FREQ_SHORT_LIST)-1),
                                0xce, FREQ_TYPE_SERV);
 
 
@@ -3765,6 +3772,15 @@ static int gsm48_rr_mdl_error_ind(struct osmocom_ms *ms, struct msgb *msg)
        struct msgb *nmsg;
        struct gsm_rr_hdr *nrrh;
 
+       printing of the cause
+
+       switch (msg->l3h[0]) {
+       case RLL_CAUSE_SEQ_ERR:
+       case RLL_CAUSE_UNSOL_DM_RESP_MF:
+       einige muessen ignoriert werden
+       andere gelten als release
+       }
+
        if (rr->hando_susp_state || rr->assign_susp_state) {
                if (!rr->resume_last_state) {
                        rr->resume_last_state = 1;
@@ -3780,7 +3796,7 @@ static int gsm48_rr_mdl_error_ind(struct osmocom_ms *ms, struct msgb *msg)
                        nmsg = gsm48_l3_msgb_alloc();
                        if (!nmsg)
                                return -ENOMEM;
-                       return gsm48_send_rsl(ms, RSL_MT_EST_REQ, nmsg);
+                       return gsm48_send_rsl(ms, RSL_MT_RECON_REQ, nmsg);
                }
                rr->resume_last_state = 0;
        }