From owner-svn-src-stable@FreeBSD.ORG  Mon Oct 22 12:39:57 2012
Return-Path: <owner-svn-src-stable@FreeBSD.ORG>
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
 by hub.freebsd.org (Postfix) with ESMTP id B551CF68;
 Mon, 22 Oct 2012 12:39:57 +0000 (UTC)
 (envelope-from melifaro@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
 by mx1.freebsd.org (Postfix) with ESMTP id 804318FC08;
 Mon, 22 Oct 2012 12:39:57 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
 by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9MCdvHe011772;
 Mon, 22 Oct 2012 12:39:57 GMT
 (envelope-from melifaro@svn.freebsd.org)
Received: (from melifaro@localhost)
 by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9MCdvkE011770;
 Mon, 22 Oct 2012 12:39:57 GMT
 (envelope-from melifaro@svn.freebsd.org)
Message-Id: <201210221239.q9MCdvkE011770@svn.freebsd.org>
From: "Alexander V. Chernikov" <melifaro@FreeBSD.org>
Date: Mon, 22 Oct 2012 12:39:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r241883 - stable/9/sbin/ipfw
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
 <svn-src-stable.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/svn-src-stable>,
 <mailto:svn-src-stable-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-stable>
List-Post: <mailto:svn-src-stable@freebsd.org>
List-Help: <mailto:svn-src-stable-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-stable>,
 <mailto:svn-src-stable-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 22 Oct 2012 12:39:58 -0000

Author: melifaro
Date: Mon Oct 22 12:39:57 2012
New Revision: 241883
URL: http://svn.freebsd.org/changeset/base/241883

Log:
  Merge r240892,r240893
  
  Permit table to be used as IPv6 address.
  Whitespace fixes
  
  Reported by:	Serhiy Popov <sergiuspso@ukr.net>

Modified:
  stable/9/sbin/ipfw/ipv6.c
Directory Properties:
  stable/9/sbin/   (props changed)
  stable/9/sbin/ipfw/   (props changed)

Modified: stable/9/sbin/ipfw/ipv6.c
==============================================================================
--- stable/9/sbin/ipfw/ipv6.c	Mon Oct 22 12:22:56 2012	(r241882)
+++ stable/9/sbin/ipfw/ipv6.c	Mon Oct 22 12:39:57 2012	(r241883)
@@ -336,24 +336,40 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av)
 	 * Note d[1] points to struct in6_add r mask6 of cmd
 	 */
 
-       cmd->o.len &= ~F_LEN_MASK;	/* zero len */
+	cmd->o.len &= ~F_LEN_MASK;	/* zero len */
 
-       if (strcmp(av, "any") == 0)
-	       return (1);
+	if (strcmp(av, "any") == 0)
+		return (1);
 
 
-       if (strcmp(av, "me") == 0) {	/* Set the data for "me" opt*/
-	       cmd->o.len |= F_INSN_SIZE(ipfw_insn);
-	       return (1);
-       }
+	if (strcmp(av, "me") == 0) {	/* Set the data for "me" opt*/
+		cmd->o.len |= F_INSN_SIZE(ipfw_insn);
+		return (1);
+	}
+
+	if (strcmp(av, "me6") == 0) {	/* Set the data for "me" opt*/
+		cmd->o.len |= F_INSN_SIZE(ipfw_insn);
+		return (1);
+	}
 
-       if (strcmp(av, "me6") == 0) {	/* Set the data for "me" opt*/
-	       cmd->o.len |= F_INSN_SIZE(ipfw_insn);
-	       return (1);
-       }
+	if (strncmp(av, "table(", 6) == 0) {
+		char *p = strchr(av + 6, ',');
+		uint32_t *dm = ((ipfw_insn_u32 *)cmd)->d;
+
+		if (p)
+			*p++ = '\0';
+		cmd->o.opcode = O_IP_DST_LOOKUP;
+		cmd->o.arg1 = strtoul(av + 6, NULL, 0);
+		if (p) {
+			cmd->o.len |= F_INSN_SIZE(ipfw_insn_u32);
+			dm[0] = strtoul(p, NULL, 0);
+		} else
+			cmd->o.len |= F_INSN_SIZE(ipfw_insn);
+		return (1);
+	}
 
-       av = strdup(av);
-       while (av) {
+	av = strdup(av);
+	while (av) {
 		/*
 		 * After the address we can have '/' indicating a mask,
 		 * or ',' indicating another address follows.
@@ -469,7 +485,11 @@ add_srcip6(ipfw_insn *cmd, char *av)
 {
 
 	fill_ip6((ipfw_insn_ip6 *)cmd, av);
-	if (F_LEN(cmd) == 0) {				/* any */
+	if (cmd->opcode == O_IP_DST_SET)			/* set */
+		cmd->opcode = O_IP_SRC_SET;
+	else if (cmd->opcode == O_IP_DST_LOOKUP)		/* table */
+		cmd->opcode = O_IP_SRC_LOOKUP;
+	else if (F_LEN(cmd) == 0) {				/* any */
 	} else if (F_LEN(cmd) == F_INSN_SIZE(ipfw_insn)) {	/* "me" */
 		cmd->opcode = O_IP6_SRC_ME;
 	} else if (F_LEN(cmd) ==
@@ -487,7 +507,11 @@ add_dstip6(ipfw_insn *cmd, char *av)
 {
 
 	fill_ip6((ipfw_insn_ip6 *)cmd, av);
-	if (F_LEN(cmd) == 0) {				/* any */
+	if (cmd->opcode == O_IP_DST_SET)			/* set */
+		;
+	else if (cmd->opcode == O_IP_DST_LOOKUP)		/* table */
+		;
+	else if (F_LEN(cmd) == 0) {				/* any */
 	} else if (F_LEN(cmd) == F_INSN_SIZE(ipfw_insn)) {	/* "me" */
 		cmd->opcode = O_IP6_DST_ME;
 	} else if (F_LEN(cmd) ==