Commit Graph

302 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 93ef33edb6 tests: Use atlocal/atlocal.in to enable/disable the NAT test
Kill the hacking, use atlocal to remember if the NAT test should
be enabled and then skip the test (exit with 77).
2012-01-09 22:53:04 +01:00
Holger Hans Peter Freyther 03ff1c8477 Revert "tests: Make the test setup more abusive to fix the build"
This reverts commit 41b42c7229.
2012-01-09 21:49:47 +01:00
Holger Hans Peter Freyther 41b42c7229 tests: Make the test setup more abusive to fix the build
Paolo says I will need to use atconfig/atlocal, need to read up on
it first though.
2012-01-09 21:13:15 +01:00
Holger Hans Peter Freyther faf1f64a2d gprs: Honor GSM 04.64 8.4.2 Receipt of unacknowledged information
GSM 04.64 8.4.2 asks to ignore UI frames if the DLCI is not known,
or if the "(V(UR)- 32) <= N(U) < V(UR)". E.g. if we want to have
V(UR) == 511 and this frame is dropped, we would ignore N(U)'s
0 to 510. Calculate the delta.

The code is based on Jonathan Santos's "LLC UI window" fix but the
issue was discovered independly.
2012-01-06 18:52:05 +01:00
Holger Hans Peter Freyther 6c88217c19 tests: Introduce running tests with GNU autotest in OpenBSC
The quality of the tests is of different value but it is good to
get started and improve from here.
2012-01-06 18:52:05 +01:00
Holger Hans Peter Freyther d5b3ca621b mgcp: Print message when the test is finished 2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther 300457b7d2 gsm0408: Print message when the test is done 2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther 45222a79e2 db: Fix the test code
* Initialize logging
* use a dummy net before calling subcr_put as the keep in ram
  option is going to be set.
2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther 08e324fda7 channel: Make the test not crash again.
* Initialize logging
* The callback expects NULL or a subscriber connection
2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther f5ede52a22 nat: Log test output stdout using printf in prep for GNU autotest 2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther 06c9da6c22 misc: Move the bsc_parse_reg to libcommom and name it gsm_parse_reg
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-08-22 18:21:33 +02:00
Pablo Neira Ayuso ed5cacb240 src: port openBSC over libosmo-abis
This is a big patch that ports openBSC over libosmo-abis.
Sorry, the changes that are included here are all dependent
of libosmo-abis, splitting them into smaller pieces would
leave the repository in some intermediate state, which is
not desired.

The main changes are:

- The directory libabis/ has been removed as it now lives in
  libosmo-abis.

- new configuration file format for nanoBTS and HSL femto, we
  need to define the virtual e1_line and attach it to the OML
  link.

- all the existing BTS drivers (nanoBTS, hsl femto, Nokia site,
  BS11 and rbs2000) now use the new libosmo-abis framework.

- use r232 input driver available in libosmo-abis for bs11_config.

- use ipa_msg_recv instead of old ipaccess_read_msg function.

- delete definition of gsm_e1_subslot and input_signal_data.
  These structures now lives in libosmo-abis.

Most of this patch are deletions of libabis/ which has been
moved to libosmo-abis.

This patch also modifies openBSC to use all the new definitions
available in libosmocore and libosmo-abis. In order to do that,
we have replaced the following:

- DINP, DMI, DMIB and DMUX by their respective DL* correspondences.
- SS_GLOBAL by SS_L_GLOBAL
- SS_INPUT by SS_L_INPUT
- S_GLOBAL_SHUTDOWN by S_L_GLOBAL_SHUTDOWN
- SS_INPUT by SS_L_INPUT
- S_INP_* by S_L_INP_* sub-signals
- E1INP_NODE by L_E1INP_NODE vty node

This patch has been tested with:
- one nanoBTS
- the HSL femto with the examples available under libosmo-abis
- BS11 with both dahdi and misdn drivers.
2011-08-19 22:38:35 +02:00
Holger Hans Peter Freyther 3d331c0062 misc: Link to libosmogsm after adding our static libraries
GCC 4.6.0 and LD.BFD 2.21 on ARM somehow fail to resolve
the dbi symbols when we have the library in front of the
static libraries, move them to the back.

