Changeset 9b3eb8d for router


Ignore:
Timestamp:
Aug 4, 2018 3:16:21 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
21fe962
Parents:
a5a5f7d
Message:

I2NP: Change DeliveryInstructions? internal flags storage from long to int

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/data/i2np/DeliveryInstructions.java

    ra5a5f7d r9b3eb8d  
    5454    /** @deprecated unused */
    5555    @Deprecated
    56     private final static long FLAG_ENCRYPTED = 128;
    57     private final static long FLAG_MODE = 96;
    58     private final static long FLAG_DELAY = 16;
     56    private final static int FLAG_ENCRYPTED = 128;
     57    private final static int FLAG_MODE = 96;
     58    private final static int FLAG_DELAY = 16;
    5959   
    6060    /**
     
    242242   
    243243    /** high bits */
    244     private static int flagMode(long flags) {
    245         long v = flags & FLAG_MODE;
     244    private static int flagMode(int flags) {
     245        int v = flags & FLAG_MODE;
    246246        v >>>= 5;
    247247        return (int)v;
     
    249249   
    250250    /**  unused */
    251     private static boolean flagDelay(long flags) {
     251    private static boolean flagDelay(int flags) {
    252252        return (0 != (flags & FLAG_DELAY));
    253253    }
    254254   
    255     private long getFlags() {
    256         long val = 0L;
     255    private int getFlags() {
     256        int val = 0;
    257257     /****
    258258        if (getEncrypted())
    259259            val = val | FLAG_ENCRYPTED;
    260260      ****/
    261         long fmode = 0;
    262261        switch (getDeliveryMode()) {
    263262            case FLAG_MODE_LOCAL:
    264263                break;
    265264            case FLAG_MODE_DESTINATION:
    266                 fmode = FLAG_MODE_DESTINATION << 5;
     265                val = FLAG_MODE_DESTINATION << 5;
    267266                break;
    268267            case FLAG_MODE_ROUTER:
    269                 fmode = FLAG_MODE_ROUTER << 5;
     268                val = FLAG_MODE_ROUTER << 5;
    270269                break;
    271270            case FLAG_MODE_TUNNEL:
    272                 fmode = FLAG_MODE_TUNNEL << 5;
    273                 break;
    274         }
    275         val = val | fmode;
     271                val = FLAG_MODE_TUNNEL << 5;
     272                break;
     273        }
    276274        if (getDelayRequested())
    277             val = val | FLAG_DELAY;
     275            val |= FLAG_DELAY;
    278276        //if (_log.shouldLog(Log.DEBUG))
    279277        //    _log.debug("getFlags() = " + val);
     
    390388    public void writeBytes(OutputStream out) throws DataFormatException, IOException {
    391389        if ( (_deliveryMode < 0) || (_deliveryMode > FLAG_MODE_TUNNEL) ) throw new DataFormatException("Invalid data: mode = " + _deliveryMode);
    392         long flags = getFlags();
     390        int flags = getFlags();
    393391        //if (_log.shouldLog(Log.DEBUG))
    394392        //    _log.debug("Write flags: " + flags + " mode: " + getDeliveryMode()
     
    407405    public int writeBytes(byte target[], int offset) {
    408406        if ( (_deliveryMode < 0) || (_deliveryMode > FLAG_MODE_TUNNEL) ) throw new IllegalStateException("Invalid data: mode = " + _deliveryMode);
    409         long flags = getFlags();
     407        int flags = getFlags();
    410408        //if (_log.shouldLog(Log.DEBUG))
    411409        //    _log.debug("Write flags: " + flags + " mode: " + getDeliveryMode()
Note: See TracChangeset for help on using the changeset viewer.