summaryrefslogtreecommitdiffstats
path: root/src/gsm/abis_nm.c
blob: 934d7cebba7a1258345065bb4dd540f97e8170d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
/* GSM Network Management (OML) messages on the A-bis interface
 * 3GPP TS 12.21 version 8.0.0 Release 1999 / ETSI TS 100 623 V8.0.0 */

/* (C) 2008-2011 by Harald Welte <laforge@gnumonks.org>
 *
 * All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/*! \addtogroup oml
 *  @{
 */

/*! \file abis_nm.c */

#include <stdint.h>
#include <errno.h>

#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/protocol/gsm_12_21.h>
#include <osmocom/gsm/abis_nm.h>

const char abis_nm_ipa_magic[13] = "com.ipaccess";
const char abis_nm_osmo_magic[12] = "org.osmocom";

/*! \brief unidirectional messages from BTS to BSC */
const enum abis_nm_msgtype abis_nm_reports[4] = {
	NM_MT_SW_ACTIVATED_REP,
	NM_MT_TEST_REP,
	NM_MT_STATECHG_EVENT_REP,
	NM_MT_FAILURE_EVENT_REP,
};

/*! \brief messages without ACK/NACK */
const enum abis_nm_msgtype abis_nm_no_ack_nack[3] = {
	NM_MT_MEAS_RES_REQ,
	NM_MT_STOP_MEAS,
	NM_MT_START_MEAS,
};

/*! \brief messages related to software load */
const enum abis_nm_msgtype abis_nm_sw_load_msgs[9] = {
	NM_MT_LOAD_INIT_ACK,
	NM_MT_LOAD_INIT_NACK,
	NM_MT_LOAD_SEG_ACK,
	NM_MT_LOAD_ABORT,
	NM_MT_LOAD_END_ACK,
	NM_MT_LOAD_END_NACK,
	//NM_MT_SW_ACT_REQ,
	NM_MT_ACTIVATE_SW_ACK,
	NM_MT_ACTIVATE_SW_NACK,
	NM_MT_SW_ACTIVATED_REP,
};

/*! \brief All NACKs (negative acknowledgements */
const enum abis_nm_msgtype abis_nm_nacks[33] = {
	NM_MT_LOAD_INIT_NACK,
	NM_MT_LOAD_END_NACK,
	NM_MT_SW_ACT_REQ_NACK,
	NM_MT_ACTIVATE_SW_NACK,
	NM_MT_ESTABLISH_TEI_NACK,
	NM_MT_CONN_TERR_SIGN_NACK,
	NM_MT_DISC_TERR_SIGN_NACK,
	NM_MT_CONN_TERR_TRAF_NACK,
	NM_MT_DISC_TERR_TRAF_NACK,
	NM_MT_CONN_MDROP_LINK_NACK,
	NM_MT_DISC_MDROP_LINK_NACK,
	NM_MT_SET_BTS_ATTR_NACK,
	NM_MT_SET_RADIO_ATTR_NACK,
	NM_MT_SET_CHAN_ATTR_NACK,
	NM_MT_PERF_TEST_NACK,
	NM_MT_SEND_TEST_REP_NACK,
	NM_MT_STOP_TEST_NACK,
	NM_MT_STOP_EVENT_REP_NACK,
	NM_MT_REST_EVENT_REP_NACK,
	NM_MT_CHG_ADM_STATE_NACK,
	NM_MT_CHG_ADM_STATE_REQ_NACK,
	NM_MT_REP_OUTST_ALARMS_NACK,
	NM_MT_CHANGEOVER_NACK,
	NM_MT_OPSTART_NACK,
	NM_MT_REINIT_NACK,
	NM_MT_SET_SITE_OUT_NACK,
	NM_MT_CHG_HW_CONF_NACK,
	NM_MT_GET_ATTR_NACK,
	NM_MT_SET_ALARM_THRES_NACK,
	NM_MT_BS11_BEGIN_DB_TX_NACK,
	NM_MT_BS11_END_DB_TX_NACK,
	NM_MT_BS11_CREATE_OBJ_NACK,
	NM_MT_BS11_DELETE_OBJ_NACK,
};

static const struct value_string nack_names[] = {
	{ NM_MT_LOAD_INIT_NACK,		"SOFTWARE LOAD INIT" },
	{ NM_MT_LOAD_END_NACK,		"SOFTWARE LOAD END" },
	{ NM_MT_SW_ACT_REQ_NACK,	"SOFTWARE ACTIVATE REQUEST" },
	{ NM_MT_ACTIVATE_SW_NACK,	"ACTIVATE SOFTWARE" },
	{ NM_MT_ESTABLISH_TEI_NACK,	"ESTABLISH TEI" },
	{ NM_MT_CONN_TERR_SIGN_NACK,	"CONNECT TERRESTRIAL SIGNALLING" },
	{ NM_MT_DISC_TERR_SIGN_NACK,	"DISCONNECT TERRESTRIAL SIGNALLING" },
	{ NM_MT_CONN_TERR_TRAF_NACK,	"CONNECT TERRESTRIAL TRAFFIC" },
	{ NM_MT_DISC_TERR_TRAF_NACK,	"DISCONNECT TERRESTRIAL TRAFFIC" },
	{ NM_MT_CONN_MDROP_LINK_NACK,	"CONNECT MULTI-DROP LINK" },
	{ NM_MT_DISC_MDROP_LINK_NACK,	"DISCONNECT MULTI-DROP LINK" },
	{ NM_MT_SET_BTS_ATTR_NACK,	"SET BTS ATTRIBUTE" },
	{ NM_MT_SET_RADIO_ATTR_NACK,	"SET RADIO ATTRIBUTE" },
	{ NM_MT_SET_CHAN_ATTR_NACK,	"SET CHANNEL ATTRIBUTE" },
	{ NM_MT_PERF_TEST_NACK,		"PERFORM TEST" },
	{ NM_MT_SEND_TEST_REP_NACK,	"SEND TEST REPORT" },
	{ NM_MT_STOP_TEST_NACK,		"STOP TEST" },
	{ NM_MT_STOP_EVENT_REP_NACK,	"STOP EVENT REPORT" },
	{ NM_MT_REST_EVENT_REP_NACK,	"RESET EVENT REPORT" },
	{ NM_MT_CHG_ADM_STATE_NACK,	"CHANGE ADMINISTRATIVE STATE" },
	{ NM_MT_CHG_ADM_STATE_REQ_NACK,
				"CHANGE ADMINISTRATIVE STATE REQUEST" },
	{ NM_MT_REP_OUTST_ALARMS_NACK,	"REPORT OUTSTANDING ALARMS" },
	{ NM_MT_CHANGEOVER_NACK,	"CHANGEOVER" },
	{ NM_MT_OPSTART_NACK,		"OPSTART" },
	{ NM_MT_REINIT_NACK,		"REINIT" },
	{ NM_MT_SET_SITE_OUT_NACK,	"SET SITE OUTPUT" },
	{ NM_MT_CHG_HW_CONF_NACK,	"CHANGE HARDWARE CONFIGURATION" },
	{ NM_MT_GET_ATTR_NACK,		"GET ATTRIBUTE" },
	{ NM_MT_SET_ALARM_THRES_NACK,	"SET ALARM THRESHOLD" },
	{ NM_MT_BS11_BEGIN_DB_TX_NACK,	"BS11 BEGIN DATABASE TRANSMISSION" },
	{ NM_MT_BS11_END_DB_TX_NACK,	"BS11 END DATABASE TRANSMISSION" },
	{ NM_MT_BS11_CREATE_OBJ_NACK,	"BS11 CREATE OBJECT" },
	{ NM_MT_BS11_DELETE_OBJ_NACK,	"BS11 DELETE OBJECT" },
	{ 0,				NULL }
};

/*! \brief Get human-readable string for OML NACK message type */
const char *abis_nm_nack_name(uint8_t nack)
{
	return get_value_string(nack_names, nack);
}

/* Section 9.4.43: Manufacturer specific values */
const struct value_string abis_mm_event_cause_names[] = {
	{ OSMO_EVT_CRIT_SW_FATAL,	"Fatal software error" },
	{ OSMO_EVT_CRIT_PROC_STOP,	"Process stopped" },
	{ OSMO_EVT_CRIT_RTP_TOUT,	"RTP error" },
	{ OSMO_EVT_CRIT_BOOT_FAIL,	"Boot failure" },
	{ OSMO_EVT_MAJ_UKWN_MSG,	"Unknown message" },
	{ OSMO_EVT_MAJ_RSL_FAIL,	"RSL failure" },
	{ OSMO_EVT_MAJ_UNSUP_ATTR,	"Unsupported attribute" },
	{ OSMO_EVT_MAJ_NET_CONGEST,	"Network congestion" },
	{ OSMO_EVT_MIN_PAG_TAB_FULL,	"Paging table full" },
	{ OSMO_EVT_WARN_SW_WARN,	"Software warning" },
	{ OSMO_EVT_EXT_ALARM,		"External alarm" },
	{ OSMO_EVT_PCU_VERS,		"PCU version report" },
	{ 0, NULL }
};

const struct value_string abis_nm_pcause_type_names[] = {
	{ NM_PCAUSE_T_X721,	"ISO/CCITT values (X.721)"},
	{ NM_PCAUSE_T_GSM,	"GSM specific values"},
	{ NM_PCAUSE_T_MANUF,	"Manufacturer specific values"},
	{ 0, NULL }
};

/* Chapter 9.4.36 */
static const struct value_string nack_cause_names[] = {
	/* General Nack Causes */
	{ NM_NACK_INCORR_STRUCT,	"Incorrect message structure" },
	{ NM_NACK_MSGTYPE_INVAL,	"Invalid message type value" },
	{ NM_NACK_OBJCLASS_INVAL,	"Invalid Object class value" },
	{ NM_NACK_OBJCLASS_NOTSUPP,	"Object class not supported" },
	{ NM_NACK_BTSNR_UNKN,		"BTS no. unknown" },
	{ NM_NACK_TRXNR_UNKN,		"Baseband Transceiver no. unknown" },
	{ NM_NACK_OBJINST_UNKN,		"Object Instance unknown" },
	{ NM_NACK_ATTRID_INVAL,		"Invalid attribute identifier value" },
	{ NM_NACK_ATTRID_NOTSUPP,	"Attribute identifier not supported" },
	{ NM_NACK_PARAM_RANGE,		"Parameter value outside permitted range" },
	{ NM_NACK_ATTRLIST_INCONSISTENT,"Inconsistency in attribute list" },
	{ NM_NACK_SPEC_IMPL_NOTSUPP,	"Specified implementation not supported" },
	{ NM_NACK_CANT_PERFORM,		"Message cannot be performed" },
	/* Specific Nack Causes */
	{ NM_NACK_RES_NOTIMPL,		"Resource not implemented" },
	{ NM_NACK_RES_NOTAVAIL,		"Resource not available" },
	{ NM_NACK_FREQ_NOTAVAIL,	"Frequency not available" },
	{ NM_NACK_TEST_NOTSUPP,		"Test not supported" },
	{ NM_NACK_CAPACITY_RESTR,	"Capacity restrictions" },
	{ NM_NACK_PHYSCFG_NOTPERFORM,	"Physical configuration cannot be performed" },
	{ NM_NACK_TEST_NOTINIT,		"Test not initiated" },
	{ NM_NACK_PHYSCFG_NOTRESTORE,	"Physical configuration cannot be restored" },
	{ NM_NACK_TEST_NOSUCH,		"No such test" },
	{ NM_NACK_TEST_NOSTOP,		"Test cannot be stopped" },
	{ NM_NACK_MSGINCONSIST_PHYSCFG,	"Message inconsistent with physical configuration" },
	{ NM_NACK_FILE_INCOMPLETE,	"Complete file notreceived" },
	{ NM_NACK_FILE_NOTAVAIL,	"File not available at destination" },
	{ NM_NACK_FILE_NOTACTIVATE,	"File cannot be activate" },
	{ NM_NACK_REQ_NOT_GRANT,	"Request not granted" },
	{ NM_NACK_WAIT,			"Wait" },
	{ NM_NACK_NOTH_REPORT_EXIST,	"Nothing reportable existing" },
	{ NM_NACK_MEAS_NOTSUPP,		"Measurement not supported" },
	{ NM_NACK_MEAS_NOTSTART,	"Measurement not started" },
	{ 0,				NULL }
};

