1*11754SKacheong.Poon@Sun.COM /* 2*11754SKacheong.Poon@Sun.COM * CDDL HEADER START 3*11754SKacheong.Poon@Sun.COM * 4*11754SKacheong.Poon@Sun.COM * The contents of this file are subject to the terms of the 5*11754SKacheong.Poon@Sun.COM * Common Development and Distribution License (the "License"). 6*11754SKacheong.Poon@Sun.COM * You may not use this file except in compliance with the License. 7*11754SKacheong.Poon@Sun.COM * 8*11754SKacheong.Poon@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*11754SKacheong.Poon@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*11754SKacheong.Poon@Sun.COM * See the License for the specific language governing permissions 11*11754SKacheong.Poon@Sun.COM * and limitations under the License. 12*11754SKacheong.Poon@Sun.COM * 13*11754SKacheong.Poon@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*11754SKacheong.Poon@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*11754SKacheong.Poon@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*11754SKacheong.Poon@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*11754SKacheong.Poon@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*11754SKacheong.Poon@Sun.COM * 19*11754SKacheong.Poon@Sun.COM * CDDL HEADER END 20*11754SKacheong.Poon@Sun.COM */ 21*11754SKacheong.Poon@Sun.COM /* 22*11754SKacheong.Poon@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23*11754SKacheong.Poon@Sun.COM * Use is subject to license terms. 24*11754SKacheong.Poon@Sun.COM */ 25*11754SKacheong.Poon@Sun.COM 26*11754SKacheong.Poon@Sun.COM #ifndef _INET_TCP_CLUSTER_H 27*11754SKacheong.Poon@Sun.COM #define _INET_TCP_CLUSTER_H 28*11754SKacheong.Poon@Sun.COM 29*11754SKacheong.Poon@Sun.COM #ifdef __cplusplus 30*11754SKacheong.Poon@Sun.COM extern "C" { 31*11754SKacheong.Poon@Sun.COM #endif 32*11754SKacheong.Poon@Sun.COM 33*11754SKacheong.Poon@Sun.COM #ifdef _KERNEL 34*11754SKacheong.Poon@Sun.COM 35*11754SKacheong.Poon@Sun.COM /* 36*11754SKacheong.Poon@Sun.COM * Cluster hooks defined in tcp_cluster.c. 37*11754SKacheong.Poon@Sun.COM */ 38*11754SKacheong.Poon@Sun.COM extern void (*cl_inet_listen)(netstackid_t, uint8_t, sa_family_t, uint8_t *, 39*11754SKacheong.Poon@Sun.COM in_port_t, void *); 40*11754SKacheong.Poon@Sun.COM extern void (*cl_inet_unlisten)(netstackid_t, uint8_t, sa_family_t, uint8_t *, 41*11754SKacheong.Poon@Sun.COM in_port_t, void *); 42*11754SKacheong.Poon@Sun.COM extern int (*cl_inet_connect2)(netstackid_t, uint8_t, boolean_t, sa_family_t, 43*11754SKacheong.Poon@Sun.COM uint8_t *, in_port_t, uint8_t *, in_port_t, void *); 44*11754SKacheong.Poon@Sun.COM extern void (*cl_inet_disconnect)(netstackid_t, uint8_t, sa_family_t, 45*11754SKacheong.Poon@Sun.COM uint8_t *, in_port_t, uint8_t *, in_port_t, void *); 46*11754SKacheong.Poon@Sun.COM 47*11754SKacheong.Poon@Sun.COM 48*11754SKacheong.Poon@Sun.COM /* 49*11754SKacheong.Poon@Sun.COM * Cluster networking hook for traversing current connection list. 50*11754SKacheong.Poon@Sun.COM * This routine is used to extract the current list of live connections 51*11754SKacheong.Poon@Sun.COM * which must continue to to be dispatched to this node. 52*11754SKacheong.Poon@Sun.COM */ 53*11754SKacheong.Poon@Sun.COM extern int cl_tcp_walk_list(netstackid_t, 54*11754SKacheong.Poon@Sun.COM int (*callback)(cl_tcp_info_t *, void *), void *); 55*11754SKacheong.Poon@Sun.COM 56*11754SKacheong.Poon@Sun.COM /* 57*11754SKacheong.Poon@Sun.COM * int CL_INET_CONNECT(conn_t *cp, tcp_t *tcp, boolean_t is_outgoing, int err) 58*11754SKacheong.Poon@Sun.COM */ 59*11754SKacheong.Poon@Sun.COM #define CL_INET_CONNECT(connp, is_outgoing, err) { \ 60*11754SKacheong.Poon@Sun.COM (err) = 0; \ 61*11754SKacheong.Poon@Sun.COM if (cl_inet_connect2 != NULL) { \ 62*11754SKacheong.Poon@Sun.COM /* \ 63*11754SKacheong.Poon@Sun.COM * Running in cluster mode - register active connection \ 64*11754SKacheong.Poon@Sun.COM * information \ 65*11754SKacheong.Poon@Sun.COM */ \ 66*11754SKacheong.Poon@Sun.COM if ((connp)->conn_ipversion == IPV4_VERSION) { \ 67*11754SKacheong.Poon@Sun.COM if ((connp)->conn_laddr_v4 != 0) { \ 68*11754SKacheong.Poon@Sun.COM (err) = (*cl_inet_connect2)( \ 69*11754SKacheong.Poon@Sun.COM (connp)->conn_netstack->netstack_stackid,\ 70*11754SKacheong.Poon@Sun.COM IPPROTO_TCP, is_outgoing, AF_INET, \ 71*11754SKacheong.Poon@Sun.COM (uint8_t *)(&((connp)->conn_laddr_v4)),\ 72*11754SKacheong.Poon@Sun.COM (in_port_t)(connp)->conn_lport, \ 73*11754SKacheong.Poon@Sun.COM (uint8_t *)(&((connp)->conn_faddr_v4)),\ 74*11754SKacheong.Poon@Sun.COM (in_port_t)(connp)->conn_fport, NULL); \ 75*11754SKacheong.Poon@Sun.COM } \ 76*11754SKacheong.Poon@Sun.COM } else { \ 77*11754SKacheong.Poon@Sun.COM if (!IN6_IS_ADDR_UNSPECIFIED( \ 78*11754SKacheong.Poon@Sun.COM &(connp)->conn_laddr_v6)) { \ 79*11754SKacheong.Poon@Sun.COM (err) = (*cl_inet_connect2)( \ 80*11754SKacheong.Poon@Sun.COM (connp)->conn_netstack->netstack_stackid,\ 81*11754SKacheong.Poon@Sun.COM IPPROTO_TCP, is_outgoing, AF_INET6, \ 82*11754SKacheong.Poon@Sun.COM (uint8_t *)(&((connp)->conn_laddr_v6)),\ 83*11754SKacheong.Poon@Sun.COM (in_port_t)(connp)->conn_lport, \ 84*11754SKacheong.Poon@Sun.COM (uint8_t *)(&((connp)->conn_faddr_v6)), \ 85*11754SKacheong.Poon@Sun.COM (in_port_t)(connp)->conn_fport, NULL); \ 86*11754SKacheong.Poon@Sun.COM } \ 87*11754SKacheong.Poon@Sun.COM } \ 88*11754SKacheong.Poon@Sun.COM } \ 89*11754SKacheong.Poon@Sun.COM } 90*11754SKacheong.Poon@Sun.COM 91*11754SKacheong.Poon@Sun.COM #define CL_INET_DISCONNECT(connp) { \ 92*11754SKacheong.Poon@Sun.COM if (cl_inet_disconnect != NULL) { \ 93*11754SKacheong.Poon@Sun.COM /* \ 94*11754SKacheong.Poon@Sun.COM * Running in cluster mode - deregister active \ 95*11754SKacheong.Poon@Sun.COM * connection information \ 96*11754SKacheong.Poon@Sun.COM */ \ 97*11754SKacheong.Poon@Sun.COM if ((connp)->conn_ipversion == IPV4_VERSION) { \ 98*11754SKacheong.Poon@Sun.COM if ((connp)->conn_laddr_v4 != 0) { \ 99*11754SKacheong.Poon@Sun.COM (*cl_inet_disconnect)( \ 100*11754SKacheong.Poon@Sun.COM (connp)->conn_netstack->netstack_stackid,\ 101*11754SKacheong.Poon@Sun.COM IPPROTO_TCP, AF_INET, \ 102*11754SKacheong.Poon@Sun.COM (uint8_t *)(&((connp)->conn_laddr_v4)),\ 103*11754SKacheong.Poon@Sun.COM (in_port_t)(connp)->conn_lport, \ 104*11754SKacheong.Poon@Sun.COM (uint8_t *)(&((connp)->conn_faddr_v4)),\ 105*11754SKacheong.Poon@Sun.COM (in_port_t)(connp)->conn_fport, NULL); \ 106*11754SKacheong.Poon@Sun.COM } \ 107*11754SKacheong.Poon@Sun.COM } else { \ 108*11754SKacheong.Poon@Sun.COM if (!IN6_IS_ADDR_UNSPECIFIED( \ 109*11754SKacheong.Poon@Sun.COM &(connp)->conn_laddr_v6)) { \ 110*11754SKacheong.Poon@Sun.COM (*cl_inet_disconnect)( \ 111*11754SKacheong.Poon@Sun.COM (connp)->conn_netstack->netstack_stackid,\ 112*11754SKacheong.Poon@Sun.COM IPPROTO_TCP, AF_INET6, \ 113*11754SKacheong.Poon@Sun.COM (uint8_t *)(&((connp)->conn_laddr_v6)),\ 114*11754SKacheong.Poon@Sun.COM (in_port_t)(connp)->conn_lport, \ 115*11754SKacheong.Poon@Sun.COM (uint8_t *)(&((connp)->conn_faddr_v6)), \ 116*11754SKacheong.Poon@Sun.COM (in_port_t)(connp)->conn_fport, NULL); \ 117*11754SKacheong.Poon@Sun.COM } \ 118*11754SKacheong.Poon@Sun.COM } \ 119*11754SKacheong.Poon@Sun.COM } \ 120*11754SKacheong.Poon@Sun.COM } 121*11754SKacheong.Poon@Sun.COM 122*11754SKacheong.Poon@Sun.COM #endif /* _KERNEL */ 123*11754SKacheong.Poon@Sun.COM 124*11754SKacheong.Poon@Sun.COM #ifdef __cplusplus 125*11754SKacheong.Poon@Sun.COM } 126*11754SKacheong.Poon@Sun.COM #endif 127*11754SKacheong.Poon@Sun.COM 128*11754SKacheong.Poon@Sun.COM #endif /* _INET_TCP_CLUSTER_H */ 129