aboutsummaryrefslogtreecommitdiffstats
path: root/src/amps
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/amps
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/amps')
-rw-r--r--src/amps/amps.c4
-rw-r--r--src/amps/amps.h1
-rw-r--r--src/amps/transaction.c28
3 files changed, 21 insertions, 12 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);