Commit Graph

104 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther aad82ce7ea nat: Print the MSC status with a new vty command. 2010-06-15 20:24:18 +08:00
Holger Hans Peter Freyther 569ee123a2 nat: Using the right fd can be a good idea as well 2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 872d7683d3 nat: Fix bad bug, make sure the fd is not overwritten..
The adding of the innocent looking code was actually overwrote
the fd and then stupid things happened. Rename variables to avoid
that. rc,ret should be scratch variables...
2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 9e938c680f nat: Use TCP_NODELAY for the connection to the BSC.
We do not want to use NAGLE for the BSC connection.
2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 74cfab7b5d nat: Improve log messages. Refer to ip and fd. 2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther da35a8da7f nat: Make ping/pong timeout configurable. 2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 5078871611 nat/bsc: Send PONG on PING, send PING from the BSC too
We do want to send PING/PONG in both ways to have a heartbeat
on the TCP connection. When switching over to SCTP we can rely
on the builtin heartbeat functionality.
2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 906c15ec53 nat: Send a IPA PING down the stream and wait for the pong.
We will send a ping every 20 seconds and if we have no pong
within 5 seconds we will close down the BSC connection and
wait for a reconnect. We will start this after having
authenticated the BSC and we stop the timer when destructing
the BSC connection.
2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 5cdcfa6224 nat: Do not allow a BSC to send auth messages twice. 2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 19c3544f0a nat: Improve log message and refer to the BSC that was lost. 2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 0b0b31c708 nat: Report some more contexts 2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther 2f9dcf0670 nat: Add a command to close a given BSC Connection
This can be used to clear stale connections for a given BSC
or to force a reconnect of the BSC.
2010-06-15 20:24:17 +08:00
Holger Hans Peter Freyther a1597f1b29 nat: Allocate a named context to make dumping allocations possible
This is fixing the SIGUSR1 to really report the allocated
memory on stderr.
2010-06-15 20:24:16 +08:00
Holger Hans Peter Freyther 4c683d1215 nat: Only close connections that were fully connected
Remember that we have seen a CC and have a valid destination
local reference now and only send a fake RLC to the MSC when
we had connections in this state.
2010-06-15 20:24:16 +08:00
Holger Hans Peter Freyther 9db7843c06 nat: When having a proper close down, or a short read close the connection
For now close the connection when having a short read. This might
be due a network issue (loss of segment) or similiar. As we are not
handling these issues well, let us close the connection.
2010-06-15 20:24:16 +08:00
Holger Hans Peter Freyther 9d56d0c45b nat: Handle all queueing to the MSC through the same function. 2010-06-15 20:24:16 +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 8151973c73 nat: Move the write queue init to the allocation function
This is required for unit tests that want to queue messages
and see if we can provoke a memleak.
2010-06-15 20:24:16 +08:00
Holger Hans Peter Freyther e464ed4e7c nat: Clear the queued messages at the end
It is possible that the calls from the loop would queue
more messages for the BSC and then we would have a nice
memory leak... Move it to the bottom.
2010-06-15 20:24:16 +08:00
Holger Hans Peter Freyther a34585e296 [nat] Degrade the message to a plain debug output. 2010-06-15 20:24:16 +08:00
Holger Hans Peter Freyther 62e5843a61 [nat] Add option to forbid the paging to the BSC.
This can be done for testing purposes and to allow making
a BTS crash that can not handle paging requests properly.
2010-06-15 20:24:15 +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 ca0c2f9d1e [nat] Slightly improve logging..
If we find the connection of a different BSC at least log the
BSCs that had duplicated references. We should also dump the
src ref and such but i am not doing this right now.
2010-06-15 20:24:15 +08:00
Holger Hans Peter Freyther 3d0049f4a0 nat: Increase the right counter on calls. 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 c615c260ea nat: Mention when we do not find a BSC for a given token.
This might help to identify what is wrong with the config
of the BSC. Also using the result of TLVP_VAL as a char
pointer looks suspicious...
2010-06-15 20:24:14 +08:00
Holger Hans Peter Freyther 6d5a60041a nat: Print the IP address of the BSC that does not respond to the query. 2010-06-15 20:24:14 +08:00
Holger Hans Peter Freyther 8139553962 nat: Make the MSC configurable. 2010-06-15 20:24:14 +08:00
Holger Hans Peter Freyther a88742cf5e nat: Move MSC ip address into the config..
The address can still be specified on the cli and it will
overwrite the config in the config file.
2010-06-15 20:24:14 +08:00
Holger Hans Peter Freyther a4ed81c8d9 [statistics] Count the times we lost the connection to the MSC. 2010-06-15 20:24:13 +08:00
Holger Hans Peter Freyther d4702862d3 [statistics] Provide basic statistics for the NAT
Count number of SCCP connections, number of BSC reconnects,
number of calls. For most of them we have a per BSC and a
global count.

