#include #include #include #include #include #include #include #define LNSIZE 80 /* max length of an input line */ #define MAXRULES 100 /* max number of lines per rule */ #define BUFSIZE 4096 /* usually means the max length of a whole rule */ /* structure contains default.W */ typedef struct rulenum { char *src[MAXRULES]; /* contains src hostname */ char *dst[MAXRULES]; /* contains dest hostname */ char *svc[MAXRULES]; /* contains service value */ char action[LNSIZE]; /* action to take */ char install[LNSIZE]; /* host to install on */ char time[LNSIZE]; /* time rule is in effect */ int rulecount; /* index to rule number */ struct rulenum *src_link, *dst_link, *svc_link, *action_link, *install_link, *time_link, *count_link; } rulenum; /* create instance for rules */ rulenum *head,*prev,*present,*next,*tail; /* create links and allocate memory for default.W structure */ void initrules(); /* print default.W structure */ void dumpsource(char *netname, int verbose, int srcdst); void dumprules(int verbose, int srcdst); /* routine to parse default.W and split into tokens */ void find_rules(char *rulesC); /* locates all entries in a particular rule of each type */ void get_source(FILE *fp, char *source[], int rule); void get_dest(FILE *fp, char *dest[], int rule); void get_service(FILE *fp, char *service[], int rule); void get_time(FILE *fp, char time[]); void get_install(FILE *fp, char install[]); void get_action(FILE *fp, char action[]); /* insert action, install, and time into linked list */ void insert_three(char *time, char *install, char *action, int rulecount); /* insert source field into linked list */ void update_source(char *src, int rulecount, int indexnum); /* insert destination field into linked list */ void update_dest(char *dest, int rulecount, int indexnum); /* insert service field into linked list */ void update_service(char *service, int rulecount, int indexnum); /* routines for turning rules into specific types of objects */ int resolv_src(char *rule_src); /* main gateways routine used to find gateways specified with -g option */ void find_gateways(char *objectsC, char *gateway); /* searches the 'install' section of the rule looking for gateway */ int process_install(char object[], char gateway[]); /* get a line of text from any sized string */ char *get_line(int *i, char *buf);