Browse code

- 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 authored on 24/03/2005 14:47:26
Showing 4 changed files
... ...
@@ -32,6 +32,7 @@
32 32
  *  2003-10-20  anchor_lump & del_lump will automatically choose the lump list
33 33
  *              based on  msg->eoh comparisons (andrei)
34 34
  *  2003-10-28  added extra checks (paranoia) for {anchor,del}_lump (andrei)
35
+ *  2005-03-24  the type of type attribute changed to enum _hdr_types_t (janakj)
35 36
  */
36 37
 
37 38
 
... ...
@@ -56,7 +57,7 @@ enum lump_dir { LD_NEXT, LD_BEFORE, LD_AFTER };
56 56
 /* adds a header to the end
57 57
  * returns  pointer on success, 0 on error */
58 58
 struct lump* append_new_lump(struct lump** list, char* new_hdr,
59
-							 int len, int type)
59
+							 int len, enum _hdr_types_t type)
60 60
 {
61 61
 	struct lump** t;
62 62
 	struct lump* tmp;
... ...
@@ -83,7 +84,7 @@ struct lump* append_new_lump(struct lump** list, char* new_hdr,
83 83
 /* inserts a header to the beginning 
84 84
  * returns pointer if success, 0 on error */
85 85
 struct lump* insert_new_lump(struct lump** list, char* new_hdr,
86
-								int len, int type)
86
+								int len, enum _hdr_types_t type)
87 87
 {
88 88
 	struct lump* tmp;
89 89
 
... ...
@@ -107,7 +108,7 @@ struct lump* insert_new_lump(struct lump** list, char* new_hdr,
107 107
 /* inserts a  header/data lump immediately after hdr 
108 108
  * returns pointer on success, 0 on error */
109 109
 struct lump* insert_new_lump_after( struct lump* after, char* new_hdr,
110
-							int len, int type)
110
+							int len, enum _hdr_types_t type)
111 111
 {
112 112
 	struct lump* tmp;
113 113
 
... ...
@@ -132,7 +133,7 @@ struct lump* insert_new_lump_after( struct lump* after, char* new_hdr,
132 132
 /* inserts a  header/data lump immediately before "before" 
133 133
  * returns pointer on success, 0 on error */
134 134
 struct lump* insert_new_lump_before( struct lump* before, char* new_hdr,
135
-							int len, int type)
135
+							int len, enum _hdr_types_t type)
136 136
 {
137 137
 	struct lump* tmp;
138 138
 
... ...
@@ -157,7 +158,7 @@ struct lump* insert_new_lump_before( struct lump* before, char* new_hdr,
157 157
 /* inserts a  subst lump immediately after hdr 
158 158
  * returns pointer on success, 0 on error */
159 159
 struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst,
160
-										int type)
160
+										enum _hdr_types_t type)
161 161
 {
162 162
 	struct lump* tmp;
163 163
 	
... ...
@@ -183,7 +184,7 @@ struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst,
183 183
  * returns pointer on success, 0 on error */
184 184
 struct lump* insert_subst_lump_before(	struct lump* before, 
185 185
 										enum lump_subst subst,
186
-										int type)
186
+										enum _hdr_types_t type)
187 187
 {
188 188
 	struct lump* tmp;
189 189
 	
... ...
@@ -208,7 +209,7 @@ struct lump* insert_subst_lump_before(	struct lump* before,
208 208
 /* inserts a  cond lump immediately after hdr 
209 209
  * returns pointer on success, 0 on error */
210 210
 struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c,
211
-										int type)
211
+										enum _hdr_types_t type)
212 212
 {
213 213
 	struct lump* tmp;
214 214
 	
... ...
@@ -234,7 +235,7 @@ struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c,
234 234
  * returns pointer on success, 0 on error */
235 235
 struct lump* insert_cond_lump_before(	struct lump* before, 
236 236
 										enum lump_conditions c,
237
-										int type)
237
+										enum _hdr_types_t type)
238 238
 {
239 239
 	struct lump* tmp;
240 240
 	
... ...
@@ -261,7 +262,7 @@ struct lump* insert_cond_lump_before(	struct lump* before,
261 261
  * msg->body_lumps list, depending on the offset being greater than msg->eoh,
262 262
  * so msg->eoh must be parsed (parse with HDR_EOH) if you think your lump
263 263
  *  might affect the body!! */
264
-struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type)
264
+struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type)
265 265
 {
266 266
 	struct lump* tmp;
267 267
 	struct lump* prev, *t;
... ...
@@ -317,7 +318,7 @@ struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type)
317 317
  * msg->body_lumps list, depending on the offset being greater than msg->eoh,
318 318
  * so msg->eoh must be parsed (parse with HDR_EOH) if you think your lump
319 319
  *  might affect the body!! */
320
-struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, int type)
320
+struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type)
321 321
 {
322 322
 	struct lump* tmp;
323 323
 	struct lump* prev, *t;
... ...
@@ -33,6 +33,7 @@
33 33
  *  2003-04-01  added opt (condition) lumps (andrei)
34 34
  *  2003-04-02  added more subst lumps: SUBST_{SND,RCV}_ALL  
35 35
  *              => ip:port;transport=proto (andrei)
36
+ *  2005-03-22  the type of type attribute changed to enum _hdr_types_t (janakj)
36 37
  *
37 38
  */
38 39
 
... ...
@@ -42,33 +43,34 @@
42 42
 
43 43
 #include "lump_struct.h"
44 44
 #include "parser/msg_parser.h"
45
+#include "parser/hf.h"
45 46
 
46 47
 /* adds a header to the end */
47 48
 struct lump* append_new_lump(struct lump** list, char* new_hdr,
48
-							 int len, int type);
49
+							 int len, enum _hdr_types_t type);
49 50
 /* inserts a header to the beginning */
50 51
 struct lump* insert_new_lump(struct lump** list, char* new_hdr,
51
-							  int len, int type);
52
+							  int len, enum _hdr_types_t type);
52 53
 struct lump* insert_new_lump_after(struct lump* after,
53
-									char* new_hdr, int len, int type);
54
+									char* new_hdr, int len, enum _hdr_types_t type);
54 55
 struct lump* insert_new_lump_before(struct lump* before, char* new_hdr,
55
-									int len,int type);
56
+									int len,enum _hdr_types_t type);
56 57
 /* substitutions (replace with ip address, port etc) */
