1 #ifndef DHCPPROBE_H
2 #define DHCPPROBE_H
3 
4 #include "defaults.h"
5 
6 
7 /* options, etc */
8 extern char *prog;
9 extern char *logfile_name;
10 extern char *pid_file;
11 extern int debug;
12 extern int dont_fork;
13 extern char *capture_file;
14 extern int snaplen;
15 extern char *ifname;
16 extern int use_8021q;
17 extern int vlan_id;
18 
19 extern int sockfd; /* general purpose datagram socket fd for temp use throughout */
20 
21 extern struct libnet_ether_addr my_eaddr;
22 
23 
24 
25 /* What flavor of DHCP or BootP packet to send? */
26 /* We construct the packets and insert them into a libnet context queue in the order they appear below.
27    When we ask libnet to walk the queue in order, it seems to return them in reverse order, as if it were a LIFO stack.
28    So we list the flavors below in the reverse of the order we actually wish to send them.
29 */
30 enum dhcp_flavor_t {
31 	DHCP_REBINDING = 0, /* send DHCPREQUEST, client in REBINDING state */
32 	DHCP_INIT_REBOOT,   /* send DHCPREQUEST, client in INIT-REBOOT state */
33 	DHCP_SELECTING,     /* send DHCPREQUEST, client in SELECTING state */
34 	BOOTP,              /* send BOOTPREQUEST */
35 	DHCP_INIT           /* send DHCPDISCOVER */
36 };
37 #define NUM_FLAVORS 5
38 
39 /* A width at least large enough for a string that will contain the string version of the number NUM_FLAVORS */
40 #define NUM_FLAVORS_MAXSTRING (NUM_FLAVORS + 2)
41 
42 /* An array listing all the valid packet flavors */
43 extern enum dhcp_flavor_t packet_flavors[];
44 
45 
46 /* forward decls for functions */
47 void process_response(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char *packet);
48 int receive_and_process_responses(int timeout_secs);
49 void set_pcap_timeout(pcap_t *pc);
50 void reconfigure(const int write_packet_len);
51 void catcher(int signal);
52 void cleanup(void);
53 void my_exit(int exit_status, int do_cleanup, int do_log);
54 void usage(void);
55 void close_and_reopen_capture_file(void);
56 
57 
58 
59 enum { MAX_ETHER_ADDR_STR = 18 };
60 enum { MAX_ETHER_TYPE_STR = 7 };
61 enum { MAX_IP_ADDR_STR = 18 };
62 
63 #define VLAN_ID_MIN 0
64 #define VLAN_ID_MAX 4095
65 #define VLAN_PRIORITY 0x0
66 #define VLAN_CFI_FLAG 0x0
67 
68 
69 #endif /* not DCHPPROBE_H */
70