|
@@ -34,6 +34,7 @@
|
|
|
traversal for SIP signaling.
|
|
|
*/
|
|
|
|
|
|
+#include <stdbool.h>
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
|
#include <unistd.h>
|
|
@@ -98,12 +99,7 @@ MODULE_VERSION
|
|
|
#define STR_HAS_IPREFIX(str, prefix) ((str).len>(prefix).len && strncasecmp((prefix).s, (str).s, (prefix).len)==0)
|
|
|
|
|
|
|
|
|
-typedef int Bool;
|
|
|
-#define True 1
|
|
|
-#define False 0
|
|
|
-
|
|
|
-
|
|
|
-typedef Bool (*NatTestFunction)(struct sip_msg *msg);
|
|
|
+typedef bool (*NatTestFunction)(struct sip_msg *msg);
|
|
|
|
|
|
typedef enum {
|
|
|
NTNone=0,
|
|
@@ -162,7 +158,7 @@ typedef struct Dialog_Param {
|
|
|
char *caller_uri;
|
|
|
char *callee_uri;
|
|
|
time_t expire;
|
|
|
- Bool confirmed;
|
|
|
+ bool confirmed;
|
|
|
gen_lock_t lock;
|
|
|
struct {
|
|
|
char **uri;
|
|
@@ -194,9 +190,9 @@ static int NAT_Keepalive(struct sip_msg *msg);
|
|
|
static int FixContact(struct sip_msg *msg);
|
|
|
static int ClientNatTest(struct sip_msg *msg, unsigned int tests);
|
|
|
|
|
|
-static Bool test_private_contact(struct sip_msg *msg);
|
|
|
-static Bool test_source_address(struct sip_msg *msg);
|
|
|
-static Bool test_private_via(struct sip_msg *msg);
|
|
|
+static bool test_private_contact(struct sip_msg *msg);
|
|
|
+static bool test_source_address(struct sip_msg *msg);
|
|
|
+static bool test_private_via(struct sip_msg *msg);
|
|
|
|
|
|
static INLINE char* shm_strdup(char *source);
|
|
|
|
|
@@ -215,7 +211,7 @@ static int pv_get_source_uri(struct sip_msg *msg, pv_param_t *param, pv_value_t
|
|
|
//
|
|
|
static HashTable *nat_table = NULL;
|
|
|
|
|
|
-static Bool keepalive_disabled = False;
|
|
|
+static bool keepalive_disabled = false;
|
|
|
|
|
|
static unsigned int keepalive_interval = 60;
|
|
|
|
|
@@ -225,7 +221,7 @@ static Keepalive_Params keepalive_params = {"NOTIFY", NULL, "", "", 0, 0, ""};
|
|
|
|
|
|
struct tm_binds tm_api;
|
|
|
struct dlg_binds dlg_api;
|
|
|
-Bool have_dlg_api = False;
|
|
|
+bool have_dlg_api = false;
|
|
|
|
|
|
static int dialog_flag = -1;
|
|
|
static unsigned dialog_default_timeout = 12*3600; // 12 hours
|
|
@@ -466,7 +462,7 @@ NAT_Contact_del(NAT_Contact *contact)
|
|
|
}
|
|
|
|
|
|
|
|
|
-static Bool
|
|
|
+static bool
|
|
|
NAT_Contact_match(NAT_Contact *contact, const char *uri)
|
|
|
{
|
|
|
return strcmp(contact->uri, uri)==0;
|
|
@@ -674,24 +670,24 @@ Dialog_Param_del(Dialog_Param *param)
|
|
|
|
|
|
// This function assumes the caller has locked the Dialog_Param while operating on it
|
|
|
//
|
|
|
-static Bool
|
|
|
+static bool
|
|
|
Dialog_Param_has_candidate(Dialog_Param *param, char *candidate)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
|
for (i=0; i<param->callee_candidates.count; i++) {
|
|
|
if (strcmp(candidate, param->callee_candidates.uri[i])==0) {
|
|
|
- return True;
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return False;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
// This function assumes the caller has locked the Dialog_Param while operating on it
|
|
|
//
|
|
|
-static Bool
|
|
|
+static bool
|
|
|
Dialog_Param_add_candidate(Dialog_Param *param, char *candidate)
|
|
|
{
|
|
|
char **new_uri, *new_candidate;
|
|
@@ -703,7 +699,7 @@ Dialog_Param_add_candidate(Dialog_Param *param, char *candidate)
|
|
|
new_uri = shm_realloc(param->callee_candidates.uri, new_size * sizeof(char*));
|
|
|
if (!new_uri) {
|
|
|
LM_ERR("failed to grow callee_candidates uri list\n");
|
|
|
- return False;
|
|
|
+ return false;
|
|
|
}
|
|
|
param->callee_candidates.uri = new_uri;
|
|
|
param->callee_candidates.size = new_size;
|
|
@@ -712,13 +708,13 @@ Dialog_Param_add_candidate(Dialog_Param *param, char *candidate)
|
|
|
new_candidate = shm_strdup(candidate);
|
|
|
if (!new_candidate) {
|
|
|
LM_ERR("cannot allocate shared memory for new candidate uri\n");
|
|
|
- return False;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
param->callee_candidates.uri[param->callee_candidates.count] = new_candidate;
|
|
|
param->callee_candidates.count++;
|
|
|
|
|
|
- return True;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -774,30 +770,30 @@ shm_strdup(char *source)
|
|
|
}
|
|
|
|
|
|
|
|
|
-static Bool
|
|
|
+static bool
|
|
|
get_contact_uri(struct sip_msg* msg, struct sip_uri *uri, contact_t **_c)
|
|
|
{
|
|
|
|
|
|
if ((parse_headers(msg, HDR_CONTACT_F, 0) == -1) || !msg->contact)
|
|
|
- return False;
|
|
|
+ return false;
|
|
|
|
|
|
if (!msg->contact->parsed && parse_contact(msg->contact) < 0) {
|
|
|
LM_ERR("cannot parse the Contact header\n");
|
|
|
- return False;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
*_c = ((contact_body_t*)msg->contact->parsed)->contacts;
|
|
|
|
|
|
if (*_c == NULL) {
|
|
|
- return False;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
if (parse_uri((*_c)->uri.s, (*_c)->uri.len, uri) < 0 || uri->host.len <= 0) {
|
|
|
LM_ERR("cannot parse the Contact URI\n");
|
|
|
- return False;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- return True;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -828,10 +824,10 @@ rfc1918address(str *address)
|
|
|
|
|
|
|
|
|
// Test if address of signaling is different from address in 1st Via field
|
|
|
-static Bool
|
|
|
+static bool
|
|
|
test_source_address(struct sip_msg *msg)
|
|
|
{
|
|
|
- Bool different_ip, different_port;
|
|
|
+ bool different_ip, different_port;
|
|
|
int via1_port;
|
|
|
|
|
|
different_ip = received_via_test(msg);
|
|
@@ -843,21 +839,21 @@ test_source_address(struct sip_msg *msg)
|
|
|
|
|
|
|
|
|
// Test if Contact field contains a private IP address as defined in RFC1918
|
|
|
-static Bool
|
|
|
+static bool
|
|
|
test_private_contact(struct sip_msg *msg)
|
|
|
{
|
|
|
struct sip_uri uri;
|
|
|
contact_t* contact;
|
|
|
|
|
|
if (!get_contact_uri(msg, &uri, &contact))
|
|
|
- return False;
|
|
|
+ return false;
|
|
|
|
|
|
return is_private_address(&(uri.host));
|
|
|
}
|
|
|
|
|
|
|
|
|
// Test if top Via field contains a private IP address as defined in RFC1918
|
|
|
-static Bool
|
|
|
+static bool
|
|
|
test_private_via(struct sip_msg *msg)
|
|
|
{
|
|
|
return is_private_address(&(msg->via1->host));
|
|
@@ -898,7 +894,7 @@ get_register_expire(struct sip_msg *request, struct sip_msg *reply)
|
|
|
param_t *expires_param;
|
|
|
time_t now, expire=0;
|
|
|
unsigned exp;
|
|
|
- Bool matched;
|
|
|
+ bool matched;
|
|
|
|
|
|
if (!request->contact)
|
|
|
return 0;
|
|
@@ -935,7 +931,7 @@ get_register_expire(struct sip_msg *request, struct sip_msg *reply)
|
|
|
}
|
|
|
|
|
|
for (contact=contact_body->contacts; contact; contact=contact->next) {
|
|
|
- for (r_hdr=reply->contact, matched=False; r_hdr && !matched; r_hdr=next_sibling_hdr(r_hdr)) {
|
|
|
+ for (r_hdr=reply->contact, matched=false; r_hdr && !matched; r_hdr=next_sibling_hdr(r_hdr)) {
|
|
|
if (!r_hdr->parsed && parse_contact(r_hdr) < 0) {
|
|
|
LM_ERR("failed to parse the Contact header body in reply\n");
|
|
|
continue;
|
|
@@ -946,7 +942,7 @@ get_register_expire(struct sip_msg *request, struct sip_msg *reply)
|
|
|
expires_param = r_contact->expires;
|
|
|
if (expires_param && expires_param->body.len && str2int(&expires_param->body, &exp) == 0)
|
|
|
expire = max(expire, exp);
|
|
|
- matched = True;
|
|
|
+ matched = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -1092,7 +1088,7 @@ __dialog_confirmed(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params
|
|
|
|
|
|
lock_get(¶m->lock);
|
|
|
|
|
|
- param->confirmed = True;
|
|
|
+ param->confirmed = true;
|
|
|
|
|
|
callee_uri = get_source_uri(_params->rpl);
|
|
|
|
|
@@ -1684,7 +1680,7 @@ restore_keepalive_state(void)
|
|
|
|
|
|
res = fscanf(f, STATE_FILE_HEADER); // skip header
|
|
|
|
|
|
- while (True) {
|
|
|
+ while (true) {
|
|
|
res = fscanf(f, "%63s %63s %ld %ld", uri, socket, &rtime, &stime);
|
|
|
if (res == EOF) {
|
|
|
if (ferror(f))
|
|
@@ -1734,7 +1730,7 @@ mod_init(void)
|
|
|
|
|
|
if (keepalive_interval <= 0) {
|
|
|
LM_NOTICE("keepalive functionality is disabled from the configuration\n");
|
|
|
- keepalive_disabled = True;
|
|
|
+ keepalive_disabled = true;
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -1764,7 +1760,7 @@ mod_init(void)
|
|
|
param = find_param_export(find_module_by_name("dialog"),
|
|
|
"dlg_flag", INT_PARAM, &type);
|
|
|
if (param) {
|
|
|
- have_dlg_api = True;
|
|
|
+ have_dlg_api = true;
|
|
|
|
|
|
dialog_flag = *param;
|
|
|
|