瀏覽代碼

Merge branch 'master' of ssh://git.sip-router.org/sip-router

Carsten Bock 13 年之前
父節點
當前提交
97e03b52f1

+ 41 - 2
Makefile.defs

@@ -162,7 +162,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
 VERSION = 3
 VERSION = 3
 PATCHLEVEL = 4
 PATCHLEVEL = 4
 SUBLEVEL =  0
 SUBLEVEL =  0
-EXTRAVERSION = -dev3
+EXTRAVERSION = -dev4
 
 
 # memory debugger switcher
 # memory debugger switcher
 # 0 - off (release mode)
 # 0 - off (release mode)
@@ -321,6 +321,14 @@ ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
 	MKDEP=$(CC) -MM 
 	MKDEP=$(CC) -MM 
 endif
 endif
 
 
+ifneq (, $(findstring clang, $(CC_LONGVER)))
+	#clang should be gcc compatible
+	CC_NAME=clang
+	CC_FULLVER:=$(shell echo "$(CC_LONGVER)" | head -n 1 |  sed -e 's/.*version \([0-9]\.[0-9]\).*/\1/g' )
+	CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
+	CC_VER=$(CC) $(CC_FULLVER)
+	MKDEP=$(CC) -MM 
+endif
 
 
 ifeq (,$(CC_NAME))
 ifeq (,$(CC_NAME))
 #not found
 #not found
@@ -866,7 +874,7 @@ ifeq ($(mode), release)
 	#if i386
 	#if i386
 ifeq	($(ARCH), i386)
 ifeq	($(ARCH), i386)
 		# if gcc 
 		# if gcc 
-ifeq		($(CC_NAME), gcc)
+ifeq		($(CC_NAME), gcc) 
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
 				#common stuff
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
@@ -923,6 +931,15 @@ endif			# CC_SHORTVER, 4.x
 endif			# CC_SHORTVER, 4.5+ or 4.2+
 endif			# CC_SHORTVER, 4.5+ or 4.2+
 
 
 else		# CC_NAME, gcc
 else		# CC_NAME, gcc
+ifeq		($(CC_NAME), clang)
+$(call                          set_if_empty,CPU,athlon64)
+					C_DEFS+=-DCC_GCC_LIKE_ASM
+                                        CFLAGS+=-m32
+                                                         \
+                                                         \
+                                                        -mtune=$(CPU)
+                                        LDFLAGS+=-m32
+else			# CC_NAME, clang
 ifeq		($(CC_NAME), icc)
 ifeq		($(CC_NAME), icc)
 			C_DEFS+=-DCC_GCC_LIKE_ASM
 			C_DEFS+=-DCC_GCC_LIKE_ASM
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
@@ -935,6 +952,7 @@ else
 				#other compilers
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, icc
 endif		#CC_NAME, icc
+endif		#CC_NAME, clang
 endif		#CC_NAME, gcc
 endif		#CC_NAME, gcc
 endif	#ARCH, i386
 endif	#ARCH, i386
 
 
@@ -1009,6 +1027,13 @@ endif			# CC_SHORTVER, 4.2+
 endif			# CC_SHORTVER, 4.5+
 endif			# CC_SHORTVER, 4.5+
 
 
 else		# CC_NAME, gcc
 else		# CC_NAME, gcc
+ifeq            ($(CC_NAME), clang)
+$(call                          set_if_empty,CPU,opteron)
+					C_DEFS+=-DCC_GCC_LIKE_ASM
+                                        CFLAGS+=-m64 \
+                                                        
+                                        LDFLAGS+=-m64
+else      	# CC_NAME, clang
 ifeq		($(CC_NAME), icc)
 ifeq		($(CC_NAME), icc)
 			C_DEFS+=-DCC_GCC_LIKE_ASM
 			C_DEFS+=-DCC_GCC_LIKE_ASM
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
@@ -1021,6 +1046,7 @@ else
 				#other compilers
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, icc
 endif		#CC_NAME, icc
+endif		#CC_NAME, clang
 endif		#CC_NAME, gcc
 endif		#CC_NAME, gcc
 endif	#ARCH, x86_64
 endif	#ARCH, x86_64
 
 
@@ -1597,6 +1623,14 @@ endif
 	# the executable file, because it's always loaded at a fixed address
 	# the executable file, because it's always loaded at a fixed address
 	# -andrei
 	# -andrei
 
 
