Search in sources :

Example 11 with OFFactoryVer13

use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.

the class SwitchTrackingServiceTest method prepareAliveSwitchEvent.

private Capture<Message> prepareAliveSwitchEvent(SpeakerSwitchView switchView) throws Exception {
    IOFSwitch sw = createMock(IOFSwitch.class);
    expect(sw.getId()).andReturn(dpId).anyTimes();
    expect(sw.getInetAddress()).andReturn(new InetSocketAddress("127.0.1.1", 32768)).times(2);
    OFConnection connect = createMock(OFConnection.class);
    expect(connect.getRemoteInetAddress()).andReturn(new InetSocketAddress("127.0.1.254", 6653)).times(2);
    expect(sw.getConnectionByCategory(eq(LogicalOFMessageCategory.MAIN))).andReturn(connect).times(2);
    SwitchDescription description = createMock(SwitchDescription.class);
    expect(description.getManufacturerDescription()).andReturn("(mock) getManufacturerDescription()").times(2);
    expect(description.getHardwareDescription()).andReturn("(mock) getHardwareDescription()");
    expect(description.getSoftwareDescription()).andReturn("(mock) getSoftwareDescription()").times(2);
    expect(description.getSerialNumber()).andReturn("(mock) getSerialNumber()");
    expect(description.getDatapathDescription()).andReturn("(mock) getDatapathDescription()");
    expect(sw.getSwitchDescription()).andReturn(description).times(3);
    expect(sw.getOFFactory()).andStubReturn(new OFFactoryVer13());
    expect(switchManager.lookupSwitch(eq(dpId))).andReturn(sw);
    List<OFPortDesc> physicalPorts = new ArrayList<>(switchView.getPorts().size());
    int idx = 1;
    for (SpeakerSwitchPortView port : switchView.getPorts()) {
        physicalPorts.add(makePhysicalPortMock(idx++, port.getState() == SpeakerSwitchPortView.State.UP));
    }
    expect(switchManager.getPhysicalPorts(sw)).andReturn(physicalPorts);
    expect(featureDetector.detectSwitch(sw)).andReturn(ImmutableSet.of(SwitchFeature.METERS));
    return prepareSwitchEventCommon(dpId);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFConnection(net.floodlightcontroller.core.internal.OFConnection) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) SpeakerSwitchDescription(org.openkilda.messaging.model.SpeakerSwitchDescription) SwitchDescription(net.floodlightcontroller.core.SwitchDescription)

Example 12 with OFFactoryVer13

use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.

the class OfMatchConverterTest method testConvertToRuleManagerMatchExact.

@Test
public void testConvertToRuleManagerMatchExact() {
    OFFactoryVer13 factory = new OFFactoryVer13();
    Match match = factory.buildMatch().setExact(MatchField.ETH_TYPE, EthType.IPv4).setExact(MatchField.ETH_SRC, MacAddress.of(1)).setExact(MatchField.ETH_DST, MacAddress.of(2)).setExact(MatchField.IP_PROTO, IpProtocol.of((short) 17)).setExact(MatchField.UDP_SRC, TransportPort.of(11)).setExact(MatchField.UDP_DST, TransportPort.of(22)).setExact(MatchField.METADATA, OFMetadata.of(U64.of(333))).setExact(MatchField.IN_PORT, OFPort.of(12)).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(444)).setExact(MatchField.TUNNEL_ID, U64.of(555)).setExact(MatchField.KILDA_VXLAN_VNI, U32.of(666)).build();
    Set<FieldMatch> expectedMatches = new HashSet<>();
    expectedMatches.add(FieldMatch.builder().value(2048).field(Field.ETH_TYPE).build());
    expectedMatches.add(FieldMatch.builder().value(1).field(Field.ETH_SRC).build());
    expectedMatches.add(FieldMatch.builder().value(2).field(Field.ETH_DST).build());
    expectedMatches.add(FieldMatch.builder().value(17).field(Field.IP_PROTO).build());
    expectedMatches.add(FieldMatch.builder().value(11).field(Field.UDP_SRC).build());
    expectedMatches.add(FieldMatch.builder().value(22).field(Field.UDP_DST).build());
    expectedMatches.add(FieldMatch.builder().value(333).field(Field.METADATA).build());
    expectedMatches.add(FieldMatch.builder().value(12).field(Field.IN_PORT).build());
    expectedMatches.add(FieldMatch.builder().value(444).field(Field.VLAN_VID).build());
    expectedMatches.add(FieldMatch.builder().value(555).field(Field.NOVIFLOW_TUNNEL_ID).build());
    expectedMatches.add(FieldMatch.builder().value(666).field(Field.OVS_VXLAN_VNI).build());
    Set<FieldMatch> fieldMatches = OfMatchConverter.INSTANCE.convertToRuleManagerMatch(match);
    assertEquals(expectedMatches, fieldMatches);
}
Also used : OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with OFFactoryVer13

use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.

the class OfMatchConverterTest method testConvertToRuleManagerMatchMasked.