Without this patch the tlv_def_patch symbol and the
gsm48_construct_ra.
2011-06-30 21:41:08 +02:00
Holger Hans Peter Freyther f5bbb1eb71 misc: Link to -ldbi after adding our static libraries
GCC 4.6.0 and LD.BFD 2.21 on ARM somehow fail to resolve
the dbi symbols when we have the library in front of the
static libraries, move them to the back.
2011-06-30 20:32:33 +02:00
Harald Welte 23cf666359 update debug_test with logging system changes
Thanks to Konrad Meier
2011-06-27 14:23:40 +02:00
Harald Welte e31816c83b make channel_test build again 2011-06-26 14:55:06 +02:00
Holger Hans Peter Freyther acc4031cf5 nat: Look into the TPDU/SMS-SUBMIT and use the TP-DestAddress for matches
Match the used SMSC and the destination of the SMS and change
the SMSC address if both are matched.
2011-06-01 20:45:12 +02:00
Holger Hans Peter Freyther 9c20571280 nat: Patch the destination SMS address of a message
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-01 20:45:03 +02:00
Holger Hans Peter Freyther df8e6e9e4a nat: Prepare to patch more than the CC Setup message
Refactor the code to allow having different handlers. The goal
is to be able to patch some SMS messages too.
2011-06-01 20:41:30 +02:00
Holger Hans Peter Freyther ad75eababc nat: Allow to have a regexp to match the MSISDN
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-06-01 20:40:35 +02:00
Holger Hans Peter Freyther 67cd75f9fa misc: Use the osmo_init code for signals and logging
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-12 16:11:14 +02:00
Pablo Neira Ayuso ab46cf38d4 src: rename msg_entr* to osmo_config_*
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-07 13:15:11 +02:00
Pablo Neira Ayuso c0d17f2266 src: use namespace prefix osmo_* for misc utils
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-07 12:58:59 +02:00
Pablo Neira Ayuso 4db9299286 src: use namespace prefix osmo_fd* and osmo_select*
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-06 12:11:23 +02:00
Holger Hans Peter Freyther 1ffe98c175 nat: Rewrite the paging handling.
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-05-02 19:19:15 +02:00
Holger Hans Peter Freyther c42ad8b686 misc: Move from u_int to uint types of stdint.h
This was done with sed on the files.
2011-04-18 17:31:39 +02:00
Holger Hans Peter Freyther 4c9557ef24 nat: Bail out if the regexp fails to compile and avoid a crash
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-04-04 19:19:26 +02:00
Pablo Neira Ayuso 928cb33eb4 tests: fix bsc-nat test
In 136f453dd2, 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-03-26 23:57:53 +01:00
Pablo Neira Ayuso 136f453dd2 src: use new library libosmogsm and new path to headers in libosmocore
libosmogsm is a new library that is distributed in the libosmocore.
Now, openbsc depends on it. This patch gets openbsc with this
change.

This patch also rewrites all include path to the new
osmocom/[gsm|core]

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-23 18:17:56 +01:00
Harald Welte bab983764e Fix Makefile.am for builddir != srcdir 2011-03-05 15:20:18 +01:00
Harald Welte c1b2cfafd4 Fix build of bsc-nat test 2011-03-04 13:49:02 +01:00
Harald Welte 89579b4317 prefix sub-directories containing libraries with 'lib'
... and make sure tests work again after restructuring
2011-03-04 13:23:09 +01:00
Holger Hans Peter Freyther afb883956d mgcp: Fix make distcheck due a copy 'n pasted Makefile.am 2011-02-28 20:45:55 +01:00
Holger Hans Peter Freyther 1f0c5b4742 mgcp: Allocate the endpoints for the E1 trunks as well. 2011-02-28 19:40:53 +01:00
Holger Hans Peter Freyther 88ad7723b4 mgcp: Introduce a mgcp_trunk_config enum for endpoint configs
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-28 19:40:53 +01:00
Holger Hans Peter Freyther 9212d9d636 nat: Fix some corruption in the test case 2011-02-27 11:18:41 +01:00
Holger Hans Peter Freyther 9ec030d32d nat: Change number of multiplexes to the max-endpoints 2011-02-27 11:05:18 +01:00
Holger Hans Peter Freyther a9e9331285 nat: Allocate endpoints from multiple multiplexes.
This code allocates endpoints from multiple multiplexes but
will always leave 0x0 and 0x1f unassigned in the multiplex.
2011-02-26 11:38:00 +01:00
Holger Hans Peter Freyther 86c1db6338 nat: Verify that we are not assigning 0x1f as endpoint.
On a classic BSC we have 32 channels but one is reserved for
signalling. Make sure that we are not assigning 0x1f as we
assume that this is the signalling channel. This means that
from 32 possible voice channels we are only going to use 30
as we are already not using the 0x0.
2011-02-26 10:38:52 +01:00
Holger Hans Peter Freyther ed500e3877 nat: Allocate the endpoint status dynamically
Allocate the status for an endpoint dynamically. We will support
BSCs with different amount of multiplexes and need to have this
flexibility in the future. Add the proper null checks to the
current users of this code.
2011-02-26 10:35:33 +01:00
Holger Hans Peter Freyther 7e0cc50e44 nat: Update the tests to make them going again
We now need to have access to a mgcp_cfg and the change to the
setup number patching needs new data. We now set the number to
international type.
2011-02-25 17:30:48 +01:00
Harald Welte f338a03b0c [BSC] Move the BTS-type specific code from bcs_init.c to bts_*.c
bsc_init.c was a big mess even only for two supported BTS models,
so before adding more BTS types, this needs a cleanup.

