process_packet(): remove one indent level
This commit is contained in:
parent
c7652bae8d
commit
e12645b1ac
142
src/exchange.c
142
src/exchange.c
|
@ -314,100 +314,100 @@ enum wps_type process_packet(const u_char *packet, struct pcap_pkthdr *header)
|
|||
frame_header = (struct dot11_frame_header *) (packet+rt_header_len);
|
||||
|
||||
/* Does the BSSID/source address match our target BSSID? */
|
||||
if(memcmp(frame_header->addr3, get_bssid(), MAC_ADDR_LEN) == 0)
|
||||
if(memcmp(frame_header->addr3, get_bssid(), MAC_ADDR_LEN) != 0)
|
||||
return UNKNOWN;
|
||||
|
||||
/* Is this a data packet sent to our MAC address? */
|
||||
if (((frame_header->fc & end_htole16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
|
||||
end_htole16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA)) &&
|
||||
(memcmp(frame_header->addr1, get_mac(), MAC_ADDR_LEN) == 0))
|
||||
{
|
||||
/* Is this a data packet sent to our MAC address? */
|
||||
if (((frame_header->fc & end_htole16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
|
||||
end_htole16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA)) &&
|
||||
(memcmp(frame_header->addr1, get_mac(), MAC_ADDR_LEN) == 0))
|
||||
llc = (struct llc_header *) (packet +
|
||||
rt_header_len +
|
||||
sizeof(struct dot11_frame_header)
|
||||
);
|
||||
|
||||
/* All packets in our exchanges will be 802.1x */
|
||||
if(llc->type == end_htobe16(DOT1X_AUTHENTICATION))
|
||||
{
|
||||
llc = (struct llc_header *) (packet +
|
||||
dot1x = (struct dot1X_header *) (packet +
|
||||
rt_header_len +
|
||||
sizeof(struct dot11_frame_header)
|
||||
sizeof(struct dot11_frame_header) +
|
||||
sizeof(struct llc_header)
|
||||
);
|
||||
|
||||
/* All packets in our exchanges will be 802.1x */
|
||||
if(llc->type == end_htobe16(DOT1X_AUTHENTICATION))
|
||||
/* All packets in our exchanges will be EAP packets */
|
||||
if(dot1x->type == DOT1X_EAP_PACKET && (header->len >= EAP_PACKET_SIZE))
|
||||
{
|
||||
dot1x = (struct dot1X_header *) (packet +
|
||||
eap = (struct eap_header *) (packet +
|
||||
rt_header_len +
|
||||
sizeof(struct dot11_frame_header) +
|
||||
sizeof(struct llc_header)
|
||||
sizeof(struct llc_header) +
|
||||
sizeof(struct dot1X_header)
|
||||
);
|
||||
|
||||
/* All packets in our exchanges will be EAP packets */
|
||||
if(dot1x->type == DOT1X_EAP_PACKET && (header->len >= EAP_PACKET_SIZE))
|
||||
/* EAP session termination. Break and move on. */
|
||||
if(eap->code == EAP_FAILURE)
|
||||
{
|
||||
eap = (struct eap_header *) (packet +
|
||||
rt_header_len +
|
||||
sizeof(struct dot11_frame_header) +
|
||||
sizeof(struct llc_header) +
|
||||
sizeof(struct dot1X_header)
|
||||
);
|
||||
type = TERMINATE;
|
||||
}
|
||||
/* If we've received an EAP request and then this should be a WPS message */
|
||||
else if(eap->code == EAP_REQUEST)
|
||||
{
|
||||
/* The EAP header builder needs this ID value */
|
||||
set_eap_id(eap->id);
|
||||
|
||||
/* EAP session termination. Break and move on. */
|
||||
if(eap->code == EAP_FAILURE)
|
||||
/* Stop the receive timer that was started by the last send_packet() */
|
||||
stop_timer();
|
||||
|
||||
/* Check to see if we received an EAP identity request */
|
||||
if(eap->type == EAP_IDENTITY)
|
||||
{
|
||||
type = TERMINATE;
|
||||
}
|
||||
/* If we've received an EAP request and then this should be a WPS message */
|
||||
else if(eap->code == EAP_REQUEST)
|
||||
/* We've initiated an EAP session, so reset the counter */
|
||||
set_eapol_start_count(0);
|
||||
|
||||
type = IDENTITY_REQUEST;
|
||||
}
|
||||
/* An expanded EAP type indicates a probable WPS message */
|
||||
else if((eap->type == EAP_EXPANDED) && (header->len > WFA_PACKET_SIZE))
|
||||
{
|
||||
/* The EAP header builder needs this ID value */
|
||||
set_eap_id(eap->id);
|
||||
wfa = (struct wfa_expanded_header *) (packet +
|
||||
rt_header_len +
|
||||
sizeof(struct dot11_frame_header) +
|
||||
sizeof(struct llc_header) +
|
||||
sizeof(struct dot1X_header) +
|
||||
sizeof(struct eap_header)
|
||||
);
|
||||
|
||||
/* Stop the receive timer that was started by the last send_packet() */
|
||||
stop_timer();
|
||||
|
||||
/* Check to see if we received an EAP identity request */
|
||||
if(eap->type == EAP_IDENTITY)
|
||||
/* Verify that this is a WPS message */
|
||||
if(wfa->type == end_htobe32(SIMPLE_CONFIG))
|
||||
{
|
||||
/* We've initiated an EAP session, so reset the counter */
|
||||
set_eapol_start_count(0);
|
||||
wps_msg_len = (size_t) ntohs(eap->len) -
|
||||
sizeof(struct eap_header) -
|
||||
sizeof(struct wfa_expanded_header);
|
||||
|
||||
type = IDENTITY_REQUEST;
|
||||
}
|
||||
/* An expanded EAP type indicates a probable WPS message */
|
||||
else if((eap->type == EAP_EXPANDED) && (header->len > WFA_PACKET_SIZE))
|
||||
{
|
||||
wfa = (struct wfa_expanded_header *) (packet +
|
||||
rt_header_len +
|
||||
sizeof(struct dot11_frame_header) +
|
||||
sizeof(struct llc_header) +
|
||||
sizeof(struct dot1X_header) +
|
||||
sizeof(struct eap_header)
|
||||
wps_msg = (const void *) (packet +
|
||||
rt_header_len +
|
||||
sizeof(struct dot11_frame_header) +
|
||||
sizeof(struct llc_header) +
|
||||
sizeof(struct dot1X_header) +
|
||||
sizeof(struct eap_header) +
|
||||
sizeof(struct wfa_expanded_header)
|
||||
);
|
||||
|
||||
/* Verify that this is a WPS message */
|
||||
if(wfa->type == end_htobe32(SIMPLE_CONFIG))
|
||||
{
|
||||
wps_msg_len = (size_t) ntohs(eap->len) -
|
||||
sizeof(struct eap_header) -
|
||||
sizeof(struct wfa_expanded_header);
|
||||
|
||||
wps_msg = (const void *) (packet +
|
||||
rt_header_len +
|
||||
sizeof(struct dot11_frame_header) +
|
||||
sizeof(struct llc_header) +
|
||||
sizeof(struct dot1X_header) +
|
||||
sizeof(struct eap_header) +
|
||||
sizeof(struct wfa_expanded_header)
|
||||
);
|
||||
/* Save the current WPS state. This way if we get a NACK message, we can
|
||||
* determine what state we were in when the NACK arrived.
|
||||
*/
|
||||
wps = get_wps();
|
||||
set_last_wps_state(wps->state);
|
||||
set_opcode(wfa->opcode);
|
||||
|
||||
/* Save the current WPS state. This way if we get a NACK message, we can
|
||||
* determine what state we were in when the NACK arrived.
|
||||
*/
|
||||
wps = get_wps();
|
||||
set_last_wps_state(wps->state);
|
||||
set_opcode(wfa->opcode);
|
||||
|
||||
/* Process the WPS message and send a response */
|
||||
type = process_wps_message(wps_msg, wps_msg_len);
|
||||
}
|
||||
/* Process the WPS message and send a response */
|
||||
type = process_wps_message(wps_msg, wps_msg_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue