88d4bebfe5
The olsr.org OLSR daemon is an implementation of the Optimized Link State Routing protocol. OLSR is a routing protocol for mobile ad-hoc networks. The protocol is pro-active, table driven and utilizes a technique called multipoint relaying for message flooding. From: Holger Mauermann <holger@mauermann.org> ok pvalchev@
131 lines
2.8 KiB
Plaintext
131 lines
2.8 KiB
Plaintext
$OpenBSD: patch-src_bsd_net_c,v 1.1.1.1 2005/05/22 14:44:45 robert Exp $
|
|
--- src/bsd/net.c.orig Sun Mar 20 17:52:25 2005
|
|
+++ src/bsd/net.c Sun May 22 06:19:15 2005
|
|
@@ -49,8 +49,17 @@
|
|
#endif
|
|
|
|
#include <net/if.h>
|
|
+#ifdef __OpenBSD__
|
|
+#include <netinet/if_ether.h>
|
|
+#include <netinet/in_systm.h>
|
|
+#include <netinet/ip.h>
|
|
+#include <netinet/ip_icmp.h>
|
|
+#include <netinet/icmp_var.h>
|
|
+#include <netinet/icmp6.h>
|
|
+#else
|
|
#include <net/if_var.h>
|
|
#include <net/ethernet.h>
|
|
+#endif
|
|
|
|
#ifdef __FreeBSD__
|
|
#include <net80211/ieee80211.h>
|
|
@@ -78,11 +87,52 @@
|
|
static int set_sysctl_int(char *name, int new)
|
|
{
|
|
int old;
|
|
- unsigned int len = sizeof (old);
|
|
+ size_t len = sizeof (old);
|
|
+
|
|
+#ifdef __OpenBSD__
|
|
+ int mib[4];
|
|
+
|
|
+ /*
|
|
+ * Set net.inet.ip.forwarding by default.
|
|
+ */
|
|
+ mib[0] = CTL_NET;
|
|
+ mib[1] = PF_INET;
|
|
+ mib[2] = IPPROTO_IP;
|
|
+ mib[3] = IPCTL_FORWARDING;
|
|
+
|
|
+ if (!strcmp(name, "net.inet6.ip6.forwarding"))
|
|
+ {
|
|
+ mib[1] = PF_INET6;
|
|
+ mib[2] = IPPROTO_IPV6;
|
|
+ }
|
|
+ else if (!strcmp(name, "net.inet.icmp.rediraccept"))
|
|
+ {
|
|
+ mib[2] = IPPROTO_ICMP;
|
|
+ mib[3] = ICMPCTL_REDIRACCEPT;
|
|
+ }
|
|
+ else if (!strcmp(name, "net.inet6.icmp6.rediraccept"))
|
|
+ {
|
|
+ mib[2] = IPPROTO_ICMPV6;
|
|
+ mib[3] = ICMPV6CTL_REDIRACCEPT;
|
|
+ }
|
|
+ else if (!strcmp(name, "net.inet.ip.redirect"))
|
|
+ {
|
|
+ mib[3] = IPCTL_SENDREDIRECTS;
|
|
+ }
|
|
+ else if (!strcmp(name, "net.inet6.ip6.redirect"))
|
|
+ {
|
|
+ mib[1] = PF_INET6;
|
|
+ mib[2] = IPPROTO_IPV6;
|
|
+ mib[3] = IPCTL_SENDREDIRECTS;
|
|
+ }
|
|
|
|
- if (sysctlbyname(name, &old, &len, &new, sizeof (new)) < 0)
|
|
+ if (sysctl(mib, 4, &old, &len, &new, sizeof (new)) < 0)
|
|
return -1;
|
|
+#else
|
|
|
|
+ if (sysctlbyname(name, &old, &len, &new, sizeof (new)) < 0)
|
|
+ return -1;
|
|
+#endif
|
|
return old;
|
|
}
|
|
|
|
@@ -122,14 +172,24 @@
|
|
first_time = 0;
|
|
|
|
// do not accept ICMP redirects
|
|
-
|
|
if (olsr_cnf->ip_version == AF_INET)
|
|
+#ifdef __OpenBSD__
|
|
+ name = "net.inet.icmp.rediraccept";
|
|
+#else
|
|
name = "net.inet.icmp.drop_redirect";
|
|
-
|
|
+#endif
|
|
else
|
|
+#ifdef __OpenBSD__
|
|
+ name = "net.inet6.icmp6.rediraccept";
|
|
+#else
|
|
name = "net.inet6.icmp6.drop_redirect";
|
|
+#endif
|
|
|
|
+#ifdef __OpenBSD__
|
|
+ ignore_redir = set_sysctl_int(name, 0);
|
|
+#else
|
|
ignore_redir = set_sysctl_int(name, 1);
|
|
+#endif
|
|
|
|
if (ignore_redir < 0)
|
|
{
|
|
@@ -152,7 +212,6 @@
|
|
fprintf(stderr, "Cannot disable outgoing ICMP redirect messages. Please disable them manually. Continuing in 3 seconds...\n");
|
|
sleep(3);
|
|
}
|
|
-
|
|
return 1;
|
|
}
|
|
|
|
@@ -178,10 +237,17 @@
|
|
// reset incoming ICMP redirects
|
|
|
|
if (olsr_cnf->ip_version == AF_INET)
|
|
+#ifdef __OpenBSD__
|
|
+ name = "net.inet.icmp.rediraccept";
|
|
+#else
|
|
name = "net.inet.icmp.drop_redirect";
|
|
-
|
|
+#endif
|
|
else
|
|
+#ifdef __OpenBSD__
|
|
+ name = "net.inet6.icmp6.rediraccept";
|
|
+#else
|
|
name = "net.inet6.icmp6.drop_redirect";
|
|
+#endif
|
|
|
|
set_sysctl_int(name, ignore_redir);
|
|
|