aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp
AgeCommit message (Collapse)AuthorFilesLines
2014-01-31mgcp/rtp: Base jitter calculation on input timestampsJacob Erlbeck1-2/+4
So far, the jitter computation has been based on output timestamps. This patch uses the input timestamps instead and resets jitter computation on SSRC changes. Sponsored-by: On-Waves ehf
2014-01-31mgcp/rtp: Compute delta timestamp based on wallclockJacob Erlbeck1-2/+10
Currently, when the SSRC changes within a stream and SSRC fixing is enabled, the RTP timestamp between the last packet that has been received with the old SSRC and the first packet of the new SSRC is always incremented by one packet duration. This can lead to audio muting (at least with the nanoBTS) when the wallclock interval between these packets is too large (> 1s). This patch changes the implementation to base the RTP timestamp offset on the wallclock interval that has passed between these two packets. Ticket: OW#466 Sponsored-by: On-Waves ehf
2014-01-31mgcp/rtp: Fix transit computation unitsJacob Erlbeck1-8/+12
Currently micro-secs and RTP rate get mixed when the transit value is computed in mgcp_patch_and_count(). This patch changes get_current_ts() to accept the desired rate as argument and to use it for the time conversion instead of always converting to microseconds. If microseconds are needed, get_current_ts(1000) can be used. The arrival_time is now measured in 1/rtp_end->rate seconds so that it can be directly compared to RTP timestamps as required by RFC3550 (section 6.4.1, see definition of 'interarrival jitter'). Sponsored-by: On-Waves ehf
2014-01-20mgcp: Synchronize conn mode bits and output enabled flagsJacob Erlbeck1-24/+7
This patch changes implementation and the mgcp_connection_mode enum in a way that net_end.output_enabled (bts_end.output_enabled) flag always matches the MGCP_CONN_SEND_ONLY (MGCP_CONN_RECV_ONLY) bit of conn_mode. Based on this, the conn_mode bits are then used instead of the output_enabled fields within mgcp_protocol.c. Sponsored-by: On-Waves ehf
2014-01-20mgcp: Disable output enabled on initialisationJacob Erlbeck1-1/+1
Currently RTP output_enabled is set to 1 on initialisation, which does not semantically match the initial value of conn_mode (MGCP_CONN_NONE). This patch changes this initial value to 0. Sponsored-by: On-Waves ehf
2014-01-17openbsc: Fix coverity issuesJacob Erlbeck1-3/+16
This patch (hopefully) fixes the new defects reported by coverity. Addresses: ** CID 1156986: Negative array index read (NEGATIVE_RETURNS) /tests/gsm0408/gsm0408_test.c: 419 in test_si_range_helpers() /tests/gsm0408/gsm0408_test.c: 423 in test_si_range_helpers() /tests/gsm0408/gsm0408_test.c: 427 in test_si_range_helpers() ** CID 1156987: Unchecked return value from library (CHECKED_RETURN) /src/libmgcp/mgcp_protocol.c: 1150 in mgcp_keepalive_timer_cb() ** CID 1156988: Unchecked return value from library (CHECKED_RETURN) /src/libmgcp/mgcp_protocol.c: 983 in handle_modify_con() Sponsored-by: On-Waves ehf
2014-01-16mgcp: Send RTP keepalive dummy packets to netJacob Erlbeck2-0/+134
So far, a single dummy packet has been sent immediately after the reception of a MDCX message. There is no dedicated keep alive mechanism (it just worked because the audio from the MS has always been forwarded to the NAT until the 'mgcp: Set output_enabled flags based on the MGCP mode' patch). This patch adds explicit, timer based keep alive handling that can be enable per trunk. A VTY command 'rtp keep-alive' command is added for configuration which can be used to set the interval in seconds, to send a single packet after the reception of a CRCX/MDCX when RTP data from the net is expected ('once'), or to disable the feature completely ('no rtp keep-alive'). In 'send-recv' connections, only the initial packet is sent if enabled (even when an interval has been configured). The default is 'once'. Note that this removes the mgcp_change_cb() from mgcp_main.c. Sponsored-by: On-Waves ehf
2014-01-16mgcp/rtp: Send dummy packet to the RTCP destination, tooJacob Erlbeck1-2/+9
Currently a dummy packet is only sent to the RTP port. This is not enough if RTCP must also cross the SNAT. This patch sends an additional dummy packet to the RTCP net destination if omit_rtcp is not set. Sponsored-by: On-Waves ehf
2014-01-16mgcp/rtp: Make offset computation understandableJacob Erlbeck1-4/+4
Rename the timestamp variable to make in clear, that the input timestamp is meant. Add a helper variable to illustrate the offset computation. Sponsored-by: On-Waves ehf
2014-01-16mgcp: Set output_enabled flags based on the MGCP modeJacob Erlbeck1-7/+30
This patch enhances parse_conn_mode() to set the output_enabled flags of each end based on the MGCP mode. Ticket: OW#1044 Sponsored-by: On-Waves ehf
2014-01-16mgcp/rtp: Add flag to disable RTP outputJacob Erlbeck3-2/+12
This patch make it possible to have a valid endpoint that drops all outgoing RTP packets. The number of dropped packets is shown by the VTY 'show mgcp' command. By default, this feature is disabled. To enable packet dropping, the corresponding output_enabled field must be set to 0. Ticket: OW#1044 Sponsored-by: On-Waves ehf
2014-01-16mgcp/rtp: Refactor mgcp_send to avoid code duplicationJacob Erlbeck1-28/+22
Currently there are two symmetric code paths which are selected by the packet destination (NET or BTS). This patch introduces 3 variables that take the different values and unifies both code paths into one. Sponsored-by: On-Waves ehf
2013-12-19mgcp/rtp: Only patch timestamp alignment errorsJacob Erlbeck3-51/+118
Currently, all timestamps are force to SeqNo*d + C which is more than required by the nanoBTS which seems to be sensitive to alignment errors only (dTS != k*d, d = ptime * rate = 160). This patch replaces the force_constant_timing feature by a force_aligned_timing feature. The timestamp offset will only be changed (and timestamp errors counted) when the alignment does not match to the raster based on ptime (default 20ms). The VTY interface does not change. Sponsored-by: On-Waves ehf
2013-12-13mgcp: Optionally send ptime in SDPJacob Erlbeck2-1/+72
Currently the SDP 'ptime' media attribute is never set in generated MGCP responses. This patch optionally includes the 'ptime' attribute if packet_duration_ms is != 0. This behaviour can be enabled/disabled by using the VTY command "sdp audio-payload send-ptime" (enabled by default). Sponsored-by: On-Waves ehf
2013-12-13mgcp: Parse SDP to get rate and packet durationJacob Erlbeck2-6/+56
This patch parses the 'ptime' and 'maxptime' SDP attributes, and the SDP rate information and sets up packet_duration_ms accordingly. If the packet duration is unknown or allows for different values (e.g. because 'ptime' uses a range or 'maxptime' allows for more than one frame) the duration is set to 0. Sponsored-by: On-Waves ehf
2013-12-13mgcp: Put local connection options into a structJacob Erlbeck1-5/+28
Currently the local connection options have been stored as a string. This patch replaces this string by a struct (that still contains a string) along with the parsed fields (only the packetization period at the moment). It also re-adds the calls to set_local_cx_options() to the handle_create_con() and handle_modify_con() functions. Except for the test program this has no side effects, since the LCO values aren't used yet.
2013-12-13mgcp/rtp: Refactor timestamp offset calculation into own functionJacob Erlbeck1-32/+66
Currently the timestamp offset calculation is done in two different places. This patch moves and unifies both code parts into a separate function. Sponsored-by: On-Waves ehf
2013-12-10mgcp/rtp: Refactored packet_duration computationJacob Erlbeck2-7/+22
Since the packet duration is given in ms with the 'ptime' RTP media attribute and also with the 'p' MGCP local connection option, the computation is changed to use this value (if present). The computation assumes, that there are N complete frames in a packet and takes into account, that the ptime value possibly had been rounded towards the next ms value (which is never the case with a frame length of exact 20ms). Sponsored-by: On-Waves ehf
2013-12-10mgcp/rtp: Fix RTP timestamps if enabledJacob Erlbeck1-9/+31
This forces the output timing to fulfill dTS = dSegNo * fixedPacketDuration where dSegNo = seqNo - lastSeqNo. If timestamp patching is enabled, the output timestamp will be set to lastTimestamp + dTS. This kind of relative updating is used to handle seqNo- and timestamp-wraparounds properly. The updating of timestamp and SSRC has been separated and the patch field of mgcp_rtp_state has been renamed to patch_ssrc to reflect it's semantics more closely. The offset fields are now used always and will change the corresponding header field if they are != 0. Ticket: OW#1065 Sponsored-by: On-Waves ehf
2013-12-10mgcp/rtp: Only patch SSRC once after MDCX if enabledJacob Erlbeck2-1/+5
Currently the output SSRC is always forced to be the same if SSRC patching is enabled. This patch modifies this to optionally restrict the number of SSRC changes that will be corrected. Note that the configuration only allows for the 'once' mode and 'off'. Sponsored-by: On-Waves ehf
2013-12-10mgcp/rtp: Use SSRC in proper byte orderingJacob Erlbeck1-9/+13
The ssrc has been used without respect to proper byte ordering in mgcp_patch_and_count(). This only affected log messages. This patch introduces a new variable 'ssrc' that takes the value of the SSRC in proper byte order. Sponsored-by: On-Waves ehf
2013-12-10mgcp/rtp: Compute default packet duration at state initialisiationJacob Erlbeck1-10/+13
This patch adds a packet_duration field to mgcp_rtp_state which contains the RTP packet's duration in RTP timestamp units or 0, when the duration is unknown or not fixed. Sponsored-by: On-Waves ehf
2013-12-10mgcp/rtp: Only update RTP header field offsets if enabledJacob Erlbeck1-16/+28
Currently seq_offset and timestamp_offset are updated on each SSRC change even when SSRC patching is not allowed. This patch fixes this by changing mgcp_patch_and_count() to only update these fields when SSRC patching is allowed. Sponsored-by: On-Waves ehf
2013-12-10mgcp/rtp: Change the log message shown when the SSRC changesJacob Erlbeck1-7/+9
Show old and new SSRC. Move logging command upward to show the values immediately after the change has been detected and before any fixing attempt is made. Sponsored-by: On-Waves ehf
2013-12-10mgcp/rtp: Add RTP header patch mode configurationJacob Erlbeck3-3/+165
This adds datastructures and a VTY frontend to configure the different type of RTP header patching: SSRC and timestamp. Note that timestamp patching is not yet implemented. Sponsored-by: On-Waves ehf
2013-12-05mgcp/rtp: Fix output timing error counterJacob Erlbeck1-3/+14
The tsdelta computation and error detection didn't handle the intialisation phase properly. This patches fixes this by skipping the output timing validation when the SSRCs don't match. Sponsored-by: On-Waves ehf
2013-12-05mgcp: Handle SDP in CRCX received by the MGWJacob Erlbeck1-0/+9
So far the SDP part of the CRCX message has been ignored by the MGW. This patch adds SDP parsing for this case, eventually updating the net end's payload type and connection parameters. Sponsored-by: On-Waves ehf
2013-12-05mgcp: NUL-terminate MGCP messageJacob Erlbeck1-1/+15
The MGCP message isn't always NUL-terminated when arriving at mgcp_handle_message(). This may lead to undefined results. This patch ensures that the message text is NUL-terminated by setting *msg->tail to '\0' in mgcp_handle_message(). Addresses: <000b> mgcp_protocol.c:642 Unhandled option: 'r'/114 on 0x3 <000b> mgcp_protocol.c:593 Unhandled SDP option: '='/61 on 0x3 <000b> mgcp_protocol.c:871 Unhandled option: '.'/46 on 0x2 Sponsored-by: On-Waves ehf
2013-12-05mgcp: Refactor MGCP/SDP parsingJacob Erlbeck1-32/+66
This patch separates the SDP parsing from the (message specific) MGCP parsing. Sponsored-by: On-Waves ehf
2013-12-05mgcp: Add new for_each_line macro that also returns empty linesJacob Erlbeck1-0/+32
This patch add the for_each_line macro based on a strline_r() function (similar to strtok_r()), that is also part of this patch. This strline_r() function is tolerant with respect to line endings, it supports CR-only, CRLF, and LF-only and any combinations thereof (note that a CRLF is always detected as a single line break). Similar to for_each_non_empty_line (the former for_each_line) where the 'save' pointer needed to be initialised by a call to strtok_r(), the new for_each_line macro expects, that the 'save' pointer has been initialised by a call to strline_r(). Also note, that for_each_line/strline_r and for_each_non_empty_line/strtok_r may use the 'save' pointer differently, so calls to them can not be mixed. Sponsored-by: On-Waves ehf
2013-12-05mgcp: Rename for_each_line to for_each_non_empty_lineJacob Erlbeck1-6/+6
The implementation of for_each_line is based on strtok() and skips any sequence of CR and LF. Thus empty lines are never detected. There exists code which tests for an empty line to detect the beginning of the SDP part which is dead code currently (the parser works nevertheless due to other reasons). So the semantics of this macro have been misunderstood at least once. This patch renames the macro to reflect the semantics more precisely. Sponsored-by: On-Waves ehf
2013-11-25mgcp/rtp: Fix timestamp offset when patching RTP packetsJacob Erlbeck2-4/+31
The current implementation increments the seqno but does not increment the RTP timestamp, leading to two identical timestamps following one after the other. This patch fixes this by adding the computed tsdelta when the offset is calulated. In the unlikely case, that a tsdelta hasn't been computed yet when the SSRC changes, a tsdelta is computed based on the RTP rate and a RTP packet duration of 20ms (one speech frame per channel and packet). If the RTP rate is not known, a rate of 8000 is assumed. Note that this approach presumes, that the per RTP packet duration (in samples) is the same for the last two packets of the stream being replaced (the first one). Sponsored-by: On-Waves ehf
2013-11-25mgcp/rtp: Add test case for RTP timestamp patching and statsJacob Erlbeck1-9/+9
This patch adds a test case to check, whether RTP timestamps are generated properly after SSRC changes and whether the error counters work properly. Sponsored-by: On-Waves ehf
2013-11-25mgcp/rtp: Add counter for invalid RTP timestamp deltasJacob Erlbeck3-27/+146
This patch modifies the patch_and_count() function to check for RTP timestamp inconsistencies. It basically checks, whether dTS/dSeqNo remains constant. If this fails, the corresponding counter is incremented. There are four counter for this: Incoming and outgoing, each for streams from the BTS and the net. Note that this approach presumes, that the per RTP packet duration (in samples) remains the same throughout the entire stream. Changing the number of speech frames per channel and packet will be detected as error. In addition, the VTY command 'show mgcp' is extended by an optional 'stats' to show the counter values, too. Ticket: OW#964 Sponsored-by: On-Waves ehf
2013-10-30vty: Use vty_install_default() instead of bsc_install_default()Jacob Erlbeck1-2/+2
Remove ournode_exit_cmd, ournode_end_cmd, and bsc_install_default() since this functionality is provided by the current libosmocore. Replace calls to bsc_install_default() by call to vty_install_default() with the following semantic patch: @rule1@ expression N; @@ - bsc_install_default(N); + vty_install_default(N); Ticket: OW#952 Sponsored-by: On-Waves ehf
2013-09-02vty: Use generic 'end' and 'exit' commandsJacob Erlbeck1-6/+2
Add bsc_install_default() and replace all install_default() This patch adds bsc_install_default() which calls install_default() and add 'exit' and 'end'. All other calls to install_default() are replaced by calls to bsc_install_default(). Since 'exit' and 'end' are now added automatically to each node, the explicit registrations of these commands are removed by this patch, too. The related tests succeed now without work-arounds (except for the 'config' node itself which is part of libosmocore).
2013-08-27libmgcp: add enum mgcp_rolePablo Neira Ayuso1-1/+3
This enum indicates if the mgcp is running on the BSC or the BSC-NAT.
2013-08-27libmgcp: attach mgcp_ prefix to udp_sendPablo Neira Ayuso1-11/+16
This patch is a cleanup.
2013-08-14libmgcp: add mgcp prefix to functions and constantsPablo Neira Ayuso1-33/+37
Functions and constants that belong to the libmgcp scope are prefixed with mgcp_ and MGCP_. This patch is a cleanup.
2013-07-08libmgcp: add enum mgcp_type and use itPablo Neira Ayuso2-12/+30
This patch replaces the field 'is_transcoded' in the mgcp_endpoint structure by the enum mgcp_type, that can be further extended with new types.
2013-07-03mgcp: Make sure the save pointer is initialized with NULL.Holger Hans Peter Freyther1-1/+1
Coverity is not happy about it but it doesn't appear to be a real issue as the data will not be NULL on the first call. Addresses: Coverity CID 1040704
2013-06-12Makefile.am: Use AM_CPPFLAGSAlexander Huemer1-1/+1
Since automake 1.13 INCLUDES is depricates and causes a warning
2013-05-21mgcp: Initialize the tone to CHAR_MAX as this might not be a requestHolger Hans Peter Freyther1-1/+1
The RQNT message might not contain a 'S:' line with the actual tone to play. Instead of calling the callback with the 0 as tone just leave early. Example: X: 6B9519B88F0 R: D/[0-9#*](N), G/ft, fxr/t38
2013-04-16nat: We want the remote to respond to our DLCX requestHolger Hans Peter Freyther1-1/+29
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-03-03vty: Document some previously undocumented parametersHolger Hans Peter Freyther1-2/+4
Katerina pointed out that some nodes are not fully documented and proposed some messages. The token/timeout messages were correct, I have modified the other messages. I removed the full-stop from the PING/PONG documentation as we are normally not using a full sentence.
2012-12-16mgcp: Allow to freely control the a=fmtp line for experimentsHolger Hans Peter Freyther2-2/+45
In case of AMR one can specify the available codecs out-of-band. Allow to configure this line statically in the configuration file.
2012-12-16mgcp: Fix the vary large jump detection in the codeHolger Hans Peter Freyther1-1/+1
GCC 3.x on PowerPC correctly highlights that the code is fishy. Re-reading the RFC 3550 shows that we should subtract it and then we are in the 16bit range. The probation and re-sync code is still missing. GCC: mgcp/mgcp_network.c:200: warning: comparison is always true due to limited range of data type
2012-12-10mgcp: Test and implement re-transmission handlingHolger Hans Peter Freyther1-161/+161
MGCP is used over UDP and a response might be lost. The MGCP RFC asks for keeping a list of responses and then using the previous response to answer a duplicate request. I tried to conserve memory and just wanted to remember the last transaction identifier and result-code and re-generate the result from that. This made the code look bad and this is why the entire response will now be stored. It sadly increases the memory usage but can not be avoided at this time. Remove the msg->l3h pointer for the RQNT callback as strtok has modified the content of it.
2012-12-10mgcp: Change the flow of the code when handling a MGCP responseHolger Hans Peter Freyther1-11/+14
Attempt to detect a response and return only then. Remove one level of tabls in preparation for the re-transmission handling.
2012-12-10mgcp: Methods generating a response now include the endpoint pointerHolger Hans Peter Freyther1-37/+35
This is required for remembering the last result in a central place and is required to properly implement detection of re-transmissions.