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

Function build_local

modules/tm/t_msgbuilder.c:104–266  ·  view source on GitHub ↗

Build a local request based on a previous request; the only customers of this function are local ACK and local CANCEL */

Source from the content-addressed store, hash-verified

102 customers of this function are local ACK and local CANCEL
103 */
104char *build_local(struct cell *Trans,unsigned int branch,
105 str *method, str *extra, struct sip_msg* rpl, unsigned int *len)
106{
107 char *cancel_buf, *p, *via;
108 unsigned int via_len;
109 struct hdr_field *buf_hdrs;
110 struct hdr_field *hdr;
111 struct sip_msg *req;
112 char branch_buf[MAX_BRANCH_PARAM_LEN];
113 str branch_str;
114 struct hostport hp;
115 str from;
116 str to;
117 str cseq_n;
118 str *cid = NULL;
119 struct ua_client* uac = & TM_BRANCH( Trans, branch);
120
121 req = Trans->uas.request;
122 cseq_n = Trans->cseq_n;
123 buf_hdrs = 0;
124
125 if (rpl && rpl!=FAKED_REPLY) {
126 /* take from and to hdrs from reply */
127 to.s = rpl->to->name.s;
128 to.len = rpl->to->len;
129 from.s = rpl->from->name.s;
130 from.len = rpl->from->len;
131 if (req && req->msg_flags&FL_USE_UAC_CSEQ) {
132 if ( extract_ftc_hdrs( uac->request.buffer.s,
133 uac->request.buffer.len,0 ,0 ,
134 &cseq_n ,0)!=0 ) {
135 LM_ERR("build_local: failed to extract UAC hdrs\n");
136 goto error;
137 }
138 }
139 } else {
140 to = Trans->to;
141 from = Trans->from;
142 if (req && req->msg_flags&(FL_USE_UAC_FROM|FL_USE_UAC_TO|FL_USE_UAC_CSEQ)) {
143 if ( extract_ftc_hdrs( uac->request.buffer.s,
144 uac->request.buffer.len,
145 (req->msg_flags&FL_USE_UAC_FROM)?&from:0 ,
146 (req->msg_flags&FL_USE_UAC_TO)?&to:0 ,
147 (req->msg_flags&FL_USE_UAC_CSEQ)?&cseq_n:0 ,0)!=0 ) {
148 LM_ERR("build_local: failed to extract UAC hdrs\n");
149 goto error;
150 }
151 }
152 }
153
154 LM_DBG("using FROM=<%.*s>, TO=<%.*s>, CSEQ_N=<%.*s>\n",
155 from.len,from.s , to.len,to.s , cseq_n.len,cseq_n.s);
156
157 /* method, separators, version */
158 *len=SIP_VERSION_LEN + method->len + 2 /* spaces */ + CRLF_LEN;
159 *len+=uac->uri.len;
160
161 if (is_anycast(uac->request.dst.send_sock))

Callers 2

send_ackFunction · 0.85
build_cancelFunction · 0.85

Calls 6

extract_ftc_hdrsFunction · 0.85
t_calc_branchFunction · 0.85
via_builderFunction · 0.85
extract_parsed_hdrsFunction · 0.85
shm_mallocFunction · 0.85
free_hdr_field_lstFunction · 0.85

Tested by

no test coverage detected