Commit 7ae3dee0 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code cleanup Authentication Response/Result

parent 57928508
......@@ -37,7 +37,8 @@ EapMessage::EapMessage(uint8_t iei) : Type6NasIe(iei), eap_() {
}
//------------------------------------------------------------------------------
EapMessage::EapMessage(const uint8_t iei, bstring eap) : Type6NasIe(iei) {
EapMessage::EapMessage(const uint8_t iei, const bstring& eap)
: Type6NasIe(iei) {
eap_ = bstrcpy(eap);
SetLengthIndicator(blength(eap));
}
......
......@@ -34,8 +34,8 @@ class EapMessage : public Type6NasIe {
public:
EapMessage();
EapMessage(uint8_t iei);
EapMessage(bstring eap);
EapMessage(uint8_t iei, bstring eap);
EapMessage(const bstring& eap);
EapMessage(uint8_t iei, const bstring& eap);
~EapMessage();
static std::string GetIeName() { return kEapMessageIeName; }
......
......@@ -49,7 +49,8 @@ void AuthenticationResponse::SetAuthenticationResponseParameter(
}
//------------------------------------------------------------------------------
bool AuthenticationResponse::GetAuthenticationResponseParameter(bstring& para) {
bool AuthenticationResponse::GetAuthenticationResponseParameter(
bstring& para) const {
if (ie_authentication_response_parameter.has_value()) {
ie_authentication_response_parameter.value().GetValue(para);
return true;
......@@ -64,7 +65,7 @@ void AuthenticationResponse::SetEapMessage(const bstring& eap) {
}
//------------------------------------------------------------------------------
bool AuthenticationResponse::GetEapMessage(bstring& eap) {
bool AuthenticationResponse::GetEapMessage(bstring& eap) const {
if (ie_eap_message.has_value()) {
ie_eap_message.value().GetValue(eap);
return true;
......
......@@ -37,10 +37,10 @@ class AuthenticationResponse : public NasMmPlainHeader {
void SetHeader(uint8_t security_header_type);
void SetAuthenticationResponseParameter(const bstring& para);
bool GetAuthenticationResponseParameter(bstring& para);
bool GetAuthenticationResponseParameter(bstring& para) const;
void SetEapMessage(const bstring& eap);
bool GetEapMessage(bstring& eap);
bool GetEapMessage(bstring& eap) const;
public:
std::optional<AuthenticationResponseParameter>
......
......@@ -42,9 +42,9 @@ void AuthenticationResult::SetHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------
void AuthenticationResult::SetNgKsi(uint8_t tsc, uint8_t key_set_id) {
ie_ngKSI.Set(false); // 4 lower bits
ie_ngKSI.SetTypeOfSecurityContext(tsc);
ie_ngKSI.SetNasKeyIdentifier(key_set_id);
ie_ng_ksi.Set(false); // 4 lower bits
ie_ng_ksi.SetTypeOfSecurityContext(tsc);
ie_ng_ksi.SetNasKeyIdentifier(key_set_id);
}
//------------------------------------------------------------------------------
......@@ -53,7 +53,7 @@ void AuthenticationResult::SetAbba(uint8_t length, uint8_t* value) {
}
//------------------------------------------------------------------------------
void AuthenticationResult::SetEapMessage(bstring eap) {
void AuthenticationResult::SetEapMessage(const bstring& eap) {
ie_eap_message.SetValue(eap);
}
......@@ -72,7 +72,7 @@ int AuthenticationResult::Encode(uint8_t* buf, int len) {
encoded_size += encoded_ie_size;
// ngKSI
int size = ie_ngKSI.Encode(buf + encoded_size, len - encoded_size);
int size = ie_ng_ksi.Encode(buf + encoded_size, len - encoded_size);
if (size != KEncodeDecodeError) {
encoded_size += size;
} else {
......@@ -81,7 +81,7 @@ int AuthenticationResult::Encode(uint8_t* buf, int len) {
return KEncodeDecodeError;
}
// Spare half octet
encoded_size++; // 1/2 octet + 1/2 octet from ie_ngKSI
encoded_size++; // 1/2 octet + 1/2 octet from ie_ng_ksi
// EAP message
size = ie_eap_message.Encode(buf + encoded_size, len - encoded_size);
......@@ -126,7 +126,7 @@ int AuthenticationResult::Decode(uint8_t* buf, int len) {
// NAS key set identifier
decoded_result =
ie_ngKSI.Decode(buf + decoded_size, len - decoded_size, false, false);
ie_ng_ksi.Decode(buf + decoded_size, len - decoded_size, false, false);
if (decoded_result == KEncodeDecodeError) {
Logger::nas_mm().error(
"Decoding %s error", NasKeySetIdentifier::GetIeName().c_str());
......@@ -154,7 +154,7 @@ int AuthenticationResult::Decode(uint8_t* buf, int len) {
while ((octet != 0x0)) {
switch (octet) {
case kIeiAbba: {
Logger::nas_mm().debug("Decoding IEI (0x38)");
Logger::nas_mm().debug("Decoding IEI 0x%x", kIeiAbba);
ABBA ie_abba_tmp = {};
if ((decoded_result = ie_abba_tmp.Decode(
buf + decoded_size, len - decoded_size, true)) ==
......
......@@ -39,7 +39,7 @@ class AuthenticationResult : public NasMmPlainHeader {
void SetNgKsi(uint8_t tsc, uint8_t key_set_id);
// TODO: Get
void SetEapMessage(bstring eap);
void SetEapMessage(const bstring& eap);
// TODO: Get
void SetAbba(uint8_t length, uint8_t* value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment