Add a payload.get_header_length() method, remove header length definitions
This commit is contained in:
@@ -102,10 +102,6 @@ static encoding_rule_t encodings[] = {
|
||||
METHOD(payload_t, verify, status_t,
|
||||
private_unknown_payload_t *this)
|
||||
{
|
||||
if (this->payload_length != UNKNOWN_PAYLOAD_HEADER_LENGTH + this->data.len)
|
||||
{
|
||||
return FAILED;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -116,6 +112,12 @@ METHOD(payload_t, get_encoding_rules, int,
|
||||
return countof(encodings);
|
||||
}
|
||||
|
||||
METHOD(payload_t, get_header_length, int,
|
||||
private_unknown_payload_t *this)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
METHOD(payload_t, get_payload_type, payload_type_t,
|
||||
private_unknown_payload_t *this)
|
||||
{
|
||||
@@ -171,6 +173,7 @@ unknown_payload_t *unknown_payload_create(payload_type_t type)
|
||||
.payload_interface = {
|
||||
.verify = _verify,
|
||||
.get_encoding_rules = _get_encoding_rules,
|
||||
.get_header_length = _get_header_length,
|
||||
.get_length = _get_length,
|
||||
.get_next_type = _get_next_type,
|
||||
.set_next_type = _set_next_type,
|
||||
@@ -182,7 +185,7 @@ unknown_payload_t *unknown_payload_create(payload_type_t type)
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.next_payload = NO_PAYLOAD,
|
||||
.payload_length = UNKNOWN_PAYLOAD_HEADER_LENGTH,
|
||||
.payload_length = get_header_length(this),
|
||||
.type = type,
|
||||
);
|
||||
|
||||
@@ -201,7 +204,7 @@ unknown_payload_t *unknown_payload_create_data(payload_type_t type,
|
||||
this = (private_unknown_payload_t*)unknown_payload_create(type);
|
||||
this->data = data;
|
||||
this->critical = critical;
|
||||
this->payload_length = UNKNOWN_PAYLOAD_HEADER_LENGTH + data.len;
|
||||
this->payload_length = get_header_length(this) + data.len;
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user