From a949470ec326abb0212e6f6c9a87db3edc9f48ff Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 10 Sep 2023 21:35:56 +0200 Subject: [PATCH] AMPS: Add ESN manufacturer names The ESN list "FCC Public Notice CL-97-70" is found at: https://web.archive.org/web/19990223224835/http://www.fcc.gov/wtb/cellular/mnfrlst.html When showing the ESN in logging, the manufacturer name is shown, if found in the list. Thanx to shadowcaster3, point to that list. --- src/amps/Makefile.am | 3 +- src/amps/amps.c | 9 +-- src/amps/amps.h | 2 + src/amps/esn.c | 152 +++++++++++++++++++++++++++++++++++++++++++ src/amps/esn.h | 3 + 5 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 src/amps/esn.c create mode 100644 src/amps/esn.h diff --git a/src/amps/Makefile.am b/src/amps/Makefile.am index 5769341..5c4439a 100644 --- a/src/amps/Makefile.am +++ b/src/amps/Makefile.am @@ -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 \ diff --git a/src/amps/amps.c b/src/amps/amps.c index f75e873..1dacd1b 100644 --- a/src/amps/amps.c +++ b/src/amps/amps.c @@ -51,6 +51,7 @@ #include "dsp.h" #include "frame.h" #include "stations.h" +#include "esn.h" #include "main.h" /* Uncomment this to test SAT via loopback */ @@ -847,7 +848,7 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint8_t mpci, uint32_t esn, uint32_ } 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)); + PDEBUG_CHAN(DAMPS, DEBUG_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) @@ -863,14 +864,14 @@ _register: } } 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)); + PDEBUG_CHAN(DAMPS, DEBUG_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)); + PDEBUG_CHAN(DAMPS, DEBUG_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)); + PDEBUG_CHAN(DAMPS, DEBUG_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"); diff --git a/src/amps/amps.h b/src/amps/amps.h index 0a85df2..53e6fea 100644 --- a/src/amps/amps.h +++ b/src/amps/amps.h @@ -182,6 +182,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/esn.c b/src/amps/esn.c new file mode 100644 index 0000000..462ad74 --- /dev/null +++ b/src/amps/esn.c @@ -0,0 +1,152 @@ +/* AMPS ESN specification + * + * (C) 2023 by Andreas Eversberg + * 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 . + */ + +#include +#include +#include +#include +#include "../libsample/sample.h" +#include "../libdebug/debug.h" +#include "../libmobile/call.h" +#include "../libmobile/cause.h" +#include "../libosmocc/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); +