code
stringlengths 1
1.05M
| repo_name
stringlengths 6
83
| path
stringlengths 3
242
| language
stringclasses 222
values | license
stringclasses 20
values | size
int64 1
1.05M
|
|---|---|---|---|---|---|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_TEST_MP_CONFIG_C_
#include "../../phl_headers.h"
#include "phl_test_mp_def.h"
#include "../../hal_g6/test/mp/hal_test_mp_api.h"
#ifdef CONFIG_PHL_TEST_MP
static enum rtw_phl_status phl_mp_config_start_dut(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_start_dut(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_get_device_info(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_get_dev_info(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_set_phy_idx(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_set_phy_idx(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_get_bw_mode(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_get_bw_mode(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_set_trx_path(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_set_trx_path(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status
phl_mp_config_reset_phy_cnt(struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_reset_phy_cnt(mp);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status
phl_mp_config_reset_mac_cnt(struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_reset_mac_cnt(mp);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status
phl_mp_config_reset_drv_cnt(struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_reset_drv_cnt(mp);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_set_modulation(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_set_modulation(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_get_modulation(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_get_modulation(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_set_rate(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_set_rate(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_get_mac_addr(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_get_mac_addr(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_set_mac_addr(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_set_mac_addr(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_set_ch_bw(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_set_ch_bw(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_get_tx_nss(
struct mp_context *mp, struct mp_config_arg *arg)
{
struct rtw_phl_com_t *phl_com = mp->phl_com;
arg->ant_tx = phl_com->phy_cap[mp->cur_phy].txss;
/* Record the result */
arg->cmd_ok = true;
arg->status = RTW_HAL_STATUS_SUCCESS;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_get_rx_nss(
struct mp_context *mp, struct mp_config_arg *arg)
{
struct rtw_phl_com_t *phl_com = mp->phl_com;
arg->ant_rx = phl_com->phy_cap[mp->cur_phy].rxss;
/* Record the result */
arg->cmd_ok = true;
arg->status = RTW_HAL_STATUS_SUCCESS;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_switch_btc_path(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_config_swith_btc_path(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = RTW_HAL_STATUS_SUCCESS;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_get_rfe_type(
struct mp_context *mp, struct mp_config_arg *arg)
{
struct rtw_phl_com_t *phl_com = mp->phl_com;
arg->rfe_type = phl_com->dev_cap.rfe_type;
/* Record the result */
arg->cmd_ok = true;
arg->status = RTW_HAL_STATUS_SUCCESS;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_config_trigger_fw_conflict(
struct mp_context *mp, struct mp_config_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_trigger_fw_conflict(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = RTW_HAL_STATUS_SUCCESS;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_config_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
enum rtw_phl_status mp_config(struct mp_context *mp,struct mp_config_arg *arg)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
switch(arg->cmd) {
case MP_CONFIG_CMD_START_DUT:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_START_DUT\n", __FUNCTION__);
phl_status = phl_mp_config_start_dut(mp, arg);
break;
case MP_CONFIG_CMD_GET_DEVICE_INFO:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_GET_DEVICE_INFO\n",
__FUNCTION__);
phl_status = phl_mp_config_get_device_info(mp, arg);
break;
case MP_CONFIG_CDM_SET_PHY_INDEX:
PHL_INFO("%s: CMD = MP_CONFIG_CDM_SET_PHY_INDEX\n",
__FUNCTION__);
phl_status = phl_mp_config_set_phy_idx(mp, arg);
break;
case MP_CONFIG_CMD_GET_BW:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_GET_BW\n", __FUNCTION__);
phl_status = phl_mp_config_get_bw_mode(mp, arg);
break;
case MP_CONFIG_CMD_SET_RF_TXRX_PATH:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SET_RF_PATH\n",
__FUNCTION__);
phl_status = phl_mp_config_set_trx_path(mp, arg);
break;
case MP_CONFIG_CMD_SET_RESET_PHY_COUNT:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SET_RESET_PHY_COUNT\n",
__FUNCTION__);
phl_status = phl_mp_config_reset_phy_cnt(mp, arg);
break;
case MP_CONFIG_CMD_SET_RESET_MAC_COUNT:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SET_RESET_MAC_COUNT\n",
__FUNCTION__);
phl_status = phl_mp_config_reset_mac_cnt(mp, arg);
break;
case MP_CONFIG_CMD_SET_RESET_DRV_COUNT:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SET_RESET_DRV_COUNT\n",
__FUNCTION__);
phl_status = phl_mp_config_reset_drv_cnt(mp, arg);
break;
case MP_CONFIG_CMD_SET_MODULATION:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SET_MODULATION\n",
__FUNCTION__);
phl_status = phl_mp_config_set_modulation(mp, arg);
break;
case MP_CONFIG_CMD_GET_MODULATION:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_GET_MODULATION\n",
__FUNCTION__);
phl_status = phl_mp_config_get_modulation(mp, arg);
break;
case MP_CONFIG_CMD_SET_RATE_IDX:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SET_RATE_IDX\n",
__FUNCTION__);
phl_status = phl_mp_config_set_rate(mp, arg);
break;
case MP_CONFIG_CMD_GET_MAC_ADDR:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_GET_MAC_ADDR\n",
__FUNCTION__);
phl_status = phl_mp_config_get_mac_addr(mp, arg);
break;
case MP_CONFIG_CMD_SET_MAC_ADDR:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SET_MAC_ADDR\n",
__FUNCTION__);
phl_status = phl_mp_config_set_mac_addr(mp, arg);
break;
case MP_CONFIG_CMD_SET_CH_BW:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SET_CH_BW\n", __FUNCTION__);
phl_status = phl_mp_config_set_ch_bw(mp, arg);
break;
case MP_CONFIG_CMD_GET_TX_NSS:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_GET_TX_NSS\n", __FUNCTION__);
phl_status = phl_mp_config_get_tx_nss(mp, arg);
break;
case MP_CONFIG_CMD_GET_RX_NSS:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_GET_RX_NSS\n", __FUNCTION__);
phl_status = phl_mp_config_get_rx_nss(mp, arg);
break;
case MP_CONFIG_CMD_SWITCH_BT_PATH:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_SWITCH_BT_PATH\n", __FUNCTION__);
phl_status = phl_mp_config_switch_btc_path(mp, arg);
break;
case MP_CONFIG_CMD_GET_RFE_TYPE:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_GET_RFE_TYPE\n", __FUNCTION__);
phl_status = phl_mp_config_get_rfe_type(mp, arg);
break;
case MP_CONFIG_CMD_TRIGGER_FW_CONFLICT:
PHL_INFO("%s: CMD = MP_CONFIG_CMD_GET_FW_RPT\n", __FUNCTION__);
phl_status = phl_mp_config_trigger_fw_conflict(mp, arg);
break;
default:
PHL_WARN("%s: CMD NOT RECOGNIZED\n", __FUNCTION__);
break;
}
return phl_status;
}
#endif /* CONFIG_PHL_TEST_MP */
|
2301_81045437/rtl8852be
|
phl/test/mp/phl_test_mp_config.c
|
C
|
agpl-3.0
| 12,916
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef _PHL_TEST_MP_DEF_H_
#define _PHL_TEST_MP_DEF_H_
#ifdef CONFIG_PHL_TEST_MP
enum mp_cmd_status {
MP_STATUS_NOT_INIT = 0,
MP_STATUS_INIT = 1,
MP_STATUS_WAIT_CMD = 2,
MP_STATUS_CMD_EVENT = 3,
MP_STATUS_RUN_CMD = 4,
};
/* mp command class */
enum mp_class {
MP_CLASS_CONFIG = 0,
MP_CLASS_TX = 1,
MP_CLASS_RX = 2,
MP_CLASS_EFUSE = 3,
MP_CLASS_REG = 4,
MP_CLASS_TXPWR = 5,
MP_CLASS_CAL = 6,
MP_CLASS_FLASH = 7,
MP_CLASS_MAX,
};
enum mp_tx_method {
MP_SW_TX = 0,
MP_PMACT_TX,
MP_TMACT_TX,
MP_FW_PMAC_TX,
};
enum mp_tx_cmd {
MP_TX_NONE = 0,
MP_TX_PACKETS,
MP_TX_CONTINUOUS,
MP_TX_SINGLE_TONE,
MP_TX_CCK_Carrier_Suppression,
MP_TX_CONFIG_PLCP_COMMON_INFO,
MP_TX_CMD_PHY_OK,
MP_TX_CONFIG_PLCP_PATTERN,
MP_TX_CONFIG_PLCP_USER_INFO,
MP_TX_MODE_SWITCH,
MP_TX_F2P,
MP_TX_TB_TEST,
MP_TX_DPD_BYPASS,
MP_TX_CHECK_TX_IDLE,
MP_TX_CMD_MAX,
};
/* mp config command */
enum mp_config_cmd {
MP_CONFIG_CMD_GET_BW,
MP_CONFIG_CMD_GET_RF_STATUS,
MP_CONFIG_CMD_SET_RATE_IDX,
MP_CONFIG_CMD_SET_RF_TXRX_PATH,
MP_CONFIG_CMD_SET_RESET_PHY_COUNT,
MP_CONFIG_CMD_SET_RESET_MAC_COUNT,
MP_CONFIG_CMD_SET_RESET_DRV_COUNT,
MP_CONFIG_CMD_PBC,
MP_CONFIG_CMD_START_DUT,
MP_CONFIG_CMD_STOP_DUT,
MP_CONFIG_CMD_GET_MIMPO_RSSI,
MP_CONFIG_CMD_GET_BOARD_TYPE,
MP_CONFIG_CMD_GET_MODULATION,
MP_CONFIG_CMD_GET_RF_MODE,
MP_CONFIG_CMD_GET_RF_PATH,
MP_CONFIG_CMD_SET_MODULATION,
MP_CONFIG_CMD_GET_DEVICE_INFO,
MP_CONFIG_CDM_SET_PHY_INDEX,
MP_CONFIG_CMD_GET_MAC_ADDR,
MP_CONFIG_CMD_SET_MAC_ADDR,
MP_CONFIG_CMD_SET_CH_BW,
MP_CONFIG_CMD_GET_TX_NSS,
MP_CONFIG_CMD_GET_RX_NSS,
MP_CONFIG_CMD_SWITCH_BT_PATH,
MP_CONFIG_CMD_GET_RFE_TYPE,
MP_CONFIG_CMD_GET_DEV_IDX,
MP_CONFIG_CMD_TRIGGER_FW_CONFLICT,
MP_CONFIG_CMD_MAX,
};
/* mp rx command */
enum mp_rx_cmd {
MP_RX_CMD_PHY_CRC_OK = 0,
MP_RX_CMD_PHY_CRC_ERR = 1,
MP_RX_CMD_MAC_CRC_OK = 2,
MP_RX_CMD_MAC_CRC_ERR = 3,
MP_RX_CMD_DRV_CRC_OK = 4,
MP_RX_CMD_DRV_CRC_ERR = 5,
MP_RX_CMD_GET_RSSI = 6,
MP_RX_CMD_GET_RXEVM = 7,
MP_RX_CMD_GET_PHYSTS = 8,
MP_RX_CMD_TRIGGER_RXEVM = 9,
MP_RX_CMD_SET_GAIN_OFFSET = 10,
MP_RX_CMD_GET_RSSI_EX = 11,
MP_RX_CMD_MAX,
};
/* mp efuse command */
enum mp_efuse_cmd {
MP_EFUSE_CMD_WIFI_READ = 0,
MP_EFUSE_CMD_WIFI_WRITE = 1,
MP_EFUSE_CMD_WIFI_UPDATE = 2,
MP_EFUSE_CMD_WIFI_UPDATE_MAP = 3,
MP_EFUSE_CMD_WIFI_GET_OFFSET_MASK = 4,
MP_EFUSE_CMD_WIFI_GET_USAGE = 5,
MP_EFUSE_CMD_BT_READ = 6,
MP_EFUSE_CMD_BT_WRITE = 7,
MP_EFUSE_CMD_BT_UPDATE = 8,
MP_EFUSE_CMD_BT_UPDATE_MAP = 9,
MP_EFUSE_CMD_BT_GET_OFFSET_MASK = 10,
MP_EFUSE_CMD_BT_GET_USAGE = 11,
MP_EFUSE_CMD_WIFI_GET_LOG_SIZE = 12,
MP_EFUSE_CMD_WIFI_GET_SIZE = 13,
MP_EFUSE_CMD_WIFI_GET_AVL_SIZE = 14,
MP_EFUSE_CMD_AUTOLOAD_STATUS = 15,
MP_EFUSE_CMD_SHADOW_MAP2BUF = 16,
MP_EFUSE_CMD_FILE_MAP_LOAD = 17,
MP_EFUSE_CMD_FILE_MASK_LOAD = 18,
MP_EFUSE_CMD_GET_INFO = 19,
/* BT */
MP_EFUSE_CMD_BT_GET_LOG_SIZE = 20,
MP_EFUSE_CMD_BT_GET_SIZE = 21,
MP_EFUSE_CMD_BT_GET_AVL_SIZE = 22,
MP_EFUSE_CMD_BT_SHADOW_MAP2BUF = 23,
MP_EFUSE_CMD_BT_FILE_MAP_LOAD = 24,
MP_EFUSE_CMD_BT_FILE_MASK_LOAD = 25,
MP_EFUSE_CMD_BT_READ_HIDDEN = 26,
MP_EFUSE_CMD_BT_WRITE_HIDDEN = 27,
MP_EFUSE_CMD_WIFI_GET_MAP_FROM = 28,
MP_EFUSE_CMD_WIFI_GET_PHY_MAP = 29,
MP_EFUSE_CMD_BT_GET_PHY_MAP = 30,
MP_EFUSE_CMD_WIFI_SET_RENEW = 31,
MP_EFUSE_CMD_MAX,
};
/* mp reg command */
enum mp_reg_cmd {
MP_REG_CMD_READ_MAC = 0,
MP_REG_CMD_WRITE_MAC = 1,
MP_REG_CMD_READ_RF = 2,
MP_REG_CMD_WRITE_RF = 3,
MP_REG_CMD_READ_SYN = 4,
MP_REG_CMD_WRITE_SYN = 5,
MP_REG_CMD_READ_BB = 6,
MP_REG_CMD_WRITE_BB = 7,
MP_REG_CMD_SET_XCAP = 8,
MP_REG_CMD_GET_XCAP = 9,
MP_REG_CMD_GET_XSI=10,
MP_REG_CMD_SET_XSI=11,
MP_REG_CMD_MAX,
};
/* mp tx power command */
enum mp_txpwr_cmd {
MP_TXPWR_CMD_READ_PWR_TABLE = 0,
MP_TXPWR_CMD_GET_PWR_TRACK_STATUS = 1,
MP_TXPWR_CMD_SET_PWR_TRACK_STATUS = 2,
MP_TXPWR_CMD_SET_TXPWR = 3,
MP_TXPWR_CMD_GET_TXPWR = 4,
MP_TXPWR_CMD_GET_TXPWR_INDEX = 5,
MP_TXPWR_CMD_GET_THERMAL = 6,
MP_TXPWR_CMD_GET_TSSI = 7,
MP_TXPWR_CMD_SET_TSSI = 8,
MP_TXPWR_CMD_GET_TXPWR_REF = 9,
MP_TXPWR_CMD_GET_TXPWR_REF_CW = 10,
MP_TXPWR_CMD_SET_TXPWR_INDEX = 11,
MP_TXPWR_CMD_GET_TXINFOPWR = 12,
MP_TXPWR_CMD_SET_RFMODE = 13,
MP_TXPWR_CMD_SET_TSSI_OFFSET = 14,
MP_TXPWR_CMD_GET_ONLINE_TSSI_DE = 15,
MP_TXPWR_CMD_SET_PWR_LMT_EN = 16,
MP_TXPWR_CMD_GET_PWR_LMT_EN = 17,
MP_TXPWR_CMD_SET_TX_POW_PATTERN_SHARP = 18,
MP_TXPWR_CMD_MAX,
};
enum mp_flash_cmd {
MP_FLASH_CMD_WIFI_READ,
MP_FLASH_CMD_WIFI_WRITE,
MP_FLASH_CMD_MAX,
};
/* mp cal command */
enum mp_cal_cmd {
MP_CAL_CMD_TRIGGER_CAL = 0,
MP_CAL_CMD_SET_CAPABILITY_CAL = 1,
MP_CAL_CMD_GET_CAPABILITY_CAL = 2,
MP_CAL_CMD_GET_TSSI_DE_VALUE = 3,
MP_CAL_CMD_SET_TSSI_DE_TX_VERIFY = 4,
MP_CAL_CMD_GET_TXPWR_FINAL_ABS = 5,
MP_CAL_CMD_TRIGGER_DPK_TRACKING = 6,
MP_CAL_CMD_SET_TSSI_AVG = 7,
MP_CAL_CMD_PSD_INIT = 8,
MP_CAL_CMD_PSD_RESTORE = 9,
MP_CAL_CMD_PSD_GET_POINT_DATA = 10,
MP_CAL_CMD_PSD_QUERY = 11,
MP_CAL_CMD_MAX,
};
enum mp_plcp_pattern {
MP_PLCP_PATTERN_1 = 1,
MP_PLCP_PATTERN_2 = 2,
MP_PLCP_PATTERN_MAX,
};
enum mp_calibration_type {
MP_CAL_CHL_RFK = 0,
MP_CAL_DACK = 1,
MP_CAL_IQK = 2,
MP_CAL_LCK = 3,
MP_CAL_DPK = 4,
MP_CAL_DPK_TRACK = 5,
MP_CAL_TSSI = 6,
MP_CAL_GAPK = 7,
MP_CAL_MAX,
};
/*
* Command structure definition.
* Fixed part would be mp_class/cmd/cmd_ok for command and report parsing.
* Data members might have input or output usage.
*/
struct mp_arg_hdr {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 status;
};
struct mp_config_arg {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 status;
u8 channel;
u8 bandwidth;
u8 rate_idx;
u8 ant_tx;
u8 ant_rx;
u8 rf_path;
u8 get_rfstats;
u8 modulation;
u8 bustype;
u32 chipid;
u8 cur_phy;
u8 mac_addr[6];
u8 sc_idx;
u8 dbcc_en;
u8 btc_mode;
u8 rfe_type;
u8 dev_id;
u32 offset;
u8 voltag;
};
struct mp_tx_arg {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 status;
u8 tx_method;
u8 plcp_ppdu_type; //offline gen
u16 plcp_case_id; //offline gen
u8 bCarrierSuppression;
u8 is_cck;
u8 start_tx;
u16 tx_cnt;
u16 period; /* us */
u16 tx_time; /* us */ /* tx duty for FW trigger tx */
u32 tx_ok;
u8 tx_path;
u8 tx_mode; /* mode: 0 = tmac, 1 = pmac */
u8 tx_concurrent_en; /* concurrent tx */
u8 dpd_bypass;
/* plcp info */
u32 dbw; //0:BW20, 1:BW40, 2:BW80, 3:BW160/BW80+80
u32 source_gen_mode;
u32 locked_clk;
u32 dyn_bw;
u32 ndp_en;
u32 long_preamble_en; //bmode
u32 stbc;
u32 gi; //0:0.4,1:0.8,2:1.6,3:3.2
u32 tb_l_len;
u32 tb_ru_tot_sts_max;
u32 vht_txop_not_allowed;
u32 tb_disam;
u32 doppler;
u32 he_ltf_type;//0:1x,1:2x,2:4x
u32 ht_l_len;
u32 preamble_puncture;
u32 he_mcs_sigb;//0~5
u32 he_dcm_sigb;
u32 he_sigb_compress_en;
u32 max_tx_time_0p4us;
u32 ul_flag;
u32 tb_ldpc_extra;
u32 bss_color;
u32 sr;
u32 beamchange_en;
u32 he_er_u106ru_en;
u32 ul_srp1;
u32 ul_srp2;
u32 ul_srp3;
u32 ul_srp4;
u32 mode;
u32 group_id;
u32 ppdu_type;//0: bmode,1:Legacy,2:HT_MF,3:HT_GF,4:VHT,5:HE_SU,6:HE_ER_SU,7:HE_MU,8:HE_TB
u32 txop;
u32 tb_strt_sts;
u32 tb_pre_fec_padding_factor;
u32 cbw;
u32 txsc;
u32 tb_mumimo_mode_en;
u32 nominal_t_pe; // def = 2
u32 ness; // def = 0
u32 n_user;
u32 tb_rsvd;//def = 0
/* plcp user info */
u32 plcp_usr_idx;
u32 mcs;
u32 mpdu_len;
u32 n_mpdu;
u32 fec;
u32 dcm;
u32 aid;
u32 scrambler_seed; // rand (1~255)
u32 random_init_seed; // rand (1~255)
u32 apep;
u32 ru_alloc;
u32 nss;
u32 txbf;
u32 pwr_boost_db;
//struct mp_plcp_param_t plcp_param; //online gen
u32 data_rate;
u8 plcp_sts;
/*HE-TB Test*/
u8 bSS_id_addr0;
u8 bSS_id_addr1;
u8 bSS_id_addr2;
u8 bSS_id_addr3;
u8 bSS_id_addr4;
u8 bSS_id_addr5;
u8 is_link_mode;
/* f2p cmd */
u32 pref_AC_0;
u32 aid12_0;
u32 ul_mcs_0;
u32 macid_0;
u32 ru_pos_0;
u32 ul_fec_code_0;
u32 ul_dcm_0;
u32 ss_alloc_0;
u32 ul_tgt_rssi_0;
u32 pref_AC_1;
u32 aid12_1;
u32 ul_mcs_1;
u32 macid_1;
u32 ru_pos_1;
u32 ul_fec_code_1;
u32 ul_dcm_1;
u32 ss_alloc_1;
u32 ul_tgt_rssi_1;
u32 pref_AC_2;
u32 aid12_2;
u32 ul_mcs_2;
u32 macid_2;
u32 ru_pos_2;
u32 ul_fec_code_2;
u32 ul_dcm_2;
u32 ss_alloc_2;
u32 ul_tgt_rssi_2;
u32 pref_AC_3;
u32 aid12_3;
u32 ul_mcs_3;
u32 macid_3;
u32 ru_pos_3;
u32 ul_fec_code_3;
u32 ul_dcm_3;
u32 ss_alloc_3;
u32 ul_tgt_rssi_3;
u32 ul_bw;
u32 gi_ltf;
u32 num_he_ltf;
u32 ul_stbc;
u32 pkt_doppler;
u32 ap_tx_power;
u32 user_num;
u32 pktnum;
u32 pri20_bitmap;
u32 datarate;
u32 mulport_id;
u32 pwr_ofset;
u32 f2p_mode;
u32 frexch_type;
u32 sigb_len;
/* dword 0 */
u32 cmd_qsel;
u32 ls;
u32 fs;
u32 total_number;
u32 seq;
u32 length;
/* dword 1 */
/* dword 0 */
u32 cmd_type;
u32 cmd_sub_type;
u32 dl_user_num;
u32 bw;
u32 tx_power;
/* dword 1 */
u32 fw_define;
u32 ss_sel_mode;
u32 next_qsel;
u32 twt_group;
u32 dis_chk_slp;
u32 ru_mu_2_su;
u32 dl_t_pe;
/* dword 2 */
u32 sigb_ch1_len;
u32 sigb_ch2_len;
u32 sigb_sym_num;
u32 sigb_ch2_ofs;
u32 dis_htp_ack;
u32 tx_time_ref;
u32 pri_user_idx;
/* dword 3 */
u32 ampdu_max_txtime;
u32 d3_group_id;
u32 twt_chk_en;
u32 twt_port_id;
/* dword 4 */
u32 twt_start_time;
/* dword 5 */
u32 twt_end_time;
/* dword 6 */
u32 apep_len;
u32 tri_pad;
u32 ul_t_pe;
u32 rf_gain_idx;
u32 fixed_gain_en;
u32 ul_gi_ltf;
u32 ul_doppler;
u32 d6_ul_stbc;
/* dword 7 */
u32 ul_mid_per;
u32 ul_cqi_rrp_tri;
u32 sigb_dcm;
u32 sigb_comp;
u32 d7_doppler;
u32 d7_stbc;
u32 mid_per;
u32 gi_ltf_size;
u32 sigb_mcs;
/* dword 8 */
u32 macid_u0;
u32 ac_type_u0;
u32 mu_sta_pos_u0;
u32 dl_rate_idx_u0;
u32 dl_dcm_en_u0;
u32 ru_alo_idx_u0;
/* dword 9 */
u32 pwr_boost_u0;
u32 agg_bmp_alo_u0;
u32 ampdu_max_txnum_u0;
u32 user_define_u0;
u32 user_define_ext_u0;
/* dword 10 */
u32 ul_addr_idx_u0;
u32 ul_dcm_u0;
u32 ul_fec_cod_u0;
u32 ul_ru_rate_u0;
u32 ul_ru_alo_idx_u0;
/* dword 11 */
/* dword 12 */
u32 macid_u1;
u32 ac_type_u1;
u32 mu_sta_pos_u1;
u32 dl_rate_idx_u1;
u32 dl_dcm_en_u1;
u32 ru_alo_idx_u1;
/* dword 13 */
u32 pwr_boost_u1;
u32 agg_bmp_alo_u1;
u32 ampdu_max_txnum_u1;
u32 user_define_u1;
u32 user_define_ext_u1;
/* dword 14 */
u32 ul_addr_idx_u1;
u32 ul_dcm_u1;
u32 ul_fec_cod_u1;
u32 ul_ru_rate_u1;
u32 ul_ru_alo_idx_u1;
/* dword 15 */
/* dword 16 */
u32 macid_u2;
u32 ac_type_u2;
u32 mu_sta_pos_u2;
u32 dl_rate_idx_u2;
u32 dl_dcm_en_u2;
u32 ru_alo_idx_u2;
/* dword 17 */
u32 pwr_boost_u2;
u32 agg_bmp_alo_u2;
u32 ampdu_max_txnum_u2;
u32 user_define_u2;
u32 user_define_ext_u2;
/* dword 18 */
u32 ul_addr_idx_u2;
u32 ul_dcm_u2;
u32 ul_fec_cod_u2;
u32 ul_ru_rate_u2;
u32 ul_ru_alo_idx_u2;
/* dword 19 */
/* dword 20 */
u32 macid_u3;
u32 ac_type_u3;
u32 mu_sta_pos_u3;
u32 dl_rate_idx_u3;
u32 dl_dcm_en_u3;
u32 ru_alo_idx_u3;
/* dword 21 */
u32 pwr_boost_u3;
u32 agg_bmp_alo_u3;
u32 ampdu_max_txnum_u3;
u32 user_define_u3;
u32 user_define_ext_u3;
/* dword 22 */
u32 ul_addr_idx_u3;
u32 ul_dcm_u3;
u32 ul_fec_cod_u3;
u32 ul_ru_rate_u3;
u32 ul_ru_alo_idx_u3;
/* dword 23 */
/* dword 24 */
u32 pkt_id_0;
u32 valid_0;
u32 ul_user_num_0;
/* dword 25 */
u32 pkt_id_1;
u32 valid_1;
u32 ul_user_num_1;
/* dword 26 */
u32 pkt_id_2;
u32 valid_2;
u32 ul_user_num_2;
/* dword 27 */
u32 pkt_id_3;
u32 valid_3;
u32 ul_user_num_3;
/* dword 28 */
u32 pkt_id_4;
u32 valid_4;
u32 ul_user_num_4;
/* dword 29 */
u32 pkt_id_5;
u32 valid_5;
u32 ul_user_num_5;
/* tx state*/
u8 tx_state;
};
struct mp_rx_arg {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 status;
u32 rx_ok;
u32 rx_err;
u8 rssi;
u8 rx_path;
u8 rx_evm;
u8 user;
u8 strm;
u8 rxevm_table;
u8 enable;
u32 phy0_user0_rxevm;
u32 phy0_user1_rxevm;
u32 phy0_user2_rxevm;
u32 phy0_user3_rxevm;
u32 phy1_user0_rxevm;
u32 phy1_user1_rxevm;
u32 phy1_user2_rxevm;
u32 phy1_user3_rxevm;
s8 offset;
u8 rf_path;
u8 iscck;
s16 rssi_ex;
};
struct mp_efuse_arg {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 status;
u8 io_type;
u16 io_offset;
u32 io_value;
u8 autoload;
u8 pfile_path[200];
u16 buf_len;
u8 poutbuf[1536];
};
enum mp_efuse_type {
PHL_MP_EFUSE_WIFI = 0,
PHL_MP_EFUSE_BT,
PHL_MP_EFUSE_NONE,
};
struct mp_reg_arg {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 status;
u32 io_offset;
u32 io_value;
u8 io_type;
u8 ofdm;
u8 rfpath;
u8 sc_xo;
u8 xsi_offset;
u8 xsi_value;
};
struct mp_txpwr_arg {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 status;
s16 txpwr;
u16 txpwr_index;
u8 txpwr_track_status;
u8 txpwr_status;
u32 tssi;
u8 thermal;
u8 rfpath;
u8 ofdm;
u8 tx_path;
u16 rate;
u8 bandwidth;
u8 channel;
s16 table_item; //get an element of power table
u8 dcm;
u8 beamforming;
u8 offset;
s16 txpwr_ref;
u8 is_cck;
u8 rf_mode;
u32 tssi_de_offset;
s32 dbm;
s32 pout;
s32 online_tssi_de;
bool pwr_lmt_en;
u8 sharp_id;
};
struct mp_cal_arg {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 status;
u8 cal_type;
u8 enable;
u8 rfpath;
u16 io_value;
u8 channel;
u8 bandwidth;
s32 xdbm;
u8 path;
u8 iq_path;
u32 avg;
u32 fft;
s32 point;
u32 upoint;
u32 start_point;
u32 stop_point;
u32 buf;
u32 outbuf[450];
};
struct mp_flash_arg {
u8 mp_class;
u8 cmd;
u8 cmd_ok;
u8 io_offset;
u8 io_value;
};
struct rtw_phl_com_t;
struct mp_context {
u8 status;
u8 cur_phy;
u8 rx_physts;
_os_sema mp_cmd_sema;
void *buf;
u32 buf_len;
void *rpt;
u32 rpt_len;
struct test_obj_ctrl_interface mp_test_ctrl;
u8 is_mp_test_end;
struct phl_info_t *phl;
struct rtw_phl_com_t *phl_com;
void *hal;
struct mp_usr_plcp_gen_in usr[4];
};
#endif /* CONFIG_PHL_TEST_MP */
#endif /* _PHL_TEST_MP_DEF_H_ */
|
2301_81045437/rtl8852be
|
phl/test/mp/phl_test_mp_def.h
|
C
|
agpl-3.0
| 14,147
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_TEST_MP_EFUSE_C_
#include "../../phl_headers.h"
#include "phl_test_mp_def.h"
#include "../../hal_g6/test/mp/hal_test_mp_api.h"
#ifdef CONFIG_PHL_TEST_MP
static enum rtw_phl_status phl_mp_efuse_wifi_shadow_read(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_wifi_shadow_read(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_wifi_shadow_write(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_wifi_shadow_write(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_wifi_shadow_update(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_wifi_shadow_update(mp);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_wifi_shadow_reload(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_wifi_shadow_reload(mp);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_wifi_get_offset_mask(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_wifi_get_offset_mask(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_wifi_get_usage(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_wifi_get_usage(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_wifi_get_log_size(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_wifi_get_log_size(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_wifi_get_size(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_wifi_get_size(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_get_avl_size(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_get_avl_size(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_get_shadowmap_from_val(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_get_shadowmap_from_val(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_autoload_status(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_autoload_status(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_shadow_map2buf(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_shadow2buf(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_file_map_load(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
if (_os_strlen(arg->pfile_path) > 0)
hal_status = rtw_hal_mp_efuse_file_map_load(mp, (char*)arg->pfile_path);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_file_mask_load(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
if (_os_strlen(arg->pfile_path) > 0)
hal_status = rtw_hal_mp_efuse_file_mask_load(mp, (char*)arg->pfile_path);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_get_info(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_get_info(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
/*BT Efuses*/
static enum rtw_phl_status phl_mp_efuse_bt_shadow_read(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_shadow_read(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_shadow_write(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_shadow_write(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_shadow_update(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_shadow_update(mp);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_shadow_reload(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_shadow_reload(mp);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_get_offset_mask(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_get_offset_mask(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_get_usage(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_get_usage(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_get_log_size(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_get_log_size(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_get_size(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_get_size(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_get_avl_size(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_get_avl_size(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_shadow_map2buf(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_shadow2buf(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_file_map_load(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
if (_os_strlen(arg->pfile_path) > 0)
hal_status = rtw_hal_mp_efuse_bt_file_map_load(mp, (char*)arg->pfile_path);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_file_mask_load(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
if (_os_strlen(arg->pfile_path) > 0)
hal_status = rtw_hal_mp_efuse_bt_file_mask_load(mp, (char*)arg->pfile_path);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_read_hidden(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_read_hidden(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_bt_write_hidden(
struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_bt_write_hidden(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_raw_read(
struct mp_context *mp, struct mp_efuse_arg *arg, u8 type)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_read_phy_map(mp, arg, type);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_efuse_renew(
struct mp_context *mp, struct mp_efuse_arg *arg, u8 type)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_efuse_renew(mp, arg, type);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_efuse_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
enum rtw_phl_status mp_efuse(struct mp_context *mp, struct mp_efuse_arg *arg)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
switch(arg->cmd) {
case MP_EFUSE_CMD_WIFI_READ:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_READ\n", __FUNCTION__);
phl_status = phl_mp_efuse_wifi_shadow_read(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_WRITE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_WRITE\n", __FUNCTION__);
phl_status = phl_mp_efuse_wifi_shadow_write(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_UPDATE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_UPDATE\n", __FUNCTION__);
phl_status = phl_mp_efuse_wifi_shadow_update(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_UPDATE_MAP:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_UPDATE_MAP\n",
__FUNCTION__);
phl_status = phl_mp_efuse_wifi_shadow_reload(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_GET_OFFSET_MASK:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_GET_OFFSET_MASK\n",
__FUNCTION__);
phl_status = phl_mp_efuse_wifi_get_offset_mask(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_GET_USAGE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_GET_USAGE\n",
__FUNCTION__);
phl_status = phl_mp_efuse_wifi_get_usage(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_GET_LOG_SIZE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_GET_LOG_SIZE\n",
__FUNCTION__);
phl_status = phl_mp_efuse_wifi_get_log_size(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_GET_SIZE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_GET_SIZE\n",
__FUNCTION__);
phl_status = phl_mp_efuse_wifi_get_size(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_GET_AVL_SIZE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_GET_AVL_SIZE\n",
__FUNCTION__);
phl_status = phl_mp_efuse_get_avl_size(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_GET_MAP_FROM:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_GET_MAP_FROM\n",
__FUNCTION__);
phl_status = phl_mp_efuse_get_shadowmap_from_val(mp, arg);
break;
case MP_EFUSE_CMD_AUTOLOAD_STATUS:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_AUTOLOAD_STATUS\n",
__FUNCTION__);
phl_status = phl_mp_efuse_autoload_status(mp, arg);
break;
case MP_EFUSE_CMD_SHADOW_MAP2BUF:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_SHADOW_MAP2BUF\n",
__FUNCTION__);
phl_status = phl_mp_efuse_shadow_map2buf(mp, arg);
break;
case MP_EFUSE_CMD_FILE_MAP_LOAD:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_FILE_MAP_LOAD\n",
__FUNCTION__);
phl_status = phl_mp_efuse_file_map_load(mp, arg);
break;
case MP_EFUSE_CMD_FILE_MASK_LOAD:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_FILE_MASK_LOAD\n",
__FUNCTION__);
phl_status = phl_mp_efuse_file_mask_load(mp, arg);
break;
case MP_EFUSE_CMD_GET_INFO:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_GET_INFO\n",
__FUNCTION__);
phl_status = phl_mp_efuse_get_info(mp, arg);
break;
case MP_EFUSE_CMD_BT_READ:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_READ\n", __FUNCTION__);
phl_status = phl_mp_efuse_bt_shadow_read(mp, arg);
break;
case MP_EFUSE_CMD_BT_WRITE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_WRITE\n", __FUNCTION__);
phl_status = phl_mp_efuse_bt_shadow_write(mp, arg);
break;
case MP_EFUSE_CMD_BT_UPDATE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_UPDATE\n", __FUNCTION__);
phl_status = phl_mp_efuse_bt_shadow_update(mp, arg);
break;
case MP_EFUSE_CMD_BT_UPDATE_MAP:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_UPDATE_MAP\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_shadow_reload(mp, arg);
break;
case MP_EFUSE_CMD_BT_GET_OFFSET_MASK:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_GET_OFFSET_MASK\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_get_offset_mask(mp, arg);
break;
case MP_EFUSE_CMD_BT_GET_USAGE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_GET_USAGE\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_get_usage(mp, arg);
break;
case MP_EFUSE_CMD_BT_GET_LOG_SIZE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_GET_LOG_SIZE\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_get_log_size(mp, arg);
break;
case MP_EFUSE_CMD_BT_GET_SIZE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_GET_SIZE\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_get_size(mp, arg);
break;
case MP_EFUSE_CMD_BT_GET_AVL_SIZE:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_GET_AVL_SIZE\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_get_avl_size(mp, arg);
break;
case MP_EFUSE_CMD_BT_SHADOW_MAP2BUF:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_SHADOW_MAP2BUF\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_shadow_map2buf(mp, arg);
break;
case MP_EFUSE_CMD_BT_FILE_MAP_LOAD:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_FILE_MAP_LOAD\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_file_map_load(mp, arg);
break;
case MP_EFUSE_CMD_BT_FILE_MASK_LOAD:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_FILE_MASK_LOAD\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_file_mask_load(mp, arg);
break;
case MP_EFUSE_CMD_BT_READ_HIDDEN:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_READ_HIDDEN\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_read_hidden(mp, arg);
break;
case MP_EFUSE_CMD_BT_WRITE_HIDDEN:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_WRITE_HIDDEN\n",
__FUNCTION__);
phl_status = phl_mp_efuse_bt_write_hidden(mp, arg);
break;
case MP_EFUSE_CMD_WIFI_GET_PHY_MAP:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_GET_PHY_MAP\n",
__FUNCTION__);
phl_status = phl_mp_efuse_raw_read (mp, arg, PHL_MP_EFUSE_WIFI);
break;
case MP_EFUSE_CMD_BT_GET_PHY_MAP:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_BT_GET_PHY_MAP\n",
__FUNCTION__);
phl_status = phl_mp_efuse_raw_read(mp, arg, PHL_MP_EFUSE_BT);
break;
case MP_EFUSE_CMD_WIFI_SET_RENEW:
PHL_INFO("%s: CMD = MP_EFUSE_CMD_WIFI_SET_RENEW\n",
__FUNCTION__);
phl_status = phl_mp_efuse_renew(mp, arg, PHL_MP_EFUSE_WIFI);
break;
default:
PHL_INFO("%s: UNKNOWN CMD = %d\n", __FUNCTION__, arg->cmd);
break;
}
return phl_status;
}
#endif /* CONFIG_PHL_TEST_MP */
|
2301_81045437/rtl8852be
|
phl/test/mp/phl_test_mp_efuse.c
|
C
|
agpl-3.0
| 20,959
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_TEST_MP_REG_C_
#include "../../phl_headers.h"
#include "phl_test_mp_def.h"
#include "../../hal_g6/test/mp/hal_test_mp_api.h"
#ifdef CONFIG_PHL_TEST_MP
static enum rtw_phl_status phl_mp_reg_read_macreg(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_read_macreg(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_write_macreg(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_write_macreg(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_read_rfreg(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_read_rfreg(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_write_rfreg(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_write_rfreg(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_read_rf_syn(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_read_rf_syn(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_write_rf_syn(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_write_rf_syn(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_read_bbreg(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_read_bbreg(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_write_bbreg(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_write_bbreg(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_get_xcap(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_get_xcap(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_set_xcap(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_set_xcap(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_get_xsi(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_get_xsi(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_reg_set_xsi(
struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_reg_set_xsi(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_reg_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
enum rtw_phl_status mp_reg(struct mp_context *mp, struct mp_reg_arg *arg)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
switch(arg->cmd){
case MP_REG_CMD_READ_MAC:
PHL_INFO("%s: CMD = MP_REG_CMD_READ_MAC\n", __FUNCTION__);
phl_status = phl_mp_reg_read_macreg(mp, arg);
break;
case MP_REG_CMD_WRITE_MAC:
PHL_INFO("%s: CMD = MP_REG_CMD_WRITE_MAC\n", __FUNCTION__);
phl_status = phl_mp_reg_write_macreg(mp, arg);
break;
case MP_REG_CMD_READ_RF:
PHL_INFO("%s: CMD = MP_REG_CMD_READ_RF\n", __FUNCTION__);
phl_status = phl_mp_reg_read_rfreg(mp, arg);
break;
case MP_REG_CMD_WRITE_RF:
PHL_INFO("%s: CMD = MP_REG_CMD_WRITE_RF\n", __FUNCTION__);
phl_status = phl_mp_reg_write_rfreg(mp, arg);
break;
case MP_REG_CMD_READ_SYN:
PHL_INFO("%s: CMD = MP_REG_CMD_READ_SYN\n", __FUNCTION__);
phl_status = phl_mp_reg_read_rf_syn(mp, arg);
break;
case MP_REG_CMD_WRITE_SYN:
PHL_INFO("%s: CMD = MP_REG_CMD_WRITE_SYN\n", __FUNCTION__);
phl_status = phl_mp_reg_write_rf_syn(mp, arg);
break;
case MP_REG_CMD_READ_BB:
PHL_INFO("%s: CMD = MP_REG_CMD_READ_BB\n", __FUNCTION__);
phl_status = phl_mp_reg_read_bbreg(mp, arg);
break;
case MP_REG_CMD_WRITE_BB:
PHL_INFO("%s: CMD = MP_REG_CMD_WRITE_BB\n", __FUNCTION__);
phl_status = phl_mp_reg_write_bbreg(mp, arg);
break;
case MP_REG_CMD_GET_XCAP:
PHL_INFO("%s: CMD = MP_REG_CMD_GET_XCAP\n", __FUNCTION__);
phl_status = phl_mp_reg_get_xcap(mp, arg);
break;
case MP_REG_CMD_SET_XCAP:
PHL_INFO("%s: CMD = MP_REG_CMD_SET_XCAP\n", __FUNCTION__);
phl_status = phl_mp_reg_set_xcap(mp, arg);
break;
case MP_REG_CMD_GET_XSI:
PHL_INFO("%s: CMD = MP_REG_CMD_GET_XSI\n", __FUNCTION__);
phl_status = phl_mp_reg_get_xsi(mp, arg);
break;
case MP_REG_CMD_SET_XSI:
PHL_INFO("%s: CMD = MP_REG_CMD_SET_XSI\n", __FUNCTION__);
phl_status = phl_mp_reg_set_xsi(mp, arg);
break;
default:
PHL_WARN("%s: CMD NOT RECOGNIZED\n", __FUNCTION__);
break;
}
return phl_status;
}
#endif /* CONFIG_PHL_TEST_MP */
|
2301_81045437/rtl8852be
|
phl/test/mp/phl_test_mp_reg.c
|
C
|
agpl-3.0
| 8,085
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_TEST_MP_RX_C_
#include "../../phl_headers.h"
#include "phl_test_mp_def.h"
#include "../../hal_g6/test/mp/hal_test_mp_api.h"
#ifdef CONFIG_PHL_TEST_MP
static enum rtw_phl_status phl_mp_rx_phy_crc_ok(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_phy_crc_ok(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_phy_crc_err(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_phy_crc_err(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_mac_crc_ok(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_mac_crc_ok(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_mac_crc_err(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_mac_crc_err(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_drv_crc_ok(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_drv_crc_ok(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_drv_crc_err(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_drv_crc_err(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_get_rssi(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_get_rssi(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_get_rxevm(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_get_rxevm(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_get_physts(
struct mp_context *mp, struct mp_rx_arg *arg)
{
if(arg->enable) {
mp->rx_physts = true;
}
else {
mp->rx_physts = false;
}
/* Record the result */
arg->cmd_ok = true;
arg->status = RTW_HAL_STATUS_SUCCESS;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
enum rtw_phl_status phl_mp_rx_get_rssi_ex(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_get_rssi_ex(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_trigger_rxevm(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_trigger_rxevm(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_rx_set_gain_offset(
struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_rx_set_gain_offset(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_rx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
enum rtw_phl_status mp_rx(struct mp_context *mp, struct mp_rx_arg *arg)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
switch(arg->cmd){
case MP_RX_CMD_PHY_CRC_OK:
PHL_INFO("%s: CMD = MP_RX_CMD_PHY_CRC_OK\n", __FUNCTION__);
phl_status = phl_mp_rx_phy_crc_ok(mp, arg);
break;
case MP_RX_CMD_PHY_CRC_ERR:
PHL_INFO("%s: CMD = MP_RX_CMD_PHY_CRC_ERR\n", __FUNCTION__);
phl_status = phl_mp_rx_phy_crc_err(mp, arg);
break;
case MP_RX_CMD_MAC_CRC_OK:
PHL_INFO("%s: CMD = MP_RX_CMD_MAC_CRC_OK\n", __FUNCTION__);
phl_status = phl_mp_rx_mac_crc_ok(mp, arg);
break;
case MP_RX_CMD_MAC_CRC_ERR:
PHL_INFO("%s: CMD = MP_RX_CMD_MAC_CRC_ERR\n", __FUNCTION__);
phl_status = phl_mp_rx_mac_crc_err(mp, arg);
break;
case MP_RX_CMD_DRV_CRC_OK:
PHL_INFO("%s: CMD = MP_RX_CMD_DRV_CRC_OK\n", __FUNCTION__);
phl_status = phl_mp_rx_drv_crc_ok(mp, arg);
break;
case MP_RX_CMD_DRV_CRC_ERR:
PHL_INFO("%s: CMD = MP_RX_CMD_DRV_CRC_ERR\n", __FUNCTION__);
phl_status = phl_mp_rx_drv_crc_err(mp, arg);
break;
case MP_RX_CMD_GET_RSSI:
PHL_INFO("%s: CMD = MP_RX_CMD_GET_RSSI\n", __FUNCTION__);
phl_status = phl_mp_rx_get_rssi(mp, arg);
break;
case MP_RX_CMD_GET_RXEVM:
PHL_INFO("%s: CMD = MP_RX_CMD_GET_RXEVM\n", __FUNCTION__);
phl_status = phl_mp_rx_get_rxevm(mp, arg);
break;
case MP_RX_CMD_GET_PHYSTS:
PHL_INFO("%s: CMD = MP_RX_CMD_GET_PHYSTS\n", __FUNCTION__);
phl_status = phl_mp_rx_get_physts(mp, arg);
break;
case MP_RX_CMD_TRIGGER_RXEVM:
PHL_INFO("%s: CMD = MP_RX_CMD_TRIGGER_RXEVM\n", __FUNCTION__);
phl_status = phl_mp_rx_trigger_rxevm(mp, arg);
break;
case MP_RX_CMD_SET_GAIN_OFFSET:
PHL_INFO("%s: CMD = MP_RX_CMD_SET_GAIN_OFFSET\n", __FUNCTION__);
phl_status = phl_mp_rx_set_gain_offset(mp, arg);
break;
case MP_RX_CMD_GET_RSSI_EX:
PHL_INFO("%s: CMD = MP_RX_CMD_GET_RSSI\n", __FUNCTION__);
phl_status = phl_mp_rx_get_rssi(mp, arg);
break;
default:
PHL_WARN("%s: CMD NOT RECOGNIZED\n", __FUNCTION__);
break;
}
return phl_status;
}
#endif /* CONFIG_PHL_TEST_MP */
|
2301_81045437/rtl8852be
|
phl/test/mp/phl_test_mp_rx.c
|
C
|
agpl-3.0
| 8,073
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_TEST_MP_TX_C_
#include "../../phl_headers.h"
#include "phl_test_mp_def.h"
#include "../../hal_g6/test/mp/hal_test_mp_api.h"
#include "../../phl_api.h"
#ifdef CONFIG_PHL_TEST_MP
static enum rtw_phl_status
phl_mp_get_plcp_usr_info(struct mp_context *mp, struct mp_tx_arg *arg)
{
struct rtw_phl_com_t *phl_com = mp->phl_com;
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
int plcp_usr_idx = arg->plcp_usr_idx;
if(arg->nss > phl_com->phy_cap[mp->cur_phy].txss){
hal_status = RTW_HAL_STATUS_FAILURE;
PHL_INFO("%s Invalid NSS %d\n",__FUNCTION__, arg->nss);
}
else{
PHL_INFO("%s arg->plcp_usr_idx = %d\n",__FUNCTION__, arg->plcp_usr_idx);
PHL_INFO("%s arg->mcs = %d\n",__FUNCTION__, arg->mcs);
PHL_INFO("%s arg->mpdu_len = %d\n",__FUNCTION__, arg->mpdu_len);
PHL_INFO("%s arg->n_mpdu = %d\n",__FUNCTION__, arg->n_mpdu);
PHL_INFO("%s arg->fec = %d\n",__FUNCTION__, arg->fec);
PHL_INFO("%s arg->dcm = %d\n",__FUNCTION__, arg->dcm);
PHL_INFO("%s arg->aid = %d\n",__FUNCTION__, arg->aid);
PHL_INFO("%s arg->scrambler_seed = %d\n",__FUNCTION__, arg->scrambler_seed);
PHL_INFO("%s arg->random_init_seed = %d\n",__FUNCTION__, arg->random_init_seed);
PHL_INFO("%s arg->apep = %d\n",__FUNCTION__, arg->apep);
PHL_INFO("%s arg->ru_alloc = %d\n",__FUNCTION__, arg->ru_alloc);
PHL_INFO("%s arg->nss = %d\n",__FUNCTION__, arg->nss);
PHL_INFO("%s arg->txbf = %d\n",__FUNCTION__, arg->txbf);
PHL_INFO("%s arg->pwr_boost_db = %d\n",__FUNCTION__, arg->pwr_boost_db);
/* _os_mem_cpy(mp->phl_com->drv_priv,(void*)(&(mp->usr[plcp_usr_idx])),(void*)((unsigned long)arg+offset1),(offset2-offset1)); */
mp->usr[plcp_usr_idx].mcs = arg->mcs;
mp->usr[plcp_usr_idx].mpdu_len = arg->mpdu_len;
mp->usr[plcp_usr_idx].n_mpdu = arg->n_mpdu;
mp->usr[plcp_usr_idx].fec = arg->fec;
mp->usr[plcp_usr_idx].dcm = arg->dcm;
mp->usr[plcp_usr_idx].aid = arg->aid;
mp->usr[plcp_usr_idx].scrambler_seed = arg->scrambler_seed;
mp->usr[plcp_usr_idx].random_init_seed = arg->random_init_seed;
mp->usr[plcp_usr_idx].apep = arg->apep;
mp->usr[plcp_usr_idx].ru_alloc = arg->ru_alloc;
mp->usr[plcp_usr_idx].nss = arg->nss;
mp->usr[plcp_usr_idx].txbf = arg->txbf;
mp->usr[plcp_usr_idx].pwr_boost_db = arg->pwr_boost_db;
PHL_INFO("%s Copy to user\n",__FUNCTION__);
PHL_INFO("%s plcp_usr_idx = %d\n",__FUNCTION__, plcp_usr_idx);
PHL_INFO("%s mcs = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].mcs);
PHL_INFO("%s mpdu_len = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].mpdu_len);
PHL_INFO("%s n_mpdu = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].n_mpdu);
PHL_INFO("%s fec = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].fec);
PHL_INFO("%s dcm = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].dcm);
PHL_INFO("%s aid = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].aid);
PHL_INFO("%s scrambler_seed = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].scrambler_seed);
PHL_INFO("%s random_init_seed = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].random_init_seed);
PHL_INFO("%s apep = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].apep);
PHL_INFO("%s ru_alloc = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].ru_alloc);
PHL_INFO("%s nss = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].nss);
PHL_INFO("%s txbf = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].txbf);
PHL_INFO("%s pwr_boost_db = %d\n",__FUNCTION__, mp->usr[plcp_usr_idx].pwr_boost_db);
hal_status = RTW_HAL_STATUS_SUCCESS;
}
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static void
phl_mp_get_plcp_common_info(struct mp_context *mp,
struct mp_tx_arg *arg,
struct mp_plcp_param_t *plcp_tx_struct)
{
/*unsigned long offset1 = (unsigned long)(&(((struct mp_tx_arg *)0)->dbw));
unsigned long offset2 = (unsigned long)(&(((struct mp_tx_arg *)0)->tb_rsvd));*/
u8 i = 0;
PHL_INFO("%s=============================\n",__FUNCTION__);
PHL_INFO("%s arg->dbw = %d\n",__FUNCTION__, arg->dbw);
PHL_INFO("%s arg->source_gen_mode = %d\n",__FUNCTION__, arg->source_gen_mode);
PHL_INFO("%s arg->locked_clk = %d\n",__FUNCTION__, arg->locked_clk);
PHL_INFO("%s arg->dyn_bw = %d\n",__FUNCTION__, arg->dyn_bw);
PHL_INFO("%s arg->ndp_en = %d\n",__FUNCTION__, arg->ndp_en);
PHL_INFO("%s arg->long_preamble_en = %d\n",__FUNCTION__, arg->long_preamble_en);
PHL_INFO("%s arg->stbc = %d\n",__FUNCTION__, arg->stbc);
PHL_INFO("%s arg->gi = %d\n",__FUNCTION__, arg->gi);
PHL_INFO("%s arg->tb_l_len = %d\n",__FUNCTION__, arg->tb_l_len);
PHL_INFO("%s arg->tb_ru_tot_sts_max = %d\n",__FUNCTION__, arg->tb_ru_tot_sts_max);
PHL_INFO("%s arg->vht_txop_not_allowed = %d\n",__FUNCTION__, arg->vht_txop_not_allowed);
PHL_INFO("%s arg->tb_disam = %d\n",__FUNCTION__, arg->tb_disam);
PHL_INFO("%s arg->doppler = %d\n",__FUNCTION__, arg->doppler);
PHL_INFO("%s arg->he_ltf_type = %d\n",__FUNCTION__, arg->he_ltf_type);
PHL_INFO("%s arg->ht_l_len = %d\n",__FUNCTION__, arg->ht_l_len);
PHL_INFO("%s arg->preamble_puncture = %d\n",__FUNCTION__, arg->preamble_puncture);
PHL_INFO("%s arg->he_mcs_sigb = %d\n",__FUNCTION__, arg->he_mcs_sigb);
PHL_INFO("%s arg->he_dcm_sigb = %d\n",__FUNCTION__, arg->he_dcm_sigb);
PHL_INFO("%s arg->he_sigb_compress_en = %d\n",__FUNCTION__, arg->he_sigb_compress_en);
PHL_INFO("%s arg->max_tx_time_0p4us = %d\n",__FUNCTION__, arg->max_tx_time_0p4us);
PHL_INFO("%s arg->ul_flag = %d\n",__FUNCTION__, arg->ul_flag);
PHL_INFO("%s arg->tb_ldpc_extra = %d\n",__FUNCTION__, arg->tb_ldpc_extra);
PHL_INFO("%s arg->bss_color = %d\n",__FUNCTION__, arg->bss_color);
PHL_INFO("%s arg->sr = %d\n",__FUNCTION__, arg->sr);
PHL_INFO("%s arg->beamchange_en = %d\n",__FUNCTION__, arg->beamchange_en);
PHL_INFO("%s arg->he_er_u106ru_en = %d\n",__FUNCTION__, arg->he_er_u106ru_en);
PHL_INFO("%s arg->ul_srp1 = %d\n",__FUNCTION__, arg->ul_srp1);
PHL_INFO("%s arg->ul_srp2 = %d\n",__FUNCTION__, arg->ul_srp2);
PHL_INFO("%s arg->ul_srp3 = %d\n",__FUNCTION__, arg->ul_srp3);
PHL_INFO("%s arg->ul_srp4 = %d\n",__FUNCTION__, arg->ul_srp4);
PHL_INFO("%s arg->mode = %d\n",__FUNCTION__, arg->mode);
PHL_INFO("%s arg->group_id = %d\n",__FUNCTION__, arg->group_id);
PHL_INFO("%s arg->ppdu_type = %d\n",__FUNCTION__, arg->ppdu_type);
PHL_INFO("%s arg->txop = %d\n",__FUNCTION__, arg->txop);
PHL_INFO("%s arg->tb_strt_sts = %d\n",__FUNCTION__, arg->tb_strt_sts);
PHL_INFO("%s arg->tb_pre_fec_padding_factor = %d\n",__FUNCTION__, arg->tb_pre_fec_padding_factor);
PHL_INFO("%s arg->cbw = %d\n",__FUNCTION__, arg->cbw);
PHL_INFO("%s arg->txsc = %d\n",__FUNCTION__, arg->txsc);
PHL_INFO("%s arg->tb_mumimo_mode_en = %d\n",__FUNCTION__, arg->tb_mumimo_mode_en);
PHL_INFO("%s arg->nominal_t_pe = %d\n",__FUNCTION__, arg->nominal_t_pe);
PHL_INFO("%s arg->ness = %d\n",__FUNCTION__, arg->ness);
PHL_INFO("%s arg->n_user = %d\n",__FUNCTION__, arg->n_user);
PHL_INFO("%s arg->tb_rsvd = %d\n",__FUNCTION__, arg->tb_rsvd);
PHL_INFO("%s=============================\n",__FUNCTION__);
plcp_tx_struct->dbw = arg->dbw;
plcp_tx_struct->source_gen_mode = arg->source_gen_mode;
plcp_tx_struct->locked_clk = arg->locked_clk;
plcp_tx_struct->dyn_bw = arg->dyn_bw;
plcp_tx_struct->ndp_en = arg->ndp_en;
plcp_tx_struct->long_preamble_en = arg->long_preamble_en;
plcp_tx_struct->stbc = arg->stbc;
plcp_tx_struct->gi = arg->gi;
plcp_tx_struct->tb_l_len = arg->tb_l_len;
plcp_tx_struct->tb_ru_tot_sts_max = arg->tb_ru_tot_sts_max;
plcp_tx_struct->vht_txop_not_allowed = arg->vht_txop_not_allowed;
plcp_tx_struct->tb_disam = arg->tb_disam;
plcp_tx_struct->doppler = arg->doppler;
plcp_tx_struct->he_ltf_type = arg->he_ltf_type;
plcp_tx_struct->ht_l_len = arg->ht_l_len;
plcp_tx_struct->preamble_puncture = arg->preamble_puncture;
plcp_tx_struct->he_mcs_sigb = arg->he_mcs_sigb;
plcp_tx_struct->he_dcm_sigb = arg->he_dcm_sigb;
plcp_tx_struct->he_sigb_compress_en = arg->he_sigb_compress_en;
plcp_tx_struct->max_tx_time_0p4us = arg->max_tx_time_0p4us;
plcp_tx_struct->ul_flag = arg->ul_flag;
plcp_tx_struct->tb_ldpc_extra = arg->tb_ldpc_extra;
plcp_tx_struct->bss_color = arg->bss_color;
plcp_tx_struct->sr = arg->sr;
plcp_tx_struct->beamchange_en = arg->beamchange_en;
plcp_tx_struct->he_er_u106ru_en = arg->he_er_u106ru_en;
plcp_tx_struct->ul_srp1 = arg->ul_srp1;
plcp_tx_struct->ul_srp2 = arg->ul_srp2;
plcp_tx_struct->ul_srp3 = arg->ul_srp3;
plcp_tx_struct->ul_srp4 = arg->ul_srp4;
plcp_tx_struct->mode = arg->mode;
plcp_tx_struct->group_id = arg->group_id;
plcp_tx_struct->ppdu_type = arg->ppdu_type;
plcp_tx_struct->txop = arg->txop;
plcp_tx_struct->tb_strt_sts = arg->tb_strt_sts;
plcp_tx_struct->tb_pre_fec_padding_factor = arg->tb_pre_fec_padding_factor;
plcp_tx_struct->cbw = arg->cbw;
plcp_tx_struct->txsc = arg->txsc;
plcp_tx_struct->tb_mumimo_mode_en = arg->tb_mumimo_mode_en;
plcp_tx_struct->nominal_t_pe = (u8)arg->nominal_t_pe;
plcp_tx_struct->ness = (u8)arg->ness;
plcp_tx_struct->n_user = (u8)arg->n_user;
plcp_tx_struct->tb_rsvd = (u16)arg->tb_rsvd;
#if 0
//copy common info
_os_mem_cpy(mp->phl_com->drv_priv,(void*)(plcp_tx_struct),(void*)((unsigned long)arg+offset1),(offset2-offset1));
#endif
//copy user info
_os_mem_cpy(mp->phl_com->drv_priv, (void *)(&(plcp_tx_struct->usr[0])),(void*)(&(mp->usr[0])),sizeof(struct mp_usr_plcp_gen_in)*4);
for(i = 0; i < 4; i++) {
PHL_INFO("%s=============================\n",__FUNCTION__);
PHL_INFO("%s plcp_usr_idx = %d\n",__FUNCTION__, i);
PHL_INFO("%s mcs = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].mcs);
PHL_INFO("%s mpdu_len = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].mpdu_len);
PHL_INFO("%s n_mpdu = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].n_mpdu);
PHL_INFO("%s fec = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].fec);
PHL_INFO("%s dcm = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].dcm);
PHL_INFO("%s aid = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].aid);
PHL_INFO("%s scrambler_seed = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].scrambler_seed);
PHL_INFO("%s random_init_seed = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].random_init_seed);
PHL_INFO("%s apep = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].apep);
PHL_INFO("%s ru_alloc = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].ru_alloc);
PHL_INFO("%s nss = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].nss);
PHL_INFO("%s txbf = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].txbf);
PHL_INFO("%s pwr_boost_db = %d\n",__FUNCTION__, plcp_tx_struct->usr[i].pwr_boost_db);
PHL_INFO("%s=============================\n",__FUNCTION__);
}
}
static void
phl_mp_get_f2p_test_para(struct mp_context *mp,
struct mp_tx_arg *arg,
struct mp_mac_ax_f2p_test_para *f2p_para_struct)
{
f2p_para_struct->tf_pkt.ul_bw = (u8)arg->ul_bw;
f2p_para_struct->tf_pkt.gi_ltf = (u8)arg->gi_ltf;
f2p_para_struct->tf_pkt.num_he_ltf = (u8)arg->num_he_ltf;
f2p_para_struct->tf_pkt.ul_stbc = (u8)arg->ul_stbc;
f2p_para_struct->tf_pkt.doppler = (u8)arg->pkt_doppler;
f2p_para_struct->tf_pkt.ap_tx_power = (u8)arg->ap_tx_power;
f2p_para_struct->tf_pkt.user_num = (u8)arg->user_num;
f2p_para_struct->tf_pkt.pktnum = (u8)arg->pktnum;
f2p_para_struct->tf_pkt.pri20_bitmap = (u8)arg->pri20_bitmap;
f2p_para_struct->tf_pkt.dep_user[0].pref_AC = (u8)arg->pref_AC_0;
f2p_para_struct->tf_pkt.user[0].aid12 = (u16)arg->aid12_0;
f2p_para_struct->tf_pkt.user[0].ul_mcs = (u16)arg->ul_mcs_0;
f2p_para_struct->tf_pkt.user[0].macid = (u8)arg->macid_0;
f2p_para_struct->tf_pkt.user[0].ru_pos = (u8)arg->ru_pos_0;
f2p_para_struct->tf_pkt.user[0].ul_fec_code = (u8)arg->ul_fec_code_0;
f2p_para_struct->tf_pkt.user[0].ul_dcm = (u8)arg->ul_dcm_0;
f2p_para_struct->tf_pkt.user[0].ss_alloc = (u8)arg->ss_alloc_0;
f2p_para_struct->tf_pkt.user[0].ul_tgt_rssi = (u8)arg->ul_tgt_rssi_0;
f2p_para_struct->tf_pkt.dep_user[1].pref_AC = (u8)arg->pref_AC_1;
f2p_para_struct->tf_pkt.user[1].aid12 = (u16)arg->aid12_1;
f2p_para_struct->tf_pkt.user[1].ul_mcs = (u16)arg->ul_mcs_1;
f2p_para_struct->tf_pkt.user[1].macid = (u8)arg->macid_1;
f2p_para_struct->tf_pkt.user[1].ru_pos = (u8)arg->ru_pos_1;
f2p_para_struct->tf_pkt.user[1].ul_fec_code = (u8)arg->ul_fec_code_1;
f2p_para_struct->tf_pkt.user[1].ul_dcm = (u8)arg->ul_dcm_1;
f2p_para_struct->tf_pkt.user[1].ss_alloc = (u8)arg->ss_alloc_1;
f2p_para_struct->tf_pkt.user[1].ul_tgt_rssi = (u8)arg->ul_tgt_rssi_1;
f2p_para_struct->tf_pkt.dep_user[2].pref_AC = (u8)arg->pref_AC_2;
f2p_para_struct->tf_pkt.user[2].aid12 = (u16)arg->aid12_2;
f2p_para_struct->tf_pkt.user[2].ul_mcs = (u16)arg->ul_mcs_2;
f2p_para_struct->tf_pkt.user[2].macid = (u8)arg->macid_2;
f2p_para_struct->tf_pkt.user[2].ru_pos = (u8)arg->ru_pos_2;
f2p_para_struct->tf_pkt.user[2].ul_fec_code = (u8)arg->ul_fec_code_2;
f2p_para_struct->tf_pkt.user[2].ul_dcm = (u8)arg->ul_dcm_2;
f2p_para_struct->tf_pkt.user[2].ss_alloc = (u8)arg->ss_alloc_2;
f2p_para_struct->tf_pkt.user[2].ul_tgt_rssi = (u8)arg->ul_tgt_rssi_2;
f2p_para_struct->tf_pkt.dep_user[3].pref_AC = (u8)arg->pref_AC_3;
f2p_para_struct->tf_pkt.user[3].aid12 = (u16)arg->aid12_3;
f2p_para_struct->tf_pkt.user[3].ul_mcs = (u16)arg->ul_mcs_3;
f2p_para_struct->tf_pkt.user[3].macid = (u8)arg->macid_3;
f2p_para_struct->tf_pkt.user[3].ru_pos = (u8)arg->ru_pos_3;
f2p_para_struct->tf_pkt.user[3].ul_fec_code = (u8)arg->ul_fec_code_3;
f2p_para_struct->tf_pkt.user[3].ul_dcm = (u8)arg->ul_dcm_3;
f2p_para_struct->tf_pkt.user[3].ss_alloc = (u8)arg->ss_alloc_3;
f2p_para_struct->tf_pkt.user[3].ul_tgt_rssi = (u8)arg->ul_tgt_rssi_3;
f2p_para_struct->tf_wd.datarate = (u16)arg->datarate;
f2p_para_struct->tf_wd.mulport_id = (u16)arg->mulport_id;
f2p_para_struct->tf_wd.pwr_ofset = (u16)arg->pwr_ofset;
f2p_para_struct->mode = (u8)arg->f2p_mode;
f2p_para_struct->frexch_type = (u8)arg->frexch_type;
f2p_para_struct->sigb_len = (u8)arg->sigb_len;
PHL_INFO("%s=============================\n",__FUNCTION__);
PHL_INFO("ul_bw = %d\n", f2p_para_struct->tf_pkt.ul_bw);
PHL_INFO("gi_ltf = %d\n", f2p_para_struct->tf_pkt.gi_ltf);
PHL_INFO("num_he_ltf = %d\n", f2p_para_struct->tf_pkt.num_he_ltf);
PHL_INFO("ul_stbc = %d\n", f2p_para_struct->tf_pkt.ul_stbc);
PHL_INFO("doppler = %d\n", f2p_para_struct->tf_pkt.doppler);
PHL_INFO("ap_tx_power = %d\n", f2p_para_struct->tf_pkt.ap_tx_power);
PHL_INFO("user_num = %d\n", f2p_para_struct->tf_pkt.user_num);
PHL_INFO("pktnum = %d\n", f2p_para_struct->tf_pkt.pktnum);
PHL_INFO("pri20_bitmap = %d\n", f2p_para_struct->tf_pkt.pri20_bitmap);
PHL_INFO("dep_user[0].pref_AC = %d\n",f2p_para_struct->tf_pkt.dep_user[0].pref_AC);
PHL_INFO("user[0].aid12 = %d\n",f2p_para_struct->tf_pkt.user[0].aid12);
PHL_INFO("user[0].ul_mcs = %d\n",f2p_para_struct->tf_pkt.user[0].ul_mcs);
PHL_INFO("user[0].macid = %d\n",f2p_para_struct->tf_pkt.user[0].macid);
PHL_INFO("user[0].ru_pos = %d\n",f2p_para_struct->tf_pkt.user[0].ru_pos);
PHL_INFO("user[0].ul_fec_code = %d\n",f2p_para_struct->tf_pkt.user[0].ul_fec_code);
PHL_INFO("user[0].ul_dcm) = %d\n",f2p_para_struct->tf_pkt.user[0].ul_dcm);
PHL_INFO("user[0].ss_alloc = %d\n",f2p_para_struct->tf_pkt.user[0].ss_alloc);
PHL_INFO("user[0].ul_tgt_rssi = %d\n",f2p_para_struct->tf_pkt.user[0].ul_tgt_rssi);
PHL_INFO("dep_user[1].pref_AC = %d\n",f2p_para_struct->tf_pkt.dep_user[1].pref_AC);
PHL_INFO("user[1].aid12 = %d\n",f2p_para_struct->tf_pkt.user[1].aid12);
PHL_INFO("user[1].ul_mcs = %d\n",f2p_para_struct->tf_pkt.user[1].ul_mcs);
PHL_INFO("user[1].macid = %d\n",f2p_para_struct->tf_pkt.user[1].macid);
PHL_INFO("user[1].ru_pos = %d\n",f2p_para_struct->tf_pkt.user[1].ru_pos);
PHL_INFO("user[1].ul_fec_code = %d\n",f2p_para_struct->tf_pkt.user[1].ul_fec_code);
PHL_INFO("user[1].ul_dcm) = %d\n",f2p_para_struct->tf_pkt.user[1].ul_dcm);
PHL_INFO("user[1].ss_alloc = %d\n",f2p_para_struct->tf_pkt.user[1].ss_alloc);
PHL_INFO("user[1].ul_tgt_rssi = %d\n",f2p_para_struct->tf_pkt.user[1].ul_tgt_rssi);
PHL_INFO("dep_user[2].pref_AC = %d\n",f2p_para_struct->tf_pkt.dep_user[2].pref_AC);
PHL_INFO("user[2].aid12 = %d\n",f2p_para_struct->tf_pkt.user[2].aid12);
PHL_INFO("user[2].ul_mcs = %d\n",f2p_para_struct->tf_pkt.user[2].ul_mcs);
PHL_INFO("user[2].macid = %d\n",f2p_para_struct->tf_pkt.user[2].macid);
PHL_INFO("user[2].ru_pos = %d\n",f2p_para_struct->tf_pkt.user[2].ru_pos);
PHL_INFO("user[2].ul_fec_code = %d\n",f2p_para_struct->tf_pkt.user[2].ul_fec_code);
PHL_INFO("user[2].ul_dcm) = %d\n",f2p_para_struct->tf_pkt.user[2].ul_dcm);
PHL_INFO("user[2].ss_alloc = %d\n",f2p_para_struct->tf_pkt.user[2].ss_alloc);
PHL_INFO("user[2].ul_tgt_rssi = %d\n",f2p_para_struct->tf_pkt.user[2].ul_tgt_rssi);
PHL_INFO("dep_user[3].pref_AC = %d\n",f2p_para_struct->tf_pkt.dep_user[3].pref_AC);
PHL_INFO("user[3].aid12 = %d\n",f2p_para_struct->tf_pkt.user[3].aid12);
PHL_INFO("user[3].ul_mcs = %d\n",f2p_para_struct->tf_pkt.user[3].ul_mcs);
PHL_INFO("user[3].macid = %d\n",f2p_para_struct->tf_pkt.user[3].macid);
PHL_INFO("user[3].ru_pos = %d\n",f2p_para_struct->tf_pkt.user[3].ru_pos);
PHL_INFO("user[3].ul_fec_code = %d\n",f2p_para_struct->tf_pkt.user[3].ul_fec_code);
PHL_INFO("user[3].ul_dcm) = %d\n",f2p_para_struct->tf_pkt.user[3].ul_dcm);
PHL_INFO("user[3].ss_alloc = %d\n",f2p_para_struct->tf_pkt.user[3].ss_alloc);
PHL_INFO("user[3].ul_tgt_rssi = %d\n",f2p_para_struct->tf_pkt.user[3].ul_tgt_rssi);
PHL_INFO("datarate = %d\n", f2p_para_struct->tf_wd.datarate);
PHL_INFO("mulport_id = %d\n", f2p_para_struct->tf_wd.mulport_id);
PHL_INFO("pwr_ofset = %d\n", f2p_para_struct->tf_wd.pwr_ofset);
PHL_INFO("mode = %d\n", f2p_para_struct->mode);
PHL_INFO("frexch_type = %d\n", f2p_para_struct->frexch_type);
PHL_INFO("sigb_len = %d\n", f2p_para_struct->sigb_len);
}
static void
phl_mp_get_f2p_wd(struct mp_context *mp,
struct mp_tx_arg *arg,
struct mp_mac_ax_f2p_wd *f2p_wd_struct)
{
f2p_wd_struct->cmd_qsel = arg->cmd_qsel;
f2p_wd_struct->ls = arg->ls;
f2p_wd_struct->fs = arg->fs;
f2p_wd_struct->total_number = arg->total_number;
f2p_wd_struct->seq = arg->seq;
f2p_wd_struct->length = arg->length;
PHL_INFO("%s=============================\n",__FUNCTION__);
PHL_INFO("cmd_qsel = %d\n", f2p_wd_struct->cmd_qsel);
PHL_INFO("ls = %d\n", f2p_wd_struct->ls);
PHL_INFO("fs = %d\n", f2p_wd_struct->fs);
PHL_INFO("total_number = %d\n", f2p_wd_struct->total_number);
PHL_INFO("seq = %d\n", f2p_wd_struct->seq);
PHL_INFO("length = %d\n", f2p_wd_struct->length);
}
static void
phl_mp_get_f2p_tx_cmd(struct mp_context *mp,
struct mp_tx_arg *arg,
struct mp_mac_ax_f2p_tx_cmd *f2p_tx_cmd_struct)
{
/* dword 0 */
f2p_tx_cmd_struct->cmd_type = arg->cmd_type;
f2p_tx_cmd_struct->cmd_sub_type = arg->cmd_sub_type;
f2p_tx_cmd_struct->dl_user_num = arg->dl_user_num;
f2p_tx_cmd_struct->bw = arg->bw;
f2p_tx_cmd_struct->tx_power = arg->tx_power;
/* dword 1 */
f2p_tx_cmd_struct->fw_define = arg->fw_define;
f2p_tx_cmd_struct->ss_sel_mode = arg->ss_sel_mode;
f2p_tx_cmd_struct->next_qsel = arg->next_qsel;
f2p_tx_cmd_struct->twt_group = arg->twt_group;
f2p_tx_cmd_struct->dis_chk_slp = arg->dis_chk_slp;
f2p_tx_cmd_struct->ru_mu_2_su = arg->ru_mu_2_su;
f2p_tx_cmd_struct->dl_t_pe = arg->dl_t_pe;
/* dword 2 */
f2p_tx_cmd_struct->sigb_ch1_len = arg->sigb_ch1_len;
f2p_tx_cmd_struct->sigb_ch2_len = arg->sigb_ch2_len;
f2p_tx_cmd_struct->sigb_sym_num = arg->sigb_sym_num;
f2p_tx_cmd_struct->sigb_ch2_ofs = arg->sigb_ch2_ofs;
f2p_tx_cmd_struct->dis_htp_ack = arg->dis_htp_ack;
f2p_tx_cmd_struct->tx_time_ref = arg->tx_time_ref;
f2p_tx_cmd_struct->pri_user_idx = arg->pri_user_idx;
/* dword 3 */
f2p_tx_cmd_struct->ampdu_max_txtime = arg->ampdu_max_txtime;
f2p_tx_cmd_struct->group_id = arg->d3_group_id;
f2p_tx_cmd_struct->twt_chk_en = arg->twt_chk_en;
f2p_tx_cmd_struct->twt_port_id = arg->twt_port_id;
/* dword 4 */
f2p_tx_cmd_struct->twt_start_time = arg->twt_start_time;
/* dword 5 */
f2p_tx_cmd_struct->twt_end_time = arg->twt_end_time;
/* dword 6 */
f2p_tx_cmd_struct->apep_len = arg->apep_len;
f2p_tx_cmd_struct->tri_pad = arg->tri_pad;
f2p_tx_cmd_struct->ul_t_pe = arg->ul_t_pe;
f2p_tx_cmd_struct->rf_gain_idx = arg->rf_gain_idx;
f2p_tx_cmd_struct->fixed_gain_en = arg->fixed_gain_en;
f2p_tx_cmd_struct->ul_gi_ltf = arg->ul_gi_ltf;
f2p_tx_cmd_struct->ul_doppler = arg->ul_doppler;
f2p_tx_cmd_struct->ul_stbc = arg->d6_ul_stbc;
/* dword 7 */
f2p_tx_cmd_struct->ul_mid_per = arg->ul_mid_per;
f2p_tx_cmd_struct->ul_cqi_rrp_tri = arg->ul_cqi_rrp_tri;
f2p_tx_cmd_struct->sigb_dcm = arg->sigb_dcm;
f2p_tx_cmd_struct->sigb_comp = arg->sigb_comp;
f2p_tx_cmd_struct->doppler = arg->d7_doppler;
f2p_tx_cmd_struct->stbc = arg->d7_stbc;
f2p_tx_cmd_struct->mid_per = arg->mid_per;
f2p_tx_cmd_struct->gi_ltf_size = arg->gi_ltf_size;
f2p_tx_cmd_struct->sigb_mcs = arg->sigb_mcs;
/* dword 8 */
f2p_tx_cmd_struct->macid_u0 = arg->macid_u0;
f2p_tx_cmd_struct->ac_type_u0 = arg->ac_type_u0;
f2p_tx_cmd_struct->mu_sta_pos_u0 = arg->mu_sta_pos_u0;
f2p_tx_cmd_struct->dl_rate_idx_u0 = arg->dl_rate_idx_u0;
f2p_tx_cmd_struct->dl_dcm_en_u0 = arg->dl_dcm_en_u0;
f2p_tx_cmd_struct->ru_alo_idx_u0 = arg->ru_alo_idx_u0;
/* dword 9 */
f2p_tx_cmd_struct->pwr_boost_u0 = arg->pwr_boost_u0;
f2p_tx_cmd_struct->agg_bmp_alo_u0 = arg->agg_bmp_alo_u0;
f2p_tx_cmd_struct->ampdu_max_txnum_u0 = arg->ampdu_max_txnum_u0;
f2p_tx_cmd_struct->user_define_u0 = arg->user_define_u0;
f2p_tx_cmd_struct->user_define_ext_u0 = arg->user_define_ext_u0;
/* dword 10 */
f2p_tx_cmd_struct->ul_addr_idx_u0 = arg->ul_addr_idx_u0;
f2p_tx_cmd_struct->ul_dcm_u0 = arg->ul_dcm_u0;
f2p_tx_cmd_struct->ul_fec_cod_u0 = arg->ul_fec_cod_u0;
f2p_tx_cmd_struct->ul_ru_rate_u0 = arg->ul_ru_rate_u0;
f2p_tx_cmd_struct->ul_ru_alo_idx_u0 = arg->ul_ru_alo_idx_u0;
/* dword 11 */
/* dword 12 */
f2p_tx_cmd_struct->macid_u1 = arg->macid_u1;
f2p_tx_cmd_struct->ac_type_u1 = arg->ac_type_u1;
f2p_tx_cmd_struct->mu_sta_pos_u1 = arg->mu_sta_pos_u1;
f2p_tx_cmd_struct->dl_rate_idx_u1 = arg->dl_rate_idx_u1;
f2p_tx_cmd_struct->dl_dcm_en_u1 = arg->dl_dcm_en_u1;
f2p_tx_cmd_struct->ru_alo_idx_u1 = arg->ru_alo_idx_u1;
/* dword 13 */
f2p_tx_cmd_struct->pwr_boost_u1 = arg->pwr_boost_u1;
f2p_tx_cmd_struct->agg_bmp_alo_u1 = arg->agg_bmp_alo_u1;
f2p_tx_cmd_struct->ampdu_max_txnum_u1 = arg->ampdu_max_txnum_u1;
f2p_tx_cmd_struct->user_define_u1 = arg->user_define_u1;
f2p_tx_cmd_struct->user_define_ext_u1 = arg->user_define_ext_u1;
/* dword 14 */
f2p_tx_cmd_struct->ul_addr_idx_u1 = arg->ul_addr_idx_u1;
f2p_tx_cmd_struct->ul_dcm_u1 = arg->ul_dcm_u1;
f2p_tx_cmd_struct->ul_fec_cod_u1 = arg->ul_fec_cod_u1;
f2p_tx_cmd_struct->ul_ru_rate_u1 = arg->ul_ru_rate_u1;
f2p_tx_cmd_struct->ul_ru_alo_idx_u1 = arg->ul_ru_alo_idx_u1;
/* dword 15 */
/* dword 16 */
f2p_tx_cmd_struct->macid_u2 = arg->macid_u2;
f2p_tx_cmd_struct->ac_type_u2 = arg->ac_type_u2;
f2p_tx_cmd_struct->mu_sta_pos_u2 = arg->mu_sta_pos_u2;
f2p_tx_cmd_struct->dl_rate_idx_u2 = arg->dl_rate_idx_u2;
f2p_tx_cmd_struct->dl_dcm_en_u2 = arg->dl_dcm_en_u2;
f2p_tx_cmd_struct->ru_alo_idx_u2 = arg->ru_alo_idx_u2;
/* dword 17 */
f2p_tx_cmd_struct->pwr_boost_u2 = arg->pwr_boost_u2;
f2p_tx_cmd_struct->agg_bmp_alo_u2 = arg->agg_bmp_alo_u2;
f2p_tx_cmd_struct->ampdu_max_txnum_u2 = arg->ampdu_max_txnum_u2;
f2p_tx_cmd_struct->user_define_u2 = arg->user_define_u2;
f2p_tx_cmd_struct->user_define_ext_u2 = arg->user_define_ext_u2;
/* dword 18 */
f2p_tx_cmd_struct->ul_addr_idx_u2 = arg->ul_addr_idx_u2;
f2p_tx_cmd_struct->ul_dcm_u2 = arg->ul_dcm_u2;
f2p_tx_cmd_struct->ul_fec_cod_u2 = arg->ul_fec_cod_u2;
f2p_tx_cmd_struct->ul_ru_rate_u2 = arg->ul_ru_rate_u2;
f2p_tx_cmd_struct->ul_ru_alo_idx_u2 = arg->ul_ru_alo_idx_u2;
/* dword 19 */
/* dword 20 */
f2p_tx_cmd_struct->macid_u3 = arg->macid_u3;
f2p_tx_cmd_struct->ac_type_u3 = arg->ac_type_u3;
f2p_tx_cmd_struct->mu_sta_pos_u3 = arg->mu_sta_pos_u3;
f2p_tx_cmd_struct->dl_rate_idx_u3 = arg->dl_rate_idx_u3;
f2p_tx_cmd_struct->dl_dcm_en_u3 = arg->dl_dcm_en_u3;
f2p_tx_cmd_struct->ru_alo_idx_u3 = arg->ru_alo_idx_u3;
/* dword 21 */
f2p_tx_cmd_struct->pwr_boost_u3 = arg->pwr_boost_u3;
f2p_tx_cmd_struct->agg_bmp_alo_u3 = arg->agg_bmp_alo_u3;
f2p_tx_cmd_struct->ampdu_max_txnum_u3 = arg->ampdu_max_txnum_u3;
f2p_tx_cmd_struct->user_define_u3 = arg->user_define_u3;
f2p_tx_cmd_struct->user_define_ext_u3 = arg->user_define_ext_u3;
/* dword 22 */
f2p_tx_cmd_struct->ul_addr_idx_u3 = arg->ul_addr_idx_u3;
f2p_tx_cmd_struct->ul_dcm_u3 = arg->ul_dcm_u3;
f2p_tx_cmd_struct->ul_fec_cod_u3 = arg->ul_fec_cod_u3;
f2p_tx_cmd_struct->ul_ru_rate_u3 = arg->ul_ru_rate_u3;
f2p_tx_cmd_struct->ul_ru_alo_idx_u3 = arg->ul_ru_alo_idx_u3;
/* dword 23 */
/* dword 24 */
f2p_tx_cmd_struct->pkt_id_0 = arg->pkt_id_0;
f2p_tx_cmd_struct->valid_0 = arg->valid_0;
f2p_tx_cmd_struct->ul_user_num_0 = arg->ul_user_num_0;
/* dword 25 */
f2p_tx_cmd_struct->pkt_id_1 = arg->pkt_id_1;
f2p_tx_cmd_struct->valid_1 = arg->valid_1;
f2p_tx_cmd_struct->ul_user_num_1 = arg->ul_user_num_1;
/* dword 26 */
f2p_tx_cmd_struct->pkt_id_2 = arg->pkt_id_2;
f2p_tx_cmd_struct->valid_2 = arg->valid_2;
f2p_tx_cmd_struct->ul_user_num_2 = arg->ul_user_num_2;
/* dword 27 */
f2p_tx_cmd_struct->pkt_id_3 = arg->pkt_id_3;
f2p_tx_cmd_struct->valid_3 = arg->valid_3;
f2p_tx_cmd_struct->ul_user_num_3 = arg->ul_user_num_3;
/* dword 28 */
f2p_tx_cmd_struct->pkt_id_4 = arg->pkt_id_4;
f2p_tx_cmd_struct->valid_4 = arg->valid_4;
f2p_tx_cmd_struct->ul_user_num_4 = arg->ul_user_num_4;
/* dword 29 */
f2p_tx_cmd_struct->pkt_id_5 = arg->pkt_id_5;
f2p_tx_cmd_struct->valid_5 = arg->valid_5;
f2p_tx_cmd_struct->ul_user_num_5 = arg->ul_user_num_5;
PHL_INFO("%s=============================\n",__FUNCTION__);
PHL_INFO("cmd_type = %d\n", f2p_tx_cmd_struct->cmd_type);
PHL_INFO("cmd_sub_type = %d\n", f2p_tx_cmd_struct->cmd_sub_type);
PHL_INFO("dl_user_num = %d\n", f2p_tx_cmd_struct->dl_user_num);
PHL_INFO("bw = %d\n", f2p_tx_cmd_struct->bw);
PHL_INFO("tx_power = %d\n", f2p_tx_cmd_struct->tx_power);
PHL_INFO("fw_define = %d\n", f2p_tx_cmd_struct->fw_define);
PHL_INFO("ss_sel_mode = %d\n", f2p_tx_cmd_struct->ss_sel_mode);
PHL_INFO("next_qsel = %d\n", f2p_tx_cmd_struct->next_qsel);
PHL_INFO("twt_group = %d\n", f2p_tx_cmd_struct->twt_group);
PHL_INFO("dis_chk_slp = %d\n", f2p_tx_cmd_struct->dis_chk_slp);
PHL_INFO("ru_mu_2_su = %d\n", f2p_tx_cmd_struct->ru_mu_2_su);
PHL_INFO("dl_t_pe = %d\n", f2p_tx_cmd_struct->dl_t_pe);
PHL_INFO("sigb_ch1_len = %d\n", f2p_tx_cmd_struct->sigb_ch1_len);
PHL_INFO("sigb_ch2_len = %d\n", f2p_tx_cmd_struct->sigb_ch2_len);
PHL_INFO("sigb_sym_num = %d\n", f2p_tx_cmd_struct->sigb_sym_num);
PHL_INFO("sigb_ch2_ofs = %d\n", f2p_tx_cmd_struct->sigb_ch2_ofs);
PHL_INFO("dis_htp_ack = %d\n", f2p_tx_cmd_struct->dis_htp_ack);
PHL_INFO("tx_time_ref = %d\n", f2p_tx_cmd_struct->tx_time_ref);
PHL_INFO("pri_user_idx = %d\n", f2p_tx_cmd_struct->pri_user_idx);
PHL_INFO("ampdu_max_txtime = %d\n", f2p_tx_cmd_struct->ampdu_max_txtime);
PHL_INFO("group_id = %d\n", f2p_tx_cmd_struct->group_id);
PHL_INFO("twt_chk_en = %d\n", f2p_tx_cmd_struct->twt_chk_en);
PHL_INFO("twt_port_id = %d\n", f2p_tx_cmd_struct->twt_port_id);
PHL_INFO("twt_start_time = %d\n", f2p_tx_cmd_struct->twt_start_time);
PHL_INFO("twt_end_time = %d\n", f2p_tx_cmd_struct->twt_end_time);
PHL_INFO("apep_len = %d\n", f2p_tx_cmd_struct->apep_len);
PHL_INFO("tri_pad = %d\n", f2p_tx_cmd_struct->tri_pad);
PHL_INFO("ul_t_pe = %d\n", f2p_tx_cmd_struct->ul_t_pe);
PHL_INFO("rf_gain_idx = %d\n", f2p_tx_cmd_struct->rf_gain_idx);
PHL_INFO("fixed_gain_en = %d\n", f2p_tx_cmd_struct->fixed_gain_en);
PHL_INFO("ul_gi_ltf = %d\n", f2p_tx_cmd_struct->ul_gi_ltf);
PHL_INFO("ul_doppler = %d\n", f2p_tx_cmd_struct->ul_doppler);
PHL_INFO("ul_stbc = %d\n", f2p_tx_cmd_struct->ul_stbc);
PHL_INFO("ul_mid_per = %d\n", f2p_tx_cmd_struct->ul_mid_per);
PHL_INFO("ul_cqi_rrp_tri = %d\n", f2p_tx_cmd_struct->ul_cqi_rrp_tri);
PHL_INFO("sigb_dcm = %d\n", f2p_tx_cmd_struct->sigb_dcm);
PHL_INFO("sigb_comp = %d\n", f2p_tx_cmd_struct->sigb_comp);
PHL_INFO("doppler = %d\n", f2p_tx_cmd_struct->doppler);
PHL_INFO("stbc = %d\n", f2p_tx_cmd_struct->stbc);
PHL_INFO("mid_per = %d\n", f2p_tx_cmd_struct->mid_per);
PHL_INFO("gi_ltf_size = %d\n", f2p_tx_cmd_struct->gi_ltf_size);
PHL_INFO("sigb_mcs = %d\n", f2p_tx_cmd_struct->sigb_mcs);
PHL_INFO("macid_u0 = %d\n", f2p_tx_cmd_struct->macid_u0);
PHL_INFO("ac_type_u0 = %d\n", f2p_tx_cmd_struct->ac_type_u0);
PHL_INFO("mu_sta_pos_u0 = %d\n", f2p_tx_cmd_struct->mu_sta_pos_u0);
PHL_INFO("dl_rate_idx_u0 = %d\n", f2p_tx_cmd_struct->dl_rate_idx_u0);
PHL_INFO("dl_dcm_en_u0 = %d\n", f2p_tx_cmd_struct->dl_dcm_en_u0);
PHL_INFO("ru_alo_idx_u0 = %d\n", f2p_tx_cmd_struct->ru_alo_idx_u0);
PHL_INFO("pwr_boost_u0 = %d\n", f2p_tx_cmd_struct->pwr_boost_u0);
PHL_INFO("agg_bmp_alo_u0 = %d\n", f2p_tx_cmd_struct->agg_bmp_alo_u0);
PHL_INFO("ampdu_max_txnum_u0 = %d\n", f2p_tx_cmd_struct->ampdu_max_txnum_u0);
PHL_INFO("user_define_u0 = %d\n", f2p_tx_cmd_struct->user_define_u0);
PHL_INFO("user_define_ext_u0 = %d\n", f2p_tx_cmd_struct->user_define_ext_u0);
PHL_INFO("ul_addr_idx_u0 = %d\n", f2p_tx_cmd_struct->ul_addr_idx_u0);
PHL_INFO("ul_dcm_u0 = %d\n", f2p_tx_cmd_struct->ul_dcm_u0);
PHL_INFO("ul_fec_cod_u0 = %d\n", f2p_tx_cmd_struct->ul_fec_cod_u0);
PHL_INFO("ul_ru_rate_u0 = %d\n", f2p_tx_cmd_struct->ul_ru_rate_u0);
PHL_INFO("ul_ru_alo_idx_u0 = %d\n", f2p_tx_cmd_struct->ul_ru_alo_idx_u0);
PHL_INFO("macid_u1 = %d\n", f2p_tx_cmd_struct->macid_u1);
PHL_INFO("ac_type_u1 = %d\n", f2p_tx_cmd_struct->ac_type_u1);
PHL_INFO("mu_sta_pos_u1 = %d\n", f2p_tx_cmd_struct->mu_sta_pos_u1);
PHL_INFO("dl_rate_idx_u1 = %d\n", f2p_tx_cmd_struct->dl_rate_idx_u1);
PHL_INFO("dl_dcm_en_u1 = %d\n", f2p_tx_cmd_struct->dl_dcm_en_u1);
PHL_INFO("ru_alo_idx_u1 = %d\n", f2p_tx_cmd_struct->ru_alo_idx_u1);
PHL_INFO("pwr_boost_u1 = %d\n", f2p_tx_cmd_struct->pwr_boost_u1);
PHL_INFO("agg_bmp_alo_u1 = %d\n", f2p_tx_cmd_struct->agg_bmp_alo_u1);
PHL_INFO("ampdu_max_txnum_u1 = %d\n", f2p_tx_cmd_struct->ampdu_max_txnum_u1);
PHL_INFO("user_define_u1 = %d\n", f2p_tx_cmd_struct->user_define_u1);
PHL_INFO("user_define_ext_u1 = %d\n", f2p_tx_cmd_struct->user_define_ext_u1);
PHL_INFO("ul_addr_idx_u1 = %d\n", f2p_tx_cmd_struct->ul_addr_idx_u1);
PHL_INFO("ul_dcm_u1 = %d\n", f2p_tx_cmd_struct->ul_dcm_u1);
PHL_INFO("ul_fec_cod_u1 = %d\n", f2p_tx_cmd_struct->ul_fec_cod_u1);
PHL_INFO("ul_ru_rate_u1 = %d\n", f2p_tx_cmd_struct->ul_ru_rate_u1);
PHL_INFO("ul_ru_alo_idx_u1 = %d\n", f2p_tx_cmd_struct->ul_ru_alo_idx_u1);
PHL_INFO("macid_u2 = %d\n", f2p_tx_cmd_struct->macid_u2);
PHL_INFO("ac_type_u2 = %d\n", f2p_tx_cmd_struct->ac_type_u2);
PHL_INFO("mu_sta_pos_u2 = %d\n", f2p_tx_cmd_struct->mu_sta_pos_u2);
PHL_INFO("dl_rate_idx_u2 = %d\n", f2p_tx_cmd_struct->dl_rate_idx_u2);
PHL_INFO("dl_dcm_en_u2 = %d\n", f2p_tx_cmd_struct->dl_dcm_en_u2);
PHL_INFO("ru_alo_idx_u2 = %d\n", f2p_tx_cmd_struct->ru_alo_idx_u2);
PHL_INFO("pwr_boost_u2 = %d\n", f2p_tx_cmd_struct->pwr_boost_u2);
PHL_INFO("agg_bmp_alo_u2 = %d\n", f2p_tx_cmd_struct->agg_bmp_alo_u2);
PHL_INFO("ampdu_max_txnum_u2 = %d\n", f2p_tx_cmd_struct->ampdu_max_txnum_u2);
PHL_INFO("user_define_u2 = %d\n", f2p_tx_cmd_struct->user_define_u2);
PHL_INFO("user_define_ext_u2 = %d\n", f2p_tx_cmd_struct->user_define_ext_u2);
PHL_INFO("ul_addr_idx_u2 = %d\n", f2p_tx_cmd_struct->ul_addr_idx_u2);
PHL_INFO("ul_dcm_u2 = %d\n", f2p_tx_cmd_struct->ul_dcm_u2);
PHL_INFO("ul_fec_cod_u2 = %d\n", f2p_tx_cmd_struct->ul_fec_cod_u2);
PHL_INFO("ul_ru_rate_u2 = %d\n", f2p_tx_cmd_struct->ul_ru_rate_u2);
PHL_INFO("ul_ru_alo_idx_u2 = %d\n", f2p_tx_cmd_struct->ul_ru_alo_idx_u2);
PHL_INFO("macid_u3 = %d\n", f2p_tx_cmd_struct->macid_u3);
PHL_INFO("ac_type_u3 = %d\n", f2p_tx_cmd_struct->ac_type_u3);
PHL_INFO("mu_sta_pos_u3 = %d\n", f2p_tx_cmd_struct->mu_sta_pos_u3);
PHL_INFO("dl_rate_idx_u3 = %d\n", f2p_tx_cmd_struct->dl_rate_idx_u3);
PHL_INFO("dl_dcm_en_u3 = %d\n", f2p_tx_cmd_struct->dl_dcm_en_u3);
PHL_INFO("ru_alo_idx_u3 = %d\n", f2p_tx_cmd_struct->ru_alo_idx_u3);
PHL_INFO("pwr_boost_u3 = %d\n", f2p_tx_cmd_struct->pwr_boost_u3);
PHL_INFO("agg_bmp_alo_u3 = %d\n", f2p_tx_cmd_struct->agg_bmp_alo_u3);
PHL_INFO("ampdu_max_txnum_u3 = %d\n", f2p_tx_cmd_struct->ampdu_max_txnum_u3);
PHL_INFO("user_define_u3 = %d\n", f2p_tx_cmd_struct->user_define_u3);
PHL_INFO("user_define_ext_u3 = %d\n", f2p_tx_cmd_struct->user_define_ext_u3);
PHL_INFO("ul_addr_idx_u3 = %d\n", f2p_tx_cmd_struct->ul_addr_idx_u3);
PHL_INFO("ul_dcm_u3 = %d\n", f2p_tx_cmd_struct->ul_dcm_u3);
PHL_INFO("ul_fec_cod_u3 = %d\n", f2p_tx_cmd_struct->ul_fec_cod_u3);
PHL_INFO("ul_ru_rate_u3 = %d\n", f2p_tx_cmd_struct->ul_ru_rate_u3);
PHL_INFO("ul_ru_alo_idx_u3 = %d\n", f2p_tx_cmd_struct->ul_ru_alo_idx_u3);
PHL_INFO("pkt_id_0 = %d\n", f2p_tx_cmd_struct->pkt_id_0);
PHL_INFO("valid_0 = %d\n", f2p_tx_cmd_struct->valid_0);
PHL_INFO("ul_user_num_0 = %d\n", f2p_tx_cmd_struct->ul_user_num_0);
PHL_INFO("pkt_id_1 = %d\n", f2p_tx_cmd_struct->pkt_id_1);
PHL_INFO("valid_1 = %d\n", f2p_tx_cmd_struct->valid_1);
PHL_INFO("ul_user_num_1 = %d\n", f2p_tx_cmd_struct->ul_user_num_1);
PHL_INFO("pkt_id_2 = %d\n", f2p_tx_cmd_struct->pkt_id_2);
PHL_INFO("valid_2 = %d\n", f2p_tx_cmd_struct->valid_2);
PHL_INFO("ul_user_num_2 = %d\n", f2p_tx_cmd_struct->ul_user_num_2);
PHL_INFO("pkt_id_3 = %d\n", f2p_tx_cmd_struct->pkt_id_3);
PHL_INFO("valid_3 = %d\n", f2p_tx_cmd_struct->valid_3);
PHL_INFO("ul_user_num_3 = %d\n", f2p_tx_cmd_struct->ul_user_num_3);
PHL_INFO("pkt_id_4 = %d\n", f2p_tx_cmd_struct->pkt_id_4);
PHL_INFO("valid_4 = %d\n", f2p_tx_cmd_struct->valid_4);
PHL_INFO("ul_user_num_4 = %d\n", f2p_tx_cmd_struct->ul_user_num_4);
PHL_INFO("pkt_id_5 = %d\n", f2p_tx_cmd_struct->pkt_id_5);
PHL_INFO("valid_5 = %d\n", f2p_tx_cmd_struct->valid_5);
PHL_INFO("ul_user_num_5 = %d\n", f2p_tx_cmd_struct->ul_user_num_5);
}
static enum rtw_phl_status phl_mp_tx_tmac(struct mp_context *mp,
struct mp_tx_arg *sw_tx_param)
{
u32 stbc = sw_tx_param->stbc;
u32 gi = sw_tx_param->gi;
u32 data_rate = sw_tx_param->data_rate;
u32 is_ldpc = sw_tx_param->fec;
u32 dbw = sw_tx_param ->dbw;
u32 dcm = sw_tx_param ->dcm;
struct rtw_trx_test_param test_param = {0};
/*u32 stbc = sw_tx_param->stbc;
u32 gi = sw_tx_param->gi;
enum rtw_data_rate data_rate = sw_tx_param->usr[sw_tx_gen_usr_idx].data_rate;;
u32 is_ldpc = sw_tx_param->usr[sw_tx_gen_usr_idx].fec;
u32 mpdu_len = sw_tx_param->usr[sw_tx_gen_usr_idx].mpdu_len;*/
// PHL_INFO("%s: stbc = %d, gi = %d, data rate = %X, coding = %d, mpdu_len = %d\n", __func__, stbc, gi, data_rate, is_ldpc, mpdu_len);
PHL_INFO("%s: stbc = %d, gi = %d, data rate = %X, coding = %d\n", __func__, stbc, gi, data_rate, is_ldpc);
rtw_phl_trx_default_param(mp->phl, &test_param);
test_param.tx_cap.f_rate = (u16)data_rate;
test_param.tx_cap.f_gi_ltf = (u8)gi;
test_param.tx_cap.f_stbc = (u8)stbc;
test_param.tx_cap.f_ldpc = (u8)is_ldpc;
test_param.tx_cap.f_bw = (u8)dbw;
test_param.tx_cap.f_dcm = (u8)dcm;
rtw_phl_trx_testsuite(mp->phl, &test_param);
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_plcp_gen(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
struct mp_plcp_param_t plcp_tx_struct = {0};
phl_mp_get_plcp_common_info(mp,arg, &plcp_tx_struct);
hal_status = rtw_hal_mp_tx_plcp_gen(mp, arg, &plcp_tx_struct);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_packet(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
if (arg->tx_method == MP_PMACT_TX) {
PHL_INFO("%s: CMD = MP_PMACT_TX\n", __func__);
hal_status = rtw_hal_mp_tx_pmac_packet(mp, arg);
phl_status = RTW_PHL_STATUS_SUCCESS;
} else if (arg->tx_method == MP_TMACT_TX) {
PHL_INFO("%s: CMD = MP_TMACT_TX\n", __func__);
phl_status = phl_mp_tx_tmac(mp, arg);
hal_status = RTW_HAL_STATUS_SUCCESS;
}
else if(arg->tx_method == MP_SW_TX) {
/* Remove this part after revise the dll command */
PHL_INFO("%s: CMD = MP_SW_TX\n", __func__);
phl_status = phl_mp_tx_tmac(mp, arg);
hal_status = RTW_HAL_STATUS_SUCCESS;
}
else if(arg->tx_method == MP_FW_PMAC_TX){
PHL_INFO("%s: CMD = MP_FW_PMAC_TX\n", __func__);
hal_status = rtw_hal_mp_tx_pmac_fw_trigger(mp, arg);
phl_status = RTW_PHL_STATUS_SUCCESS;
}
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return phl_status;
}
static enum rtw_phl_status phl_mp_tx_continuous_packet(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
if (arg->tx_method == MP_PMACT_TX) {
PHL_INFO("%s: CMD = MP_PMACT_TX\n", __func__);
hal_status = rtw_hal_mp_tx_pmac_continuous(mp, arg);
} else if (arg->tx_method == MP_TMACT_TX) {
PHL_INFO("%s: CMD = MP_TMACT_TX\n", __func__);
/* Call hal API */
}
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_single_tone(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_tx_single_tone(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_carrier_suppression(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_tx_carrier_suppression(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_phy_ok(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_tx_phy_ok_cnt(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_mode_switch(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_tx_mode_switch(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_f2p_cmd(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
struct mp_mac_ax_f2p_test_para f2p_test_para_struct = {0};
struct mp_mac_ax_f2p_wd f2p_wd_struct = {0};
struct mp_mac_ax_f2p_tx_cmd f2p_tx_cmd_struct = {0};
phl_mp_get_f2p_test_para(mp,arg, &f2p_test_para_struct);
phl_mp_get_f2p_wd(mp,arg, &f2p_wd_struct);
phl_mp_get_f2p_tx_cmd(mp,arg, &f2p_tx_cmd_struct);
hal_status = rtw_hal_mp_tx_f2p_cmd(mp, arg, &f2p_test_para_struct, &f2p_wd_struct, &f2p_tx_cmd_struct);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_tb_test(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
u8 ui_bssid[6];
ui_bssid[0] = arg->bSS_id_addr0;
ui_bssid[1] = arg->bSS_id_addr1;
ui_bssid[2] = arg->bSS_id_addr2;
ui_bssid[3] = arg->bSS_id_addr3;
ui_bssid[4] = arg->bSS_id_addr4;
ui_bssid[5] = arg->bSS_id_addr5;
PHL_INFO("Bssid = %x - %x - %x - %x - %x - %x \n",ui_bssid[0],ui_bssid[1],ui_bssid[2],ui_bssid[3],ui_bssid[4],ui_bssid[5]);
PHL_INFO("Bss aid = %x \n",arg->aid);
PHL_INFO("Bss color = %x \n",arg->bss_color);
rtw_phl_test_txtb_cfg(mp->phl_com, &arg->is_link_mode, sizeof(arg->is_link_mode), ui_bssid, (u8)arg->aid, (u8)arg->bss_color);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_dpd_bypass(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_set_dpd_bypass(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_tx_check_tx_idle(
struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_SUCCESS;
rtw_hal_mp_check_tx_idle(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_tx_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
enum rtw_phl_status mp_tx(struct mp_context *mp, struct mp_tx_arg *arg)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
switch(arg->cmd) {
case MP_TX_CONFIG_PLCP_PATTERN:
PHL_INFO("%s: CMD = MP_TX_SET_PLCP_PATTERN\n", __func__);
break;
case MP_TX_CONFIG_PLCP_USER_INFO:
PHL_INFO("%s: CMD = MP_TX_CONFIG_PLCP_USER_INFO\n", __func__);
phl_status = phl_mp_get_plcp_usr_info(mp,arg);
break;
case MP_TX_CONFIG_PLCP_COMMON_INFO:
PHL_INFO("%s: CMD = MP_TX_CONFIG_PLCP_COMMON_INFO\n", __func__);
phl_status = phl_mp_tx_plcp_gen(mp, arg);
break;
case MP_TX_PACKETS:
PHL_INFO("%s: CMD = MP_PACKETS_TX\n", __func__);
phl_status = phl_mp_tx_packet(mp, arg);
break;
case MP_TX_CONTINUOUS:
PHL_INFO("%s: CMD = MP_TX_CONTINUOUS\n", __func__);
phl_status = phl_mp_tx_continuous_packet(mp, arg);
break;
case MP_TX_SINGLE_TONE:
PHL_INFO("%s: CMD = MP_TX_SINGLE_TONE\n", __func__);
phl_status = phl_mp_tx_single_tone(mp, arg);
break;
case MP_TX_CCK_Carrier_Suppression:
PHL_INFO("%s: CMD = MP_TX_CCK_Carrier_Suppression\n", __func__);
phl_status = phl_mp_tx_carrier_suppression(mp, arg);
break;
case MP_TX_CMD_PHY_OK:
PHL_INFO("%s: CMD = MP_TX_CMD_PHY_OK\n", __FUNCTION__);
phl_status = phl_mp_tx_phy_ok(mp, arg);
break;
case MP_TX_MODE_SWITCH:
PHL_INFO("%s: CMD = MP_TX_MODE_SWITCH\n", __FUNCTION__);
phl_status = phl_mp_tx_mode_switch(mp, arg);
break;
case MP_TX_NONE:
PHL_INFO("%s: CMD = MP_TX_NONE\n", __func__);
break;
case MP_TX_F2P:
PHL_INFO("%s: CMD = MP_TX_F2P\n", __FUNCTION__);
phl_status = phl_mp_tx_f2p_cmd(mp, arg);
break;
case MP_TX_TB_TEST:
PHL_INFO("%s: CMD = MP_TX_TB_TEST\n", __FUNCTION__);
phl_status = phl_mp_tx_tb_test(mp, arg);
break;
case MP_TX_DPD_BYPASS:
PHL_INFO("%s: CMD = MP_TX_DPD_BYPASS\n", __FUNCTION__);
phl_status = phl_mp_tx_dpd_bypass(mp, arg);
break;
case MP_TX_CHECK_TX_IDLE:
PHL_INFO("%s: CMD = MP_TX_CHECK_TX_IDLE\n", __FUNCTION__);
phl_status = phl_mp_tx_check_tx_idle(mp, arg);
break;
default:
PHL_INFO("%s: CMD = Unknown\n", __func__);
break;
}
return phl_status;
}
#endif /* CONFIG_PHL_TEST_MP */
|
2301_81045437/rtl8852be
|
phl/test/mp/phl_test_mp_tx.c
|
C
|
agpl-3.0
| 44,763
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_TEST_MP_TXPWR_C_
#include "../../phl_headers.h"
#include "phl_test_mp_def.h"
#include "../../hal_g6/test/mp/hal_test_mp_api.h"
#ifdef CONFIG_PHL_TEST_MP
static enum rtw_phl_status phl_mp_txpwr_read_table(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_read_table(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_pwrtrack(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_pwrtrack(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_set_pwrtrack(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_set_pwrtrack(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_set_pwr(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_set_pwr(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_pwr(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_pwr(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_txinfo_pwr(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_txinfo_pwr(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_ctrl_rf_mode(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_ctrl_rf_mode(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_pwr_idx(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_pwr_idx(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_set_pwr_idx(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_set_pwr_idx(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_thermal(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_thermal(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_set_tssi(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_set_tssi(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_tssi(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_tssi(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_online_tssi_de(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_online_tssi_de(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_set_pwr_lmt_en(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_set_pwr_lmt_en(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_get_pwr_lmt_en(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_get_pwr_lmt_en(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_set_tssi_offset(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_set_tssi_offset(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_pwr_ref(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_pwr_ref(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status phl_mp_txpwr_get_pwr_ref_cw(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_FAILURE;
hal_status = rtw_hal_mp_txpwr_get_pwr_ref_cw(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
enum rtw_phl_status phl_mp_set_tx_pow_patten_sharp(
struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_hal_status hal_status = RTW_HAL_STATUS_SUCCESS;
rtw_hal_mp_set_tx_pow_patten_sharp(mp, arg);
/* Record the result */
arg->cmd_ok = true;
arg->status = hal_status;
/* Transfer to report */
mp->rpt = arg;
mp->rpt_len = sizeof(struct mp_txpwr_arg);
mp->buf = NULL;
mp->buf_len = 0;
return RTW_PHL_STATUS_SUCCESS;
}
enum rtw_phl_status mp_txpwr(struct mp_context *mp, struct mp_txpwr_arg *arg)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
switch(arg->cmd){
case MP_TXPWR_CMD_READ_PWR_TABLE:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_READ_PWR_TABLE\n",
__FUNCTION__);
phl_status = phl_mp_txpwr_read_table(mp, arg);
break;
case MP_TXPWR_CMD_GET_PWR_TRACK_STATUS:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_PWR_TRACK_STATUS\n",
__FUNCTION__);
phl_status = phl_mp_txpwr_get_pwrtrack(mp, arg);
break;
case MP_TXPWR_CMD_SET_PWR_TRACK_STATUS:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_SET_PWR_TRACK_STATUS\n",
__FUNCTION__);
phl_status = phl_mp_txpwr_set_pwrtrack(mp, arg);
break;
case MP_TXPWR_CMD_SET_TXPWR:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_SET_TXPWR\n", __FUNCTION__);
phl_status = phl_mp_txpwr_set_pwr(mp, arg);
break;
case MP_TXPWR_CMD_GET_TXPWR:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_TXPWR\n", __FUNCTION__);
phl_status = phl_mp_txpwr_get_pwr(mp, arg);
break;
case MP_TXPWR_CMD_GET_TXPWR_INDEX:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_TXPWR_INDEX\n",
__FUNCTION__);
phl_status = phl_mp_txpwr_get_pwr_idx(mp, arg);
break;
case MP_TXPWR_CMD_SET_TXPWR_INDEX:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_SET_TXPWR_INDEX\n",
__FUNCTION__);
phl_status = phl_mp_txpwr_set_pwr_idx(mp, arg);
break;
case MP_TXPWR_CMD_GET_THERMAL:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_THERMAL\n", __FUNCTION__);
phl_status = phl_mp_txpwr_get_thermal(mp, arg);
break;
case MP_TXPWR_CMD_SET_TSSI:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_SET_TSSI\n", __FUNCTION__);
phl_status = phl_mp_txpwr_set_tssi(mp, arg);
break;
case MP_TXPWR_CMD_GET_TSSI:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_TSSI\n", __FUNCTION__);
phl_status = phl_mp_txpwr_get_tssi(mp, arg);
break;
case MP_TXPWR_CMD_GET_TXPWR_REF:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_TXPWR_REF\n",
__FUNCTION__);
phl_status = phl_mp_txpwr_get_pwr_ref(mp, arg);
break;
case MP_TXPWR_CMD_GET_TXPWR_REF_CW:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_TXPWR_REF_CW\n",
__FUNCTION__);
phl_status = phl_mp_txpwr_get_pwr_ref_cw(mp, arg);
break;
case MP_TXPWR_CMD_GET_TXINFOPWR:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_TXINFOPWR\n", __FUNCTION__);
phl_status = phl_mp_txpwr_get_txinfo_pwr(mp, arg);
break;
case MP_TXPWR_CMD_SET_RFMODE:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_SET_RFMODE\n", __FUNCTION__);
phl_status = phl_mp_txpwr_ctrl_rf_mode(mp, arg);
break;
case MP_TXPWR_CMD_SET_TSSI_OFFSET:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_SET_TSSI\n", __FUNCTION__);
phl_status = phl_mp_txpwr_set_tssi_offset(mp, arg);
break;
case MP_TXPWR_CMD_GET_ONLINE_TSSI_DE:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_ONLINE_TSSI_DE\n", __FUNCTION__);
phl_status = phl_mp_txpwr_get_online_tssi_de(mp, arg);
break;
case MP_TXPWR_CMD_SET_PWR_LMT_EN:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_SET_PWR_LMT_EN\n", __FUNCTION__);
phl_status = phl_mp_set_pwr_lmt_en(mp, arg);
break;
case MP_TXPWR_CMD_GET_PWR_LMT_EN:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_GET_PWR_LMT_EN\n", __FUNCTION__);
phl_status = phl_mp_get_pwr_lmt_en(mp, arg);
break;
case MP_TXPWR_CMD_SET_TX_POW_PATTERN_SHARP:
PHL_INFO("%s: CMD = MP_TXPWR_CMD_SET_TX_POW_PATTERN_SHARP\n", __FUNCTION__);
phl_status = phl_mp_set_tx_pow_patten_sharp(mp, arg);
break;
default:
break;
}
return phl_status;
}
#endif /* CONFIG_PHL_TEST_MP */
|
2301_81045437/rtl8852be
|
phl/test/mp/phl_test_mp_txpwr.c
|
C
|
agpl-3.0
| 12,694
|
/******************************************************************************
*
* Copyright(c) 2019 - 2020 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
* Author: vincent_fann@realtek.com
*
*****************************************************************************/
#define _PHL_DBG_CMD_C_
#include "phl_dbg_cmd.h"
#include "phl_ps_dbg_cmd.h"
/*
* proc debug command of core
*/
enum PHL_DBG__CORE_CMD_ID {
PHL_DBG_CORE_HELP,
PHL_DBG_CORE_GIT_INFO
};
static const struct phl_dbg_cmd_info phl_dbg_core_cmd_i[] = {
{"git_info", PHL_DBG_CORE_GIT_INFO}
};
void phl_dbg_git_info(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
/* #REMOVE BEGIN */
#if CONFIG_GEN_GIT_INFO
#include "../phl_git_info.h"
u32 used = 0;
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"\ncore_ver : %s\n", RTK_CORE_TAGINFO);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"phl_ver : %s\n", RTK_PHL_TAGINFO);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"halmac_ver : %s\n", RTK_HALMAC_TAGINFO);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"halbb_ver : %s\n", RTK_HALBB_TAGINFO);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"halrf_ver : %s\n", RTK_HALRF_TAGINFO);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"btc_ver : %s\n", RTK_BTC_TAGINFO);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"\ncore_sha1 : %s\n", RTK_CORE_SHA1);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"phl_sha1 : %s\n", RTK_PHL_SHA1);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"halmac_sha1: %s\n", RTK_HALMAC_SHA1);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"halbb_sha1 : %s\n", RTK_HALBB_SHA1);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"halrf_sha1 : %s\n", RTK_HALRF_SHA1);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"btc_sha1 : %s\n", RTK_BTC_SHA1);
#endif /* CONFIG_GEN_GIT_INFO */
/* #REMOVE END */
}
void phl_dbg_core_cmd_parser(void *phl, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
u8 id = 0;
u32 i;
u32 used = 0;
u32 phl_ary_size = sizeof(phl_dbg_core_cmd_i) /
sizeof(struct phl_dbg_cmd_info);
if (phl_ary_size == 0)
return;
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used, "\n");
/* Parsing Cmd ID */
if (input_num) {
for (i = 0; i < phl_ary_size; i++) {
if (_os_strcmp(phl_dbg_core_cmd_i[i].name, input[0]) == 0) {
id = phl_dbg_core_cmd_i[i].id;
PHL_INFO("[%s]===>\n", phl_dbg_core_cmd_i[i].name);
break;
}
}
if (i == phl_ary_size) {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "PHL CMD not found!\n");
return;
}
}
switch (id) {
case PHL_DBG_CORE_HELP:
{
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"phl_dbg_core_cmd_parser : PHL_DBG_CORE_HELP \n");
for (i = 0; i < phl_ary_size - 2; i++)
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "%-5d: %s\n",
(int)i, phl_dbg_core_cmd_i[i + 2].name);
}
break;
case PHL_DBG_CORE_GIT_INFO:
{
phl_dbg_git_info(phl_info, input, input_num, output, out_len);
}
break;
default:
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[DBG] Do not support this command\n");
break;
}
}
s32
phl_dbg_core_proc_cmd(struct phl_info_t *phl_info,
char *input, char *output, u32 out_len)
{
char *token;
u32 argc = 0;
char argv[MAX_ARGC][MAX_ARGV];
do {
token = _os_strsep(&input, ", ");
if (token) {
if (_os_strlen((u8 *)token) <= MAX_ARGV)
_os_strcpy(argv[argc], token);
argc++;
} else {
break;
}
} while (argc < MAX_ARGC);
if (argc == 1)
argv[0][_os_strlen((u8 *)argv[0])] = '\0';
phl_dbg_core_cmd_parser(phl_info, argv, argc, output, out_len);
return 0;
}
enum rtw_phl_status
rtw_phl_dbg_core_cmd(struct phl_info_t *phl_info,
struct rtw_proc_cmd *incmd,
char *output,
u32 out_len)
{
if (incmd->in_type == RTW_ARG_TYPE_BUF) {
phl_dbg_core_proc_cmd(phl_info, incmd->in.buf, output, out_len);
} else if(incmd->in_type == RTW_ARG_TYPE_ARRAY){
phl_dbg_core_cmd_parser(phl_info, incmd->in.vector,
incmd->in_cnt_len, output, out_len);
}
return RTW_PHL_STATUS_SUCCESS;
}
#ifdef CONFIG_PHL_TEST_SUITE
bool
_is_hex_digit(char ch_tmp)
{
if( (ch_tmp >= '0' && ch_tmp <= '9') ||
(ch_tmp >= 'a' && ch_tmp <= 'f') ||
(ch_tmp >= 'A' && ch_tmp <= 'F') ) {
return true;
} else {
return false;
}
}
u32
_map_char_to_hex_digit(char ch_tmp)
{
if(ch_tmp >= '0' && ch_tmp <= '9')
return (ch_tmp - '0');
else if(ch_tmp >= 'a' && ch_tmp <= 'f')
return (10 + (ch_tmp - 'a'));
else if(ch_tmp >= 'A' && ch_tmp <= 'F')
return (10 + (ch_tmp - 'A'));
else
return 0;
}
bool
_get_hex_from_string(char *szstr, u32 *val)
{
char *sz_scan = szstr;
/* Check input parameter.*/
if (szstr == NULL || val == NULL) {
PHL_TRACE(COMP_PHL_DBG, _PHL_WARNING_,
"_get_hex_from_string(): Invalid inpur argumetns! szStr: %p, pu4bVal: %p \n",
szstr, val);
return false;
}
/* Initialize output. */
*val = 0;
/* Skip leading space. */
while(*sz_scan != '\0' && (*sz_scan == ' ' || *sz_scan == '\t')) {
sz_scan++;
}
/* Skip leading '0x' or '0X'. */
if (*sz_scan == '0' && (*(sz_scan+1) == 'x' || *(sz_scan+1) == 'X')) {
sz_scan += 2;
}
if (!_is_hex_digit(*sz_scan)) {
return false;
}
do {
(*val) <<= 4;
*val += _map_char_to_hex_digit(*sz_scan);
sz_scan++;
} while (_is_hex_digit(*sz_scan));
return true;
}
void
_phl_dbg_cmd_switch_chbw(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
u32 band = 0;
u32 bw = 0;
u32 offset = 0;
u32 ch = 36;
u32 used = 0;
struct rtw_chan_def chdef = {0};
do {
if (input_num < 5){
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"\n[DBG] echo phl set_ch [band(0,1)] [ch(hex)] [bw(0,1,2,3)] [offset(0,1,2,3)]\n");
break;
}
if (!_get_hex_from_string(input[1], &band))
break;
if (band > 1)
break;
if (!_get_hex_from_string(input[2], &ch))
break;
if (!_get_hex_from_string(input[3], &bw))
break;
if (!_get_hex_from_string(input[4], &offset))
break;
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"\n[DBG] PHL_DBG_SET_CH_BW ==> band = %d\n",
(int)band);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"[DBG] PHL_DBG_SET_CH_BW ==> ch = %d\n",
(int)ch);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"[DBG] PHL_DBG_SET_CH_BW ==> bw = %d\n",
(int)bw);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"[DBG] PHL_DBG_SET_CH_BW ==> offset = %d\n",
(int)offset);
chdef.chan = (u8)ch;
chdef.band = rtw_phl_get_band_type(chdef.chan);
chdef.bw = (enum channel_width)bw;
chdef.offset = (enum chan_offset)offset;
rtw_hal_set_ch_bw(phl_info->hal, (u8)band, &chdef, false);
} while (0);
}
void _dump_wifi_role(struct phl_info_t *phl_info, char *output, u32 out_len)
{
struct rtw_wifi_role_t *wrole = NULL;
struct rtw_phl_stainfo_t *sta_info = NULL;
u32 used = 0;
u8 j = 0;
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"==> PHL_DBG_DUMP_WROLE CH/BW information\n");
for( j = 0; j < MAX_WIFI_ROLE_NUMBER; j++) {
wrole = phl_get_wrole_by_ridx(phl_info, j);
if (NULL == wrole)
continue;
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole idx = 0x%x \n", j);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole->type = 0x%x \n",
wrole->type);
/* debug_dump_mac_addr(wrole->mac_addr); */
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole->chandef.bw = 0x%x \n",
wrole->chandef.bw);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole->chandef.band = 0x%x \n",
wrole->chandef.band);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole->chandef.center_ch = 0x%x \n",
wrole->chandef.center_ch);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole->chandef.chan = 0x%x \n",
wrole->chandef.chan);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole->chandef.center_freq1 = %u \n",
(int)wrole->chandef.center_freq1);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole->chandef.center_freq2 = %u \n",
(int)wrole->chandef.center_freq2);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "wrole->chandef.offset = 0x%x \n",
wrole->chandef.offset);
sta_info = rtw_phl_get_stainfo_self(phl_info, wrole);
if (NULL == sta_info)
continue;
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "sta_info->macid = 0x%x \n",
sta_info->macid);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "sta_info->aid = 0x%x \n",
sta_info->aid);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "mac_addr : %02x-%02x-%02x-%02x-%02x-%02x- \n",
sta_info->mac_addr[0], sta_info->mac_addr[1],
sta_info->mac_addr[2], sta_info->mac_addr[3],
sta_info->mac_addr[4], sta_info->mac_addr[5]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "sta_info->wmode = 0x%x \n",
sta_info->wmode);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "-----------------------------\n");
}
}
void _dump_rx_rate(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
u32 ctrl = 0;
u32 used = 0;
struct rtw_stats *rx_stat = &phl_info->phl_com->phl_stats;
if(input_num < 2)
return;
_get_hex_from_string(input[1], &ctrl);
if (ctrl == 2) {
/*TODO: Clear Counter*/
return;
}
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "\nOFDM 6M = %d ; OFDM 24M = %d ; OFDM 54M = %d\n",
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_OFDM6],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_OFDM24],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_OFDM54]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "VHT 1SS\
\nMCS0 = %d ; MCS1 = %d ; MCS2 = %d ;\
\nMCS3 = %d ; MCS4 = %d ; MCS5 = %d ;\
\nMCS6 = %d ; MCS7 = %d ; MCS8 = %d ;\
\nMCS9 = %d ;\n",
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS0],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS1],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS2],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS3],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS4],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS5],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS6],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS7],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS8],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS1_MCS9]
);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "VHT 2SS\
\nMCS0 = %d ; MCS1 = %d ; MCS2 = %d ;\
\nMCS3 = %d ; MCS4 = %d ; MCS5 = %d ;\
\nMCS6 = %d ; MCS7 = %d ; MCS8 = %d ;\
\nMCS9 = %d ;\n",
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS0],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS1],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS2],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS3],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS4],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS5],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS6],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS7],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS8],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_VHT_NSS2_MCS9]
);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "HE 1SS\
\nMCS0 = %d ; MCS1 = %d ; MCS2 = %d ;\
\nMCS3 = %d ; MCS4 = %d ; MCS5 = %d ;\
\nMCS6 = %d ; MCS7 = %d ; MCS8 = %d ;\
\nMCS9 = %d ; MCS10 = %d ; MCS11 = %d;\n",
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS0],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS1],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS2],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS3],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS4],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS5],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS6],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS7],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS8],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS9],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS10],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS1_MCS11]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "HE 2SS\
\nMCS0 = %d ; MCS1 = %d ; MCS2 = %d ;\
\nMCS3 = %d ; MCS4 = %d ; MCS5 = %d ;\
\nMCS6 = %d ; MCS7 = %d ; MCS8 = %d ;\
\nMCS9 = %d ; MCS10 = %d ; MCS11 = %d ;\n",
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS0],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS1],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS2],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS3],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS4],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS5],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS6],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS7],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS8],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS9],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS10],
(int)rx_stat->rx_rate_nmr[RTW_DATA_RATE_HE_NSS2_MCS11]
);
}
static const char *_get_mac_pwr_st_str(enum rtw_mac_pwr_st st)
{
switch (st) {
case RTW_MAC_PWR_OFF:
return "off";
case RTW_MAC_PWR_ON:
return "on";
case RTW_MAC_PWR_LPS:
return "lps";
default:
return "n/a";
}
}
static const char *_get_wow_opmode_str(enum rtw_wow_op_mode mode)
{
switch (mode) {
case RTW_WOW_OP_PWR_DOWN:
return "power down";
case RTW_WOW_OP_DISCONNECT_STBY:
return "disconnected standby";
case RTW_WOW_OP_CONNECT_STBY:
return "connected standby";
default:
return "n/a";
}
}
void _dump_wow_stats(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
#ifdef CONFIG_WOWLAN
struct phl_wow_info *wow_info = phl_to_wow_info(phl_info);
struct phl_wow_stat *wow_stat = &wow_info->wow_stat;
u32 used = 0;
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"\n%-20s : op_mode = %s, func_en = %s, mac pwr = %s, wake_rsn = %s\
\n%-20s : keep_alive_en = %d, disc_det_en = %d, arp_en = %d, ndp_en = %d, gtk_en = %d, dot11w_en = %d\
\n%-20s : init err = 0x%x, deinit err = 0x%x\
\n%-20s : aoac_rpt_fail_cnt = 0x%x\n",
"[wow information]",
_get_wow_opmode_str(wow_stat->op_mode), (wow_stat->func_en == 1 ? "yes" : "no"),
_get_mac_pwr_st_str(wow_stat->mac_pwr), rtw_phl_get_wow_rsn_str(phl_info, wow_stat->wake_rsn),
"[wow function]",
wow_stat->keep_alive_en, wow_stat->disc_det_en, wow_stat->arp_en, wow_stat->ndp_en, wow_stat->gtk_en, wow_stat->dot11w_en,
"[wow error]",
wow_stat->err.init, wow_stat->err.deinit,
"[wow aoac]",
wow_stat->aoac_rpt_fail_cnt);
#endif /* CONFIG_WOWLAN */
}
#ifdef CONFIG_MCC_SUPPORT
void _dump_mcc_info(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
bool get_ok = false;
struct rtw_phl_mcc_en_info en_info = {0};
enum rtw_phl_tdmra_wmode mcc_mode;
enum rtw_phl_mcc_state state;
enum rtw_phl_mcc_coex_mode coex_mode;
struct rtw_phl_mcc_bt_info bt_info = {0};
struct rtw_phl_mcc_role *mrole = NULL;
struct rtw_chan_def *chdef = NULL;
struct rtw_phl_mcc_dur_info *dur_i = NULL;
struct rtw_phl_mcc_pattern *m_pattern = NULL;
struct rtw_phl_mcc_dbg_slot_info *dbg_slot_i = NULL;
u32 used = 0;
u8 i = 0;
get_ok = rtw_phl_mcc_get_dbg_info(phl_info, 0, MCC_DBG_STATE, &state);
if (false == get_ok) {
PHL_TRACE(COMP_PHL_MCC, _PHL_ERR_, "_dump_mcc_info(): get MCC_DBG_STATE fail\n");
goto exit;
}
get_ok = rtw_phl_mcc_get_dbg_info(phl_info, 0, MCC_DBG_OP_MODE, &mcc_mode);
if (false == get_ok) {
PHL_TRACE(COMP_PHL_MCC, _PHL_ERR_, "_dump_mcc_info(): get MCC_DBG_OP_MODE fail\n");
goto exit;
}
get_ok = rtw_phl_mcc_get_dbg_info(phl_info, 0, MCC_DBG_COEX_MODE, &coex_mode);
if (false == get_ok) {
PHL_TRACE(COMP_PHL_MCC, _PHL_ERR_, "_dump_mcc_info(): get MCC_DBG_COEX_MODE fail\n");
goto exit;
}
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "\n======== MCC Info ========\n");
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "MCC Info: State(%s, %d), Mode(%s, %d), Coex(%s, %d)\n",
((state == MCC_NONE) ? "None" :
((state == MCC_TRIGGER_FW_EN) ? "Trig_Fw_En" :
((state == MCC_FW_EN_FAIL) ? "Fw_En_Fail" :
((state == MCC_RUNING) ? "Runing" :
((state == MCC_TRIGGER_FW_DIS) ? "Trig_Fw_Dis" :
((state == MCC_FW_DIS_FAIL) ? "Fw_Dis_Fail" :
((state == MCC_STOP) ? "Fw_Stop" : "Unknown"))))))),
state,
((mcc_mode == RTW_PHL_TDMRA_WMODE_NONE) ? "None" :
((mcc_mode == RTW_PHL_TDMRA_AP_CLIENT_WMODE) ? "AP_Client" :
((mcc_mode == RTW_PHL_TDMRA_2CLIENTS_WMODE) ? "2Clients" :
((mcc_mode == RTW_PHL_TDMRA_AP_WMODE) ? "AP" : "Unknown")))),
mcc_mode,
((coex_mode == RTW_PHL_MCC_COEX_MODE_NONE) ? "None" :
((coex_mode == RTW_PHL_MCC_COEX_MODE_BT_MASTER) ? "BT_M" :
((coex_mode == RTW_PHL_MCC_COEX_MODE_WIFI_MASTER) ? "Wifi_M" :
((coex_mode == RTW_PHL_MCC_COEX_MODE_BT_WIFI_BALANCE) ? "Balance" : "Unknown")))),
coex_mode);
get_ok = rtw_phl_mcc_get_dbg_info(phl_info, 0, MCC_DBG_BT_INFO, &bt_info);
if (false == get_ok) {
PHL_TRACE(COMP_PHL_MCC, _PHL_ERR_, "_dump_mcc_info(): get MCC_DBG_BT_INFO fail\n");
goto exit;
}
if (bt_info.bt_seg_num <= BT_SEG_NUM) {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "MCC Info: Bt_dur(%d), Add_Bt_Role(%d), Seg_Num(%d), bt_seg[0](%d), bt_seg[1](%d)\n",
bt_info.bt_dur, bt_info.add_bt_role,
bt_info.bt_seg_num, bt_info.bt_seg[0],
bt_info.bt_seg[1]);
}
get_ok = rtw_phl_mcc_get_dbg_info(phl_info, 0, MCC_DBG_EN_INFO, &en_info);
if (false == get_ok) {
PHL_TRACE(COMP_PHL_MCC, _PHL_ERR_, "_dump_mcc_info(): get MCC_DBG_EN_INFO fail\n");
goto exit;
}
m_pattern = &en_info.m_pattern;
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "MCC Info: mcc_intvl(%d), Start_tsf(0x%04x%04x %04x%04x), bcns_offset(%d), tob_r(%d), toa_r(%d), tob_a(%d), toa_a(%d)\n",
en_info.mcc_intvl, (u16)(en_info.tsf_high >> 16),
(u16)(en_info.tsf_high),
(u16)(en_info.tsf_low >> 16),
(u16)(en_info.tsf_low), m_pattern->bcns_offset,
m_pattern->tob_r, m_pattern->toa_r,
m_pattern->tob_a, m_pattern->toa_a);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "\n======== MCC Role Info ========\n");
for (i = 0; i < en_info.mrole_num; i++) {
mrole = &en_info.mcc_role[i];
chdef = mrole->chandef;
dur_i = &mrole->policy.dur_info;
if (NULL == chdef)
break;
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "MCC Info: Role(%d): macid(0x%x), Bcn_intvl(%d), band(%d), chan(%d), center_ch(%d), bw(%d), offset(%d)\n",
i, mrole->macid, mrole->bcn_intvl, chdef->band,
chdef->chan, chdef->center_ch, chdef->bw,
chdef->offset);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "MCC Info: Role(%d): dur(0x%x), lim_en(%d), tag(%d), max_dur(%d), max_toa(%d), max_tob(%d)\n\n",
i, dur_i->dur, dur_i->dur_limit.enable,
dur_i->dur_limit.tag, dur_i->dur_limit.max_dur,
dur_i->dur_limit.max_toa,
dur_i->dur_limit.max_tob);
}
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "======== Hal MCC Info ========\n");
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "MCC Info: btc_in_group(%d)\n",
en_info.dbg_hal_i.btc_in_group);
for (i = 0; i < en_info.dbg_hal_i.slot_num; i++) {
dbg_slot_i = &en_info.dbg_hal_i.dbg_slot_i[i];
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "MCC Info: FW Slot(%d), BT_Role(%d), Dur(%d), Ch(%d), Macid(0x%x)\n",
i, dbg_slot_i->bt_role, dbg_slot_i->dur,
dbg_slot_i->ch, dbg_slot_i->macid);
}
exit:
return;
}
#endif
void phl_dbg_cmd_snd(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
u32 role_idx;
u32 ctrl;
u32 used = 0;
if (input_num < 2)
return;
_get_hex_from_string(input[1], &ctrl);
_get_hex_from_string(input[2], &role_idx);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "ctrl 0x%x with role_idx 0x%x!!\n",
(int)ctrl, (int)role_idx);
if (1 == ctrl) {
rtw_phl_sound_start(phl_info, (u8)role_idx, 0, 200,
PHL_SND_TEST_F_ONE_TIME |
PHL_SND_TEST_F_PASS_STS_CHK);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "SOUND START(once) : wrole %d !!\n", (int)role_idx);
} else if (2 == ctrl) {
rtw_phl_sound_abort(phl_info);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "SOUND ABORT!!\n");
} else if (3 == ctrl) {
rtw_phl_sound_start(phl_info, (u8)role_idx, 0, 200,
PHL_SND_TEST_F_PASS_STS_CHK);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "SOUND START(loop) : wrole %d !!\n", (int)role_idx);
} else if(9 == ctrl) {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "DUMP BF Entry in debugview\n");
rtw_hal_bf_dbg_dump_entry_all(phl_info->hal);
} else {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "SOUND TEST CMD not found!\n");
}
}
void _convert_tx_rate(enum hal_rate_mode mode, u8 mcs_ss_idx, char *str, u32 str_len)
{
switch (mode) {
case HAL_LEGACY_MODE:
switch (mcs_ss_idx) {
case RTW_DATA_RATE_CCK1: _os_snprintf(str, str_len,"CCK 1"); break;
case RTW_DATA_RATE_CCK2: _os_snprintf(str, str_len,"CCK 2"); break;
case RTW_DATA_RATE_CCK5_5: _os_snprintf(str, str_len,"CCK 5_5"); break;
case RTW_DATA_RATE_CCK11: _os_snprintf(str, str_len,"CCK 11"); break;
case RTW_DATA_RATE_OFDM6: _os_snprintf(str, str_len,"OFDM 6"); break;
case RTW_DATA_RATE_OFDM9: _os_snprintf(str, str_len,"OFDM 9"); break;
case RTW_DATA_RATE_OFDM12: _os_snprintf(str, str_len,"OFDM 12"); break;
case RTW_DATA_RATE_OFDM18: _os_snprintf(str, str_len,"OFDM 18"); break;
case RTW_DATA_RATE_OFDM24: _os_snprintf(str, str_len,"OFDM 24"); break;
case RTW_DATA_RATE_OFDM36: _os_snprintf(str, str_len,"OFDM 36"); break;
case RTW_DATA_RATE_OFDM48: _os_snprintf(str, str_len,"OFDM 48"); break;
case RTW_DATA_RATE_OFDM54: _os_snprintf(str, str_len,"OFDM 54"); break;
default:
_os_snprintf(str, str_len,"Unkown rate(0x%01x)", mcs_ss_idx);
break;
}
break;
case HAL_HT_MODE:
_os_snprintf(str, str_len,"MCS%d", mcs_ss_idx);
break;
case HAL_VHT_MODE:
case HAL_HE_MODE:
_os_snprintf(str, str_len,"%dSS MCS%d",
((mcs_ss_idx & 0x70)>> 4) + 1,
(mcs_ss_idx & 0x0F));
break;
default:
_os_snprintf(str, str_len,"Unknown mode(0x%01x)", mode);
break;
}
}
void _convert_rx_rate(u32 rx_rate, char *str, u32 str_len)
{
switch(rx_rate) {
case RTW_DATA_RATE_CCK1: _os_snprintf(str, str_len,"CCK 1"); break;
case RTW_DATA_RATE_CCK2: _os_snprintf(str, str_len,"CCK 2"); break;
case RTW_DATA_RATE_CCK5_5: _os_snprintf(str, str_len,"CCK 5_5"); break;
case RTW_DATA_RATE_CCK11: _os_snprintf(str, str_len,"CCK 11"); break;
case RTW_DATA_RATE_OFDM6: _os_snprintf(str, str_len,"OFDM 6"); break;
case RTW_DATA_RATE_OFDM9: _os_snprintf(str, str_len,"OFDM 9"); break;
case RTW_DATA_RATE_OFDM12: _os_snprintf(str, str_len,"OFDM 12"); break;
case RTW_DATA_RATE_OFDM18: _os_snprintf(str, str_len,"OFDM 18"); break;
case RTW_DATA_RATE_OFDM24: _os_snprintf(str, str_len,"OFDM 24"); break;
case RTW_DATA_RATE_OFDM36: _os_snprintf(str, str_len,"OFDM 36"); break;
case RTW_DATA_RATE_OFDM48: _os_snprintf(str, str_len,"OFDM 48"); break;
case RTW_DATA_RATE_OFDM54: _os_snprintf(str, str_len,"OFDM 54"); break;
case RTW_DATA_RATE_MCS0: _os_snprintf(str, str_len,"MCS 0"); break;
case RTW_DATA_RATE_MCS1: _os_snprintf(str, str_len,"MCS 1"); break;
case RTW_DATA_RATE_MCS2: _os_snprintf(str, str_len,"MCS 2"); break;
case RTW_DATA_RATE_MCS3: _os_snprintf(str, str_len,"MCS 3"); break;
case RTW_DATA_RATE_MCS4: _os_snprintf(str, str_len,"MCS 4"); break;
case RTW_DATA_RATE_MCS5: _os_snprintf(str, str_len,"MCS 5"); break;
case RTW_DATA_RATE_MCS6: _os_snprintf(str, str_len,"MCS 6"); break;
case RTW_DATA_RATE_MCS7: _os_snprintf(str, str_len,"MCS 7"); break;
case RTW_DATA_RATE_MCS8: _os_snprintf(str, str_len,"MCS 8"); break;
case RTW_DATA_RATE_MCS9: _os_snprintf(str, str_len,"MCS 9"); break;
case RTW_DATA_RATE_MCS10: _os_snprintf(str, str_len,"MCS 10"); break;
case RTW_DATA_RATE_MCS11: _os_snprintf(str, str_len,"MCS 11"); break;
case RTW_DATA_RATE_MCS12: _os_snprintf(str, str_len,"MCS 12"); break;
case RTW_DATA_RATE_MCS13: _os_snprintf(str, str_len,"MCS 13"); break;
case RTW_DATA_RATE_MCS14: _os_snprintf(str, str_len,"MCS 14"); break;
case RTW_DATA_RATE_MCS15: _os_snprintf(str, str_len,"MCS 15"); break;
case RTW_DATA_RATE_MCS16: _os_snprintf(str, str_len,"MCS 16"); break;
case RTW_DATA_RATE_MCS17: _os_snprintf(str, str_len,"MCS 17"); break;
case RTW_DATA_RATE_MCS18: _os_snprintf(str, str_len,"MCS 18"); break;
case RTW_DATA_RATE_MCS19: _os_snprintf(str, str_len,"MCS 19"); break;
case RTW_DATA_RATE_MCS20: _os_snprintf(str, str_len,"MCS 20"); break;
case RTW_DATA_RATE_MCS21: _os_snprintf(str, str_len,"MCS 21"); break;
case RTW_DATA_RATE_MCS22: _os_snprintf(str, str_len,"MCS 22"); break;
case RTW_DATA_RATE_MCS23: _os_snprintf(str, str_len,"MCS 23"); break;
case RTW_DATA_RATE_MCS24: _os_snprintf(str, str_len,"MCS 24"); break;
case RTW_DATA_RATE_MCS25: _os_snprintf(str, str_len,"MCS 25"); break;
case RTW_DATA_RATE_MCS26: _os_snprintf(str, str_len,"MCS 26"); break;
case RTW_DATA_RATE_MCS27: _os_snprintf(str, str_len,"MCS 27"); break;
case RTW_DATA_RATE_MCS28: _os_snprintf(str, str_len,"MCS 28"); break;
case RTW_DATA_RATE_MCS29: _os_snprintf(str, str_len,"MCS 29"); break;
case RTW_DATA_RATE_MCS30: _os_snprintf(str, str_len,"MCS 30"); break;
case RTW_DATA_RATE_MCS31: _os_snprintf(str, str_len,"MCS 31"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS0: _os_snprintf(str, str_len,"NSS1_MCS0"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS1: _os_snprintf(str, str_len,"NSS1_MCS1"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS2: _os_snprintf(str, str_len,"NSS1_MCS2"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS3: _os_snprintf(str, str_len,"NSS1_MCS3"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS4: _os_snprintf(str, str_len,"NSS1_MCS4"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS5: _os_snprintf(str, str_len,"NSS1_MCS5"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS6: _os_snprintf(str, str_len,"NSS1_MCS6"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS7: _os_snprintf(str, str_len,"NSS1_MCS7"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS8: _os_snprintf(str, str_len,"NSS1_MCS8"); break;
case RTW_DATA_RATE_VHT_NSS1_MCS9: _os_snprintf(str, str_len,"NSS1_MCS9"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS0: _os_snprintf(str, str_len,"NSS2_MCS0"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS1: _os_snprintf(str, str_len,"NSS2_MCS1"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS2: _os_snprintf(str, str_len,"NSS2_MCS2"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS3: _os_snprintf(str, str_len,"NSS2_MCS3"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS4: _os_snprintf(str, str_len,"NSS2_MCS4"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS5: _os_snprintf(str, str_len,"NSS2_MCS5"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS6: _os_snprintf(str, str_len,"NSS2_MCS6"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS7: _os_snprintf(str, str_len,"NSS2_MCS7"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS8: _os_snprintf(str, str_len,"NSS2_MCS8"); break;
case RTW_DATA_RATE_VHT_NSS2_MCS9: _os_snprintf(str, str_len,"NSS2_MCS9"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS0: _os_snprintf(str, str_len,"NSS3_MCS0"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS1: _os_snprintf(str, str_len,"NSS3_MCS1"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS2: _os_snprintf(str, str_len,"NSS3_MCS2"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS3: _os_snprintf(str, str_len,"NSS3_MCS3"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS4: _os_snprintf(str, str_len,"NSS3_MCS4"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS5: _os_snprintf(str, str_len,"NSS3_MCS5"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS6: _os_snprintf(str, str_len,"NSS3_MCS6"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS7: _os_snprintf(str, str_len,"NSS3_MCS7"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS8: _os_snprintf(str, str_len,"NSS3_MCS8"); break;
case RTW_DATA_RATE_VHT_NSS3_MCS9: _os_snprintf(str, str_len,"NSS3_MCS9"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS0: _os_snprintf(str, str_len,"NSS4_MCS0"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS1: _os_snprintf(str, str_len,"NSS4_MCS1"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS2: _os_snprintf(str, str_len,"NSS4_MCS2"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS3: _os_snprintf(str, str_len,"NSS4_MCS3"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS4: _os_snprintf(str, str_len,"NSS4_MCS4"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS5: _os_snprintf(str, str_len,"NSS4_MCS5"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS6: _os_snprintf(str, str_len,"NSS4_MCS6"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS7: _os_snprintf(str, str_len,"NSS4_MCS7"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS8: _os_snprintf(str, str_len,"NSS4_MCS8"); break;
case RTW_DATA_RATE_VHT_NSS4_MCS9: _os_snprintf(str, str_len,"NSS4_MCS9"); break;
case RTW_DATA_RATE_HE_NSS1_MCS0: _os_snprintf(str, str_len,"HE_NSS1_MCS0"); break;
case RTW_DATA_RATE_HE_NSS1_MCS1: _os_snprintf(str, str_len,"HE_NSS1_MCS1"); break;
case RTW_DATA_RATE_HE_NSS1_MCS2: _os_snprintf(str, str_len,"HE_NSS1_MCS2"); break;
case RTW_DATA_RATE_HE_NSS1_MCS3: _os_snprintf(str, str_len,"HE_NSS1_MCS3"); break;
case RTW_DATA_RATE_HE_NSS1_MCS4: _os_snprintf(str, str_len,"HE_NSS1_MCS4"); break;
case RTW_DATA_RATE_HE_NSS1_MCS5: _os_snprintf(str, str_len,"HE_NSS1_MCS5"); break;
case RTW_DATA_RATE_HE_NSS1_MCS6: _os_snprintf(str, str_len,"HE_NSS1_MCS6"); break;
case RTW_DATA_RATE_HE_NSS1_MCS7: _os_snprintf(str, str_len,"HE_NSS1_MCS7"); break;
case RTW_DATA_RATE_HE_NSS1_MCS8: _os_snprintf(str, str_len,"HE_NSS1_MCS8"); break;
case RTW_DATA_RATE_HE_NSS1_MCS9: _os_snprintf(str, str_len,"HE_NSS1_MCS9"); break;
case RTW_DATA_RATE_HE_NSS1_MCS10: _os_snprintf(str, str_len,"HE_NSS1_MCS10"); break;
case RTW_DATA_RATE_HE_NSS1_MCS11: _os_snprintf(str, str_len,"HE_NSS1_MCS11"); break;
case RTW_DATA_RATE_HE_NSS2_MCS0: _os_snprintf(str, str_len,"HE_NSS2_MCS0"); break;
case RTW_DATA_RATE_HE_NSS2_MCS1: _os_snprintf(str, str_len,"HE_NSS2_MCS1"); break;
case RTW_DATA_RATE_HE_NSS2_MCS2: _os_snprintf(str, str_len,"HE_NSS2_MCS2"); break;
case RTW_DATA_RATE_HE_NSS2_MCS3: _os_snprintf(str, str_len,"HE_NSS2_MCS3"); break;
case RTW_DATA_RATE_HE_NSS2_MCS4: _os_snprintf(str, str_len,"HE_NSS2_MCS4"); break;
case RTW_DATA_RATE_HE_NSS2_MCS5: _os_snprintf(str, str_len,"HE_NSS2_MCS5"); break;
case RTW_DATA_RATE_HE_NSS2_MCS6: _os_snprintf(str, str_len,"HE_NSS2_MCS6"); break;
case RTW_DATA_RATE_HE_NSS2_MCS7: _os_snprintf(str, str_len,"HE_NSS2_MCS7"); break;
case RTW_DATA_RATE_HE_NSS2_MCS8: _os_snprintf(str, str_len,"HE_NSS2_MCS8"); break;
case RTW_DATA_RATE_HE_NSS2_MCS9: _os_snprintf(str, str_len,"HE_NSS2_MCS9"); break;
case RTW_DATA_RATE_HE_NSS2_MCS10: _os_snprintf(str, str_len,"HE_NSS2_MCS10"); break;
case RTW_DATA_RATE_HE_NSS2_MCS11: _os_snprintf(str, str_len,"HE_NSS2_MCS11"); break;
case RTW_DATA_RATE_HE_NSS3_MCS0: _os_snprintf(str, str_len,"HE_NSS3_MCS0"); break;
case RTW_DATA_RATE_HE_NSS3_MCS1: _os_snprintf(str, str_len,"HE_NSS3_MCS1"); break;
case RTW_DATA_RATE_HE_NSS3_MCS2: _os_snprintf(str, str_len,"HE_NSS3_MCS2"); break;
case RTW_DATA_RATE_HE_NSS3_MCS3: _os_snprintf(str, str_len,"HE_NSS3_MCS3"); break;
case RTW_DATA_RATE_HE_NSS3_MCS4: _os_snprintf(str, str_len,"HE_NSS3_MCS4"); break;
case RTW_DATA_RATE_HE_NSS3_MCS5: _os_snprintf(str, str_len,"HE_NSS3_MCS5"); break;
case RTW_DATA_RATE_HE_NSS3_MCS6: _os_snprintf(str, str_len,"HE_NSS3_MCS6"); break;
case RTW_DATA_RATE_HE_NSS3_MCS7: _os_snprintf(str, str_len,"HE_NSS3_MCS7"); break;
case RTW_DATA_RATE_HE_NSS3_MCS8: _os_snprintf(str, str_len,"HE_NSS3_MCS8"); break;
case RTW_DATA_RATE_HE_NSS3_MCS9: _os_snprintf(str, str_len,"HE_NSS3_MCS9"); break;
case RTW_DATA_RATE_HE_NSS3_MCS10: _os_snprintf(str, str_len,"HE_NSS3_MCS10"); break;
case RTW_DATA_RATE_HE_NSS3_MCS11: _os_snprintf(str, str_len,"HE_NSS3_MCS11"); break;
case RTW_DATA_RATE_HE_NSS4_MCS0: _os_snprintf(str, str_len,"HE_NSS4_MCS0"); break;
case RTW_DATA_RATE_HE_NSS4_MCS1: _os_snprintf(str, str_len,"HE_NSS4_MCS1"); break;
case RTW_DATA_RATE_HE_NSS4_MCS2: _os_snprintf(str, str_len,"HE_NSS4_MCS2"); break;
case RTW_DATA_RATE_HE_NSS4_MCS3: _os_snprintf(str, str_len,"HE_NSS4_MCS3"); break;
case RTW_DATA_RATE_HE_NSS4_MCS4: _os_snprintf(str, str_len,"HE_NSS4_MCS4"); break;
case RTW_DATA_RATE_HE_NSS4_MCS5: _os_snprintf(str, str_len,"HE_NSS4_MCS5"); break;
case RTW_DATA_RATE_HE_NSS4_MCS6: _os_snprintf(str, str_len,"HE_NSS4_MCS6"); break;
case RTW_DATA_RATE_HE_NSS4_MCS7: _os_snprintf(str, str_len,"HE_NSS4_MCS7"); break;
case RTW_DATA_RATE_HE_NSS4_MCS8: _os_snprintf(str, str_len,"HE_NSS4_MCS8"); break;
case RTW_DATA_RATE_HE_NSS4_MCS9: _os_snprintf(str, str_len,"HE_NSS4_MCS9"); break;
case RTW_DATA_RATE_HE_NSS4_MCS10: _os_snprintf(str, str_len,"HE_NSS4_MCS10"); break;
case RTW_DATA_RATE_HE_NSS4_MCS11: _os_snprintf(str, str_len,"HE_NSS4_MCS11"); break;
case RTW_DATA_RATE_MAX: _os_snprintf(str, str_len,"RATE_MAX"); break;
default:
_os_snprintf(str, str_len,"Unknown rate(0x%01x)", (unsigned int)rx_rate);
break;
}
}
void phl_dbg_cmd_asoc_sta(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
u32 ctrl = 0, wrole_idx = 0;
u32 used = 0;
struct rtw_wifi_role_t *wrole = NULL;
struct rtw_phl_stainfo_t *n, *psta;
void *drv = phl_to_drvpriv(phl_info);
char tx_rate_str[32] = {0};
char rx_rate_str[32] = {0};
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "\nDUMP Associate STA infomations\n");
if(input_num < 2) {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "phl asoc_sta [wrole index] [1=dump list basic information]\n");
return;
}
_get_hex_from_string(input[1], &ctrl);
_get_hex_from_string(input[2], &wrole_idx);
if (wrole_idx >= MAX_WIFI_ROLE_NUMBER) {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "Wrole Index shall < 5\n");
return;
}
wrole = phl_get_wrole_by_ridx(phl_info, (u8)wrole_idx);
if (1 == ctrl) {
_os_spinlock(drv, &wrole->assoc_sta_queue.lock, _bh, NULL);
phl_list_for_loop_safe(psta, n, struct rtw_phl_stainfo_t,
&wrole->assoc_sta_queue.queue, list) {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "\nmac_id 0x%x ; aid 0x%x ; mac addr %02x-%02x-%02x-%02x-%02x-%02x ; AX_Support %d\n",
(int)psta->macid, (int)psta->aid,
psta->mac_addr[0], psta->mac_addr[1],
psta->mac_addr[2], psta->mac_addr[3],
psta->mac_addr[4], psta->mac_addr[5],
(psta->wmode&WLAN_MD_11AX) ? 1 : 0);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "WROLE-IDX:%d wlan_mode:0x%02x, chan:%d, bw%d\n",
psta->wrole->id, psta->wmode, psta->chandef.chan, psta->chandef.bw);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[Stats] Tput -[Tx:%d KBits Rx :%d KBits]\n",
(int)psta->stats.tx_tp_kbits, (int)psta->stats.rx_tp_kbits);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[Stats] RSSI:-%d(dBm)\n",
PHL_MAX_RSSI - psta->hal_sta->rssi_stat.ma_rssi);
_convert_tx_rate( psta->hal_sta->ra_info.rpt_rt_i.mode,
psta->hal_sta->ra_info.rpt_rt_i.mcs_ss_idx,
tx_rate_str, 32);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[Stats] Tx Rate :%s\n",
tx_rate_str);
_convert_rx_rate(psta->stats.rx_rate, rx_rate_str, 32);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[Stats] Rx Rate :%s\n",
rx_rate_str);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[Stats] rx_ok_cnt:%d rx_err_cnt:%d\n",
(int)psta->hal_sta->trx_stat.rx_ok_cnt,
(int)psta->hal_sta->trx_stat.rx_err_cnt);
}
_os_spinunlock(drv, &wrole->assoc_sta_queue.lock, _bh, NULL);
}
}
#ifdef CONFIG_PCI_HCI
void _dbg_tx_stats_pcie(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len, u32 *used,
u32 ctrl, u32 ch)
{
struct hci_info_t *hci_info = (struct hci_info_t *)phl_info->hci;
struct rtw_hal_com_t *hal_com = rtw_hal_get_halcom(phl_info->hal);
struct rtw_wp_rpt_stats *rpt_stats = NULL;
rpt_stats = (struct rtw_wp_rpt_stats *)hal_com->trx_stat.wp_rpt_stats;
if (ch >= hci_info->total_txch_num) {
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"\n Invalid channel number\n");
return;
}
if (0xFF == ctrl) {
rpt_stats[ch].tx_ok_cnt = 0;
rpt_stats[ch].rty_fail_cnt = 0;
rpt_stats[ch].lifetime_drop_cnt = 0;
rpt_stats[ch].macid_drop_cnt = 0;
rpt_stats[ch].sw_drop_cnt = 0;
rpt_stats[ch].recycle_fail_cnt = 0;
rpt_stats[ch].delay_tx_ok_cnt = 0;
rpt_stats[ch].delay_rty_fail_cnt = 0;
rpt_stats[ch].delay_lifetime_drop_cnt = 0;
rpt_stats[ch].delay_macid_drop_cnt = 0;
return;
}
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"\n== wp report statistics == \n");
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"ch : %u\n", (int)ch);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"busy count : %u\n", (int)rpt_stats[ch].busy_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"ok count : %u\n", (int)rpt_stats[ch].tx_ok_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"retry fail count : %u\n",
(int)rpt_stats[ch].rty_fail_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"lifetime drop count : %u\n",
(int)rpt_stats[ch].lifetime_drop_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"macid drop count : %u\n",
(int)rpt_stats[ch].macid_drop_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"sw drop count : %u\n",
(int)rpt_stats[ch].sw_drop_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"recycle fail count : %u\n",
(int)rpt_stats[ch].recycle_fail_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"delay ok count : %u\n",
(int)rpt_stats[ch].delay_tx_ok_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"delay retry fail count : %u\n",
(int)rpt_stats[ch].delay_rty_fail_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"delay lifetime drop count : %u\n",
(int)rpt_stats[ch].delay_lifetime_drop_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"delay macid drop count : %u\n",
(int)rpt_stats[ch].delay_macid_drop_cnt);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"ltr tx delay count : %u\n",
(int)hal_com->trx_stat.ltr_tx_dly_count);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"ltr last tx delay time : %u\n",
(int)hal_com->trx_stat.ltr_last_tx_dly_time);
}
#endif
void phl_dbg_ltr_stats(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
#ifdef CONFIG_PCI_HCI
u32 used = 0;
#ifdef RTW_WKARD_DYNAMIC_LTR
if (input_num == 3) {
if (0 == _os_strcmp(input[1], "set")) {
if (0 == _os_strcmp(input[2], "disable")) {
phl_ltr_hw_ctrl(phl_info->phl_com, false);
phl_ltr_sw_ctrl(phl_info->phl_com, phl_info->hal, false);
} else if (0 == _os_strcmp(input[2], "enable")) {
phl_ltr_hw_ctrl(phl_info->phl_com, true);
phl_ltr_sw_ctrl(phl_info->phl_com, phl_info->hal, true);
} else {
return;
}
}
return;
}
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"\nltr sw ctrl : %u\n",
rtw_hal_ltr_is_sw_ctrl(phl_info->phl_com, phl_info->hal) ? 1 : 0);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"ltr hw ctrl : %u\n",
rtw_hal_ltr_is_hw_ctrl(phl_info->phl_com, phl_info->hal) ? 1 : 0);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"ltr current state : %u\n",
phl_ltr_get_cur_state(phl_info->phl_com));
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"ltr last trigger time : %lu\n",
phl_ltr_get_last_trigger_time(phl_info->phl_com));
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"ltr active trigger cnt: %lu\n",
phl_ltr_get_tri_cnt(phl_info->phl_com, RTW_PCIE_LTR_SW_ACT));
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"ltr idle trigger cnt: %lu\n",
phl_ltr_get_tri_cnt(phl_info->phl_com, RTW_PCIE_LTR_SW_IDLE));
#else
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"Not Support Dynamical LTR\n");
#endif
#endif
}
void phl_dbg_trx_stats(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
struct rtw_phl_com_t *phl_com = phl_info->phl_com;
struct rtw_stats *phl_stats = &phl_com->phl_stats;
u32 used = 0;
u32 ctrl = 0;
u32 ch = 0;
if (input_num < 2) {
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"Invalid Input\n");
return;
}
_get_hex_from_string(input[1], &ch);
if (input_num == 3) {
_get_hex_from_string(input[2], &ctrl);
}
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"\nunicast tx bytes : %llu\n", phl_stats->tx_byte_uni);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"total tx bytes : %llu\n", phl_stats->tx_byte_total);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"tx throughput : %d(kbps)\n",
(int)phl_stats->tx_tp_kbits);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"last tx time : %d(ms)\n",
(int)phl_stats->last_tx_time_ms);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"tx request num to phl : %d\n",
(int)phl_stats->txreq_num);
#ifdef CONFIG_PCI_HCI
_dbg_tx_stats_pcie(phl_info, input, input_num, output, out_len, &used,
ctrl, ch);
#endif
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"\nunicast rx bytes : %llu\n", phl_stats->rx_byte_uni);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"total rx bytes : %llu\n", phl_stats->rx_byte_total);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"rx throughput : %d(kbps)\n",
(int)phl_stats->rx_tp_kbits);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"last rx time : %d(ms)\n",
(int)phl_stats->last_rx_time_ms);
}
void phl_dbg_cmd_show_rssi(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
u32 used = 0;
struct rtw_phl_rssi_stat *rssi_stat = NULL;
struct rtw_phl_stainfo_t *psta = NULL;
struct rtw_phl_com_t *phl_com = NULL;
u32 macid = 0;
if (NULL == phl_info)
return;
rssi_stat = &phl_info->phl_com->rssi_stat;
phl_com = phl_info->phl_com;
_os_spinlock(phl_com->drv_priv,
&(phl_com->rssi_stat.lock), _bh, NULL);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "\nShow Moving Average RSSI Statistics Informations\n");
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"DATA (A1 Match, AddrCam Valid) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_DATA_ACAM_A1M]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"DATA (A1 Not Match, AddrCam Valid) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_DATA_ACAM]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"DATA (other) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_DATA_OTHER]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"MGNT (A1 Match, AddrCam Valid) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_MGNT_ACAM_A1M]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"MGNT (A1 Not Match, AddrCam Valid) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_MGNT_ACAM]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"MGNT (other) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_MGNT_OTHER]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"CTRL (A1 Match, AddrCam Valid) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_CTRL_ACAM_A1M]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"CTRL (A1 Not Match, AddrCam Valid) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_CTRL_ACAM]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"CTRL (other) : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_CTRL_OTHER]);
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"Unknown : %d\n",
rssi_stat->ma_rssi[RTW_RSSI_UNKNOWN]);
_os_spinunlock(phl_com->drv_priv,
&(phl_com->rssi_stat.lock), _bh, NULL);
if(input_num > 1) {
_get_hex_from_string(input[1], &macid);
psta = rtw_phl_get_stainfo_by_macid(phl_info, (u16)macid);
if (psta != NULL) {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used,
"STA macid : %d ; mv_avg_rssi = %d ; asoc_rssi = %d (bb : %d, %d)\n",
(int)macid, (int)psta->hal_sta->rssi_stat.ma_rssi,
(int)psta->hal_sta->rssi_stat.assoc_rssi,
(int)(psta->hal_sta->rssi_stat.rssi >> 1),
(int)(psta->hal_sta->rssi_stat.rssi_ma >> 5));
}
}
}
void phl_dbg_cmd_parser(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
u8 id = 0;
u32 i;
u32 used = 0;
u32 phl_ary_size = sizeof(phl_dbg_cmd_i) /
sizeof(struct phl_dbg_cmd_info);
if (phl_ary_size == 0)
return;
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used, "\n");
/* Parsing Cmd ID */
if (input_num) {
for (i = 0; i < phl_ary_size; i++) {
if (_os_strcmp(phl_dbg_cmd_i[i].name, input[0]) == 0) {
id = phl_dbg_cmd_i[i].id;
PHL_DBG("[%s]===>\n", phl_dbg_cmd_i[i].name);
break;
}
}
if (i == phl_ary_size) {
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "PHL CMD not found!\n");
return;
}
}
switch (id) {
case PHL_DBG_MON_HELP:
{
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"phl_dbg_cmd_parser : PHL_DBG_MON_HELP \n");
for (i = 0; i < phl_ary_size - 2; i++)
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "%-5d: %s\n",
(int)i, phl_dbg_cmd_i[i + 2].name);
}
break;
case PHL_DBG_MON_TEST:
{
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] PHL_DBG_MON_TEST (SAMPLE) \n");
}
break;
case PHL_DBG_COMP:
{
u32 ctrl = 0, comp = 0;
u32 ret = 0;
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] PHL_DBG_COMP [1=set, 2=clear] [comp_bit] \n");
if (input_num <= 2)
break;
_get_hex_from_string(input[1], &ctrl);
_get_hex_from_string(input[2], &comp);
ret = rtw_phl_dbg_ctrl_comp((u8)ctrl, (u8)comp);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] PHL_DBG_COMP (COMP = 0x%x) \n", (int)ret);
}
break;
case PHL_DBG_DUMP_WROLE:
{
_dump_wifi_role(phl_info, output, out_len);
}
break;
case PHL_DBG_SET_CH_BW:
{
_phl_dbg_cmd_switch_chbw(phl_info, input, input_num,
output, out_len);
}
break;
case PHL_DBG_SHOW_RX_RATE:
{
_dump_rx_rate(phl_info, input, input_num, output, out_len);
}
break;
case PHL_DBG_SOUND :
{
phl_dbg_cmd_snd(phl_info, input, input_num, output, out_len);
}
break;
case PHL_DBG_ASOC_STA:
{
phl_dbg_cmd_asoc_sta(phl_info, input, input_num, output, out_len);
}
break;
#ifdef CONFIG_FSM
case PHL_DBG_FSM:
{
phl_fsm_dbg(phl_info, input, input_num, output, out_len);
}
break;
#endif
case PHL_DBG_TRX_STATS:
{
phl_dbg_trx_stats(phl_info, input, input_num, output, out_len);
}
break;
case PHL_DBG_LTR:
{
phl_dbg_ltr_stats(phl_info, input, input_num, output, out_len);
}
break;
case PHL_SHOW_RSSI_STAT :
{
phl_dbg_cmd_show_rssi(phl_info, input, input_num, output, out_len);
}
break;
case PHL_DBG_SER:
{
phl_ser_cmd_parser(phl_info, input, input_num, output, out_len);
}
break;
case PHL_DBG_WOW:
{
_dump_wow_stats(phl_info, input, input_num, output, out_len);
}
break;
#ifdef CONFIG_POWER_SAVE
case PHL_DBG_PS:
{
phl_ps_cmd_parser(phl_info, input, input_num, output, out_len);
}
break;
#endif
#ifdef CONFIG_MCC_SUPPORT
case PHL_DBG_MCC:
{
_dump_mcc_info(phl_info, input, input_num, output, out_len);
}
break;
#endif /* CONFIG_MCC_SUPPORT */
case PHL_DBG_ECSA:
{
#ifdef CONFIG_PHL_ECSA
struct rtw_wifi_role_t *role = NULL;
struct rtw_phl_ecsa_param param = {0};
int chan = 0;
int bw = 0;
int offset = 0;
int count = 0;
int op_class = 0;
int mode = 0;
int delay_start_ms = 0;
if (input_num <= 7)
break;
_os_sscanf(input[1], "%d", &chan);
_os_sscanf(input[2], "%d", &bw);
_os_sscanf(input[3], "%d", &offset);
_os_sscanf(input[4], "%d", &count);
_os_sscanf(input[5], "%d", &op_class);
_os_sscanf(input[6], "%d", &mode);
_os_sscanf(input[7], "%d", &delay_start_ms);
role = phl_get_wrole_by_ridx(phl_info, 2);
if(role){
param.ecsa_type = ECSA_TYPE_AP;
param.ch = (u8)chan;
param.count = (u8)count;
param.flag = 0;
param.mode = (u8)mode;
param.op_class = (u8)op_class;
param.delay_start_ms = delay_start_ms;
param.new_chan_def.chan = (u8)chan;
param.new_chan_def.bw = (u8)bw;
param.new_chan_def.offset = (u8)offset;
rtw_phl_ecsa_start(phl_info, role, ¶m);
}
else
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[DBG] Role 2 is NULL\n");
#else
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[DBG] ECSA not support!\n");
#endif /* CONFIG_PHL_ECSA */
}
break;
case PHL_DBG_CFG_TX_DUTY:
{
int tx_duty = 100;
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] PHL_DBG_CFG_TX_DUTY [100-30] \n");
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] TX duty interval = 100ms \n");
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] No TX duty control: 100 \n");
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] Minimum TX duty control: 30 (TX 30ms pause TX 70ms)\n");
if (input_num <= 1)
break;
_os_sscanf(input[1], "%d", &tx_duty);
if (tx_duty < 30 || tx_duty > 100) {
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] TX duty should be 30~100 \n");
break;
}
if (tx_duty == 100)
phl_thermal_protect_stop_tx_duty(phl_info);
else
phl_thermal_protect_cfg_tx_duty(phl_info, 100, (u8)tx_duty);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"[DBG] Current TX duty control: %d \n", tx_duty);
}
break;
default:
PHL_DBG_MON_INFO(out_len, used, output + used,
out_len - used, "[DBG] Do not support this command\n");
break;
}
}
s32
phl_dbg_proc_cmd(struct phl_info_t *phl_info,
char *input, char *output, u32 out_len)
{
char *token;
u32 argc = 0;
char argv[MAX_ARGC][MAX_ARGV];
do {
token = _os_strsep(&input, ", ");
if (token) {
if (_os_strlen((u8 *)token) <= MAX_ARGV)
_os_strcpy(argv[argc], token);
argc++;
} else {
break;
}
} while (argc < MAX_ARGC);
if (argc == 1)
argv[0][_os_strlen((u8 *)argv[0])] = '\0';
phl_dbg_cmd_parser(phl_info, argv, argc, output, out_len);
return 0;
}
enum rtw_hal_status
rtw_phl_dbg_proc_cmd(struct phl_info_t *phl_info,
struct rtw_proc_cmd *incmd,
char *output,
u32 out_len)
{
if (incmd->in_type == RTW_ARG_TYPE_BUF) {
phl_dbg_proc_cmd(phl_info, incmd->in.buf, output, out_len);
} else if(incmd->in_type == RTW_ARG_TYPE_ARRAY){
phl_dbg_cmd_parser(phl_info, incmd->in.vector,
incmd->in_cnt_len, output, out_len);
}
return RTW_HAL_STATUS_SUCCESS;
}
#endif
|
2301_81045437/rtl8852be
|
phl/test/phl_dbg_cmd.c
|
C
|
agpl-3.0
| 52,769
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef __PHL_DBG_CMD_H__
#define __PHL_DBG_CMD_H__
#include "../phl_headers.h"
#include "../phl_types.h"
#include "../phl_struct.h"
#define PHL_DBG_MON_INFO(max_buff_len, used_len, buff_addr, remain_len, fmt, ...)\
do { \
u32 *used_len_tmp = &(used_len); \
if (*used_len_tmp < max_buff_len) \
*used_len_tmp += _os_snprintf(buff_addr, remain_len, fmt, ##__VA_ARGS__);\
} while (0)
struct phl_dbg_cmd_info {
char name[16];
u8 id;
};
enum rtw_phl_status
rtw_phl_dbg_core_cmd(struct phl_info_t *phl_info, struct rtw_proc_cmd *incmd, char *output, u32 out_len);
#ifdef CONFIG_PHL_TEST_SUITE
enum PHL_DBG_CMD_ID {
PHL_DBG_MON_HELP,
PHL_DBG_MON_TEST,
PHL_DBG_COMP,
PHL_DBG_DUMP_WROLE,
PHL_DBG_SET_CH_BW,
PHL_DBG_SHOW_RX_RATE,
PHL_DBG_ASOC_STA,
PHL_DBG_SOUND,
#ifdef CONFIG_FSM
PHL_DBG_FSM,
#endif
PHL_DBG_TRX_STATS,
PHL_SHOW_RSSI_STAT,
PHL_DBG_SER,
PHL_DBG_WOW,
#ifdef CONFIG_POWER_SAVE
PHL_DBG_PS,
#endif
PHL_DBG_ECSA,
PHL_DBG_MCC,
PHL_DBG_LTR,
PHL_DBG_CFG_TX_DUTY
};
static const struct phl_dbg_cmd_info phl_dbg_cmd_i[] = {
{"-h", PHL_DBG_MON_HELP}, /*@do not move this element to other position*/
{"test", PHL_DBG_MON_TEST},
{"dbgcomp", PHL_DBG_COMP},
{"role", PHL_DBG_DUMP_WROLE},
{"set_ch", PHL_DBG_SET_CH_BW},
{"rxrate", PHL_DBG_SHOW_RX_RATE},
{"asoc_sta", PHL_DBG_ASOC_STA},
{"sound", PHL_DBG_SOUND},
#ifdef CONFIG_FSM
{"fsm",PHL_DBG_FSM},
#endif
{"trx_stats", PHL_DBG_TRX_STATS},
{"show_rssi", PHL_SHOW_RSSI_STAT},
{"ser", PHL_DBG_SER},
{"wow", PHL_DBG_WOW},
#ifdef CONFIG_POWER_SAVE
{"ps", PHL_DBG_PS},
#endif
{"ecsa", PHL_DBG_ECSA},
{"mcc", PHL_DBG_MCC},
{"ltr", PHL_DBG_LTR},
{"tx_duty", PHL_DBG_CFG_TX_DUTY}
};
enum rtw_hal_status
rtw_phl_dbg_proc_cmd(struct phl_info_t *phl_info,
struct rtw_proc_cmd *incmd,
char *output,
u32 out_len);
bool
_get_hex_from_string(char *szstr, u32 *val);
#else
#define rtw_phl_dbg_proc_cmd(_phl_info, _incmd, _output, _out_len) RTW_HAL_STATUS_SUCCESS
#endif
#endif
|
2301_81045437/rtl8852be
|
phl/test/phl_dbg_cmd.h
|
C
|
agpl-3.0
| 2,648
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_PS_DBG_CMD_C_
#include "../phl_headers.h"
#ifdef CONFIG_POWER_SAVE
struct phl_ps_cmd_info {
char name[16];
u8 id;
};
enum PHL_PS_CMD_ID {
PHL_PS_HELP,
PHL_PS_SHOW,
PHL_PS_TEST,
PHL_PS_STOP_PS
};
struct phl_ps_cmd_info phl_ps_cmd_i[] = {
{"-h", PHL_PS_HELP},
{"show", PHL_PS_SHOW},
{"test", PHL_PS_TEST},
{"stop_ps", PHL_PS_STOP_PS}
};
/* echo phl ps show */
static void _phl_ps_cmd_show(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
if (phl_info == NULL)
return;
phl_ps_dbg_dump(phl_info, used, input, input_num, output, out_len);
}
/* debug to disable power saving */
static void _phl_ps_cmd_stop_ps(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
if (phl_info == NULL)
return;
phl_ps_dbg_stop_ps(phl_info, used, input, input_num, output, out_len);
}
static void _phl_ps_cmd_test_ps(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
if (phl_info == NULL)
return;
phl_ps_dbg_test_ps(phl_info, used, input, input_num, output, out_len);
}
void phl_ps_cmd_parser(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
u32 used = 0;
u8 id = 0;
u32 i;
u32 array_size = sizeof(phl_ps_cmd_i) / sizeof(struct phl_ps_cmd_info);
PS_CNSL(out_len, used, output + used, out_len - used, "\n");
/* Parsing Cmd ID */
if (input_num) {
for (i = 0; i < array_size; i++) {
if (!_os_strcmp(phl_ps_cmd_i[i].name, input[1])) {
id = phl_ps_cmd_i[i].id;
break;
}
}
}
switch (id) {
case PHL_PS_TEST:
_phl_ps_cmd_test_ps(phl_info, &used, input, input_num,
output, out_len);
break;
case PHL_PS_SHOW:
_phl_ps_cmd_show(phl_info, &used, input, input_num,
output, out_len);
break;
case PHL_PS_STOP_PS:
_phl_ps_cmd_stop_ps(phl_info, &used, input, input_num,
output, out_len);
break;
default:
PS_CNSL(out_len, used, output + used, out_len - used,
"command not supported !!\n");
/* fall through */
case PHL_PS_HELP:
PS_CNSL(out_len, used, output + used, out_len - used,
"PS cmd ==>\n");
for (i = 0; i < array_size - 1; i++)
PS_CNSL(out_len, used, output + used, out_len - used,
" %s\n", phl_ps_cmd_i[i + 1].name);
break;
}
}
void phl_ps_dbg_dump(struct phl_info_t *phl_info, u32 *used,
char input[][MAX_ARGV], u32 input_num, char *output, u32 out_len)
{
struct phl_module_op_info op_info = {0};
struct phl_cmd_ps_basic_info info = {0};
struct rtw_ps_cap_t *ps_cap = NULL;
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"========== Basic Info ==========\n");
op_info.op_code = PS_MDL_OP_BASIC_INFO;
op_info.inbuf = (u8 *)&info;
#ifdef CONFIG_CMD_DISP
if (phl_disp_eng_query_bk_module_info(phl_info, HW_BAND_0,
PHL_MDL_POWER_MGNT, &op_info) != RTW_PHL_STATUS_SUCCESS)
return;
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"ps_mode: %s, cur_pwr_lvl: %s\
\nap_active: %s, gc_active: %s\
\ntx traffic lvl: %s, rx traffic lvl: %s\n",
phl_ps_ps_mode_to_str(info.ps_mode), phl_ps_pwr_lvl_to_str(info.cur_pwr_lvl),
(info.ap_active == true ? "yes" : "no"), (info.gc_active == true ? "yes" : "no"),
phl_tfc_lvl_to_str(phl_info->phl_com->phl_stats.tx_traffic.lvl), phl_tfc_lvl_to_str(phl_info->phl_com->phl_stats.rx_traffic.lvl));
if (info.sta != NULL) {
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"chnl: %d, rssi: %d, rssi_bcn: %d\n",
info.sta->chandef.chan ,rtw_hal_get_sta_rssi(info.sta), phl_get_min_rssi_bcn(phl_info));
}
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"========== Advanced Info ==========\n");
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"last enter reason: %s\
\nlast leave reason: %s\
\nreject all pwr req: %s\
\nbtc req pwr: %s\
\nruntime stop reason: %d\n",
info.enter_rson,
info.leave_rson,
(info.rej_pwr_req == true ? "yes" : "no"),
(info.btc_req_pwr == true ? "yes" : "no"),
info.rt_stop_rson);
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"========== Capability ==========\n");
ps_cap = _get_ps_cap(phl_info);
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"init_rf_state: %s, init_rt_stop_rson: 0x%x, leave_fail_act: 0x%x\
\nlps: %s, lps_cap: %s, lps_pause_tx: %d\
\nawake_interval: %d, listen_bcn_mode: %d, smart_ps_mode: %d\
\nrssi_enter_threshold: %d, rssi_leave_threshold: %d, rssi_diff_threshold: %d\
\nips: %s, ips_cap: %s\n",
(ps_cap->init_rf_state ? "off" : "on"), ps_cap->init_rt_stop_rson, ps_cap->leave_fail_act,
phl_ps_op_mode_to_str(ps_cap->lps_en), phl_ps_pwr_lvl_to_str(phl_ps_judge_pwr_lvl(ps_cap->lps_cap, PS_MODE_LPS, true)), ps_cap->lps_pause_tx,
ps_cap->lps_awake_interval, ps_cap->lps_listen_bcn_mode, ps_cap->lps_smart_ps_mode,
ps_cap->lps_rssi_enter_threshold, ps_cap->lps_rssi_leave_threshold, ps_cap->lps_rssi_diff_threshold,
phl_ps_op_mode_to_str(ps_cap->ips_en), phl_ps_pwr_lvl_to_str(phl_ps_judge_pwr_lvl(ps_cap->ips_cap, PS_MODE_IPS, true)));
#else
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"Not support.\n");
#endif
}
void phl_ps_dbg_stop_ps(struct phl_info_t *phl_info, u32 *used,
char input[][MAX_ARGV], u32 input_num, char *output, u32 out_len)
{
u32 stop = 0;
bool ps_en = false;
struct rtw_phl_com_t *phl_com = phl_info->phl_com;
do {
if (input_num < 3){
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"[DBG] echo phl ps stop_ps <0/1>\n");
break;
}
if (!_get_hex_from_string(input[2], &stop))
break;
if ((phl_com->dev_sw_cap.ps_cap.ips_en != PS_OP_MODE_AUTO)&&
(phl_com->dev_sw_cap.ps_cap.lps_en != PS_OP_MODE_AUTO)){
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"One of ips or lps should set PS_OP_MODE_AUTO\n");
break;
}
if (stop)
ps_en = false;
else
ps_en = true;
rtw_phl_ps_set_rt_cap((void*)phl_info, HW_BAND_0, ps_en, PS_RT_DEBUG);
} while (0);
}
void phl_ps_dbg_test_ps(struct phl_info_t *phl_info, u32 *used,
char input[][MAX_ARGV], u32 input_num, char *output, u32 out_len)
{
u32 enter = 0;
u8 ps_mode = PS_MODE_NONE;
do {
if (input_num < 4){
PS_CNSL(out_len, *used, output + *used, out_len - *used,
"[DBG] echo phl ps test <ips/lps> <0/1>\n");
break;
}
if (!_os_strcmp(input[2], "lps")) {
ps_mode = PS_MODE_LPS;
} else if (!_os_strcmp(input[2], "ips")) {
ps_mode = PS_MODE_IPS;
} else {
break;
}
if (!_get_hex_from_string(input[3], &enter))
break;
phl_ps_dbg_set_ps(phl_info, ps_mode, (enter ? true : false));
} while (0);
}
#endif /* CONFIG_POWER_SAVE */
|
2301_81045437/rtl8852be
|
phl/test/phl_ps_dbg_cmd.c
|
C
|
agpl-3.0
| 7,342
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef _PHL_PS_DBG_CMD_H_
#define _PHL_PS_DBG_CMD_H_
#ifdef CONFIG_POWER_SAVE
#define PS_CNSL(max_buff_len, used_len, buff_addr, remain_len, fmt, ...)\
do { \
u32 *used_len_tmp = &(used_len); \
if (*used_len_tmp < max_buff_len) \
*used_len_tmp += _os_snprintf(buff_addr, remain_len, fmt, ##__VA_ARGS__);\
} while (0)
void phl_ps_cmd_parser(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len);
void phl_ps_dbg_dump(struct phl_info_t *phl_info, u32 *used,
char input[][MAX_ARGV], u32 input_num, char *output, u32 out_len);
void phl_ps_dbg_stop_ps(struct phl_info_t *phl_info, u32 *used,
char input[][MAX_ARGV], u32 input_num, char *output, u32 out_len);
void phl_ps_dbg_test_ps(struct phl_info_t *phl_info, u32 *used,
char input[][MAX_ARGV], u32 input_num, char *output, u32 out_len);
#endif
#endif /* _PHL_PS_DBG_CMD_H_ */
|
2301_81045437/rtl8852be
|
phl/test/phl_ps_dbg_cmd.h
|
C
|
agpl-3.0
| 1,548
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_SER_DBG_CMD_C_
#include "../phl_headers.h"
struct phl_ser_cmd_info {
char name[16];
u8 id;
};
enum PHL_SER_CMD_ID {
PHL_SER_STATE,
PHL_SER_CMAC,
PHL_SER_DMAC,
};
struct phl_ser_cmd_info phl_ser_cmd_i[] = {
{"state", PHL_SER_STATE},
{"cmac", PHL_SER_CMAC},
{"dmac", PHL_SER_DMAC}
};
/* echo phl ser state */
void _phl_ser_cmd_state(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
struct rtw_stats *ser_stat = &phl_info->phl_com->phl_stats;
PHL_DBG_MON_INFO(out_len, *used, output + *used,
out_len - *used, "\n[SER statistic]\
\nRTW_PHL_SER_L0_RESET = %d\
\nRTW_PHL_SER_PAUSE_TRX (M1) = %d\
\nRTW_PHL_SER_DO_RECOVERY (M3) = %d\
\nRTW_PHL_SER_READY (M5) = %d\
\nRTW_PHL_SER_L2_RESET = %d\
\nRTW_PHL_SER_EVENT_CHK = %d\
\nRTW_PHL_SER_DUMP_FW_LOG = %d\
\nRTW_PHL_SER_LOG_ONLY = %d\n",
(int)ser_stat->ser_event[RTW_PHL_SER_L0_RESET],
(int)ser_stat->ser_event[RTW_PHL_SER_PAUSE_TRX],
(int)ser_stat->ser_event[RTW_PHL_SER_DO_RECOVERY],
(int)ser_stat->ser_event[RTW_PHL_SER_READY],
(int)ser_stat->ser_event[RTW_PHL_SER_L2_RESET],
(int)ser_stat->ser_event[RTW_PHL_SER_EVENT_CHK],
(int)ser_stat->ser_event[RTW_PHL_SER_DUMP_FW_LOG],
(int)ser_stat->ser_event[RTW_PHL_SER_LOG_ONLY]);
}
/* echo phl ser cmac */
void _phl_ser_cmd_cmac(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len )
{
enum rtw_hal_status status = RTW_HAL_STATUS_FAILURE;
struct hal_info_t *hal_info = (struct hal_info_t *)(phl_info->hal);
status = rtw_hal_trigger_cmac_err(hal_info);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"\nSER CMAC Reset (status = 0x%x) \n", (int)status);
}
/* echo phl ser dmac */
void _phl_ser_cmd_dmac(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len )
{
enum rtw_hal_status status = RTW_HAL_STATUS_FAILURE;
struct hal_info_t *hal_info = (struct hal_info_t *)(phl_info->hal);
status = rtw_hal_trigger_dmac_err(hal_info);
PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
"\nSER DMAC Reset (status = 0x%x) \n", (int)status);
}
void phl_ser_cmd_parser(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len)
{
u32 used = 0;
u8 id = 0;
u32 i;
u32 array_size = sizeof(phl_ser_cmd_i) / sizeof(struct phl_ser_cmd_info);
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used, "\n");
/* Parsing cmd ID */
if (input_num) {
for (i = 0; i < array_size; i++) {
if (!_os_strcmp(phl_ser_cmd_i[i].name, input[1])) {
id = phl_ser_cmd_i[i].id;
break;
}
}
}
switch (id) {
case PHL_SER_STATE:
_phl_ser_cmd_state(phl_info, &used, input, input_num,
output, out_len);
break;
case PHL_SER_CMAC:
_phl_ser_cmd_cmac(phl_info, &used, input, input_num,
output, out_len);
break;
case PHL_SER_DMAC:
_phl_ser_cmd_dmac(phl_info, &used, input, input_num,
output, out_len);
break;
default:
PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
"command not supported !!\n");
break;
}
}
|
2301_81045437/rtl8852be
|
phl/test/phl_ser_dbg_cmd.c
|
C
|
agpl-3.0
| 3,841
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef _PHL_SER_DBG_CMD_H_
#define _PHL_SER_DBG_CMD_H_
void phl_ser_cmd_parser(struct phl_info_t *phl_info, char input[][MAX_ARGV],
u32 input_num, char *output, u32 out_len);
#endif
|
2301_81045437/rtl8852be
|
phl/test/phl_ser_dbg_cmd.h
|
C
|
agpl-3.0
| 837
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _TEST_MODULE_C_
#ifdef CONFIG_PHL_TEST_SUITE
#include "../phl_headers.h"
#define MAX_TEST_OBJ_NUM 128
#define THREAD_SLEEP_UNIT 1000 /* ms */
#define MAX_TEST_CMD_BUF 2000
#define TEST_MGNT_ALREADY_INIT(_test_mgnt) \
((_test_mgnt) && TEST_STATUS_FLAG((_test_mgnt)->status,TM_STATUS_INIT))
#define IS_TEST_MGNT_ALLOC(_phl_com) ((_phl_com) && ((_phl_com)->test_mgnt))
enum TEST_MGNT_STATUS_FALGS{
TM_STATUS_INIT = BIT0,
TM_STATUS_FORCE_STOP = BIT1,
TM_STATUS_THREAD_START = BIT2
};
enum TEST_OBJ_STATUS_FALGS{
/* regular status*/
TO_STATUS_PASS = BIT0,
TO_STATUS_FAIL = BIT1,
TO_STATUS_ENQ = BIT2,
TO_STATUS_RUNNING = BIT3,
/* process error status*/
TO_STATUS_RUN_THREAD_FAIL = BIT24,
TO_STATUS_TIMEOUT = BIT25,
};
struct test_object_ex {
struct test_object test_obj;
u32 start_time;
u32 end_time;
u32 status;
struct rtw_phl_handler handler;
void* test_mgnt;
_os_thread objthread;
u8 submd_obj_id;
u8 submd_test_mode;
};
struct test_obj_queue {
_os_list q;
_os_mutex lock;
};
struct test_mgnt_info{
struct test_obj_queue idle_queue;
struct test_obj_queue busy_queue;
struct test_obj_queue rpt_queue;
struct test_obj_queue err_queue;
struct test_object_ex test_obj_pool[MAX_TEST_OBJ_NUM];
struct test_object_ex *cur_test_obj;
s32 max_run_time[TEST_LVL_MAX];
_os_thread thread;
u32 status;
_os_sema busy_chk;
struct rtw_phl_com_t *phl_com;
struct phl_info_t *phl;
void *hal;
/* test module context root */
void *mp_ctx;
void *ver_ctx;
};
struct test_module_cmd {
u8 type;
u8 buf[MAX_TEST_CMD_BUF];
u16 len;
};
struct test_module_info {
u8 tm_type;
u8 tm_mode;
};
static void _init_test_obj_queue(void *d, struct test_obj_queue *queue)
{
INIT_LIST_HEAD(&queue->q);
_os_mutex_init(d, &queue->lock);
}
static void _deinit_test_obj_queue(void *d, struct test_obj_queue *queue)
{
_os_mutex_deinit(d, &queue->lock);
}
static int _enqueue_obj(void *d,
struct test_obj_queue *queue, struct test_object_ex *obj)
{
_os_mutex_lock(d, &queue->lock);
list_add_tail(&(obj->test_obj.list), &queue->q);
_os_mutex_unlock(d, &queue->lock);
return 0;
}
static u8 _dequeue_head_obj(void *d,
struct test_obj_queue *queue, struct test_object_ex **obj)
{
(*obj) = NULL;
if(list_empty(&(queue->q)))
return false;
_os_mutex_lock(d, &queue->lock);
(*obj) = list_first_entry(&(queue->q),
struct test_object_ex, test_obj.list);
list_del(&((*obj)->test_obj.list));
_os_mutex_unlock(d, &queue->lock);
return ((*obj) == NULL|| ((struct list_head*)(*obj)) == &(queue->q)) ? \
(false) : (true);
}
int run_test(void *testobj)
{
struct test_object_ex *obj = (struct test_object_ex *)testobj;
struct test_mgnt_info *test_mgnt = obj->test_mgnt;
u8 ret = false;
u32 start_time = 0;
u32 end_time = 0;
void *d = test_mgnt->phl_com->drv_priv;
/* -1: no limit, 0: not set use default value */
s32 limit = obj->test_obj.total_time_ms;
enum rtw_phl_status pstatus = RTW_PHL_STATUS_SUCCESS;
if (obj->test_obj.total_time_ms != -1) {
limit = (obj->test_obj.total_time_ms) ? \
(obj->test_obj.total_time_ms) : \
(test_mgnt->max_run_time[obj->test_obj.run_lvl]);
}
SET_STATUS_FLAG(obj->status, TO_STATUS_RUNNING);
pstatus = phl_schedule_handler(test_mgnt->phl_com, &(obj->handler));
if (RTW_PHL_STATUS_SUCCESS != pstatus) {
SET_STATUS_FLAG(obj->status, TO_STATUS_RUN_THREAD_FAIL);
CLEAR_STATUS_FLAG(obj->status, TO_STATUS_RUNNING);
return 0;
}
start_time = _os_get_cur_time_us();
/*wait test end*/
while (!(obj->test_obj.ctrl.is_test_end(obj->test_obj.priv))) {
end_time = _os_get_cur_time_us();
if ((limit >= 0) && ((s32)((end_time-start_time)/1000) >= limit)) {
SET_STATUS_FLAG(obj->status, TO_STATUS_TIMEOUT);
obj->end_time = end_time;
break;
}
_os_sleep_us(test_mgnt->phl_com->drv_priv, THREAD_SLEEP_UNIT);
}
if (!TEST_STATUS_FLAG(obj->status, TO_STATUS_TIMEOUT))
obj->end_time = _os_get_cur_time_us();
ret = obj->test_obj.ctrl.is_test_pass(obj->test_obj.priv);
SET_STATUS_FLAG(obj->status, (!ret) ? \
(TO_STATUS_FAIL) : (TO_STATUS_PASS));
_enqueue_obj(d, &(test_mgnt->rpt_queue), obj);
if (obj->submd_test_mode == INTGR_TEST_MODE) {
if (!_os_thread_check_stop(d, &(obj->objthread)))
_os_thread_wait_stop(d, &obj->objthread);
}
CLEAR_STATUS_FLAG(obj->status, TO_STATUS_RUNNING);
PHL_INFO("[TM]: obj thread (%s) stop.\n", obj->test_obj.name);
return 0;
}
int test_thread(void *param)
{
struct test_mgnt_info *test_mgnt
= (struct test_mgnt_info *)phl_container_of(param,
struct test_mgnt_info,
thread);
void *d = NULL;
struct test_object_ex *obj;
if (!IS_TEST_MGNT_ALLOC(test_mgnt->phl_com))
return 0;
d = test_mgnt->phl_com->drv_priv;
if (!TEST_MGNT_ALREADY_INIT(test_mgnt)) {
PHL_ERR("[TM]: return.\n");
return 0;
}
PHL_INFO("[TM]: thread started.\n");
SET_STATUS_FLAG(test_mgnt->status, TM_STATUS_THREAD_START);
while (!TEST_STATUS_FLAG(test_mgnt->status, TM_STATUS_FORCE_STOP)) {
_os_sema_down(d, &(test_mgnt->busy_chk));
if (TEST_STATUS_FLAG(test_mgnt->status, TM_STATUS_FORCE_STOP))
break;
while (_dequeue_head_obj(d, &(test_mgnt->busy_queue),
&(test_mgnt->cur_test_obj))) {
_os_thread *thread = NULL;
obj = test_mgnt->cur_test_obj;
CLEAR_STATUS_FLAG(obj->status, TO_STATUS_ENQ);
if (obj->submd_test_mode == UNIT_TEST_MODE) {
PHL_INFO("[TM]: %s UNIT_TEST_MODE \n", __FUNCTION__);
run_test(obj);
} else if (obj->submd_test_mode == INTGR_TEST_MODE) {
PHL_INFO("[TM]: %s INTGR_TEST_MODE \n", __FUNCTION__);
thread = &obj->objthread;
_os_thread_init(d, thread, run_test, obj, obj->test_obj.name);
_os_thread_schedule(d, thread);
}
test_mgnt->cur_test_obj = NULL;
}
}
CLEAR_STATUS_FLAG(test_mgnt->status, TM_STATUS_THREAD_START);
PHL_INFO("[TM]: test mgnt thread is down\n");
return 0;
}
static void _test_submodule_deinit(void *tm)
{
struct test_mgnt_info *test_mgnt = (struct test_mgnt_info *)tm;
phl_test_mp_deinit(test_mgnt->mp_ctx);
phl_test_verify_deinit(test_mgnt->ver_ctx);
}
u8 phl_test_module_init(struct phl_info_t *phl_info)
{
struct rtw_phl_com_t* phl_com = phl_info->phl_com;
struct test_mgnt_info *test_mgnt = NULL;
void *d = NULL;
u8 i = 0;
if(phl_com==NULL)
goto _test_module_mem;
d = phl_com->drv_priv;
test_mgnt = (struct test_mgnt_info *)_os_mem_alloc(d,
sizeof(struct test_mgnt_info));
if (test_mgnt == NULL)
goto _test_module_mem;
_os_mem_set(d, test_mgnt, 0, sizeof(struct test_mgnt_info));
phl_com->test_mgnt = test_mgnt;
test_mgnt->phl_com = phl_com;
test_mgnt->phl = phl_info;
test_mgnt->hal = phl_info->hal;
for(i = 0; i < MAX_TEST_OBJ_NUM; i++)
test_mgnt->test_obj_pool[i].submd_obj_id = TEST_SUB_MODULE_UNKNOWN;
if (phl_test_mp_alloc(test_mgnt->phl, test_mgnt->hal, &(test_mgnt->mp_ctx)) != RTW_PHL_STATUS_SUCCESS) {
PHL_INFO("[TM]: %s phl_test_mp_alloc fail!\n",__FUNCTION__);
goto _mp_module_mem;
}
if(phl_test_verify_alloc(test_mgnt->phl, test_mgnt->hal, &(test_mgnt->ver_ctx)) != RTW_PHL_STATUS_SUCCESS) {
PHL_INFO("[TM]: %s phl_test_verify_alloc fail!\n",__FUNCTION__);
goto _verify_module_mem;
}
PHL_INFO("[TM]: %s\n",__FUNCTION__);
return true;
_verify_module_mem:
phl_test_mp_free(&test_mgnt->mp_ctx);
_mp_module_mem:
_os_mem_free(d, test_mgnt, sizeof(struct test_mgnt_info));
_test_module_mem:
return false;
}
void phl_test_module_deinit(struct rtw_phl_com_t* phl_com)
{
void *d = NULL;
struct test_mgnt_info *test_mgnt = NULL;
if(!IS_TEST_MGNT_ALLOC(phl_com))
return;
d = phl_com->drv_priv;
test_mgnt = phlcom_to_test_mgnt(phl_com);
if(TEST_MGNT_ALREADY_INIT(test_mgnt))
phl_test_module_stop(phl_com);
phl_test_mp_free(&test_mgnt->mp_ctx);
phl_test_verify_free(&test_mgnt->ver_ctx);
_os_mem_free(d, test_mgnt, sizeof(struct test_mgnt_info));
phl_com->test_mgnt = NULL;
PHL_INFO("[TM]: %s\n",__FUNCTION__);
}
u8 phl_test_module_start(struct rtw_phl_com_t* phl_com)
{
struct test_mgnt_info *test_mgnt = NULL;
_os_thread *thread = NULL;
void *d = NULL;
u32 i = 0;
if(!IS_TEST_MGNT_ALLOC(phl_com))
return false;
d = phl_com->drv_priv;
test_mgnt = phlcom_to_test_mgnt(phl_com);
if(TEST_MGNT_ALREADY_INIT(test_mgnt)) {
PHL_INFO("[TM]: %s, already initialized\n",__FUNCTION__);
return true;
}
test_mgnt->status = 0;
_init_test_obj_queue(d, &(test_mgnt->busy_queue));
_init_test_obj_queue(d, &(test_mgnt->idle_queue));
_init_test_obj_queue(d, &(test_mgnt->rpt_queue));
_init_test_obj_queue(d, &(test_mgnt->err_queue));
/*insert all elements in obj pool into idle Q*/
for(i = 0; i < MAX_TEST_OBJ_NUM;i++) {
test_mgnt->test_obj_pool[i].submd_obj_id = TEST_SUB_MODULE_UNKNOWN;
_enqueue_obj(d, &(test_mgnt->idle_queue),
&(test_mgnt->test_obj_pool[i]));
}
test_mgnt->max_run_time[TEST_LVL_LOW] = TEST_LVL_LOW_TO;
test_mgnt->max_run_time[TEST_LVL_NORMAL] = TEST_LVL_NORMAL_TO;
test_mgnt->max_run_time[TEST_LVL_HIGH] = TEST_LVL_HIGH_TO;
SET_STATUS_FLAG(test_mgnt->status, TM_STATUS_INIT);
thread = &(test_mgnt->thread);
_os_sema_init(d, &(test_mgnt->busy_chk), 0);
_os_thread_init(d, thread, test_thread, thread, "test_thread");
_os_thread_schedule(d, thread);
PHL_INFO("[TM]: %s\n",__FUNCTION__);
return true;
}
void phl_test_module_stop(struct rtw_phl_com_t* phl_com)
{
struct test_mgnt_info *test_mgnt = NULL;
void *d = NULL;
u32 i = 0;
if(!IS_TEST_MGNT_ALLOC(phl_com))
return;
d = phl_com->drv_priv;
test_mgnt = phlcom_to_test_mgnt(phl_com);
if(!TEST_MGNT_ALREADY_INIT(test_mgnt))
return;
/* Call all sub module deinit */
_test_submodule_deinit(test_mgnt);
SET_STATUS_FLAG(test_mgnt->status, TM_STATUS_FORCE_STOP);
_os_thread_stop(d, &(test_mgnt->thread));
_os_sema_up(d, &(test_mgnt->busy_chk));
/*wait thread stop*/
PHL_INFO("[TM]: %s stop test_thread\n",__FUNCTION__);
_os_thread_deinit(d, &(test_mgnt->thread));
_os_sema_free(d, &(test_mgnt->busy_chk));
/*clean up test obj resource*/
for (i = 0; i < MAX_TEST_OBJ_NUM; i++) {
struct test_object_ex *obj = &(test_mgnt->test_obj_pool[i]);
if (obj->submd_obj_id != TEST_SUB_MODULE_UNKNOWN && obj->status != TO_STATUS_ENQ) {
if (obj->submd_test_mode == INTGR_TEST_MODE) {
if (!_os_thread_check_stop(d, &(obj->objthread))) {
_os_thread_stop(d, &(obj->objthread));
_os_thread_deinit(d, &(obj->objthread));
}
}
phl_deregister_handler(phl_com, &(obj->handler));
}
}
/*no need to empty test obj Q before deinit*/
_deinit_test_obj_queue(d, &(test_mgnt->busy_queue));
_deinit_test_obj_queue(d, &(test_mgnt->idle_queue));
_deinit_test_obj_queue(d, &(test_mgnt->rpt_queue));
_deinit_test_obj_queue(d, &(test_mgnt->err_queue));
CLEAR_STATUS_FLAG(test_mgnt->status, TM_STATUS_INIT);
PHL_INFO("[TM]: %s\n",__FUNCTION__);
}
u8
rtw_phl_test_set_max_run_time(struct rtw_phl_com_t* phl_com,
enum TEST_RUN_LVL lvl,
u32 timeout_ms)
{
struct test_mgnt_info *test_mgnt = NULL;
if(!IS_TEST_MGNT_ALLOC(phl_com))
return false;
test_mgnt = phlcom_to_test_mgnt(phl_com);
if(!TEST_MGNT_ALREADY_INIT(test_mgnt))
return false;
test_mgnt = phlcom_to_test_mgnt(phl_com);
test_mgnt->max_run_time[lvl] = timeout_ms;
return true;
}
void setup_test_rpt(void *d, struct test_rpt* rpt,struct test_object_ex *obj)
{
char str[] = "Exceed Time Limit";
char str2[] = "Test not run";
char str3[] = "None";
_os_mem_cpy(d, rpt->name, obj->test_obj.name, TEST_NAME_LEN);
if(TEST_STATUS_FLAG(obj->status, TO_STATUS_TIMEOUT)) {
_os_mem_cpy(d, rpt->rsn, str, sizeof(str));
rpt->status = 0;
rpt->total_time = (u32)((obj->end_time - obj->start_time)/1000);
}
else if(TEST_STATUS_FLAG(obj->status, TO_STATUS_RUN_THREAD_FAIL)) {
_os_mem_cpy(d, rpt->rsn, str2, sizeof(str2));
rpt->status = 0;
rpt->total_time = 0;
}
else{
obj->test_obj.ctrl.get_fail_rsn(obj->test_obj.priv,
(char*)&(rpt->rsn[0]), TEST_NAME_LEN-1);
if(_os_strlen((u8*)rpt->rsn) <= 0)
_os_mem_cpy(d, rpt->rsn, str3, sizeof(str3));
if (TEST_STATUS_FLAG(obj->status, TO_STATUS_PASS))
rpt->status = 1;
else
rpt->status = 0;
rpt->total_time = (u32)((obj->end_time - obj->start_time)/1000);
}
}
u8 rtw_phl_test_get_rpt(struct rtw_phl_com_t* phl_com, u8* buf, u32 len)
{
struct test_mgnt_info *test_mgnt = NULL;
struct test_object_ex *obj = NULL;
u32 rpt_size = sizeof(struct test_rpt);
void *d = NULL;
u8 is_rpt_empty = true;
if(!IS_TEST_MGNT_ALLOC(phl_com))
return false;
d = phl_com->drv_priv;
test_mgnt = phlcom_to_test_mgnt(phl_com);
if(!TEST_MGNT_ALREADY_INIT(test_mgnt))
return false;
while (len >= rpt_size) {
if(_dequeue_head_obj(d, &(test_mgnt->rpt_queue), &obj)) {
is_rpt_empty = false;
setup_test_rpt(d, (struct test_rpt*)buf, obj);
if (TEST_STATUS_FLAG(obj->status, TO_STATUS_TIMEOUT))
_enqueue_obj(d, &(test_mgnt->err_queue), obj);
else {
if (obj->submd_test_mode == INTGR_TEST_MODE) {
if (!_os_thread_check_stop(d, &(obj->objthread))) {
PHL_INFO("[TM]: %s obj thread (%s) stop.\n",
__FUNCTION__,
obj->test_obj.name);
_os_thread_stop(d, &(obj->objthread));
_os_thread_deinit(d, &(obj->objthread));
}
}
phl_deregister_handler(phl_com, &(obj->handler));
obj->status = 0;
obj->submd_obj_id = TEST_SUB_MODULE_UNKNOWN;
_enqueue_obj(d, &(test_mgnt->idle_queue), obj);
}
buf += rpt_size;
len -= rpt_size;
}
else
break;
}
return (is_rpt_empty)?(false):(true);
}
u8 rtw_phl_test_is_test_complete(struct rtw_phl_com_t* phl_com)
{
struct test_mgnt_info *test_mgnt = NULL;
void *d = NULL;
if(!IS_TEST_MGNT_ALLOC(phl_com))
return false;
d = phl_com->drv_priv;
test_mgnt = phlcom_to_test_mgnt(phl_com);
if(!TEST_MGNT_ALREADY_INIT(test_mgnt))
return false;
if (list_empty(&(test_mgnt->busy_queue.q)) && !(test_mgnt->cur_test_obj))
return true;
return false;
}
static void _test_obj_thread_callback(void *context)
{
struct rtw_phl_handler *phl_handler
= (struct rtw_phl_handler *)phl_container_of(context,
struct rtw_phl_handler,
os_handler);
struct test_object_ex *obj = (struct test_object_ex *)phl_handler->context;
obj->start_time = _os_get_cur_time_us();
obj->test_obj.ctrl.start_test(obj->test_obj.priv);
}
u8 init_obj_thread(struct test_mgnt_info *test_mgnt,
struct test_object_ex *obj,
enum TEST_RUN_LVL lvl)
{
enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
switch(lvl){
case TEST_LVL_LOW:
case TEST_LVL_NORMAL:
obj->handler.type = RTW_PHL_HANDLER_PRIO_LOW;
break;
case TEST_LVL_HIGH:
obj->handler.type = RTW_PHL_HANDLER_PRIO_HIGH;
break;
case TEST_LVL_NONE:
case TEST_LVL_MAX:
PHL_TRACE(COMP_PHL_DBG, _PHL_DEBUG_, "init_obj_thread(): Unsupported case:%d, please check it\n",
lvl);
break;
default:
PHL_TRACE(COMP_PHL_DBG, _PHL_DEBUG_, "init_obj_thread(): Unrecognize case:%d, please check it\n",
lvl);
break;
}
obj->handler.callback = _test_obj_thread_callback;
obj->handler.context = obj;
obj->handler.drv_priv = test_mgnt->phl_com->drv_priv;
pstatus = phl_register_handler(test_mgnt->phl_com, &(obj->handler));
return (RTW_PHL_STATUS_SUCCESS != pstatus) ? (false) : (true);
}
u8 rtw_phl_test_add_new_test_obj(struct rtw_phl_com_t *phl_com,
char *name,
void *custom_priv,
enum TEST_RUN_LVL lvl,
struct test_obj_ctrl_interface *ctrl_intf,
s32 total_time_ms,
u8 submd_id,
u8 test_mode)
{
struct test_mgnt_info *test_mgnt = NULL;
struct test_object_ex *obj = NULL;
void *d = NULL;
u8 i;
u8 is_idle_empty = true;
u32 name_len = (_os_strlen((u8 *)name) > (u32)(TEST_NAME_LEN - 1)) ?\
((u32)(TEST_NAME_LEN - 1)) :\
(_os_strlen((u8 *)name) + 1);
if (!IS_TEST_MGNT_ALLOC(phl_com))
return false;
d = phl_com->drv_priv;
test_mgnt = phlcom_to_test_mgnt(phl_com);
if (!TEST_MGNT_ALREADY_INIT(test_mgnt))
return false;
for (i = 0; i < MAX_TEST_OBJ_NUM; i++) {
obj = &(test_mgnt->test_obj_pool[i]);
if (obj->submd_obj_id == submd_id && obj->status == TO_STATUS_RUNNING) {
PHL_INFO("%s() Error same submd id %d\n", __func__, obj->submd_obj_id);
return false;
}
}
if (_dequeue_head_obj(d, &(test_mgnt->idle_queue), &obj)) {
is_idle_empty = false;
if (TEST_STATUS_FLAG(obj->status, TO_STATUS_ENQ))
phl_deregister_handler(phl_com, &(obj->handler));
/*cleanup entire test obj before reuse*/
_os_mem_set(d, obj, 0, sizeof(struct test_object_ex));
_os_mem_cpy(d, &(obj->test_obj.ctrl), ctrl_intf,
sizeof(struct test_obj_ctrl_interface));
_os_mem_cpy(d, &(obj->test_obj.name[0]), name, name_len);
obj->test_obj.priv = custom_priv;
obj->test_obj.run_lvl = lvl;
obj->test_mgnt = test_mgnt;
obj->test_obj.total_time_ms = (lvl <= TEST_LVL_LOW) ?\
(total_time_ms) : (0);
obj->submd_obj_id = submd_id;
obj->submd_test_mode = test_mode;
if (init_obj_thread(test_mgnt, obj, lvl)) {
SET_STATUS_FLAG(obj->status, TO_STATUS_ENQ);
_enqueue_obj(d, &(test_mgnt->busy_queue), obj);
_os_sema_up(d, &(test_mgnt->busy_chk));
PHL_INFO("[TM]: %s, id %u EnQ\n", __FUNCTION__, submd_id);
} else {
_enqueue_obj(d, &(test_mgnt->idle_queue), obj);
PHL_INFO("[TM]: %s, id %u EnQ fail\n", __FUNCTION__, submd_id);
}
}
if (is_idle_empty || !TEST_STATUS_FLAG(obj->status, TO_STATUS_ENQ))
return false;
return true;
}
u8
rtw_phl_test_setup_bp(struct rtw_phl_com_t* phl_com,
struct test_bp_info* bp_info,
u8 submdid)
{
u8 i;
struct test_mgnt_info *test_mgnt = NULL;
struct test_object_ex *obj = NULL;
if(!IS_TEST_MGNT_ALLOC(phl_com))
return false;
test_mgnt = phlcom_to_test_mgnt(phl_com);
for (i = 0; i < MAX_TEST_OBJ_NUM; i++) {
obj = &(test_mgnt->test_obj_pool[i]);
if (obj->submd_obj_id == submdid && TEST_STATUS_FLAG(obj->status, TO_STATUS_RUNNING)) {
PHL_DBG("%s() objid = %d setup bp\n", __func__, obj->submd_obj_id);
break;
}
}
if(!TEST_MGNT_ALREADY_INIT(test_mgnt))
return false;
return (obj && TEST_STATUS_FLAG(obj->status, TO_STATUS_RUNNING))?\
(obj->test_obj.ctrl.bp_handler(obj->test_obj.priv, bp_info)):\
(BP_RET_RUN_ORIGIN_SEC);
}
void rtw_phl_test_submodule_init(struct rtw_phl_com_t* phl_com, void *buf)
{
struct test_mgnt_info *test_mgnt = (struct test_mgnt_info *)phl_com->test_mgnt;
struct test_module_info *tm_info = NULL;
if(buf == NULL)
return;
tm_info = (struct test_module_info *)buf;
switch(tm_info->tm_type) {
case TEST_SUB_MODULE_MP:
phl_test_mp_init(test_mgnt->mp_ctx);
phl_test_mp_start(test_mgnt->mp_ctx, tm_info->tm_mode);
break;
case TEST_SUB_MODULE_VERIFY:
phl_test_verify_init(test_mgnt->ver_ctx);
phl_test_verify_start(test_mgnt->ver_ctx);
break;
case TEST_SUB_MODULE_FPGA:
case TEST_SUB_MODULE_TOOL:
default:
break;
}
}
void rtw_phl_test_submodule_deinit(struct rtw_phl_com_t* phl_com, void *buf)
{
struct test_mgnt_info *test_mgnt = (struct test_mgnt_info *)phl_com->test_mgnt;
struct test_module_info *tm_info = NULL;
if(buf == NULL)
return;
tm_info = (struct test_module_info *)buf;
switch(tm_info->tm_type) {
case TEST_SUB_MODULE_MP:
phl_test_mp_stop(test_mgnt->mp_ctx, tm_info->tm_mode);
phl_test_mp_deinit(test_mgnt->mp_ctx);
break;
case TEST_SUB_MODULE_VERIFY:
phl_test_verify_stop(test_mgnt->ver_ctx);
phl_test_verify_deinit(test_mgnt->ver_ctx);
break;
case TEST_SUB_MODULE_FPGA:
case TEST_SUB_MODULE_TOOL:
default:
break;
}
}
void
rtw_phl_test_submodule_cmd_process(struct rtw_phl_com_t* phl_com,
void *buf,
u32 buf_len)
{
struct test_mgnt_info *test_mgnt = (struct test_mgnt_info *)phl_com->test_mgnt;
struct test_module_cmd *cmd = NULL;
u8 type = TEST_SUB_MODULE_UNKNOWN;
if(buf == NULL)
return;
cmd = (struct test_module_cmd *)buf;
type = cmd->type;
/* debug_dump_data(cmd->buf, MAX_TEST_CMD_BUF, "[TM] cmd buf ="); */
PHL_INFO("%s: len = %d\n", __FUNCTION__, cmd->len);
switch(type) {
case TEST_SUB_MODULE_MP:
phl_test_mp_cmd_process(test_mgnt->mp_ctx, cmd->buf, cmd->len, TEST_SUB_MODULE_MP);
break;
case TEST_SUB_MODULE_VERIFY:
phl_test_verify_cmd_process(test_mgnt->ver_ctx, cmd->buf, cmd->len, TEST_SUB_MODULE_VERIFY);
break;
case TEST_SUB_MODULE_FPGA:
case TEST_SUB_MODULE_TOOL:
default:
break;
}
}
void
rtw_phl_test_submodule_get_rpt(struct rtw_phl_com_t* phl_com,
void *buf,
u32 buf_len)
{
struct test_mgnt_info *test_mgnt = (struct test_mgnt_info *)phl_com->test_mgnt;
struct test_module_cmd *cmd = NULL;
u8 type = TEST_SUB_MODULE_UNKNOWN;
if(!buf)
return;
cmd = (struct test_module_cmd *)buf;
type = cmd->type;
switch(type) {
case TEST_SUB_MODULE_MP:
phl_test_mp_get_rpt(test_mgnt->mp_ctx, cmd->buf, cmd->len);
break;
case TEST_SUB_MODULE_VERIFY:
phl_test_verify_get_rpt(test_mgnt->ver_ctx, cmd->buf, cmd->len);
break;
case TEST_SUB_MODULE_FPGA:
case TEST_SUB_MODULE_TOOL:
default:
break;
}
}
#endif /*ifdef CONFIG_PHL_TEST_SUITE*/
|
2301_81045437/rtl8852be
|
phl/test/test_module.c
|
C
|
agpl-3.0
| 21,902
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _TRX_TEST_C_
#include "../phl_headers.h"
#include "../phl_api.h"
/*#include "../hal_g6/hal_api_mac.h"*/
#ifdef CONFIG_PHL_TEST_SUITE
void rtw_phl_test_rx_callback(void *context);
enum rtw_phl_status phl_recycle_test_tx(void *phl, struct rtw_xmit_req *treq);
void _phl_free_rx_req_pool(void *phl)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *rx_req_pool = &trx_test->rx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
PHL_INFO("_phl_free_rx_req_pool : idle counter (%d), busy counter (%d), total counter (%d)\n",
rx_req_pool->idle_cnt, rx_req_pool->busy_cnt, rx_req_pool->total_cnt);
_os_spinlock_free(drv_priv, &rx_req_pool->idle_lock);
_os_spinlock_free(drv_priv, &rx_req_pool->busy_lock);
INIT_LIST_HEAD(&rx_req_pool->idle_list);
INIT_LIST_HEAD(&rx_req_pool->busy_list);
if (NULL != rx_req_pool->buf) {
_os_mem_free(drv_priv, rx_req_pool->buf, rx_req_pool->buf_len);
}
rx_req_pool->buf_len = 0;
rx_req_pool->idle_cnt = 0;
rx_req_pool->busy_cnt = 0;
rx_req_pool->total_cnt = 0;
}
enum rtw_phl_status _phl_alloc_rx_req_pool(void *phl, u32 rx_req_num)
{
enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *rx_req_pool = &trx_test->rx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
struct rtw_test_rx *rreq = NULL;
u32 buf_len = 0, i = 0;
FUNCIN_WSTS(status);
do {
if (0 == rx_req_num)
break;
rx_req_pool->total_cnt = rx_req_num;
buf_len = sizeof(struct rtw_test_rx) * rx_req_num;
rx_req_pool->buf = _os_mem_alloc(drv_priv, buf_len);
if (NULL == rx_req_pool->buf)
break;
rx_req_pool->buf_len = buf_len;
INIT_LIST_HEAD(&rx_req_pool->idle_list);
INIT_LIST_HEAD(&rx_req_pool->busy_list);
_os_spinlock_init(drv_priv, &rx_req_pool->idle_lock);
_os_spinlock_init(drv_priv, &rx_req_pool->busy_lock);
rreq = (struct rtw_test_rx *)rx_req_pool->buf;
for (i = 0; i < rx_req_num; i++) {
INIT_LIST_HEAD(&rreq[i].list);
list_add_tail(&rreq[i].list, &rx_req_pool->idle_list);
rx_req_pool->idle_cnt++;
}
status = RTW_PHL_STATUS_SUCCESS;
} while (false);
PHL_INFO("_phl_alloc_rx_req_pool : idle counter (%d), busy counter (%d), total counter (%d)\n",
rx_req_pool->idle_cnt, rx_req_pool->busy_cnt, rx_req_pool->total_cnt);
FUNCOUT_WSTS(status);
return status;
}
struct rtw_test_rx *_phl_query_idle_rx_req(struct phl_info_t *phl_info)
{
struct rtw_test_rx *rreq = NULL;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *rx_req_pool = &trx_test->rx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &rx_req_pool->idle_lock, _ps, NULL);
if (false == list_empty(&rx_req_pool->idle_list)) {
rreq = list_first_entry(&rx_req_pool->idle_list,
struct rtw_test_rx, list);
list_del(&rreq->list);
rx_req_pool->idle_cnt--;
}
_os_spinunlock(drv_priv, &rx_req_pool->idle_lock, _ps, NULL);
return rreq;
}
struct rtw_test_rx *_phl_query_busy_rx_req(struct phl_info_t *phl_info)
{
struct rtw_test_rx *rreq = NULL;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *rx_req_pool = &trx_test->rx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &rx_req_pool->busy_lock, _ps, NULL);
if (false == list_empty(&rx_req_pool->busy_list)) {
rreq = list_first_entry(&rx_req_pool->busy_list,
struct rtw_test_rx, list);
list_del(&rreq->list);
rx_req_pool->busy_cnt--;
}
_os_spinunlock(drv_priv, &rx_req_pool->busy_lock, _ps, NULL);
return rreq;
}
void _phl_release_rx_req(struct phl_info_t *phl_info, struct rtw_test_rx *rreq)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *rx_req_pool = &trx_test->rx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &rx_req_pool->idle_lock, _ps, NULL);
_os_mem_set(drv_priv, &rreq->rx.mdata, 0,
sizeof(rreq->rx.mdata));
_os_mem_set(drv_priv, &rreq->rx.pkt_list, 0,
sizeof(rreq->rx.pkt_list) * rreq->rx.pkt_cnt);
rreq->rx.shortcut_id = 0;
rreq->rx.pkt_cnt = 0;
INIT_LIST_HEAD(&rreq->list);
list_add_tail(&rreq->list, &rx_req_pool->idle_list);
rx_req_pool->idle_cnt++;
_os_spinunlock(drv_priv, &rx_req_pool->idle_lock, _ps, NULL);
}
void _phl_insert_busy_rx_req(struct phl_info_t *phl_info, struct rtw_test_rx *rreq)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *rx_req_pool = &trx_test->rx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &rx_req_pool->busy_lock, _ps, NULL);
list_add_tail(&rreq->list, &rx_req_pool->busy_list);
rx_req_pool->busy_cnt++;
_os_spinunlock(drv_priv, &rx_req_pool->busy_lock, _ps, NULL);
}
void _phl_free_tx_req_pool(void *phl)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_req_pool = &trx_test->tx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
PHL_INFO("_phl_free_tx_req_pool : idle counter (%d), busy counter (%d), total counter (%d)\n",
tx_req_pool->idle_cnt, tx_req_pool->busy_cnt, tx_req_pool->total_cnt);
_os_spinlock_free(drv_priv, &tx_req_pool->idle_lock);
_os_spinlock_free(drv_priv, &tx_req_pool->busy_lock);
INIT_LIST_HEAD(&tx_req_pool->idle_list);
INIT_LIST_HEAD(&tx_req_pool->busy_list);
if (NULL != tx_req_pool->buf) {
_os_mem_free(drv_priv, tx_req_pool->buf, tx_req_pool->buf_len);
}
tx_req_pool->buf_len = 0;
tx_req_pool->idle_cnt = 0;
tx_req_pool->busy_cnt = 0;
tx_req_pool->total_cnt = 0;
}
enum rtw_phl_status _phl_alloc_tx_req_pool(void *phl, u32 tx_req_num)
{
enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_req_pool = &trx_test->tx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
struct rtw_xmit_req *treq = NULL;
u32 buf_len = 0, i = 0;
FUNCIN_WSTS(status);
do {
if (0 == tx_req_num)
break;
tx_req_pool->total_cnt = tx_req_num;
buf_len = sizeof(struct rtw_xmit_req) * tx_req_num;
tx_req_pool->buf = _os_mem_alloc(drv_priv, buf_len);
if (NULL == tx_req_pool->buf)
break;
tx_req_pool->buf_len = buf_len;
INIT_LIST_HEAD(&tx_req_pool->idle_list);
INIT_LIST_HEAD(&tx_req_pool->busy_list);
_os_spinlock_init(drv_priv, &tx_req_pool->idle_lock);
_os_spinlock_init(drv_priv, &tx_req_pool->busy_lock);
treq = (struct rtw_xmit_req *)tx_req_pool->buf;
for (i = 0; i < tx_req_num; i++) {
INIT_LIST_HEAD(&treq[i].list);
treq[i].treq_type = RTW_PHL_TREQ_TYPE_TEST_PATTERN;
list_add_tail(&treq[i].list, &tx_req_pool->idle_list);
tx_req_pool->idle_cnt++;
}
status = RTW_PHL_STATUS_SUCCESS;
} while (false);
PHL_INFO("_phl_alloc_tx_req_pool : idle counter (%d), busy counter (%d), total counter (%d)\n",
tx_req_pool->idle_cnt, tx_req_pool->busy_cnt, tx_req_pool->total_cnt);
FUNCOUT_WSTS(status);
return status;
}
struct rtw_xmit_req *_phl_query_idle_tx_req(struct phl_info_t *phl_info)
{
struct rtw_xmit_req *treq = NULL;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_req_pool = &trx_test->tx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_req_pool->idle_lock, _ps, NULL);
if (false == list_empty(&tx_req_pool->idle_list)) {
treq = list_first_entry(&tx_req_pool->idle_list,
struct rtw_xmit_req, list);
list_del(&treq->list);
tx_req_pool->idle_cnt--;
}
_os_spinunlock(drv_priv, &tx_req_pool->idle_lock, _ps, NULL);
return treq;
}
struct rtw_xmit_req *_phl_query_busy_tx_req(struct phl_info_t *phl_info)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_req_pool = &trx_test->tx_req_pool;
struct rtw_xmit_req *treq = NULL;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_req_pool->busy_lock, _ps, NULL);
if (false == list_empty(&tx_req_pool->busy_list)) {
treq = list_first_entry(&tx_req_pool->busy_list,
struct rtw_xmit_req, list);
list_del(&treq->list);
tx_req_pool->busy_cnt--;
}
_os_spinunlock(drv_priv, &tx_req_pool->busy_lock, _ps, NULL);
return treq;
}
void _phl_remove_busy_tx_req(struct phl_info_t *phl_info, struct rtw_xmit_req *treq)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_req_pool = &trx_test->tx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_req_pool->busy_lock, _ps, NULL);
if (false == list_empty(&tx_req_pool->busy_list)) {
list_del(&treq->list);
tx_req_pool->busy_cnt--;
}
_os_spinunlock(drv_priv, &tx_req_pool->busy_lock, _ps, NULL);
}
void _phl_release_tx_req(struct phl_info_t *phl_info, struct rtw_xmit_req *treq)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_req_pool = &trx_test->tx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_req_pool->idle_lock, _ps, NULL);
_os_mem_set(drv_priv, &treq->mdata, 0, sizeof(treq->mdata));
treq->shortcut_id = 0;
treq->total_len = 0;
treq->pkt_cnt = 0;
treq->pkt_list = NULL;
treq->os_priv = NULL;
INIT_LIST_HEAD(&treq->list);
list_add_tail(&treq->list, &tx_req_pool->idle_list);
tx_req_pool->idle_cnt++;
_os_spinunlock(drv_priv, &tx_req_pool->idle_lock, _ps, NULL);
}
void _phl_insert_busy_tx_req(struct phl_info_t *phl_info, struct rtw_xmit_req *treq)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_req_pool = &trx_test->tx_req_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_req_pool->busy_lock, _ps, NULL);
list_add_tail(&treq->list, &tx_req_pool->busy_list);
tx_req_pool->busy_cnt++;
_os_spinunlock(drv_priv, &tx_req_pool->busy_lock, _ps, NULL);
}
void _phl_free_tx_pkt_pool(void *phl)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_pkt_pool = &trx_test->tx_pkt_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
struct rtw_payload *tpkt = NULL;
u32 i = 0;
PHL_INFO("_phl_free_tx_pkt_pool : idle counter (%d), busy counter (%d), total counter (%d)\n",
tx_pkt_pool->idle_cnt, tx_pkt_pool->busy_cnt, tx_pkt_pool->total_cnt);
_os_spinlock_free(drv_priv, &tx_pkt_pool->idle_lock);
_os_spinlock_free(drv_priv, &tx_pkt_pool->busy_lock);
INIT_LIST_HEAD(&tx_pkt_pool->idle_list);
INIT_LIST_HEAD(&tx_pkt_pool->busy_list);
tpkt = (struct rtw_payload *)tx_pkt_pool->buf;
for (i = 0; i < tx_pkt_pool->total_cnt; i++) {
INIT_LIST_HEAD(&tpkt->list);
if (NULL != tpkt->pkt.vir_addr) {
#ifdef CONFIG_PCI_HCI
_os_shmem_free(drv_priv,
tpkt->pkt.vir_addr,
(_dma *)&tpkt->pkt.phy_addr_l,
(_dma *)&tpkt->pkt.phy_addr_h,
MAX_TEST_PAYLOAD_SIZE,
false,
PCI_DMA_TODEVICE,
tpkt->os_rsvd[0]);
#else
_os_mem_free(drv_priv, tpkt->pkt.vir_addr,
tpkt->pkt.length);
#endif
}
tpkt->pkt.length = 0;
tpkt++;
}
if (NULL != tx_pkt_pool->buf) {
_os_mem_free(drv_priv, tx_pkt_pool->buf, tx_pkt_pool->buf_len);
}
tx_pkt_pool->buf_len = 0;
tx_pkt_pool->idle_cnt = 0;
tx_pkt_pool->busy_cnt = 0;
tx_pkt_pool->total_cnt = 0;
}
enum rtw_phl_status _phl_alloc_tx_pkt_pool(void *phl, u32 tx_pkt_num,
u32 tx_pkt_size)
{
enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_pkt_pool = &trx_test->tx_pkt_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
struct rtw_payload *tpkt = NULL;
u32 buf_len = 0, i = 0;
FUNCIN_WSTS(status);
do {
if (0 == tx_pkt_num)
break;
tx_pkt_pool->total_cnt = tx_pkt_num;
buf_len = sizeof(struct rtw_payload) * tx_pkt_num;
tx_pkt_pool->buf = _os_mem_alloc(drv_priv, buf_len);
if (NULL == tx_pkt_pool->buf)
break;
tx_pkt_pool->buf_len = buf_len;
INIT_LIST_HEAD(&tx_pkt_pool->idle_list);
INIT_LIST_HEAD(&tx_pkt_pool->busy_list);
_os_spinlock_init(drv_priv, &tx_pkt_pool->idle_lock);
_os_spinlock_init(drv_priv, &tx_pkt_pool->busy_lock);
tpkt = (struct rtw_payload *)tx_pkt_pool->buf;
for (i = 0; i < tx_pkt_num; i++) {
INIT_LIST_HEAD(&tpkt[i].list);
#ifdef CONFIG_PCI_HCI
tpkt[i].pkt.vir_addr = _os_shmem_alloc(drv_priv,
(_dma *)&tpkt[i].pkt.phy_addr_l,
(_dma *)&tpkt[i].pkt.phy_addr_h,
tx_pkt_size,
false,
PCI_DMA_TODEVICE,
&tpkt[i].os_rsvd[0]);
#else /*USB/SDIO*/
tpkt[i].pkt.vir_addr = _os_mem_alloc(drv_priv, tx_pkt_size);
#endif
if (NULL == tpkt[i].pkt.vir_addr) {
PHL_WARN("allocate tx pkt buf fail\n");
break;
}
/* hana_todo */
/* tpkt[i].pkt.phy_addr_l = 0; */
/* tpkt[i].pkt.phy_addr_h = 0; */
tpkt[i].pkt.length = (u16)tx_pkt_size;
tpkt[i].test_id = i;
list_add_tail(&tpkt[i].list, &tx_pkt_pool->idle_list);
tx_pkt_pool->idle_cnt++;
}
status = RTW_PHL_STATUS_SUCCESS;
} while (false);
PHL_INFO("_phl_alloc_tx_pkt_pool : idle counter (%d), busy counter (%d), total counter (%d)\n",
tx_pkt_pool->idle_cnt, tx_pkt_pool->busy_cnt, tx_pkt_pool->total_cnt);
FUNCOUT_WSTS(status);
return status;
}
struct rtw_payload *_phl_query_idle_tx_pkt(struct phl_info_t *phl_info)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_pkt_pool = &trx_test->tx_pkt_pool;
struct rtw_payload *tpkt = NULL;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_pkt_pool->idle_lock, _ps, NULL);
if (false == list_empty(&tx_pkt_pool->idle_list)) {
tpkt = list_first_entry(&tx_pkt_pool->idle_list,
struct rtw_payload, list);
list_del(&tpkt->list);
tx_pkt_pool->idle_cnt--;
}
_os_spinunlock(drv_priv, &tx_pkt_pool->idle_lock, _ps, NULL);
return tpkt;
}
struct rtw_payload *_phl_query_busy_tx_pkt(struct phl_info_t *phl_info)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_pkt_pool = &trx_test->tx_pkt_pool;
struct rtw_payload *tpkt = NULL;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_pkt_pool->busy_lock, _ps, NULL);
if (false == list_empty(&tx_pkt_pool->busy_list)) {
tpkt = list_first_entry(&tx_pkt_pool->busy_list,
struct rtw_payload, list);
list_del(&tpkt->list);
tx_pkt_pool->busy_cnt--;
}
_os_spinunlock(drv_priv, &tx_pkt_pool->busy_lock, _ps, NULL);
return tpkt;
}
void _phl_remove_busy_tx_pkt(struct phl_info_t *phl_info, struct rtw_payload *tpkt)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_pkt_pool = &trx_test->tx_pkt_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_pkt_pool->busy_lock, _ps, NULL);
if (false == list_empty(&tx_pkt_pool->busy_list)) {
list_del(&tpkt->list);
tx_pkt_pool->busy_cnt--;
}
_os_spinunlock(drv_priv, &tx_pkt_pool->busy_lock, _ps, NULL);
}
void _phl_release_tx_pkt(struct phl_info_t *phl_info, struct rtw_payload *tpkt)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_pkt_pool = &trx_test->tx_pkt_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_pkt_pool->idle_lock, _ps, NULL);
_os_mem_set(drv_priv, tpkt->pkt.vir_addr, 0, tpkt->pkt.length);
tpkt->pkt.length = 0;
INIT_LIST_HEAD(&tpkt->list);
list_add_tail(&tpkt->list, &tx_pkt_pool->idle_list);
tx_pkt_pool->idle_cnt++;
_os_spinunlock(drv_priv, &tx_pkt_pool->idle_lock, _ps, NULL);
}
void _phl_insert_busy_tx_pkt(struct phl_info_t *phl_info, struct rtw_payload *tpkt)
{
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_pkt_pool = &trx_test->tx_pkt_pool;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_spinlock(drv_priv, &tx_pkt_pool->busy_lock, _ps, NULL);
list_add_tail(&tpkt->list, &tx_pkt_pool->busy_list);
tx_pkt_pool->busy_cnt++;
_os_spinunlock(drv_priv, &tx_pkt_pool->busy_lock, _ps, NULL);
}
u8 _phl_is_tx_test_done(void *phl)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *tx_req_pool = &trx_test->tx_req_pool;
struct rtw_pool *tx_pkt_pool = &trx_test->tx_pkt_pool;
if (list_empty(&tx_req_pool->busy_list) && list_empty(&tx_pkt_pool->busy_list))
return true;
else
return false;
}
void phl_update_test_param(void *phl, struct rtw_trx_test_param *test_param)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
void *drv_priv = phl_to_drvpriv(phl_info);
_os_mem_cpy(drv_priv, &trx_test->test_param, test_param, sizeof(*test_param));
}
extern enum rtw_phl_status
phl_wifi_role_start(struct phl_info_t *phl_info,
struct rtw_wifi_role_t *wrole,
struct rtw_phl_stainfo_t *sta);
enum rtw_phl_status _phl_test_add_role(
void *phl,
struct rtw_trx_test_param *test_param)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct rtw_phl_com_t *phl_com = phl_info->phl_com;
struct rtw_t_meta_data *txcap = NULL;
struct rtw_wifi_role_t *test_wrole = &phl_com->wifi_roles[0];
struct rtw_phl_stainfo_t *sta_info = NULL;
if (NULL != test_param) {
txcap = &test_param->tx_cap;
test_wrole->hw_band = txcap->band;
test_wrole->hw_port = (u8)txcap->macid;
sta_info = rtw_phl_get_stainfo_by_addr(phl_info, test_wrole, test_wrole->mac_addr);
if (NULL != sta_info) {
test_param->tx_cap.macid = sta_info->macid;
phl_status = phl_wifi_role_start(phl_info, test_wrole, sta_info);
PHL_INFO("update test param macid to %d\n", test_param->tx_cap.macid);
} else {
PHL_ERR("fail to get stainfo from test wrole!\n");
phl_status = RTW_PHL_STATUS_FAILURE;
}
}
return phl_status;
}
extern enum rtw_phl_status
phl_wifi_role_stop(struct phl_info_t *phl_info, struct rtw_wifi_role_t *wrole);
enum rtw_phl_status _phl_test_remove_role(
void *phl,
struct rtw_trx_test_param *test_param)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct rtw_phl_com_t *phl_com = phl_info->phl_com;
struct rtw_wifi_role_t *test_wrole = &phl_com->wifi_roles[0];
if (NULL != test_param)
phl_status = phl_wifi_role_stop(phl_info, test_wrole);
return phl_status;
}
void phl_test_sw_free(void *phl)
{
FUNCIN();
_phl_free_tx_pkt_pool(phl);
_phl_free_rx_req_pool(phl);
_phl_free_tx_req_pool(phl);
FUNCOUT();
}
enum rtw_phl_status phl_test_sw_alloc(void *phl)
{
enum rtw_phl_status sts = RTW_PHL_STATUS_FAILURE;
FUNCIN_WSTS(sts);
do {
sts = _phl_alloc_tx_req_pool(phl, MAX_TEST_TXREQ_NUM);
if (RTW_PHL_STATUS_SUCCESS != sts)
break;
sts = _phl_alloc_rx_req_pool(phl, MAX_TEST_RXREQ_NUM);
if (RTW_PHL_STATUS_SUCCESS != sts)
break;
sts = _phl_alloc_tx_pkt_pool(phl, MAX_TEST_PAYLOAD_NUM,
MAX_TEST_PAYLOAD_SIZE);
} while (false);
FUNCOUT_WSTS(sts);
return sts;
}
enum rtw_phl_status phl_trx_test_init(void *phl)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = NULL;
struct rtw_phl_evt_ops *ops = &phl_info->phl_com->evt_ops;
void *drv_priv = phl_to_drvpriv(phl_info);
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
if (NULL == (trx_test = _os_mem_alloc(drv_priv, sizeof(struct phl_trx_test)))) {
phl_info->trx_test = NULL;
PHL_ERR("%s: alloc buffer failed\n", __func__);
return RTW_PHL_STATUS_FAILURE;
}
phl_info->trx_test = trx_test;
INIT_LIST_HEAD(&trx_test->rx_q);
_os_mem_set(drv_priv, &trx_test->tx_req_pool, 0, sizeof(trx_test->tx_req_pool));
_os_mem_set(drv_priv, &trx_test->rx_req_pool, 0, sizeof(trx_test->rx_req_pool));
_os_mem_set(drv_priv, &trx_test->tx_pkt_pool, 0, sizeof(trx_test->tx_pkt_pool));
_os_mem_set(drv_priv, &trx_test->test_param, 0, sizeof(trx_test->test_param));
_os_mem_set(drv_priv, &trx_test->trx_test_obj, 0, sizeof(trx_test->trx_test_obj));
ops->tx_test_recycle = phl_recycle_test_tx;
phl_status = phl_test_sw_alloc(phl);
#if 0
gtest_rxq_handler.type = RTW_PHL_HANDLER_PRIO_HIGH; /* tasklet */
gtest_rxq_handler.callback = rtw_phl_test_rx_callback;
gtest_rxq_handler.context = phl_info;
gtest_rxq_handler.drv_priv = phl_to_drvpriv(phl_info);
sts = phl_register_handler(phl_info->phl_com, >est_rxq_handler);
if (RTW_PHL_STATUS_SUCCESS != sts) {
PHL_ERR("register test rx queue handler fail\n");
phl_deregister_handler(phl_info->phl_com, >est_rxq_handler);
}
#endif
return phl_status;
}
void phl_trx_test_deinit(void *phl)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
void *drv = phl_to_drvpriv(phl_info);
phl_test_sw_free(phl);
_os_mem_free(drv, phl_info->trx_test, sizeof(struct phl_trx_test));
phl_info->trx_test = NULL;
}
void phl_test_hw_config_init(void *phl, u8 mode)
{
switch (mode) {
case TEST_MODE_PHL_TX_RING_TEST:
/* address cam receive all */
/* rtl8852a_hal_init_misc: */
/* rtl8852ae_test_loopback: */
break;
default:
break;
}
}
void phl_test_hw_config_runtime(void *phl, u8 mode)
{
switch (mode) {
case TEST_MODE_PHL_TX_RING_TEST:
/* debug register :*/
/* edca config */
/* zero delimiter counter flush */
break;
default:
break;
}
}
void phl_test_fill_packet_content(struct phl_info_t *phl_info, u8 *pkt,
u16 size,
struct rtw_trx_test_param *test_param)
{
void *drv_priv = phl_to_drvpriv(phl_info);
u8 test_pattern[7] = {0x00, 0x01, 0x02, 0x55, 0x66, 0x94, 0x87};
u16 qos_ofst = 0, payload_ofst = 0;
/* wlan header */
SET_WHDR_PROTOCOL_VERSION(pkt, 0);
SET_WHDR_TYPE(pkt, 2); //data
SET_WHDR_SUBTYPE(pkt, 0);
if (true == test_param->ap_mode) {
SET_WHDR_TO_DS(pkt, 0);
SET_WHDR_FROM_DS(pkt, 1);
SET_WHDR_ADDRESS1(drv_priv, pkt, test_param->sta_addr);
SET_WHDR_ADDRESS2(drv_priv, pkt, test_param->bssid);
SET_WHDR_ADDRESS3(drv_priv, pkt, test_param->cur_addr);
} else {
SET_WHDR_TO_DS(pkt, 1);
SET_WHDR_FROM_DS(pkt, 0);
SET_WHDR_ADDRESS1(drv_priv, pkt, test_param->bssid);
SET_WHDR_ADDRESS2(drv_priv, pkt, test_param->cur_addr);
SET_WHDR_ADDRESS3(drv_priv, pkt, test_param->sta_addr);
}
SET_WHDR_MORE_FRAG(pkt, 0);
SET_WHDR_RETRY(pkt, 0);
SET_WHDR_PWR_MGNT(pkt, 0);
SET_WHDR_MORE_DATA(pkt, 0);
SET_WHDR_WEP(pkt, 0);
SET_WHDR_ORDER(pkt, 0);
SET_WHDR_DURATION(pkt, 0);
SET_WHDR_FRAGMENT_SEQUENCE(pkt, 0);
qos_ofst = 24;
if (true == test_param->qos) {
SET_WHDR_QOS_EN(pkt, 1);
SET_WHDR_QOS_CTRL_STA_DATA_TID(pkt + qos_ofst,
test_param->tx_cap.tid);
SET_WHDR_QOS_CTRL_STA_DATA_EOSP(pkt + qos_ofst, 0);
SET_WHDR_QOS_CTRL_STA_DATA_ACK_POLICY(pkt + qos_ofst, 0);
SET_WHDR_QOS_CTRL_STA_DATA_AMSDU(pkt + qos_ofst, 0);
SET_WHDR_QOS_CTRL_STA_DATA_TXOP(pkt + qos_ofst, 0);
}
/* wlan payload */
payload_ofst = qos_ofst + WHDR_QOS_LENGTH;
_os_mem_cpy(drv_priv, pkt + payload_ofst, test_pattern,
sizeof(test_pattern));
debug_dump_data(pkt, size, "phl trx test pattern");
}
void rtw_phl_test_rx_callback(void *context)
{
struct phl_info_t *phl_info = (struct phl_info_t *)context;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_pool *rx_req_pool = &trx_test->rx_req_pool;
struct rtw_test_rx *rreq = NULL;
struct rtw_recv_pkt *recvpkt = NULL;
struct rtw_payload *tpkt = NULL;
while (!list_empty(&rx_req_pool->busy_list)) {
rreq = _phl_query_busy_rx_req(phl_info);
if (NULL == rreq) {
PHL_WARN("Get NULL rx request from busy queue\n");
break;
}
recvpkt = &rreq->rx;
PHL_INFO("Rx test_id = %d\n", rreq->test_id);
PHL_INFO("Rx mac id = %d\n", recvpkt->mdata.macid);
PHL_INFO("Rx tid = %d\n", recvpkt->mdata.tid);
debug_dump_data(recvpkt->mdata.mac_addr, 6, "Rx mac address: ");
debug_dump_data(recvpkt->pkt_list[0].vir_addr,
recvpkt->pkt_list[0].length, "Rx Pkt: ");
_phl_release_rx_req(phl_info, rreq);
tpkt = (struct rtw_payload *)rreq->tpkt;
_phl_release_tx_pkt(phl_info, tpkt);
}
}
enum rtw_phl_status rtw_phl_rx_reap(void *phl, u8 *xmit_req,
struct rtw_trx_test_param *param)
{
enum rtw_phl_status sts = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct rtw_xmit_req *treq = (struct rtw_xmit_req *)xmit_req;
struct rtw_payload *tpkt = NULL;
struct rtw_test_rx *rreq = NULL;
struct rtw_recv_pkt *recvpkt = NULL;
struct rtw_pkt_buf_list *pkt = NULL;
void *drv_priv = phl_to_drvpriv(phl_info);
u8 i = 0;
rreq = _phl_query_idle_rx_req(phl_info);
do {
if (NULL == rreq) {
PHL_ERR("query idle rx request fail!\n");
break;
}
recvpkt = &rreq->rx;
recvpkt->mdata.macid = treq->mdata.macid;
recvpkt->mdata.tid = treq->mdata.tid;
recvpkt->mdata.hal_port = treq->mdata.hal_port;
recvpkt->mdata.dma_ch = 0; /* normal rx ch */
_os_mem_cpy(drv_priv, recvpkt->mdata.mac_addr, param->sta_addr,
6);
recvpkt->mdata.seq = treq->mdata.sw_seq;
recvpkt->mdata.mc = treq->mdata.mc;
recvpkt->mdata.bc = treq->mdata.bc;
pkt = (struct rtw_pkt_buf_list *)treq->pkt_list;
tpkt = phl_container_of(pkt, struct rtw_payload, pkt);
for (i = 0; i < treq->pkt_cnt; i++) {
if (i >= MAX_RX_BUF_SEG_NUM) {
PHL_ERR("tx packet has too many segments\n");
break;
}
recvpkt->pkt_list[i].vir_addr = pkt->vir_addr;
recvpkt->pkt_list[i].phy_addr_l = pkt->phy_addr_l;
recvpkt->pkt_list[i].phy_addr_h = pkt->phy_addr_h;
recvpkt->pkt_list[i].length = pkt->length;
recvpkt->pkt_cnt++;
pkt++;
}
rreq->tpkt = (u8 *)tpkt;
rreq->test_id = tpkt->test_id;
_phl_insert_busy_rx_req(phl_info, rreq);
sts = RTW_PHL_STATUS_SUCCESS;
} while (false);
if (RTW_PHL_STATUS_SUCCESS == sts) {
_phl_release_tx_req(phl_info, treq);
}
return sts;
}
enum rtw_phl_status rtw_phl_test_rxq_notify(void *phl)
{
enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
pstatus = phl_schedule_handler(phl_info->phl_com,
&phl_info->phl_tx_handler);
return pstatus;
}
enum rtw_phl_status phl_tx_ring_test(void *phl,
struct rtw_trx_test_param *test_param)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
void *drv_priv = phl_to_drvpriv(phl_info);
enum rtw_phl_status sts = RTW_PHL_STATUS_FAILURE;
struct rtw_xmit_req *treq = NULL;
struct rtw_payload *tpkt = NULL;
u32 tx_cnt = 0;
FUNCIN_WSTS(sts);
do {
for (tx_cnt = 0; tx_cnt < test_param->tx_req_num; tx_cnt++) {
/* query tx request pool */
treq = _phl_query_idle_tx_req(phl_info);
if (NULL == treq) {
PHL_WARN("query idle tx request from pool fail\n");
break;
}
tpkt = _phl_query_idle_tx_pkt(phl_info);
if (NULL == tpkt) {
PHL_WARN("query idle tx packet from pool fail\n");
break;
}
/* fill meta_data*/
_os_mem_cpy(drv_priv, &treq->mdata, &test_param->tx_cap,
sizeof(struct rtw_t_meta_data));
/* fill tx request content */
if (test_param->tx_payload_size > MAX_TEST_PAYLOAD_SIZE)
tpkt->pkt.length = MAX_TEST_PAYLOAD_SIZE;
else
tpkt->pkt.length = (u16)test_param->tx_payload_size;
phl_test_fill_packet_content(phl_info, tpkt->pkt.vir_addr,
tpkt->pkt.length, test_param);
/* assign this tx pkt to tx request */
treq->os_priv = tpkt;
treq->pkt_cnt = 1;
treq->mdata.wdinfo_en = 1;
treq->total_len = (u16)tpkt->pkt.length;
treq->pkt_list = (u8 *)&tpkt->pkt;
/* add to phl_tx_ring */
sts = rtw_phl_add_tx_req(phl, treq);
if (RTW_PHL_STATUS_SUCCESS != sts) {
PHL_INFO("add new tx request (%d) to phl ring fail\n", tx_cnt);
_phl_release_tx_req(phl_info, treq);
_phl_release_tx_pkt(phl_info, tpkt);
break;
} else {
_phl_insert_busy_tx_req(phl_info, treq);
_phl_insert_busy_tx_pkt(phl_info, tpkt);
}
}
/* schedule tx process */
sts = rtw_phl_tx_req_notify(phl);
if (RTW_PHL_STATUS_SUCCESS != sts) {
PHL_INFO("add notify phl start tx process fail\n");
break;
}
} while (false);
/*
while (false == _phl_is_tx_test_done(phl) && i < 100) {
_os_delay_ms(drv_priv, 1);
i++;
}
*/
FUNCOUT_WSTS(sts);
return sts;
}
enum rtw_phl_status phl_rx_ring_test(void *phl,
struct rtw_trx_test_param *test_param)
{
enum rtw_phl_status sts = RTW_PHL_STATUS_FAILURE;
FUNCIN_WSTS(sts);
do {
sts = rtw_phl_start_rx_process(phl);
if (RTW_PHL_STATUS_FAILURE == sts) {
PHL_TRACE(COMP_PHL_DBG, _PHL_WARNING_, "[WARNING] phl_rx ring fail!\n");
break;
}
} while (false);
FUNCOUT_WSTS(sts);
return sts;
}
enum rtw_phl_status phl_hal_tx_test(void *phl,
struct rtw_trx_test_param *test_param)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
void *drv_priv = phl_to_drvpriv(phl_info);
struct phl_hci_trx_ops *hci_trx_ops = phl_info->hci_trx_ops;
enum rtw_phl_status sts = RTW_PHL_STATUS_FAILURE;
struct rtw_xmit_req *treq = NULL;
struct rtw_payload *tpkt = NULL;
FUNCIN_WSTS(sts);
do {
/* query tx request pool */
treq = _phl_query_idle_tx_req(phl_info);
if (NULL == treq) {
PHL_WARN("query idle tx request from pool fail\n");
break;
}
tpkt = _phl_query_idle_tx_pkt(phl_info);
if (NULL == tpkt) {
PHL_WARN("query idle tx packet from pool fail\n");
break;
}
/* fill meta_data */
_os_mem_cpy(drv_priv, &treq->mdata, &test_param->tx_cap,
sizeof(struct rtw_t_meta_data));
/* fill tx request content */
if (test_param->tx_payload_size > MAX_TEST_PAYLOAD_SIZE)
tpkt->pkt.length = MAX_TEST_PAYLOAD_SIZE;
else
tpkt->pkt.length = (u16)test_param->tx_payload_size;
phl_test_fill_packet_content(phl_info, tpkt->pkt.vir_addr,
tpkt->pkt.length, test_param);
/* assign this tx pkt to tx request */
treq->os_priv = tpkt;
treq->pkt_cnt = 1;
treq->mdata.wdinfo_en = 1;
treq->total_len = (u16)tpkt->pkt.length;
treq->pkt_list = (u8 *)&tpkt->pkt;
/* add to phl_tx_ring */
sts = hci_trx_ops->prepare_tx(phl_info, treq);
if (RTW_PHL_STATUS_SUCCESS != sts) {
PHL_INFO("add new tx request to phl_prepare_tx_pcie fail\n");
break;
}
/* schedule tx process */
sts = hci_trx_ops->tx(phl_info);
if (RTW_PHL_STATUS_SUCCESS != sts) {
PHL_INFO("phl_tx_pcie fail\n");
break;
}
} while (false);
_os_delay_ms(drv_priv, 100);
if (RTW_PHL_STATUS_SUCCESS != sts) {
if (NULL != treq)
_phl_release_tx_req(phl, treq);
if (NULL != tpkt)
_phl_release_tx_pkt(phl, tpkt);
}
FUNCOUT_WSTS(sts);
return sts;
}
enum rtw_phl_status phl_hal_rx_test(void *phl,
struct rtw_trx_test_param *test_param)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_hci_trx_ops *hci_trx_ops = phl_info->hci_trx_ops;
enum rtw_phl_status sts = RTW_PHL_STATUS_FAILURE;
FUNCIN_WSTS(sts);
do {
/* add to phl_tx_ring */
sts = hci_trx_ops->rx(phl_info);
if (RTW_PHL_STATUS_FAILURE == sts) {
PHL_TRACE(COMP_PHL_DBG, _PHL_WARNING_, "[WARNING] phl_rx fail!\n");
break;
}
} while (false);
FUNCOUT_WSTS(sts);
return sts;
}
enum rtw_phl_status phl_trx_test_start(void *phl,
struct rtw_trx_test_param *test_param)
{
enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
FUNCIN_WSTS(status);
switch (test_param->mode) {
case TEST_MODE_PHL_TX_RING_TEST:
status = phl_tx_ring_test(phl, test_param);
break;
case TEST_MODE_PHL_RX_RING_TEST:
status = phl_rx_ring_test(phl, test_param);
break;
case TEST_MODE_HAL_TX_TEST:
status = phl_hal_tx_test(phl, test_param);
break;
case TEST_MODE_HAL_RX_TEST:
status = phl_hal_rx_test(phl, test_param);
break;
default:
break;
}
FUNCOUT_WSTS(status);
return status;
}
void phl_trx_test_dump_result(void *phl, struct rtw_trx_test_param *test_param)
{
PHL_INFO("Test Done");
}
enum rtw_phl_status phl_recycle_test_tx(void *phl, struct rtw_xmit_req *treq)
{
struct phl_info_t *phl_info = NULL;
struct rtw_payload *tpkt = NULL;
enum rtw_phl_status sts = RTW_PHL_STATUS_FAILURE;
FUNCIN_WSTS(sts);
if (NULL == phl) {
PHL_ERR("treq is NULL!\n");
goto end;
}
phl_info = (struct phl_info_t *)phl;
if (NULL == treq) {
PHL_ERR("treq is NULL!\n");
goto end;
}
tpkt = (struct rtw_payload *)treq->os_priv;
if (NULL == tpkt) {
PHL_ERR("tpkt is NULL!\n");
goto end;
}
_phl_remove_busy_tx_req(phl_info, treq);
_phl_release_tx_req(phl_info, treq);
_phl_remove_busy_tx_pkt(phl_info, tpkt);
_phl_release_tx_pkt(phl_info, tpkt);
sts = RTW_PHL_STATUS_SUCCESS;
end:
FUNCOUT_WSTS(sts);
return sts;
}
void _phl_rx_test_pattern(struct phl_info_t *phl_info, void *ptr)
{
struct rtw_recv_pkt *rpkt = NULL;
FUNCIN();
if (NULL == ptr) {
PHL_ERR("bp_info->ptr is NULL!\n");
goto end;
}
rpkt = (struct rtw_recv_pkt *)ptr;
if (NULL == rpkt) {
PHL_ERR("rpkt is NULL!\n");
goto end;
}
PHL_INFO("rpkt->buf_len = %d\n", rpkt->pkt_list[0].length);
debug_dump_data(rpkt->pkt_list[0].vir_addr, (u16)rpkt->pkt_list[0].length, "dump_rx");
end:
FUNCOUT();
}
void rtw_phl_trx_default_param(void *phl, struct rtw_trx_test_param *test_param)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
_os_mem_set(phl_to_drvpriv(phl_info), test_param, 0, sizeof(struct rtw_trx_test_param));
test_param->mode = TEST_MODE_PHL_TX_RING_TEST;
test_param->ap_mode = 0;
test_param->pkt_type = TEST_PKT_TYPE_BC;
test_param->tx_req_num = 1;
test_param->rx_req_num = 1;
test_param->tx_payload_num = 1;
test_param->tx_payload_size = 100;
test_param->trx_mode = 0;
test_param->qta_mode = 0;
test_param->cur_addr[0] = 0x00;
test_param->cur_addr[1] = 0xE0;
test_param->cur_addr[2] = 0x4c;
test_param->cur_addr[3] = 0x88;
test_param->cur_addr[4] = 0x52;
test_param->cur_addr[5] = 0xaa;
if (TEST_PKT_TYPE_BC == test_param->pkt_type || TEST_PKT_TYPE_MC == test_param->pkt_type) {
test_param->sta_addr[0] = 0xFF;
test_param->sta_addr[1] = 0xFF;
test_param->sta_addr[2] = 0xFF;
test_param->sta_addr[3] = 0xFF;
test_param->sta_addr[4] = 0xFF;
test_param->sta_addr[5] = 0xFF;
test_param->bssid[0] = 0xFF;
test_param->bssid[1] = 0xFF;
test_param->bssid[2] = 0xFF;
test_param->bssid[3] = 0xFF;
test_param->bssid[4] = 0xFF;
test_param->bssid[5] = 0xFF;
test_param->tx_cap.bc = 1;
test_param->qos = 0;
} else if (TEST_PKT_TYPE_UNI == test_param->pkt_type){
test_param->sta_addr[0] = 0x00;
test_param->sta_addr[1] = 0xE0;
test_param->sta_addr[2] = 0x4C;
test_param->sta_addr[3] = 0x88;
test_param->sta_addr[4] = 0x52;
test_param->sta_addr[5] = 0xbb;
test_param->bssid[0] = 0x00;
test_param->bssid[1] = 0xE0;
test_param->bssid[2] = 0x4C;
test_param->bssid[3] = 0x88;
test_param->bssid[4] = 0x52;
test_param->bssid[5] = 0xbb;
test_param->tx_cap.bc = 0;
test_param->qos = 1;
}
test_param->tx_cap.macid= 0x00;
test_param->tx_cap.tid = 0x03;
test_param->tx_cap.dma_ch= 0x01;
test_param->tx_cap.band= 0x0;
test_param->tx_cap.userate_sel = 0x1;
test_param->tx_cap.f_rate = 0x87;
test_param->tx_cap.f_bw = 0;
test_param->tx_cap.f_gi_ltf = 0;
}
enum rtw_phl_status rtw_phl_trx_testsuite(void *phl,
struct rtw_trx_test_param *test_param)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_trx_test_param *param = &trx_test->test_param;
enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
FUNCIN_WSTS(status);
do {
param->is_trx_test_end = false;
phl_update_test_param(phl, test_param);
phl_test_hw_config_init(phl, test_param->mode);
status = phl_trx_test_start(phl, test_param);
if (RTW_PHL_STATUS_SUCCESS != status) {
PHL_ERR("The phl trx test failure\n");
break;
}
phl_trx_test_dump_result(phl, test_param);
param->is_trx_test_end = true;
} while (false);
FUNCOUT_WSTS(status);
return status;
}
u8 trx_test_bp_handler(void *priv, struct test_bp_info* bp_info)
{
u8 ret = BP_RET_SKIP_SECTION;
return ret;
}
u8 trx_test_is_test_end(void *priv)
{
struct phl_info_t *phl_info = (struct phl_info_t *)priv;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct rtw_trx_test_param *test_param = &trx_test->test_param;
FUNCIN();
FUNCOUT();
return (test_param->is_trx_test_end == true) ? (true) : (false);
}
u8 trx_test_is_test_pass(void *priv)
{
FUNCIN();
FUNCOUT();
return true;
}
u8 trx_test_get_fail_rsn(void *priv, char* rsn, u32 max_len)
{
//struct phl_info_t *phl_info = (struct phl_info_t *)priv;
FUNCIN();
FUNCOUT();
return true;
}
u8 trx_test_start_test(void *priv)
{
//struct phl_info_t *phl_info = (struct phl_info_t *)priv;
FUNCIN();
FUNCOUT();
return true;
}
void
phl_add_trx_test_obj(void *phl)
{
struct phl_info_t *phl_info = (struct phl_info_t *)phl;
struct phl_trx_test *trx_test = (struct phl_trx_test *)phl_info->trx_test;
struct test_obj_ctrl_interface *trx_test_obj = &trx_test->trx_test_obj;
FUNCIN();
trx_test_obj->bp_handler = trx_test_bp_handler;
trx_test_obj->get_fail_rsn = trx_test_get_fail_rsn;
trx_test_obj->is_test_end = trx_test_is_test_end;
trx_test_obj->is_test_pass = trx_test_is_test_pass;
trx_test_obj->start_test = trx_test_start_test;
rtw_phl_test_add_new_test_obj(phl_info->phl_com,
"tx_test",
phl_info,
TEST_LVL_HIGH,
trx_test_obj,
-1,
TEST_SUB_MODULE_TRX,
UNIT_TEST_MODE);
FUNCOUT();
}
#endif /* #ifdef CONFIG_PHL_TEST_SUITE */
|
2301_81045437/rtl8852be
|
phl/test/trx_test.c
|
C
|
agpl-3.0
| 38,594
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef _TRX_TEST_H_
#define _TRX_TEST_H_
#ifdef CONFIG_PHL_TEST_SUITE
#define MAX_TEST_TXREQ_NUM 256
#define MAX_TEST_PAYLOAD_NUM MAX_TEST_TXREQ_NUM
#define MAX_TEST_RXREQ_NUM 256
#define MAX_TEST_PAYLOAD_SIZE 2308
enum test_mode {
TEST_MODE_PHL_TX_RING_TEST = 1,
TEST_MODE_PHL_RX_RING_TEST = 2,
TEST_MODE_PHL_RING_LOOPBACK = 3,
TEST_MODE_PHL_PCIE_LOOPBACK = 4,
TEST_MODE_HAL_TX_TEST = 5,
TEST_MODE_HAL_RX_TEST = 6,
TEST_MODE_HAL_WP_REPORT_PARSE = 7,
TEST_MODE_HAL_RXDESC_PARSE = 8,
TEST_MODE_HAL_RXBD_PARSE = 9
};
enum pkt_type {
TEST_PKT_TYPE_UNI = 1,
TEST_PKT_TYPE_MC = 2,
TEST_PKT_TYPE_BC = 3,
TEST_PKT_TYPE_MAX = 0xFF,
};
struct rtw_tx_cap {
u16 macid;
u8 tid;
u8 wmm; /* for halmac add role */
u8 dma_ch;
u8 band;
u8 force_txcap;
u16 rate;
u8 bw;
u8 gi_ltf;
u8 stbc;
u8 ldpc;
u8 bk;
u8 type;
};
struct rtw_pool {
u8 *buf;
u32 buf_len;
_os_list idle_list;
_os_list busy_list;
_os_lock idle_lock;
_os_lock busy_lock;
u32 total_cnt;
u32 idle_cnt;
u32 busy_cnt;
};
struct rtw_test_rx {
_os_list list;
u32 test_id;
struct rtw_recv_pkt rx;
u8 *tpkt; /* for loopback mode */
};
struct rtw_payload {
_os_list list;
u32 test_id;
struct rtw_pkt_buf_list pkt;
void *os_rsvd[1];
};
struct rtw_trx_test_param {
u8 is_trx_test_end;
u8 mode;
/* parameter for trx resource*/
u32 tx_req_num;
u32 rx_req_num;
u32 tx_payload_num;
u32 tx_payload_size;
enum pkt_type pkt_type;
u8 ap_mode;
u8 trx_mode;
u8 qta_mode;
u8 qos;
u8 cur_addr[6]; /* mac address of this device */
u8 sta_addr[6]; /* mac address of associating device */
u8 bssid[6];
/* parameter for tx capability */
struct rtw_t_meta_data tx_cap;
/* parameter for hw configure */
/* misc */
};
struct phl_trx_test {
_os_list rx_q;
_os_lock rx_q_lock;
struct rtw_pool tx_req_pool;
struct rtw_pool rx_req_pool;
struct rtw_pool tx_pkt_pool;
struct test_obj_ctrl_interface trx_test_obj;
struct rtw_trx_test_param test_param;
struct rtw_phl_handler test_rxq_handler;
};
#define WHDR_OFST_FRAME_CONTROL 0
#define WHDR_OFST_DURATION 2
#define WHDR_OFST_ADDRESS1 4
#define WHDR_OFST_ADDRESS2 10
#define WHDR_OFST_ADDRESS3 16
#define WHDR_OFST_SEQUENCE 22
#define WHDR_OFST_ADDRESS4 24
#define WHDR_QOS_LENGTH 2
#define SET_WHDR_PROTOCOL_VERSION(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 0, 2, _val)
#define SET_WHDR_TYPE(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 2, 2, _val)
#define SET_WHDR_SUBTYPE(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 4, 4, _val)
#define SET_WHDR_TO_DS(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 8, 1, _val)
#define SET_WHDR_FROM_DS(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 9, 1, _val)
#define SET_WHDR_MORE_FRAG(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 10, 1, _val)
#define SET_WHDR_RETRY(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 11, 1, _val)
#define SET_WHDR_PWR_MGNT(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 12, 1, _val)
#define SET_WHDR_MORE_DATA(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 13, 1, _val)
#define SET_WHDR_WEP(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 14, 1, _val)
#define SET_WHDR_ORDER(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 15, 1, _val)
#define SET_WHDR_QOS_EN(_hdr, _val) \
SET_BITS_TO_LE_2BYTE(_hdr, 7, 1, _val)
#define SET_WHDR_DURATION(_hdr, _val) \
WriteLE2Byte(_hdr + WHDR_OFST_DURATION, _val)
#define SET_WHDR_ADDRESS1(_drv, _hdr, _val) \
_os_mem_cpy(_drv, _hdr + WHDR_OFST_ADDRESS1, _val, 6)
#define SET_WHDR_ADDRESS2(_drv, _hdr, _val) \
_os_mem_cpy(_drv, _hdr + WHDR_OFST_ADDRESS2, _val, 6)
#define SET_WHDR_ADDRESS3(_drv, _hdr, _val) \
_os_mem_cpy(_drv, _hdr + WHDR_OFST_ADDRESS3, _val, 6)
#define SET_WHDR_FRAGMENT_SEQUENCE(_hdr, _val) \
WriteLE2Byte(_hdr + WHDR_OFST_SEQUENCE, _val)
#define SET_WHDR_ADDRESS4(_drv, _hdr, _val) \
_os_mem_cpy(_drv, _hdr + WHDR_OFST_ADDRESS4, _val, 6)
#define SET_WHDR_QOS_CTRL_STA_DATA_TID(_qos, _value) \
SET_BITS_TO_LE_2BYTE((u8 *)_qos, 0, 4, (u8)(_value))
#define SET_WHDR_QOS_CTRL_STA_DATA_EOSP(_qos, _value) \
SET_BITS_TO_LE_2BYTE((u8 *)_qos, 4, 1, (u8)(_value))
#define SET_WHDR_QOS_CTRL_STA_DATA_ACK_POLICY(_qos, _value) \
SET_BITS_TO_LE_2BYTE((u8 *)_qos, 5, 2, (u8)(_value))
#define SET_WHDR_QOS_CTRL_STA_DATA_AMSDU(_qos, _value) \
SET_BITS_TO_LE_2BYTE((u8 *)_qos, 7, 1, (u8)(_value))
#define SET_WHDR_QOS_CTRL_STA_DATA_TXOP(_qos, _value) \
SET_BITS_TO_LE_1BYTE((u8 *)_qos + 1, 0, 8, (u8)(_value))
enum rtw_phl_status phl_trx_test_init(void *phl);
void phl_trx_test_deinit(void *phl);
void rtw_phl_trx_default_param(void *phl,
struct rtw_trx_test_param *test_param);
enum rtw_phl_status rtw_phl_trx_testsuite(void *phl,
struct rtw_trx_test_param *test_param);
#else /*!CONFIG_PHL_TEST_SUITE*/
#define phl_trx_test_init(phl)
#define phl_trx_test_deinit(phl)
#define rtw_phl_trx_default_param(phl, test_param)
#define rtw_phl_trx_testsuite(phl, test_param) RTW_PHL_STATUS_SUCCESS
#endif
#endif /*_TRX_TEST_H_*/
|
2301_81045437/rtl8852be
|
phl/test/trx_test.h
|
C
|
agpl-3.0
| 5,523
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_TEST_DBCC_C_
#include "../../../phl_headers.h"
#include "../phl_test_verify_def.h"
#include "../phl_test_verify_api.h"
#include "phl_test_dbcc_def.h"
#ifdef CONFIG_PHL_TEST_VERIFY
static u8 dbcc_get_class_from_buf(struct verify_context *ctx)
{
u8 *buf_tmp = NULL;
u8 dbcc_class = DBCC_CLASS_MAX;
if (ctx && ctx->buf &&
(ctx->buf_len > VERIFY_CMD_HDR_SIZE)) {
buf_tmp = (u8 *)VERIFY_GET_SUBUF((u8 *)ctx->buf);
dbcc_class = buf_tmp[0];
}
return dbcc_class;
}
static enum rtw_phl_status
dbcc_config(struct verify_context *ctx, struct dbcc_config_arg *arg)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = ctx->phl;
if (arg == NULL) {
return phl_status;
}
PHL_INFO("%s: en %u act %u id %u\n", __FUNCTION__, arg->dbcc_en, arg->action, arg->macid);
#ifdef CONFIG_DBCC_SUPPORT
//if (phl_info->phl_com->dev_cap.dbcc_sup)
phl_status = rtw_phl_dbcc_test(phl_info, arg->action, &arg->dbcc_en);
#else
PHL_ERR("%s: %s No Support DBCC\n", __FUNCTION__,
phl_info->phl_com->hal_spec.ic_name);
phl_status = RTW_PHL_STATUS_SUCCESS;
#endif
return phl_status;
}
static enum rtw_phl_status
dbcc_tx_tmac(struct verify_context *ctx, struct dbcc_tx_arg *arg)
{
struct rtw_trx_test_param test_param = { 0 };
rtw_phl_trx_default_param(ctx->phl, &test_param);
test_param.tx_cap.f_rate = arg->data_rate;
test_param.tx_cap.macid = arg->macid;
if (arg->macid) {
test_param.tx_cap.dma_ch = 4;
/* test_param.tx_cap.q_sel = 8; */
test_param.tx_cap.band = 1;
test_param.cur_addr[4] = 0xbb;
test_param.cur_addr[5] = 0xbb;
} else {
test_param.tx_cap.dma_ch = 0;
/* test_param.tx_cap.q_sel = 0; */
test_param.tx_cap.band = 0;
test_param.cur_addr[4] = 0xaa;
test_param.cur_addr[5] = 0xaa;
}
test_param.tx_cap.hal_port = 0;
test_param.tx_payload_size = 1000;
test_param.tx_cap.f_gi_ltf = 0;
test_param.tx_cap.f_stbc = 0;
test_param.tx_cap.f_ldpc = 0;
test_param.tx_cap.tid = 0;
rtw_phl_trx_testsuite(ctx->phl, &test_param);
return RTW_PHL_STATUS_SUCCESS;
}
static enum rtw_phl_status
dbcc_tx(struct verify_context *ctx, struct dbcc_tx_arg *arg)
{
void *d = phl_to_drvpriv(ctx->phl);
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
if (arg == NULL) {
return phl_status;
}
/* TBD: only for this moment, we force the macid 0 and 1 */
if (arg->tx_method == 0) {
phl_status = dbcc_tx_tmac(ctx, arg);
} else if (arg->tx_method == 1) {
if (arg->tx_count > 0) {
int i;
bool cctx = false;
if (arg->macid == 2)
cctx = true;
for (i = 0; i < arg->tx_count; i++) {
if (cctx)
arg->macid = i % 2;
phl_status = dbcc_tx_tmac(ctx, arg);
_os_delay_ms(d, 10);
}
}
}
return phl_status;
}
static enum rtw_phl_status
dbcc_tx_status(struct verify_context *ctx, struct dbcc_tx_cnt_arg *arg)
{
#ifndef CONFIG_DBCC_SUPPORT
return RTW_PHL_STATUS_SUCCESS;
#else
#if 0 /* no used in this moment */
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
struct phl_info_t *phl_info = ctx->phl;
if (arg == NULL) {
return phl_status;
}
PHL_INFO("%s: arg %u cmd %u band %u", __FUNCTION__, arg->arg_class, arg->cmd, arg->band);
if (arg->cmd == 0) {
phl_status = rtw_hal_dbcc_reset_tx_cnt(phl_info->hal, ctx->phl_com, arg->band);
} else if (arg->cmd == 1) {
if (arg->band) {
phl_status = rtw_hal_dbcc_tx_cnt(phl_info->hal, ctx->phl_com, arg->band);
PHL_INFO("%s: BB REG 0x14240 = 0x%X\n", __FUNCTION__,
rtw_hal_read_bbreg(phl_info->hal, 0x14240, 0xffffffff));
} else {
phl_status = rtw_hal_dbcc_tx_cnt(phl_info->hal, ctx->phl_com, arg->band);
PHL_INFO("%s: BB REG 0x14140 = 0x%X\n", __FUNCTION__,
rtw_hal_read_bbreg(phl_info->hal, 0x14140, 0xffffffff));
}
}
return phl_status;
#else
return RTW_PHL_STATUS_SUCCESS;
#endif
#endif
}
enum rtw_phl_status rtw_test_dbcc_cmd_process(void *priv)
{
struct verify_context *ctx = NULL;
struct rtw_phl_com_t *phl_com = NULL;
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
u8 dbcc_class = DBCC_CLASS_MAX;
FUNCIN();
if (priv == NULL)
return phl_status;
ctx = (struct verify_context *)priv;
phl_com = ctx->phl_com;
if ((ctx->buf_len < VERIFY_CMD_HDR_SIZE)) {
PHL_ERR("%s: Invalid buffer content!\n", __FUNCTION__);
return phl_status;
}
dbcc_class = dbcc_get_class_from_buf(ctx);
switch (dbcc_class) {
case DBCC_CLASS_CONFIG:
PHL_INFO("%s: class = DBCC_CLASS_CONFIG\n", __FUNCTION__);
phl_status = dbcc_config(ctx, (struct dbcc_config_arg *)VERIFY_GET_SUBUF((u8 *)ctx->buf));
break;
case DBCC_CLASS_TX:
PHL_INFO("%s: class = DBCC_CLASS_TX\n", __FUNCTION__);
phl_status = dbcc_tx(ctx, (struct dbcc_tx_arg *)VERIFY_GET_SUBUF((u8 *)ctx->buf));
break;
case DBCC_CLASS_TX_ST:
PHL_INFO("%s: class = DBCC_CLASS_TX_ST\n", __FUNCTION__);
phl_status = dbcc_tx_status(ctx, (struct dbcc_tx_cnt_arg *)VERIFY_GET_SUBUF((u8 *)ctx->buf));
break;
case DBCC_CLASS_RX:
PHL_INFO("%s: class = DBCC_CLASS_RX\n", __FUNCTION__);
//phl_status = dbcc_rx(ctx, (struct dbcc_rx_arg *)VERIFY_GET_SUBUF((u8 *)ctx->buf));
break;
case DBCC_CLASS_RX_ST:
PHL_INFO("%s: class = DBCC_CLASS_RX_ST\n", __FUNCTION__);
//phl_status = dbcc_rx_status(ctx, (struct dbcc_rx_arg *)VERIFY_GET_SUBUF((u8 *)ctx->buf));
break;
default:
PHL_WARN("%s: Unknown DBCC_CLASS! (%d)\n", __FUNCTION__, dbcc_class);
break;
}
FUNCOUT();
return phl_status;
}
#else
enum rtw_phl_status rtw_test_dbcc_cmd_process(void *priv)
{
return RTW_PHL_STATUS_SUCCESS;
}
#endif /* CONFIG_PHL_TEST_VERIFY */
|
2301_81045437/rtl8852be
|
phl/test/verify/dbcc/phl_test_dbcc.c
|
C
|
agpl-3.0
| 6,159
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef _PHL_TEST_DBCC_API_H_
#define _PHL_TEST_DBCC_API_H_
#ifdef CONFIG_PHL_TEST_VERIFY
enum rtw_phl_status rtw_test_dbcc_cmd_process(void *priv);
#endif /* CONFIG_PHL_TEST_VERIFY */
#endif /* _PHL_TEST_DBCC_API_H_ */
|
2301_81045437/rtl8852be
|
phl/test/verify/dbcc/phl_test_dbcc_api.h
|
C
|
agpl-3.0
| 872
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef _PHL_TEST_DBCC_DEF_H_
#define _PHL_TEST_DBCC_DEF_H_
#ifdef CONFIG_PHL_TEST_VERIFY
enum dbcc_cmd_status {
DBCC_STATUS_NOT_INIT = 0,
DBCC_STATUS_INIT = 1,
DBCC_STATUS_WAIT_CMD = 2,
DBCC_STATUS_CMD_EVENT = 3,
DBCC_STATUS_RUN_CMD = 4,
};
/* dbcc command class */
enum dbcc_class {
DBCC_CLASS_CONFIG = 0,
DBCC_CLASS_TX = 1,
DBCC_CLASS_TX_ST,
DBCC_CLASS_RX,
DBCC_CLASS_RX_ST,
DBCC_CLASS_MAX,
};
enum DBCC_tx_method {
DBCC_PKT_TX = 0,
DBCC_PMACT_TX,
DBCC_TMACT_TX,
DBCC_FW_PMAC_TX,
};
enum dbcc_tx_cmd {
DBCC_TX_NONE = 0,
DBCC_TX_PACKETS,
DBCC_TX_CONTINUOUS,
DBCC_TX_CMD_MAX,
};
/* dbcc config command */
enum dbcc_config_cmd {
DBCC_CONFIG_CMD_SET_DBCC = 0,
DBCC_CONFIG_CMD_MAX,
};
/* dbcc rx command */
enum dbcc_rx_cmd {
DBCC_RX_CMD_PHY_CRC_OK = 0,
DBCC_RX_CMD_PHY_CRC_ERR = 1,
DBCC_RX_CMD_MAC_CRC_OK = 2,
DBCC_RX_CMD_MAC_CRC_ERR = 3,
DBCC_RX_CMD_DRV_CRC_OK = 4,
DBCC_RX_CMD_DRV_CRC_ERR = 5,
DBCC_RX_CMD_MAX,
};
/*
* Command structure definition.
* Fixed part would be dbcc_class/cmd/cmd_ok for command and report parsing.
* Data members might have input or output usage.
*/
struct dbcc_cmd_hdr {
u8 arg_class;
u8 cmd;
};
struct dbcc_config_arg {
u8 arg_class;
u8 cmd;
u8 dbcc_en;
u8 action;
u8 macid;
};
struct dbcc_tx_arg {
u8 arg_class;
u8 cmd;
u8 macid;
u8 tx_method;
u16 tx_count;
u16 data_rate;
};
struct dbcc_tx_cnt_arg {
u8 arg_class;
u8 cmd;
u8 band;
u8 params;
};
struct dbcc_rx_arg {
u8 arg_class;
u8 cmd;
u8 cmd_ok;
u8 status;
u32 rx_ok;
u32 rx_err;
u8 rssi;
u8 rx_path;
u8 rx_evm;
u8 user;
u8 strm;
u8 rxevm_table;
};
#endif /* CONFIG_PHL_TEST_VERIFY */
#endif /* _PHL_TEST_DBCC_DEF_H_ */
|
2301_81045437/rtl8852be
|
phl/test/verify/dbcc/phl_test_dbcc_def.h
|
C
|
agpl-3.0
| 2,327
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#define _PHL_TEST_VERIFY_C_
#include "../../phl_headers.h"
#include "phl_test_verify_def.h"
#include "phl_test_verify_api.h"
#include "./dbcc/phl_test_dbcc_api.h"
#ifdef CONFIG_PHL_TEST_VERIFY
static struct s_handler test_handlers[VERIFY_FEATURES_MAX] = {
{ func_null }, /* VERIFY_FEATURES_NULL = 0 */
{ rtw_test_dbcc_cmd_process }, /* VERIFY_FEATURES_DBCC */
};
void verify_cmd_done_notification_complete(void *ctx, struct phl_msg *msg)
{
struct verify_context *ver_ctx = (struct verify_context *)ctx;
if (msg->inbuf) {
PHL_INFO("%s: Free info buf\n", __FUNCTION__);
_os_mem_free(ver_ctx->phl_com->drv_priv, msg->inbuf, msg->inlen);
}
}
void verify_cmd_done_notification(struct verify_context *ver_ctx, u8 feature,
u8 cmd_id)
{
struct phl_msg msg = { 0 };
struct phl_msg_attribute attr = { 0 };
u8 *info = NULL;
info = _os_mem_alloc(ver_ctx->phl_com->drv_priv, 2);
if (info == NULL) {
PHL_ERR("%s: Allocate msg hub buffer fail!\n", __FUNCTION__);
return;
}
info[0] = feature;
info[1] = cmd_id;
SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FUNC_MDL_TEST_MODULE);
SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_MP_CMD_DONE);
attr.completion.completion = verify_cmd_done_notification_complete;
attr.completion.priv = ver_ctx;
msg.inbuf = info;
msg.inlen = 2;
if (phl_msg_hub_send(ver_ctx->phl, &attr, &msg) != RTW_PHL_STATUS_SUCCESS) {
PHL_ERR("%s: send msg_hub failed\n", __func__);
_os_mem_free(ver_ctx->phl_com->drv_priv, info, 2);
}
}
bool verify_get_rpt_check(struct verify_context *ver_ctx, void *rpt_buf)
{
bool ret = true;
struct verify_cmd_hdr *rpt_hdr = (struct verify_cmd_hdr *)ver_ctx->rpt;
struct verify_cmd_hdr *rpt_buf_hdr = (struct verify_cmd_hdr *)rpt_buf;
if ((rpt_hdr->feature != rpt_buf_hdr->feature) ||
(rpt_hdr->cmd != rpt_buf_hdr->cmd)) {
PHL_WARN("%s: Report buffer not match!\n", __FUNCTION__);
rpt_buf_hdr->cmd_ok = true;
rpt_buf_hdr->status = RTW_PHL_STATUS_FAILURE;
ret = false;
}
return ret;
}
u8 verify_get_feature_from_buf(struct verify_context *ver_ctx)
{
u8 *buf_tmp = NULL;
u8 feature = VERIFY_FEATURES_MAX;
if (ver_ctx && ver_ctx->buf) {
buf_tmp = (u8 *)ver_ctx->buf;
feature = buf_tmp[0];
}
return feature;
}
u8 verify_bp_handler(void *ctx, struct test_bp_info *bp_info)
{
struct verify_context *ver_ctx = (struct verify_context *)ctx;
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
PHL_INFO("%s: bp_info->type = %x\n", __FUNCTION__, bp_info->type);
switch (bp_info->type) {
case BP_INFO_TYPE_MP_CMD_EVENT:
if (ver_ctx->status == VERIFY_STATUS_WAIT_CMD) {
ver_ctx->status = VERIFY_STATUS_CMD_EVENT;
_os_sema_up(ver_ctx->phl_com->drv_priv, &(ver_ctx->cmd_sema));
phl_status = RTW_PHL_STATUS_SUCCESS;
}
default:
break;
}
return phl_status;
}
u8 verify_get_fail_rsn(void *ctx, char *rsn, u32 max_len)
{
//struct verify_context *ver_ctx = (struct verify_context *)ctx;
return true;
}
u8 verify_is_test_end(void *ctx)
{
struct verify_context *ver_ctx = (struct verify_context *)ctx;
return ver_ctx->is_test_end;
}
u8 verifyg_is_test_pass(void *ctx)
{
//struct verify_context *ver_ctx = (struct verify_context *)ctx;
return true;
}
u8 verify_start(void *ctx)
{
struct verify_context *ver_ctx = (struct verify_context *)ctx;
struct rtw_phl_com_t *phl_com = ver_ctx->phl_com;
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
u8 feature = VERIFY_FEATURES_MAX;
FUNCIN();
/* drv_mode maybe control by MP */
//phl_com->drv_mode = RTW_DRV_MODE_MP;
while (!verify_is_test_end(ver_ctx)) {
_os_sema_down(phl_com->drv_priv, &(ver_ctx->cmd_sema));
if (ver_ctx->status == VERIFY_STATUS_CMD_EVENT) {
ver_ctx->status = VERIFY_STATUS_RUN_CMD;
feature = verify_get_feature_from_buf(ver_ctx);
/* Clear report buffer before executing next command */
if (ver_ctx->rpt != NULL) {
PHL_INFO("%s: Report not empty, cleanup!\n", __FUNCTION__);
_os_mem_free(phl_com->drv_priv, ver_ctx->rpt, ver_ctx->rpt_len);
ver_ctx->rpt = NULL;
ver_ctx->rpt_len = 0;
}
if (feature < VERIFY_FEATURES_MAX) {
PHL_INFO("%s: feature id = %u\n", __FUNCTION__, feature);
phl_status = ver_ctx->handler[feature].callback(ver_ctx);
} else {
PHL_WARN("%s: Unknown VERIFY_FEATURE! (%d)\n", __FUNCTION__, feature);
}
if (ver_ctx->rpt != NULL) {
struct verify_cmd_hdr *hdr = (struct verify_cmd_hdr *)ver_ctx->rpt;
verify_cmd_done_notification(ver_ctx, hdr->feature, hdr->cmd);
PHL_INFO("%s: Indication class(%d) cmd(%d)\n",
__FUNCTION__, hdr->feature, hdr->cmd);
}
/* Clear command buffer after executing the command */
if (ver_ctx->buf != NULL) {
PHL_INFO("%s: Command buf not empty, cleanup!\n", __FUNCTION__);
_os_mem_free(phl_com->drv_priv, ver_ctx->buf, ver_ctx->buf_len);
ver_ctx->buf = NULL;
ver_ctx->buf_len = 0;
}
ver_ctx->status = VERIFY_STATUS_WAIT_CMD;
}
}
FUNCOUT();
return (u8)phl_status;
}
void verify_change_mode(struct verify_context *ver_ctx, enum rtw_drv_mode driver_mode)
{
struct phl_info_t *phl_info = ver_ctx->phl;
PHL_INFO("%s Change to %x\n", __FUNCTION__, driver_mode);
/* Need PHL stop function later */
phl_info->phl_com->drv_mode = driver_mode;
#ifdef RTW_WKARD_MP_MODE_CHANGE
#else
/* Ouden : does need reset ? it already do in the mp start */
//rtw_phl_reset(phl_info);
#endif
}
enum rtw_phl_status phl_test_verify_alloc(struct phl_info_t *phl_info, void *hal, void **ctx)
{
enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
struct rtw_phl_com_t *phl_com = phl_info->phl_com;
struct verify_context *ver_ctx = NULL;
ver_ctx = _os_mem_alloc(phl_com->drv_priv, sizeof(struct verify_context));
if (ver_ctx == NULL) {
PHL_ERR("alloc verify context failed\n");
phl_status = RTW_PHL_STATUS_RESOURCE;
goto exit;
}
_os_sema_init(phl_com->drv_priv, &(ver_ctx->cmd_sema), 0);
ver_ctx->cur_phy = HW_PHY_0;
ver_ctx->phl = phl_info;
ver_ctx->phl_com = phl_com;
ver_ctx->hal = hal;
ver_ctx->status = VERIFY_STATUS_INIT;
ver_ctx->handler = test_handlers;
*ctx = ver_ctx;
phl_status = RTW_PHL_STATUS_SUCCESS;
exit:
return phl_status;
}
void phl_test_verify_free(void **ctx)
{
struct verify_context *ver_ctx = NULL;
if (*ctx == NULL)
return;
ver_ctx = (struct verify_context *)(*ctx);
_os_sema_free(ver_ctx->phl_com->drv_priv, &(ver_ctx->cmd_sema));
_os_mem_free(ver_ctx->phl_com->drv_priv, ver_ctx, sizeof(struct verify_context));
ver_ctx = NULL;
*ctx = NULL;
}
void phl_test_verify_init(void *ctx)
{
struct verify_context *ver_ctx = NULL;
struct test_obj_ctrl_interface *pCtrl = NULL;
if (ctx == NULL)
return;
ver_ctx = (struct verify_context *)ctx;
pCtrl = &(ver_ctx->test_ctrl);
ver_ctx->status = VERIFY_STATUS_WAIT_CMD;
ver_ctx->is_test_end = false;
pCtrl->bp_handler = verify_bp_handler;
pCtrl->get_fail_rsn = verify_get_fail_rsn;
pCtrl->is_test_end = verify_is_test_end;
pCtrl->is_test_pass = verifyg_is_test_pass;
pCtrl->start_test = verify_start;
rtw_phl_test_add_new_test_obj(ver_ctx->phl_com,
"verify_test",
ver_ctx,
TEST_LVL_LOW,
pCtrl,
-1,
TEST_SUB_MODULE_VERIFY,
INTGR_TEST_MODE);
}
void phl_test_verify_deinit(void *ctx)
{
struct verify_context *ver_ctx = NULL;
if (ctx == NULL)
return;
ver_ctx = (struct verify_context *)ctx;
if (ver_ctx->status < VERIFY_STATUS_WAIT_CMD)
return;
ver_ctx->is_test_end = true;
_os_sema_up(ver_ctx->phl_com->drv_priv, &(ver_ctx->cmd_sema));
ver_ctx->status = VERIFY_STATUS_INIT;
}
void phl_test_verify_start(void *ctx)
{
struct verify_context *ver_ctx = NULL;
if (ctx == NULL)
return;
ver_ctx = (struct verify_context *)ctx;
#if 0 /* verify keep in current mode */
verify_change_mode(ver_ctx, RTW_DRV_MODE_MP);
#endif
}
void phl_test_verify_stop(void *ctx)
{
struct verify_context *ver_ctx = NULL;
if (ctx == NULL)
return;
ver_ctx = (struct verify_context *)ctx;
if (ver_ctx->status < VERIFY_STATUS_WAIT_CMD)
return;
#if 0 /* verify keep in current mode */
verify_change_mode(ver_ctx, RTW_DRV_MODE_NORMAL);
#endif
}
void phl_test_verify_cmd_process(void *ctx, void *buf, u32 buf_len, u8 submdid)
{
struct verify_context *ver_ctx = NULL;
struct rtw_phl_com_t *phl_com = NULL;
struct test_bp_info bp_info;
FUNCIN();
if (ctx == NULL)
return;
ver_ctx = (struct verify_context *)ctx;
phl_com = ver_ctx->phl_com;
if ((buf == NULL) || (buf_len <= 0)) {
PHL_ERR("%s: Invalid buffer content!\n", __func__);
return;
}
if (ver_ctx->status == VERIFY_STATUS_WAIT_CMD) {
ver_ctx->buf_len = buf_len;
ver_ctx->buf = _os_mem_alloc(phl_com->drv_priv, buf_len);
_os_mem_cpy(phl_com->drv_priv, ver_ctx->buf, buf, buf_len);
_os_mem_set(phl_com->drv_priv, &bp_info, 0, sizeof(struct test_bp_info));
bp_info.type = BP_INFO_TYPE_MP_CMD_EVENT;
rtw_phl_test_setup_bp(phl_com, &bp_info, submdid);
} else {
PHL_WARN("%s: Previous command is still running!\n", __FUNCTION__);
}
FUNCOUT();
}
void phl_test_verify_get_rpt(void *ctx, void *buf, u32 buf_len)
{
struct verify_context *ver_ctx = NULL;
FUNCIN();
if (ctx == NULL) {
PHL_WARN("%s: mp is NULL!\n", __FUNCTION__);
goto exit;
}
ver_ctx = (struct verify_context *)ctx;
if (ver_ctx->status != VERIFY_STATUS_WAIT_CMD) {
PHL_WARN("%s: command is running!\n", __FUNCTION__);
goto exit;
}
if (ver_ctx->rpt == NULL) {
PHL_DBG("%s: ver_ctx->rpt is NULL!\n", __FUNCTION__);
goto exit;
}
if (buf_len < ver_ctx->rpt_len) {
PHL_WARN("%s: buffer not enough!\n", __FUNCTION__);
goto exit;
}
if (verify_get_rpt_check(ver_ctx, buf) == true) {
_os_mem_cpy(ver_ctx->phl_com->drv_priv, buf, ver_ctx->rpt, ver_ctx->rpt_len);
_os_mem_free(ver_ctx->phl_com->drv_priv, ver_ctx->rpt, ver_ctx->rpt_len);
ver_ctx->rpt = NULL;
ver_ctx->rpt_len = 0;
}
exit:
FUNCOUT();
}
#endif /* CONFIG_PHL_TEST_MP */
|
2301_81045437/rtl8852be
|
phl/test/verify/phl_test_verify.c
|
C
|
agpl-3.0
| 10,645
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef _PHL_TEST_VERIFY_API_H_
#define _PHL_TEST_VERIFY_API_H_
#ifdef CONFIG_PHL_TEST_VERIFY
/* verify command class */
enum verify_feature {
VERIFY_FEATURES_NULL = 0,
VERIFY_FEATURES_DBCC,
VERIFY_FEATURES_MAX,
};
#define VERIFY_CMD_HDR_SIZE (sizeof(struct verify_cmd_hdr))
#define VERIFY_GET_SUBUF(a) ((u8 *)(a) + VERIFY_CMD_HDR_SIZE)
static inline enum rtw_phl_status func_null(void *priv)
{
return RTW_PHL_STATUS_SUCCESS;
};
#endif /* CONFIG_PHL_TEST_VERIFY */
#endif /* _PHL_TEST_VERIFY_API_H_ */
|
2301_81045437/rtl8852be
|
phl/test/verify/phl_test_verify_api.h
|
C
|
agpl-3.0
| 1,158
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef _PHL_TEST_VERIFY_DEF_H_
#define _PHL_TEST_VERIFY_DEF_H_
#ifdef CONFIG_PHL_TEST_VERIFY
enum verify_cmd_status {
VERIFY_STATUS_NOT_INIT = 0,
VERIFY_STATUS_INIT = 1,
VERIFY_STATUS_WAIT_CMD = 2,
VERIFY_STATUS_CMD_EVENT = 3,
VERIFY_STATUS_RUN_CMD = 4,
};
/*
* Command structure definition.
* Fixed part would be feature/cmd/cmd_ok for command and report parsing.
* Data members might have input or output usage.
*/
struct verify_cmd_hdr {
u8 feature;
u8 cmd;
u8 cmd_ok;
u8 status;
};
struct s_handler {
enum rtw_phl_status(*callback)(void *priv);
};
struct verify_context {
u8 status;
u8 cur_phy; // need ??
_os_sema cmd_sema;
void *buf;
u32 buf_len;
void *rpt;
u32 rpt_len;
struct test_obj_ctrl_interface test_ctrl;
u8 is_test_end;
struct phl_info_t *phl;
struct rtw_phl_com_t *phl_com;
void *hal;
struct s_handler *handler;
};
#endif /* CONFIG_PHL_TEST_VERIFY */
#endif /* _PHL_TEST_VERIFY_DEF_H_ */
|
2301_81045437/rtl8852be
|
phl/test/verify/phl_test_verify_def.h
|
C
|
agpl-3.0
| 1,586
|
ifeq ($(CONFIG_PLATFORM_AML_S905), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_AML_S905
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_RADIO_WORK
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
# CONFIG_RTW_ANDROID - 0: no Android, 4/5/6/7/8/9/10/11 : Android version
CONFIG_RTW_ANDROID = 11
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -gt 0; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_RTW_ANDROID=$(CONFIG_RTW_ANDROID)
endif
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -ge 11; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_IFACE_NUMBER=3
EXTRA_CFLAGS += -DCONFIG_SEL_P2P_IFACE=1
endif
# default setting for Android
# config CONFIG_RTW_ANDROID in main Makefile
ARCH ?= arm64
CROSS_COMPILE ?= /home/sd4ce/sdk/zte_905x4_8852ae/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
ifndef KSRC
KSRC := /home/sd4ce/sdk/zte_905x4_8852ae/kernel_headers
KSRC += O=/home/sd4ce/sdk/zte_905x4_8852ae/KERNEL_OBJ
endif
ifeq ($(CONFIG_PCI_HCI), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
_PLATFORM_FILES := platform/platform_linux_pc_pci.o
OBJS += $(_PLATFORM_FILES)
endif
ifeq ($(CONFIG_PCI_HCI), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
_PLATFORM_FILES := platform/platform_linux_pc_pci.o
OBJS += $(_PLATFORM_FILES)
# Core Config
EXTRA_CFLAGS += -DCONFIG_RXBUF_NUM_1024
EXTRA_CFLAGS += -DCONFIG_TX_SKB_ORPHAN
EXTRA_CFLAGS += -DCONFIG_SWCAP_SYNC_WIN
# PHL Config
#EXTRA_CFLAGS += -DPHL_RX_BATCH_IND
EXTRA_CFLAGS += -DRTW_WKARD_98D_RXTAG
endif
ifeq ($(CONFIG_RTL8852A), y)
ifeq ($(CONFIG_SDIO_HCI), y)
CONFIG_RTL8852AS ?= m
USER_MODULE_NAME := 8852as
endif
ifeq ($(CONFIG_PCI_HCI), y)
CONFIG_RTL8852AE ?= m
USER_MODULE_NAME := 8852ae
endif
endif
endif
|
2301_81045437/rtl8852be
|
platform/aml_s905.mk
|
Makefile
|
agpl-3.0
| 1,720
|
ifeq ($(CONFIG_PLATFORM_ANDROID_INTEL_X86), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_ANDROID_INTEL_X86
EXTRA_CFLAGS += -DCONFIG_PLATFORM_INTEL_BYT
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ANDROID
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_SKIP_SIGNAL_SCALE_MAPPING
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -DCONFIG_RESUME_IN_WORKQUEUE
endif
endif
|
2301_81045437/rtl8852be
|
platform/android_intel_x86.mk
|
Makefile
|
agpl-3.0
| 455
|
ifeq ($(CONFIG_PLATFORM_ANDROID_X86), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
ARCH := $(SUBARCH)
CROSS_COMPILE := /media/DATA-2/android-x86/ics-x86_20120130/prebuilt/linux-x86/toolchain/i686-unknown-linux-gnu-4.2.1/bin/i686-unknown-linux-gnu-
KSRC := /media/DATA-2/android-x86/ics-x86_20120130/out/target/product/generic_x86/obj/kernel
MODULE_NAME :=wlan
endif
|
2301_81045437/rtl8852be
|
platform/android_x86.mk
|
Makefile
|
agpl-3.0
| 414
|
ifeq ($(CONFIG_PLATFORM_RTK1319), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_RADIO_WORK
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DRTK_1319_PLATFORM -DCONFIG_RF4CE_COEXIST
#EXTRA_CFLAGS += -Wno-error=date-time
# CONFIG_RTW_ANDROID - 0: no Android, 4/5/6/7/8/9/10/11 : Android version
CONFIG_RTW_ANDROID = 11
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -gt 0; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_RTW_ANDROID=$(CONFIG_RTW_ANDROID)
endif
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -ge 11; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_IFACE_NUMBER=3
EXTRA_CFLAGS += -DCONFIG_SEL_P2P_IFACE=1
endif
ARCH ?= arm
# For Android 10
#CROSS_COMPILE :=/sweethome/zhenrc/Workshop/1619/atv-9.0/phoenix/toolchain/asdk-6.4.1-a53-EL-4.9-g2.26-a32nut-180831/bin/arm-linux-gnueabi-
#KSRC :=/sweethome/zhenrc/Workshop/1619/atv-9.0/hydra/linux-kernel-1319
# For TV image
#CROSS_COMPILE :=/sweethome/zhenrc/Workshop/1619/atv-9.0/phoenix/toolchain/asdk-6.4.1-a53-EL-4.9-g2.26-a32nut-180831/bin/arm-linux-gnueabi-
#KSRC := /sweethome/zhenrc/Workshop/1319/q_tv_kernel_ax
# For Cert TV image
CROSS_COMPILE :=/sweethome/zhenrc/Workshop/1619/atv-9.0/phoenix/toolchain/asdk-6.4.1-a53-EL-4.9-g2.26-a32nut-180831/bin/arm-linux-gnueabi-
KSRC := /sweethome/zhenrc/Workshop/1319/cert_q_tv_kernel_ax
ifeq ($(CONFIG_PCI_HCI), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
_PLATFORM_FILES := platform/platform_linux_pc_pci.o
OBJS += $(_PLATFORM_FILES)
# Core Config
EXTRA_CFLAGS += -DCONFIG_RXBUF_NUM_1024
EXTRA_CFLAGS += -DCONFIG_TX_SKB_ORPHAN
EXTRA_CFLAGS += -DCONFIG_SWCAP_SYNC_WIN
# PHL Config
#EXTRA_CFLAGS += -DPHL_RX_BATCH_IND
EXTRA_CFLAGS += -DRTW_WKARD_98D_RXTAG
endif
endif
|
2301_81045437/rtl8852be
|
platform/arm_1319.mk
|
Makefile
|
agpl-3.0
| 1,751
|
ifeq ($(CONFIG_PLATFORM_RTK16XXB), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_RADIO_WORK
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DRTK_1619B_PLATFORM
# CONFIG_RTW_ANDROID - 0: no Android, 4/5/6/7/8/9/10/11 : Android version
CONFIG_RTW_ANDROID = $(PLTFM_VER)
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -gt 0; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_RTW_ANDROID=$(CONFIG_RTW_ANDROID)
endif
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -ge 11; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_IFACE_NUMBER=3
EXTRA_CFLAGS += -DCONFIG_SEL_P2P_IFACE=1
endif
ARCH ?= arm
CROSS_COMPILE := $(CROSS)
KSRC := $(LINUX_KERNEL_PATH)
ifeq ($(CONFIG_PCI_HCI), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
_PLATFORM_FILES := platform/platform_linux_pc_pci.o
OBJS += $(_PLATFORM_FILES)
# Core Config
EXTRA_CFLAGS += -DCONFIG_RXBUF_NUM_1024
EXTRA_CFLAGS += -DCONFIG_TX_SKB_ORPHAN
EXTRA_CFLAGS += -DCONFIG_SWCAP_SYNC_WIN
# PHL Config
#EXTRA_CFLAGS += -DPHL_RX_BATCH_IND
EXTRA_CFLAGS += -DRTW_WKARD_98D_RXTAG
endif
endif
|
2301_81045437/rtl8852be
|
platform/arm_1619b.mk
|
Makefile
|
agpl-3.0
| 1,096
|
ifeq ($(CONFIG_PLATFORM_ARM_SUNxI), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_PLATFORM_ARM_SUNxI
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
ifeq ($(CONFIG_USB_HCI), y)
EXTRA_CFLAGS += -DCONFIG_USE_USB_BUFFER_ALLOC_TX
_PLATFORM_FILES += platform/platform_ARM_SUNxI_usb.o
endif
ifeq ($(CONFIG_SDIO_HCI), y)
# default setting for A10-EVB mmc0
#EXTRA_CFLAGS += -DCONFIG_WITS_EVB_V13
_PLATFORM_FILES += platform/platform_ARM_SUNxI_sdio.o
endif
ARCH := arm
#CROSS_COMPILE := arm-none-linux-gnueabi-
CROSS_COMPILE=/home/android_sdk/Allwinner/a10/android-jb42/lichee-jb42/buildroot/output/external-toolchain/bin/arm-none-linux-gnueabi-
KVER := 3.0.8
#KSRC:= ../lichee/linux-3.0/
KSRC=/home/android_sdk/Allwinner/a10/android-jb42/lichee-jb42/linux-3.0
endif
|
2301_81045437/rtl8852be
|
platform/arm_sunxi.mk
|
Makefile
|
agpl-3.0
| 921
|
#ifdef CONFIG_PLATFORM_AML_S905
/* Core Config */
#ifndef CONFIG_PHL_USE_KMEM_ALLOC
#define CONFIG_PHL_USE_KMEM_ALLOC
#endif
#ifdef CONFIG_DYNAMIC_RX_BUF
#undef CONFIG_DYNAMIC_RX_BUF
#endif
#define CONFIG_RXBUF_NUM_1024
#define CONFIG_TX_SKB_ORPHAN
#define CONFIG_SWCAP_SYNC_WIN
/* PHL Config */
#define PHL_RX_BATCH_IND
#define RTW_WKARD_98D_RXTAG
#endif
|
2301_81045437/rtl8852be
|
platform/autoconf_8852ae_aml_s905.h
|
C
|
agpl-3.0
| 361
|
#ifdef RTK_1319_PLATFORM
/* Core Config */
#ifndef CONFIG_PHL_USE_KMEM_ALLOC
#define CONFIG_PHL_USE_KMEM_ALLOC
#endif
#ifdef CONFIG_DYNAMIC_RX_BUF
#undef CONFIG_DYNAMIC_RX_BUF
#endif
#define CONFIG_RXBUF_NUM_1024
#define CONFIG_TX_SKB_ORPHAN
#define CONFIG_SWCAP_SYNC_WIN
/* PHL Config */
#define PHL_RX_BATCH_IND
#define RTW_WKARD_98D_RXTAG
#endif
|
2301_81045437/rtl8852be
|
platform/autoconf_8852ae_arm_1319.h
|
C
|
agpl-3.0
| 354
|
#ifdef RTK_1319_PLATFORM
#undef CONFIG_DYNAMIC_RX_BUF
#endif
#ifdef RTK_1619B_PLATFORM
#undef CONFIG_DYNAMIC_RX_BUF
#endif
#ifdef CONFIG_PLATFORM_AML_S905
#undef CONFIG_DYNAMIC_RX_BUF
#endif
#ifdef CONFIG_PLATFORM_HUANGLONG
#undef CONFIG_DYNAMIC_RX_BUF
#endif
|
2301_81045437/rtl8852be
|
platform/autoconf_8852be_custom.h
|
C
|
agpl-3.0
| 263
|
#ifdef CONFIG_ARCH_CORTINA
#define CONFIG_RTW_HOSTAPD_ACS
#ifdef CONFIG_RTW_HOSTAPD_ACS
#define WKARD_ACS /* for compile happy */
#endif /* CONFIG_RTW_HOSTAPD_ACS */
#endif /* CONFIG_ARCH_CORTINA */
|
2301_81045437/rtl8852be
|
platform/autoconf_arm_9617b.h
|
C
|
agpl-3.0
| 202
|
/* CORE RX path shortcut */
#define CONFIG_RTW_CORE_RXSC
/* CORE TX path shortcut */
#define CONFIG_CORE_TXSC
#ifdef CONFIG_CORE_TXSC
/* TX shorcut amsdu */
#ifdef CONFIG_TX_AMSDU
//#define CONFIG_TXSC_AMSDU
#endif
/* PHL TX path shortcut */
#define CONFIG_PHL_TXSC
#endif/* CONFIG_CORE_TXSC */
/* Separate TX path into different CPUs */
/*#define RTW_TX_CPU_BALANCE*/
#ifdef RTW_TX_CPU_BALANCE
#define CPU_ID_TX_CORE 2
#endif
|
2301_81045437/rtl8852be
|
platform/autoconf_i386_ap_func.h
|
C
|
agpl-3.0
| 431
|
#ifdef CONFIG_PLATFORM_RTL8198D
#define CONFIG_RTW_FC_FASTFWD
#ifndef CONFIG_PHL_USE_KMEM_ALLOC
#define CONFIG_PHL_USE_KMEM_ALLOC
#endif
#ifdef RTW_WKARD_RATE_DRV_CTRL
#undef RTW_WKARD_RATE_DRV_CTRL
#endif
#ifdef RTW_WKARD_RATE_INIT_6M
#undef RTW_WKARD_RATE_INIT_6M
#endif
/* CORE RX path shortcut */
#define CONFIG_RTW_CORE_RXSC
/* CORE TX path shortcut */
#define CONFIG_CORE_TXSC
#ifdef CONFIG_CORE_TXSC
/* TX shorcut amsdu */
#ifdef CONFIG_TX_AMSDU
//#define CONFIG_TXSC_AMSDU
#endif
/* PHL TX path shortcut */
#define CONFIG_PHL_TXSC
#endif/* CONFIG_CORE_TXSC */
/* Separate TX path into different CPUs */
//#define RTW_TX_CPU_BALANCE
#ifdef RTW_TX_CPU_BALANCE
#define CPU_ID_TX_CORE 2
#endif
#endif
|
2301_81045437/rtl8852be
|
platform/autoconf_mips_98d.h
|
C
|
agpl-3.0
| 713
|
/******************************************************************************
*
* Copyright(c) 2013 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#error "You have defined CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP to use a customized map of your own instead of the default one"
#error "Before removing these error notifications, please make sure regulatory certification requirements of your target markets"
static const struct country_chplan CUSTOMIZED_country_chplan_map[] = {
COUNTRY_CHPLAN_ENT("TW", 0x76, 0x00, DEF , 1, 1), /* Taiwan */
};
|
2301_81045437/rtl8852be
|
platform/custom_country_chplan.h
|
C
|
agpl-3.0
| 1,056
|
ifeq ($(CONFIG_PLATFORM_I386_PC), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT \
-DRTW_USE_CFG80211_REPORT_PROBE_REQ
EXTRA_CFLAGS += -DCONFIG_RADIO_WORK
#EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
KVER := $(shell uname -r)
KSRC := /lib/modules/$(KVER)/build
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/
INSTALL_PREFIX :=
STAGINGMODDIR := /lib/modules/$(KVER)/kernel/drivers/staging
ifeq ($(CONFIG_PCI_HCI), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
_PLATFORM_FILES := platform/platform_linux_pc_pci.o
OBJS += $(_PLATFORM_FILES)
endif
endif
|
2301_81045437/rtl8852be
|
platform/i386_pc.mk
|
Makefile
|
agpl-3.0
| 713
|
ifeq ($(CONFIG_PLATFORM_RTL8198D), y)
EXTRA_CFLAGS += -DCONFIG_BIG_ENDIAN -DCONFIG_PLATFORM_RTL8198D
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
export DIR_LINUX=$(shell pwd)/../../../../../../linux-4.4.x
ARCH ?= mips
CROSS_COMPILE := /toolchain/msdk-4.8.5-mips-EB-4.4-u0.9.33-m32ut-180206/bin/msdk-linux-
KSRC := $(DIR_LINUX)
MODULE_NAME := $(MODULE_NAME)_98d
ifeq ($(CONFIG_PCI_HCI), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
_PLATFORM_FILES := platform/platform_mips_98d_pci.o
OBJS += $(_PLATFORM_FILES)
endif
endif
|
2301_81045437/rtl8852be
|
platform/mips_98d.mk
|
Makefile
|
agpl-3.0
| 543
|
ifeq ($(CONFIG_PLATFORM_NV_TK1), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_NV_TK1
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DCONFIG_P2P_IPS -DCONFIG_PLATFORM_ANDROID
# Enable this for Android 5.0
EXTRA_CFLAGS += -DCONFIG_RADIO_WORK
EXTRA_CFLAGS += -DRTW_VENDOR_EXT_SUPPORT
EXTRA_CFLAGS += -DRTW_ENABLE_WIFI_CONTROL_FUNC
ARCH ?= arm
CROSS_COMPILE := /mnt/newdisk/android_sdk/nvidia_tk1/android_L/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi-
KSRC :=/mnt/newdisk/android_sdk/nvidia_tk1/android_L/out/target/product/shieldtablet/obj/KERNEL/
MODULE_NAME = wlan
endif
|
2301_81045437/rtl8852be
|
platform/nv_tk1.mk
|
Makefile
|
agpl-3.0
| 731
|
ifeq ($(CONFIG_PLATFORM_NV_TK1_UBUNTU), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_NV_TK1
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
ARCH ?= arm
CROSS_COMPILE ?=
KVER := $(shell uname -r)
KSRC := /lib/modules/$(KVER)/build
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/
INSTALL_PREFIX :=
endif
|
2301_81045437/rtl8852be
|
platform/nv_tk1_ubuntu.mk
|
Makefile
|
agpl-3.0
| 373
|
ifeq ($(CONFIG_PLATFORM_HUANGLONG), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -fno-pic
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_RADIO_WORK
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DCONFIG_PLATFORM_HUANGLONG
#EXTRA_CFLAGS += -Wno-error=date-time
# CONFIG_RTW_ANDROID - 0: no Android, 4/5/6/7/8/9/10/11 : Android version
CONFIG_RTW_ANDROID = 11
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -gt 0; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_RTW_ANDROID=$(CONFIG_RTW_ANDROID)
endif
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -ge 11; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_IFACE_NUMBER=3
EXTRA_CFLAGS += -DCONFIG_SEL_P2P_IFACE=1
endif
KSRC := $(LINUX_DIR)
ARCH := $(CFG_SOCT_CPU_ARCH)
CROSS_CONPILE := $(SOCT_KERNEL_TOOLCHAINS_MAME)-
ifeq ($(CONFIG_PCI_HCI), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
_PLATFORM_FILES := platform/platform_linux_pc_pci.o
OBJS += $(_PLATFORM_FILES)
# Core Config
EXTRA_CFLAGS += -DCONFIG_RXBUF_NUM_1024
EXTRA_CFLAGS += -DCONFIG_TX_SKB_ORPHAN
EXTRA_CFLAGS += -DCONFIG_SWCAP_SYNC_WIN
# PHL Config
#EXTRA_CFLAGS += -DPHL_RX_BATCH_IND
EXTRA_CFLAGS += -DRTW_WKARD_98D_RXTAG
endif
endif
|
2301_81045437/rtl8852be
|
platform/plat_huanglong.mk
|
Makefile
|
agpl-3.0
| 1,174
|
/******************************************************************************
*
* Copyright(c) 2013 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
/*
* Description:
* This file can be applied to following platforms:
* CONFIG_PLATFORM_ARM_SUN6I
* CONFIG_PLATFORM_ARM_SUN7I
* CONFIG_PLATFORM_ARM_SUN8I
*/
#include <drv_types.h>
#include <mach/sys_config.h>
#ifdef CONFIG_GPIO_WAKEUP
#include <linux/gpio.h>
#endif
#ifdef CONFIG_MMC
static int sdc_id = -1;
static signed int gpio_eint_wlan = -1;
static u32 eint_wlan_handle = 0;
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
extern void sw_mci_rescan_card(unsigned id, unsigned insert);
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
extern void sunxi_mci_rescan_card(unsigned id, unsigned insert);
#endif
#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
extern int get_rf_mod_type(void);
#else
extern int wifi_pm_get_mod_type(void);
#endif
extern void wifi_pm_power(int on);
#ifdef CONFIG_GPIO_WAKEUP
extern unsigned int oob_irq;
#endif
#endif /* CONFIG_MMC */
/*
* Return:
* 0: power on successfully
* others: power on failed
*/
int platform_wifi_power_on(void)
{
int ret = 0;
#ifdef CONFIG_MMC
{
script_item_u val;
script_item_value_type_e type;
#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
unsigned int mod_sel = get_rf_mod_type();
#else
unsigned int mod_sel = wifi_pm_get_mod_type();
#endif
type = script_get_item("wifi_para", "wifi_sdc_id", &val);
if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
RTW_INFO("get wifi_sdc_id failed\n");
ret = -1;
} else {
sdc_id = val.val;
RTW_INFO("----- %s sdc_id: %d, mod_sel: %d\n", __FUNCTION__, sdc_id, mod_sel);
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
sw_mci_rescan_card(sdc_id, 1);
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
sunxi_mci_rescan_card(sdc_id, 1);
#endif
mdelay(100);
wifi_pm_power(1);
RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);
}
#ifdef CONFIG_GPIO_WAKEUP
#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
type = script_get_item("wifi_para", "wl_host_wake", &val);
#else
#ifdef CONFIG_RTL8723B
type = script_get_item("wifi_para", "rtl8723bs_wl_host_wake", &val);
#endif
#ifdef CONFIG_RTL8188E
type = script_get_item("wifi_para", "rtl8189es_host_wake", &val);
#endif
#endif /* CONFIG_PLATFORM_ARM_SUN8I_W5P1 */
if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
RTW_INFO("No definition of wake up host PIN\n");
ret = -1;
} else {
gpio_eint_wlan = val.gpio.gpio;
#ifdef CONFIG_PLATFORM_ARM_SUN8I
oob_irq = gpio_to_irq(gpio_eint_wlan);
#endif
}
#endif /* CONFIG_GPIO_WAKEUP */
}
#endif /* CONFIG_MMC */
return ret;
}
void platform_wifi_power_off(void)
{
#ifdef CONFIG_MMC
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
sw_mci_rescan_card(sdc_id, 0);
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
sunxi_mci_rescan_card(sdc_id, 0);
#endif
mdelay(100);
wifi_pm_power(0);
RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);
#endif /* CONFIG_MMC */
}
|
2301_81045437/rtl8852be
|
platform/platform_ARM_SUNnI_sdio.c
|
C
|
agpl-3.0
| 3,514
|
/******************************************************************************
*
* Copyright(c) 2013 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#include <drv_types.h>
#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
#ifdef CONFIG_WITS_EVB_V13
#define SDIOID 0
#else /* !CONFIG_WITS_EVB_V13 */
#define SDIOID (CONFIG_CHIP_ID == 1123 ? 3 : 1)
#endif /* !CONFIG_WITS_EVB_V13 */
#define SUNXI_SDIO_WIFI_NUM_RTL8189ES 10
extern void sunximmc_rescan_card(unsigned id, unsigned insert);
extern int mmc_pm_get_mod_type(void);
extern int mmc_pm_gpio_ctrl(char *name, int level);
/*
* rtl8189es_shdn = port:PH09<1><default><default><0>
* rtl8189es_wakeup = port:PH10<1><default><default><1>
* rtl8189es_vdd_en = port:PH11<1><default><default><0>
* rtl8189es_vcc_en = port:PH12<1><default><default><0>
*/
int rtl8189es_sdio_powerup(void)
{
mmc_pm_gpio_ctrl("rtl8189es_vdd_en", 1);
udelay(100);
mmc_pm_gpio_ctrl("rtl8189es_vcc_en", 1);
udelay(50);
mmc_pm_gpio_ctrl("rtl8189es_shdn", 1);
return 0;
}
int rtl8189es_sdio_poweroff(void)
{
mmc_pm_gpio_ctrl("rtl8189es_shdn", 0);
mmc_pm_gpio_ctrl("rtl8189es_vcc_en", 0);
mmc_pm_gpio_ctrl("rtl8189es_vdd_en", 0);
return 0;
}
#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
/*
* Return:
* 0: power on successfully
* others: power on failed
*/
int platform_wifi_power_on(void)
{
int ret = 0;
#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
unsigned int mod_sel = mmc_pm_get_mod_type();
#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
if (mod_sel == SUNXI_SDIO_WIFI_NUM_RTL8189ES) {
rtl8189es_sdio_powerup();
sunximmc_rescan_card(SDIOID, 1);
printk("[rtl8189es] %s: power up, rescan card.\n", __FUNCTION__);
} else {
ret = -1;
printk("[rtl8189es] %s: mod_sel = %d is incorrect.\n", __FUNCTION__, mod_sel);
}
#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
return ret;
}
void platform_wifi_power_off(void)
{
#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
sunximmc_rescan_card(SDIOID, 0);
#ifdef CONFIG_RTL8188E
rtl8189es_sdio_poweroff();
printk("[rtl8189es] %s: remove card, power off.\n", __FUNCTION__);
#endif /* CONFIG_RTL8188E */
#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
}
|
2301_81045437/rtl8852be
|
platform/platform_ARM_SUNxI_sdio.c
|
C
|
agpl-3.0
| 2,667
|
/******************************************************************************
*
* Copyright(c) 2013 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
/*
* Description:
* This file can be applied to following platforms:
* CONFIG_PLATFORM_ARM_SUNXI Series platform
*
*/
#include <drv_types.h>
#include <mach/sys_config.h>
#ifdef CONFIG_PLATFORM_ARM_SUNxI
extern int sw_usb_disable_hcd(__u32 usbc_no);
extern int sw_usb_enable_hcd(__u32 usbc_no);
static int usb_wifi_host = 2;
#endif
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
extern int sw_usb_disable_hcd(__u32 usbc_no);
extern int sw_usb_enable_hcd(__u32 usbc_no);
extern void wifi_pm_power(int on);
static script_item_u item;
#endif
#ifdef CONFIG_PLATFORM_ARM_SUN8I
extern int sunxi_usb_disable_hcd(__u32 usbc_no);
extern int sunxi_usb_enable_hcd(__u32 usbc_no);
extern void wifi_pm_power(int on);
static script_item_u item;
#endif
int platform_wifi_power_on(void)
{
int ret = 0;
#ifdef CONFIG_PLATFORM_ARM_SUNxI
#ifndef CONFIG_RTL8723A
{
/* ----------get usb_wifi_usbc_num------------- */
ret = script_parser_fetch("usb_wifi_para", "usb_wifi_usbc_num", (int *)&usb_wifi_host, 64);
if (ret != 0) {
RTW_INFO("ERR: script_parser_fetch usb_wifi_usbc_num failed\n");
ret = -ENOMEM;
goto exit;
}
RTW_INFO("sw_usb_enable_hcd: usbc_num = %d\n", usb_wifi_host);
sw_usb_enable_hcd(usb_wifi_host);
}
#endif /* CONFIG_RTL8723A */
#endif /* CONFIG_PLATFORM_ARM_SUNxI */
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
{
script_item_value_type_e type;
type = script_get_item("wifi_para", "wifi_usbc_id", &item);
if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
printk("ERR: script_get_item wifi_usbc_id failed\n");
ret = -ENOMEM;
goto exit;
}
printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
wifi_pm_power(1);
mdelay(10);
#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
sw_usb_enable_hcd(item.val);
#endif
}
#endif /* defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) */
#if defined(CONFIG_PLATFORM_ARM_SUN8I)
{
script_item_value_type_e type;
type = script_get_item("wifi_para", "wifi_usbc_id", &item);
if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
printk("ERR: script_get_item wifi_usbc_id failed\n");
ret = -ENOMEM;
goto exit;
}
printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
wifi_pm_power(1);
mdelay(10);
#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
sunxi_usb_enable_hcd(item.val);
#endif
}
#endif /* CONFIG_PLATFORM_ARM_SUN8I */
exit:
return ret;
}
void platform_wifi_power_off(void)
{
#ifdef CONFIG_PLATFORM_ARM_SUNxI
#ifndef CONFIG_RTL8723A
RTW_INFO("sw_usb_disable_hcd: usbc_num = %d\n", usb_wifi_host);
sw_usb_disable_hcd(usb_wifi_host);
#endif /* ifndef CONFIG_RTL8723A */
#endif /* CONFIG_PLATFORM_ARM_SUNxI */
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
sw_usb_disable_hcd(item.val);
#endif
wifi_pm_power(0);
#endif /* defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) */
#if defined(CONFIG_PLATFORM_ARM_SUN8I)
#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
sunxi_usb_disable_hcd(item.val);
#endif
wifi_pm_power(0);
#endif /* defined(CONFIG_PLATFORM_ARM_SUN8I) */
}
|
2301_81045437/rtl8852be
|
platform/platform_ARM_SUNxI_usb.c
|
C
|
agpl-3.0
| 3,895
|
/******************************************************************************
*
* Copyright(c) 2013 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#include <drv_types.h>
int platform_wifi_power_on(void)
{
int ret = 0;
u32 tmp;
tmp = readl((volatile unsigned int *)0xb801a608);
tmp &= 0xffffff00;
tmp |= 0x55;
writel(tmp, (volatile unsigned int *)0xb801a608); /* write dummy register for 1055 */
return ret;
}
void platform_wifi_power_off(void)
{
}
|
2301_81045437/rtl8852be
|
platform/platform_RTK_DMP_usb.c
|
C
|
agpl-3.0
| 966
|
/******************************************************************************
*
* Copyright(c) 2019 - Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#include "drv_types.h"
void pci_cache_wback(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
if (NULL != hwdev && NULL != bus_addr)
pci_dma_sync_single_for_device(hwdev, *bus_addr, size,
direction);
else
RTW_ERR("pcie hwdev handle or bus addr is NULL!\n");
}
void pci_cache_inv(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
if (NULL != hwdev && NULL != bus_addr)
pci_dma_sync_single_for_cpu(hwdev, *bus_addr, size, direction);
else
RTW_ERR("pcie hwdev handle or bus addr is NULL!\n");
}
void pci_get_bus_addr(struct pci_dev *hwdev,
void *vir_addr, dma_addr_t *bus_addr,
size_t size, int direction)
{
if (NULL != hwdev) {
*bus_addr = pci_map_single(hwdev, vir_addr, size, direction);
} else {
RTW_ERR("pcie hwdev handle is NULL!\n");
*bus_addr = (dma_addr_t)virt_to_phys(vir_addr);
/*RTW_ERR("Get bus_addr: %x by virt_to_phys()\n", bus_addr);*/
}
}
void pci_unmap_bus_addr(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
if (NULL != hwdev && NULL != bus_addr)
pci_unmap_single(hwdev, *bus_addr, size, direction);
else
RTW_ERR("pcie hwdev handle or bus addr is NULL!\n");
}
void *pci_alloc_cache_mem(struct pci_dev *pdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
void *vir_addr = NULL;
vir_addr = rtw_zmalloc(size);
if (!vir_addr)
bus_addr = NULL;
else
pci_get_bus_addr(pdev, vir_addr, bus_addr, size, direction);
return vir_addr;
}
void *pci_alloc_noncache_mem(struct pci_dev *pdev,
dma_addr_t *bus_addr, size_t size)
{
void *vir_addr = NULL;
if (NULL != pdev)
vir_addr = dma_alloc_coherent(&pdev->dev,
size, bus_addr,
(in_atomic() ? GFP_ATOMIC : GFP_KERNEL));
if (!vir_addr)
bus_addr = NULL;
else
bus_addr = (dma_addr_t *)((((SIZE_PTR)bus_addr + 3) / 4) * 4);
return vir_addr;
}
void pci_free_cache_mem(struct pci_dev *pdev,
void *vir_addr, dma_addr_t *bus_addr,
size_t size, int direction)
{
pci_unmap_bus_addr(pdev, bus_addr, size, direction);
rtw_mfree(vir_addr, size);
vir_addr = NULL;
}
void pci_free_noncache_mem(struct pci_dev *pdev,
void *vir_addr, dma_addr_t *bus_addr, size_t size)
{
if (NULL != pdev)
pci_free_consistent(pdev, size, vir_addr, *bus_addr);
vir_addr = NULL;
}
|
2301_81045437/rtl8852be
|
platform/platform_linux_pc_pci.c
|
C
|
agpl-3.0
| 2,935
|
/******************************************************************************
*
* Copyright(c) 2019 - Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#include "drv_types.h"
#if 1
void pci_cache_wback(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
if (NULL != hwdev && NULL != bus_addr)
pci_dma_sync_single_for_device(hwdev, *bus_addr, size,
direction);
else
RTW_ERR("pcie hwdev handle or bus addr is NULL!\n");
}
void pci_cache_inv(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
if (NULL != hwdev && NULL != bus_addr)
pci_dma_sync_single_for_cpu(hwdev, *bus_addr, size, direction);
else
RTW_ERR("pcie hwdev handle or bus addr is NULL!\n");
}
void pci_get_bus_addr(struct pci_dev *hwdev,
void *vir_addr, dma_addr_t *bus_addr,
size_t size, int direction)
{
if (NULL != hwdev) {
*bus_addr = pci_map_single(hwdev, vir_addr, size, direction);
} else {
RTW_ERR("pcie hwdev handle is NULL!\n");
*bus_addr = (dma_addr_t)virt_to_phys(vir_addr);
/*RTW_ERR("Get bus_addr: %x by virt_to_phys()\n", bus_addr);*/
}
}
void pci_unmap_bus_addr(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
if (NULL != hwdev && NULL != bus_addr)
pci_unmap_single(hwdev, *bus_addr, size, direction);
else
RTW_ERR("pcie hwdev handle or bus addr is NULL!\n");
}
void *pci_alloc_cache_mem(struct pci_dev *pdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
void *vir_addr = NULL;
vir_addr = rtw_zmalloc(size);
if (!vir_addr)
bus_addr = NULL;
else
pci_get_bus_addr(pdev, vir_addr, bus_addr, size, direction);
return vir_addr;
}
void *pci_alloc_noncache_mem(struct pci_dev *pdev,
dma_addr_t *bus_addr, size_t size)
{
void *vir_addr = NULL;
if (NULL != pdev)
vir_addr = pci_alloc_consistent(pdev, size, bus_addr);
if (!vir_addr)
bus_addr = NULL;
else
bus_addr = (dma_addr_t *)((((SIZE_PTR)bus_addr + 3) / 4) * 4);
return vir_addr;
}
void pci_free_cache_mem(struct pci_dev *pdev,
void *vir_addr, dma_addr_t *bus_addr,
size_t size, int direction)
{
pci_unmap_bus_addr(pdev, bus_addr, size, direction);
rtw_mfree(vir_addr, size);
vir_addr = NULL;
}
void pci_free_noncache_mem(struct pci_dev *pdev,
void *vir_addr, dma_addr_t *bus_addr, size_t size)
{
if (NULL != pdev)
pci_free_consistent(pdev, size, vir_addr, *bus_addr);
vir_addr = NULL;
}
#endif
#if 0
void pci_cache_wback(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
pci_dma_sync_single_for_device(hwdev, *bus_addr, size, direction);
}
void pci_cache_inv(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
pci_dma_sync_single_for_cpu(hwdev, *bus_addr, size, direction);
}
void pci_get_bus_addr(struct pci_dev *hwdev,
void *vir_addr, dma_addr_t *bus_addr,
size_t size, int direction)
{
*bus_addr = (dma_addr_t)virt_to_phys(vir_addr);
return bus_addr;
}
void pci_unmap_bus_addr(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
/* pci_unmap_single(hwdev, *bus_addr, size, direction); */
}
void *pci_alloc_cache_mem(struct pci_dev *pdev,
dma_addr_t *bus_addr, size_t size, int direction)
{
void *vir_addr = NULL;
vir_addr = rtw_zmalloc(size);
if (!vir_addr) {
bus_addr = NULL;
}
else {
pci_get_bus_addr(pdev, vir_addr, bus_addr, size,
direction);
}
return vir_addr;
}
void *pci_alloc_noncache_mem(struct pci_dev *pdev,
dma_addr_t *bus_addr, size_t size)
{
void *vir_addr = NULL;
vir_addr = pci_alloc_consistent(pdev, size, bus_addr);
if (!vir_addr)
bus_addr = NULL;
else
bus_addr = (dma_addr_t *)((((SIZE_PTR)bus_addr + 3) / 4) * 4);
return vir_addr;
}
void pci_free_cache_mem(struct pci_dev *pdev, void *vir_addr,
dma_addr_t *bus_addr, size_t size, int direction)
{
platform_mips_98d_unmap_bus_addr(pdev, bus_addr, size, direction);
rtw_mfree(vir_addr, size);
vir_addr = NULL;
}
void pci_free_noncache_mem(struct pci_dev *pdev, void *vir_addr,
dma_addr_t *bus_addr, size_t size)
{
pci_free_consistent(pdev, size, vir_addr, *bus_addr);
vir_addr = NULL;
}
#endif
|
2301_81045437/rtl8852be
|
platform/platform_mips_98d_pci.c
|
C
|
agpl-3.0
| 4,607
|
/******************************************************************************
*
* Copyright(c) 2013 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
|
2301_81045437/rtl8852be
|
platform/platform_ops.c
|
C
|
agpl-3.0
| 656
|
/******************************************************************************
*
* Copyright(c) 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#ifndef __PLATFORM_OPS_H__
#define __PLATFORM_OPS_H__
/*
* Return:
*0: power on successfully
*others: power on failed
*/
#ifdef CONFIG_PLATFORM_OPS
int platform_wifi_power_on(void);
void platform_wifi_power_off(void);
void pci_cache_wback(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction);
void pci_cache_inv(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction);
void pci_get_bus_addr(struct pci_dev *hwdev,
void *vir_addr, dma_addr_t *bus_addr, size_t size, int direction);
void pci_unmap_bus_addr(struct pci_dev *hwdev,
dma_addr_t *bus_addr, size_t size, int direction);
void *pci_alloc_cache_mem(struct pci_dev *pdev,
dma_addr_t *bus_addr, size_t size, int direction);
void *pci_alloc_noncache_mem(struct pci_dev *pdev,
dma_addr_t *bus_addr, size_t size);
void pci_free_cache_mem(struct pci_dev *pdev, void *vir_addr,
dma_addr_t *bus_addr, size_t size, int direction);
void pci_free_noncache_mem(struct pci_dev *pdev, void *vir_addr,
dma_addr_t *bus_addr, size_t size);
#else
#define platform_wifi_power_on(void) 0
#define platform_wifi_power_off(void)
#endif
#endif /* __PLATFORM_OPS_H__ */
|
2301_81045437/rtl8852be
|
platform/platform_ops.h
|
C
|
agpl-3.0
| 1,802
|
/******************************************************************************
*
* Copyright(c) 2013 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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.
*
*****************************************************************************/
#include <drv_types.h>
extern void sdhci_bus_scan(void);
#ifndef ANDROID_2X
extern int sdhci_device_attached(void);
#endif
/*
* Return:
* 0: power on successfully
* others: power on failed
*/
int platform_wifi_power_on(void)
{
int ret = 0;
#ifdef CONFIG_RTL8188E
rtw_wifi_gpio_wlan_ctrl(WLAN_POWER_ON);
#endif /* CONFIG_RTL8188E */
/* Pull up pwd pin, make wifi leave power down mode. */
rtw_wifi_gpio_init();
rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_ON);
#if (MP_DRIVER == 1) && (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
/* Pull up BT reset pin. */
rtw_wifi_gpio_wlan_ctrl(WLAN_BT_PWDN_ON);
#endif
rtw_mdelay_os(5);
sdhci_bus_scan();
#ifdef CONFIG_RTL8723B
/* YJ,test,130305 */
rtw_mdelay_os(1000);
#endif
#ifdef ANDROID_2X
rtw_mdelay_os(200);
#else /* !ANDROID_2X */
if (1) {
int i = 0;
for (i = 0; i <= 50; i++) {
msleep(10);
if (sdhci_device_attached())
break;
printk("%s delay times:%d\n", __func__, i);
}
}
#endif /* !ANDROID_2X */
return ret;
}
void platform_wifi_power_off(void)
{
/* Pull down pwd pin, make wifi enter power down mode. */
rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_OFF);
rtw_mdelay_os(5);
rtw_wifi_gpio_deinit();
#ifdef CONFIG_RTL8188E
rtw_wifi_gpio_wlan_ctrl(WLAN_POWER_OFF);
#endif /* CONFIG_RTL8188E */
#ifdef CONFIG_WOWLAN
if (mmc_host)
mmc_host->pm_flags &= ~MMC_PM_KEEP_POWER;
#endif /* CONFIG_WOWLAN */
}
|
2301_81045437/rtl8852be
|
platform/platform_sprd_sdio.c
|
C
|
agpl-3.0
| 2,048
|
ifeq ($(CONFIG_PLATFORM_ARM_RK3399), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ANDROID -DCONFIG_PLATFORM_ROCKCHIPS
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_RADIO_WORK
# CONFIG_RTW_ANDROID - 0: no Android, 4/5/6/7/8/9/10/11 : Android version
CONFIG_RTW_ANDROID = 0
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -gt 0; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_RTW_ANDROID=$(CONFIG_RTW_ANDROID)
endif
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -ge 11; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_IFACE_NUMBER=3
EXTRA_CFLAGS += -DCONFIG_SEL_P2P_IFACE=1
endif
# default setting for Android
# config CONFIG_RTW_ANDROID in main Makefile
ifeq ($(CONFIG_PCI_HCI), y)
EXTRA_CFLAGS += -DCONFIG_PLATFORM_OPS
_PLATFORM_FILES := platform/platform_linux_pc_pci.o
OBJS += $(_PLATFORM_FILES)
# Core Config
EXTRA_CFLAGS += -DCONFIG_RXBUF_NUM_1024
EXTRA_CFLAGS += -DCONFIG_TX_SKB_ORPHAN
EXTRA_CFLAGS += -DCONFIG_SWCAP_SYNC_WIN
# PHL Config
#EXTRA_CFLAGS += -DPHL_RX_BATCH_IND
EXTRA_CFLAGS += -DRTW_WKARD_98D_RXTAG
endif
endif
|
2301_81045437/rtl8852be
|
platform/rk_rk3399.mk
|
Makefile
|
agpl-3.0
| 1,070
|
#!/bin/bash
if [ "`which iwconfig`" = "" ] ; then
echo "WARNING:Wireless tool not exist!"
echo " Please install it!"
exit
else
if [ `uname -r | cut -d. -f2` -eq 4 ]; then
wpa_supplicant -D ipw -c wpa1.conf -i wlan0
else
if [ `iwconfig -v |awk '{print $4}' | head -n 1` -lt 18 ] ; then
wpa_supplicant -D ipw -c wpa1.conf -i wlan0
else
wpa_supplicant -D wext -c wpa1.conf -i wlan0
fi
fi
fi
|
2301_81045437/rtl8852be
|
runwpa
|
Shell
|
agpl-3.0
| 423
|
#!/bin/bash
var0=`ps aux|awk '/dhclient wlan0/'|awk '$11!="awk"{print $2}'`
kill $var0
cp ifcfg-wlan0 /etc/sysconfig/network-scripts/
dhclient wlan0
var1=`ifconfig wlan0 |awk '/inet/{print $2}'|awk -F: '{print $2}'`
rm -f /etc/sysconfig/network-scripts/ifcfg-wlan0
echo "get ip: $var1"
|
2301_81045437/rtl8852be
|
wlan0dhcp
|
Shell
|
agpl-3.0
| 294
|
# Copyright (C) 2011 The Libphonenumber Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Author: Philippe Liard
cmake_minimum_required (VERSION 2.8.5)
project (libphonenumber)
set (libphonenumber_VERSION_MAJOR 8)
set (libphonenumber_VERSION_MINOR 12)
set (libphonenumber_VERSION_PATCH 0)
if (32BIT)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
endif ()
# Helper functions dealing with finding libraries and programs this library
# depends on.
include (GNUInstallDirs)
include (../tools/cpp/gtest.cmake)
function (print_error DESCRIPTION FILE)
message (FATAL_ERROR
"Can't find ${DESCRIPTION}: can't locate ${FILE}. Please read the README.")
endfunction ()
# Find a library. If it has not been found, stop CMake with a fatal error
# message.
function (find_required_library NAME HEADER LIBRARY DESCRIPTION)
# Check the header.
find_path (${NAME}_INCLUDE_DIR ${HEADER})
set (INCLUDE_DIR ${${NAME}_INCLUDE_DIR})
if (${INCLUDE_DIR} STREQUAL "${INCLUDE_DIR}-NOTFOUND")
print_error (${DESCRIPTION} ${HEADER})
endif ()
include_directories (${INCLUDE_DIR})
# Check the binary.
find_library (${NAME}_LIB ${LIBRARY})
set (LIB ${NAME}_LIB)
if (${LIB} STREQUAL "${LIB}-NOTFOUND")
print_error (${DESCRIPTION} ${LIBRARY})
endif ()
endfunction (find_required_library)
# Check the library version (if pkg-config available).
find_package (PkgConfig)
function (check_library_version VARNAME LIBRARY_WITH_VERSION)
if (PKG_CONFIG_FOUND)
pkg_check_modules (${VARNAME} ${LIBRARY_WITH_VERSION})
endif ()
endfunction ()
# Find a program. If it has not been found, stop CMake with a fatal error
# message.
function (find_required_program NAME FILENAME DESCRIPTION)
find_program (${NAME}_BIN NAMES ${FILENAME})
if (${NAME}_BIN STREQUAL "${${NAME}_BIN}-NOTFOUND")
print_error (${DESCRIPTION} ${FILENAME})
endif ()
endfunction (find_required_program)
# Options that can be passed to CMake using 'cmake -DKEY=VALUE'.
option ("BUILD_GEOCODER" "Build the offline phone number geocoder" "ON")
option ("USE_ALTERNATE_FORMATS" "Use alternate formats" "ON")
option ("USE_BOOST" "Use Boost" "ON")
option ("USE_ICU_REGEXP" "Use ICU regexp engine" "ON")
option ("USE_LITE_METADATA" "Use lite metadata" "OFF")
option ("USE_RE2" "Use RE2" "OFF")
option ("USE_STD_MAP" "Force the use of std::map" "OFF")
option ("BUILD_STATIC_LIB" "Build static libraries" "ON")
if (${USE_ALTERNATE_FORMATS} STREQUAL "ON")
add_definitions ("-DI18N_PHONENUMBERS_USE_ALTERNATE_FORMATS")
endif ()
# Find all the required libraries and programs.
if (${USE_BOOST} STREQUAL "ON")
add_definitions ("-DI18N_PHONENUMBERS_USE_BOOST")
if (WIN32)
set (Boost_USE_STATIC_LIBS ON)
endif ()
find_package (Boost 1.40.0 COMPONENTS date_time system thread)
if (NOT Boost_FOUND)
print_error ("Boost Date_Time/System/Thread" "Boost")
endif ()
include_directories (${Boost_INCLUDE_DIRS})
endif ()
find_or_build_gtest ()
if (${USE_RE2} STREQUAL "ON")
find_required_library (RE2 re2/re2.h re2 "Google RE2")
endif ()
find_required_library (PROTOBUF google/protobuf/message_lite.h protobuf
"Google Protocol Buffers")
check_library_version (PC_PROTOBUF protobuf>=2.4)
find_required_library (ICU_UC unicode/uchar.h icuuc "ICU")
check_library_version (PC_ICU_UC icu-uc>=4.4)
set (ICU_INCLUDE_DIR ${ICU_UC_INCLUDE_DIR})
set (ICU_LIB ${ICU_UC_LIB})
# If ICU regexp engine is used or if the geocoder is built, use icui18n as well.
if (${USE_ICU_REGEXP} STREQUAL "ON" OR ${BUILD_GEOCODER} STREQUAL "ON")
find_required_library (ICU_I18N unicode/regex.h icui18n "ICU")
check_library_version (PC_ICU_I18N icu-i18n>=4.4)
list (APPEND ICU_INCLUDE_DIR ${ICU_I18N_INCLUDE_DIR})
list (APPEND ICU_LIB ${ICU_I18N_LIB})
endif ()
find_required_program (PROTOC protoc
"Google Protocol Buffers compiler (protoc)")
find_required_program (JAVA java
"Java Runtime Environment")
if (APPLE)
FIND_LIBRARY (COREFOUNDATION_LIB CoreFoundation)
FIND_LIBRARY (FOUNDATION_LIB Foundation)
set (CMAKE_MACOSX_RPATH "OFF")
set (CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS
"${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
endif ()
if (${USE_STD_MAP} STREQUAL "OFF")
INCLUDE (CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX ("tr1/unordered_map" HAVE_CXX_TR1_UNORDERED_MAP)
if (HAVE_CXX_TR1_UNORDERED_MAP)
add_definitions ("-DI18N_PHONENUMBERS_USE_TR1_UNORDERED_MAP")
endif ()
endif ()
# Add protoc (Protocol Buffers compiler) target.
set (RESOURCES_DIR "${CMAKE_SOURCE_DIR}/../resources")
set (
PROTOBUF_SOURCES "${RESOURCES_DIR}/phonemetadata.proto"
"${RESOURCES_DIR}/phonenumber.proto"
)
set (
PROTOBUF_OUTPUT "${CMAKE_SOURCE_DIR}/src/phonenumbers/phonemetadata.pb.cc"
"${CMAKE_SOURCE_DIR}/src/phonenumbers/phonemetadata.pb.h"
"${CMAKE_SOURCE_DIR}/src/phonenumbers/phonenumber.pb.cc"
"${CMAKE_SOURCE_DIR}/src/phonenumbers/phonenumber.pb.h"
)
add_custom_command (
COMMAND ${PROTOC_BIN} --cpp_out=${CMAKE_SOURCE_DIR}/src/phonenumbers/
--proto_path=${RESOURCES_DIR} ${PROTOBUF_SOURCES}
OUTPUT ${PROTOBUF_OUTPUT}
DEPENDS ${PROTOBUF_SOURCES}
)
if (${BUILD_GEOCODER} STREQUAL "ON")
# Geocoding data cpp file generation
set (TOOLS_DIR "${CMAKE_CURRENT_BINARY_DIR}/tools")
add_subdirectory("${CMAKE_SOURCE_DIR}/../tools/cpp" "${TOOLS_DIR}")
set (GEOCODING_DIR "${RESOURCES_DIR}/geocoding")
file (GLOB_RECURSE GEOCODING_SOURCES "${GEOCODING_DIR}/*.txt")
set (GEOCODING_DATA_OUTPUT
"${CMAKE_SOURCE_DIR}/src/phonenumbers/geocoding/geocoding_data.cc"
)
add_custom_command (
COMMAND generate_geocoding_data "${GEOCODING_DIR}"
"${GEOCODING_DATA_OUTPUT}"
OUTPUT ${GEOCODING_DATA_OUTPUT}
DEPENDS ${GEOCODING_SOURCES}
generate_geocoding_data
COMMENT "Generating geocoding data code"
)
endif ()
set (
SOURCES
"src/phonenumbers/asyoutypeformatter.cc"
"src/phonenumbers/base/strings/string_piece.cc"
"src/phonenumbers/default_logger.cc"
"src/phonenumbers/logger.cc"
"src/phonenumbers/phonemetadata.pb.cc" # Generated by Protocol Buffers.
"src/phonenumbers/phonenumber.cc"
"src/phonenumbers/phonenumber.pb.cc" # Generated by Protocol Buffers.
"src/phonenumbers/phonenumberutil.cc"
"src/phonenumbers/regex_based_matcher.cc"
"src/phonenumbers/regexp_cache.cc"
"src/phonenumbers/shortnumberinfo.cc"
"src/phonenumbers/string_byte_sink.cc"
"src/phonenumbers/stringutil.cc"
"src/phonenumbers/unicodestring.cc"
"src/phonenumbers/utf/rune.c"
"src/phonenumbers/utf/unicodetext.cc"
"src/phonenumbers/utf/unilib.cc"
)
if (${BUILD_GEOCODER} STREQUAL "ON")
set (
GEOCODING_SOURCES
"src/phonenumbers/geocoding/area_code_map.cc"
"src/phonenumbers/geocoding/default_map_storage.cc"
"src/phonenumbers/geocoding/geocoding_data.cc"
"src/phonenumbers/geocoding/mapping_file_provider.cc"
"src/phonenumbers/geocoding/phonenumber_offline_geocoder.cc"
"src/phonenumbers/phonenumber.pb.h" # Forces proto buffer generation.
)
endif ()
# Add regexp engine-dependent sources. ICU is used by default.
if (${USE_RE2} STREQUAL "ON")
# Add a flag to select the right regexp factory implementation used by
# regexp_factory.h and regexp_adapter_test.cc.
# When both ICU regexp and RE2 are defined, the regexp engine adapter defaults
# to RE2 unless the ICU implementation is instantiated explictly obviously.
add_definitions ("-DI18N_PHONENUMBERS_USE_RE2")
list (APPEND SOURCES "src/phonenumbers/regexp_adapter_re2.cc")
endif ()
if (${USE_ICU_REGEXP} STREQUAL "ON")
add_definitions ("-DI18N_PHONENUMBERS_USE_ICU_REGEXP")
list (APPEND SOURCES "src/phonenumbers/regexp_adapter_icu.cc")
# The phone number matcher needs ICU.
list (APPEND SOURCES "src/phonenumbers/phonenumbermatch.cc")
list (APPEND SOURCES "src/phonenumbers/phonenumbermatcher.cc")
if (${USE_ALTERNATE_FORMATS} STREQUAL "ON")
list (APPEND SOURCES "src/phonenumbers/alternate_format.cc")
endif ()
endif ()
# Library sources excluding the metadata files, since special metadata is used
# for unit-testing. Note that a single testing library is built for both
# libphonenumber and geocoding.
set (TESTING_LIBRARY_SOURCES ${SOURCES})
if (${BUILD_GEOCODER} STREQUAL "ON")
list (APPEND TESTING_LIBRARY_SOURCES ${GEOCODING_SOURCES})
endif ()
# Add metadata code generation targets.
# This function is invoked to create metadata, test metadata and lite metadata
# code generation targets.
function (add_metadata_gen_target TARGET_NAME
XML_FILE
METADATA_TYPE
METADATA_HEADER)
set (METADATA_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/phonenumbers")
set (GEN_OUTPUT "${METADATA_SOURCE_DIR}/${METADATA_TYPE}.cc"
"${METADATA_SOURCE_DIR}/${METADATA_HEADER}.h")
set (JAR_PATH "${CMAKE_SOURCE_DIR}/../tools/java/cpp-build/target")
set (JAR_PATH "${JAR_PATH}/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar")
add_custom_command (
COMMAND ${JAVA_BIN} -jar
${JAR_PATH} BuildMetadataCppFromXml ${XML_FILE}
${CMAKE_SOURCE_DIR}/src/phonenumbers ${METADATA_TYPE}
OUTPUT ${GEN_OUTPUT}
DEPENDS ${XML_FILE}
)
add_custom_target (
${TARGET_NAME}
DEPENDS ${GEN_OUTPUT}
COMMENT "Generating Metadata code"
)
endfunction (add_metadata_gen_target)
if (${USE_LITE_METADATA} STREQUAL "ON")
# Add the lite metadata generation target.
set (METADATA_TARGET "generate-lite-metadata")
add_metadata_gen_target (
${METADATA_TARGET}
"${RESOURCES_DIR}/PhoneNumberMetadata.xml"
"lite_metadata"
"metadata"
)
list (APPEND SOURCES "src/phonenumbers/lite_metadata.cc")
else ()
# Add the metadata generation target.
set (METADATA_TARGET "generate-metadata")
add_metadata_gen_target (
${METADATA_TARGET}
"${RESOURCES_DIR}/PhoneNumberMetadata.xml"
"metadata"
"metadata"
)
list (APPEND SOURCES "src/phonenumbers/metadata.cc")
endif ()
# Add the test metadata generation target.
set (TEST_METADATA_TARGET "generate-test-metadata")
add_metadata_gen_target (
${TEST_METADATA_TARGET}
"${RESOURCES_DIR}/PhoneNumberMetadataForTesting.xml"
"test_metadata"
"metadata"
)
list (APPEND TESTING_LIBRARY_SOURCES "src/phonenumbers/test_metadata.cc")
# Add the short metadata generation target.
set (SHORT_METADATA_TARGET "generate-short-number-metadata")
add_metadata_gen_target (
${SHORT_METADATA_TARGET}
"${RESOURCES_DIR}/ShortNumberMetadata.xml"
"short_metadata"
"short_metadata"
)
# This is used both for the real library and for testing.
list (APPEND SOURCES "src/phonenumbers/short_metadata.cc")
list (APPEND TESTING_LIBRARY_SOURCES "src/phonenumbers/short_metadata.cc")
if (${USE_ICU_REGEXP} STREQUAL "ON")
if (${USE_ALTERNATE_FORMATS} STREQUAL "ON")
# Add alternate format metadata generation for the phone number matcher.
set (ALT_FORMAT_METADATA_TARGET "generate-alt-format-metadata")
add_metadata_gen_target (
${ALT_FORMAT_METADATA_TARGET}
"${RESOURCES_DIR}/PhoneNumberAlternateFormats.xml"
"alternate_format"
"alternate_format"
)
endif ()
endif ()
if (NOT WIN32)
add_definitions ("-Wall -Werror")
endif ()
include_directories ("src")
if (${BUILD_STATIC_LIB} STREQUAL "ON")
# Build a static library (without -fPIC).
add_library (phonenumber STATIC ${SOURCES})
if (${BUILD_GEOCODER} STREQUAL "ON")
add_dependencies (phonenumber generate_geocoding_data)
endif ()
if (${USE_ICU_REGEXP} STREQUAL "ON")
if (${USE_ALTERNATE_FORMATS} STREQUAL "ON")
add_dependencies (phonenumber ${ALT_FORMAT_METADATA_TARGET})
endif ()
endif ()
endif ()
if (${BUILD_GEOCODER} STREQUAL "ON")
if (${BUILD_STATIC_LIB} STREQUAL "ON")
add_library (geocoding STATIC ${GEOCODING_SOURCES})
add_dependencies (geocoding generate_geocoding_data)
endif ()
# The geocoder doesn't use RE2 so there is no reason not to build a shared
# library for it.
add_library (geocoding-shared SHARED ${GEOCODING_SOURCES})
add_dependencies (geocoding-shared generate_geocoding_data)
set_target_properties (geocoding-shared
PROPERTIES
OUTPUT_NAME "geocoding"
PREFIX "lib"
SOVERSION ${libphonenumber_VERSION_MAJOR}
VERSION ${libphonenumber_VERSION_MAJOR}.${libphonenumber_VERSION_MINOR})
endif ()
# Build a shared library (with -fPIC).
set (BUILD_SHARED_LIB true)
if (${USE_RE2} STREQUAL "ON")
# RE2 is not always available as a shared library (e.g: package provided by
# Ubuntu) therefore disable the shared library build in this case.
if (${RE2_LIB} MATCHES ".*\\.a")
message (WARNING
"RE2 not available as a shared library, shared library build disabled")
set (BUILD_SHARED_LIB false)
endif ()
endif ()
if (BUILD_SHARED_LIB)
add_library (phonenumber-shared SHARED ${SOURCES})
if (${BUILD_GEOCODER} STREQUAL "ON")
add_dependencies (phonenumber-shared generate_geocoding_data)
endif ()
if (${USE_ICU_REGEXP} STREQUAL "ON")
if (${USE_ALTERNATE_FORMATS} STREQUAL "ON")
add_dependencies (phonenumber-shared ${ALT_FORMAT_METADATA_TARGET})
endif ()
endif ()
set_target_properties (phonenumber-shared
PROPERTIES
OUTPUT_NAME "phonenumber"
PREFIX "lib"
SOVERSION ${libphonenumber_VERSION_MAJOR}
VERSION ${libphonenumber_VERSION_MAJOR}.${libphonenumber_VERSION_MINOR})
endif ()
# Libraries used by both libphonenumber and libgeocoding.
set (COMMON_DEPS ${ICU_LIB})
set (LIBRARY_DEPS ${PROTOBUF_LIB})
if (${USE_BOOST} STREQUAL "ON")
list (APPEND LIBRARY_DEPS ${Boost_LIBRARIES})
endif ()
if (${USE_RE2} STREQUAL "ON")
list (APPEND LIBRARY_DEPS ${RE2_LIB})
endif ()
if (APPLE)
list (APPEND COMMON_DEPS ${COREFOUNDATION_LIB} ${FOUNDATION_LIB})
endif ()
list (APPEND LIBRARY_DEPS ${COMMON_DEPS})
if (${BUILD_STATIC_LIB} STREQUAL "ON")
target_link_libraries (phonenumber ${LIBRARY_DEPS})
endif ()
if (BUILD_SHARED_LIB)
target_link_libraries (phonenumber-shared ${LIBRARY_DEPS})
endif ()
if (${BUILD_GEOCODER} STREQUAL "ON")
list (APPEND GEOCODER_DEPS ${COMMON_DEPS})
# Note that the subset of base/ on which the geocoder relies is implemented
# on top of Boost header-only libraries (e.g. scoped_ptr.hpp).
target_link_libraries (geocoding ${LIBRARY_DEPS})
target_link_libraries (geocoding-shared ${LIBRARY_DEPS})
endif ()
# Build a specific library for testing purposes.
add_library (phonenumber_testing STATIC ${TESTING_LIBRARY_SOURCES})
if (${BUILD_GEOCODER} STREQUAL "ON")
add_dependencies (phonenumber_testing generate_geocoding_data)
endif ()
target_link_libraries (phonenumber_testing ${LIBRARY_DEPS})
if (${BUILD_GEOCODER} STREQUAL "ON")
# Test geocoding data cpp files generation.
set (GEOCODING_TEST_DIR "${RESOURCES_DIR}/test/geocoding")
file (GLOB_RECURSE GEOCODING_TEST_SOURCES "${GEOCODING_TEST_DIR}/*.txt")
set (GEOCODING_TEST_DATA_OUTPUT
"${CMAKE_SOURCE_DIR}/test/phonenumbers/geocoding/geocoding_test_data.cc"
)
add_custom_command (
COMMAND generate_geocoding_data "${GEOCODING_TEST_DIR}"
"${GEOCODING_TEST_DATA_OUTPUT}" "_test"
OUTPUT ${GEOCODING_TEST_DATA_OUTPUT}
DEPENDS ${GEOCODING_TEST_SOURCES} generate_geocoding_data
COMMENT "Generating geocoding test data code"
)
endif ()
set (TEST_SOURCES
"test/phonenumbers/asyoutypeformatter_test.cc"
"test/phonenumbers/logger_test.cc"
"test/phonenumbers/matcher_test.cc"
"test/phonenumbers/phonenumberutil_test.cc"
"test/phonenumbers/regexp_adapter_test.cc"
"test/phonenumbers/regexp_cache_test.cc"
"test/phonenumbers/run_tests.cc"
"test/phonenumbers/shortnumberinfo_test.cc"
"test/phonenumbers/stringutil_test.cc"
"test/phonenumbers/test_util.cc"
"test/phonenumbers/unicodestring_test.cc"
"test/phonenumbers/utf/unicodetext_test.cc"
)
if (${BUILD_GEOCODER} STREQUAL "ON")
set (GEOCODING_TEST_SOURCES
"test/phonenumbers/geocoding/area_code_map_test.cc"
"test/phonenumbers/geocoding/geocoding_data_test.cc"
"test/phonenumbers/geocoding/geocoding_test_data.cc"
"test/phonenumbers/geocoding/mapping_file_provider_test.cc"
"test/phonenumbers/geocoding/phonenumber_offline_geocoder_test.cc"
)
list (APPEND TEST_SOURCES ${GEOCODING_TEST_SOURCES})
endif ()
if (${USE_ICU_REGEXP} STREQUAL "ON")
# Add the phone number matcher tests.
list (APPEND TEST_SOURCES "test/phonenumbers/phonenumbermatch_test.cc")
list (APPEND TEST_SOURCES "test/phonenumbers/phonenumbermatcher_test.cc")
endif ()
# Build the testing binary.
include_directories ("test")
add_executable (libphonenumber_test ${TEST_SOURCES})
set (TEST_LIBS phonenumber_testing ${GTEST_LIB})
if (NOT WIN32)
list (APPEND TEST_LIBS pthread)
endif ()
target_link_libraries (libphonenumber_test ${TEST_LIBS})
# Unfortunately add_custom_target() can't accept a single command provided as a
# list of commands.
if (${BUILD_GEOCODER} STREQUAL "ON")
add_custom_target (tests
COMMAND generate_geocoding_data_test
COMMAND libphonenumber_test
DEPENDS generate_geocoding_data_test libphonenumber_test
)
else ()
add_custom_target (tests
COMMAND libphonenumber_test
DEPENDS libphonenumber_test
)
endif ()
# Install rules.
install (FILES
"src/phonenumbers/asyoutypeformatter.h"
"src/phonenumbers/callback.h"
"src/phonenumbers/logger.h"
"src/phonenumbers/matcher_api.h"
"src/phonenumbers/phonenumber.pb.h"
"src/phonenumbers/phonemetadata.pb.h"
"src/phonenumbers/phonenumberutil.h"
"src/phonenumbers/regexp_adapter.h"
"src/phonenumbers/regexp_cache.h"
"src/phonenumbers/region_code.h"
"src/phonenumbers/shortnumberinfo.h"
"src/phonenumbers/unicodestring.h"
DESTINATION include/phonenumbers/
)
install (FILES "src/phonenumbers/utf/unicodetext.h"
DESTINATION include/phonenumbers/utf/)
if (${USE_ICU_REGEXP} STREQUAL "ON")
# Install the phone number matcher headers.
install (FILES
"src/phonenumbers/phonenumbermatch.h"
"src/phonenumbers/phonenumbermatcher.h"
"src/phonenumbers/regexp_adapter.h"
DESTINATION include/phonenumbers/
)
endif ()
if (${BUILD_GEOCODER} STREQUAL "ON")
install (FILES
"src/phonenumbers/geocoding/phonenumber_offline_geocoder.h"
DESTINATION include/phonenumbers/geocoding
)
endif ()
install (
FILES
"src/phonenumbers/base/basictypes.h"
"src/phonenumbers/base/template_util.h"
"src/phonenumbers/base/logging.h"
"src/phonenumbers/base/thread_checker.h"
DESTINATION include/phonenumbers/base/
)
install (FILES
"src/phonenumbers/base/memory/scoped_ptr.h"
"src/phonenumbers/base/memory/singleton.h"
"src/phonenumbers/base/memory/singleton_posix.h"
DESTINATION include/phonenumbers/base/memory/
)
install (FILES "src/phonenumbers/base/synchronization/lock.h"
"src/phonenumbers/base/synchronization/lock_posix.h"
DESTINATION include/phonenumbers/base/synchronization/)
set (LIBDIR ${CMAKE_INSTALL_LIBDIR})
if (${BUILD_STATIC_LIB} STREQUAL "ON")
install (TARGETS phonenumber LIBRARY DESTINATION ${LIBDIR} ARCHIVE DESTINATION ${LIBDIR})
endif ()
if (BUILD_SHARED_LIB)
install (TARGETS phonenumber-shared LIBRARY DESTINATION ${LIBDIR} ARCHIVE
DESTINATION ${LIBDIR})
endif ()
if (${BUILD_GEOCODER} STREQUAL "ON")
install (TARGETS geocoding LIBRARY DESTINATION ${LIBDIR} ARCHIVE DESTINATION ${LIBDIR})
install (TARGETS geocoding-shared LIBRARY DESTINATION ${LIBDIR} ARCHIVE
DESTINATION ${LIBDIR})
endif ()
# Build an example program using geocoding, mainly to make sure that both
# libraries are built properly.
if (${BUILD_GEOCODER} STREQUAL "ON")
add_executable (
geocoding_test_program
"test/phonenumbers/geocoding/geocoding_test_program.cc"
)
target_link_libraries (geocoding_test_program geocoding phonenumber)
endif ()
# Build an RPM
set (CPACK_PACKAGE_VERSION ${libphonenumber_VERSION_MAJOR}.${libphonenumber_VERSION_MINOR}.${libphonenumber_VERSION_PATCH})
set (CPACK_GENERATOR "RPM")
set (CPACK_PACKAGE_NAME "libphonenumber")
set (CPACK_RPM_PACKAGE_RELEASE 1)
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Google's phone number handling library")
if (32BIT)
set (CPACK_RPM_PACKAGE_ARCHITECTURE i686)
else ()
set (CPACK_RPM_PACKAGE_ARCHITECTURE x86_64)
endif ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
include (CPack)
|
2301_81045437/third_party_libphonenumber
|
cpp/CMakeLists.txt
|
CMake
|
unknown
| 21,147
|
/*
* Copyright (C) 2012 The Libphonenumber Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "phonenumbers/alternate_format.h"
namespace i18n {
namespace phonenumbers {
namespace {
static const unsigned char data[] = {
0x0A, 0x2C, 0x4A, 0x00, 0x50, 0xCB, 0x07, 0x9A, 0x01, 0x24, 0x0A, 0x15, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24,
0x32, 0x20, 0x24, 0x33, 0x1A, 0x01, 0x35, 0x0A, 0xFA, 0x02, 0x4A, 0x00, 0x50,
0x36, 0x9A, 0x01, 0xEB, 0x01, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A,
0xC7, 0x01, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x32, 0x33, 0x5D, 0x30, 0x32, 0x7C,
0x36, 0x28, 0x3F, 0x3A, 0x5B, 0x32, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x36, 0x2D,
0x38, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x32, 0x33, 0x35,
0x36, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x32, 0x35, 0x36, 0x38, 0x5D, 0x7C, 0x37,
0x32, 0x7C, 0x38, 0x5B, 0x32, 0x33, 0x5D, 0x29, 0x29, 0x7C, 0x33, 0x28, 0x3F,
0x3A, 0x33, 0x5B, 0x32, 0x38, 0x5D, 0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x5B, 0x30,
0x34, 0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x35, 0x2D, 0x38, 0x5D, 0x7C,
0x38, 0x5B, 0x32, 0x33, 0x37, 0x39, 0x5D, 0x29, 0x7C, 0x35, 0x28, 0x3F, 0x3A,
0x5B, 0x32, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x33, 0x5B, 0x32, 0x33, 0x37, 0x5D,
0x7C, 0x38, 0x5B, 0x32, 0x2D, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x5B, 0x31, 0x2D,
0x35, 0x37, 0x38, 0x5D, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x5B, 0x32, 0x34, 0x36,
0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x32, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x35, 0x5B,
0x34, 0x2D, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x33, 0x36, 0x2D, 0x38, 0x5D, 0x7C,
0x38, 0x5B, 0x35, 0x2D, 0x38, 0x5D, 0x29, 0x29, 0x7C, 0x32, 0x28, 0x3F, 0x3A,
0x32, 0x5B, 0x32, 0x34, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x2D, 0x35,
0x39, 0x5D, 0x7C, 0x34, 0x37, 0x29, 0x9A, 0x01, 0x83, 0x01, 0x0A, 0x19, 0x28,
0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x0B,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x59,
0x39, 0x28, 0x3F, 0x3A, 0x32, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x30, 0x32, 0x34,
0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x2D, 0x35, 0x39, 0x5D, 0x7C, 0x34,
0x37, 0x7C, 0x36, 0x5B, 0x32, 0x34, 0x35, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x32,
0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x32, 0x38,
0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x35, 0x5B, 0x32,
0x2D, 0x34, 0x36, 0x2D, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x35, 0x37,
0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x29, 0x29, 0x0A, 0xBE,
0x06, 0x4A, 0x00, 0x50, 0x2B, 0x9A, 0x01, 0x2D, 0x0A, 0x1B, 0x28, 0x5C, 0x64,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x2C, 0x33, 0x7D, 0x29, 0x12, 0x0B,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x01,
0x31, 0x9A, 0x01, 0x1E, 0x0A, 0x0D, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x34, 0x2C, 0x36, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32,
0x1A, 0x06, 0x35, 0x5B, 0x30, 0x37, 0x39, 0x5D, 0x9A, 0x01, 0x1E, 0x0A, 0x0D,
0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x37, 0x2C, 0x38, 0x7D, 0x29,
0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32, 0x1A, 0x06, 0x35, 0x5B, 0x30, 0x37,
0x39, 0x5D, 0x9A, 0x01, 0x35, 0x0A, 0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x2C, 0x33, 0x7D, 0x29, 0x12, 0x0B,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x06,
0x35, 0x5B, 0x30, 0x37, 0x39, 0x5D, 0x9A, 0x01, 0x21, 0x0A, 0x10, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x36, 0x2C, 0x37, 0x7D,
0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32, 0x1A, 0x06, 0x35, 0x5B, 0x30,
0x37, 0x39, 0x5D, 0x9A, 0x01, 0x1F, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x39, 0x2C, 0x31, 0x32, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31,
0x20, 0x24, 0x32, 0x1A, 0x06, 0x35, 0x5B, 0x30, 0x37, 0x39, 0x5D, 0x9A, 0x01,
0x33, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x06, 0x35, 0x5B, 0x30, 0x37, 0x39, 0x5D,
0x9A, 0x01, 0x3F, 0x0A, 0x25, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x2C,
0x34, 0x7D, 0x29, 0x12, 0x0E, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x1A, 0x06, 0x35, 0x5B, 0x30, 0x37, 0x39,
0x5D, 0x9A, 0x01, 0x2B, 0x0A, 0x17, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x2C,
0x36, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x1A, 0x06, 0x35, 0x5B, 0x30, 0x37, 0x39, 0x5D, 0x9A, 0x01, 0x62, 0x0A, 0x1E,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x2C, 0x34, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x20, 0x24, 0x34, 0x1A, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x31, 0x7C, 0x34,
0x29, 0x36, 0x7C, 0x35, 0x31, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x35, 0x5B, 0x30,
0x2D, 0x33, 0x35, 0x37, 0x39, 0x5D, 0x7C, 0x5B, 0x36, 0x2D, 0x39, 0x5D, 0x29,
0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x30, 0x7C, 0x33, 0x32, 0x7C, 0x38, 0x29,
0x7C, 0x5B, 0x38, 0x39, 0x5D, 0x9A, 0x01, 0x62, 0x0A, 0x1E, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x2C, 0x33, 0x7D,
0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24,
0x34, 0x1A, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x31, 0x7C, 0x34, 0x29, 0x36, 0x7C,
0x35, 0x31, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x35, 0x5B, 0x30, 0x2D, 0x33, 0x35,
0x37, 0x39, 0x5D, 0x7C, 0x5B, 0x36, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x37, 0x28,
0x3F, 0x3A, 0x32, 0x30, 0x7C, 0x33, 0x32, 0x7C, 0x38, 0x29, 0x7C, 0x5B, 0x38,
0x39, 0x5D, 0x9A, 0x01, 0x62, 0x0A, 0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x2C, 0x33, 0x7D, 0x29, 0x12, 0x0B,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x33,
0x28, 0x3F, 0x3A, 0x33, 0x31, 0x7C, 0x34, 0x29, 0x36, 0x7C, 0x35, 0x31, 0x7C,
0x36, 0x28, 0x3F, 0x3A, 0x35, 0x5B, 0x30, 0x2D, 0x33, 0x35, 0x37, 0x39, 0x5D,
0x7C, 0x5B, 0x36, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32,
0x30, 0x7C, 0x33, 0x32, 0x7C, 0x38, 0x29, 0x7C, 0x5B, 0x38, 0x39, 0x5D, 0x9A,
0x01, 0x72, 0x0A, 0x17, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x2C, 0x34, 0x7D,
0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x4D,
0x32, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x31, 0x5B, 0x31, 0x2D, 0x35, 0x37, 0x38,
0x5D, 0x7C, 0x5B, 0x33, 0x2D, 0x36, 0x38, 0x5D, 0x29, 0x7C, 0x34, 0x5B, 0x32,
0x33, 0x37, 0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x36,
0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x32, 0x34, 0x5D, 0x7C, 0x35, 0x5B, 0x34, 0x36,
0x38, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x38,
0x5D, 0x7C, 0x33, 0x35, 0x7C, 0x5B, 0x34, 0x2D, 0x37, 0x39, 0x5D, 0x29, 0x0A,
0x96, 0x01, 0x4A, 0x00, 0x50, 0x3D, 0x9A, 0x01, 0x2B, 0x0A, 0x1C, 0x28, 0x5C,
0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34,
0x9A, 0x01, 0x17, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x36, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32,
0x9A, 0x01, 0x28, 0x0A, 0x19, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x20, 0x24, 0x34, 0x9A, 0x01, 0x1C, 0x0A, 0x0B, 0x28, 0x5C, 0x64, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x38, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24,
0x32, 0x1A, 0x06, 0x5B, 0x32, 0x33, 0x37, 0x38, 0x5D, 0x0A, 0x91, 0x01, 0x4A,
0x00, 0x50, 0xE7, 0x02, 0x9A, 0x01, 0x2B, 0x0A, 0x19, 0x28, 0x5C, 0x64, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x01, 0x32, 0x9A, 0x01,
0x27, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x04, 0x38, 0x7C, 0x39,
0x38, 0x9A, 0x01, 0x31, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x04, 0x38, 0x7C, 0x39,
0x38, 0x0A, 0x42, 0x4A, 0x00, 0x50, 0x37, 0x9A, 0x01, 0x3B, 0x0A, 0x0E, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x38, 0x7D, 0x29,
0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32, 0x1A, 0x22, 0x5B, 0x31, 0x32, 0x34,
0x36, 0x37, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x2D, 0x35, 0x37, 0x38, 0x5D, 0x7C,
0x35, 0x5B, 0x31, 0x33, 0x2D, 0x35, 0x5D, 0x7C, 0x5B, 0x38, 0x39, 0x5D, 0x5B,
0x31, 0x2D, 0x39, 0x5D, 0x0A, 0x29, 0x4A, 0x00, 0x50, 0xFA, 0x03, 0x9A, 0x01,
0x21, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x08,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x0A, 0xF1, 0x5C, 0x4A, 0x00,
0x50, 0x31, 0x9A, 0x01, 0x30, 0x0A, 0x17, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x2C, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x1A, 0x0B, 0x5B, 0x33, 0x34, 0x5D, 0x30, 0x7C, 0x5B, 0x36, 0x38, 0x5D,
0x39, 0x9A, 0x01, 0x8D, 0x06, 0x0A, 0x23, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x12, 0x0E, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x1A, 0xD5, 0x05, 0x32, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30,
0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30,
0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D,
0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x30,
0x5B, 0x31, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x32, 0x37,
0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x35, 0x37, 0x38, 0x5D,
0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x38, 0x5B,
0x31, 0x32, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x29,
0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x7C, 0x34,
0x5B, 0x31, 0x33, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x34,
0x36, 0x5D, 0x29, 0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x34, 0x5D,
0x7C, 0x32, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B,
0x31, 0x2D, 0x34, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x38, 0x5D,
0x7C, 0x38, 0x5B, 0x31, 0x33, 0x35, 0x36, 0x38, 0x5D, 0x29, 0x7C, 0x36, 0x28,
0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x34, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x5B,
0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x33, 0x5D, 0x7C,
0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D,
0x33, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x29, 0x7C,
0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x37, 0x5D, 0x7C, 0x34, 0x5B,
0x31, 0x34, 0x35, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x35, 0x5D, 0x7C, 0x37,
0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32, 0x31,
0x7C, 0x36, 0x7C, 0x37, 0x5B, 0x31, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x38, 0x5B,
0x31, 0x33, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31,
0x32, 0x34, 0x37, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x38, 0x5D,
0x7C, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x37, 0x39, 0x5D, 0x7C, 0x36, 0x5B,
0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x7C, 0x38,
0x5B, 0x31, 0x34, 0x37, 0x5D, 0x29, 0x29, 0x7C, 0x34, 0x5B, 0x30, 0x31, 0x5D,
0x7C, 0x35, 0x30, 0x7C, 0x36, 0x5B, 0x30, 0x39, 0x5D, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x30, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x2D, 0x35, 0x5D, 0x7C, 0x39, 0x5B,
0x30, 0x33, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x33, 0x5B,
0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x35, 0x5B, 0x30, 0x33,
0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B,
0x30, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x39, 0x29, 0x7C, 0x39, 0x28, 0x3F,
0x3A, 0x30, 0x5B, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x32, 0x2D,
0x34, 0x36, 0x37, 0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A, 0x34, 0x35, 0x7C, 0x38,
0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A,
0x38, 0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34, 0x36, 0x38, 0x5D, 0x7C,
0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x37, 0x5D, 0x7C,
0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29, 0x5B, 0x31, 0x33,
0x35, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x36, 0x7C, 0x37, 0x31, 0x7C,
0x38, 0x30, 0x29, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A,
0x33, 0x5B, 0x34, 0x36, 0x5D, 0x7C, 0x34, 0x36, 0x7C, 0x35, 0x5B, 0x34, 0x39,
0x5D, 0x29, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32,
0x32, 0x7C, 0x34, 0x37, 0x7C, 0x38, 0x31, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37,
0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x35, 0x37, 0x39, 0x5D, 0x33, 0x5B, 0x31,
0x33, 0x35, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x38, 0x7C, 0x34, 0x39,
0x7C, 0x35, 0x5B, 0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x37, 0x5D, 0x7C,
0x39, 0x5B, 0x35, 0x38, 0x39, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x5D,
0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x35, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B,
0x32, 0x2D, 0x34, 0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36,
0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x37, 0x33,
0x7C, 0x38, 0x32, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x5B, 0x30,
0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x34, 0x7C, 0x5B, 0x34,
0x39, 0x5D, 0x36, 0x7C, 0x35, 0x5B, 0x33, 0x38, 0x5D, 0x7C, 0x36, 0x5B, 0x34,
0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x38, 0x37, 0x29,
0x5B, 0x30, 0x32, 0x2D, 0x38, 0x5D, 0x9A, 0x01, 0x30, 0x0A, 0x17, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x33, 0x2C, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x0B, 0x5B, 0x33, 0x34, 0x5D, 0x30, 0x7C,
0x5B, 0x36, 0x38, 0x5D, 0x39, 0x9A, 0x01, 0x3A, 0x0A, 0x1E, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x31, 0x2C, 0x32, 0x7D,
0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24,
0x34, 0x1A, 0x0B, 0x5B, 0x33, 0x34, 0x5D, 0x30, 0x7C, 0x5B, 0x36, 0x38, 0x5D,
0x39, 0x9A, 0x01, 0x3D, 0x0A, 0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x2C, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x0E, 0x33,
0x5B, 0x30, 0x32, 0x5D, 0x7C, 0x34, 0x30, 0x7C, 0x5B, 0x36, 0x38, 0x5D, 0x39,
0x9A, 0x01, 0x4C, 0x0A, 0x27, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x11, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x20, 0x24, 0x36, 0x1A, 0x0E,
0x33, 0x5B, 0x30, 0x32, 0x5D, 0x7C, 0x34, 0x30, 0x7C, 0x5B, 0x36, 0x38, 0x5D,
0x39, 0x9A, 0x01, 0x91, 0x01, 0x0A, 0x17, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x2C, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x1A, 0x6C, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x33, 0x38,
0x39, 0x5D, 0x7C, 0x31, 0x32, 0x5B, 0x30, 0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x33,
0x28, 0x3F, 0x3A, 0x5B, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x5B, 0x31, 0x35, 0x5D,
0x7C, 0x34, 0x5B, 0x30, 0x31, 0x35, 0x5D, 0x29, 0x7C, 0x39, 0x30, 0x36, 0x7C,
0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x33, 0x5D, 0x5B, 0x31, 0x34, 0x5D, 0x7C,
0x32, 0x5B, 0x31, 0x38, 0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x34,
0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x35,
0x37, 0x39, 0x5D, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x36, 0x38, 0x5D,
0x5B, 0x31, 0x2D, 0x38, 0x5D, 0x29, 0x31, 0x9A, 0x01, 0x91, 0x01, 0x0A, 0x17,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x2C, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x6C, 0x32, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x31, 0x2D, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x31, 0x32, 0x5B, 0x30,
0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x5B, 0x33, 0x35, 0x2D,
0x39, 0x5D, 0x5B, 0x31, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x31, 0x35, 0x5D,
0x29, 0x7C, 0x39, 0x30, 0x36, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x33,
0x5D, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x38, 0x5D, 0x29, 0x7C,
0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x34, 0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32,
0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x35, 0x37, 0x39, 0x5D, 0x5B, 0x31, 0x2D, 0x39,
0x5D, 0x7C, 0x5B, 0x36, 0x38, 0x5D, 0x5B, 0x31, 0x2D, 0x38, 0x5D, 0x29, 0x31,
0x9A, 0x01, 0x9B, 0x01, 0x0A, 0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x31, 0x2C, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x6C, 0x32,
0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x31,
0x32, 0x5B, 0x30, 0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x5B,
0x33, 0x35, 0x2D, 0x39, 0x5D, 0x5B, 0x31, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x30,
0x31, 0x35, 0x5D, 0x29, 0x7C, 0x39, 0x30, 0x36, 0x7C, 0x32, 0x28, 0x3F, 0x3A,
0x5B, 0x31, 0x33, 0x5D, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x38,
0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x34, 0x2D, 0x39, 0x5D, 0x7C,
0x34, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x35, 0x37, 0x39, 0x5D, 0x5B,
0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x36, 0x38, 0x5D, 0x5B, 0x31, 0x2D, 0x38,
0x5D, 0x29, 0x31, 0x9A, 0x01, 0xA3, 0x01, 0x0A, 0x23, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0E, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x1A, 0x6C, 0x32, 0x28, 0x3F,
0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x31, 0x32, 0x5B,
0x30, 0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x5B, 0x33, 0x35,
0x2D, 0x39, 0x5D, 0x5B, 0x31, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x31, 0x35,
0x5D, 0x29, 0x7C, 0x39, 0x30, 0x36, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x31,
0x33, 0x5D, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x38, 0x5D, 0x29,
0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x34, 0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B,
0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x35, 0x37, 0x39, 0x5D, 0x5B, 0x31, 0x2D,
0x39, 0x5D, 0x7C, 0x5B, 0x36, 0x38, 0x5D, 0x5B, 0x31, 0x2D, 0x38, 0x5D, 0x29,
0x31, 0x9A, 0x01, 0x99, 0x01, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x6C, 0x32, 0x28,
0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x31, 0x32,
0x5B, 0x30, 0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x5B, 0x33,
0x35, 0x2D, 0x39, 0x5D, 0x5B, 0x31, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x31,
0x35, 0x5D, 0x29, 0x7C, 0x39, 0x30, 0x36, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x5B,
0x31, 0x33, 0x5D, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x38, 0x5D,
0x29, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x34, 0x2D, 0x39, 0x5D, 0x7C, 0x34,
0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x35, 0x37, 0x39, 0x5D, 0x5B, 0x31,
0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x36, 0x38, 0x5D, 0x5B, 0x31, 0x2D, 0x38, 0x5D,
0x29, 0x31, 0x9A, 0x01, 0xA0, 0x01, 0x0A, 0x20, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x29, 0x12, 0x0E, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24,
0x34, 0x20, 0x24, 0x35, 0x1A, 0x6C, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31,
0x2D, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x31, 0x32, 0x5B, 0x30, 0x2D, 0x38, 0x5D,
0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x5B, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x5B,
0x31, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x31, 0x35, 0x5D, 0x29, 0x7C, 0x39,
0x30, 0x36, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x33, 0x5D, 0x5B, 0x31,
0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x38, 0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A,
0x32, 0x5B, 0x34, 0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x2D, 0x39, 0x5D,
0x7C, 0x5B, 0x35, 0x37, 0x39, 0x5D, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x5B,
0x36, 0x38, 0x5D, 0x5B, 0x31, 0x2D, 0x38, 0x5D, 0x29, 0x31, 0x9A, 0x01, 0x9B,
0x01, 0x0A, 0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x2C, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24,
0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x6C, 0x32, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x31, 0x2D, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x31, 0x32, 0x5B, 0x30,
0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x5B, 0x33, 0x35, 0x2D,
0x39, 0x5D, 0x5B, 0x31, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x31, 0x35, 0x5D,
0x29, 0x7C, 0x39, 0x30, 0x36, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x33,
0x5D, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x38, 0x5D, 0x29, 0x7C,
0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x34, 0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32,
0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x35, 0x37, 0x39, 0x5D, 0x5B, 0x31, 0x2D, 0x39,
0x5D, 0x7C, 0x5B, 0x36, 0x38, 0x5D, 0x5B, 0x31, 0x2D, 0x38, 0x5D, 0x29, 0x31,
0x9A, 0x01, 0xF6, 0x05, 0x0A, 0x17, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x31, 0x2C,
0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x1A, 0xD0, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x34, 0x2D, 0x36, 0x5D,
0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C,
0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D,
0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A,
0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x7C,
0x32, 0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32,
0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x2D,
0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B,
0x31, 0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31,
0x33, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x38, 0x5D, 0x7C,
0x39, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x35, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38,
0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x7C, 0x37, 0x5B, 0x31,
0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x35, 0x36, 0x38,
0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x34, 0x38,
0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36,
0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x39, 0x5D,
0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31,
0x33, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D,
0x37, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x7C, 0x36, 0x5B, 0x31,
0x2D, 0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x7C, 0x38,
0x28, 0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37, 0x5B, 0x31, 0x34, 0x36,
0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28,
0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x7C, 0x32, 0x5B,
0x31, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x37,
0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x31,
0x33, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37, 0x5D, 0x29, 0x29, 0x7C,
0x34, 0x31, 0x7C, 0x5B, 0x35, 0x36, 0x5D, 0x30, 0x7C, 0x37, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x2D, 0x35,
0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x33, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x38, 0x28,
0x3F, 0x3A, 0x33, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C,
0x35, 0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x32, 0x2D, 0x38,
0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x29, 0x7C, 0x39,
0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x30,
0x32, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A, 0x34, 0x35,
0x7C, 0x38, 0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x33, 0x28,
0x3F, 0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34, 0x36, 0x38,
0x5D, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x37,
0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29, 0x5B,
0x31, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x36, 0x7C, 0x37,
0x31, 0x7C, 0x38, 0x30, 0x29, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x28,
0x3F, 0x3A, 0x33, 0x5B, 0x34, 0x36, 0x5D, 0x7C, 0x34, 0x36, 0x7C, 0x35, 0x5B,
0x34, 0x39, 0x5D, 0x29, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x5D, 0x7C, 0x28, 0x3F,
0x3A, 0x32, 0x32, 0x7C, 0x34, 0x37, 0x7C, 0x38, 0x31, 0x29, 0x5B, 0x30, 0x32,
0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x35, 0x37, 0x39, 0x5D, 0x33,
0x5B, 0x31, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x38, 0x7C,
0x34, 0x39, 0x7C, 0x35, 0x5B, 0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x37,
0x5D, 0x7C, 0x39, 0x5B, 0x35, 0x38, 0x39, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D,
0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x35, 0x36, 0x39, 0x5D, 0x7C,
0x34, 0x5B, 0x32, 0x2D, 0x34, 0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x32, 0x34,
0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x5D, 0x7C,
0x37, 0x33, 0x7C, 0x38, 0x32, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29,
0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x34, 0x7C,
0x5B, 0x34, 0x39, 0x5D, 0x36, 0x7C, 0x35, 0x5B, 0x33, 0x38, 0x5D, 0x7C, 0x36,
0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x38,
0x37, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x38, 0x5D, 0x9A, 0x01, 0xF5, 0x05, 0x0A,
0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x20, 0x24, 0x34, 0x1A, 0xC7, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x34,
0x2D, 0x36, 0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35, 0x2D,
0x39, 0x5D, 0x7C, 0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35,
0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x33,
0x28, 0x3F, 0x3A, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34, 0x36,
0x37, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x33,
0x5B, 0x31, 0x32, 0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32,
0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35, 0x36, 0x5D,
0x7C, 0x39, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F, 0x3A,
0x32, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35, 0x37,
0x38, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x35,
0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x2D,
0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x7C,
0x37, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33,
0x35, 0x36, 0x38, 0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31,
0x2D, 0x34, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36,
0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35,
0x37, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D, 0x7C,
0x39, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32,
0x5B, 0x31, 0x2D, 0x37, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x7C,
0x36, 0x5B, 0x31, 0x2D, 0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34, 0x5D,
0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37, 0x5B,
0x31, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x29,
0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37, 0x39, 0x5D,
0x7C, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33,
0x34, 0x36, 0x37, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C,
0x37, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37, 0x5D,
0x29, 0x29, 0x7C, 0x34, 0x31, 0x7C, 0x36, 0x36, 0x5B, 0x32, 0x2D, 0x39, 0x5D,
0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x31, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x38,
0x5B, 0x30, 0x32, 0x2D, 0x35, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x33, 0x2D, 0x37,
0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x30, 0x32, 0x2D, 0x34,
0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x35, 0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D, 0x7C,
0x36, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x34, 0x2D,
0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x37, 0x2D, 0x39,
0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x29, 0x7C,
0x5B, 0x35, 0x2D, 0x38, 0x5D, 0x30, 0x7C, 0x28, 0x3F, 0x3A, 0x34, 0x35, 0x7C,
0x38, 0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x33, 0x28, 0x3F,
0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34, 0x36, 0x38, 0x5D,
0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x37, 0x5D,
0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29, 0x5B, 0x31,
0x33, 0x35, 0x36, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x34, 0x36,
0x5D, 0x7C, 0x34, 0x36, 0x7C, 0x35, 0x5B, 0x34, 0x39, 0x5D, 0x29, 0x5B, 0x31,
0x32, 0x34, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x32, 0x7C, 0x34, 0x37,
0x7C, 0x38, 0x31, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33,
0x5B, 0x34, 0x35, 0x37, 0x39, 0x5D, 0x33, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x5D,
0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x38, 0x7C, 0x34, 0x39, 0x7C, 0x35, 0x5B, 0x37,
0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x35, 0x38,
0x39, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A,
0x32, 0x5B, 0x35, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x2D, 0x34, 0x38,
0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B,
0x31, 0x2D, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x37, 0x33, 0x7C, 0x38, 0x32, 0x7C,
0x39, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D,
0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x34, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x36, 0x7C,
0x35, 0x5B, 0x33, 0x38, 0x5D, 0x7C, 0x36, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x37,
0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x38, 0x37, 0x29, 0x5B, 0x30, 0x32, 0x2D,
0x38, 0x5D, 0x9A, 0x01, 0xFC, 0x05, 0x0A, 0x20, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x12, 0x0E, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24,
0x34, 0x20, 0x24, 0x35, 0x1A, 0xC7, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B,
0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35,
0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33,
0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C,
0x33, 0x28, 0x3F, 0x3A, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34,
0x36, 0x37, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C,
0x33, 0x5B, 0x31, 0x32, 0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31,
0x32, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35, 0x36,
0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F,
0x3A, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35,
0x37, 0x38, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C,
0x35, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31,
0x2D, 0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D,
0x7C, 0x37, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31,
0x33, 0x35, 0x36, 0x38, 0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B,
0x31, 0x2D, 0x34, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D,
0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32,
0x35, 0x37, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D,
0x7C, 0x39, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A,
0x32, 0x5B, 0x31, 0x2D, 0x37, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D,
0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34,
0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37,
0x5B, 0x31, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D,
0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37, 0x39,
0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31,
0x33, 0x34, 0x36, 0x37, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D,
0x7C, 0x37, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37,
0x5D, 0x29, 0x29, 0x7C, 0x34, 0x31, 0x7C, 0x36, 0x36, 0x5B, 0x32, 0x2D, 0x39,
0x5D, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x31, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C,
0x38, 0x5B, 0x30, 0x32, 0x2D, 0x35, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x33, 0x2D,
0x37, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x30, 0x32, 0x2D,
0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x35, 0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D,
0x7C, 0x36, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x34,
0x2D, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x37, 0x2D,
0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x29,
0x7C, 0x5B, 0x35, 0x2D, 0x38, 0x5D, 0x30, 0x7C, 0x28, 0x3F, 0x3A, 0x34, 0x35,
0x7C, 0x38, 0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x33, 0x28,
0x3F, 0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34, 0x36, 0x38,
0x5D, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x37,
0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29, 0x5B,
0x31, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x34,
0x36, 0x5D, 0x7C, 0x34, 0x36, 0x7C, 0x35, 0x5B, 0x34, 0x39, 0x5D, 0x29, 0x5B,
0x31, 0x32, 0x34, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x32, 0x7C, 0x34,
0x37, 0x7C, 0x38, 0x31, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x39, 0x5D, 0x7C,
0x33, 0x5B, 0x34, 0x35, 0x37, 0x39, 0x5D, 0x33, 0x5B, 0x31, 0x33, 0x35, 0x37,
0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x38, 0x7C, 0x34, 0x39, 0x7C, 0x35, 0x5B,
0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x35,
0x38, 0x39, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x5D, 0x7C, 0x28, 0x3F,
0x3A, 0x32, 0x5B, 0x35, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x2D, 0x34,
0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36,
0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x37, 0x33, 0x7C, 0x38, 0x32,
0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x39,
0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x34, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x36,
0x7C, 0x35, 0x5B, 0x33, 0x38, 0x5D, 0x7C, 0x36, 0x5B, 0x34, 0x37, 0x5D, 0x7C,
0x37, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x38, 0x37, 0x29, 0x5B, 0x30, 0x32,
0x2D, 0x38, 0x5D, 0x9A, 0x01, 0x8F, 0x06, 0x0A, 0x27, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x11, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x20,
0x24, 0x36, 0x1A, 0xD0, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x34, 0x2D,
0x36, 0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35, 0x2D, 0x39,
0x5D, 0x7C, 0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x2D,
0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x33, 0x28,
0x3F, 0x3A, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34, 0x36, 0x37,
0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B,
0x31, 0x32, 0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35,
0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35, 0x36, 0x5D, 0x7C,
0x39, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x32,
0x5B, 0x31, 0x33, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x38,
0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x35, 0x28,
0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x2D, 0x33,
0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x7C, 0x37,
0x5B, 0x31, 0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x35,
0x36, 0x38, 0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D,
0x34, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D,
0x7C, 0x36, 0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37,
0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x39,
0x5B, 0x31, 0x33, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B,
0x31, 0x2D, 0x37, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x7C, 0x36,
0x5B, 0x31, 0x2D, 0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29,
0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37, 0x5B, 0x31,
0x34, 0x36, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x29, 0x7C,
0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x7C,
0x32, 0x5B, 0x31, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x34,
0x36, 0x37, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x37,
0x5B, 0x31, 0x33, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37, 0x5D, 0x29,
0x29, 0x7C, 0x34, 0x31, 0x7C, 0x5B, 0x35, 0x36, 0x5D, 0x30, 0x7C, 0x37, 0x28,
0x3F, 0x3A, 0x30, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32,
0x2D, 0x35, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x33, 0x2D, 0x37, 0x5D, 0x29, 0x7C,
0x38, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39,
0x5D, 0x7C, 0x35, 0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x32,
0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x29,
0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37,
0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A,
0x34, 0x35, 0x7C, 0x38, 0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C,
0x33, 0x28, 0x3F, 0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34,
0x36, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33,
0x34, 0x37, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30,
0x29, 0x5B, 0x31, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x36,
0x7C, 0x37, 0x31, 0x7C, 0x38, 0x30, 0x29, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C,
0x33, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x34, 0x36, 0x5D, 0x7C, 0x34, 0x36, 0x7C,
0x35, 0x5B, 0x34, 0x39, 0x5D, 0x29, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x5D, 0x7C,
0x28, 0x3F, 0x3A, 0x32, 0x32, 0x7C, 0x34, 0x37, 0x7C, 0x38, 0x31, 0x29, 0x5B,
0x30, 0x32, 0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x35, 0x37, 0x39,
0x5D, 0x33, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32,
0x38, 0x7C, 0x34, 0x39, 0x7C, 0x35, 0x5B, 0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B,
0x32, 0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x35, 0x38, 0x39, 0x5D, 0x29, 0x5B, 0x30,
0x32, 0x2D, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x35, 0x36, 0x39,
0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x2D, 0x34, 0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x31,
0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38,
0x5D, 0x7C, 0x37, 0x33, 0x7C, 0x38, 0x32, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x34,
0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32,
0x34, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x36, 0x7C, 0x35, 0x5B, 0x33, 0x38, 0x5D,
0x7C, 0x36, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x34, 0x2D, 0x36, 0x5D,
0x7C, 0x38, 0x37, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x38, 0x5D, 0x9A, 0x01, 0x8C,
0x06, 0x0A, 0x2A, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x11, 0x24, 0x31, 0x20, 0x24, 0x32,
0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x20, 0x24, 0x36, 0x1A,
0xCA, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C,
0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x32,
0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C,
0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33,
0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x32,
0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34,
0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x2D, 0x39,
0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31,
0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x33,
0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x39,
0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x30,
0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x39,
0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x33,
0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x35, 0x36, 0x38, 0x5D,
0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x34, 0x38, 0x39,
0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B,
0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x39, 0x5D, 0x7C,
0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33,
0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x37,
0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D,
0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x7C, 0x38, 0x28,
0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37, 0x5B, 0x31, 0x34, 0x36, 0x37,
0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F,
0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x31,
0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x37, 0x39,
0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x33,
0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37, 0x5D, 0x29, 0x29, 0x7C, 0x34,
0x31, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x38, 0x5B, 0x30, 0x32, 0x2D, 0x35, 0x5D,
0x7C, 0x39, 0x5B, 0x30, 0x33, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F,
0x3A, 0x33, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x35,
0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x32, 0x2D, 0x38, 0x5D,
0x7C, 0x38, 0x5B, 0x30, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28,
0x3F, 0x3A, 0x30, 0x5B, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x32,
0x2D, 0x34, 0x36, 0x37, 0x5D, 0x29, 0x7C, 0x5B, 0x35, 0x2D, 0x37, 0x5D, 0x30,
0x7C, 0x28, 0x3F, 0x3A, 0x34, 0x35, 0x7C, 0x38, 0x34, 0x29, 0x5B, 0x30, 0x32,
0x2D, 0x36, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39,
0x29, 0x5B, 0x31, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D,
0x34, 0x5B, 0x31, 0x33, 0x34, 0x37, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34,
0x37, 0x7C, 0x36, 0x30, 0x29, 0x5B, 0x31, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x28,
0x3F, 0x3A, 0x36, 0x36, 0x7C, 0x37, 0x31, 0x7C, 0x38, 0x30, 0x29, 0x5B, 0x32,
0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x34, 0x36, 0x5D,
0x7C, 0x34, 0x36, 0x7C, 0x35, 0x5B, 0x34, 0x39, 0x5D, 0x29, 0x5B, 0x31, 0x32,
0x34, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x32, 0x7C, 0x34, 0x37, 0x7C,
0x38, 0x31, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33, 0x5B,
0x34, 0x35, 0x37, 0x39, 0x5D, 0x33, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x5D, 0x7C,
0x28, 0x3F, 0x3A, 0x32, 0x38, 0x7C, 0x34, 0x39, 0x7C, 0x35, 0x5B, 0x37, 0x39,
0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x35, 0x38, 0x39,
0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32,
0x5B, 0x35, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x2D, 0x34, 0x38, 0x5D,
0x7C, 0x35, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31,
0x2D, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x37, 0x33, 0x7C, 0x38, 0x32, 0x7C, 0x39,
0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C,
0x28, 0x3F, 0x3A, 0x32, 0x34, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x36, 0x7C, 0x35,
0x5B, 0x33, 0x38, 0x5D, 0x7C, 0x36, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x37, 0x5B,
0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x38, 0x37, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x38,
0x5D, 0x9A, 0x01, 0xF6, 0x05, 0x0A, 0x17, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x31,
0x2C, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x1A, 0xD0, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x34, 0x2D, 0x36,
0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35, 0x2D, 0x39, 0x5D,
0x7C, 0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x2D, 0x39,
0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F,
0x3A, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34, 0x36, 0x37, 0x5D,
0x7C, 0x32, 0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31,
0x32, 0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37,
0x2D, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35, 0x36, 0x5D, 0x7C, 0x39,
0x5B, 0x31, 0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x32, 0x5B,
0x31, 0x33, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x38, 0x5D,
0x7C, 0x39, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x35, 0x28, 0x3F,
0x3A, 0x30, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x2D, 0x33, 0x35,
0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x7C, 0x37, 0x5B,
0x31, 0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x35, 0x36,
0x38, 0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x34,
0x38, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C,
0x36, 0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x39,
0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B,
0x31, 0x33, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31,
0x2D, 0x37, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x7C, 0x36, 0x5B,
0x31, 0x2D, 0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x7C,
0x38, 0x28, 0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37, 0x5B, 0x31, 0x34,
0x36, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x29, 0x7C, 0x39,
0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x7C, 0x32,
0x5B, 0x31, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x36,
0x37, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B,
0x31, 0x33, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37, 0x5D, 0x29, 0x29,
0x7C, 0x34, 0x31, 0x7C, 0x5B, 0x35, 0x36, 0x5D, 0x30, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x30, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x2D,
0x35, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x33, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x38,
0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D,
0x7C, 0x35, 0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x32, 0x2D,
0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x29, 0x7C,
0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B,
0x30, 0x32, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A, 0x34,
0x35, 0x7C, 0x38, 0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x33,
0x28, 0x3F, 0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34, 0x36,
0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33, 0x34,
0x37, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29,
0x5B, 0x31, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x36, 0x7C,
0x37, 0x31, 0x7C, 0x38, 0x30, 0x29, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x33,
0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x34, 0x36, 0x5D, 0x7C, 0x34, 0x36, 0x7C, 0x35,
0x5B, 0x34, 0x39, 0x5D, 0x29, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x5D, 0x7C, 0x28,
0x3F, 0x3A, 0x32, 0x32, 0x7C, 0x34, 0x37, 0x7C, 0x38, 0x31, 0x29, 0x5B, 0x30,
0x32, 0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x35, 0x37, 0x39, 0x5D,
0x33, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x38,
0x7C, 0x34, 0x39, 0x7C, 0x35, 0x5B, 0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32,
0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x35, 0x38, 0x39, 0x5D, 0x29, 0x5B, 0x30, 0x32,
0x2D, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x35, 0x36, 0x39, 0x5D,
0x7C, 0x34, 0x5B, 0x32, 0x2D, 0x34, 0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x32,
0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x5D,
0x7C, 0x37, 0x33, 0x7C, 0x38, 0x32, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x34, 0x5D,
0x29, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x34,
0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x36, 0x7C, 0x35, 0x5B, 0x33, 0x38, 0x5D, 0x7C,
0x36, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C,
0x38, 0x37, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x38, 0x5D, 0x9A, 0x01, 0xF8, 0x05,
0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x20, 0x24, 0x34, 0x1A, 0xCA, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B,
0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35,
0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33,
0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C,
0x33, 0x28, 0x3F, 0x3A, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34,
0x36, 0x37, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C,
0x33, 0x5B, 0x31, 0x32, 0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31,
0x32, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35, 0x36,
0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F,
0x3A, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35,
0x37, 0x38, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C,
0x35, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31,
0x2D, 0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D,
0x7C, 0x37, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31,
0x33, 0x35, 0x36, 0x38, 0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B,
0x31, 0x2D, 0x34, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D,
0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32,
0x35, 0x37, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D,
0x7C, 0x39, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A,
0x32, 0x5B, 0x31, 0x2D, 0x37, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D,
0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34,
0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37,
0x5B, 0x31, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D,
0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37, 0x39,
0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31,
0x33, 0x34, 0x36, 0x37, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D,
0x7C, 0x37, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37,
0x5D, 0x29, 0x29, 0x7C, 0x34, 0x5B, 0x31, 0x39, 0x5D, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x38, 0x5B, 0x30, 0x32, 0x2D, 0x35, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x33,
0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x30, 0x32,
0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x35, 0x5B, 0x30, 0x33, 0x2D, 0x39,
0x5D, 0x7C, 0x36, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32,
0x34, 0x2D, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x37,
0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x37, 0x5D,
0x29, 0x7C, 0x5B, 0x35, 0x2D, 0x37, 0x5D, 0x30, 0x7C, 0x28, 0x3F, 0x3A, 0x34,
0x35, 0x7C, 0x38, 0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x33,
0x28, 0x3F, 0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34, 0x36,
0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33, 0x34,
0x37, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29,
0x5B, 0x31, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x36, 0x7C,
0x37, 0x31, 0x7C, 0x38, 0x30, 0x29, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x33,
0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x34, 0x36, 0x5D, 0x7C, 0x34, 0x36, 0x7C, 0x35,
0x5B, 0x34, 0x39, 0x5D, 0x29, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x5D, 0x7C, 0x28,
0x3F, 0x3A, 0x32, 0x32, 0x7C, 0x34, 0x37, 0x7C, 0x38, 0x31, 0x29, 0x5B, 0x30,
0x32, 0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x35, 0x37, 0x39, 0x5D,
0x33, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x38,
0x7C, 0x35, 0x5B, 0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x37, 0x5D, 0x7C,
0x39, 0x5B, 0x35, 0x38, 0x39, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x5D,
0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x35, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B,
0x32, 0x2D, 0x34, 0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36,
0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x37, 0x33,
0x7C, 0x38, 0x32, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x5B, 0x30,
0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x34, 0x7C, 0x5B, 0x34,
0x39, 0x5D, 0x36, 0x7C, 0x35, 0x5B, 0x33, 0x38, 0x5D, 0x7C, 0x36, 0x5B, 0x34,
0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x38, 0x37, 0x29,
0x5B, 0x30, 0x32, 0x2D, 0x38, 0x5D, 0x9A, 0x01, 0x87, 0x06, 0x0A, 0x1C, 0x28,
0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24,
0x34, 0x1A, 0xD9, 0x05, 0x31, 0x35, 0x5B, 0x31, 0x32, 0x37, 0x39, 0x5D, 0x7C,
0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x31, 0x28,
0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x39, 0x29,
0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B,
0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x28, 0x3F,
0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x32, 0x5B, 0x31,
0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x35, 0x37,
0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C,
0x38, 0x5B, 0x31, 0x32, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x34, 0x35,
0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x5D,
0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x39, 0x5B, 0x31,
0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31,
0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C,
0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x33, 0x34, 0x36,
0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x35, 0x36, 0x38, 0x5D, 0x29, 0x7C,
0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x34, 0x38, 0x39, 0x5D, 0x7C,
0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x33,
0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x39, 0x5D, 0x7C, 0x38, 0x5B,
0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x35, 0x5D,
0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x37, 0x5D, 0x7C,
0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x35, 0x5D,
0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A,
0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37, 0x5B, 0x31, 0x34, 0x36, 0x37, 0x5D, 0x7C,
0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30,
0x5B, 0x31, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x33, 0x35,
0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x37, 0x39, 0x5D, 0x7C,
0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x33, 0x36, 0x5D,
0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37, 0x5D, 0x29, 0x29, 0x7C, 0x34, 0x31, 0x7C,
0x5B, 0x35, 0x36, 0x5D, 0x30, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x32,
0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x2D, 0x35, 0x5D, 0x7C, 0x39,
0x5B, 0x30, 0x33, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x33,
0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x35, 0x5B, 0x30,
0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38,
0x5B, 0x30, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x32, 0x2D, 0x34,
0x36, 0x37, 0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A, 0x34, 0x35, 0x7C, 0x38, 0x34,
0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x38,
0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x33,
0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x37, 0x5D, 0x7C, 0x33,
0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29, 0x5B, 0x31, 0x33, 0x35,
0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x36, 0x7C, 0x37, 0x31, 0x7C, 0x38,
0x30, 0x29, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33,
0x5B, 0x34, 0x36, 0x5D, 0x7C, 0x34, 0x36, 0x7C, 0x35, 0x5B, 0x34, 0x39, 0x5D,
0x29, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x32,
0x7C, 0x34, 0x37, 0x7C, 0x38, 0x31, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x39,
0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x35, 0x37, 0x39, 0x5D, 0x33, 0x5B, 0x31, 0x33,
0x35, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x38, 0x7C, 0x34, 0x39, 0x7C,
0x35, 0x5B, 0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x37, 0x5D, 0x7C, 0x39,
0x5B, 0x35, 0x38, 0x39, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x5D, 0x7C,
0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x35, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32,
0x2D, 0x34, 0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D,
0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x37, 0x33, 0x7C,
0x38, 0x32, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x5B, 0x30, 0x32,
0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x34, 0x7C, 0x5B, 0x34, 0x39,
0x5D, 0x36, 0x7C, 0x35, 0x5B, 0x33, 0x38, 0x5D, 0x7C, 0x36, 0x5B, 0x34, 0x37,
0x5D, 0x7C, 0x37, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x38, 0x37, 0x29, 0x5B,
0x30, 0x32, 0x2D, 0x38, 0x5D, 0x9A, 0x01, 0xFE, 0x05, 0x0A, 0x1C, 0x28, 0x5C,
0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34,
0x1A, 0xD0, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x34, 0x2D, 0x36, 0x5D,
0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C,
0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D,
0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x33, 0x28, 0x3F, 0x3A,
0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x7C,
0x32, 0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32,
0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x2D,
0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B,
0x31, 0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31,
0x33, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x38, 0x5D, 0x7C,
0x39, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x35, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38,
0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x7C, 0x37, 0x5B, 0x31,
0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x35, 0x36, 0x38,
0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x34, 0x38,
0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36,
0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x32, 0x35, 0x37, 0x39, 0x5D,
0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31,
0x33, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x2D,
0x37, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x7C, 0x36, 0x5B, 0x31,
0x2D, 0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29, 0x7C, 0x38,
0x28, 0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C, 0x37, 0x5B, 0x31, 0x34, 0x36,
0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28,
0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x7C, 0x32, 0x5B,
0x31, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x37,
0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x31,
0x33, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34, 0x37, 0x5D, 0x29, 0x29, 0x7C,
0x34, 0x31, 0x7C, 0x5B, 0x35, 0x36, 0x5D, 0x30, 0x7C, 0x37, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x2D, 0x35,
0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x33, 0x2D, 0x37, 0x5D, 0x29, 0x7C, 0x38, 0x28,
0x3F, 0x3A, 0x33, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C,
0x35, 0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x32, 0x2D, 0x38,
0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x29, 0x7C, 0x39,
0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x30,
0x32, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x29, 0x7C, 0x28, 0x3F, 0x3A, 0x34, 0x35,
0x7C, 0x38, 0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x5D, 0x7C, 0x33, 0x28,
0x3F, 0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39, 0x29, 0x5B, 0x31, 0x34, 0x36, 0x38,
0x5D, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x31, 0x33, 0x34, 0x37,
0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29, 0x5B,
0x31, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x36, 0x7C, 0x37,
0x31, 0x7C, 0x38, 0x30, 0x29, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x28,
0x3F, 0x3A, 0x33, 0x5B, 0x34, 0x36, 0x5D, 0x7C, 0x34, 0x36, 0x7C, 0x35, 0x5B,
0x34, 0x39, 0x5D, 0x29, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x5D, 0x7C, 0x28, 0x3F,
0x3A, 0x32, 0x32, 0x7C, 0x34, 0x37, 0x7C, 0x38, 0x31, 0x29, 0x5B, 0x30, 0x32,
0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x35, 0x37, 0x39, 0x5D, 0x33,
0x5B, 0x31, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x38, 0x7C,
0x34, 0x39, 0x7C, 0x35, 0x5B, 0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x37,
0x5D, 0x7C, 0x39, 0x5B, 0x35, 0x38, 0x39, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D,
0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x35, 0x36, 0x39, 0x5D, 0x7C,
0x34, 0x5B, 0x32, 0x2D, 0x34, 0x38, 0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x32, 0x34,
0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x38, 0x5D, 0x7C,
0x37, 0x33, 0x7C, 0x38, 0x32, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x34, 0x5D, 0x29,
0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x34, 0x7C,
0x5B, 0x34, 0x39, 0x5D, 0x36, 0x7C, 0x35, 0x5B, 0x33, 0x38, 0x5D, 0x7C, 0x36,
0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x38,
0x37, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x38, 0x5D, 0x9A, 0x01, 0x80, 0x06, 0x0A,
0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x2C, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0xD0, 0x05, 0x32, 0x28, 0x3F, 0x3A, 0x30,
0x5B, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33,
0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x39, 0x29, 0x7C, 0x33, 0x5B, 0x30, 0x32,
0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x2D, 0x37, 0x5D, 0x29,
0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D,
0x34, 0x36, 0x37, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x32, 0x37, 0x2D, 0x39, 0x5D,
0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x37, 0x5B,
0x31, 0x32, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x35,
0x36, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x34, 0x35, 0x5D, 0x29, 0x7C, 0x34, 0x28,
0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x33,
0x35, 0x37, 0x38, 0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x5D, 0x29,
0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x32, 0x5B,
0x31, 0x2D, 0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x34,
0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B,
0x31, 0x33, 0x35, 0x36, 0x38, 0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32,
0x5B, 0x31, 0x2D, 0x34, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x34,
0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31,
0x32, 0x35, 0x37, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x36,
0x5D, 0x7C, 0x39, 0x5B, 0x31, 0x33, 0x35, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x32, 0x5B, 0x31, 0x2D, 0x37, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x34, 0x35,
0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x35, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D,
0x34, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32, 0x31, 0x7C, 0x36, 0x7C,
0x37, 0x5B, 0x31, 0x34, 0x36, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x33, 0x36,
0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x34, 0x37,
0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x31, 0x33, 0x35, 0x38, 0x5D, 0x7C, 0x34, 0x5B,
0x31, 0x33, 0x34, 0x36, 0x37, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D, 0x39,
0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x34,
0x37, 0x5D, 0x29, 0x29, 0x7C, 0x34, 0x31, 0x7C, 0x5B, 0x35, 0x36, 0x5D, 0x30,
0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38,
0x5B, 0x30, 0x32, 0x2D, 0x35, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x33, 0x2D, 0x37,
0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x30, 0x32, 0x2D, 0x34,
0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x35, 0x5B, 0x30, 0x33, 0x2D, 0x39, 0x5D, 0x7C,
0x36, 0x5B, 0x32, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x34, 0x2D,
0x36, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x37, 0x2D, 0x39,
0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x37, 0x5D, 0x29, 0x7C,
0x28, 0x3F, 0x3A, 0x34, 0x35, 0x7C, 0x38, 0x34, 0x29, 0x5B, 0x30, 0x32, 0x2D,
0x36, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x38, 0x33, 0x7C, 0x39, 0x39, 0x29,
0x5B, 0x31, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34,
0x5B, 0x31, 0x33, 0x34, 0x37, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37,
0x7C, 0x36, 0x30, 0x29, 0x5B, 0x31, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x28, 0x3F,
0x3A, 0x36, 0x36, 0x7C, 0x37, 0x31, 0x7C, 0x38, 0x30, 0x29, 0x5B, 0x32, 0x2D,
0x39, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x34, 0x36, 0x5D, 0x7C,
0x34, 0x36, 0x7C, 0x35, 0x5B, 0x34, 0x39, 0x5D, 0x29, 0x5B, 0x31, 0x32, 0x34,
0x36, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x32, 0x7C, 0x34, 0x37, 0x7C, 0x38,
0x31, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34,
0x35, 0x37, 0x39, 0x5D, 0x33, 0x5B, 0x31, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x28,
0x3F, 0x3A, 0x32, 0x38, 0x7C, 0x34, 0x39, 0x7C, 0x35, 0x5B, 0x37, 0x39, 0x5D,
0x7C, 0x37, 0x5B, 0x32, 0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x35, 0x38, 0x39, 0x5D,
0x29, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B,
0x35, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x2D, 0x34, 0x38, 0x5D, 0x7C,
0x35, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x2D,
0x33, 0x35, 0x38, 0x5D, 0x7C, 0x37, 0x33, 0x7C, 0x38, 0x32, 0x7C, 0x39, 0x5B,
0x31, 0x2D, 0x34, 0x5D, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x28,
0x3F, 0x3A, 0x32, 0x34, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x36, 0x7C, 0x35, 0x5B,
0x33, 0x38, 0x5D, 0x7C, 0x36, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x34,
0x2D, 0x36, 0x5D, 0x7C, 0x38, 0x37, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x38, 0x5D,
0x9A, 0x01, 0xA1, 0x03, 0x0A, 0x17, 0x28, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x2C,
0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x1A, 0xFB, 0x02, 0x33, 0x28, 0x3F, 0x3A, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B,
0x35, 0x38, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x30, 0x33, 0x5D, 0x7C, 0x33, 0x5B,
0x33, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x36,
0x5B, 0x30, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x33, 0x34, 0x36,
0x5D, 0x7C, 0x38, 0x5B, 0x33, 0x34, 0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x32, 0x33,
0x36, 0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x34, 0x28, 0x3F, 0x3A, 0x34, 0x5B, 0x32,
0x34, 0x36, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x33, 0x35, 0x37, 0x39, 0x5D,
0x7C, 0x39, 0x5B, 0x30, 0x32, 0x35, 0x37, 0x5D, 0x29, 0x7C, 0x35, 0x28, 0x3F,
0x3A, 0x30, 0x5B, 0x32, 0x33, 0x35, 0x5D, 0x7C, 0x32, 0x5B, 0x30, 0x34, 0x36,
0x5D, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x5B, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x36,
0x5B, 0x30, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x35, 0x37, 0x39, 0x5D, 0x7C,
0x38, 0x5B, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A,
0x32, 0x5B, 0x30, 0x35, 0x5D, 0x7C, 0x33, 0x5B, 0x33, 0x37, 0x5D, 0x7C, 0x36,
0x5B, 0x30, 0x32, 0x34, 0x35, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x33, 0x34,
0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x32,
0x34, 0x36, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x30, 0x39,
0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x33, 0x36, 0x5D, 0x7C, 0x36, 0x30, 0x7C, 0x37,
0x35, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x30, 0x32, 0x33, 0x39,
0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x37, 0x39, 0x5D, 0x7C, 0x37,
0x5B, 0x32, 0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x32, 0x34, 0x35,
0x37, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x30, 0x33, 0x35,
0x36, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x32, 0x34, 0x36, 0x38, 0x39, 0x5D, 0x7C,
0x34, 0x5B, 0x30, 0x32, 0x35, 0x38, 0x5D, 0x7C, 0x36, 0x30, 0x7C, 0x37, 0x5B,
0x32, 0x34, 0x35, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x32, 0x33, 0x35, 0x36, 0x38,
0x5D, 0x7C, 0x39, 0x5B, 0x32, 0x33, 0x35, 0x37, 0x39, 0x5D, 0x29, 0x29, 0x7C,
0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x32, 0x35, 0x36, 0x38, 0x5D, 0x7C,
0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36, 0x30, 0x29, 0x5B, 0x32, 0x34,
0x37, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x39, 0x5D, 0x32, 0x5B, 0x30, 0x32,
0x34, 0x36, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x35, 0x37, 0x5D, 0x33, 0x5B,
0x32, 0x34, 0x36, 0x38, 0x5D, 0x9A, 0x01, 0xA1, 0x03, 0x0A, 0x17, 0x28, 0x5C,
0x64, 0x7B, 0x35, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x33, 0x2C, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0xFB, 0x02, 0x33, 0x28, 0x3F, 0x3A, 0x33,
0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x30,
0x33, 0x5D, 0x7C, 0x33, 0x5B, 0x33, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x33,
0x35, 0x37, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x37,
0x5B, 0x30, 0x33, 0x34, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x33, 0x34, 0x37, 0x5D,
0x7C, 0x39, 0x5B, 0x32, 0x33, 0x36, 0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x34, 0x28,
0x3F, 0x3A, 0x34, 0x5B, 0x32, 0x34, 0x36, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x30,
0x33, 0x35, 0x37, 0x39, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x32, 0x35, 0x37, 0x5D,
0x29, 0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x32, 0x33, 0x35, 0x5D, 0x7C,
0x32, 0x5B, 0x30, 0x34, 0x36, 0x5D, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x5B, 0x33,
0x35, 0x37, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32,
0x35, 0x37, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x29,
0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x30, 0x35, 0x5D, 0x7C, 0x33, 0x5B,
0x33, 0x37, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x32, 0x34, 0x35, 0x39, 0x5D, 0x7C,
0x37, 0x5B, 0x30, 0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x34, 0x37,
0x5D, 0x7C, 0x39, 0x5B, 0x32, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x32, 0x5B, 0x30, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x33, 0x36, 0x5D,
0x7C, 0x36, 0x30, 0x7C, 0x37, 0x35, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32,
0x5B, 0x30, 0x32, 0x33, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35,
0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C,
0x38, 0x5B, 0x32, 0x34, 0x35, 0x37, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x30, 0x33, 0x35, 0x36, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x32, 0x34,
0x36, 0x38, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x32, 0x35, 0x38, 0x5D, 0x7C,
0x36, 0x30, 0x7C, 0x37, 0x5B, 0x32, 0x34, 0x35, 0x37, 0x5D, 0x7C, 0x38, 0x5B,
0x32, 0x33, 0x35, 0x36, 0x38, 0x5D, 0x7C, 0x39, 0x5B, 0x32, 0x33, 0x35, 0x37,
0x39, 0x5D, 0x29, 0x29, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x32,
0x35, 0x36, 0x38, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36,
0x30, 0x29, 0x5B, 0x32, 0x34, 0x37, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x39,
0x5D, 0x32, 0x5B, 0x30, 0x32, 0x34, 0x36, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34,
0x35, 0x37, 0x5D, 0x33, 0x5B, 0x32, 0x34, 0x36, 0x38, 0x5D, 0x9A, 0x01, 0xA9,
0x03, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0xFB, 0x02, 0x33, 0x28, 0x3F, 0x3A, 0x33,
0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x30,
0x33, 0x5D, 0x7C, 0x33, 0x5B, 0x33, 0x36, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x33,
0x35, 0x37, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x33, 0x35, 0x37, 0x5D, 0x7C, 0x37,
0x5B, 0x30, 0x33, 0x34, 0x36, 0x5D, 0x7C, 0x38, 0x5B, 0x33, 0x34, 0x37, 0x5D,
0x7C, 0x39, 0x5B, 0x32, 0x33, 0x36, 0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x34, 0x28,
0x3F, 0x3A, 0x34, 0x5B, 0x32, 0x34, 0x36, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x30,
0x33, 0x35, 0x37, 0x39, 0x5D, 0x7C, 0x39, 0x5B, 0x30, 0x32, 0x35, 0x37, 0x5D,
0x29, 0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x32, 0x33, 0x35, 0x5D, 0x7C,
0x32, 0x5B, 0x30, 0x34, 0x36, 0x5D, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x5B, 0x33,
0x35, 0x37, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32,
0x35, 0x37, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x32, 0x34, 0x37, 0x39, 0x5D, 0x29,
0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x30, 0x35, 0x5D, 0x7C, 0x33, 0x5B,
0x33, 0x37, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x32, 0x34, 0x35, 0x39, 0x5D, 0x7C,
0x37, 0x5B, 0x30, 0x33, 0x34, 0x36, 0x38, 0x5D, 0x7C, 0x38, 0x5B, 0x34, 0x37,
0x5D, 0x7C, 0x39, 0x5B, 0x32, 0x34, 0x36, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x32, 0x5B, 0x30, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x32, 0x33, 0x36, 0x5D,
0x7C, 0x36, 0x30, 0x7C, 0x37, 0x35, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x32,
0x5B, 0x30, 0x32, 0x33, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x33, 0x35,
0x37, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x33, 0x35, 0x38, 0x39, 0x5D, 0x7C,
0x38, 0x5B, 0x32, 0x34, 0x35, 0x37, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A,
0x30, 0x5B, 0x30, 0x33, 0x35, 0x36, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x32, 0x34,
0x36, 0x38, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x32, 0x35, 0x38, 0x5D, 0x7C,
0x36, 0x30, 0x7C, 0x37, 0x5B, 0x32, 0x34, 0x35, 0x37, 0x5D, 0x7C, 0x38, 0x5B,
0x32, 0x33, 0x35, 0x36, 0x38, 0x5D, 0x7C, 0x39, 0x5B, 0x32, 0x33, 0x35, 0x37,
0x39, 0x5D, 0x29, 0x29, 0x7C, 0x33, 0x5B, 0x36, 0x38, 0x5D, 0x34, 0x5B, 0x32,
0x35, 0x36, 0x38, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x34, 0x37, 0x7C, 0x36,
0x30, 0x29, 0x5B, 0x32, 0x34, 0x37, 0x38, 0x5D, 0x7C, 0x33, 0x5B, 0x34, 0x39,
0x5D, 0x32, 0x5B, 0x30, 0x32, 0x34, 0x36, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x34,
0x35, 0x37, 0x5D, 0x33, 0x5B, 0x32, 0x34, 0x36, 0x38, 0x5D, 0x9A, 0x01, 0x2B,
0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x08, 0x31, 0x35, 0x5B, 0x31,
0x32, 0x37, 0x39, 0x5D, 0x9A, 0x01, 0x2B, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B,
0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x1A, 0x08, 0x31, 0x35, 0x5B, 0x31, 0x32, 0x37, 0x39, 0x5D, 0x9A, 0x01,
0x21, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x38, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32, 0x1A, 0x08,
0x31, 0x35, 0x5B, 0x31, 0x32, 0x37, 0x39, 0x5D, 0x9A, 0x01, 0x35, 0x0A, 0x1C,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20,
0x24, 0x34, 0x1A, 0x08, 0x31, 0x35, 0x5B, 0x31, 0x32, 0x37, 0x39, 0x5D, 0x9A,
0x01, 0x33, 0x0A, 0x19, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x20, 0x24, 0x34, 0x1A, 0x09, 0x31, 0x5B, 0x36, 0x37, 0x5D, 0x7C, 0x38, 0x30,
0x30, 0x9A, 0x01, 0x38, 0x0A, 0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x2C, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x09, 0x31,
0x5B, 0x36, 0x37, 0x5D, 0x7C, 0x38, 0x30, 0x30, 0x9A, 0x01, 0x26, 0x0A, 0x15,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x03, 0x38, 0x30, 0x30, 0x9A, 0x01, 0x32,
0x0A, 0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x2C, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32,
0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x03, 0x38, 0x30, 0x30, 0x9A, 0x01,
0x32, 0x0A, 0x1E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x36, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x31, 0x2C, 0x34, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24,
0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x03, 0x38, 0x30, 0x30, 0x9A,
0x01, 0x2F, 0x0A, 0x1B, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x2C, 0x34, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x03, 0x39, 0x30, 0x30, 0x9A, 0x01, 0x2F,
0x0A, 0x1B, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x2C,
0x34, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x20, 0x24, 0x34, 0x1A, 0x03, 0x39, 0x30, 0x30, 0x9A, 0x01, 0x2D, 0x0A, 0x19,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12,
0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A,
0x03, 0x31, 0x38, 0x30, 0x9A, 0x01, 0x1E, 0x0A, 0x10, 0x28, 0x5C, 0x64, 0x7B,
0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x2C, 0x36, 0x7D, 0x29, 0x12,
0x05, 0x24, 0x31, 0x20, 0x24, 0x32, 0x1A, 0x03, 0x31, 0x38, 0x30, 0x9A, 0x01,
0x30, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x03, 0x31, 0x38, 0x30, 0x9A, 0x01, 0x1F,
0x0A, 0x11, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x34, 0x2C, 0x31, 0x30, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32,
0x1A, 0x03, 0x39, 0x30, 0x30, 0x0A, 0x81, 0x01, 0x4A, 0x00, 0x50, 0xF4, 0x02,
0x9A, 0x01, 0x21, 0x0A, 0x12, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x01, 0x36, 0x9A, 0x01, 0x29,
0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x06, 0x5B, 0x34, 0x2D, 0x37,
0x39, 0x5D, 0x9A, 0x01, 0x29, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A,
0x06, 0x5B, 0x34, 0x2D, 0x37, 0x39, 0x5D, 0x0A, 0x88, 0x01, 0x4A, 0x00, 0x50,
0x22, 0x9A, 0x01, 0x41, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x1E,
0x5B, 0x35, 0x2D, 0x37, 0x5D, 0x7C, 0x38, 0x30, 0x5B, 0x33, 0x36, 0x37, 0x5D,
0x7C, 0x39, 0x30, 0x5B, 0x31, 0x32, 0x5D, 0x7C, 0x5B, 0x38, 0x39, 0x5D, 0x5B,
0x31, 0x2D, 0x38, 0x5D, 0x9A, 0x01, 0x3D, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x10,
0x39, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x32, 0x5D, 0x7C, 0x5B, 0x31, 0x2D,
0x38, 0x5D, 0x29, 0x0A, 0xD2, 0x01, 0x4A, 0x00, 0x50, 0xE6, 0x02, 0x9A, 0x01,
0x41, 0x0A, 0x14, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x2C, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x1F, 0x5B, 0x32, 0x35, 0x36,
0x38, 0x5D, 0x5B, 0x31, 0x2D, 0x38, 0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x30,
0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x29, 0x7C,
0x39, 0x9A, 0x01, 0x44, 0x0A, 0x17, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x2C,
0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x1A, 0x1F, 0x5B, 0x31, 0x32, 0x5D, 0x30, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C,
0x34, 0x7C, 0x31, 0x5B, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x39, 0x7C, 0x35,
0x30, 0x7C, 0x37, 0x5B, 0x31, 0x35, 0x5D, 0x9A, 0x01, 0x3F, 0x0A, 0x12, 0x28,
0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x1A, 0x1F, 0x5B, 0x32, 0x35, 0x36, 0x38, 0x5D, 0x5B, 0x31, 0x2D, 0x38,
0x5D, 0x7C, 0x33, 0x28, 0x3F, 0x3A, 0x30, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C,
0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x39, 0x0A, 0x2C, 0x4A, 0x00, 0x50,
0xA7, 0x05, 0x9A, 0x01, 0x24, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A,
0x01, 0x37, 0x0A, 0xA4, 0x02, 0x4A, 0x00, 0x50, 0x2C, 0x9A, 0x01, 0x25, 0x0A,
0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x02, 0x32, 0x30, 0x9A, 0x01, 0x4C,
0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x29, 0x31, 0x28, 0x3F, 0x3A,
0x31, 0x7C, 0x5B, 0x32, 0x2D, 0x36, 0x39, 0x5D, 0x31, 0x29, 0x7C, 0x32, 0x30,
0x7C, 0x5B, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x5B, 0x31,
0x2D, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x32, 0x34, 0x29, 0x9A, 0x01,
0x2F, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x02, 0x32, 0x30, 0x9A, 0x01, 0x4D, 0x0A,
0x15, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x2A, 0x31, 0x28, 0x3F, 0x3A, 0x5B,
0x32, 0x2D, 0x36, 0x39, 0x5D, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x5B,
0x37, 0x38, 0x5D, 0x29, 0x7C, 0x33, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x5B, 0x31,
0x2D, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x32, 0x34, 0x29, 0x9A, 0x01,
0x24, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x01, 0x38, 0x0A, 0x96,
0x02, 0x4A, 0x00, 0x50, 0xE3, 0x07, 0x9A, 0x01, 0x2F, 0x0A, 0x1C, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34,
0x1A, 0x02, 0x33, 0x32, 0x9A, 0x01, 0x36, 0x0A, 0x20, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x12, 0x0E, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20,
0x24, 0x34, 0x20, 0x24, 0x35, 0x1A, 0x02, 0x33, 0x32, 0x9A, 0x01, 0x1E, 0x0A,
0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x36,
0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32, 0x1A, 0x05, 0x5B, 0x33,
0x34, 0x38, 0x5D, 0x9A, 0x01, 0x28, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x1A, 0x05, 0x5B, 0x33, 0x34, 0x38, 0x5D, 0x9A, 0x01, 0x2F, 0x0A, 0x1C, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24,
0x34, 0x1A, 0x02, 0x33, 0x32, 0x9A, 0x01, 0x25, 0x0A, 0x15, 0x28, 0x5C, 0x64,
0x7B, 0x35, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x1A, 0x02, 0x33, 0x32, 0x0A, 0x22, 0x4A, 0x00, 0x50, 0xDE, 0x02,
0x9A, 0x01, 0x1A, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32,
0x1A, 0x01, 0x32, 0x0A, 0x2C, 0x4A, 0x00, 0x50, 0x1E, 0x9A, 0x01, 0x25, 0x0A,
0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x02, 0x32, 0x31, 0x0A, 0xAA, 0x01,
0x4A, 0x00, 0x50, 0x81, 0x03, 0x9A, 0x01, 0x21, 0x0A, 0x12, 0x28, 0x5C, 0x64,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34,
0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A,
0x01, 0x31, 0x9A, 0x01, 0x2B, 0x0A, 0x19, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32,
0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x01, 0x31, 0x9A, 0x01, 0x29, 0x0A,
0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x06, 0x5B, 0x32, 0x2D, 0x36, 0x39,
0x5D, 0x9A, 0x01, 0x24, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x01,
0x36, 0x0A, 0x4C, 0x4A, 0x00, 0x50, 0x24, 0x9A, 0x01, 0x21, 0x0A, 0x12, 0x28,
0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x1A, 0x01, 0x31, 0x9A, 0x01, 0x21, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x0A, 0xAF, 0x02, 0x4A, 0x00, 0x50, 0x3E, 0x9A, 0x01, 0x31, 0x0A, 0x17,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x2C,
0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x0C, 0x32, 0x5B, 0x31, 0x32,
0x34, 0x5D, 0x7C, 0x5B, 0x33, 0x36, 0x5D, 0x31, 0x9A, 0x01, 0x2F, 0x0A, 0x15,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x0C, 0x32, 0x5B, 0x31, 0x32, 0x34, 0x5D,
0x7C, 0x5B, 0x33, 0x36, 0x5D, 0x31, 0x9A, 0x01, 0x39, 0x0A, 0x1C, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34,
0x1A, 0x0C, 0x32, 0x5B, 0x31, 0x32, 0x34, 0x5D, 0x7C, 0x5B, 0x33, 0x36, 0x5D,
0x31, 0x9A, 0x01, 0x2C, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x09,
0x38, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x9A, 0x01, 0x26, 0x0A,
0x17, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x35, 0x2C, 0x36, 0x7D, 0x29, 0x12, 0x08,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x01, 0x38, 0x9A, 0x01,
0x2E, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x01, 0x38, 0x0A, 0x39, 0x4A, 0x00, 0x50,
0xCC, 0x07, 0x9A, 0x01, 0x31, 0x0A, 0x19, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32,
0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x07, 0x5B, 0x32, 0x2D, 0x34, 0x38,
0x39, 0x5D, 0x0A, 0xA3, 0x0D, 0x4A, 0x00, 0x50, 0x5B, 0x9A, 0x01, 0x8F, 0x04,
0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x36, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0xEB, 0x03, 0x36, 0x28, 0x3F,
0x3A, 0x5B, 0x30, 0x39, 0x5D, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x32,
0x2D, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x2D, 0x33, 0x35, 0x2D, 0x39, 0x5D,
0x29, 0x7C, 0x35, 0x5B, 0x30, 0x32, 0x2D, 0x36, 0x38, 0x39, 0x5D, 0x7C, 0x36,
0x5B, 0x30, 0x32, 0x34, 0x2D, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x32, 0x34,
0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x37, 0x5D,
0x7C, 0x33, 0x5B, 0x30, 0x32, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x30,
0x2D, 0x33, 0x35, 0x36, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x5B,
0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x31, 0x5B, 0x30, 0x2D, 0x32, 0x35, 0x37,
0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x38, 0x5B, 0x30, 0x2D, 0x37, 0x39, 0x5D, 0x7C,
0x39, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x31, 0x29,
0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x30, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x31,
0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x36, 0x37, 0x5D, 0x29, 0x7C, 0x31,
0x5B, 0x30, 0x2D, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x32, 0x33,
0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x33, 0x2D, 0x35, 0x37, 0x2D,
0x39, 0x5D, 0x7C, 0x5B, 0x34, 0x35, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x32, 0x34,
0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x36, 0x39, 0x5D,
0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x2D, 0x32, 0x35, 0x2D, 0x39, 0x5D,
0x7C, 0x34, 0x5B, 0x30, 0x31, 0x34, 0x37, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x39,
0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x31, 0x5B, 0x30,
0x2D, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x29, 0x29, 0x7C, 0x39, 0x7C, 0x5B, 0x36,
0x37, 0x5D, 0x31, 0x5B, 0x30, 0x31, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F,
0x3A, 0x36, 0x37, 0x7C, 0x37, 0x32, 0x29, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x2D,
0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x33, 0x7C, 0x37, 0x35, 0x29, 0x5B,
0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x36, 0x28, 0x3F, 0x3A,
0x32, 0x39, 0x7C, 0x33, 0x35, 0x29, 0x5B, 0x30, 0x2D, 0x34, 0x36, 0x2D, 0x39,
0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x34, 0x7C, 0x28, 0x3F, 0x3A, 0x37, 0x39,
0x7C, 0x38, 0x30, 0x29, 0x37, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C,
0x28, 0x3F, 0x3A, 0x36, 0x28, 0x3F, 0x3A, 0x5B, 0x32, 0x2D, 0x34, 0x5D, 0x31,
0x7C, 0x35, 0x5B, 0x31, 0x37, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x33, 0x5D, 0x7C,
0x37, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x38, 0x30, 0x29, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x31, 0x32, 0x7C, 0x38, 0x38, 0x29, 0x29, 0x5B, 0x30, 0x31, 0x38, 0x39,
0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x31, 0x32, 0x7C, 0x37, 0x28, 0x3F, 0x3A,
0x32, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x33, 0x34, 0x5D, 0x7C,
0x34, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x35, 0x5B, 0x31, 0x35, 0x5D, 0x29, 0x7C,
0x38, 0x28, 0x3F, 0x3A, 0x31, 0x36, 0x7C, 0x32, 0x5B, 0x30, 0x31, 0x34, 0x5D,
0x7C, 0x33, 0x5B, 0x31, 0x32, 0x36, 0x5D, 0x7C, 0x36, 0x5B, 0x31, 0x33, 0x36,
0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x37, 0x38, 0x5D, 0x7C, 0x38, 0x33, 0x29, 0x29,
0x5B, 0x30, 0x31, 0x37, 0x2D, 0x39, 0x5D, 0x9A, 0x01, 0xA3, 0x04, 0x0A, 0x23,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0E, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x1A,
0xEB, 0x03, 0x36, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x39, 0x5D, 0x7C, 0x32, 0x28,
0x3F, 0x3A, 0x5B, 0x30, 0x32, 0x2D, 0x37, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x2D,
0x33, 0x35, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x35, 0x5B, 0x30, 0x32, 0x2D, 0x36,
0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x32, 0x34, 0x2D, 0x39, 0x5D, 0x7C,
0x38, 0x5B, 0x31, 0x32, 0x34, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x5B, 0x30, 0x37, 0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x35, 0x2D, 0x39,
0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x2D, 0x33, 0x35, 0x36, 0x38, 0x39, 0x5D, 0x7C,
0x36, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x31, 0x5B,
0x30, 0x2D, 0x32, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x38, 0x5B, 0x30,
0x2D, 0x37, 0x39, 0x5D, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x38, 0x39,
0x5D, 0x7C, 0x33, 0x31, 0x29, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x30, 0x28,
0x3F, 0x3A, 0x5B, 0x30, 0x31, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x36,
0x37, 0x5D, 0x29, 0x7C, 0x31, 0x5B, 0x30, 0x2D, 0x35, 0x37, 0x2D, 0x39, 0x5D,
0x7C, 0x32, 0x5B, 0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x30,
0x33, 0x2D, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x5B, 0x34, 0x35, 0x5D, 0x7C,
0x36, 0x5B, 0x30, 0x32, 0x34, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B,
0x31, 0x2D, 0x36, 0x39, 0x5D, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x2D,
0x32, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x31, 0x34, 0x37, 0x2D,
0x39, 0x5D, 0x29, 0x7C, 0x39, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x32, 0x2D, 0x39,
0x5D, 0x7C, 0x31, 0x5B, 0x30, 0x2D, 0x32, 0x37, 0x2D, 0x39, 0x5D, 0x29, 0x29,
0x7C, 0x39, 0x7C, 0x5B, 0x36, 0x37, 0x5D, 0x31, 0x5B, 0x30, 0x31, 0x33, 0x2D,
0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x37, 0x7C, 0x37, 0x32, 0x29, 0x5B,
0x30, 0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x33,
0x7C, 0x37, 0x35, 0x29, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D,
0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x32, 0x39, 0x7C, 0x33, 0x35, 0x29, 0x5B, 0x30,
0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x34, 0x7C,
0x28, 0x3F, 0x3A, 0x37, 0x39, 0x7C, 0x38, 0x30, 0x29, 0x37, 0x29, 0x5B, 0x30,
0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x28, 0x3F, 0x3A, 0x5B,
0x32, 0x2D, 0x34, 0x5D, 0x31, 0x7C, 0x35, 0x5B, 0x31, 0x37, 0x5D, 0x7C, 0x36,
0x5B, 0x31, 0x33, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x38, 0x30,
0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x31, 0x32, 0x7C, 0x38, 0x38, 0x29, 0x29,
0x5B, 0x30, 0x31, 0x38, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x36, 0x31, 0x32,
0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x33, 0x5B,
0x31, 0x33, 0x34, 0x5D, 0x7C, 0x34, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x35, 0x5B,
0x31, 0x35, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x31, 0x36, 0x7C, 0x32,
0x5B, 0x30, 0x31, 0x34, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x36, 0x5D, 0x7C,
0x36, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x37, 0x38, 0x5D,
0x7C, 0x38, 0x33, 0x29, 0x29, 0x5B, 0x30, 0x31, 0x37, 0x2D, 0x39, 0x5D, 0x9A,
0x01, 0x55, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12,
0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x32, 0x37, 0x39,
0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x31, 0x7C, 0x37,
0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x38, 0x30, 0x28, 0x3F, 0x3A,
0x5B, 0x30, 0x31, 0x35, 0x38, 0x39, 0x5D, 0x7C, 0x36, 0x5B, 0x36, 0x37, 0x5D,
0x7C, 0x37, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x29, 0x9A, 0x01, 0xC5, 0x02,
0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0xA1, 0x02, 0x37, 0x28, 0x3F,
0x3A, 0x31, 0x5B, 0x30, 0x31, 0x33, 0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x30,
0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x32, 0x35, 0x2D,
0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x2D, 0x33, 0x35, 0x36, 0x38, 0x39, 0x5D,
0x7C, 0x35, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x36,
0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x31, 0x5B, 0x30,
0x2D, 0x32, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x37, 0x7C, 0x38, 0x5B,
0x30, 0x2D, 0x37, 0x39, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x31, 0x5B,
0x30, 0x2D, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x32, 0x33, 0x35,
0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x33, 0x2D, 0x35, 0x37, 0x2D, 0x39,
0x5D, 0x7C, 0x5B, 0x34, 0x35, 0x5D, 0x7C, 0x36, 0x5B, 0x30, 0x32, 0x34, 0x35,
0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x36, 0x39, 0x5D, 0x7C,
0x38, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x2D, 0x32, 0x35, 0x2D, 0x39, 0x5D, 0x7C,
0x34, 0x5B, 0x30, 0x31, 0x34, 0x37, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x39, 0x28,
0x3F, 0x3A, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C, 0x31, 0x5B, 0x30, 0x2D,
0x32, 0x37, 0x2D, 0x39, 0x5D, 0x29, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x31,
0x32, 0x7C, 0x38, 0x38, 0x29, 0x5B, 0x30, 0x31, 0x38, 0x39, 0x5D, 0x7C, 0x28,
0x3F, 0x3A, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x34, 0x5D, 0x7C, 0x33,
0x5B, 0x31, 0x33, 0x34, 0x5D, 0x7C, 0x34, 0x5B, 0x34, 0x37, 0x5D, 0x7C, 0x35,
0x5B, 0x31, 0x35, 0x5D, 0x29, 0x7C, 0x38, 0x28, 0x3F, 0x3A, 0x31, 0x36, 0x7C,
0x32, 0x5B, 0x30, 0x31, 0x34, 0x5D, 0x7C, 0x33, 0x5B, 0x31, 0x32, 0x36, 0x5D,
0x7C, 0x36, 0x5B, 0x31, 0x33, 0x36, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x37, 0x38,
0x5D, 0x7C, 0x38, 0x33, 0x29, 0x29, 0x5B, 0x30, 0x31, 0x37, 0x2D, 0x39, 0x5D,
0x9A, 0x01, 0xC0, 0x01, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x9C,
0x01, 0x37, 0x28, 0x3F, 0x3A, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x31, 0x33,
0x2D, 0x39, 0x5D, 0x7C, 0x32, 0x5B, 0x30, 0x31, 0x38, 0x39, 0x5D, 0x29, 0x7C,
0x32, 0x5B, 0x30, 0x32, 0x33, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x33, 0x5B, 0x30,
0x32, 0x35, 0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x30, 0x2D, 0x33, 0x35, 0x36,
0x38, 0x39, 0x5D, 0x7C, 0x35, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x39,
0x5D, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x32, 0x2D, 0x39, 0x5D, 0x7C,
0x31, 0x5B, 0x30, 0x2D, 0x32, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x29, 0x7C, 0x37,
0x29, 0x7C, 0x38, 0x30, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x31, 0x35, 0x38, 0x39,
0x5D, 0x7C, 0x36, 0x5B, 0x36, 0x37, 0x5D, 0x7C, 0x37, 0x5B, 0x30, 0x32, 0x2D,
0x39, 0x5D, 0x29, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x31, 0x34, 0x5D,
0x7C, 0x33, 0x5B, 0x31, 0x33, 0x34, 0x5D, 0x7C, 0x34, 0x5B, 0x34, 0x37, 0x5D,
0x7C, 0x35, 0x5B, 0x31, 0x35, 0x5D, 0x29, 0x5B, 0x30, 0x31, 0x37, 0x2D, 0x39,
0x5D, 0x0A, 0x96, 0x01, 0x4A, 0x00, 0x50, 0x27, 0x9A, 0x01, 0x4B, 0x0A, 0x1C,
0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20,
0x24, 0x34, 0x1A, 0x1E, 0x30, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x33, 0x2D, 0x35,
0x37, 0x39, 0x5D, 0x5B, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x38, 0x5D, 0x7C, 0x38,
0x5B, 0x32, 0x33, 0x36, 0x2D, 0x38, 0x5D, 0x29, 0x9A, 0x01, 0x41, 0x0A, 0x15,
0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x1E, 0x30, 0x28, 0x3F, 0x3A, 0x5B, 0x31,
0x33, 0x2D, 0x35, 0x37, 0x39, 0x5D, 0x5B, 0x32, 0x2D, 0x34, 0x36, 0x2D, 0x38,
0x5D, 0x7C, 0x38, 0x5B, 0x32, 0x33, 0x36, 0x2D, 0x38, 0x5D, 0x29, 0x0A, 0xA7,
0x01, 0x4A, 0x00, 0x50, 0x51, 0x9A, 0x01, 0x30, 0x0A, 0x15, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x1A, 0x0D, 0x28, 0x3F, 0x3A, 0x31, 0x32, 0x7C, 0x35, 0x37, 0x7C,
0x39, 0x39, 0x29, 0x30, 0x9A, 0x01, 0x3A, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x0D,
0x28, 0x3F, 0x3A, 0x31, 0x32, 0x7C, 0x35, 0x37, 0x7C, 0x39, 0x39, 0x29, 0x30,
0x9A, 0x01, 0x30, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x0D, 0x28,
0x3F, 0x3A, 0x31, 0x32, 0x7C, 0x35, 0x37, 0x7C, 0x39, 0x39, 0x29, 0x30, 0x0A,
0x35, 0x4A, 0x00, 0x50, 0xD7, 0x06, 0x9A, 0x01, 0x2D, 0x0A, 0x1E, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x2C, 0x33,
0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20,
0x24, 0x34, 0x0A, 0x67, 0x4A, 0x00, 0x50, 0xD8, 0x06, 0x9A, 0x01, 0x21, 0x0A,
0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x9A, 0x01, 0x21, 0x0A, 0x15, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32,
0x20, 0x24, 0x33, 0x9A, 0x01, 0x17, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x38, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31,
0x20, 0x24, 0x32, 0x0A, 0x78, 0x4A, 0x00, 0x50, 0x5E, 0x9A, 0x01, 0x27, 0x0A,
0x12, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x36, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32,
0x20, 0x24, 0x33, 0x1A, 0x07, 0x5B, 0x31, 0x2D, 0x36, 0x38, 0x39, 0x5D, 0x9A,
0x01, 0x20, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x36, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, 0x32, 0x1A,
0x07, 0x5B, 0x31, 0x2D, 0x36, 0x38, 0x39, 0x5D, 0x9A, 0x01, 0x24, 0x0A, 0x15,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x01, 0x37, 0x0A, 0x3D, 0x4A, 0x00, 0x50,
0xE0, 0x02, 0x9A, 0x01, 0x35, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A,
0x12, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x33, 0x36, 0x37, 0x5D, 0x7C, 0x34,
0x5B, 0x33, 0x2D, 0x38, 0x5D, 0x29, 0x0A, 0x67, 0x4A, 0x00, 0x50, 0xF5, 0x02,
0x9A, 0x01, 0x35, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24,
0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x08, 0x32, 0x32, 0x7C, 0x5B,
0x33, 0x36, 0x37, 0x5D, 0x9A, 0x01, 0x27, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x1A, 0x04, 0x5B, 0x36, 0x37, 0x5D, 0x0A, 0x29, 0x4A, 0x00, 0x50, 0x5F,
0x9A, 0x01, 0x22, 0x0A, 0x12, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x02, 0x39, 0x32, 0x0A, 0x9E,
0x01, 0x4A, 0x00, 0x50, 0x34, 0x9A, 0x01, 0x42, 0x0A, 0x23, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0E, 0x24, 0x31, 0x20, 0x24, 0x32,
0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x1A, 0x0B, 0x33, 0x33,
0x7C, 0x35, 0x5B, 0x35, 0x36, 0x5D, 0x7C, 0x38, 0x31, 0x9A, 0x01, 0x52, 0x0A,
0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x20, 0x24, 0x34, 0x1A, 0x25, 0x5B, 0x32, 0x34, 0x36, 0x37, 0x39, 0x5D, 0x7C,
0x33, 0x5B, 0x30, 0x2D, 0x32, 0x34, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x7C, 0x35,
0x5B, 0x30, 0x38, 0x39, 0x5D, 0x7C, 0x38, 0x5B, 0x30, 0x32, 0x2D, 0x34, 0x36,
0x2D, 0x39, 0x5D, 0x0A, 0x29, 0x4A, 0x00, 0x50, 0xF9, 0x03, 0x9A, 0x01, 0x21,
0x0A, 0x12, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24,
0x32, 0x20, 0x24, 0x33, 0x1A, 0x01, 0x32, 0x0A, 0xB5, 0x01, 0x4A, 0x00, 0x50,
0x1F, 0x9A, 0x01, 0x57, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x34,
0x31, 0x5B, 0x30, 0x33, 0x35, 0x5D, 0x7C, 0x32, 0x5B, 0x30, 0x33, 0x34, 0x36,
0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x33, 0x35, 0x36, 0x38, 0x5D, 0x7C, 0x34, 0x5B,
0x30, 0x33, 0x35, 0x36, 0x5D, 0x7C, 0x35, 0x5B, 0x30, 0x33, 0x35, 0x38, 0x5D,
0x7C, 0x37, 0x7C, 0x38, 0x5B, 0x34, 0x35, 0x37, 0x38, 0x5D, 0x7C, 0x39, 0x31,
0x9A, 0x01, 0x54, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24,
0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x27, 0x31, 0x5B, 0x31, 0x36,
0x2D, 0x38, 0x5D, 0x7C, 0x32, 0x5B, 0x32, 0x35, 0x39, 0x5D, 0x7C, 0x33, 0x5B,
0x31, 0x32, 0x34, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x37, 0x2D, 0x39, 0x5D, 0x7C,
0x35, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x37, 0x39, 0x5D, 0x0A, 0x5F, 0x4A, 0x00,
0x50, 0x40, 0x9A, 0x01, 0x2D, 0x0A, 0x12, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12,
0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x0D, 0x5B, 0x33,
0x34, 0x36, 0x37, 0x5D, 0x7C, 0x39, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x9A, 0x01,
0x28, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x08,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x05, 0x5B, 0x38, 0x39,
0x5D, 0x30, 0x0A, 0x2C, 0x4A, 0x00, 0x50, 0xA3, 0x05, 0x9A, 0x01, 0x24, 0x0A,
0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x01, 0x37, 0x0A, 0x21, 0x4A, 0x00,
0x50, 0x3F, 0x9A, 0x01, 0x1A, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20,
0x24, 0x32, 0x1A, 0x01, 0x32, 0x0A, 0x8E, 0x01, 0x4A, 0x00, 0x50, 0xDF, 0x02,
0x9A, 0x01, 0x28, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x05, 0x32,
0x5B, 0x31, 0x32, 0x5D, 0x9A, 0x01, 0x34, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x07,
0x32, 0x5B, 0x31, 0x32, 0x5D, 0x7C, 0x39, 0x9A, 0x01, 0x24, 0x0A, 0x15, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24,
0x32, 0x20, 0x24, 0x33, 0x1A, 0x01, 0x39, 0x0A, 0xF9, 0x01, 0x4A, 0x00, 0x50,
0xD3, 0x04, 0x9A, 0x01, 0x48, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A,
0x25, 0x5B, 0x32, 0x36, 0x5D, 0x31, 0x7C, 0x33, 0x5B, 0x32, 0x38, 0x39, 0x5D,
0x7C, 0x34, 0x5B, 0x31, 0x32, 0x34, 0x36, 0x2D, 0x38, 0x5D, 0x7C, 0x37, 0x5B,
0x31, 0x2D, 0x33, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D, 0x33, 0x36, 0x5D, 0x9A,
0x01, 0x4F, 0x0A, 0x10, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x36, 0x2C, 0x37, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24,
0x32, 0x1A, 0x34, 0x32, 0x5B, 0x31, 0x34, 0x2D, 0x36, 0x38, 0x5D, 0x7C, 0x33,
0x5B, 0x32, 0x36, 0x2D, 0x39, 0x5D, 0x7C, 0x34, 0x5B, 0x31, 0x32, 0x34, 0x36,
0x2D, 0x38, 0x5D, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x31, 0x7C, 0x37, 0x35, 0x29,
0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x33, 0x35, 0x5D, 0x7C, 0x38, 0x5B, 0x31, 0x2D,
0x33, 0x36, 0x5D, 0x9A, 0x01, 0x54, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x36, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31,
0x20, 0x24, 0x32, 0x1A, 0x3B, 0x32, 0x5B, 0x32, 0x37, 0x39, 0x5D, 0x7C, 0x33,
0x5B, 0x31, 0x33, 0x2D, 0x35, 0x5D, 0x7C, 0x34, 0x5B, 0x33, 0x35, 0x39, 0x5D,
0x7C, 0x35, 0x5B, 0x31, 0x2D, 0x35, 0x5D, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x5B,
0x33, 0x34, 0x5D, 0x7C, 0x37, 0x5B, 0x31, 0x2D, 0x34, 0x36, 0x2D, 0x38, 0x5D,
0x29, 0x7C, 0x37, 0x5B, 0x34, 0x36, 0x2D, 0x38, 0x5D, 0x7C, 0x38, 0x35, 0x0A,
0xD9, 0x01, 0x4A, 0x00, 0x50, 0xFD, 0x02, 0x9A, 0x01, 0x4B, 0x0A, 0x15, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24,
0x32, 0x20, 0x24, 0x33, 0x1A, 0x28, 0x5B, 0x31, 0x36, 0x5D, 0x7C, 0x32, 0x5B,
0x30, 0x2D, 0x32, 0x34, 0x2D, 0x37, 0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x2D, 0x38,
0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32, 0x5B, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x33,
0x39, 0x29, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x9A, 0x01, 0x52, 0x0A, 0x1C, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24,
0x34, 0x1A, 0x25, 0x31, 0x7C, 0x32, 0x5B, 0x30, 0x2D, 0x32, 0x34, 0x2D, 0x37,
0x5D, 0x7C, 0x33, 0x5B, 0x30, 0x2D, 0x38, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x32,
0x5B, 0x33, 0x38, 0x39, 0x5D, 0x7C, 0x33, 0x39, 0x29, 0x5B, 0x32, 0x2D, 0x39,
0x5D, 0x9A, 0x01, 0x2E, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x01, 0x36, 0x0A, 0xB9,
0x04, 0x4A, 0x00, 0x50, 0x07, 0x9A, 0x01, 0x54, 0x0A, 0x15, 0x28, 0x5C, 0x64,
0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x1A, 0x31, 0x5B, 0x33, 0x34, 0x38, 0x39, 0x5D, 0x7C, 0x37, 0x28,
0x3F, 0x3A, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x2D, 0x36, 0x5D, 0x32, 0x7C,
0x37, 0x7C, 0x38, 0x5B, 0x32, 0x37, 0x5D, 0x29, 0x7C, 0x32, 0x28, 0x3F, 0x3A,
0x31, 0x5B, 0x32, 0x33, 0x5D, 0x7C, 0x5B, 0x32, 0x2D, 0x39, 0x5D, 0x32, 0x29,
0x29, 0x9A, 0x01, 0x75, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24,
0x32, 0x1A, 0x5C, 0x5B, 0x33, 0x34, 0x38, 0x39, 0x5D, 0x7C, 0x37, 0x28, 0x3F,
0x3A, 0x31, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x36, 0x5D, 0x5B, 0x33, 0x2D, 0x36,
0x5D, 0x7C, 0x5B, 0x31, 0x33, 0x2D, 0x35, 0x5D, 0x5B, 0x33, 0x2D, 0x35, 0x5D,
0x7C, 0x32, 0x5B, 0x33, 0x35, 0x5D, 0x7C, 0x38, 0x5B, 0x33, 0x34, 0x5D, 0x29,
0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x2D, 0x33, 0x38, 0x5D, 0x5B, 0x33,
0x2D, 0x35, 0x5D, 0x7C, 0x5B, 0x34, 0x39, 0x5D, 0x5B, 0x33, 0x35, 0x5D, 0x7C,
0x35, 0x5B, 0x33, 0x2D, 0x36, 0x5D, 0x7C, 0x36, 0x7C, 0x37, 0x5B, 0x34, 0x35,
0x37, 0x5D, 0x29, 0x29, 0x9A, 0x01, 0x48, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B,
0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x1B,
0x37, 0x28, 0x3F, 0x3A, 0x31, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x2D,
0x36, 0x38, 0x39, 0x5D, 0x7C, 0x37, 0x5B, 0x32, 0x34, 0x35, 0x37, 0x5D, 0x29,
0x29, 0x9A, 0x01, 0x6C, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x3F, 0x5B, 0x33, 0x34,
0x38, 0x39, 0x5D, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x34, 0x2D, 0x38,
0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x30, 0x34, 0x7C, 0x5B, 0x32, 0x33, 0x36,
0x5D, 0x33, 0x7C, 0x34, 0x5B, 0x33, 0x2D, 0x35, 0x5D, 0x7C, 0x35, 0x5B, 0x33,
0x34, 0x5D, 0x29, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x31, 0x33, 0x7C, 0x33, 0x34,
0x7C, 0x37, 0x5B, 0x33, 0x39, 0x5D, 0x29, 0x29, 0x9A, 0x01, 0x73, 0x0A, 0x20,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0E, 0x24, 0x31, 0x20, 0x24, 0x32,
0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x20, 0x24, 0x35, 0x1A, 0x3F, 0x5B, 0x33,
0x34, 0x38, 0x39, 0x5D, 0x7C, 0x37, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x34, 0x2D,
0x38, 0x5D, 0x7C, 0x31, 0x28, 0x3F, 0x3A, 0x30, 0x34, 0x7C, 0x5B, 0x32, 0x33,
0x36, 0x5D, 0x33, 0x7C, 0x34, 0x5B, 0x33, 0x2D, 0x35, 0x5D, 0x7C, 0x35, 0x5B,
0x33, 0x34, 0x5D, 0x29, 0x7C, 0x32, 0x28, 0x3F, 0x3A, 0x31, 0x33, 0x7C, 0x33,
0x34, 0x7C, 0x37, 0x5B, 0x33, 0x39, 0x5D, 0x29, 0x29, 0x9A, 0x01, 0x33, 0x0A,
0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33,
0x20, 0x24, 0x34, 0x1A, 0x06, 0x5B, 0x33, 0x34, 0x38, 0x39, 0x5D, 0x0A, 0x21,
0x4A, 0x00, 0x50, 0x42, 0x9A, 0x01, 0x1A, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B,
0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x05, 0x24,
0x31, 0x20, 0x24, 0x32, 0x1A, 0x01, 0x32, 0x0A, 0x26, 0x4A, 0x00, 0x50, 0xA4,
0x05, 0x9A, 0x01, 0x1E, 0x0A, 0x0E, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24,
0x32, 0x1A, 0x05, 0x5B, 0x35, 0x2D, 0x38, 0x5D, 0x0A, 0x7A, 0x4A, 0x00, 0x50,
0x5A, 0x9A, 0x01, 0x3B, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x18,
0x5B, 0x32, 0x2D, 0x34, 0x5D, 0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x5B, 0x30, 0x32,
0x2D, 0x36, 0x39, 0x5D, 0x7C, 0x31, 0x5B, 0x30, 0x36, 0x5D, 0x29, 0x9A, 0x01,
0x35, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x08, 0x35, 0x31, 0x32, 0x7C, 0x5B, 0x38,
0x39, 0x5D, 0x0A, 0x59, 0x4A, 0x00, 0x50, 0xFF, 0x01, 0x9A, 0x01, 0x27, 0x0A,
0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x04, 0x5B, 0x36, 0x37, 0x5D, 0x9A,
0x01, 0x27, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12,
0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x04, 0x5B, 0x36,
0x37, 0x5D, 0x0A, 0x8F, 0x02, 0x4A, 0x00, 0x50, 0xFC, 0x02, 0x9A, 0x01, 0x81,
0x01, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C,
0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20,
0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x54, 0x34, 0x5B, 0x34, 0x35, 0x5D, 0x5B,
0x30, 0x2D, 0x35, 0x5D, 0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x30, 0x7C, 0x36, 0x28,
0x3F, 0x3A, 0x33, 0x5B, 0x31, 0x34, 0x2D, 0x37, 0x5D, 0x7C, 0x37, 0x29, 0x29,
0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x32, 0x5D, 0x5B, 0x30, 0x31, 0x38,
0x5D, 0x7C, 0x5B, 0x33, 0x36, 0x2D, 0x38, 0x5D, 0x29, 0x7C, 0x37, 0x7C, 0x38,
0x39, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x28, 0x3F, 0x3A, 0x34,
0x38, 0x7C, 0x35, 0x37, 0x29, 0x5B, 0x30, 0x31, 0x33, 0x37, 0x2D, 0x39, 0x5D,
0x9A, 0x01, 0x81, 0x01, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29,
0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D,
0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20,
0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x54, 0x34, 0x5B, 0x34,
0x35, 0x5D, 0x5B, 0x30, 0x2D, 0x35, 0x5D, 0x7C, 0x35, 0x28, 0x3F, 0x3A, 0x30,
0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x33, 0x5B, 0x31, 0x34, 0x2D, 0x37, 0x5D, 0x7C,
0x37, 0x29, 0x29, 0x7C, 0x36, 0x28, 0x3F, 0x3A, 0x5B, 0x31, 0x32, 0x5D, 0x5B,
0x30, 0x31, 0x38, 0x5D, 0x7C, 0x5B, 0x33, 0x36, 0x2D, 0x38, 0x5D, 0x29, 0x7C,
0x37, 0x7C, 0x38, 0x39, 0x7C, 0x39, 0x5B, 0x31, 0x2D, 0x39, 0x5D, 0x7C, 0x28,
0x3F, 0x3A, 0x34, 0x38, 0x7C, 0x35, 0x37, 0x29, 0x5B, 0x30, 0x31, 0x33, 0x37,
0x2D, 0x39, 0x5D, 0x0A, 0x28, 0x4A, 0x00, 0x50, 0x3A, 0x9A, 0x01, 0x21, 0x0A,
0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x0A, 0x8A, 0x01, 0x4A, 0x00, 0x50, 0x54,
0x9A, 0x01, 0x27, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28,
0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29,
0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x04, 0x5B,
0x36, 0x39, 0x5D, 0x9A, 0x01, 0x32, 0x0A, 0x1C, 0x28, 0x5C, 0x64, 0x7B, 0x32,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x0B, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x05, 0x32,
0x5B, 0x34, 0x38, 0x5D, 0x9A, 0x01, 0x24, 0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B,
0x34, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64,
0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31, 0x20, 0x24, 0x32, 0x20, 0x24,
0x33, 0x1A, 0x01, 0x31, 0x0A, 0x31, 0x4A, 0x00, 0x50, 0x1B, 0x9A, 0x01, 0x2A,
0x0A, 0x15, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B,
0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x12, 0x08, 0x24,
0x31, 0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0x1A, 0x07, 0x38, 0x36, 0x5B, 0x31,
0x2D, 0x39, 0x5D
};
} // namespace
int alternate_format_size() {
return sizeof(data) / sizeof(data[0]);
}
const void* alternate_format_get() {
return data;
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/alternate_format.cc
|
C++
|
unknown
| 126,726
|
/*
* Copyright (C) 2012 The Libphonenumber Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef I18N_PHONENUMBERS_ALTERNATE_FORMAT_H_
#define I18N_PHONENUMBERS_ALTERNATE_FORMAT_H_
namespace i18n {
namespace phonenumbers {
int alternate_format_size();
const void* alternate_format_get();
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_ALTERNATE_FORMAT_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/alternate_format.h
|
C++
|
unknown
| 913
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "phonenumbers/asyoutypeformatter.h"
#include <math.h>
#include <cctype>
#include <list>
#include <string>
#include <google/protobuf/message_lite.h>
#include "phonenumbers/base/logging.h"
#include "phonenumbers/phonemetadata.pb.h"
#include "phonenumbers/phonenumberutil.h"
#include "phonenumbers/regexp_cache.h"
#include "phonenumbers/regexp_factory.h"
#include "phonenumbers/stringutil.h"
#include "phonenumbers/unicodestring.h"
namespace i18n {
namespace phonenumbers {
using google::protobuf::RepeatedPtrField;
namespace {
const char kPlusSign = '+';
// This is the minimum length of national number accrued that is required to
// trigger the formatter. The first element of the leading_digits_pattern of
// each number_format contains a regular expression that matches up to this
// number of digits.
const size_t kMinLeadingDigitsLength = 3;
// The digits that have not been entered yet will be represented by a \u2008,
// the punctuation space.
const char kDigitPlaceholder[] = "\xE2\x80\x88"; /* " " */
// Character used when appropriate to separate a prefix, such as a long NDD or a
// country calling code, from the national number.
const char kSeparatorBeforeNationalNumber = ' ';
// A set of characters that, if found in a national prefix formatting rules, are
// an indicator to us that we should separate the national prefix from the
// number when formatting.
const char kNationalPrefixSeparatorsPattern[] = "[- ]";
// Matches all the groups contained in 'input' against 'pattern'.
void MatchAllGroups(const string& pattern,
const string& input,
const AbstractRegExpFactory& regexp_factory,
RegExpCache* cache,
string* group) {
DCHECK(cache);
DCHECK(group);
string new_pattern(pattern);
// Transforms pattern "(...)(...)(...)" to "(.........)".
strrmm(&new_pattern, "()");
new_pattern = StrCat("(", new_pattern, ")");
const scoped_ptr<RegExpInput> consume_input(
regexp_factory.CreateInput(input));
bool status =
cache->GetRegExp(new_pattern).Consume(consume_input.get(), group);
DCHECK(status);
IGNORE_UNUSED(status);
}
PhoneMetadata CreateEmptyMetadata() {
PhoneMetadata metadata;
metadata.set_international_prefix("NA");
return metadata;
}
} // namespace
AsYouTypeFormatter::AsYouTypeFormatter(const string& region_code)
: regexp_factory_(new RegExpFactory()),
regexp_cache_(*regexp_factory_.get(), 64),
current_output_(),
formatting_template_(),
current_formatting_pattern_(),
accrued_input_(),
accrued_input_without_formatting_(),
able_to_format_(true),
input_has_formatting_(false),
is_complete_number_(false),
is_expecting_country_code_(false),
phone_util_(*PhoneNumberUtil::GetInstance()),
default_country_(region_code),
empty_metadata_(CreateEmptyMetadata()),
default_metadata_(GetMetadataForRegion(region_code)),
current_metadata_(default_metadata_),
last_match_position_(0),
original_position_(0),
position_to_remember_(0),
prefix_before_national_number_(),
should_add_space_after_national_prefix_(false),
extracted_national_prefix_(),
national_number_(),
possible_formats_() {
}
// The metadata needed by this class is the same for all regions sharing the
// same country calling code. Therefore, we return the metadata for "main"
// region for this country calling code.
const PhoneMetadata* AsYouTypeFormatter::GetMetadataForRegion(
const string& region_code) const {
int country_calling_code = phone_util_.GetCountryCodeForRegion(region_code);
string main_country;
phone_util_.GetRegionCodeForCountryCode(country_calling_code, &main_country);
const PhoneMetadata* const metadata =
phone_util_.GetMetadataForRegion(main_country);
if (metadata) {
return metadata;
}
// Set to a default instance of the metadata. This allows us to function with
// an incorrect region code, even if formatting only works for numbers
// specified with "+".
return &empty_metadata_;
}
bool AsYouTypeFormatter::MaybeCreateNewTemplate() {
// When there are multiple available formats, the formatter uses the first
// format where a formatting template could be created.
for (list<const NumberFormat*>::const_iterator it = possible_formats_.begin();
it != possible_formats_.end(); ++it) {
DCHECK(*it);
const NumberFormat& number_format = **it;
const string& pattern = number_format.pattern();
if (current_formatting_pattern_ == pattern) {
return false;
}
if (CreateFormattingTemplate(number_format)) {
current_formatting_pattern_ = pattern;
SetShouldAddSpaceAfterNationalPrefix(number_format);
// With a new formatting template, the matched position using the old
// template needs to be reset.
last_match_position_ = 0;
return true;
}
}
able_to_format_ = false;
return false;
}
void AsYouTypeFormatter::GetAvailableFormats(const string& leading_digits) {
// First decide whether we should use international or national number rules.
bool is_international_number =
is_complete_number_ && extracted_national_prefix_.empty();
const RepeatedPtrField<NumberFormat>& format_list =
(is_international_number &&
current_metadata_->intl_number_format().size() > 0)
? current_metadata_->intl_number_format()
: current_metadata_->number_format();
for (RepeatedPtrField<NumberFormat>::const_iterator it = format_list.begin();
it != format_list.end(); ++it) {
// Discard a few formats that we know are not relevant based on the presence
// of the national prefix.
if (!extracted_national_prefix_.empty() &&
phone_util_.FormattingRuleHasFirstGroupOnly(
it->national_prefix_formatting_rule()) &&
!it->national_prefix_optional_when_formatting() &&
!it->has_domestic_carrier_code_formatting_rule()) {
// If it is a national number that had a national prefix, any rules that
// aren't valid with a national prefix should be excluded. A rule that has
// a carrier-code formatting rule is kept since the national prefix might
// actually be an extracted carrier code - we don't distinguish between
// these when extracting it in the AYTF.
continue;
} else if (extracted_national_prefix_.empty() &&
!is_complete_number_ &&
!phone_util_.FormattingRuleHasFirstGroupOnly(
it->national_prefix_formatting_rule()) &&
!it->national_prefix_optional_when_formatting()) {
// This number was entered without a national prefix, and this formatting
// rule requires one, so we discard it.
continue;
}
if (phone_util_.IsFormatEligibleForAsYouTypeFormatter(it->format())) {
possible_formats_.push_back(&*it);
}
}
NarrowDownPossibleFormats(leading_digits);
}
void AsYouTypeFormatter::NarrowDownPossibleFormats(
const string& leading_digits) {
const int index_of_leading_digits_pattern =
leading_digits.length() - kMinLeadingDigitsLength;
for (list<const NumberFormat*>::iterator it = possible_formats_.begin();
it != possible_formats_.end(); ) {
DCHECK(*it);
const NumberFormat& format = **it;
if (format.leading_digits_pattern_size() == 0) {
// Keep everything that isn't restricted by leading digits.
++it;
continue;
}
int last_leading_digits_pattern =
std::min(index_of_leading_digits_pattern,
format.leading_digits_pattern_size() - 1);
const scoped_ptr<RegExpInput> input(
regexp_factory_->CreateInput(leading_digits));
if (!regexp_cache_.GetRegExp(format.leading_digits_pattern().Get(
last_leading_digits_pattern)).Consume(input.get())) {
it = possible_formats_.erase(it);
continue;
}
++it;
}
}
void AsYouTypeFormatter::SetShouldAddSpaceAfterNationalPrefix(
const NumberFormat& format) {
static const scoped_ptr<const RegExp> national_prefix_separators_pattern(
regexp_factory_->CreateRegExp(kNationalPrefixSeparatorsPattern));
should_add_space_after_national_prefix_ =
national_prefix_separators_pattern->PartialMatch(
format.national_prefix_formatting_rule());
}
bool AsYouTypeFormatter::CreateFormattingTemplate(const NumberFormat& format) {
string number_pattern = format.pattern();
string number_format = format.format();
formatting_template_.remove();
UnicodeString temp_template;
GetFormattingTemplate(number_pattern, number_format, &temp_template);
if (temp_template.length() > 0) {
formatting_template_.append(temp_template);
return true;
}
return false;
}
void AsYouTypeFormatter::GetFormattingTemplate(
const string& number_pattern,
const string& number_format,
UnicodeString* formatting_template) {
DCHECK(formatting_template);
// Creates a phone number consisting only of the digit 9 that matches the
// number_pattern by applying the pattern to the longest_phone_number string.
static const char longest_phone_number[] = "999999999999999";
string a_phone_number;
MatchAllGroups(number_pattern, longest_phone_number, *regexp_factory_,
®exp_cache_, &a_phone_number);
// No formatting template can be created if the number of digits entered so
// far is longer than the maximum the current formatting rule can accommodate.
if (a_phone_number.length() < national_number_.length()) {
formatting_template->remove();
return;
}
// Formats the number according to number_format.
regexp_cache_.GetRegExp(number_pattern).GlobalReplace(
&a_phone_number, number_format);
// Replaces each digit with character kDigitPlaceholder.
GlobalReplaceSubstring("9", kDigitPlaceholder, &a_phone_number);
formatting_template->setTo(a_phone_number.c_str(), a_phone_number.size());
}
void AsYouTypeFormatter::Clear() {
current_output_.clear();
accrued_input_.remove();
accrued_input_without_formatting_.remove();
formatting_template_.remove();
last_match_position_ = 0;
current_formatting_pattern_.clear();
prefix_before_national_number_.clear();
extracted_national_prefix_.clear();
national_number_.clear();
able_to_format_ = true;
input_has_formatting_ = false;
position_to_remember_ = 0;
original_position_ = 0;
is_complete_number_ = false;
is_expecting_country_code_ = false;
possible_formats_.clear();
should_add_space_after_national_prefix_ = false;
if (current_metadata_ != default_metadata_) {
current_metadata_ = GetMetadataForRegion(default_country_);
}
}
const string& AsYouTypeFormatter::InputDigit(char32 next_char, string* result) {
DCHECK(result);
InputDigitWithOptionToRememberPosition(next_char, false, ¤t_output_);
result->assign(current_output_);
return *result;
}
const string& AsYouTypeFormatter::InputDigitAndRememberPosition(
char32 next_char,
string* result) {
DCHECK(result);
InputDigitWithOptionToRememberPosition(next_char, true, ¤t_output_);
result->assign(current_output_);
return *result;
}
void AsYouTypeFormatter::InputDigitWithOptionToRememberPosition(
char32 next_char,
bool remember_position,
string* phone_number) {
DCHECK(phone_number);
accrued_input_.append(next_char);
if (remember_position) {
original_position_ = accrued_input_.length();
}
// We do formatting on-the-fly only when each character entered is either a
// plus sign (accepted at the start of the number only).
string next_char_string;
UnicodeString(next_char).toUTF8String(next_char_string);
char normalized_next_char = '\0';
if (!(phone_util_.ContainsOnlyValidDigits(next_char_string) ||
(accrued_input_.length() == 1 && next_char == kPlusSign))) {
able_to_format_ = false;
input_has_formatting_ = true;
} else {
normalized_next_char =
NormalizeAndAccrueDigitsAndPlusSign(next_char, remember_position);
}
if (!able_to_format_) {
// When we are unable to format because of reasons other than that
// formatting chars have been entered, it can be due to really long IDDs or
// NDDs. If that is the case, we might be able to do formatting again after
// extracting them.
if (input_has_formatting_) {
phone_number->clear();
accrued_input_.toUTF8String(*phone_number);
} else if (AttemptToExtractIdd()) {
if (AttemptToExtractCountryCode()) {
AttemptToChoosePatternWithPrefixExtracted(phone_number);
return;
}
} else if (AbleToExtractLongerNdd()) {
// Add an additional space to separate long NDD and national significant
// number for readability. We don't set
// should_add_space_after_national_prefix_ to true, since we don't want
// this to change later when we choose formatting templates.
prefix_before_national_number_.push_back(kSeparatorBeforeNationalNumber);
AttemptToChoosePatternWithPrefixExtracted(phone_number);
return;
}
phone_number->clear();
accrued_input_.toUTF8String(*phone_number);
return;
}
// We start to attempt to format only when at least kMinLeadingDigitsLength
// digits (the plus sign is counted as a digit as well for this purpose) have
// been entered.
switch (accrued_input_without_formatting_.length()) {
case 0:
case 1:
case 2:
phone_number->clear();
accrued_input_.toUTF8String(*phone_number);
return;
case 3:
if (AttemptToExtractIdd()) {
is_expecting_country_code_ = true;
// FALLTHROUGH_INTENDED
} else {
// No IDD or plus sign is found, might be entering in national format.
RemoveNationalPrefixFromNationalNumber(&extracted_national_prefix_);
AttemptToChooseFormattingPattern(phone_number);
return;
}
default:
if (is_expecting_country_code_) {
if (AttemptToExtractCountryCode()) {
is_expecting_country_code_ = false;
}
phone_number->assign(prefix_before_national_number_);
phone_number->append(national_number_);
return;
}
if (possible_formats_.size() > 0) {
// The formatting patterns are already chosen.
string temp_national_number;
InputDigitHelper(normalized_next_char, &temp_national_number);
// See if accrued digits can be formatted properly already. If not, use
// the results from InputDigitHelper, which does formatting based on the
// formatting pattern chosen.
string formatted_number;
AttemptToFormatAccruedDigits(&formatted_number);
if (formatted_number.length() > 0) {
phone_number->assign(formatted_number);
return;
}
NarrowDownPossibleFormats(national_number_);
if (MaybeCreateNewTemplate()) {
InputAccruedNationalNumber(phone_number);
return;
}
if (able_to_format_) {
AppendNationalNumber(temp_national_number, phone_number);
} else {
phone_number->clear();
accrued_input_.toUTF8String(*phone_number);
}
return;
} else {
AttemptToChooseFormattingPattern(phone_number);
}
}
}
void AsYouTypeFormatter::AttemptToChoosePatternWithPrefixExtracted(
string* formatted_number) {
able_to_format_ = true;
is_expecting_country_code_ = false;
possible_formats_.clear();
last_match_position_ = 0;
formatting_template_.remove();
current_formatting_pattern_.clear();
AttemptToChooseFormattingPattern(formatted_number);
}
const string& AsYouTypeFormatter::GetExtractedNationalPrefix() const {
return extracted_national_prefix_;
}
bool AsYouTypeFormatter::AbleToExtractLongerNdd() {
if (extracted_national_prefix_.length() > 0) {
// Put the extracted NDD back to the national number before attempting to
// extract a new NDD.
national_number_.insert(0, extracted_national_prefix_);
// Remove the previously extracted NDD from prefixBeforeNationalNumber. We
// cannot simply set it to empty string because people sometimes incorrectly
// enter national prefix after the country code, e.g. +44 (0)20-1234-5678.
int index_of_previous_ndd =
prefix_before_national_number_.find_last_of(extracted_national_prefix_);
prefix_before_national_number_.resize(index_of_previous_ndd);
}
string new_national_prefix;
RemoveNationalPrefixFromNationalNumber(&new_national_prefix);
return extracted_national_prefix_ != new_national_prefix;
}
void AsYouTypeFormatter::AttemptToFormatAccruedDigits(
string* formatted_result) {
DCHECK(formatted_result);
for (list<const NumberFormat*>::const_iterator it = possible_formats_.begin();
it != possible_formats_.end(); ++it) {
DCHECK(*it);
const NumberFormat& number_format = **it;
const string& pattern = number_format.pattern();
if (regexp_cache_.GetRegExp(pattern).FullMatch(national_number_)) {
SetShouldAddSpaceAfterNationalPrefix(number_format);
string formatted_number(national_number_);
bool status = regexp_cache_.GetRegExp(pattern).GlobalReplace(
&formatted_number, number_format.format());
DCHECK(status);
IGNORE_UNUSED(status);
string full_output(*formatted_result);
// Check that we didn't remove nor add any extra digits when we matched
// this formatting pattern. This usually happens after we entered the last
// digit during AYTF. Eg: In case of MX, we swallow mobile token (1) when
// formatted but AYTF should retain all the number entered and not change
// in order to match a format (of same leading digits and length) display
// in that way.
AppendNationalNumber(formatted_number, &full_output);
phone_util_.NormalizeDiallableCharsOnly(&full_output);
string accrued_input_without_formatting_stdstring;
accrued_input_without_formatting_.toUTF8String(
accrued_input_without_formatting_stdstring);
if (full_output == accrued_input_without_formatting_stdstring) {
// If it's the same (i.e entered number and format is same), then it's
// safe to return this in formatted number as nothing is lost / added.
AppendNationalNumber(formatted_number, formatted_result);
return;
}
}
}
}
int AsYouTypeFormatter::GetRememberedPosition() const {
UnicodeString current_output(current_output_.c_str());
if (!able_to_format_) {
return ConvertUnicodeStringPosition(current_output, original_position_);
}
int accrued_input_index = 0;
int current_output_index = 0;
while (accrued_input_index < position_to_remember_ &&
current_output_index < current_output.length()) {
if (accrued_input_without_formatting_[accrued_input_index] ==
current_output[current_output_index]) {
++accrued_input_index;
}
++current_output_index;
}
return ConvertUnicodeStringPosition(current_output, current_output_index);
}
void AsYouTypeFormatter::AppendNationalNumber(const string& national_number,
string* phone_number) const {
int prefix_before_national_number_length =
prefix_before_national_number_.size();
if (should_add_space_after_national_prefix_ &&
prefix_before_national_number_length > 0 &&
prefix_before_national_number_.at(
prefix_before_national_number_length - 1) !=
kSeparatorBeforeNationalNumber) {
// We want to add a space after the national prefix if the national prefix
// formatting rule indicates that this would normally be done, with the
// exception of the case where we already appended a space because the NDD
// was surprisingly long.
phone_number->assign(prefix_before_national_number_);
phone_number->push_back(kSeparatorBeforeNationalNumber);
StrAppend(phone_number, national_number);
} else {
phone_number->assign(
StrCat(prefix_before_national_number_, national_number));
}
}
void AsYouTypeFormatter::AttemptToChooseFormattingPattern(
string* formatted_number) {
DCHECK(formatted_number);
// We start to attempt to format only when at least MIN_LEADING_DIGITS_LENGTH
// digits of national number (excluding national prefix) have been entered.
if (national_number_.length() >= kMinLeadingDigitsLength) {
GetAvailableFormats(national_number_);
formatted_number->clear();
AttemptToFormatAccruedDigits(formatted_number);
// See if the accrued digits can be formatted properly already.
if (formatted_number->length() > 0) {
return;
}
if (MaybeCreateNewTemplate()) {
InputAccruedNationalNumber(formatted_number);
} else {
formatted_number->clear();
accrued_input_.toUTF8String(*formatted_number);
}
return;
} else {
AppendNationalNumber(national_number_, formatted_number);
}
}
void AsYouTypeFormatter::InputAccruedNationalNumber(string* number) {
DCHECK(number);
int length_of_national_number = national_number_.length();
if (length_of_national_number > 0) {
string temp_national_number;
for (int i = 0; i < length_of_national_number; ++i) {
temp_national_number.clear();
InputDigitHelper(national_number_[i], &temp_national_number);
}
if (able_to_format_) {
AppendNationalNumber(temp_national_number, number);
} else {
number->clear();
accrued_input_.toUTF8String(*number);
}
return;
} else {
number->assign(prefix_before_national_number_);
}
}
bool AsYouTypeFormatter::IsNanpaNumberWithNationalPrefix() const {
// For NANPA numbers beginning with 1[2-9], treat the 1 as the national
// prefix. The reason is that national significant numbers in NANPA always
// start with [2-9] after the national prefix. Numbers beginning with 1[01]
// can only be short/emergency numbers, which don't need the national
// prefix.
return (current_metadata_->country_code() == 1) &&
(national_number_[0] == '1') && (national_number_[1] != '0') &&
(national_number_[1] != '1');
}
void AsYouTypeFormatter::RemoveNationalPrefixFromNationalNumber(
string* national_prefix) {
int start_of_national_number = 0;
if (IsNanpaNumberWithNationalPrefix()) {
start_of_national_number = 1;
prefix_before_national_number_.append("1");
prefix_before_national_number_.push_back(kSeparatorBeforeNationalNumber);
is_complete_number_ = true;
} else if (current_metadata_->has_national_prefix_for_parsing()) {
const scoped_ptr<RegExpInput> consumed_input(
regexp_factory_->CreateInput(national_number_));
const RegExp& pattern = regexp_cache_.GetRegExp(
current_metadata_->national_prefix_for_parsing());
// Since some national prefix patterns are entirely optional, check that a
// national prefix could actually be extracted.
if (pattern.Consume(consumed_input.get())) {
start_of_national_number =
national_number_.length() - consumed_input->ToString().length();
if (start_of_national_number > 0) {
// When the national prefix is detected, we use international formatting
// rules instead of national ones, because national formatting rules
// could countain local formatting rules for numbers entered without
// area code.
is_complete_number_ = true;
prefix_before_national_number_.append(
national_number_.substr(0, start_of_national_number));
}
}
}
national_prefix->assign(national_number_, 0, start_of_national_number);
national_number_.erase(0, start_of_national_number);
}
bool AsYouTypeFormatter::AttemptToExtractIdd() {
string accrued_input_without_formatting_stdstring;
accrued_input_without_formatting_
.toUTF8String(accrued_input_without_formatting_stdstring);
const scoped_ptr<RegExpInput> consumed_input(
regexp_factory_->CreateInput(accrued_input_without_formatting_stdstring));
const RegExp& international_prefix = regexp_cache_.GetRegExp(
StrCat("\\", string(&kPlusSign, 1), "|",
current_metadata_->international_prefix()));
if (international_prefix.Consume(consumed_input.get())) {
is_complete_number_ = true;
const int start_of_country_code =
accrued_input_without_formatting_.length() -
consumed_input->ToString().length();
national_number_.clear();
accrued_input_without_formatting_.tempSubString(start_of_country_code)
.toUTF8String(national_number_);
string before_country_code;
accrued_input_without_formatting_.tempSubString(0, start_of_country_code)
.toUTF8String(before_country_code);
prefix_before_national_number_.clear();
prefix_before_national_number_.append(before_country_code);
if (accrued_input_without_formatting_[0] != kPlusSign) {
prefix_before_national_number_.push_back(kSeparatorBeforeNationalNumber);
}
return true;
}
return false;
}
bool AsYouTypeFormatter::AttemptToExtractCountryCode() {
if (national_number_.length() == 0) {
return false;
}
string number_without_country_code(national_number_);
int country_code =
phone_util_.ExtractCountryCode(&number_without_country_code);
if (country_code == 0) {
return false;
}
national_number_.assign(number_without_country_code);
string new_region_code;
phone_util_.GetRegionCodeForCountryCode(country_code, &new_region_code);
if (PhoneNumberUtil::kRegionCodeForNonGeoEntity == new_region_code) {
current_metadata_ =
phone_util_.GetMetadataForNonGeographicalRegion(country_code);
} else if (new_region_code != default_country_) {
current_metadata_ = GetMetadataForRegion(new_region_code);
}
StrAppend(&prefix_before_national_number_, country_code);
prefix_before_national_number_.push_back(kSeparatorBeforeNationalNumber);
// When we have successfully extracted the IDD, the previously extracted NDD
// should be cleared because it is no longer valid.
extracted_national_prefix_.clear();
return true;
}
char AsYouTypeFormatter::NormalizeAndAccrueDigitsAndPlusSign(
char32 next_char,
bool remember_position) {
char normalized_char = next_char;
if (next_char == kPlusSign) {
accrued_input_without_formatting_.append(next_char);
} else {
string number;
UnicodeString(next_char).toUTF8String(number);
phone_util_.NormalizeDigitsOnly(&number);
accrued_input_without_formatting_.append(next_char);
national_number_.append(number);
normalized_char = number[0];
}
if (remember_position) {
position_to_remember_ = accrued_input_without_formatting_.length();
}
return normalized_char;
}
void AsYouTypeFormatter::InputDigitHelper(char next_char, string* number) {
DCHECK(number);
number->clear();
// Note that formattingTemplate is not guaranteed to have a value, it could be
// empty, e.g. when the next digit is entered after extracting an IDD or NDD.
const char32 placeholder_codepoint = UnicodeString(kDigitPlaceholder)[0];
int placeholder_pos = formatting_template_
.tempSubString(last_match_position_).indexOf(placeholder_codepoint);
if (placeholder_pos != -1) {
UnicodeString temp_template = formatting_template_;
placeholder_pos = temp_template.indexOf(placeholder_codepoint);
temp_template.setCharAt(placeholder_pos, UnicodeString(next_char)[0]);
last_match_position_ = placeholder_pos;
formatting_template_.replace(0, temp_template.length(), temp_template);
formatting_template_.tempSubString(0, last_match_position_ + 1)
.toUTF8String(*number);
} else {
if (possible_formats_.size() == 1) {
// More digits are entered than we could handle, and there are no other
// valid patterns to try.
able_to_format_ = false;
} // else, we just reset the formatting pattern.
current_formatting_pattern_.clear();
accrued_input_.toUTF8String(*number);
}
}
// Returns the number of bytes contained in the given UnicodeString up to the
// specified position.
// static
int AsYouTypeFormatter::ConvertUnicodeStringPosition(const UnicodeString& s,
int pos) {
if (pos > s.length()) {
return -1;
}
string substring;
s.tempSubString(0, pos).toUTF8String(substring);
return substring.length();
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/asyoutypeformatter.cc
|
C++
|
unknown
| 29,066
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// A formatter which formats phone numbers as they are entered.
//
// An AsYouTypeFormatter can be created by invoking the GetAsYouTypeFormatter
// method of the PhoneNumberUtil. After that digits can be added by invoking the
// InputDigit method on the formatter instance, and the partially formatted
// phone number will be returned each time a digit is added. The Clear method
// can be invoked before a new number needs to be formatted.
//
// See AYTF_US, AYTF_GBFixedLine and AYTF_DE test functions in
// asyoutypeformatter_test.cc for more details on how the formatter is to be
// used.
//
// This is a direct port from AsYouTypeFormatter.java.
// Changes to this class should also happen to the Java version, whenever it
// makes sense.
//
// This class is NOT THREAD SAFE.
#ifndef I18N_PHONENUMBERS_ASYOUTYPEFORMATTER_H_
#define I18N_PHONENUMBERS_ASYOUTYPEFORMATTER_H_
#include <list>
#include <string>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/memory/scoped_ptr.h"
#include "phonenumbers/regexp_adapter.h"
#include "phonenumbers/regexp_cache.h"
#include "phonenumbers/phonemetadata.pb.h"
#include "phonenumbers/unicodestring.h"
namespace i18n {
namespace phonenumbers {
using std::list;
class PhoneNumberUtil;
class AsYouTypeFormatter {
public:
~AsYouTypeFormatter() {}
// Formats a phone number on-the-fly as each digit is entered.
// next_char is the most recently entered digit of a phone number. Formatting
// characters are allowed, but as soon as they are encountered this method
// formats the number as entered and not "as you type" anymore. Full width
// digits and Arabic-indic digits are allowed, and will be shown as they are.
// Returns the partially formatted phone number (which is a reference to the
// given string parameter for convenience).
const string& InputDigit(char32 next_char, string* result);
// Same as InputDigit, but remembers the position where next_char is inserted,
// so that it could be retrieved later by using GetRememberedPosition(). The
// remembered position will be automatically adjusted if additional formatting
// characters are later inserted/removed in front of next_char.
// Returns the partially formatted phone number (which is a reference to the
// given string parameter for convenience).
const string& InputDigitAndRememberPosition(char32 next_char, string* result);
// Returns the current position in the partially formatted phone number of the
// character which was previously passed in as the parameter of
// InputDigitAndRememberPosition().
int GetRememberedPosition() const;
// Clears the internal state of the formatter, so it could be reused.
void Clear();
private:
// Constructs an as-you-type formatter. Should be obtained from
// PhoneNumberUtil::GetAsYouTypeFormatter().
explicit AsYouTypeFormatter(const string& region_code);
// Returns the metadata corresponding to the given region code or empty
// metadata if it is unsupported.
const PhoneMetadata* GetMetadataForRegion(const string& region_code) const;
// Returns true if a new template is created as opposed to reusing the
// existing template.
bool MaybeCreateNewTemplate();
void GetAvailableFormats(const string& leading_digits);
void NarrowDownPossibleFormats(const string& leading_digits);
// Calculates whether we should be adding a space after the national prefix
// for this formatting rule or not.
void SetShouldAddSpaceAfterNationalPrefix(const NumberFormat& format);
bool CreateFormattingTemplate(const NumberFormat& format);
// Gets a formatting template which could be used to efficiently format a
// partial number where digits are added one by one.
void GetFormattingTemplate(const string& number_pattern,
const string& number_format,
UnicodeString* formatting_template);
void InputDigitWithOptionToRememberPosition(char32 next_char,
bool remember_position,
string* phone_number);
void AttemptToChoosePatternWithPrefixExtracted(string* formatted_number);
const string& GetExtractedNationalPrefix() const;
// Some national prefixes are a substring of others. If extracting the
// shorter NDD doesn't result in a number we can format, we try to see if we
// can extract a longer version here.
bool AbleToExtractLongerNdd();
// Check to see if there is an exact pattern match for these digits. If so, we
// should use this instead of any other formatting template whose
// leadingDigitsPattern also matches the input.
void AttemptToFormatAccruedDigits(string* formatted_number);
// Combines the national number with any prefix (IDD/+ and country code or
// national prefix) that was collected. A space will be inserted between them
// if the current formatting template indicates this to be suitable.
// The result will be stored in phone_number.
void AppendNationalNumber(const string& national_number,
string* phone_number) const;
// Attempts to set the formatting template and assigns the passed-in string
// parameter to the formatted version of the digits entered so far.
void AttemptToChooseFormattingPattern(string* formatted_number);
// Invokes InputDigitHelper on each digit of the national number accrued, and
// assigns the passed-in string parameter to a formatted string in the end.
void InputAccruedNationalNumber(string* number);
// Returns true if the current country is a NANPA country and the national
// number begins with the national prefix.
bool IsNanpaNumberWithNationalPrefix() const;
// Extracts the national prefix into national_prefix, or sets it to empty
// string if a national prefix is not present.
void RemoveNationalPrefixFromNationalNumber(string* national_prefix);
// Extracts IDD and plus sign to prefix_before_national_number_ when they are
// available, and places the remaining input into national_number_.
bool AttemptToExtractIdd();
// Extracts country code from the begining of national_number_ to
// prefix_before_national_number_ when they are available, and places the
// remaining input into national_number_.
// Returns true when a valid country code can be found.
bool AttemptToExtractCountryCode();
// Accrues digits and the plus sign to accrued_input_without_formatting for
// later use. If next_char contains a digit in non-ASCII format (e.g the
// full-width version of digits), it is first normalized to the ASCII
// version. The return value is next_char itself, or its normalized version,
// if next_char is a digit in non-ASCII format.
char NormalizeAndAccrueDigitsAndPlusSign(char32 next_char,
bool remember_position);
void InputDigitHelper(char next_char, string* number);
// Converts UnicodeString position to std::string position.
static int ConvertUnicodeStringPosition(const UnicodeString& s, int pos);
// Class attributes.
const scoped_ptr<const AbstractRegExpFactory> regexp_factory_;
RegExpCache regexp_cache_;
string current_output_;
UnicodeString formatting_template_;
string current_formatting_pattern_;
UnicodeString accrued_input_;
UnicodeString accrued_input_without_formatting_;
// This indicates whether AsYouTypeFormatter is currently doing the
// formatting.
bool able_to_format_;
// Set to true when users enter their own formatting. AsYouTypeFormatter will
// do no formatting at all when this is set to true.
bool input_has_formatting_;
// This is set to true when we know the user is entering a full national
// significant number, since we have either detected a national prefix or an
// international dialing prefix. When this is true, we will no longer use
// local number formatting patterns.
bool is_complete_number_;
bool is_expecting_country_code_;
const PhoneNumberUtil& phone_util_;
const string default_country_;
const PhoneMetadata empty_metadata_;
const PhoneMetadata* const default_metadata_;
const PhoneMetadata* current_metadata_;
int last_match_position_;
// The position of a digit upon which InputDigitAndRememberPosition is most
// recently invoked, as found in the original sequence of characters the user
// entered.
int original_position_;
// The position of a digit upon which InputDigitAndRememberPosition is most
// recently invoked, as found in AccruedInputWithoutFormatting.
int position_to_remember_;
// This contains anything that has been entered so far preceding the national
// significant number, and it is formatted (e.g. with space inserted). For
// example, this can contain IDD, country code, and/or NDD, etc.
string prefix_before_national_number_;
bool should_add_space_after_national_prefix_;
// This contains the national prefix that has been extracted. It contains only
// digits without formatting.
string extracted_national_prefix_;
string national_number_;
list<const NumberFormat*> possible_formats_;
friend class PhoneNumberUtil;
friend class AsYouTypeFormatterTest;
// Disallow copy and assign since this class uses RegExpCache which can't be
// copied.
DISALLOW_COPY_AND_ASSIGN(AsYouTypeFormatter);
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_ASYOUTYPEFORMATTER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/asyoutypeformatter.h
|
C++
|
unknown
| 10,043
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef I18N_PHONENUMBERS_BASE_BASICTYPES_H_
#define I18N_PHONENUMBERS_BASE_BASICTYPES_H_
#include <limits.h> // So we can set the bounds of our types
#include <stddef.h> // For size_t
#include <string.h> // for memcpy
#if !defined(_WIN32)
// stdint.h is part of C99 but MSVC doesn't have it.
#include <stdint.h> // For intptr_t.
#endif
namespace i18n {
namespace phonenumbers {
#ifdef INT64_MAX
// INT64_MAX is defined if C99 stdint.h is included; use the
// native types if available.
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
const uint8 kuint8max = UINT8_MAX;
const uint16 kuint16max = UINT16_MAX;
const uint32 kuint32max = UINT32_MAX;
const uint64 kuint64max = UINT64_MAX;
const int8 kint8min = INT8_MIN;
const int8 kint8max = INT8_MAX;
const int16 kint16min = INT16_MIN;
const int16 kint16max = INT16_MAX;
const int32 kint32min = INT32_MIN;
const int32 kint32max = INT32_MAX;
const int64 kint64min = INT64_MIN;
const int64 kint64max = INT64_MAX;
#else // !INT64_MAX
typedef signed char int8;
typedef short int16;
// TODO: Remove these type guards. These are to avoid conflicts with
// obsolete/protypes.h in the Gecko SDK.
#ifndef _INT32
#define _INT32
typedef int int32;
#endif
// The NSPR system headers define 64-bit as |long| when possible. In order to
// not have typedef mismatches, we do the same on LP64.
#if __LP64__
typedef long int64;
#else
typedef long long int64;
#endif
// NOTE: unsigned types are DANGEROUS in loops and other arithmetical
// places. Use the signed types unless your variable represents a bit
// pattern (eg a hash value) or you really need the extra bit. Do NOT
// use 'unsigned' to express "this value should always be positive";
// use assertions for this.
typedef unsigned char uint8;
typedef unsigned short uint16;
// TODO: Remove these type guards. These are to avoid conflicts with
// obsolete/protypes.h in the Gecko SDK.
#ifndef _UINT32
#define _UINT32
typedef unsigned int uint32;
#endif
// See the comment above about NSPR and 64-bit.
#if __LP64__
typedef unsigned long uint64;
#else
typedef unsigned long long uint64;
#endif
#endif // !INT64_MAX
typedef signed char schar;
// A type to represent a Unicode code-point value. As of Unicode 4.0,
// such values require up to 21 bits.
// (For type-checking on pointers, make this explicitly signed,
// and it should always be the signed version of whatever int32 is.)
typedef signed int char32;
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#if !defined(DISALLOW_COPY_AND_ASSIGN)
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
#endif
// The arraysize(arr) macro returns the # of elements in an array arr.
// The expression is a compile-time constant, and therefore can be
// used in defining new arrays, for example. If you use arraysize on
// a pointer by mistake, you will get a compile-time error.
//
// One caveat is that arraysize() doesn't accept any array of an
// anonymous type or a type defined inside a function. In these rare
// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is
// due to a limitation in C++'s template system. The limitation might
// eventually be removed, but it hasn't happened yet.
// This template function declaration is used in defining arraysize.
// Note that the function doesn't need an implementation, as we only
// use its type.
template <typename T, size_t N>
char (&ArraySizeHelper(T (&array)[N]))[N];
// That gcc wants both of these prototypes seems mysterious. VC, for
// its part, can't decide which to use (another mystery). Matching of
// template overloads: the final frontier.
#ifndef _MSC_VER
template <typename T, size_t N>
char (&ArraySizeHelper(const T (&array)[N]))[N];
#endif
#if !defined(arraysize)
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
#endif
// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
// but can be used on anonymous types or types defined inside
// functions. It's less safe than arraysize as it accepts some
// (although not all) pointers. Therefore, you should use arraysize
// whenever possible.
//
// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
// size_t.
//
// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error
//
// "warning: division by zero in ..."
//
// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
//
// The following comments are on the implementation details, and can
// be ignored by the users.
//
// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
// the array) and sizeof(*(arr)) (the # of bytes in one array
// element). If the former is divisible by the latter, perhaps arr is
// indeed an array, in which case the division result is the # of
// elements in the array. Otherwise, arr cannot possibly be an array,
// and we generate a compiler error to prevent the code from
// compiling.
//
// Since the size of bool is implementation-defined, we need to cast
// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
// result has type size_t.
//
// This macro is not perfect as it wrongfully accepts certain
// pointers, namely where the pointer size is divisible by the pointee
// size. Since all our code has to go through a 32-bit compiler,
// where a pointer is 4 bytes, this means all pointers to a type whose
// size is 3 or greater than 4 will be (righteously) rejected.
#if !defined(ARRAYSIZE_UNSAFE)
#define ARRAYSIZE_UNSAFE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif
// The COMPILE_ASSERT macro can be used to verify that a compile time
// expression is true. For example, you could use it to verify the
// size of a static array:
//
// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
// content_type_names_incorrect_size);
//
// or to make sure a struct is smaller than a certain size:
//
// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
//
// The second argument to the macro is the name of the variable. If
// the expression is false, most compilers will issue a warning/error
// containing the name of the variable.
#if __cplusplus >= 201103L
// Under C++11, just use static_assert.
#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
#else
template <bool>
struct CompileAssert {
};
// Annotate a variable indicating it's ok if the variable is not used.
// (Typically used to silence a compiler warning when the assignment
// is important for some other reason.)
// Use like:
// int x ALLOW_UNUSED = ...;
#if defined(__GNUC__)
#define ALLOW_UNUSED __attribute__((unused))
#else
#define ALLOW_UNUSED
#endif
#define COMPILE_ASSERT(expr, msg) \
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] ALLOW_UNUSED
// Implementation details of COMPILE_ASSERT:
//
// - COMPILE_ASSERT works by defining an array type that has -1
// elements (and thus is invalid) when the expression is false.
//
// - The simpler definition
//
// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
//
// does not work, as gcc supports variable-length arrays whose sizes
// are determined at run-time (this is gcc's extension and not part
// of the C++ standard). As a result, gcc fails to reject the
// following code with the simple definition:
//
// int foo;
// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
// // not a compile-time constant.
//
// - By using the type CompileAssert<(bool(expr))>, we ensures that
// expr is a compile-time constant. (Template arguments must be
// determined at compile-time.)
//
// - The outer parentheses in CompileAssert<(bool(expr))> are necessary
// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
//
// CompileAssert<bool(expr)>
//
// instead, these compilers will refuse to compile
//
// COMPILE_ASSERT(5 > 0, some_message);
//
// (They seem to think the ">" in "5 > 0" marks the end of the
// template argument list.)
//
// - The array size is (bool(expr) ? 1 : -1), instead of simply
//
// ((expr) ? 1 : -1).
//
// This is to avoid running into a bug in MS VC 7.1, which
// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
#endif
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_BASICTYPES_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/basictypes.h
|
C++
|
unknown
| 9,035
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
// This file provides a minimalist implementation of common macros.
#ifndef I18N_PHONENUMBERS_BASE_LOGGING_H_
#define I18N_PHONENUMBERS_BASE_LOGGING_H_
#include <cassert>
#if !defined(CHECK_EQ)
#define CHECK_EQ(X, Y) assert((X) == (Y))
#endif
#if !defined(DCHECK)
#define DCHECK(X) assert(X)
#define DCHECK_EQ(X, Y) CHECK_EQ((X), (Y))
#define DCHECK_GE(X, Y) assert((X) >= (Y))
#define DCHECK_GT(X, Y) assert((X) > (Y))
#define DCHECK_LT(X, Y) assert((X) < (Y))
#endif
template <typename T> T* CHECK_NOTNULL(T* ptr) {
assert(ptr);
return ptr;
}
#if !defined(IGNORE_UNUSED)
#define IGNORE_UNUSED(X) (void)(X)
#endif
#endif // I18N_PHONENUMBERS_BASE_LOGGING_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/logging.h
|
C++
|
unknown
| 1,303
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef I18N_PHONENUMBERS_BASE_MEMORY_SCOPED_PTR_H_
#define I18N_PHONENUMBERS_BASE_MEMORY_SCOPED_PTR_H_
#if defined(I18N_PHONENUMBERS_USE_BOOST)
#include <boost/scoped_ptr.hpp>
using boost::scoped_ptr;
#else // !I18N_PHONENUMBERS_USE_BOOST
// This is an implementation designed to match the anticipated future TR2
// implementation of the scoped_ptr class and scoped_ptr_malloc (deprecated).
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <algorithm> // For std::swap().
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/template_util.h"
namespace i18n {
namespace phonenumbers {
// Function object which deletes its parameter, which must be a pointer.
// If C is an array type, invokes 'delete[]' on the parameter; otherwise,
// invokes 'delete'. The default deleter for scoped_ptr<T>.
template <class T>
struct DefaultDeleter {
DefaultDeleter() {}
template <typename U> DefaultDeleter(const DefaultDeleter<U>& other) {
// IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor
// if U* is implicitly convertible to T* and U is not an array type.
//
// Correct implementation should use SFINAE to disable this
// constructor. However, since there are no other 1-argument constructors,
// using a COMPILE_ASSERT() based on is_convertible<> and requiring
// complete types is simpler and will cause compile failures for equivalent
// misuses.
//
// Note, the is_convertible<U*, T*> check also ensures that U is not an
// array. T is guaranteed to be a non-array, so any U* where U is an array
// cannot convert to T*.
enum { T_must_be_complete = sizeof(T) };
enum { U_must_be_complete = sizeof(U) };
COMPILE_ASSERT((is_convertible<U*, T*>::value),
U_ptr_must_implicitly_convert_to_T_ptr);
}
inline void operator()(T* ptr) const {
enum { type_must_be_complete = sizeof(T) };
delete ptr;
}
};
// Specialization of DefaultDeleter for array types.
template <class T>
struct DefaultDeleter<T[]> {
inline void operator()(T* ptr) const {
enum { type_must_be_complete = sizeof(T) };
delete[] ptr;
}
private:
// Disable this operator for any U != T because it is undefined to execute
// an array delete when the static type of the array mismatches the dynamic
// type.
//
// References:
// C++98 [expr.delete]p3
// http://cplusplus.github.com/LWG/lwg-defects.html#938
template <typename U> void operator()(U* array) const;
};
template <class T, int n>
struct DefaultDeleter<T[n]> {
// Never allow someone to declare something like scoped_ptr<int[10]>.
COMPILE_ASSERT(sizeof(T) == -1, do_not_use_array_with_size_as_type);
};
// Function object which invokes 'free' on its parameter, which must be
// a pointer. Can be used to store malloc-allocated pointers in scoped_ptr:
//
// scoped_ptr<int, base::FreeDeleter> foo_ptr(
// static_cast<int*>(malloc(sizeof(int))));
struct FreeDeleter {
inline void operator()(void* ptr) const {
free(ptr);
}
};
// Minimal implementation of the core logic of scoped_ptr, suitable for
// reuse in both scoped_ptr and its specializations.
template <class T, class D>
class scoped_ptr_impl {
public:
explicit scoped_ptr_impl(T* p) : data_(p) { }
// Initializer for deleters that have data parameters.
scoped_ptr_impl(T* p, const D& d) : data_(p, d) {}
// Templated constructor that destructively takes the value from another
// scoped_ptr_impl.
template <typename U, typename V>
scoped_ptr_impl(scoped_ptr_impl<U, V>* other)
: data_(other->release(), other->get_deleter()) {
// We do not support move-only deleters. We could modify our move
// emulation to have base::subtle::move() and base::subtle::forward()
// functions that are imperfect emulations of their C++11 equivalents,
// but until there's a requirement, just assume deleters are copyable.
}
template <typename U, typename V>
void TakeState(scoped_ptr_impl<U, V>* other) {
// See comment in templated constructor above regarding lack of support
// for move-only deleters.
reset(other->release());
get_deleter() = other->get_deleter();
}
~scoped_ptr_impl() {
if (data_.ptr != NULL) {
// Not using get_deleter() saves one function call in non-optimized
// builds.
static_cast<D&>(data_)(data_.ptr);
}
}
void reset(T* p) {
// This is a self-reset, which is no longer allowed: http://crbug.com/162971
if (p != NULL && p == data_.ptr)
abort();
// Note that running data_.ptr = p can lead to undefined behavior if
// get_deleter()(get()) deletes this. In order to pevent this, reset()
// should update the stored pointer before deleting its old value.
//
// However, changing reset() to use that behavior may cause current code to
// break in unexpected ways. If the destruction of the owned object
// dereferences the scoped_ptr when it is destroyed by a call to reset(),
// then it will incorrectly dispatch calls to |p| rather than the original
// value of |data_.ptr|.
//
// During the transition period, set the stored pointer to NULL while
// deleting the object. Eventually, this safety check will be removed to
// prevent the scenario initially described from occuring and
// http://crbug.com/176091 can be closed.
T* old = data_.ptr;
data_.ptr = NULL;
if (old != NULL)
static_cast<D&>(data_)(old);
data_.ptr = p;
}
T* get() const { return data_.ptr; }
D& get_deleter() { return data_; }
const D& get_deleter() const { return data_; }
void swap(scoped_ptr_impl& p2) {
// Standard swap idiom: 'using std::swap' ensures that std::swap is
// present in the overload set, but we call swap unqualified so that
// any more-specific overloads can be used, if available.
using std::swap;
swap(static_cast<D&>(data_), static_cast<D&>(p2.data_));
swap(data_.ptr, p2.data_.ptr);
}
T* release() {
T* old_ptr = data_.ptr;
data_.ptr = NULL;
return old_ptr;
}
private:
// Needed to allow type-converting constructor.
template <typename U, typename V> friend class scoped_ptr_impl;
// Use the empty base class optimization to allow us to have a D
// member, while avoiding any space overhead for it when D is an
// empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good
// discussion of this technique.
struct Data : public D {
explicit Data(T* ptr_in) : ptr(ptr_in) {}
Data(T* ptr_in, const D& other) : D(other), ptr(ptr_in) {}
T* ptr;
};
Data data_;
DISALLOW_COPY_AND_ASSIGN(scoped_ptr_impl);
};
// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
// automatically deletes the pointer it holds (if any).
// That is, scoped_ptr<T> owns the T object that it points to.
// Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
// Also like T*, scoped_ptr<T> is thread-compatible, and once you
// dereference it, you get the thread safety guarantees of T.
//
// The size of scoped_ptr is small. On most compilers, when using the
// DefaultDeleter, sizeof(scoped_ptr<T>) == sizeof(T*). Custom deleters will
// increase the size proportional to whatever state they need to have. See
// comments inside scoped_ptr_impl<> for details.
//
// Current implementation targets having a strict subset of C++11's
// unique_ptr<> features. Known deficiencies include not supporting move-only
// deleteres, function pointers as deleters, and deleters with reference
// types.
template <class T, class D = DefaultDeleter<T> >
class scoped_ptr {
public:
// The element and deleter types.
typedef T element_type;
typedef D deleter_type;
// Constructor. Defaults to initializing with NULL.
scoped_ptr() : impl_(NULL) { }
// Constructor. Takes ownership of p.
explicit scoped_ptr(element_type* p) : impl_(p) { }
// Constructor. Allows initialization of a stateful deleter.
scoped_ptr(element_type* p, const D& d) : impl_(p, d) { }
// Constructor. Allows construction from a scoped_ptr rvalue for a
// convertible type and deleter.
//
// IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this constructor distinct
// from the normal move constructor. By C++11 20.7.1.2.1.21, this constructor
// has different post-conditions if D is a reference type. Since this
// implementation does not support deleters with reference type,
// we do not need a separate move constructor allowing us to avoid one
// use of SFINAE. You only need to care about this if you modify the
// implementation of scoped_ptr.
template <typename U, typename V>
scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
COMPILE_ASSERT(!is_array<U>::value, U_cannot_be_an_array);
}
// operator=. Allows assignment from a scoped_ptr rvalue for a convertible
// type and deleter.
//
// IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this operator= distinct from
// the normal move assignment operator. By C++11 20.7.1.2.3.4, this templated
// form has different requirements on for move-only Deleters. Since this
// implementation does not support move-only Deleters, we do not need a
// separate move assignment operator allowing us to avoid one use of SFINAE.
// You only need to care about this if you modify the implementation of
// scoped_ptr.
template <typename U, typename V>
scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
COMPILE_ASSERT(!is_array<U>::value, U_cannot_be_an_array);
impl_.TakeState(&rhs.impl_);
return *this;
}
// Reset. Deletes the currently owned object, if any.
// Then takes ownership of a new object, if given.
void reset(element_type* p = NULL) { impl_.reset(p); }
// Accessors to get the owned object.
// operator* and operator-> will assert() if there is no current object.
element_type& operator*() const {
assert(impl_.get() != NULL);
return *impl_.get();
}
element_type* operator->() const {
assert(impl_.get() != NULL);
return impl_.get();
}
element_type* get() const { return impl_.get(); }
// Access to the deleter.
deleter_type& get_deleter() { return impl_.get_deleter(); }
const deleter_type& get_deleter() const { return impl_.get_deleter(); }
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
// implicitly convertible to a real bool (which is dangerous).
private:
typedef scoped_ptr_impl<element_type, deleter_type> scoped_ptr::*Testable;
public:
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
// Comparison operators.
// These return whether two scoped_ptr refer to the same object, not just to
// two different but equal objects.
bool operator==(const element_type* p) const { return impl_.get() == p; }
bool operator!=(const element_type* p) const { return impl_.get() != p; }
// Swap two scoped pointers.
void swap(scoped_ptr& p2) {
impl_.swap(p2.impl_);
}
// Release a pointer.
// The return value is the current pointer held by this object.
// If this object holds a NULL pointer, the return value is NULL.
// After this operation, this object will hold a NULL pointer,
// and will not own the object any more.
element_type* release() {
return impl_.release();
}
private:
// Needed to reach into |impl_| in the constructor.
template <typename U, typename V> friend class scoped_ptr;
scoped_ptr_impl<element_type, deleter_type> impl_;
// Forbid comparison of scoped_ptr types. If U != T, it totally
// doesn't make sense, and if U == T, it still doesn't make sense
// because you should never have the same object owned by two different
// scoped_ptrs.
template <class U> bool operator==(scoped_ptr<U> const& p2) const;
template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
};
template <class T, class D>
class scoped_ptr<T[], D> {
public:
// The element and deleter types.
typedef T element_type;
typedef D deleter_type;
// Constructor. Defaults to initializing with NULL.
scoped_ptr() : impl_(NULL) { }
// Constructor. Stores the given array. Note that the argument's type
// must exactly match T*. In particular:
// - it cannot be a pointer to a type derived from T, because it is
// inherently unsafe in the general case to access an array through a
// pointer whose dynamic type does not match its static type (eg., if
// T and the derived types had different sizes access would be
// incorrectly calculated). Deletion is also always undefined
// (C++98 [expr.delete]p3). If you're doing this, fix your code.
// - it cannot be NULL, because NULL is an integral expression, not a
// pointer to T. Use the no-argument version instead of explicitly
// passing NULL.
// - it cannot be const-qualified differently from T per unique_ptr spec
// (http://cplusplus.github.com/LWG/lwg-active.html#2118). Users wanting
// to work around this may use implicit_cast<const T*>().
// However, because of the first bullet in this comment, users MUST
// NOT use implicit_cast<Base*>() to upcast the static type of the array.
explicit scoped_ptr(element_type* array) : impl_(array) { }
// Reset. Deletes the currently owned array, if any.
// Then takes ownership of a new object, if given.
void reset(element_type* array = NULL) { impl_.reset(array); }
// Accessors to get the owned array.
element_type& operator[](size_t i) const {
assert(impl_.get() != NULL);
return impl_.get()[i];
}
element_type* get() const { return impl_.get(); }
// Access to the deleter.
deleter_type& get_deleter() { return impl_.get_deleter(); }
const deleter_type& get_deleter() const { return impl_.get_deleter(); }
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
// implicitly convertible to a real bool (which is dangerous).
private:
typedef scoped_ptr_impl<element_type, deleter_type> scoped_ptr::*Testable;
public:
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
// Comparison operators.
// These return whether two scoped_ptr refer to the same object, not just to
// two different but equal objects.
bool operator==(element_type* array) const { return impl_.get() == array; }
bool operator!=(element_type* array) const { return impl_.get() != array; }
// Swap two scoped pointers.
void swap(scoped_ptr& p2) {
impl_.swap(p2.impl_);
}
// Release a pointer.
// The return value is the current pointer held by this object.
// If this object holds a NULL pointer, the return value is NULL.
// After this operation, this object will hold a NULL pointer,
// and will not own the object any more.
element_type* release() {
return impl_.release();
}
private:
// Force element_type to be a complete type.
enum { type_must_be_complete = sizeof(element_type) };
// Actually hold the data.
scoped_ptr_impl<element_type, deleter_type> impl_;
// Disable initialization from any type other than element_type*, by
// providing a constructor that matches such an initialization, but is
// private and has no definition. This is disabled because it is not safe to
// call delete[] on an array whose static type does not match its dynamic
// type.
template <typename U> explicit scoped_ptr(U* array);
explicit scoped_ptr(int disallow_construction_from_null);
// Disable reset() from any type other than element_type*, for the same
// reasons as the constructor above.
template <typename U> void reset(U* array);
void reset(int disallow_reset_from_null);
// Forbid comparison of scoped_ptr types. If U != T, it totally
// doesn't make sense, and if U == T, it still doesn't make sense
// because you should never have the same object owned by two different
// scoped_ptrs.
template <class U> bool operator==(scoped_ptr<U> const& p2) const;
template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
};
// Free functions
template <class T, class D>
void swap(scoped_ptr<T, D>& p1, scoped_ptr<T, D>& p2) {
p1.swap(p2);
}
template <class T, class D>
bool operator==(T* p1, const scoped_ptr<T, D>& p2) {
return p1 == p2.get();
}
template <class T, class D>
bool operator!=(T* p1, const scoped_ptr<T, D>& p2) {
return p1 != p2.get();
}
// A function to convert T* into scoped_ptr<T>
// Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation
// for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
template <typename T>
scoped_ptr<T> make_scoped_ptr(T* ptr) {
return scoped_ptr<T>(ptr);
}
} // namespace phonenumbers
} // namespace i18n
#endif // !I18N_PHONENUMBERS_USE_BOOST
#endif // I18N_PHONENUMBERS_BASE_MEMORY_SCOPED_PTR_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/memory/scoped_ptr.h
|
C++
|
unknown
| 16,981
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#ifndef I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_H_
#define I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_H_
#if defined(I18N_PHONENUMBERS_USE_BOOST)
#include <boost/scoped_ptr.hpp>
#include <boost/thread/once.hpp>
#include <boost/utility.hpp>
namespace i18n {
namespace phonenumbers {
template <class T>
class Singleton : private boost::noncopyable {
public:
virtual ~Singleton() {}
static T* GetInstance() {
boost::call_once(Init, flag);
return instance.get();
}
private:
static void Init() {
instance.reset(new T());
}
static boost::scoped_ptr<T> instance;
static boost::once_flag flag;
};
template <class T> boost::scoped_ptr<T> Singleton<T>::instance;
template <class T> boost::once_flag Singleton<T>::flag = BOOST_ONCE_INIT;
} // namespace phonenumbers
} // namespace i18n
#else // !I18N_PHONENUMBERS_USE_BOOST
#include "phonenumbers/base/logging.h"
#include "phonenumbers/base/thread_checker.h"
#if !defined(__linux__) && !defined(__APPLE__)
namespace i18n {
namespace phonenumbers {
// Note that this implementation is not thread-safe. For a thread-safe
// implementation on non-POSIX platforms, please compile with
// -DI18N_PHONENUMBERS_USE_BOOST.
template <class T>
class Singleton {
public:
Singleton() : thread_checker_() {}
virtual ~Singleton() {}
static T* GetInstance() {
static T* instance = NULL;
if (!instance) {
instance = new T();
}
DCHECK(instance->thread_checker_.CalledOnValidThread());
return instance;
}
private:
const ThreadChecker thread_checker_;
};
} // namespace phonenumbers
} // namespace i18n
#else
#include "phonenumbers/base/memory/singleton_posix.h"
#endif // !defined(__linux__) && !defined(__APPLE__)
#endif // !I18N_PHONENUMBERS_USE_BOOST
#endif // I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/memory/singleton.h
|
C++
|
unknown
| 2,450
|
// Copyright (C) 2013 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_POSIX_H_
#define I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_POSIX_H_
#include <pthread.h>
#include "phonenumbers/base/logging.h"
namespace i18n {
namespace phonenumbers {
template <class T>
class Singleton {
public:
virtual ~Singleton() {}
static T* GetInstance() {
const int ret = pthread_once(&once_control_, &Init);
(void) ret;
DCHECK_EQ(0, ret);
return instance_;
}
private:
static void Init() {
instance_ = new T();
}
static T* instance_; // Leaky singleton.
static pthread_once_t once_control_;
};
template <class T> T* Singleton<T>::instance_;
template <class T> pthread_once_t Singleton<T>::once_control_ =
PTHREAD_ONCE_INIT;
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_POSIX_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/memory/singleton_posix.h
|
C++
|
unknown
| 1,444
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copied from strings/stringpiece.cc with modifications
#include <algorithm>
#include <ostream>
#include "phonenumbers/base/strings/string_piece.h"
namespace i18n {
namespace phonenumbers {
typedef StringPiece::size_type size_type;
std::ostream& operator<<(std::ostream& o, const StringPiece& piece) {
o.write(piece.data(), static_cast<std::streamsize>(piece.size()));
return o;
}
bool operator==(const StringPiece& x, const StringPiece& y) {
if (x.size() != y.size())
return false;
return StringPiece::wordmemcmp(x.data(), y.data(), x.size()) == 0;
}
void StringPiece::CopyToString(std::string* target) const {
target->assign(!empty() ? data() : "", size());
}
void StringPiece::AppendToString(std::string* target) const {
if (!empty())
target->append(data(), size());
}
size_type StringPiece::copy(char* buf, size_type n, size_type pos) const {
size_type ret = std::min(length_ - pos, n);
memcpy(buf, ptr_ + pos, ret);
return ret;
}
size_type StringPiece::find(const StringPiece& s, size_type pos) const {
if (pos > length_)
return npos;
const char* result = std::search(ptr_ + pos, ptr_ + length_,
s.ptr_, s.ptr_ + s.length_);
const size_type xpos = result - ptr_;
return xpos + s.length_ <= length_ ? xpos : npos;
}
size_type StringPiece::find(char c, size_type pos) const {
if (pos >= length_)
return npos;
const char* result = std::find(ptr_ + pos, ptr_ + length_, c);
return result != ptr_ + length_ ? static_cast<size_t>(result - ptr_) : npos;
}
size_type StringPiece::rfind(const StringPiece& s, size_type pos) const {
if (length_ < s.length_)
return npos;
if (s.empty())
return std::min(length_, pos);
const char* last = ptr_ + std::min(length_ - s.length_, pos) + s.length_;
const char* result = std::find_end(ptr_, last, s.ptr_, s.ptr_ + s.length_);
return result != last ? static_cast<size_t>(result - ptr_) : npos;
}
size_type StringPiece::rfind(char c, size_type pos) const {
if (length_ == 0)
return npos;
for (size_type i = std::min(pos, length_ - 1); ; --i) {
if (ptr_[i] == c)
return i;
if (i == 0)
break;
}
return npos;
}
// For each character in characters_wanted, sets the index corresponding
// to the ASCII code of that character to 1 in table. This is used by
// the find_.*_of methods below to tell whether or not a character is in
// the lookup table in constant time.
// The argument `table' must be an array that is large enough to hold all
// the possible values of an unsigned char. Thus it should be be declared
// as follows:
// bool table[UCHAR_MAX + 1]
static inline void BuildLookupTable(const StringPiece& characters_wanted,
bool* table) {
const size_type length = characters_wanted.length();
const char* const data = characters_wanted.data();
for (size_type i = 0; i < length; ++i) {
table[static_cast<unsigned char>(data[i])] = true;
}
}
size_type StringPiece::find_first_of(const StringPiece& s,
size_type pos) const {
if (length_ == 0 || s.length_ == 0)
return npos;
// Avoid the cost of BuildLookupTable() for a single-character search.
if (s.length_ == 1)
return find_first_of(s.ptr_[0], pos);
bool lookup[UCHAR_MAX + 1] = { false };
BuildLookupTable(s, lookup);
for (size_type i = pos; i < length_; ++i) {
if (lookup[static_cast<unsigned char>(ptr_[i])]) {
return i;
}
}
return npos;
}
size_type StringPiece::find_first_not_of(const StringPiece& s,
size_type pos) const {
if (length_ == 0)
return npos;
if (s.length_ == 0)
return 0;
// Avoid the cost of BuildLookupTable() for a single-character search.
if (s.length_ == 1)
return find_first_not_of(s.ptr_[0], pos);
bool lookup[UCHAR_MAX + 1] = { false };
BuildLookupTable(s, lookup);
for (size_type i = pos; i < length_; ++i) {
if (!lookup[static_cast<unsigned char>(ptr_[i])]) {
return i;
}
}
return npos;
}
size_type StringPiece::find_first_not_of(char c, size_type pos) const {
if (length_ == 0)
return npos;
for (; pos < length_; ++pos) {
if (ptr_[pos] != c) {
return pos;
}
}
return npos;
}
size_type StringPiece::find_last_of(const StringPiece& s, size_type pos) const {
if (length_ == 0 || s.length_ == 0)
return npos;
// Avoid the cost of BuildLookupTable() for a single-character search.
if (s.length_ == 1)
return find_last_of(s.ptr_[0], pos);
bool lookup[UCHAR_MAX + 1] = { false };
BuildLookupTable(s, lookup);
for (size_type i = std::min(pos, length_ - 1); ; --i) {
if (lookup[static_cast<unsigned char>(ptr_[i])])
return i;
if (i == 0)
break;
}
return npos;
}
size_type StringPiece::find_last_not_of(const StringPiece& s,
size_type pos) const {
if (length_ == 0)
return npos;
size_type i = std::min(pos, length_ - 1);
if (s.length_ == 0)
return i;
// Avoid the cost of BuildLookupTable() for a single-character search.
if (s.length_ == 1)
return find_last_not_of(s.ptr_[0], pos);
bool lookup[UCHAR_MAX + 1] = { false };
BuildLookupTable(s, lookup);
for (; ; --i) {
if (!lookup[static_cast<unsigned char>(ptr_[i])])
return i;
if (i == 0)
break;
}
return npos;
}
size_type StringPiece::find_last_not_of(char c, size_type pos) const {
if (length_ == 0)
return npos;
for (size_type i = std::min(pos, length_ - 1); ; --i) {
if (ptr_[i] != c)
return i;
if (i == 0)
break;
}
return npos;
}
StringPiece StringPiece::substr(size_type pos, size_type n) const {
if (pos > length_) pos = length_;
if (n > length_ - pos) n = length_ - pos;
return StringPiece(ptr_ + pos, n);
}
const StringPiece::size_type StringPiece::npos = size_type(-1);
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/strings/string_piece.cc
|
C++
|
unknown
| 6,148
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copied from strings/stringpiece.h with modifications
//
// A string-like object that points to a sized piece of memory.
//
// Functions or methods may use const StringPiece& parameters to accept either
// a "const char*" or a "string" value that will be implicitly converted to
// a StringPiece. The implicit conversion means that it is often appropriate
// to include this .h file in other files rather than forward-declaring
// StringPiece as would be appropriate for most other Google classes.
//
// Systematic usage of StringPiece is encouraged as it will reduce unnecessary
// conversions from "const char*" to "string" and back again.
//
#ifndef I18N_PHONENUMBERS_BASE_STRINGS_STRING_PIECE_H_
#define I18N_PHONENUMBERS_BASE_STRINGS_STRING_PIECE_H_
#pragma once
#include <string>
#include "phonenumbers/base/basictypes.h"
namespace i18n {
namespace phonenumbers {
class StringPiece {
public:
// standard STL container boilerplate
typedef size_t size_type;
typedef char value_type;
typedef const char* pointer;
typedef const char& reference;
typedef const char& const_reference;
typedef ptrdiff_t difference_type;
typedef const char* const_iterator;
typedef const char* iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
static const size_type npos;
public:
// We provide non-explicit singleton constructors so users can pass
// in a "const char*" or a "string" wherever a "StringPiece" is
// expected.
StringPiece() : ptr_(NULL), length_(0) { }
StringPiece(const char* str)
: ptr_(str), length_((str == NULL) ? 0 : strlen(str)) { }
StringPiece(const std::string& str)
: ptr_(str.data()), length_(str.size()) { }
StringPiece(const char* offset, size_type len)
: ptr_(offset), length_(len) { }
// data() may return a pointer to a buffer with embedded NULs, and the
// returned buffer may or may not be null terminated. Therefore it is
// typically a mistake to pass data() to a routine that expects a NUL
// terminated string.
const char* data() const { return ptr_; }
size_type size() const { return length_; }
size_type length() const { return length_; }
bool empty() const { return length_ == 0; }
void clear() {
ptr_ = NULL;
length_ = 0;
}
void set(const char* data, size_type len) {
ptr_ = data;
length_ = len;
}
void set(const char* str) {
ptr_ = str;
length_ = str ? strlen(str) : 0;
}
void set(const void* data, size_type len) {
ptr_ = reinterpret_cast<const char*>(data);
length_ = len;
}
char operator[](size_type i) const { return ptr_[i]; }
void remove_prefix(size_type n) {
ptr_ += n;
length_ -= n;
}
void remove_suffix(size_type n) {
length_ -= n;
}
int compare(const StringPiece& x) const {
int r = wordmemcmp(
ptr_, x.ptr_, (length_ < x.length_ ? length_ : x.length_));
if (r == 0) {
if (length_ < x.length_) r = -1;
else if (length_ > x.length_) r = +1;
}
return r;
}
std::string as_string() const {
// std::string doesn't like to take a NULL pointer even with a 0 size.
return std::string(!empty() ? data() : "", size());
}
void CopyToString(std::string* target) const;
void AppendToString(std::string* target) const;
// Does "this" start with "x"
bool starts_with(const StringPiece& x) const {
return ((length_ >= x.length_) &&
(wordmemcmp(ptr_, x.ptr_, x.length_) == 0));
}
// Does "this" end with "x"
bool ends_with(const StringPiece& x) const {
return ((length_ >= x.length_) &&
(wordmemcmp(ptr_ + (length_-x.length_), x.ptr_, x.length_) == 0));
}
iterator begin() const { return ptr_; }
iterator end() const { return ptr_ + length_; }
const_reverse_iterator rbegin() const {
return const_reverse_iterator(ptr_ + length_);
}
const_reverse_iterator rend() const {
return const_reverse_iterator(ptr_);
}
size_type max_size() const { return length_; }
size_type capacity() const { return length_; }
size_type copy(char* buf, size_type n, size_type pos = 0) const;
size_type find(const StringPiece& s, size_type pos = 0) const;
size_type find(char c, size_type pos = 0) const;
size_type rfind(const StringPiece& s, size_type pos = npos) const;
size_type rfind(char c, size_type pos = npos) const;
size_type find_first_of(const StringPiece& s, size_type pos = 0) const;
size_type find_first_of(char c, size_type pos = 0) const {
return find(c, pos);
}
size_type find_first_not_of(const StringPiece& s, size_type pos = 0) const;
size_type find_first_not_of(char c, size_type pos = 0) const;
size_type find_last_of(const StringPiece& s, size_type pos = npos) const;
size_type find_last_of(char c, size_type pos = npos) const {
return rfind(c, pos);
}
size_type find_last_not_of(const StringPiece& s, size_type pos = npos) const;
size_type find_last_not_of(char c, size_type pos = npos) const;
StringPiece substr(size_type pos, size_type n = npos) const;
static int wordmemcmp(const char* p, const char* p2, size_type N) {
return memcmp(p, p2, N);
}
private:
const char* ptr_;
size_type length_;
};
bool operator==(const StringPiece& x, const StringPiece& y);
inline bool operator!=(const StringPiece& x, const StringPiece& y) {
return !(x == y);
}
inline bool operator<(const StringPiece& x, const StringPiece& y) {
const int r = StringPiece::wordmemcmp(
x.data(), y.data(), (x.size() < y.size() ? x.size() : y.size()));
return ((r < 0) || ((r == 0) && (x.size() < y.size())));
}
inline bool operator>(const StringPiece& x, const StringPiece& y) {
return y < x;
}
inline bool operator<=(const StringPiece& x, const StringPiece& y) {
return !(x > y);
}
inline bool operator>=(const StringPiece& x, const StringPiece& y) {
return !(x < y);
}
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_STRINGS_STRING_PIECE_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/strings/string_piece.h
|
C++
|
unknown
| 6,199
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#ifndef I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_H_
#define I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_H_
#if defined(I18N_PHONENUMBERS_USE_BOOST)
#include <boost/thread/mutex.hpp>
namespace i18n {
namespace phonenumbers {
typedef boost::mutex Lock;
typedef boost::mutex::scoped_lock AutoLock;
} // namespace phonenumbers
} // namespace i18n
#else // I18N_PHONENUMBERS_USE_BOOST
#include "phonenumbers/base/logging.h"
#include "phonenumbers/base/thread_checker.h"
// C++11 Lock implementation based on std::mutex.
#if __cplusplus>=201103L
#include <mutex>
namespace i18n {
namespace phonenumbers {
class Lock {
public:
Lock() = default;
void Acquire() const {
mutex_.lock();
}
void Release() const {
mutex_.unlock();
}
private:
mutable std::mutex mutex_;
};
} // namespace phonenumbers
} // namespace i18n
// Dummy lock implementation on non-POSIX platforms. If you are running on a
// different platform and care about thread-safety, please compile with
// -DI18N_PHONENUMBERS_USE_BOOST.
#elif !defined(__linux__) && !defined(__APPLE__)
namespace i18n {
namespace phonenumbers {
class Lock {
public:
Lock() {}
void Acquire() const {
DCHECK(thread_checker_.CalledOnValidThread());
IGNORE_UNUSED(thread_checker_);
}
void Release() const {
DCHECK(thread_checker_.CalledOnValidThread());
IGNORE_UNUSED(thread_checker_);
}
private:
const ThreadChecker thread_checker_;
};
} // namespace phonenumbers
} // namespace i18n
#else
#include "phonenumbers/base/synchronization/lock_posix.h"
#endif
namespace i18n {
namespace phonenumbers {
class AutoLock {
public:
AutoLock(Lock& lock) : lock_(lock) {
lock_.Acquire();
}
~AutoLock() {
lock_.Release();
}
private:
Lock& lock_;
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_USE_BOOST
#endif // I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/synchronization/lock.h
|
C++
|
unknown
| 2,555
|
// Copyright (C) 2013 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#ifndef I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_POSIX_H_
#define I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_POSIX_H_
#include <pthread.h>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/logging.h"
namespace i18n {
namespace phonenumbers {
class Lock {
public:
Lock() {
const int ret = pthread_mutex_init(&mutex_, NULL);
(void) ret;
DCHECK_EQ(0, ret);
}
~Lock() {
const int ret = pthread_mutex_destroy(&mutex_);
(void) ret;
DCHECK_EQ(0, ret);
}
void Acquire() const {
int ret = pthread_mutex_lock(&mutex_);
(void) ret;
DCHECK_EQ(0, ret);
}
void Release() const {
int ret = pthread_mutex_unlock(&mutex_);
(void) ret;
DCHECK_EQ(0, ret);
}
private:
DISALLOW_COPY_AND_ASSIGN(Lock);
mutable pthread_mutex_t mutex_;
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_POSIX_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/synchronization/lock_posix.h
|
C++
|
unknown
| 1,565
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef I18N_PHONENUMBERS_BASE_TEMPLATE_UTIL_H_
#define I18N_PHONENUMBERS_BASE_TEMPLATE_UTIL_H_
#include <cstddef> // For size_t.
namespace i18n {
namespace phonenumbers {
// template definitions from tr1
template<class T, T v>
struct integral_constant {
static const T value = v;
typedef T value_type;
typedef integral_constant<T, v> type;
};
template <class T, T v> const T integral_constant<T, v>::value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
template <class T> struct is_pointer : false_type {};
template <class T> struct is_pointer<T*> : true_type {};
template <class T, class U> struct is_same : public false_type {};
template <class T> struct is_same<T,T> : true_type {};
template<class> struct is_array : public false_type {};
template<class T, size_t n> struct is_array<T[n]> : public true_type {};
template<class T> struct is_array<T[]> : public true_type {};
template <class T> struct is_non_const_reference : false_type {};
template <class T> struct is_non_const_reference<T&> : true_type {};
template <class T> struct is_non_const_reference<const T&> : false_type {};
template <class T> struct is_void : false_type {};
template <> struct is_void<void> : true_type {};
namespace internal {
// Types YesType and NoType are guaranteed such that sizeof(YesType) <
// sizeof(NoType).
typedef char YesType;
struct NoType {
YesType dummy[2];
};
// This class is an implementation detail for is_convertible, and you
// don't need to know how it works to use is_convertible. For those
// who care: we declare two different functions, one whose argument is
// of type To and one with a variadic argument list. We give them
// return types of different size, so we can use sizeof to trick the
// compiler into telling us which function it would have chosen if we
// had called it with an argument of type From. See Alexandrescu's
// _Modern C++ Design_ for more details on this sort of trick.
struct ConvertHelper {
template <typename To>
static YesType Test(To);
template <typename To>
static NoType Test(...);
template <typename From>
static From& Create();
};
// Used to determine if a type is a struct/union/class. Inspired by Boost's
// is_class type_trait implementation.
struct IsClassHelper {
template <typename C>
static YesType Test(void(C::*)(void));
template <typename C>
static NoType Test(...);
};
} // namespace internal
// Inherits from true_type if From is convertible to To, false_type otherwise.
//
// Note that if the type is convertible, this will be a true_type REGARDLESS
// of whether or not the conversion would emit a warning.
template <typename From, typename To>
struct is_convertible
: integral_constant<bool,
sizeof(internal::ConvertHelper::Test<To>(
internal::ConvertHelper::Create<From>())) ==
sizeof(internal::YesType)> {
};
template <typename T>
struct is_class
: integral_constant<bool,
sizeof(internal::IsClassHelper::Test<T>(0)) ==
sizeof(internal::YesType)> {
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_TEMPLATE_UTIL_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/template_util.h
|
C++
|
unknown
| 3,435
|
// Copyright (C) 2013 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#ifndef I18N_PHONENUMBERS_BASE_THREAD_CHECKER_H_
#define I18N_PHONENUMBERS_BASE_THREAD_CHECKER_H_
#if !defined(I18N_PHONENUMBERS_USE_BOOST)
// Note that I18N_PHONENUMBERS_NO_THREAD_SAFETY must be defined only to let the
// user of the library know that it can't be used in a thread-safe manner when
// it is not depending on Boost.
#if !defined(__linux__) && !defined(__APPLE__) && \
!defined(I18N_PHONENUMBERS_NO_THREAD_SAFETY)
#error Building without Boost, please provide \
-DI18N_PHONENUMBERS_NO_THREAD_SAFETY
#endif
#endif
#if !defined(NDEBUG) && !defined(I18N_PHONENUMBERS_USE_BOOST) && \
(defined(__linux__) || defined(__apple__))
#include <pthread.h>
namespace i18n {
namespace phonenumbers {
class ThreadChecker {
public:
ThreadChecker() : thread_id_(pthread_self()) {}
bool CalledOnValidThread() const {
return thread_id_ == pthread_self();
}
private:
const pthread_t thread_id_;
};
#else
namespace i18n {
namespace phonenumbers {
class ThreadChecker {
public:
bool CalledOnValidThread() const {
return true;
}
};
#endif
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_THREAD_CHECKER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/base/thread_checker.h
|
C++
|
unknown
| 1,817
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Philippe Liard.
//
// Light implementation emulating base/callback.h. This is an internal header,
// users should not depend on it.
// Note that this implementation is very limited for now and
// libphonenumber-specific.
#ifndef I18N_PHONENUMBERS_CALLBACK_H_
#define I18N_PHONENUMBERS_CALLBACK_H_
namespace i18n {
namespace phonenumbers {
template <typename R, typename A1, typename A2, typename A3, typename A4>
class ResultCallback4 {
public:
virtual ~ResultCallback4() {}
virtual R Run(A1 a1, A2 a2, A3 a3, A4 a4) = 0;
};
template <typename R, typename A1, typename A2, typename A3, typename A4>
class FunctionCallback4 : public ResultCallback4<R, A1, A2, A3, A4> {
public:
typedef R (FunctionType)(A1, A2, A3, A4);
explicit FunctionCallback4(FunctionType* function) : function_(function) {}
virtual ~FunctionCallback4() {}
virtual R Run(A1 a1, A2 a2, A3 a3, A4 a4) {
return function_(a1, a2, a3, a4);
}
private:
FunctionType* const function_;
};
template <typename T, typename R, typename A1, typename A2, typename A3,
typename A4>
class ConstMethodCallback4 : public ResultCallback4<R, A1, A2, A3, A4> {
public:
typedef R (T::*MethodType)(A1, A2, A3, A4) const;
ConstMethodCallback4(const T* instance, MethodType method)
: instance_(instance),
method_(method) {}
virtual ~ConstMethodCallback4() {}
virtual R Run(A1 a1, A2 a2, A3 a3, A4 a4) {
return (instance_->*method_)(a1, a2, a3, a4);
}
private:
const T* const instance_;
MethodType const method_;
};
template <typename R, typename A1, typename A2, typename A3, typename A4>
ResultCallback4<R, A1, A2, A3, A4>* NewPermanentCallback(
R (*function)(A1, A2, A3, A4)) {
return new FunctionCallback4<R, A1, A2, A3, A4>(function);
}
template <typename T, typename R, typename A1, typename A2, typename A3,
typename A4>
ResultCallback4<R, A1, A2, A3, A4>* NewPermanentCallback(
const T* instance,
R (T::*method)(A1, A2, A3, A4) const) {
return new ConstMethodCallback4<T, R, A1, A2, A3, A4>(instance, method);
}
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_CALLBACK_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/callback.h
|
C++
|
unknown
| 2,775
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#include <iostream>
#include "phonenumbers/default_logger.h"
namespace i18n {
namespace phonenumbers {
void StdoutLogger::WriteMessage(const string& msg) {
std::cout << " " << msg;
}
void StdoutLogger::WriteLevel() {
int verbosity_level = level();
if (verbosity_level <= 0) {
verbosity_level = LOG_FATAL;
}
std::cout << "[";
// Handle verbose logs first.
if (verbosity_level > LOG_DEBUG) {
std::cout << "VLOG" << (verbosity_level - LOG_DEBUG);
} else {
switch (verbosity_level) {
case LOG_FATAL: std::cout << "FATAL"; break;
#ifdef ERROR // In case ERROR is defined by MSVC (i.e not set to LOG_ERROR).
case ERROR:
#endif
case LOG_ERROR: std::cout << "ERROR"; break;
case LOG_WARNING: std::cout << "WARNING"; break;
case LOG_INFO: std::cout << "INFO"; break;
case LOG_DEBUG: std::cout << "DEBUG"; break;
}
}
std::cout << "]";
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/default_logger.cc
|
C++
|
unknown
| 1,597
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#include "phonenumbers/logger.h"
#include <sstream>
#include <string>
namespace i18n {
namespace phonenumbers {
using i18n::phonenumbers::Logger;
using std::stringstream;
// Class template used to inline the right implementation for the T -> string
// conversion.
template <typename T>
struct ConvertToString;
template <typename T>
struct ConvertToString {
static inline string DoWork(const T& s) {
return string(s);
}
};
template <>
struct ConvertToString<int> {
static inline string DoWork(int n) {
stringstream stream;
stream << n;
string result;
stream >> result;
return result;
}
};
class LoggerHandler {
public:
LoggerHandler(Logger* impl) : impl_(impl) {}
~LoggerHandler() {
if (impl_) {
impl_->WriteMessage("\n");
}
}
template <typename T>
LoggerHandler& operator<<(const T& value) {
if (impl_) {
impl_->WriteMessage(ConvertToString<T>::DoWork(value));
}
return *this;
}
private:
Logger* const impl_;
};
inline LoggerHandler LOG(int n) {
Logger* const logger_impl = Logger::mutable_logger_impl();
if (logger_impl->level() < n) {
return LoggerHandler(NULL);
}
logger_impl->WriteLevel();
return LoggerHandler(logger_impl);
}
inline LoggerHandler VLOG(int n) {
// VLOG(1) is the next logging level after LOG(DEBUG).
n += LOG_DEBUG;
return LOG(n);
}
// Default logger implementation used by PhoneNumberUtil class. It outputs the
// messages to the standard output.
class StdoutLogger : public Logger {
public:
virtual ~StdoutLogger() {}
virtual void WriteLevel();
virtual void WriteMessage(const string& msg);
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/default_logger.h
|
C++
|
unknown
| 2,457
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef I18N_PHONENUMBERS_ENCODING_UTILS_H_
#define I18N_PHONENUMBERS_ENCODING_UTILS_H_
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/utf/unilib.h"
#include "phonenumbers/utf/utf.h"
namespace i18n {
namespace phonenumbers {
class EncodingUtils {
public:
// Decodes one Unicode code-point value from a UTF-8 array. Returns the number
// of bytes read from the array. If the array does not contain valid UTF-8,
// the function stores 0xFFFD in the output variable and returns 1.
static inline int DecodeUTF8Char(const char* in, char32* out) {
Rune r;
int len = chartorune(&r, in);
*out = r;
return len;
}
static const char* AdvanceOneUTF8Character(const char* buf_utf8) {
return buf_utf8 + UniLib::OneCharLen(buf_utf8);
}
static const char* BackUpOneUTF8Character(const char* start,
const char* end) {
while (start < end && UniLib::IsTrailByte(*--end)) {}
return end;
}
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_ENCODING_UTILS_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/encoding_utils.h
|
C++
|
unknown
| 1,691
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Patrick Mezard
#include "phonenumbers/geocoding/area_code_map.h"
#include <cstddef>
#include "phonenumbers/geocoding/default_map_storage.h"
#include "phonenumbers/phonenumber.pb.h"
#include "phonenumbers/phonenumberutil.h"
#include "phonenumbers/stringutil.h"
namespace i18n {
namespace phonenumbers {
AreaCodeMap::AreaCodeMap()
: phone_util_(*PhoneNumberUtil::GetInstance()) {
}
AreaCodeMap::~AreaCodeMap() {
}
void AreaCodeMap::ReadAreaCodeMap(const PrefixDescriptions* descriptions) {
DefaultMapStorage* storage = new DefaultMapStorage();
storage->ReadFromMap(descriptions);
storage_.reset(storage);
}
const char* AreaCodeMap::Lookup(const PhoneNumber& number) const {
const int entries = storage_->GetNumOfEntries();
if (!entries) {
return NULL;
}
string national_number;
phone_util_.GetNationalSignificantNumber(number, &national_number);
int64 phone_prefix;
safe_strto64(SimpleItoa(number.country_code()) + national_number,
&phone_prefix);
const int* const lengths = storage_->GetPossibleLengths();
const int lengths_size = storage_->GetPossibleLengthsSize();
int current_index = entries - 1;
for (int lengths_index = lengths_size - 1; lengths_index >= 0;
--lengths_index) {
const int possible_length = lengths[lengths_index];
string phone_prefix_str = SimpleItoa(phone_prefix);
if (static_cast<int>(phone_prefix_str.length()) > possible_length) {
safe_strto64(phone_prefix_str.substr(0, possible_length), &phone_prefix);
}
current_index = BinarySearch(0, current_index, phone_prefix);
if (current_index < 0) {
return NULL;
}
const int32 current_prefix = storage_->GetPrefix(current_index);
if (phone_prefix == current_prefix) {
return storage_->GetDescription(current_index);
}
}
return NULL;
}
int AreaCodeMap::BinarySearch(int start, int end, int64 value) const {
int current = 0;
while (start <= end) {
current = (start + end) / 2;
int32 current_value = storage_->GetPrefix(current);
if (current_value == value) {
return current;
} else if (current_value > value) {
--current;
end = current;
} else {
start = current + 1;
}
}
return current;
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/area_code_map.cc
|
C++
|
unknown
| 2,907
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Patrick Mezard
#ifndef I18N_PHONENUMBERS_AREA_CODE_MAP_H_
#define I18N_PHONENUMBERS_AREA_CODE_MAP_H_
#include <map>
#include <string>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/memory/scoped_ptr.h"
namespace i18n {
namespace phonenumbers {
using std::map;
using std::string;
class DefaultMapStorage;
class PhoneNumber;
class PhoneNumberUtil;
struct PrefixDescriptions;
// A utility that maps phone number prefixes to a string describing the
// geographical area the prefix covers.
class AreaCodeMap {
public:
AreaCodeMap();
~AreaCodeMap();
// Returns the description of the geographical area the number corresponds
// to. This method distinguishes the case of an invalid prefix and a prefix
// for which the name is not available in the current language. If the
// description is not available in the current language an empty string is
// returned. If no description was found for the provided number, null is
// returned.
const char* Lookup(const PhoneNumber& number) const;
// Creates an AreaCodeMap initialized with area_codes. Note that the
// underlying implementation of this method is expensive thus should
// not be called by time-critical applications.
//
// area_codes maps phone number prefixes to geographical area description.
void ReadAreaCodeMap(const PrefixDescriptions* descriptions);
private:
// Does a binary search for value in the provided array from start to end
// (inclusive). Returns the position if {@code value} is found; otherwise,
// returns the position which has the largest value that is less than value.
// This means if value is the smallest, -1 will be returned.
int BinarySearch(int start, int end, int64 value) const;
const PhoneNumberUtil& phone_util_;
scoped_ptr<const DefaultMapStorage> storage_;
DISALLOW_COPY_AND_ASSIGN(AreaCodeMap);
};
} // namespace phonenumbers
} // namespace i18n
#endif /* I18N_PHONENUMBERS_AREA_CODE_MAP_H_ */
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/area_code_map.h
|
C++
|
unknown
| 2,584
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Patrick Mezard
#include "phonenumbers/geocoding/default_map_storage.h"
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/logging.h"
#include "phonenumbers/geocoding/geocoding_data.h"
namespace i18n {
namespace phonenumbers {
DefaultMapStorage::DefaultMapStorage() {
}
DefaultMapStorage::~DefaultMapStorage() {
}
int32 DefaultMapStorage::GetPrefix(int index) const {
DCHECK_GE(index, 0);
DCHECK_LT(index, prefixes_size_);
return prefixes_[index];
}
const char* DefaultMapStorage::GetDescription(int index) const {
DCHECK_GE(index, 0);
DCHECK_LT(index, prefixes_size_);
return descriptions_[index];
}
void DefaultMapStorage::ReadFromMap(const PrefixDescriptions* descriptions) {
prefixes_ = descriptions->prefixes;
prefixes_size_ = descriptions->prefixes_size;
descriptions_ = descriptions->descriptions;
possible_lengths_ = descriptions->possible_lengths;
possible_lengths_size_ = descriptions->possible_lengths_size;
}
int DefaultMapStorage::GetNumOfEntries() const {
return prefixes_size_;
}
const int* DefaultMapStorage::GetPossibleLengths() const {
return possible_lengths_;
}
int DefaultMapStorage::GetPossibleLengthsSize() const {
return possible_lengths_size_;
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/default_map_storage.cc
|
C++
|
unknown
| 1,896
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Patrick Mezard
//
// Default class for storing area codes.
#ifndef I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_
#define I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_
#include "phonenumbers/base/basictypes.h"
namespace i18n {
namespace phonenumbers {
struct PrefixDescriptions;
// Default area code map storage strategy that is used for data not
// containing description duplications. It is mainly intended to avoid
// the overhead of the string table management when it is actually
// unnecessary (i.e no string duplication).
class DefaultMapStorage {
public:
DefaultMapStorage();
virtual ~DefaultMapStorage();
// Returns the phone number prefix located at the provided index.
int32 GetPrefix(int index) const;
// Gets the description corresponding to the phone number prefix located
// at the provided index. If the description is not available in the current
// language an empty string is returned.
const char* GetDescription(int index) const;
// Sets the internal state of the underlying storage implementation from the
// provided area_codes that maps phone number prefixes to description strings.
void ReadFromMap(const PrefixDescriptions* descriptions);
// Returns the number of entries contained in the area code map.
int GetNumOfEntries() const;
// Returns an array containing the possible lengths of prefixes sorted in
// ascending order.
const int* GetPossibleLengths() const;
// Returns the number of elements in GetPossibleLengths() array.
int GetPossibleLengthsSize() const;
private:
// Sorted sequence of phone number prefixes.
const int32* prefixes_;
int prefixes_size_;
// Sequence of prefix descriptions, in the same order than prefixes_.
const char** descriptions_;
// Sequence of unique possible lengths in ascending order.
const int32* possible_lengths_;
int possible_lengths_size_;
DISALLOW_COPY_AND_ASSIGN(DefaultMapStorage);
};
} // namespace phonenumbers
} // namespace i18n
#endif /* I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_ */
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/default_map_storage.h
|
C++
|
unknown
| 2,636
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This file is generated automatically, do not edit it manually.
#ifndef I18N_PHONENUMBERS_GEOCODING_DATA
#define I18N_PHONENUMBERS_GEOCODING_DATA
#include "phonenumbers/base/basictypes.h"
namespace i18n {
namespace phonenumbers {
struct CountryLanguages {
// Sorted array of language codes.
const char** available_languages;
// Number of elements in available_languages.
const int available_languages_size;
};
struct PrefixDescriptions {
// Sorted array of phone number prefixes.
const int32* prefixes;
// Number of elements in prefixes.
const int prefixes_size;
// Array of phone number prefix descriptions, mapped one to one
// to prefixes.
const char** descriptions;
// Sorted array of unique prefix lengths in base 10.
const int32* possible_lengths;
// Number of elements in possible_lengths.
const int possible_lengths_size;
};
// Returns a sorted array of country calling codes.
const int* get_country_calling_codes();
// Returns the number of country calling codes in
// get_country_calling_codes() array.
int get_country_calling_codes_size();
// Returns the CountryLanguages record for country at index, index
// being in [0, get_country_calling_codes_size()).
const CountryLanguages* get_country_languages(int index);
// Returns a sorted array of prefix language code pairs like
// "1_de" or "82_ko".
const char** get_prefix_language_code_pairs();
// Returns the number of elements in
// get_prefix_language_code_pairs()
int get_prefix_language_code_pairs_size();
// Returns the PrefixDescriptions for language/code pair at index,
// index being in [0, get_prefix_language_code_pairs_size()).
const PrefixDescriptions* get_prefix_descriptions(int index);
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_GEOCODING_DATA
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/geocoding_data.h
|
C++
|
unknown
| 2,414
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Patrick Mezard
#include "phonenumbers/geocoding/mapping_file_provider.h"
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <sstream>
#include <string>
#include "phonenumbers/geocoding/geocoding_data.h"
namespace i18n {
namespace phonenumbers {
using std::string;
namespace {
struct NormalizedLocale {
const char* locale;
const char* normalized_locale;
};
const NormalizedLocale kNormalizedLocales[] = {
{"zh_TW", "zh_Hant"},
{"zh_HK", "zh_Hant"},
{"zh_MO", "zh_Hant"},
};
const char* GetNormalizedLocale(const string& full_locale) {
const int size = sizeof(kNormalizedLocales) / sizeof(*kNormalizedLocales);
for (int i = 0; i != size; ++i) {
if (full_locale.compare(kNormalizedLocales[i].locale) == 0) {
return kNormalizedLocales[i].normalized_locale;
}
}
return NULL;
}
void AppendLocalePart(const string& part, string* full_locale) {
if (!part.empty()) {
full_locale->append("_");
full_locale->append(part);
}
}
void ConstructFullLocale(const string& language, const string& script, const
string& region, string* full_locale) {
full_locale->assign(language);
AppendLocalePart(script, full_locale);
AppendLocalePart(region, full_locale);
}
// Returns true if s1 comes strictly before s2 in lexicographic order.
bool IsLowerThan(const char* s1, const char* s2) {
return strcmp(s1, s2) < 0;
}
// Returns true if languages contains language.
bool HasLanguage(const CountryLanguages* languages, const string& language) {
const char** const start = languages->available_languages;
const char** const end = start + languages->available_languages_size;
const char** const it =
std::lower_bound(start, end, language.c_str(), IsLowerThan);
return it != end && strcmp(language.c_str(), *it) == 0;
}
} // namespace
MappingFileProvider::MappingFileProvider(
const int* country_calling_codes, int country_calling_codes_size,
country_languages_getter get_country_languages)
: country_calling_codes_(country_calling_codes),
country_calling_codes_size_(country_calling_codes_size),
get_country_languages_(get_country_languages) {
}
const string& MappingFileProvider::GetFileName(int country_calling_code,
const string& language,
const string& script,
const string& region,
string* filename) const {
filename->clear();
if (language.empty()) {
return *filename;
}
const int* const country_calling_codes_end = country_calling_codes_ +
country_calling_codes_size_;
const int* const it =
std::lower_bound(country_calling_codes_,
country_calling_codes_end,
country_calling_code);
if (it == country_calling_codes_end || *it != country_calling_code) {
return *filename;
}
const CountryLanguages* const langs =
get_country_languages_(it - country_calling_codes_);
if (langs->available_languages_size > 0) {
string language_code;
FindBestMatchingLanguageCode(langs, language, script, region,
&language_code);
if (!language_code.empty()) {
std::stringstream filename_buf;
filename_buf << country_calling_code << "_" << language_code;
*filename = filename_buf.str();
}
}
return *filename;
}
void MappingFileProvider::FindBestMatchingLanguageCode(
const CountryLanguages* languages, const string& language,
const string& script, const string& region, string* best_match) const {
string full_locale;
ConstructFullLocale(language, script, region, &full_locale);
const char* const normalized_locale = GetNormalizedLocale(full_locale);
if (normalized_locale != NULL) {
string normalized_locale_str(normalized_locale);
if (HasLanguage(languages, normalized_locale_str)) {
best_match->swap(normalized_locale_str);
return;
}
}
if (HasLanguage(languages, full_locale)) {
best_match->swap(full_locale);
return;
}
if (script.empty() != region.empty()) {
if (HasLanguage(languages, language)) {
*best_match = language;
return;
}
} else if (!script.empty() && !region.empty()) {
string lang_with_script(language);
lang_with_script.append("_");
lang_with_script.append(script);
if (HasLanguage(languages, lang_with_script)) {
best_match->swap(lang_with_script);
return;
}
}
string lang_with_region(language);
lang_with_region.append("_");
lang_with_region.append(region);
if (HasLanguage(languages, lang_with_region)) {
best_match->swap(lang_with_region);
return;
}
if (HasLanguage(languages, language)) {
*best_match = language;
return;
}
best_match->clear();
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/mapping_file_provider.cc
|
C++
|
unknown
| 5,519
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Patrick Mezard
#ifndef I18N_PHONENUMBERS_GEOCODING_MAPPING_FILE_PROVIDER_H_
#define I18N_PHONENUMBERS_GEOCODING_MAPPING_FILE_PROVIDER_H_
#include <string>
#include "phonenumbers/base/basictypes.h"
namespace i18n {
namespace phonenumbers {
using std::string;
struct CountryLanguages;
// A utility which knows the data files that are available for the geocoder to
// use. The data files contain mappings from phone number prefixes to text
// descriptions, and are organized by country calling code and language that the
// text descriptions are in.
class MappingFileProvider {
public:
typedef const CountryLanguages* (*country_languages_getter)(int index);
// Initializes a MappingFileProvider with country_calling_codes, a sorted
// list of country_calling_code_size calling codes, and a function
// get_country_languages(int index) returning the CountryLanguage information
// related to the country code at index in country_calling_codes.
MappingFileProvider(const int* country_calling_codes,
int country_calling_code_size,
country_languages_getter get_country_languages);
// Returns the name of the file that contains the mapping data for the
// country_calling_code in the language specified, or an empty string if no
// such file can be found.
// language is a two or three-letter lowercase language code as defined by ISO
// 639. Note that where two different language codes exist (e.g. 'he' and 'iw'
// for Hebrew) we use the one that Java/Android canonicalized on ('iw' in this
// case).
// script is a four-letter titlecase (the first letter is uppercase and the
// rest of the letters are lowercase) ISO script code as defined in ISO 15924.
// region is a two-letter uppercase ISO country code as defined by ISO 3166-1.
const string& GetFileName(int country_calling_code, const string& language,
const string& script, const string& region, string*
filename) const;
private:
void FindBestMatchingLanguageCode(const CountryLanguages* languages,
const string& language,
const string& script,
const string& region,
string* best_match) const;
const int* const country_calling_codes_;
const int country_calling_codes_size_;
const country_languages_getter get_country_languages_;
DISALLOW_COPY_AND_ASSIGN(MappingFileProvider);
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_GEOCODING_MAPPING_FILE_PROVIDER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/mapping_file_provider.h
|
C++
|
unknown
| 3,265
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Patrick Mezard
#include "phonenumbers/geocoding/phonenumber_offline_geocoder.h"
#include <algorithm>
#include <string>
#include <unicode/unistr.h> // NOLINT(build/include_order)
#include "phonenumbers/geocoding/area_code_map.h"
#include "phonenumbers/geocoding/geocoding_data.h"
#include "phonenumbers/geocoding/mapping_file_provider.h"
#include "phonenumbers/phonenumberutil.h"
#include "phonenumbers/stl_util.h"
namespace i18n {
namespace phonenumbers {
using icu::UnicodeString;
using std::string;
namespace {
// Returns true if s1 comes strictly before s2 in lexicographic order.
bool IsLowerThan(const char* s1, const char* s2) {
return strcmp(s1, s2) < 0;
}
} // namespace
PhoneNumberOfflineGeocoder::PhoneNumberOfflineGeocoder() {
Init(get_country_calling_codes(), get_country_calling_codes_size(),
get_country_languages, get_prefix_language_code_pairs(),
get_prefix_language_code_pairs_size(), get_prefix_descriptions);
}
PhoneNumberOfflineGeocoder::PhoneNumberOfflineGeocoder(
const int* country_calling_codes, int country_calling_codes_size,
country_languages_getter get_country_languages,
const char** prefix_language_code_pairs,
int prefix_language_code_pairs_size,
prefix_descriptions_getter get_prefix_descriptions) {
Init(country_calling_codes, country_calling_codes_size,
get_country_languages, prefix_language_code_pairs,
prefix_language_code_pairs_size, get_prefix_descriptions);
}
void PhoneNumberOfflineGeocoder::Init(
const int* country_calling_codes, int country_calling_codes_size,
country_languages_getter get_country_languages,
const char** prefix_language_code_pairs,
int prefix_language_code_pairs_size,
prefix_descriptions_getter get_prefix_descriptions) {
phone_util_ = PhoneNumberUtil::GetInstance();
provider_.reset(new MappingFileProvider(country_calling_codes,
country_calling_codes_size,
get_country_languages));
prefix_language_code_pairs_ = prefix_language_code_pairs;
prefix_language_code_pairs_size_ = prefix_language_code_pairs_size;
get_prefix_descriptions_ = get_prefix_descriptions;
}
PhoneNumberOfflineGeocoder::~PhoneNumberOfflineGeocoder() {
gtl::STLDeleteContainerPairSecondPointers(
available_maps_.begin(), available_maps_.end());
}
const AreaCodeMap* PhoneNumberOfflineGeocoder::GetPhonePrefixDescriptions(
int prefix, const string& language, const string& script,
const string& region) const {
string filename;
provider_->GetFileName(prefix, language, script, region, &filename);
if (filename.empty()) {
return NULL;
}
AreaCodeMaps::const_iterator it = available_maps_.find(filename);
if (it == available_maps_.end()) {
it = LoadAreaCodeMapFromFile(filename);
if (it == available_maps_.end()) {
return NULL;
}
}
return it->second;
}
PhoneNumberOfflineGeocoder::AreaCodeMaps::const_iterator
PhoneNumberOfflineGeocoder::LoadAreaCodeMapFromFile(
const string& filename) const {
const char** const prefix_language_code_pairs_end =
prefix_language_code_pairs_ + prefix_language_code_pairs_size_;
const char** const prefix_language_code_pair =
std::lower_bound(prefix_language_code_pairs_,
prefix_language_code_pairs_end,
filename.c_str(), IsLowerThan);
if (prefix_language_code_pair != prefix_language_code_pairs_end &&
filename.compare(*prefix_language_code_pair) == 0) {
AreaCodeMap* const m = new AreaCodeMap();
m->ReadAreaCodeMap(get_prefix_descriptions_(
prefix_language_code_pair - prefix_language_code_pairs_));
return available_maps_.insert(AreaCodeMaps::value_type(filename, m)).first;
}
return available_maps_.end();
}
string PhoneNumberOfflineGeocoder::GetCountryNameForNumber(
const PhoneNumber& number, const Locale& language) const {
string region_code;
phone_util_->GetRegionCodeForNumber(number, ®ion_code);
return GetRegionDisplayName(®ion_code, language);
}
string PhoneNumberOfflineGeocoder::GetRegionDisplayName(
const string* region_code, const Locale& language) const {
if (region_code == NULL || region_code->compare("ZZ") == 0 ||
region_code->compare(
PhoneNumberUtil::kRegionCodeForNonGeoEntity) == 0) {
return "";
}
UnicodeString udisplay_country;
icu::Locale("", region_code->c_str()).getDisplayCountry(
language, udisplay_country);
string display_country;
udisplay_country.toUTF8String(display_country);
return display_country;
}
string PhoneNumberOfflineGeocoder::GetDescriptionForValidNumber(
const PhoneNumber& number, const Locale& language) const {
const char* const description = GetAreaDescription(
number, language.getLanguage(), "", language.getCountry());
return *description != '\0'
? description
: GetCountryNameForNumber(number, language);
}
string PhoneNumberOfflineGeocoder::GetDescriptionForValidNumber(
const PhoneNumber& number, const Locale& language,
const string& user_region) const {
// If the user region matches the number's region, then we just show the
// lower-level description, if one exists - if no description exists, we will
// show the region(country) name for the number.
string region_code;
phone_util_->GetRegionCodeForNumber(number, ®ion_code);
if (user_region.compare(region_code) == 0) {
return GetDescriptionForValidNumber(number, language);
}
// Otherwise, we just show the region(country) name for now.
return GetRegionDisplayName(®ion_code, language);
}
string PhoneNumberOfflineGeocoder::GetDescriptionForNumber(
const PhoneNumber& number, const Locale& locale) const {
PhoneNumberUtil::PhoneNumberType number_type =
phone_util_->GetNumberType(number);
if (number_type == PhoneNumberUtil::UNKNOWN) {
return "";
} else if (!phone_util_->IsNumberGeographical(number_type,
number.country_code())) {
return GetCountryNameForNumber(number, locale);
}
return GetDescriptionForValidNumber(number, locale);
}
string PhoneNumberOfflineGeocoder::GetDescriptionForNumber(
const PhoneNumber& number, const Locale& language,
const string& user_region) const {
PhoneNumberUtil::PhoneNumberType number_type =
phone_util_->GetNumberType(number);
if (number_type == PhoneNumberUtil::UNKNOWN) {
return "";
} else if (!phone_util_->IsNumberGeographical(number_type,
number.country_code())) {
return GetCountryNameForNumber(number, language);
}
return GetDescriptionForValidNumber(number, language, user_region);
}
const char* PhoneNumberOfflineGeocoder::GetAreaDescription(
const PhoneNumber& number, const string& lang, const string& script,
const string& region) const {
const int country_calling_code = number.country_code();
// NANPA area is not split in C++ code.
const int phone_prefix = country_calling_code;
const AreaCodeMap* const descriptions = GetPhonePrefixDescriptions(
phone_prefix, lang, script, region);
const char* description = descriptions ? descriptions->Lookup(number) : NULL;
// When a location is not available in the requested language, fall back to
// English.
if ((!description || *description == '\0') && MayFallBackToEnglish(lang)) {
const AreaCodeMap* default_descriptions = GetPhonePrefixDescriptions(
phone_prefix, "en", "", "");
if (!default_descriptions) {
return "";
}
description = default_descriptions->Lookup(number);
}
return description ? description : "";
}
// Don't fall back to English if the requested language is among the following:
// - Chinese
// - Japanese
// - Korean
bool PhoneNumberOfflineGeocoder::MayFallBackToEnglish(
const string& lang) const {
return lang.compare("zh") && lang.compare("ja") && lang.compare("ko");
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/phonenumber_offline_geocoder.cc
|
C++
|
unknown
| 8,638
|
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Patrick Mezard
#ifndef I18N_PHONENUMBERS_GEOCODING_PHONENUMBER_OFFLINE_GEOCODER_H_
#define I18N_PHONENUMBERS_GEOCODING_PHONENUMBER_OFFLINE_GEOCODER_H_
#include <map>
#include <string>
#include <unicode/locid.h> // NOLINT(build/include_order)
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/memory/scoped_ptr.h"
namespace i18n {
namespace phonenumbers {
using std::map;
using std::string;
class AreaCodeMap;
class MappingFileProvider;
class PhoneNumber;
class PhoneNumberUtil;
struct CountryLanguages;
struct PrefixDescriptions;
typedef icu::Locale Locale;
// An offline geocoder which provides geographical information related to a
// phone number.
class PhoneNumberOfflineGeocoder {
private:
typedef map<string, const AreaCodeMap*> AreaCodeMaps;
public:
typedef const CountryLanguages* (*country_languages_getter)(int index);
typedef const PrefixDescriptions* (*prefix_descriptions_getter)(int index);
PhoneNumberOfflineGeocoder();
// For tests
PhoneNumberOfflineGeocoder(
const int* country_calling_codes,
int country_calling_codes_size,
country_languages_getter get_country_languages,
const char** prefix_language_code_pairs,
int prefix_language_code_pairs_size,
prefix_descriptions_getter get_prefix_descriptions);
virtual ~PhoneNumberOfflineGeocoder();
// Returns a text description for the given phone number, in the language
// provided. The description might consist of the name of the country where
// the phone number is from, or the name of the geographical area the phone
// number is from if more detailed information is available. Returns an empty
// string if the number could come from multiple countries, or the country
// code is in fact invalid.
//
// This method assumes the validity of the number passed in has already been
// checked, and that the number is suitable for geocoding. We consider
// fixed-line and mobile numbers possible candidates for geocoding.
string GetDescriptionForValidNumber(const PhoneNumber& number,
const Locale& language) const;
// As per GetDescriptionForValidNumber(PhoneNumber, Locale) but also considers
// the region of the user. If the phone number is from the same region as the
// user, only a lower-level description will be returned, if one exists.
// Otherwise, the phone number's region will be returned, with optionally some
// more detailed information.
//
// For example, for a user from the region "US" (United States), we would show
// "Mountain View, CA" for a particular number, omitting the United States
// from the description. For a user from the United Kingdom (region "GB"), for
// the same number we may show "Mountain View, CA, United States" or even just
// "United States".
//
// This method assumes the validity of the number passed in has already been
// checked, and that the number is suitable for geocoding. We consider
// fixed-line and mobile numbers possible candidates for geocoding.
//
// user_region is the region code for a given user. This region will be
// omitted from the description if the phone number comes from this region. It
// should be a two-letter uppercase CLDR region code.
string GetDescriptionForValidNumber(const PhoneNumber& number,
const Locale& language, const string& user_region) const;
// As per GetDescriptionForValidNumber(PhoneNumber, Locale) but explicitly
// checks the validity of the number passed in.
string GetDescriptionForNumber(const PhoneNumber& number,
const Locale& locale) const;
// As per GetDescriptionForValidNumber(PhoneNumber, Locale, String) but
// explicitly checks the validity of the number passed in.
string GetDescriptionForNumber(const PhoneNumber& number,
const Locale& language, const string& user_region) const;
private:
void Init(const int* country_calling_codes,
int country_calling_codes_size,
country_languages_getter get_country_languages,
const char** prefix_language_code_pairs,
int prefix_language_code_pairs_size,
prefix_descriptions_getter get_prefix_descriptions);
const AreaCodeMap* GetPhonePrefixDescriptions(int prefix,
const string& language, const string& script, const string& region) const;
AreaCodeMaps::const_iterator LoadAreaCodeMapFromFile(
const string& filename) const;
// Returns the customary display name in the given language for the given
// region.
string GetRegionDisplayName(const string* region_code,
const Locale& language) const;
// Returns the customary display name in the given language for the given
// territory the phone number is from.
string GetCountryNameForNumber(const PhoneNumber& number,
const Locale& language) const;
// Returns an area-level text description in the given language for the given
// phone number, or an empty string.
// lang is a two or three-letter lowercase ISO language code as defined by ISO
// 639. Note that where two different language codes exist (e.g. 'he' and 'iw'
// for Hebrew) we use the one that Java/Android canonicalized on ('iw' in this
// case).
// script is a four-letter titlecase (the first letter is uppercase and the
// rest of the letters are lowercase) ISO script code as defined in ISO 15924.
// region should be a two-letter uppercase ISO country code as defined by ISO
// 3166-1.
const char* GetAreaDescription(const PhoneNumber& number, const string& lang,
const string& script,
const string& region) const;
bool MayFallBackToEnglish(const string& lang) const;
private:
const PhoneNumberUtil* phone_util_;
// The MappingFileProvider knows for which combination of country calling code
// and language a phone prefix mapping file is available in the file system,
// so that a file can be loaded when needed.
scoped_ptr<const MappingFileProvider> provider_;
const char** prefix_language_code_pairs_;
int prefix_language_code_pairs_size_;
prefix_descriptions_getter get_prefix_descriptions_;
// A mapping from country calling codes languages pairs to the corresponding
// phone prefix map that has been loaded.
mutable AreaCodeMaps available_maps_;
DISALLOW_COPY_AND_ASSIGN(PhoneNumberOfflineGeocoder);
};
} // namespace phonenumbers
} // namespace i18n
#endif /* I18N_PHONENUMBERS_GEOCODING_PHONENUMBER_OFFLINE_GEOCODER_H_ */
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/geocoding/phonenumber_offline_geocoder.h
|
C++
|
unknown
| 7,212
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#include "phonenumbers/logger.h"
#include <cstddef>
namespace i18n {
namespace phonenumbers {
Logger* Logger::impl_ = NULL;
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/logger.cc
|
C++
|
unknown
| 809
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#ifndef I18N_PHONENUMBERS_LOGGER_H_
#define I18N_PHONENUMBERS_LOGGER_H_
#include <cstdio>
#include <string>
namespace i18n {
namespace phonenumbers {
using std::string;
enum {
LOG_FATAL = 1,
LOG_ERROR,
LOG_WARNING,
LOG_INFO,
LOG_DEBUG,
};
enum {
DFATAL = LOG_FATAL,
// ERROR seems to be defined on MSVC, therefore don't overwrite it.
#ifndef ERROR
ERROR = LOG_ERROR,
#endif
WARNING = LOG_WARNING,
};
// Subclass this abstract class to override the way logging is handled in the
// library. You can then call the PhoneNumberUtil::SetLogger() method.
class Logger {
public:
Logger() : level_(LOG_ERROR) {}
virtual ~Logger() {}
// Writes the message level to the underlying output stream.
virtual void WriteLevel() {}
// Writes the provided message to the underlying output stream.
virtual void WriteMessage(const string& msg) = 0;
// Note that if set_verbosity_level has been used to set the level to a value
// that is not represented by an enum, the result here will be a log
// level that is higher than LOG_DEBUG.
inline int level() const {
return level_;
}
inline void set_level(int level) {
level_ = level;
}
// If you want to see verbose logs in addition to other logs, use this method.
// This will result in all log messages at the levels above being shown, along
// with calls to VLOG with the verbosity level set to this level or lower.
// For example, set_verbosity_level(2) will show calls of VLOG(1) and VLOG(2)
// but not VLOG(3), along with all calls to LOG().
inline void set_verbosity_level(int verbose_logs_level) {
set_level(LOG_DEBUG + verbose_logs_level);
}
static inline Logger* set_logger_impl(Logger* logger) {
impl_ = logger;
return logger;
}
static inline Logger* mutable_logger_impl() {
return impl_;
}
private:
static Logger* impl_;
int level_;
};
// Logger that does not log anything. It could be useful to "mute" the
// phonenumber library.
class NullLogger : public Logger {
public:
virtual ~NullLogger() {}
virtual void WriteMessage(const string& /* msg */) {}
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_LOGGER_ADAPTER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/logger.h
|
C++
|
unknown
| 2,839
|
/*
* Copyright (C) 2014 The Libphonenumber Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef I18N_PHONENUMBERS_MATCHER_API_H_
#define I18N_PHONENUMBERS_MATCHER_API_H_
#include <string>
namespace i18n {
namespace phonenumbers {
using std::string;
class PhoneNumberDesc;
// Internal phonenumber matching API used to isolate the underlying
// implementation of the matcher and allow different implementations to be
// swapped in easily.
class MatcherApi {
public:
virtual ~MatcherApi() {}
// Returns whether the given national number (a string containing only decimal
// digits) matches the national number pattern defined in the given
// PhoneNumberDesc message.
virtual bool MatchNationalNumber(const string& number,
const PhoneNumberDesc& number_desc,
bool allow_prefix_match) const = 0;
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_MATCHER_API_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/matcher_api.h
|
C++
|
unknown
| 1,500
|
/*
* Copyright (C) 2011 The Libphonenumber Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef I18N_PHONENUMBERS_METADATA_H_
#define I18N_PHONENUMBERS_METADATA_H_
namespace i18n {
namespace phonenumbers {
int metadata_size();
const void* metadata_get();
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_METADATA_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/metadata.h
|
C++
|
unknown
| 873
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string>
#include "phonenumbers/utf/unicodetext.h"
namespace i18n {
namespace phonenumbers {
struct NormalizeUTF8 {
// Put a UTF-8 string in ASCII digits: All decimal digits (Nd) replaced by
// their ASCII counterparts; all other characters are copied from input to
// output.
static string NormalizeDecimalDigits(const string& number) {
string normalized;
UnicodeText number_as_unicode;
number_as_unicode.PointToUTF8(number.data(), number.size());
for (UnicodeText::const_iterator it = number_as_unicode.begin();
it != number_as_unicode.end();
++it) {
int32_t digitValue = u_charDigitValue(*it);
if (digitValue == -1) {
// Not a decimal digit.
char utf8[4];
int len = it.get_utf8(utf8);
normalized.append(utf8, len);
} else {
normalized.push_back('0' + digitValue);
}
}
return normalized;
}
};
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/normalize_utf8.h
|
C++
|
unknown
| 1,578
|
// Copyright (C) 2009 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#include "phonenumbers/phonemetadata.pb.h"
#include "phonenumbers/phonenumber.pb.h"
namespace i18n {
namespace phonenumbers {
bool ExactlySameAs(const PhoneNumber& first_number,
const PhoneNumber& second_number) {
if (first_number.has_country_code() != second_number.has_country_code() ||
first_number.country_code() != second_number.country_code()) {
return false;
}
if (first_number.has_national_number() !=
second_number.has_national_number() ||
first_number.national_number() != second_number.national_number()) {
return false;
}
if (first_number.has_extension() != second_number.has_extension() ||
first_number.extension() != second_number.extension()) {
return false;
}
if (first_number.has_italian_leading_zero() !=
second_number.has_italian_leading_zero() ||
first_number.italian_leading_zero() !=
second_number.italian_leading_zero()) {
return false;
}
if (first_number.has_number_of_leading_zeros() !=
second_number.has_number_of_leading_zeros() ||
first_number.number_of_leading_zeros() !=
second_number.number_of_leading_zeros()) {
return false;
}
if (first_number.has_raw_input() != second_number.has_raw_input() ||
first_number.raw_input() != second_number.raw_input()) {
return false;
}
if (first_number.has_country_code_source() !=
second_number.has_country_code_source() ||
first_number.country_code_source() !=
second_number.country_code_source()) {
return false;
}
if (first_number.has_preferred_domestic_carrier_code() !=
second_number.has_preferred_domestic_carrier_code() ||
first_number.preferred_domestic_carrier_code() !=
second_number.preferred_domestic_carrier_code()) {
return false;
}
return true;
}
bool ExactlySameAs(const PhoneNumberDesc& first_number_desc,
const PhoneNumberDesc& second_number_desc) {
if (first_number_desc.has_national_number_pattern() !=
second_number_desc.has_national_number_pattern() ||
first_number_desc.national_number_pattern() !=
second_number_desc.national_number_pattern()) {
return false;
}
if (first_number_desc.has_example_number() !=
second_number_desc.has_example_number() ||
first_number_desc.example_number() !=
second_number_desc.example_number()) {
return false;
}
if (first_number_desc.possible_length_size() !=
second_number_desc.possible_length_size()) {
return false;
} else {
for (int i = 0; i < first_number_desc.possible_length_size(); ++i) {
if (first_number_desc.possible_length(i) !=
second_number_desc.possible_length(i)) {
return false;
}
}
}
if (first_number_desc.possible_length_local_only_size() !=
second_number_desc.possible_length_local_only_size()) {
return false;
} else {
for (int i = 0; i < first_number_desc.possible_length_local_only_size();
++i) {
if (first_number_desc.possible_length_local_only(i) !=
second_number_desc.possible_length_local_only(i)) {
return false;
}
}
}
return true;
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/phonenumber.cc
|
C++
|
unknown
| 3,846
|
// Copyright (C) 2009 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#ifndef I18N_PHONENUMBERS_PHONENUMBER_H_
#define I18N_PHONENUMBERS_PHONENUMBER_H_
// Helper functions dealing with PhoneNumber and PhoneNumberDesc comparisons.
namespace i18n {
namespace phonenumbers {
class PhoneNumber;
class PhoneNumberDesc;
// Compares two phone numbers.
bool ExactlySameAs(const PhoneNumber& first_number,
const PhoneNumber& second_number);
// Compares two phone number descriptions.
bool ExactlySameAs(const PhoneNumberDesc& first_number_desc,
const PhoneNumberDesc& second_number_desc);
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_PHONENUMBER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/phonenumber.h
|
C++
|
unknown
| 1,281
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Tao Huang
//
// Implementation of a mutable match of a phone number within a piece of
// text. Matches may be found using PhoneNumberUtil::FindNumbers.
#include "phonenumbers/phonenumbermatch.h"
#include <string>
#include "phonenumbers/phonenumber.h"
#include "phonenumbers/phonenumber.pb.h"
#include "phonenumbers/stringutil.h"
namespace i18n {
namespace phonenumbers {
PhoneNumberMatch::PhoneNumberMatch(int start,
const string& raw_string,
const PhoneNumber& number)
: start_(start), raw_string_(raw_string), number_(number) {
}
PhoneNumberMatch::PhoneNumberMatch()
: start_(-1), raw_string_(""), number_(PhoneNumber::default_instance()) {
}
const PhoneNumber& PhoneNumberMatch::number() const {
return number_;
}
int PhoneNumberMatch::start() const {
return start_;
}
int PhoneNumberMatch::end() const {
return start_ + raw_string_.length();
}
int PhoneNumberMatch::length() const {
return raw_string_.length();
}
const string& PhoneNumberMatch::raw_string() const {
return raw_string_;
}
void PhoneNumberMatch::set_start(int start) {
start_ = start;
}
void PhoneNumberMatch::set_raw_string(const string& raw_string) {
raw_string_ = raw_string;
}
void PhoneNumberMatch::set_number(const PhoneNumber& number) {
number_.CopyFrom(number);
}
string PhoneNumberMatch::ToString() const {
return StrCat("PhoneNumberMatch [", start(), ",", end(), ") ",
raw_string_.c_str());
}
bool PhoneNumberMatch::Equals(const PhoneNumberMatch& match) const {
return ExactlySameAs(match.number_, number_) &&
match.raw_string_.compare(raw_string_) == 0 &&
match.start_ == start_;
}
void PhoneNumberMatch::CopyFrom(const PhoneNumberMatch& match) {
raw_string_ = match.raw_string();
start_ = match.start();
number_ = match.number();
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/phonenumbermatch.cc
|
C++
|
unknown
| 2,531
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Tao Huang
//
// A mutable match of a phone number within a piece of text.
// Matches may be found using PhoneNumberUtil::FindNumbers.
//
// A match consists of the phone number as well as the start and end offsets of
// the corresponding subsequence of the searched text. Use raw_string() to
// obtain a copy of the matched subsequence.
//
// The following annotated example clarifies the relationship between the
// searched text, the match offsets, and the parsed number:
//
// string text = "Call me at +1 425 882-8080 for details.";
// const string country = "US";
//
// // Find the first phone number match:
// PhoneNumberMatcher matcher(text, country);
// if (matcher.HasNext()) {
// PhoneNumberMatch match;
// matcher.Next(&match);
// }
//
// // raw_string() contains the phone number as it appears in the text.
// "+1 425 882-8080" == match.raw_string();
//
// // start() and end() define the range of the matched subsequence.
// string subsequence = text.substr(match.start(), match.end());
// "+1 425 882-8080" == subsequence;
//
// // number() returns the the same result as PhoneNumberUtil::Parse()
// // invoked on raw_string().
// const PhoneNumberUtil& util = *PhoneNumberUtil::GetInstance();
// util.Parse(match.raw_string(), country).Equals(match.number());
//
// This class is a port of PhoneNumberMatch.java
#ifndef I18N_PHONENUMBERS_PHONENUMBERMATCH_H_
#define I18N_PHONENUMBERS_PHONENUMBERMATCH_H_
#include <string>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/phonenumber.pb.h"
namespace i18n {
namespace phonenumbers {
using std::string;
class PhoneNumberMatch {
public:
// Creates a new match.
// - start is the index into the target text.
// - match is the matched string of the target text.
// - number is the matched phone number.
PhoneNumberMatch(int start,
const string& raw_string,
const PhoneNumber& number);
// Default constructor.
PhoneNumberMatch();
~PhoneNumberMatch() {}
// Returns the phone number matched by the receiver.
const PhoneNumber& number() const;
// Returns the start index of the matched phone number within the searched
// text.
int start() const;
// Returns the exclusive end index of the matched phone number within the
// searched text.
int end() const;
// Returns the length of the text matched in the searched text.
int length() const;
// Returns the raw string matched as a phone number in the searched text.
const string& raw_string() const;
// Returns a string containing debug information.
string ToString() const;
void set_start(int start);
void set_raw_string(const string& raw_string);
void set_number(const PhoneNumber& number);
bool Equals(const PhoneNumberMatch& number) const;
void CopyFrom(const PhoneNumberMatch& number);
private:
// The start index into the text.
int start_;
// The raw substring matched.
string raw_string_;
// The matched phone number.
PhoneNumber number_;
DISALLOW_COPY_AND_ASSIGN(PhoneNumberMatch);
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_PHONENUMBERMATCH_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/phonenumbermatch.h
|
C++
|
unknown
| 3,765
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Lara Rennie
// Author: Tao Huang
//
// Implementation of a stateful class that finds and extracts telephone numbers
// from text.
#include "phonenumbers/phonenumbermatcher.h"
#ifndef I18N_PHONENUMBERS_USE_ICU_REGEXP
#error phonenumbermatcher depends on ICU \
(i.e. I18N_PHONENUMBERS_USE_ICU_REGEXP must be set)
#endif // I18N_PHONENUMBERS_USE_ICU_REGEXP
#include <ctype.h>
#include <stddef.h>
#include <limits>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include <unicode/uchar.h>
#include "phonenumbers/alternate_format.h"
#include "phonenumbers/base/logging.h"
#include "phonenumbers/base/memory/scoped_ptr.h"
#include "phonenumbers/base/memory/singleton.h"
#include "phonenumbers/callback.h"
#include "phonenumbers/default_logger.h"
#include "phonenumbers/encoding_utils.h"
#include "phonenumbers/normalize_utf8.h"
#include "phonenumbers/phonemetadata.pb.h"
#include "phonenumbers/phonenumber.pb.h"
#include "phonenumbers/phonenumbermatch.h"
#include "phonenumbers/phonenumberutil.h"
#include "phonenumbers/regexp_adapter.h"
#include "phonenumbers/regexp_adapter_icu.h"
#include "phonenumbers/regexp_cache.h"
#include "phonenumbers/stringutil.h"
#ifdef I18N_PHONENUMBERS_USE_RE2
#include "phonenumbers/regexp_adapter_re2.h"
#endif // I18N_PHONENUMBERS_USE_RE2
using std::map;
using std::numeric_limits;
using std::string;
namespace i18n {
namespace phonenumbers {
namespace {
// Returns a regular expression quantifier with an upper and lower limit.
string Limit(int lower, int upper) {
DCHECK_GE(lower, 0);
DCHECK_GT(upper, 0);
DCHECK_LT(lower, upper);
return StrCat("{", lower, ",", upper, "}");
}
bool IsInvalidPunctuationSymbol(char32 character) {
return character == '%' || u_charType(character) == U_CURRENCY_SYMBOL;
}
bool ContainsOnlyValidXChars(const PhoneNumber& number, const string& candidate,
const PhoneNumberUtil& util) {
// The characters 'x' and 'X' can be (1) a carrier code, in which case they
// always precede the national significant number or (2) an extension sign,
// in which case they always precede the extension number. We assume a
// carrier code is more than 1 digit, so the first case has to have more than
// 1 consecutive 'x' or 'X', whereas the second case can only have exactly 1
// 'x' or 'X'.
size_t found;
found = candidate.find_first_of("xX");
// We ignore the character if 'x' or 'X' appears as the last character of
// the string.
while (found != string::npos && found < candidate.length() - 1) {
// We only look for 'x' or 'X' in ASCII form.
char next_char = candidate[found + 1];
if (next_char == 'x' || next_char == 'X') {
// This is the carrier code case, in which the 'X's always precede the
// national significant number.
++found;
if (util.IsNumberMatchWithOneString(
number, candidate.substr(found, candidate.length() - found))
!= PhoneNumberUtil::NSN_MATCH) {
return false;
}
} else {
string normalized_extension(candidate.substr(found,
candidate.length() - found));
util.NormalizeDigitsOnly(&normalized_extension);
if (normalized_extension != number.extension()) {
return false;
}
}
found = candidate.find_first_of("xX", found + 1);
}
return true;
}
bool AllNumberGroupsRemainGrouped(
const PhoneNumberUtil& util,
const PhoneNumber& number,
const string& normalized_candidate,
const std::vector<string>& formatted_number_groups) {
size_t from_index = 0;
if (number.country_code_source() != PhoneNumber::FROM_DEFAULT_COUNTRY) {
// First skip the country code if the normalized candidate contained it.
string country_code = SimpleItoa(number.country_code());
from_index = normalized_candidate.find(country_code) + country_code.size();
}
// Check each group of consecutive digits are not broken into separate
// groupings in the normalized_candidate string.
for (size_t i = 0; i < formatted_number_groups.size(); ++i) {
// Fails if the substring of normalized_candidate starting from from_index
// doesn't contain the consecutive digits in formatted_number_groups.at(i).
from_index = normalized_candidate.find(formatted_number_groups.at(i),
from_index);
if (from_index == string::npos) {
return false;
}
// Moves from_index forward.
from_index += formatted_number_groups.at(i).length();
if (i == 0 && from_index < normalized_candidate.length()) {
// We are at the position right after the NDC. We get the region used for
// formatting information based on the country code in the phone number,
// rather than the number itself, as we do not need to distinguish between
// different countries with the same country calling code and this is
// faster.
string region;
util.GetRegionCodeForCountryCode(number.country_code(), ®ion);
string ndd_prefix;
util.GetNddPrefixForRegion(region, true, &ndd_prefix);
// Note although normalized_candidate might contain non-ASCII formatting
// characters, they won't be treated as ASCII digits when converted to a
// char.
if (!ndd_prefix.empty() && isdigit(normalized_candidate.at(from_index))) {
// This means there is no formatting symbol after the NDC. In this case,
// we only accept the number if there is no formatting symbol at all in
// the number, except for extensions. This is only important for
// countries with national prefixes.
string national_significant_number;
util.GetNationalSignificantNumber(number, &national_significant_number);
return HasPrefixString(normalized_candidate.substr(
from_index - formatted_number_groups.at(i).length()),
national_significant_number);
}
}
}
// The check here makes sure that we haven't mistakenly already used the
// extension to match the last group of the subscriber number. Note the
// extension cannot have formatting in-between digits.
return normalized_candidate.substr(from_index)
.find(number.extension()) != string::npos;
}
bool LoadAlternateFormats(PhoneMetadataCollection* alternate_formats) {
#if defined(I18N_PHONENUMBERS_USE_ALTERNATE_FORMATS)
if (!alternate_formats->ParseFromArray(alternate_format_get(),
alternate_format_size())) {
LOG(ERROR) << "Could not parse binary data.";
return false;
}
return true;
#else
return false;
#endif
}
} // namespace
class PhoneNumberMatcherRegExps : public Singleton<PhoneNumberMatcherRegExps> {
private:
friend class Singleton<PhoneNumberMatcherRegExps>;
string opening_parens_;
string closing_parens_;
string non_parens_;
// Limit on the number of pairs of brackets in a phone number.
string bracket_pair_limit_;
// Helper strings for the matching_brackets_ pattern.
// An opening bracket at the beginning may not be closed, but subsequent ones
// should be. It's also possible that the leading bracket was dropped, so we
// shouldn't be surprised if we see a closing bracket first.
string leading_maybe_matched_bracket_;
string bracket_pairs_;
// Limit on the number of leading (plus) characters.
string lead_limit_;
// Limit on the number of consecutive punctuation characters.
string punctuation_limit_;
// The maximum number of digits allowed in a digit-separated block. As we
// allow all digits in a single block, this should be set high enough to
// accommodate the entire national number and the international country code.
int digit_block_limit_;
// Limit on the number of blocks separated by punctuation. Uses
// kDigitBlockLimit since some formats use spaces to separate each digit.
string block_limit_;
// A punctuation sequence allowing white space.
string punctuation_;
// A digits block without punctuation.
string digit_sequence_;
// Punctuation that may be at the start of a phone number - brackets and plus
// signs.
string lead_class_chars_;
// Same as lead_class_chars_, but enclosed as a character class.
string lead_class_;
public:
// We use two different reg-ex factories here for performance reasons. RE2 is
// much faster for smaller reg-ex patterns, but the main pattern cannot be
// handled by RE2 in an efficient way.
scoped_ptr<const AbstractRegExpFactory> regexp_factory_for_pattern_;
scoped_ptr<const AbstractRegExpFactory> regexp_factory_;
// A cache for popular reg-exps of leading digits used to match formatting
// patterns and the factory used to create it.
mutable RegExpCache regexp_cache_;
// Matches strings that look like publication pages. Example:
// Computing Complete Answers to Queries in the Presence of Limited Access
// Patterns. Chen Li. VLDB J. 12(3): 211-227 (2003).
//
// The string "211-227 (2003)" is not a telephone number.
scoped_ptr<const RegExp> pub_pages_;
// Matches strings that look like dates using "/" as a separator. Examples:
// 3/10/2011, 31/10/96 or 08/31/95.
scoped_ptr<const RegExp> slash_separated_dates_;
// Matches timestamps. Examples: "2012-01-02 08:00". Note that the reg-ex does
// not include trailing ":\d\d" -- that is covered by time_stamps_suffix_.
scoped_ptr<const RegExp> time_stamps_;
scoped_ptr<const RegExp> time_stamps_suffix_;
// Pattern to check that brackets match. Opening brackets should be closed
// within a phone number. This also checks that there is something inside the
// brackets. Having no brackets at all is also fine.
scoped_ptr<const RegExp> matching_brackets_;
// Patterns used to extract phone numbers from a larger phone-number-like
// pattern. These are ordered according to specificity. For example,
// white-space is last since that is frequently used in numbers, not just to
// separate two numbers. We have separate patterns since we don't want to
// break up the phone-number-like text on more than one different kind of
// symbol at one time, although symbols of the same type (e.g. space) can be
// safely grouped together.
//
// Note that if there is a match, we will always check any text found up to
// the first match as well.
scoped_ptr<std::vector<const RegExp*> > inner_matches_;
scoped_ptr<const RegExp> capture_up_to_second_number_start_pattern_;
scoped_ptr<const RegExp> capturing_ascii_digits_pattern_;
// Compiled reg-ex representing lead_class_;
scoped_ptr<const RegExp> lead_class_pattern_;
// Phone number pattern allowing optional punctuation.
scoped_ptr<const RegExp> pattern_;
PhoneNumberMatcherRegExps()
: opening_parens_("(\\[\xEF\xBC\x88\xEF\xBC\xBB" /* "(\\[([" */),
closing_parens_(")\\]\xEF\xBC\x89\xEF\xBC\xBD" /* ")\\])]" */),
non_parens_(StrCat("[^", opening_parens_, closing_parens_, "]")),
bracket_pair_limit_(Limit(0, 3)),
leading_maybe_matched_bracket_(StrCat(
"(?:[", opening_parens_, "])?",
"(?:", non_parens_, "+[", closing_parens_, "])?")),
bracket_pairs_(StrCat(
"(?:[", opening_parens_, "]", non_parens_, "+",
"[", closing_parens_, "])", bracket_pair_limit_)),
lead_limit_(Limit(0, 2)),
punctuation_limit_(Limit(0, 4)),
digit_block_limit_(PhoneNumberUtil::kMaxLengthForNsn +
PhoneNumberUtil::kMaxLengthCountryCode),
block_limit_(Limit(0, digit_block_limit_)),
punctuation_(StrCat("[", PhoneNumberUtil::kValidPunctuation, "]",
punctuation_limit_)),
digit_sequence_(StrCat("\\p{Nd}", Limit(1, digit_block_limit_))),
lead_class_chars_(StrCat(opening_parens_, PhoneNumberUtil::kPlusChars)),
lead_class_(StrCat("[", lead_class_chars_, "]")),
regexp_factory_for_pattern_(new ICURegExpFactory()),
#ifdef I18N_PHONENUMBERS_USE_RE2
regexp_factory_(new RE2RegExpFactory()),
#else
regexp_factory_(new ICURegExpFactory()),
#endif // I18N_PHONENUMBERS_USE_RE2
// A cache for frequently used country-specific regular expressions. Set
// to 32 to cover ~2-3 countries being used for the same doc with ~10
// patterns for each country. Some pages will have a lot more countries
// in use, but typically fewer numbers for each so expanding the cache
// for that use-case won't have a lot of benefit.
regexp_cache_(*regexp_factory_, 32),
pub_pages_(regexp_factory_->CreateRegExp(
"\\d{1,5}-+\\d{1,5}\\s{0,4}\\(\\d{1,4}")),
slash_separated_dates_(regexp_factory_->CreateRegExp(
"(?:(?:[0-3]?\\d/[01]?\\d)|"
"(?:[01]?\\d/[0-3]?\\d))/(?:[12]\\d)?\\d{2}")),
time_stamps_(regexp_factory_->CreateRegExp(
"[12]\\d{3}[-/]?[01]\\d[-/]?[0-3]\\d +[0-2]\\d$")),
time_stamps_suffix_(regexp_factory_->CreateRegExp(":[0-5]\\d")),
matching_brackets_(regexp_factory_->CreateRegExp(
StrCat(leading_maybe_matched_bracket_, non_parens_, "+",
bracket_pairs_, non_parens_, "*"))),
inner_matches_(new std::vector<const RegExp*>()),
capture_up_to_second_number_start_pattern_(
regexp_factory_->CreateRegExp(
PhoneNumberUtil::kCaptureUpToSecondNumberStart)),
capturing_ascii_digits_pattern_(
regexp_factory_->CreateRegExp("(\\d+)")),
lead_class_pattern_(regexp_factory_->CreateRegExp(lead_class_)),
pattern_(regexp_factory_for_pattern_->CreateRegExp(StrCat(
"((?:", lead_class_, punctuation_, ")", lead_limit_,
digit_sequence_, "(?:", punctuation_, digit_sequence_, ")",
block_limit_, "(?i)(?:",
PhoneNumberUtil::GetInstance()->GetExtnPatternsForMatching(),
")?)"))) {
inner_matches_->push_back(
// Breaks on the slash - e.g. "651-234-2345/332-445-1234"
regexp_factory_->CreateRegExp("/+(.*)"));
inner_matches_->push_back(
// Note that the bracket here is inside the capturing group, since we
// consider it part of the phone number. Will match a pattern like
// "(650) 223 3345 (754) 223 3321".
regexp_factory_->CreateRegExp("(\\([^(]*)"));
inner_matches_->push_back(
// Breaks on a hyphen - e.g. "12345 - 332-445-1234 is my number." We
// require a space on either side of the hyphen for it to be considered
// a separator.
regexp_factory_->CreateRegExp("(?:\\p{Z}-|-\\p{Z})\\p{Z}*(.+)"));
inner_matches_->push_back(
// Various types of wide hyphens. Note we have decided not to enforce a
// space here, since it's possible that it's supposed to be used to
// break two numbers without spaces, and we haven't seen many instances
// of it used within a number.
regexp_factory_->CreateRegExp(
"[\xE2\x80\x92-\xE2\x80\x95\xEF\xBC\x8D]" /* "‒-―-" */
"\\p{Z}*(.+)"));
inner_matches_->push_back(
// Breaks on a full stop - e.g. "12345. 332-445-1234 is my number."
regexp_factory_->CreateRegExp("\\.+\\p{Z}*([^.]+)"));
inner_matches_->push_back(
// Breaks on space - e.g. "3324451234 8002341234"
regexp_factory_->CreateRegExp("\\p{Z}+(\\P{Z}+)"));
}
private:
DISALLOW_COPY_AND_ASSIGN(PhoneNumberMatcherRegExps);
};
class AlternateFormats : public Singleton<AlternateFormats> {
public:
PhoneMetadataCollection format_data_;
map<int, const PhoneMetadata*> calling_code_to_alternate_formats_map_;
AlternateFormats()
: format_data_(),
calling_code_to_alternate_formats_map_() {
if (!LoadAlternateFormats(&format_data_)) {
LOG(DFATAL) << "Could not parse compiled-in metadata.";
return;
}
for (RepeatedPtrField<PhoneMetadata>::const_iterator it =
format_data_.metadata().begin();
it != format_data_.metadata().end();
++it) {
calling_code_to_alternate_formats_map_.insert(
std::make_pair(it->country_code(), &*it));
}
}
const PhoneMetadata* GetAlternateFormatsForCountry(int country_calling_code)
const {
map<int, const PhoneMetadata*>::const_iterator it =
calling_code_to_alternate_formats_map_.find(country_calling_code);
if (it != calling_code_to_alternate_formats_map_.end()) {
return it->second;
}
return NULL;
}
private:
DISALLOW_COPY_AND_ASSIGN(AlternateFormats);
};
PhoneNumberMatcher::PhoneNumberMatcher(const PhoneNumberUtil& util,
const string& text,
const string& region_code,
PhoneNumberMatcher::Leniency leniency,
int max_tries)
: reg_exps_(PhoneNumberMatcherRegExps::GetInstance()),
alternate_formats_(AlternateFormats::GetInstance()),
phone_util_(util),
text_(text),
preferred_region_(region_code),
leniency_(leniency),
max_tries_(max_tries),
state_(NOT_READY),
last_match_(NULL),
search_index_(0) {
}
PhoneNumberMatcher::PhoneNumberMatcher(const string& text,
const string& region_code)
: reg_exps_(PhoneNumberMatcherRegExps::GetInstance()),
alternate_formats_(NULL), // Not used.
phone_util_(*PhoneNumberUtil::GetInstance()),
text_(text),
preferred_region_(region_code),
leniency_(VALID),
max_tries_(numeric_limits<int>::max()),
state_(NOT_READY),
last_match_(NULL),
search_index_(0) {
}
PhoneNumberMatcher::~PhoneNumberMatcher() {
}
// static
bool PhoneNumberMatcher::IsLatinLetter(char32 letter) {
// Combining marks are a subset of non-spacing-mark.
if (!u_isalpha(letter) && (u_charType(letter) != U_NON_SPACING_MARK)) {
return false;
}
UBlockCode block = ublock_getCode(letter);
return ((block == UBLOCK_BASIC_LATIN) ||
(block == UBLOCK_LATIN_1_SUPPLEMENT) ||
(block == UBLOCK_LATIN_EXTENDED_A) ||
(block == UBLOCK_LATIN_EXTENDED_ADDITIONAL) ||
(block == UBLOCK_LATIN_EXTENDED_B) ||
(block == UBLOCK_COMBINING_DIACRITICAL_MARKS));
}
bool PhoneNumberMatcher::ParseAndVerify(const string& candidate, int offset,
PhoneNumberMatch* match) {
DCHECK(match);
// Check the candidate doesn't contain any formatting which would indicate
// that it really isn't a phone number.
if (!reg_exps_->matching_brackets_->FullMatch(candidate) ||
reg_exps_->pub_pages_->PartialMatch(candidate)) {
return false;
}
// If leniency is set to VALID or stricter, we also want to skip numbers that
// are surrounded by Latin alphabetic characters, to skip cases like
// abc8005001234 or 8005001234def.
if (leniency_ >= VALID) {
// If the candidate is not at the start of the text, and does not start with
// phone-number punctuation, check the previous character.
scoped_ptr<RegExpInput> candidate_input(
reg_exps_->regexp_factory_->CreateInput(candidate));
if (offset > 0 &&
!reg_exps_->lead_class_pattern_->Consume(candidate_input.get())) {
char32 previous_char;
const char* previous_char_ptr =
EncodingUtils::BackUpOneUTF8Character(text_.c_str(),
text_.c_str() + offset);
EncodingUtils::DecodeUTF8Char(previous_char_ptr, &previous_char);
// We return false if it is a latin letter or an invalid punctuation
// symbol.
if (IsInvalidPunctuationSymbol(previous_char) ||
IsLatinLetter(previous_char)) {
return false;
}
}
size_t lastCharIndex = offset + candidate.length();
if (lastCharIndex < text_.length()) {
char32 next_char;
const char* next_char_ptr =
EncodingUtils::AdvanceOneUTF8Character(
text_.c_str() + lastCharIndex - 1);
EncodingUtils::DecodeUTF8Char(next_char_ptr, &next_char);
if (IsInvalidPunctuationSymbol(next_char) || IsLatinLetter(next_char)) {
return false;
}
}
}
PhoneNumber number;
if (phone_util_.ParseAndKeepRawInput(candidate, preferred_region_, &number) !=
PhoneNumberUtil::NO_PARSING_ERROR) {
return false;
}
if (VerifyAccordingToLeniency(leniency_, number, candidate)) {
match->set_start(offset);
match->set_raw_string(candidate);
// We used ParseAndKeepRawInput to create this number, but for now we don't
// return the extra values parsed. TODO: stop clearing all values here and
// switch all users over to using raw_input() rather than the raw_string()
// of PhoneNumberMatch.
number.clear_country_code_source();
number.clear_preferred_domestic_carrier_code();
number.clear_raw_input();
match->set_number(number);
return true;
}
return false;
}
// Helper method to replace the verification method for each enum in the Java
// version.
bool PhoneNumberMatcher::VerifyAccordingToLeniency(
Leniency leniency, const PhoneNumber& number,
const string& candidate) const {
switch (leniency) {
case PhoneNumberMatcher::POSSIBLE:
return phone_util_.IsPossibleNumber(number);
case PhoneNumberMatcher::VALID:
if (!phone_util_.IsValidNumber(number) ||
!ContainsOnlyValidXChars(number, candidate, phone_util_)) {
return false;
}
return IsNationalPrefixPresentIfRequired(number);
case PhoneNumberMatcher::STRICT_GROUPING: {
if (!phone_util_.IsValidNumber(number) ||
!ContainsOnlyValidXChars(number, candidate, phone_util_) ||
ContainsMoreThanOneSlashInNationalNumber(
number, candidate, phone_util_) ||
!IsNationalPrefixPresentIfRequired(number)) {
return false;
}
ResultCallback4<bool, const PhoneNumberUtil&, const PhoneNumber&,
const string&, const std::vector<string>&>* callback =
NewPermanentCallback(&AllNumberGroupsRemainGrouped);
bool is_valid = CheckNumberGroupingIsValid(number, candidate, callback);
delete(callback);
return is_valid;
}
case PhoneNumberMatcher::EXACT_GROUPING: {
if (!phone_util_.IsValidNumber(number) ||
!ContainsOnlyValidXChars(number, candidate, phone_util_) ||
ContainsMoreThanOneSlashInNationalNumber(
number, candidate, phone_util_) ||
!IsNationalPrefixPresentIfRequired(number)) {
return false;
}
ResultCallback4<bool, const PhoneNumberUtil&, const PhoneNumber&,
const string&, const std::vector<string>&>* callback =
NewPermanentCallback(
this, &PhoneNumberMatcher::AllNumberGroupsAreExactlyPresent);
bool is_valid = CheckNumberGroupingIsValid(number, candidate, callback);
delete(callback);
return is_valid;
}
default:
LOG(ERROR) << "No implementation defined for verification for leniency "
<< static_cast<int>(leniency);
return false;
}
}
bool PhoneNumberMatcher::ExtractInnerMatch(const string& candidate, int offset,
PhoneNumberMatch* match) {
DCHECK(match);
for (std::vector<const RegExp*>::const_iterator regex =
reg_exps_->inner_matches_->begin();
regex != reg_exps_->inner_matches_->end(); regex++) {
scoped_ptr<RegExpInput> candidate_input(
reg_exps_->regexp_factory_->CreateInput(candidate));
bool is_first_match = true;
string group;
while ((*regex)->FindAndConsume(candidate_input.get(), &group) &&
max_tries_ > 0) {
int group_start_index = candidate.length() -
candidate_input->ToString().length() - group.length();
if (is_first_match) {
// We should handle any group before this one too.
string first_group_only = candidate.substr(0, group_start_index);
phone_util_.TrimUnwantedEndChars(&first_group_only);
bool success = ParseAndVerify(first_group_only, offset, match);
if (success) {
return true;
}
--max_tries_;
is_first_match = false;
}
phone_util_.TrimUnwantedEndChars(&group);
bool success = ParseAndVerify(group, offset + group_start_index, match);
if (success) {
return true;
}
--max_tries_;
}
}
return false;
}
bool PhoneNumberMatcher::ExtractMatch(const string& candidate, int offset,
PhoneNumberMatch* match) {
DCHECK(match);
// Skip a match that is more likely to be a date.
if (reg_exps_->slash_separated_dates_->PartialMatch(candidate)) {
return false;
}
// Skip potential time-stamps.
if (reg_exps_->time_stamps_->PartialMatch(candidate)) {
scoped_ptr<RegExpInput> following_text(
reg_exps_->regexp_factory_->CreateInput(
text_.substr(offset + candidate.size())));
if (reg_exps_->time_stamps_suffix_->Consume(following_text.get())) {
return false;
}
}
// Try to come up with a valid match given the entire candidate.
if (ParseAndVerify(candidate, offset, match)) {
return true;
}
// If that failed, try to find an "inner match" - there might be a phone
// number within this candidate.
return ExtractInnerMatch(candidate, offset, match);
}
bool PhoneNumberMatcher::HasNext() {
if (state_ == NOT_READY) {
PhoneNumberMatch temp_match;
if (!Find(search_index_, &temp_match)) {
state_ = DONE;
} else {
last_match_.reset(new PhoneNumberMatch(temp_match.start(),
temp_match.raw_string(),
temp_match.number()));
search_index_ = last_match_->end();
state_ = READY;
}
}
return state_ == READY;
}
bool PhoneNumberMatcher::Next(PhoneNumberMatch* match) {
DCHECK(match);
// Check the state and find the next match as a side-effect if necessary.
if (!HasNext()) {
return false;
}
match->CopyFrom(*last_match_);
state_ = NOT_READY;
last_match_.reset(NULL);
return true;
}
bool PhoneNumberMatcher::Find(int index, PhoneNumberMatch* match) {
DCHECK(match);
scoped_ptr<RegExpInput> text(
reg_exps_->regexp_factory_for_pattern_->CreateInput(text_.substr(index)));
string candidate;
while ((max_tries_ > 0) &&
reg_exps_->pattern_->FindAndConsume(text.get(), &candidate)) {
int start = text_.length() - text->ToString().length() - candidate.length();
// Check for extra numbers at the end.
reg_exps_->capture_up_to_second_number_start_pattern_->
PartialMatch(candidate, &candidate);
if (ExtractMatch(candidate, start, match)) {
return true;
}
index = start + candidate.length();
--max_tries_;
}
return false;
}
bool PhoneNumberMatcher::CheckNumberGroupingIsValid(
const PhoneNumber& phone_number,
const string& candidate,
ResultCallback4<bool, const PhoneNumberUtil&, const PhoneNumber&,
const string&, const std::vector<string>&>* checker) const {
DCHECK(checker);
string normalized_candidate =
NormalizeUTF8::NormalizeDecimalDigits(candidate);
std::vector<string> formatted_number_groups;
GetNationalNumberGroups(phone_number, &formatted_number_groups);
if (checker->Run(phone_util_, phone_number, normalized_candidate,
formatted_number_groups)) {
return true;
}
// If this didn't pass, see if there are any alternate formats that match, and
// try them instead.
const PhoneMetadata* alternate_formats =
alternate_formats_->GetAlternateFormatsForCountry(
phone_number.country_code());
if (alternate_formats) {
string national_significant_number;
phone_util_.GetNationalSignificantNumber(phone_number,
&national_significant_number);
for (RepeatedPtrField<NumberFormat>::const_iterator it =
alternate_formats->number_format().begin();
it != alternate_formats->number_format().end(); ++it) {
if (it->leading_digits_pattern_size() > 0) {
std::unique_ptr<RegExpInput> nsn_input(
reg_exps_->regexp_factory_->CreateInput(
national_significant_number));
// There is only one leading digits pattern for alternate formats.
if (!reg_exps_->regexp_cache_.GetRegExp(
it->leading_digits_pattern(0)).Consume(nsn_input.get())) {
// Leading digits don't match; try another one.
continue;
}
}
formatted_number_groups.clear();
GetNationalNumberGroupsForPattern(phone_number, &*it,
&formatted_number_groups);
if (checker->Run(phone_util_, phone_number, normalized_candidate,
formatted_number_groups)) {
return true;
}
}
}
return false;
}
void PhoneNumberMatcher::GetNationalNumberGroups(
const PhoneNumber& number,
std::vector<string>* digit_blocks) const {
string rfc3966_format;
// This will be in the format +CC-DG1-DG2-DGX;ext=EXT where DG1..DGX
// represents groups of digits.
phone_util_.Format(number, PhoneNumberUtil::RFC3966, &rfc3966_format);
// We remove the extension part from the formatted string before splitting
// it into different groups.
size_t end_index = rfc3966_format.find(';');
if (end_index == string::npos) {
end_index = rfc3966_format.length();
}
// The country-code will have a '-' following it.
size_t start_index = rfc3966_format.find('-') + 1;
SplitStringUsing(rfc3966_format.substr(start_index,
end_index - start_index),
"-", digit_blocks);
}
void PhoneNumberMatcher::GetNationalNumberGroupsForPattern(
const PhoneNumber& number,
const NumberFormat* formatting_pattern,
std::vector<string>* digit_blocks) const {
string rfc3966_format;
// We format the NSN only, and split that according to the separator.
string national_significant_number;
phone_util_.GetNationalSignificantNumber(number,
&national_significant_number);
phone_util_.FormatNsnUsingPattern(national_significant_number,
*formatting_pattern,
PhoneNumberUtil::RFC3966,
&rfc3966_format);
SplitStringUsing(rfc3966_format, "-", digit_blocks);
}
bool PhoneNumberMatcher::IsNationalPrefixPresentIfRequired(
const PhoneNumber& number) const {
// First, check how we deduced the country code. If it was written in
// international format, then the national prefix is not required.
if (number.country_code_source() != PhoneNumber::FROM_DEFAULT_COUNTRY) {
return true;
}
string phone_number_region;
phone_util_.GetRegionCodeForCountryCode(
number.country_code(), &phone_number_region);
const PhoneMetadata* metadata =
phone_util_.GetMetadataForRegion(phone_number_region);
if (!metadata) {
return true;
}
// Check if a national prefix should be present when formatting this number.
string national_number;
phone_util_.GetNationalSignificantNumber(number, &national_number);
const NumberFormat* format_rule =
phone_util_.ChooseFormattingPatternForNumber(metadata->number_format(),
national_number);
// To do this, we check that a national prefix formatting rule was present and
// that it wasn't just the first-group symbol ($1) with punctuation.
if (format_rule && !format_rule->national_prefix_formatting_rule().empty()) {
if (format_rule->national_prefix_optional_when_formatting()) {
// The national-prefix is optional in these cases, so we don't need to
// check if it was present.
return true;
}
if (phone_util_.FormattingRuleHasFirstGroupOnly(
format_rule->national_prefix_formatting_rule())) {
// National Prefix not needed for this number.
return true;
}
// Normalize the remainder.
string raw_input_copy(number.raw_input());
// Check if we found a national prefix and/or carrier code at the start of
// the raw input, and return the result.
phone_util_.NormalizeDigitsOnly(&raw_input_copy);
return phone_util_.MaybeStripNationalPrefixAndCarrierCode(
*metadata,
&raw_input_copy,
NULL); // Don't need to keep the stripped carrier code.
}
return true;
}
bool PhoneNumberMatcher::AllNumberGroupsAreExactlyPresent(
const PhoneNumberUtil& util,
const PhoneNumber& phone_number,
const string& normalized_candidate,
const std::vector<string>& formatted_number_groups) const {
const scoped_ptr<RegExpInput> candidate_number(
reg_exps_->regexp_factory_->CreateInput(normalized_candidate));
std::vector<string> candidate_groups;
string digit_block;
while (reg_exps_->capturing_ascii_digits_pattern_->FindAndConsume(
candidate_number.get(),
&digit_block)) {
candidate_groups.push_back(digit_block);
}
// Set this to the last group, skipping it if the number has an extension.
int candidate_number_group_index =
phone_number.has_extension() ? candidate_groups.size() - 2
: candidate_groups.size() - 1;
// First we check if the national significant number is formatted as a block.
// We use find and not equals, since the national significant number may be
// present with a prefix such as a national number prefix, or the country code
// itself.
string national_significant_number;
util.GetNationalSignificantNumber(phone_number,
&national_significant_number);
if (candidate_groups.size() == 1 ||
candidate_groups.at(candidate_number_group_index).find(
national_significant_number) != string::npos) {
return true;
}
// Starting from the end, go through in reverse, excluding the first group,
// and check the candidate and number groups are the same.
for (int formatted_number_group_index =
(formatted_number_groups.size() - 1);
formatted_number_group_index > 0 &&
candidate_number_group_index >= 0;
--formatted_number_group_index, --candidate_number_group_index) {
if (candidate_groups.at(candidate_number_group_index) !=
formatted_number_groups.at(formatted_number_group_index)) {
return false;
}
}
// Now check the first group. There may be a national prefix at the start, so
// we only check that the candidate group ends with the formatted number
// group.
return (candidate_number_group_index >= 0 &&
HasSuffixString(candidate_groups.at(candidate_number_group_index),
formatted_number_groups.at(0)));
}
// static
bool PhoneNumberMatcher::ContainsMoreThanOneSlashInNationalNumber(
const PhoneNumber& number,
const string& candidate,
const PhoneNumberUtil& util) {
size_t first_slash_in_body = candidate.find('/');
if (first_slash_in_body == string::npos) {
// No slashes, this is okay.
return false;
}
// Now look for a second one.
size_t second_slash_in_body = candidate.find('/', first_slash_in_body + 1);
if (second_slash_in_body == string::npos) {
// Only one slash, this is okay.
return false;
}
// If the first slash is after the country calling code, this is permitted.
if (number.country_code_source() == PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN ||
number.country_code_source() ==
PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN) {
string normalized_country_code =
candidate.substr(0, first_slash_in_body);
util.NormalizeDigitsOnly(&normalized_country_code);
if (normalized_country_code == SimpleItoa(number.country_code())) {
// Any more slashes and this is illegal.
return candidate.find('/', second_slash_in_body + 1) != string::npos;
}
}
return true;
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/phonenumbermatcher.cc
|
C++
|
unknown
| 36,842
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Lara Rennie
// Author: Tao Huang
//
// This is a direct port from PhoneNumberMatcher.java.
// Changes to this class should also happen to the Java version, whenever it
// makes sense.
#ifndef I18N_PHONENUMBERS_PHONENUMBERMATCHER_H_
#define I18N_PHONENUMBERS_PHONENUMBERMATCHER_H_
#include <string>
#include <vector>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/memory/scoped_ptr.h"
#include "phonenumbers/callback.h"
#include "phonenumbers/regexp_adapter.h"
namespace i18n {
namespace phonenumbers {
template <class R, class A1, class A2, class A3, class A4>
class ResultCallback4;
using std::string;
using std::vector;
class AlternateFormats;
class NumberFormat;
class PhoneNumber;
class PhoneNumberMatch;
class PhoneNumberMatcherRegExps;
class PhoneNumberUtil;
class PhoneNumberMatcher {
friend class PhoneNumberMatcherTest;
public:
// Leniency when finding potential phone numbers in text segments. The levels
// here are ordered in increasing strictness.
enum Leniency {
// Phone numbers accepted are possible, but not necessarily valid.
POSSIBLE,
// Phone numbers accepted are possible and valid.
VALID,
// Phone numbers accepted are valid and are grouped in a possible way for
// this locale. For example, a US number written as "65 02 53 00 00" is not
// accepted at this leniency level, whereas "650 253 0000" or "6502530000"
// are. Numbers with more than one '/' symbol are also dropped at this
// level.
// Warning: The next two levels might result in lower coverage especially
// for regions outside of country code "+1". If you are not sure about which
// level to use, you can send an e-mail to the discussion group
// http://groups.google.com/group/libphonenumber-discuss/
STRICT_GROUPING,
// Phone numbers accepted are valid and are grouped in the same way that we
// would have formatted it, or as a single block. For example, a US number
// written as "650 2530000" is not accepted at this leniency level, whereas
// "650 253 0000" or "6502530000" are.
EXACT_GROUPING,
};
// Constructs a phone number matcher.
PhoneNumberMatcher(const PhoneNumberUtil& util,
const string& text,
const string& region_code,
Leniency leniency,
int max_tries);
// Wrapper to construct a phone number matcher, with no limitation on the
// number of retries and VALID Leniency.
PhoneNumberMatcher(const string& text,
const string& region_code);
~PhoneNumberMatcher();
// Returns true if the text sequence has another match.
bool HasNext();
// Gets next match from text sequence.
bool Next(PhoneNumberMatch* match);
private:
// The potential states of a PhoneNumberMatcher.
enum State {
NOT_READY,
READY,
DONE,
};
// Attempts to extract a match from a candidate string. Returns true if a
// match is found, otherwise returns false. The value "offset" refers to the
// start index of the candidate string within the overall text.
bool Find(int index, PhoneNumberMatch* match);
// Checks a number was formatted with a national prefix, if the number was
// found in national format, and a national prefix is required for that
// number. Returns false if the number needed to have a national prefix and
// none was found.
bool IsNationalPrefixPresentIfRequired(const PhoneNumber& number) const;
// Attempts to extract a match from candidate. Returns true if the match was
// found, otherwise returns false.
bool ExtractMatch(const string& candidate, int offset,
PhoneNumberMatch* match);
// Attempts to extract a match from a candidate string if the whole candidate
// does not qualify as a match. Returns true if a match is found, otherwise
// returns false.
bool ExtractInnerMatch(const string& candidate, int offset,
PhoneNumberMatch* match);
// Parses a phone number from the candidate using PhoneNumberUtil::Parse() and
// verifies it matches the requested leniency. If parsing and verification
// succeed, returns true, otherwise this method returns false;
bool ParseAndVerify(const string& candidate, int offset,
PhoneNumberMatch* match);
bool CheckNumberGroupingIsValid(
const PhoneNumber& phone_number,
const string& candidate,
ResultCallback4<bool, const PhoneNumberUtil&, const PhoneNumber&,
const string&, const vector<string>&>* checker) const;
// Helper method to get the national-number part of a number, formatted
// without any national prefix, and return it as a set of digit blocks that
// would be formatted together following standard formatting rules.
void GetNationalNumberGroups(
const PhoneNumber& number,
vector<string>* digit_blocks) const;
// Helper method to get the national-number part of a number, formatted
// without any national prefix, and return it as a set of digit blocks that
// should be formatted together according to the formatting pattern passed in.
void GetNationalNumberGroupsForPattern(
const PhoneNumber& number,
const NumberFormat* formatting_pattern,
vector<string>* digit_blocks) const;
bool AllNumberGroupsAreExactlyPresent(
const PhoneNumberUtil& util,
const PhoneNumber& phone_number,
const string& normalized_candidate,
const vector<string>& formatted_number_groups) const;
bool VerifyAccordingToLeniency(Leniency leniency, const PhoneNumber& number,
const string& candidate) const;
// In interface for testing purposes.
static bool ContainsMoreThanOneSlashInNationalNumber(
const PhoneNumber& number,
const string& candidate,
const PhoneNumberUtil& util);
// Helper method to determine if a character is a Latin-script letter or not.
// For our purposes, combining marks should also return true since we assume
// they have been added to a preceding Latin character.
static bool IsLatinLetter(char32 letter);
// Helper class holding useful regular expressions.
const PhoneNumberMatcherRegExps* reg_exps_;
// Helper class holding loaded data containing alternate ways phone numbers
// might be formatted for certain regions.
const AlternateFormats* alternate_formats_;
// The phone number utility;
const PhoneNumberUtil& phone_util_;
// The text searched for phone numbers;
const string text_;
// The region(country) to assume for phone numbers without an international
// prefix.
const string preferred_region_;
// The degree of validation requested.
Leniency leniency_;
// The maximum number of retries after matching an invalid number.
int max_tries_;
// The iteration tristate.
State state_;
// The last successful match, NULL unless in State.READY.
scoped_ptr<PhoneNumberMatch> last_match_;
// The next index to start searching at. Undefined in State.DONE.
int search_index_;
DISALLOW_COPY_AND_ASSIGN(PhoneNumberMatcher);
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_PHONENUMBERMATCHER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/phonenumbermatcher.h
|
C++
|
unknown
| 7,817
|
// Copyright (C) 2009 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "phonenumbers/phonenumberutil.h"
#include <algorithm>
#include <cctype>
#include <cstring>
#include <iterator>
#include <map>
#include <utility>
#include <vector>
#include <unicode/uchar.h>
#include <unicode/utf8.h>
#include "phonenumbers/asyoutypeformatter.h"
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/logging.h"
#include "phonenumbers/base/memory/singleton.h"
#include "phonenumbers/default_logger.h"
#include "phonenumbers/encoding_utils.h"
#include "phonenumbers/matcher_api.h"
#include "phonenumbers/metadata.h"
#include "phonenumbers/normalize_utf8.h"
#include "phonenumbers/phonemetadata.pb.h"
#include "phonenumbers/phonenumber.h"
#include "phonenumbers/phonenumber.pb.h"
#include "phonenumbers/regex_based_matcher.h"
#include "phonenumbers/regexp_adapter.h"
#include "phonenumbers/regexp_cache.h"
#include "phonenumbers/regexp_factory.h"
#include "phonenumbers/region_code.h"
#include "phonenumbers/stl_util.h"
#include "phonenumbers/stringutil.h"
#include "phonenumbers/utf/unicodetext.h"
#include "phonenumbers/utf/utf.h"
namespace i18n {
namespace phonenumbers {
using google::protobuf::RepeatedField;
using gtl::OrderByFirst;
// static constants
const size_t PhoneNumberUtil::kMinLengthForNsn;
const size_t PhoneNumberUtil::kMaxLengthForNsn;
const size_t PhoneNumberUtil::kMaxLengthCountryCode;
const int PhoneNumberUtil::kNanpaCountryCode;
// static
const char PhoneNumberUtil::kPlusChars[] = "+\xEF\xBC\x8B"; /* "++" */
// Regular expression of acceptable punctuation found in phone numbers, used to
// find numbers in text and to decide what is a viable phone number. This
// excludes diallable characters.
// This consists of dash characters, white space characters, full stops,
// slashes, square brackets, parentheses and tildes. It also includes the letter
// 'x' as that is found as a placeholder for carrier information in some phone
// numbers. Full-width variants are also present.
// To find out the unicode code-point of the characters below in vim, highlight
// the character and type 'ga'. Note that the - is used to express ranges of
// full-width punctuation below, as well as being present in the expression
// itself. In emacs, you can use M-x unicode-what to query information about the
// unicode character.
// static
const char PhoneNumberUtil::kValidPunctuation[] =
/* "-x‐-―−ー--/ <U+200B><U+2060> ()()[].\\[\\]/~⁓∼" */
"-x\xE2\x80\x90-\xE2\x80\x95\xE2\x88\x92\xE3\x83\xBC\xEF\xBC\x8D-\xEF\xBC"
"\x8F \xC2\xA0\xC2\xAD\xE2\x80\x8B\xE2\x81\xA0\xE3\x80\x80()\xEF\xBC\x88"
"\xEF\xBC\x89\xEF\xBC\xBB\xEF\xBC\xBD.\\[\\]/~\xE2\x81\x93\xE2\x88\xBC";
// static
const char PhoneNumberUtil::kCaptureUpToSecondNumberStart[] = "(.*)[\\\\/] *x";
// static
const char PhoneNumberUtil::kRegionCodeForNonGeoEntity[] = "001";
namespace {
// The prefix that needs to be inserted in front of a Colombian landline
// number when dialed from a mobile phone in Colombia.
const char kColombiaMobileToFixedLinePrefix[] = "3";
// The kPlusSign signifies the international prefix.
const char kPlusSign[] = "+";
const char kStarSign[] = "*";
const char kRfc3966ExtnPrefix[] = ";ext=";
const char kRfc3966Prefix[] = "tel:";
const char kRfc3966PhoneContext[] = ";phone-context=";
const char kRfc3966IsdnSubaddress[] = ";isub=";
const char kDigits[] = "\\p{Nd}";
// We accept alpha characters in phone numbers, ASCII only. We store lower-case
// here only since our regular expressions are case-insensitive.
const char kValidAlpha[] = "a-z";
// Default extension prefix to use when formatting. This will be put in front of
// any extension component of the number, after the main national number is
// formatted. For example, if you wish the default extension formatting to be "
// extn: 3456", then you should specify " extn: " here as the default extension
// prefix. This can be overridden by region-specific preferences.
const char kDefaultExtnPrefix[] = " ext. ";
// One-character symbols that can be used to indicate an extension.
const char kSingleExtnSymbolsForMatching[] =
"x\xEF\xBD\x98#\xEF\xBC\x83~\xEF\xBD\x9E";
bool LoadCompiledInMetadata(PhoneMetadataCollection* metadata) {
if (!metadata->ParseFromArray(metadata_get(), metadata_size())) {
LOG(ERROR) << "Could not parse binary data.";
return false;
}
return true;
}
// Returns a pointer to the description inside the metadata of the appropriate
// type.
const PhoneNumberDesc* GetNumberDescByType(
const PhoneMetadata& metadata,
PhoneNumberUtil::PhoneNumberType type) {
switch (type) {
case PhoneNumberUtil::PREMIUM_RATE:
return &metadata.premium_rate();
case PhoneNumberUtil::TOLL_FREE:
return &metadata.toll_free();
case PhoneNumberUtil::MOBILE:
return &metadata.mobile();
case PhoneNumberUtil::FIXED_LINE:
case PhoneNumberUtil::FIXED_LINE_OR_MOBILE:
return &metadata.fixed_line();
case PhoneNumberUtil::SHARED_COST:
return &metadata.shared_cost();
case PhoneNumberUtil::VOIP:
return &metadata.voip();
case PhoneNumberUtil::PERSONAL_NUMBER:
return &metadata.personal_number();
case PhoneNumberUtil::PAGER:
return &metadata.pager();
case PhoneNumberUtil::UAN:
return &metadata.uan();
case PhoneNumberUtil::VOICEMAIL:
return &metadata.voicemail();
default:
return &metadata.general_desc();
}
}
// A helper function that is used by Format and FormatByPattern.
void PrefixNumberWithCountryCallingCode(
int country_calling_code,
PhoneNumberUtil::PhoneNumberFormat number_format,
string* formatted_number) {
switch (number_format) {
case PhoneNumberUtil::E164:
formatted_number->insert(0, StrCat(kPlusSign, country_calling_code));
return;
case PhoneNumberUtil::INTERNATIONAL:
formatted_number->insert(0, StrCat(kPlusSign, country_calling_code, " "));
return;
case PhoneNumberUtil::RFC3966:
formatted_number->insert(0, StrCat(kRfc3966Prefix, kPlusSign,
country_calling_code, "-"));
return;
case PhoneNumberUtil::NATIONAL:
default:
// Do nothing.
return;
}
}
// Returns true when one national number is the suffix of the other or both are
// the same.
bool IsNationalNumberSuffixOfTheOther(const PhoneNumber& first_number,
const PhoneNumber& second_number) {
const string& first_number_national_number =
SimpleItoa(static_cast<uint64>(first_number.national_number()));
const string& second_number_national_number =
SimpleItoa(static_cast<uint64>(second_number.national_number()));
// Note that HasSuffixString returns true if the numbers are equal.
return HasSuffixString(first_number_national_number,
second_number_national_number) ||
HasSuffixString(second_number_national_number,
first_number_national_number);
}
char32 ToUnicodeCodepoint(const char* unicode_char) {
char32 codepoint;
EncodingUtils::DecodeUTF8Char(unicode_char, &codepoint);
return codepoint;
}
// Helper initialiser method to create the regular-expression pattern to match
// extensions, allowing the one-codepoint extension symbols provided by
// single_extn_symbols.
// Note that there are currently three capturing groups for the extension itself
// - if this number is changed, MaybeStripExtension needs to be updated.
string CreateExtnPattern(const string& single_extn_symbols) {
static const string capturing_extn_digits = StrCat("([", kDigits, "]{1,7})");
// The first regular expression covers RFC 3966 format, where the extension is
// added using ";ext=". The second more generic one starts with optional white
// space and ends with an optional full stop (.), followed by zero or more
// spaces/tabs/commas and then the numbers themselves. The third one covers
// the special case of American numbers where the extension is written with a
// hash at the end, such as "- 503#".
// Note that the only capturing groups should be around the digits that you
// want to capture as part of the extension, or else parsing will fail!
// Canonical-equivalence doesn't seem to be an option with RE2, so we allow
// two options for representing the ó - the character itself, and one in the
// unicode decomposed form with the combining acute accent.
return (StrCat(
kRfc3966ExtnPrefix, capturing_extn_digits, "|"
/* "[ \\t,]*(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|single_extn_symbols|"
"int|int|anexo)"
"[:\\..]?[ \\t,-]*", capturing_extn_digits, "#?|" */
"[ \xC2\xA0\\t,]*(?:e?xt(?:ensi(?:o\xCC\x81?|\xC3\xB3))?n?|"
"(?:\xEF\xBD\x85)?\xEF\xBD\x98\xEF\xBD\x94(?:\xEF\xBD\x8E)?|"
"\xD0\xB4\xD0\xBE\xD0\xB1|[", single_extn_symbols, "]|int|"
"\xEF\xBD\x89\xEF\xBD\x8E\xEF\xBD\x94|anexo)"
"[:\\.\xEF\xBC\x8E]?[ \xC2\xA0\\t,-]*", capturing_extn_digits,
"#?|[- ]+([", kDigits, "]{1,5})#"));
}
// Normalizes a string of characters representing a phone number by replacing
// all characters found in the accompanying map with the values therein, and
// stripping all other characters if remove_non_matches is true.
// Parameters:
// number - a pointer to a string of characters representing a phone number to
// be normalized.
// normalization_replacements - a mapping of characters to what they should be
// replaced by in the normalized version of the phone number
// remove_non_matches - indicates whether characters that are not able to be
// replaced should be stripped from the number. If this is false, they will be
// left unchanged in the number.
void NormalizeHelper(const std::map<char32, char>& normalization_replacements,
bool remove_non_matches,
string* number) {
DCHECK(number);
UnicodeText number_as_unicode;
number_as_unicode.PointToUTF8(number->data(), number->size());
string normalized_number;
char unicode_char[5];
for (UnicodeText::const_iterator it = number_as_unicode.begin();
it != number_as_unicode.end();
++it) {
std::map<char32, char>::const_iterator found_glyph_pair =
normalization_replacements.find(*it);
if (found_glyph_pair != normalization_replacements.end()) {
normalized_number.push_back(found_glyph_pair->second);
} else if (!remove_non_matches) {
// Find out how long this unicode char is so we can append it all.
int char_len = it.get_utf8(unicode_char);
normalized_number.append(unicode_char, char_len);
}
// If neither of the above are true, we remove this character.
}
number->assign(normalized_number);
}
// Returns true if there is any possible number data set for a particular
// PhoneNumberDesc.
bool DescHasPossibleNumberData(const PhoneNumberDesc& desc) {
// If this is empty, it means numbers of this type inherit from the "general
// desc" -> the value "-1" means that no numbers exist for this type.
return desc.possible_length_size() != 1 || desc.possible_length(0) != -1;
}
// Note: DescHasData must account for any of MetadataFilter's
// excludableChildFields potentially being absent from the metadata. It must
// check them all. For any changes in DescHasData, ensure that all the
// excludableChildFields are still being checked. If your change is safe simply
// mention why during a review without needing to change MetadataFilter.
// Returns true if there is any data set for a particular PhoneNumberDesc.
bool DescHasData(const PhoneNumberDesc& desc) {
// Checking most properties since we don't know what's present, since a custom
// build may have stripped just one of them (e.g. USE_METADATA_LITE strips
// exampleNumber). We don't bother checking the PossibleLengthsLocalOnly,
// since if this is the only thing that's present we don't really support the
// type at all: no type-specific methods will work with only this data.
return desc.has_example_number() || DescHasPossibleNumberData(desc) ||
desc.has_national_number_pattern();
}
// Returns the types we have metadata for based on the PhoneMetadata object
// passed in.
void GetSupportedTypesForMetadata(
const PhoneMetadata& metadata,
std::set<PhoneNumberUtil::PhoneNumberType>* types) {
DCHECK(types);
for (int i = 0; i <= static_cast<int>(PhoneNumberUtil::kMaxNumberType); ++i) {
PhoneNumberUtil::PhoneNumberType type =
static_cast<PhoneNumberUtil::PhoneNumberType>(i);
if (type == PhoneNumberUtil::FIXED_LINE_OR_MOBILE ||
type == PhoneNumberUtil::UNKNOWN) {
// Never return FIXED_LINE_OR_MOBILE (it is a convenience type, and
// represents that a particular number type can't be
// determined) or UNKNOWN (the non-type).
continue;
}
if (DescHasData(*GetNumberDescByType(metadata, type))) {
types->insert(type);
}
}
}
// Helper method to check a number against possible lengths for this number
// type, and determine whether it matches, or is too short or too long.
PhoneNumberUtil::ValidationResult TestNumberLength(
const string& number, const PhoneMetadata& metadata,
PhoneNumberUtil::PhoneNumberType type) {
const PhoneNumberDesc* desc_for_type = GetNumberDescByType(metadata, type);
// There should always be "possibleLengths" set for every element. This is
// declared in the XML schema which is verified by
// PhoneNumberMetadataSchemaTest. For size efficiency, where a
// sub-description (e.g. fixed-line) has the same possibleLengths as the
// parent, this is missing, so we fall back to the general desc (where no
// numbers of the type exist at all, there is one possible length (-1) which
// is guaranteed not to match the length of any real phone number).
RepeatedField<int> possible_lengths =
desc_for_type->possible_length_size() == 0
? metadata.general_desc().possible_length()
: desc_for_type->possible_length();
RepeatedField<int> local_lengths =
desc_for_type->possible_length_local_only();
if (type == PhoneNumberUtil::FIXED_LINE_OR_MOBILE) {
const PhoneNumberDesc* fixed_line_desc =
GetNumberDescByType(metadata, PhoneNumberUtil::FIXED_LINE);
if (!DescHasPossibleNumberData(*fixed_line_desc)) {
// The rare case has been encountered where no fixedLine data is available
// (true for some non-geographical entities), so we just check mobile.
return TestNumberLength(number, metadata, PhoneNumberUtil::MOBILE);
} else {
const PhoneNumberDesc* mobile_desc =
GetNumberDescByType(metadata, PhoneNumberUtil::MOBILE);
if (DescHasPossibleNumberData(*mobile_desc)) {
// Merge the mobile data in if there was any. Note that when adding the
// possible lengths from mobile, we have to again check they aren't
// empty since if they are this indicates they are the same as the
// general desc and should be obtained from there.
possible_lengths.MergeFrom(
mobile_desc->possible_length_size() == 0
? metadata.general_desc().possible_length()
: mobile_desc->possible_length());
std::sort(possible_lengths.begin(), possible_lengths.end());
if (local_lengths.size() == 0) {
local_lengths = mobile_desc->possible_length_local_only();
} else {
local_lengths.MergeFrom(mobile_desc->possible_length_local_only());
std::sort(local_lengths.begin(), local_lengths.end());
}
}
}
}
// If the type is not suported at all (indicated by the possible lengths
// containing -1 at this point) we return invalid length.
if (possible_lengths.Get(0) == -1) {
return PhoneNumberUtil::INVALID_LENGTH;
}
int actual_length = number.length();
// This is safe because there is never an overlap beween the possible lengths
// and the local-only lengths; this is checked at build time.
if (std::find(local_lengths.begin(), local_lengths.end(), actual_length) !=
local_lengths.end()) {
return PhoneNumberUtil::IS_POSSIBLE_LOCAL_ONLY;
}
int minimum_length = possible_lengths.Get(0);
if (minimum_length == actual_length) {
return PhoneNumberUtil::IS_POSSIBLE;
} else if (minimum_length > actual_length) {
return PhoneNumberUtil::TOO_SHORT;
} else if (*(possible_lengths.end() - 1) < actual_length) {
return PhoneNumberUtil::TOO_LONG;
}
// We skip the first element; we've already checked it.
return std::find(possible_lengths.begin() + 1, possible_lengths.end(),
actual_length) != possible_lengths.end()
? PhoneNumberUtil::IS_POSSIBLE
: PhoneNumberUtil::INVALID_LENGTH;
}
// Helper method to check a number against possible lengths for this region,
// based on the metadata being passed in, and determine whether it matches, or
// is too short or too long.
PhoneNumberUtil::ValidationResult TestNumberLength(
const string& number, const PhoneMetadata& metadata) {
return TestNumberLength(number, metadata, PhoneNumberUtil::UNKNOWN);
}
// Returns a new phone number containing only the fields needed to uniquely
// identify a phone number, rather than any fields that capture the context in
// which the phone number was created.
// These fields correspond to those set in Parse() rather than
// ParseAndKeepRawInput().
void CopyCoreFieldsOnly(const PhoneNumber& number, PhoneNumber* pruned_number) {
pruned_number->set_country_code(number.country_code());
pruned_number->set_national_number(number.national_number());
if (!number.extension().empty()) {
pruned_number->set_extension(number.extension());
}
if (number.italian_leading_zero()) {
pruned_number->set_italian_leading_zero(true);
// This field is only relevant if there are leading zeros at all.
pruned_number->set_number_of_leading_zeros(
number.number_of_leading_zeros());
}
}
// Determines whether the given number is a national number match for the given
// PhoneNumberDesc. Does not check against possible lengths!
bool IsMatch(const MatcherApi& matcher_api,
const string& number, const PhoneNumberDesc& desc) {
return matcher_api.MatchNationalNumber(number, desc, false);
}
} // namespace
void PhoneNumberUtil::SetLogger(Logger* logger) {
logger_.reset(logger);
Logger::set_logger_impl(logger_.get());
}
class PhoneNumberRegExpsAndMappings {
private:
void InitializeMapsAndSets() {
diallable_char_mappings_.insert(std::make_pair('+', '+'));
diallable_char_mappings_.insert(std::make_pair('*', '*'));
diallable_char_mappings_.insert(std::make_pair('#', '#'));
// Here we insert all punctuation symbols that we wish to respect when
// formatting alpha numbers, as they show the intended number groupings.
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("-"), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xEF\xBC\x8D" /* "-" */), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x90" /* "‐" */), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x91" /* "‑" */), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x92" /* "‒" */), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x93" /* "–" */), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x94" /* "—" */), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x95" /* "―" */), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE2\x88\x92" /* "−" */), '-'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("/"), '/'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xEF\xBC\x8F" /* "/" */), '/'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint(" "), ' '));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE3\x80\x80" /* " " */), ' '));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xE2\x81\xA0"), ' '));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("."), '.'));
all_plus_number_grouping_symbols_.insert(
std::make_pair(ToUnicodeCodepoint("\xEF\xBC\x8E" /* "." */), '.'));
// Only the upper-case letters are added here - the lower-case versions are
// added programmatically.
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("A"), '2'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("B"), '2'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("C"), '2'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("D"), '3'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("E"), '3'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("F"), '3'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("G"), '4'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("H"), '4'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("I"), '4'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("J"), '5'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("K"), '5'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("L"), '5'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("M"), '6'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("N"), '6'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("O"), '6'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("P"), '7'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("Q"), '7'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("R"), '7'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("S"), '7'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("T"), '8'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("U"), '8'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("V"), '8'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("W"), '9'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("X"), '9'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("Y"), '9'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("Z"), '9'));
std::map<char32, char> lower_case_mappings;
std::map<char32, char> alpha_letters;
for (std::map<char32, char>::const_iterator it = alpha_mappings_.begin();
it != alpha_mappings_.end();
++it) {
// Convert all the upper-case ASCII letters to lower-case.
if (it->first < 128) {
char letter_as_upper = static_cast<char>(it->first);
char32 letter_as_lower = static_cast<char32>(tolower(letter_as_upper));
lower_case_mappings.insert(std::make_pair(letter_as_lower, it->second));
// Add the letters in both variants to the alpha_letters map. This just
// pairs each letter with its upper-case representation so that it can
// be retained when normalising alpha numbers.
alpha_letters.insert(std::make_pair(letter_as_lower, letter_as_upper));
alpha_letters.insert(std::make_pair(it->first, letter_as_upper));
}
}
// In the Java version we don't insert the lower-case mappings in the map,
// because we convert to upper case on the fly. Doing this here would
// involve pulling in all of ICU, which we don't want to do if we don't have
// to.
alpha_mappings_.insert(lower_case_mappings.begin(),
lower_case_mappings.end());
alpha_phone_mappings_.insert(alpha_mappings_.begin(),
alpha_mappings_.end());
all_plus_number_grouping_symbols_.insert(alpha_letters.begin(),
alpha_letters.end());
// Add the ASCII digits so that they don't get deleted by NormalizeHelper().
for (char c = '0'; c <= '9'; ++c) {
diallable_char_mappings_.insert(std::make_pair(c, c));
alpha_phone_mappings_.insert(std::make_pair(c, c));
all_plus_number_grouping_symbols_.insert(std::make_pair(c, c));
}
mobile_token_mappings_.insert(std::make_pair(54, '9'));
geo_mobile_countries_without_mobile_area_codes_.insert(86); // China
geo_mobile_countries_.insert(52); // Mexico
geo_mobile_countries_.insert(54); // Argentina
geo_mobile_countries_.insert(55); // Brazil
// Indonesia: some prefixes only (fixed CMDA wireless)
geo_mobile_countries_.insert(62);
geo_mobile_countries_.insert(
geo_mobile_countries_without_mobile_area_codes_.begin(),
geo_mobile_countries_without_mobile_area_codes_.end());
}
// Regular expression of viable phone numbers. This is location independent.
// Checks we have at least three leading digits, and only valid punctuation,
// alpha characters and digits in the phone number. Does not include extension
// data. The symbol 'x' is allowed here as valid punctuation since it is often
// used as a placeholder for carrier codes, for example in Brazilian phone
// numbers. We also allow multiple plus-signs at the start.
// Corresponds to the following:
// [digits]{minLengthNsn}|
// plus_sign*(([punctuation]|[star])*[digits]){3,}
// ([punctuation]|[star]|[digits]|[alpha])*
//
// The first reg-ex is to allow short numbers (two digits long) to be parsed
// if they are entered as "15" etc, but only if there is no punctuation in
// them. The second expression restricts the number of digits to three or
// more, but then allows them to be in international form, and to have
// alpha-characters and punctuation.
const string valid_phone_number_;
// Regexp of all possible ways to write extensions, for use when parsing. This
// will be run as a case-insensitive regexp match. Wide character versions are
// also provided after each ASCII version.
// For parsing, we are slightly more lenient in our interpretation than for
// matching. Here we allow "comma" and "semicolon" as possible extension
// indicators. When matching, these are hardly ever used to indicate this.
const string extn_patterns_for_parsing_;
public:
scoped_ptr<const AbstractRegExpFactory> regexp_factory_;
scoped_ptr<RegExpCache> regexp_cache_;
// A map that contains characters that are essential when dialling. That means
// any of the characters in this map must not be removed from a number when
// dialing, otherwise the call will not reach the intended destination.
std::map<char32, char> diallable_char_mappings_;
// These mappings map a character (key) to a specific digit that should
// replace it for normalization purposes.
std::map<char32, char> alpha_mappings_;
// For performance reasons, store a map of combining alpha_mappings with ASCII
// digits.
std::map<char32, char> alpha_phone_mappings_;
// Separate map of all symbols that we wish to retain when formatting alpha
// numbers. This includes digits, ascii letters and number grouping symbols
// such as "-" and " ".
std::map<char32, char> all_plus_number_grouping_symbols_;
// Map of country calling codes that use a mobile token before the area code.
// One example of when this is relevant is when determining the length of the
// national destination code, which should be the length of the area code plus
// the length of the mobile token.
std::map<int, char> mobile_token_mappings_;
// Set of country codes that have geographically assigned mobile numbers (see
// geo_mobile_countries_ below) which are not based on *area codes*. For
// example, in China mobile numbers start with a carrier indicator, and beyond
// that are geographically assigned: this carrier indicator is not considered
// to be an area code.
std::set<int> geo_mobile_countries_without_mobile_area_codes_;
// Set of country calling codes that have geographically assigned mobile
// numbers. This may not be complete; we add calling codes case by case, as we
// find geographical mobile numbers or hear from user reports.
std::set<int> geo_mobile_countries_;
// Pattern that makes it easy to distinguish whether a region has a single
// international dialing prefix or not. If a region has a single international
// prefix (e.g. 011 in USA), it will be represented as a string that contains
// a sequence of ASCII digits, and possibly a tilde, which signals waiting for
// the tone. If there are multiple available international prefixes in a
// region, they will be represented as a regex string that always contains one
// or more characters that are not ASCII digits or a tilde.
scoped_ptr<const RegExp> single_international_prefix_;
scoped_ptr<const RegExp> digits_pattern_;
scoped_ptr<const RegExp> capturing_digit_pattern_;
scoped_ptr<const RegExp> capturing_ascii_digits_pattern_;
// Regular expression of acceptable characters that may start a phone number
// for the purposes of parsing. This allows us to strip away meaningless
// prefixes to phone numbers that may be mistakenly given to us. This consists
// of digits, the plus symbol and arabic-indic digits. This does not contain
// alpha characters, although they may be used later in the number. It also
// does not include other punctuation, as this will be stripped later during
// parsing and is of no information value when parsing a number. The string
// starting with this valid character is captured.
// This corresponds to VALID_START_CHAR in the java version.
scoped_ptr<const RegExp> valid_start_char_pattern_;
// Regular expression of valid characters before a marker that might indicate
// a second number.
scoped_ptr<const RegExp> capture_up_to_second_number_start_pattern_;
// Regular expression of trailing characters that we want to remove. We remove
// all characters that are not alpha or numerical characters. The hash
// character is retained here, as it may signify the previous block was an
// extension. Note the capturing block at the start to capture the rest of the
// number if this was a match.
// This corresponds to UNWANTED_END_CHAR_PATTERN in the java version.
scoped_ptr<const RegExp> unwanted_end_char_pattern_;
// Regular expression of groups of valid punctuation characters.
scoped_ptr<const RegExp> separator_pattern_;
// Regexp of all possible ways to write extensions, for use when finding phone
// numbers in text. This will be run as a case-insensitive regexp match. Wide
// character versions are also provided after each ASCII version.
const string extn_patterns_for_matching_;
// Regexp of all known extension prefixes used by different regions followed
// by 1 or more valid digits, for use when parsing.
scoped_ptr<const RegExp> extn_pattern_;
// We append optionally the extension pattern to the end here, as a valid
// phone number may have an extension prefix appended, followed by 1 or more
// digits.
scoped_ptr<const RegExp> valid_phone_number_pattern_;
// We use this pattern to check if the phone number has at least three letters
// in it - if so, then we treat it as a number where some phone-number digits
// are represented by letters.
scoped_ptr<const RegExp> valid_alpha_phone_pattern_;
scoped_ptr<const RegExp> first_group_capturing_pattern_;
scoped_ptr<const RegExp> carrier_code_pattern_;
scoped_ptr<const RegExp> plus_chars_pattern_;
PhoneNumberRegExpsAndMappings()
: valid_phone_number_(
StrCat(kDigits, "{", PhoneNumberUtil::kMinLengthForNsn, "}|[",
PhoneNumberUtil::kPlusChars, "]*(?:[",
PhoneNumberUtil::kValidPunctuation, kStarSign, "]*",
kDigits, "){3,}[", PhoneNumberUtil::kValidPunctuation,
kStarSign, kValidAlpha, kDigits, "]*")),
extn_patterns_for_parsing_(
CreateExtnPattern(StrCat(",;", kSingleExtnSymbolsForMatching))),
regexp_factory_(new RegExpFactory()),
regexp_cache_(new RegExpCache(*regexp_factory_.get(), 128)),
diallable_char_mappings_(),
alpha_mappings_(),
alpha_phone_mappings_(),
all_plus_number_grouping_symbols_(),
mobile_token_mappings_(),
geo_mobile_countries_without_mobile_area_codes_(),
geo_mobile_countries_(),
single_international_prefix_(regexp_factory_->CreateRegExp(
/* "[\\d]+(?:[~⁓∼~][\\d]+)?" */
"[\\d]+(?:[~\xE2\x81\x93\xE2\x88\xBC\xEF\xBD\x9E][\\d]+)?")),
digits_pattern_(
regexp_factory_->CreateRegExp(StrCat("[", kDigits, "]*"))),
capturing_digit_pattern_(
regexp_factory_->CreateRegExp(StrCat("([", kDigits, "])"))),
capturing_ascii_digits_pattern_(
regexp_factory_->CreateRegExp("(\\d+)")),
valid_start_char_pattern_(regexp_factory_->CreateRegExp(
StrCat("[", PhoneNumberUtil::kPlusChars, kDigits, "]"))),
capture_up_to_second_number_start_pattern_(
regexp_factory_->CreateRegExp(
PhoneNumberUtil::kCaptureUpToSecondNumberStart)),
unwanted_end_char_pattern_(
regexp_factory_->CreateRegExp("[^\\p{N}\\p{L}#]")),
separator_pattern_(
regexp_factory_->CreateRegExp(
StrCat("[", PhoneNumberUtil::kValidPunctuation, "]+"))),
extn_patterns_for_matching_(
CreateExtnPattern(kSingleExtnSymbolsForMatching)),
extn_pattern_(regexp_factory_->CreateRegExp(
StrCat("(?i)(?:", extn_patterns_for_parsing_, ")$"))),
valid_phone_number_pattern_(regexp_factory_->CreateRegExp(
StrCat("(?i)", valid_phone_number_,
"(?:", extn_patterns_for_parsing_, ")?"))),
valid_alpha_phone_pattern_(regexp_factory_->CreateRegExp(
StrCat("(?i)(?:.*?[", kValidAlpha, "]){3}"))),
// The first_group_capturing_pattern was originally set to $1 but there
// are some countries for which the first group is not used in the
// national pattern (e.g. Argentina) so the $1 group does not match
// correctly. Therefore, we use \d, so that the first group actually
// used in the pattern will be matched.
first_group_capturing_pattern_(
regexp_factory_->CreateRegExp("(\\$\\d)")),
carrier_code_pattern_(regexp_factory_->CreateRegExp("\\$CC")),
plus_chars_pattern_(
regexp_factory_->CreateRegExp(
StrCat("[", PhoneNumberUtil::kPlusChars, "]+"))) {
InitializeMapsAndSets();
}
private:
DISALLOW_COPY_AND_ASSIGN(PhoneNumberRegExpsAndMappings);
};
// Private constructor. Also takes care of initialisation.
PhoneNumberUtil::PhoneNumberUtil()
: logger_(Logger::set_logger_impl(new NullLogger())),
matcher_api_(new RegexBasedMatcher()),
reg_exps_(new PhoneNumberRegExpsAndMappings),
country_calling_code_to_region_code_map_(
new std::vector<IntRegionsPair>()),
nanpa_regions_(new std::set<string>()),
region_to_metadata_map_(new std::map<string, PhoneMetadata>()),
country_code_to_non_geographical_metadata_map_(
new std::map<int, PhoneMetadata>) {
Logger::set_logger_impl(logger_.get());
// TODO: Update the java version to put the contents of the init
// method inside the constructor as well to keep both in sync.
PhoneMetadataCollection metadata_collection;
if (!LoadCompiledInMetadata(&metadata_collection)) {
LOG(DFATAL) << "Could not parse compiled-in metadata.";
return;
}
// Storing data in a temporary map to make it easier to find other regions
// that share a country calling code when inserting data.
std::map<int, std::list<string>* > country_calling_code_to_region_map;
for (RepeatedPtrField<PhoneMetadata>::const_iterator it =
metadata_collection.metadata().begin();
it != metadata_collection.metadata().end();
++it) {
const string& region_code = it->id();
if (region_code == RegionCode::GetUnknown()) {
continue;
}
int country_calling_code = it->country_code();
if (kRegionCodeForNonGeoEntity == region_code) {
country_code_to_non_geographical_metadata_map_->insert(
std::make_pair(country_calling_code, *it));
} else {
region_to_metadata_map_->insert(std::make_pair(region_code, *it));
}
std::map<int, std::list<string>* >::iterator calling_code_in_map =
country_calling_code_to_region_map.find(country_calling_code);
if (calling_code_in_map != country_calling_code_to_region_map.end()) {
if (it->main_country_for_code()) {
calling_code_in_map->second->push_front(region_code);
} else {
calling_code_in_map->second->push_back(region_code);
}
} else {
// For most country calling codes, there will be only one region code.
std::list<string>* list_with_region_code = new std::list<string>();
list_with_region_code->push_back(region_code);
country_calling_code_to_region_map.insert(
std::make_pair(country_calling_code, list_with_region_code));
}
if (country_calling_code == kNanpaCountryCode) {
nanpa_regions_->insert(region_code);
}
}
country_calling_code_to_region_code_map_->insert(
country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_map.begin(),
country_calling_code_to_region_map.end());
// Sort all the pairs in ascending order according to country calling code.
std::sort(country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end(), OrderByFirst());
}
PhoneNumberUtil::~PhoneNumberUtil() {
gtl::STLDeleteContainerPairSecondPointers(
country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end());
}
void PhoneNumberUtil::GetSupportedRegions(std::set<string>* regions) const {
DCHECK(regions);
for (std::map<string, PhoneMetadata>::const_iterator it =
region_to_metadata_map_->begin(); it != region_to_metadata_map_->end();
++it) {
regions->insert(it->first);
}
}
void PhoneNumberUtil::GetSupportedGlobalNetworkCallingCodes(
std::set<int>* calling_codes) const {
DCHECK(calling_codes);
for (std::map<int, PhoneMetadata>::const_iterator it =
country_code_to_non_geographical_metadata_map_->begin();
it != country_code_to_non_geographical_metadata_map_->end(); ++it) {
calling_codes->insert(it->first);
}
}
void PhoneNumberUtil::GetSupportedCallingCodes(
std::set<int>* calling_codes) const {
DCHECK(calling_codes);
for (std::vector<IntRegionsPair>::const_iterator it =
country_calling_code_to_region_code_map_->begin();
it != country_calling_code_to_region_code_map_->end(); ++it) {
calling_codes->insert(it->first);
}
}
void PhoneNumberUtil::GetSupportedTypesForRegion(
const string& region_code,
std::set<PhoneNumberType>* types) const {
DCHECK(types);
if (!IsValidRegionCode(region_code)) {
LOG(WARNING) << "Invalid or unknown region code provided: " << region_code;
return;
}
const PhoneMetadata* metadata = GetMetadataForRegion(region_code);
GetSupportedTypesForMetadata(*metadata, types);
}
void PhoneNumberUtil::GetSupportedTypesForNonGeoEntity(
int country_calling_code,
std::set<PhoneNumberType>* types) const {
DCHECK(types);
const PhoneMetadata* metadata =
GetMetadataForNonGeographicalRegion(country_calling_code);
if (metadata == NULL) {
LOG(WARNING) << "Unknown country calling code for a non-geographical "
<< "entity provided: "
<< country_calling_code;
return;
}
GetSupportedTypesForMetadata(*metadata, types);
}
// Public wrapper function to get a PhoneNumberUtil instance with the default
// metadata file.
// static
PhoneNumberUtil* PhoneNumberUtil::GetInstance() {
return Singleton<PhoneNumberUtil>::GetInstance();
}
const string& PhoneNumberUtil::GetExtnPatternsForMatching() const {
return reg_exps_->extn_patterns_for_matching_;
}
bool PhoneNumberUtil::StartsWithPlusCharsPattern(const string& number)
const {
const scoped_ptr<RegExpInput> number_string_piece(
reg_exps_->regexp_factory_->CreateInput(number));
return reg_exps_->plus_chars_pattern_->Consume(number_string_piece.get());
}
bool PhoneNumberUtil::ContainsOnlyValidDigits(const string& s) const {
return reg_exps_->digits_pattern_->FullMatch(s);
}
void PhoneNumberUtil::TrimUnwantedEndChars(string* number) const {
DCHECK(number);
UnicodeText number_as_unicode;
number_as_unicode.PointToUTF8(number->data(), number->size());
char current_char[5];
int len;
UnicodeText::const_reverse_iterator reverse_it(number_as_unicode.end());
for (; reverse_it.base() != number_as_unicode.begin(); ++reverse_it) {
len = reverse_it.get_utf8(current_char);
current_char[len] = '\0';
if (!reg_exps_->unwanted_end_char_pattern_->FullMatch(current_char)) {
break;
}
}
number->assign(UnicodeText::UTF8Substring(number_as_unicode.begin(),
reverse_it.base()));
}
bool PhoneNumberUtil::IsFormatEligibleForAsYouTypeFormatter(
const string& format) const {
// A pattern that is used to determine if a numberFormat under
// availableFormats is eligible to be used by the AYTF. It is eligible when
// the format element under numberFormat contains groups of the dollar sign
// followed by a single digit, separated by valid phone number punctuation.
// This prevents invalid punctuation (such as the star sign in Israeli star
// numbers) getting into the output of the AYTF.
const RegExp& eligible_format_pattern = reg_exps_->regexp_cache_->GetRegExp(
StrCat("[", kValidPunctuation, "]*", "(\\$\\d", "[",
kValidPunctuation, "]*)+"));
return eligible_format_pattern.FullMatch(format);
}
bool PhoneNumberUtil::FormattingRuleHasFirstGroupOnly(
const string& national_prefix_formatting_rule) const {
// A pattern that is used to determine if the national prefix formatting rule
// has the first group only, i.e., does not start with the national prefix.
// Note that the pattern explicitly allows for unbalanced parentheses.
const RegExp& first_group_only_prefix_pattern =
reg_exps_->regexp_cache_->GetRegExp("\\(?\\$1\\)?");
return national_prefix_formatting_rule.empty() ||
first_group_only_prefix_pattern.FullMatch(
national_prefix_formatting_rule);
}
void PhoneNumberUtil::GetNddPrefixForRegion(const string& region_code,
bool strip_non_digits,
string* national_prefix) const {
DCHECK(national_prefix);
const PhoneMetadata* metadata = GetMetadataForRegion(region_code);
if (!metadata) {
LOG(WARNING) << "Invalid or unknown region code (" << region_code
<< ") provided.";
return;
}
national_prefix->assign(metadata->national_prefix());
if (strip_non_digits) {
// Note: if any other non-numeric symbols are ever used in national
// prefixes, these would have to be removed here as well.
strrmm(national_prefix, "~");
}
}
bool PhoneNumberUtil::IsValidRegionCode(const string& region_code) const {
return (region_to_metadata_map_->find(region_code) !=
region_to_metadata_map_->end());
}
bool PhoneNumberUtil::HasValidCountryCallingCode(
int country_calling_code) const {
// Create an IntRegionsPair with the country_code passed in, and use it to
// locate the pair with the same country_code in the sorted vector.
IntRegionsPair target_pair;
target_pair.first = country_calling_code;
return (std::binary_search(country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end(),
target_pair, OrderByFirst()));
}
// Returns a pointer to the phone metadata for the appropriate region or NULL
// if the region code is invalid or unknown.
const PhoneMetadata* PhoneNumberUtil::GetMetadataForRegion(
const string& region_code) const {
std::map<string, PhoneMetadata>::const_iterator it =
region_to_metadata_map_->find(region_code);
if (it != region_to_metadata_map_->end()) {
return &it->second;
}
return NULL;
}
const PhoneMetadata* PhoneNumberUtil::GetMetadataForNonGeographicalRegion(
int country_calling_code) const {
std::map<int, PhoneMetadata>::const_iterator it =
country_code_to_non_geographical_metadata_map_->find(
country_calling_code);
if (it != country_code_to_non_geographical_metadata_map_->end()) {
return &it->second;
}
return NULL;
}
void PhoneNumberUtil::Format(const PhoneNumber& number,
PhoneNumberFormat number_format,
string* formatted_number) const {
DCHECK(formatted_number);
if (number.national_number() == 0) {
const string& raw_input = number.raw_input();
if (!raw_input.empty()) {
// Unparseable numbers that kept their raw input just use that.
// This is the only case where a number can be formatted as E164 without a
// leading '+' symbol (but the original number wasn't parseable anyway).
// TODO: Consider removing the 'if' above so that unparseable
// strings without raw input format to the empty string instead of "+00".
formatted_number->assign(raw_input);
return;
}
}
int country_calling_code = number.country_code();
string national_significant_number;
GetNationalSignificantNumber(number, &national_significant_number);
if (number_format == E164) {
// Early exit for E164 case (even if the country calling code is invalid)
// since no formatting of the national number needs to be applied.
// Extensions are not formatted.
formatted_number->assign(national_significant_number);
PrefixNumberWithCountryCallingCode(country_calling_code, E164,
formatted_number);
return;
}
if (!HasValidCountryCallingCode(country_calling_code)) {
formatted_number->assign(national_significant_number);
return;
}
// Note here that all NANPA formatting rules are contained by US, so we use
// that to format NANPA numbers. The same applies to Russian Fed regions -
// rules are contained by Russia. French Indian Ocean country rules are
// contained by Réunion.
string region_code;
GetRegionCodeForCountryCode(country_calling_code, ®ion_code);
// Metadata cannot be NULL because the country calling code is valid (which
// means that the region code cannot be ZZ and must be one of our supported
// region codes).
const PhoneMetadata* metadata =
GetMetadataForRegionOrCallingCode(country_calling_code, region_code);
FormatNsn(national_significant_number, *metadata, number_format,
formatted_number);
MaybeAppendFormattedExtension(number, *metadata, number_format,
formatted_number);
PrefixNumberWithCountryCallingCode(country_calling_code, number_format,
formatted_number);
}
void PhoneNumberUtil::FormatByPattern(
const PhoneNumber& number,
PhoneNumberFormat number_format,
const RepeatedPtrField<NumberFormat>& user_defined_formats,
string* formatted_number) const {
DCHECK(formatted_number);
int country_calling_code = number.country_code();
// Note GetRegionCodeForCountryCode() is used because formatting information
// for regions which share a country calling code is contained by only one
// region for performance reasons. For example, for NANPA regions it will be
// contained in the metadata for US.
string national_significant_number;
GetNationalSignificantNumber(number, &national_significant_number);
if (!HasValidCountryCallingCode(country_calling_code)) {
formatted_number->assign(national_significant_number);
return;
}
string region_code;
GetRegionCodeForCountryCode(country_calling_code, ®ion_code);
// Metadata cannot be NULL because the country calling code is valid.
const PhoneMetadata* metadata =
GetMetadataForRegionOrCallingCode(country_calling_code, region_code);
const NumberFormat* formatting_pattern =
ChooseFormattingPatternForNumber(user_defined_formats,
national_significant_number);
if (!formatting_pattern) {
// If no pattern above is matched, we format the number as a whole.
formatted_number->assign(national_significant_number);
} else {
NumberFormat num_format_copy;
// Before we do a replacement of the national prefix pattern $NP with the
// national prefix, we need to copy the rule so that subsequent replacements
// for different numbers have the appropriate national prefix.
num_format_copy.MergeFrom(*formatting_pattern);
string national_prefix_formatting_rule(
formatting_pattern->national_prefix_formatting_rule());
if (!national_prefix_formatting_rule.empty()) {
const string& national_prefix = metadata->national_prefix();
if (!national_prefix.empty()) {
// Replace $NP with national prefix and $FG with the first group ($1).
GlobalReplaceSubstring("$NP", national_prefix,
&national_prefix_formatting_rule);
GlobalReplaceSubstring("$FG", "$1",
&national_prefix_formatting_rule);
num_format_copy.set_national_prefix_formatting_rule(
national_prefix_formatting_rule);
} else {
// We don't want to have a rule for how to format the national prefix if
// there isn't one.
num_format_copy.clear_national_prefix_formatting_rule();
}
}
FormatNsnUsingPattern(national_significant_number, num_format_copy,
number_format, formatted_number);
}
MaybeAppendFormattedExtension(number, *metadata, NATIONAL, formatted_number);
PrefixNumberWithCountryCallingCode(country_calling_code, number_format,
formatted_number);
}
void PhoneNumberUtil::FormatNationalNumberWithCarrierCode(
const PhoneNumber& number,
const string& carrier_code,
string* formatted_number) const {
int country_calling_code = number.country_code();
string national_significant_number;
GetNationalSignificantNumber(number, &national_significant_number);
if (!HasValidCountryCallingCode(country_calling_code)) {
formatted_number->assign(national_significant_number);
return;
}
// Note GetRegionCodeForCountryCode() is used because formatting information
// for regions which share a country calling code is contained by only one
// region for performance reasons. For example, for NANPA regions it will be
// contained in the metadata for US.
string region_code;
GetRegionCodeForCountryCode(country_calling_code, ®ion_code);
// Metadata cannot be NULL because the country calling code is valid.
const PhoneMetadata* metadata =
GetMetadataForRegionOrCallingCode(country_calling_code, region_code);
FormatNsnWithCarrier(national_significant_number, *metadata, NATIONAL,
carrier_code, formatted_number);
MaybeAppendFormattedExtension(number, *metadata, NATIONAL, formatted_number);
PrefixNumberWithCountryCallingCode(country_calling_code, NATIONAL,
formatted_number);
}
const PhoneMetadata* PhoneNumberUtil::GetMetadataForRegionOrCallingCode(
int country_calling_code, const string& region_code) const {
return kRegionCodeForNonGeoEntity == region_code
? GetMetadataForNonGeographicalRegion(country_calling_code)
: GetMetadataForRegion(region_code);
}
void PhoneNumberUtil::FormatNationalNumberWithPreferredCarrierCode(
const PhoneNumber& number,
const string& fallback_carrier_code,
string* formatted_number) const {
FormatNationalNumberWithCarrierCode(
number,
// Historically, we set this to an empty string when parsing with raw
// input if none was found in the input string. However, this doesn't
// result in a number we can dial. For this reason, we treat the empty
// string the same as if it isn't set at all.
!number.preferred_domestic_carrier_code().empty()
? number.preferred_domestic_carrier_code()
: fallback_carrier_code,
formatted_number);
}
void PhoneNumberUtil::FormatNumberForMobileDialing(
const PhoneNumber& number,
const string& calling_from,
bool with_formatting,
string* formatted_number) const {
int country_calling_code = number.country_code();
if (!HasValidCountryCallingCode(country_calling_code)) {
formatted_number->assign(number.has_raw_input() ? number.raw_input() : "");
return;
}
formatted_number->assign("");
// Clear the extension, as that part cannot normally be dialed together with
// the main number.
PhoneNumber number_no_extension(number);
number_no_extension.clear_extension();
string region_code;
GetRegionCodeForCountryCode(country_calling_code, ®ion_code);
PhoneNumberType number_type = GetNumberType(number_no_extension);
bool is_valid_number = (number_type != UNKNOWN);
if (calling_from == region_code) {
bool is_fixed_line_or_mobile =
(number_type == FIXED_LINE) || (number_type == MOBILE) ||
(number_type == FIXED_LINE_OR_MOBILE);
// Carrier codes may be needed in some countries. We handle this here.
if ((region_code == "CO") && (number_type == FIXED_LINE)) {
FormatNationalNumberWithCarrierCode(
number_no_extension, kColombiaMobileToFixedLinePrefix,
formatted_number);
} else if ((region_code == "BR") && (is_fixed_line_or_mobile)) {
// Historically, we set this to an empty string when parsing with raw
// input if none was found in the input string. However, this doesn't
// result in a number we can dial. For this reason, we treat the empty
// string the same as if it isn't set at all.
if (!number_no_extension.preferred_domestic_carrier_code().empty()) {
FormatNationalNumberWithPreferredCarrierCode(number_no_extension, "",
formatted_number);
} else {
// Brazilian fixed line and mobile numbers need to be dialed with a
// carrier code when called within Brazil. Without that, most of the
// carriers won't connect the call. Because of that, we return an empty
// string here.
formatted_number->assign("");
}
} else if (country_calling_code == kNanpaCountryCode) {
// For NANPA countries, we output international format for numbers that
// can be dialed internationally, since that always works, except for
// numbers which might potentially be short numbers, which are always
// dialled in national format.
const PhoneMetadata* region_metadata = GetMetadataForRegion(calling_from);
string national_number;
GetNationalSignificantNumber(number_no_extension, &national_number);
if (CanBeInternationallyDialled(number_no_extension) &&
TestNumberLength(national_number, *region_metadata) != TOO_SHORT) {
Format(number_no_extension, INTERNATIONAL, formatted_number);
} else {
Format(number_no_extension, NATIONAL, formatted_number);
}
} else {
// For non-geographical countries, and Mexican, Chilean and Uzbek fixed
// line and mobile numbers, we output international format for numbers
// that can be dialed internationally as that always works.
if ((region_code == kRegionCodeForNonGeoEntity ||
// MX fixed line and mobile numbers should always be formatted in
// international format, even when dialed within MX. For national
// format to work, a carrier code needs to be used, and the correct
// carrier code depends on if the caller and callee are from the same
// local area. It is trickier to get that to work correctly than
// using international format, which is tested to work fine on all
// carriers.
// CL fixed line numbers need the national prefix when dialing in the
// national format, but don't have it when used for display. The
// reverse is true for mobile numbers. As a result, we output them in
// the international format to make it work.
// UZ mobile and fixed-line numbers have to be formatted in
// international format or prefixed with special codes like 03, 04
// (for fixed-line) and 05 (for mobile) for dialling successfully
// from mobile devices. As we do not have complete information on
// special codes and to be consistent with formatting across all
// phone types we return the number in international format here.
((region_code == "MX" ||
region_code == "CL" ||
region_code == "UZ") &&
is_fixed_line_or_mobile)) &&
CanBeInternationallyDialled(number_no_extension)) {
Format(number_no_extension, INTERNATIONAL, formatted_number);
} else {
Format(number_no_extension, NATIONAL, formatted_number);
}
}
} else if (is_valid_number &&
CanBeInternationallyDialled(number_no_extension)) {
// We assume that short numbers are not diallable from outside their
// region, so if a number is not a valid regular length phone number, we
// treat it as if it cannot be internationally dialled.
with_formatting
? Format(number_no_extension, INTERNATIONAL, formatted_number)
: Format(number_no_extension, E164, formatted_number);
return;
}
if (!with_formatting) {
NormalizeDiallableCharsOnly(formatted_number);
}
}
void PhoneNumberUtil::FormatOutOfCountryCallingNumber(
const PhoneNumber& number,
const string& calling_from,
string* formatted_number) const {
DCHECK(formatted_number);
if (!IsValidRegionCode(calling_from)) {
VLOG(1) << "Trying to format number from invalid region " << calling_from
<< ". International formatting applied.";
Format(number, INTERNATIONAL, formatted_number);
return;
}
int country_code = number.country_code();
string national_significant_number;
GetNationalSignificantNumber(number, &national_significant_number);
if (!HasValidCountryCallingCode(country_code)) {
formatted_number->assign(national_significant_number);
return;
}
if (country_code == kNanpaCountryCode) {
if (IsNANPACountry(calling_from)) {
// For NANPA regions, return the national format for these regions but
// prefix it with the country calling code.
Format(number, NATIONAL, formatted_number);
formatted_number->insert(0, StrCat(country_code, " "));
return;
}
} else if (country_code == GetCountryCodeForValidRegion(calling_from)) {
// If neither region is a NANPA region, then we check to see if the
// country calling code of the number and the country calling code of the
// region we are calling from are the same.
// For regions that share a country calling code, the country calling code
// need not be dialled. This also applies when dialling within a region, so
// this if clause covers both these cases.
// Technically this is the case for dialling from la Réunion to other
// overseas departments of France (French Guiana, Martinique, Guadeloupe),
// but not vice versa - so we don't cover this edge case for now and for
// those cases return the version including country calling code.
// Details here:
// http://www.petitfute.com/voyage/225-info-pratiques-reunion
Format(number, NATIONAL, formatted_number);
return;
}
// Metadata cannot be NULL because we checked 'IsValidRegionCode()' above.
const PhoneMetadata* metadata_calling_from =
GetMetadataForRegion(calling_from);
const string& international_prefix =
metadata_calling_from->international_prefix();
// For regions that have multiple international prefixes, the international
// format of the number is returned, unless there is a preferred international
// prefix.
const string international_prefix_for_formatting(
reg_exps_->single_international_prefix_->FullMatch(international_prefix)
? international_prefix
: metadata_calling_from->preferred_international_prefix());
string region_code;
GetRegionCodeForCountryCode(country_code, ®ion_code);
// Metadata cannot be NULL because the country_code is valid.
const PhoneMetadata* metadata_for_region =
GetMetadataForRegionOrCallingCode(country_code, region_code);
FormatNsn(national_significant_number, *metadata_for_region, INTERNATIONAL,
formatted_number);
MaybeAppendFormattedExtension(number, *metadata_for_region, INTERNATIONAL,
formatted_number);
if (!international_prefix_for_formatting.empty()) {
formatted_number->insert(
0, StrCat(international_prefix_for_formatting, " ", country_code, " "));
} else {
PrefixNumberWithCountryCallingCode(country_code, INTERNATIONAL,
formatted_number);
}
}
void PhoneNumberUtil::FormatInOriginalFormat(const PhoneNumber& number,
const string& region_calling_from,
string* formatted_number) const {
DCHECK(formatted_number);
if (number.has_raw_input() && !HasFormattingPatternForNumber(number)) {
// We check if we have the formatting pattern because without that, we might
// format the number as a group without national prefix.
formatted_number->assign(number.raw_input());
return;
}
if (!number.has_country_code_source()) {
Format(number, NATIONAL, formatted_number);
return;
}
switch (number.country_code_source()) {
case PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN:
Format(number, INTERNATIONAL, formatted_number);
break;
case PhoneNumber::FROM_NUMBER_WITH_IDD:
FormatOutOfCountryCallingNumber(number, region_calling_from,
formatted_number);
break;
case PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN:
Format(number, INTERNATIONAL, formatted_number);
formatted_number->erase(formatted_number->begin());
break;
case PhoneNumber::FROM_DEFAULT_COUNTRY:
// Fall-through to default case.
default:
string region_code;
GetRegionCodeForCountryCode(number.country_code(), ®ion_code);
// We strip non-digits from the NDD here, and from the raw input later, so
// that we can compare them easily.
string national_prefix;
GetNddPrefixForRegion(region_code, true /* strip non-digits */,
&national_prefix);
if (national_prefix.empty()) {
// If the region doesn't have a national prefix at all, we can safely
// return the national format without worrying about a national prefix
// being added.
Format(number, NATIONAL, formatted_number);
break;
}
// Otherwise, we check if the original number was entered with a national
// prefix.
if (RawInputContainsNationalPrefix(number.raw_input(), national_prefix,
region_code)) {
// If so, we can safely return the national format.
Format(number, NATIONAL, formatted_number);
break;
}
// Metadata cannot be NULL here because GetNddPrefixForRegion() (above)
// leaves the prefix empty if there is no metadata for the region.
const PhoneMetadata* metadata = GetMetadataForRegion(region_code);
string national_number;
GetNationalSignificantNumber(number, &national_number);
// This shouldn't be NULL, because we have checked that above with
// HasFormattingPatternForNumber.
const NumberFormat* format_rule =
ChooseFormattingPatternForNumber(metadata->number_format(),
national_number);
// The format rule could still be NULL here if the national number was 0
// and there was no raw input (this should not be possible for numbers
// generated by the phonenumber library as they would also not have a
// country calling code and we would have exited earlier).
if (!format_rule) {
Format(number, NATIONAL, formatted_number);
break;
}
// When the format we apply to this number doesn't contain national
// prefix, we can just return the national format.
// TODO: Refactor the code below with the code in
// IsNationalPrefixPresentIfRequired.
string candidate_national_prefix_rule(
format_rule->national_prefix_formatting_rule());
// We assume that the first-group symbol will never be _before_ the
// national prefix.
if (!candidate_national_prefix_rule.empty()) {
size_t index_of_first_group = candidate_national_prefix_rule.find("$1");
if (index_of_first_group == string::npos) {
LOG(ERROR) << "First group missing in national prefix rule: "
<< candidate_national_prefix_rule;
Format(number, NATIONAL, formatted_number);
break;
}
candidate_national_prefix_rule.erase(index_of_first_group);
NormalizeDigitsOnly(&candidate_national_prefix_rule);
}
if (candidate_national_prefix_rule.empty()) {
// National prefix not used when formatting this number.
Format(number, NATIONAL, formatted_number);
break;
}
// Otherwise, we need to remove the national prefix from our output.
RepeatedPtrField<NumberFormat> number_formats;
NumberFormat* number_format = number_formats.Add();
number_format->MergeFrom(*format_rule);
number_format->clear_national_prefix_formatting_rule();
FormatByPattern(number, NATIONAL, number_formats, formatted_number);
break;
}
// If no digit is inserted/removed/modified as a result of our formatting, we
// return the formatted phone number; otherwise we return the raw input the
// user entered.
if (!formatted_number->empty() && !number.raw_input().empty()) {
string normalized_formatted_number(*formatted_number);
NormalizeDiallableCharsOnly(&normalized_formatted_number);
string normalized_raw_input(number.raw_input());
NormalizeDiallableCharsOnly(&normalized_raw_input);
if (normalized_formatted_number != normalized_raw_input) {
formatted_number->assign(number.raw_input());
}
}
}
// Check if raw_input, which is assumed to be in the national format, has a
// national prefix. The national prefix is assumed to be in digits-only form.
bool PhoneNumberUtil::RawInputContainsNationalPrefix(
const string& raw_input,
const string& national_prefix,
const string& region_code) const {
string normalized_national_number(raw_input);
NormalizeDigitsOnly(&normalized_national_number);
if (HasPrefixString(normalized_national_number, national_prefix)) {
// Some Japanese numbers (e.g. 00777123) might be mistaken to contain
// the national prefix when written without it (e.g. 0777123) if we just
// do prefix matching. To tackle that, we check the validity of the
// number if the assumed national prefix is removed (777123 won't be
// valid in Japan).
PhoneNumber number_without_national_prefix;
if (Parse(normalized_national_number.substr(national_prefix.length()),
region_code, &number_without_national_prefix)
== NO_PARSING_ERROR) {
return IsValidNumber(number_without_national_prefix);
}
}
return false;
}
bool PhoneNumberUtil::HasFormattingPatternForNumber(
const PhoneNumber& number) const {
int country_calling_code = number.country_code();
string region_code;
GetRegionCodeForCountryCode(country_calling_code, ®ion_code);
const PhoneMetadata* metadata =
GetMetadataForRegionOrCallingCode(country_calling_code, region_code);
if (!metadata) {
return false;
}
string national_number;
GetNationalSignificantNumber(number, &national_number);
const NumberFormat* format_rule =
ChooseFormattingPatternForNumber(metadata->number_format(),
national_number);
return format_rule;
}
void PhoneNumberUtil::FormatOutOfCountryKeepingAlphaChars(
const PhoneNumber& number,
const string& calling_from,
string* formatted_number) const {
// If there is no raw input, then we can't keep alpha characters because there
// aren't any. In this case, we return FormatOutOfCountryCallingNumber.
if (number.raw_input().empty()) {
FormatOutOfCountryCallingNumber(number, calling_from, formatted_number);
return;
}
int country_code = number.country_code();
if (!HasValidCountryCallingCode(country_code)) {
formatted_number->assign(number.raw_input());
return;
}
// Strip any prefix such as country calling code, IDD, that was present. We do
// this by comparing the number in raw_input with the parsed number.
string raw_input_copy(number.raw_input());
// Normalize punctuation. We retain number grouping symbols such as " " only.
NormalizeHelper(reg_exps_->all_plus_number_grouping_symbols_, true,
&raw_input_copy);
// Now we trim everything before the first three digits in the parsed number.
// We choose three because all valid alpha numbers have 3 digits at the start
// - if it does not, then we don't trim anything at all. Similarly, if the
// national number was less than three digits, we don't trim anything at all.
string national_number;
GetNationalSignificantNumber(number, &national_number);
if (national_number.length() > 3) {
size_t first_national_number_digit =
raw_input_copy.find(national_number.substr(0, 3));
if (first_national_number_digit != string::npos) {
raw_input_copy = raw_input_copy.substr(first_national_number_digit);
}
}
const PhoneMetadata* metadata = GetMetadataForRegion(calling_from);
if (country_code == kNanpaCountryCode) {
if (IsNANPACountry(calling_from)) {
StrAppend(formatted_number, country_code, " ", raw_input_copy);
return;
}
} else if (metadata &&
country_code == GetCountryCodeForValidRegion(calling_from)) {
const NumberFormat* formatting_pattern =
ChooseFormattingPatternForNumber(metadata->number_format(),
national_number);
if (!formatting_pattern) {
// If no pattern above is matched, we format the original input.
formatted_number->assign(raw_input_copy);
return;
}
NumberFormat new_format;
new_format.MergeFrom(*formatting_pattern);
// The first group is the first group of digits that the user wrote
// together.
new_format.set_pattern("(\\d+)(.*)");
// Here we just concatenate them back together after the national prefix
// has been fixed.
new_format.set_format("$1$2");
// Now we format using this pattern instead of the default pattern, but
// with the national prefix prefixed if necessary.
// This will not work in the cases where the pattern (and not the
// leading digits) decide whether a national prefix needs to be used, since
// we have overridden the pattern to match anything, but that is not the
// case in the metadata to date.
FormatNsnUsingPattern(raw_input_copy, new_format, NATIONAL,
formatted_number);
return;
}
string international_prefix_for_formatting;
// If an unsupported region-calling-from is entered, or a country with
// multiple international prefixes, the international format of the number is
// returned, unless there is a preferred international prefix.
if (metadata) {
const string& international_prefix = metadata->international_prefix();
international_prefix_for_formatting =
reg_exps_->single_international_prefix_->FullMatch(international_prefix)
? international_prefix
: metadata->preferred_international_prefix();
}
if (!international_prefix_for_formatting.empty()) {
StrAppend(formatted_number, international_prefix_for_formatting, " ",
country_code, " ", raw_input_copy);
} else {
// Invalid region entered as country-calling-from (so no metadata was found
// for it) or the region chosen has multiple international dialling
// prefixes.
if (!IsValidRegionCode(calling_from)) {
VLOG(1) << "Trying to format number from invalid region " << calling_from
<< ". International formatting applied.";
}
formatted_number->assign(raw_input_copy);
PrefixNumberWithCountryCallingCode(country_code, INTERNATIONAL,
formatted_number);
}
}
const NumberFormat* PhoneNumberUtil::ChooseFormattingPatternForNumber(
const RepeatedPtrField<NumberFormat>& available_formats,
const string& national_number) const {
for (RepeatedPtrField<NumberFormat>::const_iterator
it = available_formats.begin(); it != available_formats.end(); ++it) {
int size = it->leading_digits_pattern_size();
if (size > 0) {
const scoped_ptr<RegExpInput> number_copy(
reg_exps_->regexp_factory_->CreateInput(national_number));
// We always use the last leading_digits_pattern, as it is the most
// detailed.
if (!reg_exps_->regexp_cache_->GetRegExp(
it->leading_digits_pattern(size - 1)).Consume(
number_copy.get())) {
continue;
}
}
const RegExp& pattern_to_match(
reg_exps_->regexp_cache_->GetRegExp(it->pattern()));
if (pattern_to_match.FullMatch(national_number)) {
return &(*it);
}
}
return NULL;
}
// Note that carrier_code is optional - if an empty string, no carrier code
// replacement will take place.
void PhoneNumberUtil::FormatNsnUsingPatternWithCarrier(
const string& national_number,
const NumberFormat& formatting_pattern,
PhoneNumberUtil::PhoneNumberFormat number_format,
const string& carrier_code,
string* formatted_number) const {
DCHECK(formatted_number);
string number_format_rule(formatting_pattern.format());
if (number_format == PhoneNumberUtil::NATIONAL &&
carrier_code.length() > 0 &&
formatting_pattern.domestic_carrier_code_formatting_rule().length() > 0) {
// Replace the $CC in the formatting rule with the desired carrier code.
string carrier_code_formatting_rule =
formatting_pattern.domestic_carrier_code_formatting_rule();
reg_exps_->carrier_code_pattern_->Replace(&carrier_code_formatting_rule,
carrier_code);
reg_exps_->first_group_capturing_pattern_->
Replace(&number_format_rule, carrier_code_formatting_rule);
} else {
// Use the national prefix formatting rule instead.
string national_prefix_formatting_rule =
formatting_pattern.national_prefix_formatting_rule();
if (number_format == PhoneNumberUtil::NATIONAL &&
national_prefix_formatting_rule.length() > 0) {
// Apply the national_prefix_formatting_rule as the formatting_pattern
// contains only information on how the national significant number
// should be formatted at this point.
reg_exps_->first_group_capturing_pattern_->Replace(
&number_format_rule, national_prefix_formatting_rule);
}
}
formatted_number->assign(national_number);
const RegExp& pattern_to_match(
reg_exps_->regexp_cache_->GetRegExp(formatting_pattern.pattern()));
pattern_to_match.GlobalReplace(formatted_number, number_format_rule);
if (number_format == RFC3966) {
// First consume any leading punctuation, if any was present.
const scoped_ptr<RegExpInput> number(
reg_exps_->regexp_factory_->CreateInput(*formatted_number));
if (reg_exps_->separator_pattern_->Consume(number.get())) {
formatted_number->assign(number->ToString());
}
// Then replace all separators with a "-".
reg_exps_->separator_pattern_->GlobalReplace(formatted_number, "-");
}
}
// Simple wrapper of FormatNsnUsingPatternWithCarrier for the common case of
// no carrier code.
void PhoneNumberUtil::FormatNsnUsingPattern(
const string& national_number,
const NumberFormat& formatting_pattern,
PhoneNumberUtil::PhoneNumberFormat number_format,
string* formatted_number) const {
DCHECK(formatted_number);
FormatNsnUsingPatternWithCarrier(national_number, formatting_pattern,
number_format, "", formatted_number);
}
void PhoneNumberUtil::FormatNsn(const string& number,
const PhoneMetadata& metadata,
PhoneNumberFormat number_format,
string* formatted_number) const {
DCHECK(formatted_number);
FormatNsnWithCarrier(number, metadata, number_format, "", formatted_number);
}
// Note in some regions, the national number can be written in two completely
// different ways depending on whether it forms part of the NATIONAL format or
// INTERNATIONAL format. The number_format parameter here is used to specify
// which format to use for those cases. If a carrier_code is specified, this
// will be inserted into the formatted string to replace $CC.
void PhoneNumberUtil::FormatNsnWithCarrier(const string& number,
const PhoneMetadata& metadata,
PhoneNumberFormat number_format,
const string& carrier_code,
string* formatted_number) const {
DCHECK(formatted_number);
// When the intl_number_formats exists, we use that to format national number
// for the INTERNATIONAL format instead of using the number_formats.
const RepeatedPtrField<NumberFormat> available_formats =
(metadata.intl_number_format_size() == 0 || number_format == NATIONAL)
? metadata.number_format()
: metadata.intl_number_format();
const NumberFormat* formatting_pattern =
ChooseFormattingPatternForNumber(available_formats, number);
if (!formatting_pattern) {
formatted_number->assign(number);
} else {
FormatNsnUsingPatternWithCarrier(number, *formatting_pattern, number_format,
carrier_code, formatted_number);
}
}
// Appends the formatted extension of a phone number, if the phone number had an
// extension specified.
void PhoneNumberUtil::MaybeAppendFormattedExtension(
const PhoneNumber& number,
const PhoneMetadata& metadata,
PhoneNumberFormat number_format,
string* formatted_number) const {
DCHECK(formatted_number);
if (number.has_extension() && number.extension().length() > 0) {
if (number_format == RFC3966) {
StrAppend(formatted_number, kRfc3966ExtnPrefix, number.extension());
} else {
if (metadata.has_preferred_extn_prefix()) {
StrAppend(formatted_number, metadata.preferred_extn_prefix(),
number.extension());
} else {
StrAppend(formatted_number, kDefaultExtnPrefix, number.extension());
}
}
}
}
bool PhoneNumberUtil::IsNANPACountry(const string& region_code) const {
return nanpa_regions_->find(region_code) != nanpa_regions_->end();
}
// Returns the region codes that matches the specific country calling code. In
// the case of no region code being found, region_codes will be left empty.
void PhoneNumberUtil::GetRegionCodesForCountryCallingCode(
int country_calling_code,
std::list<string>* region_codes) const {
DCHECK(region_codes);
// Create a IntRegionsPair with the country_code passed in, and use it to
// locate the pair with the same country_code in the sorted vector.
IntRegionsPair target_pair;
target_pair.first = country_calling_code;
typedef std::vector<IntRegionsPair>::const_iterator ConstIterator;
std::pair<ConstIterator, ConstIterator> range =
std::equal_range(country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end(),
target_pair, OrderByFirst());
if (range.first != range.second) {
region_codes->insert(region_codes->begin(),
range.first->second->begin(),
range.first->second->end());
}
}
// Returns the region code that matches the specific country calling code. In
// the case of no region code being found, the unknown region code will be
// returned.
void PhoneNumberUtil::GetRegionCodeForCountryCode(
int country_calling_code,
string* region_code) const {
DCHECK(region_code);
std::list<string> region_codes;
GetRegionCodesForCountryCallingCode(country_calling_code, ®ion_codes);
*region_code = (region_codes.size() > 0) ?
region_codes.front() : RegionCode::GetUnknown();
}
void PhoneNumberUtil::GetRegionCodeForNumber(const PhoneNumber& number,
string* region_code) const {
DCHECK(region_code);
int country_calling_code = number.country_code();
std::list<string> region_codes;
GetRegionCodesForCountryCallingCode(country_calling_code, ®ion_codes);
if (region_codes.size() == 0) {
VLOG(1) << "Missing/invalid country calling code ("
<< country_calling_code << ")";
*region_code = RegionCode::GetUnknown();
return;
}
if (region_codes.size() == 1) {
*region_code = region_codes.front();
} else {
GetRegionCodeForNumberFromRegionList(number, region_codes, region_code);
}
}
void PhoneNumberUtil::GetRegionCodeForNumberFromRegionList(
const PhoneNumber& number, const std::list<string>& region_codes,
string* region_code) const {
DCHECK(region_code);
string national_number;
GetNationalSignificantNumber(number, &national_number);
for (std::list<string>::const_iterator it = region_codes.begin();
it != region_codes.end(); ++it) {
// Metadata cannot be NULL because the region codes come from the country
// calling code map.
const PhoneMetadata* metadata = GetMetadataForRegion(*it);
if (metadata->has_leading_digits()) {
const scoped_ptr<RegExpInput> number(
reg_exps_->regexp_factory_->CreateInput(national_number));
if (reg_exps_->regexp_cache_->
GetRegExp(metadata->leading_digits()).Consume(number.get())) {
*region_code = *it;
return;
}
} else if (GetNumberTypeHelper(national_number, *metadata) != UNKNOWN) {
*region_code = *it;
return;
}
}
*region_code = RegionCode::GetUnknown();
}
int PhoneNumberUtil::GetCountryCodeForRegion(const string& region_code) const {
if (!IsValidRegionCode(region_code)) {
LOG(WARNING) << "Invalid or unknown region code (" << region_code
<< ") provided.";
return 0;
}
return GetCountryCodeForValidRegion(region_code);
}
int PhoneNumberUtil::GetCountryCodeForValidRegion(
const string& region_code) const {
const PhoneMetadata* metadata = GetMetadataForRegion(region_code);
return metadata->country_code();
}
// Gets a valid fixed-line number for the specified region_code. Returns false
// if the region was unknown or 001 (representing non-geographical regions), or
// if no number exists.
bool PhoneNumberUtil::GetExampleNumber(const string& region_code,
PhoneNumber* number) const {
DCHECK(number);
return GetExampleNumberForType(region_code, FIXED_LINE, number);
}
bool PhoneNumberUtil::GetInvalidExampleNumber(const string& region_code,
PhoneNumber* number) const {
DCHECK(number);
if (!IsValidRegionCode(region_code)) {
LOG(WARNING) << "Invalid or unknown region code (" << region_code
<< ") provided.";
return false;
}
// We start off with a valid fixed-line number since every country supports
// this. Alternatively we could start with a different number type, since
// fixed-line numbers typically have a wide breadth of valid number lengths
// and we may have to make it very short before we get an invalid number.
const PhoneMetadata* region_metadata = GetMetadataForRegion(region_code);
const PhoneNumberDesc* desc =
GetNumberDescByType(*region_metadata, FIXED_LINE);
if (!desc->has_example_number()) {
// This shouldn't happen - we have a test for this.
return false;
}
const string& example_number = desc->example_number();
// Try and make the number invalid. We do this by changing the length. We try
// reducing the length of the number, since currently no region has a number
// that is the same length as kMinLengthForNsn. This is probably quicker than
// making the number longer, which is another alternative. We could also use
// the possible number pattern to extract the possible lengths of the number
// to make this faster, but this method is only for unit-testing so simplicity
// is preferred to performance.
// We don't want to return a number that can't be parsed, so we check the
// number is long enough. We try all possible lengths because phone number
// plans often have overlapping prefixes so the number 123456 might be valid
// as a fixed-line number, and 12345 as a mobile number. It would be faster to
// loop in a different order, but we prefer numbers that look closer to real
// numbers (and it gives us a variety of different lengths for the resulting
// phone numbers - otherwise they would all be kMinLengthForNsn digits long.)
for (size_t phone_number_length = example_number.length() - 1;
phone_number_length >= kMinLengthForNsn;
phone_number_length--) {
string number_to_try = example_number.substr(0, phone_number_length);
PhoneNumber possibly_valid_number;
Parse(number_to_try, region_code, &possibly_valid_number);
// We don't check the return value since we have already checked the
// length, we know example numbers have only valid digits, and we know the
// region code is fine.
if (!IsValidNumber(possibly_valid_number)) {
number->MergeFrom(possibly_valid_number);
return true;
}
}
// We have a test to check that this doesn't happen for any of our supported
// regions.
return false;
}
// Gets a valid number for the specified region_code and type. Returns false if
// the country was unknown or 001 (representing non-geographical regions), or if
// no number exists.
bool PhoneNumberUtil::GetExampleNumberForType(
const string& region_code,
PhoneNumberUtil::PhoneNumberType type,
PhoneNumber* number) const {
DCHECK(number);
if (!IsValidRegionCode(region_code)) {
LOG(WARNING) << "Invalid or unknown region code (" << region_code
<< ") provided.";
return false;
}
const PhoneMetadata* region_metadata = GetMetadataForRegion(region_code);
const PhoneNumberDesc* desc = GetNumberDescByType(*region_metadata, type);
if (desc && desc->has_example_number()) {
ErrorType success = Parse(desc->example_number(), region_code, number);
if (success == NO_PARSING_ERROR) {
return true;
} else {
LOG(ERROR) << "Error parsing example number ("
<< static_cast<int>(success) << ")";
}
}
return false;
}
bool PhoneNumberUtil::GetExampleNumberForType(
PhoneNumberUtil::PhoneNumberType type,
PhoneNumber* number) const {
DCHECK(number);
std::set<string> regions;
GetSupportedRegions(®ions);
for (std::set<string>::const_iterator it = regions.begin();
it != regions.end(); ++it) {
if (GetExampleNumberForType(*it, type, number)) {
return true;
}
}
// If there wasn't an example number for a region, try the non-geographical
// entities.
std::set<int> global_network_calling_codes;
GetSupportedGlobalNetworkCallingCodes(&global_network_calling_codes);
for (std::set<int>::const_iterator it = global_network_calling_codes.begin();
it != global_network_calling_codes.end(); ++it) {
int country_calling_code = *it;
const PhoneMetadata* metadata =
GetMetadataForNonGeographicalRegion(country_calling_code);
const PhoneNumberDesc* desc = GetNumberDescByType(*metadata, type);
if (desc->has_example_number()) {
ErrorType success = Parse(StrCat(kPlusSign,
country_calling_code,
desc->example_number()),
RegionCode::GetUnknown(), number);
if (success == NO_PARSING_ERROR) {
return true;
} else {
LOG(ERROR) << "Error parsing example number ("
<< static_cast<int>(success) << ")";
}
}
}
// There are no example numbers of this type for any country in the library.
return false;
}
bool PhoneNumberUtil::GetExampleNumberForNonGeoEntity(
int country_calling_code, PhoneNumber* number) const {
DCHECK(number);
const PhoneMetadata* metadata =
GetMetadataForNonGeographicalRegion(country_calling_code);
if (metadata) {
// For geographical entities, fixed-line data is always present. However,
// for non-geographical entities, this is not the case, so we have to go
// through different types to find the example number. We don't check
// fixed-line or personal number since they aren't used by non-geographical
// entities (if this changes, a unit-test will catch this.)
const int kNumberTypes = 7;
PhoneNumberDesc types[kNumberTypes] = {
metadata->mobile(), metadata->toll_free(), metadata->shared_cost(),
metadata->voip(), metadata->voicemail(), metadata->uan(),
metadata->premium_rate()};
for (int i = 0; i < kNumberTypes; ++i) {
if (types[i].has_example_number()) {
ErrorType success = Parse(StrCat(kPlusSign,
SimpleItoa(country_calling_code),
types[i].example_number()),
RegionCode::GetUnknown(), number);
if (success == NO_PARSING_ERROR) {
return true;
} else {
LOG(ERROR) << "Error parsing example number ("
<< static_cast<int>(success) << ")";
}
}
}
} else {
LOG(WARNING) << "Invalid or unknown country calling code provided: "
<< country_calling_code;
}
return false;
}
PhoneNumberUtil::ErrorType PhoneNumberUtil::Parse(const string& number_to_parse,
const string& default_region,
PhoneNumber* number) const {
DCHECK(number);
return ParseHelper(number_to_parse, default_region, false, true, number);
}
PhoneNumberUtil::ErrorType PhoneNumberUtil::ParseAndKeepRawInput(
const string& number_to_parse,
const string& default_region,
PhoneNumber* number) const {
DCHECK(number);
return ParseHelper(number_to_parse, default_region, true, true, number);
}
// Checks to see that the region code used is valid, or if it is not valid, that
// the number to parse starts with a + symbol so that we can attempt to infer
// the country from the number. Returns false if it cannot use the region
// provided and the region cannot be inferred.
bool PhoneNumberUtil::CheckRegionForParsing(
const string& number_to_parse,
const string& default_region) const {
if (!IsValidRegionCode(default_region) && !number_to_parse.empty()) {
const scoped_ptr<RegExpInput> number(
reg_exps_->regexp_factory_->CreateInput(number_to_parse));
if (!reg_exps_->plus_chars_pattern_->Consume(number.get())) {
return false;
}
}
return true;
}
// Converts number_to_parse to a form that we can parse and write it to
// national_number if it is written in RFC3966; otherwise extract a possible
// number out of it and write to national_number.
void PhoneNumberUtil::BuildNationalNumberForParsing(
const string& number_to_parse, string* national_number) const {
size_t index_of_phone_context = number_to_parse.find(kRfc3966PhoneContext);
if (index_of_phone_context != string::npos) {
size_t phone_context_start =
index_of_phone_context + strlen(kRfc3966PhoneContext);
// If the phone context contains a phone number prefix, we need to capture
// it, whereas domains will be ignored.
if (phone_context_start < (number_to_parse.length() - 1) &&
number_to_parse.at(phone_context_start) == kPlusSign[0]) {
// Additional parameters might follow the phone context. If so, we will
// remove them here because the parameters after phone context are not
// important for parsing the phone number.
size_t phone_context_end = number_to_parse.find(';', phone_context_start);
if (phone_context_end != string::npos) {
StrAppend(
national_number, number_to_parse.substr(
phone_context_start, phone_context_end - phone_context_start));
} else {
StrAppend(national_number, number_to_parse.substr(phone_context_start));
}
}
// Now append everything between the "tel:" prefix and the phone-context.
// This should include the national number, an optional extension or
// isdn-subaddress component. Note we also handle the case when "tel:" is
// missing, as we have seen in some of the phone number inputs. In that
// case, we append everything from the beginning.
size_t index_of_rfc_prefix = number_to_parse.find(kRfc3966Prefix);
int index_of_national_number = (index_of_rfc_prefix != string::npos) ?
index_of_rfc_prefix + strlen(kRfc3966Prefix) : 0;
StrAppend(
national_number,
number_to_parse.substr(
index_of_national_number,
index_of_phone_context - index_of_national_number));
} else {
// Extract a possible number from the string passed in (this strips leading
// characters that could not be the start of a phone number.)
ExtractPossibleNumber(number_to_parse, national_number);
}
// Delete the isdn-subaddress and everything after it if it is present. Note
// extension won't appear at the same time with isdn-subaddress according to
// paragraph 5.3 of the RFC3966 spec.
size_t index_of_isdn = national_number->find(kRfc3966IsdnSubaddress);
if (index_of_isdn != string::npos) {
national_number->erase(index_of_isdn);
}
// If both phone context and isdn-subaddress are absent but other parameters
// are present, the parameters are left in nationalNumber. This is because
// we are concerned about deleting content from a potential number string
// when there is no strong evidence that the number is actually written in
// RFC3966.
}
// Note if any new field is added to this method that should always be filled
// in, even when keepRawInput is false, it should also be handled in the
// CopyCoreFieldsOnly() method.
PhoneNumberUtil::ErrorType PhoneNumberUtil::ParseHelper(
const string& number_to_parse,
const string& default_region,
bool keep_raw_input,
bool check_region,
PhoneNumber* phone_number) const {
DCHECK(phone_number);
string national_number;
BuildNationalNumberForParsing(number_to_parse, &national_number);
if (!IsViablePhoneNumber(national_number)) {
VLOG(2) << "The string supplied did not seem to be a phone number.";
return NOT_A_NUMBER;
}
if (check_region &&
!CheckRegionForParsing(national_number, default_region)) {
VLOG(1) << "Missing or invalid default country.";
return INVALID_COUNTRY_CODE_ERROR;
}
PhoneNumber temp_number;
if (keep_raw_input) {
temp_number.set_raw_input(number_to_parse);
}
// Attempt to parse extension first, since it doesn't require country-specific
// data and we want to have the non-normalised number here.
string extension;
MaybeStripExtension(&national_number, &extension);
if (!extension.empty()) {
temp_number.set_extension(extension);
}
const PhoneMetadata* country_metadata = GetMetadataForRegion(default_region);
// Check to see if the number is given in international format so we know
// whether this number is from the default country or not.
string normalized_national_number(national_number);
ErrorType country_code_error =
MaybeExtractCountryCode(country_metadata, keep_raw_input,
&normalized_national_number, &temp_number);
if (country_code_error != NO_PARSING_ERROR) {
const scoped_ptr<RegExpInput> number_string_piece(
reg_exps_->regexp_factory_->CreateInput(national_number));
if ((country_code_error == INVALID_COUNTRY_CODE_ERROR) &&
(reg_exps_->plus_chars_pattern_->Consume(number_string_piece.get()))) {
normalized_national_number.assign(number_string_piece->ToString());
// Strip the plus-char, and try again.
MaybeExtractCountryCode(country_metadata,
keep_raw_input,
&normalized_national_number,
&temp_number);
if (temp_number.country_code() == 0) {
return INVALID_COUNTRY_CODE_ERROR;
}
} else {
return country_code_error;
}
}
int country_code = temp_number.country_code();
if (country_code != 0) {
string phone_number_region;
GetRegionCodeForCountryCode(country_code, &phone_number_region);
if (phone_number_region != default_region) {
country_metadata =
GetMetadataForRegionOrCallingCode(country_code, phone_number_region);
}
} else if (country_metadata) {
// If no extracted country calling code, use the region supplied instead.
// Note that the national number was already normalized by
// MaybeExtractCountryCode.
country_code = country_metadata->country_code();
}
if (normalized_national_number.length() < kMinLengthForNsn) {
VLOG(2) << "The string supplied is too short to be a phone number.";
return TOO_SHORT_NSN;
}
if (country_metadata) {
string carrier_code;
string potential_national_number(normalized_national_number);
MaybeStripNationalPrefixAndCarrierCode(*country_metadata,
&potential_national_number,
&carrier_code);
// We require that the NSN remaining after stripping the national prefix
// and carrier code be long enough to be a possible length for the region.
// Otherwise, we don't do the stripping, since the original number could be
// a valid short number.
ValidationResult validation_result =
TestNumberLength(potential_national_number, *country_metadata);
if (validation_result != TOO_SHORT &&
validation_result != IS_POSSIBLE_LOCAL_ONLY &&
validation_result != INVALID_LENGTH) {
normalized_national_number.assign(potential_national_number);
if (keep_raw_input && !carrier_code.empty()) {
temp_number.set_preferred_domestic_carrier_code(carrier_code);
}
}
}
size_t normalized_national_number_length =
normalized_national_number.length();
if (normalized_national_number_length < kMinLengthForNsn) {
VLOG(2) << "The string supplied is too short to be a phone number.";
return TOO_SHORT_NSN;
}
if (normalized_national_number_length > kMaxLengthForNsn) {
VLOG(2) << "The string supplied is too long to be a phone number.";
return TOO_LONG_NSN;
}
temp_number.set_country_code(country_code);
SetItalianLeadingZerosForPhoneNumber(normalized_national_number,
&temp_number);
uint64 number_as_int;
safe_strtou64(normalized_national_number, &number_as_int);
temp_number.set_national_number(number_as_int);
phone_number->Swap(&temp_number);
return NO_PARSING_ERROR;
}
// Attempts to extract a possible number from the string passed in. This
// currently strips all leading characters that could not be used to start a
// phone number. Characters that can be used to start a phone number are
// defined in the valid_start_char_pattern. If none of these characters are
// found in the number passed in, an empty string is returned. This function
// also attempts to strip off any alternative extensions or endings if two or
// more are present, such as in the case of: (530) 583-6985 x302/x2303. The
// second extension here makes this actually two phone numbers, (530) 583-6985
// x302 and (530) 583-6985 x2303. We remove the second extension so that the
// first number is parsed correctly.
void PhoneNumberUtil::ExtractPossibleNumber(const string& number,
string* extracted_number) const {
DCHECK(extracted_number);
UnicodeText number_as_unicode;
number_as_unicode.PointToUTF8(number.data(), number.size());
char current_char[5];
int len;
UnicodeText::const_iterator it;
for (it = number_as_unicode.begin(); it != number_as_unicode.end(); ++it) {
len = it.get_utf8(current_char);
current_char[len] = '\0';
if (reg_exps_->valid_start_char_pattern_->FullMatch(current_char)) {
break;
}
}
if (it == number_as_unicode.end()) {
// No valid start character was found. extracted_number should be set to
// empty string.
extracted_number->assign("");
return;
}
extracted_number->assign(
UnicodeText::UTF8Substring(it, number_as_unicode.end()));
TrimUnwantedEndChars(extracted_number);
if (extracted_number->length() == 0) {
return;
}
// Now remove any extra numbers at the end.
reg_exps_->capture_up_to_second_number_start_pattern_->
PartialMatch(*extracted_number, extracted_number);
}
bool PhoneNumberUtil::IsPossibleNumber(const PhoneNumber& number) const {
ValidationResult result = IsPossibleNumberWithReason(number);
return result == IS_POSSIBLE || result == IS_POSSIBLE_LOCAL_ONLY;
}
bool PhoneNumberUtil::IsPossibleNumberForType(
const PhoneNumber& number, const PhoneNumberType type) const {
ValidationResult result = IsPossibleNumberForTypeWithReason(number, type);
return result == IS_POSSIBLE || result == IS_POSSIBLE_LOCAL_ONLY;
}
bool PhoneNumberUtil::IsPossibleNumberForString(
const string& number,
const string& region_dialing_from) const {
PhoneNumber number_proto;
if (Parse(number, region_dialing_from, &number_proto) == NO_PARSING_ERROR) {
return IsPossibleNumber(number_proto);
} else {
return false;
}
}
PhoneNumberUtil::ValidationResult PhoneNumberUtil::IsPossibleNumberWithReason(
const PhoneNumber& number) const {
return IsPossibleNumberForTypeWithReason(number, PhoneNumberUtil::UNKNOWN);
}
PhoneNumberUtil::ValidationResult
PhoneNumberUtil::IsPossibleNumberForTypeWithReason(const PhoneNumber& number,
PhoneNumberType type) const {
string national_number;
GetNationalSignificantNumber(number, &national_number);
int country_code = number.country_code();
// Note: For regions that share a country calling code, like NANPA numbers, we
// just use the rules from the default region (US in this case) since the
// GetRegionCodeForNumber will not work if the number is possible but not
// valid. There is in fact one country calling code (290) where the possible
// number pattern differs between various regions (Saint Helena and Tristan da
// Cuñha), but this is handled by putting all possible lengths for any country
// with this country calling code in the metadata for the default region in
// this case.
if (!HasValidCountryCallingCode(country_code)) {
return INVALID_COUNTRY_CODE;
}
string region_code;
GetRegionCodeForCountryCode(country_code, ®ion_code);
// Metadata cannot be NULL because the country calling code is valid.
const PhoneMetadata* metadata =
GetMetadataForRegionOrCallingCode(country_code, region_code);
return TestNumberLength(national_number, *metadata, type);
}
bool PhoneNumberUtil::TruncateTooLongNumber(PhoneNumber* number) const {
if (IsValidNumber(*number)) {
return true;
}
PhoneNumber number_copy(*number);
uint64 national_number = number->national_number();
do {
national_number /= 10;
number_copy.set_national_number(national_number);
if (IsPossibleNumberWithReason(number_copy) == TOO_SHORT ||
national_number == 0) {
return false;
}
} while (!IsValidNumber(number_copy));
number->set_national_number(national_number);
return true;
}
PhoneNumberUtil::PhoneNumberType PhoneNumberUtil::GetNumberType(
const PhoneNumber& number) const {
string region_code;
GetRegionCodeForNumber(number, ®ion_code);
const PhoneMetadata* metadata =
GetMetadataForRegionOrCallingCode(number.country_code(), region_code);
if (!metadata) {
return UNKNOWN;
}
string national_significant_number;
GetNationalSignificantNumber(number, &national_significant_number);
return GetNumberTypeHelper(national_significant_number, *metadata);
}
bool PhoneNumberUtil::IsValidNumber(const PhoneNumber& number) const {
string region_code;
GetRegionCodeForNumber(number, ®ion_code);
return IsValidNumberForRegion(number, region_code);
}
bool PhoneNumberUtil::IsValidNumberForRegion(const PhoneNumber& number,
const string& region_code) const {
int country_code = number.country_code();
const PhoneMetadata* metadata =
GetMetadataForRegionOrCallingCode(country_code, region_code);
if (!metadata ||
((kRegionCodeForNonGeoEntity != region_code) &&
country_code != GetCountryCodeForValidRegion(region_code))) {
// Either the region code was invalid, or the country calling code for this
// number does not match that of the region code.
return false;
}
string national_number;
GetNationalSignificantNumber(number, &national_number);
return GetNumberTypeHelper(national_number, *metadata) != UNKNOWN;
}
bool PhoneNumberUtil::IsNumberGeographical(
const PhoneNumber& phone_number) const {
return IsNumberGeographical(GetNumberType(phone_number),
phone_number.country_code());
}
bool PhoneNumberUtil::IsNumberGeographical(
PhoneNumberType phone_number_type, int country_calling_code) const {
return phone_number_type == PhoneNumberUtil::FIXED_LINE ||
phone_number_type == PhoneNumberUtil::FIXED_LINE_OR_MOBILE ||
(reg_exps_->geo_mobile_countries_.find(country_calling_code)
!= reg_exps_->geo_mobile_countries_.end() &&
phone_number_type == PhoneNumberUtil::MOBILE);
}
// A helper function to set the values related to leading zeros in a
// PhoneNumber.
void PhoneNumberUtil::SetItalianLeadingZerosForPhoneNumber(
const string& national_number, PhoneNumber* phone_number) const {
if (national_number.length() > 1 && national_number[0] == '0') {
phone_number->set_italian_leading_zero(true);
size_t number_of_leading_zeros = 1;
// Note that if the national number is all "0"s, the last "0" is not
// counted as a leading zero.
while (number_of_leading_zeros < national_number.length() - 1 &&
national_number[number_of_leading_zeros] == '0') {
number_of_leading_zeros++;
}
if (number_of_leading_zeros != 1) {
phone_number->set_number_of_leading_zeros(number_of_leading_zeros);
}
}
}
bool PhoneNumberUtil::IsNumberMatchingDesc(
const string& national_number, const PhoneNumberDesc& number_desc) const {
// Check if any possible number lengths are present; if so, we use them to
// avoid checking the validation pattern if they don't match. If they are
// absent, this means they match the general description, which we have
// already checked before checking a specific number type.
int actual_length = national_number.length();
if (number_desc.possible_length_size() > 0 &&
std::find(number_desc.possible_length().begin(),
number_desc.possible_length().end(),
actual_length) == number_desc.possible_length().end()) {
return false;
}
return IsMatch(*matcher_api_, national_number, number_desc);
}
PhoneNumberUtil::PhoneNumberType PhoneNumberUtil::GetNumberTypeHelper(
const string& national_number, const PhoneMetadata& metadata) const {
if (!IsNumberMatchingDesc(national_number, metadata.general_desc())) {
VLOG(4) << "Number type unknown - doesn't match general national number"
<< " pattern.";
return PhoneNumberUtil::UNKNOWN;
}
if (IsNumberMatchingDesc(national_number, metadata.premium_rate())) {
VLOG(4) << "Number is a premium number.";
return PhoneNumberUtil::PREMIUM_RATE;
}
if (IsNumberMatchingDesc(national_number, metadata.toll_free())) {
VLOG(4) << "Number is a toll-free number.";
return PhoneNumberUtil::TOLL_FREE;
}
if (IsNumberMatchingDesc(national_number, metadata.shared_cost())) {
VLOG(4) << "Number is a shared cost number.";
return PhoneNumberUtil::SHARED_COST;
}
if (IsNumberMatchingDesc(national_number, metadata.voip())) {
VLOG(4) << "Number is a VOIP (Voice over IP) number.";
return PhoneNumberUtil::VOIP;
}
if (IsNumberMatchingDesc(national_number, metadata.personal_number())) {
VLOG(4) << "Number is a personal number.";
return PhoneNumberUtil::PERSONAL_NUMBER;
}
if (IsNumberMatchingDesc(national_number, metadata.pager())) {
VLOG(4) << "Number is a pager number.";
return PhoneNumberUtil::PAGER;
}
if (IsNumberMatchingDesc(national_number, metadata.uan())) {
VLOG(4) << "Number is a UAN.";
return PhoneNumberUtil::UAN;
}
if (IsNumberMatchingDesc(national_number, metadata.voicemail())) {
VLOG(4) << "Number is a voicemail number.";
return PhoneNumberUtil::VOICEMAIL;
}
bool is_fixed_line =
IsNumberMatchingDesc(national_number, metadata.fixed_line());
if (is_fixed_line) {
if (metadata.same_mobile_and_fixed_line_pattern()) {
VLOG(4) << "Fixed-line and mobile patterns equal, number is fixed-line"
<< " or mobile";
return PhoneNumberUtil::FIXED_LINE_OR_MOBILE;
} else if (IsNumberMatchingDesc(national_number, metadata.mobile())) {
VLOG(4) << "Fixed-line and mobile patterns differ, but number is "
<< "still fixed-line or mobile";
return PhoneNumberUtil::FIXED_LINE_OR_MOBILE;
}
VLOG(4) << "Number is a fixed line number.";
return PhoneNumberUtil::FIXED_LINE;
}
// Otherwise, test to see if the number is mobile. Only do this if certain
// that the patterns for mobile and fixed line aren't the same.
if (!metadata.same_mobile_and_fixed_line_pattern() &&
IsNumberMatchingDesc(national_number, metadata.mobile())) {
VLOG(4) << "Number is a mobile number.";
return PhoneNumberUtil::MOBILE;
}
VLOG(4) << "Number type unknown - doesn\'t match any specific number type"
<< " pattern.";
return PhoneNumberUtil::UNKNOWN;
}
void PhoneNumberUtil::GetNationalSignificantNumber(
const PhoneNumber& number,
string* national_number) const {
DCHECK(national_number);
// If leading zero(s) have been set, we prefix this now. Note this is not a
// national prefix. Ensure the number of leading zeros is at least 0 so we
// don't crash in the case of malicious input.
StrAppend(national_number, number.italian_leading_zero() ?
string(std::max(number.number_of_leading_zeros(), 0), '0') : "");
StrAppend(national_number, number.national_number());
}
int PhoneNumberUtil::GetLengthOfGeographicalAreaCode(
const PhoneNumber& number) const {
string region_code;
GetRegionCodeForNumber(number, ®ion_code);
const PhoneMetadata* metadata = GetMetadataForRegion(region_code);
if (!metadata) {
return 0;
}
// If a country doesn't use a national prefix, and this number doesn't have an
// Italian leading zero, we assume it is a closed dialling plan with no area
// codes.
if (!metadata->has_national_prefix() && !number.italian_leading_zero()) {
return 0;
}
PhoneNumberType type = GetNumberType(number);
int country_calling_code = number.country_code();
if (type == PhoneNumberUtil::MOBILE &&
reg_exps_->geo_mobile_countries_without_mobile_area_codes_.find(
country_calling_code) !=
reg_exps_->geo_mobile_countries_without_mobile_area_codes_.end()) {
return 0;
}
if (!IsNumberGeographical(type, country_calling_code)) {
return 0;
}
return GetLengthOfNationalDestinationCode(number);
}
int PhoneNumberUtil::GetLengthOfNationalDestinationCode(
const PhoneNumber& number) const {
PhoneNumber copied_proto(number);
if (number.has_extension()) {
// Clear the extension so it's not included when formatting.
copied_proto.clear_extension();
}
string formatted_number;
Format(copied_proto, INTERNATIONAL, &formatted_number);
const scoped_ptr<RegExpInput> i18n_number(
reg_exps_->regexp_factory_->CreateInput(formatted_number));
string digit_group;
string ndc;
string third_group;
for (int i = 0; i < 3; ++i) {
if (!reg_exps_->capturing_ascii_digits_pattern_->FindAndConsume(
i18n_number.get(), &digit_group)) {
// We should find at least three groups.
return 0;
}
if (i == 1) {
ndc = digit_group;
} else if (i == 2) {
third_group = digit_group;
}
}
if (GetNumberType(number) == MOBILE) {
// For example Argentinian mobile numbers, when formatted in the
// international format, are in the form of +54 9 NDC XXXX.... As a result,
// we take the length of the third group (NDC) and add the length of the
// mobile token, which also forms part of the national significant number.
// This assumes that the mobile token is always formatted separately from
// the rest of the phone number.
string mobile_token;
GetCountryMobileToken(number.country_code(), &mobile_token);
if (!mobile_token.empty()) {
return third_group.size() + mobile_token.size();
}
}
return ndc.size();
}
void PhoneNumberUtil::GetCountryMobileToken(int country_calling_code,
string* mobile_token) const {
DCHECK(mobile_token);
std::map<int, char>::iterator it = reg_exps_->mobile_token_mappings_.find(
country_calling_code);
if (it != reg_exps_->mobile_token_mappings_.end()) {
*mobile_token = it->second;
} else {
mobile_token->assign("");
}
}
void PhoneNumberUtil::NormalizeDigitsOnly(string* number) const {
DCHECK(number);
const RegExp& non_digits_pattern = reg_exps_->regexp_cache_->GetRegExp(
StrCat("[^", kDigits, "]"));
// Delete everything that isn't valid digits.
non_digits_pattern.GlobalReplace(number, "");
// Normalize all decimal digits to ASCII digits.
number->assign(NormalizeUTF8::NormalizeDecimalDigits(*number));
}
void PhoneNumberUtil::NormalizeDiallableCharsOnly(string* number) const {
DCHECK(number);
NormalizeHelper(reg_exps_->diallable_char_mappings_,
true /* remove non matches */, number);
}
bool PhoneNumberUtil::IsAlphaNumber(const string& number) const {
if (!IsViablePhoneNumber(number)) {
// Number is too short, or doesn't match the basic phone number pattern.
return false;
}
// Copy the number, since we are going to try and strip the extension from it.
string number_copy(number);
string extension;
MaybeStripExtension(&number_copy, &extension);
return reg_exps_->valid_alpha_phone_pattern_->FullMatch(number_copy);
}
void PhoneNumberUtil::ConvertAlphaCharactersInNumber(string* number) const {
DCHECK(number);
NormalizeHelper(reg_exps_->alpha_phone_mappings_, false, number);
}
// Normalizes a string of characters representing a phone number. This performs
// the following conversions:
// - Punctuation is stripped.
// For ALPHA/VANITY numbers:
// - Letters are converted to their numeric representation on a telephone
// keypad. The keypad used here is the one defined in ITU Recommendation
// E.161. This is only done if there are 3 or more letters in the number, to
// lessen the risk that such letters are typos.
// For other numbers:
// - Wide-ascii digits are converted to normal ASCII (European) digits.
// - Arabic-Indic numerals are converted to European numerals.
// - Spurious alpha characters are stripped.
void PhoneNumberUtil::Normalize(string* number) const {
DCHECK(number);
if (reg_exps_->valid_alpha_phone_pattern_->PartialMatch(*number)) {
NormalizeHelper(reg_exps_->alpha_phone_mappings_, true, number);
}
NormalizeDigitsOnly(number);
}
// Checks to see if the string of characters could possibly be a phone number at
// all. At the moment, checks to see that the string begins with at least 3
// digits, ignoring any punctuation commonly found in phone numbers. This
// method does not require the number to be normalized in advance - but does
// assume that leading non-number symbols have been removed, such as by the
// method ExtractPossibleNumber.
bool PhoneNumberUtil::IsViablePhoneNumber(const string& number) const {
if (number.length() < kMinLengthForNsn) {
return false;
}
return reg_exps_->valid_phone_number_pattern_->FullMatch(number);
}
// Strips the IDD from the start of the number if present. Helper function used
// by MaybeStripInternationalPrefixAndNormalize.
bool PhoneNumberUtil::ParsePrefixAsIdd(const RegExp& idd_pattern,
string* number) const {
DCHECK(number);
const scoped_ptr<RegExpInput> number_copy(
reg_exps_->regexp_factory_->CreateInput(*number));
// First attempt to strip the idd_pattern at the start, if present. We make a
// copy so that we can revert to the original string if necessary.
if (idd_pattern.Consume(number_copy.get())) {
// Only strip this if the first digit after the match is not a 0, since
// country calling codes cannot begin with 0.
string extracted_digit;
if (reg_exps_->capturing_digit_pattern_->PartialMatch(
number_copy->ToString(), &extracted_digit)) {
NormalizeDigitsOnly(&extracted_digit);
if (extracted_digit == "0") {
return false;
}
}
number->assign(number_copy->ToString());
return true;
}
return false;
}
// Strips any international prefix (such as +, 00, 011) present in the number
// provided, normalizes the resulting number, and indicates if an international
// prefix was present.
//
// possible_idd_prefix represents the international direct dialing prefix from
// the region we think this number may be dialed in.
// Returns true if an international dialing prefix could be removed from the
// number, otherwise false if the number did not seem to be in international
// format.
PhoneNumber::CountryCodeSource
PhoneNumberUtil::MaybeStripInternationalPrefixAndNormalize(
const string& possible_idd_prefix,
string* number) const {
DCHECK(number);
if (number->empty()) {
return PhoneNumber::FROM_DEFAULT_COUNTRY;
}
const scoped_ptr<RegExpInput> number_string_piece(
reg_exps_->regexp_factory_->CreateInput(*number));
if (reg_exps_->plus_chars_pattern_->Consume(number_string_piece.get())) {
number->assign(number_string_piece->ToString());
// Can now normalize the rest of the number since we've consumed the "+"
// sign at the start.
Normalize(number);
return PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN;
}
// Attempt to parse the first digits as an international prefix.
const RegExp& idd_pattern =
reg_exps_->regexp_cache_->GetRegExp(possible_idd_prefix);
Normalize(number);
return ParsePrefixAsIdd(idd_pattern, number)
? PhoneNumber::FROM_NUMBER_WITH_IDD
: PhoneNumber::FROM_DEFAULT_COUNTRY;
}
// Strips any national prefix (such as 0, 1) present in the number provided.
// The number passed in should be the normalized telephone number that we wish
// to strip any national dialing prefix from. The metadata should be for the
// region that we think this number is from. Returns true if a national prefix
// and/or carrier code was stripped.
bool PhoneNumberUtil::MaybeStripNationalPrefixAndCarrierCode(
const PhoneMetadata& metadata,
string* number,
string* carrier_code) const {
DCHECK(number);
string carrier_code_temp;
const string& possible_national_prefix =
metadata.national_prefix_for_parsing();
if (number->empty() || possible_national_prefix.empty()) {
// Early return for numbers of zero length or with no national prefix
// possible.
return false;
}
// We use two copies here since Consume modifies the phone number, and if the
// first if-clause fails the number will already be changed.
const scoped_ptr<RegExpInput> number_copy(
reg_exps_->regexp_factory_->CreateInput(*number));
const scoped_ptr<RegExpInput> number_copy_without_transform(
reg_exps_->regexp_factory_->CreateInput(*number));
string number_string_copy(*number);
string captured_part_of_prefix;
const PhoneNumberDesc& general_desc = metadata.general_desc();
// Check if the original number is viable.
bool is_viable_original_number =
IsMatch(*matcher_api_, *number, general_desc);
// Attempt to parse the first digits as a national prefix. We make a
// copy so that we can revert to the original string if necessary.
const string& transform_rule = metadata.national_prefix_transform_rule();
const RegExp& possible_national_prefix_pattern =
reg_exps_->regexp_cache_->GetRegExp(possible_national_prefix);
if (!transform_rule.empty() &&
(possible_national_prefix_pattern.Consume(
number_copy.get(), &carrier_code_temp, &captured_part_of_prefix) ||
possible_national_prefix_pattern.Consume(
number_copy.get(), &captured_part_of_prefix)) &&
!captured_part_of_prefix.empty()) {
// If this succeeded, then we must have had a transform rule and there must
// have been some part of the prefix that we captured.
// We make the transformation and check that the resultant number is still
// viable. If so, replace the number and return.
possible_national_prefix_pattern.Replace(&number_string_copy,
transform_rule);
if (is_viable_original_number &&
!IsMatch(*matcher_api_, number_string_copy, general_desc)) {
return false;
}
number->assign(number_string_copy);
if (carrier_code) {
carrier_code->assign(carrier_code_temp);
}
} else if (possible_national_prefix_pattern.Consume(
number_copy_without_transform.get(), &carrier_code_temp) ||
possible_national_prefix_pattern.Consume(
number_copy_without_transform.get())) {
VLOG(4) << "Parsed the first digits as a national prefix.";
// If captured_part_of_prefix is empty, this implies nothing was captured by
// the capturing groups in possible_national_prefix; therefore, no
// transformation is necessary, and we just remove the national prefix.
const string number_copy_as_string =
number_copy_without_transform->ToString();
if (is_viable_original_number &&
!IsMatch(*matcher_api_, number_copy_as_string, general_desc)) {
return false;
}
number->assign(number_copy_as_string);
if (carrier_code) {
carrier_code->assign(carrier_code_temp);
}
} else {
return false;
VLOG(4) << "The first digits did not match the national prefix.";
}
return true;
}
// Strips any extension (as in, the part of the number dialled after the call is
// connected, usually indicated with extn, ext, x or similar) from the end of
// the number, and returns it. The number passed in should be non-normalized.
bool PhoneNumberUtil::MaybeStripExtension(string* number, string* extension)
const {
DCHECK(number);
DCHECK(extension);
// There are three extension capturing groups in the regular expression.
string possible_extension_one;
string possible_extension_two;
string possible_extension_three;
string number_copy(*number);
const scoped_ptr<RegExpInput> number_copy_as_regexp_input(
reg_exps_->regexp_factory_->CreateInput(number_copy));
if (reg_exps_->extn_pattern_->Consume(number_copy_as_regexp_input.get(),
false,
&possible_extension_one,
&possible_extension_two,
&possible_extension_three)) {
// Replace the extensions in the original string here.
reg_exps_->extn_pattern_->Replace(&number_copy, "");
// If we find a potential extension, and the number preceding this is a
// viable number, we assume it is an extension.
if ((!possible_extension_one.empty() || !possible_extension_two.empty() ||
!possible_extension_three.empty()) &&
IsViablePhoneNumber(number_copy)) {
number->assign(number_copy);
if (!possible_extension_one.empty()) {
extension->assign(possible_extension_one);
} else if (!possible_extension_two.empty()) {
extension->assign(possible_extension_two);
} else if (!possible_extension_three.empty()) {
extension->assign(possible_extension_three);
}
return true;
}
}
return false;
}
// Extracts country calling code from national_number, and returns it. It
// assumes that the leading plus sign or IDD has already been removed. Returns 0
// if national_number doesn't start with a valid country calling code, and
// leaves national_number unmodified. Assumes the national_number is at least 3
// characters long.
int PhoneNumberUtil::ExtractCountryCode(string* national_number) const {
int potential_country_code;
if (national_number->empty() || (national_number->at(0) == '0')) {
// Country codes do not begin with a '0'.
return 0;
}
for (size_t i = 1; i <= kMaxLengthCountryCode; ++i) {
safe_strto32(national_number->substr(0, i), &potential_country_code);
string region_code;
GetRegionCodeForCountryCode(potential_country_code, ®ion_code);
if (region_code != RegionCode::GetUnknown()) {
national_number->erase(0, i);
return potential_country_code;
}
}
return 0;
}
// Tries to extract a country calling code from a number. Country calling codes
// are extracted in the following ways:
// - by stripping the international dialing prefix of the region the person
// is dialing from, if this is present in the number, and looking at the next
// digits
// - by stripping the '+' sign if present and then looking at the next digits
// - by comparing the start of the number and the country calling code of the
// default region. If the number is not considered possible for the numbering
// plan of the default region initially, but starts with the country calling
// code of this region, validation will be reattempted after stripping this
// country calling code. If this number is considered a possible number, then
// the first digits will be considered the country calling code and removed as
// such.
//
// Returns NO_PARSING_ERROR if a country calling code was successfully
// extracted or none was present, or the appropriate error otherwise, such as
// if a + was present but it was not followed by a valid country calling code.
// If NO_PARSING_ERROR is returned, the national_number without the country
// calling code is populated, and the country_code of the phone_number passed
// in is set to the country calling code if found, otherwise to 0.
PhoneNumberUtil::ErrorType PhoneNumberUtil::MaybeExtractCountryCode(
const PhoneMetadata* default_region_metadata,
bool keep_raw_input,
string* national_number,
PhoneNumber* phone_number) const {
DCHECK(national_number);
DCHECK(phone_number);
// Set the default prefix to be something that will never match if there is no
// default region.
string possible_country_idd_prefix = default_region_metadata
? default_region_metadata->international_prefix()
: "NonMatch";
PhoneNumber::CountryCodeSource country_code_source =
MaybeStripInternationalPrefixAndNormalize(possible_country_idd_prefix,
national_number);
if (keep_raw_input) {
phone_number->set_country_code_source(country_code_source);
}
if (country_code_source != PhoneNumber::FROM_DEFAULT_COUNTRY) {
if (national_number->length() <= kMinLengthForNsn) {
VLOG(2) << "Phone number had an IDD, but after this was not "
<< "long enough to be a viable phone number.";
return TOO_SHORT_AFTER_IDD;
}
int potential_country_code = ExtractCountryCode(national_number);
if (potential_country_code != 0) {
phone_number->set_country_code(potential_country_code);
return NO_PARSING_ERROR;
}
// If this fails, they must be using a strange country calling code that we
// don't recognize, or that doesn't exist.
return INVALID_COUNTRY_CODE_ERROR;
} else if (default_region_metadata) {
// Check to see if the number starts with the country calling code for the
// default region. If so, we remove the country calling code, and do some
// checks on the validity of the number before and after.
int default_country_code = default_region_metadata->country_code();
string default_country_code_string(SimpleItoa(default_country_code));
VLOG(4) << "Possible country calling code: " << default_country_code_string;
string potential_national_number;
if (TryStripPrefixString(*national_number,
default_country_code_string,
&potential_national_number)) {
const PhoneNumberDesc& general_num_desc =
default_region_metadata->general_desc();
MaybeStripNationalPrefixAndCarrierCode(*default_region_metadata,
&potential_national_number,
NULL);
VLOG(4) << "Number without country calling code prefix";
// If the number was not valid before but is valid now, or if it was too
// long before, we consider the number with the country code stripped to
// be a better result and keep that instead.
if ((!IsMatch(*matcher_api_, *national_number, general_num_desc) &&
IsMatch(
*matcher_api_, potential_national_number, general_num_desc)) ||
TestNumberLength(*national_number, *default_region_metadata) ==
TOO_LONG) {
national_number->assign(potential_national_number);
if (keep_raw_input) {
phone_number->set_country_code_source(
PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN);
}
phone_number->set_country_code(default_country_code);
return NO_PARSING_ERROR;
}
}
}
// No country calling code present. Set the country_code to 0.
phone_number->set_country_code(0);
return NO_PARSING_ERROR;
}
PhoneNumberUtil::MatchType PhoneNumberUtil::IsNumberMatch(
const PhoneNumber& first_number_in,
const PhoneNumber& second_number_in) const {
// We only are about the fields that uniquely define a number, so we copy
// these across explicitly.
PhoneNumber first_number;
CopyCoreFieldsOnly(first_number_in, &first_number);
PhoneNumber second_number;
CopyCoreFieldsOnly(second_number_in, &second_number);
// Early exit if both had extensions and these are different.
if (first_number.has_extension() && second_number.has_extension() &&
first_number.extension() != second_number.extension()) {
return NO_MATCH;
}
int first_number_country_code = first_number.country_code();
int second_number_country_code = second_number.country_code();
// Both had country calling code specified.
if (first_number_country_code != 0 && second_number_country_code != 0) {
if (ExactlySameAs(first_number, second_number)) {
return EXACT_MATCH;
} else if (first_number_country_code == second_number_country_code &&
IsNationalNumberSuffixOfTheOther(first_number, second_number)) {
// A SHORT_NSN_MATCH occurs if there is a difference because of the
// presence or absence of an 'Italian leading zero', the presence or
// absence of an extension, or one NSN being a shorter variant of the
// other.
return SHORT_NSN_MATCH;
}
// This is not a match.
return NO_MATCH;
}
// Checks cases where one or both country calling codes were not specified. To
// make equality checks easier, we first set the country_code fields to be
// equal.
first_number.set_country_code(second_number_country_code);
// If all else was the same, then this is an NSN_MATCH.
if (ExactlySameAs(first_number, second_number)) {
return NSN_MATCH;
}
if (IsNationalNumberSuffixOfTheOther(first_number, second_number)) {
return SHORT_NSN_MATCH;
}
return NO_MATCH;
}
PhoneNumberUtil::MatchType PhoneNumberUtil::IsNumberMatchWithTwoStrings(
const string& first_number,
const string& second_number) const {
PhoneNumber first_number_as_proto;
ErrorType error_type =
Parse(first_number, RegionCode::GetUnknown(), &first_number_as_proto);
if (error_type == NO_PARSING_ERROR) {
return IsNumberMatchWithOneString(first_number_as_proto, second_number);
}
if (error_type == INVALID_COUNTRY_CODE_ERROR) {
PhoneNumber second_number_as_proto;
ErrorType error_type = Parse(second_number, RegionCode::GetUnknown(),
&second_number_as_proto);
if (error_type == NO_PARSING_ERROR) {
return IsNumberMatchWithOneString(second_number_as_proto, first_number);
}
if (error_type == INVALID_COUNTRY_CODE_ERROR) {
error_type = ParseHelper(first_number, RegionCode::GetUnknown(), false,
false, &first_number_as_proto);
if (error_type == NO_PARSING_ERROR) {
error_type = ParseHelper(second_number, RegionCode::GetUnknown(), false,
false, &second_number_as_proto);
if (error_type == NO_PARSING_ERROR) {
return IsNumberMatch(first_number_as_proto, second_number_as_proto);
}
}
}
}
// One or more of the phone numbers we are trying to match is not a viable
// phone number.
return INVALID_NUMBER;
}
PhoneNumberUtil::MatchType PhoneNumberUtil::IsNumberMatchWithOneString(
const PhoneNumber& first_number,
const string& second_number) const {
// First see if the second number has an implicit country calling code, by
// attempting to parse it.
PhoneNumber second_number_as_proto;
ErrorType error_type =
Parse(second_number, RegionCode::GetUnknown(), &second_number_as_proto);
if (error_type == NO_PARSING_ERROR) {
return IsNumberMatch(first_number, second_number_as_proto);
}
if (error_type == INVALID_COUNTRY_CODE_ERROR) {
// The second number has no country calling code. EXACT_MATCH is no longer
// possible. We parse it as if the region was the same as that for the
// first number, and if EXACT_MATCH is returned, we replace this with
// NSN_MATCH.
string first_number_region;
GetRegionCodeForCountryCode(first_number.country_code(),
&first_number_region);
if (first_number_region != RegionCode::GetUnknown()) {
PhoneNumber second_number_with_first_number_region;
Parse(second_number, first_number_region,
&second_number_with_first_number_region);
MatchType match = IsNumberMatch(first_number,
second_number_with_first_number_region);
if (match == EXACT_MATCH) {
return NSN_MATCH;
}
return match;
} else {
// If the first number didn't have a valid country calling code, then we
// parse the second number without one as well.
error_type = ParseHelper(second_number, RegionCode::GetUnknown(), false,
false, &second_number_as_proto);
if (error_type == NO_PARSING_ERROR) {
return IsNumberMatch(first_number, second_number_as_proto);
}
}
}
// One or more of the phone numbers we are trying to match is not a viable
// phone number.
return INVALID_NUMBER;
}
AsYouTypeFormatter* PhoneNumberUtil::GetAsYouTypeFormatter(
const string& region_code) const {
return new AsYouTypeFormatter(region_code);
}
bool PhoneNumberUtil::CanBeInternationallyDialled(
const PhoneNumber& number) const {
string region_code;
GetRegionCodeForNumber(number, ®ion_code);
const PhoneMetadata* metadata = GetMetadataForRegion(region_code);
if (!metadata) {
// Note numbers belonging to non-geographical entities (e.g. +800 numbers)
// are always internationally diallable, and will be caught here.
return true;
}
string national_significant_number;
GetNationalSignificantNumber(number, &national_significant_number);
return !IsNumberMatchingDesc(
national_significant_number, metadata->no_international_dialling());
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/phonenumberutil.cc
|
C++
|
unknown
| 138,427
|
// Copyright (C) 2009 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Utility for international phone numbers.
#ifndef I18N_PHONENUMBERS_PHONENUMBERUTIL_H_
#define I18N_PHONENUMBERS_PHONENUMBERUTIL_H_
#include <stddef.h>
#include <list>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/memory/scoped_ptr.h"
#include "phonenumbers/base/memory/singleton.h"
#include "phonenumbers/phonenumber.pb.h"
class TelephoneNumber;
namespace i18n {
namespace phonenumbers {
using google::protobuf::RepeatedPtrField;
using std::string;
class AsYouTypeFormatter;
class Logger;
class MatcherApi;
class NumberFormat;
class PhoneMetadata;
class PhoneNumberDesc;
class PhoneNumberRegExpsAndMappings;
class RegExp;
// NOTE: A lot of methods in this class require Region Code strings. These must
// be provided using CLDR two-letter region-code format. These should be in
// upper-case. The list of the codes can be found here:
// http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html
class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
private:
friend class AsYouTypeFormatter;
friend class PhoneNumberMatcher;
friend class PhoneNumberMatcherRegExps;
friend class PhoneNumberMatcherTest;
friend class PhoneNumberRegExpsAndMappings;
friend class PhoneNumberUtilTest;
friend class ShortNumberInfo;
friend class ShortNumberInfoTest;
friend class Singleton<PhoneNumberUtil>;
public:
~PhoneNumberUtil();
static const char kRegionCodeForNonGeoEntity[];
// INTERNATIONAL and NATIONAL formats are consistent with the definition
// in ITU-T Recommendation E.123. However we follow local conventions such as
// using '-' instead of whitespace as separators. For example, the number of
// the Google Switzerland office will be written as "+41 44 668 1800" in
// INTERNATIONAL format, and as "044 668 1800" in NATIONAL format. E164
// format is as per INTERNATIONAL format but with no formatting applied e.g.
// "+41446681800". RFC3966 is as per INTERNATIONAL format, but with all spaces
// and other separating symbols replaced with a hyphen, and with any phone
// number extension appended with ";ext=". It also will have a prefix of
// "tel:" added, e.g. "tel:+41-44-668-1800".
enum PhoneNumberFormat {
E164,
INTERNATIONAL,
NATIONAL,
RFC3966
};
static const PhoneNumberFormat kMaxNumberFormat = RFC3966;
// Type of phone numbers.
enum PhoneNumberType {
FIXED_LINE,
MOBILE,
// In some regions (e.g. the USA), it is impossible to distinguish between
// fixed-line and mobile numbers by looking at the phone number itself.
FIXED_LINE_OR_MOBILE,
// Freephone lines
TOLL_FREE,
PREMIUM_RATE,
// The cost of this call is shared between the caller and the recipient, and
// is hence typically less than PREMIUM_RATE calls. See
// http://en.wikipedia.org/wiki/Shared_Cost_Service for more information.
SHARED_COST,
// Voice over IP numbers. This includes TSoIP (Telephony Service over IP).
VOIP,
// A personal number is associated with a particular person, and may be
// routed to either a MOBILE or FIXED_LINE number. Some more information can
// be found here: http://en.wikipedia.org/wiki/Personal_Numbers
PERSONAL_NUMBER,
PAGER,
// Used for "Universal Access Numbers" or "Company Numbers". They may be
// further routed to specific offices, but allow one number to be used for a
// company.
UAN,
// Used for "Voice Mail Access Numbers".
VOICEMAIL,
// A phone number is of type UNKNOWN when it does not fit any of the known
// patterns for a specific region.
UNKNOWN
};
static const PhoneNumberType kMaxNumberType = UNKNOWN;
// Types of phone number matches. See detailed description beside the
// IsNumberMatch() method.
enum MatchType {
INVALID_NUMBER, // NOT_A_NUMBER in the java version.
NO_MATCH,
SHORT_NSN_MATCH,
NSN_MATCH,
EXACT_MATCH,
};
static const MatchType kMaxMatchType = EXACT_MATCH;
enum ErrorType {
NO_PARSING_ERROR,
INVALID_COUNTRY_CODE_ERROR, // INVALID_COUNTRY_CODE in the java version.
NOT_A_NUMBER,
TOO_SHORT_AFTER_IDD,
TOO_SHORT_NSN,
TOO_LONG_NSN, // TOO_LONG in the java version.
};
static const ErrorType kMaxErrorType = TOO_LONG_NSN;
// Possible outcomes when testing if a PhoneNumber is possible.
enum ValidationResult {
// The number length matches that of valid numbers for this region.
IS_POSSIBLE,
// The number length matches that of local numbers for this region only
// (i.e. numbers that may be able to be dialled within an area, but do not
// have all the information to be dialled from anywhere inside or outside
// the country).
IS_POSSIBLE_LOCAL_ONLY,
// The number has an invalid country calling code.
INVALID_COUNTRY_CODE,
// The number is shorter than all valid numbers for this region.
TOO_SHORT,
// The number is longer than the shortest valid numbers for this region,
// shorter than the longest valid numbers for this region, and does not
// itself have a number length that matches valid numbers for this region.
// This can also be returned in the case where
// IsPossibleNumberForTypeWithReason was called, and there are no numbers of
// this type at all for this region.
INVALID_LENGTH,
// The number is longer than all valid numbers for this region.
TOO_LONG,
};
static const ValidationResult kMaxValidationResult = TOO_LONG;
// Returns all regions the library has metadata for.
// @returns an unordered set of the two-letter region codes for every
// geographical region the library supports
void GetSupportedRegions(
std::set<string>* regions) const;
// Returns all global network calling codes the library has metadata for.
// @returns an unordered set of the country calling codes for every
// non-geographical entity the library supports
void GetSupportedGlobalNetworkCallingCodes(
std::set<int>* calling_codes) const;
// Returns all country calling codes the library has metadata for, covering
// both non-geographical entities (global network calling codes) and those
// used for geographical entities. This could be used to populate a drop-down
// box of country calling codes for a phone-number widget, for instance.
void GetSupportedCallingCodes(std::set<int>* calling_codes) const;
// Returns the types for a given region which the library has metadata for.
// Will not include FIXED_LINE_OR_MOBILE (if numbers for this non-geographical
// entity could be classified as FIXED_LINE_OR_MOBILE, both FIXED_LINE and
// MOBILE would be present) and UNKNOWN.
//
// No types will be returned for invalid or unknown region codes.
void GetSupportedTypesForRegion(
const string& region_code,
std::set<PhoneNumberType>* types) const;
// Returns the types for a country-code belonging to a non-geographical entity
// which the library has metadata for. Will not include FIXED_LINE_OR_MOBILE
// (instead both FIXED_LINE and FIXED_LINE_OR_MOBILE (if numbers for this
// non-geographical entity could be classified as FIXED_LINE_OR_MOBILE, both
// FIXED_LINE and MOBILE would be present) and UNKNOWN.
//
// No types will be returned for country calling codes that do not map to a
// known non-geographical entity.
void GetSupportedTypesForNonGeoEntity(
int country_calling_code,
std::set<PhoneNumberType>* types) const;
// Gets a PhoneNumberUtil instance to carry out international phone number
// formatting, parsing, or validation. The instance is loaded with phone
// number metadata for a number of most commonly used regions, as specified by
// DEFAULT_REGIONS_.
//
// The PhoneNumberUtil is implemented as a singleton. Therefore, calling
// GetInstance multiple times will only result in one instance being created.
static PhoneNumberUtil* GetInstance();
// Returns true if the number is a valid vanity (alpha) number such as 800
// MICROSOFT. A valid vanity number will start with at least 3 digits and will
// have three or more alpha characters. This does not do region-specific
// checks - to work out if this number is actually valid for a region, it
// should be parsed and methods such as IsPossibleNumberWithReason or
// IsValidNumber should be used.
bool IsAlphaNumber(const string& number) const;
// Converts all alpha characters in a number to their respective digits on
// a keypad, but retains existing formatting.
void ConvertAlphaCharactersInNumber(string* number) const;
// Normalizes a string of characters representing a phone number. This
// converts wide-ascii and arabic-indic numerals to European numerals, and
// strips punctuation and alpha characters.
void NormalizeDigitsOnly(string* number) const;
// Normalizes a string of characters representing a phone number. This strips
// all characters which are not diallable on a mobile phone keypad (including
// all non-ASCII digits).
void NormalizeDiallableCharsOnly(string* number) const;
// Gets the national significant number of a phone number. Note a national
// significant number doesn't contain a national prefix or any formatting.
void GetNationalSignificantNumber(const PhoneNumber& number,
string* national_significant_num) const;
// Gets the length of the geographical area code from the PhoneNumber object
// passed in, so that clients could use it to split a national significant
// number into geographical area code and subscriber number. It works in such
// a way that the resultant subscriber number should be diallable, at least on
// some devices. An example of how this could be used:
//
// const PhoneNumberUtil& phone_util(*PhoneNumberUtil::GetInstance());
// PhoneNumber number;
// phone_util.Parse("16502530000", "US", &number);
// string national_significant_number;
// phone_util.GetNationalSignificantNumber(number,
// &national_significant_number);
// string area_code;
// string subscriber_number;
//
// int area_code_length = phone_util.GetLengthOfGeographicalAreaCode(number);
// if (area_code_length > 0) {
// area_code = national_significant_number.substr(0, area_code_length);
// subscriber_number = national_significant_number.substr(
// area_code_length, string::npos);
// } else {
// area_code = "";
// subscriber_number = national_significant_number;
// }
//
// N.B.: area code is a very ambiguous concept, so the authors generally
// recommend against using it for most purposes, but recommend using the
// more general national_number instead. Read the following carefully before
// deciding to use this method:
//
// - geographical area codes change over time, and this method honors those
// changes; therefore, it doesn't guarantee the stability of the result it
// produces.
// - subscriber numbers may not be diallable from all devices (notably mobile
// devices, which typically requires the full national_number to be dialled
// in most regions).
// - most non-geographical numbers have no area codes, including numbers
// from non-geographical entities.
// - some geographical numbers have no area codes.
int GetLengthOfGeographicalAreaCode(const PhoneNumber& number) const;
// Gets the length of the national destination code (NDC) from the PhoneNumber
// object passed in, so that clients could use it to split a national
// significant number into NDC and subscriber number. The NDC of a phone
// number is normally the first group of digit(s) right after the country
// calling code when the number is formatted in the international format, if
// there is a subscriber number part that follows.
//
// N.B.: similar to an area code, not all numbers have an NDC!
//
// An example of how this could be used:
//
// const PhoneNumberUtil& phone_util(*PhoneNumberUtil::GetInstance());
// PhoneNumber number;
// phone_util.Parse("16502530000", "US", &number);
// string national_significant_number;
// phone_util.GetNationalSignificantNumber(number,
// &national_significant_number);
// string national_destination_code;
// string subscriber_number;
//
// int national_destination_code_length =
// phone_util.GetLengthOfNationalDestinationCode(number);
// if (national_destination_code_length > 0) {
// national_destination_code = national_significant_number.substr(
// 0, national_destination_code_length);
// subscriber_number = national_significant_number.substr(
// national_destination_code_length, string::npos);
// } else {
// national_destination_code = "";
// subscriber_number = national_significant_number;
// }
//
// Refer to the unittests to see the difference between this function and
// GetLengthOfGeographicalAreaCode().
int GetLengthOfNationalDestinationCode(const PhoneNumber& number) const;
// Returns the mobile token for the provided country calling code if it has
// one, otherwise returns an empty string. A mobile token is a number inserted
// before the area code when dialing a mobile number from that country from
// abroad.
void GetCountryMobileToken(int country_calling_code,
string* mobile_token) const;
// Formats a phone number in the specified format using default rules. Note
// that this does not promise to produce a phone number that the user can
// dial from where they are - although we do format in either NATIONAL or
// INTERNATIONAL format depending on what the client asks for, we do not
// currently support a more abbreviated format, such as for users in the
// same area who could potentially dial the number without area code.
void Format(const PhoneNumber& number,
PhoneNumberFormat number_format,
string* formatted_number) const;
// Formats a phone number in the specified format using client-defined
// formatting rules.
void FormatByPattern(
const PhoneNumber& number,
PhoneNumberFormat number_format,
const RepeatedPtrField<NumberFormat>& user_defined_formats,
string* formatted_number) const;
// Formats a phone number in national format for dialing using the carrier as
// specified in the carrier_code. The carrier_code will always be used
// regardless of whether the phone number already has a preferred domestic
// carrier code stored. If carrier_code contains an empty string, return the
// number in national format without any carrier code.
void FormatNationalNumberWithCarrierCode(const PhoneNumber& number,
const string& carrier_code,
string* formatted_number) const;
// Formats a phone number in national format for dialing using the carrier as
// specified in the preferred_domestic_carrier_code field of the PhoneNumber
// object passed in. If that is missing, use the fallback_carrier_code passed
// in instead. If there is no preferred_domestic_carrier_code, and the
// fallback_carrier_code contains an empty string, return the number in
// national format without any carrier code.
//
// Use FormatNationalNumberWithCarrierCode instead if the carrier code passed
// in should take precedence over the number's preferred_domestic_carrier_code
// when formatting.
void FormatNationalNumberWithPreferredCarrierCode(
const PhoneNumber& number,
const string& fallback_carrier_code,
string* formatted_number) const;
// Returns a number formatted in such a way that it can be dialed from a
// mobile phone in a specific region. If the number cannot be reached from
// the region (e.g. some countries block toll-free numbers from being called
// outside of the country), the method returns an empty string.
void FormatNumberForMobileDialing(
const PhoneNumber& number,
const string& region_calling_from,
bool with_formatting,
string* formatted_number) const;
// Formats a phone number for out-of-country dialing purposes.
//
// Note this function takes care of the case for calling inside of NANPA
// and between Russia and Kazakhstan (who share the same country calling
// code). In those cases, no international prefix is used. For regions which
// have multiple international prefixes, the number in its INTERNATIONAL
// format will be returned instead.
void FormatOutOfCountryCallingNumber(
const PhoneNumber& number,
const string& calling_from,
string* formatted_number) const;
// Formats a phone number using the original phone number format that the
// number is parsed from. The original format is embedded in the
// country_code_source field of the PhoneNumber object passed in. If such
// information is missing, the number will be formatted into the NATIONAL
// format by default. When we don't have a formatting pattern for the number,
// the method returns the raw input when it is available.
//
// Note this method guarantees no digit will be inserted, removed or modified
// as a result of formatting.
void FormatInOriginalFormat(const PhoneNumber& number,
const string& region_calling_from,
string* formatted_number) const;
// Formats a phone number for out-of-country dialing purposes.
//
// Note that in this version, if the number was entered originally using alpha
// characters and this version of the number is stored in raw_input, this
// representation of the number will be used rather than the digit
// representation. Grouping information, as specified by characters such as
// "-" and " ", will be retained.
//
// Caveats:
// 1) This will not produce good results if the country calling code is both
// present in the raw input _and_ is the start of the national number. This
// is not a problem in the regions which typically use alpha numbers.
// 2) This will also not produce good results if the raw input has any
// grouping information within the first three digits of the national number,
// and if the function needs to strip preceding digits/words in the raw input
// before these digits. Normally people group the first three digits together
// so this is not a huge problem - and will be fixed if it proves to be so.
void FormatOutOfCountryKeepingAlphaChars(
const PhoneNumber& number,
const string& calling_from,
string* formatted_number) const;
// Attempts to extract a valid number from a phone number that is too long to
// be valid, and resets the PhoneNumber object passed in to that valid
// version. If no valid number could be extracted, the PhoneNumber object
// passed in will not be modified. It returns true if a valid phone number can
// be successfully extracted.
bool TruncateTooLongNumber(PhoneNumber* number) const;
// Gets the type of a valid phone number, or UNKNOWN if it is invalid.
PhoneNumberType GetNumberType(const PhoneNumber& number) const;
// Tests whether a phone number matches a valid pattern. Note this doesn't
// verify the number is actually in use, which is impossible to tell by just
// looking at a number itself.
// It only verifies whether the parsed, canonicalised number is valid: not
// whether a particular series of digits entered by the user is diallable from
// the region provided when parsing. For example, the number +41 (0) 78 927
// 2696 can be parsed into a number with country code "41" and national
// significant number "789272696". This is valid, while the original string
// is not diallable.
bool IsValidNumber(const PhoneNumber& number) const;
// Tests whether a phone number is valid for a certain region. Note this
// doesn't verify the number is actually in use, which is impossible to tell
// by just looking at a number itself. If the country calling code is not the
// same as the country calling code for the region, this immediately exits
// with false. After this, the specific number pattern rules for the region
// are examined.
// This is useful for determining for example whether a particular number is
// valid for Canada, rather than just a valid NANPA number.
// Warning: In most cases, you want to use IsValidNumber instead. For
// example, this method will mark numbers from British Crown dependencies
// such as the Isle of Man as invalid for the region "GB" (United Kingdom),
// since it has its own region code, "IM", which may be undesirable.
bool IsValidNumberForRegion(
const PhoneNumber& number,
const string& region_code) const;
// Returns the region where a phone number is from. This could be used for
// geocoding at the region level. Only guarantees correct results for valid,
// full numbers (not short-codes, or invalid numbers).
void GetRegionCodeForNumber(const PhoneNumber& number,
string* region_code) const;
// Returns the country calling code for a specific region. For example,
// this would be 1 for the United States, and 64 for New Zealand.
int GetCountryCodeForRegion(const string& region_code) const;
// Returns the region code that matches the specific country code. Note that
// it is possible that several regions share the same country calling code
// (e.g. US and Canada), and in that case, only one of the regions (normally
// the one with the largest population) is returned. If the
// countryCallingCode entered is valid but doesn't match a specific region
// (such as in the case of non-geographical calling codes like 800) the
// RegionCode 001 will be returned (corresponding to the value for World in
// the UN M.49 schema).
void GetRegionCodeForCountryCode(int country_code, string* region_code) const;
// Populates a list with the region codes that match the specific country
// calling code. For non-geographical country calling codes, the region code
// 001 is returned. Also, in the case of no region code being found, the list
// is left unchanged.
void GetRegionCodesForCountryCallingCode(
int country_calling_code,
std::list<string>* region_codes) const;
// Checks if this is a region under the North American Numbering Plan
// Administration (NANPA).
bool IsNANPACountry(const string& region_code) const;
// Returns the national dialling prefix for a specific region. For example,
// this would be 1 for the United States, and 0 for New Zealand. Set
// strip_non_digits to true to strip symbols like "~" (which indicates a wait
// for a dialling tone) from the prefix returned. If no national prefix is
// present, we return an empty string.
void GetNddPrefixForRegion(const string& region_code,
bool strip_non_digits,
string* national_prefix) const;
// Checks whether a phone number is a possible number. It provides a more
// lenient check than IsValidNumber() in the following sense:
// 1. It only checks the length of phone numbers. In particular, it doesn't
// check starting digits of the number.
// 2. It doesn't attempt to figure out the type of the number, but uses
// general rules which applies to all types of phone numbers in a
// region. Therefore, it is much faster than IsValidNumber().
// 3. For some numbers (particularly fixed-line), many regions have the
// concept of area code, which together with subscriber number constitute
// the national significant number. It is sometimes okay to dial only the
// subscriber number when dialing in the same area. This function will
// return IS_POSSIBLE_LOCAL_ONLY if the subscriber-number-only version is
// passed in. On the other hand, because IsValidNumber() validates using
// information on both starting digits (for fixed line numbers, that
// would most likely be area codes) and length (obviously includes the
// length of area codes for fixed line numbers), it will return false for
// the subscriber-number-only version.
ValidationResult IsPossibleNumberWithReason(const PhoneNumber& number) const;
// Convenience wrapper around IsPossibleNumberWithReason(). Instead of
// returning the reason for failure, this method returns true if the number is
// either a possible fully-qualified number (containing the area code and
// country code), or if the number could be a possible local number (with a
// country code, but missing an area code). Local numbers are considered
// possible if they could be possibly dialled in this format: if the area code
// is needed for a call to connect, the number is not considered possible
// without it.
bool IsPossibleNumber(const PhoneNumber& number) const;
// Check whether a phone number is a possible number of a particular type. For
// types that don't exist in a particular region, this will return a result
// that isn't so useful; it is recommended that you use
// GetSupportedTypesForRegion() or GetSupportedTypesForNonGeoEntity()
// respectively before calling this method to determine whether you should
// call it for this number at all.
//
// This provides a more lenient check than IsValidNumber() in the following
// sense:
//
// 1. It only checks the length of phone numbers. In particular, it doesn't
// check starting digits of the number.
// 2. For some numbers (particularly fixed-line), many regions have the
// concept of area code, which together with subscriber number constitute
// the national significant number. It is sometimes okay to dial only the
// subscriber number when dialing in the same area. This function will
// return IS_POSSIBLE_LOCAL_ONLY if the subscriber-number-only version is
// passed in. On the other hand, because IsValidNumber() validates using
// information on both starting digits (for fixed line numbers, that
// would most likely be area codes) and length (obviously includes the
// length of area codes for fixed line numbers), it will return false for
// the subscriber-number-only version.
ValidationResult IsPossibleNumberForTypeWithReason(
const PhoneNumber& number, PhoneNumberType type) const;
// Convenience wrapper around IsPossibleNumberForTypeWithReason(). Instead of
// returning the reason for failure, this method returns true if the number is
// either a possible fully-qualified number (containing the area code and
// country code), or if the number could be a possible local number (with a
// country code, but missing an area code). Local numbers are considered
// possible if they could be possibly dialled in this format: if the area code
// is needed for a call to connect, the number is not considered possible
// without it.
bool IsPossibleNumberForType(const PhoneNumber& number,
PhoneNumberType type) const;
// Checks whether a phone number is a possible number given a number in the
// form of a string, and the country where the number could be dialed from.
// It provides a more lenient check than IsValidNumber(). See
// IsPossibleNumber(const PhoneNumber& number) for details.
//
// This method first parses the number, then invokes
// IsPossibleNumber(const PhoneNumber& number) with the resultant PhoneNumber
// object.
//
// region_dialing_from represents the region that we are expecting the number
// to be dialed from. Note this is different from the region where the number
// belongs. For example, the number +1 650 253 0000 is a number that belongs
// to US. When written in this form, it could be dialed from any region. When
// it is written as 00 1 650 253 0000, it could be dialed from any region
// which uses an international dialling prefix of 00. When it is written as
// 650 253 0000, it could only be dialed from within the US, and when written
// as 253 0000, it could only be dialed from within a smaller area in the US
// (Mountain View, CA, to be more specific).
bool IsPossibleNumberForString(
const string& number,
const string& region_dialing_from) const;
// Returns true if the number can be dialled from outside the region, or
// unknown. If the number can only be dialled from within the region, returns
// false. Does not check the number is a valid number. Note that, at the
// moment, this method does not handle short numbers (which are currently all
// presumed to not be diallable from outside their country).
bool CanBeInternationallyDialled(const PhoneNumber& number) const;
// Tests whether a phone number has a geographical association. It checks if
// the number is associated with a certain region in the country to which it
// belongs. Note that this doesn't verify if the number is actually in use.
bool IsNumberGeographical(const PhoneNumber& phone_number) const;
// Overload of IsNumberGeographical(PhoneNumber), since calculating the phone
// number type is expensive; if we have already done this, we don't want to do
// it again.
bool IsNumberGeographical(PhoneNumberType phone_number_type,
int country_calling_code) const;
// Gets a valid fixed-line number for the specified region. Returns false if
// the region was unknown, or the region 001 is passed in. For 001
// (representing non-geographical numbers), call
// GetExampleNumberForNonGeoEntity instead.
bool GetExampleNumber(const string& region_code,
PhoneNumber* number) const;
// Gets an invalid number for the specified region. This is useful for
// unit-testing purposes, where you want to test that will happen with an
// invalid number. Note that the number that is returned will always be able
// to be parsed and will have the correct country code. It may also be a valid
// *short* number/code for this region. Validity checking such
// numbers is handled with ShortNumberInfo.
//
// Returns false when an unsupported region or the region 001 (Earth) is
// passed in.
bool GetInvalidExampleNumber(const string& region_code,
PhoneNumber* number) const;
// Gets a valid number of the specified type for the specified region.
// Returns false if the region was unknown or 001, or if no example number of
// that type could be found. For 001 (representing non-geographical numbers),
// call GetExampleNumberForNonGeoEntity instead.
bool GetExampleNumberForType(const string& region_code,
PhoneNumberType type,
PhoneNumber* number) const;
// Gets a valid number for the specified type (it may belong to any country).
// Returns false when the metadata does not contain such information. This
// should only happen when no numbers of this type are allocated anywhere in
// the world anymore.
bool GetExampleNumberForType(PhoneNumberType type,
PhoneNumber* number) const;
// Gets a valid number for the specified country calling code for a
// non-geographical entity. Returns false if the metadata does not contain
// such information, or the country calling code passed in does not belong to
// a non-geographical entity.
bool GetExampleNumberForNonGeoEntity(
int country_calling_code, PhoneNumber* number) const;
// Parses a string and returns it as a phone number in proto buffer format.
// The method is quite lenient and looks for a number in the input text
// (raw input) and does not check whether the string is definitely only a
// phone number. To do this, it ignores punctuation and white-space, as well
// as any text before the number (e.g. a leading “Tel: ”) and trims the
// non-number bits. It will accept a number in any format (E164, national,
// international etc), assuming it can be interpreted with the defaultRegion
// supplied. It also attempts to convert any alpha characters into digits
// if it thinks this is a vanity number of the type "1800 MICROSOFT".
//
// This method will return an error if the number is not considered to be a
// possible number, and NO_PARSING_ERROR if it is parsed correctly.
// Note that validation of whether the number is actually a valid number for
// a particular region is not performed. This can be done separately with
// IsValidNumber().
//
// Note this method canonicalizes the phone number such that different
// representations can be easily compared, no matter what form it was
// originally entered in (e.g. national, international). If you want to record
// context about the number being parsed, such as the raw input that was
// entered, how the country code was derived etc. then call
// ParseAndKeepRawInput() instead.
//
// number_to_parse can contain formatting such as +, ( and -, as well as a
// phone number extension. It can also be provided in RFC3966 format.
//
// default_region represents the country that we are expecting the number to
// be from. This is only used if the number being parsed is not written in
// international format. The country_code for the number in this case would be
// stored as that of the default country supplied. If the number is guaranteed
// to start with a '+' followed by the country calling code, then
// "ZZ" can be supplied.
//
// Returns an error if the string is not considered to be a viable phone
// number (e.g.too few or too many digits) or if no default region was
// supplied and the number is not in international format (does not start with
// +).
ErrorType Parse(const string& number_to_parse,
const string& default_region,
PhoneNumber* number) const;
// Parses a string and returns it in proto buffer format. This method differs
// from Parse() in that it always populates the raw_input field of the
// protocol buffer with number_to_parse as well as the country_code_source
// field.
ErrorType ParseAndKeepRawInput(const string& number_to_parse,
const string& default_region,
PhoneNumber* number) const;
// Takes two phone numbers and compares them for equality.
//
// Returns EXACT_MATCH if the country calling code, NSN, presence of a leading
// zero for Italian numbers and any extension present are the same.
// Returns NSN_MATCH if either or both has no country calling code specified,
// and the NSNs and extensions are the same.
// Returns SHORT_NSN_MATCH if either or both has no country calling code
// specified, or the country calling code specified is the same, and one NSN
// could be a shorter version of the other number. This includes the case
// where one has an extension specified, and the other does not.
// Returns NO_MATCH otherwise.
// For example, the numbers +1 345 657 1234 and 657 1234 are a
// SHORT_NSN_MATCH. The numbers +1 345 657 1234 and 345 657 are a NO_MATCH.
MatchType IsNumberMatch(const PhoneNumber& first_number,
const PhoneNumber& second_number) const;
// Takes two phone numbers as strings and compares them for equality. This
// is a convenience wrapper for IsNumberMatch(PhoneNumber firstNumber,
// PhoneNumber secondNumber). No default region is known.
// Returns INVALID_NUMBER if either number cannot be parsed into a phone
// number.
MatchType IsNumberMatchWithTwoStrings(const string& first_number,
const string& second_number) const;
// Takes two phone numbers and compares them for equality. This is a
// convenience wrapper for IsNumberMatch(PhoneNumber firstNumber,
// PhoneNumber secondNumber). No default region is known.
// Returns INVALID_NUMBER if second_number cannot be parsed into a phone
// number.
MatchType IsNumberMatchWithOneString(const PhoneNumber& first_number,
const string& second_number) const;
// Overrides the default logging system. This takes ownership of the provided
// logger.
void SetLogger(Logger* logger);
// Gets an AsYouTypeFormatter for the specific region.
// Returns an AsYouTypeFormatter object, which could be used to format phone
// numbers in the specific region "as you type".
// The deletion of the returned instance is under the responsibility of the
// caller.
AsYouTypeFormatter* GetAsYouTypeFormatter(const string& region_code) const;
friend bool ConvertFromTelephoneNumberProto(
const TelephoneNumber& proto_to_convert,
PhoneNumber* new_proto);
friend bool ConvertToTelephoneNumberProto(const PhoneNumber& proto_to_convert,
TelephoneNumber* resulting_proto);
protected:
bool IsNumberMatchingDesc(const string& national_number,
const PhoneNumberDesc& number_desc) const;
PhoneNumberUtil::PhoneNumberType GetNumberTypeHelper(
const string& national_number, const PhoneMetadata& metadata) const;
private:
scoped_ptr<Logger> logger_;
typedef std::pair<int, std::list<string>*> IntRegionsPair;
// The minimum and maximum length of the national significant number.
static const size_t kMinLengthForNsn = 2;
// The ITU says the maximum length should be 15, but we have found longer
// numbers in Germany.
static const size_t kMaxLengthForNsn = 17;
// The maximum length of the country calling code.
static const size_t kMaxLengthCountryCode = 3;
static const char kPlusChars[];
// Regular expression of acceptable punctuation found in phone numbers. This
// excludes punctuation found as a leading character only. This consists of
// dash characters, white space characters, full stops, slashes, square
// brackets, parentheses and tildes. It also includes the letter 'x' as that
// is found as a placeholder for carrier information in some phone numbers.
// Full-width variants are also present.
static const char kValidPunctuation[];
// Regular expression of characters typically used to start a second phone
// number for the purposes of parsing. This allows us to strip off parts of
// the number that are actually the start of another number, such as for:
// (530) 583-6985 x302/x2303 -> the second extension here makes this actually
// two phone numbers, (530) 583-6985 x302 and (530) 583-6985 x2303. We remove
// the second extension so that the first number is parsed correctly. The
// string preceding this is captured.
// This corresponds to SECOND_NUMBER_START in the java version.
static const char kCaptureUpToSecondNumberStart[];
// An API for validation checking.
scoped_ptr<MatcherApi> matcher_api_;
// Helper class holding useful regular expressions and character mappings.
scoped_ptr<PhoneNumberRegExpsAndMappings> reg_exps_;
// A mapping from a country calling code to a RegionCode object which denotes
// the region represented by that country calling code. Note regions under
// NANPA share the country calling code 1 and Russia and Kazakhstan share the
// country calling code 7. Under this map, 1 is mapped to region code "US" and
// 7 is mapped to region code "RU". This is implemented as a sorted vector to
// achieve better performance.
scoped_ptr<std::vector<IntRegionsPair> >
country_calling_code_to_region_code_map_;
// The set of regions that share country calling code 1.
scoped_ptr<std::set<string> > nanpa_regions_;
static const int kNanpaCountryCode = 1;
// A mapping from a region code to a PhoneMetadata for that region.
scoped_ptr<std::map<string, PhoneMetadata> > region_to_metadata_map_;
// A mapping from a country calling code for a non-geographical entity to the
// PhoneMetadata for that country calling code. Examples of the country
// calling codes include 800 (International Toll Free Service) and 808
// (International Shared Cost Service).
scoped_ptr<std::map<int, PhoneMetadata> >
country_code_to_non_geographical_metadata_map_;
PhoneNumberUtil();
// Returns a regular expression for the possible extensions that may be found
// in a number, for use when matching.
const string& GetExtnPatternsForMatching() const;
// Checks if a number matches the plus chars pattern.
bool StartsWithPlusCharsPattern(const string& number) const;
void SetItalianLeadingZerosForPhoneNumber(
const string& national_number, PhoneNumber* phone_number) const;
// Checks whether a string contains only valid digits.
bool ContainsOnlyValidDigits(const string& s) const;
// Checks if a format is eligible to be used by the AsYouTypeFormatter. This
// method is here rather than in asyoutypeformatter.h since it depends on the
// valid punctuation declared by the phone number util.
bool IsFormatEligibleForAsYouTypeFormatter(const string& format) const;
// Helper function to check if the national prefix formatting rule has the
// first group only, i.e., does not start with the national prefix.
bool FormattingRuleHasFirstGroupOnly(
const string& national_prefix_formatting_rule) const;
// Trims unwanted end characters from a phone number string.
void TrimUnwantedEndChars(string* number) const;
// Helper function to check region code is not unknown or null.
bool IsValidRegionCode(const string& region_code) const;
// Helper function to check the country calling code is valid.
bool HasValidCountryCallingCode(int country_calling_code) const;
const i18n::phonenumbers::PhoneMetadata* GetMetadataForRegion(
const string& region_code) const;
const i18n::phonenumbers::PhoneMetadata* GetMetadataForNonGeographicalRegion(
int country_calling_code) const;
const i18n::phonenumbers::PhoneMetadata* GetMetadataForRegionOrCallingCode(
int country_calling_code,
const string& region_code) const;
// As per GetCountryCodeForRegion, but assumes the validity of the region_code
// has already been checked.
int GetCountryCodeForValidRegion(const string& region_code) const;
const NumberFormat* ChooseFormattingPatternForNumber(
const RepeatedPtrField<NumberFormat>& available_formats,
const string& national_number) const;
void FormatNsnUsingPatternWithCarrier(
const string& national_number,
const NumberFormat& formatting_pattern,
PhoneNumberUtil::PhoneNumberFormat number_format,
const string& carrier_code,
string* formatted_number) const;
void FormatNsnUsingPattern(
const string& national_number,
const NumberFormat& formatting_pattern,
PhoneNumberUtil::PhoneNumberFormat number_format,
string* formatted_number) const;
// Check if raw_input, which is assumed to be in the national format, has a
// national prefix. The national prefix is assumed to be in digits-only form.
bool RawInputContainsNationalPrefix(
const string& raw_input,
const string& national_prefix,
const string& region_code) const;
bool HasFormattingPatternForNumber(const PhoneNumber& number) const;
// Simple wrapper of FormatNsnWithCarrier for the common case of
// no carrier code.
void FormatNsn(const string& number,
const PhoneMetadata& metadata,
PhoneNumberFormat number_format,
string* formatted_number) const;
void FormatNsnWithCarrier(const string& number,
const PhoneMetadata& metadata,
PhoneNumberFormat number_format,
const string& carrier_code,
string* formatted_number) const;
void MaybeAppendFormattedExtension(
const PhoneNumber& number,
const PhoneMetadata& metadata,
PhoneNumberFormat number_format,
string* extension) const;
void GetRegionCodeForNumberFromRegionList(
const PhoneNumber& number,
const std::list<string>& region_codes,
string* region_code) const;
// Strips the IDD from the start of the number if present. Helper function
// used by MaybeStripInternationalPrefixAndNormalize.
bool ParsePrefixAsIdd(const RegExp& idd_pattern, string* number) const;
void Normalize(string* number) const;
PhoneNumber::CountryCodeSource MaybeStripInternationalPrefixAndNormalize(
const string& possible_idd_prefix,
string* number) const;
bool MaybeStripNationalPrefixAndCarrierCode(
const PhoneMetadata& metadata,
string* number,
string* carrier_code) const;
void ExtractPossibleNumber(const string& number,
string* extracted_number) const;
bool IsViablePhoneNumber(const string& number) const;
bool MaybeStripExtension(string* number, string* extension) const;
int ExtractCountryCode(string* national_number) const;
ErrorType MaybeExtractCountryCode(
const PhoneMetadata* default_region_metadata,
bool keepRawInput,
string* national_number,
PhoneNumber* phone_number) const;
bool CheckRegionForParsing(
const string& number_to_parse,
const string& default_region) const;
ErrorType ParseHelper(const string& number_to_parse,
const string& default_region,
bool keep_raw_input,
bool check_region,
PhoneNumber* phone_number) const;
void BuildNationalNumberForParsing(const string& number_to_parse,
string* national_number) const;
bool IsShorterThanPossibleNormalNumber(const PhoneMetadata* country_metadata,
const string& number) const;
DISALLOW_COPY_AND_ASSIGN(PhoneNumberUtil);
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_PHONENUMBERUTIL_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/phonenumberutil.h
|
C++
|
unknown
| 46,748
|
/*
* Copyright (C) 2014 The Libphonenumber Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "phonenumbers/regex_based_matcher.h"
#include <string>
#include "phonenumbers/base/memory/scoped_ptr.h"
#include "phonenumbers/phonemetadata.pb.h"
#include "phonenumbers/regexp_adapter.h"
#include "phonenumbers/regexp_cache.h"
#include "phonenumbers/regexp_factory.h"
namespace i18n {
namespace phonenumbers {
// Same implementations of AbstractRegExpFactory and RegExpCache in
// PhoneNumberUtil (copy from phonenumberutil.cc).
RegexBasedMatcher::RegexBasedMatcher()
: regexp_factory_(new RegExpFactory()),
regexp_cache_(new RegExpCache(*regexp_factory_, 128)) {}
RegexBasedMatcher::~RegexBasedMatcher() {}
bool RegexBasedMatcher::MatchNationalNumber(
const string& number,
const PhoneNumberDesc& number_desc,
bool allow_prefix_match) const {
const string& national_number_pattern = number_desc.national_number_pattern();
// We don't want to consider it a prefix match when matching non-empty input
// against an empty pattern.
if (national_number_pattern.empty()) {
return false;
}
return Match(number, national_number_pattern, allow_prefix_match);
}
bool RegexBasedMatcher::Match(
const string& number,
const string& number_pattern,
bool allow_prefix_match) const {
const RegExp& regexp(regexp_cache_->GetRegExp(number_pattern));
if (regexp.FullMatch(number)) {
return true;
}
const scoped_ptr<RegExpInput> normalized_number_input(
regexp_factory_->CreateInput(number));
return regexp.Consume(normalized_number_input.get())
? allow_prefix_match
: false;
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/regex_based_matcher.cc
|
C++
|
unknown
| 2,220
|
/*
* Copyright (C) 2014 The Libphonenumber Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_
#define I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_
#include <string>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/memory/scoped_ptr.h"
#include "phonenumbers/matcher_api.h"
namespace i18n {
namespace phonenumbers {
class AbstractRegExpFactory;
class PhoneNumberDesc;
class RegExpCache;
// Implementation of the matcher API using the regular expressions in the
// PhoneNumberDesc proto message to match numbers.
class RegexBasedMatcher : public MatcherApi {
public:
RegexBasedMatcher();
~RegexBasedMatcher();
bool MatchNationalNumber(const string& number,
const PhoneNumberDesc& number_desc,
bool allow_prefix_match) const;
private:
bool Match(const string& number, const string& number_pattern,
bool allow_prefix_match) const;
const scoped_ptr<const AbstractRegExpFactory> regexp_factory_;
const scoped_ptr<RegExpCache> regexp_cache_;
DISALLOW_COPY_AND_ASSIGN(RegexBasedMatcher);
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/regex_based_matcher.h
|
C++
|
unknown
| 1,762
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: George Yakovlev
// Philippe Liard
//
// RegExp adapter to allow a pluggable regexp engine. It has been introduced
// during the integration of the open-source version of this library into
// Chromium to be able to use the ICU Regex engine instead of RE2, which is not
// officially supported on Windows.
// Since RE2 was initially used in this library, the interface of this adapter
// is very close to the subset of the RE2 API used in phonenumberutil.cc.
#ifndef I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
#define I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
#include <cstddef>
#include <string>
namespace i18n {
namespace phonenumbers {
using std::string;
// RegExpInput is the interface that abstracts the input that feeds the
// Consume() method of RegExp which may differ depending on its various
// implementations (StringPiece for RE2, UnicodeString for ICU Regex).
class RegExpInput {
public:
virtual ~RegExpInput() {}
// Converts to a C++ string.
virtual string ToString() const = 0;
};
// The regular expression abstract class. It supports only functions used in
// phonenumberutil.cc. Consume(), Match() and Replace() methods must be
// implemented.
class RegExp {
public:
virtual ~RegExp() {}
// Matches string to regular expression, returns true if expression was
// matched, false otherwise, advances position in the match.
// input_string - string to be searched.
// anchor_at_start - if true, match would be successful only if it appears at
// the beginning of the tested region of the string.
// matched_string1 - the first string extracted from the match. Can be NULL.
// matched_string2 - the second string extracted from the match. Can be NULL.
// matched_string3 - the third string extracted from the match. Can be NULL.
virtual bool Consume(RegExpInput* input_string,
bool anchor_at_start,
string* matched_string1,
string* matched_string2,
string* matched_string3) const = 0;
// Helper methods calling the Consume method that assume the match must start
// at the beginning.
inline bool Consume(RegExpInput* input_string,
string* matched_string1,
string* matched_string2,
string* matched_string3) const {
return Consume(input_string, true, matched_string1, matched_string2,
matched_string3);
}
inline bool Consume(RegExpInput* input_string,
string* matched_string1,
string* matched_string2) const {
return Consume(input_string, true, matched_string1, matched_string2, NULL);
}
inline bool Consume(RegExpInput* input_string, string* matched_string) const {
return Consume(input_string, true, matched_string, NULL, NULL);
}
inline bool Consume(RegExpInput* input_string) const {
return Consume(input_string, true, NULL, NULL, NULL);
}
// Helper method calling the Consume method that assumes the match can start
// at any place in the string.
inline bool FindAndConsume(RegExpInput* input_string,
string* matched_string) const {
return Consume(input_string, false, matched_string, NULL, NULL);
}
// Matches string to regular expression, returns true if the expression was
// matched, false otherwise.
// input_string - string to be searched.
// full_match - if true, match would be successful only if it matches the
// complete string.
// matched_string - the string extracted from the match. Can be NULL.
virtual bool Match(const string& input_string,
bool full_match,
string* matched_string) const = 0;
// Helper methods calling the Match method with the right arguments.
inline bool PartialMatch(const string& input_string,
string* matched_string) const {
return Match(input_string, false, matched_string);
}
inline bool PartialMatch(const string& input_string) const {
return Match(input_string, false, NULL);
}
inline bool FullMatch(const string& input_string,
string* matched_string) const {
return Match(input_string, true, matched_string);
}
inline bool FullMatch(const string& input_string) const {
return Match(input_string, true, NULL);
}
// Replaces match(es) in 'string_to_process'. If 'global' is true,
// replaces all the matches, otherwise only the first match.
// replacement_string - text the matches are replaced with. The groups in the
// replacement string are referenced with the $[0-9] notation.
// Returns true if the pattern matches and a replacement occurs, false
// otherwise.
virtual bool Replace(string* string_to_process,
bool global,
const string& replacement_string) const = 0;
// Helper methods calling the Replace method with the right arguments.
inline bool Replace(string* string_to_process,
const string& replacement_string) const {
return Replace(string_to_process, false, replacement_string);
}
inline bool GlobalReplace(string* string_to_process,
const string& replacement_string) const {
return Replace(string_to_process, true, replacement_string);
}
};
// Abstract factory class that lets its subclasses instantiate the classes
// implementing RegExp and RegExpInput.
class AbstractRegExpFactory {
public:
virtual ~AbstractRegExpFactory() {}
// Creates a new instance of RegExpInput. The deletion of the returned
// instance is under the responsibility of the caller.
virtual RegExpInput* CreateInput(const string& utf8_input) const = 0;
// Creates a new instance of RegExp. The deletion of the returned instance is
// under the responsibility of the caller.
virtual RegExp* CreateRegExp(const string& utf8_regexp) const = 0;
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/regexp_adapter.h
|
C++
|
unknown
| 6,632
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: George Yakovlev
// Philippe Liard
// Note that we don't use features of ICU that depend on std::string (e.g.
// UnicodeString::toUTF8String()) to support clients that build ICU without
// -DU_HAVE_STD_STRING.
#include "phonenumbers/regexp_adapter_icu.h"
#include <stddef.h>
#include <string>
#include <unicode/regex.h>
#include <unicode/stringpiece.h>
#include <unicode/unistr.h>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/logging.h"
#include "phonenumbers/base/memory/scoped_ptr.h"
#include "phonenumbers/default_logger.h"
#include "phonenumbers/string_byte_sink.h"
namespace i18n {
namespace phonenumbers {
using icu::RegexMatcher;
using icu::RegexPattern;
using icu::UnicodeString;
namespace {
// Converts UnicodeString 'source' to a UTF8-formatted std::string.
string UnicodeStringToUtf8String(const UnicodeString& source) {
string data;
StringByteSink sink(&data);
source.toUTF8(sink);
return data;
}
// Converts UTF8-formatted std::string 'source' to a UnicodeString.
UnicodeString Utf8StringToUnicodeString(const string& source) {
// Note that we don't use icu::StringPiece(const string&).
return UnicodeString::fromUTF8(
icu::StringPiece(source.c_str(), source.size()));
}
} // namespace
// Implementation of the abstract classes RegExpInput and RegExp using ICU
// regular expression capabilities.
// ICU implementation of the RegExpInput abstract class.
class IcuRegExpInput : public RegExpInput {
public:
explicit IcuRegExpInput(const string& utf8_input)
: utf8_input_(Utf8StringToUnicodeString(utf8_input)),
position_(0) {}
virtual ~IcuRegExpInput() {}
virtual string ToString() const {
return UnicodeStringToUtf8String(utf8_input_.tempSubString(position_));
}
UnicodeString* Data() {
return &utf8_input_;
}
// The current start position. For a newly created input, position is 0. Each
// call to ConsumeRegExp() or RegExp::Consume() advances the position in the
// case of the successful match to be after the match.
int position() const {
return position_;
}
void set_position(int position) {
DCHECK(position >= 0 && position <= utf8_input_.length());
position_ = position;
}
private:
UnicodeString utf8_input_;
int position_;
DISALLOW_COPY_AND_ASSIGN(IcuRegExpInput);
};
// ICU implementation of the RegExp abstract class.
class IcuRegExp : public RegExp {
public:
explicit IcuRegExp(const string& utf8_regexp) {
UParseError parse_error;
UErrorCode status = U_ZERO_ERROR;
utf8_regexp_.reset(RegexPattern::compile(
Utf8StringToUnicodeString(utf8_regexp), 0, parse_error, status));
if (U_FAILURE(status)) {
// The provided regular expressions should compile correctly.
LOG(ERROR) << "Error compiling regular expression: " << utf8_regexp;
utf8_regexp_.reset(NULL);
}
}
virtual ~IcuRegExp() {}
virtual bool Consume(RegExpInput* input_string,
bool anchor_at_start,
string* matched_string1,
string* matched_string2,
string* matched_string3) const {
DCHECK(input_string);
if (!utf8_regexp_.get()) {
return false;
}
IcuRegExpInput* const input = static_cast<IcuRegExpInput*>(input_string);
UErrorCode status = U_ZERO_ERROR;
const scoped_ptr<RegexMatcher> matcher(
utf8_regexp_->matcher(*input->Data(), status));
bool match_succeeded = anchor_at_start
? matcher->lookingAt(input->position(), status)
: matcher->find(input->position(), status);
if (!match_succeeded || U_FAILURE(status)) {
return false;
}
string* const matched_strings[] = {
matched_string1, matched_string2, matched_string3
};
// If less matches than expected - fail.
for (size_t i = 0; i < arraysize(matched_strings); ++i) {
if (matched_strings[i]) {
// Groups are counted from 1 rather than 0.
const int group_index = i + 1;
if (group_index > matcher->groupCount()) {
return false;
}
*matched_strings[i] =
UnicodeStringToUtf8String(matcher->group(group_index, status));
}
}
input->set_position(matcher->end(status));
return !U_FAILURE(status);
}
bool Match(const string& input_string,
bool full_match,
string* matched_string) const {
if (!utf8_regexp_.get()) {
return false;
}
IcuRegExpInput input(input_string);
UErrorCode status = U_ZERO_ERROR;
const scoped_ptr<RegexMatcher> matcher(
utf8_regexp_->matcher(*input.Data(), status));
bool match_succeeded = full_match
? matcher->matches(input.position(), status)
: matcher->find(input.position(), status);
if (!match_succeeded || U_FAILURE(status)) {
return false;
}
if (matcher->groupCount() > 0 && matched_string) {
*matched_string = UnicodeStringToUtf8String(matcher->group(1, status));
}
return !U_FAILURE(status);
}
bool Replace(string* string_to_process,
bool global,
const string& replacement_string) const {
DCHECK(string_to_process);
if (!utf8_regexp_.get()) {
return false;
}
IcuRegExpInput input(*string_to_process);
UErrorCode status = U_ZERO_ERROR;
const scoped_ptr<RegexMatcher> matcher(
utf8_regexp_->matcher(*input.Data(), status));
if (U_FAILURE(status)) {
return false;
}
UnicodeString output;
// We reimplement ReplaceFirst and ReplaceAll such that their behaviour is
// consistent with the RE2 reg-ex matcher.
if (!matcher->find()) {
return false;
}
matcher->appendReplacement(output,
Utf8StringToUnicodeString(replacement_string),
status);
if (global) {
// Continue and look for more matches.
while (matcher->find()) {
matcher->appendReplacement(
output,
Utf8StringToUnicodeString(replacement_string),
status);
}
}
matcher->appendTail(output);
if (U_FAILURE(status)) {
return false;
}
const string replaced_string = UnicodeStringToUtf8String(output);
*string_to_process = replaced_string;
return true;
}
private:
scoped_ptr<RegexPattern> utf8_regexp_;
DISALLOW_COPY_AND_ASSIGN(IcuRegExp);
};
RegExpInput* ICURegExpFactory::CreateInput(const string& utf8_input) const {
return new IcuRegExpInput(utf8_input);
}
RegExp* ICURegExpFactory::CreateRegExp(const string& utf8_regexp) const {
return new IcuRegExp(utf8_regexp);
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/regexp_adapter_icu.cc
|
C++
|
unknown
| 7,318
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: Philippe Liard
#ifndef I18N_PHONENUMBERS_REGEXP_ADAPTER_ICU_H_
#define I18N_PHONENUMBERS_REGEXP_ADAPTER_ICU_H_
#include <string>
#include "phonenumbers/regexp_adapter.h"
namespace i18n {
namespace phonenumbers {
// ICU regexp factory that lets the user instantiate the underlying
// implementation of RegExp and RegExpInput classes based on the ICU regexp
// engine.
class ICURegExpFactory : public AbstractRegExpFactory {
public:
virtual ~ICURegExpFactory() {}
virtual RegExpInput* CreateInput(const string& utf8_input) const;
virtual RegExp* CreateRegExp(const string& utf8_regexp) const;
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_REGEXP_ADAPTER_ICU_H_
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/regexp_adapter_icu.h
|
C++
|
unknown
| 1,325
|
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: George Yakovlev
// Philippe Liard
#include "phonenumbers/regexp_adapter_re2.h"
#include <cstddef>
#include <string>
#include <re2/re2.h>
#include <re2/stringpiece.h>
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/logging.h"
#include "phonenumbers/stringutil.h"
namespace i18n {
namespace phonenumbers {
// Implementation of RegExpInput abstract class.
class RE2RegExpInput : public RegExpInput {
public:
explicit RE2RegExpInput(const string& utf8_input)
: string_(utf8_input),
utf8_input_(string_) {}
virtual string ToString() const {
return utf8_input_.ToString();
}
StringPiece* Data() {
return &utf8_input_;
}
private:
// string_ holds the string referenced by utf8_input_ as StringPiece doesn't
// copy the string passed in.
const string string_;
StringPiece utf8_input_;
};
namespace {
template <typename Function, typename Input>
bool DispatchRE2Call(Function regex_function,
Input input,
const RE2& regexp,
string* out1,
string* out2,
string* out3) {
const RE2::Arg outs[] = { out1, out2, out3, };
const RE2::Arg* const args[] = { &outs[0], &outs[1], &outs[2], };
const int argc = out3 ? 3 : out2 ? 2 : out1 ? 1 : 0;
return regex_function(input, regexp, args, argc);
}
// Replaces unescaped dollar-signs with backslashes. Backslashes are deleted
// when they escape dollar-signs.
string TransformRegularExpressionToRE2Syntax(const string& regex) {
string re2_regex(regex);
if (GlobalReplaceSubstring("$", "\\", &re2_regex) == 0) {
return regex;
}
// If we replaced a dollar sign with a backslash and there are now two
// backslashes in the string, we assume that the dollar-sign was previously
// escaped and that we need to retain it. To do this, we replace pairs of
// backslashes with a dollar sign.
GlobalReplaceSubstring("\\\\", "$", &re2_regex);
return re2_regex;
}
} // namespace
// Implementation of RegExp abstract class.
class RE2RegExp : public RegExp {
public:
explicit RE2RegExp(const string& utf8_regexp)
: utf8_regexp_(utf8_regexp) {}
virtual bool Consume(RegExpInput* input_string,
bool anchor_at_start,
string* matched_string1,
string* matched_string2,
string* matched_string3) const {
DCHECK(input_string);
StringPiece* utf8_input =
static_cast<RE2RegExpInput*>(input_string)->Data();
if (anchor_at_start) {
return DispatchRE2Call(RE2::ConsumeN, utf8_input, utf8_regexp_,
matched_string1, matched_string2,
matched_string3);
} else {
return DispatchRE2Call(RE2::FindAndConsumeN, utf8_input, utf8_regexp_,
matched_string1, matched_string2,
matched_string3);
}
}
virtual bool Match(const string& input_string,
bool full_match,
string* matched_string) const {
if (full_match) {
return DispatchRE2Call(RE2::FullMatchN, input_string, utf8_regexp_,
matched_string, NULL, NULL);
} else {
return DispatchRE2Call(RE2::PartialMatchN, input_string, utf8_regexp_,
matched_string, NULL, NULL);
}
}
virtual bool Replace(string* string_to_process,
bool global,
const string& replacement_string) const {
DCHECK(string_to_process);
const string re2_replacement_string =
TransformRegularExpressionToRE2Syntax(replacement_string);
if (global) {
return RE2::GlobalReplace(string_to_process, utf8_regexp_,
re2_replacement_string);
} else {
return RE2::Replace(string_to_process, utf8_regexp_,
re2_replacement_string);
}
}
private:
RE2 utf8_regexp_;
};
RegExpInput* RE2RegExpFactory::CreateInput(const string& utf8_input) const {
return new RE2RegExpInput(utf8_input);
}
RegExp* RE2RegExpFactory::CreateRegExp(const string& utf8_regexp) const {
return new RE2RegExp(utf8_regexp);
}
} // namespace phonenumbers
} // namespace i18n
|
2301_81045437/third_party_libphonenumber
|
cpp/src/phonenumbers/regexp_adapter_re2.cc
|
C++
|
unknown
| 4,924
|