Right now all structs using the counters survive until the
end of the application so we do not need to free them.
2010-06-15 20:24:13 +08:00
Holger Hans Peter Freyther b8a337356a nat: Handle unknown RLSD by send a RLC back to the network. 2010-06-15 20:24:13 +08:00
Holger Hans Peter Freyther 02aee149f6 nat: Rename variable to make it use msc in the name 2010-06-15 20:24:13 +08:00
Holger Hans Peter Freyther 2896df7605 nat: Attempt to have a single BSC write method
This method currently prepends the IPA header and sends
the data. In the future we might be able to use SCTP for
it.

We have to remove the IPA header from the static messages
for that to work.

This code is untested.
2010-06-15 20:24:13 +08:00
Holger Hans Peter Freyther ce512c5473 nat: Rename bsc_write to bsc_send_data 2010-06-15 20:24:13 +08:00
Holger Hans Peter Freyther b752761a3d nat: Send the reset after we have received the init ack
Sending the reset right away will upset the MSC and we
need to wait for the first contact.
2010-06-15 20:24:13 +08:00
Holger Hans Peter Freyther 7cab16619e nat: Fix the reset message and prepend the IPA header 2010-06-15 20:24:12 +08:00
Holger Hans Peter Freyther af0ff6c46a nat: Send a GSM0808 message to the MSC when we are reconnecting
The rest of the code should filter the reset ack msg. This should
make the MSC give up all resources it had allocated for us.
2010-06-15 20:24:12 +08:00
Holger Hans Peter Freyther fb7a934cfc nat: Redo a merge with master that got lost on the cherry-pick 2010-06-15 20:24:12 +08:00
Holger Hans Peter Freyther 6b087d18f5 nat: Send a RLSD to the network for connections belonging to the BSC
Sending a RLSD with SCCP failure makes the MSC free all the resources
(MGCP, audio channels), right now we are ignoring the RLC we get from
the network and print a unhandled message.
2010-06-15 20:24:12 +08:00
Holger Hans Peter Freyther f464ea54d1 nat: Print a MSG when receiving unknown SCCP messages. 2010-06-15 20:24:12 +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 a7c377d593 nat: Close the filedescriptor when ignoring the request. 2010-06-15 20:24:12 +08:00
Holger Hans Peter Freyther f46ce5329d nat: Patch IT messages as well..
We need to patch the source/dest reference inside the messages
as well otherwise we will see failures in the SCCP connection
on long calls.
2010-06-15 20:24:11 +08:00
Holger Hans Peter Freyther 26a43896cd nat: Close all endpoints used by a BSC when the BSC is gone
Cleanup all endpoints that belonged to a given BSC. This is
one part of the cleanup, the other is to bring down the SCCP
link properly.
2010-06-15 20:24:11 +08:00
Holger Hans Peter Freyther b9ac37d22f nat: Logging improvement for the nat.
Print some more information, e.g. when a BSC is connected
and authenticated, print the SCCP ref number.
2010-06-15 20:24:11 +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 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 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