route.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /****************************************************************************
  2. * include/net/route.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_NET_ROUTE_H
  21. #define __INCLUDE_NET_ROUTE_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. #include <sys/socket.h>
  27. #include <nuttx/net/ioctl.h>
  28. /****************************************************************************
  29. * Pre-processor Definitions
  30. ****************************************************************************/
  31. /****************************************************************************
  32. * Public Types
  33. ****************************************************************************/
  34. /* This structure describes the route information passed with the SIOCADDRT
  35. * and SIOCDELRT ioctl commands (see include/nuttx/net/ioctl.h).
  36. */
  37. struct rtentry
  38. {
  39. struct sockaddr_storage rt_dst; /* Address of the network */
  40. struct sockaddr_storage rt_gateway; /* Gateway address associated with
  41. * the hop */
  42. struct sockaddr_storage rt_genmask; /* Network mask defining the sub-net */
  43. uint16_t rt_flags;
  44. };
  45. /****************************************************************************
  46. * Public Data
  47. ****************************************************************************/
  48. #ifdef __cplusplus
  49. #define EXTERN extern "C"
  50. extern "C"
  51. {
  52. #else
  53. #define EXTERN extern
  54. #endif
  55. /****************************************************************************
  56. * Public Function Prototypes
  57. ****************************************************************************/
  58. /****************************************************************************
  59. * Name: net_addroute
  60. *
  61. * Description:
  62. * Add a new route to the routing table. This is just a convenience
  63. * wrapper for the SIOCADDRT ioctl call.
  64. *
  65. * Input Parameters:
  66. * sockfd - Any socket descriptor
  67. * target - Target address on external network(required)
  68. * netmask - Network mask defining the external network (required)
  69. * router - Router address that on our network that can forward to the
  70. * external network.
  71. *
  72. * Returned Value:
  73. * OK on success; -1 on failure with the errno variable set appropriately.
  74. *
  75. ****************************************************************************/
  76. int addroute(int sockfd, FAR struct sockaddr_storage *target,
  77. FAR struct sockaddr_storage *netmask,
  78. FAR struct sockaddr_storage *router);
  79. /****************************************************************************
  80. * Name: net_delroute
  81. *
  82. * Description:
  83. * Delete a route from the routing table. This is just a convenience
  84. * wrapper for the SIOCDELRT ioctl call.
  85. *
  86. * Input Parameters:
  87. * sockfd - Any socket descriptor
  88. * target - Target address on the remote network (required)
  89. * netmask - Network mask defining the external network (required)
  90. *
  91. * Returned Value:
  92. * OK on success; -1 on failure with the errno variable set appropriately.
  93. *
  94. ****************************************************************************/
  95. int delroute(int sockfd, FAR struct sockaddr_storage *target,
  96. FAR struct sockaddr_storage *netmask);
  97. #undef EXTERN
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* __INCLUDE_NET_ROUTE_H */