oingo boingo

This commit is contained in:
malloc 2018-05-09 18:11:06 -05:00
parent 9f2821b84f
commit 2e43dfaab8
4 changed files with 17 additions and 13 deletions

View file

@ -39,6 +39,8 @@ public:
bool Close();
bool Close(const Packet& message);
private:
bool InitAttempt(Packet& pck);
enum kSlaveToMasterId {
InitAttempt = 1,
Authentication,

View file

@ -14,6 +14,21 @@ bool sosc::MasterIntra::Process() {
switch(pck.GetId()) {
case InitAttempt:
return this->InitAttempt(pck);
case Authentication:
break;
case StatusUpdate:
break;
default:
return this->Close();
}
return true;
}
bool sosc::MasterIntra::InitAttempt(sosc::Packet &pck) {
if(!pck.Check(1, key.key_size_bytes))
return this->Close(Packet(EncryptionError, { "\x01" }));
@ -22,19 +37,6 @@ bool sosc::MasterIntra::Process() {
return this->Close(Packet(EncryptionError, { "\x02" }));
this->sock.Send(response);
break;
case Authentication:
break;
case StatusUpdate:
break;
default:
this->Close();
return false;
}
return true;
}
bool sosc::MasterIntra::Close() {

View file

@ -127,7 +127,7 @@ int sosc::Packet::Parse(const std::string& data, std::string* extra) {
return PCK_OK;
}
bool sosc::Packet::Check(int region_count, ...) {
bool sosc::Packet::Check(int region_count, ...) const {
if(region_count > 0xFF)
return false;

View file

@ -34,7 +34,7 @@ public:
}
int Parse(const std::string& data, std::string* extra = nullptr);
bool Check(int region_count, ...);
bool Check(int region_count, ...) const;
inline void SetId(uint8_t id) {
this->id = id;