Files
kunlun/plc/cvg/nwm/inc/cvg_nwm_sg.h
2024-09-28 14:24:04 +08:00

124 lines
4.7 KiB
C

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef CVG_NWM_SG_H
#define CVG_NWM_SG_H
/* cvg module includes */
#include "cvg_nwm.h"
/* plc includes */
#include "plc_mac_header.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief cvg_nwm_mac_header_init() - init mac header for a sof frame
* @param nwm: nwm vdev pointer
* @param mac: pointer to the mac header
* @param dest_tei: tei of the original destination
* @param send_type: send type of the sof. see ST_XXX
* @param bc_direct: broadcast direction. only available when send type is
* not ST_UNICAST. see BCAST_DIR_XXX.
* @param max_cnt: max send count.
* @param max_hop: maximum allowed hops.
* @param msdu_type: tpye of the msdu inside the sof. see MSDU_TYPE_XXX.
*/
void cvg_nwm_mac_header_init(cvg_vdev_t *vdev, mac_header_t *mac,
tei_t dest_tei, uint8_t send_type, uint8_t bc_direct,
uint8_t max_cnt, uint8_t max_hop, uint8_t msdu_type);
/*
* @brief cvg_nwm_msdu_fwd() - forward a sof frame
* @param vdev: vdev pointer
* @param sof_buf: pkt to be forwarded
* @param mac: pointer to mac header
*/
void cvg_nwm_msdu_fwd(cvg_vdev_t *vdev, cvg_rx_sof_buf_t *sof_buf,
mac_header_t *mac);
/*
* @brief cvg_nwm_sof_decrypt() - decrypt sof_buf
* @param vdev: vdev pointer
* @param sof_buf: the struct contains two fields, buf_encrypted points to the
* buffer to be decrypted, and buf_plaintext points to the
* plaintext buffer to be stored
* @return:
* plaintext -- for success case
* NULL -- for failure case
*/
iot_pkt_t *cvg_nwm_sof_decrypt(cvg_vdev_t *vdev, cvg_rx_sof_buf_t *sof_buf);
/*
* @brief cvg_nwm_sof_pkt_encrypt() - encrypt buf
* @param vdev: vdev pointer
* @param buf: plaintext input buffer and output encrypted buffer
* @param is_cek: encryption type, 1 - cek encrypt, 0 - cmk encrypt
* @param is_app_unicast: the packet sending type is app unicast
* @return:
* ERR_OK -- for success case
* otherwise -- for failure case
*/
uint8_t cvg_nwm_sof_pkt_encrypt(cvg_vdev_t *vdev, iot_pkt_t **buf,
uint8_t is_cek, uint8_t is_app_unicast);
/*
* @brief cvg_nwm_sof_buf_encrypt() - encrypt sof_buf
* @param vdev: vdev pointer
* @param sof_buf: the struct contains two fields, buf_plaintext points to the
* buffer to be encrypted, and buf_encrypted points to the
* ciphertext buffer to be stored
* @param is_cek: encryption type, 1 - cek encrypt, 0 - cmk encrypt
* @param is_app_unicast: the packet sending type is app unicast
* @return:
* ERR_OK -- for success case
* otherwise -- for failure case
*/
uint8_t cvg_nwm_sof_buf_encrypt(cvg_vdev_t *vdev, cvg_rx_sof_buf_t *sof_buf,
uint8_t is_cek, uint8_t is_app_unicast);
/*
* @brief cvg_nwm_sof_encrypt_send() - encrypt and send sof data to mac layer
* @param vdev: the vdev on which data will be sent
* @param tx_info: tx descriptor
* @param msdu_buf: the buffer containing the msdu data to be sent.
* msdu data is containted in data block of the iot_pkt.
* @param is_cek: encryption type, 1 - cek encrypt, 0 - cmk encrypt
* @param is_app_unicast: the packet sending type is app unicast
*
* @return
* ERR_OK - for successful case
* otherwise - for failed case
*/
uint32_t cvg_nwm_sof_encrypt_send(cvg_vdev_t *vdev, mac_tx_info *tx_info,
iot_pkt_t *msdu_buf, uint8_t is_cek, uint8_t is_app_unicast);
/*
* @brief cvg_nwm_sof_single_hop_encrypt_enable() - enable single hop frame
* encryption
* @param vdev: vdev pointer
* @param tx_info: pointer to tx_info to be modified
* @param is_app_unicast: whether the packet being sent is a app unicast packet
*/
void cvg_nwm_sof_single_hop_encrypt_enable(cvg_vdev_t *vdev,
mac_tx_info *tx_info, uint8_t is_app_unicast);
#ifdef __cplusplus
}
#endif
#endif /* CVG_NWM_SG_H */