blob: 08a8fd1d1610ac0e95e7025023cbd0fad819d272 [file] [log] [blame]
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -07001/*
2 * NET Generic infrastructure for Network protocols.
3 *
4 * Definitions for request_sock
5 *
6 * Authors: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
7 *
8 * From code originally in include/net/tcp.h
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15#ifndef _REQUEST_SOCK_H
16#define _REQUEST_SOCK_H
17
18#include <linux/slab.h>
19#include <linux/types.h>
20#include <net/sock.h>
21
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070022struct request_sock;
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070023struct sk_buff;
24struct dst_entry;
25struct proto;
26
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070027struct request_sock_ops {
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070028 int family;
29 kmem_cache_t *slab;
30 int obj_size;
31 int (*rtx_syn_ack)(struct sock *sk,
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070032 struct request_sock *req,
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070033 struct dst_entry *dst);
34 void (*send_ack)(struct sk_buff *skb,
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070035 struct request_sock *req);
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070036 void (*send_reset)(struct sk_buff *skb);
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070037 void (*destructor)(struct request_sock *req);
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070038};
39
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070040/* struct request_sock - mini sock to represent a connection request
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070041 */
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070042struct request_sock {
43 struct request_sock *dl_next; /* Must be first member! */
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070044 u16 mss;
45 u8 retrans;
46 u8 __pad;
47 /* The following two fields can be easily recomputed I think -AK */
48 u32 window_clamp; /* window clamp at creation time */
49 u32 rcv_wnd; /* rcv_wnd offered first time */
50 u32 ts_recent;
51 unsigned long expires;
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070052 struct request_sock_ops *rsk_ops;
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070053 struct sock *sk;
54};
55
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070056static inline struct request_sock *reqsk_alloc(struct request_sock_ops *ops)
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070057{
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070058 struct request_sock *req = kmem_cache_alloc(ops->slab, SLAB_ATOMIC);
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070059
60 if (req != NULL)
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070061 req->rsk_ops = ops;
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070062
63 return req;
64}
65
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070066static inline void __reqsk_free(struct request_sock *req)
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070067{
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070068 kmem_cache_free(req->rsk_ops->slab, req);
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070069}
70
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070071static inline void reqsk_free(struct request_sock *req)
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070072{
Arnaldo Carvalho de Melo60236fd2005-06-18 22:47:21 -070073 req->rsk_ops->destructor(req);
74 __reqsk_free(req);
Arnaldo Carvalho de Melo2e6599c2005-06-18 22:46:52 -070075}
76
77#endif /* _REQUEST_SOCK_H */