Leosac  0.7.0
OpenSourceAccessControl
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 
31  : status(0)
32  , type(0)
33  , command(0)
34  , dataLen(0)
35  , sum(0)
36  , isGood(false)
37  , sender(packetSender)
38 {
39 }
40 
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 
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 
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 }
std::uint8_t Byte
Definition: bufferutils.hpp:31
RplethPacket & operator=(const RplethPacket &other)
Namespace where implementation for Rpleth support takes place.
Rpleth packet class.