Commit Graph

1658 Commits

Author SHA1 Message Date
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 806aca94c2 nat: No need to match \r\n when parsing the C: N 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 b3e0a032d0 nat: Use a ptr that was allocated by talloc
The endp is part of an array allocated by talloc and simple
array members do not qualify as a context start address.
2010-06-15 20:24:10 +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 bbb9d398e1 nat: Check the authentication bit later...
When moving it up here the code started to reject
the identity responses of the bsc and we would
never authenticate. Move it back down.
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 a0df82d48d nat: Handle CRCX/MDCX/DLCX at the nat
* Forward a rewritten msg to the BSS. We change the IP and port
  to point to the NAT instead of the core network. We also keep
  track of the BSC and the transacition id.
* Handle the case where we have not found a SCCP connection and
  need to send a response ourselves.
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 03ca97e458 bsc-msc: Flush the write queue when we have lost the connection 2010-06-15 20:24:10 +08:00
Holger Hans Peter Freyther a7f8018eb2 nat: First go at handling MGCP inside the nat
Listen on the MGCP gateway port and let our protocol stack
handle everything for now. We will need to have some more
control over things though.
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 f4cfc4f201 nat: bsc_mgcp_clear is called from within the remove function
No need to call it twice... All endpoints should be properly
freed as part of the SCCP disconnection.
2010-06-15 20:24:09 +08:00
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
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 418f394b01 [nat] Make use of the LOGP macro in the code base. 2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 600466477a [nat] Handle write errors with a warning to make the compiler happy
Make the compiler happy by checking the write error and printing
a message to the console.
2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 6a97b8d188 [nat] Add a bsc_filter.c which will carry out the analysis and filtering
The first part is to analyze the IP Access Header and only forward
SCCP messages for now. In the future we might want to do MGCP
signalling through this protocol and connection as well and need to
update this then.
2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther d7fb9545b6 [nat] Use the right len for the packages.. 2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 8e074ec27c [nat] Really forward the data to the BSC 2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther c7641c9a70 [nat] Make sure the ipaccess_bsc_cb will be called.. 2010-06-15 20:24:06 +08:00
Holger Hans Peter Freyther 7625506430 [nat] Unregister the fd before leaving.. 2010-06-15 20:24:05 +08:00
Holger Hans Peter Freyther 24614ad1c0 [nat] First code to simply forward data from the MSC to the real BSC
First code to simply forward the data, no filtering or patching
is in place. This will need to happen soon.
2010-06-15 20:24:05 +08:00
Holger Hans Peter Freyther 5aa25ae9e6 [nat] Turn off compiler warning... 2010-06-15 20:24:05 +08:00
Holger Hans Peter Freyther da86c0a034 [nat] Security will become important at some point... 2010-06-15 20:24:05 +08:00
Holger Hans Peter Freyther 49d8068b37 [nat] Start to listen for the incoming BTS 2010-06-15 20:24:05 +08:00
Holger Hans Peter Freyther 6ace522847 [nat] Connect to the MSC like the real BSC
Use the connect_to_msc method to connect to the MSC and
create structure to handle and forward messages to the
real BSC.
2010-06-15 20:24:05 +08:00
Holger Hans Peter Freyther eef86b5d59 [bsc_msc] Move the connect to the MSC routine into a new file 2010-06-15 20:24:05 +08:00
Holger Hans Peter Freyther 9e2c5f572a [bsc-nat] Start with a simple NAT/MUX for a BSC
Harald actually pointed out that this feature is just NAT. We want
to connect n-real BSCs to one BSC Mux. We will talk the ip.access
protocol and SCCP over of this link.

The mux will drop certain GSM messages (like the reset), it will
replace source local reference (NAT functionality) and it will handle
some GSM08.08 specially.

