original files of m241
This commit is contained in:
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_rsn_ie.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_rsn_ie.c,v $
|
||||
* $Author: krosenfe $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_err.h>
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_h.h"
|
||||
#include "ip8021x_rsn_ie.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
Ip_u8 IP8021x_RSN_IE_TKIP[] = { 0x00, 0x0f, 0xac, 0x02 };
|
||||
|
||||
Ip_u8 IP8021x_RSN_IE_PSK[] = { 0x00, 0x0f, 0xac, 0x02 };
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ip8021x_pkt_put_rsn_ie(Ip8021x_pkt* pkt, Ip8021x_rsn_ie* rsn_ie)
|
||||
{
|
||||
int space_left;
|
||||
int rsn_ie_size;
|
||||
Ip_u8* ptr;
|
||||
|
||||
space_left = pkt->len-pkt->end;
|
||||
rsn_ie_size = 1+1+2+4+2+(rsn_ie->pairwise_cipher_suite_len)*4+2
|
||||
+(rsn_ie->auth_key_mgnt_len)*4+2+(rsn_ie->pmkid_len)*16;
|
||||
|
||||
/* is packet large enough to hold rsn_ie? */
|
||||
if(space_left<rsn_ie_size)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ip8021x_pkt_put_rsn_ie :: packet too small to hold rsn_ie, pkt size: %d, rsn_ie size: %d",
|
||||
space_left, rsn_ie_size);
|
||||
return IPCOM_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Is rsn_ie a valid information element? */
|
||||
if(rsn_ie->pairwise_cipher_suite_len<=0 || rsn_ie->pairwise_cipher_suite_len<=0)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ip8021x_pkt_put_rsn_ie :: invalid rsn_ie: cipher_len: %d, akm_len: %d",
|
||||
rsn_ie->pairwise_cipher_suite_len, rsn_ie->pairwise_cipher_suite_len);
|
||||
return IPCOM_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ptr = &pkt->buf[pkt->end];
|
||||
|
||||
*ptr++ = rsn_ie->id;
|
||||
*ptr++ = rsn_ie_size-2; /* id and length fields not included rsn ie length count */
|
||||
ipcom_memcpy(ptr, rsn_ie->version, 6); /* version and group cipher fields */
|
||||
ptr += 6;
|
||||
IP_SET_HTONS(ptr, rsn_ie->pairwise_cipher_suite_len);
|
||||
ptr += 2;
|
||||
ipcom_memcpy(ptr, rsn_ie->pairwise_cipher_suite, (rsn_ie->pairwise_cipher_suite_len)*4);
|
||||
ptr += 4*rsn_ie->pairwise_cipher_suite_len;
|
||||
IP_SET_HTONS(ptr, rsn_ie->auth_key_mgnt_len);
|
||||
ptr += 2;
|
||||
ipcom_memcpy(ptr, rsn_ie->auth_key_mgnt, 4*(rsn_ie->auth_key_mgnt_len));
|
||||
ptr += 4*rsn_ie->auth_key_mgnt_len;
|
||||
IP_SET_HTONS(ptr, rsn_ie->pmkid_len);
|
||||
ptr += 2;
|
||||
if(rsn_ie->pmkid_len != 0)
|
||||
ipcom_memcpy(ptr, rsn_ie->pmkid, 16*(rsn_ie->pmkid_len));
|
||||
|
||||
pkt->end += rsn_ie_size;
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_rsn_ie_set_default
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_rsn_ie_set_default(Ip8021x_rsn_ie* rsn_ie)
|
||||
{
|
||||
|
||||
ipcom_memset(rsn_ie, 0, sizeof(Ip8021x_rsn_ie));
|
||||
|
||||
rsn_ie->id = 0x30;
|
||||
rsn_ie->version[0] = 1;
|
||||
rsn_ie->version[1] = 0;
|
||||
ipcom_memcpy(rsn_ie->grp_cipher_suite, IP8021x_RSN_IE_TKIP, sizeof(IP8021x_RSN_IE_TKIP));
|
||||
(Ip_u16)rsn_ie->pairwise_cipher_suite_len = 1;
|
||||
ipcom_memcpy(rsn_ie->pairwise_cipher_suite, IP8021x_RSN_IE_TKIP, sizeof(IP8021x_RSN_IE_TKIP));
|
||||
(Ip_u16)rsn_ie->auth_key_mgnt_len = 1;
|
||||
ipcom_memcpy(rsn_ie->auth_key_mgnt, IP8021x_RSN_IE_PSK, sizeof(IP8021x_RSN_IE_PSK));
|
||||
(Ip_u16)rsn_ie->rsn_cap = 0;
|
||||
(Ip_u16)rsn_ie->pmkid_len = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user