Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

fw.h

Go to the documentation of this file.
00001 /*
00002  * fw.h
00003  *
00004  * Network firewalling operations.
00005  *
00006  * Copyright (c) 2001 Dug Song <dugsong@monkey.org>
00007  *
00008  * $Id: fw.h,v 1.13 2002/12/14 04:02:36 dugsong Exp $
00009  */
00010 
00011 #ifndef DNET_FW_H
00012 #define DNET_FW_H
00013 
00014 struct fw_rule {
00015         char            fw_device[INTF_NAME_LEN]; /* interface name */
00016         uint8_t         fw_op;                    /* operation */
00017         uint8_t         fw_dir;                   /* direction */
00018         uint8_t         fw_proto;                 /* IP protocol */
00019         struct addr     fw_src;                   /* src address / net */
00020         struct addr     fw_dst;                   /* dst address / net */
00021         uint16_t        fw_sport[2];              /* range / ICMP type */
00022         uint16_t        fw_dport[2];              /* range / ICMP code */
00023 };
00024 
00025 #define FW_OP_ALLOW     1
00026 #define FW_OP_BLOCK     2
00027 
00028 #define FW_DIR_IN       1
00029 #define FW_DIR_OUT      2
00030 
00031 #define fw_pack_rule(rule, dev, op, dir, p, s, d, sp1, sp2, dp1, dp2)   \
00032 do {                                                                    \
00033         strlcpy((rule)->fw_device, dev, sizeof((rule)->fw_device));     \
00034         (rule)->fw_op = op; (rule)->fw_dir = dir;                       \
00035         (rule)->fw_proto = p;                                           \
00036         memmove(&(rule)->fw_src, &(s), sizeof((rule)->fw_src));         \
00037         memmove(&(rule)->fw_dst, &(d), sizeof((rule)->fw_dst));         \
00038         (rule)->fw_sport[0] = sp1; (rule)->fw_sport[1] = sp2;           \
00039         (rule)->fw_dport[0] = dp1; (rule)->fw_dport[1] = dp2;           \
00040 } while (0)
00041 
00042 typedef struct fw_handle fw_t;
00043 
00044 typedef int (*fw_handler)(const struct fw_rule *rule, void *arg);
00045 
00046 __BEGIN_DECLS
00047 fw_t    *fw_open(void);
00048 int      fw_add(fw_t *f, const struct fw_rule *rule);
00049 int      fw_delete(fw_t *f, const struct fw_rule *rule);
00050 int      fw_loop(fw_t *f, fw_handler callback, void *arg);
00051 fw_t    *fw_close(fw_t *f);
00052 __END_DECLS
00053 
00054 #endif /* DNET_FW_H */

Generated on Sun May 14 14:51:10 2006 by  doxygen 1.4.2