Get the thing started...
2010-06-15 20:24:05 +08:00
Holger Hans Peter Freyther 230a4d886d gsm48: Split LU Reject sending and generation into two. 2010-06-15 19:40:05 +08:00
Holger Hans Peter Freyther 2c0f16699e gsm48: Separate CM Service Reject sending and creation.
Split out the msg generation from the sending, this will
be used by the nat to send a refusal message.
2010-06-15 19:39:27 +08:00
Holger Hans Peter Freyther 580cb83ae3 Merge branch 'on-waves/sccp' 2010-06-15 17:06:45 +08:00
Holger Hans Peter Freyther 9140174faa bsc_api: Remove the lchan argument from gsm48_tx_mm_info. 2010-06-15 14:16:02 +08:00
Holger Hans Peter Freyther d521d97976 bsc_api: Remove the lchan argument from the mm_tx_identity_req method. 2010-06-15 14:11:01 +08:00
Holger Hans Peter Freyther 7bc5ba3674 bsc_api: Remove lchan from LU Reject...
Remove the lchan from the signature, the removal of the
msg->lchan will follow as a next step.
2010-06-15 14:09:34 +08:00
Holger Hans Peter Freyther dc5db2424d bsc_api: Kill the lchan argument from the LU Accept Method. 2010-06-15 14:07:27 +08:00
Holger Hans Peter Freyther 9c137a7819 bsc_api: Move most of GSM0408 to the DTAP API...
* gsm_04_08_utils.c will directly send the message...
* gsm_04_08.c will use the DTAP API, add a new method to pull
  in the data from the transaction...
2010-06-15 13:57:40 +08:00
Holger Hans Peter Freyther f6fb3efcba bsc_api: Switch gsm_04_08.c to use the clear request of the API. 2010-06-15 13:16:52 +08:00
Holger Hans Peter Freyther ecd9933826 gsm_04_11: Place subscr_put_channel whenever being done with SMS. 2010-06-15 12:53:08 +08:00
Holger Hans Peter Freyther cea722bc51 gsm_04_11: Speculative leak fix for the SMS... 2010-06-15 12:29:37 +08:00
Holger Hans Peter Freyther 6a3d765bf9 bsc_api: Do not use RLL inside the SMS code, handle SAPI n REJECT
Directly send a SMS using the send method, in case of an error
we will need to find the transaction and free the SMS and the
transaction.
2010-06-15 12:04:34 +08:00
Holger Hans Peter Freyther 43b0909394 bsc_api: Create osmo_msc, and initialize the MSC API in the bsc_init. 2010-06-15 12:04:34 +08:00
Holger Hans Peter Freyther 9c595b7474 bsc_api: Implement transparent RLL establishment and SAPI n REJECT
When submitting a DTAP message, the BSC API will attempt to
establish the RLL layer and then send the message or send an
SAPI n REJECT. This will be used by the SMS code.
2010-06-15 12:04:34 +08:00
Holger Hans Peter Freyther 0cfbe26cb9 bsc_api: Add newline to the end of the file. 2010-06-15 12:04:34 +08:00
Sylvain Munaut d04b9edfa3 auth: Add missing include/auth.h
Doh !

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:54:02 +02:00
Harald Welte eabb142c70 require libosmocore 0.1.11 to make encryption compile 2010-06-14 20:48:26 +02:00
Sylvain Munaut e824d9c2a1 auth: Add support for XOR test A3A8 algo (and vty commands)
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:53 +02:00
Sylvain Munaut c593cf100a gsm_04_08: Improve gsm48_rx_mm_auth_resp debug in failure case
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:52 +02:00
Sylvain Munaut 0c873a06b6 vty/auth: Make sure we clear the last tuple when changing auth params
If the Ki or auth algo changes, chances are that the last tuple cannot
be used anymore, so clear it.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:52 +02:00
Sylvain Munaut ba87f458ec gsm_04_08: Establish secure channel on CM SERVICE REQUEST
Note that establishing a secure channel is considered to
be an implicit CM SERVICE ACK.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:52 +02:00
Sylvain Munaut 267fba0a2b gsm_04_08: Establish secure channel on LOCATION UPDATE
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:51 +02:00
Sylvain Munaut 2030a2a228 gsm_04_08: Store the key_seq given in LOC UPD REQUEST in state
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:51 +02:00
Sylvain Munaut 30a15384f4 gsm_04_08: Add a operation to enable ciphering on a lchan
This will take care of the auth/check/enable cipher sequence
and call a callback function when done.

Currently the negotiated Kc is saved but not re-used, so
there is an authentication each time ...

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:51 +02:00
Sylvain Munaut 31ac307130 db: Fix typo in sync_lastauthtuples SQL UPDATE stmt
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:51 +02:00
Sylvain Munaut 92b2ff5081 db: Change naming convention for auth info functions
- exported function have a 'db_' prefix
 - use 'sync' vs 'set'
 - use 'for' vs 'by'

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:50 +02:00
Sylvain Munaut 10bf812a6a db: Use subscriber_id as primary key for AuthKeys/AuthLastTuples
It's unique and not null and we never use 'id' anyway.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:50 +02:00
Sylvain Munaut c614a6a199 db: Rename AuthTuples to AuthLastTuples
Ultimately, we'll need to store both the last used tuple by a
subscriber and a list of known tuples (for unknown Ki). What's
currently implemented for AuthTuples is the former behavior, so
reflect that.

