From 13df9c8a721237bcffe40ff1cfb880910cb37688 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 24 Jul 2011 02:52:20 +0200 Subject: sysmobts: add a skeleton for codec frame processing --- src/osmo-bts-sysmo/tch.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/osmo-bts-sysmo/tch.c (limited to 'src/osmo-bts-sysmo/tch.c') diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c new file mode 100644 index 00000000..87de8437 --- /dev/null +++ b/src/osmo-bts-sysmo/tch.c @@ -0,0 +1,95 @@ +/* Traffic channel support for Sysmocom BTS L1 */ + +/* (C) 2011 by Harald Welte + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "femtobts.h" +#include "l1_if.h" + +int l1if_tch_rx(struct gsm_lchan *lchan, + struct msgb *l1p_msg) +{ + GsmL1_Prim_t *l1p = msgb_l1prim(l1p_msg); + GsmL1_PhDataInd_t *data_ind = &l1p->u.phDataInd; + uint8_t payload_type = data_ind->msgUnitParam.u8Buffer[0]; + uint8_t *payload = data_ind->msgUnitParam.u8Buffer + 1; + uint8_t payload_len; + + if (data_ind->msgUnitParam.u8Size < 1) { + LOGP(DL1C, LOGL_ERROR, "%s Rx Payload size 0\n", + gsm_lchan_name(lchan)); + return -EINVAL; + } + payload_len = data_ind->msgUnitParam.u8Size - 1; + + switch (payload_type) { + case GsmL1_TchPlType_Fr: + if (lchan->type != GSM_LCHAN_TCH_F) + goto err_payload_match; + break; + case GsmL1_TchPlType_Hr: + if (lchan->type != GSM_LCHAN_TCH_H) + goto err_payload_match; + break; + case GsmL1_TchPlType_Amr: + if (lchan->type != GSM_LCHAN_TCH_H && + lchan->type != GSM_LCHAN_TCH_F) + goto err_payload_match; + default: + LOGP(DL1C, LOGL_NOTICE, "%s Rx Payload Type %s is unsupported\n", + gsm_lchan_name(lchan), + get_value_string(femtobts_tch_pl_names, payload_type)); + break; + } + + LOGP(DL1C, LOGL_DEBUG, "%s Rx codec frame (%u): %s\n", gsm_lchan_name(lchan), + payload_len, osmo_hexdump(payload, payload_len)); + + return 0; + +err_payload_match: + LOGP(DL1C, LOGL_ERROR, "%s Rx Payload Type %s incompatible with lchan\n", + gsm_lchan_name(lchan), + get_value_string(femtobts_tch_pl_names, payload_type)); + return -EINVAL; +} -- cgit v1.2.3