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;
34 NTSTATUS (*fn_init)(struct socket_context *sock);
37 NTSTATUS (*fn_connect)(struct socket_context *sock,
38 const char *my_address, int my_port,
39 const char *server_address, int server_port,
42 /* complete a non-blocking connect */
43 NTSTATUS (*fn_connect_complete)(struct socket_context *sock,
47 NTSTATUS (*fn_listen)(struct socket_context *sock,
48 const char *my_address, int port, int queue_size, uint32_t flags);
49 NTSTATUS (*fn_accept)(struct socket_context *sock, struct socket_context **new_sock);
52 NTSTATUS (*fn_recv)(struct socket_context *sock, void *buf,
53 size_t wantlen, size_t *nread, uint32_t flags);
54 NTSTATUS (*fn_send)(struct socket_context *sock,
55 const DATA_BLOB *blob, size_t *sendlen, uint32_t flags);
57 NTSTATUS (*fn_sendto)(struct socket_context *sock,
58 const DATA_BLOB *blob, size_t *sendlen, uint32_t flags,
59 const char *dest_addr, int dest_port);
60 NTSTATUS (*fn_recvfrom)(struct socket_context *sock,
61 void *buf, size_t wantlen, size_t *nread, uint32_t flags,
62 const char **src_addr, int *src_port);
64 void (*fn_close)(struct socket_context *sock);
66 NTSTATUS (*fn_set_option)(struct socket_context *sock, const char *option, const char *val);
68 char *(*fn_get_peer_name)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
69 char *(*fn_get_peer_addr)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
70 int (*fn_get_peer_port)(struct socket_context *sock);
71 char *(*fn_get_my_addr)(struct socket_context *sock, TALLOC_CTX *mem_ctx);
72 int (*fn_get_my_port)(struct socket_context *sock);
74 int (*fn_get_fd)(struct socket_context *sock);
78 SOCKET_STATE_UNDEFINED,
80 SOCKET_STATE_CLIENT_START,
81 SOCKET_STATE_CLIENT_CONNECTED,
82 SOCKET_STATE_CLIENT_STARTTLS,
83 SOCKET_STATE_CLIENT_ERROR,
85 SOCKET_STATE_SERVER_LISTEN,
86 SOCKET_STATE_SERVER_CONNECTED,
87 SOCKET_STATE_SERVER_STARTTLS,
88 SOCKET_STATE_SERVER_ERROR
91 #define SOCKET_FLAG_BLOCK 0x00000001
92 #define SOCKET_FLAG_PEEK 0x00000002
93 #define SOCKET_FLAG_TESTNONBLOCK 0x00000004
95 struct socket_context {
96 enum socket_type type;
97 enum socket_state state;
103 const struct socket_ops *ops;
106 #endif /* _SAMBA_SOCKET_H */