|
@@ -73,16 +73,15 @@
|
|
* 2008-08-08 sctp support (andrei)
|
|
* 2008-08-08 sctp support (andrei)
|
|
* 2008-08-19 -l support for mmultihomed addresses/addresses lists
|
|
* 2008-08-19 -l support for mmultihomed addresses/addresses lists
|
|
* (e.g. -l (eth0, 1.2.3.4, foo.bar) ) (andrei)
|
|
* (e.g. -l (eth0, 1.2.3.4, foo.bar) ) (andrei)
|
|
- * 2010-04-19 added daemon_status_fd pipe to communicate the parent process with
|
|
|
|
- the main process in daemonize mode, so the parent process can return
|
|
|
|
- the proper exit status code (ibc)
|
|
|
|
|
|
+ * 2010-04-19 added daemon_status_fd pipe to communicate the parent process
|
|
|
|
+ * with the main process in daemonize mode, so the parent process
|
|
|
|
+ * can return the proper exit status code (ibc)
|
|
*/
|
|
*/
|
|
|
|
|
|
-/*!
|
|
|
|
- * \file
|
|
|
|
- * \brief SIP-router core ::
|
|
|
|
- * \ingroup core
|
|
|
|
- * Module: \ref core
|
|
|
|
|
|
+/** intializations and startup.
|
|
|
|
+ * @file main.c
|
|
|
|
+ * @ingroup core
|
|
|
|
+ * Module: @ref core
|
|
*/
|
|
*/
|
|
|
|
|
|
/*! \defgroup core SIP-router core
|
|
/*! \defgroup core SIP-router core
|
|
@@ -148,6 +147,9 @@
|
|
#include "nonsip_hooks.h"
|
|
#include "nonsip_hooks.h"
|
|
#include "ut.h"
|
|
#include "ut.h"
|
|
#include "signals.h"
|
|
#include "signals.h"
|
|
|
|
+#ifdef USE_RAW_SOCKS
|
|
|
|
+#include "raw_sock.h"
|
|
|
|
+#endif /* USE_RAW_SOCKS */
|
|
#ifdef USE_TCP
|
|
#ifdef USE_TCP
|
|
#include "poll_types.h"
|
|
#include "poll_types.h"
|
|
#include "tcp_init.h"
|
|
#include "tcp_init.h"
|
|
@@ -439,6 +441,9 @@ struct socket_info* bind_address=0; /* pointer to the crt. proc.
|
|
listening address*/
|
|
listening address*/
|
|
struct socket_info* sendipv4; /* ipv4 socket to use when msg. comes from ipv6*/
|
|
struct socket_info* sendipv4; /* ipv4 socket to use when msg. comes from ipv6*/
|
|
struct socket_info* sendipv6; /* same as above for ipv6 */
|
|
struct socket_info* sendipv6; /* same as above for ipv6 */
|
|
|
|
+#ifdef USE_RAW_SOCKS
|
|
|
|
+int raw_udp4_send_sock = -1; /* raw socket used for sending udp4 packets */
|
|
|
|
+#endif /* USE_RAW_SOCKS */
|
|
#ifdef USE_TCP
|
|
#ifdef USE_TCP
|
|
struct socket_info* sendipv4_tcp;
|
|
struct socket_info* sendipv4_tcp;
|
|
struct socket_info* sendipv6_tcp;
|
|
struct socket_info* sendipv6_tcp;
|
|
@@ -1237,9 +1242,35 @@ int main_loop()
|
|
/* only one address, we ignore all the others */
|
|
/* only one address, we ignore all the others */
|
|
if (udp_init(udp_listen)==-1) goto error;
|
|
if (udp_init(udp_listen)==-1) goto error;
|
|
bind_address=udp_listen;
|
|
bind_address=udp_listen;
|
|
- if (bind_address->address.af==AF_INET)
|
|
|
|
|
|
+ if (bind_address->address.af==AF_INET) {
|
|
sendipv4=bind_address;
|
|
sendipv4=bind_address;
|
|
- else
|
|
|
|
|
|
+#ifdef USE_RAW_SOCKS
|
|
|
|
+ /* always try to have a raw socket opened if we are using ipv4 */
|
|
|
|
+ raw_udp4_send_sock = raw_socket(IPPROTO_RAW, 0, 0, 1);
|
|
|
|
+ if (raw_udp4_send_sock < 0) {
|
|
|
|
+ if ( default_core_cfg.udp4_raw > 0) {
|
|
|
|
+ /* force use raw socket failed */
|
|
|
|
+ ERR("could not initialize raw udp send socket (ipv4):"
|
|
|
|
+ " %s (%d)\n", strerror(errno), errno);
|
|
|
|
+ if (errno == EPERM)
|
|
|
|
+ ERR("could not initialize raw socket on startup"
|
|
|
|
+ " due to inadequate permissions, please"
|
|
|
|
+ " restart as root or with CAP_NET_RAW\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+ default_core_cfg.udp4_raw = 0; /* disabled */
|
|
|
|
+ } else {
|
|
|
|
+ register_fds(1);
|
|
|
|
+ if (default_core_cfg.udp4_raw < 0) {
|
|
|
|
+ /* auto-detect => use it */
|
|
|
|
+ default_core_cfg.udp4_raw = 1; /* enabled */
|
|
|
|
+ DBG("raw socket possible => turning it on\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#else
|
|
|
|
+ default_core.cfg.udp4_raw = 0;
|
|
|
|
+#endif /* USE_RAW_SOCKS */
|
|
|
|
+ } else
|
|
sendipv6=bind_address;
|
|
sendipv6=bind_address;
|
|
if (udp_listen->next){
|
|
if (udp_listen->next){
|
|
LOG(L_WARN, "WARNING: using only the first listen address"
|
|
LOG(L_WARN, "WARNING: using only the first listen address"
|
|
@@ -1363,6 +1394,34 @@ int main_loop()
|
|
/* children_no per each socket */
|
|
/* children_no per each socket */
|
|
cfg_register_child(children_no);
|
|
cfg_register_child(children_no);
|
|
}
|
|
}
|
|
|
|
+#ifdef USE_RAW_SOCKS
|
|
|
|
+ /* always try to have a raw socket opened if we are using ipv4 */
|
|
|
|
+ if (sendipv4) {
|
|
|
|
+ raw_udp4_send_sock = raw_socket(IPPROTO_RAW, 0, 0, 1);
|
|
|
|
+ if (raw_udp4_send_sock < 0) {
|
|
|
|
+ if ( default_core_cfg.udp4_raw > 0) {
|
|
|
|
+ /* force use raw socket failed */
|
|
|
|
+ ERR("could not initialize raw udp send socket (ipv4):"
|
|
|
|
+ " %s (%d)\n", strerror(errno), errno);
|
|
|
|
+ if (errno == EPERM)
|
|
|
|
+ ERR("could not initialize raw socket on startup"
|
|
|
|
+ " due to inadequate permissions, please"
|
|
|
|
+ " restart as root or with CAP_NET_RAW\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+ default_core_cfg.udp4_raw = 0; /* disabled */
|
|
|
|
+ } else {
|
|
|
|
+ register_fds(1);
|
|
|
|
+ if (default_core_cfg.udp4_raw < 0) {
|
|
|
|
+ /* auto-detect => use it */
|
|
|
|
+ default_core_cfg.udp4_raw = 1; /* enabled */
|
|
|
|
+ DBG("raw socket possible => turning it on\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#else
|
|
|
|
+ default_core_cfg.udp4_raw = 0;
|
|
|
|
+#endif /* USE_RAW_SOCKS */
|
|
#ifdef USE_SCTP
|
|
#ifdef USE_SCTP
|
|
if (!sctp_disable){
|
|
if (!sctp_disable){
|
|
for(si=sctp_listen; si; si=si->next){
|
|
for(si=sctp_listen; si; si=si->next){
|