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>
27 unsigned char ccid_id;
28 const char *ccid_name;
29 struct module *ccid_owner;
30 int (*ccid_init)(struct sock *sk);
31 void (*ccid_exit)(struct sock *sk);
32 int (*ccid_hc_rx_init)(struct sock *sk);
33 int (*ccid_hc_tx_init)(struct sock *sk);
34 void (*ccid_hc_rx_exit)(struct sock *sk);
35 void (*ccid_hc_tx_exit)(struct sock *sk);
36 void (*ccid_hc_rx_packet_recv)(struct sock *sk,
38 int (*ccid_hc_rx_parse_options)(struct sock *sk,
40 unsigned char len, u16 idx,
41 unsigned char* value);
42 void (*ccid_hc_rx_insert_options)(struct sock *sk,
44 void (*ccid_hc_tx_insert_options)(struct sock *sk,
46 void (*ccid_hc_tx_packet_recv)(struct sock *sk,
48 int (*ccid_hc_tx_parse_options)(struct sock *sk,
50 unsigned char len, u16 idx,
51 unsigned char* value);
52 int (*ccid_hc_tx_send_packet)(struct sock *sk,
53 struct sk_buff *skb, int len);
54 void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more,
56 void (*ccid_hc_rx_get_info)(struct sock *sk,
57 struct tcp_info *info);
58 void (*ccid_hc_tx_get_info)(struct sock *sk,
59 struct tcp_info *info);
60 int (*ccid_hc_rx_getsockopt)(struct sock *sk,
61 const int optname, int len,
64 int (*ccid_hc_tx_getsockopt)(struct sock *sk,
65 const int optname, int len,
70 extern int ccid_register(struct ccid *ccid);
71 extern int ccid_unregister(struct ccid *ccid);
73 extern struct ccid *ccid_init(unsigned char id, struct sock *sk);
74 extern void ccid_exit(struct ccid *ccid, struct sock *sk);
76 static inline void __ccid_get(struct ccid *ccid)
78 __module_get(ccid->ccid_owner);
81 static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
82 struct sk_buff *skb, int len)
85 if (ccid->ccid_hc_tx_send_packet != NULL)
86 rc = ccid->ccid_hc_tx_send_packet(sk, skb, len);
90 static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
93 if (ccid->ccid_hc_tx_packet_sent != NULL)
94 ccid->ccid_hc_tx_packet_sent(sk, more, len);
97 static inline int ccid_hc_rx_init(struct ccid *ccid, struct sock *sk)
100 if (ccid->ccid_hc_rx_init != NULL)
101 rc = ccid->ccid_hc_rx_init(sk);
105 static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk)
108 if (ccid->ccid_hc_tx_init != NULL)
109 rc = ccid->ccid_hc_tx_init(sk);
113 static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk)
115 if (ccid != NULL && ccid->ccid_hc_rx_exit != NULL &&
116 dccp_sk(sk)->dccps_hc_rx_ccid_private != NULL)
117 ccid->ccid_hc_rx_exit(sk);
120 static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk)
122 if (ccid != NULL && ccid->ccid_hc_tx_exit != NULL &&
123 dccp_sk(sk)->dccps_hc_tx_ccid_private != NULL)
124 ccid->ccid_hc_tx_exit(sk);
127 static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
130 if (ccid->ccid_hc_rx_packet_recv != NULL)
131 ccid->ccid_hc_rx_packet_recv(sk, skb);
134 static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
137 if (ccid->ccid_hc_tx_packet_recv != NULL)
138 ccid->ccid_hc_tx_packet_recv(sk, skb);
141 static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
142 unsigned char option,
143 unsigned char len, u16 idx,
144 unsigned char* value)
147 if (ccid->ccid_hc_tx_parse_options != NULL)
148 rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx,
153 static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
154 unsigned char option,
155 unsigned char len, u16 idx,
156 unsigned char* value)
159 if (ccid->ccid_hc_rx_parse_options != NULL)
160 rc = ccid->ccid_hc_rx_parse_options(sk, option, len, idx, value);
164 static inline void ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
167 if (ccid->ccid_hc_tx_insert_options != NULL)
168 ccid->ccid_hc_tx_insert_options(sk, skb);
171 static inline void ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
174 if (ccid->ccid_hc_rx_insert_options != NULL)
175 ccid->ccid_hc_rx_insert_options(sk, skb);
178 static inline void ccid_hc_rx_get_info(struct ccid *ccid, struct sock *sk,
179 struct tcp_info *info)
181 if (ccid->ccid_hc_rx_get_info != NULL)
182 ccid->ccid_hc_rx_get_info(sk, info);
185 static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk,
186 struct tcp_info *info)
188 if (ccid->ccid_hc_tx_get_info != NULL)
189 ccid->ccid_hc_tx_get_info(sk, info);
192 static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk,
193 const int optname, int len,
194 u32 __user *optval, int __user *optlen)
196 int rc = -ENOPROTOOPT;
197 if (ccid->ccid_hc_rx_getsockopt != NULL)
198 rc = ccid->ccid_hc_rx_getsockopt(sk, optname, len,
203 static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk,
204 const int optname, int len,
205 u32 __user *optval, int __user *optlen)
207 int rc = -ENOPROTOOPT;
208 if (ccid->ccid_hc_tx_getsockopt != NULL)
209 rc = ccid->ccid_hc_tx_getsockopt(sk, optname, len,