- 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,150 +0,0 @@ |
1 |
-/* |
|
2 |
- * find & manage listen addresses |
|
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 |
-/*! \file |
|
24 |
- * \brief Kamailio core :: listen address |
|
25 |
- * This file contains code that initializes and handles Kamailio listen addresses |
|
26 |
- * lists (struct socket_info). It is used mainly on startup. |
|
27 |
- * |
|
28 |
- */ |
|
29 |
- |
|
30 |
- |
|
31 |
-#ifndef socket_info_h |
|
32 |
-#define socket_info_h |
|
33 |
- |
|
34 |
-#include "ip_addr.h" |
|
35 |
-#include "dprint.h" |
|
36 |
-#include "globals.h" |
|
37 |
- |
|
38 |
-/* This macro evaluates to the maximum length of string buffer needed to print |
|
39 |
- * the text description of any socket, not counting the terminating zero added |
|
40 |
- * by socket2str */ |
|
41 |
-#define MAX_SOCKET_STR (sizeof("unknown") - 1 + IP_ADDR_MAX_STR_SIZE + \ |
|
42 |
- INT2STR_MAX_LEN + 2 + 2) |
|
43 |
- |
|
44 |
-int socket2str(char* s, int* len, struct socket_info* si); |
|
45 |
-int socketinfo2str(char* s, int* len, struct socket_info* si, int mode); |
|
46 |
- |
|
47 |
-/* Helper macro that results in the default port based on the protocol */ |
|
48 |
-#define proto_default_port(proto) ((proto==PROTO_TLS)?SIPS_PORT:SIP_PORT) |
|
49 |
- |
|
50 |
-/* struct socket_info is defined in ip_addr.h */ |
|
51 |
- |
|
52 |
-extern struct socket_info* udp_listen; |
|
53 |
-#ifdef USE_TCP |
|
54 |
-extern struct socket_info* tcp_listen; |
|
55 |
-#endif |
|
56 |
-#ifdef USE_TLS |
|
57 |
-extern struct socket_info* tls_listen; |
|
58 |
-#endif |
|
59 |
-#ifdef USE_SCTP |
|
60 |
-extern struct socket_info* sctp_listen; |
|
61 |
-#endif |
|
62 |
- |
|
63 |
-extern enum sip_protos nxt_proto[PROTO_LAST+1]; |
|
64 |
- |
|
65 |
- |
|
66 |
- |
|
67 |
-/* flags for finding out the address types */ |
|
68 |
-#define SOCKET_T_IPV4 1 |
|
69 |
-#define SOCKET_T_IPV6 2 |
|
70 |
-#define SOCKET_T_UDP 4 |
|
71 |
-#define SOCKET_T_TCP 8 |
|
72 |
-#define SOCKET_T_TLS 16 |
|
73 |
-#define SOCKET_T_SCTP 32 |
|
74 |
- |
|
75 |
-extern int socket_types; |
|
76 |
- |
|
77 |
-void init_proto_order(void); |
|
78 |
- |
|
79 |
-int add_listen_iface(char* name, struct name_lst* nlst, |
|
80 |
- unsigned short port, unsigned short proto, |
|
81 |
- enum si_flags flags); |
|
82 |
-int add_listen_advertise_iface(char* name, struct name_lst* nlst, |
|
83 |
- unsigned short port, unsigned short proto, |
|
84 |
- char *useaddr, unsigned short useport, |
|
85 |
- enum si_flags flags); |
|
86 |
-int fix_all_socket_lists(void); |
|
87 |
-void print_all_socket_lists(void); |
|
88 |
-void print_aliases(void); |
|
89 |
- |
|
90 |
-struct socket_info* grep_sock_info(str* host, unsigned short port, |
|
91 |
- unsigned short proto); |
|
92 |
-struct socket_info* grep_sock_info_by_port(unsigned short port, |
|
93 |
- unsigned short proto); |
|
94 |
-struct socket_info* find_si(struct ip_addr* ip, unsigned short port, |
|
95 |
- unsigned short proto); |
|
96 |
- |
|
97 |
-struct socket_info** get_sock_info_list(unsigned short proto); |
|
98 |
- |
|
99 |
-int parse_phostport(char* s, char** host, int* hlen, |
|
100 |
- int* port, int* proto); |
|
101 |
- |
|
102 |
-int parse_proto(unsigned char* s, long len, int* proto); |
|
103 |
- |
|
104 |
-char* get_valid_proto_name(unsigned short proto); |
|
105 |
- |
|
106 |
-/* helper function: |
|
107 |
- * returns next protocol, if the last one is reached return 0 |
|
108 |
- * useful for cycling on the supported protocols |
|
109 |
- * order: udp, tcp, tls, sctp */ |
|
110 |
-static inline int next_proto(unsigned short proto) |
|
111 |
-{ |
|
112 |
- if (proto>PROTO_LAST) |
|
113 |
- LM_ERR("unknown proto %d\n", proto); |
|
114 |
- else |
|
115 |
- return nxt_proto[proto]; |
|
116 |
- return 0; |
|
117 |
-} |
|
118 |
- |
|
119 |
- |
|
120 |
- |
|
121 |
-/* gets first non-null socket_info structure |
|
122 |
- * (useful if for. e.g we are not listening on any udp sockets ) |
|
123 |
- */ |
|
124 |
-inline static struct socket_info* get_first_socket(void) |
|
125 |
-{ |
|
126 |
- if (udp_listen) return udp_listen; |
|
127 |
-#ifdef USE_TCP |
|
128 |
- else if (tcp_listen) return tcp_listen; |
|
129 |
-#endif |
|
130 |
-#ifdef USE_SCTP |
|
131 |
- else if (sctp_listen) return sctp_listen; |
|
132 |
-#endif |
|
133 |
-#ifdef USE_TCP |
|
134 |
-#ifdef USE_TLS |
|
135 |
- else if (tls_listen) return tls_listen; |
|
136 |
-#endif |
|
137 |
-#endif |
|
138 |
- return 0; |
|
139 |
-} |
|
140 |
- |
|
141 |
-/* structure to break down 'proto:host:port' */ |
|
142 |
-typedef struct _sr_phostp { |
|
143 |
- int proto; |
|
144 |
- str host; |
|
145 |
- int port; |
|
146 |
-} sr_phostp_t; |
|
147 |
- |
|
148 |
-struct socket_info* lookup_local_socket(str *phostp); |
|
149 |
- |
|
150 |
-#endif |
When using double route headers the selection of the outgoing
socket is only done on IP address if the port is omitted in that
route header. This fix defaults the port to 5060/5061 depending on
protocol so the correct listen socket is chosen. When no socket is
found it will fallback to the current behaviour keeping backwards
interoperability.
... | ... |
@@ -44,6 +44,8 @@ |
44 | 44 |
int socket2str(char* s, int* len, struct socket_info* si); |
45 | 45 |
int socketinfo2str(char* s, int* len, struct socket_info* si, int mode); |
46 | 46 |
|
47 |
+/* Helper macro that results in the default port based on the protocol */ |
|
48 |
+#define proto_default_port(proto) ((proto==PROTO_TLS)?SIPS_PORT:SIP_PORT) |
|
47 | 49 |
|
48 | 50 |
/* struct socket_info is defined in ip_addr.h */ |
49 | 51 |
|
... | ... |
@@ -1,22 +1,16 @@ |
1 |
-/* $Id$ |
|
2 |
- * |
|
1 |
+/* |
|
3 | 2 |
* find & manage listen addresses |
4 | 3 |
* |
5 | 4 |
* Copyright (C) 2001-2003 FhG Fokus |
6 | 5 |
* |
7 |
- * This file is part of ser, a free SIP server. |
|
6 |
+ * This file is part of Kamailio, a free SIP server. |
|
8 | 7 |
* |
9 |
- * ser is free software; you can redistribute it and/or modify |
|
8 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
10 | 9 |
* it under the terms of the GNU General Public License as published by |
11 | 10 |
* the Free Software Foundation; either version 2 of the License, or |
12 | 11 |
* (at your option) any later version |
13 | 12 |
* |
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, |
|
13 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
20 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | 16 |
* GNU General Public License for more details. |
... | ... |
@@ -25,14 +19,12 @@ |
25 | 19 |
* along with this program; if not, write to" the Free Software |
26 | 20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
27 | 21 |
*/ |
28 |
-/* |
|
29 |
- * This file contains code that initializes and handles ser listen addresses |
|
22 |
+ |
|
23 |
+/*! \file |
|
24 |
+ * \brief Kamailio core :: listen address |
|
25 |
+ * This file contains code that initializes and handles Kamailio listen addresses |
|
30 | 26 |
* lists (struct socket_info). It is used mainly on startup. |
31 | 27 |
* |
32 |
- * History: |
|
33 |
- * -------- |
|
34 |
- * 2003-10-22 created by andrei |
|
35 |
- * 2008-08-08 sctp support (andrei) |
|
36 | 28 |
*/ |
37 | 29 |
|
38 | 30 |
|
... | ... |
@@ -116,7 +116,7 @@ char* get_valid_proto_name(unsigned short proto); |
116 | 116 |
static inline int next_proto(unsigned short proto) |
117 | 117 |
{ |
118 | 118 |
if (proto>PROTO_LAST) |
119 |
- LOG(L_ERR, "ERROR: next_proto: unknown proto %d\n", proto); |
|
119 |
+ LM_ERR("unknown proto %d\n", proto); |
|
120 | 120 |
else |
121 | 121 |
return nxt_proto[proto]; |
122 | 122 |
return 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 |
* This file contains code that initializes and handles ser listen addresses |
... | ... |
@@ -105,6 +105,8 @@ struct socket_info** get_sock_info_list(unsigned short proto); |
105 | 105 |
int parse_phostport(char* s, char** host, int* hlen, |
106 | 106 |
int* port, int* proto); |
107 | 107 |
|
108 |
+int parse_proto(unsigned char* s, long len, int* proto); |
|
109 |
+ |
|
108 | 110 |
char* get_valid_proto_name(unsigned short proto); |
109 | 111 |
|
110 | 112 |
/* helper function: |
... | ... |
@@ -142,5 +144,13 @@ inline static struct socket_info* get_first_socket(void) |
142 | 144 |
return 0; |
143 | 145 |
} |
144 | 146 |
|
147 |
+/* structure to break down 'proto:host:port' */ |
|
148 |
+typedef struct _sr_phostp { |
|
149 |
+ int proto; |
|
150 |
+ str host; |
|
151 |
+ int port; |
|
152 |
+} sr_phostp_t; |
|
153 |
+ |
|
154 |
+struct socket_info* lookup_local_socket(str *phostp); |
|
145 | 155 |
|
146 | 156 |
#endif |
... | ... |
@@ -105,6 +105,8 @@ struct socket_info** get_sock_info_list(unsigned short proto); |
105 | 105 |
int parse_phostport(char* s, char** host, int* hlen, |
106 | 106 |
int* port, int* proto); |
107 | 107 |
|
108 |
+char* get_valid_proto_name(unsigned short proto); |
|
109 |
+ |
|
108 | 110 |
/* helper function: |
109 | 111 |
* returns next protocol, if the last one is reached return 0 |
110 | 112 |
* useful for cycling on the supported protocols |
In C language, a declaration in the form int f(); is equivalent to int f(...);, thus being able to accept an indefinit number of parameters. With the -Wstrict-prototypes GCC options, these declarations are reported as "function declaration isn’t a prototype".
On some cases, this may trick the compiler into generating unoptimized code (like preparing to handle variadic argument list).
In all cases having a declaration int f() and a definition inf f(int) is missleading, even if standard compliant.
This is still Work in Progress. (maybe adding the -Wstrict-prototypes option to default is desireable)
... | ... |
@@ -80,7 +80,7 @@ extern enum sip_protos nxt_proto[PROTO_LAST+1]; |
80 | 80 |
|
81 | 81 |
extern int socket_types; |
82 | 82 |
|
83 |
-void init_proto_order(); |
|
83 |
+void init_proto_order(void); |
|
84 | 84 |
|
85 | 85 |
int add_listen_iface(char* name, struct name_lst* nlst, |
86 | 86 |
unsigned short port, unsigned short proto, |
... | ... |
@@ -89,9 +89,9 @@ int add_listen_advertise_iface(char* name, struct name_lst* nlst, |
89 | 89 |
unsigned short port, unsigned short proto, |
90 | 90 |
char *useaddr, unsigned short useport, |
91 | 91 |
enum si_flags flags); |
92 |
-int fix_all_socket_lists(); |
|
93 |
-void print_all_socket_lists(); |
|
94 |
-void print_aliases(); |
|
92 |
+int fix_all_socket_lists(void); |
|
93 |
+void print_all_socket_lists(void); |
|
94 |
+void print_aliases(void); |
|
95 | 95 |
|
96 | 96 |
struct socket_info* grep_sock_info(str* host, unsigned short port, |
97 | 97 |
unsigned short proto); |
... | ... |
@@ -123,7 +123,7 @@ static inline int next_proto(unsigned short proto) |
123 | 123 |
/* gets first non-null socket_info structure |
124 | 124 |
* (useful if for. e.g we are not listening on any udp sockets ) |
125 | 125 |
*/ |
126 |
-inline static struct socket_info* get_first_socket() |
|
126 |
+inline static struct socket_info* get_first_socket(void) |
|
127 | 127 |
{ |
128 | 128 |
if (udp_listen) return udp_listen; |
129 | 129 |
#ifdef USE_TCP |
- listen parameter can be like:
listen=proto:ip:port advertise ip1:port1
- ip1 and port1 will be used to build Via and Route headers for messages
using the socket
... | ... |
@@ -50,6 +50,7 @@ |
50 | 50 |
INT2STR_MAX_LEN + 2 + 2) |
51 | 51 |
|
52 | 52 |
int socket2str(char* s, int* len, struct socket_info* si); |
53 |
+int socketinfo2str(char* s, int* len, struct socket_info* si, int mode); |
|
53 | 54 |
|
54 | 55 |
|
55 | 56 |
/* struct socket_info is defined in ip_addr.h */ |
... | ... |
@@ -84,6 +85,10 @@ void init_proto_order(); |
84 | 85 |
int add_listen_iface(char* name, struct name_lst* nlst, |
85 | 86 |
unsigned short port, unsigned short proto, |
86 | 87 |
enum si_flags flags); |
88 |
+int add_listen_advertise_iface(char* name, struct name_lst* nlst, |
|
89 |
+ unsigned short port, unsigned short proto, |
|
90 |
+ char *useaddr, unsigned short useport, |
|
91 |
+ enum si_flags flags); |
|
87 | 92 |
int fix_all_socket_lists(); |
88 | 93 |
void print_all_socket_lists(); |
89 | 94 |
void print_aliases(); |
- string representation of socket string takes in consideration IPv6
addresses
... | ... |
@@ -47,7 +47,7 @@ |
47 | 47 |
* the text description of any socket, not counting the terminating zero added |
48 | 48 |
* by socket2str */ |
49 | 49 |
#define MAX_SOCKET_STR (sizeof("unknown") - 1 + IP_ADDR_MAX_STR_SIZE + \ |
50 |
- INT2STR_MAX_LEN + 2) |
|
50 |
+ INT2STR_MAX_LEN + 2 + 2) |
|
51 | 51 |
|
52 | 52 |
int socket2str(char* s, int* len, struct socket_info* si); |
53 | 53 |
|
parse_phostport in sr and ser returned a list of pkg_malloc'ed
addresses belonging to the same multi-homed "group". For example
sctp:(1.2.3.4, 5.6.7.8):5080 is a valid address and it means
that this sctp listening socket must use multi-homing on the 2
IPs. However several kamailio modules use parse_phostport and
expect the old integer returning version. In this case it was
easier to split the function in the core into parse_phostport()
(old behaviour) and parse_phostport_mh() (returns list of MH
addresses) and make the core command line parser use the MH
supporting version.
... | ... |
@@ -97,7 +97,7 @@ struct socket_info* find_si(struct ip_addr* ip, unsigned short port, |
97 | 97 |
|
98 | 98 |
struct socket_info** get_sock_info_list(unsigned short proto); |
99 | 99 |
|
100 |
-struct name_lst* parse_phostport(char* s, char** host, int* hlen, |
|
100 |
+int parse_phostport(char* s, char** host, int* hlen, |
|
101 | 101 |
int* port, int* proto); |
102 | 102 |
|
103 | 103 |
/* helper function: |
This patch splits fix_sock_str into two function, socket2str and
fix_sock_str. The function socket2str is exported and can be used
to print the socket into a pre-allocated memory buffer. Function
fix_sock_str allocates the memory buffer and calls socket2str
internally.
The primary consumer of this change is the serial forking code in
tm module.
This patch also defines a new macro called MAX_SOCKET_STR which
evaluates to the maximum size of textual representation of any
socket.
... | ... |
@@ -43,6 +43,13 @@ |
43 | 43 |
#include "dprint.h" |
44 | 44 |
#include "globals.h" |
45 | 45 |
|
46 |
+/* This macro evaluates to the maximum length of string buffer needed to print |
|
47 |
+ * the text description of any socket, not counting the terminating zero added |
|
48 |
+ * by socket2str */ |
|
49 |
+#define MAX_SOCKET_STR (sizeof("unknown") - 1 + IP_ADDR_MAX_STR_SIZE + \ |
|
50 |
+ INT2STR_MAX_LEN + 2) |
|
51 |
+ |
|
52 |
+int socket2str(char* s, int* len, struct socket_info* si); |
|
46 | 53 |
|
47 | 54 |
|
48 | 55 |
/* struct socket_info is defined in ip_addr.h */ |
Function parse_phostport was originally defined static in file.c, some
of kamailio modules use the function and so we re-define it as public
and add a declaration to header file socket_info.h
... | ... |
@@ -90,6 +90,9 @@ struct socket_info* find_si(struct ip_addr* ip, unsigned short port, |
90 | 90 |
|
91 | 91 |
struct socket_info** get_sock_info_list(unsigned short proto); |
92 | 92 |
|
93 |
+struct name_lst* parse_phostport(char* s, char** host, int* hlen, |
|
94 |
+ int* port, int* proto); |
|
95 |
+ |
|
93 | 96 |
/* helper function: |
94 | 97 |
* returns next protocol, if the last one is reached return 0 |
95 | 98 |
* useful for cycling on the supported protocols |
... | ... |
@@ -88,7 +88,7 @@ struct socket_info* grep_sock_info_by_port(unsigned short port, |
88 | 88 |
struct socket_info* find_si(struct ip_addr* ip, unsigned short port, |
89 | 89 |
unsigned short proto); |
90 | 90 |
|
91 |
- |
|
91 |
+struct socket_info** get_sock_info_list(unsigned short proto); |
|
92 | 92 |
|
93 | 93 |
/* helper function: |
94 | 94 |
* returns next protocol, if the last one is reached return 0 |
- config support for sctp multi-homing (listen on multiple addresses in the
same time).
Format: sctp:(addr1, addr2, addr3)
sctp:(eth0) -> will listen on all eth0 addresses in the same
time
(eth0,lo) -> sctp will listen on all addresses from eth0 & lo
in the same time, while the other protocols will
create different socket for each of the addresses
(e.g.: for udp it would be equivalent with:
listen= udp:eth0 udp:lo)
The first address is always the main one.
Conflicts are resolved automatically, by removing the duplicates. Main
addresses have priority (e.g: sctp:(lo,eth0) sctp:(eth0,eth1) after
duplicate removal will become sctp:(lo) sctp:(eth0,eth1)).
- try to always keep the order in which listen addresses were given in
config (fixes reordering between interface names and hostnames, e.g.
listen= eth0 foo.bar resulted in ip(foo.bar) , ip(eth0) )
... | ... |
@@ -42,6 +42,9 @@ |
42 | 42 |
#include "ip_addr.h" |
43 | 43 |
#include "dprint.h" |
44 | 44 |
#include "globals.h" |
45 |
+ |
|
46 |
+ |
|
47 |
+ |
|
45 | 48 |
/* struct socket_info is defined in ip_addr.h */ |
46 | 49 |
|
47 | 50 |
extern struct socket_info* udp_listen; |
... | ... |
@@ -71,8 +74,9 @@ extern int socket_types; |
71 | 74 |
|
72 | 75 |
void init_proto_order(); |
73 | 76 |
|
74 |
-int add_listen_iface(char* name, unsigned short port, unsigned short proto, |
|
75 |
- enum si_flags flags); |
|
77 |
+int add_listen_iface(char* name, struct name_lst* nlst, |
|
78 |
+ unsigned short port, unsigned short proto, |
|
79 |
+ enum si_flags flags); |
|
76 | 80 |
int fix_all_socket_lists(); |
77 | 81 |
void print_all_socket_lists(); |
78 | 82 |
void print_aliases(); |
... | ... |
@@ -32,6 +32,7 @@ |
32 | 32 |
* History: |
33 | 33 |
* -------- |
34 | 34 |
* 2003-10-22 created by andrei |
35 |
+ * 2008-08-08 sctp support (andrei) |
|
35 | 36 |
*/ |
36 | 37 |
|
37 | 38 |
|
... | ... |
@@ -50,17 +51,26 @@ extern struct socket_info* tcp_listen; |
50 | 51 |
#ifdef USE_TLS |
51 | 52 |
extern struct socket_info* tls_listen; |
52 | 53 |
#endif |
54 |
+#ifdef USE_SCTP |
|
55 |
+extern struct socket_info* sctp_listen; |
|
56 |
+#endif |
|
57 |
+ |
|
58 |
+extern enum sip_protos nxt_proto[PROTO_LAST+1]; |
|
59 |
+ |
|
53 | 60 |
|
54 | 61 |
|
55 | 62 |
/* flags for finding out the address types */ |
56 |
-#define SOCKET_T_IPV4 1 |
|
57 |
-#define SOCKET_T_IPV6 2 |
|
58 |
-#define SOCKET_T_UDP 4 |
|
59 |
-#define SOCKET_T_TCP 8 |
|
60 |
-#define SOCKET_T_TLS 16 |
|
63 |
+#define SOCKET_T_IPV4 1 |
|
64 |
+#define SOCKET_T_IPV6 2 |
|
65 |
+#define SOCKET_T_UDP 4 |
|
66 |
+#define SOCKET_T_TCP 8 |
|
67 |
+#define SOCKET_T_TLS 16 |
|
68 |
+#define SOCKET_T_SCTP 32 |
|
61 | 69 |
|
62 | 70 |
extern int socket_types; |
63 | 71 |
|
72 |
+void init_proto_order(); |
|
73 |
+ |
|
64 | 74 |
int add_listen_iface(char* name, unsigned short port, unsigned short proto, |
65 | 75 |
enum si_flags flags); |
66 | 76 |
int fix_all_socket_lists(); |
... | ... |
@@ -74,35 +84,18 @@ struct socket_info* grep_sock_info_by_port(unsigned short port, |
74 | 84 |
struct socket_info* find_si(struct ip_addr* ip, unsigned short port, |
75 | 85 |
unsigned short proto); |
76 | 86 |
|
87 |
+ |
|
88 |
+ |
|
77 | 89 |
/* helper function: |
78 | 90 |
* returns next protocol, if the last one is reached return 0 |
79 |
- * useful for cycling on the supported protocols */ |
|
91 |
+ * useful for cycling on the supported protocols |
|
92 |
+ * order: udp, tcp, tls, sctp */ |
|
80 | 93 |
static inline int next_proto(unsigned short proto) |
81 | 94 |
{ |
82 |
- switch(proto){ |
|
83 |
- case PROTO_NONE: |
|
84 |
- return PROTO_UDP; |
|
85 |
- case PROTO_UDP: |
|
86 |
-#ifdef USE_TCP |
|
87 |
- return (tcp_disable)?0:PROTO_TCP; |
|
88 |
-#else |
|
89 |
- return 0; |
|
90 |
-#endif |
|
91 |
-#ifdef USE_TCP |
|
92 |
- case PROTO_TCP: |
|
93 |
-#ifdef USE_TLS |
|
94 |
- return (tls_disable)?0:PROTO_TLS; |
|
95 |
-#else |
|
96 |
- return 0; |
|
97 |
-#endif |
|
98 |
-#endif |
|
99 |
-#ifdef USE_TLS |
|
100 |
- case PROTO_TLS: |
|
101 |
- return 0; |
|
102 |
-#endif |
|
103 |
- default: |
|
95 |
+ if (proto>PROTO_LAST) |
|
104 | 96 |
LOG(L_ERR, "ERROR: next_proto: unknown proto %d\n", proto); |
105 |
- } |
|
97 |
+ else |
|
98 |
+ return nxt_proto[proto]; |
|
106 | 99 |
return 0; |
107 | 100 |
} |
108 | 101 |
|
... | ... |
@@ -116,6 +109,11 @@ inline static struct socket_info* get_first_socket() |
116 | 109 |
if (udp_listen) return udp_listen; |
117 | 110 |
#ifdef USE_TCP |
118 | 111 |
else if (tcp_listen) return tcp_listen; |
112 |
+#endif |
|
113 |
+#ifdef USE_SCTP |
|
114 |
+ else if (sctp_listen) return sctp_listen; |
|
115 |
+#endif |
|
116 |
+#ifdef USE_TCP |
|
119 | 117 |
#ifdef USE_TLS |
120 | 118 |
else if (tls_listen) return tls_listen; |
121 | 119 |
#endif |
... | ... |
@@ -69,6 +69,8 @@ void print_aliases(); |
69 | 69 |
|
70 | 70 |
struct socket_info* grep_sock_info(str* host, unsigned short port, |
71 | 71 |
unsigned short proto); |
72 |
+struct socket_info* grep_sock_info_by_port(unsigned short port, |
|
73 |
+ unsigned short proto); |
|
72 | 74 |
struct socket_info* find_si(struct ip_addr* ip, unsigned short port, |
73 | 75 |
unsigned short proto); |
74 | 76 |
|
... | ... |
@@ -43,12 +43,12 @@ |
43 | 43 |
#include "globals.h" |
44 | 44 |
/* struct socket_info is defined in ip_addr.h */ |
45 | 45 |
|
46 |
-struct socket_info* udp_listen; |
|
46 |
+extern struct socket_info* udp_listen; |
|
47 | 47 |
#ifdef USE_TCP |
48 |
-struct socket_info* tcp_listen; |
|
48 |
+extern struct socket_info* tcp_listen; |
|
49 | 49 |
#endif |
50 | 50 |
#ifdef USE_TLS |
51 |
-struct socket_info* tls_listen; |
|
51 |
+extern struct socket_info* tls_listen; |
|
52 | 52 |
#endif |
53 | 53 |
|
54 | 54 |
|
- The resolver is reinitialized by each child process separately
when dns_retr_time, dns_retr_no, dns_servers_no, or dns_use_search_list
is changed.
- dns_reinit is introduced: the resolver is reinitialized when the
variable is set to 1, and the variable is reseted to 0 again.
It can be set via RPC for example, when /etc/resolv.conf changes,
but none of the SER config parameters are affected.
- A callback function is called by each child process after the resolver
has been reinitialized, if DNS_WATCHDOG_SUPPORT is enabled.
- socket_types is changed to be a global variable, and set by
fix_all_socket_lists(), because we have to remember for
the socket types, and do not allow dns_try_ipv6 to be enabled if there
is no ipv6 interface.
- minor bug is corrected: the expiration check is removed from
dns_cache_clean() function, when non-expired entries are deleted.
... | ... |
@@ -59,10 +59,11 @@ struct socket_info* tls_listen; |
59 | 59 |
#define SOCKET_T_TCP 8 |
60 | 60 |
#define SOCKET_T_TLS 16 |
61 | 61 |
|
62 |
+extern int socket_types; |
|
62 | 63 |
|
63 | 64 |
int add_listen_iface(char* name, unsigned short port, unsigned short proto, |
64 | 65 |
enum si_flags flags); |
65 |
-int fix_all_socket_lists(int* socket_types); |
|
66 |
+int fix_all_socket_lists(); |
|
66 | 67 |
void print_all_socket_lists(); |
67 | 68 |
void print_aliases(); |
68 | 69 |
|
WARNING: there are a lot of changes in tm
... | ... |
@@ -52,9 +52,17 @@ struct socket_info* tls_listen; |
52 | 52 |
#endif |
53 | 53 |
|
54 | 54 |
|
55 |
+/* flags for finding out the address types */ |
|
56 |
+#define SOCKET_T_IPV4 1 |
|
57 |
+#define SOCKET_T_IPV6 2 |
|
58 |
+#define SOCKET_T_UDP 4 |
|
59 |
+#define SOCKET_T_TCP 8 |
|
60 |
+#define SOCKET_T_TLS 16 |
|
61 |
+ |
|
62 |
+ |
|
55 | 63 |
int add_listen_iface(char* name, unsigned short port, unsigned short proto, |
56 | 64 |
enum si_flags flags); |
57 |
-int fix_all_socket_lists(); |
|
65 |
+int fix_all_socket_lists(int* socket_types); |
|
58 | 66 |
void print_all_socket_lists(); |
59 | 67 |
void print_aliases(); |
60 | 68 |
|
... | ... |
@@ -59,6 +59,8 @@ void print_aliases(); |
59 | 59 |
|
60 | 60 |
struct socket_info* grep_sock_info(str* host, unsigned short port, |
61 | 61 |
unsigned short proto); |
62 |
+struct socket_info* find_si(struct ip_addr* ip, unsigned short port, |
|
63 |
+ unsigned short proto); |
|
62 | 64 |
|
63 | 65 |
/* helper function: |
64 | 66 |
* returns next protocol, if the last one is reached return 0 |
... | ... |
@@ -57,6 +57,8 @@ int fix_all_socket_lists(); |
57 | 57 |
void print_all_socket_lists(); |
58 | 58 |
void print_aliases(); |
59 | 59 |
|
60 |
+struct socket_info* grep_sock_info(str* host, unsigned short port, |
|
61 |
+ unsigned short proto); |
|
60 | 62 |
|
61 | 63 |
/* helper function: |
62 | 64 |
* returns next protocol, if the last one is reached return 0 |
... | ... |
@@ -108,5 +110,4 @@ inline static struct socket_info* get_first_socket() |
108 | 110 |
} |
109 | 111 |
|
110 | 112 |
|
111 |
- |
|
112 | 113 |
#endif |
... | ... |
@@ -68,14 +68,14 @@ static inline int next_proto(unsigned short proto) |
68 | 68 |
return PROTO_UDP; |
69 | 69 |
case PROTO_UDP: |
70 | 70 |
#ifdef USE_TCP |
71 |
- return PROTO_TCP; |
|
71 |
+ return (tcp_disable)?0:PROTO_TCP; |
|
72 | 72 |
#else |
73 | 73 |
return 0; |
74 | 74 |
#endif |
75 | 75 |
#ifdef USE_TCP |
76 | 76 |
case PROTO_TCP: |
77 | 77 |
#ifdef USE_TLS |
78 |
- return PROTO_TLS; |
|
78 |
+ return (tls_disable)?0:PROTO_TLS; |
|
79 | 79 |
#else |
80 | 80 |
return 0; |
81 | 81 |
#endif |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
* |
3 | 3 |
* find & manage listen addresses |
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 |
* |
... | ... |
@@ -60,7 +60,7 @@ void print_aliases(); |
60 | 60 |
|
61 | 61 |
/* helper function: |
62 | 62 |
* returns next protocol, if the last one is reached return 0 |
63 |
- * usefull for cycling on the supported protocols */ |
|
63 |
+ * useful for cycling on the supported protocols */ |
|
64 | 64 |
static inline int next_proto(unsigned short proto) |
65 | 65 |
{ |
66 | 66 |
switch(proto){ |
... | ... |
@@ -93,7 +93,7 @@ static inline int next_proto(unsigned short proto) |
93 | 93 |
|
94 | 94 |
|
95 | 95 |
/* gets first non-null socket_info structure |
96 |
- * (usefull if for. e.g we are not listening on any udp sockets ) |
|
96 |
+ * (useful if for. e.g we are not listening on any udp sockets ) |
|
97 | 97 |
*/ |
98 | 98 |
inline static struct socket_info* get_first_socket() |
99 | 99 |
{ |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,112 @@ |
1 |
+/* $Id$ |
|
2 |
+ * |
|
3 |
+ * find & manage listen addresses |
|
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 |
|
27 |
+ */ |
|
28 |
+/* |
|
29 |
+ * This file contains code that initializes and handles ser listen addresses |
|
30 |
+ * lists (struct socket_info). It is used mainly on startup. |
|
31 |
+ * |
|
32 |
+ * History: |
|
33 |
+ * -------- |
|
34 |
+ * 2003-10-22 created by andrei |
|
35 |
+ */ |
|
36 |
+ |
|
37 |
+ |
|
38 |
+#ifndef socket_info_h |
|
39 |
+#define socket_info_h |
|
40 |
+ |
|
41 |
+#include "ip_addr.h" |
|
42 |
+#include "dprint.h" |
|
43 |
+/* struct socket_info is defined in ip_addr.h */ |
|
44 |
+ |
|
45 |
+struct socket_info* udp_listen; |
|
46 |
+#ifdef USE_TCP |
|
47 |
+struct socket_info* tcp_listen; |
|
48 |
+#endif |
|
49 |
+#ifdef USE_TLS |
|
50 |
+struct socket_info* tls_listen; |
|
51 |
+#endif |
|
52 |
+ |
|
53 |
+ |
|
54 |
+int add_listen_iface(char* name, unsigned short port, unsigned short proto, |
|
55 |
+ enum si_flags flags); |
|
56 |
+int fix_all_socket_lists(); |
|
57 |
+void print_all_socket_lists(); |
|
58 |
+void print_aliases(); |
|
59 |
+ |
|
60 |
+ |
|
61 |
+/* helper function: |
|
62 |
+ * returns next protocol, if the last one is reached return 0 |
|
63 |
+ * usefull for cycling on the supported protocols */ |
|
64 |
+static inline int next_proto(unsigned short proto) |
|
65 |
+{ |
|
66 |
+ switch(proto){ |
|
67 |
+ case PROTO_NONE: |
|
68 |
+ return PROTO_UDP; |
|
69 |
+ case PROTO_UDP: |
|
70 |
+#ifdef USE_TCP |
|
71 |
+ return PROTO_TCP; |
|
72 |
+#else |
|
73 |
+ return 0; |
|
74 |
+#endif |
|
75 |
+#ifdef USE_TCP |
|
76 |
+ case PROTO_TCP: |
|
77 |
+#ifdef USE_TLS |
|
78 |
+ return PROTO_TLS; |
|
79 |
+#else |
|
80 |
+ return 0; |
|
81 |
+#endif |
|
82 |
+#endif |
|
83 |
+#ifdef USE_TLS |
|
84 |
+ case PROTO_TLS: |
|
85 |
+ return 0; |
|
86 |
+#endif |
|
87 |
+ default: |
|
88 |
+ LOG(L_ERR, "ERROR: next_proto: unknown proto %d\n", proto); |
|
89 |
+ } |
|
90 |
+ return 0; |
|
91 |
+} |
|
92 |
+ |
|
93 |
+ |
|
94 |
+ |
|
95 |
+/* gets first non-null socket_info structure |
|
96 |
+ * (usefull if for. e.g we are not listening on any udp sockets ) |
|
97 |
+ */ |
|
98 |
+inline static struct socket_info* get_first_socket() |
|
99 |
+{ |
|
100 |
+ if (udp_listen) return udp_listen; |
|
101 |
+#ifdef USE_TCP |
|
102 |
+ else if (tcp_listen) return tcp_listen; |
|
103 |
+#ifdef USE_TLS |
|
104 |
+ else if (tls_listen) return tls_listen; |
|
105 |
+#endif |
|
106 |
+#endif |
|
107 |
+ return 0; |
|
108 |
+} |
|
109 |
+ |
|
110 |
+ |
|
111 |
+ |
|
112 |
+#endif |