remote-device-name: Minor cleanup of documentation and code
[remote/remote-mci.git] / protocols / diku_host_server / MsgHostConfirm.cc
blobdcea0b8e51ecfa717b7a17d6464a42fcddf36bce
1 #include "MsgHostConfirm.h"
3 namespace remote { namespace protocols { namespace diku_host_server {
5 MsgHostConfirm::MsgHostConfirm(uint8_t status,MsgMoteAddresses& addresses, MsgPayload& message)
6 : status(status),
7 addresses(&addresses),
8 message(&message),
9 deleteMsg(false)
12 MsgHostConfirm::MsgHostConfirm(uint8_t*& buffer, uint32_t& buflen)
14 buffer=this->read(buffer,buflen);
15 deleteMsg = true;
18 MsgHostConfirm::~MsgHostConfirm()
20 if (deleteMsg)
22 delete this->addresses;
23 delete this->message;
27 uint32_t MsgHostConfirm::getLength()
29 return sizeof(status) + addresses->getLength() + message->getLength();
32 uint8_t* MsgHostConfirm::write(uint8_t* buffer, uint32_t& buflen)
34 buffer = writevalue(status,buffer,buflen);
35 buffer = addresses->write(buffer,buflen);
36 buffer = message->write(buffer,buflen);
37 return buffer;
40 uint8_t* MsgHostConfirm::read(uint8_t* buffer, uint32_t& buflen)
42 buffer = readvalue(status,buffer,buflen);
43 addresses = new MsgMoteAddresses(buffer,buflen);
44 message = new MsgPayload(buffer,buflen);
45 return buffer;
48 void MsgHostConfirm::print(FILE* s)
52 uint8_t MsgHostConfirm::getStatus()
54 return status;
57 MsgMoteAddresses& MsgHostConfirm::getMoteAddresses()
59 return *addresses;
62 MsgPayload& MsgHostConfirm::getMessage()
64 return *message;
67 }}}