Skip to content

Commit

Permalink
Merge branch 'master' into dev_load_balancer
Browse files Browse the repository at this point in the history
  • Loading branch information
spacetourist committed Mar 28, 2024
2 parents cfccd4c + 4b23a80 commit 8fc0efa
Show file tree
Hide file tree
Showing 170 changed files with 11,862 additions and 2,094 deletions.
5 changes: 3 additions & 2 deletions Makefile.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
#identity= Adds support for SIP Identity (see RFC 4474). | SSL library, typically libssl
#jabber= Integrates XODE XML parser for parsing Jabber messages | Expat library.
#json= Introduces a new type of variable that provides both serialization and de-serialization from JSON format. | JSON library, libjson
#launch_darkly= Implements an interface to the Launch Darkly feature management cloud
#launch_darkly= Implements an interface to the Launch Darkly feature management cloud | Launch Darkly C++ server-side SDK (libldserverapi)
#ldap= Implements an LDAP search interface for OpenSIPS | OpenLDAP library & development files, typically libldap and libldap-dev
#lua= Easily implement your own OpenSIPS extensions in Lua | liblua5.1-0-dev, libmemcache-dev and libmysqlclient-dev
#httpd= Provides an HTTP transport layer implementation for OpenSIPS. | libmicrohttpd
#http2d= Provides HTTP/2 server-side support, using nghttp2 | nghttp2 library (libnghttp2), libevent, libssl and libevent-openssl
#mi_xmlrpc_ng= New version of the xmlrpc server that handles xmlrpc requests and generates xmlrpc responses. | parsing/building XML library, typically libxml
#mmgeoip= Lightweight wrapper for the MaxMind GeoIP API | libGeoIP
#osp= Enables OpenSIPS to support secure, multi-lateral peering using the OSP standard | OSP development kit, typically osptoolkit
Expand Down Expand Up @@ -68,7 +69,7 @@
#xmpp= Gateway between OpenSIPS and a jabber server. It enables the exchange of IMs between SIP clients and XMPP(jabber) clients. | parsing/building XML files, typically libexpat1-devel
#uuid= UUID generator | uuid-dev

exclude_modules?= aaa_diameter aaa_radius auth_jwt b2b_logic_xml cachedb_cassandra cachedb_couchbase cachedb_memcached cachedb_mongodb cachedb_redis carrierroute cgrates compression cpl_c db_berkeley db_http db_mysql db_oracle db_perlvdb db_postgres db_sqlite db_unixodbc dialplan emergency event_rabbitmq event_kafka h350 httpd identity jabber json launch_darkly ldap lua mi_xmlrpc_ng mmgeoip osp perl pi_http presence presence_dialoginfo presence_mwi presence_xml presence_dfks proto_sctp proto_tls proto_wss pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp python regex rabbitmq rabbitmq_consumer rest_client rls siprec sngtc snmpstats stir_shaken tls_mgm tls_openssl tls_wolfssl uuid xcap xcap_client xml xmpp
exclude_modules?= aaa_diameter aaa_radius auth_jwt b2b_logic_xml cachedb_cassandra cachedb_couchbase cachedb_memcached cachedb_mongodb cachedb_redis carrierroute cgrates compression cpl_c db_berkeley db_http db_mysql db_oracle db_perlvdb db_postgres db_sqlite db_unixodbc dialplan emergency event_rabbitmq event_kafka h350 httpd http2d identity jabber json launch_darkly ldap lua mi_xmlrpc_ng mmgeoip osp perl pi_http presence presence_dialoginfo presence_mwi presence_xml presence_dfks proto_sctp proto_tls proto_wss pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp python regex rabbitmq rabbitmq_consumer rest_client rls siprec sngtc snmpstats stir_shaken tls_mgm tls_openssl tls_wolfssl uuid xcap xcap_client xml xmpp

include_modules?=

Expand Down
1 change: 1 addition & 0 deletions db/db_cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef enum db_cap {
DB_CAP_LAST_INSERTED_ID = 1 << 8, /**< driver can return the ID of the last insert operation */
DB_CAP_INSERT_UPDATE = 1 << 9, /**< driver can insert data into database and update on duplicate */
DB_CAP_MULTIPLE_INSERT = 1 << 10, /**< driver can insert multiple rows at once */
DB_CAP_PREPARED_STMT = 1 << 11, /**< driver supports prep statements */
} db_cap_t;


Expand Down
4 changes: 2 additions & 2 deletions db/schema/dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<column>
<name>mangled_from_uri</name>
<type>string</type>
<size>&user_len;</size>
<size>&uri_len;</size>
<default><null/></default>
<null/>
<description>The mangled from URI, in case uac_replace_from
Expand All @@ -79,7 +79,7 @@
<column>
<name>mangled_to_uri</name>
<type>string</type>
<size>&user_len;</size>
<size>&uri_len;</size>
<default><null/></default>
<null/>
<description>The mangled to URI, in case uac_replace_to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
]>

