2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2004
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef _SAMBA_SOCKET_H
22 #define _SAMBA_SOCKET_H
24 struct socket_context;
32 enum socket_type type;
34 NTSTATUS (*init)(struct socket_context *sock);
37 NTSTATUS (*connect)(struct socket_context *sock,
38 const char *my_address, int my_port,
39 const char *server_address, int server_port,
43 NTSTATUS (*listen)(struct socket_context *sock,
44 const char *my_address, int port, int queue_size, uint32_t flags);
45 NTSTATUS (*accept)(struct socket_context *sock,
46 struct socket_context **new_sock, uint32_t flags);
49 NTSTATUS (*recv)(struct socket_context *sock, TALLOC_CTX *mem_ctx,
50 DATA_BLOB *blob, size_t wantlen, uint32_t flags);
51 NTSTATUS (*send)(struct socket_context *sock, TALLOC_CTX *mem_ctx,
52 const DATA_BLOB *blob, size_t *sendlen, uint32_t flags);
54 void (*close)(struct socket_context *sock);
56 NTSTATUS (*set_option)(struct socket_context *sock, const char *option, const char *val);
58 const char *(*get_peer_addr)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
59 int (*get_peer_port)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
60 const char *(*get_my_addr)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
61 int (*get_my_port)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
63 int (*get_fd)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
67 SOCKET_STATE_UNDEFINED,
69 SOCKET_STATE_CLIENT_START,
70 SOCKET_STATE_CLIENT_CONNECTED,
71 SOCKET_STATE_CLIENT_STARTTLS,
72 SOCKET_STATE_CLIENT_ERROR,
74 SOCKET_STATE_SERVER_LISTEN,
75 SOCKET_STATE_SERVER_CONNECTED,
76 SOCKET_STATE_SERVER_STARTTLS,
77 SOCKET_STATE_SERVER_ERROR
80 #define SOCKET_OPTION_BLOCK 0x00000001
82 struct socket_context {
83 enum socket_type type;
84 enum socket_state state;
90 const struct socket_ops *ops;
93 #endif /* _SAMBA_SOCKET_H */