The second use case will be added as a separate table with separate
accessors later on.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:50 +02:00
Sylvain Munaut b48216f9d1 auth: Add #define for special value for key_seq
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:48 +02:00
Harald Welte 993d06065a [GPRS] Add comment on GTP being defined in 29.060 / 09.060 2010-06-14 17:00:51 +02:00
Holger Hans Peter Freyther 2844144afd GPRS: Increase the NS msg size to 2048
According to the GPRS NS spec the maximum framesize
is 1600 octets for FrameRelay, it can be bigger if
configured to be so. Make it 2048 octets to have some
space available...
2010-06-14 22:11:40 +08:00
Holger Hans Peter Freyther abcddf1152 bsc_api: Add init, dispatch the clear request when a channel is going missing 2010-06-14 18:26:09 +08:00
Holger Hans Peter Freyther 2a9285c028 bsc_api: Move some parts over to the BSC API. 2010-06-14 18:26:09 +08:00
Holger Hans Peter Freyther 8e78fa7862 gsm_04_11: Attempt to fix some possible memory leaks in the SMS code
Sometimes we need to free the SMS, sometimes also the transaction.
2010-06-14 16:13:16 +08:00
Holger Hans Peter Freyther 4cd5158874 gsm_04_11: Remove some old code. 2010-06-14 16:06:39 +08:00
Holger Hans Peter Freyther 05a379b857 bsc_api: Add a callback based BSC -> MSC api... 2010-06-14 15:50:35 +08:00
Sylvain Munaut 644a0cac0c [gprs] bssgp: Fix LLC PDU length encoding in BSSGP.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-10 15:15:42 +02:00
Sylvain Munaut eda125ca51 [gprs] sndcp: Fix call to msgb_alloc_headroom to have both head&tail room
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-10 15:15:42 +02:00
Sylvain Munaut 5914bad40b [grps] Fix GTP data_ind call back message creation
We'll need to push data both before and after, so make sure there
is both headroom & tailroom

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-10 15:15:42 +02:00
Harald Welte efbdee9a5c [GPSR] SGSN: Keep traffic counters for each PDP context 2010-06-10 15:12:38 +02:00
Harald Welte bb35c45a02 [GPRS] BSSGP/SGSN: Implement Gb-Interface Paging
We now have a function that generates BSSGP PS and CS paging request.

It is called from the libgtp code when we receive a GTP packet from
the GGSN for a MM context that is in SUSPEND state.  We then issue
a PS paging request to the Cell with the BVCI where the last RA update
was being performed.

TODO: We still don't enqueue the GTP packet (and transmit it on paging
complete), and we don't rate-limit the paging requests, i.e. every GTP packet
will trigger another paging request.

We probably also need some kind of logic that marks the phone as UNREGISTERED
if it doesn't respond to paging requests for some time.
2010-06-10 15:12:38 +02:00
Harald Welte bffeff8089 [GPRS] SGSN: fix typo 2010-06-10 15:12:38 +02:00
Holger Hans Peter Freyther c2e88baa5e ipa-proxy: Remove printf debugging. 2010-06-10 18:27:20 +08:00
Holger Hans Peter Freyther 7afac583cd gsm_04_11: Start using the GSM Subscriber class to ask for a channel
The paging message should not be called directly and the GSM Subscriber
can handle multiple requests at the same time... Now a subscr_put_channel
should be called after the message sending. But it is not very clear when
this can be called. The current code works by luck that the SAPI=0 will
be released...
The MT-SMS was tested via the VTY interface and a N900.
2010-06-10 18:23:28 +08:00
Holger Hans Peter Freyther ca5702a5c6 gsm_04_11: Handle OOM same as expired and clean the message. 2010-06-10 18:20:54 +08:00
Holger Hans Peter Freyther 0afa044c09 gsm_04_11: Fix a typo.. 2010-06-10 18:08:12 +08:00
Holger Hans Peter Freyther 2e234f524c bsc_rll: Stop using lchan refcounts, use the lchan signal to stop the timer
Stop using the lchan refcounts and start handling the lchan
release to stop timers and free the RLL resources for the
channel.
2010-06-10 17:59:31 +08:00
Holger Hans Peter Freyther 4fe22cc56d ipa-proxy: Patch the IPA Set Attribute messages for NSVCI
We will tell the BTS where we are listening, but the ACK
will return the original settings... this should make it
possible to intercept the GPRS stream..
2010-06-10 15:59:45 +08:00
Holger Hans Peter Freyther 21e1c0d01c ipa-proxy: Fix the send routine.. convert port to network order 2010-06-10 15:59:45 +08:00
Harald Welte e98c635391 [SMS] Properly reject processing of compressed SMS
As we don't support compressed SMS, we have to properly reject it.

In the existing code, we segfaulted at some later point since the error
handling was incomplete.

This was triggered by some obscure STK SIM card that insisted on sending a
compressed SMS after registering to the OpenBSC network.
2010-06-09 21:40:45 +08:00
Harald Welte 5bfe499366 [GPRS] SGSN: Pass BSSGP SUSPEND/RESUME up to GMM and alter MMCTX state 2010-06-09 21:40:45 +08:00
Harald Welte f54e7e2102 [GPRS] GMM/SM: Improve error handling by sending STATUS messages 2010-06-09 21:40:45 +08:00
Harald Welte 588d44ee65 [GPRS] Drop all PDP contexts not present in PDP CTX STATUS IE at RA UPD 2010-06-09 21:40:45 +08:00
Harald Welte 60ebc02ba8 [GPRS] SM: Acknowledge PDP CTX DEACT for non-existing PDP CTX
Some phones (notably a Ericsson Mobile Platform based E-TEN M800)
insist on sending PDP CTX DEACT messages for contexts that have already
been deactivated.  The spec doesn't really say what we should do in
this case. But since there is no "reject", we simply acknowledge it.
2010-06-09 21:40:45 +08:00
Holger Hans Peter Freyther 0897dad300 ipa-proxy: Only handle some stuff of the CCM locally...
This is a good interim solution for messages not handled by us,
right now this would include the NVRAM attributes that I do not
feel like caching right now.
2010-06-09 21:40:45 +08:00
Holger Hans Peter Freyther 952aba7406 ipa-proxy: Move UDP socket code to the BTS and forward messages...
Forward messages from BTS to Network, Network to BTS... now
we only need to fix the Set GPRS attributes on the fly...
2010-06-09 21:40:45 +08:00
Holger Hans Peter Freyther 6147c5d7d0 ipa-proxy: Add option to locally listen to GPRS...
This is just the boilerplate code, the rest is not implemted yet.
2010-06-09 21:40:45 +08:00
Holger Hans Peter Freyther 7670651f49 ipa: Print the IP addr in the listen as well.. 2010-06-09 21:40:45 +08:00
Holger Hans Peter Freyther 6cb9b230ed ipa: Say which addr could not be connected... 2010-06-09 21:40:45 +08:00
Holger Hans Peter Freyther 1a0c2b7509 ipaccess-proxy: Add getopt based config options to the proxy...
Make the ip addresses configurable and such.
2010-06-09 21:40:45 +08:00
Holger Hans Peter Freyther 3dac881271 ipa: Increase msgb size for the IPA msg in the proxy. 2010-06-09 21:40:45 +08:00
Holger Hans Peter Freyther 62d97986a3 GPRS: Copy the content of the msgb instead of creating one that points to the other
Right now the memcpy with the data will copy data to itself as
the new_msg->data and msg->data are the same due the previous
copying of the header which included copying the list entry..

We allocate a message as big as the current one, then we have to
set all pointers by looking of how far they are away from the
msg->_data and add that to the new pointers.

