2
0
Эх сурвалжийг харах

- the type of lump->op changed from int to enum _hdr_types-t
- the value of HDR_OTHER_T changed to 0
- the value of HDR_VIA1_t changed to 1 (to avoid conflict with value 0 given
as parameter to *_lump functions)

Credits go to Norman Brandinger who investigated the problem in detail and
proposed the solution.

Jan Janak 21 жил өмнө
parent
commit
182fea0e4b
4 өөрчлөгдсөн 31 нэмэгдсэн , 26 устгасан
  1. 11 10
      data_lump.c
  2. 12 10
      data_lump.h
  3. 3 1
      lump_struct.h
  4. 5 5
      parser/hf.h

+ 11 - 10
data_lump.c

@@ -32,6 +32,7 @@
  *  2003-10-20  anchor_lump & del_lump will automatically choose the lump list
  *              based on  msg->eoh comparisons (andrei)
  *  2003-10-28  added extra checks (paranoia) for {anchor,del}_lump (andrei)
+ *  2005-03-24  the type of type attribute changed to enum _hdr_types_t (janakj)
  */
 
 
@@ -56,7 +57,7 @@ enum lump_dir { LD_NEXT, LD_BEFORE, LD_AFTER };
 /* adds a header to the end
  * returns  pointer on success, 0 on error */
 struct lump* append_new_lump(struct lump** list, char* new_hdr,
-							 int len, int type)
+							 int len, enum _hdr_types_t type)
 {
 	struct lump** t;
 	struct lump* tmp;
@@ -83,7 +84,7 @@ struct lump* append_new_lump(struct lump** list, char* new_hdr,
 /* inserts a header to the beginning 
  * returns pointer if success, 0 on error */
 struct lump* insert_new_lump(struct lump** list, char* new_hdr,
-								int len, int type)
+								int len, enum _hdr_types_t type)
 {
 	struct lump* tmp;
 
@@ -107,7 +108,7 @@ struct lump* insert_new_lump(struct lump** list, char* new_hdr,
 /* inserts a  header/data lump immediately after hdr 
  * returns pointer on success, 0 on error */
 struct lump* insert_new_lump_after( struct lump* after, char* new_hdr,
-							int len, int type)
+							int len, enum _hdr_types_t type)
 {
 	struct lump* tmp;
 
@@ -132,7 +133,7 @@ struct lump* insert_new_lump_after( struct lump* after, char* new_hdr,
 /* inserts a  header/data lump immediately before "before" 
  * returns pointer on success, 0 on error */
 struct lump* insert_new_lump_before( struct lump* before, char* new_hdr,
-							int len, int type)
+							int len, enum _hdr_types_t type)
 {
 	struct lump* tmp;
 
@@ -157,7 +158,7 @@ struct lump* insert_new_lump_before( struct lump* before, char* new_hdr,
 /* inserts a  subst lump immediately after hdr 
  * returns pointer on success, 0 on error */
 struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst,
-										int type)
+										enum _hdr_types_t type)
 {
 	struct lump* tmp;
 	
@@ -183,7 +184,7 @@ struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst,
  * returns pointer on success, 0 on error */
 struct lump* insert_subst_lump_before(	struct lump* before, 
 										enum lump_subst subst,
-										int type)
+										enum _hdr_types_t type)
 {
 	struct lump* tmp;
 	
@@ -208,7 +209,7 @@ struct lump* insert_subst_lump_before(	struct lump* before,
 /* inserts a  cond lump immediately after hdr 
  * returns pointer on success, 0 on error */
 struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c,
-										int type)
+										enum _hdr_types_t type)
 {
 	struct lump* tmp;
 	
@@ -234,7 +235,7 @@ struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c,
  * returns pointer on success, 0 on error */
 struct lump* insert_cond_lump_before(	struct lump* before, 
 										enum lump_conditions c,
-										int type)
+										enum _hdr_types_t type)
 {
 	struct lump* tmp;
 	
@@ -261,7 +262,7 @@ struct lump* insert_cond_lump_before(	struct lump* before,
  * msg->body_lumps list, depending on the offset being greater than msg->eoh,
  * so msg->eoh must be parsed (parse with HDR_EOH) if you think your lump
  *  might affect the body!! */
-struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type)
+struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type)
 {
 	struct lump* tmp;
 	struct lump* prev, *t;
@@ -317,7 +318,7 @@ struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type)
  * msg->body_lumps list, depending on the offset being greater than msg->eoh,
  * so msg->eoh must be parsed (parse with HDR_EOH) if you think your lump
  *  might affect the body!! */
-struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, int type)
+struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type)
 {
 	struct lump* tmp;
 	struct lump* prev, *t;

+ 12 - 10
data_lump.h

@@ -33,6 +33,7 @@
  *  2003-04-01  added opt (condition) lumps (andrei)
  *  2003-04-02  added more subst lumps: SUBST_{SND,RCV}_ALL  
  *              => ip:port;transport=proto (andrei)
+ *  2005-03-22  the type of type attribute changed to enum _hdr_types_t (janakj)
  *
  */
 
@@ -42,33 +43,34 @@
 
 #include "lump_struct.h"
 #include "parser/msg_parser.h"
+#include "parser/hf.h"
 
 /* adds a header to the end */
 struct lump* append_new_lump(struct lump** list, char* new_hdr,
-							 int len, int type);
+							 int len, enum _hdr_types_t type);
 /* inserts a header to the beginning */
 struct lump* insert_new_lump(struct lump** list, char* new_hdr,
-							  int len, int type);
+							  int len, enum _hdr_types_t type);
 struct lump* insert_new_lump_after(struct lump* after,
-									char* new_hdr, int len, int type);
+									char* new_hdr, int len, enum _hdr_types_t type);
 struct lump* insert_new_lump_before(struct lump* before, char* new_hdr,
-									int len,int type);
+									int len,enum _hdr_types_t type);
 /* substitutions (replace with ip address, port etc) */
 struct lump* insert_subst_lump_after(struct lump* after,  enum lump_subst subst,
-									int type);
+									enum _hdr_types_t type);
 struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst,
