Exemplo de uso da libiptc
Publicado por Andre Luiz da Silva 04/03/2006
[ Hits: 5.881 ]
Homepage: http://localhost
Exemplo basico de uso da libiptc
/* * print_all_rules.c - 11/03/2005 * A very simple libiptc functions test - by AndRack <andrack@gmail.com> * Compile: $gcc -o print_all_rules print_all_rules.c -liptc */ #include <stdio.h> #include <stdlib.h> #include <iptables.h> #include <libiptc/libiptc.h> #define OUTPUT "/dev/stdout" /*#define OUTPUT "/tmp/fw_rules" */ int main(void) { iptc_handle_t table; const struct ipt_entry *rule; char *tables[] = {"filter", "mangle", "nat"}; char *chain; FILE *fp; int n_table; fp = fopen (OUTPUT, "w"); for (n_table = 0; n_table <= 2; ++n_table) { table = iptc_init (tables[n_table]); fprintf (fp, "Table [ %s ] \n", tables[n_table]); chain = (char *) iptc_first_chain (&table); do { fprintf (fp, "%s \n", chain); rule = iptc_first_rule (chain, &table); while (rule) { fprintf (fp, "Counter Packets: %llu \n", rule->counters.pcnt); fprintf (fp, "Counter Bytes: %llu \n", rule->counters.bcnt); fprintf (fp, "INTFACE: %s \n", (strlen (rule->ip.iniface))? rule->ip.iniface: "any"); fprintf (fp, "OUTFACE: %s \n", (strlen (rule->ip.outiface))? rule->ip.outiface: "any"); rule = iptc_next_rule (rule, &table); } chain = (char *) iptc_next_chain (&table); } while (chain); } fclose (fp); return 0; }
Funções com número variável de argumentos
Função "Partição de Inteiros" Recursiva SEM Tabela Estática em C
Estrutura de dados: Lista dinâmica duplamente encadeada
POGRAMA EM C REGISTRO DE CADASTRO ALTERAR E REMOVER CLIENTES PRODUTOS
Título: aaPanel - Um Painel de Hospedagem Gratuito e Poderoso
O macete do Warsaw no Linux Mint e cia
Aprenda a Gerenciar Permissões de Arquivos no Linux
Como transformar um áudio em vídeo com efeito de forma de onda (wave form)
Visualizar arquivos em formato markdown (ex.: README.md) pelo terminal
Dando - teoricamente - um gás no Gnome-Shell do Arch Linux
Como instalar o Google Cloud CLI no Ubuntu/Debian
Mantenha seu Sistema Leve e Rápido com a Limpeza do APT!
Procurando vídeos de YouTube pelo terminal e assistindo via mpv (2025)
Pastas da raiz foram para a área de trabalho [RESOLVIDO] (9)
Problema ao atualizar archlinux nvidia [RESOLVIDO] (3)