blob: 00bbc452015765070b3ffdda20742c15f5d2daee [file] [log] [blame]
Harald Welte2a0a9632011-02-12 12:33:06 +01001/* Ericsson RBS 2xxx GSM O&M (OM2000) messages on the A-bis interface
2 * implemented based on protocol trace analysis, no formal documentation */
3
4/* (C) 2010-2011 by Harald Welte <laforge@gnumonks.org>
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
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
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
16 * GNU Affero General Public License for more details.
17 *
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/>.
20 *
21 */
22
23
24#include <errno.h>
25#include <unistd.h>
26#include <stdio.h>
27#include <stdlib.h>
28#include <time.h>
29#include <stdint.h>
30
31#include <arpa/inet.h>
32
33#include <osmocore/msgb.h>
34#include <osmocore/tlv.h>
35#include <osmocore/talloc.h>
36#include <osmocore/utils.h>
37
38#include <openbsc/gsm_data.h>
39#include <openbsc/debug.h>
40#include <openbsc/abis_nm.h>
Harald Welte4f3644b2011-02-12 13:44:14 +010041#include <openbsc/abis_om2000.h>
Harald Welte2a0a9632011-02-12 12:33:06 +010042#include <openbsc/signal.h>
Harald Weltec5845042011-02-14 15:26:13 +010043#include <openbsc/e1_input.h>
Harald Welte2a0a9632011-02-12 12:33:06 +010044
45#define OM_ALLOC_SIZE 1024
46#define OM_HEADROOM_SIZE 128
47
48/* use following functions from abis_nm.c:
49 * om2k_msgb_alloc()
Harald Welte8f909d52011-02-12 13:09:38 +010050 * abis_om2k_sendmsg()
Harald Welte2a0a9632011-02-12 12:33:06 +010051 */
52
Harald Welte2a0a9632011-02-12 12:33:06 +010053struct abis_om2k_hdr {
54 struct abis_om_hdr om;
55 uint16_t msg_type;
56 struct abis_om2k_mo mo;
57 uint8_t data[0];
58} __attribute__ ((packed));
59
60enum abis_om2k_msgtype {
61 OM2K_MSGT_ABORT_SP_CMD = 0x0000,
62 OM2K_MSGT_ABORT_SP_COMPL = 0x0002,
63 OM2K_MSGT_ALARM_REP_ACK = 0x0004,
64 OM2K_MSGT_ALARM_REP_NACK = 0x0005,
65 OM2K_MSGT_ALARM_REP = 0x0006,
66 OM2K_MSGT_ALARM_STATUS_REQ = 0x0008,
67 OM2K_MSGT_ALARM_STATUS_REQ_ACK = 0x000a,
68 OM2K_MSGT_ALARM_STATUS_REQ_REJ = 0x000b,
69 OM2K_MSGT_ALARM_STATUS_RES_ACK = 0x000c,
70 OM2K_MSGT_ALARM_STATUS_RES_NACK = 0x000d,
71 OM2K_MSGT_ALARM_STATUS_RES = 0x000e,
72 OM2K_MSGT_CAL_TIME_RESP = 0x0010,
73 OM2K_MSGT_CAL_TIME_REJ = 0x0011,
74 OM2K_MSGT_CAL_TIME_REQ = 0x0012,
75
Harald Weltef5dbc3c2011-02-14 15:31:43 +010076 OM2K_MSGT_CON_CONF_REQ = 0x0014,
77 OM2K_MSGT_CON_CONF_REQ_ACK = 0x0016,
78 OM2K_MSGT_CON_CONF_REQ_REJ = 0x0017,
79 OM2K_MSGT_CON_CONF_RES_ACK = 0x0018,
80 OM2K_MSGT_CON_CONF_RES_NACK = 0x0019,
81 OM2K_MSGT_CON_CONF_RES = 0x001a,
82
Harald Welte2a0a9632011-02-12 12:33:06 +010083 OM2K_MSGT_CONNECT_CMD = 0x001c,
84 OM2K_MSGT_CONNECT_COMPL = 0x001e,
85 OM2K_MSGT_CONNECT_REJ = 0x001f,
86
Harald Welte6d5a0392011-02-12 18:48:53 +010087 OM2K_MSGT_DISABLE_REQ = 0x0028,
88 OM2K_MSGT_DISABLE_REQ_ACK = 0x002a,
89 OM2K_MSGT_DISABLE_REQ_REJ = 0x002b,
90 OM2K_MSGT_DISABLE_RES_ACK = 0x002c,
91 OM2K_MSGT_DISABLE_RES_NACK = 0x002d,
92 OM2K_MSGT_DISABLE_RES = 0x002e,
Harald Welte9bf8e9e2011-02-12 14:57:17 +010093 OM2K_MSGT_DISCONNECT_CMD = 0x0030,
94 OM2K_MSGT_DISCONNECT_COMPL = 0x0032,
95 OM2K_MSGT_DISCONNECT_REJ = 0x0033,
Harald Welte6d5a0392011-02-12 18:48:53 +010096 OM2K_MSGT_ENABLE_REQ = 0x0034,
97 OM2K_MSGT_ENABLE_REQ_ACK = 0x0036,
98 OM2K_MSGT_ENABLE_REQ_REJ = 0x0037,
99 OM2K_MSGT_ENABLE_RES_ACK = 0x0038,
100 OM2K_MSGT_ENABLE_RES_NACK = 0x0039,
101 OM2K_MSGT_ENABLE_RES = 0x003a,
Harald Welte9bf8e9e2011-02-12 14:57:17 +0100102
Harald Welte2a0a9632011-02-12 12:33:06 +0100103 OM2K_MSGT_FAULT_REP_ACK = 0x0040,
104 OM2K_MSGT_FAULT_REP_NACK = 0x0041,
105 OM2K_MSGT_FAULT_REP = 0x0042,
106
107 OM2K_MSGT_IS_CONF_REQ = 0x0060,
108 OM2K_MSGT_IS_CONF_REQ_ACK = 0x0062,
109 OM2K_MSGT_IS_CONF_REQ_REJ = 0x0063,
110 OM2K_MSGT_IS_CONF_RES_ACK = 0x0064,
111 OM2K_MSGT_IS_CONF_RES_NACK = 0x0065,
112 OM2K_MSGT_IS_CONF_RES = 0x0066,
113
114 OM2K_MSGT_OP_INFO = 0x0074,
115 OM2K_MSGT_OP_INFO_ACK = 0x0076,
116 OM2K_MSGT_OP_INFO_REJ = 0x0077,
117 OM2K_MSGT_RESET_CMD = 0x0078,
118 OM2K_MSGT_RESET_COMPL = 0x007a,
119 OM2K_MSGT_RESET_REJ = 0x007b,
Harald Welte00585d92011-03-05 14:13:14 +0100120 OM2K_MSGT_RX_CONF_REQ = 0x007c,
121 OM2K_MSGT_RX_CONF_REQ_ACK = 0x007e,
122 OM2K_MSGT_RX_CONF_REQ_REJ = 0x007f,
123 OM2K_MSGT_RX_CONF_RES_ACK = 0x0080,
124 OM2K_MSGT_RX_CONF_RES_NACK = 0x0081,
125 OM2K_MSGT_RX_CONF_RES = 0x0082,
Harald Welte2a0a9632011-02-12 12:33:06 +0100126 OM2K_MSGT_START_REQ = 0x0084,
127 OM2K_MSGT_START_REQ_ACK = 0x0086,
128 OM2K_MSGT_START_REQ_REJ = 0x0087,
129 OM2K_MSGT_START_RES_ACK = 0x0088,
130 OM2K_MSGT_START_RES_NACK = 0x0089,
131 OM2K_MSGT_START_RES = 0x008a,
Harald Welte1d5a2062011-02-12 14:42:59 +0100132 OM2K_MSGT_STATUS_REQ = 0x008c,
133 OM2K_MSGT_STATUS_RESP = 0x008e,
134 OM2K_MSGT_STATUS_REJ = 0x008f,
Harald Welte2a0a9632011-02-12 12:33:06 +0100135
Harald Welte40ad3b32011-02-12 15:07:30 +0100136 OM2K_MSGT_TEST_REQ = 0x0094,
137 OM2K_MSGT_TEST_REQ_ACK = 0x0096,
138 OM2K_MSGT_TEST_REQ_REJ = 0x0097,
139 OM2K_MSGT_TEST_RES_ACK = 0x0098,
140 OM2K_MSGT_TEST_RES_NACK = 0x0099,
141 OM2K_MSGT_TEST_RES = 0x009a,
142
Harald Welte429bed02011-03-05 14:36:47 +0100143 OM2K_MSGT_TF_CONF_REQ = 0x00a0,
144 OM2K_MSGT_TF_CONF_REQ_ACK = 0x00a2,
145 OM2K_MSGT_TF_CONF_REQ_REJ = 0x00a3,
146 OM2K_MSGT_TF_CONF_RES_ACK = 0x00a4,
147 OM2K_MSGT_TF_CONF_RES_NACK = 0x00a5,
148 OM2K_MSGT_TF_CONF_RES = 0x00a6,
Harald Welte00585d92011-03-05 14:13:14 +0100149 OM2K_MSGT_TS_CONF_REQ = 0x00a8,
150 OM2K_MSGT_TS_CONF_REQ_ACK = 0x00aa,
151 OM2K_MSGT_TS_CONF_REQ_REJ = 0x00ab,
152 OM2K_MSGT_TS_CONF_RES_ACK = 0x00ac,
153 OM2K_MSGT_TS_CONF_RES_NACK = 0x00ad,
154 OM2K_MSGT_TS_CONF_RES = 0x00ae,
155 OM2K_MSGT_TX_CONF_REQ = 0x00b0,
156 OM2K_MSGT_TX_CONF_REQ_ACK = 0x00b2,
157 OM2K_MSGT_TX_CONF_REQ_REJ = 0x00b3,
158 OM2K_MSGT_TX_CONF_RES_ACK = 0x00b4,
159 OM2K_MSGT_TX_CONF_RES_NACK = 0x00b5,
160 OM2K_MSGT_TX_CONF_RES = 0x00b6,
161
Harald Welte2a0a9632011-02-12 12:33:06 +0100162 OM2K_MSGT_NEGOT_REQ_ACK = 0x0104,
163 OM2K_MSGT_NEGOT_REQ_NACK = 0x0105,
164 OM2K_MSGT_NEGOT_REQ = 0x0106,
165};
166
167enum abis_om2k_dei {
Harald Welte00585d92011-03-05 14:13:14 +0100168 OM2K_DEI_BCC = 0x06,
Harald Welte884e7e52011-03-05 19:21:26 +0100169 OM2K_DEI_BS_AG_BKS_RES = 0x07,
Harald Welte00585d92011-03-05 14:13:14 +0100170 OM2K_DEI_BSIC = 0x09,
Harald Welte884e7e52011-03-05 19:21:26 +0100171 OM2K_DEI_BA_PA_MFRMS = 0x0a,
172 OM2K_DEI_CBCH_INDICATOR = 0x0b,
173 OM2K_DEI_CCCH_OPTIONS = 0x0c,
Harald Welte2a0a9632011-02-12 12:33:06 +0100174 OM2K_DEI_CAL_TIME = 0x0d,
Harald Welte00585d92011-03-05 14:13:14 +0100175 OM2K_DEI_COMBINATION = 0x0f,
Harald Weltef5dbc3c2011-02-14 15:31:43 +0100176 OM2K_DEI_CON_CONN_LIST = 0x10,
Harald Welte884e7e52011-03-05 19:21:26 +0100177 OM2K_DEI_DRX_DEV_MAX = 0x12,
Harald Welte4a8f22e2011-02-12 20:23:40 +0100178 OM2K_DEI_END_LIST_NR = 0x13,
Harald Welte271e9612011-03-05 20:13:52 +0100179 OM2K_DEI_EXT_COND_MAP_1 = 0x14,
180 OM2K_DEI_EXT_COND_MAP_2 = 0x15,
Harald Welte00585d92011-03-05 14:13:14 +0100181 OM2K_DEI_FILLING_MARKER = 0x1c,
182 OM2K_DEI_FN_OFFSET = 0x1d,
183 OM2K_DEI_FREQ_LIST = 0x1e,
184 OM2K_DEI_FREQ_SPEC_RX = 0x1f,
185 OM2K_DEI_FREQ_SPEC_TX = 0x20,
186 OM2K_DEI_HSN = 0x21,
Harald Welte884e7e52011-03-05 19:21:26 +0100187 OM2K_DEI_ICM_INDICATOR = 0x22,
Harald Welte271e9612011-03-05 20:13:52 +0100188 OM2K_DEI_INT_FAULT_MAP_1A = 0x23,
189 OM2K_DEI_INT_FAULT_MAP_1B = 0x24,
190 OM2K_DEI_INT_FAULT_MAP_2A = 0x25,
191 OM2K_DEI_INT_FAULT_MAP_2A_EXT = 0x26,
Harald Welte4a8f22e2011-02-12 20:23:40 +0100192 OM2K_DEI_IS_CONN_LIST = 0x27,
193 OM2K_DEI_LIST_NR = 0x28,
Harald Welte271e9612011-03-05 20:13:52 +0100194 OM2K_DEI_LOCAL_ACCESS = 0x2a,
Harald Welte00585d92011-03-05 14:13:14 +0100195 OM2K_DEI_MAIO = 0x2b,
Harald Welte271e9612011-03-05 20:13:52 +0100196 OM2K_DEI_MO_STATE = 0x2c,
Harald Welte884e7e52011-03-05 19:21:26 +0100197 OM2K_DEI_NY1 = 0x2d,
Harald Welte2a0a9632011-02-12 12:33:06 +0100198 OM2K_DEI_OP_INFO = 0x2e,
Harald Welte00585d92011-03-05 14:13:14 +0100199 OM2K_DEI_POWER = 0x2f,
Harald Weltee1f8de42011-03-05 17:52:09 +0100200 OM2K_DEI_REASON_CODE = 0x32,
Harald Welte00585d92011-03-05 14:13:14 +0100201 OM2K_DEI_RX_DIVERSITY = 0x33,
Harald Weltee1f8de42011-03-05 17:52:09 +0100202 OM2K_DEI_RESULT_CODE = 0x35,
Harald Welte884e7e52011-03-05 19:21:26 +0100203 OM2K_DEI_T3105 = 0x38,
Harald Welte429bed02011-03-05 14:36:47 +0100204 OM2K_DEI_TF_MODE = 0x3a,
Harald Welte00585d92011-03-05 14:13:14 +0100205 OM2K_DEI_TS_NR = 0x3c,
Harald Welte884e7e52011-03-05 19:21:26 +0100206 OM2K_DEI_TSC = 0x3d,
Harald Welte271e9612011-03-05 20:13:52 +0100207 OM2K_DEI_BTS_VERSION = 0x40,
208 OM2K_DEI_OML_IWD_VERSION = 0x41,
209 OM2K_DEI_RSL_IWD_VERSION = 0x42,
210 OM2K_DEI_OML_FUNC_MAP_1 = 0x43,
211 OM2K_DEI_OML_FUNC_MAP_2 = 0x44,
212 OM2K_DEI_RSL_FUNC_MAP_1 = 0x45,
213 OM2K_DEI_RSL_FUNC_MAP_2 = 0x46,
Harald Welte00585d92011-03-05 14:13:14 +0100214 OM2K_DEI_EXT_RANGE = 0x47,
Harald Welte271e9612011-03-05 20:13:52 +0100215 OM2K_DEI_REQ_IND = 0x48,
216 OM2K_DEI_REPL_UNIT_MAP = 0x50,
Harald Welte884e7e52011-03-05 19:21:26 +0100217 OM2K_DEI_LSC = 0x79,
218 OM2K_DEI_LSC_FILT_TIME = 0x7a,
219 OM2K_DEI_CALL_SUPV_TIME = 0x7b,
Harald Welte271e9612011-03-05 20:13:52 +0100220 OM2K_DEI_HW_INFO_SIG = 0x84,
Harald Welte884e7e52011-03-05 19:21:26 +0100221 OM2K_DEI_TTA = 0x87,
Harald Welte271e9612011-03-05 20:13:52 +0100222 OM2K_DEI_CAPA_SIG = 0x8a,
Harald Welte4f3644b2011-02-12 13:44:14 +0100223 OM2K_DEI_NEGOT_REC1 = 0x90,
224 OM2K_DEI_NEGOT_REC2 = 0x91,
Harald Welte884e7e52011-03-05 19:21:26 +0100225 OM2K_DEI_ENCR_ALG = 0x92,
226 OM2K_DEI_INTERF_REJ_COMB = 0x94,
Harald Welte429bed02011-03-05 14:36:47 +0100227 OM2K_DEI_FS_OFFSET = 0x98,
Harald Welte271e9612011-03-05 20:13:52 +0100228 OM2K_DEI_EXT_COND_MAP_2_EXT = 0x9c,
Harald Welte2a0a9632011-02-12 12:33:06 +0100229};
230
Harald Weltee1f8de42011-03-05 17:52:09 +0100231const struct tlv_definition om2k_att_tlvdef = {
232 .def = {
233 [OM2K_DEI_BCC] = { TLV_TYPE_TV },
Harald Welte884e7e52011-03-05 19:21:26 +0100234 [OM2K_DEI_BS_AG_BKS_RES] = { TLV_TYPE_TV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100235 [OM2K_DEI_BSIC] = { TLV_TYPE_TV },
Harald Welte884e7e52011-03-05 19:21:26 +0100236 [OM2K_DEI_BA_PA_MFRMS] = { TLV_TYPE_TV },
237 [OM2K_DEI_CBCH_INDICATOR] = { TLV_TYPE_TV },
Harald Welte271e9612011-03-05 20:13:52 +0100238 [OM2K_DEI_INT_FAULT_MAP_1A] = { TLV_TYPE_FIXED, 6 },
239 [OM2K_DEI_INT_FAULT_MAP_1B] = { TLV_TYPE_FIXED, 6 },
240 [OM2K_DEI_INT_FAULT_MAP_2A] = { TLV_TYPE_FIXED, 6 },
241 [OM2K_DEI_INT_FAULT_MAP_2A_EXT]={ TLV_TYPE_FIXED, 6 },
Harald Welte884e7e52011-03-05 19:21:26 +0100242 [OM2K_DEI_CCCH_OPTIONS] = { TLV_TYPE_TV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100243 [OM2K_DEI_CAL_TIME] = { TLV_TYPE_FIXED, 6 },
244 [OM2K_DEI_COMBINATION] = { TLV_TYPE_TV },
245 [OM2K_DEI_CON_CONN_LIST] = { TLV_TYPE_TLV },
Harald Welte884e7e52011-03-05 19:21:26 +0100246 [OM2K_DEI_DRX_DEV_MAX] = { TLV_TYPE_TV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100247 [OM2K_DEI_END_LIST_NR] = { TLV_TYPE_TV },
Harald Welte271e9612011-03-05 20:13:52 +0100248 [OM2K_DEI_EXT_COND_MAP_1] = { TLV_TYPE_FIXED, 2 },
249 [OM2K_DEI_EXT_COND_MAP_2] = { TLV_TYPE_FIXED, 2 },
Harald Weltee1f8de42011-03-05 17:52:09 +0100250 [OM2K_DEI_FILLING_MARKER] = { TLV_TYPE_TV },
251 [OM2K_DEI_FN_OFFSET] = { TLV_TYPE_FIXED, 2 },
252 [OM2K_DEI_FREQ_LIST] = { TLV_TYPE_TLV },
253 [OM2K_DEI_FREQ_SPEC_RX] = { TLV_TYPE_FIXED, 2 },
254 [OM2K_DEI_FREQ_SPEC_TX] = { TLV_TYPE_FIXED, 2 },
255 [OM2K_DEI_HSN] = { TLV_TYPE_TV },
Harald Welte884e7e52011-03-05 19:21:26 +0100256 [OM2K_DEI_ICM_INDICATOR] = { TLV_TYPE_TV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100257 [OM2K_DEI_IS_CONN_LIST] = { TLV_TYPE_TLV },
258 [OM2K_DEI_LIST_NR] = { TLV_TYPE_TV },
Harald Welte271e9612011-03-05 20:13:52 +0100259 [OM2K_DEI_LOCAL_ACCESS] = { TLV_TYPE_TV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100260 [OM2K_DEI_MAIO] = { TLV_TYPE_TV },
Harald Welte271e9612011-03-05 20:13:52 +0100261 [OM2K_DEI_MO_STATE] = { TLV_TYPE_TV },
Harald Welte884e7e52011-03-05 19:21:26 +0100262 [OM2K_DEI_NY1] = { TLV_TYPE_TV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100263 [OM2K_DEI_OP_INFO] = { TLV_TYPE_TV },
264 [OM2K_DEI_POWER] = { TLV_TYPE_TV },
265 [OM2K_DEI_REASON_CODE] = { TLV_TYPE_TV },
266 [OM2K_DEI_RX_DIVERSITY] = { TLV_TYPE_TV },
267 [OM2K_DEI_RESULT_CODE] = { TLV_TYPE_TV },
Harald Welte884e7e52011-03-05 19:21:26 +0100268 [OM2K_DEI_T3105] = { TLV_TYPE_TV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100269 [OM2K_DEI_TF_MODE] = { TLV_TYPE_TV },
270 [OM2K_DEI_TS_NR] = { TLV_TYPE_TV },
Harald Welte884e7e52011-03-05 19:21:26 +0100271 [OM2K_DEI_TSC] = { TLV_TYPE_TV },
Harald Welte271e9612011-03-05 20:13:52 +0100272 [OM2K_DEI_BTS_VERSION] = { TLV_TYPE_FIXED, 12 },
273 [OM2K_DEI_OML_IWD_VERSION] = { TLV_TYPE_FIXED, 6 },
274 [OM2K_DEI_RSL_IWD_VERSION] = { TLV_TYPE_FIXED, 6 },
275 [OM2K_DEI_OML_FUNC_MAP_1] = { TLV_TYPE_TLV },
276 [OM2K_DEI_OML_FUNC_MAP_2] = { TLV_TYPE_TLV },
277 [OM2K_DEI_RSL_FUNC_MAP_1] = { TLV_TYPE_TLV },
278 [OM2K_DEI_RSL_FUNC_MAP_2] = { TLV_TYPE_TLV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100279 [OM2K_DEI_EXT_RANGE] = { TLV_TYPE_TV },
Harald Welte271e9612011-03-05 20:13:52 +0100280 [OM2K_DEI_REQ_IND] = { TLV_TYPE_TV },
281 [OM2K_DEI_REPL_UNIT_MAP] = { TLV_TYPE_FIXED, 6 },
Harald Welte884e7e52011-03-05 19:21:26 +0100282 [OM2K_DEI_LSC] = { TLV_TYPE_TV },
283 [OM2K_DEI_LSC_FILT_TIME] = { TLV_TYPE_TV },
284 [OM2K_DEI_CALL_SUPV_TIME] = { TLV_TYPE_TV },
Harald Welte271e9612011-03-05 20:13:52 +0100285 [OM2K_DEI_HW_INFO_SIG] = { TLV_TYPE_FIXED, 2 },
Harald Welte884e7e52011-03-05 19:21:26 +0100286 [OM2K_DEI_TTA] = { TLV_TYPE_TV },
Harald Welte271e9612011-03-05 20:13:52 +0100287 [OM2K_DEI_CAPA_SIG] = { TLV_TYPE_FIXED, 2 },
Harald Weltee1f8de42011-03-05 17:52:09 +0100288 [OM2K_DEI_NEGOT_REC1] = { TLV_TYPE_TLV },
289 [OM2K_DEI_NEGOT_REC2] = { TLV_TYPE_TLV },
Harald Welte884e7e52011-03-05 19:21:26 +0100290 [OM2K_DEI_ENCR_ALG] = { TLV_TYPE_TV },
291 [OM2K_DEI_INTERF_REJ_COMB] = { TLV_TYPE_TV },
Harald Weltee1f8de42011-03-05 17:52:09 +0100292 [OM2K_DEI_FS_OFFSET] = { TLV_TYPE_FIXED, 5 },
Harald Welte271e9612011-03-05 20:13:52 +0100293 [OM2K_DEI_EXT_COND_MAP_2_EXT] = { TLV_TYPE_FIXED, 4 },
Harald Weltee1f8de42011-03-05 17:52:09 +0100294 },
295};
296
Harald Welte2a0a9632011-02-12 12:33:06 +0100297static const struct value_string om2k_msgcode_vals[] = {
298 { 0x0000, "Abort SP Command" },
299 { 0x0002, "Abort SP Complete" },
300 { 0x0004, "Alarm Report ACK" },
301 { 0x0005, "Alarm Report NACK" },
302 { 0x0006, "Alarm Report" },
303 { 0x0008, "Alarm Status Request" },
304 { 0x000a, "Alarm Status Request Accept" },
305 { 0x000b, "Alarm Status Request Reject" },
306 { 0x000c, "Alarm Status Result ACK" },
307 { 0x000d, "Alarm Status Result NACK" },
308 { 0x000e, "Alarm Status Result" },
309 { 0x0010, "Calendar Time Response" },
310 { 0x0011, "Calendar Time Reject" },
311 { 0x0012, "Calendar Time Request" },
312 { 0x0014, "CON Configuration Request" },
313 { 0x0016, "CON Configuration Request Accept" },
314 { 0x0017, "CON Configuration Request Reject" },
315 { 0x0018, "CON Configuration Result ACK" },
316 { 0x0019, "CON Configuration Result NACK" },
317 { 0x001a, "CON Configuration Result" },
318 { 0x001c, "Connect Command" },
319 { 0x001e, "Connect Complete" },
Harald Welteaf92c402011-03-05 17:58:13 +0100320 { 0x001f, "Connect Reject" },
Harald Welte2a0a9632011-02-12 12:33:06 +0100321 { 0x0028, "Disable Request" },
322 { 0x002a, "Disable Request Accept" },
323 { 0x002b, "Disable Request Reject" },
324 { 0x002c, "Disable Result ACK" },
325 { 0x002d, "Disable Result NACK" },
326 { 0x002e, "Disable Result" },
327 { 0x0030, "Disconnect Command" },
328 { 0x0032, "Disconnect Complete" },
329 { 0x0033, "Disconnect Reject" },
330 { 0x0034, "Enable Request" },
331 { 0x0036, "Enable Request Accept" },
332 { 0x0037, "Enable Request Reject" },
333 { 0x0038, "Enable Result ACK" },
334 { 0x0039, "Enable Result NACK" },
335 { 0x003a, "Enable Result" },
336 { 0x003c, "Escape Downlink Normal" },
337 { 0x003d, "Escape Downlink NACK" },
338 { 0x003e, "Escape Uplink Normal" },
339 { 0x003f, "Escape Uplink NACK" },
340 { 0x0040, "Fault Report ACK" },
341 { 0x0041, "Fault Report NACK" },
342 { 0x0042, "Fault Report" },
343 { 0x0044, "File Package End Command" },
344 { 0x0046, "File Package End Result" },
345 { 0x0047, "File Package End Reject" },
346 { 0x0048, "File Relation Request" },
347 { 0x004a, "File Relation Response" },
348 { 0x004b, "File Relation Request Reject" },
349 { 0x004c, "File Segment Transfer" },
350 { 0x004e, "File Segment Transfer Complete" },
351 { 0x004f, "File Segment Transfer Reject" },
352 { 0x0050, "HW Information Request" },
353 { 0x0052, "HW Information Request Accept" },
354 { 0x0053, "HW Information Request Reject" },
355 { 0x0054, "HW Information Result ACK" },
356 { 0x0055, "HW Information Result NACK" },
357 { 0x0056, "HW Information Result" },
358 { 0x0060, "IS Configuration Request" },
359 { 0x0062, "IS Configuration Request Accept" },
360 { 0x0063, "IS Configuration Request Reject" },
361 { 0x0064, "IS Configuration Result ACK" },
362 { 0x0065, "IS Configuration Result NACK" },
363 { 0x0066, "IS Configuration Result" },
364 { 0x0068, "Load Data End" },
365 { 0x006a, "Load Data End Result" },
366 { 0x006b, "Load Data End Reject" },
367 { 0x006c, "Load Data Init" },
368 { 0x006e, "Load Data Init Accept" },
369 { 0x006f, "Load Data Init Reject" },
370 { 0x0070, "Loop Control Command" },
371 { 0x0072, "Loop Control Complete" },
372 { 0x0073, "Loop Control Reject" },
373 { 0x0074, "Operational Information" },
374 { 0x0076, "Operational Information Accept" },
375 { 0x0077, "Operational Information Reject" },
376 { 0x0078, "Reset Command" },
377 { 0x007a, "Reset Complete" },
378 { 0x007b, "Reset Reject" },
379 { 0x007c, "RX Configuration Request" },
380 { 0x007e, "RX Configuration Request Accept" },
381 { 0x007f, "RX Configuration Request Reject" },
382 { 0x0080, "RX Configuration Result ACK" },
383 { 0x0081, "RX Configuration Result NACK" },
384 { 0x0082, "RX Configuration Result" },
385 { 0x0084, "Start Request" },
386 { 0x0086, "Start Request Accept" },
387 { 0x0087, "Start Request Reject" },
388 { 0x0088, "Start Result ACK" },
389 { 0x0089, "Start Result NACK" },
390 { 0x008a, "Start Result" },
391 { 0x008c, "Status Request" },
392 { 0x008e, "Status Response" },
393 { 0x008f, "Status Reject" },
394 { 0x0094, "Test Request" },
395 { 0x0096, "Test Request Accept" },
396 { 0x0097, "Test Request Reject" },
397 { 0x0098, "Test Result ACK" },
398 { 0x0099, "Test Result NACK" },
399 { 0x009a, "Test Result" },
400 { 0x00a0, "TF Configuration Request" },
401 { 0x00a2, "TF Configuration Request Accept" },
402 { 0x00a3, "TF Configuration Request Reject" },
403 { 0x00a4, "TF Configuration Result ACK" },
404 { 0x00a5, "TF Configuration Result NACK" },
405 { 0x00a6, "TF Configuration Result" },
406 { 0x00a8, "TS Configuration Request" },
407 { 0x00aa, "TS Configuration Request Accept" },
408 { 0x00ab, "TS Configuration Request Reject" },
409 { 0x00ac, "TS Configuration Result ACK" },
410 { 0x00ad, "TS Configuration Result NACK" },
411 { 0x00ae, "TS Configuration Result" },
412 { 0x00b0, "TX Configuration Request" },
413 { 0x00b2, "TX Configuration Request Accept" },
414 { 0x00b3, "TX Configuration Request Reject" },
415 { 0x00b4, "TX Configuration Result ACK" },
416 { 0x00b5, "TX Configuration Result NACK" },
417 { 0x00b6, "TX Configuration Result" },
418 { 0x00bc, "DIP Alarm Report ACK" },
419 { 0x00bd, "DIP Alarm Report NACK" },
420 { 0x00be, "DIP Alarm Report" },
421 { 0x00c0, "DIP Alarm Status Request" },
422 { 0x00c2, "DIP Alarm Status Response" },
423 { 0x00c3, "DIP Alarm Status Reject" },
424 { 0x00c4, "DIP Quality Report I ACK" },
425 { 0x00c5, "DIP Quality Report I NACK" },
426 { 0x00c6, "DIP Quality Report I" },
427 { 0x00c8, "DIP Quality Report II ACK" },
428 { 0x00c9, "DIP Quality Report II NACK" },
429 { 0x00ca, "DIP Quality Report II" },
430 { 0x00dc, "DP Configuration Request" },
431 { 0x00de, "DP Configuration Request Accept" },
432 { 0x00df, "DP Configuration Request Reject" },
433 { 0x00e0, "DP Configuration Result ACK" },
434 { 0x00e1, "DP Configuration Result NACK" },
435 { 0x00e2, "DP Configuration Result" },
436 { 0x00e4, "Capabilities HW Info Report ACK" },
437 { 0x00e5, "Capabilities HW Info Report NACK" },
438 { 0x00e6, "Capabilities HW Info Report" },
439 { 0x00e8, "Capabilities Request" },
440 { 0x00ea, "Capabilities Request Accept" },
441 { 0x00eb, "Capabilities Request Reject" },
442 { 0x00ec, "Capabilities Result ACK" },
443 { 0x00ed, "Capabilities Result NACK" },
444 { 0x00ee, "Capabilities Result" },
445 { 0x00f0, "FM Configuration Request" },
446 { 0x00f2, "FM Configuration Request Accept" },
447 { 0x00f3, "FM Configuration Request Reject" },
448 { 0x00f4, "FM Configuration Result ACK" },
449 { 0x00f5, "FM Configuration Result NACK" },
450 { 0x00f6, "FM Configuration Result" },
451 { 0x00f8, "FM Report Request" },
452 { 0x00fa, "FM Report Response" },
453 { 0x00fb, "FM Report Reject" },
454 { 0x00fc, "FM Start Command" },
455 { 0x00fe, "FM Start Complete" },
456 { 0x00ff, "FM Start Reject" },
457 { 0x0100, "FM Stop Command" },
458 { 0x0102, "FM Stop Complete" },
459 { 0x0103, "FM Stop Reject" },
460 { 0x0104, "Negotiation Request ACK" },
461 { 0x0105, "Negotiation Request NACK" },
462 { 0x0106, "Negotiation Request" },
463 { 0x0108, "BTS Initiated Request ACK" },
464 { 0x0109, "BTS Initiated Request NACK" },
465 { 0x010a, "BTS Initiated Request" },
466 { 0x010c, "Radio Channels Release Command" },
467 { 0x010e, "Radio Channels Release Complete" },
468 { 0x010f, "Radio Channels Release Reject" },
469 { 0x0118, "Feature Control Command" },
470 { 0x011a, "Feature Control Complete" },
471 { 0x011b, "Feature Control Reject" },
472
473 { 0, NULL }
474};
475
476/* TS 12.21 Section 9.4: Attributes */
477static const struct value_string om2k_attr_vals[] = {
478 { 0x00, "Accordance indication" },
479 { 0x01, "Alarm Id" },
480 { 0x02, "Alarm Data" },
481 { 0x03, "Alarm Severity" },
482 { 0x04, "Alarm Status" },
483 { 0x05, "Alarm Status Type" },
484 { 0x06, "BCC" },
485 { 0x07, "BS_AG_BKS_RES" },
486 { 0x09, "BSIC" },
487 { 0x0a, "BA_PA_MFRMS" },
488 { 0x0b, "CBCH Indicator" },
489 { 0x0c, "CCCH Options" },
490 { 0x0d, "Calendar Time" },
491 { 0x0f, "Channel Combination" },
492 { 0x10, "CON Connection List" },
493 { 0x11, "Data End Indication" },
494 { 0x12, "DRX_DEV_MAX" },
495 { 0x13, "End List Number" },
496 { 0x14, "External Condition Map Class 1" },
497 { 0x15, "External Condition Map Class 2" },
498 { 0x16, "File Relation Indication" },
499 { 0x17, "File Revision" },
500 { 0x18, "File Segment Data" },
501 { 0x19, "File Segment Length" },
502 { 0x1a, "File Segment Sequence Number" },
503 { 0x1b, "File Size" },
504 { 0x1c, "Filling Marker" },
505 { 0x1d, "FN Offset" },
506 { 0x1e, "Frequency List" },
507 { 0x1f, "Frequency Specifier RX" },
508 { 0x20, "Frequency Specifier TX" },
509 { 0x21, "HSN" },
510 { 0x22, "ICM Indicator" },
511 { 0x23, "Internal Fault Map Class 1A" },
512 { 0x24, "Internal Fault Map Class 1B" },
513 { 0x25, "Internal Fault Map Class 2A" },
514 { 0x26, "Internal Fault Map Class 2A Extension" },
515 { 0x27, "IS Connection List" },
516 { 0x28, "List Number" },
517 { 0x29, "File Package State Indication" },
518 { 0x2a, "Local Access State" },
519 { 0x2b, "MAIO" },
520 { 0x2c, "MO State" },
521 { 0x2d, "Ny1" },
522 { 0x2e, "Operational Information" },
523 { 0x2f, "Power" },
524 { 0x30, "RU Position Data" },
525 { 0x31, "Protocol Error" },
526 { 0x32, "Reason Code" },
527 { 0x33, "Receiver Diversity" },
528 { 0x34, "Replacement Unit Map" },
529 { 0x35, "Result Code" },
530 { 0x36, "RU Revision Data" },
531 { 0x38, "T3105" },
532 { 0x39, "Test Loop Setting" },
533 { 0x3a, "TF Mode" },
534 { 0x3b, "TF Compensation Value" },
535 { 0x3c, "Time Slot Number" },
536 { 0x3d, "TSC" },
537 { 0x3e, "RU Logical Id" },
538 { 0x3f, "RU Serial Number Data" },
539 { 0x40, "BTS Version" },
540 { 0x41, "OML IWD Version" },
541 { 0x42, "RWL IWD Version" },
542 { 0x43, "OML Function Map 1" },
543 { 0x44, "OML Function Map 2" },
544 { 0x45, "RSL Function Map 1" },
545 { 0x46, "RSL Function Map 2" },
546 { 0x47, "Extended Range Indicator" },
547 { 0x48, "Request Indicators" },
548 { 0x49, "DIP Alarm Condition Map" },
549 { 0x4a, "ES Incoming" },
550 { 0x4b, "ES Outgoing" },
551 { 0x4e, "SES Incoming" },
552 { 0x4f, "SES Outgoing" },
553 { 0x50, "Replacement Unit Map Extension" },
554 { 0x52, "UAS Incoming" },
555 { 0x53, "UAS Outgoing" },
556 { 0x58, "DF Incoming" },
557 { 0x5a, "DF Outgoing" },
558 { 0x5c, "SF" },
559 { 0x60, "S Bits Setting" },
560 { 0x61, "CRC-4 Use Option" },
561 { 0x62, "T Parameter" },
562 { 0x63, "N Parameter" },
563 { 0x64, "N1 Parameter" },
564 { 0x65, "N3 Parameter" },
565 { 0x66, "N4 Parameter" },
566 { 0x67, "P Parameter" },
567 { 0x68, "Q Parameter" },
568 { 0x69, "BI_Q1" },
569 { 0x6a, "BI_Q2" },
570 { 0x74, "ICM Boundary Parameters" },
571 { 0x77, "AFT" },
572 { 0x78, "AFT RAI" },
573 { 0x79, "Link Supervision Control" },
574 { 0x7a, "Link Supervision Filtering Time" },
575 { 0x7b, "Call Supervision Time" },
576 { 0x7c, "Interval Length UAS Incoming" },
577 { 0x7d, "Interval Length UAS Outgoing" },
578 { 0x7e, "ICM Channel Rate" },
579 { 0x7f, "Attribute Identifier" },
580 { 0x80, "FM Frequency List" },
581 { 0x81, "FM Frequency Report" },
582 { 0x82, "FM Percentile" },
583 { 0x83, "FM Clear Indication" },
584 { 0x84, "HW Info Signature" },
585 { 0x85, "MO Record" },
586 { 0x86, "TF Synchronisation Source" },
587 { 0x87, "TTA" },
588 { 0x88, "End Segment Number" },
589 { 0x89, "Segment Number" },
590 { 0x8a, "Capabilities Signature" },
591 { 0x8c, "File Relation List" },
592 { 0x90, "Negotiation Record I" },
593 { 0x91, "Negotiation Record II" },
594 { 0x92, "Encryption Algorithm" },
595 { 0x94, "Interference Rejection Combining" },
596 { 0x95, "Dedication Information" },
597 { 0x97, "Feature Code" },
598 { 0x98, "FS Offset" },
599 { 0x99, "ESB Timeslot" },
600 { 0x9a, "Master TG Instance" },
601 { 0x9b, "Master TX Chain Delay" },
602 { 0x9c, "External Condition Class 2 Extension" },
603 { 0x9d, "TSs MO State" },
604 { 0, NULL }
605};
606
Harald Welte1d5a2062011-02-12 14:42:59 +0100607const struct value_string om2k_mo_class_short_vals[] = {
Harald Welte2a0a9632011-02-12 12:33:06 +0100608 { 0x01, "TRXC" },
609 { 0x03, "TS" },
610 { 0x04, "TF" },
611 { 0x05, "IS" },
612 { 0x06, "CON" },
613 { 0x07, "DP" },
614 { 0x0a, "CF" },
615 { 0x0b, "TX" },
616 { 0x0c, "RX" },
617 { 0, NULL }
618};
619
620static struct msgb *om2k_msgb_alloc(void)
621{
622 return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE,
623 "OM2000");
624}
625
Harald Weltee1f8de42011-03-05 17:52:09 +0100626static int abis_om2k_tlv_parse(struct tlv_parsed *tp, const u_int8_t *buf, int len)
627{
628 return tlv_parse(tp, &om2k_att_tlvdef, buf, len, 0, 0);
629}
630
Harald Weltec5845042011-02-14 15:26:13 +0100631static char *om2k_mo_name(const struct abis_om2k_mo *mo)
632{
633 static char mo_buf[64];
634
635 memset(mo_buf, 0, sizeof(mo_buf));
636 snprintf(mo_buf, sizeof(mo_buf), "%s/%02x/%02x/%02x",
637 get_value_string(om2k_mo_class_short_vals, mo->class),
638 mo->bts, mo->assoc_so, mo->inst);
639 return mo_buf;
640}
641
Harald Welte8f909d52011-02-12 13:09:38 +0100642static int abis_om2k_sendmsg(struct gsm_bts *bts, struct msgb *msg)
643{
Harald Weltec5845042011-02-14 15:26:13 +0100644 struct abis_om2k_hdr *o2h;
645 int to_trx_oml;
Harald Welte8f909d52011-02-12 13:09:38 +0100646
Harald Weltec5845042011-02-14 15:26:13 +0100647 msg->l2h = msg->data;
648 o2h = (struct abis_om2k_hdr *) msg->l2h;
649
Harald Welte884e7e52011-03-05 19:21:26 +0100650 /* Compute the length in the OML header */
651 o2h->om.length = 6 + msgb_l2len(msg)-sizeof(*o2h);
652
Harald Weltec5845042011-02-14 15:26:13 +0100653 switch (o2h->mo.class) {
654 case OM2K_MO_CLS_TRXC:
655 case OM2K_MO_CLS_TX:
656 case OM2K_MO_CLS_RX:
657 case OM2K_MO_CLS_TS:
658 /* Route through per-TRX OML Link to the appropriate TRX */
659 to_trx_oml = 1;
660 msg->trx = gsm_bts_trx_by_nr(bts, o2h->mo.inst);
661 if (!msg->trx) {
662 LOGP(DNM, LOGL_ERROR, "MO=%s Tx Dropping msg to "
663 "non-existing TRX\n", om2k_mo_name(&o2h->mo));
664 return -ENODEV;
665 }
666 break;
667 default:
668 /* Route through the IXU/DXU OML Link */
669 msg->trx = bts->c0;
670 to_trx_oml = 0;
671 break;
672 }
673
674 return _abis_nm_sendmsg(msg, to_trx_oml);
Harald Welte8f909d52011-02-12 13:09:38 +0100675}
676
Harald Welte2a0a9632011-02-12 12:33:06 +0100677static void fill_om2k_hdr(struct abis_om2k_hdr *o2h, const struct abis_om2k_mo *mo,
Harald Welte884e7e52011-03-05 19:21:26 +0100678 uint16_t msg_type)
Harald Welte2a0a9632011-02-12 12:33:06 +0100679{
680 o2h->om.mdisc = ABIS_OM_MDISC_FOM;
681 o2h->om.placement = ABIS_OM_PLACEMENT_ONLY;
682 o2h->om.sequence = 0;
Harald Welte884e7e52011-03-05 19:21:26 +0100683 /* We fill o2h->om.length later during om2k_sendmsg() */
Harald Welte2a0a9632011-02-12 12:33:06 +0100684 o2h->msg_type = htons(msg_type);
685 memcpy(&o2h->mo, mo, sizeof(o2h->mo));
686}
687
Harald Welte4f3644b2011-02-12 13:44:14 +0100688const struct abis_om2k_mo om2k_mo_cf = { OM2K_MO_CLS_CF, 0, 0xFF, 0 };
Harald Welte4a8f22e2011-02-12 20:23:40 +0100689const struct abis_om2k_mo om2k_mo_is = { OM2K_MO_CLS_IS, 0, 0xFF, 0 };
Harald Weltef5dbc3c2011-02-14 15:31:43 +0100690const struct abis_om2k_mo om2k_mo_con = { OM2K_MO_CLS_CON, 0, 0xFF, 0 };
Harald Welte429bed02011-03-05 14:36:47 +0100691const struct abis_om2k_mo om2k_mo_tf = { OM2K_MO_CLS_TF, 0, 0xFF, 0 };
Harald Welte2a0a9632011-02-12 12:33:06 +0100692
693static int abis_om2k_cal_time_resp(struct gsm_bts *bts)
694{
695 struct msgb *msg = om2k_msgb_alloc();
696 struct abis_om2k_hdr *o2k;
697 time_t tm_t;
698 struct tm *tm;
699
700 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100701 fill_om2k_hdr(o2k, &om2k_mo_cf, OM2K_MSGT_CAL_TIME_RESP);
Harald Welte2a0a9632011-02-12 12:33:06 +0100702
703 tm_t = time(NULL);
704 tm = localtime(&tm_t);
705
706 msgb_put_u8(msg, OM2K_DEI_CAL_TIME);
707 msgb_put_u8(msg, tm->tm_year % 100);
708 msgb_put_u8(msg, tm->tm_mon + 1);
709 msgb_put_u8(msg, tm->tm_mday);
710 msgb_put_u8(msg, tm->tm_hour);
711 msgb_put_u8(msg, tm->tm_min);
712 msgb_put_u8(msg, tm->tm_sec);
713
Harald Welte8f909d52011-02-12 13:09:38 +0100714 return abis_om2k_sendmsg(bts, msg);
Harald Welte2a0a9632011-02-12 12:33:06 +0100715}
716
Harald Welte9bf8e9e2011-02-12 14:57:17 +0100717static int abis_om2k_tx_simple(struct gsm_bts *bts, const struct abis_om2k_mo *mo,
Harald Welte2a0a9632011-02-12 12:33:06 +0100718 uint8_t msg_type)
719{
720 struct msgb *msg = om2k_msgb_alloc();
721 struct abis_om2k_hdr *o2k;
722
723 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100724 fill_om2k_hdr(o2k, mo, msg_type);
Harald Welte2a0a9632011-02-12 12:33:06 +0100725
Harald Welte4f3644b2011-02-12 13:44:14 +0100726 DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo),
727 get_value_string(om2k_msgcode_vals, msg_type));
728
Harald Welte8f909d52011-02-12 13:09:38 +0100729 return abis_om2k_sendmsg(bts, msg);
Harald Welte2a0a9632011-02-12 12:33:06 +0100730}
731
Harald Welte9bf8e9e2011-02-12 14:57:17 +0100732int abis_om2k_tx_reset_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
Harald Welte4f3644b2011-02-12 13:44:14 +0100733{
734 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_RESET_CMD);
735}
736
Harald Welte9bf8e9e2011-02-12 14:57:17 +0100737int abis_om2k_tx_start_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
Harald Welte4f3644b2011-02-12 13:44:14 +0100738{
739 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_START_REQ);
740}
741
Harald Welte9bf8e9e2011-02-12 14:57:17 +0100742int abis_om2k_tx_status_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
Harald Welte1d5a2062011-02-12 14:42:59 +0100743{
744 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_STATUS_REQ);
745}
746
Harald Welte9bf8e9e2011-02-12 14:57:17 +0100747int abis_om2k_tx_connect_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
748{
749 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_CONNECT_CMD);
750}
751
752int abis_om2k_tx_disconnect_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
753{
754 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_DISCONNECT_CMD);
755}
756
Harald Welte40ad3b32011-02-12 15:07:30 +0100757int abis_om2k_tx_test_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
758{
759 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_TEST_REQ);
760}
761
Harald Welte6d5a0392011-02-12 18:48:53 +0100762int abis_om2k_tx_enable_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
763{
764 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_ENABLE_REQ);
765}
766
767int abis_om2k_tx_disable_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
768{
769 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_DISABLE_REQ);
770}
771
Harald Welte9bf8e9e2011-02-12 14:57:17 +0100772int abis_om2k_tx_op_info(struct gsm_bts *bts, const struct abis_om2k_mo *mo,
773 uint8_t operational)
Harald Welte2a0a9632011-02-12 12:33:06 +0100774{
775 struct msgb *msg = om2k_msgb_alloc();
776 struct abis_om2k_hdr *o2k;
777
778 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100779 fill_om2k_hdr(o2k, mo, OM2K_MSGT_OP_INFO);
Harald Welte2a0a9632011-02-12 12:33:06 +0100780
781 msgb_tv_put(msg, OM2K_DEI_OP_INFO, operational);
782
Harald Welte4f3644b2011-02-12 13:44:14 +0100783 DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo),
784 get_value_string(om2k_msgcode_vals, OM2K_MSGT_OP_INFO));
785
Harald Welte8f909d52011-02-12 13:09:38 +0100786 return abis_om2k_sendmsg(bts, msg);
Harald Welte2a0a9632011-02-12 12:33:06 +0100787}
788
Harald Welte4a8f22e2011-02-12 20:23:40 +0100789int abis_om2k_tx_is_conf_req(struct gsm_bts *bts, struct om2k_is_conn_grp *cg,
790 unsigned int num_cg )
791{
792 struct msgb *msg = om2k_msgb_alloc();
793 struct abis_om2k_hdr *o2k;
794
795 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100796 fill_om2k_hdr(o2k, &om2k_mo_is, OM2K_MSGT_IS_CONF_REQ);
Harald Welte4a8f22e2011-02-12 20:23:40 +0100797
798 msgb_tv_put(msg, OM2K_DEI_LIST_NR, 1);
799 msgb_tv_put(msg, OM2K_DEI_END_LIST_NR, 1);
800
801 msgb_tlv_put(msg, OM2K_DEI_IS_CONN_LIST,
802 num_cg * sizeof(*cg), (uint8_t *)cg);
803
804 return abis_om2k_sendmsg(bts, msg);
805}
806
Harald Weltef5dbc3c2011-02-14 15:31:43 +0100807int abis_om2k_tx_con_conf_req(struct gsm_bts *bts, uint8_t *data,
808 unsigned int len)
809{
810 struct msgb *msg = om2k_msgb_alloc();
811 struct abis_om2k_hdr *o2k;
812
813 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100814 fill_om2k_hdr(o2k, &om2k_mo_con, OM2K_MSGT_CON_CONF_REQ);
Harald Weltef5dbc3c2011-02-14 15:31:43 +0100815
816 msgb_tv_put(msg, OM2K_DEI_LIST_NR, 1);
817 msgb_tv_put(msg, OM2K_DEI_END_LIST_NR, 1);
818
819 msgb_tlv_put(msg, OM2K_DEI_CON_CONN_LIST, len, data);
820
821 return abis_om2k_sendmsg(bts, msg);
822}
823
Harald Welte00585d92011-03-05 14:13:14 +0100824static void om2k_trx_to_mo(struct abis_om2k_mo *mo,
825 const struct gsm_bts_trx *trx,
826 enum abis_om2k_mo_cls cls)
827{
828 mo->class = cls;
829 mo->bts = 0;
830 mo->inst = trx->nr;
Harald Welte14b44342011-03-05 16:21:01 +0100831 mo->assoc_so = 255;
Harald Welte00585d92011-03-05 14:13:14 +0100832}
833
834static void om2k_ts_to_mo(struct abis_om2k_mo *mo,
835 const struct gsm_bts_trx_ts *ts)
836{
837 mo->class = OM2K_MO_CLS_TS;
838 mo->bts = 0;
839 mo->inst = ts->nr;
840 mo->assoc_so = ts->trx->nr;
841}
842
843/* Configure a Receiver MO */
844int abis_om2k_tx_rx_conf_req(struct gsm_bts_trx *trx)
845{
846 struct msgb *msg = om2k_msgb_alloc();
847 struct abis_om2k_hdr *o2k;
848 struct abis_om2k_mo mo;
849
850 om2k_trx_to_mo(&mo, trx, OM2K_MO_CLS_RX);
851
852 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100853 fill_om2k_hdr(o2k, &mo, OM2K_MSGT_RX_CONF_REQ);
Harald Welte00585d92011-03-05 14:13:14 +0100854
855 msgb_tv16_put(msg, OM2K_DEI_FREQ_SPEC_RX, trx->arfcn);
856 msgb_tv_put(msg, OM2K_DEI_RX_DIVERSITY, 0x03); /* A+B */
857
858 return abis_om2k_sendmsg(trx->bts, msg);
859}
860
861/* Configure a Transmitter MO */
862int abis_om2k_tx_tx_conf_req(struct gsm_bts_trx *trx)
863{
864 struct msgb *msg = om2k_msgb_alloc();
865 struct abis_om2k_hdr *o2k;
866 struct abis_om2k_mo mo;
867
868 om2k_trx_to_mo(&mo, trx, OM2K_MO_CLS_TX);
869
870 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100871 fill_om2k_hdr(o2k, &mo, OM2K_MSGT_TX_CONF_REQ);
Harald Welte00585d92011-03-05 14:13:14 +0100872
873 msgb_tv16_put(msg, OM2K_DEI_FREQ_SPEC_TX, trx->arfcn);
874 msgb_tv_put(msg, OM2K_DEI_POWER, trx->nominal_power-trx->max_power_red);
875 msgb_tv_put(msg, OM2K_DEI_FILLING_MARKER, 0); /* Filling enabled */
876 msgb_tv_put(msg, OM2K_DEI_BCC, trx->bts->bsic & 0x7);
877 /* Dedication Information is optional */
878
879 return abis_om2k_sendmsg(trx->bts, msg);
880}
881
Harald Welte429bed02011-03-05 14:36:47 +0100882enum abis_om2k_tf_mode {
883 OM2K_TF_MODE_MASTER = 0x00,
884 OM2K_TF_MODE_STANDALONE = 0x01,
885 OM2K_TF_MODE_SLAVE = 0x02,
886 OM2K_TF_MODE_UNDEFINED = 0xff,
887};
888
889static const uint8_t fs_offset_undef[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
890
891int abis_om2k_tx_tf_conf_req(struct gsm_bts *bts)
892{
893 struct msgb *msg = om2k_msgb_alloc();
894 struct abis_om2k_hdr *o2k;
895
896 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100897 fill_om2k_hdr(o2k, &om2k_mo_tf, OM2K_MSGT_TF_CONF_REQ);
Harald Welte429bed02011-03-05 14:36:47 +0100898
899 msgb_tv_put(msg, OM2K_DEI_TF_MODE, OM2K_TF_MODE_STANDALONE);
900 msgb_tv_fixed_put(msg, OM2K_DEI_FS_OFFSET,
901 sizeof(fs_offset_undef), fs_offset_undef);
902
903 return abis_om2k_sendmsg(bts, msg);
904}
905
Harald Welte00585d92011-03-05 14:13:14 +0100906static uint8_t pchan2comb(enum gsm_phys_chan_config pchan)
907{
908 switch (pchan) {
909 case GSM_PCHAN_CCCH:
910 return 4;
911 case GSM_PCHAN_CCCH_SDCCH4:
912 return 5;
913 case GSM_PCHAN_SDCCH8_SACCH8C:
914 return 3;
915 case GSM_PCHAN_TCH_F:
916 case GSM_PCHAN_TCH_H:
917 case GSM_PCHAN_PDCH:
918 case GSM_PCHAN_TCH_F_PDCH:
919 return 8;
920 default:
921 return 0;
922 }
923}
924
Harald Weltebde6a762011-03-05 17:30:07 +0100925static int put_freq_list(uint8_t *buf, uint16_t arfcn)
926{
927 buf[0] = 0x00; /* TX/RX address */
928 buf[1] = (arfcn >> 8);
929 buf[2] = (arfcn & 0xff);
930
931 return 3;
932}
933
Harald Welte00585d92011-03-05 14:13:14 +0100934/* Compute a frequency list in OM2000 fomrmat */
935static int om2k_gen_freq_list(uint8_t *list, struct gsm_bts_trx_ts *ts)
936{
937 uint8_t *cur = list;
Harald Weltee1f8de42011-03-05 17:52:09 +0100938 int len;
Harald Welte00585d92011-03-05 14:13:14 +0100939
940 if (ts->hopping.enabled) {
941 unsigned int i;
942 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
Harald Weltebde6a762011-03-05 17:30:07 +0100943 if (bitvec_get_bit_pos(&ts->hopping.arfcns, i))
944 cur += put_freq_list(cur, i);
Harald Welte00585d92011-03-05 14:13:14 +0100945 }
Harald Weltebde6a762011-03-05 17:30:07 +0100946 } else
947 cur += put_freq_list(cur, ts->trx->arfcn);
948
Harald Weltee1f8de42011-03-05 17:52:09 +0100949 len = cur - list;
950
951 return len;
Harald Welte00585d92011-03-05 14:13:14 +0100952}
953
954int abis_om2k_tx_ts_conf_req(struct gsm_bts_trx_ts *ts)
955{
956 struct msgb *msg = om2k_msgb_alloc();
957 struct abis_om2k_hdr *o2k;
958 struct abis_om2k_mo mo;
959 uint8_t freq_list[64*3]; /* BA max size: 64 ARFCN */
960 int freq_list_len;
961
962 om2k_ts_to_mo(&mo, ts);
963
Harald Weltebde6a762011-03-05 17:30:07 +0100964 memset(freq_list, 0, sizeof(freq_list));
Harald Welte00585d92011-03-05 14:13:14 +0100965 freq_list_len = om2k_gen_freq_list(freq_list, ts);
966 if (freq_list_len < 0)
967 return freq_list_len;
968
969 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +0100970 fill_om2k_hdr(o2k, &mo, OM2K_MSGT_TS_CONF_REQ);
Harald Welte00585d92011-03-05 14:13:14 +0100971
972 msgb_tv_put(msg, OM2K_DEI_COMBINATION, pchan2comb(ts->pchan));
973 msgb_tv_put(msg, OM2K_DEI_TS_NR, ts->nr);
974 msgb_tlv_put(msg, OM2K_DEI_FREQ_LIST, freq_list_len, freq_list);
975 msgb_tv_put(msg, OM2K_DEI_HSN, ts->hopping.hsn);
976 msgb_tv_put(msg, OM2K_DEI_MAIO, ts->hopping.maio);
977 msgb_tv_put(msg, OM2K_DEI_BSIC, ts->trx->bts->bsic);
978 msgb_tv_put(msg, OM2K_DEI_RX_DIVERSITY, 0x03); /* A+B */
979 msgb_tv16_put(msg, OM2K_DEI_FN_OFFSET, 0);
980 msgb_tv_put(msg, OM2K_DEI_EXT_RANGE, 0); /* Off */
981 /* Optional: Interference Rejection Combining */
Harald Welte884e7e52011-03-05 19:21:26 +0100982 msgb_tv_put(msg, OM2K_DEI_INTERF_REJ_COMB, 0x00);
983 switch (ts->pchan) {
984 case GSM_PCHAN_CCCH:
985 case GSM_PCHAN_CCCH_SDCCH4:
986 msgb_tv_put(msg, OM2K_DEI_BA_PA_MFRMS, 0x06);
987 msgb_tv_put(msg, OM2K_DEI_BS_AG_BKS_RES, 0x01);
988 msgb_tv_put(msg, OM2K_DEI_DRX_DEV_MAX, 0x05);
989 /* Repeat Paging/IMM.ASS: True, Allow Paging Type 3: Yes, Page for 5 seconds (default) */
990 msgb_tv_put(msg, OM2K_DEI_CCCH_OPTIONS, 0x01);
991 break;
992 case GSM_PCHAN_SDCCH8_SACCH8C:
993 msgb_tv_put(msg, OM2K_DEI_T3105, 0x04);
994 msgb_tv_put(msg, OM2K_DEI_NY1, 35);
995 msgb_tv_put(msg, OM2K_DEI_CBCH_INDICATOR, 0);
996 msgb_tv_put(msg, OM2K_DEI_TSC, ts->trx->bts->tsc);
997 /* Disable RF RESOURCE INDICATION on idle channels */
998 msgb_tv_put(msg, OM2K_DEI_ICM_INDICATOR, 0);
999 break;
1000 default:
1001 msgb_tv_put(msg, OM2K_DEI_T3105, 0x04);
1002 msgb_tv_put(msg, OM2K_DEI_NY1, 35);
1003 msgb_tv_put(msg, OM2K_DEI_CBCH_INDICATOR, 0);
1004 msgb_tv_put(msg, OM2K_DEI_TSC, ts->trx->bts->tsc);
1005 /* Disable RF RESOURCE INDICATION on idle channels */
1006 msgb_tv_put(msg, OM2K_DEI_ICM_INDICATOR, 0);
1007 msgb_tv_put(msg, OM2K_DEI_TTA, 10); /* Timer for Time Alignment */
1008 msgb_tv_put(msg, OM2K_DEI_LSC, 1); /* enabled */
1009 msgb_tv_put(msg, OM2K_DEI_LSC_FILT_TIME, 160); /* units of 100ms */
1010 msgb_tv_put(msg, OM2K_DEI_CALL_SUPV_TIME, 8);
1011 msgb_tv_put(msg, OM2K_DEI_ENCR_ALG, 0x00);
1012 /* FIXME: do we need 9e/9f/a0? */
1013 break;
1014 }
Harald Welte00585d92011-03-05 14:13:14 +01001015
1016 return abis_om2k_sendmsg(ts->trx->bts, msg);
1017}
Harald Weltef5dbc3c2011-02-14 15:31:43 +01001018
Harald Welte9bf8e9e2011-02-12 14:57:17 +01001019static int abis_om2k_tx_negot_req_ack(struct gsm_bts *bts, const struct abis_om2k_mo *mo,
Harald Welte4f3644b2011-02-12 13:44:14 +01001020 uint8_t *data, unsigned int len)
1021{
1022 struct msgb *msg = om2k_msgb_alloc();
1023 struct abis_om2k_hdr *o2k;
1024
1025 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte884e7e52011-03-05 19:21:26 +01001026 fill_om2k_hdr(o2k, mo, OM2K_MSGT_NEGOT_REQ_ACK);
Harald Welte4f3644b2011-02-12 13:44:14 +01001027
1028 msgb_tlv_put(msg, OM2K_DEI_NEGOT_REC2, len, data);
1029
1030 DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo),
1031 get_value_string(om2k_msgcode_vals, OM2K_MSGT_NEGOT_REQ_ACK));
1032
1033 return abis_om2k_sendmsg(bts, msg);
1034}
Harald Welte2a0a9632011-02-12 12:33:06 +01001035
Harald Welte5f496562011-02-12 18:11:16 +01001036struct iwd_version {
1037 uint8_t gen_char[3+1];
1038 uint8_t rev_char[3+1];
1039};
1040
1041struct iwd_type {
1042 uint8_t num_vers;
1043 struct iwd_version v[8];
1044};
1045
Harald Welte2a0a9632011-02-12 12:33:06 +01001046static int om2k_rx_negot_req(struct msgb *msg)
1047{
1048 struct abis_om2k_hdr *o2h = msgb_l2(msg);
Harald Welte5f496562011-02-12 18:11:16 +01001049 struct iwd_type iwd_types[16];
1050 uint8_t num_iwd_types = o2h->data[2];
1051 uint8_t *cur = o2h->data+3;
1052 unsigned int i, v;
Harald Welte2a0a9632011-02-12 12:33:06 +01001053
Harald Welte5f496562011-02-12 18:11:16 +01001054 uint8_t out_buf[1024];
1055 uint8_t *out_cur = out_buf+1;
1056 uint8_t out_num_types = 0;
1057
1058 memset(iwd_types, 0, sizeof(iwd_types));
1059
1060 /* Parse the RBS-supported IWD versions into iwd_types array */
1061 for (i = 0; i < num_iwd_types; i++) {
1062 uint8_t num_versions = *cur++;
1063 uint8_t iwd_type = *cur++;
1064
1065 iwd_types[iwd_type].num_vers = num_versions;
1066
1067 for (v = 0; v < num_versions; v++) {
1068 struct iwd_version *iwd_v = &iwd_types[iwd_type].v[v];
1069
1070 memcpy(iwd_v->gen_char, cur, 3);
Harald Welte091ae8f2011-02-12 18:13:37 +01001071 cur += 3;
1072 memcpy(iwd_v->rev_char, cur, 3);
1073 cur += 3;
1074
Harald Welte5f496562011-02-12 18:11:16 +01001075 DEBUGP(DNM, "\tIWD Type %u Gen %s Rev %s\n", iwd_type,
1076 iwd_v->gen_char, iwd_v->rev_char);
1077 }
1078 }
1079
1080 /* Select the last version for each IWD type */
1081 for (i = 0; i < ARRAY_SIZE(iwd_types); i++) {
1082 struct iwd_type *type = &iwd_types[i];
1083 struct iwd_version *last_v;
1084
1085 if (type->num_vers == 0)
1086 continue;
1087
1088 out_num_types++;
1089
1090 last_v = &type->v[type->num_vers-1];
1091
1092 *out_cur++ = i;
1093 memcpy(out_cur, last_v->gen_char, 3);
1094 out_cur += 3;
1095 memcpy(out_cur, last_v->rev_char, 3);
1096 out_cur += 3;
1097 }
1098
1099 out_buf[0] = out_num_types;
1100
1101 return abis_om2k_tx_negot_req_ack(msg->trx->bts, &o2h->mo, out_buf, out_cur - out_buf);
Harald Welte2a0a9632011-02-12 12:33:06 +01001102}
1103
1104static int om2k_rx_start_res(struct msgb *msg)
1105{
1106 struct abis_om2k_hdr *o2h = msgb_l2(msg);
1107 int rc;
1108
1109 rc = abis_om2k_tx_simple(msg->trx->bts, &o2h->mo, OM2K_MSGT_START_RES_ACK);
1110 rc = abis_om2k_tx_op_info(msg->trx->bts, &o2h->mo, 1);
1111
1112 return rc;
1113}
1114
Harald Welte6d5a0392011-02-12 18:48:53 +01001115static int om2k_rx_op_info_ack(struct msgb *msg)
Harald Welte2a0a9632011-02-12 12:33:06 +01001116{
1117 struct abis_om2k_hdr *o2h = msgb_l2(msg);
Harald Welte2a0a9632011-02-12 12:33:06 +01001118
Harald Welte6d5a0392011-02-12 18:48:53 +01001119 /* FIXME: update Operational state in our structures */
Harald Welte2a0a9632011-02-12 12:33:06 +01001120
Harald Welte6d5a0392011-02-12 18:48:53 +01001121 return 0;
Harald Welte2a0a9632011-02-12 12:33:06 +01001122}
1123
Harald Weltee1f8de42011-03-05 17:52:09 +01001124const struct value_string om2k_result_strings[] = {
1125 { 0x02, "Wrong state or out of sequence" },
1126 { 0x03, "File error" },
1127 { 0x04, "Fault, unspecified" },
1128 { 0x05, "Tuning fault" },
1129 { 0x06, "Protocol error" },
1130 { 0x07, "MO not connected" },
1131 { 0x08, "Parameter error" },
1132 { 0x09, "Optional function not supported" },
1133 { 0x0a, "Local access state LOCALLY DISCONNECTED" },
1134 { 0, NULL }
1135};
1136
1137static int om2k_rx_nack(struct msgb *msg)
1138{
1139 struct abis_om2k_hdr *o2h = msgb_l2(msg);
1140 uint16_t msg_type = ntohs(o2h->msg_type);
1141 struct tlv_parsed tp;
1142
1143 LOGP(DNM, LOGL_ERROR, "Rx MO=%s %s", om2k_mo_name(&o2h->mo),
1144 get_value_string(om2k_msgcode_vals, msg_type));
1145
1146 abis_om2k_tlv_parse(&tp, o2h->data, o2h->om.length - 6);
1147 if (TLVP_PRESENT(&tp, OM2K_DEI_REASON_CODE))
1148 LOGPC(DNM, LOGL_ERROR, ", Reason 0x%02x",
1149 *TLVP_VAL(&tp, OM2K_DEI_REASON_CODE));
1150
1151 if (TLVP_PRESENT(&tp, OM2K_DEI_RESULT_CODE))
1152 LOGPC(DNM, LOGL_ERROR, ", Result %s",
1153 get_value_string(om2k_result_strings,
1154 *TLVP_VAL(&tp, OM2K_DEI_RESULT_CODE)));
1155 LOGPC(DNM, LOGL_ERROR, "\n");
1156
1157 return 0;
1158}
1159
Harald Welte2a0a9632011-02-12 12:33:06 +01001160int abis_om2k_rcvmsg(struct msgb *msg)
1161{
1162 struct gsm_bts *bts = msg->trx->bts;
1163 struct abis_om2k_hdr *o2h = msgb_l2(msg);
1164 struct abis_om_hdr *oh = &o2h->om;
Harald Welte8f909d52011-02-12 13:09:38 +01001165 uint16_t msg_type = ntohs(o2h->msg_type);
Harald Welte2a0a9632011-02-12 12:33:06 +01001166 int rc = 0;
1167
1168 /* Various consistency checks */
1169 if (oh->placement != ABIS_OM_PLACEMENT_ONLY) {
1170 LOGP(DNM, LOGL_ERROR, "ABIS OML placement 0x%x not supported\n",
1171 oh->placement);
1172 if (oh->placement != ABIS_OM_PLACEMENT_FIRST)
1173 return -EINVAL;
1174 }
1175 if (oh->sequence != 0) {
1176 LOGP(DNM, LOGL_ERROR, "ABIS OML sequence 0x%x != 0x00\n",
1177 oh->sequence);
1178 return -EINVAL;
1179 }
1180
1181 msg->l3h = (unsigned char *)o2h + sizeof(*o2h);
1182
1183 if (oh->mdisc != ABIS_OM_MDISC_FOM) {
1184 LOGP(DNM, LOGL_ERROR, "unknown ABIS OM2000 message discriminator 0x%x\n",
1185 oh->mdisc);
1186 return -EINVAL;
1187 }
1188
Harald Welte4f3644b2011-02-12 13:44:14 +01001189 DEBUGP(DNM, "Rx MO=%s %s (%s)\n", om2k_mo_name(&o2h->mo),
Harald Welte8f909d52011-02-12 13:09:38 +01001190 get_value_string(om2k_msgcode_vals, msg_type),
Harald Welte2a0a9632011-02-12 12:33:06 +01001191 hexdump(msg->l2h, msgb_l2len(msg)));
1192
Harald Welte8f909d52011-02-12 13:09:38 +01001193 switch (msg_type) {
Harald Welte2a0a9632011-02-12 12:33:06 +01001194 case OM2K_MSGT_CAL_TIME_REQ:
1195 rc = abis_om2k_cal_time_resp(bts);
1196 break;
1197 case OM2K_MSGT_FAULT_REP:
Harald Welte2a0a9632011-02-12 12:33:06 +01001198 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_FAULT_REP_ACK);
1199 break;
1200 case OM2K_MSGT_NEGOT_REQ:
1201 rc = om2k_rx_negot_req(msg);
1202 break;
1203 case OM2K_MSGT_START_RES:
1204 rc = om2k_rx_start_res(msg);
1205 break;
Harald Welte6d5a0392011-02-12 18:48:53 +01001206 case OM2K_MSGT_OP_INFO_ACK:
1207 rc = om2k_rx_op_info_ack(msg);
Harald Welte2a0a9632011-02-12 12:33:06 +01001208 break;
1209 case OM2K_MSGT_IS_CONF_RES:
1210 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_IS_CONF_RES_ACK);
1211 break;
Harald Weltef5dbc3c2011-02-14 15:31:43 +01001212 case OM2K_MSGT_CON_CONF_RES:
1213 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_CON_CONF_RES_ACK);
1214 break;
Harald Welte00585d92011-03-05 14:13:14 +01001215 case OM2K_MSGT_TX_CONF_RES:
1216 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_TX_CONF_RES_ACK);
1217 break;
1218 case OM2K_MSGT_RX_CONF_RES:
1219 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_RX_CONF_RES_ACK);
1220 break;
1221 case OM2K_MSGT_TS_CONF_RES:
1222 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_TS_CONF_RES_ACK);
1223 break;
Harald Welte429bed02011-03-05 14:36:47 +01001224 case OM2K_MSGT_TF_CONF_RES:
1225 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_TF_CONF_RES_ACK);
1226 break;
Harald Welte2a0a9632011-02-12 12:33:06 +01001227 case OM2K_MSGT_CONNECT_COMPL:
1228 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_RESET_CMD);
1229 break;
1230 case OM2K_MSGT_RESET_COMPL:
1231 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_START_REQ);
1232 break;
Harald Welte252748a2011-02-13 12:43:44 +01001233 case OM2K_MSGT_ENABLE_RES:
1234 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_ENABLE_RES_ACK);
1235 break;
Harald Weltef5dbc3c2011-02-14 15:31:43 +01001236 case OM2K_MSGT_DISABLE_RES:
1237 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_DISABLE_RES_ACK);
1238 break;
1239 case OM2K_MSGT_TEST_RES:
1240 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_TEST_RES_ACK);
Harald Welte2a0a9632011-02-12 12:33:06 +01001241 break;
Harald Welte6d5a0392011-02-12 18:48:53 +01001242 case OM2K_MSGT_STATUS_RESP:
1243 break;
Harald Weltef5dbc3c2011-02-14 15:31:43 +01001244 case OM2K_MSGT_START_REQ_ACK:
1245 case OM2K_MSGT_CON_CONF_REQ_ACK:
1246 case OM2K_MSGT_IS_CONF_REQ_ACK:
Harald Welte00585d92011-03-05 14:13:14 +01001247 case OM2K_MSGT_TX_CONF_REQ_ACK:
1248 case OM2K_MSGT_RX_CONF_REQ_ACK:
1249 case OM2K_MSGT_TS_CONF_REQ_ACK:
Harald Welte429bed02011-03-05 14:36:47 +01001250 case OM2K_MSGT_TF_CONF_REQ_ACK:
Harald Weltef5dbc3c2011-02-14 15:31:43 +01001251 case OM2K_MSGT_ENABLE_REQ_ACK:
1252 case OM2K_MSGT_ALARM_STATUS_REQ_ACK:
1253 case OM2K_MSGT_DISABLE_REQ_ACK:
1254 break;
Harald Weltee1f8de42011-03-05 17:52:09 +01001255 case OM2K_MSGT_START_REQ_REJ:
Harald Welteaf92c402011-03-05 17:58:13 +01001256 case OM2K_MSGT_CONNECT_REJ:
Harald Welte902f8722011-03-05 19:42:16 +01001257 case OM2K_MSGT_OP_INFO_REJ:
Harald Welteaf92c402011-03-05 17:58:13 +01001258 case OM2K_MSGT_DISCONNECT_REJ:
Harald Welte902f8722011-03-05 19:42:16 +01001259 case OM2K_MSGT_TEST_REQ_REJ:
Harald Weltee1f8de42011-03-05 17:52:09 +01001260 case OM2K_MSGT_CON_CONF_REQ_REJ:
1261 case OM2K_MSGT_IS_CONF_REQ_REJ:
1262 case OM2K_MSGT_TX_CONF_REQ_REJ:
1263 case OM2K_MSGT_RX_CONF_REQ_REJ:
1264 case OM2K_MSGT_TS_CONF_REQ_REJ:
1265 case OM2K_MSGT_TF_CONF_REQ_REJ:
1266 case OM2K_MSGT_ENABLE_REQ_REJ:
1267 case OM2K_MSGT_ALARM_STATUS_REQ_REJ:
1268 case OM2K_MSGT_DISABLE_REQ_REJ:
1269 rc = om2k_rx_nack(msg);
1270 break;
Harald Welte2a0a9632011-02-12 12:33:06 +01001271 default:
Harald Welte6d5a0392011-02-12 18:48:53 +01001272 LOGP(DNM, LOGL_NOTICE, "Rx unhandled OM2000 msg %s\n",
Harald Welte8f909d52011-02-12 13:09:38 +01001273 get_value_string(om2k_msgcode_vals, msg_type));
Harald Welte2a0a9632011-02-12 12:33:06 +01001274 }
1275
1276 msgb_free(msg);
1277 return rc;
1278}