Switch.h 1.13 KB
Newer Older
/jdi/'s avatar
/jdi/ committed
1
2
3
4
5
6
7
8
9
10
11
12
/*
 * Switch.h
 *
 *  Created on: 29.09.2015
 *      Author: jdi
 */

#ifndef SWITCH_H_
#define SWITCH_H_

#include <string>
#include "Types.h"
/jdi/'s avatar
/jdi/ committed
13
14
#include "Types/bytes.h"
#include "Types/datasets.h"
/jdi/'s avatar
/jdi/ committed
15
16
17
18

#define DEFAULT_USER "admin"
#define DEFAULT_PASS "admin"

/jdi/'s avatar
/jdi/ committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 *
 static bitable lookup = {
 {1, "type"},
 {2, "hostname"},
 {3, "mac"},
 {4, "ip_addr"},
 {5, "ip_mask"},
 {6, "gateway"},
 {7, "firmware_version"},
 {8, "hardware_version"},
 {9, "dhcp"}};
 */

/jdi/'s avatar
/jdi/ committed
33
34
35
36
37
38
struct vlan {
	int vlan_id;
	std::string name;
};

struct port {
/jdi/'s avatar
/jdi/ committed
39
40
	byte id;
	byte status;
/jdi/'s avatar
/jdi/ committed
41
42
43
44
45
46
47
48
49
	struct {
		std::vector<vlan*> tagged;
		std::vector<vlan*> untagged;
		int pvid;
	} vlan;
};

class Switch {
public:
/jdi/'s avatar
/jdi/ committed
50
51
	Switch() {
	}
/jdi/'s avatar
/jdi/ committed
52
53
54
55
56
	void parse(datasets);
	struct {
		std::string type;
		std::string hardware_version;
		std::string firmware_version;
/jdi/'s avatar
/jdi/ committed
57
		macAddr mac { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
/jdi/'s avatar
/jdi/ committed
58
59
60
61
	} device;
	struct {
		std::string password = DEFAULT_PASS;
		std::string username = DEFAULT_USER;
/jdi/'s avatar
/jdi/ committed
62
		std::string hostname;
/jdi/'s avatar
/jdi/ committed
63
		ipAddr ip_addr { 0, 0, 0, 0, };
/jdi/'s avatar
/jdi/ committed
64
65
		ipAddr ip_mask;
		ipAddr gateway;
/jdi/'s avatar
/jdi/ committed
66
		bool dhcp;
/jdi/'s avatar
/jdi/ committed
67
	} settings;
/jdi/'s avatar
/jdi/ committed
68
private:
/jdi/'s avatar
/jdi/ committed
69
70
71
72
73
	std::vector<vlan> vlans;
	std::vector<port> ports;
};

#endif /* SWITCH_H_ */