当前位置: 首页>>代码示例>>Java>>正文


Java Validation.getThirdBit方法代码示例

本文整理汇总了Java中org.onosproject.bgpio.util.Validation.getThirdBit方法的典型用法代码示例。如果您正苦于以下问题:Java Validation.getThirdBit方法的具体用法?Java Validation.getThirdBit怎么用?Java Validation.getThirdBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onosproject.bgpio.util.Validation的用法示例。


在下文中一共展示了Validation.getThirdBit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads the channel buffer and returns object of Med.
 *
 * @param cb ChannelBuffer
 * @return object of Med
 * @throws BgpParseException while parsing Med path attribute
 */
public static Med read(ChannelBuffer cb) throws BgpParseException {
    int med;
    ChannelBuffer tempCb = cb.copy();
    Validation parseFlags = Validation.parseAttributeHeader(cb);

    if ((parseFlags.getLength() > MED_MAX_LEN) || cb.readableBytes() < parseFlags.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
                parseFlags.getLength());
    }
    int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
            .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempCb.readBytes(len);
    if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }

    med = cb.readInt();
    return new Med(med);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:Med.java

示例2: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads from ChannelBuffer and parses NextHop.
 *
 * @param cb ChannelBuffer
 * @return object of NextHop
 * @throws BgpParseException while parsing nexthop attribute
 */
public static NextHop read(ChannelBuffer cb) throws BgpParseException {
    Ip4Address nextHop;
    ChannelBuffer tempCb = cb.copy();
    Validation parseFlags = Validation.parseAttributeHeader(cb);

    if (cb.readableBytes() < parseFlags.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
                parseFlags.getLength());
    }
    int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
            .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempCb.readBytes(len);
    if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }

     InetAddress ipAddress = Validation.toInetAddress(parseFlags.getLength(), cb);
    if (ipAddress.isMulticastAddress()) {
        throw new BgpParseException("Multicast address is not supported");
    }

    nextHop = Ip4Address.valueOf(ipAddress);
    return new NextHop(nextHop);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:NextHop.java

示例3: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads from ChannelBuffer and parses Origin.
 *
 * @param cb ChannelBuffer
 * @return object of Origin
 * @throws BgpParseException while parsing Origin path attribute
 */
public static Origin read(ChannelBuffer cb) throws BgpParseException {
    ChannelBuffer tempCb = cb.copy();
    Validation parseFlags = Validation.parseAttributeHeader(cb);

    int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
            .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempCb.readBytes(len);
    if ((parseFlags.getLength() > ORIGIN_VALUE_LEN) || (cb.readableBytes() < parseFlags.getLength())) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
                parseFlags.getLength());
    }
    if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }

    byte originValue;
    originValue = cb.readByte();
    if ((originValue != OriginType.INCOMPLETE.value) && (originValue != OriginType.IGP.value) &&
          (originValue != OriginType.EGP.value)) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.INVALID_ORIGIN_ATTRIBUTE, data);
    }
    return new Origin(originValue);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:Origin.java

示例4: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads from the channel buffer and parses As4Path.
 *
 * @param cb ChannelBuffer
 * @return object of As4Path
 * @throws BgpParseException while parsing As4Path
 */
public static As4Path read(ChannelBuffer cb) throws BgpParseException {
    List<Integer> as4pathSet = new ArrayList<>();
    List<Integer> as4pathSeq = new ArrayList<>();
    ChannelBuffer tempCb = cb.copy();
    Validation validation = Validation.parseAttributeHeader(cb);

    if (cb.readableBytes() < validation.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
                validation.getLength());
    }
    //if fourth bit is set length is read as short otherwise as byte , len includes type, length and value
    int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
            .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempCb.readBytes(len);
    if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }

    ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
    while (tempBuf.readableBytes() > 0) {
        byte pathSegType = tempBuf.readByte();
        //no of ASes
        byte pathSegLen = tempBuf.readByte();
        //length = no of Ases * ASnum size (4 bytes)
        int length = pathSegLen * ASNUM_SIZE;
        if (tempBuf.readableBytes() < length) {
            Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
                    BgpErrorType.ATTRIBUTE_LENGTH_ERROR, length);
        }
        ChannelBuffer aspathBuf = tempBuf.readBytes(length);
        while (aspathBuf.readableBytes() > 0) {
            int asNum;
            asNum = aspathBuf.readInt();
            switch (pathSegType) {
            case AsPath.ASPATH_SET_TYPE:
                as4pathSet.add(asNum);
                break;
            case AsPath.ASPATH_SEQ_TYPE:
                as4pathSeq.add(asNum);
                break;
            default: log.debug("Other type Not Supported:" + pathSegType);
            }
        }
    }
    return new As4Path(as4pathSet, as4pathSeq);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:54,代码来源:As4Path.java

示例5: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads from the channel buffer and parses extended community.
 *
 * @param cb ChannelBuffer
 * @return object of BgpExtendedCommunity
 * @throws BgpParseException while parsing extended community
 */
