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

Function receive_msg

receive.c:100–329  ·  view source on GitHub ↗

! \note WARNING: buf must be 0 terminated (buf[len]=0) or some things might * break (e.g.: modules/textops) */

Source from the content-addressed store, hash-verified

98 * break (e.g.: modules/textops)
99 */
100int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info,
101 context_p existing_context, unsigned int msg_flags)
102{
103 #define reset_global_context() \
104 do {\
105 if (!current_processing_ctx) { \
106 ctx = NULL; \
107 } else { \
108 context_destroy(CONTEXT_GLOBAL, ctx); \
109 set_global_context(NULL); \
110 } \
111 } while (0)
112 static context_p ctx = NULL;
113
114 struct sip_msg* msg;
115 struct timeval start;
116 int rc, ret, old_route_type;
117 char *tmp;
118 str in_buff;
119
120 profiling_proc_enter( LEVEL_SIP, "receive_msg", 0 );
121
122 in_buff.len = len;
123 in_buff.s = buf;
124
125 if (existing_context) {
126 context_free(ctx);
127 ctx = existing_context;
128 }
129
130 /* the raw processing callbacks can change the buffer,
131 further use in_buff.s and at the end try to free in_buff.s
132 if changed by callbacks */
133 if (run_pre_raw_processing_cb(PRE_RAW_PROCESSING,&in_buff,NULL)<0) {
134 LM_ERR("error in running pre raw callbacks, dropping\n");
135 goto error;
136 }
137 /* update the length for further processing */
138 len = in_buff.len;
139
140 msg=pkg_malloc(sizeof(struct sip_msg));
141 if (msg==0) {
142 LM_ERR("no pkg mem left for sip_msg\n");
143 goto error;
144 }
145 msg_no++;
146 /* number of vias parsed -- good for diagnostic info in replies */
147 via_cnt=0;
148
149 memset(msg,0, sizeof(struct sip_msg)); /* init everything to 0 */
150 /* fill in msg */
151 msg->buf=in_buff.s;
152 msg->len=len;
153 msg->rcv=*rcv_info;
154 msg->id=msg_no;
155 msg->msg_flags=msg_flags;
156 msg->ruri_q = Q_UNSPECIFIED;
157

Callers 7

proto_sctp_readFunction · 0.85
rpc_msg_receivedFunction · 0.85
receive_tm_replFunction · 0.85
hep_receive_msgFunction · 0.85
hep_udp_read_reqFunction · 0.85
handle_ioFunction · 0.85
udp_read_reqFunction · 0.85

Calls 15

parse_msg_optFunction · 0.85
ip_addr2aFunction · 0.85
run_error_routeFunction · 0.85
clear_dsetFunction · 0.85
tcpconn_add_aliasFunction · 0.85
exec_pre_req_cbFunction · 0.85
run_top_routeFunction · 0.85
exec_post_req_cbFunction · 0.85
exec_pre_rpl_cbFunction · 0.85
forward_replyFunction · 0.85
exec_post_rpl_cbFunction · 0.85

Tested by

no test coverage detected