blob: c670dcbe41225c781c03e01c1387d84bdc99c208 [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001/* 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 Welte4724f992009-01-18 18:01:49 +00004/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
Harald Welte8470bf22008-12-25 23:28:35 +00005 *
Harald Welte52b1f982008-12-23 20:25:15 +00006 * 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 Welte4724f992009-01-18 18:01:49 +000026#include <unistd.h>
Harald Welte52b1f982008-12-23 20:25:15 +000027#include <stdio.h>
Harald Welte4724f992009-01-18 18:01:49 +000028#include <fcntl.h>
Harald Welte5e4d1b32009-02-01 13:36:56 +000029#include <malloc.h>
30#include <libgen.h>
Harald Welte268bb402009-02-01 19:11:56 +000031#include <time.h>
Harald Welte5f6f1492009-02-02 14:50:29 +000032#include <limits.h>
Harald Welte4724f992009-01-18 18:01:49 +000033
Harald Welte52b1f982008-12-23 20:25:15 +000034#include <sys/types.h>
Harald Welte4724f992009-01-18 18:01:49 +000035#include <sys/stat.h>
Harald Welte8470bf22008-12-25 23:28:35 +000036#include <netinet/in.h>
Harald Welte52b1f982008-12-23 20:25:15 +000037
Harald Welte8470bf22008-12-25 23:28:35 +000038#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 Freytherca362a62009-01-04 21:05:01 +000043#include <openbsc/misdn.h>
Harald Welte52b1f982008-12-23 20:25:15 +000044
Harald Welte8470bf22008-12-25 23:28:35 +000045#define OM_ALLOC_SIZE 1024
46#define OM_HEADROOM_SIZE 128
Harald Welte52b1f982008-12-23 20:25:15 +000047
48/* unidirectional messages from BTS to BSC */
49static 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 */
57static 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 Welte4724f992009-01-18 18:01:49 +000063/* Messages related to software load */
64static 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 Welte34a99682009-02-13 02:41:40 +000071 //NM_MT_SW_ACT_REQ,
Harald Welte4724f992009-01-18 18:01:49 +000072 NM_MT_ACTIVATE_SW_ACK,
73 NM_MT_ACTIVATE_SW_NACK,
74 NM_MT_SW_ACTIVATED_REP,
75};
76
Harald Welte52b1f982008-12-23 20:25:15 +000077/* Attributes that the BSC can set, not only get, according to Section 9.4 */
78static 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
106static 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 Freytherca362a62009-01-04 21:05:01 +0000118#if 0
Harald Welte52b1f982008-12-23 20:25:15 +0000119/* is this msgtype the usual ACK/NACK type ? */
120static 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 Freytherca362a62009-01-04 21:05:01 +0000124#endif
Harald Welte52b1f982008-12-23 20:25:15 +0000125
126/* is this msgtype a report ? */
127static int is_report(enum abis_nm_msgtype mt)
128{
Harald Welte8470bf22008-12-25 23:28:35 +0000129 return is_in_arr(mt, reports, ARRAY_SIZE(reports));
Harald Welte52b1f982008-12-23 20:25:15 +0000130}
131
132#define MT_ACK(x) (x+1)
133#define MT_NACK(x) (x+2)
134
135static 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
143static 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 Welte702d8702008-12-26 20:25:35 +0000150 fill_om_hdr(oh, len+sizeof(*foh));
Harald Welte52b1f982008-12-23 20:25:15 +0000151 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 Welte8470bf22008-12-25 23:28:35 +0000158static struct msgb *nm_msgb_alloc(void)
159{
160 return msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE);
161}
162
Harald Welte52b1f982008-12-23 20:25:15 +0000163/* Send a OML NM Message from BSC to BTS */
164int abis_nm_sendmsg(struct gsm_bts *bts, struct msgb *msg)
165{
Holger Freyther59639e82009-02-09 23:09:55 +0000166 msg->trx = bts->c0;
167
Harald Weltead384642008-12-26 10:20:07 +0000168 return _abis_nm_sendmsg(msg);
Harald Welte52b1f982008-12-23 20:25:15 +0000169}
170
Harald Welte4724f992009-01-18 18:01:49 +0000171static int abis_nm_rcvmsg_sw(struct msgb *mb);
172
Harald Welte34a99682009-02-13 02:41:40 +0000173const 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
181static 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
188static 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 Welte97ed1e72009-02-06 13:38:02 +0000203static int abis_nm_rx_statechg_rep(struct msgb *mb)
204{
205 struct abis_om_fom_hdr *foh = msgb_l3(mb);
Harald Welte97ed1e72009-02-06 13:38:02 +0000206 u_int8_t *data = &foh->data[0];
207
Harald Welte34a99682009-02-13 02:41:40 +0000208 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 Welte97ed1e72009-02-06 13:38:02 +0000211 foh->obj_inst.ts_nr);
212 if (*data++ == NM_ATT_OPER_STATE)
Harald Welte34a99682009-02-13 02:41:40 +0000213 DEBUGPC(DNM, "OP_STATE=%s ", opstate_name(*data++));
Harald Welte97ed1e72009-02-06 13:38:02 +0000214 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
223static 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 Welte34a99682009-02-13 02:41:40 +0000234 case NM_MT_SW_ACTIVATED_REP:
235 DEBUGP(DNM, "Software Activated Report\n");
236 break;
Harald Welte97ed1e72009-02-06 13:38:02 +0000237 };
238
239 DEBUGP(DNM, "reporting NM MT 0x%02x\n", mt);
240
241 return 0;
242}
243
Harald Welte34a99682009-02-13 02:41:40 +0000244/* Activate the specified software into the BTS */
245static 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
262static 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 Welte52b1f982008-12-23 20:25:15 +0000284/* Receive a OML NM Message from BTS */
Harald Welte8470bf22008-12-25 23:28:35 +0000285static int abis_nm_rcvmsg_fom(struct msgb *mb)
Harald Welte52b1f982008-12-23 20:25:15 +0000286{
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 Welte97ed1e72009-02-06 13:38:02 +0000291 if (is_report(mt))
292 return abis_nm_rcvmsg_report(mb);
Harald Welte52b1f982008-12-23 20:25:15 +0000293
Harald Welte4724f992009-01-18 18:01:49 +0000294 if (is_in_arr(mt, sw_load_msgs, ARRAY_SIZE(sw_load_msgs)))
295 return abis_nm_rcvmsg_sw(mb);
296
Harald Weltead384642008-12-26 10:20:07 +0000297#if 0
Harald Welte52b1f982008-12-23 20:25:15 +0000298 /* 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 Weltead384642008-12-26 10:20:07 +0000314#endif
315
Harald Welte97ed1e72009-02-06 13:38:02 +0000316 switch (mt) {
Harald Welte34a99682009-02-13 02:41:40 +0000317 case NM_MT_SW_ACT_REQ:
318 return abis_nm_rx_sw_act_req(mb);
319 break;
Harald Welte97ed1e72009-02-06 13:38:02 +0000320 case NM_MT_BS11_LMT_SESSION:
321 DEBUGP(DNM, "LMT Event: \n");
322 break;
323 }
324
Harald Weltead384642008-12-26 10:20:07 +0000325 return 0;
Harald Welte52b1f982008-12-23 20:25:15 +0000326}
327
328/* High-Level API */
329/* Entry-point where L2 OML from BTS enters the NM code */
Harald Welte8470bf22008-12-25 23:28:35 +0000330int abis_nm_rcvmsg(struct msgb *msg)
Harald Welte52b1f982008-12-23 20:25:15 +0000331{
332 int rc;
333 struct abis_om_hdr *oh = msgb_l2(msg);
Harald Welte52b1f982008-12-23 20:25:15 +0000334
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 Welte702d8702008-12-26 20:25:35 +0000346#if 0
Holger Freytherca362a62009-01-04 21:05:01 +0000347 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 Welte702d8702008-12-26 20:25:35 +0000349 if (oh->length + hlen > l2_len) {
Harald Welte52b1f982008-12-23 20:25:15 +0000350 fprintf(stderr, "ABIS OML truncated message (%u > %u)\n",
351 oh->length + sizeof(*oh), l2_len);
352 return -EINVAL;
353 }
Harald Welte702d8702008-12-26 20:25:35 +0000354 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 Weltead384642008-12-26 10:20:07 +0000357 msg->l3h = (unsigned char *)oh + sizeof(*oh);
Harald Welte52b1f982008-12-23 20:25:15 +0000358
359 switch (oh->mdisc) {
360 case ABIS_OM_MDISC_FOM:
Harald Welte8470bf22008-12-25 23:28:35 +0000361 rc = abis_nm_rcvmsg_fom(msg);
Harald Welte52b1f982008-12-23 20:25:15 +0000362 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 Weltead384642008-12-26 10:20:07 +0000372 msgb_free(msg);
Harald Welte52b1f982008-12-23 20:25:15 +0000373 return rc;
374}
375
376#if 0
377/* initialized all resources */
378struct 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 */
392void 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 Welte4724f992009-01-18 18:01:49 +0000405/* 6.2 Software Load: */
406enum 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 Welte52b1f982008-12-23 20:25:15 +0000414
Harald Welte52b1f982008-12-23 20:25:15 +0000415struct abis_nm_sw {
Harald Welte4724f992009-01-18 18:01:49 +0000416 struct gsm_bts *bts;
Harald Welte5e4d1b32009-02-01 13:36:56 +0000417 gsm_cbfn *cbfn;
418 void *cb_data;
Harald Welte3ffd1372009-02-01 22:15:49 +0000419 int forced;
Harald Welte5e4d1b32009-02-01 13:36:56 +0000420
Harald Welte52b1f982008-12-23 20:25:15 +0000421 /* this will become part of the SW LOAD INITIATE */
422 u_int8_t obj_class;
423 u_int8_t obj_instance[3];
Harald Welte4724f992009-01-18 18:01:49 +0000424
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 Welte1602ade2009-01-29 21:12:39 +0000437 int last_seg;
Harald Welte52b1f982008-12-23 20:25:15 +0000438};
439
Harald Welte4724f992009-01-18 18:01:49 +0000440static struct abis_nm_sw g_sw;
441
442/* 6.2.1 / 8.3.1: Load Data Initiate */
443static int sw_load_init(struct abis_nm_sw *sw)
Harald Welte52b1f982008-12-23 20:25:15 +0000444{
Harald Welte4724f992009-01-18 18:01:49 +0000445 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 Welte52b1f982008-12-23 20:25:15 +0000461}
462
Harald Welte1602ade2009-01-29 21:12:39 +0000463static 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 Welte4724f992009-01-18 18:01:49 +0000479/* 6.2.2 / 8.3.2 Load Data Segment */
480static 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 Welte3b8ba212009-01-29 12:27:58 +0000486 unsigned char *tlv;
Harald Welte4724f992009-01-18 18:01:49 +0000487 u_int8_t len;
Harald Welte4724f992009-01-18 18:01:49 +0000488
489 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte3b8ba212009-01-29 12:27:58 +0000490
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 Welte1602ade2009-01-29 21:12:39 +0000498
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 Welte3b8ba212009-01-29 12:27:58 +0000505
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 Welte4724f992009-01-18 18:01:49 +0000518 }
Harald Welte4724f992009-01-18 18:01:49 +0000519
Harald Welte4724f992009-01-18 18:01:49 +0000520 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 */
528static 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 Welte5e4d1b32009-02-01 13:36:56 +0000546
Harald Welte52b1f982008-12-23 20:25:15 +0000547/* Activate the specified software into the BTS */
Harald Welte4724f992009-01-18 18:01:49 +0000548static int sw_activate(struct abis_nm_sw *sw)
Harald Welte52b1f982008-12-23 20:25:15 +0000549{
Harald Welte4724f992009-01-18 18:01:49 +0000550 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 Welte52b1f982008-12-23 20:25:15 +0000553
Harald Welte4724f992009-01-18 18:01:49 +0000554 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 Welte52b1f982008-12-23 20:25:15 +0000565}
Harald Welte4724f992009-01-18 18:01:49 +0000566
567static 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 Welte3b8ba212009-01-29 12:27:58 +0000585 rc = fscanf(sw->stream, "@(#)%12s:%80s\r\n",
Harald Welte4724f992009-01-18 18:01:49 +0000586 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 Welte3b8ba212009-01-29 12:27:58 +0000596 rewind(sw->stream);
Harald Welte4724f992009-01-18 18:01:49 +0000597 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
607static 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 */
620static 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 Welte1602ade2009-01-29 21:12:39 +0000628 if (sw->last_seg)
629 break;
Harald Welte4724f992009-01-18 18:01:49 +0000630 }
631 return 0;
632}
633
634/* callback function from abis_nm_rcvmsg() handler */
635static 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 Welte3ffd1372009-02-01 22:15:49 +0000642 //DEBUGP(DNM, "state %u, NM MT 0x%02x\n", sw->state, foh->msg_type);
Harald Welte4724f992009-01-18 18:01:49 +0000643
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 Welte5e4d1b32009-02-01 13:36:56 +0000649 if (sw->cbfn)
650 sw->cbfn(GSM_HOOK_NM_SWLOAD,
651 NM_MT_LOAD_INIT_ACK, mb,
652 sw->cb_data, NULL);
Harald Welte4724f992009-01-18 18:01:49 +0000653 rc = sw_fill_window(sw);
654 sw->state = SW_STATE_WAIT_SEGACK;
655 break;
656 case NM_MT_LOAD_INIT_NACK:
Harald Welte3ffd1372009-02-01 22:15:49 +0000657 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 Welte4724f992009-01-18 18:01:49 +0000674 break;
675 }
676 break;
677 case SW_STATE_WAIT_SEGACK:
678 switch (foh->msg_type) {
679 case NM_MT_LOAD_SEG_ACK:
Harald Welte3ffd1372009-02-01 22:15:49 +0000680 if (sw->cbfn)
681 sw->cbfn(GSM_HOOK_NM_SWLOAD,
682 NM_MT_LOAD_SEG_ACK, mb,
683 sw->cb_data, NULL);
Harald Welte4724f992009-01-18 18:01:49 +0000684 sw->seg_in_window = 0;
Harald Welte1602ade2009-01-29 21:12:39 +0000685 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 Welte4724f992009-01-18 18:01:49 +0000694 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 Welte5e4d1b32009-02-01 13:36:56 +0000701 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 Welte4724f992009-01-18 18:01:49 +0000708 break;
709 case NM_MT_LOAD_END_NACK:
Holger Freyther31338a12009-02-06 17:43:50 +0000710 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 Welte4724f992009-01-18 18:01:49 +0000726 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 Welte5e4d1b32009-02-01 13:36:56 +0000732 DEBUGP(DNM, "Activate Software DONE!\n");
Harald Welte4724f992009-01-18 18:01:49 +0000733 sw->state = SW_STATE_NONE;
734 rc = 0;
Harald Welte5e4d1b32009-02-01 13:36:56 +0000735 if (sw->cbfn)
736 sw->cbfn(GSM_HOOK_NM_SWLOAD,
737 NM_MT_ACTIVATE_SW_ACK, mb,
738 sw->cb_data, NULL);
Harald Welte4724f992009-01-18 18:01:49 +0000739 break;
740 case NM_MT_ACTIVATE_SW_NACK:
Harald Welte1602ade2009-01-29 21:12:39 +0000741 DEBUGP(DNM, "Activate Software NACK\n");
Harald Welte4724f992009-01-18 18:01:49 +0000742 sw->state = SW_STATE_ERROR;
Harald Welte5e4d1b32009-02-01 13:36:56 +0000743 if (sw->cbfn)
744 sw->cbfn(GSM_HOOK_NM_SWLOAD,
745 NM_MT_ACTIVATE_SW_NACK, mb,
746 sw->cb_data, NULL);
Harald Welte4724f992009-01-18 18:01:49 +0000747 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 */
762int abis_nm_software_load(struct gsm_bts *bts, const char *fname,
Harald Welte3ffd1372009-02-01 22:15:49 +0000763 u_int8_t win_size, int forced,
764 gsm_cbfn *cbfn, void *cb_data)
Harald Welte4724f992009-01-18 18:01:49 +0000765{
766 struct abis_nm_sw *sw = &g_sw;
767 int rc;
768
Harald Welte5e4d1b32009-02-01 13:36:56 +0000769 DEBUGP(DNM, "Software Load (BTS %u, File \"%s\")\n",
770 bts->nr, fname);
771
Harald Welte4724f992009-01-18 18:01:49 +0000772 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 Welte5e4d1b32009-02-01 13:36:56 +0000782 sw->cbfn = cbfn;
783 sw->cb_data = cb_data;
Harald Welte3ffd1372009-02-01 22:15:49 +0000784 sw->forced = forced;
Harald Welte4724f992009-01-18 18:01:49 +0000785
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 Welte52b1f982008-12-23 20:25:15 +0000794
Harald Welte1602ade2009-01-29 21:12:39 +0000795int 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 Welte5e4d1b32009-02-01 13:36:56 +0000811/* Activate the specified software into the BTS */
812int 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 Welte8470bf22008-12-25 23:28:35 +0000844static void fill_nm_channel(struct abis_nm_channel *ch, u_int8_t bts_port,
Harald Welte52b1f982008-12-23 20:25:15 +0000845 u_int8_t ts_nr, u_int8_t subslot_nr)
846{
Harald Welteadaf08b2009-01-18 11:08:10 +0000847 ch->attrib = NM_ATT_ABIS_CHANNEL;
Harald Welte52b1f982008-12-23 20:25:15 +0000848 ch->bts_port = bts_port;
849 ch->timeslot = ts_nr;
850 ch->subslot = subslot_nr;
851}
852
853int 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 Welte702d8702008-12-26 20:25:35 +0000859 u_int8_t len = sizeof(*ch) + 2;
Harald Welte8470bf22008-12-25 23:28:35 +0000860 struct msgb *msg = nm_msgb_alloc();
Harald Welte52b1f982008-12-23 20:25:15 +0000861
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 Welte8470bf22008-12-25 23:28:35 +0000866 msgb_tv_put(msg, NM_ATT_TEI, tei);
Harald Welte52b1f982008-12-23 20:25:15 +0000867
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 */
875int 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 Welte8470bf22008-12-25 23:28:35 +0000878 struct gsm_bts *bts = trx->bts;
Harald Welte52b1f982008-12-23 20:25:15 +0000879 struct abis_om_hdr *oh;
880 struct abis_nm_channel *ch;
Harald Welte8470bf22008-12-25 23:28:35 +0000881 struct msgb *msg = nm_msgb_alloc();
Harald Welte52b1f982008-12-23 20:25:15 +0000882
883 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte6f676a32009-01-18 14:27:48 +0000884 fill_om_fom_hdr(oh, sizeof(*ch), NM_MT_CONN_TERR_SIGN,
Harald Welte52b1f982008-12-23 20:25:15 +0000885 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
894int 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
900int 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 Welte8470bf22008-12-25 23:28:35 +0000907 struct msgb *msg = nm_msgb_alloc();
Harald Welte52b1f982008-12-23 20:25:15 +0000908
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
920int 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
927int 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 Welte8470bf22008-12-25 23:28:35 +0000931 u_int16_t arfcn = htons(ts->trx->arfcn);
Harald Welte52b1f982008-12-23 20:25:15 +0000932 u_int8_t zero = 0x00;
Harald Welte8470bf22008-12-25 23:28:35 +0000933 struct msgb *msg = nm_msgb_alloc();
Harald Welte702d8702008-12-26 20:25:35 +0000934 u_int8_t len = 4 + 2 + 2 + 2 + 2 +3;
Harald Welte52b1f982008-12-23 20:25:15 +0000935
936 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte702d8702008-12-26 20:25:35 +0000937 fill_om_fom_hdr(oh, len, NM_MT_SET_CHAN_ATTR,
Harald Welte52b1f982008-12-23 20:25:15 +0000938 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 Welte34a99682009-02-13 02:41:40 +0000951int 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 Welte8470bf22008-12-25 23:28:35 +0000968int abis_nm_raw_msg(struct gsm_bts *bts, int len, u_int8_t *rawmsg)
Harald Welte52b1f982008-12-23 20:25:15 +0000969{
Harald Welte8470bf22008-12-25 23:28:35 +0000970 struct msgb *msg = nm_msgb_alloc();
971 struct abis_om_hdr *oh;
Harald Welte52b1f982008-12-23 20:25:15 +0000972 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 Weltead384642008-12-26 10:20:07 +0000977 memcpy(data, rawmsg, len);
Harald Welte52b1f982008-12-23 20:25:15 +0000978
979 return abis_nm_sendmsg(bts, msg);
980}
981
982/* Siemens specific commands */
983static int __simple_cmd(struct gsm_bts *bts, u_int8_t msg_type)
984{
985 struct abis_om_hdr *oh;
Harald Welte8470bf22008-12-25 23:28:35 +0000986 struct msgb *msg = nm_msgb_alloc();
Harald Welte52b1f982008-12-23 20:25:15 +0000987
988 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte702d8702008-12-26 20:25:35 +0000989 fill_om_fom_hdr(oh, 0, msg_type, NM_OC_SITE_MANAGER,
Harald Welte52b1f982008-12-23 20:25:15 +0000990 0xff, 0xff, 0xff);
991
992 return abis_nm_sendmsg(bts, msg);
993}
994
Harald Welte34a99682009-02-13 02:41:40 +0000995/* Chapter 8.9.2 */
996int 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 */
1008int 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 Welte52b1f982008-12-23 20:25:15 +00001022int abis_nm_event_reports(struct gsm_bts *bts, int on)
1023{
1024 if (on == 0)
Harald Welte227d4072009-01-03 08:16:25 +00001025 return __simple_cmd(bts, NM_MT_STOP_EVENT_REP);
Harald Welte52b1f982008-12-23 20:25:15 +00001026 else
Harald Welte227d4072009-01-03 08:16:25 +00001027 return __simple_cmd(bts, NM_MT_REST_EVENT_REP);
Harald Welte52b1f982008-12-23 20:25:15 +00001028}
1029
Harald Welte3ffd1372009-02-01 22:15:49 +00001030
Harald Welte47d88ae2009-01-04 12:02:08 +00001031/* Siemens (or BS-11) specific commands */
1032
Harald Welte3ffd1372009-02-01 22:15:49 +00001033int 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 Welteb8427972009-02-05 19:27:17 +00001041int abis_nm_bs11_restart(struct gsm_bts *bts)
1042{
1043 return __simple_cmd(bts, NM_MT_BS11_RESTART);
1044}
1045
1046
Harald Welte268bb402009-02-01 19:11:56 +00001047struct 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
1057void 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 Welte05188ee2009-01-18 11:39:08 +00001072int abis_nm_bs11_reset_resource(struct gsm_bts *bts)
Harald Welte52b1f982008-12-23 20:25:15 +00001073{
Harald Welte4668fda2009-01-03 08:19:29 +00001074 return __simple_cmd(bts, NM_MT_BS11_RESET_RESOURCE);
Harald Welte52b1f982008-12-23 20:25:15 +00001075}
1076
Harald Welte05188ee2009-01-18 11:39:08 +00001077int abis_nm_bs11_db_transmission(struct gsm_bts *bts, int begin)
Harald Welte52b1f982008-12-23 20:25:15 +00001078{
1079 if (begin)
Harald Welte4668fda2009-01-03 08:19:29 +00001080 return __simple_cmd(bts, NM_MT_BS11_BEGIN_DB_TX);
Harald Welte52b1f982008-12-23 20:25:15 +00001081 else
Harald Welte4668fda2009-01-03 08:19:29 +00001082 return __simple_cmd(bts, NM_MT_BS11_END_DB_TX);
Harald Welte52b1f982008-12-23 20:25:15 +00001083}
Harald Welte47d88ae2009-01-04 12:02:08 +00001084
Harald Welte05188ee2009-01-18 11:39:08 +00001085int abis_nm_bs11_create_object(struct gsm_bts *bts,
Harald Welte1bc09062009-01-18 14:17:52 +00001086 enum abis_bs11_objtype type, u_int8_t idx,
1087 u_int8_t attr_len, const u_int8_t *attr)
Harald Welte47d88ae2009-01-04 12:02:08 +00001088{
1089 struct abis_om_hdr *oh;
1090 struct msgb *msg = nm_msgb_alloc();
Harald Welte1bc09062009-01-18 14:17:52 +00001091 u_int8_t *cur;
Harald Welte47d88ae2009-01-04 12:02:08 +00001092
1093 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte6f676a32009-01-18 14:27:48 +00001094 fill_om_fom_hdr(oh, attr_len, NM_MT_BS11_CREATE_OBJ,
Harald Welte268bb402009-02-01 19:11:56 +00001095 NM_OC_BS11, type, 0, idx);
Harald Welte1bc09062009-01-18 14:17:52 +00001096 cur = msgb_put(msg, attr_len);
1097 memcpy(cur, attr, attr_len);
Harald Welte47d88ae2009-01-04 12:02:08 +00001098
1099 return abis_nm_sendmsg(bts, msg);
1100}
1101
Harald Welte05188ee2009-01-18 11:39:08 +00001102int abis_nm_bs11_create_envaBTSE(struct gsm_bts *bts, u_int8_t idx)
Harald Welte47d88ae2009-01-04 12:02:08 +00001103{
1104 struct abis_om_hdr *oh;
1105 struct msgb *msg = nm_msgb_alloc();
Harald Welte1bc09062009-01-18 14:17:52 +00001106 u_int8_t zero = 0x00;
Harald Welte47d88ae2009-01-04 12:02:08 +00001107
1108 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte6f676a32009-01-18 14:27:48 +00001109 fill_om_fom_hdr(oh, 3, NM_MT_BS11_CREATE_OBJ,
Harald Welte1bc09062009-01-18 14:17:52 +00001110 NM_OC_BS11_ENVABTSE, 0, idx, 0xff);
1111 msgb_tlv_put(msg, 0x99, 1, &zero);
Harald Welte47d88ae2009-01-04 12:02:08 +00001112
1113 return abis_nm_sendmsg(bts, msg);
1114}
1115
Harald Welte05188ee2009-01-18 11:39:08 +00001116int abis_nm_bs11_create_bport(struct gsm_bts *bts, u_int8_t idx)
Harald Welte47d88ae2009-01-04 12:02:08 +00001117{
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 Welte05188ee2009-01-18 11:39:08 +00001127
1128int 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 Welte05188ee2009-01-18 11:39:08 +00001132
1133 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte6f676a32009-01-18 14:27:48 +00001134 fill_om_fom_hdr(oh, 2, NM_MT_BS11_SET_ATTR, NM_OC_SITE_MANAGER,
Harald Welte05188ee2009-01-18 11:39:08 +00001135 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 */
1142int 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 Welte05188ee2009-01-18 11:39:08 +00001150 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
1159int 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 Welte05188ee2009-01-18 11:39:08 +00001163
1164 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte6f676a32009-01-18 14:27:48 +00001165 fill_om_fom_hdr(oh, 3, NM_MT_BS11_SET_ATTR,
Harald Welte05188ee2009-01-18 11:39:08 +00001166 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 Welte268bb402009-02-01 19:11:56 +00001172//static const u_int8_t bs11_logon_c7[] = { 0x07, 0xd9, 0x01, 0x11, 0x0d, 0x10, 0x20 };
Harald Weltebb151312009-01-28 20:42:07 +00001173static const u_int8_t bs11_logon_c8[] = { 0x02 };
Harald Welte05188ee2009-01-18 11:39:08 +00001174static const u_int8_t bs11_logon_c9[] = "FACTORY";
1175
Harald Welte1bc09062009-01-18 14:17:52 +00001176int abis_nm_bs11_factory_logon(struct gsm_bts *bts, int on)
Harald Welte05188ee2009-01-18 11:39:08 +00001177{
1178 struct abis_om_hdr *oh;
1179 struct msgb *msg = nm_msgb_alloc();
Harald Welte268bb402009-02-01 19:11:56 +00001180 struct bs11_date_time bdt;
1181
1182 get_bs11_date_time(&bdt);
Harald Welte05188ee2009-01-18 11:39:08 +00001183
1184 oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
Harald Welte1bc09062009-01-18 14:17:52 +00001185 if (on) {
Harald Welte268bb402009-02-01 19:11:56 +00001186 u_int8_t len = 3*2 + sizeof(bdt)
Harald Welte6f676a32009-01-18 14:27:48 +00001187 + sizeof(bs11_logon_c8) + sizeof(bs11_logon_c9);
Harald Welte043d04a2009-01-29 23:15:30 +00001188 fill_om_fom_hdr(oh, len, NM_MT_BS11_LMT_LOGON,
Harald Welte1bc09062009-01-18 14:17:52 +00001189 NM_OC_BS11_A3, 0xff, 0xff, 0xff);
Harald Welte043d04a2009-01-29 23:15:30 +00001190 msgb_tlv_put(msg, NM_ATT_BS11_LMT_LOGIN_TIME,
Harald Welte5083b0b2009-02-02 19:20:52 +00001191 sizeof(bdt), (u_int8_t *) &bdt);
Harald Welte043d04a2009-01-29 23:15:30 +00001192 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 Welte1bc09062009-01-18 14:17:52 +00001196 } else {
Harald Welte5e4d1b32009-02-01 13:36:56 +00001197 fill_om_fom_hdr(oh, 0, NM_MT_BS11_LMT_LOGOFF,
Harald Welte1bc09062009-01-18 14:17:52 +00001198 NM_OC_BS11_A3, 0xff, 0xff, 0xff);
1199 }
Harald Welte05188ee2009-01-18 11:39:08 +00001200
1201 return abis_nm_sendmsg(bts, msg);
1202}
Harald Welte1bc09062009-01-18 14:17:52 +00001203
1204int 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 Welte6f676a32009-01-18 14:27:48 +00001214 fill_om_fom_hdr(oh, 2+strlen(password), NM_MT_BS11_SET_ATTR,
Harald Welte1bc09062009-01-18 14:17:52 +00001215 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
1221int abis_nm_bs11_get_state(struct gsm_bts *bts)
1222{
1223 return __simple_cmd(bts, NM_MT_BS11_GET_STATE);
1224}
Harald Welte5e4d1b32009-02-01 13:36:56 +00001225
1226/* BS11 SWL */
1227
1228struct abis_nm_bs11_sw {
1229 struct gsm_bts *bts;
1230 char swl_fname[PATH_MAX];
1231 u_int8_t win_size;
Harald Welte3ffd1372009-02-01 22:15:49 +00001232 int forced;
Harald Welte5e4d1b32009-02-01 13:36:56 +00001233 struct llist_head file_list;
1234 gsm_cbfn *user_cb; /* specified by the user */
1235};
1236static struct abis_nm_bs11_sw _g_bs11_sw, *g_bs11_sw = &_g_bs11_sw;
1237
1238struct file_list_entry {
1239 struct llist_head list;
1240 char fname[PATH_MAX];
1241};
1242
1243struct 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
1256static 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 Welte3ffd1372009-02-01 22:15:49 +00001281
Harald Welte5e4d1b32009-02-01 13:36:56 +00001282 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 Welte5e4d1b32009-02-01 13:36:56 +00001303
1304 llist_add_tail(&fle->list, &bs11_sw->file_list);
1305 }
1306
1307out:
1308 fclose(swl);
1309 return rc;
1310}
1311
1312/* bs11 swload specific callback, passed to abis_nm core swload */
1313static 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 Welte5e4d1b32009-02-01 13:36:56 +00001320 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 Welte3ffd1372009-02-01 22:15:49 +00001327 bs11_sw->forced,
Harald Welte5e4d1b32009-02-01 13:36:56 +00001328 &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 Welte3ffd1372009-02-01 22:15:49 +00001338 case NM_MT_LOAD_SEG_ACK:
Harald Welte5e4d1b32009-02-01 13:36:56 +00001339 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 Welte97ed1e72009-02-06 13:38:02 +00001346 if (bs11_sw->user_cb)
1347 rc = bs11_sw->user_cb(hook, event, msg, NULL, NULL);
Harald Welte5e4d1b32009-02-01 13:36:56 +00001348 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 */
1357int abis_nm_bs11_load_swl(struct gsm_bts *bts, const char *fname,
Harald Welte3ffd1372009-02-01 22:15:49 +00001358 u_int8_t win_size, int forced, gsm_cbfn *cbfn)
Harald Welte5e4d1b32009-02-01 13:36:56 +00001359{
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 Welte3ffd1372009-02-01 22:15:49 +00001368 bs11_sw->forced = forced;
Harald Welte5e4d1b32009-02-01 13:36:56 +00001369
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 Welte3ffd1372009-02-01 22:15:49 +00001381 rc = abis_nm_software_load(bts, fle->fname, win_size, forced,
Harald Welte5e4d1b32009-02-01 13:36:56 +00001382 bs11_swload_cbfn, bs11_sw);
1383 free(fle);
1384 return rc;
1385}
1386
Harald Welte5083b0b2009-02-02 19:20:52 +00001387#if 0
Harald Welte5e4d1b32009-02-01 13:36:56 +00001388static 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
1399static 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 Welte5083b0b2009-02-02 19:20:52 +00001404#endif
Harald Welte5e4d1b32009-02-01 13:36:56 +00001405
1406static 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
1411int 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 Welte268bb402009-02-01 19:11:56 +00001424
1425int 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 Welte5083b0b2009-02-02 19:20:52 +00001436 msgb_tlv_put(msg, NM_ATT_BS11_ABIS_EXT_TIME, sizeof(aet), (u_int8_t *) &aet);
Harald Welte268bb402009-02-01 19:11:56 +00001437
1438 return abis_nm_sendmsg(bts, msg);
1439}