blob: 34093a8b1c791fdb671bf6075a044a8a3b9b1c2e [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#include <sys/types.h>
29
30#include <openbsc/gsm_04_08.h>
31#include <openbsc/debug.h>
32#include <openbsc/mncc.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010033#include <osmocore/talloc.h>
Harald Welte2cf161b2009-06-20 22:36:41 +020034#include <openbsc/gsm_data.h>
Harald Welteedbc0f72009-12-20 14:22:11 +010035#include <openbsc/transaction.h>
36#include <openbsc/rtp_proxy.h>
Harald Welte2cf161b2009-06-20 22:36:41 +020037
Harald Welte4bfdfe72009-06-10 23:11:52 +080038static 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 Welteaca8f152009-12-19 23:06:41 +010088 {"GSM_TCH_FRAME", 0x0300},
Harald Welte4bfdfe72009-06-10 23:11:52 +080089
Harald Welteb1d4c8e2009-12-17 23:10:46 +010090 {NULL, 0} };
Harald Welte4bfdfe72009-06-10 23:11:52 +080091
Harald Welte4bfdfe72009-06-10 23:11:52 +080092char *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 Welte4bfdfe72009-06-10 23:11:52 +0800104void 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}
Harald Weltefea236e2010-12-23 00:13:47 +0100110
111void cc_tx_to_mncc(struct gsm_network *net, struct msgb *msg)
112{
Harald Welte29b64e92010-12-23 01:07:46 +0100113 net->mncc_recv(net, msg);
Harald Weltefea236e2010-12-23 00:13:47 +0100114}