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
671a9df9
Commit
671a9df9
authored
Sep 26, 2015
by
/jdi/
Browse files
sniffing function added
parent
699ff422
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Program.cpp
View file @
671a9df9
...
...
@@ -27,11 +27,10 @@ int Program::list() {
//Device d = Device();
//printf(" %d\n", d.getName());
bytes
b
=
{
255
,
255
,
0
,
0
};
Host
h
=
Host
();
Packet
p
=
Packet
(
Packet
::
DISCOVERY
);
p
.
setBody
(
b
);
p
.
setHostMac
(
h
.
getMac
());
p
.
setPayload
({});
bytes
a
=
p
.
getBytes
();
p
.
encode
(
a
);
...
...
src/Utils.h
0 → 100644
View file @
671a9df9
/*
* Utils.h
*
* Created on: 24.09.2015
* Author: jdi
*/
#ifndef UTILS_H_
#define UTILS_H_
#include <string>
#include <cstring>
#include "Types.h"
namespace
utils
{
static
void
printHex
(
bytes
d
)
{
if
(
d
.
size
()
>
0
)
printf
(
"%.2X"
,
d
[
0
]);
for
(
unsigned
i
=
1
;
i
<
d
.
size
();
i
++
)
{
printf
(
":%.2X"
,
d
[
i
]);
}
}
static
void
printDec
(
bytes
d
)
{
if
(
d
.
size
()
>
0
)
printf
(
"%.1d"
,
d
[
0
]);
for
(
unsigned
i
=
1
;
i
<
d
.
size
();
i
++
)
{
printf
(
".%.1d"
,
d
[
i
]);
}
}
}
#endif
/* UTILS_H_ */
src/transfer/Packet.cpp
View file @
671a9df9
...
...
@@ -163,7 +163,12 @@ void Packet::encode(bytes &data) {
}
void
Packet
::
push
(
bytes
&
arr
,
int
&
index
,
byte
data
)
{
arr
[
index
++
]
=
data
;
if
(
arr
.
size
()
>
index
)
{
arr
[
index
++
]
=
data
;
}
else
{
arr
.
push_back
(
data
);
index
++
;
}
}
void
Packet
::
push
(
bytes
&
arr
,
int
&
index
,
bytes
data
)
{
...
...
src/transfer/Packet.h
View file @
671a9df9
...
...
@@ -9,7 +9,7 @@
#define PACKET_H_
#define HEADER_LEN 32
#define PACKET_END
-65536
#define PACKET_END
0xFFFF0000
#include "../Types.h"
...
...
@@ -19,11 +19,12 @@ public:
DISCOVERY
,
GET
,
SET
,
READ
};
Packet
(
OpCode
);
virtual
~
Packet
(){};
virtual
~
Packet
()
{
}
void
encode
(
bytes
&
);
bytes
getBytes
();
void
parse
(
bytes
);
short
getLength
()
const
;
short
getLength
()
const
;
int
getCheckSum
()
const
;
short
getSequenceId
()
const
;
const
bytes
&
getSwitchMac
()
const
;
...
...
@@ -39,13 +40,13 @@ public:
private:
bytes
head
=
bytes
(
32
);
bytes
body
;
bytes
body
=
bytes
(
0
)
;
datasets
payload
;
byte
version
=
1
;
byte
opCode
;
bytes
switchMac
=
{
0
,
0
,
0
,
0
,
0
,
0
};
bytes
hostMac
=
{
0
,
0
,
0
,
0
,
0
,
0
};
// TODO set Mac
bytes
hostMac
=
{
0
,
0
,
0
,
0
,
0
,
0
};
// TODO set Mac
bytes
broadcastMac
=
{
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
};
short
sequenceId
;
short
tokenId
=
0
;
...
...
src/transfer/Socket.cpp
View file @
671a9df9
...
...
@@ -73,7 +73,4 @@ void Socket::listen() {
}
}
});
//printf("Listen\n");
}
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