tcp.h revision a66ba7b33369c7bd064dcae0e279fd236eee6dbf
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 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 <inet/tcp_sack.h>
#include <sys/multidata.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,
/* 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 : 15;
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 */
/*
* 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.
*/
} tcp_t;
extern void tcp_ddi_init(void);
extern void tcp_ddi_destroy(void);
extern void *tcp_get_conn(void *arg);
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;
extern mib2_tcp_t tcp_mib;
#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
/* Named Dispatch Parameter Management Structure */
typedef struct tcpparam_s {
char *tcp_param_name;
} tcpparam_t;
extern tcpparam_t tcp_param_arr[];
extern boolean_t do_tcp_fusion;
#endif
#ifdef __cplusplus
}
#endif
#endif /* _INET_TCP_H */