OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / user / dhcpcd / client.h
1 /* $Id: client.h,v 1.2 2001-03-04 11:26:09 jaredd Exp $
2  *
3  * dhcpcd - DHCP client daemon -
4  * Copyright (C) 1996 - 1997 Yoichi Hariguchi <yoichi@fore.com>
5  *
6  * dhcpcd is an RFC2131 and RFC1541 compliant DHCP client daemon.
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 /* function prototypes
24  */
25
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'.
30  * modifies: ClassId[]
31  * returns:  nothing
32  */
33
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
39  *           'id' to 'ClientId'.
40  * modifies: ClientId[]
41  * returns:  nothing
42  */
43
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[]
49  * returns:  nothing
50  */
51
52 void    dhcpClient();
53 /* requests: nothing
54  * effects:  it runs the finite state machine of DHCP client.
55  * modifies: Fsm[], CurrState, PrevState, 
56  * returns:  nothing
57  */
58
59 int             initReboot();
60 /* requests: nothing
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
67  * returns:  nothing
68  */
69
70 int             init();
71 /* requests: nothing
72  * effects:  it makes and sends a DHCP discover message
73  * modifies: ReqSentTime, DhcpMsgSend
74  * returns:  SELECTING
75  */
76
77 int             rebooting();
78 /* requests: nothing
79  * effects:  it waits for a DHCPACK or DHCPNAK msg. it also rexmit DHCPREQUEST
80  *           msg if necessary.
81  * modifies: DhcpMsgRecv, OptPtr
82  * returns:  INIT if it timeouts or gets DHCPNAK msg
83  *           BOUND if it gets DHCPACK msg.
84  */
85
86 int             selecting();
87 /* requests: nothing
88  * effects:  it waits for a DHCPOFFER msg. it also rexmit DHCPREQUEST msg
89  *           if necessary.
90  * modifies: DhcpMsgRecv, OptPtr
91  * returns:  REQUESTING
92  */
93
94 int             requesting();
95 /* requests: nothing
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.
103  *           INIT if it fails. 
104  */
105
106 int             bound();
107 /* requests: nothing
108  * effects:  it closes the socket for receiving, sleeps for 'RenewTime' sec.
109  *           , and moves to the RENEWING state.
110  * modifies: nothing
111  * returns:  RENEWING
112  */
113
114 int             renewing();
115 /* requests: nothing
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
119  *           DHCPACK msg.
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.
124  */
125
126 int             rebinding();
127 /* requests: nothing
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.
135  */
136
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,
141                                                  dhcpMessage *msg);
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);
147
148
149 #ifdef LLIP_SUPPORT
150 extern int linkLocalSet;
151 extern void sendrawpacket();
152 #endif