libipt_DNAT.c revision 3fb61f3d4a194ba989fe8470f16064f20e59e3bc
1e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Shared library add-on to iptables to add destination-NAT support. */ 2e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <stdio.h> 3e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <netdb.h> 4e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <string.h> 5e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <stdlib.h> 6e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <getopt.h> 7e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <iptables.h> 8e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <linux/netfilter_ipv4/ip_tables.h> 9e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <linux/netfilter_ipv4/ip_nat_rule.h> 10e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 11e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Dest NAT data consists of a multi-range, indicating where to map 12e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher to. */ 13e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstruct ipt_natinfo 14e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 15e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct ipt_entry_target t; 16e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct ip_nat_multi_range mr; 17e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher}; 18e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 19e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Function which prints out usage message. */ 20e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic void 21e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherhelp(void) 22e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 23e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf( 24e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher"DNAT v%s options:\n" 25e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher" --to-destination <ipaddr>[-<ipaddr>][:port-port]\n" 26e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher" Address to map destination to.\n" 27e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher" (You can use this more than once)\n\n", 2880fe35d6339b53a12ddaec41885613e4e37ed031Harald WelteIPTABLES_VERSION); 29e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 30e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 31e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic struct option opts[] = { 32e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher { "to-destination", 1, 0, '1' }, 33e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher { 0 } 34e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher}; 35e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 36e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Initialize the target. */ 37e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic void 38e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherinit(struct ipt_entry_target *t, unsigned int *nfcache) 39e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 40e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher /* Can't cache this */ 41e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher *nfcache |= NFC_UNKNOWN; 42e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 43e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 44e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic struct ipt_natinfo * 45e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherappend_range(struct ipt_natinfo *info, const struct ip_nat_range *range) 46e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 47e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher unsigned int size; 48e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 49e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher /* One rangesize already in struct ipt_natinfo */ 50e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher size = IPT_ALIGN(sizeof(*info) + info->mr.rangesize * sizeof(*range)); 51e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 52e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher info = realloc(info, size); 53e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (!info) 54e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(OTHER_PROBLEM, "Out of memory\n"); 55e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 56228e98dd6303af11925235af4cf3c3ec450f3f41Rusty Russell info->t.u.target_size = size; 57e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher info->mr.range[info->mr.rangesize] = *range; 58e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher info->mr.rangesize++; 59e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 60e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher return info; 61e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 62e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 63e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Ranges expected in network order. */ 64e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic struct ipt_entry_target * 65e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherparse_to(char *arg, int portok, struct ipt_natinfo *info) 66e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 67e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct ip_nat_range range; 683fb61f3d4a194ba989fe8470f16064f20e59e3bcPhil Oester char *colon, *dash, *error; 69e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct in_addr *ip; 70e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 71e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher memset(&range, 0, sizeof(range)); 72e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher colon = strchr(arg, ':'); 73e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 74e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (colon) { 75e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher int port; 76e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 77e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (!portok) 78e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(PARAMETER_PROBLEM, 79e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher "Need TCP or UDP with port specification"); 80e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 81e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher range.flags |= IP_NAT_RANGE_PROTO_SPECIFIED; 82e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 83e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher port = atoi(colon+1); 84e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (port == 0 || port > 65535) 85e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(PARAMETER_PROBLEM, 86e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher "Port `%s' not valid\n", colon+1); 87e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 883fb61f3d4a194ba989fe8470f16064f20e59e3bcPhil Oester error = strchr(colon+1, ':'); 893fb61f3d4a194ba989fe8470f16064f20e59e3bcPhil Oester if (error) 903fb61f3d4a194ba989fe8470f16064f20e59e3bcPhil Oester exit_error(PARAMETER_PROBLEM, 913fb61f3d4a194ba989fe8470f16064f20e59e3bcPhil Oester "Invalid port:port syntax - use dash\n"); 923fb61f3d4a194ba989fe8470f16064f20e59e3bcPhil Oester 93e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher dash = strchr(colon, '-'); 94e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (!dash) { 95e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher range.min.tcp.port 96e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher = range.max.tcp.port 97e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher = htons(port); 98e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } else { 99e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher int maxport; 100e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 101e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher maxport = atoi(dash + 1); 102e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (maxport == 0 || maxport > 65535) 103e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(PARAMETER_PROBLEM, 104e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher "Port `%s' not valid\n", dash+1); 105e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (maxport < port) 106e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher /* People are stupid. */ 107e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(PARAMETER_PROBLEM, 108e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher "Port range `%s' funky\n", colon+1); 109e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher range.min.tcp.port = htons(port); 110e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher range.max.tcp.port = htons(maxport); 111e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } 112e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher /* Starts with a colon? No IP info...*/ 113e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (colon == arg) 114e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher return &(append_range(info, &range)->t); 115e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher *colon = '\0'; 116e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } 117e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 118e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher range.flags |= IP_NAT_RANGE_MAP_IPS; 119e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher dash = strchr(arg, '-'); 120e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (colon && dash && dash > colon) 121e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher dash = NULL; 122e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 123e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (dash) 124e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher *dash = '\0'; 125e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 126e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher ip = dotted_to_addr(arg); 127e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (!ip) 128e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(PARAMETER_PROBLEM, "Bad IP address `%s'\n", 129e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher arg); 130e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher range.min_ip = ip->s_addr; 131e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (dash) { 132e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher ip = dotted_to_addr(dash+1); 133e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (!ip) 134e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(PARAMETER_PROBLEM, "Bad IP address `%s'\n", 135e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher dash+1); 136e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher range.max_ip = ip->s_addr; 137e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } else 138e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher range.max_ip = range.min_ip; 139e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 140e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher return &(append_range(info, &range)->t); 141e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 142e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 143e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Function which parses command options; returns true if it 144e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher ate an option */ 145e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic int 146e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherparse(int c, char **argv, int invert, unsigned int *flags, 147e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher const struct ipt_entry *entry, 148e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct ipt_entry_target **target) 149e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 150e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct ipt_natinfo *info = (void *)*target; 151e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher int portok; 152e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 153e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (entry->ip.proto == IPPROTO_TCP 154e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher || entry->ip.proto == IPPROTO_UDP) 155e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher portok = 1; 156e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher else 157e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher portok = 0; 158e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 159e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher switch (c) { 160e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher case '1': 161b77f1dafb9f35752bb9685323bcacb32a0e6ddc5Harald Welte if (check_inverse(optarg, &invert, NULL, 0)) 162e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(PARAMETER_PROBLEM, 163e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher "Unexpected `!' after --to-destination"); 164e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 165e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher *target = parse_to(optarg, portok, info); 166e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher *flags = 1; 167e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher return 1; 168e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 169e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher default: 170e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher return 0; 171e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } 172e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 173e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 174e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Final check; must have specfied --to-source. */ 175e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic void final_check(unsigned int flags) 176e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 177e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (!flags) 178e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher exit_error(PARAMETER_PROBLEM, 179e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher "You must specify --to-destination"); 180e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 181e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 182e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic void print_range(const struct ip_nat_range *r) 183e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 184e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (r->flags & IP_NAT_RANGE_MAP_IPS) { 185e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct in_addr a; 186e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 187e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher a.s_addr = r->min_ip; 188e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf("%s", addr_to_dotted(&a)); 189e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (r->max_ip != r->min_ip) { 190e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher a.s_addr = r->max_ip; 191e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf("-%s", addr_to_dotted(&a)); 192e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } 193e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } 194e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (r->flags & IP_NAT_RANGE_PROTO_SPECIFIED) { 195e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf(":"); 196e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf("%hu", ntohs(r->min.tcp.port)); 197e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher if (r->max.tcp.port != r->min.tcp.port) 198e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf("-%hu", ntohs(r->max.tcp.port)); 199e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } 200e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 201e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 202e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Prints out the targinfo. */ 203e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic void 204e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherprint(const struct ipt_ip *ip, 205e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher const struct ipt_entry_target *target, 206e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher int numeric) 207e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 208e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct ipt_natinfo *info = (void *)target; 209e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher unsigned int i = 0; 210e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 211e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf("to:"); 212e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher for (i = 0; i < info->mr.rangesize; i++) { 213e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher print_range(&info->mr.range[i]); 214e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf(" "); 215e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } 216e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 217e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 218e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* Saves the union ipt_targinfo in parsable form to stdout. */ 219e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstatic void 220e6869a8f59d779ff4d5a0984c86d80db7078496Marc Bouchersave(const struct ipt_ip *ip, const struct ipt_entry_target *target) 221e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 222e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct ipt_natinfo *info = (void *)target; 223e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher unsigned int i = 0; 224e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 225e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher for (i = 0; i < info->mr.rangesize; i++) { 226e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf("--to-destination "); 227e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher print_range(&info->mr.range[i]); 228e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher printf(" "); 229e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher } 230e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 231e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 2328caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neirastatic struct iptables_target dnat = { 2338caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .next = NULL, 2348caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .name = "DNAT", 2358caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .version = IPTABLES_VERSION, 2368caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .size = IPT_ALIGN(sizeof(struct ip_nat_multi_range)), 2378caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .userspacesize = IPT_ALIGN(sizeof(struct ip_nat_multi_range)), 2388caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .help = &help, 2398caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .init = &init, 2408caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .parse = &parse, 2418caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .final_check = &final_check, 2428caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .print = &print, 2438caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .save = &save, 2448caee8b9e34fed4562fcff553197c161fc9d9979Pablo Neira .extra_opts = opts 245e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher}; 246e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 247e6869a8f59d779ff4d5a0984c86d80db7078496Marc Bouchervoid _init(void) 248e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 249e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher register_target(&dnat); 250e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher} 251