convert -idirafter to -I
[platform/upstream/net-tools.git] / iptunnel.c
index a41391d..4943d83 100644 (file)
@@ -13,6 +13,8 @@
  *
  * 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)
 #define IPPROTO_GRE    47
 #endif
 
-#include "utils.h"
+#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)
@@ -278,7 +288,7 @@ static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
                                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();
@@ -303,7 +313,7 @@ static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
                } else {
                        if (p->name[0])
                                usage();
-                       strncpy(p->name, *argv, IFNAMSIZ);
+                       safe_strncpy(p->name, *argv, IFNAMSIZ);
                }
                argc--; argv++;
        }
@@ -571,6 +581,12 @@ int main(int argc, char **argv)
 {
        char *basename;
 
+#if I18N
+       setlocale (LC_ALL, "");
+       bindtextdomain("net-tools", "/usr/share/locale");
+       textdomain("net-tools");
+#endif
+
        basename = strrchr(argv[0], '/');
        if (basename == NULL)
                basename = argv[0];