summaryrefslogtreecommitdiffstats
path: root/src/prim.c
blob: 20355813ad608bdaf8af36d182bc5221650049bf (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
31
32
/*! \file prim.c */

#include <osmocom/core/utils.h>
#include <osmocom/core/prim.h>

/*! 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 }
};

/*! 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;
}