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