• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IpPrefix类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix的典型用法代码示例。如果您正苦于以下问题:Java IpPrefix类的具体用法?Java IpPrefix怎么用?Java IpPrefix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IpPrefix类属于org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715包,在下文中一共展示了IpPrefix类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildArpIpMatches

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
/**
 * Builds the arp ip matches.
 * @param ipPrefixOrAddress the ip prefix or address
 * @return the MatchInfoBase list
 */
public static List<MatchInfoBase> buildArpIpMatches(IpPrefixOrAddress ipPrefixOrAddress) {
    List<MatchInfoBase> flowMatches = new ArrayList<>();
    IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
    if (ipPrefix != null) {
        Ipv4Prefix ipv4Prefix = ipPrefix.getIpv4Prefix();
        if (ipv4Prefix != null && !ipv4Prefix.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
            flowMatches.add(new MatchArpSpa(ipv4Prefix));
        }
    } else {
        IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
        if (ipAddress != null && ipAddress.getIpv4Address() != null) {
            flowMatches.add(new MatchArpSpa(ipAddress.getIpv4Address().getValue(), "32"));
        }
    }
    return flowMatches;
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:22,代码来源:AclServiceUtils.java


示例2: createGateway

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
/**
 * Create a gateway for a logical swtich on a given router.
 * @param fId - fabric identifier.
 * @param lrId - logical router identifier.
 * @param lswId - logical switch identifier.
 * @param gatewayIpAddr - the gateway Ip address
 * @param ipPrefix - network prefix.
 * @return the mac address of the gateway
 */
public MacAddress createGateway(NodeId fId, NodeId lrId, NodeId lswId, IpAddress gatewayIpAddr,
        IpPrefix ipPrefix) {
    CreateGatewayInputBuilder inputBuilder = new CreateGatewayInputBuilder();
    FabricId fabricId = new FabricId(fId);
    inputBuilder.setFabricId(fabricId);
    inputBuilder.setLogicalRouter(new NodeId(lrId));
    inputBuilder.setLogicalSwitch(new NodeId(lswId));
    inputBuilder.setIpAddress(new IpAddress(gatewayIpAddr));
    inputBuilder.setNetwork(new IpPrefix(ipPrefix));

    Future<RpcResult<CreateGatewayOutput>> result = this.fabServiceService.createGateway(inputBuilder.build());
    try {
        RpcResult<CreateGatewayOutput> output = result.get();
        if (output.isSuccessful()) {
            LOG.debug("FABMGR: createLrLswGateway: createGateway RPC success");
            CreateGatewayOutput o = output.getResult();
            return o.getPortLayer().getLayer3Info().getMac();
        }
    } catch (Exception e) {
        LOG.error("FABMGR: ERROR: createLrLswGateway: createGateway RPC failed.", e);
    }

    return null;
}
 
开发者ID:opendaylight,项目名称:faas,代码行数:34,代码来源:VContainerNetNodeServiceProvider.java


示例3: createLrLswGateway

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
/**
 * Create a gateway for a logical swtich on a given router.
 * @param fId - fabric identifier.
 * @param lrId - logical router identifier.
 * @param lswId - logical switch identifier.
 * @param gatewayIpAddr - the gateway Ip address
 * @param ipPrefix - network prefix.
 * @return the gw logical port TpId.
 */
public Uuid createLrLswGateway(NodeId fId, NodeId lrId, NodeId lswId, IpAddress gatewayIpAddr,
        IpPrefix ipPrefix) {
    CreateGatewayInputBuilder inputBuilder = new CreateGatewayInputBuilder();
    FabricId fabricId = new FabricId(fId);
    inputBuilder.setFabricId(fabricId);
    inputBuilder.setLogicalRouter(new NodeId(lrId));
    inputBuilder.setLogicalSwitch(new NodeId(lswId));
    inputBuilder.setIpAddress(new IpAddress(gatewayIpAddr));
    inputBuilder.setNetwork(new IpPrefix(ipPrefix));

    Future<RpcResult<CreateGatewayOutput>> result = this.fabServiceService.createGateway(inputBuilder.build());
    try {
        RpcResult<CreateGatewayOutput> output = result.get();
        if (output.isSuccessful()) {
            LOG.debug("FABMGR: createLrLswGateway: createGateway RPC success");
            CreateGatewayOutput o = output.getResult();
            return o.getLportUuid();
        }
    } catch (Exception e) {
        LOG.error("FABMGR: ERROR: createLrLswGateway: createGateway RPC failed.", e);
    }

    return null;
}
 
开发者ID:opendaylight,项目名称:faas,代码行数:34,代码来源:VContainerNetNodeServiceProvider.java


示例4: createLrLswGateway

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public Uuid createLrLswGateway(Uuid tenantId, NodeId vfabricId, NodeId lrId, NodeId lswId, IpAddress gatewayIpAddr,
        IpPrefix ipPrefix) {
    VContainerConfigMgr vcMgr = containerMgr.getVcConfigDataMgr(tenantId);
    if (vcMgr == null) {
        LOG.error("FABMGR: ERROR: createLrLswGateway: vcMgr is null: tenantId={}", tenantId.getValue());
        return null; // ----->
    }

    if (!vcMgr.getLdNodeConfigDataMgr().isVFabricAvailable(vfabricId)) {
        LOG.error("FABMGR: ERROR: createLrLswGateway: vfabricId is null: {}", tenantId.getValue());
        return null; // ---->
    }

    return  this.netNodeServiceProvider.createLrLswGateway(vfabricId, lrId, lswId, gatewayIpAddr, ipPrefix);
}
 
开发者ID:opendaylight,项目名称:faas,代码行数:17,代码来源:FabricMgrProvider.java


示例5: toMd

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
protected MeteringRule toMd(NeutronMeteringLabelRule meteringLabelRule) {
    final MeteringRuleBuilder meteringRuleBuilder = new MeteringRuleBuilder();
    toMdIds(meteringLabelRule, meteringRuleBuilder);
    if (meteringLabelRule.getMeteringLabelRuleLabelID() != null) {
        meteringRuleBuilder.setMeteringLabelId(toUuid(meteringLabelRule.getMeteringLabelRuleLabelID()));
    }
    if (meteringLabelRule.getMeteringLabelRuleDirection() != null) {
        meteringRuleBuilder.setDirection(
                DirectionMapper.get(meteringLabelRule.getMeteringLabelRuleDirection()));
    }
    if (meteringLabelRule.getMeteringLabelRuleRemoteIpPrefix() != null) {
        final IpPrefix ipPrefix = new IpPrefix(
                meteringLabelRule.getMeteringLabelRuleRemoteIpPrefix().toCharArray());
        meteringRuleBuilder.setRemoteIpPrefix(ipPrefix);
    }
    meteringRuleBuilder.setExcluded(meteringLabelRule.getMeteringLabelRuleExcluded());
    return meteringRuleBuilder.build();
}
 
开发者ID:opendaylight,项目名称:neutron,代码行数:20,代码来源:NeutronMeteringLabelRuleInterface.java


示例6: parseSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final SubobjectBuilder builder = new SubobjectBuilder();
    builder.setMandatory(mandatory);
    if (buffer.readableBytes() != CONTENT4_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
    }
    final int length = buffer.getUnsignedByte(PREFIX4_F_OFFSET);
    final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer,
            Ipv4Util.IP4_LENGTH), length)));
    builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
    buffer.skipBytes(PREFIX_F_LENGTH);
    builder.setAttribute(Attribute.forValue(buffer.readUnsignedByte()));
    return builder.build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:17,代码来源:XROIpv4PrefixSubobjectParser.java


