btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / servers / net / DHCPClient.h
blob63b3bf0df46fa5d1671e3e2a12407c7db3454705
1 /*
2 * Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 */
8 #ifndef DHCP_CLIENT_H
9 #define DHCP_CLIENT_H
12 #include "AutoconfigClient.h"
14 #include <netinet/in.h>
16 #include <NetworkAddress.h>
19 class BMessageRunner;
20 class dhcp_message;
21 class socket_timeout;
24 enum dhcp_state {
25 INIT,
26 SELECTING,
27 INIT_REBOOT,
28 REBOOTING,
29 REQUESTING,
30 BOUND,
31 RENEWING,
32 REBINDING,
36 class DHCPClient : public AutoconfigClient {
37 public:
38 DHCPClient(BMessenger target,
39 const char* device);
40 virtual ~DHCPClient();
42 virtual status_t Initialize();
44 virtual void MessageReceived(BMessage* message);
46 private:
47 status_t _Negotiate(dhcp_state state);
48 status_t _GotMessage(dhcp_state& state,
49 dhcp_message* message);
50 status_t _StateTransition(int socket, dhcp_state& state);
51 void _ParseOptions(dhcp_message& message,
52 BMessage& address,
53 BMessage& resolverConfiguration);
54 void _PrepareMessage(dhcp_message& message,
55 dhcp_state state);
56 status_t _SendMessage(int socket, dhcp_message& message,
57 const BNetworkAddress& address) const;
58 dhcp_state _CurrentState() const;
59 bool _TimeoutShift(int socket, dhcp_state& state,
60 socket_timeout& timeout);
61 void _RestartLease(bigtime_t lease);
63 static BString _AddressToString(const uint8* data);
64 static BString _AddressToString(in_addr_t address);
66 private:
67 BMessage fConfiguration;
68 BMessage fResolverConfiguration;
69 BMessageRunner* fRunner;
70 uint8 fMAC[6];
71 BString fHostName;
72 uint32 fTransactionID;
73 in_addr_t fAssignedAddress;
74 BNetworkAddress fServer;
75 bigtime_t fStartTime;
76 bigtime_t fRequestTime;
77 bigtime_t fRenewalTime;
78 bigtime_t fRebindingTime;
79 bigtime_t fLeaseTime;
80 status_t fStatus;
83 #endif // DHCP_CLIENT_H