Gnutella, PHP, and QRT

"Atomical" <[email protected]> Sun, 12 Oct 2008 01:46:38 -0000
Newsgroups gmane.network.gnutella.devel
Message-ID <[email protected]>
I'm not sure if this is the right group for this, although I haven't
had much success elsewhere so I hope this will do.  I'm writing a
Gnutella client in PHP.  I'm having some problems generating QRT
tables though.   I hashed the values by passing values with java since
PHP can't emulate 64-bit and my computer doesn't run at 64-bit.  I'm
probably doing something horribly that will be easy to point out.

Java Code:

    public static void main(String args[]) {
    int a;
    int count =0;
    	for ( String s: args ) {
         a = hash(args[count++], (byte)8);
            System.out.println(a);
     	}


PHP Code:


    	//write QRP reset message
    	$variant = "\0x0";
    	$table_length = pack('V',1024);
    	$infinity = "\0x01";
    	$packet = $variant . $table_length . $infinity;
    	$reset = create_header( "\0x30", "\0x01","\0x0", $packet );
    	
  		fwrite($fp, $reset,strlen($reset));
   

    	//4 kilobyte
    	$byte = '';
    	for ( $o = 0; $o < 1024/*(1024*4)*/; $o++){
    		$byte .= pack('C',$stored_table[$o]);
    	}


    //this is the message that contains all the bytes
    		$variant = "\0x01";
    		$seq_no = "\0x01";
    		echo "Patch 1 of 1\n";
    		$seq_size = "\0x01"; //bits
    		$compressor = "\0x0";
    		$entry_bits = "\0x08";
    		$packet = $variant . $seq_no . $seq_size . $compressor .
$entry_bits . $byte;
    		
    		$packet = create_header("\0x30","\0x01","\0x0",$packet);
  			
  			fwrite($fp,$packet, strlen($packet));