ipa_ipv6ct.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright (c) 2018, 2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above
  10. * copyright notice, this list of conditions and the following
  11. * disclaimer in the documentation and/or other materials provided
  12. * with the distribution.
  13. * * Neither the name of The Linux Foundation nor the names of its
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  21. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  24. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  26. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  27. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef IPA_IPV6CT_H
  30. #define IPA_IPV6CT_H
  31. #include <stdint.h>
  32. #include <stdbool.h>
  33. #include <linux/msm_ipa.h>
  34. /**
  35. * enum ipa_ipv6_ct_direction_settings_type - direction filter settings
  36. *
  37. * IPA_IPV6CT_DIRECTION_DENY_ALL - deny inbound and outbound
  38. * IPA_IPV6CT_DIRECTION_ALLOW_OUT - allow outbound and deny inbound
  39. * IPA_IPV6CT_DIRECTION_ALLOW_IN - allow inbound and deny outbound
  40. * IPA_IPV6CT_DIRECTION_ALLOW_ALL - allow inbound and outbound
  41. */
  42. typedef enum
  43. {
  44. IPA_IPV6CT_DIRECTION_DENY_ALL = 0,
  45. IPA_IPV6CT_DIRECTION_ALLOW_OUT = 1,
  46. IPA_IPV6CT_DIRECTION_ALLOW_IN = 2,
  47. IPA_IPV6CT_DIRECTION_ALLOW_ALL = 3
  48. } ipa_ipv6_ct_direction_settings_type;
  49. /**
  50. * struct ipa_ipv6ct_rule - To hold IPv6CT rule
  51. * @src_ipv6_lsb: source IPv6 address LSB
  52. * @src_ipv6_msb: source IPv6 address MSB
  53. * @dest_ipv6_lsb: destination IPv6 address LSB
  54. * @dest_ipv6_msb: destination IPv6 address MSB
  55. * @direction_settings: direction filter settings (inbound/outbound) (see ipa_ipv6_ct_direction_settings_type)
  56. * @src_port: source port
  57. * @dest_port: destination port
  58. * @protocol: protocol of rule (tcp/udp)
  59. * @uc_activation_index: index pointing to uc activation table
  60. * @s: bit indication to use the system or local (1 or 0) addr for above table
  61. * @ucp: enable uc processing
  62. */
  63. typedef struct {
  64. uint64_t src_ipv6_lsb;
  65. uint64_t src_ipv6_msb;
  66. uint64_t dest_ipv6_lsb;
  67. uint64_t dest_ipv6_msb;
  68. ipa_ipv6_ct_direction_settings_type direction_settings;
  69. bool ucp;
  70. bool s;
  71. uint16_t uc_activation_index;
  72. uint16_t src_port;
  73. uint16_t dest_port;
  74. uint8_t protocol;
  75. } ipa_ipv6ct_rule;
  76. /**
  77. * ipa_ipv6ct_add_tbl() - create IPv6CT table
  78. * @number_of_entries: [in] number of IPv6CT entries
  79. * @table_handle: [out] handle of new IPv6CT table
  80. *
  81. * To create new IPv6CT table
  82. *
  83. * Returns: 0 On Success, negative on failure
  84. */
  85. int ipa_ipv6ct_add_tbl(uint16_t number_of_entries, uint32_t* table_handle);
  86. /**
  87. * ipa_ipv6ct_del_tbl() - delete IPv6CT table
  88. * @table_handle: [in] Handle of IPv6CT table
  89. *
  90. * To delete given IPv6CT table
  91. *
  92. * Returns: 0 On Success, negative on failure
  93. */
  94. int ipa_ipv6ct_del_tbl(uint32_t table_handle);
  95. /**
  96. * ipa_ipv6ct_add_rule() - to insert new IPv6CT rule
  97. * @table_handle: [in] handle of IPv6CT table
  98. * @user_rule: [in] Pointer to new rule
  99. * @rule_handle: [out] Return the handle to rule
  100. *
  101. * To insert new rule into a IPv6CT table
  102. *
  103. * Returns: 0 On Success, negative on failure
  104. */
  105. int ipa_ipv6ct_add_rule(uint32_t table_handle, const ipa_ipv6ct_rule* user_rule, uint32_t* rule_handle);
  106. /**
  107. * ipa_ipv6ct_del_rule() - to delete IPv6CT rule
  108. * @table_handle: [in] handle of IPv6CT table
  109. * @rule_handle: [in] IPv6CT rule handle
  110. *
  111. * To delete a rule from a IPv6CT table
  112. *
  113. * Returns: 0 On Success, negative on failure
  114. */
  115. int ipa_ipv6ct_del_rule(uint32_t table_handle, uint32_t rule_handle);
  116. /**
  117. * ipa_ipv6ct_query_timestamp() - to query timestamp
  118. * @table_handle: [in] handle of IPv6CT table
  119. * @rule_handle: [in] IPv6CT rule handle
  120. * @time_stamp: [out] time stamp of rule
  121. *
  122. * To retrieve the timestamp that lastly the IPv6CT rule was accessed
  123. *
  124. * Returns: 0 On Success, negative on failure
  125. */
  126. int ipa_ipv6ct_query_timestamp(uint32_t table_handle, uint32_t rule_handle, uint32_t* time_stamp);
  127. /**
  128. * ipa_ipv6ct_dump_table() - dumps IPv6CT table
  129. * @table_handle: [in] handle of IPv6CT table
  130. */
  131. void ipa_ipv6ct_dump_table(uint32_t tbl_hdl);
  132. /**
  133. * ipa_ipv6ct_add_uc_act_entry() - add uc activation entry
  134. * @u: [in] structure specifying the uC activation entry
  135. *
  136. * Returns: 0 On Success, negative on failure
  137. */
  138. int ipa_ipv6ct_add_uc_act_entry(union ipa_ioc_uc_activation_entry *u);
  139. /**
  140. * ipa_ipv6ct_del_uc_act_entry() - del uc activation entry
  141. * @index: [in] index of the uc activation entry to be removed
  142. *
  143. * Returns: 0 On Success, negative on failure
  144. */
  145. int ipa_ipv6ct_del_uc_act_entry(uint16_t index);
  146. #endif