xref: /titanic_41/usr/src/uts/common/inet/sctp_itf.h (revision 82629e3015252bf18319ba3815c773df23e21436)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_INET_SCTP_ITF_H
27 #define	_INET_SCTP_ITF_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <netinet/sctp.h>
34 
35 /*
36  * Kernel SCTP programming interface.  Note that this interface
37  * is private to Sun and can be changed without notice.
38  */
39 
40 #ifdef _KERNEL
41 
42 /*
43  * The version number of the SCTP kernel interface.  Use it with
44  * sctp_itf_ver() to verify if the kernel supports the correct
45  * version of the interface.
46  *
47  * NOTE: do not assume backward compatibility of the interface.
48  * If the return value of sctp_itf_ver() is different from what
49  * is expected, do not call any of the routines.
50  */
51 #define	SCTP_ITF_VER	2
52 
53 /*
54  * This struct holds various flow control limits the caller of
55  * sctp_create() should observe when interacting with SCTP.
56  */
57 typedef struct sctp_sockbuf_limits_s {
58 	int sbl_rxbuf;
59 	int sbl_rxlowat;
60 	int sbl_txbuf;
61 	int sbl_txlowat;
62 } sctp_sockbuf_limits_t;
63 
64 /*
65  * Parameter to SCTP_UC_SWAP setsockopt
66  */
67 struct sock_upcalls_s;
68 struct sctp_uc_swap {
69 	void			*sus_handle;
70 	struct sock_upcalls_s	*sus_upcalls;
71 };
72 
73 struct sctp_s;
74 
75 /*
76  * The list of routines the SCTP kernel module provides.
77  */
78 extern mblk_t *sctp_alloc_hdr(const char *name, int namelen,
79     const char *control, int controllen, int flags);
80 extern int sctp_bind(struct sctp_s *conn, struct sockaddr *addr,
81     socklen_t addrlen);
82 extern int sctp_bindx(struct sctp_s *conn, const void *addrs, int addrcnt,
83     int flags);
84 extern void sctp_close(struct sctp_s *conn);
85 extern int sctp_connect(struct sctp_s *conn, const struct sockaddr *dst,
86     socklen_t addrlen, cred_t *cr, pid_t pid);
87 extern struct sctp_s *sctp_create(void *newhandle, struct sctp_s *parent,
88     int family, int type, int flags, struct sock_upcalls_s *su,
89     sctp_sockbuf_limits_t *sbl, cred_t *cr);
90 extern int sctp_disconnect(struct sctp_s *conn);
91 extern int sctp_get_opt(struct sctp_s *conn, int level, int opt, void *opts,
92     socklen_t *optlen);
93 extern int sctp_getpeername(struct sctp_s *conn, struct sockaddr *addr,
94     socklen_t *addrlen);
95 extern int sctp_getsockname(struct sctp_s *conn, struct sockaddr *addr,
96     socklen_t *addrlen);
97 extern int sctp_itf_ver(int);
98 extern int sctp_listen(struct sctp_s *conn);
99 extern void sctp_recvd(struct sctp_s *conn, int len);
100 extern int sctp_sendmsg(struct sctp_s *conn, mblk_t *mp, int flags);
101 extern int sctp_set_opt(struct sctp_s *conn, int level, int opt,
102     const void *opts, socklen_t optlen);
103 
104 /* Flags for sctp_create(), sctp_alloc_hdr() */
105 #define	SCTP_CAN_BLOCK			0x01
106 
107 /* Flags for upcall su_recv() */
108 #define	SCTP_NOTIFICATION		0x01	/* message is a notification */
109 #define	SCTP_PARTIAL_DATA		0x02	/* not a full message */
110 
111 /* Use by sockfs to do sctp_peeloff(). */
112 #define	SCTP_UC_SWAP			255
113 
114 /*
115  * The following are private interfaces between Solaris SCTP and SunCluster.
116  * Hence, these interfaces are only for use by SunCluster and are *not* part
117  * of the general SCTP kernel interface.
118  */
119 
120 typedef uintptr_t cl_sctp_handle_t;
121 
122 typedef struct cl_sctp_info_s {
123 	ushort_t		cl_sctpi_version;
124 	ushort_t		cl_sctpi_family;
125 	ushort_t		cl_sctpi_ipversion;
126 	int32_t			cl_sctpi_state;
127 	in_port_t		cl_sctpi_lport;
128 	in_port_t		cl_sctpi_fport;
129 	uint_t			cl_sctpi_nladdr;
130 	uchar_t			*cl_sctpi_laddrp;
131 	uint_t			cl_sctpi_nfaddr;
132 	uchar_t			*cl_sctpi_faddrp;
133 	cl_sctp_handle_t	cl_sctpi_handle;
134 } cl_sctp_info_t;
135 
136 #define	CL_SCTPI_V1	1	/* cl_sctpi_version number */
137 
138 /* Used to indicate if the local or peer address list has changed */
139 #define	SCTP_CL_LADDR	1
140 #define	SCTP_CL_PADDR	2
141 
142 extern int cl_sctp_cookie_paddr(sctp_chunk_hdr_t *, in6_addr_t *);
143 extern int cl_sctp_walk_list(int (*callback)(cl_sctp_info_t *, void *), void *,
144     boolean_t);
145 
146 /* End of private SunCluster interfaces */
147 
148 #endif /* _KERNEL */
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif /* _INET_SCTP_ITF_H */
155