New field "header_ppi" is now managed and inserted into
cdr_tag_data mysql table.
This field will store into the aggregated cdr data the
P-Preferred-Identity header of the INVITE.
Change-Id: Ib875976fd7332e80ae100f257c7af701ffe9f661
New added acc data are usually added without strick check of
their presence to avoid that ACC generated before the upgrade
fails and get dropped.
In the code there are some very old cases for upgrades from
mr8.x to mr9.x versions that now are removed.
Change-Id: I295547cd11656adf015a4fe5b6038a792f8cf532
This fixes a bug which incorrectly used strlen(callid) instead of
strlen(esc_callid) to determine the size of the VLA to hold the complete
query string.
Take this opportunity to eliminate the VLA and switch to an allocated
printf string instead.
Change-Id: I4a64d05180832f3471249acf354bec6b5a3ba15e
New field "r_ua" is now managed and inserted into
cdr_tag_data mysql table.
This field will store into the aggregated cdr data the user agent
relative to the first 2xx response of an INVITE.
Change-Id: Icf8e80d0d2b63f4b9db006c8a224335989057e86
New field "r_user" is now managed and inserted into
cdr_tag_data mysql table.
This field will store into the aggregated cdr data table the user part
of the RURI relative to the first 2xx response of an INVITE.
Change-Id: Ie61809e9245adfa09c6babb4b3fa328da8c56cbb
To allow mediator to continue to run after an SQL insert failure, retry
the inserts one by one after the bulk insert failed. This makes it
possible to 1) narrow down which row caused the error and make this
clearly visible in the log, and 2) allow for a small number of failed
inserts that can be ignored. The latter is needed to allow for broken
acc records that need to be discarded anyway.
Change-Id: Idf233cac3c05be108abbba061f4661255525c468
Use a queue to keep track of the position of each CDR entry as it is
added into the SQL string. This allows us to inspect each entry
individually if the insert goes wrong.
Change-Id: I2f95e35030c3f55f8ccd3efb3ef20684f301af2e
All `medmysql_str` except CDRs have an associated queue, kept separately
in `medmysql_cdr_batch`. Move it directly into `medmysql_str` to make
things easier.
Change-Id: Idd6d31596e5e121a44c9b7922be66c24e7a43518
New field "hg_ext_response" is now managed and inserted into
cdr_tag_data mysql table.
This field will store into the aggregated cdr data the number
of the extention picking up the call after an HG.
Change-Id: I816eba4a6a227e1a809c2db1ab5ae0665d4c1aa1
This makes it possible to trace which CDR record was created from which
acc records and at which point.
Change-Id: I3645ccf244bf7d86b6f70181c57e47dfa204f7b9
Use the call ID from the contained JSON object in REFER records to
follow the call flow to the new call ID and look there for the matching
BYE record.
Change-Id: Ie2655937c12bb8ae6ae2aa48c1b2cdbb3c1ac120
This allows us to fetch only specific records that we're interested in,
based on context, instead of all of them and then having to do a second
pass over them.
Change-Id: I5e314fa633f57c79db85476e347a3305b5f585e9
Instead of using two lists to keep the acc records (based on where they
were retrieved from) use only a single list for all acc records.
Make sure the list is only appended to in the functions doing the record
retrieval.
Since the list of acc records needs to be sorted only when records were
retrieved from Redis, change the return value of the retrieval functions
to indiciate whether this needs to be done, or -1 for error.
Change-Id: Ie61c054b430cb5d390b1f2b742c64be1df831fd4
Now we can use some of the JSON fields for decision making purposes,
before we get to the CDR creation stage.
Change-Id: I0a521c7c6bbf82e5fed683c5461914fefd784f0f
Use strdup/free for string fields in med_entry_t that are highly
variable in length. This elimiates future problems if one of these
fields ever has its length extended.
Use g_strdup as it guarantees a non-NULL return value.
Change-Id: Ia0f5883547feb62f04fcd4c5353850eb9d815413
Using an array in this context (to return a list of acc records) is
mostly pointless as it wastes memory and incurs the additional overhead
of having to initialise the array and an extra layer of copying strings
around. This also ultimately allows us to dynamically append to the list
of acc records without having to reallocate the array.
Change-Id: I1039f01861f8d3f82fdc3a80377fd7535fa24bab
Using an array in this context (to return a list of call IDs) is mostly
pointless as it wastes memory and incurs the additional overhead of
having to initialise the array and an extra layer of copying strings
around. This also eliminates the auxiliary type `med_callid_t` and
ultimately allows us to dynamically append to the list of call IDs
without having to reallocate the array.
Use g_strdup for string allocation as it guarantees a non-NULL return
value.
Change-Id: Iae6c97f80c216352ab36de89d361f09ee355b6c8
As the number of subscribers grows, the current approach of doing a full
table dump of the subscribers DB and caching it in memory becomes less
and less feasible. The new approach is to simply do a straight DB query
for each subscriber as records are processed, and then cache the result
in memory for a little while.
Change-Id: I19a6271d779bd0abccc29e3548e7bcdb2e00baa3
While the code is not threaded, better be future-proof and use safer
APIs, which in addition has less side-effects as it does not set the
global TZ related variables.
Change-Id: I57fbe6683590cc2fbc0da508819553c040764739
Warned-by: lgtm
While MariaDB uses my_bool here, MySQL uses the standard bool type. Both
are compatible, so use the more standard one.
Change-Id: I648bc8eb55f7617f6b4eb796a33bc77ce15ca34b
With the increased length of src/dst_leg strings, we must also increase
the buffer size for the insert string.
Did I mention that we should really move to dynamic strings here...
Change-Id: I0e77155d36f434055e36124d37bf699179f887b1
Due to the movement of call transfer handling from sems pbx to
standard sems, in case of blind call transfer the BYE ACC is
generated with call_id suffix '_pbx-1_xfer-1' instead of '_xfer-1'.
To be more precise, currently we creates 2 ACCs for INVITEs:
- one without any suffix
- one with '_xfer-1" suffix
and just one for the BYE:
- with '_xfer-1' suffix
Mediator is able to use the BYE to close both the INVITEs
With the new implementation we creats 2 ACCs for INVITEs:
- one without any suffix
- one with '_pbx-1_xfer-1" suffix
and just one for the BYE:
- with '_pbx-1_xfer-1' suffix
The sinlge BYE record is not used to close both the ACC INVITEs.
Change-Id: Id7a68fab8d84ffe987084e925fecc1e051cbaccd
Strings, in particular call IDs, that are coming from Redis are not
necessarily valid UTF-8 since Redis doesn't really do UTF-8. The MySQL
DB schema expects strings in valid UTF-8 however (even though call IDs
really should be raw binary strings), resulting in an error if an
UTF-8 invalid string is attempted to be inserted.
Solve this by verifying each string's UTF-8 correctness before inserting
it, and forcing it to be interpreted as the 100% permissive latin1
charset if it isn't.
Change-Id: I5a218083bc4e3d7a47d1f77911f7ef9a88ce9bd2
In a cluster setup, intermediate CDRs might be written to a different
host than the final CDRs (central vs pair).
Change-Id: I56716d2a96857d52715e48f513ee1d75676b1e52
Since medmysql_flush_med_str() takes the handler from the
_medmysql_batch_definition structure, the last retrieved insert ID must
also be taken from the same handler.
Change-Id: Ieaee3313d94cf41d8953591dd88a12e42be601d5
The DB schema allows for certain columns to be NULL. Handle this
appropriately to elminiate failed assertions from g_strlcpy.
Change-Id: I8768847b96b169dfad94b2ca448cc2af5058d38b
To prepare for a second kind of CDR records, we refactor the SQL batch
string handling to include the statement definition and data queues in
the string object, and stop passing them around as arguments everywhere.
Change-Id: I2e3b278e859ce0cc22e7827c91d284b39fc34ecc
* cdr_tag_data value is now escaped
* simplified cdr_group group escaping code to
bring in line with how it is in the other places
Change-Id: Ie10242fed9d4430247f8ac534b19679d38206fee
* callid that is used in sql statements is now escaped,
for scenarios where there are calls with quotes in callids
Change-Id: I3061a73fe944ec911e84031a1cff40043b7e174c
These produce too much output, and spam the log files. Make them debug
level output so that we can still see them if desired, but not shown by
default.
Change-Id: Iec8037c0c60d3f221811a4baeabdbb4daeed95ce
Instead of hardcoding -I/usr/include/mysql for CFLAGS and -lmysqlclient
for LDFLAGS, let's use mariadb_config if available (e.g. on
Debian/buster), try mysql_config otherwise (e.g. on Debian/stretch) or
if neither of them is available, fallback to -I/usr/include/mysql +
-lmysqlclient.
No longer include `m_string.h`, it was moved towards
/usr/include/mariadb/server/m_string.h and is no longer compatible when
used as such:
| /usr/include/mariadb/server/m_string.h:89:23: error: unknown type name 'uchar'; did you mean 'char'?
| extern void bmove_upp(uchar *dst,const uchar *src,size_t len);
Also no longer use libmysqlclient15-dev as alternative Build-Depend,
it's not available in neither stretch nor buster.
While at it drop include for my_global.h, since it shouldn't be included
anymore (and it doesn't seem to be relevant for us, compiling fine as-is
on Debian/stretch and Debian/buster):
| /usr/include/mariadb/my_global.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]
Change-Id: I74a75ea24f72880adb8117ae5808095f03bc0edb