示例7: serializeSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public void serializeSubobject(final Subobject 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();
    Preconditions.checkArgument(prefix.getIpv4Prefix() != null || prefix.getIpv6Prefix() != null, "Unknown AbstractPrefix instance. Passed %s.", prefix.getClass());
    if (prefix.getIpv6Prefix() != null) {
        new XROIpv6PrefixSubobjectParser().serializeSubobject(subobject, buffer);
    } else {
        final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
        Preconditions.checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
        writeIpv4Prefix(prefix.getIpv4Prefix(), body);
        Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
        writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
        XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
    }
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:18,代码来源:XROIpv4PrefixSubobjectParser.java


示例8: parseSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final SubobjectBuilder builder = new SubobjectBuilder();
    if (buffer.readableBytes() != CONTENT_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
    }
    final int length = buffer.getUnsignedByte(PREFIX_F_OFFSET);
    final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ByteArray.readBytes(buffer,
            Ipv6Util.IPV6_LENGTH), length)));
    buffer.skipBytes(PREFIX_F_LENGTH);
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    builder.setProtectionAvailable(flags.get(LPA_F_OFFSET));
    builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
    builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
    return builder.build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:18,代码来源:RROIpv6PrefixSubobjectParser.java


示例9: serializeSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public void serializeSubobject(final Subobject 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();
    Preconditions.checkArgument(prefix.getIpv4Prefix() != null || prefix.getIpv6Prefix() != null, "Unknown AbstractPrefix instance. Passed %s.", prefix.getClass());
    if (prefix.getIpv6Prefix() != null) {
        new EROIpv6PrefixSubobjectParser().serializeSubobject(subobject, buffer);
    } else {
        final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
        Preconditions.checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
        writeIpv4Prefix(prefix.getIpv4Prefix(), body);
        body.writeZero(RESERVED);
        EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
    }
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:17,代码来源:EROIpv4PrefixSubobjectParser.java


示例10: parseSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final SubobjectBuilder builder = new SubobjectBuilder();
    builder.setMandatory(mandatory);
    if (buffer.readableBytes() != CONTENT6_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
    }
    final int length = buffer.getUnsignedByte(PREFIX6_F_OFFSET);
    final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ByteArray.readBytes(buffer,
            Ipv6Util.IPV6_LENGTH), length)));
    builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
    buffer.skipBytes(PREFIX_F_LENGTH);
    builder.setAttribute(Attribute.forValue(buffer.readUnsignedByte()));
    return builder.build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:17,代码来源:XROIpv6PrefixSubobjectParser.java


示例11: parseSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (buffer.readableBytes() != CONTENT4_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
    }
    final SubobjectBuilder builder = new SubobjectBuilder();
    final int length = buffer.getUnsignedByte(PREFIX4_F_OFFSET);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.ip.prefix._case.IpPrefix prefix = new IpPrefixBuilder().setIpPrefix(
            new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv4Util.IP4_LENGTH), length))).build();
    buffer.skipBytes(PREFIX_F_LENGTH);
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    builder.setProtectionAvailable(flags.get(LPA_F_OFFSET));
    builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
    builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix).build());
    return builder.build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:18,代码来源:RROIpv4PrefixSubobjectParser.java


示例12: serializeSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public void serializeSubobject(final Subobject 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();
    Preconditions.checkArgument(prefix.getIpv4Prefix() != null || prefix.getIpv6Prefix() != null, "Unknown AbstractPrefix instance. Passed %s.", prefix.getClass());
    if (prefix.getIpv6Prefix() != null) {
        new RROIpv6PrefixSubobjectParser().serializeSubobject(subobject, buffer);
    } else {
        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(CONTENT4_LENGTH);
        Preconditions.checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
        writeIpv4Prefix(prefix.getIpv4Prefix(), body);
        flags.toByteBuf(body);
        RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
    }
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:20,代码来源:RROIpv4PrefixSubobjectParser.java


示例13: removePrefix

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
private void removePrefix(final WriteTransaction trans, final UriBuilder base, final PrefixCase prefixCase) {
    final NodeId node = buildNodeId(base, prefixCase.getAdvertisingNodeDescriptors());
    final NodeHolder nh = this.nodes.get(node);
    if (nh != null) {
        LOG.debug("Removed prefix {}", prefixCase);
        final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(nh.getNodeId()));
        final InstanceIdentifier<IgpNodeAttributes> inaId = nid.builder().augmentation(Node1.class)
                .child(IgpNodeAttributes.class).build();
        final IpPrefix ippfx = prefixCase.getPrefixDescriptors().getIpReachabilityInformation();
        if (ippfx == null) {
            LOG.warn("IP reachability not present in prefix {}, skipping it", prefixCase);
            return;
        }
        final PrefixKey pk = new PrefixKey(ippfx);
        trans.delete(LogicalDatastoreType.OPERATIONAL, inaId.child(Prefix.class, pk));
        nh.removePrefix(prefixCase);
        checkNodeForRemoval(trans, nh);
    } else {
        LOG.warn("Removing prefix from non-existing node {}", node);
    }
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:22,代码来源:LinkstateTopologyBuilder.java


示例14: createLinkstatePrefixRoute

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
private static LinkstateRoute createLinkstatePrefixRoute(final ProtocolId protocolId, final AsNumber asNumber,
        final String ipv4Prefix, final long igpMetric, final String ospfFwdAddress) {
    return createBaseBuilder(protocolId)
        .setObjectType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207
                .linkstate.object.type.PrefixCaseBuilder()
            .setAdvertisingNodeDescriptors(new AdvertisingNodeDescriptorsBuilder().setAsNumber(asNumber).build())
            .setPrefixDescriptors(new PrefixDescriptorsBuilder()
                    .setIpReachabilityInformation(new IpPrefix(new Ipv4Prefix(ipv4Prefix))).build()).build())
        .setAttributes(new AttributesBuilder()
            .setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build())
            .addAugmentation(Attributes1.class, new Attributes1Builder()
                    .setLinkStateAttribute(new PrefixAttributesCaseBuilder().setPrefixAttributes(
                            new PrefixAttributesBuilder().setOspfForwardingAddress(new IpAddress(
                                    new Ipv4Address(ospfFwdAddress))).setPrefixMetric(new IgpMetric(igpMetric))
                                    .build()).build()).build()).build()).build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:17,代码来源:LinkstateTopologyBuilderTest.java


示例15: serializeNlri

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
protected static void serializeNlri(final List<CLabeledUnicastDestination> dests, final boolean isUnreachNlri,
        final ByteBuf buffer) {
    final ByteBuf nlriByteBuf = Unpooled.buffer();
    for (final CLabeledUnicastDestination dest : dests) {
        PathIdUtil.writePathId(dest.getPathId(), buffer);

        final List<LabelStack> labelStack = dest.getLabelStack();
        final IpPrefix prefix = dest.getPrefix();
        // Serialize the length field
        // Length field contains one Byte which represents the length of label stack and prefix in bits
        nlriByteBuf.writeByte(((LABEL_LENGTH * (!isUnreachNlri ? labelStack.size() : 1)) + getPrefixLength(prefix)) * Byte.SIZE);

        serializeLabelStackEntries(labelStack, isUnreachNlri, nlriByteBuf);
        serializePrefixField(prefix, nlriByteBuf);
    }
    buffer.writeBytes(nlriByteBuf);
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:18,代码来源:LUNlriParser.java


示例16: createRouteKey

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode l3vpn) {
    final ByteBuf buffer = Unpooled.buffer();
    final VpnDestination dests = new VpnDestinationBuilder().setPrefix(extractPrefix(l3vpn, this.prefixTypeNid))
        .setRouteDistinguisher(extractRouteDistinguisher(l3vpn)).build();
    final ByteBuf nlriByteBuf = Unpooled.buffer();

    for (final VpnDestination dest : Collections.singletonList(dests)) {
        final IpPrefix prefix = dest.getPrefix();
        LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
        AbstractVpnNlriParser.serializeLengtField(prefix, null, nlriByteBuf);
        RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
        Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null,
                "Ipv6 or Ipv4 prefix is missing.");
        LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
    }
    buffer.writeBytes(nlriByteBuf);

    return new NodeIdentifierWithPredicates(routeQName(), this.routeKey, ByteArray.encodeBase64(buffer));
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:20,代码来源:AbstractVpnRIBSupport.java


示例17: serializeNlri

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
private static void serializeNlri(final List<VpnDestination> dests,
        final boolean isWithdrawnRoute, final ByteBuf buffer) {
    final ByteBuf nlriByteBuf = Unpooled.buffer();
    for (final VpnDestination dest : dests) {
        final List<LabelStack> labelStack = dest.getLabelStack();
        final IpPrefix prefix = dest.getPrefix();
        LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
        AbstractVpnNlriParser.serializeLengtField(prefix, labelStack, nlriByteBuf);
        LUNlriParser.serializeLabelStackEntries(labelStack, isWithdrawnRoute, nlriByteBuf);
        RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
        Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null,
                "Ipv6 or Ipv4 prefix is missing.");
        LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
    }
    buffer.writeBytes(nlriByteBuf);
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:17,代码来源:AbstractVpnNlriParser.java


示例18: parseSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws
    RSVPParsingException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(),
        "Array of bytes is mandatory. Can't be null or empty.");
    final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
    builder.setMandatory(mandatory);
    if (buffer.readableBytes() != CONTENT4_LENGTH) {
        throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
    }
    final int length = buffer.getUnsignedByte(PREFIX4_F_OFFSET);
    final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(
        Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv4Util.IP4_LENGTH), length)));
    builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
    buffer.skipBytes(PREFIX_F_LENGTH);
    builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
    return builder.build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:19,代码来源:XROIpv4PrefixSubobjectParser.java


示例19: serializeSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@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();
    Preconditions.checkArgument(prefix.getIpv4Prefix() != null || prefix.getIpv6Prefix() != null,
        "Unknown AbstractPrefix instance. Passed %s.", prefix.getClass());
    if (prefix.getIpv6Prefix() != null) {
        new XROIpv6PrefixSubobjectParser().serializeSubobject(subobject, buffer);
    } else {
        final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
        Preconditions.checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
        writeIpv4Prefix(prefix.getIpv4Prefix(), body);
        Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
        writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
        XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
    }
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:21,代码来源:XROIpv4PrefixSubobjectParser.java


示例20: parseSubobject

import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; //导入依赖的package包/类
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws
    RSVPParsingException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(),
        "Array of bytes is mandatory. Can't be null or empty.");
    final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
    builder.setMandatory(mandatory);
    if (buffer.readableBytes() != CONTENT6_LENGTH) {
        throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
    }
    final int length = buffer.getUnsignedByte(PREFIX6_F_OFFSET);
    final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(
        Ipv6Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv6Util.IPV6_LENGTH), length)));
    builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
    buffer.skipBytes(PREFIX_F_LENGTH);
    builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
    return builder.build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:19,代码来源:XROIpv6PrefixSubobjectParser.java



注:本文中的org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TilesView类代码示例发布时间:2022-05-22
下一篇:
Java DanmakuFilters类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap