4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * libcfs/include/libcfs/darwin/darwin-tcpip.h
36 * Basic library routines.
39 #ifndef __LIBCFS_DARWIN_TCPIP_H__
40 #define __LIBCFS_DARWIN_TCPIP_H__
43 #include <sys/socket.h>
49 typedef void (*so_upcall)(socket_t sock, void* arg, int waitf);
51 #define CFS_SOCK_UPCALL 0x1
52 #define CFS_SOCK_DOWN 0x2
54 #define CFS_SOCK_MAGIC 0xbabeface
56 typedef struct cfs_socket {
65 /* cfs_socket_t to bsd socket */
66 #define C2B_SOCK(s) ((s)->s_so)
68 static inline int get_sock_intopt(socket_t so, int opt)
74 * sock_getsockopt will take a lock(mutex) for socket,
75 * so it can be blocked. So be careful while using
79 rc = sock_getsockopt(so, SOL_SOCKET, opt, &val, &len);
84 #define SOCK_ERROR(s) get_sock_intopt(C2B_SOCK(s), SO_ERROR)
85 /* #define SOCK_WMEM_QUEUED(s) (0) */
86 #define SOCK_WMEM_QUEUED(s) get_sock_intopt(C2B_SOCK(s), SO_NWRITE)
87 /* XXX Liang: no reliable way to get it in Darwin8.x */
88 #define SOCK_TEST_NOSPACE(s) (0)
90 void libcfs_sock_set_cb(cfs_socket_t *sock, so_upcall callback, void *arg);
91 void libcfs_sock_reset_cb(cfs_socket_t *sock);
93 #else /* !__DARWIN8__ */
95 #define SOCK_WMEM_QUEUED(so) ((so)->so_snd.sb_cc)
96 #define SOCK_ERROR(so) ((so)->so_error)
98 #define SOCK_TEST_NOSPACE(so) (sbspace(&(so)->so_snd) < (so)->so_snd.sb_lowat)
100 #endif /* !__DARWIN8__ */
102 #endif /* __KERNEL END */
104 #endif /* __XNU_CFS_TYPES_H__ */