Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 1 | /* 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 Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 41 | #include <openbsc/abis_om2000.h> |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 42 | #include <openbsc/signal.h> |
| 43 | |
| 44 | #define OM_ALLOC_SIZE 1024 |
| 45 | #define OM_HEADROOM_SIZE 128 |
| 46 | |
| 47 | /* use following functions from abis_nm.c: |
| 48 | * om2k_msgb_alloc() |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 49 | * abis_om2k_sendmsg() |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 50 | */ |
| 51 | |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 52 | struct abis_om2k_hdr { |
| 53 | struct abis_om_hdr om; |
| 54 | uint16_t msg_type; |
| 55 | struct abis_om2k_mo mo; |
| 56 | uint8_t data[0]; |
| 57 | } __attribute__ ((packed)); |
| 58 | |
| 59 | enum abis_om2k_msgtype { |
| 60 | OM2K_MSGT_ABORT_SP_CMD = 0x0000, |
| 61 | OM2K_MSGT_ABORT_SP_COMPL = 0x0002, |
| 62 | OM2K_MSGT_ALARM_REP_ACK = 0x0004, |
| 63 | OM2K_MSGT_ALARM_REP_NACK = 0x0005, |
| 64 | OM2K_MSGT_ALARM_REP = 0x0006, |
| 65 | OM2K_MSGT_ALARM_STATUS_REQ = 0x0008, |
| 66 | OM2K_MSGT_ALARM_STATUS_REQ_ACK = 0x000a, |
| 67 | OM2K_MSGT_ALARM_STATUS_REQ_REJ = 0x000b, |
| 68 | OM2K_MSGT_ALARM_STATUS_RES_ACK = 0x000c, |
| 69 | OM2K_MSGT_ALARM_STATUS_RES_NACK = 0x000d, |
| 70 | OM2K_MSGT_ALARM_STATUS_RES = 0x000e, |
| 71 | OM2K_MSGT_CAL_TIME_RESP = 0x0010, |
| 72 | OM2K_MSGT_CAL_TIME_REJ = 0x0011, |
| 73 | OM2K_MSGT_CAL_TIME_REQ = 0x0012, |
| 74 | |
| 75 | OM2K_MSGT_CONNECT_CMD = 0x001c, |
| 76 | OM2K_MSGT_CONNECT_COMPL = 0x001e, |
| 77 | OM2K_MSGT_CONNECT_REJ = 0x001f, |
| 78 | |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 79 | OM2K_MSGT_DISABLE_REQ = 0x0028, |
| 80 | OM2K_MSGT_DISABLE_REQ_ACK = 0x002a, |
| 81 | OM2K_MSGT_DISABLE_REQ_REJ = 0x002b, |
| 82 | OM2K_MSGT_DISABLE_RES_ACK = 0x002c, |
| 83 | OM2K_MSGT_DISABLE_RES_NACK = 0x002d, |
| 84 | OM2K_MSGT_DISABLE_RES = 0x002e, |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 85 | OM2K_MSGT_DISCONNECT_CMD = 0x0030, |
| 86 | OM2K_MSGT_DISCONNECT_COMPL = 0x0032, |
| 87 | OM2K_MSGT_DISCONNECT_REJ = 0x0033, |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 88 | OM2K_MSGT_ENABLE_REQ = 0x0034, |
| 89 | OM2K_MSGT_ENABLE_REQ_ACK = 0x0036, |
| 90 | OM2K_MSGT_ENABLE_REQ_REJ = 0x0037, |
| 91 | OM2K_MSGT_ENABLE_RES_ACK = 0x0038, |
| 92 | OM2K_MSGT_ENABLE_RES_NACK = 0x0039, |
| 93 | OM2K_MSGT_ENABLE_RES = 0x003a, |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 94 | |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 95 | OM2K_MSGT_FAULT_REP_ACK = 0x0040, |
| 96 | OM2K_MSGT_FAULT_REP_NACK = 0x0041, |
| 97 | OM2K_MSGT_FAULT_REP = 0x0042, |
| 98 | |
| 99 | OM2K_MSGT_IS_CONF_REQ = 0x0060, |
| 100 | OM2K_MSGT_IS_CONF_REQ_ACK = 0x0062, |
| 101 | OM2K_MSGT_IS_CONF_REQ_REJ = 0x0063, |
| 102 | OM2K_MSGT_IS_CONF_RES_ACK = 0x0064, |
| 103 | OM2K_MSGT_IS_CONF_RES_NACK = 0x0065, |
| 104 | OM2K_MSGT_IS_CONF_RES = 0x0066, |
| 105 | |
| 106 | OM2K_MSGT_OP_INFO = 0x0074, |
| 107 | OM2K_MSGT_OP_INFO_ACK = 0x0076, |
| 108 | OM2K_MSGT_OP_INFO_REJ = 0x0077, |
| 109 | OM2K_MSGT_RESET_CMD = 0x0078, |
| 110 | OM2K_MSGT_RESET_COMPL = 0x007a, |
| 111 | OM2K_MSGT_RESET_REJ = 0x007b, |
| 112 | |
| 113 | OM2K_MSGT_START_REQ = 0x0084, |
| 114 | OM2K_MSGT_START_REQ_ACK = 0x0086, |
| 115 | OM2K_MSGT_START_REQ_REJ = 0x0087, |
| 116 | OM2K_MSGT_START_RES_ACK = 0x0088, |
| 117 | OM2K_MSGT_START_RES_NACK = 0x0089, |
| 118 | OM2K_MSGT_START_RES = 0x008a, |
Harald Welte | e1d5eca | 2011-02-12 14:42:59 +0100 | [diff] [blame] | 119 | OM2K_MSGT_STATUS_REQ = 0x008c, |
| 120 | OM2K_MSGT_STATUS_RESP = 0x008e, |
| 121 | OM2K_MSGT_STATUS_REJ = 0x008f, |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 122 | |
Harald Welte | 8024d8f | 2011-02-12 15:07:30 +0100 | [diff] [blame] | 123 | OM2K_MSGT_TEST_REQ = 0x0094, |
| 124 | OM2K_MSGT_TEST_REQ_ACK = 0x0096, |
| 125 | OM2K_MSGT_TEST_REQ_REJ = 0x0097, |
| 126 | OM2K_MSGT_TEST_RES_ACK = 0x0098, |
| 127 | OM2K_MSGT_TEST_RES_NACK = 0x0099, |
| 128 | OM2K_MSGT_TEST_RES = 0x009a, |
| 129 | |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 130 | OM2K_MSGT_NEGOT_REQ_ACK = 0x0104, |
| 131 | OM2K_MSGT_NEGOT_REQ_NACK = 0x0105, |
| 132 | OM2K_MSGT_NEGOT_REQ = 0x0106, |
| 133 | }; |
| 134 | |
| 135 | enum abis_om2k_dei { |
| 136 | OM2K_DEI_CAL_TIME = 0x0d, |
Harald Welte | 8bcb1a0 | 2011-02-12 20:23:40 +0100 | [diff] [blame] | 137 | OM2K_DEI_END_LIST_NR = 0x13, |
| 138 | OM2K_DEI_IS_CONN_LIST = 0x27, |
| 139 | OM2K_DEI_LIST_NR = 0x28, |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 140 | OM2K_DEI_OP_INFO = 0x2e, |
Harald Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 141 | OM2K_DEI_NEGOT_REC1 = 0x90, |
| 142 | OM2K_DEI_NEGOT_REC2 = 0x91, |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | enum abis_om2k_mo_cls { |
| 146 | OM2K_MO_CLS_TRXC = 0x01, |
| 147 | OM2K_MO_CLS_TS = 0x03, |
| 148 | OM2K_MO_CLS_TF = 0x04, |
| 149 | OM2K_MO_CLS_IS = 0x05, |
| 150 | OM2K_MO_CLS_CON = 0x06, |
| 151 | OM2K_MO_CLS_DP = 0x07, |
| 152 | OM2K_MO_CLS_CF = 0x0a, |
| 153 | OM2K_MO_CLS_TX = 0x0b, |
| 154 | OM2K_MO_CLS_RX = 0x0c, |
| 155 | }; |
| 156 | |
| 157 | static const struct value_string om2k_msgcode_vals[] = { |
| 158 | { 0x0000, "Abort SP Command" }, |
| 159 | { 0x0002, "Abort SP Complete" }, |
| 160 | { 0x0004, "Alarm Report ACK" }, |
| 161 | { 0x0005, "Alarm Report NACK" }, |
| 162 | { 0x0006, "Alarm Report" }, |
| 163 | { 0x0008, "Alarm Status Request" }, |
| 164 | { 0x000a, "Alarm Status Request Accept" }, |
| 165 | { 0x000b, "Alarm Status Request Reject" }, |
| 166 | { 0x000c, "Alarm Status Result ACK" }, |
| 167 | { 0x000d, "Alarm Status Result NACK" }, |
| 168 | { 0x000e, "Alarm Status Result" }, |
| 169 | { 0x0010, "Calendar Time Response" }, |
| 170 | { 0x0011, "Calendar Time Reject" }, |
| 171 | { 0x0012, "Calendar Time Request" }, |
| 172 | { 0x0014, "CON Configuration Request" }, |
| 173 | { 0x0016, "CON Configuration Request Accept" }, |
| 174 | { 0x0017, "CON Configuration Request Reject" }, |
| 175 | { 0x0018, "CON Configuration Result ACK" }, |
| 176 | { 0x0019, "CON Configuration Result NACK" }, |
| 177 | { 0x001a, "CON Configuration Result" }, |
| 178 | { 0x001c, "Connect Command" }, |
| 179 | { 0x001e, "Connect Complete" }, |
| 180 | { 0x001f, "Connect Rejecte" }, |
| 181 | { 0x0028, "Disable Request" }, |
| 182 | { 0x002a, "Disable Request Accept" }, |
| 183 | { 0x002b, "Disable Request Reject" }, |
| 184 | { 0x002c, "Disable Result ACK" }, |
| 185 | { 0x002d, "Disable Result NACK" }, |
| 186 | { 0x002e, "Disable Result" }, |
| 187 | { 0x0030, "Disconnect Command" }, |
| 188 | { 0x0032, "Disconnect Complete" }, |
| 189 | { 0x0033, "Disconnect Reject" }, |
| 190 | { 0x0034, "Enable Request" }, |
| 191 | { 0x0036, "Enable Request Accept" }, |
| 192 | { 0x0037, "Enable Request Reject" }, |
| 193 | { 0x0038, "Enable Result ACK" }, |
| 194 | { 0x0039, "Enable Result NACK" }, |
| 195 | { 0x003a, "Enable Result" }, |
| 196 | { 0x003c, "Escape Downlink Normal" }, |
| 197 | { 0x003d, "Escape Downlink NACK" }, |
| 198 | { 0x003e, "Escape Uplink Normal" }, |
| 199 | { 0x003f, "Escape Uplink NACK" }, |
| 200 | { 0x0040, "Fault Report ACK" }, |
| 201 | { 0x0041, "Fault Report NACK" }, |
| 202 | { 0x0042, "Fault Report" }, |
| 203 | { 0x0044, "File Package End Command" }, |
| 204 | { 0x0046, "File Package End Result" }, |
| 205 | { 0x0047, "File Package End Reject" }, |
| 206 | { 0x0048, "File Relation Request" }, |
| 207 | { 0x004a, "File Relation Response" }, |
| 208 | { 0x004b, "File Relation Request Reject" }, |
| 209 | { 0x004c, "File Segment Transfer" }, |
| 210 | { 0x004e, "File Segment Transfer Complete" }, |
| 211 | { 0x004f, "File Segment Transfer Reject" }, |
| 212 | { 0x0050, "HW Information Request" }, |
| 213 | { 0x0052, "HW Information Request Accept" }, |
| 214 | { 0x0053, "HW Information Request Reject" }, |
| 215 | { 0x0054, "HW Information Result ACK" }, |
| 216 | { 0x0055, "HW Information Result NACK" }, |
| 217 | { 0x0056, "HW Information Result" }, |
| 218 | { 0x0060, "IS Configuration Request" }, |
| 219 | { 0x0062, "IS Configuration Request Accept" }, |
| 220 | { 0x0063, "IS Configuration Request Reject" }, |
| 221 | { 0x0064, "IS Configuration Result ACK" }, |
| 222 | { 0x0065, "IS Configuration Result NACK" }, |
| 223 | { 0x0066, "IS Configuration Result" }, |
| 224 | { 0x0068, "Load Data End" }, |
| 225 | { 0x006a, "Load Data End Result" }, |
| 226 | { 0x006b, "Load Data End Reject" }, |
| 227 | { 0x006c, "Load Data Init" }, |
| 228 | { 0x006e, "Load Data Init Accept" }, |
| 229 | { 0x006f, "Load Data Init Reject" }, |
| 230 | { 0x0070, "Loop Control Command" }, |
| 231 | { 0x0072, "Loop Control Complete" }, |
| 232 | { 0x0073, "Loop Control Reject" }, |
| 233 | { 0x0074, "Operational Information" }, |
| 234 | { 0x0076, "Operational Information Accept" }, |
| 235 | { 0x0077, "Operational Information Reject" }, |
| 236 | { 0x0078, "Reset Command" }, |
| 237 | { 0x007a, "Reset Complete" }, |
| 238 | { 0x007b, "Reset Reject" }, |
| 239 | { 0x007c, "RX Configuration Request" }, |
| 240 | { 0x007e, "RX Configuration Request Accept" }, |
| 241 | { 0x007f, "RX Configuration Request Reject" }, |
| 242 | { 0x0080, "RX Configuration Result ACK" }, |
| 243 | { 0x0081, "RX Configuration Result NACK" }, |
| 244 | { 0x0082, "RX Configuration Result" }, |
| 245 | { 0x0084, "Start Request" }, |
| 246 | { 0x0086, "Start Request Accept" }, |
| 247 | { 0x0087, "Start Request Reject" }, |
| 248 | { 0x0088, "Start Result ACK" }, |
| 249 | { 0x0089, "Start Result NACK" }, |
| 250 | { 0x008a, "Start Result" }, |
| 251 | { 0x008c, "Status Request" }, |
| 252 | { 0x008e, "Status Response" }, |
| 253 | { 0x008f, "Status Reject" }, |
| 254 | { 0x0094, "Test Request" }, |
| 255 | { 0x0096, "Test Request Accept" }, |
| 256 | { 0x0097, "Test Request Reject" }, |
| 257 | { 0x0098, "Test Result ACK" }, |
| 258 | { 0x0099, "Test Result NACK" }, |
| 259 | { 0x009a, "Test Result" }, |
| 260 | { 0x00a0, "TF Configuration Request" }, |
| 261 | { 0x00a2, "TF Configuration Request Accept" }, |
| 262 | { 0x00a3, "TF Configuration Request Reject" }, |
| 263 | { 0x00a4, "TF Configuration Result ACK" }, |
| 264 | { 0x00a5, "TF Configuration Result NACK" }, |
| 265 | { 0x00a6, "TF Configuration Result" }, |
| 266 | { 0x00a8, "TS Configuration Request" }, |
| 267 | { 0x00aa, "TS Configuration Request Accept" }, |
| 268 | { 0x00ab, "TS Configuration Request Reject" }, |
| 269 | { 0x00ac, "TS Configuration Result ACK" }, |
| 270 | { 0x00ad, "TS Configuration Result NACK" }, |
| 271 | { 0x00ae, "TS Configuration Result" }, |
| 272 | { 0x00b0, "TX Configuration Request" }, |
| 273 | { 0x00b2, "TX Configuration Request Accept" }, |
| 274 | { 0x00b3, "TX Configuration Request Reject" }, |
| 275 | { 0x00b4, "TX Configuration Result ACK" }, |
| 276 | { 0x00b5, "TX Configuration Result NACK" }, |
| 277 | { 0x00b6, "TX Configuration Result" }, |
| 278 | { 0x00bc, "DIP Alarm Report ACK" }, |
| 279 | { 0x00bd, "DIP Alarm Report NACK" }, |
| 280 | { 0x00be, "DIP Alarm Report" }, |
| 281 | { 0x00c0, "DIP Alarm Status Request" }, |
| 282 | { 0x00c2, "DIP Alarm Status Response" }, |
| 283 | { 0x00c3, "DIP Alarm Status Reject" }, |
| 284 | { 0x00c4, "DIP Quality Report I ACK" }, |
| 285 | { 0x00c5, "DIP Quality Report I NACK" }, |
| 286 | { 0x00c6, "DIP Quality Report I" }, |
| 287 | { 0x00c8, "DIP Quality Report II ACK" }, |
| 288 | { 0x00c9, "DIP Quality Report II NACK" }, |
| 289 | { 0x00ca, "DIP Quality Report II" }, |
| 290 | { 0x00dc, "DP Configuration Request" }, |
| 291 | { 0x00de, "DP Configuration Request Accept" }, |
| 292 | { 0x00df, "DP Configuration Request Reject" }, |
| 293 | { 0x00e0, "DP Configuration Result ACK" }, |
| 294 | { 0x00e1, "DP Configuration Result NACK" }, |
| 295 | { 0x00e2, "DP Configuration Result" }, |
| 296 | { 0x00e4, "Capabilities HW Info Report ACK" }, |
| 297 | { 0x00e5, "Capabilities HW Info Report NACK" }, |
| 298 | { 0x00e6, "Capabilities HW Info Report" }, |
| 299 | { 0x00e8, "Capabilities Request" }, |
| 300 | { 0x00ea, "Capabilities Request Accept" }, |
| 301 | { 0x00eb, "Capabilities Request Reject" }, |
| 302 | { 0x00ec, "Capabilities Result ACK" }, |
| 303 | { 0x00ed, "Capabilities Result NACK" }, |
| 304 | { 0x00ee, "Capabilities Result" }, |
| 305 | { 0x00f0, "FM Configuration Request" }, |
| 306 | { 0x00f2, "FM Configuration Request Accept" }, |
| 307 | { 0x00f3, "FM Configuration Request Reject" }, |
| 308 | { 0x00f4, "FM Configuration Result ACK" }, |
| 309 | { 0x00f5, "FM Configuration Result NACK" }, |
| 310 | { 0x00f6, "FM Configuration Result" }, |
| 311 | { 0x00f8, "FM Report Request" }, |
| 312 | { 0x00fa, "FM Report Response" }, |
| 313 | { 0x00fb, "FM Report Reject" }, |
| 314 | { 0x00fc, "FM Start Command" }, |
| 315 | { 0x00fe, "FM Start Complete" }, |
| 316 | { 0x00ff, "FM Start Reject" }, |
| 317 | { 0x0100, "FM Stop Command" }, |
| 318 | { 0x0102, "FM Stop Complete" }, |
| 319 | { 0x0103, "FM Stop Reject" }, |
| 320 | { 0x0104, "Negotiation Request ACK" }, |
| 321 | { 0x0105, "Negotiation Request NACK" }, |
| 322 | { 0x0106, "Negotiation Request" }, |
| 323 | { 0x0108, "BTS Initiated Request ACK" }, |
| 324 | { 0x0109, "BTS Initiated Request NACK" }, |
| 325 | { 0x010a, "BTS Initiated Request" }, |
| 326 | { 0x010c, "Radio Channels Release Command" }, |
| 327 | { 0x010e, "Radio Channels Release Complete" }, |
| 328 | { 0x010f, "Radio Channels Release Reject" }, |
| 329 | { 0x0118, "Feature Control Command" }, |
| 330 | { 0x011a, "Feature Control Complete" }, |
| 331 | { 0x011b, "Feature Control Reject" }, |
| 332 | |
| 333 | { 0, NULL } |
| 334 | }; |
| 335 | |
| 336 | /* TS 12.21 Section 9.4: Attributes */ |
| 337 | static const struct value_string om2k_attr_vals[] = { |
| 338 | { 0x00, "Accordance indication" }, |
| 339 | { 0x01, "Alarm Id" }, |
| 340 | { 0x02, "Alarm Data" }, |
| 341 | { 0x03, "Alarm Severity" }, |
| 342 | { 0x04, "Alarm Status" }, |
| 343 | { 0x05, "Alarm Status Type" }, |
| 344 | { 0x06, "BCC" }, |
| 345 | { 0x07, "BS_AG_BKS_RES" }, |
| 346 | { 0x09, "BSIC" }, |
| 347 | { 0x0a, "BA_PA_MFRMS" }, |
| 348 | { 0x0b, "CBCH Indicator" }, |
| 349 | { 0x0c, "CCCH Options" }, |
| 350 | { 0x0d, "Calendar Time" }, |
| 351 | { 0x0f, "Channel Combination" }, |
| 352 | { 0x10, "CON Connection List" }, |
| 353 | { 0x11, "Data End Indication" }, |
| 354 | { 0x12, "DRX_DEV_MAX" }, |
| 355 | { 0x13, "End List Number" }, |
| 356 | { 0x14, "External Condition Map Class 1" }, |
| 357 | { 0x15, "External Condition Map Class 2" }, |
| 358 | { 0x16, "File Relation Indication" }, |
| 359 | { 0x17, "File Revision" }, |
| 360 | { 0x18, "File Segment Data" }, |
| 361 | { 0x19, "File Segment Length" }, |
| 362 | { 0x1a, "File Segment Sequence Number" }, |
| 363 | { 0x1b, "File Size" }, |
| 364 | { 0x1c, "Filling Marker" }, |
| 365 | { 0x1d, "FN Offset" }, |
| 366 | { 0x1e, "Frequency List" }, |
| 367 | { 0x1f, "Frequency Specifier RX" }, |
| 368 | { 0x20, "Frequency Specifier TX" }, |
| 369 | { 0x21, "HSN" }, |
| 370 | { 0x22, "ICM Indicator" }, |
| 371 | { 0x23, "Internal Fault Map Class 1A" }, |
| 372 | { 0x24, "Internal Fault Map Class 1B" }, |
| 373 | { 0x25, "Internal Fault Map Class 2A" }, |
| 374 | { 0x26, "Internal Fault Map Class 2A Extension" }, |
| 375 | { 0x27, "IS Connection List" }, |
| 376 | { 0x28, "List Number" }, |
| 377 | { 0x29, "File Package State Indication" }, |
| 378 | { 0x2a, "Local Access State" }, |
| 379 | { 0x2b, "MAIO" }, |
| 380 | { 0x2c, "MO State" }, |
| 381 | { 0x2d, "Ny1" }, |
| 382 | { 0x2e, "Operational Information" }, |
| 383 | { 0x2f, "Power" }, |
| 384 | { 0x30, "RU Position Data" }, |
| 385 | { 0x31, "Protocol Error" }, |
| 386 | { 0x32, "Reason Code" }, |
| 387 | { 0x33, "Receiver Diversity" }, |
| 388 | { 0x34, "Replacement Unit Map" }, |
| 389 | { 0x35, "Result Code" }, |
| 390 | { 0x36, "RU Revision Data" }, |
| 391 | { 0x38, "T3105" }, |
| 392 | { 0x39, "Test Loop Setting" }, |
| 393 | { 0x3a, "TF Mode" }, |
| 394 | { 0x3b, "TF Compensation Value" }, |
| 395 | { 0x3c, "Time Slot Number" }, |
| 396 | { 0x3d, "TSC" }, |
| 397 | { 0x3e, "RU Logical Id" }, |
| 398 | { 0x3f, "RU Serial Number Data" }, |
| 399 | { 0x40, "BTS Version" }, |
| 400 | { 0x41, "OML IWD Version" }, |
| 401 | { 0x42, "RWL IWD Version" }, |
| 402 | { 0x43, "OML Function Map 1" }, |
| 403 | { 0x44, "OML Function Map 2" }, |
| 404 | { 0x45, "RSL Function Map 1" }, |
| 405 | { 0x46, "RSL Function Map 2" }, |
| 406 | { 0x47, "Extended Range Indicator" }, |
| 407 | { 0x48, "Request Indicators" }, |
| 408 | { 0x49, "DIP Alarm Condition Map" }, |
| 409 | { 0x4a, "ES Incoming" }, |
| 410 | { 0x4b, "ES Outgoing" }, |
| 411 | { 0x4e, "SES Incoming" }, |
| 412 | { 0x4f, "SES Outgoing" }, |
| 413 | { 0x50, "Replacement Unit Map Extension" }, |
| 414 | { 0x52, "UAS Incoming" }, |
| 415 | { 0x53, "UAS Outgoing" }, |
| 416 | { 0x58, "DF Incoming" }, |
| 417 | { 0x5a, "DF Outgoing" }, |
| 418 | { 0x5c, "SF" }, |
| 419 | { 0x60, "S Bits Setting" }, |
| 420 | { 0x61, "CRC-4 Use Option" }, |
| 421 | { 0x62, "T Parameter" }, |
| 422 | { 0x63, "N Parameter" }, |
| 423 | { 0x64, "N1 Parameter" }, |
| 424 | { 0x65, "N3 Parameter" }, |
| 425 | { 0x66, "N4 Parameter" }, |
| 426 | { 0x67, "P Parameter" }, |
| 427 | { 0x68, "Q Parameter" }, |
| 428 | { 0x69, "BI_Q1" }, |
| 429 | { 0x6a, "BI_Q2" }, |
| 430 | { 0x74, "ICM Boundary Parameters" }, |
| 431 | { 0x77, "AFT" }, |
| 432 | { 0x78, "AFT RAI" }, |
| 433 | { 0x79, "Link Supervision Control" }, |
| 434 | { 0x7a, "Link Supervision Filtering Time" }, |
| 435 | { 0x7b, "Call Supervision Time" }, |
| 436 | { 0x7c, "Interval Length UAS Incoming" }, |
| 437 | { 0x7d, "Interval Length UAS Outgoing" }, |
| 438 | { 0x7e, "ICM Channel Rate" }, |
| 439 | { 0x7f, "Attribute Identifier" }, |
| 440 | { 0x80, "FM Frequency List" }, |
| 441 | { 0x81, "FM Frequency Report" }, |
| 442 | { 0x82, "FM Percentile" }, |
| 443 | { 0x83, "FM Clear Indication" }, |
| 444 | { 0x84, "HW Info Signature" }, |
| 445 | { 0x85, "MO Record" }, |
| 446 | { 0x86, "TF Synchronisation Source" }, |
| 447 | { 0x87, "TTA" }, |
| 448 | { 0x88, "End Segment Number" }, |
| 449 | { 0x89, "Segment Number" }, |
| 450 | { 0x8a, "Capabilities Signature" }, |
| 451 | { 0x8c, "File Relation List" }, |
| 452 | { 0x90, "Negotiation Record I" }, |
| 453 | { 0x91, "Negotiation Record II" }, |
| 454 | { 0x92, "Encryption Algorithm" }, |
| 455 | { 0x94, "Interference Rejection Combining" }, |
| 456 | { 0x95, "Dedication Information" }, |
| 457 | { 0x97, "Feature Code" }, |
| 458 | { 0x98, "FS Offset" }, |
| 459 | { 0x99, "ESB Timeslot" }, |
| 460 | { 0x9a, "Master TG Instance" }, |
| 461 | { 0x9b, "Master TX Chain Delay" }, |
| 462 | { 0x9c, "External Condition Class 2 Extension" }, |
| 463 | { 0x9d, "TSs MO State" }, |
| 464 | { 0, NULL } |
| 465 | }; |
| 466 | |
Harald Welte | e1d5eca | 2011-02-12 14:42:59 +0100 | [diff] [blame] | 467 | const struct value_string om2k_mo_class_short_vals[] = { |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 468 | { 0x01, "TRXC" }, |
| 469 | { 0x03, "TS" }, |
| 470 | { 0x04, "TF" }, |
| 471 | { 0x05, "IS" }, |
| 472 | { 0x06, "CON" }, |
| 473 | { 0x07, "DP" }, |
| 474 | { 0x0a, "CF" }, |
| 475 | { 0x0b, "TX" }, |
| 476 | { 0x0c, "RX" }, |
| 477 | { 0, NULL } |
| 478 | }; |
| 479 | |
| 480 | static struct msgb *om2k_msgb_alloc(void) |
| 481 | { |
| 482 | return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE, |
| 483 | "OM2000"); |
| 484 | } |
| 485 | |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 486 | static int abis_om2k_sendmsg(struct gsm_bts *bts, struct msgb *msg) |
| 487 | { |
| 488 | msg->trx = bts->c0; |
| 489 | |
| 490 | return _abis_nm_sendmsg(msg); |
| 491 | } |
| 492 | |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 493 | static void fill_om2k_hdr(struct abis_om2k_hdr *o2h, const struct abis_om2k_mo *mo, |
| 494 | uint16_t msg_type, uint8_t attr_len) |
| 495 | { |
| 496 | o2h->om.mdisc = ABIS_OM_MDISC_FOM; |
| 497 | o2h->om.placement = ABIS_OM_PLACEMENT_ONLY; |
| 498 | o2h->om.sequence = 0; |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 499 | o2h->om.length = 6 + attr_len; |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 500 | o2h->msg_type = htons(msg_type); |
| 501 | memcpy(&o2h->mo, mo, sizeof(o2h->mo)); |
| 502 | } |
| 503 | |
| 504 | static char *om2k_mo_name(const struct abis_om2k_mo *mo) |
| 505 | { |
| 506 | static char mo_buf[64]; |
| 507 | |
| 508 | memset(mo_buf, 0, sizeof(mo_buf)); |
| 509 | snprintf(mo_buf, sizeof(mo_buf), "%s/%02x/%02x/%02x", |
| 510 | get_value_string(om2k_mo_class_short_vals, mo->class), |
| 511 | mo->bts, mo->assoc_so, mo->inst); |
| 512 | return mo_buf; |
| 513 | } |
| 514 | |
Harald Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 515 | const struct abis_om2k_mo om2k_mo_cf = { OM2K_MO_CLS_CF, 0, 0xFF, 0 }; |
Harald Welte | 8bcb1a0 | 2011-02-12 20:23:40 +0100 | [diff] [blame] | 516 | const struct abis_om2k_mo om2k_mo_is = { OM2K_MO_CLS_IS, 0, 0xFF, 0 }; |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 517 | |
| 518 | static int abis_om2k_cal_time_resp(struct gsm_bts *bts) |
| 519 | { |
| 520 | struct msgb *msg = om2k_msgb_alloc(); |
| 521 | struct abis_om2k_hdr *o2k; |
| 522 | time_t tm_t; |
| 523 | struct tm *tm; |
| 524 | |
| 525 | o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k)); |
| 526 | fill_om2k_hdr(o2k, &om2k_mo_cf, OM2K_MSGT_CAL_TIME_RESP, 7); |
| 527 | |
| 528 | tm_t = time(NULL); |
| 529 | tm = localtime(&tm_t); |
| 530 | |
| 531 | msgb_put_u8(msg, OM2K_DEI_CAL_TIME); |
| 532 | msgb_put_u8(msg, tm->tm_year % 100); |
| 533 | msgb_put_u8(msg, tm->tm_mon + 1); |
| 534 | msgb_put_u8(msg, tm->tm_mday); |
| 535 | msgb_put_u8(msg, tm->tm_hour); |
| 536 | msgb_put_u8(msg, tm->tm_min); |
| 537 | msgb_put_u8(msg, tm->tm_sec); |
| 538 | |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 539 | return abis_om2k_sendmsg(bts, msg); |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 540 | } |
| 541 | |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 542 | static int abis_om2k_tx_simple(struct gsm_bts *bts, const struct abis_om2k_mo *mo, |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 543 | uint8_t msg_type) |
| 544 | { |
| 545 | struct msgb *msg = om2k_msgb_alloc(); |
| 546 | struct abis_om2k_hdr *o2k; |
| 547 | |
| 548 | o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k)); |
| 549 | fill_om2k_hdr(o2k, mo, msg_type, 0); |
| 550 | |
Harald Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 551 | DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo), |
| 552 | get_value_string(om2k_msgcode_vals, msg_type)); |
| 553 | |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 554 | return abis_om2k_sendmsg(bts, msg); |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 555 | } |
| 556 | |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 557 | int abis_om2k_tx_reset_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo) |
Harald Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 558 | { |
| 559 | return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_RESET_CMD); |
| 560 | } |
| 561 | |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 562 | int abis_om2k_tx_start_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo) |
Harald Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 563 | { |
| 564 | return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_START_REQ); |
| 565 | } |
| 566 | |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 567 | int abis_om2k_tx_status_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo) |
Harald Welte | e1d5eca | 2011-02-12 14:42:59 +0100 | [diff] [blame] | 568 | { |
| 569 | return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_STATUS_REQ); |
| 570 | } |
| 571 | |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 572 | int abis_om2k_tx_connect_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo) |
| 573 | { |
| 574 | return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_CONNECT_CMD); |
| 575 | } |
| 576 | |
| 577 | int abis_om2k_tx_disconnect_cmd(struct gsm_bts *bts, const struct abis_om2k_mo *mo) |
| 578 | { |
| 579 | return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_DISCONNECT_CMD); |
| 580 | } |
| 581 | |
Harald Welte | 8024d8f | 2011-02-12 15:07:30 +0100 | [diff] [blame] | 582 | int abis_om2k_tx_test_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo) |
| 583 | { |
| 584 | return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_TEST_REQ); |
| 585 | } |
| 586 | |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 587 | int abis_om2k_tx_enable_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo) |
| 588 | { |
| 589 | return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_ENABLE_REQ); |
| 590 | } |
| 591 | |
| 592 | int abis_om2k_tx_disable_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo) |
| 593 | { |
| 594 | return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_DISABLE_REQ); |
| 595 | } |
| 596 | |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 597 | int abis_om2k_tx_op_info(struct gsm_bts *bts, const struct abis_om2k_mo *mo, |
| 598 | uint8_t operational) |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 599 | { |
| 600 | struct msgb *msg = om2k_msgb_alloc(); |
| 601 | struct abis_om2k_hdr *o2k; |
| 602 | |
| 603 | o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k)); |
| 604 | fill_om2k_hdr(o2k, mo, OM2K_MSGT_OP_INFO, 2); |
| 605 | |
| 606 | msgb_tv_put(msg, OM2K_DEI_OP_INFO, operational); |
| 607 | |
Harald Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 608 | DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo), |
| 609 | get_value_string(om2k_msgcode_vals, OM2K_MSGT_OP_INFO)); |
| 610 | |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 611 | return abis_om2k_sendmsg(bts, msg); |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 612 | } |
| 613 | |
Harald Welte | 8bcb1a0 | 2011-02-12 20:23:40 +0100 | [diff] [blame] | 614 | int abis_om2k_tx_is_conf_req(struct gsm_bts *bts, struct om2k_is_conn_grp *cg, |
| 615 | unsigned int num_cg ) |
| 616 | { |
| 617 | struct msgb *msg = om2k_msgb_alloc(); |
| 618 | struct abis_om2k_hdr *o2k; |
| 619 | |
| 620 | o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k)); |
| 621 | fill_om2k_hdr(o2k, &om2k_mo_is, OM2K_MSGT_IS_CONF_REQ, |
| 622 | 2 + 2 + TLV_GROSS_LEN(num_cg * sizeof(*cg))); |
| 623 | |
| 624 | msgb_tv_put(msg, OM2K_DEI_LIST_NR, 1); |
| 625 | msgb_tv_put(msg, OM2K_DEI_END_LIST_NR, 1); |
| 626 | |
| 627 | msgb_tlv_put(msg, OM2K_DEI_IS_CONN_LIST, |
| 628 | num_cg * sizeof(*cg), (uint8_t *)cg); |
| 629 | |
| 630 | return abis_om2k_sendmsg(bts, msg); |
| 631 | } |
| 632 | |
Harald Welte | 6fec79d | 2011-02-12 14:57:17 +0100 | [diff] [blame] | 633 | static int abis_om2k_tx_negot_req_ack(struct gsm_bts *bts, const struct abis_om2k_mo *mo, |
Harald Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 634 | uint8_t *data, unsigned int len) |
| 635 | { |
| 636 | struct msgb *msg = om2k_msgb_alloc(); |
| 637 | struct abis_om2k_hdr *o2k; |
| 638 | |
| 639 | o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k)); |
| 640 | fill_om2k_hdr(o2k, mo, OM2K_MSGT_NEGOT_REQ_ACK, 2+len); |
| 641 | |
| 642 | msgb_tlv_put(msg, OM2K_DEI_NEGOT_REC2, len, data); |
| 643 | |
| 644 | DEBUGP(DNM, "Tx MO=%s %s\n", om2k_mo_name(mo), |
| 645 | get_value_string(om2k_msgcode_vals, OM2K_MSGT_NEGOT_REQ_ACK)); |
| 646 | |
| 647 | return abis_om2k_sendmsg(bts, msg); |
| 648 | } |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 649 | |
Harald Welte | 563d316 | 2011-02-12 18:11:16 +0100 | [diff] [blame] | 650 | struct iwd_version { |
| 651 | uint8_t gen_char[3+1]; |
| 652 | uint8_t rev_char[3+1]; |
| 653 | }; |
| 654 | |
| 655 | struct iwd_type { |
| 656 | uint8_t num_vers; |
| 657 | struct iwd_version v[8]; |
| 658 | }; |
| 659 | |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 660 | static int om2k_rx_negot_req(struct msgb *msg) |
| 661 | { |
| 662 | struct abis_om2k_hdr *o2h = msgb_l2(msg); |
Harald Welte | 563d316 | 2011-02-12 18:11:16 +0100 | [diff] [blame] | 663 | struct iwd_type iwd_types[16]; |
| 664 | uint8_t num_iwd_types = o2h->data[2]; |
| 665 | uint8_t *cur = o2h->data+3; |
| 666 | unsigned int i, v; |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 667 | |
Harald Welte | 563d316 | 2011-02-12 18:11:16 +0100 | [diff] [blame] | 668 | uint8_t out_buf[1024]; |
| 669 | uint8_t *out_cur = out_buf+1; |
| 670 | uint8_t out_num_types = 0; |
| 671 | |
| 672 | memset(iwd_types, 0, sizeof(iwd_types)); |
| 673 | |
| 674 | /* Parse the RBS-supported IWD versions into iwd_types array */ |
| 675 | for (i = 0; i < num_iwd_types; i++) { |
| 676 | uint8_t num_versions = *cur++; |
| 677 | uint8_t iwd_type = *cur++; |
| 678 | |
| 679 | iwd_types[iwd_type].num_vers = num_versions; |
| 680 | |
| 681 | for (v = 0; v < num_versions; v++) { |
| 682 | struct iwd_version *iwd_v = &iwd_types[iwd_type].v[v]; |
| 683 | |
| 684 | memcpy(iwd_v->gen_char, cur, 3); |
Harald Welte | 56ee6b8 | 2011-02-12 18:13:37 +0100 | [diff] [blame] | 685 | cur += 3; |
| 686 | memcpy(iwd_v->rev_char, cur, 3); |
| 687 | cur += 3; |
| 688 | |
Harald Welte | 563d316 | 2011-02-12 18:11:16 +0100 | [diff] [blame] | 689 | DEBUGP(DNM, "\tIWD Type %u Gen %s Rev %s\n", iwd_type, |
| 690 | iwd_v->gen_char, iwd_v->rev_char); |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | /* Select the last version for each IWD type */ |
| 695 | for (i = 0; i < ARRAY_SIZE(iwd_types); i++) { |
| 696 | struct iwd_type *type = &iwd_types[i]; |
| 697 | struct iwd_version *last_v; |
| 698 | |
| 699 | if (type->num_vers == 0) |
| 700 | continue; |
| 701 | |
| 702 | out_num_types++; |
| 703 | |
| 704 | last_v = &type->v[type->num_vers-1]; |
| 705 | |
| 706 | *out_cur++ = i; |
| 707 | memcpy(out_cur, last_v->gen_char, 3); |
| 708 | out_cur += 3; |
| 709 | memcpy(out_cur, last_v->rev_char, 3); |
| 710 | out_cur += 3; |
| 711 | } |
| 712 | |
| 713 | out_buf[0] = out_num_types; |
| 714 | |
| 715 | return abis_om2k_tx_negot_req_ack(msg->trx->bts, &o2h->mo, out_buf, out_cur - out_buf); |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | static int om2k_rx_start_res(struct msgb *msg) |
| 719 | { |
| 720 | struct abis_om2k_hdr *o2h = msgb_l2(msg); |
| 721 | int rc; |
| 722 | |
| 723 | rc = abis_om2k_tx_simple(msg->trx->bts, &o2h->mo, OM2K_MSGT_START_RES_ACK); |
| 724 | rc = abis_om2k_tx_op_info(msg->trx->bts, &o2h->mo, 1); |
| 725 | |
| 726 | return rc; |
| 727 | } |
| 728 | |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 729 | static int om2k_rx_op_info_ack(struct msgb *msg) |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 730 | { |
| 731 | struct abis_om2k_hdr *o2h = msgb_l2(msg); |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 732 | |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 733 | /* FIXME: update Operational state in our structures */ |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 734 | |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 735 | return 0; |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | int abis_om2k_rcvmsg(struct msgb *msg) |
| 739 | { |
| 740 | struct gsm_bts *bts = msg->trx->bts; |
| 741 | struct abis_om2k_hdr *o2h = msgb_l2(msg); |
| 742 | struct abis_om_hdr *oh = &o2h->om; |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 743 | uint16_t msg_type = ntohs(o2h->msg_type); |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 744 | int rc = 0; |
| 745 | |
| 746 | /* Various consistency checks */ |
| 747 | if (oh->placement != ABIS_OM_PLACEMENT_ONLY) { |
| 748 | LOGP(DNM, LOGL_ERROR, "ABIS OML placement 0x%x not supported\n", |
| 749 | oh->placement); |
| 750 | if (oh->placement != ABIS_OM_PLACEMENT_FIRST) |
| 751 | return -EINVAL; |
| 752 | } |
| 753 | if (oh->sequence != 0) { |
| 754 | LOGP(DNM, LOGL_ERROR, "ABIS OML sequence 0x%x != 0x00\n", |
| 755 | oh->sequence); |
| 756 | return -EINVAL; |
| 757 | } |
| 758 | |
| 759 | msg->l3h = (unsigned char *)o2h + sizeof(*o2h); |
| 760 | |
| 761 | if (oh->mdisc != ABIS_OM_MDISC_FOM) { |
| 762 | LOGP(DNM, LOGL_ERROR, "unknown ABIS OM2000 message discriminator 0x%x\n", |
| 763 | oh->mdisc); |
| 764 | return -EINVAL; |
| 765 | } |
| 766 | |
Harald Welte | 7354107 | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 767 | DEBUGP(DNM, "Rx MO=%s %s (%s)\n", om2k_mo_name(&o2h->mo), |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 768 | get_value_string(om2k_msgcode_vals, msg_type), |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 769 | hexdump(msg->l2h, msgb_l2len(msg))); |
| 770 | |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 771 | switch (msg_type) { |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 772 | case OM2K_MSGT_CAL_TIME_REQ: |
| 773 | rc = abis_om2k_cal_time_resp(bts); |
| 774 | break; |
| 775 | case OM2K_MSGT_FAULT_REP: |
| 776 | rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_START_REQ); |
| 777 | rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_FAULT_REP_ACK); |
| 778 | break; |
| 779 | case OM2K_MSGT_NEGOT_REQ: |
| 780 | rc = om2k_rx_negot_req(msg); |
| 781 | break; |
| 782 | case OM2K_MSGT_START_RES: |
| 783 | rc = om2k_rx_start_res(msg); |
| 784 | break; |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 785 | case OM2K_MSGT_OP_INFO_ACK: |
| 786 | rc = om2k_rx_op_info_ack(msg); |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 787 | break; |
| 788 | case OM2K_MSGT_IS_CONF_RES: |
| 789 | rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_IS_CONF_RES_ACK); |
| 790 | break; |
| 791 | case OM2K_MSGT_CONNECT_COMPL: |
| 792 | rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_RESET_CMD); |
| 793 | break; |
| 794 | case OM2K_MSGT_RESET_COMPL: |
| 795 | rc = abis_om2k_tx_simple(bts, &o2h->mo, OM2K_MSGT_START_REQ); |
| 796 | break; |
| 797 | case OM2K_MSGT_START_REQ_ACK: |
| 798 | break; |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 799 | case OM2K_MSGT_STATUS_RESP: |
| 800 | break; |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 801 | default: |
Harald Welte | 0741ffe | 2011-02-12 18:48:53 +0100 | [diff] [blame] | 802 | LOGP(DNM, LOGL_NOTICE, "Rx unhandled OM2000 msg %s\n", |
Harald Welte | bc867d9 | 2011-02-12 13:09:38 +0100 | [diff] [blame] | 803 | get_value_string(om2k_msgcode_vals, msg_type)); |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | msgb_free(msg); |
| 807 | return rc; |
| 808 | } |