ccid.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. struct kmem_cache *ccid_hc_rx_slab;
  27. __u32 ccid_hc_rx_obj_size;
  28. struct kmem_cache *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. void (*ccid_hc_tx_packet_recv)(struct sock *sk,
  43. struct sk_buff *skb);
  44. int (*ccid_hc_tx_parse_options)(struct sock *sk,
  45. unsigned char option,
  46. unsigned char len, u16 idx,
  47. unsigned char* value);
  48. int (*ccid_hc_tx_send_packet)(struct sock *sk,
  49. struct sk_buff *skb);
  50. void (*ccid_hc_tx_packet_sent)(struct sock *sk,
  51. int more, unsigned int len);
  52. void (*ccid_hc_rx_get_info)(struct sock *sk,
  53. struct tcp_info *info);
  54. void (*ccid_hc_tx_get_info)(struct sock *sk,
  55. struct tcp_info *info);
  56. int (*ccid_hc_rx_getsockopt)(struct sock *sk,
  57. const int optname, int len,
  58. u32 __user *optval,
  59. int __user *optlen);
  60. int (*ccid_hc_tx_getsockopt)(struct sock *sk,
  61. const int optname, int len,
  62. u32 __user *optval,
  63. int __user *optlen);
  64. };
  65. extern int ccid_register(struct ccid_operations *ccid_ops);
  66. extern int ccid_unregister(struct ccid_operations *ccid_ops);
  67. struct ccid {
  68. struct ccid_operations *ccid_ops;
  69. char ccid_priv[0];
  70. };
  71. static inline void *ccid_priv(const struct ccid *ccid)
  72. {
  73. return (void *)ccid->ccid_priv;
  74. }
  75. extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx,
  76. gfp_t gfp);
  77. extern struct ccid *ccid_hc_rx_new(unsigned char id, struct sock *sk,
  78. gfp_t gfp);
  79. extern struct ccid *ccid_hc_tx_new(unsigned char id, struct sock *sk,
  80. gfp_t gfp);
  81. extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
  82. extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
  83. static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
  84. struct sk_buff *skb)
  85. {
  86. int rc = 0;
  87. if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL)
  88. rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb);
  89. return rc;
  90. }
  91. static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
  92. int more, unsigned int len)
  93. {
  94. if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
  95. ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len);
  96. }
  97. static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
  98. struct sk_buff *skb)
  99. {
  100. if (ccid->ccid_ops->ccid_hc_rx_packet_recv != NULL)
  101. ccid->ccid_ops->ccid_hc_rx_packet_recv(sk, skb);
  102. }
  103. static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
  104. struct sk_buff *skb)
  105. {
  106. if (ccid->ccid_ops->ccid_hc_tx_packet_recv != NULL)
  107. ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb);
  108. }
  109. static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
  110. unsigned char option,
  111. unsigned char len, u16 idx,
  112. unsigned char* value)
  113. {
  114. int rc = 0;
  115. if (ccid->ccid_ops->ccid_hc_tx_parse_options != NULL)
  116. rc = ccid->ccid_ops->ccid_hc_tx_parse_options(sk, option, len, idx,
  117. value);
  118. return rc;
  119. }
  120. static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
  121. unsigned char option,
  122. unsigned char len, u16 idx,
  123. unsigned char* value)
  124. {
  125. int rc = 0;
  126. if (ccid->ccid_ops->ccid_hc_rx_parse_options != NULL)
  127. rc = ccid->ccid_ops->ccid_hc_rx_parse_options(sk, option, len, idx, value);
  128. return rc;
  129. }
  130. static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
  131. struct sk_buff *skb)
  132. {
  133. if (ccid->ccid_ops->ccid_hc_rx_insert_options != NULL)
  134. return ccid->ccid_ops->ccid_hc_rx_insert_options(sk, skb);
  135. return 0;
  136. }
  137. static inline void ccid_hc_rx_get_info(struct ccid *ccid, struct sock *sk,
  138. struct tcp_info *info)
  139. {
  140. if (ccid->ccid_ops->ccid_hc_rx_get_info != NULL)
  141. ccid->ccid_ops->ccid_hc_rx_get_info(sk, info);
  142. }
  143. static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk,
  144. struct tcp_info *info)
  145. {
  146. if (ccid->ccid_ops->ccid_hc_tx_get_info != NULL)
  147. ccid->ccid_ops->ccid_hc_tx_get_info(sk, info);
  148. }
  149. static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk,
  150. const int optname, int len,
  151. u32 __user *optval, int __user *optlen)
  152. {
  153. int rc = -ENOPROTOOPT;
  154. if (ccid->ccid_ops->ccid_hc_rx_getsockopt != NULL)
  155. rc = ccid->ccid_ops->ccid_hc_rx_getsockopt(sk, optname, len,
  156. optval, optlen);
  157. return rc;
  158. }
  159. static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk,
  160. const int optname, int len,
  161. u32 __user *optval, int __user *optlen)
  162. {
  163. int rc = -ENOPROTOOPT;
  164. if (ccid->ccid_ops->ccid_hc_tx_getsockopt != NULL)
  165. rc = ccid->ccid_ops->ccid_hc_tx_getsockopt(sk, optname, len,
  166. optval, optlen);
  167. return rc;
  168. }
  169. #endif /* _CCID_H */