Also copy the OpenBSC/GPRS specific CB data, also do the same
for calculating the offset to the data... At the end we should
end up with a copy...
2010-06-09 21:40:44 +08:00
Holger Hans Peter Freyther 62eaf54e7a GPRS: Fix crash when the peer can not be found...
Use UINT_MAX (or -1) if the peer can not be found.
2010-06-09 21:40:44 +08:00
Holger Hans Peter Freyther 57da4471d1 misc: Fix the return type of the go back vty function...
Without this we will get warnings about incompatible assignments
2010-06-09 21:40:44 +08:00
Holger Hans Peter Freyther 89476f5c8f GPRS: Fix compiler warning that will also lead to a crash at runtime. 2010-06-09 21:40:36 +08:00
Holger Hans Peter Freyther b9a4fcfdaf GPRS: Have a simple map from BSSGP PDU to the name...
Sadly the FieldInfo does not provide this mapping...
2010-06-08 13:45:10 +08:00
Holger Hans Peter Freyther e11b107f76 GPRS: Add something that should have become a histogram display...
One small problem... there is no way to be called at the end of
reading a pcap file...
2010-06-08 13:18:58 +08:00
Holger Hans Peter Freyther de4b0a207d chan_alloc: Stop the channel timers in the reset 2010-06-08 12:16:17 +08:00
Holger Hans Peter Freyther 4f5848dc91 abis_rsl: Allow to specify the release mode for a given channel.
This can be used by handover, early assignment to indicate the
close of the old channel...
2010-06-08 12:16:17 +08:00
Holger Hans Peter Freyther 44752d9f84 abis_rsl: Fixup direct assignment and go through the method. 2010-06-08 12:16:17 +08:00
Holger Hans Peter Freyther bddfab1f97 gsm_04_11: Remove direct RSL calls from the SMS code...
Do not use RSL to release the SAPI/Channel from within the code,
the normal channel release procedure will take care of releasing
the SAPIs and there should be no issue in keeping the SAPI=3
established until the end of the session.
2010-06-08 12:16:17 +08:00
Harald Welte f5f512cc59 GSM 04.08: Improve IMEI recording in hlr.sqlite3 for rejected subscribers
If we send the IDENTITY REQUEST for IMEI before sending the IDENTITY
REQUEST for IMSI, the probability is higher that we receive the IMEI
response and associate it with the respective subscriber.
2010-06-07 17:56:32 +02:00
Holger Hans Peter Freyther 7f573d5668 GPRS: Print the IP address to see the direction... 2010-06-07 21:37:43 +08:00
Holger Hans Peter Freyther bc10593314 GPRS: It is TLLI and not TTLI... 2010-06-07 19:17:30 +08:00
Holger Hans Peter Freyther f488121058 GPRS: Show the TLLI as hex value... 2010-06-07 19:16:31 +08:00
Holger Hans Peter Freyther 7d3b3d0e71 GPRS: Add script to track the N(U) on GPRS LLC messages..
tshark -q -X lua_script:gprs/gprs-verify-nu.lua -r trace.pcap

Output:
JUMP in N(U) on TLLI 3741437425 and SAPI: 9
	 last: 1 now: 3
JUMP in N(U) on TLLI 3741437425 and SAPI: 9
	 last: 10 now: 12
2010-06-07 19:08:57 +08:00
Holger Hans Peter Freyther 8acedec8c9 GPRS: Add wireshark lua script to split a trace by TLLI
This is currently only looking at one TLLI and is splitting
the trace by that TLLI...
2010-06-07 18:09:54 +08:00
Holger Hans Peter Freyther 98b15034b3 GPRS: Move test script into subdirectory.. 2010-06-07 17:05:54 +08:00
Harald Welte 3a7074615f [GPRS] BSSGP: Fix formatting of BSSGP TX STATUS 2010-06-03 21:30:57 +02:00
Harald Welte ce22f92b6c [GPRS] SNDCP: Implement fragmentation of N-PDUs to SN-PDUs in downlink
Using the code of this commit, it was possible to provision GPRS
services and access a website from a G1 phone (Qualcomm MSM7k baseband chipset)
using a nanoBTS, Osmo-SGSN and OpenGGSN.

There is still no fragment re-assembly in the uplink path yet,
despite the (untested) code present in the gprs_sndcp.c file
2010-06-03 21:21:21 +02:00
Harald Welte db2c39f888 [GPRS] SNDCP: Check if SN-PDU is too large and reject it
... since we don't do fragmentation yet
2010-06-03 07:16:04 +02:00
Harald Welte 1d9d944310 [GPRS] LLC: Implement per-SAPI default values for LLC parameters 2010-06-03 07:11:04 +02:00
Harald Welte bb1c805718 [GPRS] implement GTP->SNDCP->LLC downlink user-data path
This only works for packets that are small enough to not need
fragmentation at the SNDCP layer (dns queries, ntp and the like).

It requires libgtp built from OpenGGSN dc3744fda045f9fca83de6881176987335a309a8
or later.  Plain 0.90 will NOT work.

Using this version, I could see bi-directional traffic from various
phones going all the way through BTS, OsmoSGSN, OpenGGSN and being routed
to and from the real internet.  Time to celebrate...
2010-06-03 06:38:38 +02:00
Harald Welte 96df60637a [GPRS] add comments to SGSN header file 2010-06-03 06:38:09 +02:00
Harald Welte 52421a0551 [GPRS] SGSN: specify the local bind address in the config file 2010-06-02 23:18:40 +02:00
Harald Welte 61ca7ce006 [GPRS] SGSN: use correct length+data for GSN_ADDRESS
We have to copy the sin_addr.s_addr, rather than the entire sin_addr.  The
latter results in the destination interpreting it as an IPv6 address, as
the only differentiator between IPv4 and IPv6 is the size of the payload
of this IE.
2010-06-02 23:17:33 +02:00
Harald Welte 5cc2bc37a7 [GPRS] SNDCP: Fix PCOMP and DCOMP header field length
They're both just one 4bit nibble, not 1 byte each.
2010-06-02 23:17:05 +02:00
Harald Welte e300d0021c [GPRS] SGSN: Allow vty-based configuration of local listen/bind IP for GTP 2010-06-02 12:41:34 +02:00
Harald Welte 6144452068 [GPRS] SNDCP: Add new SNDCP Entity to global list of entities
Also, don't reject SN-PDUs with positive packet length.
2010-06-02 12:40:48 +02:00
Harald Welte 858491821f [GPRS] Change SI13 to NMO_II, as some phones (like G1) dislike NMO_III
I still believe NMO_III is what we want, but as indiciated some phones
absolutely refuse to even connect to the GPRS network in this mode :(
2010-06-02 12:19:21 +02:00
Harald Welte 69996cb534 [GPRS] SNDCP use DSNDCP instead of DGPRS 2010-06-02 10:26:19 +02:00
Harald Welte 16836a37aa [GPRS] SNDCP: Fix header length (pcomp is part of common_hdr)
Also add some more debug statements
2010-06-02 10:25:40 +02:00
Harald Welte f11b6d2f30 [GPRS] SGSN: fix another segfault (and use-after-free) when GGSN is dead 2010-06-02 10:09:50 +02:00
Harald Welte ebabdea0a6 [GPRS] hand SNDCP N-PDUs to the GTP to the GGSN
This so far only works for UNIT-DATA and only if the N-PDU is not fragmented at
the SNDCP layer.
2010-06-01 18:28:10 +02:00
Harald Welte 84488245e6 We now need libosmocore-0.1.10 due to gprs_tmsi2tlli() 2010-06-01 12:04:03 +02:00
Harald Welte 807a5d8264 [GPRS] Major LLC / TLLI handling fixes
* separate the LLME and LLE state in the LLC layer
* introduce gprs_llgmm_assign() function for LLGMM-ASSIGN.req primitive
* change QoS profile to match 'real' SGSN
* Update the new TLLI when assigning a P-TMSI

The result now is that the LLC layer is notified of TLLI changes, which in turn
means it doesn't allocate a new LLE structure every TLLI change, which again
in turn means that the UI frame sequence number does not reset to zero.

As a result, MS should no longer ignore frames based on wrong UI sequence number.
2010-06-01 11:57:13 +02:00
Harald Welte 1371f7dd2f [GPRS] SGSN GTP: Fix segfault in case GGSN is down 2010-06-01 11:52:41 +02:00
Harald Welte f7b3a219f6 [GPRS] update SGSN config file example 2010-06-01 11:52:21 +02:00
Harald Welte dce1255d8f [GPRS] GMM: Set LLC 'C/R' bit when sending IDENTITY REQUEST
Commands initiatied by the SGSN have to set C/R = 1
2010-05-31 22:31:04 +02:00
Harald Welte 56a0145dd8 [GPRS] Include IMSI and DRX params in BSSGP DL-UD
When we send a downlink unit-data request via BSSGP, there is a lot
of information that needs to be copied from the mm context, such as
the IMSI, DRX parametes, MS radio access parameters, ...

This is a quite strange layering violation, since we now need to pass
a pointer to the MM ctx from GMM through LLC into BSSGP :(
2010-05-31 22:12:30 +02:00
Harald Welte c2e8cc4a10 [GPRS] Implement TMSI reallocation and timers 3350 + 3370
Our state transitions and timers now reflect 04.08 for GMM much
better than before.  Also, we allocate a new P-TMSI on every ATTACH
and RA UPDATE, as some phones seem to get confused if they don't
get a P-TMSI.
2010-05-31 20:23:38 +02:00
Harald Welte 3d379ba589 [GPRS] BSSGP: Fix way too long TLLI debug line 2010-05-31 20:18:35 +02:00
Harald Welte c91ce1a9d3 [GPRS] BSSGP: More verbose debug log / error reporting 2010-05-31 18:07:17 +02:00
Harald Welte 6463232b09 VTY: properly exit from OML_NODE 2010-05-31 17:17:29 +02:00
Harald Welte 72b4b20a2a [GPRS] BSSGP: When we receive a BLOCK, we should not respond with UNBLOCK-ACK 2010-05-31 17:16:36 +02:00
Harald Welte 81c9b9ca3e OML: Introduce minimal VTY command set to interact with OML managed objects 2010-05-31 16:40:40 +02:00
Harald Welte 14ce8a0fa4 VTY: libosmocore >= 0.1.9 doesn't define BSC specific VTY nodes anymore 2010-05-31 16:04:12 +02:00
Harald Welte f5b4ba367c ipaccess-config: More verbose help message 2010-05-31 15:57:29 +02:00
Holger Hans Peter Freyther 0c8aa73db7 [bsc_hack] Call handle_options before bootstrapping the network
Otherwise we can not specify which config file to use and -h will
not work when there is no openbsc.cfg in the cwd.
2010-05-31 21:42:53 +08:00
Holger Hans Peter Freyther 4b4dd100f8 [rsl] Introduce an error state for the lchan and set it on release
When we issue a RF Channel Release in case of a failure we receive
RLL release indications after the channel was tearn down and we
issue another RF Channel Release as a result. The channel allocator
might have already allocated this channel and we release the channel
again with another MS on it.

Make rsl_rf_chan_release take an error argument and make it set
a new state in case of an error and change the RF Channel Release
ack to not set the state back to none in case of an error but wait
for a timeout that is a bit higher than T3111.

I tested this with removing the battery during a phonecall and
waiting for the channel failure. With this test we only send the
release once.
2010-05-31 21:39:23 +08:00
Holger Hans Peter Freyther f30c0dca0d [rsl] Implement the T3111 timer to delay the RF Channel release 2010-05-31 21:33:15 +08:00
Holger Hans Peter Freyther d7fd30617f [rsl] Check the assumption that RF Channel Release is sent during release
We assume that the lchan_free will initiate the release and
that when we handle the RLL release indication or the release
request as part of the shutdown sequence.
2010-05-31 21:30:37 +08:00
Holger Hans Peter Freyther dbc5fae576 [rsl] Move rf channel release scheduling to a new method
The current channel release has a couple of issues we will
need to fix in a set of upcoming commits.

The issues include:
    1.) sending release twice
    2.) reassigning the channel inbetween the relase..
