Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 1 | /*! |
| 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 Welte | 7166094 | 2017-10-16 14:52:37 +0200 | [diff] [blame] | 8 | * @{ |
| 9 | * \file prim.c */ |
Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 10 | |
Harald Welte | a2db75f | 2015-12-22 22:11:27 +0100 | [diff] [blame] | 11 | #include <osmocom/core/utils.h> |
| 12 | #include <osmocom/core/prim.h> |
| 13 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 14 | /*! human-readable string mapping for |
Harald Welte | 2d2e2cc | 2016-04-25 12:11:20 +0200 | [diff] [blame] | 15 | * \ref osmo_prim_operation */ |
Harald Welte | a2db75f | 2015-12-22 22:11:27 +0100 | [diff] [blame] | 16 | const 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 Welte | acd08fe | 2017-04-08 23:35:24 +0200 | [diff] [blame] | 23 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 24 | /*! resolve the (fsm) event for a given primitive using a map |
Harald Welte | acd08fe | 2017-04-08 23:35:24 +0200 | [diff] [blame] | 25 | * \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 */ |
| 28 | uint32_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 Welte | 7166094 | 2017-10-16 14:52:37 +0200 | [diff] [blame] | 41 | |
| 42 | /*! @} */ |