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>
25 unsigned char ccid_id
;
26 const char *ccid_name
;
27 struct module
*ccid_owner
;
28 int (*ccid_init
)(struct sock
*sk
);
29 void (*ccid_exit
)(struct sock
*sk
);
30 int (*ccid_hc_rx_init
)(struct sock
*sk
);
31 int (*ccid_hc_tx_init
)(struct sock
*sk
);
32 void (*ccid_hc_rx_exit
)(struct sock
*sk
);
33 void (*ccid_hc_tx_exit
)(struct sock
*sk
);
34 void (*ccid_hc_rx_packet_recv
)(struct sock
*sk
,
36 int (*ccid_hc_rx_parse_options
)(struct sock
*sk
,
38 unsigned char len
, u16 idx
,
39 unsigned char* value
);
40 void (*ccid_hc_rx_insert_options
)(struct sock
*sk
,
42 void (*ccid_hc_tx_insert_options
)(struct sock
*sk
,
44 void (*ccid_hc_tx_packet_recv
)(struct sock
*sk
,
46 int (*ccid_hc_tx_parse_options
)(struct sock
*sk
,
48 unsigned char len
, u16 idx
,
49 unsigned char* value
);
50 int (*ccid_hc_tx_send_packet
)(struct sock
*sk
,
51 struct sk_buff
*skb
, int len
);
52 void (*ccid_hc_tx_packet_sent
)(struct sock
*sk
, int more
,
54 void (*ccid_hc_rx_get_info
)(struct sock
*sk
,
55 struct tcp_info
*info
);
56 void (*ccid_hc_tx_get_info
)(struct sock
*sk
,
57 struct tcp_info
*info
);
58 int (*ccid_hc_rx_getsockopt
)(struct sock
*sk
,
59 const int optname
, int len
,
62 int (*ccid_hc_tx_getsockopt
)(struct sock
*sk
,
63 const int optname
, int len
,
68 extern int ccid_register(struct ccid
*ccid
);
69 extern int ccid_unregister(struct ccid
*ccid
);
71 extern struct ccid
*ccid_init(unsigned char id
, struct sock
*sk
);
72 extern void ccid_exit(struct ccid
*ccid
, struct sock
*sk
);
74 static inline void __ccid_get(struct ccid
*ccid
)
76 __module_get(ccid
->ccid_owner
);
79 static inline int ccid_hc_tx_send_packet(struct ccid
*ccid
, struct sock
*sk
,
80 struct sk_buff
*skb
, int len
)
83 if (ccid
->ccid_hc_tx_send_packet
!= NULL
)
84 rc
= ccid
->ccid_hc_tx_send_packet(sk
, skb
, len
);
88 static inline void ccid_hc_tx_packet_sent(struct ccid
*ccid
, struct sock
*sk
,
91 if (ccid
->ccid_hc_tx_packet_sent
!= NULL
)
92 ccid
->ccid_hc_tx_packet_sent(sk
, more
, len
);
95 static inline int ccid_hc_rx_init(struct ccid
*ccid
, struct sock
*sk
)
98 if (ccid
->ccid_hc_rx_init
!= NULL
)
99 rc
= ccid
->ccid_hc_rx_init(sk
);
103 static inline int ccid_hc_tx_init(struct ccid
*ccid
, struct sock
*sk
)
106 if (ccid
->ccid_hc_tx_init
!= NULL
)
107 rc
= ccid
->ccid_hc_tx_init(sk
);
111 static inline void ccid_hc_rx_exit(struct ccid
*ccid
, struct sock
*sk
)
113 if (ccid
!= NULL
&& ccid
->ccid_hc_rx_exit
!= NULL
&&
114 dccp_sk(sk
)->dccps_hc_rx_ccid_private
!= NULL
)
115 ccid
->ccid_hc_rx_exit(sk
);
118 static inline void ccid_hc_tx_exit(struct ccid
*ccid
, struct sock
*sk
)
120 if (ccid
!= NULL
&& ccid
->ccid_hc_tx_exit
!= NULL
&&
121 dccp_sk(sk
)->dccps_hc_tx_ccid_private
!= NULL
)
122 ccid
->ccid_hc_tx_exit(sk
);
125 static inline void ccid_hc_rx_packet_recv(struct ccid
*ccid
, struct sock
*sk
,
128 if (ccid
->ccid_hc_rx_packet_recv
!= NULL
)
129 ccid
->ccid_hc_rx_packet_recv(sk
, skb
);
132 static inline void ccid_hc_tx_packet_recv(struct ccid
*ccid
, struct sock
*sk
,
135 if (ccid
->ccid_hc_tx_packet_recv
!= NULL
)
136 ccid
->ccid_hc_tx_packet_recv(sk
, skb
);
139 static inline int ccid_hc_tx_parse_options(struct ccid
*ccid
, struct sock
*sk
,
140 unsigned char option
,
141 unsigned char len
, u16 idx
,
142 unsigned char* value
)
145 if (ccid
->ccid_hc_tx_parse_options
!= NULL
)
146 rc
= ccid
->ccid_hc_tx_parse_options(sk
, option
, len
, idx
,
151 static inline int ccid_hc_rx_parse_options(struct ccid
*ccid
, struct sock
*sk
,
152 unsigned char option
,
153 unsigned char len
, u16 idx
,
154 unsigned char* value
)
157 if (ccid
->ccid_hc_rx_parse_options
!= NULL
)
158 rc
= ccid
->ccid_hc_rx_parse_options(sk
, option
, len
, idx
, value
);
162 static inline void ccid_hc_tx_insert_options(struct ccid
*ccid
, struct sock
*sk
,
165 if (ccid
->ccid_hc_tx_insert_options
!= NULL
)
166 ccid
->ccid_hc_tx_insert_options(sk
, skb
);
169 static inline void ccid_hc_rx_insert_options(struct ccid
*ccid
, struct sock
*sk
,
172 if (ccid
->ccid_hc_rx_insert_options
!= NULL
)
173 ccid
->ccid_hc_rx_insert_options(sk
, skb
);
176 static inline void ccid_hc_rx_get_info(struct ccid
*ccid
, struct sock
*sk
,
177 struct tcp_info
*info
)
179 if (ccid
->ccid_hc_rx_get_info
!= NULL
)
180 ccid
->ccid_hc_rx_get_info(sk
, info
);
183 static inline void ccid_hc_tx_get_info(struct ccid
*ccid
, struct sock
*sk
,
184 struct tcp_info
*info
)
186 if (ccid
->ccid_hc_tx_get_info
!= NULL
)
187 ccid
->ccid_hc_tx_get_info(sk
, info
);
190 static inline int ccid_hc_rx_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_hc_rx_getsockopt
!= NULL
)
196 rc
= ccid
->ccid_hc_rx_getsockopt(sk
, optname
, len
,
201 static inline int ccid_hc_tx_getsockopt(struct ccid
*ccid
, struct sock
*sk
,
202 const int optname
, int len
,
203 u32 __user
*optval
, int __user
*optlen
)
205 int rc
= -ENOPROTOOPT
;
206 if (ccid
->ccid_hc_tx_getsockopt
!= NULL
)
207 rc
= ccid
->ccid_hc_tx_getsockopt(sk
, optname
, len
,