/* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file cp/msg/inc/msg_drv.h * \brief DRV-MME messages * \ingroup cp_msg */ #ifndef msg_drv__h__ #define msg_drv__h__ /* MME message context */ typedef struct { void *user; // user context mfs_rx_t *mfs; // the mfs from the one the MF comes if it comes from the PWL. u8 *buffer; // buffer containing the MME message uint length; // length of MME message //cl_mme_recv_t *mme_recv; // void *cl_mme_data; // data use by the CL } msg_ctx_t; /* enum constants for MME DRV ".CNF" message payload fields */ typedef enum { E_DRVMME_RESULT_FAILURE = 0, E_DRVMME_RESULT_SUCCESS = 1 } e_drv_mme_cnf_result; typedef enum { E_DRVMME_ERRCODE_BAD_PARAMETER = 0, E_DRVMME_ERRCODE_UNKNOWN_ID = 1, E_DRVMME_ERRCODE_INVALID_VALUE = 2 } e_drv_mme_cnf_errcode; /* constants for DRV-MME fields (DRV_STA_SET_TONEMASK.REQ) */ #define TONEMASK_MAXCOUNT 1536 #define TONEMASK_MAXSIZE (TONEMASK_MAXCOUNT / 8) /* MME DRV ".REQ" payloads */ struct mme_drv_sta_set_mac_addr_payload_type { u8 mac_addr[MAC_ADDR_SIZE]; }; typedef struct mme_drv_sta_set_mac_addr_payload_type mme_drv_sta_set_mac_addr_payload_type; struct mme_drv_sta_set_cco_pref_payload_type { u8 cco_pref; }; typedef struct mme_drv_sta_set_cco_pref_payload_type mme_drv_sta_set_cco_pref_payload_type; struct mme_drv_sta_set_was_cco_payload_type { u8 was_cco; }; typedef struct mme_drv_sta_set_was_cco_payload_type mme_drv_sta_set_was_cco_payload_type; struct mme_drv_sta_set_npw_payload_type { char npw[MAX_PWD_SIZE]; }; typedef struct mme_drv_sta_set_npw_payload_type mme_drv_sta_set_npw_payload_type; struct mme_drv_sta_set_dpw_payload_type { char dpw[MAX_PWD_SIZE]; }; typedef struct mme_drv_sta_set_dpw_payload_type mme_drv_sta_set_dpw_payload_type; struct mme_drv_sta_set_sl_payload_type { u8 sl; }; typedef struct mme_drv_sta_set_sl_payload_type mme_drv_sta_set_sl_payload_type; struct mme_drv_sta_set_m_sta_hfid_payload_type { char m_sta_hfid[MAX_HFID_SIZE]; }; typedef struct mme_drv_sta_set_m_sta_hfid_payload_type mme_drv_sta_set_m_sta_hfid_payload_type; struct mme_drv_sta_set_u_sta_hfid_payload_type { char u_sta_hfid[MAX_HFID_SIZE]; }; typedef struct mme_drv_sta_set_u_sta_hfid_payload_type mme_drv_sta_set_u_sta_hfid_payload_type; struct mme_drv_sta_set_avln_hfid_payload_type { char u_sta_hfid[MAX_HFID_SIZE]; }; typedef struct mme_drv_sta_set_avln_hfid_payload_type mme_drv_sta_set_avln_hfid_payload_type; struct mme_drv_sta_set_tonemask_payload_type { u8 sta_tonemask[TONEMASK_MAXSIZE]; }; typedef struct mme_drv_sta_set_tonemask_payload_type mme_drv_sta_set_tonemask_payload_type; /* MME DRV ".REQ" messages */ struct mme_drv_sta_set_mac_addr_req_type { mme_header_type header; u8 mac_addr[MAC_ADDR_SIZE]; }; typedef struct mme_drv_sta_set_mac_addr_req_type mme_drv_sta_set_mac_addr_req_type; struct mme_drv_sta_set_cco_pref_req_type { mme_header_type header; u8 cco_pref; }; typedef struct mme_drv_sta_set_cco_pref_req_type mme_drv_sta_set_cco_pref_req_type; struct mme_drv_sta_set_was_cco_req_type { mme_header_type header; u8 was_cco; }; typedef struct mme_drv_sta_set_was_cco_req_type mme_drv_sta_set_was_cco_req_type; struct mme_drv_sta_set_npw_req_type { mme_header_type header; char npw[MAX_PWD_SIZE]; }; typedef struct mme_drv_sta_set_npw_req_type mme_drv_sta_set_npw_req_type; struct mme_drv_sta_set_dpw_req_type { mme_header_type header; char dpw[MAX_PWD_SIZE]; }; typedef struct mme_drv_sta_set_dpw_req_type mme_drv_sta_set_dpw_req_type; struct mme_drv_sta_set_sl_req_type { mme_header_type header; u8 sl; }; typedef struct mme_drv_sta_set_sl_req_type mme_drv_sta_set_sl_req_type; struct mme_drv_sta_set_m_sta_hfid_req_type { mme_header_type header; char m_sta_hfid[MAX_HFID_SIZE]; }; typedef struct mme_drv_sta_set_m_sta_hfid_req_type mme_drv_sta_set_m_sta_hfid_req_type; struct mme_drv_sta_set_u_sta_hfid_req_type { mme_header_type header; char u_sta_hfid[MAX_HFID_SIZE]; }; typedef struct mme_drv_sta_set_u_sta_hfid_req_type mme_drv_sta_set_u_sta_hfid_req_type; struct mme_drv_sta_set_avln_hfid_req_type { mme_header_type header; char u_sta_hfid[MAX_HFID_SIZE]; }; typedef struct mme_drv_sta_set_avln_hfid_req_type mme_drv_sta_set_avln_hfid_req_type; struct mme_drv_sta_set_tonemask_req_type { mme_header_type header; u8 sta_tonemask[TONEMASK_MAXSIZE]; }; typedef struct mme_drv_sta_set_tonemask_req_type mme_drv_sta_set_tonemask_req_type; struct mme_drv_sta_start_mac_req_type { mme_header_type header; /* (no specific payload data) */ }; typedef struct mme_drv_sta_start_mac_req_type mme_drv_sta_start_mac_req_type; struct mme_drv_sta_stop_mac_req_type { mme_header_type header; /* (no specific payload data) */ }; typedef struct mme_drv_sta_stop_mac_req_type mme_drv_sta_stop_mac_req_type; /* MME DRV ".CNF" message */ struct mme_drv_cnf_type { mme_header_type header; u8 result; u8 errcode; }; typedef struct mme_drv_cnf_type mme_drv_cnf_type; /** * \brief Get DRV-MME .CNF message result string * * \param cnf_result the result code * \return the result code string constant */ char * get_str_drv_mme_cnf_result(int cnf_result); /** * \brief Get DRV-MME .CNF message error code string * * \param cnf_errcode the error code * \return the error code string constant */ char * get_str_drv_mme_cnf_errcode(int cnf_errcode); /** * \brief Get yes/no string. * * \param no_yes the index of yes/no string array * \return the yes or no string constant */ char * get_str_yes_no(int no_yes); /** * \brief Verify a password or HFID string validity. * * \param str the HFID string to be verified * \param minlen the minimal length * \param maxlen the maximal length * \return true or false depending on validity ok or not */ bool check_password_or_hfid_is_valid(char *str, int minlen,int maxlen); /** * \brief little endian to CPU host endian conversion. * * \param addrval pointer to the value to be (re)formatted from little endian to CPU host endian * \param bytesizeval the size in bytes of the value */ void little_to_cpuhost_endian(u8 *addrval, int bytesizeval); /** * \brief big endian to CPU host endian conversion. * * \param addrval pointer to the value to be (re)formatted from big endian to CPU host endian * \param bytesizeval the size in bytes of the value */ void big_to_cpuhost_endian(u8 *addrval, int bytesizeval); /** * \brief CPU host endian to little endian conversion. * * \param addrval pointer to the value to be (re)formatted from CPU host endian to little endian * \param bytesizeval the size in bytes of the value */ void cpuhost_to_little_endian(u8 *addrval, int bytesizeval); /** * \brief CPU host endian to big endian conversion. * * \param addrval pointer to the value to be (re)formatted from CPU host endian to big endian * \param bytesizeval the size in bytes of the value */ void cpuhost_to_big_endian(u8 *addrval, int bytesizeval); u16 big_to_cpuhost_endian_u16(u16 val); u32 big_to_cpuhost_endian_u32(u32 val); u16 cpuhost_to_big_endian_u16(u16 val); u32 cpuhost_to_big_endian_u32(u32 val); void display_mme_header(mme_header_type *mme_header); /** * \brief Build a "MME.CNF" confirmation message. * * \param recv_mme_header the buffer to contain the MME.CNF message being built * \param send_mme the buffer containing the MME initially received for which we're building a CNF * \param cnf_result the result code of the MME.CNF message to be built * \param cnf_errcode the error code of the MME.CNF message to be built * \param cnf_len the returned length of the MME.CNF message being built * */ void cp_mme_build_cnf (mme_header_type *recv_mme_header, mme_drv_cnf_type *send_mme, e_drv_mme_cnf_result cnf_result, e_drv_mme_cnf_errcode cnf_errcode, uint *cnf_len, u8 *mme_tx_buffer, int *mme_buffer_first); #endif