]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/ipprefix.c
man: tc-taprio.8: fix syntax error
[mirror_iproute2.git] / ip / ipprefix.c
index cf68f897ddb8a4ecea67dfa81c6121e56cc71e15..466af2088d9037e4a56ee2df21fa9eee145b12b5 100644 (file)
@@ -12,8 +12,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
  */
 /*
  * based on ip.c, iproute.c
 #include <string.h>
 #include <sys/socket.h>
 #include <netinet/icmp6.h>
+
 #include "utils.h"
+#include "ip_common.h"
 
 /* prefix flags; see kernel's net/ipv6/addrconf.c and include/net/if_inet6.h */
 #define IF_PREFIX_ONLINK       0x01
 #define IF_PREFIX_AUTOCONF     0x02
 
-int print_prefix(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
+int print_prefix(struct nlmsghdr *n, void *arg)
 {
-       FILE *fp = (FILE*)arg;
+       FILE *fp = (FILE *)arg;
        struct prefixmsg *prefix = NLMSG_DATA(n);
        int len = n->nlmsg_len;
-       struct rtattr * tb[RTA_MAX+1];
+       struct rtattr *tb[RTA_MAX+1];
        int family = preferred_family;
 
        if (n->nlmsg_type != RTM_NEWPREFIX) {
@@ -70,20 +71,11 @@ int print_prefix(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 
        parse_rtattr(tb, RTA_MAX, RTM_RTA(prefix), len);
 
-       fprintf(fp, "prefix ");
-
        if (tb[PREFIX_ADDRESS]) {
-               struct in6_addr *pfx;
-               char abuf[256];
-
-               pfx = (struct in6_addr *)RTA_DATA(tb[PREFIX_ADDRESS]);
-
-               memset(abuf, '\0', sizeof(abuf));
-               fprintf(fp, "%s", rt_addr_n2a(family, sizeof(*pfx), pfx,
-                                             abuf, sizeof(abuf)));
+               fprintf(fp, "prefix %s/%u",
+                       rt_addr_n2a_rta(family, tb[PREFIX_ADDRESS]),
+                       prefix->prefix_len);
        }
-       fprintf(fp, "/%u ", prefix->prefix_len);
-
        fprintf(fp, "dev %s ", ll_index_to_name(prefix->prefix_ifindex));
 
        if (prefix->prefix_flags & IF_PREFIX_ONLINK)
@@ -92,8 +84,8 @@ int print_prefix(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
                fprintf(fp, "autoconf ");
 
        if (tb[PREFIX_CACHEINFO]) {
-               struct prefix_cacheinfo *pc;
-               pc = (struct prefix_cacheinfo *)RTA_DATA(tb[PREFIX_CACHEINFO]);
+               const struct prefix_cacheinfo *pc
+                        = RTA_DATA(tb[PREFIX_CACHEINFO]);
 
                fprintf(fp, "valid %u ", pc->valid_time);
                fprintf(fp, "preferred %u ", pc->preferred_time);
@@ -104,4 +96,3 @@ int print_prefix(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 
        return 0;
 }
-