3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-20 02:32:36 +01:00

mpdu: Change the validation function signature

What comes in is a frame, and let's set it to uint8_t pointer, which is
semantically better than unsigned char.

Also, returning the cast pointer instead of a boolean is easier to
use as there won't be any need to perform the cast ourselves afterward
This commit is contained in:
Tomasz Bursztyka 2015-01-22 17:58:21 +02:00 committed by Denis Kenzior
parent e573b7ca0f
commit e02f02fa69
2 changed files with 11 additions and 9 deletions

View File

@ -154,26 +154,28 @@ static bool validate_mgmt_mpdu(const struct mpdu *mpdu, int len, int *offset)
return true;
}
bool mpdu_validate(const unsigned char *frame, int len)
const struct mpdu *mpdu_validate(const uint8_t *frame, int len)
{
struct mpdu *mpdu;
const struct mpdu *mpdu;
bool valid;
int offset;
if (!frame)
return false;
return NULL;
if (len < 2)
return false;
return NULL;
offset = 2;
mpdu = (struct mpdu *) frame;
mpdu = (const struct mpdu *) frame;
switch (mpdu->fc.type) {
case MPDU_TYPE_MANAGEMENT:
return validate_mgmt_mpdu(mpdu, len, &offset);
valid = validate_mgmt_mpdu(mpdu, len, &offset);
break;
default:
return false;
return NULL;
}
return true;
return valid ? mpdu : NULL;
}

View File

@ -251,4 +251,4 @@ struct mpdu {
};
} __attribute__ ((packed));
bool mpdu_validate(const unsigned char *mpdu, int len);
const struct mpdu *mpdu_validate(const uint8_t *frame, int len);