#ifndef _TCP_FASTOPEN_H_
#define _TCP_FASTOPEN_H_
#ifdef _KERNEL
#include "opt_inet.h"
#define TCP_FASTOPEN_COOKIE_LEN 8
#ifdef TCP_RFC7413
VNET_DECLARE(unsigned int, tcp_fastopen_client_enable);
#define V_tcp_fastopen_client_enable VNET(tcp_fastopen_client_enable)
VNET_DECLARE(unsigned int, tcp_fastopen_server_enable);
#define V_tcp_fastopen_server_enable VNET(tcp_fastopen_server_enable)
#else
#define V_tcp_fastopen_client_enable 0
#define V_tcp_fastopen_server_enable 0
#endif
union tcp_fastopen_ip_addr {
struct in_addr v4;
struct in6_addr v6;
};
struct tcp_fastopen_ccache_entry {
TAILQ_ENTRY(tcp_fastopen_ccache_entry) cce_link;
union tcp_fastopen_ip_addr cce_client_ip;
union tcp_fastopen_ip_addr cce_server_ip;
uint16_t server_port;
uint16_t server_mss;
uint8_t af;
uint8_t cookie_len;
uint8_t cookie[TCP_FASTOPEN_MAX_COOKIE_LEN];
sbintime_t disable_time;
};
struct tcp_fastopen_ccache;
struct tcp_fastopen_ccache_bucket {
struct mtx ccb_mtx;
TAILQ_HEAD(bucket_entries, tcp_fastopen_ccache_entry) ccb_entries;
int ccb_num_entries;
struct tcp_fastopen_ccache *ccb_ccache;
};
struct tcp_fastopen_ccache {
uma_zone_t zone;
struct tcp_fastopen_ccache_bucket *base;
unsigned int bucket_limit;
unsigned int buckets;
unsigned int mask;
uint32_t secret;
};
struct tcpcb;
#ifdef TCP_RFC7413
void tcp_fastopen_init(void);
void tcp_fastopen_destroy(void);
unsigned int *tcp_fastopen_alloc_counter(void);
void tcp_fastopen_decrement_counter(unsigned int *);
int tcp_fastopen_check_cookie(struct in_conninfo *, uint8_t *, unsigned int,
uint64_t *);
void tcp_fastopen_connect(struct tcpcb *);
void tcp_fastopen_disable_path(struct tcpcb *);
void tcp_fastopen_update_cache(struct tcpcb *, uint16_t, uint8_t,
uint8_t *);
#else
static __inline void
tcp_fastopen_init(void)
{
}
static __inline void
tcp_fastopen_destroy(void)
{
}
static __inline unsigned int *
tcp_fastopen_alloc_counter(void)
{
return (NULL);
}
static __inline void
tcp_fastopen_decrement_counter(unsigned int *_counter)
{
}
static __inline int
tcp_fastopen_check_cookie(struct in_conninfo *_inc, uint8_t *_cookie,
unsigned int _len, uint64_t *_latest_cookie)
{
return (-1);
}
static __inline void
tcp_fastopen_connect(struct tcpcb *_tp)
{
}
static __inline void
tcp_fastopen_disable_path(struct tcpcb *_tp)
{
}
static __inline void
tcp_fastopen_update_cache(struct tcpcb *_tp, uint16_t _mss, uint8_t _cookie_len,
uint8_t *_cookie)
{
}
#endif
#endif
#endif