network_types.h

Go to the documentation of this file.
00001 /************************************* */
00002 /* Rule Set Based Access Control       */
00003 /* Author and (c) 1999-2001:           */
00004 /*   Amon Ott <ao@rsbac.org>           */
00005 /* Network access control data structs */
00006 /* Last modified: 30/Oct/2001          */
00007 /************************************* */
00008 
00009 #ifndef __RSBAC_NETWORK_TYPES_H
00010 #define __RSBAC_NETWORK_TYPES_H
00011 
00012 #define RSBAC_NET_ANY 0
00013 #define RSBAC_NET_UNKNOWN 0
00014 
00015 #define RSBAC_NET_TEMP_VERSION 1
00016 #define RSBAC_NET_TEMP_KEY 0x815affe
00017 #define RSBAC_NET_TEMP_NAME "nettemp"
00018 
00019 typedef __u32 rsbac_net_temp_id_t;
00020 
00021 #define RSBAC_NET_MAX_ADDRESS_LEN 128
00022 #define RSBAC_NET_TEMP_NAMELEN 16
00023 
00024 #define RSBAC_NET_MAX_PORT 65535
00025 
00026 struct rsbac_net_temp_data_t
00027   {
00028     /* must be first for alignment */
00029     char              address[RSBAC_NET_MAX_ADDRESS_LEN];
00030     __u8              address_family;
00031     __u8              valid_len; /* Bytes for AF_UNIX, Bits for all others */
00032     __u8              type;
00033     __u8              protocol;
00034     rsbac_netdev_id_t netdev;
00035     __u16             min_port; /* for those address families that support them */
00036     __u16             max_port;
00037     char              name[RSBAC_NET_TEMP_NAMELEN];
00038   };
00039 
00040 /* default template */
00041 #define RSBAC_NET_TEMP_DEFAULT_DATA \
00042   { \
00043     "",      /* address (not used, because len=0) */ \
00044     AF_MAX,  /* impossible family */ \
00045     0,       /* valid_len (match any) */ \
00046     RSBAC_NET_ANY, /* type (not used) */ \
00047     RSBAC_NET_ANY, /* protocol (not used) */ \
00048     "",      /* netdev (not used) */ \
00049     0,       /* min_port (not used) */ \
00050     0,       /* max_port (not used) */ \
00051     "DEFAULT" /* name */ \
00052   }
00053 
00054 /* template to match all UNIX objects */
00055 #define RSBAC_NET_TEMP_UNIX_ID 100010
00056 #define RSBAC_NET_TEMP_UNIX_DATA \
00057   { \
00058     "",      /* address (not used, because len=0) */ \
00059     AF_UNIX, /* family */ \
00060     0,       /* valid_len (match any) */ \
00061     0,       /* type (not used) */ \
00062     0,       /* protocol (not used) */ \
00063     "",      /* netdev (not used) */ \
00064     0,       /* min_port (not used) */ \
00065     0,       /* max_port (not used) */ \
00066     "AF_UNIX" /* name */ \
00067   }
00068 
00069 /* template to match all INET (IPv4) objects in the localnet */
00070 #define RSBAC_NET_TEMP_LNET_ID 100101
00071 #define RSBAC_NET_TEMP_LNET_ADDRESS "127.0.0.0"
00072 #define RSBAC_NET_TEMP_LNET_DATA \
00073   { \
00074     "",            /* address filled in init code - do not enter dot-notation here! */ \
00075     AF_INET,       /* family */ \
00076     8,             /* valid_len */ \
00077     RSBAC_NET_ANY, /* type */ \
00078     RSBAC_NET_ANY, /* protocol */ \
00079     "",            /* netdev (any) */ \
00080     0,             /* min_port */ \
00081     65535,         /* max_port */ \
00082     "localnet"     /* name */ \
00083   }
00084 
00085 /* template to match all INET (IPv4) objects in the internal LAN */
00086 #define RSBAC_NET_TEMP_LAN_ID 100102
00087 #define RSBAC_NET_TEMP_LAN_ADDRESS "192.168.0.0"
00088 #define RSBAC_NET_TEMP_LAN_DATA \
00089   { \
00090     "",            /* address filled in init code - do not enter dot-notation here! */ \
00091     AF_INET,       /* family */ \
00092     16,            /* valid_len */ \
00093     RSBAC_NET_ANY, /* type */ \
00094     RSBAC_NET_ANY, /* protocol */ \
00095     "",            /* netdev (any) */ \
00096     0,             /* min_port */ \
00097     65535,         /* max_port */ \
00098     "Internal LAN" /* name */ \
00099   }
00100 
00101 /* template to match all INET (IPv4) objects with 0.0.0.0 address */
00102 /* (bind to all addresses / let system select address) */
00103 #define RSBAC_NET_TEMP_AUTO_ID 100105
00104 #define RSBAC_NET_TEMP_AUTO_ADDRESS "0.0.0.0"
00105 #define RSBAC_NET_TEMP_AUTO_DATA \
00106   { \
00107     "",            /* address filled in init code - do not enter dot-notation here! */ \
00108     AF_INET,       /* family */ \
00109     32,            /* valid_len */ \
00110     RSBAC_NET_ANY, /* type */ \
00111     RSBAC_NET_ANY, /* protocol */ \
00112     "",            /* netdev (any) */ \
00113     0,             /* min_port */ \
00114     65535,         /* max_port */ \
00115     "Auto-IPv4"    /* name */ \
00116   }
00117 
00118 /* template to match all INET (IPv4) objects */
00119 #define RSBAC_NET_TEMP_INET_ID 100110
00120 #define RSBAC_NET_TEMP_INET_DATA \
00121   { \
00122     "",            /* address (not used, because len=0) */ \
00123     AF_INET,       /* family */ \
00124     0,             /* valid_len (match any) */ \
00125     RSBAC_NET_ANY, /* type */ \
00126     RSBAC_NET_ANY, /* protocol */ \
00127     "",            /* netdev (any) */ \
00128     0,             /* min_port */ \
00129     65535,         /* max_port */ \
00130     "AF_INET" /* name */ \
00131   }
00132 
00133 /* template to match all objects */
00134 #define RSBAC_NET_TEMP_ALL_ID ((rsbac_net_temp_id_t) -1)
00135 #define RSBAC_NET_TEMP_ALL_DATA \
00136   { \
00137     "",            /* address (not used, no family) */ \
00138     RSBAC_NET_ANY, /* family */ \
00139     0,             /* valid_len (match any) */ \
00140     RSBAC_NET_ANY, /* type */ \
00141     RSBAC_NET_ANY, /* protocol */ \
00142     "",            /* netdev (any) */ \
00143     0,             /* min_port */ \
00144     65535,         /* max_port */ \
00145     "ALL" /* name */ \
00146   }
00147 
00148 struct rsbac_net_description_t
00149   {
00150     __u8              address_family;
00151     void            * address;
00152     __u8              address_len;
00153     __u8              type;
00154     __u8              protocol;
00155     rsbac_netdev_id_t netdev;
00156     __u16             port;
00157   };
00158 
00159 enum rsbac_net_temp_syscall_t
00160   {
00161     NTS_new_template,
00162     NTS_copy_template,
00163     NTS_delete_template,
00164     NTS_check_id,
00165     NTS_get_address,
00166     NTS_get_address_family,
00167     NTS_get_valid_len,
00168     NTS_get_type,
00169     NTS_get_protocol,
00170     NTS_get_netdev,
00171     NTS_get_min_port,
00172     NTS_get_max_port,
00173     NTS_get_name,
00174     NTS_set_address,
00175     NTS_set_address_family,
00176     NTS_set_valid_len,
00177     NTS_set_type,
00178     NTS_set_protocol,
00179     NTS_set_netdev,
00180     NTS_set_min_port,
00181     NTS_set_max_port,
00182     NTS_set_name,
00183     NTS_none
00184   };
00185 
00186 union rsbac_net_temp_syscall_data_t
00187   {
00188     rsbac_net_temp_id_t id;
00189     char                address[RSBAC_NET_MAX_ADDRESS_LEN];
00190     __u8                address_family;
00191     __u8                valid_len; /* Bytes for AF_UNIX, Bits for all others */
00192     __u8                type;
00193     __u8                protocol;
00194     rsbac_netdev_id_t   netdev;
00195     __u16               min_port; /* for those address families that support them */
00196     __u16               max_port;
00197     char                name[RSBAC_NET_TEMP_NAMELEN];
00198   };
00199 
00200 /*
00201  *      Display an IP address in readable format.
00202  */
00203 
00204 #ifndef NIPQUAD
00205 #define NIPQUAD(addr) \
00206         ((unsigned char *)&addr)[0], \
00207         ((unsigned char *)&addr)[1], \
00208         ((unsigned char *)&addr)[2], \
00209         ((unsigned char *)&addr)[3]
00210 
00211 #define HIPQUAD(addr) \
00212         ((unsigned char *)&addr)[3], \
00213         ((unsigned char *)&addr)[2], \
00214         ((unsigned char *)&addr)[1], \
00215         ((unsigned char *)&addr)[0]
00216 #endif
00217 
00218 #endif

Generated on Sun May 21 14:30:49 2006 for RSBAC by  doxygen 1.4.2