class TrivialPreprocessor extends Object implements TunnelGateway.QueuePreprocessor
| Modifier and Type | Field and Description |
|---|---|
protected RouterContext | _contextThe router context |
protected static ByteCache | _dataCacheHere in tunnels, we take from the cache but never add to it. |
protected Log | _logThe logger |
protected static int | IV_SIZELength of the IV |
static int | PREPROCESSED_SIZESize of preprocessed data blocks |
| Constructor and Description |
|---|
TrivialPreprocessor(RouterContext ctx) |
| Modifier and Type | Method and Description |
|---|---|
long | getDelayAmount()how long do we want to wait before flushing |
protected static int | getInstructionAugmentationSize(PendingGatewayMessage msg,
int offset,
int instructionsSize)Get the augmentation size for instructions if fragmentation is needed. |
protected static int | getInstructionsSize(PendingGatewayMessage msg)Calculate the size of the instructions for a pending message. |
protected void | notePreprocessing(long messageId,
int numFragments,
int totalLength,
List<Long> messageIds,
String msg)Note preprocessing statistics. |
protected void | preprocess(byte[] fragments,
int fragmentLength)Wrap the preprocessed fragments with the necessary padding / checksums
to act as a tunnel message. |
boolean | preprocessQueue(List<PendingGatewayMessage> pending,
TunnelGateway.Sender sender,
TunnelGateway.Receiver rec)Return true if there were messages remaining, and we should queue up
a delayed flush to clear them
NOTE: Unused here, see BatchedPreprocessor override, super is not called. |
protected int | writeFirstFragment(PendingGatewayMessage msg,
byte[] target,
int offset)Write the first fragment of a tunnel message. |
protected int | writeSubsequentFragment(PendingGatewayMessage msg,
byte[] target,
int offset)Write a subsequent fragment of a tunnel message. |
protected final RouterContext _context
protected static final ByteCache _dataCache
protected final Log _log
protected static final int IV_SIZE
public static final int PREPROCESSED_SIZE
public TrivialPreprocessor(RouterContext ctx)
ctx - the router contextpublic long getDelayAmount()
getDelayAmount in interface TunnelGateway.QueuePreprocessorprotected static int getInstructionAugmentationSize(PendingGatewayMessage msg, int offset, int instructionsSize)
msg - the pending gateway messageoffset - the current offsetinstructionsSize - the current instructions sizeprotected static int getInstructionsSize(PendingGatewayMessage msg)
msg - the pending gateway messageprotected void notePreprocessing(long messageId,
int numFragments,
int totalLength,
List<Long> messageIds,
String msg)protected void preprocess(byte[] fragments,
int fragmentLength)fragments - the fragment datafragmentLength - fragments[0:fragmentLength] is usedpublic boolean preprocessQueue(List<PendingGatewayMessage> pending, TunnelGateway.Sender sender, TunnelGateway.Receiver rec)
preprocessQueue in interface TunnelGateway.QueuePreprocessorpending - list of Pending objects for messages either unsent
or partly sent. This list should be update with any
values removed (the preprocessor owns the lock)
Messages are not removed from the list until actually sent.
The status of unsent and partially-sent messages is stored in
the Pending structure.sender - the senderrec - the receiver to accept encrypted dataprotected int writeFirstFragment(PendingGatewayMessage msg, byte[] target, int offset)
msg - the pending gateway messagetarget - the targetoffset - the starting offsetprotected int writeSubsequentFragment(PendingGatewayMessage msg, byte[] target, int offset)
msg - the pending gateway messagetarget - the targetoffset - the starting offset