From: Razvan Deaconescu Date: Sat, 14 May 2011 15:11:55 +0000 (+0300) Subject: swifty: Add swift_types.h. X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=a102e72b951902d41bcfbf56de357752807a9231;p=swifty.git swifty: Add swift_types.h. Defines struct sockaddr_sw. --- diff --git a/src/swift_types.h b/src/swift_types.h new file mode 100644 index 0000000..3decae6 --- /dev/null +++ b/src/swift_types.h @@ -0,0 +1,55 @@ +/* + * swift interface for raw sockets + * + * Simulates the classic socket syscalls (socket, bind, send, recv). + * Implementation uses raw sockets (AF_INET, SOCK_RAW). + * + * Subsequently, implementation is to be ported into kernel space and + * the interface is going to be offered by the Linux syscall API. + * + * 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro + */ + +#ifndef SWIFT_RAW_ +#define SWIFT_RAW_ 1 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * swift address + * - IP address (Network Layer) + * - file hash (or hash for part of a file) + * - a seeder (sender) publishes that hash + * - a leecher (receiver) requests that hash + * - stands as port number both for sender and receiver + */ + +#define SWIFT_HASH_SIZE 8 + +struct sw_hash { + unsigned char h_array[SWIFT_HASH_SIZE]; +}; + +struct sockaddr_sw { + __SOCKADDR_COMMON(sin_); + struct in_addr sin_addr; + struct sw_hash sw_hash; + + /* Pad to size of `struct sockaddr'. */ + unsigned char sw_zero[sizeof(struct sockaddr) - + __SOCKADDR_COMMON_SIZE - + sizeof(sw_hash) - + sizeof(struct in_addr)]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* SWIFT_RAW_ */