]> git.stg.codes - stg.git/blob - stglibs/sgcp.lib/packet.cpp
12d8f1e925b720e756f4eacb4704b09ba8bd9fae
[stg.git] / stglibs / sgcp.lib / packet.cpp
1 #include "packet.h"
2
3 #include "stg/sgcp_utils.h"
4
5 #include <ctime>
6
7 using STG::SGCP::Packet;
8
9 uint64_t Packet::MAGIC = 0x5f8edc0fdb6d3113; // Carefully picked random 64-bit number :)
10 uint16_t Packet::VERSION = 1;
11
12 Packet::Packet(uint16_t ver, uint16_t t, uint16_t sz)
13     : magic(MAGIC),
14       senderTime(time(NULL)),
15       version(ver),
16       type(t),
17       size(s)
18 {
19 }
20
21 Packet hton(Packet value)
22 {
23     value.magic = hton(value.magic);
24     value.senderTime = hton(value.senderTime);
25     value.version = hton(value.version);
26     value.type = hton(value.type);
27     value.size = hton(value.size);
28 }