Skip to content

Commit f85308c

Browse files
authored
Merge branch 'OpenSIPS:master' into master
2 parents 92dce86 + 39cd732 commit f85308c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3129
-862
lines changed

Makefile.defs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ MAIN_NAME=opensips
6565

6666
#version number
6767
VERSION_MAJOR = 3
68-
VERSION_MINOR = 6
68+
VERSION_MINOR = 7
6969
VERSION_SUBMINOR = 0
7070
VERSION_BUILD = dev
7171

cfg.lex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ CR \n
342342
343343
ANY "any"
344344
ANYCAST ("anycast"|"ANYCAST")
345+
ACCEPT_SUBDOMAIN ("accept_subdomain"|"ACCEPT_SUBDOMAIN")
345346
FRAG ("frag"|"FRAG")
346347
REUSE_PORT ("reuse_port"|"REUSE_PORT")
347348
@@ -617,6 +618,7 @@ SPACE [ ]
617618
<INITIAL>{CR} { count();/* return CR;*/ }
618619
<INITIAL>{ANY} { count(); return ANY; }
619620
<INITIAL>{ANYCAST} { count(); return ANYCAST; }
621+
<INITIAL>{ACCEPT_SUBDOMAIN} { count(); return ACCEPT_SUBDOMAIN; }
620622
<INITIAL>{REUSE_PORT} { count(); return REUSE_PORT; }
621623
<INITIAL>{FRAG} { count(); return FRAG; }
622624
<INITIAL>{SLASH} { count(); return SLASH; }

cfg.y

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static struct multi_str *tmp_mod;
206206
#define get_cfg_file_name \
207207
((finame) ? finame : cfg_file ? cfg_file : "default")
208208

209-
209+
#define si_subdomain_to_alias_flag(_flags) (int) _flags & SI_ACCEPT_SUBDOMAIN_ALIAS
210210

