@Override public ExtensionSelector mapOxm(OFOxm<?> oxm) { if (oxm.getMatchField() == MatchField.NSP) { OFOxmNsp oxmField = (OFOxmNsp) oxm; return new NiciraMatchNshSpi(NshServicePathId.of(oxmField.getValue().getRaw())); } if (oxm.getMatchField() == MatchField.NSI) { OFOxmNsi oxmField = (OFOxmNsi) oxm; return new NiciraMatchNshSi(NshServiceIndex.of(oxmField.getValue().getRaw())); } if (oxm.getMatchField() == MatchField.ENCAP_ETH_TYPE) { OFOxmEncapEthType oxmField = (OFOxmEncapEthType) oxm; return new NiciraMatchEncapEthType(oxmField.getValue().getRaw()); } return null; }
/** * Send hello message to the switch using the handshake transactions ids. * @throws IOException */ private void sendHandshakeHelloMessage() throws IOException { // The OF protocol requires us to start things off by sending the highest // version of the protocol supported. // bitmap represents OF1.0 (ofp_version=0x01) and OF1.3 (ofp_version=0x04) // see Sec. 7.5.1 of the OF1.3.4 spec U32 bitmap = U32.ofRaw(0x00000012); OFHelloElem hem = factory13.buildHelloElemVersionbitmap() .setBitmaps(Collections.singletonList(bitmap)) .build(); OFMessage.Builder mb = factory13.buildHello() .setXid(this.handshakeTransactionIds--) .setElements(Collections.singletonList(hem)); log.info("Sending OF_13 Hello to {}", channel.getRemoteAddress()); channel.write(Collections.singletonList(mb.build())); }
@Override public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) { ExtensionSelectorType type = extensionSelector.type(); if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) { NiciraMatchNshSpi niciraNshSpi = (NiciraMatchNshSpi) extensionSelector; return factory.oxms().nsp(U32.of(niciraNshSpi.nshSpi().servicePathId())); } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) { NiciraMatchNshSi niciraNshSi = (NiciraMatchNshSi) extensionSelector; return factory.oxms().nsi(U8.of(niciraNshSi.nshSi().serviceIndex())); } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_ENCAP_ETH_TYPE.type())) { NiciraMatchEncapEthType niciraEncapEthType = (NiciraMatchEncapEthType) extensionSelector; return factory.oxms().encapEthType(U16.of(niciraEncapEthType.encapEthType())); } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) { // TODO } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) { // TODO } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) { // TODO } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) { // TODO } return null; }
@SuppressWarnings("unchecked") OFOxm<U32> labelId = (OFOxm<U32>) oxm; builder.setMpls(MplsLabel.mplsLabel((int) labelId.getValue().getValue())); break; case MPLS_BOS:
return factory.actions().setField(factory.oxms().nsp(U32.of(niciraNshSpi.nshSpi().servicePathId()))); return factory.actions().setField(factory.oxms().nshC1(U32.of(niciraNshch.nshCh().nshContextHeader()))); return factory.actions().setField(factory.oxms().nshC2(U32.of(niciraNshch.nshCh().nshContextHeader()))); return factory.actions().setField(factory.oxms().nshC3(U32.of(niciraNshch.nshCh().nshContextHeader()))); return factory.actions().setField(factory.oxms().nshC4(U32.of(niciraNshch.nshCh().nshContextHeader())));
case MPLS_LABEL: builder.matchMplsLabel(MplsLabel.mplsLabel((int) match.get(MatchField.MPLS_LABEL) .getValue())); break; case MPLS_BOS:
L2ModificationInstruction.ModMplsLabelInstruction mplsLabel = (L2ModificationInstruction.ModMplsLabelInstruction) l2m; oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.label().toInt())); break; case MPLS_BOS:
return new NiciraSetNshSpi(NshServicePathId.of((nsp.getValue().getRaw()))); case NSI: OFOxmNsi nsi = (OFOxmNsi) oxm; case NSH_C1: OFOxmNshC1 nshC1 = (OFOxmNshC1) oxm; return new NiciraSetNshContextHeader(NshContextHeader.of((nshC1.getValue().getRaw())), ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1 .type()); case NSH_C2: OFOxmNshC2 nshC2 = (OFOxmNshC2) oxm; return new NiciraSetNshContextHeader(NshContextHeader.of((nshC2.getValue().getRaw())), ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2 .type()); case NSH_C3: OFOxmNshC3 nshC3 = (OFOxmNshC3) oxm; return new NiciraSetNshContextHeader(NshContextHeader.of((nshC3.getValue().getRaw())), ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3 .type()); case NSH_C4: OFOxmNshC4 nshC4 = (OFOxmNshC4) oxm; return new NiciraSetNshContextHeader(NshContextHeader.of((nshC4.getValue().getRaw())), ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4 .type());
ModMplsLabelInstruction mplsLabel = (ModMplsLabelInstruction) l2m; oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.label().toInt())); break; case MPLS_BOS:
case MPLS_LABEL: MplsCriterion mp = (MplsCriterion) c; mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label().toInt())); break; case IPV6_EXTHDR: