ipv4_nat.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * NAT - NAT implementation for lwIP supporting TCP/UDP and ICMP.
  3. * Copyright (c) 2009 Christian Walter, ?Embedded Solutions, Vienna 2009.
  4. * Copyright (c) 2010 lwIP project ;-)
  5. * COPYRIGHT (C) 2015, RT-Thread Development Team
  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. * Change Logs:
  31. * Date Author Notes
  32. * 2015-01-26 Hichard porting to RT-Thread
  33. * 2015-01-27 Bernard code cleanup for lwIP in RT-Thread
  34. */
  35. #ifndef __LWIP_NAT_H__
  36. #define __LWIP_NAT_H__
  37. #include <rtthread.h>
  38. #ifdef LWIP_USING_NAT
  39. #include "lwip/err.h"
  40. #include "lwip/ip_addr.h"
  41. #include "lwip/opt.h"
  42. /** Timer interval at which to call ip_nat_tmr() */
  43. #define LWIP_NAT_TMR_INTERVAL_SEC (30)
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif /* __cplusplus */
  47. struct netif;
  48. struct pbuf;
  49. typedef struct ip_nat_entry
  50. {
  51. ip_addr_t source_net;
  52. ip_addr_t source_netmask;
  53. ip_addr_t dest_net;
  54. ip_addr_t dest_netmask;
  55. struct netif *out_if;
  56. struct netif *in_if;
  57. } ip_nat_entry_t;
  58. void ip_nat_init(void);
  59. void ip_nat_tmr(void);
  60. u8_t ip_nat_input(struct pbuf *p);
  61. u8_t ip_nat_out(struct pbuf *p);
  62. err_t ip_nat_add(const ip_nat_entry_t *new_entry);
  63. void ip_nat_remove(const ip_nat_entry_t *remove_entry);
  64. #ifdef __cplusplus
  65. }
  66. #endif /* __cplusplus */
  67. #endif /* IP_NAT */
  68. #endif /* __LWIP_NAT_H__ */