/*! \brief Get human-readable string for NACK cause */
const char *abis_nm_nack_cause_name(uint8_t cause)
{
	return get_value_string(nack_cause_names, cause);
}

/* Chapter 9.4.16: Event Type */
static const struct value_string event_type_names[] = {
	{ NM_EVT_COMM_FAIL,		"communication failure" },
	{ NM_EVT_QOS_FAIL,		"quality of service failure" },
	{ NM_EVT_PROC_FAIL,		"processing failure" },
	{ NM_EVT_EQUIP_FAIL,		"equipment failure" },
	{ NM_EVT_ENV_FAIL,		"environment failure" },
	{ 0,				NULL }
};

/*! \brief Get human-readable string for OML event type */
const char *abis_nm_event_type_name(uint8_t cause)
{
	return get_value_string(event_type_names, cause);
}

/* Chapter 9.4.63: Perceived Severity */
static const struct value_string severity_names[] = {
	{ NM_SEVER_CEASED,		"failure ceased" },
	{ NM_SEVER_CRITICAL,		"critical failure" },
	{ NM_SEVER_MAJOR,		"major failure" },
	{ NM_SEVER_MINOR,		"minor failure" },
	{ NM_SEVER_WARNING,		"warning level failure" },
	{ NM_SEVER_INDETERMINATE,	"indeterminate failure" },
	{ 0,				NULL }
};

/*! \brief Get human-readable string for perceived OML severity */
const char *abis_nm_severity_name(uint8_t cause)
{
	return get_value_string(severity_names, cause);
}

/*! \brief 3GPP TS 12.21 9.4.53 T200 values (in msec) */
const uint8_t abis_nm_t200_ms[] = {
	[T200_SDCCH]		= 5,
	[T200_FACCH_F]		= 5,
	[T200_FACCH_H]		= 5,
	[T200_SACCH_TCH_SAPI0]	= 10,
	[T200_SACCH_SDCCH]	= 10,
	[T200_SDCCH_SAPI3]	= 5,
	[T200_SACCH_TCH_SAPI3]	= 10
};

