2 * swift interface for raw sockets
4 * Simulates the classic socket syscalls (socket, bind, send, recv).
5 * Implementation uses raw sockets (AF_INET, SOCK_RAW).
7 * Subsequently, implementation is to be ported into kernel space and
8 * the interface is going to be offered by the Linux syscall API.
10 * 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
26 * - IP address (Network Layer)
27 * - file hash (or hash for part of a file)
28 * - a seeder (sender) publishes that hash
29 * - a leecher (receiver) requests that hash
30 * - stands as port number both for sender and receiver
33 #define SWIFT_HASH_SIZE 8
36 unsigned char h_array[SWIFT_HASH_SIZE];
40 __SOCKADDR_COMMON(sin_);
41 struct in_addr sin_addr;
42 struct sw_hash sw_hash;
44 /* Pad to size of `struct sockaddr'. */
45 unsigned char sw_zero[sizeof(struct sockaddr) -
46 __SOCKADDR_COMMON_SIZE -
48 sizeof(struct in_addr)];
52 * swift header (work in progress)
56 /* file hash (to be seeded or requested) */
57 u_int8_t base_hash[SWIFT_HASH_SIZE];
65 #endif /* SWIFT_RAW_ */