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 | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 29 | #include <malloc.h> |
| 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 | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 37 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 38 | #include <openbsc/gsm_data.h> |
| 39 | #include <openbsc/debug.h> |
| 40 | #include <openbsc/msgb.h> |
| 41 | #include <openbsc/tlv.h> |
| 42 | #include <openbsc/abis_nm.h> |
Holger Freyther | ca362a6 | 2009-01-04 21:05:01 +0000 | [diff] [blame] | 43 | #include <openbsc/misdn.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 44 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 45 | #define OM_ALLOC_SIZE 1024 |
| 46 | #define OM_HEADROOM_SIZE 128 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 47 | |
| 48 | /* unidirectional messages from BTS to BSC */ |
| 49 | static const enum abis_nm_msgtype reports[] = { |
| 50 | NM_MT_SW_ACTIVATED_REP, |
| 51 | NM_MT_TEST_REP, |
| 52 | NM_MT_STATECHG_EVENT_REP, |
| 53 | NM_MT_FAILURE_EVENT_REP, |
| 54 | }; |
| 55 | |
| 56 | /* messages without ACK/NACK */ |
| 57 | static const enum abis_nm_msgtype no_ack_nack[] = { |
| 58 | NM_MT_MEAS_RES_REQ, |
| 59 | NM_MT_STOP_MEAS, |
| 60 | NM_MT_START_MEAS, |
| 61 | }; |
| 62 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 63 | /* Messages related to software load */ |
| 64 | static const enum abis_nm_msgtype sw_load_msgs[] = { |
| 65 | NM_MT_LOAD_INIT_ACK, |
| 66 | NM_MT_LOAD_INIT_NACK, |
| 67 | NM_MT_LOAD_SEG_ACK, |
| 68 | NM_MT_LOAD_ABORT, |
| 69 | NM_MT_LOAD_END_ACK, |
| 70 | NM_MT_LOAD_END_NACK, |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 71 | //NM_MT_SW_ACT_REQ, |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 72 | NM_MT_ACTIVATE_SW_ACK, |
| 73 | NM_MT_ACTIVATE_SW_NACK, |
| 74 | NM_MT_SW_ACTIVATED_REP, |
| 75 | }; |
| 76 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 77 | /* Attributes that the BSC can set, not only get, according to Section 9.4 */ |
| 78 | static const enum abis_nm_attr nm_att_settable[] = { |
| 79 | NM_ATT_ADD_INFO, |
| 80 | NM_ATT_ADD_TEXT, |
| 81 | NM_ATT_DEST, |
| 82 | NM_ATT_EVENT_TYPE, |
| 83 | NM_ATT_FILE_DATA, |
| 84 | NM_ATT_GET_ARI, |
| 85 | NM_ATT_HW_CONF_CHG, |
| 86 | NM_ATT_LIST_REQ_ATTR, |
| 87 | NM_ATT_MDROP_LINK, |
| 88 | NM_ATT_MDROP_NEXT, |
| 89 | NM_ATT_NACK_CAUSES, |
| 90 | NM_ATT_OUTST_ALARM, |
| 91 | NM_ATT_PHYS_CONF, |
| 92 | NM_ATT_PROB_CAUSE, |
| 93 | NM_ATT_RAD_SUBC, |
| 94 | NM_ATT_SOURCE, |
| 95 | NM_ATT_SPEC_PROB, |
| 96 | NM_ATT_START_TIME, |
| 97 | NM_ATT_TEST_DUR, |
| 98 | NM_ATT_TEST_NO, |
| 99 | NM_ATT_TEST_REPORT, |
| 100 | NM_ATT_WINDOW_SIZE, |
| 101 | NM_ATT_SEVERITY, |
| 102 | NM_ATT_MEAS_RES, |
| 103 | NM_ATT_MEAS_TYPE, |
| 104 | }; |
| 105 | |
| 106 | static int is_in_arr(enum abis_nm_msgtype mt, const enum abis_nm_msgtype *arr, int size) |
| 107 | { |
| 108 | int i; |
| 109 | |
| 110 | for (i = 0; i < size; i++) { |
| 111 | if (arr[i] == mt) |
| 112 | return 1; |
| 113 | } |
| 114 | |
| 115 | return 0; |
| 116 | } |
| 117 | |
Holger Freyther | ca362a6 | 2009-01-04 21:05:01 +0000 | [diff] [blame] | 118 | #if 0 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 119 | /* is this msgtype the usual ACK/NACK type ? */ |
| 120 | static int is_ack_nack(enum abis_nm_msgtype mt) |
| 121 | { |
| 122 | return !is_in_arr(mt, no_ack_nack, ARRAY_SIZE(no_ack_nack)); |
| 123 | } |
Holger Freyther | ca362a6 | 2009-01-04 21:05:01 +0000 | [diff] [blame] | 124 | #endif |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 125 | |
| 126 | /* is this msgtype a report ? */ |
| 127 | static int is_report(enum abis_nm_msgtype mt) |
| 128 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 129 | return is_in_arr(mt, reports, ARRAY_SIZE(reports)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | #define MT_ACK(x) (x+1) |
| 133 | #define MT_NACK(x) (x+2) |
| 134 | |
| 135 | static void fill_om_hdr(struct abis_om_hdr *oh, u_int8_t len) |
| 136 | { |
| 137 | oh->mdisc = ABIS_OM_MDISC_FOM; |
| 138 | oh->placement = ABIS_OM_PLACEMENT_ONLY; |
| 139 | oh->sequence = 0; |
| 140 | oh->length = len; |
| 141 | } |
| 142 | |
| 143 | static void fill_om_fom_hdr(struct abis_om_hdr *oh, u_int8_t len, |
| 144 | u_int8_t msg_type, u_int8_t obj_class, |
| 145 | u_int8_t bts_nr, u_int8_t trx_nr, u_int8_t ts_nr) |
| 146 | { |
| 147 | struct abis_om_fom_hdr *foh = |
| 148 | (struct abis_om_fom_hdr *) oh->data; |
| 149 | |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 150 | fill_om_hdr(oh, len+sizeof(*foh)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 151 | foh->msg_type = msg_type; |
| 152 | foh->obj_class = obj_class; |
| 153 | foh->obj_inst.bts_nr = bts_nr; |
| 154 | foh->obj_inst.trx_nr = trx_nr; |
| 155 | foh->obj_inst.ts_nr = ts_nr; |
| 156 | } |
| 157 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 158 | static struct msgb *nm_msgb_alloc(void) |
| 159 | { |
| 160 | return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE); |
| 161 | } |
| 162 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 163 | /* Send a OML NM Message from BSC to BTS */ |
| 164 | int abis_nm_sendmsg(struct gsm_bts *bts, struct msgb *msg) |
| 165 | { |
Holger Freyther | 59639e8 | 2009-02-09 23:09:55 +0000 | [diff] [blame] | 166 | msg->trx = bts->c0; |
| 167 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 168 | return _abis_nm_sendmsg(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 171 | static int abis_nm_rcvmsg_sw(struct msgb *mb); |
| 172 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 173 | const char *oc_names[] = { |
| 174 | [NM_OC_SITE_MANAGER] = "SITE MANAGER", |
| 175 | [NM_OC_BTS] = "BTS", |
| 176 | [NM_OC_RADIO_CARRIER] = "RADIO CARRIER", |
| 177 | [NM_OC_BASEB_TRANSC] = "BASEBAND TRANSCEIVER", |
| 178 | [NM_OC_CHANNEL] = "CHANNEL", |
| 179 | }; |
| 180 | |
| 181 | static const char *obj_class_name(u_int8_t oc) |
| 182 | { |
| 183 | if (oc >= ARRAY_SIZE(oc_names)) |
| 184 | return "UNKNOWN"; |
| 185 | return oc_names[oc]; |
| 186 | } |
| 187 | |
| 188 | static const char *opstate_name(u_int8_t os) |
| 189 | { |
| 190 | switch (os) { |
| 191 | case 1: |
| 192 | return "Disabled"; |
| 193 | case 2: |
| 194 | return "Enabled"; |
| 195 | case 0xff: |
| 196 | return "NULL"; |
| 197 | default: |
| 198 | return "RFU"; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 203 | static int abis_nm_rx_statechg_rep(struct msgb *mb) |
| 204 | { |
| 205 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 206 | u_int8_t *data = &foh->data[0]; |
| 207 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 208 | DEBUGP(DNM, "STATE CHG: OC=%s(%02x) INST=(%02x,%02x,%02x) ", |
| 209 | obj_class_name(foh->obj_class), foh->obj_class, |
| 210 | foh->obj_inst.bts_nr, foh->obj_inst.trx_nr, |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 211 | foh->obj_inst.ts_nr); |
| 212 | if (*data++ == NM_ATT_OPER_STATE) |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 213 | DEBUGPC(DNM, "OP_STATE=%s ", opstate_name(*data++)); |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 214 | if (*data++ == NM_ATT_AVAIL_STATUS) { |
| 215 | u_int8_t att_len = *data++; |
| 216 | while (att_len--) |
| 217 | DEBUGPC(DNM, "AVAIL=%02x ", *data++); |
| 218 | } |
| 219 | DEBUGPC(DNM, "\n"); |
| 220 | return 0; |
| 221 | } |
| 222 | |
| 223 | static int abis_nm_rcvmsg_report(struct msgb *mb) |
| 224 | { |
| 225 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 226 | u_int8_t mt = foh->msg_type; |
| 227 | |
| 228 | //nmh->cfg->report_cb(mb, foh); |
| 229 | |
| 230 | switch (mt) { |
| 231 | case NM_MT_STATECHG_EVENT_REP: |
| 232 | return abis_nm_rx_statechg_rep(mb); |
| 233 | break; |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 234 | case NM_MT_SW_ACTIVATED_REP: |
| 235 | DEBUGP(DNM, "Software Activated Report\n"); |
| 236 | break; |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 237 | }; |
| 238 | |
| 239 | DEBUGP(DNM, "reporting NM MT 0x%02x\n", mt); |
| 240 | |
| 241 | return 0; |
| 242 | } |
| 243 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 244 | /* Activate the specified software into the BTS */ |
| 245 | static int ipacc_sw_activate(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i0, u_int8_t i1, |
| 246 | u_int8_t i2, u_int8_t *sw_desc, u_int8_t swdesc_len) |
| 247 | { |
| 248 | struct abis_om_hdr *oh; |
| 249 | struct msgb *msg = nm_msgb_alloc(); |
| 250 | u_int8_t len = swdesc_len; |
| 251 | u_int8_t *trailer; |
| 252 | |
| 253 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 254 | fill_om_fom_hdr(oh, len, NM_MT_ACTIVATE_SW, obj_class, i0, i1, i2); |
| 255 | |
| 256 | trailer = msgb_put(msg, swdesc_len); |
| 257 | memcpy(trailer, sw_desc, swdesc_len); |
| 258 | |
| 259 | return abis_nm_sendmsg(bts, msg); |
| 260 | } |
| 261 | |
| 262 | static int abis_nm_rx_sw_act_req(struct msgb *mb) |
| 263 | { |
| 264 | struct abis_om_hdr *oh = msgb_l2(mb); |
| 265 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 266 | int ret; |
| 267 | |
| 268 | DEBUGP(DNM, "Software Activate Request, ACKing and Activating\n"); |
| 269 | |
| 270 | ret = abis_nm_sw_act_req_ack(mb->trx->bts, foh->obj_class, |
| 271 | foh->obj_inst.bts_nr, |
| 272 | foh->obj_inst.trx_nr, |
| 273 | foh->obj_inst.ts_nr, |
| 274 | foh->data, oh->length-sizeof(*foh)); |
| 275 | |
| 276 | /* FIXME: properly parse attributes */ |
| 277 | return ipacc_sw_activate(mb->trx->bts, foh->obj_class, |
| 278 | foh->obj_inst.bts_nr, |
| 279 | foh->obj_inst.trx_nr, |
| 280 | foh->obj_inst.ts_nr, |
| 281 | foh->data + oh->length-sizeof(*foh)-22, 22); |
| 282 | } |
| 283 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 284 | /* Receive a OML NM Message from BTS */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 285 | static int abis_nm_rcvmsg_fom(struct msgb *mb) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 286 | { |
| 287 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 288 | u_int8_t mt = foh->msg_type; |
| 289 | |
| 290 | /* check for unsolicited message */ |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 291 | if (is_report(mt)) |
| 292 | return abis_nm_rcvmsg_report(mb); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 293 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 294 | if (is_in_arr(mt, sw_load_msgs, ARRAY_SIZE(sw_load_msgs))) |
| 295 | return abis_nm_rcvmsg_sw(mb); |
| 296 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 297 | #if 0 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 298 | /* check if last message is to be acked */ |
| 299 | if (is_ack_nack(nmh->last_msgtype)) { |
| 300 | if (mt == MT_ACK(nmh->last_msgtype)) { |
| 301 | fprintf(stderr, "received ACK (0x%x)\n", |
| 302 | foh->msg_type); |
| 303 | /* we got our ACK, continue sending the next msg */ |
| 304 | } else if (mt == MT_NACK(nmh->last_msgtype)) { |
| 305 | /* we got a NACK, signal this to the caller */ |
| 306 | fprintf(stderr, "received NACK (0x%x)\n", |
| 307 | foh->msg_type); |
| 308 | /* FIXME: somehow signal this to the caller */ |
| 309 | } else { |
| 310 | /* really strange things happen */ |
| 311 | return -EINVAL; |
| 312 | } |
| 313 | } |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 314 | #endif |
| 315 | |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 316 | switch (mt) { |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 317 | case NM_MT_SW_ACT_REQ: |
| 318 | return abis_nm_rx_sw_act_req(mb); |
| 319 | break; |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 320 | case NM_MT_BS11_LMT_SESSION: |
| 321 | DEBUGP(DNM, "LMT Event: \n"); |
| 322 | break; |
| 323 | } |
| 324 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 325 | return 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | /* High-Level API */ |
| 329 | /* Entry-point where L2 OML from BTS enters the NM code */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 330 | int abis_nm_rcvmsg(struct msgb *msg) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 331 | { |
| 332 | int rc; |
| 333 | struct abis_om_hdr *oh = msgb_l2(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 334 | |
| 335 | /* Various consistency checks */ |
| 336 | if (oh->placement != ABIS_OM_PLACEMENT_ONLY) { |
| 337 | fprintf(stderr, "ABIS OML placement 0x%x not supported\n", |
| 338 | oh->placement); |
| 339 | return -EINVAL; |
| 340 | } |
| 341 | if (oh->sequence != 0) { |
| 342 | fprintf(stderr, "ABIS OML sequence 0x%x != 0x00\n", |
| 343 | oh->sequence); |
| 344 | return -EINVAL; |
| 345 | } |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 346 | #if 0 |
Holger Freyther | ca362a6 | 2009-01-04 21:05:01 +0000 | [diff] [blame] | 347 | unsigned int l2_len = msg->tail - (u_int8_t *)msgb_l2(msg); |
| 348 | unsigned int hlen = sizeof(*oh) + sizeof(struct abis_om_fom_hdr); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 349 | if (oh->length + hlen > l2_len) { |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 350 | fprintf(stderr, "ABIS OML truncated message (%u > %u)\n", |
| 351 | oh->length + sizeof(*oh), l2_len); |
| 352 | return -EINVAL; |
| 353 | } |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 354 | if (oh->length + hlen < l2_len) |
| 355 | fprintf(stderr, "ABIS OML message with extra trailer?!? (oh->len=%d, sizeof_oh=%d l2_len=%d\n", oh->length, sizeof(*oh), l2_len); |
| 356 | #endif |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 357 | msg->l3h = (unsigned char *)oh + sizeof(*oh); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 358 | |
| 359 | switch (oh->mdisc) { |
| 360 | case ABIS_OM_MDISC_FOM: |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 361 | rc = abis_nm_rcvmsg_fom(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 362 | break; |
| 363 | case ABIS_OM_MDISC_MMI: |
| 364 | case ABIS_OM_MDISC_TRAU: |
| 365 | case ABIS_OM_MDISC_MANUF: |
| 366 | default: |
| 367 | fprintf(stderr, "unknown ABIS OML message discriminator 0x%x\n", |
| 368 | oh->mdisc); |
| 369 | return -EINVAL; |
| 370 | } |
| 371 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 372 | msgb_free(msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 373 | return rc; |
| 374 | } |
| 375 | |
| 376 | #if 0 |
| 377 | /* initialized all resources */ |
| 378 | struct abis_nm_h *abis_nm_init(struct abis_nm_cfg *cfg) |
| 379 | { |
| 380 | struct abis_nm_h *nmh; |
| 381 | |
| 382 | nmh = malloc(sizeof(*nmh)); |
| 383 | if (!nmh) |
| 384 | return NULL; |
| 385 | |
| 386 | nmh->cfg = cfg; |
| 387 | |
| 388 | return nmh; |
| 389 | } |
| 390 | |
| 391 | /* free all resources */ |
| 392 | void abis_nm_fini(struct abis_nm_h *nmh) |
| 393 | { |
| 394 | free(nmh); |
| 395 | } |
| 396 | #endif |
| 397 | |
| 398 | /* Here we are trying to define a high-level API that can be used by |
| 399 | * the actual BSC implementation. However, the architecture is currently |
| 400 | * still under design. Ideally the calls to this API would be synchronous, |
| 401 | * while the underlying stack behind the APi runs in a traditional select |
| 402 | * based state machine. |
| 403 | */ |
| 404 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 405 | /* 6.2 Software Load: */ |
| 406 | enum sw_state { |
| 407 | SW_STATE_NONE, |
| 408 | SW_STATE_WAIT_INITACK, |
| 409 | SW_STATE_WAIT_SEGACK, |
| 410 | SW_STATE_WAIT_ENDACK, |
| 411 | SW_STATE_WAIT_ACTACK, |
| 412 | SW_STATE_ERROR, |
| 413 | }; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 414 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 415 | struct abis_nm_sw { |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 416 | struct gsm_bts *bts; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 417 | gsm_cbfn *cbfn; |
| 418 | void *cb_data; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 419 | int forced; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 420 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 421 | /* this will become part of the SW LOAD INITIATE */ |
| 422 | u_int8_t obj_class; |
| 423 | u_int8_t obj_instance[3]; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 424 | |
| 425 | u_int8_t file_id[255]; |
| 426 | u_int8_t file_id_len; |
| 427 | |
| 428 | u_int8_t file_version[255]; |
| 429 | u_int8_t file_version_len; |
| 430 | |
| 431 | u_int8_t window_size; |
| 432 | u_int8_t seg_in_window; |
| 433 | |
| 434 | int fd; |
| 435 | FILE *stream; |
| 436 | enum sw_state state; |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 437 | int last_seg; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 438 | }; |
| 439 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 440 | static struct abis_nm_sw g_sw; |
| 441 | |
| 442 | /* 6.2.1 / 8.3.1: Load Data Initiate */ |
| 443 | static int sw_load_init(struct abis_nm_sw *sw) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 444 | { |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 445 | struct abis_om_hdr *oh; |
| 446 | struct msgb *msg = nm_msgb_alloc(); |
| 447 | u_int8_t len = 3*2 + sw->file_id_len + sw->file_version_len; |
| 448 | |
| 449 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 450 | fill_om_fom_hdr(oh, len, NM_MT_LOAD_INIT, sw->obj_class, |
| 451 | sw->obj_instance[0], sw->obj_instance[1], |
| 452 | sw->obj_instance[2]); |
| 453 | |
| 454 | /* FIXME: this is BS11 specific format */ |
| 455 | msgb_tlv_put(msg, NM_ATT_FILE_ID, sw->file_id_len, sw->file_id); |
| 456 | msgb_tlv_put(msg, NM_ATT_FILE_VERSION, sw->file_version_len, |
| 457 | sw->file_version); |
| 458 | msgb_tv_put(msg, NM_ATT_WINDOW_SIZE, sw->window_size); |
| 459 | |
| 460 | return abis_nm_sendmsg(sw->bts, msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 461 | } |
| 462 | |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 463 | static int is_last_line(FILE *stream) |
| 464 | { |
| 465 | char next_seg_buf[256]; |
| 466 | long pos; |
| 467 | |
| 468 | /* check if we're sending the last line */ |
| 469 | pos = ftell(stream); |
| 470 | if (!fgets(next_seg_buf, sizeof(next_seg_buf)-2, stream)) { |
| 471 | fseek(stream, pos, SEEK_SET); |
| 472 | return 1; |
| 473 | } |
| 474 | |
| 475 | fseek(stream, pos, SEEK_SET); |
| 476 | return 0; |
| 477 | } |
| 478 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 479 | /* 6.2.2 / 8.3.2 Load Data Segment */ |
| 480 | static int sw_load_segment(struct abis_nm_sw *sw) |
| 481 | { |
| 482 | struct abis_om_hdr *oh; |
| 483 | struct msgb *msg = nm_msgb_alloc(); |
| 484 | char seg_buf[256]; |
| 485 | char *line_buf = seg_buf+2; |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 486 | unsigned char *tlv; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 487 | u_int8_t len; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 488 | |
| 489 | 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] | 490 | |
| 491 | switch (sw->bts->type) { |
| 492 | case GSM_BTS_TYPE_BS11: |
| 493 | if (fgets(line_buf, sizeof(seg_buf)-2, sw->stream) == NULL) { |
| 494 | perror("fgets reading segment"); |
| 495 | return -EINVAL; |
| 496 | } |
| 497 | seg_buf[0] = 0x00; |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 498 | |
| 499 | /* check if we're sending the last line */ |
| 500 | sw->last_seg = is_last_line(sw->stream); |
| 501 | if (sw->last_seg) |
| 502 | seg_buf[1] = 0; |
| 503 | else |
| 504 | seg_buf[1] = 1 + sw->seg_in_window++; |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 505 | |
| 506 | len = strlen(line_buf) + 2; |
| 507 | tlv = msgb_put(msg, TLV_GROSS_LEN(len)); |
| 508 | tlv_put(tlv, NM_ATT_BS11_FILE_DATA, len, (u_int8_t *)seg_buf); |
| 509 | /* BS11 wants CR + LF in excess of the TLV length !?! */ |
| 510 | tlv[1] -= 2; |
| 511 | |
| 512 | /* we only now know the exact length for the OM hdr */ |
| 513 | len = strlen(line_buf)+2; |
| 514 | break; |
| 515 | default: |
| 516 | /* FIXME: Other BTS types */ |
| 517 | return -1; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 518 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 519 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 520 | fill_om_fom_hdr(oh, len, NM_MT_LOAD_SEG, sw->obj_class, |
| 521 | sw->obj_instance[0], sw->obj_instance[1], |
| 522 | sw->obj_instance[2]); |
| 523 | |
| 524 | return abis_nm_sendmsg(sw->bts, msg); |
| 525 | } |
| 526 | |
| 527 | /* 6.2.4 / 8.3.4 Load Data End */ |
| 528 | static int sw_load_end(struct abis_nm_sw *sw) |
| 529 | { |
| 530 | struct abis_om_hdr *oh; |
| 531 | struct msgb *msg = nm_msgb_alloc(); |
| 532 | u_int8_t len = 2*2 + sw->file_id_len + sw->file_version_len; |
| 533 | |
| 534 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 535 | fill_om_fom_hdr(oh, len, NM_MT_LOAD_END, sw->obj_class, |
| 536 | sw->obj_instance[0], sw->obj_instance[1], |
| 537 | sw->obj_instance[2]); |
| 538 | |
| 539 | /* FIXME: this is BS11 specific format */ |
| 540 | msgb_tlv_put(msg, NM_ATT_FILE_ID, sw->file_id_len, sw->file_id); |
| 541 | msgb_tlv_put(msg, NM_ATT_FILE_VERSION, sw->file_version_len, |
| 542 | sw->file_version); |
| 543 | |
| 544 | return abis_nm_sendmsg(sw->bts, msg); |
| 545 | } |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 546 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 547 | /* Activate the specified software into the BTS */ |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 548 | static int sw_activate(struct abis_nm_sw *sw) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 549 | { |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 550 | struct abis_om_hdr *oh; |
| 551 | struct msgb *msg = nm_msgb_alloc(); |
| 552 | 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] | 553 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 554 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 555 | fill_om_fom_hdr(oh, len, NM_MT_ACTIVATE_SW, sw->obj_class, |
| 556 | sw->obj_instance[0], sw->obj_instance[1], |
| 557 | sw->obj_instance[2]); |
| 558 | |
| 559 | /* FIXME: this is BS11 specific format */ |
| 560 | msgb_tlv_put(msg, NM_ATT_FILE_ID, sw->file_id_len, sw->file_id); |
| 561 | msgb_tlv_put(msg, NM_ATT_FILE_VERSION, sw->file_version_len, |
| 562 | sw->file_version); |
| 563 | |
| 564 | return abis_nm_sendmsg(sw->bts, msg); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 565 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 566 | |
| 567 | static int sw_open_file(struct abis_nm_sw *sw, const char *fname) |
| 568 | { |
| 569 | char file_id[12+1]; |
| 570 | char file_version[80+1]; |
| 571 | int rc; |
| 572 | |
| 573 | sw->fd = open(fname, O_RDONLY); |
| 574 | if (sw->fd < 0) |
| 575 | return sw->fd; |
| 576 | |
| 577 | switch (sw->bts->type) { |
| 578 | case GSM_BTS_TYPE_BS11: |
| 579 | sw->stream = fdopen(sw->fd, "r"); |
| 580 | if (!sw->stream) { |
| 581 | perror("fdopen"); |
| 582 | return -1; |
| 583 | } |
| 584 | /* read first line and parse file ID and VERSION */ |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 585 | rc = fscanf(sw->stream, "@(#)%12s:%80s\r\n", |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 586 | file_id, file_version); |
| 587 | if (rc != 2) { |
| 588 | perror("parsing header line of software file"); |
| 589 | return -1; |
| 590 | } |
| 591 | strcpy((char *)sw->file_id, file_id); |
| 592 | sw->file_id_len = strlen(file_id); |
| 593 | strcpy((char *)sw->file_version, file_version); |
| 594 | sw->file_version_len = strlen(file_version); |
| 595 | /* rewind to start of file */ |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 596 | rewind(sw->stream); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 597 | break; |
| 598 | default: |
| 599 | /* We don't know how to treat them yet */ |
| 600 | close(sw->fd); |
| 601 | return -EINVAL; |
| 602 | } |
| 603 | |
| 604 | return 0; |
| 605 | } |
| 606 | |
| 607 | static void sw_close_file(struct abis_nm_sw *sw) |
| 608 | { |
| 609 | switch (sw->bts->type) { |
| 610 | case GSM_BTS_TYPE_BS11: |
| 611 | fclose(sw->stream); |
| 612 | break; |
| 613 | default: |
| 614 | close(sw->fd); |
| 615 | break; |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | /* Fill the window */ |
| 620 | static int sw_fill_window(struct abis_nm_sw *sw) |
| 621 | { |
| 622 | int rc; |
| 623 | |
| 624 | while (sw->seg_in_window < sw->window_size) { |
| 625 | rc = sw_load_segment(sw); |
| 626 | if (rc < 0) |
| 627 | return rc; |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 628 | if (sw->last_seg) |
| 629 | break; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 630 | } |
| 631 | return 0; |
| 632 | } |
| 633 | |
| 634 | /* callback function from abis_nm_rcvmsg() handler */ |
| 635 | static int abis_nm_rcvmsg_sw(struct msgb *mb) |
| 636 | { |
| 637 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 638 | int rc = -1; |
| 639 | struct abis_nm_sw *sw = &g_sw; |
| 640 | enum sw_state old_state = sw->state; |
| 641 | |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 642 | //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] | 643 | |
| 644 | switch (sw->state) { |
| 645 | case SW_STATE_WAIT_INITACK: |
| 646 | switch (foh->msg_type) { |
| 647 | case NM_MT_LOAD_INIT_ACK: |
| 648 | /* fill window with segments */ |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 649 | if (sw->cbfn) |
| 650 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 651 | NM_MT_LOAD_INIT_ACK, mb, |
| 652 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 653 | rc = sw_fill_window(sw); |
| 654 | sw->state = SW_STATE_WAIT_SEGACK; |
| 655 | break; |
| 656 | case NM_MT_LOAD_INIT_NACK: |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 657 | if (sw->forced) { |
| 658 | DEBUGP(DNM, "FORCED: Ignoring Software Load " |
| 659 | "Init NACK\n"); |
| 660 | if (sw->cbfn) |
| 661 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 662 | NM_MT_LOAD_INIT_ACK, mb, |
| 663 | sw->cb_data, NULL); |
| 664 | rc = sw_fill_window(sw); |
| 665 | sw->state = SW_STATE_WAIT_SEGACK; |
| 666 | } else { |
| 667 | DEBUGP(DNM, "Software Load Init NACK\n"); |
| 668 | if (sw->cbfn) |
| 669 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 670 | NM_MT_LOAD_INIT_NACK, mb, |
| 671 | sw->cb_data, NULL); |
| 672 | sw->state = SW_STATE_ERROR; |
| 673 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 674 | break; |
| 675 | } |
| 676 | break; |
| 677 | case SW_STATE_WAIT_SEGACK: |
| 678 | switch (foh->msg_type) { |
| 679 | case NM_MT_LOAD_SEG_ACK: |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 680 | if (sw->cbfn) |
| 681 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 682 | NM_MT_LOAD_SEG_ACK, mb, |
| 683 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 684 | sw->seg_in_window = 0; |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 685 | if (!sw->last_seg) { |
| 686 | /* fill window with more segments */ |
| 687 | rc = sw_fill_window(sw); |
| 688 | sw->state = SW_STATE_WAIT_SEGACK; |
| 689 | } else { |
| 690 | /* end the transfer */ |
| 691 | sw->state = SW_STATE_WAIT_ENDACK; |
| 692 | rc = sw_load_end(sw); |
| 693 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 694 | break; |
| 695 | } |
| 696 | break; |
| 697 | case SW_STATE_WAIT_ENDACK: |
| 698 | switch (foh->msg_type) { |
| 699 | case NM_MT_LOAD_END_ACK: |
| 700 | sw_close_file(sw); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 701 | DEBUGP(DNM, "Software Load End (BTS %u)\n", |
| 702 | sw->bts->nr); |
| 703 | sw->state = SW_STATE_NONE; |
| 704 | if (sw->cbfn) |
| 705 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 706 | NM_MT_LOAD_END_ACK, mb, |
| 707 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 708 | break; |
| 709 | case NM_MT_LOAD_END_NACK: |
Holger Freyther | 31338a1 | 2009-02-06 17:43:50 +0000 | [diff] [blame] | 710 | if (sw->forced) { |
| 711 | DEBUGP(DNM, "FORCED: Ignoring Software Load" |
| 712 | "End NACK\n"); |
| 713 | sw->state = SW_STATE_NONE; |
| 714 | if (sw->cbfn) |
| 715 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 716 | NM_MT_LOAD_END_ACK, mb, |
| 717 | sw->cb_data, NULL); |
| 718 | } else { |
| 719 | DEBUGP(DNM, "Software Load End NACK\n"); |
| 720 | sw->state = SW_STATE_ERROR; |
| 721 | if (sw->cbfn) |
| 722 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 723 | NM_MT_LOAD_END_NACK, mb, |
| 724 | sw->cb_data, NULL); |
| 725 | } |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 726 | break; |
| 727 | } |
| 728 | case SW_STATE_WAIT_ACTACK: |
| 729 | switch (foh->msg_type) { |
| 730 | case NM_MT_ACTIVATE_SW_ACK: |
| 731 | /* we're done */ |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 732 | DEBUGP(DNM, "Activate Software DONE!\n"); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 733 | sw->state = SW_STATE_NONE; |
| 734 | rc = 0; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 735 | if (sw->cbfn) |
| 736 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 737 | NM_MT_ACTIVATE_SW_ACK, mb, |
| 738 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 739 | break; |
| 740 | case NM_MT_ACTIVATE_SW_NACK: |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 741 | DEBUGP(DNM, "Activate Software NACK\n"); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 742 | sw->state = SW_STATE_ERROR; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 743 | if (sw->cbfn) |
| 744 | sw->cbfn(GSM_HOOK_NM_SWLOAD, |
| 745 | NM_MT_ACTIVATE_SW_NACK, mb, |
| 746 | sw->cb_data, NULL); |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 747 | break; |
| 748 | } |
| 749 | case SW_STATE_NONE: |
| 750 | case SW_STATE_ERROR: |
| 751 | break; |
| 752 | } |
| 753 | |
| 754 | if (rc) |
| 755 | fprintf(stderr, "unexpected NM MT 0x%02x in state %u -> %u\n", |
| 756 | foh->msg_type, old_state, sw->state); |
| 757 | |
| 758 | return rc; |
| 759 | } |
| 760 | |
| 761 | /* Load the specified software into the BTS */ |
| 762 | int abis_nm_software_load(struct gsm_bts *bts, const char *fname, |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 763 | u_int8_t win_size, int forced, |
| 764 | gsm_cbfn *cbfn, void *cb_data) |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 765 | { |
| 766 | struct abis_nm_sw *sw = &g_sw; |
| 767 | int rc; |
| 768 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 769 | DEBUGP(DNM, "Software Load (BTS %u, File \"%s\")\n", |
| 770 | bts->nr, fname); |
| 771 | |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 772 | if (sw->state != SW_STATE_NONE) |
| 773 | return -EBUSY; |
| 774 | |
| 775 | sw->bts = bts; |
| 776 | sw->obj_class = NM_OC_SITE_MANAGER; |
| 777 | sw->obj_instance[0] = 0xff; |
| 778 | sw->obj_instance[1] = 0xff; |
| 779 | sw->obj_instance[2] = 0xff; |
| 780 | sw->window_size = win_size; |
| 781 | sw->state = SW_STATE_WAIT_INITACK; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 782 | sw->cbfn = cbfn; |
| 783 | sw->cb_data = cb_data; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 784 | sw->forced = forced; |
Harald Welte | 4724f99 | 2009-01-18 18:01:49 +0000 | [diff] [blame] | 785 | |
| 786 | rc = sw_open_file(sw, fname); |
| 787 | if (rc < 0) { |
| 788 | sw->state = SW_STATE_NONE; |
| 789 | return rc; |
| 790 | } |
| 791 | |
| 792 | return sw_load_init(sw); |
| 793 | } |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 794 | |
Harald Welte | 1602ade | 2009-01-29 21:12:39 +0000 | [diff] [blame] | 795 | int abis_nm_software_load_status(struct gsm_bts *bts) |
| 796 | { |
| 797 | struct abis_nm_sw *sw = &g_sw; |
| 798 | struct stat st; |
| 799 | int rc, percent; |
| 800 | |
| 801 | rc = fstat(sw->fd, &st); |
| 802 | if (rc < 0) { |
| 803 | perror("ERROR during stat"); |
| 804 | return rc; |
| 805 | } |
| 806 | |
| 807 | percent = (ftell(sw->stream) * 100) / st.st_size; |
| 808 | return percent; |
| 809 | } |
| 810 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 811 | /* Activate the specified software into the BTS */ |
| 812 | int abis_nm_software_activate(struct gsm_bts *bts, const char *fname, |
| 813 | gsm_cbfn *cbfn, void *cb_data) |
| 814 | { |
| 815 | struct abis_nm_sw *sw = &g_sw; |
| 816 | int rc; |
| 817 | |
| 818 | DEBUGP(DNM, "Activating Software (BTS %u, File \"%s\")\n", |
| 819 | bts->nr, fname); |
| 820 | |
| 821 | if (sw->state != SW_STATE_NONE) |
| 822 | return -EBUSY; |
| 823 | |
| 824 | sw->bts = bts; |
| 825 | sw->obj_class = NM_OC_SITE_MANAGER; |
| 826 | sw->obj_instance[0] = 0xff; |
| 827 | sw->obj_instance[1] = 0xff; |
| 828 | sw->obj_instance[2] = 0xff; |
| 829 | sw->state = SW_STATE_WAIT_ACTACK; |
| 830 | sw->cbfn = cbfn; |
| 831 | sw->cb_data = cb_data; |
| 832 | |
| 833 | /* Open the file in order to fill some sw struct members */ |
| 834 | rc = sw_open_file(sw, fname); |
| 835 | if (rc < 0) { |
| 836 | sw->state = SW_STATE_NONE; |
| 837 | return rc; |
| 838 | } |
| 839 | sw_close_file(sw); |
| 840 | |
| 841 | return sw_activate(sw); |
| 842 | } |
| 843 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 844 | 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] | 845 | u_int8_t ts_nr, u_int8_t subslot_nr) |
| 846 | { |
Harald Welte | adaf08b | 2009-01-18 11:08:10 +0000 | [diff] [blame] | 847 | ch->attrib = NM_ATT_ABIS_CHANNEL; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 848 | ch->bts_port = bts_port; |
| 849 | ch->timeslot = ts_nr; |
| 850 | ch->subslot = subslot_nr; |
| 851 | } |
| 852 | |
| 853 | int abis_nm_establish_tei(struct gsm_bts *bts, u_int8_t trx_nr, |
| 854 | u_int8_t e1_port, u_int8_t e1_timeslot, u_int8_t e1_subslot, |
| 855 | u_int8_t tei) |
| 856 | { |
| 857 | struct abis_om_hdr *oh; |
| 858 | struct abis_nm_channel *ch; |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 859 | u_int8_t len = sizeof(*ch) + 2; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 860 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 861 | |
| 862 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 863 | fill_om_fom_hdr(oh, len, NM_MT_ESTABLISH_TEI, NM_OC_RADIO_CARRIER, |
| 864 | bts->bts_nr, trx_nr, 0xff); |
| 865 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 866 | msgb_tv_put(msg, NM_ATT_TEI, tei); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 867 | |
| 868 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 869 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 870 | |
| 871 | return abis_nm_sendmsg(bts, msg); |
| 872 | } |
| 873 | |
| 874 | /* connect signalling of one (BTS,TRX) to a particular timeslot on the E1 */ |
| 875 | int abis_nm_conn_terr_sign(struct gsm_bts_trx *trx, |
| 876 | u_int8_t e1_port, u_int8_t e1_timeslot, u_int8_t e1_subslot) |
| 877 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 878 | struct gsm_bts *bts = trx->bts; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 879 | struct abis_om_hdr *oh; |
| 880 | struct abis_nm_channel *ch; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 881 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 882 | |
| 883 | 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] | 884 | fill_om_fom_hdr(oh, sizeof(*ch), NM_MT_CONN_TERR_SIGN, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 885 | NM_OC_RADIO_CARRIER, bts->bts_nr, trx->nr, 0xff); |
| 886 | |
| 887 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 888 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 889 | |
| 890 | return abis_nm_sendmsg(bts, msg); |
| 891 | } |
| 892 | |
| 893 | #if 0 |
| 894 | int abis_nm_disc_terr_sign(struct abis_nm_h *h, struct abis_om_obj_inst *inst, |
| 895 | struct abis_nm_abis_channel *chan) |
| 896 | { |
| 897 | } |
| 898 | #endif |
| 899 | |
| 900 | int abis_nm_conn_terr_traf(struct gsm_bts_trx_ts *ts, |
| 901 | u_int8_t e1_port, u_int8_t e1_timeslot, |
| 902 | u_int8_t e1_subslot) |
| 903 | { |
| 904 | struct gsm_bts *bts = ts->trx->bts; |
| 905 | struct abis_om_hdr *oh; |
| 906 | struct abis_nm_channel *ch; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 907 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 908 | |
| 909 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 910 | fill_om_fom_hdr(oh, sizeof(*ch), NM_MT_CONN_TERR_TRAF, |
| 911 | NM_OC_BASEB_TRANSC, bts->bts_nr, ts->trx->nr, ts->nr); |
| 912 | |
| 913 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 914 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 915 | |
| 916 | return abis_nm_sendmsg(bts, msg); |
| 917 | } |
| 918 | |
| 919 | #if 0 |
| 920 | int abis_nm_disc_terr_traf(struct abis_nm_h *h, struct abis_om_obj_inst *inst, |
| 921 | struct abis_nm_abis_channel *chan, |
| 922 | u_int8_t subchan) |
| 923 | { |
| 924 | } |
| 925 | #endif |
| 926 | |
| 927 | int abis_nm_set_channel_attr(struct gsm_bts_trx_ts *ts, u_int8_t chan_comb) |
| 928 | { |
| 929 | struct gsm_bts *bts = ts->trx->bts; |
| 930 | struct abis_om_hdr *oh; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 931 | u_int16_t arfcn = htons(ts->trx->arfcn); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 932 | u_int8_t zero = 0x00; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 933 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 934 | u_int8_t len = 4 + 2 + 2 + 2 + 2 +3; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 935 | |
| 936 | 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] | 937 | fill_om_fom_hdr(oh, len, NM_MT_SET_CHAN_ATTR, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 938 | NM_OC_BASEB_TRANSC, bts->bts_nr, |
| 939 | ts->trx->nr, ts->nr); |
| 940 | /* FIXME: don't send ARFCN list, hopping sequence, mAIO, ...*/ |
| 941 | msgb_tlv16_put(msg, NM_ATT_ARFCN_LIST, 1, &arfcn); |
| 942 | msgb_tv_put(msg, NM_ATT_CHAN_COMB, chan_comb); |
| 943 | msgb_tv_put(msg, NM_ATT_HSN, 0x00); |
| 944 | msgb_tv_put(msg, NM_ATT_MAIO, 0x00); |
| 945 | msgb_tv_put(msg, NM_ATT_TSC, 0x07); /* training sequence */ |
| 946 | msgb_tlv_put(msg, 0x59, 1, &zero); |
| 947 | |
| 948 | return abis_nm_sendmsg(bts, msg); |
| 949 | } |
| 950 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 951 | int abis_nm_sw_act_req_ack(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i1, |
| 952 | u_int8_t i2, u_int8_t i3, u_int8_t *attr, int att_len) |
| 953 | { |
| 954 | struct abis_om_hdr *oh; |
| 955 | struct msgb *msg = nm_msgb_alloc(); |
| 956 | |
| 957 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 958 | fill_om_fom_hdr(oh, att_len, NM_MT_SW_ACT_REQ_ACK, obj_class, i1, i2, i3); |
| 959 | /* FIXME: don't send ARFCN list, hopping sequence, mAIO, ...*/ |
| 960 | if (attr) { |
| 961 | u_int8_t *ptr = msgb_put(msg, att_len); |
| 962 | memcpy(ptr, attr, att_len); |
| 963 | } |
| 964 | |
| 965 | return abis_nm_sendmsg(bts, msg); |
| 966 | } |
| 967 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 968 | 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] | 969 | { |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 970 | struct msgb *msg = nm_msgb_alloc(); |
| 971 | struct abis_om_hdr *oh; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 972 | u_int8_t *data; |
| 973 | |
| 974 | oh = (struct abis_om_hdr *) msgb_put(msg, sizeof(*oh)); |
| 975 | fill_om_hdr(oh, len); |
| 976 | data = msgb_put(msg, len); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 977 | memcpy(data, rawmsg, len); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 978 | |
| 979 | return abis_nm_sendmsg(bts, msg); |
| 980 | } |
| 981 | |
| 982 | /* Siemens specific commands */ |
| 983 | static int __simple_cmd(struct gsm_bts *bts, u_int8_t msg_type) |
| 984 | { |
| 985 | struct abis_om_hdr *oh; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 986 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 987 | |
| 988 | 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] | 989 | fill_om_fom_hdr(oh, 0, msg_type, NM_OC_SITE_MANAGER, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 990 | 0xff, 0xff, 0xff); |
| 991 | |
| 992 | return abis_nm_sendmsg(bts, msg); |
| 993 | } |
| 994 | |
Harald Welte | 34a9968 | 2009-02-13 02:41:40 +0000 | [diff] [blame^] | 995 | /* Chapter 8.9.2 */ |
| 996 | 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) |
| 997 | { |
| 998 | struct abis_om_hdr *oh; |
| 999 | struct msgb *msg = nm_msgb_alloc(); |
| 1000 | |
| 1001 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1002 | fill_om_fom_hdr(oh, 0, NM_MT_OPSTART, obj_class, i0, i1, i2); |
| 1003 | |
| 1004 | return abis_nm_sendmsg(bts, msg); |
| 1005 | } |
| 1006 | |
| 1007 | /* Chapter 8.8.5 */ |
| 1008 | int abis_nm_chg_adm_state(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i0, |
| 1009 | u_int8_t i1, u_int8_t i2, u_int8_t adm_state) |
| 1010 | { |
| 1011 | struct abis_om_hdr *oh; |
| 1012 | struct msgb *msg = nm_msgb_alloc(); |
| 1013 | |
| 1014 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1015 | fill_om_fom_hdr(oh, 2, NM_MT_CHG_ADM_STATE, obj_class, i0, i1, i2); |
| 1016 | msgb_tv_put(msg, NM_ATT_ADM_STATE, adm_state); |
| 1017 | |
| 1018 | return abis_nm_sendmsg(bts, msg); |
| 1019 | } |
| 1020 | |
| 1021 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1022 | int abis_nm_event_reports(struct gsm_bts *bts, int on) |
| 1023 | { |
| 1024 | if (on == 0) |
Harald Welte | 227d407 | 2009-01-03 08:16:25 +0000 | [diff] [blame] | 1025 | return __simple_cmd(bts, NM_MT_STOP_EVENT_REP); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1026 | else |
Harald Welte | 227d407 | 2009-01-03 08:16:25 +0000 | [diff] [blame] | 1027 | return __simple_cmd(bts, NM_MT_REST_EVENT_REP); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1030 | |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 1031 | /* Siemens (or BS-11) specific commands */ |
| 1032 | |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1033 | int abis_nm_bs11_bsc_disconnect(struct gsm_bts *bts, int reconnect) |
| 1034 | { |
| 1035 | if (reconnect == 0) |
| 1036 | return __simple_cmd(bts, NM_MT_BS11_DISCONNECT); |
| 1037 | else |
| 1038 | return __simple_cmd(bts, NM_MT_BS11_RECONNECT); |
| 1039 | } |
| 1040 | |
Harald Welte | b842797 | 2009-02-05 19:27:17 +0000 | [diff] [blame] | 1041 | int abis_nm_bs11_restart(struct gsm_bts *bts) |
| 1042 | { |
| 1043 | return __simple_cmd(bts, NM_MT_BS11_RESTART); |
| 1044 | } |
| 1045 | |
| 1046 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 1047 | struct bs11_date_time { |
| 1048 | u_int16_t year; |
| 1049 | u_int8_t month; |
| 1050 | u_int8_t day; |
| 1051 | u_int8_t hour; |
| 1052 | u_int8_t min; |
| 1053 | u_int8_t sec; |
| 1054 | } __attribute__((packed)); |
| 1055 | |
| 1056 | |
| 1057 | void get_bs11_date_time(struct bs11_date_time *aet) |
| 1058 | { |
| 1059 | time_t t; |
| 1060 | struct tm *tm; |
| 1061 | |
| 1062 | t = time(NULL); |
| 1063 | tm = localtime(&t); |
| 1064 | aet->sec = tm->tm_sec; |
| 1065 | aet->min = tm->tm_min; |
| 1066 | aet->hour = tm->tm_hour; |
| 1067 | aet->day = tm->tm_mday; |
| 1068 | aet->month = tm->tm_mon; |
| 1069 | aet->year = htons(1900 + tm->tm_year); |
| 1070 | } |
| 1071 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1072 | int abis_nm_bs11_reset_resource(struct gsm_bts *bts) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1073 | { |
Harald Welte | 4668fda | 2009-01-03 08:19:29 +0000 | [diff] [blame] | 1074 | return __simple_cmd(bts, NM_MT_BS11_RESET_RESOURCE); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1077 | int abis_nm_bs11_db_transmission(struct gsm_bts *bts, int begin) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1078 | { |
| 1079 | if (begin) |
Harald Welte | 4668fda | 2009-01-03 08:19:29 +0000 | [diff] [blame] | 1080 | return __simple_cmd(bts, NM_MT_BS11_BEGIN_DB_TX); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1081 | else |
Harald Welte | 4668fda | 2009-01-03 08:19:29 +0000 | [diff] [blame] | 1082 | return __simple_cmd(bts, NM_MT_BS11_END_DB_TX); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1083 | } |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 1084 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1085 | int abis_nm_bs11_create_object(struct gsm_bts *bts, |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1086 | enum abis_bs11_objtype type, u_int8_t idx, |
| 1087 | u_int8_t attr_len, const u_int8_t *attr) |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 1088 | { |
| 1089 | struct abis_om_hdr *oh; |
| 1090 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1091 | u_int8_t *cur; |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 1092 | |
| 1093 | 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] | 1094 | fill_om_fom_hdr(oh, attr_len, NM_MT_BS11_CREATE_OBJ, |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 1095 | NM_OC_BS11, type, 0, idx); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1096 | cur = msgb_put(msg, attr_len); |
| 1097 | memcpy(cur, attr, attr_len); |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 1098 | |
| 1099 | return abis_nm_sendmsg(bts, msg); |
| 1100 | } |
| 1101 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1102 | 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] | 1103 | { |
| 1104 | struct abis_om_hdr *oh; |
| 1105 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1106 | u_int8_t zero = 0x00; |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 1107 | |
| 1108 | 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] | 1109 | fill_om_fom_hdr(oh, 3, NM_MT_BS11_CREATE_OBJ, |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1110 | NM_OC_BS11_ENVABTSE, 0, idx, 0xff); |
| 1111 | msgb_tlv_put(msg, 0x99, 1, &zero); |
Harald Welte | 47d88ae | 2009-01-04 12:02:08 +0000 | [diff] [blame] | 1112 | |
| 1113 | return abis_nm_sendmsg(bts, msg); |
| 1114 | } |
| 1115 | |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1116 | 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] | 1117 | { |
| 1118 | struct abis_om_hdr *oh; |
| 1119 | struct msgb *msg = nm_msgb_alloc(); |
| 1120 | |
| 1121 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1122 | fill_om_fom_hdr(oh, 0, NM_MT_BS11_CREATE_OBJ, NM_OC_BS11_BPORT, |
| 1123 | idx, 0, 0); |
| 1124 | |
| 1125 | return abis_nm_sendmsg(bts, msg); |
| 1126 | } |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1127 | |
| 1128 | int abis_nm_bs11_set_oml_tei(struct gsm_bts *bts, u_int8_t tei) |
| 1129 | { |
| 1130 | struct abis_om_hdr *oh; |
| 1131 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1132 | |
| 1133 | 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] | 1134 | fill_om_fom_hdr(oh, 2, NM_MT_BS11_SET_ATTR, NM_OC_SITE_MANAGER, |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1135 | 0xff, 0xff, 0xff); |
| 1136 | msgb_tv_put(msg, NM_ATT_TEI, tei); |
| 1137 | |
| 1138 | return abis_nm_sendmsg(bts, msg); |
| 1139 | } |
| 1140 | |
| 1141 | /* like abis_nm_conn_terr_traf */ |
| 1142 | int abis_nm_bs11_conn_oml(struct gsm_bts *bts, u_int8_t e1_port, |
| 1143 | u_int8_t e1_timeslot, u_int8_t e1_subslot) |
| 1144 | { |
| 1145 | struct abis_om_hdr *oh; |
| 1146 | struct abis_nm_channel *ch; |
| 1147 | struct msgb *msg = nm_msgb_alloc(); |
| 1148 | |
| 1149 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1150 | fill_om_fom_hdr(oh, sizeof(*ch), NM_MT_BS11_SET_ATTR, |
| 1151 | NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff); |
| 1152 | |
| 1153 | ch = (struct abis_nm_channel *) msgb_put(msg, sizeof(*ch)); |
| 1154 | fill_nm_channel(ch, e1_port, e1_timeslot, e1_subslot); |
| 1155 | |
| 1156 | return abis_nm_sendmsg(bts, msg); |
| 1157 | } |
| 1158 | |
| 1159 | int abis_nm_bs11_set_trx_power(struct gsm_bts_trx *trx, u_int8_t level) |
| 1160 | { |
| 1161 | struct abis_om_hdr *oh; |
| 1162 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1163 | |
| 1164 | 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] | 1165 | fill_om_fom_hdr(oh, 3, NM_MT_BS11_SET_ATTR, |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1166 | NM_OC_BS11, BS11_OBJ_PA, 0x00, trx->nr); |
| 1167 | msgb_tlv_put(msg, NM_ATT_BS11_TXPWR, 1, &level); |
| 1168 | |
| 1169 | return abis_nm_sendmsg(trx->bts, msg); |
| 1170 | } |
| 1171 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 1172 | //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] | 1173 | static const u_int8_t bs11_logon_c8[] = { 0x02 }; |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1174 | static const u_int8_t bs11_logon_c9[] = "FACTORY"; |
| 1175 | |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1176 | int abis_nm_bs11_factory_logon(struct gsm_bts *bts, int on) |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1177 | { |
| 1178 | struct abis_om_hdr *oh; |
| 1179 | struct msgb *msg = nm_msgb_alloc(); |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 1180 | struct bs11_date_time bdt; |
| 1181 | |
| 1182 | get_bs11_date_time(&bdt); |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1183 | |
| 1184 | 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] | 1185 | if (on) { |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 1186 | u_int8_t len = 3*2 + sizeof(bdt) |
Harald Welte | 6f676a3 | 2009-01-18 14:27:48 +0000 | [diff] [blame] | 1187 | + sizeof(bs11_logon_c8) + sizeof(bs11_logon_c9); |
Harald Welte | 043d04a | 2009-01-29 23:15:30 +0000 | [diff] [blame] | 1188 | fill_om_fom_hdr(oh, len, NM_MT_BS11_LMT_LOGON, |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1189 | NM_OC_BS11_A3, 0xff, 0xff, 0xff); |
Harald Welte | 043d04a | 2009-01-29 23:15:30 +0000 | [diff] [blame] | 1190 | msgb_tlv_put(msg, NM_ATT_BS11_LMT_LOGIN_TIME, |
Harald Welte | 5083b0b | 2009-02-02 19:20:52 +0000 | [diff] [blame] | 1191 | sizeof(bdt), (u_int8_t *) &bdt); |
Harald Welte | 043d04a | 2009-01-29 23:15:30 +0000 | [diff] [blame] | 1192 | msgb_tlv_put(msg, NM_ATT_BS11_LMT_USER_ACC_LEV, |
| 1193 | sizeof(bs11_logon_c8), bs11_logon_c8); |
| 1194 | msgb_tlv_put(msg, NM_ATT_BS11_LMT_USER_NAME, |
| 1195 | sizeof(bs11_logon_c9), bs11_logon_c9); |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1196 | } else { |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1197 | fill_om_fom_hdr(oh, 0, NM_MT_BS11_LMT_LOGOFF, |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1198 | NM_OC_BS11_A3, 0xff, 0xff, 0xff); |
| 1199 | } |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 1200 | |
| 1201 | return abis_nm_sendmsg(bts, msg); |
| 1202 | } |
Harald Welte | 1bc0906 | 2009-01-18 14:17:52 +0000 | [diff] [blame] | 1203 | |
| 1204 | int abis_nm_bs11_set_trx1_pw(struct gsm_bts *bts, const char *password) |
| 1205 | { |
| 1206 | struct abis_om_hdr *oh; |
| 1207 | struct msgb *msg; |
| 1208 | |
| 1209 | if (strlen(password) != 10) |
| 1210 | return -EINVAL; |
| 1211 | |
| 1212 | msg = nm_msgb_alloc(); |
| 1213 | 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] | 1214 | 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] | 1215 | NM_OC_BS11, BS11_OBJ_TRX1, 0x00, 0x00); |
| 1216 | msgb_tlv_put(msg, NM_ATT_BS11_PASSWORD, 10, (const u_int8_t *)password); |
| 1217 | |
| 1218 | return abis_nm_sendmsg(bts, msg); |
| 1219 | } |
| 1220 | |
| 1221 | int abis_nm_bs11_get_state(struct gsm_bts *bts) |
| 1222 | { |
| 1223 | return __simple_cmd(bts, NM_MT_BS11_GET_STATE); |
| 1224 | } |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1225 | |
| 1226 | /* BS11 SWL */ |
| 1227 | |
| 1228 | struct abis_nm_bs11_sw { |
| 1229 | struct gsm_bts *bts; |
| 1230 | char swl_fname[PATH_MAX]; |
| 1231 | u_int8_t win_size; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1232 | int forced; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1233 | struct llist_head file_list; |
| 1234 | gsm_cbfn *user_cb; /* specified by the user */ |
| 1235 | }; |
| 1236 | static struct abis_nm_bs11_sw _g_bs11_sw, *g_bs11_sw = &_g_bs11_sw; |
| 1237 | |
| 1238 | struct file_list_entry { |
| 1239 | struct llist_head list; |
| 1240 | char fname[PATH_MAX]; |
| 1241 | }; |
| 1242 | |
| 1243 | struct file_list_entry *fl_dequeue(struct llist_head *queue) |
| 1244 | { |
| 1245 | struct llist_head *lh; |
| 1246 | |
| 1247 | if (llist_empty(queue)) |
| 1248 | return NULL; |
| 1249 | |
| 1250 | lh = queue->next; |
| 1251 | llist_del(lh); |
| 1252 | |
| 1253 | return llist_entry(lh, struct file_list_entry, list); |
| 1254 | } |
| 1255 | |
| 1256 | static int bs11_read_swl_file(struct abis_nm_bs11_sw *bs11_sw) |
| 1257 | { |
| 1258 | char linebuf[255]; |
| 1259 | struct llist_head *lh, *lh2; |
| 1260 | FILE *swl; |
| 1261 | int rc = 0; |
| 1262 | |
| 1263 | swl = fopen(bs11_sw->swl_fname, "r"); |
| 1264 | if (!swl) |
| 1265 | return -ENODEV; |
| 1266 | |
| 1267 | /* zero the stale file list, if any */ |
| 1268 | llist_for_each_safe(lh, lh2, &bs11_sw->file_list) { |
| 1269 | llist_del(lh); |
| 1270 | free(lh); |
| 1271 | } |
| 1272 | |
| 1273 | while (fgets(linebuf, sizeof(linebuf), swl)) { |
| 1274 | char file_id[12+1]; |
| 1275 | char file_version[80+1]; |
| 1276 | struct file_list_entry *fle; |
| 1277 | static char dir[PATH_MAX]; |
| 1278 | |
| 1279 | if (strlen(linebuf) < 4) |
| 1280 | continue; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1281 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1282 | rc = sscanf(linebuf+4, "%12s:%80s\r\n", file_id, file_version); |
| 1283 | if (rc < 0) { |
| 1284 | perror("ERR parsing SWL file"); |
| 1285 | rc = -EINVAL; |
| 1286 | goto out; |
| 1287 | } |
| 1288 | if (rc < 2) |
| 1289 | continue; |
| 1290 | |
| 1291 | fle = malloc(sizeof(*fle)); |
| 1292 | if (!fle) { |
| 1293 | rc = -ENOMEM; |
| 1294 | goto out; |
| 1295 | } |
| 1296 | memset(fle, 0, sizeof(*fle)); |
| 1297 | |
| 1298 | /* construct new filename */ |
| 1299 | strncpy(dir, bs11_sw->swl_fname, sizeof(dir)); |
| 1300 | strncat(fle->fname, dirname(dir), sizeof(fle->fname) - 1); |
| 1301 | strcat(fle->fname, "/"); |
| 1302 | strncat(fle->fname, file_id, sizeof(fle->fname) - 1 -strlen(fle->fname)); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1303 | |
| 1304 | llist_add_tail(&fle->list, &bs11_sw->file_list); |
| 1305 | } |
| 1306 | |
| 1307 | out: |
| 1308 | fclose(swl); |
| 1309 | return rc; |
| 1310 | } |
| 1311 | |
| 1312 | /* bs11 swload specific callback, passed to abis_nm core swload */ |
| 1313 | static int bs11_swload_cbfn(unsigned int hook, unsigned int event, |
| 1314 | struct msgb *msg, void *data, void *param) |
| 1315 | { |
| 1316 | struct abis_nm_bs11_sw *bs11_sw = data; |
| 1317 | struct file_list_entry *fle; |
| 1318 | int rc = 0; |
| 1319 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1320 | switch (event) { |
| 1321 | case NM_MT_LOAD_END_ACK: |
| 1322 | fle = fl_dequeue(&bs11_sw->file_list); |
| 1323 | if (fle) { |
| 1324 | /* start download the next file of our file list */ |
| 1325 | rc = abis_nm_software_load(bs11_sw->bts, fle->fname, |
| 1326 | bs11_sw->win_size, |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1327 | bs11_sw->forced, |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1328 | &bs11_swload_cbfn, bs11_sw); |
| 1329 | free(fle); |
| 1330 | } else { |
| 1331 | /* activate the SWL */ |
| 1332 | rc = abis_nm_software_activate(bs11_sw->bts, |
| 1333 | bs11_sw->swl_fname, |
| 1334 | bs11_swload_cbfn, |
| 1335 | bs11_sw); |
| 1336 | } |
| 1337 | break; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1338 | case NM_MT_LOAD_SEG_ACK: |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1339 | case NM_MT_LOAD_END_NACK: |
| 1340 | case NM_MT_LOAD_INIT_ACK: |
| 1341 | case NM_MT_LOAD_INIT_NACK: |
| 1342 | case NM_MT_ACTIVATE_SW_NACK: |
| 1343 | case NM_MT_ACTIVATE_SW_ACK: |
| 1344 | default: |
| 1345 | /* fallthrough to the user callback */ |
Harald Welte | 97ed1e7 | 2009-02-06 13:38:02 +0000 | [diff] [blame] | 1346 | if (bs11_sw->user_cb) |
| 1347 | rc = bs11_sw->user_cb(hook, event, msg, NULL, NULL); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1348 | break; |
| 1349 | } |
| 1350 | |
| 1351 | return rc; |
| 1352 | } |
| 1353 | |
| 1354 | /* Siemens provides a SWL file that is a mere listing of all the other |
| 1355 | * files that are part of a software release. We need to upload first |
| 1356 | * the list file, and then each file that is listed in the list file */ |
| 1357 | 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] | 1358 | u_int8_t win_size, int forced, gsm_cbfn *cbfn) |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1359 | { |
| 1360 | struct abis_nm_bs11_sw *bs11_sw = g_bs11_sw; |
| 1361 | struct file_list_entry *fle; |
| 1362 | int rc = 0; |
| 1363 | |
| 1364 | INIT_LLIST_HEAD(&bs11_sw->file_list); |
| 1365 | bs11_sw->bts = bts; |
| 1366 | bs11_sw->win_size = win_size; |
| 1367 | bs11_sw->user_cb = cbfn; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1368 | bs11_sw->forced = forced; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1369 | |
| 1370 | strncpy(bs11_sw->swl_fname, fname, sizeof(bs11_sw->swl_fname)); |
| 1371 | rc = bs11_read_swl_file(bs11_sw); |
| 1372 | if (rc < 0) |
| 1373 | return rc; |
| 1374 | |
| 1375 | /* dequeue next item in file list */ |
| 1376 | fle = fl_dequeue(&bs11_sw->file_list); |
| 1377 | if (!fle) |
| 1378 | return -EINVAL; |
| 1379 | |
| 1380 | /* start download the next file of our file list */ |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 1381 | rc = abis_nm_software_load(bts, fle->fname, win_size, forced, |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1382 | bs11_swload_cbfn, bs11_sw); |
| 1383 | free(fle); |
| 1384 | return rc; |
| 1385 | } |
| 1386 | |
Harald Welte | 5083b0b | 2009-02-02 19:20:52 +0000 | [diff] [blame] | 1387 | #if 0 |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1388 | static u_int8_t req_attr_btse[] = { |
| 1389 | NM_ATT_ADM_STATE, NM_ATT_BS11_LMT_LOGON_SESSION, |
| 1390 | NM_ATT_BS11_LMT_LOGIN_TIME, NM_ATT_BS11_LMT_USER_ACC_LEV, |
| 1391 | NM_ATT_BS11_LMT_USER_NAME, |
| 1392 | |
| 1393 | 0xaf, NM_ATT_BS11_RX_OFFSET, NM_ATT_BS11_VENDOR_NAME, |
| 1394 | |
| 1395 | NM_ATT_BS11_SW_LOAD_INTENDED, NM_ATT_BS11_SW_LOAD_SAFETY, |
| 1396 | |
| 1397 | NM_ATT_BS11_SW_LOAD_STORED }; |
| 1398 | |
| 1399 | static u_int8_t req_attr_btsm[] = { |
| 1400 | NM_ATT_ABIS_CHANNEL, NM_ATT_TEI, NM_ATT_BS11_ABIS_EXT_TIME, |
| 1401 | NM_ATT_ADM_STATE, NM_ATT_AVAIL_STATUS, 0xce, NM_ATT_FILE_ID, |
| 1402 | NM_ATT_FILE_VERSION, NM_ATT_OPER_STATE, 0xe8, NM_ATT_BS11_ALL_TEST_CATG, |
| 1403 | NM_ATT_SW_DESCR, NM_ATT_GET_ARI }; |
Harald Welte | 5083b0b | 2009-02-02 19:20:52 +0000 | [diff] [blame] | 1404 | #endif |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 1405 | |
| 1406 | static u_int8_t req_attr[] = { |
| 1407 | NM_ATT_ADM_STATE, NM_ATT_AVAIL_STATUS, 0xa8, NM_ATT_OPER_STATE, |
| 1408 | 0xd5, 0xa1, NM_ATT_BS11_ESN_FW_CODE_NO, NM_ATT_BS11_ESN_HW_CODE_NO, |
| 1409 | 0x42, NM_ATT_BS11_ESN_PCB_SERIAL }; |
| 1410 | |
| 1411 | int abis_nm_bs11_get_serno(struct gsm_bts *bts) |
| 1412 | { |
| 1413 | struct abis_om_hdr *oh; |
| 1414 | struct msgb *msg = nm_msgb_alloc(); |
| 1415 | |
| 1416 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1417 | /* SiemensHW CCTRL object */ |
| 1418 | fill_om_fom_hdr(oh, 2+sizeof(req_attr), NM_MT_GET_ATTR, NM_OC_BS11, |
| 1419 | 0x03, 0x00, 0x00); |
| 1420 | msgb_tlv_put(msg, NM_ATT_LIST_REQ_ATTR, sizeof(req_attr), req_attr); |
| 1421 | |
| 1422 | return abis_nm_sendmsg(bts, msg); |
| 1423 | } |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 1424 | |
| 1425 | int abis_nm_bs11_set_ext_time(struct gsm_bts *bts) |
| 1426 | { |
| 1427 | struct abis_om_hdr *oh; |
| 1428 | struct msgb *msg = nm_msgb_alloc(); |
| 1429 | struct bs11_date_time aet; |
| 1430 | |
| 1431 | get_bs11_date_time(&aet); |
| 1432 | oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE); |
| 1433 | /* SiemensHW CCTRL object */ |
| 1434 | fill_om_fom_hdr(oh, 2+sizeof(aet), NM_MT_BS11_SET_ATTR, NM_OC_SITE_MANAGER, |
| 1435 | 0xff, 0xff, 0xff); |
Harald Welte | 5083b0b | 2009-02-02 19:20:52 +0000 | [diff] [blame] | 1436 | 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] | 1437 | |
| 1438 | return abis_nm_sendmsg(bts, msg); |
| 1439 | } |