diff options
| author | Roy Marples <roy@marples.name> | 2008-09-02 13:28:11 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-09-02 13:28:11 +0000 |
| commit | fd05b7dcfc61e1a8f1d4f0f7ecd27bb25a6cc7a8 (patch) | |
| tree | eefcda1304078e7ee7e7508103cb6e1775ff5513 /dhcpcd.h | |
| parent | ca07508a27a3048ead0c0a411f2cecc84ac97935 (diff) | |
| download | dhcpcd-fd05b7dcfc61e1a8f1d4f0f7ecd27bb25a6cc7a8.tar.xz | |
Add an event loop.
Split client.c into smaller files and functions and
recode around the event loop.
Add multiple interface support using the new event loop.
Document changes and outstanding bugs.
Diffstat (limited to 'dhcpcd.h')
| -rw-r--r-- | dhcpcd.h | 140 |
1 files changed, 82 insertions, 58 deletions
@@ -28,68 +28,92 @@ #ifndef DHCPCD_H #define DHCPCD_H -#include <sys/param.h> -#include <sys/socket.h> - #include <net/if.h> -#include <netinet/in.h> #include <limits.h> -#include "common.h" - -#define DEFAULT_TIMEOUT 30 -#define DEFAULT_LEASETIME 3600 /* 1 hour */ - -#define HOSTNAME_MAX_LEN 250 /* 255 - 3 (FQDN) - 2 (DNS enc) */ -#define VENDORCLASSID_MAX_LEN 48 -#define CLIENTID_MAX_LEN 48 -#define USERCLASS_MAX_LEN 255 -#define VENDOR_MAX_LEN 255 - -#define DHCPCD_ARP (1 << 0) -#define DHCPCD_DOMAIN (1 << 2) -#define DHCPCD_GATEWAY (1 << 3) -#define DHCPCD_LASTLEASE (1 << 7) -#define DHCPCD_INFORM (1 << 8) -#define DHCPCD_REQUEST (1 << 9) -#define DHCPCD_IPV4LL (1 << 10) -#define DHCPCD_DUID (1 << 11) -#define DHCPCD_PERSISTENT (1 << 12) -#define DHCPCD_DAEMONISE (1 << 14) -#define DHCPCD_DAEMONISED (1 << 15) -#define DHCPCD_TEST (1 << 16) -#define DHCPCD_FORKED (1 << 17) -#define DHCPCD_HOSTNAME (1 << 18) -#define DHCPCD_CLIENTID (1 << 19) -#define DHCPCD_LINK (1 << 20) -#define DHCPCD_BACKGROUND (1 << 21) - -struct options { - char interface[IF_NAMESIZE]; +#include "dhcp.h" + +#define HWADDR_LEN 20 + +enum DHS { + DHS_INIT, + DHS_DISCOVERING, + DHS_REQUESTING, + DHS_BOUND, + DHS_RENEWING, + DHS_REBINDING, + DHS_REBOOT, + DHS_RENEW_REQUESTED, + DHS_INIT_IPV4LL, + DHS_PROBING, + DHS_ANNOUNCING +}; + +#define LINK_UP 1 +#define LINK_UNKNOWN 0 +#define LINK_DOWN -1 + +struct if_state { + enum DHS state; + struct if_options *options; + struct dhcp_message *sent; + struct dhcp_message *offer; + struct dhcp_message *new; + struct dhcp_message *old; + struct dhcp_lease lease; + time_t interval; + time_t nakoff; + uint32_t xid; + int socket; + int carrier; + int probes; + int claims; + int conflicts; + time_t defend; + struct in_addr fail; +}; + +struct interface +{ + char name[IF_NAMESIZE]; + struct if_state *state; + + sa_family_t family; + unsigned char hwaddr[HWADDR_LEN]; + size_t hwlen; int metric; - uint8_t requestmask[256 / 8]; - uint8_t requiremask[256 / 8]; - uint8_t nomask[256 / 8]; - uint32_t leasetime; - time_t timeout; - int options; - - struct in_addr request_address; - struct in_addr request_netmask; - - char **environ; - char script[PATH_MAX]; - char pidfile[PATH_MAX]; - - char hostname[HOSTNAME_MAX_LEN + 1]; - int fqdn; - uint8_t vendorclassid[VENDORCLASSID_MAX_LEN + 1]; - char clientid[CLIENTID_MAX_LEN + 1]; - uint8_t userclass[USERCLASS_MAX_LEN + 1]; - uint8_t vendor[VENDOR_MAX_LEN + 1]; - - size_t blacklist_len; - in_addr_t *blacklist; + int arpable; + + int raw_fd; + int udp_fd; + int arp_fd; + size_t buffer_size, buffer_len, buffer_pos; + unsigned char *buffer; + + struct in_addr addr; + struct in_addr net; + struct rt *routes; + + char leasefile[PATH_MAX]; + time_t start_uptime; + + unsigned char *clientid; + + struct interface *next; }; + +extern int pidfd; +void handle_exit_timeout(struct interface *); +void send_request(struct interface *); +void start_interface(struct interface *); +void start_discover(struct interface *); +void start_renew(struct interface *); +void start_rebind(struct interface *); +void start_reboot(struct interface *); +void start_expire(struct interface *); +void send_decline(struct interface *); +void close_sockets(struct interface *); +void drop_config(struct interface *, const char *); + #endif |
