Changeset a3b55cc


Ignore:
Timestamp:
Nov 8, 2015 4:43:49 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
63ddf11
Parents:
8e77188
Message:

cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/udp/PacketBuilder.java

    r8e77188 ra3b55cc  
    5858the following bitfields:</p>
    5959<pre>
    60   bits 0-3: payload type
    61      bit 4: rekey?
    62      bit 5: extended options included
    63   bits 6-7: reserved
     60Bit order: 76543210
     61  bits 7-4: payload type
     62     bit 3: rekey?
     63     bit 2: extended options included
     64  bits 1-0: reserved
    6465</pre>
    6566
     
    167168    private static final boolean DEFAULT_ENABLE_PADDING = true;
    168169
     170    /**
     171     *  The nine message types, 0-8, shifted to bits 7-4 for convenience
     172     */
     173    private static final byte SESSION_REQUEST_FLAG_BYTE = UDPPacket.PAYLOAD_TYPE_SESSION_REQUEST << 4;
     174    private static final byte SESSION_CREATED_FLAG_BYTE = UDPPacket.PAYLOAD_TYPE_SESSION_CREATED << 4;
     175    private static final byte SESSION_CONFIRMED_FLAG_BYTE = UDPPacket.PAYLOAD_TYPE_SESSION_CONFIRMED << 4;
     176    private static final byte PEER_RELAY_REQUEST_FLAG_BYTE = UDPPacket.PAYLOAD_TYPE_RELAY_REQUEST << 4;
     177    private static final byte PEER_RELAY_RESPONSE_FLAG_BYTE = UDPPacket.PAYLOAD_TYPE_RELAY_RESPONSE << 4;
     178    private static final byte PEER_RELAY_INTRO_FLAG_BYTE = UDPPacket.PAYLOAD_TYPE_RELAY_INTRO << 4;
     179    private static final byte DATA_FLAG_BYTE = UDPPacket.PAYLOAD_TYPE_DATA << 4;
     180    private static final byte PEER_TEST_FLAG_BYTE = UDPPacket.PAYLOAD_TYPE_TEST << 4;
     181    private static final byte SESSION_DESTROY_FLAG_BYTE = (byte) (UDPPacket.PAYLOAD_TYPE_SESSION_DESTROY << 4);
     182   
    169183    /**
    170184     *  @param transport may be null for unit testing only
     
    333347
    334348        // make the packet
    335         UDPPacket packet = buildPacketHeader((byte)(UDPPacket.PAYLOAD_TYPE_DATA << 4));
     349        UDPPacket packet = buildPacketHeader(DATA_FLAG_BYTE);
    336350        DatagramPacket pkt = packet.getPacket();
    337351        byte data[] = pkt.getData();
     
    574588     */
    575589    public UDPPacket buildACK(PeerState peer, List<ACKBitfield> ackBitfields) {
    576         UDPPacket packet = buildPacketHeader((byte)(UDPPacket.PAYLOAD_TYPE_DATA << 4));
     590        UDPPacket packet = buildPacketHeader(DATA_FLAG_BYTE);
    577591        DatagramPacket pkt = packet.getPacket();
    578592        byte data[] = pkt.getData();
     
    668682    }
    669683   
    670     /**
    671      * full flag info for a sessionCreated message.  this can be fixed,
    672      * since we never rekey on startup, and don't need any extended options
    673      */
    674     private static final byte SESSION_CREATED_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_SESSION_CREATED << 4);
    675    
    676684    /**
    677685     * Build a new SessionCreated packet for the given peer, encrypting it
     
    769777    }
    770778   
    771     /**
    772      * full flag info for a sessionRequest message.  this can be fixed,
    773      * since we never rekey on startup, and don't need any extended options
    774      */
    775     private static final byte SESSION_REQUEST_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_SESSION_REQUEST << 4);
    776    
    777779    /**
    778780     * Build a new SessionRequest packet for the given peer, encrypting it
     
    855857    }
    856858
    857    
    858     /**
    859      * full flag info for a sessionConfirmed message.  this can be fixed,
    860      * since we never rekey on startup, and don't need any extended options
    861      */
    862     private static final byte SESSION_CONFIRMED_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_SESSION_CONFIRMED << 4);
    863    
    864859    /**
    865860     * Build a new SessionConfirmed packet for the given peer
     
    10191014     */
    10201015    private UDPPacket buildSessionDestroyPacket(SessionKey cipherKey, SessionKey macKey, InetAddress addr, int port) {
    1021         UDPPacket packet = buildPacketHeader((byte)(UDPPacket.PAYLOAD_TYPE_SESSION_DESTROY << 4));
     1016        UDPPacket packet = buildPacketHeader(SESSION_DESTROY_FLAG_BYTE);
    10221017        int off = HEADER_SIZE;
    10231018       
     
    10351030    }
    10361031   
    1037     /**
    1038      * full flag info for a peerTest message.  this can be fixed,
    1039      * since we never rekey on test, and don't need any extended options
    1040      */
    1041     private static final byte PEER_TEST_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_TEST << 4);
    1042 
    10431032    /**
    10441033     * Build a packet as if we are Alice and we either want Bob to begin a
     
    11981187        return packet;
    11991188    }
    1200    
    1201     /**
    1202      * full flag info for a relay request message.  this can be fixed,
    1203      * since we never rekey on relay request, and don't need any extended options
    1204      */
    1205     private static final byte PEER_RELAY_REQUEST_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_RELAY_REQUEST << 4);
    12061189
    12071190    // specify these if we know what our external receive ip/port is and if its different
     
    13311314    }
    13321315
    1333     /**
    1334      * full flag info for a relay intro message.  this can be fixed,
    1335      * since we never rekey on relay request, and don't need any extended options
    1336      */
    1337     private static final byte PEER_RELAY_INTRO_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_RELAY_INTRO << 4);
    1338    
    13391316    UDPPacket buildRelayIntro(RemoteHostId alice, PeerState charlie, UDPPacketReader.RelayRequestReader request) {
    13401317        UDPPacket packet = buildPacketHeader(PEER_RELAY_INTRO_FLAG_BYTE);
     
    13711348        return packet;
    13721349    }
    1373 
    1374     /**
    1375      * full flag info for a relay response message.  this can be fixed,
    1376      * since we never rekey on relay response, and don't need any extended options
    1377      */
    1378     private static final byte PEER_RELAY_RESPONSE_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_RELAY_RESPONSE << 4);
    13791350   
    13801351    UDPPacket buildRelayResponse(RemoteHostId alice, PeerState charlie, long nonce,
Note: See TracChangeset for help on using the changeset viewer.