r23792: convert Samba4 to GPLv3
[kai/samba-autobuild/.git] / source4 / lib / socket / socket.h
index a50fb876193182aa9f46528f267b3c63b846e78a..6bc03188a56e1d14a331bf4081d80d6c7cd89047 100644 (file)
@@ -5,7 +5,7 @@
    
    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,
@@ -14,8 +14,7 @@
    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
@@ -62,15 +61,15 @@ struct socket_ops {
 
        /* 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);      
 
@@ -102,6 +101,15 @@ enum socket_state {
 #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;
@@ -117,6 +125,9 @@ struct socket_context {
 
 
 /* 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,
@@ -129,14 +140,14 @@ NTSTATUS socket_listen(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);
@@ -185,5 +196,7 @@ NTSTATUS socket_connect_multi(TALLOC_CTX *mem_ctx, const char *server_address,
                              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 */