-									int type);
+									enum _hdr_types_t type);
 
 /* conditional lumps */
 struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c,
-									int type);
+									enum _hdr_types_t type);
 struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c,
-									int type);
+									enum _hdr_types_t type);
 
 /* removes an already existing header */
-struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type);
+struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type);
 /* set an anchor */
-struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, int type);
+struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type);
 
 
 

+ 3 - 1
lump_struct.h

@@ -34,6 +34,7 @@
  *  2003-04-02  added more subst lumps: SUBST_{SND,RCV}_ALL  
  *              => ip:port;transport=proto (andrei)
  *  2003-10-20  split from data_lump.h (andrei)
+ *  2005-03-24  the type of type attribute changed to enum _hdr_types_t (janakj)
  *
  */
 
@@ -41,6 +42,7 @@
 #ifndef lump_struct_h
 #define lump_struct_h
 
+#include "./parser/hf.h"
 
 
 enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST, LUMP_ADD_OPT };
@@ -77,7 +79,7 @@ enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 };
 
 
 struct lump{
-	int type; /* VIA, OTHER, UNSPEC(=0), ... */
+	enum _hdr_types_t type; /* HDR_VIA_T, HDR_OTHER_T (0), ... */
 	enum lump_op op;   /* DEL, ADD, NOP, UNSPEC(=0) */
 	
 	union{

+ 5 - 5
parser/hf.h

@@ -53,9 +53,10 @@
 
 enum _hdr_types_t {
 	HDR_ERROR_T					= -1   /* Error while parsing */,
-	HDR_VIA_T					=  0   /* Via header field */,
-	HDR_VIA1_T					=  0   /* First Via header field */,
-	HDR_VIA2_T					=  1   /* only used as flag */,
+	HDR_OTHER_T                                     =  0   /* Some other header field */,
+	HDR_VIA_T					=  1   /* Via header field */,
+	HDR_VIA1_T					=  1   /* First Via header field */,
+	HDR_VIA2_T					=  2   /* only used as flag */,
 	HDR_TO_T					       /* To header field */,
 	HDR_FROM_T					       /* From header field */,
 	HDR_CSEQ_T					       /* CSeq header field */,
@@ -85,8 +86,7 @@ enum _hdr_types_t {
 	HDR_DIVERSION_T				       /* Diversion header field */,
 	HDR_RPID_T					       /* Remote-Party-ID header field */,
 	HDR_REFER_TO_T				       /* Refer-To header fiels */,
-	HDR_OTHER_T					       /* Some other header field */,
-	HDR_EOH_T					       /* end of headers */
+	HDR_EOH_T				       /* Some other header field */
 };