Deleted Added
full compact
nat.c (238900) nat.c (240351)
1/*
2 * Copyright (c) 2002-2003 Luigi Rizzo
3 * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
4 * Copyright (c) 1994 Ugen J.S.Antsilevich
5 *
6 * Idea and grammar partially left from:
7 * Copyright (c) 1993 Daniel Boulet
8 *
9 * Redistribution and use in source forms, with and without modification,
10 * are permitted provided that this entire comment appears intact.
11 *
12 * Redistribution in binary form may occur without any restrictions.
13 * Obviously, it would be nice if you gave credit where credit is due
14 * but requiring it would be too onerous.
15 *
16 * This software is provided ``AS IS'' without any warranties of any kind.
17 *
18 * NEW command line interface for IP firewall facility
19 *
1/*
2 * Copyright (c) 2002-2003 Luigi Rizzo
3 * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
4 * Copyright (c) 1994 Ugen J.S.Antsilevich
5 *
6 * Idea and grammar partially left from:
7 * Copyright (c) 1993 Daniel Boulet
8 *
9 * Redistribution and use in source forms, with and without modification,
10 * are permitted provided that this entire comment appears intact.
11 *
12 * Redistribution in binary form may occur without any restrictions.
13 * Obviously, it would be nice if you gave credit where credit is due
14 * but requiring it would be too onerous.
15 *
16 * This software is provided ``AS IS'' without any warranties of any kind.
17 *
18 * NEW command line interface for IP firewall facility
19 *
20 * $FreeBSD: head/sbin/ipfw/nat.c 238900 2012-07-30 10:55:23Z luigi $
20 * $FreeBSD: head/sbin/ipfw/nat.c 240351 2012-09-11 07:54:41Z kevlo $
21 *
22 * In-kernel nat support
23 */
24
25#include <sys/types.h>
26#include <sys/socket.h>
27#include <sys/sysctl.h>
28

--- 387 unchanged lines hidden (view full) ---

416 */
417 r->proto = StrToProto(**av);
418 protoName = **av;
419 (*av)++; (*ac)--;
420
421 /*
422 * Extract local address.
423 */
21 *
22 * In-kernel nat support
23 */
24
25#include <sys/types.h>
26#include <sys/socket.h>
27#include <sys/sysctl.h>
28

--- 387 unchanged lines hidden (view full) ---

416 */
417 r->proto = StrToProto(**av);
418 protoName = **av;
419 (*av)++; (*ac)--;
420
421 /*
422 * Extract local address.
423 */
424 if ((sep = strchr(**av, ',')) != NULL) {
424 if (strchr(**av, ',') != NULL) {
425 r->laddr.s_addr = INADDR_NONE;
426 r->lport = ~0;
427 numLocalPorts = 1;
428 lsnat = **av;
429 } else {
430 /*
431 * The sctp nat does not allow the port numbers to be mapped to
432 * new port numbers. Therefore, no ports are to be specified

--- 16 unchanged lines hidden (view full) ---

449 numLocalPorts = GETNUMPORTS(portRange);
450 }
451 }
452 (*av)++; (*ac)--;
453
454 /*
455 * Extract public port and optionally address.
456 */
425 r->laddr.s_addr = INADDR_NONE;
426 r->lport = ~0;
427 numLocalPorts = 1;
428 lsnat = **av;
429 } else {
430 /*
431 * The sctp nat does not allow the port numbers to be mapped to
432 * new port numbers. Therefore, no ports are to be specified

--- 16 unchanged lines hidden (view full) ---

449 numLocalPorts = GETNUMPORTS(portRange);
450 }
451 }
452 (*av)++; (*ac)--;
453
454 /*
455 * Extract public port and optionally address.
456 */
457 if ((sep = strchr(**av, ':')) != NULL) {
457 if (strchr(**av, ':') != NULL) {
458 if (StrToAddrAndPortRange(**av, &r->paddr, protoName,
459 &portRange) != 0)
460 errx(EX_DATAERR, "redirect_port: "
461 "invalid public port range");
462 } else {
463 r->paddr.s_addr = INADDR_ANY;
464 if (StrToPortRange(**av, protoName, &portRange) != 0)
465 errx(EX_DATAERR, "redirect_port: "

--- 11 unchanged lines hidden (view full) ---

477 /*
478 * Extract remote address and optionally port.
479 */
480 /*
481 * NB: isdigit(**av) => we've to check that next parameter is really an
482 * option for this redirect entry, else stop here processing arg[cv].
483 */
484 if (*ac != 0 && isdigit(***av)) {
458 if (StrToAddrAndPortRange(**av, &r->paddr, protoName,
459 &portRange) != 0)
460 errx(EX_DATAERR, "redirect_port: "
461 "invalid public port range");
462 } else {
463 r->paddr.s_addr = INADDR_ANY;
464 if (StrToPortRange(**av, protoName, &portRange) != 0)
465 errx(EX_DATAERR, "redirect_port: "

--- 11 unchanged lines hidden (view full) ---

477 /*
478 * Extract remote address and optionally port.
479 */
480 /*
481 * NB: isdigit(**av) => we've to check that next parameter is really an
482 * option for this redirect entry, else stop here processing arg[cv].
483 */
484 if (*ac != 0 && isdigit(***av)) {
485 if ((sep = strchr(**av, ':')) != NULL) {
485 if (strchr(**av, ':') != NULL) {
486 if (StrToAddrAndPortRange(**av, &r->raddr, protoName,
487 &portRange) != 0)
488 errx(EX_DATAERR, "redirect_port: "
489 "invalid remote port range");
490 } else {
491 SETLOPORT(portRange, 0);
492 SETNUMPORTS(portRange, 1);
493 StrToAddr(**av, &r->raddr);

--- 497 unchanged lines hidden ---
486 if (StrToAddrAndPortRange(**av, &r->raddr, protoName,
487 &portRange) != 0)
488 errx(EX_DATAERR, "redirect_port: "
489 "invalid remote port range");
490 } else {
491 SETLOPORT(portRange, 0);
492 SETNUMPORTS(portRange, 1);
493 StrToAddr(**av, &r->raddr);

--- 497 unchanged lines hidden ---