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