Osmocom primitives

Osmocom Primitives are a method to express inter-layer primitives as used often in ITU/ETSI/3GPP specifications in a generic way. They are based on Message buffers and encapsulate any (optional) user payload data with a primitive header. The header contains information on. More...

## Files

file | prim.h
file | prim.c

## Data Structures

struct | osmo_prim_hdr
| Osmocom primitive header. More...
struct | osmo_prim_event_map
| single entry in a SAP/PRIM/OP -> EVENT map More...

## Macros

#define | OSMO_PRIM(prim, op) ((prim << 8) | (op & 0xFF))
#define | OSMO_PRIM_HDR(oph) OSMO_PRIM((oph)->primitive, (oph)->operation)
#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)
#define | OSMO_NO_EVENT 0xFFFFFFFF
| magic value to be used as final record of osmo_prim_event_map More...

## Typedefs

typedef int(* | osmo_prim_cb) (struct osmo_prim_hdr *oph, void *ctx)
| primitive handler callback type More...

## Enumerations

enum | osmo_prim_operation { PRIM_OP_REQUEST, PRIM_OP_RESPONSE, PRIM_OP_INDICATION, PRIM_OP_CONFIRM }
| primitive operation More...

## Functions

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. More...
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 More...

## Variables

const struct value_string | osmo_prim_op_names [5]
| The upper 8 byte of the technology, the lower 24 bits for the SAP. More...
const struct value_string | osmo_prim_op_names [5]
| human-readable string mapping for osmo_prim_operation More...

## Detailed Description

Osmocom Primitives are a method to express inter-layer primitives as used often in ITU/ETSI/3GPP specifications in a generic way. They are based on Message buffers and encapsulate any (optional) user payload data with a primitive header. The header contains information on.

(C) 2015-2017 by Harald Welte lafor.nosp@m.ge@g.nosp@m.numon.nosp@m.ks.o.nosp@m.rg All Rights Reserved

- which SAP this primitive is used on
- what is the name of the primitive
- is it REQUEST, RESPONSE, INDICATION or CONFIRMATION

For more information on the inter-layer primitives concept, see ITU-T X.21@ as found at https://www.itu.int/rec/T-REC-X.212-199511-I/en

SPDX-License-Identifier: GPL-2.0+

## Macro Definition Documentation

## _SAP_GSM_BASE

#define _SAP_GSM_BASE (0x01 << _SAP_GSM_SHIFT)

## _SAP_GSM_SHIFT

#define _SAP_GSM_SHIFT 24

## _SAP_SS7_BASE

#define _SAP_SS7_BASE (0x03 << _SAP_GSM_SHIFT)

## _SAP_TETRA_BASE

#define _SAP_TETRA_BASE (0x02 << _SAP_GSM_SHIFT)

## OSMO_NO_EVENT

#define OSMO_NO_EVENT 0xFFFFFFFF

magic value to be used as final record of osmo_prim_event_map

## OSMO_PRIM

#define OSMO_PRIM | ( |  | prim,
|  |  | op
| ) |  | ((prim << 8) | (op & 0xFF))

## OSMO_PRIM_HDR

#define OSMO_PRIM_HDR | ( |  | oph | ) | OSMO_PRIM((oph)->primitive, (oph)->operation)

## Typedef Documentation

## osmo_prim_cb

typedef int(* osmo_prim_cb) (struct osmo_prim_hdr *oph, void *ctx)

primitive handler callback type

## Enumeration Type Documentation

## osmo_prim_operation

enum osmo_prim_operation

primitive operation

Enumerator
PRIM_OP_REQUEST | request
PRIM_OP_RESPONSE | response
PRIM_OP_INDICATION | indication
PRIM_OP_CONFIRM | confirm

## Function Documentation

## 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

Parameters

  [in] | oph | primitive header used as key for match
  [in] | maps | list of mappings from primitive to event

Returns
  event determined by map; OSMO_NO_EVENT if no match

References osmo_prim_event_map::event, osmo_prim_hdr::operation, osmo_prim_event_map::operation, OSMO_NO_EVENT, osmo_prim_hdr::primitive, osmo_prim_event_map::primitive, osmo_prim_hdr::sap, and osmo_prim_event_map::sap.

## 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
| ) |  |

inline static

Convenience function to initialize a primitive header.

Parameters

  [in,out] | oph | primitive header
  [in] | sap | Service Access Point
  [in] | primitive | Primitive Number
  [in] | operation | Primitive Operation (REQ/RESP/IND/CONF)
  [in] | msg | Message

References osmo_prim_hdr::msg, osmo_prim_hdr::operation, osmo_prim_hdr::primitive, and osmo_prim_hdr::sap.

## Variable Documentation

## osmo_prim_op_names [1/2]

const struct value_string osmo_prim_op_names[5]

The upper 8 byte of the technology, the lower 24 bits for the SAP.

The upper 8 byte of the technology, the lower 24 bits for the SAP.

## osmo_prim_op_names [2/2]

const struct value_string osmo_prim_op_names[5]

Initial value:
= {
{ PRIM_OP_REQUEST, "request" },
{ PRIM_OP_RESPONSE, "response" },
{ PRIM_OP_INDICATION, "indication" },
{ PRIM_OP_CONFIRM, "confirm" },
{ 0, NULL }
}

human-readable string mapping for osmo_prim_operation

The upper 8 byte of the technology, the lower 24 bits for the SAP.

PRIM_OP_INDICATION
@ PRIM_OP_INDICATION
indication
Definition: prim.h:29
PRIM_OP_REQUEST
@ PRIM_OP_REQUEST
request
Definition: prim.h:27
PRIM_OP_CONFIRM
@ PRIM_OP_CONFIRM
confirm
Definition: prim.h:30
PRIM_OP_RESPONSE
@ PRIM_OP_RESPONSE
response
Definition: prim.h:28