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>
11 #include <arpa/inet.h>
13 #include "swift_types.h"
14 #include "swift_raw.h"
19 * Create a socket, bind it and send data.
21 int main(int argc, char *argv[])
24 struct sockaddr_sw local_addr;
25 struct sockaddr_sw remote_addr;
30 if (argc < 3 || argc > 4) {
31 fprintf(stderr,"Usage \"./client ip_local hash ip_dest?\" .");
35 sockfd = sw_socket(PF_INET, SOCK_DGRAM, IPPROTO_SWIFT);
36 DIE(sockfd < 0, "sw_socket");
38 memset(&local_addr, 0, sizeof(local_addr));
39 inet_pton(AF_INET, argv[1], &local_addr.sin_addr.s_addr);
40 memcpy(&local_addr.sw_hash, argv[2], sizeof(struct sw_hash));
41 rc = sw_bind(sockfd, (struct sockaddr *) &local_addr, sizeof(local_addr));
42 DIE(rc < 0, "sw_bind");
45 inet_pton(AF_INET, argv[3], &remote_addr.sin_addr.s_addr);
46 memcpy(&remote_addr.sw_hash, argv[4], sizeof(struct sw_hash));
47 bytes_sent = sw_sendto(sockfd, buffer, BUFSIZ, 0, (struct sockaddr *) &remote_addr, sizeof(remote_addr));
48 DIE(bytes_sent < 0, "sw_sendto");