Loading...
Searching...
No Matches
prim.h
Go to the documentation of this file.
#pragma once
#include <stdint.h>
#include <osmocom/core/msgb.h>
#define OSMO_PRIM(prim, op) ((prim << 8) | (op & 0xFF))
#define OSMO_PRIM_HDR(oph) OSMO_PRIM((oph)->primitive, (oph)->operation)
enum osmo_prim_operation {
PRIM_OP_REQUEST,
PRIM_OP_RESPONSE,
PRIM_OP_INDICATION,
PRIM_OP_CONFIRM,
};
extern const struct value_string osmo_prim_op_names[];
static inline const char *osmo_prim_operation_name(enum osmo_prim_operation val)
{
return get_value_string(osmo_prim_op_names, val);
}
#define _SAP_GSM_SHIFT 24
#define _SAP_GSM_BASE (0x01 << _SAP_GSM_SHIFT)
#define _SAP_TETRA_BASE (0x02 << _SAP_GSM_SHIFT)
#define _SAP_SS7_BASE (0x03 << _SAP_GSM_SHIFT)
struct osmo_prim_hdr {
unsigned int sap;
unsigned int primitive;
enum osmo_prim_operation operation;
struct msgb *msg;
};
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);
#define OSMO_NO_EVENT 0xFFFFFFFF
struct osmo_prim_event_map {
unsigned int sap;
unsigned int primitive;
enum osmo_prim_operation operation;
uint32_t event;
};
uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph,
const struct osmo_prim_event_map *maps);
osmo_prim_operation
osmo_prim_operation
primitive operation
Definition prim.h:26
osmo_event_for_prim
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
osmo_prim_operation_name
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
osmo_prim_cb
int(* osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx)
primitive handler callback type
Definition prim.h:79
osmo_prim_op_names
const struct value_string osmo_prim_op_names[]
human-readable string mapping for osmo_prim_operation
Definition prim.c:16
osmo_prim_init
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
@ PRIM_OP_INDICATION
indication
Definition prim.h:29
PRIM_OP_CONFIRM
@ PRIM_OP_CONFIRM
confirm
Definition prim.h:30
PRIM_OP_REQUEST
@ PRIM_OP_REQUEST
request
Definition prim.h:27
PRIM_OP_RESPONSE
@ PRIM_OP_RESPONSE
response
Definition prim.h:28
get_value_string
const char * get_value_string(const struct value_string *vs, uint32_t val)
get human-readable string for given value
Definition utils.c:62
msg
uint8_t msg[0]
msgb.h
msgb
Osmocom message buffer.
Definition msgb.h:31
osmo_prim_event_map
single entry in a SAP/PRIM/OP -> EVENT map
Definition prim.h:86
osmo_prim_event_map::event
uint32_t event
event as result if above match
Definition prim.h:90
osmo_prim_event_map::sap
unsigned int sap
SAP to match.
Definition prim.h:87
osmo_prim_event_map::primitive
unsigned int primitive
primtiive to match
Definition prim.h:88
osmo_prim_event_map::operation
enum osmo_prim_operation operation
operation to match
Definition prim.h:89
osmo_prim_hdr
Osmocom primitive header.
Definition prim.h:47
osmo_prim_hdr::msg
struct msgb * msg
Primitive Operation.
Definition prim.h:51
osmo_prim_hdr::operation
enum osmo_prim_operation operation
Definition prim.h:50
osmo_prim_hdr::primitive
unsigned int primitive
Primitive number.
Definition prim.h:49
osmo_prim_hdr::sap
unsigned int sap
Service Access Point Identifier.
Definition prim.h:48
value_string
A mapping between human-readable string and numeric value.
Definition utils.h:51