Changeset a3b55cc
- Timestamp:
- Nov 8, 2015 4:43:49 PM (5 years ago)
- Branches:
- master
- Children:
- 63ddf11
- Parents:
- 8e77188
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
router/java/src/net/i2p/router/transport/udp/PacketBuilder.java
r8e77188 ra3b55cc 58 58 the following bitfields:</p> 59 59 <pre> 60 bits 0-3: payload type 61 bit 4: rekey? 62 bit 5: extended options included 63 bits 6-7: reserved 60 Bit order: 76543210 61 bits 7-4: payload type 62 bit 3: rekey? 63 bit 2: extended options included 64 bits 1-0: reserved 64 65 </pre> 65 66 … … 167 168 private static final boolean DEFAULT_ENABLE_PADDING = true; 168 169 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 169 183 /** 170 184 * @param transport may be null for unit testing only … … 333 347 334 348 // make the packet 335 UDPPacket packet = buildPacketHeader( (byte)(UDPPacket.PAYLOAD_TYPE_DATA << 4));349 UDPPacket packet = buildPacketHeader(DATA_FLAG_BYTE); 336 350 DatagramPacket pkt = packet.getPacket(); 337 351 byte data[] = pkt.getData(); … … 574 588 */ 575 589 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); 577 591 DatagramPacket pkt = packet.getPacket(); 578 592 byte data[] = pkt.getData(); … … 668 682 } 669 683 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 options673 */674 private static final byte SESSION_CREATED_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_SESSION_CREATED << 4);675 676 684 /** 677 685 * Build a new SessionCreated packet for the given peer, encrypting it … … 769 777 } 770 778 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 options774 */775 private static final byte SESSION_REQUEST_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_SESSION_REQUEST << 4);776 777 779 /** 778 780 * Build a new SessionRequest packet for the given peer, encrypting it … … 855 857 } 856 858 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 options861 */862 private static final byte SESSION_CONFIRMED_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_SESSION_CONFIRMED << 4);863 864 859 /** 865 860 * Build a new SessionConfirmed packet for the given peer … … 1019 1014 */ 1020 1015 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); 1022 1017 int off = HEADER_SIZE; 1023 1018 … … 1035 1030 } 1036 1031 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 options1040 */1041 private static final byte PEER_TEST_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_TEST << 4);1042 1043 1032 /** 1044 1033 * Build a packet as if we are Alice and we either want Bob to begin a … … 1198 1187 return packet; 1199 1188 } 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 options1204 */1205 private static final byte PEER_RELAY_REQUEST_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_RELAY_REQUEST << 4);1206 1189 1207 1190 // specify these if we know what our external receive ip/port is and if its different … … 1331 1314 } 1332 1315 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 options1336 */1337 private static final byte PEER_RELAY_INTRO_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_RELAY_INTRO << 4);1338 1339 1316 UDPPacket buildRelayIntro(RemoteHostId alice, PeerState charlie, UDPPacketReader.RelayRequestReader request) { 1340 1317 UDPPacket packet = buildPacketHeader(PEER_RELAY_INTRO_FLAG_BYTE); … … 1371 1348 return packet; 1372 1349 } 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 options1377 */1378 private static final byte PEER_RELAY_RESPONSE_FLAG_BYTE = (UDPPacket.PAYLOAD_TYPE_RELAY_RESPONSE << 4);1379 1350 1380 1351 UDPPacket buildRelayResponse(RemoteHostId alice, PeerState charlie, long nonce,
Note: See TracChangeset
for help on using the changeset viewer.