1 #include "../src/kernel/swift.h"
3 #include <sys/socket.h>
7 #include <netinet/in.h>
10 int main(int argc, const char *argv[])
14 sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_SWIFT);
16 perror("Failed to create socket");
20 int size = sizeof(struct sockaddr_swift) + sizeof(struct swift_dest);
21 struct sockaddr_swift *saddr = malloc(size);
22 memset(saddr, 0, size);
25 saddr->dests[0].addr = 0x0100007F;
26 saddr->dests[0].port = 50;
28 if (bind(sock, (struct sockaddr *) saddr, size) < 0) {
29 perror("Failed to bind socket");
34 char buf[] = "Buffer de test";
35 char buf2[] = "Buffer2";
38 int size2 = sizeof(struct sockaddr_swift) + 2 * sizeof(struct swift_dest);
39 struct sockaddr_swift *to = malloc(size2);
41 memset(&msg, 0, sizeof(msg));
42 memset(&iov, 0, sizeof(iov));
45 iov[0].iov_base = buf;
46 iov[0].iov_len = sizeof(buf);
47 iov[1].iov_base = buf2;
48 iov[1].iov_len = sizeof(buf2);
51 to->dests[0].addr = 0x0100007F;
52 to->dests[0].port = 100;
53 to->dests[1].addr = 0x0100007F;
54 to->dests[1].port = 101;
59 msg.msg_namelen = size2;
63 ret = sendmsg(sock, &msg, sizeof(msg));
65 perror("Failed to send on socket");
69 printf("Sent %d bytes on socket\n", msg.msg_namelen);
71 if (close(sock) < 0) {
72 perror("Failed to close socket");