All the BTS specific code from bsc_init.c has now moved into
bts_{siemens_bs11,ipaccess_nanobts}.c

This has required that input_event() and nm_state_event() get both
converted to proper libosmocore signals instead of referencing external
symbols.
2011-02-11 16:26:31 +01:00
Holger Hans Peter Freyther f43f2fce82 mgcp: We want to count trunks starting from one. 2011-01-07 11:34:50 +01:00
Holger Hans Peter Freyther 9f239a2a0f mgcp: Parse a Digital Trunk endpoint name. 2011-01-06 19:35:10 +01:00
Holger Hans Peter Freyther 763b42a92a subscr: Dump the pending requests to help with debugging state. 2011-01-06 14:52:52 +01:00
Holger Hans Peter Freyther ffccb77df0 subscr: Stop all paging requests if one is failing.
If one paging request is timing out the others will timeout soon
as well. With the current code the next timeout would expire the
next request in the queue. We will now stop all paging requests
and then issue a next paging request. So for both paging success
and failure we will now stop all the other requests.

This is mostly a workaround, one should count on how many
BTSes we are paging and wait for all failures before we remove
the item from the queue.
2011-01-06 14:52:52 +01:00
Harald Welte 9af6ddfcec License change: We are now AGPLv3+ instead of GPLv2+
The reason for this is quite simple: We want to make sure anyone
running a customized version of OpenBSC to operate a network will
have to release all custom modifiations to the source code.
2011-01-01 15:39:34 +01:00
Holger Hans Peter Freyther 28dcbc5ee5 misc: Remove gsm_subscriber.h from the db.h file
Reduce the dependencies on the header files.
2010-12-22 18:26:36 +01:00
Holger Hans Peter Freyther d9cdd056ff test: Make it compile but it is segfaulting on start now 2010-12-21 13:43:52 +01:00
Holger Hans Peter Freyther ecd94a4b45 misc: Introduce a --enable-coverage mode to build with gprof coverage
This adds a test coverage build. One can use gcov and lcov on the
resulting data afterwards to see which code paths were executed and
which were not.
2010-11-15 20:06:45 +01:00
Holger Hans Peter Freyther 74779c68f7 nat: Add test case for matching phone numbers
Add the test case for matching '*' and for not matching at all
2010-10-28 15:27:00 +02:00
Holger Hans Peter Freyther 73bbf89245 nat: Implement rewriting, have a very basic test for that feature 2010-10-27 10:40:44 +02:00
Holger Hans Peter Freyther 749497eeb3 nat: Copy the IMSI, then free it or move the context to the connection
Extract the IMSI from the first message as well and safe it
in the connection structure. The problem is that we do not
have this structure at this point, so we will allocate the
imsi as child of the bsc_connection and then move/steal it.
2010-10-21 12:22:50 +02:00
Holger Hans Peter Freyther 1fd60631f7 nat: Change the order of the DENY/ALLOW rule for the BSC.
Currently it is not is not easily possible to disable
everyone and then only allow certain SIMs. By changing
the order we can do:
	access-list imsi-deny  only-something ^[0-9]*$
	access-list imsi-allow only-something ^123[0-9]*$

and still keep the usecase of only forbidding certain
SIMs on certain LACs. Adjust test case, test that the
other cases are still functional.
2010-10-19 20:55:33 +02:00
Holger Hans Peter Freyther 3e9a7f80bd misc: Replace the idiom for replacing a string with a function call
Remove a lot of code in favor of a new function that is freeing
the old string and copying the new one. I should have gotten the
context and the strings right.
2010-10-12 23:31:53 +02:00
Holger Hans Peter Freyther 0bd60f3317 nat: Allow a BSC to have multiple LACs
Make it possible that one BSC is serving multiple
cells. Introduce a list of lacs, add functions to
manipulate the lists. The current test cases for
paging by lac continue to work.
2010-10-08 22:21:46 +08:00
Holger Hans Peter Freyther cd702379fe nat: Test for a bug inside the TLV definition for GSM 08.08
The 0x1 inside a CIC IE could indicate a new IE... add test data
and test case to verify that the patching works correctly.
2010-09-20 02:47:17 +08:00
Holger Hans Peter Freyther d2df4cab43 nat: Test the endpoint finding a bit better... 2010-09-20 02:46:57 +08:00
Holger Hans Peter Freyther adb6e1cce1 janitor: Move the * to the variable name 2010-09-18 06:44:24 +08:00
Holger Hans Peter Freyther 3268540fc3 nat: Parse the id response, extract the IMSI, compare it
Add a test case and also add a basic check that we got some
size checks correct. The next step is to act on the result.
2010-09-15 18:58:36 +08:00
Holger Hans Peter Freyther d880f54f4b nat: Update the test for the new <0,0,1 semantic of the filter function
A test case with a TMSI is missing, this would be needed for
better coverage of the filter test case.
2010-09-15 18:58:36 +08:00
Holger Hans Peter Freyther 78891078fe chan: Store the to be assigned channel type in the GSM Network.
Store the mapping from request to channel type in the GSM Network
struct as there is some policy involved with handling the request.

