This commit was generated by cvs2svn to compensate for changes in r2587,
[iproute2.git] / ip / ipmonitor.c
index cdaeb6f..50b6327 100644 (file)
@@ -38,6 +38,9 @@ int accept_msg(const struct sockaddr_nl *who,
 {
        FILE *fp = (FILE*)arg;
 
+       if (timestamp)
+               print_timestamp(fp);
+
        if (n->nlmsg_type == RTM_NEWROUTE || n->nlmsg_type == RTM_DELROUTE) {
                print_route(who, n, arg);
                return 0;
@@ -85,7 +88,6 @@ int accept_msg(const struct sockaddr_nl *who,
 
 int do_ipmonitor(int argc, char **argv)
 {
-       struct rtnl_handle rth;
        char *file = NULL;
        unsigned groups = ~RTMGRP_TC;
        int llink=0;
@@ -93,6 +95,7 @@ int do_ipmonitor(int argc, char **argv)
        int lroute=0;
        int lprefix=0;
 
+       rtnl_close(&rth);
        ipaddr_reset_filter(1);
        iproute_reset_filter();
        ipneigh_reset_filter();
@@ -150,16 +153,15 @@ int do_ipmonitor(int argc, char **argv)
                        perror("Cannot fopen");
                        exit(-1);
                }
-               return rtnl_from_file(fp, accept_msg, (void*)stdout);
+               return rtnl_from_file(fp, accept_msg, stdout);
        }
 
        if (rtnl_open(&rth, groups) < 0)
                exit(1);
-
        ll_init_map(&rth);
 
-       if (rtnl_listen(&rth, accept_msg, (void*)stdout) < 0)
+       if (rtnl_listen(&rth, accept_msg, stdout) < 0)
                exit(2);
 
-       exit(0);
+       return 0;
 }