libosmocore  0.9.3.20160317
Osmocom core library
prim.h
Go to the documentation of this file.
1 #pragma once
2 
9 #include <stdint.h>
10 #include <osmocom/core/msgb.h>
11 
12 #define OSMO_PRIM(prim, op) ((prim << 8) | (op & 0xFF))
13 #define OSMO_PRIM_HDR(oph) OSMO_PRIM((oph)->primitive, (oph)->operation)
14 
21 };
22 
23 extern const struct value_string osmo_prim_op_names[5];
24 
25 #define _SAP_GSM_SHIFT 24
26 
27 #define _SAP_GSM_BASE (0x01 << _SAP_GSM_SHIFT)
28 #define _SAP_TETRA_BASE (0x02 << _SAP_GSM_SHIFT)
29 #define _SAP_SS7_BASE (0x03 << _SAP_GSM_SHIFT)
30 
32 struct osmo_prim_hdr {
33  unsigned int sap;
34  unsigned int primitive;
35  enum osmo_prim_operation operation;
36  struct msgb *msg;
37 };
38 
46 static inline void
47 osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap,
48  unsigned int primitive, enum osmo_prim_operation operation,
49  struct msgb *msg)
50 {
51  oph->sap = sap;
52  oph->primitive = primitive;
53  oph->operation = operation;
54  oph->msg = msg;
55 }
56 
58 typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx);
59