diff --git a/src/mpdu.c b/src/mpdu.c index 10c179a9..f2637841 100644 --- a/src/mpdu.c +++ b/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; } diff --git a/src/mpdu.h b/src/mpdu.h index 440d3ee4..1407862f 100644 --- a/src/mpdu.h +++ b/src/mpdu.h @@ -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);