Harald Welte | 9b21e88 | 2011-06-23 14:14:20 +0200 | [diff] [blame] | 1 | #ifndef OSMO_PRIMITIVE_H |
| 2 | #define OSMO_PRIMITIVE_H |
| 3 | |
| 4 | #include <stdint.h> |
Harald Welte | 5e924a3 | 2011-06-23 15:04:47 +0200 | [diff] [blame] | 5 | #include <osmocom/core/msgb.h> |
Harald Welte | 9b21e88 | 2011-06-23 14:14:20 +0200 | [diff] [blame] | 6 | |
| 7 | enum osmo_prim_operation { |
| 8 | PRIM_OP_REQUEST, |
| 9 | PRIM_OP_RESPONSE, |
| 10 | PRIM_OP_INDICATION, |
| 11 | PRIM_OP_CONFIRM, |
| 12 | }; |
| 13 | |
Harald Welte | 5e924a3 | 2011-06-23 15:04:47 +0200 | [diff] [blame] | 14 | #define _SAP_GSM_SHIFT 24 |
| 15 | |
| 16 | #define _SAP_GSM_BASE (0x01 << _SAP_GSM_SHIFT) |
| 17 | #define _SAP_TETRA_BASE (0x02 << _SAP_GSM_SHIFT) |
| 18 | |
Harald Welte | 9b21e88 | 2011-06-23 14:14:20 +0200 | [diff] [blame] | 19 | struct osmo_prim_hdr { |
| 20 | unsigned int sap; |
| 21 | unsigned int primitive; |
| 22 | enum osmo_prim_operation operation; |
| 23 | struct msgb *msg; /* message containing associated data */ |
| 24 | }; |
| 25 | |
Harald Welte | 5e924a3 | 2011-06-23 15:04:47 +0200 | [diff] [blame] | 26 | static inline void |
| 27 | osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap, |
| 28 | unsigned int primitive, enum osmo_prim_operation operation, |
| 29 | struct msgb *msg) |
| 30 | { |
| 31 | oph->sap = sap; |
| 32 | oph->primitive = primitive; |
| 33 | oph->operation = operation; |
| 34 | oph->msg = msg; |
| 35 | } |
| 36 | |
| 37 | typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx); |
Harald Welte | 9b21e88 | 2011-06-23 14:14:20 +0200 | [diff] [blame] | 38 | #endif |