libosmocore 1.9.0.196-9975
Osmocom core library
prim.h
Go to the documentation of this file.
1#pragma once
2
19#include <stdint.h>
20#include <osmocom/core/msgb.h>
21
22#define OSMO_PRIM(prim, op) ((prim << 8) | (op & 0xFF))
23#define OSMO_PRIM_HDR(oph) OSMO_PRIM((oph)->primitive, (oph)->operation)
24
31};
32
33extern const struct value_string osmo_prim_op_names[];
34static inline const char *osmo_prim_operation_name(enum osmo_prim_operation val)
35{
37}
38
40#define _SAP_GSM_SHIFT 24
41
42#define _SAP_GSM_BASE (0x01 << _SAP_GSM_SHIFT)
43#define _SAP_TETRA_BASE (0x02 << _SAP_GSM_SHIFT)
44#define _SAP_SS7_BASE (0x03 << _SAP_GSM_SHIFT)
45
48 unsigned int sap;
49 unsigned int primitive;
51 struct msgb *msg;
58};
59
67static inline void
68osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap,
69 unsigned int primitive, enum osmo_prim_operation operation,
70 struct msgb *msg)
71{
72 oph->sap = sap;
73 oph->primitive = primitive;
74 oph->operation = operation;
75 oph->msg = msg;
76}
77
79typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx);
80
83#define OSMO_NO_EVENT 0xFFFFFFFF
84
87 unsigned int sap;
88 unsigned int primitive;
90 uint32_t event;
91};
92
93uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph,
94 const struct osmo_prim_event_map *maps);
osmo_prim_operation
primitive operation
Definition: prim.h:26
uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph, const struct osmo_prim_event_map *maps)
resolve the (fsm) event for a given primitive using a map
Definition: prim.c:28
static const char * osmo_prim_operation_name(enum osmo_prim_operation val)
The upper 8 byte of the technology, the lower 24 bits for the SAP.
Definition: prim.h:34
int(* osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx)
primitive handler callback type
Definition: prim.h:79
const struct value_string osmo_prim_op_names[]
human-readable string mapping for osmo_prim_operation
Definition: prim.c:16
static void osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap, unsigned int primitive, enum osmo_prim_operation operation, struct msgb *msg)
Convenience function to initialize a primitive header.
Definition: prim.h:68
@ PRIM_OP_INDICATION
indication
Definition: prim.h:29
@ PRIM_OP_CONFIRM
confirm
Definition: prim.h:30
@ PRIM_OP_REQUEST
request
Definition: prim.h:27
@ PRIM_OP_RESPONSE
response
Definition: prim.h:28
const char * get_value_string(const struct value_string *vs, uint32_t val)
get human-readable string for given value
Definition: utils.c:54
uint8_t msg[0]
Osmocom message buffer.
Definition: msgb.h:31
single entry in a SAP/PRIM/OP -> EVENT map
Definition: prim.h:86
uint32_t event
event as result if above match
Definition: prim.h:90
unsigned int sap
SAP to match.
Definition: prim.h:87
unsigned int primitive
primtiive to match
Definition: prim.h:88
enum osmo_prim_operation operation
operation to match
Definition: prim.h:89
Osmocom primitive header.
Definition: prim.h:47
struct msgb * msg
Primitive Operation.
Definition: prim.h:51
enum osmo_prim_operation operation
Definition: prim.h:50
unsigned int primitive
Primitive number.
Definition: prim.h:49
unsigned int sap
Service Access Point Identifier.
Definition: prim.h:48
A mapping between human-readable string and numeric value.
Definition: utils.h:51