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 | #include <sys/types.h> |
| 29 | |
| 30 | #include <openbsc/gsm_04_08.h> |
| 31 | #include <openbsc/debug.h> |
| 32 | #include <openbsc/mncc.h> |
Harald Welte | f4625b1 | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 33 | #include <osmocore/talloc.h> |
Harald Welte | a837977 | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 34 | #include <openbsc/gsm_data.h> |
Harald Welte | 1c5ae95 | 2009-12-20 14:22:11 +0100 | [diff] [blame] | 35 | #include <openbsc/transaction.h> |
| 36 | #include <openbsc/rtp_proxy.h> |
Harald Welte | a837977 | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 37 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 38 | static struct mncc_names { |
| 39 | char *name; |
| 40 | int value; |
| 41 | } mncc_names[] = { |
| 42 | {"MNCC_SETUP_REQ", 0x0101}, |
| 43 | {"MNCC_SETUP_IND", 0x0102}, |
| 44 | {"MNCC_SETUP_RSP", 0x0103}, |
| 45 | {"MNCC_SETUP_CNF", 0x0104}, |
| 46 | {"MNCC_SETUP_COMPL_REQ",0x0105}, |
| 47 | {"MNCC_SETUP_COMPL_IND",0x0106}, |
| 48 | {"MNCC_CALL_CONF_IND", 0x0107}, |
| 49 | {"MNCC_CALL_PROC_REQ", 0x0108}, |
| 50 | {"MNCC_PROGRESS_REQ", 0x0109}, |
| 51 | {"MNCC_ALERT_REQ", 0x010a}, |
| 52 | {"MNCC_ALERT_IND", 0x010b}, |
| 53 | {"MNCC_NOTIFY_REQ", 0x010c}, |
| 54 | {"MNCC_NOTIFY_IND", 0x010d}, |
| 55 | {"MNCC_DISC_REQ", 0x010e}, |
| 56 | {"MNCC_DISC_IND", 0x010f}, |
| 57 | {"MNCC_REL_REQ", 0x0110}, |
| 58 | {"MNCC_REL_IND", 0x0111}, |
| 59 | {"MNCC_REL_CNF", 0x0112}, |
| 60 | {"MNCC_FACILITY_REQ", 0x0113}, |
| 61 | {"MNCC_FACILITY_IND", 0x0114}, |
| 62 | {"MNCC_START_DTMF_IND", 0x0115}, |
| 63 | {"MNCC_START_DTMF_RSP", 0x0116}, |
| 64 | {"MNCC_START_DTMF_REJ", 0x0117}, |
| 65 | {"MNCC_STOP_DTMF_IND", 0x0118}, |
| 66 | {"MNCC_STOP_DTMF_RSP", 0x0119}, |
| 67 | {"MNCC_MODIFY_REQ", 0x011a}, |
| 68 | {"MNCC_MODIFY_IND", 0x011b}, |
| 69 | {"MNCC_MODIFY_RSP", 0x011c}, |
| 70 | {"MNCC_MODIFY_CNF", 0x011d}, |
| 71 | {"MNCC_MODIFY_REJ", 0x011e}, |
| 72 | {"MNCC_HOLD_IND", 0x011f}, |
| 73 | {"MNCC_HOLD_CNF", 0x0120}, |
| 74 | {"MNCC_HOLD_REJ", 0x0121}, |
| 75 | {"MNCC_RETRIEVE_IND", 0x0122}, |
| 76 | {"MNCC_RETRIEVE_CNF", 0x0123}, |
| 77 | {"MNCC_RETRIEVE_REJ", 0x0124}, |
| 78 | {"MNCC_USERINFO_REQ", 0x0125}, |
| 79 | {"MNCC_USERINFO_IND", 0x0126}, |
| 80 | {"MNCC_REJ_REQ", 0x0127}, |
| 81 | {"MNCC_REJ_IND", 0x0128}, |
| 82 | |
| 83 | {"MNCC_BRIDGE", 0x0200}, |
| 84 | {"MNCC_FRAME_RECV", 0x0201}, |
| 85 | {"MNCC_FRAME_DROP", 0x0202}, |
| 86 | {"MNCC_LCHAN_MODIFY", 0x0203}, |
| 87 | |
Harald Welte | d3d68ad | 2009-12-19 23:06:41 +0100 | [diff] [blame] | 88 | {"GSM_TCH_FRAME", 0x0300}, |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 89 | |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 90 | {NULL, 0} }; |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 91 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 92 | char *get_mncc_name(int value) |
| 93 | { |
| 94 | int i; |
| 95 | |
| 96 | for (i = 0; mncc_names[i].name; i++) { |
| 97 | if (mncc_names[i].value == value) |
| 98 | return mncc_names[i].name; |
| 99 | } |
| 100 | |
| 101 | return "MNCC_Unknown"; |
| 102 | } |
| 103 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 104 | void mncc_set_cause(struct gsm_mncc *data, int loc, int val) |
| 105 | { |
| 106 | data->fields |= MNCC_F_CAUSE; |
| 107 | data->cause.location = loc; |
| 108 | data->cause.value = val; |
| 109 | } |