Skip to content

Commit 209419a

Browse files
committed
Added new function move_branch_to_ruri().
This move a branch (give by index) from the dset into the RURI & co. This is part of the larger work to add support for dynamic following of the 3xx replies during a parallel forking attempt. Instead of waiting for the whole transaction to end (all branches), if a branch gets a 3xx reply, the redirect contact will be followed on spot by dynamically creating new branch (even if the transaction is not yet completed). This is work sponsored by the Harris Corporation (https://www.harris.com)
1 parent 9cc75c0 commit 209419a

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

dset.c

+58
Original file line numberDiff line numberDiff line change
@@ -599,3 +599,61 @@ int branch_uri2dset( str *new_uri )
599599

600600
return 0;
601601
}
602+
603+
604+
int move_branch_to_ruri(int idx, struct sip_msg *msg)
605+
{
606+
struct dset_ctx *dsct = get_dset_ctx();
607+
struct branch *branch;
608+
str s;
609+
610+
/* no branches have been added yet */
611+
if (!dsct) {
612+
LM_DBG("no branches found\n");
613+
return -1;
614+
}
615+
616+
/* */
617+
if (idx >= dsct->nr_branches) {
618+
LM_DBG("trying to move inexisting branch idx %d, out of %d\n",
619+
idx, dsct->nr_branches);
620+
return -1;
621+
}
622+
623+
branch = &dsct->branches[idx];
624+
625+
/* move RURI */
626+
s.s = branch->uri;
627+
s.len = branch->len;
628+
if (set_ruri( msg, &s)<0) {
629+
LM_ERR("failed to set new RURI\n");
630+
return -1;
631+
}
632+
633+
/* move DURI (empty is accepted as reset) */
634+
s.s = branch->dst_uri;
635+
s.len = branch->dst_uri_len;
636+
if (set_dst_uri( msg, &s)<0) {
637+
LM_ERR("failed to set DST URI\n");
638+
return -1;
639+
}
640+
641+
/* move PATH (empty is accepted as reset) */
642+
s.s = branch->path;
643+
s.len = branch->path_len;
644+
if (set_path_vector( msg, &s)<0) {
645+
LM_ERR("failed to set PATH\n");
646+
return -1;
647+
}
648+
649+
/* Qval */
650+
set_ruri_q( msg, branch->q );
651+
652+
/* BFLAGS */
653+
setb0flags( msg, branch->flags );
654+
655+
/* socket info */
656+
msg->force_send_socket = branch->force_send_socket;
657+
658+
return 0;
659+
}

dset.h

+5
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,9 @@ int isbflagset(struct sip_msg *msg, unsigned int b_idx, unsigned int mask);
107107
int resetbflag(struct sip_msg *msg, unsigned int b_idx, unsigned int mask);
108108

109109

110+
/*! \brief
111+
* Moves the branch index idx into the SIP request msg.
112+
*/
113+
int move_branch_to_ruri(int idx, struct sip_msg *msg);
114+
110115
#endif /* _DSET_H */

0 commit comments

Comments
 (0)