/*! \brief 3GPP TS 52.021 §9.1 Message Types */
const struct value_string abis_nm_msgtype_names[] = {
	{ NM_MT_LOAD_INIT,		"Load Data Initiate" },				/* §8.3.1 */
	{ NM_MT_LOAD_INIT_ACK,		"Load Data Initiate Ack" },
	{ NM_MT_LOAD_INIT_NACK,		"Load Data Initiate Nack" },
	{ NM_MT_LOAD_SEG,		"Load Data Segment" },				/* §8.3.2 */
	{ NM_MT_LOAD_SEG_ACK,		"Load Data Segment Ack" },
	{ NM_MT_LOAD_ABORT,		"Load Data Abort" },				/* §8.3.3 */
	{ NM_MT_LOAD_END,		"Load Data End" },				/* §8.3.4 */
	{ NM_MT_LOAD_END_ACK,		"Load Data End Ack" },
	{ NM_MT_LOAD_END_NACK,		"Load Data End Nack" },
	{ NM_MT_SW_ACT_REQ,		"SW Activate Request" },			/* §8.3.5 */
	{ NM_MT_SW_ACT_REQ_ACK,		"SW Activate Request Ack" },
	{ NM_MT_SW_ACT_REQ_NACK,	"SW Activate Request Nack" },
	{ NM_MT_ACTIVATE_SW,		"Activate SW" },				/* §8.3.6 */
	{ NM_MT_ACTIVATE_SW_ACK,	"Activate SW Ack" },
	{ NM_MT_ACTIVATE_SW_NACK,	"Activate SW Nack" },
	{ NM_MT_SW_ACTIVATED_REP,	"SW Activated Report" },			/* §8.3.7 */
	{ NM_MT_ESTABLISH_TEI,		"Establish TEI" },				/* §8.4.1 */
	{ NM_MT_ESTABLISH_TEI_ACK,	"Establish TEI Ack" },
	{ NM_MT_ESTABLISH_TEI_NACK,	"Establish TEI Nack" },
	{ NM_MT_CONN_TERR_SIGN,		"Connect Terrestrial Signalling" },		/* §8.4.2 */
	{ NM_MT_CONN_TERR_SIGN_ACK,	"Connect Terrestrial Signalling Ack" },
	{ NM_MT_CONN_TERR_SIGN_NACK,	"Connect Terrestrial Signalling Nack" },
	{ NM_MT_DISC_TERR_SIGN,		"Disconnect Terrestrial Signalling" },		/* §8.4.3 */
	{ NM_MT_DISC_TERR_SIGN_ACK,	"Disconnect Terrestrial Signalling Ack" },
	{ NM_MT_DISC_TERR_SIGN_NACK,	"Disconnect Terrestrial Signalling Nack" },
	{ NM_MT_CONN_TERR_TRAF,		"Connect Terrestrial Traffic" },		/* §8.4.4 */
	{ NM_MT_CONN_TERR_TRAF_ACK,	"Connect Terrestrial Traffic Ack" },
	{ NM_MT_CONN_TERR_TRAF_NACK,	"Connect Terrestrial Traffic Nack" },
	{ NM_MT_DISC_TERR_TRAF,		"Disconnect Terrestrial Traffic" },		/* §8.4.5 */
	{ NM_MT_DISC_TERR_TRAF_ACK,	"Disconnect Terrestrial Traffic Ack" },
	{ NM_MT_DISC_TERR_TRAF_NACK,	"Disconnect Terrestrial Traffic Nack" },
	{ NM_MT_CONN_MDROP_LINK,	"Connect Multi-Drop Link" },			/* §8.5.1 */
	{ NM_MT_CONN_MDROP_LINK_ACK,	"Connect Multi-Drop Link Ack" },
	{ NM_MT_CONN_MDROP_LINK_NACK,	"Connect Multi-Drop Link Nack" },
	{ NM_MT_DISC_MDROP_LINK,	"Disconnect Multi-Drop Link" },			/* §8.5.2 */
	{ NM_MT_DISC_MDROP_LINK_ACK,	"Disconnect Multi-Drop Link Ack" },
	{ NM_MT_DISC_MDROP_LINK_NACK,	"Disconnect Multi-Drop Link Nack" },
	{ NM_MT_SET_BTS_ATTR,		"Set BTS Attributes" },				/* §8.6.1 */
	{ NM_MT_SET_BTS_ATTR_ACK,	"Set BTS Attributes Ack" },
	{ NM_MT_SET_BTS_ATTR_NACK,	"Set BTS Attributes Nack" },
	{ NM_MT_SET_RADIO_ATTR,		"Set Radio Carrier Attributes" },		/* §8.6.2 */
	{ NM_MT_SET_RADIO_ATTR_ACK,	"Set Radio Carrier Attributes Ack" },
	{ NM_MT_SET_RADIO_ATTR_NACK,	"Set Radio Carrier Attributes Nack" },
	{ NM_MT_SET_CHAN_ATTR,		"Set Channel Attributes" },			/* §8.6.3 */
	{ NM_MT_SET_CHAN_ATTR_ACK,	"Set Channel Attributes Ack" },
	{ NM_MT_SET_CHAN_ATTR_NACK,	"Set Channel Attributes Nack" },
	{ NM_MT_PERF_TEST,		"Perform Test" },				/* §8.7.1 */
	{ NM_MT_PERF_TEST_ACK,		"Perform Test Ack" },
	{ NM_MT_PERF_TEST_NACK,		"Perform Test Nack" },
	{ NM_MT_TEST_REP,		"Test Report" },				/* §8.7.2 */
	{ NM_MT_SEND_TEST_REP,		"Send Test Report" },				/* §8.7.3 */
	{ NM_MT_SEND_TEST_REP_ACK,	"Send Test Report Ack" },
	{ NM_MT_SEND_TEST_REP_NACK,	"Send Test Report Nack" },
	{ NM_MT_STOP_TEST,		"Stop Test" },					/* §8.7.4 */
	{ NM_MT_STOP_TEST_ACK,		"Stop Test Ack" },
	{ NM_MT_STOP_TEST_NACK,		"Stop Test Nack" },
	{ NM_MT_STATECHG_EVENT_REP,	"State Changed Event Report" },			/* §8.8.1 */
	{ NM_MT_FAILURE_EVENT_REP,	"Failure Event Report" },			/* §8.8.2 */
	{ NM_MT_STOP_EVENT_REP,		"Stop Sending Event Reports" },			/* §8.8.3 */
	{ NM_MT_STOP_EVENT_REP_ACK,	"Stop Sending Event Reports Ack" },
	{ NM_MT_STOP_EVENT_REP_NACK,	"Stop Sending Event Reports Nack" },
	{ NM_MT_REST_EVENT_REP,		"Restart Sending Event Reports" },		/* §8.8.4 */
	{ NM_MT_REST_EVENT_REP_ACK,	"Restart Sending Event Reports Ack" },
	{ NM_MT_REST_EVENT_REP_NACK,	"Restart Sending Event Reports Nack" },
	{ NM_MT_CHG_ADM_STATE,		"Change Administrative State" },		/* §8.8.5 */
	{ NM_MT_CHG_ADM_STATE_ACK,	"Change Administrative State Ack" },
	{ NM_MT_CHG_ADM_STATE_NACK,	"Change Administrative State Nack" },
	{ NM_MT_CHG_ADM_STATE_REQ,	"Change Administrative State Request" },	/* §8.8.6 */
	{ NM_MT_CHG_ADM_STATE_REQ_ACK,	"Change Administrative State Request Ack" },
	{ NM_MT_CHG_ADM_STATE_REQ_NACK,	"Change Administrative State Request Nack" },
	{ NM_MT_REP_OUTST_ALARMS,	"Report Outstanding Alarms" },			/* §8.8.7 */
	{ NM_MT_REP_OUTST_ALARMS_ACK,	"Report Outstanding Alarms Ack" },
	{ NM_MT_REP_OUTST_ALARMS_NACK,	"Report Outstanding Alarms Nack" },
	{ NM_MT_CHANGEOVER,		"Changeover" },					/* §8.9.1 */
	{ NM_MT_CHANGEOVER_ACK,		"Changeover Ack" },
	{ NM_MT_CHANGEOVER_NACK,	"Changeover Nack" },
	{ NM_MT_OPSTART,		"Opstart" },					/* §8.9.2 */
	{ NM_MT_OPSTART_ACK,		"Opstart Ack" },
	{ NM_MT_OPSTART_NACK,		"Opstart Nack" },
	{ NM_MT_REINIT,			"Reinitialize" },				/* §8.9.3 */
	{ NM_MT_REINIT_ACK,		"Reinitialize Ack" },
	{ NM_MT_REINIT_NACK,		"Reinitialize Nack" },
	{ NM_MT_SET_SITE_OUT,		"Set Site Outputs" },				/* §8.9.4 */
	{ NM_MT_SET_SITE_OUT_ACK,	"Set Site Outputs Ack" },
	{ NM_MT_SET_SITE_OUT_NACK,	"Set Site Outputs Nack" },
	{ NM_MT_CHG_HW_CONF,		"Change HW Configuration" },			/* §8.9.5 */
	{ NM_MT_CHG_HW_CONF_ACK,	"Change HW Configuration Ack" },
	{ NM_MT_CHG_HW_CONF_NACK,	"Change HW Configuration Nack" },
	{ NM_MT_MEAS_RES_REQ,		"Measurement Result Request" },			/* §8.10.1 */
	{ NM_MT_MEAS_RES_RESP,		"Measurement Result Response" },		/* §8.10.2 */
	{ NM_MT_STOP_MEAS,		"Stop Measurement" },				/* §8.10.4 */
	{ NM_MT_START_MEAS,		"Start Measurement" },				/* §8.10.3 */
	{ NM_MT_GET_ATTR,		"Get Attributes" },				/* §8.11.1 */
	{ NM_MT_GET_ATTR_RESP,		"Get Attributes Response" },			/* §8.11.3 */
	{ NM_MT_GET_ATTR_NACK,		"Get Attributes Nack" },
	{ NM_MT_SET_ALARM_THRES,	"Set Alarm Threshold" },			/* §8.11.2 */
	{ NM_MT_SET_ALARM_THRES_ACK,	"Set Alarm Threshold Ack" },
	{ NM_MT_SET_ALARM_THRES_NACK,	"Set Alarm Threshold Nack" },
	{ 0, NULL }
};

/*! \brief 3GPP TS 52.021 §9.4 Attributes and Parameters */
const struct value_string abis_nm_att_names[] = {
	{ NM_ATT_ABIS_CHANNEL,		"Abis Channel" },			/* §9.4.1 */
	{ NM_ATT_ADD_INFO,		"Additional Info" },			/* §9.4.2 */
	{ NM_ATT_ADD_TEXT,		"Additional Text" },			/* §9.4.3 */
	{ NM_ATT_ADM_STATE,		"Administrative State" },		/* §9.4.4 */
	{ NM_ATT_ARFCN_LIST,		"ARFCN List" },				/* §9.4.5 */
	{ NM_ATT_AUTON_REPORT,		"Autonomously Report" },		/* §9.4.6 */
	{ NM_ATT_AVAIL_STATUS,		"Availability Status" },		/* §9.4.7 */
	{ NM_ATT_BCCH_ARFCN,		"BCCH ARFCN" },				/* §9.4.8 */
	{ NM_ATT_BSIC,			"BSIC" },				/* §9.4.9 */
	{ NM_ATT_BTS_AIR_TIMER,		"BTS Air Timer" },			/* §9.4.10 */
	{ NM_ATT_CCCH_L_I_P,		"CCCH Load Indication Period" },	/* §9.4.11 */
	{ NM_ATT_CCCH_L_T,		"CCCH Load Threshold" },		/* §9.4.12 */
	{ NM_ATT_CHAN_COMB,		"Channel Combination" },		/* §9.4.13 */
	{ NM_ATT_CONN_FAIL_CRIT,	"Connection Failure Criterion" },	/* §9.4.14 */
	{ NM_ATT_DEST,			"Destination" },			/* §9.4.15 */
	{ NM_ATT_EVENT_TYPE,		"Event Type" },				/* §9.4.16 */
	{ NM_ATT_FILE_DATA,		"File Data" },				/* §9.4.17 */
	{ NM_ATT_FILE_ID,		"File Id" },				/* §9.4.18 */
	{ NM_ATT_FILE_VERSION,		"File Version" },			/* §9.4.19 */
	{ NM_ATT_GSM_TIME,		"GSM Time" },				/* §9.4.20 */
	{ NM_ATT_HSN,			"HSN" },				/* §9.4.21 */
	{ NM_ATT_HW_CONFIG,		"HW Configuration" },			/* §9.4.22 */
	{ NM_ATT_HW_DESC,		"HW Description" },			/* §9.4.23 */
	{ NM_ATT_INTAVE_PARAM,		"Intave Parameter" },			/* §9.4.24 */
	{ NM_ATT_INTERF_BOUND,		"Interference level Boundaries" },	/* §9.4.25 */
	{ NM_ATT_LIST_REQ_ATTR,		"List of Required Attributes" },	/* §9.4.26 */
	{ NM_ATT_MAIO,			"MAIO" },				/* §9.4.27 */
	{ NM_ATT_MANUF_STATE,		"Manufacturer Dependent State" },	/* §9.4.28 */
	{ NM_ATT_MANUF_THRESH,		"Manufacturer Dependent Thresholds" },	/* §9.4.29 */
	{ NM_ATT_MANUF_ID,		"Manufacturer Id" },			/* §9.4.30 */
	{ NM_ATT_MAX_TA,		"Max Timing Advance" },			/* §9.4.31 */
	{ NM_ATT_MEAS_RES,		"Measurement Result" },			/* §9.4.32 */
	{ NM_ATT_MEAS_TYPE,		"Measurement Type" },			/* §9.4.33 */
	{ NM_ATT_MDROP_LINK,		"Multi-drop BSC Link" },		/* §9.4.34 */
	{ NM_ATT_MDROP_NEXT,		"Multi-drop next BTS Link" },		/* §9.4.35 */
	{ NM_ATT_NACK_CAUSES,		"Nack Causes" },			/* §9.4.36 */
	{ NM_ATT_NY1,			"Ny1" },				/* §9.4.37 */
	{ NM_ATT_OPER_STATE,		"Operational State" },			/* §9.4.38 */
	{ NM_ATT_OVERL_PERIOD,		"Overload Period" },			/* §9.4.39 */
	{ NM_ATT_PHYS_CONF,		"Physical Config" },			/* §9.4.40 */
	{ NM_ATT_POWER_CLASS,		"Power Class" },			/* §9.4.41 */
	{ NM_ATT_POWER_THRESH,		"Power Output Thresholds" },		/* §9.4.42 */
	{ NM_ATT_PROB_CAUSE,		"Probable Cause" },			/* §9.4.43 */
	{ NM_ATT_RACH_B_THRESH,		"RACH Busy Threshold" },		/* §9.4.44 */
	{ NM_ATT_LDAVG_SLOTS,		"RACH Load Averaging Slots" },		/* §9.4.45 */
	{ NM_ATT_RAD_SUBC,		"Radio Sub Channel" },			/* §9.4.46 */
	{ NM_ATT_RF_MAXPOWR_R,		"RF Max Power Reduction" },		/* §9.4.47 */
	{ NM_ATT_SITE_INPUTS,		"Site Inputs" },			/* §9.4.48 */
	{ NM_ATT_SITE_OUTPUTS,		"Site Outputs" },			/* §9.4.49 */
	{ NM_ATT_SOURCE,		"Source" },				/* §9.4.50 */
	{ NM_ATT_SPEC_PROB,		"Specific Problems" },			/* §9.4.51 */
	{ NM_ATT_START_TIME,		"Starting Time" },			/* §9.4.52 */
	{ NM_ATT_T200,			"T200" },				/* §9.4.53 */
	{ NM_ATT_TEI,			"TEI" },				/* §9.4.54 */
	{ NM_ATT_TEST_DUR,		"Test Duration" },			/* §9.4.55 */
	{ NM_ATT_TEST_NO,		"Test No" },				/* §9.4.56 */
	{ NM_ATT_TEST_REPORT,		"Test Report Info" },			/* §9.4.57 */
	{ NM_ATT_VSWR_THRESH,		"VSWR Thresholds" },			/* §9.4.58 */
	{ NM_ATT_WINDOW_SIZE,		"Window Size" },			/* §9.4.59 */
	{ NM_ATT_TSC,			"TSC" },				/* §9.4.60 */
	{ NM_ATT_SW_CONFIG,		"SW Configuration" },			/* §9.4.61 */
	{ NM_ATT_SW_DESCR,		"SW Description" },			/* §9.4.62 */
	{ NM_ATT_SEVERITY,		"Perceived Severity" },			/* §9.4.63 */
	{ NM_ATT_GET_ARI,		"Get Attribute Response Info" },	/* §9.4.64 */
	{ NM_ATT_OUTST_ALARM,		"Outstanding Alarm Sequence" },		/* §9.4.65 */
	{ NM_ATT_HW_CONF_CHG,		"HW Conf Change Info" },		/* §9.4.66 */
	{ 0, NULL }
};

