summaryrefslogtreecommitdiffstats
path: root/src/prim.c
blob: 5851f6f594d7a4ee01a3e5580ba9a839e7a3be3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <osmocom/core/utils.h>
#include <osmocom/core/prim.h>

/*! \brief human-readable string mapping for
 *  \ref osmo_prim_operation */
const struct value_string osmo_prim_op_names[5] = {
	{ PRIM_OP_REQUEST,			"request" },
	{ PRIM_OP_RESPONSE,			"response" },
	{ PRIM_OP_INDICATION,			"indication" },
	{ PRIM_OP_CONFIRM,			"confirm" },
	{ 0, NULL }
};

/*! \brief resolve the (fsm) event for a given primitive using a map
 *  \param[in] oph primitive header used as key for match
 *  \param[in] maps list of mappings from primitive to event
 *  \returns event determined by map; \ref OSMO_NO_EVENT if no match */
uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph,
			     const struct osmo_prim_event_map *maps)
{
	const struct osmo_prim_event_map *map;

	for (map = maps; map->event != OSMO_NO_EVENT; map++) {
		if (map->sap == oph->sap &&
		    map->primitive == oph->primitive &&
		    map->operation == oph->operation)
			return map->event;
	}
	return OSMO_NO_EVENT;
}