build: commit all the waf build files in the tree
[nivanova/samba-autobuild/.git] / source4 / lib / socket / socket_unix.c
index 5e04ce0d4ca84a3c503e576b960defa9d4e121bf..af7d2bb79ff66da79d18d96f3b0ebccfae05c5be 100644 (file)
@@ -8,7 +8,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -17,8 +17,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -83,7 +82,7 @@ static NTSTATUS unixdom_connect_complete(struct socket_context *sock, uint32_t f
        }
 
        if (!(flags & SOCKET_FLAG_BLOCK)) {
-               ret = set_blocking(sock->fd, False);
+               ret = set_blocking(sock->fd, false);
                if (ret == -1) {
                        return map_nt_error_from_unix(errno);
                }
@@ -134,10 +133,11 @@ static NTSTATUS unixdom_listen(struct socket_context *sock,
                unlink(my_address->addr);
        }
 
-       if (my_address && my_address->sockaddr) {
+       if (my_address->sockaddr) {
                ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
+       } else if (my_address->addr == NULL) {
+               return NT_STATUS_INVALID_PARAMETER;
        } else {
-               
                if (strlen(my_address->addr)+1 > sizeof(my_addr.sun_path)) {
                        return NT_STATUS_OBJECT_PATH_INVALID;
                }
@@ -161,7 +161,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock,
        }
 
        if (!(flags & SOCKET_FLAG_BLOCK)) {
-               ret = set_blocking(sock->fd, False);
+               ret = set_blocking(sock->fd, false);
                if (ret == -1) {
                        return unixdom_error(errno);
                }
@@ -190,7 +190,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
        }
 
        if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
-               int ret = set_blocking(new_fd, False);
+               int ret = set_blocking(new_fd, false);
                if (ret == -1) {
                        close(new_fd);
                        return map_nt_error_from_unix(errno);
@@ -218,23 +218,13 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
 }
 
 static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf, 
-                            size_t wantlen, size_t *nread, uint32_t flags)
+                            size_t wantlen, size_t *nread)
 {
        ssize_t gotlen;
-       int flgs = 0;
-
-       /* TODO: we need to map all flags here */
-       if (flags & SOCKET_FLAG_PEEK) {
-               flgs |= MSG_PEEK;
-       }
-
-       if (flags & SOCKET_FLAG_BLOCK) {
-               flgs |= MSG_WAITALL;
-       }
 
        *nread = 0;
 
-       gotlen = recv(sock->fd, buf, wantlen, flgs);
+       gotlen = recv(sock->fd, buf, wantlen, 0);
        if (gotlen == 0) {
                return NT_STATUS_END_OF_FILE;
        } else if (gotlen == -1) {
@@ -247,14 +237,13 @@ static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf,
 }
 
 static NTSTATUS unixdom_send(struct socket_context *sock,
-                            const DATA_BLOB *blob, size_t *sendlen, uint32_t flags)
+                            const DATA_BLOB *blob, size_t *sendlen)
 {
        ssize_t len;
-       int flgs = 0;
 
        *sendlen = 0;
 
-       len = send(sock->fd, blob->data, blob->length, flgs);
+       len = send(sock->fd, blob->data, blob->length, 0);
        if (len == -1) {
                return unixdom_error(errno);
        }       
@@ -266,15 +255,14 @@ static NTSTATUS unixdom_send(struct socket_context *sock,
 
 
 static NTSTATUS unixdom_sendto(struct socket_context *sock, 
-                              const DATA_BLOB *blob, size_t *sendlen, uint32_t flags,
+                              const DATA_BLOB *blob, size_t *sendlen, 
                               const struct socket_address *dest)
 {
        ssize_t len;
-       int flgs = 0;
        *sendlen = 0;
                
        if (dest->sockaddr) {
-               len = sendto(sock->fd, blob->data, blob->length, flgs
+               len = sendto(sock->fd, blob->data, blob->length, 0
                             dest->sockaddr, dest->sockaddrlen);
        } else {
                struct sockaddr_un srv_addr;
@@ -287,7 +275,7 @@ static NTSTATUS unixdom_sendto(struct socket_context *sock,
                srv_addr.sun_family = AF_UNIX;
                strncpy(srv_addr.sun_path, dest->addr, sizeof(srv_addr.sun_path));
                
-               len = sendto(sock->fd, blob->data, blob->length, flgs
+               len = sendto(sock->fd, blob->data, blob->length, 0
                             (struct sockaddr *)&srv_addr, sizeof(srv_addr));
        }
        if (len == -1) {
@@ -426,7 +414,7 @@ static const struct socket_ops unixdom_ops = {
        .fn_get_fd              = unixdom_get_fd
 };
 
-const struct socket_ops *socket_unixdom_ops(enum socket_type type)
+_PUBLIC_ const struct socket_ops *socket_unixdom_ops(enum socket_type type)
 {
        return &unixdom_ops;
 }