/*! \brief Attributes that the BSC can set, not only get, according to Section 9.4 */
const enum abis_nm_attr abis_nm_att_settable[] = {
	NM_ATT_ADD_INFO,
	NM_ATT_ADD_TEXT,
	NM_ATT_DEST,
	NM_ATT_EVENT_TYPE,
	NM_ATT_FILE_DATA,
	NM_ATT_GET_ARI,
	NM_ATT_HW_CONF_CHG,
	NM_ATT_LIST_REQ_ATTR,
	NM_ATT_MDROP_LINK,
	NM_ATT_MDROP_NEXT,
	NM_ATT_NACK_CAUSES,
	NM_ATT_OUTST_ALARM,
	NM_ATT_PHYS_CONF,
	NM_ATT_PROB_CAUSE,
	NM_ATT_RAD_SUBC,
	NM_ATT_SOURCE,
	NM_ATT_SPEC_PROB,
	NM_ATT_START_TIME,
	NM_ATT_TEST_DUR,
	NM_ATT_TEST_NO,
	NM_ATT_TEST_REPORT,
	NM_ATT_WINDOW_SIZE,
	NM_ATT_SEVERITY,
	NM_ATT_MEAS_RES,
	NM_ATT_MEAS_TYPE,
};

/*! \brief GSM A-bis OML IPA TLV parser definition */
const struct tlv_definition abis_nm_att_tlvdef_ipa = {
	.def = {
		/* ip.access specifics */
		[NM_ATT_IPACC_DST_IP] =		{ TLV_TYPE_FIXED, 4 },
		[NM_ATT_IPACC_DST_IP_PORT] =	{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_IPACC_STREAM_ID] =	{ TLV_TYPE_TV, },
		[NM_ATT_IPACC_SEC_OML_CFG] =	{ TLV_TYPE_FIXED, 6 },
		[NM_ATT_IPACC_IP_IF_CFG] =	{ TLV_TYPE_FIXED, 8 },
		[NM_ATT_IPACC_IP_GW_CFG] =	{ TLV_TYPE_FIXED, 12 },
		[NM_ATT_IPACC_IN_SERV_TIME] =	{ TLV_TYPE_FIXED, 4 },
		[NM_ATT_IPACC_LOCATION] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_PAGING_CFG] =	{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_IPACC_UNIT_ID] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_UNIT_NAME] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_SNMP_CFG] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_PRIM_OML_CFG_LIST] = { TLV_TYPE_TL16V },
		[NM_ATT_IPACC_NV_FLAGS] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_FREQ_CTRL] =	{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_IPACC_PRIM_OML_FB_TOUT] = { TLV_TYPE_TL16V },
		[NM_ATT_IPACC_CUR_SW_CFG] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_TIMING_BUS] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_CGI] =		{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_RAC] =		{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_OBJ_VERSION] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_GPRS_PAGING_CFG]= { TLV_TYPE_TL16V },
		[NM_ATT_IPACC_NSEI] =		{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_BVCI] =		{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_NSVCI] =		{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_NS_CFG] =		{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_BSSGP_CFG] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_NS_LINK_CFG] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_RLC_CFG] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_ALM_THRESH_LIST]=	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_MONIT_VAL_LIST] = { TLV_TYPE_TL16V },
		[NM_ATT_IPACC_TIB_CONTROL] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_SUPP_FEATURES] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_CODING_SCHEMES] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_RLC_CFG_2] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_HEARTB_TOUT] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_UPTIME] =		{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_RLC_CFG_3] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_SSL_CFG] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_SEC_POSSIBLE] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_IML_SSL_STATE] =	{ TLV_TYPE_TL16V },
		[NM_ATT_IPACC_REVOC_DATE] =	{ TLV_TYPE_TL16V },
	},
};

