Skip to content

Commit

Permalink
ims_registrar_scscf: clang-format for coherent indentation and coding…
Browse files Browse the repository at this point in the history
… style
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent d0d11e9 commit a840365
Show file tree
Hide file tree
Showing 42 changed files with 7,882 additions and 6,921 deletions.
16 changes: 8 additions & 8 deletions src/modules/ims_registrar_scscf/api.h
Expand Up @@ -40,14 +40,15 @@ int regapi_lookup(struct sip_msg *msg, char *table);
/**
* @brief REGISTRAR API structure
*/
typedef struct registrar_api {
regapi_save_f save;
regapi_lookup_f lookup;
regapi_lookup_f registered;
typedef struct registrar_api
{
regapi_save_f save;
regapi_lookup_f lookup;
regapi_lookup_f registered;
} registrar_api_t;

typedef int (*bind_registrar_f)(registrar_api_t* api);
int bind_registrar(registrar_api_t* api);
typedef int (*bind_registrar_f)(registrar_api_t *api);
int bind_registrar(registrar_api_t *api);

/**
* @brief Load the REGISTRAR API
Expand All @@ -61,8 +62,7 @@ static inline int registrar_load_api(registrar_api_t *api)
LM_ERR("cannot find bind_registrar\n");
return -1;
}
if (bindregistrar(api) < 0)
{
if(bindregistrar(api) < 0) {
LM_ERR("cannot bind registrar api\n");
return -1;
}
Expand Down
23 changes: 12 additions & 11 deletions src/modules/ims_registrar_scscf/common.c
Expand Up @@ -34,7 +34,7 @@
* \ingroup registrar
*/

#include <string.h>
#include <string.h>
#include "../../core/dprint.h"
#include "../../core/parser/parse_uri.h"
#include "rerrno.h"
Expand All @@ -47,7 +47,8 @@
/*! \brief
* Extract Address of Record
*/
int extract_aor(str* _uri, str* _a) {
int extract_aor(str *_uri, str *_a)
{
static char aor_buf[MAX_AOR_LEN];
str tmp;
struct sip_uri puri;
Expand All @@ -58,9 +59,9 @@ int extract_aor(str* _uri, str* _a) {
str realm_prefix;

memset(aor_buf, 0, MAX_AOR_LEN);
if (aor_avp_name.n != 0) {
if(aor_avp_name.n != 0) {
avp = search_first_avp(aor_avp_type, aor_avp_name, &avp_val, 0);
if (avp && is_avp_str_val(avp)) {
if(avp && is_avp_str_val(avp)) {
uri = &avp_val.s;
} else {
uri = _uri;
Expand All @@ -69,13 +70,13 @@ int extract_aor(str* _uri, str* _a) {
uri = _uri;
}

if (parse_uri(uri->s, uri->len, &puri) < 0) {
if(parse_uri(uri->s, uri->len, &puri) < 0) {
rerrno = R_AOR_PARSE;
LM_ERR("failed to parse Address of Record\n");
return -1;
}

if ((puri.user.len + puri.host.len + 1 + 4) > MAX_AOR_LEN
if((puri.user.len + puri.host.len + 1 + 4) > MAX_AOR_LEN
|| puri.user.len > USERNAME_MAX_SIZE
|| puri.host.len > DOMAIN_MAX_SIZE) {
rerrno = R_AOR_LEN;
Expand All @@ -91,20 +92,20 @@ int extract_aor(str* _uri, str* _a) {
tmps.s = _a->s + 4;
tmps.len = puri.user.len;

if (un_escape(&puri.user, &tmps) < 0) {
if(un_escape(&puri.user, &tmps) < 0) {
rerrno = R_UNESCAPE;
LM_ERR("failed to unescape username\n");
return -3;
}

user_len = tmps.len + 4;//_a->len;
user_len = tmps.len + 4; //_a->len;

if (user_len>4)
if(user_len > 4)
aor_buf[_a->len++] = '@';
/* strip prefix (if defined) */
realm_prefix.s = cfg_get(registrar, registrar_cfg, realm_pref);
realm_prefix.len = strlen(realm_prefix.s);
if (realm_prefix.len && realm_prefix.len < puri.host.len
if(realm_prefix.len && realm_prefix.len < puri.host.len
&& (memcmp(realm_prefix.s, puri.host.s, realm_prefix.len) == 0)) {
memcpy(aor_buf + _a->len, puri.host.s + realm_prefix.len,
puri.host.len - realm_prefix.len);
Expand All @@ -114,7 +115,7 @@ int extract_aor(str* _uri, str* _a) {
_a->len += puri.host.len;
}

if (cfg_get(registrar, registrar_cfg, case_sensitive) && user_len) {
if(cfg_get(registrar, registrar_cfg, case_sensitive) && user_len) {
tmp.s = _a->s + user_len + 1;
tmp.len = _a->s + _a->len - tmp.s;
strlower(&tmp);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/ims_registrar_scscf/common.h
Expand Up @@ -26,7 +26,7 @@
* \file
* \brief SIP registrar module - common stuff
* \ingroup registrar
*/
*/


#ifndef COMMON_H
Expand All @@ -38,7 +38,7 @@
/*! \brief
* Extract Address Of Record
*/
int extract_aor(str* _uri, str* _a);
int extract_aor(str *_uri, str *_a);


#endif /* COMMON_H */
104 changes: 60 additions & 44 deletions src/modules/ims_registrar_scscf/config.c
Expand Up @@ -30,49 +30,65 @@

#include "config.h"

struct cfg_group_registrar default_registrar_cfg = {
3600, /* default_expires */
0, /* default_expires_range */
60, /* min_expires */
0, /* max_expires */
3600, /* emergency contact default expires */
60, /* emergency contact max expires */
0, /* emergency contact min expires */
0, /* max_contacts */
0, /* retry_after */
0, /* case_sensitive */
Q_UNSPECIFIED, /* default_q */
1, /* append_branches */
"" /* realm_pref */
};
struct cfg_group_registrar default_registrar_cfg = {
3600, /* default_expires */
0, /* default_expires_range */
60, /* min_expires */
0, /* max_expires */
3600, /* emergency contact default expires */
60, /* emergency contact max expires */
0, /* emergency contact min expires */
0, /* max_contacts */
0, /* retry_after */
0, /* case_sensitive */
Q_UNSPECIFIED, /* default_q */
1, /* append_branches */
"" /* realm_pref */
};

void *registrar_cfg = &default_registrar_cfg;
void *registrar_cfg = &default_registrar_cfg;

cfg_def_t registrar_cfg_def[] = {
{"default_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, default_expires_stats_update,
"Contains number of second to expire if no expire hf or contact expire present" },
{"default_expires_range", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 100, 0, default_expires_range_update,
"Percent from default_expires that will be used in generating the range for the expire interval"},
{"min_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, 0,
"The minimum expires value of a Contact. Value 0 disables the checking. "},
{"max_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, max_expires_stats_update,
"The maximum expires value of a Contact. Value 0 disables the checking. "},
{"em_default_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, 0,
"The default emergency expires value of a Contact."},
{"em_max_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, 0,
"The maximum emergency expires value of a Contact. Value 0 disables the checking. "},
{"em_min_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, 0,
"The maximum emergency expires value of a Contact. Value 0 disables the checking. "},
{"max_contacts", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0,
"The maximum number of Contacts for an AOR. Value 0 disables the checking. "},
{"retry_after", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0,
"If you want to add the Retry-After header field in 5xx replies, set this parameter to a value grater than zero"},
{"case_sensitive", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0,
"If set to 1 then AOR comparison will be case sensitive. Recommended and default is 0, case insensitive"},
{"default_q", CFG_VAR_INT | CFG_ATOMIC, -1, 1000, 0, 0,
"The parameter represents default q value for new contacts."}, /* Q_UNSPECIFIED is -1 */
{"append_branches", CFG_VAR_INT , 0, 0, 0, 0,
"If set to 1(default), lookup will put all contacts found in msg structure"},
{"realm_pref", CFG_VAR_STRING , 0, 0, 0, 0, "Realm prefix to be removed. Default is \"\""},
{0, 0, 0, 0, 0, 0}
};
cfg_def_t registrar_cfg_def[] =
{{"default_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0,
default_expires_stats_update,
"Contains number of second to expire if no expire hf or "
"contact expire present"},
{"default_expires_range", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0,
100, 0, default_expires_range_update,
"Percent from default_expires that will be used in "
"generating the range for the expire interval"},
{"min_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, 0,
"The minimum expires value of a Contact. Value 0 "
"disables the checking. "},
{"max_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0,
max_expires_stats_update,
"The maximum expires value of a Contact. Value 0 "
"disables the checking. "},
{"em_default_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0,
0, "The default emergency expires value of a Contact."},
{"em_max_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, 0,
"The maximum emergency expires value of a Contact. "
"Value 0 disables the checking. "},
{"em_min_expires", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 0, 0, 0,
"The maximum emergency expires value of a Contact. "
"Value 0 disables the checking. "},
{"max_contacts", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0,
"The maximum number of Contacts for an AOR. Value 0 "
"disables the checking. "},
{"retry_after", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0,
"If you want to add the Retry-After header field in "
"5xx replies, set this parameter to a value grater "
"than zero"},
{"case_sensitive", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0,
"If set to 1 then AOR comparison will be case "
"sensitive. Recommended and default is 0, case "
"insensitive"},
{"default_q", CFG_VAR_INT | CFG_ATOMIC, -1, 1000, 0, 0,
"The parameter represents default q value for new "
"contacts."}, /* Q_UNSPECIFIED is -1 */
{"append_branches", CFG_VAR_INT, 0, 0, 0, 0,
"If set to 1(default), lookup will put all contacts "
"found in msg structure"},
{"realm_pref", CFG_VAR_STRING, 0, 0, 0, 0,
"Realm prefix to be removed. Default is \"\""},
{0, 0, 0, 0, 0, 0}};
41 changes: 21 additions & 20 deletions src/modules/ims_registrar_scscf/config.h
Expand Up @@ -26,28 +26,29 @@
#include "../../core/cfg/cfg.h"
#include "../../core/str.h"

struct cfg_group_registrar {
unsigned int default_expires;
unsigned int default_expires_range;
unsigned int min_expires;
unsigned int max_expires;
unsigned int em_default_expires;
unsigned int em_max_expires;
unsigned int em_min_expires;
unsigned int max_contacts;
unsigned int retry_after;
unsigned int case_sensitive;
qvalue_t default_q;
unsigned int append_branches;
char* realm_pref;
struct cfg_group_registrar
{
unsigned int default_expires;
unsigned int default_expires_range;
unsigned int min_expires;
unsigned int max_expires;
unsigned int em_default_expires;
unsigned int em_max_expires;
unsigned int em_min_expires;
unsigned int max_contacts;
unsigned int retry_after;
unsigned int case_sensitive;
qvalue_t default_q;
unsigned int append_branches;
char *realm_pref;
};

extern struct cfg_group_registrar default_registrar_cfg;
extern void *registrar_cfg;
extern cfg_def_t registrar_cfg_def[];
extern struct cfg_group_registrar default_registrar_cfg;
extern void *registrar_cfg;
extern cfg_def_t registrar_cfg_def[];

extern void default_expires_stats_update(str*, str*);
extern void default_expires_range_update(str*, str*);
extern void max_expires_stats_update(str*, str*);
extern void default_expires_stats_update(str *, str *);
extern void default_expires_range_update(str *, str *);
extern void max_expires_stats_update(str *, str *);

#endif

0 comments on commit a840365

Please sign in to comment.