aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmobile/call.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmobile/call.c')
-rw-r--r--src/libmobile/call.c256
1 files changed, 161 insertions, 95 deletions
diff --git a/src/libmobile/call.c b/src/libmobile/call.c
index 5aefa7b..69f1627 100644
--- a/src/libmobile/call.c
+++ b/src/libmobile/call.c
@@ -26,17 +26,19 @@
#include <sys/time.h>
#include <arpa/inet.h>
#include "../libsample/sample.h"
-#include "../libdebug/debug.h"
-#include "../libtimer/timer.h"
-#include "../libosmocc/endpoint.h"
-#include "../libosmocc/helper.h"
-#include "../libg711/g711.h"
+#include "../liblogging/logging.h"
+#include <osmocom/core/timer.h>
+#include <osmocom/core/select.h>
+#include <osmocom/cc/endpoint.h>
+#include <osmocom/cc/helper.h>
+#include <osmocom/cc/g711.h>
+#include <osmocom/cc/rtp.h>
#include "cause.h"
#include "sender.h"
#include "call.h"
#include "console.h"
-#define DISC_TIMEOUT 30
+#define DISC_TIMEOUT 30, 0
//#define DEBUG_LEVEL
@@ -60,7 +62,7 @@ static int release_on_disconnect; /* release towards mobile phone, if OSMO-CC ca
osmo_cc_endpoint_t endpoint, *ep;
-void encode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len)
+void encode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *arg)
{
uint16_t *src = (uint16_t *)src_data, *dst;
int len = src_len / 2, i;
@@ -74,7 +76,7 @@ void encode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len
*dst_len = len * 2;
}
-void decode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len)
+void decode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *arg)
{
uint16_t *src = (uint16_t *)src_data, *dst;
int len = src_len / 2, i;
@@ -95,6 +97,8 @@ static struct osmo_cc_helper_audio_codecs codecs[] = {
{ NULL, 0, 0, NULL, NULL},
};
+static int no_l16 = 0;
+
/* stream patterns/announcements */
int16_t *ringback_spl = NULL;
int ringback_size = 0;
@@ -250,14 +254,14 @@ typedef struct process {
enum audio_pattern pattern;
int audio_pos;
uint8_t cause;
- struct timer timer;
+ struct osmo_timer_list timer;
osmo_cc_session_t *session;
osmo_cc_session_codec_t *codec; /* codec to send */
} process_t;
static process_t *process_head = NULL;
-static void process_timeout(struct timer *timer);
+static void process_timeout(void *data);
static void indicate_disconnect_release(int callref, int cause, uint8_t msg_type);
static process_t *create_process(int callref, enum process_state state)
@@ -266,10 +270,10 @@ static process_t *create_process(int callref, enum process_state state)
process = calloc(sizeof(*process), 1);
if (!process) {
- PDEBUG(DCALL, DEBUG_ERROR, "No memory!\n");
+ LOGP(DCALL, LOGL_ERROR, "No memory!\n");
abort();
}
- timer_init(&process->timer, process_timeout, process);
+ osmo_timer_setup(&process->timer, process_timeout, process);
process->next = process_head;
process_head = process;
@@ -287,7 +291,7 @@ static void destroy_process(int callref)
while (process) {
if (process->callref == callref) {
*process_p = process->next;
- timer_exit(&process->timer);
+ osmo_timer_del(&process->timer);
if (process->session)
osmo_cc_free_session(process->session);
free(process);
@@ -296,7 +300,7 @@ static void destroy_process(int callref)
process_p = &process->next;
process = process->next;
}
- PDEBUG(DCALL, DEBUG_ERROR, "Process with callref %d not found!\n", callref);
+ LOGP(DCALL, LOGL_ERROR, "Process with callref %d not found!\n", callref);
}
static process_t *get_process(int callref)
@@ -316,10 +320,10 @@ static void new_state_process(int callref, enum process_state state)
process_t *process = get_process(callref);
if (!process) {
- PDEBUG(DCALL, DEBUG_ERROR, "Process with callref %d not found!\n", callref);
+ LOGP(DCALL, LOGL_ERROR, "Process with callref %d not found!\n", callref);
return;
}
- PDEBUG(DCALL, DEBUG_DEBUG, "Changing state for callref %d %d->%d\n", callref, process->state, state);
+ LOGP(DCALL, LOGL_DEBUG, "Changing state for callref %d %d->%d\n", callref, process->state, state);
process->state = state;
}
@@ -328,7 +332,7 @@ static void set_pattern_process(int callref, enum audio_pattern pattern)
process_t *process = get_process(callref);
if (!process) {
- PDEBUG(DCALL, DEBUG_ERROR, "Process with callref %d not found!\n", callref);
+ LOGP(DCALL, LOGL_ERROR, "Process with callref %d not found!\n", callref);
return;
}
process->pattern = pattern;
@@ -341,14 +345,14 @@ static void disconnect_process(int callref, int cause)
process_t *process = get_process(callref);
if (!process) {
- PDEBUG(DCALL, DEBUG_ERROR, "Process with callref %d not found!\n", callref);
+ LOGP(DCALL, LOGL_ERROR, "Process with callref %d not found!\n", callref);
return;
}
process->pattern = cause2pattern(cause);
process->audio_disconnected = 1;
process->audio_pos = 0;
process->cause = cause;
- timer_start(&process->timer, DISC_TIMEOUT);
+ osmo_timer_schedule(&process->timer, DISC_TIMEOUT);
}
static void get_process_patterns(process_t *process, int16_t *samples, int length)
@@ -371,14 +375,14 @@ static void get_process_patterns(process_t *process, int16_t *samples, int lengt
process->audio_pos = pos;
}
-static void process_timeout(struct timer *timer)
+static void process_timeout(void *data)
{
- process_t *process = (process_t *)timer->priv;
+ process_t *process = data;
{
/* announcement timeout */
if (process->state == PROCESS_DISCONNECT) {
- PDEBUG(DCALL, DEBUG_INFO, "Call released toward mobile network (after timeout)\n");
+ LOGP(DCALL, LOGL_INFO, "Call released toward mobile network (after timeout)\n");
call_down_release(process->callref, process->cause);
}
indicate_disconnect_release(process->callref, process->cause, OSMO_CC_MSG_REL_IND);
@@ -386,20 +390,22 @@ static void process_timeout(struct timer *timer)
}
}
-void down_audio(struct osmo_cc_session_codec *codec, uint16_t __attribute__((unused)) sequence_number, uint32_t __attribute__((unused)) timestamp, uint8_t *data, int len)
+static void down_audio(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *payload, int payload_len)
{
process_t *process = codec->media->session->priv;
- sample_t samples[len / 2];
+// sample_t samples[len / 2];
/* if we are disconnected, ignore audio */
if (!process || process->pattern != PATTERN_NONE)
return;
- int16_to_samples(samples, (int16_t *)data, len / 2);
+#if 0
+ int16_to_samples_speech(samples, (int16_t *)data, len / 2);
#ifdef DEBUG_LEVEL
double lev = level_of(samples, len / 2);
printf("festnetz-level: %s %.4f\n", debug_db(lev), (20 * log10(lev)));
#endif
- call_down_audio(process->callref, samples, len / 2);
+#endif
+ call_down_audio(codec->decoder, process, process->callref, marker, sequence_number, timestamp, ssrc, payload, payload_len);
}
static void indicate_setup(process_t *process, const char *callerid, const char *dialing, uint8_t network_type, const char *network_id)
@@ -419,9 +425,9 @@ static void indicate_setup(process_t *process, const char *callerid, const char
/* bearer capability */
osmo_cc_add_ie_bearer(msg, OSMO_CC_CODING_ITU_T, OSMO_CC_CAPABILITY_AUDIO, OSMO_CC_MODE_CIRCUIT);
/* sdp offer */
- process->session = osmo_cc_helper_audio_offer(&ep->session_config, process, codecs, down_audio, msg, 1);
+ process->session = osmo_cc_helper_audio_offer(&ep->session_config, process, codecs + no_l16, down_audio, msg, 1);
- PDEBUG(DCALL, DEBUG_INFO, "Indicate OSMO-CC setup towards fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Indicate OSMO-CC setup towards fixed network\n");
osmo_cc_ll_msg(ep, process->callref, msg);
}
@@ -437,7 +443,7 @@ static void indicate_proceeding(int callref, const char *sdp)
/* progress information */
osmo_cc_add_ie_progress(msg, OSMO_CC_CODING_ITU_T, OSMO_CC_LOCATION_BEYOND_INTERWORKING, OSMO_CC_PROGRESS_INBAND_INFO_AVAILABLE);
- PDEBUG(DCALL, DEBUG_INFO, "Indicate OSMO-CC call confirm towards fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Indicate OSMO-CC call confirm towards fixed network\n");
osmo_cc_ll_msg(ep, callref, msg);
}
@@ -447,7 +453,7 @@ static void indicate_alerting(int callref)
msg = osmo_cc_new_msg(OSMO_CC_MSG_ALERT_IND);
- PDEBUG(DCALL, DEBUG_INFO, "Indicate OSMO-CC alerting towards fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Indicate OSMO-CC alerting towards fixed network\n");
osmo_cc_ll_msg(ep, callref, msg);
}
@@ -464,7 +470,7 @@ static void indicate_answer(int callref, const char *sdp, const char *connectid)
if (sdp)
osmo_cc_add_ie_sdp(msg, sdp);
- PDEBUG(DCALL, DEBUG_INFO, "Indicate OSMO-CC answer towards fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Indicate OSMO-CC answer towards fixed network\n");
osmo_cc_ll_msg(ep, callref, msg);
}
@@ -474,7 +480,7 @@ static void indicate_answer_ack(int callref)
msg = osmo_cc_new_msg(OSMO_CC_MSG_SETUP_COMP_IND);
- PDEBUG(DCALL, DEBUG_INFO, "Indicate OSMO-CC setup complete towards fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Indicate OSMO-CC setup complete towards fixed network\n");
osmo_cc_ll_msg(ep, callref, msg);
}
@@ -491,7 +497,7 @@ static void indicate_disconnect_release(int callref, int cause, uint8_t msg_type
if (msg_type == OSMO_CC_MSG_DISC_IND)
osmo_cc_add_ie_progress(msg, OSMO_CC_CODING_ITU_T, OSMO_CC_LOCATION_BEYOND_INTERWORKING, OSMO_CC_PROGRESS_INBAND_INFO_AVAILABLE);
- PDEBUG(DCALL, DEBUG_INFO, "%s OSMO-CC %s towards fixed network\n", (msg_type == OSMO_CC_MSG_REL_CNF) ? "Confirm" : "Indicated", (msg_type == OSMO_CC_MSG_DISC_IND) ? "disconnect" : "release");
+ LOGP(DCALL, LOGL_INFO, "%s OSMO-CC %s towards fixed network\n", (msg_type == OSMO_CC_MSG_REL_CNF) ? "Confirm" : "Indicated", (msg_type == OSMO_CC_MSG_DISC_IND) ? "disconnect" : "release");
osmo_cc_ll_msg(ep, callref, msg);
}
@@ -501,9 +507,9 @@ int call_up_setup(const char *callerid, const char *dialing, uint8_t network, co
osmo_cc_call_t *call;
process_t *process;
- PDEBUG(DCALL, DEBUG_INFO, "Incoming call from '%s' to '%s'\n", callerid ? : "unknown", dialing);
+ LOGP(DCALL, LOGL_INFO, "Incoming call from '%s' to '%s'\n", callerid ? : "unknown", dialing);
if (!strcmp(dialing, "010"))
- PDEBUG(DCALL, DEBUG_INFO, " -> Call to Operator '%s'\n", dialing);
+ LOGP(DCALL, LOGL_INFO, " -> Call to Operator '%s'\n", dialing);
call = osmo_cc_call_new(ep);
@@ -518,11 +524,11 @@ int call_up_setup(const char *callerid, const char *dialing, uint8_t network, co
void call_up_alerting(int callref)
{
if (!callref) {
- PDEBUG(DCALL, DEBUG_DEBUG, "Ignoring alerting, because callref not set. (not for us)\n");
+ LOGP(DCALL, LOGL_DEBUG, "Ignoring alerting, because callref not set. (not for us)\n");
return;
}
- PDEBUG(DCALL, DEBUG_INFO, "Call is alerting\n");
+ LOGP(DCALL, LOGL_INFO, "Call is alerting\n");
if (!connect_on_setup)
indicate_alerting(callref);
@@ -540,11 +546,11 @@ void call_up_early(int callref)
void call_up_answer(int callref, const char *connect_id)
{
if (!callref) {
- PDEBUG(DCALL, DEBUG_DEBUG, "Ignoring answer, because callref not set. (not for us)\n");
+ LOGP(DCALL, LOGL_DEBUG, "Ignoring answer, because callref not set. (not for us)\n");
return;
}
- PDEBUG(DCALL, DEBUG_INFO, "Call has been answered by '%s'\n", connect_id);
+ LOGP(DCALL, LOGL_INFO, "Call has been answered by '%s'\n", connect_id);
if (!connect_on_setup)
indicate_answer(callref, NULL, connect_id);
@@ -558,11 +564,11 @@ void call_up_release(int callref, int cause)
process_t *process;
if (!callref) {
- PDEBUG(DCALL, DEBUG_DEBUG, "Ignoring release, because callref not set. (not for us)\n");
+ LOGP(DCALL, LOGL_DEBUG, "Ignoring release, because callref not set. (not for us)\n");
return;
}
- PDEBUG(DCALL, DEBUG_INFO, "Call has been released with cause=%d\n", cause);
+ LOGP(DCALL, LOGL_INFO, "Call has been released with cause=%d\n", cause);
process = get_process(callref);
if (process) {
@@ -598,12 +604,14 @@ void call_tone_recall(int callref, int on)
}
/* forward audio to OSMO-CC or call instance */
-void call_up_audio(int callref, sample_t *samples, int count)
+void call_up_audio(int callref, sample_t *samples, int len)
{
process_t *process;
- int16_t data[count];
+ int16_t spl[len];
+ uint8_t *payload;
+ int payload_len;
- if (count != 160) {
+ if (len != 160) {
fprintf(stderr, "Samples must be 160, please fix!\n");
abort();
}
@@ -615,13 +623,21 @@ void call_up_audio(int callref, sample_t *samples, int count)
if (!process || process->pattern != PATTERN_NONE)
return;
+ /* no codec negotiated (yet) */
+ if (!process->codec)
+ return;
+
/* forward audio */
#ifdef DEBUG_LEVEL
- double lev = level_of(samples, count);
+ double lev = level_of(samples, len);
printf(" mobil-level: %s%.4f\n", debug_db(lev), (20 * log10(lev)));
#endif
- samples_to_int16(data, samples, count);
- osmo_cc_rtp_send(process->codec, (uint8_t *)data, count * 2, 1, count);
+ /* real to integer */
+ samples_to_int16_speech(spl, samples, len);
+ /* encode and send via RTP */
+ process->codec->encoder((uint8_t *)spl, len * 2, &payload, &payload_len, process);
+ osmo_cc_rtp_send(process->codec, payload, payload_len, 0, 1, len);
+ free(payload);
/* don't destroy process here in case of an error */
}
@@ -634,17 +650,22 @@ void call_clock(void)
while(process) {
if (process->pattern != PATTERN_NONE) {
- int16_t data[160];
+ int16_t spl[160];
+ uint8_t *payload;
+ int payload_len;
/* try to get patterns, else copy the samples we got */
- get_process_patterns(process, data, 160);
+ get_process_patterns(process, spl, 160);
#ifdef DEBUG_LEVEL
sample_t samples[160];
- int16_to_samples(samples, (int16_t *)data->data, 160);
+ int16_to_samples(samples, (int16_t *)spl->data, 160);
double lev = level_of(samples, 160);
printf(" mobil-level: %s%.4f\n", debug_db(lev), (20 * log10(lev)));
- samples_to_int16(data, samples, 160);
+ samples_to_int16(spl, samples, 160);
#endif
- osmo_cc_rtp_send(process->codec, (uint8_t *)data, 160 * 2, 1, 160);
+ /* encode and send via RTP */
+ process->codec->encoder((uint8_t *)spl, 160 * 2, &payload, &payload_len, process);
+ osmo_cc_rtp_send(process->codec, payload, payload_len, 0, 1, 160);
+ free(payload);
/* don't destroy process here in case of an error */
}
process = process->next;
@@ -652,13 +673,15 @@ void call_clock(void)
}
/* messages received from fixed network */
-void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref, osmo_cc_msg_t *msg)
+static void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref, osmo_cc_msg_t *msg)
{
process_t *process;
uint8_t coding, location, progress, isdn_cause, socket_cause;
- uint16_t sip_cause;
+ uint16_t sip_cause, metering_connect_units;
uint8_t type, plan, present, screen, caller_type;
char caller_id[33], number[33];
+ struct timeval tv_meter = {};
+ const char *suffix, *invalid;
int rc;
process = get_process(callref);
@@ -668,7 +691,7 @@ void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref,
else {
/* release collisions is not forbidden */
if (msg->type != OSMO_CC_MSG_REL_REQ)
- PDEBUG(DCALL, DEBUG_ERROR, "No process!\n");
+ LOGP(DCALL, LOGL_ERROR, "No process!\n");
osmo_cc_free_msg(msg);
return;
}
@@ -680,8 +703,8 @@ void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref,
rc = osmo_cc_get_ie_cause(msg, 0, &location, &isdn_cause, &sip_cause, &socket_cause);
if (rc < 0)
isdn_cause = OSMO_CC_ISDN_CAUSE_NORM_CALL_CLEAR;
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC disconnect from fixed network with cause %d\n", isdn_cause);
- PDEBUG(DCALL, DEBUG_INFO, "Call disconnected, releasing!\n");
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC disconnect from fixed network with cause %d\n", isdn_cause);
+ LOGP(DCALL, LOGL_INFO, "Call disconnected, releasing!\n");
destroy_process(callref);
indicate_disconnect_release(callref, isdn_cause, OSMO_CC_MSG_REL_IND);
break;
@@ -689,8 +712,8 @@ void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref,
rc = osmo_cc_get_ie_cause(msg, 0, &location, &isdn_cause, &sip_cause, &socket_cause);
if (rc < 0)
isdn_cause = OSMO_CC_ISDN_CAUSE_NORM_CALL_CLEAR;
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC release from fixed network with cause %d\n", isdn_cause);
- PDEBUG(DCALL, DEBUG_INFO, "Call released\n");
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC release from fixed network with cause %d\n", isdn_cause);
+ LOGP(DCALL, LOGL_INFO, "Call released\n");
destroy_process(callref);
indicate_disconnect_release(callref, isdn_cause, OSMO_CC_MSG_REL_CNF);
break;
@@ -699,15 +722,19 @@ void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref,
return;
}
+ /* get metering information, tv_meter elements are 0, if no metering info available */
+ osmo_cc_get_ie_metering(msg, 0, &metering_connect_units, &tv_meter);
+
switch(msg->type) {
case OSMO_CC_MSG_SETUP_REQ:
{
const char *sdp;
/* sdp accept */
- sdp = osmo_cc_helper_audio_accept(&ep->session_config, process, codecs, down_audio, msg, &process->session, &process->codec, 0);
+ sdp = osmo_cc_helper_audio_accept(&ep->session_config, process, codecs + no_l16, down_audio, msg, &process->session, &process->codec, 0);
if (!sdp) {
disconnect_process(callref, 47);
+ indicate_disconnect_release(callref, 47, OSMO_CC_MSG_REJ_IND);
break;
}
@@ -733,24 +760,73 @@ void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref,
if (present == OSMO_CC_PRESENT_RESTRICTED)
caller_type = TYPE_ANONYMOUS;
}
+
/* dialing */
rc = osmo_cc_get_ie_called(msg, 0, &type, &plan, number, sizeof(number));
if (rc < 0)
number[0] = '\0';
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC call from fixed network '%s' to mobile '%s'\n", caller_id, number);
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC call from fixed network '%s' to mobile '%s'\n", caller_id, number);
if (!connect_on_setup)
indicate_proceeding(callref, sdp);
else {
- PDEBUG(DCALL, DEBUG_DEBUG, "Early connecting after setup\n");
+ LOGP(DCALL, LOGL_DEBUG, "Early connecting after setup\n");
indicate_answer(callref, sdp, number);
}
- PDEBUG(DCALL, DEBUG_INFO, "Outgoing call from '%s' to '%s'\n", caller_id, number);
+ LOGP(DCALL, LOGL_INFO, "Outgoing call from '%s' to '%s'\n", caller_id, number);
+
+ /* insert '+' for international dialing */
+ if (type == OSMO_CC_TYPE_INTERNATIONAL && number[0] != '+') {
+ memmove(number + 1, number, sizeof(number) - 2);
+ number[0] = '+';
+ }
- rc = call_down_setup(callref, caller_id, caller_type, number);
+ /* remove prefix, if any */
+ suffix = mobile_number_remove_prefix(number);
+
+ /* check suffix length */
+ invalid = mobile_number_check_length(suffix);
+ if (invalid) {
+ LOGP(DCALL, LOGL_NOTICE, "Mobile number '%s' has invalid length: %s\n", suffix, invalid);
+ disconnect_process(callref, OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT);
+ if (!connect_on_setup) {
+ LOGP(DCALL, LOGL_INFO, "Disconnecting OSMO-CC call towards fixed network (cause=%d)\n", OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT);
+ indicate_disconnect_release(callref, OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT, OSMO_CC_MSG_DISC_IND);
+ }
+ break;
+ }
+
+ /* check suffix digits */
+ invalid = mobile_number_check_digits(suffix);
+ if (invalid) {
+ LOGP(DCALL, LOGL_NOTICE, "Mobile number '%s' has invalid digit: %s.\n", suffix, invalid);
+ disconnect_process(callref, OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT);
+ if (!connect_on_setup) {
+ LOGP(DCALL, LOGL_INFO, "Disconnecting OSMO-CC call towards fixed network (cause=%d)\n", OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT);
+ indicate_disconnect_release(callref, OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT, OSMO_CC_MSG_DISC_IND);
+ }
+ break;
+ }
+
+ /* check if suffix is valid */
+ if (mobile_number_check_valid) {
+ invalid = mobile_number_check_valid(suffix);
+ if (invalid) {
+ LOGP(DCALL, LOGL_NOTICE, "Mobile number '%s' is invalid for this network: %s\n", suffix, invalid);
+ disconnect_process(callref, OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT);
+ if (!connect_on_setup) {
+ LOGP(DCALL, LOGL_INFO, "Disconnecting OSMO-CC call towards fixed network (cause=%d)\n", OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT);
+ indicate_disconnect_release(callref, OSMO_CC_ISDN_CAUSE_INV_NR_FORMAT, OSMO_CC_MSG_DISC_IND);
+ }
+ break;
+ }
+ }
+
+ /* setup call */
+ rc = call_down_setup(callref, caller_id, caller_type, suffix);
if (rc < 0) {
- PDEBUG(DCALL, DEBUG_NOTICE, "Call rejected, cause %d\n", -rc);
+ LOGP(DCALL, LOGL_NOTICE, "Call rejected, cause %d\n", -rc);
if (!connect_on_setup) {
- PDEBUG(DCALL, DEBUG_INFO, "Disconnecting OSMO-CC call towards fixed network (cause=%d)\n", -rc);
+ LOGP(DCALL, LOGL_INFO, "Disconnecting OSMO-CC call towards fixed network (cause=%d)\n", -rc);
indicate_disconnect_release(callref, -rc, OSMO_CC_MSG_DISC_IND);
}
disconnect_process(callref, -rc);
@@ -759,45 +835,45 @@ void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref,
break;
}
case OSMO_CC_MSG_SETUP_ACK_REQ:
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC overlap from fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC overlap from fixed network\n");
rc = osmo_cc_helper_audio_negotiate(msg, &process->session, &process->codec);
if (rc < 0) {
nego_failed:
- PDEBUG(DCALL, DEBUG_INFO, "Releasing, because codec negotiation failed.\n");
+ LOGP(DCALL, LOGL_INFO, "Releasing, because codec negotiation failed.\n");
destroy_process(callref);
indicate_disconnect_release(callref, 47, OSMO_CC_MSG_REL_IND);
- PDEBUG(DCALL, DEBUG_INFO, "Call released toward mobile network\n");
+ LOGP(DCALL, LOGL_INFO, "Call released toward mobile network\n");
call_down_release(callref, 47);
break;
}
break;
case OSMO_CC_MSG_PROC_REQ:
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC proceeding from fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC proceeding from fixed network\n");
rc = osmo_cc_helper_audio_negotiate(msg, &process->session, &process->codec);
if (rc < 0)
goto nego_failed;
break;
case OSMO_CC_MSG_PROGRESS_REQ:
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC progress from fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC progress from fixed network\n");
rc = osmo_cc_helper_audio_negotiate(msg, &process->session, &process->codec);
if (rc < 0)
goto nego_failed;
break;
case OSMO_CC_MSG_ALERT_REQ:
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC alerting from fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC alerting from fixed network\n");
rc = osmo_cc_helper_audio_negotiate(msg, &process->session, &process->codec);
if (rc < 0)
goto nego_failed;
new_state_process(callref, PROCESS_ALERTING_RO);
break;
case OSMO_CC_MSG_SETUP_RSP:
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC answer from fixed network\n");
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC answer from fixed network\n");
rc = osmo_cc_helper_audio_negotiate(msg, &process->session, &process->codec);
if (rc < 0)
goto nego_failed;
new_state_process(callref, PROCESS_CONNECT);
- PDEBUG(DCALL, DEBUG_INFO, "Call answered\n");
- call_down_answer(callref);
+ LOGP(DCALL, LOGL_INFO, "Call answered\n");
+ call_down_answer(callref, &tv_meter);
indicate_answer_ack(callref);
break;
case OSMO_CC_MSG_DISC_REQ:
@@ -810,22 +886,22 @@ void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref,
rc = osmo_cc_get_ie_progress(msg, 0, &coding, &location, &progress);
if (rc < 0)
progress = 0;
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC disconnect from fixed network with cause %d\n", isdn_cause);
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC disconnect from fixed network with cause %d\n", isdn_cause);
if (release_on_disconnect || (progress != 1 && progress != 8)) {
- PDEBUG(DCALL, DEBUG_INFO, "Releasing, because we don't send disconnect tones to mobile phone\n");
+ LOGP(DCALL, LOGL_INFO, "Releasing, because we don't send disconnect tones to mobile phone\n");
destroy_process(callref);
indicate_disconnect_release(callref, isdn_cause, OSMO_CC_MSG_REL_IND);
- PDEBUG(DCALL, DEBUG_INFO, "Call released toward mobile network\n");
+ LOGP(DCALL, LOGL_INFO, "Call released toward mobile network\n");
call_down_release(callref, isdn_cause);
break;
}
new_state_process(callref, PROCESS_DISCONNECT);
- PDEBUG(DCALL, DEBUG_INFO, "Call disconnected\n");
+ LOGP(DCALL, LOGL_INFO, "Call disconnected\n");
call_down_disconnect(callref, isdn_cause);
/* we might get released during disconnect handling!!! */
process = get_process(callref);
if (process && process->state == PROCESS_DISCONNECT)
- timer_start(&process->timer, DISC_TIMEOUT);
+ osmo_timer_schedule(&process->timer, DISC_TIMEOUT);
break;
case OSMO_CC_MSG_REJ_REQ:
case OSMO_CC_MSG_REL_REQ:
@@ -834,18 +910,18 @@ void ll_msg_cb(osmo_cc_endpoint_t __attribute__((unused)) *ep, uint32_t callref,
isdn_cause = OSMO_CC_ISDN_CAUSE_NORM_CALL_CLEAR;
destroy_process(callref);
if (msg->type == OSMO_CC_MSG_REL_REQ) {
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC release from fixed network with cause %d\n", isdn_cause);
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC release from fixed network with cause %d\n", isdn_cause);
indicate_disconnect_release(callref, isdn_cause, OSMO_CC_MSG_REL_CNF);
} else
- PDEBUG(DCALL, DEBUG_INFO, "Received OSMO-CC reject from fixed network with cause %d\n", isdn_cause);
- PDEBUG(DCALL, DEBUG_INFO, "Call released toward mobile network\n");
+ LOGP(DCALL, LOGL_INFO, "Received OSMO-CC reject from fixed network with cause %d\n", isdn_cause);
+ LOGP(DCALL, LOGL_INFO, "Call released toward mobile network\n");
call_down_release(callref, isdn_cause);
break;
}
osmo_cc_free_msg(msg);
}
-int call_init(const char *name, int _send_patterns, int _release_on_disconnect, int use_socket, int argc, const char *argv[])
+int call_init(const char *name, int _send_patterns, int _release_on_disconnect, int use_socket, int argc, const char *argv[], int _no_l16)
{
int rc;
@@ -854,6 +930,7 @@ int call_init(const char *name, int _send_patterns, int _release_on_disconnect,
g711_init();
+ no_l16 = !!_no_l16;
ep = &endpoint;
rc = osmo_cc_new(ep, OSMO_CC_VERSION, name, OSMO_CC_LOCATION_PRIV_SERV_LOC_USER, ll_msg_cb, (use_socket) ? NULL : console_msg, NULL, argc, argv);
if (rc > 0)
@@ -877,14 +954,3 @@ int call_handle(void)
return osmo_cc_handle();
}
-void call_media_handle(void)
-{
- process_t *process = process_head;
-
- while(process) {
- if (process->session)
- osmo_cc_session_handle(process->session);
- process = process->next;
- }
-}
-