|
@@ -74,6 +74,39 @@ unsigned int inc_msg_no(void)
|
|
|
return ++msg_no;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+int sip_check_fline(char* buf, unsigned int len)
|
|
|
+{
|
|
|
+ char *p;
|
|
|
+ int m;
|
|
|
+
|
|
|
+ m = 0;
|
|
|
+ for(p=buf; p<buf+len; p++) {
|
|
|
+ /* first check if is a reply - starts with SIP/2.0 */
|
|
|
+ if(m==0) {
|
|
|
+ if(*p==' ' || *p=='\t' || *p=='\r' || *p=='\n') continue;
|
|
|
+ if(buf+len-p<10) return -1;
|
|
|
+ if(strncmp(p, "SIP/2.0 ", 8)==0) {
|
|
|
+ LM_DBG("first line indicates a SIP reply\n");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ m=1;
|
|
|
+ } else {
|
|
|
+ /* check if a request - before end of first line is SIP/2.0 */
|
|
|
+ if(*p!='\r' && *p!='\n') continue;
|
|
|
+ if(p-10>=buf) {
|
|
|
+ if(strncmp(p-8, " SIP/2.0", 8)==0) {
|
|
|
+ LM_DBG("first line indicates a SIP request\n");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+}
|
|
|
|
|
|
/** Receive message
|
|
|
* WARNING: buf must be 0 terminated (buf[len]=0) or some things might
|
|
@@ -93,6 +126,16 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
|
|
|
str inb;
|
|
|
sr_net_info_t netinfo;
|
|
|
|
|
|
+ if(sr_event_enabled(SREV_NET_DATA_RECV)) {
|
|
|
+ if(sip_check_fline(buf, len)==0) {
|
|
|
+ memset(&netinfo, 0, sizeof(sr_net_info_t));
|
|
|
+ netinfo.data.s = buf;
|
|
|
+ netinfo.data.len = len;
|
|
|
+ netinfo.rcv = rcv_info;
|
|
|
+ sr_event_exec(SREV_NET_DATA_RECV, (void*)&netinfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
inb.s = buf;
|
|
|
inb.len = len;
|
|
|
sr_event_exec(SREV_NET_DATA_IN, (void*)&inb);
|
|
@@ -140,14 +183,6 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
|
|
|
/* ... clear branches from previous message */
|
|
|
clear_branches();
|
|
|
|
|
|
- if(sr_event_enabled(SREV_NET_DATA_RECV)) {
|
|
|
- memset(&netinfo, 0, sizeof(sr_net_info_t));
|
|
|
- netinfo.data.s = msg->buf;
|
|
|
- netinfo.data.len = msg->len;
|
|
|
- netinfo.rcv = rcv_info;
|
|
|
- sr_event_exec(SREV_NET_DATA_RECV, (void*)&netinfo);
|
|
|
- }
|
|
|
-
|
|
|
if (msg->first_line.type==SIP_REQUEST){
|
|
|
ruri_mark_new(); /* ruri is usable for forking (not consumed yet) */
|
|
|
if (!IS_SIP(msg)){
|