aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/bsc-nat/bsc_nat_test.c
AgeCommit message (Collapse)AuthorFilesLines
2017-08-27move openbsc/* to repos rootNeels Hofmeyr1-1584/+0
This is the first step in creating this repository from the legacy openbsc.git. Like all other Osmocom repositories, keep the autoconf and automake files in the repository root. openbsc.git has been the sole exception, which ends now. Change-Id: I9c6f2a448d9cb1cc088cf1cf6918b69d7e69b4e7
2016-10-13msgb talloc ctx: initialize in all main() scopesNeels Hofmeyr1-0/+1
Add msgb_talloc_ctx_init() call to many main() functions still lacking a msgb talloc context. Change-Id: Ib0d6751260659cabf18a7ce80680ba2fb4228ea1
2016-05-25filter/nat: Fix the context for the imsi assignmentHolger Hans Peter Freyther1-0/+3
In c09f8a3b7fb94ccef41e33c32bfe2bff1ffe0e44 as part of a cleanup I accidently changed the talloc context from "con" to "bsc". The issue occurred at an earlier commit when assigning req.ctx to the "wrong" context. The allocation needs to be scoped by the struct nat_sccp_connection and not the connection from BSC to NAT. Before we have a nat_sccp_connection we scope the copied imsi to the bsc_connection and then steal it, but for the identity resp we will always have a nat_sccp_connection and can already use the right context. Change-Id: I53789aad2809e19338ad3b2deb72c4757e7bd524 Related: OS#1733 Reviewed-on: https://gerrit.osmocom.org/102 Tested-by: Jenkins Builder Reviewed-by: Harald Welte <laforge@gnumonks.org> Reviewed-by: daniel <dwillmann@sysmocom.de> Reviewed-by: Holger Freyther <holger@freyther.de>
2016-04-12NAT: allow allocating BSC in arbitrary orderMax1-7/+7
Check for existing BSC before allocating new one. Track number of remaining BSCs on deallocation. Explicitly use BSC number in allocation function.
2015-08-0364bit: Fix compiler warnings in regard to 64bitHolger Hans Peter Freyther1-1/+1
vty_interface_layer3.c:584:4: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=] sizeof(subscr->extension)-1, VTY_NEWLINE);
2015-05-03filter: Move the con_type into the filter_stateHolger Hans Peter Freyther1-11/+11
2015-05-03filter: Remove nat_sccp_connection from public APIHolger Hans Peter Freyther1-1/+1
2015-05-03filter: More renaming and remove of "NAT" from itHolger Hans Peter Freyther1-11/+11
2015-05-03filter: Remove nat from bsc_nat_acc_lst and replace with msgHolger Hans Peter Freyther1-6/+6
2015-05-03filter: Cease out "struct bsc_nat" from the APIHolger Hans Peter Freyther1-2/+2
This means we need to require a talloc context and simply operate on the list. I had considered creating a structure to hold the list head but I didn't find any other members so omitted it for now.
2015-05-03filter: Move the method definition to the filter moduleHolger Hans Peter Freyther1-0/+1
Move the filter methods to the filter module. This is still only usable for the NAT and the _dt/_cr filter routines need to move back to the bsc_nat in the long run.
2015-04-23nat: Make mode-set patching optionalHolger Hans Peter Freyther1-1/+2
2014-08-29nat: Introduce a config free for the test and fix valgrind issuesHolger Hans Peter Freyther1-9/+16
The talloc_free on the nat lead to the freeing of the bsc_config which lead to freeing of the rate_ctr_group. The rate_ctr_group remained in a global list and the next creation of a bsc_config would access dead memory. Fix it. The free routine is only meant to be used by the test, for the real nat we would need to make sure that all connections and other state that refers to the cfg is removed/closed first. Fix various memleaks in the test while we are at it. There are still some to fix. ==7195== Invalid write of size 4 ==7195== at 0x4043171: rate_ctr_group_alloc (linuxlist.h:65) ==7195== by 0x804D893: bsc_config_alloc (bsc_nat_utils.c:174) ==7195== by 0x804B5D2: main (bsc_nat_test.c:954) ==7195== Address 0x4311cbc is 52 bytes inside a block of size 208 free'd ==7195== at 0x4029D28: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==7195== by 0x4048D98: _talloc_free (talloc.c:609) ==7195== by 0x4052806: talloc_free (talloc.c:578) ==7195== by 0x804B58A: main (bsc_nat_test.c:940)
2014-08-29tests: bsc-nat: fix bsc_mgcp_rewrite() with osmuxPablo Neira Ayuso1-1/+1
Pass -1 to indicate no osmux, before ("b769f3c osmux: add osmux circuit ID management and resolve NAT problems"), 0 was indicating no osmux.
2014-05-22mgcp: add voice muxer supportPablo Neira Ayuso1-1/+1
This patch adds the voice muxer. You can use this to batch RTP traffic to reduce bandwidth comsuption. Basically, osmux transforms RTP flows to a compact batch format, that is later on decompacted to its original form. Port UDP/1984 is used for the muxer traffic between osmo-bsc_nat and osmo-bsc_mgcp (in the BSC side). This feature depends on libosmo-netif, which contains the osmux core support. Osmux is requested on-demand via the MGCP CRCX/MDCX messages (using the vendor-specific extension X-Osmux: on) coming from the BSC-NAT, so you can selectively enable osmux per BSC from one the bsc-nat.cfg file, so we have a centralized point to enable/disable osmux. First thing you need to do is to accept requests to use Osmux, this can be done from VTY interface of osmo-bsc_nat and osmo-bsc_mgcp by adding the following line: mgcp ... osmux on osmux batch-factor 4 This just initializes the osmux engine. You still have to specify what BSC uses osmux from osmo-bsc_nat configuration file: ... bsc 1 osmux on bsc 2 ... bsc 3 osmux on In this case, bsc 1 and 3 should use osmux if possible, bsc 2 does not have osmux enabled. Thus, you can selectively enable osmux depending on the BSC, and we have a centralized point for configuration from the bsc-nat to enable osmux on demand, as suggested by Holger. At this moment, this patch contains heavy debug logging for each RTP packet that can be removed later to save cycles. The RTP ssrc/seqnum/timestamp is randomly allocated for each MDCX that is received to configure an endpoint.
2014-01-20nat: Introduce reject cause to bsc_nat_acc_lst_entryHolger Hans Peter Freyther1-1/+102
The filtering architecture already allowed to specify a reject reason but this has not been used for the access-lists. Extend the access-list to include a reject reason and extend the test case to honor it.
2013-12-05mgcp/nat: Take payload type from SDP dataJacob Erlbeck1-1/+1
So far the payload type used in RTP streams has been taken from the trunk configuration in NAT mode. This patch changes the implementation to use the payload type announced in the SDP part of MGCP messages and responses. SDP descriptions more than one m=audio line are not yet supported properly (always the last one is taken). Ticket: OW#466 Sponsored-by: On-Waves ehf
2013-12-05mgcp: Add tests for payload types in MGCP messagesJacob Erlbeck1-1/+15
These tests mainly check whether the SDP parsing works properly by looking at the payload type detected. Sponsored-by: On-Waves ehf
2013-07-31nat: Implement a post-routing for the NAT softwareHolger Hans Peter Freyther1-0/+61
* The post-routing is applied after the first re-writing. To do this the new number is copied back into the called data structure. * Add a testcase that goes from 0172 to 0049 and then back to 0049 using the post rule with a table lookup.
2013-07-31nat: Fix some memory leaks in the testcases.Holger Hans Peter Freyther1-0/+5
The test cases did not free some of the resources it allocated. Improve the situation a bit. There is still data allocated that is not freed at exit.
2013-07-31nat: Allow to use the prefix lookup to rewrite numbersHolger Hans Peter Freyther1-0/+51
* Increase the rewritten rule to five digits (this is the easiest for the unit test). This will add another 40kb to the runtime size. * Create a unit test that tests adding and removing the prefix rules. * Use the regexp match to replace from one package
2013-07-04nat: The second call didn't really add anything to the test.Holger Hans Peter Freyther1-3/+0
Avoid: Coverity CID 1042323
2013-04-16nat: Extract the LAC/CI from the Complete Layer3 InformationHolger Hans Peter Freyther1-0/+35
Find the Cell Identifier from the Complete Layer3 Information and store it for future reference. We could begin to verify that the LAC/CI used really belongs to the BSC.
2013-04-16nat: Rename "struct sccp_connections" to "struct nat_sccp_connection"Holger Hans Peter Freyther1-7/+7
The name sccp_connection is used in the osmo-sccp code, sccp_connections was used in the NAT for tracking a sccp_connection. Rename it so it is obvious that the struct belongs to the nat. The rename was done with sed: $ sed -i s,"struct sccp_connections","struct nat_sccp_connection",g \ include/openbsc/*.h src/osmo-bsc_nat/* tests/*/*
2013-04-16nat: Allow to re-write international numbers in the CC Setup messagesHolger Hans Peter Freyther1-2/+58
Prepend the international number with a '+' and then do the normal re-writing on it. There are a couple of ways to handle this: \+([0-9]), \+[0-9][0-9]([0-9]), \+49([0-9]) Add a test case for the international re-write based on an already internationalized number.
2013-04-16nat: We want the remote to respond to our DLCX requestHolger Hans Peter Freyther1-0/+1
We want to send a TRAP with the MGCP statistics from the NAT and the connected BSC. The BSC endpoint can be either released because of a DLCX from the MGCP CallAgent or the SCCP Connection release on the A-link. This is why we need to queue the statistics when the deleting the endpoint on the BSC. The processing is continued once the response arrives. This code assumes that the response of the DLCX will be sent by the remote side. The current amount of outstanding responses can be seen on the VTY. This assumption is based on the fact that the BSC has already responded to the CRCX and maybe to the MDCX. The MGCP RFC is bended to prefix the transaction identifier with "nat-" to easily detect the response and hand it to the handler. This will then parse the response and generate the TRAP. The current version is v1. We assume that the transaction space is big enough and we will not re-assign the transaction identifier too early.
2013-04-16nat: Make it possible to send MGCP messages through the IPA multiplexHolger Hans Peter Freyther1-0/+6
Instead of handling MGCP through the UDP socket, read and write messages through the ipa connection to the MSC.
2013-01-07nat: Introduce a global IMSI barr list using red-black treesHolger Hans Peter Freyther1-0/+67
2013-01-07nat: Allow the filter to select the reject causeHolger Hans Peter Freyther1-5/+10
In preparation for another kind of black-list allow the filter code to decide how the connection should be rejected. Introduce a new struct that will carry the reject causes for certain operations.
2012-03-26nat: Add another test case for TP-SRR clearing and number rewriteHolger Hans Peter Freyther1-3/+32
2012-01-18nat: Prepare to rewrite the TP-DA number of a SMS submit.Holger Hans Peter Freyther1-2/+46
Introduce number rewriting of SMS-SUBMIT. Introduce a new list, move code around to help with finding a new number, somehow the number encoding for TP-DA is borked, 03.40 references 04.11 but the length appears to be strlen(number) without taken the type field into account.
2012-01-18nat: Print the sizes and the offending data in case of a failureHolger Hans Peter Freyther1-1/+5
2012-01-10nat: Implement clearing of TP-SRR flags from TPDUsHolger Hans Peter Freyther1-2/+53
Match IMSI and destination address against a set of entries, if it is matching the header will be modified and no sender report will be requested. Change the test case to request the sender report and then verify that this bit is reset to 0.
2012-01-10nat: Reduce copy and paste in the test, create a verify_msgHolger Hans Peter Freyther1-50/+23
2012-01-06nat: Log test output stdout using printf in prep for GNU autotestHolger Hans Peter Freyther1-78/+97
2011-08-22misc: Move the bsc_parse_reg to libcommom and name it gsm_parse_regHolger Hans Peter Freyther1-3/+3
Move the regexp parsing code from the NAT to libcommon as it will be used by the NAT and BSC code. This also adds the #include <regex.h> include to gsm_data. This header should be split up.
2011-06-01nat: Look into the TPDU/SMS-SUBMIT and use the TP-DestAddress for matchesHolger Hans Peter Freyther1-9/+17
Match the used SMSC and the destination of the SMS and change the SMSC address if both are matched.
2011-06-01nat: Patch the destination SMS address of a messageHolger Hans Peter Freyther1-3/+47
Use the same filtering infrasturcture to patch the SMSC address in a CP-DATA/RP-DATA message. Add a very simple testcase for this code.
2011-06-01nat: Prepare to patch more than the CC Setup messageHolger Hans Peter Freyther1-4/+4
Refactor the code to allow having different handlers. The goal is to be able to patch some SMS messages too.
2011-06-01nat: Allow to have a regexp to match the MSISDNHolger Hans Peter Freyther1-1/+3
The idea that MCC and MNC is enough to classify a subscriber turns out to be wrong. Certain operatos license a number range of IMSIs to others. When we see a '^' in the MCC field we treat it as a regexp. The code now turns the MCC/MNC into a regexp for the IMSI. It is not using extended POSIX regexp to match the behavior of the access list.
2011-05-12misc: Use the osmo_init code for signals and loggingHolger Hans Peter Freyther1-6/+2
Use the libosmocore code to ignore certain signals by default (e.g. SIGHUP, SIGPIPE) and use the new code to create a default stderr logging target and initialize it properly.
2011-05-07src: rename msg_entr* to osmo_config_*Pablo Neira Ayuso1-2/+2
Summary of changes: s/msg_entry_parse/osmo_config_list_parse/g s/msg_entry/osmo_config_entry/g s/msg_entries/osmo_config_list/g
2011-05-07src: use namespace prefix osmo_* for misc utilsPablo Neira Ayuso1-4/+4
Summary of changes: s/bcd2char/osmo_bcd2char/g s/char2bcd/osmo_char2bcd/g s/hexparse/osmo_hexparse/g s/hexdump/osmo_hexdump/g s/hexdump_nospc/osmo_hexdump_nospc/g s/ubit_dump/osmo_ubit_dump/g s/static_assert/osmo_static_assert/g
2011-05-02nat: Rewrite the paging handling.Holger Hans Peter Freyther1-20/+3
The current code tries to find _one_ bsc for a paging message and then continues. The new code will try to find multiple BSCs for each LAC. This is done in preparation of having two BSCs handle the same LAC. This code right now is O(m*n) but it will be worse once paging groups are landed. The code to test the function was reduced to just test the lac lookup code as the other part can not be tested in a standalone setup anymore.
2011-04-04nat: Bail out if the regexp fails to compile and avoid a crashHolger Hans Peter Freyther1-6/+9
If the regexp fails to compile the internal dfa is NULL and a regexec will crash nicely. Fail and free the string if the regexp fails to compile.
2011-03-26tests: fix bsc-nat testPablo Neira Ayuso1-2/+2
In 136f453dd2492b95004461a33c90b11732f33bd8, I forgot to update the new header path in the test/bsc-nat files (this happened to me because I forgot to configured openBSC without --enable-nat).
2011-02-28mgcp: Introduce a mgcp_trunk_config enum for endpoint configsHolger Hans Peter Freyther1-2/+2
We want to support real trunks in the MGCP code and we need to have some better book keeping for those. Move the code around.
2011-02-27nat: Fix some corruption in the test caseHolger Hans Peter Freyther1-0/+2
2011-02-27nat: Change number of multiplexes to the max-endpointsHolger Hans Peter Freyther1-3/+4
2011-02-26nat: Allocate endpoints from multiple multiplexes.Holger Hans Peter Freyther1-0/+45
This code allocates endpoints from multiple multiplexes but will always leave 0x0 and 0x1f unassigned in the multiplex.