msg_parser.h
512dcd98
 /*
  * $Id$
  */
 
 #ifndef msg_parser_h
 #define msg_parser_h
 
 
 #define SIP_REQUEST 1
 #define SIP_REPLY   2
 #define SIP_INVALID 0
 
 
 #define HDR_ERROR 0
 /* end of header */
 #define HDR_EOH   -1
 #define HDR_OTHER 1
 #define HDR_VIA   2
 #define HDR_TO    3
 
 #define VIA_PARSE_OK	1
 #define VIA_PARSE_ERROR -1
 
 #define SIP_VERSION	"SIP/2.0"
 
 
 struct msg_start{
 	int type;
 	union {
 		struct {
 			char* method;
 			char* uri;
 			char* version;
 		}request;
 		struct {
 			char* version;
 			char* status;
 			char* reason;
 		}reply;
 	}u;
 };
 
 struct hdr_field{   /* format: name':' body */
 	int type;
 	char* name;
 	char* body;
 };
 
 struct via_body{  /* format: name/version/transport host:port;params comment */
 	int error;
888ca09d
 	char *hdr;   /* contains "Via" or "v" */
512dcd98
 	char* name;
 	char* version;
 	char* transport;
 	char* host;
 	int port;
 	char* params;
 	char* comment;
888ca09d
 	int size;    /* full size, including hdr */
512dcd98
 	char* next; /* pointer to next via body string if compact via or null */
 };
 
888ca09d
 struct sip_msg{
 	struct msg_start first_line;
 	struct via_body via1;
 	struct via_body via2;
4ac74c03
 
a15c363f
 	unsigned int src_ip;
 	unsigned int dst_ip;
4ac74c03
 	char* orig; /* original message copy */
 	char* buf;  /* scratch pad, holds a modfied message,
 				   via, etc. point into it */
 				   
 	unsigned int len; /* message len (orig) */
7268726e
 
 	/* modifications */
 	char* new_uri; /* changed first line uri*/
4ac74c03
 	
888ca09d
 };
 
512dcd98
 
7268726e
 struct sip_uri{
 	char* user;
 	char* passwd;
 	char* host;
 	char* port;
 	char* params;
 	char* headers;
 };
 
 
512dcd98
 
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
 char* get_hdr_field(char *buffer, unsigned int len, struct hdr_field*  hdr_f);
 int field_name(char *s);
 char* parse_hostport(char* buf, char** host, short int* port);
 char* parse_via_body(char* buffer,unsigned int len, struct via_body * vb);
888ca09d
 int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
7268726e
 int parse_uri(char *buf, int len, struct sip_uri* uri);
512dcd98
 
 
 
 #endif