1a6d42e7dSPeter Dunlap /* 2a6d42e7dSPeter Dunlap * CDDL HEADER START 3a6d42e7dSPeter Dunlap * 4a6d42e7dSPeter Dunlap * The contents of this file are subject to the terms of the 5a6d42e7dSPeter Dunlap * Common Development and Distribution License (the "License"). 6a6d42e7dSPeter Dunlap * You may not use this file except in compliance with the License. 7a6d42e7dSPeter Dunlap * 8a6d42e7dSPeter Dunlap * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9a6d42e7dSPeter Dunlap * or http://www.opensolaris.org/os/licensing. 10a6d42e7dSPeter Dunlap * See the License for the specific language governing permissions 11a6d42e7dSPeter Dunlap * and limitations under the License. 12a6d42e7dSPeter Dunlap * 13a6d42e7dSPeter Dunlap * When distributing Covered Code, include this CDDL HEADER in each 14a6d42e7dSPeter Dunlap * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15a6d42e7dSPeter Dunlap * If applicable, add the following below this CDDL HEADER, with the 16a6d42e7dSPeter Dunlap * fields enclosed by brackets "[]" replaced with your own identifying 17a6d42e7dSPeter Dunlap * information: Portions Copyright [yyyy] [name of copyright owner] 18a6d42e7dSPeter Dunlap * 19a6d42e7dSPeter Dunlap * CDDL HEADER END 20a6d42e7dSPeter Dunlap */ 21a6d42e7dSPeter Dunlap /* 22cf8c0ebaSPeter Dunlap * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23a6d42e7dSPeter Dunlap * Use is subject to license terms. 24a6d42e7dSPeter Dunlap */ 25a6d42e7dSPeter Dunlap 26a6d42e7dSPeter Dunlap #ifndef _IDM_SO_H 27a6d42e7dSPeter Dunlap #define _IDM_SO_H 28a6d42e7dSPeter Dunlap 29a6d42e7dSPeter Dunlap #ifdef __cplusplus 30a6d42e7dSPeter Dunlap extern "C" { 31a6d42e7dSPeter Dunlap #endif 32a6d42e7dSPeter Dunlap 33a6d42e7dSPeter Dunlap #include <sys/idm/idm_transport.h> 340f1702c5SYu Xiangning #include <sys/ksocket.h> 35cf8c0ebaSPeter Dunlap 36a6d42e7dSPeter Dunlap /* 37a6d42e7dSPeter Dunlap * Define TCP window size (send and receive buffer sizes) 38a6d42e7dSPeter Dunlap */ 39a6d42e7dSPeter Dunlap 40a6d42e7dSPeter Dunlap #define IDM_RCVBUF_SIZE (256 * 1024) 41a6d42e7dSPeter Dunlap #define IDM_SNDBUF_SIZE (256 * 1024) 42a6d42e7dSPeter Dunlap 43cf8c0ebaSPeter Dunlap /* 44cf8c0ebaSPeter Dunlap * Lower and upper bounds to use the 128k buffer cache. Below the lower bound 45cf8c0ebaSPeter Dunlap * allocations will use the built-in Solaris buffer caches. We don't expect 46cf8c0ebaSPeter Dunlap * to see allocations above the upper bound because SBD currently allocates 47cf8c0ebaSPeter Dunlap * 128k buffers. 48cf8c0ebaSPeter Dunlap */ 49cf8c0ebaSPeter Dunlap 50cf8c0ebaSPeter Dunlap #define IDM_SO_BUF_CACHE_LB (32 * 1024) 51cf8c0ebaSPeter Dunlap #define IDM_SO_BUF_CACHE_UB (128 * 1024) 52cf8c0ebaSPeter Dunlap 53a6d42e7dSPeter Dunlap /* sockets-specific portion of idm_svc_t */ 54a6d42e7dSPeter Dunlap typedef struct idm_so_svc_s { 550f1702c5SYu Xiangning ksocket_t is_so; 56a6d42e7dSPeter Dunlap kthread_t *is_thread; 57a6d42e7dSPeter Dunlap kt_did_t is_thread_did; 58a6d42e7dSPeter Dunlap boolean_t is_thread_running; 59a6d42e7dSPeter Dunlap } idm_so_svc_t; 60a6d42e7dSPeter Dunlap 61a6d42e7dSPeter Dunlap /* sockets-specific portion of idm_conn_t */ 62a6d42e7dSPeter Dunlap typedef struct idm_so_conn_s { 630f1702c5SYu Xiangning ksocket_t ic_so; 64a6d42e7dSPeter Dunlap 65a6d42e7dSPeter Dunlap kthread_t *ic_tx_thread; 66a6d42e7dSPeter Dunlap kt_did_t ic_tx_thread_did; 67a6d42e7dSPeter Dunlap boolean_t ic_tx_thread_running; 68a6d42e7dSPeter Dunlap kmutex_t ic_tx_mutex; 69a6d42e7dSPeter Dunlap kcondvar_t ic_tx_cv; 70a6d42e7dSPeter Dunlap list_t ic_tx_list; /* List of PDUs for transmit */ 71a6d42e7dSPeter Dunlap 72a6d42e7dSPeter Dunlap kthread_t *ic_rx_thread; 73a6d42e7dSPeter Dunlap kt_did_t ic_rx_thread_did; 74a6d42e7dSPeter Dunlap boolean_t ic_rx_thread_running; 75a6d42e7dSPeter Dunlap } idm_so_conn_t; 76a6d42e7dSPeter Dunlap 77a6d42e7dSPeter Dunlap void idm_so_init(idm_transport_t *it); 78a6d42e7dSPeter Dunlap void idm_so_fini(); 79a6d42e7dSPeter Dunlap 80*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States /* used by idm_so_timed_socket_connect */ 81*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States typedef struct idm_so_timed_socket_s { 82*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States kcondvar_t it_cv; 83*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States boolean_t it_callback_called; 84*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States int it_socket_error_code; 85*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States } idm_so_timed_socket_t; 86*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States 87a6d42e7dSPeter Dunlap /* Socket functions */ 88a6d42e7dSPeter Dunlap 890f1702c5SYu Xiangning ksocket_t 90a6d42e7dSPeter Dunlap idm_socreate(int domain, int type, int protocol); 91a6d42e7dSPeter Dunlap 920f1702c5SYu Xiangning void idm_soshutdown(ksocket_t so); 93a6d42e7dSPeter Dunlap 940f1702c5SYu Xiangning void idm_sodestroy(ksocket_t so); 95a6d42e7dSPeter Dunlap 96e42a0851Speter dunlap int idm_ss_compare(const struct sockaddr_storage *cmp_ss1, 97e42a0851Speter dunlap const struct sockaddr_storage *cmp_ss2, 98*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States boolean_t v4_mapped_as_v4, 99*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States boolean_t compare_ports); 100e42a0851Speter dunlap 101a6d42e7dSPeter Dunlap int idm_get_ipaddr(idm_addr_list_t **); 102a6d42e7dSPeter Dunlap 103*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States void idm_addr_to_sa(idm_addr_t *dportal, 104*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States struct sockaddr_storage *sa); 105*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States 106*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States #define IDM_SA_NTOP_BUFSIZ (INET6_ADDRSTRLEN + sizeof ("[].65535") + 1) 107*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States 108*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States const char *idm_sa_ntop(const struct sockaddr_storage *sa, 109*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States char *buf, size_t size); 110*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States 1110f1702c5SYu Xiangning int idm_sorecv(ksocket_t so, void *msg, size_t len); 112a6d42e7dSPeter Dunlap 1130f1702c5SYu Xiangning int idm_sosendto(ksocket_t so, void *buff, size_t len, 114a6d42e7dSPeter Dunlap struct sockaddr *name, socklen_t namelen); 115a6d42e7dSPeter Dunlap 1160f1702c5SYu Xiangning int idm_iov_sosend(ksocket_t so, iovec_t *iop, int iovlen, 117a6d42e7dSPeter Dunlap size_t total_len); 118a6d42e7dSPeter Dunlap 1190f1702c5SYu Xiangning int idm_iov_sorecv(ksocket_t so, iovec_t *iop, int iovlen, 120a6d42e7dSPeter Dunlap size_t total_len); 121a6d42e7dSPeter Dunlap 122a6d42e7dSPeter Dunlap void idm_sotx_thread(void *arg); 123a6d42e7dSPeter Dunlap void idm_sorx_thread(void *arg); 124a6d42e7dSPeter Dunlap 125a6d42e7dSPeter Dunlap 126a6d42e7dSPeter Dunlap int idm_sotx_pdu_constructor(void *hdl, void *arg, int flags); 127a6d42e7dSPeter Dunlap 128a6d42e7dSPeter Dunlap void idm_sotx_pdu_destructor(void *pdu_void, void *arg); 129a6d42e7dSPeter Dunlap 130a6d42e7dSPeter Dunlap int idm_sorx_pdu_constructor(void *hdl, void *arg, int flags); 131a6d42e7dSPeter Dunlap 132a6d42e7dSPeter Dunlap void idm_sorx_pdu_destructor(void *pdu_void, void *arg); 133a6d42e7dSPeter Dunlap 134a6d42e7dSPeter Dunlap void idm_so_svc_port_watcher(void *arg); 135a6d42e7dSPeter Dunlap 136*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States int idm_so_timed_socket_connect(ksocket_t ks, 137*bdbe8dc6SPeter Cudhea - Sun Microsystems - Burlington, MA United States struct sockaddr_storage *sa, int sa_sz, int login_max_usec); 138a6d42e7dSPeter Dunlap 139a6d42e7dSPeter Dunlap #ifdef __cplusplus 140a6d42e7dSPeter Dunlap } 141a6d42e7dSPeter Dunlap #endif 142a6d42e7dSPeter Dunlap 143a6d42e7dSPeter Dunlap #endif /* _IDM_SO_H */ 144