@Test
public void testConvertToRuleManagerMatchMasked() {
    OFFactoryVer13 factory = new OFFactoryVer13();
    Match match = factory.buildMatch().setMasked(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv4).setMasked(MatchField.ETH_SRC, MacAddress.of(1), MacAddress.of(1)).setMasked(MatchField.ETH_DST, MacAddress.of(2), MacAddress.of(2)).setMasked(MatchField.IP_PROTO, IpProtocol.of((short) 17), IpProtocol.of((short) 17)).setMasked(MatchField.UDP_SRC, TransportPort.of(11), TransportPort.of(11)).setMasked(MatchField.UDP_DST, TransportPort.of(22), TransportPort.of(22)).setMasked(MatchField.METADATA, OFMetadata.of(U64.of(333)), OFMetadata.of(U64.of(333))).setMasked(MatchField.IN_PORT, OFPort.of(12), OFPort.of(12)).setMasked(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(444), OFVlanVidMatch.ofVlan(444)).setMasked(MatchField.TUNNEL_ID, U64.of(555), U64.of(555)).build();
    Set<FieldMatch> expectedMatches = new HashSet<>();
    expectedMatches.add(FieldMatch.builder().value(2048).mask(2048L).field(Field.ETH_TYPE).build());
    expectedMatches.add(FieldMatch.builder().value(1).mask(1L).field(Field.ETH_SRC).build());
    expectedMatches.add(FieldMatch.builder().value(2).mask(2L).field(Field.ETH_DST).build());
    expectedMatches.add(FieldMatch.builder().value(17).mask(17L).field(Field.IP_PROTO).build());
    expectedMatches.add(FieldMatch.builder().value(11).mask(11L).field(Field.UDP_SRC).build());
    expectedMatches.add(FieldMatch.builder().value(22).mask(22L).field(Field.UDP_DST).build());
    expectedMatches.add(FieldMatch.builder().value(333).mask(333L).field(Field.METADATA).build());
    expectedMatches.add(FieldMatch.builder().value(12).mask(12L).field(Field.IN_PORT).build());
    expectedMatches.add(FieldMatch.builder().value(444).mask(444L).field(Field.VLAN_VID).build());
    expectedMatches.add(FieldMatch.builder().value(555).mask(555L).field(Field.NOVIFLOW_TUNNEL_ID).build());
    Set<FieldMatch> fieldMatches = OfMatchConverter.INSTANCE.convertToRuleManagerMatch(match);
    assertEquals(expectedMatches, fieldMatches);
}
Also used : OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 14 with OFFactoryVer13

use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.

the class OfInstructionsConverterTest method convertInstructionsTest.

@Test
public void convertInstructionsTest() {
    OFFactory factory = new OFFactoryVer13();
    Instructions instructions = Instructions.builder().goToTable(OfTable.PRE_INGRESS).goToMeter(new MeterId(2)).writeMetadata(new OfMetadata(123, 234)).applyActions(buildActions()).build();
    List<OFInstruction> actual = OfInstructionsConverter.INSTANCE.convertInstructions(instructions, factory);
    assertEquals(4, actual.size());
    assertTrue(actual.contains(factory.instructions().gotoTable(TableId.of(1))));
    assertTrue(actual.contains(factory.instructions().buildMeter().setMeterId(2).build()));
    assertTrue(actual.contains(factory.instructions().buildWriteMetadata().setMetadata(U64.of(123)).setMetadataMask(U64.of(234)).build()));
    OFInstructionApplyActions applyActionsInstruction = (OFInstructionApplyActions) actual.get(3);
    assertEquals(12, applyActionsInstruction.getActions().size());
    List<OFAction> expectedActions = buildActions(factory);
    assertTrue(applyActionsInstruction.getActions().containsAll(expectedActions));
}
Also used : OfMetadata(org.openkilda.rulemanager.OfMetadata) OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) Instructions(org.openkilda.rulemanager.Instructions) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 15 with OFFactoryVer13

use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.

the class OfTableStatsMapperTest method shouldConvertSuccessfully.

@Test
public void shouldConvertSuccessfully() {
    OFFactoryVer13 ofFactoryVer13 = new OFFactoryVer13();
    OFTableStatsEntry entry = ofFactoryVer13.buildTableStatsEntry().setTableId(TableId.of(11)).setActiveCount(10).setMatchedCount(U64.of(100001L)).setLookupCount(U64.of(100002L)).build();
    TableStatsEntry result = OfTableStatsMapper.INSTANCE.toTableStatsEntry(entry);
    assertEquals(result.getTableId(), entry.getTableId().getValue());
    assertEquals(result.getActiveEntries(), entry.getActiveCount());
    assertEquals(result.getLookupCount(), entry.getLookupCount().getValue());
    assertEquals(result.getMatchedCount(), entry.getMatchedCount().getValue());
}
Also used : TableStatsEntry(org.openkilda.messaging.info.stats.TableStatsEntry) OFTableStatsEntry(org.projectfloodlight.openflow.protocol.OFTableStatsEntry) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFTableStatsEntry(org.projectfloodlight.openflow.protocol.OFTableStatsEntry) Test(org.junit.Test)

Aggregations

OFFactoryVer13 (org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13)22 Test (org.junit.Test)16 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 Match (org.projectfloodlight.openflow.protocol.match.Match)5 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)5 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)4 OFSwitch (net.floodlightcontroller.core.internal.OFSwitch)4 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)4 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)4 DatapathId (org.projectfloodlight.openflow.types.DatapathId)4 OFConnection (net.floodlightcontroller.core.internal.OFConnection)3 GroupId (org.openkilda.model.GroupId)3 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)3 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)3 U64 (org.projectfloodlight.openflow.types.U64)3 InetSocketAddress (java.net.InetSocketAddress)2 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)2 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)2