aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/amps/amps.c4
-rw-r--r--src/amps/amps.h1
-rw-r--r--src/amps/transaction.c28
-rw-r--r--src/cnetz/cnetz.c4
-rw-r--r--src/cnetz/cnetz.h1
-rw-r--r--src/cnetz/transaction.c20
6 files changed, 41 insertions, 17 deletions
diff --git a/src/amps/amps.c b/src/amps/amps.c
index 5d57d63..798f95b 100644
--- a/src/amps/amps.c
+++ b/src/amps/amps.c
@@ -414,8 +414,6 @@ static amps_t *search_pc(void)
return NULL;
}
-static void amps_go_idle(amps_t *amps);
-
/* Create transceiver instance and link to a list. */
int amps_create(int channel, enum amps_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback)
{
@@ -555,7 +553,7 @@ void amps_destroy(sender_t *sender)
}
/* Abort connection towards mobile station by sending FOCC/FVC pattern. */
-static void amps_go_idle(amps_t *amps)
+void amps_go_idle(amps_t *amps)
{
int frame_length;
diff --git a/src/amps/amps.h b/src/amps/amps.h
index 6243f74..4ba1f4d 100644
--- a/src/amps/amps.h
+++ b/src/amps/amps.h
@@ -169,6 +169,7 @@ const char *amps_min2number(uint32_t min1, uint16_t min2);
const char *amps_scm(uint8_t scm);
int amps_create(int channel, enum amps_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback);
void amps_destroy(sender_t *sender);
+void amps_go_idle(amps_t *amps);
void amps_rx_signaling_tone(amps_t *amps, int tone, double quality);
void amps_rx_sat(amps_t *amps, int tone, double quality);
void amps_rx_recc(amps_t *amps, uint8_t scm, uint8_t mpci, uint32_t esn, uint32_t min1, uint16_t min2, uint8_t msg_type, uint8_t ordq, uint8_t order, const char *dialing);
diff --git a/src/amps/transaction.c b/src/amps/transaction.c
index eac29e4..d5e7976 100644
--- a/src/amps/transaction.c
+++ b/src/amps/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 "amps.h"
//#include "database.h"
@@ -104,14 +106,28 @@ const char *trans_short_state_name(int state)
/* create transaction */
transaction_t *create_transaction(amps_t *amps, enum amps_trans_state state, uint32_t min1, uint16_t min2, uint8_t msg_type, uint8_t ordq, uint8_t order, uint16_t chan)
{
- transaction_t *trans;
+ sender_t *sender;
+ transaction_t *trans = NULL;
+ amps_t *search_amps;
/* search transaction for this subsriber */
- trans = search_transaction_number(amps, min1, min2);
+ for (sender = sender_head; sender; sender = sender->next) {
+ search_amps = (amps_t *) sender;
+ /* search transaction for this callref */
+ trans = search_transaction_number(search_amps, min1, min2);
+ if (trans)
+ break;
+ }
if (trans) {
const char *number = amps_min2number(trans->min1, trans->min2);
+ int old_callref = trans->callref;
+ amps_t *old_amps = trans->amps;
PDEBUG(DTRANS, DEBUG_NOTICE, "Found alredy pending transaction for subscriber '%s', deleting!\n", number);
destroy_transaction(trans);
+ if (old_amps) /* should be... */
+ amps_go_idle(old_amps);
+ if (old_callref)
+ call_in_release(old_callref, CAUSE_NORMAL);
}
trans = calloc(1, sizeof(*trans));
@@ -131,22 +147,16 @@ transaction_t *create_transaction(amps_t *amps, enum amps_trans_state state, uin
trans->chan = chan;
const char *number = amps_min2number(trans->min1, trans->min2);
- PDEBUG(DTRANS, DEBUG_INFO, "Created transaction '%s' for subscriber '%s'\n", number, trans_state_name(state));
+ PDEBUG(DTRANS, DEBUG_INFO, "Created transaction for subscriber '%s'\n", number);
link_transaction(trans, amps);
- /* update database: now busy */
-// update_db(amps, min1, min2, 1, 0);
-
return trans;
}
/* destroy transaction */
void destroy_transaction(transaction_t *trans)
{
- /* update database: now idle */
-// update_db(trans->amps, trans->min1, trans->min2, 0, trans->ma_failed);
-
unlink_transaction(trans);
const char *number = amps_min2number(trans->min1, trans->min2);
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));