[Gd-chatter] r11663 - trunk/libraries/protocols
hannes at gwydiondylan.org
hannes at gwydiondylan.org
Tue Feb 5 03:01:14 CET 2008
Author: hannes
Date: Tue Feb 5 03:01:13 2008
New Revision: 11663
Added:
trunk/libraries/protocols/bittorrent.dylan (contents, props changed)
Modified:
trunk/libraries/protocols/protocols-library.dylan
trunk/libraries/protocols/protocols.hdp
Log:
Job: 7299
incomplete support for bittorrent udp protocol
Added: trunk/libraries/protocols/bittorrent.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/protocols/bittorrent.dylan Tue Feb 5 03:01:13 2008
@@ -0,0 +1,47 @@
+module: bittorrent
+Author: Hannes Mehnert
+Copyright: (C) 2008, All rights reserved. Free for non-commercial use.
+
+//incomplete from http://xbtt.sourceforge.net/udp_tracker_protocol.html
+define protocol bittorrent-announce (container-frame)
+ field connection-id :: <raw-frame> =
+ as(<raw-frame>,
+ #(#x0, #x0, #x04, #x17, #x27, #x10, #x19, #x80)),
+ static-length: 8 * 8;
+ field action :: <big-endian-unsigned-integer-4byte> = big-endian-unsigned-integer-4byte(#(#x0, #x0, #x0, #x1));
+ field transaction-id :: <big-endian-unsigned-integer-4byte> = big-endian-unsigned-integer-4byte(#(0, 0, 23, 42));
+ field info-hash :: <raw-frame> =
+ as(<raw-frame>,
+ #(#xF7, #x90, #xBA, #x87, #x8D, #x9F, #xF7, #xC3, #x02, #x45,
+ #x62, #x6B, #xA2, #x8E, #x8C, #x6D, #x89, #x70, #x50, #xD9)),
+ static-length: 20 * 8;
+ field peer-id :: <raw-frame> = read-frame(<raw-frame>, "fnord!"),
+ static-length: 20 * 8;
+ field downloaded :: <raw-frame> = $empty-raw-frame, static-length: 8 * 8;
+ field left :: <raw-frame> = $empty-raw-frame, static-length: 8 * 8;
+ field uploaded :: <raw-frame> = $empty-raw-frame, static-length: 8 * 8;
+ field event :: <big-endian-unsigned-integer-4byte> =
+ big-endian-unsigned-integer-4byte(#(0, 0, 0, 3));
+ field ip-address :: <ipv4-address> = ipv4-address("217.13.206.133");
+ field key :: <big-endian-unsigned-integer-4byte> =
+ big-endian-unsigned-integer-4byte(#(0, 0, 23, 42));
+ field num-want :: <big-endian-unsigned-integer-4byte> =
+ big-endian-unsigned-integer-4byte(#(0, 0, 0, 10));
+ field port :: <2byte-big-endian-unsigned-integer> = 6887;
+end;
+
+define protocol bittorrent-announce-output (container-frame)
+ over <udp-frame> 6969;
+ field action :: <big-endian-unsigned-integer-4byte>;
+ field transaction-id :: <big-endian-unsigned-integer-4byte>;
+ field interval :: <big-endian-unsigned-integer-4byte>;
+ field leechers :: <big-endian-unsigned-integer-4byte>;
+ field seeders :: <big-endian-unsigned-integer-4byte>;
+ repeated field peers :: <ip-and-port>,
+ reached-end?: #f;
+end;
+
+define protocol ip-and-port (container-frame)
+ field ip :: <ipv4-address>;
+ field port :: <2byte-big-endian-unsigned-integer>;
+end;
\ No newline at end of file
Modified: trunk/libraries/protocols/protocols-library.dylan
==============================================================================
--- trunk/libraries/protocols/protocols-library.dylan (original)
+++ trunk/libraries/protocols/protocols-library.dylan Tue Feb 5 03:01:13 2008
@@ -20,7 +20,8 @@
cidr,
ieee80211,
ppp,
- pppoe;
+ pppoe,
+ bittorrent;
end;
define module logical-link
@@ -269,6 +270,15 @@
export calculate-checksum;
end;
+define module bittorrent
+ use common-dylan;
+ use packetizer;
+ use ipv4;
+ use udp;
+
+ export <bittorrent-announce>;
+end;
+
define module ipv6
use common-dylan, exclude: { format-to-string };
use packetizer;
Modified: trunk/libraries/protocols/protocols.hdp
==============================================================================
--- trunk/libraries/protocols/protocols.hdp (original)
+++ trunk/libraries/protocols/protocols.hdp Tue Feb 5 03:01:13 2008
@@ -10,6 +10,7 @@
tcp
dhcp
dns
+ bittorrent
ieee80211
prism2
pcap
More information about the chatter
mailing list