FileDocCategorySizeDatePackage
DHTUDPPacketReply.javaAPI DocAzureus 3.0.3.45041Thu Jan 11 07:45:38 GMT 2007com.aelitis.azureus.core.dht.transport.udp.impl

DHTUDPPacketReply

public class DHTUDPPacketReply extends com.aelitis.net.udp.uc.PRUDPPacketReply implements DHTUDPPacket
author
parg

Fields Summary
public static final int
DHT_HEADER_SIZE
private DHTTransportUDPImpl
transport
private long
connection_id
private byte
protocol_version
private byte
vendor_id
private int
network
private int
target_instance_id
private long
skew
private DHTNetworkPosition[]
network_positions
Constructors Summary
public DHTUDPPacketReply(DHTTransportUDPImpl _transport, int _type, int _trans_id, long _conn_id, com.aelitis.azureus.core.dht.transport.DHTTransportContact _local_contact, com.aelitis.azureus.core.dht.transport.DHTTransportContact _remote_contact)

	
	
	
			
							
							
						
			
			 
	
		super( _type, _trans_id );
		
		transport	= _transport;
		
		connection_id	= _conn_id;
		
		protocol_version			= _remote_contact.getProtocolVersion();
		
			// the target might be at a higher protocol version that us, so trim back if necessary
			// as we obviously can't talk a higher version than what we are!
	
		if ( protocol_version > _transport.getProtocolVersion()){
						
			protocol_version = _transport.getProtocolVersion();
		}
		
		target_instance_id	= _local_contact.getInstanceID();
		
		skew	= _local_contact.getClockSkew();
	
protected DHTUDPPacketReply(com.aelitis.azureus.core.dht.transport.udp.impl.packethandler.DHTUDPPacketNetworkHandler network_handler, DataInputStream is, int type, int trans_id)

		super( type, trans_id );
		
		connection_id 	= is.readLong();
		
		protocol_version			= is.readByte();
					
		if ( protocol_version < DHTTransportUDP.PROTOCOL_VERSION_MIN ){
			
			throw( new IOException( "Invalid DHT protocol version, please update Azureus" ));
		}
		
		if ( protocol_version >= DHTTransportUDP.PROTOCOL_VERSION_VENDOR_ID ){
	
			vendor_id	= is.readByte();
		}
		
		if ( protocol_version >= DHTTransportUDP.PROTOCOL_VERSION_NETWORKS ){
			
			network	= is.readInt();
		}

			// we can only get the correct transport after decoding the network...
		
		transport = network_handler.getTransport( this );

		target_instance_id	= is.readInt();
	
Methods Summary
protected longgetClockSkew()

		return( skew );
	
public longgetConnectionId()

		return( connection_id );
	
public intgetNetwork()

		return( network );
	
protected DHTNetworkPosition[]getNetworkPositions()

		return( network_positions );
	
public bytegetProtocolVersion()

		return( protocol_version );
	
public java.lang.StringgetString()

		return( super.getString() + ",[con="+connection_id+",prot=" + protocol_version + ",ven=" + vendor_id + ",net="+network+"]");
	
protected intgetTargetInstanceID()

		return( target_instance_id );
	
public DHTTransportUDPImplgetTransport()

		return( transport );
	
protected bytegetVendorID()

		return( vendor_id );
	
public voidserialise(java.io.DataOutputStream os)

		super.serialise(os);
	
			// add to this and you need to adjust HEADER_SIZE above
		
		os.writeLong( connection_id );
		
		os.writeByte( protocol_version );
		
		if ( protocol_version >= DHTTransportUDP.PROTOCOL_VERSION_VENDOR_ID ){
						
			os.writeByte( DHTTransportUDP.VENDOR_ID_ME );
		}
		
		if ( protocol_version >= DHTTransportUDP.PROTOCOL_VERSION_NETWORKS ){
			
			os.writeInt( network );
		}
		
		os.writeInt( target_instance_id );
	
public voidsetNetwork(int _network)

		network	= _network;
	
protected voidsetNetworkPositions(DHTNetworkPosition[] _network_positions)

		network_positions = _network_positions;