use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project bgpcep by opendaylight.
the class PCCPeerProposal method setPeerSpecificProposal.
@Override
public void setPeerSpecificProposal(@Nonnull final InetSocketAddress address, @Nonnull final TlvsBuilder openBuilder) {
requireNonNull(address);
final LspDbVersion lspDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(this.dbVersion).build();
openBuilder.addAugmentation(Tlvs3.class, new Tlvs3Builder().setLspDbVersion(lspDbVersion).build());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project bgpcep by opendaylight.
the class PCCTunnelBuilder method createTunnels.
static Map<PlspId, PCCTunnel> createTunnels(final String address, final int lsps) {
final Map<PlspId, PCCTunnel> tunnels = new HashMap<>();
for (int i = 1; i <= lsps; i++) {
final PCCTunnel tunnel = new PCCTunnel(MsgBuilderUtil.getDefaultPathName(address, i), PCC_DELEGATION, LspType.PCC_LSP, createPath(Lists.newArrayList(DEFAULT_ENDPOINT_HOP)));
tunnels.put(new PlspId((long) i), tunnel);
}
return tunnels;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.
the class SalToOfSetNwSrcActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
final ActionBuilder builder = new ActionBuilder();
final Address address = source.getSetNwSrcAction().getAddress();
if (address instanceof Ipv4) {
Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(result);
Integer prefix = IpConversionUtil.extractPrefix(result);
ipv4SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchEntryBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
builder.setActionChoice(setFieldCaseBuilder.build());
} else if (address instanceof Ipv6) {
Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
ipv6SrcBuilder.setIpv6Address(result);
Integer prefix = IpConversionUtil.extractPrefix(result);
ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(matchEntryBuilder.build());
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
setFieldActionBuilder.setMatchEntry(matchEntriesList);
setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
builder.setActionChoice(setFieldCaseBuilder.build());
} else {
throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
}
return Optional.of(builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.
the class OfToSalIpv4SrcCase method process.
@Override
public Optional<MatchBuilder> process(@Nonnull Ipv4SrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final Ipv4MatchBuilder ipv4MatchBuilder = data.getIpv4MatchBuilder();
final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = data.getIpv4MatchArbitraryBitMaskBuilder();
Ipv4Src ipv4Address = source.getIpv4Src();
if (ipv4Address != null) {
byte[] mask = ipv4Address.getMask();
if (mask != null && IpConversionUtil.isArbitraryBitMask(mask)) {
// Needs to convert ipv4dst to ipv4MatchArbitrary.
if (ipv4MatchBuilder.getIpv4Destination() != null) {
Ipv4Prefix ipv4PrefixDestinationAddress = ipv4MatchBuilder.getIpv4Destination();
Ipv4Address ipv4DstAddress = IpConversionUtil.extractIpv4Address(ipv4PrefixDestinationAddress);
DottedQuad dstDottedQuadMask = IpConversionUtil.extractIpv4AddressMask(ipv4PrefixDestinationAddress);
setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, dstDottedQuadMask, ipv4DstAddress.getValue());
}
DottedQuad srcDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, srcDottedQuadMask, stringIpv4SrcAddress);
matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
} else if (ipv4MatchArbitraryBitMaskBuilder.getIpv4DestinationAddressNoMask() != null) {
/*
Case where destination is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
source which of type ipv4Match needs to be converted to ipv4MatchArbitraryBitMask.
We convert 36.36.36.0/24 to 36.36.0/255.255.255.0
expected output example:-
<ipv4-destination>36.36.36.0/24</ipv4-destination>
<ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
<ipv4-source-arbitrary-bitmask>255.0.255.0</ipv4-source-arbitrary-bitmask>
after conversion output example:-
<ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
<ipv4-destination-arbitrary-bitmask>255.255.255.0</ipv4-destination-arbitrary-bitmask>
<ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
<ipv4-source-arbitrary-bitmask>255.0.255.0</ipv4-source-arbitrary-bitmask>
*/
DottedQuad srcDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, srcDottedQuadMask, stringIpv4SrcAddress);
matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
} else {
String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
setIpv4MatchBuilderFields(ipv4MatchBuilder, mask, stringIpv4SrcAddress);
matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
}
}
return Optional.of(matchBuilder);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.
the class SalToOfSetNwDstActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
final ActionBuilder builder = new ActionBuilder();
final Address address = source.getSetNwDstAction().getAddress();
if (address instanceof Ipv4) {
Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
ipv4DstBuilder.setIpv4Address(result);
Integer prefix = IpConversionUtil.extractPrefix(result);
ipv4DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(matchEntryBuilder.build());
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
setFieldActionBuilder.setMatchEntry(matchEntriesList);
setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
builder.setActionChoice(setFieldCaseBuilder.build());
} else if (address instanceof Ipv6) {
Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
ipv6DstBuilder.setIpv6Address(result);
Integer prefix = IpConversionUtil.extractPrefix(result);
ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(matchEntryBuilder.build());
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
setFieldActionBuilder.setMatchEntry(matchEntriesList);
setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
builder.setActionChoice(setFieldCaseBuilder.build());
} else {
throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
}
return Optional.of(builder.build());
}
Aggregations