[Pkg-privacy-commits] [onioncat] 62/340: some cleanup and adapted code to freebsd again
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:25 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository onioncat.
commit 005dbb69d8725dfb19566bf8afb6467ee7515933
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date: Wed Sep 10 20:38:15 2008 +0000
some cleanup and adapted code to freebsd again
git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@278 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
config.h.in | 18 ++++++
configure | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++-
configure.ac | 34 ++++++++++-
src/ocat.c | 12 +---
src/ocat.h | 23 ++++----
src/ocatipv4route.c | 3 +
src/ocatroute.c | 152 ++++++++++++++++---------------------------------
src/ocatsetup.c | 5 +-
8 files changed, 278 insertions(+), 129 deletions(-)
diff --git a/config.h.in b/config.h.in
index 9921b07..0e776d7 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,5 +1,8 @@
/* config.h.in. Generated from configure.ac by autoheader. */
+/* Define to 1 if you have the <endian.h> header file. */
+#undef HAVE_ENDIAN_H
+
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
@@ -15,9 +18,15 @@
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
+/* Define to 1 if you have the <netinet/in_systm.h> header file. */
+#undef HAVE_NETINET_IN_SYSTM_H
+
/* Define to 1 if you have the <netinet/ip6.h> header file. */
#undef HAVE_NETINET_IP6_H
+/* Define to 1 if you have the <netinet/ip.h> header file. */
+#undef HAVE_NETINET_IP_H
+
/* Define to 1 if you have the <net/if.h> header file. */
#undef HAVE_NET_IF_H
@@ -33,9 +42,18 @@
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
+/* Define to 1 if the system has the type `struct ip'. */
+#undef HAVE_STRUCT_IP
+
/* Define to 1 if the system has the type `struct ip6_hdr'. */
#undef HAVE_STRUCT_IP6_HDR
+/* Define to 1 if the system has the type `struct iphdr'. */
+#undef HAVE_STRUCT_IPHDR
+
+/* Define to 1 if you have the <sys/endian.h> header file. */
+#undef HAVE_SYS_ENDIAN_H
+
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
diff --git a/configure b/configure
index 3dd505b..d380bd1 100755
--- a/configure
+++ b/configure
@@ -3351,7 +3351,11 @@ fi
-for ac_header in sys/types.h sys/socket.h netinet/in.h netinet/ip6.h netinet/in6.h net/if.h linux/if_tun.h net/if_tun.h linux/sockios.h
+
+
+
+
+for ac_header in sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -3375,6 +3379,9 @@ cat >>conftest.$ac_ext <<_ACEOF
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
+#ifdef HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
@@ -3612,6 +3619,157 @@ _ACEOF
fi
+{ echo "$as_me:$LINENO: checking for struct iphdr" >&5
+echo $ECHO_N "checking for struct iphdr... $ECHO_C" >&6; }
+if test "${ac_cv_type_struct_iphdr+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_NETINET_IP_H
+#include <netinet/ip.h>
+#endif
+
+
+typedef struct iphdr ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_type_struct_iphdr=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_struct_iphdr=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_struct_iphdr" >&5
+echo "${ECHO_T}$ac_cv_type_struct_iphdr" >&6; }
+if test $ac_cv_type_struct_iphdr = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_IPHDR 1
+_ACEOF
+
+
+fi
+
+
+{ echo "$as_me:$LINENO: checking for struct ip" >&5
+echo $ECHO_N "checking for struct ip... $ECHO_C" >&6; }
+if test "${ac_cv_type_struct_ip+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+#ifdef HAVE_NETINET_IP_H
+#include <netinet/ip.h>
+#endif
+
+
+typedef struct ip ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_type_struct_ip=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_struct_ip=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_struct_ip" >&5
+echo "${ECHO_T}$ac_cv_type_struct_ip" >&6; }
+if test $ac_cv_type_struct_ip = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_IP 1
+_ACEOF
+
+
+fi
+
+
{ echo "$as_me:$LINENO: checking for struct sockaddr_in.sin_len" >&5
echo $ECHO_N "checking for struct sockaddr_in.sin_len... $ECHO_C" >&6; }
if test "${ac_cv_member_struct_sockaddr_in_sin_len+set}" = set; then
diff --git a/configure.ac b/configure.ac
index 6df0500..04b8ae2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ AC_CHECK_LIB([pthread], [pthread_create])
# Checks for header files.
#AC_HEADER_STDC
#AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h])
-AC_CHECK_HEADERS([sys/types.h sys/socket.h netinet/in.h netinet/ip6.h netinet/in6.h net/if.h linux/if_tun.h net/if_tun.h linux/sockios.h], [], [],
+AC_CHECK_HEADERS([sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h], [], [],
[[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -31,6 +31,9 @@ AC_CHECK_HEADERS([sys/types.h sys/socket.h netinet/in.h netinet/ip6.h netinet/in
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
+#ifdef HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
]]
)
@@ -60,6 +63,35 @@ AC_CHECK_TYPES([struct ip6_hdr], , ,
#endif
])
+AC_CHECK_TYPES([struct iphdr], , ,
+[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_NETINET_IP_H
+#include <netinet/ip.h>
+#endif
+])
+
+AC_CHECK_TYPES([struct ip], , ,
+[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+#ifdef HAVE_NETINET_IP_H
+#include <netinet/ip.h>
+#endif
+])
+
AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
[ AC_DEFINE(HAVE_SIN_LEN, 1, [Do we have sockaddr_in.sin_len?]) ],
[],
diff --git a/src/ocat.c b/src/ocat.c
index 626756f..3a9001d 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -55,11 +55,9 @@ void usage(const char *s)
" -s <port> set hidden service virtual port, default = %d\n"
" -t <port> set tor SOCKS port, default = %d\n"
#ifndef WITHOUT_TUN
- " -p test tun header and exit (debug feature only)\n"
" -T <tun_device> path to tun character device, default = \"%s\"\n"
#endif
" -u <user> change UID to user, default = \"%s\"\n"
- " -v validate packets from sockets, default = %d (validation not mature)\n"
" -4 enable IPv4 support (default = %d)\n"
, PACKAGE_STRING, __DATE__, __TIME__, s,
// option defaults start here
@@ -67,7 +65,7 @@ void usage(const char *s)
#ifndef WITHOUT_TUN
TUN_DEV,
#endif
- OCAT_UNAME, setup.vrec, setup.ipv4_enable
+ OCAT_UNAME, setup.ipv4_enable
);
}
@@ -128,10 +126,6 @@ int main(int argc, char *argv[])
break;
#ifndef WITHOUT_TUN
- case 'p':
- setup.test_only = 1;
- break;
-
case 'T':
tun_dev_ = optarg;
break;
@@ -141,10 +135,6 @@ int main(int argc, char *argv[])
setup.usrname = optarg;
break;
- case 'v':
- setup.vrec = 1;
- break;
-
case '4':
setup.ipv4_enable = 1;
break;
diff --git a/src/ocat.h b/src/ocat.h
index 1c1663b..12fb0c8 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -32,8 +32,11 @@
#include <netinet/ip6.h>
#endif
#include <pthread.h>
+#ifdef HAVE_ENDIAN_H
#include <endian.h>
-
+#elif HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd
@@ -43,7 +46,7 @@
//! TOR prefix: FD87:D87E:EB43::/48
#define TOR_PREFIX {0xfd,0x87,0xd8,0x7e,0xeb,0x43}
#define TOR_PREFIX_LEN 48
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
#define TOR_PREFIX4 {0x0000000a}
#define TOR_PREFIX4_MASK 0x000000ff
#else
@@ -76,6 +79,7 @@
//! Maximum idle time for a peer, after that time the peer is closed.
#define MAX_IDLE_TIME 120
#define CLEANER_WAKEUP 10
+#define STAT_WAKEUP (120/CLEANER_WAKEUP)
//! log flags. word is considered as 16 bit, lower byte for level, upper byte for additional flags.
#define L_LEVEL_MASK 0x00ff
@@ -129,18 +133,19 @@ struct OcatSetup
uint16_t ocat_dest_port;
//! local port of controller interface
uint16_t ocat_ctrl_port;
- //! enable packet validation
- int vrec;
//! file descriptors of TUN device (usually tunfd[0] == tunfd[1])
int tunfd[2];
int debug_level;
+ //! user name to change uid to
char *usrname;
char onion_url[ONION_NAME_SIZE];
struct in6_addr ocat_addr;
+ //! flag to create connection log
int create_clog;
+ //! flag to not change uid to unprivileged user
int runasroot;
- int urlconv;
- int test_only;
+ //int urlconv;
+ //int test_only;
int controller;
char *ocat_dir;
char *tun_dev;
@@ -266,14 +271,13 @@ struct ip6_hdr
#ifndef WITHOUT_TUN
#define TUN_DEV "/dev/net/tun"
extern char *tun_dev_;
-//extern uint32_t fhd_key_;
#endif
extern pthread_mutex_t thread_mutex_;
extern OcatThread_t *octh_;
/* ocat.c */
-//extern int tunfd_[];
+
/* ocatlog.c */
int open_connect_log(const char*);
@@ -294,7 +298,6 @@ int has_tor_prefix(const struct in6_addr *);
/* ocattun.c */
#ifndef WITHOUT_TUN
int tun_alloc(char *, struct in6_addr);
-void test_tun_hdr(void);
#endif
/* ocatroute.c */
@@ -336,8 +339,6 @@ void delete_peer(OcatPeer_t *);
extern struct OcatSetup setup;
/* ocatipv4route.c */
-//int ipv4_add_route(IPv4Route_t *);
-//IPv4Route_t *ipv4_lookup_route(uint32_t);
struct in6_addr *ipv4_lookup_route(uint32_t);
int parse_route(const char *);
void print_routes(FILE *);
diff --git a/src/ocatipv4route.c b/src/ocatipv4route.c
index 31fb715..3d305d3 100644
--- a/src/ocatipv4route.c
+++ b/src/ocatipv4route.c
@@ -32,6 +32,9 @@
#include <arpa/inet.h>
#include <pthread.h>
#include <errno.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
#include "ocat.h"
diff --git a/src/ocatroute.c b/src/ocatroute.c
index bc3c6b8..d5d669b 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -41,7 +41,12 @@
#ifdef HAVE_LINUX_SOCKIOS_H
#include <linux/sockios.h>
#endif
+#ifdef HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
+#endif
#include "ocat.h"
@@ -198,22 +203,6 @@ void *packet_dequeuer(void *p)
}
-const static char hdigit_[] = "0123456789abcdef";
-
-void hex_code_header(const char *frame, int len, char *buf)
-{
- int i;
-
- for (i = 0; i < len; i++, frame++)
- {
- *buf++ = hdigit_[(*frame >> 4) & 0x0f];
- *buf++ = hdigit_[*frame & 0x0f];
- *buf++ = ' ';
- }
- *--buf = '\0';
-}
-
-
/*! Check if source and destination address has
* the TOR IPv6 prefix.
* @return 0 on error or packet length else. */
@@ -235,22 +224,6 @@ int check_tor_prefix(const struct ip6_hdr *ihd)
}
-// do some packet validation
-int validate_frame(const struct ip6_hdr *ihd, int len)
-{
- char hexbuf[IP6HLEN * 3 + 1];
-
- if ((ihd->ip6_vfc & 0xf0) != 0x60)
- {
- hex_code_header((char*) ihd, len > IP6HLEN ? IP6HLEN : len, hexbuf);
- log_debug("header \"%s\"", hexbuf);
- return 0;
- }
-
- return check_tor_prefix(ihd);
-}
-
-
void cleanup_socket(int fd, OcatPeer_t *peer)
{
log_msg(L_NOTICE | L_FCONN, "fd %d reached EOF, closing.", fd);
@@ -419,14 +392,6 @@ void *socket_receiver(void *p)
len = ntohs(((struct ip6_hdr*)peer->fragbuf)->ip6_plen) + IP6HLEN;
peer->fraghdr = setup.fhd_key[IPV6_KEY];
-/*
- // set IP address if it is not set yet and frame is valid
- if (!memcmp(&peer->addr, &in6addr_any, sizeof(struct in6_addr)))
- {
- memcpy(&peer->addr, &((struct ip6_hdr*)peer->fragbuf)->ip6_src, sizeof(struct in6_addr));
- log_msg(L_NOTICE | L_FCONN, "incoming connection on %d from %s is now identified", peer->tcpfd,
- inet_ntop(AF_INET6, &peer->addr, addr, INET6_ADDRSTRLEN));
- }*/
}
// incoming packet seems to be IPv4
else if ((peer->fragbuf[0] & 0xf0) == 0x40)
@@ -437,15 +402,35 @@ void *socket_receiver(void *p)
peer->fraglen = 0;
break;
}
-
+
+ #ifdef HANDLE_HTTP
+ if (handle_http(peer))
+ {
+ log_msg(L_NOTICE | L_FCONN, "closing %d due to HTTP", peer->tcpfd);
+ close(peer->tcpfd);
+ unlock_peer(peer);
+ lock_peers();
+ delete_peer(peer);
+ unlock_peers();
+ }
+#endif
+
log_debug("identified IPv4 packet");
+#ifdef HAVE_STRUCT_IPHDR
if ((peer->fraglen < sizeof(struct iphdr)) || (peer->fraglen < ntohs(((struct iphdr*) peer->fragbuf)->tot_len)))
+#else
+ if ((peer->fraglen < sizeof(struct ip)) || (peer->fraglen < ntohs(((struct ip*) peer->fragbuf)->ip_len)))
+#endif
{
log_debug("keeping %d bytes frag", peer->fraglen);
break;
}
+#ifdef HAVE_STRUCT_IPHDR
len = ntohs(((struct iphdr*) peer->fragbuf)->tot_len);
+#else
+ len = ntohs(((struct ip*) peer->fragbuf)->ip_len);
+#endif
peer->fraghdr = setup.fhd_key[IPV4_KEY];
}
else
@@ -463,7 +448,11 @@ void *socket_receiver(void *p)
else if (peer->fraghdr == setup.fhd_key[IPV4_KEY])
{
// check if there is a route back
+#ifdef HAVE_STRUCT_IPHDR
if (!(in6 = ipv4_lookup_route(ntohl(((struct iphdr*) peer->fragbuf)->saddr))))
+#else
+ if (!(in6 = ipv4_lookup_route(ntohl(((struct ip*) peer->fragbuf)->ip_src.s_addr))))
+#endif
{
drop = 1;
log_debug("no route back");
@@ -501,68 +490,7 @@ void *socket_receiver(void *p)
} // while (peer->fraglen)
-#if 0
- while (peer->fraglen >= IP6HLEN)
- {
- // check frame
- plen = validate_frame((struct ip6_hdr*) peer->fragbuf, peer->fraglen);
-
- if (!plen)
- {
-#ifdef HANDLE_HTTP
- if (handle_http(peer))
- {
- log_msg(L_NOTICE | L_FCONN, "closing %d due to HTTP.", peer->tcpfd);
- close(peer->tcpfd);
- unlock_peer(peer);
- lock_peers();
- delete_peer(peer);
- unlock_peers();
- }
-#endif
- log_debug("FRAGBUF RESET!");
- peer->fraglen = 0;
- break;
- }
-
- if (setup.vrec && !plen)
- {
- log_msg(L_ERROR, "dropping frame");
- break;
- }
-
- len = plen + IP6HLEN;
- if (peer->fraglen < len)
- {
- log_debug("keeping %d bytes frag", peer->fraglen);
- break;
- }
-
- // set IP address if it is not set yet and frame is valid
- if (plen && !memcmp(&peer->addr, &in6addr_any, sizeof(struct in6_addr)))
- {
- memcpy(&peer->addr, &((struct ip6_hdr*)peer->fragbuf)->ip6_src, sizeof(struct in6_addr));
- log_msg(L_NOTICE | L_FCONN, "incoming connection on %d from %s is now identified", peer->tcpfd,
- inet_ntop(AF_INET6, &peer->addr, addr, INET6_ADDRSTRLEN));
- }
-
- log_debug("writing to tun %d framesize %d + 4", setup.tunfd[1], len);
- if (write(setup.tunfd[1], &peer->fraghdr, len + 4) != (len + 4))
- log_msg(L_ERROR, "could not write %d bytes to tunnel %d", len + 4, setup.tunfd[1]);
-
- peer->fraglen -= len;
-
- if (peer->fraglen)
- {
- log_debug("moving fragment. fragsize %d", peer->fraglen);
- memmove(peer->fragbuf, peer->fragbuf + len, FRAME_SIZE - 4 - len);
- }
- else
- log_debug("fragbuf empty");
- } // while (peer->fraglen >= IP6HLEN)
-#endif
-
- unlock_peer(peer);
+ unlock_peer(peer);
} // while (maxfd)
} // for (;;)
}
@@ -967,13 +895,21 @@ void packet_forwarder(void)
}
else if (*((uint32_t*) buf) == setup.fhd_key[IPV4_KEY])
{
+#ifdef HAVE_STRUCT_IPHDR
if (((rlen - 4) < sizeof(struct iphdr)))
+#else
+ if (((rlen - 4) < sizeof(struct ip)))
+#endif
{
log_debug("IPv4 packet too short (%d bytes). dropping", rlen - 4);
continue;
}
+#ifdef HAVE_STRUCT_IPHDR
in.s_addr = ((struct iphdr*) &buf[4])->daddr;
+#else
+ in.s_addr = ((struct ip*) &buf[4])->ip_dst.s_addr;
+#endif
if (!(dest = ipv4_lookup_route(ntohl(in.s_addr))))
{
log_msg(L_ERROR, "no route to destination %s, dropping frame.", inet_ntoa(in));
@@ -1001,11 +937,19 @@ void packet_forwarder(void)
void *socket_cleaner(void *ptr)
{
OcatPeer_t *peer, **p;
+ int cnt;
- for (;;)
+ for (cnt = STAT_WAKEUP; ; cnt--)
{
+ if (!cnt)
+ {
+ cnt = STAT_WAKEUP;
+ log_msg(L_NOTICE, "stats: ...");
+ }
+
sleep(CLEANER_WAKEUP);
log_debug("wakeup");
+
lock_peers();
for (p = get_first_peer_ptr(); *p; p = &(*p)->next)
{
diff --git a/src/ocatsetup.c b/src/ocatsetup.c
index 67e15b5..e79e797 100644
--- a/src/ocatsetup.c
+++ b/src/ocatsetup.c
@@ -26,7 +26,10 @@
#include "ocat.h"
-struct OcatSetup setup = {{0, 0}, TOR_SOCKS_PORT, OCAT_LISTEN_PORT, OCAT_DEST_PORT, OCAT_CTRL_PORT, 0, {0, 1}, 4, OCAT_UNAME, {0}, {{{0}}}, 0, 0, 0, 0, 1, OCAT_DIR, TUN_DEV,
+struct OcatSetup setup = {{0, 0}, TOR_SOCKS_PORT, OCAT_LISTEN_PORT, OCAT_DEST_PORT, OCAT_CTRL_PORT,
+ //! default tunfd is stdin/stdout
+ {0, 1},
+ 4, OCAT_UNAME, {0}, {{{0}}}, 0, 0, 1, OCAT_DIR, TUN_DEV,
0, TOR_PREFIX4, TOR_PREFIX4_MASK,
NULL, 1
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git
More information about the Pkg-privacy-commits
mailing list