swifty: Replace initial comment in swift_types.h.
[swifty.git] / src / swift_types.h
1 /*
2  * swift data structures
3  *
4  * swift struct sockaddr is dubbed struct sockaddr_sw.
5  * swhdr is swift packet header (as delivered on the network).
6  *
7  * 2011, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
8  */
9
10 #ifndef SWIFT_TYPES_
11 #define SWIFT_TYPES_    1
12
13 #include <sys/types.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /*
22  * swift address
23  *   - IP address (Network Layer)
24  *   - file hash (or hash for part of a file)
25  *       - a seeder (sender) publishes that hash
26  *       - a leecher (receiver) requests that hash
27  *       - stands as port number both for sender and receiver
28  */
29
30 #define SWIFT_HASH_SIZE         8
31
32 struct sw_hash {
33         unsigned char h_array[SWIFT_HASH_SIZE];
34 };
35
36 struct sockaddr_sw {
37         __SOCKADDR_COMMON(sin_);
38         struct in_addr sin_addr;
39         struct sw_hash sw_hash;
40
41         /* Pad to size of `struct sockaddr'.  */
42         unsigned char sw_zero[sizeof(struct sockaddr) -
43                 __SOCKADDR_COMMON_SIZE -
44                 sizeof(sw_hash) -
45                 sizeof(struct in_addr)];
46 };
47
48 /*
49  * swift header (work in progress)
50  */
51
52 struct swhdr {
53         /* file hash (to be seeded or requested) */
54         u_int8_t base_hash[SWIFT_HASH_SIZE];
55         /* TODO */
56 };
57
58 #ifdef __cplusplus
59 }
60 #endif
61
62 #endif /* SWIFT_TYPES_ */