+ifeq ($(CC_NAME), clang)
+	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
+        MOD_LDFLAGS:=-shared $(LDFLAGS)
+        LIB_LDFLAGS:=-shared $(LDFLAGS)
+        LIB_SONAME=-Wl,-soname,
+        LD_RPATH=-Wl,-rpath,
+endif
+
 LDFLAGS+= $(LD_EXTRA_OPTS)
 LDFLAGS+= $(LD_EXTRA_OPTS)
 MOD_LDFLAGS+= $(LD_EXTRA_OPTS)
 MOD_LDFLAGS+= $(LD_EXTRA_OPTS)
 LIB_LDFLAGS+= $(LD_EXTRA_OPTS)
 LIB_LDFLAGS+= $(LD_EXTRA_OPTS)
@@ -1674,6 +1708,11 @@ ifeq	($(CC_NAME), suncc)
 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
 LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
 LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
 endif
 endif
+ifeq    ($(CC_NAME), clang)
+MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
+LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
+endif
+
 UTILS_CFLAGS=$(CFLAGS)
 UTILS_CFLAGS=$(CFLAGS)
 # LDFLAGS uses for compiling the utils
 # LDFLAGS uses for compiling the utils
 UTILS_LDFLAGS=$(LDFLAGS)
 UTILS_LDFLAGS=$(LDFLAGS)

+ 3 - 1
cfg.y

@@ -853,7 +853,9 @@ assign_stm:
 	| FORK  EQUAL error  { yyerror("boolean value expected"); }
 	| FORK  EQUAL error  { yyerror("boolean value expected"); }
 	| FORK_DELAY  EQUAL NUMBER { set_fork_delay($3); }
 	| FORK_DELAY  EQUAL NUMBER { set_fork_delay($3); }
 	| FORK_DELAY  EQUAL error  { yyerror("number expected"); }
 	| FORK_DELAY  EQUAL error  { yyerror("number expected"); }
-	| LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
+	| LOGSTDERROR EQUAL NUMBER { if (!config_check)  /* if set from cmd line, don't overwrite from yyparse()*/ 
+					if(log_stderr == 0) log_stderr=$3; 
+				   }
 	| LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
 	| LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
 	| LOGFACILITY EQUAL ID {
 	| LOGFACILITY EQUAL ID {
 		if ( (i_tmp=str2facility($3))==-1)
 		if ( (i_tmp=str2facility($3))==-1)

+ 7 - 7
lib/kcore/parse_sst.c

@@ -37,17 +37,17 @@
 #include "../../mem/mem.h"
 #include "../../mem/mem.h"
 
 
 
 
-inline int/*bool*/  is_space( char c ) { return (c == ' ' || c == '\t'); }
-inline int/*bool*/  is_num( char c ) { return (c >= '0' && c <= '9'); }
+static inline int/*bool*/  is_space( char c ) { return (c == ' ' || c == '\t'); }
+static inline int/*bool*/  is_num( char c ) { return (c >= '0' && c <= '9'); }
 
 
-inline unsigned  lower_byte( char b ) { return b | 0x20; }
-inline unsigned  lower_4bytes( unsigned d ) { return d | 0x20202020; }
-inline unsigned  lower_3bytes( unsigned d ) { return d |   0x202020; }
-inline unsigned  read_4bytes( char *val ) {
+static inline unsigned  lower_byte( char b ) { return b | 0x20; }
+static inline unsigned  lower_4bytes( unsigned d ) { return d | 0x20202020; }
+static inline unsigned  lower_3bytes( unsigned d ) { return d |   0x202020; }
+static inline unsigned  read_4bytes( char *val ) {
 	return (*(val + 0) + (*(val + 1) << 8)
 	return (*(val + 0) + (*(val + 1) << 8)
 		+ (*(val + 2) << 16) + (*(val + 3) << 24));
 		+ (*(val + 2) << 16) + (*(val + 3) << 24));
 }
 }
-inline unsigned  read_3bytes( char *val ) {
+static inline unsigned  read_3bytes( char *val ) {
 	return (*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16));
 	return (*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16));
 }
 }
 
 

+ 6 - 6
lib/srdb1/db_res.h

@@ -85,7 +85,7 @@ typedef struct db1_res {
  * \param _r the result that should be released
  * \param _r the result that should be released
  * \return zero on success, negative on errors
  * \return zero on success, negative on errors
  */
  */
-inline int db_free_rows(db1_res_t* _r);
+extern inline int db_free_rows(db1_res_t* _r);
 
 
 
 
 /**
 /**
@@ -95,20 +95,20 @@ inline int db_free_rows(db1_res_t* _r);
  * \param _r the result that should be released
  * \param _r the result that should be released
  * \return zero on success, negative on errors
  * \return zero on success, negative on errors
  */
  */
-inline int db_free_columns(db1_res_t* _r);
+extern inline int db_free_columns(db1_res_t* _r);
 
 
 
 
 /**
 /**
  * Create a new result structure and initialize it.
  * Create a new result structure and initialize it.
  * \return a pointer to the new result on success, NULL on errors
  * \return a pointer to the new result on success, NULL on errors
  */
  */
-inline db1_res_t* db_new_result(void);
+extern inline db1_res_t* db_new_result(void);
 
 
 /**
 /**
  * Release memory used by a result structure.
  * Release memory used by a result structure.
  * \return zero on success, negative on errors
  * \return zero on success, negative on errors
  */
  */
-inline int db_free_result(db1_res_t* _r);
+extern inline int db_free_result(db1_res_t* _r);
 
 
 /**
 /**
  * Allocate storage for column names and type in existing result structure.
  * Allocate storage for column names and type in existing result structure.
@@ -118,7 +118,7 @@ inline int db_free_result(db1_res_t* _r);
  * \param cols number of columns
  * \param cols number of columns
  * \return zero on success, negative on errors
  * \return zero on success, negative on errors
  */
  */
-inline int db_allocate_columns(db1_res_t* _r, const unsigned int cols);
+extern inline int db_allocate_columns(db1_res_t* _r, const unsigned int cols);
 
 
 
 
 /**
 /**
@@ -126,6 +126,6 @@ inline int db_allocate_columns(db1_res_t* _r, const unsigned int cols);
  * \param _res result set
  * \param _res result set
  * \return zero on success, negative on errors
  * \return zero on success, negative on errors
  */
  */
-inline int db_allocate_rows(db1_res_t* _res);
+extern inline int db_allocate_rows(db1_res_t* _res);
 
 
 #endif /* DB1_RES_H */
 #endif /* DB1_RES_H */

+ 2 - 2
lib/srdb1/db_row.h

@@ -62,7 +62,7 @@ typedef struct db_row {
  * \param _r row that should be released
  * \param _r row that should be released
  * \return zero on success, negative on error
  * \return zero on success, negative on error
  */
  */
-inline int db_free_row(db_row_t* _r);
+extern inline int db_free_row(db_row_t* _r);
 
 
 
 
 /**
 /**
@@ -71,6 +71,6 @@ inline int db_free_row(db_row_t* _r);
  * \param _row filled row
  * \param _row filled row
  * \return zero on success, negative on errors
  * \return zero on success, negative on errors
  */
  */
-inline int db_allocate_row(const db1_res_t* _res, db_row_t* _row);
+extern inline int db_allocate_row(const db1_res_t* _res, db_row_t* _row);
 
 
 #endif /* DB1_ROW_H */
 #endif /* DB1_ROW_H */

+ 5 - 1
lib/srdb1/schema/location.xml

@@ -80,7 +80,7 @@
         <description>Path Header(s) per RFC 3327</description>
         <description>Path Header(s) per RFC 3327</description>
     </column>
     </column>
 
 
-    <column>
+    <column id="expires">
         <name>expires</name>
         <name>expires</name>
         <type>datetime</type>
         <type>datetime</type>
         <default>&DEFAULT_ALIASES_EXPIRES;</default>
         <default>&DEFAULT_ALIASES_EXPIRES;</default>
@@ -191,6 +191,10 @@
         <colref linkend="ruid"/>
         <colref linkend="ruid"/>
         <unique/>
         <unique/>
     </index>
     </index>
+    <index>
+        <name>expires_idx</name>
+        <colref linkend="expires"/>
+    </index>
 
 
 
 
 </table>
 </table>

+ 48 - 20
modules/corex/README

@@ -23,18 +23,23 @@ Daniel-Constantin Mierla
               2.1. Kamailio Modules
               2.1. Kamailio Modules
               2.2. External Libraries or Applications
               2.2. External Libraries or Applications
 
 
-        3. Functions
+        3. Parameters
 
 
-              3.1. append_branch([ uri, [ q ] ])
+              3.1. alias_subdomains (string)
 
 
-        4. RPC Commands
+        4. Functions
 
 
-              4.1. corex.list_sockets
-              4.2. corex.list_aliases
+              4.1. append_branch([ uri, [ q ] ])
+
+        5. RPC Commands
+
+              5.1. corex.list_sockets
+              5.2. corex.list_aliases
 
 
    List of Examples
    List of Examples
 
 
-   1.1. append_branch usage
+   1.1. Set alias_subdomains parameter
+   1.2. append_branch usage
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -46,14 +51,18 @@ Chapter 1. Admin Guide
         2.1. Kamailio Modules
         2.1. Kamailio Modules
         2.2. External Libraries or Applications
         2.2. External Libraries or Applications
 
 
-   3. Functions
+   3. Parameters
+
+        3.1. alias_subdomains (string)
 
 
-        3.1. append_branch([ uri, [ q ] ])
+   4. Functions
 
 
-   4. RPC Commands
+        4.1. append_branch([ uri, [ q ] ])
 
 
-        4.1. corex.list_sockets
-        4.2. corex.list_aliases
+   5. RPC Commands
+
+        5.1. corex.list_sockets
+        5.2. corex.list_aliases
 
 
 1. Overview
 1. Overview
 
 
@@ -84,11 +93,30 @@ Chapter 1. Admin Guide
    running Kamailio with this module loaded:
    running Kamailio with this module loaded:
      * None
      * None
 
 
-3. Functions
+3. Parameters
+
+   3.1. alias_subdomains (string)
+
+3.1. alias_subdomains (string)
+
+   Register a domain and all its sub-domains to match the myself
+   condition. It can be set many times. Its full format is:
+   'proto:domain:port', allowing to set restrictions on protocol and port
+   as well. Protocol and port are optional.
+
+   Default value is "NULL".
+
+   Example 1.1. Set alias_subdomains parameter
+...
+modparam("corex", "alias_subdomain", "kamailio.org")
+modparam("corex", "alias_subdomain", "udp:sip-router.org:5060")
+...
+
+4. Functions
 
 
-   3.1. append_branch([ uri, [ q ] ])
+   4.1. append_branch([ uri, [ q ] ])
 
 
-3.1. append_branch([ uri, [ q ] ])
+4.1. append_branch([ uri, [ q ] ])
 
 
    Append a new branch to the destination set, useful to build the
    Append a new branch to the destination set, useful to build the
    addresses for parallel forking or redirect replies.
    addresses for parallel forking or redirect replies.
@@ -104,25 +132,25 @@ Chapter 1. Admin Guide
 
 
    This function can be used from REQUEST_ROUTE or FAILURE_ROUTE.
    This function can be used from REQUEST_ROUTE or FAILURE_ROUTE.
 
 
-   Example 1.1. append_branch usage
+   Example 1.2. append_branch usage
 ...
 ...
     append_branch();
     append_branch();
     append_branch("$avp(uri)", "0.5");
     append_branch("$avp(uri)", "0.5");
 ...
 ...
 
 
-4. RPC Commands
+5. RPC Commands
 
 
-   4.1. corex.list_sockets
-   4.2. corex.list_aliases
+   5.1. corex.list_sockets
+   5.2. corex.list_aliases
 
 
-4.1. corex.list_sockets
+5.1. corex.list_sockets
 
 
    Print the list of sockets the application is listening on.
    Print the list of sockets the application is listening on.
 
 
    Example:
    Example:
                 sercmd corex.list_sockets
                 sercmd corex.list_sockets
 
 
-4.2. corex.list_aliases
+5.2. corex.list_aliases
 
 
    Print the list of hostname aliases used to match myself condition.
    Print the list of hostname aliases used to match myself condition.
 
 

+ 123 - 0
modules/corex/corex_lib.c

@@ -26,6 +26,7 @@
 
 
 #include "../../dprint.h"
 #include "../../dprint.h"
 #include "../../dset.h"
 #include "../../dset.h"
+#include "../../forward.h"
 
 
 #include "corex_lib.h"
 #include "corex_lib.h"
 
 
@@ -88,3 +89,125 @@ int corex_append_branch(sip_msg_t *msg, gparam_t *pu, gparam_t *pq)
 
 
 	return ret;
 	return ret;
 }
 }
