summaryrefslogtreecommitdiff
path: root/source4/lib/socket/socket.h
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-09-13 14:17:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:44 -0500
commitce694e7051dca90cdb5700e3865315d16931c3c1 (patch)
treec6c00e86d187bfda340e03559d3561cd434bd39c /source4/lib/socket/socket.h
parent360f125f255fd7d5a172d012c00b3cfbff5a6989 (diff)
downloadsamba-ce694e7051dca90cdb5700e3865315d16931c3c1.tar.gz
samba-ce694e7051dca90cdb5700e3865315d16931c3c1.tar.bz2
samba-ce694e7051dca90cdb5700e3865315d16931c3c1.zip
r2328: add the start of a new system and protocol
independent socket library. this is not used, but compiled currently there're maybe some api changes later... metze (This used to be commit de4447d7a57c614b80d0ac00dca900ea7e1c21ea)
Diffstat (limited to 'source4/lib/socket/socket.h')
-rw-r--r--source4/lib/socket/socket.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h
new file mode 100644
index 0000000000..dfc964b741
--- /dev/null
+++ b/source4/lib/socket/socket.h
@@ -0,0 +1,93 @@
+/*
+ Unix SMB/CIFS implementation.
+ Socket functions
+ Copyright (C) Stefan Metzmacher 2004
+
+ 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
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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.
+*/
+
+#ifndef _SAMBA_SOCKET_H
+#define _SAMBA_SOCKET_H
+
+struct socket_context;
+
+enum socket_type {
+ SOCKET_TYPE_STREAM
+};
+
+struct socket_ops {
+ const char *name;
+ enum socket_type type;
+
+ NTSTATUS (*init)(struct socket_context *sock);
+
+ /* client ops */
+ NTSTATUS (*connect)(struct socket_context *sock,
+ const char *my_address, int my_port,
+ const char *server_address, int server_port,
+ uint32_t flags);
+
+ /* server ops */
+ NTSTATUS (*listen)(struct socket_context *sock,
+ const char *my_address, int port, int queue_size, uint32_t flags);
+ NTSTATUS (*accept)(struct socket_context *sock,
+ struct socket_context **new_sock, uint32_t flags);
+
+ /* general ops */
+ NTSTATUS (*recv)(struct socket_context *sock, TALLOC_CTX *mem_ctx,
+ DATA_BLOB *blob, size_t wantlen, uint32_t flags);
+ NTSTATUS (*send)(struct socket_context *sock, TALLOC_CTX *mem_ctx,
+ const DATA_BLOB *blob, size_t *sendlen, uint32_t flags);
+
+ void (*close)(struct socket_context *sock);
+
+ NTSTATUS (*set_option)(struct socket_context *sock, const char *option, const char *val);
+
+ const char *(*get_peer_addr)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
+ int (*get_peer_port)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
+ const char *(*get_my_addr)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
+ int (*get_my_port)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
+
+ int (*get_fd)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
+};
+
+enum socket_state {
+ SOCKET_STATE_UNDEFINED,
+
+ SOCKET_STATE_CLIENT_START,
+ SOCKET_STATE_CLIENT_CONNECTED,
+ SOCKET_STATE_CLIENT_STARTTLS,
+ SOCKET_STATE_CLIENT_ERROR,
+
+ SOCKET_STATE_SERVER_LISTEN,
+ SOCKET_STATE_SERVER_CONNECTED,
+ SOCKET_STATE_SERVER_STARTTLS,
+ SOCKET_STATE_SERVER_ERROR
+};
+
+#define SOCKET_OPTION_BLOCK 0x00000001
+
+struct socket_context {
+ enum socket_type type;
+ enum socket_state state;
+ uint32_t flags;
+
+ int fd;
+
+ void *private_data;
+ const struct socket_ops *ops;
+};
+
+#endif /* _SAMBA_SOCKET_H */