Go to the documentation of this file.
26 #elif defined(_MSC_VER)
59 msg(msglevel,
"*** CNAT list");
62 for (i = 0; i <
list->n; ++i)
65 msg(msglevel,
" CNAT[%d] t=%d %s/%s/%s",
98 for (i = 0; i < src->
n; ++i)
112 const char *foreign_network,
118 if (!strcmp(
type,
"snat"))
122 else if (!strcmp(
type,
"dnat"))
128 msg(msglevel,
"client-nat: type must be 'snat' or 'dnat'");
135 msg(msglevel,
"client-nat: bad network: %s",
network);
141 msg(msglevel,
"client-nat: bad netmask: %s",
netmask);
156 print_checksum(
struct openvpn_iphdr *iph,
const char *prefix)
159 unsigned int sum = 0;
161 for (sptr = (uint16_t *)iph; (uint8_t *)sptr < (uint8_t *)iph +
sizeof(
struct openvpn_iphdr); sptr++)
166 msg(
M_INFO,
"** CKSUM[%d] %s %08x", i, prefix, sum);
175 char *dirstr =
"???";
185 msg(msglevel,
"** CNAT %s %s %s -> %s",
201 uint32_t addr, *addr_ptr;
202 const uint32_t *from, *to;
205 unsigned int alog = 0;
212 for (i = 0; i < list->
n; ++i)
215 if (e->
type ^ direction)
217 addr = *(addr_ptr = &h->
ip.
daddr);
222 addr = *(addr_ptr = &h->
ip.
saddr);
236 if (((addr & e->
netmask) == *from) && !(amask & alog))
242 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)