ccid.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. #include <net/sock.h>
  16. #include <linux/compiler.h>
  17. #include <linux/dccp.h>
  18. #include <linux/list.h>
  19. #include <linux/module.h>
  20. #define CCID_MAX 255
  21. struct tcp_info;
  22. struct ccid_operations {
  23. unsigned char ccid_id;
  24. const char *ccid_name;
  25. struct module *ccid_owner;
  26. kmem_cache_t *ccid_hc_rx_slab;
  27. __u32 ccid_hc_rx_obj_size;
  28. kmem_cache_t *ccid_hc_tx_slab;
  29. __u32 ccid_hc_tx_obj_size;
  30. int (*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk);
  31. int (*ccid_hc_tx_init)(struct ccid *ccid, 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. int (*ccid_hc_rx_insert_options)(struct sock *sk,
  41. struct sk_buff *skb);
  42. int (*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);
  66. };
  67. extern int ccid_register(struct ccid_operations *ccid_ops);
  68. extern int ccid_unregister(struct ccid_operations *ccid_ops);
  69. struct ccid {
  70. struct ccid_operations *ccid_ops;
  71. char ccid_priv[0];
  72. };
  73. static inline void *ccid_priv(const struct ccid *ccid)
  74. {
  75. return (void *)ccid->ccid_priv;
  76. }
  77. extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx,
  78. gfp_t gfp);
  79. extern struct ccid *ccid_hc_rx_new(unsigned char id, struct sock *sk,
  80. gfp_t gfp);
  81. extern struct ccid *ccid_hc_tx_new(unsigned char id, struct sock *sk,
  82. gfp_t gfp);
  83. extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
  84. extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
  85. static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
  86. struct sk_buff *skb, int len)
  87. {
  88. int rc = 0;
  89. if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL)
  90. rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb, len);
  91. return rc;
  92. }
  93. static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
  94. int more, int len)
  95. {
  96. if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
  97. ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len);
  98. }
  99. static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
  100. struct sk_buff *skb)
  101. {
  102. if (ccid->ccid_ops->ccid_hc_rx_packet_recv != NULL)
  103. ccid->ccid_ops->ccid_hc_rx_packet_recv(sk, skb);
  104. }
  105. static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
  106. struct sk_buff *skb)
  107. {
  108. if (ccid->ccid_ops->ccid_hc_tx_packet_recv != NULL)
  109. ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb);
  110. }
  111. static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
  112. unsigned char option,
  113. unsigned char len, u16 idx,
  114. unsigned char* value)
  115. {
  116. int rc = 0;
  117. if (ccid->ccid_ops->ccid_hc_tx_parse_options != NULL)
  118. rc = ccid->ccid_ops->ccid_hc_tx_parse_options(sk, option, len, idx,
  119. value);
  120. return rc;
  121. }
  122. static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
  123. unsigned char option,
  124. unsigned char len, u16 idx,
  125. unsigned char* value)
  126. {
  127. int rc = 0;
  128. if (ccid->ccid_ops->ccid_hc_rx_parse_options != NULL)
  129. rc = ccid->ccid_ops->ccid_hc_rx_parse_options(sk, option, len, idx, value);
  130. return rc;
  131. }
  132. static inline int ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
  133. struct sk_buff *skb)
  134. {
  135. if (ccid->ccid_ops->ccid_hc_tx_insert_options != NULL)
  136. return ccid->ccid_ops->ccid_hc_tx_insert_options(sk, skb);
  137. return 0;
  138. }
  139. static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
  140. struct sk_buff *skb)
  141. {
  142. if (ccid->ccid_ops->ccid_hc_rx_insert_options != NULL)
  143. return ccid->ccid_ops->ccid_hc_rx_insert_options(sk, skb);
  144. return 0;
  145. }
  146. static inline void ccid_hc_rx_get_info(struct ccid *ccid, struct sock *sk,
  147. struct tcp_info *info)
  148. {
  149. if (ccid->ccid_ops->ccid_hc_rx_get_info != NULL)
  150. ccid->ccid_ops->ccid_hc_rx_get_info(sk, info);
  151. }
  152. static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk,
  153. struct tcp_info *info)
  154. {
  155. if (ccid->ccid_ops->ccid_hc_tx_get_info != NULL)
  156. ccid->ccid_ops->ccid_hc_tx_get_info(sk, info);
  157. }
  158. static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk,
  159. const int optname, int len,
  160. u32 __user *optval, int __user *optlen)
  161. {
  162. int rc = -ENOPROTOOPT;
  163. if (ccid->ccid_ops->ccid_hc_rx_getsockopt != NULL)
  164. rc = ccid->ccid_ops->ccid_hc_rx_getsockopt(sk, optname, len,
  165. optval, optlen);
  166. return rc;
  167. }
  168. static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk,
  169. const int optname, int len,
  170. u32 __user *optval, int __user *optlen)
  171. {
  172. int rc = -ENOPROTOOPT;
  173. if (ccid->ccid_ops->ccid_hc_tx_getsockopt != NULL)
  174. rc = ccid->ccid_ops->ccid_hc_tx_getsockopt(sk, optname, len,
  175. optval, optlen);
  176. return rc;
  177. }
  178. #endif /* _CCID_H */