Leosac
0.8.0
Open Source Access Control
rplethpacket.cpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014-2016 Leosac
3
4
This file is part of Leosac.
5
6
Leosac is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Affero General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
Leosac is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Affero General Public License for more details.
15
16
You should have received a copy of the GNU Affero General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
26
#include "
rplethpacket.hpp
"
27
28
using namespace
Leosac::Module::Rpleth
;
29
30
RplethPacket::RplethPacket
(
Sender
packetSender)
31
: status(0)
32
, type(0)
33
, command(0)
34
, dataLen(0)
35
, sum(0)
36
, isGood(false)
37
, sender(packetSender)
38
{
39
}
40
41
RplethPacket::RplethPacket
(
const
RplethPacket
&other)
42
: status(other.status)
43
, type(other.type)
44
, command(other.command)
45
, dataLen(other.dataLen)
46
, data(other.data)
47
, sum(other.sum)
48
, isGood(other.isGood)
49
, sender(other.sender)
50
{
51
}
52
53
RplethPacket
&
RplethPacket::operator=
(
const
RplethPacket
&other)
54
{
55
status
= other.
status
;
56
type
= other.
type
;
57
command
= other.
command
;
58
dataLen
= other.
dataLen
;
59
data
= other.
data
;
60
sum
= other.
sum
;
61
isGood
= other.
isGood
;
62
sender
= other.
sender
;
63
return
(*
this
);
64
}
65
66
Byte
RplethPacket::checksum
()
const
67
{
68
Byte
s = 0;
69
70
if
(
sender
==
Sender::Server
)
71
s ^=
status
;
72
s ^=
type
;
73
s ^=
command
;
74
s ^=
dataLen
;
75
for
(
int
i = 0; i <
dataLen
; ++i)
76
s ^=
data
[i];
77
return
(s);
78
}
Leosac::Module::Rpleth::RplethPacket::sender
Sender sender
Definition:
rplethpacket.hpp:68
Leosac::Module::Rpleth::RplethPacket
Definition:
rplethpacket.hpp:39
Leosac::Module::Rpleth::RplethPacket::Sender::Server
@ Server
Leosac::Module::Rpleth::RplethPacket::type
Byte type
Definition:
rplethpacket.hpp:62
Leosac::Module::Rpleth::RplethPacket::sum
Byte sum
Definition:
rplethpacket.hpp:66
Leosac::Module::Rpleth::RplethPacket::dataLen
Byte dataLen
Definition:
rplethpacket.hpp:64
Leosac::Module::Rpleth::RplethPacket::RplethPacket
RplethPacket(Sender packetSender)
Definition:
rplethpacket.cpp:30
Leosac::Module::Rpleth::RplethPacket::Sender
Sender
Definition:
rplethpacket.hpp:42
Leosac::Module::Rpleth
Namespace where implementation for Rpleth support takes place.
Definition:
circularbuffer.hpp:38
Leosac::Module::Rpleth::RplethPacket::status
Byte status
Definition:
rplethpacket.hpp:61
rplethpacket.hpp
Rpleth packet class.
Leosac::Module::Rpleth::RplethPacket::operator=
RplethPacket & operator=(const RplethPacket &other)
Definition:
rplethpacket.cpp:53
Leosac::Module::Rpleth::RplethPacket::command
Byte command
Definition:
rplethpacket.hpp:63
Leosac::Module::Rpleth::RplethPacket::data
std::vector< Byte > data
Definition:
rplethpacket.hpp:65
Leosac::Module::Rpleth::RplethPacket::isGood
bool isGood
Definition:
rplethpacket.hpp:67
Byte
std::uint8_t Byte
Definition:
bufferutils.hpp:31
Leosac::Module::Rpleth::RplethPacket::checksum
Byte checksum() const
Definition:
rplethpacket.cpp:66
src
modules
rpleth
rplethpacket.cpp
Generated on Tue Mar 22 2022 10:48:26 for Leosac by
1.8.17