add gsm48_pdisc_msgtype_name()

Composing the message type string requires knowing the protocol discriminator.
To ease printing the message type, add this function to switch between the
defined value_string[]s depending on pdisc.

Also publish the message type value_string[]s -- without inline functions to
access them because it is anyway more convenient to use
gsm48_pdisc_msgtype_name() instead.

Since gsm48_pdisc_msgtype_name() is nontrivial, do not add as inline function
-- in case the message type is not known, it needs a static string buffer.

Change-Id: I0fca8e95ed5c2148b1a7440eff3fc9c7583898df
changes/27/2027/3
Neels Hofmeyr 6 years ago
parent dbd994c05b
commit 00ab9ed6e2
  1. 5
      include/osmocom/gsm/protocol/gsm_04_08.h
  2. 198
      src/gsm/gsm48.c
  3. 4
      src/gsm/libosmogsm.map

@ -1180,6 +1180,11 @@ void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full,
#define GSM48_MT_CC_START_DTMF_REJ 0x37
#define GSM48_MT_CC_FACILITY 0x3a
extern const struct value_string gsm48_rr_msgtype_names[];
extern const struct value_string gsm48_mm_msgtype_names[];
extern const struct value_string gsm48_cc_msgtype_names[];
const char *gsm48_pdisc_msgtype_name(uint8_t pdisc, uint8_t msg_type);
/* FIXME: Table 10.4 / 10.4a (GPRS) */
/* Section 10.5.3.3 CM service type */

