public void readBytes(InputStream in) throws DataFormatException, IOException { _severityId = (int) DataHelper.readLong(in, 1); }
public void readBytes(InputStream in) throws DataFormatException, IOException { _messageId = DataHelper.readLong(in, 4); }
public void readBytes(InputStream in) throws DataFormatException, IOException { _tunnelId = DataHelper.readLong(in, 4); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = (int) DataHelper.readLong(in, 2); _messageId = DataHelper.readLong(in, 4); _status = (int) DataHelper.readLong(in, 1); _size = DataHelper.readLong(in, 4); _nonce = DataHelper.readLong(in, 4); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
/** * @throws IllegalStateException if already set */ public void readBytes(InputStream in) throws DataFormatException, IOException { if (_sessionId >= 0) throw new IllegalStateException(); _sessionId = (int) DataHelper.readLong(in, 2); }
/** Read in a date from the stream as specified by the I2P data structure spec. * A date is an 8 byte unsigned integer in network byte order specifying the number of * milliseconds since midnight on January 1, 1970 in the GMT timezone. If the number is * 0, the date is undefined or null. (yes, this means you can't represent midnight on 1/1/1970) * @param in stream to read from * @throws DataFormatException if the stream doesn't contain a validly formatted date * @throws IOException if there is an IO error reading the date * @return date read, or null */ public static Date readDate(InputStream in) throws DataFormatException, IOException { long date = readLong(in, DATE_LENGTH); if (date == 0L) return null; return new Date(date); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = (int) DataHelper.readLong(in, 2); _messageId = DataHelper.readLong(in, 4); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = (int) DataHelper.readLong(in, 2); _messageId = DataHelper.readLong(in, 4); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
protected void readHeader(InputStream in) throws DataFormatException, IOException { _destination = Destination.create(in); _published = DataHelper.readLong(in, 4) * 1000; _expires = _published + (DataHelper.readLong(in, 2) * 1000); _flags = (int) DataHelper.readLong(in, 2); if (isOffline()) readOfflineBytes(in); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { for (int i = 0; i < LIMITS; i++) { data[i] = (int) DataHelper.readLong(in, 4); } } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override public void readBytes(InputStream in) throws DataFormatException, IOException { _gateway = Hash.create(in); // flags DataHelper.skip(in, 2); _type = in.read(); _cost = in.read(); _end = new Date(DataHelper.readLong(in, 4) * 1000); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = (int) DataHelper.readLong(in, 2); _messageId = DataHelper.readLong(in, 4); _payload = new Payload(); _payload.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _reqID = DataHelper.readLong(in, 4); _code = (int) DataHelper.readLong(in, 1); if (_code == RESULT_SUCCESS) _dest = Destination.create(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("bad data", dfe); } }
@Override public void readBytes(InputStream in) throws DataFormatException, IOException { _gateway = Hash.create(in); _tunnelId = new TunnelId(); _tunnelId.readBytes(in); _end = new Date(DataHelper.readLong(in, 4) * 1000); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _status = (int) DataHelper.readLong(in, 1); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
public void readBytes(InputStream in) throws DataFormatException, IOException { int size = (int) DataHelper.readLong(in, 4); if (size < 0 || size > MAX_LENGTH) throw new DataFormatException("payload size out of range (" + size + ")"); _encryptedData = new byte[size]; int read = read(in, _encryptedData); if (read != size) throw new DataFormatException("Incorrect number of bytes read in the payload structure"); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("read payload: " + read + " bytes"); }
protected void readOfflineBytes(InputStream in) throws DataFormatException, IOException { _transientExpires = DataHelper.readLong(in, 4) * 1000; int itype = (int) DataHelper.readLong(in, 2); SigType type = SigType.getByCode(itype); if (type == null) throw new DataFormatException("Unknown sig type " + itype); _transientSigningPublicKey = new SigningPublicKey(type); _transientSigningPublicKey.readBytes(in); SigType stype = _destination.getSigningPublicKey().getType(); _offlineSignature = new Signature(stype); _offlineSignature.readBytes(in); }
/** * Overridden because we have a blinded key, not a dest */ @Override protected void readOfflineBytes(InputStream in) throws DataFormatException, IOException { _transientExpires = DataHelper.readLong(in, 4) * 1000; int itype = (int) DataHelper.readLong(in, 2); SigType type = SigType.getByCode(itype); if (type == null) throw new DataFormatException("Unknown sig type " + itype); _transientSigningPublicKey = new SigningPublicKey(type); _transientSigningPublicKey.readBytes(in); SigType stype = _signingKey.getType(); _offlineSignature = new Signature(stype); _offlineSignature.readBytes(in); }
@Test public void testLong() throws Exception{ byte[] temp = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataHelper.writeLong(baos, 4, 42); temp = baos.toByteArray(); long l; ByteArrayInputStream bais = new ByteArrayInputStream(temp); l = DataHelper.readLong(bais, 4); assertEquals(42, l); } }