use gsm48_ie code which is now in libosmocore
authorHarald Welte <laforge@gnumonks.org>
Mon, 8 Mar 2010 08:37:41 +0000 (09:37 +0100)
committerHarald Welte <laforge@gnumonks.org>
Mon, 8 Mar 2010 08:38:59 +0000 (09:38 +0100)
src/host/gsm48-andreas/gsm48_cc.c
src/host/gsm48-andreas/gsm48_ie.c [deleted file]
src/host/gsm48-andreas/gsm48_rr.c

index 1db41a1..3237ef2 100644 (file)
@@ -141,28 +141,28 @@ auch beim LCR für ms-mode anpassen !!!!
        gsm48_start_cc_timer(trans, 0x303, GSM48_T303_MO);
 
        /* bearer capability */
-       encode_bearer_cap(msg, 0, &setup->bearer_cap);
+       gsm48_encode_bearer_cap(msg, 0, &setup->bearer_cap);
        /* facility */
        if (setup->fields & MNCC_F_FACILITY)
-               encode_facility(msg, 0, &setup->facility);
+               gsm48_encode_facility(msg, 0, &setup->facility);
        /* called party BCD number */
        if (setup->fields & MNCC_F_CALLED)
-               encode_called(msg, &setup->called);
+               gsm48_encode_called(msg, &setup->called);
        /* user-user */
        if (setup->fields & MNCC_F_USERUSER)
-               encode_useruser(msg, 0, &setup->useruser);
+               gsm48_encode_useruser(msg, 0, &setup->useruser);
        /* ss version */
        if (setup->fields & MNCC_F_SSVERSION)
-               encode_ssversion(msg, 0, &setup->ssversion);
+               gsm48_encode_ssversion(msg, 0, &setup->ssversion);
        /* CLIR suppression */
        if (setup->clir.sup)
-               encode_clir_sup(msg);
+               gsm48_encode_clir_sup(msg);
        /* CLIR invocation */
        if (setup->clir.inv)
-               encode_clir_inv(msg);
+               gsm48_encode_clir_inv(msg);
        /* cc cap */
        if (setup->fields & MNCC_F_CCCAP)
-               encode_cccap(msg, 0, &setup->cccap);
+               gsm48_encode_cccap(msg, 0, &setup->cccap);
 
        new_cc_state(trans, GSM_CSTATE_CALL_INITIATED);
 
@@ -196,13 +196,13 @@ diesen state in MT_CALL_CONF umbenennen !!!!
 
        /* bearer capability */
        if (confirm->fields & MNCC_F_BEARER_CAP)
-               encode_bearer_cap(msg, 0, &confirm->bearer_cap);
+               gsm48_encode_bearer_cap(msg, 0, &confirm->bearer_cap);
        /* cause */
        if (confirm->fields & MNCC_F_CAUSE)
-               encode_cause(msg, 0, &confirm->cause);
+               gsm48_encode_cause(msg, 0, &confirm->cause);
        /* cc cap */
        if (confirm->fields & MNCC_F_CCCAP)
-               encode_cccap(msg, 0, &confirm->cccap);
+               gsm48_encode_cccap(msg, 0, &confirm->cccap);
 
        return gsm48_sendmsg(msg, trans);
 }
@@ -218,13 +218,13 @@ static int gsm48_cc_tx_alerting(struct gsm_trans *trans, void *arg)
 
        /* facility */
        if (alerting->fields & MNCC_F_FACILITY)
-               encode_facility(msg, 0, &alerting->facility);
+               gsm48_encode_facility(msg, 0, &alerting->facility);
        /* user-user */
        if (alerting->fields & MNCC_F_USERUSER)
-               encode_useruser(msg, 0, &alerting->useruser);
+               gsm48_encode_useruser(msg, 0, &alerting->useruser);
        /* ss version */
        if (alerting->fields & MNCC_F_SSVERSION)
-               encode_ssversion(msg, 0, &alerting->ssversion);
+               gsm48_encode_ssversion(msg, 0, &alerting->ssversion);
 
        new_cc_state(trans, GSM_CSTATE_CALL_RECEIVED);
        
@@ -245,13 +245,13 @@ static int gsm48_cc_tx_connect(struct gsm_trans *trans, void *arg)
 
        /* facility */
        if (connect->fields & MNCC_F_FACILITY)
-               encode_facility(msg, 0, &connect->facility);
+               gsm48_encode_facility(msg, 0, &connect->facility);
        /* user-user */
        if (connect->fields & MNCC_F_USERUSER)
-               encode_useruser(msg, 0, &connect->useruser);
+               gsm48_encode_useruser(msg, 0, &connect->useruser);
        /* ss version */
        if (connect->fields & MNCC_F_SSVERSION)
-               encode_ssversion(msg, 0, &connect->ssversion);
+               gsm48_encode_ssversion(msg, 0, &connect->ssversion);
 
        new_cc_state(trans, GSM_CSTATE_CONNECT_REQUEST);
 
@@ -268,7 +268,7 @@ static int gsm48_cc_tx_notify(struct gsm_trans *trans, void *arg)
        gh->msg_type = GSM48_MT_CC_NOTIFY;
 
        /* notify */
-       encode_notify(msg, notify->notify);
+       gsm48_encode_notify(msg, notify->notify);
 
        return gsm48_sendmsg(msg, trans);
 }
@@ -283,7 +283,7 @@ static int gsm48_cc_tx_start_dtmf(struct gsm_trans *trans, void *arg)
        gh->msg_type = GSM48_MT_CC_START_DTMF;
 
        /* keypad */
-       encode_keypad(msg, dtmf->keypad);
+       gsm48_encode_keypad(msg, dtmf->keypad);
 
        return gsm48_sendmsg(msg, trans);
 }
@@ -335,22 +335,22 @@ static int gsm48_cc_tx_disconnect(struct gsm_trans *trans, void *arg)
 
        /* cause */
        if (disc->fields & MNCC_F_CAUSE)
