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

Function fake_req

modules/tm/t_msgbuilder.h:194–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192
193
194static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,
195 struct ua_server *uas, struct ua_client *uac)
196{
197 /* on_negative_reply faked msg now copied from shmem msg (as opposed
198 * to zero-ing) -- more "read-only" actions (exec in particular) will
199 * work from reply_route as they will see msg->from, etc.; caution,
200 * rw actions may append some pkg stuff to msg, which will possibly be
201 * never released (shmem is released in a single block) */
202 memcpy( faked_req, shm_msg, sizeof(struct sip_msg));
203
204 /* if we set msg_id to something different from current's message
205 * id, the first t_fork will properly clean new branch URIs */
206 faked_req->id = get_next_msg_no();
207 /* msg->parsed_uri_ok must be reset since msg_parsed_uri is
208 * not cloned (and cannot be cloned) */
209 faked_req->parsed_uri_ok = 0;
210
211 faked_req->msg_flags |= FL_TM_FAKE_REQ;
212
213 if (uac) {
214 /* duplicate all URI values into private mem
215 * so they are visible and change-able at script level */
216 if (pkg_nt_str_dup(&faked_req->new_uri, &uac->uri) != 0) {
217 LM_ERR("no uri/pkg mem\n");
218 goto out0;
219 }
220
221 if (uac->duri.s) {
222 if (pkg_nt_str_dup(&faked_req->dst_uri, &uac->duri) != 0) {
223 LM_ERR("out of pkg mem\n");
224 goto out1;
225 }
226 } else {
227 faked_req->dst_uri = STR_NULL;
228 }
229
230 if (uac->path_vec.s) {
231 if (pkg_nt_str_dup(&faked_req->path_vec, &uac->path_vec) != 0) {
232 LM_ERR("out of pkg mem\n");
233 goto out2;
234 }
235 } else {
236 faked_req->path_vec = STR_NULL;
237 }
238
239 /* set the branch flags from the elected branch */
240 setb0flags( faked_req, uac->br_flags);
241 /* Q and force_send_socket values were already copied
242 * as part of the sip_msg struct */
243
244 /* duplicate advertised address and port from UAC into
245 * private mem so that they can be changed at script level */
246 if (uac->adv_address.s) {
247 if (pkg_nt_str_dup(&faked_req->set_global_address, &uac->adv_address) != 0) {
248 LM_ERR("out of pkg mem\n");
249 goto out3;
250 }
251 } else {

Callers 4

run_failure_handlersFunction · 0.85
do_dns_failoverFunction · 0.85
t_resume_async_requestFunction · 0.85
t_inject_branchFunction · 0.85

Calls 4

get_next_msg_noFunction · 0.85
fix_fake_req_headersFunction · 0.85
clone_sip_msg_bodyFunction · 0.85
pkg_nt_str_dupFunction · 0.50

Tested by

no test coverage detected