-
Notifications
You must be signed in to change notification settings - Fork 1
/
eapoption.h
88 lines (70 loc) · 2.51 KB
/
eapoption.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
/*
eapoption.h: basic options
Copyright (C) 2014 C.C.<exiledkingcc@gmail.com>
This file is part of ccnt.
ccnt is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ccnt is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ccnt. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <cstdint>
#include <string>
#include <cstring>
#include <iostream>
using std::uint8_t;
using std::uint32_t;
using std::string;
enum class eap_mode:uint8_t {Standard=0, DigitalChina=1, };
const string all_modes();
std::ostream& operator<<(std::ostream &os,eap_mode m);
class EAPOption
{
public:
EAPOption():_ip(0),_mask(0),_gateway(0),_dns(0),_mac{0},_cast{0},_mode(eap_mode::Standard),_dhcp(true){}
EAPOption(const EAPOption&) = delete;
EAPOption& operator=(const EAPOption&) = delete;
virtual ~EAPOption(){}
//get
void username(const string &x){ _username=x; }
void password(const string &x){ _password=x; }
void nic(const string &x){ _nic=x; }
void ip(const uint32_t x){ _ip=x; }
void mask(const uint32_t x){ _mask=x; }
void gateway(const uint32_t x){ _gateway=x; }
void dns(const uint32_t x){ _dns=x; }
void mac(const uint8_t x[6]){ std::memcpy(_mac,x,6); }
void cast(const uint8_t x[6]){ std::memcpy(_cast,x,6); }
void mode(eap_mode x){ _mode=x; }
void dhcp(bool x){ _dhcp=x; }
//set
const string& username() const { return _username; }
const string& password() const { return _password; }
const string& nic() const { return _nic; }
uint32_t ip() const { return _ip; }
uint32_t mask() const { return _mask; }
uint32_t gateway() const { return _gateway; }
uint32_t dns() const { return _dns; }
const uint8_t* mac() const { return _mac; }
const uint8_t* cast() const { return _cast; }
eap_mode mode() const { return _mode; }
bool dhcp() const { return _dhcp; }
protected:
string _username;
string _password;
string _nic;
uint32_t _ip;
uint32_t _mask;
uint32_t _gateway;
uint32_t _dns;
uint8_t _mac[6];
uint8_t _cast[6];
eap_mode _mode;
bool _dhcp;
};