blob: b4847722561a3276c7bf0d605fdfa0b8fe49a2ff [file] [log] [blame]
Harald Welte3e6376d2010-12-22 23:54:51 +01001/* mncc.c - utility routines for the MNCC API between the 04.08
2 * message parsing and the actual Call Control logic */
Harald Welte7ce5e252010-12-22 02:02:48 +01003
Harald Welte4bfdfe72009-06-10 23:11:52 +08004/* (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 Welte9af6ddf2011-01-01 15:25:50 +01009 * 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 Welte4bfdfe72009-06-10 23:11:52 +080011 * (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 Welte9af6ddf2011-01-01 15:25:50 +010016 * GNU Affero General Public License for more details.
Harald Welte4bfdfe72009-06-10 23:11:52 +080017 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010018 * 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 Welte4bfdfe72009-06-10 23:11:52 +080020 *
21 */
22
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
Harald Welte09b7e7f2009-12-12 21:36:53 +010027#include <errno.h>
Harald Welte4bfdfe72009-06-10 23:11:52 +080028
29#include <openbsc/gsm_04_08.h>
30#include <openbsc/debug.h>
31#include <openbsc/mncc.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010032#include <osmocom/core/talloc.h>
Harald Welte2cf161b2009-06-20 22:36:41 +020033#include <openbsc/gsm_data.h>
Harald Welteedbc0f72009-12-20 14:22:11 +010034#include <openbsc/transaction.h>
35#include <openbsc/rtp_proxy.h>
Harald Welte2cf161b2009-06-20 22:36:41 +020036
Harald Welte4bfdfe72009-06-10 23:11:52 +080037static 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
Harald Welteaca8f152009-12-19 23:06:41 +010087 {"GSM_TCH_FRAME", 0x0300},
Harald Welte4bfdfe72009-06-10 23:11:52 +080088
Harald Welteb1d4c8e2009-12-17 23:10:46 +010089 {NULL, 0} };
Harald Welte4bfdfe72009-06-10 23:11:52 +080090
Harald Welte4bfdfe72009-06-10 23:11:52 +080091char *get_mncc_name(int value)
92{
93 int i;
94
95 for (i = 0; mncc_names[i].name; i++) {
96 if (mncc_names[i].value == value)
97 return mncc_names[i].name;
98 }
99
100 return "MNCC_Unknown";
101}
102
Harald Welte4bfdfe72009-06-10 23:11:52 +0800103void mncc_set_cause(struct gsm_mncc *data, int loc, int val)
104{
105 data->fields |= MNCC_F_CAUSE;
106 data->cause.location = loc;
107 data->cause.value = val;
108}
Harald Weltefea236e2010-12-23 00:13:47 +0100109