Checkign in new iproute2
[iproute2.git] / ip / ip.c
diff --git a/ip/ip.c b/ip/ip.c
index c29d2f3..c4c773f 100644 (file)
--- a/ip/ip.c
+++ b/ip/ip.c
 
 int preferred_family = AF_UNSPEC;
 int show_stats = 0;
+int show_details = 0;
 int resolve_hosts = 0;
 int oneline = 0;
 int timestamp = 0;
 char * _SL_ = NULL;
 char *batch_file = NULL;
 int force = 0;
-struct rtnl_handle rth;
+struct rtnl_handle rth = { .fd = -1 };
 
 static void usage(void) __attribute__((noreturn));
 
@@ -45,9 +46,9 @@ static void usage(void)
        fprintf(stderr,
 "Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
 "       ip [ -force ] [-batch filename\n"
-"where  OBJECT := { link | addr | route | rule | neigh | ntable | tunnel |\n"
-"                   maddr | mroute | monitor | xfrm }\n"
-"       OPTIONS := { -V[ersion] | -s[tatistics] | -r[esolve] |\n"
+"where  OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |\n"
+"                   tunnel | maddr | mroute | monitor | xfrm }\n"
+"       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
 "                    -f[amily] { inet | inet6 | ipx | dnet | link } |\n"
 "                    -o[neline] | -t[imestamp] }\n");
        exit(-1);
@@ -63,6 +64,7 @@ static const struct cmd {
        int (*func)(int argc, char **argv);
 } cmds[] = {
        { "address",    do_ipaddr },
+       { "addrlabel",  do_ipaddrlabel },
        { "maddress",   do_multiaddr },
        { "route",      do_iproute },
        { "rule",       do_iprule },
@@ -102,7 +104,7 @@ static int batch(const char *name)
 
        if (name && strcmp(name, "-") != 0) {
                if (freopen(name, "r", stdin) == NULL) {
-                       fprintf(stderr, "Cannot open file \"%s\" for reading: %s=n",
+                       fprintf(stderr, "Cannot open file \"%s\" for reading: %s\n",
                                name, strerror(errno));
                        return -1;
                }
@@ -145,7 +147,7 @@ int main(int argc, char **argv)
                basename = argv[0];
        else
                basename++;
-       
+
        while (argc > 1) {
                char *opt = argv[1];
                if (strcmp(opt,"--") == 0) {
@@ -188,6 +190,8 @@ int main(int argc, char **argv)
                } else if (matches(opt, "-stats") == 0 ||
                           matches(opt, "-statistics") == 0) {
                        ++show_stats;
+               } else if (matches(opt, "-details") == 0) {
+                       ++show_details;
                } else if (matches(opt, "-resolve") == 0) {
                        ++resolve_hosts;
                } else if (matches(opt, "-oneline") == 0) {
@@ -220,16 +224,16 @@ int main(int argc, char **argv)
 
        _SL_ = oneline ? "\\" : "\n" ;
 
-       if (batch_file) 
+       if (batch_file)
                return batch(batch_file);
-               
+
        if (rtnl_open(&rth, 0) < 0)
                exit(1);
 
-       if (strlen(basename) > 2) 
+       if (strlen(basename) > 2)
                return do_cmd(basename+2, argc, argv);
 
-       if (argc > 1) 
+       if (argc > 1)
                return do_cmd(argv[1], argc-1, argv+1);
 
        rtnl_close(&rth);