Go to the documentation of this file.
57 msg(msglevel,
"*** CNAT list");
60 for (i = 0; i <
list->n; ++i)
63 msg(msglevel,
" CNAT[%d] t=%d %s/%s/%s",
96 for (i = 0; i < src->
n; ++i)
110 const char *foreign_network,
116 if (!strcmp(
type,
"snat"))
120 else if (!strcmp(
type,
"dnat"))
126 msg(msglevel,
"client-nat: type must be 'snat' or 'dnat'");
133 msg(msglevel,
"client-nat: bad network: %s",
network);
139 msg(msglevel,
"client-nat: bad netmask: %s",
netmask);
154 print_checksum(
struct openvpn_iphdr *iph,
const char *prefix)
157 unsigned int sum = 0;
159 for (sptr = (uint16_t *)iph; (uint8_t *)sptr < (uint8_t *)iph +
sizeof(
struct openvpn_iphdr); sptr++)
164 msg(
M_INFO,
"** CKSUM[%d] %s %08x", i, prefix, sum);
173 char *dirstr =
"???";
183 msg(msglevel,
"** CNAT %s %s %s -> %s",
199 uint32_t addr, *addr_ptr;
200 const uint32_t *from, *to;
203 unsigned int alog = 0;
210 for (i = 0; i < list->
n; ++i)
213 if (e->
type ^ direction)
215 addr = *(addr_ptr = &h->
ip.
daddr);
220 addr = *(addr_ptr = &h->
ip.
saddr);
234 if (((addr & e->
netmask) == *from) && !(amask & alog))
240 addr = (addr & ~e->
netmask) | *to;
struct gc_entry * list
First element of the linked list of gc_entry structures.
#define OPENVPN_IPPROTO_TCP
static struct gc_arena gc_new(void)
#define SUB_CHECKSUM_32(acc, u32)
#define OPENVPN_IPPROTO_UDP
#define ADD_CHECKSUM_32(acc, u32)
struct client_nat_option_list * clone_client_nat_option_list(const struct client_nat_option_list *src, struct gc_arena *gc)
void print_client_nat_list(const struct client_nat_option_list *list, int msglevel)
struct openvpn_udphdr udp
struct client_nat_entry entries[MAX_CLIENT_NAT]
#define ADJUST_CHECKSUM(acc, cksum)
in_addr_t getaddr(unsigned int flags, const char *hostname, int resolve_retry_seconds, bool *succeeded, struct signal_info *sig_info)
Translate an IPv4 addr or hostname from string form to in_addr_t.
#define ALLOC_OBJ_CLEAR_GC(dptr, type, gc)
void copy_client_nat_option_list(struct client_nat_option_list *dest, const struct client_nat_option_list *src)
Wrapper structure for dynamically allocated memory.
in_addr_t foreign_network
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)
struct openvpn_tcphdr tcp
Garbage collection arena used to keep track of dynamically allocated memory.
void add_client_nat_to_option_list(struct client_nat_option_list *dest, const char *type, const char *network, const char *netmask, const char *foreign_network, int msglevel)
struct client_nat_option_list * new_client_nat_list(struct gc_arena *gc)
void client_nat_transform(const struct client_nat_option_list *list, struct buffer *ipbuf, const int direction)
static bool check_debug_level(unsigned int level)
union ip_tcp_udp_hdr::@12 u
static void gc_free(struct gc_arena *a)
static void print_pkt(struct openvpn_iphdr *iph, const char *prefix, const int direction, const int msglevel)
static bool add_entry(struct client_nat_option_list *dest, const struct client_nat_entry *e)
#define ALLOC_OBJ_GC(dptr, type, gc)