-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPXEClient.h
105 lines (77 loc) · 2.37 KB
/
PXEClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// Created by warnelso on 5/31/16.
//
#ifndef PXESIM_PXECLIENT_H
#define PXESIM_PXECLIENT_H
#include <tins/tins.h>
#include <queue>
#include <string>
#include "DownloadHandler.h"
enum ClientState {
New,
DHCPDiscovering,
DHCPRequested,
DHCPAcknowledged,
ARPRequested,
ARPRecieved,
TFTPBootRequest,
TFTPBootDownloading,
TFTPWaitingConfigRequest,
TFTPConfigRequest,
TFTPConfigDownloading,
TFTPWaitingFilesRequest,
TFTPFilesRequest,
TFTPFilesDownloading,
Completed,
Terminated = -1
};
class PXEClient {
public:
PXEClient();
void dhcp_discover(Tins::PacketSender &sender);
void dhcp_request(
Tins::PacketSender &sender,
const Tins::IPv4Address &dhcp_server_address,
const Tins::IPv4Address &dhcp_client_address
);
const bool dhcp_acknowledged(
const Tins::DHCP &pdu
);
void arp_request_dhcp_server(Tins::PacketSender &sender);
void arp_reply_dhcp_server(
Tins::PacketSender &sender,
const Tins::HWAddress<6> &dhcp_server_mac_address
);
void ping(
Tins::PacketSender &sender,
const Tins::IPv4Address &ip_address,
const Tins::HWAddress<6> &mac_address
) const;
void pong(
Tins::PacketSender &sender,
const Tins::IPv4Address &ip_address,
const Tins::HWAddress<6> &mac_address,
const Tins::ICMP &icmp
) const;
void tftp_read(Tins::PacketSender &sender);
void tftp_ack_options(Tins::PacketSender &sender, uint16_t dest_port, uint32_t total_size);
void tftp_ack_data(
Tins::PacketSender &sender,
uint16_t dest_port,
const Data &data,
uint16_t block_number
);
void tftp_not_found_error();
const Tins::IPv4Address &dhcp_client_address() const;
ClientState state() const;
void arp_reply_recieved(const Tins::HWAddress<6> &tftp_hw_address);
const Tins::HWAddress<6> &get_client_hw_address() const { return _client_hw_address; }
private:
Tins::HWAddress<6> _client_hw_address, _dhcp_hw_address;
Tins::IPv4Address _dhcp_client_address, _dhcp_server_address;
uint32_t _dhcp_xid;
DownloadHandler _download_handler;
ClientState _state;
};
const std::vector<uint8_t> array_from_uint32(const uint32_t number);
#endif //PXESIM_PXECLIENT_H