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

#ifndef SWITCH_H_
#define SWITCH_H_

#include <string>
/jdi/'s avatar
/jdi/ committed
12
#include <map>
/jdi/'s avatar
/jdi/ committed
13
#include "Types/Types.h"
/jdi/'s avatar
/jdi/ committed
14
15
16
17
18
19
20
21
22
23

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

struct vlan {
	int vlan_id;
	std::string name;
};

struct port {
/jdi/'s avatar
/jdi/ committed
24
25
	byte id;
	byte status;
/jdi/'s avatar
/jdi/ committed
26
27
28
29
30
31
32
33
34
	struct {
		std::vector<vlan*> tagged;
		std::vector<vlan*> untagged;
		int pvid;
	} vlan;
};

class Switch {
public:
/jdi/'s avatar
/jdi/ committed
35
36
	Switch() {
	}
/jdi/'s avatar
/jdi/ committed
37
	void parse(datasets);
/jdi/'s avatar
/jdi/ committed
38
	void parse(dataset);
/jdi/'s avatar
/jdi/ committed
39
40
41
42
	struct {
		std::string type;
		std::string hardware_version;
		std::string firmware_version;
/jdi/'s avatar
/jdi/ committed
43
		macAddr mac { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
/jdi/'s avatar
/jdi/ committed
44
45
46
47
	} device;
	struct {
		std::string password = DEFAULT_PASS;
		std::string username = DEFAULT_USER;
/jdi/'s avatar
/jdi/ committed
48
		std::string hostname;
/jdi/'s avatar
/jdi/ committed
49
		ipAddr ip_addr { 0, 0, 0, 0, };
/jdi/'s avatar
/jdi/ committed
50
51
		ipAddr ip_mask;
		ipAddr gateway;
/jdi/'s avatar
/jdi/ committed
52
		bool dhcp;
/jdi/'s avatar
/jdi/ committed
53
	} settings;
/jdi/'s avatar
/jdi/ committed
54
private:
/jdi/'s avatar
/jdi/ committed
55
56
57
58
59
	std::vector<vlan> vlans;
	std::vector<port> ports;
};

#endif /* SWITCH_H_ */