Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 1 | /* 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 Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 7 | * 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 Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 9 | * (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 Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 14 | * GNU Affero General Public License for more details. |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 15 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * 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 Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 18 | * |
| 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 Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 31 | #include <stdint.h> |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 32 | #include <osmocom/msc/gsm_data.h> |
| 33 | #include <osmocom/msc/mncc.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 34 | |
Holger Hans Peter Freyther | 6ab5d4f | 2014-02-20 11:18:00 +0100 | [diff] [blame] | 35 | struct decoded_trau_frame; |
| 36 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 37 | /* map a TRAU mux map entry */ |
| 38 | int trau_mux_map(const struct gsm_e1_subslot *src, |
| 39 | const struct gsm_e1_subslot *dst); |
Harald Welte | 26aa6a1 | 2009-02-19 15:14:23 +0000 | [diff] [blame] | 40 | int trau_mux_map_lchan(const struct gsm_lchan *src, |
| 41 | const struct gsm_lchan *dst); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 42 | |
| 43 | /* unmap a TRAU mux map entry */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 44 | int trau_mux_unmap(const struct gsm_e1_subslot *ss, uint32_t callref); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 45 | |
| 46 | /* we get called by subchan_demux */ |
| 47 | int trau_mux_input(struct gsm_e1_subslot *src_e1_ss, |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 48 | const uint8_t *trau_bits, int num_bits); |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 49 | |
| 50 | /* add a trau receiver */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 51 | int trau_recv_lchan(struct gsm_lchan *lchan, uint32_t callref); |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 52 | |
| 53 | /* send trau from application */ |
Harald Welte | da7ab74 | 2009-12-19 22:23:05 +0100 | [diff] [blame] | 54 | int trau_send_frame(struct gsm_lchan *lchan, struct gsm_data_frame *frame); |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 55 | |
Andreas Eversberg | dcf38e1 | 2013-12-05 14:37:11 +0100 | [diff] [blame] | 56 | /* switch trau muxer to new lchan */ |
| 57 | int switch_trau_mux(struct gsm_lchan *old_lchan, struct gsm_lchan *new_lchan); |
| 58 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 59 | /* callback invoked if we receive TRAU frames */ |
| 60 | int subch_cb(struct subch_demux *dmx, int ch, uint8_t *data, int len, void *_priv); |
Andreas Eversberg | d074f8f | 2013-12-06 16:59:10 +0100 | [diff] [blame] | 61 | |
| 62 | /* TRAU frame transcoding */ |
| 63 | struct msgb *trau_decode_fr(uint32_t callref, |
| 64 | const struct decoded_trau_frame *tf); |
| 65 | struct msgb *trau_decode_efr(uint32_t callref, |
| 66 | const struct decoded_trau_frame *tf); |
| 67 | void trau_encode_fr(struct decoded_trau_frame *tf, |
| 68 | const unsigned char *data); |
| 69 | void trau_encode_efr(struct decoded_trau_frame *tf, |
| 70 | const unsigned char *data); |