use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method wireUp.
// for tunnels from OVS
private boolean wireUp(BigInteger dpnId, String portname, Integer vlanId, IpAddress srcIp, Boolean remoteIpFlow, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, WriteTransaction transaction) {
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId);
String tunTypeStr = tunType.getName();
String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf, new String(srcIp.getValue()), new String(dstIp.getValue()), tunTypeStr);
LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp, dstIp, gwyIpAddress);
Interface extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp, gwyIpAddress, vlanId, false, monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow, null);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build();
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf);
transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, extTunnelIf, true);
ItmUtils.ITM_CACHE.addInterface(extTunnelIf);
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString(), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(dpnId.toString(), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName);
transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
ItmUtils.ITM_CACHE.addExternalTunnel(tnl);
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project bgpcep by opendaylight.
the class PCEPXROSubobjectParserTest method testXROIp4PrefixSubobject.
@Test
public void testXROIp4PrefixSubobject() throws PCEPDeserializerException {
final XROIpv4PrefixSubobjectParser parser = new XROIpv4PrefixSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setMandatory(false);
subs.setAttribute(Attribute.Interface);
subs.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/22"))).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(ip4PrefixBytes, 2)), false));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(ip4PrefixBytes, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project bgpcep by opendaylight.
the class LinkstateAttributeParserTest method testPositiveV4Prefixes.
@Test
public void testPositiveV4Prefixes() throws BGPParsingException, BGPDocumentedException {
final AttributesBuilder builder = createUnreachBuilder(new PrefixCaseBuilder().setPrefixDescriptors(new PrefixDescriptorsBuilder().setIpReachabilityInformation(new IpPrefix(new Ipv4Prefix("127.0.0.1/32"))).build()).build());
this.parser.parseAttribute(Unpooled.copiedBuffer(P4_ATTR), builder, null);
final Attributes1 attrs = builder.augmentation(Attributes1.class);
final PrefixAttributes ls = ((PrefixAttributesCase) attrs.getLinkStateAttribute()).getPrefixAttributes();
assertNotNull(ls);
assertNotNull(ls.getSrRange());
assertFalse(ls.getSrRange().getInterArea());
assertEquals(1, ls.getSrRange().getSubTlvs().size());
assertNotNull(ls.getSrBindingSidLabels());
final IgpBits ispBits = ls.getIgpBits();
assertTrue(ispBits.getUpDown().getUpDown());
assertTrue(ispBits.getIsIsUpDown());
assertTrue(ispBits.getOspfNoUnicast());
assertTrue(ispBits.getOspfLocalAddress());
assertTrue(ispBits.getOspfPropagateNssa());
assertEquals(2, ls.getRouteTags().size());
assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }, ls.getRouteTags().get(0).getValue());
assertEquals(1, ls.getExtendedTags().size());
assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x10, (byte) 0x30, (byte) 0x50, (byte) 0x70 }, ls.getExtendedTags().get(0).getValue());
assertEquals(10, ls.getPrefixMetric().getValue().intValue());
assertEquals("10.25.2.27", ls.getOspfForwardingAddress().getIpv4AddressNoZone().getValue());
// serialization
final ByteBuf buff = Unpooled.buffer();
this.parser.serializeAttribute(builder.build(), buff);
buff.skipBytes(3);
// there is unresolved TLV at the end, that needs to be cut off
assertArrayEquals(P4_ATTR, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project bgpcep by opendaylight.
the class AbstractPrefixNlriParser method parsePrefixDescriptor.
private static PrefixDescriptors parsePrefixDescriptor(final ByteBuf buffer) {
final Map<QName, Object> tlvs = SimpleNlriTypeRegistry.getInstance().parseSubTlvs(buffer);
final PrefixDescriptorsBuilder builder = new PrefixDescriptorsBuilder();
builder.setMultiTopologyId((TopologyIdentifier) tlvs.get(MultiTopoIdTlvParser.MULTI_TOPOLOGY_ID_QNAME));
builder.setOspfRouteType((OspfRouteType) tlvs.get(OspfRouteTlvParser.OSPF_ROUTE_TYPE_QNAME));
builder.setIpReachabilityInformation((IpPrefix) tlvs.get(ReachTlvParser.IP_REACHABILITY_QNAME));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project bgpcep by opendaylight.
the class L3vpnMcastNlriSerializer method extractDest.
static List<L3vpnMcastDestination> extractDest(final ByteBuf nlri, final boolean addPath) {
List<L3vpnMcastDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final L3vpnMcastDestinationBuilder builder = new L3vpnMcastDestinationBuilder();
if (addPath) {
builder.setPathId(PathIdUtil.readPathId(nlri));
}
final int length = nlri.readUnsignedByte();
final int initialLength = nlri.readableBytes();
builder.setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(nlri));
if (length == Ipv6Util.IPV6_BITS_LENGTH) {
builder.setPrefix(new IpPrefix(Ipv6Util.prefixForByteBuf(nlri)));
} else {
builder.setPrefix(new IpPrefix(Ipv4Util.prefixForByteBuf(nlri)));
}
dests.add(builder.build());
int readed = initialLength - nlri.readableBytes();
while (readed % 8 != 0) {
nlri.readByte();
readed = initialLength - nlri.readableBytes();
}
}
return dests;
}
Aggregations