/*! \brief GSM A-bis OML TLV parser definition */
const struct tlv_definition abis_nm_att_tlvdef = {
	.def = {
		[NM_ATT_ABIS_CHANNEL] =		{ TLV_TYPE_FIXED, 3 },
		[NM_ATT_ADD_INFO] =		{ TLV_TYPE_TL16V },
		[NM_ATT_ADD_TEXT] =		{ TLV_TYPE_TL16V },
		[NM_ATT_ADM_STATE] =		{ TLV_TYPE_TV },
		[NM_ATT_ARFCN_LIST]=		{ TLV_TYPE_TL16V },
		[NM_ATT_AUTON_REPORT] =		{ TLV_TYPE_TV },
		[NM_ATT_AVAIL_STATUS] =		{ TLV_TYPE_TL16V },
		[NM_ATT_BCCH_ARFCN] =		{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_BSIC] =			{ TLV_TYPE_TV },
		[NM_ATT_BTS_AIR_TIMER] =	{ TLV_TYPE_TV },
		[NM_ATT_CCCH_L_I_P] =		{ TLV_TYPE_TV },
		[NM_ATT_CCCH_L_T] =		{ TLV_TYPE_TV },
		[NM_ATT_CHAN_COMB] =		{ TLV_TYPE_TV },
		[NM_ATT_CONN_FAIL_CRIT] =	{ TLV_TYPE_TL16V },
		[NM_ATT_DEST] =			{ TLV_TYPE_TL16V },
		[NM_ATT_EVENT_TYPE] =		{ TLV_TYPE_TV },
		[NM_ATT_FILE_DATA] =		{ TLV_TYPE_TL16V },
		[NM_ATT_FILE_ID] =		{ TLV_TYPE_TL16V },
		[NM_ATT_FILE_VERSION] =		{ TLV_TYPE_TL16V },
		[NM_ATT_GSM_TIME] =		{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_HSN] =			{ TLV_TYPE_TV },
		[NM_ATT_HW_CONFIG] =		{ TLV_TYPE_TL16V },
		[NM_ATT_HW_DESC] =		{ TLV_TYPE_TL16V },
		[NM_ATT_INTAVE_PARAM] =		{ TLV_TYPE_TV },
		[NM_ATT_INTERF_BOUND] =		{ TLV_TYPE_FIXED, 6 },
		[NM_ATT_LIST_REQ_ATTR] =	{ TLV_TYPE_TL16V },
		[NM_ATT_MAIO] =			{ TLV_TYPE_TV },
		[NM_ATT_MANUF_STATE] =		{ TLV_TYPE_TV },
		[NM_ATT_MANUF_THRESH] =		{ TLV_TYPE_TL16V },
		[NM_ATT_MANUF_ID] =		{ TLV_TYPE_TL16V },
		[NM_ATT_MAX_TA] =		{ TLV_TYPE_TV },
		[NM_ATT_MDROP_LINK] =		{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_MDROP_NEXT] =		{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_NACK_CAUSES] =		{ TLV_TYPE_TV },
		[NM_ATT_NY1] =			{ TLV_TYPE_TV },
		[NM_ATT_OPER_STATE] =		{ TLV_TYPE_TV },
		[NM_ATT_OVERL_PERIOD] =		{ TLV_TYPE_TL16V },
		[NM_ATT_PHYS_CONF] =		{ TLV_TYPE_TL16V },
		[NM_ATT_POWER_CLASS] =		{ TLV_TYPE_TV },
		[NM_ATT_POWER_THRESH] =		{ TLV_TYPE_FIXED, 3 },
		[NM_ATT_PROB_CAUSE] =		{ TLV_TYPE_FIXED, 3 },
		[NM_ATT_RACH_B_THRESH] =	{ TLV_TYPE_TV },
		[NM_ATT_LDAVG_SLOTS] =		{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_RAD_SUBC] =		{ TLV_TYPE_TV },
		[NM_ATT_RF_MAXPOWR_R] =		{ TLV_TYPE_TV },
		[NM_ATT_SITE_INPUTS] =		{ TLV_TYPE_TL16V },
		[NM_ATT_SITE_OUTPUTS] =		{ TLV_TYPE_TL16V },
		[NM_ATT_SOURCE] =		{ TLV_TYPE_TL16V },
		[NM_ATT_SPEC_PROB] =		{ TLV_TYPE_TV },
		[NM_ATT_START_TIME] =		{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_T200] =			{ TLV_TYPE_FIXED, 7 },
		[NM_ATT_TEI] =			{ TLV_TYPE_TV },
		[NM_ATT_TEST_DUR] =		{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_TEST_NO] =		{ TLV_TYPE_TV },
		[NM_ATT_TEST_REPORT] =		{ TLV_TYPE_TL16V },
		[NM_ATT_VSWR_THRESH] =		{ TLV_TYPE_FIXED, 2 },
		[NM_ATT_WINDOW_SIZE] = 		{ TLV_TYPE_TV },
		[NM_ATT_TSC] =			{ TLV_TYPE_TV },
		[NM_ATT_SW_CONFIG] =		{ TLV_TYPE_TL16V },
		[NM_ATT_SEVERITY] = 		{ TLV_TYPE_TV },
		[NM_ATT_GET_ARI] =		{ TLV_TYPE_TL16V },
		[NM_ATT_HW_CONF_CHG] = 		{ TLV_TYPE_TL16V },
		[NM_ATT_OUTST_ALARM] =		{ TLV_TYPE_TV },
		[NM_ATT_MEAS_RES] =		{ TLV_TYPE_TL16V },
	},
};

/*! \brief org.osmocom GSM A-bis OML TLV parser definition */
const struct tlv_definition abis_nm_osmo_att_tlvdef = {
	.def = {
		[NM_ATT_OSMO_REDUCEPOWER] =	{ TLV_TYPE_TV },
	},
};

/*! \brief Human-readable strings for A-bis OML Object Class */
const struct value_string abis_nm_msg_disc_names[] = {
	{ ABIS_OM_MDISC_FOM,	"FOM" },
	{ ABIS_OM_MDISC_MMI,	"MMI" },
	{ ABIS_OM_MDISC_TRAU,	"TRAU" },
	{ ABIS_OM_MDISC_MANUF,	"MANUF" },
	{ 0, NULL }
};

/*! \brief Human-readable strings for A-bis OML Object Class */
const struct value_string abis_nm_obj_class_names[] = {
	{ NM_OC_SITE_MANAGER,	"SITE-MANAGER" },
	{ NM_OC_BTS,		"BTS" },
	{ NM_OC_RADIO_CARRIER,	"RADIO-CARRIER" },
	{ NM_OC_BASEB_TRANSC,	"BASEBAND-TRANSCEIVER" },
	{ NM_OC_CHANNEL,	"CHANNEL" },
	{ NM_OC_BS11_ADJC,	"ADJC" },
	{ NM_OC_BS11_HANDOVER,	"HANDOVER" },
	{ NM_OC_BS11_PWR_CTRL,	"POWER-CONTROL" },
	{ NM_OC_BS11_BTSE,	"BTSE" },
	{ NM_OC_BS11_RACK,	"RACK" },
	{ NM_OC_BS11_TEST,	"TEST" },
	{ NM_OC_BS11_ENVABTSE,	"ENVABTSE" },
	{ NM_OC_BS11_BPORT,	"BPORT" },
	{ NM_OC_GPRS_NSE,	"GPRS-NSE" },
	{ NM_OC_GPRS_CELL,	"GPRS-CELL" },
	{ NM_OC_GPRS_NSVC,	"GPRS-NSVC" },
	{ NM_OC_BS11,		"SIEMENSHW" },
	{ 0,			NULL }
};

/*! \brief Get human-readable string for OML Operational State */
const char *abis_nm_opstate_name(uint8_t os)
{
	switch (os) {
	case NM_OPSTATE_DISABLED:
		return "Disabled";
	case NM_OPSTATE_ENABLED:
		return "Enabled";
	case NM_OPSTATE_NULL:
		return "NULL";
	default:
		return "RFU";
	}
}

