From owner-freebsd-ipfw@FreeBSD.ORG Tue Sep 23 12:14:08 2008 Return-Path: Delivered-To: freebsd-ipfw@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BF7B1065673; Tue, 23 Sep 2008 12:14:08 +0000 (UTC) (envelope-from ganbold@micom.mng.net) Received: from publicd.ub.mng.net (publicd.ub.mng.net [202.179.0.88]) by mx1.freebsd.org (Postfix) with ESMTP id C99788FC0A; Tue, 23 Sep 2008 12:14:07 +0000 (UTC) (envelope-from ganbold@micom.mng.net) Received: from [202.179.21.140] (helo=devil.micom.mng.net) by publicd.ub.mng.net with esmtpa (Exim 4.69 (FreeBSD)) (envelope-from ) id 1Ki6mF-000705-Lw; Tue, 23 Sep 2008 20:13:59 +0800 Message-ID: <48D8DD86.7000903@micom.mng.net> Date: Tue, 23 Sep 2008 20:13:58 +0800 From: Ganbold User-Agent: Thunderbird 2.0.0.16 (X11/20080901) MIME-Version: 1.0 To: Roman Kurakin References: <48D8A814.7030607@micom.mng.net> <48D8B8F0.8020900@localhost.inse.ru> In-Reply-To: <48D8B8F0.8020900@localhost.inse.ru> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Roman Kurakin , freebsd-ipfw@freebsd.org, rizzo@iet.unipi.it, julian@elischer.org Subject: Re: question related to /sbin/ipfw/ipfw2.c X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Sep 2008 12:14:08 -0000 Roman Kurakin wrote: > Ganbold wrote: >> Hi, >> >> What does following part of src/sbin/ipfw/ipfw2.c code? >> ... >> static void >> fill_ip(ipfw_insn_ip *cmd, char *av) >> { >> int len = 0; >> uint32_t *d = ((ipfw_insn_u32 *)cmd)->d; >> >> cmd->o.len &= ~F_LEN_MASK; /* zero len */ >> ----------------------------------- >> if (strncmp(av, "table(", 6) == 0) { > match the beginning of the "table(entry,value)" >> char *p = strchr(av + 6, ','); > find the ',' if any >> >> if (p) >> *p++ = '\0'; > and replace it with '\0' eq "table(entry\0value)" so as a string it is > now "table(entry" > and make p point to 'value', eq p = 'value' now >> cmd->o.opcode = O_IP_DST_LOOKUP; >> cmd->o.arg1 = strtoul(av + 6, NULL, 0); > av+6 is the "entry" string > arg1=(unsigned long)entry >> >> if (p) { > if we have a 'value ' part >> cmd->o.len |= F_INSN_SIZE(ipfw_insn_u32); >> d[0] = strtoul(p, NULL, 0); > d[0] = (unsigned long)value Ok, now how do we know or choose the index of d[]? Basically I would like to store some value in d[]. How can I do that? thanks, Ganbold >> } else >> cmd->o.len |= F_INSN_SIZE(ipfw_insn); >> return; >> } > Is that what you need? > > rik >> ----------------------------------- >> >> Specially, what does following code? >> ... >> 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); >> d[0] = strtoul(p, NULL, 0); >> } else >> cmd->o.len |= F_INSN_SIZE(ipfw_insn); >> ... >> >> thanks, >> >> Ganbold >> > > _______________________________________________ > freebsd-ipfw@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-ipfw > To unsubscribe, send any mail to "freebsd-ipfw-unsubscribe@freebsd.org" > > > -- A little inaccuracy saves a world of explanation. -- C. E. Ayres