[PATCH] AICCU Beta2 and FreeBSD
![]()
Hello,
i pressed aiccu through the compiler on freebsd 4.10 and
freebsd 5.2.1. I did very little tests that failed in the moment.
But this is based on a my possible misunderstanding of the
configuration. I don't get aiccu also to run on my colinux box
so i have to work on it next.
regard.
meno
Here the patch
Only in aiccu.my/common: aiccu.o
diff -ru aiccu/common/aiccu_freebsd.c aiccu.my/common/aiccu_freebsd.c
--- aiccu/common/aiccu_freebsd.cMon Aug 30 21:20:54 2004
+++ aiccu.my/common/aiccu_freebsd.cWed Sep 1 21:56:50 2004
@@ -15,7 +15,7 @@
void aiccu_os_install()
{
// Just try to load it, doesn't really matter if it fails
-system("modprobe -q ipv6 2>/dev/null >/dev/null");
+//system("modprobe -q ipv6 2>/dev/null >/dev/null");
}
void aiccu_os_setup(struct TIC_Tunnel *hTunnel)
@@ -41,7 +41,8 @@
"ifconfig %s inet6 %s %s prefixlen 128 alias",
g_aiccu->ipv6_interface,
hTunnel->sIPv6_Local,
-hTunnel->sIPv6_Remote);
+hTunnel->nIPv6_PrefixLength);
+
aiccu_exec(
"route add -inet6 %s %s",
Only in aiccu.my/common: aiccu_freebsd.o
diff -ru aiccu/common/aiccu_kame.c aiccu.my/common/aiccu_kame.c
--- aiccu/common/aiccu_kame.cMon Aug 30 21:20:54 2004
+++ aiccu.my/common/aiccu_kame.cWed Sep 1 21:45:53 2004
@@ -41,7 +41,7 @@
"ifconfig %s inet6 %s %s prefixlen 128 alias",
g_aiccu->ipv6_interface,
hTunnel->sIPv6_Local,
-hTunnel->sIPv6_Remote);
+hTunnel->nIPv6_PrefixLength);
aiccu_exec(
"route add -inet6 %s %s",
Only in aiccu.my/common: aiccu_kame.o
Only in aiccu.my/common: aiccu_test.o
diff -ru aiccu/common/ayiya.c aiccu.my/common/ayiya.c
--- aiccu/common/ayiya.cMon Aug 30 19:08:59 2004
+++ aiccu.my/common/ayiya.cWed Sep 1 21:40:06 2004
@@ -326,24 +326,32 @@
// Forward the packet to the kernel
#ifndef _WIN32
{
+unsigned int c;
+#ifdef LINUX
struct
{
struct tun_pi pi;
char payload[2048];
} packet;
-unsigned int c;
memset(&packet, 0, sizeof(packet));
packet.pi.proto = htons(ETH_P_IPV6);
memcpy(&packet.payload, &s->payload, payloadlen);
-
// Forward the packet to the kernel
c = write(ayiya_fd, &packet, payloadlen+sizeof(struct tun_pi));
if (c != payloadlen+sizeof(struct tun_pi))
{
ayiya_log(LOG_ERR, &ci, cl, "[writer] Error while writing to TAP: %u != %u\n", c, payloadlen+sizeof(struct tun_pi));
}
+#else
+c = write(ayiya_fd, &s->payload, payloadlen);
+if (c != payloadlen)
+{
+ayiya_log(LOG_ERR, &ci, cl, "[writer] Error while writing to TAP: %u != %u\n", c, payloadlen);
+}
+#endif
+
}
#else
if (!WriteFile(device_handle, &s->payload, payloadlen, &lenout, &overlapped))
@@ -366,8 +374,9 @@
struct addrinfo hints, *res, *ressave;
#ifndef _WIN32
pthread_tthread;
-struct ifreqifr;
+#ifdef LINUX
+struct ifreqifr;
// Create a new tap device
ayiya_fd = open("/dev/net/tun", O_RDWR);
if (ayiya_fd == -1)
@@ -388,6 +397,28 @@
g_aiccu->ipv6_interface, errno, strerror(errno));
return false;
}
+#else
+int i;
+ayiya_fd = -1;
+for (i = 0; i < 256; ++i)
+{
+char buf[128];
+snprintf(buf, sizeof(buf), "/dev/tun%d", i);
+ayiya_fd = open(buf, O_RDWR);
+if (ayiya_fd >= 0)
+{
+break;
+}
+}
+if (ayiya_fd < 0)
+{
+ayiya_log(LOG_ERR, NULL, 0, "Couldn't open device %s (%d): %s\n", "/dev/tun", errno, strerror(errno));
+return false;
+}
+#endif
+
+
+
#else
HKEYkey;
DWORDpID;
diff -ru aiccu/common/ayiya.h aiccu.my/common/ayiya.h
--- aiccu/common/ayiya.hMon Aug 30 19:08:59 2004
+++ aiccu.my/common/ayiya.hWed Sep 1 21:01:37 2004
@@ -59,7 +59,7 @@
struct ayiyahdr
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
#error "Big Endian"
u_int8_tayh_idlen:4;// Identity Length
u_int8_tayh_idtype:4;// Identity Type
@@ -67,7 +67,7 @@
u_int8_tayh_hshmeth:4;// Hashing Method
u_int8_tayh_autmeth:4;// Authentication Method
u_int8_tayh_opcode:4;// Operation Code
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#elif BYTE_ORDER == LITTLE_ENDIAN
u_int8_tayh_idtype:4;// Identity Type
u_int8_tayh_idlen:4;// Identity Length
u_int8_tayh_hshmeth:4;// Hashing Method
Only in aiccu.my/common: ayiya.o
diff -ru aiccu/common/common.h aiccu.my/common/common.h
--- aiccu/common/common.hMon Aug 30 19:08:59 2004
+++ aiccu.my/common/common.hWed Sep 1 21:04:05 2004
@@ -52,7 +52,12 @@
#include <net/if.h>
#include <netinet/if_ether.h>
+#ifdef LINUX
#include <netpacket/packet.h>
+#endif
+#ifdef __FreeBSD__
+#include <netinet/in_systm.h>
+#endif
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
@@ -60,7 +65,9 @@
#include <netinet/udp.h>
#include <netinet/ip_icmp.h>
#include <sys/ioctl.h>
+#ifdef LINUX
#include <linux/if_tun.h>
+#endif
#include <pthread.h>
Only in aiccu.my/common: common.o
Only in aiccu.my/common: hash_md5.o
diff -ru aiccu/common/hash_sha1.c aiccu.my/common/hash_sha1.c
--- aiccu/common/hash_sha1.cSun Aug 29 15:49:55 2004
+++ aiccu.my/common/hash_sha1.cWed Sep 1 21:04:26 2004
@@ -24,7 +24,7 @@
*/
#include "hash_sha1.h"
-#include "malloc.h"
+#include "stdlib.h"
#include <string.h>
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
Only in aiccu.my/common: hash_sha1.o
Only in aiccu.my/common: heartbeat.o
Only in aiccu.my/common: tic.o
diff -ru aiccu/unix-console/Makefile aiccu.my/unix-console/Makefile
--- aiccu/unix-console/MakefileMon Aug 30 19:09:05 2004
+++ aiccu.my/unix-console/MakefileWed Sep 1 21:47:18 2004
@@ -16,7 +16,6 @@
CWARNS= -W -Wall -Wshadow -Wcast-align -Wpadded
CFLAGS= $(CWARNS) -D _GNU_SOURCE -D _DEBUG -g
#CFLAGS= $(CWARNS) -D _GNU_SOURCE -O3
-LDFLAGS= -lpthread
CC = gcc
RM = rm
@@ -24,18 +23,15 @@
ifeq ($(shell uname | grep -c "Linux"),1)
SRCS+= ../common/aiccu_linux.c
OBJS+= ../common/aiccu_linux.o
+LDFLAGS= -lpthread
endif
# FreeBSD 4.x
-ifeq ($(shell uname | grep -c "FreeBSD"),1)
-SRCS+= ../common/aiccu_freebsd4.c
-OBJS+= ../common/aiccu_freebsd4.o
-endif
-
# FreeBSD 5.x
ifeq ($(shell uname | grep -c "FreeBSD"),1)
-SRCS+= ../common/aiccu_kame.c
-OBJS+= ../common/aiccu_kame.o
+SRCS+= ../common/aiccu_freebsd.c
+OBJS+= ../common/aiccu_freebsd.o
+CFLAGS += -pthread
endif
# NetBSD
Only in aiccu.my/unix-console: aiccu
Only in aiccu.my/unix-console: main.o
[PATCH] AICCU Beta2 and FreeBSD
Submit patches to info@sixxs.net so we can incorporate them... this is how other people are doing it too.
|