1 /* 2 * Created on 21-Jan-2005 3 * Created by Paul Gardner 4 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 package com.aelitis.azureus.core.dht.transport.udp; 21 22 import java.net.InetSocketAddress; 23 import java.util.Map; 24 25 import org.gudy.azureus2.core3.config.COConfigurationManager; 26 27 import com.aelitis.azureus.core.dht.transport.DHTTransport; 28 import com.aelitis.azureus.core.dht.transport.DHTTransportAlternativeNetwork; 29 import com.aelitis.azureus.core.dht.transport.DHTTransportException; 30 import com.aelitis.azureus.core.dht.transport.udp.impl.packethandler.DHTUDPPacketHandler; 31 import com.aelitis.azureus.core.dht.transport.udp.impl.packethandler.DHTUDPRequestHandler; 32 33 /** 34 * @author parg 35 * 36 */ 37 38 public interface 39 DHTTransportUDP 40 extends DHTTransport 41 { 42 public static final byte PROTOCOL_VERSION_2304 = 8; 43 public static final byte PROTOCOL_VERSION_2306 = 12; 44 public static final byte PROTOCOL_VERSION_2400 = 13; 45 public static final byte PROTOCOL_VERSION_2402 = 14; 46 public static final byte PROTOCOL_VERSION_2500 = 15; 47 public static final byte PROTOCOL_VERSION_2502 = 16; 48 public static final byte PROTOCOL_VERSION_3111 = 17; 49 public static final byte PROTOCOL_VERSION_4204 = 22; // min -> 17 50 public static final byte PROTOCOL_VERSION_4208 = 23; 51 public static final byte PROTOCOL_VERSION_4310 = 26; // somewhere min has gone to 22 52 public static final byte PROTOCOL_VERSION_4407 = 50; // cvs 53 public static final byte PROTOCOL_VERSION_4511 = 50; // main 54 public static final byte PROTOCOL_VERSION_4600 = 50; // min -> 50 55 public static final byte PROTOCOL_VERSION_4720 = 50; 56 public static final byte PROTOCOL_VERSION_4800 = 51; 57 public static final byte PROTOCOL_VERSION_5400 = 52; 58 public static final byte PROTOCOL_VERSION_5500 = 52; // min -> 51 59 60 public static final byte PROTOCOL_VERSION_DIV_AND_CONT = 6; 61 public static final byte PROTOCOL_VERSION_ANTI_SPOOF = 7; 62 public static final byte PROTOCOL_VERSION_ENCRYPT_TT = 8; // refed from DDBase 63 public static final byte PROTOCOL_VERSION_ANTI_SPOOF2 = 8; 64 65 // we can't fix the originator position until a previous fix regarding the incorrect 66 // use of a contact's version > sender's version is fixed. This will be done at 2.3.0.4 67 // We can therefore only apply this fix after then 68 69 public static final byte PROTOCOL_VERSION_FIX_ORIGINATOR = 9; 70 public static final byte PROTOCOL_VERSION_VIVALDI = 10; 71 public static final byte PROTOCOL_VERSION_REMOVE_DIST_ADD_VER = 11; 72 public static final byte PROTOCOL_VERSION_XFER_STATUS = 12; 73 public static final byte PROTOCOL_VERSION_SIZE_ESTIMATE = 13; 74 public static final byte PROTOCOL_VERSION_VENDOR_ID = 14; 75 public static final byte PROTOCOL_VERSION_BLOCK_KEYS = 14; 76 77 public static final byte PROTOCOL_VERSION_GENERIC_NETPOS = 15; 78 public static final byte PROTOCOL_VERSION_VIVALDI_FINDVALUE = 16; 79 public static final byte PROTOCOL_VERSION_ANON_VALUES = 17; 80 public static final byte PROTOCOL_VERSION_CVS_FIX_OVERLOAD_V1 = 18; 81 public static final byte PROTOCOL_VERSION_CVS_FIX_OVERLOAD_V2 = 19; 82 public static final byte PROTOCOL_VERSION_MORE_STATS = 20; 83 public static final byte PROTOCOL_VERSION_CVS_FIX_OVERLOAD_V3 = 21; 84 public static final byte PROTOCOL_VERSION_MORE_NODE_STATUS = 22; 85 public static final byte PROTOCOL_VERSION_LONGER_LIFE = 23; 86 public static final byte PROTOCOL_VERSION_REPLICATION_CONTROL = 24; 87 public static final byte PROTOCOL_VERSION_REPLICATION_CONTROL2 = 25; 88 public static final byte PROTOCOL_VERSION_REPLICATION_CONTROL3 = 26; 89 90 91 public static final byte PROTOCOL_VERSION_RESTRICT_ID_PORTS = 32; // introduced now (2403/V15) to support possible future change to id allocation 92 // If/when introduced the min DHT version must be set to 15 at the same time 93 94 public static final byte PROTOCOL_VERSION_RESTRICT_ID_PORTS2 = 33; 95 public static final byte PROTOCOL_VERSION_RESTRICT_ID_PORTS2X = 34; // nothing new here - added to we can track CVS user's access to replication control 96 public static final byte PROTOCOL_VERSION_RESTRICT_ID_PORTS2Y = 35; // another one to track fix to broken rep factor handling 97 public static final byte PROTOCOL_VERSION_RESTRICT_ID_PORTS2Z = 36; // hopefully last one - needed to excluded nodes that don't support replication frequency 98 99 public static final byte PROTOCOL_VERSION_RESTRICT_ID3 = 50; // ip and port based restrictions 100 101 public static final byte PROTOCOL_VERSION_VIVALDI_OPTIONAL = 51; // optional vivaldi 102 public static final byte PROTOCOL_VERSION_PACKET_FLAGS = 51; // flags field added to request and reply packets 103 104 public static final byte PROTOCOL_VERSION_ALT_CONTACTS = 52; 105 public static final byte PROTOCOL_VERSION_PACKET_FLAGS2 = 53; // flags2 field added to request and reply packets 106 public static final byte PROTOCOL_VERSION_PROC_TIME = 54; // added local processing time (5713) 107 108 // multiple networks reformats the requests and therefore needs the above fix to work 109 110 public static final byte PROTOCOL_VERSION_NETWORKS = PROTOCOL_VERSION_FIX_ORIGINATOR; 111 112 // current versions 113 114 public static class 115 Helper{ 116 private static int explicit_min = COConfigurationManager.getIntParameter( "DHT.protocol.version.min", -1 ); 117 118 static byte getVersion( byte min )119 getVersion( 120 byte min ) 121 { 122 return( (byte)Math.max( explicit_min, min&0x00ff )); 123 } 124 } 125 126 public static final byte PROTOCOL_VERSION_MAIN = Helper.getVersion( PROTOCOL_VERSION_PROC_TIME ); 127 public static final byte PROTOCOL_VERSION_CVS = Helper.getVersion( PROTOCOL_VERSION_PROC_TIME ); 128 129 public static final byte PROTOCOL_VERSION_MIN = Helper.getVersion( PROTOCOL_VERSION_VIVALDI_OPTIONAL ); 130 public static final byte PROTOCOL_VERSION_MIN_CVS = Helper.getVersion( PROTOCOL_VERSION_VIVALDI_OPTIONAL ); 131 132 133 134 public static final byte VENDOR_ID_AELITIS = 0x00; 135 public static final byte VENDOR_ID_ShareNET = 0x01; // http://www.sharep2p.net/ 136 public static final byte VENDOR_ID_NONE = (byte)0xff; 137 138 public static final byte VENDOR_ID_ME = VENDOR_ID_AELITIS; 139 140 public DHTTransportUDPContact importContact( InetSocketAddress address, byte protocol_version, boolean is_bootstrap )141 importContact( 142 InetSocketAddress address, 143 byte protocol_version, 144 boolean is_bootstrap ) 145 146 throws DHTTransportException; 147 148 public DHTTransportUDPContact importContact( Map<String,Object> map )149 importContact( 150 Map<String,Object> map ) 151 152 throws DHTTransportException; 153 154 public DHTUDPRequestHandler getRequestHandler()155 getRequestHandler(); 156 157 public DHTUDPPacketHandler getPacketHandler()158 getPacketHandler(); 159 160 public DHTTransportAlternativeNetwork getAlternativeNetwork( int network_type )161 getAlternativeNetwork( 162 int network_type ); 163 164 public void registerAlternativeNetwork( DHTTransportAlternativeNetwork network )165 registerAlternativeNetwork( 166 DHTTransportAlternativeNetwork network ); 167 168 public void unregisterAlternativeNetwork( DHTTransportAlternativeNetwork network )169 unregisterAlternativeNetwork( 170 DHTTransportAlternativeNetwork network ); 171 } 172