xref: /titanic_44/usr/src/uts/common/inet/sctp_itf.h (revision fb3fb4f3d76d55b64440afd0af72775dfad3bd1d)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_INET_SCTP_ITF_H
28 #define	_INET_SCTP_ITF_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <netinet/sctp.h>
37 
38 /*
39  * Kernel SCTP programming interface.  Note that this interface
40  * is private to Sun and can be changed without notice.
41  */
42 
43 #ifdef _KERNEL
44 
45 /*
46  * The version number of the SCTP kernel interface.  Use it with
47  * sctp_itf_ver() to verify if the kernel supports the correct
48  * version of the interface.
49  *
50  * NOTE: do not assume backward compatibility of the interface.
51  * If the return value of sctp_itf_ver() is different from what
52  * is expected, do not call any of the routines.
53  */
54 #define	SCTP_ITF_VER	1
55 
56 /*
57  * This struct holds all the upcalls the SCTP kernel module will
58  * invoke for different events.  When calling sctp_create() to create
59  * a SCTP handle, the caller must provide this information.
60  */
61 typedef struct sctp_upcalls_s {
62 	void *	(*su_newconn)(void *parenthandle, void *connind);
63 	void	(*su_connected)(void *handle);
64 	int	(*su_disconnected)(void *handle, int error);
65 	void	(*su_disconnecting)(void *handle);
66 	int	(*su_recv)(void *handle, mblk_t *mp, int flags);
67 	void	(*su_xmitted)(void *handle, int txqueued);
68 	void	(*su_properties)(void *handle, int wroff, size_t maxblk);
69 } sctp_upcalls_t;
70 
71 /*
72  * This struct holds various flow control limits the caller of
73  * sctp_create() should observe when interacting with SCTP.
74  */
75 typedef struct sctp_sockbuf_limits_s {
76 	int sbl_rxbuf;
77 	int sbl_rxlowat;
78 	int sbl_txbuf;
79 	int sbl_txlowat;
80 } sctp_sockbuf_limits_t;
81 
82 /*
83  * Parameter to SCTP_UC_SWAP setsockopt
84  */
85 struct sctp_uc_swap {
86 	void		*sus_handle;
87 	sctp_upcalls_t	*sus_upcalls;
88 };
89 
90 struct sctp_s;
91 
92 /*
93  * The list of routines the SCTP kernel module provides.
94  */
95 extern mblk_t *sctp_alloc_hdr(const char *name, int namelen,
96     const char *control, int controllen, int flags);
97 extern int sctp_bind(struct sctp_s *conn, struct sockaddr *addr,
98     socklen_t addrlen);
99 extern int sctp_bindx(struct sctp_s *conn, const void *addrs, int addrcnt,
100     int flags);
101 extern void sctp_close(struct sctp_s *conn);
102 extern int sctp_connect(struct sctp_s *conn, const struct sockaddr *dst,
103     socklen_t addrlen);
104 extern struct sctp_s *sctp_create(void *newhandle, struct sctp_s *parent,
105     int family, int flags, const sctp_upcalls_t *su,
106     sctp_sockbuf_limits_t *sbl, cred_t *cr);
107 extern int sctp_disconnect(struct sctp_s *conn);
108 extern int sctp_get_opt(struct sctp_s *conn, int level, int opt, void *opts,
109     socklen_t *optlen);
110 extern int sctp_getpeername(struct sctp_s *conn, struct sockaddr *addr,
111     socklen_t *addrlen);
112 extern int sctp_getsockname(struct sctp_s *conn, struct sockaddr *addr,
113     socklen_t *addrlen);
114 extern int sctp_itf_ver(int);
115 extern int sctp_listen(struct sctp_s *conn);
116 extern void sctp_recvd(struct sctp_s *conn, int len);
117 extern int sctp_sendmsg(struct sctp_s *conn, mblk_t *mp, int flags);
118 extern int sctp_set_opt(struct sctp_s *conn, int level, int opt,
119     const void *opts, socklen_t optlen);
120 
121 /* Flags for sctp_create(), sctp_alloc_hdr() */
122 #define	SCTP_CAN_BLOCK			0x01
123 
124 /* Flags for upcall su_recv() */
125 #define	SCTP_NOTIFICATION		0x01	/* message is a notification */
126 #define	SCTP_PARTIAL_DATA		0x02	/* not a full message */
127 
128 /* Use by sockfs to do sctp_peeloff(). */
129 #define	SCTP_UC_SWAP			255
130 
131 /*
132  * The following are private interfaces between Solaris SCTP and SunCluster.
133  * Hence, these interfaces are only for use by SunCluster and are *not* part
134  * of the general SCTP kernel interface.
135  */
136 
137 typedef uintptr_t cl_sctp_handle_t;
138 
139 typedef struct cl_sctp_info_s {
140 	ushort_t		cl_sctpi_version;
141 	ushort_t		cl_sctpi_family;
142 	ushort_t		cl_sctpi_ipversion;
143 	int32_t			cl_sctpi_state;
144 	in_port_t		cl_sctpi_lport;
145 	in_port_t		cl_sctpi_fport;
146 	uint_t			cl_sctpi_nladdr;
147 	uchar_t			*cl_sctpi_laddrp;
148 	uint_t			cl_sctpi_nfaddr;
149 	uchar_t			*cl_sctpi_faddrp;
150 	cl_sctp_handle_t	cl_sctpi_handle;
151 } cl_sctp_info_t;
152 
153 #define	CL_SCTPI_V1	1	/* cl_sctpi_version number */
154 
155 /* Used to indicate if the local or peer address list has changed */
156 #define	SCTP_CL_LADDR	1
157 #define	SCTP_CL_PADDR	2
158 
159 extern int cl_sctp_cookie_paddr(sctp_chunk_hdr_t *, in6_addr_t *);
160 extern int cl_sctp_walk_list(int (*callback)(cl_sctp_info_t *, void *), void *,
161     boolean_t);
162 
163 /* End of private SunCluster interfaces */
164 
165 #endif /* _KERNEL */
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* _INET_SCTP_ITF_H */
172