⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eapol.h

📁 source_code 实现无线局域网中的802.1x功能
💻 H
字号:
/**************************************************************************/
/* WIRE1x Version 1.0: A client-side 802.1x implementation                */
/* based on xsupplicant of Open1x for Windows XP, 2000, 98, and Me        */
/*                                                                        */
/* This code is released under both the GPL version 2 and BSD licenses.   */
/* Either license may be used.  The respective licenses are found below.  */
/*                                                                        */
/* Copyright (C) 2004, WIRE Lab, National Tsing Hua Univ., Hsinchu, Taiwan*/
/* All Rights Reserved                                                    */
/**************************************************************************/
/** * A client-side 802.1x implementation supporting EAP/TLS * * This code is released under both the GPL version 2 and BSD licenses. * Either license may be used.  The respective licenses are found below. * * Copyright (C) 2002 Bryan D. Payne & Nick L. Petroni Jr. * All Rights Reserved * * --- GPL Version 2 License --- * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * --- BSD License --- * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * *  - Redistributions of source code must retain the above copyright notice, *    this list of conditions and the following disclaimer. *  - Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. *  - All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *       This product includes software developed by the University of *       Maryland at College Park and its contributors. *  - Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *//*** *** Specifics for EAPOL can be found in Section 7 of  *** IEEE Draft P802.1X/D11, ***/#ifndef _EAPOL_H#define _EAPOL_H#include "eap.h"/*********** MACRO DEFINITIONS ******************/#define MY_ETHER_ADDR_LEN     6         /* 6 bytes to an ETHER address. *//*** EAPOL over 802.11 ***/#define EAP_PACK_TYPE    0x0       /* EAP-Packet EAPOL type *//* this is what is the MAX MTU as defined for CISCO Aironet in PCMCIA-CS */#define EAPOL_MAX_PACKET 2400#define EAPOL_KEY_UNICAST    0x80  /* first bit */#define EAPOL_KEY_INDEX      0x7F  /* last 7 bits *//*** TYPEDEFS ****/typedef enum {LOGOFF, DISCONNECTED, CONNECTING, ACQUIRED, AUTHENTICATING, HELD, AUTHENTICATED } EapolStates;typedef enum{NO_KEY_RECEIVE, KEY_RECEIVE} KeyReceiveStates;/*********** STRUCTURE DEFINITIONS **************//** EAPOL Header  */struct eapol_hdr {  u_char version;  /* EAPOL proto version */  u_char eaptype;  /* EAPOL Packet type */  u_short len;  /* Packet body length */  } ;/** Ethernet Header */struct eth_hdr {
	u_char eth_dst[MY_ETHER_ADDR_LEN];
	u_char eth_src[MY_ETHER_ADDR_LEN];
	u_short eth_type;
};/*** EAPOL key ***/struct eapol_key_header {  u_char type;  u_char length[2];  u_char counter[8];  u_char iv[16];  u_char index;  u_char signature[16];};/*********** FUNCTION PROTOTYPES ****************//**** APPLICATION LAYER API *****/ /* Drivers call these functions *//** * Prepares EAPOL package for use  *  * return: 0 if success  or -1 if fail */int  init_eapol(char *,  /* device name */	   char *,  /* network id */	   u_char *, /* authenticator MAC address */	   char *   /* configuration file to use */	   );/** * Function to start EAPOL process * * return: 0 if authenticated -1 if not */int eapol_authenticate();// Shutdown and clean up.int eapol_shutdown();/** * Function to perform something after successful auth * */voidxsupplicant_post_auth();/** * Funciton to cleanup whatever was started after auth */voidxsupplicant_shutdown_auth();		/**** LOW LEVEL FUNCTIONS****//* Only Functions defined in EAPOL should call these */ // Get the current state of the state machine.EapolStates eapol_get_current_state();// Get the last state of the state machine.  (May be the same as the current// state, depending on how the clock ticks during execution.)EapolStates eapol_get_last_state();  /** * Function to handle an EAPOL KEY PACKET * * return -1 on fail 0 on success */int eapol_process_key(u_char *, int);/**  * Function to perform the necessary 1x Supplicant PAE state action * * return -1 on fail 0 on success */inteapol_pae_do_state();/**  * Function to make necessary 1x Supplicant PAE state transition * * return -1 on fail 0 on success */inteapol_pae_transition_state();voideapol_pae_set_state(EapolStates);/** * Same as above two functions but for key receive states * */inteapol_key_receive_do_state();inteapol_key_receive_transition_state();/** * Function to decode an input packet and  * create the necessary response (if exists) * * Returns 0 on success -1 on failure */inteapol_decode_packet(u_char *); 		/** * Function to bring up specified interface * */inteapol_bringup_interface(char * /* the interface to bring up */		);// This actually builds EAPOL-Start, and EAPOL-Logoff frames.u_char *eapol_create_start_stop_frame(char);const char *eapol_get_dst_mac();int getFailCount();int getSuccessCount();

#endif /* _EAPOL_H_ */
int
eapol_wireless_get_bssid(char *,  /* The device Name */
			 u_char * /* The return BSSID */
			 );

int
eapol_wireless_get_ssid(char *, /* The device Name */
			char *  /* The return ssid */
			);
CString get_current_state();  //for GUI

/*** EOF ***/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -