ccid.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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, struct sk_buff *skb);
  31. int (*ccid_hc_rx_parse_options)(struct sock *sk,
  32. unsigned char option,
  33. unsigned char len, u16 idx,
  34. unsigned char* value);
  35. void (*ccid_hc_rx_insert_options)(struct sock *sk, struct sk_buff *skb);
  36. void (*ccid_hc_tx_insert_options)(struct sock *sk, struct sk_buff *skb);
  37. void (*ccid_hc_tx_packet_recv)(struct sock *sk, struct sk_buff *skb);
  38. int (*ccid_hc_tx_parse_options)(struct sock *sk,
  39. unsigned char option,
  40. unsigned char len, u16 idx,
  41. unsigned char* value);
  42. int (*ccid_hc_tx_send_packet)(struct sock *sk,
  43. struct sk_buff *skb, int len);
  44. void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more, int len);
  45. };
  46. extern int ccid_register(struct ccid *ccid);
  47. extern int ccid_unregister(struct ccid *ccid);
  48. extern struct ccid *ccid_init(unsigned char id, struct sock *sk);
  49. extern void ccid_exit(struct ccid *ccid, struct sock *sk);
  50. static inline void __ccid_get(struct ccid *ccid)
  51. {
  52. __module_get(ccid->ccid_owner);
  53. }
  54. static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
  55. struct sk_buff *skb, int len)
  56. {
  57. int rc = 0;
  58. if (ccid->ccid_hc_tx_send_packet != NULL)
  59. rc = ccid->ccid_hc_tx_send_packet(sk, skb, len);
  60. return rc;
  61. }
  62. static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
  63. int more, int len)
  64. {
  65. if (ccid->ccid_hc_tx_packet_sent != NULL)
  66. ccid->ccid_hc_tx_packet_sent(sk, more, len);
  67. }
  68. static inline int ccid_hc_rx_init(struct ccid *ccid, struct sock *sk)
  69. {
  70. int rc = 0;
  71. if (ccid->ccid_hc_rx_init != NULL)
  72. rc = ccid->ccid_hc_rx_init(sk);
  73. return rc;
  74. }
  75. static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk)
  76. {
  77. int rc = 0;
  78. if (ccid->ccid_hc_tx_init != NULL)
  79. rc = ccid->ccid_hc_tx_init(sk);
  80. return rc;
  81. }
  82. static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk)
  83. {
  84. if (ccid->ccid_hc_rx_exit != NULL)
  85. ccid->ccid_hc_rx_exit(sk);
  86. }
  87. static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk)
  88. {
  89. if (ccid->ccid_hc_tx_exit != NULL)
  90. ccid->ccid_hc_tx_exit(sk);
  91. }
  92. static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
  93. struct sk_buff *skb)
  94. {
  95. if (ccid->ccid_hc_rx_packet_recv != NULL)
  96. ccid->ccid_hc_rx_packet_recv(sk, skb);
  97. }
  98. static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
  99. struct sk_buff *skb)
  100. {
  101. if (ccid->ccid_hc_tx_packet_recv != NULL)
  102. ccid->ccid_hc_tx_packet_recv(sk, skb);
  103. }
  104. static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
  105. unsigned char option,
  106. unsigned char len, u16 idx,
  107. unsigned char* value)
  108. {
  109. int rc = 0;
  110. if (ccid->ccid_hc_tx_parse_options != NULL)
  111. rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx, value);
  112. return rc;
  113. }
  114. static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
  115. unsigned char option,
  116. unsigned char len, u16 idx,
  117. unsigned char* value)
  118. {
  119. int rc = 0;
  120. if (ccid->ccid_hc_rx_parse_options != NULL)
  121. rc = ccid->ccid_hc_rx_parse_options(sk, option, len, idx, value);
  122. return rc;
  123. }
  124. static inline void ccid_hc_tx_insert_options(struct ccid *ccid, struct sock *sk,
  125. struct sk_buff *skb)
  126. {
  127. if (ccid->ccid_hc_tx_insert_options != NULL)
  128. ccid->ccid_hc_tx_insert_options(sk, skb);
  129. }
  130. static inline void ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
  131. struct sk_buff *skb)
  132. {
  133. if (ccid->ccid_hc_rx_insert_options != NULL)
  134. ccid->ccid_hc_rx_insert_options(sk, skb);
  135. }
  136. #endif /* _CCID_H */