aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2016-08-21 09:00:55 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2016-10-02 09:06:03 +0200
commit8d7c7f44256f8e637bfe23b9987da036b67e095a (patch)
treeabe55fba46adbaf07b643bca03335eb636687b8f /src
parent4c1c8eb6fbaaa35a6d95e3c648d4861b63937eee (diff)
callref: Move callref from 'sender' to individual implementation of a, b, c-netz
Cellular networks use transaction instances, so callref is now member of transaction object.
Diffstat (limited to 'src')
-rw-r--r--src/anetz/anetz.c30
-rw-r--r--src/anetz/anetz.h1
-rw-r--r--src/anetz/dsp.c4
-rw-r--r--src/bnetz/bnetz.c34
-rw-r--r--src/bnetz/bnetz.h1
-rw-r--r--src/bnetz/dsp.c4
-rw-r--r--src/cnetz/cnetz.c48
-rw-r--r--src/cnetz/cnetz.h1
-rw-r--r--src/cnetz/dsp.c2
-rw-r--r--src/common/sender.h3
10 files changed, 64 insertions, 64 deletions
diff --git a/src/anetz/anetz.c b/src/anetz/anetz.c
index a7f183f..a65b157 100644
--- a/src/anetz/anetz.c
+++ b/src/anetz/anetz.c
@@ -235,8 +235,8 @@ void anetz_loss_indication(anetz_t *anetz)
if (anetz->state == ANETZ_GESPRAECH) {
PDEBUG(DANETZ, DEBUG_NOTICE, "Detected loss of signal, releasing.\n");
anetz_release(anetz);
- call_in_release(anetz->sender.callref, CAUSE_TEMPFAIL);
- anetz->sender.callref = 0;
+ call_in_release(anetz->callref, CAUSE_TEMPFAIL);
+ anetz->callref = 0;
}
}
@@ -269,7 +269,7 @@ void anetz_receive_tone(anetz_t *anetz, int tone)
case ANETZ_GESPRAECH:
/* throughconnect speech when calling/answer tone is gone */
if (tone != 1) {
- if (!anetz->sender.callref) {
+ if (!anetz->callref) {
int callref = ++new_callref;
int rc;
@@ -280,10 +280,10 @@ void anetz_receive_tone(anetz_t *anetz, int tone)
anetz_release(anetz);
break;
}
- anetz->sender.callref = callref;
+ anetz->callref = callref;
} else {
PDEBUG(DANETZ, DEBUG_INFO, "1750 Hz signal from mobile station is gone, answer call.\n");
- call_in_answer(anetz->sender.callref, anetz->station_id);
+ call_in_answer(anetz->callref, anetz->station_id);
}
anetz_set_dsp_mode(anetz, DSP_MODE_AUDIO);
}
@@ -291,8 +291,8 @@ void anetz_receive_tone(anetz_t *anetz, int tone)
if (tone == 1) {
PDEBUG(DANETZ, DEBUG_INFO, "Received 1750 Hz release signal from mobile station, sending release tone.\n");
anetz_release(anetz);
- call_in_release(anetz->sender.callref, CAUSE_NORMAL);
- anetz->sender.callref = 0;
+ call_in_release(anetz->callref, CAUSE_NORMAL);
+ anetz->callref = 0;
break;
}
break;
@@ -319,8 +319,8 @@ static void anetz_timeout(struct timer *timer)
case ANETZ_ANRUF:
PDEBUG(DANETZ, DEBUG_NOTICE, "Timeout while waiting for answer, releasing.\n");
anetz_go_idle(anetz);
- call_in_release(anetz->sender.callref, CAUSE_NOANSWER);
- anetz->sender.callref = 0;
+ call_in_release(anetz->callref, CAUSE_NOANSWER);
+ anetz->callref = 0;
break;
case ANETZ_AUSLOESEN:
anetz_go_idle(anetz);
@@ -374,7 +374,7 @@ inval:
PDEBUG(DANETZ, DEBUG_INFO, "Call to mobile station, paging with tones: %.1f %.1f %.1f %.1f\n", freq[0], freq[1], freq[2], freq[3]);
/* 4. trying to page mobile station */
- sender->callref = callref;
+ anetz->callref = callref;
anetz_page(anetz, dialing, freq);
call_in_alerting(callref);
@@ -395,7 +395,7 @@ void call_out_disconnect(int callref, int cause)
for (sender = sender_head; sender; sender = sender->next) {
anetz = (anetz_t *) sender;
- if (sender->callref == callref)
+ if (anetz->callref == callref)
break;
}
if (!sender) {
@@ -418,7 +418,7 @@ void call_out_disconnect(int callref, int cause)
call_in_release(callref, cause);
- sender->callref = 0;
+ anetz->callref = 0;
}
@@ -432,7 +432,7 @@ void call_out_release(int callref, int cause)
for (sender = sender_head; sender; sender = sender->next) {
anetz = (anetz_t *) sender;
- if (sender->callref == callref)
+ if (anetz->callref == callref)
break;
}
if (!sender) {
@@ -441,7 +441,7 @@ void call_out_release(int callref, int cause)
return;
}
- sender->callref = 0;
+ anetz->callref = 0;
switch (anetz->state) {
case ANETZ_GESPRAECH:
@@ -465,7 +465,7 @@ void call_rx_audio(int callref, int16_t *samples, int count)
for (sender = sender_head; sender; sender = sender->next) {
anetz = (anetz_t *) sender;
- if (sender->callref == callref)
+ if (anetz->callref == callref)
break;
}
if (!sender)
diff --git a/src/anetz/anetz.h b/src/anetz/anetz.h
index af04dc4..f1a64e7 100644
--- a/src/anetz/anetz.h
+++ b/src/anetz/anetz.h
@@ -19,6 +19,7 @@ typedef struct anetz {
/* sender's states */
enum anetz_state state; /* current sender's state */
+ int callref; /* call reference */
char station_id[8]; /* current station ID */
struct timer timer;
diff --git a/src/anetz/dsp.c b/src/anetz/dsp.c
index 1248020..2dda069 100644
--- a/src/anetz/dsp.c
+++ b/src/anetz/dsp.c
@@ -209,7 +209,7 @@ void sender_receive(sender_t *sender, int16_t *samples, int length)
anetz->fsk_filter_pos = pos;
/* Forward audio to network (call process). */
- if (anetz->dsp_mode == DSP_MODE_AUDIO && anetz->sender.callref) {
+ if (anetz->dsp_mode == DSP_MODE_AUDIO && anetz->callref) {
int16_t down[length]; /* more than enough */
int count;
@@ -219,7 +219,7 @@ void sender_receive(sender_t *sender, int16_t *samples, int length)
for (i = 0; i < count; i++) {
spl[pos++] = down[i];
if (pos == 160) {
- call_tx_audio(anetz->sender.callref, spl, 160);
+ call_tx_audio(anetz->callref, spl, 160);
pos = 0;
}
}
diff --git a/src/bnetz/bnetz.c b/src/bnetz/bnetz.c
index 13ca098..2aa598d 100644
--- a/src/bnetz/bnetz.c
+++ b/src/bnetz/bnetz.c
@@ -468,8 +468,8 @@ void bnetz_loss_indication(bnetz_t *bnetz)
|| bnetz->state == BNETZ_RUFHALTUNG) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Detected loss of signal, releasing.\n");
bnetz_release(bnetz);
- call_in_release(bnetz->sender.callref, CAUSE_TEMPFAIL);
- bnetz->sender.callref = 0;
+ call_in_release(bnetz->callref, CAUSE_TEMPFAIL);
+ bnetz->callref = 0;
}
}
@@ -502,7 +502,7 @@ void bnetz_receive_tone(bnetz_t *bnetz, int bit)
timer_stop(&bnetz->timer);
bnetz->state = BNETZ_RUFHALTUNG;
bnetz_set_dsp_mode(bnetz, DSP_MODE_1);
- call_in_alerting(bnetz->sender.callref);
+ call_in_alerting(bnetz->callref);
timer_start(&bnetz->timer, ALERTING_TO);
break;
}
@@ -513,7 +513,7 @@ void bnetz_receive_tone(bnetz_t *bnetz, int bit)
timer_stop(&bnetz->timer);
bnetz->state = BNETZ_GESPRAECH;
bnetz_set_dsp_mode(bnetz, DSP_MODE_AUDIO);
- call_in_answer(bnetz->sender.callref, bnetz->station_id);
+ call_in_answer(bnetz->callref, bnetz->station_id);
break;
}
default:
@@ -684,7 +684,7 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double level, d
bnetz_release(bnetz);
return;
}
- bnetz->sender.callref = callref;
+ bnetz->callref = callref;
break;
}
if (digit < '0' || digit > '9') {
@@ -711,8 +711,8 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double level, d
if (digit == 't') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received 'Schlusssignal' from mobile station\n");
bnetz_go_idle(bnetz);
- call_in_release(bnetz->sender.callref, CAUSE_NORMAL);
- bnetz->sender.callref = 0;
+ call_in_release(bnetz->callref, CAUSE_NORMAL);
+ bnetz->callref = 0;
break;
}
break;
@@ -750,8 +750,8 @@ static void bnetz_timeout(struct timer *timer)
if (bnetz->page_try == PAGE_TRIES) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Timeout while waiting for call acknowledge from mobile station, going idle.\n");
bnetz_go_idle(bnetz);
- call_in_release(bnetz->sender.callref, CAUSE_OUTOFORDER);
- bnetz->sender.callref = 0;
+ call_in_release(bnetz->callref, CAUSE_OUTOFORDER);
+ bnetz->callref = 0;
break;
}
PDEBUG(DBNETZ, DEBUG_NOTICE, "Timeout while waiting for call acknowledge from mobile station, trying again.\n");
@@ -760,8 +760,8 @@ static void bnetz_timeout(struct timer *timer)
case BNETZ_RUFHALTUNG:
PDEBUG(DBNETZ, DEBUG_NOTICE, "Timeout while waiting for answer of mobile station, releasing.\n");
bnetz_release(bnetz);
- call_in_release(bnetz->sender.callref, CAUSE_NOANSWER);
- bnetz->sender.callref = 0;
+ call_in_release(bnetz->callref, CAUSE_NOANSWER);
+ bnetz->callref = 0;
break;
default:
break;
@@ -813,7 +813,7 @@ inval:
PDEBUG(DBNETZ, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
/* 4. trying to page mobile station */
- sender->callref = callref;
+ bnetz->callref = callref;
bnetz_page(bnetz, dialing, 1);
return 0;
@@ -832,7 +832,7 @@ void call_out_disconnect(int callref, int cause)
for (sender = sender_head; sender; sender = sender->next) {
bnetz = (bnetz_t *) sender;
- if (sender->callref == callref)
+ if (bnetz->callref == callref)
break;
}
if (!sender) {
@@ -861,7 +861,7 @@ void call_out_disconnect(int callref, int cause)
call_in_release(callref, cause);
- sender->callref = 0;
+ bnetz->callref = 0;
}
/* Call control releases call toward mobile station. */
@@ -874,7 +874,7 @@ void call_out_release(int callref, int cause)
for (sender = sender_head; sender; sender = sender->next) {
bnetz = (bnetz_t *) sender;
- if (sender->callref == callref)
+ if (bnetz->callref == callref)
break;
}
if (!sender) {
@@ -883,7 +883,7 @@ void call_out_release(int callref, int cause)
return;
}
- sender->callref = 0;
+ bnetz->callref = 0;
switch (bnetz->state) {
case BNETZ_GESPRAECH:
@@ -913,7 +913,7 @@ void call_rx_audio(int callref, int16_t *samples, int count)
for (sender = sender_head; sender; sender = sender->next) {
bnetz = (bnetz_t *) sender;
- if (sender->callref == callref)
+ if (bnetz->callref == callref)
break;
}
if (!sender)
diff --git a/src/bnetz/bnetz.h b/src/bnetz/bnetz.h
index 62bd18d..a6cbec1 100644
--- a/src/bnetz/bnetz.h
+++ b/src/bnetz/bnetz.h
@@ -59,6 +59,7 @@ typedef struct bnetz {
/* all bnetz states */
enum bnetz_state state; /* main state of sender */
+ int callref; /* call reference */
enum dial_mode dial_mode; /* sub state while dialing is received */
enum dial_type dial_type; /* defines if mobile supports metering pulses */
char dial_number[14]; /* dial string received */
diff --git a/src/bnetz/dsp.c b/src/bnetz/dsp.c
index fb7a90d..93ba712 100644
--- a/src/bnetz/dsp.c
+++ b/src/bnetz/dsp.c
@@ -282,7 +282,7 @@ void sender_receive(sender_t *sender, int16_t *samples, int length)
}
bnetz->fsk_filter_pos = pos;
- if (bnetz->dsp_mode == DSP_MODE_AUDIO && bnetz->sender.callref) {
+ if (bnetz->dsp_mode == DSP_MODE_AUDIO && bnetz->callref) {
int16_t down[length]; /* more than enough */
int count;
@@ -292,7 +292,7 @@ void sender_receive(sender_t *sender, int16_t *samples, int length)
for (i = 0; i < count; i++) {
spl[pos++] = down[i];
if (pos == 160) {
- call_tx_audio(bnetz->sender.callref, spl, 160);
+ call_tx_audio(bnetz->callref, spl, 160);
pos = 0;
}
}
diff --git a/src/cnetz/cnetz.c b/src/cnetz/cnetz.c
index c9f8236..bfb2ff1 100644
--- a/src/cnetz/cnetz.c
+++ b/src/cnetz/cnetz.c
@@ -355,10 +355,10 @@ void cnetz_destroy(sender_t *sender)
/* Abort connection, if any and send idle broadcast */
static void cnetz_go_idle(cnetz_t *cnetz)
{
- if (cnetz->sender.callref) {
+ if (cnetz->callref) {
PDEBUG(DCNETZ, DEBUG_ERROR, "Releasing but still having callref, please fix!\n");
- call_in_release(cnetz->sender.callref, CAUSE_NORMAL);
- cnetz->sender.callref = 0;
+ call_in_release(cnetz->callref, CAUSE_NORMAL);
+ cnetz->callref = 0;
}
PDEBUG(DCNETZ, DEBUG_INFO, "Entering IDLE state on channel %d.\n", cnetz->sender.kanal);
@@ -392,7 +392,7 @@ void call_rx_audio(int callref, int16_t *samples, int count)
for (sender = sender_head; sender; sender = sender->next) {
cnetz = (cnetz_t *) sender;
- if (sender->callref == callref)
+ if (cnetz->callref == callref)
break;
}
if (!sender)
@@ -520,7 +520,7 @@ inval:
trans = create_transaction(cnetz, TRANS_VAK, dialing[0] - '0', dialing[1] - '0', atoi(dialing + 2), -1);
if (!trans) {
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to create transaction\n");
- sender->callref = 0;
+ cnetz->callref = 0;
return -CAUSE_TEMPFAIL;
}
trans->callref = callref;
@@ -559,7 +559,7 @@ void call_out_disconnect(int callref, int cause)
if (cnetz->state != CNETZ_BUSY) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing disconnect, but sender is not in busy state.\n");
call_in_release(callref, cause);
- sender->callref = 0;
+ cnetz->callref = 0;
return;
}
#endif
@@ -568,7 +568,7 @@ void call_out_disconnect(int callref, int cause)
trans = cnetz->trans_list;
if (!trans) {
call_in_release(callref, cause);
- sender->callref = 0;
+ cnetz->callref = 0;
return;
}
#endif
@@ -582,13 +582,13 @@ void call_out_disconnect(int callref, int cause)
PDEBUG(DCNETZ, DEBUG_INFO, "Call control disconnects on speech channel, releasing towards mobile station.\n");
cnetz_release(trans, cnetz_cause_isdn2cnetz(cause));
call_in_release(callref, cause);
- sender->callref = 0;
+ cnetz->callref = 0;
trans->callref = 0;
break;
default:
PDEBUG(DCNETZ, DEBUG_INFO, "Call control disconnects on organisation channel, removing transaction.\n");
call_in_release(callref, cause);
- sender->callref = 0;
+ cnetz->callref = 0;
destroy_transaction(trans);
cnetz_go_idle(cnetz);
}
@@ -617,7 +617,7 @@ void call_out_release(int callref, int cause)
return;
}
- sender->callref = 0;
+ cnetz->callref = 0;
trans->callref = 0;
#if 0
@@ -754,29 +754,29 @@ void transaction_timeout(struct timer *timer)
PDEBUG_CHAN(DCNETZ, DEBUG_NOTICE, "Lost signal from 'FuTln' (mobile station)\n");
if (trans->callref) {
call_in_release(trans->callref, CAUSE_TEMPFAIL);
- cnetz->sender.callref = 0;
+ cnetz->callref = 0;
trans->callref = 0;
}
cnetz_release(trans, CNETZ_CAUSE_FUNKTECHNISCH);
break;
case TRANS_DS:
PDEBUG_CHAN(DCNETZ, DEBUG_NOTICE, "No response after connect 'Durchschalten'\n");
- call_in_release(cnetz->sender.callref, CAUSE_TEMPFAIL);
- cnetz->sender.callref = 0;
+ call_in_release(cnetz->callref, CAUSE_TEMPFAIL);
+ cnetz->callref = 0;
trans->callref = 0;
cnetz_release(trans, CNETZ_CAUSE_FUNKTECHNISCH);
break;
case TRANS_RTA:
PDEBUG_CHAN(DCNETZ, DEBUG_NOTICE, "No response after ringing order 'Rufton anschalten'\n");
- call_in_release(cnetz->sender.callref, CAUSE_TEMPFAIL);
- cnetz->sender.callref = 0;
+ call_in_release(cnetz->callref, CAUSE_TEMPFAIL);
+ cnetz->callref = 0;
trans->callref = 0;
cnetz_release(trans, CNETZ_CAUSE_FUNKTECHNISCH);
break;
case TRANS_AHQ:
PDEBUG_CHAN(DCNETZ, DEBUG_NOTICE, "No response after answer 'Abhebequittung'\n");
- call_in_release(cnetz->sender.callref, CAUSE_TEMPFAIL);
- cnetz->sender.callref = 0;
+ call_in_release(cnetz->callref, CAUSE_TEMPFAIL);
+ cnetz->callref = 0;
trans->callref = 0;
cnetz_release(trans, CNETZ_CAUSE_FUNKTECHNISCH);
break;
@@ -919,7 +919,7 @@ wbn:
PDEBUG(DCNETZ, DEBUG_INFO, "Staying on combined calling + traffic channel %d\n", spk->sender.kanal);
} else {
PDEBUG(DCNETZ, DEBUG_INFO, "Assigning phone to traffic channel %d\n", spk->sender.kanal);
- spk->sender.callref = trans->callref;
+ spk->callref = trans->callref;
/* sync RX time to current OgK time */
spk->fsk_demod.bit_time = cnetz->fsk_demod.bit_time;
}
@@ -1153,13 +1153,13 @@ const telegramm_t *cnetz_transmit_telegramm_spk_k(cnetz_t *cnetz)
cnetz_release(trans, cnetz_cause_isdn2cnetz(-rc));
goto call_failed;
}
- cnetz->sender.callref = trans->callref;
+ cnetz->callref = trans->callref;
trans_new_state(trans, TRANS_DS);
trans->repeat = 0;
timer_start(&trans->timer, 0.0375 * F_DS); /* F_DS frames */
}
if (trans->mt_call) {
- cnetz->sender.callref = trans->callref;
+ cnetz->callref = trans->callref;
trans_new_state(trans, TRANS_RTA);
timer_start(&trans->timer, 0.0375 * F_RTA); /* F_RTA frames */
trans->repeat = 0;
@@ -1212,7 +1212,7 @@ call_failed:
cnetz_release(trans, CNETZ_CAUSE_FUNKTECHNISCH);
if (trans->callref) {
call_in_release(trans->callref, CAUSE_TEMPFAIL);
- cnetz->sender.callref = 0;
+ cnetz->callref = 0;
}
/* must destroy transaction after cnetz_release */
destroy_transaction(trans);
@@ -1221,7 +1221,7 @@ call_failed:
}
/* remove call from SpK (or OgK+SpK) */
unlink_transaction(trans);
- cnetz->sender.callref = 0;
+ cnetz->callref = 0;
/* idle channel */
cnetz_go_idle(cnetz);
/* alloc ogk again */
@@ -1358,7 +1358,7 @@ void cnetz_receive_telegramm_spk_k(cnetz_t *cnetz, telegramm_t *telegramm)
timer_stop(&trans->timer);
if (trans->callref) {
call_in_release(trans->callref, CAUSE_NORMAL);
- cnetz->sender.callref = 0;
+ cnetz->callref = 0;
trans->callref = 0;
}
break;
@@ -1470,7 +1470,7 @@ void cnetz_receive_telegramm_spk_v(cnetz_t *cnetz, telegramm_t *telegramm)
timer_stop(&trans->timer);
if (trans->callref) {
call_in_release(trans->callref, CAUSE_NORMAL);
- cnetz->sender.callref = 0;
+ cnetz->callref = 0;
trans->callref = 0;
}
break;
diff --git a/src/cnetz/cnetz.h b/src/cnetz/cnetz.h
index bc7e474..846b100 100644
--- a/src/cnetz/cnetz.h
+++ b/src/cnetz/cnetz.h
@@ -70,6 +70,7 @@ typedef struct cnetz {
/* all cnetz states */
enum cnetz_state state; /* main state of sender */
+ int callref; /* call reference while in SpK mode */
/* cell nr selection */
int cell_auto; /* if set, cell_nr is selected automatically */
diff --git a/src/cnetz/dsp.c b/src/cnetz/dsp.c
index e2be69c..7bf6159 100644
--- a/src/cnetz/dsp.c
+++ b/src/cnetz/dsp.c
@@ -837,7 +837,7 @@ void unshrink_speech(cnetz_t *cnetz, int16_t *speech_buffer, int count)
for (i = 0; i < count; i++) {
spl[pos++] = speech_buffer[i];
if (pos == 160) {
- call_tx_audio(cnetz->sender.callref, spl, 160);
+ call_tx_audio(cnetz->callref, spl, 160);
pos = 0;
}
}
diff --git a/src/common/sender.h b/src/common/sender.h
index 8a26537..d3556e6 100644
--- a/src/common/sender.h
+++ b/src/common/sender.h
@@ -14,9 +14,6 @@ typedef struct sender {
struct sender *slave; /* points to audio device slave member */
struct sender *master; /* points to audio device master source */
- /* call reference */
- int callref;
-
/* system info */
int kanal; /* channel number */