blob: d18dbd76cbfe285fd81417dea11b508dba34bca0 [file] [log] [blame]
Harald Welte71660942017-10-16 14:52:37 +02001/*! \addtogroup prim
2 * @{
3 * \file prim.c */
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02004
Harald Weltea2db75f2015-12-22 22:11:27 +01005#include <osmocom/core/utils.h>
6#include <osmocom/core/prim.h>
7
Neels Hofmeyr87e45502017-06-20 00:17:59 +02008/*! human-readable string mapping for
Harald Welte2d2e2cc2016-04-25 12:11:20 +02009 * \ref osmo_prim_operation */
Harald Weltea2db75f2015-12-22 22:11:27 +010010const struct value_string osmo_prim_op_names[5] = {
11 { PRIM_OP_REQUEST, "request" },
12 { PRIM_OP_RESPONSE, "response" },
13 { PRIM_OP_INDICATION, "indication" },
14 { PRIM_OP_CONFIRM, "confirm" },
15 { 0, NULL }
16};
Harald Welteacd08fe2017-04-08 23:35:24 +020017
Neels Hofmeyr87e45502017-06-20 00:17:59 +020018/*! resolve the (fsm) event for a given primitive using a map
Harald Welteacd08fe2017-04-08 23:35:24 +020019 * \param[in] oph primitive header used as key for match
20 * \param[in] maps list of mappings from primitive to event
21 * \returns event determined by map; \ref OSMO_NO_EVENT if no match */
22uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph,
23 const struct osmo_prim_event_map *maps)
24{
25 const struct osmo_prim_event_map *map;
26
27 for (map = maps; map->event != OSMO_NO_EVENT; map++) {
28 if (map->sap == oph->sap &&
29 map->primitive == oph->primitive &&
30 map->operation == oph->operation)
31 return map->event;
32 }
33 return OSMO_NO_EVENT;
34}
Harald Welte71660942017-10-16 14:52:37 +020035
36/*! @} */