ipfw2.h revision 187767
1187767Sluigi/* 2187767Sluigi * Copyright (c) 2002-2003 Luigi Rizzo 3187767Sluigi * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp 4187767Sluigi * Copyright (c) 1994 Ugen J.S.Antsilevich 5187767Sluigi * 6187767Sluigi * Idea and grammar partially left from: 7187767Sluigi * Copyright (c) 1993 Daniel Boulet 8187767Sluigi * 9187767Sluigi * Redistribution and use in source forms, with and without modification, 10187767Sluigi * are permitted provided that this entire comment appears intact. 11187767Sluigi * 12187767Sluigi * Redistribution in binary form may occur without any restrictions. 13187767Sluigi * Obviously, it would be nice if you gave credit where credit is due 14187767Sluigi * but requiring it would be too onerous. 15187767Sluigi * 16187767Sluigi * This software is provided ``AS IS'' without any warranties of any kind. 17187767Sluigi * 18187767Sluigi * NEW command line interface for IP firewall facility 19187767Sluigi * 20187767Sluigi * $FreeBSD: head/sbin/ipfw/ipfw2.h 187767 2009-01-27 10:18:55Z luigi $ 21187767Sluigi */ 22187767Sluigi 23187767Sluigi/* 24187767Sluigi * Options that can be set on the command line. 25187767Sluigi * When reading commands from a file, a subset of the options can also 26187767Sluigi * be applied globally by specifying them before the file name. 27187767Sluigi * After that, each line can contain its own option that changes 28187767Sluigi * the global value. 29187767Sluigi * XXX The context is not restored after each line. 30187767Sluigi */ 31187767Sluigi 32187767Sluigistruct cmdline_opts { 33187767Sluigi /* boolean options: */ 34187767Sluigi int do_value_as_ip; /* show table value as IP */ 35187767Sluigi int do_resolv; /* try to resolve all ip to names */ 36187767Sluigi int do_time; /* Show time stamps */ 37187767Sluigi int do_quiet; /* Be quiet in add and flush */ 38187767Sluigi int do_pipe; /* this cmd refers to a pipe */ 39187767Sluigi int do_nat; /* this cmd refers to a nat config */ 40187767Sluigi int do_dynamic; /* display dynamic rules */ 41187767Sluigi int do_expired; /* display expired dynamic rules */ 42187767Sluigi int do_compact; /* show rules in compact mode */ 43187767Sluigi int do_force; /* do not ask for confirmation */ 44187767Sluigi int show_sets; /* display the set each rule belongs to */ 45187767Sluigi int test_only; /* only check syntax */ 46187767Sluigi int comment_only; /* only print action and comment */ 47187767Sluigi int verbose; /* be verbose on some commands */ 48187767Sluigi 49187767Sluigi /* The options below can have multiple values. */ 50187767Sluigi 51187767Sluigi int do_sort; /* field to sort results (0 = no) */ 52187767Sluigi /* valid fields are 1 and above */ 53187767Sluigi 54187767Sluigi int use_set; /* work with specified set number */ 55187767Sluigi /* 0 means all sets, otherwise apply to set use_set - 1 */ 56187767Sluigi 57187767Sluigi}; 58187767Sluigi 59187767Sluigiextern struct cmdline_opts co; 60187767Sluigi 61187767Sluigi/* 62187767Sluigi * _s_x is a structure that stores a string <-> token pairs, used in 63187767Sluigi * various places in the parser. Entries are stored in arrays, 64187767Sluigi * with an entry with s=NULL as terminator. 65187767Sluigi * The search routines are match_token() and match_value(). 66187767Sluigi * Often, an element with x=0 contains an error string. 67187767Sluigi * 68187767Sluigi */ 69187767Sluigistruct _s_x { 70187767Sluigi char const *s; 71187767Sluigi int x; 72187767Sluigi}; 73187767Sluigi 74187767Sluigi/* 75187767Sluigi * the following macro returns an error message if we run out of 76187767Sluigi * arguments. 77187767Sluigi */ 78187767Sluigi#define NEED1(msg) {if (!ac) errx(EX_USAGE, msg);} 79187767Sluigi 80187767Sluigi/* memory allocation support */ 81187767Sluigivoid *safe_calloc(size_t number, size_t size); 82187767Sluigivoid *safe_realloc(void *ptr, size_t size); 83187767Sluigi 84187767Sluigi/* a string comparison function used for historical compatibility */ 85187767Sluigiint _substrcmp(const char *str1, const char* str2); 86187767Sluigi 87187767Sluigi/* 88187767Sluigi * The reserved set numer. This is a constant in ip_fw.h 89187767Sluigi * but we store it in a variable so other files do not depend 90187767Sluigi * in that header just for one constant. 91187767Sluigi */ 92187767Sluigiextern int resvd_set_number; 93187767Sluigi 94187767Sluigivoid ipfw_add(int ac, char *av[]); 95187767Sluigivoid ipfw_show_nat(int ac, char **av); 96187767Sluigivoid ipfw_config_pipe(int ac, char **av); 97187767Sluigivoid ipfw_config_nat(int ac, char **av); 98187767Sluigivoid ipfw_sets_handler(int ac, char *av[]); 99187767Sluigivoid ipfw_table_handler(int ac, char *av[]); 100187767Sluigivoid ipfw_sysctl_handler(int ac, char *av[], int which); 101187767Sluigivoid ipfw_delete(int ac, char *av[]); 102187767Sluigivoid ipfw_flush(int force); 103187767Sluigivoid ipfw_zero(int ac, char *av[], int optname); 104187767Sluigivoid ipfw_list(int ac, char *av[], int show_counters); 105187767Sluigi 106