4 #define SWIFT_PORT 8080
5 #define PACKET_SIZE 4*1024
10 printf("%s:%d: ", __func__, __LINE__); \
18 printf("%s:%d: ", __func__, __LINE__); \
25 #define Dprintf(msg,...) printf("[%s]:%d " msg, __FILE__, __LINE__, ##__VA_ARGS__)
27 #define Dprintf(msg,...) /* do nothing */
33 typedef struct swift {
34 SOCKET socketListener;
42 // swift_addr structure similar with in_addr
44 unsigned short N; // e.g. number of s_addr
45 unsigned long s_addr[MAX_IPs]; // i.p. ip list
48 // swift struct similar with sock_addr
49 typedef struct sockSwiftaddr {
50 short sin_family; // e.g. AF_INET
51 unsigned short sin_port; // e.g. htons(3490)
52 struct swift_addr sin_addr; // see struct swift_addr, below
58 struct sockaddr_in sa[MAX_IPs];
61 // Function to create a Swift socket
62 Swift socketSwift(int maxChannels);
64 // Function to close a Swift socket
65 void closeSwift(Swift);
67 // Function to listen to a port
68 int listenfromSwift (Swift s, void *buf, size_t len, int flags,
69 struct sockSwiftaddr * __restrict__ from, socklen_t *fromlen);
71 // Function to bind a port for swift socket
72 int bindSwift(Swift s, const struct sockSwiftaddr *my_addr, socklen_t addrlen);
74 // Function to receive a message
75 ssize_t recvfromSwift(Swift s, void *buf, size_t len, int flags,
76 struct sockSwiftaddr *from, socklen_t fromlen);
78 // Function to send a message
79 ssize_t sendToSwift(Swift s, const void *buf, size_t len, int flags,
80 const struct sockSwiftaddr *to, socklen_t tolen);
83 // test function -- don't commit
84 void transformFromAddrToSwift(struct sockSwiftaddr *ssa, struct listsockaddr lsa);
85 void transformFromSwiftToAddr(struct listsockaddr *lsa, struct sockSwiftaddr ssa);