Harald Welte | 283c7fd | 2015-12-21 23:35:56 +0100 | [diff] [blame^] | 1 | #include <string.h> |
| 2 | #include <osmocom/core/utils.h> |
| 3 | |
| 4 | #include "sccp_sap.h" |
| 5 | |
| 6 | const struct value_string osmo_scu_prim_names[] = { |
| 7 | { OSMO_SCU_PRIM_N_CONNECT, "N-CONNECT" }, |
| 8 | { OSMO_SCU_PRIM_N_DATA, "N-DATA" }, |
| 9 | { OSMO_SCU_PRIM_N_EXPEDITED_DATA, "N-EXPEDITED-DATA" }, |
| 10 | { OSMO_SCU_PRIM_N_DISCONNECT, "N-DISCONNECT" }, |
| 11 | { OSMO_SCU_PRIM_N_RESET, "N-RESET" }, |
| 12 | { OSMO_SCU_PRIM_N_INFORM, "N-INFORM" }, |
| 13 | { OSMO_SCU_PRIM_N_UNITDATA, "N-UNITDATA" }, |
| 14 | { OSMO_SCU_PRIM_N_NOTICE, "N-NOTICE" }, |
| 15 | /* management */ |
| 16 | { OSMO_SCU_PRIM_N_COORD, "N-COORD" }, |
| 17 | { OSMO_SCU_PRIM_N_STATE, "N-STATE" }, |
| 18 | { OSMO_SCU_PRIM_N_PCSTATE, "N-PCSATE" }, |
| 19 | { 0, NULL } |
| 20 | }; |
| 21 | |
| 22 | const struct value_string osmo_prim_op_names[] = { |
| 23 | { PRIM_OP_REQUEST, "request" }, |
| 24 | { PRIM_OP_RESPONSE, "response" }, |
| 25 | { PRIM_OP_INDICATION, "indication" }, |
| 26 | { PRIM_OP_CONFIRM, "confirm" }, |
| 27 | { 0, NULL } |
| 28 | }; |
| 29 | |
| 30 | static char prim_name_buf[128]; |
| 31 | |
| 32 | char *osmo_sccp_prim_name(struct osmo_prim_hdr *oph) |
| 33 | { |
| 34 | const char *name = get_value_string(osmo_scu_prim_names, oph->primitive); |
| 35 | |
| 36 | prim_name_buf[0] = '\0'; |
| 37 | strncpy(prim_name_buf, name, sizeof(prim_name_buf)-1); |
| 38 | prim_name_buf[sizeof(prim_name_buf)-1] = '\0'; |
| 39 | name = get_value_string(osmo_prim_op_names, oph->operation); |
| 40 | strncat(prim_name_buf, name, sizeof(prim_name_buf)-strlen(prim_name_buf)-2); |
| 41 | |
| 42 | return prim_name_buf; |
| 43 | } |