Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jedi
smrtlink
Commits
aa8af556
Commit
aa8af556
authored
Jan 17, 2016
by
jedi
Browse files
table.h added
parent
73df3e05
Changes
5
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
aa8af556
...
...
@@ -15,12 +15,14 @@ $(BUILDDIR):
$(TARGET)
:
$(OBJECTS)
$(CC)
$^
-o
$@
-lboost_filesystem
-lboost_system
$(CC)
$^
-o
$(BUILDDIR)
/
$@
-lboost_filesystem
-lboost_system
$(OBJECTS)
:
$(BUILDDIR)/%.o : $(SOURCEDIR)/%.cpp
$(CC)
$(CFLAGS)
$<
-o
$@
install
:
bin/$(TARGET)
install
-m
0755 bin/
$(TARGET)
$(prefix)
/bin
clean
:
rm
-f
$(BUILDDIR)
/
*
o
$(TARGET)
rm
-f
$(BUILDDIR)
/
*
src/Host.cpp
View file @
aa8af556
...
...
@@ -57,6 +57,7 @@ ipAddr Host::getIp() {
return
data
;
}
}
/*
for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
if (ifa->ifa_addr == NULL)
continue;
...
...
@@ -66,6 +67,7 @@ ipAddr Host::getIp() {
return data;
}
}
*/
freeifaddrs
(
ifaddr
);
return
data
;
}
...
...
src/Switch.h
View file @
aa8af556
...
...
@@ -43,6 +43,7 @@ public:
std
::
string
hardware_version
;
std
::
string
firmware_version
;
macAddr
mac
{
0x0
,
0x0
,
0x0
,
0x0
,
0x0
,
0x0
};
int
ports
;
}
device
;
struct
{
std
::
string
password
=
DEFAULT_PASS
;
...
...
@@ -52,6 +53,9 @@ public:
ipAddr
ip_mask
;
ipAddr
gateway
;
bool
dhcp
;
bool
loop_prevention
;
bool
qos_enabled
;
bool
vlan_enabled
;
}
settings
;
private:
rapidjson
::
Document
json
;
...
...
src/table.cpp
0 → 100644
View file @
aa8af556
/*
* lookupTable.h
*
* Created on: 11.10.2015
* Author: jdi
*/
#include
<string>
#include
"table.h"
table
::
table
(
std
::
initializer_list
<
set
>
l
)
{
int
i
=
0
;
this
->
data
.
resize
(
l
.
size
());
for
(
set
s
:
l
)
{
this
->
data
[
i
]
=
s
;
this
->
left
[
s
.
type
]
=
&
this
->
data
[
i
];
this
->
right
[
s
.
name
]
=
&
this
->
data
[
i
];
i
++
;
}
}
short
table
::
operator
[](
std
::
string
s
){
return
this
->
right
[
s
]
->
type
;
}
std
::
string
table
::
operator
[](
short
n
){
return
this
->
left
[
n
]
->
name
;
}
bool
table
::
exists
(
std
::
string
s
){
return
!
(
right
.
find
(
s
)
==
right
.
end
());
}
bool
table
::
exists
(
short
n
){
return
!
(
left
.
find
(
n
)
==
left
.
end
());
}
const
table
::
set
*
table
::
get
(
std
::
string
s
){
return
this
->
right
[
s
];
}
const
table
::
set
*
table
::
get
(
short
n
){
return
this
->
left
[
n
];
}
src/table.h
0 → 100644
View file @
aa8af556
/*
* lookupTable.h
*
* Created on: 11.10.2015
* Author: jdi
*/
#ifndef LOOKUPTABLE_H_
#define LOOKUPTABLE_H_
#include
<map>
#include
<vector>
class
table
{
public:
enum
F
{
STRING
,
HEX
,
DEC
,
ACTION
,
EMPTY
};
struct
set
{
short
type
;
F
format
;
std
::
string
name
;
};
table
(
std
::
initializer_list
<
set
>
l
);
short
operator
[](
std
::
string
);
std
::
string
operator
[](
short
);
bool
exists
(
std
::
string
);
bool
exists
(
short
);
const
set
*
get
(
std
::
string
);
const
set
*
get
(
short
);
private:
std
::
vector
<
set
>
data
;
std
::
map
<
short
,
set
*>
left
;
std
::
map
<
std
::
string
,
set
*>
right
;
};
#endif
/* LOOKUPTABLE_H_ */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment