Harald Welte | 5f77b7f | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 1 | /* mncc.c - utility routines for the MNCC API between the 04.08 |
| 2 | * message parsing and the actual Call Control logic */ |
Harald Welte | 08dd27d | 2010-12-22 02:02:48 +0100 | [diff] [blame] | 3 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 4 | /* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2009 by Andreas Eversberg <Andreas.Eversberg@versatel.de> |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * GNU Affero General Public License for more details. |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 17 | * |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
Harald Welte | 3d1f9b6 | 2009-12-12 21:36:53 +0100 | [diff] [blame] | 27 | #include <errno.h> |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 28 | |
| 29 | #include <openbsc/gsm_04_08.h> |
| 30 | #include <openbsc/debug.h> |
| 31 | #include <openbsc/mncc.h> |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 32 | #include <osmocom/core/talloc.h> |
Harald Welte | a837977 | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 33 | #include <openbsc/gsm_data.h> |
Harald Welte | 1c5ae95 | 2009-12-20 14:22:11 +0100 | [diff] [blame] | 34 | #include <openbsc/transaction.h> |
| 35 | #include <openbsc/rtp_proxy.h> |
Harald Welte | a837977 | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 36 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 37 | static struct mncc_names { |
| 38 | char *name; |
| 39 | int value; |
| 40 | } mncc_names[] = { |
| 41 | {"MNCC_SETUP_REQ", 0x0101}, |
| 42 | {"MNCC_SETUP_IND", 0x0102}, |
| 43 | {"MNCC_SETUP_RSP", 0x0103}, |
| 44 | {"MNCC_SETUP_CNF", 0x0104}, |
| 45 | {"MNCC_SETUP_COMPL_REQ",0x0105}, |
| 46 | {"MNCC_SETUP_COMPL_IND",0x0106}, |
| 47 | {"MNCC_CALL_CONF_IND", 0x0107}, |
| 48 | {"MNCC_CALL_PROC_REQ", 0x0108}, |
| 49 | {"MNCC_PROGRESS_REQ", 0x0109}, |
| 50 | {"MNCC_ALERT_REQ", 0x010a}, |
| 51 | {"MNCC_ALERT_IND", 0x010b}, |
| 52 | {"MNCC_NOTIFY_REQ", 0x010c}, |
| 53 | {"MNCC_NOTIFY_IND", 0x010d}, |
| 54 | {"MNCC_DISC_REQ", 0x010e}, |
| 55 | {"MNCC_DISC_IND", 0x010f}, |
| 56 | {"MNCC_REL_REQ", 0x0110}, |
| 57 | {"MNCC_REL_IND", 0x0111}, |
| 58 | {"MNCC_REL_CNF", 0x0112}, |
| 59 | {"MNCC_FACILITY_REQ", 0x0113}, |
| 60 | {"MNCC_FACILITY_IND", 0x0114}, |
| 61 | {"MNCC_START_DTMF_IND", 0x0115}, |
| 62 | {"MNCC_START_DTMF_RSP", 0x0116}, |
| 63 | {"MNCC_START_DTMF_REJ", 0x0117}, |
| 64 | {"MNCC_STOP_DTMF_IND", 0x0118}, |
| 65 | {"MNCC_STOP_DTMF_RSP", 0x0119}, |
| 66 | {"MNCC_MODIFY_REQ", 0x011a}, |
| 67 | {"MNCC_MODIFY_IND", 0x011b}, |
| 68 | {"MNCC_MODIFY_RSP", 0x011c}, |
| 69 | {"MNCC_MODIFY_CNF", 0x011d}, |
| 70 | {"MNCC_MODIFY_REJ", 0x011e}, |
| 71 | {"MNCC_HOLD_IND", 0x011f}, |
| 72 | {"MNCC_HOLD_CNF", 0x0120}, |
| 73 | {"MNCC_HOLD_REJ", 0x0121}, |
| 74 | {"MNCC_RETRIEVE_IND", 0x0122}, |
| 75 | {"MNCC_RETRIEVE_CNF", 0x0123}, |
| 76 | {"MNCC_RETRIEVE_REJ", 0x0124}, |
| 77 | {"MNCC_USERINFO_REQ", 0x0125}, |
| 78 | {"MNCC_USERINFO_IND", 0x0126}, |
| 79 | {"MNCC_REJ_REQ", 0x0127}, |
| 80 | {"MNCC_REJ_IND", 0x0128}, |
| 81 | |
| 82 | {"MNCC_BRIDGE", 0x0200}, |
| 83 | {"MNCC_FRAME_RECV", 0x0201}, |
| 84 | {"MNCC_FRAME_DROP", 0x0202}, |
| 85 | {"MNCC_LCHAN_MODIFY", 0x0203}, |
| 86 | |
Andreas Eversberg | eca4145 | 2014-01-31 09:02:01 +0100 | [diff] [blame] | 87 | {"GSM_TCHF_FRAME", 0x0300}, |
| 88 | {"GSM_TCHF_FRAME_EFR", 0x0301}, |
| 89 | {"GSM_TCHH_FRAME", 0x0302}, |
| 90 | {"GSM_TCH_FRAME_AMR", 0x0303}, |
| 91 | {"GSM_BAD_FRAME", 0x03ff}, |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 92 | |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 93 | {NULL, 0} }; |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 94 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 95 | char *get_mncc_name(int value) |
| 96 | { |
| 97 | int i; |
| 98 | |
| 99 | for (i = 0; mncc_names[i].name; i++) { |
| 100 | if (mncc_names[i].value == value) |
| 101 | return mncc_names[i].name; |
| 102 | } |
| 103 | |
| 104 | return "MNCC_Unknown"; |
| 105 | } |
| 106 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 107 | void mncc_set_cause(struct gsm_mncc *data, int loc, int val) |
| 108 | { |
| 109 | data->fields |= MNCC_F_CAUSE; |
| 110 | data->cause.location = loc; |
| 111 | data->cause.value = val; |
| 112 | } |
Harald Welte | cef3b46 | 2010-12-23 00:13:47 +0100 | [diff] [blame] | 113 | |