aboutsummaryrefslogtreecommitdiffstats
path: root/epan/crypt
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2008-03-05 00:57:30 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2008-03-05 00:57:30 +0000
commitf0e31fc3c3093ca2320d9e94f8ab3bdb08c88330 (patch)
tree9c4130d08e5550ec5bfd244b5d5394d7d857bf55 /epan/crypt
parent9c311f4e899e3e3a9a20c8ee7a2c6d467a16af98 (diff)
Move the contents of AirPDcapCleanKeys() into AirPDcapInitContext()
and call AirPDcapInitContext() where we were previously calling AirPDcapCleanKeys(). If we're resetting our keys, we should reset our SA list and other associated data as well. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24562 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/crypt')
-rw-r--r--epan/crypt/airpdcap.c49
-rw-r--r--epan/crypt/airpdcap_system.h3
2 files changed, 14 insertions, 38 deletions
diff --git a/epan/crypt/airpdcap.c b/epan/crypt/airpdcap.c
index e7cd3154ae..ebc40a995f 100644
--- a/epan/crypt/airpdcap.c
+++ b/epan/crypt/airpdcap.c
@@ -239,8 +239,6 @@ static void AirPDcapRsnaPrfX(
UCHAR *ptk)
;
-static void AirPDcapCleanKeys(PAIRPDCAP_CONTEXT ctx);
-
#ifdef __cplusplus
}
#endif
@@ -454,8 +452,8 @@ INT AirPDcapSetKeys(
return 0;
}
- /* clean keys collection before setting new ones */
- AirPDcapCleanKeys(ctx);
+ /* clean key and SA collections before setting new ones */
+ AirPDcapInitContext(ctx);
/* check and insert keys */
for (i=0, success=0; i<(INT)keys_nr; i++) {
@@ -484,25 +482,6 @@ INT AirPDcapSetKeys(
return success;
}
-static void
-AirPDcapCleanKeys(
- PAIRPDCAP_CONTEXT ctx)
-{
- AIRPDCAP_DEBUG_TRACE_START("AirPDcapCleanKeys");
-
- if (ctx==NULL) {
- AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapCleanKeys", "NULL context", AIRPDCAP_DEBUG_LEVEL_5);
- AIRPDCAP_DEBUG_TRACE_END("AirPDcapCleanKeys");
- return;
- }
-
- memset(ctx->keys, 0, sizeof(AIRPDCAP_KEY_ITEM) * AIRPDCAP_MAX_KEYS_NR);
-
- ctx->keys_nr=0;
-
- AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapCleanKeys", "Keys collection cleaned!", AIRPDCAP_DEBUG_LEVEL_5);
- AIRPDCAP_DEBUG_TRACE_END("AirPDcapCleanKeys");
-}
INT AirPDcapGetKeys(
const PAIRPDCAP_CONTEXT ctx,
@@ -564,15 +543,15 @@ INT AirPDcapInitContext(
return AIRPDCAP_RET_UNSUCCESS;
}
- AirPDcapCleanKeys(ctx);
+ memset(ctx->keys, 0, sizeof(AIRPDCAP_KEY_ITEM) * AIRPDCAP_MAX_KEYS_NR);
+ ctx->keys_nr=0;
+ memset(ctx->sa, 0, AIRPDCAP_MAX_SEC_ASSOCIATIONS_NR * sizeof(AIRPDCAP_SEC_ASSOCIATION));
ctx->first_free_index=0;
ctx->index=-1;
- ctx->last_stored_index=-1;
+ ctx->sa_index=-1;
ctx->pkt_ssid_len = 0;
- memset(ctx->sa, 0, AIRPDCAP_MAX_SEC_ASSOCIATIONS_NR * sizeof(AIRPDCAP_SEC_ASSOCIATION));
-
AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapInitContext", "Context initialized!", AIRPDCAP_DEBUG_LEVEL_5);
AIRPDCAP_DEBUG_TRACE_END("AirPDcapInitContext");
return AIRPDCAP_RET_SUCCESS;
@@ -589,11 +568,9 @@ INT AirPDcapDestroyContext(
return AIRPDCAP_RET_UNSUCCESS;
}
- AirPDcapCleanKeys(ctx);
-
ctx->first_free_index=0;
ctx->index=-1;
- ctx->last_stored_index=-1;
+ ctx->sa_index=-1;
AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapDestroyContext", "Context destroyed!", AIRPDCAP_DEBUG_LEVEL_5);
AIRPDCAP_DEBUG_TRACE_END("AirPDcapDestroyContext");
@@ -1107,10 +1084,10 @@ AirPDcapGetSa(
{
INT index;
- if (ctx->last_stored_index!=-1) {
+ if (ctx->sa_index!=-1) {
/* at least one association was stored */
- /* search for the association from last_stored_index to 0 (most recent added) */
- for (index=ctx->last_stored_index; index>=0; index--) {
+ /* search for the association from sa_index to 0 (most recent added) */
+ for (index=ctx->sa_index; index>=0; index--) {
if (ctx->sa[index].used) {
if (memcmp(id, &(ctx->sa[index].saId), sizeof(AIRPDCAP_SEC_ASSOCIATION_ID))==0) {
ctx->index=index;
@@ -1161,9 +1138,9 @@ AirPDcapStoreSa(
/* increment by 1 the first_free_index (heuristic) */
ctx->first_free_index++;
- /* set the last_stored_index if the added index is greater the the last_stored_index */
- if (ctx->index > ctx->last_stored_index)
- ctx->last_stored_index=ctx->index;
+ /* set the sa_index if the added index is greater the the sa_index */
+ if (ctx->index > ctx->sa_index)
+ ctx->sa_index=ctx->index;
return ctx->index;
}
diff --git a/epan/crypt/airpdcap_system.h b/epan/crypt/airpdcap_system.h
index 758beed8d3..f76f32e1e1 100644
--- a/epan/crypt/airpdcap_system.h
+++ b/epan/crypt/airpdcap_system.h
@@ -144,7 +144,7 @@ typedef struct _AIRPDCAP_SEC_ASSOCIATION {
typedef struct _AIRPDCAP_CONTEXT {
AIRPDCAP_SEC_ASSOCIATION sa[AIRPDCAP_MAX_SEC_ASSOCIATIONS_NR];
- size_t sa_nr;
+ INT sa_index;
AIRPDCAP_KEY_ITEM keys[AIRPDCAP_MAX_KEYS_NR];
size_t keys_nr;
@@ -153,7 +153,6 @@ typedef struct _AIRPDCAP_CONTEXT {
INT index;
INT first_free_index;
- INT last_stored_index;
} AIRPDCAP_CONTEXT, *PAIRPDCAP_CONTEXT;
/************************************************************************/