mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-20 10:42:48 +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:
parent
e573b7ca0f
commit
e02f02fa69
18
src/mpdu.c
18
src/mpdu.c
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user