Trailing whitespace generates a lot of warnings -- mass-remove it.
Change-Id: I9b73bc873685576daa80a998a58d1ce55e475c35
Signed-off-by: Robert Varga <rovarga@cisco.com>
</plugins>
<pluginManagement>
<plugins>
- <!--This plugin's configuration is used to store Eclipse
+ <!--This plugin's configuration is used to store Eclipse
m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
* @return future set to true, when disconnect completed
*/
Future<Boolean> disconnect();
-
+
/**
* @return true, if connection to switch is alive
*/
boolean isAlive();
-
+
/**
* @return address of the remote end - address of a switch if connected
*/
* @param messageListener here will be pushed all messages from switch
*/
void setMessageListener(OpenflowProtocolListener messageListener);
-
+
/**
* @param systemListener here will be pushed all system messages from library
*/
void fireConnectionReadyNotification();
/**
- * set listener for connection became ready-to-use event
+ * set listener for connection became ready-to-use event
* @param connectionReadyListener
*/
void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener);
* @return address to bind, if null, all available interfaces will be used
*/
InetAddress getAddress();
-
+
/**
* @return port to bind
*/
int getPort();
-
+
/**
* @return transport protocol to use
*/
Object getTransferProtocol();
-
+
/**
* @return TLS configuration object
*/
TlsConfiguration getTlsConfiguration();
-
+
/**
- * @return silence time (in milliseconds) - after this time {@link SwitchIdleEvent} message is sent upstream
+ * @return silence time (in milliseconds) - after this time {@link SwitchIdleEvent} message is sent upstream
*/
long getSwitchIdleTimeout();
-
+
/**
* @return seed for {@link SSLEngine}
*/
Object getSslContext();
-
+
/**
* @return thread numbers for TcpHandler's eventloopGroups
*/
public interface ListeningStatusProvider {
/**
- * @return future holding startup result of all library instances under plugin's control
+ * @return future holding startup result of all library instances under plugin's control
*/
Future<Boolean> isOnline();
/**
* Used for StatisticsCounter configuration
- *
+ *
* @author madamjak
*/
public interface StatisticsConfiguration {
*
*/
public interface SwitchConnectionHandler {
-
+
/**
* @param connection to switch proving message sending/receiving, connection management
*/
void onSwitchConnected(ConnectionAdapter connection);
-
+
/**
* @param switchAddress
* @return true, if connection from switch having given address shell be accepted; false otherwise
* @return keystore location
*/
String getTlsKeystore();
-
+
/**
* @return keystore type
*/
KeystoreType getTlsKeystoreType();
-
+
/**
* @return truststore location
*/
String getTlsTruststore();
-
+
/**
* @return truststore type
*/
* instructions, match entries, ... ) which are differentiated by
* vendor / experimenter subtype, vendor has to switch / choose between
* these subtypes. <br />
- *
+ *
* This has to be done in this way because of experimenter headers, which
* provide only vendor / experimenter ID. Subtype position may be different
* for different vendors (or not present at all) - that's why vendor has to
* Registers deserializer.
* Throws IllegalStateException when there is
* a deserializer already registered under given key.
- *
+ *
* If the deserializer implements {@link DeserializerRegistryInjector} interface,
* the deserializer is injected with DeserializerRegistry instance.
- *
+ *
* @param key used for deserializer lookup
* @param deserializer deserializer instance
*/
result = prime * result + ((msgType2 == null) ? 0 : msgType2.hashCode());
return result;
}
-
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
/**
* @author michal.polkorab
- * @param <E>
+ * @param <E>
*/
public interface HeaderDeserializer<E extends DataObject> extends OFGeneralDeserializer {
/**
* Deserializes byte message headers
- *
+ *
* @param rawMessage message as bytes in ByteBuf
* @return POJO/DTO
*/
private final Class<? extends E> msgType;
private final short msgVersion;
-
+
/**
* @param msgVersion protocol version
* @param msgType type of message - class of serialized object
this.msgType = msgType;
this.msgVersion = msgVersion;
}
-
+
@Override
public String toString() {
return "msgVersion: " + msgVersion + " objectType: " + msgType.getName();
/**
* Transforms byte message into POJO/DTO (of type E).
- *
+ *
* @param message message as bytes in ByteBuf
* @return POJO/DTO
*/
* instructions, match entries, ... ) which are differentiated by
* vendor / experimenter subtype, vendor has to switch / choose between
* these subtypes. <br />
- *
+ *
* This has to be done in this way because of unknown augmentations
* - that's why vendor has to handle it in his own implementations.
* @author michal.polkorab
/**
- * Stores and handles serializers
+ * Stores and handles serializers
* @author michal.polkorab
*
*/
* @param msgTypeKey lookup key
* @return serializer or NullPointerException if no serializer was found
*/
- <KEYTYPE, SERIALIZERTYPE extends OFGeneralSerializer> SERIALIZERTYPE
+ <KEYTYPE, SERIALIZERTYPE extends OFGeneralSerializer> SERIALIZERTYPE
getSerializer(MessageTypeKey<KEYTYPE> msgTypeKey);
/**
* Registers serializer
* Throws IllegalStateException when there is
* a serializer already registered under given key.
- *
+ *
* If the serializer implements {@link SerializerRegistryInjector} interface,
* the serializer is injected with SerializerRegistry instance.
- *
+ *
* @param key used for serializer lookup
* @param serializer serializer implementation
*/
/**
* @param version protocol wire version
* @param type instruction type
- * @param experimenterId
+ * @param experimenterId
*/
public InstructionDeserializerKey(short version, int type,
Long experimenterId) {
* @author michal.polkorab
*
*/
-public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey
+public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey
implements ExperimenterDeserializerKey {
/**
/**
* @author michal.polkorab
*/
-public final class ExperimenterActionSerializerKey extends ActionSerializerKey<Experimenter>
+public final class ExperimenterActionSerializerKey extends ActionSerializerKey<Experimenter>
implements ExperimenterSerializerKey {
private Class<? extends ExperimenterActionSubType> actionSubType;
* @author michal.polkorab
*
*/
-public final class ExperimenterIdDeserializerKey extends MessageCodeKey
+public final class ExperimenterIdDeserializerKey extends MessageCodeKey
implements ExperimenterDeserializerKey {
private Long experimenterId;
this.experimenterId = experimenterId;
}
-
+
@Override
public int hashCode() {
final int prime = 31;
/**
* @param version protocol wire version
- * @param experimenterId
+ * @param experimenterId
*/
public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) {
super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId);
public static long intToUnsignedLong(int value) {
return value & 0x00000000ffffffffL;
}
-
+
/**
* @param value
* @return long cut into int
public static final int OFHEADER_SIZE = 8;
/** Zero length - used when the length is updated later */
public static final int EMPTY_LENGTH = 0;
-
+
/** Length of mac address */
public static final byte MAC_ADDRESS_LENGTH = 6;
/** Number of groups in ipv4 address */
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
+
module openflow-action {
namespace "urn:opendaylight:openflow:common:action";
prefix "ofaction";
container actions-container {
uses actions-grouping;
}
-
+
grouping actions-grouping {
list action {
config false;
}
}
}
-
+
// OF1.0 structures
identity set_vlan_vid {
description "Set the 802.1q VLAN id (OF v1.0).";
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
+
module openflow-augments {
namespace "urn:opendaylight:openflow:augments";
prefix "aug";
-
+
import yang-ext {prefix ext;}
import ietf-inet-types {prefix inet;}
import ietf-yang-types {prefix yang;}
import openflow-extensible-match {prefix oxm;}
revision "2013-10-02" {
- description "OpenFlow 1.3 - augments model.
- Please visit
+ description "OpenFlow 1.3 - augments model.
+ Please visit
https://wiki.opendaylight.org/view/File:OpenFlow_Protocol_Library_-_Project_documentation.pdf
- Augmentation Tables chapter";
}
type oft:experimenter-id;
}
}
-
+
// OFP_QUEUE_PROP AUGMENTS
augment "/ofproto:queue-prop-container/ofproto:queue-property" {
ext:augment-identifier "rate-queue-property";
type oft:experimenter-id;
}
}
-
+
// OFP_ERROR_AUGMENTS (only experimenter till OpenFlow v1.3)
augment "/ofproto:error-message" {
ext:augment-identifier "experimenter-id-error";
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
+
module openflow-configuration {
namespace "urn:opendaylight:openflow:config";
prefix "of-config";
typedef path-type {
type enumeration {
enum CLASSPATH {
- value 0;
+ value 0;
description "Keystore file is located on classpath.";
}
enum PATH {
- value 1;
+ value 1;
description "Keystore file is located on absolute or relative path.";
}
}
typedef keystore-type {
type enumeration {
enum JKS {
- value 0;
+ value 0;
description "Keystore type - JKS.";
}
enum PKCS12 {
- value 1;
+ value 1;
description "Keystore type - PKCS12.";
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
+
module openflow-extensible-match {
namespace "urn:opendaylight:openflow:oxm";
prefix "oxm";
}
identity oxm-match-type {
- description
+ description
"The OpenFlow Extensible Match type must be supported by all OpenFlow
switches.";
base oft:match-type-base;
}
-
+
// oxm classes
identity oxm-class-base {
description "Base identity for OXM classes";
base oxm-class-base;
}
identity experimenter-class {
- description
+ description
"Marks Experimenter match type class.
All experimenter match classes MUST use this class as a base.";
base oxm-class-base;
container oxm-container {
uses oxm-fields-grouping;
}
-
+
grouping oxm-fields-grouping {
list match-entries {
description "OXM TLV-structures (Type Length Value)";
}
leaf has-mask {
type boolean;
- }
+ }
}
}
}
}
}
-
+
}
\ No newline at end of file
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
+
module openflow-instruction {
namespace "urn:opendaylight:openflow:common:instruction";
prefix "ofinstruction";
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
+
module openflow-protocol {
namespace "urn:opendaylight:openflow:protocol";
prefix "ofproto";
import ietf-yang-types {prefix yang;}
-
+
import openflow-types {prefix oft;}
import openflow-extensible-match { prefix oxm;}
import openflow-instruction { prefix ofinstruction;}
}
leaf peer-features {
description "Features advertised by peer.";
- type oft:port-features;
+ type oft:port-features;
}
leaf curr-speed {
description "Current port bitrate in kbps.";
leaf config-v10 {
type oft:port-config-v10;
}
- leaf state-v10 {
+ leaf state-v10 {
type oft:port-state-v10;
}
leaf current-features-v10 {
description "Features supported by the port.";
type oft:port-features-v10;
}
- leaf peer-features-v10 {
+ leaf peer-features-v10 {
description "Features advertised by peer.";
- type oft:port-features-v10;
+ type oft:port-features-v10;
}
}
uses ofaction:actions-grouping;
}
-
+
container table-features-properties-container {
uses table-features-properties-grouping;
}
reference "OFPT_HELLO message in Openflow Switch 1.3 Spec";
/* Symmetric message */
uses ofHeader;
-
+
list elements {
uses ofHelloElementHeader;
-
+
leaf-list version-bitmap {
type boolean;
}
reference "OFPT_ERROR message in Openflow Switch 1.3 Spec";
/* Symmetric message */
uses ofHeader;
-
+
leaf type {
type uint16;
}
type string;
}
leaf data {
- type binary;
+ type binary;
}
}
grouping echo-request {
reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec";
/* Symmetric message */
uses ofHeader;
-
+
leaf data {
type binary;
}
reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec";
/* Symmetric message */
uses ofHeader;
-
+
leaf data {
type binary;
}
reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec";
/* Symmetric message */
uses ofHeader;
-
+
leaf experimenter {
type oft:experimenter-id;
}
reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
-
+
leaf datapathId {
type uint64;
}
reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
-
+
leaf flags {
type oft:switch-config-flag;
}
grouping set-config {
reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
-
+
uses ofHeader;
-
+
leaf flags {
type oft:switch-config-flag;
}
grouping packet-in {
reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec";
/* Async message */
-
+
uses ofHeader;
-
+
leaf buffer-id {
// ID assigned by datapath.
type uint32;
type uint16;
}
leaf reason {
- // Reason packet is being sent (one of OFPR_*)
+ // Reason packet is being sent (one of OFPR_*)
type oft:packet-in-reason;
}
leaf table-id {
leaf data {
type binary;
}
-
+
// OF1.0 structures
leaf in-port {
type uint16;
reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec";
/* Async message */
uses ofHeader;
-
+
leaf cookie {
type uint64;
}
type uint64;
}
uses oxm:match-grouping;
-
+
// OF1.0 structures
uses oxm:match-v10-grouping;
- }
+ }
grouping port-status {
reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec";
-
+
uses ofHeader;
-
+
uses port-grouping;
-
+
leaf reason {
type oft:port-reason;
}
grouping packet-out {
reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
-
+
uses ofHeader;
-
+
uses ofaction:actions-grouping;
-
+
leaf data {
type binary;
}
leaf in-port {
type oft:port-number;
}
- }
+ }
grouping flow-mod {
reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
-
+
uses ofHeader;
-
+
leaf cookie {
type uint64;
}
type oft:flow-mod-flags;
}
uses oxm:match-grouping;
-
+
uses ofinstruction:instructions-grouping;
-
+
// OF1.0 structures
leaf flags-v10 {
type oft:flow-mod-flags-v10;
}
uses oxm:match-v10-grouping;
uses ofaction:actions-grouping;
- }
+ }
grouping group-mod {
reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
-
+
uses ofHeader;
-
+
leaf command {
type oft:group-mod-command;
}
leaf group-id {
type oft:group-id;
}
-
+
uses buckets-grouping;
}
-
+
grouping port-mod {
reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
-
+
leaf port-no {
type oft:port-number;
}
leaf hw-address {
type yang:mac-address;
- }
+ }
leaf config {
type oft:port-config;
- }
+ }
leaf mask {
type oft:port-config;
}
leaf advertise-v10 {
type oft:port-features-v10;
}
- }
+ }
grouping table-mod {
reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
-
+
leaf table-id {
type oft:table-id;
}
leaf config {
type oft:table-config;
}
- }
-
+ }
+
/* Multipart messages. */
grouping multipart-request {
reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
-
+
leaf type {
type oft:multipart-type;
}
type uint64;
}
uses oxm:match-grouping;
-
+
// OF1.0 structures
uses oxm:match-v10-grouping;
}
type uint64;
}
uses oxm:match-grouping;
-
+
// OF1.0 structures
uses oxm:match-v10-grouping;
}
}
}
}
- }
+ }
grouping multipart-reply {
reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
-
+
leaf type {
type oft:multipart-type;
}
type uint64;
}
uses oxm:match-grouping;
-
+
uses ofinstruction:instructions-grouping;
-
+
// OF1.0 structures
uses oxm:match-v10-grouping;
uses ofaction:actions-grouping;
leaf matched-count {
type uint64;
}
-
+
// OF1.0 structures
leaf name {
type string;
}
leaf config {
type oft:table-config;
- }
+ }
leaf max-entries {
type uint32;
}
}
}
}
- }
+ }
/* Barrier messages. */
grouping barrier-request {
reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
- }
+ }
grouping barrier-reply {
reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
- }
+ }
/* Queue Configuration messages. */
grouping queue-get-config-request {
reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
-
+
uses ofHeader;
-
+
leaf port {
type oft:port-number;
}
- }
+ }
grouping queue-get-config-reply {
reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
-
+
leaf port {
type oft:port-number;
}
grouping role-request {
reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
-
+
uses ofHeader;
-
+
leaf role {
type oft:controller-role;
}
leaf generation-id {
type uint64;
}
- }
+ }
grouping role-reply {
reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
-
+
leaf role {
type oft:controller-role;
}
leaf generation-id {
type uint64;
}
- }
+ }
/* Asynchronous message configuration. */
grouping get-async-request {
reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
- }
+ }
grouping get-async-reply {
reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
uses ofHeader;
uses async-body-grouping;
- }
+ }
grouping set-async {
reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec";
/* Controller/switch message */
-
+
uses ofHeader;
uses async-body-grouping;
}
-
+
grouping async-body-grouping {
list packet-in-mask {
leaf-list mask {
/* Controller/switch message */
uses ofHeader;
-
+
leaf command {
type oft:meter-mod-command;
- }
+ }
leaf flags {
type oft:meter-flags;
}
uses meter-band-header;
}
}
-
+
container meter-band-container {
uses meter-band-header;
}
}
}
}
-
+
grouping meter-band-commons {
leaf type {
type oft:meter-band-type;
notification hello-message {
uses hello;
reference "OFPT_HELLO message in Openflow Switch 1.3 Spec";
-
+
/* Symmetric message */
}
notification error-message {
uses error;
reference "OFPT_ERROR message in Openflow Switch 1.3 Spec";
-
+
/* Symmetric message */
}
notification echo-request-message {
uses echo-request;
reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec";
-
+
/* Symmetric message */
}
notification experimenter-message {
uses echo-reply;
}
}
-
+
rpc echo-reply {
input {
uses echo-reply;
}
}
-
+
rpc hello {
input {
uses hello;
}
}
-
+
rpc experimenter {
input {
uses experimenter;
uses features-reply;
}
}
-
+
rpc get-config {
input {
uses get-config-request;
}
/* Controller/switch message */
}
-
+
rpc set-config {
input {
uses set-config;
- }
+ }
/* Controller/switch message */
}
/* Asynchronous messages. */
notification packet-in-message {
uses packet-in;
-
+
/* Async message */
}
notification flow-removed-message {
uses flow-removed;
-
+
/* Async message */
- }
+ }
notification port-status-message {
uses port-status;
-
+
} /* Async message */
/* Controller command messages. */
uses packet-out;
}
/* Controller/switch message */
- }
+ }
rpc flow-mod {
input {
uses flow-mod;
}
/* Controller/switch message */
- }
+ }
rpc group-mod {
input {
uses group-mod;
}
/* Controller/switch message */
- }
+ }
rpc port-mod {
input {
uses port-mod;
}
} /* Controller/switch message */
-
+
rpc table-mod {
input {
uses table-mod;
uses multipart-reply;
// notification because of multiple following responses
} /* Controller/switch message */
-
+
/* Barrier messages. */
rpc barrier {
output {
uses queue-get-config-reply;
}
- }
+ }
/* Controller role change request messages. */
rpc role-request {
uses role-reply;
}
} /* Controller/switch message */
-
+
/* Asynchronous message configuration. */
rpc get-async {
input {
output {
uses get-async-reply;
}
- }
+ }
/* Controller/switch message */
rpc set-async {
- input {
+ input {
uses set-async;
}
-
- }
+
+ }
/* Meters and rate limiters configuration messages. */
rpc meter-mod {
input {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
+
module openflow-types {
namespace "urn:opendaylight:openflow:common:types";
prefix "oft";
supports special / reserved values (in OF v1.3)";
type uint32;
}
-
+
typedef port-number-values {
description "Reserved OpenFlow Port (fake output \"ports\") (OF v1.3).";
type enumeration {
description "Submit the packet to the first flow table
NB: This destination port can only be
used in packet-out messages.";
- value -7; // 0xfffffff9
+ value -7; // 0xfffffff9
}
enum NORMAL {
description "Process with normal L2/L3 switching.";
- value -6; // 0xfffffffa
+ value -6; // 0xfffffffa
}
enum FLOOD {
description "All physical ports in VLAN, except input
port and those blocked or link down.";
- value -5; // 0xfffffffb
+ value -5; // 0xfffffffb
}
enum ALL {
description "All physical ports except input port.";
- value -4; // 0xfffffffc
+ value -4; // 0xfffffffc
}
enum CONTROLLER {
description "Send to controller.";
}
enum ANY {
description "Wildcard port used only for flow mod
- (delete) and flow stats requests. Selects
+ (delete) and flow stats requests. Selects
all flows regardless of output port
(including flows with no output port).";
value -1; // 0xffffffff
typedef port-features {
description "Features of ports available in datapath.";
type bits {
- bit _10mb_hd {
+ bit _10mb_hd {
position 0;
description "10 Mb half-duplex rate support.";
}
- bit _10mb-fd {
+ bit _10mb-fd {
position 1;
description "10 Mb full-duplex rate support.";
}
- bit _100mb-hd {
+ bit _100mb-hd {
position 2;
description "100 Mb half-duplex rate support.";
}
- bit _100mb-fd {
+ bit _100mb-fd {
position 3;
description "100 Mb full-duplex rate support.";
}
- bit _1gb-hd {
+ bit _1gb-hd {
position 4;
description "1 Gb half-duplex rate support.";
}
- bit _1gb-fd {
+ bit _1gb-fd {
position 5;
description "1 Gb full-duplex rate support.";
}
- bit _10gb-fd {
+ bit _10gb-fd {
position 6;
description "10 Gb full-duplex rate support.";
}
- bit _40gb-fd {
+ bit _40gb-fd {
position 7;
description "40 Gb full-duplex rate support.";
}
- bit _100gb-fd {
+ bit _100gb-fd {
position 8;
description "100 Gb full-duplex rate support.";
}
- bit _1tb-fd {
+ bit _1tb-fd {
position 9;
description "1 Tb full-duplex rate support.";
}
- bit other {
+ bit other {
position 10;
description "Other rate, not in the list.";
}
- bit copper {
+ bit copper {
position 11;
description "Copper medium.";
}
- bit fiber {
+ bit fiber {
position 12;
description "Fiber medium.";
}
- bit autoneg {
+ bit autoneg {
position 13;
description "Auto-negotiation.";
}
- bit pause {
+ bit pause {
position 14;
description "Pause.";
}
- bit pause-asym {
+ bit pause-asym {
position 15;
description "Asymmetric pause.";
}
}
typedef port-config {
- description
+ description
"Flags to indicate behavior of the physical port. These flags are
- describe the current configuration and used port_mod message
+ describe the current configuration and used port_mod message
to configure the port's behavior.";
type bits {
- bit port-down {
+ bit port-down {
//description " Port is administratively down.";
position 0;
}
- bit no-recv {
+ bit no-recv {
//description " Drop all packets received by port.";
position 2;
}
- bit no-fwd {
+ bit no-fwd {
//description " Drop packets forwarded to port.";
position 5;
}
- bit no-packet-in {
+ bit no-packet-in {
//description "Do not send packet-in msgs for port.";
position 6;
}
}
typedef port-state {
- description
+ description
"Current state of the physical port. These are not configurable from
the controller.";
type bits {
}
identity match-type-base {
- description
+ description
"The match type indicates the match structure (set of fields that compose the
match) in use. The match type is placed in the type field at the beginning
- of all match structures.Extensions that define match types may be
+ of all match structures.Extensions that define match types may be
published on the ONF wiki. Support for extensions is optional.";
}
typedef error-type {
type enumeration {
enum HELLO_FAILED {
- value 0;
+ value 0;
description "Hello Protocol failed.";
}
enum BAD_REQUEST {
- value 1;
+ value 1;
description "Request was not understood.";
}
enum BAD_ACTION {
- value 2;
+ value 2;
description "Error in action description.";
}
enum BAD_INSTRUCTION {
- value 3;
+ value 3;
description "Error in instruction list.";
}
enum BAD_MATCH {
- value 4;
+ value 4;
description "Error in match.";
}
enum FLOW_MOD_FAILED {
- value 5;
+ value 5;
description "Problem modifying flow entry.";
}
enum GROUP_MOD_FAILED {
- value 6;
+ value 6;
description "Problem modifying group entry.";
}
enum PORT_MOD_FAILED {
- value 7;
+ value 7;
description "Port mod request failed.";
}
enum TABLE_MOD_FAILED {
- value 8;
+ value 8;
description "Table mod request failed.";
}
enum QUEUE_OP_FAILED {
- value 9;
+ value 9;
description "Queue operation failed.";
}
enum SWITCH_CONFIG_FAILED {
- value 10;
+ value 10;
description "Switch config request failed.";
}
enum ROLE_REQUEST_FAILED {
- value 11;
+ value 11;
description "Controller Role request failed.";
}
enum METER_MOD_FAILED {
- value 12;
+ value 12;
description "Error in meter.";
}
enum TABLE_FEATURES_FAILED {
- value 13;
+ value 13;
description "Setting table features failed.";
}
enum EXPERIMENTER {
- value 65535; //0xffff
+ value 65535; //0xffff
description "Experimenter error messages.";
}
}
}
-
+
typedef hello-failed-code {
type enumeration {
enum INCOMPATIBLE {
- value 0;
+ value 0;
description "Hello Protocol failed.";
}
enum EPERM {
- value 1;
+ value 1;
description "Request was not understood.";
}
}
}
-
+
typedef bad-request-code {
type enumeration {
enum BAD_VERSION {
- value 0;
+ value 0;
}
enum BAD_TYPE {
- value 1;
+ value 1;
}
enum BAD_MULTIPART {
- value 2;
+ value 2;
}
enum BAD_EXPERIMENTER {
- value 3;
+ value 3;
}
enum BAD_EXP_TYPE {
- value 4;
+ value 4;
}
enum EPERM {
- value 5;
+ value 5;
}
enum BAD_LEN {
- value 6;
+ value 6;
}
enum BUFFER_EMPTY {
- value 7;
+ value 7;
}
enum BUFFER_UNKNOWN {
- value 8;
+ value 8;
}
enum BAD_TABLE_ID {
- value 9;
+ value 9;
}
enum IS_SLAVE {
- value 10;
+ value 10;
}
enum BAD_PORT {
- value 11;
+ value 11;
}
enum BAD_PACKET {
- value 12;
+ value 12;
}
enum MULTIPART_BUFFER_OVERFLOW {
- value 13;
+ value 13;
}
}
}
-
+
typedef bad-action-code {
type enumeration {
enum BAD_TYPE {
- value 0;
+ value 0;
}
enum BAD_LEN {
- value 1;
+ value 1;
}
enum BAD_EXPERIMENTER {
- value 2;
+ value 2;
}
enum BAD_EXP_TYPE {
- value 3;
+ value 3;
}
enum BAD_OUT_PORT {
- value 4;
+ value 4;
}
enum BAD_ARGUMENT {
- value 5;
+ value 5;
}
enum EPERM {
- value 6;
+ value 6;
}
enum TOO_MANY {
- value 7;
+ value 7;
}
enum BAD_QUEUE {
- value 8;
+ value 8;
}
enum BAD_OUT_GROUP {
- value 9;
+ value 9;
}
enum MATCH_INCONSISTENT {
- value 10;
+ value 10;
}
enum UNSUPPORTED_ORDER {
- value 11;
+ value 11;
}
enum BAD_TAG {
- value 12;
+ value 12;
}
enum BAD_SET_TYPE {
- value 13;
+ value 13;
}
enum BAD_SET_LEN {
- value 14;
+ value 14;
}
enum BAD_SET_ARGUMENT {
- value 15;
+ value 15;
}
}
}
-
+
typedef bad-instruction-code {
type enumeration {
enum UNKNOWN_INST {
- value 0;
+ value 0;
}
enum UNSUP_INST {
- value 1;
+ value 1;
}
enum BAD_TABLE_ID {
- value 2;
+ value 2;
}
enum UNSUP_METADATA {
- value 3;
+ value 3;
}
enum UNSUP_METADATA_MASK {
- value 4;
+ value 4;
}
enum BAD_EXPERIMENTER {
- value 5;
+ value 5;
}
enum BAD_EXP_TYPE {
- value 6;
+ value 6;
}
enum BAD_LEN {
- value 7;
+ value 7;
}
enum EPERM {
- value 8;
+ value 8;
}
}
}
-
+
typedef bad-match-code {
type enumeration {
enum BAD_TYPE {
- value 0;
+ value 0;
}
enum BAD_LEN {
- value 1;
+ value 1;
}
enum BAD_TAG {
- value 2;
+ value 2;
}
enum BAD_DL_ADDR_MASK {
- value 3;
+ value 3;
}
enum BAD_NW_ADDR_MASK {
- value 4;
+ value 4;
}
enum BAD_WILDCARDS {
- value 5;
+ value 5;
}
enum BAD_FIELD {
- value 6;
+ value 6;
}
enum BAD_VALUE {
- value 7;
+ value 7;
}
enum BAD_MASK {
- value 8;
+ value 8;
}
enum BAD_PREREQ {
- value 9;
+ value 9;
}
enum DUP_FIELD {
- value 10;
+ value 10;
}
enum EPERM {
- value 11;
+ value 11;
}
}
}
-
+
typedef flow-mod-failed-code {
type enumeration {
enum UNKNOWN {
- value 0;
+ value 0;
}
enum TABLE_FULL {
- value 1;
+ value 1;
}
enum BAD_TABLE_ID {
- value 2;
+ value 2;
}
enum OVERLAP {
- value 3;
+ value 3;
}
enum EPERM {
- value 4;
+ value 4;
}
enum BAD_TIMEOUT {
- value 5;
+ value 5;
}
enum BAD_COMMAND {
- value 6;
+ value 6;
}
enum BAD_FLAGS {
- value 7;
+ value 7;
}
}
}
-
+
typedef group-mod-failed-code {
type enumeration {
enum GROUP_EXISTS {
- value 0;
+ value 0;
}
enum INVALID_GROUP {
- value 1;
+ value 1;
}
enum WEIGHT_UNSUPPORTED {
- value 2;
+ value 2;
}
enum OUT_OF_GROUPS {
- value 3;
+ value 3;
}
enum OUT_OF_BUCKETS {
- value 4;
+ value 4;
}
enum CHAINING_UNSUPPORTED {
- value 5;
+ value 5;
}
enum WATCH_UNSUPPORTED {
- value 6;
+ value 6;
}
enum LOOP {
- value 7;
+ value 7;
}
enum UNKNOWN_GROUP {
- value 8;
+ value 8;
}
enum CHAINED_GROUP {
- value 9;
+ value 9;
}
enum BAD_TYPE {
- value 10;
+ value 10;
}
enum BAD_COMMAND {
- value 11;
+ value 11;
}
enum BAD_BUCKET {
- value 12;
+ value 12;
}
enum BAD_WATCH {
- value 13;
+ value 13;
}
enum EPERM {
- value 14;
+ value 14;
}
}
}
-
+
typedef port-mod-failed-code {
type enumeration {
enum BAD_PORT {
- value 0;
+ value 0;
}
enum BAD_HW_ADDR {
- value 1;
+ value 1;
}
enum BAD_CONFIG {
- value 2;
+ value 2;
}
enum BAD_ADVERTISE {
- value 3;
+ value 3;
}
enum EPERM {
- value 4;
+ value 4;
}
}
}
-
+
typedef table-mod-failed-code {
type enumeration {
enum BAD_TABLE {
- value 0;
+ value 0;
}
enum BAD_CONFIG {
- value 1;
+ value 1;
}
enum EPERM {
- value 2;
+ value 2;
}
}
}
typedef queue-op-failed-code {
type enumeration {
enum BAD_PORT {
- value 0;
+ value 0;
}
enum BAD_QUEUE {
- value 1;
+ value 1;
}
enum EPERM {
- value 2;
+ value 2;
}
}
}
-
+
typedef switch-config-failed-code {
type enumeration {
enum BAD_FLAGS {
- value 0;
+ value 0;
}
enum BAD_LEN {
- value 1;
+ value 1;
}
enum EPERM {
- value 2;
+ value 2;
}
}
}
-
+
typedef role-request-failed-code {
type enumeration {
enum STALE {
- value 0;
+ value 0;
}
enum UNSUP {
- value 1;
+ value 1;
}
enum BAD_ROLE {
- value 2;
+ value 2;
}
}
}
-
+
typedef meter-mod-failed-code {
type enumeration {
enum UNKNOWN {
- value 0;
+ value 0;
}
enum METER_EXISTS {
- value 1;
+ value 1;
}
enum INVALID_METER {
- value 2;
+ value 2;
}
enum UNKNOWN_METER {
- value 3;
+ value 3;
}
enum BAD_COMMAND {
- value 4;
+ value 4;
}
enum BAD_FLAGS {
- value 5;
+ value 5;
}
enum BAD_RATE {
- value 6;
+ value 6;
}
enum BAD_BURST {
- value 7;
+ value 7;
}
enum BAD_BAND {
- value 8;
+ value 8;
}
enum BAD_BAND_VALUE {
- value 9;
+ value 9;
}
enum OUT_OF_METERS {
- value 10;
+ value 10;
}
enum OUT_OF_BANDS {
- value 11;
+ value 11;
}
}
}
-
+
typedef table-features-failed-code {
type enumeration {
enum BAD_TABLE {
- value 0;
+ value 0;
}
enum BAD_METADATA {
- value 1;
+ value 1;
}
enum BAD_TYPE {
- value 2;
+ value 2;
}
enum BAD_LEN {
- value 3;
+ value 3;
}
enum BAD_ARGUMENT {
- value 4;
+ value 4;
}
enum EPERM {
- value 5;
+ value 5;
}
}
}
-
+
typedef hello-element-type {
type enumeration {
enum VERSIONBITMAP {
- value 1;
+ value 1;
description "Bitmap of version supported.";
}
}
}
-
+
typedef capabilities {
description "Capabilities supported by the datapath.";
type bits {
bit OFPC_FLOW_STATS {
position 0;
/* Flow statistics. */
- }
+ }
bit OFPC_TABLE_STATS {
position 1;
/* Table statistics. */
description " Handling of IP fragments. ";
type enumeration {
enum FRAG_NORMAL {
- value 0;
+ value 0;
description "No special handling for fragments.";
}
enum OFPC_FRAG_DROP {
- value 1;
+ value 1;
description "Drop fragments.";
}
enum OFPC_FRAG_REASM {
- value 2;
+ value 2;
description "Reassemble (only if OFPC_IP_REASM set).";
}
enum OFPC_FRAG_MASK {
- value 3;
+ value 3;
}
}
}
}
enum OFPTT_ALL {
value 255; // 0xff
- description "Wildcard table used for table config,
+ description "Wildcard table used for table config,
flow stats and flow deletes.";
}
}
}
enum OFPG_ANY {
value -1; //0xffffffff
- description "Wildcard group used only for flow stats requests.
+ description "Wildcard group used only for flow stats requests.
Selects all flows regardless of group (including flows with no group)";
}
}
description "Maximum datarate.";
}
enum OFPQT_EXPERIMENTER {
- value 65535; // 0xffff
+ value 65535; // 0xffff
description "Experimenter defined property.";
}
}
}
}
}
-
+
typedef action-type {
/* ofp_action_type */
type bits {
}
}
}
-
+
typedef meter-band-type-bitmap {
/* ofp_meter_band_type */
type bits {
typedef table-features-prop-type {
type enumeration {
enum OFPTFPT_INSTRUCTIONS {
- value 0;
+ value 0;
description "Instructions property.";
}
enum OFPTFPT_INSTRUCTIONS_MISS {
- value 1;
+ value 1;
description "Instructions for table-miss.";
}
enum OFPTFPT_NEXT_TABLES {
- value 2;
+ value 2;
description "Next Table property.";
}
enum OFPTFPT_NEXT_TABLES_MISS {
- value 3;
+ value 3;
description "Next Table for table-miss.";
}
enum OFPTFPT_WRITE_ACTIONS {
- value 4;
+ value 4;
description "Write Actions property.";
}
enum OFPTFPT_WRITE_ACTIONS_MISS {
- value 5;
+ value 5;
description "Write Actions for table-miss.";
}
enum OFPTFPT_APPLY_ACTIONS {
- value 6;
+ value 6;
description "Apply Actions property.";
}
enum OFPTFPT_APPLY_ACTIONS_MISS {
- value 7;
+ value 7;
description "Apply Actions for table-miss.";
}
enum OFPTFPT_MATCH {
- value 8;
+ value 8;
description "Match property.";
}
enum OFPTFPT_WILDCARDS {
- value 10;
+ value 10;
description "Wildcards property.";
}
enum OFPTFPT_WRITE_SETFIELD {
- value 12;
+ value 12;
description "Write Set-Field property.";
}
enum OFPTFPT_WRITE_SETFIELD_MISS {
- value 13;
+ value 13;
description "Write Set-Field for table-miss.";
}
enum OFPTFPT_APPLY_SETFIELD {
- value 14;
+ value 14;
description "Apply Set-Field property.";
}
enum OFPTFPT_APPLY_SETFIELD_MISS {
- value 15;
+ value 15;
description "Apply Set-Field for table-miss.";
}
enum OFPTFPT_EXPERIMENTER {
- value 65534;
+ value 65534;
description "Experimenter property.";
}
enum OFPTFPT_EXPERIMENTER_MISS {
- value 65535; //0xffff
+ value 65535; //0xffff
description "Experimenter for table-miss.";
}
}
}
}
}
-
+
typedef ipv6-exthdr-flags {
description "Bit definitions for IPv6 Extension Header pseudo-field.";
type bits {
}
}
}
-
+
// OPENFLOW v1.0 STRUCTURES
- // Structures under this line are needed to support OpenFlow version 1.0
+ // Structures under this line are needed to support OpenFlow version 1.0
// wire protocol 0x01;
-
+
typedef error-type-v10 {
type enumeration {
enum HELLO_FAILED {
- value 0;
+ value 0;
description "Hello Protocol failed.";
}
enum BAD_REQUEST {
- value 1;
+ value 1;
description "Request was not understood.";
}
enum BAD_ACTION {
- value 2;
+ value 2;
description "Error in action description.";
}
enum FLOW_MOD_FAILED {
- value 3;
+ value 3;
description "Problem modifying flow entry.";
}
enum PORT_MOD_FAILED {
- value 4;
+ value 4;
description "Port mod request failed.";
}
enum QUEUE_OP_FAILED {
- value 5;
+ value 5;
description "Queue operation failed.";
}
}
}
-
+
typedef hello-failed-code-v10 {
type enumeration {
enum INCOMPATIBLE {
- value 0;
+ value 0;
description "Hello Protocol failed.";
}
enum EPERM {
- value 1;
+ value 1;
description "Request was not understood.";
}
}
}
-
+
typedef bad-request-code-v10 {
type enumeration {
enum BAD_VERSION {
- value 0;
+ value 0;
}
enum BAD_TYPE {
- value 1;
+ value 1;
}
enum BAD_STAT {
- value 2;
+ value 2;
}
enum BAD_VENDOR {
- value 3;
+ value 3;
}
enum BAD_SUBTYPE {
- value 4;
+ value 4;
}
enum EPERM {
- value 5;
+ value 5;
}
enum BAD_LEN {
- value 6;
+ value 6;
}
enum BUFFER_EMPTY {
- value 7;
+ value 7;
}
enum BUFFER_UNKNOWN {
- value 8;
+ value 8;
}
}
}
-
+
typedef bad-action-code-v10 {
type enumeration {
enum BAD_TYPE {
- value 0;
+ value 0;
}
enum BAD_LEN {
- value 1;
+ value 1;
}
enum VENDOR {
- value 2;
+ value 2;
}
enum BAD_VENDOR_TYPE {
- value 3;
+ value 3;
}
enum BAD_OUT_PORT {
- value 4;
+ value 4;
}
enum BAD_ARGUMENT {
- value 5;
+ value 5;
}
enum EPERM {
- value 6;
+ value 6;
}
enum TOO_MANY {
- value 7;
+ value 7;
}
enum BAD_QUEUE {
- value 8;
+ value 8;
}
}
}
-
+
typedef flow-mod-failed-code-v10 {
type enumeration {
enum ALL_TABLES_FULL {
- value 0;
+ value 0;
}
enum OVERLAP {
- value 1;
+ value 1;
}
enum EPERM {
- value 2;
+ value 2;
}
enum BAD_EMERG_TIMEOUT {
- value 3;
+ value 3;
}
enum BAD_COMMAND {
- value 4;
+ value 4;
}
enum UNSUPPORTED {
- value 5;
+ value 5;
}
}
}
-
+
typedef port-mod-failed-code-v10 {
type enumeration {
enum BAD_PORT {
- value 0;
+ value 0;
}
enum BAD_HW_ADDR {
- value 1;
+ value 1;
}
}
}
-
+
typedef queue-op-failed-code-v10 {
type enumeration {
enum BAD_PORT {
- value 0;
+ value 0;
}
enum BAD_QUEUE {
- value 1;
+ value 1;
}
enum EPERM {
- value 2;
+ value 2;
}
}
}
-
+
typedef port-number-values-v10 {
description "Port numbering. Physical ports are numbered starting from 1.";
type enumeration {
enum MAX {
- value 65280; // 0xff00
+ value 65280; // 0xff00
}
enum IN_PORT {
description "Send the packet out the input port. This
description "Perform actions in flow table.
NB: This can only be the destination
port for packet-out messages.";
- value 65529; // 0xfff9
+ value 65529; // 0xfff9
}
enum NORMAL {
description "Process with normal L2/L3 switching.";
- value 65530; // 0xfffa
+ value 65530; // 0xfffa
}
enum FLOOD {
description "All physical ports except input port and
those disabled by STP.";
- value 65531; // 0xfffb
+ value 65531; // 0xfffb
}
enum ALL {
description "All physical ports except input port.";
- value 65532; // 0xfffc
+ value 65532; // 0xfffc
}
enum CONTROLLER {
description "Send to controller.";
}
}
}
-
+
typedef port-config-v10 {
- description
+ description
"Flags to indicate behavior of the physical port. These flags are
- describe the current configuration and used port_mod message
+ describe the current configuration and used port_mod message
to configure the port's behavior.";
type bits {
- bit port-down {
+ bit port-down {
description " Port is administratively down.";
position 0;
}
description "Disable 802.1D spanning tree on port.";
position 1;
}
- bit no-recv {
+ bit no-recv {
description " Drop all packets received by port.";
position 2;
}
- bit no-recv-stp {
+ bit no-recv-stp {
description " Drop received 802.1D STP packets.";
position 3;
}
- bit no-flood {
+ bit no-flood {
description " Do not include this port when flooding.";
position 4;
}
- bit no-fwd {
+ bit no-fwd {
description " Drop packets forwarded to port.";
position 5;
}
- bit no-packet-in {
+ bit no-packet-in {
description "Do not send packet-in msgs for port.";
position 6;
}
}
}
-
+
typedef port-state-v10 {
description "Current state of the physical port. These are not configurable from
the controller.";
}
}
}
-
+
typedef port-features-v10 {
description "Features of ports available in datapath.";
reference "ofp_port_features";
type bits {
- bit _10mb-hd {
+ bit _10mb-hd {
position 0;
description "10 Mb half-duplex rate support.";
}
- bit _10mb-fd {
+ bit _10mb-fd {
position 1;
description "10 Mb full-duplex rate support.";
}
- bit _100mb-hd {
+ bit _100mb-hd {
position 2;
description "100 Mb half-duplex rate support.";
}
- bit _100mb-fd {
+ bit _100mb-fd {
position 3;
description "100 Mb full-duplex rate support.";
}
- bit _1gb-hd {
+ bit _1gb-hd {
position 4;
description "1 Gb half-duplex rate support.";
}
- bit _1gb-fd {
+ bit _1gb-fd {
position 5;
description "1 Gb full-duplex rate support.";
}
- bit _10gb-fd {
+ bit _10gb-fd {
position 6;
description "10 Gb full-duplex rate support.";
}
- bit copper {
+ bit copper {
position 7;
description "Copper medium.";
}
- bit fiber {
+ bit fiber {
position 8;
description "Fiber medium.";
}
- bit autoneg {
+ bit autoneg {
position 9;
description "Auto-negotiation.";
}
- bit pause {
+ bit pause {
position 10;
description "Pause.";
}
- bit pause-asym {
+ bit pause-asym {
position 11;
description "Asymmetric pause.";
}
}
}
-
+
typedef capabilities-v10 {
type bits {
bit OFPC_FLOW_STATS {
position 0;
description "Flow statistics.";
- }
+ }
bit OFPC_TABLE_STATS {
position 1;
description "Table statistics.";
}
}
}
-
+
typedef flow-mod-flags-v10 {
/* ofp_flow_mod_flags */
type bits {
}
}
}
-
+
typedef action-type-v10 {
/* ofp_action_type */
type bits {
}
}
}
-
+
typedef flow-wildcards-v10 {
/* ofp_flow_wildcards */
description "Flow wildcards - NW_SRC_MASK & NW_DST_MASK are handled separately";
}
}
}
-
+
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
+
module system-notifications {
namespace "urn:opendaylight:openflow:system";
prefix "ofs";
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
}
-
+
/**
* Test EnhancedMessageTypeKey equals - additional test
*/
public void testEquals() {
EnhancedMessageCodeKey key1 =
new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class);
-
+
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
}
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
}
-
+
/**
* Test EnhancedMessageTypeKey equals - additional test
*/
EnhancedMessageTypeKey<?,?> key2;
key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class);
key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class);
-
+
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
-
+
key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null);
Assert.assertFalse("Wrong equal by msgType2.", key1.equals(key2));
key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class);
@Test
public void testEquals() {
MessageTypeKey<?> key1;
- MessageTypeKey<?> key2;
+ MessageTypeKey<?> key2;
key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class);
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
}
-
+
/**
* Test ActionDeserializerKey equals - additional test
*/
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
}
-
+
/**
* Test ActionSerializerKey equals - additional test
*/
public void testEquals(){
ActionSerializerKey<?> key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
ActionSerializerKey<?> key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L);
-
+
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
Assert.assertFalse("Wrong equal by actionType", key1.equals(key2));
-
+
key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
Assert.assertTrue("Wrong equal by action type", key1.equals(key2));
key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null);
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
}
-
+
/**
* Test InstructionDeserializerKey equals - additional test
*/
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
}
-
+
/**
* Test InstructionSerializerKey equals - additional test
*/
EncodeConstants.OF13_VERSION_ID, 1L);
Assert.assertEquals(instructionDeserializerKey, experimenterInstructionDeserializerKey);
Assert.assertEquals(instructionDeserializerKey.hashCode(), experimenterInstructionDeserializerKey.hashCode());
-
+
MatchEntryDeserializerKey matchKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,
OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.ARP_OP);
MatchEntryDeserializerKey matchKey2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,
Assert.assertEquals(matchKey, matchKey2);
Assert.assertEquals(matchKey.hashCode(), matchKey2.hashCode());
}
-
+
private static class ExpSubType extends ExperimenterActionSubType {
// empty class - only used in test for comparation
}
Assert.assertTrue("Wrong equals", key1.equals(key2));
Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode());
}
-
+
/**
* Test MatchEntryDeserializerKey equals - additional test
*/
public void testEquals() {
MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42);
MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42);
-
+
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
-
+
Long expId1=123456L;
Long expId2=654321L;
key1.setExperimenterId(null);
key2.setExperimenterId(expId2);
Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2));
-
+
key1.setExperimenterId(expId1);
Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2));
Assert.assertFalse("Wrong equals with different object class", key1.equals(key2));
key2.setExperimenterId(42L);
Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
}
-
+
/**
- * Test MatchEntrySerializerKey equals - additional test
+ * Test MatchEntrySerializerKey equals - additional test
*/
@Test
public void testEquals(){
key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
-
+
Long expId1 = 987654331L;
Long expId2 = 123456789L;
-
+
key1.setExperimenterId(null);
key2.setExperimenterId(expId2);
Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));
Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2));
}
-
+
private static class TestSubType extends ExperimenterActionSubType {
// empty class - only used in test for comparation
}
private static class TestSubType2 extends ExperimenterActionSubType {
// empty class - only used in test for comparation
}
-
+
}
\ No newline at end of file
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
}
-
+
/**
* Test ExperimenterIdSerializerKey equals - additional test
*/
new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class);
Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2));
}
-
+
}
\ No newline at end of file
<yangtools.generator.version>0.7.0-SNAPSHOT</yangtools.generator.version>
<yangtools.binding.version>0.7.0-SNAPSHOT</yangtools.binding.version>
</properties>
-
+
<build>
<plugins>
<plugin>
</plugin>
</plugins>
</build>
-
+
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
private SerializationFactory serializationFactory;
private TlsConfiguration tlsConfig;
private SwitchConnectionHandler switchConnectionHandler;
-
+
/**
* @return PublishingChannelInitializer that initializes new channels
*/
int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
LOGGER.debug("length of actual message: {}", length);
-
+
if (readableBytes < length) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("skipping bytebuf - too few bytes for msg: " +
}
LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
-
+
byte version = bb.readByte();
if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) {
LOGGER.debug("detected version: " + version);
private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoder.class);
private SerializationFactory serializationFactory;
private StatisticsCounters statisticsCounters;
-
+
/** Constructor of class */
public OFEncoder() {
statisticsCounters = StatisticsCounters.getInstance();
}
return;
}
-
+
int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
LOGGER.debug("length of actual message: {}", length);
-
+
if (readableBytes < length) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("skipping bytebuf - too few bytes for msg: " +
return;
}
LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
-
+
ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length);
list.add(messageBuffer);
messageBuffer.retain();
/**
* Stores names of handlers used in pipeline.
- *
+ *
* @author michal.polkorab
*/
public enum PipelineHandlers {
public interface ShutdownProvider {
/**
- * @return shutdown future
+ * @return shutdown future
*/
ListenableFuture<Boolean> shutdown();
/**
* Class for setting up TLS connection.
- *
+ *
* @author michal.polkorab
*/
public class SslContextFactory {
/**
* Testing Constructor
- *
+ *
*/
protected TcpChannelInitializer( DefaultChannelGroup channelGroup, ConnectionAdapterFactory connAdaptorFactory ) {
allChannels = channelGroup ;
connectionAdapterFactory = connAdaptorFactory ;
}
-
+
@Override
protected void initChannel(final SocketChannel ch) {
InetAddress switchAddress = ch.remoteAddress().getAddress();
/**
* Class implementing server over UDP for handling incoming connections.
- *
+ *
* @author michal.polkorab
*/
public final class UdpHandler implements ServerFacade {
/**
* Wraps received messages (includes version) and sender address
-
+
* @author michal.polkorab
*/
public class VersionMessageUdpWrapper extends VersionMessageWrapper {
private short version;
private ByteBuf messageBuffer;
-
+
/**
* Constructor
* @param version version decoded in {@link OFVersionDetector}
public ByteBuf getMessageBuffer() {
return messageBuffer;
}
-
-
+
+
}
}
final GenericFutureListener<Future<Void>> l = h.takeListener();
-
+
final ChannelFuture p;
if (address == null) {
p = channel.write(new MessageListenerWrapper(h.takeMessage(), l));
/**
* Wraps outgoing message and includes listener attached to this message. This object
* is sent to OFEncoder. When OFEncoder fails to serialize the message,
- * listener is filled with exception. The exception is then delegated to upper ODL layers.
+ * listener is filled with exception. The exception is then delegated to upper ODL layers.
* @author michal.polkorab
*/
public class MessageListenerWrapper {
return msg;
}
-
+
/**
* @return listener listening on message sending success / failure
*/
* @author mirehak
*/
public class RpcResponseKey {
-
+
private final long xid;
private final String outputClazz;
/**
this.xid = xid;
this.outputClazz = outputClazz;
}
-
+
/**
* @return the xid
*/
public String getOutputClazz() {
return outputClazz;
}
-
+
@Override
public int hashCode() {
final int prime = 31;
* is sent to OFEncoder. When OFEncoder fails to serialize the message,
* listener is filled with exception. The exception is then delegated to upper ODL layers.
* This object is used for UDP communication - it also carries recipient address
-
+
* @author michal.polkorab
*/
public class UdpMessageListenerWrapper extends MessageListenerWrapper {
*/
public static void registerDeserializers(DeserializerRegistry registry) {
// register OF v1.0 action deserializers
- ActionDeserializerRegistryHelper helper =
+ ActionDeserializerRegistryHelper helper =
new ActionDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry);
helper.registerDeserializer(0, new OF10OutputActionDeserializer());
helper.registerDeserializer(1, new OF10SetVlanVidActionDeserializer());
*/
public static void initializeTypeToClassMap(Map<TypeToClassKey, Class<?>> messageClassMap) {
// init OF v1.0 mapping
- TypeToClassInitHelper helper =
+ TypeToClassInitHelper helper =
new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap);
helper.registerTypeToClass((short) 0, HelloMessage.class);
helper.registerTypeToClass((short) 1, ErrorMessage.class);
}
return builder.build();
}
-
+
private static void decodeType(ErrorMessageBuilder builder, ErrorType type, int readValue) {
if (type != null) {
builder.setType(type.getIntValue());
setUnknownCode(builder, code);
}
}
-
+
private static void setUnknownCode(ErrorMessageBuilder builder, int readValue) {
builder.setCode(readValue);
builder.setCodeString(UNKNOWN_CODE);
}
-
+
private static void setCode(ErrorMessageBuilder builder, int code, String codeString) {
builder.setCode(code);
builder.setCodeString(codeString);
builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage));
return builder.build();
}
-
+
private static List<PacketInMask> decodePacketInMask(ByteBuf input) {
List<PacketInMask> inMasks = new ArrayList<>();
PacketInMaskBuilder maskBuilder;
for (int i = 0; i < SEPARATE_ROLES; i++) {
maskBuilder = new PacketInMaskBuilder();
maskBuilder.setMask(decodePacketInReasons(input.readUnsignedInt()));
- inMasks.add(maskBuilder.build());
+ inMasks.add(maskBuilder.build());
}
return inMasks;
}
-
+
private static List<PortStatusMask> decodePortStatusMask(ByteBuf input) {
List<PortStatusMask> inMasks = new ArrayList<>();
PortStatusMaskBuilder maskBuilder;
}
return inMasks;
}
-
+
private static List<FlowRemovedMask> decodeFlowRemovedMask(ByteBuf input) {
List<FlowRemovedMask> inMasks = new ArrayList<>();
FlowRemovedMaskBuilder maskBuilder;
}
return inMasks;
}
-
+
private static List<PacketInReason> decodePacketInReasons(long input) {
List<PacketInReason> reasons = new ArrayList<>();
if ((input & (1 << 0)) != 0) {
}
return reasons;
}
-
+
private static List<PortReason> decodePortReasons(long input) {
List<PortReason> reasons = new ArrayList<>();
if ((input & (1 << 0)) != 0) {
}
return reasons;
}
-
+
private static List<FlowRemovedReason> decodeFlowRemovedReasons(long input) {
List<FlowRemovedReason> reasons = new ArrayList<>();
if ((input & (1 << 0)) != 0) {
}
return builder.build();
}
-
+
private static List<Elements> readElement(ByteBuf input) {
List<Elements> elementsList = new ArrayList<>();
while (input.readableBytes() > 0) {
}
return elementsList;
}
-
+
private static List<Boolean> readVersionBitmap(int[] input){
List<Boolean> versionBitmapList = new ArrayList<>();
for (int i = 0; i < input.length; i++) {
case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage));
break;
case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage));
- break;
+ break;
case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage));
break;
case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage));
- break;
+ break;
case OFPMPGROUP: builder.setMultipartReplyBody(setGroup(rawMessage));
break;
case OFPMPGROUPDESC: builder.setMultipartReplyBody(setGroupDesc(rawMessage));
break;
case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage));
break;
- default:
+ default:
break;
}
-
+
return builder.build();
}
-
+
private static MultipartReplyDescCase setDesc(ByteBuf input) {
MultipartReplyDescCaseBuilder caseBuilder = new MultipartReplyDescCaseBuilder();
MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();
caseBuilder.setMultipartReplyDesc(descBuilder.build());
return caseBuilder.build();
}
-
+
private MultipartReplyFlowCase setFlow(ByteBuf input) {
MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
caseBuilder.setMultipartReplyFlow(flowBuilder.build());
return caseBuilder.build();
}
-
+
private static FlowModFlags createFlowModFlagsFromBitmap(int input){
final Boolean fmfSENDFLOWREM = (input & (1 << 0)) != 0;
final Boolean fmfCHECKOVERLAP = (input & (1 << 1)) != 0;
- final Boolean fmfRESETCOUNTS = (input & (1 << 2)) != 0;
+ final Boolean fmfRESETCOUNTS = (input & (1 << 2)) != 0;
final Boolean fmfNOPKTCOUNTS = (input & (1 << 3)) != 0;
final Boolean fmfNOBYTCOUNTS = (input & (1 << 4)) != 0;
return new FlowModFlags(fmfCHECKOVERLAP, fmfNOBYTCOUNTS, fmfNOPKTCOUNTS, fmfRESETCOUNTS, fmfSENDFLOWREM);
}
-
+
private static MultipartReplyAggregateCase setAggregate(ByteBuf input) {
MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder();
MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
caseBuilder.setMultipartReplyAggregate(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyTableCase setTable(ByteBuf input) {
MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder();
MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
caseBuilder.setMultipartReplyTable(builder.build());
return caseBuilder.build();
}
-
+
private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) {
MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
featuresBuilder.setMetadataWrite(metadataWrite);
featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
featuresBuilder.setMaxEntries(input.readUnsignedInt());
- featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input,
+ featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input,
length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH));
features.add(featuresBuilder.build());
}
caseBuilder.setMultipartReplyTableFeatures(builder.build());
return caseBuilder.build();
}
-
+
private static TableConfig createTableConfig(long input) {
boolean deprecated = (input & 3) != 0;
return new TableConfig(deprecated);
}
-
+
private List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
List<TableFeatureProperties> properties = new ArrayList<>();
int tableFeaturesLength = length;
}
return properties;
}
-
+
private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) {
MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder();
MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();
caseBuilder.setMultipartReplyPortStats(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyQueueCase setQueue(ByteBuf input) {
MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder();
MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();
caseBuilder.setMultipartReplyQueue(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyGroupCase setGroup(ByteBuf input) {
MultipartReplyGroupCaseBuilder caseBuilder = new MultipartReplyGroupCaseBuilder();
MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();
bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket));
bucketStatsList.add(bucketStatsBuilder.build());
actualLength += BUCKET_COUNTER_LENGTH;
- }
+ }
groupStatsBuilder.setBucketStats(bucketStatsList);
groupStatsList.add(groupStatsBuilder.build());
}
caseBuilder.setMultipartReplyGroup(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) {
MultipartReplyMeterFeaturesCaseBuilder caseBuilder = new MultipartReplyMeterFeaturesCaseBuilder();
MultipartReplyMeterFeaturesBuilder builder = new MultipartReplyMeterFeaturesBuilder();
caseBuilder.setMultipartReplyMeterFeatures(builder.build());
return caseBuilder.build();
}
-
+
private static MeterFlags createMeterFlags(long input){
final Boolean mfKBPS = (input & (1 << 0)) != 0;
final Boolean mfPKTPS = (input & (1 << 1)) != 0;
final Boolean mfSTATS = (input & (1 << 3)) != 0;
return new MeterFlags(mfBURST, mfKBPS, mfPKTPS, mfSTATS);
}
-
+
private static MeterBandTypeBitmap createMeterBandsBitmap(long input) {
final Boolean mbtDROP = (input & (1 << 1)) != 0;
final Boolean mbtDSCPREMARK = (input & (1 << 2)) != 0;
return new MeterBandTypeBitmap(mbtDROP, mbtDSCPREMARK);
}
-
+
private static MultipartReplyMeterCase setMeter(ByteBuf input) {
MultipartReplyMeterCaseBuilder caseBuilder = new MultipartReplyMeterCaseBuilder();
MultipartReplyMeterBuilder builder = new MultipartReplyMeterBuilder();
caseBuilder.setMultipartReplyMeter(builder.build());
return caseBuilder.build();
}
-
+
private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) {
MultipartReplyMeterConfigCaseBuilder caseBuilder = new MultipartReplyMeterConfigCaseBuilder();
MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
caseBuilder.setMultipartReplyMeterConfig(builder.build());
return caseBuilder.build();
}
-
+
private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) {
return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(
EncodeConstants.OF13_VERSION_ID, input.readUnsignedInt()));
}
-
+
private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) {
MultipartReplyPortDescCaseBuilder caseBuilder = new MultipartReplyPortDescCaseBuilder();
MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
caseBuilder.setMultipartReplyPortDesc(builder.build());
return caseBuilder.build();
}
-
+
private static PortConfig createPortConfig(long input){
final Boolean pcPortDown = ((input) & (1<<0)) != 0;
final Boolean pcNRecv = ((input) & (1<<2)) != 0;
final Boolean pcNPacketIn = ((input) & (1<<6)) != 0;
return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown);
}
-
+
private static PortState createPortState(long input){
final Boolean psLinkDown = ((input) & (1<<0)) != 0;
final Boolean psBlocked = ((input) & (1<<1)) != 0;
final Boolean psLive = ((input) & (1<<2)) != 0;
return new PortState(psBlocked, psLinkDown, psLive);
}
-
+
private static PortFeatures createPortFeatures(long input){
final Boolean pf10mbHd = ((input) & (1<<0)) != 0;
final Boolean pf10mbFd = ((input) & (1<<1)) != 0;
return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd,
pf1gbHd, pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym);
}
-
+
private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessage) {
MultipartReplyGroupFeaturesCaseBuilder caseBuilder = new MultipartReplyGroupFeaturesCaseBuilder();
MultipartReplyGroupFeaturesBuilder featuresBuilder = new MultipartReplyGroupFeaturesBuilder();
caseBuilder.setMultipartReplyGroupFeatures(featuresBuilder.build());
return caseBuilder.build();
}
-
+
private static ActionType createActionBitmap(long input) {
final Boolean atOutput = ((input) & (1<<0)) != 0;
final Boolean atCopyTTLout = ((input) & (1<<11)) != 0;
final Boolean gtFF = ((input) & (1<<3)) != 0;
return new GroupTypes(gtAll, gtFF, gtIndirect, gtSelect);
}
-
+
private MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder();
MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
}
return builder.build();
}
-
+
private static void decodeType(ErrorMessageBuilder builder, ErrorTypeV10 type, int readValue) {
if (type != null) {
builder.setType(type.getIntValue());
setUnknownCode(builder, code);
}
}
-
+
private static void setUnknownCode(ErrorMessageBuilder builder, int readValue) {
builder.setCode(readValue);
builder.setCodeString(UNKNOWN_CODE);
}
-
+
private static void setCode(ErrorMessageBuilder builder, int code, String codeString) {
builder.setCode(code);
builder.setCodeString(codeString);
* @author michal.polkorab
*/
public class OF10FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput> {
-
+
private static final byte PADDING_IN_FEATURES_REPLY_HEADER = 3;
@Override
return new CapabilitiesV10(arpMatchIp, flowStats, ipReasm,
portStats, queueStats, reserved, stp, tableStats);
}
-
+
private static ActionTypeV10 createActionsV10(long input) {
final Boolean output = (input & (1 << 0)) != 0;
final Boolean setVLANvid = (input & (1 << 1)) != 0;
@Override
public PortStatusMessage deserialize(ByteBuf rawMessage) {
- PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
+ PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
builder.setQueues(createQueuesList(rawMessage));
return builder.build();
}
-
+
private static List<Queues> createQueuesList(ByteBuf input){
List<Queues> queuesList = new ArrayList<>();
while (input.readableBytes() > 0) {
input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH));
queuesList.add(queueBuilder.build());
- }
+ }
return queuesList;
}
-
+
private static List<QueueProperty> createPropertiesList(ByteBuf input, int length){
int propertiesLength = length;
List<QueueProperty> propertiesList = new ArrayList<>();
}
return propertiesList;
}
-}
\ No newline at end of file
+}
\ No newline at end of file
case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage));
break;
case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage));
- break;
+ break;
case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage));
break;
case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage));
- break;
+ break;
case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage));
break;
- default:
+ default:
break;
}
return builder.build();
}
-
+
private static MultipartReplyDescCase setDesc(ByteBuf input) {
MultipartReplyDescCaseBuilder caseBuilder = new MultipartReplyDescCaseBuilder();
MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();
caseBuilder.setMultipartReplyDesc(descBuilder.build());
return caseBuilder.build();
}
-
+
private MultipartReplyFlowCase setFlow(ByteBuf input) {
MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
caseBuilder.setMultipartReplyFlow(flowBuilder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyAggregateCase setAggregate(ByteBuf input) {
MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder();
MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
caseBuilder.setMultipartReplyAggregate(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyTableCase setTable(ByteBuf input) {
MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder();
MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
caseBuilder.setMultipartReplyTable(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) {
MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder();
MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();
caseBuilder.setMultipartReplyPortStats(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyQueueCase setQueue(ByteBuf input) {
MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder();
MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();
caseBuilder.setMultipartReplyQueue(builder.build());
return caseBuilder.build();
}
-
+
private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) {
return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(
EncodeConstants.OF10_VERSION_ID, input.readUnsignedInt()));
@Override
public PortStatusMessage deserialize(ByteBuf rawMessage) {
- PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
+ PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd,
pf1gbHd, pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym);
}
-
+
private static PortState createPortState(long input){
final Boolean psLinkDown = ((input) & (1<<0)) != 0;
final Boolean psBblocked = ((input) & (1<<1)) != 0;
final Boolean psLive = ((input) & (1<<2)) != 0;
return new PortState(psBblocked, psLinkDown, psLive);
}
-
+
private static PortConfig createPortConfig(long input){
final Boolean pcPortDown = ((input) & (1<<0)) != 0;
final Boolean pcNoRecv = ((input) & (1<<2)) != 0;
builder.setQueues(createQueuesList(rawMessage));
return builder.build();
}
-
+
private List<Queues> createQueuesList(ByteBuf input){
List<Queues> queuesList = new ArrayList<>();
while (input.readableBytes() > 0) {
input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_LENGTH));
queuesList.add(queueBuilder.build());
- }
+ }
return queuesList;
}
-
+
private List<QueueProperty> createPropertiesList(ByteBuf input, int length){
int propertiesLength = length;
List<QueueProperty> propertiesList = new ArrayList<>();
InstructionBuilder builder = super.processHeader(input);
input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
- ActionsInstructionBuilder actionsBuilder =
+ ActionsInstructionBuilder actionsBuilder =
new ActionsInstructionBuilder();
List<Action> actions = new ArrayList<>();
actionsBuilder.setAction(actions);
/**
* Prepares match entry header - sets oxm_class, oxm_field, hasMask
- * + sets the buffer.readerIndex() to the end of match entry
+ * + sets the buffer.readerIndex() to the end of match entry
* - where augmentation starts
* @param oxmClass oxm class type
* @param oxmField oxm field type
input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
return builder;
}
-
+
}
public class SerializationFactory {
private SerializerRegistry registry;
-
+
/**
* Transforms POJO message into ByteBuf
* @param version version used for encoding received message
public class OF13SetMplsTtlActionSerializer extends AbstractActionSerializer {
-
+
@Override
public void serialize(Action action, ByteBuf outBuffer) {
super.serialize(action, outBuffer);
output.writeZero(padding);
output.setShort(elementLengthIndex, output.writerIndex() - elementStartIndex);
}
- }
+ }
}
}
* @author michal.polkorab
*/
public class OF10QueueGetConfigInputMessageFactory implements OFSerializer<GetQueueConfigInput> {
-
+
private static final byte MESSAGE_TYPE = 20;
private static final byte PADDING_IN_GET_QUEUE_CONFIG_MESSAGE = 2;
}
}
}
-
+
private static void serializePortStatusMask(List<PortStatusMask> portStatusMask, ByteBuf outBuffer) {
if (portStatusMask != null) {
for (PortStatusMask currentPortStatusMask : portStatusMask) {
}
}
}
-
+
private static void serializerFlowRemovedMask(List<FlowRemovedMask> flowRemovedMask, ByteBuf outBuffer) {
if (flowRemovedMask != null) {
for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) {
/**
* @author michal.polkorab
- * @param <T> type the key maker is based on
+ * @param <T> type the key maker is based on
*/
public abstract class AbstractCodeKeyMaker implements CodeKeyMaker {
*/
public AbstractCodeKeyMaker(short version) {
this.version = version;
-
+
}
/**
/**
* @author michal.polkorab
- * @param <T> type the key maker is based on
+ * @param <T> type the key maker is based on
*/
public abstract class AbstractTypeKeyMaker<T> implements TypeKeyMaker<T> {
*/
public AbstractTypeKeyMaker(short version) {
this.version = version;
-
+
}
/**
/**
* Registers given serializer
- * @param instructionType
+ * @param instructionType
* @param serializer
*/
public <TYPE extends InstructionBase> void registerSerializer(Class<TYPE> instructionType,
/**
* Serializes list items and their headers
* @author michal.polkorab
- * @param <E>
+ * @param <E>
*/
public abstract class ListSerializer {
/**
* Registers given serializer
- * @param specificClass
- * @param serializer
+ * @param specificClass
+ * @param serializer
*/
public <OXM_FIELD extends MatchField> void registerSerializer(
Class<OXM_FIELD> specificClass, OFGeneralSerializer serializer) {
return;
}
for (MatchEntries entry : matchEntries) {
-
+
MatchEntrySerializerKey<?, ?> key = new MatchEntrySerializerKey<>(
EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField());
if (entry.getOxmClass().equals(ExperimenterClass.class)) {
/**
* Used for common structures translation / conversion
- *
+ *
* @author michal.polkorab
*/
public abstract class OpenflowUtils {
/**
* @author michal.polkorab
- * @param <T>
+ * @param <T>
*/
public interface TypeKeyMaker<T> {
/**
* @param entry
- * @return key that will be used for serializer lookup in
+ * @return key that will be used for serializer lookup in
* the serializer registry
*/
abstract MessageTypeKey<?> make(T entry);
* @param version protocol wire version
* @param messageClassMap map which stores type to class mapping
*/
- public TypeToClassInitHelper(short version, Map<TypeToClassKey,
+ public TypeToClassInitHelper(short version, Map<TypeToClassKey,
Class<?>> messageClassMap) {
this.version = version;
this.messageClassMap = messageClassMap;
import java.util.concurrent.atomic.AtomicLong;
/**
* Counts statistics
- *
+ *
* @author madamjak
*/
public class Counter {
}
/**
- * return the last read value of counter. This value can be set during the reading of current counter value,
+ * return the last read value of counter. This value can be set during the reading of current counter value,
* for detail see method getCounterValue(boolean modifyLastReadValue).
* @return the counterLastReadValue
*/
private boolean runCounting;
// array to hold enabled counter types
private CounterEventTypes[] enabledCounters = {
- CounterEventTypes.DS_ENCODE_FAIL,
+ CounterEventTypes.DS_ENCODE_FAIL,
CounterEventTypes.DS_ENCODE_SUCCESS,
CounterEventTypes.DS_ENTERED_OFJAVA,
CounterEventTypes.DS_FLOW_MODS_ENTERED,
CounterEventTypes.DS_FLOW_MODS_SENT,
- CounterEventTypes.US_DECODE_FAIL,
- CounterEventTypes.US_DECODE_SUCCESS,
- CounterEventTypes.US_MESSAGE_PASS,
+ CounterEventTypes.US_DECODE_FAIL,
+ CounterEventTypes.US_DECODE_SUCCESS,
+ CounterEventTypes.US_MESSAGE_PASS,
CounterEventTypes.US_RECEIVED_IN_OFJAVA};
/**
*/
public final class SwitchConnectionProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModule
{
-
+
private static Logger LOG = LoggerFactory
.getLogger(SwitchConnectionProviderModule.class);
/**
* @return instance configuration object
- * @throws UnknownHostException
+ * @throws UnknownHostException
*/
private ConnectionConfiguration createConnectionConfiguration() throws UnknownHostException {
final InetAddress address = extractIpAddressBin(getAddress());
return null;
}
return new ThreadConfiguration() {
-
+
@Override
public int getWorkerThreadCount() {
return threads.getWorkerThreads();
}
-
+
@Override
public int getBossThreadCount() {
return threads.getBossThreads();
/**
* @param address
* @return
- * @throws UnknownHostException
+ * @throws UnknownHostException
*/
private static InetAddress extractIpAddressBin(IpAddress address) throws UnknownHostException {
byte[] addressBin = null;
addressBin = address2bin(address.getIpv6Address().getValue());
}
}
-
+
if (addressBin == null) {
return null;
} else {
identity reset-ofjava-statistics-rpc;
rpc print-ofjava-statistics {
- description
+ description
"Shortcut JMX call to printOfjavaStatistics.";
input {
uses rpcx:rpc-context-ref {
}
rpc reset-ofjava-statistics {
- description
+ description
"Shortcut JMX call to resetOfjavaStatistics.";
input {
uses rpcx:rpc-context-ref {
}
/**
- *
+ *
*/
@Test
public void testChannelReadSuccess() {
verify( mockMsgConsumer, times(1)).consume(mockDataObject);
}
/**
- *
+ *
*/
@Test
public void testChannelInactive() {
private static final Logger LOGGER = LoggerFactory
.getLogger(DummyDecoder.class);
-
+
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in,
List<Object> out) throws Exception {
/**
* Sets up test environment
- *
+ *
*/
@Before
public void setUp() {
try {
idleHandler.readTimedOut(mockChHndlrCtx);
verify(mockChHndlrCtx, times(1)).fireChannelRead(any(Object.class)) ;
-
+
idleHandler.channelRead(mockChHndlrCtx, new String() );
verify(mockChHndlrCtx, times(2)).fireChannelRead(any(Object.class)) ;
-
+
idleHandler.readTimedOut(mockChHndlrCtx);
verify(mockChHndlrCtx, times(3)).fireChannelRead(any(Object.class)) ;
} catch (Exception e) {
Assert.fail();
}
}
-
+
}
/**
* Test to count decoder events (counters US_DECODE_SUCCESS, US_DECODE_FAIL and
* US_RECEIVED_IN_OFJAVA have to be enabled)
- *
+ *
* @author madamjak
*
*/
Assert.assertEquals(
"Wrong - different between RECEIVED_IN_OFJAVA and (US_DECODE_SUCCESS + US_DECODE_FAIL)",
statCounters.getCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA).getCounterValue(),
- statCounters.getCounter(CounterEventTypes.US_DECODE_SUCCESS).getCounterValue()
+ statCounters.getCounter(CounterEventTypes.US_DECODE_SUCCESS).getCounterValue()
+ statCounters.getCounter(CounterEventTypes.US_DECODE_FAIL).getCounterValue());
}
/**
* Sets up test environment
- *
+ *
*/
@Before
public void setUp() {
}
/**
- *
+ *
*/
@Test
public void testDecode() {
}
/**
- *
+ *
*/
@Test
public void testDecodeDeserializeException() {
}
/**
- *
+ *
*/
@Test
public void testDecodeDeserializeNull() {
/**
* Testing class of {@link OFFrameDecoder}
- *
+ *
* @author michal.polkorab
*/
@RunWith(MockitoJUnitRunner.class)
import org.opendaylight.openflowjava.util.ByteBufUtils;
/**
- *
+ *
* @author michal.polkorab
*/
@RunWith(MockitoJUnitRunner.class)
* Test of decode
* {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
* }
- *
+ *
* @throws Exception
*/
@Test
assertEquals( 0, byteBuffer.refCnt() ) ;
}
-
+
/**
* Test of decode
* {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
* }
- *
+ *
* @throws Exception
*/
@Test
/**
* Sets up test environment
- * @throws Exception
+ * @throws Exception
*/
@Before
public void setUp() throws Exception {
when(mockSocketCh.remoteAddress()).thenReturn(inetSockAddr) ;
when(mockSwConnHandler.accept(eq(InetAddress.getLocalHost()))).thenReturn(true) ;
when(mockSocketCh.pipeline()).thenReturn(mockChPipeline) ;
-
+
tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH,
KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH);
}
}
/**
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testGetServerContext() throws Exception {
/**
* Test keystore file access - via classpath
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testAsInputStream() throws Exception {
/**
* Test keystore file access - via relative path
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testAsInputStream2() throws Exception {
import org.mockito.MockitoAnnotations;
/**
- *
+ *
* @author madamjak
*
*/
public void startUp(){
MockitoAnnotations.initMocks(this);
}
-
+
@Test
public void test(){
short version = 35;
}
/**
- * Class for testing - channel can change state to read only or writable
+ * Class for testing - channel can change state to read only or writable
* @author madamjak
*
*/
import org.junit.Before;
import org.junit.Test;
/**
- *
+ *
* @author madamjak
*
*/
public class ConnectionAdapterFactoryImplTest {
@Mock ChannelPipeline channnelPipe;
- @Mock Channel channel;
+ @Mock Channel channel;
@Mock InetSocketAddress address;
@Before
}
}
/**
- * Test Rpc Calls
+ * Test Rpc Calls
*/
@Test
public void testRcp() {
/**
* Creates {@link ConnectionConfigurationImpl}
- * @param address
+ * @param address
* @param port
- * @param tlsConfig
+ * @param tlsConfig
* @param switchIdleTimeout
*/
public ConnectionConfigurationImpl(InetAddress address, int port, TlsConfiguration tlsConfig, long switchIdleTimeout) {
import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey;
/**
- *
+ *
* @author madamjak
*
*/
*/
@Test
public void testEquals(){
-
+
long xid1 = 12L;
long xid2 = 66L;
String outputClazz1 = "Clazz01";
*/
@Test
public void testGetters(){
-
+
long xid1 = 12L;
String outputClazz1 = "Clazz01";
RpcResponseKey key1 = new RpcResponseKey(xid1, outputClazz1);
config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT);
config.setTransferProtocol(protocol);
}
-
+
/**
- * Test getServerFacade
+ * Test getServerFacade
*/
@Test
public void testServerFacade(){
public void testUnregisterWrongKeys(){
startUp(TransportProtocol.TCP);
provider.setConfiguration(config);
- ExperimenterInstructionSerializerKey testSerKey
+ ExperimenterInstructionSerializerKey testSerKey
= new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID,42L);
Assert.assertFalse("Wrong -- unregisterSerializer",provider.unregisterSerializer(testSerKey));
ExperimenterInstructionDeserializerKey tesDeserKey
/**
* Test register and unregister method
*/
- @Test
+ @Test
public void testUnregisterExistingKeys(){
startUp(TransportProtocol.TCP);
provider.setConfiguration(config);
// -- registerActionSerializer
- ExperimenterActionSerializerKey key1
+ ExperimenterActionSerializerKey key1
= new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
provider.registerActionSerializer(key1, serializer);
Assert.assertTrue("Wrong -- unregister ActionSerializer", provider.unregisterSerializer(key1));
Assert.assertFalse("Wrong -- unregister ActionSerializer by not existing key", provider.unregisterSerializer(key1));
// -- registerActionDeserializer
- ExperimenterActionDeserializerKey key2
+ ExperimenterActionDeserializerKey key2
= new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L);
provider.registerActionDeserializer(key2, deserializer);
Assert.assertTrue("Wrong -- unregister ActionDeserializer", provider.unregisterDeserializer(key2));
Assert.assertFalse("Wrong -- unregister ActionDeserializer by not existing key", provider.unregisterDeserializer(key2));
// -- registerInstructionSerializer
- ExperimenterInstructionSerializerKey key3
+ ExperimenterInstructionSerializerKey key3
= new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID,42L);
provider.registerInstructionSerializer(key3, serializer);
Assert.assertTrue("Wrong -- unregister InstructionSerializer", provider.unregisterSerializer(key3));
Assert.assertFalse("Wrong -- unregister InstructionSerializer by not existing key", provider.unregisterSerializer(key3));
// -- registerInstructionDeserializer
- ExperimenterInstructionDeserializerKey key4
+ ExperimenterInstructionDeserializerKey key4
= new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID,42L);
provider.registerInstructionDeserializer(key4, deserializer);
Assert.assertTrue("Wrong -- unregister InstructionDeserializer", provider.unregisterDeserializer(key4));
Assert.assertFalse("Wrong -- unregister InstructionDeserializer by not existing key", provider.unregisterDeserializer(key4));
// -- registerMatchEntryDeserializer
- MatchEntryDeserializerKey key5
+ MatchEntryDeserializerKey key5
= new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42);
provider.registerMatchEntryDeserializer(key5, deserializer);
Assert.assertTrue("Wrong -- unregister MatchEntryDeserializer", provider.unregisterDeserializer(key5));
Assert.assertTrue("Wrong -- unregister QueuePropertyDeserializer", provider.unregisterDeserializer(key10));
Assert.assertFalse("Wrong -- unregister QueuePropertyDeserializer by not existing key", provider.unregisterDeserializer(key10));
// -- registerMeterBandDeserializer
- ExperimenterIdDeserializerKey key11
+ ExperimenterIdDeserializerKey key11
= new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, MeterBandExperimenterCase.class);
provider.registerMeterBandDeserializer(key11, deserializerMeterBandExpCase);
Assert.assertTrue("Wrong -- unregister MeterBandDeserializer", provider.unregisterDeserializer(key11));
Assert.assertTrue("Wrong -- unregister MeterBandSerializer", provider.unregisterSerializer(key15));
Assert.assertFalse("Wrong -- unregister MeterBandSerializer by not existing key", provider.unregisterSerializer(key15));
// -- registerMatchEntrySerializer
- MatchEntrySerializerKey<OpenflowBasicClass, InPort> key16
+ MatchEntrySerializerKey<OpenflowBasicClass, InPort> key16
= new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class);
provider.registerMatchEntrySerializer(key16, serializer);
Assert.assertTrue("Wrong -- unregister MatchEntrySerializer", provider.unregisterSerializer(key16));
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
/**
- *
+ *
* @author madamjak
*
*/
@Mock GenericFutureListener<Future<Void>> listener;
@Mock OfHeader msg;
-
+
@Before
public void startUp(){
MockitoAnnotations.initMocks(this);
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
/**
- *
+ *
* @author madamjak
*
*/
/**
- *
+ *
* @author madamjak
*
*/
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey;
/**
- *
+ *
* @author madamjak
*
*/
BufferHelper.checkHeaderV13(builtByFactory);
}
-
+
/**
* Testing {@link EchoReplyMessageFactory} for correct translation into POJO
*/
byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
ByteBuf bb = BufferHelper.buildBuffer(data);
EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
BufferHelper.checkHeaderV13(builtByFactory);
}
-
+
/**
* Testing {@link EchoRequestMessageFactory} for correct translation into POJO
*/
Assert.assertEquals("Wrong code string", "EPERM", builtByFactory.getCodeString());
Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData());
}
-
+
/**
* Test of {@link ErrorMessageFactory} for correct translation into POJO
*/
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData());
}
-
+
/**
* Test of {@link ErrorMessageFactory} for correct translation into POJO
*/
public void test() {
when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer);
when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message);
-
+
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10");
ExperimenterMessageFactory factory = new ExperimenterMessageFactory();
factory.injectDeserializerRegistry(registry);
FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
-
+
Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L);
Assert.assertTrue(builtByFactory.getPriority() == 0x03);
Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue());
Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue());
Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue());
}
-
+
}
*/
@Test
public void testGetAsyncReplyMessage() {
- ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 "+
+ ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 "+
"00 00 00 00 "+
"00 00 00 07 "+
"00 00 00 00 "+
GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
- Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue());
+ Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue());
Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue());
}
-
+
}
Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType());
Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap());
}
-
+
/**
* Testing {@link HelloMessageFactory} if incorrect version is set
*/
private static final Logger LOGGER = LoggerFactory
.getLogger(MultipartReplyMessageFactoryTest.class);
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
*/
final int DESC_STR_LEN = 256;
final int SERIAL_NUM_LEN = 32;
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");
-
+
String mfrDesc = "Manufacturer description";
byte[] mfrDescBytes = new byte[256];
mfrDescBytes = mfrDesc.getBytes();
bb.writeBytes(mfrDescBytes);
bb.writeZero(DESC_STR_LEN - mfrDescBytes.length);
-
+
String hwDesc = "Hardware description";
byte[] hwDescBytes = new byte[256];
hwDescBytes = hwDesc.getBytes();
bb.writeBytes(hwDescBytes);
bb.writeZero(DESC_STR_LEN - hwDescBytes.length);
-
+
String swDesc = "Software description";
byte[] swDescBytes = new byte[256];
swDescBytes = swDesc.getBytes();
bb.writeBytes(swDescBytes);
bb.writeZero(DESC_STR_LEN - swDescBytes.length);
-
+
String serialNum = "SN0123456789";
byte[] serialNumBytes = new byte[32];
serialNumBytes = serialNum.getBytes();
bb.writeBytes(serialNumBytes);
bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length);
-
+
String dpDesc = "switch3 in room 3120";
byte[] dpDescBytes = new byte[256];
dpDescBytes = dpDesc.getBytes();
bb.writeBytes(dpDescBytes);
bb.writeZero(DESC_STR_LEN - dpDescBytes.length);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
"00 00 00 08 "+//flowCount
"00 00 00 00"//pad
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody();
MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate();
- Assert.assertEquals("Wrong packetCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getPacketCount());
- Assert.assertEquals("Wrong byteCount",
- new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteCount",
+ new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getByteCount());
- Assert.assertEquals("Wrong flowCount",
- 8,
+ Assert.assertEquals("Wrong flowCount",
+ 8,
message.getFlowCount().intValue());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
*/
"FF 01 01 01 01 01 01 01 "+//lookupCount
"AF 01 01 01 01 01 01 01"//matchedCount
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
-
+
MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTable message = messageCase.getMultipartReplyTable();
Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
- Assert.assertEquals("Wrong lookupCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong lookupCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getTableStats().get(0).getLookupCount());
- Assert.assertEquals("Wrong matchedCount",
- new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong matchedCount",
+ new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getTableStats().get(0).getMatchedCount());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
*/
"00 00 00 02 "+//durationSec
"00 00 00 04"//durationNsec
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody();
MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats();
Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());
- Assert.assertEquals("Wrong rxPackets",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong rxPackets",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getPortStats().get(0).getRxPackets());
- Assert.assertEquals("Wrong txPackets",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong txPackets",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getPortStats().get(0).getTxPackets());
- Assert.assertEquals("Wrong rxBytes",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxBytes",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxBytes());
- Assert.assertEquals("Wrong txBytes",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txBytes",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getTxBytes());
- Assert.assertEquals("Wrong rxDropped",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxDropped",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxDropped());
- Assert.assertEquals("Wrong txDropped",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txDropped",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getTxDropped());
- Assert.assertEquals("Wrong rxErrors",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxErrors",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxErrors());
- Assert.assertEquals("Wrong txErrors",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txErrors",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getTxErrors());
- Assert.assertEquals("Wrong rxFrameErr",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxFrameErr",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxFrameErr());
- Assert.assertEquals("Wrong rxOverErr",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxOverErr",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxOverErr());
- Assert.assertEquals("Wrong rxCrcErr",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxCrcErr",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxCrcErr());
- Assert.assertEquals("Wrong collisions",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong collisions",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getCollisions());
Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());
Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
*/
"00 00 00 02 "+//durationSec
"00 00 00 04"//durationNsec
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
- Assert.assertEquals("Wrong txBytes",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txBytes",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getQueueStats().get(0).getTxBytes());
- Assert.assertEquals("Wrong txPackets",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong txPackets",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getQueueStats().get(0).getTxPackets());
- Assert.assertEquals("Wrong txErrors",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txErrors",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getQueueStats().get(0).getTxErrors());
Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());
Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
*/
"FF 02 02 02 02 02 02 02 "+//packetCountBucket_2.2
"FF 02 02 02 02 02 02 02"//byteCountBucket_2.2
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
- Assert.assertEquals("Wrong packetCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getGroupStats().get(0).getPacketCount());
- Assert.assertEquals("Wrong byteCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getGroupStats().get(0).getByteCount());
Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
- Assert.assertEquals("Wrong packetCountBucket",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetCountBucket",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
- Assert.assertEquals("Wrong byteCountBucket",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteCountBucket",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
- Assert.assertEquals("Wrong packetCountBucket_2",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong packetCountBucket_2",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
- Assert.assertEquals("Wrong byteCountBucket_2",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong byteCountBucket_2",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
-
+
Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
- Assert.assertEquals("Wrong packetCount_2",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetCount_2",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getGroupStats().get(1).getPacketCount());
- Assert.assertEquals("Wrong byteCount_2",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteCount_2",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getGroupStats().get(1).getByteCount());
Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
- Assert.assertEquals("Wrong packetCountBucket_1.2",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetCountBucket_1.2",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
- Assert.assertEquals("Wrong byteCountBucket_1.2",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteCountBucket_1.2",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
- Assert.assertEquals("Wrong packetCountBucket_2.2",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong packetCountBucket_2.2",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
- Assert.assertEquals("Wrong byteCountBucket_2.2",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong byteCountBucket_2.2",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
}
"FF 03 03 03 03 03 03 03 "+//packetBandCount_03
"FF 03 03 03 03 03 03 03"//byteBandCount_03
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
- Assert.assertEquals("Wrong meterId", 9,
+ Assert.assertEquals("Wrong meterId", 9,
message.getMeterStats().get(0).getMeterId().getValue().intValue());
- Assert.assertEquals("Wrong flowCount", 7,
+ Assert.assertEquals("Wrong flowCount", 7,
message.getMeterStats().get(0).getFlowCount().intValue());
- Assert.assertEquals("Wrong packetInCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetInCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(0).getPacketInCount());
- Assert.assertEquals("Wrong byteInCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteInCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(0).getByteInCount());
- Assert.assertEquals("Wrong durationSec", 5,
+ Assert.assertEquals("Wrong durationSec", 5,
message.getMeterStats().get(0).getDurationSec().intValue());
- Assert.assertEquals("Wrong durationNsec", 5,
+ Assert.assertEquals("Wrong durationNsec", 5,
message.getMeterStats().get(0).getDurationNsec().intValue());
- Assert.assertEquals("Wrong packetBandCount_01",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetBandCount_01",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_01",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteBandCount_01",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
- Assert.assertEquals("Wrong packetBandCount_02",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong packetBandCount_02",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_02",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong byteBandCount_02",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
- Assert.assertEquals("Wrong packetBandCount_03",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
+ Assert.assertEquals("Wrong packetBandCount_03",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_03",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
+ Assert.assertEquals("Wrong byteBandCount_03",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
*/
"FF 03 03 03 03 03 03 03 "+//packetBandCount_13
"FF 03 03 03 03 03 03 03"//byteBandCount_13
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
- MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
- Assert.assertEquals("Wrong meterId", 9,
+ MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
+ Assert.assertEquals("Wrong meterId", 9,
message.getMeterStats().get(0).getMeterId().getValue().intValue());
- Assert.assertEquals("Wrong flowCount", 7,
+ Assert.assertEquals("Wrong flowCount", 7,
message.getMeterStats().get(0).getFlowCount().intValue());
- Assert.assertEquals("Wrong packetInCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetInCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(0).getPacketInCount());
- Assert.assertEquals("Wrong byteInCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteInCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(0).getByteInCount());
- Assert.assertEquals("Wrong durationSec", 5,
+ Assert.assertEquals("Wrong durationSec", 5,
message.getMeterStats().get(0).getDurationSec().intValue());
- Assert.assertEquals("Wrong durationNsec", 5,
+ Assert.assertEquals("Wrong durationNsec", 5,
message.getMeterStats().get(0).getDurationNsec().intValue());
- Assert.assertEquals("Wrong packetBandCount_01",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetBandCount_01",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_01",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteBandCount_01",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
- Assert.assertEquals("Wrong packetBandCount_02",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong packetBandCount_02",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_02",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong byteBandCount_02",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
- Assert.assertEquals("Wrong packetBandCount_03",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
+ Assert.assertEquals("Wrong packetBandCount_03",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_03",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
+ Assert.assertEquals("Wrong byteBandCount_03",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
-
- Assert.assertEquals("Wrong meterId", 8,
+
+ Assert.assertEquals("Wrong meterId", 8,
message.getMeterStats().get(1).getMeterId().getValue().intValue());
- Assert.assertEquals("Wrong flowCount", 7,
+ Assert.assertEquals("Wrong flowCount", 7,
message.getMeterStats().get(1).getFlowCount().intValue());
- Assert.assertEquals("Wrong packetInCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetInCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(1).getPacketInCount());
- Assert.assertEquals("Wrong byteInCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteInCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(1).getByteInCount());
- Assert.assertEquals("Wrong durationSec", 5,
+ Assert.assertEquals("Wrong durationSec", 5,
message.getMeterStats().get(1).getDurationSec().intValue());
- Assert.assertEquals("Wrong durationNsec", 5,
+ Assert.assertEquals("Wrong durationNsec", 5,
message.getMeterStats().get(1).getDurationNsec().intValue());
- Assert.assertEquals("Wrong packetBandCount_01",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong packetBandCount_01",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_01",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong byteBandCount_01",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount());
- Assert.assertEquals("Wrong packetBandCount_02",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong packetBandCount_02",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_02",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong byteBandCount_02",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount());
- Assert.assertEquals("Wrong packetBandCount_03",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
+ Assert.assertEquals("Wrong packetBandCount_03",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount());
- Assert.assertEquals("Wrong byteBandCount_03",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
+ Assert.assertEquals("Wrong byteBandCount_03",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
*/
"00 00 00 20 "+//meterBandDscp.burstSize
"04 "+//meterBandDscp.precLevel
"00 00 00");//meterBandDscp.pad
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
- MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
+ MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true),
message.getMeterConfig().get(0).getFlags());
- Assert.assertEquals("Wrong meterId", 9,
+ Assert.assertEquals("Wrong meterId", 9,
message.getMeterConfig().get(0).getMeterId().getValue().intValue());
-
- MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
+
+ MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
- Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
+ Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
-
- MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
+
+ MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
- Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
+ Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
*/
"00 00 00 20 "+//meterBandDscp.burstSize
"04 "+//meterBandDscp.precLevel
"00 00 00 "+//meterBandDscp.pad
-
+
"00 18 "+//len01
"00 03 "+//flags01
"00 00 00 07 "+//meterId01
"04 "+//meterBandDscp01.precLevel
"00 00 00"//meterBandDscp01.pad
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
- MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
- Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false),
+ MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
+ Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false),
message.getMeterConfig().get(0).getFlags());
- Assert.assertEquals("Wrong meterId", 9,
+ Assert.assertEquals("Wrong meterId", 9,
message.getMeterConfig().get(0).getMeterId().getValue().intValue());
-
- MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
- MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
- Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
+
+ MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
+ MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
+ Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
-
- MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
+
+ MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
- Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
+ Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
-
+
LOGGER.info(message.getMeterConfig().get(0).getFlags().toString());
Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),
message.getMeterConfig().get(1).getFlags());
- Assert.assertEquals("Wrong meterId01", 7,
+ Assert.assertEquals("Wrong meterId01", 7,
message.getMeterConfig().get(1).getMeterId().getValue().intValue());
-
- MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand();
+
+ MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand();
MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark();
- Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue());
+ Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());
Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
-
+
}
/**
"00 00 00 00"//copyTTLInPad
);
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
- Assert.assertEquals("Wrong type", 1,
+ Assert.assertEquals("Wrong type", 1,
message.getGroupDesc().get(0).getType().getIntValue());
- Assert.assertEquals("Wrong groupId", 8,
+ Assert.assertEquals("Wrong groupId", 8,
message.getGroupDesc().get(0).getGroupId().getValue().intValue());
- Assert.assertEquals("Wrong bucketWeight", 6,
+ Assert.assertEquals("Wrong bucketWeight", 6,
message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
- Assert.assertEquals("Wrong bucketWatchPort", 5,
+ Assert.assertEquals("Wrong bucketWatchPort", 5,
message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
getValue().intValue());
- Assert.assertEquals("Wrong bucketWatchGroup", 4,
+ Assert.assertEquals("Wrong bucketWatchGroup", 4,
message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
-
- Assert.assertEquals("Wrong outputType", Output.class,
+
+ Assert.assertEquals("Wrong outputType", Output.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
.getType());
-
- Assert.assertEquals("Wrong outputPort", 4351,
+
+ Assert.assertEquals("Wrong outputPort", 4351,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
.getAugmentation(PortAction.class).
getPort().getValue().intValue());
-
- Assert.assertEquals("Wrong outputMaxLen", 65535,
+
+ Assert.assertEquals("Wrong outputMaxLen", 65535,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
.getAugmentation(MaxLengthAction.class).
getMaxLength().intValue());
-
- Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class,
+
+ Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
.getType());
-
- Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class,
+
+ Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
.getType());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
* Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB
"0F FF "+//pushPbbEthertype
"00 00"//pushPbbPad
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
- MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
- Assert.assertEquals("Wrong type", 1,
+ MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
+ Assert.assertEquals("Wrong type", 1,
message.getGroupDesc().get(0).getType().getIntValue());
- Assert.assertEquals("Wrong groupId", 8,
+ Assert.assertEquals("Wrong groupId", 8,
message.getGroupDesc().get(0).getGroupId().getValue().intValue());
- Assert.assertEquals("Wrong bucketWeight", 6,
+ Assert.assertEquals("Wrong bucketWeight", 6,
message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
- Assert.assertEquals("Wrong bucketWatchPort", 5,
+ Assert.assertEquals("Wrong bucketWatchPort", 5,
message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
- Assert.assertEquals("Wrong bucketWatchGroup", 4,
+ Assert.assertEquals("Wrong bucketWatchGroup", 4,
message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
- Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class,
+ Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
.getType());
- Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9,
+ Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
.getAugmentation(MplsTtlAction.class).
getMplsTtl().intValue());
- Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class,
+ Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
.getType());
- Assert.assertEquals("Wrong pushVlanType", PushVlan.class,
+ Assert.assertEquals("Wrong pushVlanType", PushVlan.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
.getType());
- Assert.assertEquals("Wrong pushVlanEthertype", 32,
+ Assert.assertEquals("Wrong pushVlanEthertype", 32,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
.getAugmentation(EthertypeAction.class).
getEthertype().getValue().intValue());
- Assert.assertEquals("Wrong pushMplsType", PushMpls.class,
+ Assert.assertEquals("Wrong pushMplsType", PushMpls.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
.getType());
- Assert.assertEquals("Wrong pushMplsEthertype", 255,
+ Assert.assertEquals("Wrong pushMplsEthertype", 255,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3).
getAugmentation(EthertypeAction.class).
getEthertype().getValue().intValue());
- Assert.assertEquals("Wrong pushPbbType", PushPbb.class,
+ Assert.assertEquals("Wrong pushPbbType", PushPbb.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
.getType());
- Assert.assertEquals("Wrong pushPbbEthertype", 4095,
+ Assert.assertEquals("Wrong pushPbbEthertype", 4095,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
.getAugmentation(EthertypeAction.class).
getEthertype().getValue().intValue());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
* Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL
"00 08 "+//decNwTtlLen
"00 00 00 00"//decNwTtlPad
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
- MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
+ MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
- Assert.assertEquals("Wrong bucketWeight", 6,
+ Assert.assertEquals("Wrong bucketWeight", 6,
message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
- Assert.assertEquals("Wrong bucketWatchPort", 5,
+ Assert.assertEquals("Wrong bucketWatchPort", 5,
message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
- Assert.assertEquals("Wrong bucketWatchGroup", 4,
+ Assert.assertEquals("Wrong bucketWatchGroup", 4,
message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
- Assert.assertEquals("Wrong popVlanType", PopVlan.class,
+ Assert.assertEquals("Wrong popVlanType", PopVlan.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
.getType());
- Assert.assertEquals("Wrong popPbbType", PopPbb.class,
+ Assert.assertEquals("Wrong popPbbType", PopPbb.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
.getType());
- Assert.assertEquals("Wrong popMplsType", PopMpls.class,
+ Assert.assertEquals("Wrong popMplsType", PopMpls.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
.getType());
- Assert.assertEquals("Wrong popMplsEthertype", 207,
+ Assert.assertEquals("Wrong popMplsEthertype", 207,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
.getAugmentation(EthertypeAction.class).
getEthertype().getValue().intValue());
- Assert.assertEquals("Wrong setQueueType", SetQueue.class,
+ Assert.assertEquals("Wrong setQueueType", SetQueue.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
.getType());
- Assert.assertEquals("Wrong setQueueQueueId", 13565952,
+ Assert.assertEquals("Wrong setQueueQueueId", 13565952,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
.getAugmentation(QueueIdAction.class).
getQueueId().intValue());
- Assert.assertEquals("Wrong groupType", Group.class,
+ Assert.assertEquals("Wrong groupType", Group.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
.getType());
- Assert.assertEquals("Wrong groupGroupId", 13565952,
+ Assert.assertEquals("Wrong groupGroupId", 13565952,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
.getAugmentation(GroupIdAction.class).
getGroupId().intValue());
- Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class,
+ Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(5)
.getType());
}
-
+
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
* Test covers bodies of actions NW TTL, Experimenter
"00 00 00 FF "+ //setFieldPort
"00 00 00 00"
);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
- Assert.assertEquals("Wrong type", 1,
+ Assert.assertEquals("Wrong type", 1,
message.getGroupDesc().get(0).getType().getIntValue());
- Assert.assertEquals("Wrong groupId", 8,
+ Assert.assertEquals("Wrong groupId", 8,
message.getGroupDesc().get(0).getGroupId().getValue().intValue());
- Assert.assertEquals("Wrong bucketWeight", 6,
+ Assert.assertEquals("Wrong bucketWeight", 6,
message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
- Assert.assertEquals("Wrong bucketWatchPort", 5,
+ Assert.assertEquals("Wrong bucketWatchPort", 5,
message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
getValue().intValue());
- Assert.assertEquals("Wrong bucketWatchGroup", 4,
+ Assert.assertEquals("Wrong bucketWatchGroup", 4,
message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
-
- Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class,
+
+ Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
.getType());
-
- Assert.assertEquals("Wrong nwTTlnwTTL", 14,
+
+ Assert.assertEquals("Wrong nwTTlnwTTL", 14,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
.getAugmentation(NwTtlAction.class).getNwTtl().intValue());
-
- Assert.assertEquals("Wrong setFieldType", SetField.class,
+
+ Assert.assertEquals("Wrong setFieldType", SetField.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
.getType());
-
- Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class,
+
+ Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
.getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass());
-
- Assert.assertEquals("Wrong setFieldOXMField", InPort.class,
+
+ Assert.assertEquals("Wrong setFieldOXMField", InPort.class,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
.getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField());
-
- Assert.assertEquals("Wrong setFieldOXMValue", 255,
+
+ Assert.assertEquals("Wrong setFieldOXMValue", 255,
message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
.getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).
getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());
BufferHelper.checkHeaderV10(builtByFactory);
}
-
+
/**
* Testing {@link OF10EchoReplyMessageFactory} for correct translation into POJO
*/
byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
ByteBuf bb = BufferHelper.buildBuffer(data);
EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
-
+
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
BufferHelper.checkHeaderV10(builtByFactory);
}
-
+
/**
* Testing {@link OF10EchoReplyMessageFactoryTest} for correct translation into POJO
*/
Assert.assertEquals("Wrong port - peer", new PortFeaturesV10(true, false, false, false, false, false, false,
false, true, false, false, true), port.getPeerFeaturesV10());
}
-
+
/**
* Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO
*/
GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
- Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue());
+ Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue());
Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue());
}
-
+
}
@Test
public void test(){
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00 01 02 03 04");
- PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
-
+ PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
+
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());
@Test
public void testWithNoAdditionalData(){
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00");
- PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
+ PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
Assert.assertNull("Wrong data", builtByFactory.getData());
}
+ "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 "
+ "00 00 00 00 15 00 00 00 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
-
+
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason());
Assert.assertEquals("Wrong port - port-no", 16, builtByFactory.getPortNo().intValue());
final int DESC_STR_LEN = 256;
final int SERIAL_NUM_LEN = 32;
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00");
-
+
String mfrDesc = "Manufacturer description";
byte[] mfrDescBytes = new byte[256];
mfrDescBytes = mfrDesc.getBytes();
bb.writeBytes(mfrDescBytes);
bb.writeZero(DESC_STR_LEN - mfrDescBytes.length);
-
+
String hwDesc = "Hardware description";
byte[] hwDescBytes = new byte[256];
hwDescBytes = hwDesc.getBytes();
bb.writeBytes(hwDescBytes);
bb.writeZero(DESC_STR_LEN - hwDescBytes.length);
-
+
String swDesc = "Software description";
byte[] swDescBytes = new byte[256];
swDescBytes = swDesc.getBytes();
bb.writeBytes(swDescBytes);
bb.writeZero(DESC_STR_LEN - swDescBytes.length);
-
+
String serialNum = "SN0123456789";
byte[] serialNumBytes = new byte[32];
serialNumBytes = serialNum.getBytes();
bb.writeBytes(serialNumBytes);
bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length);
-
+
String dpDesc = "switch3 in room 3120";
byte[] dpDescBytes = new byte[256];
dpDescBytes = dpDesc.getBytes();
bb.writeBytes(dpDescBytes);
bb.writeZero(DESC_STR_LEN - dpDescBytes.length);
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
-
+
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue());
Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsReplyMessageFactory (Flow) for correct deserialization
*/
+ "00 00 00 02 00 00 00 03 00 04 00 05 00 06 00 00 00 00 00 00 "
+ "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 "
+ "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00");
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong idleTimeOut", 5, message.getFlowStats().get(0).getIdleTimeout().intValue());
Assert.assertEquals("Wrong hardTimeOut", 6, message.getFlowStats().get(0).getHardTimeout().intValue());
Assert.assertEquals("Wrong cookie",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}),
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}),
message.getFlowStats().get(0).getCookie());
Assert.assertEquals("Wrong packetCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}),
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}),
message.getFlowStats().get(0).getPacketCount());
Assert.assertEquals("Wrong byteCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}),
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}),
message.getFlowStats().get(0).getByteCount());
Action action1 = message.getFlowStats().get(0).getAction().get(0);
Assert.assertEquals("Wrong action type", Output.class, action1.getType());
.getVlanVid().intValue());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsReplyMessageFactory (Aggregate) for correct deserialization
*/
public void testAggregate() {
ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 "
+ "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00");
-
+
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody();
MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate();
Assert.assertEquals("Wrong packet-count",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}),
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}),
message.getPacketCount());
Assert.assertEquals("Wrong byte-count",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}),
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}),
message.getByteCount());
Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsReplyMessageFactory (Table) for correct deserialization
*/
Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue());
Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue());
Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
- Assert.assertEquals("Wrong lookupCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong lookupCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getTableStats().get(0).getLookupCount());
- Assert.assertEquals("Wrong matchedCount",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}),
+ Assert.assertEquals("Wrong matchedCount",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}),
message.getTableStats().get(0).getMatchedCount());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsReplyMessageFactory (Port) for correct deserialization
*/
MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody();
MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats();
Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());
- Assert.assertEquals("Wrong rxPackets",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
+ Assert.assertEquals("Wrong rxPackets",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
message.getPortStats().get(0).getRxPackets());
- Assert.assertEquals("Wrong txPackets",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong txPackets",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getPortStats().get(0).getTxPackets());
- Assert.assertEquals("Wrong rxBytes",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxBytes",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxBytes());
- Assert.assertEquals("Wrong txBytes",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txBytes",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getTxBytes());
- Assert.assertEquals("Wrong rxDropped",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxDropped",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxDropped());
- Assert.assertEquals("Wrong txDropped",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txDropped",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getTxDropped());
- Assert.assertEquals("Wrong rxErrors",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxErrors",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxErrors());
- Assert.assertEquals("Wrong txErrors",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txErrors",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getTxErrors());
- Assert.assertEquals("Wrong rxFrameErr",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxFrameErr",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxFrameErr());
- Assert.assertEquals("Wrong rxOverErr",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxOverErr",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxOverErr());
- Assert.assertEquals("Wrong rxCrcErr",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong rxCrcErr",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getRxCrcErr());
- Assert.assertEquals("Wrong collisions",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong collisions",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getPortStats().get(0).getCollisions());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsReplyMessageFactory (Queue) for correct deserialization
*/
MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
- Assert.assertEquals("Wrong txBytes",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txBytes",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getQueueStats().get(0).getTxBytes());
- Assert.assertEquals("Wrong txPackets",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
+ Assert.assertEquals("Wrong txPackets",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
message.getQueueStats().get(0).getTxPackets());
- Assert.assertEquals("Wrong txErrors",
- new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
+ Assert.assertEquals("Wrong txErrors",
+ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
message.getQueueStats().get(0).getTxErrors());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
public void test(){
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C"
+ " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04");
- PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
-
+ PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
+
BufferHelper.checkHeaderV13(builtByFactory);
-
+
Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());
Assert.assertEquals("Wrong reason", PacketInReason.OFPRACTION, builtByFactory.getReason());
*/
@Test
public void test(){
- ByteBuf bb = BufferHelper.buildBuffer("01 " + //reason
+ ByteBuf bb = BufferHelper.buildBuffer("01 " + //reason
"00 00 00 00 00 00 00 " + //padding
"00 01 02 03 " + //port no
"00 00 00 00 " + //padding in ofp_port1
"00 00 00 81 " + //curr speed
"00 00 00 80" //max speed
);
-
+
PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
-
+
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue());
Assert.assertEquals("Wrong port", 3L, builtByFactory.getPort().getValue().longValue());
Assert.assertEquals("Wrong queues", builtByFactory.getQueues(), createQueuesList());
}
-
+
private static List<Queues> createQueuesList(){
List<Queues> queuesList = new ArrayList<>();
QueuesBuilder qb = new QueuesBuilder();
qb.setPort(new PortNumber(3L));
qb.setQueueProperty(createPropertiesList());
queuesList.add(qb.build());
-
+
return queuesList;
}
-
+
private static List<QueueProperty> createPropertiesList(){
List<QueueProperty> propertiesList = new ArrayList<>();
QueuePropertyBuilder pb = new QueuePropertyBuilder();
RoleRequestOutput builtByFactory = BufferHelper.deserialize(roleFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
-
+
Assert.assertEquals("Wrong role", 0x02, builtByFactory.getRole().getIntValue());
Assert.assertEquals("Wrong generationId", 0x01020304050607L, builtByFactory.getGenerationId().longValue());
}
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass());
Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask());
- Assert.assertEquals("Wrong entry value", 2,
+ Assert.assertEquals("Wrong entry value", 2,
entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());
}
}
\ No newline at end of file
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass());
Assert.assertEquals("Wrong entry field", Metadata.class, entry.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask());
- Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"),
+ Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"),
entry.getAugmentation(MetadataMatchEntry.class).getMetadata());
}
}
\ No newline at end of file
Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask());
Assert.assertEquals("Wrong entry value", 10,
entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue());
- Assert.assertEquals("Wrong entry value", false,
+ Assert.assertEquals("Wrong entry value", false,
entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit());
}
}
\ No newline at end of file
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
/**
- *
+ *
* @author madamjak
*
*/
public class SerializerRegistryImplTest {
-
+
private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
}
/**
- * Test - unregister serializer
+ * Test - unregister serializer
*/
@Test
public void testUnRegisterSerializer(){
/**
* Testing of {@link BarrierInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
BarrierInputBuilder bib = new BarrierInputBuilder();
BufferHelper.setupHeader(bib, EncodeConstants.OF13_VERSION_ID);
BarrierInput bi = bib.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
barrierFactory.serialize(bi, out);
-
+
BufferHelper.checkHeaderV13(out, BARRIER_REQUEST_MESSAGE_CODE_TYPE, 8);
}
/**
* Testing of {@link EchoInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV13() throws Exception {
echoFactory.serialize(ei, out);
BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);
}
-
+
/**
* Testing of {@link EchoInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV10() throws Exception {
/**
* Testing of {@link EchoInputMessageFactory} for correct data serialization
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testData() throws Exception{
/**
* Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV13() throws Exception {
echoFactory.serialize(eri, out);
BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);
}
-
+
/**
* Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV10() throws Exception {
/**
* Testing of {@link ExperimenterInputMessageFactory} for correct serializer
* lookup and serialization
- * @throws Exception
+ * @throws Exception
*/
@Test(expected=IllegalStateException.class)
public void testV10Real() throws Exception {
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setExperimenter(new ExperimenterId(42L));
ExperimenterInput input = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
expFactory.serialize(input, out);
}
/**
* Testing of {@link ExperimenterInputMessageFactory} for correct serializer
* lookup and serialization
- * @throws Exception
+ * @throws Exception
*/
@Test(expected=IllegalStateException.class)
public void testV13Real() throws Exception {
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setExperimenter(new ExperimenterId(42L));
ExperimenterInput input = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
expFactory.serialize(input, out);
}
/**
* Testing of {@link ExperimenterInputMessageFactory} for correct serializer
* lookup and serialization
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV10() throws Exception {
/**
* Testing of {@link ExperimenterInputMessageFactory} for correct serializer
* lookup and serialization
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV13() throws Exception {
}
/**
- * @throws Exception
+ * @throws Exception
* Testing of {@link FlowModInputMessageFactory} for correct translation from POJO
*/
@Test
out.skipBytes(6);
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
-
+
private static FlowModFlags createFlowModFlagsFromBitmap(int input){
final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0;
final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;
- final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0;
+ final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0;
final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0;
final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) > 0;
return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM);
/**
* Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV13() throws Exception {
GetConfigInputBuilder gcib = new GetConfigInputBuilder();
BufferHelper.setupHeader(gcib, EncodeConstants.OF13_VERSION_ID);
GetConfigInput gci = gcib.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
getConfigFactory.serialize(gci, out);
BufferHelper.checkHeaderV13(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);
}
-
+
/**
* Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV10() throws Exception {
GetConfigInputBuilder gcib = new GetConfigInputBuilder();
BufferHelper.setupHeader(gcib, EncodeConstants.OF10_VERSION_ID);
GetConfigInput gci = gcib.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
getConfigFactory.serialize(gci, out);
-
+
BufferHelper.checkHeaderV10(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);
}
/**
* Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV13() throws Exception {
GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
BufferHelper.setupHeader(gfib, EncodeConstants.OF13_VERSION_ID);
GetFeaturesInput gfi = gfib.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
featuresFactory.serialize(gfi, out);
/**
* Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testV10() throws Exception {
GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
BufferHelper.setupHeader(gfib, EncodeConstants.OF10_VERSION_ID);
GetFeaturesInput gfi = gfib.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
featuresFactory.serialize(gfi, out);
/**
* Testing of {@link GetQueueConfigInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testGetQueueConfigInputMessage() throws Exception {
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setPort(new PortNumber(0x00010203L));
GetQueueConfigInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
getQueueFactory.serialize(message, out);
/**
* Testing of {@link GetAsyncRequestMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testGetAsyncReques() throws Exception {
GetAsyncInputBuilder builder = new GetAsyncInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
GetAsyncInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
getAsyncFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
}
}
List<BucketsList> exp = createBucketsList();
builder.setBucketsList(exp);
GroupModInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
groupModFactory.serialize(message, out);
List<BucketsList> rec = createBucketsListFromBufer(out);
Assert.assertArrayEquals("Wrong bucketList", exp.toArray(), rec.toArray());
}
-
+
private static List<BucketsList> createBucketsList(){
List<BucketsList> bucketsList = new ArrayList<>();
BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
bucketsList.add(bucket);
return bucketsList;
}
-
+
private static List<BucketsList> createBucketsListFromBufer(ByteBuf out){
List<BucketsList> bucketsList = new ArrayList<>();
BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
/**
* Testing of {@link HelloInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testWithoutElementsSet() throws Exception {
HelloInputBuilder hib = new HelloInputBuilder();
BufferHelper.setupHeader(hib, EncodeConstants.OF13_VERSION_ID);
HelloInput hi = hib.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(hi, out);
-
+
BufferHelper.checkHeaderV13(out,(byte) 0, EncodeConstants.OFHEADER_SIZE);
}
-
+
/**
* Testing of {@link HelloInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testWith4BitVersionBitmap() throws Exception {
List<Elements> expectedElement = createElement(lengthOfBitmap);
builder.setElements(expectedElement);
HelloInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(message, out);
LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));
-
+
BufferHelper.checkHeaderV13(out, (byte) 0, 16);
Elements element = readElement(out).get(0);
Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType());
Elements comparation = createComparationElement(lengthOfBitmap).get(0);
Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray());
}
-
+
/**
* Testing of {@link HelloInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testWith64BitVersionBitmap() throws Exception {
List<Elements> expectedElement = createElement(lengthOfBitmap);
builder.setElements(expectedElement);
HelloInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(message, out);
LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));
-
+
BufferHelper.checkHeaderV13(out, (byte) 0, 24);
Elements element = readElement(out).get(0);
Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType());
Elements comparation = createComparationElement(lengthOfBitmap).get(0);
Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray());
}
-
+
private static List<Elements> createElement(int lengthOfBitmap) {
ElementsBuilder elementsBuilder = new ElementsBuilder();
List<Elements> elementsList = new ArrayList<>();
elementsList.add(elementsBuilder.build());
return elementsList;
}
-
+
private static List<Elements> createComparationElement(int lengthOfBitmap) {
ElementsBuilder elementsBuilder = new ElementsBuilder();
List<Elements> elementsList = new ArrayList<>();
elementsList.add(elementsBuilder.build());
return elementsList;
}
-
+
private static List<Elements> readElement(ByteBuf input) {
List<Elements> elementsList = new ArrayList<>();
while (input.readableBytes() > 0) {
}
return elementsList;
}
-
+
private static List<Boolean> readVersionBitmap(int[] input){
List<Boolean> versionBitmapList = new ArrayList<>();
for (int i = 0; i < input.length; i++) {
}
/**
- * @throws Exception
+ * @throws Exception
* Testing of {@link MeterModInputMessageFactory} for correct translation from POJO
*/
@Test
builder.setMeterId(new MeterId(2248L));
builder.setBands(createBandsList());
MeterModInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
meterModFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV13(out, (byte) 29, 48);
Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort()));
Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt());
Assert.assertEquals("Wrong bands", message.getBands(), decodeBandsList(out));
}
-
+
private static MeterFlags decodeMeterModFlags(short input){
final Boolean _oFPMFKBPS = (input & (1 << 0)) > 0;
final Boolean _oFPMFPKTPS = (input & (1 << 1)) > 0;
- final Boolean _oFPMFBURST = (input & (1 << 2)) > 0;
+ final Boolean _oFPMFBURST = (input & (1 << 2)) > 0;
final Boolean _oFPMFSTATS = (input & (1 << 3)) > 0;
return new MeterFlags(_oFPMFBURST, _oFPMFKBPS, _oFPMFPKTPS, _oFPMFSTATS);
}
-
+
private static List<Bands> createBandsList(){
List<Bands> bandsList = new ArrayList<>();
BandsBuilder bandsBuilder = new BandsBuilder();
bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
return bandsList;
}
-
+
private static List<Bands> decodeBandsList(ByteBuf input){
List<Bands> bandsList = new ArrayList<>();
BandsBuilder bandsBuilder = new BandsBuilder();
}
/**
- * @throws Exception
+ * @throws Exception
* Testing of {@link MeterModInputMessageFactory} for correct translation from POJO
*/
@Test
builder.setMeterId(new MeterId(2248L));
builder.setBands(null);
MeterModInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
meterModFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV13(out, (byte) 29, 16);
Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort()));
/**
* Testing of {@link OF10BarrierInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
BarrierInputBuilder bib = new BarrierInputBuilder();
BufferHelper.setupHeader(bib, EncodeConstants.OF10_VERSION_ID);
BarrierInput bi = bib.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
barrierFactory.serialize(bi, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 18, 8);
}
}
/**
- * @throws Exception
+ * @throws Exception
* Testing of {@link OF10FlowModInputMessageFactory} for correct translation from POJO
*/
@Test
actions.add(actionBuilder.build());
builder.setAction(actions);
FlowModInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
flowModFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 14, 88);
Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
Assert.assertEquals("Wrong inPort", 58, out.readUnsignedShort());
/**
* Testing of {@link OF10HelloInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testWithoutElementsSet() throws Exception {
HelloInputBuilder hib = new HelloInputBuilder();
BufferHelper.setupHeader(hib, EncodeConstants.OF10_VERSION_ID);
HelloInput hi = hib.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(hi, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 0, 8);
}
/**
* Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testPacketOutInputMessage() throws Exception {
builder.setAction(actions);
builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));
PacketOutInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
packetOutFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 13, 48);
Assert.assertEquals("Wrong BufferId", 256, out.readUnsignedInt());
Assert.assertEquals("Wrong PortNumber", 257, out.readUnsignedShort());
/**
* Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testPacketOutInputWithNoData() throws Exception {
/**
* Testing of {@link OF10PortModInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testPortModInput() throws Exception {
builder.setAdvertiseV10(new PortFeaturesV10(true, true, false, false, false, false,
false, true, true, false, false, false));
PortModInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
portModFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 15, 32);
Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedShort());
byte[] address = new byte[6];
/**
* Testing of {@link OF10QueueGetConfigInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setPort(new PortNumber(6653L));
GetQueueConfigInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
queueFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 20, 12);
Assert.assertEquals("Wrong port", 6653L, out.readUnsignedShort());
out.skipBytes(2);
caseBuilder.setMultipartRequestDesc(descBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 16, 12);
Assert.assertEquals("Wrong type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsRequestInputFactory (Flow) for correct serialization
* @throws Exception
caseBuilder.setMultipartRequestFlow(flowBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 16, 56);
Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong out-port", 42, out.readUnsignedShort());
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsRequestInputFactory (Aggregate) for correct serialization
* @throws Exception
caseBuilder.setMultipartRequestFlow(flowBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 16, 56);
Assert.assertEquals("Wrong type", 2, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong out-port", 6653, out.readUnsignedShort());
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsRequestInputFactory (Table) for correct serialization
* @throws Exception
caseBuilder.setMultipartRequestTable(tableBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 16, 12);
Assert.assertEquals("Wrong type", 3, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
-
+
/**
* Testing OF10StatsRequestInputFactory (Port) for correct serialization
* @throws Exception
caseBuilder.setMultipartRequestPortStats(portBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 16, 20);
Assert.assertEquals("Wrong type", 4, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
caseBuilder.setMultipartRequestQueue(queueBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, (byte) 16, 20);
Assert.assertEquals("Wrong type", 5, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
/**
* Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testPacketOutInputMessage() throws Exception {
builder.setAction(actions);
builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));
PacketOutInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
packetOutFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 56);
Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), out.readUnsignedInt());
Assert.assertEquals("Wrong PortNumber", message.getInPort().getValue().longValue(), out.readUnsignedInt());
/**
* Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testPacketOutInputWithNoData() throws Exception {
/**
* Testing of {@link PortModInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testPortModInput() throws Exception {
builder.setConfig(new PortConfig(true, false, true, false));
builder.setMask(new PortConfig(false, true, false, true));
builder.setAdvertise(new PortFeatures(true, false, false, false,
- false, false, false, true,
- false, false, false, false,
+ false, false, false, true,
+ false, false, false, false,
false, false, false, false));
PortModInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
portModFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);
final Boolean _noPacketIn = ((input) & (1<<6)) > 0;
return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
}
-
+
private static PortFeatures createPortFeatures(long input){
final Boolean _10mbHd = ((input) & (1<<0)) > 0;
final Boolean _10mbFd = ((input) & (1<<1)) > 0;
final Boolean _autoneg = ((input) & (1<<13)) > 0;
final Boolean _pause = ((input) & (1<<14)) > 0;
final Boolean _pauseAsym = ((input) & (1<<15)) > 0;
- return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd,
+ return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd,
_1gbFd, _1gbHd, _1tbFd, _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym);
}
-
+
}
/**
* Testing of {@link RoleRequestInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testRoleRequestInputMessage() throws Exception {
byte[] generationId = new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
builder.setGenerationId(new BigInteger(1, generationId));
RoleRequestInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
roleFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) out.readUnsignedInt()).getIntValue());
out.skipBytes(PADDING_IN_ROLE_REQUEST_MESSAGE);
}
/**
- * @throws Exception
+ * @throws Exception
* Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO
*/
@Test
Assert.assertEquals("Wrong portStatusMask", 0, out.readUnsignedInt());
Assert.assertEquals("Wrong flowRemovedMask", 15, out.readUnsignedInt());
Assert.assertEquals("Wrong flowRemovedMask", 0, out.readUnsignedInt());
-
+
}
private static List<PacketInMask> createPacketInMask() {
}
/**
- * @throws Exception
+ * @throws Exception
* Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO
*/
@Test
/**
* Testing of {@link SetConfigMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testSetConfigMessageV13() throws Exception {
builder.setFlags(flag);
builder.setMissSendLen(10);
SetConfigInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
setConfigFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
Assert.assertEquals("Wrong flags", SwitchConfigFlag.FRAGNORMAL.getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong missSendLen", 10, out.readUnsignedShort());
}
-
+
/**
* Testing of {@link SetConfigMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testSetConfigMessageV10() throws Exception {
builder.setFlags(flag);
builder.setMissSendLen(85);
SetConfigInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
setConfigFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV10(out, MESSAGE_TYPE, MESSAGE_LENGTH);
Assert.assertEquals("Wrong flags", SwitchConfigFlag.OFPCFRAGDROP.getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong missSendLen", 85, out.readUnsignedShort());
/**
* Testing of {@link TableModInputMessageFactory} for correct translation from POJO
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testTableModInput() throws Exception {
builder.setTableId(new TableId(9L));
builder.setConfig(new TableConfig(true));
TableModInput message = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
tableModFactory.serialize(message, out);
-
+
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);
Assert.assertEquals("Wrong TableID", message.getTableId().getValue().intValue(), out.readUnsignedByte());
out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
Assert.assertEquals("Wrong TableConfig", 8, out.readUnsignedInt());
}
-
+
}
/**
* Tests {@link MultipartRequestInputFactory} - GroupDesc case
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
/**
* Tests {@link MultipartRequestInputFactory} - GroupFeatures case
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
/**
* Tests {@link MultipartRequestInputFactory} - MeterFeatures case
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
/**
* Tests {@link MultipartRequestInputFactory} - PortDesc case
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
/**
* Tests {@link MultipartRequestInputFactory} - Table case
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
/**
* Tests {@link OF10StatsRequestInputFactory} for correct serialization
- * @throws Exception
+ * @throws Exception
*/
@Test
public void test() throws Exception {
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareArpOpMatchEntry(1402);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareArpOpHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[6];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[4];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[6];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[4];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[6];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[6];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareEthTypeMatchEntry(65535);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareEthTypeHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength());
}
-
+
private static MatchEntriesBuilder prepareEthTypeMatchEntry(int type) {
MatchEntriesBuilder builder = prepareEthTypeHeader(false);
EthTypeMatchEntryBuilder typeBuilder = new EthTypeMatchEntryBuilder();
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength());
}
-
+
private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) {
MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false);
Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder();
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength());
}
-
+
private static MatchEntriesBuilder prepareIcmpv4TypeMatchEntry(short value) {
MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false);
Icmpv4TypeMatchEntryBuilder icmpv4Builder = new Icmpv4TypeMatchEntryBuilder();
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength());
}
-
+
private static MatchEntriesBuilder prepareIcmpv6TypeMatchEntry(short value) {
MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false);
Icmpv6TypeMatchEntryBuilder icmpv6Builder = new Icmpv6TypeMatchEntryBuilder();
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareIpDscpMatchEntry((short) 58);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareIpDscpHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry((short) 123);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[4];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[4];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(false,
new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true));
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(true,
new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false));
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength());
}
-
+
private static MatchEntriesBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) {
MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(hasMask);
if (hasMask) {
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05");
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7});
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15});
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[8];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMplsBosMatchEntry(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareMplsBosHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength());
}
-
+
private static MatchEntriesBuilder prepareMplsBosMatchEntry(boolean bos) {
MatchEntriesBuilder builder = prepareMplsBosHeader(false);
BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMplsLabelMatchEntry(168535);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareMplsLabelHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMplsTcMatchEntry((short) 16);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareMplsTcHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = preparePbbIsidMatchEntry(false, 12345);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = preparePbbIsidMatchEntry(true, 6789);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = preparePbbIsidHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = preparePbbIsidHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
assertEquals("Wrong value length", EncodeConstants.SIZE_OF_3_BYTES, serializer.getValueLength());
}
-
+
private static MatchEntriesBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) {
MatchEntriesBuilder builder = preparePbbIsidHeader(hasMask);
if (hasMask) {
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry(4096);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry(4096);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry(4096);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry(512);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithoutMask() {
MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7});
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithMask() {
MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15});
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
checkHeader(buffer, true);
-
+
byte[] address = new byte[8];
buffer.readBytes(address);
Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry(2048);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareMatchEntry(1024);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerialize() {
MatchEntriesBuilder builder = prepareVlanPcpMatchEntry((short) 42);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeader() {
MatchEntriesBuilder builder = prepareVlanPcpHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeWithCfiBitSet() {
MatchEntriesBuilder builder = prepareVlanVidMatchEntry(false, true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeWithoutCfiBitSet() {
MatchEntriesBuilder builder = prepareVlanVidMatchEntry(true, false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(builder.build(), buffer);
@Test
public void testSerializeHeaderWithoutMask() {
MatchEntriesBuilder builder = prepareVlanVidHeader(false);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
@Test
public void testSerializeHeaderWithMask() {
MatchEntriesBuilder builder = prepareVlanVidHeader(true);
-
+
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
serializer.serializeHeader(builder.build(), buffer);
+ "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 "
+ "00 1A 00 08 00 0A 00 00 "
+ "00 1B 00 08 00 00 00 00");
-
+
message.skipBytes(4); // skip XID
LOGGER.info("bytes: " + message.readableBytes());
-
+
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
message.readableBytes(), message, keyMaker, registry);
Assert.assertEquals("Wrong match entry field", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow."
+ "oxm.rev130731.InPhyPort", entries.get(0).getOxmMatchField().getName());
Assert.assertEquals("Wrong match entry mask", false, entries.get(0).isHasMask());
- Assert.assertEquals("Wrong match entry value", 11,
+ Assert.assertEquals("Wrong match entry value", 11,
entries.get(0).getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."
+ "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName());
/**
* @author michal.polkorab
- *
+ *
*/
public abstract class BufferHelper {
/**
- *
+ *
*/
public static final Long DEFAULT_XID = 0x01020304L;
private static final byte[] XID = new byte[] { 0x01, 0x02, 0x03, 0x04 };
bb.writeBytes(payload);
return bb;
}
-
+
/**
* @param payload String in hex format
* @return ByteBuf filled with OpenFlow protocol message without first 4
public static ByteBuf buildBuffer(String payload) {
return buildBuffer(ByteBufUtils.hexStringToBytes(payload));
}
-
+
/**
* @return ByteBuf filled with OpenFlow protocol header message without first 4
* bytes
public static void checkHeaderV13(ByteBuf input, byte msgType, int length) {
checkHeader(input, msgType, length, (short) EncodeConstants.OF13_VERSION_ID);
}
-
+
/**
* Use version 1.0 for encoded message
* @param input ByteBuf to be checked for correct OpenFlow Protocol header
public static void checkHeaderV10(ByteBuf input, byte msgType, int length) {
checkHeader(input, msgType, length, (short) EncodeConstants.OF10_VERSION_ID);
}
-
+
private static void checkHeader(ByteBuf input, byte msgType, int length, Short version) {
Assert.assertEquals("Wrong version", version, Short.valueOf(input.readByte()));
Assert.assertEquals("Wrong type", msgType, input.readByte());
Assert.assertEquals("Wrong length", length, input.readUnsignedShort());
Assert.assertEquals("Wrong Xid", DEFAULT_XID, Long.valueOf(input.readUnsignedInt()));
}
-
+
/**
* @param ofHeader OpenFlow protocol header
public static void checkHeaderV13(OfHeader ofHeader) {
checkHeader(ofHeader, (short) EncodeConstants.OF13_VERSION_ID);
}
-
+
/**
* @param ofHeader OpenFlow protocol header
*/
public static void checkHeaderV10(OfHeader ofHeader) {
checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID);
}
-
+
private static void checkHeader(OfHeader ofHeader, Short version) {
Assert.assertEquals("Wrong version", version, ofHeader.getVersion());
Assert.assertEquals("Wrong Xid", DEFAULT_XID, ofHeader.getXid());
}
-
+
/**
* @param builder
* @param version wire protocol number used
+ "00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 30 00 05 00 08 00 00 00 00 00 06 00 08 "
+ "00 01 02 03 00 03 00 20 00 00 00 00 00 00 00 10 00 00 00 25 00 35 00 00 00 00 00 00 "
+ "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00");
-
+
message.skipBytes(4); // skip XID
-
+
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Instruction> instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
message.readableBytes(), message, keyMaker, registry);
Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"),
entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());
}
-
+
/**
* Testing Ipv6 address deserialization
*/
@Test
public void testIpv6Address() {
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07");
-
+
MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,
0x8000, 26);
key.setExperimenterId(null);
Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"),
entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());
}
-
+
/**
* Testing match deserialization
*/
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass());
Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask());
- Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"),
+ Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"),
entry2.getAugmentation(MetadataMatchEntry.class).getMetadata());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"),
entry2.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry3 = entries.get(3);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass());
Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask());
- Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"),
+ Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"),
entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"),
entry3.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry4 = entries.get(4);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass());
Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask());
- Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"),
+ Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"),
entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"),
entry4.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry5 = entries.get(5);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass());
Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask());
Assert.assertEquals("Wrong entry value", 10,
entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue());
- Assert.assertEquals("Wrong entry value", false,
+ Assert.assertEquals("Wrong entry value", false,
entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"),
entry6.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry7 = entries.get(7);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass());
Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask());
Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"),
entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"),
entry11.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry12 = entries.get(12);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass());
Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask());
Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"),
entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"),
entry12.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry13 = entries.get(13);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass());
Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask());
Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"),
entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"),
entry22.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry23 = entries.get(23);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass());
Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask());
Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"),
entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"),
entry23.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry24 = entries.get(24);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass());
Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask());
- Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"),
+ Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"),
entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"),
entry24.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry25 = entries.get(25);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass());
Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask());
- Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"),
+ Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"),
entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
- Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"),
+ Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"),
entry25.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry26 = entries.get(26);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass());
Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask());
- Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"),
+ Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"),
entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());
Assert.assertArrayEquals("Wrong entry mask",
- ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"),
+ ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"),
entry26.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry27 = entries.get(27);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass());
Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask());
- Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"),
+ Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"),
entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());
Assert.assertArrayEquals("Wrong entry mask",
- ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"),
+ ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"),
entry27.getAugmentation(MaskMatchEntry.class).getMask());
MatchEntries entry28 = entries.get(28);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass());
Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask());
- Assert.assertEquals("Wrong entry value", 2,
+ Assert.assertEquals("Wrong entry value", 2,
entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());
Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"),
entry28.getAugmentation(MaskMatchEntry.class).getMask());
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass());
Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask());
- Assert.assertEquals("Wrong entry value", 21,
+ Assert.assertEquals("Wrong entry value", 21,
entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue());
MatchEntries entry30 = entries.get(30);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass());
Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask());
- Assert.assertEquals("Wrong entry value", 23,
+ Assert.assertEquals("Wrong entry value", 23,
entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue());
MatchEntries entry31 = entries.get(31);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass());
Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask());
- Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"),
+ Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"),
entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());
MatchEntries entry32 = entries.get(32);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass());
Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask());
- Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"),
+ Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"),
entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
MatchEntries entry33 = entries.get(33);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass());
+ "00 09 00 08 00 02 00 00 "
+ "00 0A 00 08 00 03 00 00 "
+ "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30");
-
+
message.skipBytes(4); // skip XID
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID,
Action action6 = actions.get(5);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight"
+ ".openflow.common.action.rev130731.SetDlDst", action6.getType().getName());
- Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"),
+ Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"),
ByteBufUtils.macAddressToBytes(action6.getAugmentation(DlAddressAction.class).getDlAddress().getValue()));
Action action7 = actions.get(6);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight"
}
/**
- * Testing correct serialization of actions (OF v1.0)
+ * Testing correct serialization of actions (OF v1.0)
*/
@Test
public void test() {
queueBuilder.setQueueId(400L);
actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build());
actions.add(actionBuilder.build());
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ListSerializer.serializeList(actions, TypeKeyMakerFactory
.createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out);
-
+
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 42, out.readUnsignedShort());
Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt());
Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0);
}
-
+
}
\ No newline at end of file
Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
}
-
+
/**
* Testing correct deserialization of ofp_match
*/
builder.setTpDst(4096);
MatchV10 match = builder.build();
matchSerializer.serialize(match, out);
-
+
Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
-
+
/**
* Testing correct serialization of ofp_match
*/
builder.setTpDst(4096);
MatchV10 match = builder.build();
matchSerializer.serialize(match, out);
-
+
Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
/**
* @author michal.polkorab
- *
+ *
*/
public class OF13ActionsSerializerTest {
actionBuilder = new ActionBuilder();
actionBuilder.setType(PopPbb.class);
actions.add(actionBuilder.build());
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ListSerializer.serializeList(actions, TypeKeyMakerFactory
.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out);
-
+
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt());
actionsBuilder.setAction(actions);
builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
instructions.add(builder.build());
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ListSerializer.serializeList(instructions, TypeKeyMakerFactory
.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out);
-
+
Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte());
MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
Match match = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
matchSerializer.serialize(match, out);
-
+
Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort());
Assert.assertTrue("Wrong padding", out.readableBytes() == 4);
}
-
+
/**
* Testing serialization of match
*/
bosBuilder.setBos(true);
entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build());
entries.add(entryBuilder.build());
-
+
entryBuilder = new MatchEntriesBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(PbbIsid.class);
maskBuilder.setMask(new byte[]{0,1,2});
entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
entries.add(entryBuilder.build());
-
+
entryBuilder = new MatchEntriesBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(TunnelId.class);
maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2});
entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
entries.add(entryBuilder.build());
-
+
entryBuilder = new MatchEntriesBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv6Exthdr.class);
maskBuilder.setMask(new byte[]{0,2});
entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
entries.add(entryBuilder.build());
-
-
-
+
+
+
builder.setMatchEntries(entries);
Match match = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
matchSerializer.serialize(match, out);
-
+
Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
entries.add(entriesBuilder.build());
builder.setMatchEntries(entries);
Match match = builder.build();
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
matchSerializer.serialize(match, out);
-
+
Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong ip address (third number)", 3, out.readUnsignedByte());
Assert.assertEquals("Wrong ip address (fourth number)", 4, out.readUnsignedByte());
}
-
+
/**
* Test for correct serialization of Ipv6Address match entry
*/
Match match = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
matchSerializer.serialize(match, out);
-
+
Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
@Test
public void testIpv6Flabel() {
Match match = buildIpv6FLabelMatch(0x0f9e8dL, false, null);
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
matchSerializer.serialize(match, out);
-
+
Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
byte[] label = new byte[4];
out.readBytes(label);
-
+
LOG.debug("label: "+ ByteBufUtils.bytesToHexString(label));
Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label);
}
-
+
/**
* Test for correct serialization of Ipv4Address match entry with mask
*/
@Test
public void testIpv6FlabelWithMask() {
Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0, 0x0c, 0x7b, 0x6a});
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
matchSerializer.serialize(match, out);
-
+
Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
byte[] labelAndMask = new byte[8];
out.readBytes(labelAndMask);
-
+
LOG.debug("label: "+ByteBufUtils.bytesToHexString(labelAndMask));
Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d, 0, 0x0c, 0x7b, 0x6a}, labelAndMask);
}
-
+
/**
* Test for correct serialization of Ipv4Address match entry with wrong mask
*/
@Test
public void testIpv6FlabelWithMaskBad() {
Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0x0c, 0x7b, 0x6a});
-
+
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
-
+
try {
matchSerializer.serialize(match, out);
Assert.fail("incorrect length of mask ignored");
import org.slf4j.LoggerFactory;
/**
- * General tests for StatisticsCounters class
+ * General tests for StatisticsCounters class
* @author madamjak
*
*/
} else {
Assert.assertNull("Wrong - not enabled counter give not null value", statCounters.getCounter(cet));
}
-
+
}
statCounters.resetCounters();
for(CounterEventTypes cet : CounterEventTypes.values()){
<url>https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main</url>
<tag>HEAD</tag>
</scm>
-
+
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
private static final Logger LOGGER = LoggerFactory
.getLogger(IntegrationTest.class);
-
+
private static int port;
private TlsConfiguration tlsConfiguration;
private static final int SWITCH_IDLE_TIMEOUT = 2000;
*/
public void setUp(TransportProtocol protocol) throws Exception {
LOGGER.debug("\n starting test -------------------------------");
-
+
String currentDir = System.getProperty("user.dir");
LOGGER.debug("Current dir using System:" +currentDir);
startupAddress = InetAddress.getLocalHost();
connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT);
connConfig.setTransferProtocol(protocol);
mockPlugin = new MockPlugin();
-
+
switchConnectionProvider = new SwitchConnectionProviderImpl();
switchConnectionProvider.setSwitchConnectionHandler(mockPlugin);
switchConnectionProvider.setConfiguration(connConfig);
/**
* Library integration and communication test with handshake
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testHandshake() throws Exception {
OFClient firstClient = clients.get(0);
firstClient.getScenarioDone().get();
Thread.sleep(1000);
-
+
LOGGER.debug("testHandshake() Finished") ;
}
/**
* Library integration and secured communication test with handshake
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testTlsHandshake() throws Exception {
OFClient firstClient = clients.get(0);
firstClient.getScenarioDone().get();
Thread.sleep(1000);
-
+
LOGGER.debug("testTlsHandshake() Finished") ;
}
/**
* Library integration and communication test with handshake + echo exchange
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testHandshakeAndEcho() throws Exception {
/**
* Library integration and secured communication test with handshake + echo exchange
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testTlsHandshakeAndEcho() throws Exception {
/**
* Library udp integration and communication test with handshake + echo exchange
- * @throws Exception
+ * @throws Exception
*/
@Test
public void testUdpHandshakeAndEcho() throws Exception {
}
/**
- * @param amountOfCLients
+ * @param amountOfCLients
* @param protocol true if encrypted connection should be used
* @return new clients up and running
* @throws ExecutionException if some client could not start
* @author michal.polkorab
*
*/
-public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler,
+public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler,
SystemNotificationsListener, ConnectionReadyListener {
protected static final Logger LOGGER = LoggerFactory.getLogger(MockPlugin.class);
finishedFuture = SettableFuture.create();
LOGGER.debug("mockPlugin: "+System.identityHashCode(this));
}
-
+
@Override
public void onSwitchConnected(ConnectionAdapter connection) {
LOGGER.debug("onSwitchConnected: " + connection);
@Override
public void onErrorMessage(ErrorMessage notification) {
LOGGER.debug("Error message received");
-
+
}
@Override
public void onExperimenterMessage(ExperimenterMessage notification) {
LOGGER.debug("Experimenter message received");
-
+
}
@Override
public void onFlowRemovedMessage(FlowRemovedMessage notification) {
LOGGER.debug("FlowRemoved message received");
-
+
}
@Override
}).start();
}
-
+
protected void getSwitchFeatures() {
GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
featuresBuilder.setVersion((short) 4);
Future<Boolean> disconnect = adapter.disconnect();
disconnect.get();
LOGGER.debug("MockPlugin.shutdown() Disconnected");
- }
+ }
} catch (Exception e) {
LOGGER.error("MockPlugin.shutdown() exception caught: ", e.getMessage(), e);
}
@Override
public void onMultipartReplyMessage(MultipartReplyMessage notification) {
LOGGER.debug("MultipartReply message received");
-
+
}
@Override
@Override
public void onPortStatusMessage(PortStatusMessage notification) {
LOGGER.debug("MockPlugin.onPortStatusMessage() message received");
-
+
}
@Override
public int getIdleCounter() {
return idleCounter;
}
-
+
@Override
public void onConnectionReady() {
LOGGER.trace("MockPlugin().onConnectionReady()");
</parent>
<artifactId>openflow-protocol-spi</artifactId>
<packaging>bundle</packaging>
-
+
<name>Openflow Protocol Library - SPI</name>
<scm>
<url>https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main</url>
<tag>HEAD</tag>
</scm>
-
+
<build>
<plugins>
<plugin>
</plugin>
</plugins>
</build>
-
+
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
* @param configuration [protocol, port, address and supported features]
*/
void setConfiguration(ConnectionConfiguration configuration);
-
+
/**
* start listening to switches, but please don't forget to do
* {@link #setSwitchConnectionHandler(SwitchConnectionHandler)} first
* @return future, triggered to true, when listening channel is up and running
*/
ListenableFuture<Boolean> startup();
-
+
/**
* stop listening to switches
* @return future, triggered to true, when all listening channels are down
*/
ListenableFuture<Boolean> shutdown();
-
+
/**
* @param switchConHandler instance being informed when new switch connects
*/
/**
* Used for JConsole service
- *
+ *
* @author michal.polkorab
*/
public interface StatisticsHandler {
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
+<!-- Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<ietf.model.version>2010.09.24.7-SNAPSHOT</ietf.model.version>
<yang.ext.version>2013.09.07.7-SNAPSHOT</yang.ext.version>
<maven.bundle.version>2.4.0</maven.bundle.version>
- <guava.version>14.0.1</guava.version>
+ <guava.version>14.0.1</guava.version>
<netty.version>4.0.23.Final</netty.version>
<releaseplugin.version>2.3.2</releaseplugin.version>
<yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
<phase>deploy</phase>
<goals>
<goal>jar-no-fork</goal>
- </goals>
+ </goals>
</execution>
</executions>
</plugin>
<url>https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main</url>
<tag>HEAD</tag>
</scm>
-
+
<build>
<plugins>
<plugin>
</plugin>
</plugins>
</build>
-
+
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
kmf.init(ks, ClientSslKeyStore.getCertificatePassword());
-
+
KeyStore ts = KeyStore.getInstance("JKS");
ts.load(ClientSslTrustStore.asInputStream(),
ClientSslTrustStore.getKeyStorePassword());
-
+
TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm);
tmf.init(ts);
-
+
clientContext = SSLContext.getInstance(PROTOCOL);
clientContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
} catch (Exception e) {
/**
* Unifying interface for simple clients / switch simulators
- *
+ *
* @author michal.polkorab
*/
public interface OFClient extends Runnable {
/**
* Class for providing prepared handshake scenario
- *
+ *
* @author michal.polkorab
*/
public final class ScenarioFactory {
import org.slf4j.LoggerFactory;
/**
- *
+ *
* @author michal.polkorab
*
*/
private boolean scenarioFinished = false;
/**
- *
+ *
* @param scenario
*/
public ScenarioHandler(Stack<ClientEvent> scenario) {
this.notify();
}
}
-
+
/**
* @return true if scenario is done / empty
*/
/**
* Class representing sending message event
- *
+ *
* @author michal.polkorab
*/
public class SendEvent implements ClientEvent {
private SettableFuture<Boolean> isOnlineFuture;
private SettableFuture<Boolean> scenarioDone;
private ScenarioHandler scenarioHandler;
-
+
/**
* Constructor of class
*
isOnlineFuture = SettableFuture.create();
scenarioDone = SettableFuture.create();
}
-
+
/**
* Starting class of {@link SimpleClient}
*/
}
scenarioHandler.setCtx(ctx);
scenarioHandler.start();
-
+
}
/**
import com.google.common.util.concurrent.SettableFuture;
/** Initializes secured {@link SimpleClient} pipeline
- *
+ *
* @author michal.polkorab
*/
public class SimpleClientInitializer extends ChannelInitializer<NioSocketChannel> {
-
+
private SettableFuture<Boolean> isOnlineFuture;
private boolean secured;
private ScenarioHandler scenarioHandler;
/**
* Class representing sleep (wait) event
- *
+ *
* @author michal.polkorab
*/
public class SleepEvent implements ClientEvent {
private long sleepTime;
/**
- *
+ *
* @param sleepTime time of {@link Thread#sleep(long)} in milliseconds
*/
public SleepEvent(long sleepTime) {
private SettableFuture<Boolean> isOnlineFuture;
private SettableFuture<Boolean> scenarioDone;
private ScenarioHandler scenarioHandler;
-
+
/**
* Constructor of class
*
isOnlineFuture = SettableFuture.create();
scenarioDone = SettableFuture.create();
}
-
+
/**
* Starting class of {@link UdpSimpleClient}
*/
sc = new UdpSimpleClient(host, port);
}
sc.run();
-
+
}
@Override
import com.google.common.util.concurrent.SettableFuture;
/** Initializes udp pipeline
- *
+ *
* @author michal.polkorab
*/
public class UdpSimpleClientInitializer extends ChannelInitializer<NioDatagramChannel> {
-
+
private SettableFuture<Boolean> isOnlineFuture;
private ScenarioHandler scenarioHandler;
* @author michal.polkorab
*/
public class WaitForMessageEvent implements ClientEvent {
-
+
private static final Logger LOGGER = LoggerFactory.getLogger(WaitForMessageEvent.class);
private byte[] headerExpected;
private byte[] headerReceived;
public class ByteBufUtilsTest {
private byte[] expected = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, (byte) 0xff};
-
+
/**
* Test of {@link org.opendaylight.openflowjava.util.ByteBufUtils#hexStringToBytes(String)}
*/
@Test
public void testHexStringToByteBuf() {
ByteBuf bb = ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff");
-
+
Assert.assertArrayEquals(expected, byteBufToByteArray(bb));
}
-
+
/**
* Test of {@link ByteBufUtils#hexStringToByteBuf(String, ByteBuf)}
*/
Assert.assertArrayEquals(expected, byteBufToByteArray(buffer));
}
-
+
private static byte[] byteBufToByteArray(ByteBuf bb) {
byte[] result = new byte[bb.readableBytes()];
bb.readBytes(result);
return result;
}
-
+
/**
* Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}
*/
Map<Integer, Boolean> emptyMap = new HashMap<>();
String expectedBinaryString = "00000000000000000000000000000000";
String bitmaskInBinaryString = toBinaryString(emptyMap, 32);
-
+
Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString);
}
private static String toBinaryString(Map<Integer, Boolean> emptyMap, int length) {
- String binaryString = Integer.toBinaryString(ByteBufUtils.fillBitMaskFromMap(emptyMap));
+ String binaryString = Integer.toBinaryString(ByteBufUtils.fillBitMaskFromMap(emptyMap));
return String.format("%"+length+"s", binaryString).replaceAll(" ", "0");
}
-
+
/**
* Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}
*/
bitmaskValueInBinarySytring = toBinaryString(fullMap, 32);
Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
}
-
+
/**
* Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}
*/
bitmaskValueInBinarySytring = toBinaryString(zeroMap, 32);
Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
}
-
+
/**
* Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}
*/
bitmaskValueInBinarySytring = toBinaryString(randomMap, 32);
Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
}
-
+
/**
* Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
*/
emptyList.add(null);
String expectedBinaryString = "00000000000000000000000000000000";
String bitmaskInBinaryString = listToBinaryString(emptyList, 32);
-
+
Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString);
}
private static String listToBinaryString(List<Boolean> emptyList, int length) {
int[] bitMaskArray;
bitMaskArray = ByteBufUtils.fillBitMaskFromList(emptyList);
- String binaryString = Integer.toBinaryString(bitMaskArray[0]);
+ String binaryString = Integer.toBinaryString(bitMaskArray[0]);
return String.format("%"+length+"s", binaryString).replaceAll(" ", "0");
}
-
+
/**
* Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
*/
bitmaskValueInBinarySytring = listToBinaryString(fullList, 32);
Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
}
-
+
/**
* Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
*/
bitmaskValueInBinarySytring = listToBinaryString(zeroList, 32);
Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
}
-
+
/**
* Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
*/
public void testDecodeString() {
ByteBuf buf = ByteBufUtils.hexStringToByteBuf("4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00");
Assert.assertEquals("Wrong string decoded", "JAMES BOND", ByteBufUtils.decodeNullTerminatedString(buf, 16));
-
+
ByteBuf buf2 = ByteBufUtils.hexStringToByteBuf("53 50 49 44 45 52 4D 41 4E 00 00 00 00 00 00");
Assert.assertEquals("Wrong string decoded", "SPIDERMAN", ByteBufUtils.decodeNullTerminatedString(buf2, 15));
}
String ipv4Address = ByteBufUtils.readIpv4Address(buffer);
Assert.assertEquals("Wrong conversion", "10.20.30.40", ipv4Address);
Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0);
-
+
ByteBuf buffer2 = PooledByteBufAllocator.DEFAULT.buffer();
buffer.writeByte(10);
ipv4Address = ByteBufUtils.readIpv4Address(buffer2);
String ipv4Address = ByteBufUtils.readIpv6Address(buffer);
Assert.assertEquals("Wrong conversion", "000A:FFFF:1000:0000:0400:002A:0A08:B279", ipv4Address);
Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0);
-
+
ByteBuf buffer2 = PooledByteBufAllocator.DEFAULT.buffer();
buffer.writeShort(10);
ipv4Address = ByteBufUtils.readIpv6Address(buffer2);