- FILE *fp;
- int ipforwarding = 0;
- char buf[10];
-
- fp = fopen (proc_net_snmp, "r");
-
- if (fp == NULL)
- return -1;
-
- /* We don't care about the first line. */
- dropline (fp);
-
- /* Get ip_statistics.IpForwarding :
- 1 => ip forwarding enabled
- 2 => ip forwarding off. */
- if (fgets (buf, 6, fp))
- sscanf (buf, "Ip: %d", &ipforwarding);
-
- fclose(fp);
-
- if (ipforwarding == 1)
- return 1;
-
- return 0;
+ int ret = 0;
+ FILE *fp;
+ int ipforwarding = 0;
+ char buf[10];
+
+ fp = fopen(proc_net_snmp, "r");
+
+ if (fp == NULL)
+ return -1;
+
+ /* We don't care about the first line. */
+ dropline(fp);
+
+ /* Get ip_statistics.IpForwarding :
+ 1 => ip forwarding enabled
+ 2 => ip forwarding off. */
+ if (fgets(buf, 6, fp))
+ ret = sscanf(buf, "Ip: %d", &ipforwarding);
+
+ fclose(fp);
+
+ if (ret == 1 && ipforwarding == 1)
+ return 1;
+
+ return 0;