Commit Graph

2265 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther d131b79fc2 [nat] Send a RSIP down to the BSC after it connects
Make sure the MGCP attached to the BSC is resetting all
endpoints whenever the BSC is connecting to us as we assume
that all endpoints are available.
2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther f7d3335817 nat: Add MGCP code and parsing to the nat code..
For the nat we will have NAT and MGCP in the same process
and this commit starts with that. We are linking in the MGCP
code and one can embed MGCP config snippets...
2010-06-15 20:24:09 +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 23fe7be1ca sccp: Move the destruction of the sccp connection to a new place 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 d7657ffc84 nat: Fail more early in the case of not being authenticated
This is also fixing a possible memory leak.
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 e9be5175ff nat: Some more input validation... on the paging command. 2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther a5784b58f0 nat: Documentation fix... use nat for the parameter 2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther 39ee87783f nat: Verify that the configured LACs are unique across the nat 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 64622e42ed nat: Fix the lookup of connections to and from the BSC
When sending a message to the MSC in the case of DT1
messages we only have the address of the MSC, so we
need to go with that, otherwise (e.g. in case of a CR, RLC)
we do have the source address and need to patch it.

When forwarding a message to the BSC we do receive
a msg that should contain the patched address, we need
to unpatch it...
2010-06-15 20:24:09 +08:00
Holger Hans Peter Freyther 16a6f70834 nat: Keep track of both sides of the connection
On a CC message we will need to remeber where the source local
reference of the network belonged so we can properly identify
the connection when receiving UDT messages.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther f8048d9f5c nat: Assign the connection inside the new helper function. 2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther 58a56797a8 nat: Actually add the connection to the SCCP list of active connections
Add the connection to the list of active connections. Otherwise
we are not able to find the connection.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther 0dc569abc2 filter: Move logging level down to INFO 2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther ea8cbd5e72 nat: Compare the IPA size with the actual size of the data...
One sanity check that was needed in my test case..
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther dcf8a7db43 nat: Move creation of the structs to a separate file
This way one can create the bsc_nat structure in unit tests..
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther 0ab6babbde nat: Move SCCP patching to a new file, log updates
Move patching and reassigning of messages to a new file which
will making testing this functionality more easy.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther cd895377ca nat: Handle MSC disconnect by closing all NAT connections
When we disconnect from the MSC handle it by pushing the problem
to our connected clients. We will simply close all connections,
reject all new BSC connections and attempt to reconnect to the MSC.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther baf2abe4c4 msc: Create a real interface for BSC MSC and start handling reconnects
Create a BSC<->MSC interface and use it for the BSC MSC IP and the
BSC NAT to reduce code duplication on handling reconnects to the MSC
and cleaning up the local state. The code is only partially tested
and will contain bugs. Currently both the BSC and the NAT will just
exit on connection loss and this way have the current behavior.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther 6c0a04e196 bsc_msc: Connect in a non blocking way to the MSC
The latency of setting up of the TCP connection can be quite high,
it is better to connect in a non blocking way. This code is working
by setting the socket nonblocking and temporarily replacing the
bfd callback with the connect handling.
Once the OS has connected our socket we switch back to normal operation.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther 7c99d4fbf0 nat: Add a warning for an important todo item on connection loss
In case we disconnect with some pending operations we will need to
signal the MSC that something is wrong. This could be by sending a
RLSD directly, or a clear command. Another part of the fix is to
respond with a RLC on unknown RLSD messages.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther f38e879ca4 nat: Clear all pending messages in case the BSC disconnected
Throw away all messages we have scheduled but never delivered
to the BSC.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther 3025e198ea nat: Switch downstream over to the write queue 2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther db7ba7db8b nat: Stop using the input/ipaccess.c method as it will write directly
We want to write everything through the write queue, it seemed the
easiest to copy the bytes here and feed the data into the bsc_write
method.
2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther 0fb47e0273 nat: Make it clear where we want to send these methods 2010-06-15 20:24:08 +08:00
Holger Hans Peter Freyther 747d654189 nat: Move one more area to the bsc_write method 2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther f7cb33cb33 nat: Move BSC msg sending to a new method.
Move all writes into one place so we can switch to the
write queue more easily in the future.
2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther ed07a3fc1c nat: Start using a write_queue for the BSC connection
We are still writing to the BSC directly and don't make real
use of this feature right now but we will need to do it.
2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther 6f5fbfd6bf nat: Move MSC write to the write_queue and make it non blocking
Move the MSC code to a non blocking write.
2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther 2d677c6787 nat: Rename variable from connection to listen
This is the socket we listen for incoming BSCs.
2010-06-15 20:24:07 +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 6c45f2e325 nat: Redo a merge with master that happend at this time. 2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther aad68b5ef8 [msc/nat] It is better to use msgb_free to free the msgb
msgb_free is currently calling talloc_free but this might
change in the future and then this code would break..
2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther a416776ee3 [nat/bsc] Fix memory leak of IPA messages...
* The read_msg method is allocating the msgb and we will
  need to free it once we are done with it.
2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther 45d1181a82 [nat] Intercept the PAGING message and then forward it to the BSCs with that LAC
* Provide access to the GSM0808 TLV attributes so we can use it in
  the nat code.
* Read the PAGING message, if it is paged by LAC we go through each
  LAC and then attempt to find the proper BSC connection and then
  send the message to that BSC.
2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther 7c11d1df1b [nat] Fix compiler warning.. 2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther aa6982445f [nat] Implement token based identification.
Based on the token the NAT/MUX is capable of figuring out
which LAC this BSC is supposed to satisfy. This will be
needed for messages like paging that can be done by LAC.
2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther 3f37b8fba3 [nat] Do not forward messages from and to BSC when it is not authenticated
* Start using the authenticated bit in the BSC connection. This means
  that currently no messages are forwarded to the MSC from unauthenticated
  BSCs.
2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther 6b8763ed9a [nat] Use default handler for SIGINT to quit the app 2010-06-15 20:24:07 +08:00
Holger Hans Peter Freyther 9a85ef3266 [nat] Add VTY support to the BSC nat application
* Create struct bsc_nat and move the various lists into this structure
* Create the VTY code
* Call the VTY init and parsing code
* Create functions to create the types..
* Add some stuff into the bsc_connection to be used for the NAT with
  proper config files. E.g. to close the connection if the BSC does not
  respond to a given command.
2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 9f8f3d09a6 [nat] Move the structs to the header file
This way the VTY code can use the structures to implement
the show functionality.
2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 6db5ce5318 [nat] Add missing Makefile.am.. 2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 45f7dcd9ae [nat] Make some methods static. 2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 058eeb7ab0 [nat] Begin to patch SCCP connections
For the one MSC and n BSC case we need to patch the SCCP source
local reference on connection orientated links to avoid a clash.

For simple UDT packages we just let them pass and for SCCP connection
we have to:
    1.) Create an entry on Connection Request
    2.) Patch the entry on Connection Confirm, Connection Refuse,
        Connection Release, DT1, Connect Release Complete
    3.) Remove the entry on Connection Release Complete

The current code is blocking CRs, Release Complete from the MSC, and
creates the connection state only from the BSC side. The code to
assign a source reference is taken from sccp.c and handles wrap
arounds and such properly. We rely on the SCCP parser to fill out the
place to the source reference correctly so we can easily fix it.

The whole code is young and might contain bugs we need to resolve..
2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 38a77d0098 [nat] Send a GSM 08.08 Reset Ack to the BSC...
When the reset was filtered out to the MSC we will respond
with a GSM08.08 reset ack right away. We are using a static
acknowledge here.
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