1*36ebd06eSchristos /*
2*36ebd06eSchristos * FST module implementation
3*36ebd06eSchristos * Copyright (c) 2014, Qualcomm Atheros, Inc.
4*36ebd06eSchristos *
5*36ebd06eSchristos * This software may be distributed under the terms of the BSD license.
6*36ebd06eSchristos * See README for more details.
7*36ebd06eSchristos */
8*36ebd06eSchristos
9*36ebd06eSchristos #include "utils/includes.h"
10*36ebd06eSchristos #include "utils/common.h"
11*36ebd06eSchristos #include "common/defs.h"
12*36ebd06eSchristos #include "fst_ctrl_defs.h"
13*36ebd06eSchristos #include "fst_ctrl_aux.h"
14*36ebd06eSchristos
15*36ebd06eSchristos
16*36ebd06eSchristos static const char *session_event_names[] = {
17*36ebd06eSchristos [EVENT_FST_ESTABLISHED] = FST_PVAL_EVT_TYPE_ESTABLISHED,
18*36ebd06eSchristos [EVENT_FST_SETUP] = FST_PVAL_EVT_TYPE_SETUP,
19*36ebd06eSchristos [EVENT_FST_SESSION_STATE_CHANGED] = FST_PVAL_EVT_TYPE_SESSION_STATE,
20*36ebd06eSchristos };
21*36ebd06eSchristos
22*36ebd06eSchristos static const char *reason_names[] = {
23*36ebd06eSchristos [REASON_TEARDOWN] = FST_CS_PVAL_REASON_TEARDOWN,
24*36ebd06eSchristos [REASON_SETUP] = FST_CS_PVAL_REASON_SETUP,
25*36ebd06eSchristos [REASON_SWITCH] = FST_CS_PVAL_REASON_SWITCH,
26*36ebd06eSchristos [REASON_STT] = FST_CS_PVAL_REASON_STT,
27*36ebd06eSchristos [REASON_REJECT] = FST_CS_PVAL_REASON_REJECT,
28*36ebd06eSchristos [REASON_ERROR_PARAMS] = FST_CS_PVAL_REASON_ERROR_PARAMS,
29*36ebd06eSchristos [REASON_RESET] = FST_CS_PVAL_REASON_RESET,
30*36ebd06eSchristos [REASON_DETACH_IFACE] = FST_CS_PVAL_REASON_DETACH_IFACE,
31*36ebd06eSchristos };
32*36ebd06eSchristos
33*36ebd06eSchristos static const char *session_state_names[] = {
34*36ebd06eSchristos [FST_SESSION_STATE_INITIAL] = FST_CS_PVAL_STATE_INITIAL,
35*36ebd06eSchristos [FST_SESSION_STATE_SETUP_COMPLETION] =
36*36ebd06eSchristos FST_CS_PVAL_STATE_SETUP_COMPLETION,
37*36ebd06eSchristos [FST_SESSION_STATE_TRANSITION_DONE] = FST_CS_PVAL_STATE_TRANSITION_DONE,
38*36ebd06eSchristos [FST_SESSION_STATE_TRANSITION_CONFIRMED] =
39*36ebd06eSchristos FST_CS_PVAL_STATE_TRANSITION_CONFIRMED,
40*36ebd06eSchristos };
41*36ebd06eSchristos
42*36ebd06eSchristos
43*36ebd06eSchristos /* helpers */
fst_get_str_name(unsigned index,const char * names[],size_t names_size)44*36ebd06eSchristos const char * fst_get_str_name(unsigned index, const char *names[],
45*36ebd06eSchristos size_t names_size)
46*36ebd06eSchristos {
47*36ebd06eSchristos if (index >= names_size || !names[index])
48*36ebd06eSchristos return FST_NAME_UNKNOWN;
49*36ebd06eSchristos return names[index];
50*36ebd06eSchristos }
51*36ebd06eSchristos
52*36ebd06eSchristos
fst_session_event_type_name(enum fst_event_type event)53*36ebd06eSchristos const char * fst_session_event_type_name(enum fst_event_type event)
54*36ebd06eSchristos {
55*36ebd06eSchristos return fst_get_str_name(event, session_event_names,
56*36ebd06eSchristos ARRAY_SIZE(session_event_names));
57*36ebd06eSchristos }
58*36ebd06eSchristos
59*36ebd06eSchristos
fst_reason_name(enum fst_reason reason)60*36ebd06eSchristos const char * fst_reason_name(enum fst_reason reason)
61*36ebd06eSchristos {
62*36ebd06eSchristos return fst_get_str_name(reason, reason_names, ARRAY_SIZE(reason_names));
63*36ebd06eSchristos }
64*36ebd06eSchristos
65*36ebd06eSchristos
fst_session_state_name(enum fst_session_state state)66*36ebd06eSchristos const char * fst_session_state_name(enum fst_session_state state)
67*36ebd06eSchristos {
68*36ebd06eSchristos return fst_get_str_name(state, session_state_names,
69*36ebd06eSchristos ARRAY_SIZE(session_state_names));
70*36ebd06eSchristos }
71