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


Java ChannelBuffer.setByte方法代码示例

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


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

示例1: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) {

    int iLenStartIndex = cb.writerIndex();

    cb.writeByte(FLAGS);
    cb.writeByte(getType());
    if ((as4pathSet != null) && (as4pathSeq != null)) {
        int iAsLenIndex = cb.writerIndex();
        cb.writeByte(0);
        if (as4pathSeq.size() != 0) {
            cb.writeByte(AsPath.ASPATH_SEQ_TYPE);
            cb.writeByte(as4pathSeq.size());

            for (int j = 0; j < as4pathSeq.size(); j++) {
                cb.writeInt(as4pathSeq.get(j));
            }

            int asLen = cb.writerIndex() - iAsLenIndex;
            cb.setByte(iAsLenIndex, (byte) (asLen - 1));
        }
    } else {
        cb.writeByte(0);
    }
    return cb.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:As4Path.java

示例2: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) {
    int iLenStartIndex = cb.writerIndex();
    cb.writeByte(FLAGS);
    cb.writeByte(getType());
    if (isaspathSet()) {
        int iAsLenIndex = cb.writerIndex();
        cb.writeByte(0);
        if (aspathSeq.size() != 0) {
            cb.writeByte(ASPATH_SEQ_TYPE);
            cb.writeByte(aspathSeq.size());

            for (int j = 0; j < aspathSeq.size(); j++) {
                cb.writeShort(aspathSeq.get(j));
            }
            int asLen = cb.writerIndex() - iAsLenIndex;
            cb.setByte(iAsLenIndex, (byte) (asLen - 1));
        }
    } else {
        cb.writeByte(0);
    }
    return cb.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:AsPath.java

示例3: writeHeader

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
public static void writeHeader(ChannelBuffer buffer, long requestId, byte status, Version version) {
    int index = buffer.readerIndex();
    buffer.setByte(index, 'E');
    index += 1;
    buffer.setByte(index, 'S');
    index += 1;
    // write the size, the size indicates the remaining message size, not including the size int
    buffer.setInt(index, buffer.readableBytes() - 6);
    index += 4;
    buffer.setLong(index, requestId);
    index += 8;
    buffer.setByte(index, status);
    index += 1;
    buffer.setInt(index, version.id);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:NettyHeader.java

示例4: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int iLenStartIndex = c.writerIndex();
    c.writeByte(TYPE);
    // Store the position of object length
    int objectLenIndex = c.writerIndex();
    c.writeByte(0);

    short temp = 0;
    if (bMFlag) {
        temp = (short) (temp | MFLAG_SET);
    }
    if (bCFlag) {
        temp = (short) (temp | CFLAG_SET);
    }
    if (bSFlag) {
        temp = (short) (temp | SFLAG_SET);
    }
    if (bFFlag) {
        temp = (short) (temp | FFLAG_SET);
    }
    short tempST = (short) (st << SHIFT_ST);
    temp = (short) (temp | tempST);
    c.writeShort(temp);
    if (bMFlag) {
        int tempSid = sid << 12;
        c.writeInt(tempSid);
    } else {
        c.writeInt(sid);
    }
    nai.write(c);

    c.setByte(objectLenIndex, (c.writerIndex() - iLenStartIndex));
    return c.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:SrEroSubObject.java

示例5: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public void write(ChannelBuffer cb, BgpOpenMsgVer4 message) throws BgpParseException {

    int optParaLen = 0;
    int as4num = 0;

    int startIndex = cb.writerIndex();

    // write common header and get msg length index
    int msgLenIndex = message.bgpMsgHeader.write(cb);

    if (msgLenIndex <= 0) {
        throw new BgpParseException("Unable to write message header.");
    }

    // write version in 1-octet
    cb.writeByte(message.version);

    // get as4num if LS Capability is set
    if (message.isLargeAsCapabilitySet) {
        LinkedList<BgpValueType> capabilityTlv = message
                .getCapabilityTlv();
        ListIterator<BgpValueType> listIterator = capabilityTlv
                .listIterator();

        while (listIterator.hasNext()) {
            BgpValueType tlv = listIterator.next();
            if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) {
                as4num = ((FourOctetAsNumCapabilityTlv) tlv).getInt();
                break;
            }
        }
    }

    if ((message.isLargeAsCapabilitySet) && (as4num > 65535)) {
        // write As number as AS_TRANS
        cb.writeShort(AS_TRANS);
    } else {
        // write AS number in next 2-octet
        cb.writeShort((short) message.asNumber);
    }

    // write HoldTime in next 2-octet
    cb.writeShort(message.holdTime);

    // write BGP Identifier in next 4-octet
    cb.writeInt(message.bgpId);

    // store the index of Optional parameter length
    int optParaLenIndex = cb.writerIndex();

    // set optional parameter length as 0
    cb.writeByte(0);

    // Pack capability TLV
    optParaLen = message.packCapabilityTlv(cb, message);

    if (optParaLen != 0) {
        // Update optional parameter length
        cb.setByte(optParaLenIndex, (byte) (optParaLen + 2)); //+2 for optional parameter type.
    }

    // write OPEN Object Length
    int length = cb.writerIndex() - startIndex;
    cb.setShort(msgLenIndex, (short) length);
    message.bgpMsgHeader.setLength((short) length);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:68,代码来源:BgpOpenMsgVer4.java

示例6: packCapabilityTlv

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * returns length of capability tlvs.
 *
 * @param cb of type channel buffer
 * @param message of type BGPOpenMsgVer4
 * @return capParaLen of open message
 */
protected int packCapabilityTlv(ChannelBuffer cb, BgpOpenMsgVer4 message) {
    int startIndex = cb.writerIndex();
    int capParaLen = 0;
    int capParaLenIndex = 0;

    LinkedList<BgpValueType> capabilityTlv = message.capabilityTlv;
    ListIterator<BgpValueType> listIterator = capabilityTlv.listIterator();

    if (listIterator.hasNext()) {
        // Set optional parameter type as 2
        cb.writeByte(OPT_PARA_TYPE_CAPABILITY);

        // Store the index of capability parameter length and update length at the end
        capParaLenIndex = cb.writerIndex();

        // Set capability parameter length as 0
        cb.writeByte(0);

        // Update the startIndex to know the length of capability tlv
        startIndex = cb.writerIndex();
    }

    while (listIterator.hasNext()) {
        BgpValueType tlv = listIterator.next();
        if (tlv == null) {
            log.debug("Warning: tlv is null from CapabilityTlv list");
            continue;
        }
        tlv.write(cb);
    }

    capParaLen = cb.writerIndex() - startIndex;

    if (capParaLen != 0) {
        // Update capability parameter length
        cb.setByte(capParaLenIndex, (byte) capParaLen);
    }
    return capParaLen;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:47,代码来源:BgpOpenMsgVer4.java

示例7: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) {
    int iLenStartIndex = cb.writerIndex();
    ListIterator<BgpValueType> listIterator = fsActionTlv().listIterator();

    cb.writeByte(FLAGS);
    cb.writeByte(getType());

    int iActionLenIndex = cb.writerIndex();
    cb.writeByte(0);

    while (listIterator.hasNext()) {
        BgpValueType fsTlv = listIterator.next();
        if (fsTlv.getType() == Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_ACTION) {
            BgpFsActionTrafficAction trafficAction = (BgpFsActionTrafficAction) fsTlv;
            trafficAction.write(cb);
        } else if (fsTlv.getType() == Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_MARKING) {
            BgpFsActionTrafficMarking trafficMarking = (BgpFsActionTrafficMarking) fsTlv;
            trafficMarking.write(cb);
        } else if (fsTlv.getType() == Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_RATE) {
            BgpFsActionTrafficRate trafficRate = (BgpFsActionTrafficRate) fsTlv;
            trafficRate.write(cb);
        } else if (fsTlv.getType() == Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_REDIRECT) {
            BgpFsActionReDirect trafficRedirect = (BgpFsActionReDirect) fsTlv;
            trafficRedirect.write(cb);
        }
    }

    int fsActionLen = cb.writerIndex() - iActionLenIndex;
    cb.setByte(iActionLenIndex, (byte) (fsActionLen - 1));

    return cb.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:BgpExtendedCommunity.java


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