public static BgpExtendedCommunity read(ChannelBuffer cb) throws BgpParseException {

    ChannelBuffer tempCb = cb.copy();
    Validation validation = Validation.parseAttributeHeader(cb);
    List<BgpValueType> fsActionTlvs = new LinkedList<>();

    if (cb.readableBytes() < validation.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
                validation.getLength());
    }
    //if fourth bit is set, length is read as short otherwise as byte , len includes type, length and value
    int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
            .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempCb.readBytes(len);
    if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }

    ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
    if (tempBuf.readableBytes() > 0) {
        BgpValueType fsActionTlv = null;
        ChannelBuffer actionBuf = tempBuf.readBytes(validation.getLength());

        while (actionBuf.readableBytes() > 0) {
            short actionType = actionBuf.readShort();
            switch (actionType) {
                case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_ACTION:
                    fsActionTlv = BgpFsActionTrafficAction.read(actionBuf);
                    break;
                case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_MARKING:
                    fsActionTlv = BgpFsActionTrafficMarking.read(actionBuf);
                    break;
                case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_RATE:
                    fsActionTlv = BgpFsActionTrafficRate.read(actionBuf);
                    break;
                case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_REDIRECT:
                    fsActionTlv = BgpFsActionReDirect.read(actionBuf);
                    break;
                default: log.debug("Other type Not Supported:" + actionType);
                    break;
            }
            if (fsActionTlv != null) {
                fsActionTlvs.add(fsActionTlv);
            }
        }
    }
    return new BgpExtendedCommunity(fsActionTlvs);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:56,代码来源:BgpExtendedCommunity.java

示例6: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads from the channel buffer and parses AsPath.
 *
 * @param cb ChannelBuffer
 * @return object of AsPath
 * @throws BgpParseException while parsing AsPath
 */
public static AsPath read(ChannelBuffer cb) throws BgpParseException {
    List<Short> aspathSet = new ArrayList<>();
    List<Short> aspathSeq = new ArrayList<>();
    ChannelBuffer tempCb = cb.copy();
    Validation validation = Validation.parseAttributeHeader(cb);

    if (cb.readableBytes() < validation.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
                validation.getLength());
    }
    //if fourth bit is set, length is read as short otherwise as byte , len includes type, length and value
    int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
            .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempCb.readBytes(len);
    if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }

    ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
    while (tempBuf.readableBytes() > 0) {
        byte pathSegType = tempBuf.readByte();
        //no of ASes
        byte pathSegLen = tempBuf.readByte();
        int length = pathSegLen * ASNUM_SIZE;
        if (tempBuf.readableBytes() < length) {
            Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
                    BgpErrorType.ATTRIBUTE_LENGTH_ERROR, length);
        }
        ChannelBuffer aspathBuf = tempBuf.readBytes(length);
        while (aspathBuf.readableBytes() > 0) {
            short asNum;
            asNum = aspathBuf.readShort();
            switch (pathSegType) {
            case ASPATH_SET_TYPE:
                aspathSet.add(asNum);
                break;
            case ASPATH_SEQ_TYPE:
                aspathSeq.add(asNum);
                break;
            default: log.debug("Other type Not Supported:" + pathSegType);
            }
        }
    }
    return new AsPath(aspathSet, aspathSeq);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:53,代码来源:AsPath.java

示例7: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads from the channel buffer and parses extended community.
 *
 * @param cb ChannelBuffer
 * @return object of BgpExtendedCommunity
 * @throws BgpParseException while parsing extended community
 */
public static BgpExtendedCommunity read(ChannelBuffer cb) throws BgpParseException {

    ChannelBuffer tempCb = cb.copy();
    Validation validation = Validation.parseAttributeHeader(cb);
    List<BgpValueType> fsActionTlvs = new LinkedList<>();

    if (cb.readableBytes() < validation.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
                validation.getLength());
    }
    //if fourth bit is set, length is read as short otherwise as byte , len includes type, length and value
    int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
            .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempCb.readBytes(len);
    if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }

    ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
    if (tempBuf.readableBytes() > 0) {
        BgpValueType fsActionTlv = null;
        ChannelBuffer actionBuf = tempBuf.readBytes(validation.getLength());

        while (actionBuf.readableBytes() > 0) {
            short actionType = actionBuf.readShort();
            switch (actionType) {
                case Constants.BGP_ROUTE_TARGET_AS:
                case Constants.BGP_ROUTE_TARGET_IP:
                case Constants.BGP_ROUTE_TARGET_LARGEAS:
                    fsActionTlv = RouteTarget.read(actionType, actionBuf);
                    break;
                case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_ACTION:
                    fsActionTlv = BgpFsActionTrafficAction.read(actionBuf);
                    break;
                case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_MARKING:
                    fsActionTlv = BgpFsActionTrafficMarking.read(actionBuf);
                    break;
                case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_RATE:
                    fsActionTlv = BgpFsActionTrafficRate.read(actionBuf);
                    break;
                case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_REDIRECT:
                    fsActionTlv = BgpFsActionReDirect.read(actionBuf);
                    break;
                default:
                    log.debug("Other type Not Supported:" + actionType);
                    break;
            }
            if (fsActionTlv != null) {
                fsActionTlvs.add(fsActionTlv);
            }
        }
    }
    return new BgpExtendedCommunity(fsActionTlvs);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:62,代码来源:BgpExtendedCommunity.java


注:本文中的org.onosproject.bgpio.util.Validation.getThirdBit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。