This obsoletes the need to retain the last seen kernel stats and track
updates to the counters in order to set call states.
Change-Id: Ie5338bd630b679af205a16933f847ccdcd6a477e
Require rtpe_stats to be set before allowing a target to be created.
Refactor init method into its own function.
Otherwise currently unused.
Change-Id: Ic66e7f92f875ede1a3a2d55fee4ed53c39ff93be
Rename the "noop" method to "init" and split up the function to open the
table into two parts. Open the control file first, then do the mmap(),
then init other things, then finally call the init method.
Change-Id: I832f6e90fbec4375e3e19ed6e72d7cce78488e9e
Keep two separate timestamps, one updated by userspace code only and the
other updated by kernel only. This way we can tell where the packet
processing happens. For code that wants to report only the last
timestamp regardless of which one of the two it is, we add a convenience
function that just returns the newer one.
Change-Id: Ib3af7aa55006d8b32e2bc3db4f8bfa5514c57e40
This leaves the TOS value as the only leftover to be not in shm.
The kernel_stats structures remain for the time being as they're needed
to determine whether kernel forwarding is done or not, as well as for
global stats.
Change-Id: I158f18098e018d2870b797f1a196baa03a0e0fb7
Allocate memory from bufferpool for per-stream stats. No functional
change, but it allows sharing these between kernel and user space.
Change-Id: I370a49e1d94bb91c7fd0a2bc7d00ba65f99c4f6a
Use the kernel/user shared memory to keep track of interface stats. This
eliminates the need to update the userspace stats counters with the
values from the kernel, and vice versa when updating the kernel streams.
Add a function to reverse map userspace mapped memory address to kernel
space addresses.
Change-Id: Iaa5f9488061a12103e57faf27b3979521778cea8
There isn't any immediate benefit to this, but it prepares the code for
use of shared memory for statistics.
Use the opportunity to switch accesses to these to relaxed memory order.
Change-Id: I585fef7579202179fbbcbc1b843d3bbe440a723b
Switch all memory buffers used for RTP I/O from generic stack or heap
allocated memory to the bufferpool implementation. Use a per-thread
bufferpool to minimise lock contention.
This commit is just a one-for-one swap and doesn't use the bufferpool's
reference counting semantics yet.
Change-Id: I9cba4ec97bd0afcd374bf6c0be2b608a46e73e57
To support asynchronous pollers which may hold references on underlying
sockets, let the poller close the socket after it has released its
references. This prevents cases of file descriptor re-use while an
underlying socket is still open.
Add reset_socket() to be used in place of close_socket() which does the
same thing except the actual closing of the socket.
Add poller_del_item_callback() for cases where more action than just
closing the file descriptor is needed.
Change-Id: Iefda1487ecb89263729120ecb964436dd79b2a0e
using str_init_dup_str doesn't leave enough room for appending encryption
related pieces to the end of the packet when used for, eg, dtmf
injection
closes#1819
Change-Id: Iefae0e04b38f4a3eaaac32ed1ba70c7e3ee8e979
Support is desired for Kamailio/Rtpengine traffic via UDP.
Adding homer-disable-rtcp-stats and homer-enable-ng config params to
separately control sending to Homer each traffic type. By default rtcp
is `on` when homer parameter is configured. NG is by default disabled.
closes#1802
Change-Id: Ib68fb133cffc5d8945f9b6bf60bab3e80fab9630
This has been broken for a while and nobody seems to be using it since
nobody complained. Remove it.
Change-Id: I114e7b1859ecd1982338c625f4523f372af3bbe8
Keep the default case for the `call_ng_flags_flags()` more
accurate, which makes it easier for reading.
Change-Id: I317656ab964503389f2c84e835dd9db69cc70c3e
Deprecate a usage of intermediate dictionary for parsing
of rtpp flags. Just use the `call_ng_main_flags()` function
directly with a given `bencode_buffer_t` buffer.
Change-Id: I0bea13b94b6e0016799dd07a50061e1367131106
Switch the rest of flags (with non-specific processing)
to direct parsing or deprecate specific parsing at all
and let it be parsed as generic one (key/val).
Deprecated for:
- `TOS`
- `to-tag`
- `call-id`
- `via-branch`
Left for:
- `from-tag` (requires directional flag setting)
- `delete-delay` (uses int bencode object, because the
`call_delete_ng()` requires it in this format)
Change-Id: I0c5cb173bae09064f8177298aef3d070132f84cf
Deprecate parsing of generic flags using `new_list_to_dict()`.
Leaving it only for `received-from` as it requires special
handling. Function signature is adopted accordingly.
The funciton itself calls the `call_ng_main_flags()` directly,
without really using intermediate bencode objects.
Change-Id: I320761a4b84da0128981f9b65e3ba69e9b4018ac
Direction parsing.
Instead of adding key/val flags to the dictionary for
further parsing later via iteration in `call_ng_main_flags()`,
just call the `call_ng_main_flags()` directly.
Change-Id: Ide137aed12a6ba416b59a307a0a11a934f78a858
Codec related flags parsing.
A bencode list for codec related flags keeping (while
parsing in `parse_rtpp_flags()` ), is removed due to no need.
Instead of adding key/val flags to the dictionary for
further parsing later via iteration in `call_ng_main_flags()`,
just call the `call_ng_codec_flags()` directly.
Change-Id: I1adcea84e9254ae35e6480d61426f1434513e779
Transport parsing.
Instead of adding key/val flags to the dictionary for
further parsing later via iteration in `call_ng_main_flags()`,
just call the `call_ng_main_flags()` directly.
Change-Id: I86a2d6855bcd94edb206c632d8288dd769e94ba8
Instead of adding key/val flags to the dictionary for
further parsing later via iteration in `call_ng_main_flags()`,
just call the `call_ng_main_flags()` directly.
Change-Id: Ia893a6b50db7a0659a42c09463169f2c0f5e595e
These don't actually do anything right now as these function don't do an
early return, but having these in place will make things more future
proof.
Change-Id: I05b82a4366847e0eff1d1392885cf086516df053
NFTNL_EXPR_TG_INFO actually expects the info data to be heap allocated
via malloc(), as it will free() it when the expression is freed via
nftnl_expr_free().
No symbol table info available.
No symbol table info available.
No symbol table info available.
No locals.
No locals.
r = 0x55e087c75130
err = <optimized out>
err = <optimized out>
args=args@entry=0x7ffc80943460) at ./nftables.c:593
err = <optimized out>
nl = 0x55e087c4add0
seq = 1711621092
err = 0x0
nl = <optimized out>
seq = <optimized out>
err = <optimized out>
No locals.
Log:
rtpengine[269176]: INFO: [crypto] Generating new DTLS certificate
rtpengine[269176]: DEBUG: [crypto] Using EC-prime256v1 key for DTLS certificate
rtpengine[269176]: free(): invalid pointer
rtpengine[269792]: INFO: [crypto] Generating new DTLS certificate
rtpengine[269792]: DEBUG: [crypto] Using EC-prime256v1 key for DTLS certificate
rtpengine[269792]: free(): invalid pointer
rtpengine[270372]: INFO: [crypto] Generating new DTLS certificate
rtpengine[270372]: DEBUG: [crypto] Using EC-prime256v1 key for DTLS certificate
rtpengine[270372]: free(): invalid pointer
rtpengine[2487]: INFO: [crypto] Generating new DTLS certificate
rtpengine[2487]: DEBUG: [crypto] Using EC-prime256v1 key for DTLS certificate
rtpengine[2487]: free(): invalid pointer
Change-Id: Id67a4bb4cd3627d7ea6aed1b9f7d73b80ed676c8
Since the generic flags parsing is done (from now on) directly
in the `parse_rtpp_flags()`, there is no need to keep a separate
bencode list object to store them, which was originally intended
to be used later for parsing in `call_ng_flags_flags()`,
but not the case anymore.
Change-Id: I7898e29cabecfd6e8429c064d7b5904d94c50513
Introduced by d7b8ebbc68
*** CID 1584501: Control flow issues (MISSING_BREAK)
/daemon/call_interfaces.c: 1825 in call_ng_main_flags()
1819 call_ng_flags_str_list(out, value, call_ng_flags_replace, NULL);
1820 break;
1821 case CSH_LOOKUP("rtcp-mux"):
1822 case CSH_LOOKUP("RTCP-mux"):
1823 call_ng_flags_str_list(out, value, call_ng_flags_rtcp_mux, NULL);
1824 break;
>>> CID 1584501: Control flow issues (MISSING_BREAK)
>>> The case for value "324" is not terminated by a "break" statement.
1825 case CSH_LOOKUP("rtpp-flags"):;
1826 case CSH_LOOKUP("rtpp_flags"):;
1827 /* new dictionary to store rtpp_flags */
1828 bencode_item_t * dict;
1829 dict = bencode_dictionary(value->buffer);
1830 assert(dict != NULL);
Change-Id: Iaa1d9b3bd31d32e48451c3a47f8e99fa3c755e63
having injected events on the recv list can cause out of order TS
values which results in is_in_dtmf incorrectly returning NULL and
letting the transcoded PCM frames through.
It also doesn't make sense to add DTMF to the send list unless they're
actually being sent, so injected delayed or unblocked
Change-Id: I07e2a35e27142715a5257f199326b7a3d133e2a8
now that the returned last_event_ts is always that of the previous
DTMF, we can ensure that the next one isn't transmitted until that
time plus the required pause.
Like the num_samples calculation, the actual time needs to be
increased by 1 packets worth of samples so tha pause lasts the
full duration required
Change-Id: I6da1dd7cbcf49f7f0431a5123df2cdc382fe3dba
this function is used to determine if a pause is needed on a new
injected DTMF's start ts to ensure a gap between the events. However,
if an inject request comes in after the end of the previous event
but before it would have been offset due to pause, no pause is added
This change returns the ts value from dtmf_state if the queue is
empty as that will always be the ts of the last DTMF transmitted
Change-Id: I4f3cf5115d1a8e26c0ca1bc9570c46e29391e0d0
the num_samples was added to the start_pts, which is the first event
packet timestamp, which has already increased its ts by its event
duration. so, the total duration of events ends up being one packet
more than intended.
Change-Id: I423bb222a81c5bd78e570ff2026c72dd4dd1b100
Make sure we increase the output RTP sequence
number for each generated packet in the case
of packets that need to be duplicated or sent
repeatedly (DTMF end event)
Change-Id: Ia16ffefc0791d01575248ac5d8025eb30ccaec67
in some scenarios the start event ts can be before the *pts value, which
will result in a shortened DTMF event being transmitted than expected during
injection as the end event ts is calculated based on that initial dtmf start
value.
This change updates the end event ts by the amount the start ts was
behind, so that the resulting event has the right duration
Change-Id: Ia637d1e1c5d92de8b35317ec552c22eae23c0645
when DTMF is being transmitted using codec_output_rtp, the scheduled
time to send the packet is calculated using the timestamp difference
from the last transmitted applied on top of the realtime time the
last packet was sent. However, the timestamp is only updated on the
first event packet so a delay needs to be passed in to codec_output_rtp
to ensure the subsequent packets are scheduled based on the event
duration of the event packets
Change-Id: I5a2f6cf67b5f570f6099d201592d9a6fc01d60a5
A fix for bullseye/buster and focal:
call_interfaces.c: In function 'call_ng_main_flags':
call_interfaces.c:1828:4: error: a label can only be part of a statement and a declaration is not a statement
1828 | bencode_item_t * dict;
| ^~~~~~~~~~~~~~
make[3]: *** [<builtin>: call_interfaces.strhash.o] Error 1
Switch case has to be followed by a statement, and the declaration
is not, so just follow it by the empty statement.
Change-Id: I7c5ef62dec9ceb404736ec3c4bed84f04b892d24
It's a useful function for parsing flags, which
we most probably will need in the future, but unsed now.
Change-Id: I3bed7b52e565a24f4ea8ee791a5872ad9cb06228
During the parsing of `rtpp_flags` use the
`call_ng_flags_flags()` directly instead of the
`bencode_list_add_str()`, hence reduce amount
of iterations required to parse generic flags.
Additionally:
`call_ng_flags_flags()` is made visible for usage
within external files.
`helper_arg` union has been moved to the header.
Change-Id: I34399a0d3940a1276feb1210e4421cbcdf656e9d
Is added by:
- explicit generic flag "directionl"; or
- if the "from-tag" flag is used
Introduce the `directional` flag for `sdp_ng_flags` struct.
In use by:
- `media_block_match1()`
Additionally:
add `IS_OP_DIRECTIONAL()` marco check.
Change-Id: Ifd56ea2ad8277d7dec136def1c028c5e2b680ff1
For the sake of proper processing for From/To tags,
we need to know which message type originated interaction
with the rtpengine (from behalf of kamailo module).
This can be of two types:
- request
- reply
This can also be re-used later, if there is a need
to detect whether that was a request or reply.
P.S.: opmode and message type shouldn't be confused,
it's not the same, since SDP offer can come in the request
as well as in the reply message (late offer/answer).
So the opmode reflects what exactly is being done in terms of
rtpengine operations, meanwhile the message type shows, which
message type originated this processing.
Change-Id: I8336175d3cfcf521418ac18b71cb4a6d5730705d
Synchronize the `enum call_opmode` with the
kamailio module list of operation modes, as well
as with the `enum ng_command`.
This allows to operate based on `call_opmode`
in a more specific way, for example for a proper
setting of From/To tags based on directional flag,
which in its turn is being set using `call_opmode`.
Additionally introduce a macro checker, which covers
all previously non-existent operation mode types
as OP_OTHER, for backwards compatibility in conditions.
Change-Id: Idf4b9d910b81ee24be51008996c3fd02d8336a38
Add support of rtpp_flags parsing for the daemon.
From now on, it's possible to parse option flags
on the daemon side instead of the kamailio module.
It's identical to what the module does, but the
difference is:
- module sends general call identification such as:
call-id, From/To tags, viabranch using bencode
- meanwhile all generic/non-generic option flags
are added to the `rtpp_flags` bencode member as str
- parsing of that is done as usually using the
`call_ng_main_flags()` / `call_ng_flags_flags()`
and additionally using new parser `parse_rtpp_flags()`
New file implementation and header introduced:
- control_ng_flags_parser.c
- control_ng_flags_parser.h
Otherwise no functional changes, and the parsing itself
remains working following the same algorithm.
Change-Id: I59e47fa1947e2aeaa0bbf3930a0f21d9a6d669ad
Turn repeat count into an int. No need for a long long.
Store start_pos in media_player.
Set start_pos and repeat count at the relevant code points once, instead
of passing it into multiple functions.
Take the opportunity to turn these shared options into a struct.
Change-Id: I758e899784fe1a6531f443d6a14fa59cf71bd4eb
Use a dedicated enum return code for functions that are used in code
paths that can lead to 3 different outcomes (ok/error/consume) instead
of a plain int. Extend this tristate return code to also include
__rtp_decode().
Change-Id: I22e1b0bf72216613188cb88315edb1f8feb18d07
If multiple pollers are in use, use a single poller per call instead of
assigning pollers round-robin to each socket used in the call.
Change-Id: Iec49bd9d2fbd75d947d6232bcccfdfe87c4c6d7c
The poller-per-thread feature was broken with a division by zero. Take
the opportunity to rework it and eliminate the poller_map object. Use a
simple array of pollers for media sockets, plus one global poller for
control sockets. In the regular case only one poller is created and
everything points to that poller. In the poller-per-thread case, one
poller per thread is created, plus one poller (also with its own single
thread) for control connections. All control sockets use the single
control poller, while all media sockets get assigned one poller from the
pool in a round-robin fashion.
closes#1801
Change-Id: Iae91a3e10b7206455c6df33b1a472254c700ce21
Look up the first object in the tree to determine the needed sleep time.
But instead of leaving the object in the tree for the next (post-sleep)
iteration, which requires another tree lookup, remove it from the tree
and remember it, anticipating that nothing would get added into the tree
to be scheduled sooner. This saves us from having to do another tree
lookup for each timer that runs.
Adapt the scheduling function to be able to handle this and wake up the
thread sooner if necessary.
Change-Id: I9297346bc4aa8d2f68ecb833be8f71ce62a3bbfe
If the timer thread is already scheduled to wake before the timer that
we want to schedule, then there is no need to wake it up for nothing.
Change-Id: I5e6174bb0347954dfc5d012befe31625fad9961a
This should prevent multiple threads from fighting over the same shared
structures (GTree + mutex + condition). Downside is that it may lead to
load not being perfectly balanced between threads.
Change-Id: I8127b98dcfbeafd692d74e60cdf6d60e3e572ba7
poller_new used to have the side effect of initialising rtpe_now.
Restore this side effect explicitly in the startup code, so that timers
are launched with the correst start time instead of zero.
Change-Id: I590061a9665b52c4aed00c06dc330d2a226c73d3
We cannot directly use the rule_scratch area when checking for the
nftables status, as this scratch area is re-initialised for each rule.
Instead add check_matched_flag() to be called after each rule was
parsed, and use it to set a corresponding iterate_scratch flag.
closes#1794
Change-Id: Ie954a91949d09887b9a293f4010bb08e78100145
These aren't only used to match "immediate" rules, so rename them
accordingly. Make it more clear what check_matched_queue() does.
Change-Id: Ie2d48c075e79c24ac120673bc7c0445c3686326f
Fix a regression from 4291c858
send_timer_rtcp() does its own locking of the SSRC. Release the lock
before calling it.
Change-Id: I185fb2fb4b47a343ab4be00d16629b5f330ee965
The monologue label (and possibly other) get set during the offer/answer
routine. Do the call recording setup after this has been done.
closes#1791
Change-Id: Ie1b1a7d5a1df7058ba90c3dd5cbd79159f48683d
For convenience we provide extra HTTP and WS endpoints that accept a
cookie-less NG or JSON message string. Not all commands are sensitive to
retransmits and this makes it easier to query call status etc.
Change-Id: Iffbc4ef9a5fdf916a374dfdd4042c61b437d18c9
Create a separate function that actually processes a message packet
without dealing with the cookie
Change-Id: I163a48ff3d508ae95617eaa76403bf2cf702cff8
Distinguish between functions that enagage or disengage the recording
daemon and functions acting on actual recording, which eliminates the
need to deal with the flags separately.
Change-Id: Ia2d718d9e6f95d7621a2ba186c60b501f7404fe7
If base chain is "none", the admin is responsible for jumping into the
custom chain. Don't remove jumps the admin migth have setup.
closes#1787
Change-Id: I9980acb12fb1abb0883b22aceab2719087768763
When base chain is "none", the admin is required to manage jumping into the
rtpengine chain. The chain can't be deleted if it is still referenced by
another rule, which is common in this configuration.
closes#1787
Change-Id: I8a72e1041a364db60870b5acececc234c8452bab
Telling netlink to create a chain that already exists should technically
be a no-op, BUT it still sets the policy to whatever was given as a side
effect. Make sure we don't change the policy by explicitly checking for
the chain's existence.
closes#1785
Change-Id: I526a4e2a0f9d1dcc6e0e00a6e273e4df55863d6c
Store SDP session attributes in the monologue that were received instead
of the ones to be sent out. Look up the corresponding source monologue
when creating an outgoing SDP and insert that one's attributes.
Change-Id: Ic2e57db71b0e0b48b9868940d326b5a951d89e92
Consider call_media SDP attributes as ones that were received instead of
the ones to be sent out. Use media subscriptions to look up the source
media and print that one's attributes when creating an outgoing SDP.
Change-Id: Ibdf3a77a6f8a61654e0fc7c14aae16dfc6eabf14
Make 'extmap' attributes another type of OTHER attribute, which are
printed verbatim, but instead of skipping over them when parsing them
and "strip extmap" is requested, always parse and store them and then
skip over them when printing them.
Change-Id: I9f8e9c468ea0d1b20d82ae563c334513a8c0c43e
All OTHER attributes are printed verbatim as strings, but we still want
to be able to distinguish between different types of them. Introduce an
extra enum for that purpose.
Change-Id: I24351c26a45ffbbe1dec9299faa5d0ea65cada29
Even though both true and false are set in different calls to the
function, there's no effective difference in output.
Change-Id: I0d29dbf2d8041523b6b28bb0c0270bb6b414dcb5
An empty attribute list is not the indicative factor of whether or not
to empty out and re-fill the list of attributes, as having no attributes
is a valid scenario and should lead to no attributes present on the
output side.
Change-Id: I3464cd6cf0709a38b7c89a2f138d7a0329ce993b
Make sure sdp_attributes is only used for _received_ SDP attributes, and
not ones that we want to send out. The only places where self-generated
attributes are being used is the T.38 gateway.
Change-Id: I1f035cd42a35fa250ea477700a1a88ad59efcc38
Use a settable callback function to do attribute printing. This makes it
possible to use different sources for SDP attribute output in different
situations.
Change-Id: I30be7772dd73d9ca8cb9483de53eb60734e12950