/* Chapter 9.4.7 */
static const struct value_string avail_names[] = {
	{ 0, 	"In test" },
	{ 1,	"Failed" },
	{ 2,	"Power off" },
	{ 3,	"Off line" },
	/* Not used */
	{ 5,	"Dependency" },
	{ 6,	"Degraded" },
	{ 7,	"Not installed" },
	{ 0xff, "OK" },
	{ 0,	NULL }
};

/*! \brief Get human-readable string for OML Availability State */
const char *abis_nm_avail_name(uint8_t avail)
{
	return get_value_string(avail_names, avail);
}

static const struct value_string test_names[] = {
	/* FIXME: standard test names */
	{ NM_IPACC_TESTNO_CHAN_USAGE, "Channel Usage" },
	{ NM_IPACC_TESTNO_BCCH_CHAN_USAGE, "BCCH Channel Usage" },
	{ NM_IPACC_TESTNO_FREQ_SYNC, "Frequency Synchronization" },
	{ NM_IPACC_TESTNO_BCCH_INFO, "BCCH Info" },
	{ NM_IPACC_TESTNO_TX_BEACON, "Transmit Beacon" },
	{ NM_IPACC_TESTNO_SYSINFO_MONITOR, "System Info Monitor" },
	{ NM_IPACC_TESTNO_BCCCH_MONITOR, "BCCH Monitor" },
	{ 0, NULL }
};

/*! \brief Get human-readable string for OML test */
const char *abis_nm_test_name(uint8_t test)
{
	return get_value_string(test_names, test);
}

/*! \brief Human-readable names for OML administrative state */
const struct value_string abis_nm_adm_state_names[] = {
	{ NM_STATE_LOCKED,	"Locked" },
	{ NM_STATE_UNLOCKED,	"Unlocked" },
	{ NM_STATE_SHUTDOWN,	"Shutdown" },
	{ NM_STATE_NULL,	"NULL" },
	{ 0, NULL }
};

static const enum abis_nm_chan_comb chcomb4pchan[] = {
	[GSM_PCHAN_NONE]	= 0xff,
	[GSM_PCHAN_CCCH]	= NM_CHANC_mainBCCH,
	[GSM_PCHAN_CCCH_SDCCH4]	= NM_CHANC_BCCHComb,
	[GSM_PCHAN_TCH_F]	= NM_CHANC_TCHFull,
	[GSM_PCHAN_TCH_H]	= NM_CHANC_TCHHalf,
	[GSM_PCHAN_SDCCH8_SACCH8C] = NM_CHANC_SDCCH,
	[GSM_PCHAN_PDCH]	= NM_CHANC_IPAC_PDCH,
	[GSM_PCHAN_TCH_F_PDCH]	= NM_CHANC_IPAC_TCHFull_PDCH,
	[GSM_PCHAN_UNKNOWN]	= 0xff,
	[GSM_PCHAN_CCCH_SDCCH4_CBCH]	= NM_CHANC_BCCH_CBCH,
	[GSM_PCHAN_SDCCH8_SACCH8C_CBCH] = NM_CHANC_SDCCH_CBCH,
	[GSM_PCHAN_TCH_F_TCH_H_PDCH]	= NM_CHANC_OSMO_TCHFull_TCHHalf_PDCH,
	/* FIXME: bounds check */
};

/*! \brief Pack 3GPP TS 12.21 § 8.8.2 Failure Event Report into msgb */
struct msgb *abis_nm_fail_evt_rep(enum abis_nm_event_type t,
				  enum abis_nm_severity s,
				  enum abis_nm_pcause_type ct,
				  uint16_t cause_value, const char *fmt, ...)
{
	va_list ap;
	struct msgb *nmsg;

	va_start(ap, fmt);
	nmsg = abis_nm_fail_evt_vrep(t, s, ct, cause_value, fmt, ap);
	va_end(ap);

	return nmsg;
}

/*! \brief Pack 3GPP TS 12.21 § 8.8.2 Failure Event Report into msgb */
struct msgb *abis_nm_fail_evt_vrep(enum abis_nm_event_type t,
				   enum abis_nm_severity s,
				   enum abis_nm_pcause_type ct,
				   uint16_t cause_value, const char *fmt,
				   va_list ap)
{
	uint8_t cause[3];
	int len;
	char add_text[ABIS_NM_MSG_HEADROOM];
	struct msgb *nmsg = msgb_alloc_headroom(ABIS_NM_MSG_SIZE,
						ABIS_NM_MSG_HEADROOM,
						"OML FAIL EV. REP.");
	if (!nmsg)
		return NULL;

	msgb_tv_put(nmsg, NM_ATT_EVENT_TYPE, t);
	msgb_tv_put(nmsg, NM_ATT_SEVERITY, s);

	cause[0] = ct;
	osmo_store16be(cause_value, cause + 1);

	msgb_tv_fixed_put(nmsg, NM_ATT_PROB_CAUSE, 3, cause);

	len = vsnprintf(add_text, ABIS_NM_MSG_HEADROOM, fmt, ap);
	if (len < 0) {
		msgb_free(nmsg);
		return NULL;
	}
	if (len)
		msgb_tl16v_put(nmsg, NM_ATT_ADD_TEXT, len, (const uint8_t *) add_text);

	return nmsg;
}

/*! \brief Obtain OML Channel Combination for phnsical channel config */
int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan)
{
	if (pchan < ARRAY_SIZE(chcomb4pchan))
		return chcomb4pchan[pchan];

	return -EINVAL;
}

/*! \brief Obtain physical channel config for OML Channel Combination */
enum gsm_phys_chan_config abis_nm_pchan4chcomb(uint8_t chcomb)
{
	int i;
	for (i = 0; i < ARRAY_SIZE(chcomb4pchan); i++) {
		if (chcomb4pchan[i] == chcomb)
			return i;
	}
	return GSM_PCHAN_NONE;
}

/* this is just for compatibility reasons, it is now a macro */
#undef abis_nm_debugp_foh
OSMO_DEPRECATED("Use abis_nm_debugp_foh macro instead")
void abis_nm_debugp_foh(int ss, struct abis_om_fom_hdr *foh)
{
	DEBUGP(ss, "OC=%s(%02x) INST=(%02x,%02x,%02x) ",
		get_value_string(abis_nm_obj_class_names, foh->obj_class),
		foh->obj_class, foh->obj_inst.bts_nr, foh->obj_inst.trx_nr,
		foh->obj_inst.ts_nr);
}

/*! @} */