@@ -66,6 +66,8 @@ static int fixup_nt_string(void** param);
66
66
static int fixup_nt_str (void * * param );
67
67
static int fixup_nt_str_free (void * * param );
68
68
static int fixup_via_hdl (void * * param );
69
+ static int fixup_append_mbranch_flags (void * * param );
70
+
69
71
70
72
static int w_forward (struct sip_msg * msg , struct proxy_l * dest );
71
73
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);
84
86
static int w_prefix (struct sip_msg * msg , str * prefix );
85
87
static int w_strip (struct sip_msg * msg , int * nchars );
86
88
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 );
91
97
static int w_pv_printf (struct sip_msg * msg , pv_spec_t * var , str * fmt_str );
92
98
static int w_revert_uri (struct sip_msg * msg );
93
99
static int w_setdsturi (struct sip_msg * msg , str * uri );
@@ -191,21 +197,28 @@ const cmd_export_t core_cmds[]={
191
197
{"strip_tail" , (cmd_function )w_strip_tail , {
192
198
{CMD_PARAM_INT , 0 , 0 }, {0 ,0 ,0 }},
193
199
ALL_ROUTES },
194
- {"append_branch " , (cmd_function )w_append_branch , {
200
+ {"append_branch_old " , (cmd_function )w_append_branch_old , {
195
201
{CMD_PARAM_STR |CMD_PARAM_OPT , 0 , 0 },
196
202
{CMD_PARAM_STR |CMD_PARAM_OPT |CMD_PARAM_FIX_NULL ,
197
203
fixup_qvalue , 0 }, {0 ,0 ,0 }},
198
204
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 , {
200
213
{CMD_PARAM_INT , 0 , 0 }, {0 ,0 ,0 }},
201
214
ALL_ROUTES },
202
- {"move_branch " , (cmd_function )w_move_branch , {
215
+ {"move_msg_branch " , (cmd_function )w_move_msg_branch , {
203
216
{CMD_PARAM_INT |CMD_PARAM_OPT , fixup_branch_index , 0 },
204
217
{CMD_PARAM_INT |CMD_PARAM_OPT , fixup_branch_index , 0 },
205
218
{CMD_PARAM_STR |CMD_PARAM_OPT , fixup_branch_keep , 0 },
206
219
{0 ,0 ,0 }},
207
220
ALL_ROUTES },
208
- {"swap_branches " , (cmd_function )w_swap_branches , {
221
+ {"swap_msg_branches " , (cmd_function )w_swap_msg_branches , {
209
222
{CMD_PARAM_INT |CMD_PARAM_OPT , fixup_branch_index , 0 },
210
223
{CMD_PARAM_INT |CMD_PARAM_OPT , fixup_branch_index , 0 },
211
224
{0 ,0 ,0 }},
@@ -888,15 +901,22 @@ static int w_strip_tail(struct sip_msg *msg, int *nchars)
888
901
return rewrite_ruri (msg , 0 , * nchars , RW_RURI_STRIP_TAIL ) ? -1 : 1 ;
889
902
}
890
903
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 )
892
905
{
906
+ struct msg_branch branch ;
893
907
int ret ;
894
908
qvalue_t q = (int )(long )qvalue ;
895
909
910
+ memset ( & branch , 0 , sizeof branch );
911
+
896
912
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 );
900
920
/* reset all branch info */
901
921
msg -> force_send_socket = 0 ;
902
922
setb0flags (msg ,0 );
@@ -912,25 +932,73 @@ static int w_append_branch(struct sip_msg *msg, str *uri, int *qvalue)
912
932
913
933
return ret ;
914
934
} 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 ;
918
982
}
983
+ return append_msg_branch (& branch );
919
984
}
920
985
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 )
922
987
{
923
- return (remove_branch (* branch )== 0 )? 1 : -1 ;
988
+ return (remove_msg_branch (* branch )== 0 ) ? 1 : -1 ;
924
989
}
925
990
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 )
927
993
{
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 ;
929
996
}
930
997
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 )
932
999
{
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 ;
934
1002
}
935
1003
936
1004
static int w_pv_printf (struct sip_msg * msg , pv_spec_t * var , str * fmt_str )
0 commit comments