/** what IP Alice is reachable on */ public int readPort() { int offset = readBodyOffset() + NONCE_LENGTH; int size = _message[offset] & 0xff; offset++; offset += size; // skip the IP return (int)DataHelper.fromLong(_message, offset, 2); }
/** * What tunnel ID the next hop receives messages on. If this is the outbound tunnel endpoint, * this specifies the tunnel ID to which the reply should be sent. */ public long readNextTunnelId() { return DataHelper.fromLong(_data, OFF_SEND_TUNNEL, 4); }
/** * What message ID should we send the request to the next hop with. If this is the outbound tunnel endpoint, * this specifies the message ID with which the reply should be sent. */ public long readReplyMessageId() { return DataHelper.fromLong(_data, OFF_SEND_MSG_ID, 4); }
public int readPort() { int offset = readBodyOffset(); offset += _message[offset] & 0xff; offset++; return (int)DataHelper.fromLong(_message, offset, 2); }
public long readNonce() { int offset = readBodyOffset(); offset += _message[offset] & 0xff; offset += 1 + 2; int sz = _message[offset] & 0xff; offset += 1 + 2; // sz + port offset += sz; return DataHelper.fromLong(_message, offset, 4); } }
public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException { if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message"); int curIndex = offset; _id = DataHelper.fromLong(data, curIndex, 4); curIndex += 4; _arrival = DataHelper.fromLong(data, curIndex, DataHelper.DATE_LENGTH); }
/** * @since 0.8.9 */ private static Integer getReverseKey(Hash hash) { byte[] hashBytes = hash.getData(); int i = (int) DataHelper.fromLong(hashBytes, 0, 4); return Integer.valueOf(i); }
/** * Overridden for efficiency. * @param data non-null * @throws DataFormatException if null or wrong length */ @Override public void fromByteArray(byte data[]) throws DataFormatException { if (data == null) throw new DataFormatException("Null data passed in"); if (data.length != 8) throw new DataFormatException("Bad data length"); _flags = (int) DataHelper.fromLong(data, 0, 2); _date = DataHelper.fromLong(data, 2, 6); }
/** what port do they think we are coming from? */ public int readPort() { int offset = readBodyOffset() + Y_LENGTH + 1 + readIPSize(); return (int)DataHelper.fromLong(_message, offset, 2); }
private static TunnelId getTunnel(byte id[]) { if (id == null) return null; else return new TunnelId(DataHelper.fromLong(id, 0, id.length)); }
/** read in the 4 byte relayAs tag */ public long readRelayTag() { int offset = readBodyOffset() + Y_LENGTH + 1 + readIPSize() + 2; return DataHelper.fromLong(_message, offset, 4); }
public long readACK(int index) { if (!readACKsIncluded()) return -1; int off = readBodyOffset() + 1; //int num = (int)DataHelper.fromLong(_message, off, 1); off++; return DataHelper.fromLong(_message, off + (4 * index), 4); }
public int readMessageFragmentSize(int fragmentNum) throws DataFormatException { int off = getFragmentBegin(fragmentNum); off += 5; // messageId + fragment info return ((int)DataHelper.fromLong(_message, off, 2)) & 0x3FFF; }
public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException { if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message"); int curIndex = offset; long len = DataHelper.fromLong(data, curIndex, 4); curIndex += 4; if ( (len <= 0) || (len > MAX_SIZE) ) throw new I2NPMessageException("size="+len); _data = new byte[(int)len]; System.arraycopy(data, curIndex, _data, 0, (int)len); }
public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException { if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message"); int curIndex = offset; long size = DataHelper.fromLong(data, curIndex, 4); curIndex += 4; if (size > MAX_SIZE) throw new I2NPMessageException("too large msg, size=" + size); _data = new byte[(int)size]; System.arraycopy(data, curIndex, _data, 0, (int)size); }
public void toRawString(StringBuilder buf) throws DataFormatException { UDPPacketReader.this.toRawString(buf); buf.append(" payload: "); int off = getFragmentBegin(0); // first fragment off += 4 + 1; // messageId + fragment info int size = ((int)DataHelper.fromLong(_message, off, 2)) & 0x3FFF; off += 2; buf.append(Base64.encode(_message, off, size)); } }
/** * Overridden for efficiency. * @param data non-null * @throws DataFormatException if null or wrong length */ @Override public void fromByteArray(byte data[]) throws DataFormatException { if (data == null) throw new DataFormatException("Null data passed in"); if (data.length != 4) throw new DataFormatException("Bad data length"); _tunnelId = (int) DataHelper.fromLong(data, 0, 4); }
public int readPort() { int offset = readBodyOffset() + 4; offset += _message[offset] & 0xff; offset++; int rv = (int)DataHelper.fromLong(_message, offset, 2); if (_log.shouldLog(Log.DEBUG)) _log.debug("read alice port: " + rv); return rv; }
/** * Read the time at which the signature was generated. * TODO must be completely in final fragment. * Time and sig cannot be split across fragments. */ public long readFinalFragmentSignedOnTime() { if (readCurrentFragmentNum() != readTotalFragmentNum()-1) throw new IllegalStateException("This is not the final fragment"); int readOffset = readBodyOffset() + 1 + 2 + readCurrentFragmentSize(); return DataHelper.fromLong(_message, readOffset, 4); }
public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException { if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message"); int curIndex = offset; _now = DataHelper.fromLong(data, curIndex, DataHelper.DATE_LENGTH); }