Created
August 10, 2018 19:41
-
-
Save sangfansh/bda856ff5728ab7fff00172e6b98d456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<string> MessageHandler::incomingHandler(string v, int type) { | |
vector<string> res; | |
string s; | |
bool ret; | |
switch (type) { | |
case RA_VERIFICATION: { //Verification request | |
Messages::InitialMessage init_msg; | |
ret = init_msg.ParseFromString(v); | |
if (ret && init_msg.type() == RA_VERIFICATION) { | |
s = this->handleVerification(); | |
res.push_back(to_string(RA_MSG0)); | |
} | |
} | |
break; | |
case RA_MSG0: { //Reply to MSG0 | |
Messages::MessageMsg0 msg0; | |
ret = msg0.ParseFromString(v); | |
if (ret && (msg0.type() == RA_MSG0)) { | |
s = this->handleMSG0(msg0); | |
res.push_back(to_string(RA_MSG1)); | |
} | |
} | |
break; | |
case RA_MSG2: { //MSG2 | |
Messages::MessageMSG2 msg2; | |
ret = msg2.ParseFromString(v); | |
if (ret && (msg2.type() == RA_MSG2)) { | |
s = this->handleMSG2(msg2); | |
res.push_back(to_string(RA_MSG3)); | |
} | |
} | |
break; | |
case RA_ATT_RESULT: { //Reply to MSG3 | |
Messages::AttestationMessage att_msg; | |
ret = att_msg.ParseFromString(v); | |
if (ret && att_msg.type() == RA_ATT_RESULT) { | |
s = this->handleAttestationResult(att_msg); | |
res.push_back(to_string(RA_APP_ATT_OK)); | |
} | |
} | |
break; | |
default: | |
Log("Unknown type: %d", type, log::error); | |
break; | |
} | |
res.push_back(s); | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment