~ubuntu-branches/ubuntu/precise/iptables/precise-proposed

« back to all changes in this revision

Viewing changes to extensions/libipt_DNAT.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-07-14 15:59:54 UTC
  • mfrom: (5.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090714155954-9039kro8cnh6lb1q
Tags: 1.4.4-1ubuntu1
* Merge from debian unstable, remaining changes: LP: #399211
  - Don't fail to run iptables-save if iptables module isn't loaded.
  - debian/patches/0901-build-libipq_pic.a.patch - Build libipq_pic.a with
    -fPIC. Upstream changed build system and patch modified accordingly.
  - Revert changes between 1.4.1.1-3 and 1.4.1.1-4, thus bringing back
    the howtos.
  - Added linuxdoc-tools to Build-Depends
  - Modified debian/iptables{,-dev}.install to match DM syntax
    (removed debian/tmp)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
"DNAT target options:\n"
28
28
" --to-destination <ipaddr>[-<ipaddr>][:port-port]\n"
29
29
"                               Address to map destination to.\n"
30
 
"[--random]\n");
 
30
"[--random] [--persistent]\n");
31
31
}
32
32
 
33
33
static const struct option DNAT_opts[] = {
34
34
        { "to-destination", 1, NULL, '1' },
35
35
        { "random", 0, NULL, '2' },
 
36
        { "persistent", 0, NULL, '3' },
36
37
        { .name = NULL }
37
38
};
38
39
 
178
179
                } else
179
180
                        *flags |= IPT_DNAT_OPT_RANDOM;
180
181
                return 1;
 
182
 
 
183
        case '3':
 
184
                info->mr.range[0].flags |= IP_NAT_RANGE_PERSISTENT;
 
185
                return 1;
 
186
 
181
187
        default:
182
188
                return 0;
183
189
        }
213
219
static void DNAT_print(const void *ip, const struct xt_entry_target *target,
214
220
                       int numeric)
215
221
{
216
 
        struct ipt_natinfo *info = (void *)target;
 
222
        const struct ipt_natinfo *info = (const void *)target;
217
223
        unsigned int i = 0;
218
224
 
219
225
        printf("to:");
222
228
                printf(" ");
223
229
                if (info->mr.range[i].flags & IP_NAT_RANGE_PROTO_RANDOM)
224
230
                        printf("random ");
 
231
                if (info->mr.range[i].flags & IP_NAT_RANGE_PERSISTENT)
 
232
                        printf("persistent ");
225
233
        }
226
234
}
227
235
 
228
236
static void DNAT_save(const void *ip, const struct xt_entry_target *target)
229
237
{
230
 
        struct ipt_natinfo *info = (void *)target;
 
238
        const struct ipt_natinfo *info = (const void *)target;
231
239
        unsigned int i = 0;
232
240
 
233
241
        for (i = 0; i < info->mr.rangesize; i++) {
236
244
                printf(" ");
237
245
                if (info->mr.range[i].flags & IP_NAT_RANGE_PROTO_RANDOM)
238
246
                        printf("--random ");
 
247
                if (info->mr.range[i].flags & IP_NAT_RANGE_PERSISTENT)
 
248
                        printf("--persistent ");
239
249
        }
240
250
}
241
251