Updated libs

laforge/submodule
Andreas Eversberg 1 year ago
parent d025e35c3b
commit 94a08803a5
  1. 51
      src/libdebug/debug.c
  2. 66
      src/libdebug/debug.h
  3. 70
      src/libosmocc/endpoint.c
  4. 5
      src/libosmocc/endpoint.h
  5. 8
      src/libosmocc/helper.c
  6. 4
      src/libosmocc/helper.h
  7. 605
      src/libosmocc/message.c
  8. 72
      src/libosmocc/message.h
  9. 31
      src/libosmocc/rtp.c
  10. 2
      src/libosmocc/rtp.h
  11. 4
      src/libosmocc/sdp.c
  12. 2
      src/libosmocc/sdp.h
  13. 42
      src/libosmocc/session.c
  14. 39
      src/libosmocc/session.h
  15. 4
      src/libsound/sound.h
  16. 8
      src/libsound/sound_alsa.c
  17. 14
      src/libtimer/timer.c
  18. 6
      src/telephone/main.c
  19. 18
      src/telephone/telephone.c
  20. 2
      src/telephone/telephone.h

@ -24,7 +24,10 @@
#include <stdint.h>
#include <errno.h>
#include <math.h>
#include <time.h>
#include <pthread.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include "debug.h"
const char *debug_level[] = {
@ -53,6 +56,7 @@ struct debug_cat {
{ "mpt1327", "\033[1;34m" },
{ "jollycom", "\033[1;34m" },
{ "eurosignal", "\033[1;34m" },
{ "pocsag", "\033[1;34m" },
{ "frame", "\033[0;36m" },
{ "call", "\033[0;37m" },
{ "cc", "\033[1;32m" },
@ -89,6 +93,7 @@ struct debug_cat {
};
int debuglevel = DEBUG_INFO;
int debug_date = 0;
uint64_t debug_mask = ~0;
extern int num_kanal;
@ -97,6 +102,9 @@ void (*print_console_text)(void) = NULL;
int debug_limit_scroll = 0;
static int lock_initialized = 0;
static pthread_mutex_t debug_mutex;
void get_win_size(int *w, int *h)
{
struct winsize win;
@ -120,10 +128,22 @@ void _printdebug(const char *file, const char __attribute__((unused)) *function,
const char *p;
va_list args;
int w, h;
int rc;
if (debuglevel > level)
return;
if (!(debug_mask & ((uint64_t)1 << cat)))
return;
if (!lock_initialized) {
rc = pthread_mutex_init(&debug_mutex, NULL);
if (rc == 0)
lock_initialized = 1;
}
if (lock_initialized)
pthread_mutex_lock(&debug_mutex);
buffer[sizeof(buffer) - 1] = '\0';
/* if kanal is used, prefix the channel number */
@ -133,9 +153,6 @@ void _printdebug(const char *file, const char __attribute__((unused)) *function,
s -= strlen(buffer);
}
if (!(debug_mask & ((uint64_t)1 << cat)))
return;
va_start(args, fmt);
vsnprintf(b, s, fmt, args);
va_end(args);
@ -148,12 +165,24 @@ void _printdebug(const char *file, const char __attribute__((unused)) *function,
get_win_size(&w, &h);
printf("\0337\033[%d;%dr\0338", debug_limit_scroll + 1, h);
}
if (debug_date) {
struct timeval tv;
struct tm *tm;
gettimeofday(&tv, NULL);
tm = localtime(&tv.tv_sec);
printf("%04d-%02d-%02d %02d:%02d:%02d.%03d ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 10000.0));
}
printf("%s%s:%4d %s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_level[level], buffer);
if (debug_limit_scroll)
printf("\0337\033[%d;%dr\0338", 1, h);
if (print_console_text)
print_console_text();
fflush(stdout);
if (lock_initialized)
pthread_mutex_unlock(&debug_mutex);
}
const char *debug_amplitude(double level)
@ -190,6 +219,17 @@ const char *debug_db(double level_db)
return text;
}
void debug_print_help(void)
{
printf(" -v --verbose <level> | <level>,<category>[,<category>[,...]] | list\n");
printf(" Use 'list' to get a list of all levels and categories\n");
printf(" Verbose level: digit of debug level (default = '%d')\n", debuglevel);
printf(" Verbose level+category: level digit followed by one or more categories\n");
printf(" -> If no category is specified, all categories are selected\n");
printf(" -v --verbose date\n");
printf(" Show date with debug output\n");
}
void debug_list_cat(void)
{
int i;
@ -210,6 +250,11 @@ int parse_debug_opt(const char *optarg)
int i, max_level = 0;
char *dup, *dstring, *p;
if (!strcasecmp(optarg, "date")) {
debug_date = 1;
return 0;
}
for (i = 0; debug_level[i]; i++)
max_level = i;

@ -18,38 +18,39 @@
#define DMPT1327 11
#define DJOLLY 12
#define DEURO 13
#define DFRAME 14
#define DCALL 15
#define DCC 16
#define DDB 17
#define DTRANS 18
#define DDMS 19
#define DSMS 20
#define DSDR 21
#define DUHD 22
#define DSOAPY 23
#define DWAVE 24
#define DRADIO 25
#define DAM791X 26
#define DUART 27
#define DDEVICE 28
#define DDATENKLO 29
#define DZEIT 30
#define DSIM1 31
#define DSIM2 32
#define DSIMI 33
#define DSIM7 34
#define DMTP2 35
#define DMTP3 36
#define DMUP 37
#define DROUTER 38
#define DSTDERR 39
#define DSS5 40
#define DISDN 41
#define DMISDN 42
#define DDSS1 43
#define DSIP 44
#define DTEL 45
#define DPOCSAG 14
#define DFRAME 15
#define DCALL 16
#define DCC 17
#define DDB 18
#define DTRANS 19
#define DDMS 20
#define DSMS 21
#define DSDR 22
#define DUHD 23
#define DSOAPY 24
#define DWAVE 25
#define DRADIO 26
#define DAM791X 27
#define DUART 28
#define DDEVICE 29
#define DDATENKLO 30
#define DZEIT 31
#define DSIM1 32
#define DSIM2 33
#define DSIMI 34
#define DSIM7 35
#define DMTP2 36
#define DMTP3 37
#define DMUP 38
#define DROUTER 39
#define DSTDERR 40
#define DSS5 41
#define DISDN 42
#define DMISDN 43
#define DDSS1 44
#define DSIP 45
#define DTEL 46
void get_win_size(int *w, int *h);
@ -60,6 +61,7 @@ void _printdebug(const char *file, const char *function, int line, int cat, int
const char *debug_amplitude(double level);
const char *debug_db(double level_db);
void debug_print_help(void);
void debug_list_cat(void);
int parse_debug_opt(const char *opt);

@ -172,6 +172,27 @@ static int split_address(const char *address, const char **host_p, uint16_t *por
return 0;
}
osmo_cc_call_t *osmo_cc_get_attached_interface(osmo_cc_endpoint_t *ep, const char *interface)
{
osmo_cc_call_t *att;
for (att = ep->call_list; att; att = att->next) {
if (att->state != OSMO_CC_STATE_ATTACH_IN)
continue;
/* no interface given, just use the attached peer */
if (!interface[0])
break;
/* no interface name given on attached peer, ignore it */
if (!att->attached_name || !att->attached_name[0])
continue;
/* interface given, use the attached peer with the same interface name */
if (!strcmp(interface, att->attached_name))
break;
}
return att;
}
/* helper to forward message to upper layer */
static void forward_to_ul(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
{
@ -233,19 +254,7 @@ reject:
if (rc < 0)
interface[0] = '\0';
/* check for incoming attachment */
for (att = call->ep->call_list; att; att = att->next) {
if (att->state != OSMO_CC_STATE_ATTACH_IN)
continue;
/* no interface given, just use the attached peer */
if (!interface[0])
break;
/* no interface name given on attached peer, ignore it */
if (!att->attached_name || !att->attached_name[0])
continue;
/* interface given, use the attached peer with the same interface name */
if (!strcmp(interface, att->attached_name))
break;
}
att = osmo_cc_get_attached_interface(call->ep, interface);
if (!att && !interface[0]) {
PDEBUG(DCC, DEBUG_ERROR, "No remote peer attached, rejecting call.\n");
goto reject;
@ -351,7 +360,7 @@ void attach_req(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
rel:
/* change to REL_REQ */
msg->type = OSMO_CC_MSG_REL_IND;
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_name(msg->type));
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type));
/* message to socket */
forward_to_ul(call, msg);
@ -382,7 +391,7 @@ rel:
/* changing to confirm message */
msg->type = OSMO_CC_MSG_ATTACH_CNF;
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_name(msg->type));
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type));
/* message to socket */
forward_to_ul(call, msg);
@ -633,7 +642,7 @@ static void disc_collision_ind(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
/* change to REL_REQ */
msg->type = OSMO_CC_MSG_REL_REQ;
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_name(msg->type));
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type));
/* to lower layer */
forward_to_ll(call, msg);
@ -654,7 +663,7 @@ static void disc_collision_req(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
if (call->lower_layer_released) {
/* change to REL_REQ */
msg->type = OSMO_CC_MSG_REL_IND;
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_name(msg->type));
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type));
/* to upper layer */
forward_to_ul(call, msg);
@ -692,7 +701,7 @@ static void rej_ind_disc(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
/* change to REL_IND */
msg->type = OSMO_CC_MSG_REL_IND;
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_name(msg->type));
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type));
/* to upper layer */
forward_to_ul(call, msg);
@ -708,7 +717,7 @@ static void rej_req_disc(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
/* change to REL_REQ */
msg->type = OSMO_CC_MSG_REL_REQ;
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_name(msg->type));
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type));
/* to lower layer */
forward_to_ll(call, msg);
@ -737,7 +746,7 @@ static void rel_ind_other(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
/* change to DISC_IND */
msg->type = OSMO_CC_MSG_DISC_IND;
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_name(msg->type));
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type));
call->lower_layer_released = 1;
/* to upper layer */
@ -764,7 +773,7 @@ static void rel_req_other(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
/* change to DISC_REQ */
msg->type = OSMO_CC_MSG_DISC_REQ;
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_name(msg->type));
PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type));
call->upper_layer_released = 1;
/* to lower layer */
@ -914,13 +923,15 @@ static void handle_msg(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
break;
if (i == STATEMACHINE_LEN) {
PDEBUG(DCC, DEBUG_INFO, "Message %s unhandled at state %s (callref %d)\n",
osmo_cc_msg_name(msg->type), state_names[call->state], call->callref);
osmo_cc_msg_value2name(msg->type), state_names[call->state], call->callref);
osmo_cc_free_msg(msg);
return;
}
PDEBUG(DCC, DEBUG_INFO, "Handle message %s at state %s (callref %d)\n",
osmo_cc_msg_name(msg->type), state_names[call->state], call->callref);
osmo_cc_msg_value2name(msg->type), state_names[call->state], call->callref);
if (debuglevel <= DEBUG_INFO)
osmo_cc_debug_ie(msg, DEBUG_INFO);
statemachine_list[i].action(call, msg);
}
@ -1146,7 +1157,7 @@ static int osmo_cc_set_address(osmo_cc_endpoint_t *ep, const char *text)
PDEBUG(DCC, DEBUG_ERROR, "Given local address '%s' is invalid.\n", *host_p);
return -EINVAL;
}
osmo_cc_set_local_peer(osmo_cc_session_nettype_inet, addrtype, *host_p);
osmo_cc_set_local_peer(&ep->session_config, osmo_cc_session_nettype_inet, addrtype, *host_p);
return 0;
}
@ -1166,7 +1177,7 @@ static void osmo_cc_help_rtp(void)
printf("interfaces, between machines, local machine's IP must be given.\n\n");
}
static int osmo_cc_set_rtp(const char *text)
static int osmo_cc_set_rtp(osmo_cc_endpoint_t *ep, const char *text)
{
int peer = 0, ports = 0;
@ -1195,7 +1206,7 @@ static int osmo_cc_set_rtp(const char *text)
PDEBUG(DCC, DEBUG_ERROR, "Given RTP address '%s' is invalid.\n", text);
return -EINVAL;
}
osmo_cc_set_local_peer(osmo_cc_session_nettype_inet, addrtype, text);
osmo_cc_set_local_peer(&ep->session_config, osmo_cc_session_nettype_inet, addrtype, text);
return 0;
}
@ -1227,7 +1238,7 @@ static int osmo_cc_set_rtp(const char *text)
from = from * 10 + *text - '0';
}
osmo_cc_set_rtp_ports(from, to);
osmo_cc_set_rtp_ports(&ep->session_config, from, to);
return 0;
}
@ -1270,6 +1281,9 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u
ep->serving_location = serving_location;
ep->priv = priv;
osmo_cc_set_local_peer(&ep->session_config, osmo_cc_session_nettype_inet, osmo_cc_session_addrtype_ipv4, "127.0.0.1");
osmo_cc_set_rtp_ports(&ep->session_config, 16384, 32767);
/* apply args */
for (i = 0; i < argc; i++) {
if (!strncasecmp(argv[i], "local", 5)) {
@ -1285,7 +1299,7 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u
}
} else
if (!strncasecmp(argv[i], "rtp", 3)) {
rc = osmo_cc_set_rtp(argv[i]);
rc = osmo_cc_set_rtp(ep, argv[i]);
if (rc < 0) {
return rc;
}

@ -45,6 +45,8 @@ typedef int16_t osmo_cc_sample_t;
#define OSMO_CC_SAMPLE_MIN -32768 /* lowest level */
#define OSMO_CC_SAMPLE_MAX 32767 /* highest level */
#include "session.h"
struct osmo_cc_call;
typedef struct osmo_cc_screen_list {
@ -84,6 +86,7 @@ typedef struct osmo_cc_endpoint {
osmo_cc_screen_list_t *screen_called_out;
int remote_auto; /* automatic remote address */
struct timer attach_timer; /* timer to retry attachment */
osmo_cc_session_config_t session_config; /* SDP/RTP default configuration */
} osmo_cc_endpoint_t;
extern osmo_cc_endpoint_t *osmo_cc_endpoint_list;
@ -112,6 +115,7 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u
void osmo_cc_delete(struct osmo_cc_endpoint *ep);
int osmo_cc_handle(void);
osmo_cc_call_t *osmo_cc_call_by_callref(osmo_cc_endpoint_t *ep, uint32_t callref);
osmo_cc_call_t *osmo_cc_get_attached_interface(osmo_cc_endpoint_t *ep, const char *interface);
void osmo_cc_ll_msg(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg);
void osmo_cc_ul_msg(void *priv, uint32_t callref, osmo_cc_msg_t *msg);
osmo_cc_call_t *osmo_cc_call_new(osmo_cc_endpoint_t *ep);
@ -120,7 +124,6 @@ enum osmo_cc_session_addrtype osmo_cc_address_type(const char *address);
const char *osmo_cc_host_of_address(const char *address);
const char *osmo_cc_port_of_address(const char *address);
#include "session.h"
#include "rtp.h"
#include "sdp.h"
#include "screen.h"

@ -29,14 +29,14 @@
#include "endpoint.h"
#include "helper.h"
osmo_cc_session_t *osmo_cc_helper_audio_offer(void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint8_t *data, int len), osmo_cc_msg_t *msg, int debug)
osmo_cc_session_t *osmo_cc_helper_audio_offer(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint8_t *data, int len), osmo_cc_msg_t *msg, int debug)
{
osmo_cc_session_t *session;
osmo_cc_session_media_t *media;
const char *sdp;
int i;
session = osmo_cc_new_session(priv, NULL, NULL, NULL, 0, 0, NULL, NULL, debug);
session = osmo_cc_new_session(conf, priv, NULL, NULL, NULL, 0, 0, NULL, NULL, debug);
if (!session)
return NULL;
@ -52,7 +52,7 @@ osmo_cc_session_t *osmo_cc_helper_audio_offer(void *priv, struct osmo_cc_helper_
return session;
}
const char *osmo_cc_helper_audio_accept(void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint8_t *data, int len), osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, int force_our_codec)
const char *osmo_cc_helper_audio_accept(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint8_t *data, int len), osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, int force_our_codec)
{
char offer_sdp[65536];
const char *accept_sdp;
@ -77,7 +77,7 @@ const char *osmo_cc_helper_audio_accept(void *priv, struct osmo_cc_helper_audio_
return NULL;
}
*session_p = osmo_cc_session_receive_offer(priv, offer_sdp);
*session_p = osmo_cc_session_receive_offer(conf, priv, offer_sdp);
if (!*session_p) {
PDEBUG(DCC, DEBUG_ERROR, "Failed to parse SDP.\n");
return NULL;

@ -7,7 +7,7 @@ struct osmo_cc_helper_audio_codecs {
void (*decoder)(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len);
};
osmo_cc_session_t *osmo_cc_helper_audio_offer(void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint8_t *data, int len), osmo_cc_msg_t *msg, int debug);
const char *osmo_cc_helper_audio_accept(void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint8_t *data, int len), osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, int force_our_codec);
osmo_cc_session_t *osmo_cc_helper_audio_offer(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint8_t *data, int len), osmo_cc_msg_t *msg, int debug);
const char *osmo_cc_helper_audio_accept(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint8_t *data, int len), osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, int force_our_codec);
int osmo_cc_helper_audio_negotiate(osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p);

@ -25,6 +25,337 @@
#include "../libdebug/debug.h"
#include "message.h"
#define _OSMO_CC_VALUE2NAME(array) { \
if (value < 0 || (size_t)value >= (sizeof(array) / sizeof(array[0])) || array[value] == NULL) \
return "<unknown>"; \
else \
return array[value]; \
}
#define _OSMO_CC_NAME2VALUE(array) { \
for (int value = 0; (size_t)value < (sizeof(array) / sizeof(array[0])); value++) { \
if (!strcasecmp(array[value], name)) \
return value; \
} \
return -1; \
}
static const char *osmo_cc_msg_name[OSMO_CC_MSG_NUM] = {
[OSMO_CC_MSG_SETUP_REQ] = "CC-SETUP-REQ",
[OSMO_CC_MSG_SETUP_IND] = "CC-SETUP-IND",
[OSMO_CC_MSG_REJ_REQ] = "CC-REJ-REQ",
[OSMO_CC_MSG_REJ_IND] = "CC-REJ-IND",
[OSMO_CC_MSG_SETUP_ACK_REQ] = "CC-SETUP-ACK-REQ",
[OSMO_CC_MSG_SETUP_ACK_IND] = "CC-SETUP-ACK-IND",
[OSMO_CC_MSG_PROC_REQ] = "CC-PROC-REQ",
[OSMO_CC_MSG_PROC_IND] = "CC-PROC-IND",
[OSMO_CC_MSG_ALERT_REQ] = "CC-ALERT-REQ",
[OSMO_CC_MSG_ALERT_IND] = "CC-ALERT-IND",
[OSMO_CC_MSG_SETUP_RSP] = "CC-SETUP-RSP",
[OSMO_CC_MSG_SETUP_CNF] = "CC-SETUP-CNF",
[OSMO_CC_MSG_SETUP_COMP_REQ] = "CC-SETUP-COMP-REQ",
[OSMO_CC_MSG_SETUP_COMP_IND] = "CC-SETUP-COMP-IND",
[OSMO_CC_MSG_DISC_REQ] = "CC-DISC-REQ",
[OSMO_CC_MSG_DISC_IND] = "CC-DISC-IND",
[OSMO_CC_MSG_REL_REQ] = "CC-REL-REQ",
[OSMO_CC_MSG_REL_CNF] = "CC-REL-CNF",
[OSMO_CC_MSG_REL_IND] = "CC-REL-IND",
[OSMO_CC_MSG_PROGRESS_REQ] = "CC-PROGRESS-REQ",
[OSMO_CC_MSG_PROGRESS_IND] = "CC-PROGRESS-IND",
[OSMO_CC_MSG_NOTIFY_REQ] = "CC-NOTIFY-REQ",
[OSMO_CC_MSG_NOTIFY_IND] = "CC-NOTIFY-IND",
[OSMO_CC_MSG_INFO_REQ] = "CC-INFO-REQ",
[OSMO_CC_MSG_INFO_IND] = "CC-INFO-IND",
[OSMO_CC_MSG_ATTACH_REQ] = "CC-ATTACH-REQ",
[OSMO_CC_MSG_ATTACH_IND] = "CC-ATTACH-IND",
[OSMO_CC_MSG_ATTACH_RSP] = "CC-ATTACH-RSP",
[OSMO_CC_MSG_ATTACH_CNF] = "CC-ATTACH-CNF",
};
const char *osmo_cc_msg_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_msg_name)
int osmo_cc_msg_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_msg_name)
static const char *osmo_cc_ie_name[OSMO_CC_IE_NUM] = {
[OSMO_CC_IE_CALLED] = "IE_CALLED",
[OSMO_CC_IE_CALLED_SUB] = "IE_CALLED_SUB",
[OSMO_CC_IE_CALLED_NAME] = "IE_CALLED_NAME",
[OSMO_CC_IE_CALLED_INTERFACE] = "IE_CALLED_INTERFACE",
[OSMO_CC_IE_DTMF] = "IE_DTMF",
[OSMO_CC_IE_KEYPAD] = "IE_KEYPAD",
[OSMO_CC_IE_COMPLETE] = "IE_COMPLETE",
[OSMO_CC_IE_CALLING] = "IE_CALLING",
[OSMO_CC_IE_CALLING_SUB] = "IE_CALLING_SUB",
[OSMO_CC_IE_CALLING_NAME] = "IE_CALLING_NAME",
[OSMO_CC_IE_CALLING_INTERFACE] = "IE_CALLING_INTERFACE",
[OSMO_CC_IE_CALLING_NETWORK] = "IE_CALLING_NETWORK",
[OSMO_CC_IE_REDIR] = "IE_REDIR",
[OSMO_CC_IE_PROGRESS] = "IE_PROGRESS",
[OSMO_CC_IE_NOTIFY] = "IE_NOTIFY",
[OSMO_CC_IE_DISPLAY] = "IE_DISPLAY",
[OSMO_CC_IE_CAUSE] = "IE_CAUSE",
[OSMO_CC_IE_BEARER] = "IE_BEARER",
[OSMO_CC_IE_SDP] = "IE_SDP",
[OSMO_CC_IE_SOCKET_ADDRESS] = "IE_SOCKET_ADDRESS",
[OSMO_CC_IE_PRIVATE] = "IE_PRIVATE",
};
const char *osmo_cc_ie_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_ie_name)
int osmo_cc_ie_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_ie_name)
static const char *osmo_cc_type_name[OSMO_CC_TYPE_NUM] = {
[OSMO_CC_TYPE_UNKNOWN] = "unknown",
[OSMO_CC_TYPE_INTERNATIONAL] = "international",
[OSMO_CC_TYPE_NATIONAL] = "national",
[OSMO_CC_TYPE_NETWORK] = "network",
[OSMO_CC_TYPE_SUBSCRIBER] = "subscriber",
[OSMO_CC_TYPE_ABBREVIATED] = "abbreviated",
[OSMO_CC_TYPE_RESERVED] = "reserved",
};
const char *osmo_cc_type_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_type_name)
int osmo_cc_type_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_type_name)
static const char *osmo_cc_plan_name[OSMO_CC_PLAN_NUM] = {
[OSMO_CC_PLAN_UNKNOWN] = "unknown",
[OSMO_CC_PLAN_TELEPHONY] = "telephony",
[OSMO_CC_PLAN_DATA] = "data",
[OSMO_CC_PLAN_TTY] = "tty",
[OSMO_CC_PLAN_NATIONAL_STANDARD] = "national standard",
[OSMO_CC_PLAN_PRIVATE] = "private",
[OSMO_CC_PLAN_RESERVED] = "reserved",
};
const char *osmo_cc_plan_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_plan_name)
int osmo_cc_plan_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_plan_name)
static const char *osmo_cc_present_name[OSMO_CC_PRESENT_NUM] = {
[OSMO_CC_PRESENT_ALLOWED] = "allowed",
[OSMO_CC_PRESENT_RESTRICTED] = "restricted",
[OSMO_CC_PRESENT_NOT_AVAIL] = "not available",
[OSMO_CC_PRESENT_RESERVED] = "reserved",
};
const char *osmo_cc_present_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_present_name)
int osmo_cc_present_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_present_name)
static const char *osmo_cc_screen_name[OSMO_CC_SCREEN_NUM] = {
[OSMO_CC_SCREEN_USER_UNSCREENED] = "unscreened",
[OSMO_CC_SCREEN_USER_VERIFIED_PASSED] = "user provided and passed",
[OSMO_CC_SCREEN_USER_VERIFIED_FAILED] = "user provided an failed",
[OSMO_CC_SCREEN_NETWORK] = "network provided",
};
const char *osmo_cc_screen_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_screen_name)
int osmo_cc_screen_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_screen_name)
static const char *osmo_cc_redir_reason_name[OSMO_CC_REDIR_REASON_NUM] = {
[OSMO_CC_REDIR_REASON_UNKNOWN] = "unknown",
[OSMO_CC_REDIR_REASON_CFB] = "call forward busy",
[OSMO_CC_REDIR_REASON_CFNR] = "call forward no response",
[OSMO_CC_REDIR_REASON_CD] = "call deflect",
[OSMO_CC_REDIR_REASON_CF_OUTOFORDER] = "call forward out of order",
[OSMO_CC_REDIR_REASON_CF_BY_DTE] = "call froward by dte",
[OSMO_CC_REDIR_REASON_CFU] = "call forward unconditional",
};
const char *osmo_cc_redir_reason_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_redir_reason_name)
int osmo_cc_redir_reason_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_redir_reason_name)
static const char *osmo_cc_notify_name[OSMO_CC_NOTIFY_NUM] = {
[OSMO_CC_NOTIFY_USER_SUSPENDED] = "user suspended",
[OSMO_CC_NOTIFY_USER_RESUMED] = "user resumed",
[OSMO_CC_NOTIFY_BEARER_SERVICE_CHANGE] = "bearer service change",
[OSMO_CC_NOTIFY_CALL_COMPLETION_DELAY] = "call completion delay",
[OSMO_CC_NOTIFY_CONFERENCE_ESTABLISHED] = "conference established",
[OSMO_CC_NOTIFY_CONFERENCE_DISCONNECTED] = "conference disconnected",
[OSMO_CC_NOTIFY_OTHER_PARTY_ADDED] = "ohter party added",
[OSMO_CC_NOTIFY_ISOLATED] = "isolated",
[OSMO_CC_NOTIFY_REATTACHED] = "reattached",
[OSMO_CC_NOTIFY_OTHER_PARTY_ISOLATED] = "ohter party isolated",
[OSMO_CC_NOTIFY_OTHER_PARTY_REATTACHED] = "ohter party reattached",
[OSMO_CC_NOTIFY_OTHER_PARTY_SPLIT] = "other party split",
[OSMO_CC_NOTIFY_OTHER_PARTY_DISCONNECTED] = "other party disconnected",
[OSMO_CC_NOTIFY_CONFERENCE_FLOATING] = "confernce floating",
[OSMO_CC_NOTIFY_CONFERENCE_DISC_PREEMPT] = "confernce disconnect preemption",
[OSMO_CC_NOTIFY_CONFERENCE_FLOATING_SUP] = "conference floating sup",
[OSMO_CC_NOTIFY_CALL_IS_A_WAITING_CALL] = "call is a waiting call",
[OSMO_CC_NOTIFY_DIVERSION_ACTIVATED] = "diversion activated",
[OSMO_CC_NOTIFY_RESERVED_CT_1] = "reserved CT 1",
[OSMO_CC_NOTIFY_RESERVED_CT_2] = "reserved CT 2",
[OSMO_CC_NOTIFY_REVERSE_CHARGING] = "reverse charging",
[OSMO_CC_NOTIFY_REMOTE_HOLD] = "remote hold",
[OSMO_CC_NOTIFY_REMOTE_RETRIEVAL] = "remote retrieval",
[OSMO_CC_NOTIFY_CALL_IS_DIVERTING] = "call is diverting",
};
const char *osmo_cc_notify_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_notify_name)
int osmo_cc_notify_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_notify_name)
static const char *osmo_cc_coding_name[OSMO_CC_CODING_NUM] = {
[OSMO_CC_CODING_ITU_T] = "ITU-T",
[OSMO_CC_CODING_ISO_IEC] = "ISO/IEC",
[OSMO_CC_CODING_NATIONAL] = "national",
[OSMO_CC_CODING_STANDARD_SPECIFIC] = "standard specific",
};
const char *osmo_cc_coding_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_coding_name)
int osmo_cc_coding_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_coding_name)
static const char *osmo_cc_isdn_cause_name[OSMO_CC_ISDN_CAUSE_NUM] = {
[0] = "unset",
[OSMO_CC_ISDN_CAUSE_UNASSIGNED_NR] = "unsassigned number",
[OSMO_CC_ISDN_CAUSE_NO_ROUTE_TRANSIT] = "no route to transit network",
[OSMO_CC_ISDN_CAUSE_NO_ROUTE] = "no route",
[OSMO_CC_ISDN_CAUSE_CHAN_UNACCEPT] = "channel unacceptable",
[OSMO_CC_ISDN_CAUSE_OP_DET_BARRING] = "detected barring",
[OSMO_CC_ISDN_CAUSE_NORM_CALL_CLEAR] = "normal call clearing",
[OSMO_CC_ISDN_CAUSE_USER_BUSY] = "user busy",
[OSMO_CC_ISDN_CAUSE_USER_NOTRESPOND] = "user not responding",
[OSMO_CC_ISDN_CAUSE_USER_ALERTING_NA] = "user does not answer",
[OSMO_CC_ISDN_CAUSE_CALL_REJECTED] = "call rejected",
[OSMO_CC_ISDN_CAUSE_NUMBER_CHANGED] = "number changed",
[OSMO_CC_ISDN_CAUSE_PRE_EMPTION] = "pre-emption",
[OSMO_CC_ISDN_CAUSE_NONSE_USER_CLR] = "non-selected user clearing",
[OSMO_CC_ISDN_CAUSE_DEST_OOO] = "destination out-of-order",
[OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT] = "invalid number format",
[OSMO_CC_ISDN_CAUSE_FACILITY_REJ] = "facility rejected",
[OSMO_CC_ISDN_CAUSE_RESP_STATUS_INQ] = "response to status enquiery",
[OSMO_CC_ISDN_CAUSE_NORMAL_UNSPEC] = "normal, uspecified",
[OSMO_CC_ISDN_CAUSE_NO_CIRCUIT_CHAN] = "no circuit/channel available",
[OSMO_CC_ISDN_CAUSE_NETWORK_OOO] = "network out of order",
[OSMO_CC_ISDN_CAUSE_TEMP_FAILURE] = "temporary failure",
[OSMO_CC_ISDN_CAUSE_SWITCH_CONG] = "switching equipment congested",
[OSMO_CC_ISDN_CAUSE_ACC_INF_DISCARD] = "access information discarded",
[OSMO_CC_ISDN_CAUSE_REQ_CHAN_UNAVAIL] = "requested circuit/channel unavailable",
[OSMO_CC_ISDN_CAUSE_RESOURCE_UNAVAIL] = "resource unavailable",
[OSMO_CC_ISDN_CAUSE_QOS_UNAVAIL] = "quality of service unavailable",
[OSMO_CC_ISDN_CAUSE_REQ_FAC_NOT_SUBSC] = "requested facility not subscribed",
[OSMO_CC_ISDN_CAUSE_INC_BARRED_CUG] = "inc barred in closed user group",
[OSMO_CC_ISDN_CAUSE_BEARER_CAP_UNAUTH] = "bearer capability unauthorized",
[OSMO_CC_ISDN_CAUSE_BEARER_CA_UNAVAIL] = "bearer capability not available",
[OSMO_CC_ISDN_CAUSE_SERV_OPT_UNAVAIL] = "service or option not available",
[OSMO_CC_ISDN_CAUSE_BEARERSERV_UNIMPL] = "bearer service unimplemented",
[OSMO_CC_ISDN_CAUSE_ACM_GE_ACM_MAX] = "acm ge ach max",
[OSMO_CC_ISDN_CAUSE_REQ_FAC_NOTIMPL] = "requrested facility not implemented",
[OSMO_CC_ISDN_CAUSE_RESTR_BCAP_AVAIL] = "restricted bearer capabilitey available",
[OSMO_CC_ISDN_CAUSE_SERV_OPT_UNIMPL] = "service or option unimplemented",
[OSMO_CC_ISDN_CAUSE_INVAL_CALLREF] = "invalid call reference",
[OSMO_CC_ISDN_CAUSE_USER_NOT_IN_CUG] = "user not in closed user group",
[OSMO_CC_ISDN_CAUSE_INCOMPAT_DEST] = "incompatible destination",
[OSMO_CC_ISDN_CAUSE_INVAL_TRANS_NET] = "invalid transit network",
[OSMO_CC_ISDN_CAUSE_SEMANTIC_INCORR] = "semantically incorrect",
[OSMO_CC_ISDN_CAUSE_INVAL_MAND_INF] = "invalid mandatory information",
[OSMO_CC_ISDN_CAUSE_MSGTYPE_NOTEXIST] = "message type does not exist",
[OSMO_CC_ISDN_CAUSE_MSGTYPE_INCOMPAT] = "message type incompatible",
[OSMO_CC_ISDN_CAUSE_IE_NOTEXIST] = "informaton element does not exits",
[OSMO_CC_ISDN_CAUSE_COND_IE_ERR] = "conditional information element error",
[OSMO_CC_ISDN_CAUSE_MSG_INCOMP_STATE] = "message at incompatlible state",
[OSMO_CC_ISDN_CAUSE_RECOVERY_TIMER] = "recovery on time expiery",
[OSMO_CC_ISDN_CAUSE_PROTO_ERR] = "protocol error",
[OSMO_CC_ISDN_CAUSE_INTERWORKING] = "interworking, unspecified",
};
const char *osmo_cc_isdn_cause_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_isdn_cause_name)
int osmo_cc_isdn_cause_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_isdn_cause_name)
static const char *osmo_cc_location_name[OSMO_CC_LOCATION_NUM] = {
[OSMO_CC_LOCATION_USER] = "user",
[OSMO_CC_LOCATION_PRIV_SERV_LOC_USER] = "private network serving local user",
[OSMO_CC_LOCATION_PUB_SERV_LOC_USER] = "public network serving local user",
[OSMO_CC_LOCATION_TRANSIT] = "transit network",
[OSMO_CC_LOCATION_PUB_SERV_REM_USER] = "public network serving remote user",
[OSMO_CC_LOCATION_PRIV_SERV_REM_USER] = "private network serving remote user",
[OSMO_CC_LOCATION_BEYOND_INTERWORKING] = "beyond interworking",
};
const char *osmo_cc_location_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_location_name)
int osmo_cc_location_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_location_name)
static const char *osmo_cc_progress_name[OSMO_CC_PROGRESS_NUM] = {
[OSMO_CC_PROGRESS_NOT_END_TO_END_ISDN] = "not end-to-end ISDN",
[OSMO_CC_PROGRESS_DEST_NOT_ISDN] = "destination not ISDN",
[OSMO_CC_PROGRESS_ORIG_NOT_ISDN] = "originator not ISDN",
[OSMO_CC_PROGRESS_RETURN_TO_ISDN] = "return to ISDN",
[OSMO_CC_PROGRESS_INTERWORKING] = "interworking",
[OSMO_CC_PROGRESS_INBAND_INFO_AVAILABLE] = "inmand information available (audio)",
};
const char *osmo_cc_progress_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_progress_name)
int osmo_cc_progress_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_progress_name)
static const char *osmo_cc_capability_name[OSMO_CC_CAPABILITY_NUM] = {
[OSMO_CC_CAPABILITY_SPEECH] = "speech",
[OSMO_CC_CAPABILITY_DATA] = "data",
[OSMO_CC_CAPABILITY_DATA_RESTRICTED] = "data restricted",
[OSMO_CC_CAPABILITY_AUDIO] = "audio",
[OSMO_CC_CAPABILITY_DATA_WITH_TONES] = "data with tones",
[OSMO_CC_CAPABILITY_VIDEO] = "video",
};
const char *osmo_cc_capability_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_capability_name)
int osmo_cc_capability_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_capability_name)
static const char *osmo_cc_mode_name[OSMO_CC_MODE_NUM] = {
[OSMO_CC_MODE_CIRCUIT] = "circuit",
[OSMO_CC_MODE_PACKET] = "packet",
};
const char *osmo_cc_mode_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_mode_name)
int osmo_cc_mode_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_mode_name)
static const char *osmo_cc_dtmf_mode_name[OSMO_CC_DTMF_MODE_NUM] = {
[OSMO_CC_DTMF_MODE_OFF] = "off",
[OSMO_CC_DTMF_MODE_ON] = "on",
[OSMO_CC_DTMF_MODE_DIGITS] = "digit",
};
const char *osmo_cc_dtmf_mode_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_dtmf_mode_name)
int osmo_cc_dtmf_mode_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_dtmf_mode_name)
static const char *osmo_cc_socket_cause_name[OSMO_CC_SOCKET_CAUSE_NUM] = {
[0] = "unset",
[OSMO_CC_SOCKET_CAUSE_VERSION_MISMATCH] = "version mismatch",
[OSMO_CC_SOCKET_CAUSE_FAILED] = "socket failed",
[OSMO_CC_SOCKET_CAUSE_BROKEN_PIPE] = "broken pipe",
[OSMO_CC_SOCKET_CAUSE_TIMEOUT] = "keepalive timeout",
};
const char *osmo_cc_socket_cause_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_socket_cause_name)
int osmo_cc_socket_cause_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_socket_cause_name)
static const char *osmo_cc_network_name[OSMO_CC_NETWORK_NUM] = {
[OSMO_CC_NETWORK_UNDEFINED] = "undefined",
[OSMO_CC_NETWORK_ALSA_NONE] = "alsa",
[OSMO_CC_NETWORK_POTS_NONE] = "pots",
[OSMO_CC_NETWORK_ISDN_NONE] = "isdn",
[OSMO_CC_NETWORK_SIP_NONE] = "sip",
[OSMO_CC_NETWORK_GSM_IMSI] = "gsm-imsi",
[OSMO_CC_NETWORK_GSM_IMEI] = "gsm-imei",
[OSMO_CC_NETWORK_WEB_NONE] = "web",
[OSMO_CC_NETWORK_DECT_NONE] = "decs",
[OSMO_CC_NETWORK_BLUETOOTH_NONE] = "bluetooth",
[OSMO_CC_NETWORK_SS5_NONE] = "ss5",
[OSMO_CC_NETWORK_ANETZ_NONE] = "anetz",
[OSMO_CC_NETWORK_BNETZ_MUENZ] = "bnetz",
[OSMO_CC_NETWORK_CNETZ_NONE] = "cnetz",
[OSMO_CC_NETWORK_NMT_NONE] = "nmt",
[OSMO_CC_NETWORK_R2000_NONE] = "radiocom2000",
[OSMO_CC_NETWORK_AMPS_ESN] = "amps",
[OSMO_CC_NETWORK_MTS_NONE] = "mts",
[OSMO_CC_NETWORK_IMTS_NONE] = "imts",
[OSMO_CC_NETWORK_EUROSIGNAL_NONE] = "eurosignal",
[OSMO_CC_NETWORK_JOLLYCOM_NONE] = "jollycom",
[OSMO_CC_NETWORK_MPT1327_PSTN] = "mpt1327-pstn",
[OSMO_CC_NETWORK_MPT1327_PBX] = "mpt1327-pbx",
};
const char *osmo_cc_network_value2name(int value) _OSMO_CC_VALUE2NAME(osmo_cc_network_name)
int osmo_cc_network_name2value(const char *name) _OSMO_CC_NAME2VALUE(osmo_cc_network_name)
/*
*
*/
static uint32_t new_callref = 0;
uint32_t osmo_cc_new_callref(void)
@ -32,126 +363,6 @@ uint32_t osmo_cc_new_callref(void)
return (++new_callref);
}
const char *osmo_cc_msg_name(uint8_t msg_type)
{
switch (msg_type) {
case OSMO_CC_MSG_SETUP_REQ:
return "CC-SETUP-REQ";
case OSMO_CC_MSG_SETUP_IND:
return "CC-SETUP-IND";
case OSMO_CC_MSG_REJ_REQ:
return "CC-REJ-REQ";
case OSMO_CC_MSG_REJ_IND:
return "CC-REJ-IND";
case OSMO_CC_MSG_SETUP_ACK_REQ:
return "CC-SETUP-ACK-REQ";
case OSMO_CC_MSG_SETUP_ACK_IND:
return "CC-SETUP-ACK-IND";
case OSMO_CC_MSG_PROC_REQ:
return "CC-PROC-REQ";
case OSMO_CC_MSG_PROC_IND:
return "CC-PROC-IND";
case OSMO_CC_MSG_ALERT_REQ:
return "CC-ALERT-REQ";
case OSMO_CC_MSG_ALERT_IND:
return "CC-ALERT-IND";
case OSMO_CC_MSG_SETUP_RSP:
return "CC-SETUP-RSP";
case OSMO_CC_MSG_SETUP_CNF:
return "CC-SETUP-CNF";
case OSMO_CC_MSG_SETUP_COMP_REQ:
return "CC-SETUP-COMP-REQ";
case OSMO_CC_MSG_SETUP_COMP_IND:
return "CC-SETUP-COMP-IND";
case OSMO_CC_MSG_DISC_REQ:
return "CC-DISC-REQ";
case OSMO_CC_MSG_DISC_IND:
return "CC-DISC-IND";
case OSMO_CC_MSG_REL_REQ:
return "CC-REL-REQ";
case OSMO_CC_MSG_REL_CNF:
return "CC-REL-CNF";
case OSMO_CC_MSG_REL_IND:
return "CC-REL-IND";
case OSMO_CC_MSG_PROGRESS_REQ:
return "CC-PROGRESS-REQ";
case OSMO_CC_MSG_PROGRESS_IND:
return "CC-PROGRESS-IND";
case OSMO_CC_MSG_NOTIFY_REQ:
return "CC-NOTIFY-REQ";
case OSMO_CC_MSG_NOTIFY_IND:
return "CC-NOTIFY-IND";
case OSMO_CC_MSG_INFO_REQ:
return "CC-INFO-REQ";
case OSMO_CC_MSG_INFO_IND:
return "CC-INFO-IND";
case OSMO_CC_MSG_ATTACH_REQ:
return "CC-ATTACH-REQ";
case OSMO_CC_MSG_ATTACH_IND:
return "CC-ATTACH-IND";
case OSMO_CC_MSG_ATTACH_RSP:
return "CC-ATTACH-RSP";
case OSMO_CC_MSG_ATTACH_CNF:
return "CC-ATTACH-CNF";
default:
return "<unknown>";
}
}
const char *osmo_cc_network_type_name(uint8_t type)
{
switch (type) {
case OSMO_CC_NETWORK_UNDEFINED:
return "";
case OSMO_CC_NETWORK_ALSA_NONE:
return "alsa";
case OSMO_CC_NETWORK_POTS_NONE:
return "pots";
case OSMO_CC_NETWORK_ISDN_NONE:
return "isdn";
case OSMO_CC_NETWORK_SIP_NONE:
return "sip";
case OSMO_CC_NETWORK_GSM_IMSI:
return "gsm-imsi";
case OSMO_CC_NETWORK_GSM_IMEI:
return "gsm-imei";
case OSMO_CC_NETWORK_WEB_NONE:
return "web";
case OSMO_CC_NETWORK_DECT_NONE:
return "decs";
case OSMO_CC_NETWORK_BLUETOOTH_NONE:
return "bluetooth";
case OSMO_CC_NETWORK_SS5_NONE:
return "ss5";
case OSMO_CC_NETWORK_ANETZ_NONE:
return "anetz";
case OSMO_CC_NETWORK_BNETZ_MUENZ:
return "bnetz";
case OSMO_CC_NETWORK_CNETZ_NONE:
return "cnetz";
case OSMO_CC_NETWORK_NMT_NONE:
return "nmt";
case OSMO_CC_NETWORK_R2000_NONE:
return "radiocom2000";
case OSMO_CC_NETWORK_AMPS_ESN:
return "amps";
case OSMO_CC_NETWORK_MTS_NONE:
return "mts";
case OSMO_CC_NETWORK_IMTS_NONE:
return "imts";
case OSMO_CC_NETWORK_EUROSIGNAL_NONE:
return "eurosignal";
case OSMO_CC_NETWORK_JOLLYCOM_NONE:
return "jollycom";
case OSMO_CC_NETWORK_MPT1327_PSTN:
return "mpt1327-pstn";
case OSMO_CC_NETWORK_MPT1327_PBX:
return "mpt1327-pbx";
default:
return "<unknown>";
}
}
/* create message with maximum size */
osmo_cc_msg_t *osmo_cc_new_msg(uint8_t msg_type)
{
@ -217,16 +428,24 @@ void osmo_cc_free_msg(osmo_cc_msg_t *msg)
free(msg);
}
static void osmo_cc_debug_ie(osmo_cc_msg_t *msg, int level)
void osmo_cc_debug_ie(osmo_cc_msg_t *msg, int level)
{
uint16_t msg_len, len;
uint8_t *p;
osmo_cc_ie_t *ie;
int rc;
int ie_repeat[256];
uint8_t type, plan, present, screen, coding, capability, mode, progress, reason, duration_ms, pause_ms, dtmf_mode, location, notify, isdn_cause, socket_cause;
uint16_t sip_cause;
uint32_t unique;
char string[65536];
int i;
memset(ie_repeat, 0, sizeof(ie_repeat));
msg_len = ntohs(msg->length_networkorder);
p = msg->data;
PDEBUG(DCC, level, "Debugging Message: type=0x%02x length=%d value=%s\n", msg->type, msg_len, debug_hex(p, msg_len));
while (msg_len) {
ie = (osmo_cc_ie_t *)p;
/* check for minimum IE length */
@ -241,7 +460,143 @@ static void osmo_cc_debug_ie(osmo_cc_msg_t *msg, int level)
PDEBUG(DCC, level, "****** IE: type=0x%02x length=%d would exceed the rest length of message (%d bytes left)\n", ie->type, len, msg_len - (int)sizeof(*ie));
return;
}
PDEBUG(DCC, level, "IE: type=0x%02x length=%d value=%s\n", ie->type, len, debug_hex(ie->data, len));
switch (ie->type) {
case OSMO_CC_IE_CALLED:
rc = osmo_cc_get_ie_called(msg, ie_repeat[ie->type], &type, &plan, string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s type=%d(%s) plan=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), string);
break;
case OSMO_CC_IE_CALLED_SUB:
rc = osmo_cc_get_ie_called_sub(msg, ie_repeat[ie->type], &type, string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s type=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), string);
break;
case OSMO_CC_IE_CALLED_NAME:
rc = osmo_cc_get_ie_called_name(msg, ie_repeat[ie->type], string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string);
break;
case OSMO_CC_IE_CALLED_INTERFACE:
rc = osmo_cc_get_ie_called_interface(msg, ie_repeat[ie->type], string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string);
break;
case OSMO_CC_IE_COMPLETE:
rc = osmo_cc_get_ie_complete(msg, ie_repeat[ie->type]);
if (rc < 0)
break;
PDEBUG(DCC, level, " %s\n", osmo_cc_ie_value2name(ie->type));
break;
case OSMO_CC_IE_CALLING:
rc = osmo_cc_get_ie_calling(msg, ie_repeat[ie->type], &type, &plan, &present, &screen, string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s type=%d(%s) plan=%d(%s), presentation=%d(%s), screening=%d(%s), number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), present, osmo_cc_present_value2name(present), screen, osmo_cc_screen_value2name(screen), string);
break;
case OSMO_CC_IE_CALLING_SUB:
rc = osmo_cc_get_ie_calling_sub(msg, ie_repeat[ie->type], &type, string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s type=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), string);
break;
case OSMO_CC_IE_CALLING_NAME:
rc = osmo_cc_get_ie_calling_name(msg, ie_repeat[ie->type], string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string);
break;
case OSMO_CC_IE_CALLING_INTERFACE:
rc = osmo_cc_get_ie_calling_interface(msg, ie_repeat[ie->type], string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string);
break;
case OSMO_CC_IE_CALLING_NETWORK:
rc = osmo_cc_get_ie_calling_network(msg, ie_repeat[ie->type], &type, string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s type=%d(%s) id='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_network_value2name(type), string);
break;
case OSMO_CC_IE_BEARER:
rc = osmo_cc_get_ie_bearer(msg, ie_repeat[ie->type], &coding, &capability, &mode);
if (rc < 0)
break;
PDEBUG(DCC, level, " %s coding=%d(%s) capability=%d(%s) mode=%d(%s)\n", osmo_cc_ie_value2name(ie->type), coding, osmo_cc_coding_value2name(coding), capability, osmo_cc_capability_value2name(capability), mode, osmo_cc_mode_value2name(mode));
break;
case OSMO_CC_IE_REDIR:
rc = osmo_cc_get_ie_redir(msg, ie_repeat[ie->type], &type, &plan, &present, &screen, &reason, string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s type=%d(%s) plan=%d(%s) presentation=%d(%s) screening=%d(%s) reason=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), present, osmo_cc_present_value2name(present), screen, osmo_cc_screen_value2name(screen), reason, osmo_cc_redir_reason_value2name(reason), string);
break;
case OSMO_CC_IE_DTMF:
rc = osmo_cc_get_ie_dtmf(msg, ie_repeat[ie->type], &duration_ms, &pause_ms, &dtmf_mode, string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s duration=%dms pause=%dms mode=%d(%s)\n", osmo_cc_ie_value2name(ie->type), duration_ms, pause_ms, dtmf_mode, osmo_cc_dtmf_mode_value2name(dtmf_mode));
break;
case OSMO_CC_IE_KEYPAD:
rc = osmo_cc_get_ie_keypad(msg, ie_repeat[ie->type], string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s digits='%s'\n", osmo_cc_ie_value2name(ie->type), string);
break;
case OSMO_CC_IE_PROGRESS:
rc = osmo_cc_get_ie_progress(msg, ie_repeat[ie->type], &coding, &location, &progress);
if (rc < 0)
break;
PDEBUG(DCC, level, " %s coding=%d(%s) location=%d(%s) progress=%d(%s)\n", osmo_cc_ie_value2name(ie->type), coding, osmo_cc_coding_value2name(coding), location, osmo_cc_location_value2name(location), progress, osmo_cc_progress_value2name(progress));
break;
case OSMO_CC_IE_NOTIFY:
rc = osmo_cc_get_ie_notify(msg, ie_repeat[ie->type], &notify);
if (rc < 0)
break;
PDEBUG(DCC, level, " %s indicator=%d(%s)\n", osmo_cc_ie_value2name(ie->type), notify, osmo_cc_notify_value2name(notify));
break;
case OSMO_CC_IE_CAUSE:
rc = osmo_cc_get_ie_cause(msg, ie_repeat[ie->type], &location, &isdn_cause, &sip_cause, &socket_cause);
if (rc < 0)
break;
PDEBUG(DCC, level, " %s location=%d(%s) isdn_cause=%d(%s) sip_cause=%d socket_cause=%d(%s)\n", osmo_cc_ie_value2name(ie->type), location, osmo_cc_location_value2name(location), isdn_cause, osmo_cc_isdn_cause_value2name(isdn_cause), sip_cause, socket_cause, osmo_cc_socket_cause_value2name(socket_cause));
break;
case OSMO_CC_IE_DISPLAY:
rc = osmo_cc_get_ie_display(msg, ie_repeat[ie->type], string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s info='%s'\n", osmo_cc_ie_value2name(ie->type), string);
break;
case OSMO_CC_IE_SDP:
rc = osmo_cc_get_ie_sdp(msg, ie_repeat[ie->type], string, sizeof(string));
if (rc < 0)
break;
for (i = 0; string[i]; i++) {
if (string[i] == '\r')
string[i] = '\\';
if (string[i] == '\n')
string[i] = 'n';
}
PDEBUG(DCC, level, " %s payload=%s\n", osmo_cc_ie_value2name(ie->type), string);
break;
case OSMO_CC_IE_SOCKET_ADDRESS:
rc = osmo_cc_get_ie_socket_address(msg, ie_repeat[ie->type], string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s address='%s'\n", osmo_cc_ie_value2name(ie->type), string);
break;
case OSMO_CC_IE_PRIVATE:
rc = osmo_cc_get_ie_private(msg, ie_repeat[ie->type], &unique, (uint8_t *)string, sizeof(string));
if (rc < 0)
break;
PDEBUG(DCC, level, " %s unique=%u=0x%08x private=%s\n", osmo_cc_ie_value2name(ie->type), unique, unique, debug_hex((uint8_t *)string, rc));
break;
default:
PDEBUG(DCC, level, " %s type=0x%02x length=%d value=%s\n", osmo_cc_ie_value2name(ie->type), ie->type, len, debug_hex(ie->data, len));
}
ie_repeat[ie->type]++;
p += sizeof(*ie) + len;
msg_len -= sizeof(*ie) + len;
}
@ -927,7 +1282,9 @@ int osmo_cc_get_ie_private(osmo_cc_msg_t *msg, int ie_repeat, uint32_t *unique,
if (rc < 0)
return rc;
*unique = ntohl(ie_private->unique_networkorder);
memcpy(data, ie_private->data, (rc < (int)data_size) ? rc : (int)data_size);
if (rc > (int)data_size)
rc = data_size;
memcpy(data, ie_private->data, rc);
return rc;
}

@ -36,6 +36,7 @@ enum osmo_cc_msg_type {
OSMO_CC_MSG_ATTACH_CNF = 0xfb,
OSMO_CC_MSG_DUMMY_REQ = 0xfc,
};
#define OSMO_CC_MSG_NUM 0x100
#define OSMO_CC_MSG_MASK 0x03,
#define OSMO_CC_MSG_REQ 0x00,
@ -43,6 +44,9 @@ enum osmo_cc_msg_type {
#define OSMO_CC_MSG_RSP 0x02,
#define OSMO_CC_MSG_CNF 0x03,
const char *osmo_cc_msg_value2name(int value);
int osmo_cc_msg_name2value(const char *name);
/* information elements */
enum osmo_cc_ie_type {
OSMO_CC_IE_CALLED = 0x11,
@ -67,6 +71,10 @@ enum osmo_cc_ie_type {
OSMO_CC_IE_SOCKET_ADDRESS = 0x5e,
OSMO_CC_IE_PRIVATE = 0x5f,
};
#define OSMO_CC_IE_NUM 0x100
const char *osmo_cc_ie_value2name(int value);
int osmo_cc_ie_name2value(const char *name);
/* type of number, see ITU-T Rec. Q.931 */
#define OSMO_CC_TYPE_UNKNOWN 0
@ -76,6 +84,10 @@ enum osmo_cc_ie_type {
#define OSMO_CC_TYPE_SUBSCRIBER 4
#define OSMO_CC_TYPE_ABBREVIATED 5
#define OSMO_CC_TYPE_RESERVED 7
#define OSMO_CC_TYPE_NUM 8
const char *osmo_cc_type_value2name(int value);
int osmo_cc_type_name2value(const char *name);
/* numbering plan, see ITU-T Rec. Q.931 */
#define OSMO_CC_PLAN_UNKNOWN 0
@ -85,18 +97,30 @@ enum osmo_cc_ie_type {
#define OSMO_CC_PLAN_NATIONAL_STANDARD 8
#define OSMO_CC_PLAN_PRIVATE 9
#define OSMO_CC_PLAN_RESERVED 15
#define OSMO_CC_PLAN_NUM 16
const char *osmo_cc_plan_value2name(int value);
int osmo_cc_plan_name2value(const char *name);
/* presentation indicator, see ITU-T Rec. Q.931 */
#define OSMO_CC_PRESENT_ALLOWED 0
#define OSMO_CC_PRESENT_RESTRICTED 1
#define OSMO_CC_PRESENT_NOT_AVAIL 2
#define OSMO_CC_PRESENT_RESERVED 3
#define OSMO_CC_PRESENT_NUM 4
const char *osmo_cc_present_value2name(int value);
int osmo_cc_present_name2value(const char *name);
/* screening indicator, see ITU-T Rec. Q.931 */
#define OSMO_CC_SCREEN_USER_UNSCREENED 0
#define OSMO_CC_SCREEN_USER_VERIFIED_PASSED 1
#define OSMO_CC_SCREEN_USER_VERIFIED_FAILED 2
#define OSMO_CC_SCREEN_NETWORK 3
#define OSMO_CC_SCREEN_NUM 4
const char *osmo_cc_screen_value2name(int value);
int osmo_cc_screen_name2value(const char *name);
/* screening indicator, see ITU-T Rec. Q.931 */
#define OSMO_CC_REDIR_REASON_UNKNOWN 0
@ -106,6 +130,10 @@ enum osmo_cc_ie_type {
#define OSMO_CC_REDIR_REASON_CF_OUTOFORDER 9
#define OSMO_CC_REDIR_REASON_CF_BY_DTE 10
#define OSMO_CC_REDIR_REASON_CFU 15
#define OSMO_CC_REDIR_REASON_NUM 16
const char *osmo_cc_redir_reason_value2name(int value);
int osmo_cc_redir_reason_name2value(const char *name);
/* notification indicator, see ITU-T Rec. Q.931 ff. */
#define OSMO_CC_NOTIFY_USER_SUSPENDED 0x00