quering byte counts for user defined chains/rules using libiptc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



dear all,

my prog, which uses libiptc, queries byte counts for a single rule in an user defined chain (ipXXX.XXX.XXX.XXX)

here comes a sample code:
...
                h = iptc_init(tablenamefilter);
                if (!h) slog(LOG_ERR, "Can't initialize: %s\n",iptc_strerror(errno));
        
                now = time(NULL);
        
                for (chain = iptc_first_chain(&h); chain; chain = iptc_next_chain(&h))//ITERATE CHAINS
                {
                        ip = chain+2;//2==strlen(chainprefix);
                        if(strncmp(chain,chainprefix,2)!=0) continue;
                        
                        struct ipt_counters *count = NULL;
                        count = iptc_read_counter(chain, 1, &h);
                        if(count == NULL) slog(LOG_ERR,"iptc_read_counter(%s, 1, &h); returns NULL",chain);
                        else
                        {
                                bytecnt = count->bcnt;
                                slog(LOG_INFO,"iptc_read_counter(%s, 1, &h); returns %u",chain,bytecnt);
                        }
......
the problem is that it always returns 0.
with iptables -L -v i get real counts

the version of iptables is 1.2.8 (stable)

if yoe have any suggestions please reply to my email,
because i am not a list member

thanks in advance

jaroslaw


Jaroslaw Zdrzalek             | e-mail zdrzalek@xxxxxxxxxx
Leiter Anwendungsentwicklung  | web    www.silpion.de
Silpion IT-Solutions GmbH     | tel    +49 (40) 54 00 71 20
Pinnasberg 29-33              | fax   +49 (40) 54 00 71 19
20359 Hamburg                 | mobil  +49 (170) 87 82 96 9



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux