/* Code style: -*- linux-c -*- */ /* File : xfw/find/range.h */ /* needfulls */ #include #include #include #include #include #include #include #include /* description of ethernet packets */ #include #include #include #include #include "Tree.h" /* definitions used to find out the network characteristics */ #define MAXROUTER 5 typedef unsigned int address; /* addresses held in coded form (2^n8) ie AABBCCDD */ /* lego kit time, I need a building brick like this .--------. |Details |- (active?) -> Other router outwards back to top level start <-----|of node |- (active?) -> | |- (active?) -> `--------' */ /* this struct is purely to help in producing the nice debugging pictures in */ /* the project write up */ struct hosts { char other_hosts[255]; /* 256 bytes containing encoded info on other hosts */ }; struct node { address ip; /* holds the routers ip address in coded form */ address netmask; /* holds the netmask for this node */ address broadcast; /* holds the bradcast address for this node */ char *last_updated; /* when the whole net cell was last looked at (update?) */ Widget w; /* wonderfully descriptive pointer to X11 tree widget */ struct hosts local_cell; /* 256 bytes containing info on other hosts */ /* in the same local network cell (max 255) */ /* eg hosts[0]=0xFF means the host is active */ /* problem, I need multiple occurances of this as a list */ struct node *face; /* this points back at the last level router */ struct node *out[MAXROUTER]; /* pointer to next router out in the list */ }; struct net_attrib { address ip; /* host ip */ address netmask; /* netmask of host's network */ address broadcast; /* broadcast of the host's netnork */ }; struct range { address start; /* starting ip of the local network */ address finish; /* ending ip of the local network */ }; /* humm,.. well the fifo list we wish to use is a linked list something like this <-----[ IP ]-----> */ struct ip_chain { address ip; /* ip we caught */ char *next; /* next in list */ char *prev; /* just in case we need it */ }; /* Typedefs */ /* These are defines for the byte number of class's in an ip held as a 4 byte int */ #define SN_RCV_BUF_SIZE 128 /* above was 1600, but kernel discards*/ /* excess and tells us full length, */ /* so we only need enough to analyze. */ #define TIME_DELAY 2 #define CLASS_A 1 #define CLASS_B 2 #define CLASS_C 3 #define CLASS_D 4 /* prototypes used */ extern int encode_ip (const char *); extern int dig_out_ip (const unsigned char *); extern unsigned char decode (int, int); extern struct range * calc (unsigned int, unsigned int, unsigned int); extern void translate (char *, int); extern char * ip_to_str (int encoded_ip); extern struct range * describe_net (struct net_attrib *); extern void dummy_test (Widget, struct node *); extern struct node * add_new_node_to_current (Widget, Widget, struct node *, struct node *); extern char * curr_time (void); extern char * dummy_create_hosts (struct node *); extern void dump_tree (Widget, struct node *, Widget); extern struct node * if_setup (void); extern void alarm_catcher (int); extern void dump_packet_addr (unsigned char *, int, struct sockaddr *); extern void grab_ips_from_net (void); /* Nasty horrible globals */ volatile int rang; .