diff --git a/.gitmodules b/.gitmodules index d1739a4c..d5e98870 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +1,8 @@ [submodule "CommonLibs"] path = CommonLibs - url = https://github.com/RangeNetworks/CommonLibs.git + url = https://github.com/PentHertz/CommonLibs.git branch = master [submodule "NodeManager"] path = NodeManager - url = https://github.com/RangeNetworks/NodeManager.git + url = https://github.com/PentHertz/NodeManager.git branch = master diff --git a/CLI/CLIServer.cpp b/CLI/CLIServer.cpp index 9f6ff2fe..debee4e2 100644 --- a/CLI/CLIServer.cpp +++ b/CLI/CLIServer.cpp @@ -202,7 +202,7 @@ void Parser::cliServer() close(i); continue; // go to next socket } - if (len < (int) sizeof(len)) // should never get here + if (nread < (int) sizeof(len)) // should never get here { char buf[BUFSIZ]; sprintf(buf, "Unable to read complete length, s.b. %d bytes, got %d bytes\n", sizeof(len), len); diff --git a/CommonLibs b/CommonLibs index 76b71d50..95007dad 160000 --- a/CommonLibs +++ b/CommonLibs @@ -1 +1 @@ -Subproject commit 76b71d509bb5e6f146d7305d01b4c1cfec21302a +Subproject commit 95007dad00118aa1ea1f039ef2cb5fefcf1976a5 diff --git a/Control/L3StateMachine.cpp b/Control/L3StateMachine.cpp index b0c8e207..33d9f55d 100644 --- a/Control/L3StateMachine.cpp +++ b/Control/L3StateMachine.cpp @@ -1,6 +1,7 @@ /**@file Declarations for Circuit Switched State Machine and related classes. */ /* * Copyright 2013, 2014 Range Networks, Inc. +* Renewed for 2023 by FlUxIuS @ Penthertz * * This software is distributed under multiple licenses; * see the COPYING file in the main directory for licensing @@ -85,11 +86,11 @@ void MachineBase::machineErrorMessage(int level, int state, const L3Message *l3m // This kind sucks, digging into the Logger. The logger could be better. if (l3msg) { - Log(level).get() < 1) { std::ostringstream os; msDumpChannels(os); - LOG(INFO) << "Multislot assignment for "< #include @@ -7,5 +7,5 @@ typedef unsigned char byte; typedef unsigned long word; typedef word bit; -void A51_GSM( byte *key, int klen, int count, byte *block1, byte *block2 ); +void A51_GSM( unsigned char *key, int klen, int count, unsigned char *block1, unsigned char *block2 ); diff --git a/Globals/GlobalVars.cpp b/Globals/GlobalVars.cpp index 30f6c0f2..3e4db76c 100644 --- a/Globals/GlobalVars.cpp +++ b/Globals/GlobalVars.cpp @@ -35,6 +35,7 @@ const char* gOpenBTSWelcome = "Copyright 2008, 2009, 2010 Free Software Foundation, Inc.\n" "Copyright 2010 Kestrel Signal Processing, Inc.\n" "Copyright 2011-2021 Range Networks, Inc.\n" + "Reloaded for 2023 by FlUxIuS @ Penthertz SAS.\n" "Release " VERSION "+" REPO_REV " " PROD_CAT " formal build date " TIMESTAMP_ISO "\n" "\"OpenBTS\" is a registered trademark of Range Networks, Inc.\n" "\nContributors:\n" diff --git a/NodeManager b/NodeManager index 8c8a6e8f..720d812f 160000 --- a/NodeManager +++ b/NodeManager @@ -1 +1 @@ -Subproject commit 8c8a6e8f7a93543b60b85cea9fb2b3479cd57584 +Subproject commit 720d812f285e01e68ad18a49036b30ae132208cc diff --git a/README b/README.md similarity index 70% rename from README rename to README.md index 0d1cb5cf..033afbe0 100644 --- a/README +++ b/README.md @@ -1,5 +1,88 @@ -Welcome to the OpenBTS source code. +Welcome to the OpenBTS source code reloaded for 2024 supporting new UHD drivers and Ubuntu 22.04 LTS to be compiled against C++11 and C++17. +# What is this project? + +This projects provides a GSM+GPRS Radio Access Network Node with Software-Defined Radio. + +# Supported hardware + +* USRPs: + * USRP v1 (with 52 MHz clock -> but can be patched for default 64 MHz) + * USRP2 + * USRP B200/B210 and B205mini-* + * USRP N210 + * USRP X3*0 + * USRP N210 +* UmTRX +* LimeSDR with OsmoTRX transceiver by now +* ANTSDR E200: Warning! Super experimental as we don't own the hardware yet (send your captures centered on the used ARFCN for debug) + +# Quick usage + +## Setup + +Clone the repository and use the pre-installation script `preinstall.sh` to clone all other projects, submodules and install dependencies: + +``` +$ git clone https://github.com/PentHertz/OpenBTS.git +$ cd OpenBTS +$ # Optionally, checkout 5.1.0 branch which is the stable one with `git checkout 5.1.0` +$ ./preinstall.sh # note that for now libcoredumper will show some failures but we quickly bypass them forcing the compilation +``` + +Once it is finished, you can proceed with the installation of OpenBTS as follows: + +``` +$ ./autogen.sh +$ ./configure --with-uhd # use different options for other drivers +$ make -j$(nproc) +$ sudo make install +$ sudo ldconfig +``` + +And then we can launch everything! + +## Running everything + +Preferably run the probe UHD tool to load the firmware and FPGA into the USRP first: + +``` +$ uhd_usrp_probe +[INFO] [UHD] linux; GNU C++ version 11.2.0; Boost_107400; UHD_4.1.0.5-3 +[INFO] [B200] Loading firmware image: /usr/share/uhd/images/usrp_b200_fw.hex... +[INFO] [B200] Detected Device: B210 +[INFO] [B200] Loading FPGA image: /usr/share/uhd/images/usrp_b210_fpga.bin... +[...] +``` + +You can use `screen`, `tmux` or just laucnh everything except `OpenBTS` in background: + +``` +$ sudo smqueue & +$ sudo sipauthserve & +$ sudo /OpenBTS/OpenBTS +``` + +And voilĂ ! + +# Docker container + +A Docker images has been also generated for the backup and is ready to use with all installed tools: https://hub.docker.com/r/penthertz/openbts + +# Fuzzing with OpenBTS + +The Testcall feature has been reintroduced and includes also a SMS Fuzzing features thanks to @Djimmer work, and is under test with this new version of OpenBTS. + +You can already test it with the `fuzzing-dev` branch: + +``` +git checkout fuzzing-dev +``` + +Do not hesitate to send issue or pull requests in order to stabilize it. + + +# Old README For free support, please subscribe to openbts-discuss@lists.sourceforge.net. See http://sourceforge.net/mailarchive/forum.php?forum_name=openbts-discuss @@ -58,8 +141,7 @@ normal GNU build process with the rest of OpenBTS. To build smqueue, go into the smqueue directory and just type "make -f Makefile.standalone". - -Release history: +# Release history: Release Name SVN Reposiory SVN Rev Comments @@ -178,3 +260,5 @@ Release Name SVN Reposiory SVN Rev Comments 2.9 Plaquemine Range socket-based remote CLI merge-in of "S" Release +5.0 ? ? ? +5.1 FlUxIuS Penthertz Release for 2023 compiling with fresh Ubuntu 22.04 diff --git a/SGSNGGSN/GPRSL3Messages.cpp b/SGSNGGSN/GPRSL3Messages.cpp index 62f1ccd5..17a542b6 100644 --- a/SGSNGGSN/GPRSL3Messages.cpp +++ b/SGSNGGSN/GPRSL3Messages.cpp @@ -367,6 +367,22 @@ void GMMAttach::gmParseIEs(L3GmmFrame &src, size_t &rp, const char *culprit) mTmsiStatus = iei & 1; continue; } + if ((iei & 0xf0) == 0xd0) { + // 10.5.7.8 Device properties. Ignore for now + continue; + } + if ((iei & 0xf0) == 0xe0) { + // 10.5.5.29 P-TMSI type. Ignore for now + continue; + } + if ((iei & 0xf0) == 0xc0) { + // 10.5.1.15 MS network feature support. Ignore for now + continue; + } + if ((iei & 0xf0) == 0xf0) { + // 10.5.5.0 Additional update type. Ignore for now + continue; + } switch (iei) { case 0x19: // TV Old P-TMSI signature. // Dont have a 3 byte 'read' function so use getField then advance rp by 3. @@ -385,6 +401,10 @@ void GMMAttach::gmParseIEs(L3GmmFrame &src, size_t &rp, const char *culprit) // The specified length is of the ie itself, excluding the iei type and length byte. // Get the length, but dont move rp - let the IEs do that, because // some of them need the length byte. + if (rp >= src.size()) { + SGSNERROR("invalid message size in "< * * Copyright 2010,2011 Free Software Foundation, Inc. - * + * Renewed for 2023 by FlUxIuS @ Penthertz * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -25,8 +25,7 @@ #include #include #include -#include -#include +#include #ifdef HAVE_CONFIG_H #include "config.h" @@ -45,6 +44,7 @@ enum uhd_dev_type { B2XX, X3XX, UMTRX, + ANTSDR_E200, NUM_USRP_TYPES, }; @@ -66,6 +66,9 @@ struct uhd_dev_offset { #define B2XX_TIMING_4SPS 6.9248e-5 #endif +#define E200_TIMING_1SPS 9.9692e-5 // TODO: probably to fix +#define E200_TIMING_4SPS 6.9248e-5 // TODO: probably to fix + /* * Tx / Rx sample offset values. In a perfect world, there is no group delay * though analog components, and behaviour through digital filters exactly @@ -89,6 +92,8 @@ static struct uhd_dev_offset uhd_offsets[NUM_USRP_TYPES * 2] = { { X3XX, 4, 1.1264e-4, "X3XX 4 SPS"}, { UMTRX, 1, 9.9692e-5, "UmTRX 1 SPS" }, { UMTRX, 4, 7.3846e-5, "UmTRX 4 SPS" }, + { ANTSDR_E200, 1, E200_TIMING_1SPS, "ANTSDR E200 1 SPS" }, + { ANTSDR_E200, 4, E200_TIMING_4SPS, "ANTSDR E200 4 SPS" }, }; static double get_dev_offset(enum uhd_dev_type type, int sps) @@ -126,6 +131,7 @@ static double select_rate(uhd_dev_type type, int sps) case B100: return B100_BASE_RT * sps; case B2XX: + case ANTSDR_E200: case UMTRX: return GSMRATE * sps; default: @@ -211,7 +217,7 @@ class uhd_device : public RadioDevice { uhd_device(int sps, bool skip_rx); ~uhd_device(); - int open(const std::string &args, ReferenceType ref); + int open(const std::string &args, ReferenceType ref, const std::string &subdev); bool start(); bool stop(); void restart(uhd::time_spec_t ts); @@ -313,12 +319,13 @@ void *async_event_loop(uhd_device *dev) return NULL; } +// TODO: Use the new API to display new stuff /* Catch and drop underrun 'U' and overrun 'O' messages from stdout since we already report using the logging facility. Direct everything else appropriately. */ -void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg) +/*void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg) { switch (type) { case uhd::msg::status: @@ -333,7 +340,7 @@ void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg) case uhd::msg::fastpath: break; } -} +}*/ uhd_device::uhd_device(int sps, bool skip_rx) : tx_gain(0.0), tx_gain_min(0.0), tx_gain_max(0.0), @@ -487,8 +494,8 @@ bool uhd_device::parse_dev_type() { std::string mboard_str, dev_str; uhd::property_tree::sptr prop_tree; - size_t usrp1_str, usrp2_str, b100_str, b200_str, - b210_str, x300_str, x310_str, umtrx_str; + size_t usrp1_str, usrp2_str, b100_str, b200_str, antsdr_e200_str, + b210_str, x300_str, x310_str, umtrx_str, b205mini_str, b200mini_str; prop_tree = usrp_dev->get_device()->get_tree(); dev_str = prop_tree->access("/name").get(); @@ -498,10 +505,13 @@ bool uhd_device::parse_dev_type() usrp2_str = dev_str.find("USRP2"); b100_str = mboard_str.find("B100"); b200_str = mboard_str.find("B200"); + b200mini_str = mboard_str.find("B200mini"); + b205mini_str = mboard_str.find("B205mini"); b210_str = mboard_str.find("B210"); x300_str = mboard_str.find("X300"); x310_str = mboard_str.find("X310"); umtrx_str = dev_str.find("UmTRX"); + antsdr_e200_str = mboard_str.find("E200"); if (usrp1_str != std::string::npos) { LOG(ALERT) << "USRP1 is not supported using the UHD driver"; @@ -518,7 +528,11 @@ bool uhd_device::parse_dev_type() return true; } else if (b200_str != std::string::npos) { dev_type = B2XX; - } else if (b210_str != std::string::npos) { + } else if (b200mini_str != std::string::npos) { + dev_type = B2XX; + } else if (b205mini_str != std::string::npos) { + dev_type = B2XX; + } else if (b210_str != std::string::npos) { dev_type = B2XX; } else if (x300_str != std::string::npos) { dev_type = X3XX; @@ -528,7 +542,9 @@ bool uhd_device::parse_dev_type() dev_type = USRP2; } else if (umtrx_str != std::string::npos) { dev_type = UMTRX; - } else { + } else if (antsdr_e200_str != std::string::npos) { + dev_type = ANTSDR_E200; + } else { LOG(ALERT) << "Unknown UHD device type " << dev_str; return false; } @@ -539,7 +555,7 @@ bool uhd_device::parse_dev_type() return true; } -int uhd_device::open(const std::string &args, ReferenceType ref) +int uhd_device::open(const std::string &args, ReferenceType ref, const std::string &subdev) { // Find UHD devices uhd::device_addr_t addr(args); @@ -564,6 +580,12 @@ int uhd_device::open(const std::string &args, ReferenceType ref) set_ref_clk(ref); + //specify subdevice (daughterboard) + if(!subdev.empty()) { + usrp_dev->set_tx_subdev_spec(subdev); + usrp_dev->set_rx_subdev_spec(subdev); + } + // Create TX and RX streamers uhd::stream_args_t stream_args("sc16"); tx_stream = usrp_dev->get_tx_stream(stream_args); @@ -664,7 +686,7 @@ bool uhd_device::start() setPriority(); // Register msg handler - uhd::msg::register_handler(&uhd_msg_handler); + //uhd::msg::register_handler(&uhd_msg_handler); // Start asynchronous event (underrun check) loop async_event_thrd.start((void * (*)(void*))async_event_loop, (void*)this); diff --git a/Transceiver52M/radioDevice.h b/Transceiver52M/radioDevice.h index 40174395..7df91c9e 100644 --- a/Transceiver52M/radioDevice.h +++ b/Transceiver52M/radioDevice.h @@ -43,7 +43,7 @@ class RadioDevice { virtual ~RadioDevice() { } /** Initialize the USRP */ - virtual int open(const std::string &args, ReferenceType ref)=0; + virtual int open(const std::string &args, ReferenceType ref, const std::string &subdev = "")=0; /** Start the USRP */ virtual bool start()=0; diff --git a/Transceiver52M/runTransceiver.cpp b/Transceiver52M/runTransceiver.cpp index c06d3c34..8a6854b4 100644 --- a/Transceiver52M/runTransceiver.cpp +++ b/Transceiver52M/runTransceiver.cpp @@ -112,7 +112,7 @@ int testConfig(const char *filename) int main(int argc, char *argv[]) { int trxPort, radioType, fail = 0; - std::string deviceArgs, logLevel, trxAddr, refstr; + std::string deviceArgs, logLevel, trxAddr, refstr, subdev; RadioDevice *usrp = NULL; RadioDevice::ReferenceType refType; RadioInterface *radio = NULL; @@ -142,6 +142,7 @@ int main(int argc, char *argv[]) logLevel = gConfig.getStr("Log.Level"); trxPort = gConfig.getNum("TRX.Port"); trxAddr = gConfig.getStr("TRX.IP"); + subdev = gConfig.getStr("TRX.Subdevice"); if (gConfig.defines("TRX.Reference")) refstr = gConfig.getStr("TRX.Reference"); diff --git a/apps/GetConfigurationKeys.cpp b/apps/GetConfigurationKeys.cpp index 63606399..11b735f7 100644 --- a/apps/GetConfigurationKeys.cpp +++ b/apps/GetConfigurationKeys.cpp @@ -3078,6 +3078,17 @@ ConfigurationKeyMap getConfigurationKeys() map[tmp.getName()] = tmp; } + { ConfigurationKey tmp("TRX.Subdevice","", + "", + ConfigurationKey::CUSTOMERWARN, + ConfigurationKey::STRING, + "", + true, + "This value is a string that specifies a subdevice for Ettus Hardware." + ); + map[tmp.getName()] = tmp; + } + { ConfigurationKey tmp("TRX.Timeout.Clock","10", "seconds", ConfigurationKey::DEVELOPER, diff --git a/apps/OpenBTS.example.sql b/apps/OpenBTS.example.sql index 1610138e..421072e4 100644 --- a/apps/OpenBTS.example.sql +++ b/apps/OpenBTS.example.sql @@ -237,6 +237,7 @@ INSERT OR IGNORE INTO "CONFIG" VALUES('TRX.RadioFrequencyOffset','128',1,0,'Fine INSERT OR IGNORE INTO "CONFIG" VALUES('TRX.Timeout.Clock','10',0,0,'How long to wait during a read operation from the Transceiver before giving up.'); INSERT OR IGNORE INTO "CONFIG" VALUES('TRX.Timeout.Start','2',0,0,'How long to wait during system startup before checking to see if the Transceiver can be reached.'); INSERT OR IGNORE INTO "CONFIG" VALUES('TRX.TxAttenOffset','0',1,0,'Hardware-specific gain adjustment for transmitter, matched to the power amplifier, expessed as an attenuation in dB. Set at the factory. Do not adjust without proper calibration. Static.'); +INSERT OR IGNORE INTO "CONFIG" VALUES('TRX.Subdevice','',1,0,'Subdevice (Daughterboard) to use on Ettus hardware that supports it'); INSERT OR IGNORE INTO "CONFIG" VALUES('TRX.Reference','internal',0,0,'TRX reference type ("internal", "external", "gpsdo")'); INSERT OR IGNORE INTO "CONFIG" VALUES('Test.GSM.SimulatedFER.Downlink','0',0,0,'Probability (0-100) of dropping any downlink frame to test robustness.'); INSERT OR IGNORE INTO "CONFIG" VALUES('Test.GSM.SimulatedFER.Uplink','0',0,0,'Probability (0-100) of dropping any uplink frame to test robustness.'); diff --git a/configure.ac b/configure.ac index 19c1ba64..760e7d21 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ dnl AC_PREREQ([2.57]) # must be AC_INIT([openbts], [5.0-master]) -AC_INIT(openbts,5.0-master) +AC_INIT(openbts,5.1-master) AC_CANONICAL_BUILD AC_CANONICAL_HOST diff --git a/preinstall.sh b/preinstall.sh new file mode 100755 index 00000000..6ed77ca6 --- /dev/null +++ b/preinstall.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +########################################################## +# This is a simple script made by FlUxIuS @ Penthertz # +# It is there to simplify the installation of this whole # +# project. # +########################################################## + +# Installing compilation dependencies +sudo apt install -y autoconf libtool libosip2-dev libortp-dev libusb-1.0-0-dev g++ sqlite3 libsqlite3-dev erlang libreadline6-dev libncurses5-dev git dpkg-dev debhelper libssl-dev cmake build-essential wget libzmq3-dev + +# Installing HD driver 4.1.0 & tools from Ubuntu package manager +sudo apt install libuhd4.1.0 libuhd-dev uhd-host + +# Cloning submodules +git submodule init +git submodule update + +# Installing libcoredumper +git clone https://github.com/PentHertz/libcoredumper.git +cd libcoredumper +./build.sh +cd coredumper-1.2.1 +./configure +make -j$(nproc) +sudo make install +sudo ldconfig +cd ../.. + +# Installing subscriberRegistry +git clone https://github.com/PentHertz/subscriberRegistry.git +cd subscriberRegistry +git submodule init +git submodule update +./autogen.sh +./configure +make -j$(nproc) +sudo make install +sudo ldconfig +cd ../ + +# Installing liba53 +git clone https://github.com/PentHertz/liba53.git +cd liba53 +make -j$(nproc) +sudo make install +sudo ldconfig +cd .. + +# Installing smqueue +git clone https://github.com/PentHertz/smqueue.git +cd smqueue +git submodule init +git submodule update +./autogen.sh +./configure +make -j$(nproc) +sudo make install +sudo ldconfig +cd ../ + +# Making rooms for subscriberRegistry and smqueue +sudo sqlite3 -init ./apps/OpenBTS.example.sql /etc/OpenBTS/OpenBTS.db ".quit" +sudo mkdir -p /var/lib/asterisk/sqlite3dir +sudo sqlite3 -init /etc/OpenBTS/sipauthserve.example.sql /etc/OpenBTS/sipauthserve.db ".quit" +sudo mkdir /var/lib/OpenBTS +sudo touch /var/lib/OpenBTS/smq.cdr + +# Installing OpenBTS +#./autogen.sh +#./configure --with-uhd +#make -j$(nproc) +#make install