ccid.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. /**
  23. * struct ccid_operations - Interface to Congestion-Control Infrastructure
  24. *
  25. * @ccid_id: numerical CCID ID (up to %CCID_MAX, cf. table 5 in RFC 4340, 10.)
  26. * @ccid_ccmps: the CCMPS including network/transport headers (0 when disabled)
  27. * @ccid_name: alphabetical identifier string for @ccid_id
  28. * @ccid_owner: module which implements/owns this CCID
  29. * @ccid_hc_{r,t}x_slab: memory pool for the receiver/sender half-connection
  30. * @ccid_hc_{r,t}x_obj_size: size of the receiver/sender half-connection socket
  31. *
  32. * @ccid_hc_{r,t}x_init: CCID-specific initialisation routine (before startup)
  33. * @ccid_hc_{r,t}x_exit: CCID-specific cleanup routine (before destruction)
  34. * @ccid_hc_rx_packet_recv: implements the HC-receiver side
  35. * @ccid_hc_{r,t}x_parse_options: parsing routine for CCID/HC-specific options
  36. * @ccid_hc_{r,t}x_insert_options: insert routine for CCID/HC-specific options
  37. * @ccid_hc_tx_packet_recv: implements feedback processing for the HC-sender
  38. * @ccid_hc_tx_send_packet: implements the sending part of the HC-sender
  39. * @ccid_hc_tx_packet_sent: does accounting for packets in flight by HC-sender
  40. * @ccid_hc_{r,t}x_get_info: INET_DIAG information for HC-receiver/sender
  41. * @ccid_hc_{r,t}x_getsockopt: socket options specific to HC-receiver/sender
  42. */
  43. struct ccid_operations {
  44. unsigned char ccid_id;
  45. __u32 ccid_ccmps;
  46. const char *ccid_name;
  47. struct module *ccid_owner;
  48. struct kmem_cache *ccid_hc_rx_slab,
  49. *ccid_hc_tx_slab;
  50. __u32 ccid_hc_rx_obj_size,
  51. ccid_hc_tx_obj_size;
  52. /* Interface Routines */
  53. int (*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk);
  54. int (*ccid_hc_tx_init)(struct ccid *ccid, struct sock *sk);
  55. void (*ccid_hc_rx_exit)(struct sock *sk);
  56. void (*ccid_hc_tx_exit)(struct sock *sk);
  57. void (*ccid_hc_rx_packet_recv)(struct sock *sk,
  58. struct sk_buff *skb);
  59. int (*ccid_hc_rx_parse_options)(struct sock *sk,
  60. unsigned char option,
  61. unsigned char len, u16 idx,
  62. unsigned char* value);
  63. int (*ccid_hc_rx_insert_options)(struct sock *sk,
  64. struct sk_buff *skb);
  65. void (*ccid_hc_tx_packet_recv)(struct sock *sk,
  66. struct sk_buff *skb);
  67. int (*ccid_hc_tx_parse_options)(struct sock *sk,
  68. unsigned char option,
  69. unsigned char len, u16 idx,
  70. unsigned char* value);
  71. int (*ccid_hc_tx_send_packet)(struct sock *sk,
  72. struct sk_buff *skb);
  73. void (*ccid_hc_tx_packet_sent)(struct sock *sk,
  74. int more, unsigned int len);
  75. void (*ccid_hc_rx_get_info)(struct sock *sk,
  76. struct tcp_info *info);
  77. void (*ccid_hc_tx_get_info)(struct sock *sk,
  78. struct tcp_info *info);
  79. int (*ccid_hc_rx_getsockopt)(struct sock *sk,
  80. const int optname, int len,
  81. u32 __user *optval,
  82. int __user *optlen);
  83. int (*ccid_hc_tx_getsockopt)(struct sock *sk,
  84. const int optname, int len,
  85. u32 __user *optval,
  86. int __user *optlen);
  87. };
  88. extern int ccid_register(struct ccid_operations *ccid_ops);
  89. extern int ccid_unregister(struct ccid_operations *ccid_ops);
  90. struct ccid {
  91. struct ccid_operations *ccid_ops;
  92. char ccid_priv[0];
  93. };
  94. static inline void *ccid_priv(const struct ccid *ccid)
  95. {
  96. return (void *)ccid->ccid_priv;
  97. }
  98. extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx,
  99. gfp_t gfp);
  100. extern struct ccid *ccid_hc_rx_new(unsigned char id, struct sock *sk,
  101. gfp_t gfp);
  102. extern struct ccid *ccid_hc_tx_new(unsigned char id, struct sock *sk,
  103. gfp_t gfp);
  104. extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
  105. extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
  106. static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
  107. struct sk_buff *skb)
  108. {
  109. int rc = 0;
  110. if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL)
  111. rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb);
  112. return rc;
  113. }
  114. static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
  115. int more, unsigned int len)
  116. {
  117. if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
  118. ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len);
  119. }
  120. static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
  121. struct sk_buff *skb)
  122. {
  123. if (ccid->ccid_ops->ccid_hc_rx_packet_recv != NULL)
  124. ccid->ccid_ops->ccid_hc_rx_packet_recv(sk, skb);
  125. }
  126. static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
  127. struct sk_buff *skb)
  128. {
  129. if (ccid->ccid_ops->ccid_hc_tx_packet_recv != NULL)
  130. ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb);
  131. }
  132. static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
  133. unsigned char option,
  134. unsigned char len, u16 idx,
  135. unsigned char* value)
  136. {
  137. int rc = 0;
  138. if (ccid->ccid_ops->ccid_hc_tx_parse_options != NULL)
  139. rc = ccid->ccid_ops->ccid_hc_tx_parse_options(sk, option, len, idx,
  140. value);
  141. return rc;
  142. }
  143. static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
  144. unsigned char option,
  145. unsigned char len, u16 idx,
  146. unsigned char* value)
  147. {
  148. int rc = 0;
  149. if (ccid->ccid_ops->ccid_hc_rx_parse_options != NULL)
  150. rc = ccid->ccid_ops->ccid_hc_rx_parse_options(sk, option, len, idx, value);
  151. return rc;
  152. }
  153. static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
  154. struct sk_buff *skb)
  155. {
  156. if (ccid->ccid_ops->ccid_hc_rx_insert_options != NULL)
  157. return ccid->ccid_ops->ccid_hc_rx_insert_options(sk, skb);
  158. return 0;
  159. }
  160. static inline void ccid_hc_rx_get_info(struct ccid *ccid, struct sock *sk,
  161. struct tcp_info *info)
  162. {
  163. if (ccid->ccid_ops->ccid_hc_rx_get_info != NULL)
  164. ccid->ccid_ops->ccid_hc_rx_get_info(sk, info);
  165. }
  166. static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk,
  167. struct tcp_info *info)
  168. {
  169. if (ccid->ccid_ops->ccid_hc_tx_get_info != NULL)
  170. ccid->ccid_ops->ccid_hc_tx_get_info(sk, info);
  171. }
  172. static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk,
  173. const int optname, int len,
  174. u32 __user *optval, int __user *optlen)
  175. {
  176. int rc = -ENOPROTOOPT;
  177. if (ccid->ccid_ops->ccid_hc_rx_getsockopt != NULL)
  178. rc = ccid->ccid_ops->ccid_hc_rx_getsockopt(sk, optname, len,
  179. optval, optlen);
  180. return rc;
  181. }
  182. static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk,
  183. const int optname, int len,
  184. u32 __user *optval, int __user *optlen)
  185. {
  186. int rc = -ENOPROTOOPT;
  187. if (ccid->ccid_ops->ccid_hc_tx_getsockopt != NULL)
  188. rc = ccid->ccid_ops->ccid_hc_tx_getsockopt(sk, optname, len,
  189. optval, optlen);
  190. return rc;
  191. }
  192. #endif /* _CCID_H */