blob: 3c8a7f124a12456f9433d74ede7a834fd163a716 [file] [log] [blame]
Harald Weltee08da972017-11-13 01:00:26 +09001/*!
2 * (C) 2015-2017 by Harald Welte <laforge@gnumonks.org>
3 * All Rights Reserved
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 *
7 * \addtogroup prim
Harald Welte71660942017-10-16 14:52:37 +02008 * @{
9 * \file prim.c */
Neels Hofmeyr17518fe2017-06-20 04:35:06 +020010
Harald Weltea2db75f2015-12-22 22:11:27 +010011#include <osmocom/core/utils.h>
12#include <osmocom/core/prim.h>
13
Neels Hofmeyr87e45502017-06-20 00:17:59 +020014/*! human-readable string mapping for
Harald Welte2d2e2cc2016-04-25 12:11:20 +020015 * \ref osmo_prim_operation */
Harald Weltea2db75f2015-12-22 22:11:27 +010016const struct value_string osmo_prim_op_names[5] = {
17 { PRIM_OP_REQUEST, "request" },
18 { PRIM_OP_RESPONSE, "response" },
19 { PRIM_OP_INDICATION, "indication" },
20 { PRIM_OP_CONFIRM, "confirm" },
21 { 0, NULL }
22};
Harald Welteacd08fe2017-04-08 23:35:24 +020023
Neels Hofmeyr87e45502017-06-20 00:17:59 +020024/*! resolve the (fsm) event for a given primitive using a map
Harald Welteacd08fe2017-04-08 23:35:24 +020025 * \param[in] oph primitive header used as key for match
26 * \param[in] maps list of mappings from primitive to event
27 * \returns event determined by map; \ref OSMO_NO_EVENT if no match */
28uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph,
29 const struct osmo_prim_event_map *maps)
30{
31 const struct osmo_prim_event_map *map;
32
33 for (map = maps; map->event != OSMO_NO_EVENT; map++) {
34 if (map->sap == oph->sap &&
35 map->primitive == oph->primitive &&
36 map->operation == oph->operation)
37 return map->event;
38 }
39 return OSMO_NO_EVENT;
40}
Harald Welte71660942017-10-16 14:52:37 +020041
42/*! @} */