summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-06-03 04:19:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:26 -0500
commite83b74244d9e5bc8dee202b86fb3ec192fe93185 (patch)
tree309325ee00484f391afaae3c6a98278436339c29 /source4
parent7cc9ce3cd0e164a168db11da4d63cf6ddbf6208d (diff)
downloadsamba-e83b74244d9e5bc8dee202b86fb3ec192fe93185.tar.gz
samba-e83b74244d9e5bc8dee202b86fb3ec192fe93185.tar.bz2
samba-e83b74244d9e5bc8dee202b86fb3ec192fe93185.zip
r7205: added support for sendto() on unix domain sockets
(This used to be commit 35ef6e3b153f527f79539b2d99c5ff1cd034ba4b)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/socket/socket_unix.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c
index 3f265f7214..04ba89578f 100644
--- a/source4/lib/socket/socket_unix.c
+++ b/source4/lib/socket/socket_unix.c
@@ -249,6 +249,37 @@ static NTSTATUS unixdom_send(struct socket_context *sock,
return NT_STATUS_OK;
}
+
+static NTSTATUS unixdom_sendto(struct socket_context *sock,
+ const DATA_BLOB *blob, size_t *sendlen, uint32_t flags,
+ const char *dest_addr, int dest_port)
+{
+ ssize_t len;
+ int flgs = 0;
+ struct sockaddr_un srv_addr;
+
+ if (strlen(dest_addr)+1 > sizeof(srv_addr.sun_path)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ ZERO_STRUCT(srv_addr);
+ srv_addr.sun_family = AF_UNIX;
+ strncpy(srv_addr.sun_path, dest_addr, sizeof(srv_addr.sun_path));
+
+ *sendlen = 0;
+
+ len = sendto(sock->fd, blob->data, blob->length, flgs,
+ (struct sockaddr *)&srv_addr, sizeof(srv_addr));
+ if (len == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ *sendlen = len;
+
+ return NT_STATUS_OK;
+}
+
+
static NTSTATUS unixdom_set_option(struct socket_context *sock,
const char *option, const char *val)
{
@@ -294,6 +325,7 @@ static const struct socket_ops unixdom_ops = {
.fn_accept = unixdom_accept,
.fn_recv = unixdom_recv,
.fn_send = unixdom_send,
+ .fn_sendto = unixdom_sendto,
.fn_close = unixdom_close,
.fn_set_option = unixdom_set_option,