@ -697,3 +697,201 @@ const struct value_string gsm48_pdisc_names[] = {
OSMO_VALUE_STRING(GSM48_PDISC_USSD),
{ 0, NULL }
};
const struct value_string gsm48_rr_msgtype_names[] = {
OSMO_VALUE_STRING(GSM48_MT_RR_INIT_REQ),
OSMO_VALUE_STRING(GSM48_MT_RR_ADD_ASS),
OSMO_VALUE_STRING(GSM48_MT_RR_IMM_ASS),
OSMO_VALUE_STRING(GSM48_MT_RR_IMM_ASS_EXT),
OSMO_VALUE_STRING(GSM48_MT_RR_IMM_ASS_REJ),
OSMO_VALUE_STRING(GSM48_MT_RR_DTM_ASS_FAIL),
OSMO_VALUE_STRING(GSM48_MT_RR_DTM_REJECT),
OSMO_VALUE_STRING(GSM48_MT_RR_DTM_REQUEST),
OSMO_VALUE_STRING(GSM48_MT_RR_PACKET_ASS),
OSMO_VALUE_STRING(GSM48_MT_RR_CIPH_M_CMD),
OSMO_VALUE_STRING(GSM48_MT_RR_CIPH_M_COMPL),
OSMO_VALUE_STRING(GSM48_MT_RR_CFG_CHG_CMD),
OSMO_VALUE_STRING(GSM48_MT_RR_CFG_CHG_ACK),
OSMO_VALUE_STRING(GSM48_MT_RR_CFG_CHG_REJ),
OSMO_VALUE_STRING(GSM48_MT_RR_ASS_CMD),
OSMO_VALUE_STRING(GSM48_MT_RR_ASS_COMPL),
OSMO_VALUE_STRING(GSM48_MT_RR_ASS_FAIL),
OSMO_VALUE_STRING(GSM48_MT_RR_HANDO_CMD),
OSMO_VALUE_STRING(GSM48_MT_RR_HANDO_COMPL),
OSMO_VALUE_STRING(GSM48_MT_RR_HANDO_FAIL),
OSMO_VALUE_STRING(GSM48_MT_RR_HANDO_INFO),
OSMO_VALUE_STRING(GSM48_MT_RR_HANDO_INFO),
OSMO_VALUE_STRING(GSM48_MT_RR_DTM_ASS_CMD),
OSMO_VALUE_STRING(GSM48_MT_RR_CELL_CHG_ORDER),
OSMO_VALUE_STRING(GSM48_MT_RR_PDCH_ASS_CMD),
OSMO_VALUE_STRING(GSM48_MT_RR_CHAN_REL),
OSMO_VALUE_STRING(GSM48_MT_RR_PART_REL),
OSMO_VALUE_STRING(GSM48_MT_RR_PART_REL_COMP),
OSMO_VALUE_STRING(GSM48_MT_RR_PAG_REQ_1),
OSMO_VALUE_STRING(GSM48_MT_RR_PAG_REQ_2),
OSMO_VALUE_STRING(GSM48_MT_RR_PAG_REQ_3),
OSMO_VALUE_STRING(GSM48_MT_RR_PAG_RESP),
OSMO_VALUE_STRING(GSM48_MT_RR_NOTIF_NCH),
OSMO_VALUE_STRING(GSM48_MT_RR_NOTIF_FACCH),
OSMO_VALUE_STRING(GSM48_MT_RR_NOTIF_RESP),
OSMO_VALUE_STRING(GSM48_MT_RR_PACKET_NOTIF),
OSMO_VALUE_STRING(GSM48_MT_RR_UTRAN_CLSM_CHG),
OSMO_VALUE_STRING(GSM48_MT_RR_CDMA2K_CLSM_CHG),
OSMO_VALUE_STRING(GSM48_MT_RR_IS_TO_UTRAN_HANDO),
OSMO_VALUE_STRING(GSM48_MT_RR_IS_TO_CDMA2K_HANDO),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_8),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_1),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_2),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_3),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_4),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_5),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_6),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_7),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_2bis),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_2ter),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_2quater),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_5bis),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_5ter),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_9),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_13),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_16),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_17),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_18),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_19),
OSMO_VALUE_STRING(GSM48_MT_RR_SYSINFO_20),
OSMO_VALUE_STRING(GSM48_MT_RR_CHAN_MODE_MODIF),
OSMO_VALUE_STRING(GSM48_MT_RR_STATUS),
OSMO_VALUE_STRING(GSM48_MT_RR_CHAN_MODE_MODIF_ACK),
OSMO_VALUE_STRING(GSM48_MT_RR_FREQ_REDEF),
OSMO_VALUE_STRING(GSM48_MT_RR_MEAS_REP),
OSMO_VALUE_STRING(GSM48_MT_RR_CLSM_CHG),
OSMO_VALUE_STRING(GSM48_MT_RR_CLSM_ENQ),
OSMO_VALUE_STRING(GSM48_MT_RR_EXT_MEAS_REP),
OSMO_VALUE_STRING(GSM48_MT_RR_EXT_MEAS_REP_ORD),
OSMO_VALUE_STRING(GSM48_MT_RR_GPRS_SUSP_REQ),
OSMO_VALUE_STRING(GSM48_MT_RR_DTM_INFO),
OSMO_VALUE_STRING(GSM48_MT_RR_VGCS_UPL_GRANT),
OSMO_VALUE_STRING(GSM48_MT_RR_UPLINK_RELEASE),
OSMO_VALUE_STRING(GSM48_MT_RR_UPLINK_FREE),
OSMO_VALUE_STRING(GSM48_MT_RR_UPLINK_BUSY),
OSMO_VALUE_STRING(GSM48_MT_RR_TALKER_IND),
{ 0, NULL }
};
const struct value_string gsm48_mm_msgtype_names[] = {
OSMO_VALUE_STRING(GSM48_MT_MM_IMSI_DETACH_IND),
OSMO_VALUE_STRING(GSM48_MT_MM_LOC_UPD_ACCEPT),
OSMO_VALUE_STRING(GSM48_MT_MM_LOC_UPD_REJECT),
OSMO_VALUE_STRING(GSM48_MT_MM_LOC_UPD_REQUEST),
OSMO_VALUE_STRING(GSM48_MT_MM_AUTH_REJ),
OSMO_VALUE_STRING(GSM48_MT_MM_AUTH_REQ),
OSMO_VALUE_STRING(GSM48_MT_MM_AUTH_RESP),
OSMO_VALUE_STRING(GSM48_MT_MM_AUTH_FAIL),
OSMO_VALUE_STRING(GSM48_MT_MM_ID_REQ),
OSMO_VALUE_STRING(GSM48_MT_MM_ID_RESP),
OSMO_VALUE_STRING(GSM48_MT_MM_TMSI_REALL_CMD),
OSMO_VALUE_STRING(GSM48_MT_MM_TMSI_REALL_COMPL),
OSMO_VALUE_STRING(GSM48_MT_MM_CM_SERV_ACC),
OSMO_VALUE_STRING(GSM48_MT_MM_CM_SERV_REJ),
OSMO_VALUE_STRING(GSM48_MT_MM_CM_SERV_ABORT),
OSMO_VALUE_STRING(GSM48_MT_MM_CM_SERV_REQ),
OSMO_VALUE_STRING(GSM48_MT_MM_CM_SERV_PROMPT),
OSMO_VALUE_STRING(GSM48_MT_MM_CM_REEST_REQ),
OSMO_VALUE_STRING(GSM48_MT_MM_ABORT),
OSMO_VALUE_STRING(GSM48_MT_MM_NULL),
OSMO_VALUE_STRING(GSM48_MT_MM_STATUS),
OSMO_VALUE_STRING(GSM48_MT_MM_INFO),
{ 0, NULL }
};
const struct value_string gsm48_cc_msgtype_names[] = {
OSMO_VALUE_STRING(GSM48_MT_CC_ALERTING),
OSMO_VALUE_STRING(GSM48_MT_CC_CALL_CONF),
OSMO_VALUE_STRING(GSM48_MT_CC_CALL_PROC),
OSMO_VALUE_STRING(GSM48_MT_CC_CONNECT),
OSMO_VALUE_STRING(GSM48_MT_CC_CONNECT_ACK),
OSMO_VALUE_STRING(GSM48_MT_CC_EMERG_SETUP),
OSMO_VALUE_STRING(GSM48_MT_CC_PROGRESS),
OSMO_VALUE_STRING(GSM48_MT_CC_ESTAB),
OSMO_VALUE_STRING(GSM48_MT_CC_ESTAB_CONF),
OSMO_VALUE_STRING(GSM48_MT_CC_RECALL),
OSMO_VALUE_STRING(GSM48_MT_CC_START_CC),
OSMO_VALUE_STRING(GSM48_MT_CC_SETUP),
OSMO_VALUE_STRING(GSM48_MT_CC_MODIFY),
OSMO_VALUE_STRING(GSM48_MT_CC_MODIFY_COMPL),
OSMO_VALUE_STRING(GSM48_MT_CC_MODIFY_REJECT),
OSMO_VALUE_STRING(GSM48_MT_CC_USER_INFO),
OSMO_VALUE_STRING(GSM48_MT_CC_HOLD),
OSMO_VALUE_STRING(GSM48_MT_CC_HOLD_ACK),
OSMO_VALUE_STRING(GSM48_MT_CC_HOLD_REJ),
OSMO_VALUE_STRING(GSM48_MT_CC_RETR),
OSMO_VALUE_STRING(GSM48_MT_CC_RETR_ACK),
OSMO_VALUE_STRING(GSM48_MT_CC_RETR_REJ),
OSMO_VALUE_STRING(GSM48_MT_CC_DISCONNECT),
OSMO_VALUE_STRING(GSM48_MT_CC_RELEASE),
OSMO_VALUE_STRING(GSM48_MT_CC_RELEASE_COMPL),
OSMO_VALUE_STRING(GSM48_MT_CC_CONG_CTRL),
OSMO_VALUE_STRING(GSM48_MT_CC_NOTIFY),
OSMO_VALUE_STRING(GSM48_MT_CC_STATUS),
OSMO_VALUE_STRING(GSM48_MT_CC_STATUS_ENQ),
OSMO_VALUE_STRING(GSM48_MT_CC_START_DTMF),
OSMO_VALUE_STRING(GSM48_MT_CC_STOP_DTMF),
OSMO_VALUE_STRING(GSM48_MT_CC_STOP_DTMF_ACK),
OSMO_VALUE_STRING(GSM48_MT_CC_START_DTMF_ACK),
OSMO_VALUE_STRING(GSM48_MT_CC_START_DTMF_REJ),
OSMO_VALUE_STRING(GSM48_MT_CC_FACILITY),
{ 0, NULL }
};
/*! /brief Compose a string naming the message type for given protocol.
* If the message type string is known, return the message type name, otherwise
* return "<protocol discriminator name>:<message type in hex>".
* /param pdisc[in] protocol discriminator like GSM48_PDISC_MM
* /param msg_type[in] message type like GSM48_MT_MM_LOC_UPD_REQUEST
* /returns statically allocated string or string constant.
*/
const char *gsm48_pdisc_msgtype_name(uint8_t pdisc, uint8_t msg_type)
{
static char namebuf[64];
const struct value_string *msgt_names;
switch (pdisc) {
case GSM48_PDISC_RR:
msgt_names = gsm48_rr_msgtype_names;
break;
case GSM48_PDISC_MM:
msgt_names = gsm48_mm_msgtype_names;
break;
case GSM48_PDISC_CC:
msgt_names = gsm48_cc_msgtype_names;
break;
default:
msgt_names = NULL;
break;
}
if (msgt_names)
return get_value_string(msgt_names, msg_type);
snprintf(namebuf, sizeof(namebuf), "%s:0x%02x",
gsm48_pdisc_name(pdisc), msg_type);
return namebuf;
}

@ -218,6 +218,10 @@ gsm48_mcc_mnc_from_bcd;
gsm48_chan_mode_names;
gsm_chan_t_names;
gsm48_pdisc_names;
gsm48_rr_msgtype_names;
gsm48_mm_msgtype_names;
gsm48_cc_msgtype_names;
gsm48_pdisc_msgtype_name;
gsm_7bit_decode;
gsm_7bit_decode_ussd;

Loading…
Cancel
Save