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


Java IpProtocol.of方法代码示例

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


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

示例1: main

import org.projectfloodlight.openflow.types.IpProtocol; //导入方法依赖的package包/类
public static void main(String []args){
    IPv6Address srcAddr = IPv6Address.of(11L, 11L);
    IPv6Address dstAddr = IPv6Address.of(12L,12L);
    TransportPort srcPort = TransportPort.of(11);
    TransportPort dstPort = TransportPort.of(12);
    //int prot = 67;
    IpProtocol prot = IpProtocol.of((byte)67);
    byte tos = 1;
    int input= 1 ;
    int pkts=1212;
    int octs=123123;
    long first=System.currentTimeMillis();
    long last= System.currentTimeMillis();
    byte tcpflags= 11;
    int drops= 1223;
    int type =2;//因为何种原因而不再活跃
    long timestamp= System.currentTimeMillis();//
    FlowPersistence f = new FlowPersistence(srcAddr,dstAddr,srcPort,dstPort,prot,tos,input,pkts
    ,octs,first,last,tcpflags,drops,type,timestamp);
    FlowStatisticsDAO fsDAO = new FlowStatisticsDAOImpl();
    fsDAO.insertFlow(f);




}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:27,代码来源:FlowStatisticsDAOImpl.java

示例2: deserialize

