aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp
AgeCommit message (Collapse)AuthorFilesLines
2015-01-02Partial revert "Fix most compiler warnings with gcc-4.9.2"Holger Hans Peter Freyther1-1/+1
Most of the "fixes" have nothing to do with gcc-4.9.2 but are a question of ABI/Architecture (e.g. x86 vs. AMD64). Revert these for now. This partially reverts commit 7b1d25a11e44bbc1cb0d2acd9f1a3d4a16ec7c90. abis_test.c: In function ‘test_simple_sw_config’: abis_test.c:68:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[0].start - simple_config, descr[0].len); ^ abis_test.c: In function ‘test_dual_sw_config’: abis_test.c:111:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[0].start - dual_config, descr[0].len); ^ abis_test.c:115:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[1].start - dual_config, descr[1].len); ^ abis_test.c: In function ‘test_sw_selection’: abis_test.c:132:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[0].start - load_config, descr[0].len); ^ abis_test.c:136:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[1].start - load_config, descr[1].len);
2015-01-01Fix most compiler warnings with gcc-4.9.2Harald Welte1-1/+1
2014-11-20mgcp/sdp: Session name must not be empty pick an empty oneHolger Hans Peter Freyther1-0/+1
The session name must be present in a SDP file. The RFC proposes to use a space for it but the other equipment is using the dash so I have picked that as well. RFC 4566: The "s=" field is the textual session name. There MUST be one and only one "s=" field per session description. The "s=" field MUST NOT be empty and SHOULD contain ISO 10646 characters (but see also the "a=charset" attribute). If a session has no meaningful name, the alue "s= " SHOULD be used (i.e., a single space as the session name). Fixes: RT#2196
2014-11-19mgcp: Allow to omit sending the audio name at allHolger Hans Peter Freyther2-1/+53
Equipment like AudioCode appears to get upset when we use a builtin type and then assign a name to it. Allow to completely omit the name.
2014-10-09mgcp: Count the incoming data instead of the modified oneHolger Hans Peter Freyther1-2/+2
For jitter, transit and packet loss we should count the data that arrived and not the data we send towards the remote. This is changing the jitter timings to what they were before the re-factoring. For forced timing we might willingly add jumps in the sequence number but for jitter and packet loss we are more interested in the data that traveled through the wire/air.
2014-10-09mgcp: Do not detect the initial package as a wrap aroundHolger Hans Peter Freyther1-20/+21
The Annex A code has a probation period but we don't have it. When starting with seq_no==0 do not assume that the sequence numbers have wrapped. Do it by moving the entire checking code into the else.
2014-10-09mgcp: Move Annex A counting out of patch/count methodHolger Hans Peter Freyther1-41/+63
mgcp_patch_and_count has grown due supporting linearizing timestamps, ssrc and other things for equipment like the ip.access nanoBTS. Fight back and move the Annex A code into a dedicated method. The result is updated as we now count after all the patching and for the Annex A code no change in SSRC can be detected.
2014-10-09mgcp: We only look at the RTP header use that in the commentHolger Hans Peter Freyther1-2/+2
2014-09-17osmux: send osmux stats in MGCP DLCX responsesPablo Neira Ayuso2-6/+32
This allows us to know what number of messages and bytes has been received per active osmux endpoint. Note that an Osmux message is composed of several chunks. Each chunk contains an osmux header plus several voice data frames. P: PS=385, OS=11188, PR=195, OR=5655, PL=0, JI=49 X-Osmo-CP: EC TIS=0, TOS=0, TIR=0, TOR=0 X-Osmux-ST: CR=51, BR=3129 The new 'X-Osmux-ST:' notifies the received chunks and bytes.
2014-09-16osmux: account extracted traffic from the osmux batchPablo Neira Ayuso1-0/+6
Use struct mgcp_rtp_end statistics to account the RTP messages that has been extracted from the osmux batch and transmitted.
2014-09-02mgcp: Deal with receiving another payload typeHolger Hans Peter Freyther1-1/+53
In case we get offered G729 and G711 we might have selected G729 as the audio codec. The first packet we receive might be G711 though. In that case we will need to change. But only if we have a matching alternate codec payload_type. E.g. in the case of comfort noise we will receive the PT=11 and we don't want to change.
2014-09-02mgcp: Store one more codec/payload type if it is presentHolger Hans Peter Freyther1-7/+18
In case of some RTP proxy from time to time we are offered both G729 and G711 but only one of them will work. I intend to adjust the codec at runtime in case we receive the wrong codec.
2014-09-02mgcp: Group codec reset and put it to a separate method.Holger Hans Peter Freyther1-9/+15
2014-09-02mgcp: Move the "codec" params to a structHolger Hans Peter Freyther4-71/+78
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-09-02mgcp: Use the rtp_hdr structure and extract ts/seq from thereHolger Hans Peter Freyther1-6/+8
Use the rtp_hdr structure. The basic alignment issue remains and I need to merge/cherry-pick Jacob's getters for the ts, sequence number and other attributes.
2014-09-01osmux: osmux batch-factor can't be higher than 8Pablo Neira Ayuso1-1/+1
The osmux header uses a counter of 3 bits, so you can put up to 8 message in it.
2014-09-01osmux: save specific osmux configuration options if osmux is enabledPablo Neira Ayuso1-7/+8
Just like other options do, to avoid polluting the configuration file with unused options if osmux is disabled.
2014-08-30osmux: initialize osmux_batch_size in mgcp configPablo Neira Ayuso1-1/+1
The library allows to indicate zero as batch size if you want to use the default size, however openbsc saves 'osmux batch-size 0' which is not good as input. Use OSMUX_BATCH_DEFAULT_MAX to explicitly initialize the batch size from mgcp_parse_config().
2014-08-29osmux: add 'osmux batch-size NUM' option to mgcp vtyPablo Neira Ayuso2-0/+14
This allows you to specify the osmux batch frame size. If zero, the library uses the default value.
2014-08-29osmux: set default port from mgcp_parse_config()Pablo Neira Ayuso2-5/+1
2014-08-29osmux: fix unchecked return value in mgcp_parse_osmux_cid()Pablo Neira Ayuso1-2/+4
** CID 1232804: Unchecked return value (CHECKED_RETURN) /src/libmgcp/mgcp_protocol.c: 888 in mgcp_parse_osmux_cid()
2014-08-28osmux: fix leak in osmux_deliver()Pablo Neira Ayuso1-0/+1
The callback is responsible for releasing the batch message that libosmo-netif builds.
2014-08-28osmux: fix access to uninitialized memory area in scheduled_tx_*_cbPablo Neira Ayuso1-2/+8
mgcp_send() needs some initialized address when printing a log message. Nothing really serious but let's calm down valgrind.
2014-08-28osmux: rename osmux.c to mgcp_osmux.cPablo Neira Ayuso2-1/+1
So we can easily identify in the log message what refers to libosmo-netif and what to libmgcp.
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.