User mode sends down three distinct Read ioctl commands for Events, Packet Reads and Dumps. In case the Packet Read socket can not be distinguished a Set function will be provided.
Signed-off-by: Eitan Eliahu <elia...@vmware.com> --- lib/netlink-socket.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c index 1717ab8..88d36b1 100644 --- a/lib/netlink-socket.c +++ b/lib/netlink-socket.c @@ -81,6 +81,7 @@ struct nl_sock { #ifdef _WIN32 HANDLE handle; OVERLAPPED overlapped; + DWORD readIoctl; #else int fd; #endif @@ -157,7 +158,8 @@ nl_sock_create(int protocol, struct nl_sock **sockp) VLOG_ERR("fcntl: %s", ovs_lasterror_to_string()); goto error; } - + /* Initialize the type/ioctl to Generic */ + sock->readIoctl = OVS_IOCTL_READ; #else sock->fd = socket(AF_NETLINK, SOCK_RAW, protocol); if (sock->fd < 0) { @@ -374,8 +376,11 @@ int nl_sock_join_mcgroup(struct nl_sock *sock, unsigned int multicast_group) { #ifdef _WIN32 + /* Set the socket type as a "multicast" socket */ + sock->readIoctl = OVS_IOCTL_READ_EVENT; int error = nl_sock_mcgroup(sock, multicast_group, true); if (error) { + sock->readIoctl = OVS_IOCTL_READ; VLOG_WARN("could not join multicast group %u (%s)", multicast_group, ovs_strerror(errno)); return errno; @@ -411,6 +416,7 @@ nl_sock_leave_mcgroup(struct nl_sock *sock, unsigned int multicast_group) multicast_group, ovs_strerror(errno)); return errno; } + sock->readIoctl = OVS_IOCTL_READ; #else if (setsockopt(sock->fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP, &multicast_group, sizeof multicast_group) < 0) { @@ -530,7 +536,7 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait) nlmsghdr->nlmsg_len = UINT32_MAX; #ifdef _WIN32 DWORD bytes; - if (!DeviceIoControl(sock->handle, OVS_IOCTL_READ, + if (!DeviceIoControl(sock->handle, sock->readIoctl, NULL, 0, tail, sizeof tail, &bytes, NULL)) { retval = -1; errno = EINVAL; @@ -1126,7 +1132,7 @@ pend_io_request(const struct nl_sock *sock) int retval; int error; DWORD bytes; - OVERLAPPED *overlapped = &sock->overlapped; + OVERLAPPED *overlapped = CONST_CAST(OVERLAPPED *, &sock->overlapped); int ovs_msg_size = sizeof (struct nlmsghdr) + sizeof (struct genlmsghdr) + sizeof (struct ovs_header); -- 1.9.4.msysgit.0 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev