ccid.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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/dccp.h>
  17. #include <linux/list.h>
  18. #include <linux/module.h>
  19. #define CCID_MAX 255
  20. struct ccid {
  21. unsigned char ccid_id;
  22. const char *ccid_name;
  23. struct module *ccid_owner;
  24. int (*ccid_init)(struct sock *sk);
  25. void (*ccid_exit)(struct sock *sk);
  26. int (*ccid_hc_rx_init)(struct sock *sk);
  27. int (*ccid_hc_tx_init)(struct sock *sk);
  28. void (*ccid_hc_rx_exit)(struct sock *sk);
  29. void (*ccid_hc_tx_exit)(struct sock *sk);
  30. void (*ccid_hc_rx_packet_recv)(struct sock *sk,
  31. struct sk_buff *skb);
  32. int (*ccid_hc_rx_parse_options)(struct sock *sk,
  33. unsigned char option,
  34. unsigned char len, u16 idx,
  35. unsigned char* value);
  36. void (*ccid_hc_rx_insert_options)(struct sock *sk,
  37. struct sk_buff *skb);
  38. void (*ccid_hc_tx_insert_options)(struct sock *sk,
  39. struct sk_buff *skb);
  40. void (*ccid_hc_tx_packet_recv)(struct sock *sk,
  41. struct sk_buff *skb);
  42. int (*ccid_hc_tx_parse_options)(struct sock *sk,
  43. unsigned char option,
  44. unsigned char len, u16 idx,
  45. unsigned char* value);
  46. int (*ccid_hc_tx_send_packet)(struct sock *sk,
  47. struct sk_buff *skb, int len);
  48. void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more,
  49. int len);
  50. void (*ccid_hc_rx_get_info)(struct sock *sk,
  51. struct tcp_info *info);
  52. void (*ccid_hc_tx_get_info)(struct sock *sk,
  53. struct tcp_info *info);
  54. };
  55. extern int ccid_register(struct ccid *ccid);
  56. extern int ccid_unregister(struct ccid *ccid);
  57. extern struct ccid *ccid_init(unsigned char id, struct sock *sk);
  58. extern void ccid_exit(struct ccid *ccid, struct sock *sk);
  59. static inline void __ccid_get(struct ccid *ccid)
  60. {
  61. __module_get(ccid->ccid_owner);
  62. }
  63. static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
  64. struct sk_buff *skb, int len)
  65. {
  66. int rc = 0;
  67. if (ccid->ccid_hc_tx_send_packet != NULL)
  68. rc = ccid->ccid_hc_tx_send_packet(sk, skb, len);
  69. return rc;
  70. }
  71. static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
  72. int more, int len)
  73. {
  74. if (ccid->ccid_hc_tx_packet_sent != NULL)
  75. ccid->ccid_hc_tx_packet_sent(sk, more, len);
  76. }
  77. static inline int ccid_hc_rx_init(struct ccid *ccid, struct sock *sk)
  78. {
  79. int rc = 0;
  80. if (ccid->ccid_hc_rx_init != NULL)
  81. rc = ccid->ccid_hc_rx_init(sk);
  82. return rc;
  83. }
  84. static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk)
  85. {
  86. int rc = 0;
  87. if (ccid->ccid_hc_tx_init != NULL)
  88. rc = ccid->ccid_hc_tx_init(sk);
  89. return rc;
  90. }
  91. static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk)
  92. {
  93. if (ccid->ccid_hc_rx_exit != NULL &&
  94. dccp_sk(sk)->dccps_hc_rx_ccid_private != NULL)
  95. ccid->ccid_hc_rx_exit(sk);
  96. }
  97. static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk)
  98. {
  99. if (ccid->ccid_hc_tx_exit != NULL &&
  100. dccp_sk(sk)->dccps_hc_tx_ccid_private != NULL)
  101. ccid->ccid_hc_tx_exit(sk);
  102. }
  103. static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
  104. struct sk_buff *skb)
  105. {
  106. if (ccid->ccid_hc_rx_packet_recv != NULL)
  107. ccid->ccid_hc_rx_packet_recv(sk, skb);
  108. }
  109. static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
  110. struct sk_buff *skb)
  111. {
  112. if (ccid->ccid_hc_tx_packet_recv != NULL)
  113. ccid->ccid_hc_tx_packet_recv(sk, skb);
  114. }
  115. static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
  116. unsigned char option,
  117. unsigned char len, u16 idx,
  118. unsigned char* value)
  119. {
  120. int rc = 0;
  121. if (ccid->ccid_hc_tx_parse_options != NULL)
  122. rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx,
  123. value);
  124. return rc;
  125. }
  126. static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
  127. unsigned char option,
  128. unsigned char len, u16 idx,
  129. unsigned char* value)
  130. {
  131. int rc = 0;
  132. if (ccid->ccid_hc_rx_parse_options != NULL)
  133. rc = ccid->ccid_hc_rx_parse_options(sk, option, len, idx, value);
  134. return rc;
  135. }
  136. static inline void ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
  137. struct sk_buff *skb)
  138. {
  139. if (ccid->ccid_hc_tx_insert_options != NULL)
  140. ccid->ccid_hc_tx_insert_options(sk, skb);
  141. }
  142. static inline void ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
  143. struct sk_buff *skb)
  144. {
  145. if (ccid->ccid_hc_rx_insert_options != NULL)
  146. ccid->ccid_hc_rx_insert_options(sk, skb);
  147. }
  148. static inline void ccid_hc_rx_get_info(struct ccid *ccid, struct sock *sk,
  149. struct tcp_info *info)
  150. {
  151. if (ccid->ccid_hc_rx_get_info != NULL)
  152. ccid->ccid_hc_rx_get_info(sk, info);
  153. }
  154. static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk,
  155. struct tcp_info *info)
  156. {
  157. if (ccid->ccid_hc_tx_get_info != NULL)
  158. ccid->ccid_hc_tx_get_info(sk, info);
  159. }
  160. #endif /* _CCID_H */