+
+typedef struct corex_alias {
+	str alias;
+	unsigned short port;
+	unsigned short proto;
+	int flags;
+	struct corex_alias* next;
+} corex_alias_t;
+
+static corex_alias_t *_corex_alias_list = NULL;
+
+int corex_add_alias_subdomains(char* aliasval)
+{
+	char *p = NULL;
+	corex_alias_t ta;
+	corex_alias_t *na;
+
+	memset(&ta, 0, sizeof(corex_alias_t));
+
+	p = strchr(aliasval, ':');
+	if(p==NULL) {
+		/* only hostname */
+		ta.alias.s = aliasval;
+		ta.alias.len = strlen(aliasval);
+		goto done;
+	}
+	if((p-aliasval)==3 || (p-aliasval)==4) {
+		/* check if it is protocol */
+		if((p-aliasval)==3 && strncasecmp(aliasval, "udp", 3)==0) {
+			ta.proto = PROTO_UDP;
+		} else if((p-aliasval)==3 && strncasecmp(aliasval, "tcp", 3)==0) {
+			ta.proto = PROTO_TCP;
+		} else if((p-aliasval)==3 && strncasecmp(aliasval, "tls", 3)==0) {
+			ta.proto = PROTO_TLS;
+		} else if((p-aliasval)==4 && strncasecmp(aliasval, "sctp", 4)==0) {
+			ta.proto = PROTO_SCTP;
+		} else {
+			/* use hostname */
+			ta.alias.s = aliasval;
+			ta.alias.len = p - aliasval;
+		}
+	}
+	if(ta.alias.len==0) {
+		p++;
+		if(p>=aliasval+strlen(aliasval))
+			goto error;
+		ta.alias.s = p;
+		p = strchr(ta.alias.s, ':');
+		if(p==NULL) {
+			ta.alias.len = strlen(ta.alias.s);
+			goto done;
+		}
+	}
+	/* port */
+	p++;
+	if(p>=aliasval+strlen(aliasval))
+		goto error;
+	ta.port = str2s(p, strlen(p), NULL);
+
+done:
+	if(ta.alias.len==0)
+		goto error;
+
+	na = (corex_alias_t*)pkg_malloc(sizeof(corex_alias_t));
+	if(na==NULL) {
+		LM_ERR("no memory for adding alias subdomains: %s\n", aliasval);
+		return -1;
+	}
+	memcpy(na, &ta, sizeof(corex_alias_t));
+	na->next = _corex_alias_list;
+	_corex_alias_list = na;
+
+	return 0;
+
+error:
+	LM_ERR("error adding alias subdomains: %s\n", aliasval);
+	return -1;
+}
+
+
+int corex_check_self(str* host, unsigned short port, unsigned short proto)
+{
+	corex_alias_t *ta;
+
+	for(ta=_corex_alias_list; ta; ta=ta->next) {
+		if(host->len<ta->alias.len)
+			continue;
+		if(ta->port!=0 && port!=0 && ta->port!=port)
+			continue;
+		if(ta->proto!=0 && proto!=0 && ta->proto!=proto)
+			continue;
+		if(host->len==ta->alias.len
+				&& strncasecmp(host->s, ta->alias.s, host->len)==0) {
+			/* match domain */
+			LM_DBG("check self domain match: %d:%.*s:%d\n", (int)ta->port,
+					ta->alias.len, ta->alias.s, (int)ta->proto);
+			return 1;
+		}
+		if(strncasecmp(ta->alias.s, host->s + host->len - ta->alias.len,
+					ta->alias.len)==0) {
+			if(host->s[host->len - ta->alias.len - 1]=='.') {
+				/* match sub-domain */
+				LM_DBG("check self sub-domain match: %d:%.*s:%d\n", (int)ta->port,
+					ta->alias.len, ta->alias.s, (int)ta->proto);
+				return 1;
+			}
+		}
+	}
+
+	return 0; /* no match */
+}
+
+int corex_register_check_self(void)
+{
+	if(_corex_alias_list==NULL)
+		return 0;
+	if (register_check_self_func(corex_check_self) <0 ) {
+	    LM_ERR("failed to register check self function\n");
+	    return -1;
+	}
+	return 0;
+}

