]>
Commit | Line | Data |
---|---|---|
7c657876 ACM |
1 | #ifndef _CCID_H |
2 | #define _CCID_H | |
3 | /* | |
4 | * net/dccp/ccid.h | |
5 | * | |
6 | * An implementation of the DCCP protocol | |
7 | * Arnaldo Carvalho de Melo <acme@conectiva.com.br> | |
8 | * | |
9 | * CCID infrastructure | |
10 | * | |
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. | |
14 | */ | |
15 | ||
16 | #include <net/sock.h> | |
88f964db | 17 | #include <linux/compiler.h> |
7c657876 ACM |
18 | #include <linux/dccp.h> |
19 | #include <linux/list.h> | |
20 | #include <linux/module.h> | |
21 | ||
22 | #define CCID_MAX 255 | |
23 | ||
14c85021 ACM |
24 | struct tcp_info; |
25 | ||
7c657876 ACM |
26 | struct ccid { |
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); | |
7690af3f ACM |
36 | void (*ccid_hc_rx_packet_recv)(struct sock *sk, |
37 | struct sk_buff *skb); | |
7c657876 ACM |
38 | int (*ccid_hc_rx_parse_options)(struct sock *sk, |
39 | unsigned char option, | |
40 | unsigned char len, u16 idx, | |
41 | unsigned char* value); | |
7690af3f ACM |
42 | void (*ccid_hc_rx_insert_options)(struct sock *sk, |
43 | struct sk_buff *skb); | |
44 | void (*ccid_hc_tx_insert_options)(struct sock *sk, | |
45 | struct sk_buff *skb); | |
46 | void (*ccid_hc_tx_packet_recv)(struct sock *sk, | |
47 | struct sk_buff *skb); | |
7c657876 ACM |
48 | int (*ccid_hc_tx_parse_options)(struct sock *sk, |
49 | unsigned char option, | |
50 | unsigned char len, u16 idx, | |
51 | unsigned char* value); | |
52 | int (*ccid_hc_tx_send_packet)(struct sock *sk, | |
27258ee5 | 53 | struct sk_buff *skb, int len); |
7690af3f ACM |
54 | void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more, |
55 | int len); | |
2babe1f6 ACM |
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); | |
88f964db ACM |
60 | int (*ccid_hc_rx_getsockopt)(struct sock *sk, |
61 | const int optname, int len, | |
62 | u32 __user *optval, | |
63 | int __user *optlen); | |
64 | int (*ccid_hc_tx_getsockopt)(struct sock *sk, | |
65 | const int optname, int len, | |
66 | u32 __user *optval, | |
67 | int __user *optlen); | |
7c657876 ACM |
68 | }; |
69 | ||
70 | extern int ccid_register(struct ccid *ccid); | |
71 | extern int ccid_unregister(struct ccid *ccid); | |
72 | ||
73 | extern struct ccid *ccid_init(unsigned char id, struct sock *sk); | |
74 | extern void ccid_exit(struct ccid *ccid, struct sock *sk); | |
75 | ||
76 | static inline void __ccid_get(struct ccid *ccid) | |
77 | { | |
78 | __module_get(ccid->ccid_owner); | |
79 | } | |
80 | ||
81 | static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk, | |
27258ee5 | 82 | struct sk_buff *skb, int len) |
7c657876 ACM |
83 | { |
84 | int rc = 0; | |
85 | if (ccid->ccid_hc_tx_send_packet != NULL) | |
27258ee5 | 86 | rc = ccid->ccid_hc_tx_send_packet(sk, skb, len); |
7c657876 ACM |
87 | return rc; |
88 | } | |
89 | ||
90 | static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk, | |
91 | int more, int len) | |
92 | { | |
93 | if (ccid->ccid_hc_tx_packet_sent != NULL) | |
94 | ccid->ccid_hc_tx_packet_sent(sk, more, len); | |
95 | } | |
96 | ||
97 | static inline int ccid_hc_rx_init(struct ccid *ccid, struct sock *sk) | |
98 | { | |
99 | int rc = 0; | |
100 | if (ccid->ccid_hc_rx_init != NULL) | |
101 | rc = ccid->ccid_hc_rx_init(sk); | |
102 | return rc; | |
103 | } | |
104 | ||
105 | static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk) | |
106 | { | |
107 | int rc = 0; | |
108 | if (ccid->ccid_hc_tx_init != NULL) | |
109 | rc = ccid->ccid_hc_tx_init(sk); | |
110 | return rc; | |
111 | } | |
112 | ||
113 | static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk) | |
114 | { | |
777b25a2 | 115 | if (ccid != NULL && ccid->ccid_hc_rx_exit != NULL && |
012e13ea | 116 | dccp_sk(sk)->dccps_hc_rx_ccid_private != NULL) |
7c657876 ACM |
117 | ccid->ccid_hc_rx_exit(sk); |
118 | } | |
119 | ||
120 | static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk) | |
121 | { | |
777b25a2 | 122 | if (ccid != NULL && ccid->ccid_hc_tx_exit != NULL && |
012e13ea | 123 | dccp_sk(sk)->dccps_hc_tx_ccid_private != NULL) |
7c657876 ACM |
124 | ccid->ccid_hc_tx_exit(sk); |
125 | } | |
126 | ||
127 | static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk, | |
128 | struct sk_buff *skb) | |
129 | { | |
130 | if (ccid->ccid_hc_rx_packet_recv != NULL) | |
131 | ccid->ccid_hc_rx_packet_recv(sk, skb); | |
132 | } | |
133 | ||
134 | static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk, | |
135 | struct sk_buff *skb) | |
136 | { | |
137 | if (ccid->ccid_hc_tx_packet_recv != NULL) | |
138 | ccid->ccid_hc_tx_packet_recv(sk, skb); | |
139 | } | |
140 | ||
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) | |
145 | { | |
146 | int rc = 0; | |
147 | if (ccid->ccid_hc_tx_parse_options != NULL) | |
7690af3f ACM |
148 | rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx, |
149 | value); | |
7c657876 ACM |
150 | return rc; |
151 | } | |
152 | ||
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) | |
157 | { | |
158 | int rc = 0; | |
159 | if (ccid->ccid_hc_rx_parse_options != NULL) | |
160 | rc = ccid->ccid_hc_rx_parse_options(sk, option, len, idx, value); | |
161 | return rc; | |
162 | } | |
163 | ||
164 | static inline void ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk, | |
165 | struct sk_buff *skb) | |
166 | { | |
167 | if (ccid->ccid_hc_tx_insert_options != NULL) | |
168 | ccid->ccid_hc_tx_insert_options(sk, skb); | |
169 | } | |
170 | ||
171 | static inline void ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk, | |
172 | struct sk_buff *skb) | |
173 | { | |
174 | if (ccid->ccid_hc_rx_insert_options != NULL) | |
175 | ccid->ccid_hc_rx_insert_options(sk, skb); | |
176 | } | |
2babe1f6 ACM |
177 | |
178 | static inline void ccid_hc_rx_get_info(struct ccid *ccid, struct sock *sk, | |
179 | struct tcp_info *info) | |
180 | { | |
181 | if (ccid->ccid_hc_rx_get_info != NULL) | |
182 | ccid->ccid_hc_rx_get_info(sk, info); | |
183 | } | |
184 | ||
185 | static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk, | |
186 | struct tcp_info *info) | |
187 | { | |
188 | if (ccid->ccid_hc_tx_get_info != NULL) | |
189 | ccid->ccid_hc_tx_get_info(sk, info); | |
190 | } | |
88f964db ACM |
191 | |
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) | |
195 | { | |
196 | int rc = -ENOPROTOOPT; | |
197 | if (ccid->ccid_hc_rx_getsockopt != NULL) | |
198 | rc = ccid->ccid_hc_rx_getsockopt(sk, optname, len, | |
199 | optval, optlen); | |
200 | return rc; | |
201 | } | |
202 | ||
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) | |
206 | { | |
207 | int rc = -ENOPROTOOPT; | |
208 | if (ccid->ccid_hc_tx_getsockopt != NULL) | |
209 | rc = ccid->ccid_hc_tx_getsockopt(sk, optname, len, | |
210 | optval, optlen); | |
211 | return rc; | |
212 | } | |
7c657876 | 213 | #endif /* _CCID_H */ |