57 58
 struct lump* insert_subst_lump_after(struct lump* after,  enum lump_subst subst,
58
-									int type);
59
+									enum _hdr_types_t type);
59 60
 struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst,
60
-									int type);
61
+									enum _hdr_types_t type);
61 62
 
62 63
 /* conditional lumps */
63 64
 struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c,
64
-									int type);
65
+									enum _hdr_types_t type);
65 66
 struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c,
66
-									int type);
67
+									enum _hdr_types_t type);
67 68
 
68 69
 /* removes an already existing header */
69
-struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type);
70
+struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type);
70 71
 /* set an anchor */
71
-struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, int type);
72
+struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type);
72 73
 
73 74
 
74 75
 
... ...
@@ -34,6 +34,7 @@
34 34
  *  2003-04-02  added more subst lumps: SUBST_{SND,RCV}_ALL  
35 35
  *              => ip:port;transport=proto (andrei)
36 36
  *  2003-10-20  split from data_lump.h (andrei)
37
+ *  2005-03-24  the type of type attribute changed to enum _hdr_types_t (janakj)
37 38
  *
38 39
  */
39 40
 
... ...
@@ -41,6 +42,7 @@
41 41
 #ifndef lump_struct_h
42 42
 #define lump_struct_h
43 43
 
44
+#include "./parser/hf.h"
44 45
 
45 46
 
46 47
 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 };
77 77
 
78 78
 
79 79
 struct lump{
80
-	int type; /* VIA, OTHER, UNSPEC(=0), ... */
80
+	enum _hdr_types_t type; /* HDR_VIA_T, HDR_OTHER_T (0), ... */
81 81
 	enum lump_op op;   /* DEL, ADD, NOP, UNSPEC(=0) */
82 82
 	
83 83
 	union{
... ...
@@ -53,9 +53,10 @@
53 53
 
54 54
 enum _hdr_types_t {
55 55
 	HDR_ERROR_T					= -1   /* Error while parsing */,
56
-	HDR_VIA_T					=  0   /* Via header field */,
57
-	HDR_VIA1_T					=  0   /* First Via header field */,
58
-	HDR_VIA2_T					=  1   /* only used as flag */,
56
+	HDR_OTHER_T                                     =  0   /* Some other header field */,
57
+	HDR_VIA_T					=  1   /* Via header field */,
58
+	HDR_VIA1_T					=  1   /* First Via header field */,
59
+	HDR_VIA2_T					=  2   /* only used as flag */,
59 60
 	HDR_TO_T					       /* To header field */,
60 61
 	HDR_FROM_T					       /* From header field */,
61 62
 	HDR_CSEQ_T					       /* CSeq header field */,
... ...
@@ -85,8 +86,7 @@ enum _hdr_types_t {
85 85
 	HDR_DIVERSION_T				       /* Diversion header field */,
86 86
 	HDR_RPID_T					       /* Remote-Party-ID header field */,
87 87
 	HDR_REFER_TO_T				       /* Refer-To header fiels */,
88
-	HDR_OTHER_T					       /* Some other header field */,
89
-	HDR_EOH_T					       /* end of headers */
88
+	HDR_EOH_T				       /* Some other header field */
90 89
 };
91 90
 
92 91