package org.kne.cloud.network.srv6;

import java.io.EOFException;
import java.io.IOException;
import java.net.Inet6Address;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.util.UUID;

import org.kne.cloud.network.ipv6.PacketID;

public class ACKSEQSSegmentRoutingTLV extends IPv6SegmentRoutingTLV {
	public ACKSEQSSegmentRoutingTLV(ByteBuffer klalbHeader) {
		super(klalbHeader);
	}

	@Override
	public String toString() {
		return "ACKSEQSSegmentRoutingTLV [getSequence()=" + getSequence() + "]";
	}

	public ACKSEQSSegmentRoutingTLV(UUID ackid,long sequence) {
		super(IPv6SegmentRoutingTLV.ACKSEQS);
		setUUID(ackid);
		getData().limit(30);
	}
	public ACKSEQSSegmentRoutingTLV(PacketID ackid) {
		super(IPv6SegmentRoutingTLV.ACKSEQS);
		setPacketID(ackid);
		getData().limit(30);
	}
	public void setUUID(UUID uuid) {
		getData().putLong(6,uuid.getMostSignificantBits());
		getData().putLong(14,uuid.getLeastSignificantBits());
	}

	public UUID getUUID() {
		return new UUID(getData().getLong(6),getData().getLong(14));
	}
	public void setPacketID(PacketID ackid) {
		setUUID(ackid.getFlowuuid());
		setSequence(ackid.getSequence());
	}
	
	public PacketID getPacketID() {
		return new PacketID(getUUID(),getSequence());
	}
	
	@Override
	public void writeToChannel(WritableByteChannel dto) throws IOException {
		
		super.writeToChannel(dto);
	
	}

	@Override
	public void readFromChannel(ReadableByteChannel din, long length) throws IOException {
		super.readFromChannel(din, length);
		
	}
	
	public long getSequence() {
		return getData().getLong(22);
	}
	public void setSequence(long sequence) {
		getData().putLong(22,sequence);
	}
	public int getFlowNumber() {
		return getData().getInt(2);
	}
	public void setFlowNumber(int flowsequence) {
		getData().putInt(2,flowsequence);
	}

	
}
