libosmocore  0.9.3
Osmocom core library
include/osmocom/core/prim.h
Go to the documentation of this file.
00001 #pragma once
00002 
00009 #include <stdint.h>
00010 #include <osmocom/core/msgb.h>
00011 
00012 #define OSMO_PRIM(prim, op)     ((prim << 8) | (op & 0xFF))
00013 #define OSMO_PRIM_HDR(oph)      OSMO_PRIM((oph)->primitive, (oph)->operation)
00014 
00016 enum osmo_prim_operation {
00017         PRIM_OP_REQUEST,        
00018         PRIM_OP_RESPONSE,       
00019         PRIM_OP_INDICATION,     
00020         PRIM_OP_CONFIRM,        
00021 };
00022 
00023 #define _SAP_GSM_SHIFT  24
00024 
00025 #define _SAP_GSM_BASE   (0x01 << _SAP_GSM_SHIFT)
00026 #define _SAP_TETRA_BASE (0x02 << _SAP_GSM_SHIFT)
00027 
00029 struct osmo_prim_hdr {
00030         unsigned int sap;       
00031         unsigned int primitive; 
00032         enum osmo_prim_operation operation; 
00033         struct msgb *msg;       
00034 };
00035 
00043 static inline void
00044 osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap,
00045                 unsigned int primitive, enum osmo_prim_operation operation,
00046                 struct msgb *msg)
00047 {
00048         oph->sap = sap;
00049         oph->primitive = primitive;
00050         oph->operation = operation;
00051         oph->msg = msg;
00052 }
00053 
00055 typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx);
00056