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