[CRYPTO] api: Handle unaligned keys in setkey
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / dccp / ccid.h
blobc65cb2453e43d7836e80ab25059d3993c5d875ce
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_operations {
27 unsigned char ccid_id;
28 const char *ccid_name;
29 struct module *ccid_owner;
30 struct kmem_cache *ccid_hc_rx_slab;
31 __u32 ccid_hc_rx_obj_size;
32 struct kmem_cache *ccid_hc_tx_slab;
33 __u32 ccid_hc_tx_obj_size;
34 int (*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk);
35 int (*ccid_hc_tx_init)(struct ccid *ccid, struct sock *sk);
36 void (*ccid_hc_rx_exit)(struct sock *sk);
37 void (*ccid_hc_tx_exit)(struct sock *sk);
38 void (*ccid_hc_rx_packet_recv)(struct sock *sk,
39 struct sk_buff *skb);
40 int (*ccid_hc_rx_parse_options)(struct sock *sk,
41 unsigned char option,
42 unsigned char len, u16 idx,
43 unsigned char* value);
44 int (*ccid_hc_rx_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);
54 void (*ccid_hc_tx_packet_sent)(struct sock *sk,
55 int more, unsigned 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_operations *ccid_ops);
71 extern int ccid_unregister(struct ccid_operations *ccid_ops);
73 struct ccid {
74 struct ccid_operations *ccid_ops;
75 char ccid_priv[0];
78 static inline void *ccid_priv(const struct ccid *ccid)
80 return (void *)ccid->ccid_priv;
83 extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx,
84 gfp_t gfp);
86 extern struct ccid *ccid_hc_rx_new(unsigned char id, struct sock *sk,
87 gfp_t gfp);
88 extern struct ccid *ccid_hc_tx_new(unsigned char id, struct sock *sk,
89 gfp_t gfp);
91 extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
92 extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
94 static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
95 struct sk_buff *skb)
97 int rc = 0;
98 if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL)
99 rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb);
100 return rc;
103 static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
104 int more, unsigned int len)
106 if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
107 ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len);
110 static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
111 struct sk_buff *skb)
113 if (ccid->ccid_ops->ccid_hc_rx_packet_recv != NULL)
114 ccid->ccid_ops->ccid_hc_rx_packet_recv(sk, skb);
117 static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
118 struct sk_buff *skb)
120 if (ccid->ccid_ops->ccid_hc_tx_packet_recv != NULL)
121 ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb);
124 static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
125 unsigned char option,
126 unsigned char len, u16 idx,
127 unsigned char* value)
129 int rc = 0;
130 if (ccid->ccid_ops->ccid_hc_tx_parse_options != NULL)
131 rc = ccid->ccid_ops->ccid_hc_tx_parse_options(sk, option, len, idx,
132 value);
133 return rc;
136 static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
137 unsigned char option,
138 unsigned char len, u16 idx,
139 unsigned char* value)
141 int rc = 0;
142 if (ccid->ccid_ops->ccid_hc_rx_parse_options != NULL)
143 rc = ccid->ccid_ops->ccid_hc_rx_parse_options(sk, option, len, idx, value);
144 return rc;
147 static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
148 struct sk_buff *skb)
150 if (ccid->ccid_ops->ccid_hc_rx_insert_options != NULL)
151 return ccid->ccid_ops->ccid_hc_rx_insert_options(sk, skb);
152 return 0;
155 static inline void ccid_hc_rx_get_info(struct ccid *ccid, struct sock *sk,
156 struct tcp_info *info)
158 if (ccid->ccid_ops->ccid_hc_rx_get_info != NULL)
159 ccid->ccid_ops->ccid_hc_rx_get_info(sk, info);
162 static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk,
163 struct tcp_info *info)
165 if (ccid->ccid_ops->ccid_hc_tx_get_info != NULL)
166 ccid->ccid_ops->ccid_hc_tx_get_info(sk, info);
169 static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk,
170 const int optname, int len,
171 u32 __user *optval, int __user *optlen)
173 int rc = -ENOPROTOOPT;
174 if (ccid->ccid_ops->ccid_hc_rx_getsockopt != NULL)
175 rc = ccid->ccid_ops->ccid_hc_rx_getsockopt(sk, optname, len,
176 optval, optlen);
177 return rc;
180 static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk,
181 const int optname, int len,
182 u32 __user *optval, int __user *optlen)
184 int rc = -ENOPROTOOPT;
185 if (ccid->ccid_ops->ccid_hc_tx_getsockopt != NULL)
186 rc = ccid->ccid_ops->ccid_hc_tx_getsockopt(sk, optname, len,
187 optval, optlen);
188 return rc;
190 #endif /* _CCID_H */