cacheroute.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /****************************************************************************
  2. * net/route/cacheroute.h
  3. *
  4. * Copyright (C) 2017 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ****************************************************************************/
  35. #ifndef __NET_ROUTE_CACHEROUTE_H
  36. #define __NET_ROUTE_CACHEROUTE_H
  37. /****************************************************************************
  38. * Included Files
  39. ****************************************************************************/
  40. #include <nuttx/config.h>
  41. #include "route/route.h"
  42. #if defined(CONFIG_ROUTE_IPv4_CACHEROUTE) || defined(CONFIG_ROUTE_IPv6_CACHEROUTE)
  43. /****************************************************************************
  44. * Public Function Prototypes
  45. ****************************************************************************/
  46. /****************************************************************************
  47. * Name: net_init_cacheroute
  48. *
  49. * Description:
  50. * Initialize the in-memory, routing table cache
  51. *
  52. * Input Parameters:
  53. * None
  54. *
  55. * Returned Value:
  56. * None
  57. *
  58. * Assumptions:
  59. * Called early in initialization so that no special protection is needed.
  60. *
  61. ****************************************************************************/
  62. void net_init_cacheroute(void);
  63. /****************************************************************************
  64. * Name: net_addcache_ipv4 and net_addcache_ipv6
  65. *
  66. * Description:
  67. * Add one route to the routing table cache
  68. *
  69. * Input Parameters:
  70. * None
  71. *
  72. * Returned Value:
  73. * Zero (OK) is returned on success; a negated errno value is returned
  74. * on any failure.
  75. *
  76. ****************************************************************************/
  77. #ifdef CONFIG_ROUTE_IPv4_CACHEROUTE
  78. int net_addcache_ipv4(FAR struct net_route_ipv4_s *route);
  79. #endif
  80. #ifdef CONFIG_ROUTE_IPv6_CACHEROUTE
  81. int net_addcache_ipv6(FAR struct net_route_ipv6_s *route);
  82. #endif
  83. /****************************************************************************
  84. * Name: net_foreachcache_ipv4/net_foreachcache_ipv6
  85. *
  86. * Description:
  87. * Traverse the routing table cache
  88. *
  89. * Input Parameters:
  90. * handler - Will be called for each route in the routing table cache.
  91. * arg - An arbitrary value that will be passed tot he handler.
  92. *
  93. * Returned Value:
  94. * Zero (OK) returned if the entire table was searched. A negated errno
  95. * value will be returned in the event of a failure. Handlers may also
  96. * terminate the search early with any non-zero value.
  97. *
  98. ****************************************************************************/
  99. #ifdef CONFIG_ROUTE_IPv4_CACHEROUTE
  100. int net_foreachcache_ipv4(route_handler_ipv4_t handler, FAR void *arg);
  101. #endif
  102. #ifdef CONFIG_ROUTE_IPv6_CACHEROUTE
  103. int net_foreachcache_ipv6(route_handler_ipv6_t handler, FAR void *arg);
  104. #endif
  105. /****************************************************************************
  106. * Name: net_flushcache_ipv4 and net_flushcache_ipv6
  107. *
  108. * Description:
  109. * Flush the content of the routing table cache
  110. *
  111. * Input Parameters:
  112. * None
  113. *
  114. * Returned Value:
  115. * None
  116. *
  117. ****************************************************************************/
  118. #ifdef CONFIG_ROUTE_IPv4_CACHEROUTE
  119. void net_flushcache_ipv4(void);
  120. #endif
  121. #ifdef CONFIG_ROUTE_IPv6_CACHEROUTE
  122. void net_flushcache_ipv6(void);
  123. #endif
  124. #endif /* CONFIG_ROUTE_IPv4_CACHEROUTE || CONFIG_ROUTE_IPv6_CACHEROUTE */
  125. #endif /* __NET_ROUTE_CACHEROUTE_H */