10f1702c5SYu Xiangning /* 20f1702c5SYu Xiangning * CDDL HEADER START 30f1702c5SYu Xiangning * 40f1702c5SYu Xiangning * The contents of this file are subject to the terms of the 50f1702c5SYu Xiangning * Common Development and Distribution License (the "License"). 60f1702c5SYu Xiangning * You may not use this file except in compliance with the License. 70f1702c5SYu Xiangning * 80f1702c5SYu Xiangning * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90f1702c5SYu Xiangning * or http://www.opensolaris.org/os/licensing. 100f1702c5SYu Xiangning * See the License for the specific language governing permissions 110f1702c5SYu Xiangning * and limitations under the License. 120f1702c5SYu Xiangning * 130f1702c5SYu Xiangning * When distributing Covered Code, include this CDDL HEADER in each 140f1702c5SYu Xiangning * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150f1702c5SYu Xiangning * If applicable, add the following below this CDDL HEADER, with the 160f1702c5SYu Xiangning * fields enclosed by brackets "[]" replaced with your own identifying 170f1702c5SYu Xiangning * information: Portions Copyright [yyyy] [name of copyright owner] 180f1702c5SYu Xiangning * 190f1702c5SYu Xiangning * CDDL HEADER END 200f1702c5SYu Xiangning */ 210f1702c5SYu Xiangning /* 22*3076c25aSStepan Zastupov * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 233e95bd4aSAnders Persson * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 240f1702c5SYu Xiangning */ 250f1702c5SYu Xiangning 260f1702c5SYu Xiangning #ifndef _SYS_KSOCKET_H_ 270f1702c5SYu Xiangning #define _SYS_KSOCKET_H_ 280f1702c5SYu Xiangning 290f1702c5SYu Xiangning #ifdef __cplusplus 300f1702c5SYu Xiangning extern "C" { 310f1702c5SYu Xiangning #endif 320f1702c5SYu Xiangning 330f1702c5SYu Xiangning /* Opaque kernel socket type */ 340f1702c5SYu Xiangning typedef struct __ksocket *ksocket_t; 350f1702c5SYu Xiangning struct nmsghdr; 360f1702c5SYu Xiangning 370f1702c5SYu Xiangning /* flag bit for each Callback Event */ 380f1702c5SYu Xiangning #define KSOCKET_CB_CONNECTED 0x00000001 390f1702c5SYu Xiangning #define KSOCKET_CB_CONNECTFAILED 0x00000002 400f1702c5SYu Xiangning #define KSOCKET_CB_DISCONNECTED 0x00000004 410f1702c5SYu Xiangning #define KSOCKET_CB_NEWDATA 0x00000008 420f1702c5SYu Xiangning #define KSOCKET_CB_NEWCONN 0x00000010 430f1702c5SYu Xiangning #define KSOCKET_CB_CANSEND 0x00000020 440f1702c5SYu Xiangning #define KSOCKET_CB_OOBDATA 0x00000040 450f1702c5SYu Xiangning #define KSOCKET_CB_CANTSENDMORE 0x00000080 460f1702c5SYu Xiangning #define KSOCKET_CB_CANTRECVMORE 0x00000100 470f1702c5SYu Xiangning #define KSOCKET_CB_ERROR 0x00000200 480f1702c5SYu Xiangning 490f1702c5SYu Xiangning /* 500f1702c5SYu Xiangning * Kernel Socket Callback Events 510f1702c5SYu Xiangning */ 520f1702c5SYu Xiangning typedef enum ksocket_event { 530f1702c5SYu Xiangning KSOCKET_EV_CONNECTED, 540f1702c5SYu Xiangning KSOCKET_EV_CONNECTFAILED, 550f1702c5SYu Xiangning KSOCKET_EV_DISCONNECTED, 560f1702c5SYu Xiangning KSOCKET_EV_OOBDATA, 570f1702c5SYu Xiangning KSOCKET_EV_NEWDATA, 580f1702c5SYu Xiangning KSOCKET_EV_NEWCONN, 590f1702c5SYu Xiangning KSOCKET_EV_CANSEND, 600f1702c5SYu Xiangning KSOCKET_EV_CANTSENDMORE, 610f1702c5SYu Xiangning KSOCKET_EV_CANTRECVMORE, 620f1702c5SYu Xiangning KSOCKET_EV_ERROR 630f1702c5SYu Xiangning } ksocket_callback_event_t; 640f1702c5SYu Xiangning 650f1702c5SYu Xiangning typedef void (*ksocket_callback_t)(ksocket_t, ksocket_callback_event_t, 660f1702c5SYu Xiangning void *, uintptr_t); 670f1702c5SYu Xiangning 680f1702c5SYu Xiangning typedef struct ksocket_callbacks { 690f1702c5SYu Xiangning uint32_t ksock_cb_flags; 700f1702c5SYu Xiangning ksocket_callback_t ksock_cb_connected; 710f1702c5SYu Xiangning ksocket_callback_t ksock_cb_connectfailed; 720f1702c5SYu Xiangning ksocket_callback_t ksock_cb_disconnected; 730f1702c5SYu Xiangning ksocket_callback_t ksock_cb_newdata; 740f1702c5SYu Xiangning ksocket_callback_t ksock_cb_newconn; 750f1702c5SYu Xiangning ksocket_callback_t ksock_cb_cansend; 760f1702c5SYu Xiangning ksocket_callback_t ksock_cb_oobdata; 770f1702c5SYu Xiangning ksocket_callback_t ksock_cb_cantsendmore; 780f1702c5SYu Xiangning ksocket_callback_t ksock_cb_cantrecvmore; 790f1702c5SYu Xiangning ksocket_callback_t ksock_cb_error; 800f1702c5SYu Xiangning } ksocket_callbacks_t; 810f1702c5SYu Xiangning 820f1702c5SYu Xiangning #define KSOCKET_SLEEP SOCKET_SLEEP 830f1702c5SYu Xiangning #define KSOCKET_NOSLEEP SOCKET_NOSLEEP 840f1702c5SYu Xiangning 850f1702c5SYu Xiangning extern int ksocket_socket(ksocket_t *, int, int, int, int, struct cred *); 860f1702c5SYu Xiangning extern int ksocket_bind(ksocket_t, struct sockaddr *, socklen_t, 870f1702c5SYu Xiangning struct cred *); 880f1702c5SYu Xiangning extern int ksocket_listen(ksocket_t, int, struct cred *); 890f1702c5SYu Xiangning extern int ksocket_accept(ksocket_t, struct sockaddr *, socklen_t *, 900f1702c5SYu Xiangning ksocket_t *, struct cred *); 913e95bd4aSAnders Persson extern int ksocket_connect(ksocket_t, struct sockaddr *, socklen_t, 920f1702c5SYu Xiangning struct cred *); 930f1702c5SYu Xiangning extern int ksocket_send(ksocket_t, void *, size_t, int, size_t *, 940f1702c5SYu Xiangning struct cred *); 950f1702c5SYu Xiangning extern int ksocket_sendto(ksocket_t, void *, size_t, int, 960f1702c5SYu Xiangning struct sockaddr *, socklen_t, size_t *, struct cred *); 970f1702c5SYu Xiangning extern int ksocket_sendmsg(ksocket_t, struct nmsghdr *, int, size_t *, 980f1702c5SYu Xiangning struct cred *); 990f1702c5SYu Xiangning extern int ksocket_sendmblk(ksocket_t, struct nmsghdr *, int, mblk_t **, 1000f1702c5SYu Xiangning struct cred *); 1010f1702c5SYu Xiangning extern int ksocket_recv(ksocket_t, void *, size_t, int, size_t *, 1020f1702c5SYu Xiangning struct cred *); 1030f1702c5SYu Xiangning extern int ksocket_recvfrom(ksocket_t, void *, size_t, int, 1040f1702c5SYu Xiangning struct sockaddr *, socklen_t *, size_t *, struct cred *); 1050f1702c5SYu Xiangning extern int ksocket_recvmsg(ksocket_t, struct nmsghdr *, int, size_t *, 1060f1702c5SYu Xiangning struct cred *); 1070f1702c5SYu Xiangning extern int ksocket_shutdown(ksocket_t, int, struct cred *); 1080f1702c5SYu Xiangning extern int ksocket_setsockopt(ksocket_t, int, int, const void *, int, 1090f1702c5SYu Xiangning struct cred *); 1100f1702c5SYu Xiangning extern int ksocket_getsockopt(ksocket_t, int, int, void *, int *, 1110f1702c5SYu Xiangning struct cred *); 1120f1702c5SYu Xiangning extern int ksocket_getpeername(ksocket_t, struct sockaddr *, socklen_t *, 1130f1702c5SYu Xiangning struct cred *); 1140f1702c5SYu Xiangning extern int ksocket_getsockname(ksocket_t, struct sockaddr *, socklen_t *, 1150f1702c5SYu Xiangning struct cred *); 1160f1702c5SYu Xiangning extern int ksocket_ioctl(ksocket_t, int, intptr_t, int *, struct cred *); 117*3076c25aSStepan Zastupov extern int ksocket_spoll(ksocket_t, int, short, short *, struct cred *); 1180f1702c5SYu Xiangning extern int ksocket_setcallbacks(ksocket_t, ksocket_callbacks_t *, void *, 1190f1702c5SYu Xiangning struct cred *); 1200f1702c5SYu Xiangning extern int ksocket_close(ksocket_t, struct cred *); 1210f1702c5SYu Xiangning extern void ksocket_hold(ksocket_t); 1220f1702c5SYu Xiangning extern void ksocket_rele(ksocket_t); 1230f1702c5SYu Xiangning 1240f1702c5SYu Xiangning #ifdef __cplusplus 1250f1702c5SYu Xiangning } 1260f1702c5SYu Xiangning #endif 1270f1702c5SYu Xiangning 1280f1702c5SYu Xiangning #endif /* _SYS_KSOCKET_H_ */ 129