path: root/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
AgeCommit message (Collapse)AuthorFilesLines
2015-10-12osmux: Make sure that bigger Osmux ids actually fitHolger Hans Peter Freyther1-2/+2
We put a signed integer into this string but did not account for the newline and for the terminating NUL of the string. Add the newline to the string and add one for NUL. Spotted while accidently having a CID of 255.
2015-10-12osmux: Remember the allocated CID and make sure it is releasedHolger Hans Peter Freyther1-9/+9
There appears to be a leak of CIDs: <000b> mgcp_osmux.c:544 All Osmux circuits are in use! There are paths that a CID had been requested and never released of the NAT. Remember the allocated CID inside the endpoint so it can always be released. It is using a new variable as the behavior for the NAT and MGCP MGW is different. The allocated_cid must be signed so that we can assign outside of the 0-255 range of it. Fixes: OW#1493
2015-10-12osmux: Enforce Osmux only global and per BSC configurationHolger Hans Peter Freyther1-3/+29
Extend the osmux only setting from the MGCP MGW to the NAT. This is applied when an endpoint is allocated and/or when the allocation is confirmed by the remote system. Not tested. The impact should only be when the new option is being used. Fixes: OW#1492
2015-08-20mgcp: Begin to separate network and bts endpointsHolger Hans Peter Freyther1-3/+3
Make it possible to bind the call-agent to a specific IP address and the network and bts end to different ip addresses. Begin by clarifying which source ip address we want to have.
2015-08-13nat: Forward SDP files with multiple payload types in itHolger Hans Peter Freyther1-6/+7
The parsing code assumed that there will be a single payload type and this assumption is clearly wrong. Forward all of the payload types. The code is still only extracting the first type from the list. The variable name has been renamed to reflect this.
2015-04-23nat: Make mode-set patching optionalHolger Hans Peter Freyther1-4/+6
2014-09-02mgcp: Move the "codec" params to a structHolger Hans Peter Freyther1-2/+2
We might be offered multiple codecs by the remote and need to switch between them once we receive data. Do this by moving it to a struct so we can separate between proposed and current codec. In SDP we can have multiple codecs but a global ptime. The current code doesn't separate that clearly instead we write it to the main codec.
2014-08-28osmux: remove redundant log message when bsc doesn't want to use OsmuxPablo Neira Ayuso1-3/+1
Remove redundant information log message: <000b> bsc_mgcp_utils.c:647 BSC doesn't want to use Osmux, failing back to RTP <000b> bsc_mgcp_utils.c:669 bsc didn't accept to use Osmux (cid=0) One single log message is just fine. The error path already indicates the precise reason not to accept the request to use Osmux.
2014-08-28osmux: add osmux circuit ID management and resolve NAT problemsPablo Neira Ayuso1-21/+75
This patch includes several osmux fixes that are interdependent: 1) This adds Osmux circuit ID, this is allocated from the bsc-nat. This announces the circuit ID in the CRCX MGCP message. This aims to resolve the lack of uniqueness due to the use of endp->ci, which is local to the bsc. This ID is notified via X-Osmux: NUM where NUM is the osmux circuit ID. 2) The dummy load routines are now used to setup osmux both in bsc and bsc-nat to resolve source port NAT issues as suggested by Holger. The source port that is used from the bsc is not known until the first voice message is sent to the bsc-nat, therefore enabling osmux from the MGCP plane breaks when a different source port is used. 3) Add refcnt to struct osmux_handle, several endpoints can be using the same input RTP osmux handle to perform the batching. Remove it from the osmux handle list once nobody is using it anymore to clean it up. 4) Add a simple Osmux state-machine with three states. The initial state is disabled, then if the bsc-nat requests Osmux, both sides enters activating. The final enabled state is reached once the bsc-nat sees the dummy load message that tells what source port is used by the bsc. 5) The osmux input handle (which transforms RTP messages to one Osmux batch) is now permanently attached to the endpoint when Osmux is set up from the dummy load path, so we skip a lookup for each message. This simplifies osmux_xfrm_to_osmux(). After this patch, the workflow to setup Osmux is the following: bsc bsc-nat | | |<------ CRCX ----------| | X-Osmux: 3 | (where 3 is the Osmux circuit ID | | that the bsc-nat has allocated) |------- resp --------->| | X-Osmux: 3 | (the bsc confirm that it can | | use Osmux). . . | | setup osmux |----- dummy load ----->| setup osmux | Osmux CID: 3 | In two steps: 1st) Allocate the Osmux Circuit ID (CID): The bsc-nat allocates an unique Osmux CID that is notified to the bsc through the 'X-Osmux:' extension. The bsc-nat annotates this circuit ID in the endpoint object. The bsc replies back with the 'X-Osmux:' to confirm that it agrees to use Osmux. If the bsc doesn't want to use Osmux, it doesn't include the extension so the bsc-nat knows that it has to use to RTP. 2nd) The dummy load is used to convey the Osmux CID. This needs to happen at this stage since the bsc-nat needs to know what source port the bsc uses to get this working since the bsc may use a different source port due to NAT. Unfortunately, this can't be done from the MGCP signal plane since the real source port is not known that the bsc uses is not known. This patch also reverts the MDCX handling until it is clear that we need this special handling for this case.
2014-08-21move libctrl from openbsc to libosmoctrl (libosmocore.git)Harald Welte1-1/+1
2014-07-22mgcp: Change API to remove memory management from the nameHolger Hans Peter Freyther1-3/+3
Jacob pointed out that "free_endp" refers to the memory of the endpoint being freed. What we want is actually a way to release an endpoint (and the resource it allocated) or in the case of the testcase/testapp initialize the data structure correctly. Introduce two names for that.
2014-07-07libbsc, osmo-bsc{, _nat}: Prevent unaligned access when casting TLVP_VALDaniel Willmann1-1/+1
foo = *((uintXX_t *) TLVP_VAL(...) can lead to unaligned access. To prevent that use tlvp_valXX_unal() to get the values.
2014-05-22mgcp: add voice muxer supportPablo Neira Ayuso1-10/+22
This patch adds the voice muxer. You can use this to batch RTP traffic to reduce bandwidth comsuption. Basically, osmux transforms RTP flows to a compact batch format, that is later on decompacted to its original form. Port UDP/1984 is used for the muxer traffic between osmo-bsc_nat and osmo-bsc_mgcp (in the BSC side). This feature depends on libosmo-netif, which contains the osmux core support. Osmux is requested on-demand via the MGCP CRCX/MDCX messages (using the vendor-specific extension X-Osmux: on) coming from the BSC-NAT, so you can selectively enable osmux per BSC from one the bsc-nat.cfg file, so we have a centralized point to enable/disable osmux. First thing you need to do is to accept requests to use Osmux, this can be done from VTY interface of osmo-bsc_nat and osmo-bsc_mgcp by adding the following line: mgcp ... osmux on osmux batch-factor 4 This just initializes the osmux engine. You still have to specify what BSC uses osmux from osmo-bsc_nat configuration file: ... bsc 1 osmux on bsc 2 ... bsc 3 osmux on In this case, bsc 1 and 3 should use osmux if possible, bsc 2 does not have osmux enabled. Thus, you can selectively enable osmux depending on the BSC, and we have a centralized point for configuration from the bsc-nat to enable osmux on demand, as suggested by Holger. At this moment, this patch contains heavy debug logging for each RTP packet that can be removed later to save cycles. The RTP ssrc/seqnum/timestamp is randomly allocated for each MDCX that is received to configure an endpoint.
2013-12-05mgcp/nat: Take payload type from SDP dataJacob Erlbeck1-4/+13
So far the payload type used in RTP streams has been taken from the trunk configuration in NAT mode. This patch changes the implementation to use the payload type announced in the SDP part of MGCP messages and responses. SDP descriptions more than one m=audio line are not yet supported properly (always the last one is taken). Ticket: OW#466 Sponsored-by: On-Waves ehf
2013-07-05nat: Address coverity warning about uninitialized addrHolger Hans Peter Freyther1-0/+1
Use memset on the addr to initialize the entire structure. Fixes: Coverity CID 1042324
2013-04-22nat: Move the callstats to a new header file due sccp usageHolger Hans Peter Freyther1-0/+1
The bsc_nat.h is included by common_vty.c so we may not used sccp_types.h in the bsc_nat.h header file. Move the callstats to a new file and include it where it is needed.
2013-04-16nat: Rename "struct sccp_connections" to "struct nat_sccp_connection"Holger Hans Peter Freyther1-11/+11
The name sccp_connection is used in the osmo-sccp code, sccp_connections was used in the NAT for tracking a sccp_connection. Rename it so it is obvious that the struct belongs to the nat. The rename was done with sed: $ sed -i s,"struct sccp_connections","struct nat_sccp_connection",g \ include/openbsc/*.h src/osmo-bsc_nat/* tests/*/*
2013-04-16nat: Name the variable more properly and begin with net.1.bsc.%dHolger Hans Peter Freyther1-3/+4
We can identify the NAT and BSC given the types of the variable, no need to put them into the value itself.
2013-04-16nat: Include the sccp_src_ref and sccp_dst_ref for this callHolger Hans Peter Freyther1-2/+6
This can help with some post analysis for failed calls and helps finding the connection in the pcap trace.
2013-04-16nat: Do not allow the amount of pending responses to grow infinitelyHolger Hans Peter Freyther1-0/+15
Limit the amount of pending DLCX responses to three times the amount of available endpoints. Currently all MGCP messages are sent and handled in sequence.
2013-04-16nat: Reword the log messages as this is normal operationHolger Hans Peter Freyther1-1/+1
The bsc_mgcp_dlcx method is called from the mgcp policy callback but also from inside the nat core when the SCCP connection is going away.
2013-04-16nat: We want the remote to respond to our DLCX requestHolger Hans Peter Freyther1-7/+161
We want to send a TRAP with the MGCP statistics from the NAT and the connected BSC. The BSC endpoint can be either released because of a DLCX from the MGCP CallAgent or the SCCP Connection release on the A-link. This is why we need to queue the statistics when the deleting the endpoint on the BSC. The processing is continued once the response arrives. This code assumes that the response of the DLCX will be sent by the remote side. The current amount of outstanding responses can be seen on the VTY. This assumption is based on the fact that the BSC has already responded to the CRCX and maybe to the MDCX. The MGCP RFC is bended to prefix the transaction identifier with "nat-" to easily detect the response and hand it to the handler. This will then parse the response and generate the TRAP. The current version is v1. We assume that the transaction space is big enough and we will not re-assign the transaction identifier too early.
2013-04-16nat: Make it possible to send MGCP messages through the IPA multiplexHolger Hans Peter Freyther1-14/+68
Instead of handling MGCP through the UDP socket, read and write messages through the ipa connection to the MSC.
2013-04-16nat: Move all methods sending a response to the callagent to a single placeHolger Hans Peter Freyther1-10/+11
For testing it can be nice to handle MGCP messages through the IPA protocol. Prepare the code to send the messages through other means.
2013-04-16nat: Address the FIXME and send the MDCX down to the BSCHolger Hans Peter Freyther1-1/+1
2012-11-07nat: sizeof char * != sizeof char[], make the code work on 64bit systemsHolger Hans Peter Freyther1-6/+6
The test cases were failing on 64bit systems because the sizeof code operated on the pointer size which is 8 and longer than the size that was intended to be used for comparing it.
2012-11-07nat: Inject a a=fmtp:%d to force the right AMR codeHolger Hans Peter Freyther1-3/+24
This assumes that AMR is used and/or the mode-set is ignored for other codecs by the remote end.
2012-10-30mgcp: Fix the log message. This is inside the MDCX printing routineHolger Hans Peter Freyther1-1/+1
2012-10-29nat: Make MGCP helper routine static as it is internal to the MGCP codeHolger Hans Peter Freyther1-1/+1
2012-10-29nat: Document the high level goal of the MGCP/NAT routinesHolger Hans Peter Freyther1-2/+26
Provide some high level documentation that might help to understand what this code is supposed to be doing.
2012-01-17mgcp: Provide documentation for the method, check sscanf returnHolger Hans Peter Freyther1-0/+8
2011-05-06src: use namespace prefix osmo_wqueue*Pablo Neira Ayuso1-3/+3
Summary of changes: s/struct write_queue/struct osmo_wqueue/g s/write_queue_init/osmo_wqueue_init/g s/write_queue_clear/osmo_wqueue_clear/g s/write_queue_enqueue/osmo_wqueue_enqueue/g s/write_queue_bfd_cb/osmo_wqueue_bfd_cb/g
2011-05-06src: use namespace prefix osmo_fd* and osmo_select*Pablo Neira Ayuso1-3/+3
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-03-29nat: Improve the error message for the failing bind callHolger Hans Peter Freyther1-1/+2
Print the IP and port that was used for the address to bind to.
2011-03-23Fix build of bsc-nat and GPRS code after include path changeHarald Welte1-2/+2
The last patch changed the osmocore include paths, this fixes some build problems caused by it
2011-03-23src: use new library libosmogsm and new path to headers in libosmocorePablo Neira Ayuso1-3/+3
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-03Rename bsc_nat -> osmo-bsc_nat and bsc_mgcp -> osmo-bsc_mgcpHarald Welte1-0/+764
This now enforces a unique structure: All of our main daemon programs start with an "osmo-" prefix.