Add bound check/ debug message destination address
[swifty.git] / src / raw / swift_raw.c
index 937c62d..4f26551 100644 (file)
@@ -22,9 +22,9 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include "swift_types.h"
-#include "swift_raw.h"
-#include "swift_list.h"
+#include "include/swift_types.h"
+#include "include/swift_raw.h"
+#include "include/swift_list.h"
 
 /*
  * Create a new socket of type TYPE in domain DOMAIN, using
@@ -140,22 +140,24 @@ ssize_t sw_sendto(int __fd, __const void *__buf, size_t __n,
        struct sock_list *list;
        struct iovec __iov[1];
        struct msghdr __msgh;
-       
+       struct sockaddr_sw *__sw_addr = (struct sockaddr_sw *) __addr;
+
+       printf("=== ADDR: %s ===", ntohl(__sw_addr->sin_addr.s_addr));
        list = list_elem_from_socket(__fd);
        if (list == NULL) {
                errno = EBADF;
                goto sock_err;
        }
 
-/*
-       if (list->state == STATE_NOBOUND) {
+
+       if (list->bind_state == STATE_NOTBOUND) {
                errno = EDESTADDRREQ;
                goto sock_err;
        }
- */
        
        /* Specify the components of the message in an "iovec".   */
-       __iov[0].iov_base = __buf;
+       __iov[0].iov_base = (void *) __buf;
        __iov[0].iov_len = __n;
        
        /* The message header contains parameters for sendmsg.    */