! \note WARNING: buf must be 0 terminated (buf[len]=0) or some things might * break (e.g.: modules/textops) */
| 98 | * break (e.g.: modules/textops) |
| 99 | */ |
| 100 | int 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 |
no test coverage detected