xref: /nrf52832-nimble/rt-thread/components/net/lwip_nat/ipv4_nat.h (revision 104654410c56c573564690304ae786df310c91fc)
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 
36 #ifndef __LWIP_NAT_H__
37 #define __LWIP_NAT_H__
38 
39 #include <rtthread.h>
40 
41 #ifdef LWIP_USING_NAT
42 
43 #include "lwip/err.h"
44 #include "lwip/ip_addr.h"
45 #include "lwip/opt.h"
46 
47 /** Timer interval at which to call ip_nat_tmr() */
48 #define LWIP_NAT_TMR_INTERVAL_SEC        (30)
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif /* __cplusplus */
53 
54 struct netif;
55 struct pbuf;
56 
57 typedef struct ip_nat_entry
58 {
59   ip_addr_t    source_net;
60   ip_addr_t    source_netmask;
61   ip_addr_t    dest_net;
62   ip_addr_t    dest_netmask;
63   struct netif *out_if;
64   struct netif *in_if;
65 } ip_nat_entry_t;
66 
67 void  ip_nat_init(void);
68 void  ip_nat_tmr(void);
69 u8_t  ip_nat_input(struct pbuf *p);
70 u8_t  ip_nat_out(struct pbuf *p);
71 
72 err_t ip_nat_add(const ip_nat_entry_t *new_entry);
73 void  ip_nat_remove(const ip_nat_entry_t *remove_entry);
74 
75 #ifdef __cplusplus
76 }
77 #endif /* __cplusplus */
78 
79 #endif /* IP_NAT */
80 
81 #endif /* __LWIP_NAT_H__ */
82