tcp.h revision f4b3ec61df05330d25f55a36b975b4d7519fdeb1
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1990 Mentat Inc. */
#ifndef _INET_TCP_H
#define _INET_TCP_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/inttypes.h>
#include <sys/multidata.h>
#include <inet/tcp_stack.h>
#include <inet/tcp_sack.h>
/*
* Private (and possibly temporary) ioctl used by configuration code
* to lock in the "default" stream for detached closes.
*/
/* TCP states */
#define TCPS_CLOSED -6
/* states < TCPS_ESTABLISHED are those where connections not established */
#define TCPS_ESTABLISHED 0 /* established */
/* states > TCPS_CLOSE_WAIT are those where user has closed */
/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
/*
* Internal flags used in conjunction with the packet header flags.
* Used in tcp_rput_data to keep track of what needs to be done.
*/
/*
* TCP sequence numbers are 32 bit integers operated
* on with modular arithmetic. These macros can be
* used to compare such integers.
*/
/* TCP Protocol header */
typedef struct tcphdr_s {
} tcph_t;
#define TCP_MAX_HDR_LENGTH 60
#define TCP_MIN_HEADER_LENGTH 20
#define TCP_MAXWIN 65535
#define TCP_PORT_LEN sizeof (in_port_t)
#define TCP_MAX_WINSHIFT 14
#define TCPIP_HDR_LENGTH(mp, n) \
/* TCP Protocol header (used if the header is known to be 32-bit aligned) */
typedef struct tcphdra_s {
} tcpha_t;
struct conn_s;
/*
* Control structure for each open TCP stream,
* defined only within the kernel or for a kmem user.
* NOTE: tcp_reinit_values MUST have a line for each field in this structure!
*/
typedef struct tcp_s {
/* Pointer to previous bind hash next. */
struct tcp_s *tcp_time_wait_next;
/* Pointer to next T/W block */
struct tcp_s *tcp_time_wait_prev;
/* Pointer to previous T/W next */
/* data segment */
/* lbolt on last packet, used for PAWS */
/* Fields arranged in approximate access order along main paths */
/*
* Following socket options are set by sockfs outside the squeue
* and we want to separate these bit fields from the other bit fields
* set by TCP to avoid grabbing locks. sockfs ensures that only one
* thread in sockfs can set a socket option at a time on a conn_t.
* However TCP may read these options concurrently. The linger option
* needs atomicity since tcp_lingertime also needs to be in sync.
* However TCP uses it only during close, and by then no socket option
* can come down. So we don't need any locks, instead just separating
* the sockfs settable bit fields from the other bit fields is
* sufficient.
*/
tcp_junk_to_bit_31 : 24;
/* Following manipulated by TCP under squeue protection */
/* defer tcp endpoint cleanup etc. */
#define tcp_dontdrop tcp_syn_defense
tcp_set_timer : 1,
tcp_anon_priv_bind : 1,
tcp_pad_to_bit31 : 1;
/* Following manipulated by TCP under squeue protection */
tcp_snd_ts_ok : 1,
tcp_snd_ws_ok : 1,
tcp_reserved_port : 1,
tcp_hdr_grown : 1,
tcp_in_free_list : 1,
tcp_pad_to_bit_31 : 16;
int tcp_lingertime; /* Close linger time (in seconds) */
int tcp_conn_req_cnt_q0; /* # of conn reqs in SYN_RCVD */
int tcp_conn_req_cnt_q; /* # of conn reqs in ESTABLISHED */
int tcp_conn_req_max; /* # of ESTABLISHED conn reqs allowed */
#define tcp_ip_addr_cache tcp_reass_tail
/* Cache ip addresses that */
/* complete the 3-way handshake */
/* all eagers form a circular list */
union {
} tcp_conn;
/* TCP Keepalive Timer members */
int tcp_iphc_len; /* actual allocated buffer size */
int tcp_ip_hdr_len; /* Byte len of our current IPvx hdr */
/* routed packets. Host byte order */
int tcp_ipsec_overhead;
/*
* Address family that app wishes returned addrsses to be in.
* Currently taken from address family used in T_BIND_REQ, but
* should really come from family used in original socket() call.
* Value can be AF_INET or AF_INET6.
*/
/*
* used for a quick test to determine if any ancillary bits are
* set
*/
union {
struct {
/* Dup of tcp_ipha.iph_type_of_service */
} v4_hdr_info;
struct {
} v6_hdr_info;
} tcp_hdr_info;
void *tcp_tracebuf;
struct tcp_s **tcp_ptpbhn;
/*
* used for Multidata Transmit
*/
int tcp_mdt_max_pld; /* maximum payload buffers per Multidata */
/*
* The following fusion-related fields are protected by squeue.
*/
/*
* The following fusion-related fields and bit fields are to be
* manipulated with squeue protection or with tcp_non_sq_lock held.
* tcp_non_sq_lock is used to protect fields that may be modified
* accessed outside the squeue.
*/
tcp_fuse_to_bit_31 : 26;
/*
* This variable is accessed without any lock protection
* and therefore must not be declared as a bit field along
* with the rest which require such condition.
*/
/* protected by the tcp_non_sq_lock lock */
/*
* Kernel SSL session information
*/
/*
* tcp_closemp_used is protected by listener's tcp_eager_lock
* when used for eagers. When used for a tcp in TIME_WAIT state
* or in tcp_close(), it is not protected by any lock as we
* do not expect any other thread to use it concurrently.
* Since we do allow re-use of tcp_closemp at certain places,
* tcp_closemp_used is declared as uint32_t instead of boolean_t
* to record any attempt to re-use tcp_closemp while it is still
* in use. This would facilitate debugging in non-debug kernels.
*/
/*
* previous and next eagers in the list of droppable eagers. See
* the comments before MAKE_DROPPABLE(). These pointers are
* protected by listener's tcp_eager_lock.
*/
struct tcp_s *tcp_eager_prev_drop_q0;
struct tcp_s *tcp_eager_next_drop_q0;
/*
* Have we flow controlled xmitter?
* This variable can be modified outside the squeue and hence must
* not be declared as a bit field along with the rest that are
* modified only within the squeue.
* protected by the tcp_non_sq_lock lock.
*/
#ifdef DEBUG
#endif
} tcp_t;
#ifdef DEBUG
depth))
#else
#endif
/*
* Track a reference count on the tcps in order to know when
* the tcps_g_q can be removed. As long as there is any
* tcp_t, other that the tcps_g_q itself, in the tcp_stack_t we
* need to keep tcps_g_q around so that a closing connection can
* switch to using tcps_g_q as part of it closing.
*/
#define TCPS_REFHOLD(tcps) { \
}
/*
* Decrement the reference count on the tcp_stack_t.
* In architectures e.g sun4u, where atomic_add_32_nv is just
* a cas, we need to maintain the right memory barrier semantics
* as that of mutex_exit i.e all the loads and stores should complete
* before the cas is executed. membar_exit() does that here.
*/
#define TCPS_REFRELE(tcps) { \
membar_exit(); \
/* Only tcps_g_q left */ \
tcp_g_q_inactive(tcps); \
} \
}
extern void tcp_ddi_g_init(void);
extern void tcp_ddi_g_destroy(void);
extern void tcp_g_q_inactive(tcp_stack_t *);
extern void tcp_time_wait_collector(void *arg);
/*
* The TCP Fanout structure.
* The hash tables and their linkage (tcp_*_hash_next, tcp_ptp*hn) are
* protected by the per-bucket tf_lock. Each tcp_t
* inserted in the list points back at this lock using tcp_*_lockp.
*
* The listener and acceptor hash queues are lists of tcp_t.
*/
/* listener hash and acceptor hash queue head */
typedef struct tf_s {
} tf_t;
#endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */
/* Contract private interface between TCP and Clustering. */
typedef struct cl_tcp_info_s {
#ifdef _KERNEL
/* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */
#endif /* _KERNEL */
/*
* Hook functions to enable cluster networking
* On non-clustered systems these vectors must always be NULL.
*/
/*
* Contracted Consolidation Private ioctl for aborting TCP connections.
* In order to keep the offsets and size of the structure the same between
* a 32-bit application and a 64-bit amd64 kernel, we use a #pragma
* pack(4).
*/
#pragma pack(4)
#endif
typedef struct tcp_ioc_abort_conn_s {
#pragma pack()
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _INET_TCP_H */