diff options
Diffstat (limited to 'src/fuvst')
-rw-r--r-- | src/fuvst/Makefile.am | 16 | ||||
-rwxr-xr-x | src/fuvst/fuvst.c | 213 | ||||
-rwxr-xr-x | src/fuvst/main.c | 5 | ||||
-rwxr-xr-x | src/fuvst/mup.c | 157 | ||||
-rw-r--r-- | src/fuvst/sniffer.c | 32 | ||||
-rw-r--r-- | src/fuvst/systemmeldungen.c | 6 |
6 files changed, 225 insertions, 204 deletions
diff --git a/src/fuvst/Makefile.am b/src/fuvst/Makefile.am index 090a433..983ea4e 100644 --- a/src/fuvst/Makefile.am +++ b/src/fuvst/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -Wmissing-prototypes -g $(all_includes) if HAVE_ALSA bin_PROGRAMS = \ @@ -15,13 +15,10 @@ fuvst_LDADD = \ ../anetz/libgermanton.a \ ../cnetz/libcnetztones.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/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 \ @@ -31,8 +28,10 @@ fuvst_LDADD = \ $(top_builddir)/src/libwave/libwave.a \ $(top_builddir)/src/libsample/libsample.a \ $(top_builddir)/src/libsound/libsound.a \ - $(top_builddir)/src/libg711/libg711.a \ $(top_builddir)/src/libaaimage/libaaimage.a \ + $(top_builddir)/src/liblogging/liblogging.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOCC_LIBS) \ $(ALSA_LIBS) \ -lm @@ -41,13 +40,10 @@ fuvst_sniffer_SOURCES = \ fuvst_sniffer_LDADD = \ $(COMMON_LA) \ $(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/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 \ @@ -57,8 +53,10 @@ fuvst_sniffer_LDADD = \ $(top_builddir)/src/libwave/libwave.a \ $(top_builddir)/src/libsample/libsample.a \ $(top_builddir)/src/libsound/libsound.a \ - $(top_builddir)/src/libg711/libg711.a \ $(top_builddir)/src/libaaimage/libaaimage.a \ + $(top_builddir)/src/liblogging/liblogging.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOCC_LIBS) \ $(ALSA_LIBS) \ -lm diff --git a/src/fuvst/fuvst.c b/src/fuvst/fuvst.c index f86b0a8..847876e 100755 --- a/src/fuvst/fuvst.c +++ b/src/fuvst/fuvst.c @@ -35,12 +35,15 @@ #include <time.h> #include <inttypes.h> #include "../libsample/sample.h" -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" #include "../liboptions/options.h" #include "../libmobile/call.h" #include "../libmobile/cause.h" -#include "../libtimer/timer.h" -#include "../libosmocc/message.h" +#include "../libmobile/get_time.h" +#include "../libmobile/console.h" +#include <osmocom/core/timer.h> +#include <osmocom/core/utils.h> +#include <osmocom/cc/message.h> #include "fuvst.h" /* digital loopback test */ @@ -120,21 +123,21 @@ int config_file(const char *filename) uint8_t byte; if (!fp) { - PDEBUG(DTRANS, DEBUG_ERROR, "Failed to open data base file: '%s'\n", filename); + LOGP(DTRANS, LOGL_ERROR, "Failed to open data base file: '%s'\n", filename); return -EIO; } rc = fread(conf.data, 1, sizeof(conf.data), fp); if (rc < (int)sizeof(conf.data)) { fclose(fp); - PDEBUG(DTRANS, DEBUG_ERROR, "Data base file shorter than %d bytes. This seems not to be a valid config file.\n", (int)sizeof(conf.data)); + LOGP(DTRANS, LOGL_ERROR, "Data base file shorter than %d bytes. This seems not to be a valid config file.\n", (int)sizeof(conf.data)); return -EIO; } rc = fread(&byte, 1, 1, fp); if (rc == 1) { fclose(fp); - PDEBUG(DTRANS, DEBUG_ERROR, "Data base file larger than %d bytes. (Don't use the EEPROM config format, use the MSC config format.)\n", (int)sizeof(conf.data)); + LOGP(DTRANS, LOGL_ERROR, "Data base file larger than %d bytes. (Don't use the EEPROM config format, use the MSC config format.)\n", (int)sizeof(conf.data)); return -EIO; } @@ -156,10 +159,10 @@ static void config_send(uint8_t ident, uint8_t job, uint16_t offset, uint16_t le uint32_t checksum = 0; uint8_t rc = 1; /* Auftrag angenommen */ - PDEBUG(DCNETZ, DEBUG_NOTICE, "MSC requests data base block. (offset=%d, length=%d)\n", offset, length); + LOGP(DCNETZ, LOGL_NOTICE, "MSC requests data base block. (offset=%d, length=%d)\n", offset, length); if (!conf.loaded) { - PDEBUG(DCNETZ, DEBUG_ERROR, "MSC requests data base, but no file name given. Please give file name!\n"); + LOGP(DCNETZ, LOGL_ERROR, "MSC requests data base, but no file name given. Please give file name!\n"); error: /* return error */ len = encode_xedbu_1(&opcode, &data, 16, job, 0); @@ -168,7 +171,7 @@ error: } if (offset + length > sizeof(conf.data)) { - PDEBUG(DCNETZ, DEBUG_ERROR, "Requested date out of range!\n"); + LOGP(DCNETZ, LOGL_ERROR, "Requested date out of range!\n"); goto error; } @@ -262,7 +265,7 @@ void add_emergency(const char *number) emerg = calloc(1, sizeof(*emerg)); if (!emerg) { - PDEBUG(DTRANS, DEBUG_ERROR, "No memory!\n"); + LOGP(DTRANS, LOGL_ERROR, "No memory!\n"); return; } @@ -288,7 +291,7 @@ static int check_emerg(const char *number) if (!emerg) return 0; - PDEBUG(DCNETZ, DEBUG_NOTICE, "Emergency call, matching prefix '%s' in list of emergency numbers.\n", emerg->number); + LOGP(DCNETZ, LOGL_NOTICE, "Emergency call, matching prefix '%s' in list of emergency numbers.\n", emerg->number); return 1; } @@ -303,6 +306,7 @@ typedef struct cnetz_database { uint8_t futln_fuvst; uint16_t futln_rest; uint8_t chip; + int32_t sicherungscode; } cnetz_db_t; static cnetz_db_t *cnetz_db_head; @@ -337,12 +341,12 @@ static void remove_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_res while (*dbp && *dbp != db) dbp = &((*dbp)->next); if (!(*dbp)) { - PDEBUG(DDB, DEBUG_ERROR, "Subscriber not in list, please fix!!\n"); + LOGP(DDB, LOGL_ERROR, "Subscriber not in list, please fix!!\n"); abort(); } *dbp = db->next; - PDEBUG(DDB, DEBUG_INFO, "Removing subscriber '%d,%d,%d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest); + LOGP(DDB, LOGL_INFO, "Removing subscriber '%d,%d,%d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest); /* remove */ free(db); @@ -353,13 +357,13 @@ static void flush_db(void) cnetz_db_t *db; while ((db = cnetz_db_head)) { - PDEBUG(DDB, DEBUG_INFO, "Removing subscriber '%d,%d,%d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest); + LOGP(DDB, LOGL_INFO, "Removing subscriber '%d,%d,%d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest); cnetz_db_head = db->next; free(db); } } -static void add_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, uint8_t chip) +static void add_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, uint8_t chip, int32_t sicherungscode) { cnetz_db_t *db, **dbp; @@ -370,15 +374,16 @@ static void add_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, /* add */ db = calloc(1, sizeof(*db)); if (!db) { - PDEBUG(DDB, DEBUG_ERROR, "No memory!\n"); + LOGP(DDB, LOGL_ERROR, "No memory!\n"); return; } db->futln_nat = futln_nat; db->futln_fuvst = futln_fuvst; db->futln_rest = futln_rest; db->chip = chip; + db->sicherungscode = sicherungscode; - PDEBUG(DDB, DEBUG_INFO, "Adding subscriber '%d,%d,%d' to database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest); + LOGP(DDB, LOGL_INFO, "Adding subscriber '%d,%d,%d' to database. (reader=%s, sicherungs-code=%d)\n", db->futln_nat, db->futln_fuvst, db->futln_rest, (db->chip) ? "chip" : "magent", db->sicherungscode); /* attach to end of list */ dbp = &cnetz_db_head; @@ -392,7 +397,7 @@ static void add_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, */ /* Release timeout */ -#define RELEASE_TO 3.0 +#define RELEASE_TO 3,0 /* BSC originated Ident-Numbers */ #define IDENT_BSC_FROM 0x9f @@ -425,21 +430,26 @@ typedef struct transaction { fuvst_t *spk; /* assigned SPK */ char number[17]; /* dialed by mobile */ int sonderruf; /* an emergency call */ - struct timer timer; /* release timer */ + struct osmo_timer_list timer; /* release timer */ } transaction_t; transaction_t *trans_list = NULL; -const char *transaction2rufnummer(transaction_t *trans) +static const char *nut2rufnummer(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest) { static char rufnummer[32]; /* make GCC happy (overflow check) */ - sprintf(rufnummer, "%d%d%05d", trans->futln_nat, trans->futln_fuvst, trans->futln_rest); + sprintf(rufnummer, "%d%d%05d", futln_nat, futln_fuvst, futln_rest); return rufnummer; } -const char *state_name(enum call_state state) +static const char *transaction2rufnummer(transaction_t *trans) +{ + return nut2rufnummer(trans->futln_nat, trans->futln_fuvst, trans->futln_rest); +} + +static const char *state_name(enum call_state state) { static char invalid[16]; @@ -468,7 +478,7 @@ const char *state_name(enum call_state state) return invalid; } -void display_status(void) +static void display_status(void) { sender_t *sender; fuvst_t *fuvst; @@ -500,12 +510,12 @@ static void new_call_state(transaction_t *trans, enum call_state new_state) { if (trans->state == new_state) return; - PDEBUG(DTRANS, DEBUG_INFO, "State change: %s -> %s\n", state_name(trans->state), state_name(new_state)); + LOGP(DTRANS, LOGL_INFO, "State change: %s -> %s\n", state_name(trans->state), state_name(new_state)); trans->state = new_state; display_status(); } -transaction_t *search_transaction_number(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest) +static transaction_t *search_transaction_number(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest) { transaction_t *trans = trans_list; @@ -514,7 +524,7 @@ transaction_t *search_transaction_number(uint8_t futln_nat, uint8_t futln_fuvst, && trans->futln_fuvst == futln_fuvst && trans->futln_rest == futln_rest) { const char *rufnummer = transaction2rufnummer(trans); - PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer); + LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer); return trans; } trans = trans->next; @@ -523,14 +533,14 @@ transaction_t *search_transaction_number(uint8_t futln_nat, uint8_t futln_fuvst, return NULL; } -transaction_t *search_transaction_ident(uint8_t ident) +static transaction_t *search_transaction_ident(uint8_t ident) { transaction_t *trans = trans_list; while (trans) { if (trans->ident == ident) { const char *rufnummer = transaction2rufnummer(trans); - PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer); + LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer); return trans; } trans = trans->next; @@ -539,7 +549,7 @@ transaction_t *search_transaction_ident(uint8_t ident) return NULL; } -transaction_t *search_transaction_callref(int callref) +static transaction_t *search_transaction_callref(int callref) { transaction_t *trans = trans_list; @@ -549,7 +559,7 @@ transaction_t *search_transaction_callref(int callref) while (trans) { if (trans->callref == callref) { const char *rufnummer = transaction2rufnummer(trans); - PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer); + LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer); return trans; } trans = trans->next; @@ -564,9 +574,9 @@ static void destroy_transaction(transaction_t *trans) transaction_t **transp; const char *rufnummer = transaction2rufnummer(trans); - PDEBUG(DTRANS, DEBUG_INFO, "Destroying transaction for subscriber '%s'\n", rufnummer); + LOGP(DTRANS, LOGL_INFO, "Destroying transaction for subscriber '%s'\n", rufnummer); - timer_exit(&trans->timer); + osmo_timer_del(&trans->timer); /* check for old callref (before removal) then detach SPK * if SPK has been reused by BS, our old callref will not match, @@ -580,7 +590,7 @@ static void destroy_transaction(transaction_t *trans) 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; @@ -591,11 +601,11 @@ static void destroy_transaction(transaction_t *trans) } /* Timeout handling */ -void trans_timeout(struct timer *timer) +static void trans_timeout(void *data) { - transaction_t *trans = (transaction_t *)timer->priv; + transaction_t *trans = data; - PDEBUG(DTRANS, DEBUG_NOTICE, "Releasing transaction due to timeout.\n"); + LOGP(DTRANS, LOGL_NOTICE, "Releasing transaction due to timeout.\n"); if (trans->callref) call_up_release(trans->callref, CAUSE_NORMAL); trans->callref = 0; @@ -611,7 +621,7 @@ static transaction_t *create_transaction(uint8_t ident, uint8_t futln_nat, uint8 trans = search_transaction_number(futln_nat, futln_fuvst, futln_rest); if (trans && mo) { const char *rufnummer = transaction2rufnummer(trans); - PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s', dropping that!\n", rufnummer); + LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s', dropping that!\n", rufnummer); if (trans->callref) call_up_release(trans->callref, CAUSE_NORMAL); trans->callref = 0; @@ -620,13 +630,13 @@ static transaction_t *create_transaction(uint8_t ident, uint8_t futln_nat, uint8 } if (trans) { const char *rufnummer = transaction2rufnummer(trans); - PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s', we are busy!\n", rufnummer); + LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s', we are busy!\n", rufnummer); return NULL; } trans = calloc(1, sizeof(*trans)); if (!trans) { - PDEBUG(DTRANS, DEBUG_ERROR, "No memory!\n"); + LOGP(DTRANS, LOGL_ERROR, "No memory!\n"); return NULL; } @@ -636,10 +646,10 @@ static transaction_t *create_transaction(uint8_t ident, uint8_t futln_nat, uint8 trans->futln_fuvst = futln_fuvst; trans->futln_rest = futln_rest; - timer_init(&trans->timer, trans_timeout, trans); + osmo_timer_setup(&trans->timer, trans_timeout, trans); const char *rufnummer = transaction2rufnummer(trans); - PDEBUG(DTRANS, DEBUG_INFO, "Creating transaction for subscriber '%s'\n", rufnummer); + LOGP(DTRANS, LOGL_INFO, "Creating transaction for subscriber '%s'\n", rufnummer); /* attach to end of list, so first transaction is served first */ transp = &trans_list; @@ -712,7 +722,7 @@ static fuvst_t *get_spk(uint8_t Q) } /* Convert 'Ausloesegrund' of C-Netz base station to ISDN cause */ -int cnetz_fufst2cause(uint8_t X) +static int cnetz_fufst2cause(uint8_t X) { switch (X) { case 0: /* undefiniert */ @@ -735,7 +745,7 @@ int cnetz_fufst2cause(uint8_t X) } /* Convert ISDN cause to 'Ausloesegrund' of C-Netz mobile station */ -uint8_t cnetz_cause2futln(int cause) +static uint8_t cnetz_cause2futln(int cause) { switch (cause) { case CAUSE_NORMAL: @@ -763,14 +773,14 @@ static int message_send(uint8_t ident, uint8_t opcode, uint8_t *data, int len) if (!zzk) zzk = get_zzk(0); if (!zzk) { - PDEBUG(DCNETZ, DEBUG_ERROR, "No ZZK or link down!\n"); + LOGP(DCNETZ, LOGL_ERROR, "No ZZK or link down!\n"); return -EIO; } uint8_t buffer[len + 2]; - if (debuglevel == DEBUG_DEBUG || opcode != OPCODE_XEDBU) - PDEBUG(DCNETZ, DEBUG_INFO, "TX Message to BS: link=%s ident=0x%02x OP=%02XH %s\n", zzk->sender.kanal, ident, opcode, debug_hex(data, len)); + if (loglevel == LOGL_DEBUG || opcode != OPCODE_XEDBU) + LOGP(DCNETZ, LOGL_INFO, "TX Message to BS: link=%s ident=0x%02x OP=%02XH %s\n", zzk->sender.kanal, ident, opcode, osmo_hexdump(data, len)); /* assemble Ident, swap Opcode and add data */ slc = ident & 0xf; @@ -808,25 +818,25 @@ static void release_for_emergency(void) /* found idle channel */ if (sender) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Emergency call received. We have a free channel available.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Emergency call received. We have a free channel available.\n"); return; } /* found no normal call (no emergency) */ if (!last_trans) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Emergency call received. We cannot free a channel, because there is no non-emergency call.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Emergency call received. We cannot free a channel, because there is no non-emergency call.\n"); return; } /* releasing the last call in list */ - PDEBUG(DCNETZ, DEBUG_NOTICE, "Emergency call received. We free a channel.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Emergency call received. We free a channel.\n"); len = encode_aau(&opcode, &data, trans->spk_nr, 0, cnetz_cause2futln(CAUSE_NORMAL)); message_send(trans->ident, opcode, data, len); call_up_release(trans->callref, CAUSE_NORMAL); trans->callref = 0; new_call_state(trans, STATE_RELEASE); - timer_start(&trans->timer, RELEASE_TO); + osmo_timer_schedule(&trans->timer, RELEASE_TO); } /* MTP data message from lower layer */ @@ -847,12 +857,12 @@ static void message_receive(fuvst_t *zzk, uint8_t ident, uint8_t opcode, uint8_t uint16_t s = 0; uint8_t u = 0, b = 0, l = 0; uint16_t T_array[3]; - uint8_t U_array[3], N_array[3], l_array[3]; + uint8_t U_array[3], N_array[3], b_array[3]; int i, num; char number[17]; - if (debuglevel == DEBUG_DEBUG || opcode != OPCODE_YLSMF) - PDEBUG(DCNETZ, DEBUG_INFO, "RX Message from BS: link=%s ident=0x%02x OP=%02XH %s\n", zzk->sender.kanal, ident, opcode, debug_hex(data, len)); + if (loglevel == LOGL_DEBUG || opcode != OPCODE_YLSMF) + LOGP(DCNETZ, LOGL_INFO, "RX Message from BS: link=%s ident=0x%02x OP=%02XH %s\n", zzk->sender.kanal, ident, opcode, osmo_hexdump(data, len)); switch (opcode) { case OPCODE_SWAF: /* BS restarts */ @@ -866,7 +876,7 @@ static void message_receive(fuvst_t *zzk, uint8_t ident, uint8_t opcode, uint8_t message_send(5, opcode, NULL, 0); #endif if (warmstart) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Forcing a warm start and load the config...\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Forcing a warm start and load the config...\n"); warmstart = 0; len = encode_yaaau(&opcode, &data, 42); message_send(0, opcode, data, len); @@ -922,7 +932,8 @@ static void message_receive(fuvst_t *zzk, uint8_t ident, uint8_t opcode, uint8_t break; case OPCODE_EBAF: /* enter BS (inscription) */ decode_ebaf(data, len, &T, &U, &N, &s, &u, &b, &l); - add_db(N, U, T, l); + add_db(N, U, T, b, (!l || !b) ? s : -1); + console_inscription(nut2rufnummer(N, U, T)); len = encode_ebpqu(&opcode, &data); message_send(ident, opcode, data, len); break; @@ -932,11 +943,11 @@ static void message_receive(fuvst_t *zzk, uint8_t ident, uint8_t opcode, uint8_t break; case OPCODE_GVAF: /* MO call */ decode_gvaf(data, len, &T, &U, &N, number); - PDEBUG(DCNETZ, DEBUG_INFO, "Call from mobile.\n"); + LOGP(DCNETZ, LOGL_INFO, "Call from mobile.\n"); goto outgoing; case OPCODE_GVWAF: /* MO call (queue) */ decode_gvaf(data, len, &T, &U, &N, number); - PDEBUG(DCNETZ, DEBUG_INFO, "Call from mobile (queue).\n"); + LOGP(DCNETZ, LOGL_INFO, "Call from mobile (queue).\n"); outgoing: trans = create_transaction(ident, N, U, T, 1); if (!trans) { @@ -958,7 +969,7 @@ outgoing: trans = search_transaction_ident(ident); if (!trans) break; - PDEBUG(DCNETZ, DEBUG_INFO, "Call to mobile is alerting (queue).\n"); + LOGP(DCNETZ, LOGL_INFO, "Call to mobile is alerting (queue).\n"); new_call_state(trans, STATE_MT_QUEUE); if (trans->callref) call_up_alerting(trans->callref); @@ -968,7 +979,7 @@ outgoing: trans = search_transaction_ident(ident); if (!trans) break; - PDEBUG(DCNETZ, DEBUG_INFO, "Call to mobile has been answered.\n"); + LOGP(DCNETZ, LOGL_INFO, "Call to mobile has been answered.\n"); new_call_state(trans, STATE_MT_CONNECT); if (trans->callref) call_up_answer(trans->callref, transaction2rufnummer(trans)); @@ -986,7 +997,7 @@ outgoing: trans->spk_nr = Q; /* SPK not exist, release */ if (!trans->spk) { - PDEBUG(DCNETZ, DEBUG_ERROR, "SpK '%d' requested by BS not configured, please configure all SpK that base station has available!\n", Q); + LOGP(DCNETZ, LOGL_ERROR, "SpK '%d' requested by BS not configured, please configure all SpK that base station has available!\n", Q); len = encode_stnqu(&opcode, &data, Q); message_send(ident, opcode, data, len); if (trans->callref) @@ -1002,22 +1013,22 @@ outgoing: message_send(ident, opcode, data, len); /* no callref == outgoing call */ if (!trans->callref) { - PDEBUG(DCNETZ, DEBUG_INFO, "Setup call to network. (Ident = %d, FuTln=%s, number=%s)\n", ident, transaction2rufnummer(trans), trans->number); + LOGP(DCNETZ, LOGL_INFO, "Setup call to network. (Ident = %d, FuTln=%s, number=%s)\n", ident, transaction2rufnummer(trans), trans->number); trans->callref = trans->old_callref = call_up_setup(transaction2rufnummer(trans), trans->number, OSMO_CC_NETWORK_CNETZ_NONE, ""); } else { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Call to mobile is alerting.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Call to mobile is alerting.\n"); new_call_state(trans, STATE_MT_ALERTING); call_up_alerting(trans->callref); } trans->spk->callref = trans->callref; - PDEBUG(DCNETZ, DEBUG_INFO, "Assigned SpK %d to call.\n", trans->spk_nr); + LOGP(DCNETZ, LOGL_INFO, "Assigned SpK %d to call.\n", trans->spk_nr); break; case OPCODE_APF: /* auth response */ decode_apf(data, len, &Q, &a); break; case OPCODE_FAF: /* MCID request */ decode_faf(data, len); - PDEBUG(DCNETZ, DEBUG_NOTICE, "Fangen (MCID) was activated by BS.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Fangen (MCID) was activated by BS.\n"); break; case OPCODE_NAF: /* incoming release (before SPK assignment) */ decode_naf(data, len, &X); @@ -1027,7 +1038,7 @@ outgoing: trans = search_transaction_ident(ident); if (!trans) break; - PDEBUG(DCNETZ, DEBUG_NOTICE, "Call released by BS.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Call released by BS.\n"); new_call_state(trans, STATE_RELEASE); if (trans->callref) call_up_release(trans->callref, cnetz_fufst2cause(X)); @@ -1057,7 +1068,7 @@ outgoing: message_send(ident, opcode, data, len); if (trans->callref) call_up_release(trans->callref, cnetz_fufst2cause(X)); - PDEBUG(DCNETZ, DEBUG_NOTICE, "Call released by BS.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Call released by BS.\n"); new_call_state(trans, STATE_RELEASE); trans->callref = 0; destroy_transaction(trans); @@ -1078,16 +1089,16 @@ outgoing: config_send(ident, PJ, D, L); break; case OPCODE_SADQF: /* transfer of inscription list (aktivdatei) */ - num = decode_sadqf(data, len, &s, &e, l_array, T_array, U_array, N_array); + num = decode_sadqf(data, len, &s, &e, b_array, T_array, U_array, N_array); if (s == 0) flush_db(); for (i = 0; i < num; i++) - add_db(N_array[i], U_array[i], T_array[i], l_array[i]); + add_db(N_array[i], U_array[i], T_array[i], b_array[i], -1); len = encode_ebpqu(&opcode, &data); message_send(ident, opcode, data, len); break; default: - PDEBUG(DCNETZ, DEBUG_INFO, "RX Message from BS with unknown OPcode: %02XH\n", opcode); + LOGP(DCNETZ, LOGL_INFO, "RX Message from BS with unknown OPcode: %02XH\n", opcode); } } @@ -1123,25 +1134,25 @@ static void mtp_receive(void *inst, enum mtp_prim prim, uint8_t slc, uint8_t *da default: cause_text = "MTP link '%s' failed! Trying again.\n"; } - PDEBUG(DCNETZ, DEBUG_NOTICE, cause_text, zzk->sender.kanal); + LOGP(DCNETZ, LOGL_NOTICE, cause_text, zzk->sender.kanal); mtp_send(&zzk->mtp, MTP_PRIM_START, 0, NULL, 0); zzk->link = 0; display_status(); break; case MTP_PRIM_IN_SERVICE: - PDEBUG(DCNETZ, DEBUG_NOTICE, "Link '%s' established.\n", zzk->sender.kanal); + LOGP(DCNETZ, LOGL_NOTICE, "Link '%s' established.\n", zzk->sender.kanal); zzk->link = 1; display_status(); break; case MTP_PRIM_REMOTE_PROCESSOR_OUTAGE: - PDEBUG(DCNETZ, DEBUG_NOTICE, "Link '%s' indicates remote processor outage.\n", zzk->sender.kanal); + LOGP(DCNETZ, LOGL_NOTICE, "Link '%s' indicates remote processor outage.\n", zzk->sender.kanal); break; case MTP_PRIM_REMOTE_PROCESSOR_RECOVERED: - PDEBUG(DCNETZ, DEBUG_NOTICE, "Link '%s' indicates remote processor outage is recovered.\n", zzk->sender.kanal); + LOGP(DCNETZ, LOGL_NOTICE, "Link '%s' indicates remote processor outage is recovered.\n", zzk->sender.kanal); break; case MTP_PRIM_DATA: if (len < 2) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "No Opcode, message too short!\n"); + LOGP(DCNETZ, LOGL_NOTICE, "No Opcode, message too short!\n"); return; } @@ -1172,17 +1183,17 @@ int fuvst_create(const char *kanal, enum fuvst_chan_type chan_type, const char * fuvst = calloc(1, sizeof(fuvst_t)); if (!fuvst) { - PDEBUG(DCNETZ, DEBUG_ERROR, "No memory!\n"); + LOGP(DCNETZ, LOGL_ERROR, "No memory!\n"); return -ENOMEM; } - PDEBUG(DCNETZ, DEBUG_DEBUG, "Creating 'C-Netz' instance for 'Kanal' = %s (sample rate %d).\n", chan_name, samplerate); + LOGP(DCNETZ, LOGL_DEBUG, "Creating 'C-Netz' instance for 'Kanal' = %s (sample rate %d).\n", chan_name, samplerate); /* init general part of transceiver */ /* do not enable emphasis, since it is done by fuvst code, not by common sender code */ rc = sender_create(&fuvst->sender, options_strdup(chan_name), 0, 0, audiodev, 0, 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(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n"); + LOGP(DCNETZ, LOGL_ERROR, "Failed to init transceiver process!\n"); goto error; } fuvst->chan_num = atoi(kanal); @@ -1208,7 +1219,7 @@ int fuvst_create(const char *kanal, enum fuvst_chan_type chan_type, const char * goto error; } - PDEBUG(DCNETZ, DEBUG_NOTICE, "Created 'Kanal' %s\n", chan_name); + LOGP(DCNETZ, LOGL_NOTICE, "Created 'Kanal' %s\n", chan_name); display_status(); @@ -1225,7 +1236,7 @@ void fuvst_destroy(sender_t *sender) { fuvst_t *fuvst = (fuvst_t *) sender; - PDEBUG(DCNETZ, DEBUG_DEBUG, "Destroying 'C-Netz' instance for 'Kanal' = %s.\n", sender->kanal); + LOGP(DCNETZ, LOGL_DEBUG, "Destroying 'C-Netz' instance for 'Kanal' = %s.\n", sender->kanal); if (fuvst->chan_type == CHAN_TYPE_ZZK) { mtp_exit(&fuvst->mtp); @@ -1248,7 +1259,11 @@ void sender_send(sender_t *sender, sample_t *samples, uint8_t *power, int length v27_modem_send(&fuvst->modem, samples, length); else { 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); + } samplerate_upsample(&sender->srstate, samples, input_num, samples, length); } } @@ -1284,7 +1299,7 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double __at } /* 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) +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; fuvst_t *fuvst; @@ -1297,8 +1312,12 @@ void call_down_audio(int callref, uint16_t sequence, uint32_t timestamp, uint32_ if (!sender) return; - if (fuvst->callref) - jitter_save(&fuvst->sender.dejitter, samples, count, 1, sequence, timestamp, ssrc); + if (fuvst->callref) { + jitter_frame_t *jf; + jf = jitter_frame_alloc(decoder, decoder_priv, payload, payload_len, marker, sequence, timestamp, ssrc); + if (jf) + jitter_save(&fuvst->sender.dejitter, jf); + } } void call_down_clock(void) {} @@ -1325,19 +1344,19 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, /* 2. base station ready? */ if (!base_station_ready) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing call not possible, base station not ready, rejecting!\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Outgoing call not possible, base station not ready, rejecting!\n"); return -CAUSE_TEMPFAIL; } /* 3. create transaction */ ident = get_free_ident(); if (!ident) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing call not possible, no free Ident code?? What the hack?\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Outgoing call not possible, no free Ident code?? What the hack?\n"); return -CAUSE_TEMPFAIL; } trans = create_transaction(ident, futln_nat, futln_fuvst, futln_rest, 0); if (!trans) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing call not possible, Transaction already exists: Subscriber busy!\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Outgoing call not possible, Transaction already exists: Subscriber busy!\n"); return -CAUSE_BUSY; } trans->callref = trans->old_callref = callref; @@ -1345,13 +1364,13 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, /* 4. start call */ len = encode_kvau(&opcode, &data, futln_rest, futln_fuvst, futln_nat, 0, authentication); message_send(trans->ident, opcode, data, len); - PDEBUG(DCNETZ, DEBUG_INFO, "Send call for mobile towards BS. (Ident = %d, FuTln=%s)\n", ident, transaction2rufnummer(trans)); + LOGP(DCNETZ, LOGL_INFO, "Send call for mobile towards BS. (Ident = %d, FuTln=%s)\n", ident, transaction2rufnummer(trans)); new_call_state(trans, STATE_MT); return 0; } -void call_down_answer(int callref) +void call_down_answer(int callref, struct timeval __attribute__((unused)) *tv_meter) { transaction_t *trans; uint8_t opcode, *data; @@ -1359,7 +1378,7 @@ void call_down_answer(int callref) trans = search_transaction_callref(callref); if (!trans) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Answer to unknown callref.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Answer to unknown callref.\n"); return; } @@ -1387,7 +1406,7 @@ static void _disconnect_release(transaction_t *trans, int callref, int cause) call_up_release(callref, cause); trans->callref = 0; new_call_state(trans, STATE_RELEASE); - timer_start(&trans->timer, RELEASE_TO); + osmo_timer_schedule(&trans->timer, RELEASE_TO); } /* Call control sends disconnect (with tones). @@ -1398,11 +1417,11 @@ void call_down_disconnect(int callref, int cause) { transaction_t *trans; - PDEBUG(DCNETZ, DEBUG_INFO, "Call has been disconnected by network.\n"); + LOGP(DCNETZ, LOGL_INFO, "Call has been disconnected by network.\n"); trans = search_transaction_callref(callref); if (!trans) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing disconnect to unknown callref.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Outgoing disconnect to unknown callref.\n"); call_up_release(callref, CAUSE_INVALCALLREF); return; } @@ -1422,11 +1441,11 @@ void call_down_release(int callref, int cause) { transaction_t *trans; - PDEBUG(DCNETZ, DEBUG_INFO, "Call has been released by network.\n"); + LOGP(DCNETZ, LOGL_INFO, "Call has been released by network.\n"); trans = search_transaction_callref(callref); if (!trans) { - PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing released to unknown callref.\n"); + LOGP(DCNETZ, LOGL_NOTICE, "Outgoing released to unknown callref.\n"); call_up_release(callref, CAUSE_INVALCALLREF); return; } @@ -1438,14 +1457,14 @@ void dump_info(void) { cnetz_db_t *db = cnetz_db_head; - PDEBUG(DDB, DEBUG_NOTICE, "Dump of subscriber database:\n"); + LOGP(DDB, LOGL_NOTICE, "Dump of subscriber database:\n"); if (!db) { - PDEBUG(DDB, DEBUG_NOTICE, " - No subscribers attached!\n"); + LOGP(DDB, LOGL_NOTICE, " - No subscribers attached!\n"); return; } while (db) { - PDEBUG(DDB, DEBUG_NOTICE, " - Subscriber '%d,%d,%d' is attached.\n", db->futln_nat, db->futln_fuvst, db->futln_rest); + LOGP(DDB, LOGL_NOTICE, " - Subscriber '%d,%d,%d' (reader=%s, sicherungs-code=%d) is attached.\n", db->futln_nat, db->futln_fuvst, db->futln_rest, (db->chip) ? "chip" : "magent", db->sicherungscode); db = db->next; } } diff --git a/src/fuvst/main.c b/src/fuvst/main.c index 7a18da0..0a8ab58 100755 --- a/src/fuvst/main.c +++ b/src/fuvst/main.c @@ -23,10 +23,10 @@ #include <string.h> #include <errno.h> #include "../libsample/sample.h" -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" #include "../libmobile/call.h" #include "../libmobile/main_mobile.h" -#include "../libtimer/timer.h" +#include <osmocom/core/timer.h> #include "../liboptions/options.h" #include "../libfm/fm.h" #include "../anetz/freiton.h" @@ -293,6 +293,7 @@ fail: fuvst_destroy(sender_head); /* exits */ + main_mobile_exit(); // zeit_exit(); fm_exit(); diff --git a/src/fuvst/mup.c b/src/fuvst/mup.c index 7224fb4..24f0c9f 100755 --- a/src/fuvst/mup.c +++ b/src/fuvst/mup.c @@ -23,7 +23,8 @@ #include <string.h> #include <time.h> #include <inttypes.h> -#include "../libdebug/debug.h" +#include <osmocom/core/utils.h> +#include "../liblogging/logging.h" #include "mup.h" #include "systemmeldungen.h" @@ -291,7 +292,7 @@ static const char *futln_cause(uint8_t Y) void decode_swaf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uint8_t *F, uint8_t *C, uint8_t *B) { if (len < 6) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -302,7 +303,7 @@ void decode_swaf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uin *C = data[4]; *B = data[5]; - PDEBUG(DMUP, DEBUG_INFO, "(BS SWAF) Wiederanlauf der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B)); + LOGP(DMUP, LOGL_INFO, "(BS SWAF) Wiederanlauf der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B)); } /* ack to base station boot */ @@ -310,7 +311,7 @@ int encode_swqu(uint8_t *opcode, uint8_t **data, uint8_t A) { static uint8_t buffer[1]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC SWQU) Wiederanlaufquittung des MSC: aktivdatei=%d (%s)\n", A, aktivdatei_string(A)); + LOGP(DMUP, LOGL_INFO, "(MSC SWQU) Wiederanlaufquittung des MSC: aktivdatei=%d (%s)\n", A, aktivdatei_string(A)); *opcode = OPCODE_SWQU; buffer[0] = A; @@ -323,7 +324,7 @@ int encode_swqu(uint8_t *opcode, uint8_t **data, uint8_t A) void decode_suaf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uint8_t *F, uint8_t *C, uint8_t *B) { if (len < 6) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -334,7 +335,7 @@ void decode_suaf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uin *C = data[4]; *B = data[5]; - PDEBUG(DMUP, DEBUG_INFO, "(BS SUAF) Datum-Uhrzeit-Anforderung der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B)); + LOGP(DMUP, LOGL_INFO, "(BS SUAF) Datum-Uhrzeit-Anforderung der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B)); } /* ack to time request */ @@ -355,7 +356,7 @@ int encode_suqu(uint8_t *opcode, uint8_t **data, uint8_t Q, uint8_t N, time_t no m = tm->tm_min; s = tm->tm_sec; - PDEBUG(DMUP, DEBUG_INFO, "(MSC SUQU) Datum-Uhrzeit-Quittung des MSC: Q=%d (%s) Widerholung=%d (%s) Wochentag=%d (%s) Datum: %d.%d.%d %d:%02d:%02d\n", Q, qualitaet_string(Q), N, wiederholung_string(N), W, woche_string(W), D, M, J, h, m, s); + LOGP(DMUP, LOGL_INFO, "(MSC SUQU) Datum-Uhrzeit-Quittung des MSC: Q=%d (%s) Widerholung=%d (%s) Wochentag=%d (%s) Datum: %d.%d.%d %d:%02d:%02d\n", Q, qualitaet_string(Q), N, wiederholung_string(N), W, woche_string(W), D, M, J, h, m, s); *opcode = OPCODE_SUQU; buffer[0] = Q | (N << 1) | (R << 2); @@ -380,7 +381,7 @@ void decode_sssaf(uint8_t *data, int len) int i, start_i = 0, stop_i = 0; if (len < 11) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -388,9 +389,9 @@ void decode_sssaf(uint8_t *data, int len) A = data[1] | (data[2] << 8); E = data[3] | (data[4] << 8); - PDEBUG(DMUP, DEBUG_INFO, "(BS SSSAF) Sprechkanal-Sammel-Sperrauftrag der BS: Liste-Ende=%d Anfang=%d Ende=%d\n", E_, A, E); + LOGP(DMUP, LOGL_INFO, "(BS SSSAF) Sprechkanal-Sammel-Sperrauftrag der BS: Liste-Ende=%d Anfang=%d Ende=%d\n", E_, A, E); if (E - A + 1 > 6 * 8) { - PDEBUG(DMUP, DEBUG_INFO, " -> Bereich zu gross für Nachricht!\n"); + LOGP(DMUP, LOGL_INFO, " -> Bereich zu gross für Nachricht!\n"); return; } if ((int)E - (int)A < 0) @@ -411,9 +412,9 @@ void decode_sssaf(uint8_t *data, int len) if (i > 0 && S != last_S) { end: if (start_i == stop_i) - PDEBUG(DMUP, DEBUG_INFO, " -> SpK #%d=%d (%s)\n", start_i + A, last_S, (last_S) ? "gesperrt" : "frei"); + LOGP(DMUP, LOGL_INFO, " -> SpK #%d=%d (%s)\n", start_i + A, last_S, (last_S) ? "gesperrt" : "frei"); else - PDEBUG(DMUP, DEBUG_INFO, " -> SpK #%d..%d=%d (%s)\n", start_i + A, stop_i + A, last_S, (last_S) ? "gesperrt" : "frei"); + LOGP(DMUP, LOGL_INFO, " -> SpK #%d..%d=%d (%s)\n", start_i + A, stop_i + A, last_S, (last_S) ? "gesperrt" : "frei"); /* new start */ start_i = stop_i = i; } @@ -425,20 +426,20 @@ end: void encode_sssqu(uint8_t *opcode) { *opcode = OPCODE_SSSQU; - PDEBUG(DMUP, DEBUG_INFO, "(MSC SSSQU) Sprechkanal-Sammel-Sperrquittung des MSC\n"); + LOGP(DMUP, LOGL_INFO, "(MSC SSSQU) Sprechkanal-Sammel-Sperrquittung des MSC\n"); } /* base station locks a voice channel */ void decode_ssaf(uint8_t *data, int len, uint8_t *S) { if (len < 1) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } *S = data[0]; - PDEBUG(DMUP, DEBUG_INFO, "(BS SSAF) Sprechkanal-Sperr-Auftrag der BS: SPK=%d\n", *S); + LOGP(DMUP, LOGL_INFO, "(BS SSAF) Sprechkanal-Sperr-Auftrag der BS: SPK=%d\n", *S); } /* ack to lockeed voice channel */ @@ -446,7 +447,7 @@ int encode_ssqu(uint8_t *opcode, uint8_t **data, uint8_t S) { static uint8_t buffer[1]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC SSQU) Sprechkanal-Sperr-Quittung von der MSC: SPK=%d\n", S); + LOGP(DMUP, LOGL_INFO, "(MSC SSQU) Sprechkanal-Sperr-Quittung von der MSC: SPK=%d\n", S); *opcode = OPCODE_SSQU; buffer[0] = S; @@ -459,13 +460,13 @@ int encode_ssqu(uint8_t *opcode, uint8_t **data, uint8_t S) void decode_sfaf(uint8_t *data, int len, uint8_t *S) { if (len < 1) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } *S = data[0]; - PDEBUG(DMUP, DEBUG_INFO, "(BS SFAF) Sprechkanal-Freigabe-Auftrag der BS: SPK=%d\n", *S); + LOGP(DMUP, LOGL_INFO, "(BS SFAF) Sprechkanal-Freigabe-Auftrag der BS: SPK=%d\n", *S); } /* ack to unlockeed voice channel */ @@ -473,7 +474,7 @@ int encode_sfqu(uint8_t *opcode, uint8_t **data, uint8_t S) { static uint8_t buffer[1]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC SFQU) Sprechkanal-Freigabe-Quittung von der MSC: SPK=%d\n", S); + LOGP(DMUP, LOGL_INFO, "(MSC SFQU) Sprechkanal-Freigabe-Quittung von der MSC: SPK=%d\n", S); *opcode = OPCODE_SFQU; buffer[0] = S; @@ -485,13 +486,13 @@ int encode_sfqu(uint8_t *opcode, uint8_t **data, uint8_t S) /* base station ready */ void decode_svaf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len) { - PDEBUG(DMUP, DEBUG_INFO, "(BS SVAF) Vermittlungsfaehig-Auftrag der BS\n"); + LOGP(DMUP, LOGL_INFO, "(BS SVAF) Vermittlungsfaehig-Auftrag der BS\n"); } /* ack to base station ready */ int encode_svqu(uint8_t *opcode, uint8_t **data) { - PDEBUG(DMUP, DEBUG_INFO, "(MSC SVQU) Vermittlungsfaehig-Quittung des MSC\n"); + LOGP(DMUP, LOGL_INFO, "(MSC SVQU) Vermittlungsfaehig-Quittung des MSC\n"); *opcode = OPCODE_SVQU; *data = NULL; @@ -501,13 +502,13 @@ int encode_svqu(uint8_t *opcode, uint8_t **data) /* base station requests alarm messages */ void decode_ylsaf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len) { - PDEBUG(DMUP, DEBUG_INFO, "(BS YLSAF) Systemmeldungsanforderung an MSC\n"); + LOGP(DMUP, LOGL_INFO, "(BS YLSAF) Systemmeldungsanforderung an MSC\n"); } /* ack to base stations alarm request */ int encode_ylsmu(uint8_t *opcode, uint8_t **data) { - PDEBUG(DMUP, DEBUG_INFO, "(MSC YLSMU) Systemmeldungsbestaetigung vom MSC\n"); + LOGP(DMUP, LOGL_INFO, "(MSC YLSMU) Systemmeldungsbestaetigung vom MSC\n"); *opcode = OPCODE_YLSMU; *data = NULL; @@ -518,7 +519,7 @@ int encode_ylsmu(uint8_t *opcode, uint8_t **data) void decode_ylsmf(uint8_t *data, int len, uint8_t *N, uint8_t *C, struct SysMeld *SM) { if (len < 9) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -578,7 +579,7 @@ void decode_ylsmf(uint8_t *data, int len, uint8_t *N, uint8_t *C, struct SysMeld indizien[strlen(indizien)] = ' '; } - PDEBUG(DMUP, DEBUG_INFO, "SM: %03d %02d.%02d %02d:%02d %s%02d %c H\"%04X %02d H\"%sH\"%02X%02X%02X%02X\n", *C, + LOGP(DMUP, LOGL_INFO, "SM: %03d %02d.%02d %02d:%02d %s%02d %c H\"%04X %02d H\"%sH\"%02X%02X%02X%02X\n", *C, SM->Monat, SM->Tag, SM->Stunde, SM->Minute, einrichtrungstyp_string(SM->Einrichtungstyp), SM->Einrichtungsnr, SM->ASCII_Typ ? : '0', SM->Systemmeldungsnr, @@ -590,13 +591,13 @@ void decode_ylsmf(uint8_t *data, int len, uint8_t *N, uint8_t *C, struct SysMeld /* base station ends list of alarm messages */ void decode_ylsef(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len) { - PDEBUG(DMUP, DEBUG_INFO, "(BS YLSEF) Systemmeldungsuebertragungsende an MSC\n"); + LOGP(DMUP, LOGL_INFO, "(BS YLSEF) Systemmeldungsuebertragungsende an MSC\n"); } /* base station requests billing info */ void decode_stdaf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len) { - PDEBUG(DMUP, DEBUG_INFO, "(BS STDAF) Tarifdatenauftrag der BS\n"); + LOGP(DMUP, LOGL_INFO, "(BS STDAF) Tarifdatenauftrag der BS\n"); } /* reply to billing info */ @@ -606,7 +607,7 @@ int encode_xgtau(uint8_t *opcode, uint8_t **data, uint8_t Z, uint32_t T, uint8_t // Example from UeLE-ROM = { 0xff, 0x00, 0x01, 0xec, 0x3f, 0x01, 0x31, 0x1c, 0x03 }; // { 0xff, 0x00, 0x01, 0xec, 0x3f, 0x01, 0x41, 0x1c, 0x03 }; - PDEBUG(DMUP, DEBUG_INFO, "(MSC XGTAU) Tarifdatensignalisierung vom MSC\n"); + LOGP(DMUP, LOGL_INFO, "(MSC XGTAU) Tarifdatensignalisierung vom MSC\n"); *opcode = OPCODE_XGTAU; buffer[0] = 0xff; @@ -627,7 +628,7 @@ int encode_xgtau(uint8_t *opcode, uint8_t **data, uint8_t Z, uint32_t T, uint8_t void decode_ebaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, uint16_t *s, uint8_t *u, uint8_t *b, uint8_t *l) { if (len < 6) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -639,13 +640,13 @@ void decode_ebaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, ui *b = (data[5] >> 6) & 0x1; *l = data[5] >> 7; - PDEBUG(DMUP, DEBUG_INFO, "(BS EBAF) Einbuchauftrag: FuTln=%d,%d,%d (0161-%d%d%05d)\n", *N, *U, *T, *N, *U, *T); + LOGP(DMUP, LOGL_INFO, "(BS EBAF) Einbuchauftrag: FuTln=%d,%d,%d (0161-%d%d%05d) reader=%s\n", *N, *U, *T, *N, *U, *T, (b) ? "chip" : "magent"); } /* ack to inscription */ int encode_ebpqu(uint8_t *opcode, uint8_t **data) { - PDEBUG(DMUP, DEBUG_INFO, "(MSC EBPQU) Einbuchungs-Positiv-Quittiung vom MSC\n"); + LOGP(DMUP, LOGL_INFO, "(MSC EBPQU) Einbuchungs-Positiv-Quittiung vom MSC\n"); *opcode = OPCODE_EBPQU; *data = NULL; @@ -656,7 +657,7 @@ int encode_ebpqu(uint8_t *opcode, uint8_t **data) void decode_abaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N) { if (len < 3) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -664,18 +665,18 @@ void decode_abaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N) *U = data[2] & 0x1f; *N = data[2] >> 5; - PDEBUG(DMUP, DEBUG_INFO, "(BS ABAF) Ausbuchung-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d)\n", *N, *U, *T, *N, *U, *T); + LOGP(DMUP, LOGL_INFO, "(BS ABAF) Ausbuchung-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d)\n", *N, *U, *T, *N, *U, *T); } static char digit2char[16] = "0123456789a*#bcd"; /* MO call */ -void _decode_outgoing(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, char *number) +static void _decode_outgoing(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, char *number) { int i; if (len < 11) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -709,14 +710,14 @@ void decode_gvaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, ch { _decode_outgoing(data, len, T, U , N, number); - PDEBUG(DMUP, DEBUG_INFO, "(BS GVAF) Gehender Verbindungs-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d) number=%s\n", *N, *U, *T, *N, *U, *T, number); + LOGP(DMUP, LOGL_INFO, "(BS GVAF) Gehender Verbindungs-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d) number=%s\n", *N, *U, *T, *N, *U, *T, number); } void decode_gvwaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, char *number) { _decode_outgoing(data, len, T, U , N, number); - PDEBUG(DMUP, DEBUG_INFO, "(BS GVWAF) Gehender Verbindungs-Warteschlange-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d) number=%s\n", *N, *U, *T, *N, *U, *T, number); + LOGP(DMUP, LOGL_INFO, "(BS GVWAF) Gehender Verbindungs-Warteschlange-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d) number=%s\n", *N, *U, *T, *N, *U, *T, number); } /* ack to MO call */ @@ -724,7 +725,7 @@ int encode_gvpqu(uint8_t *opcode, uint8_t **data, uint8_t P, uint8_t e) { static uint8_t buffer[2]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC GVPQU) Verbindungs-Positiv-Quittiung vom MSC: Prio=%d (%s) AP-Pruefung=%d\n", P, prio_string(P), e); + LOGP(DMUP, LOGL_INFO, "(MSC GVPQU) Verbindungs-Positiv-Quittiung vom MSC: Prio=%d (%s) AP-Pruefung=%d\n", P, prio_string(P), e); *opcode = OPCODE_GVNQU; buffer[0] = P; @@ -739,7 +740,7 @@ int encode_gvnqu(uint8_t *opcode, uint8_t **data, uint8_t X, uint8_t Y) { static uint8_t buffer[2]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC GVNQU) Verbindungs-Negativ-Quittiung vom MSC: Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", X, fufst_cause(X), Y, futln_cause(Y)); + LOGP(DMUP, LOGL_INFO, "(MSC GVNQU) Verbindungs-Negativ-Quittiung vom MSC: Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", X, fufst_cause(X), Y, futln_cause(Y)); *opcode = OPCODE_GVNQU; buffer[0] = X; @@ -754,7 +755,7 @@ int encode_kvau(uint8_t *opcode, uint8_t **data, uint16_t T, uint8_t U, uint8_t { static uint8_t buffer[5]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC KVAU) Kommender Verbindungs-Auftrag vom MSC: FuTln=%d,%d,%d (0161-%d%d%05d) Rufzeitbegrenzung=%d (%s) AP-Pruefung=%d\n", N, U, T, N, U, T, F, rufzeit_string(F), e); + LOGP(DMUP, LOGL_INFO, "(MSC KVAU) Kommender Verbindungs-Auftrag vom MSC: FuTln=%d,%d,%d (0161-%d%d%05d) Rufzeitbegrenzung=%d (%s) AP-Pruefung=%d\n", N, U, T, N, U, T, F, rufzeit_string(F), e); *opcode = OPCODE_KVAU; buffer[0] = T; @@ -770,20 +771,20 @@ int encode_kvau(uint8_t *opcode, uint8_t **data, uint16_t T, uint8_t U, uint8_t /* ack to MT call on queue */ void decode_kvwqf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len) { - PDEBUG(DMUP, DEBUG_INFO, "(BS KVWQF) Kommende Verbindungs-Warteschalngen-Quittung der BS\n"); + LOGP(DMUP, LOGL_INFO, "(BS KVWQF) Kommende Verbindungs-Warteschalngen-Quittung der BS\n"); } /* answer of MT call */ void decode_kvbaf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len) { - PDEBUG(DMUP, DEBUG_INFO, "(BS KVBAF) Kommende Verbindungs-Beginn-Auftrag der BS\n"); + LOGP(DMUP, LOGL_INFO, "(BS KVBAF) Kommende Verbindungs-Beginn-Auftrag der BS\n"); } /* loop test request */ void decode_staf(uint8_t *data, int len, uint8_t *Q, uint8_t *V, uint8_t *e, uint64_t *n) { if (len < 10) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -799,7 +800,7 @@ void decode_staf(uint8_t *data, int len, uint8_t *Q, uint8_t *V, uint8_t *e, uin *n |= (uint64_t)data[8] << 48; *n |= (uint64_t)data[9] << 56; - PDEBUG(DMUP, DEBUG_INFO, "(BS STAF) Schleifentest-Auftrag der BS: SPK=%d Typ=%d (%s) AP-Pruefung=%d Random=0x%016" PRIx64 "\n", *Q, *V, typ_string(*V), *e, *n); + LOGP(DMUP, LOGL_INFO, "(BS STAF) Schleifentest-Auftrag der BS: SPK=%d Typ=%d (%s) AP-Pruefung=%d Random=0x%016" PRIx64 "\n", *Q, *V, typ_string(*V), *e, *n); } /* loop test positive */ @@ -807,7 +808,7 @@ int encode_stpqu(uint8_t *opcode, uint8_t **data, uint8_t Q, uint8_t A, uint8_t { static uint8_t buffer[7]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC STPQU) Schleifentest-Positiv-Quittiung vom MSC: SPK=%d\n", Q); + LOGP(DMUP, LOGL_INFO, "(MSC STPQU) Schleifentest-Positiv-Quittiung vom MSC: SPK=%d\n", Q); *opcode = OPCODE_STPQU; buffer[0] = Q; @@ -827,7 +828,7 @@ int encode_stnqu(uint8_t *opcode, uint8_t **data, uint8_t Q) { static uint8_t buffer[1]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC STNQU) Schleifentest-Negativ-Quittiung vom MSC: SPK=%d\n", Q); + LOGP(DMUP, LOGL_INFO, "(MSC STNQU) Schleifentest-Negativ-Quittiung vom MSC: SPK=%d\n", Q); *opcode = OPCODE_STNQU; buffer[0] = Q; @@ -840,7 +841,7 @@ int encode_stnqu(uint8_t *opcode, uint8_t **data, uint8_t Q) void decode_apf(uint8_t *data, int len, uint8_t *Q, uint64_t *a) { if (len < 9) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -854,7 +855,7 @@ void decode_apf(uint8_t *data, int len, uint8_t *Q, uint64_t *a) *a |= (uint64_t)data[7] << 48; *a |= (uint64_t)data[8] << 56; - PDEBUG(DMUP, DEBUG_INFO, "(BS APF) Autorisierunsparameter FUKO: SPK=%d AP=0x%016" PRIx64 "\n", *Q, *a); + LOGP(DMUP, LOGL_INFO, "(BS APF) Autorisierunsparameter FUKO: SPK=%d AP=0x%016" PRIx64 "\n", *Q, *a); } /* start metering pulses (answer to call) */ @@ -862,7 +863,7 @@ int encode_gstau(uint8_t *opcode, uint8_t **data, uint8_t Q, uint16_t G, uint8_t { static uint8_t buffer[6]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC GSTAU) Gebuehren-Start-Auftrag vom MSC: SPK=%d\n", Q); + LOGP(DMUP, LOGL_INFO, "(MSC GSTAU) Gebuehren-Start-Auftrag vom MSC: SPK=%d\n", Q); *opcode = OPCODE_GSTAU; buffer[0] = Q; @@ -879,26 +880,26 @@ int encode_gstau(uint8_t *opcode, uint8_t **data, uint8_t Q, uint16_t G, uint8_t /* MCID */ void decode_faf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len) { - PDEBUG(DMUP, DEBUG_INFO, "(BS FAF) Fang-Auftrag der BS\n"); + LOGP(DMUP, LOGL_INFO, "(BS FAF) Fang-Auftrag der BS\n"); } /* release by base station (before SPK assignment) */ void decode_naf(uint8_t *data, int len, uint8_t *X) { if (len < 1) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } *X = data[0]; - PDEBUG(DMUP, DEBUG_INFO, "(BS AAF) Negativ-Auftrag der BS: Grund=%d (%s)\n", *X, fufst_cause(*X)); + LOGP(DMUP, LOGL_INFO, "(BS AAF) Negativ-Auftrag der BS: Grund=%d (%s)\n", *X, fufst_cause(*X)); } /* release by base station ack (before SPK assignment) */ int encode_equ(uint8_t *opcode, uint8_t **data) { - PDEBUG(DMUP, DEBUG_INFO, "(MSC AQU) Ende-Quittung vom MSC\n"); + LOGP(DMUP, LOGL_INFO, "(MSC AQU) Ende-Quittung vom MSC\n"); *opcode = OPCODE_EQU; *data = NULL; @@ -909,14 +910,14 @@ int encode_equ(uint8_t *opcode, uint8_t **data) void decode_aaf(uint8_t *data, int len, uint8_t *Q, uint8_t *X) { if (len < 2) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } *Q = data[0]; *X = data[1]; - PDEBUG(DMUP, DEBUG_INFO, "(BS AAF) Ausloese-Auftrag der BS: SPK=%d, Grund=%d (%s)\n", *Q, *X, fufst_cause(*X)); + LOGP(DMUP, LOGL_INFO, "(BS AAF) Ausloese-Auftrag der BS: SPK=%d, Grund=%d (%s)\n", *Q, *X, fufst_cause(*X)); } /* release by base station ack (after SPK assignment) */ @@ -924,7 +925,7 @@ int encode_aqu(uint8_t *opcode, uint8_t **data, uint8_t Q) { static uint8_t buffer[1]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC AQU) Ausloese-Quittung vom MSC: SPK=%d\n", Q); + LOGP(DMUP, LOGL_INFO, "(MSC AQU) Ausloese-Quittung vom MSC: SPK=%d\n", Q); *opcode = OPCODE_AQU; buffer[0] = Q; @@ -938,7 +939,7 @@ int encode_nau(uint8_t *opcode, uint8_t **data, uint8_t X, uint8_t Y) { static uint8_t buffer[2]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC NAU) Negativ-Auftrag vom MSC: Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", X, fufst_cause(X), Y, futln_cause(Y)); + LOGP(DMUP, LOGL_INFO, "(MSC NAU) Negativ-Auftrag vom MSC: Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", X, fufst_cause(X), Y, futln_cause(Y)); *opcode = OPCODE_NAU; buffer[0] = X; @@ -951,7 +952,7 @@ int encode_nau(uint8_t *opcode, uint8_t **data, uint8_t X, uint8_t Y) /* release by network ack (before SPK assignment) */ void decode_eqf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len) { - PDEBUG(DMUP, DEBUG_INFO, "(BS EQF) Ende-Quittung der BS\n"); + LOGP(DMUP, LOGL_INFO, "(BS EQF) Ende-Quittung der BS\n"); } /* release by network (after SPK assignment) */ @@ -959,7 +960,7 @@ int encode_aau(uint8_t *opcode, uint8_t **data, uint8_t Q, uint8_t X, uint8_t Y) { static uint8_t buffer[3]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC AAU) Ausloese-Auftrag vom MSC: SPK=%d, Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", Q, X, fufst_cause(X), Y, futln_cause(Y)); + LOGP(DMUP, LOGL_INFO, "(MSC AAU) Ausloese-Auftrag vom MSC: SPK=%d, Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", Q, X, fufst_cause(X), Y, futln_cause(Y)); *opcode = OPCODE_AAU; buffer[0] = Q; @@ -974,20 +975,20 @@ int encode_aau(uint8_t *opcode, uint8_t **data, uint8_t Q, uint8_t X, uint8_t Y) void decode_aqf(uint8_t *data, int len, uint8_t *Q) { if (len < 1) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } *Q = data[0]; - PDEBUG(DMUP, DEBUG_INFO, "(BS AQF) Ausloese-Quittung der BS: SPK=%d\n", *Q); + LOGP(DMUP, LOGL_INFO, "(BS AQF) Ausloese-Quittung der BS: SPK=%d\n", *Q); } /* request data base block */ void decode_xadbf(uint8_t *data, int len, uint8_t *PJ, uint16_t *D, uint16_t *L) { if (len < 6) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -995,7 +996,7 @@ void decode_xadbf(uint8_t *data, int len, uint8_t *PJ, uint16_t *D, uint16_t *L) *D = data[2] | (data[3] << 8); *L = data[4] | (data[5] << 8); - PDEBUG(DMUP, DEBUG_INFO, "(BS XADBF) Auftragssign. Anfordern BS-DB-Datenblock am MSC: job=%d, offset=0x%02x length=0x%02x\n", *PJ, *D, *L); + LOGP(DMUP, LOGL_INFO, "(BS XADBF) Auftragssign. Anfordern BS-DB-Datenblock am MSC: job=%d, offset=0x%02x length=0x%02x\n", *PJ, *D, *L); } /* transfer data base block */ @@ -1003,7 +1004,7 @@ int encode_xedbu_1(uint8_t *opcode, uint8_t **data, uint8_t R, uint8_t PJ, uint1 { static uint8_t buffer[4]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (header): return=%d job=%d frames=%d\n", R, PJ, A); + LOGP(DMUP, LOGL_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (header): return=%d job=%d frames=%d\n", R, PJ, A); *opcode = OPCODE_XEDBU; buffer[0] = R; @@ -1018,10 +1019,10 @@ int encode_xedbu_2(uint8_t *opcode, uint8_t **data, uint8_t S, uint8_t PJ, uint8 { static uint8_t buffer[11]; - if (debuglevel == DEBUG_DEBUG) - PDEBUG(DMUP, DEBUG_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (data): count=%d job=%d data=%s\n", S, PJ, debug_hex(P, 9)); + if (loglevel == LOGL_DEBUG) + LOGP(DMUP, LOGL_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (data): count=%d job=%d data=%s\n", S, PJ, osmo_hexdump(P, 9)); else if (S == 1) - PDEBUG(DMUP, DEBUG_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (data): Messages are not shown, due to heavy debug output!\n"); + LOGP(DMUP, LOGL_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (data): Messages are not shown, due to heavy debug output!\n"); *opcode = OPCODE_XEDBU; buffer[0] = S; @@ -1035,7 +1036,7 @@ int encode_xedbu_3(uint8_t *opcode, uint8_t **data, uint8_t S, uint8_t PJ, uint1 { static uint8_t buffer[9]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (footer): count=%d job=%d offset=0x%02x length=0x%02x checksum=0x%06x\n", S, PJ, D, L, CS); + LOGP(DMUP, LOGL_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (footer): count=%d job=%d offset=0x%02x length=0x%02x checksum=0x%06x\n", S, PJ, D, L, CS); *opcode = OPCODE_XEDBU; buffer[0] = S; @@ -1057,7 +1058,7 @@ int encode_yaaau(uint8_t *opcode, uint8_t **data, uint8_t J) { static uint8_t buffer[2]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC YAAAU) Auftrag Initialisieren BS des MSC: job=%d\n", J); + LOGP(DMUP, LOGL_INFO, "(MSC YAAAU) Auftrag Initialisieren BS des MSC: job=%d\n", J); *opcode = OPCODE_YAAAU; buffer[0] = 0xff; @@ -1072,7 +1073,7 @@ int encode_swau(uint8_t *opcode, uint8_t **data, uint8_t V) { static uint8_t buffer[1]; - PDEBUG(DMUP, DEBUG_INFO, "(MSC SWAU) Wiederanlaufauftrag des MSC: version=%d (%s)\n", V, version_string(V)); + LOGP(DMUP, LOGL_INFO, "(MSC SWAU) Wiederanlaufauftrag des MSC: version=%d (%s)\n", V, version_string(V)); *opcode = OPCODE_SWAU; buffer[0] = V; @@ -1085,7 +1086,7 @@ int encode_swau(uint8_t *opcode, uint8_t **data, uint8_t V) void decode_swqf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uint8_t *F, uint8_t *C, uint8_t *B) { if (len < 6) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return; } @@ -1096,30 +1097,30 @@ void decode_swqf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uin *C = data[4]; *B = data[5]; - PDEBUG(DMUP, DEBUG_INFO, "(BS SWQF) Wiederanlauf-Quittung der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B)); + LOGP(DMUP, LOGL_INFO, "(BS SWQF) Wiederanlauf-Quittung der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B)); } /* request "Aktivdatei" (inscripted substribers) */ void encode_sadau(uint8_t *opcode) { *opcode = OPCODE_SADAU; - PDEBUG(DMUP, DEBUG_INFO, "(MSC SADAU) Aktivdatei-Auftrag vom MSC\n"); + LOGP(DMUP, LOGL_INFO, "(MSC SADAU) Aktivdatei-Auftrag vom MSC\n"); } /* ack "Aktivdatei" */ -int decode_sadqf(uint8_t *data, int len, uint16_t *S, uint8_t *E, uint8_t *l, uint16_t *T, uint8_t *U, uint8_t *N) +int decode_sadqf(uint8_t *data, int len, uint16_t *S, uint8_t *E, uint8_t *b, uint16_t *T, uint8_t *U, uint8_t *N) { int i, n = 0; if (len < 11) { - PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n"); + LOGP(DMUP, LOGL_NOTICE, "Message too short!\n"); return 0; } *S = ((data[1] & 0xf) << 4) | data[0]; *E = data[1] >> 7; for (i = 0; i < 3; i++) { - l[n] = (data[1] >> (6 - i)) & 0x1; + b[n] = (data[1] >> (6 - i)) & 0x1; T[n] = (data[3 + (i * 3)] << 8) | data[2 + (i * 3)]; U[n] = data[4 + (i * 3)] & 0x1f; N[n] = data[4 + (i * 3)] >> 5; @@ -1127,9 +1128,9 @@ int decode_sadqf(uint8_t *data, int len, uint16_t *S, uint8_t *E, uint8_t *l, ui n++; } - PDEBUG(DMUP, DEBUG_INFO, "(BS SADQF) Aktivdateiquittung der BS:\n"); + LOGP(DMUP, LOGL_INFO, "(BS SADQF) Aktivdateiquittung der BS:\n"); for (i = 0; i < n; i++) - PDEBUG(DMUP, DEBUG_INFO, " %d: FuTln=%d,%d,%d (0161-%d%d%05d)\n", i + 1, N[i], U[i], T[i], N[i], U[i], T[i]); + LOGP(DMUP, LOGL_INFO, " %d: FuTln=%d,%d,%d (0161-%d%d%05d) reader=%s\n", i + 1, N[i], U[i], T[i], N[i], U[i], T[i], (b[i]) ? "chip" : "magent"); return n; } diff --git a/src/fuvst/sniffer.c b/src/fuvst/sniffer.c index f7fd656..dcac22d 100644 --- a/src/fuvst/sniffer.c +++ b/src/fuvst/sniffer.c @@ -23,8 +23,9 @@ #include <string.h> #include <errno.h> #include "../libsample/sample.h" -#include "../libtimer/timer.h" -#include "../libdebug/debug.h" +#include <osmocom/core/timer.h> +#include <osmocom/core/utils.h> +#include "../liblogging/logging.h" #include "../libmobile/call.h" #include "../libmobile/main_mobile.h" #include "../liboptions/options.h" @@ -72,7 +73,7 @@ static void receive_fisu(mtp_t *mtp, uint8_t bsn, uint8_t bib, uint8_t fsn, uint { sniffer_t *sniffer = (sniffer_t *)mtp->inst; - PDEBUG(DMTP3, (fsn == sniffer->last_fsn) ? DEBUG_INFO : DEBUG_NOTICE, "%s FISU Frame: FSN=%d FIB=%d BSN=%d BIB=%d\n", mtp->name, fsn, fib, bsn, bib); + LOGP(DMTP3, (fsn == sniffer->last_fsn) ? LOGL_INFO : LOGL_NOTICE, "%s FISU Frame: FSN=%d FIB=%d BSN=%d BIB=%d\n", mtp->name, fsn, fib, bsn, bib); /* store current FSN */ sniffer->last_fsn = fsn; @@ -83,7 +84,7 @@ static void receive_lssu(mtp_t *mtp, uint8_t fsn, uint8_t bib, uint8_t status) { sniffer_t *sniffer = (sniffer_t *)mtp->inst; - PDEBUG(DMTP3, DEBUG_INFO, "%s LSSU Frame: FSN=%d BIB=%d status=%d\n", mtp->name, fsn, bib, status); + LOGP(DMTP3, LOGL_INFO, "%s LSSU Frame: FSN=%d BIB=%d status=%d\n", mtp->name, fsn, bib, status); /* store initial FSN */ sniffer->last_fsn = fsn; @@ -98,17 +99,17 @@ static void receive_msu(mtp_t *mtp, uint8_t bsn, uint8_t bib, uint8_t fsn, uint8 uint8_t ident, opcode; if (len < 4) { - PDEBUG(DMTP3, DEBUG_NOTICE, "Short frame from layer 2 (len=%d)\n", len); + LOGP(DMTP3, LOGL_NOTICE, "Short frame from layer 2 (len=%d)\n", len); return; } if (fsn == sniffer->last_fsn) { - PDEBUG(DMTP3, DEBUG_INFO, "%s MSU Frame: FSN=%d FIB=%d BSN=%d BIB=%d data: %02x %s\n", mtp->name, fsn, fib, bsn, bib, sio, debug_hex(data, len)); + LOGP(DMTP3, LOGL_INFO, "%s MSU Frame: FSN=%d FIB=%d BSN=%d BIB=%d data: %02x %s\n", mtp->name, fsn, fib, bsn, bib, sio, osmo_hexdump(data, len)); return; } if (len < 6) { - PDEBUG(DMTP3, DEBUG_NOTICE, "Frame from layer 2 too short to carry an Opcode (len=%d)\n", len); + LOGP(DMTP3, LOGL_NOTICE, "Frame from layer 2 too short to carry an Opcode (len=%d)\n", len); return; } @@ -126,9 +127,9 @@ static void receive_msu(mtp_t *mtp, uint8_t bsn, uint8_t bib, uint8_t fsn, uint8 len -= 6; if (sio == 0xcd) - PDEBUG(DMTP3, DEBUG_NOTICE, "%s MuP Frame: FSN=%d FIB=%d BSN=%d BIB=%d SIO=0x%02x DCP=%d OCP=%d Ident=0x%02x OP=%02XH %s\n", mtp->name, fsn, fib, bsn, bib, sio, dcp, ocp, ident, opcode, debug_hex(data, len)); + LOGP(DMTP3, LOGL_NOTICE, "%s MuP Frame: FSN=%d FIB=%d BSN=%d BIB=%d SIO=0x%02x DCP=%d OCP=%d Ident=0x%02x OP=%02XH %s\n", mtp->name, fsn, fib, bsn, bib, sio, dcp, ocp, ident, opcode, osmo_hexdump(data, len)); else - PDEBUG(DMTP3, DEBUG_NOTICE, "%s MSU Frame: FSN=%d FIB=%d BSN=%d BIB=%d SIO=0x%02x DCP=%d OCP=%d SLC=%d H2/H1=0x%02x %02x %s\n", mtp->name, fsn, fib, bsn, bib, sio, dcp, ocp, slc, h2h1, data[-1], debug_hex(data, len)); + LOGP(DMTP3, LOGL_NOTICE, "%s MSU Frame: FSN=%d FIB=%d BSN=%d BIB=%d SIO=0x%02x DCP=%d OCP=%d SLC=%d H2/H1=0x%02x %02x %s\n", mtp->name, fsn, fib, bsn, bib, sio, dcp, ocp, slc, h2h1, data[-1], osmo_hexdump(data, len)); /* store current FSN */ sniffer->last_fsn = fsn; @@ -154,11 +155,11 @@ static void receive_bit(void *inst, int bit) } /* Destroy transceiver instance and unlink from list. */ -void sniffer_destroy(sender_t *sender) +static void sniffer_destroy(sender_t *sender) { sniffer_t *sniffer = (sniffer_t *) sender; - PDEBUG(DCNETZ, DEBUG_DEBUG, "Destroying 'Sniffer' instance for 'Kanal' = %s.\n", sender->kanal); + LOGP(DCNETZ, LOGL_DEBUG, "Destroying 'Sniffer' instance for 'Kanal' = %s.\n", sender->kanal); mtp_exit(&sniffer->mtp); @@ -202,11 +203,11 @@ int main(int argc, char *argv[]) if (num_device <= 1) dsp_device[1] = dsp_device[0]; for (i = 0; i < num_kanal; i++) { - PDEBUG(DCNETZ, DEBUG_DEBUG, "Creating 'Sniffer' instance for 'Kanal' = %s (sample rate %d).\n", kanal[i], dsp_samplerate); + LOGP(DCNETZ, LOGL_DEBUG, "Creating 'Sniffer' instance for 'Kanal' = %s (sample rate %d).\n", kanal[i], dsp_samplerate); sniffer = calloc(1, sizeof(sniffer_t)); if (!sniffer) { - PDEBUG(DCNETZ, DEBUG_ERROR, "No memory!\n"); + LOGP(DCNETZ, LOGL_ERROR, "No memory!\n"); goto fail; } rc = sender_create(&sniffer->sender, kanal[i], 131, 131, dsp_device[i], 0, dsp_samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); @@ -234,6 +235,7 @@ fail: sniffer_destroy(sender_head); /* exits */ + main_mobile_exit(); fm_exit(); return 0; @@ -255,13 +257,13 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double __at v27_modem_receive(&sniffer->modem, samples, length); } -void call_down_audio(int __attribute__((unused)) callref, uint16_t __attribute__((unused)) sequence, uint32_t __attribute__((unused)) timestamp, uint32_t __attribute__((unused)) ssrc, sample_t __attribute__((unused)) *samples, int __attribute__((unused)) count) { } +void call_down_audio(void __attribute__((unused)) *decoder, void __attribute__((unused)) *decoder_priv, int __attribute__((unused)) callref, uint16_t __attribute__((unused)) sequence, uint8_t __attribute__((unused)) marker, uint32_t __attribute__((unused)) timestamp, uint32_t __attribute__((unused)) ssrc, uint8_t __attribute__((unused)) *payload, int __attribute__((unused)) payload_len) { } void call_down_clock(void) {} int call_down_setup(int __attribute__((unused)) callref, const char __attribute__((unused)) *caller_id, enum number_type __attribute__((unused)) caller_type, const char __attribute__((unused)) *dialing) { return 0; } -void call_down_answer(int __attribute__((unused)) callref) { } +void call_down_answer(int __attribute__((unused)) callref, struct timeval __attribute__((unused)) *tv_meter) { } void call_down_disconnect(int __attribute__((unused)) callref, int __attribute__((unused)) cause) { } diff --git a/src/fuvst/systemmeldungen.c b/src/fuvst/systemmeldungen.c index 1d801ee..504a4aa 100644 --- a/src/fuvst/systemmeldungen.c +++ b/src/fuvst/systemmeldungen.c @@ -1,6 +1,6 @@ #include <stdlib.h> #include <inttypes.h> -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" #include "systemmeldungen.h" static struct systemmeldungen { @@ -21894,8 +21894,8 @@ void print_systemmeldung(uint16_t code, int bytes, uint8_t *ind) if (i == ii) return; - PDEBUG(DMUP, DEBUG_INFO, " -> %s\n", systemmeldungen[i].desc); + LOGP(DMUP, LOGL_INFO, " -> %s\n", systemmeldungen[i].desc); for (j = 0; j < systemmeldungen[i].bytes; j++) - PDEBUG(DMUP, DEBUG_INFO, " Byte %d = %02Xh: %s\n", j, ind[j], systemmeldungen[i].ind[j]); + LOGP(DMUP, LOGL_INFO, " Byte %d = %02Xh: %s\n", j, ind[j], systemmeldungen[i].ind[j]); } |