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

Function buf_to_sip_msg

modules/tm/t_msgbuilder.h:86–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84
85
86static inline struct sip_msg* buf_to_sip_msg(char *buf, unsigned int len,
87 dlg_t *dialog)
88{
89 struct sip_msg *req;
90
91 req = (struct sip_msg*)pkg_malloc( sizeof(struct sip_msg));
92 if (req==NULL) {
93 LM_ERR("no more pkg mem, needed %zu\n",sizeof(struct sip_msg));
94 return NULL;
95 }
96 memset( req, 0, sizeof(struct sip_msg) );
97 req->id = get_next_msg_no();
98 req->buf = buf;
99 req->len = len;
100 if (parse_msg(buf, len, req)!=0) {
101 LM_CRIT("BUG - buffer parsing failed!\n");
102 goto error;
103 }
104 /* parse all headers, to be sure they get cloned in shm */
105 if (parse_headers(req, HDR_EOH_F, 0 )<0) {
106 LM_ERR("parse_headers failed\n");
107 goto error1;
108 }
109 /* check if we have all necessary headers */
110 if (check_transaction_quadruple(req)==0) {
111 LM_ERR("too few headers\n");
112 /* stop processing */
113 goto error1;
114 }
115
116 /* populate some special fields in sip_msg */
117 req->force_send_socket = dialog->send_sock;
118 if (set_dst_uri(req, dialog->hooks.next_hop)) {
119 LM_ERR("failed to set dst_uri\n");
120 goto error1;
121 }
122 req->rcv.proto = dialog->send_sock->proto;
123 req->rcv.src_ip = req->rcv.dst_ip = dialog->send_sock->address;
124 req->rcv.src_port = req->rcv.dst_port = dialog->send_sock->port_no;
125 req->rcv.bind_address = dialog->send_sock;
126
127 req->flags |= FL_IS_LOCAL;
128
129 return req;
130
131error1:
132 free_sip_msg(req);
133error:
134 pkg_free(req);
135 return NULL;
136}
137
138static inline int fix_fake_req_headers(struct sip_msg *req)
139{

Callers 2

do_dns_failoverFunction · 0.85
run_local_routeFunction · 0.85

Calls 4

get_next_msg_noFunction · 0.85
set_dst_uriFunction · 0.85
free_sip_msgFunction · 0.85

Tested by

no test coverage detected