From patchwork Wed Jun 26 11:37:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arturo Borrero X-Patchwork-Id: 254708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 740932C0092 for ; Wed, 26 Jun 2013 21:37:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752088Ab3FZLhP (ORCPT ); Wed, 26 Jun 2013 07:37:15 -0400 Received: from smtp3.cica.es ([150.214.5.190]:54667 "EHLO smtp.cica.es" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752018Ab3FZLhL (ORCPT ); Wed, 26 Jun 2013 07:37:11 -0400 Received: from localhost (unknown [127.0.0.1]) by smtp.cica.es (Postfix) with ESMTP id 91FB651ED34; Wed, 26 Jun 2013 11:37:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at cica.es Received: from smtp.cica.es ([127.0.0.1]) by localhost (mail.cica.es [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Io-uE7cWuh4v; Wed, 26 Jun 2013 13:37:05 +0200 (CEST) Received: from nfdev.cica.es (nfdev.cica.es [IPv6:2a00:9ac0:c1ca:31::220]) by smtp.cica.es (Postfix) with ESMTP id 7679051ED25; Wed, 26 Jun 2013 13:37:05 +0200 (CEST) Subject: [libnftables PATCH 06/21] nat: xml: change nat types string to dnat/snat To: netfilter-devel@vger.kernel.org From: Arturo Borrero Gonzalez Cc: pablo@netfilter.org Date: Wed, 26 Jun 2013 13:37:03 +0200 Message-ID: <20130626113703.23511.73236.stgit@nfdev.cica.es> In-Reply-To: <20130626113509.23511.14359.stgit@nfdev.cica.es> References: <20130626113509.23511.14359.stgit@nfdev.cica.es> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org This patch replaces the string NFT_NAT_{S|D}NAT with {s|d}nat in the node. Signed-off-by: Arturo Borrero Gonzalez --- src/expr/nat.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/src/expr/nat.c b/src/expr/nat.c index 501f20c..f38011a 100644 --- a/src/expr/nat.c +++ b/src/expr/nat.c @@ -236,9 +236,9 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, char *xml) return -1; } - if (strcmp(node->child->value.opaque, "NFT_NAT_SNAT") == 0) { + if (strcmp(node->child->value.opaque, "snat") == 0) { nat->type = NFT_NAT_SNAT; - } else if (strcmp(node->child->value.opaque, "NFT_NAT_DNAT") == 0) { + } else if (strcmp(node->child->value.opaque, "dnat") == 0) { nat->type = NFT_NAT_DNAT; } else { mxmlDelete(tree); @@ -332,18 +332,15 @@ nft_rule_expr_nat_snprintf_xml(char *buf, size_t size, struct nft_expr_nat *nat = (struct nft_expr_nat *)e->data; int len = size, offset = 0, ret = 0; - switch (nat->type) { - case NFT_NAT_SNAT: - ret = snprintf(buf, len, - "NFT_NAT_SNAT"); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - break; - case NFT_NAT_DNAT: - ret = snprintf(buf, len, - "NFT_NAT_DNAT"); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - break; - } + /* Is a mandatory element. Provide a default, even empty */ + if (nat->type == NFT_NAT_SNAT) + ret = snprintf(buf, len, "snat"); + else if (nat->type == NFT_NAT_DNAT) + ret = snprintf(buf, len, "dnat"); + else + ret = snprintf(buf, len, ""); + + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = snprintf(buf+offset, len, "%s", nft_family2str(nat->family));