|
@@ -40,7 +40,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
|
|
/* see if it's a reply (status) */
|
|
/* see if it's a reply (status) */
|
|
tmp=eat_token(buffer, len);
|
|
tmp=eat_token(buffer, len);
|
|
if ((tmp==buffer)||(tmp>=end)){
|
|
if ((tmp==buffer)||(tmp>=end)){
|
|
- DPrint("ERROR: empty or bad first line\n");
|
|
|
|
|
|
+ LOG(L_INFO, "ERROR:parse_first_line: empty or bad first line\n");
|
|
goto error1;
|
|
goto error1;
|
|
}
|
|
}
|
|
if ((strlen(SIP_VERSION)==(tmp-buffer)) &&
|
|
if ((strlen(SIP_VERSION)==(tmp-buffer)) &&
|
|
@@ -103,11 +103,11 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
|
|
return nl;
|
|
return nl;
|
|
|
|
|
|
error:
|
|
error:
|
|
- DPrint("ERROR: bad %s first line\n",
|
|
|
|
|
|
+ LOG(L_INFO, "ERROR:parse_first_line: bad %s first line\n",
|
|
(fl->type==SIP_REPLY)?"reply(status)":"request");
|
|
(fl->type==SIP_REPLY)?"reply(status)":"request");
|
|
error1:
|
|
error1:
|
|
fl->type=SIP_INVALID;
|
|
fl->type=SIP_INVALID;
|
|
- DPrint("ERROR: at line 0 char %d\n", offset);
|
|
|
|
|
|
+ LOG(L_INFO, "ERROR: at line 0 char %d\n", offset);
|
|
/* skip line */
|
|
/* skip line */
|
|
nl=eat_line(buffer,len);
|
|
nl=eat_line(buffer,len);
|
|
return nl;
|
|
return nl;
|
|
@@ -168,7 +168,7 @@ char* get_hdr_field(char *buffer, unsigned int len, struct hdr_field* hdr_f)
|
|
}while( (*tmp==' ' || *tmp=='\t') && (offset<len) );
|
|
}while( (*tmp==' ' || *tmp=='\t') && (offset<len) );
|
|
if (offset==len){
|
|
if (offset==len){
|
|
hdr_f->type=HDR_ERROR;
|
|
hdr_f->type=HDR_ERROR;
|
|
- DPrint("ERROR: field body too long\n");
|
|
|
|
|
|
+ LOG(L_INFO, "ERROR: het_hdr_field: field body too long\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
*(tmp-1)=0; /* should be an LF */
|
|
*(tmp-1)=0; /* should be an LF */
|
|
@@ -193,7 +193,8 @@ char* parse_hostport(char* buf, char** host, short int* port)
|
|
invalid=0;
|
|
invalid=0;
|
|
*port=strtol(tmp+1, &invalid, 10);
|
|
*port=strtol(tmp+1, &invalid, 10);
|
|
if ((invalid!=0)&&(*invalid)){
|
|
if ((invalid!=0)&&(*invalid)){
|
|
- DPrint("ERROR: hostport: trailing chars in port number: %s(%x)\n",
|
|
|
|
|
|
+ LOG(L_INFO,
|
|
|
|
+ "ERROR: hostport: trailing chars in port number: %s(%x)\n",
|
|
invalid, invalid);
|
|
invalid, invalid);
|
|
/* report error? */
|
|
/* report error? */
|
|
}
|
|
}
|
|
@@ -362,23 +363,23 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
|
|
tmp=rest;
|
|
tmp=rest;
|
|
switch(fl.type){
|
|
switch(fl.type){
|
|
case SIP_INVALID:
|
|
case SIP_INVALID:
|
|
- DPrint("invalid message\n");
|
|
|
|
|
|
+ DBG("parse_msg: invalid message\n");
|
|
goto error;
|
|
goto error;
|
|
break;
|
|
break;
|
|
case SIP_REQUEST:
|
|
case SIP_REQUEST:
|
|
- DPrint("SIP Request:\n");
|
|
|
|
- DPrint(" method: <%s>\n",fl.u.request.method);
|
|
|
|
- DPrint(" uri: <%s>\n",fl.u.request.uri);
|
|
|
|
- DPrint(" version: <%s>\n",fl.u.request.version);
|
|
|
|
|
|
+ DBG("SIP Request:\n");
|
|
|
|
+ DBG(" method: <%s>\n",fl.u.request.method);
|
|
|
|
+ DBG(" uri: <%s>\n",fl.u.request.uri);
|
|
|
|
+ DBG(" version: <%s>\n",fl.u.request.version);
|
|
break;
|
|
break;
|
|
case SIP_REPLY:
|
|
case SIP_REPLY:
|
|
- DPrint("SIP Reply (status):\n");
|
|
|
|
- DPrint(" version: <%s>\n",fl.u.reply.version);
|
|
|
|
- DPrint(" status: <%s>\n",fl.u.reply.status);
|
|
|
|
- DPrint(" reason: <%s>\n",fl.u.reply.reason);
|
|
|
|
|
|
+ DBG("SIP Reply (status):\n");
|
|
|
|
+ DBG(" version: <%s>\n",fl.u.reply.version);
|
|
|
|
+ DBG(" status: <%s>\n",fl.u.reply.status);
|
|
|
|
+ DBG(" reason: <%s>\n",fl.u.reply.reason);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- DPrint("unknown type %d\n",fl.type);
|
|
|
|
|
|
+ DBG("unknown type %d\n",fl.type);
|
|
}
|
|
}
|
|
|
|
|
|
/*find first Via: */
|
|
/*find first Via: */
|
|
@@ -390,7 +391,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
|
|
offset+=rest-tmp;
|
|
offset+=rest-tmp;
|
|
switch (hf.type){
|
|
switch (hf.type){
|
|
case HDR_ERROR:
|
|
case HDR_ERROR:
|
|
- DPrint("ERROR: bad header field\n");
|
|
|
|
|
|
+ LOG(L_INFO,"ERROR: bad header field\n");
|
|
goto error;
|
|
goto error;
|
|
case HDR_EOH:
|
|
case HDR_EOH:
|
|
goto skip;
|
|
goto skip;
|
|
@@ -402,11 +403,12 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
|
|
for (bar=first_via;(first_via) && (*bar);bar++)
|
|
for (bar=first_via;(first_via) && (*bar);bar++)
|
|
if ((*bar=='\r')||(*bar=='\n')) *bar=' ';
|
|
if ((*bar=='\r')||(*bar=='\n')) *bar=' ';
|
|
#ifdef DEBUG
|
|
#ifdef DEBUG
|
|
- printf("first via: <%s>\n", first_via);
|
|
|
|
|
|
+ DBG("first via: <%s>\n", first_via);
|
|
#endif
|
|
#endif
|
|
bar=parse_via_body(first_via, strlen(first_via), &vb1);
|
|
bar=parse_via_body(first_via, strlen(first_via), &vb1);
|
|
if (vb1.error!=VIA_PARSE_OK){
|
|
if (vb1.error!=VIA_PARSE_OK){
|
|
- DPrint("ERROR: parsing via body: %s\n", first_via);
|
|
|
|
|
|
+ LOG(L_INFO, "ERROR: parsing via body: %s\n",
|
|
|
|
+ first_via);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -430,7 +432,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
#ifdef DEBUG
|
|
#ifdef DEBUG
|
|
- printf("header field type %d, name=<%s>, body=<%s>\n",
|
|
|
|
|
|
+ DBG("header field type %d, name=<%s>, body=<%s>\n",
|
|
hf.type, hf.name, hf.body);
|
|
hf.type, hf.name, hf.body);
|
|
#endif
|
|
#endif
|
|
tmp=rest;
|
|
tmp=rest;
|
|
@@ -444,7 +446,7 @@ skip:
|
|
if (second_via) {
|
|
if (second_via) {
|
|
tmp=parse_via_body(second_via, strlen(second_via), &vb2);
|
|
tmp=parse_via_body(second_via, strlen(second_via), &vb2);
|
|
if (vb2.error!=VIA_PARSE_OK){
|
|
if (vb2.error!=VIA_PARSE_OK){
|
|
- DPrint("ERROR: parsing via2 body: %s\n", second_via);
|
|
|
|
|
|
+ LOG(L_INFO, "ERROR: parsing via2 body: %s\n", second_via);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
vb2.size=tmp-second_via;
|
|
vb2.size=tmp-second_via;
|
|
@@ -455,17 +457,17 @@ skip:
|
|
|
|
|
|
#ifdef DEBUG
|
|
#ifdef DEBUG
|
|
/* dump parsed data */
|
|
/* dump parsed data */
|
|
- printf(" first via: <%s/%s/%s> <%s:%d>",
|
|
|
|
|
|
+ DBG(" first via: <%s/%s/%s> <%s:%d>",
|
|
vb1.name, vb1.version, vb1.transport, vb1.host, vb1.port);
|
|
vb1.name, vb1.version, vb1.transport, vb1.host, vb1.port);
|
|
- if (vb1.params) printf(";<%s>", vb1.params);
|
|
|
|
- if (vb1.comment) printf(" <%s>", vb1.comment);
|
|
|
|
- printf ("\n");
|
|
|
|
|
|
+ if (vb1.params) DBG(";<%s>", vb1.params);
|
|
|
|
+ if (vb1.comment) DBG(" <%s>", vb1.comment);
|
|
|
|
+ DBG ("\n");
|
|
if (second_via){
|
|
if (second_via){
|
|
- printf(" second via: <%s/%s/%s> <%s:%d>",
|
|
|
|
|
|
+ DBG(" second via: <%s/%s/%s> <%s:%d>",
|
|
vb2.name, vb2.version, vb2.transport, vb2.host, vb2.port);
|
|
vb2.name, vb2.version, vb2.transport, vb2.host, vb2.port);
|
|
- if (vb2.params) printf(";<%s>", vb2.params);
|
|
|
|
- if (vb2.comment) printf(" <%s>", vb2.comment);
|
|
|
|
- printf ("\n");
|
|
|
|
|
|
+ if (vb2.params) DBG(";<%s>", vb2.params);
|
|
|
|
+ if (vb2.comment) DBG(" <%s>", vb2.comment);
|
|
|
|
+ DBG("\n");
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -475,7 +477,7 @@ skip:
|
|
memcpy(&(msg->via2), &vb2, sizeof(struct via_body));
|
|
memcpy(&(msg->via2), &vb2, sizeof(struct via_body));
|
|
|
|
|
|
#ifdef DEBUG
|
|
#ifdef DEBUG
|
|
- printf ("exiting parse_msg\n");
|
|
|
|
|
|
+ DBG("exiting parse_msg\n");
|
|
#endif
|
|
#endif
|
|
|
|
|
|
return 0;
|
|
return 0;
|