E.g. in a half rate network we don't want emergy calls to be getting
a TCH/F, or we want to have a different policy for early/late assignment
of phone calls. Update the table when creating the network and when
the neci is changed.
2010-09-06 09:36:02 +08:00
Holger Hans Peter Freyther f7c86c5b4d nat: Replace the MGCP Endpoint if that is required
Add code to replace the Endpoint number for the mgcp.
2010-08-30 13:44:32 +08:00
Holger Hans Peter Freyther 45fd07dc33 nat: Attempt to assign the BSC Timeslot based on a free list
Do attempt to not reassign an endpoint immediately but go
to the next free one.
2010-08-29 16:35:26 +08:00
Holger Hans Peter Freyther f4b3439206 nat: Make the code work in terms of endpoints instead of timeslot/multiplex
We are going to have more than one trunk, so all code hardcoding the
multiplex to zero must go. Avoid this kind of problem by saving the
MGCP endpoint number and comparing that.
2010-08-29 16:35:24 +08:00
Harald Welte d5db12c160 Use new include paths of libosmo-sccp 0.0.2 2010-08-03 15:11:51 +02:00
Holger Hans Peter Freyther c2b31ed9cd nat: Fix compilation with nat not being enabled.
common_vty.c was including bsc_nat.h which tried to
get the sccp/sccp_types.h which is not required to be
installed. Move all structs using/embedding SCCP structures
into the bsc_nat_sccp.h and include. This should fix
the compilation.
2010-07-31 05:20:31 +08:00
Holger Hans Peter Freyther 30e1ae923d sccp: Use the external libosmo-sccp as sccp implementation
Add --enable-nat and --enable-osmo-bsc to build applications
requiring the Osmo SCCP library to be installed. We are not
using autodiscover as this is out of fashion.
2010-07-31 04:09:38 +08:00
Holger Hans Peter Freyther e2c1520a71 nat: u_int16_t -> uint16_t 2010-07-23 19:09:21 +08:00
Holger Hans Peter Freyther dbd16fe59a nat: u_int8_t -> uint8_t 2010-07-23 19:08:55 +08:00
Holger Hans Peter Freyther f957095385 sccp: u_int16_t -> uint16_t 2010-07-23 18:39:39 +08:00
Holger Hans Peter Freyther c2c4621a5d sccp: u_int8_t -> uint8_t 2010-07-23 18:39:17 +08:00
Holger Hans Peter Freyther f0945408f5 nat: Fix the testcase and init the logging infrastructure 2010-07-05 13:29:42 +08:00
Holger Hans Peter Freyther 9764331062 bsc_api: Move gsm48_rcvmsg into the BSC API and dispatch.
The next step in the way to the BSC API. We have a clear a
new connection was opened signal now... and the MSC could
use it...
2010-06-17 16:41:25 +08:00
Holger Hans Peter Freyther 28e2988ce2 nat: Add the OSMO NAT to the build process. 2010-06-15 20:31:43 +08:00
Holger Hans Peter Freyther 434a1fd84e nat: Make the test compile, no bssap.c, use log_target 2010-06-15 20:31:43 +08:00
Holger Hans Peter Freyther d77c8171aa nat: Allow to specify multiple entries in the access-list...
Inside the access-list we have a list of entries that have
either one allow or one deny rule... we do not allow to remove
a single rule but one has to remove the whole list, in that case
talloc will handle cleaning all entries.

Right now the matching is O(n*m) as we traverse the list
(multiple times) and run the regexp multiple times. One
way to make it faster would be to concat all regexps into
one.
2010-06-15 20:24:21 +08:00
Holger Hans Peter Freyther 29c67039fe nat: Shorten the access-list struct and method names (still way too long) 2010-06-15 20:24:21 +08:00
Holger Hans Peter Freyther 8affef5059 [nat] Introduce the concept of access-list
One can set one access-list to one BSC and one
access-list to one NAT. The matching of IMSIs
remains the same for now, also applying the
white/blacklist. Access lists can not be deleted
for now and no perf opt is done (e.g. one could
cache the result of the last lookup in the bsc
struct).
2010-06-15 20:24:21 +08:00
Holger Hans Peter Freyther fa20c94456 [nat] Make create_sccp_src_ref return the SCCP Connection.
Right now it was not possible to just find a connection, by returning
the connection that is created we will have direct access to it. It
will be used by the local connection handling.
2010-06-15 20:24:20 +08:00
Holger Hans Peter Freyther e1fb5670cd [nat] Remove parameter that is never accessed directly
The msgb needs to be around when we access the parsed structure
but that needs to be guranteed by the caller handing out the parsed
structure.
2010-06-15 20:24:20 +08:00
Holger Hans Peter Freyther 19c0a84fb8 [nat] Set the connection type/reason as out parameter
We are analyzing each CR message and it is nice to know the
reason these connections were created. Change the nat method.
2010-06-15 20:24:20 +08:00
Holger Hans Peter Freyther f192498885 [nat] Parse the PAGING RESPONSE inside a CR message as well.
Now we are parsing a CM Service Request, Location Updating Request
and the Paging Response. For all other messages we claim to not
support it and force a refuse.
2010-06-15 20:24:20 +08:00
Holger Hans Peter Freyther f1012a432c [nat] Remove the imsi allow option on the nat level.
For now we have:
1.) bsc imsi deny to deny at the BSC level
2.) bsc imsi allow to allow a SIM at the BSC level
3.) nat imsi deny to deny at the global level
2010-06-15 20:24:19 +08:00
Holger Hans Peter Freyther a0aeaa799e [nat] Fix the regexp of the test and the command line. 2010-06-15 20:24:19 +08:00
Holger Hans Peter Freyther 34a96aeb32 [nat] Implement IMSI filtering... 2010-06-15 20:24:18 +08:00
Holger Hans Peter Freyther 0c08db17bf nat: Start to add a test case.. with one CR message. 2010-06-15 20:24:18 +08:00
Holger Hans Peter Freyther c14e09bb2d nat: Store the creation time of a sccp connection.
Generate it when creating the connection but also when
reusing an existing connection.
2010-06-15 20:24:18 +08:00
Holger Hans Peter Freyther 7b7eef62c1 nat: Change MGCP DLCX handling and send dummy MDCX to the BTS.
When setting a new MSC timeslot to a SCCP connection check if
any of the existing connections have this timeslot, if so we will
send a DLCX down the stream to make sure it is closed there, when
we will CRCX this new timeslot we will happily reallocate it.

When the SCCP connection goes away, or we get a DLCX from the
network, or the BSC is gone we will send a DLCX message down the
stream as well.

When we receive a CRCX from the network we will forward the CRCX
as usual and send a dummy MDCX after it.

For the DLCX and the dummy MDCX we send a custom MGCP message
that will not provoke an answer. Even if the downstream MGCP GW
will answer we will ignore it due the dummy transaction id that
is not used anywhere else.

This change should make sure that we close the dowstream endpoint
all the time, even when the DLCX arrives after the SCCP connection
is torndown.
2010-06-15 20:24:16 +08:00
Holger Hans Peter Freyther b5513caaf8 [nat] Lookup by BSC Connection otherwise the point of reassigning the is defeated
When sending a MSG to the MSC try to find the to be used "src" reference
by comparing the reference on the BSC and the BSC connection. Only this
tuple needs to be unique.
Actually only when looking at the SRC REF we need to compare the BSC as the
dest reference should be unique but we are just making the check a bit stronger
to make it look symmetric.
2010-06-15 20:24:15 +08:00
Holger Hans Peter Freyther 5e63f921f0 [nat] Add unit test to forward Proto Error messages back both ways. 2010-06-15 20:24:15 +08:00
Holger Hans Peter Freyther c87c8b748e nat: Fix the test case by allocating a config.
For the statistics we do need to have an allocated config,
otherwise we will nicely crash.
2010-06-15 20:24:14 +08:00
Holger Hans Peter Freyther 08a1b16674 nat: Return the SCCP Connection again...
We will reset the multiplex in a DLCX message and then
we can reset the multiplex as well...even if the MGCP
connection is staying open. or at least this is a theory.

The MSC likes to leave a connection open during CallControl
when hanging up early enough in the process.
2010-06-15 20:24:14 +08:00
Holger Hans Peter Freyther 979a309c94 nat: Print the LAC that was searched for and not found. 2010-06-15 20:24:14 +08:00
Holger Hans Peter Freyther 47dd4944ae nat: Store the config in the connection instead of the lac
This allows that we can print the Nr. next to the lac
and it allows us to change the lac at runtime without
reconnecting the BSC.
2010-06-15 20:24:12 +08:00
Holger Hans Peter Freyther d2dd6e878c Revert "nat: Remember where the BTS is listening for things."
Remove the code to parse port as we need to discover the
BTS behind the nat and most likely it will have a different
port than the one advertised by the BTS.

This reverts commit c6a1fe773d.
2010-06-15 20:24:11 +08:00
Holger Hans Peter Freyther 0a6f62f8e3 nat: Test forwarding Inactivity Test messages.
No change needed to the code.
2010-06-15 20:24:11 +08:00
Holger Hans Peter Freyther 9d51855f66 nat: remove is called on already patched connections..
Fix the test to search for the original message instead
of the already patched one that should not find any items
anyway.

The remove is called on already patched connections so we
need to match it with the patch reference count.
2010-06-15 20:24:11 +08:00
Holger Hans Peter Freyther f05506eceb nat: Remember where the BTS is listening for things.
Extract the port from the BSS's MGCP Gateway so we know
where to forward the data to.
2010-06-15 20:24:11 +08:00
Holger Hans Peter Freyther 9e5300ada6 nat: Remove the broken empty line check, follow \n vs \r\n of input
Instead of checking the token for NULL we need to check if running
was set to null. Look at the data of the token and check if the line
was ending with a \r\n or \n and then when rewriting a line use that
line ending as well. Add a new test for that.
2010-06-15 20:24:11 +08:00
Holger Hans Peter Freyther 8d20065c4b nat: Make rewrite work on string, read to a string first, copy to msgb
The MGCP protocol parsing is adding '\0' to make sure we do not
parse beyond where we should parse. This does not mix with strtok
or similiar routines.
For now we will read the msg into a global array first, then copy
it to the msgb for mgcp protocol handling and if we are required
to forward it to the MGCP we have a untouched copy we will modify
into our own msgb.
2010-06-15 20:24:10 +08:00
Holger Hans Peter Freyther 3c3bce10bd nat: Return MGCP messages to the call agent
Attempt to find the message by transaction id, then patch
the response and use the IP/PORT of the local network, update
the ci with the one from the BSC.

This is currently not tracking any state of the MGCP and will
not handle two bsc's... this will need to happen later.

With this in we should be feature complete and now enter the
mode of making all of this work reliable and fixing thinko's
and other bugs.
2010-06-15 20:24:10 +08:00
Holger Hans Peter Freyther a128d91f98 nat: Allow to send MGCP messages from the BSC to the network 2010-06-15 20:24:10 +08:00
Holger Hans Peter Freyther 76c8354863 nat: Test rewriting of MGCP messages to patch ip and port
Add code to change the ip and port for audio data inside
MGCP messages. This is needed because the BSS might be
behind the NAT and can not reach the network directly and
might be behind a nat so the announced sourceport is not
the one as we see it.
2010-06-15 20:24:10 +08:00
Holger Hans Peter Freyther fc9bd23000 nat: Add code to find a BSC connection by the given msc multiplex 2010-06-15 20:24:10 +08:00
Holger Hans Peter Freyther 241e13005a nat: In the case of losing the MSC, reset all endpoints
When losing the SCCP connection make sure that we free all
endpoints. The disconnection of the BSC should already make
sure they are closed but this makes sure everything is
properly reset.
2010-06-15 20:24:10 +08:00
Holger Hans Peter Freyther 465313e48c nat: Look at the assignment command and remember on which timeslot the data is
This information will be needed when we are trying to forward
MGCP connections to and from the BSC through the IPA protocol.
2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther 49c7fb52f0 nat: Return the SCCP connection, change order of patching and updating
* Return the SCCP connection. This will be needed to store the
  assigned timeslot in there.
* Update code to work with this change
* This uncovered a bug in the CC handling, at the time the BSC was
  passed it was still a null pointer and the code would have failed.
2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther 72ba1624b3 misc: Do not prepend 0x when using %p in printf. 2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther 04fd992af3 nat: Add test case and data for paging by lac test. 2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther bae9da49b9 nat: Move paging by lac handling code into the utils file
Moving it here means we can more easily test this code, there is one
behaviour change with the code that we only support paging messages
with one LAC and will silently ignore the others.
2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther 38f7c75739 nat: Add a test case for the connection tracking
This test case tests connectiont tracking by sending
a CR, getting a CC, sending a DTAP, receiving a DTAP,
receiving a RLSD, sending a RLC. It verifies that the
messages are properly patched specially the references
at the BSC.
2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther df6143a08e Correct the company name. It should be On-Waves (ehf) 2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther 6db5ce5318 [nat] Add missing Makefile.am.. 2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 1d6fb18b57 [nat] Specify the direction of the message
Do not run into the situation where we need to filter in one
direction but it should not be filtered..
2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 0b8f69d839 [nat] Prepare more sophisicated filtering and patching
Introduce a bsc_nat_parse method to parse a IP Access method
into various parts. Write out the IPA Proto, in case SCCP is used,
store the msg type, pointers to the source/dest local reference and
other information.

