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,
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/>.
*/
#ifndef _SAMBA_SOCKET_H
/* general ops */
NTSTATUS (*fn_recv)(struct socket_context *sock, void *buf,
- size_t wantlen, size_t *nread, uint32_t flags);
+ size_t wantlen, size_t *nread);
NTSTATUS (*fn_send)(struct socket_context *sock,
- const DATA_BLOB *blob, size_t *sendlen, uint32_t flags);
+ const DATA_BLOB *blob, size_t *sendlen);
NTSTATUS (*fn_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_addr);
NTSTATUS (*fn_recvfrom)(struct socket_context *sock,
- void *buf, size_t wantlen, size_t *nread, uint32_t flags,
+ void *buf, size_t wantlen, size_t *nread,
TALLOC_CTX *addr_ctx, struct socket_address **src_addr);
NTSTATUS (*fn_pending)(struct socket_context *sock, size_t *npending);
#define SOCKET_FLAG_BLOCK 0x00000001
#define SOCKET_FLAG_PEEK 0x00000002
#define SOCKET_FLAG_TESTNONBLOCK 0x00000004
+#define SOCKET_FLAG_ENCRYPT 0x00000008 /* This socket
+ * implementation requires
+ * that re-sends be
+ * consistant, because it
+ * is encrypting data.
+ * This modifies the
+ * TESTNONBLOCK case */
+#define SOCKET_FLAG_NOCLOSE 0x00000010 /* don't auto-close on free */
+
struct socket_context {
enum socket_type type;
/* prototypes */
+NTSTATUS socket_create_with_ops(TALLOC_CTX *mem_ctx, const struct socket_ops *ops,
+ struct socket_context **new_sock,
+ enum socket_type type, uint32_t flags);
NTSTATUS socket_create(const char *name, enum socket_type type,
struct socket_context **new_sock, uint32_t flags);
NTSTATUS socket_connect(struct socket_context *sock,
int queue_size, uint32_t flags);
NTSTATUS socket_accept(struct socket_context *sock, struct socket_context **new_sock);
NTSTATUS socket_recv(struct socket_context *sock, void *buf,
- size_t wantlen, size_t *nread, uint32_t flags);
+ size_t wantlen, size_t *nread);
NTSTATUS socket_recvfrom(struct socket_context *sock, void *buf,
- size_t wantlen, size_t *nread, uint32_t flags,
+ size_t wantlen, size_t *nread,
TALLOC_CTX *addr_ctx, struct socket_address **src_addr);
NTSTATUS socket_send(struct socket_context *sock,
- const DATA_BLOB *blob, size_t *sendlen, uint32_t flags);
+ const DATA_BLOB *blob, size_t *sendlen);
NTSTATUS socket_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_addr);
NTSTATUS socket_pending(struct socket_context *sock, size_t *npending);
NTSTATUS socket_set_option(struct socket_context *sock, const char *option, const char *val);
struct event_context *event_ctx,
struct socket_context **result,
uint16_t *port);
+void set_socket_options(int fd, const char *options);
+void socket_set_flags(struct socket_context *socket, unsigned flags);
#endif /* _SAMBA_SOCKET_H */