1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Basic library routines.
25 #ifndef __LIBCFS_DARWIN_TCPIP_H__
26 #define __LIBCFS_DARWIN_TCPIP_H__
29 #include <sys/socket.h>
35 typedef void (*so_upcall)(socket_t sock, void* arg, int waitf);
37 #define CFS_SOCK_UPCALL 0x1
38 #define CFS_SOCK_DOWN 0x2
40 #define CFS_SOCK_MAGIC 0xbabeface
42 typedef struct cfs_socket {
51 /* cfs_socket_t to bsd socket */
52 #define C2B_SOCK(s) ((s)->s_so)
54 static inline int get_sock_intopt(socket_t so, int opt)
60 * sock_getsockopt will take a lock(mutex) for socket,
61 * so it can be blocked. So be careful while using
65 rc = sock_getsockopt(so, SOL_SOCKET, opt, &val, &len);
70 #define SOCK_ERROR(s) get_sock_intopt(C2B_SOCK(s), SO_ERROR)
71 /* #define SOCK_WMEM_QUEUED(s) (0) */
72 #define SOCK_WMEM_QUEUED(s) get_sock_intopt(C2B_SOCK(s), SO_NWRITE)
73 /* XXX Liang: no reliable way to get it in Darwin8.x */
74 #define SOCK_TEST_NOSPACE(s) (0)
76 void libcfs_sock_set_cb(cfs_socket_t *sock, so_upcall callback, void *arg);
77 void libcfs_sock_reset_cb(cfs_socket_t *sock);
79 #else /* !__DARWIN8__ */
81 #define SOCK_WMEM_QUEUED(so) ((so)->so_snd.sb_cc)
82 #define SOCK_ERROR(so) ((so)->so_error)
84 #define SOCK_TEST_NOSPACE(so) (sbspace(&(so)->so_snd) < (so)->so_snd.sb_lowat)
86 #endif /* !__DARWIN8__ */
88 #endif /* __KERNEL END */
90 #endif /* __XNU_CFS_TYPES_H__ */