Project

General

Profile

Actions

Bug #13

closed

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

Added by Anonymous over 16 years ago. Updated almost 8 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

Also available in: Atom PDF