diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-07-24 02:52:20 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-07-24 02:52:20 +0200 |
commit | 13df9c8a721237bcffe40ff1cfb880910cb37688 (patch) | |
tree | 9842a086ac9458a68e8e3c1fa02ce6f2f0f08a34 /src/osmo-bts-sysmo/tch.c | |
parent | 97d4c44db20fbcd4070bf058f0a537a3170ccbe7 (diff) |
sysmobts: add a skeleton for codec frame processing
Diffstat (limited to 'src/osmo-bts-sysmo/tch.c')
-rw-r--r-- | src/osmo-bts-sysmo/tch.c | 95 |
1 files changed, 95 insertions, 0 deletions
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 <laforge@gnumonks.org> + * + * 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 <http://www.gnu.org/licenses/>. + * + */ + +#include <stdint.h> +#include <unistd.h> +#include <errno.h> +#include <fcntl.h> + +#include <sys/types.h> +#include <sys/stat.h> + +#include <osmocom/core/talloc.h> +#include <osmocom/core/utils.h> +#include <osmocom/core/select.h> +#include <osmocom/core/timer.h> +#include <osmocom/gsm/gsm_utils.h> + +#include <osmo-bts/logging.h> +#include <osmo-bts/bts.h> +#include <osmo-bts/gsm_data.h> +#include <osmo-bts/measurement.h> + +#include <sysmocom/femtobts/femtobts.h> +#include <sysmocom/femtobts/gsml1prim.h> +#include <sysmocom/femtobts/gsml1const.h> +#include <sysmocom/femtobts/gsml1types.h> + +#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; +} |