diff options
Diffstat (limited to 'src/amps')
-rw-r--r-- | src/amps/Makefile.am | 26 | ||||
-rw-r--r-- | src/amps/amps.c | 272 | ||||
-rw-r--r-- | src/amps/amps.h | 5 | ||||
-rw-r--r-- | src/amps/dsp.c | 92 | ||||
-rw-r--r-- | src/amps/esn.c | 153 | ||||
-rw-r--r-- | src/amps/esn.h | 3 | ||||
-rw-r--r-- | src/amps/frame.c | 79 | ||||
-rw-r--r-- | src/amps/jtacs_tones.c | 1 | ||||
-rw-r--r-- | src/amps/main_common.c | 16 | ||||
-rw-r--r-- | src/amps/sysinfo.c | 1 | ||||
-rw-r--r-- | src/amps/tacs_outoforder.c | 1 | ||||
-rw-r--r-- | src/amps/tacs_tones.c | 1 | ||||
-rw-r--r-- | src/amps/transaction.c | 30 | ||||
-rw-r--r-- | src/amps/transaction.h | 4 | ||||
-rw-r--r-- | src/amps/usa_congestion.c | 1 | ||||
-rw-r--r-- | src/amps/usa_invalidnumber.c | 1 | ||||
-rw-r--r-- | src/amps/usa_noanswer.c | 1 | ||||
-rw-r--r-- | src/amps/usa_outoforder.c | 1 | ||||
-rw-r--r-- | src/amps/usa_tones.c | 1 |
19 files changed, 441 insertions, 248 deletions
diff --git a/src/amps/Makefile.am b/src/amps/Makefile.am index 2887466..a3686b0 100644 --- a/src/amps/Makefile.am +++ b/src/amps/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -Wmissing-prototypes -g $(all_includes) bin_PROGRAMS = \ amps tacs jtacs @@ -11,7 +11,8 @@ libamps_a_SOURCES = \ transaction.c \ frame.c \ dsp.c \ - sysinfo.c + sysinfo.c \ + esn.c libusatone_a_SOURCES = \ usa_tones.c \ @@ -30,22 +31,21 @@ amps_LDADD = \ libamps.a \ libusatone.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/libtimer/libtimer.a \ $(top_builddir)/src/libsamplerate/libsamplerate.a \ $(top_builddir)/src/libemphasis/libemphasis.a \ $(top_builddir)/src/libfm/libfm.a \ $(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 @@ -74,22 +74,21 @@ tacs_LDADD = \ $(COMMON_LA) \ libamps.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/libtimer/libtimer.a \ $(top_builddir)/src/libsamplerate/libsamplerate.a \ $(top_builddir)/src/libemphasis/libemphasis.a \ $(top_builddir)/src/libfm/libfm.a \ $(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 @@ -117,22 +116,21 @@ jtacs_LDADD = \ $(COMMON_LA) \ libamps.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/libtimer/libtimer.a \ $(top_builddir)/src/libsamplerate/libsamplerate.a \ $(top_builddir)/src/libemphasis/libemphasis.a \ $(top_builddir)/src/libfm/libfm.a \ $(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 diff --git a/src/amps/amps.c b/src/amps/amps.c index 747b470..ad2881d 100644 --- a/src/amps/amps.c +++ b/src/amps/amps.c @@ -43,28 +43,30 @@ #include <string.h> #include <errno.h> #include "../libsample/sample.h" -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" #include "../libmobile/call.h" #include "../libmobile/cause.h" -#include "../libosmocc/message.h" +#include "../libmobile/console.h" +#include <osmocom/cc/message.h> #include "amps.h" #include "dsp.h" #include "frame.h" #include "stations.h" +#include "esn.h" #include "main.h" /* Uncomment this to test SAT via loopback */ //#define DEBUG_VC -#define SAT_TO1 5.0 /* 5 sec to detect after setup */ -#define SAT_TO2 5.0 /* 5 sec lost until abort (specs say 5) */ -#define PAGE_TRIES 2 /* how many times to page the phone */ -#define PAGE_TO1 8.0 /* max time to wait for paging reply */ -#define PAGE_TO2 4.0 /* max time to wait for last paging reply */ -#define ALERT_TRIES 3 /* how many times to alert the phone */ -#define ALERT_TO 0.6 /* max time to wait for alert confirm */ -#define ANSWER_TO 60.0 /* max time to wait for answer */ -#define RELEASE_TIMER 5.0 /* max time to send release messages */ +#define SAT_TO1 5,0 /* 5 sec to detect after setup */ +#define SAT_TO2 5,0 /* 5 sec lost until abort (specs say 5) */ +#define PAGE_TRIES 2 /* how many times to page the phone */ +#define PAGE_TO1 8,0 /* max time to wait for paging reply */ +#define PAGE_TO2 4,0 /* max time to wait for last paging reply */ +#define ALERT_TRIES 3 /* how many times to alert the phone */ +#define ALERT_TO 0,600000 /* max time to wait for alert confirm */ +#define ANSWER_TO 60,0 /* max time to wait for answer */ +#define RELEASE_TIMER 5,0 /* max time to send release messages */ /* Convert channel number to frequency number of base station. Set 'uplink' to 1 to get frequency of mobile station. */ @@ -340,7 +342,7 @@ const char *amps_scm(uint8_t scm) return text; } -const char *amps_mpci(uint8_t mpci) +static const char *amps_mpci(uint8_t mpci) { switch (mpci) { case 0: @@ -357,7 +359,7 @@ const char *amps_mpci(uint8_t mpci) } -const char *amps_state_name(enum amps_state state) +static const char *amps_state_name(enum amps_state state) { static char invalid[16]; @@ -394,7 +396,7 @@ static void amps_new_state(amps_t *amps, enum amps_state new_state) { if (amps->state == new_state) return; - PDEBUG_CHAN(DAMPS, DEBUG_DEBUG, "State change: %s -> %s\n", amps_state_name(amps->state), amps_state_name(new_state)); + LOGP_CHAN(DAMPS, LOGL_DEBUG, "State change: %s -> %s\n", amps_state_name(amps->state), amps_state_name(new_state)); amps->state = new_state; amps_display_status(); } @@ -428,7 +430,7 @@ int amps_channel_by_short_name(const char *short_name) for (i = 0; amps_channels[i].short_name; i++) { if (!strcasecmp(amps_channels[i].short_name, short_name)) { - PDEBUG(DAMPS, DEBUG_INFO, "Selecting channel '%s' = %s\n", amps_channels[i].short_name, amps_channels[i].long_name); + LOGP(DAMPS, LOGL_INFO, "Selecting channel '%s' = %s\n", amps_channels[i].short_name, amps_channels[i].long_name); return amps_channels[i].chan_type; } } @@ -527,15 +529,15 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de /* check for channel number */ if (amps_channel2freq(atoi(kanal), 0) == 0) { - PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %s invalid.\n", kanal); + LOGP(DAMPS, LOGL_ERROR, "Channel number %s invalid.\n", kanal); if (jtacs) - PDEBUG(DAMPS, DEBUG_ERROR, "Try an even channel number, like 440.\n"); + LOGP(DAMPS, LOGL_ERROR, "Try an even channel number, like 440.\n"); return -EINVAL; } /* no paging channel (without control channel) support */ if (chan_type == CHAN_TYPE_PC) { - PDEBUG(DAMPS, DEBUG_ERROR, "Dedicated paging channel currently not supported. Please select CC/PC or CC/PC/VC instead.\n"); + LOGP(DAMPS, LOGL_ERROR, "Dedicated paging channel currently not supported. Please select CC/PC or CC/PC/VC instead.\n"); return -EINVAL; } @@ -544,7 +546,7 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de for (sender = sender_head; sender; sender = sender->next) { amps = (amps_t *)sender; if (amps->chan_type == CHAN_TYPE_PC || amps->chan_type == CHAN_TYPE_CC_PC || amps->chan_type == CHAN_TYPE_CC_PC_VC) { - PDEBUG(DAMPS, DEBUG_ERROR, "Only one paging channel is currently supported. Please check your channel types.\n"); + LOGP(DAMPS, LOGL_ERROR, "Only one paging channel is currently supported. Please check your channel types.\n"); return -EINVAL; } } @@ -553,51 +555,51 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de /* check if channel type matches channel number */ ct = amps_channel2type(atoi(kanal)); if (ct == CHAN_TYPE_CC && chan_type != CHAN_TYPE_PC && chan_type != CHAN_TYPE_CC_PC && chan_type != CHAN_TYPE_CC_PC_VC) { - PDEBUG(DAMPS, DEBUG_NOTICE, "Channel number %s belongs to a control channel, but your channel type '%s' requires to be on a voice channel number. Some phone may reject this, but all my phones don't.\n", kanal, chan_type_long_name(chan_type)); + LOGP(DAMPS, LOGL_NOTICE, "Channel number %s belongs to a control channel, but your channel type '%s' requires to be on a voice channel number. Some phone may reject this, but all my phones don't.\n", kanal, chan_type_long_name(chan_type)); } if (ct == CHAN_TYPE_VC && chan_type != CHAN_TYPE_VC) { - PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %s belongs to a voice channel, but your channel type '%s' requires to be on a control channel number. Please use correct channel.\n", kanal, chan_type_long_name(chan_type)); + LOGP(DAMPS, LOGL_ERROR, "Channel number %s belongs to a voice channel, but your channel type '%s' requires to be on a control channel number. Please use correct channel.\n", kanal, chan_type_long_name(chan_type)); return -EINVAL; } /* only even channels */ if (jtacs && chan_type != CHAN_TYPE_VC && (atoi(kanal) & 1)) { - PDEBUG(DAMPS, DEBUG_ERROR, "Control channel on JTACS system seem not to work with odd channel numbers. Please use even channel number.\n"); + LOGP(DAMPS, LOGL_ERROR, "Control channel on JTACS system seem not to work with odd channel numbers. Please use even channel number.\n"); return -EINVAL; } /* check if sid machtes channel band */ band = amps_channel2band(atoi(kanal)); if (band[0] == 'A' && (sid & 1) == 0 && chan_type != CHAN_TYPE_VC) { - PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %s belongs to system A, but your %s %d is even and belongs to system B. Please give odd %s.\n", kanal, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID"); + LOGP(DAMPS, LOGL_ERROR, "Channel number %s belongs to system A, but your %s %d is even and belongs to system B. Please give odd %s.\n", kanal, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID"); return -EINVAL; } if (band[0] == 'B' && (sid & 1) == 1 && chan_type != CHAN_TYPE_VC) { - PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %s belongs to system B, but your %s %d is odd and belongs to system A. Please give even %s.\n", kanal, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID"); + LOGP(DAMPS, LOGL_ERROR, "Channel number %s belongs to system B, but your %s %d is odd and belongs to system A. Please give even %s.\n", kanal, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID"); return -EINVAL; } /* check if we use combined voice channel hack */ if (chan_type == CHAN_TYPE_CC_PC_VC) { - PDEBUG(DAMPS, DEBUG_NOTICE, "You selected '%s'. This is a hack, but the only way to use control channel and voice channel on one transceiver. Some phones may reject this, but all my phones don't.\n", chan_type_long_name(chan_type)); + LOGP(DAMPS, LOGL_NOTICE, "You selected '%s'. This is a hack, but the only way to use control channel and voice channel on one transceiver. Some phones may reject this, but all my phones don't.\n", chan_type_long_name(chan_type)); } /* check if we selected a voice channel that i outside 20 MHz band */ if (chan_type == CHAN_TYPE_VC && atoi(kanal) > 666) { - PDEBUG(DAMPS, DEBUG_NOTICE, "You selected '%s' on channel #%s. Older phones do not support channels above #666.\n", chan_type_long_name(chan_type), kanal); + LOGP(DAMPS, LOGL_NOTICE, "You selected '%s' on channel #%s. Older phones do not support channels above #666.\n", chan_type_long_name(chan_type), kanal); } amps = calloc(1, sizeof(amps_t)); if (!amps) { - PDEBUG(DAMPS, DEBUG_ERROR, "No memory!\n"); + LOGP(DAMPS, LOGL_ERROR, "No memory!\n"); return -ENOMEM; } - PDEBUG(DAMPS, DEBUG_DEBUG, "Creating 'AMPS' instance for channel = %s of band %s (sample rate %d).\n", kanal, band, samplerate); + LOGP(DAMPS, LOGL_DEBUG, "Creating 'AMPS' instance for channel = %s of band %s (sample rate %d).\n", kanal, band, samplerate); /* init general part of transceiver */ rc = sender_create(&s->sender, kanal, amps_channel2freq(atoi(kanal), 0), amps_channel2freq(atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); if (rc < 0) { - PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n"); + LOGP(DAMPS, LOGL_ERROR, "Failed to init transceiver process!\n"); goto error; } @@ -618,7 +620,7 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de /* init audio processing */ rc = dsp_init_sender(amps, tolerant); if (rc < 0) { - PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init audio processing!\n"); + LOGP(DAMPS, LOGL_ERROR, "Failed to init audio processing!\n"); goto error; } @@ -633,7 +635,7 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de // amps_new_state(amps, STATE_BUSY); #endif - PDEBUG(DAMPS, DEBUG_NOTICE, "Created channel #%s (System %s) of type '%s' = %s\n", kanal, band, chan_type_short_name(chan_type), chan_type_long_name(chan_type)); + LOGP(DAMPS, LOGL_NOTICE, "Created channel #%s (System %s) of type '%s' = %s\n", kanal, band, chan_type_short_name(chan_type), chan_type_long_name(chan_type)); return 0; @@ -649,11 +651,11 @@ void amps_destroy(sender_t *sender) amps_t *amps = (amps_t *) sender; transaction_t *trans; - PDEBUG(DAMPS, DEBUG_DEBUG, "Destroying 'AMPS' instance for channel = %s.\n", sender->kanal); + LOGP(DAMPS, LOGL_DEBUG, "Destroying 'AMPS' instance for channel = %s.\n", sender->kanal); while ((trans = amps->trans_list)) { const char *number = amps_min2number(trans->min1, trans->min2); - PDEBUG(DAMPS, DEBUG_NOTICE, "Removing pending transaction for subscriber '%s'\n", number); + LOGP(DAMPS, LOGL_NOTICE, "Removing pending transaction for subscriber '%s'\n", number); destroy_transaction(trans); } @@ -671,7 +673,7 @@ void amps_go_idle(amps_t *amps) return; if (amps->trans_list) { - PDEBUG(DAMPS, DEBUG_ERROR, "Releasing but still having transaction, please fix!\n"); + LOGP(DAMPS, LOGL_ERROR, "Releasing but still having transaction, please fix!\n"); if (amps->trans_list->callref) call_up_release(amps->trans_list->callref, CAUSE_NORMAL); destroy_transaction(amps->trans_list); @@ -680,14 +682,14 @@ void amps_go_idle(amps_t *amps) amps_new_state(amps, STATE_IDLE); if (amps->chan_type != CHAN_TYPE_VC) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Entering IDLE state, sending Overhead/Filler frames on %s.\n", chan_type_long_name(amps->chan_type)); + LOGP_CHAN(DAMPS, LOGL_INFO, "Entering IDLE state, sending Overhead/Filler frames on %s.\n", chan_type_long_name(amps->chan_type)); if (amps->sender.loopback) frame_length = 441; /* bits after sync (FOCC) */ else frame_length = 247; /* bits after sync (RECC) */ amps_set_dsp_mode(amps, DSP_MODE_FRAME_RX_FRAME_TX, frame_length); } else { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Entering IDLE state (sending silence / no RF) on %s.\n", chan_type_long_name(amps->chan_type)); + LOGP_CHAN(DAMPS, LOGL_INFO, "Entering IDLE state (sending silence / no RF) on %s.\n", chan_type_long_name(amps->chan_type)); amps_set_dsp_mode(amps, DSP_MODE_OFF, 0); } } @@ -697,8 +699,8 @@ static void amps_release(transaction_t *trans, uint8_t cause) { amps_t *amps = trans->amps; - timer_stop(&trans->timer); - timer_start(&trans->timer, RELEASE_TIMER); + osmo_timer_del(&trans->timer); + osmo_timer_schedule(&trans->timer, RELEASE_TIMER); trans_new_state(trans, TRANS_CALL_RELEASE); trans->chan = 0; trans->msg_type = 0; @@ -721,14 +723,14 @@ void amps_rx_signaling_tone(amps_t *amps, int tone, double quality) { transaction_t *trans = amps->trans_list; if (trans == NULL) { - PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Signaling Tone without transaction, please fix!\n"); + LOGP_CHAN(DAMPS, LOGL_ERROR, "Signaling Tone without transaction, please fix!\n"); return; } if (tone) - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Detected Signaling Tone with quality=%.0f.\n", quality * 100.0); + LOGP_CHAN(DAMPS, LOGL_INFO, "Detected Signaling Tone with quality=%.0f.\n", quality * 100.0); else - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Lost Signaling Tone signal\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Lost Signaling Tone signal\n"); switch (trans->state) { case TRANS_CALL_MO_ASSIGN_CONFIRM: // should not happen @@ -739,7 +741,7 @@ void amps_rx_signaling_tone(amps_t *amps, int tone, double quality) case TRANS_CALL_RELEASE: case TRANS_CALL_RELEASE_SEND: /* also loosing singaling tone indicates release confirm (after alerting) */ - timer_stop(&trans->timer); + osmo_timer_del(&trans->timer); if (trans->callref) call_up_release(trans->callref, CAUSE_NORMAL); destroy_transaction(trans); @@ -750,24 +752,24 @@ void amps_rx_signaling_tone(amps_t *amps, int tone, double quality) case TRANS_CALL_MT_ALERT_SEND: // should not happen case TRANS_CALL_MT_ALERT_CONFIRM: if (tone) { - timer_stop(&trans->timer); + osmo_timer_del(&trans->timer); call_up_alerting(trans->callref); amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_AUDIO_TX, 0); trans_new_state(trans, TRANS_CALL_MT_ANSWER_WAIT); - timer_start(&trans->timer, ANSWER_TO); + osmo_timer_schedule(&trans->timer, ANSWER_TO); } break; case TRANS_CALL_MT_ANSWER_WAIT: if (!tone) { - timer_stop(&trans->timer); + osmo_timer_del(&trans->timer); if (!trans->sat_detected) - timer_start(&trans->timer, SAT_TO1); + osmo_timer_schedule(&trans->timer, SAT_TO1); call_up_answer(trans->callref, amps_min2number(trans->min1, trans->min2)); trans_new_state(trans, TRANS_CALL); } break; default: - PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Signaling Tone without active call, please fix!\n"); + LOGP_CHAN(DAMPS, LOGL_ERROR, "Signaling Tone without active call, please fix!\n"); } } @@ -775,7 +777,7 @@ void amps_rx_sat(amps_t *amps, int tone, double quality) { transaction_t *trans = amps->trans_list; if (trans == NULL) { - PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "SAT signal without transaction, please fix!\n"); + LOGP_CHAN(DAMPS, LOGL_ERROR, "SAT signal without transaction, please fix!\n"); return; } @@ -792,40 +794,40 @@ void amps_rx_sat(amps_t *amps, int tone, double quality) && trans->state != TRANS_CALL_MT_ALERT_CONFIRM && trans->state != TRANS_CALL_MT_ANSWER_WAIT && trans->state != TRANS_CALL) { - PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "SAT signal without active call, please fix!\n"); + LOGP_CHAN(DAMPS, LOGL_ERROR, "SAT signal without active call, please fix!\n"); return; } if (tone) { - PDEBUG(DAMPS, DEBUG_INFO, "Detected SAT signal with quality=%.0f.\n", quality * 100.0); + LOGP(DAMPS, LOGL_INFO, "Detected SAT signal with quality=%.0f.\n", quality * 100.0); trans->sat_detected = 1; } else { - PDEBUG(DAMPS, DEBUG_INFO, "Lost SAT signal\n"); + LOGP(DAMPS, LOGL_INFO, "Lost SAT signal\n"); trans->sat_detected = 0; } /* initial SAT received */ if (tone && trans->state == TRANS_CALL_MO_ASSIGN_CONFIRM) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Confirm from mobile (SAT) received\n"); - timer_stop(&trans->timer); + LOGP_CHAN(DAMPS, LOGL_INFO, "Confirm from mobile (SAT) received\n"); + osmo_timer_del(&trans->timer); trans_new_state(trans, TRANS_CALL); amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_AUDIO_TX, 0); } if (tone && trans->state == TRANS_CALL_MT_ASSIGN_CONFIRM) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Confirm from mobile (SAT) received\n"); - timer_stop(&trans->timer); + LOGP_CHAN(DAMPS, LOGL_INFO, "Confirm from mobile (SAT) received\n"); + osmo_timer_del(&trans->timer); trans->alert_retry = 1; trans_new_state(trans, TRANS_CALL_MT_ALERT); amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_FRAME_TX, 0); } if (tone) { - timer_stop(&trans->timer); + osmo_timer_del(&trans->timer); } else { if (!trans->dtx) - timer_start(&trans->timer, SAT_TO2); + osmo_timer_schedule(&trans->timer, SAT_TO2); else - timer_stop(&trans->timer); + osmo_timer_del(&trans->timer); } if (amps->sender.loopback) @@ -842,50 +844,51 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint8_t mpci, uint32_t esn, uint32_ /* check if we are busy, so we ignore all signaling */ if (amps->state == STATE_BUSY) { - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Ignoring RECC messages from phone while using this channel for voice.\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Ignoring RECC messages from phone while using this channel for voice.\n"); return; } if (order == 13 && (ordq == 0 || ordq == 1 || ordq == 2 || ordq == 3) && msg_type == 0) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Registration %s (ESN = %08x, %s, %s)\n", callerid, esn, amps_scm(scm), amps_mpci(mpci)); + LOGP_CHAN(DAMPS, LOGL_INFO, "Registration %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci)); _register: numbering(callerid, &carrier, &country, &national_number); if (carrier) - PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home carrier: %s\n", carrier); + LOGP_CHAN(DAMPS, LOGL_INFO, " -> Home carrier: %s\n", carrier); if (country) - PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home country: %s\n", country); + LOGP_CHAN(DAMPS, LOGL_INFO, " -> Home country: %s\n", country); if (national_number) - PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home number: %s\n", national_number); + LOGP_CHAN(DAMPS, LOGL_INFO, " -> Home number: %s\n", national_number); trans = create_transaction(amps, TRANS_REGISTER_ACK, min1, min2, esn, msg_type, ordq, order, 0); if (!trans) { - PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n"); + LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n"); return; } + console_inscription(callerid); } else if (order == 13 && ordq == 3 && msg_type == 1) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Registration - Power Down %s (ESN = %08x, %s, %s)\n", callerid, esn, amps_scm(scm), amps_mpci(mpci)); + LOGP_CHAN(DAMPS, LOGL_INFO, "Registration - Power Down %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci)); goto _register; } else if (order == 0 && ordq == 0 && msg_type == 0) { if (!dialing) - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Paging reply %s (ESN = %08x, %s, %s)\n", callerid, esn, amps_scm(scm), amps_mpci(mpci)); + LOGP_CHAN(DAMPS, LOGL_INFO, "Paging reply %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci)); else - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call %s -> %s (ESN = %08x, %s, %s)\n", callerid, dialing, esn, amps_scm(scm), amps_mpci(mpci)); + LOGP_CHAN(DAMPS, LOGL_INFO, "Call %s -> %s (ESN = %s, %s, %s)\n", callerid, dialing, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci)); trans = search_transaction_number(amps, min1, min2); if (!trans && !dialing) { - PDEBUG(DAMPS, DEBUG_NOTICE, "Paging reply, but call is already gone, rejecting call\n"); + LOGP(DAMPS, LOGL_NOTICE, "Paging reply, but call is already gone, rejecting call\n"); goto reject; } if (trans && dialing) - PDEBUG(DAMPS, DEBUG_NOTICE, "There is already a transaction for this phone. Cloning?\n"); + LOGP(DAMPS, LOGL_NOTICE, "There is already a transaction for this phone. Cloning?\n"); vc = search_free_vc(); if (!vc) { - PDEBUG(DAMPS, DEBUG_NOTICE, "No free channel, rejecting call\n"); + LOGP(DAMPS, LOGL_NOTICE, "No free channel, rejecting call\n"); reject: if (!trans) { trans = create_transaction(amps, TRANS_CALL_REJECT, min1, min2, esn, 0, 0, 3, 0); if (!trans) { - PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n"); + LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n"); return; } } else { @@ -901,7 +904,7 @@ reject: trans = create_transaction(amps, TRANS_CALL_MO_ASSIGN, min1, min2, esn, 0, 0, 0, atoi(vc->sender.kanal)); strncpy(trans->dialing, dialing, sizeof(trans->dialing) - 1); if (!trans) { - PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n"); + LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n"); return; } } else { @@ -911,13 +914,13 @@ reject: /* if we support DTX and also the phone does, we set DTX state of transaction */ if (amps->si.word2.dtx) { if ((scm & 4)) { - PDEBUG(DAMPS, DEBUG_INFO, " -> Use DTX for this call\n"); + LOGP(DAMPS, LOGL_INFO, " -> Use DTX for this call\n"); trans->dtx = 1; } else - PDEBUG(DAMPS, DEBUG_INFO, " -> Requested DTX, but not supported by phone\n"); + LOGP(DAMPS, LOGL_INFO, " -> Requested DTX, but not supported by phone\n"); } } else - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Unsupported RECC messages: ORDER: %d ORDQ: %d MSG TYPE: %d (See Table 4 of specs.)\n", order, ordq, msg_type); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Unsupported RECC messages: ORDER: %d ORDQ: %d MSG TYPE: %d (See Table 4 of specs.)\n", order, ordq, msg_type); } /* @@ -938,7 +941,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, /* 2. check if the subscriber is attached */ // if (!find_db(min1, min2)) { -// PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing call to not attached subscriber, rejecting!\n"); +// LOGP(DAMPS, LOGL_NOTICE, "Outgoing call to not attached subscriber, rejecting!\n"); // return -CAUSE_OUTOFORDER; // } @@ -951,29 +954,29 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, break; } if (sender) { - PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing call to busy number, rejecting!\n"); + LOGP(DAMPS, LOGL_NOTICE, "Outgoing call to busy number, rejecting!\n"); return -CAUSE_BUSY; } /* 4. check if all senders are busy, return NOCHANNEL */ if (!search_free_vc()) { - PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing call, but no free channel, rejecting!\n"); + LOGP(DAMPS, LOGL_NOTICE, "Outgoing call, but no free channel, rejecting!\n"); return -CAUSE_NOCHANNEL; } /* 5. check if we have (currently) no paging channel, return NOCHANNEL */ amps = search_pc(); if (!amps) { - PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing call, but paging channel (control channel) is currently busy, rejecting!\n"); + LOGP(DAMPS, LOGL_NOTICE, "Outgoing call, but paging channel (control channel) is currently busy, rejecting!\n"); return -CAUSE_NOCHANNEL; } - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing); + LOGP_CHAN(DAMPS, LOGL_INFO, "Call to mobile station, paging station id '%s'\n", dialing); /* 6. trying to page mobile station */ trans = create_transaction(amps, TRANS_PAGE, min1, min2, 0, 0, 0, 0, 0); if (!trans) { - PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n"); + LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n"); return -CAUSE_TEMPFAIL; } trans->callref = callref; @@ -987,7 +990,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, return 0; } -void call_down_answer(int __attribute__((unused)) callref) +void call_down_answer(int __attribute__((unused)) callref, struct timeval __attribute__((unused)) *tv_meter) { } @@ -1001,7 +1004,7 @@ void call_down_disconnect(int callref, int cause) amps_t *amps; transaction_t *trans; - PDEBUG(DAMPS, DEBUG_INFO, "Call has been disconnected by network.\n"); + LOGP(DAMPS, LOGL_INFO, "Call has been disconnected by network.\n"); for (sender = sender_head; sender; sender = sender->next) { amps = (amps_t *) sender; @@ -1011,7 +1014,7 @@ void call_down_disconnect(int callref, int cause) break; } if (!sender) { - PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing disconnect, but no callref!\n"); + LOGP(DAMPS, LOGL_NOTICE, "Outgoing disconnect, but no callref!\n"); call_up_release(callref, CAUSE_INVALCALLREF); return; } @@ -1026,12 +1029,12 @@ void call_down_disconnect(int callref, int cause) || trans->state == TRANS_CALL_MT_ALERT_SEND || trans->state == TRANS_CALL_MT_ALERT_CONFIRM || trans->state == TRANS_CALL_MT_ANSWER_WAIT) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control disconnect on voice channel while alerting, releasing towards mobile station.\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Call control disconnect on voice channel while alerting, releasing towards mobile station.\n"); amps_release(trans, cause); } return; default: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control disconnects on control channel, removing transaction.\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Call control disconnects on control channel, removing transaction.\n"); call_up_release(callref, cause); trans->callref = 0; destroy_transaction(trans); @@ -1046,7 +1049,7 @@ void call_down_release(int callref, int cause) amps_t *amps; transaction_t *trans; - PDEBUG(DAMPS, DEBUG_INFO, "Call has been released by network, releasing call.\n"); + LOGP(DAMPS, LOGL_INFO, "Call has been released by network, releasing call.\n"); for (sender = sender_head; sender; sender = sender->next) { amps = (amps_t *) sender; @@ -1056,7 +1059,7 @@ void call_down_release(int callref, int cause) break; } if (!sender) { - PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing release, but no callref!\n"); + LOGP(DAMPS, LOGL_NOTICE, "Outgoing release, but no callref!\n"); /* don't send release, because caller already released */ return; } @@ -1067,88 +1070,66 @@ void call_down_release(int callref, int cause) case DSP_MODE_AUDIO_RX_SILENCE_TX: case DSP_MODE_AUDIO_RX_AUDIO_TX: case DSP_MODE_AUDIO_RX_FRAME_TX: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control releases on voice channel, releasing towards mobile station.\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Call control releases on voice channel, releasing towards mobile station.\n"); amps_release(trans, cause); break; default: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control releases on control channel, removing transaction.\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Call control releases on control channel, removing transaction.\n"); destroy_transaction(trans); amps_go_idle(amps); } } -/* Receive audio from call instance. */ -void call_down_audio(int callref, uint16_t sequence, uint32_t timestamp, uint32_t ssrc, sample_t *samples, int count) -{ - sender_t *sender; - amps_t *amps; - - for (sender = sender_head; sender; sender = sender->next) { - amps = (amps_t *) sender; - if (amps->trans_list && amps->trans_list->callref == callref) - break; - } - if (!sender) - return; - - if (amps->dsp_mode == DSP_MODE_AUDIO_RX_AUDIO_TX) { - compress_audio(&s->cstate, samples, count); - jitter_save(&s->sender.dejitter, samples, count, 1, sequence, timestamp, ssrc); - } -} - -void call_down_clock(void) {} - /* Timeout handling */ -void transaction_timeout(struct timer *timer) +void transaction_timeout(void *data) { - transaction_t *trans = (transaction_t *)timer->priv; + transaction_t *trans = data; amps_t *amps = trans->amps; switch (trans->state) { case TRANS_CALL_MO_ASSIGN_CONFIRM: case TRANS_CALL_MT_ASSIGN_CONFIRM: - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Timeout after %.0f seconds not receiving initial SAT signal.\n", timer->duration); - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Release call towards network.\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Timeout after %ld seconds not receiving initial SAT signal.\n", trans->timer.timeout.tv_sec); + LOGP_CHAN(DAMPS, LOGL_INFO, "Release call towards network.\n"); amps_release(amps->trans_list, CAUSE_TEMPFAIL); break; case TRANS_CALL: - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Timeout after %.0f seconds loosing SAT signal.\n", timer->duration); - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Release call towards network.\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Timeout after %ld seconds loosing SAT signal.\n", trans->timer.timeout.tv_sec); + LOGP_CHAN(DAMPS, LOGL_INFO, "Release call towards network.\n"); amps_release(amps->trans_list, CAUSE_TEMPFAIL); break; case TRANS_CALL_RELEASE: case TRANS_CALL_RELEASE_SEND: - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Release timeout, destroying transaction\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Release timeout, destroying transaction\n"); destroy_transaction(trans); amps_go_idle(amps); break; case TRANS_CALL_MT_ALERT_SEND: case TRANS_CALL_MT_ALERT_CONFIRM: if (trans->alert_retry++ == ALERT_TRIES) { - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Phone does not respond to alert order, destroying transaction\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Phone does not respond to alert order, destroying transaction\n"); amps_release(trans, CAUSE_TEMPFAIL); } else { - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Phone does not respond to alert order, retrying\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Phone does not respond to alert order, retrying\n"); trans_new_state(trans, TRANS_CALL_MT_ALERT); amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_FRAME_TX, 0); } break; case TRANS_CALL_MT_ANSWER_WAIT: - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Alerting timeout, destroying transaction\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Alerting timeout, destroying transaction\n"); amps_release(trans, CAUSE_NOANSWER); break; case TRANS_PAGE_REPLY: if (trans->page_retry++ == PAGE_TRIES) { - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Paging timeout, destroying transaction\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Paging timeout, destroying transaction\n"); amps_release(trans, CAUSE_OUTOFORDER); } else { - PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Paging timeout, retrying\n"); + LOGP_CHAN(DAMPS, LOGL_NOTICE, "Paging timeout, retrying\n"); trans_new_state(trans, TRANS_PAGE); } break; default: - PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Timeout unhandled in state %d\n", trans->state); + LOGP_CHAN(DAMPS, LOGL_ERROR, "Timeout unhandled in state %d\n", trans->state); } } @@ -1160,18 +1141,18 @@ static amps_t *assign_voice_channel(transaction_t *trans) vc = search_channel(trans->chan); if (!vc) { - PDEBUG(DAMPS, DEBUG_NOTICE, "Channel %d is not free anymore, rejecting call\n", trans->chan); + LOGP(DAMPS, LOGL_NOTICE, "Channel %d is not free anymore, rejecting call\n", trans->chan); amps_release(trans, CAUSE_NOCHANNEL); return NULL; } if (vc == amps) - PDEBUG(DAMPS, DEBUG_INFO, "Staying on combined control + voice channel %s\n", vc->sender.kanal); + LOGP(DAMPS, LOGL_INFO, "Staying on combined control + voice channel %s\n", vc->sender.kanal); else - PDEBUG(DAMPS, DEBUG_INFO, "Moving to voice channel %s\n", vc->sender.kanal); + LOGP(DAMPS, LOGL_INFO, "Moving to voice channel %s\n", vc->sender.kanal); /* switch channel... */ - timer_start(&trans->timer, SAT_TO1); + osmo_timer_schedule(&trans->timer, SAT_TO1); /* make channel busy */ amps_new_state(vc, STATE_BUSY); /* relink */ @@ -1184,7 +1165,7 @@ static amps_t *assign_voice_channel(transaction_t *trans) char esn_text[16]; sprintf(esn_text, "%u", trans->esn); /* setup call */ - PDEBUG(DAMPS, DEBUG_INFO, "Setup call to network.\n"); + LOGP(DAMPS, LOGL_INFO, "Setup call to network.\n"); trans->callref = call_up_setup(callerid, trans->dialing, OSMO_CC_NETWORK_AMPS_ESN, esn_text); } @@ -1203,52 +1184,55 @@ again: switch (trans->state) { case TRANS_REGISTER_ACK: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Sending Register acknowledge\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Sending Register acknowledge\n"); trans_new_state(trans, TRANS_REGISTER_ACK_SEND); return trans; case TRANS_REGISTER_ACK_SEND: destroy_transaction(trans); goto again; case TRANS_CALL_REJECT: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Rejecting call from mobile station\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Rejecting call from mobile station\n"); trans_new_state(trans, TRANS_CALL_REJECT_SEND); return trans; case TRANS_CALL_REJECT_SEND: destroy_transaction(trans); goto again; case TRANS_CALL_MO_ASSIGN: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assigning channel to call from mobile station\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Assigning channel to call from mobile station\n"); trans_new_state(trans, TRANS_CALL_MO_ASSIGN_SEND); return trans; case TRANS_CALL_MO_ASSIGN_SEND: vc = assign_voice_channel(trans); if (vc) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assignment complete, voice connected\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Assignment complete, voice connected\n"); /* timer and other things are processed at assign_voice_channel() */ trans_new_state(trans, TRANS_CALL_MO_ASSIGN_CONFIRM); amps_set_dsp_mode(vc, DSP_MODE_AUDIO_RX_SILENCE_TX, 0); } return NULL; case TRANS_CALL_MT_ASSIGN: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assigning channel to call to mobile station\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Assigning channel to call to mobile station\n"); trans_new_state(trans, TRANS_CALL_MT_ASSIGN_SEND); return trans; case TRANS_CALL_MT_ASSIGN_SEND: vc = assign_voice_channel(trans); if (vc) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assignment complete, waiting for SAT on VC\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Assignment complete, waiting for SAT on VC\n"); /* timer and other things are processed at assign_voice_channel() */ trans_new_state(trans, TRANS_CALL_MT_ASSIGN_CONFIRM); amps_set_dsp_mode(vc, DSP_MODE_AUDIO_RX_SILENCE_TX, 0); } return NULL; case TRANS_PAGE: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Paging the phone\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Paging the phone\n"); trans_new_state(trans, TRANS_PAGE_SEND); return trans; case TRANS_PAGE_SEND: trans_new_state(trans, TRANS_PAGE_REPLY); - timer_start(&trans->timer, (trans->page_retry == PAGE_TRIES) ? PAGE_TO2 : PAGE_TO1); + if (trans->page_retry == PAGE_TRIES) + osmo_timer_schedule(&trans->timer, PAGE_TO2); + else + osmo_timer_schedule(&trans->timer, PAGE_TO1); return NULL; default: return NULL; @@ -1265,11 +1249,11 @@ transaction_t *amps_tx_frame_fvc(amps_t *amps) switch (trans->state) { case TRANS_CALL_RELEASE: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Releasing call towards mobile station\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Releasing call towards mobile station\n"); trans_new_state(trans, TRANS_CALL_RELEASE_SEND); return trans; case TRANS_CALL_RELEASE_SEND: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Release call was sent, continue sending release\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Release call was sent, continue sending release\n"); return trans; case TRANS_CALL_MT_ALERT: trans->chan = 0; @@ -1277,17 +1261,17 @@ transaction_t *amps_tx_frame_fvc(amps_t *amps) trans->ordq = 0; // "Alert with caller ID" causes older phones to interrupt the connection for some reason, therefore we don't use order 17 when no caller ID is set if (amps->send_callerid && trans->alert_retry == 1 && trans->caller_id[0]) { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Sending alerting with caller ID\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Sending alerting with caller ID\n"); trans->order = 17; } else { - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Sending alerting\n"); + LOGP_CHAN(DAMPS, LOGL_INFO, "Sending alerting\n"); trans->order = 1; } trans_new_state(trans, TRANS_CALL_MT_ALERT_SEND); return trans; case TRANS_CALL_MT_ALERT_SEND: - PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Alerting was sent, continue waiting for ST or timeout\n"); - timer_start(&trans->timer, ALERT_TO); + LOGP_CHAN(DAMPS, LOGL_INFO, "Alerting was sent, continue waiting for ST or timeout\n"); + osmo_timer_schedule(&trans->timer, ALERT_TO); amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_SILENCE_TX, 0); trans_new_state(trans, TRANS_CALL_MT_ALERT_CONFIRM); return NULL; diff --git a/src/amps/amps.h b/src/amps/amps.h index 0a85df2..da0e660 100644 --- a/src/amps/amps.h +++ b/src/amps/amps.h @@ -1,6 +1,6 @@ #include "../libgoertzel/goertzel.h" #include "../libmobile/sender.h" -#include "../libtimer/timer.h" +#include <osmocom/core/timer.h> #include "../libcompandor/compandor.h" typedef struct amps amps_t; #include "sysinfo.h" @@ -171,6 +171,7 @@ struct amps { int when_count; /* counter of the filler frame */ }; +void amps_display_status(void); void amps_channel_list(void); int amps_channel_by_short_name(const char *short_name); const char *chan_type_short_name(enum amps_chan_type chan_type); @@ -182,6 +183,8 @@ const char *amps_min22number(uint16_t min2); const char *amps_min12number(uint32_t min1); void amps_number2min(const char *number, uint32_t *min1, uint16_t *min2); const char *amps_min2number(uint32_t min1, uint16_t min2); +void amps_encode_esn(uint32_t *esn, uint8_t mfr, uint32_t serial); +void amps_decode_esn(uint32_t esn, uint8_t *mfr, uint32_t *serial); const char *amps_scm(uint8_t scm); int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int send_callerid, int tolerant, int loopback); void amps_destroy(sender_t *sender); diff --git a/src/amps/dsp.c b/src/amps/dsp.c index a18abee..f0c5da2 100644 --- a/src/amps/dsp.c +++ b/src/amps/dsp.c @@ -82,8 +82,9 @@ #include <errno.h> #include <math.h> #include "../libsample/sample.h" -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" #include "../libmobile/call.h" +#include "../libmobile/get_time.h" #include "amps.h" #include "frame.h" #include "dsp.h" @@ -146,7 +147,7 @@ void dsp_init(void) int i; double s; - PDEBUG(DDSP, DEBUG_DEBUG, "Generating sine table for SAT signal.\n"); + LOGP(DDSP, LOGL_DEBUG, "Generating sine table for SAT signal.\n"); for (i = 0; i < 65536; i++) { s = sin((double)i / 65536.0 * 2.0 * PI); dsp_sine_sat[i] = s * ((!tacs) ? AMPS_SAT_DEVIATION : TACS_SAT_DEVIATION); @@ -162,6 +163,8 @@ void dsp_init(void) } dsp_sync_check[0x712] = 0x00; /* no bit error */ dsp_sync_check[0x0ed] = 0x80; /* no bit error */ + + compandor_init(); } static void dsp_init_ramp(amps_t *amps) @@ -169,7 +172,7 @@ static void dsp_init_ramp(amps_t *amps) double c; int i; - PDEBUG(DDSP, DEBUG_DEBUG, "Generating smooth ramp table.\n"); + LOGP(DDSP, LOGL_DEBUG, "Generating smooth ramp table.\n"); for (i = 0; i < 256; i++) { c = cos((double)i / 256.0 * PI); #if 0 @@ -194,9 +197,9 @@ int dsp_init_sender(amps_t *amps, int tolerant) int half; /* attack (3ms) and recovery time (13.5ms) according to amps specs */ - init_compandor(&s->cstate, 8000, 3.0, 13.5); + setup_compandor(&s->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(&s->sender, @@ -206,18 +209,18 @@ int dsp_init_sender(amps_t *amps, int tolerant) (!tacs) ? AMPS_MAX_DISPLAY : TACS_MAX_DISPLAY); if (amps->sender.samplerate < 96000) { - PDEBUG(DDSP, DEBUG_ERROR, "Sample rate must be at least 96000 Hz to process FSK and SAT signals.\n"); + LOGP(DDSP, LOGL_ERROR, "Sample rate must be at least 96000 Hz to process FSK and SAT signals.\n"); return -EINVAL; } amps->fsk_bitduration = (double)amps->sender.samplerate / (double)((!tacs) ? AMPS_BITRATE : TACS_BITRATE); amps->fsk_bitstep = 1.0 / amps->fsk_bitduration; - PDEBUG(DDSP, DEBUG_DEBUG, "Use %.4f samples for full bit duration @ %d.\n", amps->fsk_bitduration, amps->sender.samplerate); + LOGP(DDSP, LOGL_DEBUG, "Use %.4f samples for full bit duration @ %d.\n", amps->fsk_bitduration, amps->sender.samplerate); amps->fsk_tx_buffer_size = amps->fsk_bitduration + 10; /* 10 extra to avoid overflow due to rounding */ spl = calloc(sizeof(*spl), amps->fsk_tx_buffer_size); if (!spl) { - PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n"); + LOGP(DDSP, LOGL_ERROR, "No memory!\n"); rc = -ENOMEM; goto error; } @@ -228,12 +231,12 @@ int dsp_init_sender(amps_t *amps, int tolerant) amps->fsk_rx_window_begin = half >> 1; amps->fsk_rx_window_half = half; amps->fsk_rx_window_end = amps->fsk_rx_window_length - (half >> 1); - PDEBUG(DDSP, DEBUG_DEBUG, "Bit window length: %d\n", amps->fsk_rx_window_length); - PDEBUG(DDSP, DEBUG_DEBUG, " -> Samples in window to analyse level left of edge: %d..%d\n", amps->fsk_rx_window_begin, amps->fsk_rx_window_half - 1); - PDEBUG(DDSP, DEBUG_DEBUG, " -> Samples in window to analyse level right of edge: %d..%d\n", amps->fsk_rx_window_half, amps->fsk_rx_window_end - 1); + LOGP(DDSP, LOGL_DEBUG, "Bit window length: %d\n", amps->fsk_rx_window_length); + LOGP(DDSP, LOGL_DEBUG, " -> Samples in window to analyse level left of edge: %d..%d\n", amps->fsk_rx_window_begin, amps->fsk_rx_window_half - 1); + LOGP(DDSP, LOGL_DEBUG, " -> Samples in window to analyse level right of edge: %d..%d\n", amps->fsk_rx_window_half, amps->fsk_rx_window_end - 1); spl = calloc(sizeof(*amps->fsk_rx_window), amps->fsk_rx_window_length); if (!spl) { - PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n"); + LOGP(DDSP, LOGL_ERROR, "No memory!\n"); rc = -ENOMEM; goto error; } @@ -250,10 +253,10 @@ int dsp_init_sender(amps_t *amps, int tolerant) amps->sat_samples = (int)((double)amps->sender.samplerate * (1.0 / (SAT_BANDWIDTH / 2.0)) + 0.5); spl = calloc(sizeof(*spl), amps->sat_samples); if (!spl) { - PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n"); + LOGP(DDSP, LOGL_ERROR, "No memory!\n"); return -ENOMEM; } - PDEBUG(DDSP, DEBUG_DEBUG, "Sat detection interval is %d ms.\n", amps->sat_samples * 1000 / amps->sender.samplerate); + LOGP(DDSP, LOGL_DEBUG, "Sat detection interval is %d ms.\n", amps->sat_samples * 1000 / amps->sender.samplerate); amps->sat_filter_spl = spl; /* count SAT tones */ @@ -287,7 +290,7 @@ error: /* Cleanup transceiver instance. */ void dsp_cleanup_sender(amps_t *amps) { - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for treansceiver.\n"); + LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for treansceiver.\n"); if (amps->fsk_tx_buffer) free(amps->fsk_tx_buffer); @@ -485,7 +488,12 @@ again: case DSP_MODE_AUDIO_RX_AUDIO_TX: memset(power, 1, length); input_num = samplerate_upsample_input_num(&sender->srstate, length); - jitter_load(&sender->dejitter, samples, input_num); + { + int16_t spl[input_num]; + jitter_load_samples(&sender->dejitter, (uint8_t *)spl, input_num, sizeof(*spl), jitter_conceal_s16, NULL); + int16_to_samples_speech(samples, spl, input_num); + } + compress_audio(&s->cstate, samples, input_num); samplerate_upsample(&sender->srstate, samples, input_num, samples, length); /* pre-emphasis */ if (amps->pre_emphasis) @@ -768,7 +776,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length) /* debug SAT */ if (++amps->sat_print == SAT_PRINT) { - PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "SAT level %.2f%% quality %.0f%%\n", sat_level * 100.0, sat_quality * 100.0); + LOGP_CHAN(DDSP, LOGL_NOTICE, "SAT level %.2f%% quality %.0f%%\n", sat_level * 100.0, sat_quality * 100.0); amps->sat_print = 0; } @@ -777,8 +785,8 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length) display_measurements_update(amps->dmp_sat_quality, sat_quality * 100.0, 0.0); /* debug signaling tone */ - if (amps->sender.loopback || debuglevel == DEBUG_DEBUG) { - PDEBUG_CHAN(DDSP, debuglevel, "Signaling Tone level %.2f%% quality %.0f%%\n", sig_level * 100.0, sig_quality * 100.0); + if (amps->sender.loopback || loglevel == LOGL_DEBUG) { + LOGP_CHAN(DDSP, loglevel, "Signaling Tone level %.2f%% quality %.0f%%\n", sig_level * 100.0, sig_quality * 100.0); } /* mute if SAT quality or level is below threshold */ @@ -794,7 +802,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length) if (amps->sat_detect_count == SAT_DETECT_COUNT) { amps->sat_detected = 1; amps->sat_detect_count = 0; - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "SAT signal detected with level=%.0f%%, quality=%.0f%%.\n", sat_level * 100.0, sat_quality * 100.0); + LOGP_CHAN(DDSP, LOGL_DEBUG, "SAT signal detected with level=%.0f%%, quality=%.0f%%.\n", sat_level * 100.0, sat_quality * 100.0); amps_rx_sat(amps, 1, sat_quality); } } else @@ -805,7 +813,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length) if (amps->sat_detect_count == SAT_LOST_COUNT) { amps->sat_detected = 0; amps->sat_detect_count = 0; - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "SAT signal lost.\n"); + LOGP_CHAN(DDSP, LOGL_DEBUG, "SAT signal lost.\n"); amps_rx_sat(amps, 0, 0.0); } } else @@ -819,7 +827,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length) if (amps->sig_detect_count == SIG_DETECT_COUNT) { amps->sig_detected = 1; amps->sig_detect_count = 0; - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Signaling Tone detected with level=%.0f%%, quality=%.0f%%.\n", sig_level * 100.0, sig_quality * 100.0); + LOGP_CHAN(DDSP, LOGL_DEBUG, "Signaling Tone detected with level=%.0f%%, quality=%.0f%%.\n", sig_level * 100.0, sig_quality * 100.0); amps_rx_signaling_tone(amps, 1, sig_quality); } } else @@ -830,7 +838,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length) if (amps->sig_detect_count == SIG_LOST_COUNT) { amps->sig_detected = 0; amps->sig_detect_count = 0; - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Signaling Tone lost.\n"); + LOGP_CHAN(DDSP, LOGL_DEBUG, "Signaling Tone lost.\n"); amps_rx_signaling_tone(amps, 0, 0.0); } } else @@ -916,7 +924,7 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double __at /* Reset SAT detection states, so ongoing tone will be detected again. */ static void sat_reset(amps_t *amps, const char *reason) { - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "SAT detector reset: %s.\n", reason); + LOGP_CHAN(DDSP, LOGL_DEBUG, "SAT detector reset: %s.\n", reason); amps->sat_detected = 0; amps->sat_detect_count = 0; amps->sig_detected = 0; @@ -933,28 +941,30 @@ void amps_set_dsp_mode(amps_t *amps, enum dsp_mode mode, int frame_length) if (mode == DSP_MODE_FRAME_RX_FRAME_TX) { /* reset SAT detection */ sat_reset(amps, "Change to FOCC"); - PDEBUG_CHAN(DDSP, DEBUG_INFO, "Change mode to FOCC\n"); + LOGP_CHAN(DDSP, LOGL_INFO, "Change mode to FOCC\n"); amps->tx_focc_debugged = 0; } if (amps->dsp_mode == DSP_MODE_FRAME_RX_FRAME_TX && (mode == DSP_MODE_AUDIO_RX_AUDIO_TX || mode == DSP_MODE_AUDIO_RX_FRAME_TX || mode == DSP_MODE_AUDIO_RX_SILENCE_TX)) { /* reset SAT detection */ sat_reset(amps, "Change from FOCC to FVC"); - PDEBUG_CHAN(DDSP, DEBUG_INFO, "Change mode from FOCC to FVC\n"); + LOGP_CHAN(DDSP, LOGL_INFO, "Change mode from FOCC to FVC\n"); } if (amps->dsp_mode == DSP_MODE_OFF && (mode == DSP_MODE_AUDIO_RX_AUDIO_TX || mode == DSP_MODE_AUDIO_RX_FRAME_TX || mode == DSP_MODE_AUDIO_RX_SILENCE_TX)) { /* reset SAT detection */ sat_reset(amps, "Enable FVC"); - PDEBUG_CHAN(DDSP, DEBUG_INFO, "Change mode from OFF to FVC\n"); + LOGP_CHAN(DDSP, LOGL_INFO, "Change mode from OFF to FVC\n"); } if (mode == DSP_MODE_OFF) { /* reset SAT detection */ sat_reset(amps, "Disable FVC"); - PDEBUG_CHAN(DDSP, DEBUG_INFO, "Change mode from FVC to OFF\n"); + LOGP_CHAN(DDSP, LOGL_INFO, "Change mode from FVC to OFF\n"); } + if (mode == DSP_MODE_AUDIO_RX_AUDIO_TX && amps->dsp_mode != mode) + jitter_reset(&s->sender.dejitter); - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Reset FSK frame transmitter, due to setting dsp mode.\n"); + LOGP_CHAN(DDSP, LOGL_DEBUG, "Reset FSK frame transmitter, due to setting dsp mode.\n"); amps->dsp_mode = mode; if (frame_length) @@ -971,3 +981,27 @@ void amps_set_dsp_mode(amps_t *amps, enum dsp_mode mode, int frame_length) amps->fsk_tx_frame_pos = 0; } +/* Receive audio from call instance. */ +void call_down_audio(void *decoder, void *decoder_priv, int callref, uint16_t sequence, uint8_t marker, uint32_t timestamp, uint32_t ssrc, uint8_t *payload, int payload_len) +{ + sender_t *sender; + amps_t *amps; + + for (sender = sender_head; sender; sender = sender->next) { + amps = (amps_t *) sender; + if (amps->trans_list && amps->trans_list->callref == callref) + break; + } + if (!sender) + return; + + if (amps->dsp_mode == DSP_MODE_AUDIO_RX_AUDIO_TX) { + jitter_frame_t *jf; + jf = jitter_frame_alloc(decoder, decoder_priv, payload, payload_len, marker, sequence, timestamp, ssrc); + if (jf) + jitter_save(&s->sender.dejitter, jf); + } +} + +void call_down_clock(void) {} + diff --git a/src/amps/esn.c b/src/amps/esn.c new file mode 100644 index 0000000..93bcb70 --- /dev/null +++ b/src/amps/esn.c @@ -0,0 +1,153 @@ +/* AMPS ESN specification + * + * (C) 2023 by Andreas Eversberg <jolly@eversberg.eu> + * All Rights Reserved + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <stdio.h> +#include <stdint.h> +#include <string.h> +#include <pthread.h> +#include <sys/time.h> +#include "../libsample/sample.h" +#include "../liblogging/logging.h" +#include "../libmobile/call.h" +#include "../libmobile/cause.h" +#include <osmocom/cc/message.h> +#include "amps.h" +#include "esn.h" + +const char *amps_manufacturer[256] = { + [129] = "Oki", + [130] = "Motorola, Inc.", + [131] = "E.F. Johnson", + [132] = "Hitachi", + [133] = "Fujitsu", + [134] = "Mitsubishi", + [135] = "NEC America, Inc.", + [136] = "Matsushita (Panasonic)", + [137] = "Harris", + [138] = "Toshiba", + [139] = "Kokusai", + [140] = "Clarion Company, Ltd.", + [141] = "GoldStar Products Co.,Ltd.", + [142] = "International Systcom (Novatel)", + [143] = "Ericsson, Inc.", + [144] = "Murata Machinery, Ltd.", + [145] = "DI-BAR Electronics, Inc.", + [146] = "Ericsson Inc. (formerly assigned to General Electric)", + [147] = "Gateway Telephone, Inc.", + [148] = "Robert Bosch Corporation (Blaupunkt)", + [149] = "Universal Cellular, Inc.", + [150] = "Alpine Electronics of America, Inc.", + [151] = "Verma Laboratories", + [152] = "Japan Radio Co.,Ltd.", + [153] = "CM Communications Incorporated", + [154] = "Sony Corporation (Japan)", + [155] = "Tama Denki Company, Ltd.", + [156] = "Mobira (Nokia-Kinex)", + [157] = "Ericsson GE Mobile Communications, Inc.", + [158] = "AT&T Technologies, Inc.", + [159] = "QUALCOMM, Incorporated", + [160] = "Hyundai", + [161] = "Satellite Technology Services, Inc.", + [162] = "Technophone Limited", + [163] = "Yupiteru Industries Company Ltd.", + [164] = "Hughes Network Systems", + [165] = "TMC Company Limited (Nokia)", + [166] = "Clarion Manufacturing Corporation of America", + [167] = "Mansoor Electronics Limited", + [168] = "Motorola International", + [169] = "Otron Corporation", + [170] = "Philips Telecom Equipment Corporation", + [171] = "Philips Circuit Assemblies", + [172] = "Uniden Corporation of America", + [173] = "Uniden Corporation - Japan", + [174] = "Shintom West Corporation of America", + [175] = "Tottori Sanyo Electric Co. Ltd.", + [176] = "Samsung Communications", + [177] = "INFA Telecom Canada, Inc.", + [178] = "Emptel Electronics Company Ltd.", + [179] = "**Unassigned**", + [180] = "ASCNet", + [181] = "Yaesu USA", + [182] = "Tecom Co. Ltd.", + [183] = "Omni Telecommunications, Inc. (formerly assigned to Valor Electronics, Inc.)", + [184] = "Royal Information Electronics Co. Ltd.", + [185] = "Tele Digital Development, Inc. (formerly assigned to Cumulus Corporation.)", + [186] = "DNC", + [187] = "**Unassigned**", + [188] = "Myday Technology, Ltd.", + [189] = "NEC America, Inc.", + [190] = "Kyocera Corporation", + [191] = "Digital Security Controls", + [192] = "CTCELL Digital, Inc.", + [193] = "Matsushita Communication Industrial Corporation of America", + [194] = "HS Electronics Corporation", + [195] = "Motorola, Inc.", + [196] = "Pacific Communication Sciences, Inc.", + [197] = "Maxon Systems, Inc., (London) Ltd.", + [198] = "Hongsheng Electronics Co., Ltd.", + [199] = "M/ACOM", + [200] = "CHANNLE LINK Incorporation", + [201] = "L.G. Information & Communications (formerly assigned to Goldstar Information & Communications, Ltd.)", + [202] = "Intel Corporation", + [203] = "Air Communications, Inc.", + [204] = "Ericsson GE Mobile Communications Inc.", + [205] = "Goldtron RF PTE Ltd.", + [206] = "Sierra Wireless Inc.", + [207] = "Mitsubishi International Corp.", + [208] = "JRC International, Inc.", + [209] = "Sapura Holdings SDN. BHD.", + [210] = "Inex Technologies, Inc.", + [211] = "Sony Electronics (U.S.A.)", + [212] = "Motorola, Inc.", + [213] = "Motorola, Inc.", + [214] = "Philips Semiconductors", + [215] = "Carillon Corp.", + [216] = "Nippondenso America, Inc.", + [217] = "International Business Machines Corporation", + [218] = "Nokia (Hong Kong)", + [219] = "Nokia (TMC Co. Ltd.)", + [220] = "TEMIC", + [221] = "Northern Telecom", + [222] = "Telrad Telecommunications Ltd.", + [223] = "Motorola, Inc.", + [224] = "Motorola, Inc.", + [225] = "Telital s.r.l.", + [226] = "Nokia (Manau, Brazil)", + [227] = "Stanilite Pacific", + [228] = "Philips Consumer Communications", + [229] = "NEC America, Inc.", + [230] = "TELLULAR Corporation", + [231] = "Ericsson Inc.", +}; + +const char *esn_to_string(uint32_t esn) +{ + uint8_t mfr; + uint32_t serial; + static char esn_string[256]; + + amps_decode_esn(esn, &mfr, &serial); + + if (amps_manufacturer[mfr]) + snprintf(esn_string, sizeof(esn_string), "0x%08x or %d-%06d (%s)", esn, mfr, serial, amps_manufacturer[mfr]); + else + snprintf(esn_string, sizeof(esn_string), "0x%08x or %d-%06d", esn, mfr, serial); + + return esn_string; +} diff --git a/src/amps/esn.h b/src/amps/esn.h new file mode 100644 index 0000000..713ff12 --- /dev/null +++ b/src/amps/esn.h @@ -0,0 +1,3 @@ + +const char *esn_to_string(uint32_t esn); + diff --git a/src/amps/frame.c b/src/amps/frame.c index e89f3d5..14bd856 100644 --- a/src/amps/frame.c +++ b/src/amps/frame.c @@ -27,7 +27,8 @@ #include <math.h> #include <inttypes.h> #include "../libsample/sample.h" -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" +#include "../libmobile/get_time.h" #include "amps.h" #include "dsp.h" #include "frame.h" @@ -2719,7 +2720,7 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug) sum_bits += w->ie[i].bits; if (debug) - PDEBUG(DFRAME, DEBUG_INFO, "Transmit: %s\n", w->name); + LOGP(DFRAME, LOGL_INFO, "Transmit: %s\n", w->name); word = 0; for (i = 0; w->ie[i].name; i++) { bits = w->ie[i].bits; @@ -2730,9 +2731,9 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug) word = (word << bits) | (value & cut_bits[bits]); if (debug) { if (amps_ie_desc[w->ie[i].ie].decoder) - PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc); + LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc); else - PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc); + LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc); } /* show result for 3 IEs of table 4 */ if (w->ie[i].ie == AMPS_IE_LOCAL_MSG_TYPE || w->ie[i].ie == AMPS_IE_ORDQ || w->ie[i].ie == AMPS_IE_ORDER) @@ -2740,7 +2741,7 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug) if (t4 == 3) { t4 = 0; if (debug) - PDEBUG(DFRAME, DEBUG_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame->ie[AMPS_IE_LOCAL_MSG_TYPE], frame->ie[AMPS_IE_ORDQ], frame->ie[AMPS_IE_ORDER])); + LOGP(DFRAME, LOGL_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame->ie[AMPS_IE_LOCAL_MSG_TYPE], frame->ie[AMPS_IE_ORDQ], frame->ie[AMPS_IE_ORDER])); } } @@ -3070,22 +3071,22 @@ static frame_t *amps_decode_word(uint64_t word, struct def_word *w) for (i = 0; w->ie[i].name; i++) bits_left += w->ie[i].bits; - PDEBUG(DFRAME, DEBUG_INFO, "Received: %s\n", w->name); + LOGP(DFRAME, LOGL_INFO, "Received: %s\n", w->name); for (i = 0; w->ie[i].name; i++) { bits = w->ie[i].bits; bits_left -= bits; value = (word >> bits_left) & cut_bits[bits]; frame.ie[w->ie[i].ie] = value; if (amps_ie_desc[w->ie[i].ie].decoder) - PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc); + LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc); else - PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc); + LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc); /* show result for 3 IEs of table 4 */ if (w->ie[i].ie == AMPS_IE_LOCAL_MSG_TYPE || w->ie[i].ie == AMPS_IE_ORDQ || w->ie[i].ie == AMPS_IE_ORDER) t4++; if (t4 == 3) { t4 = 0; - PDEBUG(DFRAME, DEBUG_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame.ie[AMPS_IE_LOCAL_MSG_TYPE], frame.ie[AMPS_IE_ORDQ], frame.ie[AMPS_IE_ORDER])); + LOGP(DFRAME, LOGL_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame.ie[AMPS_IE_LOCAL_MSG_TYPE], frame.ie[AMPS_IE_ORDQ], frame.ie[AMPS_IE_ORDER])); } } @@ -3103,7 +3104,7 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word) /* control message */ if (t1t2 != 3) { - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Mobile Station Control Message (T1T2 = %d)\n", t1t2); + LOGP_CHAN(DFRAME, LOGL_INFO, "Received Mobile Station Control Message (T1T2 = %d)\n", t1t2); if (t1t2 == 1) amps->rx_focc_word_count = 1; if (t1t2 == 0 || t1t2 == 1) { @@ -3120,7 +3121,7 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word) w = &word2_extended_address_word_b; goto decode; } - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Decoding of more than 2 Control messages not supported\n"); + LOGP_CHAN(DFRAME, LOGL_INFO, "Decoding of more than 2 Control messages not supported\n"); } return; } @@ -3188,14 +3189,14 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word) decode: if (!w) { - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Illegal Overhead Message\n"); + LOGP_CHAN(DFRAME, LOGL_INFO, "Received Illegal Overhead Message\n"); return; } frame = amps_decode_word(word, w); /* show control filler delay */ if (amps->sender.loopback && ohd == 1) - PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "Round trip delay is %.3f seconds\n", amps->when_received - amps->when_transmitted[frame->ie[AMPS_IE_1111]]); + LOGP_CHAN(DDSP, LOGL_NOTICE, "Round trip delay is %.3f seconds\n", amps->when_received - amps->when_transmitted[frame->ie[AMPS_IE_1111]]); } /* get word from data bits and call decoder function @@ -3214,24 +3215,24 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first) amps->rx_recc_word_count = 0; amps->rx_recc_nawc = nawc; if (f == 0) { - PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received first word, but F bit is not set.\n"); + LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received first word, but F bit is not set.\n"); return 0; } } else { if (f == 1) { - PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received additional word, but F bit is set.\n"); + LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received additional word, but F bit is set.\n"); return 0; } amps->rx_recc_nawc--; if (amps->rx_recc_nawc != nawc) { - PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received additional word with NAWC mismatch!\n"); + LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received additional word with NAWC mismatch!\n"); } } msg_count = amps->rx_recc_word_count; if (msg_count == 8) { - PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received too many words.\n"); + LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received too many words.\n"); return 0; } @@ -3268,7 +3269,7 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first) if (!w) { - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Illegal RECC Message\n"); + LOGP_CHAN(DFRAME, LOGL_INFO, "Received Illegal RECC Message\n"); goto done; } @@ -3333,7 +3334,7 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first) amps->rx_recc_dialing[31] = digit2number[frame->ie[AMPS_IE_DIGIT_32]]; } - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "expecting %d more word(s) to come\n", amps->rx_recc_nawc); + LOGP_CHAN(DFRAME, LOGL_INFO, "expecting %d more word(s) to come\n", amps->rx_recc_nawc); if (msg_count >= 3 && amps->rx_recc_nawc == 0) { /* if no digit messages are present, send NULL as dial string (paging reply) */ @@ -3400,16 +3401,16 @@ static void amps_encode_focc_bits(uint64_t word_a, uint64_t word_b, char *bits) bits[k] = '\0'; #ifdef BIT_DEBUGGING - if (debuglevel == DEBUG_DEBUG) { + if (loglevel == LOGL_DEBUG) { char text[64]; strncpy(text, bits, 23); text[23] = '\0'; - PDEBUG(DFRAME, DEBUG_INFO, "TX FOCC: %s\n", text); + LOGP(DFRAME, LOGL_INFO, "TX FOCC: %s\n", text); for (i = 0; i < 10; i++) { strncpy(text, bits + 23 + i * 44, 44); text[44] = '\0'; - PDEBUG(DFRAME, DEBUG_DEBUG, " word %c - %s\n", (i & 1) ? 'b' : 'a', text); + LOGP(DFRAME, LOGL_DEBUG, " word %c - %s\n", (i & 1) ? 'b' : 'a', text); } } #endif @@ -3440,8 +3441,8 @@ static void amps_encode_fvc_bits(uint64_t word_a, char *bits) bits[k] = '\0'; #ifdef BIT_DEBUGGING - if (debuglevel == DEBUG_DEBUG) { - PDEBUG(DFRAME, DEBUG_INFO, "TX FVC: %s\n", bits); + if (loglevel == LOGL_DEBUG) { + LOGP(DFRAME, LOGL_INFO, "TX FVC: %s\n", bits); } #endif } @@ -3511,7 +3512,7 @@ int amps_encode_frame_focc(amps_t *amps, char *bits) if (++amps->tx_focc_frame_count >= amps->si.overhead_repeat) amps->tx_focc_frame_count = 0; if (debug) - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Subsequent system/filler frames are not show, to prevent flooding the output.\n"); + LOGP_CHAN(DFRAME, LOGL_INFO, "Subsequent system/filler frames are not show, to prevent flooding the output.\n"); amps->tx_focc_debugged = 1; send: @@ -3626,17 +3627,17 @@ static void amps_decode_bits_focc(amps_t *amps, const char *bits) else idle = 0; - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX FOCC: B/I = %s\n", (idle) ? "idle" : "busy"); - if (debuglevel == DEBUG_DEBUG) { + LOGP_CHAN(DFRAME, LOGL_INFO, "RX FOCC: B/I = %s\n", (idle) ? "idle" : "busy"); + if (loglevel == LOGL_DEBUG) { char text[64]; for (i = 0; i < 10; i++) { strncpy(text, bits + i * 44, 44); text[44] = '\0'; if ((i & 1) == 0) - PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word a - %s%s\n", text, (crc_a_ok[i >> 1]) ? " ok" : " BAD CRC!"); + LOGP_CHAN(DFRAME, LOGL_DEBUG, " word a - %s%s\n", text, (crc_a_ok[i >> 1]) ? " ok" : " BAD CRC!"); else - PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word b - %s%s\n", text, (crc_b_ok[i >> 1]) ? " ok" : " BAD CRC!"); + LOGP_CHAN(DFRAME, LOGL_DEBUG, " word b - %s%s\n", text, (crc_b_ok[i >> 1]) ? " ok" : " BAD CRC!"); } } @@ -3712,7 +3713,7 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first) crc_ok++; } if (crc_ok) { - PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Seems we RX FOCC frame due to loopback, ignoring!\n"); + LOGP_CHAN(DFRAME, LOGL_NOTICE, "Seems we RX FOCC frame due to loopback, ignoring!\n"); return 0; } bits_ -= 221; @@ -3724,24 +3725,24 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first) } if (first) { - if (debuglevel == DEBUG_DEBUG || crc_ok_count > 0) { - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX RECC: DCC=%d (%d of 5 CRCs are ok)\n", dcc, crc_ok_count); + if (loglevel == LOGL_DEBUG || crc_ok_count > 0) { + LOGP_CHAN(DFRAME, LOGL_INFO, "RX RECC: DCC=%d (%d of 5 CRCs are ok)\n", dcc, crc_ok_count); if (dcc != amps->si.dcc) { - PDEBUG(DFRAME, DEBUG_INFO, "received DCC=%d mismatches the base station's DCC=%d\n", dcc, amps->si.dcc); + LOGP(DFRAME, LOGL_INFO, "received DCC=%d mismatches the base station's DCC=%d\n", dcc, amps->si.dcc); return 0; } } } else { - if (debuglevel == DEBUG_DEBUG || crc_ok_count > 0) - PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX RECC: (%d of 5 CRCs are ok)\n", crc_ok_count); + if (loglevel == LOGL_DEBUG || crc_ok_count > 0) + LOGP_CHAN(DFRAME, LOGL_INFO, "RX RECC: (%d of 5 CRCs are ok)\n", crc_ok_count); } - if (debuglevel == DEBUG_DEBUG) { + if (loglevel == LOGL_DEBUG) { char text[64]; for (i = 0; i < 5; i++) { strncpy(text, bits + i * 48, 48); text[48] = '\0'; - PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word - %s%s\n", text, (crc_a_ok[i]) ? " ok" : " BAD CRC!"); + LOGP_CHAN(DFRAME, LOGL_DEBUG, " word - %s%s\n", text, (crc_a_ok[i]) ? " ok" : " BAD CRC!"); } } @@ -3756,7 +3757,7 @@ int amps_decode_frame(amps_t *amps, const char *bits, int count, double level, d /* not if additional words are received without sync */ if (count != 240) { - PDEBUG_CHAN(DDSP, DEBUG_INFO, "RX Level: %.0f%% Quality: %.0f%% Polarity: %s\n", level * 100.0, quality * 100.0, (negative) ? "NEGATIVE" : "POSITIVE"); + LOGP_CHAN(DDSP, LOGL_INFO, "RX Level: %.0f%% Quality: %.0f%% Polarity: %s\n", level * 100.0, quality * 100.0, (negative) ? "NEGATIVE" : "POSITIVE"); } if (count == 441) { amps_decode_bits_focc(amps, bits); @@ -3765,7 +3766,7 @@ int amps_decode_frame(amps_t *amps, const char *bits, int count, double level, d } else if (count == 240) { more = amps_decode_bits_recc(amps, bits, 0); } else { - PDEBUG_CHAN(DFRAME, DEBUG_ERROR, "Frame with unknown length = %d, please fix!\n", count); + LOGP_CHAN(DFRAME, LOGL_ERROR, "Frame with unknown length = %d, please fix!\n", count); } return more; diff --git a/src/amps/jtacs_tones.c b/src/amps/jtacs_tones.c index 1530b57..e54918a 100644 --- a/src/amps/jtacs_tones.c +++ b/src/amps/jtacs_tones.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "tones.h" static int16_t pattern_ringback[1000] = { 0x00e5, 0x0070, 0x001c, 0x0001, 0x001c, 0x0070, 0x00e5, 0x0168, diff --git a/src/amps/main_common.c b/src/amps/main_common.c index d7a5ed5..9acaa61 100644 --- a/src/amps/main_common.c +++ b/src/amps/main_common.c @@ -24,7 +24,7 @@ #include <errno.h> #include "../libsample/sample.h" #include "../libmobile/main_mobile.h" -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" #include "../libmobile/call.h" #include "../liboptions/options.h" #include "../libfm/fm.h" @@ -44,6 +44,13 @@ int send_callerid = 0; int dcc = 0, scc = 0, sid = 0, regh = 1, regr = 1, pureg = 0, pdreg = 0, locaid = -1, regincr = 300, bis = 0; int tolerant = 0; +static void print_location_area_note(void) +{ + /* - - */ + printf(" Warning: Older phones may not like this and show 'No Service'!\n"); + printf(" Note: This feature was added 1995 to the standard, it might not work.\n"); +} + void print_help(const char *arg0) { if (!tacs) @@ -97,14 +104,14 @@ void print_help(const char *arg0) printf(" many second the phone waits before it re-registers.\n"); printf(" -S --sysinfo pureg=0 | pureg=1\n"); printf(" If 1, phone registers on every power on (default = '%d')\n", pureg); - printf(" Warning: Older phones may not like this and show 'No Service'!\n"); + print_location_area_note(); printf(" -S --sysinfo pdreg=0 | pdreg=1\n"); printf(" If 1, phone de-registers on every power down (default = '%d')\n", pureg); - printf(" Warning: Older phones may not like this and show 'No Service'!\n"); + print_location_area_note(); printf(" -S --sysinfo locaid=<location area ID > | locaid=-1 to disable\n"); printf(" (default = '%d')\n", locaid); printf(" If it changes, phone re-registers.\n"); - printf(" Warning: Older phones may not like this and show 'No Service'!\n"); + print_location_area_note(); printf(" -S --sysinfo regh=0 | regh=1\n"); printf(" If 1, phone registers only if System ID matches (default = '%d')\n", regh); printf(" -S --sysinfo regr=0 | regr=1\n"); @@ -423,6 +430,7 @@ fail: amps_destroy(sender_head); /* exits */ + main_mobile_exit(); fm_exit(); options_free(); diff --git a/src/amps/sysinfo.c b/src/amps/sysinfo.c index ce060b2..bfd31b8 100644 --- a/src/amps/sysinfo.c +++ b/src/amps/sysinfo.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <string.h> #include <stdlib.h> +#include <stdbool.h> #include <time.h> #include "../libsample/sample.h" #include "amps.h" diff --git a/src/amps/tacs_outoforder.c b/src/amps/tacs_outoforder.c index ab2009a..e217b24 100644 --- a/src/amps/tacs_outoforder.c +++ b/src/amps/tacs_outoforder.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "outoforder.h" static int16_t pattern[] = { 0x0000, 0x0000, 0xffff, 0x0002, 0xfffe, 0x0003, 0xfffd, 0x0001, diff --git a/src/amps/tacs_tones.c b/src/amps/tacs_tones.c index 577dad7..8c1815f 100644 --- a/src/amps/tacs_tones.c +++ b/src/amps/tacs_tones.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "tones.h" static int16_t pattern_ringback[] = { 0x000b, 0x0008, 0x000d, 0x000e, 0x000d, 0x0012, 0x0011, 0xffcd, diff --git a/src/amps/transaction.c b/src/amps/transaction.c index f8a4aee..1abd403 100644 --- a/src/amps/transaction.c +++ b/src/amps/transaction.c @@ -21,7 +21,7 @@ #include <stdint.h> #include <stdlib.h> #include "../libsample/sample.h" -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" #include "../libmobile/call.h" #include "../libmobile/cause.h" #include "amps.h" @@ -133,7 +133,7 @@ transaction_t *create_transaction(amps_t *amps, enum amps_trans_state state, uin 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 already pending transaction for subscriber '%s', deleting!\n", number); + LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s', deleting!\n", number); destroy_transaction(trans); if (old_amps) /* should be... */ amps_go_idle(old_amps); @@ -143,11 +143,11 @@ transaction_t *create_transaction(amps_t *amps, enum amps_trans_state state, uin 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); trans_new_state(trans, state); trans->min1 = min1; @@ -159,7 +159,7 @@ 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 for subscriber '%s'\n", number); + LOGP(DTRANS, LOGL_INFO, "Created transaction for subscriber '%s'\n", number); link_transaction(trans, amps); @@ -172,9 +172,9 @@ void destroy_transaction(transaction_t *trans) unlink_transaction(trans); const char *number = amps_min2number(trans->min1, trans->min2); - PDEBUG(DTRANS, DEBUG_INFO, "Destroying transaction for subscriber '%s'\n", number); + LOGP(DTRANS, LOGL_INFO, "Destroying transaction for subscriber '%s'\n", number); - timer_exit(&trans->timer); + osmo_timer_del(&trans->timer); trans_new_state(trans, 0); @@ -187,7 +187,7 @@ void link_transaction(transaction_t *trans, amps_t *amps) transaction_t **transp; /* attach to end of list, so first transaction is served first */ - PDEBUG(DTRANS, DEBUG_DEBUG, "Linking transaction %p to amps %p\n", trans, amps); + LOGP(DTRANS, LOGL_DEBUG, "Linking transaction %p to amps %p\n", trans, amps); trans->amps = amps; trans->next = NULL; transp = &s->trans_list; @@ -203,12 +203,12 @@ void unlink_transaction(transaction_t *trans) transaction_t **transp; /* unlink */ - PDEBUG(DTRANS, DEBUG_DEBUG, "Unlinking transaction %p from amps %p\n", trans, trans->amps); + LOGP(DTRANS, LOGL_DEBUG, "Unlinking transaction %p from amps %p\n", trans, trans->amps); transp = &trans->amps->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; @@ -224,7 +224,7 @@ transaction_t *search_transaction_number(amps_t *amps, uint32_t min1, uint16_t m if (trans->min1 == min1 && trans->min2 == min2) { const char *number = amps_min2number(trans->min1, trans->min2); - PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", number); + LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", number); return trans; } trans = trans->next; @@ -243,7 +243,7 @@ transaction_t *search_transaction_callref(amps_t *amps, int callref) while (trans) { if (trans->callref == callref) { const char *number = amps_min2number(trans->min1, trans->min2); - PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", number); + LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", number); return trans; } trans = trans->next; @@ -254,7 +254,7 @@ transaction_t *search_transaction_callref(amps_t *amps, int callref) void trans_new_state(transaction_t *trans, int state) { - PDEBUG(DTRANS, DEBUG_INFO, "Transaction state %s -> %s\n", trans_state_name(trans->state), trans_state_name(state)); + LOGP(DTRANS, LOGL_INFO, "Transaction state %s -> %s\n", trans_state_name(trans->state), trans_state_name(state)); trans->state = state; amps_display_status(); } @@ -263,12 +263,12 @@ void amps_flush_other_transactions(amps_t *amps, transaction_t *trans) { /* flush after this very trans */ while (trans->next) { - PDEBUG(DTRANS, DEBUG_NOTICE, "Kicking other pending transaction\n"); + LOGP(DTRANS, LOGL_NOTICE, "Kicking other pending transaction\n"); destroy_transaction(trans->next); } /* flush before this very trans */ while (amps->trans_list != trans) { - PDEBUG(DTRANS, DEBUG_NOTICE, "Kicking other pending transaction\n"); + LOGP(DTRANS, LOGL_NOTICE, "Kicking other pending transaction\n"); destroy_transaction(amps->trans_list); } } diff --git a/src/amps/transaction.h b/src/amps/transaction.h index 6cd6441..29da337 100644 --- a/src/amps/transaction.h +++ b/src/amps/transaction.h @@ -39,7 +39,7 @@ typedef struct transaction { char caller_id[33]; /* id of calling phone */ char dialing[33]; /* number dialed by the phone */ enum amps_trans_state state; /* state of transaction */ - struct timer timer; /* for varous timeouts */ + struct osmo_timer_list timer; /* for varous timeouts */ int sat_detected; /* state if we detected SAT */ int dtx; /* if set, DTX is used with this call */ } transaction_t; @@ -53,6 +53,6 @@ transaction_t *search_transaction_number(amps_t *amps, uint32_t min1, uint16_t m transaction_t *search_transaction_callref(amps_t *amps, int callref); void trans_new_state(transaction_t *trans, int state); void amps_flush_other_transactions(amps_t *amps, transaction_t *trans); -void transaction_timeout(struct timer *timer); +void transaction_timeout(void *data); const char *trans_short_state_name(int state); diff --git a/src/amps/usa_congestion.c b/src/amps/usa_congestion.c index ed1b87b..cc9e5fa 100644 --- a/src/amps/usa_congestion.c +++ b/src/amps/usa_congestion.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "congestion.h" static int16_t pattern[] = { 0xfffd, 0x0004, 0xfffb, 0x0004, 0xfffe, 0x0001, 0x0001, 0xfffe, diff --git a/src/amps/usa_invalidnumber.c b/src/amps/usa_invalidnumber.c index a272f7c..e470a90 100644 --- a/src/amps/usa_invalidnumber.c +++ b/src/amps/usa_invalidnumber.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "invalidnumber.h" static int16_t pattern[] = { 0xfffe, 0x0001, 0xffff, 0x0001, 0xffff, 0x0002, 0xfffe, 0x0002, diff --git a/src/amps/usa_noanswer.c b/src/amps/usa_noanswer.c index 5bddcb6..06ef7ba 100644 --- a/src/amps/usa_noanswer.c +++ b/src/amps/usa_noanswer.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "noanswer.h" static int16_t pattern[] = { 0xfe24, 0xfd20, 0xfd2c, 0xfdb5, 0xfeba, 0xfe20, 0xfd41, 0xfe32, diff --git a/src/amps/usa_outoforder.c b/src/amps/usa_outoforder.c index de5947c..ec15a29 100644 --- a/src/amps/usa_outoforder.c +++ b/src/amps/usa_outoforder.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "outoforder.h" static int16_t pattern[] = { 0xfeae, 0xfde4, 0xfe26, 0xfea7, 0xfe94, 0xfe8a, 0xfeb4, 0xfe3b, diff --git a/src/amps/usa_tones.c b/src/amps/usa_tones.c index b919775..3b60226 100644 --- a/src/amps/usa_tones.c +++ b/src/amps/usa_tones.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "tones.h" static int16_t pattern_ringback[] = { 0x0070, 0x00dd, 0x013b, 0x0192, 0x0191, 0x0153, 0x0099, 0xffb2, |