forked from I2P_Developers/i2p.i2p
SSU: Add support for SSU2 fragmentation to OMS
This commit is contained in:
@@ -87,11 +87,18 @@ class OutboundMessageState implements CDPQEntry {
|
||||
//_expiration = msg.getExpiration();
|
||||
|
||||
// now "fragment" it
|
||||
int totalSize = _i2npMessage.getRawMessageSize();
|
||||
int totalSize;
|
||||
if (_peer.getVersion() == 2)
|
||||
totalSize = _i2npMessage.getMessageSize() - 7; // NTCP2 style, 9 byte header
|
||||
else
|
||||
totalSize = _i2npMessage.getRawMessageSize();
|
||||
if (totalSize > MAX_MSG_SIZE)
|
||||
throw new IllegalArgumentException("Size too large! " + totalSize);
|
||||
_messageBuf = new byte[totalSize];
|
||||
_i2npMessage.toRawByteArray(_messageBuf);
|
||||
if (_peer.getVersion() == 2)
|
||||
_i2npMessage.toRawByteArrayNTCP2(_messageBuf, 0); // NTCP2 style, 9 byte header
|
||||
else
|
||||
_i2npMessage.toRawByteArray(_messageBuf);
|
||||
_fragmentSize = _peer.fragmentSize();
|
||||
int numFragments = totalSize / _fragmentSize;
|
||||
if (numFragments * _fragmentSize < totalSize)
|
||||
|
||||
@@ -393,11 +393,10 @@ class SSU2Payload {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static class I2NPBlock extends Block {
|
||||
private final OutboundMessageState2 m;
|
||||
private final OutboundMessageState m;
|
||||
|
||||
public I2NPBlock(OutboundMessageState2 msg) {
|
||||
public I2NPBlock(OutboundMessageState msg) {
|
||||
super(BLOCK_I2NP);
|
||||
m = msg;
|
||||
}
|
||||
@@ -412,16 +411,14 @@ class SSU2Payload {
|
||||
return off + m.writeFragment(tgt, off, 0);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Same format as I2NPBlock
|
||||
*/
|
||||
/*
|
||||
public static class FirstFragBlock extends Block {
|
||||
private final OutboundMessageState2 m;
|
||||
private final OutboundMessageState m;
|
||||
|
||||
public FirstFragBlock(OutboundMessageState2 msg) {
|
||||
public FirstFragBlock(OutboundMessageState msg) {
|
||||
super(BLOCK_FIRSTFRAG);
|
||||
m = msg;
|
||||
}
|
||||
@@ -436,17 +433,15 @@ class SSU2Payload {
|
||||
return off + m.writeFragment(tgt, off, 0);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/*
|
||||
public static class FollowFragBlock extends Block {
|
||||
private final OutboundMessageState2 m;
|
||||
private final OutboundMessageState m;
|
||||
private final int f;
|
||||
|
||||
public FollowFragBlock(OutboundMessageState2 msg, int frag) {
|
||||
public FollowFragBlock(OutboundMessageState msg, int frag) {
|
||||
super(BLOCK_FOLLOWONFRAG);
|
||||
if (frag <= 0)
|
||||
throw new IllegalArgumentException();
|
||||
@@ -468,7 +463,6 @@ class SSU2Payload {
|
||||
return off + m.writeFragment(tgt, off, 0);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static class PaddingBlock extends Block {
|
||||
private final int sz;
|
||||
|
||||
Reference in New Issue
Block a user