blob: 9d2a47fecc2d693ad3048ddaca5a8e330a0bc039 [file] [log] [blame]
Harald Welte9a311ec2011-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 Welte73541072011-02-12 13:44:14 +010041#include <openbsc/abis_om2000.h>
Harald Welte9a311ec2011-02-12 12:33:06 +010042#include <openbsc/signal.h>
Harald Welted88a3872011-02-14 15:26:13 +010043#include <openbsc/e1_input.h>
Harald Welte9a311ec2011-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 Weltebc867d92011-02-12 13:09:38 +010050 * abis_om2k_sendmsg()
Harald Welte9a311ec2011-02-12 12:33:06 +010051 */
52
Harald Welte9a311ec2011-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 Weltefdb71942011-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 Welte9a311ec2011-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 Welte0741ffe2011-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 Welte6fec79d2011-02-12 14:57:17 +010093 OM2K_MSGT_DISCONNECT_CMD = 0x0030,
94 OM2K_MSGT_DISCONNECT_COMPL = 0x0032,
95 OM2K_MSGT_DISCONNECT_REJ = 0x0033,
Harald Welte0741ffe2011-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 Welte6fec79d2011-02-12 14:57:17 +0100102
Harald Welte9a311ec2011-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 Weltea0ce3492011-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 Welte9a311ec2011-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 Weltee1d5eca2011-02-12 14:42:59 +0100132 OM2K_MSGT_STATUS_REQ = 0x008c,
133 OM2K_MSGT_STATUS_RESP = 0x008e,
134 OM2K_MSGT_STATUS_REJ = 0x008f,
Harald Welte9a311ec2011-02-12 12:33:06 +0100135
Harald Welte8024d8f2011-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 Weltef9cf9612011-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 Weltea0ce3492011-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 Welte9a311ec2011-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 Weltea0ce3492011-03-05 14:13:14 +0100168 OM2K_DEI_BCC = 0x06,
Harald Welte1164dce2011-03-05 19:21:26 +0100169 OM2K_DEI_BS_AG_BKS_RES = 0x07,
Harald Weltea0ce3492011-03-05 14:13:14 +0100170 OM2K_DEI_BSIC = 0x09,
Harald Welte1164dce2011-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 Welte9a311ec2011-02-12 12:33:06 +0100174 OM2K_DEI_CAL_TIME = 0x0d,
Harald Weltea0ce3492011-03-05 14:13:14 +0100175 OM2K_DEI_COMBINATION = 0x0f,
Harald Weltefdb71942011-02-14 15:31:43 +0100176 OM2K_DEI_CON_CONN_LIST = 0x10,
Harald Welte1164dce2011-03-05 19:21:26 +0100177 OM2K_DEI_DRX_DEV_MAX = 0x12,
Harald Welte8bcb1a02011-02-12 20:23:40 +0100178 OM2K_DEI_END_LIST_NR = 0x13,
Harald Weltef6d6b212011-03-05 20:13:52 +0100179 OM2K_DEI_EXT_COND_MAP_1 = 0x14,
180 OM2K_DEI_EXT_COND_MAP_2 = 0x15,
Harald Weltea0ce3492011-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 Welte1164dce2011-03-05 19:21:26 +0100187 OM2K_DEI_ICM_INDICATOR = 0x22,
Harald Weltef6d6b212011-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 Welte8bcb1a02011-02-12 20:23:40 +0100192 OM2K_DEI_IS_CONN_LIST = 0x27,
193 OM2K_DEI_LIST_NR = 0x28,
Harald Weltef6d6b212011-03-05 20:13:52 +0100194 OM2K_DEI_LOCAL_ACCESS = 0x2a,
Harald Weltea0ce3492011-03-05 14:13:14 +0100195 OM2K_DEI_MAIO = 0x2b,
Harald Weltef6d6b212011-03-05 20:13:52 +0100196 OM2K_DEI_MO_STATE = 0x2c,
Harald Welte1164dce2011-03-05 19:21:26 +0100197 OM2K_DEI_NY1 = 0x2d,
Harald Welte9a311ec2011-02-12 12:33:06 +0100198 OM2K_DEI_OP_INFO = 0x2e,
Harald Weltea0ce3492011-03-05 14:13:14 +0100199 OM2K_DEI_POWER = 0x2f,
Harald Weltee6e83832011-03-05 17:52:09 +0100200 OM2K_DEI_REASON_CODE = 0x32,
Harald Weltea0ce3492011-03-05 14:13:14 +0100201 OM2K_DEI_RX_DIVERSITY = 0x33,
Harald Weltee6e83832011-03-05 17:52:09 +0100202 OM2K_DEI_RESULT_CODE = 0x35,
Harald Welte1164dce2011-03-05 19:21:26 +0100203 OM2K_DEI_T3105 = 0x38,
Harald Weltef9cf9612011-03-05 14:36:47 +0100204 OM2K_DEI_TF_MODE = 0x3a,
Harald Weltea0ce3492011-03-05 14:13:14 +0100205 OM2K_DEI_TS_NR = 0x3c,
Harald Welte1164dce2011-03-05 19:21:26 +0100206 OM2K_DEI_TSC = 0x3d,
Harald Weltef6d6b212011-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 Weltea0ce3492011-03-05 14:13:14 +0100214 OM2K_DEI_EXT_RANGE = 0x47,
Harald Weltef6d6b212011-03-05 20:13:52 +0100215 OM2K_DEI_REQ_IND = 0x48,
216 OM2K_DEI_REPL_UNIT_MAP = 0x50,
Harald Welte75755c52011-03-05 20:38:35 +0100217 OM2K_DEI_ICM_BOUND_PARAMS = 0x74,
Harald Welte1164dce2011-03-05 19:21:26 +0100218 OM2K_DEI_LSC = 0x79,
219 OM2K_DEI_LSC_FILT_TIME = 0x7a,
220 OM2K_DEI_CALL_SUPV_TIME = 0x7b,
Harald Welte75755c52011-03-05 20:38:35 +0100221 OM2K_DEI_ICM_CHAN_RATE = 0x7e,
Harald Weltef6d6b212011-03-05 20:13:52 +0100222 OM2K_DEI_HW_INFO_SIG = 0x84,
Harald Welteba9adbb2011-03-06 19:01:16 +0100223 OM2K_DEI_TF_SYNC_SRC = 0x86,
Harald Welte1164dce2011-03-05 19:21:26 +0100224 OM2K_DEI_TTA = 0x87,
Harald Weltef6d6b212011-03-05 20:13:52 +0100225 OM2K_DEI_CAPA_SIG = 0x8a,
Harald Welte73541072011-02-12 13:44:14 +0100226 OM2K_DEI_NEGOT_REC1 = 0x90,
227 OM2K_DEI_NEGOT_REC2 = 0x91,
Harald Welte1164dce2011-03-05 19:21:26 +0100228 OM2K_DEI_ENCR_ALG = 0x92,
229 OM2K_DEI_INTERF_REJ_COMB = 0x94,
Harald Weltef9cf9612011-03-05 14:36:47 +0100230 OM2K_DEI_FS_OFFSET = 0x98,
Harald Weltef6d6b212011-03-05 20:13:52 +0100231 OM2K_DEI_EXT_COND_MAP_2_EXT = 0x9c,
Harald Welte9a311ec2011-02-12 12:33:06 +0100232};
233
Harald Weltee6e83832011-03-05 17:52:09 +0100234const struct tlv_definition om2k_att_tlvdef = {
235 .def = {
236 [OM2K_DEI_BCC] = { TLV_TYPE_TV },
Harald Welte1164dce2011-03-05 19:21:26 +0100237 [OM2K_DEI_BS_AG_BKS_RES] = { TLV_TYPE_TV },
Harald Weltee6e83832011-03-05 17:52:09 +0100238 [OM2K_DEI_BSIC] = { TLV_TYPE_TV },
Harald Welte1164dce2011-03-05 19:21:26 +0100239 [OM2K_DEI_BA_PA_MFRMS] = { TLV_TYPE_TV },
240 [OM2K_DEI_CBCH_INDICATOR] = { TLV_TYPE_TV },
Harald Weltef6d6b212011-03-05 20:13:52 +0100241 [OM2K_DEI_INT_FAULT_MAP_1A] = { TLV_TYPE_FIXED, 6 },
242 [OM2K_DEI_INT_FAULT_MAP_1B] = { TLV_TYPE_FIXED, 6 },
243 [OM2K_DEI_INT_FAULT_MAP_2A] = { TLV_TYPE_FIXED, 6 },
244 [OM2K_DEI_INT_FAULT_MAP_2A_EXT]={ TLV_TYPE_FIXED, 6 },
Harald Welte1164dce2011-03-05 19:21:26 +0100245 [OM2K_DEI_CCCH_OPTIONS] = { TLV_TYPE_TV },
Harald Weltee6e83832011-03-05 17:52:09 +0100246 [OM2K_DEI_CAL_TIME] = { TLV_TYPE_FIXED, 6 },
247 [OM2K_DEI_COMBINATION] = { TLV_TYPE_TV },
248 [OM2K_DEI_CON_CONN_LIST] = { TLV_TYPE_TLV },
Harald Welte1164dce2011-03-05 19:21:26 +0100249 [OM2K_DEI_DRX_DEV_MAX] = { TLV_TYPE_TV },
Harald Weltee6e83832011-03-05 17:52:09 +0100250 [OM2K_DEI_END_LIST_NR] = { TLV_TYPE_TV },
Harald Weltef6d6b212011-03-05 20:13:52 +0100251 [OM2K_DEI_EXT_COND_MAP_1] = { TLV_TYPE_FIXED, 2 },
252 [OM2K_DEI_EXT_COND_MAP_2] = { TLV_TYPE_FIXED, 2 },
Harald Weltee6e83832011-03-05 17:52:09 +0100253 [OM2K_DEI_FILLING_MARKER] = { TLV_TYPE_TV },
254 [OM2K_DEI_FN_OFFSET] = { TLV_TYPE_FIXED, 2 },
255 [OM2K_DEI_FREQ_LIST] = { TLV_TYPE_TLV },
256 [OM2K_DEI_FREQ_SPEC_RX] = { TLV_TYPE_FIXED, 2 },
257 [OM2K_DEI_FREQ_SPEC_TX] = { TLV_TYPE_FIXED, 2 },
258 [OM2K_DEI_HSN] = { TLV_TYPE_TV },
Harald Welte1164dce2011-03-05 19:21:26 +0100259 [OM2K_DEI_ICM_INDICATOR] = { TLV_TYPE_TV },
Harald Weltee6e83832011-03-05 17:52:09 +0100260 [OM2K_DEI_IS_CONN_LIST] = { TLV_TYPE_TLV },
261 [OM2K_DEI_LIST_NR] = { TLV_TYPE_TV },
Harald Weltef6d6b212011-03-05 20:13:52 +0100262 [OM2K_DEI_LOCAL_ACCESS] = { TLV_TYPE_TV },
Harald Weltee6e83832011-03-05 17:52:09 +0100263 [OM2K_DEI_MAIO] = { TLV_TYPE_TV },
Harald Weltef6d6b212011-03-05 20:13:52 +0100264 [OM2K_DEI_MO_STATE] = { TLV_TYPE_TV },
Harald Welte1164dce2011-03-05 19:21:26 +0100265 [OM2K_DEI_NY1] = { TLV_TYPE_TV },
Harald Weltee6e83832011-03-05 17:52:09 +0100266 [OM2K_DEI_OP_INFO] = { TLV_TYPE_TV },
267 [OM2K_DEI_POWER] = { TLV_TYPE_TV },
268 [OM2K_DEI_REASON_CODE] = { TLV_TYPE_TV },
269 [OM2K_DEI_RX_DIVERSITY] = { TLV_TYPE_TV },
270 [OM2K_DEI_RESULT_CODE] = { TLV_TYPE_TV },
Harald Welte1164dce2011-03-05 19:21:26 +0100271 [OM2K_DEI_T3105] = { TLV_TYPE_TV },
Harald Weltee6e83832011-03-05 17:52:09 +0100272 [OM2K_DEI_TF_MODE] = { TLV_TYPE_TV },
273 [OM2K_DEI_TS_NR] = { TLV_TYPE_TV },
Harald Welte1164dce2011-03-05 19:21:26 +0100274 [OM2K_DEI_TSC] = { TLV_TYPE_TV },
Harald Weltef6d6b212011-03-05 20:13:52 +0100275 [OM2K_DEI_BTS_VERSION] = { TLV_TYPE_FIXED, 12 },
276 [OM2K_DEI_OML_IWD_VERSION] = { TLV_TYPE_FIXED, 6 },
277 [OM2K_DEI_RSL_IWD_VERSION] = { TLV_TYPE_FIXED, 6 },
278 [OM2K_DEI_OML_FUNC_MAP_1] = { TLV_TYPE_TLV },
279 [OM2K_DEI_OML_FUNC_MAP_2] = { TLV_TYPE_TLV },
280 [OM2K_DEI_RSL_FUNC_MAP_1] = { TLV_TYPE_TLV },
281 [OM2K_DEI_RSL_FUNC_MAP_2] = { TLV_TYPE_TLV },
Harald Weltee6e83832011-03-05 17:52:09 +0100282 [OM2K_DEI_EXT_RANGE] = { TLV_TYPE_TV },
Harald Weltef6d6b212011-03-05 20:13:52 +0100283 [OM2K_DEI_REQ_IND] = { TLV_TYPE_TV },
284 [OM2K_DEI_REPL_UNIT_MAP] = { TLV_TYPE_FIXED, 6 },
Harald Welte75755c52011-03-05 20:38:35 +0100285 [OM2K_DEI_ICM_BOUND_PARAMS] = { TLV_TYPE_FIXED, 5 },
Harald Welte1164dce2011-03-05 19:21:26 +0100286 [OM2K_DEI_LSC] = { TLV_TYPE_TV },
287 [OM2K_DEI_LSC_FILT_TIME] = { TLV_TYPE_TV },
288 [OM2K_DEI_CALL_SUPV_TIME] = { TLV_TYPE_TV },
Harald Welte75755c52011-03-05 20:38:35 +0100289 [OM2K_DEI_ICM_CHAN_RATE] = { TLV_TYPE_TV },
Harald Weltef6d6b212011-03-05 20:13:52 +0100290 [OM2K_DEI_HW_INFO_SIG] = { TLV_TYPE_FIXED, 2 },
Harald Welteba9adbb2011-03-06 19:01:16 +0100291 [OM2K_DEI_TF_SYNC_SRC] = { TLV_TYPE_TV },
Harald Welte1164dce2011-03-05 19:21:26 +0100292 [OM2K_DEI_TTA] = { TLV_TYPE_TV },
Harald Weltef6d6b212011-03-05 20:13:52 +0100293 [OM2K_DEI_CAPA_SIG] = { TLV_TYPE_FIXED, 2 },
Harald Weltee6e83832011-03-05 17:52:09 +0100294 [OM2K_DEI_NEGOT_REC1] = { TLV_TYPE_TLV },
295 [OM2K_DEI_NEGOT_REC2] = { TLV_TYPE_TLV },
Harald Welte1164dce2011-03-05 19:21:26 +0100296 [OM2K_DEI_ENCR_ALG] = { TLV_TYPE_TV },
297 [OM2K_DEI_INTERF_REJ_COMB] = { TLV_TYPE_TV },
Harald Weltee6e83832011-03-05 17:52:09 +0100298 [OM2K_DEI_FS_OFFSET] = { TLV_TYPE_FIXED, 5 },
Harald Weltef6d6b212011-03-05 20:13:52 +0100299 [OM2K_DEI_EXT_COND_MAP_2_EXT] = { TLV_TYPE_FIXED, 4 },
Harald Weltee6e83832011-03-05 17:52:09 +0100300 },
301};
302
Harald Welte9a311ec2011-02-12 12:33:06 +0100303static const struct value_string om2k_msgcode_vals[] = {
304 { 0x0000, "Abort SP Command" },
305 { 0x0002, "Abort SP Complete" },
306 { 0x0004, "Alarm Report ACK" },
307 { 0x0005, "Alarm Report NACK" },
308 { 0x0006, "Alarm Report" },
309 { 0x0008, "Alarm Status Request" },
310 { 0x000a, "Alarm Status Request Accept" },
311 { 0x000b, "Alarm Status Request Reject" },
312 { 0x000c, "Alarm Status Result ACK" },
313 { 0x000d, "Alarm Status Result NACK" },
314 { 0x000e, "Alarm Status Result" },
315 { 0x0010, "Calendar Time Response" },
316 { 0x0011, "Calendar Time Reject" },
317 { 0x0012, "Calendar Time Request" },
318 { 0x0014, "CON Configuration Request" },
319 { 0x0016, "CON Configuration Request Accept" },
320 { 0x0017, "CON Configuration Request Reject" },
321 { 0x0018, "CON Configuration Result ACK" },
322 { 0x0019, "CON Configuration Result NACK" },
323 { 0x001a, "CON Configuration Result" },
324 { 0x001c, "Connect Command" },
325 { 0x001e, "Connect Complete" },
Harald Welte3ede7232011-03-05 17:58:13 +0100326 { 0x001f, "Connect Reject" },
Harald Welte9a311ec2011-02-12 12:33:06 +0100327 { 0x0028, "Disable Request" },
328 { 0x002a, "Disable Request Accept" },
329 { 0x002b, "Disable Request Reject" },
330 { 0x002c, "Disable Result ACK" },
331 { 0x002d, "Disable Result NACK" },
332 { 0x002e, "Disable Result" },
333 { 0x0030, "Disconnect Command" },
334 { 0x0032, "Disconnect Complete" },
335 { 0x0033, "Disconnect Reject" },
336 { 0x0034, "Enable Request" },
337 { 0x0036, "Enable Request Accept" },
338 { 0x0037, "Enable Request Reject" },
339 { 0x0038, "Enable Result ACK" },
340 { 0x0039, "Enable Result NACK" },
341 { 0x003a, "Enable Result" },
342 { 0x003c, "Escape Downlink Normal" },
343 { 0x003d, "Escape Downlink NACK" },
344 { 0x003e, "Escape Uplink Normal" },
345 { 0x003f, "Escape Uplink NACK" },
346 { 0x0040, "Fault Report ACK" },
347 { 0x0041, "Fault Report NACK" },
348 { 0x0042, "Fault Report" },
349 { 0x0044, "File Package End Command" },
350 { 0x0046, "File Package End Result" },
351 { 0x0047, "File Package End Reject" },
352 { 0x0048, "File Relation Request" },
353 { 0x004a, "File Relation Response" },
354 { 0x004b, "File Relation Request Reject" },
355 { 0x004c, "File Segment Transfer" },
356 { 0x004e, "File Segment Transfer Complete" },
357 { 0x004f, "File Segment Transfer Reject" },
358 { 0x0050, "HW Information Request" },
359 { 0x0052, "HW Information Request Accept" },
360 { 0x0053, "HW Information Request Reject" },
361 { 0x0054, "HW Information Result ACK" },
362 { 0x0055, "HW Information Result NACK" },
363 { 0x0056, "HW Information Result" },
364 { 0x0060, "IS Configuration Request" },
365 { 0x0062, "IS Configuration Request Accept" },
366 { 0x0063, "IS Configuration Request Reject" },
367 { 0x0064, "IS Configuration Result ACK" },
368 { 0x0065, "IS Configuration Result NACK" },
369 { 0x0066, "IS Configuration Result" },
370 { 0x0068, "Load Data End" },
371 { 0x006a, "Load Data End Result" },
372 { 0x006b, "Load Data End Reject" },
373 { 0x006c, "Load Data Init" },
374 { 0x006e, "Load Data Init Accept" },
375 { 0x006f, "Load Data Init Reject" },
376 { 0x0070, "Loop Control Command" },
377 { 0x0072, "Loop Control Complete" },
378 { 0x0073, "Loop Control Reject" },
379 { 0x0074, "Operational Information" },
380 { 0x0076, "Operational Information Accept" },
381 { 0x0077, "Operational Information Reject" },
382 { 0x0078, "Reset Command" },
383 { 0x007a, "Reset Complete" },
384 { 0x007b, "Reset Reject" },
385 { 0x007c, "RX Configuration Request" },
386 { 0x007e, "RX Configuration Request Accept" },
387 { 0x007f, "RX Configuration Request Reject" },
388 { 0x0080, "RX Configuration Result ACK" },
389 { 0x0081, "RX Configuration Result NACK" },
390 { 0x0082, "RX Configuration Result" },
391 { 0x0084, "Start Request" },
392 { 0x0086, "Start Request Accept" },
393 { 0x0087, "Start Request Reject" },
394 { 0x0088, "Start Result ACK" },
395 { 0x0089, "Start Result NACK" },
396 { 0x008a, "Start Result" },
397 { 0x008c, "Status Request" },
398 { 0x008e, "Status Response" },
399 { 0x008f, "Status Reject" },
400 { 0x0094, "Test Request" },
401 { 0x0096, "Test Request Accept" },
402 { 0x0097, "Test Request Reject" },
403 { 0x0098, "Test Result ACK" },
404 { 0x0099, "Test Result NACK" },
405 { 0x009a, "Test Result" },
406 { 0x00a0, "TF Configuration Request" },
407 { 0x00a2, "TF Configuration Request Accept" },
408 { 0x00a3, "TF Configuration Request Reject" },
409 { 0x00a4, "TF Configuration Result ACK" },
410 { 0x00a5, "TF Configuration Result NACK" },
411 { 0x00a6, "TF Configuration Result" },
412 { 0x00a8, "TS Configuration Request" },
413 { 0x00aa, "TS Configuration Request Accept" },
414 { 0x00ab, "TS Configuration Request Reject" },
415 { 0x00ac, "TS Configuration Result ACK" },
416 { 0x00ad, "TS Configuration Result NACK" },
417 { 0x00ae, "TS Configuration Result" },
418 { 0x00b0, "TX Configuration Request" },
419 { 0x00b2, "TX Configuration Request Accept" },
420 { 0x00b3, "TX Configuration Request Reject" },
421 { 0x00b4, "TX Configuration Result ACK" },
422 { 0x00b5, "TX Configuration Result NACK" },
423 { 0x00b6, "TX Configuration Result" },
424 { 0x00bc, "DIP Alarm Report ACK" },
425 { 0x00bd, "DIP Alarm Report NACK" },
426 { 0x00be, "DIP Alarm Report" },
427 { 0x00c0, "DIP Alarm Status Request" },
428 { 0x00c2, "DIP Alarm Status Response" },
429 { 0x00c3, "DIP Alarm Status Reject" },
430 { 0x00c4, "DIP Quality Report I ACK" },
431 { 0x00c5, "DIP Quality Report I NACK" },
432 { 0x00c6, "DIP Quality Report I" },
433 { 0x00c8, "DIP Quality Report II ACK" },
434 { 0x00c9, "DIP Quality Report II NACK" },
435 { 0x00ca, "DIP Quality Report II" },
436 { 0x00dc, "DP Configuration Request" },
437 { 0x00de, "DP Configuration Request Accept" },
438 { 0x00df, "DP Configuration Request Reject" },
439 { 0x00e0, "DP Configuration Result ACK" },
440 { 0x00e1, "DP Configuration Result NACK" },
441 { 0x00e2, "DP Configuration Result" },
442 { 0x00e4, "Capabilities HW Info Report ACK" },
443 { 0x00e5, "Capabilities HW Info Report NACK" },
444 { 0x00e6, "Capabilities HW Info Report" },
445 { 0x00e8, "Capabilities Request" },
446 { 0x00ea, "Capabilities Request Accept" },
447 { 0x00eb, "Capabilities Request Reject" },
448 { 0x00ec, "Capabilities Result ACK" },
449 { 0x00ed, "Capabilities Result NACK" },
450 { 0x00ee, "Capabilities Result" },
451 { 0x00f0, "FM Configuration Request" },
452 { 0x00f2, "FM Configuration Request Accept" },
453 { 0x00f3, "FM Configuration Request Reject" },
454 { 0x00f4, "FM Configuration Result ACK" },
455 { 0x00f5, "FM Configuration Result NACK" },
456 { 0x00f6, "FM Configuration Result" },
457 { 0x00f8, "FM Report Request" },
458 { 0x00fa, "FM Report Response" },
459 { 0x00fb, "FM Report Reject" },
460 { 0x00fc, "FM Start Command" },
461 { 0x00fe, "FM Start Complete" },
462 { 0x00ff, "FM Start Reject" },
463 { 0x0100, "FM Stop Command" },
464 { 0x0102, "FM Stop Complete" },
465 { 0x0103, "FM Stop Reject" },
466 { 0x0104, "Negotiation Request ACK" },
467 { 0x0105, "Negotiation Request NACK" },
468 { 0x0106, "Negotiation Request" },
469 { 0x0108, "BTS Initiated Request ACK" },
470 { 0x0109, "BTS Initiated Request NACK" },
471 { 0x010a, "BTS Initiated Request" },
472 { 0x010c, "Radio Channels Release Command" },
473 { 0x010e, "Radio Channels Release Complete" },
474 { 0x010f, "Radio Channels Release Reject" },
475 { 0x0118, "Feature Control Command" },
476 { 0x011a, "Feature Control Complete" },
477 { 0x011b, "Feature Control Reject" },
478
479 { 0, NULL }
480};
481
482/* TS 12.21 Section 9.4: Attributes */
483static const struct value_string om2k_attr_vals[] = {
484 { 0x00, "Accordance indication" },
485 { 0x01, "Alarm Id" },
486 { 0x02, "Alarm Data" },
487 { 0x03, "Alarm Severity" },
488 { 0x04, "Alarm Status" },
489 { 0x05, "Alarm Status Type" },
490 { 0x06, "BCC" },
491 { 0x07, "BS_AG_BKS_RES" },
492 { 0x09, "BSIC" },
493 { 0x0a, "BA_PA_MFRMS" },
494 { 0x0b, "CBCH Indicator" },
495 { 0x0c, "CCCH Options" },
496 { 0x0d, "Calendar Time" },
497 { 0x0f, "Channel Combination" },
498 { 0x10, "CON Connection List" },
499 { 0x11, "Data End Indication" },
500 { 0x12, "DRX_DEV_MAX" },
501 { 0x13, "End List Number" },
502 { 0x14, "External Condition Map Class 1" },
503 { 0x15, "External Condition Map Class 2" },
504 { 0x16, "File Relation Indication" },
505 { 0x17, "File Revision" },
506 { 0x18, "File Segment Data" },
507 { 0x19, "File Segment Length" },
508 { 0x1a, "File Segment Sequence Number" },
509 { 0x1b, "File Size" },
510 { 0x1c, "Filling Marker" },
511 { 0x1d, "FN Offset" },
512 { 0x1e, "Frequency List" },
513 { 0x1f, "Frequency Specifier RX" },
514 { 0x20, "Frequency Specifier TX" },
515 { 0x21, "HSN" },
516 { 0x22, "ICM Indicator" },
517 { 0x23, "Internal Fault Map Class 1A" },
518 { 0x24, "Internal Fault Map Class 1B" },
519 { 0x25, "Internal Fault Map Class 2A" },
520 { 0x26, "Internal Fault Map Class 2A Extension" },
521 { 0x27, "IS Connection List" },
522 { 0x28, "List Number" },
523 { 0x29, "File Package State Indication" },
524 { 0x2a, "Local Access State" },
525 { 0x2b, "MAIO" },
526 { 0x2c, "MO State" },
527 { 0x2d, "Ny1" },
528 { 0x2e, "Operational Information" },
529 { 0x2f, "Power" },
530 { 0x30, "RU Position Data" },
531 { 0x31, "Protocol Error" },
532 { 0x32, "Reason Code" },
533 { 0x33, "Receiver Diversity" },
534 { 0x34, "Replacement Unit Map" },
535 { 0x35, "Result Code" },
536 { 0x36, "RU Revision Data" },
537 { 0x38, "T3105" },
538 { 0x39, "Test Loop Setting" },
539 { 0x3a, "TF Mode" },
540 { 0x3b, "TF Compensation Value" },
541 { 0x3c, "Time Slot Number" },
542 { 0x3d, "TSC" },
543 { 0x3e, "RU Logical Id" },
544 { 0x3f, "RU Serial Number Data" },
545 { 0x40, "BTS Version" },
546 { 0x41, "OML IWD Version" },
547 { 0x42, "RWL IWD Version" },
548 { 0x43, "OML Function Map 1" },
549 { 0x44, "OML Function Map 2" },
550 { 0x45, "RSL Function Map 1" },
551 { 0x46, "RSL Function Map 2" },
552 { 0x47, "Extended Range Indicator" },
553 { 0x48, "Request Indicators" },
554 { 0x49, "DIP Alarm Condition Map" },
555 { 0x4a, "ES Incoming" },
556 { 0x4b, "ES Outgoing" },
557 { 0x4e, "SES Incoming" },
558 { 0x4f, "SES Outgoing" },
559 { 0x50, "Replacement Unit Map Extension" },
560 { 0x52, "UAS Incoming" },
561 { 0x53, "UAS Outgoing" },
562 { 0x58, "DF Incoming" },
563 { 0x5a, "DF Outgoing" },
564 { 0x5c, "SF" },
565 { 0x60, "S Bits Setting" },
566 { 0x61, "CRC-4 Use Option" },
567 { 0x62, "T Parameter" },
568 { 0x63, "N Parameter" },
569 { 0x64, "N1 Parameter" },
570 { 0x65, "N3 Parameter" },
571 { 0x66, "N4 Parameter" },
572 { 0x67, "P Parameter" },
573 { 0x68, "Q Parameter" },
574 { 0x69, "BI_Q1" },
575 { 0x6a, "BI_Q2" },
576 { 0x74, "ICM Boundary Parameters" },
577 { 0x77, "AFT" },
578 { 0x78, "AFT RAI" },
579 { 0x79, "Link Supervision Control" },
580 { 0x7a, "Link Supervision Filtering Time" },
581 { 0x7b, "Call Supervision Time" },
582 { 0x7c, "Interval Length UAS Incoming" },
583 { 0x7d, "Interval Length UAS Outgoing" },
584 { 0x7e, "ICM Channel Rate" },
585 { 0x7f, "Attribute Identifier" },
586 { 0x80, "FM Frequency List" },
587 { 0x81, "FM Frequency Report" },
588 { 0x82, "FM Percentile" },
589 { 0x83, "FM Clear Indication" },
590 { 0x84, "HW Info Signature" },
591 { 0x85, "MO Record" },
592 { 0x86, "TF Synchronisation Source" },
593 { 0x87, "TTA" },
594 { 0x88, "End Segment Number" },
595 { 0x89, "Segment Number" },
596 { 0x8a, "Capabilities Signature" },
597 { 0x8c, "File Relation List" },
598 { 0x90, "Negotiation Record I" },
599 { 0x91, "Negotiation Record II" },
600 { 0x92, "Encryption Algorithm" },
601 { 0x94, "Interference Rejection Combining" },
602 { 0x95, "Dedication Information" },
603 { 0x97, "Feature Code" },
604 { 0x98, "FS Offset" },
605 { 0x99, "ESB Timeslot" },
606 { 0x9a, "Master TG Instance" },
607 { 0x9b, "Master TX Chain Delay" },
608 { 0x9c, "External Condition Class 2 Extension" },
609 { 0x9d, "TSs MO State" },
610 { 0, NULL }
611};
612
Harald Weltee1d5eca2011-02-12 14:42:59 +0100613const struct value_string om2k_mo_class_short_vals[] = {
Harald Welte9a311ec2011-02-12 12:33:06 +0100614 { 0x01, "TRXC" },
615 { 0x03, "TS" },
616 { 0x04, "TF" },
617 { 0x05, "IS" },
618 { 0x06, "CON" },
619 { 0x07, "DP" },
620 { 0x0a, "CF" },
621 { 0x0b, "TX" },
622 { 0x0c, "RX" },
623 { 0, NULL }
624};
625
626static struct msgb *om2k_msgb_alloc(void)
627{
628 return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE,
629 "OM2000");
630}
631
Harald Weltee6e83832011-03-05 17:52:09 +0100632static int abis_om2k_tlv_parse(struct tlv_parsed *tp, const u_int8_t *buf, int len)
633{
634 return tlv_parse(tp, &om2k_att_tlvdef, buf, len, 0, 0);
635}
636
Harald Welted88a3872011-02-14 15:26:13 +0100637static char *om2k_mo_name(const struct abis_om2k_mo *mo)
638{
639 static char mo_buf[64];
640
641 memset(mo_buf, 0, sizeof(mo_buf));
642 snprintf(mo_buf, sizeof(mo_buf), "%s/%02x/%02x/%02x",
643 get_value_string(om2k_mo_class_short_vals, mo->class),
644 mo->bts, mo->assoc_so, mo->inst);
645 return mo_buf;
646}
647
Harald Weltebc867d92011-02-12 13:09:38 +0100648static int abis_om2k_sendmsg(struct gsm_bts *bts, struct msgb *msg)
649{
Harald Welted88a3872011-02-14 15:26:13 +0100650 struct abis_om2k_hdr *o2h;
651 int to_trx_oml;
Harald Weltebc867d92011-02-12 13:09:38 +0100652
Harald Welted88a3872011-02-14 15:26:13 +0100653 msg->l2h = msg->data;
654 o2h = (struct abis_om2k_hdr *) msg->l2h;
655
Harald Welte1164dce2011-03-05 19:21:26 +0100656 /* Compute the length in the OML header */
657 o2h->om.length = 6 + msgb_l2len(msg)-sizeof(*o2h);
658
Harald Welted88a3872011-02-14 15:26:13 +0100659 switch (o2h->mo.class) {
660 case OM2K_MO_CLS_TRXC:
661 case OM2K_MO_CLS_TX:
662 case OM2K_MO_CLS_RX:
Harald Welted88a3872011-02-14 15:26:13 +0100663 /* Route through per-TRX OML Link to the appropriate TRX */
664 to_trx_oml = 1;
665 msg->trx = gsm_bts_trx_by_nr(bts, o2h->mo.inst);
666 if (!msg->trx) {
667 LOGP(DNM, LOGL_ERROR, "MO=%s Tx Dropping msg to "
668 "non-existing TRX\n", om2k_mo_name(&o2h->mo));
669 return -ENODEV;
670 }
671 break;
Harald Welte8aeac192011-03-05 20:15:09 +0100672 case OM2K_MO_CLS_TS:
673 /* Route through per-TRX OML Link to the appropriate TRX */
674 to_trx_oml = 1;
675 msg->trx = gsm_bts_trx_by_nr(bts, o2h->mo.assoc_so);
676 if (!msg->trx) {
677 LOGP(DNM, LOGL_ERROR, "MO=%s Tx Dropping msg to "
678 "non-existing TRX\n", om2k_mo_name(&o2h->mo));
679 return -ENODEV;
680 }
681 break;
Harald Welted88a3872011-02-14 15:26:13 +0100682 default:
683 /* Route through the IXU/DXU OML Link */
684 msg->trx = bts->c0;
685 to_trx_oml = 0;
686 break;
687 }
688
689 return _abis_nm_sendmsg(msg, to_trx_oml);
Harald Weltebc867d92011-02-12 13:09:38 +0100690}
691
Harald Welte9a311ec2011-02-12 12:33:06 +0100692static void fill_om2k_hdr(struct abis_om2k_hdr *o2h, const struct abis_om2k_mo *mo,
Harald Welte1164dce2011-03-05 19:21:26 +0100693 uint16_t msg_type)
Harald Welte9a311ec2011-02-12 12:33:06 +0100694{
695 o2h->om.mdisc = ABIS_OM_MDISC_FOM;
696 o2h->om.placement = ABIS_OM_PLACEMENT_ONLY;
697 o2h->om.sequence = 0;
Harald Welte1164dce2011-03-05 19:21:26 +0100698 /* We fill o2h->om.length later during om2k_sendmsg() */
Harald Welte9a311ec2011-02-12 12:33:06 +0100699 o2h->msg_type = htons(msg_type);
700 memcpy(&o2h->mo, mo, sizeof(o2h->mo));
701}
702
Harald Welte73541072011-02-12 13:44:14 +0100703const struct abis_om2k_mo om2k_mo_cf = { OM2K_MO_CLS_CF, 0, 0xFF, 0 };
Harald Welte8bcb1a02011-02-12 20:23:40 +0100704const struct abis_om2k_mo om2k_mo_is = { OM2K_MO_CLS_IS, 0, 0xFF, 0 };
Harald Weltefdb71942011-02-14 15:31:43 +0100705const struct abis_om2k_mo om2k_mo_con = { OM2K_MO_CLS_CON, 0, 0xFF, 0 };
Harald Weltef9cf9612011-03-05 14:36:47 +0100706const struct abis_om2k_mo om2k_mo_tf = { OM2K_MO_CLS_TF, 0, 0xFF, 0 };
Harald Welte9a311ec2011-02-12 12:33:06 +0100707
708static int abis_om2k_cal_time_resp(struct gsm_bts *bts)
709{
710 struct msgb *msg = om2k_msgb_alloc();
711 struct abis_om2k_hdr *o2k;
712 time_t tm_t;
713 struct tm *tm;
714
715 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100716 fill_om2k_hdr(o2k, &om2k_mo_cf, OM2K_MSGT_CAL_TIME_RESP);
Harald Welte9a311ec2011-02-12 12:33:06 +0100717
718 tm_t = time(NULL);
719 tm = localtime(&tm_t);
720
721 msgb_put_u8(msg, OM2K_DEI_CAL_TIME);
722 msgb_put_u8(msg, tm->tm_year % 100);
723 msgb_put_u8(msg, tm->tm_mon + 1);
724 msgb_put_u8(msg, tm->tm_mday);
725 msgb_put_u8(msg, tm->tm_hour);
726 msgb_put_u8(msg, tm->tm_min);
727 msgb_put_u8(msg, tm->tm_sec);
728
Harald Weltebc867d92011-02-12 13:09:38 +0100729 return abis_om2k_sendmsg(bts, msg);
Harald Welte9a311ec2011-02-12 12:33:06 +0100730}
731
Harald Welte6fec79d2011-02-12 14:57:17 +0100732static int abis_om2k_tx_simple(struct gsm_bts *bts, const struct abis_om2k_mo *mo,
Harald Welte9a311ec2011-02-12 12:33:06 +0100733 uint8_t msg_type)
734{
735 struct msgb *msg = om2k_msgb_alloc();
736 struct abis_om2k_hdr *o2k;
737
738 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100739 fill_om2k_hdr(o2k, mo, msg_type);
Harald Welte9a311ec2011-02-12 12:33:06 +0100740
Harald Welte73541072011-02-12 13:44:14 +0100741 DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo),
742 get_value_string(om2k_msgcode_vals, msg_type));
743
Harald Weltebc867d92011-02-12 13:09:38 +0100744 return abis_om2k_sendmsg(bts, msg);
Harald Welte9a311ec2011-02-12 12:33:06 +0100745}
746
Harald Welte6fec79d2011-02-12 14:57:17 +0100747int abis_om2k_tx_reset_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
Harald Welte73541072011-02-12 13:44:14 +0100748{
749 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_RESET_CMD);
750}
751
Harald Welte6fec79d2011-02-12 14:57:17 +0100752int abis_om2k_tx_start_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
Harald Welte73541072011-02-12 13:44:14 +0100753{
754 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_START_REQ);
755}
756
Harald Welte6fec79d2011-02-12 14:57:17 +0100757int abis_om2k_tx_status_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
Harald Weltee1d5eca2011-02-12 14:42:59 +0100758{
759 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_STATUS_REQ);
760}
761
Harald Welte6fec79d2011-02-12 14:57:17 +0100762int abis_om2k_tx_connect_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
763{
764 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_CONNECT_CMD);
765}
766
767int abis_om2k_tx_disconnect_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
768{
769 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_DISCONNECT_CMD);
770}
771
Harald Welte8024d8f2011-02-12 15:07:30 +0100772int abis_om2k_tx_test_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
773{
774 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_TEST_REQ);
775}
776
Harald Welte0741ffe2011-02-12 18:48:53 +0100777int abis_om2k_tx_enable_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
778{
779 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_ENABLE_REQ);
780}
781
782int abis_om2k_tx_disable_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
783{
784 return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_DISABLE_REQ);
785}
786
Harald Welte6fec79d2011-02-12 14:57:17 +0100787int abis_om2k_tx_op_info(struct gsm_bts *bts, const struct abis_om2k_mo *mo,
788 uint8_t operational)
Harald Welte9a311ec2011-02-12 12:33:06 +0100789{
790 struct msgb *msg = om2k_msgb_alloc();
791 struct abis_om2k_hdr *o2k;
792
793 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100794 fill_om2k_hdr(o2k, mo, OM2K_MSGT_OP_INFO);
Harald Welte9a311ec2011-02-12 12:33:06 +0100795
796 msgb_tv_put(msg, OM2K_DEI_OP_INFO, operational);
797
Harald Welte73541072011-02-12 13:44:14 +0100798 DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo),
799 get_value_string(om2k_msgcode_vals, OM2K_MSGT_OP_INFO));
800
Harald Weltebc867d92011-02-12 13:09:38 +0100801 return abis_om2k_sendmsg(bts, msg);
Harald Welte9a311ec2011-02-12 12:33:06 +0100802}
803
Harald Welte8bcb1a02011-02-12 20:23:40 +0100804int abis_om2k_tx_is_conf_req(struct gsm_bts *bts, struct om2k_is_conn_grp *cg,
805 unsigned int num_cg )
806{
807 struct msgb *msg = om2k_msgb_alloc();
808 struct abis_om2k_hdr *o2k;
809
810 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100811 fill_om2k_hdr(o2k, &om2k_mo_is, OM2K_MSGT_IS_CONF_REQ);
Harald Welte8bcb1a02011-02-12 20:23:40 +0100812
813 msgb_tv_put(msg, OM2K_DEI_LIST_NR, 1);
814 msgb_tv_put(msg, OM2K_DEI_END_LIST_NR, 1);
815
816 msgb_tlv_put(msg, OM2K_DEI_IS_CONN_LIST,
817 num_cg * sizeof(*cg), (uint8_t *)cg);
818
819 return abis_om2k_sendmsg(bts, msg);
820}
821
Harald Weltefdb71942011-02-14 15:31:43 +0100822int abis_om2k_tx_con_conf_req(struct gsm_bts *bts, uint8_t *data,
823 unsigned int len)
824{
825 struct msgb *msg = om2k_msgb_alloc();
826 struct abis_om2k_hdr *o2k;
827
828 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100829 fill_om2k_hdr(o2k, &om2k_mo_con, OM2K_MSGT_CON_CONF_REQ);
Harald Weltefdb71942011-02-14 15:31:43 +0100830
831 msgb_tv_put(msg, OM2K_DEI_LIST_NR, 1);
832 msgb_tv_put(msg, OM2K_DEI_END_LIST_NR, 1);
833
834 msgb_tlv_put(msg, OM2K_DEI_CON_CONN_LIST, len, data);
835
836 return abis_om2k_sendmsg(bts, msg);
837}
838
Harald Weltea0ce3492011-03-05 14:13:14 +0100839static void om2k_trx_to_mo(struct abis_om2k_mo *mo,
840 const struct gsm_bts_trx *trx,
841 enum abis_om2k_mo_cls cls)
842{
843 mo->class = cls;
844 mo->bts = 0;
845 mo->inst = trx->nr;
Harald Welte53492c82011-03-05 16:21:01 +0100846 mo->assoc_so = 255;
Harald Weltea0ce3492011-03-05 14:13:14 +0100847}
848
849static void om2k_ts_to_mo(struct abis_om2k_mo *mo,
850 const struct gsm_bts_trx_ts *ts)
851{
852 mo->class = OM2K_MO_CLS_TS;
853 mo->bts = 0;
854 mo->inst = ts->nr;
855 mo->assoc_so = ts->trx->nr;
856}
857
858/* Configure a Receiver MO */
859int abis_om2k_tx_rx_conf_req(struct gsm_bts_trx *trx)
860{
861 struct msgb *msg = om2k_msgb_alloc();
862 struct abis_om2k_hdr *o2k;
863 struct abis_om2k_mo mo;
864
865 om2k_trx_to_mo(&mo, trx, OM2K_MO_CLS_RX);
866
867 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100868 fill_om2k_hdr(o2k, &mo, OM2K_MSGT_RX_CONF_REQ);
Harald Weltea0ce3492011-03-05 14:13:14 +0100869
870 msgb_tv16_put(msg, OM2K_DEI_FREQ_SPEC_RX, trx->arfcn);
871 msgb_tv_put(msg, OM2K_DEI_RX_DIVERSITY, 0x03); /* A+B */
872
873 return abis_om2k_sendmsg(trx->bts, msg);
874}
875
876/* Configure a Transmitter MO */
877int abis_om2k_tx_tx_conf_req(struct gsm_bts_trx *trx)
878{
879 struct msgb *msg = om2k_msgb_alloc();
880 struct abis_om2k_hdr *o2k;
881 struct abis_om2k_mo mo;
882
883 om2k_trx_to_mo(&mo, trx, OM2K_MO_CLS_TX);
884
885 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100886 fill_om2k_hdr(o2k, &mo, OM2K_MSGT_TX_CONF_REQ);
Harald Weltea0ce3492011-03-05 14:13:14 +0100887
888 msgb_tv16_put(msg, OM2K_DEI_FREQ_SPEC_TX, trx->arfcn);
889 msgb_tv_put(msg, OM2K_DEI_POWER, trx->nominal_power-trx->max_power_red);
890 msgb_tv_put(msg, OM2K_DEI_FILLING_MARKER, 0); /* Filling enabled */
891 msgb_tv_put(msg, OM2K_DEI_BCC, trx->bts->bsic & 0x7);
892 /* Dedication Information is optional */
893
894 return abis_om2k_sendmsg(trx->bts, msg);
895}
896
Harald Weltef9cf9612011-03-05 14:36:47 +0100897enum abis_om2k_tf_mode {
898 OM2K_TF_MODE_MASTER = 0x00,
899 OM2K_TF_MODE_STANDALONE = 0x01,
900 OM2K_TF_MODE_SLAVE = 0x02,
901 OM2K_TF_MODE_UNDEFINED = 0xff,
902};
903
904static const uint8_t fs_offset_undef[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
905
906int abis_om2k_tx_tf_conf_req(struct gsm_bts *bts)
907{
908 struct msgb *msg = om2k_msgb_alloc();
909 struct abis_om2k_hdr *o2k;
910
911 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100912 fill_om2k_hdr(o2k, &om2k_mo_tf, OM2K_MSGT_TF_CONF_REQ);
Harald Weltef9cf9612011-03-05 14:36:47 +0100913
914 msgb_tv_put(msg, OM2K_DEI_TF_MODE, OM2K_TF_MODE_STANDALONE);
Harald Welteba9adbb2011-03-06 19:01:16 +0100915 msgb_tv_put(msg, OM2K_DEI_TF_SYNC_SRC, 0x00);
Harald Weltef9cf9612011-03-05 14:36:47 +0100916 msgb_tv_fixed_put(msg, OM2K_DEI_FS_OFFSET,
917 sizeof(fs_offset_undef), fs_offset_undef);
918
919 return abis_om2k_sendmsg(bts, msg);
920}
921
Harald Weltea0ce3492011-03-05 14:13:14 +0100922static uint8_t pchan2comb(enum gsm_phys_chan_config pchan)
923{
924 switch (pchan) {
925 case GSM_PCHAN_CCCH:
926 return 4;
927 case GSM_PCHAN_CCCH_SDCCH4:
928 return 5;
929 case GSM_PCHAN_SDCCH8_SACCH8C:
930 return 3;
931 case GSM_PCHAN_TCH_F:
932 case GSM_PCHAN_TCH_H:
933 case GSM_PCHAN_PDCH:
934 case GSM_PCHAN_TCH_F_PDCH:
935 return 8;
936 default:
937 return 0;
938 }
939}
940
Harald Welte5748c202011-03-05 17:30:07 +0100941static int put_freq_list(uint8_t *buf, uint16_t arfcn)
942{
943 buf[0] = 0x00; /* TX/RX address */
944 buf[1] = (arfcn >> 8);
945 buf[2] = (arfcn & 0xff);
946
947 return 3;
948}
949
Harald Weltea0ce3492011-03-05 14:13:14 +0100950/* Compute a frequency list in OM2000 fomrmat */
951static int om2k_gen_freq_list(uint8_t *list, struct gsm_bts_trx_ts *ts)
952{
953 uint8_t *cur = list;
Harald Weltee6e83832011-03-05 17:52:09 +0100954 int len;
Harald Weltea0ce3492011-03-05 14:13:14 +0100955
956 if (ts->hopping.enabled) {
957 unsigned int i;
958 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
Harald Welte5748c202011-03-05 17:30:07 +0100959 if (bitvec_get_bit_pos(&ts->hopping.arfcns, i))
960 cur += put_freq_list(cur, i);
Harald Weltea0ce3492011-03-05 14:13:14 +0100961 }
Harald Welte5748c202011-03-05 17:30:07 +0100962 } else
963 cur += put_freq_list(cur, ts->trx->arfcn);
964
Harald Weltee6e83832011-03-05 17:52:09 +0100965 len = cur - list;
966
967 return len;
Harald Weltea0ce3492011-03-05 14:13:14 +0100968}
969
Harald Welte75755c52011-03-05 20:38:35 +0100970const uint8_t icm_bound_params[] = { 0x02, 0x06, 0x0c, 0x16, 0x06 };
971
Harald Weltea0ce3492011-03-05 14:13:14 +0100972int abis_om2k_tx_ts_conf_req(struct gsm_bts_trx_ts *ts)
973{
974 struct msgb *msg = om2k_msgb_alloc();
975 struct abis_om2k_hdr *o2k;
976 struct abis_om2k_mo mo;
977 uint8_t freq_list[64*3]; /* BA max size: 64 ARFCN */
978 int freq_list_len;
979
980 om2k_ts_to_mo(&mo, ts);
981
Harald Welte5748c202011-03-05 17:30:07 +0100982 memset(freq_list, 0, sizeof(freq_list));
Harald Weltea0ce3492011-03-05 14:13:14 +0100983 freq_list_len = om2k_gen_freq_list(freq_list, ts);
984 if (freq_list_len < 0)
985 return freq_list_len;
986
987 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +0100988 fill_om2k_hdr(o2k, &mo, OM2K_MSGT_TS_CONF_REQ);
Harald Weltea0ce3492011-03-05 14:13:14 +0100989
990 msgb_tv_put(msg, OM2K_DEI_COMBINATION, pchan2comb(ts->pchan));
991 msgb_tv_put(msg, OM2K_DEI_TS_NR, ts->nr);
992 msgb_tlv_put(msg, OM2K_DEI_FREQ_LIST, freq_list_len, freq_list);
993 msgb_tv_put(msg, OM2K_DEI_HSN, ts->hopping.hsn);
994 msgb_tv_put(msg, OM2K_DEI_MAIO, ts->hopping.maio);
995 msgb_tv_put(msg, OM2K_DEI_BSIC, ts->trx->bts->bsic);
996 msgb_tv_put(msg, OM2K_DEI_RX_DIVERSITY, 0x03); /* A+B */
997 msgb_tv16_put(msg, OM2K_DEI_FN_OFFSET, 0);
998 msgb_tv_put(msg, OM2K_DEI_EXT_RANGE, 0); /* Off */
999 /* Optional: Interference Rejection Combining */
Harald Welte1164dce2011-03-05 19:21:26 +01001000 msgb_tv_put(msg, OM2K_DEI_INTERF_REJ_COMB, 0x00);
1001 switch (ts->pchan) {
1002 case GSM_PCHAN_CCCH:
Harald Welte1164dce2011-03-05 19:21:26 +01001003 msgb_tv_put(msg, OM2K_DEI_BA_PA_MFRMS, 0x06);
1004 msgb_tv_put(msg, OM2K_DEI_BS_AG_BKS_RES, 0x01);
1005 msgb_tv_put(msg, OM2K_DEI_DRX_DEV_MAX, 0x05);
1006 /* Repeat Paging/IMM.ASS: True, Allow Paging Type 3: Yes, Page for 5 seconds (default) */
1007 msgb_tv_put(msg, OM2K_DEI_CCCH_OPTIONS, 0x01);
1008 break;
Harald Welte75755c52011-03-05 20:38:35 +01001009 case GSM_PCHAN_CCCH_SDCCH4:
1010 msgb_tv_put(msg, OM2K_DEI_T3105, 0x04);
1011 msgb_tv_put(msg, OM2K_DEI_NY1, 35);
1012 msgb_tv_put(msg, OM2K_DEI_BA_PA_MFRMS, 0x06);
1013 msgb_tv_put(msg, OM2K_DEI_CBCH_INDICATOR, 0);
1014 msgb_tv_put(msg, OM2K_DEI_TSC, ts->trx->bts->tsc);
1015 msgb_tv_put(msg, OM2K_DEI_BS_AG_BKS_RES, 0x01);
1016 msgb_tv_put(msg, OM2K_DEI_ICM_INDICATOR, 0);
1017 msgb_tv_put(msg, OM2K_DEI_DRX_DEV_MAX, 0x05);
1018 /* Repeat Paging/IMM.ASS: True, Allow Paging Type 3: Yes, Page for 5 seconds (default) */
1019 msgb_tv_put(msg, OM2K_DEI_CCCH_OPTIONS, 0x01);
1020 msgb_tv_fixed_put(msg, OM2K_DEI_ICM_BOUND_PARAMS,
1021 sizeof(icm_bound_params), icm_bound_params);
1022 break;
Harald Welte1164dce2011-03-05 19:21:26 +01001023 case GSM_PCHAN_SDCCH8_SACCH8C:
1024 msgb_tv_put(msg, OM2K_DEI_T3105, 0x04);
1025 msgb_tv_put(msg, OM2K_DEI_NY1, 35);
1026 msgb_tv_put(msg, OM2K_DEI_CBCH_INDICATOR, 0);
1027 msgb_tv_put(msg, OM2K_DEI_TSC, ts->trx->bts->tsc);
1028 /* Disable RF RESOURCE INDICATION on idle channels */
1029 msgb_tv_put(msg, OM2K_DEI_ICM_INDICATOR, 0);
Harald Welte75755c52011-03-05 20:38:35 +01001030 msgb_tv_fixed_put(msg, OM2K_DEI_ICM_BOUND_PARAMS,
1031 sizeof(icm_bound_params), icm_bound_params);
Harald Welte1164dce2011-03-05 19:21:26 +01001032 break;
1033 default:
1034 msgb_tv_put(msg, OM2K_DEI_T3105, 0x04);
1035 msgb_tv_put(msg, OM2K_DEI_NY1, 35);
Harald Welte1164dce2011-03-05 19:21:26 +01001036 msgb_tv_put(msg, OM2K_DEI_TSC, ts->trx->bts->tsc);
1037 /* Disable RF RESOURCE INDICATION on idle channels */
1038 msgb_tv_put(msg, OM2K_DEI_ICM_INDICATOR, 0);
Harald Welte75755c52011-03-05 20:38:35 +01001039 msgb_tv_fixed_put(msg, OM2K_DEI_ICM_BOUND_PARAMS,
1040 sizeof(icm_bound_params), icm_bound_params);
Harald Welte1164dce2011-03-05 19:21:26 +01001041 msgb_tv_put(msg, OM2K_DEI_TTA, 10); /* Timer for Time Alignment */
Harald Welte75755c52011-03-05 20:38:35 +01001042 if (ts->pchan == GSM_PCHAN_TCH_H)
1043 msgb_tv_put(msg, OM2K_DEI_ICM_CHAN_RATE, 1); /* TCH/H */
1044 else
1045 msgb_tv_put(msg, OM2K_DEI_ICM_CHAN_RATE, 0); /* TCH/F */
Harald Welte1164dce2011-03-05 19:21:26 +01001046 msgb_tv_put(msg, OM2K_DEI_LSC, 1); /* enabled */
1047 msgb_tv_put(msg, OM2K_DEI_LSC_FILT_TIME, 160); /* units of 100ms */
1048 msgb_tv_put(msg, OM2K_DEI_CALL_SUPV_TIME, 8);
1049 msgb_tv_put(msg, OM2K_DEI_ENCR_ALG, 0x00);
1050 /* FIXME: do we need 9e/9f/a0? */
1051 break;
1052 }
Harald Weltea0ce3492011-03-05 14:13:14 +01001053
1054 return abis_om2k_sendmsg(ts->trx->bts, msg);
1055}
Harald Weltefdb71942011-02-14 15:31:43 +01001056
Harald Welte6fec79d2011-02-12 14:57:17 +01001057static int abis_om2k_tx_negot_req_ack(struct gsm_bts *bts, const struct abis_om2k_mo *mo,
Harald Welte73541072011-02-12 13:44:14 +01001058 uint8_t *data, unsigned int len)
1059{
1060 struct msgb *msg = om2k_msgb_alloc();
1061 struct abis_om2k_hdr *o2k;
1062
1063 o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
Harald Welte1164dce2011-03-05 19:21:26 +01001064 fill_om2k_hdr(o2k, mo, OM2K_MSGT_NEGOT_REQ_ACK);
Harald Welte73541072011-02-12 13:44:14 +01001065
1066 msgb_tlv_put(msg, OM2K_DEI_NEGOT_REC2, len, data);
1067
1068 DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo),
1069 get_value_string(om2k_msgcode_vals, OM2K_MSGT_NEGOT_REQ_ACK));
1070
1071 return abis_om2k_sendmsg(bts, msg);
1072}
Harald Welte9a311ec2011-02-12 12:33:06 +01001073
Harald Welte563d3162011-02-12 18:11:16 +01001074struct iwd_version {
1075 uint8_t gen_char[3+1];
1076 uint8_t rev_char[3+1];
1077};
1078
1079struct iwd_type {
1080 uint8_t num_vers;
1081 struct iwd_version v[8];
1082};
1083
Harald Welte9a311ec2011-02-12 12:33:06 +01001084static int om2k_rx_negot_req(struct msgb *msg)
1085{
1086 struct abis_om2k_hdr *o2h = msgb_l2(msg);
Harald Welte563d3162011-02-12 18:11:16 +01001087 struct iwd_type iwd_types[16];
1088 uint8_t num_iwd_types = o2h->data[2];
1089 uint8_t *cur = o2h->data+3;
1090 unsigned int i, v;
Harald Welte9a311ec2011-02-12 12:33:06 +01001091
Harald Welte563d3162011-02-12 18:11:16 +01001092 uint8_t out_buf[1024];
1093 uint8_t *out_cur = out_buf+1;
1094 uint8_t out_num_types = 0;
1095
1096 memset(iwd_types, 0, sizeof(iwd_types));
1097
1098 /* Parse the RBS-supported IWD versions into iwd_types array */
1099 for (i = 0; i < num_iwd_types; i++) {
1100 uint8_t num_versions = *cur++;
1101 uint8_t iwd_type = *cur++;
1102
1103 iwd_types[iwd_type].num_vers = num_versions;
1104
1105 for (v = 0; v < num_versions; v++) {
1106 struct iwd_version *iwd_v = &iwd_types[iwd_type].v[v];
1107
1108 memcpy(iwd_v->gen_char, cur, 3);
Harald Welte56ee6b82011-02-12 18:13:37 +01001109 cur += 3;
1110 memcpy(iwd_v->rev_char, cur, 3);
1111 cur += 3;
1112
Harald Welte563d3162011-02-12 18:11:16 +01001113 DEBUGP(DNM, "\tIWD Type %u Gen %s Rev %s\n", iwd_type,
1114 iwd_v->gen_char, iwd_v->rev_char);
1115 }
1116 }
1117
1118 /* Select the last version for each IWD type */
1119 for (i = 0; i < ARRAY_SIZE(iwd_types); i++) {
1120 struct iwd_type *type = &iwd_types[i];
1121 struct iwd_version *last_v;
1122
1123 if (type->num_vers == 0)
1124 continue;
1125
1126 out_num_types++;
1127
1128 last_v = &type->v[type->num_vers-1];
1129
1130 *out_cur++ = i;
1131 memcpy(out_cur, last_v->gen_char, 3);
1132 out_cur += 3;
1133 memcpy(out_cur, last_v->rev_char, 3);
1134 out_cur += 3;
1135 }
1136
1137 out_buf[0] = out_num_types;
1138
1139 return abis_om2k_tx_negot_req_ack(msg->trx->bts, &o2h->mo, out_buf, out_cur - out_buf);
Harald Welte9a311ec2011-02-12 12:33:06 +01001140}
1141
1142static int om2k_rx_start_res(struct msgb *msg)
1143{
1144 struct abis_om2k_hdr *o2h = msgb_l2(msg);
1145 int rc;
1146
1147 rc = abis_om2k_tx_simple(msg->trx->bts, &o2h->mo, OM2K_MSGT_START_RES_ACK);
1148 rc = abis_om2k_tx_op_info(msg->trx->bts, &o2h->mo, 1);
1149
1150 return rc;
1151}
1152
Harald Welte0741ffe2011-02-12 18:48:53 +01001153static int om2k_rx_op_info_ack(struct msgb *msg)
Harald Welte9a311ec2011-02-12 12:33:06 +01001154{
1155 struct abis_om2k_hdr *o2h = msgb_l2(msg);
Harald Welte9a311ec2011-02-12 12:33:06 +01001156
Harald Welte0741ffe2011-02-12 18:48:53 +01001157 /* FIXME: update Operational state in our structures */
Harald Welte9a311ec2011-02-12 12:33:06 +01001158
Harald Welte0741ffe2011-02-12 18:48:53 +01001159 return 0;
Harald Welte9a311ec2011-02-12 12:33:06 +01001160}
1161
Harald Weltee6e83832011-03-05 17:52:09 +01001162const struct value_string om2k_result_strings[] = {
1163 { 0x02, "Wrong state or out of sequence" },
1164 { 0x03, "File error" },
1165 { 0x04, "Fault, unspecified" },
1166 { 0x05, "Tuning fault" },
1167 { 0x06, "Protocol error" },
1168 { 0x07, "MO not connected" },
1169 { 0x08, "Parameter error" },
1170 { 0x09, "Optional function not supported" },
1171 { 0x0a, "Local access state LOCALLY DISCONNECTED" },
1172 { 0, NULL }
1173};
1174
1175static int om2k_rx_nack(struct msgb *msg)
1176{
1177 struct abis_om2k_hdr *o2h = msgb_l2(msg);
1178 uint16_t msg_type = ntohs(o2h->msg_type);
1179 struct tlv_parsed tp;
1180
1181 LOGP(DNM, LOGL_ERROR, "Rx MO=%s %s", om2k_mo_name(&o2h->mo),
1182 get_value_string(om2k_msgcode_vals, msg_type));
1183
1184 abis_om2k_tlv_parse(&tp, o2h->data, o2h->om.length - 6);
1185 if (TLVP_PRESENT(&tp, OM2K_DEI_REASON_CODE))
1186 LOGPC(DNM, LOGL_ERROR, ", Reason 0x%02x",
1187 *TLVP_VAL(&tp, OM2K_DEI_REASON_CODE));
1188
1189 if (TLVP_PRESENT(&tp, OM2K_DEI_RESULT_CODE))
1190 LOGPC(DNM, LOGL_ERROR, ", Result %s",
1191 get_value_string(om2k_result_strings,
1192 *TLVP_VAL(&tp, OM2K_DEI_RESULT_CODE)));
1193 LOGPC(DNM, LOGL_ERROR, "\n");
1194
1195 return 0;
1196}
1197
Harald Welte9a311ec2011-02-12 12:33:06 +01001198int abis_om2k_rcvmsg(struct msgb *msg)
1199{
1200 struct gsm_bts *bts = msg->trx->bts;
1201 struct abis_om2k_hdr *o2h = msgb_l2(msg);
1202 struct abis_om_hdr *oh = &o2h->om;
Harald Weltebc867d92011-02-12 13:09:38 +01001203 uint16_t msg_type = ntohs(o2h->msg_type);
Harald Welte9a311ec2011-02-12 12:33:06 +01001204 int rc = 0;
1205
1206 /* Various consistency checks */
1207 if (oh->placement != ABIS_OM_PLACEMENT_ONLY) {
1208 LOGP(DNM, LOGL_ERROR, "ABIS OML placement 0x%x not supported\n",
1209 oh->placement);
1210 if (oh->placement != ABIS_OM_PLACEMENT_FIRST)
1211 return -EINVAL;
1212 }
1213 if (oh->sequence != 0) {
1214 LOGP(DNM, LOGL_ERROR, "ABIS OML sequence 0x%x != 0x00\n",
1215 oh->sequence);
1216 return -EINVAL;
1217 }
1218
1219 msg->l3h = (unsigned char *)o2h + sizeof(*o2h);
1220
1221 if (oh->mdisc != ABIS_OM_MDISC_FOM) {
1222 LOGP(DNM, LOGL_ERROR, "unknown ABIS OM2000 message discriminator 0x%x\n",
1223 oh->mdisc);
1224 return -EINVAL;
1225 }
1226
Harald Welte73541072011-02-12 13:44:14 +01001227 DEBUGP(DNM, "Rx MO=%s %s (%s)\n", om2k_mo_name(&o2h->mo),
Harald Weltebc867d92011-02-12 13:09:38 +01001228 get_value_string(om2k_msgcode_vals, msg_type),
Harald Welte9a311ec2011-02-12 12:33:06 +01001229 hexdump(msg->l2h, msgb_l2len(msg)));
1230
Harald Weltebc867d92011-02-12 13:09:38 +01001231 switch (msg_type) {
Harald Welte9a311ec2011-02-12 12:33:06 +01001232 case OM2K_MSGT_CAL_TIME_REQ:
1233 rc = abis_om2k_cal_time_resp(bts);
1234 break;
1235 case OM2K_MSGT_FAULT_REP:
Harald Welte9a311ec2011-02-12 12:33:06 +01001236 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_FAULT_REP_ACK);
1237 break;
1238 case OM2K_MSGT_NEGOT_REQ:
1239 rc = om2k_rx_negot_req(msg);
1240 break;
1241 case OM2K_MSGT_START_RES:
1242 rc = om2k_rx_start_res(msg);
1243 break;
Harald Welte0741ffe2011-02-12 18:48:53 +01001244 case OM2K_MSGT_OP_INFO_ACK:
1245 rc = om2k_rx_op_info_ack(msg);
Harald Welte9a311ec2011-02-12 12:33:06 +01001246 break;
1247 case OM2K_MSGT_IS_CONF_RES:
1248 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_IS_CONF_RES_ACK);
1249 break;
Harald Weltefdb71942011-02-14 15:31:43 +01001250 case OM2K_MSGT_CON_CONF_RES:
1251 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_CON_CONF_RES_ACK);
1252 break;
Harald Weltea0ce3492011-03-05 14:13:14 +01001253 case OM2K_MSGT_TX_CONF_RES:
1254 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_TX_CONF_RES_ACK);
1255 break;
1256 case OM2K_MSGT_RX_CONF_RES:
1257 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_RX_CONF_RES_ACK);
1258 break;
1259 case OM2K_MSGT_TS_CONF_RES:
1260 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_TS_CONF_RES_ACK);
1261 break;
Harald Weltef9cf9612011-03-05 14:36:47 +01001262 case OM2K_MSGT_TF_CONF_RES:
1263 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_TF_CONF_RES_ACK);
1264 break;
Harald Welte9a311ec2011-02-12 12:33:06 +01001265 case OM2K_MSGT_CONNECT_COMPL:
1266 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_RESET_CMD);
1267 break;
1268 case OM2K_MSGT_RESET_COMPL:
1269 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_START_REQ);
1270 break;
Harald Welteb3d70fd2011-02-13 12:43:44 +01001271 case OM2K_MSGT_ENABLE_RES:
1272 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_ENABLE_RES_ACK);
1273 break;
Harald Weltefdb71942011-02-14 15:31:43 +01001274 case OM2K_MSGT_DISABLE_RES:
1275 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_DISABLE_RES_ACK);
1276 break;
1277 case OM2K_MSGT_TEST_RES:
1278 rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_TEST_RES_ACK);
Harald Welte9a311ec2011-02-12 12:33:06 +01001279 break;
Harald Welte0741ffe2011-02-12 18:48:53 +01001280 case OM2K_MSGT_STATUS_RESP:
1281 break;
Harald Weltefdb71942011-02-14 15:31:43 +01001282 case OM2K_MSGT_START_REQ_ACK:
1283 case OM2K_MSGT_CON_CONF_REQ_ACK:
1284 case OM2K_MSGT_IS_CONF_REQ_ACK:
Harald Weltea0ce3492011-03-05 14:13:14 +01001285 case OM2K_MSGT_TX_CONF_REQ_ACK:
1286 case OM2K_MSGT_RX_CONF_REQ_ACK:
1287 case OM2K_MSGT_TS_CONF_REQ_ACK:
Harald Weltef9cf9612011-03-05 14:36:47 +01001288 case OM2K_MSGT_TF_CONF_REQ_ACK:
Harald Weltefdb71942011-02-14 15:31:43 +01001289 case OM2K_MSGT_ENABLE_REQ_ACK:
1290 case OM2K_MSGT_ALARM_STATUS_REQ_ACK:
1291 case OM2K_MSGT_DISABLE_REQ_ACK:
1292 break;
Harald Weltee6e83832011-03-05 17:52:09 +01001293 case OM2K_MSGT_START_REQ_REJ:
Harald Welte3ede7232011-03-05 17:58:13 +01001294 case OM2K_MSGT_CONNECT_REJ:
Harald Welteaff63bc2011-03-05 19:42:16 +01001295 case OM2K_MSGT_OP_INFO_REJ:
Harald Welte3ede7232011-03-05 17:58:13 +01001296 case OM2K_MSGT_DISCONNECT_REJ:
Harald Welteaff63bc2011-03-05 19:42:16 +01001297 case OM2K_MSGT_TEST_REQ_REJ:
Harald Weltee6e83832011-03-05 17:52:09 +01001298 case OM2K_MSGT_CON_CONF_REQ_REJ:
1299 case OM2K_MSGT_IS_CONF_REQ_REJ:
1300 case OM2K_MSGT_TX_CONF_REQ_REJ:
1301 case OM2K_MSGT_RX_CONF_REQ_REJ:
1302 case OM2K_MSGT_TS_CONF_REQ_REJ:
1303 case OM2K_MSGT_TF_CONF_REQ_REJ:
1304 case OM2K_MSGT_ENABLE_REQ_REJ:
1305 case OM2K_MSGT_ALARM_STATUS_REQ_REJ:
1306 case OM2K_MSGT_DISABLE_REQ_REJ:
1307 rc = om2k_rx_nack(msg);
1308 break;
Harald Welte9a311ec2011-02-12 12:33:06 +01001309 default:
Harald Welte0741ffe2011-02-12 18:48:53 +01001310 LOGP(DNM, LOGL_NOTICE, "Rx unhandled OM2000 msg %s\n",
Harald Weltebc867d92011-02-12 13:09:38 +01001311 get_value_string(om2k_msgcode_vals, msg_type));
Harald Welte9a311ec2011-02-12 12:33:06 +01001312 }
1313
1314 msgb_free(msg);
1315 return rc;
1316}