remove compile errors
[swifty.git] / src / raw / swift_raw_simple_test.c
1 /*
2  * Simple test for raw socket based implementation of swift socket API.
3  *
4  * 2011, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro
5  */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <sys/types.h>
11
12 #include "include/swift_types.h"
13 #include "include/swift_raw.h"
14 #include "include/util.h"
15
16 /*
17  * Create a socket, bind it and send data.
18  */
19 int main(void)
20 {
21         int sockfd;
22         struct sockaddr_sw local_addr;
23         struct sockaddr_sw remote_addr;
24         char buffer[BUFSIZ];
25         ssize_t bytes_sent;
26         int rc;
27
28         sockfd = sw_socket(PF_INET, SOCK_DGRAM, IPPROTO_SWIFT);
29         DIE(sockfd < 0, "sw_socket");
30
31         /* TODO: init_addr */
32
33         rc = sw_bind(sockfd, (struct sockaddr *) &local_addr, sizeof(local_addr));
34         DIE(rc < 0, "sw_bind");
35
36         /* TODO: init remote_addr */
37         bytes_sent = sw_sendto(sockfd, buffer, BUFSIZ, 0,
38                         (struct sockaddr *) &remote_addr, sizeof(remote_addr));
39         DIE(bytes_sent < 0, "sw_sendto");
40
41         return 0;
42 }