dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / include / sys / ksocket.h
blob05005b9dde731466ef567224fbc9c75ef86aee5e
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
26 #ifndef _SYS_KSOCKET_H_
27 #define _SYS_KSOCKET_H_
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 #include <sys/stream.h>
34 /* Opaque kernel socket type */
35 typedef struct __ksocket *ksocket_t;
36 struct msghdr;
37 struct msgb; /* avoiding sys/stream.h here */
39 /* flag bit for each Callback Event */
40 #define KSOCKET_CB_CONNECTED 0x00000001
41 #define KSOCKET_CB_CONNECTFAILED 0x00000002
42 #define KSOCKET_CB_DISCONNECTED 0x00000004
43 #define KSOCKET_CB_NEWDATA 0x00000008
44 #define KSOCKET_CB_NEWCONN 0x00000010
45 #define KSOCKET_CB_CANSEND 0x00000020
46 #define KSOCKET_CB_OOBDATA 0x00000040
47 #define KSOCKET_CB_CANTSENDMORE 0x00000080
48 #define KSOCKET_CB_CANTRECVMORE 0x00000100
49 #define KSOCKET_CB_ERROR 0x00000200
52 * Kernel Socket Callback Events
54 typedef enum ksocket_event {
55 KSOCKET_EV_CONNECTED,
56 KSOCKET_EV_CONNECTFAILED,
57 KSOCKET_EV_DISCONNECTED,
58 KSOCKET_EV_OOBDATA,
59 KSOCKET_EV_NEWDATA,
60 KSOCKET_EV_NEWCONN,
61 KSOCKET_EV_CANSEND,
62 KSOCKET_EV_CANTSENDMORE,
63 KSOCKET_EV_CANTRECVMORE,
64 KSOCKET_EV_ERROR
65 } ksocket_callback_event_t;
67 typedef void (*ksocket_callback_t)(ksocket_t, ksocket_callback_event_t,
68 void *, uintptr_t);
70 typedef struct ksocket_callbacks {
71 uint32_t ksock_cb_flags;
72 ksocket_callback_t ksock_cb_connected;
73 ksocket_callback_t ksock_cb_connectfailed;
74 ksocket_callback_t ksock_cb_disconnected;
75 ksocket_callback_t ksock_cb_newdata;
76 ksocket_callback_t ksock_cb_newconn;
77 ksocket_callback_t ksock_cb_cansend;
78 ksocket_callback_t ksock_cb_oobdata;
79 ksocket_callback_t ksock_cb_cantsendmore;
80 ksocket_callback_t ksock_cb_cantrecvmore;
81 ksocket_callback_t ksock_cb_error;
82 } ksocket_callbacks_t;
84 #define KSOCKET_SLEEP SOCKET_SLEEP
85 #define KSOCKET_NOSLEEP SOCKET_NOSLEEP
87 extern int ksocket_socket(ksocket_t *, int, int, int, int, struct cred *);
88 extern int ksocket_bind(ksocket_t, struct sockaddr *, socklen_t,
89 struct cred *);
90 extern int ksocket_listen(ksocket_t, int, struct cred *);
91 extern int ksocket_accept(ksocket_t, struct sockaddr *, socklen_t *,
92 ksocket_t *, struct cred *);
93 extern int ksocket_connect(ksocket_t, struct sockaddr *, socklen_t,
94 struct cred *);
95 extern int ksocket_send(ksocket_t, void *, size_t, int, size_t *,
96 struct cred *);
97 extern int ksocket_sendto(ksocket_t, void *, size_t, int,
98 struct sockaddr *, socklen_t, size_t *, struct cred *);
99 extern int ksocket_sendmsg(ksocket_t, struct msghdr *, int, size_t *,
100 struct cred *);
101 extern int ksocket_sendmblk(ksocket_t, struct msghdr *, int,
102 struct msgb **, struct cred *);
103 extern int ksocket_recv(ksocket_t, void *, size_t, int, size_t *,
104 struct cred *);
105 extern int ksocket_recvfrom(ksocket_t, void *, size_t, int,
106 struct sockaddr *, socklen_t *, size_t *, struct cred *);
107 extern int ksocket_recvmsg(ksocket_t, struct msghdr *, int, size_t *,
108 struct cred *);
109 extern int ksocket_shutdown(ksocket_t, int, struct cred *);
110 extern int ksocket_setsockopt(ksocket_t, int, int, const void *, int,
111 struct cred *);
112 extern int ksocket_getsockopt(ksocket_t, int, int, void *, int *,
113 struct cred *);
114 extern int ksocket_getpeername(ksocket_t, struct sockaddr *, socklen_t *,
115 struct cred *);
116 extern int ksocket_getsockname(ksocket_t, struct sockaddr *, socklen_t *,
117 struct cred *);
118 extern int ksocket_ioctl(ksocket_t, int, intptr_t, int *, struct cred *);
119 extern int ksocket_spoll(ksocket_t, int, short, short *, struct cred *);
120 extern int ksocket_setcallbacks(ksocket_t, ksocket_callbacks_t *, void *,
121 struct cred *);
122 extern int ksocket_close(ksocket_t, struct cred *);
123 extern void ksocket_hold(ksocket_t);
124 extern void ksocket_rele(ksocket_t);
126 #ifdef __cplusplus
128 #endif
130 #endif /* _SYS_KSOCKET_H_ */