+ 4 - 0
modules/corex/corex_lib.h

@@ -26,4 +26,8 @@
 
 
 int corex_append_branch(sip_msg_t *msg, gparam_t *pu, gparam_t *pq);
 int corex_append_branch(sip_msg_t *msg, gparam_t *pu, gparam_t *pq);
 
 
+int corex_add_alias_subdomains(char* aliasval);
+
+int corex_register_check_self(void);
+
 #endif
 #endif

+ 22 - 0
modules/corex/corex_mod.c

@@ -35,6 +35,8 @@ MODULE_VERSION
 
 
 static int w_append_branch(sip_msg_t *msg, char *su, char *sq);
 static int w_append_branch(sip_msg_t *msg, char *su, char *sq);
 
 
+int corex_alias_subdomains_param(modparam_t type, void *val);
+
 static int  mod_init(void);
 static int  mod_init(void);
 static int  child_init(int);
 static int  child_init(int);
 static void mod_destroy(void);
 static void mod_destroy(void);
@@ -52,6 +54,8 @@ static cmd_export_t cmds[]={
 };
 };
 
 
 static param_export_t params[]={
 static param_export_t params[]={
+	{"alias_subdomains",  STR_PARAM|USE_FUNC_PARAM,
+								(void*)corex_alias_subdomains_param},
 	{0, 0, 0}
 	{0, 0, 0}
 };
 };
 
 
@@ -83,6 +87,12 @@ static int mod_init(void)
 		return -1;
 		return -1;
 	}
 	}
 
 
+	if(corex_register_check_self()<0)
+	{
+		LM_ERR("failed to register check self callback\n");
+		return -1;
+	}
+
 	return 0;
 	return 0;
 }
 }
 
 
@@ -113,3 +123,15 @@ static int w_append_branch(sip_msg_t *msg, char *su, char *sq)
 	return 1;
 	return 1;
 }
 }
 
 
+
+int corex_alias_subdomains_param(modparam_t type, void *val)
+{
+	if(val==NULL)
+		goto error;
+
+	return corex_add_alias_subdomains((char*)val);
+error:
+	return -1;
+
+}
+

