1 /* $Id: client.h,v 1.2 2001-03-04 11:26:09 jaredd Exp $
3 * dhcpcd - DHCP client daemon -
4 * Copyright (C) 1996 - 1997 Yoichi Hariguchi <yoichi@fore.com>
6 * dhcpcd is an RFC2131 and RFC1541 compliant DHCP client daemon.
8 * This is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 /* function prototypes
26 void classIDsetup(char *id);
27 /* requests: 'id' pointing to the class identifier string
28 * effects: it sets the default class identifier to 'ClassId' if 'id' is NULL.
29 * Otherwise it sets the string described by 'id' to 'ClassId'.
34 void clientIDsetup(char *id, char *ifname);
35 /* requests: 'id' pointing to the class identifier string
36 * 'ifname' pointing to the interface name like 'eth0'
37 * effects: it sets the default client identifier to 'ClientId'
38 * if 'id' is NULL. Otherwise it sets the string described by
40 * modifies: ClientId[]
44 void dhcpMsgInit(u_char *ifname);
45 /* requests: 'ifname' pointing to the interface name
46 * effects: it opens two sockets 'Srecv' and 'Ssend' for sending/receiving
47 * DHCP messages. it also initializes 'ClassId[]', class identifier.
48 * modifies: Srecv, Ssend, ClassId[]
54 * effects: it runs the finite state machine of DHCP client.
55 * modifies: Fsm[], CurrState, PrevState,
61 * effects: it handles 'INIT/REBOOT state as follows:
62 * 1. try to get the previously used IP address from the cache file
63 * 2. move to the state INIT if it fails.
64 * 3. send DHCP REQUEST message and move to the state REBOOTING
65 * if it succeeded in reading the cache file.
66 * modifies: DhcpMsgSend, ReqSentTime
72 * effects: it makes and sends a DHCP discover message
73 * modifies: ReqSentTime, DhcpMsgSend
79 * effects: it waits for a DHCPACK or DHCPNAK msg. it also rexmit DHCPREQUEST
81 * modifies: DhcpMsgRecv, OptPtr
82 * returns: INIT if it timeouts or gets DHCPNAK msg
83 * BOUND if it gets DHCPACK msg.
88 * effects: it waits for a DHCPOFFER msg. it also rexmit DHCPREQUEST msg
90 * modifies: DhcpMsgRecv, OptPtr
96 * effects: it checks if the assigned IP address is already used. if not,
97 * it sends a DHCPREQUEST msg and waits for a DHCPACK or DHCPNAK msg.
98 * it also rexmit DHCPREQUEST msgs if necessary. it configures host
99 * information if it gets a DHCPACK msg. it moves back to the
100 * INIT state if it gets a DHCPNAK msg, or timeouts.
101 * modifies: DhcpMsgRecv, OptPtr
102 * returns: BOUND if it gets an IP IP address successfully.
108 * effects: it closes the socket for receiving, sleeps for 'RenewTime' sec.
109 * , and moves to the RENEWING state.
116 * effects: it opens a socket for receiving, sends a DHCPREQ msg, and waits
117 * for DHCPACK or DHCPNAK msg. it makes the interface down if it gets
118 * a DHCPNAK msg. it moves back to the BOUND state if it gets a
120 * modifies: DhcpMsgSend, DhcpMsgRecv, Srecv, OptPtr, ReqSentTime
121 * returns: BOUND if it gets a DHCPACK msg,
122 * REBIND if it gets a DHCPNAK msg,
123 * INIT if it timeouts.
128 * effects: it sends a DHCPREQ msg, and waits for DHCPACK or DHCPNAK msg.
129 * it rexmit DHCPREQ msg if necessary. it makes the interface down
130 * if it gets a DHCPNAK msg. it moves back to the BOUND state if it
131 * gets a DHCPACK msg.
132 * modifies: DhcpMsgSend, DhcpMsgRecv, Srecv, OptPtr, ReqSentTime
133 * returns: BOUND if it gets a DHCPACK msg,
134 * INIT if it gets a DHCPACK msg.
137 void mkDhcpDiscoverMsg(u_char *haddr, dhcpMessage *msg);
138 void mkDhcpRequestMsg(int flag, u_long serverInaddr, u_long leaseTime,
139 u_long xid, u_long ciaddr, dhcpMessage *msg);
140 void mkDhcpDeclineMsg(int flag, u_long serverInaddr, u_long ciaddr,
142 void sendDhcpDecline(int flag, u_long serverInaddr, u_long ciaddr);
143 int setDhcpInfo(u_char *optp[], dhcpMessage *msg);
144 void setupIfInfo(struct ifinfo *ifbuf, u_long yiaddr, u_char *optp[]);
145 void initHost(struct ifinfo *ifbuf, u_long yiaddr);
146 long getNextTimeout(int flag);
150 extern int linkLocalSet;
151 extern void sendrawpacket();