blob: f39527fc038733859d1c60f47067e653cacbafc0 [file] [log] [blame]
Harald Weltea2db75f2015-12-22 22:11:27 +01001#include <osmocom/core/utils.h>
2#include <osmocom/core/prim.h>
3
Neels Hofmeyr87e45502017-06-20 00:17:59 +02004/*! human-readable string mapping for
Harald Welte2d2e2cc2016-04-25 12:11:20 +02005 * \ref osmo_prim_operation */
Harald Weltea2db75f2015-12-22 22:11:27 +01006const struct value_string osmo_prim_op_names[5] = {
7 { PRIM_OP_REQUEST, "request" },
8 { PRIM_OP_RESPONSE, "response" },
9 { PRIM_OP_INDICATION, "indication" },
10 { PRIM_OP_CONFIRM, "confirm" },
11 { 0, NULL }
12};
Harald Welteacd08fe2017-04-08 23:35:24 +020013
Neels Hofmeyr87e45502017-06-20 00:17:59 +020014/*! resolve the (fsm) event for a given primitive using a map
Harald Welteacd08fe2017-04-08 23:35:24 +020015 * \param[in] oph primitive header used as key for match
16 * \param[in] maps list of mappings from primitive to event
17 * \returns event determined by map; \ref OSMO_NO_EVENT if no match */
18uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph,
19 const struct osmo_prim_event_map *maps)
20{
21 const struct osmo_prim_event_map *map;
22
23 for (map = maps; map->event != OSMO_NO_EVENT; map++) {
24 if (map->sap == oph->sap &&
25 map->primitive == oph->primitive &&
26 map->operation == oph->operation)
27 return map->event;
28 }
29 return OSMO_NO_EVENT;
30}