- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,96 +0,0 @@ |
1 |
-/* |
|
2 |
- * adding/removing headers or any other data chunk from a message |
|
3 |
- * |
|
4 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
5 |
- * |
|
6 |
- * This file is part of Kamailio, a free SIP server. |
|
7 |
- * |
|
8 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
9 |
- * it under the terms of the GNU General Public License as published by |
|
10 |
- * the Free Software Foundation; either version 2 of the License, or |
|
11 |
- * (at your option) any later version |
|
12 |
- * |
|
13 |
- * Kamailio is distributed in the hope that it will be useful, |
|
14 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
- * GNU General Public License for more details. |
|
17 |
- * |
|
18 |
- * You should have received a copy of the GNU General Public License |
|
19 |
- * along with this program; if not, write to the Free Software |
|
20 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
21 |
- */ |
|
22 |
- |
|
23 |
-/*! |
|
24 |
- * \file |
|
25 |
- * \brief Kamailio core :: Data_lumps |
|
26 |
- * \author jiri, andrei, janakj |
|
27 |
- * adding/removing headers or any other data chunk from a message |
|
28 |
- * \ingroup core |
|
29 |
- * Module: \ref core |
|
30 |
- */ |
|
31 |
- |
|
32 |
- |
|
33 |
-#ifndef data_lump_h |
|
34 |
-#define data_lump_h |
|
35 |
- |
|
36 |
-#include "lump_struct.h" |
|
37 |
-#include "parser/msg_parser.h" |
|
38 |
-#include "parser/hf.h" |
|
39 |
- |
|
40 |
- |
|
41 |
-/* adds a header right after an anchor point if exists */ |
|
42 |
-struct lump* add_new_lump(struct lump** list, char* new_hdr, |
|
43 |
- int len, enum _hdr_types_t type); |
|
44 |
- |
|
45 |
-/*! \brief adds a header to the end */ |
|
46 |
-struct lump* append_new_lump(struct lump** list, char* new_hdr, |
|
47 |
- int len, enum _hdr_types_t type); |
|
48 |
-/*! \brief inserts a header to the beginning */ |
|
49 |
-struct lump* insert_new_lump(struct lump** list, char* new_hdr, |
|
50 |
- int len, enum _hdr_types_t type); |
|
51 |
-struct lump* insert_new_lump_after(struct lump* after, |
|
52 |
- char* new_hdr, int len, enum _hdr_types_t type); |
|
53 |
-struct lump* insert_new_lump_before(struct lump* before, char* new_hdr, |
|
54 |
- int len,enum _hdr_types_t type); |
|
55 |
-/*! \brief substitutions (replace with ip address, port etc) */ |
|
56 |
-struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst, |
|
57 |
- enum _hdr_types_t type); |
|
58 |
-struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst, |
|
59 |
- enum _hdr_types_t type); |
|
60 |
- |
|
61 |
-/*! \brief conditional lumps */ |
|
62 |
-struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c, |
|
63 |
- enum _hdr_types_t type); |
|
64 |
-struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, |
|
65 |
- enum _hdr_types_t type); |
|
66 |
- |
|
67 |
-/* set an anchor if there is no existing one at the given offset, |
|
68 |
- * otherwise return the existing anchor */ |
|
69 |
-struct lump* anchor_lump2(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type, |
|
70 |
- int *is_ref); |
|
71 |
-/*! \brief removes an already existing header */ |
|
72 |
-struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
|
73 |
-/*! \brief set an anchor */ |
|
74 |
-struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
|
75 |
- |
|
76 |
- |
|
77 |
- |
|
78 |
-/*! \brief duplicates a lump list shallowly in pkg-mem */ |
|
79 |
-struct lump* dup_lump_list( struct lump *l ); |
|
80 |
-/*! \brief frees a shallowly duplicated lump list */ |
|
81 |
-void free_duped_lump_list(struct lump* l); |
|
82 |
- |
|
83 |
- |
|
84 |
-/*! \brief remove all non-SHMEM lumps from the list */ |
|
85 |
-void del_nonshm_lump( struct lump** lump_list ); |
|
86 |
- |
|
87 |
-/*! \brief remove the lump from the internal lists */ |
|
88 |
-int remove_lump(sip_msg_t *msg, struct lump *l); |
|
89 |
- |
|
90 |
-int sr_hdr_add(sip_msg_t *msg, str *sname, str *sbody); |
|
91 |
-int sr_hdr_add_zz(sip_msg_t *msg, char *hname, char *hbody); |
|
92 |
-int sr_hdr_add_zs(sip_msg_t *msg, char *hname, str *sbody); |
|
93 |
-int sr_hdr_del_z(sip_msg_t *msg, char *hname); |
|
94 |
-hdr_field_t *sr_hdr_get_z(sip_msg_t *msg, char *hname); |
|
95 |
- |
|
96 |
-#endif |
... | ... |
@@ -87,7 +87,9 @@ void del_nonshm_lump( struct lump** lump_list ); |
87 | 87 |
/*! \brief remove the lump from the internal lists */ |
88 | 88 |
int remove_lump(sip_msg_t *msg, struct lump *l); |
89 | 89 |
|
90 |
+int sr_hdr_add(sip_msg_t *msg, str *sname, str *sbody); |
|
90 | 91 |
int sr_hdr_add_zz(sip_msg_t *msg, char *hname, char *hbody); |
92 |
+int sr_hdr_add_zs(sip_msg_t *msg, char *hname, str *sbody); |
|
91 | 93 |
int sr_hdr_del_z(sip_msg_t *msg, char *hname); |
92 | 94 |
hdr_field_t *sr_hdr_get_z(sip_msg_t *msg, char *hname); |
93 | 95 |
|
... | ... |
@@ -86,4 +86,9 @@ void del_nonshm_lump( struct lump** lump_list ); |
86 | 86 |
|
87 | 87 |
/*! \brief remove the lump from the internal lists */ |
88 | 88 |
int remove_lump(sip_msg_t *msg, struct lump *l); |
89 |
+ |
|
90 |
+int sr_hdr_add_zz(sip_msg_t *msg, char *hname, char *hbody); |
|
91 |
+int sr_hdr_del_z(sip_msg_t *msg, char *hname); |
|
92 |
+hdr_field_t *sr_hdr_get_z(sip_msg_t *msg, char *hname); |
|
93 |
+ |
|
89 | 94 |
#endif |
... | ... |
@@ -1,18 +1,16 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 |
- * |
|
4 | 2 |
* adding/removing headers or any other data chunk from a message |
5 | 3 |
* |
6 | 4 |
* Copyright (C) 2001-2003 FhG Fokus |
7 | 5 |
* |
8 |
- * This file is part of ser, a free SIP server. |
|
6 |
+ * This file is part of Kamailio, a free SIP server. |
|
9 | 7 |
* |
10 |
- * ser is free software; you can redistribute it and/or modify |
|
8 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
11 | 9 |
* it under the terms of the GNU General Public License as published by |
12 | 10 |
* the Free Software Foundation; either version 2 of the License, or |
13 | 11 |
* (at your option) any later version |
14 | 12 |
* |
15 |
- * ser is distributed in the hope that it will be useful, |
|
13 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
16 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | 16 |
* GNU General Public License for more details. |
... | ... |
@@ -22,20 +20,11 @@ |
22 | 20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 | 21 |
*/ |
24 | 22 |
|
25 |
-/* History: |
|
26 |
- * -------- |
|
27 |
- * 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
|
28 |
- * 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei) |
|
29 |
- * 2003-04-01 added opt (condition) lumps (andrei) |
|
30 |
- * 2003-04-02 added more subst lumps: SUBST_{SND,RCV}_ALL |
|
31 |
- * => ip:port;transport=proto (andrei) |
|
32 |
- * 2005-03-22 the type of type attribute changed to enum _hdr_types_t (janakj) |
|
33 |
- * |
|
34 |
- */ |
|
35 |
- |
|
36 | 23 |
/*! |
37 | 24 |
* \file |
38 | 25 |
* \brief SIP-router core :: Data_lumps |
26 |
+ * \author jiri, andrei, janakj |
|
27 |
+ * adding/removing headers or any other data chunk from a message |
|
39 | 28 |
* \ingroup core |
40 | 29 |
* Module: \ref core |
41 | 30 |
*/ |
... | ... |
@@ -19,7 +19,7 @@ |
19 | 19 |
* |
20 | 20 |
* You should have received a copy of the GNU General Public License |
21 | 21 |
* along with this program; if not, write to the Free Software |
22 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
22 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
23 | 23 |
*/ |
24 | 24 |
|
25 | 25 |
/* History: |
... | ... |
@@ -75,11 +75,11 @@ struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c, |
75 | 75 |
struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, |
76 | 76 |
enum _hdr_types_t type); |
77 | 77 |
|
78 |
-/*! \brief removes an already existing header */ |
|
79 | 78 |
/* set an anchor if there is no existing one at the given offset, |
80 | 79 |
* otherwise return the existing anchor */ |
81 | 80 |
struct lump* anchor_lump2(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type, |
82 | 81 |
int *is_ref); |
82 |
+/*! \brief removes an already existing header */ |
|
83 | 83 |
struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
84 | 84 |
/*! \brief set an anchor */ |
85 | 85 |
struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
... | ... |
@@ -95,4 +95,6 @@ void free_duped_lump_list(struct lump* l); |
95 | 95 |
/*! \brief remove all non-SHMEM lumps from the list */ |
96 | 96 |
void del_nonshm_lump( struct lump** lump_list ); |
97 | 97 |
|
98 |
+/*! \brief remove the lump from the internal lists */ |
|
99 |
+int remove_lump(sip_msg_t *msg, struct lump *l); |
|
98 | 100 |
#endif |
The following new functions are introduces that can be used
to add new lumps:
- add_new_lump(): Add a data lump right after the anchor point
into the main lump list. Every "before" lump of the same
anchor point will preceed, every "after" lump will
follow this lump.
- anchor_lump2(): Return the anchor point at the given offset
if exists, otherwise create a new anchor.
... | ... |
@@ -48,6 +48,11 @@ |
48 | 48 |
#include "parser/msg_parser.h" |
49 | 49 |
#include "parser/hf.h" |
50 | 50 |
|
51 |
+ |
|
52 |
+/* adds a header right after an anchor point if exists */ |
|
53 |
+struct lump* add_new_lump(struct lump** list, char* new_hdr, |
|
54 |
+ int len, enum _hdr_types_t type); |
|
55 |
+ |
|
51 | 56 |
/*! \brief adds a header to the end */ |
52 | 57 |
struct lump* append_new_lump(struct lump** list, char* new_hdr, |
53 | 58 |
int len, enum _hdr_types_t type); |
... | ... |
@@ -71,6 +76,10 @@ struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, |
71 | 76 |
enum _hdr_types_t type); |
72 | 77 |
|
73 | 78 |
/*! \brief removes an already existing header */ |
79 |
+/* set an anchor if there is no existing one at the given offset, |
|
80 |
+ * otherwise return the existing anchor */ |
|
81 |
+struct lump* anchor_lump2(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type, |
|
82 |
+ int *is_ref); |
|
74 | 83 |
struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
75 | 84 |
/*! \brief set an anchor */ |
76 | 85 |
struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
... | ... |
@@ -12,11 +12,6 @@ |
12 | 12 |
* the Free Software Foundation; either version 2 of the License, or |
13 | 13 |
* (at your option) any later version |
14 | 14 |
* |
15 |
- * For a license to use the ser software under conditions |
|
16 |
- * other than those described here, or to purchase support for this |
|
17 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
18 |
- * info@iptel.org |
|
19 |
- * |
|
20 | 15 |
* ser is distributed in the hope that it will be useful, |
21 | 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
... | ... |
@@ -26,6 +21,7 @@ |
26 | 21 |
* along with this program; if not, write to the Free Software |
27 | 22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 | 23 |
*/ |
24 |
+ |
|
29 | 25 |
/* History: |
30 | 26 |
* -------- |
31 | 27 |
* 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
... | ... |
@@ -37,6 +33,13 @@ |
37 | 33 |
* |
38 | 34 |
*/ |
39 | 35 |
|
36 |
+/*! |
|
37 |
+ * \file |
|
38 |
+ * \brief SIP-router core :: Data_lumps |
|
39 |
+ * \ingroup core |
|
40 |
+ * Module: \ref core |
|
41 |
+ */ |
|
42 |
+ |
|
40 | 43 |
|
41 | 44 |
#ifndef data_lump_h |
42 | 45 |
#define data_lump_h |
... | ... |
@@ -45,42 +48,42 @@ |
45 | 48 |
#include "parser/msg_parser.h" |
46 | 49 |
#include "parser/hf.h" |
47 | 50 |
|
48 |
-/* adds a header to the end */ |
|
51 |
+/*! \brief adds a header to the end */ |
|
49 | 52 |
struct lump* append_new_lump(struct lump** list, char* new_hdr, |
50 | 53 |
int len, enum _hdr_types_t type); |
51 |
-/* inserts a header to the beginning */ |
|
54 |
+/*! \brief inserts a header to the beginning */ |
|
52 | 55 |
struct lump* insert_new_lump(struct lump** list, char* new_hdr, |
53 | 56 |
int len, enum _hdr_types_t type); |
54 | 57 |
struct lump* insert_new_lump_after(struct lump* after, |
55 | 58 |
char* new_hdr, int len, enum _hdr_types_t type); |
56 | 59 |
struct lump* insert_new_lump_before(struct lump* before, char* new_hdr, |
57 | 60 |
int len,enum _hdr_types_t type); |
58 |
-/* substitutions (replace with ip address, port etc) */ |
|
61 |
+/*! \brief substitutions (replace with ip address, port etc) */ |
|
59 | 62 |
struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst, |
60 | 63 |
enum _hdr_types_t type); |
61 | 64 |
struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst, |
62 | 65 |
enum _hdr_types_t type); |
63 | 66 |
|
64 |
-/* conditional lumps */ |
|
67 |
+/*! \brief conditional lumps */ |
|
65 | 68 |
struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c, |
66 | 69 |
enum _hdr_types_t type); |
67 | 70 |
struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, |
68 | 71 |
enum _hdr_types_t type); |
69 | 72 |
|
70 |
-/* removes an already existing header */ |
|
73 |
+/*! \brief removes an already existing header */ |
|
71 | 74 |
struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
72 |
-/* set an anchor */ |
|
75 |
+/*! \brief set an anchor */ |
|
73 | 76 |
struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); |
74 | 77 |
|
75 | 78 |
|
76 | 79 |
|
77 |
-/* duplicates a lump list shallowly in pkg-mem */ |
|
80 |
+/*! \brief duplicates a lump list shallowly in pkg-mem */ |
|
78 | 81 |
struct lump* dup_lump_list( struct lump *l ); |
79 |
-/* frees a shallowly duplicated lump list */ |
|
82 |
+/*! \brief frees a shallowly duplicated lump list */ |
|
80 | 83 |
void free_duped_lump_list(struct lump* l); |
81 | 84 |
|
82 | 85 |
|
83 |
-/* remove all non-SHMEM lumps from the list */ |
|
86 |
+/*! \brief remove all non-SHMEM lumps from the list */ |
|
84 | 87 |
void del_nonshm_lump( struct lump** lump_list ); |
85 | 88 |
|
86 | 89 |
#endif |
Credits go to Norman Brandinger who investigated the problem in detail and
proposed the solution.
... | ... |
@@ -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 |
|
- hdr_allocs_parse(hdr) macro added - return true if the header uses
allocated memory on parse field
... | ... |
@@ -77,4 +77,8 @@ struct lump* dup_lump_list( struct lump *l ); |
77 | 77 |
/* frees a shallowly duplicated lump list */ |
78 | 78 |
void free_duped_lump_list(struct lump* l); |
79 | 79 |
|
80 |
+ |
|
81 |
+/* remove all non-SHMEM lumps from the list */ |
|
82 |
+void del_nonshm_lump( struct lump** lump_list ); |
|
83 |
+ |
|
80 | 84 |
#endif |
... | ... |
@@ -40,82 +40,8 @@ |
40 | 40 |
#ifndef data_lump_h |
41 | 41 |
#define data_lump_h |
42 | 42 |
|
43 |
- |
|
44 |
-enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST, LUMP_ADD_OPT }; |
|
45 |
-enum lump_subst{ SUBST_NOP=0, /* do nothing */ |
|
46 |
- SUBST_RCV_IP, SUBST_SND_IP, /* add ip address */ |
|
47 |
- SUBST_RCV_PORT, SUBST_SND_PORT, /* add port no */ |
|
48 |
- SUBST_RCV_PROTO, SUBST_SND_PROTO,/* add protocol(udp,tcp,tls)*/ |
|
49 |
- SUBST_RCV_ALL, SUBST_SND_ALL /* ip:port;transport=proto */ |
|
50 |
- }; |
|
51 |
- /* Where: |
|
52 |
- SND = sending, e.g the src ip of the outgoing message |
|
53 |
- RCV = received e.g the dst ip of the original incoming msg, |
|
54 |
- or the ip of the ser socket on which the msg was received |
|
55 |
- For SUBST_{RCV,SND}_ALL, :port is added only if port!=5060 |
|
56 |
- and transport=proto only if proto!=udp |
|
57 |
- */ |
|
58 |
- |
|
59 |
-enum lump_conditions { COND_FALSE, /* always false */ |
|
60 |
- COND_TRUE, /* always true */ |
|
61 |
- COND_IF_DIFF_REALMS,/* true if RCV realm != SND realm */ |
|
62 |
- COND_IF_DIFF_AF, /* true if RCV af != SND af */ |
|
63 |
- COND_IF_DIFF_PROTO, /* true if RCV proto != SND proto */ |
|
64 |
- COND_IF_DIFF_PORT, /* true if RCV port != SND port */ |
|
65 |
- COND_IF_DIFF_IP, /* true if RCV ip != SND ip */ |
|
66 |
- COND_IF_RAND /* 50-50 random prob.of being true*/ |
|
67 |
- }; |
|
68 |
- /* Where: |
|
69 |
- REALM= ip_addr:port:proto |
|
70 |
- af = address family (ipv4 or ipv6) |
|
71 |
- proto = protocol (tcp, udp, tls) |
|
72 |
- */ |
|
73 |
- |
|
74 |
-enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 }; |
|
75 |
- |
|
76 |
-struct lump{ |
|
77 |
- int type; /* VIA, OTHER, UNSPEC(=0), ... */ |
|
78 |
- enum lump_op op; /* DEL, ADD, NOP, UNSPEC(=0) */ |
|
79 |
- |
|
80 |
- union{ |
|
81 |
- int offset; /* used for DEL, MODIFY */ |
|
82 |
- enum lump_subst subst; /*what to subst: ip addr, port, proto*/ |
|
83 |
- enum lump_conditions cond; /* condition for LUMP_ADD_OPT */ |
|
84 |
- char * value; /* used for ADD */ |
|
85 |
- }u; |
|
86 |
- int len; /* length of this header field */ |
|
87 |
- |
|
88 |
- |
|
89 |
- struct lump* before; /* list of headers to be inserted in front of the |
|
90 |
- current one */ |
|
91 |
- struct lump* after; /* list of headers to be inserted immediately after |
|
92 |
- the current one */ |
|
93 |
- |
|
94 |
- struct lump* next; |
|
95 |
- |
|
96 |
- enum lump_flag flags; /* additional hints for use from TM's shmem */ |
|
97 |
-}; |
|
98 |
- |
|
99 |
-/* |
|
100 |
- * hdrs must be kept sorted after their offset (DEL, NOP, UNSPEC) |
|
101 |
- * and/or their position (ADD). E.g.: |
|
102 |
- * - to delete header Z insert it in to the list according to its offset |
|
103 |
- * and with op=DELETE |
|
104 |
- * - if you want to add a new header X after a header Y, insert Y in the list |
|
105 |
- * with op NOP and after it X (op ADD). |
|
106 |
- * - if you want X before Y, insert X in Y's before list. |
|
107 |
- * - if you want X to be the first header just put it first in hdr_lst. |
|
108 |
- * -if you want to replace Y with X, insert Y with op=DELETE and then X with |
|
109 |
- * op=ADD. |
|
110 |
- * before and after must contain only ADD ops! |
|
111 |
- * |
|
112 |
- * Difference between "after" & "next" when ADDing: |
|
113 |
- * "after" forces the new header immediately after the current one while |
|
114 |
- * "next" means another header can be inserted between them. |
|
115 |
- * |
|
116 |
- */ |
|
117 |
- |
|
118 |
- |
|
43 |
+#include "lump_struct.h" |
|
44 |
+#include "parser/msg_parser.h" |
|
119 | 45 |
|
120 | 46 |
/* adds a header to the end */ |
121 | 47 |
struct lump* append_new_lump(struct lump** list, char* new_hdr, |
... | ... |
@@ -140,15 +66,11 @@ struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, |
140 | 66 |
int type); |
141 | 67 |
|
142 | 68 |
/* removes an already existing header */ |
143 |
-struct lump* del_lump(struct lump** list, int offset, int len, int type); |
|
69 |
+struct lump* del_lump(struct sip_msg* msg, int offset, int len, int type); |
|
144 | 70 |
/* set an anchor */ |
145 |
-struct lump* anchor_lump(struct lump** list, int offset, int len, int type); |
|
71 |
+struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, int type); |
|
146 | 72 |
|
147 | 73 |
|
148 |
-/* frees the content of a lump struct */ |
|
149 |
-void free_lump(struct lump* l); |
|
150 |
-/*frees an entire lump list, recursively */ |
|
151 |
-void free_lump_list(struct lump* lump_list); |
|
152 | 74 |
|
153 | 75 |
/* duplicates a lump list shallowly in pkg-mem */ |
154 | 76 |
struct lump* dup_lump_list( struct lump *l ); |
... | ... |
@@ -31,6 +31,9 @@ |
31 | 31 |
* 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
32 | 32 |
* 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei) |
33 | 33 |
* 2003-04-01 added opt (condition) lumps (andrei) |
34 |
+ * 2003-04-02 added more subst lumps: SUBST_{SND,RCV}_ALL |
|
35 |
+ * => ip:port;transport=proto (andrei) |
|
36 |
+ * |
|
34 | 37 |
*/ |
35 | 38 |
|
36 | 39 |
|
... | ... |
@@ -42,12 +45,15 @@ enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST, LUMP_ADD_OPT }; |
42 | 45 |
enum lump_subst{ SUBST_NOP=0, /* do nothing */ |
43 | 46 |
SUBST_RCV_IP, SUBST_SND_IP, /* add ip address */ |
44 | 47 |
SUBST_RCV_PORT, SUBST_SND_PORT, /* add port no */ |
45 |
- SUBST_RCV_PROTO, SUBST_SND_PROTO /* add protocol */ |
|
48 |
+ SUBST_RCV_PROTO, SUBST_SND_PROTO,/* add protocol(udp,tcp,tls)*/ |
|
49 |
+ SUBST_RCV_ALL, SUBST_SND_ALL /* ip:port;transport=proto */ |
|
46 | 50 |
}; |
47 | 51 |
/* Where: |
48 | 52 |
SND = sending, e.g the src ip of the outgoing message |
49 | 53 |
RCV = received e.g the dst ip of the original incoming msg, |
50 | 54 |
or the ip of the ser socket on which the msg was received |
55 |
+ For SUBST_{RCV,SND}_ALL, :port is added only if port!=5060 |
|
56 |
+ and transport=proto only if proto!=udp |
|
51 | 57 |
*/ |
52 | 58 |
|
53 | 59 |
enum lump_conditions { COND_FALSE, /* always false */ |
... | ... |
@@ -127,6 +127,11 @@ struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst, |
127 | 127 |
struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst, |
128 | 128 |
int type); |
129 | 129 |
|
130 |
+/* conditional lumps */ |
|
131 |
+struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c, |
|
132 |
+ int type); |
|
133 |
+struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, |
|
134 |
+ int type); |
|
130 | 135 |
|
131 | 136 |
/* removes an already existing header */ |
132 | 137 |
struct lump* del_lump(struct lump** list, int offset, int len, int type); |
... | ... |
@@ -30,6 +30,7 @@ |
30 | 30 |
* -------- |
31 | 31 |
* 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
32 | 32 |
* 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei) |
33 |
+ * 2003-04-01 added opt (condition) lumps (andrei) |
|
33 | 34 |
*/ |
34 | 35 |
|
35 | 36 |
|
... | ... |
@@ -37,12 +38,33 @@ |
37 | 38 |
#define data_lump_h |
38 | 39 |
|
39 | 40 |
|
40 |
-enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST }; |
|
41 |
-enum lump_subst{ SUBST_NOP=0, |
|
42 |
- SUBST_RCV_IP, SUBST_SND_IP, |
|
43 |
- SUBST_RCV_PORT, SUBST_SND_PORT, |
|
44 |
- SUBST_RCV_PROTO, SUBST_SND_PROTO |
|
41 |
+enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST, LUMP_ADD_OPT }; |
|
42 |
+enum lump_subst{ SUBST_NOP=0, /* do nothing */ |
|
43 |
+ SUBST_RCV_IP, SUBST_SND_IP, /* add ip address */ |
|
44 |
+ SUBST_RCV_PORT, SUBST_SND_PORT, /* add port no */ |
|
45 |
+ SUBST_RCV_PROTO, SUBST_SND_PROTO /* add protocol */ |
|
45 | 46 |
}; |
47 |
+ /* Where: |
|
48 |
+ SND = sending, e.g the src ip of the outgoing message |
|
49 |
+ RCV = received e.g the dst ip of the original incoming msg, |
|
50 |
+ or the ip of the ser socket on which the msg was received |
|
51 |
+ */ |
|
52 |
+ |
|
53 |
+enum lump_conditions { COND_FALSE, /* always false */ |
|
54 |
+ COND_TRUE, /* always true */ |
|
55 |
+ COND_IF_DIFF_REALMS,/* true if RCV realm != SND realm */ |
|
56 |
+ COND_IF_DIFF_AF, /* true if RCV af != SND af */ |
|
57 |
+ COND_IF_DIFF_PROTO, /* true if RCV proto != SND proto */ |
|
58 |
+ COND_IF_DIFF_PORT, /* true if RCV port != SND port */ |
|
59 |
+ COND_IF_DIFF_IP, /* true if RCV ip != SND ip */ |
|
60 |
+ COND_IF_RAND /* 50-50 random prob.of being true*/ |
|
61 |
+ }; |
|
62 |
+ /* Where: |
|
63 |
+ REALM= ip_addr:port:proto |
|
64 |
+ af = address family (ipv4 or ipv6) |
|
65 |
+ proto = protocol (tcp, udp, tls) |
|
66 |
+ */ |
|
67 |
+ |
|
46 | 68 |
enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 }; |
47 | 69 |
|
48 | 70 |
struct lump{ |
... | ... |
@@ -52,6 +74,7 @@ struct lump{ |
52 | 74 |
union{ |
53 | 75 |
int offset; /* used for DEL, MODIFY */ |
54 | 76 |
enum lump_subst subst; /*what to subst: ip addr, port, proto*/ |
77 |
+ enum lump_conditions cond; /* condition for LUMP_ADD_OPT */ |
|
55 | 78 |
char * value; /* used for ADD */ |
56 | 79 |
}u; |
57 | 80 |
int len; /* length of this header field */ |
... | ... |
@@ -25,8 +25,11 @@ |
25 | 25 |
* You should have received a copy of the GNU General Public License |
26 | 26 |
* along with this program; if not, write to the Free Software |
27 | 27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
- * |
|
29 |
- * 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
|
28 |
+ */ |
|
29 |
+/* History: |
|
30 |
+ * -------- |
|
31 |
+ * 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
|
32 |
+ * 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei) |
|
30 | 33 |
*/ |
31 | 34 |
|
32 | 35 |
|
... | ... |
@@ -34,7 +37,12 @@ |
34 | 37 |
#define data_lump_h |
35 | 38 |
|
36 | 39 |
|
37 |
-enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD }; |
|
40 |
+enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST }; |
|
41 |
+enum lump_subst{ SUBST_NOP=0, |
|
42 |
+ SUBST_RCV_IP, SUBST_SND_IP, |
|
43 |
+ SUBST_RCV_PORT, SUBST_SND_PORT, |
|
44 |
+ SUBST_RCV_PROTO, SUBST_SND_PROTO |
|
45 |
+ }; |
|
38 | 46 |
enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 }; |
39 | 47 |
|
40 | 48 |
struct lump{ |
... | ... |
@@ -43,6 +51,7 @@ struct lump{ |
43 | 51 |
|
44 | 52 |
union{ |
45 | 53 |
int offset; /* used for DEL, MODIFY */ |
54 |
+ enum lump_subst subst; /*what to subst: ip addr, port, proto*/ |
|
46 | 55 |
char * value; /* used for ADD */ |
47 | 56 |
}u; |
48 | 57 |
int len; /* length of this header field */ |
... | ... |
@@ -89,6 +98,11 @@ struct lump* insert_new_lump_after(struct lump* after, |
89 | 98 |
char* new_hdr, int len, int type); |
90 | 99 |
struct lump* insert_new_lump_before(struct lump* before, char* new_hdr, |
91 | 100 |
int len,int type); |
101 |
+/* substitutions (replace with ip address, port etc) */ |
|
102 |
+struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst, |
|
103 |
+ int type); |
|
104 |
+struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst, |
|
105 |
+ int type); |
|
92 | 106 |
|
93 | 107 |
|
94 | 108 |
/* removes an already existing header */ |
... | ... |
@@ -25,6 +25,8 @@ |
25 | 25 |
* You should have received a copy of the GNU General Public License |
26 | 26 |
* along with this program; if not, write to the Free Software |
27 | 27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
+ * |
|
29 |
+ * 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
|
28 | 30 |
*/ |
29 | 31 |
|
30 | 32 |
|
... | ... |
@@ -32,12 +34,12 @@ |
32 | 34 |
#define data_lump_h |
33 | 35 |
|
34 | 36 |
|
35 |
-enum { LUMP_NOP=0, LUMP_DEL, LUMP_ADD }; |
|
36 |
-enum { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 }; |
|
37 |
+enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD }; |
|
38 |
+enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 }; |
|
37 | 39 |
|
38 | 40 |
struct lump{ |
39 | 41 |
int type; /* VIA, OTHER, UNSPEC(=0), ... */ |
40 |
- int op; /* DEL, ADD, NOP, UNSPEC(=0) */ |
|
42 |
+ enum lump_op op; /* DEL, ADD, NOP, UNSPEC(=0) */ |
|
41 | 43 |
|
42 | 44 |
union{ |
43 | 45 |
int offset; /* used for DEL, MODIFY */ |
... | ... |
@@ -53,7 +55,7 @@ struct lump{ |
53 | 55 |
|
54 | 56 |
struct lump* next; |
55 | 57 |
|
56 |
- int flags; /* additional hints for use from TM's shmem */ |
|
58 |
+ enum lump_flag flags; /* additional hints for use from TM's shmem */ |
|
57 | 59 |
}; |
58 | 60 |
|
59 | 61 |
/* |
... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
|
34 | 34 |
|
35 | 35 |
enum { LUMP_NOP=0, LUMP_DEL, LUMP_ADD }; |
36 |
+enum { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 }; |
|
36 | 37 |
|
37 | 38 |
struct lump{ |
38 | 39 |
int type; /* VIA, OTHER, UNSPEC(=0), ... */ |
... | ... |
@@ -51,6 +52,8 @@ struct lump{ |
51 | 52 |
the current one */ |
52 | 53 |
|
53 | 54 |
struct lump* next; |
55 |
+ |
|
56 |
+ int flags; /* additional hints for use from TM's shmem */ |
|
54 | 57 |
}; |
55 | 58 |
|
56 | 59 |
/* |
... | ... |
@@ -97,4 +100,9 @@ void free_lump(struct lump* l); |
97 | 100 |
/*frees an entire lump list, recursively */ |
98 | 101 |
void free_lump_list(struct lump* lump_list); |
99 | 102 |
|
103 |
+/* duplicates a lump list shallowly in pkg-mem */ |
|
104 |
+struct lump* dup_lump_list( struct lump *l ); |
|
105 |
+/* frees a shallowly duplicated lump list */ |
|
106 |
+void free_duped_lump_list(struct lump* l); |
|
107 |
+ |
|
100 | 108 |
#endif |
... | ... |
@@ -2,8 +2,32 @@ |
2 | 2 |
* $Id$ |
3 | 3 |
* |
4 | 4 |
* adding/removing headers or any other data chunk from a message |
5 |
+ * |
|
6 |
+ * Copyright (C) 2001-2003 Fhg Fokus |
|
7 |
+ * |
|
8 |
+ * This file is part of ser, a free SIP server. |
|
9 |
+ * |
|
10 |
+ * ser is free software; you can redistribute it and/or modify |
|
11 |
+ * it under the terms of the GNU General Public License as published by |
|
12 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
13 |
+ * (at your option) any later version |
|
14 |
+ * |
|
15 |
+ * For a license to use the ser software under conditions |
|
16 |
+ * other than those described here, or to purchase support for this |
|
17 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
18 |
+ * info@iptel.org |
|
19 |
+ * |
|
20 |
+ * ser is distributed in the hope that it will be useful, |
|
21 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
+ * GNU General Public License for more details. |
|
24 |
+ * |
|
25 |
+ * You should have received a copy of the GNU General Public License |
|
26 |
+ * along with this program; if not, write to the Free Software |
|
27 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
5 | 28 |
*/ |
6 | 29 |
|
30 |
+ |
|
7 | 31 |
#ifndef data_lump_h |
8 | 32 |
#define data_lump_h |
9 | 33 |
|
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,76 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * adding/removing headers or any other data chunk from a message |
|
5 |
+ */ |
|
6 |
+ |
|
7 |
+#ifndef data_lump_h |
|
8 |
+#define data_lump_h |
|
9 |
+ |
|
10 |
+ |
|
11 |
+enum { LUMP_NOP=0, LUMP_DEL, LUMP_ADD }; |
|
12 |
+ |
|
13 |
+struct lump{ |
|
14 |
+ int type; /* VIA, OTHER, UNSPEC(=0), ... */ |
|
15 |
+ int op; /* DEL, ADD, NOP, UNSPEC(=0) */ |
|
16 |
+ |
|
17 |
+ union{ |
|
18 |
+ int offset; /* used for DEL, MODIFY */ |
|
19 |
+ char * value; /* used for ADD */ |
|
20 |
+ }u; |
|
21 |
+ int len; /* length of this header field */ |
|
22 |
+ |
|
23 |
+ |
|
24 |
+ struct lump* before; /* list of headers to be inserted in front of the |
|
25 |
+ current one */ |
|
26 |
+ struct lump* after; /* list of headers to be inserted immediately after |
|
27 |
+ the current one */ |
|
28 |
+ |
|
29 |
+ struct lump* next; |
|
30 |
+}; |
|
31 |
+ |
|
32 |
+/* |
|
33 |
+ * hdrs must be kept sorted after their offset (DEL, NOP, UNSPEC) |
|
34 |
+ * and/or their position (ADD). E.g.: |
|
35 |
+ * - to delete header Z insert it in to the list according to its offset |
|
36 |
+ * and with op=DELETE |
|
37 |
+ * - if you want to add a new header X after a header Y, insert Y in the list |
|
38 |
+ * with op NOP and after it X (op ADD). |
|
39 |
+ * - if you want X before Y, insert X in Y's before list. |
|
40 |
+ * - if you want X to be the first header just put it first in hdr_lst. |
|
41 |
+ * -if you want to replace Y with X, insert Y with op=DELETE and then X with |
|
42 |
+ * op=ADD. |
|
43 |
+ * before and after must contain only ADD ops! |
|
44 |
+ * |
|
45 |
+ * Difference between "after" & "next" when ADDing: |
|
46 |
+ * "after" forces the new header immediately after the current one while |
|
47 |
+ * "next" means another header can be inserted between them. |
|
48 |
+ * |
|
49 |
+ */ |
|
50 |
+ |
|
51 |
+ |
|
52 |
+ |
|
53 |
+/* adds a header to the end */ |
|
54 |
+struct lump* append_new_lump(struct lump** list, char* new_hdr, |
|
55 |
+ int len, int type); |
|
56 |
+/* inserts a header to the beginning */ |
|
57 |
+struct lump* insert_new_lump(struct lump** list, char* new_hdr, |
|
58 |
+ int len, int type); |
|
59 |
+struct lump* insert_new_lump_after(struct lump* after, |
|
60 |
+ char* new_hdr, int len, int type); |
|
61 |
+struct lump* insert_new_lump_before(struct lump* before, char* new_hdr, |
|
62 |
+ int len,int type); |
|
63 |
+ |
|
64 |
+ |
|
65 |
+/* removes an already existing header */ |
|
66 |
+struct lump* del_lump(struct lump** list, int offset, int len, int type); |
|
67 |
+/* set an anchor */ |
|
68 |
+struct lump* anchor_lump(struct lump** list, int offset, int len, int type); |
|
69 |
+ |
|
70 |
+ |
|
71 |
+/* frees the content of a lump struct */ |
|
72 |
+void free_lump(struct lump* l); |
|
73 |
+/*frees an entire lump list, recursively */ |
|
74 |
+void free_lump_list(struct lump* lump_list); |
|
75 |
+ |
|
76 |
+#endif |