<database xmlns:xi="http://www.w3.org/2001/XInclude">
<name>DB Operations</name>
<name>SQL Operations</name>
<xi:include href="usr_preferences.xml"/>
</database>
2 changes: 1 addition & 1 deletion db/schema/usr_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<version>3</version>
<type db="mysql">&MYSQL_TABLE_TYPE;</type>
<description>
<db:para>This table us used by the DBops module to implement Attribute Value Pairs (AVP's). More information about the DBops module can be found at: &OPENSIPS_MOD_DOC;dbops.html
<db:para>This table us used by the SQLops module to implement Attribute Value Pairs (AVP's). More information about the SQLops module can be found at: &OPENSIPS_MOD_DOC;sqlops.html
</db:para>
</description>

Expand Down
4 changes: 3 additions & 1 deletion doc/build-contrib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ fix_authors=(
["13e9a5cbe14050e622a3ef65cd34b72260a74f01"]="Kennard White"
["26599d25cbc140373a5c24759dce688235e57589"]="Anatoly Pidruchny"

# dbops
# sqlops
["37eba4b6d38f379a227040397c569f0d0fe99c9c"]="Kennard White"
["d129377f64f13e85ea0baf6d215092b4b4776f6e"]="Norman Brandinger"
["b9247c08af07662c6e712179dc57bcc5f16794aa"]="Kobi Eshun"
Expand Down Expand Up @@ -617,6 +617,8 @@ mod_renames=(
[event_stream]=event_jsonrpc
[b2b_logic]=b2b_logic:1605638778
[b2b_logic_xml]=b2b_logic::1605638778
[sqlops]=dbops
[dbops]=avpops
)

mk_git_handle() {
Expand Down
2 changes: 1 addition & 1 deletion doc/doxygen/opensips-doxygen
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ INPUT = ./ \
modules/auth \
modules/auth_aaa \
modules/auth_db \
modules/dbops \
modules/sqlops \
modules/b2b_entities \
modules/b2b_logic \
modules/b2b_sca \
Expand Down
4 changes: 3 additions & 1 deletion lib/cJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ extern cJSON_Hooks sys_mem_hooks;
extern cJSON_Hooks shm_mem_hooks;


/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate.
* The input @value can be safely freed immediately after the parsing.
* Call cJSON_Delete when finished. */
extern cJSON *cJSON_Parse(const char *value);
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
extern char *cJSON_Print(const cJSON *item);
Expand Down
70 changes: 70 additions & 0 deletions lib/cond.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (C) 2024 OpenSIPS Solutions
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* opensips is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "cond.h"
#include "../dprint.h"

int cond_init(gen_cond_t *cond)
{
int ret = -1;
pthread_condattr_t cattr;
pthread_mutexattr_t mattr;

if (pthread_mutexattr_init(&mattr) != 0) {
LM_ERR("could not initialize mutex attributes\n");
return -1;
}
if (pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED) != 0) {
LM_ERR("could not mark mutex attribute as shared\n");
goto mutex_error;
}
if (pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST) != 0) {
LM_ERR("could not mark mutex attribute as robust\n");
goto mutex_error;
}
if (pthread_mutex_init(&cond->m, &mattr) != 0) {
LM_ERR("could not initialize mutex\n");
goto mutex_error;
}
if (pthread_condattr_init(&cattr) != 0) {
LM_ERR("could not initialize cond attributes\n");
goto cond_error;
}
if (pthread_condattr_setpshared(&cattr, PTHREAD_PROCESS_SHARED) != 0) {
LM_ERR("could not mark mutex cond as shared\n");
goto cond_error;
}
if (pthread_cond_init(&cond->c, &cattr) != 0) {
LM_ERR("could not initialize cond\n");
goto cond_error;
}
return 0;
cond_error:
pthread_condattr_destroy(&cattr);
mutex_error:
pthread_mutexattr_destroy(&mattr);
return ret;
}

void cond_destroy(gen_cond_t *cond)
{
pthread_cond_destroy(&cond->c);
pthread_mutex_destroy(&cond->m);
}
50 changes: 50 additions & 0 deletions lib/cond.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2024 OpenSIPS Solutions
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* opensips is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef __OSIPS_COND__
#define __OSIPS_COND__

#include <pthread.h>

typedef struct gen_cond {
pthread_mutex_t m;
pthread_cond_t c;
} gen_cond_t;

/* initializes a condition allocated in shared memory */
int cond_init(gen_cond_t *cond);

/* destroyes a condition */
void cond_destroy(gen_cond_t *cond);

#define cond_lock(_c) pthread_mutex_lock(&(_c)->m)
#define cond_unlock(_c) pthread_mutex_unlock(&(_c)->m)
#define cond_wait(_c) pthread_cond_wait(&(_c)->c, &(_c)->m)
/* make sure we reset the errno, to avoid confusion when resumed */
#define cond_timedwait(_c, _ts) \
do { \
errno = 0; \
pthread_cond_timedwait(&(_c)->c, &(_c)->m, (_ts)); \
} while (0)
#define cond_has_timedout(_c) (errno == ETIMEDOUT || errno == EAGAIN)/* TODO do we need to store this during wait? */
#define cond_signal(_c) pthread_cond_signal(&(_c)->c)
#define cond_broadcast(_c) pthread_cond_broadcast(&(_c)->c)

#endif /* __OSIPS_COND__ */
75 changes: 75 additions & 0 deletions lib/csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,78 @@ void free_csv_record(csv_record *record)
free_f(prev);
}
}

