use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv4TcpMatchTest.
@Test
public void buildIpv4TcpMatchTest() {
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
aceIpBuilder.setProtocol(IPProtocols.TCP.shortValue());
SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
srcPortRange.setLowerPort(new PortNumber(TCP_SRC_LOWER_PORT));
srcPortRange.setUpperPort(new PortNumber(TCP_SRC_UPPER_PORT));
aceIpBuilder.setSourcePortRange(srcPortRange.build());
DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
dstPortRange.setLowerPort(new PortNumber(TCP_DST_LOWER_PORT));
dstPortRange.setUpperPort(new PortNumber(TCP_DST_UPPER_PORT));
aceIpBuilder.setDestinationPortRange(dstPortRange.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// There should be an IPv4 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
// Make sure its TCP
IpMatch ipMatch = matchBuilder.getIpMatch();
assertNotNull(ipMatch);
assertEquals(ipMatch.getIpProtocol(), Short.valueOf(IPProtocols.TCP.shortValue()));
// Currently ranges arent supported, only the lower port is used
TcpMatch tcpMatch = (TcpMatch) matchBuilder.getLayer4Match();
assertEquals(tcpMatch.getTcpSourcePort().getValue(), Integer.valueOf(TCP_SRC_LOWER_PORT));
assertEquals(tcpMatch.getTcpDestinationPort().getValue(), Integer.valueOf(TCP_DST_LOWER_PORT));
// The layer3 match should be null
assertNull(matchBuilder.getLayer3Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project netvirt by opendaylight.
the class OpenFlow13Provider method createIngressClassifierFilterVxgpeNshFlow.
/*
* Ingress Classifier Filter Vxgpe NSH flow:
* Only allows Non-NSH packets to proceed in the classifier
* Match on ethertype and resubmit to SFC (we don't resubmit to
* dispatcher since it is still not used for tunnel ports)
*/
public Flow createIngressClassifierFilterVxgpeNshFlow(NodeId nodeId) {
MatchBuilder match = new MatchBuilder();
OpenFlow13Utils.addMatchEthNsh(match);
List<Action> actionList = new ArrayList<>();
actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.SFC_TRANSPORT_INGRESS_TABLE, actionList.size()));
InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
String flowIdStr = INGRESS_CLASSIFIER_FILTER_VXGPENSH_FLOW_NAME + nodeId.getValue();
return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE, INGRESS_CLASSIFIER_FILTER_TUN_NSH_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE, INGRESS_CLASSIFIER_FILTER_VXGPENSH_FLOW_NAME, flowIdStr, match, isb).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project netvirt by opendaylight.
the class Ipv6NeighborSolicitationTest method testTransmitNeighborSolicitation.
/**
* Test transmitNeighborSolicitation.
*/
@Test
public void testTransmitNeighborSolicitation() {
doReturn(RpcResultBuilder.status(true).buildFuture()).when(pktProcessService).transmitPacket(any(TransmitPacketInput.class));
BigInteger dpnId = BigInteger.valueOf(1);
String macAddr = "08:00:27:FE:8F:95";
boolean retValue;
Ipv6Address srcIpv6Address = new Ipv6Address("2001:db8::1");
Ipv6Address targetIpv6Address = new Ipv6Address("2001:db8::2");
InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
NodeConnectorRef nodeRef = new NodeConnectorRef(ncId);
retValue = instance.transmitNeighborSolicitation(dpnId, nodeRef, new MacAddress(macAddr), srcIpv6Address, targetIpv6Address);
assertEquals(true, retValue);
verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
byte[] expectedPayload = ipv6TestUtils.buildPacket(// Destination MAC
"33 33 00 00 00 02", // Source MAC
"08 00 27 FE 8F 95", // Ethertype - IPv6
"86 DD", // Version 6, traffic class 0, no flowlabel
"60 00 00 00", // Payload length
"00 20", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 01", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF 00 00 02", // ICMPv6 neighbor advertisement.
"87", // Code
"00", // Checksum (valid)
"5E 94", // Flags
"00 00 00 00", // Target Address
"20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 02", // Type: Source Link-Layer Option
"01", // Option length
"01", // Source Link layer address
"08 00 27 FE 8F 95");
NodeConnectorRef nodeConnectorRef = MDSALUtil.getNodeConnRef(dpnId, "0xfffffffd");
verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload).setNode(new NodeRef(ncId)).setEgress(nodeRef).setIngress(nodeConnectorRef).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testonPacketReceivedNeighborSolicitationWithValidPayload.
@Test
public void testonPacketReceivedNeighborSolicitationWithValidPayload() throws Exception {
VirtualPort intf = Mockito.mock(VirtualPort.class);
when(intf.getNetworkID()).thenReturn(new Uuid("eeec9dba-d831-4ad7-84b9-00d7f65f0555"));
when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
VirtualPort routerIntf = Mockito.mock(VirtualPort.class);
when(ifMgrInstance.getRouterV6InterfaceForNetwork(any())).thenReturn(routerIntf);
List<Ipv6Address> ipv6AddrList = new ArrayList<>();
when(routerIntf.getMacAddress()).thenReturn("08:00:27:FE:8F:95");
Ipv6Address llAddr = Ipv6ServiceUtils.getIpv6LinkLocalAddressFromMac(new MacAddress("08:00:27:FE:8F:95"));
ipv6AddrList.add(llAddr);
when(routerIntf.getIpv6Addresses()).thenReturn(ipv6AddrList);
InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF FE 8F 95", // Source MAC
"08 00 27 D4 10 BB", // IPv6
"86 DD", // Version 6, traffic class 0, no flowlabel
"60 00 00 00", // Payload length
"00 20", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE D4 10 BB", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF FE 8F 95", // ICMPv6 neighbor solicitation
"87", // Code
"00", // Checksum (valid)
"A9 57", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // ICMPv6 Option: Source Link Layer Address
"01", // Length
"01", // Link Layer Address
"08 00 27 D4 10 BB")).setIngress(ncRef).setMatch(matchbuilder.build()).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
byte[] expectedPayload = ipv6TestUtils.buildPacket(// Destination MAC
"08 00 27 D4 10 BB", // Source MAC
"08 00 27 FE 8F 95", // Ethertype - IPv6
"86 DD", // Version 6, traffic class 0, no flowlabel
"60 00 00 00", // Payload length
"00 20", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // Destination IP
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE D4 10 BB", // ICMPv6 neighbor advertisement.
"88", // Code
"00", // Checksum (valid)
"17 D6", // Flags
"E0 00 00 00", // Target Address
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // Type: Target Link-Layer Option
"02", // Option length
"01", // Target Link layer address
"08 00 27 FE 8F 95");
verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload).setNode(new NodeRef(ncId)).setEgress(ncRef).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project openflowplugin by opendaylight.
the class ActionConvertorV13Test method testToMDSalActions2.
/**
* Test {@link ActionConvertor#convert(List, ActionConvertorData)}}.
*/
// @Test
public void testToMDSalActions2() {
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(52);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
List<Action> actions = new ArrayList<>();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder();
SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder();
setMplsTtlBuilder.setMplsTtl((short) 4);
setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlBuilder.build());
actionBuilder.setActionChoice(setMplsTtlCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecMplsTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
pushVlanBuilder.setEthertype(new EtherType(new EtherType(16)));
pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
actionBuilder.setActionChoice(pushVlanCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder();
pushMplsBuilder.setEthertype(new EtherType(new EtherType(17)));
pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
actionBuilder.setActionChoice(pushMplsCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
popMplsBuilder.setEthertype(new EtherType(new EtherType(18)));
popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
actionBuilder.setActionChoice(popMplsCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
setQueueBuilder.setQueueId(1234L);
setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
actionBuilder.setActionChoice(setQueueCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder();
GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
groupActionBuilder.setGroupId(555L);
groupCaseBuilder.setGroupAction(groupActionBuilder.build());
actionBuilder.setActionChoice(groupCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
nwTtlBuilder.setNwTtl((short) 8);
nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
actionBuilder.setActionChoice(nwTtlCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setOxmMatchField(InPort.class);
matchBuilder.setHasMask(false);
InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder();
InPortBuilder inPortBuilder = new InPortBuilder();
inPortBuilder.setPortNumber(new PortNumber(1L));
inPortCaseBuilder.setInPort(inPortBuilder.build());
matchBuilder.setMatchEntryValue(inPortCaseBuilder.build());
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
actionBuilder.setActionChoice(setFieldCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder();
pushPbbBuilder.setEthertype(new EtherType(new EtherType(19)));
pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build());
actionBuilder.setActionChoice(pushPbbCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
// Add some unsupported actions and check if they are missing from results
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new SetNwDstCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
actions.add(actionBuilder.build());
ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_3);
data.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> mdSalActionsOptional = convertorManager.convert(actions, data);
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());
Assert.assertEquals("Wrong number of output actions", 16, mdSalActions.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());
OutputActionCase output = (OutputActionCase) action;
Assert.assertEquals("Wrong output port", "42", output.getOutputAction().getOutputNodeConnector().getValue());
Assert.assertEquals("Wrong max length", 52, output.getOutputAction().getMaxLength().intValue());
action = mdSalActions.get(1);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.CopyTtlOutCase", action.getImplementedInterface().getName());
action = mdSalActions.get(2);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.CopyTtlInCase", action.getImplementedInterface().getName());
action = mdSalActions.get(3);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetMplsTtlActionCase", action.getImplementedInterface().getName());
SetMplsTtlActionCase setMplsTtl = (SetMplsTtlActionCase) action;
Assert.assertEquals("Wrong mpls ttl", 4, setMplsTtl.getSetMplsTtlAction().getMplsTtl().intValue());
action = mdSalActions.get(4);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.DecMplsTtlCase", action.getImplementedInterface().getName());
action = mdSalActions.get(5);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushVlanActionCase", action.getImplementedInterface().getName());
PushVlanActionCase pushVlan = (PushVlanActionCase) action;
Assert.assertEquals("Wrong ethertype", 16, pushVlan.getPushVlanAction().getEthernetType().intValue());
action = mdSalActions.get(6);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopVlanActionCase", action.getImplementedInterface().getName());
action = mdSalActions.get(7);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushMplsActionCase", action.getImplementedInterface().getName());
PushMplsActionCase pushMpls = (PushMplsActionCase) action;
Assert.assertEquals("Wrong ethertype", 17, pushMpls.getPushMplsAction().getEthernetType().intValue());
action = mdSalActions.get(8);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopMplsActionCase", action.getImplementedInterface().getName());
PopMplsActionCase popMpls = (PopMplsActionCase) action;
Assert.assertEquals("Wrong ethertype", 18, popMpls.getPopMplsAction().getEthernetType().intValue());
action = mdSalActions.get(9);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetQueueActionCase", action.getImplementedInterface().getName());
SetQueueActionCase setQueue = (SetQueueActionCase) action;
Assert.assertEquals("Wrong queue-id", 1234, setQueue.getSetQueueAction().getQueueId().intValue());
action = mdSalActions.get(10);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.GroupActionCase", action.getImplementedInterface().getName());
GroupActionCase groupAction = (GroupActionCase) action;
Assert.assertEquals("Wrong group-id", 555, groupAction.getGroupAction().getGroupId().intValue());
action = mdSalActions.get(11);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetNwTtlActionCase", action.getImplementedInterface().getName());
SetNwTtlActionCase setNwTtl = (SetNwTtlActionCase) action;
Assert.assertEquals("Wrong nw ttl", 8, setNwTtl.getSetNwTtlAction().getNwTtl().intValue());
action = mdSalActions.get(12);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.DecNwTtlCase", action.getImplementedInterface().getName());
action = mdSalActions.get(13);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetFieldCase", action.getImplementedInterface().getName());
SetFieldCase setField = (SetFieldCase) action;
Assert.assertEquals("Wrong in port", "openflow:null:1", setField.getSetField().getInPort().getValue());
action = mdSalActions.get(14);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushPbbActionCase", action.getImplementedInterface().getName());
PushPbbActionCase pushPbb = (PushPbbActionCase) action;
Assert.assertEquals("Wrong ethertype", 19, pushPbb.getPushPbbAction().getEthernetType().intValue());
action = mdSalActions.get(15);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopPbbActionCase", action.getImplementedInterface().getName());
}
Aggregations