Commit Graph

41 Commits

Author SHA1 Message Date
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 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 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 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 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 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 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 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