static int check_quote_csv_record(str *val, int *escape)
{
char *p;
int quote = 0;
*escape = 0;

for (p = val->s; p < val->s + val->len; p++) {
switch (*p) {
case '"':
(*escape)++;
/* fallthrough */
case ',':
case '\n':
quote = 1;
break;
}
}
return quote;
}

str *__print_csv_record(csv_record *record, enum csv_flags print_flags,
unsigned char sep)
{
static str ret;
str_list *it;
int len = -1, esc;
char *p, *c;

if (print_flags & CSV_SHM)
malloc_f = osips_shm_malloc;
else
malloc_f = osips_pkg_malloc;

for (it = record; it; it = it->next) {
len += 1 /* sep */ + it->s.len;
/* check to see if ne need to encode */
if (check_quote_csv_record(&it->s, &esc))
len += 2 + esc;
}

ret.s = malloc_f(len);
if (!ret.s)
return NULL;
p = ret.s;
for (it = record; it; it = it->next) {
if (it != record)
*p++ = sep;

if (check_quote_csv_record(&it->s, &esc)) {
if (!esc) {
/* simply add the quotes */
*p++ = '"';
memcpy(p, it->s.s, it->s.len);
p+= it->s.len;
*p++ = '"';
} else {
for (c = it->s.s; c < it->s.s + it->s.len; c++) {
switch (*c) {
case '"':
*p++ = '"';
break;
}
*p++ = *c;
}
}
} else {
/* simply copy the content */
memcpy(p, it->s.s, it->s.len);
p += it->s.len;
}
}
ret.len = len;
return &ret;
}
5 changes: 5 additions & 0 deletions lib/csv.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ csv_record *__parse_csv_record(const str *in, enum csv_flags parse_flags,
/* Easily free your CSV records, regardless of any flags set during parsing */
void free_csv_record(csv_record *record);

str *__print_csv_record(csv_record *record, enum csv_flags print_flags,
unsigned char sep);
#define _print_csv_record(in, flags) __print_csv_record(in, flags, ',')
#define print_csv_record(in) _print_csv_record(in, 0)

#endif /* __LIB_CSV__ */
12 changes: 12 additions & 0 deletions lib/digest_auth/dauth_calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,40 @@ const struct digest_auth_calc* get_digest_calc(alg_t algorithm)
switch (algorithm) {
case ALG_UNSPEC:
case ALG_MD5:
case ALG_AKAv1_MD5:
case ALG_AKAv2_MD5:
digest_calc = &md5_digest_calc;
break;

case ALG_MD5SESS:
case ALG_AKAv1_MD5SESS:
case ALG_AKAv2_MD5SESS:
digest_calc = &md5sess_digest_calc;
break;

#if defined(SHA_256_ENABLE)
case ALG_SHA256:
case ALG_AKAv1_SHA256:
case ALG_AKAv2_SHA256:
digest_calc = &sha256_digest_calc;
break;

case ALG_SHA256SESS:
case ALG_AKAv1_SHA256SESS:
case ALG_AKAv2_SHA256SESS:
digest_calc = &sha256sess_digest_calc;
break;
#endif
#if defined(SHA_512_256_ENABLE)
case ALG_SHA512_256:
case ALG_AKAv1_SHA512_256:
case ALG_AKAv2_SHA512_256:
digest_calc = &sha512t256_digest_calc;
break;

case ALG_SHA512_256SESS:
case ALG_AKAv1_SHA512_256SESS:
case ALG_AKAv2_SHA512_256SESS:
digest_calc = &sha512t256sess_digest_calc;
break;
#endif
Expand Down
12 changes: 12 additions & 0 deletions lib/digest_auth/digest_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,25 @@ int digest_algorithm_available(alg_t algorithm)
case ALG_UNSPEC:
case ALG_MD5:
case ALG_MD5SESS:
case ALG_AKAv1_MD5:
case ALG_AKAv1_MD5SESS:
case ALG_AKAv2_MD5:
case ALG_AKAv2_MD5SESS:
#if defined(SHA_256_ENABLE)
case ALG_SHA256:
case ALG_SHA256SESS:
case ALG_AKAv1_SHA256:
case ALG_AKAv1_SHA256SESS:
case ALG_AKAv2_SHA256:
case ALG_AKAv2_SHA256SESS:
#endif
#if defined(SHA_512_256_ENABLE)
case ALG_SHA512_256:
case ALG_SHA512_256SESS:
case ALG_AKAv1_SHA512_256:
case ALG_AKAv1_SHA512_256SESS:
case ALG_AKAv2_SHA512_256:
case ALG_AKAv2_SHA512_256SESS:
#endif
return (1);

Expand Down
Loading

0 comments on commit 8fc0efa

Please sign in to comment.