--- /dev/null	2012-08-18 10:37:11.000000000 +0000
+++ new/usr/src/uts/common/inet/dccp_impl.h	2012-08-18 10:37:11.937118819 +0000
@@ -0,0 +1,379 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012 David Hoeppner. All rights reserved.
+ */
+
+#ifndef	_INET_DCCP_IMPL_H
+#define	_INET_DCCP_IMPL_H
+
+#include <sys/int_types.h>
+#include <sys/netstack.h>
+#include <sys/socket.h>
+#include <sys/socket_proto.h>
+#include <sys/clock_impl.h>
+
+#include <netinet/in.h>
+#include <netinet/ip6.h>
+#include <netinet/dccp.h>
+
+#include <inet/common.h>
+#include <inet/dccp.h>
+#include <inet/ip.h>
+#include <inet/ip6.h>
+#include <inet/optcom.h>
+#include <inet/tunables.h>
+
+#include <inet/dccp_stack.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#ifdef	_KERNEL
+
+#define	DCCP_MOD_ID		5999 /* XXX */
+
+extern struct qinit	dccp_sock_winit;
+extern struct qinit	dccp_winit;
+
+extern sock_downcalls_t	sock_dccp_downcalls;
+
+#define	DCCP_XMIT_LOWATER	(4 * 1024)
+#define	DCCP_XMIT_HIWATER	49152
+#define	DCCP_RECV_LOWATER	(2 * 1024)
+#define	DCCP_RECV_HIWATER	128000
+
+#define	TIDUSZ	4096	/* transport interface data unit size */
+
+/*
+ * Format arguments passed to dccp_display.
+ */
+#define	DISP_PORT_ONLY		1
+#define	DISP_ADDR_AND_PORT	2
+
+/*
+ * Bind hash array size and hash function.
+ */
+#define	DCCP_BIND_FANOUT_SIZE		128
+#define	DCCP_BIND_HASH(lport, size)	((ntohs((uint16_t)lport)) & (size - 1))
+
+/*
+ * Was this tcp created via socket() interface?
+ */
+#define	DCCP_IS_SOCKET(dccp)	((dccp)->dccp_issocket)
+
+/*
+ * Is this dccp not attached to any upper client?
+ */
+#define	DCCP_IS_DETACHED(dccp)	((dccp)->dccp_detached)
+
+/* Packet types (RFC 4340, Section 5.1.) */
+#define	DCCP_PKT_REQUEST	0
+#define	DCCP_PKT_RESPONSE	1
+#define	DCCP_PKT_DATA		2
+#define	DCCP_PKT_ACK		3
+#define	DCCP_PKT_DATAACK	4
+#define	DCCP_PKT_CLOSEREQ	5
+#define	DCCP_PKT_CLOSE		6
+#define	DCCP_PKT_RESET		7
+#define	DCCP_PKT_SYNC		8
+#define	DCCP_PKT_SYNCACK	9
+
+#define	DCCP_PACKET_REQUEST	0
+#define	DCCP_PACKET_RESPONSE	1
+#define	DCCP_PACKET_DATA	2
+#define	DCCP_PACKET_ACK		3
+#define	DCCP_PACKET_DATAACK	4
+#define	DCCP_PACKET_CLOSEREQ	5
+#define	DCCP_PACKET_CLOSE	6
+#define	DCCP_PACKET_RESET	7
+#define	DCCP_PACKET_SYNC	8
+#define	DCCP_PACKET_SYNCACK	9
+
+/*
+ * DCCP options and features.
+ */
+
+/*
+ * Options types (RFC 4340, Section 5.8.)
+ */
+#define	DCCP_OPTION_PADDING		0
+#define	DCCP_OPTION_MANDATORY		1
+#define	DCCP_OPTION_SLOW_RECEIVER	2
+#define	DCCP_OPTION_CHANGE_L		32
+#define	DCCP_OPTION_CONFIRM_L		33
+#define	DCCP_OPTION_CHANGE_R		34
+#define	DCCP_OPTION_CONFIRM_R		35
+#define	DCCP_OPTION_INIT_COOKIE		36
+#define	DCCP_OPTION_NDP_COUNT		37
+#define	DCCP_OPTION_ACK_VECTOR_1	38
+#define	DCCP_OPTION_ACK_VECTOR_2	39
+#define	DCCP_OPTION_DATA_DROPPED	40
+#define	DCCP_OPTION_TIMESTAMP		41
+#define	DCCP_OPTION_TIMESTAMP_ECHO	42
+#define	DCCP_OPTION_ELAPSED_TIME	43
+#define	DCCP_OPTION_DATA_CHECKSUM	44
+
+/*
+ * Feature types (RFC 4340, Section 6.4.)
+ */
+#define	DCCP_FEATURE_CCID			1
+#define	DCCP_FEATURE_ALLOW_SHORT_SEQNOS		2
+#define	DCCP_FEATURE_SEQUENCE_WINDOW		3
+#define	DCCP_FEATURE_ECN_INCAPABLE		4
+#define	DCCP_FEATURE_ACK_RATIO			5
+#define	DCCP_FEATURE_SEND_ACK_VECTOR		6
+#define	DCCP_FEATURE_SEND_NDP_COUNT		7
+#define	DCCP_FEATURE_MIN_CHECKSUM_COVERAGE	8
+#define	DCCP_FEATURE_CHECK_DATA_CHECKSUM	9
+
+/*
+ * Feature negotation states (RFC 4340, Section 6.6.2.)
+ */
+#define	DCCP_FEATURE_STATE_CHANGING		0
+#define	DCCP_FEATURE_STATE_UNSTABLE		1
+#define	DCCP_FEATURE_STATE_STABLE		2
+
+/*
+ * Reset types (RFC 4230, Section 5.6.)
+ */
+#define	DCCP_RESET_UNSPECIFIED			0
+#define	DCCP_RESET_CLOSED			1
+#define	DCCP_RESET_ABORTED			2
+#define	DCCP_RESET_NO_CONNECTION		3
+#define	DCCP_RESET_PACKET_ERROR			4
+#define	DCCP_RESET_OPTION_ERROR			5
+#define	DCCP_RESET_MANDATORY_ERROR		6
+#define	DCCP_RESET_CONNECTION_REFUSED		7
+#define	DCCP_RESET_BAD_SERVICE_CODE		8
+#define	DCCP_RESET_TOO_BUSY			9
+#define	DCCP_RESET_BAD_INIT_COOKIE		10
+#define	DCCP_RESET_AGGRESSION_PENALTY		11
+#define	DCCP_RESET_RESERVED			12
+
+typedef struct dccp_feature_s {
+	list_node_t	df_next;
+	uint8_t		df_option;
+	uint8_t		df_type;
+	uint8_t		df_state;
+	uint64_t	df_value;
+	boolean_t	df_mandatory;
+} dccp_feature_t;
+
+/* Options in DCCP header */
+typedef struct dccp_opt_s {
+	int		type;
+	boolean_t	mandatory;
+} dccp_opt_t;
+
+/*
+ * Tuneables.
+ */
+#define	dccps_smallest_nonpriv_port	dccps_propinfo_tbl[0].prop_cur_uval
+#define	dccps_smallest_anon_port	dccps_propinfo_tbl[1].prop_cur_uval
+#define	dccps_largest_anon_port		dccps_propinfo_tbl[2].prop_cur_uval
+
+#define	dccps_dbg			dccps_propinfo_tbl[4].prop_cur_uval
+#define	dccps_rst_sent_rate_enabled	dccps_propinfo_tbl[5].prop_cur_uval
+#define	dccps_rst_sent_rate		dccps_propinfo_tbl[6].prop_cur_uval
+
+#define	dccps_ip_abort_cinterval	dccps_propinfo_tbl[7].prop_cur_uval
+#define	dccps_ip_abort_linterval	dccps_propinfo_tbl[8].prop_cur_uval
+#define	dccps_ip_abort_interval		dccps_propinfo_tbl[9].prop_cur_uval
+#define	dccps_ip_notify_cinterval	dccps_propinfo_tbl[10].prop_cur_uval
+#define	dccps_ip_notify_interval	dccps_propinfo_tbl[11].prop_cur_uval
+#define	dccps_keepalive_interval_high	dccps_propinfo_tbl[12].prop_max_uval
+#define	dccps_keepalive_interval	dccps_propinfo_tbl[12].prop_cur_uval
+#define	dccps_keepalive_interval_low	dccps_propinfo_tbl[12].prop_min_uval
+#define	dccps_keepalive_abort_interval_high \
+					dccps_propinfo_tbl[13].prop_max_uval
+#define	dccps_keepalive_abort_interval	dccps_propinfo_tbl[13].prop_cur_uval
+#define	dccps_keepalive_abort_interval_low \
+					dccps_propinfo_tbl[13].prop_min_uval
+
+/*
+ * Timers.
+ */
+typedef struct dccp_timer_s {
+	conn_t	*connp;
+	void	(*dccpt_proc)(void *);
+	callout_id_t	dccpt_tid;
+} dccp_timer_t;
+
+extern kmem_cache_t	*dccp_timercache;
+
+#define	DCCP_TIMER(dccp, f, tim)	\
+	dccp_timeout(dccp->dccp_connp, f, tim)
+
+#define	DCCP_TIMER_CANCEL(dccp, id)	\
+	dccp_timeout_cancel(dccp->dccp_connp, id)
+
+#define	DCCP_TIMER_RESTART(dccp, intvl) {			\
+	if ((dccp)->dccp_timer_tid != 0)			\
+		(void) DCCP_TIMER_CANCEL((dccp), (dccp)->dccp_timer_tid); \
+	(dccp)->dccp_timer_tid = DCCP_TIMER((dccp), dccp_timer, (intvl)); \
+}
+
+extern struct qinit	dccp_rinitv4, dccp_rinitv6;
+
+extern optdb_obj_t	dccp_opt_obj;
+extern uint_t		dccp_max_optsize;
+
+extern int		dccp_squeue_flag;
+
+/*
+ * Functions in dccp.c
+ */
+extern int	dccp_build_hdrs(dccp_t *);
+extern conn_t	*dccp_create_common(cred_t *, boolean_t, boolean_t, int *);
+extern void	dccp_close_common(conn_t *, int);
+extern int	dccp_do_bind(conn_t *, struct sockaddr *, socklen_t, cred_t *,
+		    boolean_t);
+extern int	dccp_do_unbind(conn_t *);
+extern int	dccp_do_listen(conn_t *, struct sockaddr *, socklen_t, int,
+		    cred_t *, boolean_t);
+extern int	dccp_do_connect(conn_t *, const struct sockaddr *, socklen_t,
+		    cred_t *, pid_t);
+extern void	dccp_init_values(dccp_t *, dccp_t *);
+extern void	dccp_free(dccp_t *);
+extern void	*dccp_get_conn(void *, dccp_stack_t *);
+extern void	dccp_get_proto_props(dccp_t *, struct sock_proto_props *);
+extern int	dccp_set_destination(dccp_t *);
+extern int	dccp_clean_death(dccp_t *, int);
+
+
+/*
+ * Functions in dccp_bind.c
+ */
+extern void	dccp_bind_hash_insert(dccp_df_t *, dccp_t *, int);
+extern void	dccp_bind_hash_remove(dccp_t *);
+extern int	dccp_bind_check(conn_t *, struct sockaddr *, socklen_t,
+		    cred_t *cr, boolean_t);
+extern in_port_t dccp_bindi(dccp_t *, in_port_t, const in6_addr_t *, int,
+		    boolean_t, boolean_t, boolean_t);
+extern in_port_t dccp_update_next_port(in_port_t, const dccp_t *, boolean_t);
+
+/*
+ * Functions in dccp_features.c
+ */
+extern int	dccp_parse_feature(dccp_t *, uint8_t, uint8_t, uchar_t *,
+		    boolean_t);
+
+/*
+ * Functions in dccp_stats.c
+ */
+extern mblk_t	*dccp_snmp_get(queue_t *, mblk_t *, boolean_t);
+extern void	*dccp_kstat_init(netstackid_t);
+extern void	dccp_kstat_fini(netstackid_t, kstat_t *);
+extern void	*dccp_kstat2_init(netstackid_t);
+extern void	dccp_kstat2_fini(netstackid_t, kstat_t *);
+
+/*
+ * Functions in dccp_socket.c
+ */
+extern sock_lower_handle_t	dccp_create(int, int, int, sock_downcalls_t **,
+				    uint_t *, int *, int, cred_t *);
+extern int	dccp_fallback(sock_lower_handle_t, queue_t *, boolean_t,
+		    so_proto_quiesced_cb_t, sock_quiesce_arg_t *);
+extern boolean_t	dccp_newconn_notify(dccp_t *, ip_recv_attr_t *);
+
+/*
+ * Functions in dccp_input.c
+ */
+extern void	dccp_icmp_input(void *, mblk_t *, void *, ip_recv_attr_t *);
+extern void	dccp_input_data(void *, mblk_t *, void *, ip_recv_attr_t *);
+extern void	dccp_rsrv(queue_t *);
+extern void	dccp_input_listener_unbound(void *, mblk_t *, void *,
+		    ip_recv_attr_t *);
+extern boolean_t dccp_verifyicmp(conn_t *, void *, icmph_t *, icmp6_t *,
+		    ip_recv_attr_t *);
+
+/*
+ * Functions in dccp_misc.c
+ */
+extern void	dccp_stack_cpu_add(dccp_stack_t *, processorid_t);
+extern char	*dccp_display(dccp_t *, char *, char);
+
+/*
+ * Functions in dccp_options.c
+ */
+extern int	dccp_parse_options(dccp_t *, dccpha_t *);
+extern int	dccp_process_options(dccp_t *, dccpha_t *);
+extern int	dccp_generate_options(dccp_t *, void **, size_t *);
+
+/*
+ * Functions in dccp_output.c
+ */
+extern void	dccp_wput(queue_t *, mblk_t *);
+extern void	dccp_wput_data(dccp_t *, mblk_t *, boolean_t);
+extern void	dccp_wput_sock(queue_t *, mblk_t *);
+extern void	dccp_wput_fallback(queue_t *, mblk_t *);
+extern void	dccp_output(void *, mblk_t *, void *, ip_recv_attr_t *);
+extern void	dccp_output_urgent(void *, mblk_t *, void *, ip_recv_attr_t *);
+extern void	dccp_close_output(void *, mblk_t *, void *, ip_recv_attr_t *);
+extern void	dccp_shutdown_output(void *, mblk_t *, void *, ip_recv_attr_t *);
+extern void	dccp_send_data(dccp_t *, mblk_t *);
+extern void	dccp_xmit_listeners_reset(mblk_t *, ip_recv_attr_t *,
+		    ip_stack_t *, conn_t *);
+extern void	dccp_send_synack(void *, mblk_t *, void *, ip_recv_attr_t *);
+extern mblk_t	*dccp_xmit_mp(dccp_t *, mblk_t *, int32_t, int32_t *,
+		    mblk_t **, uint32_t, boolean_t, uint32_t *, boolean_t);
+/* XXX following functions should be redone */
+extern mblk_t	*dccp_generate_response(conn_t *, mblk_t *);
+extern mblk_t	*dccp_generate_request(conn_t *);
+extern mblk_t	*dccp_generate_reset(conn_t *);
+extern mblk_t	*dccp_generate_ack(conn_t *);
+extern mblk_t	*dccp_generate_sync(conn_t *);
+
+/*
+ * Functions in dccp_opt_data.c
+ */
+extern int	dccp_opt_get(conn_t *, int, int, uchar_t *);
+extern int	dccp_opt_set(conn_t *, uint_t, int, int, uint_t, uchar_t *,
+		    uint_t *, uchar_t *, void *, cred_t *);
+
+/*
+ * Functions in dccp_timers.c
+ */
+extern timeout_id_t	dccp_timeout(conn_t *, void (*)(void *), hrtime_t);
+extern clock_t	dccp_timeout_cancel(conn_t *, timeout_id_t);
+extern mblk_t	*dccp_timermp_alloc(int);
+extern void	dccp_timermp_free(dccp_t *);
+extern void	dccp_timers_stop(dccp_t *);
+extern void	dccp_keepalive_timer(void *);
+extern void	dccp_timer(void *);
+
+/*
+ * Functions in dccp_tpi.c
+ */
+extern void	dccp_do_capability_ack(dccp_t *, struct T_capability_ack *,
+		    t_uscalar_t);
+extern void	dccp_capability_req(dccp_t *, mblk_t *);
+extern void	dccp_err_ack(dccp_t *, mblk_t *, int, int);
+extern void	dccp_tpi_connect(dccp_t *, mblk_t *);
+extern int	dccp_tpi_close(queue_t *, int);
+extern int	dccp_tpi_close_accept(queue_t *);
+extern boolean_t	dccp_conn_con(dccp_t *, uchar_t *, mblk_t *, mblk_t **,
+			    ip_recv_attr_t *);
+extern int	dccp_tpi_opt_get(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
+extern int	dccp_tpi_opt_set(queue_t *, uint_t, int, int, uint_t, uchar_t *,
+		    uint_t *, uchar_t *, void *, cred_t *);
+extern void	dccp_tpi_accept(queue_t *, mblk_t *);
+
+#endif	/* _KERNEL */
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* _INET_DCCP_IMPL_H */
