aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp
AgeCommit message (Collapse)AuthorFilesLines
2014-08-28osmux: remove spamming debug log messagesPablo Neira Ayuso1-28/+0
It may print a debug line every 20ms, so disable this. We can still compile this extra spamming debug from the libosmo-netif library.
2014-08-28osmux: use osmux port when specified from vty from enginePablo Neira Ayuso1-3/+3
Instead of the hardcoded OSMUX_PORT.
2014-08-28osmux: print out 'osmux port' when saving configurationPablo Neira Ayuso1-0/+2
2014-08-28osmux: allow to specify the Osmux portPablo Neira Ayuso2-1/+14
via mgcp section from the configuration file.
2014-08-28osmux: display statistics once osmux input handle is releasedPablo Neira Ayuso1-1/+9
2014-08-28osmux: fix error path in osmux_handle_dummy()Pablo Neira Ayuso1-1/+2
This patch adds a missing goto err. While at it, reword log message.
2014-08-28osmux: remove spamming log messagePablo Neira Ayuso1-3/+0
Not very useful: <000b> osmux.c:163 Osmux uses CID 1 from endpoint=7 (active=1) Get rid of it.
2014-08-28osmux: cleanup osmux input handle on releasePablo Neira Ayuso1-0/+1
Use osmux_xfrm_input_fini() to release the internal state of the osmux input handle.
2014-08-28osmux: add osmux circuit ID management and resolve NAT problemsPablo Neira Ayuso2-113/+192
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-27osmux: move osmux socket initialization out of osmux_enable_endpoint()Pablo Neira Ayuso2-14/+20
In the bsc-nat side, the osmux socket initialization can be done from the vty. This ensure that the osmux socket is available by the time the bsc-nt receives the dummy load that confirms that the osmux flow has been set up. This change is required by the follow up patch. This change ensures that the Osmux socket in the bsc-nat is already in place by the time this receives the dummy load.
2014-08-27osmux: split osmux_handle_lookup() in several functionsPablo Neira Ayuso1-7/+31
This is a cleanup to allow the reuse of the new functions osmux_handle_find_get() and osmux_handle_alloc().
2014-08-27osmux: encapsulate for osmux state information in struct mgcp_endpointPablo Neira Ayuso2-6/+7
Just a cleanup, wrap around the osmux state information in a struct.
2014-07-22osmux: Drop the message in case we don't know the remote yet.Holger Hans Peter Freyther1-0/+7
Avoid creating a bogus state that will never go away.
2014-07-22osmux: Qualify the handle by IPv4 address _and_ portHolger Hans Peter Freyther1-12/+25
For our usecase several different systems might be behind the same firewall so we need to distinguish the remote by more than the IPv4 address.
2014-07-22osmux: Extract the dummy message, find the endpoint and set rtp portHolger Hans Peter Freyther1-1/+34
Set the remote port for the endpoint. Somehow this needs to propagate all the way to the handle.
2014-07-22osmux: Send the CI as part of the dummy to help to identify a clientHolger Hans Peter Freyther1-2/+7
We need to discover the remote port as we are likely behind a NAT. Right now the NAT code will just send to port 1984 on the BSC but this might not arrive at the BSC. Include the CI (in the future we need to include the endpoint address or send the dummy to the net port). This is just an interim solution.
2014-07-22osmux: Using the "CI" and calling it "CID" is plain wrongHolger Hans Peter Freyther1-1/+1
The CI is a MGCP value that is counted from 0 upwards. The code is comparing a uint8_t with a uint32_t. This will only work for up to UINT8_MAX calls and then will silently break. The code should probably work with the endpoint number and not the CI. For now truncate things and hope things work.
2014-07-22mgcp: Change API to remove memory management from the nameHolger Hans Peter Freyther2-7/+12
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-22mgcp: Fix/test the case of a time jump and the resyncHolger Hans Peter Freyther1-0/+1
In case the sender didn't send a couple of frames we will have a time gap that is bigger than the accepted delta. Add a new testcase for this and update the next_time.
2014-07-22mgcp: Initialise next_time in case the initial timestamp is not 0.Holger Hans Peter Freyther1-2/+4
2014-07-22mgcp: Document transcoding semantic and follow itHolger Hans Peter Freyther1-1/+8
Transcoding from GSM to PCMA can lead to the MGCP MGW sending two PCMA packages with the same sequence number and timestamp. Once with the encoded audio and once completely empty. This is because "state->dst_packet_duration" is 0 in most cases (unless a ptime is forced) and we attempt to encode audio even if there are not enough samples. The encode_audio return will return 0 in that case which is not trated as an error by the mgcp network code. Handle rc == 0 specially and document the semantic.
2014-07-22mgcp: Fix/test reading/writing the sequence numberHolger Hans Peter Freyther1-2/+2
The sequence number was read from the wrong place and then the wrong byte order conversion routine was used so we ended up wirting 0x00, 0x00 into the patched sequence number. Add a testcase for that.
2014-07-22mgcp: Patch and Count _after_ the transcodingHolger Hans Peter Freyther1-1/+1
When going from a ptime of 10 to 20 a lot of alignment errors are reported. In fact the alignment check should be done before and after the transcoding. As this is not possible right now only do it _after_ the patching.
2014-07-22mgcp: Add a comment about the return of the functionHolger Hans Peter Freyther1-0/+5
2014-07-22mgcp: Make the internal state of the transcoder accessibleHolger Hans Peter Freyther1-50/+1
For the unit tests we need to look at the internal state.
2014-07-22mgcp: Warn when the buffer is being reset due a wrong seq numberHolger Hans Peter Freyther1-2/+5
When the sample buffer is being dropped write a warning so we can see how often this event occurs.
2014-07-22mgcp: Mention the packet duration in the error messageHolger Hans Peter Freyther1-2/+2
2014-07-22mgcp: Provide more information about configured endpointsHolger Hans Peter Freyther1-13/+26
2014-07-22mgcp: Fix memory leak in the transcoding codeHolger Hans Peter Freyther1-1/+1
The GSM handle was never released. This was found using valgrind and the leak check. ==14933== 752 bytes in 1 blocks are definitely lost in loss record 15 of 19 ==14933== at 0x4028B4C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==14933== by 0x4130201: gsm_create (in /usr/lib/i386-linux-gnu/libgsm.so.1.0.12) ==14933== by 0x80517AE: mgcp_transcoding_setup (mgcp_transcode.c:199) ==14933== by 0x8049691: given_configured_endpoint.isra.1 (mgcp_transcoding_test.c:198) ==14933== by 0x8049C11: test_transcode_result (mgcp_transcoding_test.c:328) ==14933== by 0x8049418: main (mgcp_transcoding_test.c:582)
2014-07-09osmux: Now that we have IPv4/port we might want to consider to expire handlesHolger Hans Peter Freyther1-0/+1
2014-07-09osmux: Mention where the data was coming fromHolger Hans Peter Freyther1-2/+4
2014-07-09osmux: Be accurate. The label has been already createdHolger Hans Peter Freyther1-1/+1
2014-07-08osmux: Make sure to always use the right dummy sending methodHolger Hans Peter Freyther1-6/+11
Make sure to re-use the right method for nat traversal. Found by Roch while looking at traces.
2014-07-08osmux: Remove extra newline from the osmux log messageHolger Hans Peter Freyther1-1/+1
<000b> osmux.c:177 Cannot find endpoint with cid=7 ! <000b> osmux.c:253 Cannot find an endpoint for circuit_id=7 The extra newline and '!' do not provide any extra value and make reading the output more difficult. Just remove it.
2014-07-07mgcp: Verify that the force-ptime is written back to the fileHolger Hans Peter Freyther1-1/+3
When the command was added it was not verified that. Add a very basic MGCP VTY test and test that the string appears in the config.
2014-07-07mgcp: Fix documentation issue in the force-ptime commandHolger Hans Peter Freyther1-1/+2
<command id='rtp force-ptime (10|20|40)'> <param name='10' doc='(null)' /> <param name='20' doc='(null)' /> <param name='40' doc='(null)' />
2014-07-07rtp: Share the rtp header between the proxy and the mgcp codeHolger Hans Peter Freyther1-36/+1
2014-06-16mgcp: Allow to batch more than four messagesHolger Hans Peter Freyther1-1/+1
2014-06-15mgcp: Fix SDP formatting of fmtp_extra (Coverity)Jacob Erlbeck1-2/+1
Currently when ftmp_extra is set, a doubled a=rtpmap line is emitted instead of the fmtp_extra info. This patch fixes replaces the formerly copied and pasted but not modified snprintf parameters by the correct ones. Fixes: Coverity CID 1220873 Sponsored-by: On-Waves ehf
2014-06-05mgcp: Set net_end audio params in recvonly modeJacob Erlbeck1-3/+38
Currently, if there is no SDP data in the MGCP message received from the net, the fields containing audio encoding information are not set in net_end. So in recvonly mode transcoding would not be set up correctly. This patch changes the implementation of the code handling CRCX and MDCX to use the codec signalled in the MGCP local connection options (field 'a:') if there isn't any SDP data. This is only halfway negotiation, because the codec is used blindly and not matched against the supported ones. Sponsored-by: On-Waves ehf
2014-06-05mgcp: Move transcoding to libmgcpJacob Erlbeck3-3/+746
This patch moves the files relevant to transcoding from src/osmo-bsc_mgcp to src/libmgcp and src/include/openbsc. Makefiles and include directives are being updated accordingly. Sponsored-by: On-Waves ehf
2014-06-05mgcp: Add packet size (ptime) conversionJacob Erlbeck3-9/+61
The current transcoder implemenation always does a 1:1 recoding concerning the duration of a packet. So RTP timestamps and sequence numbers are not modified. This is not sufficient in some cases, e.g. when the BTS does only allow for a single fixed ptime. This patch decouples encoding from decoding and moves the decoded samples to the state structure so that samples can be combined or drain according to the packaging of incoming and outgoing packets. This patch incorporates parts of Holger's experimental fixes in 0e669e05^..9eba68f9. Ticket: OW#1111 Sponsored-by: On-Waves ehf
2014-06-05mgcp: Only include SDP lines with valid contentJacob Erlbeck1-43/+90
Don't show media related lines if the payload type has not been set. Don't show a 'a=rtpmap' line if the audio_name has not been set. This patch unifies the SDP generation of create_response_with_sdp() and send_msg(). Sponsored-by: On-Waves ehf
2014-06-05mgcp: Add a function to get media info for MGCP responsesJacob Erlbeck2-5/+27
This patch adds the get_net_downlink_format_cb() callback to provide payload_type, subtype_name, and fmtp_extra suitable for use in a MGCP response sent to the network. Per default, the BTS side values are returned since these must be honoured by the net peer when sending audio to the media gateway (unless transcoding is done). Sponsored-by: On-Waves ehf
2014-06-05mgcp: Add audio info fields to struct mgcp_rtp_endJacob Erlbeck1-20/+64
This patch adds the fields channels, subtype_name, and audio_name to the struct. The field audio_name contains the full string that has been used for the last part of a SDP a=rtpmap line. The others contain decoded parts of that string. If no a=rtpmap line has been given (e.g. because dynamic payload types are not used), values are assigned when the payload type matches one of the predefined ones (GSM, G729, PCMA). The patch also moves the audio_name parsing code to a dedicated set_audio_info() function. Sponsored-by: On-Waves ehf
2014-06-05mgcp: Add callbacks for payload processingJacob Erlbeck2-4/+50
This patch adds the callbacks rtp_processing_cb and setup_rtp_processing_cb to mgcp_config to support arbitrary RTP payload processing. Sponsored-by: On-Waves ehf
2014-06-03osmux: Fix the VTY online help in the osmux commandHolger Hans Peter Freyther1-1/+1
This should fix most of: Documentation error (missing docs): <command id='osmux (on|off)'> <param name='off' doc='(null)' /> Documentation error (missing docs): <command id='osmux batch-factor &lt;1-4&gt;'> <param name='&lt;1-4&gt;' doc='(null)' /> Documentation error (missing docs): <command id='osmux (on|off)'> <param name='off' doc='(null)' /> Documentation error (missing docs): <command id='osmux (on|off)'> <param name='off' doc='(null)' /> Documentation error (missing docs): <command id='osmux batch-factor &lt;1-4&gt;'> <param name='&lt;1-4&gt;' doc='(null)' />
2014-05-28mgcp: Address scanf issue already found by cppcheck and now ASANHolger Hans Peter Freyther1-1/+1
Use the right size for scanf. ================================================================= ==6106== ERROR: AddressSanitizer: unknown-crash on address 0xbffff4b0 at pc 0xb69d87fd bp 0xbffff248 sp 0xbffff21c WRITE of size 65 at 0xbffff4b0 thread T0 #0 0xb69d87fc (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xa7fc) #1 0xb69d9239 (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xb239) #2 0xb69d92d6 (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xb2d6) #3 0x804f151 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x804f151) #4 0x80531e8 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x80531e8) #5 0x8051e6f (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8051e6f) #6 0x8049b0a (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8049b0a) #7 0x804bd9e (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x804bd9e) #8 0xb6778a62 (/lib/i386-linux-gnu/i686/cmov/libc-2.18.so+0x19a62) #9 0x8049330 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8049330) Address 0xbffff4b0 is located at offset 416 in frame <parse_sdp_data> of T0's stack: This frame has 8 object(s): [32, 36) 'audio_payload' [96, 100) 'payload' [160, 164) 'channels' [224, 228) 'ptime' [288, 292) 'port' [352, 368) 'ipv4' [416, 480) 'audio_name' [512, 576) 'audio_codec' HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext (longjmp and C++ exceptions *are*
2014-05-22osmux: Fix potential memory leak in the msgb handlingHolger Hans Peter Freyther1-0/+2
2014-05-22mgcp: Add proper length checking for line handlingHolger Hans Peter Freyther1-0/+22
In ae1997248ccb4fba1394267d3051082dfd85448a the handwritten tokenizer was replaced with strtok_r. As part of this change the structural checking of MGCP parameters was stopped. This means that a code like "line + 3" might access beyond the first NUL and be possibly behind the msgb. Manually add size checking again. Manually jumping to the error label is not possible anymore as it has been removed. The result is that invalid lines will be skipped. This is matching the general approach by the IETF RFCs to be permissive in data being received.