From: Drutu Bogdan Date: Thu, 3 Feb 2011 17:58:27 +0000 (+0200) Subject: No comment... X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=fddea12d1d54da0c36797074923833a88491479c;p=swifty.git No comment... --- diff --git a/src/lib_swift.c b/src/lib_swift.c index 01a838b..d244b20 100644 --- a/src/lib_swift.c +++ b/src/lib_swift.c @@ -73,9 +73,12 @@ Swift socketSwift() Dprintf("create swift socket"); Swift s = calloc(1,sizeof(*s)); - Dprintf("create swift listener"); + Dprintf("create swift socket listener"); CHECK(s->socketListener = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)); + Dprintf("create swift socket data"); + CHECK(s->socketData = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)); + memset((char *) &s->socketListenerAddr, 0, sizeof(s->socketListenerAddr)); s->socketListenerAddr.sin_family = AF_INET; @@ -92,3 +95,5 @@ void closeSwift(Swift s) free(s); } + + diff --git a/src/lib_swift.h b/src/lib_swift.h index 8611c80..c735752 100644 --- a/src/lib_swift.h +++ b/src/lib_swift.h @@ -27,32 +27,50 @@ #define Dprintf(msg,...) /* do nothing */ #endif +// swift interface typedef struct swift { - int socketListener; + int socketListener, socketData; struct sockaddr_in socketListenerAddr; } *Swift; +// swift_addr structure similar with in_addr struct swift_addr { unsigned short N; // e.g. number of s_addr unsigned long s_addr[MAX_IPs]; // i.p. ip list }; +// swift struct similar with sock_addr typedef struct sockSwiftaddr { short sin_family; // e.g. AF_INET unsigned short sin_port; // e.g. htons(3490) struct swift_addr sin_addr; // see struct swift_addr, below } *SockSwiftaddr; +// list of swift_addr struct listsockaddr { unsigned short N; struct sockaddr_in sa[MAX_IPs]; }; +// Function to create a Swift socket Swift socketSwift(); + +// Function to close a Swift socket void closeSwift(Swift); +// Function to listen to a port +int listenfromSwift (Swift s, void *buf, size_t len, int flags, + struct sockSwiftaddr * __restrict__ from, socklen_t *fromlen); + +// Function to bind a port for swift socket +int bindSwift(Swift s, const struct sockSwiftaddr *my_addr, socklen_t addrlen); -int recvfromSwift (Swift, void *, size_t, int, struct sockSwiftaddr *, socklen_t *); -int bindSwift(Swift, const struct sockSwiftaddr *, socklen_t); +// Function to receive a message +ssize_t recvfrom(Swift s, void *buf, size_t len, int flags, + struct sockSwiftaddr *from, socklen_t *fromlen); + +// Function to send a message +ssize_t sendto(Swift s, const void *buf, size_t len, int flags, + const struct sockSwiftaddr *to, socklen_t tolen); #endif