xref: /illumos-gate/usr/src/uts/common/inet/sdp_itf.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_INET_SDP_ITF_H
27 #define	_INET_SDP_ITF_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Kernel SDP programming interface.  Note that this interface
35  * is private to Sun and can be changed without notice.
36  */
37 
38 #ifdef _KERNEL
39 
40 /*
41  * The version number of the SDP kernel interface.  Use it with
42  * sdp_itf_ver() to verify if the kernel supports the correct
43  * version of the interface.
44  *
45  * NOTE: do not assume backward compatibility of the interface.
46  * If the return value of sdp_itf_ver() is different from what
47  * is expected, do not call any of the routines.
48  */
49 #define	SDP_ITF_VER	1
50 
51 /*
52  * This struct holds all the upcalls the SDP kernel module will
53  * invoke for different events.  When calling sdp_create() to create
54  * a SDP handle, the caller must provide this information.
55  */
56 typedef struct sdp_upcalls_s {
57 	void *	(*su_newconn)(void *parenthandle, void *connind);
58 	void	(*su_connected)(void *handle);
59 	void	(*su_disconnected)(void *handle, int error);
60 	void	(*su_connfailed)(void *handle, int error);
61 	int	(*su_recv)(void *handle, mblk_t *mp, int flags);
62 	void	(*su_xmitted)(void *handle, int writeable);
63 	void	(*su_urgdata)(void *handle);
64 	void	(*su_ordrel)(void *handle);
65 } sdp_upcalls_t;
66 
67 
68 /*
69  * This struct holds various flow control limits the caller of
70  * sdp_create() should observe when interacting with SDP.
71  */
72 typedef struct sdp_sockbuf_limits_s {
73 	int sbl_rxbuf;
74 	int sbl_rxlowat;
75 	int sbl_txbuf;
76 	int sbl_txlowat;
77 } sdp_sockbuf_limits_t;
78 
79 struct sdp_conn_struct_t;
80 
81 /*
82  * The list of routines the SDP kernel module provides.
83  */
84 extern int sdp_bind(struct sdp_conn_struct_t *conn, struct sockaddr *addr,
85     socklen_t addrlen);
86 extern void sdp_close(struct sdp_conn_struct_t *conn);
87 extern int sdp_connect(struct sdp_conn_struct_t *conn,
88     const struct sockaddr *dst, socklen_t addrlen);
89 extern struct sdp_conn_struct_t *sdp_create(void *newhandle,
90     struct sdp_conn_struct_t *parent, int family, int flags,
91     const sdp_upcalls_t *su, sdp_sockbuf_limits_t *sbl, cred_t *cr,
92     int *error);
93 extern int sdp_disconnect(struct sdp_conn_struct_t *conn, int flags);
94 extern int sdp_shutdown(struct sdp_conn_struct_t *conn, int flag);
95 extern int sdp_polldata(struct sdp_conn_struct_t *conn, int flag);
96 extern int sdp_get_opt(struct sdp_conn_struct_t *conn, int level, int opt,
97     void *opts, socklen_t *optlen);
98 extern int sdp_getpeername(struct sdp_conn_struct_t *conn,
99     struct sockaddr *addr, socklen_t *addrlen);
100 extern int sdp_getsockname(struct sdp_conn_struct_t *conn,
101     struct sockaddr *addr, socklen_t *addrlen);
102 extern int sdp_itf_ver(int);
103 extern int sdp_listen(struct sdp_conn_struct_t *conn, int backlog);
104 extern int sdp_send(struct sdp_conn_struct_t *conn, struct msghdr *msg,
105     size_t size, int flags, struct uio *uiop);
106 extern int sdp_recv(struct sdp_conn_struct_t *conn, struct msghdr *msg,
107     size_t size, int flags, struct uio *uiop);
108 extern int sdp_set_opt(struct sdp_conn_struct_t *conn, int level, int opt,
109     const void *opts, socklen_t optlen);
110 extern int sdp_ioctl(struct sdp_conn_struct_t *conn, int cmd, int32_t *value,
111     struct cred *cr);
112 
113 
114 /* Flags for sdp_create() */
115 #define	SDP_CAN_BLOCK			0x01
116 
117 #define	SDP_READ 0x01
118 #define	SDP_XMIT 0x02
119 
120 #endif /* _KERNEL */
121 
122 #define	SDP_NODELAY 0x01
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* _INET_SDP_ITF_H */
129