aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2007-04-22 18:26:45 +0000
committerGuy Harris <guy@alum.mit.edu>2007-04-22 18:26:45 +0000
commit065be642f4a970c0a12d80d00df7e1e93cbbd254 (patch)
treebe6c6de063a1dea879ce12e960083031c34488d8 /epan
parent6327554e6cf4e78d389bd46bc379572c5f87f872 (diff)
Get rid of some const warnings.
Use the "pnto" macros to fetch 16-bit quantities from a buffer - not only do they have the right casts to avoid const warnings, they also work even on platforms (such as SPARC) where you can't dereference unaligned pointers without a trap. Similarly, compare a possibly-unaligned (we make no alignment guarantees in Wireshark) 16-bit quantity against 0 a byte at a time. svn path=/trunk/; revision=21507
Diffstat (limited to 'epan')
-rw-r--r--epan/crypt/airpdcap.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/epan/crypt/airpdcap.c b/epan/crypt/airpdcap.c
index 796db5d6aa..a73c57da14 100644
--- a/epan/crypt/airpdcap.c
+++ b/epan/crypt/airpdcap.c
@@ -37,6 +37,7 @@
#include <epan/strutil.h>
#include <epan/ws_strsplit.h>
#include <epan/emem.h>
+#include <epan/pint.h>
#include "airpdcap_system.h"
#include "airpdcap_int.h"
@@ -213,12 +214,12 @@ static INT AirPDcapStoreSa(
AIRPDCAP_SEC_ASSOCIATION_ID *id)
;
-static UCHAR * AirPDcapGetStaAddress(
- PAIRPDCAP_MAC_FRAME frame)
+static const UCHAR * AirPDcapGetStaAddress(
+ const AIRPDCAP_MAC_FRAME *frame)
;
-static UCHAR * AirPDcapGetBssidAddress(
- PAIRPDCAP_MAC_FRAME frame)
+static const UCHAR * AirPDcapGetBssidAddress(
+ const AIRPDCAP_MAC_FRAME *frame)
;
static void AirPDcapRsnaPrfX(
@@ -255,7 +256,7 @@ INT AirPDcapPacketProcess(
UINT8 mngDecrypt)
{
size_t mac_header_len;
- UCHAR *address;
+ const UCHAR *address;
AIRPDCAP_SEC_ASSOCIATION_ID id;
INT index;
PAIRPDCAP_SEC_ASSOCIATION sa;
@@ -299,7 +300,7 @@ INT AirPDcapPacketProcess(
}
/* get BSSID */
- if ( (address=AirPDcapGetBssidAddress((PAIRPDCAP_MAC_FRAME)(data+offset))) != NULL) {
+ if ( (address=AirPDcapGetBssidAddress((const AIRPDCAP_MAC_FRAME *)(data+offset))) != NULL) {
memcpy(id.bssid, address, AIRPDCAP_MAC_LEN);
#ifdef _DEBUG
sprintf(msgbuf, "BSSID: %2X.%2X.%2X.%2X.%2X.%2X\t", id.bssid[0],id.bssid[1],id.bssid[2],id.bssid[3],id.bssid[4],id.bssid[5]);
@@ -311,7 +312,7 @@ INT AirPDcapPacketProcess(
}
/* get STA address */
- if ( (address=AirPDcapGetStaAddress((PAIRPDCAP_MAC_FRAME)(data+offset))) != NULL) {
+ if ( (address=AirPDcapGetStaAddress((const AIRPDCAP_MAC_FRAME *)(data+offset))) != NULL) {
memcpy(id.sta, address, AIRPDCAP_MAC_LEN);
#ifdef _DEBUG
sprintf(msgbuf, "ST_MAC: %2X.%2X.%2X.%2X.%2X.%2X\t", id.sta[0],id.sta[1],id.sta[2],id.sta[3],id.sta[4],id.sta[5]);
@@ -371,7 +372,7 @@ INT AirPDcapPacketProcess(
}
/* get and check the body length (IEEE 802.1X-2004, pg. 25) */
- bodyLength=ntohs(*(UINT16 *)(data+offset+2));
+ bodyLength=pntohs(data+offset+2);
if (((len-offset-4)!=bodyLength && !fcsPresent) || ((len-offset-8)!=bodyLength && fcsPresent)) {
AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapPacketProcess", "EAPOL body not valid (wrong length)", AIRPDCAP_DEBUG_LEVEL_5);
return AIRPDCAP_RET_NO_VALID_HANDSHAKE;
@@ -864,7 +865,7 @@ AirPDcapRsna4WHandshake(
/* PATCH: some implementations set secure bit to 0 also in the 4th message */
/* to recognize which message is this check if wep_key data lenght is 0 */
/* in the 4th message */
- if (*(UINT16 *)(data+offset+92)!=0) {
+ if (data[offset+92]!=0 || data[offset+93]!=0) {
/* message 2 */
AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapRsna4WHandshake", "4-way handshake message 2", AIRPDCAP_DEBUG_LEVEL_3);
@@ -917,7 +918,7 @@ AirPDcapRsna4WHandshake(
sa->wpa.ptk);
/* verify the MIC (compare the MIC in the packet included in this message with a MIC calculated with the PTK) */
- eapol_len=(USHORT)(ntohs(*(UINT16 *)(data+offset-3))+4);
+ eapol_len=pntohs(data+offset-3)+4;
memcpy(eapol, &data[offset-5], (eapol_len<AIRPDCAP_EAPOL_MAX_LEN?eapol_len:AIRPDCAP_EAPOL_MAX_LEN));
ret_value=AirPDcapRsnaMicCheck(eapol, /* eapol frame (header also) */
eapol_len, /* eapol frame length */
@@ -1191,9 +1192,9 @@ AirPDcapStoreSa(
return ctx->index;
}
-static UCHAR *
+static const UCHAR *
AirPDcapGetStaAddress(
- PAIRPDCAP_MAC_FRAME frame)
+ const AIRPDCAP_MAC_FRAME *frame)
{
if (AIRPDCAP_TO_DS(frame->fc[1])==0) {
if (AIRPDCAP_FROM_DS(frame->fc[1])==0)
@@ -1208,9 +1209,9 @@ AirPDcapGetStaAddress(
}
}
-static UCHAR *
+static const UCHAR *
AirPDcapGetBssidAddress(
- PAIRPDCAP_MAC_FRAME frame)
+ const AIRPDCAP_MAC_FRAME *frame)
{
if (AIRPDCAP_TO_DS(frame->fc[1])==0) {
if (AIRPDCAP_FROM_DS(frame->fc[1])==0)