Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Jan 2009 14:51:49 +0000 (UTC)
From:      Paolo Pisati <piso@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r186723 - user/piso/sbin/ipfw
Message-ID:  <200901031451.n03EpnPp030645@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: piso
Date: Sat Jan  3 14:51:49 2009
New Revision: 186723
URL: http://svn.freebsd.org/changeset/base/186723

Log:
  -get rid of #ifdef ALIAS_SCTP
  -style

Modified:
  user/piso/sbin/ipfw/ipfw2.c

Modified: user/piso/sbin/ipfw/ipfw2.c
==============================================================================
--- user/piso/sbin/ipfw/ipfw2.c	Sat Jan  3 14:33:48 2009	(r186722)
+++ user/piso/sbin/ipfw/ipfw2.c	Sat Jan  3 14:51:49 2009	(r186723)
@@ -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>
@@ -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 
@@ -3687,29 +3682,27 @@ setup_redir_port(char *spool_buf, int le
 		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();	
 
@@ -3733,12 +3726,10 @@ setup_redir_port(char *spool_buf, int le
 	}
 
 	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();
 
@@ -3794,33 +3785,31 @@ setup_redir_port(char *spool_buf, int le
 				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;
-			}
-		      } 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*/
+			/*
+			 * 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);
+			}
 			r->spool_cnt++;	
 			/* Point to the next possible cfg_spool. */
 			spool_buf = &spool_buf[SOF_SPOOL];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901031451.n03EpnPp030645>