+ 28 - 0
modules/corex/doc/corex_admin.xml

@@ -61,6 +61,34 @@
 		</para>
 		</para>
 	</section>
 	</section>
 	</section>
 	</section>
+
+    <section>
+	<title>Parameters</title>
+	<section>
+	    <title><varname>alias_subdomains</varname> (string)</title>
+	    <para>
+		Register a domain and all its sub-domains to match the myself
+		condition. It can be set many times. Its full format is:
+		'proto:domain:port', allowing to set restrictions on protocol
+		and port as well. Protocol and port are optional.
+	    </para>
+	    <para>
+		<emphasis>
+		    Default value is <quote>NULL</quote>.
+		</emphasis>
+	    </para>
+	    <example>
+		<title>Set <varname>alias_subdomains</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("corex", "alias_subdomain", "kamailio.org")
+modparam("corex", "alias_subdomain", "udp:sip-router.org:5060")
+...
+</programlisting>
+	    </example>
+	</section>
+	</section>
+
 	<section>
 	<section>
 	<title>Functions</title>
 	<title>Functions</title>
 	<section>
 	<section>

+ 1 - 1
modules/ctl/binrpc_run.c

@@ -384,7 +384,7 @@ end:
 
 
 
 
 
 
-inline void destroy_binrpc_ctx(struct binrpc_ctx* ctx)
+static inline void destroy_binrpc_ctx(struct binrpc_ctx* ctx)
 {
 {
 	free_structs(&ctx->out.structs);
 	free_structs(&ctx->out.structs);
 	if (ctx->out.pkt.body){
 	if (ctx->out.pkt.body){

+ 2 - 2
modules_k/benchmark/benchmark.h

@@ -88,8 +88,8 @@ inline unsigned long long bm_diff_time(bm_timeval_t *t1, bm_timeval_t *t2)
 {
 {
 	unsigned long long tdiff;
 	unsigned long long tdiff;
 
 
-	tdiff = t1->tv_sec - t1->tv_sec;
-	
+	tdiff = t2->tv_sec - t1->tv_sec;
+
 #ifdef BM_CLOCK_REALTIME
 #ifdef BM_CLOCK_REALTIME
 	tdiff = tdiff*1000000000 + t2->tv_nsec - t1->tv_nsec;
 	tdiff = tdiff*1000000000 + t2->tv_nsec - t1->tv_nsec;
 #else
 #else

+ 8 - 2
modules_k/rls/rls_db.c

@@ -884,8 +884,8 @@ int get_dialog_subscribe_rlsdb(subs_t *subs)
 
 
 subs_t *get_dialog_notify_rlsdb(str callid, str to_tag, str from_tag) 
 subs_t *get_dialog_notify_rlsdb(str callid, str to_tag, str from_tag) 
 {
 {
- 	db_key_t query_cols[3];
-	db_val_t query_vals[3];
+ 	db_key_t query_cols[4];
+	db_val_t query_vals[4];
 	db_key_t result_cols[22];
 	db_key_t result_cols[22];
 	int n_query_cols = 0, n_result_cols=0;
 	int n_query_cols = 0, n_result_cols=0;
 	int r_pres_uri_col,r_to_user_col,r_to_domain_col;
 	int r_pres_uri_col,r_to_user_col,r_to_domain_col;
@@ -934,6 +934,12 @@ subs_t *get_dialog_notify_rlsdb(str callid, str to_tag, str from_tag)
 	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].val.str_val= from_tag;
 	query_vals[n_query_cols].val.str_val= from_tag;
 	n_query_cols++;
 	n_query_cols++;
+
+	query_cols[n_query_cols] = &str_updated_col;
+	query_vals[n_query_cols].type = DB1_INT;
+	query_vals[n_query_cols].nul = 0;
+	query_vals[n_query_cols].val.int_val= NO_UPDATE_TYPE;
+	n_query_cols++;
 	
 	
 	result_cols[r_pres_uri_col=n_result_cols++] = &str_presentity_uri_col;
 	result_cols[r_pres_uri_col=n_result_cols++] = &str_presentity_uri_col;
 	result_cols[r_to_user_col=n_result_cols++] = &str_to_user_col;
 	result_cols[r_to_user_col=n_result_cols++] = &str_to_user_col;

+ 2 - 4
modules_k/rls/subscribe.c

@@ -1102,15 +1102,13 @@ int resource_subscriptions(subs_t* subs, xmlNodePtr xmlnode)
 		{
 		{
 			LM_DBG("Removing subscription for %.*s\n", tmp_str->len, tmp_str->s);
 			LM_DBG("Removing subscription for %.*s\n", tmp_str->len, tmp_str->s);
 			s.expires = 0;
 			s.expires = 0;
-			send_resource_subs(tmp_str->s, (void*)(&s));
+			send_resource_subs(tmp_str->s, params);
 			pkg_free(tmp_str->s);
 			pkg_free(tmp_str->s);
 			pkg_free(tmp_str);
 			pkg_free(tmp_str);
 		}
 		}
 	}
 	}
-	else
-	{
+	if (rls_contact_list != NULL)
 		list_free(&rls_contact_list);
 		list_free(&rls_contact_list);
-	}
 
 
 	pkg_free(wuri.s);
 	pkg_free(wuri.s);
 	pkg_free(did_str.s);
 	pkg_free(did_str.s);

+ 2 - 2
modules_k/usrloc/dlist.c

@@ -223,12 +223,12 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
 			} else {
 			} else {
 				if (parse_phostport( p, &host.s, &host.len,
 				if (parse_phostport( p, &host.s, &host.len,
 				&port, &proto)!=0) {
 				&port, &proto)!=0) {
-					LM_ERR("bad socket <%s>...ignoring\n", p);
+					LM_ERR("bad socket <%s>...set to 0\n", p);
 					sock = 0;
 					sock = 0;
 				} else {
 				} else {
 					sock = grep_sock_info( &host, (unsigned short)port, proto);
 					sock = grep_sock_info( &host, (unsigned short)port, proto);
 					if (sock==0) {
 					if (sock==0) {
-						LM_WARN("non-local socket <%s>...ignoring\n", p);
+						LM_DBG("non-local socket <%s>...set to 0\n", p);
 					}
 					}
 				}
 				}
 			}
 			}

+ 1 - 1
parser/parse_param.h

@@ -150,7 +150,7 @@ typedef union param_hooks {
  * 	0: success, but expect a next paramter
  * 	0: success, but expect a next paramter
  * 	1: success and exepect no more parameters
  * 	1: success and exepect no more parameters
  */
  */
-inline int parse_param(str *_s, pclass_t _c, param_hooks_t *_h, param_t *t);
+extern inline int parse_param(str *_s, pclass_t _c, param_hooks_t *_h, param_t *t);
 
 
 
 
 /*! \brief
 /*! \brief

+ 8 - 3
pkg/kamailio/fedora/16/kamailio.spec

@@ -1,6 +1,6 @@
 %define name    kamailio
 %define name    kamailio
 %define ver     3.4.0
 %define ver     3.4.0
-%define rel     dev3%{dist}
+%define rel     dev4%{dist}
 
 
 
 
 
 
@@ -364,14 +364,14 @@ make every-module skip_modules="auth_identity db_cassandra iptrtpproxy\
 	kpostgres kunixodbc kldap kperl kpython klua kutils kpurple ktls kxmpp\
 	kpostgres kunixodbc kldap kperl kpython klua kutils kpurple ktls kxmpp\
 	kcpl ksnmpstats kcarrierroute kpresence kradius kgeoip kregex kdialplan\
 	kcpl ksnmpstats kcarrierroute kpresence kradius kgeoip kregex kdialplan\
 	klcr ksqlite kredis kjson kmono kberkeley kwebsocket"\
 	klcr ksqlite kredis kjson kmono kberkeley kwebsocket"\
-	include_modules="xmlrpc xmlops cdp cdp_avp"
+	include_modules="xmlrpc xmlops cdp cdp_avp corex"
 %else
 %else
 make every-module skip_modules="auth_identity db_cassandra iptrtpproxy\
 make every-module skip_modules="auth_identity db_cassandra iptrtpproxy\
 	db_oracle memcached mi_xmlrpc osp" group_include="kstandard kmysql\
 	db_oracle memcached mi_xmlrpc osp" group_include="kstandard kmysql\
 	kpostgres kunixodbc kldap kperl kpython klua kutils kpurple ktls kxmpp\
 	kpostgres kunixodbc kldap kperl kpython klua kutils kpurple ktls kxmpp\
 	kcpl ksnmpstats kpresence kregex kdialplan\
 	kcpl ksnmpstats kpresence kregex kdialplan\
 	klcr ksqlite kberkeley kwebsocket"\
 	klcr ksqlite kberkeley kwebsocket"\
-	include_modules="xmlrpc xmlops cdp cdp_avp"
+	include_modules="xmlrpc xmlops cdp cdp_avp corex"
 %endif
 %endif
 
 
 
 
@@ -471,6 +471,7 @@ fi
 %doc %{_docdir}/kamailio/modules/README.blst
 %doc %{_docdir}/kamailio/modules/README.blst
 %doc %{_docdir}/kamailio/modules/README.cfg_db
 %doc %{_docdir}/kamailio/modules/README.cfg_db
 %doc %{_docdir}/kamailio/modules/README.cfg_rpc
 %doc %{_docdir}/kamailio/modules/README.cfg_rpc
+%doc %{_docdir}/kamailio/modules/README.corex
 %doc %{_docdir}/kamailio/modules/README.counters
 %doc %{_docdir}/kamailio/modules/README.counters
 %doc %{_docdir}/kamailio/modules/README.ctl
 %doc %{_docdir}/kamailio/modules/README.ctl
 %doc %{_docdir}/kamailio/modules/README.db_flatstore
 %doc %{_docdir}/kamailio/modules/README.db_flatstore
@@ -594,6 +595,7 @@ fi
 %{_libdir}/kamailio/modules/blst.so
 %{_libdir}/kamailio/modules/blst.so
 %{_libdir}/kamailio/modules/cfg_db.so
 %{_libdir}/kamailio/modules/cfg_db.so
 %{_libdir}/kamailio/modules/cfg_rpc.so
 %{_libdir}/kamailio/modules/cfg_rpc.so
+%{_libdir}/kamailio/modules/corex.so
 %{_libdir}/kamailio/modules/counters.so
 %{_libdir}/kamailio/modules/counters.so
 %{_libdir}/kamailio/modules/ctl.so
 %{_libdir}/kamailio/modules/ctl.so
 %{_libdir}/kamailio/modules/db_flatstore.so
 %{_libdir}/kamailio/modules/db_flatstore.so
@@ -976,6 +978,9 @@ fi
 
 
 
 
 %changelog
 %changelog
+* Sun Sep 17 2012 Peter Dunkley <[email protected]>
+  - Added corex module to RPM builds
+  - Updated rel to dev4
 * Sun Aug 19 2012 Peter Dunkley <[email protected]>
 * Sun Aug 19 2012 Peter Dunkley <[email protected]>
   - Updated rel to dev3
   - Updated rel to dev3
 * Fri Jul 13 2012 Peter Dunkley <[email protected]>
 * Fri Jul 13 2012 Peter Dunkley <[email protected]>

+ 1 - 1
raw_sock.c

@@ -391,7 +391,7 @@ error:
  *                 in _host_ order.
  *                 in _host_ order.
  * @return the partial checksum in host order
  * @return the partial checksum in host order
  */
  */
-inline unsigned short udpv4_vhdr_sum(	struct udphdr* uh,
+static inline unsigned short udpv4_vhdr_sum(	struct udphdr* uh,
 										struct in_addr* src,
 										struct in_addr* src,
 										struct in_addr* dst,
 										struct in_addr* dst,
 										unsigned short length)
 										unsigned short length)

+ 1 - 1
sip_msg_clone.c

@@ -150,7 +150,7 @@ do { \
 
 
 
 
 
 
-inline struct via_body* via_body_cloner( char* new_buf,
+static inline struct via_body* via_body_cloner( char* new_buf,
 					char *org_buf, struct via_body *param_org_via, char **p)
 					char *org_buf, struct via_body *param_org_via, char **p)
 {
 {
 	struct via_body *new_via;
 	struct via_body *new_via;

+ 1 - 0
utils/kamctl/db_sqlite/usrloc-create.sql

@@ -23,4 +23,5 @@ CREATE TABLE location (
 );
 );
 
 
 CREATE INDEX location_account_contact_idx ON location (username, domain, contact);
 CREATE INDEX location_account_contact_idx ON location (username, domain, contact);
+CREATE INDEX location_expires_idx ON location (expires);
 
 

+ 1 - 0
utils/kamctl/mysql/usrloc-create.sql

@@ -23,4 +23,5 @@ CREATE TABLE location (
 ) ENGINE=MyISAM;
 ) ENGINE=MyISAM;
 
 
 CREATE INDEX account_contact_idx ON location (username, domain, contact);
 CREATE INDEX account_contact_idx ON location (username, domain, contact);
+CREATE INDEX expires_idx ON location (expires);
 
 

+ 1 - 0
utils/kamctl/oracle/usrloc-create.sql

@@ -31,4 +31,5 @@ END location_tr;
 BEGIN map2users('location'); END;
 BEGIN map2users('location'); END;
 /
 /
 CREATE INDEX location_account_contact_idx  ON location (username, domain, contact);
 CREATE INDEX location_account_contact_idx  ON location (username, domain, contact);
+CREATE INDEX location_expires_idx  ON location (expires);
 
 

+ 1 - 0
utils/kamctl/postgres/usrloc-create.sql

@@ -23,4 +23,5 @@ CREATE TABLE location (
 );
 );
 
 
 CREATE INDEX location_account_contact_idx ON location (username, domain, contact);
 CREATE INDEX location_account_contact_idx ON location (username, domain, contact);
+CREATE INDEX location_expires_idx ON location (expires);