/*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <stddef.h>
#include <linux/rtnetlink.h>
#include "netlink.h"
+#include "netlink-socket.h"
#include "ofpbuf.h"
#include "poll-loop.h"
#include "timeval.h"
};
int
-main(int argc UNUSED, char *argv[])
+main(int argc OVS_UNUSED, char *argv[])
{
struct nl_sock *sock;
int error;
set_program_name(argv[0]);
- time_init();
- vlog_init();
- vlog_set_levels(VLM_ANY_MODULE, VLF_ANY_FACILITY, VLL_DBG);
+ vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_DBG);
- error = nl_sock_create(NETLINK_ROUTE, RTNLGRP_LINK, 0, 0, &sock);
+ error = nl_sock_create(NETLINK_ROUTE, &sock);
if (error) {
ovs_fatal(error, "could not create rtnetlink socket");
}
+ error = nl_sock_join_mcgroup(sock, RTNLGRP_LINK);
+ if (error) {
+ ovs_fatal(error, "could not join RTNLGRP_LINK multicast group");
+ }
+
for (;;) {
struct ofpbuf *buf;
} else if (error) {
ovs_fatal(error, "error on network monitor socket");
} else {
+ struct iff_flag {
+ unsigned int flag;
+ const char *name;
+ };
+
+ static const struct iff_flag flags[] = {
+ { IFF_UP, "UP", },
+ { IFF_BROADCAST, "BROADCAST", },
+ { IFF_DEBUG, "DEBUG", },
+ { IFF_LOOPBACK, "LOOPBACK", },
+ { IFF_POINTOPOINT, "POINTOPOINT", },
+ { IFF_NOTRAILERS, "NOTRAILERS", },
+ { IFF_RUNNING, "RUNNING", },
+ { IFF_NOARP, "NOARP", },
+ { IFF_PROMISC, "PROMISC", },
+ { IFF_ALLMULTI, "ALLMULTI", },
+ { IFF_MASTER, "MASTER", },
+ { IFF_SLAVE, "SLAVE", },
+ { IFF_MULTICAST, "MULTICAST", },
+ { IFF_PORTSEL, "PORTSEL", },
+ { IFF_AUTOMEDIA, "AUTOMEDIA", },
+ { IFF_DYNAMIC, "DYNAMIC", },
+ };
+
struct nlattr *attrs[ARRAY_SIZE(rtnlgrp_link_policy)];
struct nlmsghdr *nlh;
struct ifinfomsg *iim;
+ int i;
nlh = ofpbuf_at(buf, 0, NLMSG_HDRLEN);
iim = ofpbuf_at(buf, NLMSG_HDRLEN, sizeof *iim);
: nlh->nlmsg_type == RTM_GETLINK ? "RTM_GETLINK"
: nlh->nlmsg_type == RTM_SETLINK ? "RTM_SETLINK"
: "other"));
+ printf("\tflags:");
+ for (i = 0; i < ARRAY_SIZE(flags); i++) {
+ if (iim->ifi_flags & flags[i].flag) {
+ printf(" %s", flags[i].name);
+ }
+ }
+ printf("\n");
if (attrs[IFLA_MASTER]) {
uint32_t idx = nl_attr_get_u32(attrs[IFLA_MASTER]);
char ifname[IFNAMSIZ];