aboutsummaryrefslogtreecommitdiffstats
path: root/src/cnetz
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-05-26 07:27:30 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2017-06-10 13:08:22 +0200
commit57d4d1739eed6bb908577f2aef9a4d952387df05 (patch)
treee365b8a602dace41f7cd55d6dfaa76c3a02008c5 /src/cnetz
parent6adfcf74664a30021f12cc84e00a7cd471ee81a1 (diff)
AMPS/C-Netz: Correctly release pending transaction when creating a new one
If transactions is created, look on all channels for pending transaction with same subscriber. 1. Remove that transaction. 2. Make channel return to IDLE. 3. Release call, if callref exists.
Diffstat (limited to 'src/cnetz')
-rw-r--r--src/cnetz/cnetz.c4
-rw-r--r--src/cnetz/cnetz.h1
-rw-r--r--src/cnetz/transaction.c20
3 files changed, 20 insertions, 5 deletions
diff --git a/src/cnetz/cnetz.c b/src/cnetz/cnetz.c
index 5563841..c51c5e0 100644
--- a/src/cnetz/cnetz.c
+++ b/src/cnetz/cnetz.c
@@ -230,8 +230,6 @@ int cnetz_init(void)
return 0;
}
-static void cnetz_go_idle(cnetz_t *cnetz);
-
/* Create transceiver instance and link to a list. */
int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *audiodev, int use_sdr, enum demod_type demod, int samplerate, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback)
{
@@ -412,7 +410,7 @@ void cnetz_destroy(sender_t *sender)
}
/* Abort connection, if any and send idle broadcast */
-static void cnetz_go_idle(cnetz_t *cnetz)
+void cnetz_go_idle(cnetz_t *cnetz)
{
if (cnetz->state == CNETZ_IDLE)
return;
diff --git a/src/cnetz/cnetz.h b/src/cnetz/cnetz.h
index 4f0bebe..ed73831 100644
--- a/src/cnetz/cnetz.h
+++ b/src/cnetz/cnetz.h
@@ -129,6 +129,7 @@ const char *chan_type_long_name(enum cnetz_chan_type chan_type);
int cnetz_init(void);
int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *audiodev, int use_sdr, enum demod_type demod, int samplerate, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback);
void cnetz_destroy(sender_t *sender);
+void cnetz_go_idle(cnetz_t *cnetz);
void cnetz_sync_frame(cnetz_t *cnetz, double sync, int ts);
int cnetz_meldeaufruf(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest);
const struct telegramm *cnetz_transmit_telegramm_rufblock(cnetz_t *cnetz);
diff --git a/src/cnetz/transaction.c b/src/cnetz/transaction.c
index b37a014..e63a6bf 100644
--- a/src/cnetz/transaction.c
+++ b/src/cnetz/transaction.c
@@ -23,6 +23,8 @@
#include "../common/sample.h"
#include "../common/debug.h"
#include "../common/timer.h"
+#include "../common/call.h"
+#include "../common/cause.h"
#include "cnetz.h"
#include "telegramm.h"
#include "database.h"
@@ -39,14 +41,28 @@ const char *transaction2rufnummer(transaction_t *trans)
/* create transaction */
transaction_t *create_transaction(cnetz_t *cnetz, uint32_t state, uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, int extended)
{
- transaction_t *trans;
+ sender_t *sender;
+ transaction_t *trans = NULL;
+ cnetz_t *search_cnetz;
/* search transaction for this subsriber */
- trans = search_transaction_number(cnetz, futln_nat, futln_fuvst, futln_rest);
+ for (sender = sender_head; sender; sender = sender->next) {
+ search_cnetz = (cnetz_t *) sender;
+ /* search transaction for this callref */
+ trans = search_transaction_number(search_cnetz, futln_nat, futln_fuvst, futln_rest);
+ if (trans)
+ break;
+ }
if (trans) {
const char *rufnummer = transaction2rufnummer(trans);
+ int old_callref = trans->callref;
+ cnetz_t *old_cnetz = trans->cnetz;
PDEBUG(DTRANS, DEBUG_NOTICE, "Found alredy pending transaction for subscriber '%s', deleting!\n", rufnummer);
destroy_transaction(trans);
+ if (old_cnetz) /* should be... */
+ cnetz_go_idle(old_cnetz);
+ if (old_callref)
+ call_in_release(old_callref, CAUSE_NORMAL);
}
trans = calloc(1, sizeof(*trans));