*
* Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
* Rani Assaf <rani@magic.metawire.com> 980930: do not allow key for ipip/sit
+ * Bernd Eckenfels 990715: add linux/types.h (not clean but solves missing __u16
+ * Arnaldo Carvalho de Melo 20010404: use setlocale
*/
#include <stdio.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
-#include <linux/if.h>
-#include <linux/if_arp.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
+#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1))
+#include <net/if.h>
+#include <net/if_arp.h>
+#else
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#endif
+#include <linux/types.h>
#include <linux/if_tunnel.h>
#include "config.h"
#include "intl.h"
#include "net-support.h"
#include "version.h"
+#include "util.h"
#undef GRE_CSUM
#define GRE_CSUM htons(0x8000)
#include "util-ank.h"
char *Release = RELEASE,
- *Version = "iptunnel 1.0",
+ *Version = "iptunnel 1.01",
*Signature = "Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>";
static void version(void)
fprintf(stderr, _(" TOS := { NUMBER | inherit }\n"));
fprintf(stderr, _(" TTL := { 1..255 | inherit }\n"));
fprintf(stderr, _(" KEY := { DOTTED_QUAD | NUMBER }\n"));
- exit(-1);
+ exit(E_USAGE);
}
static int do_ioctl_get_ifindex(char *dev)
err = ioctl(fd, SIOCGIFINDEX, &ifr);
if (err) {
perror("ioctl");
+ close(fd);
return 0;
}
close(fd);
err = ioctl(fd, SIOCGIFHWADDR, &ifr);
if (err) {
perror("ioctl");
+ close(fd);
return -1;
}
close(fd);
err = ioctl(fd, SIOCGIFNAME, &ifr);
if (err) {
perror("ioctl");
+ close(fd);
return NULL;
}
close(fd);
p->iph.saddr = get_addr32(*argv);
} else if (strcmp(*argv, "dev") == 0) {
NEXT_ARG();
- strncpy(medium, *argv, IFNAMSIZ-1);
+ safe_strncpy(medium, *argv, IFNAMSIZ-1);
} else if (strcmp(*argv, "ttl") == 0) {
unsigned uval;
NEXT_ARG();
} else {
if (p->name[0])
usage();
- strncpy(p->name, *argv, IFNAMSIZ);
+ safe_strncpy(p->name, *argv, IFNAMSIZ);
}
argc--; argv++;
}
return -1;
}
- fgets(buf, sizeof(buf), fp);
- fgets(buf, sizeof(buf), fp);
+ if (fgets(buf, sizeof(buf), fp))
+ /* eat line */;
+ if (fgets(buf, sizeof(buf), fp))
+ /* eat line */;
while (fgets(buf, sizeof(buf), fp) != NULL) {
char *ptr;
if ((ptr = strchr(buf, ':')) == NULL ||
(*ptr++ = 0, sscanf(buf, "%s", name) != 1)) {
fprintf(stderr, _("Wrong format of /proc/net/dev. Sorry.\n"));
+ fclose(fp);
return -1;
}
if (sscanf(ptr, "%ld%ld%ld%ld%ld%ld%ld%*d%ld%ld%ld%ld%ld%ld%ld",
tx_packets, tx_bytes, tx_errs, tx_colls, tx_carrier, tx_drops);
}
}
+ fclose(fp);
return 0;
}
char *basename;
#if I18N
+ setlocale (LC_ALL, "");
bindtextdomain("net-tools", "/usr/share/locale");
textdomain("net-tools");
#endif