No comment...
authorDrutu Bogdan <bcristia@adobe.com>
Thu, 3 Feb 2011 17:58:27 +0000 (19:58 +0200)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sat, 2 Apr 2011 07:27:23 +0000 (10:27 +0300)
src/lib_swift.c
src/lib_swift.h

index 01a838b..d244b20 100644 (file)
@@ -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);
 }
+
+
index 8611c80..c735752 100644 (file)
 #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