Merge branch 'jolly/mncc'

Merge the interface changes to the MNCC protocol
This commit is contained in:
Holger Hans Peter Freyther 2014-03-20 22:36:27 +01:00
commit 870cc0fdac
8 changed files with 46 additions and 23 deletions

View File

@ -95,7 +95,9 @@ struct gsm_call {
#define GSM_TCHF_FRAME 0x0300
#define GSM_TCHF_FRAME_EFR 0x0301
#define GSM_TCHF_BAD_FRAME 0x03ff
#define GSM_TCHH_FRAME 0x0302
#define GSM_TCH_FRAME_AMR 0x0303
#define GSM_BAD_FRAME 0x03ff
#define MNCC_SOCKET_HELLO 0x0400
@ -161,7 +163,7 @@ struct gsm_data_frame {
unsigned char data[0];
};
#define MNCC_SOCK_VERSION 2
#define MNCC_SOCK_VERSION 4
struct gsm_mncc_hello {
uint32_t msg_type;
uint32_t version;
@ -189,4 +191,12 @@ int mncc_sock_from_cc(struct gsm_network *net, struct msgb *msg);
int mncc_sock_init(struct gsm_network *gsmnet);
#define mncc_is_data_frame(msg_type) \
(msg_type == GSM_TCHF_FRAME \
|| msg_type == GSM_TCHF_FRAME_EFR \
|| msg_type == GSM_TCHH_FRAME \
|| msg_type == GSM_TCH_FRAME_AMR \
|| msg_type == GSM_BAD_FRAME)
#endif

View File

@ -2952,6 +2952,7 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
return tch_recv_mncc(net, data->callref, 1);
case GSM_TCHF_FRAME:
case GSM_TCHF_FRAME_EFR:
case GSM_TCHH_FRAME:
/* Find callref */
trans = trans_find_by_callref(net, data->callref);
if (!trans) {
@ -2963,11 +2964,12 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n");
return 0;
}
if (trans->conn->lchan->type != GSM_LCHAN_TCH_F) {
if (trans->conn->lchan->type != GSM_LCHAN_TCH_F
&& trans->conn->lchan->type != GSM_LCHAN_TCH_H) {
/* This should be LOGL_ERROR or NOTICE, but
* unfortuantely it happens for a couple of frames at
* the beginning of every RTP connection */
LOGP(DMNCC, LOGL_DEBUG, "TCH frame for lchan != TCH_F\n");
LOGP(DMNCC, LOGL_DEBUG, "TCH frame for lchan != TCH_F/TCH_H\n");
return 0;
}
bts = trans->conn->lchan->ts->trx->bts;

View File

@ -84,7 +84,11 @@ static struct mncc_names {
{"MNCC_FRAME_DROP", 0x0202},
{"MNCC_LCHAN_MODIFY", 0x0203},
{"GSM_TCH_FRAME", 0x0300},
{"GSM_TCHF_FRAME", 0x0300},
{"GSM_TCHF_FRAME_EFR", 0x0301},
{"GSM_TCHH_FRAME", 0x0302},
{"GSM_TCH_FRAME_AMR", 0x0303},
{"GSM_BAD_FRAME", 0x03ff},
{NULL, 0} };

View File

@ -273,8 +273,8 @@ static int mncc_rel_cnf(struct gsm_call *call, int msg_type, struct gsm_mncc *re
return 0;
}
/* receiving a TCH/F frame from the BSC code */
static int mncc_rcv_tchf(struct gsm_call *call, int msg_type,
/* receiving a (speech) traffic frame from the BSC code */
static int mncc_rcv_data(struct gsm_call *call, int msg_type,
struct gsm_data_frame *dfr)
{
struct gsm_trans *remote_trans;
@ -339,16 +339,14 @@ int int_mncc_recv(struct gsm_network *net, struct msgb *msg)
DEBUGP(DMNCC, "(call %x) Call created.\n", call->callref);
}
switch (msg_type) {
case GSM_TCHF_FRAME:
case GSM_TCHF_FRAME_EFR:
break;
default:
DEBUGP(DMNCC, "(call %x) Received message %s\n", call->callref,
get_mncc_name(msg_type));
break;
if (mncc_is_data_frame(msg_type)) {
rc = mncc_rcv_data(call, msg_type, arg);
goto out_free;
}
DEBUGP(DMNCC, "(call %x) Received message %s\n", call->callref,
get_mncc_name(msg_type));
switch(msg_type) {
case MNCC_SETUP_IND:
rc = mncc_setup_ind(call, msg_type, arg);
@ -408,10 +406,6 @@ int int_mncc_recv(struct gsm_network *net, struct msgb *msg)
call->callref, data->cause.value);
rc = mncc_tx_to_cc(net, MNCC_RETRIEVE_REJ, data);
break;
case GSM_TCHF_FRAME:
case GSM_TCHF_FRAME_EFR:
rc = mncc_rcv_tchf(call, msg_type, arg);
break;
default:
LOGP(DMNCC, LOGL_NOTICE, "(call %x) Message unhandled\n", callref);
break;

View File

@ -54,8 +54,7 @@ int mncc_sock_from_cc(struct gsm_network *net, struct msgb *msg)
if (net->mncc_state->conn_bfd.fd < 0) {
LOGP(DMNCC, LOGL_ERROR, "mncc_sock receives %s for external CC app "
"but socket is gone\n", get_mncc_name(msg_type));
if (msg_type != GSM_TCHF_FRAME &&
msg_type != GSM_TCHF_FRAME_EFR) {
if (!mncc_is_data_frame(msg_type)) {
/* release the request */
struct gsm_mncc mncc_out;
memset(&mncc_out, 0, sizeof(mncc_out));

View File

@ -183,6 +183,15 @@ static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data)
return -EINVAL;
}
break;
case RTP_PT_GSM_HALF:
msg_type = GSM_TCHH_FRAME;
if (payload_len != RTP_LEN_GSM_HALF) {
DEBUGPC(DLMUX, "received RTP half rate frame with "
"payload length != %d (len = %d)\n",
RTP_LEN_GSM_HALF, payload_len);
return -EINVAL;
}
break;
default:
DEBUGPC(DLMUX, "received RTP frame with unknown payload "
"type %d\n", rtph->payload_type);
@ -250,6 +259,11 @@ int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame)
payload_len = RTP_LEN_GSM_EFR;
duration = RTP_GSM_DURATION;
break;
case GSM_TCHH_FRAME:
payload_type = RTP_PT_GSM_HALF;
payload_len = RTP_LEN_GSM_HALF;
duration = RTP_GSM_DURATION;
break;
default:
DEBUGPC(DLMUX, "unsupported message type %d\n",
frame->msg_type);

View File

@ -314,7 +314,7 @@ struct msgb *trau_decode_efr(uint32_t callref,
return msg;
bad_frame:
frame->msg_type = GSM_TCHF_BAD_FRAME;
frame->msg_type = GSM_BAD_FRAME;
return msg;
}

View File

@ -57,7 +57,7 @@ void test_trau_fr_efr(unsigned char *data)
msg = trau_decode_efr(1, &tf);
OSMO_ASSERT(msg != NULL);
frame = (struct gsm_data_frame *)msg->data;
OSMO_ASSERT(frame->msg_type == GSM_TCHF_BAD_FRAME);
OSMO_ASSERT(frame->msg_type == GSM_BAD_FRAME);
msgb_free(msg);
}