MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / serialize_branches

Function serialize_branches

serialize.c:88–264  ·  view source on GitHub ↗

! \brief * Loads contacts in destination set into "serial_avp" AVP in reverse * priority order and associated each contact with Q_FLAG telling if * contact is the last one in its priority class. Finally, removes * all branches from destination set. */

Source from the content-addressed store, hash-verified

86 * all branches from destination set.
87 */
88int serialize_branches(struct sip_msg *msg, int clean_before, int keep_order)
89{
90 static struct serial_contact contacts[MAX_BRANCHES];
91 struct msg_branch *branch;
92 int n, last, first, i, prev, bflags;
93 str *ruri;
94 qvalue_t ruri_q;
95 char *p;
96 str enc_info;
97 int_str val;
98 int idx;
99
100 /* Check if anything needs to be done */
101 if (get_dset_size() == 0) {
102 LM_DBG("nothing to do - no branches!\n");
103 return 0;
104 }
105
106 ruri = GET_RURI(msg);
107 ruri_q = get_ruri_q(msg);
108 bflags = getb0flags(msg);
109
110 for (idx = 0; (branch = get_msg_branch(idx)); idx++) {
111 if (branch->q != ruri_q)
112 break;
113 }
114
115 if (branch==NULL && !keep_order) {
116 LM_DBG("nothing to do - all same q!\n");
117 return 0;
118 }
119
120 /* reset contact array */
121 n = 0;
122
123 /* Insert Request-URI to contact list */
124 enc_info.len = 3 * sizeof(long)
125 + ruri->len + msg->dst_uri.len + msg->path_vec.len + 3;
126 enc_info.s = (char*) pkg_malloc (enc_info.len);
127
128 if (!enc_info.s) {
129 LM_ERR("no pkg memory left\n");
130 goto error; /* nothing to free here */
131 }
132
133 memset(enc_info.s, 0, enc_info.len);
134 p = enc_info.s;
135
136 LM_DBG("Msg information <%.*s,%.*s,%.*s,%d,%u>\n",
137 ruri->len, ruri->s,
138 msg->dst_uri.len, msg->dst_uri.s,
139 msg->path_vec.len, msg->path_vec.s,
140 ruri_q, bflags);
141
142 seras(p, &msg->force_send_socket, long);
143 p += sizeof(long);
144 seras(p, &bflags, long);
145 p += sizeof(long);

Callers 1

w_serialize_branchesFunction · 0.85

Calls 5

get_dset_sizeFunction · 0.85
get_msg_branchFunction · 0.85
destroy_avpsFunction · 0.85
add_avpFunction · 0.85
clear_dsetFunction · 0.85

Tested by

no test coverage detected