Move from local to external osmo* libraries

src/libdebug -> libosmocore
src/libselect -> libosmocore
src/libtimer -> libosmocore
src/libosmocc -> libosmo-cc
src/libg711 -> libosmo-cc
This commit is contained in:
Andreas Eversberg
2024-01-05 14:20:36 +01:00
parent 6cd2c3e323
commit 3158c48365
198 changed files with 4202 additions and 12564 deletions

View File

@@ -23,17 +23,13 @@ nmt_LDADD = \
$(COMMON_LA) \
libdmssms.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libcompandor/libcompandor.a \
$(top_builddir)/src/libgoertzel/libgoertzel.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libhagelbarger/libhagelbarger.a \
$(top_builddir)/src/libdtmf/libdtmf.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfsk/libfsk.a \
@@ -41,8 +37,10 @@ nmt_LDADD = \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/liblogging/liblogging.a \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOCC_LIBS) \
-lm
if HAVE_ALSA

View File

@@ -22,7 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/get_time.h"
#include "nmt.h"
#define MUTE_DURATION 0.300 /* 200ms, and about 95ms for the frame itself */
@@ -110,7 +111,7 @@ void link_dms_frame(nmt_t *nmt, struct dms_frame *frame)
dms_t *dms = &nmt->dms;
struct dms_frame **framep;
PDEBUG(DDMS, DEBUG_DEBUG, "link DMS frame\n");
LOGP(DDMS, LOGL_DEBUG, "link DMS frame\n");
/* attach to end of list */
framep = &dms->state.frame_list;
@@ -125,14 +126,14 @@ void unlink_dms_frame(nmt_t *nmt, struct dms_frame *frame)
dms_t *dms = &nmt->dms;
struct dms_frame **framep;
PDEBUG(DDMS, DEBUG_DEBUG, "unlink DMS frame\n");
LOGP(DDMS, LOGL_DEBUG, "unlink DMS frame\n");
/* unlink */
framep = &dms->state.frame_list;
while (*framep && *framep != frame)
framep = &((*framep)->next);
if (!(*framep)) {
PDEBUG(DTRANS, DEBUG_ERROR, "Frame not in list, please fix!!\n");
LOGP(DTRANS, LOGL_ERROR, "Frame not in list, please fix!!\n");
abort();
}
*framep = frame->next;
@@ -146,7 +147,7 @@ static void dms_frame_add(nmt_t *nmt, int s, const uint8_t *data)
dms_frame = calloc(1, sizeof(*dms_frame));
if (!dms_frame) {
PDEBUG(DDMS, DEBUG_ERROR, "No memory!\n");
LOGP(DDMS, LOGL_ERROR, "No memory!\n");
return;
}
@@ -155,7 +156,7 @@ static void dms_frame_add(nmt_t *nmt, int s, const uint8_t *data)
dms->state.n_count = (dms->state.n_count + 1) & 7;
memcpy(dms_frame->data, data, 8);
PDEBUG(DDMS, DEBUG_DEBUG, "add DMS %cT(%d) frame to queue\n", dms_frame->s + 'C', dms_frame->n);
LOGP(DDMS, LOGL_DEBUG, "add DMS %cT(%d) frame to queue\n", dms_frame->s + 'C', dms_frame->n);
link_dms_frame(nmt, dms_frame);
}
@@ -163,7 +164,7 @@ static void dms_frame_add(nmt_t *nmt, int s, const uint8_t *data)
/* delete DMS frame from list of TX frames */
static void dms_frame_delete(nmt_t *nmt, struct dms_frame *dms_frame)
{
PDEBUG(DDMS, DEBUG_DEBUG, "delete DMS frame %cT(%d) from queue\n", dms_frame->s + 'C', dms_frame->n);
LOGP(DDMS, LOGL_DEBUG, "delete DMS frame %cT(%d) from queue\n", dms_frame->s + 'C', dms_frame->n);
unlink_dms_frame(nmt, dms_frame);
@@ -248,7 +249,7 @@ static void dms_encode_dt(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n, uint8_t *
uint16_t crc;
int i, j;
PDEBUG(DDMS, DEBUG_INFO, "Sending DMS frame: %s\n", print_ct_dt(s, n, _data, dms->state.eight_bits));
LOGP(DDMS, LOGL_INFO, "Sending DMS frame: %s\n", print_ct_dt(s, n, _data, dms->state.eight_bits));
/* generate label */
data[0] = (d << 6) | (s << 5) | (3 << 3) | n;
@@ -354,7 +355,7 @@ void trigger_frame_transmission(nmt_t *nmt)
/* check for RR first, because high priority */
if (dms->state.send_rr) {
PDEBUG(DDMS, DEBUG_DEBUG, "Found pending RR(%d) frame, sending.\n", dms->state.n_r);
LOGP(DDMS, LOGL_DEBUG, "Found pending RR(%d) frame, sending.\n", dms->state.n_r);
dms->state.send_rr = 0;
dms_encode_rr(nmt, dms->state.dir ^ 1, 1, dms->state.n_r);
return;
@@ -374,7 +375,7 @@ void trigger_frame_transmission(nmt_t *nmt)
/* check if outstanding frame */
if (!dms_frame) {
PDEBUG(DDMS, DEBUG_DEBUG, "No pending RR/CT/DT frame found.\n");
LOGP(DDMS, LOGL_DEBUG, "No pending RR/CT/DT frame found.\n");
if (dms->state.tx_pending) {
dms->state.tx_pending = 0;
dms_all_sent(nmt);
@@ -382,7 +383,7 @@ void trigger_frame_transmission(nmt_t *nmt)
return;
}
PDEBUG(DDMS, DEBUG_DEBUG, "Found pending %cT(%d) frame, sending.\n", dms_frame->s + 'C', dms_frame->n);
LOGP(DDMS, LOGL_DEBUG, "Found pending %cT(%d) frame, sending.\n", dms_frame->s + 'C', dms_frame->n);
/* sent next send state to next frame in buffer.
* if there is no next frame, set it to the first frame (cycle).
@@ -390,19 +391,19 @@ void trigger_frame_transmission(nmt_t *nmt)
*/
if (!dms_frame->next) {
dms->state.n_s = dms->state.frame_list->n;
PDEBUG(DDMS, DEBUG_DEBUG, " -> Next sequence number is %d, because this was the last frame in queue.\n", dms->state.n_s);
LOGP(DDMS, LOGL_DEBUG, " -> Next sequence number is %d, because this was the last frame in queue.\n", dms->state.n_s);
} else if (!dms->state.established && dms_frame->next->s == 1) {
dms->state.n_s = dms->state.frame_list->n;
PDEBUG(DDMS, DEBUG_DEBUG, " -> Next sequence number is %d, because this was the last frame before DT queue, and RAND has not been acked yet.\n", dms->state.n_s);
LOGP(DDMS, LOGL_DEBUG, " -> Next sequence number is %d, because this was the last frame before DT queue, and RAND has not been acked yet.\n", dms->state.n_s);
} else if (i == 3) {
dms->state.n_s = dms->state.frame_list->n;
PDEBUG(DDMS, DEBUG_DEBUG, " -> Next sequence number is %d, because we reached max number of unacknowledged frames.\n", dms->state.n_s);
LOGP(DDMS, LOGL_DEBUG, " -> Next sequence number is %d, because we reached max number of unacknowledged frames.\n", dms->state.n_s);
} else if (!dms->state.established && dms_frame->next->s == 0) {
dms->state.n_s = dms_frame->next->n;
PDEBUG(DDMS, DEBUG_DEBUG, " -> Next sequence number is %d, because this is the next CT frame in queue.\n", dms->state.n_s);
LOGP(DDMS, LOGL_DEBUG, " -> Next sequence number is %d, because this is the next CT frame in queue.\n", dms->state.n_s);
} else {
dms->state.n_s = dms_frame->next->n;
PDEBUG(DDMS, DEBUG_DEBUG, " -> Next sequence number is %d, because this is the next frame in queue.\n", dms->state.n_s);
LOGP(DDMS, LOGL_DEBUG, " -> Next sequence number is %d, because this is the next frame in queue.\n", dms->state.n_s);
}
dms_encode_dt(nmt, dms->state.dir ^ 1, dms_frame->s, dms_frame->n, dms_frame->data);
@@ -438,7 +439,7 @@ static void dms_rx_dt(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n, uint8_t *data
/* start transfer */
if (!dms->state.started) {
PDEBUG(DDMS, DEBUG_INFO, "Starting DMS transfer (mobile originated)\n");
LOGP(DDMS, LOGL_INFO, "Starting DMS transfer (mobile originated)\n");
dms->state.started = 1;
dms->state.established = 0;
dms->state.dir = d;
@@ -451,15 +452,15 @@ static void dms_rx_dt(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n, uint8_t *data
if (dms->state.dir != d && !dms_allow_loopback) {
/* drop frames with wrong direction indicator */
PDEBUG(DDMS, DEBUG_INFO, "DMS frame ignored, direction indicator mismatch!\n");
LOGP(DDMS, LOGL_INFO, "DMS frame ignored, direction indicator mismatch!\n");
return;
}
if (dms->state.n_r != n) {
/* ignore out of sequence frames */
PDEBUG(DDMS, DEBUG_DEBUG, "DMS frame number mismatch (due to resending)\n");
LOGP(DDMS, LOGL_DEBUG, "DMS frame number mismatch (due to resending)\n");
} else {
PDEBUG(DDMS, DEBUG_INFO, "Received valid DMS frame: %s\n", print_ct_dt(s, n, data, dms->state.eight_bits));
LOGP(DDMS, LOGL_INFO, "Received valid DMS frame: %s\n", print_ct_dt(s, n, data, dms->state.eight_bits));
/* cycle sequence */
dms->state.n_r = (n + 1) % 8;
@@ -470,7 +471,7 @@ static void dms_rx_dt(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n, uint8_t *data
case 73: /* ID */
break;
case 82: /* RAND */
PDEBUG(DDMS, DEBUG_DEBUG, "RAND frame has been received, so we can send/receive DT frame\n");
LOGP(DDMS, LOGL_DEBUG, "RAND frame has been received, so we can send/receive DT frame\n");
/* when we sent RAND, we do not resend it again, this would be wrong */
if (!dms->state.rand_sent) {
dms_frame_add_rand(nmt, data[7]);
@@ -484,7 +485,7 @@ static void dms_rx_dt(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n, uint8_t *data
}
} else {
if (!dms->state.established)
PDEBUG(DDMS, DEBUG_NOTICE, "Received DT frame, but RAND frame has not been received yet\n");
LOGP(DDMS, LOGL_NOTICE, "Received DT frame, but RAND frame has not been received yet\n");
else {
if (!dms->state.eight_bits)
length = 8;
@@ -526,7 +527,7 @@ static void dms_rx_rr(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n)
if (dms->state.dir != d && !dms_allow_loopback) {
/* drop frames with wrong direction indicator */
PDEBUG(DDMS, DEBUG_INFO, "DMS frame ignored, direction indicator mismatch!\n");
LOGP(DDMS, LOGL_INFO, "DMS frame ignored, direction indicator mismatch!\n");
return;
}
@@ -541,17 +542,17 @@ static void dms_rx_rr(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n)
/* if we don't find a frame, it must have been already acked, so we ignore RR */
if (!dms_frame || i == 4) {
PDEBUG(DDMS, DEBUG_DEBUG, "Received already acked DMS frame: RR(%d) (s = %d), ignoring\n", n, s);
LOGP(DDMS, LOGL_DEBUG, "Received already acked DMS frame: RR(%d) (s = %d), ignoring\n", n, s);
return;
}
PDEBUG(DDMS, DEBUG_INFO, "Received valid DMS frame: RR(%d) (s = %d)\n", n, s);
LOGP(DDMS, LOGL_INFO, "Received valid DMS frame: RR(%d) (s = %d)\n", n, s);
/* flush all acked frames. */
dms_frame = dms->state.frame_list;
for (j = 0; j <= i; j++) {
if (dms_frame->data[0] == 82) { /* RAND */
PDEBUG(DDMS, DEBUG_DEBUG, "RAND frame has been acknowledged, so we can continue to send DT frame\n");
LOGP(DDMS, LOGL_DEBUG, "RAND frame has been acknowledged, so we can continue to send DT frame\n");
dms->state.established = 1;
}
/* increment ack counter */
@@ -559,9 +560,9 @@ static void dms_rx_rr(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n)
/* raise send counter if required */
if (dms->state.n_s == dms_frame->n) {
dms->state.n_s = dms->state.n_a;
PDEBUG(DDMS, DEBUG_DEBUG, "Raising next frame to send to #%d\n", dms->state.n_s);
LOGP(DDMS, LOGL_DEBUG, "Raising next frame to send to #%d\n", dms->state.n_s);
}
PDEBUG(DDMS, DEBUG_DEBUG, "Removing acked frame #%d\n", dms_frame->n);
LOGP(DDMS, LOGL_DEBUG, "Removing acked frame #%d\n", dms_frame->n);
dms_frame_next = dms_frame->next;
dms_frame_delete(nmt, dms_frame);
dms_frame = dms_frame_next;
@@ -581,11 +582,11 @@ static void dms_rx_nr(nmt_t *nmt, uint8_t d, uint8_t s, uint8_t n)
if (dms->state.dir != d && !dms_allow_loopback) {
/* drop frames with wrong direction indicator */
PDEBUG(DDMS, DEBUG_INFO, "DMS frame ignored, direction indicator mismatch!\n");
LOGP(DDMS, LOGL_INFO, "DMS frame ignored, direction indicator mismatch!\n");
return;
}
PDEBUG(DDMS, DEBUG_INFO, "Received valid DMS frame: NR(%d) (s = %d)\n", n, s);
LOGP(DDMS, LOGL_INFO, "Received valid DMS frame: NR(%d) (s = %d)\n", n, s);
// FIXME: support NR
@@ -624,7 +625,7 @@ void fsk_receive_bit_dms(nmt_t *nmt, int bit, double quality, double level)
if (quality < 0.65)
return;
PDEBUG(DDSP, DEBUG_DEBUG, "DMS sync RX Level: %.0f%% Quality=%.0f\n", level * 100.0 + 0.5, quality * 100.0 + 0.5);
LOGP(DDSP, LOGL_DEBUG, "DMS sync RX Level: %.0f%% Quality=%.0f\n", level * 100.0 + 0.5, quality * 100.0 + 0.5);
/* rest sync register */
dms->rx_sync = 0;
@@ -657,10 +658,10 @@ void fsk_receive_bit_dms(nmt_t *nmt, int bit, double quality, double level)
dms->rx_label.s = (dms->rx_frame[0] >> 5) & 0x1;
dms->rx_label.p = (dms->rx_frame[0] >> 3) & 0x3;
dms->rx_label.n = dms->rx_frame[0] & 0x7;
PDEBUG(DDMS, DEBUG_DEBUG, "Got DMS label (d = %d, s = %d, p = %d, n = %d)\n", dms->rx_label.d,dms->rx_label.s,dms->rx_label.p,dms->rx_label.n);
LOGP(DDMS, LOGL_DEBUG, "Got DMS label (d = %d, s = %d, p = %d, n = %d)\n", dms->rx_label.d,dms->rx_label.s,dms->rx_label.p,dms->rx_label.n);
dms->rx_frame_count++;
if (dms->rx_label.p == 0) {
PDEBUG(DDMS, DEBUG_DEBUG, "Spare prefix '00' ignoring!\n");
LOGP(DDMS, LOGL_DEBUG, "Spare prefix '00' ignoring!\n");
dms->rx_in_sync = 0;
}
}
@@ -673,7 +674,7 @@ void fsk_receive_bit_dms(nmt_t *nmt, int bit, double quality, double level)
if (dms->rx_bit_count == 9) {
dms->rx_bit_count = 0;
uint8_t c = dms->rx_frame[dms->rx_frame_count];
PDEBUG(DDMS, DEBUG_DEBUG, "Got DMS word 0x%02x (%c)\n", c, (c >= 32 && c <= 126) ? c : '.');
LOGP(DDMS, LOGL_DEBUG, "Got DMS word 0x%02x (%c)\n", c, (c >= 32 && c <= 126) ? c : '.');
dms->rx_frame_count++;
}
return;
@@ -681,7 +682,7 @@ void fsk_receive_bit_dms(nmt_t *nmt, int bit, double quality, double level)
if (dms->rx_frame_count <= 10) {
if (dms->rx_bit_count == 9) {
dms->rx_bit_count = 0;
PDEBUG(DDMS, DEBUG_DEBUG, "Got DMS CRC 0x%02x\n", dms->rx_frame[dms->rx_frame_count]);
LOGP(DDMS, LOGL_DEBUG, "Got DMS CRC 0x%02x\n", dms->rx_frame[dms->rx_frame_count]);
dms->rx_frame_count++;
}
return;
@@ -691,7 +692,7 @@ void fsk_receive_bit_dms(nmt_t *nmt, int bit, double quality, double level)
uint8_t bits[63 + 16];
int i, j;
dms->rx_bit_count = 0;
PDEBUG(DDMS, DEBUG_DEBUG, "Got DMS CRC 0x%x\n", dms->rx_frame[dms->rx_frame_count]);
LOGP(DDMS, LOGL_DEBUG, "Got DMS CRC 0x%x\n", dms->rx_frame[dms->rx_frame_count]);
crc_got = (dms->rx_frame[9] << 9) | (dms->rx_frame[10] << 2) | dms->rx_frame[11];
for (i = 0; i < 9; i++) {
for (j = 0; j < 7; j++)
@@ -700,7 +701,7 @@ void fsk_receive_bit_dms(nmt_t *nmt, int bit, double quality, double level)
for (i = 0; i < 16; i++)
bits[63 + i] = 0;
crc_calc = crc16(bits, 63 + 16);
PDEBUG(DDMS, DEBUG_DEBUG, "DMS CRC = 0x%04x %s\n", crc_got, (crc_calc == crc_got) ? "(OK)" : "(CRC error)");
LOGP(DDMS, LOGL_DEBUG, "DMS CRC = 0x%04x %s\n", crc_got, (crc_calc == crc_got) ? "(OK)" : "(CRC error)");
if (crc_calc == crc_got)
dms_rx_dt(nmt, dms->rx_label.d, dms->rx_label.s, dms->rx_label.n, dms->rx_frame + 1);
dms->rx_in_sync = 0;
@@ -713,12 +714,12 @@ void fsk_receive_bit_dms(nmt_t *nmt, int bit, double quality, double level)
if (dms->rx_bit_count == 9) {
dms->rx_bit_count = 0;
if (dms->rx_frame[0] != dms->rx_frame[1]) {
PDEBUG(DDMS, DEBUG_DEBUG, "Repeated DMS label mismatches!\n");
LOGP(DDMS, LOGL_DEBUG, "Repeated DMS label mismatches!\n");
dms->rx_in_sync = 0;
return;
}
dms->rx_frame_count++;
PDEBUG(DDMS, DEBUG_DEBUG, "Repeated label matches\n");
LOGP(DDMS, LOGL_DEBUG, "Repeated label matches\n");
}
return;
}
@@ -727,13 +728,13 @@ void fsk_receive_bit_dms(nmt_t *nmt, int bit, double quality, double level)
int i;
dms->rx_bit_count = 0;
parity_got = dms->rx_frame[2];
PDEBUG(DDMS, DEBUG_DEBUG, "Got DMS parity 0x%x\n", dms->rx_frame[dms->rx_frame_count]);
LOGP(DDMS, LOGL_DEBUG, "Got DMS parity 0x%x\n", dms->rx_frame[dms->rx_frame_count]);
for (i = 0; i < 7; i++) {
bit = (dms->rx_frame[0] >> i) & 1;
if (bit)
parity_calc ^= 0x3;
}
PDEBUG(DDMS, DEBUG_DEBUG, "DMS parity %s\n", (parity_calc == parity_got) ? "(OK)" : "(parity error)");
LOGP(DDMS, LOGL_DEBUG, "DMS parity %s\n", (parity_calc == parity_got) ? "(OK)" : "(parity error)");
if (parity_calc == parity_got) {
if (dms->rx_label.p == 1)
dms_rx_rr(nmt, dms->rx_label.d, dms->rx_label.s, dms->rx_label.n);
@@ -758,18 +759,18 @@ void dms_send(nmt_t *nmt, const uint8_t *data, int length, int eight_bits)
uint8_t frame[8];
int i, copied;
PDEBUG(DDMS, DEBUG_DEBUG, "Received message with %d digits of %d bits\n", length, (eight_bits) ? 8 : 7);
LOGP(DDMS, LOGL_DEBUG, "Received message with %d digits of %d bits\n", length, (eight_bits) ? 8 : 7);
/* active connection */
if (dms->state.started) {
if (dms->state.eight_bits != eight_bits) {
PDEBUG(DDMS, DEBUG_ERROR, "DMS session active, but upper layer sends wrong bit format!\n");
LOGP(DDMS, LOGL_ERROR, "DMS session active, but upper layer sends wrong bit format!\n");
return;
}
}
if (!dms->state.started) {
PDEBUG(DDMS, DEBUG_DEBUG, "Transfer not started, so we send ID + RAND first\n");
LOGP(DDMS, LOGL_DEBUG, "Transfer not started, so we send ID + RAND first\n");
dms->state.started = 1;
dms->state.established = 0;
dms->state.eight_bits = eight_bits;
@@ -783,7 +784,7 @@ void dms_send(nmt_t *nmt, const uint8_t *data, int length, int eight_bits)
dms->state.rand_sent = 1;
}
PDEBUG(DDMS, DEBUG_DEBUG, "Queueing message data as DT frames...\n");
LOGP(DDMS, LOGL_DEBUG, "Queueing message data as DT frames...\n");
while (length) {
if (eight_bits) {
/* copy what we have */
@@ -837,7 +838,7 @@ void dms_send(nmt_t *nmt, const uint8_t *data, int length, int eight_bits)
void dms_reset(nmt_t *nmt)
{
dms_t *dms = &nmt->dms;
PDEBUG(DDMS, DEBUG_DEBUG, "Resetting DMS states\n");
LOGP(DDMS, LOGL_DEBUG, "Resetting DMS states\n");
dms->rx_in_sync = 0;
memset(&dms->state, 0, sizeof(dms->state));

View File

@@ -26,7 +26,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "nmt.h"
#include "transaction.h"
#include "dsp.h"
@@ -89,7 +89,7 @@ void dsp_init(void)
int i;
double s;
PDEBUG(DDSP, DEBUG_DEBUG, "Generating sine table for supervisory signal and dial tone.\n");
LOGP(DDSP, LOGL_DEBUG, "Generating sine table for supervisory signal and dial tone.\n");
for (i = 0; i < 65536; i++) {
s = sin((double)i / 65536.0 * 2.0 * PI);
/* supervisor sine */
@@ -113,21 +113,21 @@ int dsp_init_sender(nmt_t *nmt, double deviation_factor)
/* attack (3ms) and recovery time (13.5ms) according to NMT specs */
setup_compandor(&nmt->cstate, 8000, 3.0, 13.5);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for Transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Init DSP for Transceiver.\n");
/* set modulation parameters */
sender_set_fm(&nmt->sender, MAX_DEVIATION * deviation_factor, MAX_MODULATION * deviation_factor, SPEECH_DEVIATION * deviation_factor, MAX_DISPLAY);
PDEBUG(DDSP, DEBUG_DEBUG, "Using FSK level of %.3f (%.3f KHz deviation @ 1500 Hz)\n", TX_PEAK_FSK * deviation_factor, 3.5 * deviation_factor);
PDEBUG(DDSP, DEBUG_DEBUG, "Using Supervisory level of %.3f (%.3f KHz deviation @ 4015 Hz)\n", TX_PEAK_SUPER * deviation_factor, 0.3 * deviation_factor);
LOGP(DDSP, LOGL_DEBUG, "Using FSK level of %.3f (%.3f KHz deviation @ 1500 Hz)\n", TX_PEAK_FSK * deviation_factor, 3.5 * deviation_factor);
LOGP(DDSP, LOGL_DEBUG, "Using Supervisory level of %.3f (%.3f KHz deviation @ 4015 Hz)\n", TX_PEAK_SUPER * deviation_factor, 0.3 * deviation_factor);
/* init fsk */
if (fsk_mod_init(&nmt->fsk_mod, nmt, fsk_send_bit, nmt->sender.samplerate, BIT_RATE, F0, F1, TX_PEAK_FSK, 1, 0) < 0) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "FSK init failed!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "FSK init failed!\n");
return -EINVAL;
}
if (fsk_demod_init(&nmt->fsk_demod, nmt, fsk_receive_bit, nmt->sender.samplerate, BIT_RATE, F0, F1, BIT_ADJUST) < 0) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "FSK init failed!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "FSK init failed!\n");
return -EINVAL;
}
@@ -138,7 +138,7 @@ int dsp_init_sender(nmt_t *nmt, double deviation_factor)
nmt->super_samples = (int)((double)nmt->sender.samplerate * (1.0 / (SUPER_BANDWIDTH / 2)) + 0.5);
spl = calloc(1, nmt->super_samples * sizeof(*spl));
if (!spl) {
PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n");
LOGP(DDSP, LOGL_ERROR, "No memory!\n");
return -ENOMEM;
}
nmt->super_filter_spl = spl;
@@ -170,7 +170,7 @@ int dsp_init_sender(nmt_t *nmt, double deviation_factor)
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(nmt_t *nmt)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for Transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for Transceiver.\n");
fsk_mod_cleanup(&nmt->fsk_mod);
fsk_demod_cleanup(&nmt->fsk_demod);
@@ -283,7 +283,7 @@ static void super_decode(nmt_t *nmt, sample_t *samples, int length)
if (nmt->state == STATE_ACTIVE) {
if (++nmt->super_print == SUPER_PRINT) {
nmt->super_print = 0;
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "Supervisory level %.0f%% quality %.0f%%\n", level * 100.0, quality * 100.0);
LOGP_CHAN(DDSP, LOGL_NOTICE, "Supervisory level %.0f%% quality %.0f%%\n", level * 100.0, quality * 100.0);
}
/* update measurements (if dmp_* params are NULL, we omit this) */
display_measurements_update(nmt->dmp_super_level, level * 100.0, 0.0);
@@ -296,7 +296,7 @@ static void super_decode(nmt_t *nmt, sample_t *samples, int length)
if (nmt->super_detect_count == SUPER_DETECT_COUNT) {
nmt->super_detected = 1;
nmt->super_detect_count = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Supervisory signal detected with level=%.0f%%, quality=%.0f%%.\n", result[0] / 0.63662 / TX_PEAK_SUPER * 100.0, quality * 100.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Supervisory signal detected with level=%.0f%%, quality=%.0f%%.\n", result[0] / 0.63662 / TX_PEAK_SUPER * 100.0, quality * 100.0);
nmt_rx_super(nmt, 1, quality);
}
} else
@@ -307,7 +307,7 @@ static void super_decode(nmt_t *nmt, sample_t *samples, int length)
if (nmt->super_detect_count == SUPER_LOST_COUNT) {
nmt->super_detected = 0;
nmt->super_detect_count = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Supervisory signal lost.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Supervisory signal lost.\n");
nmt_rx_super(nmt, 0, 0.0);
}
} else
@@ -318,7 +318,7 @@ static void super_decode(nmt_t *nmt, sample_t *samples, int length)
/* Reset supervisory detection states, so ongoing tone will be detected again. */
void super_reset(nmt_t *nmt)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Supervisory detector reset.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Supervisory detector reset.\n");
nmt->super_detected = 0;
nmt->super_detect_count = 0;
}
@@ -395,7 +395,7 @@ static int fsk_send_bit(void *inst)
frame = nmt_get_frame(nmt);
if (!frame) {
nmt->tx_frame_length = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Stop sending frames.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Stop sending frames.\n");
return -1;
}
memcpy(nmt->tx_frame, frame, 166);
@@ -521,7 +521,7 @@ void nmt_set_dsp_mode(nmt_t *nmt, enum dsp_mode mode)
nmt->tx_frame_length = 0;
}
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %s -> %s\n", nmt_dsp_mode_name(nmt->dsp_mode), nmt_dsp_mode_name(mode));
LOGP_CHAN(DDSP, LOGL_DEBUG, "DSP mode %s -> %s\n", nmt_dsp_mode_name(nmt->dsp_mode), nmt_dsp_mode_name(mode));
nmt->dsp_mode = mode;
}

View File

@@ -23,7 +23,7 @@
#include <string.h>
#include <inttypes.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libhagelbarger/hagelbarger.h"
#include "nmt.h"
#include "frame.h"
@@ -854,7 +854,7 @@ int init_frame(void)
for (i = 0; nmt_frame[i].digits; i++) {
/* check message type */
if ((int)nmt_frame[i].message_type != i) {
PDEBUG(DFRAME, DEBUG_ERROR, "Message type at message index #%d does not have a value of %d, but has %d, please fix!\n", i, i + 1, nmt_frame[i].message_type);
LOGP(DFRAME, LOGL_ERROR, "Message type at message index #%d does not have a value of %d, but has %d, please fix!\n", i, i + 1, nmt_frame[i].message_type);
return -1;
}
/* check IEs */
@@ -867,7 +867,7 @@ int init_frame(void)
break;
}
if (!nmt_parameter[k].digit) {
PDEBUG(DFRAME, DEBUG_ERROR, "Digit '%c' in message index %d does not exist, please fix!\n", digit, i);
LOGP(DFRAME, LOGL_ERROR, "Digit '%c' in message index %d does not exist, please fix!\n", digit, i);
return -1;
}
}
@@ -894,7 +894,7 @@ static void disassemble_frame(int nmt_system, frame_t *frame, const uint8_t *dig
/* update direction */
direction = nmt_frame[mt].direction;
PDEBUG(DFRAME, DEBUG_DEBUG, "Decoding %s %s %s\n", nmt_dir_name(direction), nmt_frame[mt].nr, nmt_frame[mt].description);
LOGP(DFRAME, LOGL_DEBUG, "Decoding %s %s %s\n", nmt_dir_name(direction), nmt_frame[mt].nr, nmt_frame[mt].description);
for (i = 0; i < 16; i++) {
digit = nmt_frame[mt].digits[i];
@@ -983,28 +983,28 @@ static void disassemble_frame(int nmt_system, frame_t *frame, const uint8_t *dig
frame->waiting_info = value;
break;
default:
PDEBUG(DFRAME, DEBUG_ERROR, "Digit '%c' does not exist, please fix!\n", digit);
LOGP(DFRAME, LOGL_ERROR, "Digit '%c' does not exist, please fix!\n", digit);
abort();
}
if (debuglevel <= DEBUG_DEBUG) {
if (loglevel <= LOGL_DEBUG) {
for (j = 0; nmt_parameter[j].digit; j++) {
if (nmt_parameter[j].system != 0 && nmt_parameter[j].system != nmt_system)
continue;
if (nmt_parameter[j].digit == digit) {
PDEBUG(DFRAME, DEBUG_DEBUG, " %c: %s\n", digit, nmt_parameter[j].decoder(value, ndigits, direction));
LOGP(DFRAME, LOGL_DEBUG, " %c: %s\n", digit, nmt_parameter[j].decoder(value, ndigits, direction));
}
}
}
}
if (debuglevel <= DEBUG_DEBUG) {
if (loglevel <= LOGL_DEBUG) {
char debug_digits[17];
for (i = 0; i < 16; i++)
debug_digits[i] = "0123456789abcdef"[digits[i]];
debug_digits[i] = '\0';
PDEBUG(DFRAME, DEBUG_DEBUG, "%s\n", nmt_frame[mt].digits);
PDEBUG(DFRAME, DEBUG_DEBUG, "%s\n", debug_digits);
LOGP(DFRAME, LOGL_DEBUG, "%s\n", nmt_frame[mt].digits);
LOGP(DFRAME, LOGL_DEBUG, "%s\n", debug_digits);
}
}
@@ -1020,7 +1020,7 @@ static void assemble_frame(int nmt_system, frame_t *frame, uint8_t *digits, int
mt = frame->mt;
if ((int)mt >= num_frames) {
PDEBUG(DFRAME, DEBUG_ERROR, "Frame mt %d out of range (0..%d), please fix!\n", mt, num_frames - 1);
LOGP(DFRAME, LOGL_ERROR, "Frame mt %d out of range (0..%d), please fix!\n", mt, num_frames - 1);
abort();
}
@@ -1031,7 +1031,7 @@ static void assemble_frame(int nmt_system, frame_t *frame, uint8_t *digits, int
direction = nmt_frame[mt].direction;
if (debug)
PDEBUG(DFRAME, DEBUG_DEBUG, "Coding %s %s %s\n", nmt_dir_name(direction), nmt_frame[mt].nr, nmt_frame[mt].description);
LOGP(DFRAME, LOGL_DEBUG, "Coding %s %s %s\n", nmt_dir_name(direction), nmt_frame[mt].nr, nmt_frame[mt].description);
for (i = 15; i >= 0; i--) {
digit = nmt_frame[mt].digits[i];
@@ -1113,7 +1113,7 @@ static void assemble_frame(int nmt_system, frame_t *frame, uint8_t *digits, int
value = frame->waiting_info;
break;
default:
PDEBUG(DFRAME, DEBUG_ERROR, "Digit '%c' does not exist, please fix!\n", digit);
LOGP(DFRAME, LOGL_ERROR, "Digit '%c' does not exist, please fix!\n", digit);
abort();
}
@@ -1127,7 +1127,7 @@ static void assemble_frame(int nmt_system, frame_t *frame, uint8_t *digits, int
i--;
}
}
if (debug && debuglevel <= DEBUG_DEBUG) {
if (debug && loglevel <= LOGL_DEBUG) {
char debug_digits[17];
int ndigits;
@@ -1148,7 +1148,7 @@ static void assemble_frame(int nmt_system, frame_t *frame, uint8_t *digits, int
if (nmt_parameter[j].system != 0 && nmt_parameter[j].system != nmt_system)
continue;
if (nmt_parameter[j].digit == digit) {
PDEBUG(DFRAME, DEBUG_DEBUG, " %c: %s\n", digit, nmt_parameter[j].decoder(value, ndigits, direction));
LOGP(DFRAME, LOGL_DEBUG, " %c: %s\n", digit, nmt_parameter[j].decoder(value, ndigits, direction));
}
}
}
@@ -1156,8 +1156,8 @@ static void assemble_frame(int nmt_system, frame_t *frame, uint8_t *digits, int
for (i = 0; i < 16; i++)
debug_digits[i] = "0123456789abcdef"[digits[i]];
debug_digits[i] = '\0';
PDEBUG(DFRAME, DEBUG_DEBUG, "%s\n", nmt_frame[mt].digits);
PDEBUG(DFRAME, DEBUG_DEBUG, "%s\n", debug_digits);
LOGP(DFRAME, LOGL_DEBUG, "%s\n", nmt_frame[mt].digits);
LOGP(DFRAME, LOGL_DEBUG, "%s\n", debug_digits);
}
}

View File

@@ -28,7 +28,7 @@
#include <sys/stat.h>
#include "../libsample/sample.h"
#include "../libmobile/main_mobile.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../liboptions/options.h"
#include "nmt.h"
#include "frame.h"
@@ -432,6 +432,7 @@ fail:
nmt_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
options_free();

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
#include "../libmobile/sender.h"
#include "../libtimer/timer.h"
#include <osmocom/core/timer.h>
#include "../libcompandor/compandor.h"
#include "../libdtmf/dtmf_encode.h"
#include "../libmobile/call.h"
@@ -85,7 +85,7 @@ struct nmt {
enum nmt_state state;
int wait_autoanswer; /* wait for frame 15 before we can send autoanswer */
enum nmt_active_state active_state;
struct timer timer;
struct osmo_timer_list timer;
int rx_frame_count; /* receive frame counter */
int tx_frame_count; /* transmit frame counter */
int tx_callerid_count; /* counter for caller ID repetition */
@@ -138,7 +138,7 @@ struct nmt {
dms_t dms; /* DMS states */
sms_t sms; /* SMS states */
char smsc_number[33]; /* digits to match SMSC */
struct timer sms_timer;
struct osmo_timer_list sms_timer;
};
void nmt_channel_list(int nmt_system);

View File

@@ -24,11 +24,11 @@
#include <time.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "nmt.h"
#define SMS_RECEIVE_TO 5.0
#define SMS_RELEASE_TO 2.0
#define SMS_RECEIVE_TO 5,0
#define SMS_RELEASE_TO 2,0
/* TP-Message-Type-Indicator (TP-MTI) */
#define MTI_SMS_DELIVER 0x00 /* SC -> MS */
@@ -99,7 +99,7 @@ static void sms_timeout(void *data);
/* init instance */
int sms_init_sender(nmt_t *nmt)
{
timer_init(&nmt->sms_timer, sms_timeout, nmt);
osmo_timer_setup(&nmt->sms_timer, sms_timeout, nmt);
return 0;
}
@@ -108,7 +108,7 @@ int sms_init_sender(nmt_t *nmt)
void sms_cleanup_sender(nmt_t *nmt)
{
sms_reset(nmt);
timer_exit(&nmt->sms_timer);
osmo_timer_del(&nmt->sms_timer);
}
/*
@@ -130,7 +130,7 @@ static int encode_address(uint8_t *data, const char *address, uint8_t type, uint
uint8_t digit;
int i, j;
PDEBUG(DSMS, DEBUG_DEBUG, "Encode SC->MS header\n");
LOGP(DSMS, LOGL_DEBUG, "Encode SC->MS header\n");
data[length++] = 0x80 | (type << 4) | plan;
j = 0;
@@ -170,7 +170,7 @@ static int encode_time(uint8_t *data, time_t timestamp, int local)
uint8_t digit1, digit2;
int quarters, sign;
PDEBUG(DSMS, DEBUG_DEBUG, "Encode time stamp '%02d.%02d.%02d %02d:%02d:%02d'\n", tm->tm_mday, tm->tm_mon + 1, tm->tm_year % 100, tm->tm_hour, tm->tm_min, tm->tm_sec);
LOGP(DSMS, LOGL_DEBUG, "Encode time stamp '%02d.%02d.%02d %02d:%02d:%02d'\n", tm->tm_mday, tm->tm_mon + 1, tm->tm_year % 100, tm->tm_hour, tm->tm_min, tm->tm_sec);
/* year */
digit1 = (tm->tm_year % 100) / 10;
@@ -247,7 +247,7 @@ static int encode_userdata(uint8_t *data, const char *message)
uint8_t character;
int i, j, pos;
PDEBUG(DSMS, DEBUG_DEBUG, "Encode user data '%s'\n", message);
LOGP(DSMS, LOGL_DEBUG, "Encode user data '%s'\n", message);
j = 0;
pos = 0;
@@ -293,17 +293,17 @@ int sms_deliver(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_
int orig_len;
int msg_len;
PDEBUG(DSMS, DEBUG_INFO, "Delivering SMS from upper layer\n");
LOGP(DSMS, LOGL_INFO, "Delivering SMS from upper layer\n");
orig_len = strlen(orig_address);
msg_len = strlen(message);
if (orig_len > 24) {
PDEBUG(DSMS, DEBUG_NOTICE, "Originator Address too long (%d characters)\n", orig_len);
LOGP(DSMS, LOGL_NOTICE, "Originator Address too long (%d characters)\n", orig_len);
return -EINVAL;
}
if (msg_len > 140) {
PDEBUG(DSMS, DEBUG_NOTICE, "Message too long (%d characters)\n", msg_len);
LOGP(DSMS, LOGL_NOTICE, "Message too long (%d characters)\n", msg_len);
return -EINVAL;
}
@@ -326,13 +326,13 @@ int sms_deliver(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_
/* RP length */
*tpdu_length = length - (uint8_t)(tpdu_length - data) - 1;
PDEBUG(DSMS, DEBUG_DEBUG, " -> TPDU length = %d\n", *tpdu_length);
LOGP(DSMS, LOGL_DEBUG, " -> TPDU length = %d\n", *tpdu_length);
nmt->sms.mt = 1;
dms_send(nmt, data, length, 1);
/* start timer */
timer_start(&nmt->sms_timer, SMS_RECEIVE_TO);
osmo_timer_schedule(&nmt->sms_timer, SMS_RECEIVE_TO);
return 0;
}
@@ -343,7 +343,7 @@ static void sms_submit_report(nmt_t *nmt, uint8_t ref, int error)
uint8_t data[64];
int length = 0;
PDEBUG(DSMS, DEBUG_INFO, "Sending Submit Report (%s)\n", (error) ? "error" : "ok");
LOGP(DSMS, LOGL_INFO, "Sending Submit Report (%s)\n", (error) ? "error" : "ok");
/* HEADER */
length = encode_header(data);
@@ -417,7 +417,7 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* do we have originator address length ? */
if (length < 2) {
PDEBUG(DSMS, DEBUG_DEBUG, "SMS still incomplete, waiting for originator address\n");
LOGP(DSMS, LOGL_DEBUG, "SMS still incomplete, waiting for originator address\n");
return 0;
}
orig_data = 2 + data;
@@ -426,7 +426,7 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
orig_plan = data[1] & 0x0f;
orig_len = (orig_digits + 1) >> 1;
if (length < 2 + orig_len) {
PDEBUG(DSMS, DEBUG_DEBUG, "SMS still incomplete, waiting for originator address digits (got %d of %d)\n", length - 1, orig_len);
LOGP(DSMS, LOGL_DEBUG, "SMS still incomplete, waiting for originator address digits (got %d of %d)\n", length - 1, orig_len);
return 0;
}
data += 2 + orig_len;
@@ -434,17 +434,17 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* do we have user data IE ? */
if (length < 2) {
PDEBUG(DSMS, DEBUG_DEBUG, "SMS still incomplete, waiting for user data IE\n");
LOGP(DSMS, LOGL_DEBUG, "SMS still incomplete, waiting for user data IE\n");
return 0;
}
if (data[0] != RP_IE_USER_DATA) {
PDEBUG(DSMS, DEBUG_NOTICE, "missing user data IE\n");
LOGP(DSMS, LOGL_NOTICE, "missing user data IE\n");
return -FSC_ERROR_IN_MS;
}
tpdu_len = data[1];
tpdu_data = 2 + data;
if (length < 2 + tpdu_len) {
PDEBUG(DSMS, DEBUG_DEBUG, "SMS still incomplete, waiting for TPDU to be complete\n");
LOGP(DSMS, LOGL_DEBUG, "SMS still incomplete, waiting for TPDU to be complete\n");
return 0;
}
data += 2 + tpdu_len;
@@ -453,7 +453,7 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* decode orig address */
char orig_address[orig_digits + 1];
decode_address(orig_data, orig_digits, orig_address);
PDEBUG(DSMS, DEBUG_DEBUG, "Decoded originating address: '%s'\n", orig_address);
LOGP(DSMS, LOGL_DEBUG, "Decoded originating address: '%s'\n", orig_address);
/* go into TP */
data = tpdu_data;
@@ -461,11 +461,11 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* check msg_type */
if (length < 1) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read user data IE\n");
LOGP(DSMS, LOGL_NOTICE, "short read user data IE\n");
return -FSC_ERROR_IN_MS;
}
if ((data[0] & MTI_MASK) != MTI_SMS_SUBMIT) {
PDEBUG(DSMS, DEBUG_NOTICE, "especting SUBMIT MTI, but got 0x%02x\n", data[0]);
LOGP(DSMS, LOGL_NOTICE, "especting SUBMIT MTI, but got 0x%02x\n", data[0]);
return -FSC_ERROR_IN_MS;
}
if ((data[0] & VPF_MASK))
@@ -475,7 +475,7 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* decode msg ref */
if (length < 1) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read user data IE\n");
LOGP(DSMS, LOGL_NOTICE, "short read user data IE\n");
return -FSC_ERROR_IN_MS;
}
msg_ref = data[0];
@@ -484,7 +484,7 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* decode dest address */
if (length < 2) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read user data IE\n");
LOGP(DSMS, LOGL_NOTICE, "short read user data IE\n");
return -FSC_ERROR_IN_MS;
}
dest_data = 2 + data;
@@ -493,18 +493,18 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
dest_plan = data[1] & 0x0f;
dest_len = (dest_digits + 1) >> 1;
if (length < 2 + dest_len) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read user data IE\n");
LOGP(DSMS, LOGL_NOTICE, "short read user data IE\n");
return -FSC_ERROR_IN_MS;
}
data += 2 + dest_len;
length -= 2 + dest_len;
char dest_address[dest_digits + 1];
decode_address(dest_data, dest_digits, dest_address);
PDEBUG(DSMS, DEBUG_DEBUG, "Decoded destination address: '%s'\n", dest_address);
LOGP(DSMS, LOGL_DEBUG, "Decoded destination address: '%s'\n", dest_address);
/* skip above protocol identifier */
if (length < 1) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read above protocol identifier IE\n");
LOGP(DSMS, LOGL_NOTICE, "short read above protocol identifier IE\n");
return -FSC_ERROR_IN_MS;
}
data++;
@@ -512,17 +512,17 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* decode data coding scheme */
if (length < 1) {
PDEBUG(DSMS, DEBUG_NOTICE, "short data coding scheme IE\n");
LOGP(DSMS, LOGL_NOTICE, "short data coding scheme IE\n");
return -FSC_ERROR_IN_MS;
}
if (data[0] == 0x00) {
PDEBUG(DSMS, DEBUG_DEBUG, "SMS coding is 7 bits (got 0x%02x)\n", data[0]);
LOGP(DSMS, LOGL_DEBUG, "SMS coding is 7 bits (got 0x%02x)\n", data[0]);
coding = 7;
} else if ((data[0] & 0xf0) == 0x30) {
PDEBUG(DSMS, DEBUG_DEBUG, "SMS coding is 8 bits (got 0x%02x)\n", data[0]);
LOGP(DSMS, LOGL_DEBUG, "SMS coding is 8 bits (got 0x%02x)\n", data[0]);
coding = 8;
} else {
PDEBUG(DSMS, DEBUG_NOTICE, "SMS coding unsupported (got 0x%02x)\n", data[0]);
LOGP(DSMS, LOGL_NOTICE, "SMS coding unsupported (got 0x%02x)\n", data[0]);
return -FSC_ERROR_IN_MS;
}
data++;
@@ -531,7 +531,7 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* skip validity period */
if (tp_vpf_present) {
if (length < 1) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read validity period IE\n");
LOGP(DSMS, LOGL_NOTICE, "short read validity period IE\n");
return -FSC_ERROR_IN_MS;
}
data++;
@@ -540,7 +540,7 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
/* decode data message text */
if (length < 1) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read user data IE\n");
LOGP(DSMS, LOGL_NOTICE, "short read user data IE\n");
return -FSC_ERROR_IN_MS;
}
msg_data = data + 1;
@@ -550,20 +550,20 @@ static int decode_sms_submit(nmt_t *nmt, const uint8_t *data, int length)
else
msg_len = msg_chars;
if (length < 1 + msg_len) {
PDEBUG(DSMS, DEBUG_NOTICE, "short read user data IE\n");
LOGP(DSMS, LOGL_NOTICE, "short read user data IE\n");
return -FSC_ERROR_IN_MS;
}
char message[msg_chars + 1];
if (coding == 7) {
decode_message_7(msg_data, msg_len, message);
PDEBUG(DSMS, DEBUG_DEBUG, "Decoded message: '%s'\n", message);
LOGP(DSMS, LOGL_DEBUG, "Decoded message: '%s'\n", message);
} else {
memcpy(message, msg_data, msg_len);
message[msg_len] = '\0';
PDEBUG(DSMS, DEBUG_DEBUG, "Included message: '%s'\n", message);
LOGP(DSMS, LOGL_DEBUG, "Included message: '%s'\n", message);
}
PDEBUG(DSMS, DEBUG_INFO, "Submitting SMS to upper layer\n");
LOGP(DSMS, LOGL_INFO, "Submitting SMS to upper layer\n");
rc = sms_submit(nmt, ref, orig_address, orig_type, orig_plan, msg_ref, dest_address, dest_type, dest_plan, message);
if (rc < 0)
@@ -584,18 +584,18 @@ static int decode_deliver_report(nmt_t *nmt, const uint8_t *data, int length)
if ((data[0] & RP_MTI_MASK) == RP_MT_ERROR) {
error = 1;
if (length < 4) {
PDEBUG(DSMS, DEBUG_DEBUG, "deliver report still incomplete, waiting for cause IE\n");
LOGP(DSMS, LOGL_DEBUG, "deliver report still incomplete, waiting for cause IE\n");
return 0;
}
if (length < 4 + data[3]) {
PDEBUG(DSMS, DEBUG_DEBUG, "deliver report still incomplete, waiting for cause IE content\n");
LOGP(DSMS, LOGL_DEBUG, "deliver report still incomplete, waiting for cause IE content\n");
return 0;
}
if (data[2] == RP_IE_CAUSE && data[3] > 0)
cause = data[4];
PDEBUG(DSMS, DEBUG_INFO, "Received Delivery report: ERROR, cause=%d\n", cause);
LOGP(DSMS, LOGL_INFO, "Received Delivery report: ERROR, cause=%d\n", cause);
} else
PDEBUG(DSMS, DEBUG_INFO, "Received Delivery report: OK\n");
LOGP(DSMS, LOGL_INFO, "Received Delivery report: OK\n");
sms_deliver_report(nmt, ref, error, cause);
@@ -616,21 +616,21 @@ void dms_receive(nmt_t *nmt, const uint8_t *data, int length, int __attribute__(
debug_text[length * 5] = '\0';
/* restart timer */
timer_start(&nmt->sms_timer, SMS_RECEIVE_TO);
osmo_timer_schedule(&nmt->sms_timer, SMS_RECEIVE_TO);
PDEBUG(DSMS, DEBUG_DEBUG, "Received %d bytes from DMS layer:%s\n", length, debug_text);
LOGP(DSMS, LOGL_DEBUG, "Received %d bytes from DMS layer:%s\n", length, debug_text);
if (sms->mt && !sms->data_sent) {
PDEBUG(DSMS, DEBUG_NOTICE, "Ignoring data while we transmit data\n");
LOGP(DSMS, LOGL_NOTICE, "Ignoring data while we transmit data\n");
return;
}
/* append received data */
space = sizeof(sms->rx_buffer) - sms->rx_count;
if (space < length) {
PDEBUG(DSMS, DEBUG_NOTICE, "Received message exceeds RX buffer, terminating call!\n");
LOGP(DSMS, LOGL_NOTICE, "Received message exceeds RX buffer, terminating call!\n");
release:
timer_start(&nmt->sms_timer, SMS_RELEASE_TO);
osmo_timer_schedule(&nmt->sms_timer, SMS_RELEASE_TO);
return;
}
memcpy(sms->rx_buffer + sms->rx_count, data, length);
@@ -661,12 +661,12 @@ release:
rc = 0;
break;
case RP_SM_READY_TO_RECEIVE:
PDEBUG(DSMS, DEBUG_NOTICE, "Received READY-TO-RECEVIE message.\n");
LOGP(DSMS, LOGL_NOTICE, "Received READY-TO-RECEVIE message.\n");
data += length;
length -= length;
break;
default:
PDEBUG(DSMS, DEBUG_NOTICE, "Received unknown RP message type %d.\n", data[0]);
LOGP(DSMS, LOGL_NOTICE, "Received unknown RP message type %d.\n", data[0]);
rc = -1;
}
if (rc)
@@ -689,11 +689,11 @@ void dms_all_sent(nmt_t *nmt)
if (!sms->data_sent) {
if (!sms->mt) {
PDEBUG(DSMS, DEBUG_DEBUG, "Done sending submit report, releasing.\n");
timer_start(&nmt->sms_timer, SMS_RELEASE_TO);
LOGP(DSMS, LOGL_DEBUG, "Done sending submit report, releasing.\n");
osmo_timer_schedule(&nmt->sms_timer, SMS_RELEASE_TO);
}
sms->data_sent = 1;
PDEBUG(DSMS, DEBUG_DEBUG, "DMS layer indicates acknowledge of sent data\n");
LOGP(DSMS, LOGL_DEBUG, "DMS layer indicates acknowledge of sent data\n");
}
}
@@ -701,9 +701,8 @@ void sms_reset(nmt_t *nmt)
{
sms_t *sms = &nmt->sms;
PDEBUG(DSMS, DEBUG_DEBUG, "Resetting SMS states\n");
if (nmt->sms_timer.linked)
timer_stop(&nmt->sms_timer);
LOGP(DSMS, LOGL_DEBUG, "Resetting SMS states\n");
osmo_timer_del(&nmt->sms_timer);
memset(sms, 0, sizeof(*sms));
}

View File

@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "nmt.h"
#include "transaction.h"
@@ -35,7 +35,7 @@ static void link_transaction(transaction_t *trans)
transaction_t **transp;
/* attach to end of list, so first transaction is served first */
PDEBUG(DTRANS, DEBUG_DEBUG, "Linking transaction %p to list\n", trans);
LOGP(DTRANS, LOGL_DEBUG, "Linking transaction %p to list\n", trans);
trans->next = NULL;
transp = &trans_list;
while (*transp)
@@ -51,12 +51,12 @@ static void unlink_transaction(transaction_t *trans)
nmt_t *nmt;
/* unlink */
PDEBUG(DTRANS, DEBUG_DEBUG, "Unlinking transaction %p from list\n", trans);
LOGP(DTRANS, LOGL_DEBUG, "Unlinking transaction %p from list\n", trans);
transp = &trans_list;
while (*transp && *transp != trans)
transp = &((*transp)->next);
if (!(*transp)) {
PDEBUG(DTRANS, DEBUG_ERROR, "Transaction not in list, please fix!!\n");
LOGP(DTRANS, LOGL_ERROR, "Transaction not in list, please fix!!\n");
abort();
}
*transp = trans->next;
@@ -78,15 +78,15 @@ transaction_t *create_transaction(struct nmt_subscriber *subscr)
trans = calloc(1, sizeof(*trans));
if (!trans) {
PDEBUG(DTRANS, DEBUG_ERROR, "No memory!\n");
LOGP(DTRANS, LOGL_ERROR, "No memory!\n");
return NULL;
}
timer_init(&trans->timer, transaction_timeout, trans);
osmo_timer_setup(&trans->timer, transaction_timeout, trans);
memcpy(&trans->subscriber, subscr, sizeof(struct nmt_subscriber));
PDEBUG(DTRANS, DEBUG_INFO, "Created transaction for subscriber '%c,%s'\n", subscr->country, subscr->number);
LOGP(DTRANS, LOGL_INFO, "Created transaction for subscriber '%c,%s'\n", subscr->country, subscr->number);
link_transaction(trans);
@@ -98,9 +98,9 @@ void destroy_transaction(transaction_t *trans)
{
unlink_transaction(trans);
PDEBUG(DTRANS, DEBUG_INFO, "Destroying transaction for subscriber '%c,%s'\n", trans->subscriber.country, trans->subscriber.number);
LOGP(DTRANS, LOGL_INFO, "Destroying transaction for subscriber '%c,%s'\n", trans->subscriber.country, trans->subscriber.number);
timer_exit(&trans->timer);
osmo_timer_del(&trans->timer);
free(trans);
}

View File

@@ -14,7 +14,7 @@ typedef struct transaction {
nmt_t *nmt; /* pointer to nmt instance, if bound to a channel */
int callref; /* callref for transaction */
struct nmt_subscriber subscriber;
struct timer timer;
struct osmo_timer_list timer;
int page_try; /* number of paging try */
/* caller ID */