Use the result of bsc_nat_parse inside the bsc_nat_filter method
to decide if the message should be dropped or not.

In the future the bsc_nat_parse result will be used for patching
SCCP references and other parts of the message.

The filter language should be able to filter the msg type of SCCP
messages and gain the "NOT" word in the filter language.
2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther d941edaca2 Merge branch 'on-waves/sccp' 2010-04-25 23:07:24 +08:00
Holger Hans Peter Freyther 2cdda72b3c [sccp] Parse the error message and add a unit test for it. 2010-04-25 23:04:38 +08:00
Holger Hans Peter Freyther 500ff97c21 Fix compiler warning about void return in non void method. 2010-04-07 23:00:23 +02:00
Holger Hans Peter Freyther 014136da47 Merge branch 'on-waves/sccp' 2010-04-07 22:54:12 +02:00
Harald Welte dc5062b185 move log/debug codebase to libosmocore
The logging/debugging code is generic enough to move it into libosmocore
while keeping OpenBSC specific definitions in openbsc itself.

This commit uses the logging support present in libosmocore-0.1.2,
you will have to update your library to this version.
2010-03-26 21:31:43 +08:00
Holger Hans Peter Freyther 3c1221e2b2 sccp: Change the ownership of the msgb passed to the callback
Instead of deleting the msgb within the SCCP library the implementor
of the write callback needs to free it. This is required for non
blocking io with the server.
2010-03-26 05:44:21 +01:00
Harald Welte afedeabd91 move some gsm48 utility functions to libosmocore
* gsm48_generate_lai() gsm48_generate_mid_from_tmsi() gsm48_generate_mid_from_imsi()
* gsm48_cc_msg_names[]
2010-03-04 10:55:40 +01:00
Holger Hans Peter Freyther 10ca3799e7 Merge remote branch 'origin/master' into on-waves/sccp 2010-02-26 20:18:24 +01:00
Holger Hans Peter Freyther 140f6e9b12 [misc] Add LIBOSMOCORE_CFLAGS to the includes 2010-02-26 20:10:58 +01:00
Holger Hans Peter Freyther e1d5067789 [sccp] Implement parsing the rather easy IT messages. 2010-02-26 19:26:35 +01:00
Harald Welte f98a4974d7 finish openbsc / libosmocore separation
* use pkg-config from openbsc to find header and library
* move sms and timer tests to libosmocore itself
* ensure "make distcheck" works on both packages
2010-02-20 17:29:27 +01:00
Holger Hans Peter Freyther 7184c2d7d2 Merge branch 'on-waves/sccp' 2010-02-12 22:52:12 +01:00
Holger Hans Peter Freyther 8a69cb2d99 [sccp] Make the file includable outside of OpenBSC 2010-02-12 22:51:24 +01:00
Holger Hans Peter Freyther b19dc286aa liblaf0rge: Make the other targets depend on the liblaforge...
Everything is linking fine here.
2010-02-09 22:04:09 +01:00
Holger Hans Peter Freyther 6ae657228c [sccp] Refer to the right Company in the Copyright/Copyleft line
Use On-Waves instead of the name I made up from the domain name.
2010-02-03 18:17:49 +01:00
Holger Hans Peter Freyther 98657d5dee misc: Fix compilation of the test cases. 2010-01-11 16:42:07 +01:00
Holger Hans Peter Freyther 5dbd71e31d [sccp] Provide dummy db_store_counter... 2009-12-23 05:13:48 +01:00
Holger Hans Peter Freyther 3b05a7affa [channel] Compile statistics.c into the test. 2009-12-23 05:13:29 +01:00
Holger Hans Peter Freyther f9b1f30558 [debug] Make the test case compile and it is still passing 2009-12-23 05:08:12 +01:00
Holger Hans Peter Freyther b61e3b2158 Import the new logging architecture
This is the new logging architecture, including

* support for multiuple logging targets like stderr and vty
* log levels in addition to categories/subsystems
* filtering based on imsi, i.e. only see events for one subscriber
* dynamically change log level for each category for each vty
2009-12-22 22:32:51 +01:00
Holger Hans Peter Freyther fdd0ddf7e9 [sms] Fix compile warning by including gsm_data.h
In file included from sms_test.c:27:
../../include/openbsc/gsm_utils.h:33: warning: `enum gsm_band' declared inside parameter list
../../include/openbsc/gsm_utils.h:33: warning: its scope is only this definition or declaration, which is probably not what you want
../../include/openbsc/gsm_utils.h:34: warning: `enum gsm_band' declared inside parameter list
2009-11-22 18:01:42 +01:00
Holger Hans Peter Freyther 3b9516e0d8 [sccp] Implement sending the Inactivity Test on a connection..
Currently this will send a dummy inactivity test message,
there is currently no parsing or API to receive the messages.