2010-05-31 21:30:16 +08:00
Harald Welte a4b16658d5 [GPRS] Make sure SI13 rest octets look like those of the ip.access BSC 2010-05-31 12:55:11 +02:00
Harald Welte a6932d2eae [GPRS] NS: Fix GRE keepalive response in FR-GRE encapsulation 2010-05-31 11:02:57 +02:00
Harald Welte 02ea86fa71 [GPRS] BSSGP: Acknowledge all SUSPEND and RESUME requests
This is of course not the correct way of dealing with it, but for
now it should make the Ericsson Mobile Plafrom based phones happy
(they insist to do a suspend/resume cycle before pdp ctx act)
2010-05-30 22:00:53 +02:00
Harald Welte 6bdee6ada3 [GPRS] LLC: Increment V(U) and N(U) 2010-05-30 22:00:42 +02:00
Harald Welte b12aa4b1ee [GPRS] GMM: Add some FIXME's to the code 2010-05-30 20:28:22 +02:00
Harald Welte d75d71e95c [GPRS] NS: correctly pass the NS payload length to the TLV parser 2010-05-30 17:19:38 +02:00
Harald Welte 0ede21f547 [GPRS] NS: Don't hand Frame Relay LMI packets into the NS code 2010-05-28 16:12:57 +02:00