#include <unistd.h>
#include <errno.h>
-#include "include/swift_types.h"
-#include "include/swift_raw.h"
-#include "include/swift_list.h"
+#include "swift_types.h"
+#include "swift_raw.h"
+#include "swift_list.h"
+#include "debug.h"
+#include "util.h"
/*
* Create a new socket of type TYPE in domain DOMAIN, using
struct sock_list *list;
struct iovec __iov[1];
struct msghdr __msgh;
-
+ struct sockaddr_sw *__sw_addr = (struct sockaddr_sw *) __addr;
+
list = list_elem_from_socket(__fd);
- if (list == NULL) {
- errno = EBADF;
+ if (list != NULL && list->bind_state == STATE_NOTBOUND) {
+ errno = EAFNOSUPPORT;
goto sock_err;
}
-/*
- if (list->state == STATE_NOBOUND) {
- errno = EDESTADDRREQ;
- goto sock_err;
+ {
+ char str[INET_ADDRSTRLEN];
+
+ inet_ntop(AF_INET, &(__sw_addr->sin_addr), str, INET_ADDRSTRLEN);
+ printf("=== ADDR: %s ===\n", str);
}
- */
-
+
/* Specify the components of the message in an "iovec". */
__iov[0].iov_base = (void *) __buf;
__iov[0].iov_len = __n;
socklen_t *__restrict __addr_len)
{
ssize_t bytes_recv;
+ struct sock_list *list;
+ struct iovec __iov[1];
+ struct msghdr __msgh;
+ struct sockaddr_sw *__sw_addr = (struct sockaddr_sw *) __addr;
+ list = list_elem_from_socket(__fd);
+ if (list != NULL && list->bind_state == STATE_NOTBOUND) {
+ errno = EAFNOSUPPORT;
+ goto sock_err;
+ }
+
/* TODO */
- return bytes_recv;
+ return recvmsg(__fd, &__msgh, 0);
+
+sock_err:
+ return -1;
}
/*
{
ssize_t bytes_sent;
+ /* TODO */
+
return sendmsg(__fd, __message, __flags);
}
/* TODO */
- return bytes_recv;
+ return recvmsg(__fd, __message, __flags);
}
/*