1 /* IP forward control by sysctl function.
2 * Copyright (C) 1997, 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 #include <netinet6/in6.h>
32 /* IPv4 forwarding control MIB. */
47 len = sizeof ipforwarding;
48 if (sysctl (mib, MIB_SIZ, &ipforwarding, &len, 0, 0) < 0)
50 zlog_warn ("Can't get ipforwarding value");
62 len = sizeof ipforwarding;
63 if (sysctl (mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0)
65 zlog_warn ("Can't set ipforwarding on");
77 len = sizeof ipforwarding;
78 if (sysctl (mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0)
80 zlog_warn ("Can't set ipforwarding on");
88 /* IPv6 forwarding control MIB. */
89 int mib_ipv6[MIB_SIZ] =
93 #if defined(KAME) || (defined(__bsdi__) && _BSDI_VERSION >= 199802 ) || defined(NRL)
106 int ip6forwarding = 0;
108 len = sizeof ip6forwarding;
109 if (sysctl (mib_ipv6, MIB_SIZ, &ip6forwarding, &len, 0, 0) < 0)
111 zlog_warn ("can't get ip6forwarding value");
114 return ip6forwarding;
121 int ip6forwarding = 1;
123 len = sizeof ip6forwarding;
124 if (sysctl (mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len) < 0)
126 zlog_warn ("can't get ip6forwarding value");
129 return ip6forwarding;
133 ipforward_ipv6_off ()
136 int ip6forwarding = 0;
138 len = sizeof ip6forwarding;
139 if (sysctl (mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len) < 0)
141 zlog_warn ("can't get ip6forwarding value");
144 return ip6forwarding;
146 #endif /* HAVE_IPV6 */