Project

General

Profile

Actions

Bug #13

closed

Patch to make macosx/freebsd/et.al. work again.

Added by Anonymous about 16 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
batmand
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Fix against current -HEAD for *BSDs.

Dw.

Index: bsd.c
===================================================================
--- bsd.c    (revision 1016)
+++ bsd.c    (working copy)
@@ -17,8 +17,6 @@
  *
  */

-#warning BSD support is known broken - if you compile this on BSD you are expected to fix it :-P
-
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -115,6 +113,45 @@
     return 1;
 }

+
+void set_send_redirects( int32_t state, char* dev ) {
+        int mibr4;
+
+        if (state < 0 || state > 1) {
+                errno = EINVAL;
+                err(1, "set_redirect: %i", state);
+        }
+
+        /* net.inet.ip.redirect */
+        mibr0 = CTL_NET;
+        mibr1 = PF_INET;
+        mibr2 = IPPROTO_IP;
+        mibr3 = IPCTL_SENDREDIRECTS;
+
+        if (sysctl(mib, 4, NULL, 0, (void*)&state, sizeof(state)) == -1)
+                err(1, "Cannot enable packet redirection");
+}
+
+int32_t get_send_redirects( char *dev ) {
+    int state;
+    size_t len;
+    int mibr4;
+
+    /* "net.inet.ip.redirect" */
+    mibr0 = CTL_NET;
+    mibr1 = PF_INET;
+    mibr2 = IPPROTO_IP;
+    mibr3 = IPCTL_SENDREDIRECTS;
+
+    len = sizeof(int);
+
+    if (sysctl(mib, 4, &state, &len, NULL, 0) == -1)
+        err(1, "Cannot tell if packet redirection is enabled");
+
+    return state;
+}
+
+
 /* Message structure used to interface the kernel routing table.
** See route(4) for details on the message passing interface for
** manipulating the kernel routing table.
Index: bsd.h
===================================================================
--- bsd.h    (revision 0)
+++ bsd.h    (revision 0)
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2006 BATMAN contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+int vdprintf(int d, const char *format, va_list ap);
+int dprintf(int d, const char *format, ...);
Index: posix-specific.c
===================================================================
--- posix-specific.c    (revision 1016)
+++ posix-specific.c    (working copy)
@@ -41,6 +41,9 @@
 #include <paths.h>

 #include "os.h" 
+#ifdef BSD
+#include "bsd.h" 
+#endif
 #include "originator.h" 
 #include "batman.h" 

Index: Makefile
===================================================================
--- Makefile    (revision 1016)
+++ Makefile    (working copy)
@@ -20,7 +20,7 @@
 CC =            gcc
 CFLAGS =        -Wall -O1 -g3 -DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA
 STRIP=            strip
-LDFLAGS =        -lpthread -static
+LDFLAGS =        -lpthread 

 CFLAGS_MIPS =    -Wall -O1 -g3
 LDFLAGS_MIPS =    -lpthread
@@ -29,18 +29,24 @@

 ifeq ($(UNAME),Linux)
 OS_C=     linux-specific.c linux.c
+LDFLAGS += -static
 endif

 ifeq ($(UNAME),Darwin)
 OS_C=    bsd.c
+CFLAGS += -DBSD
 endif

 ifeq ($(UNAME),FreeBSD)
 OS_C=    bsd.c
+CFLAGS += -DBSD
+LDFLAGS += -static
 endif

 ifeq ($(UNAME),OpenBSD)
 OS_C=    bsd.c
+CFLAGS += -DBSD
+LDFLAGS += -static
 endif

 LOG_BRANCH= branches/batman-0.2.x
Actions #1

Updated by Anonymous about 16 years ago

Slightly more daring patch to generalize above.

Dw.


Property changes on: .
+++++++++++++++++++++++++++++++++_
Name: svn:ignore
   + batmand.dSYM
batmand

Index: bsd.c
===================================================================
--- bsd.c    (revision 1016)
+++ bsd.c    (working copy)
@@ -17,8 +17,6 @@
  *
  */

