Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
-get rid of #ifdef ALIAS_SCTP
-style
  • Loading branch information
piso authored and piso committed Jan 3, 2009
1 parent 8af3d78 commit c677556
Showing 1 changed file with 46 additions and 57 deletions.
103 changes: 46 additions & 57 deletions sbin/ipfw/ipfw2.c
Expand Up @@ -48,7 +48,6 @@
#include <fcntl.h>

#define IPFW_INTERNAL /* Access to protected structures in ip_fw.h. */
#define _ALIAS_SCTP /*Using alias_sctp*/

#include <net/ethernet.h>
#include <net/if.h>
Expand Down Expand Up @@ -3505,13 +3504,9 @@ StrToProto (const char* str)
if (!strcmp (str, "udp"))
return IPPROTO_UDP;

#ifdef _ALIAS_SCTP /*Using alias_sctp*/
if (!strcmp (str, "sctp"))
return IPPROTO_SCTP;
errx (EX_DATAERR, "unknown protocol %s. Expected sctp, tcp or udp", str);
#else
errx (EX_DATAERR, "unknown protocol %s. Expected tcp or udp", str);
#endif
}

static int
Expand Down Expand Up @@ -3687,29 +3682,27 @@ setup_redir_port(char *spool_buf, int len,
strncpy(tmp_spool_buf, *av, strlen(*av)+1);
lsnat = 1;
} else {
#ifdef _ALIAS_SCTP /*Using alias_sctp*/
/*
* The sctp nat does not allow the port numbers to be mapped to new port numbers
* Therefore, no ports are to be specified in the target port field
*/
if (r->proto == IPPROTO_SCTP) {
if (strchr (*av, ':'))
errx(EX_DATAERR, "redirect_port:"
"port numbers do not change in sctp, so do not specify them as part of the target");
else
StrToAddr(*av, &r->laddr);
} else {
#endif /*Using alias_sctp*/
if (StrToAddrAndPortRange (*av, &r->laddr, protoName,
&portRange) != 0)
errx(EX_DATAERR, "redirect_port:"
"invalid local port range");
/*
* The sctp nat does not allow the port numbers to be mapped to
* new port numbers. Therefore, no ports are to be specified
* in the target port field.
*/
if (r->proto == IPPROTO_SCTP) {
if (strchr (*av, ':'))
errx(EX_DATAERR, "redirect_port:"
"port numbers do not change in sctp, so do not "
"specify them as part of the target");
else
StrToAddr(*av, &r->laddr);
} else {
if (StrToAddrAndPortRange (*av, &r->laddr, protoName,
&portRange) != 0)
errx(EX_DATAERR, "redirect_port:"
"invalid local port range");

r->lport = GETLOPORT(portRange);
numLocalPorts = GETNUMPORTS(portRange);
#ifdef _ALIAS_SCTP /*Using alias_sctp*/
}
#endif /*Using alias_sctp*/
r->lport = GETLOPORT(portRange);
numLocalPorts = GETNUMPORTS(portRange);
}
}
INC_ARGCV();

Expand All @@ -3733,12 +3726,10 @@ setup_redir_port(char *spool_buf, int len,
}

r->pport = GETLOPORT(portRange);
#ifdef _ALIAS_SCTP /*Using alias_sctp*/
if (r->proto == IPPROTO_SCTP) { /* so the logic below still works */
numLocalPorts = GETNUMPORTS(portRange);
r->lport = r->pport;
numLocalPorts = GETNUMPORTS(portRange);
r->lport = r->pport;
}
#endif /*Using alias_sctp*/
r->pport_cnt = GETNUMPORTS(portRange);
INC_ARGCV();

Expand Down Expand Up @@ -3794,33 +3785,31 @@ setup_redir_port(char *spool_buf, int len,
goto nospace;
len -= SOF_SPOOL;
space += SOF_SPOOL;

#ifdef _ALIAS_SCTP /*Using alias_sctp*/
/*
* The sctp nat does not allow the port numbers to be mapped to new port numbers
* Therefore, no ports are to be specified in the target port field
*/
if (r->proto == IPPROTO_SCTP) {
if (strchr (sep, ':')) {
errx(EX_DATAERR, "redirect_port:"
"port numbers do not change in sctp, so do not specify them as part of the target");
} else {
StrToAddr(sep, &tmp->addr);
tmp->port = r->pport;
/*
* The sctp nat does not allow the port numbers to be mapped to new port numbers
* Therefore, no ports are to be specified in the target port field
*/
if (r->proto == IPPROTO_SCTP) {
if (strchr (sep, ':')) {
errx(EX_DATAERR, "redirect_port:"
"port numbers do not change in "
"sctp, so do not specify them as "
"part of the target");
} else {
StrToAddr(sep, &tmp->addr);
tmp->port = r->pport;
}
} else {
if (StrToAddrAndPortRange(sep, &tmp->addr,
protoName, &portRange) != 0)
errx(EX_DATAERR, "redirect_port:"
"invalid local port range");
if (GETNUMPORTS(portRange) != 1)
errx(EX_DATAERR, "redirect_port: "
"local port must be single in "
"this context");
tmp->port = GETLOPORT(portRange);
}
} else {
#endif /*Using alias_sctp*/
if (StrToAddrAndPortRange(sep, &tmp->addr, protoName,
&portRange) != 0)
errx(EX_DATAERR, "redirect_port:"
"invalid local port range");
if (GETNUMPORTS(portRange) != 1)
errx(EX_DATAERR, "redirect_port: local port"
"must be single in this context");
tmp->port = GETLOPORT(portRange);
#ifdef _ALIAS_SCTP /*Using alias_sctp*/
}
#endif /*Using alias_sctp*/
r->spool_cnt++;
/* Point to the next possible cfg_spool. */
spool_buf = &spool_buf[SOF_SPOOL];
Expand Down

0 comments on commit c677556

Please sign in to comment.