This commit is contained in:
Administrator
2025-04-24 10:16:38 +08:00
parent 6de65562be
commit 7267aec1fd
108 changed files with 7621 additions and 1890 deletions
@@ -0,0 +1,101 @@
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.klalb.IPSequence;
public class ACKSEQSSegmentRoutingTLV extends IPv6SegmentRoutingTLV {
public ACKSEQSSegmentRoutingTLV(ByteBuffer klalbHeader) {
super(klalbHeader);
}
@Override
public String toString() {
return "ACKSEQSSegmentRoutingTLV [getSequence()=" + getSequence() + "]";
}
public ACKSEQSSegmentRoutingTLV(UUID ackid, boolean promise) {
super(IPv6SegmentRoutingTLV.ACKSEQS);
setUUID(ackid);
setPromise(promise);
getData().limit(22);
}
public ACKSEQSSegmentRoutingTLV(IPSequence ackid, boolean promise) {
super(IPv6SegmentRoutingTLV.ACKSEQS);
setIPSequence(ackid);
setPromise(promise);
getData().limit(22);
}
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 setIPSequence(IPSequence ackid) {
setUUID(ackid.getUuid());
}
public IPSequence getIPSequence() {
return new IPSequence(getUUID(),isPromise());
}
@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(6);
}
public void setSequence(long sequence) {
getData().putLong(6,sequence);
}
public int getFlowNumber() {
return getData().getInt(2);
}
public void setFlowNumber(int flowsequence) {
getData().putInt(2,flowsequence);
}
public void setACKIP(Inet6Address ip) {
getData().put(14, ip.getAddress());
}
public Inet6Address getACKIP() {
byte[]arr=new byte[16];
getData().get(14,arr);
try {
return (Inet6Address) Inet6Address.getByAddress(arr);
} catch (UnknownHostException e) {
e.printStackTrace();
return null;
}
}
public boolean isPromise() {
return getData().get(0)!=0?true:false;
}
public void setPromise(boolean promise) {
if(promise) {
getData().put(0, (byte) 1);
}else {
getData().put(0, (byte) 0);
}
}
}