-#warning BSD support is known broken - if you compile this on BSD you are expected to fix it :-P
-
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -115,6 +113,45 @@
     return 1;
 }

+
+void set_send_redirects( int32_t state, char* dev ) {
+        int mibr4;
+
+        if (state < 0 || state > 1) {
+                errno = EINVAL;
+                err(1, "set_redirect: %i", state);
+        }
+
+        /* net.inet.ip.redirect */
+        mibr0 = CTL_NET;
+        mibr1 = PF_INET;
+        mibr2 = IPPROTO_IP;
+        mibr3 = IPCTL_SENDREDIRECTS;
+
+        if (sysctl(mib, 4, NULL, 0, (void*)&state, sizeof(state)) == -1)
+                err(1, "Cannot enable packet redirection");
+}
+
+int32_t get_send_redirects( char *dev ) {
+    int state;
+    size_t len;
+    int mibr4;
+
+    /* "net.inet.ip.redirect" */
+    mibr0 = CTL_NET;
+    mibr1 = PF_INET;
+    mibr2 = IPPROTO_IP;
+    mibr3 = IPCTL_SENDREDIRECTS;
+
+    len = sizeof(int);
+
+    if (sysctl(mib, 4, &state, &len, NULL, 0) == -1)
+        err(1, "Cannot tell if packet redirection is enabled");
+
+    return state;
+}
+
+
 /* Message structure used to interface the kernel routing table.
** See route(4) for details on the message passing interface for
** manipulating the kernel routing table.
Index: bsd.h
===================================================================
--- bsd.h    (revision 0)
+++ bsd.h    (revision 0)
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2006 BATMAN contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+int vdprintf(int d, const char *format, va_list ap);
+int dprintf(int d, const char *format, ...);
Index: posix-specific.c
===================================================================
--- posix-specific.c    (revision 1016)
+++ posix-specific.c    (working copy)
@@ -41,6 +41,9 @@
 #include <paths.h>

 #include "os.h" 
+#ifdef BSD
+#include "bsd.h" 
+#endif
 #include "originator.h" 
 #include "batman.h" 

Index: Makefile
===================================================================
--- Makefile    (revision 1016)
+++ Makefile    (working copy)
@@ -20,7 +20,7 @@
 CC =            gcc
 CFLAGS =        -Wall -O1 -g3 -DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA
 STRIP=            strip
-LDFLAGS =        -lpthread -static
+LDFLAGS =        -lpthread 

 CFLAGS_MIPS =    -Wall -O1 -g3
 LDFLAGS_MIPS =    -lpthread
@@ -28,25 +28,34 @@
 UNAME=        $(shell uname)

 ifeq ($(UNAME),Linux)
-OS_C=     linux-specific.c linux.c
+OS_C += linux-specific.c linux.c
+LDFLAGS += -static
 endif

 ifeq ($(UNAME),Darwin)
-OS_C=    bsd.c
+CFLAGS += -DBSD
+OS_C += bsd.c
+OS_H += bsd.h
 endif

 ifeq ($(UNAME),FreeBSD)
-OS_C=    bsd.c
+CFLAGS += -DBSD
+LDFLAGS += -static
+OS_C += bsd.c
+OS_H += bsd.h
 endif

 ifeq ($(UNAME),OpenBSD)
-OS_C=    bsd.c
+CFLAGS += -DBSD
+LDFLAGS += -static
+OS_C += bsd.c
+OS_H += bsd.h
 endif

 LOG_BRANCH= branches/batman-0.2.x

-LINUX_SRC_C= batman.c originator.c schedule.c posix-specific.c posix.c allocate.c bitarray.c hash.c profile.c $(OS_C)
-LINUX_SRC_H= batman.h originator.h schedule.h batman-specific.h list.h os.h allocate.h bitarray.h hash.h profile.h 
+SRC_C= batman.c originator.c schedule.c posix-specific.c posix.c allocate.c bitarray.c hash.c profile.c $(OS_C)
+SRC_H= batman.h originator.h schedule.h batman-specific.h list.h os.h allocate.h bitarray.h hash.h profile.h $(OS_H)

 BINARY_NAME=    batmand
 SOURCE_VERSION_HEADER= batman.h
@@ -99,18 +108,16 @@

 all:        $(BINARY_NAME)

-$(BINARY_NAME):    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC) $(CFLAGS)  -o $@ $(LINUX_SRC_C) $(LDFLAGS)
+$(BINARY_NAME):    $(SRC_C) $(SRC_H) Makefile
+    $(CC) $(CFLAGS)  -o $@ $(SRC_C) $(LDFLAGS)

-
-
 long:    sources i386 mipsel-kk-bc mips-kk-at mipsel-wr arm-oe nokia770-oe clean-long

 axel:    sources i386 mipsel-kk-bc mips-kk-at mipsel-wr arm-oe clean-long

 sources:
     mkdir -p $(FILE_NAME)
-    cp $(LINUX_SRC_H) $(LINUX_SRC_C) Makefile $(FILE_NAME)/
+    cp $(SRC_H) $(SRC_C) Makefile $(FILE_NAME)/
     $(BUILD_PATH)/wget --no-check-certificate -O changelog.html  https://dev.open-mesh.org/batman/log/$(LOG_BRANCH)/
     html2text -o changelog.txt -nobs -ascii changelog.html
     awk '/View revision/,/10\/01\/06 20:23:03/' changelog.txt > $(FILE_NAME)/CHANGELOG
@@ -124,11 +131,10 @@
     ln -f $(FILE_NAME).tgz dl/sources/
     ln -f $(FILE_NAME).tgz dl/sources/$(FILE_CURRENT).tgz

-
 i386: i386-gc-elf-32-lsb-static i386-gc-elf-32-lsb-dynamic

-i386-gc-elf-32-lsb-static:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC) $(CFLAGS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS) -static
+i386-gc-elf-32-lsb-static:    $(SRC_C) $(SRC_H) Makefile
+    $(CC) $(CFLAGS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS) -static
     $(STRIP) $(FILE_NAME)
     $(IPKG_BUILD) i386
     $(LINK_AND_TAR)
@@ -138,8 +144,8 @@
     ln -f $(FILE_CURRENT).tgz dl/i386/

-i386-gc-elf-32-lsb-dynamic:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC) $(CFLAGS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS)
+i386-gc-elf-32-lsb-dynamic:    $(SRC_C) $(SRC_H) Makefile
+    $(CC) $(CFLAGS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS)
     $(STRIP) $(FILE_NAME)
     $(IPKG_BUILD) i386
     $(LINK_AND_TAR)
@@ -153,8 +159,8 @@

 mipsel-kk-bc:    mipsel-kk-elf-32-lsb-static mipsel-kk-elf-32-lsb-dynamic

-mipsel-kk-elf-32-lsb-static:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_MIPS_KK_BC) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS) -static
+mipsel-kk-elf-32-lsb-static:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_MIPS_KK_BC) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS) -static
     $(STRIP_MIPS_KK_BC) $(FILE_NAME)
     $(IPKG_BUILD) mipsel
     $(LINK_AND_TAR)
@@ -164,8 +170,8 @@
     ln -f $(FILE_CURRENT).ipk dl/meshcube/

-mipsel-kk-elf-32-lsb-dynamic:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_MIPS_KK_BC) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS)
+mipsel-kk-elf-32-lsb-dynamic:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_MIPS_KK_BC) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS)
     $(STRIP_MIPS_KK_BC) $(FILE_NAME)
     $(IPKG_BUILD) mipsel $(IPKG_DEPENDS)
     $(LINK_AND_TAR)
@@ -177,8 +183,8 @@

 mips-kk-at:    mips-kk-elf-32-msb-static mips-kk-elf-32-msb-dynamic

-mips-kk-elf-32-msb-static:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_MIPS_KK_AT) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS) -static
+mips-kk-elf-32-msb-static:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_MIPS_KK_AT) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS) -static
     $(STRIP_MIPS_KK_AT) $(FILE_NAME)
     $(IPKG_BUILD) mips
     $(LINK_AND_TAR)
@@ -188,8 +194,8 @@
     ln -f $(FILE_CURRENT).tgz dl/fonera/

-mips-kk-elf-32-msb-dynamic:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_MIPS_KK_AT) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS)
+mips-kk-elf-32-msb-dynamic:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_MIPS_KK_AT) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS)
     $(STRIP_MIPS_KK_AT) $(FILE_NAME)
     $(IPKG_BUILD) mips $(IPKG_DEPENDS)
     $(LINK_AND_TAR)
@@ -201,14 +207,14 @@

 mipsel-wr:    mipsel-wr-elf-32-lsb-static mipsel-wr-elf-32-lsb-dynamic

-mipsel-wr-elf-32-lsb-static:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_MIPS_WR) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS) -static
+mipsel-wr-elf-32-lsb-static:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_MIPS_WR) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS) -static
     $(STRIP_MIPS_WR) $(FILE_NAME)
     $(IPKG_BUILD) mipsel
     $(LINK_AND_TAR)

-mipsel-wr-elf-32-lsb-dynamic:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_MIPS_WR) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS)
+mipsel-wr-elf-32-lsb-dynamic:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_MIPS_WR) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS)
     $(STRIP_MIPS_WR) $(FILE_NAME)
     $(IPKG_BUILD) mipsel $(IPKG_DEPENDS)
     $(LINK_AND_TAR)
@@ -222,8 +228,8 @@

 arm-oe:        armv5te-oe-elf-32-lsb-static armv5te-oe-elf-32-lsb-dynamic 

-armv5te-oe-elf-32-lsb-static:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_ARM_OE) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS) -static
+armv5te-oe-elf-32-lsb-static:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_ARM_OE) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS) -static
     $(STRIP_ARM_OE) $(FILE_NAME)
     $(IPKG_BUILD) armv5te
     $(LINK_AND_TAR)    
@@ -234,8 +240,8 @@
     ln -f $(FILE_CURRENT).ipk dl/armv5te/
     ln -f $(FILE_CURRENT).tgz dl/armv5te/

-armv5te-oe-elf-32-lsb-dynamic:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_ARM_OE) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS)
+armv5te-oe-elf-32-lsb-dynamic:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_ARM_OE) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS)
     $(STRIP_ARM_OE) $(FILE_NAME)
     $(IPKG_BUILD) armv5te kernel-module-tun
     $(LINK_AND_TAR)    
@@ -246,14 +252,14 @@

 nokia770-oe:    nokia770-oe-elf-32-lsb-static nokia770-oe-elf-32-lsb-dynamic

-nokia770-oe-elf-32-lsb-static:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_N770_OE) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS) -static
+nokia770-oe-elf-32-lsb-static:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_N770_OE) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS) -static
     $(STRIP_N770_OE) $(FILE_NAME)
     $(IPKG_BUILD) arm-nokia770
     $(LINK_AND_TAR)    

-nokia770-oe-elf-32-lsb-dynamic:    $(LINUX_SRC_C) $(LINUX_SRC_H) Makefile
-    $(CC_N770_OE) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(LINUX_SRC_C) $(LDFLAGS_MIPS)
+nokia770-oe-elf-32-lsb-dynamic:    $(SRC_C) $(SRC_H) Makefile
+    $(CC_N770_OE) $(CFLAGS_MIPS) -DREVISION_VERSION=$(REVISION_VERSION) -o $(FILE_NAME) $(SRC_C) $(LDFLAGS_MIPS)
     $(STRIP_N770_OE) $(FILE_NAME)
     $(IPKG_BUILD) arm-nokia770 kernel-module-tun
     $(LINK_AND_TAR)    

Actions #2

Updated by Marek Lindner about 16 years ago

  • Status changed from New to In Progress

Hi,

many thanks for the patch.

What branch is supposed to be patched ?

Could you please attach it as a file ?

Marek

Actions #3

Updated by Anonymous over 15 years ago

  • Status changed from In Progress to Closed
Actions #4

Updated by Anonymous about 13 years ago

  • Category set to batmand
Actions #5

Updated by Sven Eckelmann about 7 years ago

  • Target version set to 0.3
Actions

Also available in: Atom PDF