]>
git.proxmox.com Git - mirror_frr.git/blob - zebra/ipforward_proc.c
eb8cef01f167b675c6462169432c69bda95544af
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
25 char proc_net_snmp
[] = "/proc/net/snmp";
32 while ((c
= getc (fp
)) != '\n')
44 fp
= fopen (proc_net_snmp
, "r");
49 /* We don't care about the first line. */
52 /* Get ip_statistics.IpForwarding :
53 1 => ip forwarding enabled
54 2 => ip forwarding off. */
55 pnt
= fgets (buf
, 6, fp
);
56 sscanf (buf
, "Ip: %d", &ipforwarding
);
58 if (ipforwarding
== 1)
64 /* char proc_ipv4_forwarding[] = "/proc/sys/net/ipv4/conf/all/forwarding"; */
65 char proc_ipv4_forwarding
[] = "/proc/sys/net/ipv4/ip_forward";
72 fp
= fopen (proc_ipv4_forwarding
, "w");
89 fp
= fopen (proc_ipv4_forwarding
, "w");
102 char proc_ipv6_forwarding
[] = "/proc/sys/net/ipv6/conf/all/forwarding";
109 int ipforwarding
= 0;
111 fp
= fopen (proc_ipv6_forwarding
, "r");
117 sscanf (buf
, "%d", &ipforwarding
);
127 fp
= fopen (proc_ipv6_forwarding
, "w");
136 return ipforward_ipv6 ();
140 ipforward_ipv6_off ()
144 fp
= fopen (proc_ipv6_forwarding
, "w");
153 return ipforward_ipv6 ();
155 #endif /* HAVE_IPV6 */