- 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,97 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
3 |
- * |
|
4 |
- * This file is part of Kamailio, a free SIP server. |
|
5 |
- * |
|
6 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
7 |
- * it under the terms of the GNU General Public License as published by |
|
8 |
- * the Free Software Foundation; either version 2 of the License, or |
|
9 |
- * (at your option) any later version |
|
10 |
- * |
|
11 |
- * Kamailio is distributed in the hope that it will be useful, |
|
12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
- * GNU General Public License for more details. |
|
15 |
- * |
|
16 |
- * You should have received a copy of the GNU General Public License |
|
17 |
- * along with this program; if not, write to the Free Software |
|
18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
- */ |
|
20 |
-/*! |
|
21 |
- * \file |
|
22 |
- * \brief Kamailio core :: Proxy |
|
23 |
- * \ingroup core |
|
24 |
- * \author andrei |
|
25 |
- * Module: \ref core |
|
26 |
- */ |
|
27 |
- |
|
28 |
-#ifndef proxy_h |
|
29 |
-#define proxy_h |
|
30 |
- |
|
31 |
-#include <netdb.h> |
|
32 |
-#include "ip_addr.h" |
|
33 |
-#include "str.h" |
|
34 |
-#include "config.h" |
|
35 |
- |
|
36 |
-struct proxy_l{ |
|
37 |
- struct proxy_l* next; |
|
38 |
- str name; /* original name */ |
|
39 |
- struct hostent host; /* addresses */ |
|
40 |
- unsigned short port; |
|
41 |
- unsigned short reserved; /*align*/ |
|
42 |
- int proto; |
|
43 |
- |
|
44 |
- /* socket ? */ |
|
45 |
- |
|
46 |
- int addr_idx; /* crt. addr. idx. */ |
|
47 |
- int ok; /* 0 on error */ |
|
48 |
- /*statistics*/ |
|
49 |
- int tx; |
|
50 |
- int tx_bytes; |
|
51 |
- int errors; |
|
52 |
-}; |
|
53 |
- |
|
54 |
-extern struct proxy_l* proxies; |
|
55 |
- |
|
56 |
-struct proxy_l* add_proxy(str* name, unsigned short port, int proto); |
|
57 |
-struct proxy_l* mk_proxy(str* name, unsigned short port, int proto); |
|
58 |
-struct proxy_l* mk_shm_proxy(str* name, unsigned short port, int proto); |
|
59 |
-struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port, |
|
60 |
- int proto); |
|
61 |
-void free_proxy(struct proxy_l* p); |
|
62 |
-void free_shm_proxy(struct proxy_l* p); |
|
63 |
- |
|
64 |
- |
|
65 |
- |
|
66 |
-/** returns 0 on success, -1 on error (unknown af/bug) */ |
|
67 |
-inline static int proxy2su(union sockaddr_union* su, struct proxy_l* p) |
|
68 |
-{ |
|
69 |
- /* if error try next ip address if possible */ |
|
70 |
- if (p->ok==0){ |
|
71 |
- if (p->host.h_addr_list[p->addr_idx+1]) |
|
72 |
- p->addr_idx++; |
|
73 |
- else p->addr_idx=0; |
|
74 |
- p->ok=1; |
|
75 |
- } |
|
76 |
- |
|
77 |
- return hostent2su(su, &p->host, p->addr_idx, |
|
78 |
- (p->port)?p->port:((p->proto==PROTO_TLS)?SIPS_PORT:SIP_PORT) ); |
|
79 |
-} |
|
80 |
- |
|
81 |
- |
|
82 |
- |
|
83 |
-/** mark proxy either as ok (err>=0) or as bad (err<0) */ |
|
84 |
-inline static void proxy_mark(struct proxy_l* p, int err) |
|
85 |
-{ |
|
86 |
- if (err<0){ |
|
87 |
- p->errors++; |
|
88 |
- p->ok=0; |
|
89 |
- }else{ |
|
90 |
- p->tx++; |
|
91 |
- } |
|
92 |
-} |
|
93 |
- |
|
94 |
- |
|
95 |
- |
|
96 |
-#endif |
|
97 |
- |
... | ... |
@@ -1,22 +1,14 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 |
- * |
|
4 |
- * |
|
5 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
6 | 3 |
* |
7 |
- * This file is part of ser, a free SIP server. |
|
4 |
+ * This file is part of Kamailio, a free SIP server. |
|
8 | 5 |
* |
9 |
- * ser is free software; you can redistribute it and/or modify |
|
6 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
10 | 7 |
* it under the terms of the GNU General Public License as published by |
11 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
12 | 9 |
* (at your option) any later version |
13 | 10 |
* |
14 |
- * For a license to use the ser software under conditions |
|
15 |
- * other than those described here, or to purchase support for this |
|
16 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
17 |
- * info@iptel.org |
|
18 |
- * |
|
19 |
- * ser is distributed in the hope that it will be useful, |
|
11 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
20 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | 14 |
* GNU General Public License for more details. |
... | ... |
@@ -25,12 +17,13 @@ |
25 | 17 |
* along with this program; if not, write to the Free Software |
26 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
27 | 19 |
*/ |
28 |
- /* |
|
29 |
- * History: |
|
30 |
- * ------- |
|
31 |
- * 2003-02-13 added proto to struct proxy_l & to *_proxy functions (andrei) |
|
32 |
- */ |
|
33 |
- |
|
20 |
+/*! |
|
21 |
+ * \file |
|
22 |
+ * \brief Kamailio core :: Proxy |
|
23 |
+ * \ingroup core |
|
24 |
+ * \author andrei |
|
25 |
+ * Module: \ref core |
|
26 |
+ */ |
|
34 | 27 |
|
35 | 28 |
#ifndef proxy_h |
36 | 29 |
#define proxy_h |
... | ... |
@@ -70,7 +63,7 @@ void free_shm_proxy(struct proxy_l* p); |
70 | 63 |
|
71 | 64 |
|
72 | 65 |
|
73 |
-/* returns 0 on success, -1 on error (unknown af/bug) */ |
|
66 |
+/** returns 0 on success, -1 on error (unknown af/bug) */ |
|
74 | 67 |
inline static int proxy2su(union sockaddr_union* su, struct proxy_l* p) |
75 | 68 |
{ |
76 | 69 |
/* if error try next ip address if possible */ |
... | ... |
@@ -87,7 +80,7 @@ inline static int proxy2su(union sockaddr_union* su, struct proxy_l* p) |
87 | 80 |
|
88 | 81 |
|
89 | 82 |
|
90 |
-/* mark as proxy either as ok (err>=0) or as bad (err<0) */ |
|
83 |
+/** mark proxy either as ok (err>=0) or as bad (err<0) */ |
|
91 | 84 |
inline static void proxy_mark(struct proxy_l* p, int err) |
92 | 85 |
{ |
93 | 86 |
if (err<0){ |
... | ... |
@@ -23,7 +23,7 @@ |
23 | 23 |
* |
24 | 24 |
* You should have received a copy of the GNU General Public License |
25 | 25 |
* along with this program; if not, write to the Free Software |
26 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
27 | 27 |
*/ |
28 | 28 |
/* |
29 | 29 |
* History: |
This patch adds function mk_shm_proxy, which is the shared memory
version of function mk_proxy. In addition to that it adds function
free_shm_proxy which is the shared memory version of free_proxy.
To avoid code duplication, we turned the body of the original
hostent_cpy function into macro called HOSTENT_CPY, the macro takes
malloc and free functions as parameters. The macro is then called in
the body of hostent_cpy with pkg_malloc and pkg_free as parameters and
in the body of hostent_shm_cpy with shm_malloc and shm_free as
parameters.
We did the same to mk_proxy function. The original body of the function
was converted into macro MK_PROXY which, again, takes memory allocation
functions as we all the hostent copy function as parameters.
... | ... |
@@ -62,9 +62,11 @@ extern struct proxy_l* proxies; |
62 | 62 |
|
63 | 63 |
struct proxy_l* add_proxy(str* name, unsigned short port, int proto); |
64 | 64 |
struct proxy_l* mk_proxy(str* name, unsigned short port, int proto); |
65 |
+struct proxy_l* mk_shm_proxy(str* name, unsigned short port, int proto); |
|
65 | 66 |
struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port, |
66 | 67 |
int proto); |
67 | 68 |
void free_proxy(struct proxy_l* p); |
69 |
+void free_shm_proxy(struct proxy_l* p); |
|
68 | 70 |
|
69 | 71 |
|
70 | 72 |
|
WARNING: not tested, use with care
... | ... |
@@ -38,6 +38,7 @@ |
38 | 38 |
#include <netdb.h> |
39 | 39 |
#include "ip_addr.h" |
40 | 40 |
#include "str.h" |
41 |
+#include "config.h" |
|
41 | 42 |
|
42 | 43 |
struct proxy_l{ |
43 | 44 |
struct proxy_l* next; |
... | ... |
@@ -66,5 +67,36 @@ struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port, |
66 | 67 |
void free_proxy(struct proxy_l* p); |
67 | 68 |
|
68 | 69 |
|
70 |
+ |
|
71 |
+/* returns 0 on success, -1 on error (unknown af/bug) */ |
|
72 |
+inline static int proxy2su(union sockaddr_union* su, struct proxy_l* p) |
|
73 |
+{ |
|
74 |
+ /* if error try next ip address if possible */ |
|
75 |
+ if (p->ok==0){ |
|
76 |
+ if (p->host.h_addr_list[p->addr_idx+1]) |
|
77 |
+ p->addr_idx++; |
|
78 |
+ else p->addr_idx=0; |
|
79 |
+ p->ok=1; |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ return hostent2su(su, &p->host, p->addr_idx, |
|
83 |
+ (p->port)?p->port:((p->proto==PROTO_TLS)?SIPS_PORT:SIP_PORT) ); |
|
84 |
+} |
|
85 |
+ |
|
86 |
+ |
|
87 |
+ |
|
88 |
+/* mark as proxy either as ok (err>=0) or as bad (err<0) */ |
|
89 |
+inline static void proxy_mark(struct proxy_l* p, int err) |
|
90 |
+{ |
|
91 |
+ if (err<0){ |
|
92 |
+ p->errors++; |
|
93 |
+ p->ok=0; |
|
94 |
+ }else{ |
|
95 |
+ p->tx++; |
|
96 |
+ } |
|
97 |
+} |
|
98 |
+ |
|
99 |
+ |
|
100 |
+ |
|
69 | 101 |
#endif |
70 | 102 |
|
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
* $Id$ |
3 | 3 |
* |
4 | 4 |
* |
5 |
- * Copyright (C) 2001-2003 Fhg Fokus |
|
5 |
+ * Copyright (C) 2001-2003 FhG Fokus |
|
6 | 6 |
* |
7 | 7 |
* This file is part of ser, a free SIP server. |
8 | 8 |
* |
... | ... |
@@ -28,7 +28,7 @@ |
28 | 28 |
/* |
29 | 29 |
* History: |
30 | 30 |
* ------- |
31 |
- * 2003-02-13 added proto to struct proxy_l & to *_proxy fucntions (andrei) |
|
31 |
+ * 2003-02-13 added proto to struct proxy_l & to *_proxy functions (andrei) |
|
32 | 32 |
*/ |
33 | 33 |
|
34 | 34 |
|
... | ... |
@@ -51,7 +51,7 @@ struct proxy_l{ |
51 | 51 |
|
52 | 52 |
int addr_idx; /* crt. addr. idx. */ |
53 | 53 |
int ok; /* 0 on error */ |
54 |
- /*statisticis*/ |
|
54 |
+ /*statistics*/ |
|
55 | 55 |
int tx; |
56 | 56 |
int tx_bytes; |
57 | 57 |
int errors; |
old tag & version: pre6-tcp4
new tag & version (current): pre6-tcp5-tm
... | ... |
@@ -25,6 +25,11 @@ |
25 | 25 |
* along with this program; if not, write to the Free Software |
26 | 26 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
27 | 27 |
*/ |
28 |
+ /* |
|
29 |
+ * History: |
|
30 |
+ * ------- |
|
31 |
+ * 2003-02-13 added proto to struct proxy_l & to *_proxy fucntions (andrei) |
|
32 |
+ */ |
|
28 | 33 |
|
29 | 34 |
|
30 | 35 |
#ifndef proxy_h |
... | ... |
@@ -40,6 +45,7 @@ struct proxy_l{ |
40 | 45 |
struct hostent host; /* addresses */ |
41 | 46 |
unsigned short port; |
42 | 47 |
unsigned short reserved; /*align*/ |
48 |
+ int proto; |
|
43 | 49 |
|
44 | 50 |
/* socket ? */ |
45 | 51 |
|
... | ... |
@@ -53,9 +59,10 @@ struct proxy_l{ |
53 | 59 |
|
54 | 60 |
extern struct proxy_l* proxies; |
55 | 61 |
|
56 |
-struct proxy_l* add_proxy(str* name, unsigned short port); |
|
57 |
-struct proxy_l* mk_proxy(str* name, unsigned short port); |
|
58 |
-struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port); |
|
62 |
+struct proxy_l* add_proxy(str* name, unsigned short port, int proto); |
|
63 |
+struct proxy_l* mk_proxy(str* name, unsigned short port, int proto); |
|
64 |
+struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port, |
|
65 |
+ int proto); |
|
59 | 66 |
void free_proxy(struct proxy_l* p); |
60 | 67 |
|
61 | 68 |
|
... | ... |
@@ -32,10 +32,11 @@ |
32 | 32 |
|
33 | 33 |
#include <netdb.h> |
34 | 34 |
#include "ip_addr.h" |
35 |
+#include "str.h" |
|
35 | 36 |
|
36 | 37 |
struct proxy_l{ |
37 | 38 |
struct proxy_l* next; |
38 |
- char* name; /* original name */ |
|
39 |
+ str name; /* original name */ |
|
39 | 40 |
struct hostent host; /* addresses */ |
40 | 41 |
unsigned short port; |
41 | 42 |
unsigned short reserved; /*align*/ |
... | ... |
@@ -52,8 +53,8 @@ struct proxy_l{ |
52 | 53 |
|
53 | 54 |
extern struct proxy_l* proxies; |
54 | 55 |
|
55 |
-struct proxy_l* add_proxy(char* name, unsigned short port); |
|
56 |
-struct proxy_l* mk_proxy(char* name, unsigned short port); |
|
56 |
+struct proxy_l* add_proxy(str* name, unsigned short port); |
|
57 |
+struct proxy_l* mk_proxy(str* name, unsigned short port); |
|
57 | 58 |
struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port); |
58 | 59 |
void free_proxy(struct proxy_l* p); |
59 | 60 |
|
... | ... |
@@ -1,8 +1,32 @@ |
1 | 1 |
/* |
2 | 2 |
* $Id$ |
3 | 3 |
* |
4 |
+ * |
|
5 |
+ * Copyright (C) 2001-2003 Fhg Fokus |
|
6 |
+ * |
|
7 |
+ * This file is part of ser, a free SIP server. |
|
8 |
+ * |
|
9 |
+ * ser is free software; you can redistribute it and/or modify |
|
10 |
+ * it under the terms of the GNU General Public License as published by |
|
11 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
12 |
+ * (at your option) any later version |
|
13 |
+ * |
|
14 |
+ * For a license to use the ser software under conditions |
|
15 |
+ * other than those described here, or to purchase support for this |
|
16 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
17 |
+ * info@iptel.org |
|
18 |
+ * |
|
19 |
+ * ser is distributed in the hope that it will be useful, |
|
20 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
+ * GNU General Public License for more details. |
|
23 |
+ * |
|
24 |
+ * You should have received a copy of the GNU General Public License |
|
25 |
+ * along with this program; if not, write to the Free Software |
|
26 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
4 | 27 |
*/ |
5 | 28 |
|
29 |
+ |
|
6 | 30 |
#ifndef proxy_h |
7 | 31 |
#define proxy_h |
8 | 32 |
|
... | ... |
@@ -7,6 +7,7 @@ |
7 | 7 |
#define proxy_h |
8 | 8 |
|
9 | 9 |
#include <netdb.h> |
10 |
+#include "ip_addr.h" |
|
10 | 11 |
|
11 | 12 |
struct proxy_l{ |
12 | 13 |
struct proxy_l* next; |
... | ... |
@@ -29,7 +30,7 @@ extern struct proxy_l* proxies; |
29 | 30 |
|
30 | 31 |
struct proxy_l* add_proxy(char* name, unsigned short port); |
31 | 32 |
struct proxy_l* mk_proxy(char* name, unsigned short port); |
32 |
-struct proxy_l* mk_proxy_from_ip(unsigned int ip, unsigned short port); |
|
33 |
+struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port); |
|
33 | 34 |
void free_proxy(struct proxy_l* p); |
34 | 35 |
|
35 | 36 |
|
... | ... |
@@ -29,6 +29,7 @@ extern struct proxy_l* proxies; |
29 | 29 |
|
30 | 30 |
struct proxy_l* add_proxy(char* name, unsigned short port); |
31 | 31 |
struct proxy_l* mk_proxy(char* name, unsigned short port); |
32 |
+struct proxy_l* mk_proxy_from_ip(unsigned int ip, unsigned short port); |
|
32 | 33 |
void free_proxy(struct proxy_l* p); |
33 | 34 |
|
34 | 35 |
|
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,32 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ */ |
|
5 |
+ |
|
6 |
+#ifndef proxy_h |
|
7 |
+#define proxy_h |
|
8 |
+ |
|
9 |
+#include <netdb.h> |
|
10 |
+ |
|
11 |
+struct proxy_l{ |
|
12 |
+ struct proxy_l* next; |
|
13 |
+ char* name; /* original name */ |
|
14 |
+ struct hostent host; /* addresses */ |
|
15 |
+ unsigned short port; |
|
16 |
+ unsigned short reserved; /*align*/ |
|
17 |
+ |
|
18 |
+ /* socket ? */ |
|
19 |
+ |
|
20 |
+ int addr_idx; /* crt. addr. idx. */ |
|
21 |
+ int ok; /* 0 on error */ |
|
22 |
+ /*statisticis*/ |
|
23 |
+ int tx; |
|
24 |
+ int tx_bytes; |
|
25 |
+ int errors; |
|
26 |
+}; |
|
27 |
+ |
|
28 |
+extern struct proxy_l* proxies; |
|
29 |
+ |
|
30 |
+ |
|
31 |
+#endif |
|
32 |
+ |