6 * An implementation of the DCCP protocol
7 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
17 #include <linux/compiler.h>
18 #include <linux/dccp.h>
19 #include <linux/list.h>
20 #include <linux/module.h>
26 struct ccid_operations
{
27 unsigned char ccid_id
;
28 const char *ccid_name
;
29 struct module
*ccid_owner
;
30 kmem_cache_t
*ccid_hc_rx_slab
;
31 __u32 ccid_hc_rx_obj_size
;
32 kmem_cache_t
*ccid_hc_tx_slab
;
33 __u32 ccid_hc_tx_obj_size
;
34 int (*ccid_hc_rx_init
)(struct ccid
*ccid
, struct sock
*sk
);
35 int (*ccid_hc_tx_init
)(struct ccid
*ccid
, struct sock
*sk
);
36 void (*ccid_hc_rx_exit
)(struct sock
*sk
);
37 void (*ccid_hc_tx_exit
)(struct sock
*sk
);
38 void (*ccid_hc_rx_packet_recv
)(struct sock
*sk
,
40 int (*ccid_hc_rx_parse_options
)(struct sock
*sk
,
42 unsigned char len
, u16 idx
,
43 unsigned char* value
);
44 int (*ccid_hc_rx_insert_options
)(struct sock
*sk
,
46 int (*ccid_hc_tx_insert_options
)(struct sock
*sk
,
48 void (*ccid_hc_tx_packet_recv
)(struct sock
*sk
,
50 int (*ccid_hc_tx_parse_options
)(struct sock
*sk
,
52 unsigned char len
, u16 idx
,
53 unsigned char* value
);
54 int (*ccid_hc_tx_send_packet
)(struct sock
*sk
,
55 struct sk_buff
*skb
, int len
);
56 void (*ccid_hc_tx_packet_sent
)(struct sock
*sk
, int more
,
58 void (*ccid_hc_rx_get_info
)(struct sock
*sk
,
59 struct tcp_info
*info
);
60 void (*ccid_hc_tx_get_info
)(struct sock
*sk
,
61 struct tcp_info
*info
);
62 int (*ccid_hc_rx_getsockopt
)(struct sock
*sk
,
63 const int optname
, int len
,
66 int (*ccid_hc_tx_getsockopt
)(struct sock
*sk
,
67 const int optname
, int len
,
72 extern int ccid_register(struct ccid_operations
*ccid_ops
);
73 extern int ccid_unregister(struct ccid_operations
*ccid_ops
);
76 struct ccid_operations
*ccid_ops
;
80 static inline void *ccid_priv(const struct ccid
*ccid
)
82 return (void *)ccid
->ccid_priv
;
85 extern struct ccid
*ccid_new(unsigned char id
, struct sock
*sk
, int rx
,
88 extern struct ccid
*ccid_hc_rx_new(unsigned char id
, struct sock
*sk
,
90 extern struct ccid
*ccid_hc_tx_new(unsigned char id
, struct sock
*sk
,
93 extern void ccid_hc_rx_delete(struct ccid
*ccid
, struct sock
*sk
);
94 extern void ccid_hc_tx_delete(struct ccid
*ccid
, struct sock
*sk
);
96 static inline int ccid_hc_tx_send_packet(struct ccid
*ccid
, struct sock
*sk
,
97 struct sk_buff
*skb
, int len
)
100 if (ccid
->ccid_ops
->ccid_hc_tx_send_packet
!= NULL
)
101 rc
= ccid
->ccid_ops
->ccid_hc_tx_send_packet(sk
, skb
, len
);
105 static inline void ccid_hc_tx_packet_sent(struct ccid
*ccid
, struct sock
*sk
,
108 if (ccid
->ccid_ops
->ccid_hc_tx_packet_sent
!= NULL
)
109 ccid
->ccid_ops
->ccid_hc_tx_packet_sent(sk
, more
, len
);
112 static inline void ccid_hc_rx_packet_recv(struct ccid
*ccid
, struct sock
*sk
,
115 if (ccid
->ccid_ops
->ccid_hc_rx_packet_recv
!= NULL
)
116 ccid
->ccid_ops
->ccid_hc_rx_packet_recv(sk
, skb
);
119 static inline void ccid_hc_tx_packet_recv(struct ccid
*ccid
, struct sock
*sk
,
122 if (ccid
->ccid_ops
->ccid_hc_tx_packet_recv
!= NULL
)
123 ccid
->ccid_ops
->ccid_hc_tx_packet_recv(sk
, skb
);
126 static inline int ccid_hc_tx_parse_options(struct ccid
*ccid
, struct sock
*sk
,
127 unsigned char option
,
128 unsigned char len
, u16 idx
,
129 unsigned char* value
)
132 if (ccid
->ccid_ops
->ccid_hc_tx_parse_options
!= NULL
)
133 rc
= ccid
->ccid_ops
->ccid_hc_tx_parse_options(sk
, option
, len
, idx
,
138 static inline int ccid_hc_rx_parse_options(struct ccid
*ccid
, struct sock
*sk
,
139 unsigned char option
,
140 unsigned char len
, u16 idx
,
141 unsigned char* value
)
144 if (ccid
->ccid_ops
->ccid_hc_rx_parse_options
!= NULL
)
145 rc
= ccid
->ccid_ops
->ccid_hc_rx_parse_options(sk
, option
, len
, idx
, value
);
149 static inline int ccid_hc_tx_insert_options(struct ccid
*ccid
, struct sock
*sk
,
152 if (ccid
->ccid_ops
->ccid_hc_tx_insert_options
!= NULL
)
153 return ccid
->ccid_ops
->ccid_hc_tx_insert_options(sk
, skb
);
157 static inline int ccid_hc_rx_insert_options(struct ccid
*ccid
, struct sock
*sk
,
160 if (ccid
->ccid_ops
->ccid_hc_rx_insert_options
!= NULL
)
161 return ccid
->ccid_ops
->ccid_hc_rx_insert_options(sk
, skb
);
165 static inline void ccid_hc_rx_get_info(struct ccid
*ccid
, struct sock
*sk
,
166 struct tcp_info
*info
)
168 if (ccid
->ccid_ops
->ccid_hc_rx_get_info
!= NULL
)
169 ccid
->ccid_ops
->ccid_hc_rx_get_info(sk
, info
);
172 static inline void ccid_hc_tx_get_info(struct ccid
*ccid
, struct sock
*sk
,
173 struct tcp_info
*info
)
175 if (ccid
->ccid_ops
->ccid_hc_tx_get_info
!= NULL
)
176 ccid
->ccid_ops
->ccid_hc_tx_get_info(sk
, info
);
179 static inline int ccid_hc_rx_getsockopt(struct ccid
*ccid
, struct sock
*sk
,
180 const int optname
, int len
,
181 u32 __user
*optval
, int __user
*optlen
)
183 int rc
= -ENOPROTOOPT
;
184 if (ccid
->ccid_ops
->ccid_hc_rx_getsockopt
!= NULL
)
185 rc
= ccid
->ccid_ops
->ccid_hc_rx_getsockopt(sk
, optname
, len
,
190 static inline int ccid_hc_tx_getsockopt(struct ccid
*ccid
, struct sock
*sk
,
191 const int optname
, int len
,
192 u32 __user
*optval
, int __user
*optlen
)
194 int rc
= -ENOPROTOOPT
;
195 if (ccid
->ccid_ops
->ccid_hc_tx_getsockopt
!= NULL
)
196 rc
= ccid
->ccid_ops
->ccid_hc_tx_getsockopt(sk
, optname
, len
,