-               encode_cause(msg, 1, &disc->cause);
+               gsm48_encode_cause(msg, 1, &disc->cause);
        else
-               encode_cause(msg, 1, &default_cause);
+               gsm48_encode_cause(msg, 1, &default_cause);
 
        /* facility */
        if (disc->fields & MNCC_F_FACILITY)
-               encode_facility(msg, 0, &disc->facility);
+               gsm48_encode_facility(msg, 0, &disc->facility);
        /* progress */
        if (disc->fields & MNCC_F_PROGRESS)
-               encode_progress(msg, 0, &disc->progress);
+               gsm48_encode_progress(msg, 0, &disc->progress);
        /* user-user */
        if (disc->fields & MNCC_F_USERUSER)
-               encode_useruser(msg, 0, &disc->useruser);
+               gsm48_encode_useruser(msg, 0, &disc->useruser);
        /* ss version */
        if (disc->fields & MNCC_F_SSVERSION)
-               encode_ssversion(msg, 0, &disc->ssversion);
+               gsm48_encode_ssversion(msg, 0, &disc->ssversion);
 
        new_cc_state(trans, GSM_CSTATE_DISCONNECT_REQ);
 
@@ -373,16 +373,16 @@ static int gsm48_cc_tx_release(struct gsm_trans *trans, void *arg)
 
        /* cause */
        if (rel->fields & MNCC_F_CAUSE)
-               encode_cause(msg, 0, &rel->cause);
+               gsm48_encode_cause(msg, 0, &rel->cause);
        /* facility */
        if (rel->fields & MNCC_F_FACILITY)
-               encode_facility(msg, 0, &rel->facility);
+               gsm48_encode_facility(msg, 0, &rel->facility);
        /* user-user */
        if (rel->fields & MNCC_F_USERUSER)
-               encode_useruser(msg, 0, &rel->useruser);
+               gsm48_encode_useruser(msg, 0, &rel->useruser);
        /* ss version */
        if (rel->fields & MNCC_F_SSVERSION)
-               encode_ssversion(msg, 0, &rel->ssversion);
+               gsm48_encode_ssversion(msg, 0, &rel->ssversion);
 
        trans->cc.T308_second = 0;
        memcpy(&trans->cc.msg, rel, sizeof(struct gsm_mncc));
@@ -408,16 +408,16 @@ static int gsm48_cc_tx_release_compl(struct gsm_trans *trans, void *arg)
 
        /* cause */
        if (rel->fields & MNCC_F_CAUSE)
-               encode_cause(msg, 0, &rel->cause);
+               gsm48_encode_cause(msg, 0, &rel->cause);
        /* facility */
        if (rel->fields & MNCC_F_FACILITY)
-               encode_facility(msg, 0, &rel->facility);
+               gsm48_encode_facility(msg, 0, &rel->facility);
        /* user-user */
        if (rel->fields & MNCC_F_USERUSER)
-               encode_useruser(msg, 0, &rel->useruser);
+               gsm48_encode_useruser(msg, 0, &rel->useruser);
        /* ss version */
        if (rel->fields & MNCC_F_SSVERSION)
-               encode_ssversion(msg, 0, &rel->ssversion);
+               gsm48_encode_ssversion(msg, 0, &rel->ssversion);
 
        trans_free(trans);
 
@@ -434,10 +434,10 @@ static int gsm48_cc_tx_facility(struct gsm_trans *trans, void *arg)
        gh->msg_type = GSM48_MT_CC_FACILITY;
 
        /* facility */
-       encode_facility(msg, 1, &fac->facility);
+       gsm48_encode_facility(msg, 1, &fac->facility);
        /* ss version */
        if (rel->fields & MNCC_F_SSVERSION)
-               encode_ssversion(msg, 0, &rel->ssversion);
+               gsm48_encode_ssversion(msg, 0, &rel->ssversion);
 
        return gsm48_sendmsg(msg, trans);
 }
@@ -453,10 +453,10 @@ static int gsm48_cc_tx_userinfo(struct gsm_trans *trans, void *arg)
 
        /* user-user */
        if (user->fields & MNCC_F_USERUSER)
-               encode_useruser(msg, 1, &user->useruser);
+               gsm48_encode_useruser(msg, 1, &user->useruser);
        /* more data */
        if (user->more)
-               encode_more(msg);
+               gsm48_encode_more(msg);
 
        return gsm48_sendmsg(msg, trans);
 }
@@ -473,7 +473,7 @@ static int gsm48_cc_tx_modify(struct gsm_trans *trans, void *arg)
        gsm48_start_cc_timer(trans, 0x323, GSM48_T323_MS);
 
        /* bearer capability */
-       encode_bearer_cap(msg, 1, &modify->bearer_cap);
+       gsm48_encode_bearer_cap(msg, 1, &modify->bearer_cap);
 
        new_cc_state(trans, GSM_CSTATE_MO_TERM_MODIFY);
 
@@ -490,7 +490,7 @@ static int gsm48_cc_tx_modify_complete(struct gsm_trans *trans, void *arg)
        gh->msg_type = GSM48_MT_CC_MODIFY_COMPL;
 
        /* bearer capability */
-       encode_bearer_cap(msg, 1, &modify->bearer_cap);
+       gsm48_encode_bearer_cap(msg, 1, &modify->bearer_cap);
 
        new_cc_state(trans, GSM_CSTATE_ACTIVE);
 
@@ -507,9 +507,9 @@ static int gsm48_cc_tx_modify_reject(struct gsm_trans *trans, void *arg)
        gh->msg_type = GSM48_MT_CC_MODIFY_REJECT;
 
        /* bearer capability */
-       encode_bearer_cap(msg, 1, &modify->bearer_cap);
+       gsm48_encode_bearer_cap(msg, 1, &modify->bearer_cap);
        /* cause */
