Added the handlers for update_flags and set_etheraddr. These handlers were needed for vswitchd bringup on windows platform.
Signed-off-by: Ankur Sharma <ankursha...@vmware.com> --- lib/netdev-windows.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/lib/netdev-windows.c b/lib/netdev-windows.c index 02d37a7..0ce77a8 100644 --- a/lib/netdev-windows.c +++ b/lib/netdev-windows.c @@ -32,6 +32,9 @@ #include "netlink-socket.h" #include "netlink.h" +#define IFF_RUNNING 0x20 +#define IFF_PROMISC 0x40 + VLOG_DEFINE_THIS_MODULE(netdev_windows); static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(9999, 5); @@ -326,7 +329,78 @@ netdev_windows_get_mtu(const struct netdev *netdev_, int *mtup) } return 0; } - + +static int +netdev_windows_set_etheraddr(const struct netdev *netdev_, uint8_t mac[6]) +{ + struct netdev_windows *netdev = netdev_windows_cast(netdev_); + + if (netdev->cache_valid & VALID_ETHERADDR) { + memcpy(netdev->mac, mac, ETH_ADDR_LEN); + } else { + return EINVAL; + } + return 0; +} + +static int +nd_to_iff_flags(enum netdev_flags nd) +{ + int iff = 0; + if (nd & NETDEV_UP) { + iff |= IFF_UP; + } + if (nd & NETDEV_PROMISC) { + iff |= IFF_PROMISC; + } + return iff; +} + +static int +iff_to_nd_flags(int iff) +{ + enum netdev_flags nd = 0; + if (iff & IFF_UP) { + nd |= NETDEV_UP; + } + + if (iff & IFF_PROMISC) { + nd |= NETDEV_PROMISC; + } + + return nd; +} + +static int +netdev_win_set_flag(const char *name, uint32_t flags) +{ + return 0; +} + +static int +netdev_win_update_flags_system(struct netdev *netdev_, + enum netdev_flags off, + enum netdev_flags on, + enum netdev_flags *old_flagsp) +{ + struct netdev_windows *netdev; + int old_flags, new_flags; + int error = 0; + + netdev = netdev_windows_cast(netdev_); + + old_flags = netdev->ifi_flags; + *old_flagsp = iff_to_nd_flags(old_flags); + new_flags = (old_flags & ~nd_to_iff_flags(off)) | nd_to_iff_flags(on); + + /* Set netdev flags. */ + if (new_flags != old_flags) { + const char *devname = netdev_get_name(&netdev->up); + error = netdev_win_set_flag(devname, new_flags); + } + return error; +} + static int netdev_windows_internal_construct(struct netdev *netdev_) @@ -343,6 +417,8 @@ netdev_windows_internal_construct(struct netdev *netdev_) .destruct = netdev_windows_destruct, \ .dealloc = netdev_windows_dealloc, \ .get_etheraddr = netdev_windows_get_etheraddr, \ + .set_etheraddr = netdev_windows_set_etheraddr, \ + .update_flags = netdev_win_update_flags_system, \ } const struct netdev_class netdev_windows_class = -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev