Search in sources :

Example 1 with Uint8

use of org.opendaylight.yangtools.yang.common.Uint8 in project netvirt by opendaylight.

the class DisplayAclDataCaches method printAcl.

private void printAcl(String aclId, Acl acl) {
    session.getConsole().println();
    session.getConsole().println(ACL_HEADER + String.format("%-32s  ", aclId));
    if (null != acl.getAccessListEntries() && null != acl.getAccessListEntries().getAce()) {
        printHeader(ACL_ENTRIES_HEADERS, ACL_ENTRIES_HEADER_LINE);
        List<Ace> aceList = acl.getAccessListEntries().getAce();
        for (Ace ace : aceList) {
            LOG.info("ace data: {}", ace);
            SecurityRuleAttr aceAttr = getAccessListAttributes(ace);
            Class<? extends DirectionBase> aceAttrDirection = aceAttr.getDirection();
            AceIp aceIp = (AceIp) ace.getMatches().getAceType();
            AceIpVersion ipVersion = aceIp.getAceIpVersion();
            Uint8 protoNum = aceIp.getProtocol();
            String protocol = "Any";
            if (null != protoNum) {
                protocol = protoMap.get(protoNum.toString());
                protocol = (protocol == null) ? protoNum.toString() : protocol;
            }
            String ipVer = "";
            String direction = DirectionEgress.class.equals(aceAttrDirection) ? "Egress" : "Ingress";
            String ipPrefix = " -- ";
            if (null != ipVersion && ipVersion instanceof AceIpv4) {
                ipVer = "IPv4";
                Ipv4Prefix srcNetwork = ((AceIpv4) ipVersion).getSourceIpv4Network();
                if (null != srcNetwork) {
                    ipPrefix = srcNetwork.getValue();
                }
            } else if (null != ipVersion && ipVersion instanceof AceIpv6) {
                ipVer = "IPv6";
                Ipv6Prefix srcNetwork = ((AceIpv6) ipVersion).getSourceIpv6Network();
                if (null != srcNetwork) {
                    ipPrefix = srcNetwork.getValue();
                }
            }
            String remoteGroupId = "-";
            if (aceAttr.getRemoteGroupId() != null) {
                remoteGroupId = aceAttr.getRemoteGroupId().getValue();
                ipPrefix = "-";
            }
            String prefixAndRemoteId = ipPrefix + " / " + remoteGroupId;
            session.getConsole().print(String.format(ACE_ENTRIES_FORMAT_STRING, ace.key().getRuleName(), direction, protocol, ipVer, prefixAndRemoteId));
        }
    }
    session.getConsole().println();
}
Also used : Uint8(org.opendaylight.yangtools.yang.common.Uint8) Ace(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace) AceIp(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.AceIp) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) SecurityRuleAttr(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr) AceIpVersion(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.AceIpVersion) DirectionEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress) AceIpv6(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.AceIpv6) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) AceIpv4(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.AceIpv4)

Example 2 with Uint8

use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.

the class OpaqueUtil method parseOpaque.

public static Opaque parseOpaque(final ByteBuf buffer) {
    final Uint8 type = ByteBufUtils.readUint8(buffer);
    final OpaqueValueBuilder builder = new OpaqueValueBuilder();
    switch(type.toJava()) {
        case GENERIC_LSP_IDENTIFIER:
            builder.setOpaque(buildOpaqueValue(buffer));
            break;
        case EXTENDED_TYPE:
            buildExtended(builder, buffer);
            break;
        default:
            final int length = buffer.readUnsignedShort();
            buffer.skipBytes(length);
            LOG.debug("Skipping parsing of Opaque Value {}", buffer);
            return null;
    }
    return builder.setOpaqueType(type).build();
}
Also used : Uint8(org.opendaylight.yangtools.yang.common.Uint8) OpaqueValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder)

Example 3 with Uint8

use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.

the class FlowspecIpv4NlriParserHelper method createProtocolsIps.

private static List<ProtocolIps> createProtocolsIps(final UnkeyedListNode protocolIpsData) {
    final List<ProtocolIps> protocolIps = new ArrayList<>();
    for (final UnkeyedListEntryNode node : protocolIpsData.body()) {
        final ProtocolIpsBuilder ipsBuilder = new ProtocolIpsBuilder();
        node.findChildByArg(AbstractFlowspecNlriParser.OP_NID).ifPresent(dataContainerChild -> ipsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
        node.findChildByArg(AbstractFlowspecNlriParser.VALUE_NID).ifPresent(dataContainerChild -> ipsBuilder.setValue((Uint8) dataContainerChild.body()));
        protocolIps.add(ipsBuilder.build());
    }
    return protocolIps;
}
Also used : Uint8(org.opendaylight.yangtools.yang.common.Uint8) ProtocolIpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.protocol.ip._case.ProtocolIpsBuilder) ProtocolIps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv4.flowspec.flowspec.type.protocol.ip._case.ProtocolIps) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)

Example 4 with Uint8

use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.

the class BGPNotificationMessageParser method parseMessageBody.

/**
 * Parses BGP Notification message to bytes.
 *
 * @param body ByteBuf to be parsed
 * @param messageLength the length of the message
 * @return {@link Notify} which represents BGP notification message
 * @throws BGPDocumentedException if parsing goes wrong
 */
@Override
public Notify parseMessageBody(final ByteBuf body, final int messageLength, final PeerSpecificParserConstraint constraint) throws BGPDocumentedException {
    checkArgument(body != null, "Buffer cannot be null.");
    if (body.readableBytes() < ERROR_SIZE) {
        throw BGPDocumentedException.badMessageLength("Notification message too small.", messageLength);
    }
    final Uint8 errorCode = Uint8.valueOf(body.readUnsignedByte());
    final Uint8 errorSubcode = Uint8.valueOf(body.readUnsignedByte());
    final NotifyBuilder builder = new NotifyBuilder().setErrorCode(errorCode).setErrorSubcode(errorSubcode);
    if (body.isReadable()) {
        builder.setData(ByteArray.readAllBytes(body));
    }
    final Notify result = builder.build();
    final BGPError err = BGPError.forValue(errorCode, errorSubcode);
    if (LOG.isDebugEnabled()) {
        LOG.debug("BGP Notification message was parsed: err = {}, data = {}.", err, Arrays.toString(result.getData()));
    }
    return result;
}
Also used : NotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.NotifyBuilder) BGPError(org.opendaylight.protocol.bgp.parser.BGPError) Uint8(org.opendaylight.yangtools.yang.common.Uint8) Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify)

Example 5 with Uint8

use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.

the class PCEPOpenObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
    final int versionValue = ByteArray.copyBitsRange(bytes.readByte(), VERSION_SF_OFFSET, VERSION_SF_LENGTH);
    final short keepalive = bytes.readUnsignedByte();
    final short deadTimer = bytes.readUnsignedByte();
    final Uint8 sessionId = ByteBufUtils.readUint8(bytes);
    final TlvsBuilder tbuilder = new TlvsBuilder();
    parseTlvs(tbuilder, bytes.slice());
    final OpenBuilder builder = new OpenBuilder().setVersion(new ProtocolVersion(Uint8.valueOf(versionValue))).setProcessingRule(header.getProcessingRule()).setIgnore(header.getIgnore()).setKeepalive(Uint8.valueOf(keepalive)).setSessionId(sessionId).setTlvs(tbuilder.build());
    if (keepalive == 0) {
        builder.setDeadTimer(Uint8.ZERO);
    } else {
        builder.setDeadTimer(Uint8.valueOf(deadTimer));
    }
    final Open obj = builder.build();
    if (versionValue != PCEP_VERSION) {
        // TODO: Should we move this check into the negotiator
        LOG.debug("Unsupported PCEP version {}", versionValue);
        return new UnknownObject(PCEPErrors.PCEP_VERSION_NOT_SUPPORTED, obj);
    }
    return obj;
}
Also used : Uint8(org.opendaylight.yangtools.yang.common.Uint8) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder) OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject)

Aggregations

Uint8 (org.opendaylight.yangtools.yang.common.Uint8)12 ArrayList (java.util.ArrayList)4 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)4 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)1 BGPError (org.opendaylight.protocol.bgp.parser.BGPError)1 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)1 BitArray (org.opendaylight.protocol.util.BitArray)1 Ace (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace)1 AceIp (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.AceIp)1 AceIpVersion (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.AceIpVersion)1 AceIpv4 (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.AceIpv4)1 AceIpv6 (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.AceIpv6)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)1 DirectionEgress (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress)1 SecurityRuleAttr (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr)1 Codes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes)1 CodesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.CodesBuilder)1 Types (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types)1 TypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.TypesBuilder)1