blob: 08863bfea638303fe4cbd0df9bfa67e91e196282 [file] [log] [blame]
Harald Welte1fa60c82009-02-09 18:13:26 +00001/* Simple TRAU frame reflector to route voice calls */
2
3/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01007 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
Harald Welte1fa60c82009-02-09 18:13:26 +00009 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010014 * GNU Affero General Public License for more details.
Harald Welte1fa60c82009-02-09 18:13:26 +000015 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010016 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte1fa60c82009-02-09 18:13:26 +000018 *
19 */
20
21/* The "TRAU mux map" defines which particular 16kbit sub-slot (in which E1
22 * timeslot on which E1 interface) should be directly muxed to which other
23 * sub-slot. Entries in the mux map are always bi-directional.
24 *
25 * The idea of all this is to directly switch voice channels in the BSC
26 * from one phone to another. We do this right now since we don't support
27 * any external interface for voice channels, and in the future as an
28 * optimization to routing them externally.
29 */
30
Harald Weltef142c972011-05-24 13:25:38 +020031#include <stdint.h>
Neels Hofmeyr90843962017-09-04 15:04:35 +020032#include <osmocom/msc/gsm_data.h>
33#include <osmocom/msc/mncc.h>
Harald Weltef142c972011-05-24 13:25:38 +020034
Holger Hans Peter Freyther6ab5d4f2014-02-20 11:18:00 +010035struct decoded_trau_frame;
36
Harald Welte1fa60c82009-02-09 18:13:26 +000037/* map a TRAU mux map entry */
38int trau_mux_map(const struct gsm_e1_subslot *src,
39 const struct gsm_e1_subslot *dst);
Harald Welte26aa6a12009-02-19 15:14:23 +000040int trau_mux_map_lchan(const struct gsm_lchan *src,
41 const struct gsm_lchan *dst);
Harald Welte1fa60c82009-02-09 18:13:26 +000042
43/* unmap a TRAU mux map entry */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020044int trau_mux_unmap(const struct gsm_e1_subslot *ss, uint32_t callref);
Harald Welte1fa60c82009-02-09 18:13:26 +000045
46/* we get called by subchan_demux */
47int trau_mux_input(struct gsm_e1_subslot *src_e1_ss,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020048 const uint8_t *trau_bits, int num_bits);
Harald Welte45b407a2009-05-23 15:51:12 +000049
50/* add a trau receiver */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020051int trau_recv_lchan(struct gsm_lchan *lchan, uint32_t callref);
Harald Welte45b407a2009-05-23 15:51:12 +000052
53/* send trau from application */
Harald Welteda7ab742009-12-19 22:23:05 +010054int trau_send_frame(struct gsm_lchan *lchan, struct gsm_data_frame *frame);
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +020055
Andreas Eversbergdcf38e12013-12-05 14:37:11 +010056/* switch trau muxer to new lchan */
57int switch_trau_mux(struct gsm_lchan *old_lchan, struct gsm_lchan *new_lchan);
58
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +020059/* callback invoked if we receive TRAU frames */
60int subch_cb(struct subch_demux *dmx, int ch, uint8_t *data, int len, void *_priv);
Andreas Eversbergd074f8f2013-12-06 16:59:10 +010061
62/* TRAU frame transcoding */
63struct msgb *trau_decode_fr(uint32_t callref,
64 const struct decoded_trau_frame *tf);
65struct msgb *trau_decode_efr(uint32_t callref,
66 const struct decoded_trau_frame *tf);
67void trau_encode_fr(struct decoded_trau_frame *tf,
68 const unsigned char *data);
69void trau_encode_efr(struct decoded_trau_frame *tf,
70 const unsigned char *data);