Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | /* GSM Network Management (OML) messages on the A-bis interface |
| 2 | * 3GPP TS 12.21 version 8.0.0 Release 1999 / ETSI TS 100 623 V8.0.0 */ |
| 3 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 4 | /* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 5 | * |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 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 General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 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 General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | #include <errno.h> |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 26 | #include <unistd.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 27 | #include <stdio.h> |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 28 | #include <fcntl.h> |
Harald Welte | 12247c6 | 2009-05-21 07:23:02 +0000 | [diff] [blame] | 29 | #include <stdlib.h> |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 30 | #include <libgen.h> |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 31 | #include <time.h> |
Harald Welte | 5f6f149 | 2009-02-02 14:50:29 +0000 | [diff] [blame] | 32 | #include <limits.h> |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 33 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 34 | #include <sys/types.h> |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 35 | #include <sys/stat.h> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 36 | #include <netinet/in.h> |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 37 | #include <arpa/inet.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 38 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 39 | #include <openbsc/gsm_data.h> |
| 40 | #include <openbsc/debug.h> |
| 41 | #include <openbsc/msgb.h> |
| 42 | #include <openbsc/tlv.h> |
| 43 | #include <openbsc/abis_nm.h> |
Holger Freyther | ca362a6 | 2009-01-04 21:05:01 +0000 | [diff] [blame] | 44 | #include <openbsc/misdn.h> |
Harald Welte | f9a8cc3 | 2009-05-01 15:39:49 +0000 | [diff] [blame] | 45 | #include <openbsc/signal.h> |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 46 | #include <openbsc/talloc.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 47 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 48 | #define OM_ALLOC_SIZE 1024 |
| 49 | #define OM_HEADROOM_SIZE 128 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 50 | |
| 51 | /* unidirectional messages from BTS to BSC */ |
| 52 | static const enum abis_nm_msgtype reports[] = { |
| 53 | NM_MT_SW_ACTIVATED_REP, |
| 54 | NM_MT_TEST_REP, |
| 55 | NM_MT_STATECHG_EVENT_REP, |
| 56 | NM_MT_FAILURE_EVENT_REP, |
| 57 | }; |
| 58 | |
| 59 | /* messages without ACK/NACK */ |
| 60 | static const enum abis_nm_msgtype no_ack_nack[] = { |
| 61 | NM_MT_MEAS_RES_REQ, |
| 62 | NM_MT_STOP_MEAS, |
| 63 | NM_MT_START_MEAS, |
| 64 | }; |
| 65 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 66 | /* Messages related to software load */ |
| 67 | static const enum abis_nm_msgtype sw_load_msgs[] = { |
| 68 | NM_MT_LOAD_INIT_ACK, |
| 69 | NM_MT_LOAD_INIT_NACK, |
| 70 | NM_MT_LOAD_SEG_ACK, |
| 71 | NM_MT_LOAD_ABORT, |
| 72 | NM_MT_LOAD_END_ACK, |
| 73 | NM_MT_LOAD_END_NACK, |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 74 | //NM_MT_SW_ACT_REQ, |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 75 | NM_MT_ACTIVATE_SW_ACK, |
| 76 | NM_MT_ACTIVATE_SW_NACK, |
| 77 | NM_MT_SW_ACTIVATED_REP, |
| 78 | }; |
| 79 | |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 80 | static const enum abis_nm_msgtype nacks[] = { |
| 81 | NM_MT_LOAD_INIT_NACK, |
| 82 | NM_MT_LOAD_END_NACK, |
| 83 | NM_MT_SW_ACT_REQ_NACK, |
| 84 | NM_MT_ACTIVATE_SW_NACK, |
| 85 | NM_MT_ESTABLISH_TEI_NACK, |
| 86 | NM_MT_CONN_TERR_SIGN_NACK, |
| 87 | NM_MT_DISC_TERR_SIGN_NACK, |
| 88 | NM_MT_CONN_TERR_TRAF_NACK, |
| 89 | NM_MT_DISC_TERR_TRAF_NACK, |
| 90 | NM_MT_CONN_MDROP_LINK_NACK, |
| 91 | NM_MT_DISC_MDROP_LINK_NACK, |
| 92 | NM_MT_SET_BTS_ATTR_NACK, |
| 93 | NM_MT_SET_RADIO_ATTR_NACK, |
| 94 | NM_MT_SET_CHAN_ATTR_NACK, |
| 95 | NM_MT_PERF_TEST_NACK, |
| 96 | NM_MT_SEND_TEST_REP_NACK, |
| 97 | NM_MT_STOP_TEST_NACK, |
| 98 | NM_MT_STOP_EVENT_REP_NACK, |
| 99 | NM_MT_REST_EVENT_REP_NACK, |
| 100 | NM_MT_CHG_ADM_STATE_NACK, |
| 101 | NM_MT_CHG_ADM_STATE_REQ_NACK, |
| 102 | NM_MT_REP_OUTST_ALARMS_NACK, |
| 103 | NM_MT_CHANGEOVER_NACK, |
| 104 | NM_MT_OPSTART_NACK, |
| 105 | NM_MT_REINIT_NACK, |
| 106 | NM_MT_SET_SITE_OUT_NACK, |
| 107 | NM_MT_CHG_HW_CONF_NACK, |
| 108 | NM_MT_GET_ATTR_NACK, |
| 109 | NM_MT_SET_ALARM_THRES_NACK, |
| 110 | NM_MT_BS11_BEGIN_DB_TX_NACK, |
| 111 | NM_MT_BS11_END_DB_TX_NACK, |
| 112 | NM_MT_BS11_CREATE_OBJ_NACK, |
| 113 | NM_MT_BS11_DELETE_OBJ_NACK, |
| 114 | }; |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 115 | |
| 116 | static const char *nack_names[0xff] = { |
| 117 | [NM_MT_LOAD_INIT_NACK] = "SOFTWARE LOAD INIT", |
| 118 | [NM_MT_LOAD_END_NACK] = "SOFTWARE LOAD END", |
| 119 | [NM_MT_SW_ACT_REQ_NACK] = "SOFTWARE ACTIVATE REQUEST", |
| 120 | [NM_MT_ACTIVATE_SW_NACK] = "ACTIVATE SOFTWARE", |
| 121 | [NM_MT_ESTABLISH_TEI_NACK] = "ESTABLISH TEI", |
| 122 | [NM_MT_CONN_TERR_SIGN_NACK] = "CONNECT TERRESTRIAL SIGNALLING", |
| 123 | [NM_MT_DISC_TERR_SIGN_NACK] = "DISCONNECT TERRESTRIAL SIGNALLING", |
| 124 | [NM_MT_CONN_TERR_TRAF_NACK] = "CONNECT TERRESTRIAL TRAFFIC", |
| 125 | [NM_MT_DISC_TERR_TRAF_NACK] = "DISCONNECT TERRESTRIAL TRAFFIC", |
| 126 | [NM_MT_CONN_MDROP_LINK_NACK] = "CONNECT MULTI-DROP LINK", |
| 127 | [NM_MT_DISC_MDROP_LINK_NACK] = "DISCONNECT MULTI-DROP LINK", |
| 128 | [NM_MT_SET_BTS_ATTR_NACK] = "SET BTS ATTRIBUTE", |
| 129 | [NM_MT_SET_RADIO_ATTR_NACK] = "SET RADIO ATTRIBUTE", |
| 130 | [NM_MT_SET_CHAN_ATTR_NACK] = "SET CHANNEL ATTRIBUTE", |
| 131 | [NM_MT_PERF_TEST_NACK] = "PERFORM TEST", |
| 132 | [NM_MT_SEND_TEST_REP_NACK] = "SEND TEST REPORT", |
| 133 | [NM_MT_STOP_TEST_NACK] = "STOP TEST", |
| 134 | [NM_MT_STOP_EVENT_REP_NACK] = "STOP EVENT REPORT", |
| 135 | [NM_MT_REST_EVENT_REP_NACK] = "RESET EVENT REPORT", |
| 136 | [NM_MT_CHG_ADM_STATE_NACK] = "CHANGE ADMINISTRATIVE STATE", |
| 137 | [NM_MT_CHG_ADM_STATE_REQ_NACK] = "CHANGE ADMINISTRATIVE STATE REQUEST", |
| 138 | [NM_MT_REP_OUTST_ALARMS_NACK] = "REPORT OUTSTANDING ALARMS", |
| 139 | [NM_MT_CHANGEOVER_NACK] = "CHANGEOVER", |
| 140 | [NM_MT_OPSTART_NACK] = "OPSTART", |
| 141 | [NM_MT_REINIT_NACK] = "REINIT", |
| 142 | [NM_MT_SET_SITE_OUT_NACK] = "SET SITE OUTPUT", |
| 143 | [NM_MT_CHG_HW_CONF_NACK] = "CHANGE HARDWARE CONFIGURATION", |
| 144 | [NM_MT_GET_ATTR_NACK] = "GET ATTRIBUTE", |
| 145 | [NM_MT_SET_ALARM_THRES_NACK] = "SET ALARM THRESHOLD", |
| 146 | [NM_MT_BS11_BEGIN_DB_TX_NACK] = "BS11 BEGIN DATABASE TRANSMISSION", |
| 147 | [NM_MT_BS11_END_DB_TX_NACK] = "BS11 END DATABASE TRANSMISSION", |
| 148 | [NM_MT_BS11_CREATE_OBJ_NACK] = "BS11 CREATE OBJECT", |
| 149 | [NM_MT_BS11_DELETE_OBJ_NACK] = "BS11 DELETE OBJECT", |
| 150 | }; |
| 151 | |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 152 | /* Chapter 9.4.36 */ |
| 153 | static const char *nack_cause_names[] = { |
| 154 | /* General Nack Causes */ |
| 155 | [NM_NACK_INCORR_STRUCT] = "Incorrect message structure", |
| 156 | [NM_NACK_MSGTYPE_INVAL] = "Invalid message type value", |
| 157 | [NM_NACK_OBJCLASS_INVAL] = "Invalid Object class value", |
| 158 | [NM_NACK_OBJCLASS_NOTSUPP] = "Object class not supported", |
| 159 | [NM_NACK_BTSNR_UNKN] = "BTS no. unknown", |
| 160 | [NM_NACK_TRXNR_UNKN] = "Baseband Transceiver no. unknown", |
| 161 | [NM_NACK_OBJINST_UNKN] = "Object Instance unknown", |
| 162 | [NM_NACK_ATTRID_INVAL] = "Invalid attribute identifier value", |
| 163 | [NM_NACK_ATTRID_NOTSUPP] = "Attribute identifier not supported", |
| 164 | [NM_NACK_PARAM_RANGE] = "Parameter value outside permitted range", |
| 165 | [NM_NACK_ATTRLIST_INCONSISTENT] = "Inconsistency in attribute list", |
| 166 | [NM_NACK_SPEC_IMPL_NOTSUPP] = "Specified implementation not supported", |
| 167 | [NM_NACK_CANT_PERFORM] = "Message cannot be performed", |
| 168 | /* Specific Nack Causes */ |
| 169 | [NM_NACK_RES_NOTIMPL] = "Resource not implemented", |
| 170 | [NM_NACK_RES_NOTAVAIL] = "Resource not available", |
| 171 | [NM_NACK_FREQ_NOTAVAIL] = "Frequency not available", |
| 172 | [NM_NACK_TEST_NOTSUPP] = "Test not supported", |
| 173 | [NM_NACK_CAPACITY_RESTR] = "Capacity restrictions", |
| 174 | [NM_NACK_PHYSCFG_NOTPERFORM] = "Physical configuration cannot be performed", |
| 175 | [NM_NACK_TEST_NOTINIT] = "Test not initiated", |
| 176 | [NM_NACK_PHYSCFG_NOTRESTORE] = "Physical configuration cannot be restored", |
| 177 | [NM_NACK_TEST_NOSUCH] = "No such test", |
| 178 | [NM_NACK_TEST_NOSTOP] = "Test cannot be stopped", |
| 179 | [NM_NACK_MSGINCONSIST_PHYSCFG] = "Message inconsistent with physical configuration", |
| 180 | [NM_NACK_FILE_INCOMPLETE] = "Complete file notreceived", |
| 181 | [NM_NACK_FILE_NOTAVAIL] = "File not available at destination", |
Harald Welte | 560982b | 2009-06-26 13:21:57 +0200 | [diff] [blame] | 182 | [NM_NACK_FILE_NOTACTIVATE] = "File cannot be activate", |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 183 | [NM_NACK_REQ_NOT_GRANT] = "Request not granted", |
| 184 | [NM_NACK_WAIT] = "Wait", |
| 185 | [NM_NACK_NOTH_REPORT_EXIST] = "Nothing reportable existing", |
| 186 | [NM_NACK_MEAS_NOTSUPP] = "Measurement not supported", |
| 187 | [NM_NACK_MEAS_NOTSTART] = "Measurement not started", |
| 188 | }; |
| 189 | |
| 190 | static char namebuf[255]; |
| 191 | static const char *nack_cause_name(u_int8_t cause) |
| 192 | { |
| 193 | if (cause < ARRAY_SIZE(nack_cause_names) && nack_cause_names[cause]) |
| 194 | return nack_cause_names[cause]; |
| 195 | |
| 196 | snprintf(namebuf, sizeof(namebuf), "0x%02x\n", cause); |
| 197 | return namebuf; |
| 198 | } |
| 199 | |
Harald Welte | 0db97b2 | 2009-05-01 17:22:47 +0000 | [diff] [blame] | 200 | /* Chapter 9.4.16: Event Type */ |
| 201 | static const char *event_type_names[] = { |
| 202 | [NM_EVT_COMM_FAIL] = "communication failure", |
| 203 | [NM_EVT_QOS_FAIL] = "quality of service failure", |
| 204 | [NM_EVT_PROC_FAIL] = "processing failure", |
| 205 | [NM_EVT_EQUIP_FAIL] = "equipment failure", |
| 206 | [NM_EVT_ENV_FAIL] = "environment failure", |
| 207 | }; |
| 208 | |
| 209 | static const char *event_type_name(u_int8_t cause) |
| 210 | { |
| 211 | if (cause < ARRAY_SIZE(event_type_names) && event_type_names[cause]) |
| 212 | return event_type_names[cause]; |
| 213 | |
| 214 | snprintf(namebuf, sizeof(namebuf), "0x%02x\n", cause); |
| 215 | return namebuf; |
| 216 | } |
| 217 | |
| 218 | /* Chapter 9.4.63: Perceived Severity */ |
| 219 | static const char *severity_names[] = { |
| 220 | [NM_SEVER_CEASED] = "failure ceased", |
| 221 | [NM_SEVER_CRITICAL] = "critical failure", |
| 222 | [NM_SEVER_MAJOR] = "major failure", |
| 223 | [NM_SEVER_MINOR] = "minor failure", |
| 224 | [NM_SEVER_WARNING] = "warning level failure", |
| 225 | [NM_SEVER_INDETERMINATE] = "indeterminate failure", |
| 226 | }; |
| 227 | |
| 228 | static const char *severity_name(u_int8_t cause) |
| 229 | { |
| 230 | if (cause < ARRAY_SIZE(severity_names) && severity_names[cause]) |
| 231 | return severity_names[cause]; |
| 232 | |
| 233 | snprintf(namebuf, sizeof(namebuf), "0x%02x\n", cause); |
| 234 | return namebuf; |
| 235 | } |
| 236 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 237 | /* Attributes that the BSC can set, not only get, according to Section 9.4 */ |
| 238 | static const enum abis_nm_attr nm_att_settable[] = { |
| 239 | NM_ATT_ADD_INFO, |
| 240 | NM_ATT_ADD_TEXT, |
| 241 | NM_ATT_DEST, |
| 242 | NM_ATT_EVENT_TYPE, |
| 243 | NM_ATT_FILE_DATA, |
| 244 | NM_ATT_GET_ARI, |
| 245 | NM_ATT_HW_CONF_CHG, |
| 246 | NM_ATT_LIST_REQ_ATTR, |
| 247 | NM_ATT_MDROP_LINK, |
| 248 | NM_ATT_MDROP_NEXT, |
| 249 | NM_ATT_NACK_CAUSES, |
| 250 | NM_ATT_OUTST_ALARM, |
| 251 | NM_ATT_PHYS_CONF, |
| 252 | NM_ATT_PROB_CAUSE, |
| 253 | NM_ATT_RAD_SUBC, |
| 254 | NM_ATT_SOURCE, |
| 255 | NM_ATT_SPEC_PROB, |
| 256 | NM_ATT_START_TIME, |
| 257 | NM_ATT_TEST_DUR, |
| 258 | NM_ATT_TEST_NO, |
| 259 | NM_ATT_TEST_REPORT, |
| 260 | NM_ATT_WINDOW_SIZE, |
| 261 | NM_ATT_SEVERITY, |
| 262 | NM_ATT_MEAS_RES, |
| 263 | NM_ATT_MEAS_TYPE, |
| 264 | }; |
| 265 | |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 266 | static const struct tlv_definition nm_att_tlvdef = { |
| 267 | .def = { |
| 268 | [NM_ATT_ABIS_CHANNEL] = { TLV_TYPE_FIXED, 3 }, |
| 269 | [NM_ATT_ADD_INFO] = { TLV_TYPE_TL16V }, |
| 270 | [NM_ATT_ADD_TEXT] = { TLV_TYPE_TL16V }, |
| 271 | [NM_ATT_ADM_STATE] = { TLV_TYPE_TV }, |
| 272 | [NM_ATT_ARFCN_LIST]= { TLV_TYPE_TL16V }, |
| 273 | [NM_ATT_AUTON_REPORT] = { TLV_TYPE_TV }, |
| 274 | [NM_ATT_AVAIL_STATUS] = { TLV_TYPE_TL16V }, |
| 275 | [NM_ATT_BCCH_ARFCN] = { TLV_TYPE_FIXED, 2 }, |
| 276 | [NM_ATT_BSIC] = { TLV_TYPE_TV }, |
| 277 | [NM_ATT_BTS_AIR_TIMER] = { TLV_TYPE_TV }, |
| 278 | [NM_ATT_CCCH_L_I_P] = { TLV_TYPE_TV }, |
| 279 | [NM_ATT_CCCH_L_T] = { TLV_TYPE_TV }, |
| 280 | [NM_ATT_CHAN_COMB] = { TLV_TYPE_TV }, |
| 281 | [NM_ATT_CONN_FAIL_CRIT] = { TLV_TYPE_TL16V }, |
| 282 | [NM_ATT_DEST] = { TLV_TYPE_TL16V }, |
| 283 | [NM_ATT_EVENT_TYPE] = { TLV_TYPE_TV }, |
| 284 | [NM_ATT_FILE_DATA] = { TLV_TYPE_TL16V }, |
| 285 | [NM_ATT_FILE_ID] = { TLV_TYPE_TL16V }, |
| 286 | [NM_ATT_FILE_VERSION] = { TLV_TYPE_TL16V }, |
| 287 | [NM_ATT_GSM_TIME] = { TLV_TYPE_FIXED, 2 }, |
| 288 | [NM_ATT_HSN] = { TLV_TYPE_TV }, |
| 289 | [NM_ATT_HW_CONFIG] = { TLV_TYPE_TL16V }, |
| 290 | [NM_ATT_HW_DESC] = { TLV_TYPE_TL16V }, |
| 291 | [NM_ATT_INTAVE_PARAM] = { TLV_TYPE_TV }, |
| 292 | [NM_ATT_INTERF_BOUND] = { TLV_TYPE_FIXED, 6 }, |
| 293 | [NM_ATT_LIST_REQ_ATTR] = { TLV_TYPE_TL16V }, |
| 294 | [NM_ATT_MAIO] = { TLV_TYPE_TV }, |
| 295 | [NM_ATT_MANUF_STATE] = { TLV_TYPE_TV }, |
| 296 | [NM_ATT_MANUF_THRESH] = { TLV_TYPE_TL16V }, |
| 297 | [NM_ATT_MANUF_ID] = { TLV_TYPE_TL16V }, |
| 298 | [NM_ATT_MAX_TA] = { TLV_TYPE_TV }, |
| 299 | [NM_ATT_MDROP_LINK] = { TLV_TYPE_FIXED, 2 }, |
| 300 | [NM_ATT_MDROP_NEXT] = { TLV_TYPE_FIXED, 2 }, |
| 301 | [NM_ATT_NACK_CAUSES] = { TLV_TYPE_TV }, |
| 302 | [NM_ATT_NY1] = { TLV_TYPE_TV }, |
| 303 | [NM_ATT_OPER_STATE] = { TLV_TYPE_TV }, |
| 304 | [NM_ATT_OVERL_PERIOD] = { TLV_TYPE_TL16V }, |
| 305 | [NM_ATT_PHYS_CONF] = { TLV_TYPE_TL16V }, |
| 306 | [NM_ATT_POWER_CLASS] = { TLV_TYPE_TV }, |
| 307 | [NM_ATT_POWER_THRESH] = { TLV_TYPE_FIXED, 3 }, |
| 308 | [NM_ATT_PROB_CAUSE] = { TLV_TYPE_FIXED, 3 }, |
| 309 | [NM_ATT_RACH_B_THRESH] = { TLV_TYPE_TV }, |
| 310 | [NM_ATT_LDAVG_SLOTS] = { TLV_TYPE_FIXED, 2 }, |
| 311 | [NM_ATT_RAD_SUBC] = { TLV_TYPE_TV }, |
| 312 | [NM_ATT_RF_MAXPOWR_R] = { TLV_TYPE_TV }, |
| 313 | [NM_ATT_SITE_INPUTS] = { TLV_TYPE_TL16V }, |
| 314 | [NM_ATT_SITE_OUTPUTS] = { TLV_TYPE_TL16V }, |
| 315 | [NM_ATT_SOURCE] = { TLV_TYPE_TL16V }, |
| 316 | [NM_ATT_SPEC_PROB] = { TLV_TYPE_TV }, |
| 317 | [NM_ATT_START_TIME] = { TLV_TYPE_FIXED, 2 }, |
| 318 | [NM_ATT_T200] = { TLV_TYPE_FIXED, 7 }, |
| 319 | [NM_ATT_TEI] = { TLV_TYPE_TV }, |
| 320 | [NM_ATT_TEST_DUR] = { TLV_TYPE_FIXED, 2 }, |
| 321 | [NM_ATT_TEST_NO] = { TLV_TYPE_TV }, |
| 322 | [NM_ATT_TEST_REPORT] = { TLV_TYPE_TL16V }, |
| 323 | [NM_ATT_VSWR_THRESH] = { TLV_TYPE_FIXED, 2 }, |
| 324 | [NM_ATT_WINDOW_SIZE] = { TLV_TYPE_TV }, |
| 325 | [NM_ATT_TSC] = { TLV_TYPE_TV }, |
| 326 | [NM_ATT_SW_CONFIG] = { TLV_TYPE_TL16V }, |
| 327 | [NM_ATT_SEVERITY] = { TLV_TYPE_TV }, |
| 328 | [NM_ATT_GET_ARI] = { TLV_TYPE_TL16V }, |
| 329 | [NM_ATT_HW_CONF_CHG] = { TLV_TYPE_TL16V }, |
| 330 | [NM_ATT_OUTST_ALARM] = { TLV_TYPE_TV }, |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 331 | [NM_ATT_MEAS_RES] = { TLV_TYPE_TL16V }, |
| 332 | /* BS11 specifics */ |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 333 | [NM_ATT_BS11_ESN_FW_CODE_NO] = { TLV_TYPE_TLV }, |
| 334 | [NM_ATT_BS11_ESN_HW_CODE_NO] = { TLV_TYPE_TLV }, |
| 335 | [NM_ATT_BS11_ESN_PCB_SERIAL] = { TLV_TYPE_TLV }, |
| 336 | [NM_ATT_BS11_BOOT_SW_VERS] = { TLV_TYPE_TLV }, |
| 337 | [0xd5] = { TLV_TYPE_TLV }, |
| 338 | [0xa8] = { TLV_TYPE_TLV }, |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 339 | [NM_ATT_BS11_PASSWORD] = { TLV_TYPE_TLV }, |
| 340 | [NM_ATT_BS11_TXPWR] = { TLV_TYPE_TLV }, |
| 341 | [NM_ATT_BS11_RSSI_OFFS] = { TLV_TYPE_TLV }, |
| 342 | [NM_ATT_BS11_LINE_CFG] = { TLV_TYPE_TV }, |
| 343 | [NM_ATT_BS11_L1_PROT_TYPE] = { TLV_TYPE_TV }, |
| 344 | [NM_ATT_BS11_BIT_ERR_THESH] = { TLV_TYPE_FIXED, 2 }, |
| 345 | [NM_ATT_BS11_DIVERSITY] = { TLV_TYPE_TLV }, |
Harald Welte | ee67047 | 2009-02-22 21:58:49 +0000 | [diff] [blame] | 346 | [NM_ATT_BS11_LMT_LOGON_SESSION]={ TLV_TYPE_TLV }, |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 347 | [NM_ATT_BS11_LMT_LOGIN_TIME] = { TLV_TYPE_TLV }, |
| 348 | [NM_ATT_BS11_LMT_USER_ACC_LEV] ={ TLV_TYPE_TLV }, |
| 349 | [NM_ATT_BS11_LMT_USER_NAME] = { TLV_TYPE_TLV }, |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 350 | [NM_ATT_BS11_BTS_STATE] = { TLV_TYPE_TLV }, |
| 351 | [NM_ATT_BS11_E1_STATE] = { TLV_TYPE_TLV }, |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 352 | [NM_ATT_BS11_PLL_MODE] = { TLV_TYPE_TLV }, |
Harald Welte | a7cfa03 | 2009-04-29 22:33:02 +0000 | [diff] [blame] | 353 | [NM_ATT_BS11_PLL] = { TLV_TYPE_TLV }, |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 354 | [NM_ATT_BS11_CCLK_ACCURACY] = { TLV_TYPE_TV }, |
| 355 | [NM_ATT_BS11_CCLK_TYPE] = { TLV_TYPE_TV }, |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 356 | /* ip.access specifics */ |
Harald Welte | 0efe9b7 | 2009-07-12 09:33:54 +0200 | [diff] [blame] | 357 | [NM_ATT_IPACC_DST_IP] = { TLV_TYPE_FIXED, 4 }, |
| 358 | [NM_ATT_IPACC_DST_IP_PORT] = { TLV_TYPE_FIXED, 2 }, |
Harald Welte | 4fbfd3a | 2009-08-06 17:57:23 +0200 | [diff] [blame] | 359 | [NM_ATT_IPACC_STREAM_ID] = { TLV_TYPE_TV, }, |
| 360 | [NM_ATT_IPACC_FREQ_CTRL] = { TLV_TYPE_TV, }, |
| 361 | [NM_ATT_IPACC_SEC_OML_CFG] = { TLV_TYPE_FIXED, 6 }, |
| 362 | [NM_ATT_IPACC_IP_IF_CFG] = { TLV_TYPE_FIXED, 8 }, |
| 363 | [NM_ATT_IPACC_IP_GW_CFG] = { TLV_TYPE_FIXED, 12 }, |
| 364 | [NM_ATT_IPACC_IN_SERV_TIME] = { TLV_TYPE_FIXED, 4 }, |
| 365 | [NM_ATT_IPACC_LOCATION] = { TLV_TYPE_TL16V }, |
| 366 | [NM_ATT_IPACC_PAGING_CFG] = { TLV_TYPE_FIXED, 2 }, |
| 367 | [NM_ATT_IPACC_UNIT_ID] = { TLV_TYPE_TL16V }, |
| 368 | [NM_ATT_IPACC_UNIT_NAME] = { TLV_TYPE_TL16V }, |
| 369 | [NM_ATT_IPACC_SNMP_CFG] = { TLV_TYPE_TL16V }, |
Harald Welte | 0efe9b7 | 2009-07-12 09:33:54 +0200 | [diff] [blame] | 370 | [NM_ATT_IPACC_PRIM_OML_CFG_LIST] = { TLV_TYPE_TL16V }, |
Harald Welte | a0c0b57 | 2009-07-03 12:46:27 +0200 | [diff] [blame] | 371 | [NM_ATT_IPACC_NV_FLAGS] = { TLV_TYPE_TL16V }, |
| 372 | [NM_ATT_IPACC_FREQ_CTRL] = { TLV_TYPE_FIXED, 2 }, |
Harald Welte | 0efe9b7 | 2009-07-12 09:33:54 +0200 | [diff] [blame] | 373 | [NM_ATT_IPACC_PRIM_OML_FB_TOUT] = { TLV_TYPE_TL16V }, |
Harald Welte | 4fbfd3a | 2009-08-06 17:57:23 +0200 | [diff] [blame] | 374 | [NM_ATT_IPACC_CUR_SW_CFG] = { TLV_TYPE_TL16V }, |
| 375 | [NM_ATT_IPACC_TIMING_BUS] = { TLV_TYPE_TL16V }, |
| 376 | [NM_ATT_IPACC_CGI] = { TLV_TYPE_TL16V }, |
| 377 | [NM_ATT_IPACC_RAC] = { TLV_TYPE_TL16V }, |
| 378 | [NM_ATT_IPACC_OBJ_VERSION] = { TLV_TYPE_TL16V }, |
| 379 | [NM_ATT_IPACC_GPRS_PAGING_CFG]= { TLV_TYPE_TL16V }, |
| 380 | [NM_ATT_IPACC_NSEI] = { TLV_TYPE_TL16V }, |
| 381 | [NM_ATT_IPACC_BVCI] = { TLV_TYPE_TL16V }, |
| 382 | [NM_ATT_IPACC_NSVCI] = { TLV_TYPE_TL16V }, |
| 383 | [NM_ATT_IPACC_NS_CFG] = { TLV_TYPE_TL16V }, |
| 384 | [NM_ATT_IPACC_BSSGP_CFG] = { TLV_TYPE_TL16V }, |
| 385 | [NM_ATT_IPACC_NS_LINK_CFG] = { TLV_TYPE_TL16V }, |
| 386 | [NM_ATT_IPACC_RLC_CFG] = { TLV_TYPE_TL16V }, |
Harald Welte | a0c0b57 | 2009-07-03 12:46:27 +0200 | [diff] [blame] | 387 | [NM_ATT_IPACC_ALM_THRESH_LIST]= { TLV_TYPE_TL16V }, |
Harald Welte | 4fbfd3a | 2009-08-06 17:57:23 +0200 | [diff] [blame] | 388 | [NM_ATT_IPACC_MONIT_VAL_LIST] = { TLV_TYPE_TL16V }, |
| 389 | [NM_ATT_IPACC_TIB_CONTROL] = { TLV_TYPE_TL16V }, |
| 390 | [NM_ATT_IPACC_SUPP_FEATURES] = { TLV_TYPE_TL16V }, |
| 391 | [NM_ATT_IPACC_CODING_SCHEMES] = { TLV_TYPE_TL16V }, |
| 392 | [NM_ATT_IPACC_RLC_CFG_2] = { TLV_TYPE_TL16V }, |
| 393 | [NM_ATT_IPACC_HEARTB_TOUT] = { TLV_TYPE_TL16V }, |
| 394 | [NM_ATT_IPACC_UPTIME] = { TLV_TYPE_TL16V }, |
| 395 | [NM_ATT_IPACC_RLC_CFG_3] = { TLV_TYPE_TL16V }, |
| 396 | [NM_ATT_IPACC_SSL_CFG] = { TLV_TYPE_TL16V }, |
| 397 | [NM_ATT_IPACC_SEC_POSSIBLE] = { TLV_TYPE_TL16V }, |
| 398 | [NM_ATT_IPACC_IML_SSL_STATE] = { TLV_TYPE_TL16V }, |
| 399 | [NM_ATT_IPACC_REVOC_DATE] = { TLV_TYPE_TL16V }, |
Harald Welte | a0c0b57 | 2009-07-03 12:46:27 +0200 | [diff] [blame] | 400 | //[0x95] = { TLV_TYPE_FIXED, 2 }, |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 401 | [0x85] = { TLV_TYPE_TV }, |
| 402 | |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 403 | }, |
| 404 | }; |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 405 | |
Harald Welte | 21bd3a5 | 2009-08-10 12:21:22 +0200 | [diff] [blame] | 406 | static const enum abis_nm_chan_comb chcomb4pchan[] = { |
| 407 | [GSM_PCHAN_CCCH] = NM_CHANC_mainBCCH, |
| 408 | [GSM_PCHAN_CCCH_SDCCH4] = NM_CHANC_BCCHComb, |
| 409 | [GSM_PCHAN_TCH_F] = NM_CHANC_TCHFull, |
| 410 | [GSM_PCHAN_TCH_H] = NM_CHANC_TCHHalf, |
| 411 | [GSM_PCHAN_SDCCH8_SACCH8C] = NM_CHANC_SDCCH, |
Harald Welte | a1499d0 | 2009-10-24 10:25:50 +0200 | [diff] [blame] | 412 | [GSM_PCHAN_PDCH] = NM_CHANC_IPAC_PDCH, |
| 413 | [GSM_PCHAN_TCH_F_PDCH] = NM_CHANC_IPAC_TCHFull_PDCH, |
Harald Welte | 21bd3a5 | 2009-08-10 12:21:22 +0200 | [diff] [blame] | 414 | /* FIXME: bounds check */ |
| 415 | }; |
| 416 | |
| 417 | int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan) |
| 418 | { |
| 419 | if (pchan < ARRAY_SIZE(chcomb4pchan)) |
| 420 | return chcomb4pchan[pchan]; |
| 421 | |
| 422 | return -EINVAL; |
| 423 | } |
| 424 | |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 425 | int abis_nm_tlv_parse(struct tlv_parsed *tp, const u_int8_t *buf, int len) |
| 426 | { |
Harald Welte | a4d49e9 | 2009-05-23 06:39:58 +0000 | [diff] [blame] | 427 | return tlv_parse(tp, &nm_att_tlvdef, buf, len, 0, 0); |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 428 | } |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 429 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 430 | static int is_in_arr(enum abis_nm_msgtype mt, const enum abis_nm_msgtype *arr, int size) |
| 431 | { |
| 432 | int i; |
| 433 | |
| 434 | for (i = 0; i < size; i++) { |
| 435 | if (arr[i] == mt) |
| 436 | return 1; |
| 437 | } |
| 438 | |
| 439 | return 0; |
| 440 | } |
| 441 | |
Holger Freyther | ca362a6 | 2009-01-04 21:05:01 +0000 | [diff] [blame] | 442 | #if 0 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 443 | /* is this msgtype the usual ACK/NACK type ? */ |
| 444 | static int is_ack_nack(enum abis_nm_msgtype mt) |
| 445 | { |
| 446 | return !is_in_arr(mt, no_ack_nack, ARRAY_SIZE(no_ack_nack)); |
| 447 | } |
Holger Freyther | ca362a6 | 2009-01-04 21:05:01 +0000 | [diff] [blame] | 448 | #endif |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 449 | |
| 450 | /* is this msgtype a report ? */ |
| 451 | static int is_report(enum abis_nm_msgtype mt) |
| 452 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 453 | return is_in_arr(mt, reports, ARRAY_SIZE(reports)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | #define MT_ACK(x) (x+1) |
| 457 | #define MT_NACK(x) (x+2) |
| 458 | |
| 459 | static void fill_om_hdr(struct abis_om_hdr *oh, u_int8_t len) |
| 460 | { |
| 461 | oh->mdisc = ABIS_OM_MDISC_FOM; |
| 462 | oh->placement = ABIS_OM_PLACEMENT_ONLY; |
| 463 | oh->sequence = 0; |
| 464 | oh->length = len; |
| 465 | } |
| 466 | |
| 467 | static void fill_om_fom_hdr(struct abis_om_hdr *oh, u_int8_t len, |
| 468 | u_int8_t msg_type, u_int8_t obj_class, |
| 469 | u_int8_t bts_nr, u_int8_t trx_nr, u_int8_t ts_nr) |
| 470 | { |
| 471 | struct abis_om_fom_hdr *foh = |
| 472 | (struct abis_om_fom_hdr *) oh->data; |
| 473 | |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 474 | fill_om_hdr(oh, len+sizeof(*foh)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 475 | foh->msg_type = msg_type; |
| 476 | foh->obj_class = obj_class; |
| 477 | foh->obj_inst.bts_nr = bts_nr; |
| 478 | foh->obj_inst.trx_nr = trx_nr; |
| 479 | foh->obj_inst.ts_nr = ts_nr; |
| 480 | } |
| 481 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 482 | static struct msgb *nm_msgb_alloc(void) |
| 483 | { |
Harald Welte | 966636f | 2009-06-26 19:39:35 +0200 | [diff] [blame] | 484 | return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE, |
| 485 | "OML"); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 486 | } |
| 487 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 488 | /* Send a OML NM Message from BSC to BTS */ |
| 489 | int abis_nm_sendmsg(struct gsm_bts *bts, struct msgb *msg) |
| 490 | { |
Holger Freyther | 59639e8 | 2009-02-09 23:09:55 +0000 | [diff] [blame] | 491 | msg->trx = bts->c0; |
| 492 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 493 | return _abis_nm_sendmsg(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 494 | } |
| 495 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 496 | static int abis_nm_rcvmsg_sw(struct msgb *mb); |
| 497 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 498 | static const char *obj_class_name(u_int8_t oc) |
| 499 | { |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 500 | switch (oc) { |
| 501 | case NM_OC_SITE_MANAGER: |
| 502 | return "SITE MANAGER"; |
| 503 | case NM_OC_BTS: |
| 504 | return "BTS"; |
| 505 | case NM_OC_RADIO_CARRIER: |
| 506 | return "RADIO CARRIER"; |
| 507 | case NM_OC_BASEB_TRANSC: |
| 508 | return "BASEBAND TRANSCEIVER"; |
| 509 | case NM_OC_CHANNEL: |
Harald Welte | bd8f7e3 | 2009-06-09 20:17:12 +0000 | [diff] [blame] | 510 | return "CHANNEL"; |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 511 | case NM_OC_BS11_ADJC: |
| 512 | return "ADJC"; |
| 513 | case NM_OC_BS11_HANDOVER: |
| 514 | return "HANDOVER"; |
| 515 | case NM_OC_BS11_PWR_CTRL: |
| 516 | return "POWER CONTROL"; |
| 517 | case NM_OC_BS11_BTSE: |
| 518 | return "BTSE"; |
| 519 | case NM_OC_BS11_RACK: |
| 520 | return "RACK"; |
| 521 | case NM_OC_BS11_TEST: |
| 522 | return "TEST"; |
| 523 | case NM_OC_BS11_ENVABTSE: |
| 524 | return "ENVABTSE"; |
| 525 | case NM_OC_BS11_BPORT: |
| 526 | return "BPORT"; |
| 527 | case NM_OC_GPRS_NSE: |
| 528 | return "GPRS NSE"; |
| 529 | case NM_OC_GPRS_CELL: |
| 530 | return "GPRS CELL"; |
Harald Welte | d83a127 | 2009-07-12 10:56:06 +0200 | [diff] [blame] | 531 | case NM_OC_GPRS_NSVC: |
| 532 | return "GPRS NSVC"; |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 533 | case NM_OC_BS11: |
| 534 | return "SIEMENSHW"; |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | return "UNKNOWN"; |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 538 | } |
| 539 | |
Harald Welte | 4d87f24 | 2009-03-10 19:43:44 +0000 | [diff] [blame] | 540 | const char *nm_opstate_name(u_int8_t os) |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 541 | { |
| 542 | switch (os) { |
| 543 | case 1: |
| 544 | return "Disabled"; |
| 545 | case 2: |
| 546 | return "Enabled"; |
| 547 | case 0xff: |
| 548 | return "NULL"; |
| 549 | default: |
| 550 | return "RFU"; |
| 551 | } |
| 552 | } |
| 553 | |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 554 | /* Chapter 9.4.7 */ |
Harald Welte | 4d87f24 | 2009-03-10 19:43:44 +0000 | [diff] [blame] | 555 | static const char *avail_names[] = { |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 556 | "In test", |
| 557 | "Failed", |
| 558 | "Power off", |
| 559 | "Off line", |
| 560 | "<not used>", |
| 561 | "Dependency", |
| 562 | "Degraded", |
| 563 | "Not installed", |
| 564 | }; |
| 565 | |
Harald Welte | 4d87f24 | 2009-03-10 19:43:44 +0000 | [diff] [blame] | 566 | const char *nm_avail_name(u_int8_t avail) |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 567 | { |
Harald Welte | 0b8348d | 2009-02-18 03:43:01 +0000 | [diff] [blame] | 568 | if (avail == 0xff) |
| 569 | return "OK"; |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 570 | if (avail >= ARRAY_SIZE(avail_names)) |
| 571 | return "UNKNOWN"; |
| 572 | return avail_names[avail]; |
| 573 | } |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 574 | |
Harald Welte | 0f25585 | 2009-11-12 14:48:42 +0100 | [diff] [blame] | 575 | static struct value_string test_names[] = { |
| 576 | /* FIXME: standard test names */ |
| 577 | { NM_IPACC_TESTNO_CHAN_USAGE, "Channel Usage" }, |
| 578 | { NM_IPACC_TESTNO_BCCH_CHAN_USAGE, "BCCH Channel Usage" }, |
| 579 | { NM_IPACC_TESTNO_FREQ_SYNC, "Frequency Synchronization" }, |
| 580 | { NM_IPACC_TESTNO_BCCH_INFO, "BCCH Info" }, |
| 581 | { NM_IPACC_TESTNO_TX_BEACON, "Transmit Beacon" }, |
| 582 | { NM_IPACC_TESTNO_SYSINFO_MONITOR, "System Info Monitor" }, |
| 583 | { NM_IPACC_TESTNO_BCCCH_MONITOR, "BCCH Monitor" }, |
| 584 | { 0, NULL } |
| 585 | }; |
| 586 | |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 587 | const char *nm_adm_name(u_int8_t adm) |
| 588 | { |
| 589 | switch (adm) { |
| 590 | case 1: |
| 591 | return "Locked"; |
| 592 | case 2: |
| 593 | return "Unlocked"; |
| 594 | case 3: |
| 595 | return "Shutdown"; |
| 596 | default: |
| 597 | return "<not used>"; |
| 598 | } |
| 599 | } |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 600 | |
Harald Welte | a8bd6d4 | 2009-10-20 09:56:18 +0200 | [diff] [blame] | 601 | static void debugp_foh(struct abis_om_fom_hdr *foh) |
| 602 | { |
| 603 | DEBUGP(DNM, "OC=%s(%02x) INST=(%02x,%02x,%02x) ", |
| 604 | obj_class_name(foh->obj_class), foh->obj_class, |
| 605 | foh->obj_inst.bts_nr, foh->obj_inst.trx_nr, |
| 606 | foh->obj_inst.ts_nr); |
| 607 | } |
| 608 | |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 609 | /* obtain the gsm_nm_state data structure for a given object instance */ |
| 610 | static struct gsm_nm_state * |
| 611 | objclass2nmstate(struct gsm_bts *bts, u_int8_t obj_class, |
| 612 | struct abis_om_obj_inst *obj_inst) |
| 613 | { |
| 614 | struct gsm_bts_trx *trx; |
| 615 | struct gsm_nm_state *nm_state = NULL; |
| 616 | |
| 617 | switch (obj_class) { |
| 618 | case NM_OC_BTS: |
| 619 | nm_state = &bts->nm_state; |
| 620 | break; |
| 621 | case NM_OC_RADIO_CARRIER: |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 622 | if (obj_inst->trx_nr >= bts->num_trx) { |
| 623 | DEBUGPC(DNM, "TRX %u does not exist ", obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 624 | return NULL; |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 625 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 626 | trx = gsm_bts_trx_num(bts, obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 627 | nm_state = &trx->nm_state; |
| 628 | break; |
| 629 | case NM_OC_BASEB_TRANSC: |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 630 | if (obj_inst->trx_nr >= bts->num_trx) { |
| 631 | DEBUGPC(DNM, "TRX %u does not exist ", obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 632 | return NULL; |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 633 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 634 | trx = gsm_bts_trx_num(bts, obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 635 | nm_state = &trx->bb_transc.nm_state; |
| 636 | break; |
| 637 | case NM_OC_CHANNEL: |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 638 | if (obj_inst->trx_nr > bts->num_trx) { |
| 639 | DEBUGPC(DNM, "TRX %u does not exist ", obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 640 | return NULL; |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 641 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 642 | trx = gsm_bts_trx_num(bts, obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 643 | if (obj_inst->ts_nr >= TRX_NR_TS) |
| 644 | return NULL; |
| 645 | nm_state = &trx->ts[obj_inst->ts_nr].nm_state; |
| 646 | break; |
| 647 | case NM_OC_SITE_MANAGER: |
| 648 | nm_state = &bts->site_mgr.nm_state; |
| 649 | break; |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 650 | case NM_OC_BS11: |
| 651 | switch (obj_inst->bts_nr) { |
| 652 | case BS11_OBJ_CCLK: |
| 653 | nm_state = &bts->bs11.cclk.nm_state; |
| 654 | break; |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 655 | case BS11_OBJ_BBSIG: |
| 656 | if (obj_inst->ts_nr > bts->num_trx) |
| 657 | return NULL; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 658 | trx = gsm_bts_trx_num(bts, obj_inst->trx_nr); |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 659 | nm_state = &trx->bs11.bbsig.nm_state; |
| 660 | break; |
| 661 | case BS11_OBJ_PA: |
| 662 | if (obj_inst->ts_nr > bts->num_trx) |
| 663 | return NULL; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 664 | trx = gsm_bts_trx_num(bts, obj_inst->trx_nr); |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 665 | nm_state = &trx->bs11.pa.nm_state; |
| 666 | break; |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 667 | default: |
| 668 | return NULL; |
| 669 | } |
| 670 | case NM_OC_BS11_RACK: |
| 671 | nm_state = &bts->bs11.rack.nm_state; |
| 672 | break; |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 673 | case NM_OC_BS11_ENVABTSE: |
| 674 | if (obj_inst->trx_nr > ARRAY_SIZE(bts->bs11.envabtse)) |
| 675 | return NULL; |
| 676 | nm_state = &bts->bs11.envabtse[obj_inst->trx_nr].nm_state; |
| 677 | break; |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 678 | case NM_OC_GPRS_NSE: |
| 679 | nm_state = &bts->gprs.nse.nm_state; |
| 680 | break; |
| 681 | case NM_OC_GPRS_CELL: |
| 682 | nm_state = &bts->gprs.cell.nm_state; |
| 683 | break; |
| 684 | case NM_OC_GPRS_NSVC: |
| 685 | if (obj_inst->trx_nr > ARRAY_SIZE(bts->gprs.nsvc)) |
| 686 | return NULL; |
| 687 | nm_state = &bts->gprs.nsvc[obj_inst->trx_nr].nm_state; |
| 688 | break; |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 689 | } |
| 690 | return nm_state; |
| 691 | } |
| 692 | |
| 693 | /* obtain the in-memory data structure of a given object instance */ |
| 694 | static void * |
| 695 | objclass2obj(struct gsm_bts *bts, u_int8_t obj_class, |
| 696 | struct abis_om_obj_inst *obj_inst) |
| 697 | { |
| 698 | struct gsm_bts_trx *trx; |
| 699 | void *obj = NULL; |
| 700 | |
| 701 | switch (obj_class) { |
| 702 | case NM_OC_BTS: |
| 703 | obj = bts; |
| 704 | break; |
| 705 | case NM_OC_RADIO_CARRIER: |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 706 | if (obj_inst->trx_nr >= bts->num_trx) { |
| 707 | DEBUGPC(DNM, "TRX %u does not exist ", obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 708 | return NULL; |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 709 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 710 | trx = gsm_bts_trx_num(bts, obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 711 | obj = trx; |
| 712 | break; |
| 713 | case NM_OC_BASEB_TRANSC: |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 714 | if (obj_inst->trx_nr >= bts->num_trx) { |
| 715 | DEBUGPC(DNM, "TRX %u does not exist ", obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 716 | return NULL; |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 717 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 718 | trx = gsm_bts_trx_num(bts, obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 719 | obj = &trx->bb_transc; |
| 720 | break; |
| 721 | case NM_OC_CHANNEL: |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 722 | if (obj_inst->trx_nr > bts->num_trx) { |
| 723 | DEBUGPC(DNM, "TRX %u does not exist ", obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 724 | return NULL; |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 725 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 726 | trx = gsm_bts_trx_num(bts, obj_inst->trx_nr); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 727 | if (obj_inst->ts_nr >= TRX_NR_TS) |
| 728 | return NULL; |
| 729 | obj = &trx->ts[obj_inst->ts_nr]; |
| 730 | break; |
| 731 | case NM_OC_SITE_MANAGER: |
| 732 | obj = &bts->site_mgr; |
| 733 | break; |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 734 | case NM_OC_GPRS_NSE: |
| 735 | obj = &bts->gprs.nse; |
| 736 | break; |
| 737 | case NM_OC_GPRS_CELL: |
| 738 | obj = &bts->gprs.cell; |
| 739 | break; |
| 740 | case NM_OC_GPRS_NSVC: |
| 741 | if (obj_inst->trx_nr > ARRAY_SIZE(bts->gprs.nsvc)) |
| 742 | return NULL; |
| 743 | obj = &bts->gprs.nsvc[obj_inst->trx_nr]; |
| 744 | break; |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 745 | } |
| 746 | return obj; |
| 747 | } |
| 748 | |
| 749 | /* Update the administrative state of a given object in our in-memory data |
| 750 | * structures and send an event to the higher layer */ |
| 751 | static int update_admstate(struct gsm_bts *bts, u_int8_t obj_class, |
| 752 | struct abis_om_obj_inst *obj_inst, u_int8_t adm_state) |
| 753 | { |
Harald Welte | aeedeb4 | 2009-05-01 13:08:14 +0000 | [diff] [blame] | 754 | struct gsm_nm_state *nm_state, new_state; |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 755 | void *obj; |
| 756 | int rc; |
| 757 | |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 758 | obj = objclass2obj(bts, obj_class, obj_inst); |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 759 | if (!obj) |
| 760 | return -EINVAL; |
Harald Welte | aeedeb4 | 2009-05-01 13:08:14 +0000 | [diff] [blame] | 761 | nm_state = objclass2nmstate(bts, obj_class, obj_inst); |
| 762 | if (!nm_state) |
| 763 | return -1; |
| 764 | |
| 765 | new_state = *nm_state; |
| 766 | new_state.administrative = adm_state; |
| 767 | |
| 768 | rc = nm_state_event(EVT_STATECHG_ADM, obj_class, obj, nm_state, &new_state); |
| 769 | |
| 770 | nm_state->administrative = adm_state; |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 771 | |
| 772 | return rc; |
| 773 | } |
| 774 | |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 775 | static int abis_nm_rx_statechg_rep(struct msgb *mb) |
| 776 | { |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 777 | struct abis_om_hdr *oh = msgb_l2(mb); |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 778 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
Harald Welte | 22af0db | 2009-02-14 15:41:08 +0000 | [diff] [blame] | 779 | struct gsm_bts *bts = mb->trx->bts; |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 780 | struct tlv_parsed tp; |
| 781 | struct gsm_nm_state *nm_state, new_state; |
| 782 | int rc; |
| 783 | |
Harald Welte | 2389766 | 2009-05-01 14:52:51 +0000 | [diff] [blame] | 784 | DEBUGPC(DNM, "STATE CHG: "); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 785 | |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 786 | memset(&new_state, 0, sizeof(new_state)); |
| 787 | |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 788 | nm_state = objclass2nmstate(bts, foh->obj_class, &foh->obj_inst); |
| 789 | if (!nm_state) { |
Harald Welte | 999549d | 2009-11-13 12:10:18 +0100 | [diff] [blame] | 790 | DEBUGPC(DNM, "unknown object class\n"); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 791 | return -EINVAL; |
Harald Welte | 22af0db | 2009-02-14 15:41:08 +0000 | [diff] [blame] | 792 | } |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 793 | |
| 794 | new_state = *nm_state; |
| 795 | |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 796 | abis_nm_tlv_parse(&tp, foh->data, oh->length-sizeof(*foh)); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 797 | if (TLVP_PRESENT(&tp, NM_ATT_OPER_STATE)) { |
| 798 | new_state.operational = *TLVP_VAL(&tp, NM_ATT_OPER_STATE); |
Harald Welte | 4d87f24 | 2009-03-10 19:43:44 +0000 | [diff] [blame] | 799 | DEBUGPC(DNM, "OP_STATE=%s ", nm_opstate_name(new_state.operational)); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 800 | } |
| 801 | if (TLVP_PRESENT(&tp, NM_ATT_AVAIL_STATUS)) { |
Harald Welte | 0b8348d | 2009-02-18 03:43:01 +0000 | [diff] [blame] | 802 | if (TLVP_LEN(&tp, NM_ATT_AVAIL_STATUS) == 0) |
| 803 | new_state.availability = 0xff; |
| 804 | else |
| 805 | new_state.availability = *TLVP_VAL(&tp, NM_ATT_AVAIL_STATUS); |
Harald Welte | 4d87f24 | 2009-03-10 19:43:44 +0000 | [diff] [blame] | 806 | DEBUGPC(DNM, "AVAIL=%s(%02x) ", nm_avail_name(new_state.availability), |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 807 | new_state.availability); |
| 808 | } |
| 809 | if (TLVP_PRESENT(&tp, NM_ATT_ADM_STATE)) { |
| 810 | new_state.administrative = *TLVP_VAL(&tp, NM_ATT_ADM_STATE); |
Holger Hans Peter Freyther | 2c481b2 | 2009-10-22 15:44:30 +0200 | [diff] [blame] | 811 | DEBUGPC(DNM, "ADM=%2s ", nm_adm_name(new_state.administrative)); |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 812 | } |
| 813 | DEBUGPC(DNM, "\n"); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 814 | |
| 815 | if (memcmp(&new_state, nm_state, sizeof(new_state))) { |
| 816 | /* Update the operational state of a given object in our in-memory data |
| 817 | * structures and send an event to the higher layer */ |
| 818 | void *obj = objclass2obj(bts, foh->obj_class, &foh->obj_inst); |
| 819 | rc = nm_state_event(EVT_STATECHG_OPER, foh->obj_class, obj, nm_state, &new_state); |
| 820 | *nm_state = new_state; |
| 821 | } |
| 822 | #if 0 |
Harald Welte | 22af0db | 2009-02-14 15:41:08 +0000 | [diff] [blame] | 823 | if (op_state == 1) { |
| 824 | /* try to enable objects that are disabled */ |
| 825 | abis_nm_opstart(bts, foh->obj_class, |
| 826 | foh->obj_inst.bts_nr, |
| 827 | foh->obj_inst.trx_nr, |
| 828 | foh->obj_inst.ts_nr); |
| 829 | } |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 830 | #endif |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 831 | return 0; |
| 832 | } |
| 833 | |
Harald Welte | 0db97b2 | 2009-05-01 17:22:47 +0000 | [diff] [blame] | 834 | static int rx_fail_evt_rep(struct msgb *mb) |
| 835 | { |
| 836 | struct abis_om_hdr *oh = msgb_l2(mb); |
| 837 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 838 | struct tlv_parsed tp; |
| 839 | |
| 840 | DEBUGPC(DNM, "Failure Event Report "); |
| 841 | |
| 842 | abis_nm_tlv_parse(&tp, foh->data, oh->length-sizeof(*foh)); |
| 843 | |
| 844 | if (TLVP_PRESENT(&tp, NM_ATT_EVENT_TYPE)) |
| 845 | DEBUGPC(DNM, "Type=%s ", event_type_name(*TLVP_VAL(&tp, NM_ATT_EVENT_TYPE))); |
| 846 | if (TLVP_PRESENT(&tp, NM_ATT_SEVERITY)) |
| 847 | DEBUGPC(DNM, "Severity=%s ", severity_name(*TLVP_VAL(&tp, NM_ATT_SEVERITY))); |
| 848 | |
| 849 | DEBUGPC(DNM, "\n"); |
| 850 | |
| 851 | return 0; |
| 852 | } |
| 853 | |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 854 | static int abis_nm_rcvmsg_report(struct msgb *mb) |
| 855 | { |
| 856 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 857 | u_int8_t mt = foh->msg_type; |
| 858 | |
Harald Welte | a8bd6d4 | 2009-10-20 09:56:18 +0200 | [diff] [blame] | 859 | debugp_foh(foh); |
Harald Welte | 2389766 | 2009-05-01 14:52:51 +0000 | [diff] [blame] | 860 | |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 861 | //nmh->cfg->report_cb(mb, foh); |
| 862 | |
| 863 | switch (mt) { |
| 864 | case NM_MT_STATECHG_EVENT_REP: |
| 865 | return abis_nm_rx_statechg_rep(mb); |
| 866 | break; |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 867 | case NM_MT_SW_ACTIVATED_REP: |
Harald Welte | 2389766 | 2009-05-01 14:52:51 +0000 | [diff] [blame] | 868 | DEBUGPC(DNM, "Software Activated Report\n"); |
Harald Welte | f9a8cc3 | 2009-05-01 15:39:49 +0000 | [diff] [blame] | 869 | dispatch_signal(SS_NM, S_NM_SW_ACTIV_REP, mb); |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 870 | break; |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 871 | case NM_MT_FAILURE_EVENT_REP: |
Harald Welte | 0db97b2 | 2009-05-01 17:22:47 +0000 | [diff] [blame] | 872 | rx_fail_evt_rep(mb); |
Harald Welte | f9a8cc3 | 2009-05-01 15:39:49 +0000 | [diff] [blame] | 873 | dispatch_signal(SS_NM, S_NM_FAIL_REP, mb); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 874 | break; |
Harald Welte | c731038 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 875 | case NM_MT_TEST_REP: |
| 876 | DEBUGPC(DNM, "Test Report\n"); |
| 877 | dispatch_signal(SS_NM, S_NM_TEST_REP, mb); |
| 878 | break; |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 879 | default: |
Harald Welte | 2389766 | 2009-05-01 14:52:51 +0000 | [diff] [blame] | 880 | DEBUGPC(DNM, "reporting NM MT 0x%02x\n", mt); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 881 | break; |
| 882 | |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 883 | }; |
| 884 | |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 885 | return 0; |
| 886 | } |
| 887 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 888 | /* Activate the specified software into the BTS */ |
| 889 | static int ipacc_sw_activate(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i0, u_int8_t i1, |
Mike Haben | a03f977 | 2009-10-01 14:56:13 +0200 | [diff] [blame] | 890 | u_int8_t i2, const u_int8_t *sw_desc, u_int8_t swdesc_len) |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 891 | { |
| 892 | struct abis_om_hdr *oh; |
| 893 | struct msgb *msg = nm_msgb_alloc(); |
| 894 | u_int8_t len = swdesc_len; |
| 895 | u_int8_t *trailer; |
| 896 | |
| 897 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 898 | fill_om_fom_hdr(oh, len, NM_MT_ACTIVATE_SW, obj_class, i0, i1, i2); |
| 899 | |
| 900 | trailer = msgb_put(msg, swdesc_len); |
| 901 | memcpy(trailer, sw_desc, swdesc_len); |
| 902 | |
| 903 | return abis_nm_sendmsg(bts, msg); |
| 904 | } |
| 905 | |
| 906 | static int abis_nm_rx_sw_act_req(struct msgb *mb) |
| 907 | { |
| 908 | struct abis_om_hdr *oh = msgb_l2(mb); |
| 909 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
Mike Haben | a03f977 | 2009-10-01 14:56:13 +0200 | [diff] [blame] | 910 | struct tlv_parsed tp; |
| 911 | const u_int8_t *sw_config; |
| 912 | int sw_config_len; |
| 913 | int file_id_len; |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 914 | int nack = 0; |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 915 | int ret; |
| 916 | |
Harald Welte | a8bd6d4 | 2009-10-20 09:56:18 +0200 | [diff] [blame] | 917 | debugp_foh(foh); |
| 918 | |
| 919 | DEBUGPC(DNM, "SW Activate Request: "); |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 920 | |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 921 | if (foh->obj_class >= 0xf0 && foh->obj_class <= 0xf3) { |
| 922 | DEBUGPC(DNM, "NACKing for GPRS obj_class 0x%02x\n", foh->obj_class); |
| 923 | nack = 1; |
| 924 | } else |
| 925 | DEBUGPC(DNM, "ACKing and Activating\n"); |
| 926 | |
| 927 | ret = abis_nm_sw_act_req_ack(mb->trx->bts, foh->obj_class, |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 928 | foh->obj_inst.bts_nr, |
| 929 | foh->obj_inst.trx_nr, |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 930 | foh->obj_inst.ts_nr, nack, |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 931 | foh->data, oh->length-sizeof(*foh)); |
| 932 | |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 933 | if (nack) |
| 934 | return ret; |
| 935 | |
Mike Haben | a03f977 | 2009-10-01 14:56:13 +0200 | [diff] [blame] | 936 | abis_nm_tlv_parse(&tp, foh->data, oh->length-sizeof(*foh)); |
| 937 | sw_config = TLVP_VAL(&tp, NM_ATT_SW_CONFIG); |
| 938 | sw_config_len = TLVP_LEN(&tp, NM_ATT_SW_CONFIG); |
| 939 | if (!TLVP_PRESENT(&tp, NM_ATT_SW_CONFIG)) { |
| 940 | DEBUGP(DNM, "SW config not found! Can't continue.\n"); |
| 941 | return -EINVAL; |
| 942 | } else { |
| 943 | DEBUGP(DNM, "Found SW config: %s\n", hexdump(sw_config, sw_config_len)); |
| 944 | } |
| 945 | |
| 946 | if (sw_config[0] != NM_ATT_SW_DESCR) |
| 947 | DEBUGP(DNM, "SW_DESCR attribute identifier not found!\n"); |
| 948 | if (sw_config[1] != NM_ATT_FILE_ID) |
| 949 | DEBUGP(DNM, "FILE_ID attribute identifier not found!\n"); |
| 950 | file_id_len = sw_config[2] * 256 + sw_config[3]; |
| 951 | |
| 952 | /* Assumes first SW file in list is the one to be activated */ |
| 953 | /* sw_config + 4 to skip over 2 attribute ID bytes and 16-bit length field */ |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 954 | return ipacc_sw_activate(mb->trx->bts, foh->obj_class, |
| 955 | foh->obj_inst.bts_nr, |
| 956 | foh->obj_inst.trx_nr, |
| 957 | foh->obj_inst.ts_nr, |
Mike Haben | a03f977 | 2009-10-01 14:56:13 +0200 | [diff] [blame] | 958 | sw_config + 4, |
| 959 | file_id_len); |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 960 | } |
| 961 | |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 962 | /* Receive a CHANGE_ADM_STATE_ACK, parse the TLV and update local state */ |
| 963 | static int abis_nm_rx_chg_adm_state_ack(struct msgb *mb) |
| 964 | { |
| 965 | struct abis_om_hdr *oh = msgb_l2(mb); |
| 966 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 967 | struct tlv_parsed tp; |
| 968 | u_int8_t adm_state; |
| 969 | |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 970 | abis_nm_tlv_parse(&tp, foh->data, oh->length-sizeof(*foh)); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 971 | if (!TLVP_PRESENT(&tp, NM_ATT_ADM_STATE)) |
| 972 | return -EINVAL; |
| 973 | |
| 974 | adm_state = *TLVP_VAL(&tp, NM_ATT_ADM_STATE); |
| 975 | |
| 976 | return update_admstate(mb->trx->bts, foh->obj_class, &foh->obj_inst, adm_state); |
| 977 | } |
| 978 | |
Harald Welte | ee67047 | 2009-02-22 21:58:49 +0000 | [diff] [blame] | 979 | static int abis_nm_rx_lmt_event(struct msgb *mb) |
| 980 | { |
| 981 | struct abis_om_hdr *oh = msgb_l2(mb); |
| 982 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 983 | struct tlv_parsed tp; |
| 984 | |
| 985 | DEBUGP(DNM, "LMT Event "); |
| 986 | abis_nm_tlv_parse(&tp, foh->data, oh->length-sizeof(*foh)); |
| 987 | if (TLVP_PRESENT(&tp, NM_ATT_BS11_LMT_LOGON_SESSION) && |
| 988 | TLVP_LEN(&tp, NM_ATT_BS11_LMT_LOGON_SESSION) >= 1) { |
| 989 | u_int8_t onoff = *TLVP_VAL(&tp, NM_ATT_BS11_LMT_LOGON_SESSION); |
| 990 | DEBUGPC(DNM, "LOG%s ", onoff ? "ON" : "OFF"); |
| 991 | } |
| 992 | if (TLVP_PRESENT(&tp, NM_ATT_BS11_LMT_USER_ACC_LEV) && |
| 993 | TLVP_LEN(&tp, NM_ATT_BS11_LMT_USER_ACC_LEV) >= 1) { |
| 994 | u_int8_t level = *TLVP_VAL(&tp, NM_ATT_BS11_LMT_USER_ACC_LEV); |
| 995 | DEBUGPC(DNM, "Level=%u ", level); |
| 996 | } |
| 997 | if (TLVP_PRESENT(&tp, NM_ATT_BS11_LMT_USER_NAME) && |
| 998 | TLVP_LEN(&tp, NM_ATT_BS11_LMT_USER_NAME) >= 1) { |
| 999 | char *name = (char *) TLVP_VAL(&tp, NM_ATT_BS11_LMT_USER_NAME); |
| 1000 | DEBUGPC(DNM, "Username=%s ", name); |
| 1001 | } |
| 1002 | DEBUGPC(DNM, "\n"); |
| 1003 | /* FIXME: parse LMT LOGON TIME */ |
| 1004 | return 0; |
| 1005 | } |
| 1006 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1007 | /* Receive a OML NM Message from BTS */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1008 | static int abis_nm_rcvmsg_fom(struct msgb *mb) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1009 | { |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 1010 | struct abis_om_hdr *oh = msgb_l2(mb); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1011 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 1012 | u_int8_t mt = foh->msg_type; |
| 1013 | |
| 1014 | /* check for unsolicited message */ |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 1015 | if (is_report(mt)) |
| 1016 | return abis_nm_rcvmsg_report(mb); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1017 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1018 | if (is_in_arr(mt, sw_load_msgs, ARRAY_SIZE(sw_load_msgs))) |
| 1019 | return abis_nm_rcvmsg_sw(mb); |
| 1020 | |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 1021 | if (is_in_arr(mt, nacks, ARRAY_SIZE(nacks))) { |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 1022 | struct tlv_parsed tp; |
Harald Welte | 4bd0a98 | 2009-10-08 20:18:59 +0200 | [diff] [blame] | 1023 | |
Harald Welte | a8bd6d4 | 2009-10-20 09:56:18 +0200 | [diff] [blame] | 1024 | debugp_foh(foh); |
Harald Welte | 4bd0a98 | 2009-10-08 20:18:59 +0200 | [diff] [blame] | 1025 | |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 1026 | if (nack_names[mt]) |
Harald Welte | 4bd0a98 | 2009-10-08 20:18:59 +0200 | [diff] [blame] | 1027 | DEBUGPC(DNM, "%s NACK ", nack_names[mt]); |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 1028 | /* FIXME: NACK cause */ |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 1029 | else |
Harald Welte | 4bd0a98 | 2009-10-08 20:18:59 +0200 | [diff] [blame] | 1030 | DEBUGPC(DNM, "NACK 0x%02x ", mt); |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 1031 | |
| 1032 | abis_nm_tlv_parse(&tp, foh->data, oh->length-sizeof(*foh)); |
| 1033 | if (TLVP_PRESENT(&tp, NM_ATT_NACK_CAUSES)) |
| 1034 | DEBUGPC(DNM, "CAUSE=%s\n", |
| 1035 | nack_cause_name(*TLVP_VAL(&tp, NM_ATT_NACK_CAUSES))); |
| 1036 | else |
| 1037 | DEBUGPC(DNM, "\n"); |
Holger Hans Peter Freyther | 500f3ca | 2009-06-10 10:48:14 +0200 | [diff] [blame] | 1038 | |
Harald Welte | d8cfc90 | 2009-11-17 06:09:56 +0100 | [diff] [blame] | 1039 | dispatch_signal(SS_NM, S_NM_NACK, (void*) &mt); |
Holger Hans Peter Freyther | 500f3ca | 2009-06-10 10:48:14 +0200 | [diff] [blame] | 1040 | return 0; |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 1041 | } |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1042 | #if 0 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1043 | /* check if last message is to be acked */ |
| 1044 | if (is_ack_nack(nmh->last_msgtype)) { |
| 1045 | if (mt == MT_ACK(nmh->last_msgtype)) { |
| 1046 | fprintf(stderr, "received ACK (0x%x)\n", |
| 1047 | foh->msg_type); |
| 1048 | /* we got our ACK, continue sending the next msg */ |
| 1049 | } else if (mt == MT_NACK(nmh->last_msgtype)) { |
| 1050 | /* we got a NACK, signal this to the caller */ |
| 1051 | fprintf(stderr, "received NACK (0x%x)\n", |
| 1052 | foh->msg_type); |
| 1053 | /* FIXME: somehow signal this to the caller */ |
| 1054 | } else { |
| 1055 | /* really strange things happen */ |
| 1056 | return -EINVAL; |
| 1057 | } |
| 1058 | } |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1059 | #endif |
| 1060 | |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 1061 | switch (mt) { |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 1062 | case NM_MT_CHG_ADM_STATE_ACK: |
| 1063 | return abis_nm_rx_chg_adm_state_ack(mb); |
| 1064 | break; |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1065 | case NM_MT_SW_ACT_REQ: |
| 1066 | return abis_nm_rx_sw_act_req(mb); |
| 1067 | break; |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 1068 | case NM_MT_BS11_LMT_SESSION: |
Harald Welte | ee67047 | 2009-02-22 21:58:49 +0000 | [diff] [blame] | 1069 | return abis_nm_rx_lmt_event(mb); |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 1070 | break; |
Harald Welte | 1989c08 | 2009-08-06 17:58:31 +0200 | [diff] [blame] | 1071 | case NM_MT_CONN_MDROP_LINK_ACK: |
| 1072 | DEBUGP(DNM, "CONN MDROP LINK ACK\n"); |
| 1073 | break; |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 1074 | } |
| 1075 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1076 | return 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1077 | } |
| 1078 | |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 1079 | static int abis_nm_rx_ipacc(struct msgb *mb); |
| 1080 | |
| 1081 | static int abis_nm_rcvmsg_manuf(struct msgb *mb) |
| 1082 | { |
| 1083 | int rc; |
| 1084 | int bts_type = mb->trx->bts->type; |
| 1085 | |
| 1086 | switch (bts_type) { |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 1087 | case GSM_BTS_TYPE_NANOBTS: |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 1088 | rc = abis_nm_rx_ipacc(mb); |
| 1089 | break; |
| 1090 | default: |
| 1091 | fprintf(stderr, "don't know how to parse OML for this " |
| 1092 | "BTS type (%u)\n", bts_type); |
| 1093 | rc = 0; |
| 1094 | break; |
| 1095 | } |
| 1096 | |
| 1097 | return rc; |
| 1098 | } |
| 1099 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1100 | /* High-Level API */ |
| 1101 | /* Entry-point where L2 OML from BTS enters the NM code */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1102 | int abis_nm_rcvmsg(struct msgb *msg) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1103 | { |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1104 | struct abis_om_hdr *oh = msgb_l2(msg); |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 1105 | int rc = 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1106 | |
| 1107 | /* Various consistency checks */ |
| 1108 | if (oh->placement != ABIS_OM_PLACEMENT_ONLY) { |
| 1109 | fprintf(stderr, "ABIS OML placement 0x%x not supported\n", |
| 1110 | oh->placement); |
| 1111 | return -EINVAL; |
| 1112 | } |
| 1113 | if (oh->sequence != 0) { |
| 1114 | fprintf(stderr, "ABIS OML sequence 0x%x != 0x00\n", |
| 1115 | oh->sequence); |
| 1116 | return -EINVAL; |
| 1117 | } |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 1118 | #if 0 |
Holger Freyther | ca362a6 | 2009-01-04 21:05:01 +0000 | [diff] [blame] | 1119 | unsigned int l2_len = msg->tail - (u_int8_t *)msgb_l2(msg); |
| 1120 | unsigned int hlen = sizeof(*oh) + sizeof(struct abis_om_fom_hdr); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 1121 | if (oh->length + hlen > l2_len) { |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1122 | fprintf(stderr, "ABIS OML truncated message (%u > %u)\n", |
| 1123 | oh->length + sizeof(*oh), l2_len); |
| 1124 | return -EINVAL; |
| 1125 | } |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 1126 | if (oh->length + hlen < l2_len) |
| 1127 | fprintf(stderr, "ABIS OML message with extra trailer?!? (oh->len=%d, sizeof_oh=%d l2_len=%d\n", oh->length, sizeof(*oh), l2_len); |
| 1128 | #endif |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1129 | msg->l3h = (unsigned char *)oh + sizeof(*oh); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1130 | |
| 1131 | switch (oh->mdisc) { |
| 1132 | case ABIS_OM_MDISC_FOM: |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1133 | rc = abis_nm_rcvmsg_fom(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1134 | break; |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 1135 | case ABIS_OM_MDISC_MANUF: |
| 1136 | rc = abis_nm_rcvmsg_manuf(msg); |
| 1137 | break; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1138 | case ABIS_OM_MDISC_MMI: |
| 1139 | case ABIS_OM_MDISC_TRAU: |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 1140 | fprintf(stderr, "unimplemented ABIS OML message discriminator 0x%x\n", |
| 1141 | oh->mdisc); |
| 1142 | break; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1143 | default: |
| 1144 | fprintf(stderr, "unknown ABIS OML message discriminator 0x%x\n", |
| 1145 | oh->mdisc); |
| 1146 | return -EINVAL; |
| 1147 | } |
| 1148 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1149 | msgb_free(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1150 | return rc; |
| 1151 | } |
| 1152 | |
| 1153 | #if 0 |
| 1154 | /* initialized all resources */ |
| 1155 | struct abis_nm_h *abis_nm_init(struct abis_nm_cfg *cfg) |
| 1156 | { |
| 1157 | struct abis_nm_h *nmh; |
| 1158 | |
| 1159 | nmh = malloc(sizeof(*nmh)); |
| 1160 | if (!nmh) |
| 1161 | return NULL; |
| 1162 | |
| 1163 | nmh->cfg = cfg; |
| 1164 | |
| 1165 | return nmh; |
| 1166 | } |
| 1167 | |
| 1168 | /* free all resources */ |
| 1169 | void abis_nm_fini(struct abis_nm_h *nmh) |
| 1170 | { |
| 1171 | free(nmh); |
| 1172 | } |
| 1173 | #endif |
| 1174 | |
| 1175 | /* Here we are trying to define a high-level API that can be used by |
| 1176 | * the actual BSC implementation. However, the architecture is currently |
| 1177 | * still under design. Ideally the calls to this API would be synchronous, |
| 1178 | * while the underlying stack behind the APi runs in a traditional select |
| 1179 | * based state machine. |
| 1180 | */ |
| 1181 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1182 | /* 6.2 Software Load: */ |
| 1183 | enum sw_state { |
| 1184 | SW_STATE_NONE, |
| 1185 | SW_STATE_WAIT_INITACK, |
| 1186 | SW_STATE_WAIT_SEGACK, |
| 1187 | SW_STATE_WAIT_ENDACK, |
| 1188 | SW_STATE_WAIT_ACTACK, |
| 1189 | SW_STATE_ERROR, |
| 1190 | }; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1191 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1192 | struct abis_nm_sw { |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1193 | struct gsm_bts *bts; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1194 | gsm_cbfn *cbfn; |
| 1195 | void *cb_data; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1196 | int forced; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1197 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1198 | /* this will become part of the SW LOAD INITIATE */ |
| 1199 | u_int8_t obj_class; |
| 1200 | u_int8_t obj_instance[3]; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1201 | |
| 1202 | u_int8_t file_id[255]; |
| 1203 | u_int8_t file_id_len; |
| 1204 | |
| 1205 | u_int8_t file_version[255]; |
| 1206 | u_int8_t file_version_len; |
| 1207 | |
| 1208 | u_int8_t window_size; |
| 1209 | u_int8_t seg_in_window; |
| 1210 | |
| 1211 | int fd; |
| 1212 | FILE *stream; |
| 1213 | enum sw_state state; |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 1214 | int last_seg; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1215 | }; |
| 1216 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1217 | static struct abis_nm_sw g_sw; |
| 1218 | |
| 1219 | /* 6.2.1 / 8.3.1: Load Data Initiate */ |
| 1220 | static int sw_load_init(struct abis_nm_sw *sw) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1221 | { |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1222 | struct abis_om_hdr *oh; |
| 1223 | struct msgb *msg = nm_msgb_alloc(); |
| 1224 | u_int8_t len = 3*2 + sw->file_id_len + sw->file_version_len; |
| 1225 | |
| 1226 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1227 | fill_om_fom_hdr(oh, len, NM_MT_LOAD_INIT, sw->obj_class, |
| 1228 | sw->obj_instance[0], sw->obj_instance[1], |
| 1229 | sw->obj_instance[2]); |
| 1230 | |
| 1231 | /* FIXME: this is BS11 specific format */ |
| 1232 | msgb_tlv_put(msg, NM_ATT_FILE_ID, sw->file_id_len, sw->file_id); |
| 1233 | msgb_tlv_put(msg, NM_ATT_FILE_VERSION, sw->file_version_len, |
| 1234 | sw->file_version); |
| 1235 | msgb_tv_put(msg, NM_ATT_WINDOW_SIZE, sw->window_size); |
| 1236 | |
| 1237 | return abis_nm_sendmsg(sw->bts, msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1238 | } |
| 1239 | |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 1240 | static int is_last_line(FILE *stream) |
| 1241 | { |
| 1242 | char next_seg_buf[256]; |
| 1243 | long pos; |
| 1244 | |
| 1245 | /* check if we're sending the last line */ |
| 1246 | pos = ftell(stream); |
| 1247 | if (!fgets(next_seg_buf, sizeof(next_seg_buf)-2, stream)) { |
| 1248 | fseek(stream, pos, SEEK_SET); |
| 1249 | return 1; |
| 1250 | } |
| 1251 | |
| 1252 | fseek(stream, pos, SEEK_SET); |
| 1253 | return 0; |
| 1254 | } |
| 1255 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1256 | /* 6.2.2 / 8.3.2 Load Data Segment */ |
| 1257 | static int sw_load_segment(struct abis_nm_sw *sw) |
| 1258 | { |
| 1259 | struct abis_om_hdr *oh; |
| 1260 | struct msgb *msg = nm_msgb_alloc(); |
| 1261 | char seg_buf[256]; |
| 1262 | char *line_buf = seg_buf+2; |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 1263 | unsigned char *tlv; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1264 | u_int8_t len; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1265 | |
| 1266 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 1267 | |
| 1268 | switch (sw->bts->type) { |
| 1269 | case GSM_BTS_TYPE_BS11: |
| 1270 | if (fgets(line_buf, sizeof(seg_buf)-2, sw->stream) == NULL) { |
| 1271 | perror("fgets reading segment"); |
| 1272 | return -EINVAL; |
| 1273 | } |
| 1274 | seg_buf[0] = 0x00; |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 1275 | |
| 1276 | /* check if we're sending the last line */ |
| 1277 | sw->last_seg = is_last_line(sw->stream); |
| 1278 | if (sw->last_seg) |
| 1279 | seg_buf[1] = 0; |
| 1280 | else |
| 1281 | seg_buf[1] = 1 + sw->seg_in_window++; |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 1282 | |
| 1283 | len = strlen(line_buf) + 2; |
| 1284 | tlv = msgb_put(msg, TLV_GROSS_LEN(len)); |
| 1285 | tlv_put(tlv, NM_ATT_BS11_FILE_DATA, len, (u_int8_t *)seg_buf); |
| 1286 | /* BS11 wants CR + LF in excess of the TLV length !?! */ |
| 1287 | tlv[1] -= 2; |
| 1288 | |
| 1289 | /* we only now know the exact length for the OM hdr */ |
| 1290 | len = strlen(line_buf)+2; |
| 1291 | break; |
| 1292 | default: |
| 1293 | /* FIXME: Other BTS types */ |
| 1294 | return -1; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1295 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1296 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1297 | fill_om_fom_hdr(oh, len, NM_MT_LOAD_SEG, sw->obj_class, |
| 1298 | sw->obj_instance[0], sw->obj_instance[1], |
| 1299 | sw->obj_instance[2]); |
| 1300 | |
| 1301 | return abis_nm_sendmsg(sw->bts, msg); |
| 1302 | } |
| 1303 | |
| 1304 | /* 6.2.4 / 8.3.4 Load Data End */ |
| 1305 | static int sw_load_end(struct abis_nm_sw *sw) |
| 1306 | { |
| 1307 | struct abis_om_hdr *oh; |
| 1308 | struct msgb *msg = nm_msgb_alloc(); |
| 1309 | u_int8_t len = 2*2 + sw->file_id_len + sw->file_version_len; |
| 1310 | |
| 1311 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1312 | fill_om_fom_hdr(oh, len, NM_MT_LOAD_END, sw->obj_class, |
| 1313 | sw->obj_instance[0], sw->obj_instance[1], |
| 1314 | sw->obj_instance[2]); |
| 1315 | |
| 1316 | /* FIXME: this is BS11 specific format */ |
| 1317 | msgb_tlv_put(msg, NM_ATT_FILE_ID, sw->file_id_len, sw->file_id); |
| 1318 | msgb_tlv_put(msg, NM_ATT_FILE_VERSION, sw->file_version_len, |
| 1319 | sw->file_version); |
| 1320 | |
| 1321 | return abis_nm_sendmsg(sw->bts, msg); |
| 1322 | } |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1323 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1324 | /* Activate the specified software into the BTS */ |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1325 | static int sw_activate(struct abis_nm_sw *sw) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1326 | { |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1327 | struct abis_om_hdr *oh; |
| 1328 | struct msgb *msg = nm_msgb_alloc(); |
| 1329 | u_int8_t len = 2*2 + sw->file_id_len + sw->file_version_len; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1330 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1331 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1332 | fill_om_fom_hdr(oh, len, NM_MT_ACTIVATE_SW, sw->obj_class, |
| 1333 | sw->obj_instance[0], sw->obj_instance[1], |
| 1334 | sw->obj_instance[2]); |
| 1335 | |
| 1336 | /* FIXME: this is BS11 specific format */ |
| 1337 | msgb_tlv_put(msg, NM_ATT_FILE_ID, sw->file_id_len, sw->file_id); |
| 1338 | msgb_tlv_put(msg, NM_ATT_FILE_VERSION, sw->file_version_len, |
| 1339 | sw->file_version); |
| 1340 | |
| 1341 | return abis_nm_sendmsg(sw->bts, msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1342 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1343 | |
| 1344 | static int sw_open_file(struct abis_nm_sw *sw, const char *fname) |
| 1345 | { |
| 1346 | char file_id[12+1]; |
| 1347 | char file_version[80+1]; |
| 1348 | int rc; |
| 1349 | |
| 1350 | sw->fd = open(fname, O_RDONLY); |
| 1351 | if (sw->fd < 0) |
| 1352 | return sw->fd; |
| 1353 | |
| 1354 | switch (sw->bts->type) { |
| 1355 | case GSM_BTS_TYPE_BS11: |
| 1356 | sw->stream = fdopen(sw->fd, "r"); |
| 1357 | if (!sw->stream) { |
| 1358 | perror("fdopen"); |
| 1359 | return -1; |
| 1360 | } |
| 1361 | /* read first line and parse file ID and VERSION */ |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 1362 | rc = fscanf(sw->stream, "@(#)%12s:%80s\r\n", |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1363 | file_id, file_version); |
| 1364 | if (rc != 2) { |
| 1365 | perror("parsing header line of software file"); |
| 1366 | return -1; |
| 1367 | } |
| 1368 | strcpy((char *)sw->file_id, file_id); |
| 1369 | sw->file_id_len = strlen(file_id); |
| 1370 | strcpy((char *)sw->file_version, file_version); |
| 1371 | sw->file_version_len = strlen(file_version); |
| 1372 | /* rewind to start of file */ |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 1373 | rewind(sw->stream); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1374 | break; |
| 1375 | default: |
| 1376 | /* We don't know how to treat them yet */ |
| 1377 | close(sw->fd); |
| 1378 | return -EINVAL; |
| 1379 | } |
| 1380 | |
| 1381 | return 0; |
| 1382 | } |
| 1383 | |
| 1384 | static void sw_close_file(struct abis_nm_sw *sw) |
| 1385 | { |
| 1386 | switch (sw->bts->type) { |
| 1387 | case GSM_BTS_TYPE_BS11: |
| 1388 | fclose(sw->stream); |
| 1389 | break; |
| 1390 | default: |
| 1391 | close(sw->fd); |
| 1392 | break; |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | /* Fill the window */ |
| 1397 | static int sw_fill_window(struct abis_nm_sw *sw) |
| 1398 | { |
| 1399 | int rc; |
| 1400 | |
| 1401 | while (sw->seg_in_window < sw->window_size) { |
| 1402 | rc = sw_load_segment(sw); |
| 1403 | if (rc < 0) |
| 1404 | return rc; |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 1405 | if (sw->last_seg) |
| 1406 | break; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1407 | } |
| 1408 | return 0; |
| 1409 | } |
| 1410 | |
| 1411 | /* callback function from abis_nm_rcvmsg() handler */ |
| 1412 | static int abis_nm_rcvmsg_sw(struct msgb *mb) |
| 1413 | { |
| 1414 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 1415 | int rc = -1; |
| 1416 | struct abis_nm_sw *sw = &g_sw; |
| 1417 | enum sw_state old_state = sw->state; |
| 1418 | |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1419 | //DEBUGP(DNM, "state %u, NM MT 0x%02x\n", sw->state, foh->msg_type); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1420 | |
| 1421 | switch (sw->state) { |
| 1422 | case SW_STATE_WAIT_INITACK: |
| 1423 | switch (foh->msg_type) { |
| 1424 | case NM_MT_LOAD_INIT_ACK: |
| 1425 | /* fill window with segments */ |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1426 | if (sw->cbfn) |
| 1427 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1428 | NM_MT_LOAD_INIT_ACK, mb, |
| 1429 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1430 | rc = sw_fill_window(sw); |
| 1431 | sw->state = SW_STATE_WAIT_SEGACK; |
| 1432 | break; |
| 1433 | case NM_MT_LOAD_INIT_NACK: |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1434 | if (sw->forced) { |
| 1435 | DEBUGP(DNM, "FORCED: Ignoring Software Load " |
| 1436 | "Init NACK\n"); |
| 1437 | if (sw->cbfn) |
| 1438 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1439 | NM_MT_LOAD_INIT_ACK, mb, |
| 1440 | sw->cb_data, NULL); |
| 1441 | rc = sw_fill_window(sw); |
| 1442 | sw->state = SW_STATE_WAIT_SEGACK; |
| 1443 | } else { |
| 1444 | DEBUGP(DNM, "Software Load Init NACK\n"); |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 1445 | /* FIXME: cause */ |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1446 | if (sw->cbfn) |
| 1447 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1448 | NM_MT_LOAD_INIT_NACK, mb, |
| 1449 | sw->cb_data, NULL); |
| 1450 | sw->state = SW_STATE_ERROR; |
| 1451 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1452 | break; |
| 1453 | } |
| 1454 | break; |
| 1455 | case SW_STATE_WAIT_SEGACK: |
| 1456 | switch (foh->msg_type) { |
| 1457 | case NM_MT_LOAD_SEG_ACK: |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1458 | if (sw->cbfn) |
| 1459 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1460 | NM_MT_LOAD_SEG_ACK, mb, |
| 1461 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1462 | sw->seg_in_window = 0; |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 1463 | if (!sw->last_seg) { |
| 1464 | /* fill window with more segments */ |
| 1465 | rc = sw_fill_window(sw); |
| 1466 | sw->state = SW_STATE_WAIT_SEGACK; |
| 1467 | } else { |
| 1468 | /* end the transfer */ |
| 1469 | sw->state = SW_STATE_WAIT_ENDACK; |
| 1470 | rc = sw_load_end(sw); |
| 1471 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1472 | break; |
| 1473 | } |
| 1474 | break; |
| 1475 | case SW_STATE_WAIT_ENDACK: |
| 1476 | switch (foh->msg_type) { |
| 1477 | case NM_MT_LOAD_END_ACK: |
| 1478 | sw_close_file(sw); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1479 | DEBUGP(DNM, "Software Load End (BTS %u)\n", |
| 1480 | sw->bts->nr); |
| 1481 | sw->state = SW_STATE_NONE; |
| 1482 | if (sw->cbfn) |
| 1483 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1484 | NM_MT_LOAD_END_ACK, mb, |
| 1485 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1486 | break; |
| 1487 | case NM_MT_LOAD_END_NACK: |
Holger Freyther | 31338a1 | 2009-02-06 17:43:50 +0000 | [diff] [blame] | 1488 | if (sw->forced) { |
| 1489 | DEBUGP(DNM, "FORCED: Ignoring Software Load" |
| 1490 | "End NACK\n"); |
| 1491 | sw->state = SW_STATE_NONE; |
| 1492 | if (sw->cbfn) |
| 1493 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1494 | NM_MT_LOAD_END_ACK, mb, |
| 1495 | sw->cb_data, NULL); |
| 1496 | } else { |
| 1497 | DEBUGP(DNM, "Software Load End NACK\n"); |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 1498 | /* FIXME: cause */ |
Holger Freyther | 31338a1 | 2009-02-06 17:43:50 +0000 | [diff] [blame] | 1499 | sw->state = SW_STATE_ERROR; |
| 1500 | if (sw->cbfn) |
| 1501 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1502 | NM_MT_LOAD_END_NACK, mb, |
| 1503 | sw->cb_data, NULL); |
| 1504 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1505 | break; |
| 1506 | } |
| 1507 | case SW_STATE_WAIT_ACTACK: |
| 1508 | switch (foh->msg_type) { |
| 1509 | case NM_MT_ACTIVATE_SW_ACK: |
| 1510 | /* we're done */ |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1511 | DEBUGP(DNM, "Activate Software DONE!\n"); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1512 | sw->state = SW_STATE_NONE; |
| 1513 | rc = 0; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1514 | if (sw->cbfn) |
| 1515 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1516 | NM_MT_ACTIVATE_SW_ACK, mb, |
| 1517 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1518 | break; |
| 1519 | case NM_MT_ACTIVATE_SW_NACK: |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 1520 | DEBUGP(DNM, "Activate Software NACK\n"); |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 1521 | /* FIXME: cause */ |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1522 | sw->state = SW_STATE_ERROR; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1523 | if (sw->cbfn) |
| 1524 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 1525 | NM_MT_ACTIVATE_SW_NACK, mb, |
| 1526 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1527 | break; |
| 1528 | } |
| 1529 | case SW_STATE_NONE: |
Harald Welte | a994a48 | 2009-05-01 15:54:23 +0000 | [diff] [blame] | 1530 | switch (foh->msg_type) { |
| 1531 | case NM_MT_ACTIVATE_SW_ACK: |
| 1532 | rc = 0; |
| 1533 | break; |
| 1534 | } |
| 1535 | break; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1536 | case SW_STATE_ERROR: |
| 1537 | break; |
| 1538 | } |
| 1539 | |
| 1540 | if (rc) |
Harald Welte | a994a48 | 2009-05-01 15:54:23 +0000 | [diff] [blame] | 1541 | DEBUGP(DNM, "unexpected NM MT 0x%02x in state %u -> %u\n", |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1542 | foh->msg_type, old_state, sw->state); |
| 1543 | |
| 1544 | return rc; |
| 1545 | } |
| 1546 | |
| 1547 | /* Load the specified software into the BTS */ |
| 1548 | int abis_nm_software_load(struct gsm_bts *bts, const char *fname, |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1549 | u_int8_t win_size, int forced, |
| 1550 | gsm_cbfn *cbfn, void *cb_data) |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1551 | { |
| 1552 | struct abis_nm_sw *sw = &g_sw; |
| 1553 | int rc; |
| 1554 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1555 | DEBUGP(DNM, "Software Load (BTS %u, File \"%s\")\n", |
| 1556 | bts->nr, fname); |
| 1557 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1558 | if (sw->state != SW_STATE_NONE) |
| 1559 | return -EBUSY; |
| 1560 | |
| 1561 | sw->bts = bts; |
| 1562 | sw->obj_class = NM_OC_SITE_MANAGER; |
| 1563 | sw->obj_instance[0] = 0xff; |
| 1564 | sw->obj_instance[1] = 0xff; |
| 1565 | sw->obj_instance[2] = 0xff; |
| 1566 | sw->window_size = win_size; |
| 1567 | sw->state = SW_STATE_WAIT_INITACK; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1568 | sw->cbfn = cbfn; |
| 1569 | sw->cb_data = cb_data; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1570 | sw->forced = forced; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 1571 | |
| 1572 | rc = sw_open_file(sw, fname); |
| 1573 | if (rc < 0) { |
| 1574 | sw->state = SW_STATE_NONE; |
| 1575 | return rc; |
| 1576 | } |
| 1577 | |
| 1578 | return sw_load_init(sw); |
| 1579 | } |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1580 | |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 1581 | int abis_nm_software_load_status(struct gsm_bts *bts) |
| 1582 | { |
| 1583 | struct abis_nm_sw *sw = &g_sw; |
| 1584 | struct stat st; |
| 1585 | int rc, percent; |
| 1586 | |
| 1587 | rc = fstat(sw->fd, &st); |
| 1588 | if (rc < 0) { |
| 1589 | perror("ERROR during stat"); |
| 1590 | return rc; |
| 1591 | } |
| 1592 | |
| 1593 | percent = (ftell(sw->stream) * 100) / st.st_size; |
| 1594 | return percent; |
| 1595 | } |
| 1596 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1597 | /* Activate the specified software into the BTS */ |
| 1598 | int abis_nm_software_activate(struct gsm_bts *bts, const char *fname, |
| 1599 | gsm_cbfn *cbfn, void *cb_data) |
| 1600 | { |
| 1601 | struct abis_nm_sw *sw = &g_sw; |
| 1602 | int rc; |
| 1603 | |
| 1604 | DEBUGP(DNM, "Activating Software (BTS %u, File \"%s\")\n", |
| 1605 | bts->nr, fname); |
| 1606 | |
| 1607 | if (sw->state != SW_STATE_NONE) |
| 1608 | return -EBUSY; |
| 1609 | |
| 1610 | sw->bts = bts; |
| 1611 | sw->obj_class = NM_OC_SITE_MANAGER; |
| 1612 | sw->obj_instance[0] = 0xff; |
| 1613 | sw->obj_instance[1] = 0xff; |
| 1614 | sw->obj_instance[2] = 0xff; |
| 1615 | sw->state = SW_STATE_WAIT_ACTACK; |
| 1616 | sw->cbfn = cbfn; |
| 1617 | sw->cb_data = cb_data; |
| 1618 | |
| 1619 | /* Open the file in order to fill some sw struct members */ |
| 1620 | rc = sw_open_file(sw, fname); |
| 1621 | if (rc < 0) { |
| 1622 | sw->state = SW_STATE_NONE; |
| 1623 | return rc; |
| 1624 | } |
| 1625 | sw_close_file(sw); |
| 1626 | |
| 1627 | return sw_activate(sw); |
| 1628 | } |
| 1629 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1630 | static void fill_nm_channel(struct abis_nm_channel *ch, u_int8_t bts_port, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1631 | u_int8_t ts_nr, u_int8_t subslot_nr) |
| 1632 | { |
Harald Welte | adaf08b | 2009-01-18 11:08:10 +0000 | [diff] [blame] | 1633 | ch->attrib = NM_ATT_ABIS_CHANNEL; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1634 | ch->bts_port = bts_port; |
| 1635 | ch->timeslot = ts_nr; |
| 1636 | ch->subslot = subslot_nr; |
| 1637 | } |
| 1638 | |
| 1639 | int abis_nm_establish_tei(struct gsm_bts *bts, u_int8_t trx_nr, |
| 1640 | u_int8_t e1_port, u_int8_t e1_timeslot, u_int8_t e1_subslot, |
| 1641 | u_int8_t tei) |
| 1642 | { |
| 1643 | struct abis_om_hdr *oh; |
| 1644 | struct abis_nm_channel *ch; |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 1645 | u_int8_t len = sizeof(*ch) + 2; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1646 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1647 | |
| 1648 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1649 | fill_om_fom_hdr(oh, len, NM_MT_ESTABLISH_TEI, NM_OC_RADIO_CARRIER, |
| 1650 | bts->bts_nr, trx_nr, 0xff); |
| 1651 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1652 | msgb_tv_put(msg, NM_ATT_TEI, tei); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1653 | |
| 1654 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 1655 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 1656 | |
| 1657 | return abis_nm_sendmsg(bts, msg); |
| 1658 | } |
| 1659 | |
| 1660 | /* connect signalling of one (BTS,TRX) to a particular timeslot on the E1 */ |
| 1661 | int abis_nm_conn_terr_sign(struct gsm_bts_trx *trx, |
| 1662 | u_int8_t e1_port, u_int8_t e1_timeslot, u_int8_t e1_subslot) |
| 1663 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1664 | struct gsm_bts *bts = trx->bts; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1665 | struct abis_om_hdr *oh; |
| 1666 | struct abis_nm_channel *ch; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1667 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1668 | |
| 1669 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 6f676a3 | 2009-01-18 14:27:48 +0000 | [diff] [blame] | 1670 | fill_om_fom_hdr(oh, sizeof(*ch), NM_MT_CONN_TERR_SIGN, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1671 | NM_OC_RADIO_CARRIER, bts->bts_nr, trx->nr, 0xff); |
| 1672 | |
| 1673 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 1674 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 1675 | |
| 1676 | return abis_nm_sendmsg(bts, msg); |
| 1677 | } |
| 1678 | |
| 1679 | #if 0 |
| 1680 | int abis_nm_disc_terr_sign(struct abis_nm_h *h, struct abis_om_obj_inst *inst, |
| 1681 | struct abis_nm_abis_channel *chan) |
| 1682 | { |
| 1683 | } |
| 1684 | #endif |
| 1685 | |
| 1686 | int abis_nm_conn_terr_traf(struct gsm_bts_trx_ts *ts, |
| 1687 | u_int8_t e1_port, u_int8_t e1_timeslot, |
| 1688 | u_int8_t e1_subslot) |
| 1689 | { |
| 1690 | struct gsm_bts *bts = ts->trx->bts; |
| 1691 | struct abis_om_hdr *oh; |
| 1692 | struct abis_nm_channel *ch; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1693 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1694 | |
| 1695 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1696 | fill_om_fom_hdr(oh, sizeof(*ch), NM_MT_CONN_TERR_TRAF, |
Harald Welte | b110cee | 2009-02-18 03:42:35 +0000 | [diff] [blame] | 1697 | NM_OC_CHANNEL, bts->bts_nr, ts->trx->nr, ts->nr); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1698 | |
| 1699 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 1700 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 1701 | |
Harald Welte | f325eb4 | 2009-02-19 17:07:39 +0000 | [diff] [blame] | 1702 | DEBUGP(DNM, "CONNECT TERR TRAF Um=%s E1=(%u,%u,%u)\n", |
| 1703 | gsm_ts_name(ts), |
Harald Welte | b110cee | 2009-02-18 03:42:35 +0000 | [diff] [blame] | 1704 | e1_port, e1_timeslot, e1_subslot); |
| 1705 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1706 | return abis_nm_sendmsg(bts, msg); |
| 1707 | } |
| 1708 | |
| 1709 | #if 0 |
| 1710 | int abis_nm_disc_terr_traf(struct abis_nm_h *h, struct abis_om_obj_inst *inst, |
| 1711 | struct abis_nm_abis_channel *chan, |
| 1712 | u_int8_t subchan) |
| 1713 | { |
| 1714 | } |
| 1715 | #endif |
| 1716 | |
Harald Welte | 22af0db | 2009-02-14 15:41:08 +0000 | [diff] [blame] | 1717 | /* Chapter 8.6.1 */ |
| 1718 | int abis_nm_set_bts_attr(struct gsm_bts *bts, u_int8_t *attr, int attr_len) |
| 1719 | { |
| 1720 | struct abis_om_hdr *oh; |
| 1721 | struct msgb *msg = nm_msgb_alloc(); |
| 1722 | u_int8_t *cur; |
| 1723 | |
| 1724 | DEBUGP(DNM, "Set BTS Attr (bts=%d)\n", bts->nr); |
| 1725 | |
| 1726 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 191280d | 2009-05-01 13:20:04 +0000 | [diff] [blame] | 1727 | fill_om_fom_hdr(oh, attr_len, NM_MT_SET_BTS_ATTR, NM_OC_BTS, bts->bts_nr, 0xff, 0xff); |
Harald Welte | 22af0db | 2009-02-14 15:41:08 +0000 | [diff] [blame] | 1728 | cur = msgb_put(msg, attr_len); |
| 1729 | memcpy(cur, attr, attr_len); |
| 1730 | |
| 1731 | return abis_nm_sendmsg(bts, msg); |
| 1732 | } |
| 1733 | |
| 1734 | /* Chapter 8.6.2 */ |
| 1735 | int abis_nm_set_radio_attr(struct gsm_bts_trx *trx, u_int8_t *attr, int attr_len) |
| 1736 | { |
| 1737 | struct abis_om_hdr *oh; |
| 1738 | struct msgb *msg = nm_msgb_alloc(); |
| 1739 | u_int8_t *cur; |
| 1740 | |
| 1741 | DEBUGP(DNM, "Set TRX Attr (bts=%d,trx=%d)\n", trx->bts->nr, trx->nr); |
| 1742 | |
| 1743 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1744 | fill_om_fom_hdr(oh, attr_len, NM_MT_SET_RADIO_ATTR, NM_OC_RADIO_CARRIER, |
Harald Welte | 191280d | 2009-05-01 13:20:04 +0000 | [diff] [blame] | 1745 | trx->bts->bts_nr, trx->nr, 0xff); |
Harald Welte | 22af0db | 2009-02-14 15:41:08 +0000 | [diff] [blame] | 1746 | cur = msgb_put(msg, attr_len); |
| 1747 | memcpy(cur, attr, attr_len); |
| 1748 | |
| 1749 | return abis_nm_sendmsg(trx->bts, msg); |
| 1750 | } |
| 1751 | |
Harald Welte | 39c7deb | 2009-08-09 21:49:48 +0200 | [diff] [blame] | 1752 | static int verify_chan_comb(struct gsm_bts_trx_ts *ts, u_int8_t chan_comb) |
| 1753 | { |
| 1754 | int i; |
| 1755 | |
| 1756 | /* As it turns out, the BS-11 has some very peculiar restrictions |
| 1757 | * on the channel combinations it allows */ |
| 1758 | if (ts->trx->bts->type == GSM_BTS_TYPE_BS11) { |
| 1759 | switch (chan_comb) { |
| 1760 | case NM_CHANC_TCHHalf: |
| 1761 | case NM_CHANC_TCHHalf2: |
| 1762 | /* not supported */ |
| 1763 | return -EINVAL; |
| 1764 | case NM_CHANC_SDCCH: |
| 1765 | /* only one SDCCH/8 per TRX */ |
| 1766 | for (i = 0; i < TRX_NR_TS; i++) { |
| 1767 | if (i == ts->nr) |
| 1768 | continue; |
| 1769 | if (ts->trx->ts[i].nm_chan_comb == |
| 1770 | NM_CHANC_SDCCH) |
| 1771 | return -EINVAL; |
| 1772 | } |
| 1773 | /* not allowed for TS0 of BCCH-TRX */ |
| 1774 | if (ts->trx == ts->trx->bts->c0 && |
| 1775 | ts->nr == 0) |
| 1776 | return -EINVAL; |
| 1777 | /* not on the same TRX that has a BCCH+SDCCH4 |
| 1778 | * combination */ |
| 1779 | if (ts->trx == ts->trx->bts->c0 && |
| 1780 | (ts->trx->ts[0].nm_chan_comb == 5 || |
| 1781 | ts->trx->ts[0].nm_chan_comb == 8)) |
| 1782 | return -EINVAL; |
| 1783 | break; |
| 1784 | case NM_CHANC_mainBCCH: |
| 1785 | case NM_CHANC_BCCHComb: |
| 1786 | /* allowed only for TS0 of C0 */ |
| 1787 | if (ts->trx != ts->trx->bts->c0 || |
| 1788 | ts->nr != 0) |
| 1789 | return -EINVAL; |
| 1790 | break; |
| 1791 | case NM_CHANC_BCCH: |
| 1792 | /* allowed only for TS 2/4/6 of C0 */ |
| 1793 | if (ts->trx != ts->trx->bts->c0) |
| 1794 | return -EINVAL; |
| 1795 | if (ts->nr != 2 && ts->nr != 4 && |
| 1796 | ts->nr != 6) |
| 1797 | return -EINVAL; |
| 1798 | break; |
| 1799 | case 8: /* this is not like 08.58, but in fact |
| 1800 | * FCCH+SCH+BCCH+CCCH+SDCCH/4+SACCH/C4+CBCH */ |
| 1801 | /* FIXME: only one CBCH allowed per cell */ |
| 1802 | break; |
| 1803 | } |
| 1804 | } |
| 1805 | return 0; |
| 1806 | } |
| 1807 | |
Harald Welte | 22af0db | 2009-02-14 15:41:08 +0000 | [diff] [blame] | 1808 | /* Chapter 8.6.3 */ |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1809 | int abis_nm_set_channel_attr(struct gsm_bts_trx_ts *ts, u_int8_t chan_comb) |
| 1810 | { |
| 1811 | struct gsm_bts *bts = ts->trx->bts; |
| 1812 | struct abis_om_hdr *oh; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1813 | u_int16_t arfcn = htons(ts->trx->arfcn); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1814 | u_int8_t zero = 0x00; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1815 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 1816 | u_int8_t len = 2 + 2; |
| 1817 | |
| 1818 | if (bts->type == GSM_BTS_TYPE_BS11) |
| 1819 | len += 4 + 2 + 2 + 3; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1820 | |
Harald Welte | f325eb4 | 2009-02-19 17:07:39 +0000 | [diff] [blame] | 1821 | DEBUGP(DNM, "Set Chan Attr %s\n", gsm_ts_name(ts)); |
Harald Welte | 39c7deb | 2009-08-09 21:49:48 +0200 | [diff] [blame] | 1822 | if (verify_chan_comb(ts, chan_comb) < 0) { |
| 1823 | msgb_free(msg); |
| 1824 | DEBUGP(DNM, "Invalid Channel Combination!!!\n"); |
| 1825 | return -EINVAL; |
| 1826 | } |
| 1827 | ts->nm_chan_comb = chan_comb; |
Harald Welte | 22af0db | 2009-02-14 15:41:08 +0000 | [diff] [blame] | 1828 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1829 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 1830 | fill_om_fom_hdr(oh, len, NM_MT_SET_CHAN_ATTR, |
Holger Freyther | 6b2d262 | 2009-02-14 23:16:59 +0000 | [diff] [blame] | 1831 | NM_OC_CHANNEL, bts->bts_nr, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1832 | ts->trx->nr, ts->nr); |
| 1833 | /* FIXME: don't send ARFCN list, hopping sequence, mAIO, ...*/ |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 1834 | if (bts->type == GSM_BTS_TYPE_BS11) |
| 1835 | msgb_tlv16_put(msg, NM_ATT_ARFCN_LIST, 1, &arfcn); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1836 | msgb_tv_put(msg, NM_ATT_CHAN_COMB, chan_comb); |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 1837 | if (bts->type == GSM_BTS_TYPE_BS11) { |
| 1838 | msgb_tv_put(msg, NM_ATT_HSN, 0x00); |
| 1839 | msgb_tv_put(msg, NM_ATT_MAIO, 0x00); |
| 1840 | } |
Harald Welte | e6c22d9 | 2009-07-21 20:40:05 +0200 | [diff] [blame] | 1841 | msgb_tv_put(msg, NM_ATT_TSC, bts->tsc); /* training sequence */ |
Harald Welte | e0590df | 2009-02-15 03:34:15 +0000 | [diff] [blame] | 1842 | if (bts->type == GSM_BTS_TYPE_BS11) |
| 1843 | msgb_tlv_put(msg, 0x59, 1, &zero); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1844 | |
| 1845 | return abis_nm_sendmsg(bts, msg); |
| 1846 | } |
| 1847 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1848 | int abis_nm_sw_act_req_ack(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i1, |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 1849 | u_int8_t i2, u_int8_t i3, int nack, u_int8_t *attr, int att_len) |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1850 | { |
| 1851 | struct abis_om_hdr *oh; |
| 1852 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 1853 | u_int8_t msgtype = NM_MT_SW_ACT_REQ_ACK; |
| 1854 | u_int8_t len = att_len; |
| 1855 | |
| 1856 | if (nack) { |
| 1857 | len += 2; |
| 1858 | msgtype = NM_MT_SW_ACT_REQ_NACK; |
| 1859 | } |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1860 | |
| 1861 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 1862 | fill_om_fom_hdr(oh, att_len, msgtype, obj_class, i1, i2, i3); |
| 1863 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1864 | if (attr) { |
| 1865 | u_int8_t *ptr = msgb_put(msg, att_len); |
| 1866 | memcpy(ptr, attr, att_len); |
| 1867 | } |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 1868 | if (nack) |
| 1869 | msgb_tv_put(msg, NM_ATT_NACK_CAUSES, NM_NACK_OBJCLASS_NOTSUPP); |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1870 | |
| 1871 | return abis_nm_sendmsg(bts, msg); |
| 1872 | } |
| 1873 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1874 | int abis_nm_raw_msg(struct gsm_bts *bts, int len, u_int8_t *rawmsg) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1875 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1876 | struct msgb *msg = nm_msgb_alloc(); |
| 1877 | struct abis_om_hdr *oh; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1878 | u_int8_t *data; |
| 1879 | |
| 1880 | oh = (struct abis_om_hdr *) msgb_put(msg, sizeof(*oh)); |
| 1881 | fill_om_hdr(oh, len); |
| 1882 | data = msgb_put(msg, len); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1883 | memcpy(data, rawmsg, len); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1884 | |
| 1885 | return abis_nm_sendmsg(bts, msg); |
| 1886 | } |
| 1887 | |
| 1888 | /* Siemens specific commands */ |
| 1889 | static int __simple_cmd(struct gsm_bts *bts, u_int8_t msg_type) |
| 1890 | { |
| 1891 | struct abis_om_hdr *oh; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 1892 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1893 | |
| 1894 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 1895 | fill_om_fom_hdr(oh, 0, msg_type, NM_OC_SITE_MANAGER, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1896 | 0xff, 0xff, 0xff); |
| 1897 | |
| 1898 | return abis_nm_sendmsg(bts, msg); |
| 1899 | } |
| 1900 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1901 | /* Chapter 8.9.2 */ |
| 1902 | int abis_nm_opstart(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i0, u_int8_t i1, u_int8_t i2) |
| 1903 | { |
| 1904 | struct abis_om_hdr *oh; |
| 1905 | struct msgb *msg = nm_msgb_alloc(); |
| 1906 | |
| 1907 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1908 | fill_om_fom_hdr(oh, 0, NM_MT_OPSTART, obj_class, i0, i1, i2); |
| 1909 | |
Harald Welte | a8bd6d4 | 2009-10-20 09:56:18 +0200 | [diff] [blame] | 1910 | debugp_foh((struct abis_om_fom_hdr *) oh->data); |
| 1911 | DEBUGPC(DNM, "Sending OPSTART\n"); |
| 1912 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1913 | return abis_nm_sendmsg(bts, msg); |
| 1914 | } |
| 1915 | |
| 1916 | /* Chapter 8.8.5 */ |
| 1917 | int abis_nm_chg_adm_state(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i0, |
Daniel Willmann | 65f68fa | 2009-08-10 11:49:36 +0200 | [diff] [blame] | 1918 | u_int8_t i1, u_int8_t i2, enum abis_nm_adm_state adm_state) |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1919 | { |
| 1920 | struct abis_om_hdr *oh; |
| 1921 | struct msgb *msg = nm_msgb_alloc(); |
| 1922 | |
| 1923 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1924 | fill_om_fom_hdr(oh, 2, NM_MT_CHG_ADM_STATE, obj_class, i0, i1, i2); |
| 1925 | msgb_tv_put(msg, NM_ATT_ADM_STATE, adm_state); |
| 1926 | |
| 1927 | return abis_nm_sendmsg(bts, msg); |
| 1928 | } |
| 1929 | |
Harald Welte | 1989c08 | 2009-08-06 17:58:31 +0200 | [diff] [blame] | 1930 | int abis_nm_conn_mdrop_link(struct gsm_bts *bts, u_int8_t e1_port0, u_int8_t ts0, |
| 1931 | u_int8_t e1_port1, u_int8_t ts1) |
| 1932 | { |
| 1933 | struct abis_om_hdr *oh; |
| 1934 | struct msgb *msg = nm_msgb_alloc(); |
| 1935 | u_int8_t *attr; |
| 1936 | |
| 1937 | DEBUGP(DNM, "CONNECT MDROP LINK E1=(%u,%u) -> E1=(%u, %u)\n", |
| 1938 | e1_port0, ts0, e1_port1, ts1); |
| 1939 | |
| 1940 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1941 | fill_om_fom_hdr(oh, 6, NM_MT_CONN_MDROP_LINK, |
| 1942 | NM_OC_SITE_MANAGER, 0x00, 0x00, 0x00); |
| 1943 | |
| 1944 | attr = msgb_put(msg, 3); |
| 1945 | attr[0] = NM_ATT_MDROP_LINK; |
| 1946 | attr[1] = e1_port0; |
| 1947 | attr[2] = ts0; |
| 1948 | |
| 1949 | attr = msgb_put(msg, 3); |
| 1950 | attr[0] = NM_ATT_MDROP_NEXT; |
| 1951 | attr[1] = e1_port1; |
| 1952 | attr[2] = ts1; |
| 1953 | |
| 1954 | return abis_nm_sendmsg(bts, msg); |
| 1955 | } |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame] | 1956 | |
Harald Welte | c731038 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 1957 | /* Chapter 8.7.1 */ |
| 1958 | int abis_nm_perform_test(struct gsm_bts *bts, u_int8_t obj_class, |
| 1959 | u_int8_t bts_nr, u_int8_t trx_nr, u_int8_t ts_nr, |
| 1960 | u_int8_t test_nr, u_int8_t auton_report, |
| 1961 | u_int8_t *phys_config, u_int16_t phys_config_len) |
| 1962 | { |
| 1963 | struct abis_om_hdr *oh; |
| 1964 | struct msgb *msg = nm_msgb_alloc(); |
| 1965 | int len = 4; /* 2 TV attributes */ |
| 1966 | |
| 1967 | DEBUGP(DNM, "PEFORM TEST\n"); |
| 1968 | |
| 1969 | if (phys_config_len) |
| 1970 | len += 3 + phys_config_len; |
| 1971 | |
| 1972 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1973 | fill_om_fom_hdr(oh, len, NM_MT_PERF_TEST, |
| 1974 | obj_class, bts_nr, trx_nr, ts_nr); |
| 1975 | msgb_tv_put(msg, NM_ATT_TEST_NO, test_nr); |
| 1976 | msgb_tv_put(msg, NM_ATT_AUTON_REPORT, auton_report); |
| 1977 | if (phys_config_len) |
| 1978 | msgb_tl16v_put(msg, NM_ATT_PHYS_CONF, phys_config_len, |
| 1979 | phys_config); |
| 1980 | |
| 1981 | return abis_nm_sendmsg(bts, msg); |
| 1982 | } |
| 1983 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1984 | int abis_nm_event_reports(struct gsm_bts *bts, int on) |
| 1985 | { |
| 1986 | if (on == 0) |
Harald Welte | 227d407 | 2009-01-03 08:16:25 +0000 | [diff] [blame] | 1987 | return __simple_cmd(bts, NM_MT_STOP_EVENT_REP); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1988 | else |
Harald Welte | 227d407 | 2009-01-03 08:16:25 +0000 | [diff] [blame] | 1989 | return __simple_cmd(bts, NM_MT_REST_EVENT_REP); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1990 | } |
| 1991 | |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 1992 | /* Siemens (or BS-11) specific commands */ |
| 1993 | |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1994 | int abis_nm_bs11_bsc_disconnect(struct gsm_bts *bts, int reconnect) |
| 1995 | { |
| 1996 | if (reconnect == 0) |
| 1997 | return __simple_cmd(bts, NM_MT_BS11_DISCONNECT); |
| 1998 | else |
| 1999 | return __simple_cmd(bts, NM_MT_BS11_RECONNECT); |
| 2000 | } |
| 2001 | |
Harald Welte | b842797 | 2009-02-05 19:27:17 +0000 | [diff] [blame] | 2002 | int abis_nm_bs11_restart(struct gsm_bts *bts) |
| 2003 | { |
| 2004 | return __simple_cmd(bts, NM_MT_BS11_RESTART); |
| 2005 | } |
| 2006 | |
| 2007 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 2008 | struct bs11_date_time { |
| 2009 | u_int16_t year; |
| 2010 | u_int8_t month; |
| 2011 | u_int8_t day; |
| 2012 | u_int8_t hour; |
| 2013 | u_int8_t min; |
| 2014 | u_int8_t sec; |
| 2015 | } __attribute__((packed)); |
| 2016 | |
| 2017 | |
| 2018 | void get_bs11_date_time(struct bs11_date_time *aet) |
| 2019 | { |
| 2020 | time_t t; |
| 2021 | struct tm *tm; |
| 2022 | |
| 2023 | t = time(NULL); |
| 2024 | tm = localtime(&t); |
| 2025 | aet->sec = tm->tm_sec; |
| 2026 | aet->min = tm->tm_min; |
| 2027 | aet->hour = tm->tm_hour; |
| 2028 | aet->day = tm->tm_mday; |
| 2029 | aet->month = tm->tm_mon; |
| 2030 | aet->year = htons(1900 + tm->tm_year); |
| 2031 | } |
| 2032 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2033 | int abis_nm_bs11_reset_resource(struct gsm_bts *bts) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 2034 | { |
Harald Welte | 4668fda | 2009-01-03 08:19:29 +0000 | [diff] [blame] | 2035 | return __simple_cmd(bts, NM_MT_BS11_RESET_RESOURCE); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 2036 | } |
| 2037 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2038 | int abis_nm_bs11_db_transmission(struct gsm_bts *bts, int begin) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 2039 | { |
| 2040 | if (begin) |
Harald Welte | 4668fda | 2009-01-03 08:19:29 +0000 | [diff] [blame] | 2041 | return __simple_cmd(bts, NM_MT_BS11_BEGIN_DB_TX); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 2042 | else |
Harald Welte | 4668fda | 2009-01-03 08:19:29 +0000 | [diff] [blame] | 2043 | return __simple_cmd(bts, NM_MT_BS11_END_DB_TX); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 2044 | } |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2045 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2046 | int abis_nm_bs11_create_object(struct gsm_bts *bts, |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2047 | enum abis_bs11_objtype type, u_int8_t idx, |
| 2048 | u_int8_t attr_len, const u_int8_t *attr) |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2049 | { |
| 2050 | struct abis_om_hdr *oh; |
| 2051 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2052 | u_int8_t *cur; |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2053 | |
| 2054 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 6f676a3 | 2009-01-18 14:27:48 +0000 | [diff] [blame] | 2055 | fill_om_fom_hdr(oh, attr_len, NM_MT_BS11_CREATE_OBJ, |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 2056 | NM_OC_BS11, type, 0, idx); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2057 | cur = msgb_put(msg, attr_len); |
| 2058 | memcpy(cur, attr, attr_len); |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2059 | |
| 2060 | return abis_nm_sendmsg(bts, msg); |
| 2061 | } |
| 2062 | |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 2063 | int abis_nm_bs11_delete_object(struct gsm_bts *bts, |
| 2064 | enum abis_bs11_objtype type, u_int8_t idx) |
| 2065 | { |
| 2066 | struct abis_om_hdr *oh; |
| 2067 | struct msgb *msg = nm_msgb_alloc(); |
| 2068 | |
| 2069 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2070 | fill_om_fom_hdr(oh, 0, NM_MT_BS11_DELETE_OBJ, |
| 2071 | NM_OC_BS11, type, 0, idx); |
| 2072 | |
| 2073 | return abis_nm_sendmsg(bts, msg); |
| 2074 | } |
| 2075 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2076 | int abis_nm_bs11_create_envaBTSE(struct gsm_bts *bts, u_int8_t idx) |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2077 | { |
| 2078 | struct abis_om_hdr *oh; |
| 2079 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2080 | u_int8_t zero = 0x00; |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2081 | |
| 2082 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 6f676a3 | 2009-01-18 14:27:48 +0000 | [diff] [blame] | 2083 | fill_om_fom_hdr(oh, 3, NM_MT_BS11_CREATE_OBJ, |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2084 | NM_OC_BS11_ENVABTSE, 0, idx, 0xff); |
| 2085 | msgb_tlv_put(msg, 0x99, 1, &zero); |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2086 | |
| 2087 | return abis_nm_sendmsg(bts, msg); |
| 2088 | } |
| 2089 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2090 | int abis_nm_bs11_create_bport(struct gsm_bts *bts, u_int8_t idx) |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2091 | { |
| 2092 | struct abis_om_hdr *oh; |
| 2093 | struct msgb *msg = nm_msgb_alloc(); |
| 2094 | |
| 2095 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2096 | fill_om_fom_hdr(oh, 0, NM_MT_BS11_CREATE_OBJ, NM_OC_BS11_BPORT, |
Daniel Willmann | 65f68fa | 2009-08-10 11:49:36 +0200 | [diff] [blame] | 2097 | idx, 0xff, 0xff); |
| 2098 | |
| 2099 | return abis_nm_sendmsg(bts, msg); |
| 2100 | } |
| 2101 | |
| 2102 | int abis_nm_bs11_delete_bport(struct gsm_bts *bts, u_int8_t idx) |
| 2103 | { |
| 2104 | struct abis_om_hdr *oh; |
| 2105 | struct msgb *msg = nm_msgb_alloc(); |
| 2106 | |
| 2107 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2108 | fill_om_fom_hdr(oh, 0, NM_MT_BS11_DELETE_OBJ, NM_OC_BS11_BPORT, |
| 2109 | idx, 0xff, 0xff); |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 2110 | |
| 2111 | return abis_nm_sendmsg(bts, msg); |
| 2112 | } |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2113 | |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 2114 | static const u_int8_t sm_attr[] = { NM_ATT_TEI, NM_ATT_ABIS_CHANNEL }; |
| 2115 | int abis_nm_bs11_get_oml_tei_ts(struct gsm_bts *bts) |
| 2116 | { |
| 2117 | struct abis_om_hdr *oh; |
| 2118 | struct msgb *msg = nm_msgb_alloc(); |
| 2119 | |
| 2120 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2121 | fill_om_fom_hdr(oh, 2+sizeof(sm_attr), NM_MT_GET_ATTR, NM_OC_SITE_MANAGER, |
| 2122 | 0xff, 0xff, 0xff); |
| 2123 | msgb_tlv_put(msg, NM_ATT_LIST_REQ_ATTR, sizeof(sm_attr), sm_attr); |
| 2124 | |
| 2125 | return abis_nm_sendmsg(bts, msg); |
| 2126 | } |
| 2127 | |
Harald Welte | b6c92ae | 2009-02-21 20:15:32 +0000 | [diff] [blame] | 2128 | /* like abis_nm_conn_terr_traf + set_tei */ |
| 2129 | int abis_nm_bs11_conn_oml_tei(struct gsm_bts *bts, u_int8_t e1_port, |
| 2130 | u_int8_t e1_timeslot, u_int8_t e1_subslot, |
| 2131 | u_int8_t tei) |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2132 | { |
| 2133 | struct abis_om_hdr *oh; |
| 2134 | struct abis_nm_channel *ch; |
| 2135 | struct msgb *msg = nm_msgb_alloc(); |
| 2136 | |
| 2137 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | b6c92ae | 2009-02-21 20:15:32 +0000 | [diff] [blame] | 2138 | fill_om_fom_hdr(oh, sizeof(*ch)+2, NM_MT_BS11_SET_ATTR, |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2139 | NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff); |
| 2140 | |
| 2141 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 2142 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
Harald Welte | b6c92ae | 2009-02-21 20:15:32 +0000 | [diff] [blame] | 2143 | msgb_tv_put(msg, NM_ATT_TEI, tei); |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2144 | |
| 2145 | return abis_nm_sendmsg(bts, msg); |
| 2146 | } |
| 2147 | |
| 2148 | int abis_nm_bs11_set_trx_power(struct gsm_bts_trx *trx, u_int8_t level) |
| 2149 | { |
| 2150 | struct abis_om_hdr *oh; |
| 2151 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2152 | |
| 2153 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 6f676a3 | 2009-01-18 14:27:48 +0000 | [diff] [blame] | 2154 | fill_om_fom_hdr(oh, 3, NM_MT_BS11_SET_ATTR, |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2155 | NM_OC_BS11, BS11_OBJ_PA, 0x00, trx->nr); |
| 2156 | msgb_tlv_put(msg, NM_ATT_BS11_TXPWR, 1, &level); |
| 2157 | |
| 2158 | return abis_nm_sendmsg(trx->bts, msg); |
| 2159 | } |
| 2160 | |
Harald Welte | 78fc0d4 | 2009-02-19 02:50:57 +0000 | [diff] [blame] | 2161 | int abis_nm_bs11_get_trx_power(struct gsm_bts_trx *trx) |
| 2162 | { |
| 2163 | struct abis_om_hdr *oh; |
| 2164 | struct msgb *msg = nm_msgb_alloc(); |
| 2165 | u_int8_t attr = NM_ATT_BS11_TXPWR; |
| 2166 | |
| 2167 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2168 | fill_om_fom_hdr(oh, 2+sizeof(attr), NM_MT_GET_ATTR, |
| 2169 | NM_OC_BS11, BS11_OBJ_PA, 0x00, trx->nr); |
| 2170 | msgb_tlv_put(msg, NM_ATT_LIST_REQ_ATTR, sizeof(attr), &attr); |
| 2171 | |
| 2172 | return abis_nm_sendmsg(trx->bts, msg); |
| 2173 | } |
| 2174 | |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 2175 | int abis_nm_bs11_get_pll_mode(struct gsm_bts *bts) |
| 2176 | { |
| 2177 | struct abis_om_hdr *oh; |
| 2178 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | a7cfa03 | 2009-04-29 22:33:02 +0000 | [diff] [blame] | 2179 | u_int8_t attr[] = { NM_ATT_BS11_PLL_MODE }; |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 2180 | |
| 2181 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2182 | fill_om_fom_hdr(oh, 2+sizeof(attr), NM_MT_GET_ATTR, |
| 2183 | NM_OC_BS11, BS11_OBJ_LI, 0x00, 0x00); |
Harald Welte | aeedeb4 | 2009-05-01 13:08:14 +0000 | [diff] [blame] | 2184 | msgb_tlv_put(msg, NM_ATT_LIST_REQ_ATTR, sizeof(attr), attr); |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 2185 | |
| 2186 | return abis_nm_sendmsg(bts, msg); |
| 2187 | } |
| 2188 | |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 2189 | int abis_nm_bs11_get_cclk(struct gsm_bts *bts) |
| 2190 | { |
| 2191 | struct abis_om_hdr *oh; |
| 2192 | struct msgb *msg = nm_msgb_alloc(); |
| 2193 | u_int8_t attr[] = { NM_ATT_BS11_CCLK_ACCURACY, |
| 2194 | NM_ATT_BS11_CCLK_TYPE }; |
| 2195 | |
| 2196 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2197 | fill_om_fom_hdr(oh, 2+sizeof(attr), NM_MT_GET_ATTR, |
| 2198 | NM_OC_BS11, BS11_OBJ_CCLK, 0x00, 0x00); |
| 2199 | msgb_tlv_put(msg, NM_ATT_LIST_REQ_ATTR, sizeof(attr), attr); |
| 2200 | |
| 2201 | return abis_nm_sendmsg(bts, msg); |
| 2202 | |
| 2203 | } |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 2204 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 2205 | //static const u_int8_t bs11_logon_c7[] = { 0x07, 0xd9, 0x01, 0x11, 0x0d, 0x10, 0x20 }; |
Harald Welte | bb15131 | 2009-01-28 20:42:07 +0000 | [diff] [blame] | 2206 | static const u_int8_t bs11_logon_c8[] = { 0x02 }; |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2207 | static const u_int8_t bs11_logon_c9[] = "FACTORY"; |
| 2208 | |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2209 | int abis_nm_bs11_factory_logon(struct gsm_bts *bts, int on) |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2210 | { |
| 2211 | struct abis_om_hdr *oh; |
| 2212 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 2213 | struct bs11_date_time bdt; |
| 2214 | |
| 2215 | get_bs11_date_time(&bdt); |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2216 | |
| 2217 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2218 | if (on) { |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 2219 | u_int8_t len = 3*2 + sizeof(bdt) |
Harald Welte | 6f676a3 | 2009-01-18 14:27:48 +0000 | [diff] [blame] | 2220 | + sizeof(bs11_logon_c8) + sizeof(bs11_logon_c9); |
Harald Welte | 043d04a | 2009-01-29 23:15:30 +0000 | [diff] [blame] | 2221 | fill_om_fom_hdr(oh, len, NM_MT_BS11_LMT_LOGON, |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 2222 | NM_OC_BS11_BTSE, 0xff, 0xff, 0xff); |
Harald Welte | 043d04a | 2009-01-29 23:15:30 +0000 | [diff] [blame] | 2223 | msgb_tlv_put(msg, NM_ATT_BS11_LMT_LOGIN_TIME, |
Harald Welte | 5083b0b | 2009-02-02 19:20:52 +0000 | [diff] [blame] | 2224 | sizeof(bdt), (u_int8_t *) &bdt); |
Harald Welte | 043d04a | 2009-01-29 23:15:30 +0000 | [diff] [blame] | 2225 | msgb_tlv_put(msg, NM_ATT_BS11_LMT_USER_ACC_LEV, |
| 2226 | sizeof(bs11_logon_c8), bs11_logon_c8); |
| 2227 | msgb_tlv_put(msg, NM_ATT_BS11_LMT_USER_NAME, |
| 2228 | sizeof(bs11_logon_c9), bs11_logon_c9); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2229 | } else { |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2230 | fill_om_fom_hdr(oh, 0, NM_MT_BS11_LMT_LOGOFF, |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 2231 | NM_OC_BS11_BTSE, 0xff, 0xff, 0xff); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2232 | } |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 2233 | |
| 2234 | return abis_nm_sendmsg(bts, msg); |
| 2235 | } |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2236 | |
| 2237 | int abis_nm_bs11_set_trx1_pw(struct gsm_bts *bts, const char *password) |
| 2238 | { |
| 2239 | struct abis_om_hdr *oh; |
| 2240 | struct msgb *msg; |
| 2241 | |
| 2242 | if (strlen(password) != 10) |
| 2243 | return -EINVAL; |
| 2244 | |
| 2245 | msg = nm_msgb_alloc(); |
| 2246 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 6f676a3 | 2009-01-18 14:27:48 +0000 | [diff] [blame] | 2247 | fill_om_fom_hdr(oh, 2+strlen(password), NM_MT_BS11_SET_ATTR, |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2248 | NM_OC_BS11, BS11_OBJ_TRX1, 0x00, 0x00); |
| 2249 | msgb_tlv_put(msg, NM_ATT_BS11_PASSWORD, 10, (const u_int8_t *)password); |
| 2250 | |
| 2251 | return abis_nm_sendmsg(bts, msg); |
| 2252 | } |
| 2253 | |
Harald Welte | e69f5fb | 2009-04-28 16:31:38 +0000 | [diff] [blame] | 2254 | /* change the BS-11 PLL Mode to either locked (E1 derived) or standalone */ |
| 2255 | int abis_nm_bs11_set_pll_locked(struct gsm_bts *bts, int locked) |
| 2256 | { |
| 2257 | struct abis_om_hdr *oh; |
| 2258 | struct msgb *msg; |
Harald Welte | a432cd3 | 2009-04-29 13:01:50 +0000 | [diff] [blame] | 2259 | u_int8_t tlv_value; |
Harald Welte | e69f5fb | 2009-04-28 16:31:38 +0000 | [diff] [blame] | 2260 | |
| 2261 | msg = nm_msgb_alloc(); |
| 2262 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2263 | fill_om_fom_hdr(oh, 3, NM_MT_BS11_SET_ATTR, NM_OC_BS11, |
| 2264 | BS11_OBJ_LI, 0x00, 0x00); |
Harald Welte | a432cd3 | 2009-04-29 13:01:50 +0000 | [diff] [blame] | 2265 | |
| 2266 | if (locked) |
| 2267 | tlv_value = BS11_LI_PLL_LOCKED; |
| 2268 | else |
| 2269 | tlv_value = BS11_LI_PLL_STANDALONE; |
| 2270 | |
| 2271 | msgb_tlv_put(msg, NM_ATT_BS11_PLL_MODE, 1, &tlv_value); |
Harald Welte | e69f5fb | 2009-04-28 16:31:38 +0000 | [diff] [blame] | 2272 | |
| 2273 | return abis_nm_sendmsg(bts, msg); |
| 2274 | } |
| 2275 | |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 2276 | int abis_nm_bs11_get_state(struct gsm_bts *bts) |
| 2277 | { |
| 2278 | return __simple_cmd(bts, NM_MT_BS11_GET_STATE); |
| 2279 | } |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2280 | |
| 2281 | /* BS11 SWL */ |
| 2282 | |
Harald Welte (local) | d19e58b | 2009-08-15 02:30:58 +0200 | [diff] [blame] | 2283 | void *tall_fle_ctx; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 2284 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2285 | struct abis_nm_bs11_sw { |
| 2286 | struct gsm_bts *bts; |
| 2287 | char swl_fname[PATH_MAX]; |
| 2288 | u_int8_t win_size; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 2289 | int forced; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2290 | struct llist_head file_list; |
| 2291 | gsm_cbfn *user_cb; /* specified by the user */ |
| 2292 | }; |
| 2293 | static struct abis_nm_bs11_sw _g_bs11_sw, *g_bs11_sw = &_g_bs11_sw; |
| 2294 | |
| 2295 | struct file_list_entry { |
| 2296 | struct llist_head list; |
| 2297 | char fname[PATH_MAX]; |
| 2298 | }; |
| 2299 | |
| 2300 | struct file_list_entry *fl_dequeue(struct llist_head *queue) |
| 2301 | { |
| 2302 | struct llist_head *lh; |
| 2303 | |
| 2304 | if (llist_empty(queue)) |
| 2305 | return NULL; |
| 2306 | |
| 2307 | lh = queue->next; |
| 2308 | llist_del(lh); |
| 2309 | |
| 2310 | return llist_entry(lh, struct file_list_entry, list); |
| 2311 | } |
| 2312 | |
| 2313 | static int bs11_read_swl_file(struct abis_nm_bs11_sw *bs11_sw) |
| 2314 | { |
| 2315 | char linebuf[255]; |
| 2316 | struct llist_head *lh, *lh2; |
| 2317 | FILE *swl; |
| 2318 | int rc = 0; |
| 2319 | |
| 2320 | swl = fopen(bs11_sw->swl_fname, "r"); |
| 2321 | if (!swl) |
| 2322 | return -ENODEV; |
| 2323 | |
| 2324 | /* zero the stale file list, if any */ |
| 2325 | llist_for_each_safe(lh, lh2, &bs11_sw->file_list) { |
| 2326 | llist_del(lh); |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 2327 | talloc_free(lh); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2328 | } |
| 2329 | |
| 2330 | while (fgets(linebuf, sizeof(linebuf), swl)) { |
| 2331 | char file_id[12+1]; |
| 2332 | char file_version[80+1]; |
| 2333 | struct file_list_entry *fle; |
| 2334 | static char dir[PATH_MAX]; |
| 2335 | |
| 2336 | if (strlen(linebuf) < 4) |
| 2337 | continue; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 2338 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2339 | rc = sscanf(linebuf+4, "%12s:%80s\r\n", file_id, file_version); |
| 2340 | if (rc < 0) { |
| 2341 | perror("ERR parsing SWL file"); |
| 2342 | rc = -EINVAL; |
| 2343 | goto out; |
| 2344 | } |
| 2345 | if (rc < 2) |
| 2346 | continue; |
| 2347 | |
Harald Welte | 470ec29 | 2009-06-26 20:25:23 +0200 | [diff] [blame] | 2348 | fle = talloc_zero(tall_fle_ctx, struct file_list_entry); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2349 | if (!fle) { |
| 2350 | rc = -ENOMEM; |
| 2351 | goto out; |
| 2352 | } |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2353 | |
| 2354 | /* construct new filename */ |
| 2355 | strncpy(dir, bs11_sw->swl_fname, sizeof(dir)); |
| 2356 | strncat(fle->fname, dirname(dir), sizeof(fle->fname) - 1); |
| 2357 | strcat(fle->fname, "/"); |
| 2358 | strncat(fle->fname, file_id, sizeof(fle->fname) - 1 -strlen(fle->fname)); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2359 | |
| 2360 | llist_add_tail(&fle->list, &bs11_sw->file_list); |
| 2361 | } |
| 2362 | |
| 2363 | out: |
| 2364 | fclose(swl); |
| 2365 | return rc; |
| 2366 | } |
| 2367 | |
| 2368 | /* bs11 swload specific callback, passed to abis_nm core swload */ |
| 2369 | static int bs11_swload_cbfn(unsigned int hook, unsigned int event, |
| 2370 | struct msgb *msg, void *data, void *param) |
| 2371 | { |
| 2372 | struct abis_nm_bs11_sw *bs11_sw = data; |
| 2373 | struct file_list_entry *fle; |
| 2374 | int rc = 0; |
| 2375 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2376 | switch (event) { |
| 2377 | case NM_MT_LOAD_END_ACK: |
| 2378 | fle = fl_dequeue(&bs11_sw->file_list); |
| 2379 | if (fle) { |
| 2380 | /* start download the next file of our file list */ |
| 2381 | rc = abis_nm_software_load(bs11_sw->bts, fle->fname, |
| 2382 | bs11_sw->win_size, |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 2383 | bs11_sw->forced, |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2384 | &bs11_swload_cbfn, bs11_sw); |
Harald Welte | ac606dc | 2009-08-06 15:44:18 +0200 | [diff] [blame] | 2385 | talloc_free(fle); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2386 | } else { |
| 2387 | /* activate the SWL */ |
| 2388 | rc = abis_nm_software_activate(bs11_sw->bts, |
| 2389 | bs11_sw->swl_fname, |
| 2390 | bs11_swload_cbfn, |
| 2391 | bs11_sw); |
| 2392 | } |
| 2393 | break; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 2394 | case NM_MT_LOAD_SEG_ACK: |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2395 | case NM_MT_LOAD_END_NACK: |
| 2396 | case NM_MT_LOAD_INIT_ACK: |
| 2397 | case NM_MT_LOAD_INIT_NACK: |
| 2398 | case NM_MT_ACTIVATE_SW_NACK: |
| 2399 | case NM_MT_ACTIVATE_SW_ACK: |
| 2400 | default: |
| 2401 | /* fallthrough to the user callback */ |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 2402 | if (bs11_sw->user_cb) |
| 2403 | rc = bs11_sw->user_cb(hook, event, msg, NULL, NULL); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2404 | break; |
| 2405 | } |
| 2406 | |
| 2407 | return rc; |
| 2408 | } |
| 2409 | |
| 2410 | /* Siemens provides a SWL file that is a mere listing of all the other |
| 2411 | * files that are part of a software release. We need to upload first |
| 2412 | * the list file, and then each file that is listed in the list file */ |
| 2413 | int abis_nm_bs11_load_swl(struct gsm_bts *bts, const char *fname, |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 2414 | u_int8_t win_size, int forced, gsm_cbfn *cbfn) |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2415 | { |
| 2416 | struct abis_nm_bs11_sw *bs11_sw = g_bs11_sw; |
| 2417 | struct file_list_entry *fle; |
| 2418 | int rc = 0; |
| 2419 | |
| 2420 | INIT_LLIST_HEAD(&bs11_sw->file_list); |
| 2421 | bs11_sw->bts = bts; |
| 2422 | bs11_sw->win_size = win_size; |
| 2423 | bs11_sw->user_cb = cbfn; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 2424 | bs11_sw->forced = forced; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2425 | |
| 2426 | strncpy(bs11_sw->swl_fname, fname, sizeof(bs11_sw->swl_fname)); |
| 2427 | rc = bs11_read_swl_file(bs11_sw); |
| 2428 | if (rc < 0) |
| 2429 | return rc; |
| 2430 | |
| 2431 | /* dequeue next item in file list */ |
| 2432 | fle = fl_dequeue(&bs11_sw->file_list); |
| 2433 | if (!fle) |
| 2434 | return -EINVAL; |
| 2435 | |
| 2436 | /* start download the next file of our file list */ |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 2437 | rc = abis_nm_software_load(bts, fle->fname, win_size, forced, |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2438 | bs11_swload_cbfn, bs11_sw); |
Harald Welte | ac606dc | 2009-08-06 15:44:18 +0200 | [diff] [blame] | 2439 | talloc_free(fle); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2440 | return rc; |
| 2441 | } |
| 2442 | |
Harald Welte | 5083b0b | 2009-02-02 19:20:52 +0000 | [diff] [blame] | 2443 | #if 0 |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2444 | static u_int8_t req_attr_btse[] = { |
| 2445 | NM_ATT_ADM_STATE, NM_ATT_BS11_LMT_LOGON_SESSION, |
| 2446 | NM_ATT_BS11_LMT_LOGIN_TIME, NM_ATT_BS11_LMT_USER_ACC_LEV, |
| 2447 | NM_ATT_BS11_LMT_USER_NAME, |
| 2448 | |
| 2449 | 0xaf, NM_ATT_BS11_RX_OFFSET, NM_ATT_BS11_VENDOR_NAME, |
| 2450 | |
| 2451 | NM_ATT_BS11_SW_LOAD_INTENDED, NM_ATT_BS11_SW_LOAD_SAFETY, |
| 2452 | |
| 2453 | NM_ATT_BS11_SW_LOAD_STORED }; |
| 2454 | |
| 2455 | static u_int8_t req_attr_btsm[] = { |
| 2456 | NM_ATT_ABIS_CHANNEL, NM_ATT_TEI, NM_ATT_BS11_ABIS_EXT_TIME, |
| 2457 | NM_ATT_ADM_STATE, NM_ATT_AVAIL_STATUS, 0xce, NM_ATT_FILE_ID, |
| 2458 | NM_ATT_FILE_VERSION, NM_ATT_OPER_STATE, 0xe8, NM_ATT_BS11_ALL_TEST_CATG, |
| 2459 | NM_ATT_SW_DESCR, NM_ATT_GET_ARI }; |
Harald Welte | 5083b0b | 2009-02-02 19:20:52 +0000 | [diff] [blame] | 2460 | #endif |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2461 | |
| 2462 | static u_int8_t req_attr[] = { |
| 2463 | NM_ATT_ADM_STATE, NM_ATT_AVAIL_STATUS, 0xa8, NM_ATT_OPER_STATE, |
| 2464 | 0xd5, 0xa1, NM_ATT_BS11_ESN_FW_CODE_NO, NM_ATT_BS11_ESN_HW_CODE_NO, |
Harald Welte | a7cfa03 | 2009-04-29 22:33:02 +0000 | [diff] [blame] | 2465 | 0x42, NM_ATT_BS11_ESN_PCB_SERIAL, NM_ATT_BS11_PLL }; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 2466 | |
| 2467 | int abis_nm_bs11_get_serno(struct gsm_bts *bts) |
| 2468 | { |
| 2469 | struct abis_om_hdr *oh; |
| 2470 | struct msgb *msg = nm_msgb_alloc(); |
| 2471 | |
| 2472 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2473 | /* SiemensHW CCTRL object */ |
| 2474 | fill_om_fom_hdr(oh, 2+sizeof(req_attr), NM_MT_GET_ATTR, NM_OC_BS11, |
| 2475 | 0x03, 0x00, 0x00); |
| 2476 | msgb_tlv_put(msg, NM_ATT_LIST_REQ_ATTR, sizeof(req_attr), req_attr); |
| 2477 | |
| 2478 | return abis_nm_sendmsg(bts, msg); |
| 2479 | } |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 2480 | |
| 2481 | int abis_nm_bs11_set_ext_time(struct gsm_bts *bts) |
| 2482 | { |
| 2483 | struct abis_om_hdr *oh; |
| 2484 | struct msgb *msg = nm_msgb_alloc(); |
| 2485 | struct bs11_date_time aet; |
| 2486 | |
| 2487 | get_bs11_date_time(&aet); |
| 2488 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2489 | /* SiemensHW CCTRL object */ |
| 2490 | fill_om_fom_hdr(oh, 2+sizeof(aet), NM_MT_BS11_SET_ATTR, NM_OC_SITE_MANAGER, |
| 2491 | 0xff, 0xff, 0xff); |
Harald Welte | 5083b0b | 2009-02-02 19:20:52 +0000 | [diff] [blame] | 2492 | msgb_tlv_put(msg, NM_ATT_BS11_ABIS_EXT_TIME, sizeof(aet), (u_int8_t *) &aet); |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 2493 | |
| 2494 | return abis_nm_sendmsg(bts, msg); |
| 2495 | } |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 2496 | |
Daniel Willmann | 65f68fa | 2009-08-10 11:49:36 +0200 | [diff] [blame] | 2497 | int abis_nm_bs11_set_bport_line_cfg(struct gsm_bts *bts, u_int8_t bport, enum abis_bs11_line_cfg line_cfg) |
| 2498 | { |
| 2499 | struct abis_om_hdr *oh; |
| 2500 | struct msgb *msg = nm_msgb_alloc(); |
| 2501 | struct bs11_date_time aet; |
| 2502 | |
| 2503 | get_bs11_date_time(&aet); |
| 2504 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 2505 | fill_om_fom_hdr(oh, 2, NM_MT_BS11_SET_ATTR, NM_OC_BS11_BPORT, |
| 2506 | bport, 0xff, 0x02); |
| 2507 | msgb_tv_put(msg, NM_ATT_BS11_LINE_CFG, line_cfg); |
| 2508 | |
| 2509 | return abis_nm_sendmsg(bts, msg); |
| 2510 | } |
| 2511 | |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 2512 | /* ip.access nanoBTS specific commands */ |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 2513 | static const char ipaccess_magic[] = "com.ipaccess"; |
| 2514 | |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2515 | |
| 2516 | static int abis_nm_rx_ipacc(struct msgb *msg) |
| 2517 | { |
| 2518 | struct abis_om_hdr *oh = msgb_l2(msg); |
| 2519 | struct abis_om_fom_hdr *foh; |
| 2520 | u_int8_t idstrlen = oh->data[0]; |
| 2521 | struct tlv_parsed tp; |
| 2522 | |
| 2523 | if (strncmp((char *)&oh->data[1], ipaccess_magic, idstrlen)) { |
| 2524 | DEBUGP(DNM, "id string is not com.ipaccess !?!\n"); |
| 2525 | return -EINVAL; |
| 2526 | } |
| 2527 | |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2528 | foh = (struct abis_om_fom_hdr *) (oh->data + 1 + idstrlen); |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 2529 | abis_nm_tlv_parse(&tp, foh->data, oh->length-sizeof(*foh)); |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2530 | |
Harald Welte | a8bd6d4 | 2009-10-20 09:56:18 +0200 | [diff] [blame] | 2531 | debugp_foh(foh); |
Harald Welte | a62202b | 2009-10-19 21:46:54 +0200 | [diff] [blame] | 2532 | |
Harald Welte | 746d609 | 2009-10-19 22:11:11 +0200 | [diff] [blame] | 2533 | DEBUGPC(DNM, "IPACCESS(0x%02x): ", foh->msg_type); |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2534 | |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2535 | switch (foh->msg_type) { |
| 2536 | case NM_MT_IPACC_RSL_CONNECT_ACK: |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2537 | DEBUGPC(DNM, "RSL CONNECT ACK "); |
Harald Welte | 0efe9b7 | 2009-07-12 09:33:54 +0200 | [diff] [blame] | 2538 | if (TLVP_PRESENT(&tp, NM_ATT_IPACC_DST_IP)) |
Harald Welte | 9de2bf8 | 2009-04-30 15:59:55 +0000 | [diff] [blame] | 2539 | DEBUGPC(DNM, "IP=%s ", |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2540 | inet_ntoa(*((struct in_addr *) |
Harald Welte | 0efe9b7 | 2009-07-12 09:33:54 +0200 | [diff] [blame] | 2541 | TLVP_VAL(&tp, NM_ATT_IPACC_DST_IP)))); |
| 2542 | if (TLVP_PRESENT(&tp, NM_ATT_IPACC_DST_IP_PORT)) |
Harald Welte | 9de2bf8 | 2009-04-30 15:59:55 +0000 | [diff] [blame] | 2543 | DEBUGPC(DNM, "PORT=%u ", |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2544 | ntohs(*((u_int16_t *) |
Harald Welte | 0efe9b7 | 2009-07-12 09:33:54 +0200 | [diff] [blame] | 2545 | TLVP_VAL(&tp, NM_ATT_IPACC_DST_IP_PORT)))); |
Harald Welte | 35d447b | 2009-10-19 22:49:33 +0200 | [diff] [blame] | 2546 | if (TLVP_PRESENT(&tp, NM_ATT_IPACC_STREAM_ID)) |
| 2547 | DEBUGPC(DNM, "STREAM=0x%02x ", |
| 2548 | *TLVP_VAL(&tp, NM_ATT_IPACC_STREAM_ID)); |
Harald Welte | 9de2bf8 | 2009-04-30 15:59:55 +0000 | [diff] [blame] | 2549 | DEBUGPC(DNM, "\n"); |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2550 | break; |
| 2551 | case NM_MT_IPACC_RSL_CONNECT_NACK: |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2552 | DEBUGPC(DNM, "RSL CONNECT NACK "); |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2553 | if (TLVP_PRESENT(&tp, NM_ATT_NACK_CAUSES)) |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 2554 | DEBUGPC(DNM, " CAUSE=%s\n", |
| 2555 | nack_cause_name(*TLVP_VAL(&tp, NM_ATT_NACK_CAUSES))); |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2556 | else |
| 2557 | DEBUGPC(DNM, "\n"); |
| 2558 | break; |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2559 | case NM_MT_IPACC_SET_NVATTR_ACK: |
| 2560 | DEBUGPC(DNM, "SET NVATTR ACK\n"); |
| 2561 | /* FIXME: decode and show the actual attributes */ |
| 2562 | break; |
| 2563 | case NM_MT_IPACC_SET_NVATTR_NACK: |
Harald Welte | 6c96ba5 | 2009-05-01 13:03:40 +0000 | [diff] [blame] | 2564 | DEBUGPC(DNM, "SET NVATTR NACK "); |
| 2565 | if (TLVP_PRESENT(&tp, NM_ATT_NACK_CAUSES)) |
| 2566 | DEBUGPC(DNM, " CAUSE=%s\n", |
| 2567 | nack_cause_name(*TLVP_VAL(&tp, NM_ATT_NACK_CAUSES))); |
| 2568 | else |
| 2569 | DEBUGPC(DNM, "\n"); |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2570 | break; |
Harald Welte | 684b1a8 | 2009-07-03 11:26:45 +0200 | [diff] [blame] | 2571 | case NM_MT_IPACC_GET_NVATTR_ACK: |
| 2572 | DEBUGPC(DNM, "GET NVATTR ACK\n"); |
| 2573 | /* FIXME: decode and show the actual attributes */ |
| 2574 | break; |
| 2575 | case NM_MT_IPACC_GET_NVATTR_NACK: |
| 2576 | DEBUGPC(DNM, "GET NVATTR NACK "); |
| 2577 | if (TLVP_PRESENT(&tp, NM_ATT_NACK_CAUSES)) |
| 2578 | DEBUGPC(DNM, " CAUSE=%s\n", |
| 2579 | nack_cause_name(*TLVP_VAL(&tp, NM_ATT_NACK_CAUSES))); |
| 2580 | else |
| 2581 | DEBUGPC(DNM, "\n"); |
| 2582 | break; |
Harald Welte | 15c4417 | 2009-10-08 20:15:24 +0200 | [diff] [blame] | 2583 | case NM_MT_IPACC_SET_ATTR_ACK: |
| 2584 | DEBUGPC(DNM, "SET ATTR ACK\n"); |
| 2585 | break; |
| 2586 | case NM_MT_IPACC_SET_ATTR_NACK: |
| 2587 | DEBUGPC(DNM, "SET ATTR NACK "); |
| 2588 | if (TLVP_PRESENT(&tp, NM_ATT_NACK_CAUSES)) |
| 2589 | DEBUGPC(DNM, " CAUSE=%s\n", |
| 2590 | nack_cause_name(*TLVP_VAL(&tp, NM_ATT_NACK_CAUSES))); |
| 2591 | else |
| 2592 | DEBUGPC(DNM, "\n"); |
| 2593 | break; |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2594 | default: |
| 2595 | DEBUGPC(DNM, "unknown\n"); |
| 2596 | break; |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2597 | } |
Holger Hans Peter Freyther | a7cd9fc | 2009-07-07 12:40:07 +0200 | [diff] [blame] | 2598 | |
| 2599 | /* signal handling */ |
| 2600 | switch (foh->msg_type) { |
| 2601 | case NM_MT_IPACC_RSL_CONNECT_NACK: |
| 2602 | case NM_MT_IPACC_SET_NVATTR_NACK: |
| 2603 | case NM_MT_IPACC_GET_NVATTR_NACK: |
Harald Welte | d8cfc90 | 2009-11-17 06:09:56 +0100 | [diff] [blame] | 2604 | dispatch_signal(SS_NM, S_NM_IPACC_NACK, &foh->msg_type); |
Holger Hans Peter Freyther | a7cd9fc | 2009-07-07 12:40:07 +0200 | [diff] [blame] | 2605 | break; |
| 2606 | default: |
| 2607 | break; |
| 2608 | } |
| 2609 | |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2610 | return 0; |
| 2611 | } |
| 2612 | |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2613 | /* send an ip-access manufacturer specific message */ |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 2614 | int abis_nm_ipaccess_msg(struct gsm_bts *bts, u_int8_t msg_type, |
| 2615 | u_int8_t obj_class, u_int8_t bts_nr, |
| 2616 | u_int8_t trx_nr, u_int8_t ts_nr, |
| 2617 | u_int8_t *attr, int attr_len) |
| 2618 | { |
| 2619 | struct msgb *msg = nm_msgb_alloc(); |
| 2620 | struct abis_om_hdr *oh; |
| 2621 | struct abis_om_fom_hdr *foh; |
| 2622 | u_int8_t *data; |
| 2623 | |
| 2624 | /* construct the 12.21 OM header, observe the erroneous length */ |
| 2625 | oh = (struct abis_om_hdr *) msgb_put(msg, sizeof(*oh)); |
| 2626 | fill_om_hdr(oh, sizeof(*foh) + attr_len); |
| 2627 | oh->mdisc = ABIS_OM_MDISC_MANUF; |
| 2628 | |
| 2629 | /* add the ip.access magic */ |
| 2630 | data = msgb_put(msg, sizeof(ipaccess_magic)+1); |
| 2631 | *data++ = sizeof(ipaccess_magic); |
| 2632 | memcpy(data, ipaccess_magic, sizeof(ipaccess_magic)); |
| 2633 | |
| 2634 | /* fill the 12.21 FOM header */ |
| 2635 | foh = (struct abis_om_fom_hdr *) msgb_put(msg, sizeof(*foh)); |
| 2636 | foh->msg_type = msg_type; |
| 2637 | foh->obj_class = obj_class; |
| 2638 | foh->obj_inst.bts_nr = bts_nr; |
| 2639 | foh->obj_inst.trx_nr = trx_nr; |
| 2640 | foh->obj_inst.ts_nr = ts_nr; |
| 2641 | |
| 2642 | if (attr && attr_len) { |
| 2643 | data = msgb_put(msg, attr_len); |
| 2644 | memcpy(data, attr, attr_len); |
| 2645 | } |
| 2646 | |
| 2647 | return abis_nm_sendmsg(bts, msg); |
| 2648 | } |
Harald Welte | 677c21f | 2009-02-17 13:22:23 +0000 | [diff] [blame] | 2649 | |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2650 | /* set some attributes in NVRAM */ |
| 2651 | int abis_nm_ipaccess_set_nvattr(struct gsm_bts *bts, u_int8_t *attr, |
| 2652 | int attr_len) |
| 2653 | { |
| 2654 | return abis_nm_ipaccess_msg(bts, NM_MT_IPACC_SET_NVATTR, |
| 2655 | NM_OC_BASEB_TRANSC, 0, 0, 0xff, attr, |
| 2656 | attr_len); |
| 2657 | } |
| 2658 | |
Harald Welte | 746d609 | 2009-10-19 22:11:11 +0200 | [diff] [blame] | 2659 | int abis_nm_ipaccess_rsl_connect(struct gsm_bts_trx *trx, |
| 2660 | u_int32_t ip, u_int16_t port, u_int8_t stream) |
| 2661 | { |
| 2662 | struct in_addr ia; |
| 2663 | u_int8_t attr[] = { NM_ATT_IPACC_STREAM_ID, 0, |
| 2664 | NM_ATT_IPACC_DST_IP_PORT, 0, 0, |
| 2665 | NM_ATT_IPACC_DST_IP, 0, 0, 0, 0 }; |
| 2666 | |
| 2667 | int attr_len = sizeof(attr); |
| 2668 | |
| 2669 | ia.s_addr = htonl(ip); |
| 2670 | attr[1] = stream; |
| 2671 | attr[3] = port >> 8; |
| 2672 | attr[4] = port & 0xff; |
| 2673 | *(u_int32_t *)(attr+6) = ia.s_addr; |
| 2674 | |
| 2675 | /* if ip == 0, we use the default IP */ |
| 2676 | if (ip == 0) |
| 2677 | attr_len -= 5; |
| 2678 | |
| 2679 | DEBUGP(DNM, "ip.access RSL CONNECT IP=%s PORT=%u STREAM=0x%02x\n", |
Harald Welte | 31a7490 | 2009-10-19 22:50:30 +0200 | [diff] [blame] | 2680 | inet_ntoa(ia), port, stream); |
Harald Welte | 746d609 | 2009-10-19 22:11:11 +0200 | [diff] [blame] | 2681 | |
| 2682 | return abis_nm_ipaccess_msg(trx->bts, NM_MT_IPACC_RSL_CONNECT, |
| 2683 | NM_OC_BASEB_TRANSC, trx->bts->bts_nr, |
| 2684 | trx->nr, 0xff, attr, attr_len); |
| 2685 | } |
| 2686 | |
Harald Welte | 193fefc | 2009-04-30 15:16:27 +0000 | [diff] [blame] | 2687 | /* restart / reboot an ip.access nanoBTS */ |
| 2688 | int abis_nm_ipaccess_restart(struct gsm_bts *bts) |
| 2689 | { |
| 2690 | return __simple_cmd(bts, NM_MT_IPACC_RESTART); |
| 2691 | } |
Harald Welte | daef521 | 2009-10-24 10:20:41 +0200 | [diff] [blame] | 2692 | |
| 2693 | int abis_nm_ipaccess_set_attr(struct gsm_bts *bts, u_int8_t obj_class, |
| 2694 | u_int8_t bts_nr, u_int8_t trx_nr, u_int8_t ts_nr, |
| 2695 | u_int8_t *attr, u_int8_t attr_len) |
| 2696 | { |
| 2697 | return abis_nm_ipaccess_msg(bts, NM_MT_IPACC_SET_ATTR, |
| 2698 | obj_class, bts_nr, trx_nr, ts_nr, |
| 2699 | attr, attr_len); |
| 2700 | } |
Harald Welte | 0f25585 | 2009-11-12 14:48:42 +0100 | [diff] [blame] | 2701 | |
| 2702 | static const char *ipacc_testres_names[] = { |
| 2703 | [NM_IPACC_TESTRES_SUCCESS] = "SUCCESS", |
| 2704 | [NM_IPACC_TESTRES_TIMEOUT] = "TIMEOUT", |
| 2705 | [NM_IPACC_TESTRES_NO_CHANS] = "NO CHANNELS", |
| 2706 | [NM_IPACC_TESTRES_PARTIAL] = "PARTIAL", |
| 2707 | [NM_IPACC_TESTRES_STOPPED] = "STOPPED", |
| 2708 | }; |
| 2709 | |
| 2710 | const char *ipacc_testres_name(u_int8_t res) |
| 2711 | { |
| 2712 | if (res < ARRAY_SIZE(ipacc_testres_names) && |
| 2713 | ipacc_testres_names[res]) |
| 2714 | return ipacc_testres_names[res]; |
| 2715 | |
| 2716 | return "unknown"; |
| 2717 | } |
| 2718 | |
Harald Welte | b40a38f | 2009-11-13 11:56:05 +0100 | [diff] [blame] | 2719 | void ipac_parse_cgi(struct cell_global_id *cid, const u_int8_t *buf) |
| 2720 | { |
| 2721 | cid->mcc = (buf[0] & 0xf) * 100; |
| 2722 | cid->mcc += (buf[0] >> 4) * 10; |
| 2723 | cid->mcc += (buf[1] & 0xf) * 1; |
| 2724 | |
| 2725 | if (buf[1] >> 4 == 0xf) { |
| 2726 | cid->mnc = (buf[2] & 0xf) * 10; |
| 2727 | cid->mnc += (buf[2] >> 4) * 1; |
| 2728 | } else { |
| 2729 | cid->mnc = (buf[2] & 0xf) * 100; |
| 2730 | cid->mnc += (buf[2] >> 4) * 10; |
| 2731 | cid->mnc += (buf[1] >> 4) * 1; |
| 2732 | } |
| 2733 | |
Harald Welte | aff237d | 2009-11-13 14:41:52 +0100 | [diff] [blame] | 2734 | cid->lac = ntohs(*((u_int16_t *)&buf[3])); |
| 2735 | cid->ci = ntohs(*((u_int16_t *)&buf[5])); |
Harald Welte | b40a38f | 2009-11-13 11:56:05 +0100 | [diff] [blame] | 2736 | } |
| 2737 | |
Harald Welte | 0f25585 | 2009-11-12 14:48:42 +0100 | [diff] [blame] | 2738 | /* parse BCCH information IEI from wire format to struct ipac_bcch_info */ |
| 2739 | int ipac_parse_bcch_info(struct ipac_bcch_info *binf, u_int8_t *buf) |
| 2740 | { |
| 2741 | u_int8_t *cur = buf; |
| 2742 | u_int16_t len; |
| 2743 | |
| 2744 | memset(binf, 0, sizeof(binf)); |
| 2745 | |
| 2746 | if (cur[0] != NM_IPAC_EIE_BCCH_INFO) |
| 2747 | return -EINVAL; |
| 2748 | cur++; |
| 2749 | |
| 2750 | len = ntohs(*(u_int16_t *)cur); |
| 2751 | cur += 2; |
| 2752 | |
| 2753 | binf->info_type = ntohs(*(u_int16_t *)cur); |
| 2754 | cur += 2; |
| 2755 | |
| 2756 | if (binf->info_type & IPAC_BINF_FREQ_ERR_QUAL) |
| 2757 | binf->freq_qual = *cur >> 2; |
| 2758 | |
| 2759 | binf->arfcn = *cur++ & 3 << 8; |
| 2760 | binf->arfcn |= *cur++; |
| 2761 | |
| 2762 | if (binf->info_type & IPAC_BINF_RXLEV) |
| 2763 | binf->rx_lev = *cur & 0x3f; |
| 2764 | cur++; |
| 2765 | |
| 2766 | if (binf->info_type & IPAC_BINF_RXQUAL) |
| 2767 | binf->rx_qual = *cur & 0x7; |
| 2768 | cur++; |
| 2769 | |
| 2770 | if (binf->info_type & IPAC_BINF_FREQ_ERR_QUAL) |
| 2771 | binf->freq_err = ntohs(*(u_int16_t *)cur); |
| 2772 | cur += 2; |
| 2773 | |
| 2774 | if (binf->info_type & IPAC_BINF_FRAME_OFFSET) |
| 2775 | binf->frame_offset = ntohs(*(u_int16_t *)cur); |
| 2776 | cur += 2; |
| 2777 | |
| 2778 | if (binf->info_type & IPAC_BINF_FRAME_NR_OFFSET) |
| 2779 | binf->frame_nr_offset = ntohl(*(u_int32_t *)cur); |
| 2780 | cur += 4; |
| 2781 | |
| 2782 | if (binf->info_type & IPAC_BINF_BSIC) |
Harald Welte | aff237d | 2009-11-13 14:41:52 +0100 | [diff] [blame] | 2783 | binf->bsic = *cur & 0x3f; |
Harald Welte | 0f25585 | 2009-11-12 14:48:42 +0100 | [diff] [blame] | 2784 | cur++; |
| 2785 | |
Harald Welte | b40a38f | 2009-11-13 11:56:05 +0100 | [diff] [blame] | 2786 | ipac_parse_cgi(&binf->cgi, cur); |
| 2787 | cur += 7; |
Harald Welte | 0f25585 | 2009-11-12 14:48:42 +0100 | [diff] [blame] | 2788 | |
| 2789 | if (binf->info_type & IPAC_BINF_NEIGH_BA_SI2) { |
| 2790 | memcpy(binf->ba_list_si2, cur, sizeof(binf->ba_list_si2)); |
| 2791 | cur += sizeof(binf->ba_list_si2); |
| 2792 | } |
| 2793 | |
| 2794 | if (binf->info_type & IPAC_BINF_NEIGH_BA_SI2bis) { |
| 2795 | memcpy(binf->ba_list_si2bis, cur, |
| 2796 | sizeof(binf->ba_list_si2bis)); |
| 2797 | cur += sizeof(binf->ba_list_si2bis); |
| 2798 | } |
| 2799 | |
| 2800 | if (binf->info_type & IPAC_BINF_NEIGH_BA_SI2ter) { |
| 2801 | memcpy(binf->ba_list_si2ter, cur, |
| 2802 | sizeof(binf->ba_list_si2ter)); |
| 2803 | cur += sizeof(binf->ba_list_si2ter); |
| 2804 | } |
| 2805 | |
| 2806 | return 0; |
| 2807 | } |
| 2808 | |
| 2809 | |