ipv4_nat.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. * NAT - NAT implementation for lwIP supporting TCP/UDP and ICMP.
  3. * Copyright (c) 2009 Christian Walter, ?Embedded Solutions, Vienna 2009.
  4. *
  5. * Copyright (c) 2010 lwIP project ;-)
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without modification,
  9. * are permitted provided that the following conditions are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright notice,
  12. * this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright notice,
  14. * this list of conditions and the following disclaimer in the documentation
  15. * and/or other materials provided with the distribution.
  16. * 3. The name of the author may not be used to endorse or promote products
  17. * derived from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  20. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  22. * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  24. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  27. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  28. * OF SUCH DAMAGE.
  29. *
  30. * This file is part of the lwIP TCP/IP stack.
  31. */
  32. /*
  33. * File : ipv4_nat.h
  34. * This file is part of RT-Thread RTOS
  35. * COPYRIGHT (C) 2015, RT-Thread Development Team
  36. *
  37. * This program is free software; you can redistribute it and/or modify
  38. * it under the terms of the GNU General Public License as published by
  39. * the Free Software Foundation; either version 2 of the License, or
  40. * (at your option) any later version.
  41. *
  42. * This program is distributed in the hope that it will be useful,
  43. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  44. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  45. * GNU General Public License for more details.
  46. *
  47. * You should have received a copy of the GNU General Public License along
  48. * with this program; if not, write to the Free Software Foundation, Inc.,
  49. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  50. *
  51. * Change Logs:
  52. * Date Author Notes
  53. * 2015-01-26 Hichard porting to RT-Thread
  54. * 2015-01-27 Bernard code cleanup for lwIP in RT-Thread
  55. */
  56. #ifndef __LWIP_NAT_H__
  57. #define __LWIP_NAT_H__
  58. #include <rtthread.h>
  59. #ifdef LWIP_USING_NAT
  60. #include "lwip/err.h"
  61. #include "lwip/ip_addr.h"
  62. #include "lwip/opt.h"
  63. /** Timer interval at which to call ip_nat_tmr() */
  64. #define LWIP_NAT_TMR_INTERVAL_SEC (30)
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif /* __cplusplus */
  68. struct netif;
  69. struct pbuf;
  70. typedef struct ip_nat_entry
  71. {
  72. ip_addr_t source_net;
  73. ip_addr_t source_netmask;
  74. ip_addr_t dest_net;
  75. ip_addr_t dest_netmask;
  76. struct netif *out_if;
  77. struct netif *in_if;
  78. } ip_nat_entry_t;
  79. void ip_nat_init(void);
  80. void ip_nat_tmr(void);
  81. u8_t ip_nat_input(struct pbuf *p);
  82. u8_t ip_nat_out(struct pbuf *p);
  83. err_t ip_nat_add(const ip_nat_entry_t *new_entry);
  84. void ip_nat_remove(const ip_nat_entry_t *remove_entry);
  85. #ifdef __cplusplus
  86. }
  87. #endif /* __cplusplus */
  88. #endif /* IP_NAT */
  89. #endif /* __LWIP_NAT_H__ */