ccid.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. };
  51. extern int ccid_register(struct ccid *ccid);
  52. extern int ccid_unregister(struct ccid *ccid);
  53. extern struct ccid *ccid_init(unsigned char id, struct sock *sk);
  54. extern void ccid_exit(struct ccid *ccid, struct sock *sk);
  55. static inline void __ccid_get(struct ccid *ccid)
  56. {
  57. __module_get(ccid->ccid_owner);
  58. }
  59. static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
  60. struct sk_buff *skb, int len)
  61. {
  62. int rc = 0;
  63. if (ccid->ccid_hc_tx_send_packet != NULL)
  64. rc = ccid->ccid_hc_tx_send_packet(sk, skb, len);
  65. return rc;
  66. }
  67. static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
  68. int more, int len)
  69. {
  70. if (ccid->ccid_hc_tx_packet_sent != NULL)
  71. ccid->ccid_hc_tx_packet_sent(sk, more, len);
  72. }
  73. static inline int ccid_hc_rx_init(struct ccid *ccid, struct sock *sk)
  74. {
  75. int rc = 0;
  76. if (ccid->ccid_hc_rx_init != NULL)
  77. rc = ccid->ccid_hc_rx_init(sk);
  78. return rc;
  79. }
  80. static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk)
  81. {
  82. int rc = 0;
  83. if (ccid->ccid_hc_tx_init != NULL)
  84. rc = ccid->ccid_hc_tx_init(sk);
  85. return rc;
  86. }
  87. static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk)
  88. {
  89. if (ccid->ccid_hc_rx_exit != NULL &&
  90. dccp_sk(sk)->dccps_hc_rx_ccid_private != NULL)
  91. ccid->ccid_hc_rx_exit(sk);
  92. }
  93. static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk)
  94. {
  95. if (ccid->ccid_hc_tx_exit != NULL &&
  96. dccp_sk(sk)->dccps_hc_tx_ccid_private != NULL)
  97. ccid->ccid_hc_tx_exit(sk);
  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_hc_rx_packet_recv != NULL)
  103. ccid->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_hc_tx_packet_recv != NULL)
  109. ccid->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_hc_tx_parse_options != NULL)
  118. rc = ccid->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_hc_rx_parse_options != NULL)
  129. rc = ccid->ccid_hc_rx_parse_options(sk, option, len, idx, value);
  130. return rc;
  131. }
  132. static inline void ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
  133. struct sk_buff *skb)
  134. {
  135. if (ccid->ccid_hc_tx_insert_options != NULL)
  136. ccid->ccid_hc_tx_insert_options(sk, skb);
  137. }
  138. static inline void ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
  139. struct sk_buff *skb)
  140. {
  141. if (ccid->ccid_hc_rx_insert_options != NULL)
  142. ccid->ccid_hc_rx_insert_options(sk, skb);
  143. }
  144. #endif /* _CCID_H */