/** * Sets the Vendor type in OFVendor message */ public void setVendor() { super.setVendor(V6StatsRequest.NICIRA_VENDOR_ID); }
@Override public OFMessage instantiate() { return new OFVendor(); } }), FEATURES_REQUEST(5, OFFeaturesRequest.class,
/** * Sends a role reply. * * @param role the role * @param xid the transaction ID * @param channel the channel on which to send */ private void sendRoleReply(Role role, int xid, Channel channel) { OFVendor vendor = new OFVendor(); vendor.setXid(xid); vendor.setVendor(OFNiciraVendorData.NX_VENDOR_ID); OFRoleReplyVendorData reply = new OFRoleReplyVendorData(role.toNxRole()); vendor.setVendorData(reply); vendor.setLengthU(OFVendor.MINIMUM_LENGTH + reply.getLength()); channel.write(Collections.singletonList(vendor)); }
@Override void processOFVendor(final ControllerChannelHandler h, final OFVendor m) { if (m.getVendor() == OFNiciraVendorData.NX_VENDOR_ID && m.getVendorData() instanceof OFRoleRequestVendorData) { h.sw.handleRoleIO(m, h.channel); } else { this.unhandledMessageReceived(h, m); } }
super.writeTo(data); data.putInt(getIPv6ExtensionFlowModAddSubType()); data.putLong(this.cookie);
@Override public void handleRoleIO(OFVendor msg, Channel channel) { Role role = extractNiciraRoleRequest(channel, msg); try { this.roleMan.setRole(channel, role); sendRoleReply(role, msg.getXid(), channel); log.info("Finished handling role for {}", channel.getRemoteAddress()); } catch (IllegalArgumentException | UnknownRoleException ex) { log.warn(ex.getMessage()); } }
/** * Extracts the vendor-specific (Nicira) role. * * @param chan the channel * @param vendorMessage the vendor message * @return the role */ private Role extractNiciraRoleRequest(Channel chan, OFVendor vendorMessage) { int vendor = vendorMessage.getVendor(); if (vendor != OFNiciraVendorData.NX_VENDOR_ID) { return null; } if (!(vendorMessage.getVendorData() instanceof OFRoleRequestVendorData)) { return null; } OFRoleRequestVendorData roleRequestVendorData = (OFRoleRequestVendorData) vendorMessage .getVendorData(); Role role = Role.fromNxRole(roleRequestVendorData.getRole()); if (role == null) { String msg = String.format("Controller: [%s], State: [%s], " + "received NX_ROLE_REPLY with invalid role " + "value %d", chan.getRemoteAddress(), this.toString(), roleRequestVendorData.getRole()); throw new ControllerStateException(msg); } return role; }
super.writeTo(data); data.putInt(getIPv6ExtensionFlowModAddSubType()); data.putLong(this.cookie);
/** * Sets the Vendor type in OFVendor message */ public void setVendor() { super.setVendor(V6StatsRequest.NICIRA_VENDOR_ID); }