use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.
the class ActiveProfileBlock method getData.
@Override
public byte[] getData() {
ByteBuf byteBuf = new ByteBuf(2);
byteBuf.putShort(activeProfile.getValue());
return byteBuf.getBytes();
}
use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.
the class AppLayerProcessor method onInboundMessage.
@Override
public void onInboundMessage(Object message, Pipeline pipeline) throws Exception {
if (!(message instanceof DataMessage))
return;
DataMessage dataMessage = (DataMessage) message;
ByteBuf byteBuf = new ByteBuf(dataMessage.getData().length);
byteBuf.putBytes(dataMessage.getData());
AppLayerMessage appLayerMessage = AppLayerMessage.deserialize(byteBuf);
Log.d("SightService", "RECEIVE: " + appLayerMessage.getClass());
pipeline.receive(appLayerMessage);
Answers.getInstance().logCustom(new CustomEvent("Received Application Layer Message").putCustomAttribute("Message", appLayerMessage.getClass().getSimpleName()));
}
use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.
the class AuthLayerProcessor method onInboundMessage.
@Override
public void onInboundMessage(Object message, Pipeline pipeline) throws Exception {
if (!(message instanceof ByteBuf))
return;
ByteBuf data = (ByteBuf) message;
while (data.size() >= 37) {
int length = data.getUInt16LE(4);
if (data.size() < length + 8)
return;
try {
AuthLayerMessage authLayerMessage = AuthLayerMessage.deserialize(data, pipeline.getLastNonceReceived(), pipeline.getDerivedKeys() != null ? pipeline.getDerivedKeys().getIncomingKey() : null);
pipeline.setLastNonceReceived(authLayerMessage.getNonce());
pipeline.setCommID(authLayerMessage.getCommID());
pipeline.receive(authLayerMessage);
} catch (InvalidNonceError | InvalidAuthCRCError | InvalidTrailerError e) {
data.shift(data.size());
throw e;
}
}
}
use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.
the class ByteProcessor method onOutboundMessage.
@Override
public void onOutboundMessage(Object message, Pipeline pipeline) throws Exception {
if (!(message instanceof ByteBuf))
return;
ByteBuf data = (ByteBuf) message;
while (data.size() > 0) {
pipeline.getOutputStream().write(data.readBytes(data.size() >= 110 ? 110 : data.size()));
pipeline.getOutputStream().flush();
}
}
use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.
the class Cryptograph method produceCCMPrimitive.
private static byte[] produceCCMPrimitive(byte headerByte, byte[] nonce, short number) {
ByteBuf byteBuf = new ByteBuf(16);
byteBuf.putByte(headerByte);
byteBuf.putBytes(nonce);
byteBuf.putShort(number);
return byteBuf.getBytes();
}
Aggregations