fst_ctrl_aux.c 1.9 KB

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