Search in sources :

Example 16 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project bgpcep by opendaylight.

the class IPv6RIBSupport method extractPrefixes.

private List<Ipv6Prefixes> extractPrefixes(final Collection<MapEntryNode> routes) {
    final List<Ipv6Prefixes> prefs = new ArrayList<>(routes.size());
    for (final MapEntryNode route : routes) {
        final String prefix = (String) NormalizedNodes.findNode(route, routePrefixIdentifier()).get().getValue();
        prefs.add(new Ipv6PrefixesBuilder().setPathId(PathIdUtil.buildPathId(route, routePathIdNid())).setPrefix(new Ipv6Prefix(prefix)).build());
    }
    return prefs;
}
Also used : Ipv6PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv6.prefixes.destination.ipv6.Ipv6PrefixesBuilder) ArrayList(java.util.ArrayList) Ipv6Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv6.prefixes.destination.ipv6.Ipv6Prefixes) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Example 17 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project bgpcep by opendaylight.

the class RROIpv6PrefixSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
    final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
    final IpPrefix prefix = specObj.getIpPrefix();
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
    flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory.");
    writeIpv6Prefix(prefix.getIpv6Prefix(), body);
    flags.toByteBuf(body);
    RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Also used : IpPrefixSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCase) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 18 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project bgpcep by opendaylight.

the class XROIpv6PrefixSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
    final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
    final IpPrefix prefix = specObj.getIpPrefix();
    final ByteBuf body = Unpooled.buffer(CONTENT6_LENGTH);
    Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory.");
    writeIpv6Prefix(prefix.getIpv6Prefix(), body);
    Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
    writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
    XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
Also used : IpPrefixSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) ByteBuf(io.netty.buffer.ByteBuf)

Example 19 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project bgpcep by opendaylight.

the class PrefixAttributesParser method parseAttribute.

private static void parseAttribute(final int key, final ByteBuf value, final ProtocolId protocolId, final PrefixAttributesBuilder builder, final List<RouteTag> routeTags, final List<ExtendedRouteTag> exRouteTags) {
    switch(key) {
        case IGP_FLAGS:
            parseIgpFags(builder, value);
            break;
        case ROUTE_TAG:
            parseRouteTags(routeTags, value);
            break;
        case EXTENDED_ROUTE_TAG:
            parseExtendedRouteTags(exRouteTags, value);
            break;
        case PREFIX_METRIC:
            final IgpMetric metric = new IgpMetric(value.readUnsignedInt());
            builder.setPrefixMetric(metric);
            LOG.debug("Parsed Metric: {}", metric);
            break;
        case FORWARDING_ADDRESS:
            final IpAddress fwdAddress = parseForwardingAddress(value);
            builder.setOspfForwardingAddress(fwdAddress);
            LOG.debug("Parsed FWD Address: {}", fwdAddress);
            break;
        case PREFIX_OPAQUE:
            if (LOG.isDebugEnabled()) {
                LOG.debug("Parsed Opaque value: {}, not preserving it", ByteBufUtil.hexDump(value));
            }
            break;
        case PREFIX_SID:
            final SrPrefix prefix = SrPrefixAttributesParser.parseSrPrefix(value, protocolId);
            builder.setSrPrefix(prefix);
            LOG.debug("Parsed SR Prefix: {}", prefix);
            break;
        case IPV6_PREFIX_SID:
            final Ipv6SrPrefix ipv6Prefix = Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(value);
            builder.setIpv6SrPrefix(ipv6Prefix);
            LOG.debug("Parsed Ipv6 SR Prefix: {}", ipv6Prefix);
            break;
        case RANGE:
            final SrRange range = RangeTlvParser.parseSrRange(value, protocolId);
            builder.setSrRange(range);
            LOG.debug("Parsed SR Range: {}", range);
            break;
        case BINDING_SID:
            parseBindingSid(builder, value, protocolId);
            break;
        default:
            LOG.warn("TLV {} is not a valid prefix attribute, ignoring it", key);
    }
}
Also used : SrPrefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.SrPrefix) Ipv6SrPrefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefix) SrRange(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.SrRange) IgpMetric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IgpMetric) Ipv6SrPrefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefix) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 20 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project bgpcep by opendaylight.

the class ByteBufWriteUtilTest method testWriteIpv6Prefix.

@Test
public void testWriteIpv6Prefix() {
    final byte[] result = { 0x20, (byte) 0x01, 0x0d, (byte) 0xb8, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40 };
    final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.IPV6_PREFIX_BYTE_LENGTH);
    writeIpv6Prefix(new Ipv6Prefix("2001:db8:1:2::/64"), output);
    assertArrayEquals(result, output.array());
    output.clear();
    final byte[] zeroResult = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    writeIpv6Prefix(null, output);
    assertArrayEquals(zeroResult, output.array());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) ByteBufWriteUtil.writeIpv6Prefix(org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Prefix) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Aggregations

Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)63 Test (org.junit.Test)42 ArrayList (java.util.ArrayList)20 ByteBuf (io.netty.buffer.ByteBuf)16 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)13 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)13 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)12 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)11 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)10 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)8 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)8 InetAddress (java.net.InetAddress)6 AceIpv6Builder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6Builder)6 SourceIpv6PrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.group.ipv6.flowspec.flowspec.type.SourceIpv6PrefixCaseBuilder)6 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 Attributes1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder)6 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)6 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder)6 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)6 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)5