original files of m241

This commit is contained in:
neelimap
2026-07-30 11:19:44 +05:30
parent 170c2b3f3a
commit afc7070c1f
12254 changed files with 7655111 additions and 0 deletions
@@ -0,0 +1,593 @@
/*
******************************************************************************
* INTERPEAK API HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x.h,v $ $Revision: 1.22 $
* $Source: /home/interpeak/CVSRoot/ip8021x/include/ip8021x.h,v $
* $Author: krosenfe $ $Date: 2010-04-01 20:49:57 $
* $State: Exp $ $Locker: $
*
* Copyright 2000-2006 Interpeak AB (http://www.interpeak.se). All rights reserved.
* Design and implementation by Roger Boden <roger@interpeak.se>
******************************************************************************
*/
#ifndef IP8021X_H
#define IP8021X_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#include <ipcom_sock.h>
#include <ipcom_ipd.h>
#ifdef IPEAP
#include <ipeap.h>
#endif
#include "ip8021x_config.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#ifdef IPWPS
#ifndef IP8021X_AUTH_SUPPORT
#define IP8021X_AUTH_SUPPORT
#define IP8021X_EAP_REQ_MAX_RETRIES 5
#define IP8021X_EAP_REQ_RETRANSMIT_TMO 500
#endif
#endif
#define IP8021X_RELEASE 67000
#ifdef IP8021X_SIM_SUPPORT
#define IP8021X_IFNAMSIZ 128
#else
#define IP8021X_IFNAMSIZ IP_IFNAMSIZ
#endif
#define IP8021X_RELEASE 67000
/* Return codes for ip8021x_state_get */
#define IP8021X_STATE_LOGOFF 1
#define IP8021X_STATE_DISCONNECTED 2
#define IP8021X_STATE_CONNECTING 3
#define IP8021X_STATE_ACQUIRED 4
#define IP8021X_STATE_AUTHENTICATING 5
#define IP8021X_STATE_HELD 6
#define IP8021X_STATE_AUTHENTICATED 7
/* Return codes for ip8021x_pkt_input */
#define IP8021X_EAP_PENDING 1 /* Keep in sync with IPEAP_PENDING_SEND_OUT_PKT */
#define IP8021X_DROPPED_PKT 2 /* Keep in sync with IPEAP_DROPPED_PKT */
#define IP8021X_EAP_SUCCESS 3 /* Keep in sync with IPEAP_SUCCESS */
#define IP8021X_EAP_FAILURE 4 /* Keep in sync with IPEAP_FAILURE */
#define IP8021X_KEY_MSG 20
#define IP8021X_PROCESS_NAME "ip8021x"
/* Deauthentication Reason codes (from IEEE Std 802.11i-2004) */
#define IP8021X_DEAUTH_REASON_MIC_FAILURE 14 /* Michael failure */
#define IP8021X_DEAUTH_REASON_4WAYHS_TIMEOUT 15 /* 4-way handshake timeout */
#define IP8021X_DEAUTH_REASON_IE_MISMATCH 17 /* IE in 4-way handshake doesn't match */
#define IP8021X_MSG1_TIMEOUT 30000 /* In milliseconds*/
#define IP8021X_MAX_SUPPS_BITS 8 /* # of bits used to represent a supplicant instance */
#define IP8021X_MAX_SUPPS (1 << IP8021X_MAX_SUPPS_BITS) /* Maximum # of supported supplicant instances */
#define IP8021X_SUPP_INSTANCE_SHIFT (sizeof(Ip_u32)*8 - IP8021X_MAX_SUPPS_BITS)
#define IP8021X_SUPP_INSTANCE_MASK ((IP8021X_MAX_SUPPS-1) << IP8021X_SUPP_INSTANCE_SHIFT) /* Use upper most bits for a mask */
#define IP8021X_ENCODE_SUPP_INSTANCE(word,inst) (((word) & ~IP8021X_SUPP_INSTANCE_MASK) | ((inst & (IP8021X_MAX_SUPPS-1)) << IP8021X_SUPP_INSTANCE_SHIFT))
#define IP8021X_DECODE_SUPP_INSTANCE(word) ((((word) & IP8021X_SUPP_INSTANCE_MASK) >> IP8021X_SUPP_INSTANCE_SHIFT) & (IP8021X_MAX_SUPPS-1))
#define IP8021X_IPD_EVENT_LOGOFF 100
#define IP8021X_IPD_EVENT_DISCONNECT 101
#define IP8021X_IPD_EVENT_CONNECT 102
#define IP8021X_IPD_EVENT_GETSTATUS 103
#define IP8021X_IPD_EVENT_ADD 104
#define IP8021X_IPD_EVENT_DELETE 105
#define IP8021X_IPD_EVENT_LIST 106
#define IP8021X_IPD_EVENT_EAPCR 107
#define IP8021X_IPD_EVENT_PHYPORT_UP 108
#define IP8021X_IPD_EVENT_PHYPORT_DOWN 109
#define IP8021X_IPD_EVENT_MIC_ERR_PAIR 110
#define IP8021X_IPD_EVENT_MIC_ERR_GRP 111
#define IP8021X_IPD_EVENT_DATAMSG 112
#define IP8021X_IPD_EVENT_WPSON 113 /* Enable WPS mode */
#define IP8021X_IPD_EVENT_WPSOFF 114 /* Disable WPS mode */
#define IP8021X_IPD_EVENT_SEND_EAPOL_START 115
#define IP8021X_IPD_EVENT_AUTH_REG 116 /* Authenticator registration */
#define IP8021X_IPD_EVENT_AUTH_DEREG 117 /* Authenticator de-registration */
/* IPD data message subtypes */
#define IP8021X_IPD_DATAMSG_MIB_SUPP_CFG 1
#define IP8021X_IPD_DATAMSG_MIB_SUPP_STATS 2
#define IP8021X_IPD_DATAMSG_MIB_SUPP_HELD_PERIOD 3
#define IP8021X_IPD_DATAMSG_MIB_SUPP_AUTH_PERIOD 4
#define IP8021X_IPD_DATAMSG_MIB_SUPP_START_PERIOD 5
#define IP8021X_IPD_DATAMSG_MIB_SUPP_MAX_START 6
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/* Forward declarations */
struct Ip8021x_ctx_st;
struct Ip8021x_eapol_key_msg_st;
/*
*===========================================================================
* Ip8021x_pkt
*===========================================================================
* This type represents an 802.1x packet
*/
typedef struct Ip8021x_pkt_st
{
int start; /* Index to first used byte */
int end; /* Index to first free byte */
int len; /* Length of allocated buffer */
int ref; /* No of references to this packet */
Ip_u8* buf;
} Ip8021x_pkt;
#ifdef IP8021X_USE_STATS
/*
*===========================================================================
* Ip8021x_stats
*===========================================================================
* Supplicant statistic counters as defined in 802.1x
*/
typedef struct Ip8021x_stats_st
{
Ip_u32 eapol_frames_recv;
Ip_u32 eapol_frames_tx;
Ip_u32 eapol_start_frames_tx;
Ip_u32 eapol_logoff_frames_tx;
Ip_u32 eapol_resp_id_frames_tx;
Ip_u32 eapol_resp_frames_tx;
Ip_u32 eapol_req_frames_recv;
Ip_u32 eapol_req_id_frames_recv;
#ifdef IP8021X_AUTH_SUPPORT
Ip_u32 eapol_req_id_frames_tx;
Ip_u32 eapol_req_frames_tx;
Ip_u32 eapol_resp_frames_recv;
Ip_u32 eapol_resp_id_frames_recv;
#endif
Ip_u32 eapol_invalid_frames_recv;
Ip_u32 eapol_length_error_frames_recv;
Ip_u32 eapol_key_msg_drops;
Ip_u32 eapol_key_msg_errors;
Ip_u32 eapol_msg1_timeouts;
Ip_u8 eapol_last_frame_version;
Ip_u8 eapol_last_frame_source_addr[6];
Ip_u32 tkip_mic_errors;
Ip_u32 tkip_cm_triggers;
Ip_u32 deauth_reqs;
Ip_u32 eapol_mic_error_report_sent;
Ip_u32 eapol_mic_error_report_fail;
} Ip8021x_stats;
#endif
typedef struct ip8021x_instance_info_st {
Ip_u32 instance_id; /* Identifier for the specified ip8021x instance */
char ifname[IP8021X_IFNAMSIZ]; /* Interface name for the specified ip8021x instance */
Ip_u8 mac_addr[6]; /* Interface mac address for the specified ip8021x instance */
} ip8021x_instance_info;
typedef struct Ip8021x_mib_supp_cfg_st {
int supp_state;
int auth_period;
int held_period;
int start_period;
int max_start;
} Ip8021x_mib_supp_cfg;
#ifdef IP8021X_AUTH_SUPPORT
/* external authenticator uses this message to register/deregister on an interface */
typedef struct ip8021x_auth_reg_st {
char ifname[IP8021X_IFNAMSIZ]; /* interface */
void *assocCallback; /* callback for (dis)association indications */
void *assocCallbackParm;
void *packetCallback; /* callback for incoming EAPOL packets */
void *packetCallbackParm;
Ip_bool assocDereg; /* deregister association callback */
Ip_bool packetDereg; /* deregister packet callback */
} Ip8021x_auth_reg;
#endif
/* For processing MIB messages or
* generic comms to the supplicant */
typedef struct Ip8021x_ipd_msg_st
{
/* This is an overlay struct.
DO NOT MOVE THIS MEMBER! */
Ipcom_ipd_msg ipd_msg;
int subtype;
union {
Ip8021x_mib_supp_cfg supp_cfg;
#ifdef IP8021X_USE_STATS
Ip8021x_stats supp_stats;
#endif
ip8021x_instance_info ip8021x_info;
#ifdef IP8021X_AUTH_SUPPORT
Ip8021x_auth_reg auth_reg;
#endif
} data;
} Ip8021x_ipd_msg;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ip8021x_ctx_new
*===========================================================================
* Description:
* Allocate a new 802.1x context
* Parameters:
* Returns:
* Pointer to a context
* IP_NULL if no new context could be created
*/
IP_PUBLIC struct Ip8021x_ctx_st* ip8021x_ctx_new(void);
/*
*===========================================================================
* ip8021x_ctx_free
*===========================================================================
* Description:
* Free an 802.1x context
* Parameters:
* ctx - pointer to a context
* Returns:
*
*/
IP_PUBLIC void ip8021x_ctx_free(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_ctx_sock_init
*===========================================================================
* Description:
* Initialize the example implementation of the function callbacks,
* based on packet sockets.
* Parameters:
* ctx - pointer to a context
* Returns:
* pointer to a function pointer structure.
* IP_NULL is case of failure
*/
IP_PUBLIC struct Ip8021x_funcs_st* ip8021x_ctx_sock_init(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_wpa_psk_sta_init
*===========================================================================
* Description: Initialize the 802.1x context for use in a wireless
* environment, using WPA-PSK authentication. WPA-PSK
* authentication is sometimes refered to as WPA Personal.
* Parameters:
* ctx - pointer to a context
* Returns:
* IPCOM_SUCCESS if the context was successfully initialized
* < 0 if the initialization failed
*/
IP_PUBLIC Ip_err ip8021x_wpa_psk_sta_init(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_wpa2_psk_sta_init
*===========================================================================
* Description: Initialize the 802.1x context for use in a wireless
* environment, using WPA-PSK authentication. The key exchange
* will be done according to IEEE 802.11i or WPA2.
* Parameters:
* ctx - pointer to a context
* Returns:
* IPCOM_SUCCESS if the context was successfully initialized
* < 0 if the initialization failed
*/
IP_PUBLIC Ip_err ip8021x_wpa2_psk_sta_init(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_wpa_sta_init
*===========================================================================
* Description:
* Initialize the 802.1x context for use in a wireless environment, using
* WPA authentication. WPA authentication is sometimes refered to as WPA
* Enterprise.
* Parameters:
* ctx - pointer to a context
* Returns:
* IPCOM_SUCCESS if the context was successfully initialized
* < 0 if the initialization failed
*
*/
IP_PUBLIC Ip_err ip8021x_wpa_sta_init(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_wpa2_sta_init
*===========================================================================
* Description:
* Initialize the 802.1x context for use in a wireless environment, using
* WPA authentication. The key exchange will be done according to
* IEEE 802.11i or WPA2.
* Parameters:
* ctx - pointer to a context
* Returns:
* IPCOM_SUCCESS if the context was successfully initialized
* < 0 if the initialization failed
*
*/
IP_PUBLIC Ip_err ip8021x_wpa2_sta_init(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_wired_suppl_init
*===========================================================================
* Description:
* Initialize the 802.1x context for use in a wired environment.
* Parameters:
* ctx - pointer to a context
* Returns:
* IPCOM_SUCCESS if the context was successfully initialized
* < 0 if the initialization failed
*/
IP_PUBLIC Ip_err ip8021x_wired_suppl_init(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_wps_suppl_init
*===========================================================================
* Description:
* Initialize the 802.1x context for use in a wps environment.
* Parameters:
* ctx - pointer to a context
* Returns:
* IPCOM_SUCCESS if the context was successfully initialized
* < 0 if the initialization failed
*/
IP_PUBLIC Ip_err ip8021x_wps_suppl_init(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_ctx_set_callbacks
*===========================================================================
* Description:
* Setup the function callbacks for this context.
* Parameters:
* ctx - pointer to a context
* Returns:
* IPCOM_SUCCESS if the callbacks were successfully set
* < 0 in case of failure
*/
IP_PUBLIC Ip_err ip8021x_ctx_set_callbacks(struct Ip8021x_ctx_st *ctx, struct Ip8021x_funcs_st* funcs);
/*
*===========================================================================
* ip8021x_ctx_set_if_name
*===========================================================================
* Description:
* Set the name of the interface this context shall be bound to.
* Parameters:
* ctx - pointer to the context
* if_name - name of the interface that the context shall be bound to.
* Returns:
* IPCOM_SUCCESS if the interface name was successfully set.
* < 0 if the name could not be set.
*/
IP_PUBLIC Ip_err ip8021x_ctx_set_if_name(struct Ip8021x_ctx_st* ctx, const char* if_name);
/*
*===========================================================================
* ip8021x_state_get
*===========================================================================
* Description:
* Returns the 802.1x state of this context
* Parameters:
* ctx - pointer to the context
* Returns:
* IP8021X_STATE_LOGOFF
* IP8021X_STATE_DISCONNECTED
* IP8021X_STATE_CONNECTING
* IP8021X_STATE_ACQUIRED
* IP8021X_STATE_AUTHENTICATING
* IP8021X_STATE_HELD
* IP8021X_STATE_AUTHENTICATED
*/
IP_PUBLIC int ip8021x_state_get(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_port_status_get
*===========================================================================
* Description:
* Returns the 802.1x state of this context
* Parameters:
* ctx - pointer to the context
* Returns:
* IP8021X_PORT_STATUS_AUTHORIZED
* IP8021X_PORT_STATUS_UNAUTHORIZED
*/
IP_PUBLIC int ip8021x_port_status_get(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_cfg_get
*===========================================================================
* Description:
* Returns the supplicant configuration values as defined in IEEE 802.1x
* Parameters:
* ctx - pointer to the 802.1x context
* supp_cfg - pointer to structure where the data will be written
* Returns:
*
*/
IP_PUBLIC void ip8021x_cfg_get(struct Ip8021x_ctx_st* ctx, Ip8021x_mib_supp_cfg* supp_cfg);
#ifdef IP8021X_USE_STATS
/*
*===========================================================================
* ip8021x_stats_get
*===========================================================================
* Description:
* Returns the supplicant statistics counters as defined in IEEE 802.1x
* Parameters:
* ctx - pointer to the 802.1x context
* stats - pointer to structure where the data will be written
* Returns:
*
*/
IP_PUBLIC void ip8021x_stats_get(struct Ip8021x_ctx_st* ctx, Ip8021x_stats* stats);
#endif
/*
*===========================================================================
* ip8021x_pkt_input
*===========================================================================
* Description:
* Processes an incoming 802.1x packet. Any response packet that needs to
* be sent will be sent by calling the output function pointer.
* Parameters:
* ctx - pointer to the 802.1x context
* pkt - pointer to the packet that shall be processed.
* Returns:
* IP8021X_EAP_PENDING - an EAP authentication handshake is in progress.
* IP8021X_DROPPED_PKT - packet dropped
* IP8021X_EAP_SUCCESS - an EAP success message was received from the authenticator
* IP8021X_EAP_FAILURE - an EAP failure message was received from the authenticator
* IP8021X_KEY_MSG - an EAPOL key message was received from the authenticator
*/
IP_PUBLIC Ip_err ip8021x_pkt_input(struct Ip8021x_ctx_st *ctx, Ip8021x_pkt *pkt);
/*
*===========================================================================
* ip8021x_logoff
*===========================================================================
* Description:
* Sends an EAPOL logoff frame and sets the 802.1x context in state
* IP8021X_STATE_LOGOFF which is transitioned to IP8021X_STATE_DISCONNECTED
* Parameters:
* ctx - pointer to the 802.1x context
* Returns:
* IPCOM_SUCCESS
*/
IP_PUBLIC Ip_err ip8021x_logoff(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_connecting
*===========================================================================
* Description:
* Sets the 802.1x context in state IP8021X_STATE_CONNECTING and sends an
* EAPOL-START frame. This function is, for instance, called when the
* link is up.
* Parameters:
* ctx - pointer to the 802.1x context
* Returns:
* IPCOM_SUCCESS
*/
IP_PUBLIC Ip_err ip8021x_connecting(struct Ip8021x_ctx_st* ctx);
/*
*===========================================================================
* ip8021x_disconnected
*===========================================================================
* Sets the 802.1x context in state IP8021X_STATE_DISCONNECTED. This
* function is, for instance, called when the link is down.
* Parameters:
* ctx - pointer to the 802.1x context
* Returns:
* IPCOM_SUCCESS
*/
IP_PUBLIC Ip_err ip8021x_disconnected(struct Ip8021x_ctx_st* ctx);
#ifdef IPWPS
/*
*===========================================================================
* ip8021x_set_wps_mode
*===========================================================================
* Description:
* Enable/Disable WPS mode for a specific 8021x interface.
* During WPS mode, the 8021x module doesn't invoke the IEEE 802.1X state
* machine transitions and just behaves as a passthrough for EAPOL and EAP
* packets.
*
* Parameters:
* char *wps_if - 8021X interface to enable WPS on
* Ip_bool on - IP_TRUE to enable (turn on WPS mode),
* IP_FLASE to disable (turn it off).
* char *wps_eap_id - (optional) EAP Identity to use when creating the EAP context
* ONLY needed when WPS mode is being turned on.
* If NULL, then no identity is set.
* Ip_u32 *ip8021x_instance - Container for IP8021X instance corresponding to the
* WPS interface (valid only upon success)
* Ip_u8 *mac_addr - Ptr to buffer that will hold the Mac Address of the interface
* corresponding to the ip8021x_instance.
* Returns:
* IPCOM_SUCCESS upon success, error indication otherwise
*/
IP_PUBLIC Ip_err ip8021x_set_wps_mode(char *wps_if, Ip_bool on, char *wps_eap_id,
Ip_u32 *ip8021x_instance, Ip_u8 *mac_addr);
#endif
/*
*===========================================================================
* ip8021x_send_eapol_start
*===========================================================================
* Description: Ask the IP8021X module to send an EAPOL START (auth mode only).
* Parameters:
* Ip_u32 instance - IP8021X instance to send the EAPOL START.
* Returns:
* IPCOM_SUCCESS upon success, error indication otherwise
*/
IP_PUBLIC Ip_err ip8021x_send_eapol_start(Ip_u32 instance);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/