Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / uts / common / io / ksocket / ksocket_impl.h
blobac5251540fe57418a54d2c2f8b8521de954ead4a
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
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _INET_KSOCKET_KSOCKET_IMPL_H
28 #define _INET_KSOCKET_KSOCKET_IMPL_H
30 #define KSTOSO(ks) ((struct sonode *)(ks))
31 #define SOTOKS(so) ((ksocket_t)(uintptr_t)(so))
33 #define IS_KERNEL_SOCKET(so) ((so)->so_mode & SM_KERNEL)
35 #define KSOCKET_MOD_VERSION "kernel socket module"
37 #define __KSOCKET_EV_connected KSOCKET_EV_CONNECTED
38 #define __KSOCKET_EV_connectfailed KSOCKET_EV_CONNECTFAILED
39 #define __KSOCKET_EV_disconnected KSOCKET_EV_DISCONNECTED
40 #define __KSOCKET_EV_oobdata KSOCKET_EV_OOBDATA
41 #define __KSOCKET_EV_newdata KSOCKET_EV_NEWDATA
42 #define __KSOCKET_EV_newconn KSOCKET_EV_NEWCONN
43 #define __KSOCKET_EV_cansend KSOCKET_EV_CANSEND
44 #define __KSOCKET_EV_cantsendmore KSOCKET_EV_CANTSENDMORE
45 #define __KSOCKET_EV_cantrecvmore KSOCKET_EV_CANTRECVMORE
46 #define __KSOCKET_EV_error KSOCKET_EV_ERROR
48 #define KSOCKET_CALLBACK(so, cbfn, arg) \
49 if ((so)->so_ksock_callbacks.ksock_cb_##cbfn != NULL) { \
50 (*(so)->so_ksock_callbacks.ksock_cb_##cbfn)(SOTOKS(so), \
51 __KSOCKET_EV_##cbfn, (so)->so_ksock_cb_arg, (arg)); \
54 #define KSOCKET_FMODE(so) FREAD|FWRITE| \
55 ((KSTOSO(so)->so_state & (SS_NDELAY|SS_NONBLOCK)) ? FNDELAY : 0)
57 #define KSOCKET_VALID(ks) \
58 ((ks) != NULL && (KSTOSO(ks))->so_mode & SM_KERNEL && \
59 !((KSTOSO(ks))->so_state & SS_CLOSING))
61 #define SETCALLBACK(so, cb, cbfn, cbflg) \
62 if ((cb)->ksock_cb_flags & (cbflg)) { \
63 (so)->so_ksock_callbacks.ksock_cb_##cbfn \
64 = (cb)->ksock_cb_##cbfn; \
65 if ((cb)->ksock_cb_##cbfn == NULL) \
66 (so)->so_ksock_callbacks.ksock_cb_flags \
67 &= ~(cbflg); \
68 else \
69 (so)->so_ksock_callbacks.ksock_cb_flags \
70 |= (cbflg); \
74 #endif /* _INET_KSOCKET_KSOCKET_IMPL_H */