[ALSA] sscape - Use platform_device
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / dccp / ccid.h
blobc37eeeaf5c6e21982c341391d8d8db1a9929bdb9
1 #ifndef _CCID_H
2 #define _CCID_H
3 /*
4 * net/dccp/ccid.h
6 * An implementation of the DCCP protocol
7 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
9 * CCID infrastructure
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.
16 #include <net/sock.h>
17 #include <linux/compiler.h>
18 #include <linux/dccp.h>
19 #include <linux/list.h>
20 #include <linux/module.h>
22 #define CCID_MAX 255
24 struct ccid {
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,
35 struct sk_buff *skb);
36 int (*ccid_hc_rx_parse_options)(struct sock *sk,
37 unsigned char option,
38 unsigned char len, u16 idx,
39 unsigned char* value);
40 void (*ccid_hc_rx_insert_options)(struct sock *sk,
41 struct sk_buff *skb);
42 void (*ccid_hc_tx_insert_options)(struct sock *sk,
43 struct sk_buff *skb);
44 void (*ccid_hc_tx_packet_recv)(struct sock *sk,
45 struct sk_buff *skb);
46 int (*ccid_hc_tx_parse_options)(struct sock *sk,
47 unsigned char option,
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,
53 int len);
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,
60 u32 __user *optval,
61 int __user *optlen);
62 int (*ccid_hc_tx_getsockopt)(struct sock *sk,
63 const int optname, int len,
64 u32 __user *optval,
65 int __user *optlen);
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)
82 int rc = 0;
83 if (ccid->ccid_hc_tx_send_packet != NULL)
84 rc = ccid->ccid_hc_tx_send_packet(sk, skb, len);
85 return rc;
88 static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
89 int more, int len)
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)
97 int rc = 0;
98 if (ccid->ccid_hc_rx_init != NULL)
99 rc = ccid->ccid_hc_rx_init(sk);
100 return rc;
103 static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk)
105 int rc = 0;
106 if (ccid->ccid_hc_tx_init != NULL)
107 rc = ccid->ccid_hc_tx_init(sk);
108 return rc;
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,
126 struct sk_buff *skb)
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,
133 struct sk_buff *skb)
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)
144 int rc = 0;
145 if (ccid->ccid_hc_tx_parse_options != NULL)
146 rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx,
147 value);
148 return rc;
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)
156 int rc = 0;
157 if (ccid->ccid_hc_rx_parse_options != NULL)
158 rc = ccid->ccid_hc_rx_parse_options(sk, option, len, idx, value);
159 return rc;
162 static inline void ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
163 struct sk_buff *skb)
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,
170 struct sk_buff *skb)
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,
197 optval, optlen);
198 return rc;
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,
208 optval, optlen);
209 return rc;
211 #endif /* _CCID_H */