introduce GSM primitive definitions
authorHarald Welte <laforge@gnumonks.org>
Thu, 23 Jun 2011 13:04:47 +0000 (15:04 +0200)
committerHarald Welte <laforge@gnumonks.org>
Thu, 23 Jun 2011 13:04:47 +0000 (15:04 +0200)
The idea here is to use the osmocom core primitive code ot abstract out
primitives for inter-layer comunication in GSM.

include/osmocom/core/prim.h
include/osmocom/gsm/Makefile.am
include/osmocom/gsm/prim.h [new file with mode: 0644]

index 5494f3c..e892c62 100644 (file)
@@ -2,6 +2,7 @@
 #define OSMO_PRIMITIVE_H
 
 #include <stdint.h>
+#include <osmocom/core/msgb.h>
 
 enum osmo_prim_operation {
        PRIM_OP_REQUEST,
@@ -10,6 +11,11 @@ enum osmo_prim_operation {
        PRIM_OP_CONFIRM,
 };
 
+#define _SAP_GSM_SHIFT 24
+
+#define _SAP_GSM_BASE  (0x01 << _SAP_GSM_SHIFT)
+#define _SAP_TETRA_BASE        (0x02 << _SAP_GSM_SHIFT)
+
 struct osmo_prim_hdr {
        unsigned int sap;
        unsigned int primitive;
@@ -17,4 +23,16 @@ struct osmo_prim_hdr {
        struct msgb *msg;       /* message containing associated data */
 };
 
+static inline void
+osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap,
+               unsigned int primitive, enum osmo_prim_operation operation,
+               struct msgb *msg)
+{
+       oph->sap = sap;
+       oph->primitive = primitive;
+       oph->operation = operation;
+       oph->msg = msg;
+}
+
+typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx);
 #endif
index 547933e..aa7b1a9 100644 (file)
@@ -1,6 +1,6 @@
 osmogsm_HEADERS = a5.h comp128.h gsm0808.h gsm48_ie.h mncc.h rxlev_stat.h \
                  gsm0480.h gsm48.h gsm_utils.h rsl.h tlv.h abis_nm.h \
-                 sysinfo.h
+                 sysinfo.h prim.h
 
 SUBDIRS = protocol
 
diff --git a/include/osmocom/gsm/prim.h b/include/osmocom/gsm/prim.h
new file mode 100644 (file)
index 0000000..95cbb12
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef OSMO_GSM_PRIM_H
+#define OSMO_GSM_PRIM_H
+
+#include <osmocom/core/prim.h>
+
+/* enumeration of GSM related SAPs */
+enum osmo_gsm_sap {
+       SAP_GSM_PH      = _SAP_GSM_BASE,
+       SAP_GSM_DL,
+       SAP_GSM_MDL,
+};
+
+#endif