211211
#define mk_action_(_res, _type, _no, _elems) \
212212
do { \
@@ -468,6 +468,7 @@ extern int cfg_parse_only_routes;
468468
%token COLON
469469
%token ANY
470470
%token ANYCAST
471+
%token ACCEPT_SUBDOMAIN
471472
%token FRAG
472473
%token REUSE_PORT
473474
%token SCRIPTVARERR
@@ -493,6 +494,7 @@ extern int cfg_parse_only_routes;
493494
%type <sockid> socket_def
494495
%type <sockid> id_lst
495496
%type <sockid> alias_def
497+
%type <sockid> any_alias
496498
%type <sockid> listen_id_def
497499
%type <sockid> phostport phostportrange
498500
%type <intval> proto port any_proto
@@ -696,7 +698,7 @@ phostportrange: proto COLON MULT { IFOR();
696698
}
697699
;
698700

699-
alias_def: listen_id { IFOR();
701+
any_alias: listen_id { IFOR();
700702
$$=mk_listen_id($1, PROTO_NONE, 0); }
701703
| ANY COLON listen_id { IFOR();
702704
$$=mk_listen_id($3, PROTO_NONE, 0); }
@@ -709,6 +711,13 @@ alias_def: listen_id { IFOR();
709711
| phostport
710712
;
711713

714+
alias_def: any_alias { $$=$1; }
715+
| any_alias ACCEPT_SUBDOMAIN {
716+
$$=$1;
717+
$$->flags |= SI_ACCEPT_SUBDOMAIN_ALIAS;
718+
}
719+
;
720+
712721
id_lst: alias_def { IFOR(); $$=$1 ; }
713722
| alias_def id_lst { IFOR(); $$=$1; $$->next=$2; }
714723
;
@@ -732,6 +741,9 @@ socket_def_param: ANYCAST { IFOR();
732741
| REUSE_PORT { IFOR();
733742
p_tmp.flags |= SI_REUSEPORT;
734743
}
744+
| ACCEPT_SUBDOMAIN { IFOR();
745+
p_tmp.flags |= SI_ACCEPT_SUBDOMAIN_ALIAS;
746+
}
735747
| USE_WORKERS NUMBER { IFOR();
736748
p_tmp.workers=$2;
737749
}
@@ -1489,7 +1501,7 @@ assign_stm: LOGLEVEL EQUAL snumber { IFOR();
14891501
| ALIAS EQUAL id_lst { IFOR();
14901502
for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
14911503
add_alias(lst_tmp->name, strlen(lst_tmp->name),
1492-
lst_tmp->port, lst_tmp->proto);
1504+
lst_tmp->port, lst_tmp->proto, si_subdomain_to_alias_flag(lst_tmp->flags));
14931505
}
14941506
| ALIAS EQUAL error { yyerror("hostname expected (use quotes"
14951507
" if the hostname includes config keywords)"); }

core_cmds.c

Lines changed: 89 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ static int fixup_nt_string(void** param);
6666
static int fixup_nt_str(void** param);
6767
static int fixup_nt_str_free(void** param);
6868
static int fixup_via_hdl(void** param);
69+
static int fixup_append_mbranch_flags(void** param);
70+
6971

7072
static int w_forward(struct sip_msg *msg, struct proxy_l *dest);
7173
static int w_send(struct sip_msg *msg, struct proxy_l *dest, str *headers);
@@ -84,10 +86,14 @@ static int w_seturi(struct sip_msg *msg, str *uri);
8486
static int w_prefix(struct sip_msg *msg, str *prefix);
8587
static int w_strip(struct sip_msg *msg, int *nchars);
8688
static int w_strip_tail(struct sip_msg *msg, int *nchars);
87-
static int w_append_branch(struct sip_msg *msg, str *uri, int *qvalue);
88-
static int w_remove_branch(struct sip_msg *msg, int *branch);
89-
static int w_move_branch(struct sip_msg *msg, int *src_idx, int *dst_idx, int *keep);
90-
static int w_swap_branches(struct sip_msg *msg, int *src_idx, int *dst_idx);
89+
static int w_append_branch_old(struct sip_msg *msg, str *uri, int *qvalue);
90+
static int w_append_msg_branch(struct sip_msg *msg, str *uri, int *qvalue,
91+
void *flags);
92+
static int w_remove_msg_branch(struct sip_msg *msg, int *branch);
93+
static int w_move_msg_branch(struct sip_msg *msg,
94+
int *src_idx, int *dst_idx, int *keep);
95+
static int w_swap_msg_branches(struct sip_msg *msg,
96+
int *src_idx, int *dst_idx);
9197
static int w_pv_printf(struct sip_msg *msg, pv_spec_t *var, str *fmt_str);
9298
static int w_revert_uri(struct sip_msg *msg);
9399
static int w_setdsturi(struct sip_msg *msg, str *uri);
@@ -191,21 +197,28 @@ const cmd_export_t core_cmds[]={
191197
{"strip_tail", (cmd_function)w_strip_tail, {
192198
{CMD_PARAM_INT, 0, 0}, {0,0,0}},
193199
ALL_ROUTES},
194-
{"append_branch", (cmd_function)w_append_branch, {
200+
{"append_branch_old", (cmd_function)w_append_branch_old, {
195201
{CMD_PARAM_STR|CMD_PARAM_OPT, 0, 0},
196202
{CMD_PARAM_STR|CMD_PARAM_OPT|CMD_PARAM_FIX_NULL,
197203
fixup_qvalue, 0}, {0,0,0}},
198204
ALL_ROUTES},
199-
{"remove_branch", (cmd_function)w_remove_branch, {
205+
{"append_msg_branch", (cmd_function)w_append_msg_branch, {
206+
{CMD_PARAM_STR, 0, 0},
207+
{CMD_PARAM_STR|CMD_PARAM_OPT|CMD_PARAM_FIX_NULL,
208+
fixup_qvalue, 0},
209+
{CMD_PARAM_STR|CMD_PARAM_OPT,fixup_append_mbranch_flags,0},
210+
{0,0,0}},
211+
ALL_ROUTES},
212+
{"remove_msg_branch", (cmd_function)w_remove_msg_branch, {
200213
{CMD_PARAM_INT, 0, 0}, {0,0,0}},
201214
ALL_ROUTES},
202-
{"move_branch", (cmd_function)w_move_branch, {
215+
{"move_msg_branch", (cmd_function)w_move_msg_branch, {
203216
{CMD_PARAM_INT|CMD_PARAM_OPT, fixup_branch_index, 0},
204217
{CMD_PARAM_INT|CMD_PARAM_OPT, fixup_branch_index, 0},
205218
{CMD_PARAM_STR|CMD_PARAM_OPT, fixup_branch_keep, 0},
206219
{0,0,0}},
207220
ALL_ROUTES},
208-
{"swap_branches", (cmd_function)w_swap_branches, {
221+
{"swap_msg_branches", (cmd_function)w_swap_msg_branches, {
209222
{CMD_PARAM_INT|CMD_PARAM_OPT, fixup_branch_index, 0},
210223
{CMD_PARAM_INT|CMD_PARAM_OPT, fixup_branch_index, 0},
211224
{0,0,0}},
@@ -888,15 +901,22 @@ static int w_strip_tail(struct sip_msg *msg, int *nchars)
888901
return rewrite_ruri(msg, 0, *nchars, RW_RURI_STRIP_TAIL) ? -1 : 1;
889902
}
890903

891-
static int w_append_branch(struct sip_msg *msg, str *uri, int *qvalue)
904+
static int w_append_branch_old(struct sip_msg *msg, str *uri, int *qvalue)
892905
{
906+
struct msg_branch branch;
893907
int ret;
894908
qvalue_t q = (int)(long)qvalue;
895909

910+
memset( &branch, 0, sizeof branch);
911+
896912
if (!uri) {
897-
ret = append_branch(msg, 0, &msg->dst_uri, &msg->path_vec,
898-
(q==Q_UNSPECIFIED) ? get_ruri_q(msg) : q,
899-
getb0flags(msg), msg->force_send_socket);
913+
branch.uri = *GET_RURI(msg);
914+
branch.dst_uri = msg->dst_uri;
915+
branch.path = msg->path_vec;
916+
branch.q = (q==Q_UNSPECIFIED) ? get_ruri_q(msg) : q;
917+
branch.force_send_socket = msg->force_send_socket;
918+
branch.bflags = msg->ruri_bflags;
919+
ret = append_msg_branch(&branch);
900920
/* reset all branch info */
901921
msg->force_send_socket = 0;
902922
setb0flags(msg,0);
@@ -912,25 +932,73 @@ static int w_append_branch(struct sip_msg *msg, str *uri, int *qvalue)
912932

913933
return ret;
914934
} else {
915-
return append_branch(msg, uri, &msg->dst_uri,
916-
&msg->path_vec, q, getb0flags(msg),
917-
msg->force_send_socket);
935+
branch.uri = *uri;
936+
branch.dst_uri = msg->dst_uri;
937+
branch.path = msg->path_vec;
938+
branch.q = q;
939+
branch.force_send_socket = msg->force_send_socket;
940+
branch.bflags = msg->ruri_bflags;
941+
return append_msg_branch(&branch);
942+
}
943+
}
944+
945+
946+
static str append_mbranch_flag_names[] =
947+
{
948+
str_init("inherite"),
949+
STR_NULL
950+
};
951+
952+
static int fixup_append_mbranch_flags(void** param)
953+
{
954+
return fixup_named_flags(param, append_mbranch_flag_names, NULL, NULL);
955+
}
956+
957+
958+
static int w_append_msg_branch(struct sip_msg *msg, str *uri, int *qvalue,
959+
void *flags)
960+
{
961+
unsigned int opts = (unsigned int)(unsigned long)flags;
962+
struct msg_branch branch;
963+
qvalue_t q = (int)(long)qvalue;
964+
965+
if (ZSTRP(uri)) {
966+
LM_ERR("appending emptry URI :(\n");
967+
return -1;
968+
}
969+
970+
memset( &branch, 0, sizeof branch);
971+
branch.uri = *uri;
972+
973+
if ( opts & (1<<0) ) {
974+
/* inherite the rest of the branch attrs from RURI branch */
975+
branch.dst_uri = msg->dst_uri;
976+
branch.path = msg->path_vec;
977+
branch.q = (q==Q_UNSPECIFIED) ? get_ruri_q(msg) : q;
978+
branch.force_send_socket = msg->force_send_socket;
979+
branch.bflags = msg->ruri_bflags;
980+
} else {
981+
branch.q = q;
918982
}
983+
return append_msg_branch(&branch);
919984
}
920985

921-
static int w_remove_branch(struct sip_msg *msg, int *branch)
986+
static int w_remove_msg_branch(struct sip_msg *msg, int *branch)
922987
{
923-
return (remove_branch(*branch)==0)?1:-1;
988+
return (remove_msg_branch(*branch)==0) ? 1 : -1 ;
924989
}
925990

926-
static int w_move_branch(struct sip_msg *msg, int *src_idx, int *dst_idx, int *keep)
991+
static int w_move_msg_branch(struct sip_msg *msg, int *src_idx,
992+
int *dst_idx, int *keep)
927993
{
928-
return (move_branch(msg, (src_idx?*src_idx:-1), (dst_idx?*dst_idx:-1), (keep?1:0))==0)?1:-1;
994+
return (move_msg_branch(msg,
995+
(src_idx?*src_idx:-1), (dst_idx?*dst_idx:-1), (keep?1:0))==0) ? 1 : -1;
929996
}
930997

931-
static int w_swap_branches(struct sip_msg *msg, int *src_idx, int *dst_idx)
998+
static int w_swap_msg_branches(struct sip_msg *msg, int *src_idx, int *dst_idx)
932999
{
933-
return (swap_branches(msg, (src_idx?*src_idx:-1), (dst_idx?*dst_idx:-1))==0)?1:-1;
1000+
return (swap_msg_branches(msg,
1001+
(src_idx?*src_idx:-1), (dst_idx?*dst_idx:-1))==0) ? 1 : -1 ;
9341002
}
9351003

9361004
static int w_pv_printf(struct sip_msg *msg, pv_spec_t *var, str *fmt_str)

db/schema/domain.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<table id="domain" xmlns:db="http://docbook.org/ns/docbook">
1111
<name>domain</name>
12-
<version>3</version>
12+
<version>4</version>
1313
<type db="mysql">&MYSQL_TABLE_TYPE;</type>
1414
<description>
1515
<db:para>This table is used by the domain module to determine if a host part of a URI is "local" or not. More information about the domain module can be found at: &OPENSIPS_MOD_DOC;domain.html
@@ -44,6 +44,13 @@
4444
<null/>
4545
</column>
4646

47+
<column id="accept_subdomain">
48+
<name>accept_subdomain</name>
49+
<type>unsigned int</type>
50+
<size>11</size>
51+
<default>0</default>
52+
<description>Accept subdomain</description>
53+
</column>
4754

4855
<column>
4956
<name>last_modified</name>

db/schema/trie_partitions.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
]>
99

10-
<table id="dr_partitions" xmlns:db="http://docbook.org/ns/docbook">
11-
<name>dr_partitions</name>
10+
<table id="trie_partitions" xmlns:db="http://docbook.org/ns/docbook">
11+
<name>trie_partitions</name>
1212
<version>1</version>
1313
<type db="mysql">&MYSQL_TABLE_TYPE;</type>
1414
<description>

doc/build-contrib.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
2222

2323
### global OpenSIPS commit stats, self-generated on each "rebuild-proj-stats"
24-
__PROJ_COMMITS=21604
25-
__PROJ_LINES_ADD=2576926
26-
__PROJ_LINES_DEL=1328694
27-
__LAST_REBUILD_SHA=816b58e6b36d873f63b20923fb822593a175b5f2
24+
__PROJ_COMMITS=22438
25+
__PROJ_LINES_ADD=2669737
26+
__PROJ_LINES_DEL=1359428
27+
__LAST_REBUILD_SHA=eb9a3007c236220b53d880dd4cc768cbe7e80110
2828

2929
TMP_FILE=/var/tmp/.opensips-build-contrib.tmp
3030

0 commit comments

Comments
 (0)