aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc/bsc_nat.h
AgeCommit message (Collapse)AuthorFilesLines
2017-08-27move openbsc/* to repos rootNeels Hofmeyr1-462/+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-04-14NAT: reload BSCs config dynamicallyMax1-0/+5
Add vty tests for BSC configuration reloading. Load BSCs configuration on bscs-config-file command: * remove all runtime configured BSC not in the config file * close connections to all BSC with updated token value Fixes: OS#1670 Sponsored-by: On-Waves ehf
2016-04-14NAT: move BSC config into separate fileMax1-0/+5
Introduce new configuration option bscs-config-file which includes BSC configuration from the given file. Both absolute and relative (to the main config file) paths are supported. Add 'show bscs-config' command to display current BSC configuration. Note: it is still possible to have BSC configuration in the main file (provided proper index number is used) and in runtime but BSC configuration is no longer saved automatically. The management of included configuration file is left to external tools. Update configuration examples. Fixes: OS#1669 Sponsored-by: On-Waves ehf
2016-04-12NAT: allow allocating BSC in arbitrary orderMax1-1/+2
Check for existing BSC before allocating new one. Track number of remaining BSCs on deallocation. Explicitly use BSC number in allocation function.
2016-02-25enable ctrl bind config for various programsNeels Hofmeyr1-1/+2
Add ctrl_vty_init() calls and feed the ctrl_vty_get_bind_addr() return value to ctrl_interface_setup() in the following programs: osmo-bsc osmo-bsc_nat osmo-nitb osmo-sgsn For osmo-sgsn, move the control interface setup invocation below the config parsing, so that the ctrl_vty_get_bind_addr() can return the configured address.
2015-08-13nat: Forward SDP files with multiple payload types in itHolger Hans Peter Freyther1-1/+1
The parsing code assumed that there will be a single payload type and this assumption is clearly wrong. Forward all of the payload types. The code is still only extracting the first type from the list. The variable name has been renamed to reflect this.
2015-07-01nat: Use RAND_bytes instead of /dev/urandomHolger Hans Peter Freyther1-3/+0
We don't need to consume all the entropy of the kernel but can use libcrypto (OpenSSL) to generate random data. It is not clear if we need to call RAND_load_file but I think we can assume that our Unices have a /dev/urandom. This takes less CPU time, provides good enough entropy (in theory) and leaves some in the kernel entropy pool.
2015-07-01nat: After we identified the bsc check the keyHolger Hans Peter Freyther1-0/+2
We are using the token to find the right bsc_config and then we can use the last_rand of the bsc_connection to calculate the expected result and try to compare it with a time constant(???) memcmp.
2015-07-01nat: Send 16 bytes of rand to the BSC and remember itHolger Hans Peter Freyther1-0/+1
Generate 16 byte of random data to be used for A3A8 by the BSC in the response. We can't know which BSC it is at this point and I don't want to send another message once the token has been received so always send the data with an undefined code. The old BSCs don't parse the message and will happily ignore the RAND. /dev/urandom can give short reads on Linux so loop around it until the bytes have been read from the kernel.
2015-07-01nat: Provide access to /dev/urandom for the codeHolger Hans Peter Freyther1-0/+3
Instead of doing open/read/close all the time, open the FD in the beginning and keep it open. To scare me even more I have seen /dev/urandom actually providing a short read and then blocking but it seems to be the best way to get the random byes we need for authentication. So one should/could run the cheap random generator on the system (e.g. haveged) or deal with the NAT process to block.
2015-07-01nat: Factor out the config by token searchHolger Hans Peter Freyther1-0/+1
In the upcoming authentication improvements it is nice to separate the finding of the config from the post-allow handling of it.
2015-05-03filter: Move the con_type into the filter_stateHolger Hans Peter Freyther1-10/+0
2015-05-03filter: Separate SCCP/BSSAP extraction and gsm48 codeHolger Hans Peter Freyther1-0/+8
For the BSC we will have the gsm48_hdr and don't need to find data within SCCP. For legacy reasons we need to initialize con_type, imsi, reject causes early on and need to do the same in the filter method.
2015-05-03filter: Move the access list management aroundHolger Hans Peter Freyther1-8/+0
2015-05-03filter: Move the method definition to the filter moduleHolger Hans Peter Freyther1-56/+0
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
2015-04-05nat: Inform others if an IMSI is rejectedHolger Hans Peter Freyther1-0/+4
In case one wants to monitor the access lists one there is now a trap for the IMSI.
2014-08-29nat: Introduce a config free for the test and fix valgrind issuesHolger Hans Peter Freyther1-0/+6
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-05-22mgcp: add voice muxer supportPablo Neira Ayuso1-1/+4
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-04-01ipa: Use enhanced ipa_msg_recv_buffered() to cope with partioned IPA messagesJacob Erlbeck1-0/+5
The old ipa_msg_recv() implementation didn't support partial receive, so IPA connections got disconnected when this happened. This patch adds the handling of the temporary message buffers and uses ipa_msg_recv_buffered(). It has been successfully tested by jerlbeck with osmo-nitb and osmo-bsc. Ticket: OW#768 Sponsored-by: On-Waves ehf
2014-01-20nat: Introduce reject cause to bsc_nat_acc_lst_entryHolger Hans Peter Freyther1-0/+4
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/+2
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-09-02nat: Attempt to follow the MODULE_METHOD pattern for methodsHolger Hans Peter Freyther1-2/+2
Rename methods to be like bsc_ussd_ACTION.
2013-07-31nat: Implement a post-routing for the NAT softwareHolger Hans Peter Freyther1-0/+2
* 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: Allow to use the prefix lookup to rewrite numbersHolger Hans Peter Freyther1-0/+6
* 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-04-22nat: Move the callstats to a new header file due sccp usageHolger Hans Peter Freyther1-28/+0
The bsc_nat.h is included by common_vty.c so we may not used sccp_types.h in the bsc_nat.h header file. Move the callstats to a new file and include it where it is needed.
2013-04-16nat: Extract the LAC/CI from the Complete Layer3 InformationHolger Hans Peter Freyther1-0/+3
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-14/+14
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: We want the remote to respond to our DLCX requestHolger Hans Peter Freyther1-0/+31
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/+4
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/+15
2013-01-07nat: Allow the filter to select the reject causeHolger Hans Peter Freyther1-2/+9
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-12-03bsc: Send the USSD message after the location updating accept.Holger Hans Peter Freyther1-2/+2
Make sure to accept the phone first before sending the USSD message.
2012-11-12nat: Move the ctrl handling code into a separate fileHolger Hans Peter Freyther1-0/+4
Move to the control command handling out of the main file into a dedicated module. There are still some calls embedded into the main code but it will be moved soon.
2012-09-11libctrl: Change controlif_setup so it returns the ctrl handleDaniel Willmann1-0/+3
nat: Catch up with controlif_setup API change We now save a control handle reference in the nat osmo-bsc: Catch up with controlif_setup API change We now save a control handle reference in the gsm network
2012-01-18nat: Prepare to rewrite the TP-DA number of a SMS submit.Holger Hans Peter Freyther1-0/+2
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-10nat: Implement clearing of TP-SRR flags from TPDUsHolger Hans Peter Freyther1-0/+2
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.
2011-08-22misc: Move the bsc_parse_reg to libcommom and name it gsm_parse_regHolger Hans Peter Freyther1-1/+0
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-07-13nat: Use libctrl and add command forwarding to osmo-bscDaniel Willmann1-0/+22
Passes commands beginning with "bsc.<num>" to the bsc that is responsible for LAC <num>.
2011-06-01nat: Look into the TPDU/SMS-SUBMIT and use the TP-DestAddress for matchesHolger Hans Peter Freyther1-0/+2
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-1/+4
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-1/+1
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/+15
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-07src: rename msg_entr* to osmo_config_*Pablo Neira Ayuso1-1/+1
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-06src: use namespace prefix osmo_counter*Pablo Neira Ayuso1-6/+6
Summary of changes: s/struct counter/struct osmo_counter/g s/counter_inc/osmo_counter_inc/g s/counter_get/osmo_counter_get/g s/counter_reset/osmo_counter_reset/g s/counter_alloc/osmo_counter_alloc/g s/counter_free/osmo_counter_free
2011-05-06src: use namespace prefix osmo_wqueue*Pablo Neira Ayuso1-4/+4
Summary of changes: s/struct write_queue/struct osmo_wqueue/g s/write_queue_init/osmo_wqueue_init/g s/write_queue_clear/osmo_wqueue_clear/g s/write_queue_enqueue/osmo_wqueue_enqueue/g s/write_queue_bfd_cb/osmo_wqueue_bfd_cb/g
2011-05-06src: use namespace prefix osmo_fd* and osmo_select*Pablo Neira Ayuso1-2/+2
Summary of changes: s/struct bsc_fd/struct osmo_fd/g s/bsc_register_fd/osmo_fd_register/g s/bsc_unregister_fd/osmo_fd_unregister/g s/bsc_select_main/osmo_select_main/g
2011-05-06src: use namespace prefix osmo_timer* for timer functionsPablo Neira Ayuso1-4/+4
Summary of changes: s/struct timer_list/struct osmo_timer_list/g s/bsc_add_timer/osmo_timer_add/g s/bsc_schedule_timer/osmo_timer_schedule/g s/bsc_del_timer/osmo_timer_del/g s/bsc_timer_pending/osmo_timer_pending/g s/bsc_nearest_timer/osmo_timers_nearest/g s/bsc_prepare_timers/osmo_timers_prepare/g s/bsc_update_timers/osmo_timers_update/g s/bsc_timer_check/osmo_timers_check/g
2011-05-02nat: Create a Paging Group that BSCs can refer toHolger Hans Peter Freyther1-0/+7
Introduce a paging group that a BSC can refer to and is used during the LAC lookup. This way paging can be flooded through the network and just filtered at the last element in the core.
2011-05-02nat: Introduce the concept of a paging group and use itHolger Hans Peter Freyther1-0/+14
A paging group is a list of LACs, different BSCs can point to a paging group and use it for the LAC lookup.