18348SEric.Yu@Sun.COM /* 28348SEric.Yu@Sun.COM * CDDL HEADER START 38348SEric.Yu@Sun.COM * 48348SEric.Yu@Sun.COM * The contents of this file are subject to the terms of the 58348SEric.Yu@Sun.COM * Common Development and Distribution License (the "License"). 68348SEric.Yu@Sun.COM * You may not use this file except in compliance with the License. 78348SEric.Yu@Sun.COM * 88348SEric.Yu@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 98348SEric.Yu@Sun.COM * or http://www.opensolaris.org/os/licensing. 108348SEric.Yu@Sun.COM * See the License for the specific language governing permissions 118348SEric.Yu@Sun.COM * and limitations under the License. 128348SEric.Yu@Sun.COM * 138348SEric.Yu@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 148348SEric.Yu@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 158348SEric.Yu@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 168348SEric.Yu@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 178348SEric.Yu@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 188348SEric.Yu@Sun.COM * 198348SEric.Yu@Sun.COM * CDDL HEADER END 208348SEric.Yu@Sun.COM */ 21*13054SKacheong.Poon@Sun.COM 228348SEric.Yu@Sun.COM /* 23*13054SKacheong.Poon@Sun.COM * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 248348SEric.Yu@Sun.COM */ 258348SEric.Yu@Sun.COM 268348SEric.Yu@Sun.COM #ifndef _SOCKSCTP_H_ 278348SEric.Yu@Sun.COM #define _SOCKSCTP_H_ 288348SEric.Yu@Sun.COM 298348SEric.Yu@Sun.COM #ifdef __cplusplus 308348SEric.Yu@Sun.COM extern "C" { 318348SEric.Yu@Sun.COM #endif 328348SEric.Yu@Sun.COM 338348SEric.Yu@Sun.COM /* 348348SEric.Yu@Sun.COM * SCTP socket structure. 358348SEric.Yu@Sun.COM * 368348SEric.Yu@Sun.COM * The opaque pointer passed in upcalls is either a pointer to sctp_sonode, 378348SEric.Yu@Sun.COM * or sctp_soassoc. The identification is done through the first element 388348SEric.Yu@Sun.COM * in data structure (if it cannot be identified by upcall which gets called). 398348SEric.Yu@Sun.COM */ 408348SEric.Yu@Sun.COM struct sctp_sonode { 418348SEric.Yu@Sun.COM int ss_type; /* sonode or soassoc */ 428348SEric.Yu@Sun.COM struct sonode ss_so; 438348SEric.Yu@Sun.COM sctp_assoc_t ss_maxassoc; /* assoc array size for 1-N */ 448348SEric.Yu@Sun.COM sctp_assoc_t ss_assoccnt; /* current # of assocs */ 458348SEric.Yu@Sun.COM struct sctp_sa_id *ss_assocs; /* assoc array for 1-N */ 468348SEric.Yu@Sun.COM #define ss_wroff ss_so.so_proto_props.sopp_wroff 478348SEric.Yu@Sun.COM #define ss_wrsize ss_so.so_proto_props.sopp_maxblk 488348SEric.Yu@Sun.COM }; 498348SEric.Yu@Sun.COM 508348SEric.Yu@Sun.COM /* 518348SEric.Yu@Sun.COM * Association for 1-N sockets. 528348SEric.Yu@Sun.COM */ 538348SEric.Yu@Sun.COM struct sctp_soassoc { 548348SEric.Yu@Sun.COM int ssa_type; 558348SEric.Yu@Sun.COM sctp_assoc_t ssa_id; /* association ID */ 568348SEric.Yu@Sun.COM uint_t ssa_refcnt; 578348SEric.Yu@Sun.COM struct sctp_sonode *ssa_sonode; 588348SEric.Yu@Sun.COM struct sctp_s *ssa_conn; /* opaque ptr passed to SCTP */ 598348SEric.Yu@Sun.COM uint_t ssa_state; /* same as so_state */ 608348SEric.Yu@Sun.COM int ssa_error; /* same as so_error */ 618348SEric.Yu@Sun.COM boolean_t ssa_snd_qfull; 62*13054SKacheong.Poon@Sun.COM ushort_t ssa_wroff; 63*13054SKacheong.Poon@Sun.COM ssize_t ssa_wrsize; 648348SEric.Yu@Sun.COM int ssa_rcv_queued; /* queued rx bytes/# of conn */ 65*13054SKacheong.Poon@Sun.COM boolean_t ssa_flowctrld; /* receive flow controlled */ 668348SEric.Yu@Sun.COM }; 678348SEric.Yu@Sun.COM 688348SEric.Yu@Sun.COM /* 1-N socket association cache defined in socksctp.c */ 698348SEric.Yu@Sun.COM 708348SEric.Yu@Sun.COM /* 718348SEric.Yu@Sun.COM * Association array element. 728348SEric.Yu@Sun.COM * 738348SEric.Yu@Sun.COM * Association data structures for 1-N socket are stored in 748348SEric.Yu@Sun.COM * an array in similar manner to file descriptor array. 758348SEric.Yu@Sun.COM * Each association is identified by its association ID, which also 768348SEric.Yu@Sun.COM * is used as an index to this array (again, like file descriptor number). 778348SEric.Yu@Sun.COM */ 788348SEric.Yu@Sun.COM struct sctp_sa_id { 798348SEric.Yu@Sun.COM sctp_assoc_t ssi_alloc; 808348SEric.Yu@Sun.COM struct sctp_soassoc *ssi_assoc; 818348SEric.Yu@Sun.COM }; 828348SEric.Yu@Sun.COM 838348SEric.Yu@Sun.COM extern sonodeops_t sosctp_sonodeops; 848348SEric.Yu@Sun.COM extern sonodeops_t sosctp_seq_sonodeops; 858348SEric.Yu@Sun.COM extern sock_upcalls_t sosctp_sock_upcalls; 868348SEric.Yu@Sun.COM extern sock_upcalls_t sosctp_assoc_upcalls; 878348SEric.Yu@Sun.COM 888348SEric.Yu@Sun.COM extern struct sonode *socksctp_create(struct sockparams *, int, int, 898348SEric.Yu@Sun.COM int, int, int, int *, cred_t *); 908348SEric.Yu@Sun.COM extern void sosctp_fini(struct sonode *, struct cred *); 918348SEric.Yu@Sun.COM extern int sosctp_aid_grow(struct sctp_sonode *ss, sctp_assoc_t maxid, 928348SEric.Yu@Sun.COM int kmflags); 938348SEric.Yu@Sun.COM extern sctp_assoc_t sosctp_aid_get(struct sctp_sonode *ss); 948348SEric.Yu@Sun.COM extern void sosctp_aid_reserve(struct sctp_sonode *ss, sctp_assoc_t id, 958348SEric.Yu@Sun.COM int incr); 968348SEric.Yu@Sun.COM extern struct cmsghdr *sosctp_find_cmsg(const uchar_t *control, socklen_t clen, 978348SEric.Yu@Sun.COM int type); 988348SEric.Yu@Sun.COM extern void sosctp_pack_cmsg(const uchar_t *, struct nmsghdr *, int); 998348SEric.Yu@Sun.COM 1008348SEric.Yu@Sun.COM extern int sosctp_assoc(struct sctp_sonode *ss, sctp_assoc_t id, 1018348SEric.Yu@Sun.COM struct sctp_soassoc **ssa); 1028348SEric.Yu@Sun.COM extern struct sctp_soassoc *sosctp_assoc_create(struct sctp_sonode *ss, 1038348SEric.Yu@Sun.COM int kmflags); 1048348SEric.Yu@Sun.COM extern void sosctp_assoc_free(struct sctp_sonode *ss, struct sctp_soassoc *ssa); 1058348SEric.Yu@Sun.COM extern int sosctp_assoc_createconn(struct sctp_sonode *ss, 1068348SEric.Yu@Sun.COM const struct sockaddr *name, socklen_t namelen, 1078348SEric.Yu@Sun.COM const uchar_t *control, socklen_t controllen, int fflag, struct cred *, 1088348SEric.Yu@Sun.COM struct sctp_soassoc **ssap); 1098348SEric.Yu@Sun.COM extern void sosctp_assoc_move(struct sctp_sonode *ss, struct sctp_sonode *nss, 1108348SEric.Yu@Sun.COM struct sctp_soassoc *ssa); 1118348SEric.Yu@Sun.COM extern void sosctp_so_inherit(struct sctp_sonode *lss, struct sctp_sonode *nss); 1128348SEric.Yu@Sun.COM 1138348SEric.Yu@Sun.COM extern void sosctp_assoc_isconnecting(struct sctp_soassoc *ssa); 1148348SEric.Yu@Sun.COM extern void sosctp_assoc_isconnected(struct sctp_soassoc *ssa); 1158348SEric.Yu@Sun.COM extern void sosctp_assoc_isdisconnecting(struct sctp_soassoc *ssa); 1168348SEric.Yu@Sun.COM extern void sosctp_assoc_isdisconnected(struct sctp_soassoc *ssa, int error); 1178348SEric.Yu@Sun.COM 1188348SEric.Yu@Sun.COM extern int sosctp_waitconnected(struct sonode *so, int fmode); 1198348SEric.Yu@Sun.COM extern int sosctp_uiomove(mblk_t *hdr_mp, ssize_t count, ssize_t blk_size, 12011042SErik.Nordmark@Sun.COM int wroff, struct uio *uiop, int flags); 1218348SEric.Yu@Sun.COM 1228348SEric.Yu@Sun.COM /* 1238348SEric.Yu@Sun.COM * Data structure types. 1248348SEric.Yu@Sun.COM */ 1258348SEric.Yu@Sun.COM #define SOSCTP_SOCKET 0x1 1268348SEric.Yu@Sun.COM #define SOSCTP_ASSOC 0x2 1278348SEric.Yu@Sun.COM 1288348SEric.Yu@Sun.COM #define SOTOSSO(so) ((struct sctp_sonode *)(((char *)so) - \ 1298348SEric.Yu@Sun.COM offsetof(struct sctp_sonode, ss_so))) 1308348SEric.Yu@Sun.COM 1318348SEric.Yu@Sun.COM #define SSA_REFHOLD(ssa) \ 1328348SEric.Yu@Sun.COM { \ 1338348SEric.Yu@Sun.COM ASSERT(MUTEX_HELD(&(ssa)->ssa_sonode->ss_so.so_lock)); \ 1348348SEric.Yu@Sun.COM ASSERT((ssa)->ssa_refcnt > 0); \ 1358348SEric.Yu@Sun.COM ++(ssa)->ssa_refcnt; \ 1368348SEric.Yu@Sun.COM dprint(3, ("ssa_refhold on %p %d (%s,%d)\n", \ 1378348SEric.Yu@Sun.COM (void *)(ssa), (ssa)->ssa_refcnt, \ 1388348SEric.Yu@Sun.COM __FILE__, __LINE__)); \ 1398348SEric.Yu@Sun.COM } 1408348SEric.Yu@Sun.COM 1418348SEric.Yu@Sun.COM 1428348SEric.Yu@Sun.COM #define SSA_REFRELE(ss, ssa) \ 1438348SEric.Yu@Sun.COM { \ 1448348SEric.Yu@Sun.COM dprint(3, ("ssa_refrele on %p %d (%s, %d)\n", \ 1458348SEric.Yu@Sun.COM (void *)(ssa), \ 1468348SEric.Yu@Sun.COM (ssa)->ssa_refcnt-1, __FILE__, __LINE__)); \ 1478348SEric.Yu@Sun.COM ASSERT((ssa)->ssa_refcnt > 0); \ 1488348SEric.Yu@Sun.COM if (--(ssa)->ssa_refcnt == 0) { \ 1498348SEric.Yu@Sun.COM sosctp_assoc_free(ss, ssa); \ 1508348SEric.Yu@Sun.COM } \ 1518348SEric.Yu@Sun.COM } 1528348SEric.Yu@Sun.COM 1538348SEric.Yu@Sun.COM #ifdef __cplusplus 1548348SEric.Yu@Sun.COM } 1558348SEric.Yu@Sun.COM #endif 1568348SEric.Yu@Sun.COM 1578348SEric.Yu@Sun.COM #endif /* _SOCKSCTP_H_ */ 158