From 922e10e82cb7d2c59c7f20fba588755df5181c93 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 22 Feb 2019 15:39:39 -0800 Subject: [PATCH] ie: add macro for calculating an IE's length All over the place we do "ie[1] + 2" for getting the IE length. It is much clearer to use a macro to do this. The macro also checks for NULL, and returns zero in this case. --- src/ie.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ie.h b/src/ie.h index da7d6d71..ce36060a 100644 --- a/src/ie.h +++ b/src/ie.h @@ -258,6 +258,9 @@ enum ie_rsn_akm_suite { ((akm == IE_RSN_AKM_SUITE_SAE_SHA256) || \ (akm == IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256)) +#define IE_LEN(ie) \ + (ie) ? (ie)[1] + 2 : 0 + struct ie_tlv_iter { unsigned int max; unsigned int pos;