blob: 2e60c46d75732eddf435609d197869ab3a5d70e9 [file] [log] [blame]
Harald Welte9b21e882011-06-23 14:14:20 +02001#ifndef OSMO_PRIMITIVE_H
2#define OSMO_PRIMITIVE_H
3
Harald Welteeee37902011-08-17 16:14:11 +02004/*! \defgroup prim Osmocom primitives
5 * @{
6 */
7
8/*! \file prim.c */
9
Harald Welte9b21e882011-06-23 14:14:20 +020010#include <stdint.h>
Harald Welte5e924a32011-06-23 15:04:47 +020011#include <osmocom/core/msgb.h>
Harald Welte9b21e882011-06-23 14:14:20 +020012
Harald Welteeee37902011-08-17 16:14:11 +020013/*! \brief primitive operation */
Harald Welte9b21e882011-06-23 14:14:20 +020014enum osmo_prim_operation {
Harald Welteeee37902011-08-17 16:14:11 +020015 PRIM_OP_REQUEST, /*!< \brief request */
16 PRIM_OP_RESPONSE, /*!< \brief response */
17 PRIM_OP_INDICATION, /*!< \brief indication */
18 PRIM_OP_CONFIRM, /*!< \brief cofirm */
Harald Welte9b21e882011-06-23 14:14:20 +020019};
20
Harald Welte5e924a32011-06-23 15:04:47 +020021#define _SAP_GSM_SHIFT 24
22
23#define _SAP_GSM_BASE (0x01 << _SAP_GSM_SHIFT)
24#define _SAP_TETRA_BASE (0x02 << _SAP_GSM_SHIFT)
25
Harald Welteeee37902011-08-17 16:14:11 +020026/*! \brief primitive header */
Harald Welte9b21e882011-06-23 14:14:20 +020027struct osmo_prim_hdr {
Harald Welteeee37902011-08-17 16:14:11 +020028 unsigned int sap; /*!< \brief Service Access Point */
29 unsigned int primitive; /*!< \brief Primitive number */
30 enum osmo_prim_operation operation; /*! \brief Primitive Operation */
31 struct msgb *msg; /*!< \brief \ref msgb containing associated data */
Harald Welte9b21e882011-06-23 14:14:20 +020032};
33
Harald Welteeee37902011-08-17 16:14:11 +020034/*! \brief initialize a primitive header
35 * \param[in,out] oph primitive header
36 * \param[in] sap Service Access Point
37 * \param[in] primtive Primitive Number
38 * \param[in] operation Primitive Operation (REQ/RESP/IND/CONF)
39 * \param[in] msg Message
40 */
Harald Welte5e924a32011-06-23 15:04:47 +020041static inline void
42osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap,
43 unsigned int primitive, enum osmo_prim_operation operation,
44 struct msgb *msg)
45{
46 oph->sap = sap;
47 oph->primitive = primitive;
48 oph->operation = operation;
49 oph->msg = msg;
50}
51
Harald Welteeee37902011-08-17 16:14:11 +020052/*! \brief primitive handler callback type */
Harald Welte5e924a32011-06-23 15:04:47 +020053typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx);
Harald Welteeee37902011-08-17 16:14:11 +020054
55#endif /* OSMO_PRIMITIVE_H */