Browse code

parser directory cleanup

Jan Janak authored on 08/07/2002 17:53:33
Showing 8 changed files
... ...
@@ -228,7 +228,7 @@ int forward_reply(struct sip_msg* msg)
228 228
 	}
229 229
 	
230 230
 	/* we have to forward the reply stateless, so we need second via -bogdan*/
231
-	if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK))
231
+	if ((msg->via2==0) || (msg->via2->error!=PARSE_OK))
232 232
 	{
233 233
 		/* no second via => error */
234 234
 		LOG(L_ERR, "ERROR: forward_msg: no 2nd via found in reply\n");
... ...
@@ -246,7 +246,7 @@ int t_on_reply( struct sip_msg  *p_msg )
246 246
 	}
247 247
 
248 248
 	/* do we have via2 ? - maybe we'll need it for forwarding -bogdan*/
249
-	if ((p_msg->via2==0) || (p_msg->via2->error!=VIA_PARSE_OK)){
249
+	if ((p_msg->via2==0) || (p_msg->via2->error!=PARSE_OK)){
250 250
 		/* no second via => error */
251 251
 		LOG(L_ERR, "ERROR: t_on_reply: no 2nd via found in reply\n");
252 252
 		goto error;
... ...
@@ -66,7 +66,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
66 66
 			memset(vb,0,sizeof(struct via_body));
67 67
 			hdr->body.s=tmp;
68 68
 			tmp=parse_via(tmp, end, vb);
69
-			if (vb->error==VIA_PARSE_ERROR){
69
+			if (vb->error==PARSE_ERROR){
70 70
 				LOG(L_ERR, "ERROR: get_hdr_field: bad via\n");
71 71
 				pkg_free(vb);
72 72
 				goto error;
... ...
@@ -5,14 +5,11 @@
5 5
  * 
6 6
  */
7 7
 
8
-
9
-
10 8
 #include "../dprint.h"
11 9
 #include "msg_parser.h"
12 10
 #include "parser_f.h"
13 11
 #include "../mem/mem.h"
14 12
 
15
-
16 13
 /* grammar:
17 14
 	request  =  method SP uri SP version CRLF
18 15
 	response =  version SP status  SP reason  CRLF
... ...
@@ -7,16 +7,15 @@
7 7
 
8 8
 #include "../str.h"
9 9
 
10
-/* Message is a request */
10
+/* Message is request */
11 11
 #define SIP_REQUEST 1
12 12
 
13
-/* Message is a reply */
13
+/* Message is reply */
14 14
 #define SIP_REPLY   2
15 15
 
16 16
 /* Invalid message */
17 17
 #define SIP_INVALID 0
18 18
 
19
-
20 19
 #define SIP_VERSION "SIP/2.0"
21 20
 #define SIP_VERSION_LEN 7
22 21
 
... ...
@@ -29,6 +28,7 @@
29 28
 #define ACK_LEN 3
30 29
 #define BYE_LEN 3
31 30
 
31
+
32 32
 struct msg_start {
33 33
 	int type;                         /* Type of the Message - Request/Response */
34 34
 	union {
... ...
@@ -850,7 +850,7 @@ char* parse_via(char* buffer, char* end, struct via_body *vb)
850 850
 	struct via_param* param;
851 851
 
852 852
 parse_again:
853
-	vb->error=VIA_PARSE_ERROR;
853
+	vb->error=PARSE_ERROR;
854 854
 	/* parse start of via ( SIP/2.0/UDP    )*/
855 855
 	state=F_SIP;
856 856
 	for(tmp=buffer;tmp<end;tmp++){
... ...
@@ -1733,7 +1733,7 @@ endofpacket:
1733 1733
 	*/
1734 1734
 	/*DBG("parse_via: rest=<%s>\n", tmp);*/
1735 1735
 
1736
-	vb->error=VIA_PARSE_OK;
1736
+	vb->error=PARSE_OK;
1737 1737
 	vb->bsize=tmp-buffer;
1738 1738
 	if (vb->port_str.s){
1739 1739
 		vb->port=str2s((unsigned char*)vb->port_str.s, vb->port_str.len, &err);
... ...
@@ -1746,7 +1746,7 @@ endofpacket:
1746 1746
 	return tmp;
1747 1747
 nextvia:
1748 1748
 	DBG("parse_via: next_via\n");
1749
-	vb->error=VIA_PARSE_OK;
1749
+	vb->error=PARSE_OK;
1750 1750
 	vb->bsize=tmp-buffer;
1751 1751
 	if (vb->port_str.s){
1752 1752
 		vb->port=str2s((unsigned char*)vb->port_str.s, vb->port_str.len, &err);
... ...
@@ -1776,7 +1776,7 @@ error:
1776 1776
 	}else{
1777 1777
 		LOG(L_ERR, "ERROR: parse_via: via parse error\n");
1778 1778
 	}
1779
-	vb->error=VIA_PARSE_ERROR;
1779
+	vb->error=PARSE_ERROR;
1780 1780
 	return tmp;
1781 1781
 }
1782 1782
 
... ...
@@ -7,9 +7,6 @@
7 7
 
8 8
 #include "../str.h"
9 9
 
10
-#define VIA_PARSE_OK	1
11
-#define VIA_PARSE_ERROR -1
12
-
13 10
 /* via param types
14 11
  * WARNING: keep in sync w/ FIN_*, GEN_PARAM and PARAM_ERROR from via_parse.c
15 12
  */
... ...
@@ -64,7 +64,7 @@ int receive_msg(char* buf, unsigned int len, union sockaddr_union* src_su)
64 64
 	DBG("After parse_msg...\n");
65 65
 	if (msg->first_line.type==SIP_REQUEST){
66 66
 		/* sanity checks */
67
-		if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
67
+		if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
68 68
 			/* no via, send back error ? */
69 69
 			LOG(L_ERR, "ERROR: receive_msg: no via found in request\n");
70 70
 			goto error;
... ...
@@ -97,13 +97,13 @@ int receive_msg(char* buf, unsigned int len, union sockaddr_union* src_su)
97 97
 #endif
98 98
 	}else if (msg->first_line.type==SIP_REPLY){
99 99
 		/* sanity checks */
100
-		if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
100
+		if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
101 101
 			/* no via, send back error ? */
102 102
 			LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n");
103 103
 			goto error;
104 104
 		}
105 105
 #if 0
106
-		if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK)){
106
+		if ((msg->via2==0) || (msg->via2->error!=PARSE_OK)){
107 107
 			/* no second via => error? */
108 108
 			LOG(L_ERR, "ERROR: receive_msg: no 2nd via found in reply\n");
109 109
 			goto error;