[PATCH] fix arm26 THREAD_SIZE
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / dccp / ccid.h
blobde681c6ad081307c8fd1069eb6c370b4854177cd
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 tcp_info;
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);
36 void (*ccid_hc_rx_packet_recv)(struct sock *sk,
37 struct sk_buff *skb);
38 int (*ccid_hc_rx_parse_options)(struct sock *sk,
39 unsigned char option,
40 unsigned char len, u16 idx,
41 unsigned char* value);
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);
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,
53 struct sk_buff *skb, int len);
54 void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more,
55 int len);
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,
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);
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)
84 int rc = 0;
85 if (ccid->ccid_hc_tx_send_packet != NULL)
86 rc = ccid->ccid_hc_tx_send_packet(sk, skb, len);
87 return rc;
90 static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
91 int more, int len)
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)
99 int rc = 0;
100 if (ccid->ccid_hc_rx_init != NULL)
101 rc = ccid->ccid_hc_rx_init(sk);
102 return rc;
105 static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk)
107 int rc = 0;
108 if (ccid->ccid_hc_tx_init != NULL)
109 rc = ccid->ccid_hc_tx_init(sk);
110 return rc;
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,
128 struct sk_buff *skb)
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,
135 struct sk_buff *skb)
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)
146 int rc = 0;
147 if (ccid->ccid_hc_tx_parse_options != NULL)
148 rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx,
149 value);
150 return rc;
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)
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;
164 static inline void ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
165 struct sk_buff *skb)
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,
172 struct sk_buff *skb)
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,
199 optval, optlen);
200 return rc;
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,
210 optval, optlen);
211 return rc;
213 #endif /* _CCID_H */