The sequencing and credit entries are empty as sequencing
is currently not used at all.

The test is currently limited to send the message and see
if the application is crashing or not.
2009-11-20 13:09:15 +01:00
Holger Hans Peter Freyther ac96770ad7 [sccp] Implement parts of ITU SCCP for use in the A-Interface
include/sccp/sccp_types.h contain Q.713 and GSM definitions
include/sccp/sccp.h is the application interface resembling
                    the esentials of the UNIX socket interface.

src/sccp.c is the actual implementation of SCCP featuring
           connection and UDT1 support.

tests/sccp/sccp.c is testing connection creation and formating
                  of the SCCP messages used by the A-interface. And
                  it contains a simple fuzzing test to test the
                  robustnes of the implementation.
2009-11-20 13:09:15 +01:00
Holger Hans Peter Freyther 2223025e21 [tmsi] Make the tmsi a 4 octet number
tmsi is four octets long, there is no need to make it a string
and then jump through hoops to convert it to a number. Keep the database
using it as a string to benefit from the NULL handling of the db.

Introduce the reserved tmsi which has all bits set to 1 according
to GSM 03.03 §2.4 and start checking for it and make sure the db
code will never allocate such a tmsi.
2009-09-28 05:14:25 +02:00
Holger Hans Peter Freyther 5d0e56f722 [gsm48] Introduce a gsm48_generate_mid_from_imsi method
Prefix generate_mid_from_tmsi with a gsm48_, create a new method
to binary encode the imsi. Add a unit test for parsing and decoding.

The implementation can parse the data it generated and the
last octet seems to be filled with the end mark.
2009-08-20 13:59:14 +02:00
Holger Hans Peter Freyther e4e8bf4dd0 [subscr] Change the signature... the gsm_network is in the subscr
Remove the extra parameter from the method, the network can be
taken from the subscriber.
2009-08-20 13:56:45 +02:00
Holger Hans Peter Freyther 1494a768c1 [bsc] Move the GSM 04.08 helper functions to gsm_04_08_utils.c
The existing gsm_04_08.c implementation is mixing BSC and MSC
behavior. Move some simple parsing and generation functions over
to gsm_04_08_utils.c to allow a different MSC to define the policy.
2009-08-17 09:52:42 +02:00
Holger Hans Peter Freyther 93d4394d1d [msc] Move gsm_04_08.c, mncc and various others to libmsc
Currently we have circular dependencies from libbsc to libmsc
and this requires to play some linker tricks. The problem will
be solved in two ways, first we will get rid of the circular
dependencies and second we can start using --start-group and
--end-group of the linker to play the tricks for us.
2009-08-17 09:52:42 +02:00
Holger Hans Peter Freyther 857e5e6e30 [subscr] Split gsm_subscriber.c in BSC and MSC part
For the BSC part we still assign a gsm_subscriber to lchan but it
might only contain the TMSI of this subscriber.

For the MSC part we will need the HLR/VLR feature of the gsm_subscriber,
specially the lookup's by number...

So if libbsc.a/libmsc.a are compiled in one app and used the
subscribers will be shared, and if only libbsc.a gets used we will
have more empty gsm_subscriber.c..
2009-08-17 09:52:42 +02:00
Holger Hans Peter Freyther 42e327b52f [msc] Introduce a libmsc.a library
Attempt to split up bsc/msc functionality according to the specs. The
libbsc.a will be responsible for communicating with the BTS, configuring
it, paging, channel allocation and passing layer3 messages in both
ways. libmsc.a will implement the policy and such.
2009-08-17 09:52:42 +02:00
Holger Hans Peter Freyther 9085cda959 tests: Remove the sms sending from the sms test
The test for the 7bit encoding and decoding remains in the code. The
test didn't compile and the code changed too much so the current test
didn't make any sense.
2009-08-17 06:35:59 +02:00
Holger Hans Peter Freyther 7673ce4ebe misc: Firs round of fixing compilation of test cases
Next round should be using them again
2009-08-10 06:40:05 +02:00
Holger Hans Peter Freyther b45649460d db_test.c: Make it compile again 2009-07-29 06:46:07 +02:00
Harald Welte 6bfda782b9 make tests compile again after talloc branch changes 2009-06-26 20:30:46 +02:00
Holger Hans Peter Freyther 800d29d798 [channel] Add a test case for the request foo in gsm_subscriber.c
This is simulating a successfull request and is causing
a segfault. The test is done with a "mock object" in this
case a minimalistic paging implementation which is enough
to show the crash.

Compare that the callback data is supposed to be the same....
2009-06-10 13:26:47 +02:00
Harald Welte 13e10daa33 move openbsc into its own subdirectory 2009-06-10 05:40:52 +08:00