FileDocCategorySizeDatePackage
NetworkAdminNATUDPCodecs.javaAPI DocAzureus 3.0.3.43153Wed Nov 29 12:54:04 GMT 2006com.aelitis.azureus.core.networkmanager.admin.impl

NetworkAdminNATUDPCodecs

public class NetworkAdminNATUDPCodecs extends Object

Fields Summary
public static final int
ACT_NAT_REQUEST
public static final int
ACT_NAT_REPLY
private static boolean
registered
Constructors Summary
Methods Summary
public static voidregisterCodecs()

	
	
		registerCodecs();
	
		if ( registered ){
			
			return;
		}
	
		registered	= true;
		
		PRUDPPacketReplyDecoder	reply_decoder =
			new PRUDPPacketReplyDecoder()
			{
				public PRUDPPacketReply
				decode(
					PRUDPPacketHandler	handler,
					DataInputStream		is,
					int					action,
					int					transaction_id )
				
					throws IOException
				{
					switch( action ){
					
						case ACT_NAT_REPLY:
						{
							return( new NetworkAdminNATUDPReply(is, transaction_id ));
						}
						default:
						{
							throw( new IOException( "Unrecognised action '" + action + "'" ));
						}
					}
				}
			};
					
		Map	reply_decoders = new HashMap();
		
		reply_decoders.put( new Integer( ACT_NAT_REPLY ), reply_decoder );
		
		PRUDPPacketReply.registerDecoders( reply_decoders );
		
		PRUDPPacketRequestDecoder	request_decoder =
			new PRUDPPacketRequestDecoder()
			{
				public PRUDPPacketRequest
				decode(
					PRUDPPacketHandler	handler,
					DataInputStream		is,
					long				connection_id,
					int					action,
					int					transaction_id )
				
					throws IOException
				{
					switch( action ){
						case ACT_NAT_REQUEST:
						{
							return( new NetworkAdminNATUDPRequest(is, connection_id, transaction_id ));
						}
						default:
						{
							throw( new IOException( "unsupported request type"));
						}
					}
				}
			};

		Map	request_decoders = new HashMap();
		
		request_decoders.put( new Integer( ACT_NAT_REQUEST ), request_decoder );
		
		PRUDPPacketRequest.registerDecoders( request_decoders );