dhcpcd.h revision 1.1.2.2 1 1.1.2.2 bouyer /*
2 1.1.2.2 bouyer * dhcpcd - DHCP client daemon
3 1.1.2.2 bouyer * Copyright (c) 2006-2010 Roy Marples <roy (at) marples.name>
4 1.1.2.2 bouyer * All rights reserved
5 1.1.2.2 bouyer
6 1.1.2.2 bouyer * Redistribution and use in source and binary forms, with or without
7 1.1.2.2 bouyer * modification, are permitted provided that the following conditions
8 1.1.2.2 bouyer * are met:
9 1.1.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer.
11 1.1.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.1.2.2 bouyer * documentation and/or other materials provided with the distribution.
14 1.1.2.2 bouyer *
15 1.1.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 1.1.2.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 1.1.2.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 1.1.2.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 1.1.2.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 1.1.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 1.1.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.1.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 1.1.2.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 1.1.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 1.1.2.2 bouyer * SUCH DAMAGE.
26 1.1.2.2 bouyer */
27 1.1.2.2 bouyer
28 1.1.2.2 bouyer #ifndef DHCPCD_H
29 1.1.2.2 bouyer #define DHCPCD_H
30 1.1.2.2 bouyer
31 1.1.2.2 bouyer #include <sys/socket.h>
32 1.1.2.2 bouyer #include <net/if.h>
33 1.1.2.2 bouyer
34 1.1.2.2 bouyer #include <limits.h>
35 1.1.2.2 bouyer
36 1.1.2.2 bouyer #include "dhcp.h"
37 1.1.2.2 bouyer #include "if-options.h"
38 1.1.2.2 bouyer
39 1.1.2.2 bouyer #define HWADDR_LEN 20
40 1.1.2.2 bouyer #define IF_SSIDSIZE 33
41 1.1.2.2 bouyer #define PROFILE_LEN 64
42 1.1.2.2 bouyer
43 1.1.2.2 bouyer enum DHS {
44 1.1.2.2 bouyer DHS_INIT,
45 1.1.2.2 bouyer DHS_DISCOVER,
46 1.1.2.2 bouyer DHS_REQUEST,
47 1.1.2.2 bouyer DHS_BOUND,
48 1.1.2.2 bouyer DHS_RENEW,
49 1.1.2.2 bouyer DHS_REBIND,
50 1.1.2.2 bouyer DHS_REBOOT,
51 1.1.2.2 bouyer DHS_INFORM,
52 1.1.2.2 bouyer DHS_RENEW_REQUESTED,
53 1.1.2.2 bouyer DHS_INIT_IPV4LL,
54 1.1.2.2 bouyer DHS_PROBE
55 1.1.2.2 bouyer };
56 1.1.2.2 bouyer
57 1.1.2.2 bouyer #define LINK_UP 1
58 1.1.2.2 bouyer #define LINK_UNKNOWN 0
59 1.1.2.2 bouyer #define LINK_DOWN -1
60 1.1.2.2 bouyer
61 1.1.2.2 bouyer struct if_state {
62 1.1.2.2 bouyer enum DHS state;
63 1.1.2.2 bouyer char profile[PROFILE_LEN];
64 1.1.2.2 bouyer struct if_options *options;
65 1.1.2.2 bouyer struct dhcp_message *sent;
66 1.1.2.2 bouyer struct dhcp_message *offer;
67 1.1.2.2 bouyer struct dhcp_message *new;
68 1.1.2.2 bouyer struct dhcp_message *old;
69 1.1.2.2 bouyer struct dhcp_lease lease;
70 1.1.2.2 bouyer const char *reason;
71 1.1.2.2 bouyer time_t interval;
72 1.1.2.2 bouyer time_t nakoff;
73 1.1.2.2 bouyer uint32_t xid;
74 1.1.2.2 bouyer int socket;
75 1.1.2.2 bouyer int probes;
76 1.1.2.2 bouyer int claims;
77 1.1.2.2 bouyer int conflicts;
78 1.1.2.2 bouyer time_t defend;
79 1.1.2.2 bouyer struct in_addr fail;
80 1.1.2.2 bouyer size_t arping_index;
81 1.1.2.2 bouyer };
82 1.1.2.2 bouyer
83 1.1.2.2 bouyer struct interface {
84 1.1.2.2 bouyer char name[IF_NAMESIZE];
85 1.1.2.2 bouyer struct if_state *state;
86 1.1.2.2 bouyer
87 1.1.2.2 bouyer int flags;
88 1.1.2.2 bouyer sa_family_t family;
89 1.1.2.2 bouyer unsigned char hwaddr[HWADDR_LEN];
90 1.1.2.2 bouyer size_t hwlen;
91 1.1.2.2 bouyer int metric;
92 1.1.2.2 bouyer int carrier;
93 1.1.2.2 bouyer int wireless;
94 1.1.2.2 bouyer char ssid[IF_SSIDSIZE];
95 1.1.2.2 bouyer
96 1.1.2.2 bouyer int raw_fd;
97 1.1.2.2 bouyer int udp_fd;
98 1.1.2.2 bouyer int arp_fd;
99 1.1.2.2 bouyer size_t buffer_size, buffer_len, buffer_pos;
100 1.1.2.2 bouyer unsigned char *buffer;
101 1.1.2.2 bouyer
102 1.1.2.2 bouyer struct in_addr addr;
103 1.1.2.2 bouyer struct in_addr net;
104 1.1.2.2 bouyer struct in_addr dst;
105 1.1.2.2 bouyer
106 1.1.2.2 bouyer char leasefile[PATH_MAX];
107 1.1.2.2 bouyer time_t start_uptime;
108 1.1.2.2 bouyer
109 1.1.2.2 bouyer unsigned char *clientid;
110 1.1.2.2 bouyer
111 1.1.2.2 bouyer struct interface *next;
112 1.1.2.2 bouyer };
113 1.1.2.2 bouyer
114 1.1.2.2 bouyer extern int pidfd;
115 1.1.2.2 bouyer extern int options;
116 1.1.2.2 bouyer extern int ifac;
117 1.1.2.2 bouyer extern char **ifav;
118 1.1.2.2 bouyer extern int ifdc;
119 1.1.2.2 bouyer extern char **ifdv;
120 1.1.2.2 bouyer extern struct interface *ifaces;
121 1.1.2.2 bouyer
122 1.1.2.2 bouyer #endif
123