2017-10-28 05:11:40 +00:00
|
|
|
/* interface between mobile network/phone implementation and MNCC
|
2016-03-01 17:40:38 +00:00
|
|
|
*
|
|
|
|
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/time.h>
|
2017-11-18 07:06:06 +00:00
|
|
|
#include "../libsample/sample.h"
|
2017-11-18 07:58:57 +00:00
|
|
|
#include "../libdebug/debug.h"
|
2016-06-19 15:46:56 +00:00
|
|
|
#include "sender.h"
|
2016-03-01 17:40:38 +00:00
|
|
|
#include "call.h"
|
2017-11-13 19:00:52 +00:00
|
|
|
#include "../libtimer/timer.h"
|
2017-11-17 08:01:44 +00:00
|
|
|
#include "../libmncc/mncc.h"
|
|
|
|
#include "../libmncc/cause.h"
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2016-06-19 15:46:56 +00:00
|
|
|
#define DISC_TIMEOUT 30
|
|
|
|
|
2017-01-29 06:25:12 +00:00
|
|
|
//#define DEBUG_LEVEL
|
|
|
|
|
|
|
|
#ifdef DEBUG_LEVEL
|
|
|
|
static double level_of(double *samples, int count)
|
|
|
|
{
|
|
|
|
double level = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
if (samples[i] > level)
|
|
|
|
level = samples[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return level;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
static int send_patterns; /* send patterns towards fixed network */
|
|
|
|
static int release_on_disconnect; /* release towards mobile phone, if MNCC call disconnects, don't send disconnect tone */
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* stream patterns/announcements */
|
2016-03-11 05:59:05 +00:00
|
|
|
int16_t *ringback_spl = NULL;
|
|
|
|
int ringback_size = 0;
|
|
|
|
int ringback_max = 0;
|
2017-10-28 05:11:40 +00:00
|
|
|
int16_t *hangup_spl = NULL;
|
|
|
|
int hangup_size = 0;
|
2016-05-01 17:51:56 +00:00
|
|
|
int hangup_max = 0;
|
2017-10-28 05:11:40 +00:00
|
|
|
int16_t *busy_spl = NULL;
|
|
|
|
int busy_size = 0;
|
2016-03-11 05:59:05 +00:00
|
|
|
int busy_max = 0;
|
2017-10-28 05:11:40 +00:00
|
|
|
int16_t *noanswer_spl = NULL;
|
|
|
|
int noanswer_size = 0;
|
2016-05-01 17:51:56 +00:00
|
|
|
int noanswer_max = 0;
|
2017-10-28 05:11:40 +00:00
|
|
|
int16_t *outoforder_spl = NULL;
|
|
|
|
int outoforder_size = 0;
|
2016-05-01 17:51:56 +00:00
|
|
|
int outoforder_max = 0;
|
2017-10-28 05:11:40 +00:00
|
|
|
int16_t *invalidnumber_spl = NULL;
|
|
|
|
int invalidnumber_size = 0;
|
2016-05-01 17:51:56 +00:00
|
|
|
int invalidnumber_max = 0;
|
2017-10-28 05:11:40 +00:00
|
|
|
int16_t *congestion_spl = NULL;
|
|
|
|
int congestion_size = 0;
|
2016-03-11 05:59:05 +00:00
|
|
|
int congestion_max = 0;
|
2017-10-28 05:11:40 +00:00
|
|
|
int16_t *recall_spl = NULL;
|
|
|
|
int recall_size = 0;
|
2017-08-06 09:30:39 +00:00
|
|
|
int recall_max = 0;
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
enum audio_pattern {
|
|
|
|
PATTERN_NONE = 0,
|
2016-08-03 05:48:26 +00:00
|
|
|
PATTERN_TEST,
|
2016-03-01 17:40:38 +00:00
|
|
|
PATTERN_RINGBACK,
|
2016-05-01 17:51:56 +00:00
|
|
|
PATTERN_HANGUP,
|
2016-03-01 17:40:38 +00:00
|
|
|
PATTERN_BUSY,
|
2016-05-01 17:51:56 +00:00
|
|
|
PATTERN_NOANSWER,
|
2016-03-01 17:40:38 +00:00
|
|
|
PATTERN_OUTOFORDER,
|
2016-05-01 17:51:56 +00:00
|
|
|
PATTERN_INVALIDNUMBER,
|
|
|
|
PATTERN_CONGESTION,
|
2017-08-06 09:30:39 +00:00
|
|
|
PATTERN_RECALL,
|
2016-03-01 17:40:38 +00:00
|
|
|
};
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
static void get_pattern(const int16_t **spl, int *size, int *max, enum audio_pattern pattern)
|
2016-03-11 05:59:05 +00:00
|
|
|
{
|
|
|
|
*spl = NULL;
|
|
|
|
*size = 0;
|
|
|
|
*max = 0;
|
|
|
|
|
|
|
|
switch (pattern) {
|
|
|
|
case PATTERN_RINGBACK:
|
2017-08-06 09:30:39 +00:00
|
|
|
no_recall:
|
2016-03-11 05:59:05 +00:00
|
|
|
*spl = ringback_spl;
|
|
|
|
*size = ringback_size;
|
|
|
|
*max = ringback_max;
|
|
|
|
break;
|
2016-05-01 17:51:56 +00:00
|
|
|
case PATTERN_HANGUP:
|
|
|
|
if (!hangup_spl)
|
|
|
|
goto no_hangup;
|
|
|
|
*spl = hangup_spl;
|
|
|
|
*size = hangup_size;
|
|
|
|
*max = hangup_max;
|
|
|
|
break;
|
2016-03-11 05:59:05 +00:00
|
|
|
case PATTERN_BUSY:
|
2016-05-01 17:51:56 +00:00
|
|
|
no_hangup:
|
|
|
|
no_noanswer:
|
2016-03-11 05:59:05 +00:00
|
|
|
*spl = busy_spl;
|
|
|
|
*size = busy_size;
|
|
|
|
*max = busy_max;
|
|
|
|
break;
|
2016-05-01 17:51:56 +00:00
|
|
|
case PATTERN_NOANSWER:
|
|
|
|
if (!noanswer_spl)
|
|
|
|
goto no_noanswer;
|
|
|
|
*spl = noanswer_spl;
|
|
|
|
*size = noanswer_size;
|
|
|
|
*max = noanswer_max;
|
2016-03-11 05:59:05 +00:00
|
|
|
break;
|
|
|
|
case PATTERN_OUTOFORDER:
|
|
|
|
if (!outoforder_spl)
|
|
|
|
goto no_outoforder;
|
|
|
|
*spl = outoforder_spl;
|
|
|
|
*size = outoforder_size;
|
|
|
|
*max = outoforder_max;
|
|
|
|
break;
|
2016-05-01 17:51:56 +00:00
|
|
|
case PATTERN_INVALIDNUMBER:
|
|
|
|
if (!invalidnumber_spl)
|
|
|
|
goto no_invalidnumber;
|
|
|
|
*spl = invalidnumber_spl;
|
|
|
|
*size = invalidnumber_size;
|
|
|
|
*max = invalidnumber_max;
|
|
|
|
break;
|
|
|
|
case PATTERN_CONGESTION:
|
|
|
|
no_outoforder:
|
|
|
|
no_invalidnumber:
|
|
|
|
*spl = congestion_spl;
|
|
|
|
*size = congestion_size;
|
|
|
|
*max = congestion_max;
|
|
|
|
break;
|
2017-08-06 09:30:39 +00:00
|
|
|
case PATTERN_RECALL:
|
|
|
|
if (!recall_spl)
|
|
|
|
goto no_recall;
|
|
|
|
*spl = recall_spl;
|
|
|
|
*size = recall_size;
|
|
|
|
*max = recall_max;
|
|
|
|
break;
|
2016-03-11 05:59:05 +00:00
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
static enum audio_pattern cause2pattern(int cause)
|
|
|
|
{
|
|
|
|
int pattern;
|
|
|
|
|
|
|
|
switch (cause) {
|
2016-05-01 17:51:56 +00:00
|
|
|
case CAUSE_NORMAL:
|
|
|
|
pattern = PATTERN_HANGUP;
|
|
|
|
break;
|
2016-03-11 05:59:05 +00:00
|
|
|
case CAUSE_BUSY:
|
|
|
|
pattern = PATTERN_BUSY;
|
|
|
|
break;
|
2016-05-01 17:51:56 +00:00
|
|
|
case CAUSE_NOANSWER:
|
|
|
|
pattern = PATTERN_NOANSWER;
|
|
|
|
break;
|
2016-03-01 17:40:38 +00:00
|
|
|
case CAUSE_OUTOFORDER:
|
|
|
|
pattern = PATTERN_OUTOFORDER;
|
|
|
|
break;
|
2016-05-01 17:51:56 +00:00
|
|
|
case CAUSE_INVALNUMBER:
|
|
|
|
pattern = PATTERN_INVALIDNUMBER;
|
|
|
|
break;
|
|
|
|
case CAUSE_NOCHANNEL:
|
2016-03-11 05:59:05 +00:00
|
|
|
pattern = PATTERN_CONGESTION;
|
2016-05-01 17:51:56 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pattern = PATTERN_HANGUP;
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
enum process_state {
|
|
|
|
PROCESS_IDLE = 0, /* IDLE */
|
|
|
|
PROCESS_SETUP_RO, /* call from radio to MNCC */
|
|
|
|
PROCESS_SETUP_RT, /* call from MNCC to radio */
|
|
|
|
PROCESS_ALERTING_RO, /* call from radio to MNCC */
|
|
|
|
PROCESS_ALERTING_RT, /* call from MNCC to radio */
|
|
|
|
PROCESS_CONNECT,
|
|
|
|
PROCESS_DISCONNECT,
|
|
|
|
};
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* MNCC call instance */
|
|
|
|
typedef struct process {
|
|
|
|
struct process *next;
|
|
|
|
int callref;
|
2017-10-28 05:11:40 +00:00
|
|
|
enum process_state state;
|
2016-03-01 17:40:38 +00:00
|
|
|
int audio_disconnected; /* if not associated with transceiver anymore */
|
|
|
|
enum audio_pattern pattern;
|
|
|
|
int audio_pos;
|
2016-06-19 15:46:56 +00:00
|
|
|
uint8_t cause;
|
|
|
|
struct timer timer;
|
2016-03-01 17:40:38 +00:00
|
|
|
} process_t;
|
|
|
|
|
|
|
|
static process_t *process_head = NULL;
|
|
|
|
|
2016-06-19 15:46:56 +00:00
|
|
|
static void process_timeout(struct timer *timer);
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
static process_t *create_process(int callref, enum process_state state)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
|
|
|
process_t *process;
|
|
|
|
|
|
|
|
process = calloc(sizeof(*process), 1);
|
|
|
|
if (!process) {
|
|
|
|
PDEBUG(DCALL, DEBUG_ERROR, "No memory!\n");
|
|
|
|
abort();
|
|
|
|
}
|
2016-06-19 15:46:56 +00:00
|
|
|
timer_init(&process->timer, process_timeout, process);
|
2016-03-01 17:40:38 +00:00
|
|
|
process->next = process_head;
|
|
|
|
process_head = process;
|
|
|
|
|
|
|
|
process->callref = callref;
|
|
|
|
process->state = state;
|
2017-10-28 05:11:40 +00:00
|
|
|
|
|
|
|
return process;
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_process(int callref)
|
|
|
|
{
|
|
|
|
process_t *process = process_head;
|
|
|
|
process_t **process_p = &process_head;
|
|
|
|
|
|
|
|
while (process) {
|
|
|
|
if (process->callref == callref) {
|
|
|
|
*process_p = process->next;
|
2016-06-19 15:46:56 +00:00
|
|
|
timer_exit(&process->timer);
|
2016-03-01 17:40:38 +00:00
|
|
|
free(process);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
process_p = &process->next;
|
|
|
|
process = process->next;
|
|
|
|
}
|
|
|
|
PDEBUG(DCALL, DEBUG_ERROR, "Process with callref 0x%x not found!\n", callref);
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
static process_t *get_process(int callref)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
|
|
|
process_t *process = process_head;
|
|
|
|
|
|
|
|
while (process) {
|
|
|
|
if (process->callref == callref)
|
2017-10-28 05:11:40 +00:00
|
|
|
return process;
|
2016-03-01 17:40:38 +00:00
|
|
|
process = process->next;
|
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
return NULL;
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
static void new_state_process(int callref, enum process_state state)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
2017-10-28 05:11:40 +00:00
|
|
|
process_t *process = get_process(callref);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
if (!process) {
|
|
|
|
PDEBUG(DCALL, DEBUG_ERROR, "Process with callref 0x%x not found!\n", callref);
|
|
|
|
return;
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
process->state = state;
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void set_pattern_process(int callref, enum audio_pattern pattern)
|
|
|
|
{
|
2017-10-28 05:11:40 +00:00
|
|
|
process_t *process = get_process(callref);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
if (!process) {
|
|
|
|
PDEBUG(DCALL, DEBUG_ERROR, "Process with callref 0x%x not found!\n", callref);
|
|
|
|
return;
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
process->pattern = pattern;
|
|
|
|
process->audio_pos = 0;
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* disconnect audio, now send audio directly from pattern/announcement, not from transceiver */
|
|
|
|
static void disconnect_process(int callref, int cause)
|
|
|
|
{
|
2017-10-28 05:11:40 +00:00
|
|
|
process_t *process = get_process(callref);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
if (!process) {
|
|
|
|
PDEBUG(DCALL, DEBUG_ERROR, "Process with callref 0x%x not found!\n", callref);
|
|
|
|
return;
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
process->pattern = cause2pattern(cause);
|
|
|
|
process->audio_disconnected = 1;
|
|
|
|
process->audio_pos = 0;
|
|
|
|
process->cause = cause;
|
|
|
|
timer_start(&process->timer, DISC_TIMEOUT);
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void get_process_patterns(process_t *process, int16_t *samples, int length)
|
|
|
|
{
|
2016-03-11 05:59:05 +00:00
|
|
|
const int16_t *spl;
|
|
|
|
int size, max, pos;
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2016-03-11 05:59:05 +00:00
|
|
|
get_pattern(&spl, &size, &max, process->pattern);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
/* stream sample */
|
|
|
|
pos = process->audio_pos;
|
|
|
|
while(length--) {
|
|
|
|
if (pos >= size)
|
|
|
|
*samples++ = 0;
|
|
|
|
else
|
|
|
|
*samples++ = spl[pos] >> 1;
|
|
|
|
if (++pos == max)
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
process->audio_pos = pos;
|
|
|
|
}
|
|
|
|
|
2016-06-19 15:46:56 +00:00
|
|
|
static void process_timeout(struct timer *timer)
|
|
|
|
{
|
|
|
|
process_t *process = (process_t *)timer->priv;
|
|
|
|
|
|
|
|
{
|
|
|
|
/* announcement timeout */
|
|
|
|
uint8_t buf[sizeof(struct gsm_mncc)];
|
|
|
|
struct gsm_mncc *mncc = (struct gsm_mncc *)buf;
|
|
|
|
|
2017-11-18 07:33:07 +00:00
|
|
|
if (process->state == PROCESS_DISCONNECT) {
|
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call released toward mobile network (after timeout)\n");
|
|
|
|
call_down_release(process->callref, process->cause);
|
|
|
|
}
|
|
|
|
|
2016-06-19 15:46:56 +00:00
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
mncc->msg_type = MNCC_REL_IND;
|
|
|
|
mncc->callref = process->callref;
|
|
|
|
mncc->fields |= MNCC_F_CAUSE;
|
2017-10-28 05:11:40 +00:00
|
|
|
mncc->cause.location = LOCATION_PRIVATE_LOCAL;
|
2016-06-19 15:46:56 +00:00
|
|
|
mncc->cause.value = process->cause;
|
|
|
|
|
|
|
|
destroy_process(process->callref);
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Releasing MNCC call towards fixed network (after timeout)\n");
|
|
|
|
mncc_up(buf, sizeof(struct gsm_mncc));
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
int call_init(int _send_patterns, int _release_on_disconnect)
|
2017-01-29 15:54:28 +00:00
|
|
|
{
|
2017-10-28 05:11:40 +00:00
|
|
|
send_patterns = _send_patterns;
|
|
|
|
release_on_disconnect = _release_on_disconnect;
|
2017-01-29 15:54:28 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
/* Setup is received from transceiver. */
|
|
|
|
static int _indicate_setup(int callref, const char *callerid, const char *dialing)
|
2016-12-11 13:21:22 +00:00
|
|
|
{
|
2017-10-28 05:11:40 +00:00
|
|
|
uint8_t buf[sizeof(struct gsm_mncc)];
|
|
|
|
struct gsm_mncc *mncc = (struct gsm_mncc *)buf;
|
|
|
|
int rc;
|
2016-12-11 13:21:22 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
mncc->msg_type = MNCC_SETUP_IND;
|
|
|
|
mncc->callref = callref;
|
|
|
|
mncc->fields |= MNCC_F_CALLING;
|
|
|
|
if (callerid) {
|
|
|
|
strncpy(mncc->calling.number, callerid, sizeof(mncc->calling.number) - 1);
|
|
|
|
mncc->calling.type = 4; /* caller ID is of type 'subscriber' */
|
|
|
|
} // otherwise unknown and no number
|
|
|
|
mncc->fields |= MNCC_F_CALLED;
|
|
|
|
strncpy(mncc->called.number, dialing, sizeof(mncc->called.number) - 1);
|
|
|
|
mncc->called.type = 0; /* dialing is of type 'unknown' */
|
|
|
|
mncc->lchan_type = GSM_LCHAN_TCH_F;
|
|
|
|
mncc->fields |= MNCC_F_BEARER_CAP;
|
|
|
|
mncc->bearer_cap.speech_ver[0] = BCAP_ANALOG_8000HZ;
|
|
|
|
mncc->bearer_cap.speech_ver[1] = -1;
|
|
|
|
|
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Indicate MNCC setup towards fixed network\n");
|
|
|
|
rc = mncc_up(buf, sizeof(struct gsm_mncc));
|
|
|
|
if (rc < 0)
|
|
|
|
destroy_process(callref);
|
|
|
|
return rc;
|
2016-12-11 13:21:22 +00:00
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
int call_up_setup(int callref, const char *callerid, const char *dialing)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2016-07-09 09:16:50 +00:00
|
|
|
if (!callref) {
|
|
|
|
PDEBUG(DCALL, DEBUG_DEBUG, "Ignoring setup, because callref not set. (not for us)\n");
|
|
|
|
return -CAUSE_INVALCALLREF;
|
|
|
|
}
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
if (callref < 0x4000000) {
|
|
|
|
PDEBUG(DCALL, DEBUG_ERROR, "Invalid callref from mobile station, please fix!\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2016-11-13 05:04:54 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_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);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
create_process(callref, PROCESS_SETUP_RO);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
rc = _indicate_setup(callref, callerid, dialing);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
/* Transceiver indicates alerting. */
|
|
|
|
static void _indicate_alerting(int callref)
|
|
|
|
{
|
|
|
|
uint8_t buf[sizeof(struct gsm_mncc)];
|
|
|
|
struct gsm_mncc *mncc = (struct gsm_mncc *)buf;
|
|
|
|
int rc;
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
mncc->msg_type = MNCC_ALERT_IND;
|
|
|
|
mncc->callref = callref;
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Indicate MNCC alerting towards fixed network\n");
|
|
|
|
rc = mncc_up(buf, sizeof(struct gsm_mncc));
|
|
|
|
if (rc < 0)
|
|
|
|
destroy_process(callref);
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
void call_up_alerting(int callref)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
2016-07-09 09:16:50 +00:00
|
|
|
if (!callref) {
|
|
|
|
PDEBUG(DCALL, DEBUG_DEBUG, "Ignoring alerting, because callref not set. (not for us)\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call is alerting\n");
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
if (!send_patterns)
|
|
|
|
_indicate_alerting(callref);
|
|
|
|
set_pattern_process(callref, PATTERN_RINGBACK);
|
|
|
|
new_state_process(callref, PROCESS_ALERTING_RT);
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Transceiver indicates answer. */
|
2016-07-20 09:58:12 +00:00
|
|
|
static void _indicate_answer(int callref, const char *connect_id)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
|
|
|
uint8_t buf[sizeof(struct gsm_mncc)];
|
|
|
|
struct gsm_mncc *mncc = (struct gsm_mncc *)buf;
|
2017-10-28 05:11:40 +00:00
|
|
|
int rc;
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
mncc->msg_type = MNCC_SETUP_CNF;
|
|
|
|
mncc->callref = callref;
|
|
|
|
mncc->fields |= MNCC_F_CONNECTED;
|
2016-07-20 09:58:12 +00:00
|
|
|
/* copy connected number as subscriber number */
|
|
|
|
strncpy(mncc->connected.number, connect_id, sizeof(mncc->connected.number));
|
|
|
|
mncc->connected.type = 4;
|
|
|
|
mncc->connected.plan = 1;
|
|
|
|
mncc->connected.present = 0;
|
|
|
|
mncc->connected.screen = 3;
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Indicate MNCC answer towards fixed network\n");
|
|
|
|
rc = mncc_up(buf, sizeof(struct gsm_mncc));
|
|
|
|
if (rc < 0)
|
|
|
|
destroy_process(callref);
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
void call_up_answer(int callref, const char *connect_id)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
2016-07-09 09:16:50 +00:00
|
|
|
if (!callref) {
|
|
|
|
PDEBUG(DCALL, DEBUG_DEBUG, "Ignoring answer, because callref not set. (not for us)\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-20 09:58:12 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call has been answered by '%s'\n", connect_id);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
if (!send_patterns)
|
2016-07-20 09:58:12 +00:00
|
|
|
_indicate_answer(callref, connect_id);
|
2017-10-28 05:11:40 +00:00
|
|
|
set_pattern_process(callref, PATTERN_NONE);
|
|
|
|
new_state_process(callref, PROCESS_CONNECT);
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Transceiver indicates release. */
|
2017-10-28 05:11:40 +00:00
|
|
|
static void _indicate_disconnect_release(int callref, int cause, int disc)
|
|
|
|
{
|
|
|
|
uint8_t buf[sizeof(struct gsm_mncc)];
|
|
|
|
struct gsm_mncc *mncc = (struct gsm_mncc *)buf;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
mncc->msg_type = (disc) ? MNCC_DISC_IND : MNCC_REL_IND;
|
|
|
|
mncc->callref = callref;
|
|
|
|
mncc->fields |= MNCC_F_CAUSE;
|
|
|
|
mncc->cause.location = LOCATION_PRIVATE_LOCAL;
|
|
|
|
mncc->cause.value = cause;
|
|
|
|
|
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Indicate MNCC %s towards fixed network\n", (disc) ? "disconnect" : "release");
|
|
|
|
rc = mncc_up(buf, sizeof(struct gsm_mncc));
|
|
|
|
if (rc < 0)
|
|
|
|
destroy_process(callref);
|
|
|
|
}
|
|
|
|
void call_up_release(int callref, int cause)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
2017-10-28 05:11:40 +00:00
|
|
|
process_t *process;
|
|
|
|
|
2016-07-09 09:16:50 +00:00
|
|
|
if (!callref) {
|
|
|
|
PDEBUG(DCALL, DEBUG_DEBUG, "Ignoring release, because callref not set. (not for us)\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call has been released with cause=%d\n", cause);
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
process = get_process(callref);
|
|
|
|
if (process) {
|
2017-11-11 04:55:32 +00:00
|
|
|
/* just keep MNCC connection if tones shall be sent.
|
2017-10-28 05:11:40 +00:00
|
|
|
* no tones while setting up / alerting the call. */
|
2017-11-11 04:55:32 +00:00
|
|
|
if (send_patterns
|
|
|
|
&& process->state != PROCESS_SETUP_RO
|
|
|
|
&& process->state != PROCESS_ALERTING_RO)
|
2017-10-28 05:11:40 +00:00
|
|
|
disconnect_process(callref, cause);
|
|
|
|
else
|
2017-11-11 04:55:32 +00:00
|
|
|
/* if no tones shall be sent, release on disconnect
|
|
|
|
* or RO setup states */
|
2017-10-28 05:11:40 +00:00
|
|
|
if (process->state == PROCESS_DISCONNECT
|
|
|
|
|| process->state == PROCESS_SETUP_RO
|
|
|
|
|| process->state == PROCESS_ALERTING_RO) {
|
|
|
|
destroy_process(callref);
|
|
|
|
_indicate_disconnect_release(callref, cause, 0);
|
2017-11-11 04:55:32 +00:00
|
|
|
/* if no tones shall be sent, disconnect on all other states */
|
2016-03-01 17:40:38 +00:00
|
|
|
} else {
|
2017-10-28 05:11:40 +00:00
|
|
|
disconnect_process(callref, cause);
|
|
|
|
_indicate_disconnect_release(callref, cause, 1);
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
} else {
|
|
|
|
/* we don't know about the process, just send release to upper layer anyway */
|
|
|
|
_indicate_disconnect_release(callref, cause, 0);
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-06 09:30:39 +00:00
|
|
|
/* turn recall tone on or off */
|
|
|
|
void call_tone_recall(int callref, int on)
|
|
|
|
{
|
2017-10-28 05:11:40 +00:00
|
|
|
set_pattern_process(callref, (on) ? PATTERN_RECALL : PATTERN_NONE);
|
2017-08-06 09:30:39 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* forward audio to MNCC or call instance */
|
2017-10-28 05:11:40 +00:00
|
|
|
void call_up_audio(int callref, sample_t *samples, int count)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
2017-10-28 05:11:40 +00:00
|
|
|
if (count != 160) {
|
|
|
|
fprintf(stderr, "Samples must be 160, please fix!\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
/* is MNCC us used, forward audio */
|
|
|
|
uint8_t buf[sizeof(struct gsm_data_frame) + 160 * sizeof(int16_t)];
|
|
|
|
struct gsm_data_frame *data = (struct gsm_data_frame *)buf;
|
|
|
|
process_t *process;
|
|
|
|
|
2016-07-09 09:16:50 +00:00
|
|
|
if (!callref)
|
|
|
|
return;
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
/* if we are disconnected, ignore audio */
|
|
|
|
process = get_process(callref);
|
|
|
|
if (!process || process->pattern != PATTERN_NONE)
|
|
|
|
return;
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
/* forward audio */
|
|
|
|
data->msg_type = ANALOG_8000HZ;
|
|
|
|
data->callref = callref;
|
2017-01-29 06:25:12 +00:00
|
|
|
#ifdef DEBUG_LEVEL
|
2017-10-28 05:11:40 +00:00
|
|
|
double lev = level_of(samples, count);
|
|
|
|
printf(" mobil-level: %s%.4f\n", debug_db(lev), (20 * log10(lev)));
|
2017-01-29 06:25:12 +00:00
|
|
|
#endif
|
2017-10-28 05:11:40 +00:00
|
|
|
samples_to_int16((int16_t *)data->data, samples, count);
|
|
|
|
|
|
|
|
mncc_up(buf, sizeof(buf));
|
|
|
|
/* don't destroy process here in case of an error */
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clock that is used to transmit patterns */
|
2017-10-28 05:11:40 +00:00
|
|
|
void call_clock(void)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
|
|
|
process_t *process = process_head;
|
|
|
|
uint8_t buf[sizeof(struct gsm_data_frame) + 160 * sizeof(int16_t)];
|
|
|
|
struct gsm_data_frame *data = (struct gsm_data_frame *)buf;
|
|
|
|
|
|
|
|
while(process) {
|
|
|
|
if (process->pattern != PATTERN_NONE) {
|
|
|
|
data->msg_type = ANALOG_8000HZ;
|
|
|
|
data->callref = process->callref;
|
|
|
|
/* try to get patterns, else copy the samples we got */
|
|
|
|
get_process_patterns(process, (int16_t *)data->data, 160);
|
2017-01-29 06:25:12 +00:00
|
|
|
#ifdef DEBUG_LEVEL
|
|
|
|
sample_t samples[160];
|
|
|
|
int16_to_samples(samples, (int16_t *)data->data, 160);
|
|
|
|
double lev = level_of(samples, 160);
|
|
|
|
printf(" mobil-level: %s%.4f\n", debug_db(lev), (20 * log10(lev)));
|
|
|
|
samples_to_int16((int16_t *)data->data, samples, 160);
|
|
|
|
#endif
|
2017-10-28 05:11:40 +00:00
|
|
|
mncc_up(buf, sizeof(buf));
|
|
|
|
/* don't destroy process here in case of an error */
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
|
|
|
process = process->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
/* mncc messages received from fixed network */
|
|
|
|
void mncc_down(uint8_t *buf, int length)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
|
|
|
struct gsm_mncc *mncc = (struct gsm_mncc *)buf;
|
|
|
|
char number[sizeof(mncc->called.number)];
|
2016-07-20 09:58:12 +00:00
|
|
|
char caller_id[sizeof(mncc->calling.number)];
|
|
|
|
enum number_type caller_type;
|
2016-03-01 17:40:38 +00:00
|
|
|
int callref;
|
|
|
|
int rc;
|
2017-10-28 05:11:40 +00:00
|
|
|
process_t *process;
|
|
|
|
|
|
|
|
callref = mncc->callref;
|
|
|
|
process = get_process(callref);
|
|
|
|
if (!process) {
|
|
|
|
if (mncc->msg_type == MNCC_SETUP_REQ)
|
|
|
|
process = create_process(callref, PROCESS_SETUP_RT);
|
|
|
|
else {
|
|
|
|
if (mncc->msg_type != MNCC_REL_REQ)
|
|
|
|
PDEBUG(DCALL, DEBUG_ERROR, "No process!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
if (mncc->msg_type == ANALOG_8000HZ) {
|
|
|
|
struct gsm_data_frame *data = (struct gsm_data_frame *)buf;
|
2017-10-28 05:11:40 +00:00
|
|
|
sample_t samples[160];
|
2017-01-27 15:57:34 +00:00
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* if we are disconnected, ignore audio */
|
2017-10-28 05:11:40 +00:00
|
|
|
if (process->pattern != PATTERN_NONE)
|
2016-03-01 17:40:38 +00:00
|
|
|
return;
|
2017-10-28 05:11:40 +00:00
|
|
|
int16_to_samples(samples, (int16_t *)data->data, 160);
|
2017-01-29 06:25:12 +00:00
|
|
|
#ifdef DEBUG_LEVEL
|
2017-10-28 05:11:40 +00:00
|
|
|
double lev = level_of(samples, 160);
|
2017-01-29 06:25:12 +00:00
|
|
|
printf("festnetz-level: %s %.4f\n", debug_db(lev), (20 * log10(lev)));
|
|
|
|
#endif
|
2017-10-28 05:11:40 +00:00
|
|
|
call_down_audio(callref, samples, 160);
|
2016-03-01 17:40:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
if (process->audio_disconnected) {
|
2016-03-01 17:40:38 +00:00
|
|
|
switch(mncc->msg_type) {
|
|
|
|
case MNCC_DISC_REQ:
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Received MNCC disconnect from fixed network with cause %d\n", mncc->cause.value);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call disconnected, releasing!\n");
|
|
|
|
|
|
|
|
destroy_process(callref);
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Indicate MNCC release towards fixed network\n");
|
2016-03-01 17:40:38 +00:00
|
|
|
mncc->msg_type = MNCC_REL_IND;
|
2017-10-28 05:11:40 +00:00
|
|
|
rc = mncc_up(buf, sizeof(struct gsm_mncc));
|
|
|
|
if (rc < 0)
|
|
|
|
destroy_process(callref);
|
2016-03-01 17:40:38 +00:00
|
|
|
break;
|
|
|
|
case MNCC_REL_REQ:
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Received MNCC release from fixed network with cause %d\n", mncc->cause.value);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call released\n");
|
|
|
|
|
|
|
|
destroy_process(callref);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(mncc->msg_type) {
|
|
|
|
case MNCC_SETUP_REQ:
|
2016-07-20 09:58:12 +00:00
|
|
|
strcpy(number, mncc->called.number);
|
|
|
|
|
|
|
|
/* caller ID conversion */
|
|
|
|
strcpy(caller_id, mncc->calling.number);
|
|
|
|
switch(mncc->calling.type) {
|
|
|
|
case 1:
|
|
|
|
caller_type = TYPE_INTERNATIONAL;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
caller_type = TYPE_NATIONAL;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
caller_type = TYPE_SUBSCRIBER;
|
|
|
|
break;
|
|
|
|
default: /* or 0 */
|
|
|
|
caller_type = TYPE_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!caller_id[0])
|
|
|
|
caller_type = TYPE_NOTAVAIL;
|
|
|
|
if (mncc->calling.present == 1)
|
|
|
|
caller_type = TYPE_ANONYMOUS;
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Received MNCC call from fixed network '%s' to mobile '%s'\n", caller_id, number);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
if (mncc->callref >= 0x4000000) {
|
2017-10-28 05:11:40 +00:00
|
|
|
fprintf(stderr, "Invalid callref from fixed network, please fix!\n");
|
2016-03-01 17:40:38 +00:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Indicate MNCC call confirm towards fixed network\n");
|
2016-03-01 17:40:38 +00:00
|
|
|
memset(buf, 0, length);
|
|
|
|
mncc->msg_type = MNCC_CALL_CONF_IND;
|
|
|
|
mncc->callref = callref;
|
|
|
|
mncc->lchan_type = GSM_LCHAN_TCH_F;
|
|
|
|
mncc->fields |= MNCC_F_BEARER_CAP;
|
|
|
|
mncc->bearer_cap.speech_ver[0] = BCAP_ANALOG_8000HZ;
|
|
|
|
mncc->bearer_cap.speech_ver[1] = -1;
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
mncc_up(buf, sizeof(struct gsm_mncc));
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2016-07-20 09:58:12 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Outgoing call from '%s' to '%s'\n", caller_id, number);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
rc = call_down_setup(callref, caller_id, caller_type, number);
|
2016-03-01 17:40:38 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
PDEBUG(DCALL, DEBUG_NOTICE, "Call rejected, cause %d\n", -rc);
|
2017-10-28 05:11:40 +00:00
|
|
|
if (send_patterns) {
|
2016-03-01 17:40:38 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_DEBUG, "Early connecting after setup\n");
|
|
|
|
_indicate_answer(callref, number);
|
2017-10-28 05:11:40 +00:00
|
|
|
} else {
|
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Disconnecting MNCC call towards fixed network (cause=%d)\n", -rc);
|
|
|
|
_indicate_disconnect_release(callref, -rc, 1);
|
2016-03-01 17:40:38 +00:00
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
disconnect_process(callref, -rc);
|
2016-03-01 17:40:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
if (send_patterns) {
|
2016-03-01 17:40:38 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_DEBUG, "Early connecting after setup\n");
|
|
|
|
_indicate_answer(callref, number);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2017-10-28 05:11:40 +00:00
|
|
|
case MNCC_ALERT_REQ:
|
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Received MNCC alerting from fixed network\n");
|
|
|
|
new_state_process(callref, PROCESS_ALERTING_RO);
|
|
|
|
break;
|
2016-03-01 17:40:38 +00:00
|
|
|
case MNCC_SETUP_RSP:
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Received MNCC answer from fixed network\n");
|
|
|
|
new_state_process(callref, PROCESS_CONNECT);
|
2017-10-07 16:08:31 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call answered\n");
|
2017-10-28 05:11:40 +00:00
|
|
|
call_down_answer(callref);
|
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Indicate MNCC setup complete towards fixed network\n");
|
|
|
|
memset(buf, 0, length);
|
|
|
|
mncc->msg_type = MNCC_SETUP_COMPL_IND;
|
|
|
|
mncc->callref = callref;
|
|
|
|
rc = mncc_up(buf, sizeof(struct gsm_mncc));
|
|
|
|
if (rc < 0)
|
|
|
|
destroy_process(callref);
|
2016-03-01 17:40:38 +00:00
|
|
|
break;
|
|
|
|
case MNCC_DISC_REQ:
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Received MNCC disconnect from fixed network with cause %d\n", mncc->cause.value);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
process = get_process(callref);
|
|
|
|
if (process && process->state == PROCESS_CONNECT && release_on_disconnect) {
|
2017-09-21 17:22:03 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Releasing, because we don't send disconnect tones to mobile phone\n");
|
2016-07-20 10:50:22 +00:00
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Indicate MNCC release towards fixed network\n");
|
2016-07-20 10:50:22 +00:00
|
|
|
mncc->msg_type = MNCC_REL_IND;
|
2017-10-28 05:11:40 +00:00
|
|
|
mncc_up(buf, sizeof(struct gsm_mncc));
|
2016-07-20 10:50:22 +00:00
|
|
|
goto release;
|
|
|
|
}
|
2017-10-28 05:11:40 +00:00
|
|
|
new_state_process(callref, PROCESS_DISCONNECT);
|
2016-03-01 17:40:38 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call disconnected\n");
|
2017-10-28 05:11:40 +00:00
|
|
|
call_down_disconnect(callref, mncc->cause.value);
|
2017-11-18 07:33:07 +00:00
|
|
|
timer_start(&process->timer, DISC_TIMEOUT);
|
2016-03-01 17:40:38 +00:00
|
|
|
break;
|
|
|
|
case MNCC_REL_REQ:
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Received MNCC release from fixed network with cause %d\n", mncc->cause.value);
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2016-07-20 10:50:22 +00:00
|
|
|
release:
|
2016-03-01 17:40:38 +00:00
|
|
|
destroy_process(callref);
|
2017-11-18 07:33:07 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_INFO, "Call released toward mobile network\n");
|
2017-10-28 05:11:40 +00:00
|
|
|
call_down_release(callref, mncc->cause.value);
|
2016-03-01 17:40:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:11:40 +00:00
|
|
|
int (*mncc_up)(uint8_t *buf, int length) = NULL;
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* break down of MNCC socket */
|
2017-10-28 05:11:40 +00:00
|
|
|
void mncc_flush(void)
|
2016-03-01 17:40:38 +00:00
|
|
|
{
|
|
|
|
while(process_head) {
|
2017-10-28 05:11:40 +00:00
|
|
|
PDEBUG(DCALL, DEBUG_NOTICE, "MNCC socket closed, releasing call\n");
|
|
|
|
call_down_release(process_head->callref, CAUSE_TEMPFAIL);
|
2016-03-01 17:40:38 +00:00
|
|
|
destroy_process(process_head->callref);
|
|
|
|
/* note: callref is released by sender's instance */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|