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
06351d87
Commit
06351d87
authored
Jan 17, 2016
by
jedi
Browse files
some minor fixes
parent
5b616762
Changes
8
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
06351d87
...
...
@@ -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/Lookup.h
View file @
06351d87
...
...
@@ -7,7 +7,7 @@
#include
"table.h"
const
static
table
rcv_lookup
=
{
//
static
table
rcv_lookup
=
{
//
{
1
,
table
::
STRING
,
"type"
},
//+string
{
2
,
table
::
STRING
,
"hostname"
},
//+string
{
3
,
table
::
HEX
,
"mac"
},
//+byte[6]
...
...
@@ -44,7 +44,7 @@ const static table rcv_lookup = { //
//{0000," "},
};
const
static
table
snd_lookup
=
{
static
table
snd_lookup
=
{
// TODO find out if id is unique in response
{
2
,
table
::
HEX
,
"system_info"
},
//page sysinfo
...
...
src/Program.cpp
View file @
06351d87
...
...
@@ -15,6 +15,7 @@
#include
"Switch.h"
#include
"Packet.h"
#include
"Lookup.h"
#include
"table.h"
int
printHeader
(
Packet
p
)
{
if
(
options
.
flags
&
FLAG_HEADER
)
{
...
...
src/Switch.cpp
View file @
06351d87
...
...
@@ -11,6 +11,7 @@
#include
"Lookup.h"
#include
"jsonNode.h"
#include
"Options.h"
#include
"table.h"
int
Switch
::
parse
(
datasets
arr
)
{
for
(
dataset
a
:
arr
)
{
...
...
@@ -21,55 +22,44 @@ int Switch::parse(datasets arr) {
int
Switch
::
parse
(
dataset
d
)
{
auto
lookup
=
(
options
.
flags
&
FLAG_REVERSE
)
?
snd_lookup
:
rcv_lookup
;
switch
(
d
.
type
)
{
case
lookup
[
"type"
]:
if
(
d
.
type
==
lookup
[
"type"
])
{
device
.
type
=
d
.
value
;
return
0
;
case
lookup
[
"mac"
]
:
}
if
(
d
.
type
==
lookup
[
"mac"
]
)
{
device
.
mac
=
d
.
value
;
return
0
;
case
lookup
[
"ip_addr"
]:
device
.
firmware_version
=
d
.
value
;
return
0
;
case
lookup
[
"ip_mask"
]:
device
.
firmware_version
=
d
.
value
;
return
0
;
case
lookup
[
"gateway"
]:
device
.
firmware_version
=
d
.
value
;
return
0
;
case
lookup
[
"firmware_version"
]:
}
if
(
d
.
type
==
lookup
[
"firmware_version"
])
{
device
.
firmware_version
=
d
.
value
;
return
0
;
case
lookup
[
"hardware_version"
]
:
}
if
(
d
.
type
==
lookup
[
"hardware_version"
]
)
{
device
.
hardware_version
=
d
.
value
;
return
0
;
case
lookup
[
"ports"
]
:
}
if
(
d
.
type
==
lookup
[
"ports"
]
)
{
device
.
ports
=
d
.
value
[
0
];
return
0
;
case
lookup
[
"hostname"
]
:
}
if
(
d
.
type
==
lookup
[
"hostname"
]
)
{
settings
.
hostname
=
d
.
value
;
return
0
;
case
lookup
[
"ip_addr"
]
:
}
if
(
d
.
type
==
lookup
[
"ip_addr"
]
)
{
settings
.
ip_addr
=
d
.
value
;
return
0
;
case
lookup
[
"ip_mask"
]
:
}
if
(
d
.
type
==
lookup
[
"ip_mask"
]
)
{
settings
.
ip_mask
=
d
.
value
;
return
0
;
case
lookup
[
"gateway"
]
:
}
if
(
d
.
type
==
lookup
[
"gateway"
]
)
{
settings
.
gateway
=
d
.
value
;
return
0
;
case
lookup
[
"dhcp"
]
:
}
if
(
d
.
type
==
lookup
[
"dhcp"
]
)
{
settings
.
dhcp
=
d
.
value
[
0
];
return
0
;
case
lookup
[
"loop_prevention"
]
:
}
if
(
d
.
type
==
lookup
[
"loop_prevention"
]
)
{
settings
.
loop_prevention
=
d
.
value
[
0
];
return
0
;
case
lookup
[
"qos_basic_enabled"
]
:
}
if
(
d
.
type
==
lookup
[
"qos_basic_enabled"
]
)
{
settings
.
qos_enabled
=
d
.
value
[
0
];
return
0
;
case
lookup
[
"vlan_enabled"
]
:
}
if
(
d
.
type
==
lookup
[
"vlan_enabled"
]
)
{
settings
.
vlan_enabled
=
d
.
value
[
0
];
return
0
;
}
return
0
;
}
...
...
src/Switch.h
View file @
06351d87
...
...
@@ -27,7 +27,7 @@ struct vlan {
struct
port
{
byte
id
;
byte
status
;
int
vlan_
pvid
;
int
pvid
;
//port_settings
//qos_basic
//bandwidth_control_1
...
...
src/Types.h
View file @
06351d87
...
...
@@ -17,6 +17,7 @@
#include
"bytes.h"
#include
"datasets.h"
#include
"table.h"
class
macAddr
:
public
std
::
array
<
byte
,
6
>
{
public:
...
...
src/table.cpp
View file @
06351d87
...
...
@@ -18,21 +18,21 @@ table::table(std::initializer_list<set> l) {
i
++
;
}
}
constexpr
const
short
&
table
::
operator
[](
std
::
string
s
)
{
short
table
::
operator
[](
std
::
string
s
){
return
this
->
right
[
s
]
->
type
;
}
constexpr
const
std
::
string
&
table
::
operator
[](
short
n
)
{
std
::
string
table
::
operator
[](
short
n
){
return
this
->
left
[
n
]
->
name
;
}
bool
table
::
exists
(
std
::
string
s
)
{
bool
table
::
exists
(
std
::
string
s
){
return
!
(
right
.
find
(
s
)
==
right
.
end
());
}
bool
table
::
exists
(
short
n
)
{
bool
table
::
exists
(
short
n
){
return
!
(
left
.
find
(
n
)
==
left
.
end
());
}
const
table
::
set
*
table
::
get
(
std
::
string
s
)
{
const
table
::
set
*
table
::
get
(
std
::
string
s
){
return
this
->
right
[
s
];
}
const
table
::
set
*
table
::
get
(
short
n
)
{
const
table
::
set
*
table
::
get
(
short
n
){
return
this
->
left
[
n
];
}
src/table.h
View file @
06351d87
...
...
@@ -20,16 +20,16 @@ public:
std
::
string
name
;
};
table
(
std
::
initializer_list
<
set
>
l
);
const
short
&
operator
[](
std
::
string
);
const
std
::
string
&
operator
[](
short
);
const
set
*
get
(
std
::
string
);
const
set
*
get
(
short
);
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
;
const
std
::
map
<
short
,
set
*>
left
;
const
std
::
map
<
std
::
string
,
set
*>
right
;
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