- if (evbuffer_get_length(evb)<4)
- return_log("socket layer weird: datagram shorter than 4 bytes from %s (prob ICMP unreach)\n",addr.str());
- uint32_t mych = evbuffer_remove_32be(evb);
- Sha1Hash hash;
- Channel* channel = NULL;
- if (mych==0) { // peer initiates handshake
- if (evbuffer_get_length(evb)<1+4+1+4+Sha1Hash::SIZE)
- return_log ("%s #0 incorrect size %i initial handshake packet %s\n",
- tintstr(),(int)evbuffer_get_length(evb),addr.str());
- uint8_t hashid = evbuffer_remove_8(evb);
- if (hashid!=SWIFT_HASH)
- return_log ("%s #0 no hash in the initial handshake %s\n",
- tintstr(),addr.str());
- bin_t pos = bin_fromUInt32(evbuffer_remove_32be(evb));
- if (!pos.is_all())
- return_log ("%s #0 that is not the root hash %s\n",tintstr(),addr.str());
- hash = evbuffer_remove_hash(evb);
- FileTransfer* ft = FileTransfer::Find(hash);
- if (!ft)
- return_log ("%s #0 hash %s unknown, requested by %s\n",tintstr(),hash.hex().c_str(),addr.str());
- dprintf("%s #0 -hash ALL %s\n",tintstr(),hash.hex().c_str());
-
- // Arno, 2012-02-27: Check for duplicate channel
- Channel* existchannel = ft->FindChannel(addr,NULL);
- if (existchannel)
- {
- // Arno: 2011-10-13: Ignore if established, otherwise consider
- // it a concurrent connection attempt.
- if (existchannel->is_established()) {
- // ARNOTODO: Read complete handshake here so we know whether
- // attempt is to new channel or to existing. Currently read
- // in OnHandshake()
- //
- return_log("%s #0 have a channel already to %s\n",tintstr(),addr.str());
- } else {
- channel = existchannel;
- //fprintf(stderr,"Channel::RecvDatagram: HANDSHAKE: reuse channel %s\n", channel->peer_.str() );
+ if (evbuffer_get_length(evb)<4)
+ return_log("socket layer weird: datagram shorter than 4 bytes from %s (prob ICMP unreach)\n",addr.str());
+ uint32_t mych = evbuffer_remove_32be(evb);
+ Sha1Hash hash;
+ Channel* channel = NULL;
+ if (mych==0) { // peer initiates handshake
+ if (evbuffer_get_length(evb)<1+4+1+4+Sha1Hash::SIZE)
+ return_log ("%s #0 incorrect size %i initial handshake packet %s\n",
+ tintstr(),(int)evbuffer_get_length(evb),addr.str());
+ uint8_t hashid = evbuffer_remove_8(evb);
+ if (hashid!=SWIFT_HASH)
+ return_log ("%s #0 no hash in the initial handshake %s\n",
+ tintstr(),addr.str());
+ bin_t pos = bin_fromUInt32(evbuffer_remove_32be(evb));
+ if (!pos.is_all())
+ return_log ("%s #0 that is not the root hash %s\n",tintstr(),addr.str());
+ hash = evbuffer_remove_hash(evb);
+ FileTransfer* ft = FileTransfer::Find(hash);
+ if (!ft)
+ return_log ("%s #0 hash %s unknown, requested by %s\n",tintstr(),hash.hex().c_str(),addr.str());
+ dprintf("%s #0 -hash ALL %s\n",tintstr(),hash.hex().c_str());
+
+ // Arno, 2012-02-27: Check for duplicate channel
+ Channel* existchannel = ft->FindChannel(addr,NULL);
+ if (existchannel)
+ {
+ // Arno: 2011-10-13: Ignore if established, otherwise consider
+ // it a concurrent connection attempt.
+ if (existchannel->is_established()) {
+ // ARNOTODO: Read complete handshake here so we know whether
+ // attempt is to new channel or to existing. Currently read
+ // in OnHandshake()
+ //
+ return_log("%s #0 have a channel already to %s\n",tintstr(),addr.str());
+ } else {
+ channel = existchannel;
+ //fprintf(stderr,"Channel::RecvDatagram: HANDSHAKE: reuse channel %s\n", channel->peer_.str() );
+ }