2 * Fetch ipforward value by reading /proc filesystem.
3 * Copyright (C) 1997 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 char proc_net_snmp[] = "/proc/net/snmp";
34 while ((c = getc (fp)) != '\n')
46 fp = fopen (proc_net_snmp, "r");
51 /* We don't care about the first line. */
54 /* Get ip_statistics.IpForwarding :
55 1 => ip forwarding enabled
56 2 => ip forwarding off. */
57 pnt = fgets (buf, 6, fp);
58 sscanf (buf, "Ip: %d", &ipforwarding);
60 if (ipforwarding == 1)
66 /* char proc_ipv4_forwarding[] = "/proc/sys/net/ipv4/conf/all/forwarding"; */
67 char proc_ipv4_forwarding[] = "/proc/sys/net/ipv4/ip_forward";
74 fp = fopen (proc_ipv4_forwarding, "w");
91 fp = fopen (proc_ipv4_forwarding, "w");
104 char proc_ipv6_forwarding[] = "/proc/sys/net/ipv6/conf/all/forwarding";
111 int ipforwarding = 0;
113 fp = fopen (proc_ipv6_forwarding, "r");
119 sscanf (buf, "%d", &ipforwarding);
129 fp = fopen (proc_ipv6_forwarding, "w");
138 return ipforward_ipv6 ();
142 ipforward_ipv6_off ()
146 fp = fopen (proc_ipv6_forwarding, "w");
155 return ipforward_ipv6 ();
157 #endif /* HAVE_IPV6 */
159 #endif /* BRCM_CMD_SUPPORT */