因为在软件中如何分割一个包可以不一样,但是数据结构都一样。
我们来看下图,eapol的数据包:
如上图我们可以看到,在ethernet frame中,在协议类型Protocol type(0x888e),后面的接着的data封的是
eapol的数据包:
关于eapol的hdr结构,根据上面的图,可以如下设置
/* EAPOL for 802.3/Ethernet */
typedef struct {
struct ether_header eth; /* 802.3/Ethernet header */ 这里是上图ethernet frame的hdr
unsigned char version; /* EAPOL protocol version */
unsigned char type; /* EAPOL type */
unsigned short length; /* Length of body */
unsigned char body[1]; /* Body (optional) */ 这个是optional
} eapol_header_t;
eapol header结束以后,就是eap的封包:
同样对应上面的图:
/* EAP packet format */
typedef struct {
unsigned char code; /* EAP code */
unsigned char id; /* Current request ID */
unsigned short length; /* Length including header */
unsigned char type; /* EAP type (optional) */ 注意这里是optional
unsigned char data[1]; /* Type data (optional) */ 注意这里是optional
} eap_header_t;
我们从上面可以看到这个header的后面两位是图中的eap data。
为什么会有optional,因为eapol,以及eap的数据头不是特别固定,从前面文章的封包图可以看。
例如eapol-key以及eap req 的封包。