Credits go to Norman Brandinger who investigated the problem in detail and
proposed the solution.
... | ... |
@@ -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 | 57 |
/* adds a header to the end |
57 | 58 |
* returns pointer on success, 0 on error */ |
58 | 59 |
struct lump* append_new_lump(struct lump** list, char* new_hdr, |
59 |
- int len, int type) |
|
60 |
+ int len, enum _hdr_types_t type) |
|
60 | 61 |
{ |
61 | 62 |
struct lump** t; |
62 | 63 |
struct lump* tmp; |
... | ... |
@@ -83,7 +84,7 @@ struct lump* append_new_lump(struct lump** list, char* new_hdr, |
83 | 84 |
/* inserts a header to the beginning |
84 | 85 |
* returns pointer if success, 0 on error */ |
85 | 86 |
struct lump* insert_new_lump(struct lump** list, char* new_hdr, |
86 |
- int len, int type) |
|
87 |
+ int len, enum _hdr_types_t type) |
|
87 | 88 |
{ |
88 | 89 |
struct lump* tmp; |
89 | 90 |
|
... | ... |
@@ -107,7 +108,7 @@ struct lump* insert_new_lump(struct lump** list, char* new_hdr, |
107 | 108 |
/* inserts a header/data lump immediately after hdr |
108 | 109 |
* returns pointer on success, 0 on error */ |
109 | 110 |
struct lump* insert_new_lump_after( struct lump* after, char* new_hdr, |
110 |
- int len, int type) |
|
111 |
+ int len, enum _hdr_types_t type) |
|
111 | 112 |
{ |
112 | 113 |
struct lump* tmp; |
113 | 114 |
|
... | ... |
@@ -132,7 +133,7 @@ struct lump* insert_new_lump_after( struct lump* after, char* new_hdr, |
132 | 133 |
/* inserts a header/data lump immediately before "before" |
133 | 134 |
* returns pointer on success, 0 on error */ |
134 | 135 |
struct lump* insert_new_lump_before( struct lump* before, char* new_hdr, |
135 |
- int len, int type) |
|
136 |
+ int len, enum _hdr_types_t type) |
|
136 | 137 |
{ |
137 | 138 |
struct lump* tmp; |
138 | 139 |
|
... | ... |
@@ -157,7 +158,7 @@ struct lump* insert_new_lump_before( struct lump* before, char* new_hdr, |
157 | 158 |
/* inserts a subst lump immediately after hdr |
158 | 159 |
* returns pointer on success, 0 on error */ |
159 | 160 |
struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst, |
160 |
- int type) |
|
161 |
+ enum _hdr_types_t type) |
|
161 | 162 |
{ |
162 | 163 |
struct lump* tmp; |
163 | 164 |
|
... | ... |
@@ -183,7 +184,7 @@ struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst, |
183 | 184 |
* returns pointer on success, 0 on error */ |
184 | 185 |
struct lump* insert_subst_lump_before( struct lump* before, |
185 | 186 |
enum lump_subst subst, |
186 |
- int type) |
|
187 |
+ enum _hdr_types_t type) |
|
187 | 188 |
{ |
188 | 189 |
struct lump* tmp; |
189 | 190 |
|
... | ... |
@@ -208,7 +209,7 @@ struct lump* insert_subst_lump_before( struct lump* before, |
208 | 209 |
/* inserts a cond lump immediately after hdr |
209 | 210 |
* returns pointer on success, 0 on error */ |
210 | 211 |
struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c, |
211 |
- int type) |
|
212 |
+ enum _hdr_types_t type) |
|
212 | 213 |
{ |
213 | 214 |
struct lump* tmp; |
214 | 215 |
|
... | ... |
@@ -234,7 +235,7 @@ struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c, |
234 | 235 |
* returns pointer on success, 0 on error */ |
235 | 236 |
struct lump* insert_cond_lump_before( struct lump* before, |
236 | 237 |
enum lump_conditions c, |
237 |
- int type) |
|
238 |
+ enum _hdr_types_t type) |
|
238 | 239 |
{ |
239 | 240 |
struct lump* tmp; |
240 | 241 |
|
... | ... |
@@ -261,7 +262,7 @@ struct lump* insert_cond_lump_before( struct lump* before, |
261 | 262 |
* msg->body_lumps list, depending on the offset being greater than msg->eoh, |
262 | 263 |
* so msg->eoh must be parsed (parse with HDR_EOH) if you think your lump |
263 | 264 |
* might affect the body!! */ |
264 |
-struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type) |
|
265 |
+struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type) |
|
265 | 266 |
{ |
266 | 267 |
struct lump* tmp; |
267 | 268 |
struct lump* prev, *t; |
... | ... |
@@ -317,7 +318,7 @@ struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type) |
317 | 318 |
* msg->body_lumps list, depending on the offset being greater than msg->eoh, |
318 | 319 |
* so msg->eoh must be parsed (parse with HDR_EOH) if you think your lump |
319 | 320 |
* might affect the body!! */ |
320 |
-struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, int type) |
|
321 |
+struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type) |
|
321 | 322 |
{ |
322 | 323 |
struct lump* tmp; |
323 | 324 |
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 | 43 |
|
43 | 44 |
#include "lump_struct.h" |
44 | 45 |
#include "parser/msg_parser.h" |
46 |
+#include "parser/hf.h" |
|
45 | 47 |
|
46 | 48 |
/* adds a header to the end */ |
47 | 49 |
struct lump* append_new_lump(struct lump** list, char* new_hdr, |
48 |
- int len, int type); |
|
50 |
+ int len, enum _hdr_types_t type); |
|
49 | 51 |
/* inserts a header to the beginning */ |
50 | 52 |
struct lump* insert_new_lump(struct lump** list, char* new_hdr, |
51 |
- int len, int type); |
|
53 |
+ int len, enum _hdr_types_t type); |
|
52 | 54 |
struct lump* insert_new_lump_after(struct lump* after, |
53 |
- char* new_hdr, int len, int type); |
|
55 |
+ char* new_hdr, int len, enum _hdr_types_t type); |
|
54 | 56 |
struct lump* insert_new_lump_before(struct lump* before, char* new_hdr, |
55 |
- int len,int type); |
|
57 |
+ int len,enum _hdr_types_t type); |
|
56 | 58 |
/* substitutions (replace with ip address, port etc) */ |
57 | 59 |
struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst, |
58 |
- int type); |
|
60 |
+ enum _hdr_types_t type); |
|
59 | 61 |
struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst, |
60 |
- int type); |
|
62 |
+ enum _hdr_types_t type); |
|
61 | 63 |
|
62 | 64 |
/* conditional lumps */ |
63 | 65 |
struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c, |
64 |
- int type); |
|
66 |
+ enum _hdr_types_t type); |
|
65 | 67 |
struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, |
66 |
- int type); |
|
68 |
+ enum _hdr_types_t type); |
|
67 | 69 |
|
68 | 70 |
/* removes an already existing header */ |
69 |
-struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type); |
|
71 |
+struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
|
70 | 72 |
/* set an anchor */ |
71 |
-struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, int type); |
|
73 |
+struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
|
72 | 74 |
|
73 | 75 |
|
74 | 76 |
|
... | ... |
@@ -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 | 42 |
#ifndef lump_struct_h |
42 | 43 |
#define lump_struct_h |
43 | 44 |
|
45 |
+#include "./parser/hf.h" |
|
44 | 46 |
|
45 | 47 |
|
46 | 48 |
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 | 79 |
|
78 | 80 |
|
79 | 81 |
struct lump{ |
80 |
- int type; /* VIA, OTHER, UNSPEC(=0), ... */ |
|
82 |
+ enum _hdr_types_t type; /* HDR_VIA_T, HDR_OTHER_T (0), ... */ |
|
81 | 83 |
enum lump_op op; /* DEL, ADD, NOP, UNSPEC(=0) */ |
82 | 84 |
|
83 | 85 |
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 | 86 |
HDR_DIVERSION_T /* Diversion header field */, |
86 | 87 |
HDR_RPID_T /* Remote-Party-ID header field */, |
87 | 88 |
HDR_REFER_TO_T /* Refer-To header fiels */, |
88 |
- HDR_OTHER_T /* Some other header field */, |
|
89 |
- HDR_EOH_T /* end of headers */ |
|
89 |
+ HDR_EOH_T /* Some other header field */ |
|
90 | 90 |
}; |
91 | 91 |
|
92 | 92 |
|