2 * Simple test for raw socket based implementation of swift socket API.
4 * 2011, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
10 #include <sys/types.h>
12 #include "include/swift_types.h"
13 #include "include/swift_raw.h"
14 #include "include/util.h"
17 * Create a socket, bind it and send data.
19 int main(int argc, char *argv[])
22 struct sockaddr_sw local_addr;
23 struct sockaddr_sw remote_addr;
30 fprintf(stderr,"Usage \"./client ip_local hash ip_dest?\" .");
33 sockfd = sw_socket(PF_INET, SOCK_DGRAM, IPPROTO_SWIFT);
34 DIE(sockfd < 0, "sw_socket");
37 local_addr.sin_addr.s_addr = htonl(argv[1]);
38 memcpy(&local_addr.sw_hash, argv[2], sizeof(struct sw_hash));
39 rc = sw_bind(sockfd, (struct sockaddr *) &local_addr, sizeof(local_addr));
40 DIE(rc < 0, "sw_bind");
42 /* TODO: init remote_addr */
45 remote_addr.sin_addr.s_addr = htonl(argv[1]);
46 memcpy(&remote_addr.sw_hash, argv[3], sizeof(struct sw_hash));
47 bytes_sent = sw_sendto(sockfd, buffer, BUFSIZ, 0,
48 (struct sockaddr *) &remote_addr, sizeof(remote_addr));
49 DIE(bytes_sent < 0, "sw_sendto");