reformat
This commit is contained in:
parent
f15abc71be
commit
1f3730ac87
26 changed files with 880 additions and 844 deletions
119
src/Packet.h
119
src/Packet.h
|
|
@ -16,65 +16,68 @@
|
|||
static short sequenceId = 0;
|
||||
|
||||
class Packet {
|
||||
public:
|
||||
enum OpCode {
|
||||
DISCOVERY, GET, REPLY, SET, CONFIRM, NONE
|
||||
};
|
||||
Packet(OpCode);
|
||||
static void encode(bytes&);
|
||||
bytes getBytes();
|
||||
void parse(bytes);
|
||||
void printHeader();
|
||||
std::string opCodeToString();
|
||||
short getLength() const;
|
||||
int getCheckSum() const;
|
||||
int getErrorCode() const;
|
||||
short getSequenceId() const;
|
||||
macAddr getSwitchMac() const;
|
||||
const bytes& getBody() const;
|
||||
const bytes& getHead() const;
|
||||
const datasets& getPayload() const;
|
||||
void setBody(bytes);
|
||||
void setHostMac(macAddr);
|
||||
void setSwitchMac(macAddr);
|
||||
void setCheckSum(int);
|
||||
void setSequenceId(short);
|
||||
void setPayload(datasets payload);
|
||||
short getTokenId() const;
|
||||
void setTokenId(short tokenId = 0);
|
||||
byte getOpCode() const;
|
||||
void setOpCode(byte opCode);
|
||||
public:
|
||||
enum OpCode {
|
||||
DISCOVERY, GET, REPLY, SET, CONFIRM, NONE
|
||||
};
|
||||
Packet(OpCode);
|
||||
static void encode(bytes&);
|
||||
bytes getBytes();
|
||||
void parse(bytes);
|
||||
void printHeader();
|
||||
std::string opCodeToString();
|
||||
short getLength() const;
|
||||
int getCheckSum() const;
|
||||
int getErrorCode() const;
|
||||
short getSequenceId() const;
|
||||
macAddr getSwitchMac() const;
|
||||
const bytes& getBody() const;
|
||||
const bytes& getHead() const;
|
||||
const datasets& getPayload() const;
|
||||
void setBody(bytes);
|
||||
void setHostMac(macAddr);
|
||||
void setSwitchMac(macAddr);
|
||||
void setCheckSum(int);
|
||||
void setSequenceId(short);
|
||||
void setPayload(datasets payload);
|
||||
short getTokenId() const;
|
||||
void setTokenId(short tokenId = 0);
|
||||
byte getOpCode() const;
|
||||
void setOpCode(byte opCode);
|
||||
|
||||
private:
|
||||
bytes head = bytes(32);
|
||||
bytes body = bytes(0);
|
||||
datasets payload;
|
||||
byte version = 1;
|
||||
byte opCode;
|
||||
macAddr switchMac { { 0, 0, 0, 0, 0, 0 } };
|
||||
macAddr hostMac { { 0, 0, 0, 0, 0, 0 } };
|
||||
macAddr broadcastMac { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
|
||||
short tokenId = 0;
|
||||
short fragmentOffset = 0;
|
||||
int errorCode = 0;
|
||||
int checkSum = 0;
|
||||
short flag = 0;
|
||||
void buildHead();
|
||||
void buildBody();
|
||||
void push(bytes&, int&, short);
|
||||
void push(bytes&, int&, int);
|
||||
void push(bytes&, int&, byte);
|
||||
void push(bytes&, int&, bytes);
|
||||
void push(bytes&, int&, ipAddr);
|
||||
void push(bytes&, int&, macAddr);
|
||||
void push(bytes&, int&, dataset);
|
||||
void pull(bytes&, int&, short &);
|
||||
void pull(bytes&, int&, int&);
|
||||
void pull(bytes&, int&, byte&);
|
||||
void pull(bytes&, int&, bytes&, unsigned);
|
||||
void pull(bytes&, int&, ipAddr&);
|
||||
void pull(bytes&, int&, macAddr&);
|
||||
void pull(bytes&, int&, dataset&);
|
||||
private:
|
||||
bytes head = bytes(32);
|
||||
bytes body = bytes(0);
|
||||
datasets payload;
|
||||
byte version = 1;
|
||||
byte opCode;
|
||||
macAddr switchMac {
|
||||
{ 0, 0, 0, 0, 0, 0 } };
|
||||
macAddr hostMac {
|
||||
{ 0, 0, 0, 0, 0, 0 } };
|
||||
macAddr broadcastMac {
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
|
||||
short tokenId = 0;
|
||||
short fragmentOffset = 0;
|
||||
int errorCode = 0;
|
||||
int checkSum = 0;
|
||||
short flag = 0;
|
||||
void buildHead();
|
||||
void buildBody();
|
||||
void push(bytes&, int&, short);
|
||||
void push(bytes&, int&, int);
|
||||
void push(bytes&, int&, byte);
|
||||
void push(bytes&, int&, bytes);
|
||||
void push(bytes&, int&, ipAddr);
|
||||
void push(bytes&, int&, macAddr);
|
||||
void push(bytes&, int&, dataset);
|
||||
void pull(bytes&, int&, short &);
|
||||
void pull(bytes&, int&, int&);
|
||||
void pull(bytes&, int&, byte&);
|
||||
void pull(bytes&, int&, bytes&, unsigned);
|
||||
void pull(bytes&, int&, ipAddr&);
|
||||
void pull(bytes&, int&, macAddr&);
|
||||
void pull(bytes&, int&, dataset&);
|
||||
};
|
||||
|
||||
#endif /* PACKET_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue