All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rick Jones <rick.jones2@hp.com>
To: Jesper Dangaard Brouer <hawk@diku.dk>
Cc: Netfilter Developers <netfilter-devel@vger.kernel.org>
Subject: Re: [Fwd: Re: Shortcuts to counting rules?]
Date: Wed, 05 Nov 2008 13:02:22 -0800	[thread overview]
Message-ID: <491209DE.3060300@hp.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0811052133050.9289@ask.diku.dk>

Jesper Dangaard Brouer wrote:
> 
>>>  On Friday 2008-10-31 19:54, Rick Jones wrote:
>>> > >  Here is where I cop to being a luddite who prefers straight C to 
>>> calling
>>> >  system() :)
> 
> 
> Using libiptc, here is the C-program you need:
> 
> --- cut here ---
> #include <stdio.h>
> #include <libiptc/libiptc.h>
> 
> main(int argc, char *argv[])
> {
>     char *table = "filter";
>     const char             *chain;
>     const struct ipt_entry *rule;
>     iptc_handle_t handle = NULL;
>     unsigned int num_chains = 0;
>     unsigned int num_rules  = 0;
> 
>     handle = iptc_init(table);
>     //dump_entries(handle);
> 
>     chain = iptc_first_chain(&handle);
>     while (chain) {
>         //printf("Chain:%s\n", chain);
>         num_chains++;
> 
>         rule = iptc_first_rule(chain, &handle);
>         while (rule) {
>             num_rules++;
>             rule = iptc_next_rule(rule, &handle);
>         }
>         //printf("Rules so far:%u\n", num_rules);
> 
>         chain = iptc_next_chain(&handle);
>     }
> 
>     printf("Number of chains:%u\n", num_chains);
>     printf("Number of rules:%u\n", num_rules);
> }
> --- cut here ---
> 

Thanks - indeed I have code very much like that already in my initial 
prototype.  Biggest difference is I check every table listed under 
/proc/net/mumble :)  I'm still trying to decipher what the parsing code 
in libiptc is doing so see how much work it would be for me to create 
braindead rule counting code.

I could I suppose just drop back and not worry about counting rules per 
se, but just arriving at a rules vs no rules decision somehow.

rick jones

  reply	other threads:[~2008-11-05 21:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-31 17:57 [Fwd: Re: Shortcuts to counting rules?] Rick Jones
2008-10-31 18:07 ` Jan Engelhardt
2008-10-31 18:54   ` Rick Jones
2008-11-01  1:10     ` Jan Engelhardt
2008-11-03 18:02       ` Rick Jones
2008-11-05 18:25       ` Jesper Dangaard Brouer
2008-11-05 18:55         ` Rick Jones
2008-11-05 20:36         ` Jesper Dangaard Brouer
2008-11-05 21:02           ` Rick Jones [this message]
2008-11-07  3:06         ` Jan Engelhardt
2008-11-08 10:28           ` Jesper Dangaard Brouer
2008-11-04  0:41   ` Philip Craig
2008-11-04  1:22     ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=491209DE.3060300@hp.com \
    --to=rick.jones2@hp.com \
    --cc=hawk@diku.dk \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.