-       encode_cause(msg, 1, &modify->cause);
+       gsm48_encode_cause(msg, 1, &modify->cause);
 
        new_cc_state(trans, GSM_CSTATE_ACTIVE);
 
@@ -600,20 +600,20 @@ T310 stoppen, wenn eine progress message mit einem progress indicator mit 1, 2 o
        /* bearer capability */
        if (TLVP_PRESENT(&tp, GSM48_IE_BEARER_CAP)) {
                call_proc.fields |= MNCC_F_BEARER_CAP;
-               decode_bearer_cap(&call_proc.bearer_cap,
+               gsm48_decode_bearer_cap(&call_proc.bearer_cap,
                                  TLVP_VAL(&tp, GSM48_IE_BEARER_CAP)-1);
        }
        /* facility */
        if (TLVP_PRESENT(&tp, GSM48_IE_FACILITY)) {
                call_proc.fields |= MNCC_F_FACILITY;
-               decode_facility(&call_proc.facility,
+               gsm48_decode_facility(&call_proc.facility,
                                TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
        }
 
        /* progress */
        if (TLVP_PRESENT(&tp, GSM48_IE_PROGR_IND)) {
                call_proc.fields |= MNCC_F_PROGRESS;
-               decode_progress(&call_proc.progress,
+               gsm48_decode_progress(&call_proc.progress,
                                TLVP_VAL(&tp, GSM48_IE_PROGR_IND)-1);
        }
 
@@ -640,20 +640,20 @@ static int gsm48_cc_rx_alerting(struct gsm_trans *trans, struct msgb *msg)
        /* facility */
        if (TLVP_PRESENT(&tp, GSM48_IE_FACILITY)) {
                alerting.fields |= MNCC_F_FACILITY;
-               decode_facility(&alerting.facility,
+               gsm48_decode_facility(&alerting.facility,
                                TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
        }
 
        /* progress */
        if (TLVP_PRESENT(&tp, GSM48_IE_PROGR_IND)) {
                alerting.fields |= MNCC_F_PROGRESS;
-               decode_progress(&alerting.progress,
+               gsm48_decode_progress(&alerting.progress,
                                TLVP_VAL(&tp, GSM48_IE_PROGR_IND)-1);
        }
        /* user-user */
        if (TLVP_PRESENT(&tp, GSM48_IE_USER_USER)) {
                alerting.fields |= MNCC_F_USERUSER;
-               decode_useruser(&alerting.alerting,
+               gsm48_decode_useruser(&alerting.alerting,
                                TLVP_VAL(&tp, GSM48_IE_USER_USER)-1);
        }
 
@@ -679,25 +679,25 @@ static int gsm48_cc_rx_connect(struct gsm_trans *trans, struct msgb *msg)
        /* facility */
        if (TLVP_PRESENT(&tp, GSM48_IE_FACILITY)) {
                connect.fields |= MNCC_F_FACILITY;
-               decode_facility(&connect.facility,
+               gsm48_decode_facility(&connect.facility,
                                TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
        }
        /* connected */
        if (TLVP_PRESENT(&tp, GSM48_IE_CON_BCD)) {
                connect.fields |= MNCC_F_CONNECTED;
-               decode_connected(&alerting.connected,
+               gsm48_decode_connected(&alerting.connected,
                                TLVP_VAL(&tp, GSM48_IE_CON_BCD)-1);
        }
        /* progress */
        if (TLVP_PRESENT(&tp, GSM48_IE_PROGR_IND)) {
                connect.fields |= MNCC_F_PROGRESS;
-               decode_progress(&alerting.connect,
+               gsm48_decode_progress(&alerting.connect,
                                TLVP_VAL(&tp, GSM48_IE_PROGR_IND)-1);
        }
        /* user-user */
        if (TLVP_PRESENT(&tp, GSM48_IE_USER_USER)) {
                connect.fields |= MNCC_F_USERUSER;
-               decode_useruser(&connect.useruser,
+               gsm48_decode_useruser(&connect.useruser,
                                TLVP_VAL(&tp, GSM48_IE_USER_USER)-1);
        }
 
@@ -723,49 +723,49 @@ static int gsm48_cc_rx_setup(struct gsm_trans *trans, struct msgb *msg)
        /* bearer capability */
        if (TLVP_PRESENT(&tp, GSM48_IE_BEARER_CAP)) {
                setup.fields |= MNCC_F_BEARER_CAP;
-               decode_bearer_cap(&setup.bearer_cap,
+               gsm48_decode_bearer_cap(&setup.bearer_cap,
                                  TLVP_VAL(&tp, GSM48_IE_BEARER_CAP)-1);
        }
        /* facility */
        if (TLVP_PRESENT(&tp, GSM48_IE_FACILITY)) {
                setup.fields |= MNCC_F_FACILITY;
-               decode_facility(&setup.facility,
+               gsm48_decode_facility(&setup.facility,
                                TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
        }
        /* progress */
        if (TLVP_PRESENT(&tp, GSM48_IE_PROGR_IND)) {
                setup.fields |= MNCC_F_PROGRESS;
-               decode_progress(&setup.progress,
+               gsm48_decode_progress(&setup.progress,
                                TLVP_VAL(&tp, GSM48_IE_PROGR_IND)-1);
        }
        /* signal */
        if (TLVP_PRESENT(&tp, GSM48_IE_SIGNAL)) {
                setup.fields |= MNCC_F_SIGNAL;
-               decode_signal(&setup.signal,
+               gsm48_decode_signal(&setup.signal,
                                TLVP_VAL(&tp, GSM48_IE_SIGNAL)-1);
        }
        /* calling party bcd number */
        if (TLVP_PRESENT(&tp, GSM48_IE_CALLING_BCD)) {
                setup.fields |= MNCC_F_CALLING;
-               decode_calling(&setup.calling,
+               gsm48_decode_calling(&setup.calling,
                              TLVP_VAL(&tp, GSM48_IE_CALLING_BCD)-1);
        }
        /* called party bcd number */
        if (TLVP_PRESENT(&tp, GSM48_IE_CALLED_BCD)) {
                setup.fields |= MNCC_F_CALLED;
-               decode_called(&setup.called,
+               gsm48_decode_called(&setup.called,
                              TLVP_VAL(&tp, GSM48_IE_CALLED_BCD)-1);
        }
        /* redirecting party bcd number */
        if (TLVP_PRESENT(&tp, GSM48_IE_REDIR_BCD)) {
                setup.fields |= MNCC_F_REDIRECTING;
-               decode_redirecting(&setup.redirecting,
+               gsm48_decode_redirecting(&setup.redirecting,
                              TLVP_VAL(&tp, GSM48_IE_REDIR_BCD)-1);
        }
        /* user-user */
        if (TLVP_PRESENT(&tp, GSM48_IE_USER_USER)) {
                setup.fields |= MNCC_F_USERUSER;
-               decode_useruser(&setup.useruser,
+               gsm48_decode_useruser(&setup.useruser,
                                TLVP_VAL(&tp, GSM48_IE_USER_USER)-1);
        }
 
@@ -806,7 +806,7 @@ static int gsm48_cc_rx_notify(struct gsm_trans *trans, struct msgb *msg)
                DEBUGP(DCC, "Short read of notify message error.\n");
                return -EINVAL;
        }
-       decode_notify(&notify.notify, gh->data);
+       gsm48_decode_notify(&notify.notify, gh->data);
 
        return mncc_recvmsg(trans->subscr->net, trans, MNCC_NOTIFY_IND, &notify);
 }
@@ -825,13 +825,13 @@ static int gsm48_cc_rx_progress(struct gsm_trans *trans, struct msgb *msg)
        /* progress */
        if (TLVP_PRESENT(&tp, GSM48_IE_PROGR_IND)) {
                setup.fields |= MNCC_F_PROGRESS;
-               decode_progress(&setup.progress,
+               gsm48_decode_progress(&setup.progress,
                                TLVP_VAL(&tp, GSM48_IE_PROGR_IND)-1);
        }
        /* user-user */
        if (TLVP_PRESENT(&tp, GSM48_IE_USER_USER)) {
                disc.fields |= MNCC_F_USERUSER;
-               decode_useruser(&disc.useruser,
+               gsm48_decode_useruser(&disc.useruser,
                                TLVP_VAL(&tp, GSM48_IE_USER_USER)-1);
        }
 
@@ -852,7 +852,7 @@ static int gsm48_cc_rx_start_dtmf_ack(struct gsm_trans *trans, struct msgb *msg)
        /* keypad facility */
        if (TLVP_PRESENT(&tp, GSM48_IE_KPD_FACILITY)) {
                dtmf.fields |= MNCC_F_KEYPAD;
-               decode_keypad(&dtmf.keypad,
+               gsm48_decode_keypad(&dtmf.keypad,
                              TLVP_VAL(&tp, GSM48_IE_KPD_FACILITY)-1);
        }
 
@@ -874,7 +874,7 @@ static int gsm48_cc_rx_start_dtmf_rej(struct gsm_trans *trans, struct msgb *msg)
                DEBUGP(DCC, "Short read of dtmf reject message error.\n");
                return -EINVAL;
        }
-       decode_cause(&dtmf.cause, gh->data);
+       gsm48_decode_cause(&dtmf.cause, gh->data);
 
        return mncc_recvmsg(trans->subscr->net, trans, MNCC_START_DTMF_REJ, &dtmf);
 }
@@ -921,7 +921,7 @@ static int gsm48_cc_rx_hold_rej(struct gsm_trans *trans, struct msgb *msg)
                DEBUGP(DCC, "Short read of hold reject message error.\n");
                return -EINVAL;
        }
-       decode_cause(&hold.cause, gh->data);
+       gsm48_decode_cause(&hold.cause, gh->data);
 
        return mncc_recvmsg(trans->subscr->net, trans, MNCC_HOLD_REJ, &hold);
 }
@@ -954,7 +954,7 @@ static int gsm48_cc_rx_retrieve_rej(struct gsm_trans *trans, struct msgb *msg)
                DEBUGP(DCC, "Short read of retrieve reject message error.\n");
                return -EINVAL;
        }
-       decode_cause(&retrieve.cause, gh->data);
+       gsm48_decode_cause(&retrieve.cause, gh->data);
 
        return mncc_recvmsg(trans->subscr->net, trans, MNCC_RETRIEVE_REJ, &retrieve);
 }
@@ -977,19 +977,19 @@ static int gsm48_cc_rx_disconnect(struct gsm_trans *trans, struct msgb *msg)
        /* cause */
        if (TLVP_PRESENT(&tp, GSM48_IE_CAUSE)) {
                disc.fields |= MNCC_F_CAUSE;
-               decode_cause(&disc.cause,
+               gsm48_decode_cause(&disc.cause,
                             TLVP_VAL(&tp, GSM48_IE_CAUSE)-1);
        }
        /* facility */
        if (TLVP_PRESENT(&tp, GSM48_IE_FACILITY)) {
                disc.fields |= MNCC_F_FACILITY;
-               decode_facility(&disc.facility,
+               gsm48_decode_facility(&disc.facility,
                                TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
        }
        /* user-user */
        if (TLVP_PRESENT(&tp, GSM48_IE_USER_USER)) {
                disc.fields |= MNCC_F_USERUSER;
-               decode_useruser(&disc.useruser,
+               gsm48_decode_useruser(&disc.useruser,
                                TLVP_VAL(&tp, GSM48_IE_USER_USER)-1);
        }
 
@@ -1017,19 +1017,19 @@ static int gsm48_cc_rx_release(struct gsm_trans *trans, struct msgb *msg)
        /* cause */
        if (TLVP_PRESENT(&tp, GSM48_IE_CAUSE)) {
                rel.fields |= MNCC_F_CAUSE;
-               decode_cause(&rel.cause,
+               gsm48_decode_cause(&rel.cause,
                             TLVP_VAL(&tp, GSM48_IE_CAUSE)-1);
        }
        /* facility */
        if (TLVP_PRESENT(&tp, GSM48_IE_FACILITY)) {
                rel.fields |= MNCC_F_FACILITY;
-               decode_facility(&rel.facility,
+               gsm48_decode_facility(&rel.facility,
                                TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
        }
        /* user-user */
        if (TLVP_PRESENT(&tp, GSM48_IE_USER_USER)) {
                rel.fields |= MNCC_F_USERUSER;
-               decode_useruser(&rel.useruser,
+               gsm48_decode_useruser(&rel.useruser,
                                TLVP_VAL(&tp, GSM48_IE_USER_USER)-1);
        }
 
@@ -1068,19 +1068,19 @@ static int gsm48_cc_rx_release_compl(struct gsm_trans *trans, struct msgb *msg)
        /* cause */
        if (TLVP_PRESENT(&tp, GSM48_IE_CAUSE)) {
                rel.fields |= MNCC_F_CAUSE;
-               decode_cause(&rel.cause,
+               gsm48_decode_cause(&rel.cause,
                             TLVP_VAL(&tp, GSM48_IE_CAUSE)-1);
        }
        /* facility */
        if (TLVP_PRESENT(&tp, GSM48_IE_FACILITY)) {
                rel.fields |= MNCC_F_FACILITY;
-               decode_facility(&rel.facility,
+               gsm48_decode_facility(&rel.facility,
                                TLVP_VAL(&tp, GSM48_IE_FACILITY)-1);
        }
        /* user-user */
        if (TLVP_PRESENT(&tp, GSM48_IE_USER_USER)) {
                rel.fields |= MNCC_F_USERUSER;
-               decode_useruser(&rel.useruser,
+               gsm48_decode_useruser(&rel.useruser,
                                TLVP_VAL(&tp, GSM48_IE_USER_USER)-1);
        }
 
@@ -1123,7 +1123,7 @@ static int gsm48_cc_rx_facility(struct gsm_trans *trans, struct msgb *msg)
                DEBUGP(DCC, "Short read of facility message error.\n");
                return -EINVAL;
        }
-       decode_facility(&fac.facility, gh->data);
+       gsm48_decode_facility(&fac.facility, gh->data);
 
        return mncc_recvmsg(trans->subscr->net, trans, MNCC_FACILITY_IND, &fac);
 }
@@ -1139,10 +1139,10 @@ static int gsm48_cc_tx_userinfo(struct gsm_trans *trans, void *arg)
 
        /* user-user */
        if (user->fields & MNCC_F_USERUSER)
-               encode_useruser(msg, 1, &user->useruser);
+               gsm48_encode_useruser(msg, 1, &user->useruser);
        /* more data */
        if (user->more)
-               encode_more(msg);
+               gsm48_encode_more(msg);
 
        return gsm48_sendmsg(msg, trans);
 }
@@ -1161,7 +1161,7 @@ static int gsm48_cc_rx_modify(struct gsm_trans *trans, struct msgb *msg)
                DEBUGP(DCC, "Short read of modify message error.\n");
                return -EINVAL;
        }
-       decode_bearer_cap(&modify.bearer_cap, gh->data);
+       gsm48_decode_bearer_cap(&modify.bearer_cap, gh->data);
 
        new_cc_state(trans, GSM_CSTATE_MO_ORIG_MODIFY);
 
@@ -1184,7 +1184,7 @@ static int gsm48_cc_rx_modify_complete(struct gsm_trans *trans, struct msgb *msg
                DEBUGP(DCC, "Short read of modify complete message error.\n");
                return -EINVAL;
        }
-       decode_bearer_cap(&modify.bearer_cap, gh->data);
+       gsm48_decode_bearer_cap(&modify.bearer_cap, gh->data);
 
        new_cc_state(trans, GSM_CSTATE_ACTIVE);
 
@@ -1211,13 +1211,13 @@ static int gsm48_cc_rx_modify_reject(struct gsm_trans *trans, struct msgb *msg)
        /* bearer capability */
        if (TLVP_PRESENT(&tp, GSM48_IE_BEARER_CAP)) {
                call_proc.fields |= MNCC_F_BEARER_CAP;
-               decode_bearer_cap(&call_proc.bearer_cap,
+               gsm48_decode_bearer_cap(&call_proc.bearer_cap,
                                  TLVP_VAL(&tp, GSM48_IE_BEARER_CAP)-1);
        }
        /* cause */
        if (TLVP_PRESENT(&tp, GSM48_IE_CAUSE)) {
                modify.fields |= MNCC_F_CAUSE;
-               decode_cause(&modify.cause,
+               gsm48_decode_cause(&modify.cause,
                             TLVP_VAL(&tp, GSM48_IE_CAUSE)-1);
        }
 
diff --git a/src/host/gsm48-andreas/gsm48_ie.c b/src/host/gsm48-andreas/gsm48_ie.c
deleted file mode 100644 (file)
index 060dc29..0000000
+++ /dev/null
@@ -1,624 +0,0 @@
-static const char bcd_num_digits[] = {
-       '0', '1', '2', '3', '4', '5', '6', '7', 
-       '8', '9', '*', '#', 'a', 'b', 'c', '\0'
-};
-
-/* decode a 'called/calling/connect party BCD number' as in 10.5.4.7 */
-int decode_bcd_number(char *output, int output_len, const u_int8_t *bcd_lv,
-                     int h_len)
-{
-       u_int8_t in_len = bcd_lv[0];
-       int i;
-
-       for (i = 1 + h_len; i <= in_len; i++) {
-               /* lower nibble */
-               output_len--;
-               if (output_len <= 1)
-                       break;
-               *output++ = bcd_num_digits[bcd_lv[i] & 0xf];
-
-               /* higher nibble */
-               output_len--;
-               if (output_len <= 1)
-                       break;
-               *output++ = bcd_num_digits[bcd_lv[i] >> 4];
-       }
-       if (output_len >= 1)
-               *output++ = '\0';
-
-       return 0;
-}
-
-/* convert a single ASCII character to call-control BCD */
-static int asc_to_bcd(const char asc)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(bcd_num_digits); i++) {
-               if (bcd_num_digits[i] == asc)
-                       return i;
-       }
-       return -EINVAL;
-}
-
-/* convert a ASCII phone number to 'called/calling/connect party BCD number' */
-int encode_bcd_number(u_int8_t *bcd_lv, u_int8_t max_len,
-                     int h_len, const char *input)
-{
-       int in_len = strlen(input);
-       int i;
-       u_int8_t *bcd_cur = bcd_lv + 1 + h_len;
-
-       /* two digits per byte, plus type byte */
-       bcd_lv[0] = in_len/2 + h_len;
-       if (in_len % 2)
-               bcd_lv[0]++;
-
-       if (bcd_lv[0] > max_len)
-               return -EIO;
-
-       for (i = 0; i < in_len; i++) {
-               int rc = asc_to_bcd(input[i]);
-               if (rc < 0)
-                       return rc;
-               if (i % 2 == 0)
-                       *bcd_cur = rc;  
-               else
-                       *bcd_cur++ |= (rc << 4);
-       }
-       /* append padding nibble in case of odd length */
-       if (i % 2)
-               *bcd_cur++ |= 0xf0;
-
-       /* return how many bytes we used */
-       return (bcd_cur - bcd_lv);
-}
-
-/* decode 'bearer capability' */
-int decode_bearer_cap(struct gsm_mncc_bearer_cap *bcap,
-                            const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-       int i, s;
-
-       if (in_len < 1)
-               return -EINVAL;
-
-       bcap->speech_ver[0] = -1; /* end of list, of maximum 7 values */
-
-       /* octet 3 */
-       bcap->transfer = lv[1] & 0x07;
-       bcap->mode = (lv[1] & 0x08) >> 3;
-       bcap->coding = (lv[1] & 0x10) >> 4;
-       bcap->radio = (lv[1] & 0x60) >> 5;
-
-       if (bcap->transfer == GSM_MNCC_BCAP_SPEECH) {
-               i = 1;
-               s = 0;
-               while(!(lv[i] & 0x80)) {
-                       i++; /* octet 3a etc */
-                       if (in_len < i)
-                               return 0;
-                       bcap->speech_ver[s++] = lv[i] & 0x0f;
-                       bcap->speech_ver[s] = -1; /* end of list */
-                       if (i == 2) /* octet 3a */
-                               bcap->speech_ctm = (lv[i] & 0x20) >> 5;
-                       if (s == 7) /* maximum speech versions + end of list */
-                               return 0;
-               }
-       } else {
-               i = 1;
-               while (!(lv[i] & 0x80)) {
-                       i++; /* octet 3a etc */
-                       if (in_len < i)
-                               return 0;
-                       /* ignore them */
-               }
-               /* FIXME: implement OCTET 4+ parsing */
-       }
-
-       return 0;
-}
-
-/* encode 'bearer capability' */
-int encode_bearer_cap(struct msgb *msg, int lv_only,
-                            const struct gsm_mncc_bearer_cap *bcap)
-{
-       u_int8_t lv[32 + 1];
-       int i = 1, s;
-
-       lv[1] = bcap->transfer;
-       lv[1] |= bcap->mode << 3;
-       lv[1] |= bcap->coding << 4;
-       lv[1] |= bcap->radio << 5;
-
-       if (bcap->transfer == GSM_MNCC_BCAP_SPEECH) {
-               for (s = 0; bcap->speech_ver[s] >= 0; s++) {
-                       i++; /* octet 3a etc */
-                       lv[i] = bcap->speech_ver[s];
-                       if (i == 2) /* octet 3a */
-                               lv[i] |= bcap->speech_ctm << 5;
-               }
-               lv[i] |= 0x80; /* last IE of octet 3 etc */
-       } else {
-               /* FIXME: implement OCTET 4+ encoding */
-       }
-
-       lv[0] = i;
-       if (lv_only)
-               msgb_lv_put(msg, lv[0], lv+1);
-       else
-               msgb_tlv_put(msg, GSM48_IE_BEARER_CAP, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode 'call control cap' */
-int decode_cccap(struct gsm_mncc_cccap *ccap, const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-
-       if (in_len < 1)
-               return -EINVAL;
-
-       /* octet 3 */
-       ccap->dtmf = lv[1] & 0x01;
-       ccap->pcp = (lv[1] & 0x02) >> 1;
-       
-       return 0;
-}
-
-/* encode 'call control cap' */
-int encode_cccap(struct msgb *msg,
-                       const struct gsm_mncc_cccap *ccap)
-{
-       u_int8_t lv[2];
-       int ret;
-
-       lv[0] = 1;
-       lv[1] = 0;
-       if (ccap->dtmf)
-               lv [1] |= 0x01;
-       if (ccap->cpc)
-               lv [1] |= 0x02;
-
-       msgb_tlv_put(msg, GSM48_IE_CCCAP, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode 'called party BCD number' */
-int decode_called(struct gsm_mncc_number *called,
-                        const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-
-       if (in_len < 1)
-               return -EINVAL;
-
-       /* octet 3 */
-       called->plan = lv[1] & 0x0f;
-       called->type = (lv[1] & 0x70) >> 4;
-
-       /* octet 4..N */
-       decode_bcd_number(called->number, sizeof(called->number), lv, 1);
-       
-       return 0;
-}
-
-/* encode 'called party BCD number' */
-int encode_called(struct msgb *msg,
-                        const struct gsm_mncc_number *called)
-{
-       u_int8_t lv[18];
-       int ret;
-
-       /* octet 3 */
-       lv[1] = called->plan;
-       lv[1] |= called->type << 4;
-
-       /* octet 4..N, octet 2 */
-       ret = encode_bcd_number(lv, sizeof(lv), 1, called->number);
-       if (ret < 0)
-               return ret;
-
-       msgb_tlv_put(msg, GSM48_IE_CALLED_BCD, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode callerid of various IEs */
-int decode_callerid(struct gsm_mncc_number *callerid,
-                        const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-       int i = 1;
-
-       if (in_len < 1)
-               return -EINVAL;
-
-       /* octet 3 */
-       callerid->plan = lv[1] & 0x0f;
-       callerid->type = (lv[1] & 0x70) >> 4;
-
-       /* octet 3a */
-       if (!(lv[1] & 0x80)) {
-               callerid->screen = lv[2] & 0x03;
-               callerid->preent = (lv[2] & 0x60) >> 5;
-               i = 2;
-       }
-
-       /* octet 4..N */
-       decode_bcd_number(callerid->number, sizeof(callerid->number), lv, i);
-
-       return 0;
-}
-
-/* encode callerid of various IEs */
-int encode_callerid(struct msgb *msg, int ie, int max_len,
-                          const struct gsm_mncc_number *callerid)
-{
-       u_int8_t lv[max_len - 1];
-       int h_len = 1;
-       int ret;
-
-       /* octet 3 */
-       lv[1] = callerid->plan;
-       lv[1] |= callerid->type << 4;
-
-       if (callerid->present || callerid->screen) {
-               /* octet 3a */
-               lv[2] = callerid->screen;
-               lv[2] |= callerid->present << 5;
-               lv[2] |= 0x80;
-               h_len++;
-       } else
-               lv[1] |= 0x80;
-
-       /* octet 4..N, octet 2 */
-       ret = encode_bcd_number(lv, sizeof(lv), h_len, callerid->number);
-       if (ret < 0)
-               return ret;
-
-       msgb_tlv_put(msg, ie, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode 'cause' */
-int decode_cause(struct gsm_mncc_cause *cause,
-                       const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-       int i;
-
-       if (in_len < 2)
-               return -EINVAL;
-
-       cause->diag_len = 0;
-
-       /* octet 3 */
-       cause->location = lv[1] & 0x0f;
-       cause->coding = (lv[1] & 0x60) >> 5;
-       
-       i = 1;
-       if (!(lv[i] & 0x80)) {
-               i++; /* octet 3a */
-               if (in_len < i+1)
-                       return 0;
-               cause->rec = 1;
-               cause->rec_val = lv[i] & 0x7f;
-               
-       }
-       i++;
-
-       /* octet 4 */
-       cause->value = lv[i] & 0x7f;
-       i++;
-
-       if (in_len < i) /* no diag */
-               return 0;
-
-       if (in_len - (i-1) > 32) /* maximum 32 octets */
-               return 0;
-
-       /* octet 5-N */
-       memcpy(cause->diag, lv + i, in_len - (i-1));
-       cause->diag_len = in_len - (i-1);
-
-       return 0;
-}
-
-/* encode 'cause' */
-int encode_cause(struct msgb *msg, int lv_only,
-                       const struct gsm_mncc_cause *cause)
-{
-       u_int8_t lv[32+4];
-       int i;
-
-       if (cause->diag_len > 32)
-               return -EINVAL;
-
-       /* octet 3 */
-       lv[1] = cause->location;
-       lv[1] |= cause->coding << 5;
-
-       i = 1;
-       if (cause->rec) {
-               i++; /* octet 3a */
-               lv[i] = cause->rec_val;
-       }
-       lv[i] |= 0x80; /* end of octet 3 */
-
-       /* octet 4 */
-       i++;
-       lv[i] = 0x80 | cause->value;
-
-       /* octet 5-N */
-       if (cause->diag_len) {
-               memcpy(lv + i, cause->diag, cause->diag_len);
-               i += cause->diag_len;
-       }
-
-       lv[0] = i;
-       if (lv_only)
-               msgb_lv_put(msg, lv[0], lv+1);
-       else
-               msgb_tlv_put(msg, GSM48_IE_CAUSE, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode 'calling number' */
-int decode_calling(struct gsm_mncc_number *calling,
-                        const u_int8_t *lv)
-{
-       return decode_callerid(calling, lv);
-}
-
-/* encode 'calling number' */
-int encode_calling(struct msgb *msg, 
-                         const struct gsm_mncc_number *calling)
-{
-       return encode_callerid(msg, GSM48_IE_CALLING_BCD, 14, calling);
-}
-
-/* decode 'connected number' */
-int decode_connected(struct gsm_mncc_number *connected,
-                        const u_int8_t *lv)
-{
-       return decode_callerid(calling, lv);
-}
-
-/* encode 'connected number' */
-int encode_connected(struct msgb *msg, 
-                           const struct gsm_mncc_number *connected)
-{
-       return encode_callerid(msg, GSM48_IE_CONN_BCD, 14, connected);
-}
-
-/* decode 'redirecting number' */
-int decode_redirecting(struct gsm_mncc_number *redirecting,
-                        const u_int8_t *lv)
-{
-       return decode_callerid(calling, lv);
-}
-
-/* encode 'redirecting number' */
-int encode_redirecting(struct msgb *msg,
-                             const struct gsm_mncc_number *redirecting)
-{
-       return encode_callerid(msg, GSM48_IE_REDIR_BCD, 19, redirecting);
-}
-
-/* decode 'facility' */
-int decode_facility(struct gsm_mncc_facility *facility,
-                          const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-
-       if (in_len < 1)
-               return -EINVAL;
-
-       if (in_len > sizeof(facility->info))
-               return -EINVAL;
-
-       memcpy(facility->info, lv+1, in_len);
-       facility->len = in_len;
-
-       return 0;
-}
-
-/* encode 'facility' */
-int encode_facility(struct msgb *msg, int lv_only,
-                          const struct gsm_mncc_facility *facility)
-{
-       u_int8_t lv[GSM_MAX_FACILITY + 1];
-
-       if (facility->len < 1 || facility->len > GSM_MAX_FACILITY)
-               return -EINVAL;
-
-       memcpy(lv+1, facility->info, facility->len);
-       lv[0] = facility->len;
-       if (lv_only)
-               msgb_lv_put(msg, lv[0], lv+1);
-       else
-               msgb_tlv_put(msg, GSM48_IE_FACILITY, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode 'notify' */
-int decode_notify(int *notify, const u_int8_t *v)
-{
-       *notify = v[0] & 0x7f;
-       
-       return 0;
-}
-
-/* encode 'notify' */
-int encode_notify(struct msgb *msg, int notify)
-{
-       msgb_v_put(msg, notify | 0x80);
-
-       return 0;
-}
-
-/* decode 'signal' */
-int decode_signal(int *signal, const u_int8_t *v)
-{
-       *signal = v[0];
-}
-
-/* encode 'signal' */
-int encode_signal(struct msgb *msg, int signal)
-{
-       msgb_tv_put(msg, GSM48_IE_SIGNAL, signal);
-
-       return 0;
-}
-
-/* decode 'keypad' */
-int decode_keypad(int *keypad, const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-
-       if (in_len < 1)
-               return -EINVAL;
-
-       *keypad = lv[1] & 0x7f;
-       
-       return 0;
-}
-
-/* encode 'keypad' */
-int encode_keypad(struct msgb *msg, int keypad)
-{
-       msgb_tv_put(msg, GSM48_IE_KEYPAD, keypad);
-
-       return 0;
-}
-
-/* decode 'progress' */
-int decode_progress(struct gsm_mncc_progress *progress,
-                          const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-
-       if (in_len < 2)
-               return -EINVAL;
-
-       progress->coding = (lv[1] & 0x60) >> 5;
-       progress->location = lv[1] & 0x0f;
-       progress->descr = lv[2] & 0x7f;
-       
-       return 0;
-}
-
-/* encode 'progress' */
-int encode_progress(struct msgb *msg, int lv_only,
-                          const struct gsm_mncc_progress *p)
-{
-       u_int8_t lv[3];
-
-       lv[0] = 2;
-       lv[1] = 0x80 | ((p->coding & 0x3) << 5) | (p->location & 0xf);
-       lv[2] = 0x80 | (p->descr & 0x7f);
-       if (lv_only)
-               msgb_lv_put(msg, lv[0], lv+1);
-       else
-               msgb_tlv_put(msg, GSM48_IE_PROGR_IND, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode 'user-user' */
-int decode_useruser(struct gsm_mncc_useruser *uu,
-                          const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-       char *info = uu->info;
-       int info_len = sizeof(uu->info);
-       int i;
-
-       if (in_len < 1)
-               return -EINVAL;
-
-       uu->proto = lv[1];
-
-       for (i = 2; i <= in_len; i++) {
-               info_len--;
-               if (info_len <= 1)
-                       break;
-               *info++ = lv[i];
-       }
-       if (info_len >= 1)
-               *info++ = '\0';
-       
-       return 0;
-}
-
-/* encode 'useruser' */
-int encode_useruser(struct msgb *msg, int lv_only,
-                          const struct gsm_mncc_useruser *uu)
-{
-       u_int8_t lv[GSM_MAX_USERUSER + 2];
-
-       if (strlen(uu->info) > GSM_MAX_USERUSER)
-               return -EINVAL;
-
-       lv[0] = 1 + strlen(uu->info);
-       lv[1] = uu->proto;
-       memcpy(lv + 2, uu->info, strlen(uu->info));
-       if (lv_only)
-               msgb_lv_put(msg, lv[0], lv+1);
-       else
-               msgb_tlv_put(msg, GSM48_IE_USER_USER, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode 'ss version' */
-int decode_ssversion(struct gsm_mncc_ssversion *ssv,
-                           const u_int8_t *lv)
-{
-       u_int8_t in_len = lv[0];
-
-       if (in_len < 1 || in_len < sizeof(ssv->info))
-               return -EINVAL;
-
-       memcpy(ssv->info, lv + 1, in_len);
-       ssv->len = in_len;
-
-       return 0;
-}
-
-/* encode 'ss version' */
-int encode_ssversion(struct msgb *msg,
-                          const struct gsm_mncc_ssversion *ssv)
-{
-       u_int8_t lv[GSM_MAX_SSVERSION + 1];
-
-       if (ssv->len > GSM_MAX_SSVERSION)
-               return -EINVAL;
-
-       lv[0] = ssv->len;
-       memcpy(lv + 1, ssv->info, ssv->ssversion.len);
-       msgb_tlv_put(msg, GSM48_IE_SSVERSION, lv[0], lv+1);
-
-       return 0;
-}
-
-/* decode 'more data' does not require a function, because it has no value */
-
-/* encode 'more data' */
-int encode_more(struct msgb *msg)
-{
-       u_int8_t *ie;
-
-       ie = msgb_put(msg, 1);
-       ie[0] = GSM48_IE_MORE_DATA;
-
-       return 0;
-}
-
index a1dd435..2c529c3 100644 (file)
@@ -29,6 +29,10 @@ todo rr_sync_ind
 
 todo change procedures, release procedure
 
+#include <osmocore/protocol/gsm_04_08.h>
+#include <osmocore/msgb.h>
+#include <osmocore/gsm48.h>
+
 static int gsm_rr_chan2cause[4] = {
        RR_EST_CAUSE_ANS_PAG_ANY,
        RR_EST_CAUSE_ANS_PAG_SDCCH,