summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-05-06 17:31:19 +0200
committerHarald Welte <laforge@gnumonks.org>2010-06-20 16:28:35 +0200
commit94f0f9ddc45ac3128f5f4c50973fe3d41c324a88 (patch)
treefe3a078010132cb9352066794740063ed0d56687
parent9575fd07323a81cf11a65099e2de161b1f886ff4 (diff)
OML: Add 'struct nm_attr' representing a single OML attributelaforge/nm_attr
-rw-r--r--openbsc/include/openbsc/abis_nm.h18
-rw-r--r--openbsc/include/openbsc/gsm_data.h5
-rw-r--r--openbsc/src/abis_nm.c48
3 files changed, 67 insertions, 4 deletions
diff --git a/openbsc/include/openbsc/abis_nm.h b/openbsc/include/openbsc/abis_nm.h
index b3bf27e9b..2478fd6c5 100644
--- a/openbsc/include/openbsc/abis_nm.h
+++ b/openbsc/include/openbsc/abis_nm.h
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <osmocore/tlv.h>
+#include <osmocore/linuxlist.h>
#include <osmocore/protocol/gsm_12_21.h>
struct cell_global_id {
@@ -55,9 +56,24 @@ struct ipac_bcch_info {
u_int8_t ca_list_si1[16];
};
+struct nm_attr {
+ struct llist_head list;
+ uint8_t tag;
+ uint16_t len;
+ uint8_t val[0];
+};
+
+struct nm_attr *nm_attr_alloc(struct llist_head *nma_list,
+ uint8_t tag, uint16_t len);
+struct nm_attr *nm_attr_realloc(struct llist_head *nma_list,
+ struct nm_attr *orig, uint16_t new_len);
+struct nm_attr *nm_attr_get(struct llist_head *nma_list, uint8_t tag);
+void nm_attr_free(struct nm_attr *nma);
+
+extern const struct tlv_definition nm_att_tlvdef;
+
extern const struct value_string abis_nm_adm_state_names[];
extern const struct value_string abis_nm_obj_class_names[];
-extern const struct tlv_definition nm_att_tlvdef;
/* PUBLIC */
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 4dcdd4bf0..459bc9a87 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -174,6 +174,8 @@ struct gsm_nm_state {
u_int8_t operational;
u_int8_t administrative;
u_int8_t availability;
+ /* linked list of 'struct nm_attr' */
+ struct llist_head nma_list;
};
/*
@@ -335,7 +337,6 @@ struct gsm_bts_trx_ts {
unsigned int flags;
struct gsm_nm_state nm_state;
- struct tlv_parsed nm_attr;
u_int8_t nm_chan_comb;
struct {
@@ -373,7 +374,6 @@ struct gsm_bts_trx {
struct e1inp_sign_link *rsl_link;
struct gsm_nm_state nm_state;
- struct tlv_parsed nm_attr;
struct {
struct gsm_nm_state nm_state;
} bb_transc;
@@ -514,7 +514,6 @@ struct gsm_bts {
/* Abis network management O&M handle */
struct abis_nm_h *nmh;
struct gsm_nm_state nm_state;
- struct tlv_parsed nm_attr;
/* number of this BTS on given E1 link */
u_int8_t bts_nr;
diff --git a/openbsc/src/abis_nm.c b/openbsc/src/abis_nm.c
index 63d9d9c3c..aa89cb42b 100644
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -3027,3 +3027,51 @@ int ipac_parse_bcch_info(struct ipac_bcch_info *binf, u_int8_t *buf)
return 0;
}
+
+void *tall_nmattr_ctx;
+
+struct nm_attr *nm_attr_alloc(struct llist_head *nma_list,
+ uint8_t tag, uint16_t len)
+{
+ struct nm_attr *na;
+
+ na = talloc_zero_size(tall_nmattr_ctx, sizeof(*na)+len);
+ na->tag = tag;
+ na->len = len;
+
+ llist_add(&na->list, nma_list);
+
+ return na;
+}
+
+struct nm_attr *nm_attr_realloc(struct llist_head *nma_list,
+ struct nm_attr *orig, uint16_t new_len)
+{
+ struct nm_attr *new;
+
+ llist_del(&orig->list);
+
+ new = talloc_realloc_size(tall_nmattr_ctx, orig, new_len);
+
+ llist_add(&new->list, nma_list);
+
+ return new;
+}
+
+struct nm_attr *nm_attr_get(struct llist_head *nma_list, uint8_t tag)
+{
+ struct nm_attr *na;
+
+ llist_for_each_entry(na, nma_list, list) {
+ if (na->tag == tag)
+ return na;
+ }
+
+ return NULL;
+}
+
+void nm_attr_free(struct nm_attr *nma)
+{
+ llist_del(&nma->list);
+ talloc_free(nma);
+}