#ifndef _EAP8021X_EAP_H
#define _EAP8021X_EAP_H
#include <stdint.h>
#include <sys/types.h>
enum {
kEAPCodeRequest = 1,
kEAPCodeResponse = 2,
kEAPCodeSuccess = 3,
kEAPCodeFailure = 4,
};
typedef uint32_t EAPCode;
enum {
kEAPTypeInvalid = 0,
kEAPTypeIdentity = 1,
kEAPTypeNotification = 2,
kEAPTypeNak = 3,
kEAPTypeMD5Challenge = 4,
kEAPTypeOneTimePassword = 5,
kEAPTypeGenericTokenCard = 6,
kEAPTypeTLS = 13,
kEAPTypeCiscoLEAP = 17,
kEAPTypeEAPSIM = 18,
kEAPTypeSRPSHA1 = 19,
kEAPTypeTTLS = 21,
kEAPTypeEAPAKA = 23,
kEAPTypePEAP = 25,
kEAPTypeMSCHAPv2 = 26,
kEAPTypeExtensions = 33,
kEAPTypeEAPFAST = 43,
};
typedef uint32_t EAPType;
typedef struct EAPPacket_s {
uint8_t code;
uint8_t identifier;
uint8_t length[2];
uint8_t data[0];
} EAPPacket, *EAPPacketRef;
typedef struct EAPSuccessFailurePacket_s {
uint8_t code;
uint8_t identifier;
uint8_t length[2];
} EAPSuccessPacket, *EAPSuccessPacketRef,
EAPFailurePacket, *EAPFailurePacketRef;
typedef struct EAPRequestResponsePacket_s {
uint8_t code;
uint8_t identifier;
uint8_t length[2];
uint8_t type;
uint8_t type_data[0];
} EAPRequestPacket, *EAPRequestPacketRef,
EAPResponsePacket, *EAPResponsePacketRef;
typedef struct EAPNotificationPacket_s {
uint8_t code;
uint8_t identifier;
uint8_t length[2];
uint8_t type;
} EAPNotificationPacket, *EAPNotificationPacketRef;
typedef struct EAPNakPacket_s {
uint8_t code;
uint8_t identifier;
uint8_t length[2];
uint8_t type;
uint8_t desired_type;
} EAPNakPacket, *EAPNakPacketRef;
typedef struct EAPMD5ChallengePacket_s {
uint8_t code;
uint8_t identifier;
uint8_t length[2];
uint8_t type;
uint8_t value_size;
uint8_t value[0];
} EAPMD5ChallengePacket, *EAPMD5ChallengePacketRef;
typedef struct EAPMD5ResponsePacket_s {
uint8_t code;
uint8_t identifier;
uint8_t length[2];
uint8_t type;
uint8_t value_size;
uint8_t value[16];
uint8_t name[0];
} EAPMD5ResponsePacket, *EAPMD5ResponsePacketRef;
static __inline__ void
EAPPacketSetLength(EAPPacketRef pkt, uint16_t length)
{
*((u_short *)pkt->length) = htons(length);
return;
}
static __inline__ uint16_t
EAPPacketGetLength(const EAPPacketRef pkt)
{
return (ntohs(*((u_short *)pkt->length)));
}
#endif