import org.projectfloodlight.openflow.types.IpProtocol; //导入方法依赖的package包/类
@Override
public IPacket deserialize(byte[] data, int offset, int length)
		throws PacketParsingException {
	// Wrap the data in a byte buffer for easier retrieval.
	ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
	// Retrieve values from IPv6 header.
	byte firstByte = bb.get();
	byte secondByte = bb.get();
	this.version = (byte) ((firstByte & 0xF0) >>> 4);
	if (this.version != 6) {
		throw new PacketParsingException(
				"Invalid version for IPv6 packet: " +
						this.version);
	}
	this.trafficClass = (byte) (((firstByte & 0xF) << 4) |
			((secondByte & 0xF0) >>> 4));
	this.flowLabel = ((secondByte & 0xF) << 16) |
			(bb.getShort() & 0xFFFF);
	this.payloadLength = bb.getShort();
	this.nextHeader = IpProtocol.of(bb.get());
	this.hopLimit = bb.get();
	byte[] sourceAddress = new byte[16];
	bb.get(sourceAddress, 0, 16);
	byte[] destinationAddress = new byte[16];
	bb.get(destinationAddress, 0, 16);
	this.sourceAddress = IPv6Address.of(sourceAddress);
	this.destinationAddress = IPv6Address.of(destinationAddress);
	// Retrieve the payload, if possible.
	IPacket payload;
	if (IPv6.nextHeaderClassMap.containsKey(this.nextHeader)) {
		Class<? extends IPacket> clazz = IPv6.nextHeaderClassMap.get(this.nextHeader);
		try {
			payload = clazz.newInstance();
		} catch (Exception e) {
			throw new RuntimeException("Error parsing payload for IPv6 packet", e);
		}
	} else {
		payload = new Data();
	}
	// Deserialize as much of the payload as we can (hopefully all of it).
	this.payload = payload.deserialize(data, bb.position(),
			Math.min(this.payloadLength, bb.limit() - bb.position()));
	this.payload.setParent(this);
	// We're done!
	return this;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:47,代码来源:IPv6.java

示例3: deserialize

import org.projectfloodlight.openflow.types.IpProtocol; //导入方法依赖的package包/类
@Override
public IPacket deserialize(byte[] data, int offset, int length)
        throws PacketParsingException {
    ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
    short sscratch;

    this.version = bb.get();
    this.headerLength = (byte) (this.version & 0xf);
    this.version = (byte) ((this.version >> 4) & 0xf);
    if (this.version != 4) {
        throw new PacketParsingException(
                "Invalid version for IPv4 packet: " +
                this.version);
    }
    this.diffServ = bb.get();
    this.totalLength = bb.getShort();
    this.identification = bb.getShort();
    sscratch = bb.getShort();
    this.flags = (byte) ((sscratch >> IPV4_FLAGS_SHIFT) & IPV4_FLAGS_MASK);
    this.fragmentOffset = (short) (sscratch & IPV4_OFFSET_MASK);
    this.ttl = bb.get();
    this.protocol = IpProtocol.of(U8.f(bb.get()));
    this.checksum = bb.getShort();
    this.sourceAddress = IPv4Address.of(bb.getInt());
    this.destinationAddress = IPv4Address.of(bb.getInt());

    if (this.headerLength > 5) {
        int optionsLength = (this.headerLength - 5) * 4;
        this.options = new byte[optionsLength];
        bb.get(this.options);
    }

    IPacket payload;
    isFragment = ((this.flags & IPV4_FLAGS_DONTFRAG) == 0) &&
            ((this.flags & IPV4_FLAGS_MOREFRAG) != 0 ||
            this.fragmentOffset != 0);
    if (!isFragment && IPv4.protocolClassMap.containsKey(this.protocol)) {
        Class<? extends IPacket> clazz = IPv4.protocolClassMap.get(this.protocol);
        try {
            payload = clazz.newInstance();
        } catch (Exception e) {
            throw new RuntimeException("Error parsing payload for IPv4 packet", e);
        }
    } else {
        if (log.isTraceEnabled() && isFragment) {
            log.trace("IPv4 fragment detected {}->{}, forward using IP header only",
                    this.sourceAddress.toString(),
                    this.destinationAddress.toString());
        }
        payload = new Data();
    }
    int payloadLength = this.totalLength - this.headerLength * 4;
    int remLength = bb.limit()-bb.position();
    if (remLength < payloadLength)
        payloadLength = bb.limit()-bb.position();
    this.payload = payload.deserialize(data, bb.position(), payloadLength);
    this.payload.setParent(this);

    if (this.totalLength > length)
        this.isTruncated = true;
    else
        this.isTruncated = false;

    return this;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:66,代码来源:IPv4.java

示例4: setIpProtocol

import org.projectfloodlight.openflow.types.IpProtocol; //导入方法依赖的package包/类
public void setIpProtocol(IpProtocol ipProtocol) {
	IpProtocol = IpProtocol.of(ipProtocol.getIpProtocolNumber());
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:4,代码来源:ObfuscatedFlow.java

示例5: deserialize

import org.projectfloodlight.openflow.types.IpProtocol; //导入方法依赖的package包/类
@Override
public IPacket deserialize(byte[] data, int offset, int length) throws PacketParsingException {
    ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
    // Retrieve values from IPv6 header.
    byte firstByte = bb.get();
    byte secondByte = bb.get();
    this.version = (byte) ((firstByte & 0xF0) >>> 4);

    if (this.version != 6) {
        throw new PacketParsingException(
                "Invalid version for IPv6 packet: " +
                        this.version);
    }

    this.trafficClass = (byte) (((firstByte & 0xF) << 4) |
            ((secondByte & 0xF0) >>> 4));
    this.flowLabel = ((secondByte & 0xF) << 16) |
            (bb.getShort() & 0xFFFF);
    this.payloadLength = bb.getShort();
    this.nextHeader = IpProtocol.of(bb.get());
    this.hopLimit = bb.get();
    byte[] sourceAddress = new byte[16];
    bb.get(sourceAddress, 0, 16);
    byte[] destinationAddress = new byte[16];
    bb.get(destinationAddress, 0, 16);
    this.sourceAddress = IPv6Address.of(sourceAddress);
    this.destinationAddress = IPv6Address.of(destinationAddress);
    /**
     * TCP header
     */
    this.sourcePort = TransportPort.of((int) (bb.getShort() & 0xffff)); // short will be signed, pos or neg
    this.destinationPort = TransportPort.of((int) (bb.getShort() & 0xffff)); // convert range 0 to 65534, not -32768 to 32767
    this.sequence = bb.getInt();
    this.acknowledge = bb.getInt();
    this.flags = bb.getShort();
    this.dataOffset = (byte) ((this.flags >> 12) & 0xf);
    /* dont care dataOffset
    if (this.dataOffset < 5) {
        throw new PacketParsingException("Invalid tcp header length < 20");
    }*/
    this.flags = (short) (this.flags & 0x1ff);
    this.windowSize = bb.getShort();
    this.checksum = bb.getShort();
    this.urgentPointer = bb.getShort();
    this.timeStamp = bb.getInt();
    /**
     * todo:
     */
    int i = bb.get();
    this.input = (i < 0)? i+256 :i  ;
    IPacket payload = new Data() ;

    // Deserialize as much of the payload as we can (hopefully all of it).
    this.payload = payload.deserialize(data, bb.position(), bb.limit() - bb.position());

    return this;

}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:59,代码来源:PktSummary.java


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