From da1f4962209103a9c4b8de8081614312a2c05864 Mon Sep 17 00:00:00 2001 From: andre Date: Thu, 15 Mar 2007 15:59:28 +0000 Subject: Consolidate insertion of TCP options into a segment from within tcp_output() and syncache_respond() into its own generic function tcp_addoptions(). tcp_addoptions() is alignment agnostic and does optimal packing in all cases. In struct tcpopt rename to_requested_s_scale to just to_wscale. Add a comment with quote from RFC1323: "The Window field in a SYN (i.e., a or ) segment itself is never scaled." Reviewed by: silby, mohans, julian Sponsored by: TCP/IP Optimization Fundraise 2005 --- sys/netinet/tcp_var.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'sys/netinet/tcp_var.h') diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 46d396d..6dc20d4 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -229,22 +229,27 @@ struct tcpcb { * Structure to hold TCP options that are only used during segment * processing (in tcp_input), but not held in the tcpcb. * It's basically used to reduce the number of parameters - * to tcp_dooptions. + * to tcp_dooptions and tcp_addoptions. + * The binary order of the to_flags is relevant for packing of the + * options in tcp_addoptions. */ struct tcpopt { u_long to_flags; /* which options are present */ -#define TOF_TS 0x0001 /* timestamp */ -#define TOF_MSS 0x0010 /* maximum segment size */ -#define TOF_SCALE 0x0020 /* window scaling */ +#define TOF_MSS 0x0001 /* maximum segment size */ +#define TOF_SCALE 0x0002 /* window scaling */ +#define TOF_SACKPERM 0x0004 /* SACK permitted */ +#define TOF_TS 0x0010 /* timestamp */ #define TOF_SIGNATURE 0x0040 /* signature option present */ #define TOF_SIGLEN 0x0080 /* signature length valid (RFC2385) */ #define TOF_SACK 0x0100 /* Peer sent SACK option */ - u_int32_t to_tsval; - u_int32_t to_tsecr; - u_int16_t to_mss; - u_int8_t to_requested_s_scale; +#define TOF_MAXOPT 0x0200 + u_int32_t to_tsval; /* our new timestamp */ + u_int32_t to_tsecr; /* reflected timestamp */ + u_int16_t to_mss; /* maximum segment size */ + u_int8_t to_wscale; /* window scaling */ u_int8_t to_nsacks; /* number of SACK blocks */ u_char *to_sacks; /* pointer to the first SACK blocks */ + u_char *to_signature; /* pointer to the MD5 signature */ }; /* @@ -497,6 +502,7 @@ extern int ss_fltsz_local; extern int tcp_do_sack; /* SACK enabled/disabled */ +int tcp_addoptions(struct tcpopt *, u_char *); struct tcpcb * tcp_close(struct tcpcb *); void tcp_discardcb(struct tcpcb *); -- cgit v1.1