use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project openflowplugin by opendaylight.
the class MatchV10ResponseConvertorTest method test.
/**
* Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
*/
@Test
public void test() {
MatchV10Builder builder = new MatchV10Builder();
builder.setWildcards(new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false));
builder.setNwSrcMask((short) 24);
builder.setNwDstMask((short) 16);
builder.setInPort(6653);
builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
builder.setDlVlan(128);
builder.setDlVlanPcp((short) 2);
builder.setDlType(15);
builder.setNwTos((short) 16);
builder.setNwProto((short) 6);
builder.setNwSrc(new Ipv4Address("1.1.1.2"));
builder.setNwDst(new Ipv4Address("32.16.8.1"));
builder.setTpSrc(2048);
builder.setTpDst(4096);
MatchV10 match = builder.build();
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final Match salMatch = convert(match, datapathIdConvertorData).build();
Assert.assertEquals("Wrong in port", "openflow:42:6653", salMatch.getInPort().getValue());
Assert.assertEquals("Wrong dl src", new MacAddress("01:01:01:01:01:01"), salMatch.getEthernetMatch().getEthernetSource().getAddress());
Assert.assertEquals("Wrong dl dst", new MacAddress("02:02:02:02:02:02"), salMatch.getEthernetMatch().getEthernetDestination().getAddress());
Assert.assertEquals("Wrong dl type", 15, salMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());
Assert.assertEquals("Wrong dl vlan", 128, salMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
Assert.assertEquals("Wrong dl vlan pcp", 2, salMatch.getVlanMatch().getVlanPcp().getValue().intValue());
Ipv4Match ipv4Match = (Ipv4Match) salMatch.getLayer3Match();
Assert.assertEquals("Wrong nw src address", "1.1.1.2/24", ipv4Match.getIpv4Source().getValue());
Assert.assertEquals("Wrong nw dst address", "32.16.8.1/16", ipv4Match.getIpv4Destination().getValue());
Assert.assertEquals("Wrong ip protocol", 6, salMatch.getIpMatch().getIpProtocol().intValue());
Assert.assertEquals("Wrong ip proto", null, salMatch.getIpMatch().getIpProto());
Assert.assertEquals("Wrong ip ecn", null, salMatch.getIpMatch().getIpEcn());
Assert.assertEquals("Wrong ip dscp", 4, salMatch.getIpMatch().getIpDscp().getValue().intValue());
TcpMatch tcpMatch = (TcpMatch) salMatch.getLayer4Match();
Assert.assertEquals("Wrong tp dst", 4096, tcpMatch.getTcpDestinationPort().getValue().intValue());
Assert.assertEquals("Wrong tp src", 2048, tcpMatch.getTcpSourcePort().getValue().intValue());
Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAndQuery__ApplicationData.
public void registerAndQuery__ApplicationData() throws SocketTimeoutException {
cleanUP();
String ipString = "1.2.3.4";
short protocol = 1;
int ipTOs = 2;
int localPortLow = 3;
int localPortHigh = 4;
int remotePortLow = 4;
int remotePortHigh = 5;
ApplicationDataBuilder builder = new ApplicationDataBuilder();
builder.setIpTos(ipTOs);
builder.setProtocol(protocol);
builder.setLocalPortLow(new PortNumber(localPortLow));
builder.setLocalPortHigh(new PortNumber(localPortHigh));
builder.setRemotePortLow(new PortNumber(remotePortLow));
builder.setRemotePortHigh(new PortNumber(remotePortHigh));
builder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(ipString))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(ApplicationDataLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(builder.build()).build());
Eid addressToSend = eb.build();
MapReply reply = registerAddressAndQuery(addressToSend);
Eid receivedAddress = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(ApplicationDataLcaf.class, receivedAddress.getAddressType());
ApplicationData receivedApplicationDataAddress = (ApplicationData) receivedAddress.getAddress();
assertEquals(protocol, receivedApplicationDataAddress.getApplicationData().getProtocol().intValue());
assertEquals(ipTOs, receivedApplicationDataAddress.getApplicationData().getIpTos().intValue());
assertEquals(localPortLow, receivedApplicationDataAddress.getApplicationData().getLocalPortLow().getValue().intValue());
assertEquals(localPortHigh, receivedApplicationDataAddress.getApplicationData().getLocalPortHigh().getValue().intValue());
assertEquals(remotePortLow, receivedApplicationDataAddress.getApplicationData().getRemotePortLow().getValue().intValue());
assertEquals(remotePortHigh, receivedApplicationDataAddress.getApplicationData().getRemotePortHigh().getValue().intValue());
SimpleAddress ipAddressReceived = receivedApplicationDataAddress.getApplicationData().getAddress();
assertEquals(ipString, ipAddressReceived.getIpAddress().getIpv4Address().getValue());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project lispflowmapping by opendaylight.
the class ApplicationDataSerializerTest method deserialize__Ipv6.
@Test
public void deserialize__Ipv6() throws Exception {
Eid appAddress = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"04 20 00 1E " + // IPTOS & protocol
"AA BB CC DD " + // local port range
"A6 A1 A6 A2 " + // remote port range
"FF DD FF DE " + "00 02 11 22 33 44 55 66 77 88 99 AA BB CC AA BB CC DD"), // AFI=2,
null);
// IPv6
assertEquals("1122:3344:5566:7788:99aa:bbcc:aabb:ccdd", String.valueOf(((ApplicationData) appAddress.getAddress()).getApplicationData().getAddress().getValue()));
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project lispflowmapping by opendaylight.
the class ApplicationDataSerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
ApplicationDataBuilder addressBuilder = new ApplicationDataBuilder();
addressBuilder.setIpTos(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC }));
addressBuilder.setProtocol((short) 0xDD);
addressBuilder.setLocalPortLow(new PortNumber(0xA6A1));
addressBuilder.setLocalPortHigh(new PortNumber(0xA6A2));
addressBuilder.setRemotePortLow(new PortNumber(0xFFDD));
addressBuilder.setRemotePortHigh(new PortNumber(0xFFDE));
addressBuilder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address("17.34.51.68"))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(ApplicationDataLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(addressBuilder.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(eb.build()));
LispAddressSerializer.getInstance().serialize(buf, eb.build());
ByteBuffer expectedBuf = hexToByteBuffer(//
"40 03 00 00 " + //
"04 00 00 12 " + // IPTOS & protocol
"AA BB CC DD " + // local port range
"A6 A1 A6 A2 " + // remote port range
"FF DD FF DE " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project genius by opendaylight.
the class ArpUtilTestUtil method createPayload.
public static PacketReceived createPayload(int oc) {
final short ID = 2;
byte[] payload = bytePayload(// Destination MAC
"1F 1F 1F 1F 1F 1F", // Source MAC
"00 01 02 03 04 05", // Ethernet type
"08 06", // Hardware type
"0 1", // Protocol type
"8 0", // Hardware size
"6", // Protocol size
"4", // Opcode
OP_CODE[oc], // Sender MAC Address
"00 01 02 03 04 05", // Sender IP Address
"C0 A8 0 2", // Target MAC Address
"00 01 02 03 04 05", // Target IP Address
"C0 A8 0 2");
return new PacketReceivedBuilder().setPacketInReason(SendToController.class).setTableId(new TableId(ID)).setPayload(payload).setIngress(new NodeConnectorRef(InstanceIdentifier.create(Node.class))).setMatch(new MatchBuilder().setMetadata(new MetadataBuilder().setMetadata(META_DATA).build()).build()).build();
}
Aggregations