29 /*
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
32 * All Rights Reserved
33 *
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
36 * contributors.
37 */
38 /*
39 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
40 */
41
42 #ifndef _SYS_SOCKETVAR_H
43 #define _SYS_SOCKETVAR_H
44
45 #include <sys/types.h>
46 #include <sys/stream.h>
47 #include <sys/t_lock.h>
48 #include <sys/cred.h>
49 #include <sys/vnode.h>
50 #include <sys/file.h>
51 #include <sys/param.h>
52 #include <sys/zone.h>
53 #include <sys/sdt.h>
54 #include <sys/modctl.h>
55 #include <sys/atomic.h>
56 #include <sys/socket.h>
57 #include <sys/ksocket.h>
58 #include <sys/kstat.h>
59
60 #ifdef _KERNEL
61 #include <sys/vfs_opreg.h>
62 #endif
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67
68 /*
227
228 struct sock_proto_props so_proto_props; /* protocol settings */
229 boolean_t so_flowctrld; /* Flow controlled */
230 uint_t so_copyflag; /* Copy related flag */
231 kcondvar_t so_copy_cv; /* Copy cond variable */
232
233 /* kernel sockets */
234 ksocket_callbacks_t so_ksock_callbacks;
235 void *so_ksock_cb_arg; /* callback argument */
236 kcondvar_t so_closing_cv;
237
238 /* != NULL for sodirect enabled socket */
239 struct sodirect_s *so_direct;
240
241 /* socket filters */
242 uint_t so_filter_active; /* # of active fil */
243 uint_t so_filter_tx; /* pending tx ops */
244 struct sof_instance *so_filter_top; /* top of stack */
245 struct sof_instance *so_filter_bottom; /* bottom of stack */
246 clock_t so_filter_defertime; /* time when deferred */
247 };
248
249 #define SO_HAVE_DATA(so) \
250 /* \
251 * For the (tid == 0) case we must check so_rcv_{q_,}head \
252 * rather than (so_rcv_queued > 0), since the latter does not \
253 * take into account mblks with only control/name information. \
254 */ \
255 ((so)->so_rcv_timer_tid == 0 && ((so)->so_rcv_head != NULL || \
256 (so)->so_rcv_q_head != NULL)) || \
257 ((so)->so_state & SS_CANTRCVMORE)
258
259 /*
260 * Events handled by the protocol (in case sd_poll is set)
261 */
262 #define SO_PROTO_POLLEV (POLLIN|POLLRDNORM|POLLRDBAND)
263
264
265 #endif /* _KERNEL || _KMEMUSER */
266
934 int, int);
935 extern int sorecvmsg(struct sonode *, struct nmsghdr *, struct uio *);
936 extern int sosendmsg(struct sonode *, struct nmsghdr *, struct uio *);
937 extern int soshutdown(struct sonode *, int);
938 extern int sogetsockopt(struct sonode *, int, int, void *, socklen_t *,
939 int);
940 extern int sosetsockopt(struct sonode *, int, int, const void *,
941 t_uscalar_t);
942
943 extern struct sonode *socreate(struct sockparams *, int, int, int, int,
944 int *);
945
946 extern int so_copyin(const void *, void *, size_t, int);
947 extern int so_copyout(const void *, void *, size_t, int);
948
949 #endif
950
951 /*
952 * Internal structure for obtaining sonode information from the socklist.
953 * These types match those corresponding in the sonode structure.
954 * This is not a published interface, and may change at any time.
955 */
956 struct sockinfo {
957 uint_t si_size; /* real length of this struct */
958 short si_family;
959 short si_type;
960 ushort_t si_flag;
961 uint_t si_state;
962 uint_t si_ux_laddr_sou_magic;
963 uint_t si_ux_faddr_sou_magic;
964 t_scalar_t si_serv_type;
965 t_uscalar_t si_laddr_soa_len;
966 t_uscalar_t si_faddr_soa_len;
967 uint16_t si_laddr_family;
968 uint16_t si_faddr_family;
969 char si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */
970 char si_faddr_sun_path[MAXPATHLEN + 1];
971 boolean_t si_faddr_noxlate;
972 zoneid_t si_szoneid;
973 };
974
975 /*
976 * Subcodes for sockconf() system call
977 */
978 #define SOCKCONFIG_ADD_SOCK 0
979 #define SOCKCONFIG_REMOVE_SOCK 1
980 #define SOCKCONFIG_ADD_FILTER 2
981 #define SOCKCONFIG_REMOVE_FILTER 3
982 #define SOCKCONFIG_GET_SOCKTABLE 4
983
984 /*
985 * Data structures for configuring socket filters.
986 */
987
988 /*
989 * Placement hint for automatic filters
990 */
991 typedef enum {
992 SOF_HINT_NONE,
|
29 /*
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
32 * All Rights Reserved
33 *
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
36 * contributors.
37 */
38 /*
39 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
40 */
41
42 #ifndef _SYS_SOCKETVAR_H
43 #define _SYS_SOCKETVAR_H
44
45 #include <sys/types.h>
46 #include <sys/stream.h>
47 #include <sys/t_lock.h>
48 #include <sys/cred.h>
49 #include <sys/pidnode.h>
50 #include <sys/vnode.h>
51 #include <sys/file.h>
52 #include <sys/param.h>
53 #include <sys/zone.h>
54 #include <sys/sdt.h>
55 #include <sys/modctl.h>
56 #include <sys/atomic.h>
57 #include <sys/socket.h>
58 #include <sys/ksocket.h>
59 #include <sys/kstat.h>
60
61 #ifdef _KERNEL
62 #include <sys/vfs_opreg.h>
63 #endif
64
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68
69 /*
228
229 struct sock_proto_props so_proto_props; /* protocol settings */
230 boolean_t so_flowctrld; /* Flow controlled */
231 uint_t so_copyflag; /* Copy related flag */
232 kcondvar_t so_copy_cv; /* Copy cond variable */
233
234 /* kernel sockets */
235 ksocket_callbacks_t so_ksock_callbacks;
236 void *so_ksock_cb_arg; /* callback argument */
237 kcondvar_t so_closing_cv;
238
239 /* != NULL for sodirect enabled socket */
240 struct sodirect_s *so_direct;
241
242 /* socket filters */
243 uint_t so_filter_active; /* # of active fil */
244 uint_t so_filter_tx; /* pending tx ops */
245 struct sof_instance *so_filter_top; /* top of stack */
246 struct sof_instance *so_filter_bottom; /* bottom of stack */
247 clock_t so_filter_defertime; /* time when deferred */
248
249 /* pid tree */
250 avl_tree_t so_pid_tree;
251 kmutex_t so_pid_tree_lock;
252 };
253
254 #define SO_HAVE_DATA(so) \
255 /* \
256 * For the (tid == 0) case we must check so_rcv_{q_,}head \
257 * rather than (so_rcv_queued > 0), since the latter does not \
258 * take into account mblks with only control/name information. \
259 */ \
260 ((so)->so_rcv_timer_tid == 0 && ((so)->so_rcv_head != NULL || \
261 (so)->so_rcv_q_head != NULL)) || \
262 ((so)->so_state & SS_CANTRCVMORE)
263
264 /*
265 * Events handled by the protocol (in case sd_poll is set)
266 */
267 #define SO_PROTO_POLLEV (POLLIN|POLLRDNORM|POLLRDBAND)
268
269
270 #endif /* _KERNEL || _KMEMUSER */
271
939 int, int);
940 extern int sorecvmsg(struct sonode *, struct nmsghdr *, struct uio *);
941 extern int sosendmsg(struct sonode *, struct nmsghdr *, struct uio *);
942 extern int soshutdown(struct sonode *, int);
943 extern int sogetsockopt(struct sonode *, int, int, void *, socklen_t *,
944 int);
945 extern int sosetsockopt(struct sonode *, int, int, const void *,
946 t_uscalar_t);
947
948 extern struct sonode *socreate(struct sockparams *, int, int, int, int,
949 int *);
950
951 extern int so_copyin(const void *, void *, size_t, int);
952 extern int so_copyout(const void *, void *, size_t, int);
953
954 #endif
955
956 /*
957 * Internal structure for obtaining sonode information from the socklist.
958 * These types match those corresponding in the sonode structure.
959 * This is not a published interface, and may change at any time. It is
960 * used for passing information back up to the kstat consumers. By converting
961 * kernel addresses to strings, we should be able to pass information from
962 * the kernel to userland regardless of n-bit kernel we are using.
963 */
964
965 #define ADRSTRLEN (2 * sizeof (uint64_t) + 1)
966
967 struct sockinfo {
968 uint_t si_size; /* real length of this struct */
969 short si_family;
970 short si_type;
971 ushort_t si_flag;
972 uint_t si_state;
973 uint_t si_ux_laddr_sou_magic;
974 uint_t si_ux_faddr_sou_magic;
975 t_scalar_t si_serv_type;
976 t_uscalar_t si_laddr_soa_len;
977 t_uscalar_t si_faddr_soa_len;
978 uint16_t si_laddr_family;
979 uint16_t si_faddr_family;
980 char si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */
981 char si_faddr_sun_path[MAXPATHLEN + 1];
982 boolean_t si_faddr_noxlate;
983 zoneid_t si_szoneid;
984 char si_son_straddr[ADRSTRLEN];
985 char si_lvn_straddr[ADRSTRLEN];
986 char si_fvn_straddr[ADRSTRLEN];
987 uint_t si_pn_cnt;
988 pid_t si_pids[1];
989 };
990
991 /*
992 * Subcodes for sockconf() system call
993 */
994 #define SOCKCONFIG_ADD_SOCK 0
995 #define SOCKCONFIG_REMOVE_SOCK 1
996 #define SOCKCONFIG_ADD_FILTER 2
997 #define SOCKCONFIG_REMOVE_FILTER 3
998 #define SOCKCONFIG_GET_SOCKTABLE 4
999
1000 /*
1001 * Data structures for configuring socket filters.
1002 */
1003
1004 /*
1005 * Placement hint for automatic filters
1006 */
1007 typedef enum {
1008 SOF_HINT_NONE,
|