[
  {
    "path": "Android.mk",
    "content": "#\n# Copyright 2014 The Android Open Source Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n# This contains the module build definitions for the hardware-specific\n# components for this device.\n#\n# As much as possible, those components should be built unconditionally,\n# with device-specific names to avoid collisions, to avoid device-specific\n# bitrot and build breakages. Building a component unconditionally does\n# *not* include it on all devices, so it is safe even with hardware-specific\n# components.\n\nLOCAL_PATH := $(call my-dir)\n\nifeq ($(TARGET_DEVICE),oneplus2)\n\ninclude $(call all-subdir-makefiles,$(LOCAL_PATH))\n\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE := wifi_symlinks\nLOCAL_MODULE_TAGS := optional\nLOCAL_MODULE_CLASS := FAKE\nLOCAL_MODULE_SUFFIX := -timestamp\n\ninclude $(BUILD_SYSTEM)/base_rules.mk\n\n$(LOCAL_BUILT_MODULE): ACTUAL_INI_FILE := /system/etc/wifi/WCNSS_qcom_cfg.ini\n$(LOCAL_BUILT_MODULE): WCNSS_INI_SYMLINK := $(TARGET_OUT)/etc/firmware/wlan/qca_cld/WCNSS_qcom_cfg.ini\n\n$(LOCAL_BUILT_MODULE): ACTUAL_BIN_FILE := /system/etc/wifi/WCNSS_qcom_wlan_nv.bin\n$(LOCAL_BUILT_MODULE): WCNSS_BIN_SYMLINK := $(TARGET_OUT)/etc/firmware/wlan/qca_cld/WCNSS_qcom_wlan_nv.bin\n\n$(LOCAL_BUILT_MODULE): ACTUAL_DAT_FILE := /system/etc/wifi/WCNSS_cfg.dat\n$(LOCAL_BUILT_MODULE): WCNSS_DAT_SYMLINK := $(TARGET_OUT)/etc/firmware/wlan/qca_cld/WCNSS_cfg.dat\n\n$(LOCAL_BUILT_MODULE): ACTUAL_MAC_FILE := /persist/wlan_mac.bin\n$(LOCAL_BUILT_MODULE): WCNSS_MAC_SYMLINK := $(TARGET_OUT)/etc/firmware/wlan/qca_cld/wlan_mac.bin\n\n\n$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/Android.mk\n$(LOCAL_BUILT_MODULE):\n\t$(hide) echo \"Making symlinks for wifi\"\n\t$(hide) mkdir -p $(dir $@)\n\t$(hide) mkdir -p $(dir $(WCNSS_BIN_SYMLINK))\n\t$(hide) rm -rf $@\n\t$(hide) rm -rf $(WCNSS_INI_SYMLINK)\n\t$(hide) ln -sf $(ACTUAL_INI_FILE) $(WCNSS_INI_SYMLINK)\n\t$(hide) rm -rf $(WCNSS_BIN_SYMLINK)\n\t$(hide) ln -sf $(ACTUAL_BIN_FILE) $(WCNSS_BIN_SYMLINK)\n\t$(hide) rm -rf $(WCNSS_DAT_SYMLINK)\n\t$(hide) ln -sf $(ACTUAL_DAT_FILE) $(WCNSS_DAT_SYMLINK)\n\t$(hide) rm -rf $(WCNSS_MAC_SYMLINK)\n\t$(hide) ln -sf $(ACTUAL_MAC_FILE) $(WCNSS_MAC_SYMLINK)\n\t$(hide) touch $@\n\ninclude $(call all-makefiles-under,$(LOCAL_PATH))\n\nIMS_LIBS := libimscamera_jni.so libimsmedia_jni.so\n\nIMS_SYMLINKS := $(addprefix $(TARGET_OUT)/app/ims/lib/arm64/,$(notdir $(IMS_LIBS)))\n$(IMS_SYMLINKS): $(LOCAL_INSTALLED_MODULE)\n\t@echo \"IMS lib link: $@\"\n\t@mkdir -p $(dir $@)\n\t@rm -rf $@\n\t$(hide) ln -sf /system/vendor/lib64/$(notdir $@) $@\n\nALL_DEFAULT_INSTALLED_MODULES += $(IMS_SYMLINKS)\n\ninclude device/oneplus/oneplus2/tftp.mk\n\nendif\n"
  },
  {
    "path": "BoardConfig.mk",
    "content": "# Copyright (C) 2015 The CyanogenMod Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n#\n# This file sets variables that control the way modules are built\n# thorughout the system. It should not be used to conditionally\n# disable makefiles (the proper mechanism to control what gets\n# included in a build is to use PRODUCT_PACKAGES in a product\n# definition file).\n#\n\n# Inherit from oppo-common\n-include device/oppo/common/BoardConfigCommon.mk\n\nTARGET_OTA_ASSERT_DEVICE := OnePlus2,oneplus2\n\nPLATFORM_PATH := device/oneplus/oneplus2\n\nBOARD_VENDOR := oneplus\n\n# Use Snapdragon LLVM, if available\nTARGET_USE_SDCLANG := true\n\n# Assertions\nTARGET_BOARD_INFO_FILE ?= $(PLATFORM_PATH)/board-info.txt\n\n# Bootloader\nTARGET_BOOTLOADER_BOARD_NAME := MSM8994\nTARGET_NO_BOOTLOADER := true\n\n# Platform\nTARGET_BOARD_PLATFORM := msm8994\nTARGET_BOARD_PLATFORM_GPU := qcom-adreno430\n\n# Architecture\nTARGET_ARCH := arm64\nTARGET_ARCH_VARIANT := armv8-a\nTARGET_CPU_ABI := arm64-v8a\nTARGET_CPU_ABI2 :=\nTARGET_CPU_VARIANT := generic\n\nTARGET_2ND_ARCH := arm\nTARGET_2ND_ARCH_VARIANT := armv7-a-neon\nTARGET_2ND_CPU_ABI := armeabi-v7a\nTARGET_2ND_CPU_ABI2 := armeabi\nTARGET_2ND_CPU_VARIANT := cortex-a53.a57\n\nTARGET_USES_64_BIT_BINDER := true\n\n# Kernel\nBOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-3\nBOARD_KERNEL_BASE := 0x00000000\nBOARD_KERNEL_PAGESIZE := 4096\nBOARD_KERNEL_TAGS_OFFSET := 0x00000100\nBOARD_RAMDISK_OFFSET := 0x01000000\nBOARD_KERNEL_IMAGE_NAME := Image.gz-dtb\nTARGET_KERNEL_APPEND_DTB := true\nTARGET_KERNEL_ARCH := arm64\nTARGET_KERNEL_HEADER_ARCH := arm64\nTARGET_KERNEL_SOURCE := kernel/oneplus/msm8994\nTARGET_KERNEL_CONFIG := cm_oneplus2_defconfig\nTARGET_KERNEL_CROSS_COMPILE_PREFIX := aarch64-linux-android-\n\n# QCOM hardware\nBOARD_USES_QCOM_HARDWARE := true\n\n# ANT+\nBOARD_ANT_WIRELESS_DEVICE := \"qualcomm-uart\"\n\n# Audio\nAUDIO_FEATURE_ENABLED_ACDB_LICENSE := true\nAUDIO_FEATURE_ENABLED_COMPRESS_CAPTURE := true\nAUDIO_FEATURE_ENABLED_COMPRESS_VOIP := true\nAUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP := true\nAUDIO_FEATURE_ENABLED_EXTN_FORMATS := true\nAUDIO_FEATURE_ENABLED_FLAC_OFFLOAD := true\nAUDIO_FEATURE_ENABLED_FLUENCE := true\nAUDIO_FEATURE_ENABLED_HFP := true\nAUDIO_FEATURE_ENABLED_INCALL_MUSIC := false\nAUDIO_FEATURE_ENABLED_KPI_OPTIMIZE := true\nAUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS := true\nAUDIO_FEATURE_ENABLED_PCM_OFFLOAD := true\nAUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24 := true\nAUDIO_FEATURE_ENABLED_PROXY_DEVICE := true\n\nAUDIO_USE_LL_AS_PRIMARY_OUTPUT := true\nBOARD_USES_ALSA_AUDIO := true\n\n# Bluetooth\nBOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(PLATFORM_PATH)/bluetooth\nBOARD_HAS_QCA_BT_ROME := true\nBOARD_HAVE_BLUETOOTH := true\nBOARD_HAVE_BLUETOOTH_QCOM := true\nQCOM_BT_USE_BTNV := true\nQCOM_BT_USE_SMD_TTY := true\n\n# Camera\nTARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS := true\nUSE_DEVICE_SPECIFIC_CAMERA := true\nTARGET_USES_MEDIA_EXTENSIONS := true\nTARGET_HAS_LEGACY_CAMERA_HAL1 := true\n\n# Charger\nBOARD_CHARGER_DISABLE_INIT_BLANK := true\n\n# CNE and DPM\nTARGET_LDPRELOAD := libNimsWrap.so\nBOARD_USES_QCNE := true\n\n# Cpusets\nENABLE_CPUSETS := true\n\n# GPS\nTARGET_NO_RPC := true\nUSE_DEVICE_SPECIFIC_GPS := true\n\n# Graphics\nNUM_FRAMEBUFFER_SURFACE_BUFFERS := 3\nTARGET_USES_ION := true\nTARGET_USES_NEW_ION_API :=true\nTARGET_USES_C2D_COMPOSITION := true\nUSE_OPENGL_RENDERER := true\n\nMAX_EGL_CACHE_KEY_SIZE := 12*1024\nMAX_EGL_CACHE_SIZE := 2048*1024\n\nHAVE_ADRENO_SOURCE := false\nOVERRIDE_RS_DRIVER := libRSDriver_adreno.so\n\nVSYNC_EVENT_PHASE_OFFSET_NS := 2000000\nSF_VSYNC_EVENT_PHASE_OFFSET_NS := 6000000\n\n# Include path\nTARGET_SPECIFIC_HEADER_PATH := $(PLATFORM_PATH)/include\n\n# Init\nTARGET_INIT_VENDOR_LIB := libinit_oneplus2\nTARGET_PLATFORM_DEVICE_BASE := /devices/soc.0/\n\n# Keystore\nTARGET_PROVIDES_KEYMASTER := true\n\n# Lights\nTARGET_PROVIDES_LIBLIGHT := true\n\n# RIL\nTARGET_RIL_VARIANT := caf\n\n# RPC\nTARGET_NO_RPC := true\n\n# Sensors\nUSE_SENSOR_MULTI_HAL := true\n\n# Enable dexpreopt to speed boot time\nifeq ($(HOST_OS),linux)\n  ifeq ($(call match-word-in-list,$(TARGET_BUILD_VARIANT),user),true)\n    ifeq ($(WITH_DEXPREOPT),)\n      WITH_DEXPREOPT := true\n    endif\n  endif\nendif\n\n# Wifi\nBOARD_HAS_QCOM_WLAN := true\nBOARD_HAS_QCOM_WLAN_SDK := true\nBOARD_WLAN_DEVICE := qcwcn\nBOARD_HOSTAPD_DRIVER := NL80211\nBOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)\nBOARD_WPA_SUPPLICANT_DRIVER := NL80211\nBOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)\nTARGET_USES_WCNSS_CTRL := true\nTARGET_USES_QCOM_WCNSS_QMI := true\nWIFI_DRIVER_FW_PATH_AP := \"ap\"\nWIFI_DRIVER_FW_PATH_STA := \"sta\"\nWIFI_DRIVER_FW_PATH_P2P := \"p2p\"\nWPA_SUPPLICANT_VERSION := VER_0_8_X\nCONFIG_EAP_PROXY := qmi\nCONFIG_EAP_PROXY_DUAL_SIM := true\nCONFIG_EAP_PROXY_AKA_PRIME := true\nCONFIG_EAP_PROXY_MSM8994_TARGET := true\n\n# Partitions\nBOARD_BOOTIMAGE_PARTITION_SIZE := 67108864\nBOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := f2fs\nBOARD_CACHEIMAGE_PARTITION_SIZE := 268435456\nBOARD_RECOVERYIMAGE_PARTITION_SIZE := 67108864\nBOARD_SYSTEMIMAGE_PARTITION_SIZE := 2684354560\nBOARD_USERDATAIMAGE_PARTITION_SIZE := 59047394304\nBOARD_FLASH_BLOCK_SIZE := 262144\nTARGET_USERIMAGES_USE_EXT4 := true\nTARGET_USERIMAGES_USE_F2FS := true\n\n# Recovery\nTARGET_RECOVERY_FSTAB := $(PLATFORM_PATH)/rootdir/etc/fstab.qcom\n\n# SELinux\ninclude device/qcom/sepolicy/sepolicy.mk\n\nBOARD_SEPOLICY_DIRS += $(PLATFORM_PATH)/sepolicy\n\n# Time services\nBOARD_USES_QC_TIME_SERVICES := true\n\n# CM Hardware\nBOARD_HARDWARE_CLASS += $(PLATFORM_PATH)/cmhw\nTARGET_TAP_TO_WAKE_NODE := \"/proc/touchpanel/double_tap_enable\"\n\n# inherit from the proprietary version\n-include vendor/oneplus/oneplus2/BoardConfigVendor.mk\n"
  },
  {
    "path": "android_filesystem_config.h",
    "content": "/*\n# Copyright (c) 2016, The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n#       copyright notice, this list of conditions and the following\n#       disclaimer in the documentation and/or other materials provided\n#       with the distribution.\n#     * Neither the name of The Linux Foundation nor the names of its\n#       contributors may be used to endorse or promote products derived\n#       from this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include <private/android_filesystem_config.h>\n\n#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS\n const struct fs_path_config android_device_files[] = {\n      // { 00755, AID_UID,     AID_GID,     (1ULL << CAPABILITY), \"PATH_TO_BINARY\" },\n      { 00755, AID_SYSTEM,      AID_SYSTEM,      (1ULL << CAP_NET_BIND_SERVICE), \"system/bin/pm-service\"},\n      { 00755, AID_SYSTEM,         AID_SYSTEM,         (1ULL << CAP_NET_BIND_SERVICE), \"system/bin/imsdatadaemon\" },\n      { 00755, AID_SYSTEM,         AID_SYSTEM,         (1ULL << CAP_NET_BIND_SERVICE), \"system/bin/cnss-daemon\"},\n      { 00755, AID_SYSTEM,         AID_RADIO,          (1ULL << CAP_NET_BIND_SERVICE), \"system/bin/ims_rtp_daemon\" },\n};\n"
  },
  {
    "path": "audio/aanc_tuning_mixer.txt",
    "content": "#ANC_TEST_P_PATH_MIC_STEREO Capture\nacdb_dev_id:85\n!Capture\nTxdevice:0\n\nenable\nTX7 HPF Switch:1\nTX8 HPF Switch:1\nAIF1_CAP Mixer SLIM TX7:1\nAIF1_CAP Mixer SLIM TX8:1\nSLIM TX7 MUX:DEC9\nDEC9 MUX:DMIC4\nSLIM TX8 MUX:DEC10\nDEC10 MUX:DMIC3\nSLIM_0_TX Channels:Two\nMultiMedia1 Mixer SLIM_0_TX:1\n\ndisable\nMultiMedia1 Mixer SLIM_0_TX:0\nAIF1_CAP Mixer SLIM TX7:0\nAIF1_CAP Mixer SLIM TX8:0\nSLIM TX7 MUX:ZERO\nSLIM TX8 MUX:ZERO\nDEC9 MUX:ZERO\nDEC10 MUX:ZERO\nTX7 HPF Switch:0\nTX8 HPF Switch:0\n\n#ANC_TEST_S_PATH_MIC_STEREO Capture\nacdb_dev_id:88\n!Capture\nTxdevice:0\n\nenable\nTX7 HPF Switch:1\nTX8 HPF Switch:1\nAIF1_CAP Mixer SLIM TX7:1\nAIF1_CAP Mixer SLIM TX8:1\nSLIM TX7 MUX:DEC8\nDEC7 MUX:ANC2_FB\nANC2 MUX:DMIC3\nSLIM TX8 MUX:DEC7\nDEC8 MUX:ANC1_FB\nANC1 MUX:DMIC3\nANC1 FB MUX:EAR_HPH_L\nSLIM_0_TX Channels:Two\nMultiMedia1 Mixer SLIM_0_TX:1\n\ndisable\nMultiMedia1 Mixer SLIM_0_TX:0\nAIF1_CAP Mixer SLIM TX7:0\nAIF1_CAP Mixer SLIM TX8:0\nSLIM TX7 MUX:ZERO\nSLIM TX8 MUX:ZERO\nDEC7 MUX:ZERO\nANC2 MUX:ZERO\nANC1 MUX:ZERO\nDEC8 MUX:ZERO\nANC1 FB MUX:ZERO\nTX7 HPF Switch:0\nTX8 HPF Switch:0\n\n#ANC_TEST_E_PATH_MIC_STEREO Capture\nacdb_dev_id:91\n!Capture\nTxdevice:0\n\nenable\nTX7 HPF Switch:1\nTX8 HPF Switch:1\nAIF1_CAP Mixer SLIM TX7:1\nAIF1_CAP Mixer SLIM TX8:1\nSLIM TX7 MUX:DEC8\nDEC7 MUX:ANC2_FB\nANC2 MUX:DMIC4\nANC1 MUX:DMIC4\nSLIM TX8 MUX:DEC7\nDEC8 MUX:ANC1_FB\nANC1 FB MUX:EAR_HPH_L\nSLIM_0_TX Channels:Two\nMultiMedia1 Mixer SLIM_0_TX:1\n\ndisable\nMultiMedia1 Mixer SLIM_0_TX:0\nAIF1_CAP Mixer SLIM TX7:0\nAIF1_CAP Mixer SLIM TX8:0\nSLIM TX7 MUX:ZERO\nSLIM TX8 MUX:ZERO\nDEC7 MUX:ZERO\nANC2 MUX:ZERO\nDEC10 MUX:ZERO\nANC1 FB MUX:ZERO\nTX7 HPF Switch:0\nTX8 HPF Switch:0\n\n#ANC_TEST_S_PATH_HANDSET_SPKR_ANC_MONO\nacdb_dev_id:86\n!Playback\nRxdevice:0\n\nenable\nANC Function:ON\nSLIM RX1 MUX:AIF1_PB\nSLIM_0_RX Channels:One\nRX1 MIX1 INP1:RX1\nCLASS_H_DSM MUX:DSM_HPHL_RX1\nRX1 Digital Volume:87\nDAC1 Switch:1\nANC Slot:7\nSLIMBUS_0_RX Audio Mixer MultiMedia1:1\n\ndisable\nSLIMBUS_0_RX Audio Mixer MultiMedia1:0\nANC Slot:0\nSLIM RX1 MUX:ZERO\nRX1 MIX1 INP1:ZERO\nRX1 Digital Volume:0\nDAC1 Switch:0\nANC Function:OFF\n\n#ANC_TEST_E_PATH_HANDSET_SPKR_ANC_MONO\nacdb_dev_id:89\n!Playback\nRxdevice:0\n\nenable\nANC Function:ON\nSLIM RX1 MUX:AIF1_PB\nSLIM_0_RX Channels:One\nRX1 MIX1 INP1:RX1\nCLASS_H_DSM MUX:DSM_HPHL_RX1\nRX1 Digital Volume:87\nDAC1 Switch:1\nANC Slot:8\nSLIMBUS_0_RX Audio Mixer MultiMedia1:1\n\ndisable\nSLIMBUS_0_RX Audio Mixer MultiMedia1:0\nANC Slot:0\nSLIM RX1 MUX:ZERO\nRX1 MIX1 INP1:ZERO\nRX1 Digital Volume:0\nDAC1 Switch:0\nANC Function:OFF\n"
  },
  {
    "path": "audio/audio_effects.conf",
    "content": "# List of effect libraries to load. Each library element must contain a \"path\" element\n# giving the full path of the library .so file.\n#    libraries {\n#        <lib name> {\n#          path <lib path>\n#        }\n#    }\nlibraries {\n  bundle {\n    path /system/lib/soundfx/libbundlewrapper.so\n  }\n  reverb {\n    path /system/lib/soundfx/libreverbwrapper.so\n  }\n  qcbassboost {\n    path /vendor/lib/soundfx/libqcbassboost.so\n  }\n  qcvirt {\n    path /vendor/lib/soundfx/libqcvirt.so\n  }\n  qcreverb {\n    path /vendor/lib/soundfx/libqcreverb.so\n  }\n  visualizer_sw {\n    path /system/lib/soundfx/libvisualizer.so\n  }\n  visualizer_hw {\n    path /system/lib/soundfx/libqcomvisualizer.so\n  }\n  downmix {\n    path /system/lib/soundfx/libdownmix.so\n  }\n  proxy {\n    path /system/lib/soundfx/libeffectproxy.so\n  }\n  offload_bundle {\n    path /system/lib/soundfx/libqcompostprocbundle.so\n  }\n  qcom_pre_processing {\n    path /system/lib/soundfx/libqcomvoiceprocessing.so\n  }\n  loudness_enhancer {\n    path /system/lib/soundfx/libldnhncr.so\n  }\n}\n\n# Default pre-processing library. Add to audio_effect.conf \"libraries\" section if\n# audio HAL implements support for default software audio pre-processing effects\n#\n#  pre_processing {\n#    path /system/lib/soundfx/libaudiopreprocessing.so\n#  }\n\n# list of effects to load. Each effect element must contain a \"library\" and a \"uuid\" element.\n# The value of the \"library\" element must correspond to the name of one library element in the\n# \"libraries\" element.\n# The name of the effect element is indicative, only the value of the \"uuid\" element\n# designates the effect.\n# The uuid is the implementation specific UUID as specified by the effect vendor. This is not the\n# generic effect type UUID.\n#    effects {\n#        <fx name> {\n#            library <lib name>\n#            uuid <effect uuid>\n#        }\n#        ...\n#    }\n\neffects {\n\n# additions for the proxy implementation\n# Proxy implementation\n  #effectname {\n    #library proxy\n    #uuid  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n\n    # SW implemetation of the effect. Added as a node under the proxy to\n    # indicate this as a sub effect.\n      #libsw {\n         #library libSW\n         #uuid  yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy\n      #} End of SW effect\n\n    # HW implementation of the effect. Added as a node under the proxy to\n    # indicate this as a sub effect.\n      #libhw {\n         #library libHW\n         #uuid  zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz\n      #}End of HW effect\n  #} End of effect proxy\n\n  bassboost {\n    library proxy\n    uuid 14804144-a5ee-4d24-aa88-0002a5d5c51b\n\n    libsw {\n      library qcbassboost\n      uuid 23aca180-44bd-11e2-bcfd-0800200c9a66\n    }\n\n    libhw {\n      library offload_bundle\n      uuid 2c4a8c24-1581-487f-94f6-0002a5d5c51b\n    }\n  }\n  virtualizer {\n    library proxy\n    uuid d3467faa-acc7-4d34-acaf-0002a5d5c51b\n\n    libsw {\n      library qcvirt\n      uuid e6c98a16-22a3-11e2-b87b-f23c91aec05e\n    }\n\n    libhw {\n      library offload_bundle\n      uuid 509a4498-561a-4bea-b3b1-0002a5d5c51b\n    }\n  }\n  equalizer {\n    library proxy\n    uuid c8e70ecd-48ca-456e-8a4f-0002a5d5c51b\n\n    libsw {\n      library bundle\n      uuid ce772f20-847d-11df-bb17-0002a5d5c51b\n    }\n\n    libhw {\n      library offload_bundle\n      uuid a0dac280-401c-11e3-9379-0002a5d5c51b\n    }\n  }\n  volume {\n    library bundle\n    uuid 119341a0-8469-11df-81f9-0002a5d5c51b\n  }\n  reverb_env_aux {\n    library proxy\n    uuid 48404ac9-d202-4ccc-bf84-0002a5d5c51b\n\n    libsw {\n      library qcreverb\n      uuid a8c1e5f3-293d-43cd-95ec-d5e26c02e217\n    }\n\n    libhw {\n      library offload_bundle\n      uuid 79a18026-18fd-4185-8233-0002a5d5c51b\n    }\n  }\n  reverb_env_ins {\n    library proxy\n    uuid b707403a-a1c1-4291-9573-0002a5d5c51b\n\n    libsw {\n      library qcreverb\n      uuid 791fff8b-8129-4655-83a4-59bc61034c3a\n    }\n\n    libhw {\n      library offload_bundle\n      uuid eb64ea04-973b-43d2-8f5e-0002a5d5c51b\n    }\n  }\n  reverb_pre_aux {\n    library proxy\n    uuid 1b78f587-6d1c-422e-8b84-0002a5d5c51b\n\n    libsw {\n      library qcreverb\n      uuid 53ef1db5-c0c0-445b-b060-e34d20ebb70a\n    }\n\n    libhw {\n      library offload_bundle\n      uuid 6987be09-b142-4b41-9056-0002a5d5c51b\n    }\n  }\n  reverb_pre_ins {\n    library proxy\n    uuid f3e178d2-ebcb-408e-8357-0002a5d5c51b\n\n    libsw {\n      library qcreverb\n      uuid b08a0e38-22a5-11e2-b87b-f23c91aec05e\n    }\n\n    libhw {\n      library offload_bundle\n      uuid aa2bebf6-47cf-4613-9bca-0002a5d5c51b\n    }\n  }\n  visualizer {\n    library proxy\n    uuid 1d0a1a53-7d5d-48f2-8e71-27fbd10d842c\n\n    libsw {\n      library visualizer_sw\n      uuid  d069d9e0-8329-11df-9168-0002a5d5c51b\n    }\n\n    libhw {\n      library visualizer_hw\n      uuid 7a8044a0-1a71-11e3-a184-0002a5d5c51b\n    }\n  }\n  downmix {\n    library downmix\n    uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f\n  }\n  hw_acc {\n    library offload_bundle\n    uuid 7d1580bd-297f-4683-9239-e475b6d1d69f\n  }\n  loudness_enhancer {\n    library loudness_enhancer\n    uuid fa415329-2034-4bea-b5dc-5b381c8d1e2c\n  }\n  aec {\n    library qcom_pre_processing\n    uuid 0f8d0d2a-59e5-45fe-b6e4-248c8a799109\n  }\n  ns {\n    library qcom_pre_processing\n    uuid 1d97bb0b-9e2f-4403-9ae3-58c2554306f8\n  }\n}\n\n#ifdef VENDOR_EDIT\n#lifei@OnePlus.MultiMediaService, 2015/12/31,remove this because no use for skype for slove SNDM-206\n#pre_processing {\n#    voice_communication {\n#        aec {\n#        }\n#        ns {\n#        }\n#    }\n#}\n#endif/*VENDOR_EDIT*/\n\n# Default pre-processing effects. Add to audio_effect.conf \"effects\" section if\n# audio HAL implements support for them.\n#\n#  agc {\n#    library pre_processing\n#    uuid aa8130e0-66fc-11e0-bad0-0002a5d5c51b\n#  }\n#  aec {\n#    library pre_processing\n#    uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b\n#  }\n#  ns {\n#    library pre_processing\n#    uuid c06c8400-8e06-11e0-9cb6-0002a5d5c51b\n#  }\n\n# Audio preprocessor configurations.\n# The pre processor configuration consists in a list of elements each describing\n# pre processor settings for a given input source. Valid input source names are:\n# \"mic\", \"camcorder\", \"voice_recognition\", \"voice_communication\"\n# Each input source element contains a list of effects elements. The name of the effect\n# element must be the name of one of the effects in the \"effects\" list of the file.\n# Each effect element may optionally contain a list of parameters and their\n# default value to apply when the pre processor effect is created.\n# A parameter is defined by a \"param\" element and a \"value\" element. Each of these elements\n# consists in one or more elements specifying a type followed by a value.\n# The types defined are: \"int\", \"short\", \"float\", \"bool\" and \"string\"\n# When both \"param\" and \"value\" are a single int, a simple form is allowed where just\n# the param and value pair is present in the parameter description\n#    pre_processing {\n#        <input source name> {\n#            <fx name> {\n#                <param 1 name> {\n#                    param {\n#                        int|short|float|bool|string <value>\n#                        [ int|short|float|bool|string <value> ]\n#                        ...\n#                    }\n#                    value {\n#                        int|short|float|bool|string <value>\n#                        [ int|short|float|bool|string <value> ]\n#                        ...\n#                    }\n#                }\n#                <param 2 name > {<param> <value>}\n#                ...\n#            }\n#            ...\n#        }\n#        ...\n#    }\n\n#\n# TODO: add default audio pre processor configurations after debug and tuning phase\n#\n"
  },
  {
    "path": "audio/audio_output_policy.conf",
    "content": "# List of profiles for the output device session where stream is routed.\n# A stream opened with the inputs attributes which match the \"flags\" and\n# \"formats\" as specified in the profile is routed to a device at\n# sample rate specified under \"sampling_rates\" and bit width under\n# \"bit_width\" and the topology extracted from the acdb data against\n# the \"app_type\".\n#\n# the flags and formats are specified using the strings corresponding to\n# enums in audio.h and audio_policy.h. They are concatenated with \"|\"\n# without space or \"\\n\".\n# the flags and formats should match the ones in \"audio_policy.conf\"\n\noutputs {\n  default {\n    flags AUDIO_OUTPUT_FLAG_PRIMARY\n    formats AUDIO_FORMAT_PCM_16_BIT\n    sampling_rates 48000\n    bit_width 16\n    app_type 69937\n  }\n  deep_buffer {\n    flags AUDIO_OUTPUT_FLAG_DEEP_BUFFER\n    formats AUDIO_FORMAT_PCM_16_BIT\n    sampling_rates 48000\n    bit_width 16\n    app_type 69936\n  }\n  direct {\n    flags AUDIO_OUTPUT_FLAG_DIRECT\n    formats AUDIO_FORMAT_PCM_16_BIT\n    sampling_rates 48000\n    bit_width 16\n    app_type 69936\n  }\n  direct_pcm {\n    flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_DIRECT_PCM\n    formats AUDIO_FORMAT_PCM_16_BIT\n    sampling_rates 48000\n    bit_width 16\n    app_type 69936\n  }\n  compress_offload_16 {\n    flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING\n    formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_AAC|AUDIO_FORMAT_AC3|AUDIO_FORMAT_EAC3|AUDIO_FORMAT_PCM_16_BIT_OFFLOAD|AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC\n    sampling_rates 48000\n    bit_width 16\n    app_type 69936\n  }\n  compress_offload_24 {\n    flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING\n    formats AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC\n    sampling_rates 48000|96000|192000\n    bit_width 24\n    app_type 69940\n  }\n}\n"
  },
  {
    "path": "audio/audio_platform_info.xml",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved.         -->\n<!--                                                                        -->\n<!-- Redistribution and use in source and binary forms, with or without     -->\n<!-- modification, are permitted provided that the following conditions are -->\n<!-- met:                                                                   -->\n<!--     * Redistributions of source code must retain the above copyright   -->\n<!--       notice, this list of conditions and the following disclaimer.    -->\n<!--     * Redistributions in binary form must reproduce the above          -->\n<!--       copyright notice, this list of conditions and the following      -->\n<!--       disclaimer in the documentation and/or other materials provided  -->\n<!--       with the distribution.                                           -->\n<!--     * Neither the name of The Linux Foundation nor the names of its    -->\n<!--       contributors may be used to endorse or promote products derived  -->\n<!--       from this software without specific prior written permission.    -->\n<!--                                                                        -->\n<!-- THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED           -->\n<!-- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF   -->\n<!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -->\n<!-- ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -->\n<!-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -->\n<!-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF   -->\n<!-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        -->\n<!-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  -->\n<!-- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -->\n<!-- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                          -->\n<audio_platform_info>\n    <acdb_ids>\n        <device name=\"SND_DEVICE_OUT_SPEAKER_PROTECTED\" acdb_id=\"124\"/>\n        <device name=\"SND_DEVICE_OUT_SPEAKER\" acdb_id=\"81\" />\n        <device name=\"SND_DEVICE_OUT_VOICE_SPEAKER\" acdb_id=\"15\" />\n        <device name=\"SND_DEVICE_OUT_HEADPHONES\" acdb_id=\"94\" />\n        <device name=\"SND_DEVICE_IN_HANDSET_MIC\" acdb_id=\"42\" />\n        <device name=\"SND_DEVICE_IN_CAMCORDER_MIC\" acdb_id=\"35\" />\n        <device name=\"SND_DEVICE_IN_VOICE_REC_MIC\" acdb_id=\"119\" />\n        <device name=\"SND_DEVICE_IN_VOICE_HEADSET_MIC\" acdb_id=\"23\" />\n    </acdb_ids>\n    <backend_names>\n        <device name=\"SND_DEVICE_OUT_SPEAKER\" backend=\"speaker\" />\n        <device name=\"SND_DEVICE_OUT_VOICE_SPEAKER\" backend=\"speaker\" />\n        <device name=\"SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES\" backend=\"speaker-and-headphones\" />\n    </backend_names>\n    <bit_width_configs>\n        <device name=\"SND_DEVICE_OUT_SPEAKER\" bit_width=\"24\"/>\n    </bit_width_configs>\n</audio_platform_info>\n"
  },
  {
    "path": "audio/audio_policy.conf",
    "content": "# Global configuration section:\n# - lists input and output devices always present on the device\n# as well as the output device selected by default.\n# Devices are designated by a string that corresponds to the enum in audio.h\n# - defines whether the speaker output path uses DRC\n# \"TRUE\" means DRC is enabled, \"FALSE\" or omission means DRC isn't used.\n\nglobal_configuration {\n  attached_output_devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_TELEPHONY_TX\n  default_output_device AUDIO_DEVICE_OUT_SPEAKER\n  attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_VOICE_CALL|AUDIO_DEVICE_IN_TELEPHONY_RX|AUDIO_DEVICE_IN_FM_TUNER\n  speaker_drc_enabled TRUE\n}\n\n# audio hardware module section: contains descriptors for all audio hw modules present on the\n# device. Each hw module node is named after the corresponding hw module library base name.\n# For instance, \"primary\" corresponds to audio.primary.<device>.so.\n# The \"primary\" module is mandatory and must include at least one output with\n# AUDIO_OUTPUT_FLAG_PRIMARY flag.\n# Each module descriptor contains one or more output profile descriptors and zero or more\n# input profile descriptors. Each profile lists all the parameters supported by a given output\n# or input stream category.\n# The \"channel_masks\", \"formats\", \"devices\" and \"flags\" are specified using strings corresponding\n# to enums in audio.h and audio_policy.h. They are concatenated by use of \"|\" without space or \"\\n\".\n\naudio_hw_modules {\n  primary {\n    outputs {\n      primary {\n        sampling_rates 44100|48000\n        channel_masks AUDIO_CHANNEL_OUT_STEREO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_PROXY|AUDIO_DEVICE_OUT_FM\n        flags AUDIO_OUTPUT_FLAG_PRIMARY|AUDIO_OUTPUT_FLAG_FAST\n      }\n      raw {\n        sampling_rates 48000\n        channel_masks AUDIO_CHANNEL_OUT_STEREO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL\n        flags AUDIO_OUTPUT_FLAG_FAST|AUDIO_OUTPUT_FLAG_RAW\n      }\n      deep_buffer {\n         sampling_rates 44100|48000\n         channel_masks AUDIO_CHANNEL_OUT_STEREO\n         formats AUDIO_FORMAT_PCM_16_BIT\n         devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_PROXY|AUDIO_DEVICE_OUT_FM\n         flags AUDIO_OUTPUT_FLAG_DEEP_BUFFER\n      }\n      multichannel {\n        sampling_rates 8000|11025|16000|22050|32000|44100|48000|64000|88200|96000|128000|176400|192000\n        channel_masks dynamic\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_PROXY\n        flags AUDIO_OUTPUT_FLAG_DIRECT\n      }\n      direct_pcm {\n        sampling_rates 8000|11025|16000|22050|32000|44100|48000|64000|88200|96000|176400|192000\n        channel_masks AUDIO_CHANNEL_OUT_MONO|AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_2POINT1|AUDIO_CHANNEL_OUT_QUAD|AUDIO_CHANNEL_OUT_PENTA|AUDIO_CHANNEL_OUT_5POINT1|AUDIO_CHANNEL_OUT_6POINT1|AUDIO_CHANNEL_OUT_7POINT1\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO\n        flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_DIRECT_PCM\n      }\n      compress_offload {\n        sampling_rates 8000|11025|12000|16000|22050|24000|32000|44100|48000|64000|88200|96000|176400|192000\n        channel_masks AUDIO_CHANNEL_OUT_MONO|AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_2POINT1|AUDIO_CHANNEL_OUT_QUAD|AUDIO_CHANNEL_OUT_PENTA|AUDIO_CHANNEL_OUT_5POINT1|AUDIO_CHANNEL_OUT_6POINT1|AUDIO_CHANNEL_OUT_7POINT1\n#ifndef VENDOR_EDIT\n#lifei@OnePlus.MultiMediaService, 2015/12/23,add MP2 offload playback\n        #formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_AC3|AUDIO_FORMAT_E_AC3|AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_AAC_LC|AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2\n#else\n        formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_AC3|AUDIO_FORMAT_E_AC3|AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_AAC_LC|AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2|AUDIO_FORMAT_MP2|AUDIO_FORMAT_AAC\n#endif/*VENDOR_EDIT*/\n        devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_PROXY\n        flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING\n      }\n      incall_music {\n        sampling_rates 8000|16000|48000\n        channel_masks AUDIO_CHANNEL_OUT_MONO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO\n        flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_INCALL_MUSIC\n      }\n      voice_tx {\n        sampling_rates 8000|16000|48000\n        channel_masks AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_MONO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_TELEPHONY_TX\n      }\n      voip_rx {\n        sampling_rates 8000|16000\n        channel_masks AUDIO_CHANNEL_OUT_MONO\n        formats AUDIO_FORMAT_PCM_16_BIT|AUDIO_FORMAT_AMR_NB|AUDIO_FORMAT_AMR_WB|AUDIO_FORMAT_QCELP|AUDIO_FORMAT_EVRC|AUDIO_FORMAT_EVRCB|AUDIO_FORMAT_EVRCWB|AUDIO_FORMAT_EVRCNW\n        devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO\n        flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_VOIP_RX\n      }\n    }\n    inputs {\n      primary {\n        sampling_rates 8000|11025|12000|16000|22050|24000|32000|44100|48000\n        channel_masks AUDIO_CHANNEL_IN_5POINT1|AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO|AUDIO_CHANNEL_IN_FRONT_BACK\n        formats AUDIO_FORMAT_PCM_16_BIT|AUDIO_FORMAT_AMR_NB|AUDIO_FORMAT_AMR_WB|AUDIO_FORMAT_QCELP|AUDIO_FORMAT_EVRC|AUDIO_FORMAT_EVRCB|AUDIO_FORMAT_EVRCWB|AUDIO_FORMAT_EVRCNW\n        devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_WIRED_HEADSET|AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_VOICE_CALL|AUDIO_DEVICE_IN_FM_TUNER\n      }\n      voice_rx {\n        sampling_rates 8000|16000|48000\n        channel_masks AUDIO_CHANNEL_IN_STEREO|AUDIO_CHANNEL_IN_MONO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_IN_TELEPHONY_RX\n      }\n    }\n  }\n  a2dp {\n    outputs {\n      a2dp {\n        sampling_rates 44100\n        channel_masks AUDIO_CHANNEL_OUT_STEREO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_ALL_A2DP\n      }\n    }\n  }\n  usb {\n    outputs {\n      usb_accessory {\n        sampling_rates 44100\n        channel_masks AUDIO_CHANNEL_OUT_STEREO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_USB_ACCESSORY\n      }\n      usb_device {\n        sampling_rates dynamic\n        channel_masks dynamic\n        formats dynamic\n        devices AUDIO_DEVICE_OUT_USB_DEVICE\n      }\n    }\n    inputs {\n      usb_device {\n        sampling_rates dynamic\n        channel_masks dynamic\n        formats dynamic\n        devices AUDIO_DEVICE_IN_USB_DEVICE\n      }\n    }\n  }\n  r_submix {\n    outputs {\n      submix {\n        sampling_rates 48000\n        channel_masks AUDIO_CHANNEL_OUT_STEREO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_OUT_REMOTE_SUBMIX\n      }\n    }\n    inputs {\n      submix {\n        sampling_rates 48000\n        channel_masks AUDIO_CHANNEL_IN_STEREO\n        formats AUDIO_FORMAT_PCM_16_BIT\n        devices AUDIO_DEVICE_IN_REMOTE_SUBMIX\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "audio/listen_platform_info.xml",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<!--- Copyright (c) 2014, The Linux Foundation. All rights reserved.            -->\n<!---                                                                           -->\n<!--- Redistribution and use in source and binary forms, with or without        -->\n<!--- modification, are permitted provided that the following conditions are    -->\n<!--- met:                                                                      -->\n<!---     * Redistributions of source code must retain the above copyright      -->\n<!---       notice, this list of conditions and the following disclaimer.       -->\n<!---     * Redistributions in binary form must reproduce the above             -->\n<!---       copyright notice, this list of conditions and the following         -->\n<!---       disclaimer in the documentation and/or other materials provided     -->\n<!---       with the distribution.                                              -->\n<!---     * Neither the name of The Linux Foundation nor the names of its       -->\n<!---       contributors may be used to endorse or promote products derived     -->\n<!---       from this software without specific prior written permission.       -->\n<!---                                                                           -->\n<!--- THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED              -->\n<!--- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF      -->\n<!--- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT    -->\n<!--- ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS    -->\n<!--- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    -->\n<!--- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      -->\n<!--- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR           -->\n<!--- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,     -->\n<!--- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE      -->\n<!--- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN    -->\n<!--- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                             -->\n<listen_platform_info>\n    <device name=\"DEVICE_HANDSET_APE_ACDB_ID\" acdb_id=\"100\" />\n    <device name=\"DEVICE_HANDSET_CPE_ACDB_ID\" acdb_id=\"128\" />\n    <ctrl name=\"execution_type\" value=\"CPE\" /> <!-- value: \"CPE\" \"APE\" -->\n    <ctrl name=\"max_cpe_sessions\" value=\"1\" />\n    <ctrl name=\"max_cpe_keywords\" value=\"6\" />\n    <ctrl name=\"max_cpe_kw_user_pairs\" value=\"6\" />\n    <ctrl name=\"max_ape_sessions\" value=\"8\" />\n    <ctrl name=\"max_ape_keywords\" value=\"10\" />\n    <ctrl name=\"max_ape_kw_user_pairs\" value=\"10\" />\n</listen_platform_info>\n\n"
  },
  {
    "path": "audio/mixer_paths.xml",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<mixer>\n    <!-- These are the initial mixer settings -->\n    <ctl name=\"Voice Rx Device Mute\" id=\"0\" value=\"0\" />\n    <ctl name=\"Voice Rx Device Mute\" id=\"1\" value=\"-1\" />\n    <ctl name=\"Voice Rx Device Mute\" id=\"2\" value=\"20\" />\n    <ctl name=\"Voice Tx Mute\" id=\"0\" value=\"0\" />\n    <ctl name=\"Voice Tx Mute\" id=\"1\" value=\"-1\" />\n    <ctl name=\"Voice Tx Mute\" id=\"2\" value=\"500\" />\n    <ctl name=\"Voice Rx Gain\" id=\"0\" value=\"0\" />\n    <ctl name=\"Voice Rx Gain\" id=\"1\" value=\"-1\" />\n    <ctl name=\"Voice Rx Gain\" id=\"2\" value=\"20\" />\n    <ctl name=\"Voip Tx Mute\" id=\"0\" value=\"0\" />\n    <ctl name=\"Voip Tx Mute\" id=\"1\" value=\"500\" />\n    <ctl name=\"Voip Rx Gain\" id=\"0\" value=\"0\" />\n    <ctl name=\"Voip Rx Gain\" id=\"1\" value=\"20\" />\n    <ctl name=\"Voip Mode Config\" value=\"12\" />\n    <ctl name=\"Voip Rate Config\" value=\"0\" />\n    <ctl name=\"Voip Evrc Min Max Rate Config\" id=\"0\" value=\"1\" />\n    <ctl name=\"Voip Evrc Min Max Rate Config\" id=\"1\" value=\"4\" />\n    <ctl name=\"Voip Dtx Mode\" value=\"0\" />\n    <ctl name=\"TTY Mode\" value=\"OFF\" />\n    <ctl name=\"LINEOUT1 Volume\" value=\"13\" />\n    <ctl name=\"LINEOUT2 Volume\" value=\"13\" />\n    <ctl name=\"LINEOUT3 Volume\" value=\"13\" />\n    <ctl name=\"LINEOUT4 Volume\" value=\"13\" />\n    <ctl name=\"HPHL Volume\" value=\"20\" />\n    <ctl name=\"HPHR Volume\" value=\"20\" />\n    <ctl name=\"RX1 Digital Volume\" value=\"84\" />\n    <ctl name=\"RX2 Digital Volume\" value=\"84\" />\n    <ctl name=\"RX3 Digital Volume\" value=\"84\" />\n    <ctl name=\"RX4 Digital Volume\" value=\"84\" />\n    <ctl name=\"RX5 Digital Volume\" value=\"84\" />\n    <ctl name=\"RX6 Digital Volume\" value=\"84\" />\n    <ctl name=\"RX7 Digital Volume\" value=\"84\" />\n    <ctl name=\"RX8 Digital Volume\" value=\"84\" />\n    <ctl name=\"ADC1 Volume\" value=\"19\" />\n    <ctl name=\"ADC2 Volume\" value=\"19\" />\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/3,change to pass test for qualcomm advise  -->    \n    <ctl name=\"ADC3 Volume\" value=\"14\" />\n    <ctl name=\"ADC4 Volume\" value=\"14\" />\n    <!-- #endif VENDOR_EDIT-->\n    <ctl name=\"ADC5 Volume\" value=\"19\" />\n    <ctl name=\"ADC6 Volume\" value=\"19\" />\n    <ctl name=\"DEC1 Volume\" value=\"84\" />\n    <ctl name=\"DEC2 Volume\" value=\"84\" />\n    <ctl name=\"DEC3 Volume\" value=\"84\" />\n    <ctl name=\"DEC4 Volume\" value=\"84\" />\n    <ctl name=\"DEC5 Volume\" value=\"84\" />\n    <ctl name=\"DEC6 Volume\" value=\"84\" />\n    <ctl name=\"DEC7 Volume\" value=\"84\" />\n    <ctl name=\"DEC8 Volume\" value=\"84\" />\n    <ctl name=\"DEC9 Volume\" value=\"84\" />\n    <ctl name=\"DEC10 Volume\" value=\"84\" />\n    <ctl name=\"COMP0 Switch\" value=\"0\" />\n    <ctl name=\"COMP1 Switch\" value=\"0\" />\n    <ctl name=\"COMP2 Switch\" value=\"0\" />\n    <ctl name=\"SLIMBUS_3_RX Port Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"HDMI_RX Port Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Port Mixer SLIM_0_TX\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia1\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia5\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia6\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia7\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia10\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia11\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia12\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia13\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia14\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia15\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia16\" value=\"0\" />\n    <ctl name=\"SLIMBUS_4_RX Audio Mixer MultiMedia1\" value=\"0\" />\n    <ctl name=\"SLIMBUS_4_RX Audio Mixer MultiMedia2\" value=\"0\" />\n    <ctl name=\"MultiMedia5 Mixer SLIM_0_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia5 Mixer AFE_PCM_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia4 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia7 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia10 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia11 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia12 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia13 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia14 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia15 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia16 Mixer MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer SLIM_0_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer SLIM_4_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer SEC_AUX_PCM_UL_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia3 Mixer SLIM_0_TX\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia1\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia2\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia3\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia5\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia7\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia10\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia11\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia12\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia13\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia14\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia15\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia16\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia1\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia2\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia3\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia5\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia7\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia10\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia11\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia12\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia13\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia14\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia15\" value=\"0\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia16\" value=\"0\" />\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/7/8,reset values  -->\n    <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia1\" value=\"0\" />\n    <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia5\" value=\"0\" />\n    <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia7\" value=\"0\" />\n    <!-- #endif VENDOR_EDIT-->\n\n    <ctl name=\"MultiMedia6 Mixer SLIM_0_TX\" value=\"0\" />\n    <ctl name=\"IIR1 INP1 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM0_RX_VI_FB_LCH_MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM0_RX_VI_FB_RCH_MUX\" value=\"ZERO\" />\n    <ctl name=\"VI_FEED_TX Channels\" value=\"Two\" />\n    <ctl name=\"AIF4_VI Mixer SPKR_VI_1\" value=\"0\" />\n    <ctl name=\"AIF4_VI Mixer SPKR_VI_2\" value=\"0\" />\n    <ctl name=\"SLIM TX10 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX9 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX8 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX7 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX6 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX5 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX4 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX3 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX2 MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIM TX1 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC10 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC9 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC8 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC7 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC6 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC5 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC4 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC3 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC2 MUX\" value=\"ZERO\" />\n    <ctl name=\"DEC1 MUX\" value=\"ZERO\" />\n    <ctl name=\"RX2 MIX2 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX2 MIX2 INP1\" value=\"ZERO\" />\n    <ctl name=\"RX1 MIX2 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX1 MIX2 INP1\" value=\"ZERO\" />\n    <ctl name=\"RX7 MIX1 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX7 MIX1 INP1\" value=\"ZERO\" />\n    <ctl name=\"RX6 MIX1 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX6 MIX1 INP1\" value=\"ZERO\" />\n    <ctl name=\"RX5 MIX1 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX5 MIX1 INP1\" value=\"ZERO\" />\n    <ctl name=\"RX4 MIX1 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX4 MIX1 INP1\" value=\"ZERO\" />\n    <ctl name=\"RX3 MIX1 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX3 MIX1 INP1\" value=\"ZERO\" />\n    <ctl name=\"RX2 MIX1 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX2 MIX1 INP1\" value=\"ZERO\" />\n    <ctl name=\"RX1 MIX1 INP3\" value=\"ZERO\" />\n    <ctl name=\"RX1 MIX1 INP2\" value=\"ZERO\" />\n    <ctl name=\"RX1 MIX1 INP1\" value=\"ZERO\" />\n    <ctl name=\"HPHL DAC Switch\" value=\"0\" />\n    <ctl name=\"DAC1 Switch\" value=\"0\" />\n    <ctl name=\"SLIM_0_RX Channels\" value=\"One\" />\n    <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n    <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n    <ctl name=\"EAR PA Gain\" value=\"POS_6_DB\" />\n    <ctl name=\"SLIM RX2 MUX\" value=\"ZERO\" />\n    <ctl name=\"SPK DRV Volume\" value=\"8\" />\n    <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"0\" />\n    <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"0\"/>\n    <ctl name=\"CLASS_H_DSM MUX\" value=\"ZERO\" />\n    <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"PRI_MI2S_RX Audio Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"HDMI Mixer MultiMedia4\" value=\"0\" />\n    <!-- echo reference -->\n    <ctl name=\"AUDIO_REF_EC_UL1 MUX\" value=\"None\" />\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/7/8,reset values  -->\n     <ctl name=\"AUDIO_REF_EC_UL5 MUX\" value=\"None\" />\n    <!-- #endif VENDOR_EDIT-->\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/7/25,reset values  -->\n     <ctl name=\"VOC_EXT_EC MUX\" value=\"NONE\" />\n    <!-- #endif VENDOR_EDIT-->\n\n    <!-- usb headset -->\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia1\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia7\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia10\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia11\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia12\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia13\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia14\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia15\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia16\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer AFE_PCM_TX\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia5\" value=\"0\" />\n    <!-- usb headset end -->\n    <!-- fm -->\n    <ctl name=\"SLIMBUS_0_RX Port Mixer PRI_MI2S_TX\" value=\"0\" />\n    <ctl name=\"SLIMBUS_DL_HL Switch\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer PRI_MI2S_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia2 Mixer PRI_MI2S_TX\" value=\"0\" />\n    <!-- fm end -->\n\n    <!-- Voice -->\n    <ctl name=\"SLIM_0_RX_Voice Mixer CSVoice\" value=\"0\" />\n    <ctl name=\"Voice_Tx Mixer SLIM_0_TX_Voice\" value=\"0\" />\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/7/8,reset values  -->\n    <ctl name=\"QUAT_MI2S_RX_Voice Mixer CSVoice\" value=\"0\" />\n    <!-- #endif VENDOR_EDIT-->\n\n    <!-- Voice HDMI -->\n    <ctl name=\"HDMI_RX_Voice Mixer CSVoice\" value=\"0\" />\n    <!-- Voice BTSCO -->\n    <ctl name=\"AUX PCM SampleRate\" value=\"8000\" />\n    <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer CSVoice\" value=\"0\" />\n    <ctl name=\"Voice_Tx Mixer SEC_AUX_PCM_TX_Voice\" value=\"0\" />\n    <!-- Voice USB headset -->\n    <ctl name=\"AFE_PCM_RX_Voice Mixer CSVoice\" value=\"0\" />\n    <ctl name=\"Voice_Tx Mixer AFE_PCM_TX_Voice\" value=\"0\" />\n    <!-- Voice end-->\n\n    <!-- Voice2 -->\n    <ctl name=\"SLIM_0_RX_Voice Mixer Voice2\" value=\"0\" />\n    <ctl name=\"Voice2_Tx Mixer SLIM_0_TX_Voice2\" value=\"0\" />\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/7/8,reset values  -->\n    <ctl name=\"QUAT_MI2S_RX_Voice Mixer Voice2\" value=\"0\" />\n    <!-- #endif VENDOR_EDIT-->\n\n    <!-- Voice2 HDMI -->\n    <ctl name=\"HDMI_RX_Voice Mixer Voice2\" value=\"0\" />\n    <!-- Voice2 BTSCO -->\n    <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer Voice2\" value=\"0\" />\n    <ctl name=\"Voice2_Tx Mixer SEC_AUX_PCM_TX_Voice2\" value=\"0\" />\n    <!-- Voice2 USB headset -->\n    <ctl name=\"AFE_PCM_RX_Voice Mixer Voice2\" value=\"0\" />\n    <ctl name=\"Voice2_Tx Mixer AFE_PCM_TX_Voice2\" value=\"0\" />\n    <!-- Voice2 end-->\n\n    <!-- VoLTE -->\n    <ctl name=\"SLIM_0_RX_Voice Mixer VoLTE\" value=\"0\" />\n    <ctl name=\"VoLTE_Tx Mixer SLIM_0_TX_VoLTE\" value=\"0\" />\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/7/8,reset values  -->\n    <ctl name=\"QUAT_MI2S_RX_Voice Mixer VoLTE\" value=\"0\" />\n    <!-- #endif VENDOR_EDIT-->\n\n    <!-- VoLTE HDMI -->\n    <ctl name=\"HDMI_RX_Voice Mixer VoLTE\" value=\"0\" />\n    <!-- VoLTE BTSCO -->\n    <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer VoLTE\" value=\"0\" />\n    <ctl name=\"VoLTE_Tx Mixer SEC_AUX_PCM_TX_VoLTE\" value=\"0\" />\n    <!-- VoLTE USB headset -->\n    <ctl name=\"AFE_PCM_RX_Voice Mixer VoLTE\" value=\"0\" />\n    <ctl name=\"VoLTE_Tx Mixer AFE_PCM_TX_VoLTE\" value=\"0\" />\n    <!-- VoLTE end-->\n\n    <!-- Incall Recording -->\n    <ctl name=\"MultiMedia1 Mixer VOC_REC_UL\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer VOC_REC_DL\" value=\"0\" />\n    <ctl name=\"MultiMedia8 Mixer VOC_REC_UL\" value=\"0\" />\n    <ctl name=\"MultiMedia8 Mixer VOC_REC_DL\" value=\"0\" />\n    <!-- Incall Recording End -->\n\n    <!-- Incall Music -->\n    <ctl name=\"Incall_Music Audio Mixer MultiMedia2\" value=\"0\" />\n    <ctl name=\"Incall_Music_2 Audio Mixer MultiMedia9\" value=\"0\" />\n    <!-- Incall Music End -->\n\n    <!-- compress-voip-call start -->\n    <ctl name=\"SLIM_0_RX_Voice Mixer Voip\" value=\"0\" />\n    <ctl name=\"Voip_Tx Mixer SLIM_0_TX_Voip\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer Voip\" value=\"0\" />\n    <ctl name=\"Voip_Tx Mixer SEC_AUX_PCM_TX_Voip\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX_Voice Mixer Voip\" value=\"0\" />\n    <ctl name=\"Voip_Tx Mixer AFE_PCM_TX_Voip\" value=\"0\" />\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/7/8,reset values  -->\n    <ctl name=\"QUAT_MI2S_RX_Voice Mixer Voip\" value=\"0\" />\n    <!-- #endif VENDOR_EDIT-->\n\n    <!-- compress-voip-call end-->\n\n    <!-- QCHAT start -->\n    <ctl name=\"SLIM_0_RX_Voice Mixer QCHAT\" value=\"0\" />\n    <ctl name=\"QCHAT_Tx Mixer SLIM_0_TX_QCHAT\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer QCHAT\" value=\"0\" />\n    <ctl name=\"QCHAT_Tx Mixer SEC_AUX_PCM_TX_QCHAT\" value=\"0\" />\n    <!-- QCHAT end-->\n\n    <!-- VoWLAN start -->\n    <ctl name=\"SLIM_0_RX_Voice Mixer VoWLAN\" value=\"0\" />\n    <ctl name=\"VoWLAN_Tx Mixer SLIM_0_TX_VoWLAN\" value=\"0\" />\n    <ctl name=\"HDMI_RX_Voice Mixer VoWLAN\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer VoWLAN\" value=\"0\" />\n    <ctl name=\"VoWLAN_Tx Mixer SEC_AUX_PCM_TX_VoWLAN\" value=\"0\" />\n    <ctl name=\"AFE_PCM_RX_Voice Mixer VoWLAN\" value=\"0\" />\n    <ctl name=\"VoWLAN_Tx Mixer AFE_PCM_TX_VoWLAN\" value=\"0\" />\n    <!-- VoWLAN end-->\n\n    <!-- Audio BTSCO -->\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia1\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia4\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia5\" value=\"0\" />\n    <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia6\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer SEC_AUX_PCM_UL_TX\" value=\"0\" />\n    <!-- anc headset -->\n    <!-- speaker anc combo -->\n    <ctl name=\"RX4 DSM MUX\" value=\"CIC_OUT\" />\n    <ctl name=\"RX6 DSM MUX\" value=\"CIC_OUT\" />\n    <!-- speaker anc combo end -->\n    <!-- IIR/voice anc -->\n    <ctl name=\"IIR1 Band1\" id =\"0\" value=\"268435456\" />\n    <ctl name=\"IIR1 Band1\" id =\"1\" value=\"0\" />\n    <ctl name=\"IIR1 Band1\" id =\"2\" value=\"0\" />\n    <ctl name=\"IIR1 Band1\" id =\"3\" value=\"0\" />\n    <ctl name=\"IIR1 Band1\" id =\"4\" value=\"0\" />\n    <ctl name=\"IIR1 Band2\" id =\"0\" value=\"268435456\" />\n    <ctl name=\"IIR1 Band2\" id =\"1\" value=\"0\" />\n    <ctl name=\"IIR1 Band2\" id =\"2\" value=\"0\" />\n    <ctl name=\"IIR1 Band2\" id =\"3\" value=\"0\" />\n    <ctl name=\"IIR1 Band2\" id =\"4\" value=\"0\" />\n    <ctl name=\"IIR1 Band3\" id =\"0\" value=\"268435456\" />\n    <ctl name=\"IIR1 Band3\" id =\"1\" value=\"0\" />\n    <ctl name=\"IIR1 Band3\" id =\"2\" value=\"0\" />\n    <ctl name=\"IIR1 Band3\" id =\"3\" value=\"0\" />\n    <ctl name=\"IIR1 Band3\" id =\"4\" value=\"0\" />\n    <ctl name=\"IIR1 Band4\" id =\"0\" value=\"268435456\" />\n    <ctl name=\"IIR1 Band4\" id =\"1\" value=\"0\" />\n    <ctl name=\"IIR1 Band4\" id =\"2\" value=\"0\" />\n    <ctl name=\"IIR1 Band4\" id =\"3\" value=\"0\" />\n    <ctl name=\"IIR1 Band4\" id =\"4\" value=\"0\" />\n    <ctl name=\"IIR1 Band5\" id =\"0\" value=\"268435456\" />\n    <ctl name=\"IIR1 Band5\" id =\"1\" value=\"0\" />\n    <ctl name=\"IIR1 Band5\" id =\"2\" value=\"0\" />\n    <ctl name=\"IIR1 Band5\" id =\"3\" value=\"0\" />\n    <ctl name=\"IIR1 Band5\" id =\"4\" value=\"0\" />\n    <ctl name=\"IIR1 Enable Band1\" value=\"0\" />\n    <ctl name=\"IIR1 Enable Band2\" value=\"0\" />\n    <ctl name=\"IIR1 Enable Band3\" value=\"0\" />\n    <ctl name=\"IIR1 Enable Band4\" value=\"0\" />\n    <ctl name=\"IIR1 Enable Band5\" value=\"0\" />\n    <ctl name=\"IIR1 INP1 Volume\" value=\"54\" />\n    <!-- IIR/voice anc end -->\n    <!-- anc handset -->\n    <ctl name=\"ANC Slot\" value=\"0\" />\n    <ctl name=\"ANC1 FB MUX\" value=\"ZERO\" />\n    <!-- anc handset end -->\n    <ctl name=\"ANC1 MUX\" value=\"ZERO\" />\n    <ctl name=\"ANC2 MUX\" value=\"ZERO\" />\n    <ctl name=\"ANC Function\" value=\"OFF\" />\n    <!-- anc headset end-->\n    <!-- aanc handset mic -->\n    <ctl name=\"AIF1_CAP Mixer SLIM TX9\" value=\"0\" />\n    <ctl name=\"AANC_SLIM_0_RX MUX\" value=\"ZERO\" />\n    <!-- aanc handset mic end -->\n    <!-- ssr qmic -->\n    <ctl name=\"AIF1_CAP Mixer SLIM TX10\" value=\"0\" />\n    <!-- ssr qmic end-->\n    <!-- audio record compress-->\n    <ctl name=\"MultiMedia8 Mixer SLIM_0_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia1 Mixer SEC_AUX_PCM_UL_TX\" value=\"0\" />\n    <ctl name=\"MultiMedia8 Mixer AFE_PCM_TX\" value=\"0\" />\n    <!-- audio record compress end-->\n    <!-- listen -->\n    <ctl name=\"LSM1 MUX\" value=\"None\" />\n    <ctl name=\"LSM2 MUX\" value=\"None\" />\n    <ctl name=\"LSM3 MUX\" value=\"None\" />\n    <ctl name=\"LSM4 MUX\" value=\"None\" />\n    <ctl name=\"LSM5 MUX\" value=\"None\" />\n    <ctl name=\"LSM6 MUX\" value=\"None\" />\n    <ctl name=\"LSM7 MUX\" value=\"None\" />\n    <ctl name=\"LSM8 MUX\" value=\"None\" />\n    <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"None\" />\n    <ctl name=\"MADONOFF Switch\" value=\"0\" />\n    <ctl name=\"MAD Input\" value=\"DMIC1\" />\n    <!-- listen end-->\n    <!-- afe-proxy -->\n    <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia2\" value=\"0\" />\n    <!-- afe-proxy end-->\n    <ctl name=\"AFE_PCM_RX Port Mixer PRI_MI2S_TX\" value=\"0\" />\n\n    <!-- surround sound record -->\n    <ctl name=\"Input Num Channel\" value=\"0\" />\n    <ctl name=\"Output Num Channel\" value=\"0\" />\n    <ctl name=\"Out Channel1\" id=\"0\" value=\"0\" />\n    <ctl name=\"Out Channel1\" id=\"1\" value=\"0\" />\n    <ctl name=\"Out Channel1\" id=\"2\" value=\"0\" />\n    <ctl name=\"Out Channel2\" id=\"0\" value=\"0\" />\n    <ctl name=\"Out Channel2\" id=\"1\" value=\"0\" />\n    <ctl name=\"Out Channel2\" id=\"2\" value=\"0\" />\n    <ctl name=\"Out Channel3\" id=\"0\" value=\"0\" />\n    <ctl name=\"Out Channel3\" id=\"1\" value=\"0\" />\n    <ctl name=\"Out Channel3\" id=\"2\" value=\"0\" />\n    <ctl name=\"Out Channel4\" id=\"0\" value=\"0\" />\n    <ctl name=\"Out Channel4\" id=\"1\" value=\"0\" />\n    <ctl name=\"Out Channel4\" id=\"2\" value=\"0\" />\n    <!-- surround sound record end -->\n\n    <!-- ADSP testfwk -->\n    <ctl name=\"SLIMBUS_DL_HL Switch\" value=\"0\" />\n    <!-- ADSP testfwk end-->\n    \n    <!-- tfa98xx -->\n    \t<ctl name=\"left Profile\" value=\"0\"/>\n    <!-- tfa98xx end-->\n \n    <!-- These are audio route (FE to BE) specific mixer settings -->\n    <path name=\"deep-buffer-playback\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia1\" value=\"1\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv 2015-03-05 These are audio route (FE to BE) specific mixer settings  -->\n    <path name=\"deep-buffer-playback speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia1\" value=\"1\" />\n    </path>\n    <!-- #ENDIF VENDOR_EDIT-->\n    \n    <!--wangdongdong@MultiMedia.AudioDrv,2015-03-30,add for speaker and headphone play ring-->\n    <path name=\"deep-buffer-playback speaker-and-headphones\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia1\" value=\"1\" />\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia1\" value=\"1\" />\n    </path>\n    \n    <path name=\"deep-buffer-playback speaker-protected\">\n        <path name=\"deep-buffer-playback\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/28,changed for EC ref -->\n    <path name=\"echo-reference-skype\">\n        <ctl name=\"AUDIO_REF_EC_UL5 MUX\" value=\"QUAT_MI2S_TX\" />\n    </path>\n\n    <path name=\"echo-reference\">\n        <ctl name=\"AUDIO_REF_EC_UL1 MUX\" value=\"QUAT_MI2S_TX\" />\n    </path>\n   <!-- #endif VENDOR_EDIT-->\n\n\n\n    <path name=\"deep-buffer-playback hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia1\" value=\"1\" />\n    </path>\n\n    <path name=\"deep-buffer-playback speaker-and-hdmi\">\n        <path name=\"deep-buffer-playback hdmi\" />\n        <path name=\"deep-buffer-playback\" />\n    </path>\n\n    <path name=\"deep-buffer-playback bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia1\" value=\"1\" />\n    </path>\n\n    <path name=\"deep-buffer-playback bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"deep-buffer-playback bt-sco\" />\n    </path>\n\n    <path name=\"deep-buffer-playback afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia1\" value=\"1\" />\n    </path>\n\n    <path name=\"deep-buffer-playback usb-headphones\">\n        <path name=\"deep-buffer-playback afe-proxy\" />\n    </path>\n\n    <path name=\"deep-buffer-playback speaker-and-usb-headphones\">\n        <path name=\"deep-buffer-playback usb-headphones\" />\n        <path name=\"deep-buffer-playback\" />\n    </path>\n\n    <path name=\"low-latency-playback\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia5\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv 2015-03-05 These are audio route (FE to BE) specific mixer settings  -->\n    <path name=\"low-latency-playback speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia5\" value=\"1\" />\n    </path>\n    <!-- #ENDIF EVNDOR_EDIT -->\n    \n    <!--wangdongdong@MultiMedia.AudioDrv,2015-03-30,add for speaker and headphone play ring-->\n    <path name=\"low-latency-playback speaker-and-headphones\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia5\" value=\"1\" />\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia5\" value=\"1\" />\n    </path>\n\n    \n    <path name=\"low-latency-playback speaker-protected\">\n        <path name=\"low-latency-playback\" />\n    </path>\n\n    <path name=\"low-latency-playback hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia5\" value=\"1\" />\n    </path>\n\n    <path name=\"low-latency-playback bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia5\" value=\"1\" />\n    </path>\n\n    <path name=\"low-latency-playback bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"low-latency-playback bt-sco\" />\n    </path>\n\n    <path name=\"low-latency-playback speaker-and-hdmi\">\n        <path name=\"low-latency-playback hdmi\" />\n        <path name=\"low-latency-playback\" />\n    </path>\n\n    <path name=\"low-latency-playback afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia5\" value=\"1\" />\n    </path>\n\n    <path name=\"low-latency-playback usb-headphones\">\n        <path name=\"low-latency-playback afe-proxy\" />\n    </path>\n\n    <path name=\"low-latency-playback speaker-and-usb-headphones\">\n        <path name=\"low-latency-playback usb-headphones\" />\n        <path name=\"low-latency-playback\" />\n    </path>\n\n    <path name=\"audio-ull-playback\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia3\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n<!-- lifei@MultiMedia.AudioDrv 2015-12-22 These are audio route (FE to BE) specific mixer settings  -->\n    <path name=\"audio-ull-playback speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia3\" value=\"1\" />\n    </path>\n<!-- #ENDIF EVNDOR_EDIT -->\n\n    <path name=\"audio-ull-playback speaker-protected\">\n        <path name=\"audio-ull-playback\" />\n    </path>\n\n    <path name=\"audio-ull-playback headphones\">\n      <path name=\"audio-ull-playback\" />\n    </path>\n\n    <path name=\"audio-ull-playback speaker-and-headphones\">\n        <path name=\"audio-ull-playback\" />\n        <path name=\"audio-ull-playback headphones\" />\n    </path>\n\n    <path name=\"audio-ull-playback hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia3\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-ull-playback bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia3\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-ull-playback bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"audio-ull-playback bt-sco\" />\n    </path>\n\n    <path name=\"audio-ull-playback speaker-and-hdmi\">\n        <path name=\"audio-ull-playback hdmi\" />\n        <path name=\"audio-ull-playback\" />\n    </path>\n\n    <path name=\"audio-ull-playback afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia3\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-ull-playback usb-headphones\">\n        <path name=\"audio-ull-playback afe-proxy\" />\n    </path>\n\n    <path name=\"audio-ull-playback speaker-and-usb-headphones\">\n        <path name=\"audio-ull-playback usb-headphones\" />\n        <path name=\"audio-ull-playback\" />\n    </path>\n\n    <path name=\"multi-channel-playback hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia2\" value=\"1\" />\n    </path>\n\n    <path name=\"multi-channel-playback afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia2\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia4\" value=\"1\" />\n    </path>    \n    \n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv 2015-03-05 These are audio route (FE to BE) specific mixer settings  -->    \n    <path name=\"compress-offload-playback speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia4\" value=\"1\" />\n    </path>\n     <!-- #ENDIF EVNDOR_EDIT -->\n     \n    <path name=\"compress-offload-playback speaker-protected\">\n        <path name=\"compress-offload-playback\" />\n    </path>\n\n    <path name=\"compress-offload-playback hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia4\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia4\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback speaker-and-hdmi\">\n        <path name=\"compress-offload-playback hdmi\" />\n        <path name=\"compress-offload-playback\" />\n    </path>\n\n    <path name=\"compress-offload-playback afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia4\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback usb-headphones\">\n        <path name=\"compress-offload-playback afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback usb-headphones\" />\n        <path name=\"compress-offload-playback\" />\n    </path>\n\n    <path name=\"compress-offload-playback2\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia7\" value=\"1\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv 2015-04-08 PA output for network video playback  --> \n    <path name=\"compress-offload-playback2 speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia7\" value=\"1\" />\n    </path>\n     <!-- #ENDIF EVNDOR_EDIT -->\n     \n    <path name=\"compress-offload-playback2 hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia7\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback2 bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia7\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback2 bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback2 bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback2 speaker-and-hdmi\">\n        <path name=\"compress-offload-playback2 hdmi\" />\n        <path name=\"compress-offload-playback2\" />\n    </path>\n\n    <path name=\"compress-offload-playback2 afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia7\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback2 usb-headphones\">\n        <path name=\"compress-offload-playback2 afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback2 speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback2 usb-headphones\" />\n        <path name=\"compress-offload-playback2\" />\n    </path>\n\n    <path name=\"compress-offload-playback3\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia10\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n<!-- lifei@MultiMedia.AudioDrv 2015-07.15 PA output for network video playback  --> \n    <path name=\"compress-offload-playback3 speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia10\" value=\"1\" />\n    </path>\n<!-- #ENDIF EVNDOR_EDIT -->\n\n    <path name=\"compress-offload-playback3 hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia10\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback3 bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia10\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback3 bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback3 bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback3 speaker-and-hdmi\">\n        <path name=\"compress-offload-playback3 hdmi\" />\n        <path name=\"compress-offload-playback3\" />\n    </path>\n\n    <path name=\"compress-offload-playback3 afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia10\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback3 usb-headphones\">\n        <path name=\"compress-offload-playback3 afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback3 speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback3 usb-headphones\" />\n        <path name=\"compress-offload-playback3\" />\n    </path>\n\n    <path name=\"compress-offload-playback4\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia11\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n<!-- lifei@MultiMedia.AudioDrv 2015-07.15 PA output for network video playback  --> \n    <path name=\"compress-offload-playback4 speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia11\" value=\"1\" />\n    </path>\n<!-- #ENDIF EVNDOR_EDIT -->\n\n    <path name=\"compress-offload-playback4 hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia11\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback4 bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia11\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback4 bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback4 bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback4 speaker-and-hdmi\">\n        <path name=\"compress-offload-playback4 hdmi\" />\n        <path name=\"compress-offload-playback4\" />\n    </path>\n\n    <path name=\"compress-offload-playback4 afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia11\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback4 usb-headphones\">\n        <path name=\"compress-offload-playback4 afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback4 speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback4 usb-headphones\" />\n        <path name=\"compress-offload-playback4\" />\n    </path>\n\n    <path name=\"compress-offload-playback5\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia12\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n<!-- lifei@MultiMedia.AudioDrv 2015-07.15 PA output for network video playback  --> \n    <path name=\"compress-offload-playback5 speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia12\" value=\"1\" />\n    </path>\n<!-- #ENDIF EVNDOR_EDIT -->\n\n    <path name=\"compress-offload-playback5 hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia12\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback5 bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia12\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback5 bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback5 bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback5 speaker-and-hdmi\">\n        <path name=\"compress-offload-playback5 hdmi\" />\n        <path name=\"compress-offload-playback5\" />\n    </path>\n\n    <path name=\"compress-offload-playback5 afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia12\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback5 usb-headphones\">\n        <path name=\"compress-offload-playback5 afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback5 speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback5 usb-headphones\" />\n        <path name=\"compress-offload-playback5\" />\n    </path>\n\n    <path name=\"compress-offload-playback6\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia13\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n<!-- lifei@MultiMedia.AudioDrv 2015-07.15 PA output for network video playback  --> \n    <path name=\"compress-offload-playback6 speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia13\" value=\"1\" />\n    </path>\n<!-- #ENDIF EVNDOR_EDIT -->\n\n    <path name=\"compress-offload-playback6 hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia13\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback6 bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia13\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback6 bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback6 bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback6 speaker-and-hdmi\">\n        <path name=\"compress-offload-playback6 hdmi\" />\n        <path name=\"compress-offload-playback6\" />\n    </path>\n\n    <path name=\"compress-offload-playback6 afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia13\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback6 usb-headphones\">\n        <path name=\"compress-offload-playback6 afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback6 speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback6 usb-headphones\" />\n        <path name=\"compress-offload-playback6\" />\n    </path>\n\n    <path name=\"compress-offload-playback7\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia14\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n<!-- lifei@MultiMedia.AudioDrv 2015-07.15 PA output for network video playback  --> \n    <path name=\"compress-offload-playback7 speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia14\" value=\"1\" />\n    </path>\n<!-- #ENDIF EVNDOR_EDIT -->\n\n    <path name=\"compress-offload-playback7 hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia14\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback7 bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia14\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback7 bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback7 bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback7 speaker-and-hdmi\">\n        <path name=\"compress-offload-playback7 hdmi\" />\n        <path name=\"compress-offload-playback7\" />\n    </path>\n\n    <path name=\"compress-offload-playback7 afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia14\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback7 usb-headphones\">\n        <path name=\"compress-offload-playback7 afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback7 speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback7 usb-headphones\" />\n        <path name=\"compress-offload-playback7\" />\n    </path>\n\n    <path name=\"compress-offload-playback8\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia15\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n<!-- lifei@MultiMedia.AudioDrv 2015-07.15 PA output for network video playback  --> \n    <path name=\"compress-offload-playback8 speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia15\" value=\"1\" />\n    </path>\n<!-- #ENDIF EVNDOR_EDIT -->\n\n    <path name=\"compress-offload-playback8 hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia15\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback8 bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia15\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback8 bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback8 bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback8 speaker-and-hdmi\">\n        <path name=\"compress-offload-playback8 hdmi\" />\n        <path name=\"compress-offload-playback8\" />\n    </path>\n\n    <path name=\"compress-offload-playback8 afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia15\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback8 usb-headphones\">\n        <path name=\"compress-offload-playback8 afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback8 speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback8 usb-headphones\" />\n        <path name=\"compress-offload-playback8\" />\n    </path>\n\n    <path name=\"compress-offload-playback9\">\n        <ctl name=\"SLIMBUS_0_RX Audio Mixer MultiMedia16\" value=\"1\" />\n    </path>\n\n<!-- #ifdef VENDOR_EDIT-->\n<!-- lifei@MultiMedia.AudioDrv 2015-07.15 PA output for network video playback  --> \n    <path name=\"compress-offload-playback9 speaker\">\n        <ctl name=\"QUAT_MI2S_RX Audio Mixer MultiMedia16\" value=\"1\" />\n    </path>\n<!-- #ENDIF EVNDOR_EDIT -->\n\n    <path name=\"compress-offload-playback9 hdmi\">\n        <ctl name=\"HDMI Mixer MultiMedia16\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback9 bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia16\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback9 bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-offload-playback9 bt-sco\" />\n    </path>\n\n    <path name=\"compress-offload-playback9 speaker-and-hdmi\">\n        <path name=\"compress-offload-playback9 hdmi\" />\n        <path name=\"compress-offload-playback9\" />\n    </path>\n\n    <path name=\"compress-offload-playback9 afe-proxy\">\n        <ctl name=\"AFE_PCM_RX Audio Mixer MultiMedia16\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-offload-playback9 usb-headphones\">\n        <path name=\"compress-offload-playback9 afe-proxy\" />\n    </path>\n\n    <path name=\"compress-offload-playback9 speaker-and-usb-headphones\">\n        <path name=\"compress-offload-playback9 usb-headphones\" />\n        <path name=\"compress-offload-playback9\" />\n    </path>\n\n    <path name=\"audio-record\">\n        <ctl name=\"MultiMedia1 Mixer SLIM_0_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-record-3mic-ssr\">\n        <ctl name=\"Input Num Channel\" value=\"3\" />\n        <ctl name=\"Output Num Channel\" value=\"4\" />\n        <ctl name=\"Out Channel1\" id=\"0\" value=\"16384\" />\n        <ctl name=\"Out Channel1\" id=\"1\" value=\"0\" />\n        <ctl name=\"Out Channel1\" id=\"2\" value=\"0\" />\n        <ctl name=\"Out Channel2\" id=\"0\" value=\"0\" />\n        <ctl name=\"Out Channel2\" id=\"1\" value=\"16384\" />\n        <ctl name=\"Out Channel2\" id=\"2\" value=\"0\" />\n        <ctl name=\"Out Channel3\" id=\"0\" value=\"0\" />\n        <ctl name=\"Out Channel3\" id=\"1\" value=\"0\" />\n        <ctl name=\"Out Channel3\" id=\"2\" value=\"16384\" />\n        <ctl name=\"MultiMedia3 Mixer SLIM_0_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-record usb-headset-mic\">\n        <ctl name=\"MultiMedia1 Mixer AFE_PCM_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-record bt-sco\">\n        <ctl name=\"MultiMedia1 Mixer SEC_AUX_PCM_UL_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-record bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"audio-record bt-sco\" />\n    </path>\n\n    <path name=\"audio-record capture-fm\">\n        <ctl name=\"MultiMedia1 Mixer PRI_MI2S_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-record-compress\">\n        <ctl name=\"MultiMedia8 Mixer SLIM_0_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-record-compress bt-sco\">\n        <ctl name=\"MultiMedia8 Mixer SEC_AUX_PCM_UL_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"audio-record-compress bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"audio-record-compress bt-sco\" />\n    </path>\n\n    <path name=\"audio-record-compress usb-headset-mic\">\n        <ctl name=\"MultiMedia8 Mixer AFE_PCM_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"low-latency-record\">\n      <ctl name=\"MultiMedia5 Mixer SLIM_0_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"low-latency-record bt-sco\">\n      <ctl name=\"MultiMedia5 Mixer SEC_AUX_PCM_UL_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"low-latency-record bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"low-latency-record bt-sco\" />\n    </path>\n\n    <path name=\"low-latency-record capture-fm\">\n      <ctl name=\"MultiMedia5 Mixer PRI_MI2S_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"fm-virtual-record capture-fm\">\n        <ctl name=\"MultiMedia2 Mixer PRI_MI2S_TX\" value=\"1\" />\n    </path>\n\n    <path name=\"afe-proxy-playback afe-proxy\">\n    </path>\n\n    <path name=\"afe-proxy-record afe-proxy\">\n    </path>\n\n    <path name=\"voice-call\">\n        <ctl name=\"SLIM_0_RX_Voice Mixer CSVoice\" value=\"1\" />\n        <ctl name=\"Voice_Tx Mixer SLIM_0_TX_Voice\" value=\"1\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/25,add for 14049 voice call speaker -->\n    <path name=\"voice-call speaker\">\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/28,add for EC ref -->\n        <ctl name=\"VOC_EXT_EC MUX\" value=\"QUAT_MI2S_TX\" />\n        <ctl name=\"QUAT_MI2S_RX_Voice Mixer CSVoice\" value=\"1\" />\n        <ctl name=\"Voice_Tx Mixer SLIM_0_TX_Voice\" value=\"1\" />\n    </path>\n    <!-- guangyi.guo@MultiMedia.AudioDrv,2015/4/26,add for 14049 voice2 call speaker -->\n    <path name=\"voice2-call speaker\">\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/6/03,add for EC ref -->\n      <ctl name=\"VOC_EXT_EC MUX\" value=\"QUAT_MI2S_TX\" />\n      <ctl name=\"QUAT_MI2S_RX_Voice Mixer Voice2\" value=\"1\" />\n      <ctl name=\"Voice2_Tx Mixer SLIM_0_TX_Voice2\" value=\"1\" />\n    </path>\n\n   <!-- #endif VENDOR_EDIT-->\n   \n    <path name=\"voice-call hdmi\">\n        <ctl name=\"HDMI_RX_Voice Mixer CSVoice\" value=\"1\" />\n        <ctl name=\"Voice_Tx Mixer SLIM_0_TX_Voice\" value=\"1\" />\n    </path>\n\n    <path name=\"voice-call bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer CSVoice\" value=\"1\" />\n        <ctl name=\"Voice_Tx Mixer SEC_AUX_PCM_TX_Voice\" value=\"1\" />\n    </path>\n\n    <path name=\"voice-call bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"voice-call bt-sco\" />\n    </path>\n\n    <path name=\"voice-call afe-proxy\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer CSVoice\" value=\"1\" />\n        <ctl name=\"Voice_Tx Mixer AFE_PCM_TX_Voice\" value=\"1\" />\n    </path>\n\n    <path name=\"voice-call usb-headphones\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer CSVoice\" value=\"1\" />\n        <ctl name=\"Voice_Tx Mixer AFE_PCM_TX_Voice\" value=\"1\" />\n    </path>\n\n    <path name=\"voice2-call\">\n        <ctl name=\"SLIM_0_RX_Voice Mixer Voice2\" value=\"1\" />\n        <ctl name=\"Voice2_Tx Mixer SLIM_0_TX_Voice2\" value=\"1\" />\n    </path>\n\n    <path name=\"voice2-call hdmi\">\n        <ctl name=\"HDMI_RX_Voice Mixer Voice2\" value=\"1\" />\n        <ctl name=\"Voice2_Tx Mixer SLIM_0_TX_Voice2\" value=\"1\" />\n    </path>\n\n    <path name=\"voice2-call bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer Voice2\" value=\"1\" />\n        <ctl name=\"Voice2_Tx Mixer SEC_AUX_PCM_TX_Voice2\" value=\"1\" />\n    </path>\n\n    <path name=\"voice2-call bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"voice2-call bt-sco\" />\n    </path>\n\n    <path name=\"voice2-call afe-proxy\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer Voice2\" value=\"1\" />\n        <ctl name=\"Voice2_Tx Mixer AFE_PCM_TX_Voice2\" value=\"1\" />\n    </path>\n\n    <path name=\"voice2-call usb-headphones\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer Voice2\" value=\"1\" />\n        <ctl name=\"Voice2_Tx Mixer AFE_PCM_TX_Voice2\" value=\"1\" />\n    </path>\n\n    <path name=\"voice2-call speaker-protected\">\n    </path>\n\n    <path name=\"play-fm\">\n        <ctl name=\"PRI MI2S LOOPBACK Volume\" value=\"1\" />\n        <ctl name=\"SLIMBUS_0_RX Port Mixer PRI_MI2S_TX\" value=\"1\" />\n        <ctl name=\"SLIMBUS_DL_HL Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"incall-rec-uplink\">\n        <ctl name=\"MultiMedia1 Mixer VOC_REC_UL\" value=\"1\" />\n    </path>\n\n    <path name=\"incall-rec-uplink bt-sco\">\n        <path name=\"incall-rec-uplink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink bt-sco-wb\">\n        <path name=\"incall-rec-uplink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink usb-headset-mic\">\n        <path name=\"incall-rec-uplink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink afe-proxy\">\n        <path name=\"incall-rec-uplink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-compress\">\n        <ctl name=\"MultiMedia8 Mixer VOC_REC_UL\" value=\"1\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-compress bt-sco\">\n        <path name=\"incall-rec-uplink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-compress bt-sco-wb\">\n        <path name=\"incall-rec-uplink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-compress usb-headset-mic\">\n        <path name=\"incall-rec-uplink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-compress afe-proxy\">\n        <path name=\"incall-rec-uplink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-downlink\">\n        <ctl name=\"MultiMedia1 Mixer VOC_REC_DL\" value=\"1\" />\n    </path>\n\n    <path name=\"incall-rec-downlink bt-sco\">\n        <path name=\"incall-rec-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-downlink bt-sco-wb\">\n        <path name=\"incall-rec-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-downlink usb-headset-mic\">\n        <path name=\"incall-rec-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-downlink afe-proxy\">\n        <path name=\"incall-rec-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-downlink-compress\">\n        <ctl name=\"MultiMedia8 Mixer VOC_REC_DL\" value=\"1\" />\n    </path>\n\n    <path name=\"incall-rec-downlink-compress bt-sco\">\n        <path name=\"incall-rec-downlink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-downlink-compress bt-sco-wb\">\n        <path name=\"incall-rec-downlink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-downlink-compress usb-headset-mic\">\n        <path name=\"incall-rec-downlink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-downlink-compress afe-proxy\">\n        <path name=\"incall-rec-downlink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink\">\n        <path name=\"incall-rec-uplink\" />\n        <path name=\"incall-rec-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink bt-sco\">\n        <path name=\"incall-rec-uplink-and-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink bt-sco-wb\">\n        <path name=\"incall-rec-uplink-and-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink usb-headset-mic\">\n        <path name=\"incall-rec-uplink-and-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink afe-proxy\">\n        <path name=\"incall-rec-uplink-and-downlink\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink-compress\">\n        <path name=\"incall-rec-uplink-compress\" />\n        <path name=\"incall-rec-downlink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink-compress bt-sco\">\n        <path name=\"incall-rec-uplink-and-downlink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink-compress bt-sco-wb\">\n        <path name=\"incall-rec-uplink-and-downlink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink-compress usb-headset-mic\">\n        <path name=\"incall-rec-uplink-and-downlink-compress\" />\n    </path>\n\n    <path name=\"incall-rec-uplink-and-downlink-compress afe-proxy\">\n        <path name=\"incall-rec-uplink-and-downlink-compress\" />\n    </path>\n\n    <path name=\"incall_music_uplink\">\n        <ctl name=\"Incall_Music Audio Mixer MultiMedia2\" value=\"1\" />\n    </path>\n\n    <path name=\"incall_music_uplink bt-sco\">\n        <path name=\"incall_music_uplink\" />\n    </path>\n\n    <path name=\"incall_music_uplink bt-sco-wb\">\n        <path name=\"incall_music_uplink\" />\n    </path>\n\n    <path name=\"incall_music_uplink afe-proxy\">\n        <path name=\"incall_music_uplink\" />\n    </path>\n\n    <path name=\"incall_music_uplink usb-headphones\">\n        <path name=\"incall_music_uplink\" />\n    </path>\n\n    <path name=\"incall_music_uplink hdmi\">\n        <path name=\"incall_music_uplink\" />\n    </path>\n\n    <path name=\"incall_music_uplink2\">\n        <ctl name=\"Incall_Music_2 Audio Mixer MultiMedia9\" value=\"1\" />\n    </path>\n\n    <path name=\"incall_music_uplink2 bt-sco\">\n        <path name=\"incall_music_uplink2\" />\n    </path>\n\n    <path name=\"incall_music_uplink2 bt-sco-wb\">\n        <path name=\"incall_music_uplink2\" />\n    </path>\n\n    <path name=\"incall_music_uplink2 afe-proxy\">\n        <path name=\"incall_music_uplink2\" />\n    </path>\n\n    <path name=\"incall_music_uplink2 usb-headphones\">\n        <path name=\"incall_music_uplink2\" />\n    </path>\n\n    <path name=\"incall_music_uplink2 hdmi\">\n        <path name=\"incall_music_uplink2\" />\n    </path>\n\n    <path name=\"hfp-sco\">\n        <ctl name=\"HFP_AUX_UL_HL Switch\" value=\"1\" />\n        <ctl name=\"SLIMBUS_0_RX Port Mixer SEC_AUX_PCM_UL_TX\" value=\"1\" />\n        <ctl name=\"SEC_AUX_PCM_RX Audio Mixer MultiMedia6\" value=\"1\" />\n        <ctl name=\"MultiMedia6 Mixer SLIM_0_TX\" value=\"1\" />\n        <ctl name=\"SLIMBUS_DL_HL Switch\" value=\"1\" />\n   </path>\n\n   <path name=\"hfp-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"hfp-sco\" />\n   </path>\n\n    <path name=\"volte-call\">\n        <ctl name=\"SLIM_0_RX_Voice Mixer VoLTE\" value=\"1\" />\n        <ctl name=\"VoLTE_Tx Mixer SLIM_0_TX_VoLTE\" value=\"1\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv 2015-05-13 add for volte call speaker  -->\n    <path name=\"volte-call speaker\">\n        <ctl name=\"QUAT_MI2S_RX_Voice Mixer VoLTE\" value=\"1\" />\n        <ctl name=\"VoLTE_Tx Mixer SLIM_0_TX_VoLTE\" value=\"1\" />\n    </path>\n    <!-- ENDIF-->\n\n    <path name=\"volte-call hdmi\">\n        <ctl name=\"HDMI_RX_Voice Mixer VoLTE\" value=\"1\" />\n        <ctl name=\"VoLTE_Tx Mixer SLIM_0_TX_VoLTE\" value=\"1\" />\n    </path>\n\n    <path name=\"volte-call bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer VoLTE\" value=\"1\" />\n        <ctl name=\"VoLTE_Tx Mixer SEC_AUX_PCM_TX_VoLTE\" value=\"1\" />\n    </path>\n\n    <path name=\"volte-call bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"volte-call bt-sco\" />\n    </path>\n\n    <path name=\"volte-call afe-proxy\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer VoLTE\" value=\"1\" />\n        <ctl name=\"VoLTE_Tx Mixer AFE_PCM_TX_VoLTE\" value=\"1\" />\n    </path>\n\n    <path name=\"volte-call usb-headphones\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer VoLTE\" value=\"1\" />\n        <ctl name=\"VoLTE_Tx Mixer AFE_PCM_TX_VoLTE\" value=\"1\" />\n    </path>\n\n    <path name=\"volte-call speaker-protected\">\n    </path>\n\n    <path name=\"compress-voip-call\">\n        <ctl name=\"SLIM_0_RX_Voice Mixer Voip\" value=\"1\" />\n        <ctl name=\"Voip_Tx Mixer SLIM_0_TX_Voip\" value=\"1\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv 2015-04-21 voip spkeaker support  -->\n    <path name=\"compress-voip-call speaker\">        \n        <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/28,add for EC ref -->\n        <ctl name=\"VOC_EXT_EC MUX\" value=\"QUAT_MI2S_TX\" />\n        <ctl name=\"QUAT_MI2S_RX_Voice Mixer Voip\" value=\"1\" />\n        <ctl name=\"Voip_Tx Mixer SLIM_0_TX_Voip\" value=\"1\" />\n    </path>\n    <!-- ENDIF-->\n\n    <path name=\"compress-voip-call bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer Voip\" value=\"1\" />\n        <ctl name=\"Voip_Tx Mixer SEC_AUX_PCM_TX_Voip\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-voip-call bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"compress-voip-call bt-sco\" />\n    </path>\n\n    <path name=\"compress-voip-call afe-proxy\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer Voip\" value=\"1\" />\n        <ctl name=\"Voip_Tx Mixer AFE_PCM_TX_Voip\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-voip-call usb-headphones\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer Voip\" value=\"1\" />\n        <ctl name=\"Voip_Tx Mixer AFE_PCM_TX_Voip\" value=\"1\" />\n    </path>\n\n    <path name=\"compress-voip-call speaker-protected\">\n    </path>\n\n    <path name=\"listen-voice-wakeup-1\">\n        <ctl name=\"LSM1 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-2\">\n        <ctl name=\"LSM2 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-3\">\n        <ctl name=\"LSM3 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-4\">\n        <ctl name=\"LSM4 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-5\">\n        <ctl name=\"LSM5 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-6\">\n        <ctl name=\"LSM6 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-7\">\n        <ctl name=\"LSM7 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-8\">\n        <ctl name=\"LSM8 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n\n   <path name=\"spkr-rx-calib\">\n        <ctl name=\"SLIMBUS_DL_HL Switch\"  value=\"1\" />\n    </path>\n\n    <path name=\"spkr-vi-record\">\n    </path>\n\n    <path name=\"qchat-call\">\n        <ctl name=\"SLIM_0_RX_Voice Mixer QCHAT\" value=\"1\" />\n        <ctl name=\"QCHAT_Tx Mixer SLIM_0_TX_QCHAT\" value=\"1\" />\n    </path>\n\n    <path name=\"qchat-call bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer QCHAT\" value=\"1\" />\n        <ctl name=\"QCHAT_Tx Mixer SEC_AUX_PCM_TX_QCHAT\" value=\"1\" />\n    </path>\n\n    <path name=\"qchat-call bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"qchat-call bt-sco\" />\n    </path>\n\n    <path name=\"vowlan-call\">\n        <ctl name=\"SLIM_0_RX_Voice Mixer VoWLAN\" value=\"1\" />\n        <ctl name=\"VoWLAN_Tx Mixer SLIM_0_TX_VoWLAN\" value=\"1\" />\n    </path>\n\n    <path name=\"vowlan-call hdmi\">\n        <ctl name=\"HDMI_RX_Voice Mixer VoWLAN\" value=\"1\" />\n        <ctl name=\"VoWLAN_Tx Mixer SLIM_0_TX_VoWLAN\" value=\"1\" />\n    </path>\n\n    <path name=\"vowlan-call bt-sco\">\n        <ctl name=\"SEC_AUX_PCM_RX_Voice Mixer VoWLAN\" value=\"1\" />\n        <ctl name=\"VoWLAN_Tx Mixer SEC_AUX_PCM_TX_VoWLAN\" value=\"1\" />\n    </path>\n\n    <path name=\"vowlan-call bt-sco-wb\">\n        <ctl name=\"AUX PCM SampleRate\" value=\"16000\" />\n        <path name=\"vowlan-call bt-sco\" />\n    </path>\n\n    <path name=\"vowlan-call afe-proxy\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer VoWLAN\" value=\"1\" />\n        <ctl name=\"VoWLAN_Tx Mixer AFE_PCM_TX_VoWLAN\" value=\"1\" />\n    </path>\n\n    <path name=\"vowlan-call usb-headphones\">\n        <ctl name=\"AFE_PCM_RX_Voice Mixer VoWLAN\" value=\"1\" />\n        <ctl name=\"VoWLAN_Tx Mixer AFE_PCM_TX_VoWLAN\" value=\"1\" />\n    </path>\n\n    <!-- These are actual sound device specific mixer settings -->\n    <path name=\"adc1\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC6\" />\n        <ctl name=\"DEC6 MUX\" value=\"ADC1\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC6\" />\n    </path>\n\n    <path name=\"adc2\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC5\" />\n        <ctl name=\"DEC5 MUX\" value=\"ADC2\" />\n<!-- #ifndef VENDOR_EDIT -->\n<!-- Kangjirui@MultMedia.Audio, 2015/04/16, Remove for echo noise -->\n<!--\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC5\" />\n-->\n<!-- #endif //VENDOR_EDIT -->\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/19,add for 14049 mic -->\n\n    <path name=\"adc3\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC4\" />\n        <ctl name=\"DEC4 MUX\" value=\"ADC3\" />\n        <ctl name=\"DEC4 Volume\" value=\"84\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC4\" />\n       <ctl name=\"ADC3 Volume\" value=\"13\" />\n    </path>\n\n\t<path name=\"adc4\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC3\" />\n        <ctl name=\"DEC3 MUX\" value=\"ADC4\" />\n        <ctl name=\"DEC3 Volume\" value=\"84\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC3\" />\n        <ctl name=\"ADC4 Volume\" value=\"13\" />\n    </path>\n <!-- #ENDIF-->\n    <path name=\"adc5\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC2\" />\n        <ctl name=\"DEC2 MUX\" value=\"ADC5\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC2\" />\n    </path>\n\n    <path name=\"adc6\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC1\" />\n        <ctl name=\"DEC1 MUX\" value=\"ADC6\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC1\" />\n    </path>\n\n    <path name=\"dmic1\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC7\" />\n        <ctl name=\"DEC7 MUX\" value=\"DMIC1\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC7\" />\n    </path>\n\n    <path name=\"dmic2\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC8\" />\n        <ctl name=\"DEC8 MUX\" value=\"DMIC2\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC8\" />\n    </path>\n\n    <path name=\"dmic3\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC10\" />\n        <ctl name=\"DEC10 MUX\" value=\"DMIC3\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC10\" />\n    </path>\n\n    <path name=\"dmic4\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC7\" />\n        <ctl name=\"DEC9 MUX\" value=\"DMIC4\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC9\" />\n    </path>\n\n    <path name=\"dmic5\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC5\" />\n        <ctl name=\"DEC5 MUX\" value=\"DMIC5\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC5\" />\n    </path>\n\n    <path name=\"dmic6\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX10\" value=\"1\"/>\n        <ctl name=\"SLIM_0_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM TX10 MUX\" value=\"DEC6\" />\n        <ctl name=\"DEC6 MUX\" value=\"DMIC6\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC6\" />\n    </path>\n    \n   <!-- #ifdef VENDOR_EDIT-->\n   <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/5,pa do not use the following control any more  -->    \t\n       <!--<path name=\"speaker\">   -->\n        <!--<ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" /> -->\n        <!--<ctl name=\"SLIM RX2 MUX\" value=\"AIF1_PB\" /> -->\n        <!--<ctl name=\"SLIM_0_RX Channels\" value=\"Two\" /> -->\n        <!--<ctl name=\"RX7 MIX1 INP1\" value=\"RX1\" /> -->\n        <!--<ctl name=\"RX8 MIX1 INP1\" value=\"RX2\" /> -->\n        <!-- <ctl name=\"RX7 Digital Volume\" value=\"84\" /> -->\n        <!--<ctl name=\"RX8 Digital Volume\" value=\"84\" /> -->\n        <!--<ctl name=\"COMP0 Switch\" value=\"1\" /> -->\n    <!--</path>  -->\n    <!-- #endif VENDOR_EDIT-->\n    \n   <!-- #ifdef VENDOR_EDIT-->\n   <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/28,remove for causing ec ref problem  -->\n\n    <path name=\"speaker\">\n      \t<!-- <ctl name=\"left Profile\" value=\"0\" /> -->\n    </path>\n    <!-- #endif VENDOR_EDIT-->\n\n   <!-- #ifdef VENDOR_EDIT-->\n   <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/5,deleted unused path,which cause phone breakdown when power up  -->    \t\n    <path name=\"speaker-fluid\">\n    <!--    <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" /> -->\n     <!--    <ctl name=\"SLIM_0_RX Channels\" value=\"One\" /> -->\n     <!--    <ctl name=\"RX8 MIX1 INP1\" value=\"RX1\" /> -->\n     <!--    <ctl name=\"RX8 Digital Volume\" value=\"84\" /> -->\n     <!--    <ctl name=\"COMP0 Switch\" value=\"1\" /> -->\n    </path>\n<!-- #endif VENDOR_EDIT-->\n\n    <path name=\"speaker-liquid\">\n        <path name=\"speaker\" />\n    </path>\n\n    <path name=\"speaker-db\">\n        <path name=\"speaker\" />\n        <ctl name=\"RX7 Digital Volume\" value=\"83\" />\n        <ctl name=\"RX8 Digital Volume\" value=\"83\" />\n    </path>\n\n    <path name=\"speaker-ext-1-liquid\">\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM RX2 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"Two\" />\n        <ctl name=\"RX3 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX5 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"RX3 Digital Volume\" value=\"84\" />\n        <ctl name=\"RX5 Digital Volume\" value=\"84\" />\n        <ctl name=\"LINEOUT1 Volume\" value=\"84\" />\n        <ctl name=\"LINEOUT2 Volume\" value=\"84\" />\n        <ctl name=\"COMP2 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-ext-1-db\">\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM RX2 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"Two\" />\n        <ctl name=\"RX4 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX6 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"RX4 Digital Volume\" value=\"70\" />\n        <ctl name=\"RX6 Digital Volume\" value=\"70\" />\n        <ctl name=\"LINEOUT3 Volume\" value=\"90\" />\n        <ctl name=\"LINEOUT4 Volume\" value=\"90\" />\n        <ctl name=\"COMP2 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-ext-2-db\">\n        <path name=\"speaker-ext-1-liquid\"/>\n    </path>\n\n   <path name=\"sidetone-iir\">\n        <ctl name=\"IIR1 Enable Band1\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band2\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band3\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band4\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band5\" value=\"1\" />\n    </path>\n\n    <path name=\"sidetone-headphones\">\n        <path name=\"sidetone-iir\" />\n        <ctl name=\"IIR1 INP1 Volume\" value=\"54\" />\n        <ctl name=\"RX1 MIX2 INP1\" value=\"IIR1\" />\n        <ctl name=\"RX2 MIX2 INP1\" value=\"IIR1\" />\n    </path>\n\n    <path name=\"sidetone-handset\">\n        <path name=\"sidetone-iir\" />\n        <ctl name=\"IIR1 INP1 Volume\" value=\"54\" />\n        <ctl name=\"RX1 MIX2 INP1\" value=\"IIR1\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- wangdongdong@MultiMedia.AudioDrv,2015-04-02,modify for single mic record -->\n    <path name=\"hdmi-mic\"> \n    \t<path name=\"adc3\" />\n    </path>\n    <!-- #endif VENDOR_EDIT-->\n    \n    <path name=\"speaker-mic\">\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/19,add for 14049 mic -->\n    \n        <path name=\"adc3\" />\n     <!-- #ENDIF-->\t\n\t\n    </path>\n\n    <path name=\"speaker-mic-liquid\">\n        <path name=\"dmic3\" />\n        <ctl name=\"DEC9 Volume\" value=\"111\" />\n    </path>\n\n    <path name=\"speaker-mic-sbc\">\n        <path name=\"adc5\" />\n        <ctl name=\"ADC5 Volume\" value=\"20\" />\n    </path>\n\n    <path name=\"speaker-protected\">\n        <ctl name=\"AIF4_VI Mixer SPKR_VI_1\" value=\"1\" />\n        <ctl name=\"AIF4_VI Mixer SPKR_VI_2\" value=\"1\" />\n        <path name=\"speaker\" />\n        <ctl name=\"VI_FEED_TX Channels\" value=\"Two\" />\n        <ctl name=\"SLIM0_RX_VI_FB_LCH_MUX\"  value=\"SLIM4_TX\" />\n        <ctl name=\"SLIM0_RX_VI_FB_RCH_MUX\"  value=\"SLIM4_TX\" />\n    </path>\n\n    <path name=\"speaker-protected-fluid\">\n        <ctl name=\"AIF4_VI Mixer SPKR_VI_1\" value=\"1\" />\n        <path name=\"speaker-fluid\" />\n        <ctl name=\"VI_FEED_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM0_RX_VI_FB_LCH_MUX\"  value=\"SLIM4_TX\" />\n    </path>\n\n    <path name=\"vi-feedback\">\n    </path>\n\n    <path name=\"speaker-mono\">\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"One\" />\n        <ctl name=\"RX7 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"COMP0 Switch\" value=\"1\" />\n        <ctl name=\"RX7 Digital Volume\" value=\"84\" />\n    </path>\n\n    <path name=\"voice-speaker-protected\">\n        <ctl name=\"AIF4_VI Mixer SPKR_VI_1\" value=\"1\" />\n        <path name=\"speaker-mono\" />\n        <ctl name=\"VI_FEED_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM0_RX_VI_FB_LCH_MUX\"  value=\"SLIM4_TX\" />\n    </path>\n\n    <path name=\"voice-speaker-protected-fluid\">\n        <ctl name=\"AIF4_VI Mixer SPKR_VI_1\" value=\"1\" />\n        <path name=\"speaker-fluid\" />\n        <ctl name=\"VI_FEED_TX Channels\" value=\"One\" />\n        <ctl name=\"SLIM0_RX_VI_FB_LCH_MUX\"  value=\"SLIM4_TX\" />\n    </path>\n\n    <path name=\"handset\">\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"One\" />\n        <ctl name=\"RX1 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"CLASS_H_DSM MUX\" value=\"DSM_HPHL_RX1\" />\n        <ctl name=\"DAC1 Switch\" value=\"1\" />\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/3,change to pass test for qualcomm advise  -->    \t\n        <ctl name=\"RX1 Digital Volume\" value=\"90\" />\n    <!-- #endif VENDOR_EDIT-->\t\n    </path>\n\n    <path name=\"handset-mic\">\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/19,add for 14049 mic -->\n        <path name=\"adc3\" />\n\t <!-- #ENDIF-->\n    </path>\n\n    <path name=\"handset-mic-db\">\n        <path name=\"adc6\" />\n    </path>\n\n    <path name=\"handset-mic-ext-db\">\n        <path name=\"adc5\" />\n        <path name=\"adc1\" />\n    </path>\n\n    <path name=\"handset-mic-cdp\">\n        <path name=\"adc1\" />\n        <ctl name=\"ADC1 Volume\" value=\"20\" />\n    </path>\n\n    <path name=\"handset-mic-sbc\">\n        <path name=\"adc5\" />\n        <ctl name=\"ADC5 Volume\" value=\"20\" />\n    </path>\n\n    <path name=\"three-mic\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX9\" value=\"1\" />\n        <ctl name=\"SLIM_0_TX Channels\" value=\"Three\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC9\" />\n        <ctl name=\"DEC9 MUX\" value=\"DMIC5\" />\n        <ctl name=\"SLIM TX8 MUX\" value=\"DEC7\" />\n        <ctl name=\"DEC7 MUX\" value=\"DMIC1\" />\n        <ctl name=\"SLIM TX9 MUX\" value=\"DEC10\" />\n        <ctl name=\"DEC10 MUX\" value=\"DMIC3\" />\n    </path>\n\n    <path name=\"anc-handset\">\n        <ctl name=\"ANC Function\" value=\"ON\" />\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"One\" />\n        <ctl name=\"RX1 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"CLASS_H_DSM MUX\" value=\"DSM_HPHL_RX1\" />\n        <ctl name=\"DAC1 Switch\" value=\"1\" />\n        <ctl name=\"RX1 Digital Volume\" value=\"81\" />\n        <ctl name=\"ANC Slot\" value=\"6\" />\n        <ctl name=\"ANC1 MUX\" value=\"DMIC4\" />\n        <ctl name=\"ANC1 FB MUX\" value=\"EAR_HPH_L\" />\n    </path>\n\n    <path name=\"headphones\">\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM RX2 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"Two\" />\n        <ctl name=\"RX1 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX2 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"CLASS_H_DSM MUX\" value=\"DSM_HPHL_RX1\" />\n        <ctl name=\"HPHL DAC Switch\" value=\"1\" />\n        <ctl name=\"COMP1 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"headset-mic\">\n        <path name=\"adc2\" />\n        <ctl name=\"ADC2 Volume\" value=\"13\" />\n    </path>\n\n    <path name=\"headset-mic-liquid\">\n        <path name=\"adc2\" />\n        <ctl name=\"ADC2 Volume\" value=\"20\" />\n    </path>\n\n    <path name=\"voice-handset\">\n        <path name=\"handset\" />\n    </path>\n\n    <path name=\"voice-handset-tmus\">\n        <path name=\"handset\" />\n    </path>\n\n    <path name=\"voice-speaker\">\n        <path name=\"speaker-mono\" />\n    </path>\n\n    <path name=\"voice-speaker-fluid\">\n        <path name=\"speaker-fluid\" />\n    </path>\n\n    <path name=\"voice-speaker-db\">\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM RX2 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"Two\" />\n        <ctl name=\"RX3 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX5 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"RX3 Digital Volume\" value=\"68\" />\n        <ctl name=\"RX5 Digital Volume\" value=\"68\" />\n        <ctl name=\"LINEOUT1 Volume\" value=\"84\" />\n        <ctl name=\"LINEOUT2 Volume\" value=\"84\" />\n        <ctl name=\"COMP2 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"voice-speaker-mic\">\n        <path name=\"speaker-mic\" />\n    </path>\n\n    <path name=\"voice-speaker-mic-db\">\n        <path name=\"handset-mic-db\" />\n    </path>\n\n    <path name=\"voice-headphones\">\n        <path name=\"headphones\" />\n    </path>\n\n    <path name=\"voice-headset-mic\">\n        <path name=\"headset-mic\" />\n        <ctl name=\"ADC2 Volume\" value=\"13\" />\n    </path>\n\n    <path name=\"speaker-and-headphones\">\n        <path name=\"headphones\" />\n        <ctl name=\"RX7 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX8 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"COMP0 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-and-headphones-fluid\">\n        <path name=\"headphones\" />\n        <ctl name=\"RX8 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"COMP0 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-and-headphones-liquid\">\n        <path name=\"headphones\" />\n        <ctl name=\"RX7 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX8 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"RX7 Digital Volume\" value=\"84\" />\n        <ctl name=\"RX8 Digital Volume\" value=\"84\" />\n        <ctl name=\"COMP0 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-and-headphones-ext-1-liquid\">\n        <path name=\"headphones\" />\n        <ctl name=\"RX3 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX5 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"RX3 Digital Volume\" value=\"68\" />\n        <ctl name=\"RX5 Digital Volume\" value=\"68\" />\n        <ctl name=\"LINEOUT1 Volume\" value=\"84\" />\n        <ctl name=\"LINEOUT2 Volume\" value=\"84\" />\n        <ctl name=\"COMP2 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-and-headphones-ext-1-db\">\n        <path name=\"headphones\" />\n        <ctl name=\"RX4 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX6 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"RX4 Digital Volume\" value=\"67\" />\n        <ctl name=\"RX6 Digital Volume\" value=\"67\" />\n        <ctl name=\"LINEOUT3 Volume\" value=\"80\" />\n        <ctl name=\"LINEOUT4 Volume\" value=\"80\" />\n        <ctl name=\"COMP2 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-and-headphones-ext-2-db\">\n        <path name=\"speaker-and-headphones-ext-1-liquid\"/>\n    </path>\n\n    <path name=\"usb-headphones\">\n    </path>\n\n    <path name=\"afe-proxy\">\n    </path>\n\n    <path name=\"anc-headphones\">\n        <ctl name=\"ANC Function\" value=\"ON\" />\n        <ctl name=\"ANC Slot\" value=\"0\" />\n        <ctl name=\"ANC1 FB MUX\" value=\"EAR_HPH_L\" />\n        <ctl name=\"ANC1 MUX\" value=\"ADC3\" />\n        <ctl name=\"ANC2 MUX\" value=\"ADC4\" />\n\t<ctl name=\"ADC3 Volume\" value=\"8\" />\n        <ctl name=\"ADC4 Volume\" value=\"8\" />\n        <ctl name=\"HPHL Volume\" value=\"20\" />\n        <ctl name=\"HPHR Volume\" value=\"20\" />\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM RX2 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"Two\" />\n        <ctl name=\"RX1 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX2 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"CLASS_H_DSM MUX\" value=\"DSM_HPHL_RX1\" />\n        <ctl name=\"HPHL DAC Switch\" value=\"1\" />\n        <ctl name=\"RX1 Digital Volume\" value=\"84\" />\n        <ctl name=\"RX2 Digital Volume\" value=\"84\" />\n    </path>\n\n    <path name=\"speaker-and-anc-headphones\">\n        <path name=\"anc-headphones\" />\n        <ctl name=\"RX7 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"COMP0 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-and-anc-headphones-fluid\">\n        <path name=\"anc-headphones\" />\n        <ctl name=\"RX8 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"COMP0 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"anc-fb-headphones\">\n        <path name=\"anc-headphones\" />\n        <ctl name=\"ANC Slot\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-and-anc-fb-headphones\">\n        <path name=\"anc-fb-headphones\" />\n        <ctl name=\"RX7 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"COMP0 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"speaker-and-anc-fb-headphones-fluid\">\n        <path name=\"anc-fb-headphones\" />\n        <ctl name=\"RX8 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"COMP0 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"voice-anc-headphones\">\n        <ctl name=\"ANC Function\" value=\"ON\" />\n        <ctl name=\"ANC Slot\" value=\"0\" />\n        <ctl name=\"ANC1 FB MUX\" value=\"EAR_HPH_L\" />\n        <ctl name=\"ANC1 MUX\" value=\"ADC3\" />\n        <ctl name=\"ANC2 MUX\" value=\"ADC4\" />\n        <ctl name=\"ADC3 Volume\" value=\"8\" />\n        <ctl name=\"ADC4 Volume\" value=\"8\" />\n        <ctl name=\"HPHL Volume\" value=\"20\" />\n        <ctl name=\"HPHR Volume\" value=\"20\" />\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM RX2 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"Two\" />\n        <ctl name=\"RX1 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX2 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"IIR1 Enable Band1\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band2\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band3\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band4\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band5\" value=\"1\" />\n        <ctl name=\"IIR1 INP1 Volume\" value=\"54\" />\n        <ctl name=\"CLASS_H_DSM MUX\" value=\"DSM_HPHL_RX1\" />\n        <ctl name=\"HPHL DAC Switch\" value=\"1\" />\n        <ctl name=\"RX1 Digital Volume\" value=\"84\" />\n        <ctl name=\"RX2 Digital Volume\" value=\"84\" />\n    </path>\n\n    <path name=\"voice-anc-fb-headphones\">\n        <ctl name=\"ANC Function\" value=\"ON\" />\n        <ctl name=\"ANC Slot\" value=\"1\" />\n        <ctl name=\"ANC1 FB MUX\" value=\"EAR_HPH_L\" />\n        <ctl name=\"ANC1 MUX\" value=\"ADC3\" />\n        <ctl name=\"ANC2 MUX\" value=\"ADC4\" />\n        <ctl name=\"ADC3 Volume\" value=\"8\" />\n        <ctl name=\"ADC4 Volume\" value=\"8\" />\n        <ctl name=\"HPHL Volume\" value=\"20\" />\n        <ctl name=\"HPHR Volume\" value=\"20\" />\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM RX2 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"Two\" />\n        <ctl name=\"RX1 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX2 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"IIR1 Enable Band1\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band2\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band3\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band4\" value=\"1\" />\n        <ctl name=\"IIR1 Enable Band5\" value=\"1\" />\n        <ctl name=\"IIR1 INP1 Volume\" value=\"54\" />\n        <ctl name=\"CLASS_H_DSM MUX\" value=\"DSM_HPHL_RX1\" />\n        <ctl name=\"HPHL DAC Switch\" value=\"1\" />\n        <ctl name=\"RX1 Digital Volume\" value=\"81\" />\n        <ctl name=\"RX2 Digital Volume\" value=\"81\" />\n    </path>\n\n    <path name=\"speaker-and-anc-headphones-liquid\">\n        <path name=\"anc-headphones\" />\n        <ctl name=\"RX3 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"RX5 MIX1 INP1\" value=\"RX2\" />\n        <ctl name=\"RDAC5 MUX\" value=\"DEM3_INV\" />\n        <ctl name=\"RDAC7 MUX\" value=\"DEM5_INV\" />\n        <ctl name=\"RX3 Digital Volume\" value=\"68\" />\n        <ctl name=\"RX5 Digital Volume\" value=\"68\" />\n        <ctl name=\"LINEOUT1 Volume\" value=\"20\" />\n        <ctl name=\"LINEOUT2 Volume\" value=\"20\" />\n        <ctl name=\"LINEOUT3 Volume\" value=\"20\" />\n        <ctl name=\"LINEOUT4 Volume\" value=\"20\" />\n        <ctl name=\"COMP2 Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"hdmi\">\n    </path>\n\n    <path name=\"speaker-and-usb-headphones\">\n        <path name=\"speaker\" />\n        <path name=\"usb-headphones\" />\n    </path>\n\n    <path name=\"speaker-and-usb-headphones-fluid\">\n        <path name=\"speaker-fluid\" />\n        <path name=\"usb-headphones\" />\n    </path>\n\n    <path name=\"speaker-and-hdmi\">\n        <path name=\"speaker\" />\n        <path name=\"hdmi\" />\n    </path>\n\n    <path name=\"speaker-and-hdmi-fluid\">\n        <path name=\"speaker-fluid\" />\n        <path name=\"hdmi\" />\n    </path>\n\n    <path name=\"voice-rec-mic\">\n        <path name=\"handset-mic\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/24,change for 14049 config  -->\n    <!-- Dual MIC devices -->\n    <path name=\"handset-dmic-endfire\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"1\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC4\" />\n        <ctl name=\"DEC4 MUX\" value=\"ADC3\" />\n        <ctl name=\"SLIM TX8 MUX\" value=\"DEC3\" />\n        <ctl name=\"DEC3 MUX\" value=\"ADC4\" />\n        <ctl name=\"SLIM_0_TX Channels\" value=\"Two\" />\n    </path>\n    <path name=\"camcorder-mic\">\n        <path name=\"handset-dmic-endfire\" />\n    </path>\n<!-- #endif VENDOR_EDIT-->\n\n    <path name=\"hdmi-tx\">\n        <path name=\"handset-mic\" />\n    </path>\n\n    <path name=\"bt-sco-headset\">\n    </path>\n\n    <path name=\"bt-sco-mic\">\n    </path>\n\n    <path name=\"bt-sco-headset-wb\">\n    </path>\n\n    <path name=\"bt-sco-mic-wb\">\n    </path>\n\n    <path name=\"usb-headset-mic\">\n    </path>\n\n    <path name=\"capture-fm\">\n    </path>\n\n    <path name=\"aanc-handset-mic\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX9\" value=\"1\" />\n        <ctl name=\"SLIM_0_TX Channels\" value=\"Three\" />\n        <ctl name=\"AANC_SLIM_0_RX MUX\" value=\"SLIMBUS_0_TX\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC7\" />\n        <ctl name=\"DEC7 MUX\" value=\"DMIC1\" />\n        <ctl name=\"SLIM TX8 MUX\" value=\"DEC9\" />\n        <ctl name=\"DEC9 MUX\" value=\"DMIC4\" />\n        <ctl name=\"SLIM TX9 MUX\" value=\"DEC10\" />\n        <ctl name=\"DEC10 MUX\" value=\"DMIC3\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC7\" />\n    </path>\n    <!-- Dual MIC devices -->\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/24,change for 14049 config  -->\n    <!-- lifei@MultiMedia.AudioDrv,2015/4/01,change for 14049 config for voice mic no sound  -->\n    <path name=\"dmic-endfire\">\n        <path name=\"handset-dmic-endfire\" />\n        <!--ctl name=\"IIR1 INP1 MUX\" value=\"DEC7\" /-->\n    </path>\n\n    <path name=\"speaker-dmic-endfire\">\n\t\t\t\t<path name=\"dmic-endfire\" />\n    </path>\n\n    <path name=\"dmic-endfire-liquid\">\n        <path name=\"handset-dmic-endfire\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC7\" />\n    </path>\n\n\n<!-- #ifndef VENDOR_EDIT-->\n<!-- zhiguang.su@MultiMedia.AudioDrv,2015/5/7,switch left/right channel for stereo record  -->\n<!--    <path name=\"handset-stereo-dmic-ef\"> -->\n<!--        <path name=\"handset-dmic-endfire\" /> -->\n<!--    </path> -->\n\n<!-- #else -->\n    <path name=\"handset-stereo-dmic-ef\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"1\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC3\" />\n        <ctl name=\"DEC3 MUX\" value=\"ADC4\" />\n        <ctl name=\"SLIM TX8 MUX\" value=\"DEC4\" />\n        <ctl name=\"DEC4 MUX\" value=\"ADC3\" />\n        <ctl name=\"SLIM_0_TX Channels\" value=\"Two\" />\n<!-- zhiguang.su@MultiMedia.AudioDrv,2015/5/25,add volume control for stereo record  -->\n        <ctl name=\"DEC3 Volume\" value=\"84\" />\n        <ctl name=\"DEC4 Volume\" value=\"84\" />\n        <ctl name=\"ADC3 Volume\" value=\"13\" />\n        <ctl name=\"ADC4 Volume\" value=\"8\" />\n    </path>\n<!-- #endif VENDOR_EDIT-->\n\n    <path name=\"speaker-stereo-dmic-ef\">\n        <path name=\"speaker-dmic-endfire\" />\n    </path>\n\n    <path name=\"voice-dmic-ef-tmus\">\n        <path name=\"dmic-endfire\" />\n    </path>\n\n    <path name=\"voice-dmic-ef\">\n        <path name=\"dmic-endfire\" />\n    </path>\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/18,add for skype  -->\n    <path name=\"voice-speaker-voip-mic\">\n\t\t\t\t<path name=\"speaker-dmic-endfire\" />\n        <ctl name=\"DEC3 Volume\" value=\"84\" />\n        <ctl name=\"DEC4 Volume\" value=\"78\" />\n        <ctl name=\"ADC3 Volume\" value=\"13\" />\n        <ctl name=\"ADC4 Volume\" value=\"13\" />\n        <ctl name=\"left Profile\" value=\"2\"/>\n       <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/28,remove for causing ec ref problem  -->\n       <!--  <ctl name=\"VOC_EXT_EC MUX\" value=\"QUAT_MI2S_TX\" /> -->\n    </path>\n    <!-- #endif VENDOR_EDIT-->\n\n    <!-- #ifdef VENDOR_EDIT-->\n    <!-- zhiguang.su@MultiMedia.AudioDrv,2015/3/24,change for 14049 config  -->\n    <!-- wangdongdong@MultiMedia.AudioDrv,2015-04-02,config for speaker voice call -->\n    <path name=\"voice-speaker-dmic-ef\">\n        <path name=\"speaker-dmic-endfire\" />\n        <ctl name=\"DEC3 Volume\" value=\"84\" />\n        <ctl name=\"DEC4 Volume\" value=\"78\" />\n        <ctl name=\"ADC3 Volume\" value=\"13\" />\n        <ctl name=\"ADC4 Volume\" value=\"13\" />\n        <ctl name=\"left Profile\" value=\"2\"/>\n\t <!-- zhiguang.su@MultiMedia.AudioDrv,2015/4/28,remove for causing ec ref problem  -->\n       <!-- <ctl name=\"VOC_EXT_EC MUX\" value=\"QUAT_MI2S_TX\" /> -->\n    </path>\n<!-- #endif VENDOR_EDIT-->\n\n    <path name=\"voice-rec-dmic-ef\">\n        <path name=\"dmic-endfire\" />\n    </path>\n\n    <path name=\"voice-rec-dmic-ef-fluence\">\n        <path name=\"dmic-endfire\" />\n    </path>\n\n    <path name=\"handset-stereo-dmic-ef-liquid\">\n        <path name=\"handset-dmic-endfire\" />\n    </path>\n\n    <path name=\"speaker-stereo-dmic-ef-liquid\">\n        <path name=\"handset-dmic-endfire\" />\n    </path>\n\n    <path name=\"voice-dmic-ef-liquid-liquid\">\n        <path name=\"dmic-endfire-liquid\" />\n    </path>\n\n    <path name=\"voice-speaker-dmic-ef-liquid\">\n        <path name=\"dmic-endfire-liquid\" />\n    </path>\n\n    <path name=\"voice-rec-dmic-ef-liquid\">\n        <path name=\"dmic-endfire-liquid\" />\n    </path>\n\n    <path name=\"voice-rec-dmic-ef-fluence-liquid\">\n        <path name=\"dmic-endfire-liquid\" />\n    </path>\n\n    <path name=\"speaker-dmic-broadside\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"1\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC7\" />\n        <ctl name=\"DEC7 MUX\" value=\"DMIC1\" />\n        <ctl name=\"SLIM TX8 MUX\" value=\"DEC10\" />\n        <ctl name=\"DEC10 MUX\" value=\"DMIC3\" />\n        <ctl name=\"SLIM_0_TX Channels\" value=\"Two\" />\n    </path>\n\n    <path name=\"dmic-broadside\">\n        <path name=\"speaker-dmic-broadside\" />\n        <ctl name=\"IIR1 INP1 MUX\" value=\"DEC6\" />\n    </path>\n\n    <path name=\"voice-speaker-dmic-broadside\">\n        <path name=\"dmic-broadside\" />\n    </path>\n\n    <!-- Quad MIC devices -->\n    <path name=\"speaker-qmic\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX9\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX10\" value=\"1\" />\n        <ctl name=\"SLIM_0_TX Channels\" value=\"Four\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC7\" />\n        <ctl name=\"DEC7 MUX\" value=\"DMIC1\" />\n        <ctl name=\"SLIM TX8 MUX\" value=\"DEC10\" />\n        <ctl name=\"DEC10 MUX\" value=\"DMIC3\" />\n        <ctl name=\"SLIM TX9 MUX\" value=\"DEC8\" />\n        <ctl name=\"DEC8 MUX\" value=\"DMIC2\" />\n        <ctl name=\"SLIM TX10 MUX\" value=\"DEC9\" />\n        <ctl name=\"DEC9 MUX\" value=\"DMIC4\" />\n    </path>\n\n    <path name=\"speaker-qmic-cdp\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX9\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX10\" value=\"1\" />\n        <ctl name=\"SLIM_0_TX Channels\" value=\"Four\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC9\" />\n        <ctl name=\"DEC9 MUX\" value=\"DMIC4\" />\n        <ctl name=\"SLIM TX8 MUX\" value=\"DEC10\" />\n        <ctl name=\"DEC10 MUX\" value=\"DMIC3\" />\n        <ctl name=\"SLIM TX9 MUX\" value=\"DEC7\" />\n        <ctl name=\"DEC7 MUX\" value=\"DMIC1\" />\n        <ctl name=\"SLIM TX10 MUX\" value=\"DEC6\" />\n        <ctl name=\"DEC6 MUX\" value=\"DMIC6\" />\n    </path>\n\n    <path name=\"speaker-qmic-liquid\">\n        <ctl name=\"AIF1_CAP Mixer SLIM TX7\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX8\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX9\" value=\"1\" />\n        <ctl name=\"AIF1_CAP Mixer SLIM TX10\" value=\"1\" />\n        <ctl name=\"SLIM_0_TX Channels\" value=\"Four\" />\n        <ctl name=\"SLIM TX7 MUX\" value=\"DEC9\" />\n        <ctl name=\"DEC9 MUX\" value=\"DMIC4\" />\n        <ctl name=\"SLIM TX8 MUX\" value=\"DEC10\" />\n        <ctl name=\"DEC10 MUX\" value=\"DMIC3\" />\n        <ctl name=\"SLIM TX9 MUX\" value=\"DEC8\" />\n        <ctl name=\"DEC8 MUX\" value=\"DMIC2\" />\n        <ctl name=\"SLIM TX10 MUX\" value=\"DEC6\" />\n        <ctl name=\"DEC6 MUX\" value=\"DMIC6\" />\n    </path>\n\n    <path name=\"voice-speaker-qmic\">\n        <path name=\"speaker-qmic\" />\n    </path>\n\n    <path name=\"quad-mic\">\n        <path name=\"speaker-qmic\" />\n    </path>\n\n    <path name=\"voice-speaker-qmic-cdp\">\n        <path name=\"speaker-qmic-cdp\" />\n    </path>\n\n    <path name=\"quad-mic-cdp\">\n        <path name=\"speaker-qmic-cdp\" />\n    </path>\n    <path name=\"voice-speaker-qmic-liquid\">\n        <path name=\"speaker-qmic-liquid\" />\n    </path>\n\n    <path name=\"quad-mic-liquid\">\n        <path name=\"speaker-qmic-liquid\" />\n    </path>\n\n    <!-- TTY devices -->\n    <path name=\"tty-headphones\">\n        <ctl name=\"SLIM RX1 MUX\" value=\"AIF1_PB\" />\n        <ctl name=\"SLIM_0_RX Channels\" value=\"One\" />\n        <ctl name=\"RX1 MIX1 INP1\" value=\"RX1\" />\n        <ctl name=\"CLASS_H_DSM MUX\" value=\"DSM_HPHL_RX1\" />\n        <ctl name=\"HPHL DAC Switch\" value=\"1\" />\n        <ctl name=\"COMP1 Switch\" value=\"1\" />\n        <ctl name=\"HPHL Volume\" value=\"20\" />\n    </path>\n\n    <path name=\"voice-tty-full-headphones\">\n        <ctl name=\"TTY Mode\" value=\"FULL\" />\n        <path name=\"tty-headphones\" />\n    </path>\n\n    <path name=\"voice-tty-vco-headphones\">\n        <ctl name=\"TTY Mode\" value=\"VCO\" />\n        <path name=\"tty-headphones\" />\n    </path>\n\n    <path name=\"voice-tty-hco-handset\">\n        <ctl name=\"TTY Mode\" value=\"HCO\" />\n        <path name=\"handset\" />\n    </path>\n\n    <path name=\"voice-tty-full-headset-mic\">\n        <path name=\"adc2\" />\n        <ctl name=\"ADC2 Volume\" value=\"12\" />\n    </path>\n\n    <path name=\"voice-tty-hco-headset-mic\">\n        <path name=\"voice-tty-full-headset-mic\" />\n    </path>\n\n    <path name=\"voice-tty-vco-handset-mic\">\n        <path name=\"dmic1\" />\n    </path>\n\n    <path name=\"listen-handset-mic\">\n        <ctl name=\"MADONOFF Switch\" value=\"1\" />\n        <ctl name=\"MAD Input\" value=\"DMIC1\" />\n    </path>\n\n    <!-- Added for ADSP testfwk -->\n    <path name=\"ADSP testfwk\">\n        <ctl name=\"SLIMBUS_DL_HL Switch\" value=\"1\" />\n    </path>\n\n    <path name=\"voice-rx\">\n    </path>\n\n    <path name=\"voice-tx\">\n    </path>\n\n</mixer>\n"
  },
  {
    "path": "audio/sound_trigger_mixer_paths.xml",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<!--- Copyright (c) 2014, The Linux Foundation. All rights reserved.            -->\n<!---                                                                           -->\n<!--- Redistribution and use in source and binary forms, with or without        -->\n<!--- modification, are permitted provided that the following conditions are    -->\n<!--- met:                                                                      -->\n<!---     * Redistributions of source code must retain the above copyright      -->\n<!---       notice, this list of conditions and the following disclaimer.       -->\n<!---     * Redistributions in binary form must reproduce the above             -->\n<!---       copyright notice, this list of conditions and the following         -->\n<!---       disclaimer in the documentation and/or other materials provided     -->\n<!---       with the distribution.                                              -->\n<!---     * Neither the name of The Linux Foundation nor the names of its       -->\n<!---       contributors may be used to endorse or promote products derived     -->\n<!---       from this software without specific prior written permission.       -->\n<!---                                                                           -->\n<!--- THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED              -->\n<!--- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF      -->\n<!--- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT    -->\n<!--- ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS    -->\n<!--- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    -->\n<!--- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      -->\n<!--- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR           -->\n<!--- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,     -->\n<!--- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE      -->\n<!--- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN    -->\n<!--- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                             -->\n\n<mixer>\n    <!-- These are the initial mixer settings -->\n    <ctl name=\"LSM1 MUX\" value=\"None\" />\n    <ctl name=\"LSM2 MUX\" value=\"None\" />\n    <ctl name=\"LSM3 MUX\" value=\"None\" />\n    <ctl name=\"LSM4 MUX\" value=\"None\" />\n    <ctl name=\"LSM5 MUX\" value=\"None\" />\n    <ctl name=\"LSM6 MUX\" value=\"None\" />\n    <ctl name=\"LSM7 MUX\" value=\"None\" />\n    <ctl name=\"LSM8 MUX\" value=\"None\" />\n    <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"None\" />\n    <ctl name=\"MADONOFF Switch\" value=\"0\" />\n    <ctl name=\"MAD Input\" value=\"DMIC1\" />\n\n    <path name=\"listen-voice-wakeup-1\">\n        <ctl name=\"LSM1 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n\n    <path name=\"listen-voice-wakeup-2\">\n        <ctl name=\"LSM2 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-3\">\n        <ctl name=\"LSM3 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-4\">\n        <ctl name=\"LSM4 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-5\">\n        <ctl name=\"LSM5 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-6\">\n        <ctl name=\"LSM6 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-7\">\n        <ctl name=\"LSM7 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n    <path name=\"listen-voice-wakeup-8\">\n        <ctl name=\"LSM8 MUX\" value=\"SLIMBUS_5_TX\" />\n        <ctl name=\"SLIMBUS_5_TX LSM Function\" value=\"AUDIO\" />\n    </path>\n\n    <path name=\"listen-handset-mic\">\n        <ctl name=\"MADONOFF Switch\" value=\"1\" />\n        <ctl name=\"MAD Input\" value=\"DMIC1\" />\n    </path>\n\n</mixer>\n"
  },
  {
    "path": "audio/sound_trigger_platform_info.xml",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<!--- Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.       -->\n<!---                                                                           -->\n<!--- Redistribution and use in source and binary forms, with or without        -->\n<!--- modification, are permitted provided that the following conditions are    -->\n<!--- met:                                                                      -->\n<!---     * Redistributions of source code must retain the above copyright      -->\n<!---       notice, this list of conditions and the following disclaimer.       -->\n<!---     * Redistributions in binary form must reproduce the above             -->\n<!---       copyright notice, this list of conditions and the following         -->\n<!---       disclaimer in the documentation and/or other materials provided     -->\n<!---       with the distribution.                                              -->\n<!---     * Neither the name of The Linux Foundation nor the names of its       -->\n<!---       contributors may be used to endorse or promote products derived     -->\n<!---       from this software without specific prior written permission.       -->\n<!---                                                                           -->\n<!--- THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED              -->\n<!--- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF      -->\n<!--- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT    -->\n<!--- ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS    -->\n<!--- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    -->\n<!--- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      -->\n<!--- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR           -->\n<!--- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,     -->\n<!--- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE      -->\n<!--- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN    -->\n<!--- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                             -->\n<sound_trigger_platform_info>\n    <device name=\"DEVICE_HANDSET_APE_ACDB_ID\" value=\"100\" />\n    <device name=\"DEVICE_HANDSET_CPE_ACDB_ID\" value=\"128\" />\n    <ctrl name=\"execution_type\" value=\"CPE\" /> <!-- value: \"CPE\" \"APE\" -->\n    <ctrl name=\"max_cpe_sessions\" value=\"1\" />\n    <ctrl name=\"max_cpe_phrases\" value=\"6\" />\n    <ctrl name=\"max_cpe_users\" value=\"3\" />\n    <ctrl name=\"max_ape_sessions\" value=\"8\" />\n    <ctrl name=\"max_ape_phrases\" value=\"10\" />\n    <ctrl name=\"max_ape_users\" value=\"10\" />\n    <ctrl name=\"enable_failure_detection\" value=\"false\" />\n    <ctrl name=\"enable_transition\" value=\"false\" />\n</sound_trigger_platform_info>\n\n"
  },
  {
    "path": "bluetooth/bdroid_buildcfg.h",
    "content": "/*\n * Copyright (C) 2014 The CyanogenMod Project <http://www.cyanogenmod.org>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef _BDROID_BUILDCFG_H\n#define _BDROID_BUILDCFG_H\n\n#define BTM_DEF_LOCAL_NAME   \"OnePlus 2\"\n// Disables read remote device feature\n#define BTA_SKIP_BLE_READ_REMOTE_FEAT FALSE\n#define MAX_ACL_CONNECTIONS    7\n#define MAX_L2CAP_CHANNELS    16\n#define BLE_VND_INCLUDED   TRUE\n// skips conn update at conn completion\n#define BTA_BLE_SKIP_CONN_UPD  FALSE\n#define BLE_PERIPHERAL_ADV_NAME  FALSE\n#define BT_CLEAN_TURN_ON_DISABLED 1\n#endif\n"
  },
  {
    "path": "board-info.txt",
    "content": "require version-trustzone=TZ.BF.3.0.R1-00201\n"
  },
  {
    "path": "camera/Android.mk",
    "content": "# Copyright (C) 2008 The Android Open Source Project\r\n#\r\n# Licensed under the Apache License, Version 2.0 (the \"License\");\r\n# you may not use this file except in compliance with the License.\r\n# You may obtain a copy of the License at\r\n#\r\n#      http://www.apache.org/licenses/LICENSE-2.0\r\n#\r\n# Unless required by applicable law or agreed to in writing, software\r\n# distributed under the License is distributed on an \"AS IS\" BASIS,\r\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n# See the License for the specific language governing permissions and\r\n# limitations under the License.\r\n\r\nLOCAL_PATH := $(call my-dir)\r\n\r\ninclude $(CLEAR_VARS)\r\n\r\nLOCAL_MODULE := sensors.hal.tof\r\n\r\nLOCAL_C_INCLUDES := kernel/include/linux/input\r\n\r\nLOCAL_MODULE_RELATIVE_PATH := hw\r\n\r\nLOCAL_MODULE_TAGS := optional\r\n\r\nLOCAL_CFLAGS := -DLOG_TAG=\\\"Sensors\\\"\r\nLOCAL_SRC_FILES := \\\r\n    sensors.cpp \\\r\n    SensorBase.cpp \\\r\n    ProximitySensor.cpp \\\r\n    InputEventReader.cpp\r\n\r\nLOCAL_SHARED_LIBRARIES := liblog libcutils\r\nLOCAL_PRELINK_MODULE := false\r\n\r\ninclude $(BUILD_SHARED_LIBRARY)\r\n\r\ninclude $(CLEAR_VARS)\r\n\r\nLOCAL_C_INCLUDES := \\\r\n    system/media/camera/include\r\n\r\nLOCAL_SRC_FILES := \\\r\n    CameraWrapper.cpp\r\n\r\nLOCAL_SHARED_LIBRARIES := \\\r\n    libhardware liblog libgui libutils\r\n\r\nLOCAL_MODULE_RELATIVE_PATH := hw\r\nLOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM)\r\nLOCAL_MODULE_TAGS := optional\r\n\r\ninclude $(BUILD_SHARED_LIBRARY)\r\n"
  },
  {
    "path": "camera/CameraWrapper.cpp",
    "content": "/* Copyright (C) 2016, The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n* @file CameraWrapper.cpp\n*\n* This file wraps a vendor camera module.\n*\n*/\n\n//#define LOG_NDEBUG 0\n\n#define LOG_TAG \"CameraWrapper\"\n#include <cutils/log.h>\n\n#include <dlfcn.h>\n#include <hardware/hardware.h>\n#include <hardware/camera.h>\n#include <utils/threads.h>\n#include <gui/SensorManager.h>\n\nstatic android::Mutex gCameraWrapperLock;\nstatic camera_module_t *gVendorModule = 0;\n\nstatic int camera_device_open(const hw_module_t *module, const char *name,\n        hw_device_t **device);\nstatic int camera_get_number_of_cameras(void);\nstatic int camera_get_camera_info(int camera_id, struct camera_info *info);\n\nstatic struct hw_module_methods_t camera_module_methods = {\n    .open = camera_device_open\n};\n\ncamera_module_t HAL_MODULE_INFO_SYM = {\n    .common = {\n         .tag = HARDWARE_MODULE_TAG,\n         .module_api_version = CAMERA_MODULE_API_VERSION_1_0,\n         .hal_api_version = HARDWARE_HAL_API_VERSION,\n         .id = CAMERA_HARDWARE_MODULE_ID,\n         .name = \"OnePlus 2 Camera Wrapper\",\n         .author = \"The CyanogenMod Project\",\n         .methods = &camera_module_methods,\n         .dso = NULL, /* remove compilation warnings */\n         .reserved = {0}, /* remove compilation warnings */\n    },\n    .get_number_of_cameras = camera_get_number_of_cameras,\n    .get_camera_info = camera_get_camera_info,\n    .set_callbacks = NULL, /* remove compilation warnings */\n    .get_vendor_tag_ops = NULL, /* remove compilation warnings */\n    .open_legacy = NULL, /* remove compilation warnings */\n    .set_torch_mode = NULL, /* remove compilation warnings */\n    .init = NULL, /* remove compilation warnings */\n    .reserved = {0}, /* remove compilation warnings */\n};\n\nstatic int load(const char *path,\n        const struct hw_module_t **pHmi)\n{\n    int status = 0;\n    void *handle = NULL;\n    struct hw_module_t *hmi = NULL;\n\n    handle = dlopen(path, RTLD_NOW);\n    if (handle == NULL) {\n        status = -EINVAL;\n        goto done;\n    }\n\n    hmi = (struct hw_module_t *)dlsym(handle,\n        HAL_MODULE_INFO_SYM_AS_STR);\n    if (hmi == NULL) {\n        status = -EINVAL;\n        goto done;\n    }\n\n    hmi->dso = handle;\n\n    done:\n    *pHmi = hmi;\n\n    return status;\n}\n\nstatic int check_vendor_module()\n{\n    int rv = 0;\n    ALOGV(\"%s\", __FUNCTION__);\n\n    if (gVendorModule)\n        return 0;\n\n    rv = load(\"/system/lib/hw/camera.vendor.msm8994.so\",\n            (const hw_module_t**)&gVendorModule);\n    if (rv)\n        ALOGE(\"failed to open vendor camera module\");\n    return rv;\n}\n\nstatic int camera_device_open(const hw_module_t *module __unused, const char *name,\n        hw_device_t **device)\n{\n    int rv = 0;\n    int num_cameras = 0;\n    int cameraid;\n    int cameraretry;\n\n    android::Mutex::Autolock lock(gCameraWrapperLock);\n\n    ALOGV(\"%s\", __FUNCTION__);\n\n    if (name == NULL || check_vendor_module() != android::NO_ERROR) {\n        return -EINVAL;\n    }\n\n    for (cameraretry = 0; cameraretry < 2; cameraretry++) {\n         rv = gVendorModule->common.methods->open(\n                 (const hw_module_t*)gVendorModule, name,\n                 device);\n         if (!rv)\n             break;\n\n         ALOGV(\"%s: open failed - retrying attempt %d\",__FUNCTION__, cameraretry);\n    }\n\n    if (rv)\n        ALOGE(\"vendor camera open fail\");\n\n    return rv;\n}\n\nstatic int camera_get_number_of_cameras(void)\n{\n    ALOGV(\"%s\", __FUNCTION__);\n    if (check_vendor_module())\n        return 0;\n    return gVendorModule->get_number_of_cameras();\n}\n\nstatic int camera_get_camera_info(int camera_id, struct camera_info *info)\n{\n    ALOGV(\"%s\", __FUNCTION__);\n    if (check_vendor_module())\n        return 0;\n\n    return gVendorModule->get_camera_info(camera_id, info);\n}\n"
  },
  {
    "path": "camera/InputEventReader.cpp",
    "content": "/*\r\n * Copyright (C) 2014 STMicroelectronics, Inc.\r\n * Copyright (C) 2008 The Android Open Source Project\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#include <stdint.h>\r\n#include <errno.h>\r\n#include <unistd.h>\r\n#include <poll.h>\r\n\r\n#include <sys/cdefs.h>\r\n#include <sys/types.h>\r\n\r\n#include <linux/input.h>\r\n\r\n#include <cutils/log.h>\r\n\r\n#include \"InputEventReader.h\"\r\n\r\n/*****************************************************************************/\r\n\r\nstruct input_event;\r\n\r\nInputEventCircularReader::InputEventCircularReader(size_t numEvents)\r\n    : mBuffer(new input_event[numEvents * 2]),\r\n      mBufferEnd(mBuffer + numEvents),\r\n      mHead(mBuffer),\r\n      mCurr(mBuffer),\r\n      mFreeSpace(numEvents)\r\n{\r\n}\r\n\r\nInputEventCircularReader::~InputEventCircularReader()\r\n{\r\n    delete [] mBuffer;\r\n}\r\n\r\nssize_t InputEventCircularReader::fill(int fd)\r\n{\r\n    size_t numEventsRead = 0;\r\n    if (mFreeSpace) {\r\n        const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event));\r\n        if (nread<0 || nread % sizeof(input_event)) {\r\n            // we got a partial event!!\r\n            return nread<0 ? -errno : -EINVAL;\r\n        }\r\n\r\n        numEventsRead = nread / sizeof(input_event);\r\n        if (numEventsRead) {\r\n            mHead += numEventsRead;\r\n            mFreeSpace -= numEventsRead;\r\n            if (mHead > mBufferEnd) {\r\n                size_t s = mHead - mBufferEnd;\r\n                memcpy(mBuffer, mBufferEnd, s * sizeof(input_event));\r\n                mHead = mBuffer + s;\r\n            }\r\n        }\r\n    }\r\n\r\n    return numEventsRead;\r\n}\r\n\r\nssize_t InputEventCircularReader::readEvent(input_event const** events)\r\n{\r\n    *events = mCurr;\r\n    ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace;\r\n    return available ? 1 : 0;\r\n}\r\n\r\nvoid InputEventCircularReader::next()\r\n{\r\n    mCurr++;\r\n    mFreeSpace++;\r\n    if (mCurr >= mBufferEnd) {\r\n        mCurr = mBuffer;\r\n    }\r\n}\r\n"
  },
  {
    "path": "camera/InputEventReader.h",
    "content": "/*\r\n * Copyright (C) 2013 STMicroelectronics, Inc.\r\n * Copyright (C) 2008 The Android Open Source Project\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#ifndef ANDROID_INPUT_EVENT_READER_H\r\n#define ANDROID_INPUT_EVENT_READER_H\r\n\r\n#include <stdint.h>\r\n#include <errno.h>\r\n#include <sys/cdefs.h>\r\n#include <sys/types.h>\r\n\r\n#include <string.h>\r\n\r\n/*****************************************************************************/\r\n\r\nstruct input_event;\r\n\r\nclass InputEventCircularReader\r\n{\r\n    struct input_event* const mBuffer;\r\n    struct input_event* const mBufferEnd;\r\n    struct input_event* mHead;\r\n    struct input_event* mCurr;\r\n    ssize_t mFreeSpace;\r\n\r\npublic:\r\n    InputEventCircularReader(size_t numEvents);\r\n    ~InputEventCircularReader();\r\n    ssize_t fill(int fd);\r\n    ssize_t readEvent(input_event const** events);\r\n    void next();\r\n};\r\n\r\n/*****************************************************************************/\r\n\r\n#endif  // ANDROID_INPUT_EVENT_READER_H"
  },
  {
    "path": "camera/ProximitySensor.cpp",
    "content": "/*\r\n * Copyright (C) 2014 STMicroelectronics, Inc.\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#include <fcntl.h>\r\n#include <errno.h>\r\n#include <math.h>\r\n#include <poll.h>\r\n#include <unistd.h>\r\n#include <dirent.h>\r\n#include <sys/select.h>\r\n#include <cutils/log.h>\r\n#include <linux/input.h>\r\n\r\n#include \"configuration.h\"\r\n#include \"ProximitySensor.h\"\r\n\r\n//#define FETCH_FULL_EVENT_BEFORE_RETURN 1\r\n\r\n/*****************************************************************************/\r\n\r\nProximitySensor::ProximitySensor()\r\n    : SensorBase(NULL, \"STM VL6180 proximity sensor\"),\r\n      mEnabled(0),\r\n\t  mBatchEnabled(0),\r\n      mInputReader(4),\r\n      mHasPendingEvent(false)\r\n{\r\n    //Added for debug\r\n    LOGV(\"ProximitySensor::ProximitySensor gets called!\");\r\n\r\n    mPendingEvent.version = sizeof(sensors_event_t);\r\n    mPendingEvent.sensor = ID_P;\r\n    mPendingEvent.type = SENSOR_TYPE_TIME_OF_FLIGHT;\r\n    memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));\r\n\r\n    if (data_fd) {\r\n        strcpy(input_sysfs_path, \"/sys/class/input/\");\r\n        strcat(input_sysfs_path, \"input\");\r\n        strcat(input_sysfs_path, input_name+5);\r\n        strcat(input_sysfs_path, \"/device/\");\r\n        input_sysfs_path_len = strlen(input_sysfs_path);\r\n\t LOGV(\"ProximitySensor: input_name:%s, input_sysfs_path:%s\",input_name,input_sysfs_path);\r\n        enable(0, 1);\r\n    }else\r\n    \tLOGV(\"%s:%d wrong fd\", __func__, __LINE__);\r\n}\r\n\r\nProximitySensor::~ProximitySensor() {\r\n    if (mEnabled) {\r\n        enable(0, 0);\r\n    }\r\n}\r\n\r\nint ProximitySensor::setInitialState() {\r\n    struct input_absinfo absinfo;\r\n\tint rc;\r\n\r\n\trc = ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PROXIMITY), &absinfo);\r\n    if (!rc ) {\r\n\t\tLOGE(\"%s:%d Pend event successfully!\", __func__, __LINE__);\r\n        mHasPendingEvent = true;\r\n\t\tmPendingEvent.distance = absinfo.value;\r\n\t\treturn 0;\r\n    }\r\n    else{\r\n\t\tLOGV(\"%s:%d Pend event failed!\", __func__, __LINE__);\r\n    \treturn rc;\r\n    }\r\n}\r\n\r\nint ProximitySensor::enable(int32_t, int en) {\r\n\r\n    //Added for debug\r\n    LOGE(\"ProximitySensor::enable function called for stmvl6180 %d!\", en);\r\n\r\n    char buf[2];\r\n    int err;\r\n\r\n    int flags = en ? 1 : 0;\r\n    if (flags != mEnabled) {\r\n        int fd;\r\n        //strcpy(&input_sysfs_path[input_sysfs_path_len], \"enable\");\r\n        //fd = open(input_sysfs_path, O_RDWR);\r\n\tfd = open(PROXIMITY_ENABLE_FILENAME_CCI, O_RDWR);\r\n\tif(fd < 0){\r\n\t\tLOGE(\"%s:%d open %s failed(%s), try to open %s\", __func__, __LINE__, PROXIMITY_ENABLE_FILENAME_CCI, strerror(errno), PROXIMITY_ENABLE_FILENAME_I2C);\r\n\t\tfd = open(PROXIMITY_ENABLE_FILENAME_I2C, O_RDWR);\r\n\t}\r\n\r\n        if (fd >= 0) {\r\n            buf[1] = 0;\r\n            if (flags) {\r\n                buf[0] = '1';\r\n            } else {\r\n                buf[0] = '0';\r\n        \t}\r\n\t    LOGV(\"%s:%d fd = %d, flags = %d\", __func__, __LINE__, fd, flags);\r\n\r\n           err = write(fd, buf, sizeof(buf));\r\n\t    LOGV(\"%s:%d after write\", __func__, __LINE__, fd, flags);\r\n\t    if(err <= 0){\r\n\t\tLOGE(\"%s:%d write %d failed: %s\", __func__, __LINE__, fd, strerror(errno));\r\n\t       close(fd);\r\n\t\treturn err;\r\n\t    }\r\n\t    else\r\n\t\tLOGV(\"%s:%d write successfully!\", __func__, __LINE__, fd, flags);\r\n\r\n            close(fd);\r\n            mEnabled = flags;\r\n            setInitialState();\r\n\t    \t//Added for debug\r\n\t    \tLOGV(\"ProximitySensor::enable enabled VL6180! Error code(2 should indicate success): %d\", err);\r\n            return 0;\r\n        }\r\n        LOGV(\"ProximitySensor::enable: Failed to open %s for enabling VL6180 %s\", PROXIMITY_ENABLE_FILENAME_I2C, strerror(errno));\r\n        LOGV(\"ProximitySensor::enable: Attempted to open file %s\", input_sysfs_path);\r\n        return -1;\r\n    }\r\n    return 0;\r\n}\r\n\r\nbool ProximitySensor::hasPendingEvents() const {\r\n    return mHasPendingEvent;\r\n}\r\n\r\nint ProximitySensor::batch(int handle, int flags, int64_t period_ns, int64_t timeout)\r\n{\r\n   \tint err;\r\n\r\n \tif (period_ns > 0)\r\n\t{\r\n        int fd;\r\n\t \tfd = open(PROXIMITY_SET_DELAY_FILENAME_CCI, O_RDWR);\r\n\t \tif(fd < 0){\r\n\t\t\tLOGE(\"%s:%d open %s failed(%s), try to open %s\", __func__, __LINE__, PROXIMITY_SET_DELAY_FILENAME_CCI, strerror(errno), PROXIMITY_SET_DELAY_FILENAME_I2C);\r\n\t\t\tfd = open(PROXIMITY_SET_DELAY_FILENAME_I2C, O_RDWR);\r\n\t \t}\r\n        if (fd >= 0) {\r\n\t\t   \tchar buf[80];\r\n\t\t\tsprintf(buf,\"%lld\", period_ns / 1000000);\r\n            err = write(fd, buf, strlen(buf)+1);\r\n            close(fd);\r\n\t    \t//Added for debug\r\n\t    \tLOGV(\"ProximitySensor::batch return: %d\", err);\r\n            return 0;\r\n        }\r\n        LOGV(\"ProximitySensor::batch: Failed to open %s for set delay time(%s)\", PROXIMITY_SET_DELAY_FILENAME_I2C, strerror(errno));\r\n        return -1;\r\n    }\r\n    return 0;\r\n\r\n}\r\n\r\nint ProximitySensor::setDelay(int32_t handle, int64_t delay_ns)\r\n{\r\n    LOGV(\"ProximitySensor::setDelay called!\");\r\n    int fd;\r\n    strcpy(&input_sysfs_path[input_sysfs_path_len], \"pollrate_ms\");\r\n    fd = open(input_sysfs_path, O_RDWR);\r\n    if (fd >= 0) {\r\n        char buf[80];\r\n        sprintf(buf, \"%lld\", delay_ns / 1000000);\r\n        write(fd, buf, strlen(buf)+1);\r\n        close(fd);\r\n\t\t//Added for debug\r\n\t\tLOGV(\"ProximitySensor::setDelay is successful!\");\r\n        return 0;\r\n    }\r\n    LOGV(\"ProximitySensor::setDelay failed!\");\r\n    return -1;\r\n}\r\n\r\nint ProximitySensor::readEvents(sensors_event_t* data, int count)\r\n{\r\n\r\n    //Added for debug\r\n\r\n    if (count < 1)\r\n        return -EINVAL;\r\n\r\n    if (mHasPendingEvent) {\r\n        mHasPendingEvent = false;\r\n        mPendingEvent.timestamp = getTimestamp();\r\n        *data = mPendingEvent;\r\n        return mEnabled ? 1 : 0;\r\n    }\r\n\r\n    ssize_t n = mInputReader.fill(data_fd);\r\n    if (n < 0){\r\n        LOGE(\"ProximitySensor::readEvents: Did not successfully read an event, error: %d\", n);\r\n        return n;\r\n    }\r\n\r\n    int numEventReceived = 0;\r\n    input_event const* event;\r\n\r\n#if FETCH_FULL_EVENT_BEFORE_RETURN\r\nagain:\r\n#endif\r\n    LOGV(\"ProximitySensor::readEvents: At readEvent loop, probably was able to read at least one event successfully\");\r\n    while (count && mInputReader.readEvent(&event)) {\r\n        int type = event->type;\r\n        if (type == EV_ABS) {\r\n            if (event->code == EVENT_TYPE_PROXIMITY) { //ABS_DISTANCE\r\n               if (event->value != -1) {\r\n                    // FIXME: not sure why we're getting -1 sometimes\r\n                    //mPendingEvent.distance = indexToValue(event->value);\r\n\t\t    \t\t//mPendingEvent.distance = event->value;\r\n\t\t    \t\tmPendingEvent.data[0] = event->value;\r\n\t\t    \t\tLOGE(\"%s:%d mPendingEvent.data[0] = %d\",__func__, __LINE__, event->value);\r\n                }\r\n            }\r\n\t\t\t/*\r\n\t    \telse if (event->code == ABS_X)\r\n\t\t\t\tmPendingEvent.data[1] = event->value;\r\n\t    \telse if (event->code == ABS_HAT0X)\r\n\t\t\t\tmPendingEvent.data[2] = event->value;\r\n\t\t\t*/\r\n\r\n\t\t    else if (event->code == ABS_HAT0X){\r\n\t\t\t\tmPendingEvent.data[1] = event->value;\r\n\t\t\t\tLOGV(\"%s:%d mPendingEvent.data[1] = %d\",__func__, __LINE__, event->value);\r\n\r\n\t\t\t}\r\n\t\t    else if (event->code == ABS_HAT0Y){\r\n\t\t\t\tmPendingEvent.data[2] = event->value;\r\n\t\t\t\tLOGV(\"%s:%d mPendingEvent.data[2] = %d\",__func__, __LINE__, event->value);\r\n\r\n\t\t\t}\r\n\t\t    else if (event->code == ABS_HAT1X){\r\n\t\t\t\tmPendingEvent.data[3] = event->value;\r\n\t\t\t\tLOGV(\"%s:%d mPendingEvent.data[3] = %d\",__func__, __LINE__, event->value);\r\n\r\n\t\t\t}\r\n\t\t    else if (event->code == ABS_HAT1Y){\r\n\t\t\t\tmPendingEvent.data[4] = event->value;\r\n\t\t\t\tLOGV(\"%s:%d mPendingEvent.data[4] = %d\",__func__, __LINE__, event->value);\r\n\r\n\t\t\t}\r\n\t\t    else if (event->code == ABS_HAT2X){\r\n\t\t\t\tmPendingEvent.data[5] = event->value;\r\n\t\t\t\tLOGV(\"%s:%d mPendingEvent.data[5] = %d\",__func__, __LINE__, event->value);\r\n\r\n\t\t\t}\r\n\t\t    else if (event->code == ABS_HAT2Y){\r\n\t\t\t\tmPendingEvent.data[6] = event->value;\r\n\t\t\t\tLOGV(\"%s:%d mPendingEvent.data[6] = %d\",__func__, __LINE__, event->value);\r\n\r\n\t\t\t}\r\n\t\t    else if (event->code == ABS_HAT3X){\r\n\t\t\t\tmPendingEvent.data[7] = event->value;\r\n\t\t\t\tLOGV(\"%s:%d mPendingEvent.data[7] = %d\",__func__, __LINE__, event->value);\r\n\r\n\t\t\t}\r\n\t\t    else if (event->code == ABS_HAT3Y){\r\n\t\t\t\tmPendingEvent.data[8] = event->value;\r\n\t\t\t\tLOGV(\"%s:%d mPendingEvent.data[8] = %d\",__func__, __LINE__, event->value);\r\n\r\n\t\t\t}\r\n\r\n            LOGV(\"ProximitySensor: gets one ps data event!\");\r\n        }\r\n\t\telse if (type == EV_SYN) {\r\n            mPendingEvent.timestamp = timevalToNano(event->time);\r\n            if (mEnabled) {\r\n                *data++ = mPendingEvent;\r\n                numEventReceived++;\r\n                count--;\r\n\t        //Added for debug\r\n\t\tLOGV(\"ProximitySensor: gets one ps sync event!\");\r\n            }\r\n        } else {\r\n            LOGV(\"ProximitySensor: unknown event (type=%d, code=%d)\",\r\n                    type, event->code);\r\n        }\r\n        mInputReader.next();\r\n    }\r\n#if 0\r\n\tLOGV(\"HAL: distance: %f cm tv_sec: %f tv_usec: %f \"\r\n      \"distance: %fmm error_code: %x signalRate_mcps: %f \"\r\n      \"rtnAmbRate(kcps): %f rtnConvTime: %f dmax_sq: %f\",\r\n      mPendingEvent.data[0], mPendingEvent.data[1], mPendingEvent.data[2], mPendingEvent.data[3],\r\n      mPendingEvent.data[4], mPendingEvent.data[5], mPendingEvent.data[6],mPendingEvent.data[7],\r\n      mPendingEvent.data[8]);\r\n#endif\r\n\r\n#if FETCH_FULL_EVENT_BEFORE_RETURN\r\n    /* if we didn't read a complete event, see if we can fill and\r\n       try again instead of returning with nothing and redoing poll. */\r\n    if (numEventReceived == 0 && mEnabled == 1) {\r\n        n = mInputReader.fill(data_fd);\r\n        if (n)\r\n            goto again;\r\n    }\r\n#endif\r\n\r\n    return numEventReceived;\r\n}\r\n\r\n\r\n"
  },
  {
    "path": "camera/ProximitySensor.h",
    "content": "/*\r\n * Copyright (C) 2014 STMicroelectronics, Inc.\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#ifndef ANDROID_PROXIMITY_SENSOR_H\r\n#define ANDROID_PROXIMITY_SENSOR_H\r\n\r\n#include <stdint.h>\r\n#include <errno.h>\r\n#include <sys/cdefs.h>\r\n#include <sys/types.h>\r\n\r\n#include \"sensors.h\"\r\n#include \"SensorBase.h\"\r\n#include \"InputEventReader.h\"\r\n\r\n/*****************************************************************************/\r\n\r\nstruct input_event;\r\n\r\nclass ProximitySensor : public SensorBase {\r\n    int mEnabled;\r\n\tint mBatchEnabled;\r\n    InputEventCircularReader mInputReader;\r\n    sensors_event_t mPendingEvent;\r\n    bool mHasPendingEvent;\r\n    char input_sysfs_path[PATH_MAX];\r\n    int input_sysfs_path_len;\r\n\r\n    int setInitialState();\r\n\r\npublic:\r\n            ProximitySensor();\r\n    virtual ~ProximitySensor();\r\n    virtual int readEvents(sensors_event_t* data, int count);\r\n    virtual bool hasPendingEvents() const;\r\n    virtual int setDelay(int32_t handle, int64_t ns);\r\n    virtual int enable(int32_t handle, int enabled);\r\n    virtual int batch(int handle, int flags, int64_t period_ns, int64_t timeout);\r\n};\r\n\r\n\r\n\r\n/*****************************************************************************/\r\n\r\n#endif  // ANDROID_PROXIMITY_SENSOR_H\r\n"
  },
  {
    "path": "camera/SensorBase.cpp",
    "content": "/*\r\n * Copyright (C) 2014 STMicroelectronice, Inc.\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#include <fcntl.h>\r\n#include <errno.h>\r\n#include <math.h>\r\n#include <poll.h>\r\n#include <unistd.h>\r\n#include <dirent.h>\r\n#include <sys/select.h>\r\n#include <cutils/log.h>\r\n#include <linux/input.h>\r\n\r\n#include \"SensorBase.h\"\r\n\r\n/*****************************************************************************/\r\n\r\nSensorBase::SensorBase(\r\n        const char* dev_name,\r\n        const char* data_name)\r\n    : dev_name(dev_name), data_name(data_name),\r\n      dev_fd(-1), data_fd(-1)\r\n{\r\n    if (data_name) {\r\n        data_fd = openInput(data_name);\r\n    }\r\n}\r\n\r\nSensorBase::~SensorBase() {\r\n    if (data_fd >= 0) {\r\n        close(data_fd);\r\n    }\r\n    if (dev_fd >= 0) {\r\n        close(dev_fd);\r\n    }\r\n}\r\n\r\nint SensorBase::open_device() {\r\n    if (dev_fd<0 && dev_name) {\r\n        dev_fd = open(dev_name, O_RDONLY);\r\n        LOGE_IF(dev_fd<0, \"Couldn't open %s (%s)\", dev_name, strerror(errno));\r\n    }\r\n    return 0;\r\n}\r\n\r\nint SensorBase::close_device() {\r\n    if (dev_fd >= 0) {\r\n        close(dev_fd);\r\n        dev_fd = -1;\r\n    }\r\n    return 0;\r\n}\r\n\r\nint SensorBase::getFd() const {\r\n    if (!data_name) {\r\n        return dev_fd;\r\n    }\r\n    return data_fd;\r\n}\r\n\r\nint SensorBase::setDelay(int32_t handle, int64_t ns) {\r\n    return 0;\r\n}\r\n\r\nbool SensorBase::hasPendingEvents() const {\r\n    return false;\r\n}\r\n\r\nint64_t SensorBase::getTimestamp() {\r\n    struct timespec t;\r\n    t.tv_sec = t.tv_nsec = 0;\r\n    clock_gettime(CLOCK_MONOTONIC, &t);\r\n    return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;\r\n}\r\n\r\nint SensorBase::openInput(const char* inputName) {\r\n    int fd = -1;\r\n    char devname[PATH_MAX] = \"/dev/stm_sensor\";\r\n    char *filename;\r\n    fd = open(devname, O_RDONLY);\r\n    if (fd>=0) {\r\n        char name[80];\r\n        if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {\r\n            name[0] = '\\0';\r\n        }\r\n        if (!strcmp(name, inputName)) {\r\n            strcpy(input_name, devname);\r\n        } else {\r\n            close(fd);\r\n            fd = -1;\r\n        }\r\n    }\r\n    LOGE_IF(fd<0, \"couldn't find '%s' input device\", inputName);\r\n    return fd;\r\n}\r\n\r\nint SensorBase::enable(int32_t handle, int enabled)\r\n{\r\n    return 0;\r\n}\r\n\r\nint SensorBase::query(int what, int* value)\r\n{\r\n    return 0;\r\n}\r\n\r\nint SensorBase::batch(int handle, int flags, int64_t period_ns, int64_t timeout)\r\n{\r\n    return 0;\r\n}\r\n"
  },
  {
    "path": "camera/SensorBase.h",
    "content": "/*\r\n * Copyright (C) 2014 STMicroelectronics, Inc.\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#ifndef ANDROID_SENSOR_BASE_H\r\n#define ANDROID_SENSOR_BASE_H\r\n\r\n#include <stdint.h>\r\n#include <errno.h>\r\n#include <sys/cdefs.h>\r\n#include <sys/types.h>\r\n\r\n#include <string.h>\r\n\r\n//#if defined ANDROID_JELLYBEAN\r\n//build for Jellybean\r\n#define LOGV_IF ALOGV_IF\r\n#define LOGE_IF ALOGE_IF\r\n#define LOGI_IF ALOGI_IF\r\n#define LOGI    ALOGI\r\n#define LOGE    ALOGE\r\n#define LOGV    ALOGV\r\n#define LOGW    ALOGW\r\n//#else\r\n//build for ICS or earlier version\r\n//#endif\r\n/*****************************************************************************/\r\n\r\nstruct sensors_event_t;\r\n\r\nclass SensorBase {\r\nprotected:\r\n    const char* dev_name;\r\n    const char* data_name;\r\n    char        input_name[PATH_MAX];\r\n    int         dev_fd;\r\n    int         data_fd;\r\n\r\n    int openInput(const char* inputName);\r\n    static int64_t getTimestamp();\r\n\r\n\r\n    static int64_t timevalToNano(timeval const& t) {\r\n        return t.tv_sec*1000000000LL + t.tv_usec*1000;\r\n    }\r\n\r\n    int open_device();\r\n    int close_device();\r\n\r\npublic:\r\n    SensorBase(const char* dev_name, const char* data_name);\r\n\r\n    virtual ~SensorBase();\r\n\r\n    virtual int readEvents(sensors_event_t* data, int count) = 0;\r\n    virtual bool hasPendingEvents() const;\r\n    virtual int getFd() const;\r\n    virtual int setDelay(int32_t handle, int64_t ns);\r\n    virtual int enable(int32_t handle, int enabled) = 0;\r\n    virtual int query(int what, int* value);\r\n    virtual int batch(int handle, int flags, int64_t period_ns, int64_t timeout);\r\n};\r\n\r\n/*****************************************************************************/\r\n\r\n#endif  // ANDROID_SENSOR_BASE_H\r\n"
  },
  {
    "path": "camera/configuration.h",
    "content": "/*\r\n * Copyright (C) 2014 STMicroelectronics, Inc.\r\n * Copyright (C) 2008 The Android Open Source Project\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#ifndef STM_SENSORS_CONFIGURATION_H\r\n#define STM_SENSORS_CONFIGURATION_H\r\n\r\n#include <stdint.h>\r\n#include <errno.h>\r\n#include <sys/cdefs.h>\r\n#include <sys/types.h>\r\n\r\n\r\n\r\n__BEGIN_DECLS\r\n\r\n#define SENSOR_PROXIMITY_LABEL \t\t\t\"Time of Flight Proximity Sensor\"\r\n#define SENSOR_PROXIMITY_DATANAME\t\t\"STM VL6180 proximity sensor\"\r\n#define PROXIMITY_ENABLE_FILENAME_CCI\t\t\"/sys/bus/platform/devices/29.qcom,proximity/enable_ps_sensor\"\r\n#define PROXIMITY_SET_DELAY_FILENAME_CCI    \"/sys/bus/platform/devices/29.qcom,proximity/set_delay_ms\"\r\n#define PROXIMITY_ENABLE_FILENAME_I2C\t\t\"/sys/bus/i2c/devices/i2c-6/6-0029/enable_ps_sensor\"\r\n#define PROXIMITY_SET_DELAY_FILENAME_I2C    \"/sys/bus/i2c/devices/i2c-6/6-0029/set_delay_ms\"\r\n#define PROXIMITY_MAX_RANGE\t\t\t\t76\r\n#define PROXIMITY_POWER_CONSUMPTION\t\t0.23f\r\n#define PROXIMITY_MIN_DELAY\t\t\t\t5000 //in microseconds\r\n#define PROXIMITY_FIFO_RESERVED_COUNT\t0\r\n#define PROXIMITY_FIFO_MAX_COUNT\t\t0\r\n#define SENSOR_TYPE_TIME_OF_FLIGHT      (30)\r\n__END_DECLS\r\n\r\n#endif  // ANDROID_SENSORS_H\r\n"
  },
  {
    "path": "camera/sensors.cpp",
    "content": "/*\r\n * Copyright (C) 2014 STMicroelectronics, Inc.\r\n * Copyright (C) 2008 The Android Open Source Project\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#define LOG_TAG \"Sensors\"\r\n\r\n#include <hardware/sensors.h>\r\n#include <fcntl.h>\r\n#include <errno.h>\r\n#include <dirent.h>\r\n#include <math.h>\r\n#include <poll.h>\r\n#include <pthread.h>\r\n#include <stdlib.h>\r\n#include <linux/input.h>\r\n\r\n\r\n#include <utils/Atomic.h>\r\n#include <utils/Log.h>\r\n\r\n#include \"sensors.h\"\r\n#include \"configuration.h\"\r\n\r\n#include \"ProximitySensor.h\"\r\n\r\n/*****************************************************************************/\r\n\r\n#define DELAY_OUT_TIME 0x7FFFFFFF\r\n\r\n\r\n/*\r\n#define SENSORS_ACCELERATION     (1<<ID_A)\r\n#define SENSORS_MAGNETIC_FIELD   (1<<ID_M)\r\n#define SENSORS_ORIENTATION      (1<<ID_O)\r\n#define SENSORS_LIGHT            (1<<ID_L)\r\n#define SENSORS_PROXIMITY        (1<<ID_P)\r\n#define SENSORS_GYROSCOPE        (1<<ID_GY)\r\n*/\r\n#define SENSORS_ACCELERATION_HANDLE     0\r\n#define SENSORS_MAGNETIC_FIELD_HANDLE   1\r\n#define SENSORS_ORIENTATION_HANDLE      2\r\n#define SENSORS_LIGHT_HANDLE            3\r\n#define SENSORS_PROXIMITY_HANDLE        4\r\n#define SENSORS_GYROSCOPE_HANDLE        5\r\n\r\n\r\n#define AKM_FTRACE 0\r\n#define AKM_DEBUG 0\r\n#define AKM_DATA 0\r\n\r\n/*****************************************************************************/\r\n\r\n/* The SENSORS Module */\r\nstatic const struct sensor_t sSensorList[] = {\r\n        { \tSENSOR_PROXIMITY_LABEL,\r\n          \t\"STMicroelectronics\",\r\n          \t1,\r\n\t\t\tSENSORS_PROXIMITY_HANDLE,\r\n\t  \t\tSENSOR_TYPE_TIME_OF_FLIGHT,\r\n\t\t\tPROXIMITY_MAX_RANGE,\r\n\t\t\t1,\r\n\t\t\tPROXIMITY_POWER_CONSUMPTION,\r\n\t\t\tPROXIMITY_MIN_DELAY,\r\n\t\t\tPROXIMITY_FIFO_RESERVED_COUNT,\r\n\t\t\tPROXIMITY_FIFO_MAX_COUNT,\r\n      NULL,\r\n      NULL,\r\n      0,\r\n      0,\r\n\t\t\t{ } },\r\n};\r\n\r\n\r\nstatic int open_sensors(const struct hw_module_t* module, const char* id, struct hw_device_t** device);\r\n\r\n\r\nstatic int sensors__get_sensors_list(struct sensors_module_t* module,\r\n                                     struct sensor_t const** list)\r\n{\r\n        *list = sSensorList;\r\n        return ARRAY_SIZE(sSensorList);\r\n}\r\n\r\nstatic struct hw_module_methods_t sensors_module_methods = {\r\n        open: open_sensors\r\n};\r\n\r\nstruct sensors_module_t HAL_MODULE_INFO_SYM = {\r\n        common: {\r\n                tag: HARDWARE_MODULE_TAG,\r\n                version_major: 1,\r\n                version_minor: 0,\r\n                id: SENSORS_HARDWARE_MODULE_ID,\r\n                name: \"STMicroelectronics vl6180 sensor module\",\r\n                author: \"STMicroelectronics Inc.\",\r\n                methods: &sensors_module_methods,\r\n\t\t\t\tdso: NULL,\r\n\t\t\t\treserved: {0}\r\n        },\r\n        get_sensors_list: sensors__get_sensors_list,\r\n};\r\n\r\nstruct sensors_poll_context_t {\r\n    sensors_poll_device_1_t device; // must be first\r\n\r\n    sensors_poll_context_t();\r\n    ~sensors_poll_context_t();\r\n    int activate(int handle, int enabled);\r\n    int setDelay(int handle, int64_t ns);\r\n    int pollEvents(sensors_event_t* data, int count);\r\n    int query(int what, int *value);\r\n    int batch(int handle, int flags, int64_t period_ns, int64_t timeout);\r\n\r\nprivate:\r\n    enum {\r\n        proximity           = 0,\r\n        numSensorDrivers,\r\n        numFds,\r\n    };\r\n\r\n    static const size_t wake = numFds - 1;\r\n    static const char WAKE_MESSAGE = 'W';\r\n    struct pollfd mPollFds[numFds];\r\n    int mWritePipeFd;\r\n    SensorBase* mSensors[numSensorDrivers];\r\n\r\n    int handleToDriver(int handle) const {\r\n        switch (handle) {\r\n            case ID_P:\r\n                return proximity;\r\n\r\n\r\n        }\r\n        return -EINVAL;\r\n    }\r\n};\r\n\r\n/*****************************************************************************/\r\n\r\nsensors_poll_context_t::sensors_poll_context_t()\r\n{\r\n    //for proximity sensor\r\n    mSensors[proximity] = new ProximitySensor();\r\n    mPollFds[proximity].fd = mSensors[proximity]->getFd();\r\n    mPollFds[proximity].events = POLLIN;\r\n    mPollFds[proximity].revents = 0;\r\n\r\n    int wakeFds[2];\r\n    int result = pipe(wakeFds);\r\n    LOGE_IF(result<0, \"error creating wake pipe (%s)\", strerror(errno));\r\n    fcntl(wakeFds[0], F_SETFL, O_NONBLOCK);\r\n    fcntl(wakeFds[1], F_SETFL, O_NONBLOCK);\r\n    mWritePipeFd = wakeFds[1];\r\n\r\n    mPollFds[wake].fd = wakeFds[0];\r\n    mPollFds[wake].events = POLLIN;\r\n    mPollFds[wake].revents = 0;\r\n\r\n}\r\n\r\nsensors_poll_context_t::~sensors_poll_context_t() {\r\n    for (int i=0 ; i<numSensorDrivers ; i++) {\r\n        delete mSensors[i];\r\n    }\r\n    close(mPollFds[wake].fd);\r\n    close(mWritePipeFd);\r\n}\r\n\r\nint sensors_poll_context_t::activate(int handle, int enabled) {\r\n\t//Added for debug\r\n\tLOGV(\"sensors_poll_context_t::activate gets called!index = %d enabled = %d\", handleToDriver(handle), enabled);\r\n\r\n    int index = handleToDriver(handle);\r\n    if (index < 0)\r\n\t\treturn index;\r\n    int err = mSensors[index]->enable(handle, enabled);\r\n\tLOGV(\"%s:%d enabled = %d, err = %d\", __func__, __LINE__, enabled, err);\r\n    if (enabled && !err) {\r\n        const char wakeMessage(WAKE_MESSAGE);\r\n        int result = write(mWritePipeFd, &wakeMessage, 1);\r\n        LOGE_IF(result<0, \"error sending wake message (%s)\", strerror(errno));\r\n    }\r\n    return err;\r\n}\r\n\r\nint sensors_poll_context_t::setDelay(int handle, int64_t ns) {\r\n    //Added for debug\r\n    LOGV(\"sensors_poll_context_t::setDelay gets called!\");\r\n\r\n    int index = handleToDriver(handle);\r\n    if (index < 0) return index;\r\n    return 0;\r\n}\r\n\r\nint sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)\r\n{\r\n    int nbEvents = 0;\r\n    int n = 0;\r\n\r\n\t//Added for debug\r\n\tLOGV(\"sensors_poll_context_t::pollEvents gets called!\");\r\n\r\n    do {\r\n        // see if we have some leftover from the last poll()\r\n        for (int i=0 ; count && i<numSensorDrivers ; i++) {\r\n            SensorBase* const sensor(mSensors[i]);\r\n            if ((mPollFds[i].revents & POLLIN) || (sensor->hasPendingEvents())) {\r\n                int nb = sensor->readEvents(data, count);\r\n                if (nb < count) {\r\n                    // no more data for this sensor\r\n                    mPollFds[i].revents = 0;\r\n                }\r\n                count -= nb;\r\n                nbEvents += nb;\r\n                data += nb;\r\n            }\r\n        }\r\n\r\n        if (count) {\r\n            // we still have some room, so try to see if we can get\r\n            // some events immediately or just wait if we don't have\r\n            // anything to return\r\n            n = poll(mPollFds, numFds, nbEvents ? 0 : -1);\r\n            if (n<0) {\r\n                LOGE(\"poll() failed (%s)\", strerror(errno));\r\n                return -errno;\r\n            }\r\n            if (mPollFds[wake].revents & POLLIN) {\r\n                char msg;\r\n                int result = read(mPollFds[wake].fd, &msg, 1);\r\n                LOGE_IF(result<0, \"error reading from wake pipe (%s)\", strerror(errno));\r\n                LOGE_IF(msg != WAKE_MESSAGE, \"unknown message on wake queue (0x%02x)\", int(msg));\r\n                mPollFds[wake].revents = 0;\r\n            }\r\n        }\r\n        // if we have events and space, go read them\r\n    } while (n && count);\r\n\r\n    return nbEvents;\r\n}\r\n\r\nint sensors_poll_context_t::query(int handle, int* value)\r\n{\r\n    //Added for debug\r\n    LOGV(\"sensors_poll_context_t::query gets called!\");\r\n    int index = handleToDriver(handle);\r\n    if (index < 0) return index;\r\n\r\n    return mSensors[index]->query(handle, value);\r\n}\r\n\r\nint sensors_poll_context_t::batch(int handle, int flags, int64_t period_ns, int64_t timeout)\r\n{\r\n    //Added for debug\r\n    LOGV(\"sensors_poll_context_t::batch gets called!\");\r\n    int index = handleToDriver(handle);\r\n    if (index < 0) return index;\r\n\r\n    return mSensors[index]->batch(handle, flags, period_ns, timeout);\r\n}\r\n\r\n/*****************************************************************************/\r\n\r\nstatic int poll__close(struct hw_device_t *dev)\r\n{\r\n    sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;\r\n    if (ctx) {\r\n        delete ctx;\r\n    }\r\n    return 0;\r\n}\r\n\r\nstatic int poll__activate(struct sensors_poll_device_t *dev,\r\n        int handle, int enabled) {\r\n    sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;\r\n    return ctx->activate(handle, enabled);\r\n}\r\n\r\nstatic int poll__setDelay(struct sensors_poll_device_t *dev,\r\n        int handle, int64_t ns) {\r\n    sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;\r\n    return ctx->setDelay(handle, ns);\r\n}\r\n\r\nstatic int poll__poll(struct sensors_poll_device_t *dev,\r\n        sensors_event_t* data, int count) {\r\n    sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;\r\n    return ctx->pollEvents(data, count);\r\n}\r\n\r\nstatic int poll__query(struct sensors_poll_device_1 *dev,\r\n                      int what, int *value)\r\n{\r\n    sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;\r\n    return ctx->query(what, value);\r\n}\r\n\r\nstatic int poll__batch(struct sensors_poll_device_1 *dev,\r\n                      int handle, int flags, int64_t period_ns, int64_t timeout)\r\n{\r\n    sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;\r\n    return ctx->batch(handle, flags, period_ns, timeout);\r\n}\r\n\r\n/*****************************************************************************/\r\n\r\n/** Open a new instance of a sensor device using name */\r\nstatic int open_sensors(const struct hw_module_t* module, const char* id,\r\n                        struct hw_device_t** device)\r\n{\r\n        int status = -EINVAL;\r\n        sensors_poll_context_t *dev = new sensors_poll_context_t();\r\n\r\n        memset(&dev->device, 0, sizeof(sensors_poll_device_1));\r\n\r\n        dev->device.common.tag = HARDWARE_DEVICE_TAG;\r\n        dev->device.common.version  = SENSORS_DEVICE_API_VERSION_1_0;\r\n        dev->device.common.module   = const_cast<hw_module_t*>(module);\r\n        dev->device.common.close    = poll__close;\r\n        dev->device.activate        = poll__activate;\r\n        dev->device.setDelay        = poll__setDelay;\r\n        dev->device.poll            = poll__poll;\r\n\r\n\t    /* Batch processing */\r\n\t    dev->device.batch           = poll__batch;\r\n\r\n        *device = &dev->device.common;\r\n        status = 0;\r\n\r\n\t\t//Added for debug\r\n\t\tLOGV(\"open_sensors gets called!\");\r\n\r\n        return status;\r\n}\r\n"
  },
  {
    "path": "camera/sensors.h",
    "content": "/*\r\n * Copyright (C) 2008 The Android Open Source Project\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n#ifndef ANDROID_SENSORS_H\r\n#define ANDROID_SENSORS_H\r\n\r\n#include <stdint.h>\r\n#include <errno.h>\r\n#include <sys/cdefs.h>\r\n#include <sys/types.h>\r\n\r\n#include <string.h>\r\n\r\n#include <linux/input.h>\r\n\r\n#include <hardware/hardware.h>\r\n#include <hardware/sensors.h>\r\n\r\n__BEGIN_DECLS\r\n\r\n/*****************************************************************************/\r\n\r\n#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))\r\n\r\n#define ID_A  (0)\r\n#define ID_M  (1)\r\n#define ID_O  (2)\r\n#define ID_L  (3)\r\n#define ID_P  (4)\r\n#define ID_GY (5)\r\n#define ID_PR (6)\r\n#define ID_T  (7)\r\n\r\n/*****************************************************************************/\r\n\r\n/*\r\n * The SENSORS Module\r\n */\r\n\r\n/* the GP2A is a binary proximity sensor that triggers around 5 cm on\r\n * this hardware */\r\n#define PROXIMITY_THRESHOLD_GP2A  5.0f\r\n\r\n/*****************************************************************************/\r\n\r\n#define EVENT_TYPE_ACCEL_X          ABS_X\r\n#define EVENT_TYPE_ACCEL_Y          ABS_Y\r\n#define EVENT_TYPE_ACCEL_Z          ABS_Z\r\n\r\n#define EVENT_TYPE_YAW              REL_RX\r\n#define EVENT_TYPE_PITCH            REL_RY\r\n#define EVENT_TYPE_ROLL             REL_RZ\r\n#define EVENT_TYPE_ORIENT_STATUS    REL_WHEEL\r\n\r\n\r\n#define EVENT_TYPE_MAG_X           ABS_X\r\n#define EVENT_TYPE_MAG_Y           ABS_Y\r\n#define EVENT_TYPE_MAG_Z           ABS_Z\r\n\r\n#define EVENT_TYPE_PROXIMITY        ABS_DISTANCE\r\n#define EVENT_TYPE_LIGHT            ABS_MISC\r\n\r\n#define EVENT_TYPE_GYRO_X           ABS_X\r\n#define EVENT_TYPE_GYRO_Y           ABS_Y\r\n#define EVENT_TYPE_GYRO_Z           ABS_Z\r\n\r\n#define EVENT_TYPE_PRESS            ABS_PRESSURE\r\n#define EVENT_TYPE_TEMP             ABS_GAS\r\n\r\n\r\n// under default setting in acc driver, Full Scale = 2G, 1000 LSG = 1G\r\n#define LSG                 (1000.0f)\r\n\r\n// conversion of acceleration data to SI units (m/s^2)\r\n#define RANGE_A                     (2*GRAVITY_EARTH)\r\n#define CONVERT_A                   (GRAVITY_EARTH / LSG)\r\n#define CONVERT_A_X                 (CONVERT_A)\r\n#define CONVERT_A_Y                 (CONVERT_A)\r\n#define CONVERT_A_Z                 (CONVERT_A)\r\n\r\n// conversion of magnetic data to uT units\r\n// conversion of magnetic data to uT units. 1G = 100 uT.\r\n#define CONVERT_M                   (1.0f/10.0f)\r\n#define CONVERT_M_X                 (CONVERT_M)\r\n#define CONVERT_M_Y                 (CONVERT_M)\r\n#define CONVERT_M_Z                 (CONVERT_M)\r\n\r\n/* conversion of orientation data to degree units */\r\n#define CONVERT_O                   (1.0f/64.0f)\r\n#define CONVERT_O_A                 (CONVERT_O)\r\n#define CONVERT_O_P                 (CONVERT_O)\r\n#define CONVERT_O_R                 (CONVERT_O)\r\n\r\n/* Conversion of pressure and temperature */\r\n#define CONVERT_P (1.0f/4096.0f)\r\n#define CONVERT_T(x) ((x / 480.0f) + 42.5)\r\n\r\n// conversion of gyro data to SI units (radian/sec)\r\n//#define RANGE_GYRO                  (2000.0f*(float)M_PI/180.0f)\r\n// #define CONVERT_GYRO                ((70.0f / 1000.0f) * ((float)M_PI / 180.0f))\r\n// **************************\r\n// under default setting in gyro driver, Full Scale = 250dps, sensitivity = 8.75 mdps/digit\r\n#define GYRO_SSTVT          (8.75f/1000.0f)\r\n#define CONVERT_GYRO                (GYRO_SSTVT * ((float)M_PI / 180.0f))\r\n#define CONVERT_GYRO_X              (CONVERT_GYRO)\r\n#define CONVERT_GYRO_Y              (CONVERT_GYRO)\r\n#define CONVERT_GYRO_Z              (CONVERT_GYRO)\r\n\r\n#define SENSOR_STATE_MASK           (0x7FFF)\r\n\r\n/*****************************************************************************/\r\n\r\n__END_DECLS\r\n\r\n#endif  // ANDROID_SENSORS_H\r\n"
  },
  {
    "path": "cm.dependencies",
    "content": "[\n  {\n    \"repository\": \"android_device_oppo_common\",\n    \"target_path\": \"device/oppo/common\"\n  },\n  {\n    \"repository\": \"android_kernel_oneplus_msm8994\",\n    \"target_path\": \"kernel/oneplus/msm8994\"\n  },\n  {\n    \"repository\": \"android_packages_resources_devicesettings\",\n    \"target_path\": \"packages/resources/devicesettings\"\n  }\n]\n"
  },
  {
    "path": "cm.mk",
    "content": "# Copyright (C) 2016 The CyanogenMod Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# Inherit from those products. Most specific first.\n$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)\n$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)\n\n# Inherit from oneplus2 device\n$(call inherit-product, device/oneplus/oneplus2/device.mk)\n\n# Inherit some common CM stuff.\n$(call inherit-product, vendor/cm/config/common_full_phone.mk)\n\nPRODUCT_NAME := cm_oneplus2\nPRODUCT_DEVICE := oneplus2\nPRODUCT_MANUFACTURER := OnePlus\nPRODUCT_BRAND := OnePlus\n\nPRODUCT_GMS_CLIENTID_BASE := android-oneplus\n\nTARGET_VENDOR_PRODUCT_NAME := OnePlus2\nTARGET_VENDOR_DEVICE_NAME := OnePlus2\nPRODUCT_BUILD_PROP_OVERRIDES += TARGET_DEVICE=OnePlus2 PRODUCT_NAME=OnePlus2\n\nPRODUCT_BUILD_PROP_OVERRIDES += \\\n    BUILD_FINGERPRINT=OnePlus/OnePlus2/OnePlus2:6.0.1/MMB29M/1447840920:user/release-keys \\\n    PRIVATE_BUILD_DESC=\"OnePlus2-user 6.0.1 MMB29M 20 dev-keys\"\n\nPRODUCT_SYSTEM_PROPERTY_BLACKLIST += ro.product.model\n\nTARGET_VENDOR := oneplus\n"
  },
  {
    "path": "cmhw/org/cyanogenmod/hardware/KeyDisabler.java",
    "content": "/*\n * Copyright (C) 2014 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.cyanogenmod.hardware;\n\nimport org.cyanogenmod.internal.util.FileUtils;\n\n/*\n * Disable capacitive keys\n *\n * This is intended for use on devices in which the capacitive keys\n * can be fully disabled for replacement with a soft navbar. You\n * really should not be using this on a device with mechanical or\n * otherwise visible-when-inactive keys\n */\n\npublic class KeyDisabler {\n\n    private static String CONTROL_PATH = \"/proc/s1302/virtual_key\";\n\n    public static boolean isSupported() {\n        return FileUtils.isFileWritable(CONTROL_PATH);\n    }\n\n    public static boolean isActive() {\n        return FileUtils.readOneLine(CONTROL_PATH).contains(\"enabled\");\n    }\n\n    public static boolean setActive(boolean state) {\n        return FileUtils.writeLine(CONTROL_PATH, (state ? \"1\" : \"0\"));\n    }\n}\n"
  },
  {
    "path": "configs/media_codecs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<!-- Copyright (C) 2012 The Android Open Source Project\n     Copyright (C) 2014 - 2015 The Linux Foundation. All rights reserved.\n     Not a contribution.\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n\n<!--\n<!DOCTYPE MediaCodecs [\n<!ELEMENT Include EMPTY>\n<!ATTLIST Include href CDATA #REQUIRED>\n<!ELEMENT MediaCodecs (Decoders|Encoders|Include)*>\n<!ELEMENT Decoders (MediaCodec|Include)*>\n<!ELEMENT Encoders (MediaCodec|Include)*>\n<!ELEMENT MediaCodec (Type|Quirk|Include)*>\n<!ATTLIST MediaCodec name CDATA #REQUIRED>\n<!ATTLIST MediaCodec type CDATA>\n<!ELEMENT Type EMPTY>\n<!ATTLIST Type name CDATA #REQUIRED>\n<!ELEMENT Quirk EMPTY>\n<!ATTLIST Quirk name CDATA #REQUIRED>\n]>\n\nThere's a simple and a complex syntax to declare the availability of a\nmedia codec:\n\nA codec that properly follows the OpenMax spec and therefore doesn't have any\nquirks and that only supports a single content type can be declared like so:\n\n    <MediaCodec name=\"OMX.foo.bar\" type=\"something/interesting\" />\n\nIf a codec has quirks OR supports multiple content types, the following syntax\ncan be used:\n\n    <MediaCodec name=\"OMX.foo.bar\" >\n        <Type name=\"something/interesting\" />\n        <Type name=\"something/else\" />\n        ...\n        <Quirk name=\"requires-allocate-on-input-ports\" />\n        <Quirk name=\"requires-allocate-on-output-ports\" />\n        <Quirk name=\"output-buffers-are-unreadable\" />\n    </MediaCodec>\n\nOnly the three quirks included above are recognized at this point:\n\n\"requires-allocate-on-input-ports\"\n    must be advertised if the component does not properly support specification\n    of input buffers using the OMX_UseBuffer(...) API but instead requires\n    OMX_AllocateBuffer to be used.\n\n\"requires-allocate-on-output-ports\"\n    must be advertised if the component does not properly support specification\n    of output buffers using the OMX_UseBuffer(...) API but instead requires\n    OMX_AllocateBuffer to be used.\n\n\"output-buffers-are-unreadable\"\n    must be advertised if the emitted output buffers of a decoder component\n    are not readable, i.e. use a custom format even though abusing one of\n    the official OMX colorspace constants.\n    Clients of such decoders will not be able to access the decoded data,\n    naturally making the component much less useful. The only use for\n    a component with this quirk is to render the output to the screen.\n    Audio decoders MUST NOT advertise this quirk.\n    Video decoders that advertise this quirk must be accompanied by a\n    corresponding color space converter for thumbnail extraction,\n    matching surfaceflinger support that can render the custom format to\n    a texture and possibly other code, so just DON'T USE THIS QUIRK.\n\n\n-->\n\n<!--\n 8994 Decoder capabilities (If Encode is supported, same numbers apply)\n __________________________________________________________________________\n | Codec    | W       H       fps     Mbps    MB/s    | Encode Secure-dec |\n |__________|_________________________________________|___________________|\n | h264     | 3840    2160    30      100     972000  |  Y       Y        |\n |          | (4096)  (2160)  (24)    (100)           |                   |\n | hevc     | 3840    2160    30      100     972000  |  Y       Y        |\n |          | (4096)  (2160)  (24)    (100)           |                   |\n | mpeg4    | 1920    1088    60      60      489600  |  Y       N        |\n | vc1      | 1920    1088    60      60      489600  |  N       Y        |\n | vp8      | 3840    2160    30      20      972000  |  Y       N        |\n | divx3    | 720     480     30      2       40500   |  N       N        |\n | div4/5/6 | 1920    1088    30      10      244800  |  N       N        |\n | h263     | 864     480     30      2       48600   |  Y       N        |\n | mpeg2    | 1920    1088    30      40      244800  |  N       Y        |\n |__________|_________________________________________|___________________|\n-->\n\n<MediaCodecs>\n    <Include href=\"media_codecs_google_audio.xml\" />\n    <Include href=\"media_codecs_google_telephony.xml\" />\n    <Settings>\n        <Setting name=\"max-video-encoder-input-buffers\" value=\"11\" />\n    </Settings>\n    <Encoders>\n        <!-- Audio Hardware  -->\n        <!-- Video Hardware  -->\n        <MediaCodec name=\"OMX.qcom.video.encoder.avc\" type=\"video/avc\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Quirk name=\"requires-loaded-to-idle-after-allocation\" />\n            <Limit name=\"size\" min=\"96x64\" max=\"4096x2160\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"972000\" />\n            <Limit name=\"bitrate\" range=\"1-100000000\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.encoder.mpeg4\" type=\"video/mp4v-es\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Quirk name=\"requires-loaded-to-idle-after-allocation\"/>\n            <Limit name=\"size\" min=\"96x64\" max=\"1920x1088\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"489600\" />\n            <Limit name=\"bitrate\" range=\"1-60000000\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.encoder.h263\" type=\"video/3gpp\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Quirk name=\"requires-loaded-to-idle-after-allocation\" />\n            <Limit name=\"size\" min=\"96x64\" max=\"864x480\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"48600\" />\n            <Limit name=\"bitrate\" range=\"1-2000000\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.encoder.vp8\" type=\"video/x-vnd.on2.vp8\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Quirk name=\"requires-loaded-to-idle-after-allocation\" />\n            <Limit name=\"size\" min=\"96x64\" max=\"3840x2160\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"972000\" />\n            <Limit name=\"bitrate\" range=\"1-20000000\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.encoder.hevc\" type=\"video/hevc\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Quirk name=\"requires-loaded-to-idle-after-allocation\" />\n            <Limit name=\"size\" min=\"176x64\" max=\"4096x2160\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"972000\" />\n            <Limit name=\"bitrate\" range=\"1-100000000\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n    </Encoders>\n    <Decoders>\n        <!-- Audio Hardware  -->\n        <!-- Audio Software  -->\n        <!-- Video Hardware  -->\n        <MediaCodec name=\"OMX.qcom.video.decoder.avc\" type=\"video/avc\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"4096x2160\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"972000\" />\n            <Limit name=\"bitrate\" range=\"1-100000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.avc.secure\" type=\"video/avc\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"4096x2160\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"972000\" />\n            <Limit name=\"bitrate\" range=\"1-100000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Feature name=\"secure-playback\" required=\"true\" />\n            <Limit name=\"concurrent-instances\" max=\"6\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.mpeg4\" type=\"video/mp4v-es\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\"/>\n            <Limit name=\"size\" min=\"64x64\" max=\"1920x1088\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"489600\" />\n            <Limit name=\"bitrate\" range=\"1-60000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.mpeg2\" type=\"video/mpeg2\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"96x64\" max=\"1920x1088\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"244800\" />\n            <Limit name=\"bitrate\" range=\"1-40000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.mpeg2.secure\" type=\"video/mpeg2\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"96x64\" max=\"1920x1088\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"244800\" />\n            <Limit name=\"bitrate\" range=\"1-40000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Feature name=\"secure-playback\" required=\"true\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.h263\" type=\"video/3gpp\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"864x480\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"489600\" />\n            <Limit name=\"bitrate\" range=\"1-2000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.vc1\" type=\"video/x-ms-wmv\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"1920x1088\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"489600\" />\n            <Limit name=\"bitrate\" range=\"1-60000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.vc1.secure\" type=\"video/x-ms-wmv\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"1920x1088\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"489600\" />\n            <Limit name=\"bitrate\" range=\"1-60000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Feature name=\"secure-playback\" required=\"true\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.divx\" type=\"video/divx\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"1920x1088\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"244800\" />\n            <Limit name=\"bitrate\" range=\"1-10000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.divx311\" type=\"video/divx311\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"720x480\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"40500\" />\n            <Limit name=\"bitrate\" range=\"1-2000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.divx4\" type=\"video/divx4\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"1920x1088\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"244800\" />\n            <Limit name=\"bitrate\" range=\"1-10000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.vp8\" type=\"video/x-vnd.on2.vp8\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"3840x2160\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"972000\" />\n            <Limit name=\"bitrate\" range=\"1-20000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.hevc\" type=\"video/hevc\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"4096x2160\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"972000\" />\n            <Limit name=\"bitrate\" range=\"1-100000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Limit name=\"concurrent-instances\" max=\"13\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.hevc.secure\" type=\"video/hevc\" >\n            <Quirk name=\"requires-allocate-on-input-ports\" />\n            <Quirk name=\"requires-allocate-on-output-ports\" />\n            <Limit name=\"size\" min=\"64x64\" max=\"4096x2160\" />\n            <Limit name=\"alignment\" value=\"2x2\" />\n            <Limit name=\"block-size\" value=\"16x16\" />\n            <Limit name=\"blocks-per-second\" min=\"1\" max=\"972000\" />\n            <Limit name=\"bitrate\" range=\"1-100000000\" />\n            <Feature name=\"adaptive-playback\" />\n            <Feature name=\"secure-playback\" required=\"true\" />\n            <Limit name=\"concurrent-instances\" max=\"6\" />\n        </MediaCodec>\n    </Decoders>\n    <Include href=\"media_codecs_google_video.xml\" />\n    <Include href=\"media_codecs_ffmpeg.xml\" />\n</MediaCodecs>\n"
  },
  {
    "path": "configs/media_codecs_performance.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<!--\nCopyright (c) 2015, The Linux Foundation. All rights reserved.\n\nNot a Contribution.\n\nCopyright 2015 The Android Open Source Project\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n     http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n\n<MediaCodecs>\n    <Encoders>\n        <MediaCodec name=\"OMX.qcom.video.encoder.avc\" type=\"video/avc\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x240\" range=\"489-489\" />\n            <Limit name=\"measured-frame-rate-720x480\" range=\"152-152\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"168-168\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"86-86\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.encoder.h263\" type=\"video/3gpp\" update=\"true\">\n            <Limit name=\"measured-frame-rate-176x144\" range=\"427-427\" />\n            <Limit name=\"measured-frame-rate-352x288\" range=\"248-248\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.encoder.mpeg4\" type=\"video/mp4v-es\" update=\"true\">\n            <Limit name=\"measured-frame-rate-176x144\" range=\"390-390\" />\n            <Limit name=\"measured-frame-rate-352x288\" range=\"243-243\" />\n            <Limit name=\"measured-frame-rate-640x480\" range=\"206-206\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.encoder.vp8\" type=\"video/x-vnd.on2.vp8\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x180\" range=\"137-137\" />\n            <Limit name=\"measured-frame-rate-640x360\" range=\"123-123\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"95-95\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"49-49\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.h264.encoder\" type=\"video/avc\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x240\" range=\"472-472\" />\n            <Limit name=\"measured-frame-rate-720x480\" range=\"174-174\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"79-79\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"42-42\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.h263.encoder\" type=\"video/3gpp\" update=\"true\">\n            <Limit name=\"measured-frame-rate-176x144\" range=\"788-788\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.mpeg4.encoder\" type=\"video/mp4v-es\" update=\"true\">\n            <Limit name=\"measured-frame-rate-176x144\" range=\"784-784\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.vp8.encoder\" type=\"video/x-vnd.on2.vp8\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x180\" range=\"484-484\" />\n            <Limit name=\"measured-frame-rate-640x360\" range=\"209-209\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"78-78\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"36-36\" />\n        </MediaCodec>\n    </Encoders>\n    <Decoders>\n        <MediaCodec name=\"OMX.qcom.video.decoder.avc\" type=\"video/avc\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x240\" range=\"498-498\" />\n            <Limit name=\"measured-frame-rate-720x480\" range=\"377-377\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"220-220\" />\n            <Limit name=\"measured-frame-rate-1920x1088\" range=\"111-111\" />\n        </MediaCodec>\n            <MediaCodec name=\"OMX.qcom.video.decoder.hevc\" type=\"video/hevc\" update=\"true\">\n            <Limit name=\"measured-frame-rate-352x288\" range=\"597-597\" />\n            <Limit name=\"measured-frame-rate-720x480\" range=\"512-512\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"340-340\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"194-194\" />\n            <Limit name=\"measured-frame-rate-3840x2160\" range=\"49-49\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.h263\" type=\"video/3gpp\" update=\"true\">\n            <Limit name=\"measured-frame-rate-176x144\" range=\"692-692\" />\n            <Limit name=\"measured-frame-rate-352x288\" range=\"586-586\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.mpeg4\" type=\"video/mp4v-es\" update=\"true\">\n            <Limit name=\"measured-frame-rate-480x360\" range=\"559-559\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.qcom.video.decoder.vp8\" type=\"video/x-vnd.on2.vp8\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x240\" range=\"500-500\" />\n            <Limit name=\"measured-frame-rate-640x360\" range=\"456-456\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"533-533\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"323-323\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.h264.decoder\" type=\"video/avc\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x240\" range=\"570-570\" />\n            <Limit name=\"measured-frame-rate-720x480\" range=\"231-231\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"220-220\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"84-84\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.h263.decoder\" type=\"video/3gpp\" update=\"true\">\n            <Limit name=\"measured-frame-rate-176x144\" range=\"992-992\" />\n            <Limit name=\"measured-frame-rate-352x288\" range=\"724-724\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.hevc.decoder\" type=\"video/hevc\" update=\"true\">\n            <Limit name=\"measured-frame-rate-352x288\" range=\"534-534\" />\n            <Limit name=\"measured-frame-rate-720x480\" range=\"363-363\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"161-161\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"153-153\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.vp8.decoder\" type=\"video/x-vnd.on2.vp8\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x240\" range=\"1237-1237\" />\n            <Limit name=\"measured-frame-rate-640x360\" range=\"636-636\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"118-118\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"97-97\" />\n        </MediaCodec>\n        <MediaCodec name=\"OMX.google.vp9.decoder\" type=\"video/x-vnd.on2.vp9\" update=\"true\">\n            <Limit name=\"measured-frame-rate-320x240\" range=\"664-664\" />\n            <Limit name=\"measured-frame-rate-640x360\" range=\"648-648\" />\n            <Limit name=\"measured-frame-rate-1280x720\" range=\"203-203\" />\n            <Limit name=\"measured-frame-rate-1920x1080\" range=\"112-112\" />\n        </MediaCodec>\n    </Decoders>\n</MediaCodecs>\n"
  },
  {
    "path": "configs/media_profiles.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2010 The Android Open Source Project\n     Copyright (C) 2013 - 2015 The Linux Foundation. All rights reserved.\n     Not a contribution.\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<!DOCTYPE MediaSettings [\n<!ELEMENT MediaSettings (CamcorderProfiles,\n                         EncoderOutputFileFormat+,\n                         VideoEncoderCap+,\n                         AudioEncoderCap+,\n                         VideoDecoderCap,\n                         AudioDecoderCap)>\n<!ELEMENT CamcorderProfiles (EncoderProfile+, ImageEncoding+, ImageDecoding, Camera)>\n<!ELEMENT EncoderProfile (Video, Audio)>\n<!ATTLIST EncoderProfile quality (high|low) #REQUIRED>\n<!ATTLIST EncoderProfile fileFormat (mp4|3gp) #REQUIRED>\n<!ATTLIST EncoderProfile duration (30|60) #REQUIRED>\n<!ATTLIST EncoderProfile cameraId (0|1) #REQUIRED>\n<!ELEMENT Video EMPTY>\n<!ATTLIST Video codec (h264|h263|m4v) #REQUIRED>\n<!ATTLIST Video bitRate CDATA #REQUIRED>\n<!ATTLIST Video width CDATA #REQUIRED>\n<!ATTLIST Video height CDATA #REQUIRED>\n<!ATTLIST Video frameRate CDATA #REQUIRED>\n<!ELEMENT Audio EMPTY>\n<!ATTLIST Audio codec (amrnb|amrwb|aac|lpcm) #REQUIRED>\n<!ATTLIST Audio bitRate CDATA #REQUIRED>\n<!ATTLIST Audio sampleRate CDATA #REQUIRED>\n<!ATTLIST Audio channels (1|2|6) #REQUIRED>\n<!ELEMENT ImageEncoding EMPTY>\n<!ATTLIST ImageEncoding quality (90|80|70|60|50|40) #REQUIRED>\n<!ELEMENT ImageDecoding EMPTY>\n<!ATTLIST ImageDecoding memCap CDATA #REQUIRED>\n<!ELEMENT Camera EMPTY>\n<!ELEMENT EncoderOutputFileFormat EMPTY>\n<!ATTLIST EncoderOutputFileFormat name (mp4|3gp) #REQUIRED>\n<!ELEMENT VideoEncoderCap EMPTY>\n<!ATTLIST VideoEncoderCap name (h264|h263|m4v|wmv) #REQUIRED>\n<!ATTLIST VideoEncoderCap enabled (true|false) #REQUIRED>\n<!ATTLIST VideoEncoderCap minBitRate CDATA #REQUIRED>\n<!ATTLIST VideoEncoderCap maxBitRate CDATA #REQUIRED>\n<!ATTLIST VideoEncoderCap minFrameWidth CDATA #REQUIRED>\n<!ATTLIST VideoEncoderCap maxFrameWidth CDATA #REQUIRED>\n<!ATTLIST VideoEncoderCap minFrameHeight CDATA #REQUIRED>\n<!ATTLIST VideoEncoderCap maxFrameHeight CDATA #REQUIRED>\n<!ATTLIST VideoEncoderCap minFrameRate CDATA #REQUIRED>\n<!ATTLIST VideoEncoderCap maxFrameRate CDATA #REQUIRED>\n<!ELEMENT AudioEncoderCap EMPTY>\n<!ATTLIST AudioEncoderCap name (amrnb|amrwb|aac|wma|lpcm) #REQUIRED>\n<!ATTLIST AudioEncoderCap enabled (true|false) #REQUIRED>\n<!ATTLIST AudioEncoderCap minBitRate CDATA #REQUIRED>\n<!ATTLIST AudioEncoderCap maxBitRate CDATA #REQUIRED>\n<!ATTLIST AudioEncoderCap minSampleRate CDATA #REQUIRED>\n<!ATTLIST AudioEncoderCap maxSampleRate CDATA #REQUIRED>\n<!ATTLIST AudioEncoderCap minChannels (1|2|6) #REQUIRED>\n<!ATTLIST AudioEncoderCap maxChannels (1|2|6) #REQUIRED>\n<!ELEMENT VideoDecoderCap EMPTY>\n<!ATTLIST VideoDecoderCap name (wmv) #REQUIRED>\n<!ATTLIST VideoDecoderCap enabled (true|false) #REQUIRED>\n<!ELEMENT AudioDecoderCap EMPTY>\n<!ATTLIST AudioDecoderCap name (wma) #REQUIRED>\n<!ATTLIST AudioDecoderCap enabled (true|false) #REQUIRED>\n]>\n<!--\n     This file is used to declare the multimedia profiles and capabilities\n     on an android-powered device.\n-->\n<MediaSettings>\n    <!-- Each camcorder profile defines a set of predefined configuration parameters -->\n    <!-- Back Camera -->\n    <CamcorderProfiles cameraId=\"0\">\n\n    <EncoderProfile quality=\"low\" fileFormat=\"3gp\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"192000\"\n             width=\"176\"\n             height=\"144\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"high\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"42000000\"\n             width=\"3840\"\n             height=\"2160\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"qvga\" fileFormat=\"mp4\" duration=\"60\">\n      <Video codec=\"h264\"\n             bitRate=\"512000\"\n             width=\"320\"\n             height=\"240\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"cif\" fileFormat=\"3gp\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"720000\"\n             width=\"352\"\n             height=\"288\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"480p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"2000000\"\n               width=\"720\"\n               height=\"480\"\n               frameRate=\"30\" />\n        <Audio codec=\"aac\"\n         bitRate=\"156000\"\n               sampleRate=\"48000\"\n         channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"720p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"14000000\"\n               width=\"1280\"\n               height=\"720\"\n               frameRate=\"30\" />\n        <Audio codec=\"aac\"\n         bitRate=\"156000\"\n               sampleRate=\"48000\"\n         channels=\"2\" />\n    </EncoderProfile>\n\n        <EncoderProfile quality=\"1080p\" fileFormat=\"mp4\" duration=\"30\">\n            <Video codec=\"h264\"\n             bitRate=\"20000000\"\n                   width=\"1920\"\n                   height=\"1080\"\n                   frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"4kdci\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n            bitRate=\"42000000\"\n            width=\"4096\"\n            height=\"2160\"\n            frameRate=\"24\" />\n\n      <Audio codec=\"aac\"\n            bitRate=\"156000\"\n            sampleRate=\"48000\"\n            channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"2160p\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n            bitRate=\"42000000\"\n            width=\"3840\"\n            height=\"2160\"\n            frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n            bitRate=\"156000\"\n            sampleRate=\"48000\"\n            channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"qcif\" fileFormat=\"3gp\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"192000\"\n             width=\"176\"\n             height=\"144\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"vga\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"2000000\"\n             width=\"640\"\n             height=\"480\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <!-- TIMELAPSE PROFILE for back-camera -->\n\n    <EncoderProfile quality=\"timelapselow\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"192000\"\n             width=\"176\"\n             height=\"144\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapsehigh\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"42000000\"\n             width=\"3840\"\n             height=\"2160\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapseqcif\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n               bitRate=\"192000\"\n               width=\"176\"\n               height=\"144\"\n               frameRate=\"30\" />\n        <!-- audio setting is ignored -->\n        <Audio codec=\"amrnb\"\n               bitRate=\"12200\"\n               sampleRate=\"8000\"\n               channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapsecif\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"720000\"\n               width=\"352\"\n               height=\"288\"\n               frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapseqvga\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"512000\"\n             width=\"320\"\n             height=\"240\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapsevga\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"2000000\"\n             width=\"640\"\n             height=\"480\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapse480p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"2000000\"\n         width=\"640\"\n               height=\"480\"\n               frameRate=\"30\" />\n        <!-- audio setting is ignored -->\n        <Audio codec=\"aac\"\n         bitRate=\"156000\"\n               sampleRate=\"48000\"\n         channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapse720p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"14000000\"\n               width=\"1280\"\n               height=\"720\"\n               frameRate=\"30\" />\n        <!-- audio setting is ignored -->\n        <Audio codec=\"aac\"\n         bitRate=\"156000\"\n               sampleRate=\"48000\"\n         channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapse1080p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"20000000\"\n               width=\"1920\"\n               height=\"1080\"\n               frameRate=\"30\" />\n        <!-- audio setting is ignored -->\n        <Audio codec=\"aac\"\n         bitRate=\"156000\"\n         sampleRate=\"48000\"\n         channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapse4kdci\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n            bitRate=\"42000000\"\n            width=\"4096\"\n            height=\"2160\"\n            frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n            bitRate=\"156000\"\n            sampleRate=\"48000\"\n            channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapse2160p\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n            bitRate=\"42000000\"\n            width=\"3840\"\n            height=\"2160\"\n            frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n            bitRate=\"156000\"\n                   sampleRate=\"48000\"\n            channels=\"2\" />\n    </EncoderProfile>\n\n        <!-- CAMCORDER_QUALITY_HIGH_SPEED_LOW/720P : 720p@120fps; 27.0 Mbps -->\n        <EncoderProfile quality=\"highspeedlow\" fileFormat=\"mp4\" duration=\"30\">\n            <Video codec=\"h264\"\n                   bitRate=\"27000000\"\n                   width=\"1280\"\n                   height=\"720\"\n                   frameRate=\"120\" />\n            <!-- audio setting is ignored -->\n            <Audio codec=\"aac\"\n                   bitRate=\"96000\"\n                   sampleRate=\"48000\"\n                   channels=\"2\" />\n        </EncoderProfile>\n\n        <!-- CAMCORDER_QUALITY_HIGH_SPEED_HIGH/720P : 720p@120fps; 27.0 Mbps -->\n        <EncoderProfile quality=\"highspeedhigh\" fileFormat=\"mp4\" duration=\"30\">\n            <Video codec=\"h264\"\n                   bitRate=\"27000000\"\n                   width=\"1280\"\n                   height=\"720\"\n                   frameRate=\"120\" />\n            <!-- audio setting is ignored -->\n            <Audio codec=\"aac\"\n                   bitRate=\"96000\"\n                   sampleRate=\"48000\"\n                   channels=\"2\" />\n        </EncoderProfile>\n\n        <EncoderProfile quality=\"highspeed720p\" fileFormat=\"mp4\" duration=\"30\">\n            <Video codec=\"h264\"\n                   bitRate=\"27000000\"\n                   width=\"1280\"\n                   height=\"720\"\n                   frameRate=\"120\" />\n            <!-- audio setting is ignored -->\n            <Audio codec=\"aac\"\n                   bitRate=\"96000\"\n                   sampleRate=\"48000\"\n                   channels=\"2\" />\n        </EncoderProfile>\n\n        <!-- CAMCORDER_QUALITY_HIGH_SPEED_HIGH/1080P : 1080p@60fps; 34.0 Mbps -->\n        <EncoderProfile quality=\"highspeed1080p\" fileFormat=\"mp4\" duration=\"30\">\n            <Video codec=\"h264\"\n                   bitRate=\"34000000\"\n                   width=\"1920\"\n                   height=\"1080\"\n                   frameRate=\"60\" />\n            <!-- audio setting is ignored -->\n            <Audio codec=\"aac\"\n                   bitRate=\"96000\"\n                   sampleRate=\"48000\"\n                   channels=\"2\" />\n        </EncoderProfile>\n\n        <ImageEncoding quality=\"95\" />\n        <ImageEncoding quality=\"80\" />\n        <ImageEncoding quality=\"70\" />\n        <ImageDecoding memCap=\"20000000\" />\n\n    </CamcorderProfiles>\n\n    <!-- Front Camera -->\n    <CamcorderProfiles cameraId=\"1\">\n\n    <EncoderProfile quality=\"low\" fileFormat=\"3gp\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"192000\"\n             width=\"176\"\n             height=\"144\"\n             frameRate=\"30\" />\n\n            <Audio codec=\"amrnb\"\n                   bitRate=\"12200\"\n                   sampleRate=\"8000\"\n                   channels=\"1\" />\n        </EncoderProfile>\n\n    <EncoderProfile quality=\"high\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"20000000\"\n             width=\"1920\"\n             height=\"1080\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"qvga\" fileFormat=\"mp4\" duration=\"60\">\n      <Video codec=\"h264\"\n             bitRate=\"512000\"\n             width=\"320\"\n             height=\"240\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"cif\" fileFormat=\"3gp\" duration=\"30\">\n            <Video codec=\"h264\"\n             bitRate=\"720000\"\n                   width=\"352\"\n                   height=\"288\"\n                   frameRate=\"30\" />\n\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n                   channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"480p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"2000000\"\n               width=\"720\"\n               height=\"480\"\n               frameRate=\"30\" />\n        <Audio codec=\"aac\"\n         bitRate=\"156000\"\n               sampleRate=\"48000\"\n         channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"720p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"14000000\"\n               width=\"1280\"\n               height=\"720\"\n               frameRate=\"30\" />\n        <Audio codec=\"aac\"\n         bitRate=\"156000\"\n         sampleRate=\"48000\"\n         channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"1080p\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"20000000\"\n             width=\"1920\"\n             height=\"1080\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n                   sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"qcif\" fileFormat=\"3gp\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"192000\"\n             width=\"176\"\n             height=\"144\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n     <EncoderProfile quality=\"vga\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"2000000\"\n             width=\"640\"\n             height=\"480\"\n             frameRate=\"30\" />\n\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n    <!-- TIMELAPSE profiles for front camera -->\n    <EncoderProfile quality=\"timelapselow\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"192000\"\n             width=\"176\"\n             height=\"144\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n                   channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapsehigh\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"20000000\"\n             width=\"1920\"\n             height=\"1080\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n    <EncoderProfile quality=\"timelapseqcif\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n               bitRate=\"192000\"\n               width=\"176\"\n               height=\"144\"\n               frameRate=\"30\" />\n        <!-- audio setting is ignored -->\n        <Audio codec=\"amrnb\"\n               bitRate=\"12200\"\n               sampleRate=\"8000\"\n               channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapsecif\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n               bitRate=\"1200000\"\n               width=\"352\"\n               height=\"288\"\n               frameRate=\"30\" />\n        <!-- audio setting is ignored -->\n        <Audio codec=\"aac\"\n               bitRate=\"96000\"\n               sampleRate=\"48000\"\n               channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapseqvga\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"512000\"\n             width=\"320\"\n             height=\"240\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapsevga\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"2000000\"\n             width=\"640\"\n             height=\"480\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"amrnb\"\n             bitRate=\"12200\"\n             sampleRate=\"8000\"\n             channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapse480p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"5000000\"\n               width=\"720\"\n               height=\"480\"\n               frameRate=\"30\" />\n        <!-- audio setting is ignored -->\n        <Audio codec=\"aac\"\n               bitRate=\"96000\"\n               sampleRate=\"48000\"\n               channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapse720p\" fileFormat=\"mp4\" duration=\"30\">\n        <Video codec=\"h264\"\n         bitRate=\"8000000\"\n               width=\"1280\"\n               height=\"720\"\n               frameRate=\"30\" />\n        <!-- audio setting is ignored -->\n        <Audio codec=\"aac\"\n               bitRate=\"96000\"\n               sampleRate=\"48000\"\n               channels=\"1\" />\n    </EncoderProfile>\n\n    <EncoderProfile quality=\"timelapse1080p\" fileFormat=\"mp4\" duration=\"30\">\n      <Video codec=\"h264\"\n             bitRate=\"20000000\"\n             width=\"1920\"\n             height=\"1080\"\n             frameRate=\"30\" />\n\n      <!-- audio setting is ignored -->\n      <Audio codec=\"aac\"\n             bitRate=\"156000\"\n             sampleRate=\"48000\"\n             channels=\"2\" />\n    </EncoderProfile>\n\n        <ImageEncoding quality=\"95\" />\n        <ImageEncoding quality=\"80\" />\n        <ImageEncoding quality=\"70\" />\n        <ImageDecoding memCap=\"20000000\" />\n\n    </CamcorderProfiles>\n\n    <EncoderOutputFileFormat name=\"3gp\" />\n    <EncoderOutputFileFormat name=\"mp4\" />\n\n    <!--\n         If a codec is not enabled, it is invisible to the applications\n         In other words, the applications won't be able to use the codec\n         or query the capabilities of the codec at all if it is disabled\n    -->\n    <VideoEncoderCap name=\"h264\" enabled=\"true\"\n        minBitRate=\"64000\" maxBitRate=\"42000000\"\n        minFrameWidth=\"176\" maxFrameWidth=\"4096\"\n        minFrameHeight=\"144\" maxFrameHeight=\"2160\"\n        minFrameRate=\"15\" maxFrameRate=\"30\" />\n\n    <VideoEncoderCap name=\"h263\" enabled=\"true\"\n        minBitRate=\"64000\" maxBitRate=\"2000000\"\n        minFrameWidth=\"176\" maxFrameWidth=\"800\"\n        minFrameHeight=\"144\" maxFrameHeight=\"480\"\n        minFrameRate=\"15\" maxFrameRate=\"30\" />\n\n    <VideoEncoderCap name=\"m4v\" enabled=\"true\"\n        minBitRate=\"64000\" maxBitRate=\"20000000\"\n        minFrameWidth=\"176\" maxFrameWidth=\"1920\"\n        minFrameHeight=\"144\" maxFrameHeight=\"1088\"\n        minFrameRate=\"15\" maxFrameRate=\"30\" />\n\n    <AudioEncoderCap name=\"aac\" enabled=\"true\"\n        minBitRate=\"8000\" maxBitRate=\"96000\"\n        minSampleRate=\"8000\" maxSampleRate=\"48000\"\n        minChannels=\"1\" maxChannels=\"6\" />\n\n    <AudioEncoderCap name=\"heaac\" enabled=\"true\"\n        minBitRate=\"8000\" maxBitRate=\"64000\"\n        minSampleRate=\"16000\" maxSampleRate=\"48000\"\n        minChannels=\"1\" maxChannels=\"1\" />\n\n    <AudioEncoderCap name=\"aaceld\" enabled=\"true\"\n        minBitRate=\"16000\" maxBitRate=\"192000\"\n        minSampleRate=\"16000\" maxSampleRate=\"48000\"\n        minChannels=\"1\" maxChannels=\"1\" />\n\n    <AudioEncoderCap name=\"amrwb\" enabled=\"true\"\n        minBitRate=\"6600\" maxBitRate=\"23850\"\n        minSampleRate=\"16000\" maxSampleRate=\"16000\"\n        minChannels=\"1\" maxChannels=\"1\" />\n\n    <AudioEncoderCap name=\"amrnb\" enabled=\"true\"\n        minBitRate=\"5525\" maxBitRate=\"12200\"\n        minSampleRate=\"8000\" maxSampleRate=\"8000\"\n        minChannels=\"1\" maxChannels=\"1\" />\n\n    <AudioEncoderCap name=\"lpcm\" enabled=\"true\"\n        minBitRate=\"768000\" maxBitRate=\"4608000\"\n        minSampleRate=\"8000\" maxSampleRate=\"48000\"\n        minChannels=\"1\" maxChannels=\"6\" />\n\n    <!--\n        FIXME:\n        We do not check decoder capabilities at present\n        At present, we only check whether windows media is visible\n        for TEST applications. For other applications, we do\n        not perform any checks at all.\n    -->\n    <VideoDecoderCap name=\"wmv\" enabled=\"true\"/>\n    <AudioDecoderCap name=\"wma\" enabled=\"true\"/>\n\n</MediaSettings>\n"
  },
  {
    "path": "configs/msm_irqbalance.conf",
    "content": "PRIO=1,1,1,1,0,0,0,0\nIGNORED_IRQ=20,40,200,203,155,157\n"
  },
  {
    "path": "configs/sec_config",
    "content": "/* IPC Security Config */\n/* <GPS QMI Service ID - 16>:<GPS QMI Instance ID - all instances>:<Client Group ID> */\n16:4294967295:1000:3004\n/* Allow SS CTL service to be used by system and net_raw processes */\n43:4294967295:1000:3004\n/* <UIMRMT QMI Service ID - 16>:<UIMRMT QMI Instance ID - all instances>:<Client Group ID> */\n50:4294967295:1001\n/* Allow Sensor services to be used by sensor process */\n256:4294967295:3011\n257:4294967295:3011\n258:4294967295:3011\n259:4294967295:3011\n260:4294967295:3011\n261:4294967295:3011\n262:4294967295:3011\n263:4294967295:3011\n264:4294967295:3011\n265:4294967295:3011\n266:4294967295:3011\n267:4294967295:3011\n268:4294967295:3011\n269:4294967295:3011\n270:4294967295:3011\n271:4294967295:3011\n272:4294967295:3011\n273:4294967295:3011\n274:4294967295:3011\n275:4294967295:3011\n276:4294967295:3011\n277:4294967295:3011\n278:4294967295:3011\n279:4294967295:3011\n280:4294967295:3011\n281:4294967295:3011\n282:4294967295:3011\n283:4294967295:3011\n284:4294967295:3011\n285:4294967295:3011\n286:4294967295:3011\n287:4294967295:3011\n288:4294967295:3011\n289:4294967295:3011\n290:4294967295:3011\n291:4294967295:3011\n292:4294967295:3011\n293:4294967295:3011\n294:4294967295:3011\n295:4294967295:3011\n296:4294967295:3011\n297:4294967295:3011\n298:4294967295:3011\n299:4294967295:3011\n300:4294967295:3011\n301:4294967295:3011\n302:4294967295:3011\n303:4294967295:3011\n304:4294967295:3011\n305:4294967295:3011\n306:4294967295:3011\n307:4294967295:3011\n308:4294967295:3011\n309:4294967295:3011\n310:4294967295:3011\n311:4294967295:3011\n312:4294967295:3011\n313:4294967295:3011\n314:4294967295:3011\n315:4294967295:3011\n316:4294967295:3011\n317:4294967295:3011\n318:4294967295:3011\n319:4294967295:3011\n320:4294967295:3011\n321:4294967295:3011\n322:4294967295:3011\n323:4294967295:3011\n324:4294967295:3011\n325:4294967295:3011\n326:4294967295:3011\n327:4294967295:3011\n328:4294967295:3011\n329:4294967295:3011\n330:4294967295:3011\n331:4294967295:3011\n332:4294967295:3011\n333:4294967295:3011\n334:4294967295:3011\n335:4294967295:3011\n336:4294967295:3011\n337:4294967295:3011\n338:4294967295:3011\n339:4294967295:3011\n340:4294967295:3011\n341:4294967295:3011\n342:4294967295:3011\n343:4294967295:3011\n344:4294967295:3011\n345:4294967295:3011\n346:4294967295:3011\n347:4294967295:3011\n348:4294967295:3011\n349:4294967295:3011\n350:4294967295:3011\n351:4294967295:3011\n352:4294967295:3011\n353:4294967295:3011\n354:4294967295:3011\n355:4294967295:3011\n356:4294967295:3011\n357:4294967295:3011\n358:4294967295:3011\n359:4294967295:3011\n360:4294967295:3011\n361:4294967295:3011\n362:4294967295:3011\n363:4294967295:3011\n364:4294967295:3011\n365:4294967295:3011\n366:4294967295:3011\n367:4294967295:3011\n368:4294967295:3011\n369:4294967295:3011\n370:4294967295:3011\n371:4294967295:3011\n372:4294967295:3011\n373:4294967295:3011\n374:4294967295:3011\n375:4294967295:3011\n376:4294967295:3011\n377:4294967295:3011\n378:4294967295:3011\n379:4294967295:3011\n380:4294967295:3011\n381:4294967295:3011\n382:4294967295:3011\n383:4294967295:3011\n384:4294967295:3011\n385:4294967295:3011\n386:4294967295:3011\n387:4294967295:3011\n388:4294967295:3011\n389:4294967295:3011\n390:4294967295:3011\n391:4294967295:3011\n392:4294967295:3011\n393:4294967295:3011\n394:4294967295:3011\n395:4294967295:3011\n396:4294967295:3011\n397:4294967295:3011\n398:4294967295:3011\n399:4294967295:3011\n400:4294967295:3011\n401:4294967295:3011\n402:4294967295:3011\n403:4294967295:3011\n404:4294967295:3011\n405:4294967295:3011\n406:4294967295:3011\n407:4294967295:3011\n408:4294967295:3011\n409:4294967295:3011\n410:4294967295:3011\n411:4294967295:3011\n412:4294967295:3011\n413:4294967295:3011\n414:4294967295:3011\n415:4294967295:3011\n416:4294967295:3011\n417:4294967295:3011\n418:4294967295:3011\n419:4294967295:3011\n420:4294967295:3011\n421:4294967295:3011\n422:4294967295:3011\n423:4294967295:3011\n424:4294967295:3011\n425:4294967295:3011\n426:4294967295:3011\n427:4294967295:3011\n428:4294967295:3011\n429:4294967295:3011\n430:4294967295:3011\n431:4294967295:3011\n432:4294967295:3011\n433:4294967295:3011\n434:4294967295:3011\n435:4294967295:3011\n436:4294967295:3011\n437:4294967295:3011\n438:4294967295:3011\n439:4294967295:3011\n440:4294967295:3011\n441:4294967295:3011\n442:4294967295:3011\n443:4294967295:3011\n444:4294967295:3011\n445:4294967295:3011\n446:4294967295:3011\n447:4294967295:3011\n448:4294967295:3011\n449:4294967295:3011\n450:4294967295:3011\n451:4294967295:3011\n452:4294967295:3011\n453:4294967295:3011\n454:4294967295:3011\n455:4294967295:3011\n456:4294967295:3011\n457:4294967295:3011\n458:4294967295:3011\n459:4294967295:3011\n460:4294967295:3011\n461:4294967295:3011\n462:4294967295:3011\n463:4294967295:3011\n464:4294967295:3011\n465:4294967295:3011\n466:4294967295:3011\n467:4294967295:3011\n468:4294967295:3011\n469:4294967295:3011\n470:4294967295:3011\n471:4294967295:3011\n472:4294967295:3011\n473:4294967295:3011\n474:4294967295:3011\n475:4294967295:3011\n476:4294967295:3011\n477:4294967295:3011\n478:4294967295:3011\n479:4294967295:3011\n480:4294967295:3011\n481:4294967295:3011\n482:4294967295:3011\n483:4294967295:3011\n484:4294967295:3011\n485:4294967295:3011\n486:4294967295:3011\n487:4294967295:3011\n488:4294967295:3011\n489:4294967295:3011\n490:4294967295:3011\n491:4294967295:3011\n492:4294967295:3011\n493:4294967295:3011\n494:4294967295:3011\n495:4294967295:3011\n496:4294967295:3011\n497:4294967295:3011\n498:4294967295:3011\n499:4294967295:3011\n500:4294967295:3011\n501:4294967295:3011\n502:4294967295:3011\n503:4294967295:3011\n504:4294967295:3011\n505:4294967295:3011\n506:4294967295:3011\n507:4294967295:3011\n508:4294967295:3011\n509:4294967295:3011\n510:4294967295:3011\n511:4294967295:3011\n/* Allow RCS service to aquire net_raw permission */\n18:4294967295:1001:3004\n/* Allow QMID service to aquire net_raw permission */\n3:4294967295:1001:3004\n2:4294967295:1001:3004\n42:4294967295:1001:3004\n18:4294967295:1001:3004\n9:4294967295:1001:3004\n1:4294967295:1001:3004:1000\n4:4294967295:1001:3004\n2797:4294967295:1001:3004\n2808:4294967295:1001:3004:1000\n/* DPM */\n47:4294967295:1001:3004\n/* Allow communication to some QMI services with radio privilages */\n/* Format is <Service id>:<all instances>:<radio> */\n/* PBM */\n12:4294967295:1001\n/* WMS */\n5:4294967295:1001\n/* IMS VT */\n32:4294967295:1001\n/* IMSP */\n31:4294967295:1001\n/* PDC */\n36:4294967295:1001\n/* SAR */\n17:4294967295:1001\n/* RFRPE */\n41:4294967295:1001\n/*UIM*/\n11:4294967295:1001\n/*CAT*/\n10:4294967295:1001\n/*IMSA*/\n33:4294967295:1001\n/* CSVT */\n29:4294967295:1001\n/* Allow Data dpmd to access QMI DFS */\n48:4294967295:1000:3004\n/* DIAG */\n4097:4294967295:3009\n"
  },
  {
    "path": "configs/sensors/hals.conf",
    "content": "sensors.ssc.wrapper.so\n"
  },
  {
    "path": "data-ipa-cfg-mgr/Android.mk",
    "content": "#\n# Copyright (C) 2015 The CyanogenMod Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nLOCAL_PATH := $(call my-dir)\n\ninclude $(call first-makefiles-under,$(LOCAL_PATH))\n"
  },
  {
    "path": "data-ipa-cfg-mgr/Makefile.am",
    "content": "ACLOCAL_AMFLAGS = -I m4\nAUTOMAKE_OPTIONS = foreign\nSUBDIRS = ipanat/src ipacm/src/\n"
  },
  {
    "path": "data-ipa-cfg-mgr/configure.ac",
    "content": "#                                               -*- Autoconf -*-\n# Process this file with autoconf to produce a configure script.\n\nAC_PREREQ([2.65])\nAC_INIT(data-ipa, 1.0.0)\nAM_INIT_AUTOMAKE(data-ipa, 1.0.0)\nAC_OUTPUT(Makefile ipanat/src/Makefile ipacm/src/Makefile)\nAC_CONFIG_SRCDIR([ipanat/src/ipa_nat_drv.c])\nAC_CONFIG_HEADERS([config.h])\nAC_CONFIG_MACRO_DIR([m4])\n\n# Checks for programs.\nAC_PROG_CC\nAC_PROG_LIBTOOL\nAC_PROG_CXX\n\nPKG_CHECK_MODULES([LIBXML], [libxml-2.0])\nAC_SUBST([LIBXML_CFLAGS])\nAC_SUBST([LIBXML_LIBS])\n\n# Checks for libraries.\n\nAC_ARG_WITH(sanitized-headers,\n      AS_HELP_STRING([--with-sanitized-headers=DIR],\n         [Specify the location of the sanitized Linux headers]),\n      [CPPFLAGS=\"$CPPFLAGS -idirafter $withval\"])\n\nAC_ARG_WITH([glib],\n      AC_HELP_STRING([--with-glib],\n         [enable glib, building HLOS systems which use glib]))\n\nif (test \"x${with_glib}\" = \"xyes\"); then\n        AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])\n        PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,\n                                AC_MSG_ERROR(GThread >= 2.16 is required))\n        PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,\n                                AC_MSG_ERROR(GLib >= 2.16 is required))\n        GLIB_CFLAGS=\"$GLIB_CFLAGS $GTHREAD_CFLAGS\"\n        GLIB_LIBS=\"$GLIB_LIBS $GTHREAD_LIBS\"\n        AC_SUBST(GLIB_CFLAGS)\n        AC_SUBST(GLIB_LIBS)\nfi\n\nAM_CONDITIONAL(USE_GLIB, test \"x${with_glib}\" = \"xyes\")\n\t  \n# Checks for header files.\nAC_CHECK_HEADERS([fcntl.h netinet/in.h sys/ioctl.h unistd.h])\n\n# Checks for typedefs, structures, and compiler characteristics.\nAC_TYPE_OFF_T\n\n# Checks for library functions.\nAC_FUNC_MALLOC\nAC_FUNC_MMAP\nAC_CHECK_FUNCS([memset munmap])\n\nAC_OUTPUT\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_CmdQueue.h\n\n\t@brief\n\tThis file implements the IPAM Comment Queue definitions\n\n\t@Author\n\n*/\n#ifndef IPA_CONNTRACK_MESSAGE_H\n#define IPA_CONNTRACK_MESSAGE_H\n\n#include <pthread.h>\n#include \"IPACM_Defs.h\"\n\n\n\n/*---------------------------------------------------------------------------\n\t Event data required by IPA_CM\n---------------------------------------------------------------------------*/\n\n\ntypedef struct _ipacm_cmd_q_data {\n\tipa_cm_event_id event;\n\tvoid *evt_data;\n}ipacm_cmd_q_data;\n\ntypedef struct cmd_s\n{\n\tvoid (*callback_ptr)(ipacm_cmd_q_data *);\n\tipacm_cmd_q_data data;\n}cmd_t;\n\nclass Message\n{\nprivate:\n\tMessage *m_next;\n\npublic:\n\tcmd_t evt;\n\n\tMessage()\n\t{\n\t\tm_next = NULL;\n\t\tevt.callback_ptr = NULL;\n\t}\n\t~Message() { }\n\tvoid setnext(Message *item) { m_next = item; }\n\tMessage* getnext()       { return m_next; }\n};\n\nclass MessageQueue\n{\n\nprivate:\n\tMessage *Head;\n\tMessage *Tail;\n\tMessage* dequeue(void);\n\tstatic MessageQueue *inst;\n\n\tMessageQueue()\n\t{\n\t\tHead = NULL;\n\t\tTail = NULL;\n\t}\n\npublic:\n\n\t~MessageQueue() { }\n\tvoid enqueue(Message *item);\n\n\tstatic void* Process(void *);\n\tstatic MessageQueue* getInstance();\n\n};\n\n#endif  /* IPA_CONNTRACK_MESSAGE_H */\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Config.h\n\n\t@brief\n\tThis file implements the IPACM Configuration from XML file\n\n\t@Author\n\tSkylar Chang\n\n*/\n#ifndef IPACM_CONFIG_H\n#define IPACM_CONFIG_H\n\n#include \"IPACM_Defs.h\"\n#include \"IPACM_Xml.h\"\n#include \"IPACM_EvtDispatcher.h\"\n\ntypedef struct\n{\n  char iface_name[IPA_IFACE_NAME_LEN];\n}NatIfaces;\n\n/* for IPACM rm dependency use*/\ntypedef struct _ipa_rm_client\n{\n    ipa_rm_resource_name producer_rm1;\n    ipa_rm_resource_name consumer_rm1;\n    ipa_rm_resource_name producer_rm2;\n    ipa_rm_resource_name consumer_rm2;\n    bool producer1_up;            /* only monitor producer_rm1, not monitor producer_rm2 */\n    bool consumer1_up;            /* only monitor consumer_rm1, not monitor consumer_rm2 */\n    bool rm_set;                  /* once producer1_up and consumer1_up, will add bi-directional dependency */\n    bool rx_bypass_ipa;          /* support WLAN may not register RX-property, should not add dependency */\n}ipa_rm_client;\n\n#define MAX_NUM_EXT_PROPS 15\n\n/* used to hold extended properties */\ntypedef struct\n{\n\tuint8_t num_ext_props;\n\tipa_ioc_ext_intf_prop prop[MAX_NUM_EXT_PROPS];\n} ipacm_ext_prop;\n\n/* iface */\nclass IPACM_Config\n{\npublic:\n\n\t/* IPACM ipa_client map to rm_resource*/\n\tipa_rm_resource_name ipa_client_rm_map_tbl[IPA_CLIENT_MAX];\n\n\t/* IPACM monitored rm_depency table */\n\tipa_rm_client ipa_rm_tbl[IPA_MAX_RM_ENTRY];\n\n\t/* IPACM rm_depency a2 endpoint check*/\n\tint ipa_rm_a2_check;\n\n\t/* Store interested interface and their configuration from XML file */\n\tipa_ifi_dev_name_t *iface_table;\n\n\t/* Store interested ALG port from XML file */\n\tipacm_alg *alg_table;\n\n\t/* Store private subnet configuration from XML file */\n\tipa_private_subnet private_subnet_table[IPA_MAX_PRIVATE_SUBNET_ENTRIES];\n\n\t/* Store the non nat iface names */\n\tNatIfaces *pNatIfaces;\n\n\t/* Store the bridge iface names */\n\tchar ipa_virtual_iface_name[IPA_IFACE_NAME_LEN];\n\n\t/* Store the number of interface IPACM read from XML file */\n\tint ipa_num_ipa_interfaces;\n\n\tint ipa_num_private_subnet;\n\n\tint ipa_num_alg_ports;\n\n\tint ipa_nat_max_entries;\n\n\tbool ipacm_odu_router_mode;\n\n\tbool ipacm_odu_enable;\n\n\tint ipa_nat_iface_entries;\n\n\t/* Store SW-enable or not */\n\tbool ipa_sw_rt_enable;\n\n\t/* IPACM routing table name for v4/v6 */\n\tstruct ipa_ioc_get_rt_tbl rt_tbl_lan_v4, rt_tbl_wan_v4, rt_tbl_default_v4, rt_tbl_v6, rt_tbl_wan_v6;\n\tstruct ipa_ioc_get_rt_tbl rt_tbl_wan_dl;\n\tstruct ipa_ioc_get_rt_tbl rt_tbl_lan2lan_v4, rt_tbl_lan2lan_v6;\n\n\tstruct ipa_ioc_get_rt_tbl rt_tbl_odu_v4, rt_tbl_odu_v6;\n\n\tstruct ipa_ioc_get_rt_tbl rt_tbl_eth_bridge_usb_wlan_v4, rt_tbl_eth_bridge_wlan_wlan_v4;\n\tstruct ipa_ioc_get_rt_tbl rt_tbl_eth_bridge_usb_wlan_v6, rt_tbl_eth_bridge_wlan_wlan_v6;\n\n\t/* To return the instance */\n\tstatic IPACM_Config* GetInstance();\n\n\tinline int GetAlgPortCnt()\n\t{\n\t\treturn ipa_num_alg_ports;\n\t}\n\n\tint GetAlgPorts(int nPorts, ipacm_alg *pAlgPorts);\n\n\tinline int GetNatMaxEntries(void)\n\t{\n\t\treturn ipa_nat_max_entries;\n\t}\n\n\tinline int GetNatIfacesCnt()\n\t{\n\t\treturn ipa_nat_iface_entries;\n\t}\n\tint GetNatIfaces(int nPorts, NatIfaces *ifaces);\n\n\t/* for IPACM resource manager dependency usage */\n\tvoid AddRmDepend(ipa_rm_resource_name rm1,bool rx_bypass_ipa);\n\n\tvoid DelRmDepend(ipa_rm_resource_name rm1);\n\n\tint AddNatIfaces(char *dev_name);\n\n\tint DelNatIfaces(char *dev_name);\n\n\tinline void SetQmapId(uint8_t id)\n\t{\n\t\tqmap_id = id;\n\t}\n\n\tinline uint8_t GetQmapId()\n\t{\n\t\treturn qmap_id;\n\t}\n\n\tint SetExtProp(ipa_ioc_query_intf_ext_props *prop);\n\n\tipacm_ext_prop* GetExtProp(ipa_ip_type ip_type);\n\n\tint DelExtProp(ipa_ip_type ip_type);\n\n\tint Init(void);\n\n\tinline bool isPrivateSubnet(uint32_t ip_addr)\n\t{\n\t\tfor(int cnt=0; cnt<ipa_num_private_subnet; cnt++)\n\t\t{\n\t\t\tif(private_subnet_table[cnt].subnet_addr ==\n\t\t\t\t (private_subnet_table[cnt].subnet_mask & ip_addr))\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n#ifdef FEATURE_IPA_ANDROID\n\tinline bool AddPrivateSubnet(uint32_t ip_addr, int ipa_if_index)\n\t{\n\t\tipacm_cmd_q_data evt_data;\n\t\tipacm_event_data_fid *data_fid;\n\t\tuint32_t subnet_mask = ~0;\n\t\tfor(int cnt=0; cnt<ipa_num_private_subnet; cnt++)\n\t\t{\n\t\t\tif(private_subnet_table[cnt].subnet_addr == ip_addr)\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Already has private subnet_addr as: 0x%x in entry(%d) \\n\", ip_addr, cnt);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif(ipa_num_private_subnet < IPA_MAX_PRIVATE_SUBNET_ENTRIES)\n\t\t{\n\t\t\tIPACMDBG(\"Add IPACM private subnet_addr as: 0x%x in entry(%d) \\n\", ip_addr, ipa_num_private_subnet);\n\t\t\tprivate_subnet_table[ipa_num_private_subnet].subnet_addr = ip_addr;\n\t\t\tprivate_subnet_table[ipa_num_private_subnet].subnet_mask = (subnet_mask >> 8) << 8;\n\t\t\tipa_num_private_subnet++;\n\n\t\t\t/* IPACM private subnet set changes */\n\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\tif(data_fid == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event data_fid\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\tdata_fid->if_index = ipa_if_index; // already ipa index, not fid index\n\t\t\tevt_data.event = IPA_PRIVATE_SUBNET_CHANGE_EVENT;\n\t\t\tevt_data.evt_data = data_fid;\n\n\t\t\t/* Insert IPA_PRIVATE_SUBNET_CHANGE_EVENT to command queue */\n\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\treturn true;\n\t\t}\n\t\tIPACMERR(\"IPACM private subnet_addr overflow, total entry(%d)\\n\", ipa_num_private_subnet);\n\t\treturn false;\n\t}\n\n\tinline bool DelPrivateSubnet(uint32_t ip_addr, int ipa_if_index)\n\t{\n\t\tipacm_cmd_q_data evt_data;\n\t\tipacm_event_data_fid *data_fid;\n\t\tfor(int cnt=0; cnt<ipa_num_private_subnet; cnt++)\n\t\t{\n\t\t\tif(private_subnet_table[cnt].subnet_addr == ip_addr)\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Found private subnet_addr as: 0x%x in entry(%d) \\n\", ip_addr, cnt);\n\t\t\t\tfor (; cnt < ipa_num_private_subnet - 1; cnt++)\n\t\t\t\t{\n\t\t\t\t\tprivate_subnet_table[cnt].subnet_addr = private_subnet_table[cnt+1].subnet_addr;\n\t\t\t\t}\n\t\t\t\tipa_num_private_subnet = ipa_num_private_subnet - 1;\n\n\t\t\t\t/* IPACM private subnet set changes */\n\t\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\t\tif(data_fid == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_fid\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tdata_fid->if_index = ipa_if_index; // already ipa index, not fid index\n\t\t\t\tevt_data.event = IPA_PRIVATE_SUBNET_CHANGE_EVENT;\n\t\t\t\tevt_data.evt_data = data_fid;\n\n\t\t\t\t/* Insert IPA_PRIVATE_SUBNET_CHANGE_EVENT to command queue */\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tIPACMDBG(\"can't find private subnet_addr as: 0x%x \\n\", ip_addr);\n\t\treturn false;\n\t}\n#endif /* defined(FEATURE_IPA_ANDROID)*/\n\n\tstatic const char *DEVICE_NAME_ODU;\n\nprivate:\n\tstatic IPACM_Config *pInstance;\n\tstatic const char *DEVICE_NAME;\n\tIPACM_Config(void);\n\tint m_fd; /* File descriptor of the IPA device node /dev/ipa */\n\tuint8_t qmap_id;\n\tipacm_ext_prop ext_prop_v4;\n\tipacm_ext_prop ext_prop_v6;\n};\n\n#endif /* IPACM_CONFIG */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackClient.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef IPACM_CONNTRACK_FILTER_H\n#define IPACM_CONNTRACK_FILTER_H\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <arpa/inet.h>\n#include <netinet/in.h>\n#include <errno.h>\n\n#include \"IPACM_ConntrackClient.h\"\n#include \"IPACM_CmdQueue.h\"\n#include \"IPACM_Conntrack_NATApp.h\"\n#include \"IPACM_EvtDispatcher.h\"\n#include \"IPACM_Defs.h\"\n\n#ifndef IPACM_DEBUG\n#define IPACM_DEBUG\n#endif\n\nextern \"C\"\n{\n#include <libnetfilter_conntrack/libnetfilter_conntrack.h>\n#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>\n#include <sys/inotify.h>\n}\n\nusing namespace std;\n\n#define UDP_TIMEOUT_UPDATE 20\n#define BROADCAST_IPV4_ADDR 0xFFFFFFFF\n\n\n#define IPACM_TCP_UDP_DIR_NAME       \"/proc/sys/net/ipv4/netfilter\"\n#define IPACM_TCP_FILE_NAME  \"ip_conntrack_tcp_timeout_established\"\n#define IPACM_UDP_FILE_NAME   \"ip_conntrack_udp_timeout_stream\"\n\n#define IPACM_TCP_FULL_FILE_NAME  \"/proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_established\"\n#define IPACM_UDP_FULL_FILE_NAME   \"/proc/sys/net/ipv4/netfilter/ip_conntrack_udp_timeout_stream\"\n\n#define INOTIFY_EVT_SIZE  (sizeof(struct inotify_event))\n#define INOTIFY_BUFFER_LEN     (INOTIFY_EVT_SIZE + 2*sizeof(IPACM_TCP_FILE_NAME))\n\nclass IPACM_ConntrackClient\n{\n\nprivate:\n   static IPACM_ConntrackClient *pInstance;\n\n   struct nfct_handle *tcp_hdl;\n   struct nfct_handle *udp_hdl;\n   struct nfct_filter *tcp_filter;\n   struct nfct_filter *udp_filter;\n   static int IPA_Conntrack_Filters_Ignore_Local_Addrs(struct nfct_filter *filter);\n   static int IPA_Conntrack_Filters_Ignore_Bridge_Addrs(struct nfct_filter *filter);\n   static int IPA_Conntrack_Filters_Ignore_Local_Iface(struct nfct_filter *, ipacm_event_iface_up *);\n   IPACM_ConntrackClient();\n\npublic:\n   static int IPAConntrackEventCB(enum nf_conntrack_msg_type type,\n                                  struct nf_conntrack *ct,\n                                  void *data);\n\n   static int IPA_Conntrack_UDP_Filter_Init(void);\n   static int IPA_Conntrack_TCP_Filter_Init(void);\n   static void* TCPRegisterWithConnTrack(void *);\n   static void* UDPRegisterWithConnTrack(void *);\n   static void* UDPConnTimeoutUpdate(void *);\n   static void* TCPUDP_Timeout_monitor(void *);\n\n   static void UpdateUDPFilters(void *, bool);\n   static void UpdateTCPFilters(void *, bool);\n   static void Read_TcpUdp_Timeout(char *in, int len);\n\n   static IPACM_ConntrackClient* GetInstance();\n\n#ifdef IPACM_DEBUG\n#define iptodot(X,Y) \\\n\t\t IPACMLOG(\" %s(0x%x): %d.%d.%d.%d\\n\", X, Y, ((Y>>24) & 0xFF), ((Y>>16) & 0xFF), ((Y>>8) & 0xFF), (Y & 0xFF));\n#endif\n\n};\n\n#endif  /* IPACM_CONNTRACK_FILTER_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef IPACM_CONNTRACK_LISTENER\n#define IPACM_CONNTRACK_LISTENER\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <fcntl.h>\n\n#include <arpa/inet.h>\n#include <netinet/in.h>\n#include <errno.h>\n\n#include \"IPACM_CmdQueue.h\"\n#include \"IPACM_Conntrack_NATApp.h\"\n#include \"IPACM_Listener.h\"\n#ifdef CT_OPT\n#include \"IPACM_LanToLan.h\"\n#endif\n\n#define MAX_NAT_IFACES 50\n#define MAX_STA_CLNT_IFACES 10\n\nusing namespace std;\n\nclass IPACM_ConntrackListener : public IPACM_Listener\n{\n\nprivate:\n\tbool isCTReg;\n\tbool isNatThreadStart;\n\tbool WanUp;\n\tNatApp *nat_inst;\n\n\tint NatIfaceCnt;\n\tint StaClntCnt;\n\tNatIfaces *pNatIfaces;\n\tuint32_t nat_iface_ipv4_addr[MAX_NAT_IFACES];\n\tuint32_t nonnat_iface_ipv4_addr[MAX_NAT_IFACES];\n\tuint32_t sta_clnt_ipv4_addr[MAX_STA_CLNT_IFACES];\n\tIPACM_Config *pConfig;\n#ifdef CT_OPT\n\tIPACM_LanToLan *p_lan2lan;\n#endif\n\n\tvoid ProcessCTMessage(void *);\n\tvoid ProcessTCPorUDPMsg(struct nf_conntrack *,\n\tenum nf_conntrack_msg_type, u_int8_t);\n\tvoid TriggerWANUp(void *);\n\tvoid TriggerWANDown(uint32_t);\n\tint  CreateNatThreads(void);\n\tint  CreateConnTrackThreads(void);\n\n#ifdef CT_OPT\n\tvoid ProcessCTV6Message(void *);\n#endif\n\npublic:\n\tchar wan_ifname[IPA_IFACE_NAME_LEN];\n\tuint32_t wan_ipaddr;\n\tbool isStaMode;\n\tIPACM_ConntrackListener();\n\tvoid event_callback(ipa_cm_event_id, void *data);\n\tinline bool isWanUp()\n\t{\n\t\treturn WanUp;\n\t}\n\n\tvoid HandleNeighIpAddrAddEvt(ipacm_event_data_all *);\n\tvoid HandleNeighIpAddrDelEvt(uint32_t);\n\tvoid HandleSTAClientAddEvt(uint32_t);\n\tvoid HandleSTAClientDelEvt(uint32_t);\n};\n\nextern IPACM_ConntrackListener *CtList;\n\n#endif /* IPACM_CONNTRACK_LISTENER */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef IPACM_CONNTRACK_NATAPP_H\n#define IPACM_CONNTRACK_NATAPP_H\n\n#include <string.h>  /* for stderror */\n#include <stdlib.h>\n#include <cstdio>  /* for perror */\n\n#include \"IPACM_Config.h\"\n#include \"IPACM_Xml.h\"\n\nextern \"C\"\n{\n#include <libnetfilter_conntrack/libnetfilter_conntrack.h>\n#include <ipa_nat_drv.h>\n}\n\n#define MAX_TEMP_ENTRIES 25\n\ntypedef struct _nat_table_entry\n{\n\tuint32_t private_ip;\n\tuint16_t private_port;\n\n\tuint32_t target_ip;\n\tuint16_t target_port;\n\n\tuint16_t public_ip;\n\tuint16_t public_port;\n\n\tu_int8_t  protocol;\n\tuint32_t timestamp;\n\n\tbool dst_nat;\n\tbool enabled;\n\tuint32_t rule_hdl;\n\n}nat_table_entry;\n\n#define CHK_TBL_HDL()  if(nat_table_hdl == 0){ return -1; }\n\nclass NatApp\n{\nprivate:\n\n\tstatic NatApp *pInstance;\n\n\tnat_table_entry *cache;\n\tnat_table_entry temp[MAX_TEMP_ENTRIES];\n\tuint32_t pub_ip_addr;\n\tuint32_t pub_ip_addr_pre;\n\tuint32_t nat_table_hdl;\n\n\tint curCnt, max_entries;\n\n\tipacm_alg *pALGPorts;\n\tuint16_t nALGPort;\n\n\tuint32_t tcp_timeout;\n\tuint32_t udp_timeout;\n\n\tuint32_t PwrSaveIfs[IPA_MAX_NUM_WIFI_CLIENTS];\n\n\tstruct nf_conntrack *ct;\n\tstruct nfct_handle *ct_hdl;\n\n\tNatApp();\n\tint Init();\n\n\tvoid UpdateCTUdpTs(nat_table_entry *, uint32_t);\n\tbool ChkForDup(const nat_table_entry *);\n\tbool isAlgPort(uint8_t, uint16_t);\n\tvoid Reset();\n\tbool isPwrSaveIf(uint32_t);\n\npublic:\n\tstatic NatApp* GetInstance();\n\n\tint AddTable(uint32_t);\n\tuint32_t GetTableHdl(uint32_t);\n\tint DeleteTable(uint32_t);\n\n\tint AddEntry(const nat_table_entry *);\n\tint DeleteEntry(const nat_table_entry *);\n\n\tvoid UpdateUDPTimeStamp();\n\n\tint UpdatePwrSaveIf(uint32_t);\n\tint ResetPwrSaveIf(uint32_t);\n\tint DelEntriesOnClntDiscon(uint32_t);\n\tint DelEntriesOnSTAClntDiscon(uint32_t);\n\n\tvoid UpdateTcpUdpTo(uint32_t, int proto);\n\n\tvoid AddTempEntry(const nat_table_entry *);\n\tvoid CacheEntry(const nat_table_entry *);\n\tvoid DeleteTempEntry(const nat_table_entry *);\n\tvoid FlushTempEntries(uint32_t, bool);\n};\n\n\n\n#endif /* IPACM_CONNTRACK_NATAPP_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Defs.h\n\n\t@brief\n\tThis file implements the common definitions amon all ifaces.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#ifndef IPA_CM_DEFS_H\n#define IPA_CM_DEFS_H\n\n#include <unistd.h>\n#include <fcntl.h>\n#include <linux/msm_ipa.h>\n#include \"IPACM_Log.h\"\n\nextern \"C\"\n{\n#include <libnetfilter_conntrack/libnetfilter_conntrack.h>\n#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>\n}\n\n#define IF_NAME_LEN 16\n#define IPA_MAX_FILE_LEN  64\n#define IPA_IFACE_NAME_LEN 16\n#define IPA_ALG_PROTOCOL_NAME_LEN  10\n\n#define IPA_WLAN_PARTIAL_HDR_OFFSET  0 // dst mac first then src mac\n//#define IPA_ETH_PARTIAL_HDR_OFFSET  8 // dst mac first then src mac\n#define IPA_ODU_PARTIAL_HDR_OFFSET  8 // dst mac first then src mac\n#define IPA_WLAN_PARTIAL_HDR_NAME_v4  \"IEEE802_3_v4\"\n#define IPA_WLAN_PARTIAL_HDR_NAME_v6  \"IEEE802_3_v6\"\n#define IPA_WAN_PARTIAL_HDR_NAME_v4  \"IEEE802_3_STA_v4\"\n#define IPA_WAN_PARTIAL_HDR_NAME_v6  \"IEEE802_3_STA_v6\"\n#define IPA_ETH_HDR_NAME_v4  \"IPACM_ETH_v4\"\n#define IPA_ETH_HDR_NAME_v6  \"IPACM_ETH_v6\"\n#define IPA_ODU_HDR_NAME_v4  \"IPACM_ODU_v4\"\n#define IPA_ODU_HDR_NAME_v6  \"IPACM_ODU_v6\"\n\n\n#define IPA_MAX_IFACE_ENTRIES 15\n#define IPA_MAX_PRIVATE_SUBNET_ENTRIES 3\n#define IPA_MAX_ALG_ENTRIES 20\n#define IPA_MAX_RM_ENTRY 6\n\n#define V4_DEFAULT_ROUTE_TABLE_NAME  \"ipa_dflt_rt\"\n#define V4_LAN_ROUTE_TABLE_NAME  \"COMRTBLLANv4\"\n#define V4_WAN_ROUTE_TABLE_NAME  \"WANRTBLv4\"\n#define WAN_DL_ROUTE_TABLE_NAME \"ipa_dflt_wan_rt\"\n#define V6_COMMON_ROUTE_TABLE_NAME  \"COMRTBLv6\"\n#define V6_WAN_ROUTE_TABLE_NAME  \"WANRTBLv6\"\n#define V4_LAN_TO_LAN_ROUTE_TABLE_NAME \"LANTOLANRTBLv4\"\n#define V6_LAN_TO_LAN_ROUTE_TABLE_NAME \"LANTOLANRTBLv6\"\n#define V4_ODU_ROUTE_TABLE_NAME  \"ODURTBLv4\"\n#define V6_ODU_ROUTE_TABLE_NAME  \"ODURTBLv6\"\n\n#define ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V4 \"ETH_BRIDGE_USB_WLAN_RTBLv4\"\n#define ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V4 \"ETH_BRIDGE_WLAN_WLAN_RTBLv4\"\n#define ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V6 \"ETH_BRIDGE_USB_WLAN_RTBLv6\"\n#define ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V6 \"ETH_BRIDGE_WLAN_WLAN_RTBLv6\"\n\n#define WWAN_QMI_IOCTL_DEVICE_NAME \"/dev/wwan_ioctl\"\n#define IPA_DEVICE_NAME \"/dev/ipa\"\n#define IPA_MAX_FLT_RULE 50\n\n#define MAX_OFFLOAD_PAIR 3\n#define MAX_NUM_PROP 8\n#define IPA_LAN_TO_LAN_USB_HDR_NAME_V4 \"Lan2Lan_USB_v4\"\n#define IPA_LAN_TO_LAN_USB_HDR_NAME_V6 \"Lan2Lan_USB_v6\"\n#define IPA_LAN_TO_LAN_WLAN_HDR_NAME_V4 \"Lan2Lan_Wlan_v4\"\n#define IPA_LAN_TO_LAN_WLAN_HDR_NAME_V6 \"Lan2Lan_Wlan_v6\"\n#define IPA_LAN_TO_LAN_MAX_WLAN_CLIENT 32\n#define IPA_LAN_TO_LAN_MAX_USB_CLIENT 1\n#define TCP_FIN_SHIFT 16\n#define TCP_SYN_SHIFT 17\n#define TCP_RST_SHIFT 18\n#define NUM_TCP_CTL_FLT_RULE 3\n\n/*---------------------------------------------------------------------------\n\t\t\t\t\t\t\t\t\t\tReturn values indicating error status\n---------------------------------------------------------------------------*/\n\n#define IPACM_SUCCESS                0         /* Successful operation   */\n#define IPACM_FAILURE               -1         /* Unsuccessful operation */\n\n#define IPACM_IP_NULL (ipa_ip_type)0xFF\n#define IPACM_INVALID_INDEX (ipa_ip_type)0xFF\n\n#define IPA_MAX_NUM_WIFI_CLIENTS  32\n#define IPA_MAX_NUM_WAN_CLIENTS  10\n#define IPA_MAX_NUM_ETH_CLIENTS  15\n#define IPA_MAX_NUM_AMPDU_RULE  15\n#define IPA_MAC_ADDR_SIZE  6\n\n/*===========================================================================\n\t\t\t\t\t\t\t\t\t\t GLOBAL DEFINITIONS AND DECLARATIONS\n===========================================================================*/\ntypedef enum\n{\n\tIPA_CFG_CHANGE_EVENT = 1,                 /* 1 NULL */\n\tIPA_LINK_UP_EVENT,                        /* 2 ipacm_event_data_fid */\n\tIPA_LINK_DOWN_EVENT,                      /* 3 ipacm_event_data_fid */\n\tIPA_ADDR_ADD_EVENT,                       /* 4 ipacm_event_data_addr */\n\tIPA_ADDR_DEL_EVENT,                       /* 5 no use */\n\tIPA_ROUTE_ADD_EVENT,                      /* 6 ipacm_event_data_addr */\n\tIPA_ROUTE_DEL_EVENT,                      /* 7 ipacm_event_data_addr */\n\tIPA_FIREWALL_CHANGE_EVENT,                /* 8 NULL */\n\tIPA_WLAN_AP_LINK_UP_EVENT,                /* 9 ipacm_event_data_mac */\n\tIPA_WLAN_STA_LINK_UP_EVENT,               /* 10 ipacm_event_data_mac */\n\tIPA_WLAN_CLIENT_ADD_EVENT,                /* 11 ipacm_event_data_mac */\n\tIPA_WLAN_CLIENT_DEL_EVENT,                /* 12 ipacm_event_data_mac */\n\tIPA_WLAN_CLIENT_POWER_SAVE_EVENT,         /* 13 ipacm_event_data_mac */\n\tIPA_WLAN_CLIENT_RECOVER_EVENT,            /* 14 ipacm_event_data_mac */\n\tIPA_NEW_NEIGH_EVENT,                      /* 15 ipacm_event_data_all */\n\tIPA_DEL_NEIGH_EVENT,                      /* 16 ipacm_event_data_all */\n\tIPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT,       /* 17 ipacm_event_data_all */\n\tIPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT,       /* 18 ipacm_event_data_all */\n\tIPA_SW_ROUTING_ENABLE,                    /* 19 NULL */\n\tIPA_SW_ROUTING_DISABLE,                   /* 20 NULL */\n\tIPA_PROCESS_CT_MESSAGE,                   /* 21 ipacm_ct_evt_data */\n\tIPA_HANDLE_WAN_UP,                        /* 22 ipacm_event_iface_up  */\n\tIPA_HANDLE_WAN_DOWN,                      /* 23 ipacm_event_iface_up  */\n\tIPA_HANDLE_WLAN_UP,                       /* 24 ipacm_event_iface_up */\n\tIPA_HANDLE_LAN_UP,                        /* 25 ipacm_event_iface_up */\n\tIPA_WLAN_CLIENT_ADD_EVENT_EX,             /* 26 ipacm_event_data_wlan_ex */\n\tIPA_HANDLE_WAN_UP_V6,\t\t\t\t\t  /* 27 NULL */\n\tIPA_HANDLE_WAN_DOWN_V6,\t\t\t\t\t  /* 28 NULL */\n\tIPA_LAN_CLIENT_ACTIVE,\t\t\t\t\t  /* 29 ipacm_event_lan_client*/\n\tIPA_LAN_CLIENT_INACTIVE,\t\t\t\t  /* 30 ipacm_event_lan_client*/\n\tIPA_LAN_CLIENT_DISCONNECT,\t\t\t\t  /* 31 ipacm_event_lan_client*/\n\tIPA_LAN_CLIENT_POWER_SAVE,\t\t\t\t  /* 32 ipacm_event_lan_client*/\n\tIPA_LAN_CLIENT_POWER_RECOVER,\t\t\t  /* 33 ipacm_event_lan_client*/\n\tIPA_LAN_TO_LAN_NEW_CONNECTION,\t\t\t  /* 34 ipacm_event_connection */\n\tIPA_LAN_TO_LAN_DEL_CONNECTION,\t\t\t  /* 35 ipacm_event_connection */\n\tIPA_LAN_DELETE_SELF,\t\t\t\t\t  /* 36 ipacm_event_data_fid */\n\tIPA_WLAN_LINK_DOWN_EVENT,                 /* 37 ipacm_event_data_mac */\n\tIPA_USB_LINK_UP_EVENT,                    /* 38 ipacm_event_data_fid */\n\tIPA_PROCESS_CT_MESSAGE_V6,                /* 39 ipacm_ct_evt_data */\n\tIPA_PRIVATE_SUBNET_CHANGE_EVENT,          /* 40 ipacm_event_data_fid */\n\tIPA_WAN_UPSTREAM_ROUTE_ADD_EVENT,         /* 41 ipacm_event_data_fid */\n\tIPA_WAN_UPSTREAM_ROUTE_DEL_EVENT,         /* 42 ipacm_event_data_fid */\n\tIPA_WAN_EMBMS_LINK_UP_EVENT,              /* 43 ipacm_event_data_mac */\n\tIPA_ETH_BRIDGE_USB_CLIENT_ADD_EVENT,      /* 44 ipacm_event_data_mac */\n\tIPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT,     /* 45 ipacm_event_data_mac */\n\tIPA_ETH_BRIDGE_USB_CLIENT_DEL_EVENT,      /* 46 ipacm_event_data_mac */\n\tIPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT,     /* 47 ipacm_event_data_mac */\n\tIPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT,    /* 48 ipacm_event_data_if_cat */\n\tIPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT,  /* 49 ipacm_event_data_if_cat */\n\tIPA_WLAN_SWITCH_TO_SCC,                   /* 50 No Data */\n\tIPA_WLAN_SWITCH_TO_MCC,                   /* 51 No Data */\n\tIPA_CRADLE_WAN_MODE_SWITCH,               /* 52 ipacm_event_cradle_wan_mode */\n\tIPA_WAN_XLAT_CONNECT_EVENT,               /* 53 ipacm_event_data_fid */\n\tIPA_TETHERING_STATS_UPDATE_EVENT,         /* 54 ipacm_event_data_fid */\n\tIPA_NETWORK_STATS_UPDATE_EVENT,           /* 55 ipacm_event_data_fid */\n\tIPA_HANDLE_WAN_UP_TETHER,                 /* 56 ipacm_event_iface_up_tehter */\n\tIPA_HANDLE_WAN_DOWN_TETHER,               /* 57 ipacm_event_iface_up_tehter */\n\tIPA_HANDLE_WAN_UP_V6_TETHER,\t\t  /* 58 ipacm_event_iface_up_tehter */\n\tIPA_HANDLE_WAN_DOWN_V6_TETHER,\t\t  /* 59 ipacm_event_iface_up_tehter */\n\tIPACM_EVENT_MAX\n} ipa_cm_event_id;\n\ntypedef struct\n{\n\tuint8_t num_rule;\n\tuint32_t rule_hdl[MAX_NUM_PROP];\n} lan_to_lan_rt_rule_hdl;\n\ntypedef enum\n{\n\tLAN_IF = 0,\n\tWLAN_IF,\n\tWAN_IF,\n\tVIRTUAL_IF,\n\tETH_IF,\n\tEMBMS_IF,\n\tODU_IF,\n\tUNKNOWN_IF\n} ipacm_iface_type;\n\ntypedef struct\n{\n\tstruct nf_conntrack *ct;\n\tenum nf_conntrack_msg_type type;\n}ipacm_ct_evt_data;\n\ntypedef struct\n{\n\tchar iface_name[IPA_IFACE_NAME_LEN];\n\tipacm_iface_type if_cat;\n\tint netlink_interface_index;\n} ipa_ifi_dev_name_t;\n\ntypedef struct\n{\n\tuint32_t subnet_addr;\n\tuint32_t subnet_mask;\n} ipa_private_subnet;\n\n\ntypedef struct _ipacm_event_data_all\n{\n\tenum ipa_ip_type iptype;\n\tint if_index;\n\tuint32_t  ipv4_addr;\n\tuint32_t  ipv6_addr[4];\n\tuint8_t mac_addr[IPA_MAC_ADDR_SIZE];\n} ipacm_event_data_all;\n\nclass IPACM_Lan;\n\ntypedef struct\n{\n\tenum ipa_ip_type iptype;\n\tuint32_t ipv4_addr;\n\tuint32_t ipv6_addr[4];\n\tuint8_t mac_addr[6];\n\tIPACM_Lan* p_iface;\n} ipacm_event_lan_client;\n\ntypedef struct\n{\n\tenum ipa_ip_type iptype;\n\tuint32_t src_ipv4_addr;\n\tuint32_t dst_ipv4_addr;\n\tuint32_t src_ipv6_addr[4];\n\tuint32_t dst_ipv6_addr[4];\n} ipacm_event_connection;\n\ntypedef struct _ipacm_event_data_fid\n{\n\tint if_index;\n} ipacm_event_data_fid;\n\ntypedef struct _ipacm_event_data_iptype\n{\n\tint if_index;\n\tint if_index_tether;\n\tenum ipa_ip_type iptype;\n} ipacm_event_data_iptype;\n\n\ntypedef struct _ipacm_event_data_addr\n{\n\tenum ipa_ip_type iptype;\n\tint if_index;\n\tuint32_t  ipv4_addr;\n\tuint32_t  ipv4_addr_mask;\n\tuint32_t  ipv6_addr[4];\n\tuint32_t  ipv6_addr_mask[4];\n} ipacm_event_data_addr;\n\ntypedef struct _ipacm_event_data_mac\n{\n\tint if_index;\n\tuint8_t mac_addr[IPA_MAC_ADDR_SIZE];\n} ipacm_event_data_mac;\n\ntypedef struct\n{\n\tint if_index;\n\tuint8_t num_of_attribs;\n\tstruct ipa_wlan_hdr_attrib_val attribs[0];\n} ipacm_event_data_wlan_ex;\n\ntypedef struct _ipacm_event_iface_up\n{\n\tchar ifname[IPA_IFACE_NAME_LEN];\n\tuint32_t ipv4_addr;\n\tuint32_t addr_mask;\n\tuint32_t ipv6_prefix[2];\n\tbool is_sta;\n}ipacm_event_iface_up;\n\ntypedef struct _ipacm_event_iface_up_tether\n{\n\tuint32_t if_index_tether;\n\tuint32_t ipv6_prefix[2];\n\tbool is_sta;\n}ipacm_event_iface_up_tehter;\n\ntypedef enum\n{\n\tQ6_WAN = 0,\n\tWLAN_WAN,\n\tECM_WAN\n} ipacm_wan_iface_type;\n\ntypedef struct _ipacm_ifacemgr_data\n{\n\tint if_index;\n\tipacm_wan_iface_type if_type;\n\tuint8_t mac_addr[IPA_MAC_ADDR_SIZE];\n}ipacm_ifacemgr_data;\n\n#endif /* IPA_CM_DEFS_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_EvtDispatcher.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*!\n\t@file\n\tIPACM_EvtDispatcher.h\n\n\t@brief\n\tThis file implements the IPAM event dispatcher definitions\n\n\t@Author\n\n*/\n#ifndef IPACM_EvtDispatcher_H\n#define IPACM_EvtDispatcher_H\n\n#include <stdio.h>\n#include <IPACM_CmdQueue.h>\n#include \"IPACM_Defs.h\"\n#include \"IPACM_Listener.h\"\n\n/* queue */\ntypedef struct _cmd_evts\n{\n\tipa_cm_event_id event;\n\tIPACM_Listener *obj;\n\t//int ipa_interface_index;\n\t_cmd_evts *next;\n}  cmd_evts;\n\n\n\nclass IPACM_EvtDispatcher\n{\npublic:\n\n\t/* api for all iface instances to register events */\n\tstatic int registr(ipa_cm_event_id event, IPACM_Listener *obj);\n\n\t/* api for all iface instances to de-register events */\n\tstatic int deregistr(IPACM_Listener *obj);\n\n\tstatic int PostEvt(ipacm_cmd_q_data *);\n\tstatic void ProcessEvt(ipacm_cmd_q_data *);\n\nprivate:\n\tstatic cmd_evts *head;\n};\n\n#endif /* IPACM_EvtDispatcher_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*!\n\t@file\n\tIPACM_Filtering.h\n\n\t@brief\n\tThis file implements the IPACM filtering definitions\n\n\t@Author\n\tSkylar Chang\n\n*/\n\n#ifndef IPACM_FILTERING_H\n#define IPACM_FILTERING_H\n\n#include <stdint.h>\n#include <linux/msm_ipa.h>\n#include <IPACM_Defs.h>\n#include <linux/rmnet_ipa_fd_ioctl.h>\n\nclass IPACM_Filtering\n{\npublic:\n\tIPACM_Filtering();\n\t~IPACM_Filtering();\n\tbool AddFilteringRule(struct ipa_ioc_add_flt_rule const *ruleTable);\n\tbool DeleteFilteringRule(struct ipa_ioc_del_flt_rule *ruleTable);\n\tbool Commit(enum ipa_ip_type ip);\n\tbool Reset(enum ipa_ip_type ip);\n\tbool DeviceNodeIsOpened();\n\tbool DeleteFilteringHdls(uint32_t *flt_rule_hdls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t ipa_ip_type ip,\n\t\t\t\t\t\t\t\t\t\t\t\t\t uint8_t num_rules);\n\n\tbool AddWanDLFilteringRule(struct ipa_ioc_add_flt_rule const *rule_table_v4, struct ipa_ioc_add_flt_rule const * rule_table_v6, uint8_t mux_id);\n\tbool SendFilteringRuleIndex(struct ipa_fltr_installed_notif_req_msg_v01* table);\n\tbool ModifyFilteringRule(struct ipa_ioc_mdfy_flt_rule* ruleTable);\n\tipa_filter_action_enum_v01 GetQmiFilterAction(ipa_flt_action action);\n\nprivate:\n\tstatic const char *DEVICE_NAME;\n\tint fd; /* File descriptor of the IPA device node /dev/ipa */\n};\n\n#endif //IPACM_FILTERING_H\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Header.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * IPACM_Header.h\n *\n *  Created on: Jun 20, 2012\n *      Author: tatias\n */\n\n//////////////////////////////////////////////////////////////////////////////////\n\n#ifndef IPACM_HEADER_H\n#define IPACM_HEADER_H\n\n#include <stdint.h>\n#include \"linux/msm_ipa.h\"\n\n//////////////////////////////////////////////////////////////////////////////////\n\nclass IPACM_Header\n{\nprivate:\n\tint m_fd;\npublic:\n\tbool AddHeader(struct ipa_ioc_add_hdr   *pHeaderTable);\n\tbool DeleteHeader(struct ipa_ioc_del_hdr *pHeaderTable);\n\tbool GetHeaderHandle(struct ipa_ioc_get_hdr *pHeaderStruct);\n\tbool CopyHeader(struct ipa_ioc_copy_hdr *pCopyHeaderStruct);\n\tbool Commit();\n\tbool Reset();\n\tbool DeleteHeaderHdl(uint32_t hdr_hdl);\n\tbool AddHeaderProcCtx(struct ipa_ioc_add_hdr_proc_ctx* pHeader);\n\tbool DeleteHeaderProcCtx(uint32_t hdl);\n\n\tIPACM_Header();\n\t~IPACM_Header();\n\tbool DeviceNodeIsOpened();\n};\n\n\n#endif\n\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t\t@file\n\t\tIPACM_iface.h\n\n\t\t@brief\n\t\tThis file implements the basis Iface definitions.\n\n\t\t@Author\n\t\tSkylar Chang\n\n*/\n#ifndef IPACM_IFACE_H\n#define IPACM_IFACE_H\n\n#include <stdio.h>\n#include <IPACM_CmdQueue.h>\n#include <linux/msm_ipa.h>\n#include \"IPACM_Routing.h\"\n#include \"IPACM_Filtering.h\"\n#include \"IPACM_Header.h\"\n#include \"IPACM_EvtDispatcher.h\"\n#include \"IPACM_Xml.h\"\n#include \"IPACM_Log.h\"\n#include \"IPACM_Config.h\"\n#include \"IPACM_Defs.h\"\n#include <string.h>\n\n/* current support 2 ipv6-address*/\n#define MAX_DEFAULT_v4_ROUTE_RULES  1\n#define MAX_DEFAULT_v6_ROUTE_RULES  2\n#define IPV4_DEFAULT_FILTERTING_RULES 3\n\n#ifdef FEATURE_IPA_ANDROID\n#define IPV6_DEFAULT_FILTERTING_RULES 6\n#else\n#define IPV6_DEFAULT_FILTERTING_RULES 3\n#endif\n\n#define IPV6_DEFAULT_LAN_FILTERTING_RULES 1\n#define IPV6_NUM_ADDR 3\n#define MAX_SOFTWAREROUTING_FILTERTING_RULES 2\n#define INVALID_IFACE -1\n\n/* iface */\nclass IPACM_Iface :public IPACM_Listener\n{\npublic:\n\n\t/* Static class for reading IPACM configuration from XML file*/\n\tstatic IPACM_Config *ipacmcfg;\n\n\t/* IPACM interface id */\n\tint ipa_if_num;\n\n\t/* IPACM interface category */\n\tint ipa_if_cate;\n\n\t/* IPACM interface name */\n\tchar dev_name[IF_NAME_LEN];\n\n\t/* IPACM interface iptype v4, v6 or both */\n\tipa_ip_type ip_type;\n\n\t/* IPACM interface v6 ip-address*/\n\tuint32_t ipv6_addr[MAX_DEFAULT_v6_ROUTE_RULES][4];\n\n\tuint32_t header_hdl;\n\n\tuint32_t software_routing_fl_rule_hdl[MAX_SOFTWAREROUTING_FILTERTING_RULES];\n\n\tbool softwarerouting_act;\n\n\t/* IPACM number of default route rules for ipv6*/\n\tint num_dft_rt_v6;\n\n\tuint32_t dft_v4fl_rule_hdl[IPV4_DEFAULT_FILTERTING_RULES];\n\tuint32_t dft_v6fl_rule_hdl[IPV6_DEFAULT_FILTERTING_RULES + IPV6_DEFAULT_LAN_FILTERTING_RULES];\n\t/* create additional set of v6 RT-rules in Wanv6RT table*/\n\tuint32_t dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+2*MAX_DEFAULT_v6_ROUTE_RULES];\n\n\tipa_ioc_query_intf *iface_query;\n\tipa_ioc_query_intf_tx_props *tx_prop;\n\tipa_ioc_query_intf_rx_props *rx_prop;\n\n\tvirtual int handle_down_evt() = 0;\n\n\tvirtual int handle_addr_evt(ipacm_event_data_addr *data) = 0;\n\n\tIPACM_Iface(int iface_index);\n\n\tvirtual void event_callback(ipa_cm_event_id event,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvoid *data) = 0;\n\n\t/* Query ipa_interface_index by given linux interface_index */\n\tstatic int iface_ipa_index_query(int interface_index);\n\n\t/* Query ipa_interface ipv4_addr by given linux interface_index */\n\tstatic void iface_addr_query(int interface_index);\n\n\t/*Query the IPA endpoint property */\n\tint query_iface_property(void);\n\n\t/*implement IPACM strlcpy */\n\tsize_t strlcpy(char *dest, const char *src, size_t size);\n\n\t/*implement IPACM strlcat */\n\tsize_t strlcat(char *dest, const char *src, size_t n);\n\n\t/*Configure the initial filter rules */\n\tvirtual int init_fl_rule(ipa_ip_type iptype);\n\n\t/* Get interface index */\n\tvirtual int ipa_get_if_index(char * if_name, int * if_index);\n\n\tstatic IPACM_Routing m_routing;\n\tstatic IPACM_Filtering m_filtering;\n\tstatic IPACM_Header m_header;\n\n\t/* software routing enable */\n\tvirtual int handle_software_routing_enable(void);\n\n\t/* software routing disable */\n\tvirtual int handle_software_routing_disable(void);\n\n\t/* used to get filtering rule index in table */\n\tint flt_rule_count_v4;\n\n\tint flt_rule_count_v6;\n\nprivate:\n\n\tstatic const char *DEVICE_NAME;\n};\n\n#endif /* IPACM_IFACE_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_IfaceManager.h\n\n\t@brief\n\tThis file implements the IPAM iface_manager definitions\n\n\t@Author\n\tSkylar Chang\n\n*/\n#ifndef IPACM_IFACEMANAGER_H\n#define IPACM_IFACEMANAGER_H\n\n#include <stdio.h>\n#include <IPACM_CmdQueue.h>\n\n#include \"IPACM_Routing.h\"\n#include \"IPACM_Filtering.h\"\n#include \"IPACM_Listener.h\"\n#include \"IPACM_Iface.h\"\n\n#define IPA_MAX_NUM_NEIGHBOR_CLIENTS  17\n#define IPA_INSTANCE_NOT_FOUND  0\n#define IPA_INSTANCE_FOUND  1\n\n/* queue */\ntypedef struct _iface_instances\n{\n    /* Linux interface id */\n\tint ipa_if_index;\n\tIPACM_Listener *obj;\n\t_iface_instances *next;\n}  iface_instances;\n\n\nclass IPACM_IfaceManager : public IPACM_Listener\n{\n\npublic:\n\n  IPACM_IfaceManager();\n\n  void event_callback(ipa_cm_event_id event,\n                      void *data);\n\n  /* api for all iface instances to de-register instances */\n  static int deregistr(IPACM_Listener *param);\n\n\nprivate:\n\tint create_iface_instance(ipacm_ifacemgr_data *);\n\n    /* api to register instances */\n\tint registr(int ipa_if_index, IPACM_Listener *obj);\n\n\tint SearchInstance(int ipa_if_index);\n\n\tstatic iface_instances *head;\n\n};\n\n#endif /* IPACM_IFACEMANAGER_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Lan.h\n\n\t@brief\n\tThis file implements the LAN iface definitions\n\n\t@Author\n\tSkylar Chang\n\n*/\n#ifndef IPACM_LAN_H\n#define IPACM_LAN_H\n\n#include <stdio.h>\n#include <linux/msm_ipa.h>\n\n#include \"IPACM_CmdQueue.h\"\n#include \"IPACM_Iface.h\"\n#include \"IPACM_Routing.h\"\n#include \"IPACM_Filtering.h\"\n#include \"IPACM_Config.h\"\n#include \"IPACM_Conntrack_NATApp.h\"\n\n#define IPA_WAN_DEFAULT_FILTER_RULE_HANDLES  1\n#define IPA_PRIV_SUBNET_FILTER_RULE_HANDLES  3\n#define IPA_NUM_ODU_ROUTE_RULES 2\n#define MAX_WAN_UL_FILTER_RULES 20\n#define NUM_IPV6_PREFIX_FLT_RULE 1\n#define NUM_IPV6_ICMP_FLT_RULE 1\n\n/* echo ipatetherstats <ifaceIn> <ifaceOut> */\n/* <in->out_bytes> <in->out_pkts> <out->in_bytes> <out->in_pkts */\n\n#define PIPE_STATS \"%s %s %lu %lu %lu %lu\"\n#define IPA_PIPE_STATS_FILE_NAME \"/data/misc/ipa/tether_stats\"\n\n/* store each lan-iface unicast routing rule and its handler*/\nstruct ipa_lan_rt_rule\n{\n\tipa_ip_type ip;\n\tuint32_t v4_addr;\n\tuint32_t v4_addr_mask;\n\tuint32_t v6_addr[4];\n\tuint32_t rt_rule_hdl[0];\n};\n\n/* Support multiple eth client */\ntypedef struct _eth_client_rt_hdl\n{\n\tuint32_t eth_rt_rule_hdl_v4;\n\tuint32_t eth_rt_rule_hdl_v6[IPV6_NUM_ADDR];\n\tuint32_t eth_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];\n}eth_client_rt_hdl;\n\ntypedef struct _ipa_eth_client\n{\n\tuint8_t mac[IPA_MAC_ADDR_SIZE];\n\tuint32_t v4_addr;\n\tuint32_t v6_addr[IPV6_NUM_ADDR][4];\n\tuint32_t hdr_hdl_v4;\n\tuint32_t hdr_hdl_v6;\n\tbool route_rule_set_v4;\n\tint route_rule_set_v6;\n\tbool ipv4_set;\n\tint ipv6_set;\n\tbool ipv4_header_set;\n\tbool ipv6_header_set;\n\teth_client_rt_hdl eth_rt_hdl[0]; /* depends on number of tx properties */\n}ipa_eth_client;\n\nstruct lan2lan_flt_rule_hdl\n{\n\tuint32_t rule_hdl;\n\tbool valid;\n};\n\nstruct lan2lan_hdr_hdl\n{\n\tuint32_t hdr_hdl;\n\tbool valid;\n};\n\nstruct eth_bridge_client_flt_info\n{\n\tuint8_t mac[IPA_MAC_ADDR_SIZE];\n\tuint32_t flt_rule_hdl_v4;\n\tbool flt_rule_set_v4;\n\tuint32_t flt_rule_hdl_v6;\n\tbool flt_rule_set_v6;\n};\n\nstruct eth_bridge_client_rt_info\n{\n\tuint8_t mac[IPA_MAC_ADDR_SIZE];\n\tuint32_t rt_rule_hdl[0];\n};\n\nstruct hdr_proc_ctx_info\n{\n\tuint32_t proc_ctx_hdl;\n\tbool valid;\n};\n\nstruct eth_bridge_subnet_client_info\n{\n\tuint8_t mac[IPA_MAC_ADDR_SIZE];\n\tint ipa_if_num;\n};\n\n/* lan iface */\nclass IPACM_Lan : public IPACM_Iface\n{\npublic:\n\n\tIPACM_Lan(int iface_index);\n\t~IPACM_Lan();\n\n\t/* store lan's wan-up filter rule handlers */\n\tuint32_t lan_wan_fl_rule_hdl[IPA_WAN_DEFAULT_FILTER_RULE_HANDLES];\n\n\t/* store private-subnet filter rule handlers */\n\tuint32_t private_fl_rule_hdl[IPA_MAX_PRIVATE_SUBNET_ENTRIES];\n\n\t/* LAN-iface's callback function */\n\tvoid event_callback(ipa_cm_event_id event,\n\t\t\t\t\t\t\t\t\t\t\tvoid *data);\n\n\tvirtual int handle_wan_up(ipa_ip_type ip_type);\n\n\t/* configure filter rule for wan_up event*/\n\tvirtual int handle_wan_up_ex(ipacm_ext_prop* ext_prop, ipa_ip_type iptype);\n\n\t/* delete filter rule for wan_down event*/\n\tvirtual int handle_wan_down(bool is_sta_mode);\n\n\t/* delete filter rule for wan_down event*/\n\tvirtual int handle_wan_down_v6(bool is_sta_mode);\n\n\t/* configure private subnet filter rules*/\n\tvirtual int handle_private_subnet(ipa_ip_type iptype);\n\n\t/* handle new_address event*/\n\tint handle_addr_evt(ipacm_event_data_addr *data);\n\n\tint handle_addr_evt_odu_bridge(ipacm_event_data_addr* data);\n\n\tstatic bool odu_up;\n\n\t/* install UL filter rule from Q6 */\n\tvirtual int handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype);\n\n\tint add_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr, uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t* rule_hdl);\n\n\tint del_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl);\n\n\tvirtual int add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl);\n\n\tint add_lan2lan_rt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr,\n\t\t\t\t\t\t\t\tuint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t hdr_hdl, lan_to_lan_rt_rule_hdl* rule_hdl);\n\n\tint del_lan2lan_rt_rule(ipa_ip_type iptype, lan_to_lan_rt_rule_hdl);\n\n\tint del_lan2lan_hdr(ipa_ip_type iptype, uint32_t hdr_hdl);\n\n\n\n\tstatic ipa_hdr_l2_type usb_hdr_type;\n\tstatic ipa_hdr_l2_type wlan_hdr_type;\n\n\tstatic uint32_t usb_hdr_template_hdl;\n\tstatic uint32_t wlan_hdr_template_hdl;\n\n\tstatic hdr_proc_ctx_info usb_to_wlan_hdr_proc_ctx, wlan_to_usb_hdr_proc_ctx;\n\tstatic hdr_proc_ctx_info wlan_to_wlan_hdr_proc_ctx;\n\n\tstatic eth_bridge_subnet_client_info eth_bridge_wlan_client[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\n\tstatic eth_bridge_subnet_client_info eth_bridge_usb_client[IPA_LAN_TO_LAN_MAX_USB_CLIENT];\n\n\tstatic int num_wlan_client;\n\tstatic int num_usb_client;\n\nprotected:\n\n\tlan2lan_flt_rule_hdl wlan_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\n\tlan2lan_flt_rule_hdl wlan_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\n\n\teth_bridge_client_flt_info eth_bridge_wlan_client_flt_info[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\n\tint wlan_client_flt_info_count;\n\n\teth_bridge_client_rt_info* eth_bridge_usb_client_rt_info_v4;\n\teth_bridge_client_rt_info* eth_bridge_usb_client_rt_info_v6;\n\tint usb_client_rt_info_count_v4;\n\tint usb_client_rt_info_count_v6;\n\tint client_rt_info_size_v4;\n\tint client_rt_info_size_v6;\n\n\tint each_client_rt_rule_count_v4;\n\tint each_client_rt_rule_count_v6;\n\n\tvirtual int eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype);\n\n\tvirtual int eth_bridge_add_wlan_guest_ap_flt_rule(ipa_ip_type iptype);\n\n\tvirtual int eth_bridge_handle_dummy_usb_client_flt_rule(ipa_ip_type iptype);\n\n\tint eth_bridge_add_wlan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype);\n\n\tint eth_bridge_del_wlan_client_flt_rule(uint8_t* mac);\n\n\tint eth_bridge_post_lan_client_event(uint8_t* mac_addr, ipa_cm_event_id evt);\n\n\tint add_hdr_proc_ctx();\n\n\tint del_hdr_proc_ctx();\n\n\tipa_hdr_proc_type get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2);\n\n\tvirtual int eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype);\n\n\tvirtual int eth_bridge_install_cache_usb_client_flt_rule(ipa_ip_type iptype);\n\n\tint eth_bridge_add_usb_client_rt_rule(uint8_t* mac, ipa_ip_type iptype);\n\n\tint eth_bridge_del_usb_client_rt_rule(uint8_t* mac);\n\n\teth_bridge_client_rt_info* eth_bridge_get_client_rt_info_ptr(uint8_t index, ipa_ip_type iptype);\n\n\tvoid eth_bridge_add_usb_client(uint8_t* mac);\n\n\tvoid eth_bridge_del_usb_client(uint8_t* mac);\n\n\tint eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl);\n\n\n\n\tvirtual int add_dummy_lan2lan_flt_rule(ipa_ip_type iptype);\n\n\tvirtual int add_dummy_private_subnet_flt_rule(ipa_ip_type iptype);\n\n\tint handle_private_subnet_android(ipa_ip_type iptype);\n\n\tint reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl);\n\n\t/*handle lan2lan client active*/\n\tint handle_lan2lan_client_active(ipacm_event_data_all *data, ipa_cm_event_id event);\n\n\tint install_ipv6_prefix_flt_rule(uint32_t* prefix);\n\n\tint install_ipv6_icmp_flt_rule();\n\n\tvoid post_del_self_evt();\n\n\t/* handle tethering stats */\n\tint handle_tethering_stats_event(ipa_get_data_stats_resp_msg_v01 *data);\n\n\t/* handle tethering client */\n\tint handle_tethering_client(bool reset, ipacm_client_enum ipa_client);\n\n\tlan2lan_flt_rule_hdl lan2lan_flt_rule_hdl_v4[MAX_OFFLOAD_PAIR];\n\tlan2lan_flt_rule_hdl lan2lan_flt_rule_hdl_v6[MAX_OFFLOAD_PAIR];\n\n\tuint8_t num_lan2lan_flt_rule_v4;\n\tuint8_t num_lan2lan_flt_rule_v6;\n\n\tlan2lan_hdr_hdl lan2lan_hdr_hdl_v4[MAX_OFFLOAD_PAIR];\n\tlan2lan_hdr_hdl lan2lan_hdr_hdl_v6[MAX_OFFLOAD_PAIR];\n\n\t/* store ipv4 UL filter rule handlers from Q6*/\n\tuint32_t wan_ul_fl_rule_hdl_v4[MAX_WAN_UL_FILTER_RULES];\n\n\t/* store ipv6 UL filter rule handlers from Q6*/\n\tuint32_t wan_ul_fl_rule_hdl_v6[MAX_WAN_UL_FILTER_RULES];\n\n\tvirtual void install_tcp_ctl_flt_rule(ipa_ip_type iptype);\n\n\tuint32_t tcp_ctl_flt_rule_hdl_v4[NUM_TCP_CTL_FLT_RULE];\n\tuint32_t tcp_ctl_flt_rule_hdl_v6[NUM_TCP_CTL_FLT_RULE];\n\n\tuint32_t ipv6_prefix_flt_rule_hdl[NUM_IPV6_PREFIX_FLT_RULE];\n\tuint32_t ipv6_icmp_flt_rule_hdl[NUM_IPV6_ICMP_FLT_RULE];\n\n\tint num_wan_ul_fl_rule_v4;\n\tint num_wan_ul_fl_rule_v6;\n\n\tbool is_active;\n\tbool modem_ul_v4_set;\n\tbool modem_ul_v6_set;\n\n\tuint32_t if_ipv4_subnet;\n\nprivate:\n\n\t/* dynamically allocate lan iface's unicast routing rule structure */\n\n\tbool is_mode_switch; /* indicate mode switch, need post internal up event */\n\n\tint eth_client_len;\n\n\tipa_eth_client *eth_client;\n\n\tint header_name_count;\n\n\tint num_eth_client;\n\n\tNatApp *Nat_App;\n\n    int ipv6_set;\n\n\tuint32_t ODU_hdr_hdl_v4, ODU_hdr_hdl_v6;\n\n\tuint32_t *odu_route_rule_v4_hdl;\n\n\tuint32_t *odu_route_rule_v6_hdl;\n\n\tbool ipv4_header_set;\n\n\tbool ipv6_header_set;\n\n\tinline ipa_eth_client* get_client_memptr(ipa_eth_client *param, int cnt)\n\t{\n\t    char *ret = ((char *)param) + (eth_client_len * cnt);\n\t\treturn (ipa_eth_client *)ret;\n\t}\n\n\tinline int get_eth_client_index(uint8_t *mac_addr)\n\t{\n\t\tint cnt;\n\t\tint num_eth_client_tmp = num_eth_client;\n\n\t\tIPACMDBG_H(\"Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\t\tfor(cnt = 0; cnt < num_eth_client_tmp; cnt++)\n\t\t{\n\t\t\tIPACMDBG_H(\"stored MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t get_client_memptr(eth_client, cnt)->mac[0],\n\t\t\t\t\t\t\t get_client_memptr(eth_client, cnt)->mac[1],\n\t\t\t\t\t\t\t get_client_memptr(eth_client, cnt)->mac[2],\n\t\t\t\t\t\t\t get_client_memptr(eth_client, cnt)->mac[3],\n\t\t\t\t\t\t\t get_client_memptr(eth_client, cnt)->mac[4],\n\t\t\t\t\t\t\t get_client_memptr(eth_client, cnt)->mac[5]);\n\n\t\t\tif(memcmp(get_client_memptr(eth_client, cnt)->mac,\n\t\t\t\t\t\t\t\tmac_addr,\n\t\t\t\t\t\t\t\tsizeof(get_client_memptr(eth_client, cnt)->mac)) == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Matched client index: %d\\n\", cnt);\n\t\t\t\treturn cnt;\n\t\t\t}\n\t\t}\n\n\t\treturn IPACM_INVALID_INDEX;\n\t}\n\n\tinline int delete_eth_rtrules(int clt_indx, ipa_ip_type iptype)\n\t{\n\t\tuint32_t tx_index;\n\t\tuint32_t rt_hdl;\n\t\tint num_v6;\n\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t    for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t    {\n\t\t        if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(eth_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Delete client index %d ipv4 RT-rules for tx:%d\\n\",clt_indx,tx_index);\n\t\t\t\t\trt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v4;\n\n\t\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t    } /* end of for loop */\n\n\t\t     /* clean the ipv4 RT rules for eth-client:clt_indx */\n\t\t     if(get_client_memptr(eth_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */\n\t\t     {\n\t\t\t\tget_client_memptr(eth_client, clt_indx)->route_rule_set_v4 = false;\n\t\t     }\n\t\t}\n\n\t\tif(iptype == IPA_IP_v6)\n\t\t{\n\t\t\tfor(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t\t{\n\t\t\t\tif((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */\n\t\t\t\t{\n\t\t\t\t\tfor(num_v6 =0;num_v6 < get_client_memptr(eth_client, clt_indx)->route_rule_set_v6;num_v6++)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Delete client index %d ipv6 RT-rules for %d-st ipv6 for tx:%d\\n\", clt_indx,num_v6,tx_index);\n\t\t\t\t\t\trt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6[num_v6];\n\t\t\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\trt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6_wan[num_v6];\n\t\t\t\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n                    }\n\t\t    } /* end of for loop */\n\n\t\t    /* clean the ipv6 RT rules for eth-client:clt_indx */\n\t\t    if(get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */\n\t\t    {\n\t\t        get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 = 0;\n            }\n\t\t}\n\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\t/* handle eth client initial, construct full headers (tx property) */\n\tint handle_eth_hdr_init(uint8_t *mac_addr);\n\n\t/* handle eth client ip-address */\n\tint handle_eth_client_ipaddr(ipacm_event_data_all *data);\n\n\t/* handle eth client routing rule*/\n\tint handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);\n\n\t/*handle eth client del mode*/\n\tint handle_eth_client_down_evt(uint8_t *mac_addr);\n\n\t/* handle odu client initial, construct full headers (tx property) */\n\tint handle_odu_hdr_init(uint8_t *mac_addr);\n\n\t/* handle odu default route rule configuration */\n\tint handle_odu_route_add();\n\n\t/* handle odu default route rule deletion */\n\tint handle_odu_route_del();\n\n\t/*handle lan iface down event*/\n\tint handle_down_evt();\n\n\t/*handle lan2lan internal mesg posting*/\n\tint post_lan2lan_client_disconnect_msg(ipa_ip_type iptype);\n\n\t/*handle reset usb-client rt-rules */\n\tint handle_lan_client_reset_rt(ipa_ip_type iptype);\n};\n\n#endif /* IPACM_LAN_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h",
    "content": "/*\nCopyright (c) 2014, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * IPACM_LanToLan.h\n *\n *  Created on: Mar 4th, 2014\n *      Author: Shihuan Liu\n */\n\n#ifndef IPACM_LANTOLAN_H\n#define IPACM_LANTOLAN_H\n\n#include <stdint.h>\n#include \"linux/msm_ipa.h\"\n#include \"IPACM_Iface.h\"\n#include \"IPACM_Defs.h\"\n#include \"IPACM_Lan.h\"\n#include <unordered_map>\n\n#ifdef FEATURE_IPA_ANDROID\n#include <libxml/list.h>\n#else/* defined(FEATURE_IPA_ANDROID) */\n#include <list>\n#endif /* ndefined(FEATURE_IPA_ANDROID)*/\n\nstruct client_info;\n\nstruct peer_info\n{\n\tstruct client_info* peer_pointer;\n\tint num_connection;\n};\n\n//used to store rule handles for offload link (one direction)\nstruct offload_link_info\n{\n\tstruct client_info* peer_pointer;\n\tuint32_t flt_rule_hdl;\n\tlan_to_lan_rt_rule_hdl rt_rule_hdl;\n\tuint32_t hdr_hdl;\n};\n\ntypedef list<peer_info> peer_info_list;\ntypedef list<offload_link_info> offload_link_info_list;\ntypedef list<ipacm_event_connection> connection_list;\n\nstruct client_info\n{\n\tunion\n\t{\n\t\tuint32_t ipv4_addr;\n\t\tuint32_t ipv6_addr[4];\n\t} ip;\n\tuint8_t mac_addr[6];\n\tbool is_active;\n\tbool is_powersave;\n\tIPACM_Lan* p_iface;\n\tpeer_info_list peer;\n\toffload_link_info_list link;\n};\n\nstruct v6_addr\n{\n\tuint32_t ipv6_addr[4];\n};\n\ntypedef unordered_map<uint32_t, client_info> client_table_v4;\ntypedef unordered_map<uint64_t, client_info> client_table_v6;\n\n\nclass IPACM_LanToLan : public IPACM_Listener\n{\n\npublic:\n\n\t\tIPACM_LanToLan();\n\t\t~IPACM_LanToLan();\n\n\t\tvoid handle_new_connection(ipacm_event_connection* new_conn);\n\t\tvoid handle_del_connection(ipacm_event_connection* del_conn);\n\n\t\tstatic IPACM_LanToLan* getLan2LanInstance();\n\nprivate:\n\n\t\tuint8_t num_offload_pair_v4_;\n\t\tuint8_t num_offload_pair_v6_;\n\t\tclient_table_v4 client_info_v4_;\n\t\tclient_table_v6 client_info_v6_;\n\n\t\tconnection_list connection_v4_;\n\t\tconnection_list connection_v6_;\n\n\t\tstatic IPACM_LanToLan* p_instance;\n\n\t\tvoid event_callback(ipa_cm_event_id event, void* param);\n\n\t\tvoid handle_client_active(ipacm_event_lan_client* data);\n\n\t\tvoid check_potential_link(ipa_ip_type iptype, client_info* client);\n\n\t\tint add_offload_link(ipa_ip_type iptype, client_info* client, client_info* peer);\n\n\t\tvoid handle_client_inactive(ipacm_event_lan_client* data);\n\n\t\tint turnoff_offload_links(ipa_ip_type iptype, client_info* client);\n\n\t\tint del_offload_link(ipa_ip_type iptype, IPACM_Lan* client, IPACM_Lan* peer, offload_link_info* link);\n\n\t\tvoid handle_client_disconnect(ipacm_event_lan_client* data);\n\n\t\tint clear_peer_list(client_info* client);\n\n\t\tvoid handle_client_power_save(ipacm_event_lan_client* data);\n\n\t\tvoid handle_client_power_recover(ipacm_event_lan_client* data);\n\n\t\tint remove_flt_rules(ipa_ip_type iptype, client_info* client);\n\n\t\tint add_flt_rules(ipa_ip_type iptype, client_info* client);\n\n//the following are for connections\n\n\t\tvoid handle_new_lan2lan_connection(ipacm_event_connection* data);\n\n\t\tbool add_connection(client_info* src_client, client_info* dst_client);\n\n\t\tvoid handle_del_lan2lan_connection(ipacm_event_connection* data);\n\n\t\tbool remove_connection(client_info* src_client, client_info* dst_client);\n\n\t\tvoid erase_offload_link(ipa_ip_type iptype, client_info* src_client, client_info* dst_client);\n\n\t\tvoid generate_new_connection(ipa_ip_type iptype, client_info* client);\n\n\t\tbool is_lan2lan_connection(ipacm_event_connection* data);\n\n\t\tbool is_potential_lan2lan_connection(ipacm_event_connection* new_conn);\n\n\t\tvoid cache_new_connection(ipacm_event_connection* new_conn);\n\n\t\tvoid remove_cache_connection(ipacm_event_connection* del_conn);\n\n\t\tvoid check_cache_connection(ipa_ip_type iptype, client_info* client);\n\n};\n\n#endif\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Listener.h\n\n\t@brief\n\tThis file implements the abstract class notifier.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#ifndef IPACM_LISTENER_H\n#define IPACM_LISTENER_H\n\n#include \"IPACM_Defs.h\"\n#include \"IPACM_CmdQueue.h\"\n\n/* abstract class notifier */\nclass IPACM_Listener\n{\npublic:\n\tvirtual void event_callback(ipa_cm_event_id event,\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvoid *data) = 0;\n\tvirtual ~IPACM_Listener(void) {};\n};\n\n#endif /* IPACM_LISTENER_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_log.h\n\n\t@brief\n\tThis file implements the IPAM log functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n\n#ifndef IPACM_LOG_H\n#define IPACM_LOG_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#include <stdio.h>\n#include <string.h>\n#include <syslog.h>\n\n#define MAX_BUF_LEN 256\n\n#ifdef FEATURE_IPA_ANDROID\n#define IPACMLOG_FILE \"/dev/socket/ipacm_log_file\"\n#else/* defined(FEATURE_IPA_ANDROID) */\n#define IPACMLOG_FILE \"/etc/ipacm_log_file\"\n#endif /* defined(NOT FEATURE_IPA_ANDROID)*/\n\ntypedef struct ipacm_log_buffer_s {\n\tchar\tuser_data[MAX_BUF_LEN];\n} ipacm_log_buffer_t;\n\nvoid ipacm_log_send( void * user_data);\n\nstatic char buffer_send[MAX_BUF_LEN];\n\n#define PERROR(fmt)   memset(buffer_send, 0, MAX_BUF_LEN);\\\n\t\t\t\t\t  snprintf(buffer_send,MAX_BUF_LEN,\"%s:%d %s()\", __FILE__, __LINE__, __FUNCTION__);\\\n\t\t\t\t\t  ipacm_log_send (buffer_send); \\\n                      perror(fmt);\n\n#define IPACMERR(fmt, ...)\tmemset(buffer_send, 0, MAX_BUF_LEN);\\\n\t\t\t\t\t\t\tsnprintf(buffer_send,MAX_BUF_LEN,\"ERR: %s:%d %s() \" fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\\\n\t\t\t\t\t\t\tipacm_log_send (buffer_send);\\\n\t\t\t\t\t\t\tprintf(\"ERR: %s:%d %s() \" fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\n#define IPACMDBG_H(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\\\n\t\t\t\t\t\t\t snprintf(buffer_send,MAX_BUF_LEN,\"%s:%d %s() \" fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\\\n\t\t\t\t\t\t\t ipacm_log_send (buffer_send);\\\n\t\t\t\t\t\t\t printf(\"%s:%d %s() \" fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\n#define IPACMDBG(fmt, ...)\tprintf(\"%s:%d %s() \" fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\n#define IPACMLOG(fmt, ...)  printf(fmt, ##__VA_ARGS__);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* IPACM_LOG_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Neighbor.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Neighbor.h\n\n\t@brief\n\tThis file implements the functionality of handling IPACM Neighbor events.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#ifndef IPACM_NEIGHBOR_H\n#define IPACM_NEIGHBOR_H\n\n#include <stdio.h>\n#include <IPACM_CmdQueue.h>\n#include <linux/msm_ipa.h>\n#include \"IPACM_Routing.h\"\n#include \"IPACM_Filtering.h\"\n#include \"IPACM_Listener.h\"\n#include \"IPACM_Iface.h\"\n\n#define IPA_MAX_NUM_NEIGHBOR_CLIENTS  17\n\nstruct ipa_neighbor_client\n{\n\tuint8_t mac_addr[6];\n\tint iface_index;\n\tuint32_t v4_addr;\n\tint ipa_if_num;\n};\n\nclass IPACM_Neighbor : public IPACM_Listener\n{\n\npublic:\n\n\tIPACM_Neighbor();\n\n\tvoid event_callback(ipa_cm_event_id event,\n\t\t\t\t\t\t\t\t\t\t\tvoid *data);\n\nprivate:\n\n\tint num_neighbor_client;\n\n\tipa_neighbor_client neighbor_client[IPA_MAX_NUM_NEIGHBOR_CLIENTS];\n\n\n};\n\n#endif /* IPACM_NEIGHBOR_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Netlink.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPA_Netlink.h\n\n\t@brief\n\tIPACM Netlink Messaging Implementation File\n\n\t@Author\n\tSkylar Chang\n\n*/\n#ifndef IPACM_NETLINK_H\n#define IPACM_NETLINK_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <pthread.h>\n#include <sys/select.h>\n#include <sys/socket.h>\n#include <linux/if.h>\n#include <linux/if_addr.h>\n#include <linux/rtnetlink.h>\n#include <linux/netlink.h>\n#include <netinet/in.h>\n#include \"IPACM_Defs.h\"\n\n#define MAX_NUM_OF_FD 10\n#define IPA_NL_MSG_MAX_LEN (2048)\n\n/*--------------------------------------------------------------------------- \n\t Type representing enumeration of NetLink event indication messages\n---------------------------------------------------------------------------*/\n\n/*--------------------------------------------------------------------------- \n\t Types representing parsed NetLink message\n---------------------------------------------------------------------------*/\n#define IPA_NLA_PARAM_NONE        (0x0000)\n#define IPA_NLA_PARAM_PREFIXADDR  (0x0001)\n#define IPA_NLA_PARAM_LOCALADDR   (0x0002)\n#define IPA_NLA_PARAM_LABELNAME   (0x0004)\n#define IPA_NLA_PARAM_BCASTADDR   (0x0008)\n#define IPA_NLA_PARAM_ACASTADDR   (0x0010)\n#define IPA_NLA_PARAM_MCASTADDR   (0x0020)\n#define IPA_NLA_PARAM_CACHEINFO   (0x0080)\n#define IPA_NLA_PARAM_PROTOINFO   (0x0100)\n#define IPA_NLA_PARAM_FLAGS       (0x0200)\n\n#define IPA_RTA_PARAM_NONE        (0x0000)\n#define IPA_RTA_PARAM_DST         (0x0001)\n#define IPA_RTA_PARAM_SRC         (0x0002)\n#define IPA_RTA_PARAM_GATEWAY     (0x0004)\n#define IPA_RTA_PARAM_IIF         (0x0008)\n#define IPA_RTA_PARAM_OIF         (0x0010)\n#define IPA_RTA_PARAM_CACHEINFO   (0x0020)\n#define IPA_RTA_PARAM_PRIORITY    (0x0080)\n#define IPA_RTA_PARAM_METRICS     (0x0100)\n\n\n/*--------------------------------------------------------------------------- \n\t Type representing function callback registered with a socket listener \n\t thread for reading from a socket on receipt of an incoming message\n---------------------------------------------------------------------------*/\ntypedef int (*ipa_sock_thrd_fd_read_f)(int fd);\n\ntypedef enum\n{\n\tIPA_INIT = 0,\n\tIPA_LINK_UP_WAIT,\n\tIPA_LINK_UP,\n\tIPA_LINK_DOWN_WAIT,\n\tIPA_LINK_DOWN\n} ipa_nl_state_e;\n\ntypedef struct\n{\n\tint sk_fd;\n\tipa_sock_thrd_fd_read_f read_func;\n} ipa_nl_sk_fd_map_info_t;\n\ntypedef struct\n{\n\tipa_nl_sk_fd_map_info_t sk_fds[MAX_NUM_OF_FD];\n\tfd_set fdset;\n\tint num_fd;\n\tint max_fd;\n} ipa_nl_sk_fd_set_info_t;\n\ntypedef struct\n{\n\tint                 sk_fd;       /* socket descriptor */\n\tstruct sockaddr_nl  sk_addr_loc; /* local address of socket */\n} ipa_nl_sk_info_t;\n\ntypedef struct ipa_nl_addr_s {\n\tstruct sockaddr_storage        ip_addr;\n\tunsigned int                   mask;\n} ipa_nl_addr_t;\n\ntypedef struct ipa_nl_proto_info_s {\n\tunsigned int                    param_mask;\n\tunsigned int                    flags;\n\tstruct ifla_cacheinfo           cache_info;\n} ipa_nl_proto_info_t;\n\ntypedef struct\n{\n\tstruct ifinfomsg  metainfo;                   /* from header */\n} ipa_nl_link_info_t;\n\n\n\ntypedef struct ipa_nl_addr_info_s {\n\tstruct ifaddrmsg                metainfo;     /* from header */\n\tstruct                                      /* attributes  */\n\t{\n\t\tunsigned int                  param_mask;\n\t\tunsigned char                 label_name[IF_NAME_LEN];\n\t\tstruct sockaddr_storage       prefix_addr;\n\t\tstruct sockaddr_storage       local_addr;\n\t\tstruct sockaddr_storage       bcast_addr;\n\t\tstruct sockaddr_storage       acast_addr;\n\t\tstruct sockaddr_storage       mcast_addr;\n\t} attr_info;\n} ipa_nl_addr_info_t;\n\n\ntypedef struct ipa_nl_neigh_info_s {\n\tstruct ndmsg                metainfo;     /* from header */\n\tstruct                                  /* attributes  */\n\t{\n\t\tunsigned int                param_mask;\n\t\tstruct sockaddr_storage     local_addr;\n\t\tstruct  sockaddr            lladdr_hwaddr;\n\t} attr_info;\n} ipa_nl_neigh_info_t;\n\n\n\ntypedef struct ipa_nl_route_info_s {\n\tstruct rtmsg                    metainfo;     /* from header */\n\tstruct                                      /* attributes  */\n\t{\n\t\tunsigned int                  param_mask;\n\t\tstruct sockaddr_storage       dst_addr;\n\t\tstruct sockaddr_storage       src_addr;\n\t\tstruct sockaddr_storage       gateway_addr;\n\t\tstruct sockaddr_storage       mark_addr;\n\t\tstruct rta_cacheinfo          cache_info;\n\t\t__u32\t\tiif_index;                      /* Link index  */\n\t\t__u32\t\toif_index;                      /* Link index  */\n\t\t__u32       priority;\n\t\t__u32       metrics;\n\t\tipa_nl_proto_info_t        proto_info;\n\t} attr_info;\n} ipa_nl_route_info_t;\n\n#define IPA_FLOW_TYPE_INVALID      (-1)\n\ntypedef struct\n{\n\tunsigned int type;\n\tbool link_event;\n\t/* Optional parameters */\n\tipa_nl_link_info_t      nl_link_info;\n\tipa_nl_addr_info_t      nl_addr_info;\n\tipa_nl_neigh_info_t      nl_neigh_info;\n\tipa_nl_route_info_t      nl_route_info;\n} ipa_nl_msg_t;\n\n/* Initialization routine for listener on NetLink sockets interface */\nint ipa_nl_listener_init\n(\n\t unsigned int nl_type,\n\t unsigned int nl_groups,\n\t ipa_nl_sk_fd_set_info_t *sk_fdset,\n\t ipa_sock_thrd_fd_read_f read_f\n\t );\n\n/*  Virtual function registered to receive incoming messages over the NETLINK routing socket*/\nint ipa_nl_recv_msg(int fd);\n\n/* map mask value for ipv6 */\nint mask_v6(int index, uint32_t *mask);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* IPACM_NETLINK_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Routing.cpp\n\n\t@brief\n\tThis file implements the IPACM routing functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n\n\n#ifndef IPACM_ROUTING_H\n#define IPACM_ROUTING_H\n\n#include <stdint.h>\n#include <linux/msm_ipa.h>\n#include <IPACM_Defs.h>\n\nusing namespace std;\n\nclass IPACM_Routing\n{\npublic:\n\tIPACM_Routing();\n\t~IPACM_Routing();\n\n\tbool AddRoutingRule(struct ipa_ioc_add_rt_rule *ruleTable);\n\tbool DeleteRoutingRule(struct ipa_ioc_del_rt_rule *ruleTable);\n\n\tbool Commit(enum ipa_ip_type ip);\n\tbool Reset(enum ipa_ip_type ip);\n\n\tbool GetRoutingTable(struct ipa_ioc_get_rt_tbl *routingTable);\n\tbool PutRoutingTable(uint32_t routingTableHandle);\n\n\tbool DeviceNodeIsOpened();\n\tbool DeleteRoutingHdl(uint32_t rt_rule_hdl, ipa_ip_type ip);\n\nprivate:\n\tstatic const char *DEVICE_NAME;\n\tint m_fd; /* File descriptor of the IPA device node /dev/ipa */\n};\n\n#endif //IPACM_ROUTING_H\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Wan.cpp\n\n\t@brief\n\tThis file implements the WAN iface functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#ifndef IPACM_WAN_H\n#define IPACM_WAN_H\n\n#include <stdio.h>\n#include <IPACM_CmdQueue.h>\n#include <linux/msm_ipa.h>\n#include \"IPACM_Routing.h\"\n#include \"IPACM_Filtering.h\"\n#include <IPACM_Iface.h>\n#include <IPACM_Defs.h>\n#include <IPACM_Xml.h>\n\n#define IPA_NUM_DEFAULT_WAN_FILTER_RULES 3 /*1 for v4, 2 for v6*/\n#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4 2\n\n#ifdef FEATURE_IPA_ANDROID\n#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6 6\n#else\n#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6 3\n#endif\n\n#define NETWORK_STATS \"%s %lu %lu %lu %lu\"\n#define IPA_NETWORK_STATS_FILE_NAME \"/data/misc/ipa/network_stats\"\n\ntypedef struct _wan_client_rt_hdl\n{\n\tuint32_t wan_rt_rule_hdl_v4;\n\tuint32_t wan_rt_rule_hdl_v6[IPV6_NUM_ADDR];\n\tuint32_t wan_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];\n}wan_client_rt_hdl;\n\ntypedef struct _ipa_wan_client\n{\n\tipacm_event_data_wlan_ex* p_hdr_info;\n\tuint8_t mac[IPA_MAC_ADDR_SIZE];\n\tuint32_t v4_addr;\n\tuint32_t v6_addr[IPV6_NUM_ADDR][4];\n\tuint32_t hdr_hdl_v4;\n\tuint32_t hdr_hdl_v6;\n\tbool route_rule_set_v4;\n\tint route_rule_set_v6;\n\tbool ipv4_set;\n\tint ipv6_set;\n\tbool ipv4_header_set;\n\tbool ipv6_header_set;\n\tbool power_save_set;\n\twan_client_rt_hdl wan_rt_hdl[0]; /* depends on number of tx properties */\n}ipa_wan_client;\n\n/* wan iface */\nclass IPACM_Wan : public IPACM_Iface\n{\n\npublic:\n\n\tstatic bool wan_up;\n\tstatic bool wan_up_v6;\n\t/* IPACM interface name */\n\tstatic char wan_up_dev_name[IF_NAME_LEN];\n\tIPACM_Wan(int, ipacm_wan_iface_type, uint8_t *);\n\tvirtual ~IPACM_Wan();\n\n\tstatic bool isWanUP(int ipa_if_num_tether)\n\t{\n#ifdef FEATURE_IPA_ANDROID\n\t\tint i;\n\t\tfor (i=0; i < ipa_if_num_tether_v4_total;i++)\n\t\t{\n\t\t\tif (ipa_if_num_tether_v4[i] == ipa_if_num_tether)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"support ipv4 tether_iface(%s)\\n\",\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);\n\t\t\t\treturn wan_up;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn false;\n#else\n\t\treturn wan_up;\n#endif\n\t}\n\n\tstatic bool isWanUP_V6(int ipa_if_num_tether)\n\t{\n#ifdef FEATURE_IPA_ANDROID\n\t\tint i;\n\t\tfor (i=0; i < ipa_if_num_tether_v6_total;i++)\n\t\t{\n\t\t\tif (ipa_if_num_tether_v6[i] == ipa_if_num_tether)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"support ipv6 tether_iface(%s)\\n\",\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);\n\t\t\t\treturn wan_up_v6;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn false;\n#else\n\t\treturn wan_up_v6;\n#endif\n\t}\n\n\n\tvoid event_callback(ipa_cm_event_id event,\n\t\t\t\t\t\t\t\t\t\t\tvoid *data);\n\n\tstatic struct ipa_flt_rule_add flt_rule_v4[IPA_MAX_FLT_RULE];\n\tstatic struct ipa_flt_rule_add flt_rule_v6[IPA_MAX_FLT_RULE];\n\n\tstatic int num_v4_flt_rule;\n\tstatic int num_v6_flt_rule;\n\n\tipacm_wan_iface_type m_is_sta_mode;\n\tstatic bool backhaul_is_sta_mode;\n\tstatic bool is_ext_prop_set;\n\tstatic uint32_t backhaul_ipv6_prefix[2];\n\n\tstatic bool embms_is_on;\n#ifdef FEATURE_IPA_ANDROID\n\t/* IPACM interface id */\n\tstatic int ipa_if_num_tether_v4_total;\n\tstatic int ipa_if_num_tether_v4[IPA_MAX_IFACE_ENTRIES];\n\tstatic int ipa_if_num_tether_v6_total;\n\tstatic int ipa_if_num_tether_v6[IPA_MAX_IFACE_ENTRIES];\n#endif\n\nprivate:\n\n\tuint32_t ipv6_frag_firewall_flt_rule_hdl;\n\tuint32_t *wan_route_rule_v4_hdl;\n\tuint32_t *wan_route_rule_v6_hdl;\n\tuint32_t *wan_route_rule_v6_hdl_a5;\n\tuint32_t hdr_hdl_sta_v4;\n\tuint32_t hdr_hdl_sta_v6;\n\tuint32_t firewall_hdl_v4[IPACM_MAX_FIREWALL_ENTRIES];\n\tuint32_t firewall_hdl_v6[IPACM_MAX_FIREWALL_ENTRIES];\n\tuint32_t dft_wan_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];\n\tuint32_t ipv6_dest_flt_rule_hdl[MAX_DEFAULT_v6_ROUTE_RULES];\n\tint num_ipv6_dest_flt_rule;\n\tuint32_t ODU_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];\n\tint num_firewall_v4,num_firewall_v6;\n\tuint32_t wan_v4_addr;\n\tbool active_v4;\n\tbool active_v6;\n\tbool header_set_v4;\n\tbool header_set_v6;\n\tbool header_partial_default_wan_v4;\n\tbool header_partial_default_wan_v6;\n\tuint8_t ext_router_mac_addr[IPA_MAC_ADDR_SIZE];\n\tuint16_t eth2_ofst_v4;\n\tuint16_t eth2_ofst_v6;\n\n\tstatic int num_ipv4_modem_pdn;\n\n\tstatic int num_ipv6_modem_pdn;\n\n\tint modem_ipv4_pdn_index;\n\n\tint modem_ipv6_pdn_index;\n\n\tbool is_default_gateway;\n\n\tuint32_t ipv6_prefix[2];\n\n\t/* IPACM firewall Configuration file*/\n\tIPACM_firewall_conf_t firewall_config;\n\n\t/* STA mode wan-client*/\n\tint wan_client_len;\n\tipa_wan_client *wan_client;\n\tint header_name_count;\n\tint num_wan_client;\n\tuint8_t invalid_mac[IPA_MAC_ADDR_SIZE];\n\t/* update network stats for CNE */\n\tint ipa_network_stats_fd;\n\n\tinline ipa_wan_client* get_client_memptr(ipa_wan_client *param, int cnt)\n\t{\n\t    char *ret = ((char *)param) + (wan_client_len * cnt);\n\t\treturn (ipa_wan_client *)ret;\n\t}\n\n\tinline int get_wan_client_index(uint8_t *mac_addr)\n\t{\n\t\tint cnt;\n\t\tint num_wan_client_tmp = num_wan_client;\n\n\t\tIPACMDBG_H(\"Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\t\tfor(cnt = 0; cnt < num_wan_client_tmp; cnt++)\n\t\t{\n\t\t\tIPACMDBG_H(\"stored MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t get_client_memptr(wan_client, cnt)->mac[0],\n\t\t\t\t\t\t\t get_client_memptr(wan_client, cnt)->mac[1],\n\t\t\t\t\t\t\t get_client_memptr(wan_client, cnt)->mac[2],\n\t\t\t\t\t\t\t get_client_memptr(wan_client, cnt)->mac[3],\n\t\t\t\t\t\t\t get_client_memptr(wan_client, cnt)->mac[4],\n\t\t\t\t\t\t\t get_client_memptr(wan_client, cnt)->mac[5]);\n\n\t\t\tif(memcmp(get_client_memptr(wan_client, cnt)->mac,\n\t\t\t\t\t\t\t\tmac_addr,\n\t\t\t\t\t\t\t\tsizeof(get_client_memptr(wan_client, cnt)->mac)) == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Matched client index: %d\\n\", cnt);\n\t\t\t\treturn cnt;\n\t\t\t}\n\t\t}\n\n\t\treturn IPACM_INVALID_INDEX;\n\t}\n\n\tinline int delete_wan_rtrules(int clt_indx, ipa_ip_type iptype)\n\t{\n\t\tuint32_t tx_index;\n\t\tuint32_t rt_hdl;\n\t\tint num_v6;\n\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t     for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t     {\n\t\t        if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Delete client index %d ipv4 Qos rules for tx:%d \\n\",clt_indx,tx_index);\n\t\t\t\trt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v4;\n\n\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)\n\t\t\t\t{\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t}\n\t\t     } /* end of for loop */\n\n\t\t     /* clean the 4 Qos ipv4 RT rules for client:clt_indx */\n\t\t     if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */\n\t\t     {\n\t\t\t\tget_client_memptr(wan_client, clt_indx)->route_rule_set_v4 = false;\n\t\t     }\n\t\t}\n\n\t\tif(iptype == IPA_IP_v6)\n\t\t{\n\t\t    for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t    {\n\n\t\t\t\tif((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */\n\t\t\t\t{\n\t\t\t\t\tfor(num_v6 =0;num_v6 < get_client_memptr(wan_client, clt_indx)->route_rule_set_v6;num_v6++)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Delete client index %d ipv6 Qos rules for %d-st ipv6 for tx:%d\\n\", clt_indx,num_v6,tx_index);\n\t\t\t\t\t\trt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6[num_v6];\n\t\t\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6_wan[num_v6];\n\t\t\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t} /* end of for loop */\n\n\t\t    /* clean the 4 Qos ipv6 RT rules for client:clt_indx */\n\t\t    if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */\n\t\t    {\n\t\t                 get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 = 0;\n                    }\n\t\t}\n\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tint handle_wan_hdr_init(uint8_t *mac_addr);\n\tint handle_wan_client_ipaddr(ipacm_event_data_all *data);\n\tint handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);\n\n\t/* handle new_address event */\n\tint handle_addr_evt(ipacm_event_data_addr *data);\n\n\t/* wan default route/filter rule configuration */\n\tint handle_route_add_evt(ipa_ip_type iptype);\n\n\t/* construct complete ethernet header */\n\tint handle_header_add_evt(uint8_t *mac_addr);\n\t/* wan posting supported tether_iface */\n\tint post_wan_up_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);\n\n\tint config_dft_firewall_rules(ipa_ip_type iptype);\n\n\t/* configure the initial firewall filter rules */\n\tint config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, ipa_ioc_add_flt_rule *pFilteringTable_v6);\n\n\tint handle_route_del_evt(ipa_ip_type iptype);\n\n\tint post_wan_down_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);\n\n\tint del_dft_firewall_rules(ipa_ip_type iptype);\n\n\tint handle_down_evt();\n\n\t/*handle wan-iface down event */\n\tint handle_down_evt_ex();\n\n\t/* wan default route/filter rule delete */\n\tint handle_route_del_evt_ex(ipa_ip_type iptype);\n\n\t/* configure the initial firewall filter rules */\n\tint config_dft_firewall_rules_ex(struct ipa_flt_rule_add* rules, int rule_offset,\n\t\tipa_ip_type iptype);\n\n\t/* init filtering rule in wan dl filtering table */\n\tint init_fl_rule_ex(ipa_ip_type iptype);\n\n\t/* add ICMP and ALG rules in wan dl filtering table */\n\tint add_icmp_alg_rules(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);\n\n\t/* query extended property */\n\tint query_ext_prop();\n\n\tipa_ioc_query_intf_ext_props *ext_prop;\n\n\tint config_wan_firewall_rule(ipa_ip_type iptype);\n\n\tint del_wan_firewall_rule(ipa_ip_type iptype);\n\n\tint add_dft_filtering_rule(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);\n\n\tint install_wan_filtering_rule(bool is_sw_routing);\n\n\tvoid change_to_network_order(ipa_ip_type iptype, ipa_rule_attrib* attrib);\n\n\tbool is_global_ipv6_addr(uint32_t* ipv6_addr);\n\n\tint handle_network_stats_evt();\n\n\tint m_fd_ipa;\n\n\tint handle_network_stats_update(ipa_get_apn_data_stats_resp_msg_v01 *data);\n};\n\n#endif /* IPACM_WAN_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t\t@file\n\t\tIPACM_Wlan.h\n\n\t\t@brief\n\t\tThis file implements the WLAN iface functionality.\n\n\t\t@Author\n\t\tSkylar Chang\n\n*/\n#ifndef IPACM_WLAN_H\n#define IPACM_WLAN_H\n\n#include <stdio.h>\n#include <IPACM_CmdQueue.h>\n#include <linux/msm_ipa.h>\n#include \"IPACM_Routing.h\"\n#include \"IPACM_Filtering.h\"\n#include \"IPACM_Lan.h\"\n#include \"IPACM_Iface.h\"\n#include \"IPACM_Conntrack_NATApp.h\"\n\ntypedef struct _wlan_client_rt_hdl\n{\n\tuint32_t wifi_rt_rule_hdl_v4;\n\tuint32_t wifi_rt_rule_hdl_v6[IPV6_NUM_ADDR];\n\tuint32_t wifi_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];\n}wlan_client_rt_hdl;\n\ntypedef struct _ipa_wlan_client\n{\n\tipacm_event_data_wlan_ex* p_hdr_info;\n\tuint8_t mac[IPA_MAC_ADDR_SIZE];\n\tuint32_t v4_addr;\n\tuint32_t v6_addr[IPV6_NUM_ADDR][4];\n\tuint32_t hdr_hdl_v4;\n\tuint32_t hdr_hdl_v6;\n\tbool route_rule_set_v4;\n\tint route_rule_set_v6;\n\tbool ipv4_set;\n\tint ipv6_set;\n\tbool ipv4_header_set;\n\tbool ipv6_header_set;\n\tbool power_save_set;\n\twlan_client_rt_hdl wifi_rt_hdl[0]; /* depends on number of tx properties */\n}ipa_wlan_client;\n\ntypedef enum\n{\n\tSRC_WLAN,\n\tSRC_USB\n} eth_bridge_src_iface;\n\n\n/* wlan iface */\nclass IPACM_Wlan : public IPACM_Lan\n{\n\npublic:\n\n\tIPACM_Wlan(int iface_index);\n\tvirtual ~IPACM_Wlan(void);\n\n\tstatic int total_num_wifi_clients;\n\n\tvoid event_callback(ipa_cm_event_id event,\n\t\t\t\t\t\t\t\t\t\t\tvoid *data);\n\n\tvirtual int add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl);\n\nprivate:\n\n\teth_bridge_client_flt_info eth_bridge_usb_client_flt_info[IPA_LAN_TO_LAN_MAX_USB_CLIENT];\n\tint num_usb_client;\n\n\tuint32_t wlan_guest_ap_flt_rule_hdl_v4[IPA_MAX_PRIVATE_SUBNET_ENTRIES];\n\n\tuint32_t wlan_guest_ap_flt_rule_hdl_v6;\n\n\tstatic lan2lan_flt_rule_hdl self_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\n\tstatic lan2lan_flt_rule_hdl self_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\n\n\tstatic lan2lan_flt_rule_hdl usb_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_USB_CLIENT];\n\tstatic lan2lan_flt_rule_hdl usb_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_USB_CLIENT];\n\n\tbool is_guest_ap;\n\n\teth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_usb_info_v4;\n\tint wlan_client_rt_from_usb_info_count_v4;\n\teth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_usb_info_v6;\n\tint wlan_client_rt_from_usb_info_count_v6;\n\n\teth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_wlan_info_v4;\n\tint wlan_client_rt_from_wlan_info_count_v4;\n\teth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_wlan_info_v6;\n\tint wlan_client_rt_from_wlan_info_count_v6;\n\n\tvirtual int eth_bridge_add_wlan_guest_ap_flt_rule(ipa_ip_type iptype);\n\n\tint eth_bridge_install_wlan_guest_ap_ipv6_flt_rule();\n\n\tvirtual int eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype);\n\n\tvirtual int eth_bridge_handle_dummy_usb_client_flt_rule(ipa_ip_type iptype);\n\n\tint eth_bridge_add_usb_client_flt_rule(uint8_t* mac, ipa_ip_type iptype);\n\n\tint eth_bridge_del_usb_client_flt_rule(uint8_t* mac);\n\n\tint eth_bridge_add_self_client_flt_rule(uint8_t* mac, ipa_ip_type iptype);\n\n\tint eth_bridge_del_self_client_flt_rule(uint8_t* mac);\n\n\tvirtual int eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype);\n\n\tvirtual int eth_bridge_install_cache_usb_client_flt_rule(ipa_ip_type iptype);\n\n\tint eth_bridge_add_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype);\n\n\tint eth_bridge_del_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src);\n\n\teth_bridge_client_rt_info* eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype);\n\n\tvoid eth_bridge_add_wlan_client(uint8_t* mac, int if_num);\n\n\tvoid eth_bridge_del_wlan_client(uint8_t* mac);\n\n\n\tint wlan_client_len;\n\tipa_wlan_client *wlan_client;\n\n\tint header_name_count;\n\tint num_wifi_client;\n\n\tint wlan_ap_index;\n\n\tstatic uint32_t* dummy_flt_rule_hdl_v4;\n\tstatic uint32_t* dummy_flt_rule_hdl_v6;\n\n\tstatic int num_wlan_ap_iface;\n\n\tNatApp *Nat_App;\n\n\tinline ipa_wlan_client* get_client_memptr(ipa_wlan_client *param, int cnt)\n\t{\n\t    char *ret = ((char *)param) + (wlan_client_len * cnt);\n\t\treturn (ipa_wlan_client *)ret;\n\t}\n\n\tinline int get_wlan_client_index(uint8_t *mac_addr)\n\t{\n\t\tint cnt;\n\t\tint num_wifi_client_tmp = num_wifi_client;\n\n\t\tIPACMDBG_H(\"Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\t\tfor(cnt = 0; cnt < num_wifi_client_tmp; cnt++)\n\t\t{\n\t\t\tIPACMDBG_H(\"stored MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t get_client_memptr(wlan_client, cnt)->mac[0],\n\t\t\t\t\t\t\t get_client_memptr(wlan_client, cnt)->mac[1],\n\t\t\t\t\t\t\t get_client_memptr(wlan_client, cnt)->mac[2],\n\t\t\t\t\t\t\t get_client_memptr(wlan_client, cnt)->mac[3],\n\t\t\t\t\t\t\t get_client_memptr(wlan_client, cnt)->mac[4],\n\t\t\t\t\t\t\t get_client_memptr(wlan_client, cnt)->mac[5]);\n\n\t\t\tif(memcmp(get_client_memptr(wlan_client, cnt)->mac,\n\t\t\t\t\t\t\t\tmac_addr,\n\t\t\t\t\t\t\t\tsizeof(get_client_memptr(wlan_client, cnt)->mac)) == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Matched client index: %d\\n\", cnt);\n\t\t\t\treturn cnt;\n\t\t\t}\n\t\t}\n\n\t\treturn IPACM_INVALID_INDEX;\n\t}\n\n\tinline int delete_default_qos_rtrules(int clt_indx, ipa_ip_type iptype)\n\t{\n\t\tuint32_t tx_index;\n\t\tuint32_t rt_hdl;\n\t\tint num_v6;\n\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t     for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t     {\n\t\t        if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(wlan_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Delete client index %d ipv4 Qos rules for tx:%d \\n\",clt_indx,tx_index);\n\t\t\t\trt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v4;\n\n\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)\n\t\t\t\t{\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t}\n\t\t     } /* end of for loop */\n\n\t\t     /* clean the 4 Qos ipv4 RT rules for client:clt_indx */\n\t\t     if(get_client_memptr(wlan_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */\n\t\t     {\n\t\t\t\tget_client_memptr(wlan_client, clt_indx)->route_rule_set_v4 = false;\n\t\t     }\n\t\t}\n\n\t\tif(iptype == IPA_IP_v6)\n\t\t{\n\t\t    for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t    {\n\n\t\t\t\tif((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */\n\t\t\t\t{\n\t\t\t\t\tfor(num_v6 =0;num_v6 < get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6;num_v6++)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Delete client index %d ipv6 Qos rules for %d-st ipv6 for tx:%d\\n\", clt_indx,num_v6,tx_index);\n\t\t\t\t\t\trt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6[num_v6];\n\t\t\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6_wan[num_v6];\n\t\t\t\t\t\tif(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t} /* end of for loop */\n\n\t\t    /* clean the 4 Qos ipv6 RT rules for client:clt_indx */\n\t\t    if(get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */\n\t\t    {\n\t\t                 get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 = 0;\n                    }\n\t\t}\n\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\t/* for handle wifi client initial,copy all partial headers (tx property) */\n\tint handle_wlan_client_init_ex(ipacm_event_data_wlan_ex *data);\n\n\t/*handle lan2lan internal mesg posting*/\n\tint handle_lan2lan_msg_post(uint8_t *mac_addr, ipa_cm_event_id event, ipa_ip_type iptype);\n\n\t/*handle wifi client */\n\tint handle_wlan_client_ipaddr(ipacm_event_data_all *data);\n\n\t/*handle wifi client routing rule*/\n\tint handle_wlan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);\n\n\t/*handle wifi client power-save mode*/\n\tint handle_wlan_client_pwrsave(uint8_t *mac_addr);\n\n\t/*handle wifi client del mode*/\n\tint handle_wlan_client_down_evt(uint8_t *mac_addr);\n\n\t/*handle wlan iface down event*/\n\tint handle_down_evt();\n\n\t/* add dummy filtering rules for WLAN AP-AP mode support */\n\tvoid add_dummy_flt_rule();\n\n\t/* install dummy filtering rules for WLAN AP-AP mode support */\n\tint install_dummy_flt_rule(ipa_ip_type iptype, int num_rule);\n\n\t/* delete dummy flt rule for WLAN AP-AP mode support*/\n\tvoid del_dummy_flt_rule();\n\n\t/*Configure the initial filter rules */\n\tvirtual int init_fl_rule(ipa_ip_type iptype);\n\n\tvirtual int add_dummy_lan2lan_flt_rule(ipa_ip_type iptype);\n\n\tvirtual int add_dummy_private_subnet_flt_rule(ipa_ip_type iptype);\n\n\t/*configure private subnet filter rules*/\n\tvirtual int handle_private_subnet(ipa_ip_type iptype);\n\n\t/* install UL filter rule from Q6 */\n\tvirtual int handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype);\n\n\t/* install TCP control filter rules */\n\tvirtual void install_tcp_ctl_flt_rule(ipa_ip_type iptype);\n\n\t/*handle reset wifi-client rt-rules */\n\tint handle_wlan_client_reset_rt(ipa_ip_type iptype);\n};\n\n\n#endif /* IPACM_WLAN_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n  @file\n  IPACM_Xml.h\n\n  @brief\n  This file implements the XML specific parsing functionality.\n\n  @Author\n  Skylar Chang/Shihuan Liu\n\n*/\n#ifndef IPACM_XML_H\n#define IPACM_XML_H\n\n#include <linux/msm_ipa.h>\n#include \"IPACM_Defs.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <arpa/inet.h>\n#include <stdint.h>\n#include <libxml/parser.h>\n#include <libxml/tree.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n  \n#define IPACM_ASSERT(a)                                            \\\nif (!(a)) {                                             \\\n    fprintf(stderr, \"%s, %d: assertion (a) failed!\",    \\\n            __FILE__,                                   \\\n            __LINE__);                                  \\\n    abort();                                         \\\n}\n  \n/* Max allowed size of the XML file (2 MB) */\n#define IPACM_XML_MAX_FILESIZE               (2 << 20)\n#define IPACM_MAX_FIREWALL_ENTRIES            50\n#define IPACM_IPV6_ADDR_LEN                   16\n\n/* Defines for clipping space or space & quotes (single, double) */\n#define IPACM_XML_CLIP_SPACE         \" \"\n#define IPACM_XML_CLIP_SPACE_QUOTES  \" '\\\"\"\n\n#define MAX_XML_STR_LEN                 120\n  \n/* IPA Config Entries */\n#define system_TAG                           \"system\"\n#define ODU_TAG                              \"ODUCFG\"\n#define ODUMODE_TAG                          \"Mode\"\n#define ODU_ROUTER_TAG                       \"router\"\n#define ODU_BRIDGE_TAG                       \"bridge\"\n#define IPACMCFG_TAG                         \"IPACM\"\n#define IPACMIFACECFG_TAG                    \"IPACMIface\"\n#define IFACE_TAG                            \"Iface\"\n#define NAME_TAG                             \"Name\"\n#define CATEGORY_TAG                         \"Category\"\n#define IPACMPRIVATESUBNETCFG_TAG            \"IPACMPrivateSubnet\"\n#define SUBNET_TAG                           \"Subnet\"\n#define SUBNETADDRESS_TAG                    \"SubnetAddress\"\n#define SUBNETMASK_TAG                       \"SubnetMask\"\n#define WANIF_TAG                            \"WAN\"\n#define LANIF_TAG                            \"LAN\"\n#define WLANIF_TAG                           \"WLAN\"\n#define VIRTUALIF_TAG                        \"VIRTUAL\"\n#define UNKNOWNIF_TAG                        \"UNKNOWN\"\n#define ODUIF_TAG                            \"ODU\"\n#define EMBMSIF_TAG                          \"EMBMS\"\n#define ETHIF_TAG                            \"ETH\"\n#define IPACMALG_TAG                         \"IPACMALG\"\n#define ALG_TAG                              \"ALG\"\n#define Protocol_TAG                         \"Protocol\"\n#define Port_TAG                             \"Port\"\n#define TCP_PROTOCOL_TAG                     \"TCP\"\n#define UDP_PROTOCOL_TAG                     \"UDP\"\n\n/* FIREWALL Config Entries */\n#define Firewall_TAG                         \"Firewall\"\n#define MobileAPFirewallCfg_TAG              \"MobileAPFirewallCfg\"\n#define FirewallEnabled_TAG                  \"FirewallEnabled\"\n#define FirewallPktsAllowed_TAG              \"FirewallPktsAllowed\"\n\n#define IPFamily_TAG                         \"IPFamily\"\n#define IPV4SourceAddress_TAG                \"IPV4SourceAddress\"\n#define IPV4SourceIPAddress_TAG              \"IPV4SourceIPAddress\"\n#define IPV4SourceSubnetMask_TAG             \"IPV4SourceSubnetMask\"\n\n#define IPV4DestinationAddress_TAG           \"IPV4DestinationAddress\"\n#define IPV4DestinationIPAddress_TAG         \"IPV4DestinationIPAddress\"\n#define IPV4DestinationSubnetMask_TAG        \"IPV4DestinationSubnetMask\"\n\n#define IPV4TypeOfService_TAG                \"IPV4TypeOfService\"\n#define TOSValue_TAG                         \"TOSValue\"\n#define TOSMask_TAG                          \"TOSMask\"\n\n#define IPV4NextHeaderProtocol_TAG           \"IPV4NextHeaderProtocol\"\n\n#define IPV6SourceAddress_TAG                \"IPV6SourceAddress\"\n#define IPV6SourceIPAddress_TAG              \"IPV6SourceIPAddress\"\n#define IPV6SourcePrefix_TAG                 \"IPV6SourcePrefix\"\n\n#define IPV6DestinationAddress_TAG           \"IPV6DestinationAddress\"\n#define IPV6DestinationIPAddress_TAG         \"IPV6DestinationIPAddress\"\n#define IPV6DestinationPrefix_TAG            \"IPV6DestinationPrefix\"\n\n#define IPV6TrafficClass_TAG                 \"IPV6TrafficClass\"\n#define TrfClsValue_TAG                      \"TrfClsValue\"\n#define TrfClsMask_TAG                       \"TrfClsMask\"\n\n#define IPV6NextHeaderProtocol_TAG           \"IPV6NextHeaderProtocol\"\n\n#define TCPSource_TAG                        \"TCPSource\"\n#define TCPSourcePort_TAG                    \"TCPSourcePort\"\n#define TCPSourceRange_TAG                   \"TCPSourceRange\"\n\n#define TCPDestination_TAG                   \"TCPDestination\"\n#define TCPDestinationPort_TAG               \"TCPDestinationPort\"\n#define TCPDestinationRange_TAG              \"TCPDestinationRange\"\n\n#define UDPSource_TAG                        \"UDPSource\"\n#define UDPSourcePort_TAG                    \"UDPSourcePort\"\n#define UDPSourceRange_TAG                   \"UDPSourceRange\"\n\n#define UDPDestination_TAG                   \"UDPDestination\"\n#define UDPDestinationPort_TAG               \"UDPDestinationPort\"\n#define UDPDestinationRange_TAG              \"UDPDestinationRange\"\n\n#define ICMPType_TAG                         \"ICMPType\"\n#define ICMPCode_TAG                         \"ICMPCode\"\n\n#define ESP_TAG                              \"ESP\"\n#define ESPSPI_TAG                           \"ESPSPI\"\n\n#define TCP_UDPSource_TAG                    \"TCP_UDPSource\"\n#define TCP_UDPSourcePort_TAG                \"TCP_UDPSourcePort\"\n#define TCP_UDPSourceRange_TAG               \"TCP_UDPSourceRange\"\n\n#define TCP_UDPDestination_TAG               \"TCP_UDPDestination\"\n#define TCP_UDPDestinationPort_TAG           \"TCP_UDPDestinationPort\"\n#define TCP_UDPDestinationRange_TAG          \"TCP_UDPDestinationRange\"\n\n#define IPACMNat_TAG                         \"IPACMNAT\"\n#define NAT_MaxEntries_TAG                   \"MaxNatEntries\"\n\n/*---------------------------------------------------------------------------\n      IP protocol numbers - use in dss_socket() to identify protocols.\n      Also contains the extension header types for IPv6.\n---------------------------------------------------------------------------*/\ntypedef enum\n{\n  IPACM_FIREWALL_IPV6_BASE_HDR        = 4,                               /* IPv6 Base Header           */\n  IPACM_FIREWALL_IPPROTO_HOP_BY_HOP_OPT_HDR = 0,                         /* Hop-by-hop Option Header   */\n  IPACM_FIREWALL_IPPROTO_ICMP         = 1,                               /* ICMP protocol */\n  IPACM_FIREWALL_IPPROTO_IGMP         = 2,                               /* IGMP protocol */\n  IPACM_FIREWALL_IPPROTO_IP           = IPACM_FIREWALL_IPV6_BASE_HDR,    /* IPv4          */\n  IPACM_FIREWALL_IPPROTO_TCP          = 6,                               /* TCP Protocol */\n  IPACM_FIREWALL_IPPROTO_UDP          = 17,                              /* UDP Protocol */\n  IPACM_FIREWALL_IPPROTO_IPV6         = 41,                              /* IPv6                       */\n  IPACM_FIREWALL_IPPROTO_ROUTING_HDR  = 43,                              /* Routing Header             */\n  IPACM_FIREWALL_IPPROTO_FRAG_HDR     = 44,                              /* Fragmentation Header       */\n  IPACM_FIREWALL_IPPROTO_GRE          = 47,                              /* GRE Protocol */\n  IPACM_FIREWALL_IPPROTO_ESP          = 50,                              /* ESP Protocol */\n  IPACM_FIREWALL_IPPROTO_AH           = 51,                              /* Authentication Header      */\n  IPACM_FIREWALL_IPPROTO_ICMP6        = 58,                              /* ICMPv6                     */\n  IPACM_FIREWALL_NO_NEXT_HDR          = 59,                              /* No Next Header for IPv6    */\n  IPACM_FIREWALL_IPPROTO_DEST_OPT_HDR = 60,                              /* Destination Options Header */\n  IPACM_FIREWALL_IPPROTO_MOBILITY_HDR = 135,                             /* Mobility Header            */\n  IPACM_FIREWALL_IPPROTO_TCP_UDP      = 253                              /* Unspecified protocol used for IPACM */\n} ipacm_firewall_ip_protocol_enum_type;\n\n/* define as mobileap firewall rule format*/\ntypedef enum\n{\n  IP_V4 = 4,\n  IP_V6 = 6\n} firewall_ip_version_enum;\n  \n/*---------------------------------------------------------------------------\n           Extended FireWall Entry Configuration.\n---------------------------------------------------------------------------*/\ntypedef struct\n{\n  struct ipa_rule_attrib attrib;\n  firewall_ip_version_enum  ip_vsn;\n} IPACM_extd_firewall_entry_conf_t;\n\n\n/*---------------------------------------------------------------------------\n           Extended FireWall configuration.\n---------------------------------------------------------------------------*/\ntypedef union\n{\n  IPACM_extd_firewall_entry_conf_t extd_firewall_entry;\n} IPACM_extd_firewall_conf_t;\n\n\ntypedef struct\n{\n  char     firewall_config_file[IPA_MAX_FILE_LEN];\n  uint8_t    num_extd_firewall_entries;\n  IPACM_extd_firewall_entry_conf_t extd_firewall_entries[IPACM_MAX_FIREWALL_ENTRIES];\n\tbool     rule_action_accept;\n\tbool     firewall_enable;\t\n} IPACM_firewall_conf_t;\n  \n\n\ntypedef struct\n{\n  uint8_t    num_iface_entries;\n  ipa_ifi_dev_name_t iface_entries[IPA_MAX_IFACE_ENTRIES];\n} ipacm_iface_conf_t;\n\ntypedef struct\n{\n  uint8_t    num_subnet_entries;\n  ipa_private_subnet private_subnet_entries[IPA_MAX_PRIVATE_SUBNET_ENTRIES];\n} ipacm_private_subnet_conf_t;\n\ntypedef struct\n{\n  uint8_t protocol;\n  uint16_t port;\n} ipacm_alg;\n\ntypedef struct\n{\n  uint8_t    num_alg_entries;\n  ipacm_alg alg_entries[IPA_MAX_ALG_ENTRIES];\n} ipacm_alg_conf_t;\n\n \ntypedef struct  _IPACM_conf_t\n{\n  ipacm_iface_conf_t iface_config;\n  ipacm_private_subnet_conf_t private_subnet_config;\n  ipacm_alg_conf_t alg_config;\n\tint nat_max_entries;\n  bool odu_enable;\n  bool router_mode_enable;\n} IPACM_conf_t;  \n\n/* This function read IPACM XML configuration*/\nint ipacm_read_cfg_xml\n(\n  char *xml_file,                              /* Filename and path     */\n  IPACM_conf_t *config                         /* Mobile AP config data */\n);\n\n/* This function reads QCMAP Firewall XML and store in IPACM Firewall stucture */\nint IPACM_read_firewall_xml\n(\n  char *xml_file,                                 /* Filename and path     */\n  IPACM_firewall_conf_t *config                   /* Mobile AP config data */\n);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif //IPACM_XML\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_C_INCLUDES := $(LOCAL_PATH)/../src\nLOCAL_C_INCLUDES += $(LOCAL_PATH)/../inc\nLOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ipanat/inc\nifeq ($(call is-platform-sdk-version-at-least,20),true)\nLOCAL_C_INCLUDES += external/icu/icu4c/source/common\nelse\nLOCAL_C_INCLUDES += external/icu4c/common\nendif\nLOCAL_C_INCLUDES += external/libxml2/include\nLOCAL_C_INCLUDES += external/libnetfilter_conntrack/include\nLOCAL_C_INCLUDES += external/libnfnetlink/include\n\nLOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include\nLOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr\n\n\nLOCAL_CFLAGS := -v\nLOCAL_CFLAGS += -DFEATURE_IPA_ANDROID\nLOCAL_CFLAGS += -DDEBUG\n\nifeq ($(TARGET_ARCH),arm)\nLOCAL_CFLAGS += -include bionic/libc/kernel/arch-arm/asm/posix_types.h\nLOCAL_CFLAGS += -include bionic/libc/kernel/arch-arm/asm/byteorder.h\nendif\n\nLOCAL_SRC_FILES := IPACM_Main.cpp \\\n\t\tIPACM_EvtDispatcher.cpp \\\n\t\tIPACM_Config.cpp \\\n\t\tIPACM_CmdQueue.cpp \\\n\t\tIPACM_Filtering.cpp \\\n\t\tIPACM_Routing.cpp \\\n\t\tIPACM_Header.cpp \\\n\t\tIPACM_Lan.cpp \\\n\t\tIPACM_Iface.cpp \\\n\t\tIPACM_Wlan.cpp \\\n\t\tIPACM_Wan.cpp \\\n\t\tIPACM_IfaceManager.cpp \\\n\t\tIPACM_Neighbor.cpp \\\n\t\tIPACM_Netlink.cpp \\\n\t\tIPACM_Xml.cpp \\\n\t\tIPACM_Conntrack_NATApp.cpp\\\n\t\tIPACM_ConntrackClient.cpp \\\n\t\tIPACM_ConntrackListener.cpp \\\n                IPACM_Log.cpp\n\nLOCAL_MODULE := ipacm\nLOCAL_MODULE_TAGS := optional\n\nLOCAL_SHARED_LIBRARIES := libipanat\nLOCAL_SHARED_LIBRARIES += libxml2\nLOCAL_SHARED_LIBRARIES += libnfnetlink\nLOCAL_SHARED_LIBRARIES += libnetfilter_conntrack\ninclude $(BUILD_EXECUTABLE)\n\n################################################################################\n\ndefine ADD_TEST\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE       := $1\nLOCAL_SRC_FILES    := $1\nLOCAL_MODULE_CLASS := ipacm\nLOCAL_MODULE_TAGS  := debug\nLOCAL_MODULE_PATH  := $(TARGET_OUT_ETC)\ninclude $(BUILD_PREBUILT)\n\nendef\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := IPACM_cfg.xml\nLOCAL_MODULE_CLASS := ETC\nLOCAL_MODULE_PATH := $(TARGET_OUT_ETC)\nLOCAL_MODULE_TAGS := optional\nLOCAL_SRC_FILES := $(LOCAL_MODULE)\nLOCAL_MODULE_OWNER := ipacm\ninclude $(BUILD_PREBUILT)\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_CmdQueue.cpp",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_CmdQueue.cpp\n\n\t@brief\n\tThis file implements the IPAM Comment Queue functionality\n\n\t@Author \n   Sunil\n\n*/\n#include <string.h>\n#include \"IPACM_CmdQueue.h\"\n#include \"IPACM_Log.h\"\n\npthread_mutex_t mutex    = PTHREAD_MUTEX_INITIALIZER;\npthread_cond_t  cond_var = PTHREAD_COND_INITIALIZER;\n\nMessageQueue* MessageQueue::inst = NULL;\nMessageQueue* MessageQueue::getInstance()\n{\n\tif(inst == NULL)\n\t{\n\t\tinst = new MessageQueue();\n\t\tif(inst == NULL)\n\t\t{\n\t\t\tIPACMERR(\"unable to create Message Queue instance\\n\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\treturn inst;\n}\n\nvoid MessageQueue::enqueue(Message *item)\n{\n\tif(!Head)\n\t{\n\t\tTail = item;\n\t\tHead = item;\n\t}\n\telse\n\t{\n\t\tif(Tail == NULL)\n\t\t{\n\t\t\tIPACMDBG(\"Tail is null\\n\");\n\t\t\tHead->setnext(item);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tTail->setnext(item);\n\t\t}\n\t\tTail = item;\n\t}\n}\n\n\nMessage* MessageQueue::dequeue(void)\n{\n\tif(Head == NULL)\n\t{\n\t\treturn NULL;\n\t}\n\telse\n\t{\n\t\tMessage *tmp = Head;\n\t\tHead = Head->getnext();\n\n\t\treturn tmp;\n\t}\n}\n\n\nvoid* MessageQueue::Process(void *param)\n{\n\tMessageQueue *MsgQueue = NULL;\n\tMessage *item = NULL;\n\tIPACMDBG(\"MessageQueue::Process()\\n\");\n\n\tMsgQueue = MessageQueue::getInstance();\n\tif(MsgQueue == NULL)\n\t{\n\t\tIPACMERR(\"unable to start cmd queue process\\n\");\n\t\treturn NULL;\n\t}\n\n\twhile(1)\n\t{\n\t\tif(pthread_mutex_lock(&mutex) != 0)\n\t\t{\n\t\t\tIPACMERR(\"unable to lock the mutex\\n\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\titem = MsgQueue->dequeue();\n\n\t\tif(item == NULL)\n\t\t{\n\t\t\tIPACMDBG(\"Waiting for Message\\n\");\n\n\t\t\tif(pthread_cond_wait(&cond_var, &mutex) != 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to lock the mutex\\n\");\n\n\t\t\t\tif(pthread_mutex_unlock(&mutex) != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to unlock the mutex\\n\");\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tif(pthread_mutex_unlock(&mutex) != 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to unlock the mutex\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(pthread_mutex_unlock(&mutex) != 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to unlock the mutex\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tIPACMDBG(\"Processing item %p event ID: %d\\n\",item,item->evt.data.event);\n\t\t\titem->evt.callback_ptr(&item->evt.data);\n\t\t\tdelete item;\n\t\t\titem = NULL;\n\t\t}\n\n\t} /* Go forever until a termination indication is received */\n\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t\t\t* Redistributions of source code must retain the above copyright\n\t\t\t\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t\t\t* Redistributions in binary form must reproduce the above\n\t\t\t\t\t\tcopyright notice, this list of conditions and the following\n\t\t\t\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\t\t\t\twith the distribution.\n\t\t\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\t\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\t\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t\t@file\n\t\tIPACM_Config.cpp\n\n\t\t@brief\n\t\tThis file implements the IPACM Configuration from XML file\n\n\t\t@Author\n\t\tSkylar Chang\n\n*/\n#include <IPACM_Config.h>\n#include <IPACM_Log.h>\n#include <IPACM_Iface.h>\n#include <sys/ioctl.h>\n#include <fcntl.h>\n\nIPACM_Config *IPACM_Config::pInstance = NULL;\nconst char *IPACM_Config::DEVICE_NAME = \"/dev/ipa\";\nconst char *IPACM_Config::DEVICE_NAME_ODU = \"/dev/odu_ipa_bridge\";\n\nIPACM_Config::IPACM_Config()\n{\n\tiface_table = NULL;\n\talg_table = NULL;\n\tmemset(&ipa_client_rm_map_tbl, 0, sizeof(ipa_client_rm_map_tbl));\n\tmemset(&ipa_rm_tbl, 0, sizeof(ipa_rm_tbl));\n    ipa_rm_a2_check=0;\n\tipacm_odu_enable = false;\n\tipacm_odu_router_mode = false;\n\n\tipa_num_ipa_interfaces = 0;\n\tipa_num_private_subnet = 0;\n\tipa_num_alg_ports = 0;\n\tipa_nat_max_entries = 0;\n\tipa_nat_iface_entries = 0;\n\tipa_sw_rt_enable = false;\n\n\tmemset(&rt_tbl_default_v4, 0, sizeof(rt_tbl_default_v4));\n\tmemset(&rt_tbl_lan_v4, 0, sizeof(rt_tbl_lan_v4));\n\tmemset(&rt_tbl_wan_v4, 0, sizeof(rt_tbl_wan_v4));\n\tmemset(&rt_tbl_v6, 0, sizeof(rt_tbl_v6));\n\tmemset(&rt_tbl_wan_v6, 0, sizeof(rt_tbl_wan_v6));\n\tmemset(&rt_tbl_wan_dl, 0, sizeof(rt_tbl_wan_dl));\n\tmemset(&rt_tbl_odu_v4, 0, sizeof(rt_tbl_odu_v4));\n\tmemset(&rt_tbl_odu_v6, 0, sizeof(rt_tbl_odu_v6));\n\n\tmemset(&ext_prop_v4, 0, sizeof(ext_prop_v4));\n\tmemset(&ext_prop_v6, 0, sizeof(ext_prop_v6));\n\n\tmemset(&rt_tbl_eth_bridge_usb_wlan_v4, 0, sizeof(rt_tbl_eth_bridge_usb_wlan_v4));\n\tmemset(&rt_tbl_eth_bridge_wlan_wlan_v4, 0, sizeof(rt_tbl_eth_bridge_wlan_wlan_v4));\n\tmemset(&rt_tbl_eth_bridge_usb_wlan_v6, 0, sizeof(rt_tbl_eth_bridge_usb_wlan_v6));\n\tmemset(&rt_tbl_eth_bridge_wlan_wlan_v6, 0, sizeof(rt_tbl_eth_bridge_wlan_wlan_v6));\n\n\tqmap_id = ~0;\n\n\tIPACMDBG_H(\" create IPACM_Config constructor\\n\");\n\treturn;\n}\n\nint IPACM_Config::Init(void)\n{\n\t/* Read IPACM Config file */\n\tchar\tIPACM_config_file[IPA_MAX_FILE_LEN];\n\tIPACM_conf_t\t*cfg;\n\tcfg = (IPACM_conf_t *)malloc(sizeof(IPACM_conf_t));\n\tif(cfg == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate cfg memory.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tuint32_t subnet_addr;\n\tuint32_t subnet_mask;\n\tint i, ret = IPACM_SUCCESS;\n\tstruct in_addr in_addr_print;\n\n\tm_fd = open(DEVICE_NAME, O_RDWR);\n\tif (0 > m_fd)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", DEVICE_NAME);\n\t}\n\tstrncpy(IPACM_config_file, \"/etc/IPACM_cfg.xml\", sizeof(IPACM_config_file));\n\n\tIPACMDBG_H(\"\\n IPACM XML file is %s \\n\", IPACM_config_file);\n\tif (IPACM_SUCCESS == ipacm_read_cfg_xml(IPACM_config_file, cfg))\n\t{\n\t\tIPACMDBG_H(\"\\n IPACM XML read OK \\n\");\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"\\n IPACM XML read failed \\n\");\n\t\tret = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\t/* Construct IPACM Iface table */\n\tipa_num_ipa_interfaces = cfg->iface_config.num_iface_entries;\n\tif (iface_table != NULL)\n\t{\n\t\tfree(iface_table);\n\t\tiface_table = NULL;\n\t\tIPACMDBG_H(\"RESET IPACM_Config::iface_table\\n\");\n\t}\n\tiface_table = (ipa_ifi_dev_name_t *)calloc(ipa_num_ipa_interfaces,\n\t\t\t\t\tsizeof(ipa_ifi_dev_name_t));\n\tif(iface_table == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate iface_table memory.\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tfor (i = 0; i < cfg->iface_config.num_iface_entries; i++)\n\t{\n\t\tstrncpy(iface_table[i].iface_name, cfg->iface_config.iface_entries[i].iface_name, sizeof(iface_table[i].iface_name));\n\t\tiface_table[i].if_cat = cfg->iface_config.iface_entries[i].if_cat;\n\t\tIPACMDBG_H(\"IPACM_Config::iface_table[%d] = %s, cat=%d\\n\", i, iface_table[i].iface_name, iface_table[i].if_cat);\n\t\t/* copy bridge interface name to ipacmcfg */\n\t\tif( iface_table[i].if_cat == VIRTUAL_IF)\n\t\t{\n\t\t\tmemcpy(ipa_virtual_iface_name, iface_table[i].iface_name, sizeof(ipa_virtual_iface_name));\n\t\t\tIPACMDBG_H(\"ipa_virtual_iface_name(%s) \\n\", ipa_virtual_iface_name);\n\t\t}\n\t}\n\n\t/* Construct IPACM Private_Subnet table */\n\tmemset(&private_subnet_table, 0, sizeof(private_subnet_table));\n\tipa_num_private_subnet = cfg->private_subnet_config.num_subnet_entries;\n\n\tfor (i = 0; i < cfg->private_subnet_config.num_subnet_entries; i++)\n\t{\n\t\tmemcpy(&private_subnet_table[i].subnet_addr,\n\t\t\t\t\t &cfg->private_subnet_config.private_subnet_entries[i].subnet_addr,\n\t\t\t\t\t sizeof(cfg->private_subnet_config.private_subnet_entries[i].subnet_addr));\n\n\t\tmemcpy(&private_subnet_table[i].subnet_mask,\n\t\t\t\t\t &cfg->private_subnet_config.private_subnet_entries[i].subnet_mask,\n\t\t\t\t\t sizeof(cfg->private_subnet_config.private_subnet_entries[i].subnet_mask));\n\n\t\tsubnet_addr = htonl(private_subnet_table[i].subnet_addr);\n\t\tmemcpy(&in_addr_print,&subnet_addr,sizeof(in_addr_print));\n\t\tIPACMDBG_H(\"%dst::private_subnet_table= %s \\n \", i,\n\t\t\t\t\t\t inet_ntoa(in_addr_print));\n\n\t\tsubnet_mask =  htonl(private_subnet_table[i].subnet_mask);\n\t\tmemcpy(&in_addr_print,&subnet_mask,sizeof(in_addr_print));\n\t\tIPACMDBG_H(\"%dst::private_subnet_table= %s \\n \", i,\n\t\t\t\t\t\t inet_ntoa(in_addr_print));\n\t}\n\n\t/* Construct IPACM ALG table */\n\tipa_num_alg_ports = cfg->alg_config.num_alg_entries;\n\tif (alg_table != NULL)\n\t{\n\t\tfree(alg_table);\n\t\talg_table = NULL;\n\t\tIPACMDBG_H(\"RESET IPACM_Config::alg_table \\n\");\n\t}\n\talg_table = (ipacm_alg *)calloc(ipa_num_alg_ports,\n\t\t\t\tsizeof(ipacm_alg));\n\tif(alg_table == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate alg_table memory.\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tfree(iface_table);\n\t\tgoto fail;;\n\t}\n\tfor (i = 0; i < cfg->alg_config.num_alg_entries; i++)\n\t{\n\t\talg_table[i].protocol = cfg->alg_config.alg_entries[i].protocol;\n\t\talg_table[i].port = cfg->alg_config.alg_entries[i].port;\n\t\tIPACMDBG_H(\"IPACM_Config::ipacm_alg[%d] = %d, port=%d\\n\", i, alg_table[i].protocol, alg_table[i].port);\n\t}\n\n\tipa_nat_max_entries = cfg->nat_max_entries;\n\tIPACMDBG_H(\"Nat Maximum Entries %d\\n\", ipa_nat_max_entries);\n\n\t/* Find ODU is either router mode or bridge mode*/\n\tipacm_odu_enable = cfg->odu_enable;\n\tipacm_odu_router_mode = cfg->router_mode_enable;\n\tIPACMDBG_H(\"ipacm_odu_enable %d\\n\", ipacm_odu_enable);\n\tIPACMDBG_H(\"ipacm_odu_mode %d\\n\", ipacm_odu_router_mode);\n\n\t/* Allocate more non-nat entries if the monitored iface dun have Tx/Rx properties */\n\tif (pNatIfaces != NULL)\n\t{\n\t\tfree(pNatIfaces);\n\t\tpNatIfaces = NULL;\n\t\tIPACMDBG_H(\"RESET IPACM_Config::pNatIfaces \\n\");\n\t}\n\tpNatIfaces = (NatIfaces *)calloc(ipa_num_ipa_interfaces, sizeof(NatIfaces));\n\tif (pNatIfaces == NULL)\n\t{\n\t\tIPACMERR(\"unable to allocate nat ifaces\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tfree(iface_table);\n\t\tfree(alg_table);\n\t\tgoto fail;\n\t}\n\n\t/* Construct the routing table ictol name in iface static member*/\n\trt_tbl_default_v4.ip = IPA_IP_v4;\n\tstrncpy(rt_tbl_default_v4.name, V4_DEFAULT_ROUTE_TABLE_NAME, sizeof(rt_tbl_default_v4.name));\n\n\trt_tbl_lan_v4.ip = IPA_IP_v4;\n\tstrncpy(rt_tbl_lan_v4.name, V4_LAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_lan_v4.name));\n\n\trt_tbl_wan_v4.ip = IPA_IP_v4;\n\tstrncpy(rt_tbl_wan_v4.name, V4_WAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_wan_v4.name));\n\n\trt_tbl_v6.ip = IPA_IP_v6;\n\tstrncpy(rt_tbl_v6.name, V6_COMMON_ROUTE_TABLE_NAME, sizeof(rt_tbl_v6.name));\n\n\trt_tbl_wan_v6.ip = IPA_IP_v6;\n\tstrncpy(rt_tbl_wan_v6.name, V6_WAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_wan_v6.name));\n\n\trt_tbl_odu_v4.ip = IPA_IP_v4;\n\tstrncpy(rt_tbl_odu_v4.name, V4_ODU_ROUTE_TABLE_NAME, sizeof(rt_tbl_odu_v4.name));\n\n\trt_tbl_odu_v6.ip = IPA_IP_v6;\n\tstrncpy(rt_tbl_odu_v6.name, V6_ODU_ROUTE_TABLE_NAME, sizeof(rt_tbl_odu_v6.name));\n\n\trt_tbl_wan_dl.ip = IPA_IP_MAX;\n\tstrncpy(rt_tbl_wan_dl.name, WAN_DL_ROUTE_TABLE_NAME, sizeof(rt_tbl_wan_dl.name));\n\n\trt_tbl_lan2lan_v4.ip = IPA_IP_v4;\n\tstrncpy(rt_tbl_lan2lan_v4.name, V4_LAN_TO_LAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_lan2lan_v4.name));\n\n\trt_tbl_lan2lan_v6.ip = IPA_IP_v6;\n\tstrncpy(rt_tbl_lan2lan_v6.name, V6_LAN_TO_LAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_lan2lan_v6.name));\n\n\trt_tbl_eth_bridge_usb_wlan_v4.ip = IPA_IP_v4;\n\tstrncpy(rt_tbl_eth_bridge_usb_wlan_v4.name, ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V4, sizeof(rt_tbl_eth_bridge_usb_wlan_v4.name));\n\n\trt_tbl_eth_bridge_wlan_wlan_v4.ip = IPA_IP_v4;\n\tstrncpy(rt_tbl_eth_bridge_wlan_wlan_v4.name, ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V4, sizeof(rt_tbl_eth_bridge_wlan_wlan_v4.name));\n\n\trt_tbl_eth_bridge_usb_wlan_v6.ip = IPA_IP_v6;\n\tstrncpy(rt_tbl_eth_bridge_usb_wlan_v6.name, ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V6, sizeof(rt_tbl_eth_bridge_usb_wlan_v6.name));\n\n\trt_tbl_eth_bridge_wlan_wlan_v6.ip = IPA_IP_v6;\n\tstrncpy(rt_tbl_eth_bridge_wlan_wlan_v6.name, ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V6, sizeof(rt_tbl_eth_bridge_wlan_wlan_v6.name));\n\n\t/* Construct IPACM ipa_client map to rm_resource table */\n\tipa_client_rm_map_tbl[IPA_CLIENT_WLAN1_PROD]= IPA_RM_RESOURCE_WLAN_PROD;\n\tipa_client_rm_map_tbl[IPA_CLIENT_USB_PROD]= IPA_RM_RESOURCE_USB_PROD;\n\tipa_client_rm_map_tbl[IPA_CLIENT_A5_WLAN_AMPDU_PROD]= IPA_RM_RESOURCE_HSIC_PROD;\n\tipa_client_rm_map_tbl[IPA_CLIENT_A2_EMBEDDED_PROD]= IPA_RM_RESOURCE_Q6_PROD;\n\tipa_client_rm_map_tbl[IPA_CLIENT_A2_TETHERED_PROD]= IPA_RM_RESOURCE_Q6_PROD;\n\tipa_client_rm_map_tbl[IPA_CLIENT_APPS_LAN_WAN_PROD]= IPA_RM_RESOURCE_Q6_PROD;\n\tipa_client_rm_map_tbl[IPA_CLIENT_WLAN1_CONS]= IPA_RM_RESOURCE_WLAN_CONS;\n\tipa_client_rm_map_tbl[IPA_CLIENT_WLAN2_CONS]= IPA_RM_RESOURCE_WLAN_CONS;\n\tipa_client_rm_map_tbl[IPA_CLIENT_WLAN3_CONS]= IPA_RM_RESOURCE_WLAN_CONS;\n\tipa_client_rm_map_tbl[IPA_CLIENT_WLAN4_CONS]= IPA_RM_RESOURCE_WLAN_CONS;\n\tipa_client_rm_map_tbl[IPA_CLIENT_USB_CONS]= IPA_RM_RESOURCE_USB_CONS;\n\tipa_client_rm_map_tbl[IPA_CLIENT_A2_EMBEDDED_CONS]= IPA_RM_RESOURCE_Q6_CONS;\n\tipa_client_rm_map_tbl[IPA_CLIENT_A2_TETHERED_CONS]= IPA_RM_RESOURCE_Q6_CONS;\n\tipa_client_rm_map_tbl[IPA_CLIENT_APPS_WAN_CONS]= IPA_RM_RESOURCE_Q6_CONS;\n\n\t/* Create the entries which IPACM wants to add dependencies on */\n\tipa_rm_tbl[0].producer_rm1 = IPA_RM_RESOURCE_WLAN_PROD;\n\tipa_rm_tbl[0].consumer_rm1 = IPA_RM_RESOURCE_Q6_CONS;\n\tipa_rm_tbl[0].producer_rm2 = IPA_RM_RESOURCE_Q6_PROD;\n\tipa_rm_tbl[0].consumer_rm2 = IPA_RM_RESOURCE_WLAN_CONS;\n\n\tipa_rm_tbl[1].producer_rm1 = IPA_RM_RESOURCE_USB_PROD;\n\tipa_rm_tbl[1].consumer_rm1 = IPA_RM_RESOURCE_Q6_CONS;\n\tipa_rm_tbl[1].producer_rm2 = IPA_RM_RESOURCE_Q6_PROD;\n\tipa_rm_tbl[1].consumer_rm2 = IPA_RM_RESOURCE_USB_CONS;\n\n\tipa_rm_tbl[2].producer_rm1 = IPA_RM_RESOURCE_WLAN_PROD;\n\tipa_rm_tbl[2].consumer_rm1 = IPA_RM_RESOURCE_USB_CONS;\n\tipa_rm_tbl[2].producer_rm2 = IPA_RM_RESOURCE_USB_PROD;\n\tipa_rm_tbl[2].consumer_rm2 = IPA_RM_RESOURCE_WLAN_CONS;\n\n\tIPACMDBG_H(\" depend MAP-0 rm index %d to rm index: %d \\n\", IPA_RM_RESOURCE_WLAN_PROD, IPA_RM_RESOURCE_Q6_CONS);\n\tIPACMDBG_H(\" depend MAP-1 rm index %d to rm index: %d \\n\", IPA_RM_RESOURCE_USB_PROD, IPA_RM_RESOURCE_Q6_CONS);\n\tIPACMDBG_H(\" depend MAP-2 rm index %d to rm index: %d \\n\", IPA_RM_RESOURCE_WLAN_PROD, IPA_RM_RESOURCE_USB_CONS);\n\nfail:\n\tif (cfg != NULL)\n\t{\n\t\tfree(cfg);\n\t\tcfg = NULL;\n\t}\n\n\treturn ret;\n}\n\nIPACM_Config* IPACM_Config::GetInstance()\n{\n\tint res = IPACM_SUCCESS;\n\n\tif (pInstance == NULL)\n\t{\n\t\tpInstance = new IPACM_Config();\n\n\t\tres = pInstance->Init();\n\t\tif (res != IPACM_SUCCESS)\n\t\t{\n\t\t\tdelete pInstance;\n\t\t\tIPACMERR(\"unable to initialize config instance\\n\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\treturn pInstance;\n}\n\nint IPACM_Config::GetAlgPorts(int nPorts, ipacm_alg *pAlgPorts)\n{\n\tif (nPorts <= 0 || pAlgPorts == NULL)\n\t{\n\t\tIPACMERR(\"Invalid input\\n\");\n\t\treturn -1;\n\t}\n\n\tfor (int cnt = 0; cnt < nPorts; cnt++)\n\t{\n\t\tpAlgPorts[cnt].protocol = alg_table[cnt].protocol;\n\t\tpAlgPorts[cnt].port = alg_table[cnt].port;\n\t}\n\n\treturn 0;\n}\n\nint IPACM_Config::GetNatIfaces(int nIfaces, NatIfaces *pIfaces)\n{\n\tif (nIfaces <= 0 || pIfaces == NULL)\n\t{\n\t\tIPACMERR(\"Invalid input\\n\");\n\t\treturn -1;\n\t}\n\n\tfor (int cnt=0; cnt<nIfaces; cnt++)\n\t{\n\t\tmemcpy(pIfaces[cnt].iface_name,\n\t\t\t\t\t pNatIfaces[cnt].iface_name,\n\t\t\t\t\t sizeof(pIfaces[cnt].iface_name));\n\t}\n\n\treturn 0;\n}\n\n\nint IPACM_Config::AddNatIfaces(char *dev_name)\n{\n\tIPACMDBG_H(\"Add iface %s to NAT-ifaces, origin it has %d nat ifaces\\n\",\n\t\t\t\t\t          dev_name, ipa_nat_iface_entries);\n\tipa_nat_iface_entries++;\n\n\tif (ipa_nat_iface_entries < ipa_num_ipa_interfaces)\n\t{\n\t\tmemcpy(pNatIfaces[ipa_nat_iface_entries - 1].iface_name,\n\t\t\t\t\t dev_name, IPA_IFACE_NAME_LEN);\n\n\t\tIPACMDBG_H(\"Add Nat IfaceName: %s ,update nat-ifaces number: %d\\n\",\n\t\t\t\t\t\t pNatIfaces[ipa_nat_iface_entries - 1].iface_name,\n\t\t\t\t\t\t ipa_nat_iface_entries);\n\t}\n\n\treturn 0;\n}\n\nint IPACM_Config::DelNatIfaces(char *dev_name)\n{\n\tint i = 0;\n\tIPACMDBG_H(\"Del iface %s from NAT-ifaces, origin it has %d nat ifaces\\n\",\n\t\t\t\t\t dev_name, ipa_nat_iface_entries);\n\n\tfor (i = 0; i < ipa_nat_iface_entries; i++)\n\t{\n\t\tif (strcmp(dev_name, pNatIfaces[i].iface_name) == 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"Find Nat IfaceName: %s ,previous nat-ifaces number: %d\\n\",\n\t\t\t\t\t\t\t pNatIfaces[i].iface_name, ipa_nat_iface_entries);\n\n\t\t\t/* Reset the matched entry */\n\t\t\tmemset(pNatIfaces[i].iface_name, 0, IPA_IFACE_NAME_LEN);\n\n\t\t\tfor (; i < ipa_nat_iface_entries - 1; i++)\n\t\t\t{\n\t\t\t\tmemcpy(pNatIfaces[i].iface_name,\n\t\t\t\t\t\t\t pNatIfaces[i + 1].iface_name, IPA_IFACE_NAME_LEN);\n\n\t\t\t\t/* Reset the copied entry */\n\t\t\t\tmemset(pNatIfaces[i + 1].iface_name, 0, IPA_IFACE_NAME_LEN);\n\t\t\t}\n\t\t\tipa_nat_iface_entries--;\n\t\t\tIPACMDBG_H(\"Update nat-ifaces number: %d\\n\", ipa_nat_iface_entries);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tIPACMDBG_H(\"Can't find Nat IfaceName: %s with total nat-ifaces number: %d\\n\",\n\t\t\t\t\t    dev_name, ipa_nat_iface_entries);\n\treturn 0;\n}\n\n/* for IPACM resource manager dependency usage\n   add either Tx or Rx ipa_rm_resource_name and\n   also indicate that endpoint property if valid */\nvoid IPACM_Config::AddRmDepend(ipa_rm_resource_name rm1,bool rx_bypass_ipa)\n{\n\tint retval = 0;\n\tstruct ipa_ioc_rm_dependency dep;\n\n\tIPACMDBG_H(\" Got rm add-depend index : %d \\n\", rm1);\n\t/* ipa_rm_a2_check: IPA_RM_RESOURCE_Q6_CONS*/\n\tif(rm1 == IPA_RM_RESOURCE_Q6_CONS)\n\t{\n\t\tipa_rm_a2_check+=1;\n\t\tIPACMDBG_H(\"got %d times default RT routing from A2 \\n\", ipa_rm_a2_check);\n\t}\n\n\tfor(int i=0;i<IPA_MAX_PRIVATE_SUBNET_ENTRIES;i++)\n\t{\n\t\tif(rm1 == ipa_rm_tbl[i].producer_rm1)\n\t\t{\n\t\t\tipa_rm_tbl[i].producer1_up = true;\n\t\t\t/* entry1's producer actually dun have registered Rx-property */\n\t\t\tipa_rm_tbl[i].rx_bypass_ipa = rx_bypass_ipa;\n\t\t\tIPACMDBG_H(\"Matched RM_table entry: %d's producer_rm1 with non_rx_prop: %d \\n\", i,ipa_rm_tbl[i].rx_bypass_ipa);\n\n\t\t\tif(ipa_rm_tbl[i].consumer1_up == true && ipa_rm_tbl[i].rm_set == false)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"SETUP RM_table entry %d's bi-direction dependency  \\n\", i);\n\t\t\t\t/* add bi-directional dependency*/\n\t\t\t\tif(ipa_rm_tbl[i].rx_bypass_ipa)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Skip ADD entry %d's dependency between WLAN-Pro: %d, Con: %d \\n\", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemset(&dep, 0, sizeof(dep));\n\t\t\t\t\tdep.resource_name = ipa_rm_tbl[i].producer_rm1;\n\t\t\t\t\tdep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;\n\t\t\t\t\tretval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);\n\t\t\t\t\tIPACMDBG_H(\"ADD entry %d's dependency between Pro: %d, Con: %d \\n\", i,dep.resource_name,dep.depends_on_name);\n\t\t\t\t\tif (retval)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \\n\", i,retval);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmemset(&dep, 0, sizeof(dep));\n\t\t\t\tdep.resource_name = ipa_rm_tbl[i].producer_rm2;\n\t\t\t\tdep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;\n\t\t\t\tretval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);\n\t\t\t\tIPACMDBG_H(\"ADD entry %d's dependency between Pro: %d, Con: %d \\n\", i,dep.resource_name,dep.depends_on_name);\n\t\t\t\tif (retval)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d)  \\n\", i,retval);\n\t\t\t\t}\n\t\t\t\tipa_rm_tbl[i].rm_set = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Not SETUP RM_table entry %d: prod_up:%d, cons_up:%d, rm_set: %d \\n\", i,ipa_rm_tbl[i].producer1_up, ipa_rm_tbl[i].consumer1_up, ipa_rm_tbl[i].rm_set);\n\t\t\t}\n\t\t}\n\n\t\tif(rm1 == ipa_rm_tbl[i].consumer_rm1)\n\t\t{\n\t\t\tipa_rm_tbl[i].consumer1_up = true;\n\t\t\tIPACMDBG_H(\"Matched RM_table entry: %d's consumer_rm1 \\n\", i);\n\n\t\t\tif(ipa_rm_tbl[i].producer1_up == true && ipa_rm_tbl[i].rm_set == false)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"SETUP RM_table entry %d's bi-direction dependency  \\n\", i);\n\t\t\t\t/* add bi-directional dependency*/\n\t\t\t\tif(ipa_rm_tbl[i].rx_bypass_ipa)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Skip ADD entry %d's dependency between WLAN-Pro: %d, Con: %d \\n\", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemset(&dep, 0, sizeof(dep));\n\t\t\t\t\tdep.resource_name = ipa_rm_tbl[i].producer_rm1;\n\t\t\t\t\tdep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;\n\t\t\t\t\tretval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);\n\t\t\t\t\tIPACMDBG_H(\"ADD entry %d's dependency between Pro: %d, Con: %d \\n\", i,dep.resource_name,dep.depends_on_name);\n\t\t\t\t\tif (retval)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d)  \\n\", i,retval);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmemset(&dep, 0, sizeof(dep));\n\t\t\t\tdep.resource_name = ipa_rm_tbl[i].producer_rm2;\n\t\t\t\tdep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;\n\t\t\t\tretval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);\n\t\t\t\tIPACMDBG_H(\"ADD entry %d's dependency between Pro: %d, Con: %d \\n\", i,dep.resource_name,dep.depends_on_name);\n\t\t\t\tif (retval)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d)  \\n\", i,retval);\n\t\t\t\t}\n\t\t\t\tipa_rm_tbl[i].rm_set = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Not SETUP RM_table entry %d: prod_up:%d, cons_up:%d, rm_set: %d \\n\", i,ipa_rm_tbl[i].producer1_up, ipa_rm_tbl[i].consumer1_up, ipa_rm_tbl[i].rm_set);\n\t\t\t}\n\t   }\n   }\n   return ;\n}\n\n/* for IPACM resource manager dependency usage\n   delete either Tx or Rx ipa_rm_resource_name */\n\nvoid IPACM_Config::DelRmDepend(ipa_rm_resource_name rm1)\n{\n\tint retval = 0;\n\tstruct ipa_ioc_rm_dependency dep;\n\n\tIPACMDBG_H(\" Got rm del-depend index : %d \\n\", rm1);\n\t/* ipa_rm_a2_check: IPA_RM_RESOURCE_Q6_CONS*/\n\tif(rm1 == IPA_RM_RESOURCE_Q6_CONS)\n\t{\n\t\tipa_rm_a2_check-=1;\n\t\tIPACMDBG_H(\"Left %d times default RT routing from A2 \\n\", ipa_rm_a2_check);\n\t}\n\n\tfor(int i=0;i<IPA_MAX_PRIVATE_SUBNET_ENTRIES;i++)\n\t{\n\n\t\tif(rm1 == ipa_rm_tbl[i].producer_rm1)\n\t\t{\n\t\t\tif(ipa_rm_tbl[i].rm_set == true)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Matched RM_table entry: %d's producer_rm1 and dependency is up \\n\", i);\n\t\t\t\tipa_rm_tbl[i].rm_set = false;\n\n\t\t\t\t/* delete bi-directional dependency*/\n\t\t\t\tif(ipa_rm_tbl[i].rx_bypass_ipa)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Skip DEL entry %d's dependency between WLAN-Pro: %d, Con: %d \\n\", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemset(&dep, 0, sizeof(dep));\n\t\t\t\t\tdep.resource_name = ipa_rm_tbl[i].producer_rm1;\n\t\t\t\t\tdep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;\n\t\t\t\t\tretval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);\n\t\t\t\t\tIPACMDBG_H(\"Delete entry %d's dependency between Pro: %d, Con: %d \\n\", i,dep.resource_name,dep.depends_on_name);\n\t\t\t\t\tif (retval)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \\n\", i,retval);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmemset(&dep, 0, sizeof(dep));\n\t\t\t\tdep.resource_name = ipa_rm_tbl[i].producer_rm2;\n\t\t\t\tdep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;\n\t\t\t\tretval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);\n\t\t\t\tIPACMDBG_H(\"Delete entry %d's dependency between Pro: %d, Con: %d \\n\", i,dep.resource_name,dep.depends_on_name);\n\t\t\t\tif (retval)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \\n\", i,retval);\n\t\t\t\t}\n\t\t\t}\n\t\t\tipa_rm_tbl[i].producer1_up = false;\n\t\t\tipa_rm_tbl[i].rx_bypass_ipa = false;\n\t\t}\n\t\tif(rm1 == ipa_rm_tbl[i].consumer_rm1)\n\t\t{\n\t\t\t/* ipa_rm_a2_check: IPA_RM_RESOURCE_!6_CONS*/\n\t\t\tif(ipa_rm_tbl[i].consumer_rm1 == IPA_RM_RESOURCE_Q6_CONS && ipa_rm_a2_check == 1)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\" still have %d default RT routing from A2 \\n\", ipa_rm_a2_check);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif(ipa_rm_tbl[i].rm_set == true)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Matched RM_table entry: %d's consumer_rm1 and dependency is up \\n\", i);\n\t\t\t\tipa_rm_tbl[i].rm_set = false;\n\t\t\t\t/* delete bi-directional dependency*/\n\t\t\t\tif(ipa_rm_tbl[i].rx_bypass_ipa)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Skip DEL entry %d's dependency between WLAN-Pro: %d, Con: %d \\n\", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemset(&dep, 0, sizeof(dep));\n\t\t\t\t\tdep.resource_name = ipa_rm_tbl[i].producer_rm1;\n\t\t\t\t\tdep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;\n\t\t\t\t\tretval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);\n\t\t\t\t\tIPACMDBG_H(\"Delete entry %d's dependency between Pro: %d, Con: %d \\n\", i,dep.resource_name,dep.depends_on_name);\n\t\t\t\t\tif (retval)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \\n\", i,retval);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmemset(&dep, 0, sizeof(dep));\n\t\t\t\tdep.resource_name = ipa_rm_tbl[i].producer_rm2;\n\t\t\t\tdep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;\n\t\t\t\tretval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);\n\t\t\t\tIPACMDBG_H(\"Delete entry %d's dependency between Pro: %d, Con: %d \\n\", i,dep.resource_name,dep.depends_on_name);\n\t\t\t\tif (retval)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \\n\", i,retval);\n\t\t\t\t}\n\t\t\t}\n\t\t\tipa_rm_tbl[i].consumer1_up = false;\n\t\t}\n\t}\n\treturn ;\n}\n\nint IPACM_Config::SetExtProp(ipa_ioc_query_intf_ext_props *prop)\n{\n\tint i, num;\n\n\tif(prop == NULL || prop->num_ext_props <= 0)\n\t{\n\t\tIPACMERR(\"There is no extended property!\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tnum = prop->num_ext_props;\n\tfor(i=0; i<num; i++)\n\t{\n\t\tif(prop->ext[i].ip == IPA_IP_v4)\n\t\t{\n\t\t\tif(ext_prop_v4.num_ext_props >= MAX_NUM_EXT_PROPS)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"IPv4 extended property table is full!\\n\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmemcpy(&ext_prop_v4.prop[ext_prop_v4.num_ext_props], &prop->ext[i], sizeof(struct ipa_ioc_ext_intf_prop));\n\t\t\text_prop_v4.num_ext_props++;\n\t\t}\n\t\telse if(prop->ext[i].ip == IPA_IP_v6)\n\t\t{\n\t\t\tif(ext_prop_v6.num_ext_props >= MAX_NUM_EXT_PROPS)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"IPv6 extended property table is full!\\n\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmemcpy(&ext_prop_v6.prop[ext_prop_v6.num_ext_props], &prop->ext[i], sizeof(struct ipa_ioc_ext_intf_prop));\n\t\t\text_prop_v6.num_ext_props++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"The IP type is not expected!\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tIPACMDBG_H(\"Set extended property succeeded.\\n\");\n\n\treturn IPACM_SUCCESS;\n}\n\nipacm_ext_prop* IPACM_Config::GetExtProp(ipa_ip_type ip_type)\n{\n\tif(ip_type == IPA_IP_v4)\n\t\treturn &ext_prop_v4;\n\telse if(ip_type == IPA_IP_v6)\n\t\treturn &ext_prop_v6;\n\telse\n\t{\n\t\tIPACMERR(\"Failed to get extended property: the IP version is neither IPv4 nor IPv6!\\n\");\n\t\treturn NULL;\n\t}\n}\n\nint IPACM_Config::DelExtProp(ipa_ip_type ip_type)\n{\n\tif(ip_type != IPA_IP_v6)\n\t{\n\t\tmemset(&ext_prop_v4, 0, sizeof(ext_prop_v4));\n\t}\n\n\tif(ip_type != IPA_IP_v4)\n\t{\n\t\tmemset(&ext_prop_v6, 0, sizeof(ext_prop_v6));\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackClient.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <errno.h>\n#include <arpa/inet.h>\n#include <netinet/in.h>\n#include <sys/ioctl.h>\n#include <net/if.h>\n#include \"IPACM_Iface.h\"\n#include \"IPACM_ConntrackListener.h\"\n#include \"IPACM_ConntrackClient.h\"\n#include \"IPACM_Log.h\"\n\n#define LO_NAME \"lo\"\n\nextern IPACM_EvtDispatcher cm_dis;\nextern void ParseCTMessage(struct nf_conntrack *ct);\n\nIPACM_ConntrackClient *IPACM_ConntrackClient::pInstance = NULL;\nIPACM_ConntrackListener *CtList = NULL;\n\n/* ================================\n\t\t Local Function Definitions\n\t\t =================================\n*/\nIPACM_ConntrackClient::IPACM_ConntrackClient()\n{\n\tIPACMDBG(\"\\n\");\n\n\ttcp_hdl = NULL;\n\tudp_hdl = NULL;\n\ttcp_filter = NULL;\n\tudp_filter = NULL;\n}\n\nIPACM_ConntrackClient* IPACM_ConntrackClient::GetInstance()\n{\n\tif(pInstance == NULL)\n\t{\n\t\tpInstance = new IPACM_ConntrackClient();\n\n\t\tpInstance->udp_filter = nfct_filter_create();\n\t\tif(pInstance->udp_filter == NULL)\n\t\t{\n\t\t\tIPACMERR(\"unable to create UDP filter\\n\");\n\t\t\tdelete pInstance;\n\t\t\treturn NULL;\n\t\t}\n\t\tIPACMDBG(\"Created UDP filter\\n\");\n\n\t\tpInstance->tcp_filter = nfct_filter_create();\n\t\tif(pInstance->tcp_filter == NULL)\n\t\t{\n\t\t\tIPACMERR(\"unable to create TCP filter\\n\");\n\t\t\tdelete pInstance;\n\t\t\treturn NULL;\n\t\t}\n\t\tIPACMDBG(\"Created TCP filter\\n\");\n\t}\n\n\treturn pInstance;\n}\n\nint IPACM_ConntrackClient::IPAConntrackEventCB\n(\n\t enum nf_conntrack_msg_type type,\n\t struct nf_conntrack *ct,\n\t void *data\n\t )\n{\n\tipacm_cmd_q_data evt_data;\n\tipacm_ct_evt_data *ct_data;\n\tuint8_t ip_type = 0;\n\n\tIPACMDBG(\"Event callback called with msgtype: %d\\n\",type);\n\n\t/* Retrieve ip type */\n\tip_type = nfct_get_attr_u8(ct, ATTR_REPL_L3PROTO);\n\n#ifndef CT_OPT\n\tif(AF_INET6 == ip_type)\n\t{\n\t\tIPACMDBG(\"Ignoring ipv6(%d) connections\\n\", ip_type);\n\t\tgoto IGNORE;\n\t}\n\n#endif\n\n\tct_data = (ipacm_ct_evt_data *)malloc(sizeof(ipacm_ct_evt_data));\n\tif(ct_data == NULL)\n\t{\n\t\tIPACMERR(\"unable to allocate memory \\n\");\n\t\tgoto IGNORE;\n\t}\n\n\tct_data->ct = ct;\n\tct_data->type = type;\n\n\tevt_data.event = IPA_PROCESS_CT_MESSAGE;\n\tevt_data.evt_data = (void *)ct_data;\n\n#ifdef CT_OPT\n\tif(AF_INET6 == ip_type)\n\t{\n\t\tevt_data.event = IPA_PROCESS_CT_MESSAGE_V6;\n\t}\n#endif\n\n\tif(0 != IPACM_EvtDispatcher::PostEvt(&evt_data))\n\t{\n\t\tIPACMERR(\"Error sending Conntrack message to processing thread!\\n\");\n\t\tfree(ct_data);\n\t\tgoto IGNORE;\n\t}\n\n/* NFCT_CB_STOLEN means that the conntrack object is not released after the\n\t callback That must be manually done later when the object is no longer needed. */\n\treturn NFCT_CB_STOLEN;\n\nIGNORE:\n\tnfct_destroy(ct);\n\treturn NFCT_CB_STOLEN;\n\n}\n\nint IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Bridge_Addrs\n(\n\t struct nfct_filter *filter\n)\n{\n\tint fd;\n\tfd = socket(AF_INET, SOCK_DGRAM, 0);\n\tif(fd < 0)\n\t{\n\t\tPERROR(\"unable to open socket\");\n\t\treturn -1;\n\t}\n\n\tint ret;\n\tuint32_t ipv4_addr;\n\tstruct ifreq ifr;\n\n\t/* retrieve bridge interface ipv4 address */\n\tmemset(&ifr, 0, sizeof(struct ifreq));\n\tifr.ifr_addr.sa_family = AF_INET;\n\t(void)strncpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name));\n\tIPACMDBG(\"bridge interface name (%s)\\n\", ifr.ifr_name);\n\n\tret = ioctl(fd, SIOCGIFADDR, &ifr);\n\tif (ret < 0)\n\t{\n\t\tIPACMERR(\"unable to retrieve (%s) interface address\\n\",ifr.ifr_name);\n\t\tclose(fd);\n\t\treturn -1;\n\t}\n\tIPACMDBG(\"Interface (%s) address %s\\n\", ifr.ifr_name, inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));\n\tipv4_addr = ntohl(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr);\n\tclose(fd);\n\n\t/* ignore whatever is destined to or originates from broadcast ip address */\n\tstruct nfct_filter_ipv4 filter_ipv4;\n\n\tfilter_ipv4.addr = ipv4_addr;\n\tfilter_ipv4.mask = 0xffffffff;\n\n\tnfct_filter_set_logic(filter,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_DST_IPV4,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_NEGATIVE);\n\n\tnfct_filter_add_attr(filter, NFCT_FILTER_DST_IPV4, &filter_ipv4);\n\n\tnfct_filter_set_logic(filter,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_SRC_IPV4,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_NEGATIVE);\n\n\tnfct_filter_add_attr(filter, NFCT_FILTER_SRC_IPV4, &filter_ipv4);\n\n  return 0;\n}\n\nint IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Local_Iface\n(\n\t struct nfct_filter *filter,\n\t ipacm_event_iface_up *param\n)\n{\n\tstruct nfct_filter_ipv4 filter_ipv4;\n\n\tfilter_ipv4.addr = param->ipv4_addr;\n\tfilter_ipv4.mask = 0xffffffff;\n\n\t/* ignore whatever is destined to local interfaces */\n\tIPACMDBG(\"Ignore connections destinated to interface %s\", param->ifname);\n\tiptodot(\"with ipv4 address\", param->ipv4_addr);\n\tnfct_filter_set_logic(filter,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_DST_IPV4,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_NEGATIVE);\n\n\tnfct_filter_add_attr(filter, NFCT_FILTER_DST_IPV4, &filter_ipv4);\n\n\tIPACMDBG(\"Ignore connections orignated from interface %s\", param->ifname);\n\tiptodot(\"with ipv4 address\", filter_ipv4.addr);\n\tnfct_filter_set_logic(filter,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_SRC_IPV4,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_NEGATIVE);\n\n\tnfct_filter_add_attr(filter, NFCT_FILTER_SRC_IPV4, &filter_ipv4);\n\n\t/* Retrieve broadcast address */\n\t/* Intialize with 255.255.255.255 */\n\tuint32_t bc_ip_addr = 0xFFFFFFFF;\n\n\t/* calculate broadcast address from addr and addr_mask */\n\tbc_ip_addr = (bc_ip_addr & (~param->addr_mask));\n\tbc_ip_addr = (bc_ip_addr | (param->ipv4_addr & param->addr_mask));\n\n\t/* netfitler expecting in host-byte order */\n\tfilter_ipv4.addr = bc_ip_addr;\n\tfilter_ipv4.mask = 0xffffffff;\n\n\tiptodot(\"with broadcast address\", filter_ipv4.addr);\n\tnfct_filter_set_logic(filter,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_DST_IPV4,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_NEGATIVE);\n\n\tnfct_filter_add_attr(filter, NFCT_FILTER_DST_IPV4, &filter_ipv4);\n\n\treturn 0;\n}\n\n/* Function which sets up filters to ignore\n\t\t connections to and from local interfaces */\nint IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Local_Addrs\n(\n\t struct nfct_filter *filter\n)\n{\n\tstruct nfct_filter_ipv4 filter_ipv4;\n\n\t/* ignore whatever is destined to or originates from broadcast ip address */\n\tfilter_ipv4.addr = 0xffffffff;\n\tfilter_ipv4.mask = 0xffffffff;\n\n\tnfct_filter_set_logic(filter,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_DST_IPV4,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_NEGATIVE);\n\n\tnfct_filter_add_attr(filter, NFCT_FILTER_DST_IPV4, &filter_ipv4);\n\n\tnfct_filter_set_logic(filter,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_SRC_IPV4,\n\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_NEGATIVE);\n\n\tnfct_filter_add_attr(filter, NFCT_FILTER_SRC_IPV4, &filter_ipv4);\n\n\treturn 0;\n} /* IPA_Conntrack_Filters_Ignore_Local_Addrs() */\n\n/* Initialize TCP Filter */\nint IPACM_ConntrackClient::IPA_Conntrack_TCP_Filter_Init(void)\n{\n\tint ret = 0;\n\tIPACM_ConntrackClient *pClient;\n\n\tIPACMDBG(\"\\n\");\n\n\tpClient = IPACM_ConntrackClient::GetInstance();\n\tif(pClient == NULL)\n\t{\n\t\tIPACMERR(\"unable to get conntrack client instance\\n\");\n\t\treturn -1;\n\t}\n\n\tret = nfct_filter_set_logic(pClient->tcp_filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_L4PROTO,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_POSITIVE);\n\tif(ret == -1)\n\t{\n\t\tIPACMERR(\"Unable to set filter logic\\n\");\n\t\treturn -1;\n\t}\n\n\t/* set protocol filters as tcp and udp */\n\tnfct_filter_add_attr_u32(pClient->tcp_filter, NFCT_FILTER_L4PROTO, IPPROTO_TCP);\n\n\n\tstruct nfct_filter_proto tcp_proto_state;\n\ttcp_proto_state.proto = IPPROTO_TCP;\n\ttcp_proto_state.state = TCP_CONNTRACK_ESTABLISHED;\n\n\tret = nfct_filter_set_logic(pClient->tcp_filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_L4PROTO_STATE,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_POSITIVE);\n\tif(ret == -1)\n\t{\n\t\tIPACMERR(\"unable to set filter logic\\n\");\n\t\treturn -1;\n\t}\n\tnfct_filter_add_attr(pClient->tcp_filter,\n\t\t\t\t\t\t\t\t\t\t\t NFCT_FILTER_L4PROTO_STATE,\n\t\t\t\t\t\t\t\t\t\t\t &tcp_proto_state);\n\n\n\ttcp_proto_state.proto = IPPROTO_TCP;\n\ttcp_proto_state.state = TCP_CONNTRACK_FIN_WAIT;\n\tret = nfct_filter_set_logic(pClient->tcp_filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_L4PROTO_STATE,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_POSITIVE);\n\tif(ret == -1)\n\t{\n\t\tIPACMERR(\"unable to set filter logic\\n\");\n\t\treturn -1;\n\t}\n\n\tnfct_filter_add_attr(pClient->tcp_filter,\n\t\t\t\t\t\t\t\t\t\t\t NFCT_FILTER_L4PROTO_STATE,\n\t\t\t\t\t\t\t\t\t\t\t &tcp_proto_state);\n\treturn 0;\n}\n\n\n/* Initialize UDP Filter */\nint IPACM_ConntrackClient::IPA_Conntrack_UDP_Filter_Init(void)\n{\n\tint ret = 0;\n\tIPACM_ConntrackClient *pClient = IPACM_ConntrackClient::GetInstance();\n\tif(pClient == NULL)\n\t{\n\t\tIPACMERR(\"unable to get conntrack client instance\\n\");\n\t\treturn -1;\n\t}\n\n\tret = nfct_filter_set_logic(pClient->udp_filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_L4PROTO,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNFCT_FILTER_LOGIC_POSITIVE);\n\tif(ret == -1)\n\t{\n\t\tIPACMERR(\"unable to set filter logic\\n\");\n\t}\n\t/* set protocol filters as tcp and udp */\n\tnfct_filter_add_attr_u32(pClient->udp_filter, NFCT_FILTER_L4PROTO, IPPROTO_UDP);\n\n\treturn 0;\n}\n\nvoid* IPACM_ConntrackClient::UDPConnTimeoutUpdate(void *ptr)\n{\n\n\tNatApp *nat_inst = NULL;\n#ifdef IPACM_DEBUG\n\tIPACMDBG(\"\\n\");\n#endif\n\n\tnat_inst = NatApp::GetInstance();\n\tif(nat_inst == NULL)\n\t{\n\t\tIPACMERR(\"unable to create nat instance\\n\");\n\t\treturn NULL;\n\t}\n\n\twhile(1)\n\t{\n\t\tnat_inst->UpdateUDPTimeStamp();\n\t\tsleep(UDP_TIMEOUT_UPDATE);\n\t} /* end of while(1) loop */\n\n#ifdef IPACM_DEBUG\n\tIPACMDBG(\"Returning from %s() %d\\n\", __FUNCTION__, __LINE__);\n#endif\n\n\treturn NULL;\n}\n\n/* Thread to initialize TCP Conntrack Filters*/\nvoid* IPACM_ConntrackClient::TCPRegisterWithConnTrack(void *)\n{\n\tint ret;\n\tIPACM_ConntrackClient *pClient;\n\tunsigned subscrips = 0;\n\n\tIPACMDBG(\"\\n\");\n\n\tpClient = IPACM_ConntrackClient::GetInstance();\n\tif(pClient == NULL)\n\t{\n\t\tIPACMERR(\"unable to get conntrack client instance\\n\");\n\t\treturn NULL;\n\t}\n\n\tsubscrips = (NF_NETLINK_CONNTRACK_UPDATE | NF_NETLINK_CONNTRACK_DESTROY);\n#ifdef CT_OPT\n\tsubscrips |= NF_NETLINK_CONNTRACK_NEW;\n#endif\n\n\tpClient->tcp_hdl = nfct_open(CONNTRACK, subscrips);\n\tif(pClient->tcp_hdl == NULL)\n\t{\n\t\tPERROR(\"nfct_open\\n\");\n\t\treturn NULL;\n\t}\n\n\t/* Initialize the filter */\n\tret = IPA_Conntrack_TCP_Filter_Init();\n\tif(ret == -1)\n\t{\n\t\tIPACMERR(\"Unable to initliaze TCP Filter\\n\");\n\t\treturn NULL;\n\t}\n\n\t/* Attach the filter to net filter handler */\n\tret = nfct_filter_attach(nfct_fd(pClient->tcp_hdl), pClient->tcp_filter);\n\tif(ret == -1)\n\t{\n\t\tIPACMDBG(\"unable to attach TCP filter\\n\");\n\t\treturn NULL;\n\t}\n\n\t/* Register callback with netfilter handler */\n\tIPACMDBG(\"tcp handle:%p, fd:%d\\n\", pClient->tcp_hdl, nfct_fd(pClient->tcp_hdl));\n#ifndef CT_OPT\n\tnfct_callback_register(pClient->tcp_hdl,\n\t\t\t(nf_conntrack_msg_type)\t(NFCT_T_UPDATE | NFCT_T_DESTROY | NFCT_T_NEW),\n\t\t\t\t\t\tIPAConntrackEventCB, NULL);\n#else\n\tnfct_callback_register(pClient->tcp_hdl, (nf_conntrack_msg_type) NFCT_T_ALL, IPAConntrackEventCB, NULL);\n#endif\n\n\t/* Block to catch events from net filter connection track */\n\t/* nfct_catch() receives conntrack events from kernel-space, by default it\n\t\t\t blocks waiting for events. */\n\tIPACMDBG(\"Waiting for events\\n\");\n\n\tret = nfct_catch(pClient->tcp_hdl);\n\tif(ret == -1)\n\t{\n\t\tIPACMERR(\"(%d)(%s)\\n\", ret, strerror(errno));\n\t\treturn NULL;\n\t}\n\n\tIPACMDBG(\"Exit from tcp thread\\n\");\n\n\t/* destroy the filter.. this will not detach the filter */\n\tnfct_filter_destroy(pClient->tcp_filter);\n\tpClient->tcp_filter = NULL;\n\n\t/* de-register the callback */\n\tnfct_callback_unregister(pClient->tcp_hdl);\n\t/* close the handle */\n\tnfct_close(pClient->tcp_hdl);\n  pClient->tcp_hdl = NULL;\n\n\tpthread_exit(NULL);\n\treturn NULL;\n}\n\n/* Thread to initialize UDP Conntrack Filters*/\nvoid* IPACM_ConntrackClient::UDPRegisterWithConnTrack(void *)\n{\n\tint ret;\n\tIPACM_ConntrackClient *pClient = NULL;\n\n\tIPACMDBG(\"\\n\");\n\n\tpClient = IPACM_ConntrackClient::GetInstance();\n\tif(pClient == NULL)\n\t{\n\t\tIPACMERR(\"unable to retrieve instance of conntrack client\\n\");\n\t\treturn NULL;\n\t}\n\n\tpClient->udp_hdl = nfct_open(CONNTRACK,\n\t\t\t\t\t(NF_NETLINK_CONNTRACK_NEW | NF_NETLINK_CONNTRACK_DESTROY));\n\tif(pClient->udp_hdl == NULL)\n\t{\n\t\tPERROR(\"nfct_open\\n\");\n\t\treturn NULL;\n\t}\n\n\t/* Initialize Filter */\n\tret = IPA_Conntrack_UDP_Filter_Init();\n\tif(-1 == ret)\n\t{\n\t\tIPACMDBG(\"Unable to initalize udp filters\\n\");\n\t\treturn NULL;\n\t}\n\n\t/* Attach the filter to net filter handler */\n\tret = nfct_filter_attach(nfct_fd(pClient->udp_hdl), pClient->udp_filter);\n\tif(ret == -1)\n\t{\n\t\tIPACMDBG(\"unable to attach the filter\\n\");\n\t\treturn NULL;\n\t}\n\n\t/* Register callback with netfilter handler */\n\tIPACMDBG(\"udp handle:%p, fd:%d\\n\", pClient->udp_hdl, nfct_fd(pClient->udp_hdl));\n\tnfct_callback_register(pClient->udp_hdl,\n\t\t\t\t\t\t\t\t\t\t\t\t (nf_conntrack_msg_type)(NFCT_T_NEW | NFCT_T_DESTROY),\n\t\t\t\t\t\t\t\t\t\t\t\t IPAConntrackEventCB,\n\t\t\t\t\t\t\t\t\t\t\t\t NULL);\n\n\t/* Block to catch events from net filter connection track */\nctcatch:\n\tret = nfct_catch(pClient->udp_hdl);\n\tif(ret == -1)\n\t{\n\t\tIPACMDBG(\"(%d)(%s)\\n\", ret, strerror(errno));\n\t\treturn NULL;\n\t}\n\telse\n\t{\n\t\tIPACMDBG(\"ctcatch ret:%d\\n\", ret);\n\t\tgoto ctcatch;\n\t}\n\n\tIPACMDBG(\"Exit from udp thread with ret: %d\\n\", ret);\n\n\t/* destroy the filter.. this will not detach the filter */\n\tnfct_filter_destroy(pClient->udp_filter);\n\tpClient->udp_filter = NULL;\n\n\t/* de-register the callback */\n\tnfct_callback_unregister(pClient->udp_hdl);\n\t/* close the handle */\n\tnfct_close(pClient->udp_hdl);\n\tpClient->udp_hdl = NULL;\n\n\tpthread_exit(NULL);\n\treturn NULL;\n}\n\nvoid IPACM_ConntrackClient::UpdateUDPFilters(void *param, bool isWan)\n{\n\tstatic bool isIgnore = false;\n\tint ret = 0;\n\tIPACM_ConntrackClient *pClient = NULL;\n\n\tpClient = IPACM_ConntrackClient::GetInstance();\n\tif(pClient == NULL)\n\t{\n\t\tIPACMERR(\"unable to retrieve conntrack client instance\\n\");\n\t\treturn;\n\t}\n\n\tif(pClient->udp_filter == NULL)\n\t{\n\t\t return;\n\t}\n\n\tif(!isWan)\n\t{\n\t\tIPA_Conntrack_Filters_Ignore_Local_Iface(pClient->udp_filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (ipacm_event_iface_up *)param);\n\n\t\tif(!isIgnore)\n\t\t{\n\t\t\tIPA_Conntrack_Filters_Ignore_Bridge_Addrs(pClient->udp_filter);\n\t\t\tIPA_Conntrack_Filters_Ignore_Local_Addrs(pClient->udp_filter);\n\t\t\tisIgnore = true;\n\t\t}\n\t}\n\n\t/* Attach the filter to udp handle */\n\tif(pClient->udp_hdl != NULL)\n\t{\n\t\tIPACMDBG(\"attaching the filter to udp handle\\n\");\n\t\tret = nfct_filter_attach(nfct_fd(pClient->udp_hdl), pClient->udp_filter);\n\t\tif(ret == -1)\n\t\t{\n\t\t\tPERROR(\"unable to attach the filter to udp handle\\n\");\n\t\t\tIPACMERR(\"udp handle:%p, fd:%d Error: %d\\n\",pClient->udp_hdl, nfct_fd(pClient->udp_hdl), ret);\n\t\t\treturn;\n\t\t}\n\t}\n\n\treturn;\n}\n\nvoid IPACM_ConntrackClient::UpdateTCPFilters(void *param, bool isWan)\n{\n\tstatic bool isIgnore = false;\n\tint ret = 0;\n\tIPACM_ConntrackClient *pClient = NULL;\n\n\tpClient = IPACM_ConntrackClient::GetInstance();\n\tif(pClient == NULL)\n\t{\n\t\tIPACMERR(\"unable to retrieve conntrack client instance\\n\");\n\t\treturn;\n\t}\n\n\tif(pClient->tcp_filter == NULL)\n\t\treturn;\n\n\tif(!isWan)\n\t{\n\t\tIPA_Conntrack_Filters_Ignore_Local_Iface(pClient->tcp_filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(ipacm_event_iface_up *)param);\n\n\t\tif(!isIgnore)\n\t\t{\n\t\t\tIPA_Conntrack_Filters_Ignore_Bridge_Addrs(pClient->udp_filter);\n\t\t\tIPA_Conntrack_Filters_Ignore_Local_Addrs(pClient->udp_filter);\n\t\t\tisIgnore = true;\n\t\t}\n\t}\n\n\t/* Attach the filter to tcp handle */\n\tif(pClient->tcp_hdl != NULL)\n\t{\n\t\tIPACMDBG(\"attaching the filter to tcp handle\\n\");\n\t\tret = nfct_filter_attach(nfct_fd(pClient->tcp_hdl), pClient->tcp_filter);\n\t\tif(ret == -1)\n\t\t{\n\t\t\tPERROR(\"unable to attach the filter to tcp handle\\n\");\n\t\t\tIPACMERR(\"tcp handle:%p, fd:%d Error: %d\\n\",pClient->tcp_hdl, nfct_fd(pClient->tcp_hdl), ret);\n\t\t\treturn;\n\t\t}\n\t}\n\n  return;\n}\n\nvoid IPACM_ConntrackClient::Read_TcpUdp_Timeout(char *in, int len)\n{\n\tint proto;\n\tFILE *fd = NULL;\n\tchar to_str[10];\n\tuint32_t value;\n\tNatApp *nat_inst = NULL;\n\n\tnat_inst = NatApp::GetInstance();\n\tif(nat_inst == NULL)\n\t{\n\t\tIPACMERR(\"unable to create nat instance\\n\");\n\t\treturn;\n\t}\n\n\tif(!strncmp(in, IPACM_TCP_FILE_NAME, len))\n\t{\n\t\tproto = IPPROTO_TCP;\n\t}\n\telse if(!strncmp(in, IPACM_UDP_FILE_NAME, len))\n\t{\n\t\tproto = IPPROTO_UDP;\n\t}\n\telse\n\t{\n\t\treturn;\n\t}\n\n\tif(proto == IPPROTO_TCP)\n\t{\n\t\tfd = fopen(IPACM_TCP_FULL_FILE_NAME, \"r\");\n\t}\n\telse\n\t{\n\t\tfd = fopen(IPACM_UDP_FULL_FILE_NAME, \"r\");\n\t}\n\tif(fd == NULL)\n\t{\n\t\tPERROR(\"unable to open file\");\n\t\treturn;\n\t}\n\n\tfgets(to_str, sizeof(to_str), fd);\n\tvalue = atoi(to_str);\n\tIPACMDBG(\"Protocol %d file \\\"%s\\\" value: %d\\n\", proto, in, value);\n\tnat_inst->UpdateTcpUdpTo(value, proto);\n\n\tfclose(fd);\n\treturn;\n}\n\nvoid *IPACM_ConntrackClient::TCPUDP_Timeout_monitor(void *)\n{\n  int length;\n\tint wd;\n\tchar buffer[INOTIFY_BUFFER_LEN];\n\tint inotify_fd;\n\tuint32_t mask = IN_MODIFY;\n\tFILE *to_fd = NULL;\n\tchar to_str[10];\n\tuint32_t value=0;\n\tNatApp *nat_inst = NULL;\n\n\tnat_inst = NatApp::GetInstance();\n\tif(nat_inst == NULL)\n\t{\n\t\tIPACMERR(\"unable to create nat instance\\n\");\n\t\treturn NULL;\n\t}\n\n\tto_fd = fopen(IPACM_TCP_FULL_FILE_NAME, \"r\");\n\tif(to_fd == NULL)\n\t{\n\t  PERROR(\"unable to open file \\\"ip_conntrack_tcp_timeout_established\\\" \");\n\t\treturn NULL;\n\t}\n\tmemset(to_str, 0, sizeof(to_str));\n\tfgets(to_str, sizeof(to_str), to_fd);\n\tvalue = atoi(to_str);\n\tIPACMDBG(\"ip conntrack tcp timeout initial value:%d\\n\", value);\n\tnat_inst->UpdateTcpUdpTo(value, IPPROTO_TCP);\n\tfclose(to_fd);\n\n\tto_fd = fopen(IPACM_UDP_FULL_FILE_NAME, \"r\");\n\tif(to_fd == NULL)\n\t{\n\t  PERROR(\"unable to open file \\\"ip_conntrack_udp_timeout_stream\\\" \");\n\t\treturn NULL;\n\t}\n\tmemset(to_str, 0, sizeof(to_str));\n\tfgets(to_str, sizeof(to_str), to_fd);\n\tvalue = atoi(to_str);\n\tIPACMDBG(\"ip conntrack udp timeout:%d\\n\", value);\n\tnat_inst->UpdateTcpUdpTo(value, IPPROTO_UDP);\n\tfclose(to_fd);\n\n\tinotify_fd = inotify_init();\n\tif (inotify_fd < 0)\n\t{\n\t\tPERROR(\"inotify_init\");\n\t\treturn NULL;\n\t}\n\n\tIPACMDBG(\"Waiting for nofications in dir %s with mask: 0x%x\\n\",\n\t\t\t\t\t              IPACM_TCP_UDP_DIR_NAME, mask);\n\n\twd = inotify_add_watch(inotify_fd,\n\t\t\t\t\t\t\t\t\t\t\t\t IPACM_TCP_UDP_DIR_NAME,\n\t\t\t\t\t\t\t\t\t\t\t\t mask);\n\n\twhile (1)\n\t{\n\t\tlength = read(inotify_fd, buffer, INOTIFY_BUFFER_LEN);\n\t\tstruct inotify_event *event = (struct inotify_event *)buffer;\n\n\t\tif (length < 0)\n\t\t{\n\t\t\tIPACMERR(\"inotify read() error return length: %d and mask: 0x%x 0x%x\\n\",\n\t\t\t\t\t\t\t         length, event->mask, mask);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif( (event->len > 0) && (event->mask & IN_MODIFY) )\n\t\t{\n\t\t\tif(!(event->mask & IN_ISDIR))\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Received inotify event for file %s with mask %x value\",\n\t\t\t\t\t\t\t\t       event->name, event->mask);\n\t\t\t\tRead_TcpUdp_Timeout(event->name, event->len);\n\t\t\t}\n\t\t}\n\t}\n\n\t(void)inotify_rm_watch(inotify_fd, wd);\n\t(void)close(inotify_fd);\n\treturn NULL;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackListener.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include <sys/ioctl.h>\n#include <net/if.h>\n\n#include \"IPACM_ConntrackListener.h\"\n#include \"IPACM_ConntrackClient.h\"\n#include \"IPACM_EvtDispatcher.h\"\n\nIPACM_ConntrackListener::IPACM_ConntrackListener()\n{\n\t IPACMDBG(\"\\n\");\n\n\t isNatThreadStart = false;\n\t isCTReg = false;\n\t WanUp = false;\n\t nat_inst = NatApp::GetInstance();\n\n\t NatIfaceCnt = 0;\n\t StaClntCnt = 0;\n\t pNatIfaces = NULL;\n\t pConfig = NULL;\n\n\t memset(nat_iface_ipv4_addr, 0, sizeof(nat_iface_ipv4_addr));\n\t memset(nonnat_iface_ipv4_addr, 0, sizeof(nonnat_iface_ipv4_addr));\n\t memset(sta_clnt_ipv4_addr, 0, sizeof(sta_clnt_ipv4_addr));\n\n\t IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, this);\n\t IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, this);\n\t IPACM_EvtDispatcher::registr(IPA_PROCESS_CT_MESSAGE, this);\n\t IPACM_EvtDispatcher::registr(IPA_PROCESS_CT_MESSAGE_V6, this);\n\t IPACM_EvtDispatcher::registr(IPA_HANDLE_WLAN_UP, this);\n\t IPACM_EvtDispatcher::registr(IPA_HANDLE_LAN_UP, this);\n\n#ifdef CT_OPT\n\t p_lan2lan = IPACM_LanToLan::getLan2LanInstance();\n#endif\n}\n\nvoid IPACM_ConntrackListener::event_callback(ipa_cm_event_id evt,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t void *data)\n{\n\t ipacm_event_iface_up *wan_down = NULL;\n\n\t if(data == NULL)\n\t {\n\t\t IPACMERR(\"Invalid Data\\n\");\n\t\t return;\n\t }\n\n\t switch(evt)\n\t {\n\t case IPA_PROCESS_CT_MESSAGE:\n\t\t\tIPACMDBG(\"Received IPA_PROCESS_CT_MESSAGE event\\n\");\n\t\t\tProcessCTMessage(data);\n\t\t\tbreak;\n\n#ifdef CT_OPT\n\t case IPA_PROCESS_CT_MESSAGE_V6:\n\t\t\tIPACMDBG(\"Received IPA_PROCESS_CT_MESSAGE_V6 event\\n\");\n\t\t\tProcessCTV6Message(data);\n\t\t\tbreak;\n#endif\n\n\t case IPA_HANDLE_WAN_UP:\n\t\t\tIPACMDBG(\"Received IPA_HANDLE_WAN_UP event\\n\");\n\t\t\tCreateConnTrackThreads();\n\t\t\tif(!isWanUp())\n\t\t\t{\n\t\t\t\tTriggerWANUp(data);\n\t\t\t}\n\t\t\tbreak;\n\n\t case IPA_HANDLE_WAN_DOWN:\n\t\t\tIPACMDBG(\"Received IPA_HANDLE_WAN_DOWN event\\n\");\n\t\t\twan_down = (ipacm_event_iface_up *)data;\n\t\t\tif(isWanUp())\n\t\t\t{\n\t\t\t\tTriggerWANDown(wan_down->ipv4_addr);\n\t\t\t}\n\t\t\tbreak;\n\n\t/* if wlan or lan comes up after wan interface, modify\n\t\t tcp/udp filters to ignore local wlan or lan connections */\n\t case IPA_HANDLE_WLAN_UP:\n\t case IPA_HANDLE_LAN_UP:\n\t\t\tIPACMDBG(\"Received event: %d with ifname: %s and address: 0x%x\\n\",\n\t\t\t\t\t\t\t evt, ((ipacm_event_iface_up *)data)->ifname,\n\t\t\t\t\t\t\t ((ipacm_event_iface_up *)data)->ipv4_addr);\n\t\t\tCreateConnTrackThreads();\n\t\t\tIPACM_ConntrackClient::UpdateUDPFilters(data, false);\n\t\t\tIPACM_ConntrackClient::UpdateTCPFilters(data, false);\n\t\t\tbreak;\n\n\t default:\n\t\t\tIPACMDBG(\"Ignore cmd %d\\n\", evt);\n\t\t\tbreak;\n\t }\n}\nvoid IPACM_ConntrackListener::HandleNeighIpAddrAddEvt(ipacm_event_data_all *data)\n{\n\tint fd = 0, len = 0, cnt, i, j;\n\tstruct ifreq ifr;\n\tbool isNatIface = false;\n\n\tif(data->ipv4_addr == 0 || data->iptype != IPA_IP_v4)\n\t{\n\t\tIPACMDBG(\"Ignoring IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT EVENT\\n\");\n\t\treturn;\n\t}\n\n  IPACMDBG(\"\\n\");\n\tIPACMDBG(\"Received interface index %d with ip type: %d\", data->if_index, data->iptype);\n\tiptodot(\" and ipv4 address\", data->ipv4_addr);\n\n\tif(pConfig == NULL)\n\t{\n\t\tpConfig = IPACM_Config::GetInstance();\n\t\tif(pConfig == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to get Config instance\\n\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\n\tcnt = pConfig->GetNatIfacesCnt();\n\t\tNatIfaceCnt = cnt;\n\t\tif(pNatIfaces != NULL)\n\t\t{\n\t\t\tfree(pNatIfaces);\n\t\t\tpNatIfaces = NULL;\n\t\t}\n\n\t\tlen = (sizeof(NatIfaces) * NatIfaceCnt);\n\t\tpNatIfaces = (NatIfaces *)malloc(len);\n\t\tif(pNatIfaces == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to allocate memory for non nat ifaces\\n\");\n\t\t\treturn;\n\t\t}\n\t\tmemset(pNatIfaces, 0, len);\n\n\t\tif(pConfig->GetNatIfaces(NatIfaceCnt, pNatIfaces) != 0)\n\t\t{\n\t\t\tIPACMERR(\"Unable to retrieve non nat ifaces\\n\");\n\t\t\treturn;\n\t\t}\n  IPACMDBG(\"Update %d Nat ifaces\\n\", NatIfaceCnt);\n\n\n\t/* Search/Configure linux interface-index and map it to IPA interface-index */\n\tif((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)\n\t{\n\t\tPERROR(\"get interface name socket create failed\");\n\t\treturn;\n\t}\n\n\tmemset(&ifr, 0, sizeof(struct ifreq));\n\tifr.ifr_ifindex = data->if_index;\n\n\tif(ioctl(fd, SIOCGIFNAME, &ifr) < 0)\n\t{\n\t\tPERROR(\"call_ioctl_on_dev: ioctl failed:\");\n\t\tclose(fd);\n\t\treturn;\n\t}\n\tclose(fd);\n\n\tfor(i = 0; i < NatIfaceCnt; i++)\n\t{\n\t\tif(strncmp(ifr.ifr_name,\n\t\t\t\t\t\t\t pNatIfaces[i].iface_name,\n\t\t\t\t\t\t\t sizeof(pNatIfaces[i].iface_name)) == 0)\n\t\t{\n\t\t\t/* copy the ipv4 address to filter out downlink connections\n\t\t\t\t ignore downlink after listening connection event from\n\t\t\t\t conntrack as it is not destinated to private ip address */\n\t\t\tIPACMDBG(\"Interface (%s) is nat\\n\", ifr.ifr_name);\n\t\t\tfor(j = 0; j < MAX_NAT_IFACES; j++)\n\t\t\t{\n\t\t\t\t/* check if duplicate NAT ip */\n\t\t\t\tif(nat_iface_ipv4_addr[j] == data->ipv4_addr)\n\t\t\t\t\tbreak;\n\n\t\t\t\tif(nat_iface_ipv4_addr[j] == 0)\n\t\t\t\t{\n\t\t\t\t\tnat_iface_ipv4_addr[j] = data->ipv4_addr;\n\t\t\t\t\tnat_inst->ResetPwrSaveIf(data->ipv4_addr);\n\t\t\t\t\tnat_inst->FlushTempEntries(data->ipv4_addr, true);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(j == MAX_NAT_IFACES)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Nat ifaces(%d) exceed maximum\\n\", j);\n\t\t\t\tbreak;\n\t\t\t}\n\n\n\t\t\tisNatIface = true;\n\t\t\tIPACMDBG(\"Nating connections of Interface (%s), entry (%d) \", pNatIfaces[i].iface_name, j);\n\t\t\tiptodot(\"with ipv4 address\", nat_iface_ipv4_addr[j]);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* Cache the non nat iface ip address */\n\tif(isNatIface != true)\n\t{\n\t\tfor(i = 0; i < MAX_NAT_IFACES; i++)\n\t\t{\n\t\t\tif(nonnat_iface_ipv4_addr[i] == 0)\n\t\t\t{\n\t\t\t\tnonnat_iface_ipv4_addr[i] = data->ipv4_addr;\n\t\t\t\tnat_inst->FlushTempEntries(data->ipv4_addr, false);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n}\n\nvoid IPACM_ConntrackListener::HandleNeighIpAddrDelEvt(uint32_t ipv4_addr)\n{\n\tint cnt;\n\n\tif(ipv4_addr == 0)\n\t{\n\t\tIPACMDBG(\"Ignoring IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT EVENT\\n\");\n\t\treturn;\n\t}\n\n  IPACMDBG(\"\\n\");\n  iptodot(\"Received ip addr\", ipv4_addr);\n\tIPACMDBG(\"Entering NAT entry deletion checking\\n\");\n\n\tfor(cnt = 0; cnt<MAX_NAT_IFACES; cnt++)\n\t{\n\t\tif(nat_iface_ipv4_addr[cnt] == ipv4_addr)\n\t\t{\n\t\t\tIPACMDBG(\"Reseting ct nat iface, entry (%d) \", cnt);\n\t\t\tiptodot(\"with ipv4 address\", nat_iface_ipv4_addr[cnt]);\n\t\t\tnat_iface_ipv4_addr[cnt] = 0;\n\t\t}\n\n\t\tif(nonnat_iface_ipv4_addr[cnt] == ipv4_addr)\n\t\t{\n\t\t\tIPACMDBG(\"Reseting ct filters, entry (%d) \", cnt);\n\t\t\tiptodot(\"with ipv4 address\", nonnat_iface_ipv4_addr[cnt]);\n\t\t\tnonnat_iface_ipv4_addr[cnt] = 0;\n\t\t}\n\t}\n\n\tnat_inst->FlushTempEntries(ipv4_addr, false);\n  nat_inst->DelEntriesOnClntDiscon(ipv4_addr);\n\treturn;\n}\n\nvoid IPACM_ConntrackListener::TriggerWANUp(void *in_param)\n{\n\t ipacm_event_iface_up *wanup_data = (ipacm_event_iface_up *)in_param;\n\n\t IPACMDBG(\"Recevied below information during wanup,\\n\");\n\t IPACMDBG(\"if_name:%s, ipv4_address:0x%x\\n\",\n\t\t\t\t\t\twanup_data->ifname, wanup_data->ipv4_addr);\n\n\t if(wanup_data->ipv4_addr == 0)\n\t {\n\t\t IPACMERR(\"Invalid ipv4 address,ignoring IPA_HANDLE_WAN_UP event\\n\");\n\t\t return;\n\t }\n\n\t WanUp = true;\n\t isStaMode = wanup_data->is_sta;\n\t IPACMDBG(\"isStaMode: %d\\n\", isStaMode);\n\n\t wan_ipaddr = wanup_data->ipv4_addr;\n\t memcpy(wan_ifname, wanup_data->ifname, sizeof(wan_ifname));\n\n\t if(nat_inst != NULL)\n\t {\n\t\t nat_inst->AddTable(wanup_data->ipv4_addr);\n\t }\n\n\t IPACMDBG(\"creating nat threads\\n\");\n\t CreateNatThreads();\n}\n\nint IPACM_ConntrackListener::CreateConnTrackThreads(void)\n{\n\t int ret;\n\t pthread_t tcp_thread = 0, udp_thread = 0;\n\n\t if(isCTReg == false)\n\t {\n\n\t\t\tif(!tcp_thread)\n\t\t\t{\n\t\t\t\t ret = pthread_create(&tcp_thread, NULL, IPACM_ConntrackClient::TCPRegisterWithConnTrack, NULL);\n\t\t\t\t if(0 != ret)\n\t\t\t\t {\n\t\t\t\t\t\tIPACMERR(\"unable to create TCP conntrack event listner thread\\n\");\n\t\t\t\t\t\tPERROR(\"unable to create TCP conntrack\\n\");\n\t\t\t\t\t\treturn -1;\n\t\t\t\t }\n\n\t\t\t\t IPACMDBG(\"created TCP conntrack event listner thread\\n\");\n\t\t\t}\n\n\t\t\tif(!udp_thread)\n\t\t\t{\n\t\t\t\t ret = pthread_create(&udp_thread, NULL, IPACM_ConntrackClient::UDPRegisterWithConnTrack, NULL);\n\t\t\t\t if(0 != ret)\n\t\t\t\t {\n\t\t\t\t\t\tIPACMERR(\"unable to create UDP conntrack event listner thread\\n\");\n\t\t\t\t\t\tPERROR(\"unable to create UDP conntrack\\n\");\n\t\t\t\t\t\tgoto error;\n\t\t\t\t }\n\n\t\t\t\t IPACMDBG(\"created UDP conntrack event listner thread\\n\");\n\t\t\t}\n\n\t\t\tisCTReg = true;\n\t }\n\n\t return 0;\n\nerror:\n\t return -1;\n}\nint IPACM_ConntrackListener::CreateNatThreads(void)\n{\n\t int ret;\n\t pthread_t udpcto_thread = 0, to_monitor_thread = 0;\n\n\t if(isNatThreadStart == false)\n\t {\n\n\t\t\tif(!udpcto_thread)\n\t\t\t{\n\t\t\t\t ret = pthread_create(&udpcto_thread, NULL, IPACM_ConntrackClient::UDPConnTimeoutUpdate, NULL);\n\t\t\t\t if(0 != ret)\n\t\t\t\t {\n\t\t\t\t\t\tIPACMERR(\"unable to create udp conn timeout thread\\n\");\n\t\t\t\t\t\tPERROR(\"unable to create udp conn timeout\\n\");\n\t\t\t\t\t\tgoto error;\n\t\t\t\t }\n\n\t\t\t\t IPACMDBG(\"created upd conn timeout thread\\n\");\n\t\t\t}\n\n\t\t\tif(!to_monitor_thread)\n\t\t\t{\n\t\t\t\tret = pthread_create(&to_monitor_thread, NULL, IPACM_ConntrackClient::TCPUDP_Timeout_monitor, NULL);\n\t\t\t\t if(0 != ret)\n\t\t\t\t {\n\t\t\t\t\t\tIPACMERR(\"unable to create tcp/udp timeout monitor thread\\n\");\n\t\t\t\t\t\tPERROR(\"unable to create tcp/udp timeout monitor\\n\");\n\t\t\t\t\t\tgoto error;\n\t\t\t\t }\n\n\t\t\t\t IPACMDBG(\"created tcp/udp timeout monitor thread\\n\");\n\t\t\t}\n\n\t\t\tisNatThreadStart = true;\n\t }\n\t return 0;\n\nerror:\n\t return -1;\n}\n\nvoid IPACM_ConntrackListener::TriggerWANDown(uint32_t wan_addr)\n{\n\t IPACMDBG(\"Deleting ipv4 nat table with\");\n\t iptodot(\"public ip address\", wan_addr);\n\t WanUp = false;\n\n\t if(nat_inst != NULL)\n\t {\n\t\t nat_inst->DeleteTable(wan_addr);\n\t }\n}\n\n\nvoid ParseCTMessage(struct nf_conntrack *ct)\n{\n\t uint32_t status, timeout;\n\t IPACMDBG(\"Printing conntrack parameters\\n\");\n\n\t iptodot(\"ATTR_IPV4_SRC = ATTR_ORIG_IPV4_SRC:\", nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_SRC));\n\t iptodot(\"ATTR_IPV4_DST = ATTR_ORIG_IPV4_DST:\", nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_DST));\n\t IPACMDBG(\"ATTR_PORT_SRC = ATTR_ORIG_PORT_SRC: 0x%x\\n\", nfct_get_attr_u16(ct, ATTR_ORIG_PORT_SRC));\n\t IPACMDBG(\"ATTR_PORT_DST = ATTR_ORIG_PORT_DST: 0x%x\\n\", nfct_get_attr_u16(ct, ATTR_ORIG_PORT_DST));\n\n\t iptodot(\"ATTR_REPL_IPV4_SRC:\", nfct_get_attr_u32(ct, ATTR_REPL_IPV4_SRC));\n\t iptodot(\"ATTR_REPL_IPV4_DST:\", nfct_get_attr_u32(ct, ATTR_REPL_IPV4_DST));\n\t IPACMDBG(\"ATTR_REPL_PORT_SRC: 0x%x\\n\", nfct_get_attr_u16(ct, ATTR_REPL_PORT_SRC));\n\t IPACMDBG(\"ATTR_REPL_PORT_DST: 0x%x\\n\", nfct_get_attr_u16(ct, ATTR_REPL_PORT_DST));\n\n\t iptodot(\"ATTR_SNAT_IPV4:\", nfct_get_attr_u32(ct, ATTR_SNAT_IPV4));\n\t iptodot(\"ATTR_DNAT_IPV4:\", nfct_get_attr_u32(ct, ATTR_DNAT_IPV4));\n\t IPACMDBG(\"ATTR_SNAT_PORT: 0x%x\\n\", nfct_get_attr_u16(ct, ATTR_SNAT_PORT));\n\t IPACMDBG(\"ATTR_DNAT_PORT: 0x%x\\n\", nfct_get_attr_u16(ct, ATTR_DNAT_PORT));\n\n\t IPACMDBG(\"ATTR_MARK: 0x%x\\n\", nfct_get_attr_u32(ct, ATTR_MARK));\n\t IPACMDBG(\"ATTR_USE: 0x%x\\n\", nfct_get_attr_u32(ct, ATTR_USE));\n\t IPACMDBG(\"ATTR_ID: 0x%x\\n\", nfct_get_attr_u32(ct, ATTR_ID));\n\n\t status = nfct_get_attr_u32(ct, ATTR_STATUS);\n\t IPACMDBG(\"ATTR_STATUS: 0x%x\\n\", status);\n\n\t timeout = nfct_get_attr_u32(ct, ATTR_TIMEOUT);\n\t IPACMDBG(\"ATTR_TIMEOUT: 0x%x\\n\", timeout);\n\n\t if(IPS_SRC_NAT & status)\n\t {\n\t\t\tIPACMDBG(\"IPS_SRC_NAT set\\n\");\n\t }\n\n\t if(IPS_DST_NAT & status)\n\t {\n\t\t\tIPACMDBG(\"IPS_DST_NAT set\\n\");\n\t }\n\n\t if(IPS_SRC_NAT_DONE & status)\n\t {\n\t\t\tIPACMDBG(\"IPS_SRC_NAT_DONE set\\n\");\n\t }\n\n\t if(IPS_DST_NAT_DONE & status)\n\t {\n\t\t\tIPACMDBG(\" IPS_DST_NAT_DONE set\\n\");\n\t }\n\n\t IPACMDBG(\"\\n\");\n\t return;\n}\n\nvoid ParseCTV6Message(struct nf_conntrack *ct)\n{\n\t uint32_t status, timeout, secmark;\n\t struct nfct_attr_grp_ipv6 orig_params;\n\t uint8_t l4proto, tcp_flags, tcp_state;\n\n\t IPACMDBG(\"Printing conntrack parameters\\n\");\n\n\t nfct_get_attr_grp(ct, ATTR_GRP_ORIG_IPV6, (void *)&orig_params);\n\t IPACMDBG(\"Orig src_v6_addr: 0x%08x%08x%08x%08x\\n\", orig_params.src[0], orig_params.src[1],\n                \torig_params.src[2], orig_params.src[3]);\n\tIPACMDBG(\"Orig dst_v6_addr: 0x%08x%08x%08x%08x\\n\", orig_params.dst[0], orig_params.dst[1],\n                \torig_params.dst[2], orig_params.dst[3]);\n\n\t IPACMDBG(\"ATTR_PORT_SRC = ATTR_ORIG_PORT_SRC: 0x%x\\n\", nfct_get_attr_u16(ct, ATTR_ORIG_PORT_SRC));\n\t IPACMDBG(\"ATTR_PORT_DST = ATTR_ORIG_PORT_DST: 0x%x\\n\", nfct_get_attr_u16(ct, ATTR_ORIG_PORT_DST));\n\n\t IPACMDBG(\"ATTR_MARK: 0x%x\\n\", nfct_get_attr_u32(ct, ATTR_MARK));\n\t IPACMDBG(\"ATTR_USE: 0x%x\\n\", nfct_get_attr_u32(ct, ATTR_USE));\n\t IPACMDBG(\"ATTR_ID: 0x%x\\n\", nfct_get_attr_u32(ct, ATTR_ID));\n\n\t timeout = nfct_get_attr_u32(ct, ATTR_TIMEOUT);\n\t IPACMDBG(\"ATTR_TIMEOUT: 0x%x\\n\", timeout);\n\n\t status = nfct_get_attr_u32(ct, ATTR_STATUS);\n\t IPACMDBG(\"ATTR_STATUS: 0x%x\\n\", status);\n\n\t l4proto = nfct_get_attr_u8(ct, ATTR_ORIG_L4PROTO);\n\t IPACMDBG(\"ATTR_ORIG_L4PROTO: 0x%x\\n\", l4proto);\n\t if(l4proto == IPPROTO_TCP)\n\t {\n\t\ttcp_state = nfct_get_attr_u8(ct, ATTR_TCP_STATE);\n\t\tIPACMDBG(\"ATTR_TCP_STATE: 0x%x\\n\", tcp_state);\n\n\t\ttcp_flags =  nfct_get_attr_u8(ct, ATTR_TCP_FLAGS_ORIG);\n\t\tIPACMDBG(\"ATTR_TCP_FLAGS_ORIG: 0x%x\\n\", tcp_flags);\n\t }\n\n\t IPACMDBG(\"\\n\");\n\t return;\n}\n\n#ifdef CT_OPT\nvoid IPACM_ConntrackListener::ProcessCTV6Message(void *param)\n{\n\tipacm_ct_evt_data *evt_data = (ipacm_ct_evt_data *)param;\n\tu_int8_t l4proto = 0;\n\tuint32_t status = 0;\n\tstruct nf_conntrack *ct = evt_data->ct;\n\n#ifdef IPACM_DEBUG\n\t char buf[1024];\n\n\t /* Process message and generate ioctl call to kernel thread */\n\t nfct_snprintf(buf, sizeof(buf), evt_data->ct,\n\t\t\t\t\t\t\t\t evt_data->type, NFCT_O_PLAIN, NFCT_OF_TIME);\n\t IPACMDBG(\"%s\\n\", buf);\n\t IPACMDBG(\"\\n\");\n\t ParseCTV6Message(ct);\n#endif\n\n\tif(p_lan2lan == NULL)\n\t{\n\t\tIPACMERR(\"Lan2Lan Instance is null\\n\");\n\t\tgoto IGNORE;\n\t}\n\n\tstatus = nfct_get_attr_u32(ct, ATTR_STATUS);\n\tif((IPS_DST_NAT & status) || (IPS_SRC_NAT & status))\n\t{\n\t\tIPACMDBG(\"Either Destination or Source nat flag Set\\n\");\n\t\tgoto IGNORE;\n\t}\n\n\tl4proto = nfct_get_attr_u8(ct, ATTR_ORIG_L4PROTO);\n\tif(IPPROTO_UDP != l4proto && IPPROTO_TCP != l4proto)\n\t{\n\t\t IPACMDBG(\"Received unexpected protocl %d conntrack message\\n\", l4proto);\n\t\t goto IGNORE;\n\t}\n\n\tIPACMDBG(\"Neither Destination nor Source nat flag Set\\n\");\n\tstruct nfct_attr_grp_ipv6 orig_params;\n\tnfct_get_attr_grp(ct, ATTR_GRP_ORIG_IPV6, (void *)&orig_params);\n\n\tipacm_event_connection lan2lan_conn;\n\tlan2lan_conn.iptype = IPA_IP_v6;\n\tmemcpy(lan2lan_conn.src_ipv6_addr, orig_params.src,\n\t\t\t\t sizeof(lan2lan_conn.src_ipv6_addr));\n    IPACMDBG(\"Before convert, src_v6_addr: 0x%08x%08x%08x%08x\\n\", lan2lan_conn.src_ipv6_addr[0], lan2lan_conn.src_ipv6_addr[1],\n                \tlan2lan_conn.src_ipv6_addr[2], lan2lan_conn.src_ipv6_addr[3]);\n    for(int cnt=0; cnt<4; cnt++)\n\t{\n\t   lan2lan_conn.src_ipv6_addr[cnt] = ntohl(lan2lan_conn.src_ipv6_addr[cnt]);\n\t}\n\tIPACMDBG(\"After convert src_v6_addr: 0x%08x%08x%08x%08x\\n\", lan2lan_conn.src_ipv6_addr[0], lan2lan_conn.src_ipv6_addr[1],\n                \tlan2lan_conn.src_ipv6_addr[2], lan2lan_conn.src_ipv6_addr[3]);\n\n\tmemcpy(lan2lan_conn.dst_ipv6_addr, orig_params.dst,\n\t\t\t\t sizeof(lan2lan_conn.dst_ipv6_addr));\n\tIPACMDBG(\"Before convert, dst_ipv6_addr: 0x%08x%08x%08x%08x\\n\", lan2lan_conn.dst_ipv6_addr[0], lan2lan_conn.dst_ipv6_addr[1],\n                \tlan2lan_conn.dst_ipv6_addr[2], lan2lan_conn.dst_ipv6_addr[3]);\n    for(int cnt=0; cnt<4; cnt++)\n\t{\n\t   lan2lan_conn.dst_ipv6_addr[cnt] = ntohl(lan2lan_conn.dst_ipv6_addr[cnt]);\n\t}\n\tIPACMDBG(\"After convert, dst_ipv6_addr: 0x%08x%08x%08x%08x\\n\", lan2lan_conn.dst_ipv6_addr[0], lan2lan_conn.dst_ipv6_addr[1],\n                \tlan2lan_conn.dst_ipv6_addr[2], lan2lan_conn.dst_ipv6_addr[3]);\n\n\tif(((IPPROTO_UDP == l4proto) && (NFCT_T_NEW == evt_data->type)) ||\n\t\t ((IPPROTO_TCP == l4proto) &&\n\t\t\t(nfct_get_attr_u8(ct, ATTR_TCP_STATE) == TCP_CONNTRACK_ESTABLISHED))\n\t\t )\n\t{\n\t\t\tp_lan2lan->handle_new_connection(&lan2lan_conn);\n\t}\n\telse if((IPPROTO_UDP == l4proto && NFCT_T_DESTROY == evt_data->type) ||\n\t\t\t\t\t(IPPROTO_TCP == l4proto &&\n\t\t\t\t\t nfct_get_attr_u8(ct, ATTR_TCP_STATE) == TCP_CONNTRACK_FIN_WAIT))\n\t{\n\t\t\tp_lan2lan->handle_del_connection(&lan2lan_conn);\n\t}\n\nIGNORE:\n\t/* Cleanup item that was allocated during the original CT callback */\n\tnfct_destroy(ct);\n\treturn;\n}\n#endif\n\nvoid IPACM_ConntrackListener::ProcessCTMessage(void *param)\n{\n\t ipacm_ct_evt_data *evt_data = (ipacm_ct_evt_data *)param;\n\t u_int8_t l4proto = 0;\n\n#ifdef IPACM_DEBUG\n\t char buf[1024];\n\t unsigned int out_flags;\n\n\t /* Process message and generate ioctl call to kernel thread */\n\t out_flags = (NFCT_OF_SHOW_LAYER3 | NFCT_OF_TIME | NFCT_OF_ID);\n\t nfct_snprintf(buf, sizeof(buf), evt_data->ct,\n\t\t\t\t\t\t\t\t evt_data->type, NFCT_O_PLAIN, out_flags);\n\t IPACMDBG(\"%s\\n\", buf);\n\t IPACMDBG(\"\\n\");\n\n\t ParseCTMessage(evt_data->ct);\n#endif\n\n\t l4proto = nfct_get_attr_u8(evt_data->ct, ATTR_ORIG_L4PROTO);\n\t if(IPPROTO_UDP != l4proto && IPPROTO_TCP != l4proto)\n\t {\n\t\t\tIPACMDBG(\"Received unexpected protocl %d conntrack message\\n\", l4proto);\n\t }\n\t else\n\t {\n\t\t\tProcessTCPorUDPMsg(evt_data->ct, evt_data->type, l4proto);\n\t }\n\n\t /* Cleanup item that was allocated during the original CT callback */\n\t nfct_destroy(evt_data->ct);\n\t return;\n}\n\n\n/* conntrack send in host order and ipa expects in host order */\nvoid IPACM_ConntrackListener::ProcessTCPorUDPMsg(\n\t struct nf_conntrack *ct,\n\t enum nf_conntrack_msg_type type,\n\t u_int8_t l4proto)\n{\n\t nat_table_entry rule;\n\t u_int8_t tcp_state;\n\t uint32_t status = 0;\n\t IPACM_Config *pConfig;\n\t uint32_t orig_src_ip, orig_dst_ip;\n\t bool isTempEntry = false;\n\n \t memset(&rule, 0, sizeof(rule));\n\t pConfig = IPACM_Config::GetInstance();\n\t if(pConfig == NULL)\n\t {\n\t\t IPACMERR(\"Unable to get Config instance\\n\");\n\t }\n\n\t IPACMDBG(\"Received type:%d with proto:%d\\n\", type, l4proto);\n\t status = nfct_get_attr_u32(ct, ATTR_STATUS);\n\n\t /* Retrieve Protocol */\n\t rule.protocol = nfct_get_attr_u8(ct, ATTR_REPL_L4PROTO);\n\n\t if(IPS_DST_NAT & status)\n\t {\n\t\t status = IPS_DST_NAT;\n\t }\n\t else if(IPS_SRC_NAT & status)\n\t {\n\t\t status = IPS_SRC_NAT;\n\t }\n\t else\n\t {\n\t\t IPACMDBG(\"Neither Destination nor Source nat flag Set\\n\");\n\t\t orig_src_ip = nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_SRC);\n\t\t orig_src_ip = ntohl(orig_src_ip);\n\t\t if(orig_src_ip == 0)\n\t\t {\n\t\t\t IPACMERR(\"unable to retrieve orig src ip address\\n\");\n\t\t\t return;\n\t\t }\n\n\t\t orig_dst_ip = nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_DST);\n\t\t orig_dst_ip = ntohl(orig_dst_ip);\n\t\t if(orig_dst_ip == 0)\n\t\t {\n\t\t\t IPACMERR(\"unable to retrieve orig dst ip address\\n\");\n\t\t\t return;\n\t\t }\n\n\t\t if(orig_src_ip == wan_ipaddr)\n\t\t {\n\t\t\t IPACMDBG(\"orig src ip:0x%x equal to wan ip\\n\",orig_src_ip);\n\t\t\t status = IPS_SRC_NAT;\n\t\t\t rule.public_ip = wan_ipaddr;\n\t\t }\n\t\t else if(orig_dst_ip == wan_ipaddr)\n\t\t {\n\t\t\t IPACMDBG(\"orig Dst IP:0x%x equal to wan ip\\n\",orig_dst_ip);\n\t\t\t status = IPS_DST_NAT;\n\t \t \t rule.public_ip = wan_ipaddr;\n\t\t }\n\t\t else\n\t\t {\n\t\t\t IPACMDBG(\"Neither orig src ip:0x%x Nor orig Dst IP:0x%x equal to wan ip:0x%x\\n\",\n\t\t\t\t\t\torig_src_ip, orig_dst_ip, wan_ipaddr);\n\n#ifdef CT_OPT\n\t\tif(p_lan2lan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Lan2Lan Instance is null\\n\");\n\t\t\tgoto IGNORE;\n\t\t}\n\n\t\t\t ipacm_event_connection lan2lan_conn = { 0 };\n\t\t\t lan2lan_conn.iptype = IPA_IP_v4;\n\t\t\t lan2lan_conn.src_ipv4_addr = orig_src_ip;\n\t\t\t lan2lan_conn.dst_ipv4_addr = orig_dst_ip;\n\n\t\t\t if(((IPPROTO_UDP == rule.protocol) && (NFCT_T_NEW == type)) ||\n\t\t\t\t\t((IPPROTO_TCP == rule.protocol) && (nfct_get_attr_u8(ct, ATTR_TCP_STATE) == TCP_CONNTRACK_ESTABLISHED)))\n\t\t\t {\n\t\t\t\t p_lan2lan->handle_new_connection(&lan2lan_conn);\n\t\t\t }\n\t\t\t else if((IPPROTO_UDP == rule.protocol && NFCT_T_DESTROY == type) ||\n\t\t\t\t\t\t\t (IPPROTO_TCP == rule.protocol &&\n\t\t\t\t\t\t\t\tnfct_get_attr_u8(ct, ATTR_TCP_STATE) == TCP_CONNTRACK_FIN_WAIT))\n\t\t\t {\n\t\t\t\t p_lan2lan->handle_del_connection(&lan2lan_conn);\n\t\t\t }\n#endif\n\t\t\t\t\t return;\n\t\t }\n\t }\n\n\t if(IPS_DST_NAT == status)\n\t {\n\t\t\tIPACMDBG(\"Destination NAT\\n\");\n\t\t\trule.dst_nat = true;\n\n\t\t\tIPACMDBG(\"Parse reply tuple\\n\");\n\t\t\trule.target_ip = nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_SRC);\n\t\t\trule.target_ip = ntohl(rule.target_ip);\n\n\t\t\t/* Retriev target/dst port */\n\t\t\trule.target_port = nfct_get_attr_u16(ct, ATTR_ORIG_PORT_SRC);\n\t\t\trule.target_port = ntohs(rule.target_port);\n\t\t\tif(0 == rule.target_port)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"unable to retrieve target port\\n\");\n\t\t\t}\n\n\t\t\trule.public_port = nfct_get_attr_u16(ct, ATTR_ORIG_PORT_DST);\n\t\t\trule.public_port = ntohs(rule.public_port);\n\n\t\t\t/* Retriev src/private ip address */\n\t\t\trule.private_ip = nfct_get_attr_u32(ct, ATTR_REPL_IPV4_SRC);\n\t\t\trule.private_ip = ntohl(rule.private_ip);\n\t\t\tif(0 == rule.private_ip)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"unable to retrieve private ip address\\n\");\n\t\t\t}\n\n\t\t\t/* Retriev src/private port */\n\t\t\trule.private_port = nfct_get_attr_u16(ct, ATTR_REPL_PORT_SRC);\n\t\t\trule.private_port = ntohs(rule.private_port);\n\t\t\tif(0 == rule.private_port)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"unable to retrieve private port\\n\");\n\t\t\t}\n\t }\n\t else if(IPS_SRC_NAT == status)\n\t {\n\t\t\tIPACMDBG(\"Source NAT\\n\");\n\t\t\trule.dst_nat = false;\n\n\t\t\t/* Retriev target/dst ip address */\n\t\t\tIPACMDBG(\"Parse source tuple\\n\");\n\t\t\trule.target_ip = nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_DST);\n\t\t\trule.target_ip = ntohl(rule.target_ip);\n\t\t\tif(0 == rule.target_ip)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"unable to retrieve target ip address\\n\");\n\t\t\t}\n\t\t\t/* Retriev target/dst port */\n\t\t\trule.target_port = nfct_get_attr_u16(ct, ATTR_ORIG_PORT_DST);\n\t\t\trule.target_port = ntohs(rule.target_port);\n\t\t\tif(0 == rule.target_port)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"unable to retrieve target port\\n\");\n\t\t\t}\n\n\t\t\t/* Retriev public port */\n\t\t\trule.public_port = nfct_get_attr_u16(ct, ATTR_REPL_PORT_DST);\n\t\t\trule.public_port = ntohs(rule.public_port);\n\t\t\tif(0 == rule.public_port)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"unable to retrieve public port\\n\");\n\t\t\t}\n\n\t\t\t/* Retriev src/private ip address */\n\t\t\trule.private_ip = nfct_get_attr_u32(ct, ATTR_ORIG_IPV4_SRC);\n\t\t\trule.private_ip = ntohl(rule.private_ip);\n\t\t\tif(0 == rule.private_ip)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"unable to retrieve private ip address\\n\");\n\t\t\t}\n\n\t\t\t/* Retriev src/private port */\n\t\t\trule.private_port = nfct_get_attr_u16(ct, ATTR_ORIG_PORT_SRC);\n\t\t\trule.private_port = ntohs(rule.private_port);\n\t\t\tif(0 == rule.private_port)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"unable to retrieve private port\\n\");\n\t\t\t}\n\t }\n\t else\n\t {\n\t\t IPACMDBG(\"Neither source Nor destination nat\\n\");\n\t\t goto IGNORE;\n\t }\n\n\t if(rule.private_ip != wan_ipaddr)\n\t {\n\t\t int cnt;\n\t\t for(cnt = 0; cnt < MAX_NAT_IFACES; cnt++)\n\t\t {\n\t\t\t if(nat_iface_ipv4_addr[cnt] != 0)\n\t\t\t {\n\t\t\t\t if(rule.private_ip == nat_iface_ipv4_addr[cnt] ||\n\t\t\t\t\t\trule.target_ip == nat_iface_ipv4_addr[cnt])\n\t\t\t\t {\n\t\t\t\t\t IPACMDBG(\"matched nat_iface_ipv4_addr entry(%d)\\n\", cnt);\n\t\t\t\t\t iptodot(\"ProcessTCPorUDPMsg(): Nat entry match with ip addr\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnat_iface_ipv4_addr[cnt]);\n\t\t\t\t\t break;\n\t\t\t\t }\n\t\t\t }\n\t\t }\n\n\t\t if(cnt == MAX_NAT_IFACES)\n\t\t {\n\t\t\t IPACMDBG(\"Not mtaching with nat ifaces\\n\")\n\t\t\t if(pConfig == NULL)\n\t\t\t {\n\t\t\t\t goto IGNORE;\n\t\t\t }\n\n\t\t\t if(pConfig->isPrivateSubnet(rule.private_ip) ||\n\t\t\t\t\t\tpConfig->isPrivateSubnet(rule.target_ip))\n\t\t\t {\n\t\t\t\t IPACMDBG(\"Matching with Private subnet\\n\");\n\t\t\t\t isTempEntry = true;\n\t\t\t }\n\t\t\t else\n\t\t\t {\n\t\t\t\t goto IGNORE;\n\t\t\t }\n\t\t }\n\n\t }\n\t else\n\t {\n\t\t if(isStaMode) {\n\t\t\t IPACMDBG(\"In STA mode, ignore connections destinated to STA interface\\n\");\n\t\t\t goto IGNORE;\n\t\t }\n\n     IPACMDBG(\"For embedded connections add dummy nat rule\\n\");\n     IPACMDBG(\"Change private port %d to %d\\n\",\n              rule.private_port, rule.public_port);\n     rule.private_port = rule.public_port;\n\t }\n\n\t /* Check whether target is in STA client list or not\n      if not ignore the connection */\n\t int nCnt;\n\n\t if(!isStaMode || (StaClntCnt == 0))\n\t {\n\t\tgoto ADD;\n\t }\n\n\t if((sta_clnt_ipv4_addr[0] & 0xFFFFFF00) !=\n\t\t (rule.target_ip & 0xFFFFFF00))\n\t {\n\t\tIPACMDBG(\"STA client subnet mask not matching\\n\");\n\t\tgoto ADD;\n\t }\n\n\t IPACMDBG(\"StaClntCnt %d\\n\", StaClntCnt);\n\t for(nCnt = 0; nCnt < StaClntCnt; nCnt++)\n\t {\n\t\tIPACMDBG(\"Comparing trgt_ip 0x%x with sta clnt ip: 0x%x\\n\",\n\t\t\t rule.target_ip, sta_clnt_ipv4_addr[nCnt]);\n\t\tif(rule.target_ip == sta_clnt_ipv4_addr[nCnt])\n\t\t{\n\t\t\tIPACMDBG(\"Match index %d\\n\", nCnt);\n\t\t\tgoto ADD;\n\t\t}\n\t }\n\n\t IPACMDBG(\"Not matching with STA Clnt Ip Addrs 0x%x\\n\",\n\t\t\t rule.target_ip);\n\t goto IGNORE;\n\n\nADD:\n\t IPACMDBG(\"Nat Entry with below information will either be added or deleted\\n\");\n\t iptodot(\"target ip or dst ip\", rule.target_ip);\n\t IPACMDBG(\"target port or dst port: 0x%x Decimal:%d\\n\", rule.target_port, rule.target_port);\n\t iptodot(\"private ip or src ip\", rule.private_ip);\n\t IPACMDBG(\"private port or src port: 0x%x, Decimal:%d\\n\", rule.private_port, rule.private_port);\n\t IPACMDBG(\"public port or reply dst port: 0x%x, Decimal:%d\\n\", rule.public_port, rule.public_port);\n\t IPACMDBG(\"Protocol: %d, destination nat flag: %d\\n\", rule.protocol, rule.dst_nat);\n\n\t if(IPPROTO_TCP == rule.protocol)\n\t {\n\t\t\tif(nat_inst == NULL)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttcp_state = nfct_get_attr_u8(ct, ATTR_TCP_STATE);\n\t\t\tif(TCP_CONNTRACK_ESTABLISHED == tcp_state)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"TCP state TCP_CONNTRACK_ESTABLISHED(%d)\\n\", tcp_state);\n\t\t\t\t if(!CtList->isWanUp())\n\t\t\t\t {\n\t\t\t\t \t IPACMDBG(\"Wan is not up, cache connections\\n\");\n\t\t\t\t\t nat_inst->CacheEntry(&rule);\n\t\t\t\t }\n\t\t\t\t else if(isTempEntry)\n\t\t\t\t {\n\t\t\t\t\t nat_inst->AddTempEntry(&rule);\n\t\t\t\t }\n\t\t\t\t else\n\t\t\t\t {\n\t\t\t\t\t nat_inst->AddEntry(&rule);\n\t\t\t\t }\n\t\t\t}\n\t\t\telse if(TCP_CONNTRACK_FIN_WAIT == tcp_state ||\n\t\t\t        type == NFCT_T_DESTROY)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"TCP state TCP_CONNTRACK_FIN_WAIT(%d) \"\n\t\t\t\t\t\t\"or type NFCT_T_DESTROY(%d)\\n\", tcp_state, type);\n\n\t\t\t\t if(isTempEntry)\n\t\t\t\t {\n\t\t\t\t\t nat_inst->DeleteTempEntry(&rule);\n\t\t\t\t }\n\t\t\t\t else\n\t\t\t\t {\n\t\t\t\t\t nat_inst->DeleteEntry(&rule);\n\t\t\t\t }\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t IPACMDBG(\"Ignore tcp state: %d and type: %d\\n\", tcp_state, type);\n\t\t\t}\n\n\t }\n\t else if(IPPROTO_UDP == rule.protocol)\n\t {\n\t\t\tif(nat_inst == NULL)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif(NFCT_T_NEW == type)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"New UDP connection at time %ld\\n\", time(NULL));\n\t\t\t\t if(!CtList->isWanUp())\n\t\t\t\t {\n\t\t\t\t \t IPACMDBG(\"Wan is not up, cache connections\\n\");\n\t\t\t\t\t nat_inst->CacheEntry(&rule);\n\t\t\t\t }\n\t\t\t\t else if(isTempEntry)\n\t\t\t\t {\n\t\t\t\t\t nat_inst->AddTempEntry(&rule);\n\t\t\t\t }\n\t\t\t\t else\n\t\t\t\t {\n\t\t\t\t\t nat_inst->AddEntry(&rule);\n\t\t\t\t }\n\t\t\t}\n\t\t\telse if(NFCT_T_DESTROY == type)\n\t\t\t{\n\t\t\t\t IPACMDBG(\"UDP connection close at time %ld\\n\", time(NULL));\n\t\t\t\t if(isTempEntry)\n\t\t\t\t {\n\t\t\t\t\t nat_inst->DeleteTempEntry(&rule);\n\t\t\t\t }\n\t\t\t\t else\n\t\t\t\t {\n\t\t\t\t\t nat_inst->DeleteEntry(&rule);\n\t\t\t\t }\n\t\t\t}\n\t }\n\t else\n\t {\n\t\t\tIPACMDBG(\"Ignore protocol: %d and type: %d\\n\", rule.protocol, type);\n\t }\n\n\t return;\n\nIGNORE:\n\tIPACMDBG(\"ignoring below Nat Entry\\n\");\n\tiptodot(\"target ip or dst ip\", rule.target_ip);\n\tIPACMDBG(\"target port or dst port: 0x%x Decimal:%d\\n\", rule.target_port, rule.target_port);\n\tiptodot(\"private ip or src ip\", rule.private_ip);\n\tIPACMDBG(\"private port or src port: 0x%x, Decimal:%d\\n\", rule.private_port, rule.private_port);\n\tIPACMDBG(\"public port or reply dst port: 0x%x, Decimal:%d\\n\", rule.public_port, rule.public_port);\n\tIPACMDBG(\"Protocol: %d, destination nat flag: %d\\n\", rule.protocol, rule.dst_nat);\n\n\treturn;\n}\n\nvoid IPACM_ConntrackListener::HandleSTAClientAddEvt(uint32_t clnt_ip_addr)\n{\n\t int cnt;\n\t IPACMDBG(\"Received STA client 0x%x\\n\", clnt_ip_addr);\n\n\t if(StaClntCnt >= MAX_STA_CLNT_IFACES)\n\t {\n\t\tIPACMDBG(\"Max STA client reached, ignore 0x%x\\n\", clnt_ip_addr);\n\t\treturn;\n\t }\n\n\t for(cnt=0; cnt<MAX_STA_CLNT_IFACES; cnt++)\n\t {\n\t\tif(sta_clnt_ipv4_addr[cnt] != 0 &&\n\t\t sta_clnt_ipv4_addr[cnt] == clnt_ip_addr)\n\t\t{\n\t\t\tIPACMDBG(\"Ignoring duplicate one 0x%x\\n\", clnt_ip_addr);\n\t\t\tbreak;\n\t\t}\n\n\t\tif(sta_clnt_ipv4_addr[cnt] == 0)\n\t\t{\n\t\t\tIPACMDBG(\"Adding STA client 0x%x at Index: %d\\n\",\n\t\t\t\t\tclnt_ip_addr, cnt);\n\t\t\tsta_clnt_ipv4_addr[cnt] = clnt_ip_addr;\n\t\t\tStaClntCnt++;\n\t\t\tIPACMDBG(\"STA client cnt %d\\n\", StaClntCnt);\n\t\t\tbreak;\n\t\t}\n\n\t }\n\n\t return;\n}\n\nvoid IPACM_ConntrackListener::HandleSTAClientDelEvt(uint32_t clnt_ip_addr)\n{\n\t int cnt;\n\t IPACMDBG(\"Received STA client 0x%x\\n\", clnt_ip_addr);\n\n\t for(cnt=0; cnt<MAX_STA_CLNT_IFACES; cnt++)\n\t {\n\t\tif(sta_clnt_ipv4_addr[cnt] != 0 &&\n\t\t sta_clnt_ipv4_addr[cnt] == clnt_ip_addr)\n\t\t{\n\t\t\tIPACMDBG(\"Deleting STA client 0x%x at index: %d\\n\",\n\t\t\t\t\tclnt_ip_addr, cnt);\n\t\t\tsta_clnt_ipv4_addr[cnt] = 0;\n\t\t\tnat_inst->DelEntriesOnSTAClntDiscon(clnt_ip_addr);\n\t\t\tStaClntCnt--;\n\t\t\tIPACMDBG(\"STA client cnt %d\\n\", StaClntCnt);\n\t\t\tbreak;\n\t\t}\n\t }\n\n  return;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Conntrack_NATApp.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#include \"IPACM_Conntrack_NATApp.h\"\n#include \"IPACM_ConntrackClient.h\"\n\n#define INVALID_IP_ADDR 0x0\n\n/* NatApp class Implementation */\nNatApp *NatApp::pInstance = NULL;\nNatApp::NatApp()\n{\n\tmax_entries = 0;\n\tcache = NULL;\n\n\tnat_table_hdl = 0;\n\tpub_ip_addr = 0;\n\n\tcurCnt = 0;\n\n\tpALGPorts = NULL;\n\tnALGPort = 0;\n\n\tct = NULL;\n\tct_hdl = NULL;\n\n\tmemset(temp, 0, sizeof(temp));\n}\n\nint NatApp::Init(void)\n{\n\tIPACM_Config *pConfig;\n\tint size = 0;\n\n\tpConfig = IPACM_Config::GetInstance();\n\tif(pConfig == NULL)\n\t{\n\t\tIPACMERR(\"Unable to get Config instance\\n\");\n\t\treturn -1;\n\t}\n\n\tmax_entries = pConfig->GetNatMaxEntries();\n\n\tsize = (sizeof(nat_table_entry) * max_entries);\n\tcache = (nat_table_entry *)malloc(size);\n\tif(cache == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate memory for cache\\n\");\n\t\tgoto fail;\n\t}\n\tIPACMDBG(\"Allocated %d bytes for config manager nat cache\\n\", size);\n\tmemset(cache, 0, size);\n\n\tnALGPort = pConfig->GetAlgPortCnt();\n\tpALGPorts = (ipacm_alg *)malloc(sizeof(ipacm_alg) * nALGPort);\n\tif(pALGPorts == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate memory for alg prots\\n\");\n\t\tgoto fail;\n\t}\n\tmemset(pALGPorts, 0, sizeof(ipacm_alg) * nALGPort);\n\n\tif(pConfig->GetAlgPorts(nALGPort, pALGPorts) != 0)\n\t{\n\t\tIPACMERR(\"Unable to retrieve ALG prots\\n\");\n\t\tgoto fail;\n\t}\n\n\tIPACMDBG(\"Printing %d alg ports information\\n\", nALGPort);\n\tfor(int cnt=0; cnt<nALGPort; cnt++)\n\t{\n\t\tIPACMDBG(\"%d: Proto[%d], port[%d]\\n\", cnt, pALGPorts[cnt].protocol, pALGPorts[cnt].port);\n\t}\n\n\treturn 0;\n\nfail:\n\tfree(cache);\n\tfree(pALGPorts);\n\treturn -1;\n}\n\nNatApp* NatApp::GetInstance()\n{\n\tif(pInstance == NULL)\n\t{\n\t\tpInstance = new NatApp();\n\n\t\tif(pInstance->Init())\n\t\t{\n\t\t\tdelete pInstance;\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\treturn pInstance;\n}\n\n/* NAT APP related object function definitions */\n\nint NatApp::AddTable(uint32_t pub_ip)\n{\n\tint ret;\n\tint cnt = 0;\n\tipa_nat_ipv4_rule nat_rule;\n\tIPACMDBG(\"%s() %d\\n\", __FUNCTION__, __LINE__);\n\n\t/* Not reset the cache wait it timeout by destroy event */\n#if 0\n\tif (pub_ip != pub_ip_addr_pre)\n\t{\n\t\tIPACMDBG(\"Reset the cache because NAT-ipv4 different\\n\");\n\t\tmemset(cache, 0, sizeof(nat_table_entry) * max_entries);\n\t\tcurCnt = 0;\n\t}\n#endif\n\tret = ipa_nat_add_ipv4_tbl(pub_ip, max_entries, &nat_table_hdl);\n\tif(ret)\n\t{\n\t\tIPACMERR(\"unable to create nat table Error:%d\\n\", ret);\n\t\treturn ret;\n\t}\n\n\t/* Add back the cashed NAT-entry */\n\tif (pub_ip == pub_ip_addr_pre)\n\t{\n\t\tIPACMDBG(\"Restore the cache to ipa NAT-table\\n\");\n\t\tfor(cnt = 0; cnt < max_entries; cnt++)\n\t\t{\n\t\t\tif(cache[cnt].private_ip !=0)\n\t\t\t{\n\t\t\t\tmemset(&nat_rule, 0 , sizeof(nat_rule));\n\t\t\t\tnat_rule.private_ip = cache[cnt].private_ip;\n\t\t\t\tnat_rule.target_ip = cache[cnt].target_ip;\n\t\t\t\tnat_rule.target_port = cache[cnt].target_port;\n\t\t\t\tnat_rule.private_port = cache[cnt].private_port;\n\t\t\t\tnat_rule.public_port = cache[cnt].public_port;\n\t\t\t\tnat_rule.protocol = cache[cnt].protocol;\n\n\t\t\t\tif(ipa_nat_add_ipv4_rule(nat_table_hdl, &nat_rule, &cache[cnt].rule_hdl) < 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to add the rule delete from cache\\n\");\n\t\t\t\t\tmemset(&cache[cnt], 0, sizeof(cache[cnt]));\n\t\t\t\t\tcurCnt--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcache[cnt].enabled = true;\n\n\t\t\t\tIPACMDBG(\"On wan-iface reset added below rule successfully\\n\");\n\t\t\t\tiptodot(\"Private IP\", nat_rule.private_ip);\n\t\t\t\tiptodot(\"Target IP\", nat_rule.target_ip);\n\t\t\t\tIPACMDBG(\"Private Port:%d \\t Target Port: %d\\t\", nat_rule.private_port, nat_rule.target_port);\n\t\t\t\tIPACMDBG(\"Public Port:%d\\n\", nat_rule.public_port);\n\t\t\t\tIPACMDBG(\"protocol: %d\\n\", nat_rule.protocol);\n\t\t\t}\n\t\t}\n\t}\n\n\tpub_ip_addr = pub_ip;\n\treturn 0;\n}\n\nvoid NatApp::Reset()\n{\n\tint cnt = 0;\n\n\tnat_table_hdl = 0;\n\tpub_ip_addr = 0;\n\t/* NAT tbl deleted, reset enabled bit */\n\tfor(cnt = 0; cnt < max_entries; cnt++)\n\t{\n\t\tcache[cnt].enabled ==false;\n\t}\n}\n\nint NatApp::DeleteTable(uint32_t pub_ip)\n{\n\tint ret;\n\tIPACMDBG(\"%s() %d\\n\", __FUNCTION__, __LINE__);\n\n\tCHK_TBL_HDL();\n\n\tif(pub_ip_addr != pub_ip)\n\t{\n\t\tIPACMDBG(\"Public ip address is not matching\\n\");\n\t\tIPACMERR(\"unable to delete the nat table\\n\");\n\t\treturn -1;\n\t}\n\n\tret = ipa_nat_del_ipv4_tbl(nat_table_hdl);\n\tif(ret)\n\t{\n\t\tIPACMERR(\"unable to delete nat table Error: %d\\n\", ret);;\n\t\treturn ret;\n\t}\n\n\tpub_ip_addr_pre = pub_ip_addr;\n\tReset();\n\treturn 0;\n}\n\n/* Check for duplicate entries */\nbool NatApp::ChkForDup(const nat_table_entry *rule)\n{\n\tint cnt = 0;\n\tIPACMDBG(\"%s() %d\\n\", __FUNCTION__, __LINE__);\n\n\tfor(; cnt < max_entries; cnt++)\n\t{\n\t\tif(cache[cnt].private_ip == rule->private_ip &&\n\t\t\t cache[cnt].target_ip == rule->target_ip &&\n\t\t\t cache[cnt].private_port ==  rule->private_port  &&\n\t\t\t cache[cnt].target_port == rule->target_port &&\n\t\t\t cache[cnt].protocol == rule->protocol)\n\t\t{\n\t\t\tIPACMDBG(\"Duplicate Rule\\n\");\n\t\t\tiptodot(\"Private IP\", rule->private_ip);\n\t\t\tiptodot(\"Target IP\", rule->target_ip);\n\t\t\tIPACMDBG(\"Private Port: %d\\t Target Port: %d\\t\", rule->private_port, rule->target_port);\n\t\t\tIPACMDBG(\"protocolcol: %d\\n\", rule->protocol);\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/* Delete the entry from Nat table on connection close */\nint NatApp::DeleteEntry(const nat_table_entry *rule)\n{\n\tint cnt = 0;\n\tIPACMDBG(\"%s() %d\\n\", __FUNCTION__, __LINE__);\n\n\tIPACMDBG(\"Received below nat entry for deletion\\n\");\n\tiptodot(\"Private IP\", rule->private_ip);\n\tiptodot(\"Target IP\", rule->target_ip);\n\tIPACMDBG(\"Private Port: %d\\t Target Port: %d\\t\", rule->private_port, rule->target_port);\n\tIPACMDBG(\"protocolcol: %d\\n\", rule->protocol);\n\n\tfor(; cnt < max_entries; cnt++)\n\t{\n\t\tif(cache[cnt].private_ip == rule->private_ip &&\n\t\t\t cache[cnt].target_ip == rule->target_ip &&\n\t\t\t cache[cnt].private_port ==  rule->private_port  &&\n\t\t\t cache[cnt].target_port == rule->target_port &&\n\t\t\t cache[cnt].protocol == rule->protocol)\n\t\t{\n\n\t\t\tif(cache[cnt].enabled == true)\n\t\t\t{\n\t\t\t\tif(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"%s() %d deletion failed\\n\", __FUNCTION__, __LINE__);\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG(\"Deleted Nat entry(%d) Successfully\\n\", cnt);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Deleted Nat entry(%d) only from cache\\n\", cnt);\n\t\t\t}\n\n\t\t\tmemset(&cache[cnt], 0, sizeof(cache[cnt]));\n\t\t\tcurCnt--;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/* Add new entry to the nat table on new connection */\nint NatApp::AddEntry(const nat_table_entry *rule)\n{\n\n\tint cnt = 0;\n\tipa_nat_ipv4_rule nat_rule;\n\tIPACMDBG(\"%s() %d\\n\", __FUNCTION__, __LINE__);\n\n\tCHK_TBL_HDL();\n\n\tIPACMDBG(\"Received below nat entry for addition\\n\");\n\tiptodot(\"Private IP\", rule->private_ip);\n\tiptodot(\"Target IP\", rule->target_ip);\n\tIPACMDBG(\"Private Port: %d\\t Target Port: %d\\t\", rule->private_port, rule->target_port);\n\tIPACMDBG(\"protocolcol: %d\\n\", rule->protocol);\n\n\tif(isAlgPort(rule->protocol, rule->private_port) ||\n\t\t isAlgPort(rule->protocol, rule->target_port))\n\t{\n\t\tIPACMERR(\"connection using ALG Port. Dont insert into nat table\\n\");\n\t\treturn -1;\n\t}\n\n\tif(rule->private_ip == 0 ||\n\t\t rule->target_ip == 0 ||\n\t\t rule->private_port == 0  ||\n\t\t rule->target_port == 0 ||\n\t\t rule->protocol == 0)\n\t{\n\t\tIPACMERR(\"Invalid Connection, ignoring it\\n\");\n\t\treturn 0;\n\t}\n\n\tif(!ChkForDup(rule))\n\t{\n\t\tfor(; cnt < max_entries; cnt++)\n\t\t{\n\t\t\tif(cache[cnt].private_ip == 0 &&\n\t\t\t\t cache[cnt].target_ip == 0 &&\n\t\t\t\t cache[cnt].private_port == 0  &&\n\t\t\t\t cache[cnt].target_port == 0 &&\n\t\t\t\t cache[cnt].protocol == 0)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif(max_entries == cnt)\n\t\t{\n\t\t\tIPACMERR(\"Error: Unable to add, reached maximum rules\\n\");\n\t\t\treturn -1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tnat_rule.private_ip = rule->private_ip;\n\t\t\tnat_rule.target_ip = rule->target_ip;\n\t\t\tnat_rule.target_port = rule->target_port;\n\t\t\tnat_rule.private_port = rule->private_port;\n\t\t\tnat_rule.public_port = rule->public_port;\n\t\t\tnat_rule.protocol = rule->protocol;\n\n\t\t\tif(isPwrSaveIf(rule->private_ip) ||\n\t\t\t\t isPwrSaveIf(rule->target_ip))\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Device is Power Save mode: Dont insert into nat table but cache\\n\");\n\t\t\t\tcache[cnt].enabled = false;\n\t\t\t\tcache[cnt].rule_hdl = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\n\t\t\t\tif(ipa_nat_add_ipv4_rule(nat_table_hdl, &nat_rule, &cache[cnt].rule_hdl) < 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to add the rule\\n\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\n\t\t\t\tcache[cnt].enabled = true;\n\t\t\t}\n\n\t\t\tcache[cnt].private_ip = rule->private_ip;\n\t\t\tcache[cnt].target_ip = rule->target_ip;\n\t\t\tcache[cnt].target_port = rule->target_port;\n\t\t\tcache[cnt].private_port = rule->private_port;\n\t\t\tcache[cnt].protocol = rule->protocol;\n\t\t\tcache[cnt].timestamp = 0;\n\t\t\tcache[cnt].public_port = rule->public_port;\n\t\t\tcache[cnt].dst_nat = rule->dst_nat;\n\t\t\tcurCnt++;\n\t\t}\n\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"Duplicate rule. Ignore it\\n\");\n\t\treturn -1;\n\t}\n\n\tif(cache[cnt].enabled == true)\n\t{\n\t\tIPACMDBG(\"Added rule(%d) successfully\\n\", cnt);\n\t}\n  else\n  {\n    IPACMDBG(\"Cached rule(%d) successfully\\n\", cnt);\n  }\n\n\treturn 0;\n}\n\nvoid NatApp::UpdateCTUdpTs(nat_table_entry *rule, uint32_t new_ts)\n{\n\tint ret;\n\n\tiptodot(\"Private IP:\", rule->private_ip);\n\tiptodot(\"Target IP:\",  rule->target_ip);\n\tIPACMDBG(\"Private Port: %d, Target Port: %d\\n\", rule->private_port, rule->target_port);\n\n\tif(!ct_hdl)\n\t{\n\t\tct_hdl = nfct_open(CONNTRACK, 0);\n\t\tif(!ct_hdl)\n\t\t{\n\t\t\tPERROR(\"nfct_open\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif(!ct)\n\t{\n\t\tct = nfct_new();\n\t\tif(!ct)\n\t\t{\n\t\t\tPERROR(\"nfct_new\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\tnfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET);\n\tif(rule->protocol == IPPROTO_UDP)\n\t{\n\t\tnfct_set_attr_u8(ct, ATTR_L4PROTO, rule->protocol);\n\t\tnfct_set_attr_u32(ct, ATTR_TIMEOUT, udp_timeout);\n\t}\n\telse\n\t{\n\t\tnfct_set_attr_u8(ct, ATTR_L4PROTO, rule->protocol);\n\t\tnfct_set_attr_u32(ct, ATTR_TIMEOUT, tcp_timeout);\n\t}\n\n\tif(rule->dst_nat == false)\n\t{\n\t\tnfct_set_attr_u32(ct, ATTR_IPV4_SRC, htonl(rule->private_ip));\n\t\tnfct_set_attr_u16(ct, ATTR_PORT_SRC, htons(rule->private_port));\n\n\t\tnfct_set_attr_u32(ct, ATTR_IPV4_DST, htonl(rule->target_ip));\n\t\tnfct_set_attr_u16(ct, ATTR_PORT_DST, htons(rule->target_port));\n\n\t\tIPACMDBG(\"dst nat is not set\\n\");\n\t}\n\telse\n\t{\n\t\tnfct_set_attr_u32(ct, ATTR_IPV4_SRC, htonl(rule->target_ip));\n\t\tnfct_set_attr_u16(ct, ATTR_PORT_SRC, htons(rule->target_port));\n\n\t\tnfct_set_attr_u32(ct, ATTR_IPV4_DST, htonl(pub_ip_addr));\n\t\tnfct_set_attr_u16(ct, ATTR_PORT_DST, htons(rule->public_port));\n\n\t\tIPACMDBG(\"dst nat is set\\n\");\n\t}\n\n\tiptodot(\"Source IP:\", nfct_get_attr_u32(ct, ATTR_IPV4_SRC));\n\tiptodot(\"Destination IP:\",  nfct_get_attr_u32(ct, ATTR_IPV4_DST));\n\tIPACMDBG(\"Source Port: %d, Destination Port: %d\\n\",\n\t\t\t\t\t nfct_get_attr_u16(ct, ATTR_PORT_SRC), nfct_get_attr_u16(ct, ATTR_PORT_DST));\n\n\tIPACMDBG(\"updating %d connection with time: %d\\n\",\n\t\t\t\t\t rule->protocol, nfct_get_attr_u32(ct, ATTR_TIMEOUT));\n\n\tret = nfct_query(ct_hdl, NFCT_Q_UPDATE, ct);\n\tif(ret == -1)\n\t{\n\t\tPERROR(\"unable to update time stamp\");\n\t}\n\telse\n\t{\n\t\trule->timestamp = new_ts;\n\t\tIPACMDBG(\"Updated time stamp successfully\\n\");\n\t}\n\n\treturn;\n}\n\nvoid NatApp::UpdateUDPTimeStamp()\n{\n\tint cnt;\n\tuint32_t ts;\n\n\tfor(cnt = 0; cnt < max_entries; cnt++)\n\t{\n\t\tts = 0;\n\t\tif(cache[cnt].enabled == true)\n\t\t{\n\t\t\tIPACMDBG(\"\\n\");\n\t\t\tif(ipa_nat_query_timestamp(nat_table_hdl, cache[cnt].rule_hdl, &ts) < 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to retrieve timeout for rule hanle: %d\\n\", cache[cnt].rule_hdl);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif(cache[cnt].timestamp == ts)\n\t\t\t{\n\t\t\t\tIPACMDBG(\"No Change in Time Stamp: cahce:%d, ipahw:%d\\n\",\n\t\t\t\t\t\t\t\t                  cache[cnt].timestamp, ts);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tUpdateCTUdpTs(&cache[cnt], ts);\n\t\t} /* end of outer if */\n\n\t} /* end of for loop */\n\n}\n\nbool NatApp::isAlgPort(uint8_t proto, uint16_t port)\n{\n\tint cnt;\n\tfor(cnt = 0; cnt < nALGPort; cnt++)\n\t{\n\t\tif(proto == pALGPorts[cnt].protocol &&\n\t\t\t port == pALGPorts[cnt].port)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nbool NatApp::isPwrSaveIf(uint32_t ip_addr)\n{\n\tint cnt;\n\n\tfor(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)\n\t{\n\t\tif(0 != PwrSaveIfs[cnt] &&\n\t\t\t ip_addr == PwrSaveIfs[cnt])\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nint NatApp::UpdatePwrSaveIf(uint32_t client_lan_ip)\n{\n\tint cnt;\n\tIPACMDBG(\"Received IP address: 0x%x\\n\", client_lan_ip);\n\n\tif(client_lan_ip == INVALID_IP_ADDR)\n\t{\n\t\tIPACMERR(\"Invalid ip address received\\n\");\n\t\treturn -1;\n\t}\n\n\t/* check for duplicate events */\n\tfor(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)\n\t{\n\t\tif(PwrSaveIfs[cnt] == client_lan_ip)\n\t\t{\n\t\t\tIPACMDBG(\"The client 0x%x is already in power save\\n\", client_lan_ip);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\n\tfor(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)\n\t{\n\t\tif(PwrSaveIfs[cnt] == 0)\n\t\t{\n\t\t\tPwrSaveIfs[cnt] = client_lan_ip;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor(cnt = 0; cnt < max_entries; cnt++)\n\t{\n\t\tif(cache[cnt].private_ip == client_lan_ip &&\n\t\t\t cache[cnt].enabled == true)\n\t\t{\n\t\t\tif(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to delete the rule\\n\");\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tcache[cnt].enabled = false;\n\t\t\tcache[cnt].rule_hdl = 0;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nint NatApp::ResetPwrSaveIf(uint32_t client_lan_ip)\n{\n\tint cnt;\n\tipa_nat_ipv4_rule nat_rule;\n\n\tIPACMDBG(\"Received ip address: 0x%x\\n\", client_lan_ip);\n\n\tif(client_lan_ip == INVALID_IP_ADDR)\n\t{\n\t\tIPACMERR(\"Invalid ip address received\\n\");\n\t\treturn -1;\n\t}\n\n\tfor(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)\n\t{\n\t\tif(PwrSaveIfs[cnt] == client_lan_ip)\n\t\t{\n\t\t\tPwrSaveIfs[cnt] = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor(cnt = 0; cnt < max_entries; cnt++)\n\t{\n\t\tIPACMDBG(\"cache (%d): enable %d, ip 0x%x\\n\", cnt, cache[cnt].enabled, cache[cnt].private_ip);\n\n\t\tif(cache[cnt].private_ip == client_lan_ip &&\n\t\t\t cache[cnt].enabled == false)\n\t\t{\n\t\t\tmemset(&nat_rule, 0 , sizeof(nat_rule));\n\t\t\tnat_rule.private_ip = cache[cnt].private_ip;\n\t\t\tnat_rule.target_ip = cache[cnt].target_ip;\n\t\t\tnat_rule.target_port = cache[cnt].target_port;\n\t\t\tnat_rule.private_port = cache[cnt].private_port;\n\t\t\tnat_rule.public_port = cache[cnt].public_port;\n\t\t\tnat_rule.protocol = cache[cnt].protocol;\n\n\t\t\tif(ipa_nat_add_ipv4_rule(nat_table_hdl, &nat_rule, &cache[cnt].rule_hdl) < 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to add the rule delete from cache\\n\");\n\t\t\t\tmemset(&cache[cnt], 0, sizeof(cache[cnt]));\n\t\t\t\tcurCnt--;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcache[cnt].enabled = true;\n\n\t\t\tIPACMDBG(\"On power reset added below rule successfully\\n\");\n\t\t\tiptodot(\"Private IP\", nat_rule.private_ip);\n\t\t\tiptodot(\"Target IP\", nat_rule.target_ip);\n\t\t\tIPACMDBG(\"Private Port:%d \\t Target Port: %d\\t\", nat_rule.private_port, nat_rule.target_port);\n\t\t\tIPACMDBG(\"Public Port:%d\\n\", nat_rule.public_port);\n\t\t\tIPACMDBG(\"protocol: %d\\n\", nat_rule.protocol);\n\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nvoid NatApp::UpdateTcpUdpTo(uint32_t new_value, int proto)\n{\n\tif(proto == IPPROTO_TCP)\n\t{\n\t\ttcp_timeout = new_value;\n\t\tIPACMDBG(\"new nat tcp timeout value: %d\\n\", tcp_timeout);\n\t}\n\telse if(proto == IPPROTO_UDP)\n\t{\n\t\tudp_timeout = new_value;\n\t\tIPACMDBG(\"new nat udp timeout value: %d\\n\", udp_timeout);\n\t}\n}\n\nuint32_t NatApp::GetTableHdl(uint32_t in_ip_addr)\n{\n\tif(in_ip_addr == pub_ip_addr)\n\t{\n\t\treturn nat_table_hdl;\n\t}\n\n\treturn -1;\n}\n\nvoid NatApp::AddTempEntry(const nat_table_entry *new_entry)\n{\n\tint cnt;\n\n\tIPACMDBG(\"Received below nat entry\\n\");\n\tiptodot(\"Private IP\", new_entry->private_ip);\n\tiptodot(\"Target IP\", new_entry->target_ip);\n\tIPACMDBG(\"Private Port: %d\\t Target Port: %d\\t\", new_entry->private_port, new_entry->target_port);\n\tIPACMDBG(\"protocolcol: %d\\n\", new_entry->protocol);\n\n\tfor(cnt=0; cnt<MAX_TEMP_ENTRIES; cnt++)\n\t{\n\t\tif(temp[cnt].private_ip == 0 &&\n\t\t\t temp[cnt].target_ip == 0)\n\t\t{\n\t\t\tmemcpy(&temp[cnt], new_entry, sizeof(nat_table_entry));\n\t\t\tIPACMDBG(\"Added Temp Entry\\n\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\tIPACMDBG(\"unable to add temp entry, cache full\\n\");\n\treturn;\n}\n\nvoid NatApp::DeleteTempEntry(const nat_table_entry *entry)\n{\n\tint cnt;\n\n\tIPACMDBG(\"Received below nat entry\\n\");\n\tiptodot(\"Private IP\", entry->private_ip);\n\tiptodot(\"Target IP\", entry->target_ip);\n\tIPACMDBG(\"Private Port: %d\\t Target Port: %d\\t\", entry->private_port, entry->target_port);\n\tIPACMDBG(\"protocolcol: %d\\n\", entry->protocol);\n\n\tfor(cnt=0; cnt<MAX_TEMP_ENTRIES; cnt++)\n\t{\n\t\tif(temp[cnt].private_ip == entry->private_ip &&\n\t\t\t temp[cnt].target_ip == entry->target_ip &&\n\t\t\t temp[cnt].private_port ==  entry->private_port  &&\n\t\t\t temp[cnt].target_port == entry->target_port &&\n\t\t\t temp[cnt].protocol == entry->protocol)\n\t\t{\n\t\t\tmemset(&temp[cnt], 0, sizeof(nat_table_entry));\n\t\t\tIPACMDBG(\"Delete Temp Entry\\n\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\tIPACMDBG(\"No Such Entry exists\\n\");\n\treturn;\n}\n\nvoid NatApp::FlushTempEntries(uint32_t ip_addr, bool isAdd)\n{\n\tint cnt;\n\tint ret;\n\n\tIPACMDBG(\"Received below with isAdd:%d\\n\", isAdd);\n\tiptodot(\"IP Address:\", ip_addr);\n\n\tfor(cnt=0; cnt<MAX_TEMP_ENTRIES; cnt++)\n\t{\n\t\tif(temp[cnt].private_ip == ip_addr ||\n\t\t\t temp[cnt].target_ip == ip_addr)\n\t\t{\n\t\t\tif(isAdd)\n\t\t\t{\n\t\t\t\tif(temp[cnt].public_ip == pub_ip_addr)\n\t\t\t\t{\n\t\t\t\t\tret = AddEntry(&temp[cnt]);\n\t\t\t\t\tif(ret)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to add temp entry: %d\\n\", ret);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemset(&temp[cnt], 0, sizeof(nat_table_entry));\n\t\t}\n\t}\n\n\treturn;\n}\n\nint NatApp::DelEntriesOnClntDiscon(uint32_t ip_addr)\n{\n \tint cnt, tmp = curCnt;\n\tIPACMDBG(\"Received IP address: 0x%x\\n\", ip_addr);\n\n\tif(ip_addr == INVALID_IP_ADDR)\n\t{\n\t\tIPACMERR(\"Invalid ip address received\\n\");\n\t\treturn -1;\n\t}\n\n\n  for(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)\n  {\n    if(PwrSaveIfs[cnt] == ip_addr)\n    {\n      PwrSaveIfs[cnt] = 0;\n      IPACMDBG(\"Remove %d power save entry\\n\", cnt);\n      break;\n    }\n  }\n\n  for(cnt = 0; cnt < max_entries; cnt++)\n  {\n\tif(cache[cnt].private_ip == ip_addr)\n\t{\n\t\tif(cache[cnt].enabled == true)\n      \t\t{\n\t\t\tif(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to delete the rule\\n\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG(\"won't delete the rule\\n\");\n\t\t\t\tcache[cnt].enabled = false;\n\t\t        }\n\t        }\n\t\tIPACMDBG(\"won't delete the rule for entry %d, enabled %d\\n\",cnt, cache[cnt].enabled);\n\t}\n  }\n  IPACMDBG(\"Deleted %d entries\\n\", (tmp - curCnt));\n  return 0;\n}\n\nint NatApp::DelEntriesOnSTAClntDiscon(uint32_t ip_addr)\n{\n\tint cnt, tmp = curCnt;\n\tIPACMDBG(\"Received IP address: 0x%x\\n\", ip_addr);\n\n\tif(ip_addr == INVALID_IP_ADDR)\n\t{\n\t\tIPACMERR(\"Invalid ip address received\\n\");\n\t\treturn -1;\n\t}\n\n\n\tfor(cnt = 0; cnt < max_entries; cnt++)\n\t{\n\t\tif(cache[cnt].target_ip == ip_addr)\n\t\t{\n\t\t\tif(cache[cnt].enabled == true)\n\t\t\t{\n\t\t\t\tif(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to delete the rule\\n\");\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmemset(&cache[cnt], 0, sizeof(cache[cnt]));\n\t\t\tcurCnt--;\n\t\t}\n\t}\n\n\tIPACMDBG(\"Deleted %d entries\\n\", (tmp - curCnt));\n\treturn 0;\n}\n\nvoid NatApp::CacheEntry(const nat_table_entry *rule)\n{\n\tint cnt;\n\tif(rule->private_ip == 0 ||\n\t\t rule->target_ip == 0 ||\n\t\t rule->private_port == 0  ||\n\t\t rule->target_port == 0 ||\n\t\t rule->protocol == 0)\n\t{\n\t\tIPACMERR(\"Invalid Connection, ignoring it\\n\");\n\t\treturn;\n\t}\n\n\tif(!ChkForDup(rule))\n\t{\n\t\tfor(; cnt < max_entries; cnt++)\n\t\t{\n\t\t\tif(cache[cnt].private_ip == 0 &&\n\t\t\t\t cache[cnt].target_ip == 0 &&\n\t\t\t\t cache[cnt].private_port == 0  &&\n\t\t\t\t cache[cnt].target_port == 0 &&\n\t\t\t\t cache[cnt].protocol == 0)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif(max_entries == cnt)\n\t\t{\n\t\t\tIPACMERR(\"Error: Unable to add, reached maximum rules\\n\");\n\t\t\treturn;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcache[cnt].enabled = false;\n\t\t\tcache[cnt].rule_hdl = 0;\n\t\t\tcache[cnt].private_ip = rule->private_ip;\n\t\t\tcache[cnt].target_ip = rule->target_ip;\n\t\t\tcache[cnt].target_port = rule->target_port;\n\t\t\tcache[cnt].private_port = rule->private_port;\n\t\t\tcache[cnt].protocol = rule->protocol;\n\t\t\tcache[cnt].timestamp = 0;\n\t\t\tcache[cnt].public_port = rule->public_port;\n\t\t\tcache[cnt].dst_nat = rule->dst_nat;\n\t\t\tcurCnt++;\n\t\t}\n\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"Duplicate rule. Ignore it\\n\");\n\t\treturn;\n\t}\n\n\tIPACMDBG(\"Cached rule(%d) successfully\\n\", cnt);\n\treturn;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_EvtDispatcher.cpp",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_EvtDispatcher.cpp\n\n\t@brief\n\tThis file implements the IPAM event dispatcher functionality\n\n\t@Author\n\n*/\n#include <string.h>\n#include <pthread.h>\n#include <IPACM_EvtDispatcher.h>\n#include <IPACM_Neighbor.h>\n#include \"IPACM_CmdQueue.h\"\n#include \"IPACM_Defs.h\"\n\n\nextern pthread_mutex_t mutex;\nextern pthread_cond_t  cond_var;\n\ncmd_evts *IPACM_EvtDispatcher::head = NULL;\nextern uint32_t ipacm_event_stats[IPACM_EVENT_MAX];\n\nint IPACM_EvtDispatcher::PostEvt\n(\n\t ipacm_cmd_q_data *data\n)\n{\n\tMessage *item = NULL;\n\tMessageQueue *MsgQueue = NULL;\n\n\tMsgQueue = MessageQueue::getInstance();\n\tif(MsgQueue == NULL)\n\t{\n\t\tIPACMERR(\"unable to retrieve MsgQueue instance\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\titem = new Message();\n\tif(item == NULL)\n\t{\n\t\tIPACMERR(\"unable to create new message item\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG(\"Populating item to post to queue\\n\");\n\titem->evt.callback_ptr = IPACM_EvtDispatcher::ProcessEvt;\n\tmemcpy(&item->evt.data, data, sizeof(ipacm_cmd_q_data));\n\n\tif(pthread_mutex_lock(&mutex) != 0)\n\t{\n\t\tIPACMERR(\"unable to lock the mutex\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG(\"Enqueing item\\n\");\n\tMsgQueue->enqueue(item);\n\tIPACMDBG(\"Enqueued item %p\\n\", item);\n\n\tif(pthread_cond_signal(&cond_var) != 0)\n\t{\n\t\tIPACMDBG(\"unable to lock the mutex\\n\");\n\t\t/* Release the mutex before you return failure */\n\t\tif(pthread_mutex_unlock(&mutex) != 0)\n\t\t{\n\t\t\tIPACMERR(\"unable to unlock the mutex\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(pthread_mutex_unlock(&mutex) != 0)\n\t{\n\t\tIPACMERR(\"unable to unlock the mutex\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\nvoid IPACM_EvtDispatcher::ProcessEvt(ipacm_cmd_q_data *data)\n{\n\n\tcmd_evts *tmp = head, tmp1;\n\n\tif(head == NULL)\n\t{\n\t\tIPACMDBG(\"Queue is empty\\n\");\n\t}\n\n\twhile(tmp != NULL)\n\t{\n\t        memcpy(&tmp1, tmp, sizeof(tmp1));\n\t\tif(data->event == tmp1.event)\n\t\t{\n\t\t\tipacm_event_stats[data->event]++;\n\t\t\ttmp1.obj->event_callback(data->event, data->evt_data);\n\t\t\tIPACMDBG(\" Find matched registered events\\n\");\n\t\t}\n\t        tmp = tmp1.next;\n\t}\n\n\tIPACMDBG(\" Finished process events\\n\");\n\t\t\t\n\tif(data->evt_data != NULL)\n\t{\n\t\tIPACMDBG(\"free the event:%d data: %p\\n\", data->event, data->evt_data);\n\t\tfree(data->evt_data);\n\t}\n\treturn;\n}\n\nint IPACM_EvtDispatcher::registr(ipa_cm_event_id event, IPACM_Listener *obj)\n{\n\tcmd_evts *tmp = head,*nw;\n\n\tnw = (cmd_evts *)malloc(sizeof(cmd_evts));\n\tif(nw != NULL)\n\t{\n\t\tnw->event = event;\n\t\tnw->obj = obj;\n\t\tnw->next = NULL;\n\t}\n\telse\n\t{\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(head == NULL)\n\t{\n\t\thead = nw;\n\t}\n\telse\n\t{\n\t\twhile(tmp->next)\n\t\t{\n\t\t\ttmp = tmp->next;\n\t\t}\n\t\ttmp->next = nw;\n\t}\n\treturn IPACM_SUCCESS;\n}\n\n\nint IPACM_EvtDispatcher::deregistr(IPACM_Listener *param)\n{\n\tcmd_evts *tmp = head,*tmp1,*prev = head;\n\n\twhile(tmp != NULL)\n\t{\n\t\tif(tmp->obj == param)\n\t\t{\n\t\t\ttmp1 = tmp;\n\t\t\tif(tmp == head)\n\t\t\t{\n\t\t\t\thead = head->next;\n\t\t\t}\n\t\t\telse if(tmp->next == NULL)\n\t\t\t{\n\t\t\t\tprev->next = NULL;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprev->next = tmp->next;\n\t\t\t}\n\n\t\t\ttmp = tmp->next;\n\t\t\tfree(tmp1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprev = tmp;\n\t\t\ttmp = tmp->next;\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Filtering.cpp",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Filtering.cpp\n\n\t@brief\n\tThis file implements the IPACM filtering functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#include <unistd.h>\n#include <sys/ioctl.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"IPACM_Filtering.h\"\n#include <IPACM_Log.h>\n#include \"IPACM_Defs.h\"\n\n\nconst char *IPACM_Filtering::DEVICE_NAME = \"/dev/ipa\";\n\nIPACM_Filtering::IPACM_Filtering()\n{\n\tfd = open(DEVICE_NAME, O_RDWR);\n\tif (fd < 0)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", DEVICE_NAME);\n\t}\n}\n\nIPACM_Filtering::~IPACM_Filtering()\n{\n\tclose(fd);\n}\n\nbool IPACM_Filtering::DeviceNodeIsOpened()\n{\n\treturn fd;\n}\n\nbool IPACM_Filtering::AddFilteringRule(struct ipa_ioc_add_flt_rule const *ruleTable)\n{\n\tint retval = 0;\n\n\tIPACMDBG(\"Printing filter add attributes\\n\");\n\tIPACMDBG(\"ip type: %d\\n\", ruleTable->ip);\n\tIPACMDBG(\"Number of rules: %d\\n\", ruleTable->num_rules);\n\tIPACMDBG(\"End point: %d and global value: %d\\n\", ruleTable->ep, ruleTable->global);\n\tIPACMDBG(\"commit value: %d\\n\", ruleTable->commit);\n\tfor (int cnt=0; cnt<ruleTable->num_rules; cnt++)\n\t{\n\t\tIPACMDBG(\"Filter rule:%d attrib mask: 0x%x\\n\",\n\t\t\t\t\t\t cnt, \n\t\t\t\t\t\t ruleTable->rules[cnt].rule.attrib.attrib_mask);\n\t}\n\n\tretval = ioctl(fd, IPA_IOC_ADD_FLT_RULE, ruleTable);\n\tif (retval != 0)\n\t{\n\t\tIPACMERR(\"Failed adding Filtering rule %p\\n\", ruleTable);\n\t\tPERROR(\"unable to add filter rule:\");\n\n\t\tfor (int cnt = 0; cnt < ruleTable->num_rules; cnt++)\n\t\t{\n\t\t\tif (ruleTable->rules[cnt].status != 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Adding Filter rule:%d failed with status:%d\\n\",\n\t\t\t\t\t\t\t\t cnt, ruleTable->rules[cnt].status);\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tfor (int cnt = 0; cnt<ruleTable->num_rules; cnt++)\n\t{\n\t\tif(ruleTable->rules[cnt].status != 0)\n\t\t{\n\t\t\tIPACMERR(\"Adding Filter rule:%d failed with status:%d\\n\",\n\t\t\t\t\t\t\t cnt, ruleTable->rules[cnt].status);\n\t\t}\n\t}\n\n\tIPACMDBG(\"Added Filtering rule %p\\n\", ruleTable);\n\treturn true;\n}\n\nbool IPACM_Filtering::DeleteFilteringRule(struct ipa_ioc_del_flt_rule *ruleTable)\n{\n\tint retval = 0;\n\n\tretval = ioctl(fd, IPA_IOC_DEL_FLT_RULE, ruleTable);\n\tif (retval != 0)\n\t{\n\t\tIPACMERR(\"Failed deleting Filtering rule %p\\n\", ruleTable);\n\t\treturn false;\n\t}\n\n\tIPACMDBG(\"Deleted Filtering rule %p\\n\", ruleTable);\n\treturn true;\n}\n\nbool IPACM_Filtering::Commit(enum ipa_ip_type ip)\n{\n\tint retval = 0;\n\n\tretval = ioctl(fd, IPA_IOC_COMMIT_FLT, ip);\n\tif (retval != 0)\n\t{\n\t\tIPACMERR(\"failed committing Filtering rules.\\n\");\n\t\treturn false;\n\t}\n\n\tIPACMDBG(\"Committed Filtering rules to IPA HW.\\n\");\n\treturn true;\n}\n\nbool IPACM_Filtering::Reset(enum ipa_ip_type ip)\n{\n\tint retval = 0;\n\n\tretval = ioctl(fd, IPA_IOC_RESET_FLT, ip);\n\tretval |= ioctl(fd, IPA_IOC_COMMIT_FLT, ip);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"failed resetting Filtering block.\\n\");\n\t\treturn false;\n\t}\n\n\tIPACMDBG(\"Reset command issued to IPA Filtering block.\\n\");\n\treturn true;\n}\n\nbool IPACM_Filtering::DeleteFilteringHdls\n(\n\t uint32_t *flt_rule_hdls,\n\t ipa_ip_type ip,\n\t uint8_t num_rules\n)\n{\n\tstruct ipa_ioc_del_flt_rule *flt_rule;\n\tbool res = true;\n\tint len = 0, cnt = 0;\n        const uint8_t UNIT_RULES = 1;\n\n\tlen = (sizeof(struct ipa_ioc_del_flt_rule)) + (UNIT_RULES * sizeof(struct ipa_flt_rule_del));\n\tflt_rule = (struct ipa_ioc_del_flt_rule *)malloc(len);\n\tif (flt_rule == NULL)\n\t{\n\t\tIPACMERR(\"unable to allocate memory for del filter rule\\n\");\n\t\treturn false;\n\t}\n\n\tfor (cnt = 0; cnt < num_rules; cnt++)\n\t{\n\t    memset(flt_rule, 0, len);\n\t    flt_rule->commit = 1;\n\t    flt_rule->num_hdls = UNIT_RULES;\n\t    flt_rule->ip = ip;\n\n\t    if (flt_rule_hdls[cnt] == 0)\n\t    {\n\t\t   IPACMERR(\"invalid filter handle passed, ignoring it: %d\\n\", cnt)\n\t    }\n            else\n\t    {\n\n\t\t   flt_rule->hdl[0].status = -1;\n\t\t   flt_rule->hdl[0].hdl = flt_rule_hdls[cnt];\n\t\t   IPACMDBG(\"Deleting filter hdl:(0x%x) with ip type: %d\\n\", flt_rule_hdls[cnt], ip);\n\n\t           if (DeleteFilteringRule(flt_rule) == false)\n\t           {\n\t\t        PERROR(\"Filter rule deletion failed!\\n\");\n\t\t        res = false;\n\t\t        goto fail;\n\t           }\n\t\t   else\n\t           {\n\n\t\t        if (flt_rule->hdl[0].status != 0)\n\t\t        {\n\t\t\t     IPACMERR(\"Filter rule hdl 0x%x deletion failed with error:%d\\n\",\n\t\t        \t\t\t\t\t flt_rule->hdl[0].hdl, flt_rule->hdl[0].status);\n\t\t\t     res = false;\n\t\t\t     goto fail;\n\t\t        }\n\t\t   \n\t\t   }\t   \n\t    }\n\t}\n\nfail:\n\tfree(flt_rule);\n\n\treturn res;\n}\n\nbool IPACM_Filtering::AddWanDLFilteringRule(struct ipa_ioc_add_flt_rule const *rule_table_v4, struct ipa_ioc_add_flt_rule const * rule_table_v6, uint8_t mux_id)\n{\n\tint ret = 0, cnt, num_rules = 0, pos = 0;\n\tipa_install_fltr_rule_req_msg_v01 qmi_rule_msg;\n\n\tint fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR);\n\tif(fd_wwan_ioctl < 0)\n\t{\n\t\tIPACMERR(\"Failed to open %s.\\n\",WWAN_QMI_IOCTL_DEVICE_NAME);\n\t\treturn false;\n\t}\n\n\tif(rule_table_v4 != NULL)\n\t{\n\t\tnum_rules += rule_table_v4->num_rules;\n\t\tIPACMDBG_H(\"Get %d WAN DL IPv4 filtering rules.\\n\", rule_table_v4->num_rules);\n\t}\n\tif(rule_table_v6 != NULL)\n\t{\n\t\tnum_rules += rule_table_v6->num_rules;\n\t\tIPACMDBG_H(\"Get %d WAN DL IPv6 filtering rules.\\n\", rule_table_v6->num_rules);\n\t}\n\n\tif(num_rules > QMI_IPA_MAX_FILTERS_V01)\n\t{\n\t\tIPACMERR(\"The number of filtering rules exceed limit.\\n\");\n\t\tclose(fd_wwan_ioctl);\n\t\treturn false;\n\t}\n\telse\n\t{\n\t\tmemset(&qmi_rule_msg, 0, sizeof(qmi_rule_msg));\n\n\t\tif (num_rules > 0)\n\t\t{\n\t\t\tqmi_rule_msg.filter_spec_list_valid = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tqmi_rule_msg.filter_spec_list_valid = false;\n\t\t}\n\t\tqmi_rule_msg.filter_spec_list_len = num_rules;\n\t\tqmi_rule_msg.source_pipe_index_valid = 0;\n\n\t\tIPACMDBG_H(\"Get %d WAN DL filtering rules in total.\\n\", num_rules);\n\t\t\n\t\tif(rule_table_v4 != NULL)\n\t\t{\n\t\t\tfor(cnt = rule_table_v4->num_rules - 1; cnt >= 0; cnt--)\n\t\t\t{\n\t\t\t\tif (pos < QMI_IPA_MAX_FILTERS_V01)\n\t\t\t\t{\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].filter_spec_identifier = pos;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].ip_type = QMI_IPA_IP_TYPE_V4_V01;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].filter_action = GetQmiFilterAction(rule_table_v4->rules[cnt].rule.action);\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].is_routing_table_index_valid = 1;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].route_table_index = rule_table_v4->rules[cnt].rule.rt_tbl_idx;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].is_mux_id_valid = 1;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].mux_id = mux_id;\n\n\t\t\t\tmemcpy(&qmi_rule_msg.filter_spec_list[pos].filter_rule, &rule_table_v4->rules[cnt].rule.eq_attrib, \n\t\t\t\t\tsizeof(struct ipa_filter_rule_type_v01));\n\t\t\t\tpos++;\n\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" QMI only support max %d rules, current (%d)\\n \",QMI_IPA_MAX_FILTERS_V01, pos);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif(rule_table_v6 != NULL)\n\t\t{\n\t\t\tfor(cnt = rule_table_v6->num_rules - 1; cnt >= 0; cnt--)\n\t\t\t{\n\t\t\t\tif (pos < QMI_IPA_MAX_FILTERS_V01)\n\t\t\t\t{\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].filter_spec_identifier = pos;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].ip_type = QMI_IPA_IP_TYPE_V6_V01;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].filter_action = GetQmiFilterAction(rule_table_v6->rules[cnt].rule.action);\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].is_routing_table_index_valid = 1;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].route_table_index = rule_table_v6->rules[cnt].rule.rt_tbl_idx;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].is_mux_id_valid = 1;\n\t\t\t\tqmi_rule_msg.filter_spec_list[pos].mux_id = mux_id;\n\n\t\t\t\tmemcpy(&qmi_rule_msg.filter_spec_list[pos].filter_rule, &rule_table_v6->rules[cnt].rule.eq_attrib, \n\t\t\t\t\tsizeof(struct ipa_filter_rule_type_v01));\n\t\t\t\tpos++;\n\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" QMI only support max %d rules, current (%d)\\n \",QMI_IPA_MAX_FILTERS_V01, pos);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE, &qmi_rule_msg);\n\t\tif (ret != 0)\n\t\t{\n\t\t\tIPACMERR(\"Failed adding Filtering rule %p with ret %d\\n \", &qmi_rule_msg, ret);\n\t\t\tclose(fd_wwan_ioctl);\n\t\t\treturn false;\n\t\t}\n\t}\n\tIPACMDBG(\"Added Filtering rule %p\\n\", &qmi_rule_msg);\n\tclose(fd_wwan_ioctl);\n\treturn true;\n}\n\nbool IPACM_Filtering::SendFilteringRuleIndex(struct ipa_fltr_installed_notif_req_msg_v01* table)\n{\n\tint ret = 0;\n\tint fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR);\n\tif(fd_wwan_ioctl < 0)\n\t{\n\t\tIPACMERR(\"Failed to open %s.\\n\",WWAN_QMI_IOCTL_DEVICE_NAME);\n\t\treturn false;\n\t}\n\n\tret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_INDEX, table);\n\tif (ret != 0)\n\t{\n\t\tIPACMERR(\"Failed adding filtering rule index %p with ret %d\\n\", table, ret);\n\t\tclose(fd_wwan_ioctl);\n\t\treturn false;\n\t}\n\n\tIPACMDBG(\"Added Filtering rule index %p\\n\", table);\n\tclose(fd_wwan_ioctl);\n\treturn true;\n}\n\nipa_filter_action_enum_v01 IPACM_Filtering::GetQmiFilterAction(ipa_flt_action action)\n{\n\tswitch(action)\n\t{\n\tcase IPA_PASS_TO_ROUTING:\n\t\treturn QMI_IPA_FILTER_ACTION_ROUTING_V01;\n\n\tcase IPA_PASS_TO_SRC_NAT:\n\t\treturn QMI_IPA_FILTER_ACTION_SRC_NAT_V01;\n\n\tcase IPA_PASS_TO_DST_NAT:\n\t\treturn QMI_IPA_FILTER_ACTION_DST_NAT_V01;\n\n\tcase IPA_PASS_TO_EXCEPTION:\n\t\treturn QMI_IPA_FILTER_ACTION_EXCEPTION_V01;\n\n\tdefault:\n\t\treturn IPA_FILTER_ACTION_ENUM_MAX_ENUM_VAL_V01;\n\t}\n}\n\nbool IPACM_Filtering::ModifyFilteringRule(struct ipa_ioc_mdfy_flt_rule* ruleTable)\n{\n\tint i, ret = 0;\n\n\tIPACMDBG(\"Printing filtering add attributes\\n\");\n\tIPACMDBG(\"IP type: %d Number of rules: %d commit value: %d\\n\", ruleTable->ip, ruleTable->num_rules, ruleTable->commit);\n\n\tfor (i=0; i<ruleTable->num_rules; i++)\n\t{\n\t\tIPACMDBG(\"Filter rule:%d attrib mask: 0x%x\\n\", i, ruleTable->rules[i].rule.attrib.attrib_mask);\n\t}\n\n\tret = ioctl(fd, IPA_IOC_MDFY_FLT_RULE, ruleTable);\n\tif (ret != 0)\n\t{\n\t\tIPACMERR(\"Failed modifying filtering rule %p\\n\", ruleTable);\n\n\t\tfor (i = 0; i < ruleTable->num_rules; i++)\n\t\t{\n\t\t\tif (ruleTable->rules[i].status != 0)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Modifying filter rule %d failed\\n\", i);\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tIPACMDBG(\"Modified filtering rule %p\\n\", ruleTable);\n\treturn true;\n}\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Header.cpp",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#include <unistd.h>\n#include <sys/ioctl.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"IPACM_Header.h\"\n#include \"IPACM_Log.h\"\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n//All interaction through the driver are made through this inode.\nstatic const char *DEVICE_NAME = \"/dev/ipa\";\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nIPACM_Header::IPACM_Header()\n{\n\tm_fd = open(DEVICE_NAME, O_RDWR);\n\tif (-1 == m_fd)\n\t{\n\t\tIPACMERR(\"Failed to open %s in IPACM_Header test application constructor.\\n\", DEVICE_NAME);\n\t}\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nIPACM_Header::~IPACM_Header()\n{\n\tif (-1 != m_fd)\n\t{\n\t\tclose(m_fd);\n\t}\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nbool IPACM_Header::DeviceNodeIsOpened()\n{\n\treturn (-1 != m_fd);\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nbool IPACM_Header::AddHeader(struct ipa_ioc_add_hdr *pHeaderTableToAdd)\n{\n\tint nRetVal = 0;\n\t//call the Driver ioctl in order to add header\n\tnRetVal = ioctl(m_fd, IPA_IOC_ADD_HDR, pHeaderTableToAdd);\n\tIPACMDBG(\"return value: %d\\n\", nRetVal);\n\treturn (-1 != nRetVal);\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nbool IPACM_Header::DeleteHeader(struct ipa_ioc_del_hdr *pHeaderTableToDelete)\n{\n\tint nRetVal = 0;\n\t//call the Driver ioctl in order to remove header\n\tnRetVal = ioctl(m_fd, IPA_IOC_DEL_HDR, pHeaderTableToDelete);\n\tIPACMDBG(\"return value: %d\\n\", nRetVal);\n\treturn (-1 != nRetVal);\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nbool IPACM_Header::Commit()\n{\n\tint nRetVal = 0;\n\tnRetVal = ioctl(m_fd, IPA_IOC_COMMIT_HDR);\n\tIPACMDBG(\"return value: %d\\n\", nRetVal);\n\treturn true;\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nbool IPACM_Header::Reset()\n{\n\tint nRetVal = 0;\n\n\tnRetVal = ioctl(m_fd, IPA_IOC_RESET_HDR);\n\tnRetVal |= ioctl(m_fd, IPA_IOC_COMMIT_HDR);\n\tIPACMDBG(\"return value: %d\\n\", nRetVal);\n\treturn true;\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nbool IPACM_Header::GetHeaderHandle(struct ipa_ioc_get_hdr *pHeaderStruct)\n{\n\tint retval = 0;\n\n\tif (!DeviceNodeIsOpened()) return false;\n\n\tretval = ioctl(m_fd, IPA_IOC_GET_HDR, pHeaderStruct);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"IPA_IOC_GET_HDR ioctl failed, routingTable =0x%p, retval=0x%x.\\n\", pHeaderStruct, retval);\n\t\treturn false;\n\t}\n\n\tIPACMDBG(\"IPA_IOC_GET_HDR ioctl issued to IPA header insertion block.\\n\");\n\treturn true;\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nbool IPACM_Header::CopyHeader(struct ipa_ioc_copy_hdr *pCopyHeaderStruct)\n{\n\tint retval = 0;\n\n\tif (!DeviceNodeIsOpened()) return false;\n\n\tretval = ioctl(m_fd, IPA_IOC_COPY_HDR, pCopyHeaderStruct);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"IPA_IOC_COPY_HDR ioctl failed, retval=0x%x.\\n\", retval);\n\t\treturn false;\n\t}\n\n\tIPACMDBG(\"IPA_IOC_COPY_HDR ioctl issued to IPA header insertion block.\\n\");\n\treturn true;\n}\n\nbool IPACM_Header::DeleteHeaderHdl(uint32_t hdr_hdl)\n{\n\tconst uint8_t NUM_HDLS = 1;\n\tstruct ipa_ioc_del_hdr *pHeaderDescriptor = NULL;\n\tstruct ipa_hdr_del *hd_rule_entry;\n\tint len = 0;\n\tbool res = true;\n\n\tif (hdr_hdl == 0)\n\t{\n\t\tIPACMERR(\"Invalid header handle passed. Ignoring it\\n\");\n\t\treturn false;\n\t}\n\n\tlen = (sizeof(struct ipa_ioc_del_hdr)) + (NUM_HDLS * sizeof(struct ipa_hdr_del));\n\tpHeaderDescriptor = (struct ipa_ioc_del_hdr *)malloc(len);\n\tif (pHeaderDescriptor == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate memory for del header\\n\");\n\t\treturn false;\n\t}\n\n\tmemset(pHeaderDescriptor, 0, len);\n\tpHeaderDescriptor->commit = true;\n\tpHeaderDescriptor->num_hdls = NUM_HDLS;\n\thd_rule_entry = &pHeaderDescriptor->hdl[0];\n\n\thd_rule_entry->hdl = hdr_hdl;\n\thd_rule_entry->status = -1;\n\n\tIPACMDBG(\"Deleting Header hdl:(%x)\\n\", hd_rule_entry->hdl);\n\tif ((false == DeleteHeader(pHeaderDescriptor)) ||\n\t\t\t(hd_rule_entry->status))\n\t{\n\t    IPACMERR(\"Header hdl:(%x) deletion failed!  status: %d\\n\", hd_rule_entry->hdl,hd_rule_entry->status);\n\t\tres = false;\n\t\tgoto fail;\n\t}\n\n\tIPACMDBG_H(\"Deleted Header hdl:(%x) successfully\\n\", hd_rule_entry->hdl);\n\nfail:\n\tfree(pHeaderDescriptor);\n\n\treturn res;\n\n}\n\nbool IPACM_Header::AddHeaderProcCtx(struct ipa_ioc_add_hdr_proc_ctx* pHeader)\n{\n\tint ret = 0;\n\t//call the Driver ioctl to add header processing context\n\tret = ioctl(m_fd, IPA_IOC_ADD_HDR_PROC_CTX, pHeader);\n\treturn (ret != -1);\n}\n\nbool IPACM_Header::DeleteHeaderProcCtx(uint32_t hdl)\n{\n\tint len, ret;\n\tstruct ipa_ioc_del_hdr_proc_ctx* pHeaderTable = NULL;\n\n\tlen = sizeof(struct ipa_ioc_del_hdr_proc_ctx) + sizeof(struct ipa_hdr_proc_ctx_del);\n\tpHeaderTable = (struct ipa_ioc_del_hdr_proc_ctx*)malloc(len);\n\tif(pHeaderTable == NULL)\n\t{\n\t\tIPACMERR(\"Failed to allocate buffer.\\n\");\n\t\treturn false;\n\t}\n\tmemset(pHeaderTable, 0, len);\n\n\tpHeaderTable->commit = 1;\n\tpHeaderTable->num_hdls = 1;\n\tpHeaderTable->hdl[0].hdl = hdl;\n\n\tret = ioctl(m_fd, IPA_IOC_DEL_HDR_PROC_CTX, pHeaderTable);\n\tfree(pHeaderTable);\n\treturn (ret != -1);\n}\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n* Redistributions of source code must retain the above copyright\n  notice, this list of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above\n  copyright notice, this list of conditions and the following\n  disclaimer in the documentation and/or other materials provided\n  with the distribution.\n* Neither the name of The Linux Foundation nor the names of its\n  contributors may be used to endorse or promote products derived\n  from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.Z\n*/\n/*!\n  @file\n  IPACM_Iface.cpp\n\n  @brief\n  This file implements the basis Iface functionality.\n\n  @Author\n  Skylar Chang\n\n*/\n#include <fcntl.h>\n#include <sys/ioctl.h>\n#include <IPACM_Netlink.h>\n#include <IPACM_Iface.h>\n#include <IPACM_Lan.h>\n#include <IPACM_Wan.h>\n#include <IPACM_Wlan.h>\n#include <string.h>\n\nextern \"C\"\n{\n#include <ifaddrs.h>\n}\n\n\nconst char *IPACM_Iface::DEVICE_NAME = \"/dev/ipa\";\nIPACM_Routing IPACM_Iface::m_routing;\nIPACM_Filtering IPACM_Iface::m_filtering;\nIPACM_Header IPACM_Iface::m_header;\n\nIPACM_Config *IPACM_Iface::ipacmcfg = IPACM_Config::GetInstance();\n\nIPACM_Iface::IPACM_Iface(int iface_index)\n{\n\tip_type = IPACM_IP_NULL; /* initially set invalid */\n\tnum_dft_rt_v6 = 0;\n\tsoftwarerouting_act = false;\n\tipa_if_num = iface_index;\n\tipa_if_cate = IPACM_Iface::ipacmcfg->iface_table[iface_index].if_cat;\n\n\tiface_query = NULL;\n\ttx_prop = NULL;\n\trx_prop = NULL;\n\n\tmemcpy(dev_name,\n\t\t\t\t IPACM_Iface::ipacmcfg->iface_table[iface_index].iface_name,\n\t\t\t\t sizeof(IPACM_Iface::ipacmcfg->iface_table[iface_index].iface_name));\n\n\tmemset(dft_v4fl_rule_hdl, 0, sizeof(dft_v4fl_rule_hdl));\n\tmemset(dft_v6fl_rule_hdl, 0, sizeof(dft_v6fl_rule_hdl));\n\n\tmemset(dft_rt_rule_hdl, 0, sizeof(dft_rt_rule_hdl));\n\tmemset(software_routing_fl_rule_hdl, 0, sizeof(software_routing_fl_rule_hdl));\n\tmemset(ipv6_addr, 0, sizeof(ipv6_addr));\n\n\tflt_rule_count_v4 = 0;\n\tflt_rule_count_v6 = 0;\n\tquery_iface_property();\n\tIPACMDBG_H(\" create iface-index(%d) constructor\\n\", ipa_if_num);\n\treturn;\n}\n\n/* software routing enable */\nint IPACM_Iface::handle_software_routing_enable(void)\n{\n\n\tint res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tipa_ioc_add_flt_rule *m_pFilteringTable;\n\n\tIPACMDBG(\"\\n\");\n\tif (softwarerouting_act == true)\n\t{\n\t\tIPACMDBG(\"already setup software_routing rule for (%s)iface ip-family %d\\n\",\n\t\t\t\t\t\t     IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ip_type);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tm_pFilteringTable = (struct ipa_ioc_add_flt_rule *)\n\t\t calloc(1,\n\t\t\t\t\t\tsizeof(struct ipa_ioc_add_flt_rule) +\n\t\t\t\t\t\t1 * sizeof(struct ipa_flt_rule_add)\n\t\t\t\t\t\t);\n\tif (!m_pFilteringTable)\n\t{\n\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tm_pFilteringTable->commit = 1;\n\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\tm_pFilteringTable->global = false;\n\tm_pFilteringTable->num_rules = (uint8_t)1;\n\n\n\t/* Configuring Software-Routing Filtering Rule */\n\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\tflt_rule_entry.at_rear = false;\n\tflt_rule_entry.flt_rule_hdl = -1;\n\tflt_rule_entry.status = -1;\n\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\n\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t/* check iface is v4 or v6 or both*/\n//\tif (ip_type == IPA_IP_MAX)\n//\t{\n\t\t/* handle v4 */\n\t\tm_pFilteringTable->ip = IPA_IP_v4;\n\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse if (m_pFilteringTable->rules[0].status)\n\t\t{\n\t\t\tIPACMERR(\"adding flt rule failed status=0x%x\\n\", m_pFilteringTable->rules[0].status);\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG(\"soft-routing flt rule hdl0=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl);\n\t\t/* copy filter hdls */\n\t\tsoftware_routing_fl_rule_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\n\n\t\t/* handle v6*/\n\t\tm_pFilteringTable->ip = IPA_IP_v6;\n\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse if (m_pFilteringTable->rules[0].status)\n\t\t{\n\t\t\tIPACMDBG(\"adding flt rule failed status=0x%x\\n\", m_pFilteringTable->rules[0].status);\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG(\"soft-routing flt rule hdl0=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl);\n\t\t/* copy filter hdls */\n\t\tsoftware_routing_fl_rule_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\tsoftwarerouting_act = true;\n#if 0\n\t}\n\telse\n\t{\n\t\tif (ip_type == IPA_IP_v4)\n\t\t{\n\t\t\tm_pFilteringTable->ip = IPA_IP_v4;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tm_pFilteringTable->ip = IPA_IP_v6;\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse if (m_pFilteringTable->rules[0].status)\n\t\t{\n\t\t\tIPACMERR(\"adding flt rule failed status=0x%x\\n\", m_pFilteringTable->rules[0].status);\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG(\"soft-routing flt rule hdl0=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl);\n\t\t/* copy filter hdls */\n\t\tif (ip_type == IPA_IP_v4)\n\t\t{\n\t\t\tsoftware_routing_fl_rule_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsoftware_routing_fl_rule_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t}\n\t\tsoftwarerouting_act = true;\n\t}\n#endif\n\nfail:\n\tfree(m_pFilteringTable);\n\n\treturn res;\n}\n\n/* software routing disable */\nint IPACM_Iface::handle_software_routing_disable(void)\n{\n\tint res = IPACM_SUCCESS;\n\tipa_ip_type ip;\n\tuint32_t flt_hdl;\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif (softwarerouting_act == false)\n\t{\n\t\tIPACMDBG(\"already delete software_routing rule for (%s)iface ip-family %d\\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ip_type);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n//\tif (ip_type == IPA_IP_MAX)\n//\t{\n\t\t/* ipv4 case */\n\t\tif (m_filtering.DeleteFilteringHdls(&software_routing_fl_rule_hdl[0],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v4, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\t/* ipv6 case */\n\t\tif (m_filtering.DeleteFilteringHdls(&software_routing_fl_rule_hdl[1],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v6, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tsoftwarerouting_act = false;\n#if 0\n\t}\n\telse\n\t{\n\t\tif (ip_type == IPA_IP_v4)\n\t\t{\n\t\t\tip = IPA_IP_v4;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tip = IPA_IP_v6;\n\t\t}\n\n\n\t\tif (ip_type == IPA_IP_v4)\n\t\t{\n\t\t\tflt_hdl = software_routing_fl_rule_hdl[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_hdl = software_routing_fl_rule_hdl[1];\n\t\t}\n\n\t\tif (m_filtering.DeleteFilteringHdls(&flt_hdl, ip, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tsoftwarerouting_act = false;\n\t}\n#endif\n\nfail:\n\treturn res;\n}\n\n/* Query ipa_interface_index by given linux interface_index */\nint IPACM_Iface::iface_ipa_index_query\n(\n\t int interface_index\n)\n{\n\tint fd;\n\tint link = INVALID_IFACE;\n\tint i = 0;\n\tstruct ifreq ifr;\n\n\n\tif(IPACM_Iface::ipacmcfg->iface_table == NULL)\n\t{\n\t\tIPACMERR(\"Iface table in IPACM_Config is not available.\\n\");\n\t\treturn link;\n\t}\n\n\t/* Search known linux interface-index and map to IPA interface-index*/\n\tfor (i = 0; i < IPACM_Iface::ipacmcfg->ipa_num_ipa_interfaces; i++)\n\t{\n\t\tif (interface_index == IPACM_Iface::ipacmcfg->iface_table[i].netlink_interface_index)\n\t\t{\n\t\t\tlink = i;\n\t\t\tIPACMDBG(\"Interface (%s) found: linux(%d) ipa(%d) \\n\",\n\t\t\t\t\t\t\t IPACM_Iface::ipacmcfg->iface_table[i].iface_name,\n\t\t\t\t\t\t\t IPACM_Iface::ipacmcfg->iface_table[i].netlink_interface_index,\n\t\t\t\t\t\t\t link);\n\t\t\treturn link;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* Search/Configure linux interface-index and map it to IPA interface-index */\n\tif ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)\n\t{\n\t\tPERROR(\"get interface name socket create failed\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tmemset(&ifr, 0, sizeof(struct ifreq));\n\n\tifr.ifr_ifindex = interface_index;\n\tIPACMDBG_H(\"Interface index %d\\n\", interface_index);\n\n\tif (ioctl(fd, SIOCGIFNAME, &ifr) < 0)\n\t{\n\t\tPERROR(\"call_ioctl_on_dev: ioctl failed:\");\n\t\tclose(fd);\n\t\treturn IPACM_FAILURE;\n\t}\n\tclose(fd);\n\n\tIPACMDBG_H(\"Received interface name %s\\n\", ifr.ifr_name);\n\tfor (i = 0; i < IPACM_Iface::ipacmcfg->ipa_num_ipa_interfaces; i++)\n\t{\n\t\tif (strncmp(ifr.ifr_name,\n\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[i].iface_name,\n\t\t\t\t\t\t\t\tsizeof(IPACM_Iface::ipacmcfg->iface_table[i].iface_name)) == 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"Interface (%s) linux(%d) mapped to ipa(%d) \\n\", ifr.ifr_name,\n\t\t\t\t\t\t\t IPACM_Iface::ipacmcfg->iface_table[i].netlink_interface_index, i);\n\n\t\t\tlink = i;\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[i].netlink_interface_index = interface_index;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn link;\n}\n\n/* Query ipa_interface ipv4_addr by given linux interface_index */\nvoid IPACM_Iface::iface_addr_query\n(\n\t int interface_index\n)\n{\n\tint fd;\n\tstruct ifreq ifr;\n\tstruct ifaddrs *myaddrs, *ifa;\n\tipacm_cmd_q_data evt_data;\n\tipacm_event_data_addr *data_addr;\n\tstruct in_addr iface_ipv4;\n\n\t/* use linux interface-index to find interface name */\n\tif ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)\n\t{\n\t\tPERROR(\"get interface name socket create failed\");\n\t\treturn ;\n\t}\n\n\tmemset(&ifr, 0, sizeof(struct ifreq));\n\n\tifr.ifr_ifindex = interface_index;\n\tIPACMDBG_H(\"Interface index %d\\n\", interface_index);\n\n\tif (ioctl(fd, SIOCGIFNAME, &ifr) < 0)\n\t{\n\t\tPERROR(\"call_ioctl_on_dev: ioctl failed:\");\n\t\tclose(fd);\n\t\treturn ;\n\t}\n\tIPACMDBG_H(\"Interface index %d name: %s\\n\", interface_index,ifr.ifr_name);\n\tclose(fd);\n\n\t/* query ipv4/v6 address */\n    if(getifaddrs(&myaddrs) != 0)\n\t{\n        IPACMERR(\"getifaddrs\");\n\t\treturn ;\n\t}\n\n    for (ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next)\n    {\n        if (ifa->ifa_addr == NULL)\n            continue;\n        if (!(ifa->ifa_flags & IFF_UP))\n            continue;\n\n\t\tif(strcmp(ifr.ifr_name,ifa->ifa_name) == 0) // find current iface\n\t\t{\n\t\t\tIPACMDBG_H(\"Internal post new_addr event for iface %s\\n\", ifa->ifa_name);\n\t\t\tswitch (ifa->ifa_addr->sa_family)\n\t\t\t{\n\t\t\t\tcase AF_INET:\n\t\t\t\t{\n\t\t\t\t\tstruct sockaddr_in *s4 = (struct sockaddr_in *)ifa->ifa_addr;\n\t\t\t\t\tIPACMDBG_H(\"ipv4 address %s\\n\",inet_ntoa(s4->sin_addr));\n\t\t\t\t\tiface_ipv4 = s4->sin_addr;\n\t\t\t\t\t/* post new_addr event to command queue */\n\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\tfreeifaddrs(myaddrs);\n\t\t\t\t\t\treturn ;\n\t\t\t\t\t}\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v4;\n\t\t\t\t\tdata_addr->if_index = interface_index;\n\t\t\t\t\tdata_addr->ipv4_addr = \tiface_ipv4.s_addr;\n\t\t\t\t\tdata_addr->ipv4_addr = ntohl(data_addr->ipv4_addr);\n\t\t\t\t\tIPACMDBG_H(\"Posting IPA_ADDR_ADD_EVENT with if index:%d, ipv4 addr:0x%x\\n\",\n\t\t\t\t\t\tdata_addr->if_index,\n\t\t\t\t\t\tdata_addr->ipv4_addr);\n\n\t\t\t\t\tevt_data.event = IPA_ADDR_ADD_EVENT;\n\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase AF_INET6:\n\t\t\t\t{\n\t\t\t\t\tstruct sockaddr_in6 *s6 = (struct sockaddr_in6 *)ifa->ifa_addr;\n\t\t\t\t\t/* post new_addr event to command queue */\n\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\tfreeifaddrs(myaddrs);\n\t\t\t\t\t\treturn ;\n\t\t\t\t\t}\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v6;\n\t\t\t\t\tdata_addr->if_index = interface_index;\n\t\t\t\t\tmemcpy(data_addr->ipv6_addr,\n\t\t\t\t\t\t\t\t\t&s6->sin6_addr,\n\t\t\t\t\t\t\t\t\tsizeof(data_addr->ipv6_addr));\n\t\t\t\t\tdata_addr->ipv6_addr[0] = ntohl(data_addr->ipv6_addr[0]);\n\t\t\t\t\tdata_addr->ipv6_addr[1] = ntohl(data_addr->ipv6_addr[1]);\n\t\t\t\t\tdata_addr->ipv6_addr[2] = ntohl(data_addr->ipv6_addr[2]);\n\t\t\t\t\tdata_addr->ipv6_addr[3] = ntohl(data_addr->ipv6_addr[3]);\n\t\t\t\t\tIPACMDBG_H(\"Posting IPA_ADDR_ADD_EVENT with if index:%d, ipv6 addr:0x%x:%x:%x:%x\\n\",\n\t\t\t\t\t\t\tdata_addr->if_index,\n\t\t\t\t\t\t\tdata_addr->ipv6_addr[0], data_addr->ipv6_addr[1], data_addr->ipv6_addr[2], data_addr->ipv6_addr[3]);\n\n\t\t\t\t\tevt_data.event = IPA_ADDR_ADD_EVENT;\n\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t}\n    freeifaddrs(myaddrs);\n\treturn ;\n}\n\n/*Query the IPA endpoint property */\nint IPACM_Iface::query_iface_property(void)\n{\n\tint res = IPACM_SUCCESS, fd = 0;\n\tuint32_t cnt=0;\n\n\tfd = open(DEVICE_NAME, O_RDWR);\n\tIPACMDBG(\"iface query-property \\n\");\n\tif (0 == fd)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", DEVICE_NAME);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tiface_query = (struct ipa_ioc_query_intf *)\n\t\t calloc(1, sizeof(struct ipa_ioc_query_intf));\n\tif(iface_query == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate iface_query memory.\\n\");\n\t\tclose(fd);\n\t\treturn IPACM_FAILURE;\n\t}\n\tIPACMDBG_H(\"iface name %s\\n\", dev_name);\n\tmemcpy(iface_query->name, dev_name, sizeof(dev_name));\n\n\tif (ioctl(fd, IPA_IOC_QUERY_INTF, iface_query) < 0)\n\t{\n\t\tPERROR(\"ioctl IPA_IOC_QUERY_INTF failed\\n\");\n\t\t/* iface_query memory will free when iface-down*/\n\t\tres = IPACM_FAILURE;\n\t}\n\n\tif(iface_query->num_tx_props > 0)\n\t{\n\t\ttx_prop = (struct ipa_ioc_query_intf_tx_props *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_query_intf_tx_props) +\n\t\t\t\t\t\t\tiface_query->num_tx_props * sizeof(struct ipa_ioc_tx_intf_prop));\n\t\tif(tx_prop == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to allocate tx_prop memory.\\n\");\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\tmemcpy(tx_prop->name, dev_name, sizeof(tx_prop->name));\n\ttx_prop->num_tx_props = iface_query->num_tx_props;\n\n\tif (ioctl(fd, IPA_IOC_QUERY_INTF_TX_PROPS, tx_prop) < 0)\n\t{\n\t\tPERROR(\"ioctl IPA_IOC_QUERY_INTF_TX_PROPS failed\\n\");\n\t\t/* tx_prop memory will free when iface-down*/\n\t\tres = IPACM_FAILURE;\n\t}\n\n\t\tif (res != IPACM_FAILURE)\n\t\t{\n\t\t\tfor (cnt = 0; cnt < tx_prop->num_tx_props; cnt++)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Tx(%d):attrib-mask:0x%x, ip-type: %d, dst_pipe: %d, header: %s\\n\",\n\t\t\t\t\t\t\t\t cnt, tx_prop->tx[cnt].attrib.attrib_mask, tx_prop->tx[cnt].ip, tx_prop->tx[cnt].dst_pipe, tx_prop->tx[cnt].hdr_name);\n\t\t\t}\n\t\t}\n\n\t}\n\n\t\tif (iface_query->num_rx_props > 0)\n\t{\n\t\trx_prop = (struct ipa_ioc_query_intf_rx_props *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_query_intf_rx_props) +\n\t\t\t\t\t\t\tiface_query->num_rx_props * sizeof(struct ipa_ioc_rx_intf_prop));\n\t\tif(rx_prop == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to allocate rx_prop memory.\\n\");\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\tmemcpy(rx_prop->name, dev_name,\n\t\t\t\t sizeof(rx_prop->name));\n\trx_prop->num_rx_props = iface_query->num_rx_props;\n\n\tif (ioctl(fd, IPA_IOC_QUERY_INTF_RX_PROPS, rx_prop) < 0)\n\t{\n\t\tPERROR(\"ioctl IPA_IOC_QUERY_INTF_RX_PROPS failed\\n\");\n\t\t/* rx_prop memory will free when iface-down*/\n\t\tres = IPACM_FAILURE;\n\t}\n\n\t\tif (res != IPACM_FAILURE)\n\t\t{\n\t\t\tfor (cnt = 0; cnt < rx_prop->num_rx_props; cnt++)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Rx(%d):attrib-mask:0x%x, ip-type: %d, src_pipe: %d\\n\",\n\t\t\t\t\t\t\t\t cnt, rx_prop->rx[cnt].attrib.attrib_mask, rx_prop->rx[cnt].ip, rx_prop->rx[cnt].src_pipe);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Add Natting iface to IPACM_Config if there is  Rx/Tx property */\n\tif (rx_prop != NULL || tx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\" Has rx/tx properties registered for iface %s, add for NATTING \\n\", dev_name);\n        IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name);\n\t}\n\n\tclose(fd);\n\treturn res;\n}\n\n/*Configure the initial filter rules */\nint IPACM_Iface::init_fl_rule(ipa_ip_type iptype)\n{\n\n\tint res = IPACM_SUCCESS, len = 0;\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tipa_ioc_add_flt_rule *m_pFilteringTable;\n\n  /* Adding this hack because WLAN may not registered for Rx-endpoint, other ifaces will always have*/\n\tconst char *dev_wlan0=\"wlan0\";\n\tconst char *dev_wlan1=\"wlan1\";\n\tconst char *dev_ecm0=\"ecm0\";\n\n\t/* update the iface ip-type to be IPA_IP_v4, IPA_IP_v6 or both*/\n\tif (iptype == IPA_IP_v4)\n\t{\n\n\t\tif ((ip_type == IPA_IP_v4) || (ip_type == IPA_IP_MAX))\n\t\t{\n\t\t\tIPACMDBG_H(\" interface(%s:%d) already in ip-type %d\\n\", dev_name, ipa_if_num, ip_type);\n\t\t\treturn res;\n\t\t}\n\n\t\tif (ip_type == IPA_IP_v6)\n\t\t{\n\t\t\tip_type = IPA_IP_MAX;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tip_type = IPA_IP_v4;\n\t\t}\n\n\t\tIPACMDBG_H(\" interface(%s:%d) now ip-type is %d\\n\", dev_name, ipa_if_num, ip_type);\n\t}\n\telse\n\t{\n\n\t\tif ((ip_type == IPA_IP_v6) || (ip_type == IPA_IP_MAX))\n\t\t{\n\t\t\tIPACMDBG_H(\" interface(%s:%d) already in ip-type %d\\n\", dev_name, ipa_if_num, ip_type);\n\t\t\treturn res;\n\t\t}\n\n\t\tif (ip_type == IPA_IP_v4)\n\t\t{\n\t\t\tip_type = IPA_IP_MAX;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tip_type = IPA_IP_v6;\n\t\t}\n\n\t\tIPACMDBG_H(\" interface(%s:%d) now ip-type is %d\\n\", dev_name, ipa_if_num, ip_type);\n\t}\n\n    /* ADD corresponding ipa_rm_resource_name of RX-endpoint before adding all IPV4V6 FT-rules */\n\tif((IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat== WAN_IF) || (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat== EMBMS_IF))\n\t{\n\t\tIPACMDBG_H(\" NOT add producer dependency on dev %s with registered rx-prop cat:%d \\n\", dev_name, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat);\n\t}\n\telse\n\t{\n\t\tif(rx_prop != NULL)\n\t\t{\n\t\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", rx_prop->rx[0].src_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);\n\t\t\tIPACM_Iface::ipacmcfg->AddRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe],false);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/* only wlan may take software-path, not register Rx-property*/\n\t\t\tif(strcmp(dev_name,dev_wlan0) == 0 || strcmp(dev_name,dev_wlan1) == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\t\t\tIPACMDBG_H(\"depend Got piperm index : %d \\n\", IPA_RM_RESOURCE_HSIC_PROD);\n\t\t\t\tIPACM_Iface::ipacmcfg->AddRmDepend(IPA_RM_RESOURCE_HSIC_PROD,true);\n\t\t\t}\n\t\t\tif(strcmp(dev_name,dev_ecm0) == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\t\t\tIPACMDBG_H(\"depend Got piperm index : %d \\n\", IPA_RM_RESOURCE_USB_PROD);\n\t\t\t\tIPACM_Iface::ipacmcfg->AddRmDepend(IPA_RM_RESOURCE_USB_PROD,true);\n\t\t\t}\n\t\t}\n\t}\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\t/* construct ipa_ioc_add_flt_rule with default filter rules */\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) +\n\t\t\t (IPV4_DEFAULT_FILTERTING_RULES * sizeof(struct ipa_flt_rule_add));\n\n\t\tm_pFilteringTable = (struct ipa_ioc_add_flt_rule *)calloc(1, len);\n\t\tif (!m_pFilteringTable)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tm_pFilteringTable->commit = 1;\n\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\tm_pFilteringTable->global = false;\n\t\tm_pFilteringTable->ip = iptype;\n\t\tm_pFilteringTable->num_rules = (uint8_t)IPV4_DEFAULT_FILTERTING_RULES;\n\n\t\t/* Configuring Fragment Filtering Rule */\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\tIPACMDBG_H(\"rx property attrib mask:0x%x\\n\", rx_prop->rx[0].attrib.attrib_mask);\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_FRAGMENT;\n\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* Configuring Multicast Filtering Rule */\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0xF0000000;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0xE0000000;\n\t\tmemcpy(&(m_pFilteringTable->rules[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* Configuring Broadcast Filtering Rule */\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0xFFFFFFFF;\n\t\tmemcpy(&(m_pFilteringTable->rules[2]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_rule_count_v4 += IPV4_DEFAULT_FILTERTING_RULES;\n\t\t\t/* copy filter hdls */\n\t\t\tfor (int i = 0; i < IPV4_DEFAULT_FILTERTING_RULES; i++)\n\t\t\t{\n\t\t\t\tif (m_pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tdft_v4fl_rule_hdl[i] = m_pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"Default v4 filter Rule %d HDL:0x%x\\n\", i, dft_v4fl_rule_hdl[i]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding default v4 Filtering rule %d\\n\", i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) +\n\t\t\t (IPV6_DEFAULT_FILTERTING_RULES * sizeof(struct ipa_flt_rule_add));\n\n\t\tm_pFilteringTable = (struct ipa_ioc_add_flt_rule *)calloc(1, len);\n\t\tif (!m_pFilteringTable)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tm_pFilteringTable->commit = 1;\n\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\tm_pFilteringTable->global = false;\n\t\tm_pFilteringTable->ip = iptype;\n\t\tm_pFilteringTable->num_rules = (uint8_t)IPV6_DEFAULT_FILTERTING_RULES;\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\t\t/* Configuring Multicast Filtering Rule */\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFF000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0XFF000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* Configuring fe80::/10 Link-Scoped Unicast Filtering Rule */\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0XFFC00000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0xFE800000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\t\tmemcpy(&(m_pFilteringTable->rules[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* Configuring fec0::/10 Reserved by IETF Filtering Rule */\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0XFFC00000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0xFEC00000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\t\tmemcpy(&(m_pFilteringTable->rules[2]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n#ifdef FEATURE_IPA_ANDROID\n\t\tIPACMDBG_H(\"Add TCP ctrl rules: total num %d\\n\", IPV6_DEFAULT_FILTERTING_RULES);\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\n\t\tflt_rule_entry.rule.eq_attrib.rule_eq_bitmap = 0;\n\n\t\tif(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA)\n\t\t{\n\t\t\tflt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<14);\n\t\t\tflt_rule_entry.rule.eq_attrib.metadata_meq32_present = 1;\n\t\t\tflt_rule_entry.rule.eq_attrib.metadata_meq32.offset = 0;\n\t\t\tflt_rule_entry.rule.eq_attrib.metadata_meq32.value = rx_prop->rx[0].attrib.meta_data;\n\t\t\tflt_rule_entry.rule.eq_attrib.metadata_meq32.mask = rx_prop->rx[0].attrib.meta_data_mask;\n\t\t}\n\n\t\tflt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<1);\n\t\tflt_rule_entry.rule.eq_attrib.protocol_eq_present = 1;\n\t\tflt_rule_entry.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;\n\n\t\tflt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<8);\n\t\tflt_rule_entry.rule.eq_attrib.num_ihl_offset_meq_32 = 1;\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;\n\n\t\t/* add TCP FIN rule*/\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\t\tmemcpy(&(m_pFilteringTable->rules[3]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* add TCP SYN rule*/\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\t\tmemcpy(&(m_pFilteringTable->rules[4]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* add TCP RST rule*/\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);\n\t\tmemcpy(&(m_pFilteringTable->rules[5]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n#endif\n\t\tif (m_filtering.AddFilteringRule(m_pFilteringTable) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_rule_count_v6 += IPV6_DEFAULT_FILTERTING_RULES;\n\t\t\t/* copy filter hdls */\n\t\t\tfor (int i = 0;\n\t\t\t\t\t i < IPV6_DEFAULT_FILTERTING_RULES;\n\t\t\t\t\t i++)\n\t\t\t{\n\t\t\t\tif (m_pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tdft_v6fl_rule_hdl[i] = m_pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"Default v6 Filter Rule %d HDL:0x%x\\n\", i, dft_v6fl_rule_hdl[i]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failing adding v6 default IPV6 rule %d\\n\", i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\nfail:\n\tfree(m_pFilteringTable);\n\n\treturn res;\n}\n\n/*  get ipa interface name */\nint IPACM_Iface::ipa_get_if_index\n(\n  char * if_name,\n  int * if_index\n)\n{\n  int fd;\n  struct ifreq ifr;\n\n  if((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)\n  {\n    IPACMERR(\"get interface index socket create failed \\n\");\n    return IPACM_FAILURE;\n  }\n\n  memset(&ifr, 0, sizeof(struct ifreq));\n  (void)strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));\n  IPACMDBG_H(\"interface name (%s)\\n\", if_name);\n\n  if (ioctl(fd,SIOCGIFINDEX , &ifr) < 0)\n  {\n    IPACMERR(\"call_ioctl_on_dev: ioctl failed, interface name (%s):\\n\", ifr.ifr_name);\n    close(fd);\n    return IPACM_FAILURE;\n  }\n\n  *if_index = ifr.ifr_ifindex;\n  IPACMDBG_H(\"Interface index %d\\n\", *if_index);\n  close(fd);\n  return IPACM_SUCCESS;\n}\n\nsize_t IPACM_Iface::strlcpy(char *dest, const char *src, size_t n)\n{\n\tsize_t ret = strlen(src);\n\tsize_t len = 0;\n\tif (n > 0) {\n\t\tif(ret >= n)\n\t\t{\n\t\t\tlen = n-1;\n\t\t\tIPACMERR(\" overflow detected \\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlen = ret;\n\t\t}\n\t\tdest[len] = '\\0';\n\t\tmemcpy(dest, src, len);\n\t}\n\treturn ret;\n}\n\nsize_t IPACM_Iface::strlcat(char *dest, const char *src, size_t n)\n{\n\tsize_t dsize = strlen(dest);\n\tsize_t len = strlen(src);\n\tsize_t ret = dsize + len;\n\n\tif (dsize < n)\n\t{\n\t\tdest += dsize;\n\t\tn -= dsize;\n\t\tif (len >= n)\n\t\t{\n\t\t\tlen = n - 1;\n\t\t\tIPACMERR(\" overflow detected \\n\");\n\t\t}\n\t\tdest[len] = '\\0';\n\t\tmemcpy(dest, src, len);\n\t}\n\telse\n\t{\n\t\tIPACMERR(\" dest buffer full\\n\");\n\t}\n\treturn ret;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_IfaceManager.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_IfaceManager.cpp\n\n\t@brief\n\tThis file implements the IPAM iface_manager functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#include <string.h>\n#include <sys/ioctl.h>\n\n#include <IPACM_IfaceManager.h>\n#include <IPACM_EvtDispatcher.h>\n#include <IPACM_Defs.h>\n#include <IPACM_Wlan.h>\n#include <IPACM_Lan.h>\n#include <IPACM_Wan.h>\n#include <IPACM_Iface.h>\n#include <IPACM_Log.h>\n\niface_instances *IPACM_IfaceManager::head = NULL;\n\nIPACM_IfaceManager::IPACM_IfaceManager()\n{\n\tIPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, this); \t\t// register for IPA_CFG_CHANGE event\n\tIPACM_EvtDispatcher::registr(IPA_LINK_UP_EVENT, this);\n\tIPACM_EvtDispatcher::registr(IPA_WLAN_AP_LINK_UP_EVENT, this);  // register for wlan AP-iface\n#ifndef FEATURE_IPA_ANDROID\n\tIPACM_EvtDispatcher::registr(IPA_WLAN_STA_LINK_UP_EVENT, this); // register for wlan STA-iface\n#endif /* not defined(FEATURE_IPA_ANDROID)*/\n\tIPACM_EvtDispatcher::registr(IPA_USB_LINK_UP_EVENT, this); // register for wlan STA-iface\n\tIPACM_EvtDispatcher::registr(IPA_WAN_EMBMS_LINK_UP_EVENT, this);  // register for wan eMBMS-iface\n\treturn;\n}\n\nvoid IPACM_IfaceManager::event_callback(ipa_cm_event_id event, void *param)\n{\n\tint ipa_interface_index;\n\tipacm_event_data_fid *evt_data = (ipacm_event_data_fid *)param;\n\tipacm_event_data_mac *StaData = (ipacm_event_data_mac *)param;\n\tipacm_ifacemgr_data ifmgr_data = {0};\n\n\tswitch(event)\n\t{\n\t\tcase IPA_CFG_CHANGE_EVENT:\n\t\t\t\tIPACMDBG_H(\" RESET IPACM_cfg \\n\");\n\t\t\t\tIPACM_Iface::ipacmcfg->Init();\n\t\t\tbreak;\n\t\tcase IPA_LINK_UP_EVENT:\n\t\t\tIPACMDBG_H(\"link up %d: \\n\", evt_data->if_index);\n\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);\n\t\t\t/* LTE-backhaul */\n\t\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == EMBMS_IF)\n\t\t\t{\n\t\t\t\tIPACMDBG(\"WAN-EMBMS (%s) link already up, iface: %d: \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);\n\t\t\t}\n\t\t\telse if(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == WAN_IF)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"WAN-LTE (%s) link up, iface: %d: \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);\n\t\t\t\tifmgr_data.if_index = evt_data->if_index;\n\t\t\t\tifmgr_data.if_type = Q6_WAN;\n\t\t\t\tcreate_iface_instance(&ifmgr_data);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase IPA_USB_LINK_UP_EVENT:\n\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);\n\t\t\t/* check if it's WAN_IF */\n\t\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == WAN_IF)\n\t\t\t{\n\t\t\t\t/* usb-backhaul using sta_mode ECM_WAN*/\n\t\t\t\tIPACMDBG_H(\"WAN-usb (%s) link up, iface: %d: \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name, evt_data->if_index);\n\t\t\t\tifmgr_data.if_index = evt_data->if_index;\n\t\t\t\tifmgr_data.if_type = ECM_WAN;\n\t\t\t\tcreate_iface_instance(&ifmgr_data);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tifmgr_data.if_index = evt_data->if_index;\n\t\t\t\tifmgr_data.if_type = Q6_WAN;\n\t\t\t\tcreate_iface_instance(&ifmgr_data);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase IPA_WLAN_AP_LINK_UP_EVENT:\n\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);\n\t\t\t/* change iface category from unknown to WLAN_IF */\n\t\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == UNKNOWN_IF)\n\t\t\t{\n\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat = WLAN_IF;\n\t\t\t\tIPACMDBG_H(\"WLAN AP (%s) link up, iface: %d: \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);\n\t\t\t\tifmgr_data.if_index = evt_data->if_index;\n\t\t\t\tifmgr_data.if_type = Q6_WAN;\n\t\t\t\tcreate_iface_instance(&ifmgr_data);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"iface %s already up and act as %d mode: \\n\",IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase IPA_WLAN_STA_LINK_UP_EVENT:\n\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(StaData->if_index);\n\t\t\t/* change iface category from unknown to WAN_IF */\n\t\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == UNKNOWN_IF)\n\t\t\t{\n\t\t\t\t/* wlan-backhaul using sta_mode WLAN_WAN */\n\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat = WAN_IF;\n\t\t\t\tIPACMDBG_H(\"WLAN STA (%s) link up, iface: %d: \\n\",\n\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name, StaData->if_index);\n\n\t\t\t\tifmgr_data.if_index = StaData->if_index;\n\t\t\t\tifmgr_data.if_type = WLAN_WAN;\n\t\t\t\tmemcpy(ifmgr_data.mac_addr, StaData->mac_addr, sizeof(ifmgr_data.mac_addr));\n\t\t\t\tcreate_iface_instance(&ifmgr_data);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"iface %s already up and act as %d mode: \\n\",\n\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,\n\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat);\n\t\t\t}\n\t\t\tbreak;\n\n\t\t/* Add new instance open for eMBMS iface and wan iface */\n\t\tcase IPA_WAN_EMBMS_LINK_UP_EVENT:\n\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);\n\t\t\t/* change iface category from unknown to EMBMS_IF */\n\t\t\tif (IPACM_Iface::ipacmcfg->ipacm_odu_enable == true)\n\t\t\t{\n\t\t\t\tIPACMDBG(\" ODU-mode enable or not (%d) \\n\",IPACM_Iface::ipacmcfg->ipacm_odu_enable);\n\t\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == WAN_IF)\n\t\t\t{\n\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat=EMBMS_IF;\n\t\t\t\tIPACMDBG(\"WAN eMBMS (%s) link up, iface: %d: \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);\n\t\t\t\tifmgr_data.if_index = StaData->if_index;\n\t\t\t\tifmgr_data.if_type = Q6_WAN;\n\t\t\t\tcreate_iface_instance(&ifmgr_data);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG(\"iface %s already up and act as %d mode: \\n\",IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat);\n\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\treturn;\n}\n\nint IPACM_IfaceManager::create_iface_instance(ipacm_ifacemgr_data *param)\n{\n\tint if_index = param->if_index;\n\tipacm_wan_iface_type is_sta_mode = param->if_type;\n\n\tint ipa_interface_index;\n\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(if_index);\n\n\tif(ipa_interface_index == INVALID_IFACE)\n\t{\n\t\t\tIPACMDBG_H(\"Unhandled interface received, fid: %d\\n\",if_index);\n\t\t\treturn IPACM_SUCCESS;\n\t}\n\n\t/* check if duplicate instance*/\n\tif(SearchInstance(ipa_interface_index) == IPA_INSTANCE_NOT_FOUND)\n\t{\n\t\t/* IPA_INSTANCE_NOT_FOUND */\n\t\tswitch(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat)\n\t\t{\n\n\t\tcase LAN_IF:\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Creating Lan interface\\n\");\n\t\t\t\tIPACM_Lan *lan = new IPACM_Lan(ipa_interface_index);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, lan);\n\t\t\t\t//IPACM_EvtDispatcher::registr(IPA_ROUTE_ADD_EVENT, lan);\n\t\t\t\t//IPACM_EvtDispatcher::registr(IPA_ROUTE_DEL_EVENT, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, lan);\n\t\t\t\t//IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, lan);\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_TETHER, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6_TETHER, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_TETHER, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6_TETHER, lan);\n#else\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, lan);\n#endif\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, lan); \t\t\t\t// register for IPA_CFG_CHANGE event\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, lan); \t// register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT, lan);\n#endif\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_TETHERING_STATS_UPDATE_EVENT, lan);\n#endif\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, lan);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, lan);\n\t\t\t\tIPACMDBG_H(\"ipa_LAN (%s):ipa_index (%d) instance open/registr ok\\n\", lan->dev_name, lan->ipa_if_num);\n\t\t\t\tregistr(ipa_interface_index, lan);\n\t\t\t\t/* solve the new_addr comes earlier issue */\n                                IPACM_Iface::iface_addr_query(if_index);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ETH_IF:\n\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Creating ETH interface in router mode\\n\");\n\t\t\t\t\tIPACM_Lan *ETH = new IPACM_Lan(ipa_interface_index);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, ETH);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, ETH);\n\t\t\t\t\tIPACMDBG_H(\"ipa_LAN (%s):ipa_index (%d) instance open/registr ok\\n\", ETH->dev_name, ETH->ipa_if_num);\n\t\t\t\t\tregistr(ipa_interface_index, ETH);\n\t\t\t\t\t/* solve the new_addr comes earlier issue */\n\t\t\t\t\tIPACM_Iface::iface_addr_query(if_index);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ODU_IF:\n\t\t\t{\n\t\t\t\tif(IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == true)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\"Creating ODU interface in router mode\\n\");\n\t\t\t\t\tIPACM_Lan *odu = new IPACM_Lan(ipa_interface_index);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, odu);\n\t\t\t\t\tIPACMDBG(\"ipa_LAN (%s):ipa_index (%d) instance open/registr ok\\n\", odu->dev_name, odu->ipa_if_num);\n\t\t\t\t\tregistr(ipa_interface_index, odu);\n\t\t\t\t\t/* solve the new_addr comes earlier issue */\n\t\t\t\t\tIPACM_Iface::iface_addr_query(if_index);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\"Creating ODU interface in bridge mode\\n\");\n\t\t\t\t\tIPACM_Lan *odu = new IPACM_Lan(ipa_interface_index);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, odu);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, odu);\n\t\t\t\t\tIPACMDBG(\"ipa_LAN (%s):ipa_index (%d) instance open/registr ok\\n\", odu->dev_name, odu->ipa_if_num);\n\t\t\t\t\tregistr(ipa_interface_index, odu);\n\t\t\t\t\t/* solve the new_addr comes earlier issue */\n\t\t\t\t\tIPACM_Iface::iface_addr_query(if_index);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase WLAN_IF:\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Creating WLan interface\\n\");\n\t\t\t\tIPACM_Wlan *wl = new IPACM_Wlan(ipa_interface_index);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ROUTE_DEL_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_ADD_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_ADD_EVENT_EX, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_DEL_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_POWER_SAVE_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_RECOVER_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, wl);\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_TETHER, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6_TETHER, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_TETHER, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6_TETHER, wl);\n#else\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, wl);\n#endif\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, wl); \t// register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_USB_CLIENT_ADD_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_USB_CLIENT_DEL_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT, wl);\n#endif\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, wl);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, wl);\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_TETHERING_STATS_UPDATE_EVENT, wl);\n#endif\n\t\t\t\tIPACMDBG_H(\"ipa_WLAN (%s):ipa_index (%d) instance open/registr ok\\n\", wl->dev_name, wl->ipa_if_num);\n\t\t\t\tregistr(ipa_interface_index, wl);\n\t\t\t\t/* solve the new_addr comes earlier issue */\n\t                        IPACM_Iface::iface_addr_query(if_index);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase WAN_IF:\n\t\t\t{\n\t\t\t\tif((IPACM_Iface::ipacmcfg->ipacm_odu_enable == false) || (IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == true))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Creating Wan interface\\n\");\n\t\t\t\t\tIPACM_Wan *w;\n\t\t\t\t\tif(is_sta_mode == WLAN_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tw = new IPACM_Wan(ipa_interface_index, is_sta_mode, param->mac_addr);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tw = new IPACM_Wan(ipa_interface_index, is_sta_mode, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, w);\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT, w);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, w);\n\t\t\t\t\tif(is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_NETWORK_STATS_UPDATE_EVENT, w);\n\t\t\t\t\t};\n#else/* defined(FEATURE_IPA_ANDROID) */\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ROUTE_ADD_EVENT, w);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_ROUTE_DEL_EVENT, w);\n#endif /* not defined(FEATURE_IPA_ANDROID)*/\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_FIREWALL_CHANGE_EVENT, w);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, w);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, w);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, w);\n\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, w); \t\t// register for IPA_CFG_CHANGE event\n\t\t\t\t\tif(is_sta_mode == WLAN_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, w); // for STA mode\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, w);\n\t\t\t\t\t}\n\t\t\t\t\tIPACMDBG_H(\"ipa_WAN (%s):ipa_index (%d) instance open/registr ok\\n\", w->dev_name, w->ipa_if_num);\n\t\t\t\t\tregistr(ipa_interface_index, w);\n\t\t\t\t\t/* solve the new_addr comes earlier issue */\n\t\t\t\t\t\t\t\t\tIPACM_Iface::iface_addr_query(if_index);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t    /* WAN-eMBMS instance */\n\t\tcase EMBMS_IF:\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Creating Wan-eMBSM interface\\n\");\n\t\t\t\tIPACM_Wan *embms = new IPACM_Wan(ipa_interface_index, is_sta_mode, NULL);\n\t\t\t\tIPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, embms);\n\t\t\t\tIPACMDBG(\"ipa_WAN (%s):ipa_index (%d) instance open/registr ok\\n\", embms->dev_name, embms->ipa_if_num);\n\t\t\t\tregistr(ipa_interface_index, embms);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tIPACMDBG_H(\"Unhandled interface category received iface name: %s, category: %d\\n\",\n\t\t\t            IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,\n\t\t\t\t\t\t       IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat);\n\t\t\treturn IPACM_SUCCESS;\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\n\nint IPACM_IfaceManager::registr(int ipa_if_index, IPACM_Listener *obj)\n{\n\tiface_instances *tmp = head,*nw;\n\n\tnw = (iface_instances *)malloc(sizeof(iface_instances));\n\tif(nw != NULL)\n\t{\n\t\tnw->ipa_if_index = ipa_if_index;\n\t\tnw->obj = obj;\n\t\tnw->next = NULL;\n\t}\n\telse\n\t{\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(head == NULL)\n\t{\n\t\thead = nw;\n\t}\n\telse\n\t{\n\t\twhile(tmp->next)\n\t\t{\n\t\t\ttmp = tmp->next;\n\t\t}\n\t\ttmp->next = nw;\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_IfaceManager::deregistr(IPACM_Listener *param)\n{\n\tiface_instances *tmp = head,*tmp1,*prev = head;\n\n\twhile(tmp != NULL)\n\t{\n\t\tif(tmp->obj == param)\n\t\t{\n\t\t\ttmp1 = tmp;\n\t\t\tif(tmp == head)\n\t\t\t{\n\t\t\t\thead = head->next;\n\t\t\t}\n\t\t\telse if(tmp->next == NULL)\n\t\t\t{\n\t\t\t\tprev->next = NULL;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprev->next = tmp->next;\n\t\t\t}\n\n\t\t\ttmp = tmp->next;\n\t\t\tfree(tmp1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprev = tmp;\n\t\t\ttmp = tmp->next;\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\n\nint IPACM_IfaceManager::SearchInstance(int ipa_if_index)\n{\n\n\tiface_instances *tmp = head;\n\n\twhile(tmp != NULL)\n\t{\n\t\tif(ipa_if_index == tmp->ipa_if_index)\n\t\t{\n\t\t\tIPACMDBG_H(\"Find existed iface-instance name: %s\\n\",\n\t\t\t\t\t\t\t IPACM_Iface::ipacmcfg->iface_table[ipa_if_index].iface_name);\n\t\t\treturn IPA_INSTANCE_FOUND;\n\t\t}\n\t\ttmp = tmp->next;\n\t}\n\n\tIPACMDBG_H(\"No existed iface-instance name: %s,\\n\",\n\t\t\t\t\t IPACM_Iface::ipacmcfg->iface_table[ipa_if_index].iface_name);\n\n\treturn IPA_INSTANCE_NOT_FOUND;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n* Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following\ndisclaimer in the documentation and/or other materials provided\nwith the distribution.\n\n* Neither the name of The Linux Foundation nor the names of its\ncontributors may be used to endorse or promote products derived\nfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Lan.cpp\n\n\t@brief\n\tThis file implements the LAN iface functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#include <string.h>\n#include <fcntl.h>\n#include <sys/ioctl.h>\n#include \"IPACM_Netlink.h\"\n#include \"IPACM_Lan.h\"\n#include \"IPACM_Wan.h\"\n#include \"IPACM_IfaceManager.h\"\n#include \"linux/rmnet_ipa_fd_ioctl.h\"\n#include \"linux/ipa_qmi_service_v01.h\"\n#include \"linux/msm_ipa.h\"\n#include \"IPACM_ConntrackListener.h\"\n#include <sys/ioctl.h>\n#include <fcntl.h>\n\nbool IPACM_Lan::odu_up = false;\n\nipa_hdr_l2_type IPACM_Lan::usb_hdr_type = IPA_HDR_L2_NONE;\nipa_hdr_l2_type IPACM_Lan::wlan_hdr_type = IPA_HDR_L2_NONE;\n\nuint32_t IPACM_Lan::usb_hdr_template_hdl = 0;\nuint32_t IPACM_Lan::wlan_hdr_template_hdl = 0;\n\nhdr_proc_ctx_info IPACM_Lan::usb_to_wlan_hdr_proc_ctx;\nhdr_proc_ctx_info IPACM_Lan::wlan_to_usb_hdr_proc_ctx;\nhdr_proc_ctx_info IPACM_Lan::wlan_to_wlan_hdr_proc_ctx;\n\neth_bridge_subnet_client_info IPACM_Lan::eth_bridge_wlan_client[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\neth_bridge_subnet_client_info IPACM_Lan::eth_bridge_usb_client[IPA_LAN_TO_LAN_MAX_USB_CLIENT];\n\nint IPACM_Lan::num_wlan_client = 0;\nint IPACM_Lan::num_usb_client = 0;\n\nIPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)\n{\n\tnum_eth_client = 0;\n\theader_name_count = 0;\n\tipv6_set = 0;\n\tipv4_header_set = false;\n\tipv6_header_set = false;\n\todu_route_rule_v4_hdl = NULL;\n\todu_route_rule_v6_hdl = NULL;\n\teth_client = NULL;\n\tint m_fd_odu, ret = IPACM_SUCCESS;\n\n\tNat_App = NatApp::GetInstance();\n\tif (Nat_App == NULL)\n\t{\n\t\tIPACMERR(\"unable to get Nat App instance \\n\");\n\t\treturn;\n\t}\n\n\t/* support eth multiple clients */\n\tif(iface_query != NULL)\n\t{\n\n\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat != WLAN_IF)\n\t{\n\t\teth_client_len = (sizeof(ipa_eth_client)) + (iface_query->num_tx_props * sizeof(eth_client_rt_hdl));\n\t\teth_client = (ipa_eth_client *)calloc(IPA_MAX_NUM_ETH_CLIENTS, eth_client_len);\n\t\tif (eth_client == NULL)\n\t\t{\n\t\t\tIPACMERR(\"unable to allocate memory\\n\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\tIPACMDBG_H(\" IPACM->IPACM_Lan(%d) constructor: Tx:%d Rx:%d\\n\", ipa_if_num,\n\t\t\t\t\t iface_query->num_tx_props, iface_query->num_rx_props);\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF && tx_prop != NULL)\n\t\t{\n\t\t\tif(IPACM_Lan::usb_hdr_type != IPA_HDR_L2_NONE && tx_prop->tx[0].hdr_l2_type != IPACM_Lan::usb_hdr_type)\n\t\t\t{\n\t\t\t\tIPACMERR(\"The USB header format is not consistent! Now header format is %d.\\n\", tx_prop->tx[0].hdr_l2_type);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(eth_bridge_get_hdr_template_hdl(&IPACM_Lan::usb_hdr_template_hdl) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to setup usb hdr template.\\n\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACM_Lan::usb_hdr_type = tx_prop->tx[0].hdr_l2_type;\n\t\t\t\t\tadd_hdr_proc_ctx();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#endif\n\t\t/* ODU routing table initilization */\n\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)\n\t\t{\n\t\t\todu_route_rule_v4_hdl = (uint32_t *)calloc(iface_query->num_tx_props, sizeof(uint32_t));\n\t\t\todu_route_rule_v6_hdl = (uint32_t *)calloc(iface_query->num_tx_props, sizeof(uint32_t));\n\t\t\tif ((odu_route_rule_v4_hdl == NULL) || (odu_route_rule_v6_hdl == NULL))\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tnum_wan_ul_fl_rule_v4 = 0;\n\tnum_wan_ul_fl_rule_v6 = 0;\n\n\tmemset(wan_ul_fl_rule_hdl_v4, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));\n\tmemset(wan_ul_fl_rule_hdl_v6, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));\n\n\tmemset(lan2lan_flt_rule_hdl_v4, 0, MAX_OFFLOAD_PAIR * sizeof(lan2lan_flt_rule_hdl));\n\tnum_lan2lan_flt_rule_v4 = 0;\n\n\tmemset(lan2lan_flt_rule_hdl_v6, 0, MAX_OFFLOAD_PAIR * sizeof(lan2lan_flt_rule_hdl));\n\tnum_lan2lan_flt_rule_v6 = 0;\n\n\tmemset(lan2lan_hdr_hdl_v4, 0, MAX_OFFLOAD_PAIR*sizeof(lan2lan_hdr_hdl));\n\tmemset(lan2lan_hdr_hdl_v6, 0, MAX_OFFLOAD_PAIR*sizeof(lan2lan_hdr_hdl));\n\n\tmemset(wlan_client_flt_rule_hdl_v4, 0, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(lan2lan_flt_rule_hdl));\n\tmemset(wlan_client_flt_rule_hdl_v6, 0, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(lan2lan_flt_rule_hdl));\n\n\tis_active = true;\n\tmemset(tcp_ctl_flt_rule_hdl_v4, 0, NUM_TCP_CTL_FLT_RULE*sizeof(uint32_t));\n\tmemset(tcp_ctl_flt_rule_hdl_v6, 0, NUM_TCP_CTL_FLT_RULE*sizeof(uint32_t));\n\tis_mode_switch = false;\n\tif_ipv4_subnet =0;\n\tmemset(private_fl_rule_hdl, 0, IPA_MAX_PRIVATE_SUBNET_ENTRIES * sizeof(uint32_t));\n\tmemset(ipv6_prefix_flt_rule_hdl, 0, NUM_IPV6_PREFIX_FLT_RULE * sizeof(uint32_t));\n\tmemset(ipv6_icmp_flt_rule_hdl, 0, NUM_IPV6_ICMP_FLT_RULE * sizeof(uint32_t));\n\tmodem_ul_v4_set = false;\n\tmodem_ul_v6_set = false;\n\n\t/* ODU routing table initilization */\n\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)\n\t{\n\n\t\t/* only do one time ioctl to odu-driver to infrom in router or bridge mode*/\n\t\tif (IPACM_Lan::odu_up != true)\n\t\t{\n\t\t\t\tm_fd_odu = open(IPACM_Iface::ipacmcfg->DEVICE_NAME_ODU, O_RDWR);\n\t\t\t\tif (0 == m_fd_odu)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed opening %s.\\n\", IPACM_Iface::ipacmcfg->DEVICE_NAME_ODU);\n\t\t\t\t\treturn ;\n\t\t\t\t}\n\n\t\t\t\tif(IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == true)\n\t\t\t\t{\n\t\t\t\t\tret = ioctl(m_fd_odu, ODU_BRIDGE_IOC_SET_MODE, ODU_BRIDGE_MODE_ROUTER);\n\t\t\t\t\tIPACM_Iface::ipacmcfg->ipacm_odu_enable = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tret = ioctl(m_fd_odu, ODU_BRIDGE_IOC_SET_MODE, ODU_BRIDGE_MODE_BRIDGE);\n\t\t\t\t\tIPACM_Iface::ipacmcfg->ipacm_odu_enable = true;\n\t\t\t\t}\n\n\t\t\t\tif (ret)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed tell odu-driver the mode\\n\");\n\t\t\t\t}\n\t\t\t\tIPACMDBG(\"Tell odu-driver in router-mode(%d)\\n\", IPACM_Iface::ipacmcfg->ipacm_odu_router_mode);\n\t\t\t\tclose(m_fd_odu);\n\t\t\t\tIPACM_Lan::odu_up = true;\n\t\t}\n\t}\n\n\tint i;\n\teach_client_rt_rule_count_v4 = 0;\n\teach_client_rt_rule_count_v6 = 0;\n\tif(iface_query != NULL && tx_prop != NULL)\n\t{\n\t\tfor(i=0; i<iface_query->num_tx_props; i++)\n\t\t{\n\t\t\tif(tx_prop->tx[i].ip == IPA_IP_v4)\n\t\t\t{\n\t\t\t\teach_client_rt_rule_count_v4++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\teach_client_rt_rule_count_v6++;\n\t\t\t}\n\t\t}\n\t}\n\tIPACMDBG_H(\"Need to add %d IPv4 and %d IPv6 routing rules for eth bridge for each client.\\n\", each_client_rt_rule_count_v4, each_client_rt_rule_count_v6);\n\n\tmemset(eth_bridge_wlan_client_flt_info, 0, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(eth_bridge_client_flt_info));\n\twlan_client_flt_info_count = 0;\n\teth_bridge_usb_client_rt_info_v4 = NULL;\n\teth_bridge_usb_client_rt_info_v6 = NULL;\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tif(tx_prop != NULL)\n\t{\n\t\tclient_rt_info_size_v4 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v4 * sizeof(uint32_t);\n\t\teth_bridge_usb_client_rt_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_USB_CLIENT, client_rt_info_size_v4);\n\t\tclient_rt_info_size_v6 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v6 * sizeof(uint32_t);\n\t\teth_bridge_usb_client_rt_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_USB_CLIENT, client_rt_info_size_v6);\n\t}\n#endif\n\tusb_client_rt_info_count_v4 = 0;\n\tusb_client_rt_info_count_v6 = 0;\n\n#ifdef FEATURE_IPA_ANDROID\n\t/* set the IPA-client pipe enum */\n\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)\n\t{\n\t\thandle_tethering_client(false, IPACM_CLIENT_USB);\n\t}\n#endif\n\treturn;\n}\n\nIPACM_Lan::~IPACM_Lan()\n{\n\tIPACM_EvtDispatcher::deregistr(this);\n\tIPACM_IfaceManager::deregistr(this);\n\treturn;\n}\n\n\n/* LAN-iface's callback function */\nvoid IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)\n{\n\tif(is_active == false && event != IPA_LAN_DELETE_SELF)\n\t{\n\t\tIPACMDBG_H(\"The interface is no longer active, return.\\n\");\n\t\treturn;\n\t}\n\n\tint ipa_interface_index;\n\tipacm_ext_prop* ext_prop;\n\tipacm_event_iface_up* data_wan;\n\tipacm_event_iface_up_tehter* data_wan_tether;\n\n\tswitch (event)\n\t{\n\tcase IPA_LINK_DOWN_EVENT:\n\t\t{\n\t\t\tipacm_event_data_fid *data = (ipacm_event_data_fid *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_LINK_DOWN_EVENT\\n\");\n\t\t\t\thandle_down_evt();\n\t\t\t\tIPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_CFG_CHANGE_EVENT:\n\t\t{\n\t\t\tif ( IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat != ipa_if_cate)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_CFG_CHANGE_EVENT and category changed\\n\");\n\t\t\t\t/* delete previous instance */\n\t\t\t\thandle_down_evt();\n\t\t\t\tIPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface\n\t\t\t\tis_mode_switch = true; // need post internal usb-link up event\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_PRIVATE_SUBNET_CHANGE_EVENT:\n\t\t{\n\t\t\tipacm_event_data_fid *data = (ipacm_event_data_fid *)param;\n\t\t\t/* internel event: data->if_index is ipa_if_index */\n\t\t\tif (data->if_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_PRIVATE_SUBNET_CHANGE_EVENT from itself posting, ignore\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_PRIVATE_SUBNET_CHANGE_EVENT from other LAN iface \\n\");\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\thandle_private_subnet_android(IPA_IP_v4);\n#endif\n\t\t\t\tIPACMDBG_H(\" delete old private subnet rules, use new sets \\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_LAN_DELETE_SELF:\n\t{\n\t\tipacm_event_data_fid *data = (ipacm_event_data_fid *)param;\n\t\tif(data->if_index == ipa_if_num)\n\t\t{\n\t\t\tIPACMDBG_H(\"Received IPA_LAN_DELETE_SELF event.\\n\");\n\t\t\tIPACMDBG_H(\"ipa_LAN (%s):ipa_index (%d) instance close \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ipa_if_num);\n\t\t\t/* posting link-up event for cradle use-case */\n\t\t\tif(is_mode_switch)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Posting IPA_USB_LINK_UP_EVENT event for (%s)\\n\", dev_name);\n\t\t\t\tipacm_cmd_q_data evt_data;\n\t\t\t\tmemset(&evt_data, 0, sizeof(evt_data));\n\n\t\t\t\tipacm_event_data_fid *data_fid = NULL;\n\t\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\t\tif(data_fid == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to allocate memory for IPA_USB_LINK_UP_EVENT data_fid\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif(IPACM_Iface::ipa_get_if_index(dev_name, &(data_fid->if_index)))\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error while getting interface index for %s device\", dev_name);\n\t\t\t\t}\n\t\t\t\tevt_data.event = IPA_USB_LINK_UP_EVENT;\n\t\t\t\tevt_data.evt_data = data_fid;\n\t\t\t\t//IPACMDBG_H(\"Posting event:%d\\n\", evt_data.event);\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t}\n\t\t\tdelete this;\n\t\t}\n\t\tbreak;\n\t}\n\n\tcase IPA_ADDR_ADD_EVENT:\n\t\t{\n\t\t\tipacm_event_data_addr *data = (ipacm_event_data_addr *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\n\t\t\tif ( (data->iptype == IPA_IP_v4 && data->ipv4_addr == 0) ||\n\t\t\t\t\t (data->iptype == IPA_IP_v6 &&\n\t\t\t\t\t\tdata->ipv6_addr[0] == 0 && data->ipv6_addr[1] == 0 &&\n\t\t\t\t\t  data->ipv6_addr[2] == 0 && data->ipv6_addr[3] == 0) )\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Invalid address, ignore IPA_ADDR_ADD_EVENT event\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\n\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_ADDR_ADD_EVENT\\n\");\n\n\t\t\t\t/* only call ioctl for ODU iface with bridge mode */\n\t\t\t\tif((IPACM_Iface::ipacmcfg->ipacm_odu_enable == true) && (IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == false)\n\t\t\t\t\t\t&& (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF))\n\t\t\t\t{\n\t\t\t\t\tif((data->iptype == IPA_IP_v6) && (num_dft_rt_v6 == 0))\n\t\t\t\t\t{\n\t\t\t\t\t\thandle_addr_evt_odu_bridge(data);\n\t\t\t\t\t}\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\t\tadd_dummy_private_subnet_flt_rule(data->iptype);\n\t\t\t\t\thandle_private_subnet_android(data->iptype);\n#else\n\t\t\t\t\thandle_private_subnet(data->iptype);\n#endif\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\n\t\t\t\t\t/* check v4 not setup before, v6 can have 2 iface ip */\n\t\t\t\t\tif( ((data->iptype != ip_type) && (ip_type != IPA_IP_MAX))\n\t\t\t\t\t\t|| ((data->iptype==IPA_IP_v6) && (num_dft_rt_v6!=MAX_DEFAULT_v6_ROUTE_RULES)))\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Got IPA_ADDR_ADD_EVENT ip-family:%d, v6 num %d: \\n\",data->iptype,num_dft_rt_v6);\n\t\t\t\t\t\t/* ADD ipv6 icmp rule */\n\t\t\t\t\t\tif ((num_dft_rt_v6 == 0) && (data->iptype == IPA_IP_v6))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tinstall_ipv6_icmp_flt_rule();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(handle_addr_evt(data) == IPACM_FAILURE)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\thandle_private_subnet(data->iptype);\n\n\t\t\t\t\t\tif (IPACM_Wan::isWanUP(ipa_if_num))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(data->iptype == IPA_IP_v4 || data->iptype == IPA_IP_MAX)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif(IPACM_Wan::backhaul_is_sta_mode == false)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v4);\n\t\t\t\t\t\t\t\t\thandle_wan_up_ex(ext_prop, IPA_IP_v4);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\thandle_wan_up(IPA_IP_v4);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif(IPACM_Wan::isWanUP_V6(ipa_if_num))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif((data->iptype == IPA_IP_v6 || data->iptype == IPA_IP_MAX) && num_dft_rt_v6 == 1)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinstall_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);\n\t\t\t\t\t\t\t\tif(IPACM_Wan::backhaul_is_sta_mode == false)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v6);\n\t\t\t\t\t\t\t\t\thandle_wan_up_ex(ext_prop, IPA_IP_v6);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\thandle_wan_up(IPA_IP_v6);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* Post event to NAT */\n\t\t\t\t\t\tif (data->iptype == IPA_IP_v4)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tipacm_cmd_q_data evt_data;\n\t\t\t\t\t\t\tipacm_event_iface_up *info;\n\n\t\t\t\t\t\t\tinfo = (ipacm_event_iface_up *)\n\t\t\t\t\t\t\t\tmalloc(sizeof(ipacm_event_iface_up));\n\t\t\t\t\t\t\tif (info == NULL)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tmemcpy(info->ifname, dev_name, IF_NAME_LEN);\n\t\t\t\t\t\t\tinfo->ipv4_addr = data->ipv4_addr;\n\t\t\t\t\t\t\tinfo->addr_mask = IPACM_Iface::ipacmcfg->private_subnet_table[0].subnet_mask;\n\n\t\t\t\t\t\t\tevt_data.event = IPA_HANDLE_LAN_UP;\n\t\t\t\t\t\t\tevt_data.evt_data = (void *)info;\n\n\t\t\t\t\t\t\t/* Insert IPA_HANDLE_LAN_UP to command queue */\n\t\t\t\t\t\t\tIPACMDBG_H(\"posting IPA_HANDLE_LAN_UP for IPv4 with below information\\n\");\n\t\t\t\t\t\t\tIPACMDBG_H(\"IPv4 address:0x%x, IPv4 address mask:0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t\tinfo->ipv4_addr, info->addr_mask);\n\t\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tIPACMDBG_H(\"Finish handling IPA_ADDR_ADD_EVENT for ip-family(%d)\\n\", data->iptype);\n\t\t\t\t\t}\n\n\t\t\t\t\tIPACMDBG_H(\"Finish handling IPA_ADDR_ADD_EVENT for ip-family(%d)\\n\", data->iptype);\n\t\t\t\t\t/* checking if SW-RT_enable */\n\t\t\t\t\tif (IPACM_Iface::ipacmcfg->ipa_sw_rt_enable == true)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* handle software routing enable event*/\n\t\t\t\t\t\tIPACMDBG_H(\"IPA_SW_ROUTING_ENABLE for iface: %s \\n\",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);\n\t\t\t\t\t\thandle_software_routing_enable();\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n#ifdef FEATURE_IPA_ANDROID\n\tcase IPA_HANDLE_WAN_UP_TETHER:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_UP_TETHER event\\n\");\n\n\t\tdata_wan_tether = (ipacm_event_iface_up_tehter*)param;\n\t\tif(data_wan_tether == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d, if_index_tether:%d tether_if_name:%s\\n\", data_wan_tether->is_sta,\n\t\t\t\t\tdata_wan_tether->if_index_tether,\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[data_wan_tether->if_index_tether].iface_name);\n\t\tif (data_wan_tether->if_index_tether == ipa_if_num)\n\t\t{\n\t\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\tif(data_wan_tether->is_sta == false)\n\t\t\t\t{\n\t\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v4);\n\t\t\t\t\thandle_wan_up_ex(ext_prop, IPA_IP_v4);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\thandle_wan_up(IPA_IP_v4);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_UP_V6_TETHER:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_UP_V6_TETHER event\\n\");\n\n\t\tdata_wan_tether = (ipacm_event_iface_up_tehter*)param;\n\t\tif(data_wan_tether == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d, if_index_tether:%d tether_if_name:%s\\n\", data_wan_tether->is_sta,\n\t\t\t\t\tdata_wan_tether->if_index_tether,\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[data_wan_tether->if_index_tether].iface_name);\n\t\tif (data_wan_tether->if_index_tether == ipa_if_num)\n\t\t{\n\t\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\t\tinstall_ipv6_prefix_flt_rule(data_wan_tether->ipv6_prefix);\n\t\t\t\t\tif(data_wan_tether->is_sta == false)\n\t\t\t\t\t{\n\t\t\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v6);\n\t\t\t\t\t\thandle_wan_up_ex(ext_prop, IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\thandle_wan_up(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_DOWN_TETHER:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN_TETHER event\\n\");\n\t\tdata_wan_tether = (ipacm_event_iface_up_tehter*)param;\n\t\tif(data_wan_tether == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d, if_index_tether:%d tether_if_name:%s\\n\", data_wan_tether->is_sta,\n\t\t\t\t\tdata_wan_tether->if_index_tether,\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[data_wan_tether->if_index_tether].iface_name);\n\t\tif (data_wan_tether->if_index_tether == ipa_if_num)\n\t\t{\n\t\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\thandle_wan_down(data_wan_tether->is_sta);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_DOWN_V6_TETHER:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN_V6_TETHER event\\n\");\n\t\tdata_wan_tether = (ipacm_event_iface_up_tehter*)param;\n\t\tif(data_wan_tether == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d, if_index_tether:%d tether_if_name:%s\\n\", data_wan_tether->is_sta,\n\t\t\t\t\tdata_wan_tether->if_index_tether,\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[data_wan_tether->if_index_tether].iface_name);\n\t\tif (data_wan_tether->if_index_tether == ipa_if_num)\n\t\t{\n\t\t\t/* clean up v6 RT rules*/\n\t\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN_V6_TETHER in LAN-instance and need clean up client IPv6 address \\n\");\n\t\t\t/* reset usb-client ipv6 rt-rules */\n\t\t\thandle_lan_client_reset_rt(IPA_IP_v6);\n\n\t\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\thandle_wan_down_v6(data_wan_tether->is_sta);\n\t\t\t}\n\t\t}\n\t\tbreak;\n#else\n\tcase IPA_HANDLE_WAN_UP:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_UP event\\n\");\n\n\t\tdata_wan = (ipacm_event_iface_up*)param;\n\t\tif(data_wan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d\\n\", data_wan->is_sta);\n\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t{\n\t\tif(data_wan->is_sta == false)\n\t\t{\n\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v4);\n\t\t\t\thandle_wan_up_ex(ext_prop, IPA_IP_v4);\n\t\t\t}\n\t\telse\n\t\t{\n\t\t\thandle_wan_up(IPA_IP_v4);\n\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_UP_V6:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_UP_V6 event\\n\");\n\n\t\tdata_wan = (ipacm_event_iface_up*)param;\n\t\tif(data_wan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d\\n\", data_wan->is_sta);\n\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t{\n\t\t\tinstall_ipv6_prefix_flt_rule(data_wan->ipv6_prefix);\n\t\tif(data_wan->is_sta == false)\n\t\t{\n\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v6);\n\t\t\t\thandle_wan_up_ex(ext_prop, IPA_IP_v6);\n\t\t\t}\n\t\telse\n\t\t{\n\t\t\thandle_wan_up(IPA_IP_v6);\n\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_DOWN:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN event\\n\");\n\t\tdata_wan = (ipacm_event_iface_up*)param;\n\t\tif(data_wan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d\\n\", data_wan->is_sta);\n\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t{\n\t\t\thandle_wan_down(data_wan->is_sta);\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_DOWN_V6:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN_V6 event\\n\");\n\t\tdata_wan = (ipacm_event_iface_up*)param;\n\t\tif(data_wan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\t/* clean up v6 RT rules*/\n\t\tIPACMDBG_H(\"Received IPA_WAN_V6_DOWN in LAN-instance and need clean up client IPv6 address \\n\");\n\t\t/* reset usb-client ipv6 rt-rules */\n\t\thandle_lan_client_reset_rt(IPA_IP_v6);\n\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d\\n\", data_wan->is_sta);\n\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t{\n\t\t\thandle_wan_down_v6(data_wan->is_sta);\n\t\t}\n\t\tbreak;\n#endif\n\n\tcase IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT:\n\t\t{\n\t\t\tipacm_event_data_all *data = (ipacm_event_data_all *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tIPACMDBG_H(\"check iface %s category: %d\\n\",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat);\n\n\t\t\tif ((ipa_interface_index == ipa_if_num) && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF))\n\t\t\t{\n\t\t\t\tIPACMDBG(\"ODU iface got v4-ip \\n\");\n\t\t\t\t/* first construc ODU full header */\n\t\t\t\tif ((ipv4_header_set == false) && (ipv6_header_set == false))\n\t\t\t\t{\n\t\t\t\t\thandle_odu_hdr_init(data->mac_addr);\n\t\t\t\t\thandle_odu_route_add(); /* construct ODU RT tbl*/\n\t\t\t\t\tIPACMDBG(\"construct ODU header and route rules \\n\");\n\t\t\t\t}\n\t\t\t\t/* if ODU in bridge mode, directly return */\n\t\t\t\tif(IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == false)\n\t\t\t\t{\n\t\t\t\t  return;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"ETH iface got client \\n\");\n\t\t\t\t/* first construc ETH full header */\n\t\t\t\thandle_eth_hdr_init(data->mac_addr);\n\t\t\t\thandle_lan2lan_client_active(data, IPA_LAN_CLIENT_ACTIVE);\n\t\t\t\tIPACMDBG_H(\"construct ETH header and route rules \\n\");\n\t\t\t\t/* Associate with IP and construct RT-rule */\n\t\t\t\tif (handle_eth_client_ipaddr(data) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thandle_eth_client_route_rule(data->mac_addr, data->iptype);\n\t\t\t\tif (data->iptype == IPA_IP_v4)\n\t\t\t\t{\n\t\t\t\t\t/* Add NAT rules after ipv4 RT rules are set */\n\t\t\t\t\tCtList->HandleNeighIpAddrAddEvt(data);\n\t\t\t\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t\t\tif(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == true)\n\t\t\t\t{\n\t\t\t\t\teth_bridge_add_usb_client_rt_rule(data->mac_addr, IPA_IP_v4);\n\t\t\t\t\teth_bridge_add_usb_client_rt_rule(data->mac_addr, IPA_IP_v6);\n\t\t\t\t}\n\t\t\t\teth_bridge_post_lan_client_event(data->mac_addr, IPA_ETH_BRIDGE_USB_CLIENT_ADD_EVENT);\n\t\t\t\teth_bridge_add_usb_client(data->mac_addr);\n#endif\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT:\n\t\t{\n\t\t\tipacm_event_data_all *data = (ipacm_event_data_all *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\n\t\t\tIPACMDBG_H(\"check iface %s category: %d\\n\",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"ETH iface delete client \\n\");\n\t\t\t\thandle_eth_client_down_evt(data->mac_addr);\n\t\t\t\thandle_lan2lan_client_active(data, IPA_LAN_CLIENT_INACTIVE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_SW_ROUTING_ENABLE:\n\t\tIPACMDBG_H(\"Received IPA_SW_ROUTING_ENABLE\\n\");\n\t\t/* handle software routing enable event*/\n\t\thandle_software_routing_enable();\n\t\tbreak;\n\n\tcase IPA_SW_ROUTING_DISABLE:\n\t\tIPACMDBG_H(\"Received IPA_SW_ROUTING_DISABLE\\n\");\n\t\t/* handle software routing disable event*/\n\t\thandle_software_routing_disable();\n\t\tbreak;\n\n\tcase IPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT:\n\t\t{\n\t\t\tIPACMDBG_H(\"Received IPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT event.\\n\");\n\t\t\tipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;\n\t\t\tif(mac != NULL)\n\t\t\t{\n\t\t\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t\t\t{\n\t\t\t\t\teth_bridge_add_wlan_client_flt_rule(mac->mac_addr, IPA_IP_v4);\n\t\t\t\t}\n\t\t\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t\t\t{\n\t\t\t\t\teth_bridge_add_wlan_client_flt_rule(mac->mac_addr, IPA_IP_v6);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMERR(\"Event MAC is empty.\\n\");\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT:\n\t\t{\n\t\t\tIPACMDBG_H(\"Received IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT event.\\n\");\n\t\t\tipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;\n\t\t\tif(mac != NULL)\n\t\t\t{\n\t\t\t\tif(eth_bridge_del_wlan_client_flt_rule(mac->mac_addr) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Failed to delete wlan client MAC based flt rule.\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMERR(\"Event MAC is empty.\\n\");\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT:\n\t{\n\t\tIPACMDBG_H(\"Received IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT event.\\n\");\n\t\tint i;\n\t\tipacm_event_data_fid* fid = (ipacm_event_data_fid*)param;\n\t\tif(fid == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Event data is empty.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif(fid->if_index == ipa_if_num)\n\t\t{\n\t\t\tIPACMDBG_H(\"The event was sent by the same interface, ignore.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tfor(i=0; i<IPACM_Lan::num_usb_client; i++)\n\t\t{\n\t\t\teth_bridge_add_usb_client_rt_rule(IPACM_Lan::eth_bridge_usb_client[i].mac, IPA_IP_v4);\n\t\t\teth_bridge_add_usb_client_rt_rule(IPACM_Lan::eth_bridge_usb_client[i].mac, IPA_IP_v6);\n\t\t}\n\t}\n\tbreak;\n\n\tcase IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT:\n\t{\n\t\tIPACMDBG_H(\"Received IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT event.\\n\");\n\t\tint i;\n\t\tipacm_event_data_fid* fid = (ipacm_event_data_fid*)param;\n\t\tif(fid == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Event data is empty.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif(fid->if_index == ipa_if_num)\n\t\t{\n\t\t\tIPACMDBG_H(\"The event was sent by the same interface, ignore.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tfor(i=0; i<IPACM_Lan::num_usb_client; i++)\n\t\t{\n\t\t\teth_bridge_del_usb_client_rt_rule(IPACM_Lan::eth_bridge_usb_client[i].mac);\n\t\t}\n\t}\n\tbreak;\n\n\tcase IPA_TETHERING_STATS_UPDATE_EVENT:\n\t{\n\t\tIPACMDBG_H(\"Received IPA_TETHERING_STATS_UPDATE_EVENT event.\\n\");\n\t\tif (IPACM_Wan::isWanUP(ipa_if_num) || IPACM_Wan::isWanUP_V6(ipa_if_num))\n\t\t{\n\t\t\tif(IPACM_Wan::backhaul_is_sta_mode == false) /* LTE */\n\t\t\t{\n\t\t\t\tipa_get_data_stats_resp_msg_v01 *data = (ipa_get_data_stats_resp_msg_v01 *)param;\n\t\t\t\tIPACMDBG(\"Received IPA_TETHERING_STATS_UPDATE_STATS ipa_stats_type: %d\\n\",data->ipa_stats_type);\n\t\t\t\tIPACMDBG(\"Received %d UL, %d DL pipe stats\\n\",data->ul_src_pipe_stats_list_len,\n\t\t\t\t\tdata->dl_dst_pipe_stats_list_len);\n\t\t\t\tif (data->ipa_stats_type != QMI_IPA_STATS_TYPE_PIPE_V01)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"not valid pipe stats enum(%d)\\n\", data->ipa_stats_type);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thandle_tethering_stats_event(data);\n\t\t\t}\n\t\t}\n\t}\n\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn;\n}\n\n/* delete filter rule for wan_down event for IPv4*/\nint IPACM_Lan::handle_wan_down(bool is_sta_mode)\n{\n\tipa_fltr_installed_notif_req_msg_v01 flt_index;\n\tint fd;\n\n\tfd = open(IPA_DEVICE_NAME, O_RDWR);\n\tif (0 == fd)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", IPA_DEVICE_NAME);\n\t\treturn IPACM_FAILURE;\n\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tflt_rule_count_v4 = IPV4_DEFAULT_FILTERTING_RULES + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n#else\n#ifdef CT_OPT\n\tflt_rule_count_v4 = IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR\n\t\t\t\t\t+ NUM_TCP_CTL_FLT_RULE + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n#else\n\tflt_rule_count_v4 = IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR\n\t\t\t\t\t+ IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n#endif\n#ifdef FEATURE_IPA_ANDROID\n\tflt_rule_count_v4 = flt_rule_count_v4 - IPACM_Iface::ipacmcfg->ipa_num_private_subnet + IPA_MAX_PRIVATE_SUBNET_ENTRIES;\n#endif\n#endif\n\n\tif(is_sta_mode == false)\n\t{\n\t\tif (num_wan_ul_fl_rule_v4 > MAX_WAN_UL_FILTER_RULES)\n\t\t{\n\t\t\tIPACMERR(\"number of wan_ul_fl_rule_v4 (%d) > MAX_WAN_UL_FILTER_RULES (%d), aborting...\\n\", num_wan_ul_fl_rule_v4, MAX_WAN_UL_FILTER_RULES);\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tif (m_filtering.DeleteFilteringHdls(wan_ul_fl_rule_hdl_v4,\n\t\t\tIPA_IP_v4, num_wan_ul_fl_rule_v4) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting RuleTable(1) to Filtering, aborting...\\n\");\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tmemset(wan_ul_fl_rule_hdl_v4, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));\n\t\tnum_wan_ul_fl_rule_v4 = 0;\n\t\tmodem_ul_v4_set = false;\n\n\t\tmemset(&flt_index, 0, sizeof(flt_index));\n\t\tflt_index.source_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, rx_prop->rx[0].src_pipe);\n\t\tflt_index.install_status = IPA_QMI_RESULT_SUCCESS_V01;\n\t\tflt_index.filter_index_list_len = 0;\n\t\tflt_index.embedded_pipe_index_valid = 1;\n\t\tflt_index.embedded_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, IPA_CLIENT_APPS_LAN_WAN_PROD);\n\t\tflt_index.retain_header_valid = 1;\n\t\tflt_index.retain_header = 0;\n\t\tflt_index.embedded_call_mux_id_valid = 1;\n\t\tflt_index.embedded_call_mux_id = IPACM_Iface::ipacmcfg->GetQmapId();\n\n\t\tif(false == m_filtering.SendFilteringRuleIndex(&flt_index))\n\t\t{\n\t\t\tIPACMERR(\"Error sending filtering rule index, aborting...\\n\");\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (m_filtering.DeleteFilteringHdls(&lan_wan_fl_rule_hdl[0], IPA_IP_v4, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding RuleTable(1) to Filtering, aborting...\\n\");\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tclose(fd);\n\treturn IPACM_SUCCESS;\n}\n\n/* handle new_address event*/\nint IPACM_Lan::handle_addr_evt(ipacm_event_data_addr *data)\n{\n\tstruct ipa_ioc_add_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_add *rt_rule_entry;\n\tconst int NUM_RULES = 1;\n\tint num_ipv6_addr;\n\tint res = IPACM_SUCCESS;\n\n\tIPACMDBG_H(\"set route/filter rule ip-type: %d \\n\", data->iptype);\n\n/* Add private subnet*/\n#ifdef FEATURE_IPA_ANDROID\nif (data->iptype == IPA_IP_v4)\n{\n\tIPACMDBG_H(\"current IPACM private subnet_addr number(%d)\\n\", IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n\tif_ipv4_subnet = (data->ipv4_addr >> 8) << 8;\n\tIPACMDBG_H(\" Add IPACM private subnet_addr as: 0x%x \\n\", if_ipv4_subnet);\n\tif(IPACM_Iface::ipacmcfg->AddPrivateSubnet(if_ipv4_subnet, ipa_if_num) == false)\n\t{\n\t\tIPACMERR(\" can't Add IPACM private subnet_addr as: 0x%x \\n\", if_ipv4_subnet);\n\t}\n}\n#endif /* defined(FEATURE_IPA_ANDROID)*/\n\n\tif (data->iptype == IPA_IP_v4)\n\t{\n\t\trt_rule = (struct ipa_ioc_add_rt_rule *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t\t\t\t\t\t\tNUM_RULES * sizeof(struct ipa_rt_rule_add));\n\n\t\tif (!rt_rule)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\trt_rule->commit = 1;\n\t\trt_rule->num_rules = NUM_RULES;\n\t\trt_rule->ip = data->iptype;\n\t\trt_rule_entry = &rt_rule->rules[0];\n\t\trt_rule_entry->at_rear = false;\n\t\trt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;  //go to A5\n\t\trt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;\n   \t\tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name);\n\t\trt_rule_entry->rule.attrib.u.v4.dst_addr      = data->ipv4_addr;\n\t\trt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\t    if (false == m_routing.AddRoutingRule(rt_rule))\n\t    {\n\t    \tIPACMERR(\"Routing rule addition failed!\\n\");\n\t    \tres = IPACM_FAILURE;\n\t    \tgoto fail;\n\t    }\n\t    else if (rt_rule_entry->status)\n\t    {\n\t    \tIPACMERR(\"rt rule adding failed. Result=%d\\n\", rt_rule_entry->status);\n\t    \tres = rt_rule_entry->status;\n\t    \tgoto fail;\n\t    }\n\t\tdft_rt_rule_hdl[0] = rt_rule_entry->rt_rule_hdl;\n        IPACMDBG_H(\"ipv4 iface rt-rule hdl1=0x%x\\n\", dft_rt_rule_hdl[0]);\n\t\t/* initial multicast/broadcast/fragment filter rule */\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tinit_fl_rule(data->iptype);\n\t\teth_bridge_add_wlan_guest_ap_flt_rule(data->iptype);\n\t\teth_bridge_handle_dummy_wlan_client_flt_rule(data->iptype);\n\t\teth_bridge_handle_dummy_usb_client_flt_rule(data->iptype);\n\t\teth_bridge_install_cache_wlan_client_flt_rule(data->iptype);\n\t\teth_bridge_install_cache_usb_client_flt_rule(data->iptype);\n#else\n#ifdef CT_OPT\n\t\tinstall_tcp_ctl_flt_rule(IPA_IP_v4);\n#endif\n\t\tinit_fl_rule(data->iptype);\n\t\tadd_dummy_lan2lan_flt_rule(data->iptype);\n#endif\n\t}\n\telse\n\t{\n\t    /* check if see that v6-addr already or not*/\n\t    for(num_ipv6_addr=0;num_ipv6_addr<num_dft_rt_v6;num_ipv6_addr++)\n\t    {\n            if((ipv6_addr[num_ipv6_addr][0] == data->ipv6_addr[0]) &&\n\t           (ipv6_addr[num_ipv6_addr][1] == data->ipv6_addr[1]) &&\n\t           (ipv6_addr[num_ipv6_addr][2] == data->ipv6_addr[2]) &&\n\t           (ipv6_addr[num_ipv6_addr][3] == data->ipv6_addr[3]))\n            {\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\tbreak;\n\t        }\n\t    }\n\n\t\trt_rule = (struct ipa_ioc_add_rt_rule *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t\t\t\t\t\t\tNUM_RULES * sizeof(struct ipa_rt_rule_add));\n\n\t\tif (!rt_rule)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\trt_rule->commit = 1;\n\t\trt_rule->num_rules = NUM_RULES;\n\t\trt_rule->ip = data->iptype;\n\t\tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_v6.name);\n\n\t    rt_rule_entry = &rt_rule->rules[0];\n\t    rt_rule_entry->at_rear = false;\n\t    rt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;  //go to A5\n\t    rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;\n\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[0] = data->ipv6_addr[0];\n\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[1] = data->ipv6_addr[1];\n\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[2] = data->ipv6_addr[2];\n\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[3] = data->ipv6_addr[3];\n\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\t\tipv6_addr[num_dft_rt_v6][0] = data->ipv6_addr[0];\n\t\tipv6_addr[num_dft_rt_v6][1] = data->ipv6_addr[1];\n\t\tipv6_addr[num_dft_rt_v6][2] = data->ipv6_addr[2];\n\t\tipv6_addr[num_dft_rt_v6][3] = data->ipv6_addr[3];\n\n\t\tif (false == m_routing.AddRoutingRule(rt_rule))\n\t\t{\n\t\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse if (rt_rule_entry->status)\n\t\t{\n\t\t\tIPACMERR(\"rt rule adding failed. Result=%d\\n\", rt_rule_entry->status);\n\t\t\tres = rt_rule_entry->status;\n\t\t\tgoto fail;\n\t\t}\n\t\tdft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6] = rt_rule_entry->rt_rule_hdl;\n\n        /* setup same rule for v6_wan table*/\n\t\tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name);\n\t    if (false == m_routing.AddRoutingRule(rt_rule))\n\t\t{\n\t    \tIPACMERR(\"Routing rule addition failed!\\n\");\n\t    \tres = IPACM_FAILURE;\n\t    \tgoto fail;\n\t\t}\n\t    else if (rt_rule_entry->status)\n\t\t{\n\t    \tIPACMERR(\"rt rule adding failed. Result=%d\\n\", rt_rule_entry->status);\n\t    \tres = rt_rule_entry->status;\n\t    \tgoto fail;\n\t    }\n\t\tdft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6+1] = rt_rule_entry->rt_rule_hdl;\n\n\t\tIPACMDBG_H(\"ipv6 wan iface rt-rule hdl=0x%x hdl=0x%x, num_dft_rt_v6: %d \\n\",\n\t\t          dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6],\n\t\t          dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6+1],num_dft_rt_v6);\n\n\t\tif (num_dft_rt_v6 == 0)\n\t\t{\n\t\t\t/* initial multicast/broadcast/fragment filter rule */\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t\teth_bridge_add_wlan_guest_ap_flt_rule(data->iptype);\n\t\t\teth_bridge_handle_dummy_wlan_client_flt_rule(data->iptype);\n\t\t\teth_bridge_handle_dummy_usb_client_flt_rule(data->iptype);\n\t\t\teth_bridge_install_cache_wlan_client_flt_rule(data->iptype);\n\t\t\teth_bridge_install_cache_usb_client_flt_rule(data->iptype);\n\t\t\tinit_fl_rule(data->iptype);\n#else\n#ifdef CT_OPT\n\t\t\tinstall_tcp_ctl_flt_rule(IPA_IP_v6);\n#endif\n\t\t\tadd_dummy_lan2lan_flt_rule(data->iptype);\n\t\t\tinit_fl_rule(data->iptype);\n#endif\n\t\t}\n\t\tnum_dft_rt_v6++;\n\t\tIPACMDBG_H(\"number of default route rules %d\\n\", num_dft_rt_v6);\n\t}\n\n\tIPACMDBG_H(\"finish route/filter rule ip-type: %d, res(%d)\\n\", data->iptype, res);\n\nfail:\n\tfree(rt_rule);\n\treturn res;\n}\n\n/* configure private subnet filter rules*/\nint IPACM_Lan::handle_private_subnet(ipa_ip_type iptype)\n{\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tint i;\n\n\tipa_ioc_add_flt_rule *m_pFilteringTable;\n\n\tIPACMDBG_H(\"lan->handle_private_subnet(); set route/filter rule \\n\");\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\n\t\tm_pFilteringTable = (struct ipa_ioc_add_flt_rule *)\n\t\t\t calloc(1,\n\t\t\t\t\t\t\tsizeof(struct ipa_ioc_add_flt_rule) +\n\t\t\t\t\t\t\t(IPACM_Iface::ipacmcfg->ipa_num_private_subnet) * sizeof(struct ipa_flt_rule_add)\n\t\t\t\t\t\t\t);\n\t\tif (!m_pFilteringTable)\n\t\t{\n\t\t\tPERROR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tm_pFilteringTable->commit = 1;\n\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\tm_pFilteringTable->global = false;\n\t\tm_pFilteringTable->ip = IPA_IP_v4;\n\t\tm_pFilteringTable->num_rules = (uint8_t)IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan_v4))\n\t\t{\n\t\t\tIPACMERR(\"LAN m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan_v4=0x%p) Failed.\\n\", &IPACM_Iface::ipacmcfg->rt_tbl_lan_v4);\n\t\t\tfree(m_pFilteringTable);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\t/* Make LAN-traffic always go A5, use default IPA-RT table */\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_default_v4))\n\t\t{\n\t\t\tIPACMERR(\"LAN m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_default_v4=0x%p) Failed.\\n\", &IPACM_Iface::ipacmcfg->rt_tbl_default_v4);\n\t\t\tfree(m_pFilteringTable);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tfor (i = 0; i < (IPACM_Iface::ipacmcfg->ipa_num_private_subnet); i++)\n\t\t{\n\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\t\t\tflt_rule_entry.at_rear = true;\n\t\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\tflt_rule_entry.status = -1;\n\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\n                        /* Support priave subnet feature including guest-AP can't talk to primary AP etc */\n\t\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_default_v4.hdl;\n\t\t\tIPACMDBG_H(\" private filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_default_v4.name);\n\n\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask;\n\t\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr;\n\t\t\tmemcpy(&(m_pFilteringTable->rules[i]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\tIPACMDBG_H(\"Loop %d  5\\n\", i);\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error Adding RuleTable(0) to Filtering, aborting...\\n\");\n\t\t\tfree(m_pFilteringTable);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tflt_rule_count_v4 += IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\n\t\t/* copy filter rule hdls */\n\t\tfor (i = 0; i < IPACM_Iface::ipacmcfg->ipa_num_private_subnet; i++)\n\t\t{\n\t\t\tprivate_fl_rule_hdl[i] = m_pFilteringTable->rules[i].flt_rule_hdl;\n\t\t}\n\t\tfree(m_pFilteringTable);\n\t}\n\telse\n\t{\n\t\tIPACMDBG_H(\"No private subnet rules for ipv6 iface %s\\n\", dev_name);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\n\n/* for STA mode wan up:  configure filter rule for wan_up event*/\nint IPACM_Lan::handle_wan_up(ipa_ip_type ip_type)\n{\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tint len = 0;\n\tipa_ioc_add_flt_rule *m_pFilteringTable;\n\n\tIPACMDBG_H(\"set WAN interface as default filter rule\\n\");\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif(ip_type == IPA_IP_v4)\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + (1 * sizeof(struct ipa_flt_rule_add));\n\t\tm_pFilteringTable = (struct ipa_ioc_add_flt_rule *)calloc(1, len);\n\t\tif (m_pFilteringTable == NULL)\n\t\t{\n\t\t\tPERROR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tm_pFilteringTable->commit = 1;\n\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\tm_pFilteringTable->global = false;\n\t\tm_pFilteringTable->ip = IPA_IP_v4;\n\t\tm_pFilteringTable->num_rules = (uint8_t)1;\n\n\t\tIPACMDBG_H(\"Retrieving routing hanle for table: %s\\n\",\n\t\t\t\t\t\t IPACM_Iface::ipacmcfg->rt_tbl_wan_v4.name);\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_wan_v4))\n\t\t{\n\t\t\tIPACMERR(\"m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_wan_v4=0x%p) Failed.\\n\",\n\t\t\t\t\t\t\t &IPACM_Iface::ipacmcfg->rt_tbl_wan_v4);\n\t\t\tfree(m_pFilteringTable);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tIPACMDBG_H(\"Routing hanle for table: %d\\n\", IPACM_Iface::ipacmcfg->rt_tbl_wan_v4.hdl);\n\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add)); // Zero All Fields\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_SRC_NAT; //IPA_PASS_TO_ROUTING\n\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_wan_v4.hdl;\n\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0x0;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0x0;\n\n\t\tmemcpy(&m_pFilteringTable->rules[0], &flt_rule_entry, sizeof(flt_rule_entry));\n\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error Adding RuleTable(0) to Filtering, aborting...\\n\");\n\t\t\tfree(m_pFilteringTable);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\",\n\t\t\t\t\t\t\t m_pFilteringTable->rules[0].flt_rule_hdl,\n\t\t\t\t\t\t\t m_pFilteringTable->rules[0].status);\n\t\t}\n\n\n\t\t/* copy filter hdls  */\n\t\tlan_wan_fl_rule_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\tfree(m_pFilteringTable);\n\t}\n\telse if(ip_type == IPA_IP_v6)\n\t{\n\t\t/* add default v6 filter rule */\n\t\tm_pFilteringTable = (struct ipa_ioc_add_flt_rule *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_add_flt_rule) +\n\t\t\t\t\t1 * sizeof(struct ipa_flt_rule_add));\n\n\t\tif (!m_pFilteringTable)\n\t\t{\n\t\t\tPERROR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tm_pFilteringTable->commit = 1;\n\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\tm_pFilteringTable->global = false;\n\t\tm_pFilteringTable->ip = IPA_IP_v6;\n\t\tm_pFilteringTable->num_rules = (uint8_t)1;\n\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_v6))\n\t\t{\n\t\t\tIPACMERR(\"m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_v6=0x%p) Failed.\\n\", &IPACM_Iface::ipacmcfg->rt_tbl_v6);\n\t\t\tfree(m_pFilteringTable);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_v6.hdl;\n\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0X00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\n\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tfree(m_pFilteringTable);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t}\n\n\t\t/* copy filter hdls */\n\t\tdft_v6fl_rule_hdl[IPV6_DEFAULT_FILTERTING_RULES] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\tfree(m_pFilteringTable);\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::handle_wan_up_ex(ipacm_ext_prop* ext_prop, ipa_ip_type iptype)\n{\n\tint fd, ret = IPACM_SUCCESS, cnt;\n\tIPACM_Config* ipacm_config = IPACM_Iface::ipacmcfg;\n\tstruct ipa_ioc_write_qmapid mux;\n\n\tif(rx_prop != NULL)\n\t{\n\t\t/* give mud ID to IPA-driver for WLAN/LAN pkts */\n\t\tfd = open(IPA_DEVICE_NAME, O_RDWR);\n\t\tif (0 == fd)\n\t\t{\n\t\t\tIPACMDBG_H(\"Failed opening %s.\\n\", IPA_DEVICE_NAME);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tmux.qmap_id = ipacm_config->GetQmapId();\n\t\tfor(cnt=0; cnt<rx_prop->num_rx_props; cnt++)\n\t\t{\n\t\t\tmux.client = rx_prop->rx[cnt].src_pipe;\n\t\t\tret = ioctl(fd, IPA_IOC_WRITE_QMAPID, &mux);\n\t\t\tif (ret)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to write mux id %d\\n\", mux.qmap_id);\n\t\t\t\tclose(fd);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\tclose(fd);\n\t}\n\n\t/* check only add static UL filter rule once */\n\tif (num_dft_rt_v6 ==1 && iptype ==IPA_IP_v6 && modem_ul_v6_set == false)\n\t{\n\t\tIPACMDBG_H(\"IPA_IP_v6 num_dft_rt_v6 %d modem_ul_v6_set: %d\\n\", num_dft_rt_v6, modem_ul_v6_set);\n\t\tret = handle_uplink_filter_rule(ext_prop, iptype);\n\t\tmodem_ul_v6_set = true;\n\t} else if (iptype ==IPA_IP_v4 && modem_ul_v4_set == false) {\n\t\tIPACMDBG_H(\"IPA_IP_v4 modem_ul_v4_set %d\\n\", modem_ul_v4_set);\n\t\tret = handle_uplink_filter_rule(ext_prop, iptype);\n\t\tmodem_ul_v4_set = true;\n\t} else {\n\t\tIPACMDBG_H(\"ip-type: %d modem_ul_v4_set: %d, modem_ul_v6_set %d\\n\", iptype, modem_ul_v4_set, modem_ul_v6_set);\n\t}\n\treturn ret;\n}\n\n/* handle ETH client initial, construct full headers (tx property) */\nint IPACM_Lan::handle_eth_hdr_init(uint8_t *mac_addr)\n{\n\n#define ETH_IFACE_INDEX_LEN 2\n\n\tint res = IPACM_SUCCESS, len = 0;\n\tchar index[ETH_IFACE_INDEX_LEN];\n\tstruct ipa_ioc_copy_hdr sCopyHeader;\n\tstruct ipa_ioc_add_hdr *pHeaderDescriptor = NULL;\n    uint32_t cnt;\n\tint clnt_indx;\n\n\tclnt_indx = get_eth_client_index(mac_addr);\n\n\tif (clnt_indx != IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMERR(\"eth client is found/attached already with index %d \\n\", clnt_indx);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* add header to IPA */\n\tif (num_eth_client >= IPA_MAX_NUM_ETH_CLIENTS)\n\t{\n\t\tIPACMERR(\"Reached maximum number(%d) of eth clients\\n\", IPA_MAX_NUM_ETH_CLIENTS);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"ETH client number: %d\\n\", num_eth_client);\n\n\tmemcpy(get_client_memptr(eth_client, num_eth_client)->mac,\n\t\t\t\t mac_addr,\n\t\t\t\t sizeof(get_client_memptr(eth_client, num_eth_client)->mac));\n\n\n\tIPACMDBG_H(\"Received Client MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\tIPACMDBG_H(\"stored MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t get_client_memptr(eth_client, num_eth_client)->mac[0],\n\t\t\t\t\t get_client_memptr(eth_client, num_eth_client)->mac[1],\n\t\t\t\t\t get_client_memptr(eth_client, num_eth_client)->mac[2],\n\t\t\t\t\t get_client_memptr(eth_client, num_eth_client)->mac[3],\n\t\t\t\t\t get_client_memptr(eth_client, num_eth_client)->mac[4],\n\t\t\t\t\t get_client_memptr(eth_client, num_eth_client)->mac[5]);\n\n\t/* add header to IPA */\n\tif(tx_prop != NULL)\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_hdr) + (1 * sizeof(struct ipa_hdr_add));\n\t\tpHeaderDescriptor = (struct ipa_ioc_add_hdr *)calloc(1, len);\n\t\tif (pHeaderDescriptor == NULL)\n\t\t{\n\t\t\tIPACMERR(\"calloc failed to allocate pHeaderDescriptor\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\t/* copy partial header for v4*/\n\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\t\t if(tx_prop->tx[cnt].ip==IPA_IP_v4)\n\t\t\t\t {\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"Got partial v4-header name from %d tx props\\n\", cnt);\n\t\t\t\t\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\t\t\t\t\tmemcpy(sCopyHeader.name,\n\t\t\t\t\t\t\t\t\t\t\t tx_prop->tx[cnt].hdr_name,\n\t\t\t\t\t\t\t\t\t\t\t sizeof(sCopyHeader.name));\n\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"header name: %s in tx:%d\\n\", sCopyHeader.name,cnt);\n\t\t\t\t\t\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tPERROR(\"ioctl copy header failed\");\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"header eth2_ofst_valid: %d, eth2_ofst: %d\\n\", sCopyHeader.is_eth2_ofst_valid, sCopyHeader.eth2_ofst);\n\t\t\t\t\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\"header oversize\\n\");\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t\t\t\t\t\t\t\t sCopyHeader.hdr,\n\t\t\t\t\t\t\t\t\t\t\t\t sCopyHeader.hdr_len);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t/* copy client mac_addr to partial header */\n\t\t\t\t\t\t\t\tif (sCopyHeader.is_eth2_ofst_valid)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[sCopyHeader.eth2_ofst],\n\t\t\t\t\t\t\t\t\t\t\t mac_addr,\n\t\t\t\t\t\t\t\t\t\t\t IPA_MAC_ADDR_SIZE);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tpHeaderDescriptor->commit = true;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->num_hdrs = 1;\n\n\t\t\t\t\t\t\t\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t\t\t\t\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\t\t\t\t\tsnprintf(index,sizeof(index), \"%d\", ipa_if_num);\n\t\t\t\t\t\t\t\tstrlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\t\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, IPA_ETH_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tsnprintf(index,sizeof(index), \"%d\", header_name_count);\n\t\t\t\t\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status = -1;\n\n\t\t\t\t\t if (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t\t\t\t\t {\n\t\t\t\t\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t }\n\n\t\t\t\t\tget_client_memptr(eth_client, num_eth_client)->hdr_hdl_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\t\t\t\tIPACMDBG_H(\"eth-client(%d) v4 full header name:%s header handle:(0x%x)\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\t num_eth_client,\n\t\t\t\t\t\t\t\t\t\t\t\t pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t\t\t\t\t\t\t\t get_client_memptr(eth_client, num_eth_client)->hdr_hdl_v4);\n\t\t\t\t\t\t\t\t\tget_client_memptr(eth_client, num_eth_client)->ipv4_header_set=true;\n\n\t\t\t\t\tbreak;\n\t\t\t\t }\n\t\t}\n\n\n\t\t/* copy partial header for v6*/\n\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\tif(tx_prop->tx[cnt].ip==IPA_IP_v6)\n\t\t\t{\n\n\t\t\t\tIPACMDBG_H(\"Got partial v6-header name from %d tx props\\n\", cnt);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name,\n\t\t\t\t\t\ttx_prop->tx[cnt].hdr_name,\n\t\t\t\t\t\t\tsizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG_H(\"header name: %s in tx:%d\\n\", sCopyHeader.name,cnt);\n\t\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tPERROR(\"ioctl copy header failed\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tIPACMDBG_H(\"header eth2_ofst_valid: %d, eth2_ofst: %d\\n\", sCopyHeader.is_eth2_ofst_valid, sCopyHeader.eth2_ofst);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t\t\tsCopyHeader.hdr,\n\t\t\t\t\t\t\t\tsCopyHeader.hdr_len);\n\t\t\t\t}\n\n\t\t\t\t/* copy client mac_addr to partial header */\n\t\t\t\tif (sCopyHeader.is_eth2_ofst_valid)\n\t\t\t\t{\n\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[sCopyHeader.eth2_ofst],\n\t\t\t\t\t\tmac_addr,\n\t\t\t\t\t\tIPA_MAC_ADDR_SIZE);\n\t\t\t\t}\n\t\t\t\tpHeaderDescriptor->commit = true;\n\t\t\t\tpHeaderDescriptor->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", ipa_if_num);\n\t\t\t\tstrlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, IPA_ETH_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", header_name_count);\n\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\t\t\t\tpHeaderDescriptor->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tget_client_memptr(eth_client, num_eth_client)->hdr_hdl_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\t\t\tIPACMDBG_H(\"eth-client(%d) v6 full header name:%s header handle:(0x%x)\\n\",\n\t\t\t\t\t\t num_eth_client,\n\t\t\t\t\t\t pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t\t\t\t\t get_client_memptr(eth_client, num_eth_client)->hdr_hdl_v6);\n\n\t\t\t\t\t\t\t\t\tget_client_memptr(eth_client, num_eth_client)->ipv6_header_set=true;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\t\t}\n\t\t/* initialize wifi client*/\n\t\tget_client_memptr(eth_client, num_eth_client)->route_rule_set_v4 = false;\n\t\tget_client_memptr(eth_client, num_eth_client)->route_rule_set_v6 = 0;\n\t\tget_client_memptr(eth_client, num_eth_client)->ipv4_set = false;\n\t\tget_client_memptr(eth_client, num_eth_client)->ipv6_set = 0;\n\t\tnum_eth_client++;\n\t\theader_name_count++; //keep increasing header_name_count\n\t\tres = IPACM_SUCCESS;\n\t\tIPACMDBG_H(\"eth client number: %d\\n\", num_eth_client);\n\t}\n\telse\n\t{\n\t\treturn res;\n\t}\nfail:\n\tfree(pHeaderDescriptor);\n\n\treturn res;\n}\n\n/*handle eth client */\nint IPACM_Lan::handle_eth_client_ipaddr(ipacm_event_data_all *data)\n{\n\tint clnt_indx;\n\tint v6_num;\n\n\tIPACMDBG_H(\"number of eth clients: %d\\n\", num_eth_client);\n\tIPACMDBG_H(\" event MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t data->mac_addr[0],\n\t\t\t\t\t data->mac_addr[1],\n\t\t\t\t\t data->mac_addr[2],\n\t\t\t\t\t data->mac_addr[3],\n\t\t\t\t\t data->mac_addr[4],\n\t\t\t\t\t data->mac_addr[5]);\n\n\tclnt_indx = get_eth_client_index(data->mac_addr);\n\n\t\tif (clnt_indx == IPACM_INVALID_INDEX)\n\t\t{\n\t\t\tIPACMERR(\"eth client not found/attached \\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\tIPACMDBG_H(\"Ip-type received %d\\n\", data->iptype);\n\tif (data->iptype == IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"ipv4 address: 0x%x\\n\", data->ipv4_addr);\n\t\tif (data->ipv4_addr != 0) /* not 0.0.0.0 */\n\t\t{\n\t\t\tif (get_client_memptr(eth_client, clnt_indx)->ipv4_set == false)\n\t\t\t{\n\t\t\t\tget_client_memptr(eth_client, clnt_indx)->v4_addr = data->ipv4_addr;\n\t\t\t\tget_client_memptr(eth_client, clnt_indx)->ipv4_set = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t   /* check if client got new IPv4 address*/\n\t\t\t   if(data->ipv4_addr == get_client_memptr(eth_client, clnt_indx)->v4_addr)\n\t\t\t   {\n\t\t\t     IPACMDBG_H(\"Already setup ipv4 addr for client:%d, ipv4 address didn't change\\n\", clnt_indx);\n\t\t\t\t return IPACM_FAILURE;\n\t\t\t   }\n\t\t\t   else\n\t\t\t   {\n\t\t\t\t\tIPACMDBG_H(\"ipv4 addr for client:%d is changed \\n\", clnt_indx);\n\t\t\t\t\t/* delete NAT rules first */\n\t\t\t\t\tCtList->HandleNeighIpAddrDelEvt(get_client_memptr(eth_client, clnt_indx)->v4_addr);\n\t\t\t\t\tdelete_eth_rtrules(clnt_indx,IPA_IP_v4);\n\t\t\t\t\tget_client_memptr(eth_client, clnt_indx)->route_rule_set_v4 = false;\n\t\t\t\t\tget_client_memptr(eth_client, clnt_indx)->v4_addr = data->ipv4_addr;\n\t\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\t    IPACMDBG_H(\"Invalid client IPv4 address \\n\");\n\t\t    return IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif ((data->ipv6_addr[0] != 0) || (data->ipv6_addr[1] != 0) ||\n\t\t\t\t(data->ipv6_addr[2] != 0) || (data->ipv6_addr[3] || 0)) /* check if all 0 not valid ipv6 address */\n\t\t{\n\t\t   IPACMDBG_H(\"ipv6 address: 0x%x:%x:%x:%x\\n\", data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n                   if(get_client_memptr(eth_client, clnt_indx)->ipv6_set < IPV6_NUM_ADDR)\n\t\t   {\n\n\t\t       for(v6_num=0;v6_num < get_client_memptr(eth_client, clnt_indx)->ipv6_set;v6_num++)\n\t               {\n\t\t\t      if( data->ipv6_addr[0] == get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][0] &&\n\t\t\t           data->ipv6_addr[1] == get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][1] &&\n\t\t\t  \t        data->ipv6_addr[2]== get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][2] &&\n\t\t\t  \t         data->ipv6_addr[3] == get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][3])\n\t\t\t      {\n\t\t\t  \t    IPACMDBG_H(\"Already see this ipv6 addr for client:%d\\n\", clnt_indx);\n\t\t\t  \t    return IPACM_FAILURE; /* not setup the RT rules*/\n\t\t\t  \t\tbreak;\n\t\t\t      }\n\t\t       }\n\n\t\t       /* not see this ipv6 before for wifi client*/\n\t\t\t   get_client_memptr(eth_client, clnt_indx)->v6_addr[get_client_memptr(eth_client, clnt_indx)->ipv6_set][0] = data->ipv6_addr[0];\n\t\t\t   get_client_memptr(eth_client, clnt_indx)->v6_addr[get_client_memptr(eth_client, clnt_indx)->ipv6_set][1] = data->ipv6_addr[1];\n\t\t\t   get_client_memptr(eth_client, clnt_indx)->v6_addr[get_client_memptr(eth_client, clnt_indx)->ipv6_set][2] = data->ipv6_addr[2];\n\t\t\t   get_client_memptr(eth_client, clnt_indx)->v6_addr[get_client_memptr(eth_client, clnt_indx)->ipv6_set][3] = data->ipv6_addr[3];\n\t\t\t   get_client_memptr(eth_client, clnt_indx)->ipv6_set++;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t         IPACMDBG_H(\"Already got 3 ipv6 addr for client:%d\\n\", clnt_indx);\n\t\t\t return IPACM_FAILURE; /* not setup the RT rules*/\n\t\t    }\n\t\t}\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*handle eth client routing rule*/\nint IPACM_Lan::handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype)\n{\n\tstruct ipa_ioc_add_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_add *rt_rule_entry;\n\tuint32_t tx_index;\n\tint eth_index,v6_num;\n\tconst int NUM = 1;\n\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tIPACMDBG_H(\"Received mac_addr MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\teth_index = get_eth_client_index(mac_addr);\n\tif (eth_index == IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMDBG_H(\"eth client not found/attached \\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif (iptype==IPA_IP_v4) {\n\t\tIPACMDBG_H(\"eth client index: %d, ip-type: %d, ipv4_set:%d, ipv4_rule_set:%d \\n\", eth_index, iptype,\n\t\t\t\t\t get_client_memptr(eth_client, eth_index)->ipv4_set,\n\t\t\t\t\t get_client_memptr(eth_client, eth_index)->route_rule_set_v4);\n\t} else {\n\t\tIPACMDBG_H(\"eth client index: %d, ip-type: %d, ipv6_set:%d, ipv6_rule_num:%d \\n\", eth_index, iptype,\n\t\t\t\t\t get_client_memptr(eth_client, eth_index)->ipv6_set,\n\t\t\t\t\t get_client_memptr(eth_client, eth_index)->route_rule_set_v6);\n\t}\n\n\t/* Add default routing rules if not set yet */\n\tif ((iptype == IPA_IP_v4\n\t\t\t && get_client_memptr(eth_client, eth_index)->route_rule_set_v4 == false\n\t\t\t && get_client_memptr(eth_client, eth_index)->ipv4_set == true)\n\t\t\t|| (iptype == IPA_IP_v6\n\t\t            && get_client_memptr(eth_client, eth_index)->route_rule_set_v6 < get_client_memptr(eth_client, eth_index)->ipv6_set\n\t\t\t\t\t))\n\t{\n\n        /* Add corresponding ipa_rm_resource_name of TX-endpoint up before IPV6 RT-rule set */\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tif (tx_prop != NULL)\n\t\t{\n\t\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\t\tIPACM_Iface::ipacmcfg->AddRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe],false);\n\t\t}\n\t\trt_rule = (struct ipa_ioc_add_rt_rule *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t\t\t\t\t\tNUM * sizeof(struct ipa_rt_rule_add));\n\n\t\tif (rt_rule == NULL)\n\t\t{\n\t\t\tPERROR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\trt_rule->commit = 1;\n\t\trt_rule->num_rules = (uint8_t)NUM;\n\t\trt_rule->ip = iptype;\n\n\t\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t\tif(iptype != tx_prop->tx[tx_index].ip)\n\t\t    {\n\t\t\t\tIPACMDBG_H(\"Tx:%d, ip-type: %d conflict ip-type: %d no RT-rule added\\n\",\n\t\t\t\t\t\ttx_index, tx_prop->tx[tx_index].ip,iptype);\n\t\t   \t        continue;\n\t\t    }\n\n  \t   \t    rt_rule_entry = &rt_rule->rules[0];\n\t\t\trt_rule_entry->at_rear = 0;\n\n\t\t\tif (iptype == IPA_IP_v4)\n\t\t\t{\n\t\t        IPACMDBG_H(\"client index(%d):ipv4 address: 0x%x\\n\", eth_index,\n\t\t  \t\t        get_client_memptr(eth_client, eth_index)->v4_addr);\n\n                IPACMDBG_H(\"client(%d): v4 header handle:(0x%x)\\n\",\n\t\t  \t\t\t\t eth_index,\n\t\t  \t\t\t\t get_client_memptr(eth_client, eth_index)->hdr_hdl_v4);\n\t\t\t\tstrncpy(rt_rule->rt_tbl_name,\n\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name,\n\t\t\t\t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n\n\t\t\t    rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\t    memcpy(&rt_rule_entry->rule.attrib,\n\t\t\t\t\t\t &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\t\t sizeof(rt_rule_entry->rule.attrib));\n\t\t\t    rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t    rt_rule_entry->rule.hdr_hdl = get_client_memptr(eth_client, eth_index)->hdr_hdl_v4;\n\t\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr = get_client_memptr(eth_client, eth_index)->v4_addr;\n\t\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\n\t\t\t\t/* Replace the v4 header in ODU interface */\n\t\t\t\tif (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)\n\t\t\t\trt_rule_entry->rule.hdr_hdl = ODU_hdr_hdl_v4;\n\n\t\t\t    if (false == m_routing.AddRoutingRule(rt_rule))\n  \t            {\n  \t          \t            IPACMERR(\"Routing rule addition failed!\\n\");\n  \t          \t            free(rt_rule);\n  \t          \t            return IPACM_FAILURE;\n\t\t\t    }\n\n\t\t\t    /* copy ipv4 RT hdl */\n\t\t        get_client_memptr(eth_client, eth_index)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v4 =\n  \t   \t        rt_rule->rules[0].rt_rule_hdl;\n\t\t        IPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t      \tget_client_memptr(eth_client, eth_index)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v4, iptype);\n\n  \t   \t    } else {\n\n\t\t        for(v6_num = get_client_memptr(eth_client, eth_index)->route_rule_set_v6;v6_num < get_client_memptr(eth_client, eth_index)->ipv6_set;v6_num++)\n\t\t\t    {\n                    IPACMDBG_H(\"client(%d): v6 header handle:(0x%x)\\n\",\n\t\t  \t    \t\t\t eth_index,\n\t\t  \t    \t\t\t get_client_memptr(eth_client, eth_index)->hdr_hdl_v6);\n\n\t\t            /* v6 LAN_RT_TBL */\n\t\t\t    \tstrncpy(rt_rule->rt_tbl_name,\n\t\t\t    \t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_v6.name,\n\t\t\t    \t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n\t\t\t\t   /* Replace v6 header in ODU interface */\n\t\t\t\t   if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)\n\t\t\t\t\t\trt_rule_entry->rule.hdr_hdl = ODU_hdr_hdl_v6;\n\n\t\t            /* Support QCMAP LAN traffic feature, send to A5 */\n\t\t\t\t\trt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;\n\t\t\t        memset(&rt_rule_entry->rule.attrib, 0, sizeof(rt_rule_entry->rule.attrib));\n\t\t   \t        rt_rule_entry->rule.hdr_hdl = 0;\n\t\t\t        rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = get_client_memptr(eth_client, eth_index)->v6_addr[v6_num][0];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = get_client_memptr(eth_client, eth_index)->v6_addr[v6_num][1];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = get_client_memptr(eth_client, eth_index)->v6_addr[v6_num][2];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = get_client_memptr(eth_client, eth_index)->v6_addr[v6_num][3];\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\n   \t                if (false == m_routing.AddRoutingRule(rt_rule))\n  \t                {\n  \t                \t    IPACMERR(\"Routing rule addition failed!\\n\");\n  \t                \t    free(rt_rule);\n  \t                \t    return IPACM_FAILURE;\n\t\t\t        }\n\n\t\t            get_client_memptr(eth_client, eth_index)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6[v6_num] = rt_rule->rules[0].rt_rule_hdl;\n\t\t            IPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t            \t\t\t\t get_client_memptr(eth_client, eth_index)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6[v6_num], iptype);\n\n\t\t\t        /*Copy same rule to v6 WAN RT TBL*/\n  \t                strncpy(rt_rule->rt_tbl_name,\n  \t                 \t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name,\n  \t                 \t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n                    /* Downlink traffic from Wan iface, directly through IPA */\n\t\t\t\t\trt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\t        memcpy(&rt_rule_entry->rule.attrib,\n\t\t\t\t\t\t &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\t\t sizeof(rt_rule_entry->rule.attrib));\n\t\t   \t        rt_rule_entry->rule.hdr_hdl = get_client_memptr(eth_client, eth_index)->hdr_hdl_v6;\n\t\t\t        rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = get_client_memptr(eth_client, eth_index)->v6_addr[v6_num][0];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = get_client_memptr(eth_client, eth_index)->v6_addr[v6_num][1];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = get_client_memptr(eth_client, eth_index)->v6_addr[v6_num][2];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = get_client_memptr(eth_client, eth_index)->v6_addr[v6_num][3];\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\n\t\t            if (false == m_routing.AddRoutingRule(rt_rule))\n\t\t            {\n\t\t\t\t\t\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t\t\t\t\t\tfree(rt_rule);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t            }\n\n\t\t            get_client_memptr(eth_client, eth_index)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6_wan[v6_num] = rt_rule->rules[0].rt_rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t            \t\t\t\t get_client_memptr(eth_client, eth_index)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6_wan[v6_num], iptype);\n\t\t\t    }\n\t\t\t}\n\n  \t    } /* end of for loop */\n\n\t\tfree(rt_rule);\n\n\t\tif (iptype == IPA_IP_v4)\n\t\t{\n\t\t\tget_client_memptr(eth_client, eth_index)->route_rule_set_v4 = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tget_client_memptr(eth_client, eth_index)->route_rule_set_v6 = get_client_memptr(eth_client, eth_index)->ipv6_set;\n\t\t}\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* handle odu client initial, construct full headers (tx property) */\nint IPACM_Lan::handle_odu_hdr_init(uint8_t *mac_addr)\n{\n\tint res = IPACM_SUCCESS, len = 0;\n\tstruct ipa_ioc_copy_hdr sCopyHeader;\n\tstruct ipa_ioc_add_hdr *pHeaderDescriptor = NULL;\n    uint32_t cnt;\n\n\tIPACMDBG(\"Received Client MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\t/* add header to IPA */\n\tif(tx_prop != NULL)\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_hdr) + (1 * sizeof(struct ipa_hdr_add));\n\t\tpHeaderDescriptor = (struct ipa_ioc_add_hdr *)calloc(1, len);\n\t\tif (pHeaderDescriptor == NULL)\n\t\t{\n\t\t\tIPACMERR(\"calloc failed to allocate pHeaderDescriptor\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\t/* copy partial header for v4*/\n\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\t\t if(tx_prop->tx[cnt].ip==IPA_IP_v4)\n\t\t\t\t {\n\t\t\t\t\t\t\t\tIPACMDBG(\"Got partial v4-header name from %d tx props\\n\", cnt);\n\t\t\t\t\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\t\t\t\t\tmemcpy(sCopyHeader.name,\n\t\t\t\t\t\t\t\t\t\t\ttx_prop->tx[cnt].hdr_name,\n\t\t\t\t\t\t\t\t\t\t\t sizeof(sCopyHeader.name));\n\t\t\t\t\t\t\t\tIPACMDBG(\"header name: %s in tx:%d\\n\", sCopyHeader.name,cnt);\n\t\t\t\t\t\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tPERROR(\"ioctl copy header failed\");\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tIPACMDBG(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\t\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\"header oversize\\n\");\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t\t\t\t\t\t\t\t sCopyHeader.hdr,\n\t\t\t\t\t\t\t\t\t\t\t\t sCopyHeader.hdr_len);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/* copy client mac_addr to partial header */\n\t\t\t\t\t\t\t\tif (sCopyHeader.is_eth2_ofst_valid)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[sCopyHeader.eth2_ofst],\n\t\t\t\t\t\t\t\t\t\t\t mac_addr,\n\t\t\t\t\t\t\t\t\t\t\t IPA_MAC_ADDR_SIZE);\n\t\t\t\t\t\t\t\t}\n\n\n\t\t\t\t\t\t\t\tpHeaderDescriptor->commit = true;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->num_hdrs = 1;\n\n\t\t\t\t\t\t\t\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t\t\t\t\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\t\t\t\tstrcpy(pHeaderDescriptor->hdr[0].name, IPA_ODU_HDR_NAME_v4);\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status = -1;\n\n\t\t\t\t\t if (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t\t\t\t\t {\n\t\t\t\t\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t }\n\n\t\t\t\t\tODU_hdr_hdl_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\t\t\t\tipv4_header_set = true ;\n\t\t\t\t\tIPACMDBG(\" ODU v4 full header name:%s header handle:(0x%x)\\n\",\n\t\t\t\t\t\t\t\t\t\t pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t\t\t\t\t\t\t\t ODU_hdr_hdl_v4);\n\t\t\t\t\tbreak;\n\t\t\t\t }\n\t\t}\n\n\n\t\t/* copy partial header for v6*/\n\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\tif(tx_prop->tx[cnt].ip==IPA_IP_v6)\n\t\t\t{\n\n\t\t\t\tIPACMDBG(\"Got partial v6-header name from %d tx props\\n\", cnt);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name,\n\t\t\t\t\t\ttx_prop->tx[cnt].hdr_name,\n\t\t\t\t\t\t\tsizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG(\"header name: %s in tx:%d\\n\", sCopyHeader.name,cnt);\n\t\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tPERROR(\"ioctl copy header failed\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t\t\tsCopyHeader.hdr,\n\t\t\t\t\t\t\t\tsCopyHeader.hdr_len);\n\t\t\t\t}\n\n\t\t\t\t/* copy client mac_addr to partial header */\n\t\t\t\tif (sCopyHeader.is_eth2_ofst_valid)\n\t\t\t\t{\n\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[sCopyHeader.eth2_ofst],\n\t\t\t\t\t mac_addr,\n\t\t\t\t\t IPA_MAC_ADDR_SIZE);\n\t\t\t\t}\n\n\t\t\t\tpHeaderDescriptor->commit = true;\n\t\t\t\tpHeaderDescriptor->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\tstrcpy(pHeaderDescriptor->hdr[0].name, IPA_ODU_HDR_NAME_v6);\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\t\t\t\tpHeaderDescriptor->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tODU_hdr_hdl_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\t\t\tipv6_header_set = true ;\n\t\t\t\tIPACMDBG(\" ODU v4 full header name:%s header handle:(0x%x)\\n\",\n\t\t\t\t\t\t\t\t\t pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t\t\t\t\t\t\t ODU_hdr_hdl_v6);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\nfail:\n\tfree(pHeaderDescriptor);\n\n\treturn res;\n}\n\n\n/* handle odu default route rule configuration */\nint IPACM_Lan::handle_odu_route_add()\n{\n\t/* add default WAN route */\n\tstruct ipa_ioc_add_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_add *rt_rule_entry;\n\tuint32_t tx_index;\n\tconst int NUM = 1;\n\n\tif(tx_prop == NULL)\n\t{\n\t  IPACMDBG(\"No tx properties, ignore default route setting\\n\");\n\t  return IPACM_SUCCESS;\n\t}\n\n\trt_rule = (struct ipa_ioc_add_rt_rule *)\n\t\t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t\t\t\t\t\tNUM * sizeof(struct ipa_rt_rule_add));\n\n\tif (!rt_rule)\n\t{\n\t\tIPACMERR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\trt_rule->commit = 1;\n\trt_rule->num_rules = (uint8_t)NUM;\n\n\n\tIPACMDBG(\" WAN table created %s \\n\", rt_rule->rt_tbl_name);\n\trt_rule_entry = &rt_rule->rules[0];\n\trt_rule_entry->at_rear = true;\n\n\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t{\n\n\t    if (IPA_IP_v4 == tx_prop->tx[tx_index].ip)\n\t    {\n\t    \tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v4.name);\n\t\t\trt_rule_entry->rule.hdr_hdl = ODU_hdr_hdl_v4;\n\t\t\trt_rule->ip = IPA_IP_v4;\n\t    }\n\t    else\n\t    {\n\t    \tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v6.name);\n\t\t\trt_rule_entry->rule.hdr_hdl = ODU_hdr_hdl_v6;\n\t\t\trt_rule->ip = IPA_IP_v6;\n\t    }\n\n\t\trt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\tmemcpy(&rt_rule_entry->rule.attrib,\n\t\t\t\t\t &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\t sizeof(rt_rule_entry->rule.attrib));\n\n\t\trt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tif (IPA_IP_v4 == tx_prop->tx[tx_index].ip)\n\t\t{\n\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr      = 0;\n\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0;\n\n\t\t\tif (false == m_routing.AddRoutingRule(rt_rule))\n\t\t    {\n\t\t    \tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t    \tfree(rt_rule);\n\t\t    \treturn IPACM_FAILURE;\n\t\t    }\n\t\t\todu_route_rule_v4_hdl[tx_index] = rt_rule_entry->rt_rule_hdl;\n\t\t    IPACMDBG(\"Got ipv4 ODU-route rule hdl:0x%x,tx:%d,ip-type: %d \\n\",\n\t\t\t\t\t\t odu_route_rule_v4_hdl[tx_index],\n\t\t\t\t\t\t tx_index,\n\t\t\t\t\t\t IPA_IP_v4);\n\t\t}\n\t\telse\n\t\t{\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0;\n\n\t\t\tif (false == m_routing.AddRoutingRule(rt_rule))\n\t\t    {\n\t\t    \tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t    \tfree(rt_rule);\n\t\t    \treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\todu_route_rule_v6_hdl[tx_index] = rt_rule_entry->rt_rule_hdl;\n\t\t\tIPACMDBG(\"Set ipv6 ODU-route rule hdl for v6_lan_table:0x%x,tx:%d,ip-type: %d \\n\",\n\t\t                 odu_route_rule_v6_hdl[tx_index],\n\t\t                 tx_index,\n\t\t                 IPA_IP_v6);\n\t\t}\n\n\t}\n\tfree(rt_rule);\n\treturn IPACM_SUCCESS;\n}\n\n/* handle odu default route rule deletion */\nint IPACM_Lan::handle_odu_route_del()\n{\n\tuint32_t tx_index;\n\n\tif(tx_prop == NULL)\n\t{\n\t  IPACMDBG(\"No tx properties, ignore delete default route setting\\n\");\n\t  return IPACM_SUCCESS;\n\t}\n\n\t\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t\tif (tx_prop->tx[tx_index].ip == IPA_IP_v4)\n\t\t\t{\n\t\t    \tIPACMDBG(\"Tx:%d, ip-type: %d match ip-type: %d, RT-rule deleted\\n\",\n\t\t    \t\t\t\t\t    tx_index, tx_prop->tx[tx_index].ip,IPA_IP_v4);\n\n\t\t\t\tif (m_routing.DeleteRoutingHdl(odu_route_rule_v4_hdl[tx_index], IPA_IP_v4)\n\t\t\t\t\t\t== false)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\"IP-family:%d, Routing rule(hdl:0x%x) deletion failed with tx_index %d!\\n\", IPA_IP_v4, odu_route_rule_v4_hdl[tx_index], tx_index);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t    \tIPACMDBG(\"Tx:%d, ip-type: %d match ip-type: %d, RT-rule deleted\\n\",\n\t\t    \t\t\t\t\t    tx_index, tx_prop->tx[tx_index].ip,IPA_IP_v6);\n\n\t\t\t\tif (m_routing.DeleteRoutingHdl(odu_route_rule_v6_hdl[tx_index], IPA_IP_v6)\n\t\t\t\t\t\t== false)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\"IP-family:%d, Routing rule(hdl:0x%x) deletion failed with tx_index %d!\\n\", IPA_IP_v6, odu_route_rule_v6_hdl[tx_index], tx_index);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*handle eth client del mode*/\nint IPACM_Lan::handle_eth_client_down_evt(uint8_t *mac_addr)\n{\n\tint clt_indx;\n\tuint32_t tx_index;\n\tint num_eth_client_tmp = num_eth_client;\n\tint num_v6;\n\n\tIPACMDBG_H(\"total client: %d\\n\", num_eth_client_tmp);\n\n\tclt_indx = get_eth_client_index(mac_addr);\n\tif (clt_indx == IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMDBG_H(\"eth client not attached\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\t/* First reset nat rules and then route rules */\n\tif(get_client_memptr(eth_client, clt_indx)->ipv4_set == true)\n\t{\n\t\t\tIPACMDBG_H(\"Clean Nat Rules for ipv4:0x%x\\n\", get_client_memptr(eth_client, clt_indx)->v4_addr);\n\t\t\tCtList->HandleNeighIpAddrDelEvt(get_client_memptr(eth_client, clt_indx)->v4_addr);\n \t}\n\n\tif (delete_eth_rtrules(clt_indx, IPA_IP_v4))\n\t{\n\t\tIPACMERR(\"unbale to delete ecm-client v4 route rules for index: %d\\n\", clt_indx);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif (delete_eth_rtrules(clt_indx, IPA_IP_v6))\n\t{\n\t\tIPACMERR(\"unbale to delete ecm-client v6 route rules for index: %d\\n\", clt_indx);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* Delete eth client header */\n\tif(get_client_memptr(eth_client, clt_indx)->ipv4_header_set == true)\n\t{\n\t\tif (m_header.DeleteHeaderHdl(get_client_memptr(eth_client, clt_indx)->hdr_hdl_v4)\n\t\t\t\t== false)\n\t\t{\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tget_client_memptr(eth_client, clt_indx)->ipv4_header_set = false;\n\t}\n\n\tif(get_client_memptr(eth_client, clt_indx)->ipv6_header_set == true)\n\t{\n\t\tif (m_header.DeleteHeaderHdl(get_client_memptr(eth_client, clt_indx)->hdr_hdl_v6)\n\t\t\t\t== false)\n\t\t{\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tget_client_memptr(eth_client, clt_indx)->ipv6_header_set = false;\n\t}\n\n\t/* Reset ip_set to 0*/\n\tget_client_memptr(eth_client, clt_indx)->ipv4_set = false;\n\tget_client_memptr(eth_client, clt_indx)->ipv6_set = 0;\n\tget_client_memptr(eth_client, clt_indx)->ipv4_header_set = false;\n\tget_client_memptr(eth_client, clt_indx)->ipv6_header_set = false;\n\tget_client_memptr(eth_client, clt_indx)->route_rule_set_v4 = false;\n\tget_client_memptr(eth_client, clt_indx)->route_rule_set_v6 = 0;\n\n\tfor (; clt_indx < num_eth_client_tmp - 1; clt_indx++)\n\t{\n\t\tmemcpy(get_client_memptr(eth_client, clt_indx)->mac,\n\t\t\t\t\t get_client_memptr(eth_client, (clt_indx + 1))->mac,\n\t\t\t\t\t sizeof(get_client_memptr(eth_client, clt_indx)->mac));\n\n\t\tget_client_memptr(eth_client, clt_indx)->hdr_hdl_v4 = get_client_memptr(eth_client, (clt_indx + 1))->hdr_hdl_v4;\n\t\tget_client_memptr(eth_client, clt_indx)->hdr_hdl_v6 = get_client_memptr(eth_client, (clt_indx + 1))->hdr_hdl_v6;\n\t\tget_client_memptr(eth_client, clt_indx)->v4_addr = get_client_memptr(eth_client, (clt_indx + 1))->v4_addr;\n\n\t\tget_client_memptr(eth_client, clt_indx)->ipv4_set = get_client_memptr(eth_client, (clt_indx + 1))->ipv4_set;\n\t\tget_client_memptr(eth_client, clt_indx)->ipv6_set = get_client_memptr(eth_client, (clt_indx + 1))->ipv6_set;\n\t\tget_client_memptr(eth_client, clt_indx)->ipv4_header_set = get_client_memptr(eth_client, (clt_indx + 1))->ipv4_header_set;\n\t\tget_client_memptr(eth_client, clt_indx)->ipv6_header_set = get_client_memptr(eth_client, (clt_indx + 1))->ipv6_header_set;\n\n\t\tget_client_memptr(eth_client, clt_indx)->route_rule_set_v4 = get_client_memptr(eth_client, (clt_indx + 1))->route_rule_set_v4;\n\t\tget_client_memptr(eth_client, clt_indx)->route_rule_set_v6 = get_client_memptr(eth_client, (clt_indx + 1))->route_rule_set_v6;\n\n        for (num_v6=0;num_v6< get_client_memptr(eth_client, clt_indx)->ipv6_set;num_v6++)\n\t    {\n\t\t    get_client_memptr(eth_client, clt_indx)->v6_addr[num_v6][0] = get_client_memptr(eth_client, (clt_indx + 1))->v6_addr[num_v6][0];\n\t\t    get_client_memptr(eth_client, clt_indx)->v6_addr[num_v6][1] = get_client_memptr(eth_client, (clt_indx + 1))->v6_addr[num_v6][1];\n\t\t    get_client_memptr(eth_client, clt_indx)->v6_addr[num_v6][2] = get_client_memptr(eth_client, (clt_indx + 1))->v6_addr[num_v6][2];\n\t\t    get_client_memptr(eth_client, clt_indx)->v6_addr[num_v6][3] = get_client_memptr(eth_client, (clt_indx + 1))->v6_addr[num_v6][3];\n        }\n\n\t\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t\tget_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v4 =\n\t\t\t\t get_client_memptr(eth_client, (clt_indx + 1))->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v4;\n\n\t\t\tfor(num_v6=0;num_v6< get_client_memptr(eth_client, clt_indx)->route_rule_set_v6;num_v6++)\n\t\t\t{\n\t\t\t  get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6[num_v6] =\n\t\t\t   \t get_client_memptr(eth_client, (clt_indx + 1))->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6[num_v6];\n\t\t\t  get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6_wan[num_v6] =\n\t\t\t   \t get_client_memptr(eth_client, (clt_indx + 1))->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6_wan[num_v6];\n\t\t    }\n\t\t}\n\t}\n\n\tIPACMDBG_H(\" %d eth client deleted successfully \\n\", num_eth_client);\n\tnum_eth_client = num_eth_client - 1;\n\tIPACMDBG_H(\" Number of eth client: %d\\n\", num_eth_client);\n\n\t/* Del RM dependency */\n\tif(num_eth_client == 0)\n\t{\n\t\t/* Delete corresponding ipa_rm_resource_name of TX-endpoint after delete all IPV4V6 RT-rule*/\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tif (tx_prop != NULL)\n\t\t{\n\t\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\t\tIPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\t}\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*handle LAN iface down event*/\nint IPACM_Lan::handle_down_evt()\n{\n\tint i;\n\tint res = IPACM_SUCCESS;\n\tuint32_t temp_eth_bridge_flt_rule[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\n\n\tif (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)\n\t{\n\t\t/* delete ODU default RT rules */\n\t\thandle_odu_route_del();\n\n\t\t/* delete full header */\n\t\tif (ipv4_header_set)\n\t\t{\n\t\t\tif (m_header.DeleteHeaderHdl(ODU_hdr_hdl_v4)\n\t\t\t\t\t== false)\n\t\t\t{\n\t\t\t\t\tIPACMDBG(\"ODU ipv4 header delete fail\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tIPACMDBG(\"ODU ipv4 header delete success\\n\");\n\t\t}\n\n\t\tif (ipv6_header_set)\n\t\t{\n\t\t\tif (m_header.DeleteHeaderHdl(ODU_hdr_hdl_v6)\n\t\t\t\t\t== false)\n\t\t\t{\n\t\t\t\tIPACMDBG(\"ODU ipv6 header delete fail\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tIPACMDBG(\"ODU ipv6 header delete success\\n\");\n\t\t}\n\t}\n\n\t/* no iface address up, directly close iface*/\n\tif (ip_type == IPACM_IP_NULL)\n\t{\n\t\tgoto fail;\n\t}\n\tIPACMDBG_H(\"lan handle_down_evt\\n \");\n\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tIPACM_Lan::usb_hdr_type = IPA_HDR_L2_NONE;\n\tIPACM_Lan::usb_hdr_template_hdl = 0;\n\tdel_hdr_proc_ctx();\n#endif\n\n\t/* delete wan filter rule */\n\tif (IPACM_Wan::isWanUP(ipa_if_num) && rx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"LAN IF goes down, backhaul type %d\\n\", IPACM_Wan::backhaul_is_sta_mode);\n\t\thandle_wan_down(IPACM_Wan::backhaul_is_sta_mode);\n\t}\n\n\tif (IPACM_Wan::isWanUP_V6(ipa_if_num) && rx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"LAN IF goes down, backhaul type %d\\n\", IPACM_Wan::backhaul_is_sta_mode);\n\t\thandle_wan_down_v6(IPACM_Wan::backhaul_is_sta_mode);\n\t}\n\n\t/* delete default filter rules */\n\tif (ip_type != IPA_IP_v6 && rx_prop != NULL)\n\t{\n\t\tif (m_filtering.DeleteFilteringHdls(dft_v4fl_rule_hdl, IPA_IP_v4, IPV4_DEFAULT_FILTERTING_RULES) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting Filtering Rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t{\n\t\t\ttemp_eth_bridge_flt_rule[i] = wlan_client_flt_rule_hdl_v4[i].rule_hdl;\n\t\t}\n\t\tif (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, IPA_IP_v4, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting Filtering Rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#endif\n\t\tif(m_filtering.DeleteFilteringHdls(ipv6_icmp_flt_rule_hdl, IPA_IP_v6, NUM_IPV6_ICMP_FLT_RULE) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting ICMPv6 Filtering Rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#ifndef FEATURE_ETH_BRIDGE_LE\n#ifdef CT_OPT\n\t\tif (m_filtering.DeleteFilteringHdls(tcp_ctl_flt_rule_hdl_v4, IPA_IP_v4, NUM_TCP_CTL_FLT_RULE) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error deleting default filtering Rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#endif\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(m_filtering.DeleteFilteringHdls(&(lan2lan_flt_rule_hdl_v4[i].rule_hdl), IPA_IP_v4, 1) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error deleting lan2lan IPv4 flt rules.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tIPACMDBG_H(\"Deleted lan2lan IPv4 flt rules.\\n\");\n#endif\n\n\t\t/* free private-subnet ipv4 filter rules */\n\t\tif (IPACM_Iface::ipacmcfg->ipa_num_private_subnet > IPA_PRIV_SUBNET_FILTER_RULE_HANDLES)\n\t\t{\n\t\t\tIPACMERR(\" the number of rules are bigger than array, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n#ifdef FEATURE_IPA_ANDROID\n\t\tif(m_filtering.DeleteFilteringHdls(private_fl_rule_hdl, IPA_IP_v4, IPA_MAX_PRIVATE_SUBNET_ENTRIES) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error deleting private subnet IPv4 flt rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#else\n\t\tif (m_filtering.DeleteFilteringHdls(private_fl_rule_hdl, IPA_IP_v4, IPACM_Iface::ipacmcfg->ipa_num_private_subnet) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting RuleTable(1) to Filtering, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#endif\n\t}\n    IPACMDBG_H(\"Finished delete default iface ipv4 filtering rules \\n \");\n\n\tif (ip_type != IPA_IP_v4 && rx_prop != NULL)\n\t{\n\t\tif (m_filtering.DeleteFilteringHdls(dft_v6fl_rule_hdl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v6,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(IPV6_DEFAULT_FILTERTING_RULES + IPV6_DEFAULT_LAN_FILTERTING_RULES)) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding RuleTable(1) to Filtering, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t{\n\t\t\ttemp_eth_bridge_flt_rule[i] = wlan_client_flt_rule_hdl_v6[i].rule_hdl;\n\t\t}\n\t\tif (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, IPA_IP_v6, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting Filtering Rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#endif\n#ifndef FEATURE_ETH_BRIDGE_LE\n#ifdef CT_OPT\n\t\tif (m_filtering.DeleteFilteringHdls(tcp_ctl_flt_rule_hdl_v6, IPA_IP_v6, NUM_TCP_CTL_FLT_RULE) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error deleting default filtering Rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n#endif\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(m_filtering.DeleteFilteringHdls(&(lan2lan_flt_rule_hdl_v6[i].rule_hdl), IPA_IP_v6, 1) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error deleting lan2lan IPv4 flt rules.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tIPACMDBG_H(\"Deleted lan2lan IPv6 flt rules.\\n\");\n#endif\n\t}\n    IPACMDBG_H(\"Finished delete default iface ipv6 filtering rules \\n \");\n\n\tif (ip_type != IPA_IP_v6)\n\t{\n\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4)\n\t\t\t\t== false)\n\t\t{\n\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\tIPACMDBG_H(\"Finished delete default iface ipv4 rules \\n \");\n\n\t/* delete default v6 routing rule */\n\tif (ip_type != IPA_IP_v4)\n\t{\n\t\t/* may have multiple ipv6 iface-RT rules*/\n\t\tfor (i = 0; i < 2*num_dft_rt_v6; i++)\n\t\t{\n\t\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + i], IPA_IP_v6)\n\t\t\t\t\t== false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t}\n\n\tIPACMDBG_H(\"Finished delete default iface ipv6 rules \\n \");\n\t/* clean eth-client header, routing rules */\n\tIPACMDBG_H(\"left %d eth clients need to be deleted \\n \", num_eth_client);\n\tfor (i = 0; i < num_eth_client; i++)\n\t{\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t\teth_bridge_del_usb_client_rt_rule(get_client_memptr(eth_client, i)->mac);\n\t\t\teth_bridge_post_lan_client_event(get_client_memptr(eth_client, i)->mac, IPA_ETH_BRIDGE_USB_CLIENT_DEL_EVENT);\n\t\t\teth_bridge_del_usb_client(get_client_memptr(eth_client, i)->mac);\n#endif\n\n\t\t\t/* First reset nat rules and then route rules */\n\t\t\tif(get_client_memptr(eth_client, i)->ipv4_set == true)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Clean Nat Rules for ipv4:0x%x\\n\", get_client_memptr(eth_client, i)->v4_addr);\n\t\t\t\tCtList->HandleNeighIpAddrDelEvt(get_client_memptr(eth_client, i)->v4_addr);\n\t\t\t}\n\n\t\t\tif (delete_eth_rtrules(i, IPA_IP_v4))\n\t\t\t{\n\t\t\t\tIPACMERR(\"unbale to delete ecm-client v4 route rules for index %d\\n\", i);\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tif (delete_eth_rtrules(i, IPA_IP_v6))\n\t\t\t{\n\t\t\t\tIPACMERR(\"unbale to delete ecm-client v6 route rules for index %d\\n\", i);\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tIPACMDBG_H(\"Delete %d client header\\n\", num_eth_client);\n\n\n\t\t\tif(get_client_memptr(eth_client, i)->ipv4_header_set == true)\n\t\t\t{\n\t\t\t\tif (m_header.DeleteHeaderHdl(get_client_memptr(eth_client, i)->hdr_hdl_v4)\n\t\t\t\t\t== false)\n\t\t\t\t{\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(get_client_memptr(eth_client, i)->ipv6_header_set == true)\n\t\t\t{\n\t\t\tif (m_header.DeleteHeaderHdl(get_client_memptr(eth_client, i)->hdr_hdl_v6)\n\t\t\t\t\t== false)\n\t\t\t{\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\t}\n\t} /* end of for loop */\n\n\t/* free the edm clients cache */\n\tIPACMDBG_H(\"Free ecm clients cache\\n\");\n\n\t/* Delete corresponding ipa_rm_resource_name of TX-endpoint after delete all IPV4V6 RT-rule */\n\tIPACMDBG_H(\"dev %s delete producer dependency\\n\", dev_name);\n\tif (tx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\tIPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t}\n\t/* check software routing fl rule hdl */\n\tif (softwarerouting_act == true && rx_prop != NULL)\n\t{\n\t\thandle_software_routing_disable();\n\t}\n\n\t/* posting ip to lan2lan module to delete RT/FILTER rules*/\n\tpost_lan2lan_client_disconnect_msg(IPA_IP_v4);\n\tpost_lan2lan_client_disconnect_msg(IPA_IP_v6);\n\n/* Delete private subnet*/\n#ifdef FEATURE_IPA_ANDROID\n\tif (ip_type != IPA_IP_v6)\n\t{\n\t\tIPACMDBG_H(\"current IPACM private subnet_addr number(%d)\\n\", IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n\t\tIPACMDBG_H(\" Delete IPACM private subnet_addr as: 0x%x \\n\", if_ipv4_subnet);\n\t\tif(IPACM_Iface::ipacmcfg->DelPrivateSubnet(if_ipv4_subnet, ipa_if_num) == false)\n\t\t{\n\t\t\tIPACMERR(\" can't Delete IPACM private subnet_addr as: 0x%x \\n\", if_ipv4_subnet);\n\t\t}\n\t}\n\n\t/* reset the IPA-client pipe enum */\n\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat != WAN_IF)\n\t{\n\t\thandle_tethering_client(true, IPACM_CLIENT_USB);\n\t}\n#endif /* defined(FEATURE_IPA_ANDROID)*/\nfail:\n\tif (odu_route_rule_v4_hdl != NULL)\n\t{\n\t\tfree(odu_route_rule_v4_hdl);\n\t}\n\tif (odu_route_rule_v6_hdl != NULL)\n\t{\n\t\tfree(odu_route_rule_v6_hdl);\n\t}\n\t/* Delete corresponding ipa_rm_resource_name of RX-endpoint after delete all IPV4V6 FT-rule */\n\tif (rx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", rx_prop->rx[0].src_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);\n\t\tIPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);\n\t\tIPACMDBG_H(\"Finished delete dependency \\n \");\n\t\tfree(rx_prop);\n\t}\n\n\tif (eth_client != NULL)\n\t{\n\t\tfree(eth_client);\n\t}\n\n\tif (tx_prop != NULL)\n\t{\n\t\tfree(tx_prop);\n\t}\n\tif (iface_query != NULL)\n\t{\n\t\tfree(iface_query);\n\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tif(eth_bridge_usb_client_rt_info_v4 != NULL)\n\t{\n\t\tfree(eth_bridge_usb_client_rt_info_v4);\n\t}\n\tif(eth_bridge_usb_client_rt_info_v6 != NULL)\n\t{\n\t\tfree(eth_bridge_usb_client_rt_info_v6);\n\t}\n#endif\n\tis_active = false;\n\tpost_del_self_evt();\n\n\treturn res;\n}\n\n/* install UL filter rule from Q6 */\nint IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype)\n{\n\tipa_flt_rule_add flt_rule_entry;\n\tint len = 0, cnt, ret = IPACM_SUCCESS;\n\tipa_ioc_add_flt_rule *pFilteringTable;\n\tipa_fltr_installed_notif_req_msg_v01 flt_index;\n\tint fd;\n\tint i;\n\n\tIPACMDBG_H(\"Set extended property rules in LAN\\n\");\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif(prop == NULL || prop->num_ext_props <= 0)\n\t{\n\t\tIPACMDBG_H(\"No extended property.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tfd = open(IPA_DEVICE_NAME, O_RDWR);\n\tif (0 == fd)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", IPA_DEVICE_NAME);\n\t}\n\n\tmemset(&flt_index, 0, sizeof(flt_index));\n\tflt_index.source_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, rx_prop->rx[0].src_pipe);\n\tflt_index.install_status = IPA_QMI_RESULT_SUCCESS_V01;\n\tflt_index.filter_index_list_len = prop->num_ext_props;\n\tflt_index.embedded_pipe_index_valid = 1;\n\tflt_index.embedded_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, IPA_CLIENT_APPS_LAN_WAN_PROD);\n\tflt_index.retain_header_valid = 1;\n\tflt_index.retain_header = 0;\n\tflt_index.embedded_call_mux_id_valid = 1;\n\tflt_index.embedded_call_mux_id = IPACM_Iface::ipacmcfg->GetQmapId();\n\n\tIPACMDBG_H(\"flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d\\n\", flt_index.source_pipe_index,\n\t\t\t\tflt_index.filter_index_list_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id);\n\n\tlen = sizeof(struct ipa_ioc_add_flt_rule) + prop->num_ext_props * sizeof(struct ipa_flt_rule_add);\n\tpFilteringTable = (struct ipa_ioc_add_flt_rule*)malloc(len);\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\tclose(fd);\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\tpFilteringTable->global = false;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = prop->num_ext_props;\n\n\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add)); // Zero All Fields\n\tflt_rule_entry.at_rear = 1;\n\tflt_rule_entry.flt_rule_hdl = -1;\n\tflt_rule_entry.status = -1;\n\n\tflt_rule_entry.rule.retain_hdr = 0;\n\tflt_rule_entry.rule.to_uc = 0;\n\tflt_rule_entry.rule.eq_attrib_type = 1;\n\tif(iptype == IPA_IP_v4)\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_SRC_NAT;\n\telse if(iptype == IPA_IP_v6)\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tfor(cnt=0; cnt<prop->num_ext_props; cnt++)\n\t{\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &prop->prop[cnt].eq_attrib,\n\t\t\t\t\t sizeof(prop->prop[cnt].eq_attrib));\n\t\tflt_rule_entry.rule.rt_tbl_idx = prop->prop[cnt].rt_tbl_idx;\n\t\tmemcpy(&pFilteringTable->rules[cnt], &flt_rule_entry, sizeof(flt_rule_entry));\n\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tIPACMDBG_H(\"Filtering rule %d has index %d\\n\", cnt, flt_rule_count_v4);\n\t\t\tflt_index.filter_index_list[cnt].filter_index = flt_rule_count_v4;\n\t\t\tflt_rule_count_v4++;\n\t\t}\n\t\tif(iptype == IPA_IP_v6)\n\t\t{\n\t\t\tIPACMDBG_H(\"Filtering rule %d has index %d\\n\", cnt, flt_rule_count_v6);\n\t\t\tflt_index.filter_index_list[cnt].filter_index = flt_rule_count_v6;\n\t\t\tflt_rule_count_v6++;\n\t\t}\n\t\tflt_index.filter_index_list[cnt].filter_handle = prop->prop[cnt].filter_hdl;\n\t}\n\n\tif(false == m_filtering.SendFilteringRuleIndex(&flt_index))\n\t{\n\t\tIPACMERR(\"Error sending filtering rule index, aborting...\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tif(false == m_filtering.AddFilteringRule(pFilteringTable))\n\t{\n\t\tIPACMERR(\"Error Adding RuleTable to Filtering, aborting...\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\telse\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tfor(i=0; i<pFilteringTable->num_rules; i++)\n\t\t\t{\n\t\t\t\twan_ul_fl_rule_hdl_v4[num_wan_ul_fl_rule_v4] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\tnum_wan_ul_fl_rule_v4++;\n\t\t\t}\n\t\t}\n\t\telse if(iptype == IPA_IP_v6)\n\t\t{\n\t\t\tfor(i=0; i<pFilteringTable->num_rules; i++)\n\t\t\t{\n\t\t\t\twan_ul_fl_rule_hdl_v6[num_wan_ul_fl_rule_v6] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\tnum_wan_ul_fl_rule_v6++;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\tclose(fd);\n\treturn ret;\n}\n\nint IPACM_Lan::handle_wan_down_v6(bool is_sta_mode)\n{\n\tipa_fltr_installed_notif_req_msg_v01 flt_index;\n\tint fd;\n\n\tfd = open(IPA_DEVICE_NAME, O_RDWR);\n\tif (0 == fd)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", IPA_DEVICE_NAME);\n\t\treturn IPACM_FAILURE;\n\t}\n\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tflt_rule_count_v6 = IPV6_DEFAULT_FILTERTING_RULES + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + NUM_IPV6_ICMP_FLT_RULE;\n#else\n#ifdef CT_OPT\n\tflt_rule_count_v6 = IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + NUM_IPV6_ICMP_FLT_RULE;\n#else\n\tflt_rule_count_v6 = IPV6_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + NUM_IPV6_ICMP_FLT_RULE;\n#endif\n#endif\n\n\tif(m_filtering.DeleteFilteringHdls(ipv6_prefix_flt_rule_hdl, IPA_IP_v6, NUM_IPV6_PREFIX_FLT_RULE) == false)\n\t{\n\t\tclose(fd);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(is_sta_mode == false)\n\t{\n\t\tif (num_wan_ul_fl_rule_v6 > MAX_WAN_UL_FILTER_RULES)\n\t\t{\n\t\t\tIPACMERR(\" the number of rules (%d) are bigger than array (%d), aborting...\\n\", num_wan_ul_fl_rule_v6, MAX_WAN_UL_FILTER_RULES);\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tif (m_filtering.DeleteFilteringHdls(wan_ul_fl_rule_hdl_v6,\n\t\t\tIPA_IP_v6, num_wan_ul_fl_rule_v6) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting RuleTable(1) to Filtering, aborting...\\n\");\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tmemset(wan_ul_fl_rule_hdl_v6, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));\n\t\tnum_wan_ul_fl_rule_v6 = 0;\n\t\tmodem_ul_v6_set = false;\n\n\t\tmemset(&flt_index, 0, sizeof(flt_index));\n\t\tflt_index.source_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, rx_prop->rx[0].src_pipe);\n\t\tflt_index.install_status = IPA_QMI_RESULT_SUCCESS_V01;\n\t\tflt_index.filter_index_list_len = 0;\n\t\tflt_index.embedded_pipe_index_valid = 1;\n\t\tflt_index.embedded_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, IPA_CLIENT_APPS_LAN_WAN_PROD);\n\t\tflt_index.retain_header_valid = 1;\n\t\tflt_index.retain_header = 0;\n\t\tflt_index.embedded_call_mux_id_valid = 1;\n\t\tflt_index.embedded_call_mux_id = IPACM_Iface::ipacmcfg->GetQmapId();\n\t\tif(false == m_filtering.SendFilteringRuleIndex(&flt_index))\n\t\t{\n\t\t\tIPACMERR(\"Error sending filtering rule index, aborting...\\n\");\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (m_filtering.DeleteFilteringHdls(&dft_v6fl_rule_hdl[IPV6_DEFAULT_FILTERTING_RULES],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v6, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding RuleTable(1) to Filtering, aborting...\\n\");\n\t\t\tclose(fd);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\tclose(fd);\n\treturn IPACM_SUCCESS;\n}\n\n\n/*handle lan2lan client active*/\nint IPACM_Lan::handle_lan2lan_client_active(ipacm_event_data_all *data, ipa_cm_event_id event)\n{\n\tif(data == NULL)\n\t{\n\t\tIPACMERR(\"Event data is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(data->iptype == IPA_IP_v4 && ip_type != IPA_IP_v4 && ip_type != IPA_IP_MAX)\n\t{\n\t\tIPACMERR(\"Client has IPv4 addr but iface does not have IPv4 up.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(data->iptype == IPA_IP_v6 && ip_type != IPA_IP_v6 && ip_type != IPA_IP_MAX)\n\t{\n\t\tIPACMERR(\"Client has IPv6 addr but iface does not have IPv6 up.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tipacm_cmd_q_data evt_data;\n\tmemset(&evt_data, 0, sizeof(evt_data));\n\n\tipacm_event_lan_client* lan_client;\n\tlan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));\n\tif(lan_client == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate memory.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(lan_client, 0, sizeof(ipacm_event_lan_client));\n\tlan_client->iptype = data->iptype;\n\tlan_client->ipv4_addr = data->ipv4_addr;\n\tmemcpy(lan_client->ipv6_addr, data->ipv6_addr, 4 * sizeof(uint32_t));\n\tmemcpy(lan_client->mac_addr, data->mac_addr, 6 * sizeof(uint8_t));\n\tlan_client->p_iface = this;\n\n\tevt_data.event = event;\n\tevt_data.evt_data = (void*)lan_client;\n\n\tIPACMDBG_H(\"Posting event: %d\\n\", event);\n\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::add_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr, uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t* rule_hdl)\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMERR(\"There is no rx_prop for iface %s, not able to add lan2lan filtering rule.\\n\", dev_name);\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(rule_hdl == NULL)\n\t{\n\t\tIPACMERR(\"Filteing rule handle is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Got a new lan2lan flt rule with IP type: %d\\n\", iptype);\n\n\tint i, len, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable;\n\n\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);\n\n\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error allocate lan2lan flt rule memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = 1;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"src_v4_addr: %d dst_v4_addr: %d\\n\", src_v4_addr, dst_v4_addr);\n\n\t\tif(num_lan2lan_flt_rule_v4 >= MAX_OFFLOAD_PAIR)\n\t\t{\n\t\t\tIPACMERR(\"Lan2lan flt rule table is full, not able to add.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tif(false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table %s handle.\\n\", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name);\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"Routing handle for table %s: %d\\n\", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name,\n\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.hdl);\n\n\t\tflt_rule.status = -1;\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(lan2lan_flt_rule_hdl_v4[i].valid == false)\n\t\t\t{\n\t\t\t\tflt_rule.rule_hdl = lan2lan_flt_rule_hdl_v4[i].rule_hdl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == MAX_OFFLOAD_PAIR)\n\t\t{\n\t\t\tIPACMERR(\"Failed to find a filtering rule.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tflt_rule.rule.retain_hdr = 0;\n\t\tflt_rule.rule.to_uc = 0;\n\t\tflt_rule.rule.eq_attrib_type = 0;\n\t\tflt_rule.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.hdl;\n\n\t\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule.rule.attrib));\n\t\tIPACMDBG_H(\"Rx property attrib mask:0x%x\\n\", rx_prop->rx[0].attrib.attrib_mask);\n\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;\n\t\tflt_rule.rule.attrib.u.v4.src_addr = src_v4_addr;\n\t\tflt_rule.rule.attrib.u.v4.src_addr_mask = 0xFFFFFFFF;\n\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr = dst_v4_addr;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\n\t\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\t\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error modifying filtering rule.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlan2lan_flt_rule_hdl_v4[i].valid = true;\n\t\t\t*rule_hdl = lan2lan_flt_rule_hdl_v4[i].rule_hdl;\n\t\t\tnum_lan2lan_flt_rule_v4++;\n\t\t\tIPACMDBG_H(\"Flt rule modified, hdl: 0x%x, status: %d\\n\", pFilteringTable->rules[0].rule_hdl,\n\t\t\t\t\t\tpFilteringTable->rules[0].status);\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tif(num_lan2lan_flt_rule_v6 >= MAX_OFFLOAD_PAIR)\n\t\t{\n\t\t\tIPACMERR(\"Lan2lan flt rule table is full, not able to add.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tif(src_v6_addr == NULL || dst_v6_addr == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Got IPv6 flt rule but without IPv6 src/dst addr.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\\n\", src_v6_addr[0], src_v6_addr[1],\n\t\t\t\tsrc_v6_addr[2], src_v6_addr[3], dst_v6_addr[0], dst_v6_addr[1], dst_v6_addr[2], dst_v6_addr[3]);\n\n\t\tif(false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table %s handle.\\n\", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name);\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"Routing handle for table %s: %d\\n\", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name,\n\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.hdl);\n\n\t\tflt_rule.status = -1;\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(lan2lan_flt_rule_hdl_v6[i].valid == false)\n\t\t\t{\n\t\t\t\tflt_rule.rule_hdl = lan2lan_flt_rule_hdl_v6[i].rule_hdl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == MAX_OFFLOAD_PAIR)\n\t\t{\n\t\t\tIPACMERR(\"Failed to find a filtering rule handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tflt_rule.rule.retain_hdr = 0;\n\t\tflt_rule.rule.to_uc = 0;\n\t\tflt_rule.rule.eq_attrib_type = 0;\n\t\tflt_rule.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.hdl;\n\n\t\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule.rule.attrib));\n\t\tIPACMDBG_H(\"Rx property attrib mask:0x%x\\n\", rx_prop->rx[0].attrib.attrib_mask);\n\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[0] = src_v6_addr[0];\n\t\tflt_rule.rule.attrib.u.v6.src_addr[1] = src_v6_addr[1];\n\t\tflt_rule.rule.attrib.u.v6.src_addr[2] = src_v6_addr[2];\n\t\tflt_rule.rule.attrib.u.v6.src_addr[3] = src_v6_addr[3];\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[0] = 0xFFFFFFFF;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[1] = 0xFFFFFFFF;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[2] = 0xFFFFFFFF;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[3] = 0xFFFFFFFF;\n\n\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[0] = dst_v6_addr[0];\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[1] = dst_v6_addr[1];\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[2] = dst_v6_addr[2];\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[3] = dst_v6_addr[3];\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\n\t\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\t\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error modifying filtering rule.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlan2lan_flt_rule_hdl_v6[i].valid = true;\n\t\t\t*rule_hdl = lan2lan_flt_rule_hdl_v6[i].rule_hdl;\n\t\t\tnum_lan2lan_flt_rule_v6++;\n\t\t\tIPACMDBG_H(\"Flt rule modified, hdl: 0x%x, status: %d\\n\", pFilteringTable->rules[0].rule_hdl,\n\t\t\t\t\t\tpFilteringTable->rules[0].status);\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\treturn res;\n}\n\nint IPACM_Lan::add_dummy_lan2lan_flt_rule(ipa_ip_type iptype)\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no rx_prop for iface %s, not able to add dummy lan2lan filtering rule.\\n\", dev_name);\n\t\treturn 0;\n\t}\n\n\tint i, len, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_add flt_rule;\n\tipa_ioc_add_flt_rule* pFilteringTable;\n\n\tlen = sizeof(struct ipa_ioc_add_flt_rule) +\tMAX_OFFLOAD_PAIR * sizeof(struct ipa_flt_rule_add);\n\n\tpFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error allocate flt table memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\tpFilteringTable->global = false;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = MAX_OFFLOAD_PAIR;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));\n\n\tflt_rule.rule.retain_hdr = 0;\n\tflt_rule.at_rear = true;\n\tflt_rule.flt_rule_hdl = -1;\n\tflt_rule.status = -1;\n\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,\n\t\t\tsizeof(flt_rule.rule.attrib));\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v4.src_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.src_addr = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr = ~0;\n\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error adding dummy lan2lan v4 flt rule\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_rule_count_v4 += MAX_OFFLOAD_PAIR;\n\t\t\t/* copy filter rule hdls */\n\t\t\tfor (int i = 0; i < MAX_OFFLOAD_PAIR; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tlan2lan_flt_rule_hdl_v4[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"Lan2lan v4 flt rule %d hdl:0x%x\\n\", i, lan2lan_flt_rule_hdl_v4[i].rule_hdl);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding lan2lan v4 flt rule %d\\n\", i);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[3] = ~0;\n\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error adding dummy lan2lan v6 flt rule\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_rule_count_v6 += MAX_OFFLOAD_PAIR;\n\t\t\t/* copy filter rule hdls */\n\t\t\tfor (int i = 0; i < MAX_OFFLOAD_PAIR; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tlan2lan_flt_rule_hdl_v6[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"Lan2lan v6 flt rule %d hdl:0x%x\\n\", i, lan2lan_flt_rule_hdl_v6[i].rule_hdl);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding lan2lan v6 flt rule %d\\n\", i);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\tgoto fail;\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\treturn res;\n}\n\nint IPACM_Lan::del_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl)\n{\n\tint i;\n\n\tIPACMDBG_H(\"Del lan2lan flt rule with IP type: %d hdl: %d\\n\", iptype, rule_hdl);\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(lan2lan_flt_rule_hdl_v4[i].rule_hdl == rule_hdl)\n\t\t\t{\n\t\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, rule_hdl) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to delete lan2lan v4 flt rule %d\\n\", rule_hdl);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tIPACMDBG_H(\"Deleted lan2lan v4 flt rule %d\\n\", rule_hdl);\n\t\t\t\tlan2lan_flt_rule_hdl_v4[i].valid = false;\n\t\t\t\tnum_lan2lan_flt_rule_v4--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif(i == MAX_OFFLOAD_PAIR) //not finding the rule\n\t\t{\n\t\t\tIPACMERR(\"The rule is not found.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(lan2lan_flt_rule_hdl_v6[i].rule_hdl == rule_hdl)\n\t\t\t{\n\t\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, rule_hdl) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to delete lan2lan v6 flt rule %d\\n\", rule_hdl);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tIPACMDBG_H(\"Deleted lan2lan v6 flt rule %d\\n\", rule_hdl);\n\t\t\t\tlan2lan_flt_rule_hdl_v6[i].valid = false;\n\t\t\t\tnum_lan2lan_flt_rule_v6--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif(i == MAX_OFFLOAD_PAIR) //not finding the rule\n\t\t{\n\t\t\tIPACMERR(\"The rule is not found.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl)\n{\n\tint len, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable;\n\n\tIPACMDBG_H(\"Reset flt rule to dummy, IP type: %d, hdl: %d\\n\", iptype, rule_hdl);\n\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);\n\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error allocate flt rule memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = 1;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\tflt_rule.status = -1;\n\tflt_rule.rule_hdl = rule_hdl;\n\n\tflt_rule.rule.retain_hdr = 0;\n\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"Reset IPv4 flt rule to dummy\\n\");\n\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.src_addr = ~0;\n\t\tflt_rule.rule.attrib.u.v4.src_addr_mask = ~0;\n\n\t\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\t\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error modifying filtering rule.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMDBG_H(\"Flt rule reset to dummy, hdl: 0x%x, status: %d\\n\", pFilteringTable->rules[0].rule_hdl,\n\t\t\t\t\t\tpFilteringTable->rules[0].status);\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tIPACMDBG_H(\"Reset IPv6 flt rule to dummy\\n\");\n\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = ~0;\n\n\n\t\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\t\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error modifying filtering rule.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMDBG_H(\"Flt rule reset to dummy, hdl: 0x%x, status: %d\\n\", pFilteringTable->rules[0].rule_hdl,\n\t\t\t\t\t\tpFilteringTable->rules[0].status);\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\treturn res;\n}\n\nint IPACM_Lan::add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl)\n{\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMERR(\"There is no tx_prop, cannot add header.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(src_mac == NULL || dst_mac == NULL)\n\t{\n\t\tIPACMERR(\"Either src_mac or dst_mac is null, cannot add header.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(hdr_hdl == NULL)\n\t{\n\t\tIPACMERR(\"Header handle is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tint i, j, len;\n\tint res = IPACM_SUCCESS;\n\tchar index[4];\n\tstruct ipa_ioc_copy_hdr sCopyHeader;\n\tstruct ipa_ioc_add_hdr *pHeader;\n\n\tIPACMDBG_H(\"Get lan2lan header request, src_mac: 0x%02x%02x%02x%02x%02x%02x dst_mac: 0x%02x%02x%02x%02x%02x%02x\\n\",\n\t\t\tsrc_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], dst_mac[0], dst_mac[1],\n\t\t\tdst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]);\n\n\tlen = sizeof(struct ipa_ioc_add_hdr) + sizeof(struct ipa_hdr_add);\n\tpHeader = (struct ipa_ioc_add_hdr *)malloc(len);\n\tif (pHeader == NULL)\n\t{\n\t\tIPACMERR(\"Failed to allocate header\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pHeader, 0, len);\n\n\tif(iptype == IPA_IP_v4)\n\t{\t\t/* copy partial header for v4*/\n\t\tfor(i=0; i<tx_prop->num_tx_props; i++)\n\t\t{\n\t\t\tif(tx_prop->tx[i].ip == IPA_IP_v4)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Got v4-header name from %d tx props\\n\", i);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG_H(\"Header name: %s\\n\", sCopyHeader.name);\n\t\t\t\tif(m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Copy header failed\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"Header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);\n\t\t\t\t}\n\n\t\t\t\tif(sCopyHeader.is_eth2_ofst_valid)\n\t\t\t\t{\n\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst], dst_mac, IPA_MAC_ADDR_SIZE);\n\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst+IPA_MAC_ADDR_SIZE], src_mac, IPA_MAC_ADDR_SIZE);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Ethernet 2 header offset is invalid.\\n\");\n\t\t\t\t}\n\n\t\t\t\tpHeader->commit = true;\n\t\t\t\tpHeader->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));\n\t\t\t\tstrlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_USB_HDR_NAME_V4, sizeof(pHeader->hdr[0].name));\n\n\t\t\t\tfor(j=0; j<MAX_OFFLOAD_PAIR; j++)\n\t\t\t\t{\n\t\t\t\t\tif( lan2lan_hdr_hdl_v4[j].valid == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Construct lan2lan hdr with index %d.\\n\", j);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(j == MAX_OFFLOAD_PAIR)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to find an available hdr index.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tlan2lan_hdr_hdl_v4[j].valid = true;\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", j);\n\t\t\t\tif (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeader->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tpHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeader->hdr[0].is_partial = 0;\n\t\t\t\tpHeader->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeader->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Ioctl IPA_IOC_ADD_HDR failed with status: %d\\n\", pHeader->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tIPACMDBG_H(\"Installed v4 full header %s header handle 0x%08x\\n\", pHeader->hdr[0].name,\n\t\t\t\t\t\t\tpHeader->hdr[0].hdr_hdl);\n\t\t\t\t*hdr_hdl = pHeader->hdr[0].hdr_hdl;\n\t\t\t\tlan2lan_hdr_hdl_v4[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\t\t/* copy partial header for v6*/\n\t\tfor(i=0; i<tx_prop->num_tx_props; i++)\n\t\t{\n\t\t\tif(tx_prop->tx[i].ip == IPA_IP_v6)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Got v6-header name from %d tx props\\n\", i);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG_H(\"Header name: %s\\n\", sCopyHeader.name);\n\t\t\t\tif(m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Copy header failed\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"Header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);\n\t\t\t\t}\n\t\t\t\tif(sCopyHeader.is_eth2_ofst_valid)\n\t\t\t\t{\n\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst], dst_mac, IPA_MAC_ADDR_SIZE);\n\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst+IPA_MAC_ADDR_SIZE], src_mac, IPA_MAC_ADDR_SIZE);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Ethernet 2 header offset is invalid.\\n\");\n\t\t\t\t}\n\n\t\t\t\tpHeader->commit = true;\n\t\t\t\tpHeader->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));\n\t\t\t\tstrlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_USB_HDR_NAME_V6, sizeof(pHeader->hdr[0].name));\n\n\t\t\t\tfor(j=0; j<MAX_OFFLOAD_PAIR; j++)\n\t\t\t\t{\n\t\t\t\t\tif( lan2lan_hdr_hdl_v6[j].valid == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Construct lan2lan hdr with index %d.\\n\", j);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(j == MAX_OFFLOAD_PAIR)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to find an available hdr index.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tlan2lan_hdr_hdl_v6[j].valid = true;\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", j);\n\t\t\t\tif (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeader->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tpHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeader->hdr[0].is_partial = 0;\n\t\t\t\tpHeader->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeader->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Ioctl IPA_IOC_ADD_HDR failed with status: %d\\n\", pHeader->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tIPACMDBG_H(\"Installed v6 full header %s header handle 0x%08x\\n\", pHeader->hdr[0].name,\n\t\t\t\t\t\t\tpHeader->hdr[0].hdr_hdl);\n\t\t\t\t*hdr_hdl = pHeader->hdr[0].hdr_hdl;\n\t\t\t\tlan2lan_hdr_hdl_v6[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t}\n\nfail:\n\tfree(pHeader);\n\treturn res;\n}\n\nint IPACM_Lan::del_lan2lan_hdr(ipa_ip_type iptype, uint32_t hdr_hdl)\n{\n\tint i;\n\tif (m_header.DeleteHeaderHdl(hdr_hdl) == false)\n\t{\n\t\tIPACMERR(\"Failed to delete header %d\\n\", hdr_hdl);\n\t\treturn IPACM_FAILURE;\n\t}\n\tIPACMDBG_H(\"Deleted header %d\\n\", hdr_hdl);\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(lan2lan_hdr_hdl_v4[i].hdr_hdl == hdr_hdl)\n\t\t\t{\n\t\t\t\tlan2lan_hdr_hdl_v4[i].valid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == MAX_OFFLOAD_PAIR)\n\t\t{\n\t\t\tIPACMERR(\"Failed to find corresponding hdr hdl.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(lan2lan_hdr_hdl_v6[i].hdr_hdl == hdr_hdl)\n\t\t\t{\n\t\t\t\tlan2lan_hdr_hdl_v6[i].valid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == MAX_OFFLOAD_PAIR)\n\t\t{\n\t\t\tIPACMERR(\"Failed to find corresponding hdr hdl.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::add_lan2lan_rt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr,\n\t\t\tuint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t hdr_hdl, lan_to_lan_rt_rule_hdl* rule_hdl)\n{\n\tstruct ipa_ioc_add_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_add *rt_rule_entry;\n\tuint32_t tx_index;\n\tint len;\n\tint res = IPACM_SUCCESS;\n\n\tIPACMDBG_H(\"Got a new lan2lan rt rule with IP type: %d\\n\", iptype);\n\n\tif(rule_hdl == NULL)\n\t{\n\t\tIPACMERR(\"Rule hdl is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(rule_hdl, 0, sizeof(lan_to_lan_rt_rule_hdl));\n\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no tx_prop for iface %s, not able to add lan2lan routing rule.\\n\", dev_name);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tlen = sizeof(struct ipa_ioc_add_rt_rule) + sizeof(struct ipa_rt_rule_add);\n\trt_rule = (struct ipa_ioc_add_rt_rule *)malloc(len);\n\tif (!rt_rule)\n\t{\n\t\tIPACMERR(\"Failed to allocate memory for rt rule\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(rt_rule, 0, len);\n\n\trt_rule->commit = 1;\n\trt_rule->num_rules = 1;\n\trt_rule->ip = iptype;\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"src_v4_addr: 0x%08x dst_v4_addr: 0x%08x\\n\", src_v4_addr, dst_v4_addr);\n\n\t\tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name);\n\t\trt_rule_entry = &rt_rule->rules[0];\n\t\trt_rule_entry->at_rear = false;\n\t\trt_rule_entry->rt_rule_hdl = 0;\n\t\trt_rule_entry->status = -1;\n\n\t\tfor (tx_index = 0; tx_index<iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t    if(tx_prop->tx[tx_index].ip != IPA_IP_v4)\n\t\t    {\n\t\t    \tIPACMDBG_H(\"Tx:%d, iptype: %d conflict ip-type: %d bypass\\n\",\n\t\t    \t\t\t\ttx_index, tx_prop->tx[tx_index].ip, IPA_IP_v4);\n\t\t    \tcontinue;\n\t\t    }\n\n\t\t\trt_rule_entry->rule.hdr_hdl = hdr_hdl;\n\t\t\trt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\tmemcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\tsizeof(rt_rule_entry->rule.attrib));\n\n\t\t\trt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;\n\t\t\trt_rule_entry->rule.attrib.u.v4.src_addr      = src_v4_addr;\n\t\t\trt_rule_entry->rule.attrib.u.v4.src_addr_mask = 0xFFFFFFFF;\n\n\t\t\trt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr      = dst_v4_addr;\n\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\n\t\t\tif(m_routing.AddRoutingRule(rt_rule) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Routing rule addition failed\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tIPACMDBG_H(\"Added rt rule hdl: 0x%08x\\n\", rt_rule_entry->rt_rule_hdl);\n\t\t\trule_hdl->rule_hdl[rule_hdl->num_rule] = rt_rule_entry->rt_rule_hdl;\n\t\t\trule_hdl->num_rule++;\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tif(src_v6_addr == NULL || dst_v6_addr == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Got IPv6 rt rule but without IPv6 src/dst addr.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\\n\", src_v6_addr[0], src_v6_addr[1],\n\t\t\t\tsrc_v6_addr[2], src_v6_addr[3], dst_v6_addr[0], dst_v6_addr[1], dst_v6_addr[2], dst_v6_addr[3]);\n\n\t\tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name);\n\t\trt_rule_entry = &rt_rule->rules[0];\n\t\trt_rule_entry->at_rear = false;\n\t\trt_rule_entry->rt_rule_hdl = 0;\n\t\trt_rule_entry->status = -1;\n\n\t\tfor (tx_index = 0; tx_index<iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t    if(tx_prop->tx[tx_index].ip != IPA_IP_v6)\n\t\t    {\n\t\t    \tIPACMDBG_H(\"Tx:%d, iptype: %d conflict ip-type: %d bypass\\n\",\n\t\t    \t\t\t\ttx_index, tx_prop->tx[tx_index].ip, IPA_IP_v6);\n\t\t    \tcontinue;\n\t\t    }\n\n\t\t\trt_rule_entry->rule.hdr_hdl = hdr_hdl;\n\t\t\trt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\tmemcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\tsizeof(rt_rule_entry->rule.attrib));\n\n\t\t\trt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;\n\t\t\trt_rule_entry->rule.attrib.u.v6.src_addr[0] = src_v6_addr[0];\n\t\t\trt_rule_entry->rule.attrib.u.v6.src_addr[1] = src_v6_addr[1];\n\t\t\trt_rule_entry->rule.attrib.u.v6.src_addr[2] = src_v6_addr[2];\n\t\t\trt_rule_entry->rule.attrib.u.v6.src_addr[3] = src_v6_addr[3];\n\t\t\trt_rule_entry->rule.attrib.u.v6.src_addr_mask[0] = 0xFFFFFFFF;\n\t\t\trt_rule_entry->rule.attrib.u.v6.src_addr_mask[1] = 0xFFFFFFFF;\n\t\t\trt_rule_entry->rule.attrib.u.v6.src_addr_mask[2] = 0xFFFFFFFF;\n\t\t\trt_rule_entry->rule.attrib.u.v6.src_addr_mask[3] = 0xFFFFFFFF;\n\n\t\t\trt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[0] = dst_v6_addr[0];\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[1] = dst_v6_addr[1];\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[2] = dst_v6_addr[2];\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[3] = dst_v6_addr[3];\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\n\t\t\tif(m_routing.AddRoutingRule(rt_rule) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Routing rule addition failed\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tIPACMDBG_H(\"Added rt rule hdl: 0x%08x\\n\", rt_rule_entry->rt_rule_hdl);\n\t\t\trule_hdl->rule_hdl[rule_hdl->num_rule] = rt_rule_entry->rt_rule_hdl;\n\t\t\trule_hdl->num_rule++;\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t}\n\nfail:\n\tfree(rt_rule);\n\treturn res;\n}\n\nint IPACM_Lan::del_lan2lan_rt_rule(ipa_ip_type iptype, lan_to_lan_rt_rule_hdl rule_hdl)\n{\n\tif(rule_hdl.num_rule <= 0 || rule_hdl.num_rule > MAX_NUM_PROP)\n\t{\n\t\tIPACMERR(\"The number of rule handles are not correct.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tint i, res = IPACM_SUCCESS;\n\n\tIPACMDBG_H(\"Get %d rule handles with IP type %d\\n\", rule_hdl.num_rule, iptype);\n\tfor(i=0; i<rule_hdl.num_rule; i++)\n\t{\n\t\tif(m_routing.DeleteRoutingHdl(rule_hdl.rule_hdl[i], iptype) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete routing rule hdl %d.\\n\", rule_hdl.rule_hdl[i]);\n\t\t\tres = IPACM_FAILURE;\n\t\t}\n\t\tIPACMDBG_H(\"Deleted routing rule handle %d\\n\",rule_hdl.rule_hdl[i]);\n\t}\n\treturn res;\n}\n\nvoid IPACM_Lan::post_del_self_evt()\n{\n\tipacm_cmd_q_data evt;\n\tipacm_event_data_fid* fid;\n\tfid = (ipacm_event_data_fid*)malloc(sizeof(ipacm_event_data_fid));\n\tif(fid == NULL)\n\t{\n\t\tIPACMERR(\"Failed to allocate fid memory.\\n\");\n\t\treturn;\n\t}\n\tmemset(fid, 0, sizeof(ipacm_event_data_fid));\n\tmemset(&evt, 0, sizeof(ipacm_cmd_q_data));\n\n\tfid->if_index = ipa_if_num;\n\n\tevt.evt_data = (void*)fid;\n\tevt.event = IPA_LAN_DELETE_SELF;\n\n\tIPACMDBG_H(\"Posting event IPA_LAN_DELETE_SELF\\n\");\n\tIPACM_EvtDispatcher::PostEvt(&evt);\n}\n\n/*handle reset usb-client rt-rules */\nint IPACM_Lan::handle_lan_client_reset_rt(ipa_ip_type iptype)\n{\n\tint i, res = IPACM_SUCCESS;\n\n\t/* clean eth-client routing rules */\n\tIPACMDBG_H(\"left %d eth clients need to be deleted \\n \", num_eth_client);\n\tfor (i = 0; i < num_eth_client; i++)\n\t{\n\t\tres = delete_eth_rtrules(i, iptype);\n\t\tif (res != IPACM_SUCCESS)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete old iptype(%d) rules.\\n\", iptype);\n\t\t\treturn res;\n\t\t}\n\t} /* end of for loop */\n\n\t/* Pass info to LAN2LAN module */\n\tres = post_lan2lan_client_disconnect_msg(iptype);\n\tif (res != IPACM_SUCCESS)\n\t{\n\t\tIPACMERR(\"Failed to posting delete old iptype(%d) address.\\n\", iptype);\n\t\treturn res;\n\t}\n\t/* Reset ip-address */\n\tfor (i = 0; i < num_eth_client; i++)\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tget_client_memptr(eth_client, i)->ipv4_set = false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tget_client_memptr(eth_client, i)->ipv6_set = 0;\n\t\t}\n\t} /* end of for loop */\n\treturn res;\n}\n\n/*handle lan2lan internal mesg posting*/\nint IPACM_Lan::post_lan2lan_client_disconnect_msg(ipa_ip_type iptype)\n{\n\tint i, j;\n\tipacm_cmd_q_data evt_data;\n\tipacm_event_lan_client* lan_client;\n\n\tfor (i = 0; i < num_eth_client; i++)\n\t{\n\t\t\tif((get_client_memptr(eth_client, i)->ipv4_set == true)\n\t\t\t\t&& (iptype == IPA_IP_v4))\n\t\t\t{\n\t\t\t\tlan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));\n\t\t\t\tif(lan_client == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to allocate memory.\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tmemset(lan_client, 0, sizeof(ipacm_event_lan_client));\n\t\t\t\tlan_client->iptype = IPA_IP_v4;\n\t\t\t\tlan_client->ipv4_addr = get_client_memptr(eth_client, i)->v4_addr;\n\t\t\t\tlan_client->p_iface = this;\n\n\t\t\t\tmemset(&evt_data, 0, sizeof(ipacm_cmd_q_data));\n\t\t\t\tevt_data.evt_data = (void*)lan_client;\n\t\t\t\tevt_data.event = IPA_LAN_CLIENT_DISCONNECT;\n\n\t\t\t\tIPACMDBG_H(\"Posting event IPA_LAN_CLIENT_DISCONNECT\\n\");\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t}\n\n\t\t\tif((get_client_memptr(eth_client, i)->ipv6_set > 0)\n\t\t\t\t&& (iptype == IPA_IP_v6))\n\t\t\t{\n\t\t\t\tfor (j = 0; j < get_client_memptr(eth_client, i)->ipv6_set; j++)\n\t\t\t\t{\n\t\t\t\t\tlan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));\n\t\t\t\t\tif(lan_client == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Failed to allocate memory.\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t\tmemset(lan_client, 0, sizeof(ipacm_event_lan_client));\n\t\t\t\t\tlan_client->iptype = IPA_IP_v6;\n\t\t\t\t\tlan_client->ipv6_addr[0] = get_client_memptr(eth_client, i)->v6_addr[j][0];\n\t\t\t\t\tlan_client->ipv6_addr[0] = get_client_memptr(eth_client, i)->v6_addr[j][0];\n\t\t\t\t\tlan_client->ipv6_addr[0] = get_client_memptr(eth_client, i)->v6_addr[j][0];\n\t\t\t\t\tlan_client->ipv6_addr[0] = get_client_memptr(eth_client, i)->v6_addr[j][0];\n\t\t\t\t\tlan_client->p_iface = this;\n\n\t\t\t\t\tmemset(&evt_data, 0, sizeof(ipacm_cmd_q_data));\n\t\t\t\t\tevt_data.evt_data = (void*)lan_client;\n\t\t\t\t\tevt_data.event = IPA_LAN_CLIENT_DISCONNECT;\n\n\t\t\t\t\tIPACMDBG_H(\"Posting event IPA_LAN_CLIENT_DISCONNECT\\n\");\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t}\n\t\t\t}\n\t} /* end of for loop */\n\treturn IPACM_SUCCESS;\n}\n\nvoid IPACM_Lan::install_tcp_ctl_flt_rule(ipa_ip_type iptype)\n{\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn;\n\t}\n\n\tint len, i;\n\tstruct ipa_flt_rule_add flt_rule;\n\tipa_ioc_add_flt_rule* pFilteringTable;\n\n\tlen = sizeof(struct ipa_ioc_add_flt_rule) +\tNUM_TCP_CTL_FLT_RULE * sizeof(struct ipa_flt_rule_add);\n\n\tpFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error allocate flt table memory...\\n\");\n\t\treturn;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\tpFilteringTable->global = false;\n\tpFilteringTable->num_rules = NUM_TCP_CTL_FLT_RULE;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));\n\n\tflt_rule.at_rear = true;\n\tflt_rule.flt_rule_hdl = -1;\n\tflt_rule.status = -1;\n\n\tflt_rule.rule.retain_hdr = 1;\n\tflt_rule.rule.to_uc = 0;\n\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\tflt_rule.rule.eq_attrib_type = 1;\n\n\tflt_rule.rule.eq_attrib.rule_eq_bitmap = 0;\n\n\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<14);\n\tflt_rule.rule.eq_attrib.metadata_meq32_present = 1;\n\tflt_rule.rule.eq_attrib.metadata_meq32.offset = 0;\n\tflt_rule.rule.eq_attrib.metadata_meq32.value = rx_prop->rx[0].attrib.meta_data;\n\tflt_rule.rule.eq_attrib.metadata_meq32.mask = rx_prop->rx[0].attrib.meta_data_mask;\n\n\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<1);\n\tflt_rule.rule.eq_attrib.protocol_eq_present = 1;\n\tflt_rule.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;\n\n\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<8);\n\tflt_rule.rule.eq_attrib.num_ihl_offset_meq_32 = 1;\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;\n\n\t/* add TCP FIN rule*/\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\n\t/* add TCP SYN rule*/\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\tmemcpy(&(pFilteringTable->rules[1]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\n\t/* add TCP RST rule*/\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);\n\tmemcpy(&(pFilteringTable->rules[2]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\n\tif (false == m_filtering.AddFilteringRule(pFilteringTable))\n\t{\n\t\tIPACMERR(\"Error adding tcp control flt rule\\n\");\n\t\tgoto fail;\n\t}\n\telse\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tfor(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)\n\t\t\t{\n\t\t\t\tflt_rule_count_v4++;\n\t\t\t\ttcp_ctl_flt_rule_hdl_v4[i] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)\n\t\t\t{\n\t\t\t\tflt_rule_count_v6++;\n\t\t\t\ttcp_ctl_flt_rule_hdl_v6[i] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t}\n\t\t}\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\treturn;\n}\n\nint IPACM_Lan::add_dummy_private_subnet_flt_rule(ipa_ip_type iptype)\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no rx_prop for iface %s, not able to add dummy private subnet filtering rule.\\n\", dev_name);\n\t\treturn 0;\n\t}\n\n\tif(iptype == IPA_IP_v6)\n\t{\n\t\tIPACMDBG_H(\"There is no ipv6 dummy filter rules needed for iface %s\\n\", dev_name);\n\t\treturn 0;\n\t}\n\tint i, len, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_add flt_rule;\n\tipa_ioc_add_flt_rule* pFilteringTable;\n\n\tlen = sizeof(struct ipa_ioc_add_flt_rule) +\tIPA_MAX_PRIVATE_SUBNET_ENTRIES * sizeof(struct ipa_flt_rule_add);\n\n\tpFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error allocate flt table memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\tpFilteringTable->global = false;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = IPA_MAX_PRIVATE_SUBNET_ENTRIES;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));\n\n\tflt_rule.rule.retain_hdr = 0;\n\tflt_rule.at_rear = true;\n\tflt_rule.flt_rule_hdl = -1;\n\tflt_rule.status = -1;\n\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,\n\t\t\tsizeof(flt_rule.rule.attrib));\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v4.src_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.src_addr = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr = ~0;\n\n\t\tfor(i=0; i<IPA_MAX_PRIVATE_SUBNET_ENTRIES; i++)\n\t\t{\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error adding dummy private subnet v4 flt rule\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_rule_count_v4 += IPA_MAX_PRIVATE_SUBNET_ENTRIES;\n\t\t\t/* copy filter rule hdls */\n\t\t\tfor (int i = 0; i < IPA_MAX_PRIVATE_SUBNET_ENTRIES; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tprivate_fl_rule_hdl[i] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"Private subnet v4 flt rule %d hdl:0x%x\\n\", i, private_fl_rule_hdl[i]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding lan2lan v4 flt rule %d\\n\", i);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\nfail:\n\tfree(pFilteringTable);\n\treturn res;\n}\n\nint IPACM_Lan::handle_private_subnet_android(ipa_ip_type iptype)\n{\n\tint i, len, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable;\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif(iptype == IPA_IP_v6)\n\t{\n\t\tIPACMDBG_H(\"There is no ipv6 dummy filter rules needed for iface %s\\n\", dev_name);\n\t\treturn 0;\n\t}\n\telse\n\t{\n\t\tfor(i=0; i<IPA_MAX_PRIVATE_SUBNET_ENTRIES; i++)\n\t\t{\n\t\t\treset_to_dummy_flt_rule(IPA_IP_v4, private_fl_rule_hdl[i]);\n\t\t}\n\n\t\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + (IPACM_Iface::ipacmcfg->ipa_num_private_subnet) * sizeof(struct ipa_flt_rule_mdfy);\n\t\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\t\tif (!pFilteringTable)\n\t\t{\n\t\t\tIPACMERR(\"Failed to allocate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(pFilteringTable, 0, len);\n\n\t\tpFilteringTable->commit = 1;\n\t\tpFilteringTable->ip = iptype;\n\t\tpFilteringTable->num_rules = (uint8_t)IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\n\t\t/* Make LAN-traffic always go A5, use default IPA-RT table */\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_default_v4))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\t\tflt_rule.status = -1;\n\n\t\tflt_rule.rule.retain_hdr = 1;\n\t\tflt_rule.rule.to_uc = 0;\n\t\tflt_rule.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule.rule.eq_attrib_type = 0;\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_default_v4.hdl;\n\t\tIPACMDBG_H(\"Private filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_default_v4.name);\n\n\t\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\n\t\tfor (i = 0; i < (IPACM_Iface::ipacmcfg->ipa_num_private_subnet); i++)\n\t\t{\n\t\t\tflt_rule.rule_hdl = private_fl_rule_hdl[i];\n\t\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask;\n\t\t\tflt_rule.rule.attrib.u.v4.dst_addr = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr;\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\t\t\tIPACMDBG_H(\" IPACM private subnet_addr as: 0x%x entry(%d)\\n\", flt_rule.rule.attrib.u.v4.dst_addr, i);\n\t\t}\n\n\t\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Failed to modify private subnet filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\nfail:\n\tif(pFilteringTable != NULL)\n\t{\n\t\tfree(pFilteringTable);\n\t}\n\treturn res;\n}\n\nint IPACM_Lan::install_ipv6_prefix_flt_rule(uint32_t* prefix)\n{\n\tif(prefix == NULL)\n\t{\n\t\tIPACMERR(\"IPv6 prefix is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tIPACMDBG_H(\"Receive IPv6 prefix: 0x%08x%08x.\\n\", prefix[0], prefix[1]);\n\n\tint len;\n\tstruct ipa_ioc_add_flt_rule* flt_rule;\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\n\tif(rx_prop != NULL)\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);\n\n\t\tflt_rule = (struct ipa_ioc_add_flt_rule *)calloc(1, len);\n\t\tif (!flt_rule)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tflt_rule->commit = 1;\n\t\tflt_rule->ep = rx_prop->rx[0].src_pipe;\n\t\tflt_rule->global = false;\n\t\tflt_rule->ip = IPA_IP_v6;\n\t\tflt_rule->num_rules = 1;\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 0;\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\t\tmemcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));\n\t\tflt_rule_entry.rule.attrib.attrib_mask = flt_rule_entry.rule.attrib.attrib_mask & ~((uint32_t)IPA_FLT_META_DATA);\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = prefix[0];\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = prefix[1];\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x0;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0x0;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x0;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x0;\n\t\tmemcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\tif (m_filtering.AddFilteringRule(flt_rule) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tfree(flt_rule);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tipv6_prefix_flt_rule_hdl[0] = flt_rule->rules[0].flt_rule_hdl;\n\t\t\tIPACMDBG_H(\"IPv6 prefix filter rule HDL:0x%x\\n\", ipv6_prefix_flt_rule_hdl[0]);\n\t\t\tflt_rule_count_v6++;\n\t\t\tfree(flt_rule);\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::install_ipv6_icmp_flt_rule()\n{\n\n\tint len;\n\tstruct ipa_ioc_add_flt_rule* flt_rule;\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\n\tif(rx_prop != NULL)\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);\n\n\t\tflt_rule = (struct ipa_ioc_add_flt_rule *)calloc(1, len);\n\t\tif (!flt_rule)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tflt_rule->commit = 1;\n\t\tflt_rule->ep = rx_prop->rx[0].src_pipe;\n\t\tflt_rule->global = false;\n\t\tflt_rule->ip = IPA_IP_v6;\n\t\tflt_rule->num_rules = 1;\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 0;\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\t\tmemcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));\n\t\tflt_rule_entry.rule.attrib.attrib_mask = flt_rule_entry.rule.attrib.attrib_mask & ~((uint32_t)IPA_FLT_META_DATA);\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6;\n\t\tmemcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\tif (m_filtering.AddFilteringRule(flt_rule) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\tfree(flt_rule);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tipv6_icmp_flt_rule_hdl[0] = flt_rule->rules[0].flt_rule_hdl;\n\t\t\tIPACMDBG_H(\"IPv6 icmp filter rule HDL:0x%x\\n\", ipv6_icmp_flt_rule_hdl[0]);\n\t\t\tflt_rule_count_v6++;\n\t\t\tfree(flt_rule);\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::handle_addr_evt_odu_bridge(ipacm_event_data_addr* data)\n{\n\tint fd, res = IPACM_SUCCESS;\n\tstruct in6_addr ipv6_addr;\n\tif(data == NULL)\n\t{\n\t\tIPACMERR(\"Failed to get interface IP address.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(data->iptype == IPA_IP_v6)\n\t{\n\t\tfd = open(IPACM_Iface::ipacmcfg->DEVICE_NAME_ODU, O_RDWR);\n\t\tif(fd == 0)\n\t\t{\n\t\t\tIPACMERR(\"Failed to open %s.\\n\", IPACM_Iface::ipacmcfg->DEVICE_NAME_ODU);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tmemcpy(&ipv6_addr, data->ipv6_addr, sizeof(struct in6_addr));\n\n\t\tif( ioctl(fd, ODU_BRIDGE_IOC_SET_LLV6_ADDR, &ipv6_addr) )\n\t\t{\n\t\t\tIPACMERR(\"Failed to write IPv6 address to odu driver.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t}\n\t\tnum_dft_rt_v6++;\n\t\tclose(fd);\n\t}\n\n\treturn res;\n}\n\nint IPACM_Lan::eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype)\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no rx_prop for iface %s, not able to add dummy wlan client specific filtering rule.\\n\", dev_name);\n\t\treturn 0;\n\t}\n\n\tint i, len, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_add flt_rule;\n\tipa_ioc_add_flt_rule* pFilteringTable;\n\n\tlen = sizeof(struct ipa_ioc_add_flt_rule) +\tIPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(struct ipa_flt_rule_add);\n\n\tpFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error allocate flt table memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\tpFilteringTable->global = false;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = IPA_LAN_TO_LAN_MAX_WLAN_CLIENT;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));\n\n\tflt_rule.rule.retain_hdr = 0;\n\tflt_rule.at_rear = true;\n\tflt_rule.flt_rule_hdl = -1;\n\tflt_rule.status = -1;\n\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,\n\t\t\tsizeof(flt_rule.rule.attrib));\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v4.src_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.src_addr = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr = ~0;\n\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t{\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error adding dummy lan2lan v4 flt rule\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_rule_count_v4 += IPA_LAN_TO_LAN_MAX_WLAN_CLIENT;\n\t\t\t/* copy filter rule hdls */\n\t\t\tfor (int i = 0; i < IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\twlan_client_flt_rule_hdl_v4[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\twlan_client_flt_rule_hdl_v4[i].valid = true;\n\t\t\t\t\tIPACMDBG_H(\"Wlan client v4 flt rule %d hdl:0x%x\\n\", i, wlan_client_flt_rule_hdl_v4[i].rule_hdl);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding wlan client v4 flt rule %d\\n\", i);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[3] = ~0;\n\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t{\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error adding dummy lan2lan v6 flt rule\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_rule_count_v6 += IPA_LAN_TO_LAN_MAX_WLAN_CLIENT;\n\t\t\t/* copy filter rule hdls */\n\t\t\tfor (int i = 0; i < IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\twlan_client_flt_rule_hdl_v6[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\twlan_client_flt_rule_hdl_v6[i].valid = true;\n\t\t\t\t\tIPACMDBG_H(\"Wlan client v6 flt rule %d hdl:0x%x\\n\", i, wlan_client_flt_rule_hdl_v6[i].rule_hdl);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding wlan client v6 flt rule %d\\n\", i);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\tgoto fail;\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\treturn res;\n}\n\nint IPACM_Lan::eth_bridge_add_wlan_guest_ap_flt_rule(ipa_ip_type iptype)\n{\n\tIPACMDBG_H(\"No need to add WLAN guest AP flt rule on USB pipe.\\n\");\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::eth_bridge_handle_dummy_usb_client_flt_rule(ipa_ip_type iptype)\n{\n\tIPACMDBG_H(\"No need to add USB client specific flt rule on USB pipe.\\n\");\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::eth_bridge_post_lan_client_event(uint8_t* mac_addr, ipa_cm_event_id evt)\n{\n\tif(mac_addr == NULL)\n\t{\n\t\tIPACMERR(\"Event mac is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tipacm_cmd_q_data evt_data;\n\tmemset(&evt_data, 0, sizeof(evt_data));\n\n\tipacm_event_data_mac* mac;\n\tmac = (ipacm_event_data_mac*)malloc(sizeof(ipacm_event_data_mac));\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate memory.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(mac, 0, sizeof(ipacm_event_data_mac));\n\tmemcpy(mac->mac_addr, mac_addr, 6 * sizeof(uint8_t));\n\n\tevt_data.event = evt;\n\tevt_data.evt_data = (void*)mac;\n\tIPACMDBG_H(\"Posting event: %d\\n\", evt);\n\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::eth_bridge_add_wlan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype)\n{\n\tint i, len, res = IPACM_SUCCESS, client_position;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable = NULL;\n\tbool client_is_found = false;\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(IPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid == false)\n\t{\n\t\tIPACMDBG_H(\"USB to WLAN hdr proc ctx has not been set, don't add client specific flt rule.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tfor(i=0; i<wlan_client_flt_info_count; i++)\n\t{\n\t\tif(memcmp(eth_bridge_wlan_client_flt_info[i].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[i].mac)) == 0)\n\t\t{\n\t\t\tclient_is_found = true;\n\t\t\tclient_position = i;\n\t\t\tif( (iptype == IPA_IP_v4 && eth_bridge_wlan_client_flt_info[i].flt_rule_set_v4 == true)\n\t\t\t\t|| (iptype == IPA_IP_v6 && eth_bridge_wlan_client_flt_info[i].flt_rule_set_v6 == true))\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Flt rule for iptype %d has been set.\\n\", iptype);\n\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(client_is_found == false && wlan_client_flt_info_count == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t{\n\t\tIPACMDBG_H(\"The wlan client flt table is already full.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);\n\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\tif (!pFilteringTable)\n\t{\n\t\tIPACMERR(\"Failed to allocate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tIPACMDBG_H(\"Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\t/* add mac based rule*/\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = 1;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\tflt_rule.status = -1;\n\n\tflt_rule.rule.retain_hdr = 0;\n\tflt_rule.rule.to_uc = 0;\n\tflt_rule.rule.action = IPA_PASS_TO_ROUTING;\n\tflt_rule.rule.eq_attrib_type = 0;\n\n\t/* point to USB-WLAN routing table */\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v4))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v4.hdl;\n\t\tIPACMDBG_H(\"USB->WLAN filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v4.name);\n\t}\n\telse\n\t{\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v6))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v6.hdl;\n\t\tIPACMDBG_H(\"USB->WLAN filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v6.name);\n\t}\n\n\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n\tif(IPACM_Lan::usb_hdr_type == IPA_HDR_L2_ETHERNET_II)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;\n\t}\n\telse if(IPACM_Lan::usb_hdr_type == IPA_HDR_L2_802_3)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"USB hdr type is not expected.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\tmemcpy(flt_rule.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule.rule.attrib.dst_mac_addr));\n\tmemset(flt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule.rule.attrib.dst_mac_addr_mask));\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t{\n\t\t\tif(wlan_client_flt_rule_hdl_v4[i].valid == true)\n\t\t\t{\n\t\t\t\tflt_rule.rule_hdl = wlan_client_flt_rule_hdl_v4[i].rule_hdl;\n\t\t\t\twlan_client_flt_rule_hdl_v4[i].valid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t{\n\t\t\tIPACMDBG_H(\"Cannot find a valid flt rule hdl.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t{\n\t\t\tif(wlan_client_flt_rule_hdl_v6[i].valid == true)\n\t\t\t{\n\t\t\t\tflt_rule.rule_hdl = wlan_client_flt_rule_hdl_v6[i].rule_hdl;\n\t\t\t\twlan_client_flt_rule_hdl_v6[i].valid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t{\n\t\t\tIPACMDBG_H(\"Cannot find a valid flt rule hdl.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t{\n\t\tIPACMERR(\"Failed to add wlan client filtering rules.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tif(client_is_found == false)\n\t{\n\t\tclient_position = wlan_client_flt_info_count;\n\t\twlan_client_flt_info_count++;\n\t}\n\n\tmemcpy(eth_bridge_wlan_client_flt_info[client_position].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[client_position].mac));\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\teth_bridge_wlan_client_flt_info[client_position].flt_rule_set_v4 = true;\n\t\teth_bridge_wlan_client_flt_info[client_position].flt_rule_hdl_v4 = wlan_client_flt_rule_hdl_v4[i].rule_hdl;\n\t}\n\telse\n\t{\n\t\teth_bridge_wlan_client_flt_info[client_position].flt_rule_set_v6 = true;\n\t\teth_bridge_wlan_client_flt_info[client_position].flt_rule_hdl_v6 = wlan_client_flt_rule_hdl_v6[i].rule_hdl;\n\t}\n\nfail:\n\tif(pFilteringTable == NULL)\n\t{\n\t\tfree(pFilteringTable);\n\t}\n\treturn res;\n}\n\nint IPACM_Lan::eth_bridge_del_wlan_client_flt_rule(uint8_t* mac)\n{\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Client MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\tint i, j, res = IPACM_SUCCESS;\n\tfor(i=0; i<wlan_client_flt_info_count; i++)\n\t{\n\t\tif(memcmp(eth_bridge_wlan_client_flt_info[i].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[i].mac)) == 0)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(i == wlan_client_flt_info_count)\n\t{\n\t\tIPACMERR(\"Do not find the wlan client.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(eth_bridge_wlan_client_flt_info[i].flt_rule_set_v4 == true)\n\t{\n\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v4) == IPACM_SUCCESS)\n\t\t{\n\t\t\tfor(j=0; j<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; j++)\n\t\t\t{\n\t\t\t\tif(wlan_client_flt_rule_hdl_v4[j].rule_hdl == eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v4)\n\t\t\t\t{\n\t\t\t\t\twlan_client_flt_rule_hdl_v4[j].valid = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(j == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Not finding the rule handle in handle pool.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete the wlan client specific flt rule.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\tif(eth_bridge_wlan_client_flt_info[i].flt_rule_set_v6 == true)\n\t{\n\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v6) == IPACM_SUCCESS)\n\t\t{\n\t\t\tfor(j=0; j<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; j++)\n\t\t\t{\n\t\t\t\tif(wlan_client_flt_rule_hdl_v6[j].rule_hdl == eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v6)\n\t\t\t\t{\n\t\t\t\t\twlan_client_flt_rule_hdl_v6[j].valid = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(j == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Not finding the rule handle in handle pool.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete the wlan client specific flt rule.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tfor(j=i+1; j<wlan_client_flt_info_count; j++)\n\t{\n\t\tmemcpy(&(eth_bridge_wlan_client_flt_info[j-1]), &(eth_bridge_wlan_client_flt_info[j]), sizeof(eth_bridge_client_flt_info));\n\t}\n\tmemset(&(eth_bridge_wlan_client_flt_info[wlan_client_flt_info_count-1]), 0, sizeof(eth_bridge_client_flt_info));\n\twlan_client_flt_info_count--;\n\n\treturn res;\n}\n\nint IPACM_Lan::add_hdr_proc_ctx()\n{\n\tint len, res = IPACM_SUCCESS;\n\tstruct ipa_ioc_add_hdr_proc_ctx* pHeaderProcTable = NULL;\n\n\tlen = sizeof(struct ipa_ioc_add_hdr_proc_ctx) + sizeof(struct ipa_hdr_proc_ctx_add);\n\tpHeaderProcTable = (ipa_ioc_add_hdr_proc_ctx*)malloc(len);\n\tif(pHeaderProcTable == NULL)\n\t{\n\t\tIPACMERR(\"Cannot allocate header processing table.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(IPACM_Lan::wlan_hdr_type != IPA_HDR_L2_NONE)\n\t{\n\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF)\n\t\t{\n\t\t\tif(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == false)\n\t\t\t{\n\t\t\t\tmemset(pHeaderProcTable, 0, len);\n\t\t\t\tpHeaderProcTable->commit = 1;\n\t\t\t\tpHeaderProcTable->num_proc_ctxs = 1;\n\t\t\t\tpHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::wlan_hdr_type, IPACM_Lan::wlan_hdr_type);\n\t\t\t\tpHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::wlan_hdr_template_hdl;\n\t\t\t\tif (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Adding WLAN to WLAN hdr proc ctx failed with status: %d\\n\", pHeaderProcTable->proc_ctx[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;\n\t\t\t\t\tIPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif(IPACM_Lan::usb_hdr_type != IPA_HDR_L2_NONE)\n\t\t{\n\t\t\tif(IPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid == false)\n\t\t\t{\n\t\t\t\tmemset(pHeaderProcTable, 0, len);\n\t\t\t\tpHeaderProcTable->commit = 1;\n\t\t\t\tpHeaderProcTable->num_proc_ctxs = 1;\n\t\t\t\tpHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::usb_hdr_type, IPACM_Lan::wlan_hdr_type);\n\t\t\t\tpHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::wlan_hdr_template_hdl;\n\t\t\t\tif (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Adding USB to WLAN hdr proc ctx failed with status: %d\\n\", pHeaderProcTable->proc_ctx[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACM_Lan::usb_to_wlan_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;\n\t\t\t\t\tIPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid = true;\n\t\t\t\t}\n\n\t\t\t\tipacm_cmd_q_data evt_data;\n\t\t\t\tmemset(&evt_data, 0, sizeof(ipacm_cmd_q_data));\n\n\t\t\t\tipacm_event_data_fid* fid;\n\t\t\t\tfid = (ipacm_event_data_fid*)malloc(sizeof(ipacm_event_data_fid));\n\t\t\t\tif(fid == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Unable to allocate memory.\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tmemset(fid, 0, sizeof(ipacm_event_data_fid));\n\t\t\t\tfid->if_index = ipa_if_num;\n\n\t\t\t\tevt_data.evt_data = fid;\n\t\t\t\tevt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT;\n\t\t\t\tIPACMDBG_H(\"Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT\\n\");\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t}\n\n\t\t\tif(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == false)\n\t\t\t{\n\t\t\t\tmemset(pHeaderProcTable, 0, len);\n\t\t\t\tpHeaderProcTable->commit = 1;\n\t\t\t\tpHeaderProcTable->num_proc_ctxs = 1;\n\t\t\t\tpHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::wlan_hdr_type, IPACM_Lan::usb_hdr_type);\n\t\t\t\tpHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::usb_hdr_template_hdl;\n\t\t\t\tif (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Adding WLAN to USB hdr proc ctx failed with status: %d\\n\", pHeaderProcTable->proc_ctx[0].status);\n\t\t\t\t\tm_header.DeleteHeaderProcCtx(IPACM_Lan::usb_to_wlan_hdr_proc_ctx.proc_ctx_hdl);\n\t\t\t\t\tIPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid = false;\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;\n\t\t\t\t\tIPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMDBG_H(\"Not adding header processing context.\\n\");\n\t}\n\nfail:\n\tfree(pHeaderProcTable);\n\treturn res;\n}\n\nipa_hdr_proc_type IPACM_Lan::get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2)\n{\n\tif(t1 == IPA_HDR_L2_ETHERNET_II)\n\t{\n\t\tif(t2 == IPA_HDR_L2_ETHERNET_II)\n\t\t{\n\t\t\treturn IPA_HDR_PROC_ETHII_TO_ETHII;\n\t\t}\n\t\tif(t2 == IPA_HDR_L2_802_3)\n\t\t{\n\t\t\treturn IPA_HDR_PROC_ETHII_TO_802_3;\n\t\t}\n\t}\n\n\tif(t1 == IPA_HDR_L2_802_3)\n\t{\n\t\tif(t2 == IPA_HDR_L2_ETHERNET_II)\n\t\t{\n\t\t\treturn IPA_HDR_PROC_802_3_TO_ETHII;\n\t\t}\n\t\tif(t2 == IPA_HDR_L2_802_3)\n\t\t{\n\t\t\treturn IPA_HDR_PROC_802_3_TO_802_3;\n\t\t}\n\t}\n\n\treturn IPA_HDR_PROC_NONE;\n}\n\nint IPACM_Lan::eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype)\n{\n\tint i;\n\n\tIPACMDBG_H(\"There are %d wlan clients cached.\\n\",IPACM_Lan::num_wlan_client);\n\tfor(i=0; i<IPACM_Lan::num_wlan_client; i++)\n\t{\n\t\teth_bridge_add_wlan_client_flt_rule(IPACM_Lan::eth_bridge_wlan_client[i].mac, iptype);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::eth_bridge_install_cache_usb_client_flt_rule(ipa_ip_type iptype)\n{\n\tIPACMDBG_H(\"No need to install usb client specific flt rules on usb pipe.\\n\");\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::eth_bridge_add_usb_client_rt_rule(uint8_t* mac, ipa_ip_type iptype)\n{\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"Tx prop is empty, not adding routing rule.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Client MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif( (iptype == IPA_IP_v4 && usb_client_rt_info_count_v4 == IPA_LAN_TO_LAN_MAX_USB_CLIENT)\n\t\t|| (iptype == IPA_IP_v6 && usb_client_rt_info_count_v6 == IPA_LAN_TO_LAN_MAX_USB_CLIENT))\n\t{\n\t\tIPACMDBG_H(\"USB client number has reached maximum.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == false)\n\t{\n\t\tIPACMDBG_H(\"WLAN to USB hdr proc ctx has not been set, don't add USB routing rule.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Receive USB client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\tint i, len, res = IPACM_SUCCESS;\n\tstruct ipa_ioc_add_rt_rule* rt_rule_table = NULL;\n\tstruct ipa_rt_rule_add rt_rule;\n\tint position, num_rt_rule;\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tfor(i=0; i<usb_client_rt_info_count_v4; i++)\n\t\t{\n\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, iptype)->mac)) == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"The client's routing rule was added before.\\n\");\n\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t}\n\t\t}\n\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(usb_client_rt_info_count_v4, iptype)->mac, mac,\n\t\t\t\tsizeof(eth_bridge_get_client_rt_info_ptr(usb_client_rt_info_count_v4, iptype)->mac));\n\t}\n\telse\n\t{\n\t\tfor(i=0; i<usb_client_rt_info_count_v6; i++)\n\t\t{\n\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, iptype)->mac)) == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"The client's routing rule was added before.\\n\");\n\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t}\n\t\t}\n\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(usb_client_rt_info_count_v6, iptype)->mac, mac,\n\t\t\t\tsizeof(eth_bridge_get_client_rt_info_ptr(usb_client_rt_info_count_v6, iptype)->mac));\n\t}\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tnum_rt_rule = each_client_rt_rule_count_v4;\n\t}\n\telse\n\t{\n\t\tnum_rt_rule = each_client_rt_rule_count_v6;\n\t}\n\n\tlen = sizeof(ipa_ioc_add_rt_rule) + num_rt_rule * sizeof(ipa_rt_rule_add);\n\trt_rule_table = (ipa_ioc_add_rt_rule*)malloc(len);\n\tif(rt_rule_table == NULL)\n\t{\n\t\tIPACMERR(\"Failed to allocate memory.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(rt_rule_table, 0, len);\n\n\trt_rule_table->commit = 1;\n\trt_rule_table->ip = iptype;\n\trt_rule_table->num_rules = num_rt_rule;\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tstrncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));\n\t}\n\telse\n\t{\n\t\tstrncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));\n\t}\n\n\tmemset(&rt_rule, 0, sizeof(ipa_rt_rule_add));\n\trt_rule.at_rear = false;\n\trt_rule.status = -1;\n\trt_rule.rt_rule_hdl = -1;\n\n\trt_rule.rule.hdr_hdl = 0;\n\trt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl;\n\tposition = 0;\n\tfor(i=0; i<iface_query->num_tx_props; i++)\n\t{\n\t\tif(tx_prop->tx[i].ip == iptype)\n\t\t{\n\t\t\tif(position >= num_rt_rule)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Number of routing rules already exceeds limit for iptype %d.\\n\", iptype);\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\trt_rule.rule.dst = tx_prop->tx[i].dst_pipe;\n\t\t\tmemcpy(&rt_rule.rule.attrib, &tx_prop->tx[i].attrib, sizeof(rt_rule.rule.attrib));\n\t\t\tif(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_ETHERNET_II)\n\t\t\t{\n\t\t\t\trt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;\n\t\t\t}\n\t\t\telse if(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_802_3)\n\t\t\t{\n\t\t\t\trt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMERR(\"WLAN header type is not expected.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tmemcpy(rt_rule.rule.attrib.dst_mac_addr, mac, sizeof(rt_rule.rule.attrib.dst_mac_addr));\n\t\t\tmemset(rt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(rt_rule.rule.attrib.dst_mac_addr_mask));\n\n\t\t\tmemcpy(&(rt_rule_table->rules[position]), &rt_rule, sizeof(rt_rule_table->rules[position]));\n\t\t\tposition++;\n\t\t}\n\t}\n\n\tif(false == m_routing.AddRoutingRule(rt_rule_table))\n\t{\n\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\telse\n\t{\n\t\tfor(i=0; i<num_rt_rule; i++)\n\t\t{\n\t\t\tif(iptype == IPA_IP_v4)\n\t\t\t{\n\t\t\t\teth_bridge_get_client_rt_info_ptr(usb_client_rt_info_count_v4, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\teth_bridge_get_client_rt_info_ptr(usb_client_rt_info_count_v6, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;\n\t\t\t}\n\t\t}\n\t}\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tusb_client_rt_info_count_v4++;\n\t\tIPACMDBG_H(\"Now the number of IPv4 rt rule info is %d.\\n\", usb_client_rt_info_count_v4);\n\t}\n\telse\n\t{\n\t\tusb_client_rt_info_count_v6++;\n\t\tIPACMDBG_H(\"Now the number of IPv6 rt rule info is %d.\\n\", usb_client_rt_info_count_v6);\n\t}\n\nfail:\n\tif(rt_rule_table != NULL)\n\t{\n\t\tfree(rt_rule_table);\n\t}\n\treturn res;\n}\n\nint IPACM_Lan::eth_bridge_del_usb_client_rt_rule(uint8_t* mac)\n{\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"Tx prop is empty, not deleting routing rule.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Client MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Receive USB client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\tint i, position;\n\t/* delete rule from IPv4 rt table first */\n\tfor(i=0; i<usb_client_rt_info_count_v4; i++)\n\t{\n\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, IPA_IP_v4)->mac)) == 0)\n\t\t{\n\t\t\tposition = i;\n\t\t\tIPACMDBG_H(\"The client is found at position %d.\\n\", position);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(i == usb_client_rt_info_count_v4)\n\t{\n\t\tIPACMERR(\"The client is not found.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tfor(i=0; i<each_client_rt_rule_count_v4; i++)\n\t{\n\t\tif(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, IPA_IP_v4)->rt_rule_hdl[i], IPA_IP_v4) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete routing rule %d.\\n\", i);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tfor(i=position+1; i<usb_client_rt_info_count_v4; i++)\n\t{\n\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(i-1, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, IPA_IP_v4), client_rt_info_size_v4);\n\t}\n\tmemset(eth_bridge_get_client_rt_info_ptr(usb_client_rt_info_count_v4-1, IPA_IP_v4), 0, client_rt_info_size_v4);\n\tusb_client_rt_info_count_v4--;\n\tIPACMDBG_H(\"Now the number of IPv4 rt rule info is %d.\\n\", usb_client_rt_info_count_v4);\n\n\t/*delete rule from IPv6 rt table */\n\tfor(i=0; i<usb_client_rt_info_count_v6; i++)\n\t{\n\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, IPA_IP_v6)->mac)) == 0)\n\t\t{\n\t\t\tposition = i;\n\t\t\tIPACMDBG_H(\"The client is found at position %d.\\n\", position);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(i == usb_client_rt_info_count_v6)\n\t{\n\t\tIPACMERR(\"The client is not found.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tfor(i=0; i<each_client_rt_rule_count_v6; i++)\n\t{\n\t\tif(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, IPA_IP_v6)->rt_rule_hdl[i], IPA_IP_v6) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete routing rule %d.\\n\", i);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tfor(i=position+1; i<usb_client_rt_info_count_v6; i++)\n\t{\n\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(i-1, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, IPA_IP_v6), client_rt_info_size_v6);\n\t}\n\tmemset(eth_bridge_get_client_rt_info_ptr(usb_client_rt_info_count_v6-1, IPA_IP_v6), 0, client_rt_info_size_v6);\n\tusb_client_rt_info_count_v6--;\n\tIPACMDBG_H(\"Now the number of IPv6 rt rule info is %d.\\n\", usb_client_rt_info_count_v6);\n\n\treturn IPACM_SUCCESS;\n}\n\neth_bridge_client_rt_info* IPACM_Lan::eth_bridge_get_client_rt_info_ptr(uint8_t index, ipa_ip_type iptype)\n{\n\tvoid* result;\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tresult = (void*)((char*)eth_bridge_usb_client_rt_info_v4 + index * client_rt_info_size_v4);\n\t}\n\telse\n\t{\n\t\tresult = (void*)((char*)eth_bridge_usb_client_rt_info_v6 + index * client_rt_info_size_v6);\n\t}\n\treturn (eth_bridge_client_rt_info*)result;\n}\n\nvoid IPACM_Lan::eth_bridge_add_usb_client(uint8_t* mac)\n{\n\tif(IPACM_Lan::num_usb_client == IPA_LAN_TO_LAN_MAX_USB_CLIENT)\n\t{\n\t\tIPACMDBG_H(\"USB client table is already full.\\n\");\n\t\treturn;\n\t}\n\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Mac address is empty.\\n\");\n\t\treturn;\n\t}\n\n\tmemcpy(IPACM_Lan::eth_bridge_usb_client[IPACM_Lan::num_usb_client].mac, mac, sizeof(IPACM_Lan::eth_bridge_usb_client[IPACM_Lan::num_usb_client].mac));\n\tIPACM_Lan::num_usb_client++;\n\treturn;\n}\n\nvoid IPACM_Lan::eth_bridge_del_usb_client(uint8_t* mac)\n{\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Mac address is empty.\\n\");\n\t\treturn;\n\t}\n\n\tint i, j;\n\tfor(i=0; i<IPACM_Lan::num_usb_client; i++)\n\t{\n\t\tif(memcmp(IPACM_Lan::eth_bridge_usb_client[i].mac, mac, sizeof(IPACM_Lan::eth_bridge_usb_client[i].mac)) == 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"Found USB client at position %d.\\n\", i);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(i == IPACM_Lan::num_usb_client)\n\t{\n\t\tIPACMDBG_H(\"Not finding the USB client.\\n\");\n\t\treturn;\n\t}\n\n\tfor(j=i+1; j<IPACM_Lan::num_usb_client; j++)\n\t{\n\t\tmemcpy(IPACM_Lan::eth_bridge_usb_client[j-1].mac, IPACM_Lan::eth_bridge_usb_client[j].mac, sizeof(IPACM_Lan::eth_bridge_usb_client[j].mac));\n\t\tIPACM_Lan::eth_bridge_usb_client[j-1].ipa_if_num = IPACM_Lan::eth_bridge_usb_client[j].ipa_if_num;\n\t}\n\tIPACM_Lan::num_usb_client--;\n\treturn;\n}\n\nint IPACM_Lan::eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl)\n{\n\tif(hdr_hdl == NULL)\n\t{\n\t\tIPACMDBG_H(\"Hdr handle pointer is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tstruct ipa_ioc_get_hdr hdr;\n\tmemset(&hdr, 0, sizeof(hdr));\n\n\tmemcpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name));\n\tif(m_header.GetHeaderHandle(&hdr) == false)\n\t{\n\t\tIPACMERR(\"Failed to get template hdr hdl.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t*hdr_hdl = hdr.hdl;\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Lan::del_hdr_proc_ctx()\n{\n\tif(IPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid == true)\n\t{\n\t\tif(m_header.DeleteHeaderProcCtx(IPACM_Lan::usb_to_wlan_hdr_proc_ctx.proc_ctx_hdl) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete usb to wlan hdr proc ctx.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tIPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid = false;\n\n\t\tipacm_cmd_q_data evt_data;\n\t\tmemset(&evt_data, 0, sizeof(ipacm_cmd_q_data));\n\n\t\tipacm_event_data_fid* fid;\n\t\tfid = (ipacm_event_data_fid*)malloc(sizeof(ipacm_event_data_fid));\n\t\tif(fid == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to allocate memory.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(fid, 0, sizeof(ipacm_event_data_fid));\n\t\tfid->if_index = ipa_if_num;\n\n\t\tevt_data.evt_data = fid;\n\t\tevt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT;\n\t\tIPACMDBG_H(\"Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT\\n\");\n\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t}\n\n\tif(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == true)\n\t{\n\t\tif(m_header.DeleteHeaderProcCtx(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete wlan to usb hdr proc ctx.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tIPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid = false;\n\t}\n\n\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF)\n\t{\n\t\tif(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)\n\t\t{\n\t\t\tif(m_header.DeleteHeaderProcCtx(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to delete wlan to wlan hdr proc ctx.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\tIPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid = false;\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\n/*handle reset usb-client rt-rules */\nint IPACM_Lan::handle_tethering_stats_event(ipa_get_data_stats_resp_msg_v01 *data)\n{\n\tint cnt, pipe_len, fd;\n\tuint64_t num_ul_packets, num_ul_bytes;\n\tuint64_t num_dl_packets, num_dl_bytes;\n\tbool ul_pipe_found, dl_pipe_found;\n\tFILE *fp = NULL;\n\n\tfd = open(IPA_DEVICE_NAME, O_RDWR);\n\tif (fd < 0)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", IPA_DEVICE_NAME);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\n\tul_pipe_found = false;\n\tdl_pipe_found = false;\n\tnum_ul_packets = 0;\n\tnum_dl_packets = 0;\n\tnum_ul_bytes = 0;\n\tnum_dl_bytes = 0;\n\n\tif (data->dl_dst_pipe_stats_list_valid)\n\t{\n\t\tif(tx_prop != NULL)\n\t\t{\n\t\t\tfor (pipe_len = 0; pipe_len < data->dl_dst_pipe_stats_list_len; pipe_len++)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Check entry(%d) dl_dst_pipe(%d)\\n\", pipe_len, data->dl_dst_pipe_stats_list[pipe_len].pipe_index);\n\t\t\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Check Tx_prop_entry(%d) pipe(%d)\\n\", cnt, ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, tx_prop->tx[cnt].dst_pipe));\n\t\t\t\t\tif(ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, tx_prop->tx[cnt].dst_pipe) == data->dl_dst_pipe_stats_list[pipe_len].pipe_index)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* update the DL stats */\n\t\t\t\t\t\tdl_pipe_found = true;\n\t\t\t\t\t\tnum_dl_packets += data->dl_dst_pipe_stats_list[pipe_len].num_ipv4_packets;\n\t\t\t\t\t\tnum_dl_packets += data->dl_dst_pipe_stats_list[pipe_len].num_ipv6_packets;\n\t\t\t\t\t\tnum_dl_bytes += data->dl_dst_pipe_stats_list[pipe_len].num_ipv4_bytes;\n\t\t\t\t\t\tnum_dl_bytes += data->dl_dst_pipe_stats_list[pipe_len].num_ipv6_bytes;\n\t\t\t\t\t\tIPACMDBG_H(\"Got matched dst-pipe (%d) from %d tx props\\n\", data->dl_dst_pipe_stats_list[pipe_len].pipe_index, cnt);\n\t\t\t\t\t\tIPACMDBG_H(\"DL_packets:(%lu) DL_bytes:(%lu) \\n\", num_dl_packets, num_dl_bytes);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (data->ul_src_pipe_stats_list_valid)\n\t{\n\t\tif(rx_prop != NULL)\n\t\t{\n\t\t\tfor (pipe_len = 0; pipe_len < data->ul_src_pipe_stats_list_len; pipe_len++)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Check entry(%d) dl_dst_pipe(%d)\\n\", pipe_len, data->ul_src_pipe_stats_list[pipe_len].pipe_index);\n\t\t\t\tfor (cnt=0; cnt < rx_prop->num_rx_props; cnt++)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Check Rx_prop_entry(%d) pipe(%d)\\n\", cnt, ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, rx_prop->rx[cnt].src_pipe));\n\t\t\t\t\tif(ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, rx_prop->rx[cnt].src_pipe) == data->ul_src_pipe_stats_list[pipe_len].pipe_index)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* update the UL stats */\n\t\t\t\t\t\tul_pipe_found = true;\n\t\t\t\t\t\tnum_ul_packets += data->ul_src_pipe_stats_list[pipe_len].num_ipv4_packets;\n\t\t\t\t\t\tnum_ul_packets += data->ul_src_pipe_stats_list[pipe_len].num_ipv6_packets;\n\t\t\t\t\t\tnum_ul_bytes += data->ul_src_pipe_stats_list[pipe_len].num_ipv4_bytes;\n\t\t\t\t\t\tnum_ul_bytes += data->ul_src_pipe_stats_list[pipe_len].num_ipv6_bytes;\n\t\t\t\t\t\tIPACMDBG_H(\"Got matched dst-pipe (%d) from %d tx props\\n\", data->ul_src_pipe_stats_list[pipe_len].pipe_index, cnt);\n\t\t\t\t\t\tIPACMDBG_H(\"UL_packets:(%lu) UL_bytes:(%lu) \\n\", num_ul_packets, num_ul_bytes);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tclose(fd);\n\n\tif (ul_pipe_found || dl_pipe_found)\n\t{\n\t\tIPACMDBG_H(\"Update IPA_TETHERING_STATS_UPDATE_EVENT, TX(P%lu/B%lu) RX(P%lu/B%lu) DEV(%s) to LTE(%s) \\n\",\n\t\t\t\t\tnum_ul_packets,\n\t\t\t\t\t\tnum_ul_bytes,\n\t\t\t\t\t\t\tnum_dl_packets,\n\t\t\t\t\t\t\t\tnum_dl_bytes,\n\t\t\t\t\t\t\t\t\tdev_name,\n\t\t\t\t\t\t\t\t\t\tIPACM_Wan::wan_up_dev_name);\n\t\tfp = fopen(IPA_PIPE_STATS_FILE_NAME, \"w\");\n\t\tif ( fp == NULL )\n\t\t{\n\t\t\tIPACMERR(\"Failed to write pipe stats to %s, error is %d - %s\\n\",\n\t\t\t\t\tIPA_PIPE_STATS_FILE_NAME, errno, strerror(errno));\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tfprintf(fp, PIPE_STATS,\n\t\t\t\tdev_name,\n\t\t\t\t\tIPACM_Wan::wan_up_dev_name,\n\t\t\t\t\t\tnum_ul_bytes,\n\t\t\t\t\t\tnum_ul_packets,\n\t\t\t\t\t\t\t    num_dl_bytes,\n\t\t\t\t\t\t\tnum_dl_packets);\n\t\tfclose(fp);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\n/*handle tether client */\nint IPACM_Lan::handle_tethering_client(bool reset, ipacm_client_enum ipa_client)\n{\n\tint cnt, fd, ret = IPACM_SUCCESS;\n\tint fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR);\n\twan_ioctl_set_tether_client_pipe tether_client;\n\n\tif(fd_wwan_ioctl < 0)\n\t{\n\t\tIPACMERR(\"Failed to open %s.\\n\",WWAN_QMI_IOCTL_DEVICE_NAME);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tfd = open(IPA_DEVICE_NAME, O_RDWR);\n\tif (fd < 0)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", IPA_DEVICE_NAME);\n\t\tclose(fd_wwan_ioctl);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tmemset(&tether_client, 0, sizeof(tether_client));\n\ttether_client.reset_client = reset;\n\ttether_client.ipa_client = ipa_client;\n\n\tif(tx_prop != NULL)\n\t{\n\t\ttether_client.dl_dst_pipe_len = tx_prop->num_tx_props;\n\t\tfor (cnt = 0; cnt < tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\tIPACMDBG_H(\"Tx(%d), dst_pipe: %d, ipa_pipe: %d\\n\",\n\t\t\t\t\tcnt, tx_prop->tx[cnt].dst_pipe,\n\t\t\t\t\t\tioctl(fd, IPA_IOC_QUERY_EP_MAPPING, tx_prop->tx[cnt].dst_pipe));\n\t\t\ttether_client.dl_dst_pipe_list[cnt] = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, tx_prop->tx[cnt].dst_pipe);\n\t\t}\n\t}\n\n\tif(rx_prop != NULL)\n\t{\n\t\ttether_client.ul_src_pipe_len = rx_prop->num_rx_props;\n\t\tfor (cnt = 0; cnt < rx_prop->num_rx_props; cnt++)\n\t\t{\n\t\t\tIPACMDBG_H(\"Rx(%d), src_pipe: %d, ipa_pipe: %d\\n\",\n\t\t\t\t\tcnt, rx_prop->rx[cnt].src_pipe,\n\t\t\t\t\t\tioctl(fd, IPA_IOC_QUERY_EP_MAPPING, rx_prop->rx[cnt].src_pipe));\n\t\t\ttether_client.ul_src_pipe_list[cnt] = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, rx_prop->rx[cnt].src_pipe);\n\t\t}\n\t}\n\n\tret = ioctl(fd_wwan_ioctl, WAN_IOC_SET_TETHER_CLIENT_PIPE, &tether_client);\n\tif (ret != 0)\n\t{\n\t\tIPACMERR(\"Failed set tether-client-pipe %p with ret %d\\n \", &tether_client, ret);\n\t}\n\tIPACMDBG(\"Set tether-client-pipe %p\\n\", &tether_client);\n\tclose(fd);\n\tclose(fd_wwan_ioctl);\n\treturn ret;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_LanToLan.cpp",
    "content": "/*\nCopyright (c) 2014, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_LanToLan.cpp\n\n\t@brief\n\tThis file implements the functionality of offloading LAN to LAN traffic.\n\n\t@Author\n\tShihuan Liu\n\n*/\n\n#include <stdlib.h>\n#include <assert.h>\n#include \"IPACM_LanToLan.h\"\n#include \"IPACM_Wlan.h\"\n\n#define ipv6_multicast_addr 0xff000000\n#define ipv6_multicast_mask 0xff000000\n\n#define max_cache_connection 20\n\nIPACM_LanToLan* IPACM_LanToLan::p_instance = NULL;\n\nIPACM_LanToLan::IPACM_LanToLan()\n{\n\tnum_offload_pair_v4_ = 0;\n\tnum_offload_pair_v6_ = 0;\n\tclient_info_v4_.reserve(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT);\n\tclient_info_v6_.reserve(3*(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT));\n\tp_instance = this;\n\n\tIPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_ACTIVE, this);\n\tIPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_INACTIVE, this);\n\tIPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_DISCONNECT, this);\n\tIPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_POWER_SAVE, this);\n\tIPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_POWER_RECOVER, this);\n\tIPACM_EvtDispatcher::registr(IPA_LAN_TO_LAN_NEW_CONNECTION, this);\n\tIPACM_EvtDispatcher::registr(IPA_LAN_TO_LAN_DEL_CONNECTION, this);\n\treturn;\n}\n\nIPACM_LanToLan::~IPACM_LanToLan()\n{\n\tclient_table_v4::iterator it_v4;\n\tfor(it_v4 = client_info_v4_.begin(); it_v4 != client_info_v4_.end(); it_v4++)\n\t{\n\t\tturnoff_offload_links(IPA_IP_v4, &(it_v4->second));\n\t\tclear_peer_list(&(it_v4->second));\n\t}\n\tclient_info_v4_.clear();\n\tIPACMDBG(\"Clear IPv4 hash table in Lan2Lan distructor.\\n\");\n\n\tclient_table_v6::iterator it_v6;\n\tfor(it_v6 = client_info_v6_.begin(); it_v6 != client_info_v6_.end(); it_v6++)\n\t{\n\t\tturnoff_offload_links(IPA_IP_v6, &(it_v6->second));\n\t\tclear_peer_list(&(it_v6->second));\n\t}\n\tclient_info_v6_.clear();\n\tIPACMDBG(\"Clear IPv6 hash table in Lan2Lan distructor.\\n\");\n\n\treturn;\n}\n\nvoid IPACM_LanToLan::event_callback(ipa_cm_event_id event, void* param)\n{\n\tswitch(event)\n\t{\n\t\tcase IPA_LAN_CLIENT_ACTIVE:\n\t\t{\n\t\t\tIPACMDBG_H(\"Get IPA_LAN_CLIENT_ACTIVE event.\\n\");\n\t\t\tipacm_event_lan_client* data = (ipacm_event_lan_client*)param;\n\t\t\thandle_client_active(data);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IPA_LAN_CLIENT_INACTIVE:\n\t\t{\n\t\t\tIPACMDBG_H(\"Get IPA_LAN_CLIENT_INACTIVE event.\\n\");\n\t\t\tipacm_event_lan_client* data = (ipacm_event_lan_client*)param;\n\t\t\thandle_client_inactive(data);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IPA_LAN_CLIENT_DISCONNECT:\n\t\t{\n\t\t\tIPACMDBG_H(\"Get IPA_LAN_CLIENT_DISCONNECT event.\\n\");\n\t\t\tipacm_event_lan_client* data = (ipacm_event_lan_client*)param;\n\t\t\thandle_client_disconnect(data);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IPA_LAN_TO_LAN_NEW_CONNECTION:\n\t\t{\n\t\t\tIPACMDBG_H(\"Get IPA_LAN_TO_LAN_NEW_CONNECTION event.\\n\");\n\t\t\tipacm_event_connection* data = (ipacm_event_connection*)param;\n\t\t\thandle_new_lan2lan_connection(data);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IPA_LAN_TO_LAN_DEL_CONNECTION:\n\t\t{\n\t\t\tIPACMDBG_H(\"Get IPA_LAN_TO_LAN_DEL_CONNECTION event.\\n\");\n\t\t\tipacm_event_connection* data = (ipacm_event_connection*)param;\n\t\t\thandle_del_lan2lan_connection(data);\n\t\t\tbreak;\n\t\t}\n\t\tcase IPA_LAN_CLIENT_POWER_SAVE:\n\t\t{\n\t\t\tIPACMDBG_H(\"Get IPA_LAN_CLIENT_POWER_SAVE event.\\n\");\n\t\t\tipacm_event_lan_client* data = (ipacm_event_lan_client*)param;\n\t\t\thandle_client_power_save(data);\n\t\t\tbreak;\n\t\t}\n\t\tcase IPA_LAN_CLIENT_POWER_RECOVER:\n\t\t{\n\t\t\tIPACMDBG_H(\"Get IPA_LAN_CLIENT_POWER_RECOVER event.\\n\");\n\t\t\tipacm_event_lan_client* data = (ipacm_event_lan_client*)param;\n\t\t\thandle_client_power_recover(data);\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\treturn;\n}\n\nvoid IPACM_LanToLan::handle_client_active(ipacm_event_lan_client* data)\n{\n\tif(data == NULL)\n\t{\n\t\tIPACMERR(\"No client info is found.\\n\");\n\t\treturn;\n\t}\n\tif(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)\n\t{\n\t\tIPACMERR(\"Event data is not populated properly.\\n\");\n\t\treturn;\n\t}\n\tif(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"New client info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \\n\",\n\t\tdata->p_iface->dev_name, data->iptype,\n\t\tdata->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],\n\t\tdata->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n\n\tbool client_not_found;\n\tclient_info* client_ptr;\n\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tclient_not_found = (client_info_v4_.count(data->ipv4_addr) == 0);\n\t\tIPACMDBG_H(\"Is the client not found? %d\\n\", client_not_found);\n\t\tclient_info& client = client_info_v4_[data->ipv4_addr];\n\t\tclient_ptr = &client;\n\t}\n\telse\n\t{\n\t\tuint64_t v6_addr;\n\t\tmemcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));\n\n\t\tclient_not_found = (client_info_v6_.count(v6_addr) == 0);\n\t\tIPACMDBG_H(\"Is the client not found? %d\\n\", client_not_found);\n\t\tclient_info& client = client_info_v6_[v6_addr];\n\t\tclient_ptr = &client;\n\t}\n\n\tif(client_not_found == true)\n\t{\n\t\tif(data->iptype == IPA_IP_v4)\n\t\t{\n\t\t\tclient_ptr->ip.ipv4_addr = data->ipv4_addr;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmemcpy(client_ptr->ip.ipv6_addr, data->ipv6_addr, sizeof(client_ptr->ip.ipv6_addr));\n\t\t}\n\t\tmemcpy(client_ptr->mac_addr, data->mac_addr, sizeof(client_ptr->mac_addr));\n\t\tclient_ptr->is_active =  true;\n\t\tclient_ptr->is_powersave = false;\n\t\tclient_ptr->p_iface = data->p_iface;\n\n\t\tgenerate_new_connection(data->iptype, client_ptr);\n\t\tcheck_cache_connection(data->iptype, client_ptr);\n\t}\n\telse\t//the client is found\n\t{\n\t\tif(client_ptr->is_active == true)\t//the client is active\n\t\t{\n\t\t\tIPACMDBG_H(\"The client is active.\\n\");\n\t\t\tif(memcmp(client_ptr->mac_addr, data->mac_addr, sizeof(client_ptr->mac_addr)) == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Mac addr is the same, do nothing.\\n\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMERR(\"The new client has same IP but differenc mac.\\n\");\n\t\t\t\tturnoff_offload_links(data->iptype, client_ptr);\n\t\t\t\tclear_peer_list(client_ptr);\n\n\t\t\t\tif(data->iptype == IPA_IP_v4)\n\t\t\t\t{\n\t\t\t\t\tclient_ptr->ip.ipv4_addr = data->ipv4_addr;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(client_ptr->ip.ipv6_addr, data->ipv6_addr, sizeof(client_ptr->ip.ipv6_addr));\n\t\t\t\t}\n\t\t\t\tmemcpy(client_ptr->mac_addr, data->mac_addr, sizeof(client_ptr->mac_addr));\n\t\t\t\tclient_ptr->is_active =  true;\n\t\t\t\tclient_ptr->is_powersave = false;\n\t\t\t\tclient_ptr->p_iface = data->p_iface;\n\n\t\t\t\tgenerate_new_connection(data->iptype, client_ptr);\n\t\t\t\tcheck_cache_connection(data->iptype, client_ptr);\n\t\t\t}\n\t\t}\n\t\telse \t//the client is inactive\n\t\t{\n\t\t\tIPACMDBG_H(\"The client is inactive.\\n\");\n\t\t\tif(data->iptype == IPA_IP_v4)\n\t\t\t{\n\t\t\t\tclient_ptr->ip.ipv4_addr = data->ipv4_addr;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmemcpy(client_ptr->ip.ipv6_addr, data->ipv6_addr, sizeof(client_ptr->ip.ipv6_addr));\n\t\t\t}\n\t\t\tmemcpy(client_ptr->mac_addr, data->mac_addr, sizeof(client_ptr->mac_addr));\n\t\t\tclient_ptr->is_active =  true;\n\t\t\tclient_ptr->is_powersave = false;\n\t\t\tclient_ptr->p_iface = data->p_iface;\n\n\t\t\tcheck_potential_link(data->iptype, client_ptr);\n\t\t\tgenerate_new_connection(data->iptype, client_ptr);\n\t\t\tcheck_cache_connection(data->iptype, client_ptr);\n\t\t}\n\t}\n\tIPACMDBG_H(\"There are %d clients in v4 table and %d clients in v6 table.\\n\", client_info_v4_.size(), client_info_v6_.size());\n\treturn;\n}\n\nvoid IPACM_LanToLan::check_potential_link(ipa_ip_type iptype, client_info* client)\n{\n\tif(client == NULL)\n\t{\n\t\tIPACMERR(\"Client is NULL.\\n\");\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"Check client's peer list.\\n\");\n\tIPACMDBG_H(\"Client: IP type: %d, IPv4 addr: 0x%08x, IPv6 addr: 0x%08x%08x%08x%08x\\n\", iptype, client->ip.ipv4_addr,\n\t\t\t\tclient->ip.ipv6_addr[0], client->ip.ipv6_addr[1], client->ip.ipv6_addr[2], client->ip.ipv6_addr[3]);\n\n\tpeer_info_list::iterator peer_it;\n\tint res, num = 0;\n\n\tfor(peer_it = client->peer.begin(); peer_it != client->peer.end(); peer_it++)\n\t{\n\t\tif(peer_it->peer_pointer->is_active == true && peer_it->num_connection > 0)\n\t\t{\n\t\t\tres = IPACM_SUCCESS;\n\t\t\tres = add_offload_link(iptype, client, peer_it->peer_pointer);\n\t\t\tres = add_offload_link(iptype, peer_it->peer_pointer, client);\n\t\t\tif(res == IPACM_SUCCESS)\n\t\t\t{\n\t\t\t\tif(iptype == IPA_IP_v4)\n\t\t\t\t{\n\t\t\t\t\tnum_offload_pair_v4_ ++;\n\t\t\t\t\tIPACMDBG_H(\"Now the number of v4 offload links is %d.\\n\", num_offload_pair_v4_);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tnum_offload_pair_v6_ ++;\n\t\t\t\t\tIPACMDBG_H(\"Now the number of v6 offload links is %d.\\n\", num_offload_pair_v6_);\n\t\t\t\t}\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t}\n\tIPACMDBG_H(\"Added %d offload links in total.\\n\", num);\n\treturn;\n}\n\nint IPACM_LanToLan::add_offload_link(ipa_ip_type iptype, client_info* client, client_info* peer)\n{\n\tif( (iptype == IPA_IP_v4 && num_offload_pair_v4_ >= MAX_OFFLOAD_PAIR)\n\t\t|| (iptype == IPA_IP_v6 && num_offload_pair_v6_ >= MAX_OFFLOAD_PAIR) )\n\t{\n\t\tIPACMDBG_H(\"The number of offload pairs already reaches maximum.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(client == NULL || peer == NULL)\n\t{\n\t\tIPACMERR(\"Either client or peer is NULL.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tuint32_t hdr_hdl, flt_hdl;\n\tlan_to_lan_rt_rule_hdl rt_rule_hdl;\n\n\toffload_link_info link_info;\n\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"Add offload link for IPv4, client IP: 0x%08x, peer IP: 0x%08x \\n\", client->ip.ipv4_addr, peer->ip.ipv4_addr);\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tIPACMDBG_H(\"Add offload link for IPv6, client IP: 0x%08x%08x%08x%08x, peer IP: 0x%08x%08x%08x%08x \\n\",\n\t\t\t\tclient->ip.ipv6_addr[0], client->ip.ipv6_addr[1], client->ip.ipv6_addr[2], client->ip.ipv6_addr[3],\n\t\t\t\tpeer->ip.ipv6_addr[0], peer->ip.ipv6_addr[1], peer->ip.ipv6_addr[2], peer->ip.ipv6_addr[3]);\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t//add lan2lan header\n\tif(peer->p_iface->add_lan2lan_hdr(iptype, client->mac_addr, peer->mac_addr, &hdr_hdl) == IPACM_FAILURE)\n\t{\n\t\tIPACMERR(\"Failed to create lan2lan header.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tIPACMDBG_H(\"Created lan2lan hdr with hdl %d.\\n\", hdr_hdl);\n\n\t//add lan2lan routing/filtering rules\n\tif(peer->p_iface->add_lan2lan_rt_rule(iptype, client->ip.ipv4_addr, peer->ip.ipv4_addr,\n\t\t\t\t\tclient->ip.ipv6_addr, peer->ip.ipv6_addr, hdr_hdl, &rt_rule_hdl) == IPACM_FAILURE)\n\t{\n\t\tIPACMERR(\"Failed to create lan2lan rt rule.\\n\");\n\t\tgoto rt_fail;\n\t}\n\tIPACMDBG_H(\"Created %d lan2lan rt rules.\\n\", rt_rule_hdl.num_rule);\n\tIPACMDBG_H(\"Created lan2lan rt rules with hdl: %d.\\n\", rt_rule_hdl.rule_hdl[0]);\n\n\tif(client->p_iface->add_lan2lan_flt_rule(iptype, client->ip.ipv4_addr, peer->ip.ipv4_addr,\n\t\t\t\t\tclient->ip.ipv6_addr, peer->ip.ipv6_addr, &flt_hdl) == IPACM_FAILURE)\n\t{\n\t\tIPACMERR(\"Failed to create lan2lan flt rule.\\n\");\n\t\tgoto flt_fail;\n\t}\n\tIPACMDBG_H(\"Created lan2lan flt rule with hdl %d.\\n\", flt_hdl);\n\n\tlink_info.peer_pointer = peer;\n\tlink_info.flt_rule_hdl = flt_hdl;\n\tlink_info.hdr_hdl = hdr_hdl;\n\tmemcpy(&link_info.rt_rule_hdl, &rt_rule_hdl, sizeof(lan_to_lan_rt_rule_hdl));\n\n\tclient->link.push_back(link_info);\n\n\treturn IPACM_SUCCESS;\n\nflt_fail:\n\tpeer->p_iface->del_lan2lan_rt_rule(iptype, rt_rule_hdl);\n\nrt_fail:\n\tpeer->p_iface->del_lan2lan_hdr(iptype, hdr_hdl);\n\n\treturn IPACM_FAILURE;\n}\n\nvoid IPACM_LanToLan::handle_client_inactive(ipacm_event_lan_client* data)\n{\n\tif(data == NULL)\n\t{\n\t\tIPACMERR(\"No client info is found.\\n\");\n\t\treturn;\n\t}\n\tif(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)\n\t{\n\t\tIPACMERR(\"Event data is not populated properly.\\n\");\n\t\treturn;\n\t}\n\tif(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)\n\t{\n\t\tIPACMERR(\"IP type is not expected: %d.\\n\", data->iptype);\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"Del client info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \\n\",\n\t\tdata->p_iface->dev_name, data->iptype,\n\t\tdata->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],\n\t\tdata->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n\n\tclient_info* client_ptr;\n\tuint64_t v6_addr;\n\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tif(client_info_v4_.count(data->ipv4_addr) == 0)//if not found the client, return\n\t\t{\n\t\t\tIPACMERR(\"The client is not found the client, return.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"The client is found.\\n\");\n\t\tclient_info& client = client_info_v4_[data->ipv4_addr];\n\t\tclient_ptr = &client;\n\t}\n\telse\n\t{\n\t\tmemcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));\n\t\tif(client_info_v6_.count(v6_addr) == 0)\t//if not found the client, insert it in table\n\t\t{\n\t\t\tIPACMERR(\"The client is not found the client, return.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"The client is found.\\n\");\n\t\tclient_info& client = client_info_v6_[v6_addr];\n\t\tclient_ptr = &client;\n\t}\n\n\tturnoff_offload_links(data->iptype, client_ptr);\n\tclient_ptr->is_active = false;\n\tif(client_ptr->peer.size() == 0)\n\t{\n\t\tIPACMDBG_H(\"Peer list is empty, remove client entry.\\n\");\n\t\tif(data->iptype == IPA_IP_v4)\n\t\t{\n\t\t\tclient_info_v4_.erase(data->ipv4_addr);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tclient_info_v6_.erase(v6_addr);\n\t\t}\n\t}\n\treturn;\n}\n\nint IPACM_LanToLan::turnoff_offload_links(ipa_ip_type iptype, client_info* client)\n{\n\tif(client == NULL)\n\t{\n\t\tIPACMERR(\"Client is NULL.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tbool err_flag;\n\toffload_link_info_list::iterator client_it;\n\toffload_link_info_list::iterator peer_it;\n\tclient_info* peer;\n\n\tfor(client_it = client->link.begin(); client_it != client->link.end(); client_it++)\n\t{\n\t\tpeer = client_it->peer_pointer;\n\t\tif(del_offload_link(iptype, client->p_iface, peer->p_iface, &(*client_it)) == IPACM_FAILURE)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete client's offload link.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\terr_flag = true;\n\t\tfor(peer_it = peer->link.begin(); peer_it != peer->link.end(); peer_it++)\n\t\t{\n\t\t\tif(peer_it->peer_pointer == client)\n\t\t\t{\n\t\t\t\tif(del_offload_link(iptype, peer->p_iface, client->p_iface, &(*peer_it)) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to delete peer's offload link.\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tpeer->link.erase(peer_it);\n\t\t\t\terr_flag = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(err_flag)\n\t\t{\n\t\t\tIPACMERR(\"Unable to find corresponding offload link in peer's entry.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tnum_offload_pair_v4_ --;\n\t\t\tIPACMDBG_H(\"Now the number of v4 offload pair is %d\\n\", num_offload_pair_v4_);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tnum_offload_pair_v6_ --;\n\t\t\tIPACMDBG_H(\"Now the number of v6 offload pair is %d\\n\", num_offload_pair_v6_);\n\t\t}\n\t}\n\n\tclient->link.clear();\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_LanToLan::del_offload_link(ipa_ip_type iptype, IPACM_Lan* client, IPACM_Lan* peer, offload_link_info* link)\n{\n\tif(client == NULL || peer == NULL || link == NULL)\n\t{\n\t\tIPACMERR(\"Either iface or link is NULL.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Delete an offload link for IP type: %d\\n\", iptype);\n\n\tint res = IPACM_SUCCESS;\n\n\tif(client->del_lan2lan_flt_rule(iptype, link->flt_rule_hdl) == IPACM_FAILURE)\n\t{\n\t\tIPACMERR(\"Failed to delete flt rule.\\n\");\n\t\tres = IPACM_FAILURE;\n\t}\n\n\tif(peer->del_lan2lan_rt_rule(iptype, link->rt_rule_hdl) == IPACM_FAILURE)\n\t{\n\t\tIPACMERR(\"Failed to delete rt rules.\\n\");\n\t\tres = IPACM_FAILURE;\n\t}\n\n\tif(peer->del_lan2lan_hdr(iptype, link->hdr_hdl) == IPACM_FAILURE)\n\t{\n\t\tIPACMERR(\"Failed to delete header.\\n\");\n\t\tres = IPACM_FAILURE;\n\t}\n\n\treturn res;\n}\n\nvoid IPACM_LanToLan::handle_client_disconnect(ipacm_event_lan_client* data)\n{\n\tif(data == NULL)\n\t{\n\t\tIPACMERR(\"No client info is found.\\n\");\n\t\treturn;\n\t}\n\tif(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)\n\t{\n\t\tIPACMERR(\"Event data is not populated properly.\\n\");\n\t\treturn;\n\t}\n\tif(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)\n\t{\n\t\tIPACMERR(\"IP type is not expected: %d.\\n\", data->iptype);\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"Del client info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \\n\",\n\t\tdata->p_iface->dev_name, data->iptype,\n\t\tdata->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],\n\t\tdata->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n\n\tclient_info* client_ptr;\n\tuint64_t v6_addr;\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tif(client_info_v4_.count(data->ipv4_addr) == 0)\t//if not found the client, return\n\t\t{\n\t\t\tIPACMERR(\"The client is not found the client, return.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"The client is found.\\n\");\n\t\tclient_info& client = client_info_v4_[data->ipv4_addr];\n\t\tclient_ptr = &client;\n\t}\n\telse\n\t{\n\t\tmemcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));\n\t\tif(client_info_v6_.count(v6_addr) == 0)\t//if not found the client, insert it in table\n\t\t{\n\t\t\tIPACMERR(\"The client is not found the client, return.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"The client is found.\\n\");\n\t\tclient_info& client = client_info_v6_[v6_addr];\n\t\tclient_ptr = &client;\n\t}\n\n\tturnoff_offload_links(data->iptype, client_ptr);\n\tclear_peer_list(client_ptr);\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tclient_info_v4_.erase(data->ipv4_addr);\n\t}\n\telse\n\t{\n\t\tclient_info_v6_.erase(v6_addr);\n\t}\n\treturn;\n}\n\nint IPACM_LanToLan::clear_peer_list(client_info* client)\n{\n\tif(client == NULL)\n\t{\n\t\tIPACMERR(\"Client is NULL.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tbool err_flag;\n\tpeer_info_list::iterator client_it;\n\tpeer_info_list::iterator peer_it;\n\tclient_info* peer;\n\n\tfor(client_it = client->peer.begin(); client_it != client->peer.end(); client_it++)\n\t{\n\t\terr_flag = true;\n\t\tpeer = client_it->peer_pointer;\n\t\tfor(peer_it = peer->peer.begin(); peer_it != peer->peer.end(); peer_it++)\n\t\t{\n\t\t\tif(peer_it->peer_pointer == client)\n\t\t\t{\n\t\t\t\tpeer->peer.erase(peer_it);\n\t\t\t\terr_flag = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(err_flag == true)\n\t\t{\n\t\t\tIPACMERR(\"Failed to find peer info.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\tclient->peer.clear();\n\treturn IPACM_SUCCESS;\n}\n\nvoid IPACM_LanToLan::handle_client_power_save(ipacm_event_lan_client* data)\n{\n\tif(data == NULL)\n\t{\n\t\tIPACMERR(\"No client info is found.\\n\");\n\t\treturn;\n\t}\n\tif(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)\n\t{\n\t\tIPACMERR(\"Event data is not populated properly.\\n\");\n\t\treturn;\n\t}\n\tif(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)\n\t{\n\t\tIPACMERR(\"IP type is not expected: %d.\\n\", data->iptype);\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"Client power save info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \\n\",\n\t\tdata->p_iface->dev_name, data->iptype,\n\t\tdata->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],\n\t\tdata->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n\n\tclient_info* client_ptr;\n\tuint64_t v6_addr;\n\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tif(client_info_v4_.count(data->ipv4_addr) == 0)//if not found the client, return\n\t\t{\n\t\t\tIPACMERR(\"The client is not found the client, return.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"The client is found.\\n\");\n\t\tclient_info& client = client_info_v4_[data->ipv4_addr];\n\t\tclient_ptr = &client;\n\t}\n\telse\n\t{\n\t\tmemcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));\n\t\tif(client_info_v6_.count(v6_addr) == 0)\t//if not found the client, insert it in table\n\t\t{\n\t\t\tIPACMERR(\"The client is not found the client, return.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"The client is found.\\n\");\n\t\tclient_info& client = client_info_v6_[v6_addr];\n\t\tclient_ptr = &client;\n\t}\n\n\tif(remove_flt_rules(data->iptype, client_ptr) == IPACM_FAILURE)\n\t{\n\t\tIPACMERR(\"Failed to remove flt rules when power save.\\n\");\n\t\treturn;\n\t}\n\tclient_ptr->is_active = false;\n\tclient_ptr->is_powersave = true;\n\treturn;\n}\n\nvoid IPACM_LanToLan::handle_new_lan2lan_connection(ipacm_event_connection* data)\n{\n\tIPACMDBG_H(\"New lan2lan connection info: IP type: %d, src_v4_addr: 0x%08x, dst_v4_addr: 0x%08x\\n\", data->iptype, data->src_ipv4_addr, data->dst_ipv4_addr);\n\tIPACMDBG_H(\"src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\", data->src_ipv6_addr[0], data->src_ipv6_addr[1], data->src_ipv6_addr[2],\n\t\t\t\tdata->src_ipv6_addr[3], data->dst_ipv6_addr[0], data->dst_ipv6_addr[1], data->dst_ipv6_addr[2], data->dst_ipv6_addr[3]);\n\n\tclient_info* src_client_ptr;\n\tclient_info* dst_client_ptr;\n\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tif(client_info_v4_.count(data->src_ipv4_addr) == 0 || client_info_v4_.count(data->dst_ipv4_addr) == 0)\n\t\t{\n\t\t\tIPACMERR(\"Either source or destination is not in table.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tclient_info& src_client = client_info_v4_[data->src_ipv4_addr];\n\t\tsrc_client_ptr = &src_client;\n\t\tclient_info& dst_client = client_info_v4_[data->dst_ipv4_addr];\n\t\tdst_client_ptr = &dst_client;\n\t}\n\telse //ipv6 case\n\t{\n\t\tuint64_t src_ipv6_addr;\n\t\tuint64_t dst_ipv6_addr;\n\t\tmemcpy(&src_ipv6_addr, &(data->src_ipv6_addr[2]), sizeof(uint64_t));\n\t\tmemcpy(&dst_ipv6_addr, &(data->dst_ipv6_addr[2]), sizeof(uint64_t));\n\n\t\tif(client_info_v6_.count(src_ipv6_addr) == 0 || client_info_v6_.count(dst_ipv6_addr) == 0)\n\t\t{\n\t\t\tIPACMERR(\"Either source or destination is not in table.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tclient_info& src_client = client_info_v6_[src_ipv6_addr];\n\t\tsrc_client_ptr = &src_client;\n\t\tclient_info& dst_client = client_info_v6_[dst_ipv6_addr];\n\t\tdst_client_ptr = &dst_client;\n\t}\n\n\tIPACMDBG_H(\"Both src and dst are already in table.\\n\");\n\tbool is_first_connection;\n\tis_first_connection = add_connection(src_client_ptr, dst_client_ptr);\n\n\tif(is_first_connection && src_client_ptr->is_active && dst_client_ptr->is_active)\n\t{\n\t\tIPACMDBG_H(\"This is first connection, add offload links.\\n\");\n\n\t\tif(add_offload_link(data->iptype, src_client_ptr, dst_client_ptr) == IPACM_FAILURE)\n\t\t{\n\t\t\tIPACMERR(\"Failed to add offload link for src->dst direction.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif(add_offload_link(data->iptype, dst_client_ptr, src_client_ptr) == IPACM_FAILURE)\n\t\t{\n\t\t\tIPACMERR(\"Failed to add offload link for dst->src direction.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tif(data->iptype == IPA_IP_v4)\n\t\t{\n\t\t\tnum_offload_pair_v4_ ++;\n\t\t\tIPACMDBG_H(\"Added offload links, now num_offload_pair_v4_: %d\\n\", num_offload_pair_v4_);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tnum_offload_pair_v6_ ++;\n\t\t\tIPACMDBG_H(\"Added offload links, now num_offload_pair_v6_: %d\\n\", num_offload_pair_v6_);\n\t\t}\n\t}\n\treturn;\n}\n\n//If need to insert an entry in peer list, return true, otherwise return false\nbool IPACM_LanToLan::add_connection(client_info* src_client, client_info* dst_client)\n{\n\tif(src_client == NULL || dst_client == NULL)\n\t{\n\t\tIPACMERR(\"Either source or dest client is NULL.\\n\");\n\t\treturn false;\n\t}\n\n\tpeer_info_list::iterator it;\n\tpeer_info new_peer;\n\tbool ret = false;\n\n\tfor(it = src_client->peer.begin(); it != src_client->peer.end(); it++)\n\t{\n\t\tif(it->peer_pointer == dst_client)\n\t\t{\n\t\t\tit->num_connection++;\n\t\t\tIPACMDBG_H(\"Find dst client entry in peer list, connection count: %d\\n\", it->num_connection);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(it == src_client->peer.end())\n\t{\n\t\tIPACMDBG_H(\"Not finding dst client entry, insert a new one in peer list.\\n\");\n\t\tnew_peer.peer_pointer = dst_client;\n\t\tnew_peer.num_connection = 1;\n\t\tsrc_client->peer.push_back(new_peer);\n\t\tret = true;\n\t}\n\n\tfor(it = dst_client->peer.begin(); it != dst_client->peer.end(); it++)\n\t{\n\t\tif(it->peer_pointer == src_client)\n\t\t{\n\t\t\tit->num_connection++;\n\t\t\tIPACMDBG_H(\"Find dst client entry in peer list, connection count: %d\\n\", it->num_connection);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(it == dst_client->peer.end())\n\t{\n\t\tIPACMDBG_H(\"Not finding src client entry, insert a new one in peer list.\\n\");\n\t\tnew_peer.peer_pointer = src_client;\n\t\tnew_peer.num_connection = 1;\n\t\tdst_client->peer.push_back(new_peer);\n\t\tret = true;\n\t}\n\treturn ret;\n}\n\nvoid IPACM_LanToLan::handle_del_lan2lan_connection(ipacm_event_connection* data)\n{\n\tIPACMDBG_H(\"Del lan2lan connection info: IP type: %d, src_v4_addr: 0x%08x, dst_v4_addr: 0x%08x\\n\", data->iptype, data->src_ipv4_addr, data->dst_ipv4_addr);\n\tIPACMDBG_H(\"src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\", data->src_ipv6_addr[0], data->src_ipv6_addr[1], data->src_ipv6_addr[2],\n\t\t\t\tdata->src_ipv6_addr[3], data->dst_ipv6_addr[0], data->dst_ipv6_addr[1], data->dst_ipv6_addr[2], data->dst_ipv6_addr[3]);\n\n\tbool res;\n\tuint64_t src_ipv6_addr, dst_ipv6_addr;\n\tclient_info* src_client_ptr;\n\tclient_info* dst_client_ptr;\n\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tif(client_info_v4_.count(data->src_ipv4_addr) == 0\n\t\t\t|| client_info_v4_.count(data->dst_ipv4_addr) == 0)\t//if not found the client\n\t\t{\n\t\t\tIPACMDBG_H(\"Not found either source or dest client, return.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tclient_info& src_client = client_info_v4_[data->src_ipv4_addr];\n\t\tclient_info& dst_client = client_info_v4_[data->dst_ipv4_addr];\n\t\tsrc_client_ptr = &src_client;\n\t\tdst_client_ptr = &dst_client;\n\t}\n\telse\n\t{\n\t\tmemcpy(&src_ipv6_addr, &(data->src_ipv6_addr[2]), sizeof(uint64_t));\n\t\tmemcpy(&dst_ipv6_addr, &(data->dst_ipv6_addr[2]), sizeof(uint64_t));\n\t\tif(client_info_v6_.count(src_ipv6_addr) == 0\n\t\t\t|| client_info_v6_.count(dst_ipv6_addr) == 0)//if not found the client\n\t\t{\n\t\t\tIPACMDBG_H(\"Not found either source or dest client, return.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tclient_info& src_client = client_info_v6_[src_ipv6_addr];\n\t\tclient_info& dst_client = client_info_v6_[dst_ipv6_addr];\n\t\tsrc_client_ptr = &src_client;\n\t\tdst_client_ptr = &dst_client;\n\t}\n\n\tres = remove_connection(src_client_ptr, dst_client_ptr);\n\n\tif(res && src_client_ptr->is_active && dst_client_ptr->is_active)\n\t{\n\t\tIPACMDBG_H(\"Erase link info for both src and dst entries.\\n\");\n\t\terase_offload_link(data->iptype, src_client_ptr, dst_client_ptr);\n\t}\n\telse\n\t{\n\t\tif(res && src_client_ptr->is_powersave && (dst_client_ptr->is_active || dst_client_ptr->is_powersave))\n\t\t{\n\t\t\tIPACMDBG_H(\"Erase link info for both src and dst entries due to src powersave.\\n\");\n\t\t\terase_offload_link(data->iptype, src_client_ptr, dst_client_ptr);\n\t\t}\n\t\tif(res && dst_client_ptr->is_powersave && (src_client_ptr->is_active || src_client_ptr->is_powersave))\n\t\t{\n\t\t\tIPACMDBG_H(\"Erase link info for both src and dst entries due to dst powersave.\\n\");\n\t\t\terase_offload_link(data->iptype, dst_client_ptr, src_client_ptr);\n\t\t}\n\t}\n\n\t//if the src client is not active and not powersave mode, if peer list is empty, remove client entry\n\tif(res && src_client_ptr->is_active == false && src_client_ptr->is_powersave == false && src_client_ptr->peer.size() == 0)\n\t{\n\t\tIPACMDBG_H(\"Peer list of src is empty, remove src entry.\\n\");\n\t\tif(data->iptype == IPA_IP_v4)\n\t\t{\n\t\t\tclient_info_v4_.erase(data->src_ipv4_addr);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tclient_info_v6_.erase(src_ipv6_addr);\n\t\t}\n\t}\n\n\t//if the dst client is not active and not powersave mode, if peer list is empty, remove client entry\n\tif(res && dst_client_ptr->is_active == false && dst_client_ptr->is_powersave == false && dst_client_ptr->peer.size() == 0)\n\t{\n\t\tIPACMDBG_H(\"Peer list of dst is empty, remove dst entry.\\n\");\n\t\tif(data->iptype == IPA_IP_v4)\n\t\t{\n\t\t\tclient_info_v4_.erase(data->dst_ipv4_addr);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tclient_info_v6_.erase(dst_ipv6_addr);\n\t\t}\n\t}\n\treturn;\n}\n\n//If need to remove an entry in peer list, return true, otherwise return false\nbool IPACM_LanToLan::remove_connection(client_info* src_client, client_info* dst_client)\n{\n\tif(src_client == NULL || dst_client == NULL)\n\t{\n\t\tIPACMERR(\"Either source or dest client is NULL.\\n\");\n\t\treturn false;\n\t}\n\n\tpeer_info_list::iterator it;\n\tbool ret = false;\n\n\tfor(it = src_client->peer.begin(); it != src_client->peer.end(); it++)\n\t{\n\t\tif(it->peer_pointer == dst_client)\n\t\t{\n\t\t\tit->num_connection--;\n\t\t\tIPACMDBG_H(\"Find dst client entry in src peer list, connection count: %d\\n\", it->num_connection);\n\t\t\tif(it->num_connection == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Need to remove dst entry in src peer list.\\n\");\n\t\t\t\tret = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(ret == true)\n\t{\n\t\tsrc_client->peer.erase(it);\n\t}\n\n\tret = false;\n\tfor(it = dst_client->peer.begin(); it != dst_client->peer.end(); it++)\n\t{\n\t\tif(it->peer_pointer == src_client)\n\t\t{\n\t\t\tit->num_connection--;\n\t\t\tIPACMDBG_H(\"Find src client entry in dst peer list, connection count: %d\\n\", it->num_connection);\n\t\t\tif(it->num_connection == 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Need to remove src entry in dst peer list.\\n\");\n\t\t\t\tret = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(ret == true)\n\t{\n\t\tdst_client->peer.erase(it);\n\t}\n\treturn ret;\n}\n\nvoid IPACM_LanToLan::erase_offload_link(ipa_ip_type iptype, client_info* src_client, client_info* dst_client)\n{\n\tif(src_client == NULL || dst_client == NULL)\n\t{\n\t\tIPACMERR(\"Either source or dest client is NULL.\\n\");\n\t\treturn;\n\t}\n\n\toffload_link_info_list::iterator it;\n\tint res_src = IPACM_FAILURE, res_dst = IPACM_FAILURE;\n\n\tfor(it = src_client->link.begin(); it != src_client->link.end(); it++)\n\t{\n\t\tif(it->peer_pointer == dst_client)\n\t\t{\n\t\t\tres_src = IPACM_SUCCESS;\n\t\t\tIPACMDBG_H(\"Find dst client entry in src link list\\n\");\n\t\t\tres_src = del_offload_link(iptype, src_client->p_iface, dst_client->p_iface, &(*it));\n\t\t\tsrc_client->link.erase(it);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor(it = dst_client->link.begin(); it != dst_client->link.end(); it++)\n\t{\n\t\tif(it->peer_pointer == src_client)\n\t\t{\n\t\t\tres_dst = IPACM_SUCCESS;\n\t\t\tIPACMDBG_H(\"Find src client entry in dst link list\\n\");\n\t\t\tres_dst = del_offload_link(iptype, dst_client->p_iface, src_client->p_iface, &(*it));\n\t\t\tdst_client->link.erase(it);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(res_src == IPACM_SUCCESS && res_dst == IPACM_SUCCESS)\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tnum_offload_pair_v4_ --;\n\t\t\tIPACMDBG_H(\"Decrease num of v4 offload pairs to %d\\n\", num_offload_pair_v4_);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tnum_offload_pair_v6_ --;\n\t\t\tIPACMDBG_H(\"Decrease num of v6 offload pairs to %d\\n\", num_offload_pair_v6_);\n\t\t}\n\t}\n\treturn;\n}\n\nvoid IPACM_LanToLan::generate_new_connection(ipa_ip_type iptype, client_info* client)\n{\n#ifndef CT_OPT\n\tif(client == NULL)\n\t{\n\t\tIPACMERR(\"Client is NULL.\\n\");\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"Generate new connection events for IP type %d\\n\", iptype);\n\n\tint num = 0;\n\tipacm_cmd_q_data evt;\n\tipacm_event_connection* new_conn;\n\tipacm_iface_type client_type, peer_type;\n\tclient_type = IPACM_Iface::ipacmcfg->iface_table[client->p_iface->ipa_if_num].if_cat;\n\n\tIPACMDBG_H(\"Client's iface type is %d.\\n\", client_type);\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tclient_table_v4::iterator it;\n\t\tfor(it = client_info_v4_.begin(); it != client_info_v4_.end(); it++)\n\t\t{\n\t\t\tpeer_type = IPACM_Iface::ipacmcfg->iface_table[it->second.p_iface->ipa_if_num].if_cat;\n\t\t\tif(peer_type != client_type && it->second.is_active == true)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Find a qualified peer to generate new_conn event.\\n\");\n\t\t\t\tIPACMDBG_H(\"Peer's iface type is %d.\\n\", peer_type);\n\t\t\t\tnew_conn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));\n\t\t\t\tif(new_conn == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to allocate memory for new_connection event.\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tmemset(new_conn, 0, sizeof(ipacm_event_connection));\n\t\t\t\tnew_conn->iptype = IPA_IP_v4;\n\t\t\t\tnew_conn->src_ipv4_addr = client->ip.ipv4_addr;\n\t\t\t\tnew_conn->dst_ipv4_addr = it->second.ip.ipv4_addr;\n\n\t\t\t\tmemset(&evt, 0, sizeof(evt));\n\t\t\t\tevt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;\n\t\t\t\tevt.evt_data = (void*)new_conn;\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt);\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tclient_table_v6::iterator it;\n\t\tfor(it = client_info_v6_.begin(); it != client_info_v6_.end(); it++)\n\t\t{\n\t\t\tpeer_type = IPACM_Iface::ipacmcfg->iface_table[it->second.p_iface->ipa_if_num].if_cat;\n\t\t\tif(peer_type != client_type && it->second.is_active == true)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Find a qualified peer to generate new_conn event.\\n\");\n\t\t\t\tIPACMDBG_H(\"Peer's iface type is %d.\\n\", peer_type);\n\t\t\t\tnew_conn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));\n\t\t\t\tif(new_conn == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to allocate memory for new_connection event.\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tmemset(new_conn, 0, sizeof(ipacm_event_connection));\n\t\t\t\tnew_conn->iptype = IPA_IP_v6;\n\t\t\t\tmemcpy(new_conn->src_ipv6_addr, client->ip.ipv6_addr, sizeof(new_conn->src_ipv6_addr));\n\t\t\t\tmemcpy(new_conn->dst_ipv6_addr, it->second.ip.ipv6_addr, sizeof(new_conn->dst_ipv6_addr));\n\n\t\t\t\tmemset(&evt, 0, sizeof(evt));\n\t\t\t\tevt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;\n\t\t\t\tevt.evt_data = (void*)new_conn;\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt);\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t}\n\tIPACMDBG_H(\"Generate %d new connection events in total.\\n\", num);\n#endif\n\treturn;\n}\n\nvoid IPACM_LanToLan::handle_client_power_recover(ipacm_event_lan_client* data)\n{\n\tif(data == NULL)\n\t{\n\t\tIPACMERR(\"No client info is found.\\n\");\n\t\treturn;\n\t}\n\tif(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)\n\t{\n\t\tIPACMERR(\"Event data is not populated properly.\\n\");\n\t\treturn;\n\t}\n\tif(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)\n\t{\n\t\tIPACMERR(\"IP type is not expected: %d\\n\", data->iptype);\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"New client info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \\n\",\n\t\tdata->p_iface->dev_name, data->iptype,\n\t\tdata->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],\n\t\tdata->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n\n\tclient_info* client_ptr;\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tif(client_info_v4_.count(data->ipv4_addr) == 0)\n\t\t{\n\t\t\tIPACMERR(\"Client is not found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tclient_info& client = client_info_v4_[data->ipv4_addr];\n\t\tclient_ptr = &client;\n\t}\n\telse\n\t{\n\t\tuint64_t v6_addr;\n\t\tmemcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));\n\t\tif(client_info_v6_.count(v6_addr) == 0)\n\t\t{\n\t\t\tIPACMERR(\"Client is not found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tclient_info& client = client_info_v6_[v6_addr];\n\t\tclient_ptr = &client;\n\t}\n\n\tif(client_ptr->is_active == true || client_ptr->is_powersave != true)\t//the client is in wrong state\n\t{\n\t\tIPACMERR(\"The client is in wrong state: active %d, powersave %d.\\n\", client_ptr->is_active, client_ptr->is_powersave);\n\t\treturn;\n\t}\n\telse\n\t{\n\t\tif(add_flt_rules(data->iptype, client_ptr) == IPACM_FAILURE)\n\t\t{\n\t\t\tIPACMERR(\"Failed to add back flt rules when power recovery.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tclient_ptr->is_active =  true;\n\t\tclient_ptr->is_powersave = false;\n\n\t\tcheck_potential_link(data->iptype, client_ptr);\n\t\tgenerate_new_connection(data->iptype, client_ptr);\n\t}\n\tIPACMDBG_H(\"There are %d clients in v4 table and %d clients in v6 table.\\n\", client_info_v4_.size(), client_info_v6_.size());\n\treturn;\n}\n\n//This function is called when power save: remove filtering rules only\nint IPACM_LanToLan::remove_flt_rules(ipa_ip_type iptype, client_info* client)\n{\n\tif(client == NULL)\n\t{\n\t\tIPACMERR(\"No client info is found.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tbool err_flag;\n\toffload_link_info_list::iterator client_it;\n\toffload_link_info_list::iterator peer_it;\n\tclient_info* peer;\n\n\tfor(client_it = client->link.begin(); client_it != client->link.end(); client_it++)\n\t{\n\t\tif(client->p_iface->del_lan2lan_flt_rule(iptype, client_it->flt_rule_hdl) == IPACM_FAILURE)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete client's filtering rule.\\n\");\n\t\t}\n\n\t\terr_flag = true;\n\t\tpeer = client_it->peer_pointer;\n\t\tfor(peer_it = peer->link.begin(); peer_it != peer->link.end(); peer_it++)\n\t\t{\n\t\t\tif(peer_it->peer_pointer == client)\n\t\t\t{\n\t\t\t\tif(peer->p_iface->del_lan2lan_flt_rule(iptype, peer_it->flt_rule_hdl) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to delete peer's offload link.\\n\");\n\t\t\t\t}\n\t\t\t\terr_flag = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(err_flag)\n\t\t{\n\t\t\tIPACMERR(\"Unable to find corresponding offload link in peer's entry.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_LanToLan::add_flt_rules(ipa_ip_type iptype, client_info* client)\n{\n\tif(client == NULL)\n\t{\n\t\tIPACMERR(\"No client info is found.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tbool err_flag;\n\toffload_link_info_list::iterator client_it;\n\toffload_link_info_list::iterator peer_it;\n\tclient_info* peer;\n\n\tfor(client_it = client->link.begin(); client_it != client->link.end(); client_it++)\n\t{\n\t\tpeer = client_it->peer_pointer;\n\t\tif(client->p_iface->add_lan2lan_flt_rule(iptype, client->ip.ipv4_addr, peer->ip.ipv4_addr,\n\t\t\tclient->ip.ipv6_addr, peer->ip.ipv6_addr, &(client_it->flt_rule_hdl)) == IPACM_FAILURE)\n\t\t{\n\t\t\tIPACMERR(\"Failed to add client's filtering rule.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\terr_flag = true;\n\t\tfor(peer_it = peer->link.begin(); peer_it != peer->link.end(); peer_it++)\n\t\t{\n\t\t\tif(peer_it->peer_pointer == client)\n\t\t\t{\n\t\t\t\tif(peer->p_iface->add_lan2lan_flt_rule(iptype, peer->ip.ipv4_addr, client->ip.ipv4_addr,\n\t\t\t\t\tpeer->ip.ipv6_addr, client->ip.ipv6_addr, &(peer_it->flt_rule_hdl)) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to delete peer's offload link.\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\terr_flag = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(err_flag)\n\t\t{\n\t\t\tIPACMERR(\"Unable to find corresponding offload link in peer's entry.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nvoid IPACM_LanToLan::handle_new_connection(ipacm_event_connection* new_conn)\n{\n#ifdef CT_OPT\n\tif(new_conn == NULL)\n\t{\n\t\tIPACMERR(\"No connection info is found.\\n\");\n\t\treturn;\n\t}\n\tif(new_conn->iptype != IPA_IP_v4 && new_conn->iptype != IPA_IP_v6)\n\t{\n\t\tIPACMERR(\"IP type is not expected: %d.\\n\", new_conn->iptype);\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"New connection info: IP type: %d, src_v4_addr: 0x%08x, dst_v4_addr: 0x%08x\\n\", new_conn->iptype, new_conn->src_ipv4_addr, new_conn->dst_ipv4_addr);\n\tIPACMDBG_H(\"src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\", new_conn->src_ipv6_addr[0], new_conn->src_ipv6_addr[1], new_conn->src_ipv6_addr[2],\n\t\t\t\tnew_conn->src_ipv6_addr[3], new_conn->dst_ipv6_addr[0], new_conn->dst_ipv6_addr[1], new_conn->dst_ipv6_addr[2], new_conn->dst_ipv6_addr[3]);\n\n\tif(is_lan2lan_connection(new_conn) == false)\n\t{\n\t\tIPACMDBG_H(\"The connection is not lan2lan connection.\\n\");\n\t\tcache_new_connection(new_conn);\n\t\treturn;\n\t}\n\n\tipacm_cmd_q_data evt;\n\tipacm_event_connection* conn;\n\n\tconn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));\n\tif(conn == NULL)\n\t{\n\t\tIPACMERR(\"Failed to allocate memory for new_connection event.\\n\");\n\t\treturn;\n\t}\n\tmemcpy(conn, new_conn, sizeof(ipacm_event_connection));\n\n\tmemset(&evt, 0, sizeof(evt));\n\tevt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;\n\tevt.evt_data = (void*)conn;\n\tIPACM_EvtDispatcher::PostEvt(&evt);\n#endif\n\treturn;\n}\n\nvoid IPACM_LanToLan::handle_del_connection(ipacm_event_connection* new_conn)\n{\n#ifdef CT_OPT\n\tif(new_conn == NULL)\n\t{\n\t\tIPACMERR(\"No connection info is found.\\n\");\n\t\treturn;\n\t}\n\tif(new_conn->iptype != IPA_IP_v4 && new_conn->iptype != IPA_IP_v6)\n\t{\n\t\tIPACMERR(\"IP type is not expected: %d.\\n\", new_conn->iptype);\n\t\treturn;\n\t}\n\n\tIPACMDBG_H(\"Del connection info: IP type: %d, src_v4_addr: 0x%08x, dst_v4_addr: 0x%08x\\n\", new_conn->iptype, new_conn->src_ipv4_addr, new_conn->dst_ipv4_addr);\n\tIPACMDBG_H(\"src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\", new_conn->src_ipv6_addr[0], new_conn->src_ipv6_addr[1], new_conn->src_ipv6_addr[2],\n\t\t\t\tnew_conn->src_ipv6_addr[3], new_conn->dst_ipv6_addr[0], new_conn->dst_ipv6_addr[1], new_conn->dst_ipv6_addr[2], new_conn->dst_ipv6_addr[3]);\n\n\tif(is_lan2lan_connection(new_conn) == false)\n\t{\n\t\tIPACMDBG_H(\"The connection is not lan2lan connection.\\n\");\n\t\tremove_cache_connection(new_conn);\n\t\treturn;\n\t}\n\n\tipacm_cmd_q_data evt;\n\tipacm_event_connection* conn;\n\n\tconn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));\n\tif(conn == NULL)\n\t{\n\t\tIPACMERR(\"Failed to allocate memory for del_connection event.\\n\");\n\t\treturn;\n\t}\n\tmemcpy(conn, new_conn, sizeof(ipacm_event_connection));\n\n\tmemset(&evt, 0, sizeof(evt));\n\tevt.event = IPA_LAN_TO_LAN_DEL_CONNECTION;\n\tevt.evt_data = (void*)conn;\n\tIPACM_EvtDispatcher::PostEvt(&evt);\n#endif\n\treturn;\n}\n\nbool IPACM_LanToLan::is_lan2lan_connection(ipacm_event_connection* data)\n{\n\tif(data->iptype == IPA_IP_v4)\n\t{\n\t\tif(client_info_v4_.count(data->src_ipv4_addr) == 0 || client_info_v4_.count(data->dst_ipv4_addr) == 0)\n\t\t{\n\t\t\tIPACMDBG(\"Either source or destination is not in client table\\n\");\n\t\t\treturn false;\n\t\t}\n\n\t\tipacm_iface_type src_type, dst_type;\n\t\tsrc_type = IPACM_Iface::ipacmcfg->iface_table[client_info_v4_[data->src_ipv4_addr].p_iface->ipa_if_num].if_cat;\n\t\tdst_type = IPACM_Iface::ipacmcfg->iface_table[client_info_v4_[data->dst_ipv4_addr].p_iface->ipa_if_num].if_cat;\n\n\t\treturn (src_type != dst_type);\n\t}\n\telse\n\t{\n\t\tuint64_t src_v6_addr, dst_v6_addr;\n\t\tmemcpy(&src_v6_addr, &(data->src_ipv6_addr[2]), sizeof(uint64_t));\n\t\tmemcpy(&dst_v6_addr, &(data->dst_ipv6_addr[2]), sizeof(uint64_t));\n\n\t\tif(client_info_v6_.count(src_v6_addr) == 0 || client_info_v6_.count(dst_v6_addr) == 0)\n\t\t{\n\t\t\tIPACMDBG(\"Either source or destination is not in client table\\n\");\n\t\t\treturn false;\n\t\t}\n\n\t\tipacm_iface_type src_type, dst_type;\n\t\tsrc_type = IPACM_Iface::ipacmcfg->iface_table[client_info_v6_[src_v6_addr].p_iface->ipa_if_num].if_cat;\n\t\tdst_type = IPACM_Iface::ipacmcfg->iface_table[client_info_v6_[dst_v6_addr].p_iface->ipa_if_num].if_cat;\n\n\t\treturn (src_type != dst_type);\n\t}\n}\n\nIPACM_LanToLan* IPACM_LanToLan::getLan2LanInstance()\n{\n\treturn p_instance;\n}\n\nbool IPACM_LanToLan::is_potential_lan2lan_connection(ipacm_event_connection* new_conn)\n{\n\tint i, num_private_subnet;\n\tbool src_is_valid = false;\n\tbool dst_is_valid = false;\n\n\tif(new_conn->iptype == IPA_IP_v4)\n\t{\n\t\tnum_private_subnet = IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\t\tfor(i=0; i<num_private_subnet; i++)\n\t\t{\n\t\t\tif( (new_conn->src_ipv4_addr & IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask)\n\t\t\t\t== (IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr & IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask) )\n\t\t\t{\n\t\t\t\tsrc_is_valid = true;\n\t\t\t}\n\t\t\tif( (new_conn->dst_ipv4_addr & IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask)\n\t\t\t\t== (IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr & IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask) )\n\t\t\t{\n\t\t\t\tdst_is_valid = true;\n\t\t\t}\n\t\t}\n\n\t\tif(src_is_valid && dst_is_valid)\n\t\t{\n\t\t\tIPACMDBG(\"Both src and dst are potentially in subnet.\\n\");\n\t\t\treturn true;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif( (new_conn->src_ipv6_addr[0] & ipv6_multicast_mask) != (ipv6_multicast_addr & ipv6_multicast_mask) )\n\t\t{\n\t\t\tsrc_is_valid = true;\n\t\t}\n\t\tif( (new_conn->dst_ipv6_addr[0] & ipv6_multicast_mask) != (ipv6_multicast_addr & ipv6_multicast_mask) )\n\t\t{\n\t\t\tdst_is_valid = true;\n\t\t}\n\n\t\tif(src_is_valid && dst_is_valid)\n\t\t{\n\t\t\tIPACMDBG(\"Both src and dst are potentially in subnet.\\n\");\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tIPACMDBG(\"This connection is not a lan2lan connection potentially.\\n\");\n\treturn false;\n}\n\nvoid IPACM_LanToLan::cache_new_connection(ipacm_event_connection* new_conn)\n{\n\tif(is_potential_lan2lan_connection(new_conn) == true)\n\t{\n\t\tif(new_conn->iptype == IPA_IP_v4)\n\t\t{\n\t\t\tif(connection_v4_.size() == max_cache_connection)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Cached ipv4 connections already reach maximum, clear up the list.\\n\");\n\t\t\t\tconnection_v4_.clear();\n\t\t\t}\n\n\t\t\tconnection_v4_.push_back(*new_conn);\n\t\t\tIPACMDBG_H(\"Cache an ipv4 connection, now the number of ipv4 cache connection is %d.\\n\", connection_v4_.size());\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(connection_v6_.size() == max_cache_connection)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Cached ipv6 connections already reach maximum, clear up the list.\\n\");\n\t\t\t\tconnection_v6_.clear();\n\t\t\t}\n\n\t\t\tconnection_v6_.push_back(*new_conn);\n\t\t\tIPACMDBG_H(\"Cache an ipv6 connection, now the number of ipv6 cache connection is %d.\\n\", connection_v6_.size());\n\t\t}\n\t}\n\treturn;\n}\n\nvoid IPACM_LanToLan::remove_cache_connection(ipacm_event_connection* del_conn)\n{\n\tconnection_list::iterator it;\n\tif(is_potential_lan2lan_connection(del_conn) == true)\n\t{\n\t\tif(del_conn->iptype == IPA_IP_v4)\n\t\t{\n\t\t\tfor(it = connection_v4_.begin(); it != connection_v4_.end(); it++)\n\t\t\t{\n\t\t\t\tif(it->src_ipv4_addr == del_conn->src_ipv4_addr && it->dst_ipv4_addr == del_conn->dst_ipv4_addr)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\"Find the cached ipv4 connection, remove it from list.\\n\");\n\t\t\t\t\tconnection_v4_.erase(it);\n\t\t\t\t\tIPACMDBG_H(\"Now the number of ipv4 cache connection is %d.\\n\", connection_v4_.size());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tIPACMDBG_H(\"Do not find the cached ipv4 connection, do nothing.\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(it = connection_v6_.begin(); it != connection_v6_.end(); it++)\n\t\t\t{\n\t\t\t\tif(memcmp(it->src_ipv6_addr, del_conn->src_ipv6_addr, 4*sizeof(uint32_t)) == 0\n\t\t\t\t\t&& memcmp(it->dst_ipv6_addr, del_conn->dst_ipv6_addr, 4*sizeof(uint32_t)) == 0 )\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\"Find the cached ipv6 connection, remove it from list.\\n\");\n\t\t\t\t\tconnection_v6_.erase(it);\n\t\t\t\t\tIPACMDBG_H(\"Now the number of ipv6 cache connection is %d.\\n\", connection_v6_.size());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tIPACMDBG_H(\"Do not find the cached ipv6 connection, do nothing.\\n\");\n\t\t}\n\t}\n\treturn;\n}\n\nvoid IPACM_LanToLan::check_cache_connection(ipa_ip_type iptype, client_info* client)\n{\n#ifdef CT_OPT\n\tconnection_list::iterator it;\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tit = connection_v4_.begin();\n\t\twhile(it != connection_v4_.end())\n\t\t{\n\t\t\tif( (it->src_ipv4_addr == client->ip.ipv4_addr && client_info_v4_.count(it->dst_ipv4_addr) > 0)\n\t\t\t\t|| (it->dst_ipv4_addr == client->ip.ipv4_addr && client_info_v4_.count(it->src_ipv4_addr) > 0) )\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Found a cache connection for src client 0x%08x and dst client 0x%08x.\\n\", it->src_ipv4_addr, it->dst_ipv4_addr);\n\t\t\t\tipacm_cmd_q_data evt;\n\t\t\t\tipacm_event_connection* conn;\n\n\t\t\t\tconn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));\n\t\t\t\tif(conn == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to allocate memory for new_connection event.\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tmemcpy(conn, &(*it), sizeof(ipacm_event_connection));\n\n\t\t\t\tmemset(&evt, 0, sizeof(evt));\n\t\t\t\tevt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;\n\t\t\t\tevt.evt_data = (void*)conn;\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt);\n\n\t\t\t\tit = connection_v4_.erase(it);\n\t\t\t\tIPACMDBG_H(\"Now the number of cache connections is %d.\\n\", connection_v4_.size());\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tit++;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tuint64_t src_v6_addr, dst_v6_addr;\n\t\tit = connection_v6_.begin();\n\t\twhile(it != connection_v6_.end())\n\t\t{\n\t\t\tmemcpy(&src_v6_addr, &(it->src_ipv6_addr[2]), sizeof(uint64_t));\n\t\t\tmemcpy(&dst_v6_addr, &(it->dst_ipv6_addr[2]), sizeof(uint64_t));\n\t\t\tif( (memcmp(it->src_ipv6_addr, client->ip.ipv6_addr, 4*sizeof(uint32_t)) == 0 && client_info_v6_.count(dst_v6_addr) > 0)\n\t\t\t\t|| (memcmp(it->dst_ipv6_addr, client->ip.ipv6_addr, 4*sizeof(uint32_t)) == 0 && client_info_v6_.count(src_v6_addr) > 0) )\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Found a cache connection with src client 0x%08x%08x%08x%08x and dst client 0x%08x%08x%08x%08x.\\n\", it->src_ipv6_addr[0],\n\t\t\t\t\t\t\tit->src_ipv6_addr[1], it->src_ipv6_addr[2], it->src_ipv6_addr[3], it->dst_ipv6_addr[0], it->dst_ipv6_addr[1],\n\t\t\t\t\t\t\tit->dst_ipv6_addr[2], it->dst_ipv6_addr[3]);\n\t\t\t\tipacm_cmd_q_data evt;\n\t\t\t\tipacm_event_connection* conn;\n\n\t\t\t\tconn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));\n\t\t\t\tif(conn == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to allocate memory for new_connection event.\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tmemcpy(conn, &(*it), sizeof(ipacm_event_connection));\n\n\t\t\t\tmemset(&evt, 0, sizeof(evt));\n\t\t\t\tevt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;\n\t\t\t\tevt.evt_data = (void*)conn;\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt);\n\n\t\t\t\tit = connection_v6_.erase(it);\n\t\t\t\tIPACMDBG_H(\"Now the number of cache connections is %d.\\n\", connection_v6_.size());\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tit++;\n\t\t\t}\n\t\t}\n\t}\n#endif\n\treturn;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Log.cpp",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_log.cpp\n\n\t@brief\n\tThis file implements the IPAM log functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#include \"IPACM_Log.h\"\n#include <stdlib.h>\n#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>\n#include <fcntl.h>\n#include <unistd.h>\n#include <asm/types.h>\n#include <linux/if.h>\n#include <sys/un.h>\n#include <errno.h>\n#include <IPACM_Defs.h>\n\nvoid logmessage(int log_level)\n{\n\treturn;\n}\n\n/* start IPACMDIAG socket*/\nint create_socket(unsigned int *sockfd)\n{\n\n  if ((*sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == IPACM_FAILURE)\n  {\n    perror(\"Error creating ipacm_log socket\\n\");\n    return IPACM_FAILURE;\n  }\n\n  if(fcntl(*sockfd, F_SETFD, FD_CLOEXEC) < 0)\n  {\n    perror(\"Couldn't set ipacm_log Close on Exec\\n\");\n  }\n\n  return IPACM_SUCCESS;\n}\n\nvoid ipacm_log_send( void * user_data)\n{\n\tipacm_log_buffer_t ipacm_log_buffer;\n\tint numBytes=0, len;\n\tstruct sockaddr_un ipacmlog_socket;\n\tstatic unsigned int ipacm_log_sockfd = 0;\n\n\tif(ipacm_log_sockfd == 0)\n\t{\n\t\t/* start ipacm_log socket */\n\t\tif(create_socket(&ipacm_log_sockfd) < 0)\n\t\t{\n\t\t\tprintf(\"unable to create ipacm_log socket\\n\");\n\t\t\treturn;\n\t\t}\n\t\tprintf(\"create ipacm_log socket successfully\\n\");\n\t}\n\tipacmlog_socket.sun_family = AF_UNIX;\n\tstrcpy(ipacmlog_socket.sun_path, IPACMLOG_FILE);\n\tlen = strlen(ipacmlog_socket.sun_path) + sizeof(ipacmlog_socket.sun_family);\n\n\tmemcpy(ipacm_log_buffer.user_data, user_data, MAX_BUF_LEN);\n\n\t//printf(\"send : %s\\n\", ipacm_log_buffer.user_data);\n\tif ((numBytes = sendto(ipacm_log_sockfd, (void *)&ipacm_log_buffer, sizeof(ipacm_log_buffer.user_data), 0,\n\t\t\t(struct sockaddr *)&ipacmlog_socket, len)) == -1)\n\t{\n\t\tprintf(\"Send Failed(%d) %s \\n\",errno,strerror(errno));\n\t\treturn;\n\t}\n\treturn;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Main.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Main.cpp\n\n\t@brief\n\tThis file implements the IPAM functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n/******************************************************************************\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIP_MAIN.C\n\n******************************************************************************/\n\n#include <sys/socket.h>\n#include <signal.h>\n#include <fcntl.h>\n#include <pthread.h>\n#include <sys/ioctl.h>\n#include <linux/if.h>\n#include <linux/netlink.h>\n#include <linux/rtnetlink.h>\n#include <fcntl.h>\n#include <sys/inotify.h>\n#include <stdlib.h>\n#include <signal.h>\n#include \"linux/ipa_qmi_service_v01.h\"\n\n#define __stringify_1(x...)\t#x\n#define __stringify(x...)\t__stringify_1(x)\n\n#include \"IPACM_CmdQueue.h\"\n#include \"IPACM_EvtDispatcher.h\"\n#include \"IPACM_Defs.h\"\n#include \"IPACM_Neighbor.h\"\n#include \"IPACM_IfaceManager.h\"\n#include \"IPACM_Log.h\"\n\n#include \"IPACM_ConntrackListener.h\"\n#include \"IPACM_ConntrackClient.h\"\n#include \"IPACM_Netlink.h\"\n\n/* not defined(FEATURE_IPA_ANDROID)*/\n#ifndef FEATURE_IPA_ANDROID\n#include \"IPACM_LanToLan.h\"\n#endif\n\n\nconst char *ipacm_event_name[] = {\n\t__stringify(IPA_CFG_CHANGE_EVENT),                     /* 1 NULL */\n\t__stringify(IPA_LINK_UP_EVENT),                        /* 2 ipacm_event_data_fid */\n\t__stringify(IPA_LINK_DOWN_EVENT),                      /* 3 ipacm_event_data_fid */\n\t__stringify(IPA_ADDR_ADD_EVENT),                       /* 4 ipacm_event_data_addr */\n\t__stringify(IPA_ADDR_DEL_EVENT),                       /* 5 no use */\n\t__stringify(IPA_ROUTE_ADD_EVENT),                      /* 6 ipacm_event_data_addr */\n\t__stringify(IPA_ROUTE_DEL_EVENT),                      /* 7 ipacm_event_data_addr */\n\t__stringify(IPA_FIREWALL_CHANGE_EVENT),                /* 8 NULL */\n\t__stringify(IPA_WLAN_AP_LINK_UP_EVENT),                /* 9 ipacm_event_data_mac */\n\t__stringify(IPA_WLAN_STA_LINK_UP_EVENT),               /* 10 ipacm_event_data_mac */\n\t__stringify(IPA_WLAN_CLIENT_ADD_EVENT),                /* 11 ipacm_event_data_mac */\n\t__stringify(IPA_WLAN_CLIENT_DEL_EVENT),                /* 12 ipacm_event_data_mac */\n\t__stringify(IPA_WLAN_CLIENT_POWER_SAVE_EVENT),         /* 13 ipacm_event_data_mac */\n\t__stringify(IPA_WLAN_CLIENT_RECOVER_EVENT),            /* 14 ipacm_event_data_mac */\n\t__stringify(IPA_NEW_NEIGH_EVENT),                      /* 15 ipacm_event_data_all */\n\t__stringify(IPA_DEL_NEIGH_EVENT),                      /* 16 ipacm_event_data_all */\n\t__stringify(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT),       /* 17 ipacm_event_data_all */\n\t__stringify(IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT),       /* 18 ipacm_event_data_all */\n\t__stringify(IPA_SW_ROUTING_ENABLE),                    /* 19 NULL */\n\t__stringify(IPA_SW_ROUTING_DISABLE),                   /* 20 NULL */\n\t__stringify(IPA_PROCESS_CT_MESSAGE),                   /* 21 ipacm_ct_evt_data */\n\t__stringify(IPA_HANDLE_WAN_UP),                        /* 22 ipacm_event_iface_up  */\n\t__stringify(IPA_HANDLE_WAN_DOWN),                      /* 23 ipacm_event_iface_up  */\n\t__stringify(IPA_HANDLE_WLAN_UP),                       /* 24 ipacm_event_iface_up */\n\t__stringify(IPA_HANDLE_LAN_UP),                        /* 25 ipacm_event_iface_up */\n\t__stringify(IPA_WLAN_CLIENT_ADD_EVENT_EX),             /* 26 ipacm_event_data_wlan_ex */\n\t__stringify(IPA_HANDLE_WAN_UP_V6),\t\t\t\t\t   /* 27 NULL */\n\t__stringify(IPA_HANDLE_WAN_DOWN_V6),\t\t\t\t   /* 28 NULL */\n\t__stringify(IPA_LAN_CLIENT_ACTIVE),\t\t\t\t\t   /* 29 ipacm_event_lan_client*/\n\t__stringify(IPA_LAN_CLIENT_INACTIVE),\t\t\t\t   /* 30 ipacm_event_lan_client*/\n\t__stringify(IPA_LAN_CLIENT_DISCONNECT),\t\t\t\t   /* 31 ipacm_event_lan_client*/\n\t__stringify(IPA_LAN_CLIENT_POWER_SAVE),\t\t\t\t   /* 32 ipacm_event_lan_client*/\n\t__stringify(IPA_LAN_CLIENT_POWER_RECOVER),\t\t\t   /* 33 ipacm_event_lan_client*/\n\t__stringify(IPA_LAN_TO_LAN_NEW_CONNECTION),\t\t\t   /* 34 ipacm_event_connection */\n\t__stringify(IPA_LAN_TO_LAN_DEL_CONNECTION),\t\t\t   /* 35 ipacm_event_connection */\n\t__stringify(IPA_LAN_DELETE_SELF),\t\t               /* 36 ipacm_event_data_fid */\n\t__stringify(IPA_WLAN_LINK_DOWN_EVENT),                 /* 37 ipacm_event_data_mac */\n\t__stringify(IPA_USB_LINK_UP_EVENT),                    /* 38 ipacm_event_data_fid */\n    __stringify(IPA_PROCESS_CT_MESSAGE_V6),\t\t\t       /* 39 ipacm_ct_evt_data */\n\t__stringify(IPA_PRIVATE_SUBNET_CHANGE_EVENT),\t\t   /* 40 ipacm_event_data_fid */\n\t__stringify(IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT),\t\t   /* 41 ipacm_event_data_fid */\n\t__stringify(IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT),\t\t   /* 42 ipacm_event_data_fid */\n};\n\n#define IPA_DRIVER  \"/dev/ipa\"\n\n#define IPACM_FIREWALL_FILE_NAME    \"mobileap_firewall.xml\"\n#define IPACM_CFG_FILE_NAME    \"IPACM_cfg.xml\"\n#ifdef FEATURE_IPA_ANDROID\n#define IPACM_PID_FILE \"/data/misc/ipa/ipacm.pid\"\n#define IPACM_DIR_NAME     \"/data\"\n#else/* defined(FEATURE_IPA_ANDROID) */\n#define IPACM_PID_FILE \"/etc/ipacm.pid\"\n#define IPACM_DIR_NAME     \"/etc\"\n#endif /* defined(NOT FEATURE_IPA_ANDROID)*/\n#define IPACM_NAME \"ipacm\"\n\n#define INOTIFY_EVENT_SIZE  (sizeof(struct inotify_event))\n#define INOTIFY_BUF_LEN     (INOTIFY_EVENT_SIZE + 2*sizeof(IPACM_FIREWALL_FILE_NAME))\n\n#define IPA_DRIVER_WLAN_EVENT_MAX_OF_ATTRIBS  3\n#define IPA_DRIVER_WLAN_EVENT_SIZE  (sizeof(struct ipa_wlan_msg_ex)+ IPA_DRIVER_WLAN_EVENT_MAX_OF_ATTRIBS*sizeof(ipa_wlan_hdr_attrib_val))\n#define IPA_DRIVER_PIPE_STATS_EVENT_SIZE  (sizeof(struct ipa_get_data_stats_resp_msg_v01))\n#define IPA_DRIVER_WLAN_META_MSG    (sizeof(struct ipa_msg_meta))\n#define IPA_DRIVER_WLAN_BUF_LEN     (IPA_DRIVER_PIPE_STATS_EVENT_SIZE + IPA_DRIVER_WLAN_META_MSG)\n\nuint32_t ipacm_event_stats[IPACM_EVENT_MAX];\nbool ipacm_logging = true;\n\nvoid ipa_is_ipacm_running(void);\nint ipa_get_if_index(char *if_name, int *if_index);\n\n/* start netlink socket monitor*/\nvoid* netlink_start(void *param)\n{\n\tipa_nl_sk_fd_set_info_t sk_fdset;\n\tint ret_val = 0;\n\tmemset(&sk_fdset, 0, sizeof(ipa_nl_sk_fd_set_info_t));\n\tIPACMDBG_H(\"netlink starter memset sk_fdset succeeds\\n\");\n\tret_val = ipa_nl_listener_init(NETLINK_ROUTE, (RTMGRP_IPV4_ROUTE | RTMGRP_IPV6_ROUTE | RTMGRP_LINK |\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tRTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR | RTMGRP_NEIGH |\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tRTNLGRP_IPV6_PREFIX),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t &sk_fdset, ipa_nl_recv_msg);\n\n\tif (ret_val != IPACM_SUCCESS)\n\t{\n\t\tIPACMERR(\"Failed to initialize IPA netlink event listener\\n\");\n\t\treturn NULL;\n\t}\n\n\treturn NULL;\n}\n\n/* start firewall-rule monitor*/\nvoid* firewall_monitor(void *param)\n{\n\tint length;\n\tint wd;\n\tchar buffer[INOTIFY_BUF_LEN];\n\tint inotify_fd;\n\tipacm_cmd_q_data evt_data;\n\tuint32_t mask = IN_MODIFY | IN_MOVE;\n\n\tinotify_fd = inotify_init();\n\tif (inotify_fd < 0)\n\t{\n\t\tPERROR(\"inotify_init\");\n\t}\n\n\tIPACMDBG_H(\"Waiting for nofications in dir %s with mask: 0x%x\\n\", IPACM_DIR_NAME, mask);\n\n\twd = inotify_add_watch(inotify_fd,\n\t\t\t\t\t\t\t\t\t\t\t\t IPACM_DIR_NAME,\n\t\t\t\t\t\t\t\t\t\t\t\t mask);\n\n\twhile (1)\n\t{\n\t\tlength = read(inotify_fd, buffer, INOTIFY_BUF_LEN);\n\t\tif (length < 0)\n\t\t{\n\t\t\tIPACMERR(\"inotify read() error return length: %d and mask: 0x%x\\n\", length, mask);\n\t\t\tcontinue;\n\t\t}\n\n\t\tstruct inotify_event* event;\n\t\tevent = (struct inotify_event*)malloc(length);\n\t\tif(event == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Failed to allocate memory.\\n\");\n\t\t\treturn NULL;\n\t\t}\n\t\tmemset(event, 0, length);\n\t\tmemcpy(event, buffer, length);\n\n\t\tif (event->len > 0)\n\t\t{\n\t\t\tif ( (event->mask & IN_MODIFY) || (event->mask & IN_MOVE))\n\t\t\t{\n\t\t\t\tif (event->mask & IN_ISDIR)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"The directory %s was 0x%x\\n\", event->name, event->mask);\n\t\t\t\t}\n\t\t\t\telse if (!strncmp(event->name, IPACM_FIREWALL_FILE_NAME, event->len)) // firewall_rule change\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"File \\\"%s\\\" was 0x%x\\n\", event->name, event->mask);\n\t\t\t\t\tIPACMDBG_H(\"The interested file %s .\\n\", IPACM_FIREWALL_FILE_NAME);\n\n\t\t\t\t\tevt_data.event = IPA_FIREWALL_CHANGE_EVENT;\n\t\t\t\t\tevt_data.evt_data = NULL;\n\n\t\t\t\t\t/* Insert IPA_FIREWALL_CHANGE_EVENT to command queue */\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t}\n\t\t\t\telse if (!strncmp(event->name, IPACM_CFG_FILE_NAME, event->len)) // IPACM_configuration change\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"File \\\"%s\\\" was 0x%x\\n\", event->name, event->mask);\n\t\t\t\t\tIPACMDBG_H(\"The interested file %s .\\n\", IPACM_CFG_FILE_NAME);\n\n\t\t\t\t\tevt_data.event = IPA_CFG_CHANGE_EVENT;\n\t\t\t\t\tevt_data.evt_data = NULL;\n\n\t\t\t\t\t/* Insert IPA_FIREWALL_CHANGE_EVENT to command queue */\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tIPACMDBG_H(\"Received monitoring event %s.\\n\", event->name);\n\t\t}\n\t\tfree(event);\n\t}\n\n\t(void)inotify_rm_watch(inotify_fd, wd);\n\t(void)close(inotify_fd);\n\treturn NULL;\n}\n\n\n/* start IPACM WLAN-driver notifier */\nvoid* ipa_driver_wlan_notifier(void *param)\n{\n\tint length, fd, cnt;\n\tchar buffer[IPA_DRIVER_WLAN_BUF_LEN];\n\tstruct ipa_msg_meta event_hdr;\n\tstruct ipa_ecm_msg event_ecm;\n\tstruct ipa_wan_msg event_wan;\n\tstruct ipa_wlan_msg_ex event_ex_o;\n\tstruct ipa_wlan_msg *event_wlan=NULL;\n\tstruct ipa_wlan_msg_ex *event_ex= NULL;\n\tstruct ipa_get_data_stats_resp_msg_v01 event_data_stats;\n\tstruct ipa_get_apn_data_stats_resp_msg_v01 event_network_stats;\n\n\tipacm_cmd_q_data evt_data;\n\tipacm_event_data_mac *data = NULL;\n    ipacm_event_data_fid *data_fid = NULL;\n\tipacm_event_data_iptype *data_iptype = NULL;\n\tipacm_event_data_wlan_ex *data_ex;\n\tipa_get_data_stats_resp_msg_v01 *data_tethering_stats = NULL;\n\tipa_get_apn_data_stats_resp_msg_v01 *data_network_stats = NULL;\n\n\tfd = open(IPA_DRIVER, O_RDWR);\n\tif (fd == 0)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", IPA_DRIVER);\n\t\treturn NULL;\n\t}\n\n\twhile (1)\n\t{\n\t\tIPACMDBG_H(\"Waiting for nofications from IPA driver \\n\");\n\t\tmemset(buffer, 0, sizeof(buffer));\n\t\tmemset(&evt_data, 0, sizeof(evt_data));\n\t\tdata = NULL;\n\t\tdata_fid = NULL;\n\t\tdata_tethering_stats = NULL;\n\t\tdata_network_stats = NULL;\n\n\t\tlength = read(fd, buffer, IPA_DRIVER_WLAN_BUF_LEN);\n\t\tif (length < 0)\n\t\t{\n\t\t\tPERROR(\"didn't read IPA_driver correctly\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tmemcpy(&event_hdr, buffer,sizeof(struct ipa_msg_meta));\n\t\tIPACMDBG_H(\"Message type: %d\\n\", event_hdr.msg_type);\n\t\tIPACMDBG_H(\"Event header length received: %d\\n\",event_hdr.msg_len);\n\n\t\t/* Insert WLAN_DRIVER_EVENT to command queue */\n\t\tswitch (event_hdr.msg_type)\n\t\t{\n\n\t\tcase SW_ROUTING_ENABLE:\n\t\t\tIPACMDBG_H(\"Received SW_ROUTING_ENABLE\\n\");\n\t\t\tevt_data.event = IPA_SW_ROUTING_ENABLE;\n\t\t\tIPACMDBG_H(\"Not supported anymore\\n\");\n\t\t\tcontinue;\n\n\t\tcase SW_ROUTING_DISABLE:\n\t\t\tIPACMDBG_H(\"Received SW_ROUTING_DISABLE\\n\");\n\t\t\tevt_data.event = IPA_SW_ROUTING_DISABLE;\n\t\t\tIPACMDBG_H(\"Not supported anymore\\n\");\n\t\t\tcontinue;\n\n\t\tcase WLAN_AP_CONNECT:\n\t\t\tevent_wlan = (struct ipa_wlan_msg *) (buffer + sizeof(struct ipa_msg_meta));\n\t\t\tIPACMDBG_H(\"Received WLAN_AP_CONNECT name: %s\\n\",event_wlan->name);\n\t\t\tIPACMDBG_H(\"AP Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],\n\t\t\t\t\t\t\t event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);\n                        data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\tif(data_fid == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event_wlan data_fid\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tipa_get_if_index(event_wlan->name, &(data_fid->if_index));\n\t\t\tevt_data.event = IPA_WLAN_AP_LINK_UP_EVENT;\n\t\t\tevt_data.evt_data = data_fid;\n\t\t\tbreak;\n\n\t\tcase WLAN_AP_DISCONNECT:\n\t\t\tevent_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));\n\t\t\tIPACMDBG_H(\"Received WLAN_AP_DISCONNECT name: %s\\n\",event_wlan->name);\n\t\t\tIPACMDBG_H(\"AP Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],\n\t\t\t\t\t\t\t event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);\n                        data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\tif(data_fid == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event_wlan data_fid\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tipa_get_if_index(event_wlan->name, &(data_fid->if_index));\n\t\t\tevt_data.event = IPA_WLAN_LINK_DOWN_EVENT;\n\t\t\tevt_data.evt_data = data_fid;\n\t\t\tbreak;\n\t\tcase WLAN_STA_CONNECT:\n\t\t\tevent_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));\n\t\t\tIPACMDBG_H(\"Received WLAN_STA_CONNECT name: %s\\n\",event_wlan->name);\n\t\t\tIPACMDBG_H(\"STA Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],\n\t\t\t\t\t\t\t event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);\n\t\t\tdata = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));\n\t\t\tif(data == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event_wlan data_fid\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tmemcpy(data->mac_addr,\n\t\t\t\t event_wlan->mac_addr,\n\t\t\t\t sizeof(event_wlan->mac_addr));\n\t\t\tipa_get_if_index(event_wlan->name, &(data->if_index));\n\t\t\tevt_data.event = IPA_WLAN_STA_LINK_UP_EVENT;\n\t\t\tevt_data.evt_data = data;\n\t\t\tbreak;\n\n\t\tcase WLAN_STA_DISCONNECT:\n\t\t\tevent_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));\n\t\t\tIPACMDBG_H(\"Received WLAN_STA_DISCONNECT name: %s\\n\",event_wlan->name);\n\t\t\tIPACMDBG_H(\"STA Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],\n\t\t\t\t\t\t\t event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);\n                        data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\tif(data_fid == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event_wlan data_fid\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tipa_get_if_index(event_wlan->name, &(data_fid->if_index));\n\t\t\tevt_data.event = IPA_WLAN_LINK_DOWN_EVENT;\n\t\t\tevt_data.evt_data = data_fid;\n\t\t\tbreak;\n\n\t\tcase WLAN_CLIENT_CONNECT:\n\t\t\tevent_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));\n\t\t\tIPACMDBG_H(\"Received WLAN_CLIENT_CONNECT\\n\");\n\t\t\tIPACMDBG_H(\"Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],\n\t\t\t\t\t\t\t event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);\n\t\t        data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));\n\t\t        if (data == NULL)\n\t\t        {\n\t\t    \t        IPACMERR(\"unable to allocate memory for event_wlan data\\n\");\n\t\t    \t        return NULL;\n\t\t        }\n\t\t\tmemcpy(data->mac_addr,\n\t\t\t\t\t\t event_wlan->mac_addr,\n\t\t\t\t\t\t sizeof(event_wlan->mac_addr));\n\t\t\tipa_get_if_index(event_wlan->name, &(data->if_index));\n\t\t        evt_data.event = IPA_WLAN_CLIENT_ADD_EVENT;\n\t\t\tevt_data.evt_data = data;\n\t\t\tbreak;\n\n\t\tcase WLAN_CLIENT_CONNECT_EX:\n\t\t\tIPACMDBG_H(\"Received WLAN_CLIENT_CONNECT_EX\\n\");\n\t\t\tmemcpy(&event_ex_o, buffer + sizeof(struct ipa_msg_meta),sizeof(struct ipa_wlan_msg_ex));\n\t\t\tif(event_ex_o.num_of_attribs > IPA_DRIVER_WLAN_EVENT_MAX_OF_ATTRIBS)\n\t\t\t{\n\t\t\t\tIPACMERR(\"buffer size overflow\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tlength = sizeof(ipa_wlan_msg_ex)+ event_ex_o.num_of_attribs * sizeof(ipa_wlan_hdr_attrib_val);\n\t\t\tIPACMDBG_H(\"num_of_attribs %d, length %d\\n\", event_ex_o.num_of_attribs, length);\n\t\t\tevent_ex = (ipa_wlan_msg_ex *)malloc(length);\n\t\t\tif(event_ex == NULL )\n\t\t\t{\n\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tmemcpy(event_ex, buffer + sizeof(struct ipa_msg_meta), length);\n\t\t\tdata_ex = (ipacm_event_data_wlan_ex *)malloc(sizeof(ipacm_event_data_wlan_ex) + event_ex_o.num_of_attribs * sizeof(ipa_wlan_hdr_attrib_val));\n\t\t    if (data_ex == NULL)\n\t\t    {\n\t\t\t\tIPACMERR(\"unable to allocate memory for event data\\n\");\n\t\t    \treturn NULL;\n\t\t    }\n\t\t\tdata_ex->num_of_attribs = event_ex->num_of_attribs;\n\n\t\t\tmemcpy(data_ex->attribs,\n\t\t\t\t\t\tevent_ex->attribs,\n\t\t\t\t\t\tevent_ex->num_of_attribs * sizeof(ipa_wlan_hdr_attrib_val));\n\t\t\tfor(cnt = 0; cnt < event_ex->num_of_attribs; cnt++)\n\t\t\t{\n\t\t\t\tif(event_ex->attribs[cnt].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t\t event_ex->attribs[cnt].u.mac_addr[0], event_ex->attribs[cnt].u.mac_addr[1], event_ex->attribs[cnt].u.mac_addr[2],\n\t\t\t\t\t\t\t\t event_ex->attribs[cnt].u.mac_addr[3], event_ex->attribs[cnt].u.mac_addr[4], event_ex->attribs[cnt].u.mac_addr[5]);\n\t\t\t\t}\n\t\t\t\telse if(event_ex->attribs[cnt].attrib_type == WLAN_HDR_ATTRIB_STA_ID)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Wlan client id %d\\n\",event_ex->attribs[cnt].u.sta_id);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Wlan message has unexpected type!\\n\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tipa_get_if_index(event_ex->name, &(data_ex->if_index));\n\t\t    evt_data.event = IPA_WLAN_CLIENT_ADD_EVENT_EX;\n\t\t\tevt_data.evt_data = data_ex;\n\t\t\tfree(event_ex);\n\t\t\tbreak;\n\n\t\tcase WLAN_CLIENT_DISCONNECT:\n\t\t\tIPACMDBG_H(\"Received WLAN_CLIENT_DISCONNECT\\n\");\n\t\t\tevent_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));\n\t\t\tIPACMDBG_H(\"Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],\n\t\t\t\t\t\t\t event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);\n\t\t        data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));\n\t\t        if (data == NULL)\n\t\t        {\n\t\t    \t        IPACMERR(\"unable to allocate memory for event_wlan data\\n\");\n\t\t    \t        return NULL;\n\t\t        }\n\t\t\tmemcpy(data->mac_addr,\n\t\t\t\t\t\t event_wlan->mac_addr,\n\t\t\t\t\t\t sizeof(event_wlan->mac_addr));\n\t\t\tipa_get_if_index(event_wlan->name, &(data->if_index));\n\t\t\tevt_data.event = IPA_WLAN_CLIENT_DEL_EVENT;\n\t\t\tevt_data.evt_data = data;\n\t\t\tbreak;\n\n\t\tcase WLAN_CLIENT_POWER_SAVE_MODE:\n\t\t\tIPACMDBG_H(\"Received WLAN_CLIENT_POWER_SAVE_MODE\\n\");\n\t\t\tevent_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));\n\t\t\tIPACMDBG_H(\"Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],\n\t\t\t\t\t\t\t event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);\n\t\t        data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));\n\t\t        if (data == NULL)\n\t\t        {\n\t\t    \t        IPACMERR(\"unable to allocate memory for event_wlan data\\n\");\n\t\t    \t        return NULL;\n\t\t        }\n\t\t\tmemcpy(data->mac_addr,\n\t\t\t\t\t\t event_wlan->mac_addr,\n\t\t\t\t\t\t sizeof(event_wlan->mac_addr));\n\t\t\tipa_get_if_index(event_wlan->name, &(data->if_index));\n\t\t\tevt_data.event = IPA_WLAN_CLIENT_POWER_SAVE_EVENT;\n\t\t\tevt_data.evt_data = data;\n\t\t\tbreak;\n\n\t\tcase WLAN_CLIENT_NORMAL_MODE:\n\t\t\tIPACMDBG_H(\"Received WLAN_CLIENT_NORMAL_MODE\\n\");\n\t\t\tevent_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));\n\t\t\tIPACMDBG_H(\"Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],\n\t\t\t\t\t\t\t event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);\n\t\t        data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));\n\t\t        if (data == NULL)\n\t\t        {\n\t\t    \t       IPACMERR(\"unable to allocate memory for event_wlan data\\n\");\n\t\t    \t       return NULL;\n\t\t        }\n\t\t\tmemcpy(data->mac_addr,\n\t\t\t\t\t\t event_wlan->mac_addr,\n\t\t\t\t\t\t sizeof(event_wlan->mac_addr));\n\t\t\tipa_get_if_index(event_wlan->name, &(data->if_index));\n\t\t\tevt_data.evt_data = data;\n\t\t\tevt_data.event = IPA_WLAN_CLIENT_RECOVER_EVENT;\n\t\t\tbreak;\n\n\t\tcase ECM_CONNECT:\n\t\t\tmemcpy(&event_ecm, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_ecm_msg));\n\t\t\tIPACMDBG_H(\"Received ECM_CONNECT name: %s\\n\",event_ecm.name);\n            data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\tif(data_fid == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event_ecm data_fid\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdata_fid->if_index = event_ecm.ifindex;\n\t\t\tevt_data.event = IPA_USB_LINK_UP_EVENT;\n\t\t\tevt_data.evt_data = data_fid;\n\t\t\tbreak;\n\n\t\tcase ECM_DISCONNECT:\n\t\t\tmemcpy(&event_ecm, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_ecm_msg));\n\t\t\tIPACMDBG_H(\"Received ECM_DISCONNECT name: %s\\n\",event_ecm.name);\n\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\tif(data_fid == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event_ecm data_fid\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdata_fid->if_index = event_ecm.ifindex;\n\t\t\tevt_data.event = IPA_LINK_DOWN_EVENT;\n\t\t\tevt_data.evt_data = data_fid;\n\t\t\tbreak;\n\t\t/* Add for 8994 Android case */\n\t\tcase WAN_UPSTREAM_ROUTE_ADD:\n\t\t\tmemcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_wan_msg));\n\t\t\tIPACMDBG_H(\"Received WAN_UPSTREAM_ROUTE_ADD name: %s, tethered name: %s\\n\", event_wan.upstream_ifname, event_wan.tethered_ifname);\n            data_iptype = (ipacm_event_data_iptype *)malloc(sizeof(ipacm_event_data_iptype));\n\t\t\tif(data_iptype == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event_ecm data_iptype\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tipa_get_if_index(event_wan.upstream_ifname, &(data_iptype->if_index));\n\t\t\tipa_get_if_index(event_wan.tethered_ifname, &(data_iptype->if_index_tether));\n\t\t\tdata_iptype->iptype = event_wan.ip;\n\t\t\tIPACMDBG_H(\"Received WAN_UPSTREAM_ROUTE_ADD: fid(%d) tether_fid(%d) ip-type(%d)\\n\", data_iptype->if_index,\n\t\t\t\t\tdata_iptype->if_index_tether, data_iptype->iptype);\n\t\t\tevt_data.event = IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT;\n\t\t\tevt_data.evt_data = data_iptype;\n\t\t\tbreak;\n\t\tcase WAN_UPSTREAM_ROUTE_DEL:\n\t\t\tmemcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_wan_msg));\n\t\t\tIPACMDBG_H(\"Received WAN_UPSTREAM_ROUTE_DEL name: %s, tethered name: %s\\n\", event_wan.upstream_ifname, event_wan.tethered_ifname);\n            data_iptype = (ipacm_event_data_iptype *)malloc(sizeof(ipacm_event_data_iptype));\n\t\t\tif(data_iptype == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event_ecm data_iptype\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tipa_get_if_index(event_wan.upstream_ifname, &(data_iptype->if_index));\n\t\t\tipa_get_if_index(event_wan.tethered_ifname, &(data_iptype->if_index_tether));\n\t\t\tdata_iptype->iptype = event_wan.ip;\n\t\t\tIPACMDBG_H(\"Received WAN_UPSTREAM_ROUTE_DEL: fid(%d) ip-type(%d)\\n\", data_iptype->if_index, data_iptype->iptype);\n\t\t\tevt_data.event = IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT;\n\t\t\tevt_data.evt_data = data_iptype;\n\t\t\tbreak;\n\t\t/* End of adding for 8994 Android case */\n\n\t\t/* Add for embms case */\n\t\tcase WAN_EMBMS_CONNECT:\n\t\t\tmemcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_wan_msg));\n\t\t\tIPACMDBG(\"Received WAN_EMBMS_CONNECT name: %s\\n\",event_wan.upstream_ifname);\n\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\tif(data_fid == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event data_fid\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tipa_get_if_index(event_wan.upstream_ifname, &(data_fid->if_index));\n\t\t\tevt_data.event = IPA_WAN_EMBMS_LINK_UP_EVENT;\n\t\t\tevt_data.evt_data = data_fid;\n\t\t\tbreak;\n\n\t\tcase IPA_TETHERING_STATS_UPDATE_STATS:\n\t\t\tmemcpy(&event_data_stats, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_get_data_stats_resp_msg_v01));\n\t\t\tdata_tethering_stats = (ipa_get_data_stats_resp_msg_v01 *)malloc(sizeof(struct ipa_get_data_stats_resp_msg_v01));\n\t\t\tif(data_tethering_stats == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event data_tethering_stats\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tmemcpy(data_tethering_stats,\n\t\t\t\t\t &event_data_stats,\n\t\t\t\t\t\t sizeof(struct ipa_get_data_stats_resp_msg_v01));\n\t\t\tIPACMDBG(\"Received IPA_TETHERING_STATS_UPDATE_STATS ipa_stats_type: %d\\n\",data_tethering_stats->ipa_stats_type);\n\t\t\tIPACMDBG(\"Received %d UL, %d DL pipe stats\\n\",data_tethering_stats->ul_src_pipe_stats_list_len, data_tethering_stats->dl_dst_pipe_stats_list_len);\n\t\t\tevt_data.event = IPA_TETHERING_STATS_UPDATE_EVENT;\n\t\t\tevt_data.evt_data = data_tethering_stats;\n\t\t\tbreak;\n\n\t\tcase IPA_TETHERING_STATS_UPDATE_NETWORK_STATS:\n\t\t\tmemcpy(&event_network_stats, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_get_apn_data_stats_resp_msg_v01));\n\t\t\tdata_network_stats = (ipa_get_apn_data_stats_resp_msg_v01 *)malloc(sizeof(ipa_get_apn_data_stats_resp_msg_v01));\n\t\t\tif(data_network_stats == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"unable to allocate memory for event data_network_stats\\n\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tmemcpy(data_network_stats,\n\t\t\t\t\t &event_network_stats,\n\t\t\t\t\t\t sizeof(struct ipa_get_apn_data_stats_resp_msg_v01));\n\t\t\tIPACMDBG(\"Received %d apn network stats \\n\", data_network_stats->apn_data_stats_list_len);\n\t\t\tevt_data.event = IPA_NETWORK_STATS_UPDATE_EVENT;\n\t\t\tevt_data.evt_data = data_network_stats;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tIPACMDBG_H(\"Unhandled message type: %d\\n\", event_hdr.msg_type);\n\t\t\tcontinue;\n\n\t\t}\n\t\t/* finish command queue */\n\t\tIPACMDBG_H(\"Posting event:%d\\n\", evt_data.event);\n\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t}\n\n\t(void)close(fd);\n\treturn NULL;\n}\n\nvoid IPACM_Sig_Handler(int sig)\n{\n\tint cnt;\n\tipacm_cmd_q_data evt_data;\n\n\tprintf(\"Received Signal: %d\\n\", sig);\n\tmemset(&evt_data, 0, sizeof(evt_data));\n\n\tswitch(sig)\n\t{\n\t\tcase SIGUSR1:\n\t\t\tIPACMDBG_H(\"Received SW_ROUTING_ENABLE request \\n\");\n\t\t\tevt_data.event = IPA_SW_ROUTING_ENABLE;\n\t\t\tIPACM_Iface::ipacmcfg->ipa_sw_rt_enable = true;\n\t\t\tbreak;\n\n\t\tcase SIGUSR2:\n\t\t\tIPACMDBG_H(\"Received SW_ROUTING_DISABLE request \\n\");\n\t\t\tevt_data.event = IPA_SW_ROUTING_DISABLE;\n\t\t\tIPACM_Iface::ipacmcfg->ipa_sw_rt_enable = false;\n\t\t\tbreak;\n\t}\n\t/* finish command queue */\n\tIPACMDBG_H(\"Posting event:%d\\n\", evt_data.event);\n\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\treturn;\n}\n\nvoid RegisterForSignals(void)\n{\n\n\tsignal(SIGUSR1, IPACM_Sig_Handler);\n\tsignal(SIGUSR2, IPACM_Sig_Handler);\n}\n\n\nint main(int argc, char **argv)\n{\n\tint ret;\n\tpthread_t netlink_thread = 0, monitor_thread = 0, ipa_driver_thread = 0;\n\tpthread_t cmd_queue_thread = 0;\n\n\t/* check if ipacm is already running or not */\n\tipa_is_ipacm_running();\n\n\tIPACMDBG_H(\"In main()\\n\");\n\tIPACM_Neighbor *neigh = new IPACM_Neighbor();\n\tIPACM_IfaceManager *ifacemgr = new IPACM_IfaceManager();\n#ifndef FEATURE_ETH_BRIDGE_LE\n#ifndef FEATURE_IPA_ANDROID\n\tIPACM_LanToLan* lan2lan = new IPACM_LanToLan();\n#endif /* defined(FEATURE_IPA_ANDROID)*/\n#endif\n\tIPACM_ConntrackClient *cc = IPACM_ConntrackClient::GetInstance();\n\tCtList = new IPACM_ConntrackListener();\n\n\tIPACMDBG_H(\"Staring IPA main\\n\");\n\tIPACMDBG_H(\"ipa_cmdq_successful\\n\");\n\n\n\tRegisterForSignals();\n\n\tif (IPACM_SUCCESS == cmd_queue_thread)\n\t{\n\t\tret = pthread_create(&cmd_queue_thread, NULL, MessageQueue::Process, NULL);\n\t\tif (IPACM_SUCCESS != ret)\n\t\t{\n\t\t\tIPACMERR(\"unable to command queue thread\\n\");\n\t\t\treturn ret;\n\t\t}\n\t\tIPACMDBG_H(\"created command queue thread\\n\");\n\t}\n\n\tif (IPACM_SUCCESS == netlink_thread)\n\t{\n\t\tret = pthread_create(&netlink_thread, NULL, netlink_start, NULL);\n\t\tif (IPACM_SUCCESS != ret)\n\t\t{\n\t\t\tIPACMERR(\"unable to create netlink thread\\n\");\n\t\t\treturn ret;\n\t\t}\n\t\tIPACMDBG_H(\"created netlink thread\\n\");\n\t}\n\n\n\tif (IPACM_SUCCESS == monitor_thread)\n\t{\n\t\tret = pthread_create(&monitor_thread, NULL, firewall_monitor, NULL);\n\t\tif (IPACM_SUCCESS != ret)\n\t\t{\n\t\t\tIPACMERR(\"unable to create monitor thread\\n\");\n\t\t\treturn ret;\n\t\t}\n\t\tIPACMDBG_H(\"created firewall monitor thread\\n\");\n\t}\n\n\tif (IPACM_SUCCESS == ipa_driver_thread)\n\t{\n\t\tret = pthread_create(&ipa_driver_thread, NULL, ipa_driver_wlan_notifier, NULL);\n\t\tif (IPACM_SUCCESS != ret)\n\t\t{\n\t\t\tIPACMERR(\"unable to create ipa_driver_wlan thread\\n\");\n\t\t\treturn ret;\n\t\t}\n\t\tIPACMDBG_H(\"created ipa_driver_wlan thread\\n\");\n\t}\n\n\tpthread_join(cmd_queue_thread, NULL);\n\tpthread_join(netlink_thread, NULL);\n\tpthread_join(monitor_thread, NULL);\n\tpthread_join(ipa_driver_thread, NULL);\n\treturn IPACM_SUCCESS;\n}\n\n/*===========================================================================\n\t\tFUNCTION  ipa_is_ipacm_running\n===========================================================================*/\n/*!\n@brief\n  Determine whether there's already an IPACM process running, if so, terminate\n  the current one\n\n@return\n\tNone\n\n@note\n\n- Dependencies\n\t\t- None\n\n- Side Effects\n\t\t- None\n*/\n/*=========================================================================*/\n\nvoid ipa_is_ipacm_running(void) {\n\n\tint fd;\n\tstruct flock lock;\n\tint retval;\n\n\tfd = open(IPACM_PID_FILE, O_RDWR | O_CREAT, 0600);\n\tif ( fd <= 0 )\n\t{\n\t\tIPACMERR(\"Failed to open %s, error is %d - %s\\n\",\n\t\t\t\t IPACM_PID_FILE, errno, strerror(errno));\n\t\texit(0);\n\t}\n\n\t/*\n\t * Getting an exclusive Write lock on the file, if it fails,\n\t * it means that another instance of IPACM is running and it\n\t * got the lock before us.\n\t */\n\tmemset(&lock, 0, sizeof(lock));\n\tlock.l_type = F_WRLCK;\n\tretval = fcntl(fd, F_SETLK, &lock);\n\n\tif (retval != 0)\n\t{\n\t\tretval = fcntl(fd, F_GETLK, &lock);\n\t\tif (retval == 0)\n\t\t{\n\t\t\tIPACMERR(\"Unable to get lock on file %s (my PID %d), PID %d already has it\\n\",\n\t\t\t\t\t IPACM_PID_FILE, getpid(), lock.l_pid);\n\t\t\tclose(fd);\n\t\t\texit(0);\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"PID %d is IPACM main process\\n\", getpid());\n\t}\n\n\treturn;\n}\n\n/*===========================================================================\n\t\tFUNCTION  ipa_get_if_index\n===========================================================================*/\n/*!\n@brief\n  get ipa interface index by given the interface name\n\n@return\n\tIPACM_SUCCESS or IPA_FALUIRE\n\n@note\n\n- Dependencies\n\t\t- None\n\n- Side Effects\n\t\t- None\n*/\n/*=========================================================================*/\nint ipa_get_if_index\n(\n\t char *if_name,\n\t int *if_index\n\t )\n{\n\tint fd;\n\tstruct ifreq ifr;\n\n\tif ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)\n\t{\n\t\tPERROR(\"get interface index socket create failed\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tmemset(&ifr, 0, sizeof(struct ifreq));\n\n\t(void)strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));\n\n\tif (ioctl(fd, SIOCGIFINDEX, &ifr) < 0)\n\t{\n\t\tIPACMERR(\"call_ioctl_on_dev: ioctl failed: can't find device %s\",if_name);\n\t\t*if_index = -1;\n\t\tclose(fd);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t*if_index = ifr.ifr_ifindex;\n\tclose(fd);\n\treturn IPACM_SUCCESS;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Neighbor.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Neighbor.cpp\n\n\t@brief\n\tThis file implements the functionality of handling IPACM Neighbor events.\n\n\t@Author\n\tSkylar Chang\n\n*/\n\n#include <sys/ioctl.h>\n#include <IPACM_Neighbor.h>\n#include <IPACM_EvtDispatcher.h>\n#include \"IPACM_Defs.h\"\n#include \"IPACM_Log.h\"\n\n\nIPACM_Neighbor::IPACM_Neighbor()\n{\n\tnum_neighbor_client = 0;\n\tIPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_ADD_EVENT_EX, this);\n\tIPACM_EvtDispatcher::registr(IPA_NEW_NEIGH_EVENT, this);\n\tIPACM_EvtDispatcher::registr(IPA_DEL_NEIGH_EVENT, this);\n\treturn;\n}\n\nvoid IPACM_Neighbor::event_callback(ipa_cm_event_id event, void *param)\n{\n\tipacm_event_data_all *data_all = NULL;\n\tint i, ipa_interface_index;\n\tipacm_cmd_q_data evt_data;\n\tint num_neighbor_client_temp = num_neighbor_client;\n\n\tIPACMDBG(\"Recieved event %d\\n\", event);\n\n\tswitch (event)\n\t{\n\t\tcase IPA_WLAN_CLIENT_ADD_EVENT_EX:\n\t\t{\n\t\t\tipacm_event_data_wlan_ex *data = (ipacm_event_data_wlan_ex *)param;\n\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(data->if_index);\n\t\t\tuint8_t client_mac_addr[6];\n\n\t\t\tIPACMDBG_H(\"Received IPA_WLAN_CLIENT_ADD_EVENT\\n\");\n\t\t\tfor(i = 0; i < data->num_of_attribs; i++)\n\t\t\t{\n\t\t\t\tif(data->attribs[i].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)\n\t\t\t\t{\n\t\t\t\t\tmemcpy(client_mac_addr,\n\t\t\t\t\t\t\tdata->attribs[i].u.mac_addr,\n\t\t\t\t\t\t\tsizeof(client_mac_addr));\n\t\t\t\t\tIPACMDBG_H(\"AP Mac Address %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t\t\t client_mac_addr[0], client_mac_addr[1], client_mac_addr[2],\n\t\t\t\t\t\t\t client_mac_addr[3], client_mac_addr[4], client_mac_addr[5]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"The attribute type is not expected!\\n\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (i = 0; i < num_neighbor_client_temp; i++)\n\t\t\t{\n\t\t\t\t/* find the client */\n\t\t\t\tif (memcmp(neighbor_client[i].mac_addr, client_mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)\n\t\t\t\t{\n\t\t\t\t\t/* check if iface is not bridge interface*/\n\t\t\t\t\tif (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* use previous ipv4 first */\n\t\t\t\t\t\tif(data->if_index != neighbor_client[i].iface_index)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"update new kernel iface index \\n\");\n\t\t\t\t\t\t\tneighbor_client[i].iface_index = data->if_index;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* check if client associated with previous network interface */\n\t\t\t\t\t\tif(ipa_interface_index != neighbor_client[i].ipa_if_num)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"client associate to different AP \\n\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (neighbor_client[i].v4_addr != 0) /* not 0.0.0.0 */\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tevt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;\n\t\t\t\t\t\t\tdata_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));\n\t\t\t\t\t\t\tif (data_all == NULL)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdata_all->iptype = IPA_IP_v4;\n\t\t\t\t\t\t\tdata_all->if_index = neighbor_client[i].iface_index;\n\t\t\t\t\t\t\tdata_all->ipv4_addr = neighbor_client[i].v4_addr; //use previous ipv4 address\n\t\t\t\t\t\t\tmemcpy(data_all->mac_addr,\n\t\t\t\t\t\t\t\t\tneighbor_client[i].mac_addr,\n\t\t\t\t\t\t\t\t\t\t\t\tsizeof(data_all->mac_addr));\n\t\t\t\t\t\t\tevt_data.evt_data = (void *)data_all;\n\t\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t\t\t/* ask for replaced iface name*/\n\t\t\t\t\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);\n\t\t\t\t\t\t\tIPACMDBG_H(\"Posted event %d, with %s for ipv4 client re-connect\\n\",\n\t\t\t\t\t\t\t\t\t\t\tevt_data.event,\n\t\t\t\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\t\tdefault:\n\t\t{\n\t\t\tipacm_event_data_all *data = (ipacm_event_data_all *)param;\n\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(data->if_index);\n\n\t\t\tif (data->iptype == IPA_IP_v4)\n\t\t\t{\n\t\t\t\tif (data->ipv4_addr != 0) /* not 0.0.0.0 */\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\" Got New_Neighbor event with ipv4 address \\n\");\n\t\t\t\t\t/* check if iface is bridge interface*/\n\t\t\t\t\tif (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* searh if seen this client or not*/\n\t\t\t\t\t\tfor (i = 0; i < num_neighbor_client_temp; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdata->if_index = neighbor_client[i].iface_index;\n\t\t\t\t\t\t\t\tneighbor_client[i].v4_addr = data->ipv4_addr; // cache client's previous ipv4 address\n\t\t\t\t\t\t\t\t/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */\n\t\t\t\t\t\t\t\tif (event == IPA_NEW_NEIGH_EVENT)\n\t\t\t\t\t\t\t\t\tevt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tevt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;\n\n\t\t\t\t\t\t\t\tdata_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));\n\t\t\t\t\t\t\t\tif (data_all == NULL)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmemcpy(data_all, data, sizeof(ipacm_event_data_all));\n\t\t\t\t\t\t\t\tevt_data.evt_data = (void *)data_all;\n\t\t\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\n\t\t\t\t\t\t\t\t/* ask for replaced iface name*/\n\t\t\t\t\t\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"Posted event %d, with %s for ipv4\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\tevt_data.event,\n\t\t\t\t\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */\n\t\t\t\t\t\tif (event == IPA_NEW_NEIGH_EVENT)\n\t\t\t\t\t\t\tevt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tevt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;\n\n\t\t\t\t\t\tdata_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));\n\t\t\t\t\t\tif (data_all == NULL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(data_all, data, sizeof(ipacm_event_data_all));\n\t\t\t\t\t\tevt_data.evt_data = (void *)data_all;\n\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t\tIPACMDBG_H(\"Posted event %d with %s for ipv4\\n\",\n\t\t\t\t\t\t\t\t\t\tevt_data.event,\n\t\t\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\t\t/* Also save to cache for ipv4 */\n\t\t\t\t\t\t/*searh if seen this client or not*/\n\t\t\t\t\t\tfor (i = 0; i < num_neighbor_client_temp; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* find the client */\n\t\t\t\t\t\t\tif (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/* update the network interface client associated */\n\t\t\t\t\t\t\t\tneighbor_client[i].iface_index = data->if_index;\n\t\t\t\t\t\t\t\tneighbor_client[i].ipa_if_num = ipa_interface_index;\n\t\t\t\t\t\t\t\tneighbor_client[i].v4_addr = data->ipv4_addr; // cache client's previous ipv4 address\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"update cache %d-entry, with %s iface, ipv4 address: 0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\ti,\n\t\t\t\t\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,\n\t\t\t\t\t\t\t\t\t\t\t\tdata->ipv4_addr);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t/* not find client */\n\t\t\t\t\t\tif (i == num_neighbor_client_temp)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (num_neighbor_client_temp < IPA_MAX_NUM_NEIGHBOR_CLIENTS)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmemcpy(neighbor_client[num_neighbor_client_temp].mac_addr,\n\t\t\t\t\t\t\t\t\t\t\tdata->mac_addr,\n\t\t\t\t\t\t\t\t\t\t\tsizeof(data->mac_addr));\n\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].iface_index = data->if_index;\n\t\t\t\t\t\t\t\t/* cache the network interface client associated */\n\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].ipa_if_num = ipa_interface_index;\n\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].v4_addr = data->ipv4_addr;\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"Cache wlan-iface client MAC %02x:%02x:%02x:%02x:%02x:%02x\\n, total client: %d\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[0],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[1],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[2],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[3],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[4],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[5],\n\t\t\t\t\t\t\t\t\t\t\t\tnum_neighbor_client);\n\t\t\t\t\t\t\t\tnum_neighbor_client++;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tIPACMERR(\"error:  neighbor client oversize!\");\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{   //ipv6 starts\n\n\t\t\t\tif ((data->ipv6_addr[0]) || (data->ipv6_addr[1]) || (data->ipv6_addr[2]) || (data->ipv6_addr[3]))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\" Got New_Neighbor event with ipv6 address \\n\");\n\t\t\t\t\t/* check if iface is bridge interface*/\n\t\t\t\t\tif (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* searh if seen this client or not*/\n\t\t\t\t\t\tfor (i = 0; i < num_neighbor_client_temp; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdata->if_index = neighbor_client[i].iface_index;\n\t\t\t\t\t\t\t\t/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */\n\t\t\t\t\t\t\t\tif (event == IPA_NEW_NEIGH_EVENT) evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;\n\t\t\t\t\t\t\t\telse evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;\n\t\t\t\t\t\t\t\tdata_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));\n\t\t\t\t\t\t\t\tif (data_all == NULL)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmemcpy(data_all, data, sizeof(ipacm_event_data_all));\n\t\t\t\t\t\t\t\tevt_data.evt_data = (void *)data_all;\n\t\t\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t\t\t\t/* ask for replaced iface name*/\n\t\t\t\t\t\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"Posted event %d, with %s for ipv6\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\tevt_data.event,\n\t\t\t\t\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */\n\t\t\t\t\t\tif (event == IPA_NEW_NEIGH_EVENT)\n\t\t\t\t\t\t\tevt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tevt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;\n\t\t\t\t\t\tdata_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));\n\t\t\t\t\t\tif (data_all == NULL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(data_all, data, sizeof(ipacm_event_data_all));\n\t\t\t\t\t\tevt_data.evt_data = (void *)data_all;\n\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t\tIPACMDBG_H(\"Posted event %d with %s for ipv6\\n\",\n\t\t\t\t\t\t\t\t\t\tevt_data.event,\n\t\t\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\" Got New_Neighbor event with no ipv6/ipv4 address \\n\");\n\t\t\t\t\t/*no ipv6 in data searh if seen this client or not*/\n\t\t\t\t\tfor (i = 0; i < num_neighbor_client_temp; i++)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* find the client */\n\t\t\t\t\t\tif (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* check if iface is not bridge interface*/\n\t\t\t\t\t\t\tif (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) != 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/* use previous ipv4 first */\n\t\t\t\t\t\t\t\tif(data->if_index != neighbor_client[i].iface_index)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\"update new kernel iface index \\n\");\n\t\t\t\t\t\t\t\t\tneighbor_client[i].iface_index = data->if_index;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t/* check if client associated with previous network interface */\n\t\t\t\t\t\t\t\tif(ipa_interface_index != neighbor_client[i].ipa_if_num)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\"client associate to different AP \\n\");\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (neighbor_client[i].v4_addr != 0) /* not 0.0.0.0 */\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tevt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;\n\t\t\t\t\t\t\t\t\tdata_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));\n\t\t\t\t\t\t\t\t\tif (data_all == NULL)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdata_all->iptype = IPA_IP_v4;\n\t\t\t\t\t\t\t\t\tdata_all->if_index = neighbor_client[i].iface_index;\n\t\t\t\t\t\t\t\t\tdata_all->ipv4_addr = neighbor_client[i].v4_addr; //use previous ipv4 address\n\t\t\t\t\t\t\t\t\tmemcpy(data_all->mac_addr,\n\t\t\t\t\t\t\t\t\t\t\tneighbor_client[i].mac_addr,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsizeof(data_all->mac_addr));\n\t\t\t\t\t\t\t\t\tevt_data.evt_data = (void *)data_all;\n\t\t\t\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t\t\t\t\t/* ask for replaced iface name*/\n\t\t\t\t\t\t\t\t\tipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);\n\t\t\t\t\t\t\t\t\tIPACMDBG_H(\"Posted event %d, with %s for ipv4 client re-connect\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tevt_data.event,\n\t\t\t\t\t\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t/* not find client */\n\t\t\t\t\tif (i == num_neighbor_client_temp)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* check if iface is not bridge interface*/\n\t\t\t\t\t\tif (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) != 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (num_neighbor_client_temp < IPA_MAX_NUM_NEIGHBOR_CLIENTS)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmemcpy(neighbor_client[num_neighbor_client_temp].mac_addr,\n\t\t\t\t\t\t\t\t\t\t\tdata->mac_addr,\n\t\t\t\t\t\t\t\t\t\t\tsizeof(data->mac_addr));\n\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].iface_index = data->if_index;\n\t\t\t\t\t\t\t\t/* cache the network interface client associated */\n\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].ipa_if_num = ipa_interface_index;\n\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].v4_addr = 0;\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"Copy wlan-iface client MAC %02x:%02x:%02x:%02x:%02x:%02x\\n, total client: %d\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[0],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[1],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[2],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[3],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[4],\n\t\t\t\t\t\t\t\t\t\t\t\tneighbor_client[num_neighbor_client_temp].mac_addr[5],\n\t\t\t\t\t\t\t\t\t\t\t\tnum_neighbor_client);\n\t\t\t\t\t\t\t\tnum_neighbor_client++;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tIPACMERR(\"error:  neighbor client oversize!\");\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} //ipv6 ends\n\t\t}\n\t\tbreak;\n\t}\n\treturn;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Netlink.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n* Redistributions of source code must retain the above copyright\n  notice, this list of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above\n  copyright notice, this list of conditions and the following\n  disclaimer in the documentation and/or other materials provided\n  with the distribution.\n* Neither the name of The Linux Foundation nor the names of its\n  contributors may be used to endorse or promote products derived\n  from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Netlink.cpp\n\n\t@brief\n\tThis file implements the IPAM Netlink Socket Parer functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#include <string.h>\n#include <unistd.h>\n#include <sys/ioctl.h>\n#include <netinet/in.h>\n#include \"IPACM_CmdQueue.h\"\n#include \"IPACM_Defs.h\"\n#include \"IPACM_Netlink.h\"\n#include \"IPACM_EvtDispatcher.h\"\n#include \"IPACM_Log.h\"\n\nint ipa_get_if_name(char *if_name, int if_index);\nint find_mask(int ip_v4_last, int *mask_value);\n\n#ifdef FEATURE_IPA_ANDROID\n\n#define IPACM_NL_COPY_ADDR( event_info, element )                                        \\\n        memcpy( &event_info->attr_info.element.__data,                                   \\\n                RTA_DATA(rtah),                                                          \\\n                sizeof(event_info->attr_info.element.__data) );\n\n#define IPACM_EVENT_COPY_ADDR_v6( event_data, element)                                   \\\n        memcpy( event_data, element.__data, sizeof(event_data));\n\n#define IPACM_EVENT_COPY_ADDR_v4( event_data, element)                                   \\\n        memcpy( &event_data, element.__data, sizeof(event_data));\n\n#define IPACM_NL_REPORT_ADDR( prefix, addr )                                             \\\n        if( AF_INET6 == (addr).ss_family ) {                                             \\\n          IPACM_LOG_IPV6_ADDR( prefix, addr.__data);                                    \\\n        } else {                                                                         \\\n          IPACM_LOG_IPV4_ADDR( prefix, (*(unsigned int*)&(addr).__data) );               \\\n        }\n\n#else/* defined(FEATURE_IPA_ANDROID) */\n\n#define IPACM_NL_COPY_ADDR( event_info, element )                                        \\\n        memcpy( &event_info->attr_info.element.__ss_padding,                             \\\n                RTA_DATA(rtah),                                                          \\\n                sizeof(event_info->attr_info.element.__ss_padding) );\n\n#define IPACM_EVENT_COPY_ADDR_v6( event_data, element)                                   \\\n        memcpy( event_data, element.__ss_padding, sizeof(event_data));\n\n#define IPACM_EVENT_COPY_ADDR_v4( event_data, element)                                   \\\n        memcpy( &event_data, element.__ss_padding, sizeof(event_data));\n\n#define IPACM_NL_REPORT_ADDR( prefix, addr )                                             \\\n        if( AF_INET6 == (addr).ss_family ) {                                             \\\n          IPACM_LOG_IPV6_ADDR( prefix, addr.__ss_padding);                               \\\n        } else {                                                                         \\\n          IPACM_LOG_IPV4_ADDR( prefix, (*(unsigned int*)&(addr).__ss_padding) );         \\\n        }\n#endif /* defined(FEATURE_IPA_ANDROID)*/\n\n#define NDA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))\n#define IPACM_LOG_IPV6_ADDR(prefix, ip_addr)                            \\\n        IPACMDBG_H(prefix);                                               \\\n\t\tIPACMDBG_H(\" IPV6 Address %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\\n\", \\\n                  (int)ip_addr[0],  (int)ip_addr[1],                                                        \\\n                  (int)ip_addr[2],  (int)ip_addr[3],                                                        \\\n                  (int)ip_addr[4],  (int)ip_addr[5],                                                        \\\n                  (int)ip_addr[6],  (int)ip_addr[7],                                                        \\\n                  (int)ip_addr[8],  (int)ip_addr[9],                                                        \\\n                  (int)ip_addr[10], (int)ip_addr[11],                                                       \\\n                  (int)ip_addr[12], (int)ip_addr[13],                                                       \\\n                  (int)ip_addr[14], (int)ip_addr[15]);\n\n#define IPACM_LOG_IPV4_ADDR(prefix, ip_addr)                            \\\n        IPACMDBG_H(prefix);                                               \\\n        IPACMDBG_H(\" IPV4 Address %d.%d.%d.%d\\n\",                         \\\n                    (unsigned char)(ip_addr),                               \\\n                    (unsigned char)(ip_addr >> 8),                          \\\n                    (unsigned char)(ip_addr >> 16) ,                        \\\n                    (unsigned char)(ip_addr >> 24));\n\n/* Opens a netlink socket*/\nstatic int ipa_nl_open_socket\n(\n\t ipa_nl_sk_info_t *sk_info,\n\t int protocol,\n\t unsigned int grps\n\t )\n{\n\tint *p_sk_fd;\n\tint buf_size = 6669999, sendbuff=0, res;\n\tstruct sockaddr_nl *p_sk_addr_loc;\n\tsocklen_t optlen;\n\n\tp_sk_fd = &(sk_info->sk_fd);\n\tp_sk_addr_loc = &(sk_info->sk_addr_loc);\n\n\t/* Open netlink socket for specified protocol */\n\tif((*p_sk_fd = socket(AF_NETLINK, SOCK_RAW, protocol)) < 0)\n\t{\n\t\tIPACMERR(\"cannot open netlink socket\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\toptlen = sizeof(sendbuff);\n\tres = getsockopt(*p_sk_fd, SOL_SOCKET, SO_SNDBUF, &sendbuff, &optlen);\n\n\tif(res == -1) {\n\t\tIPACMDBG(\"Error getsockopt one\");\n\t} else {\n\t\tIPACMDBG(\"orignal send buffer size = %d\\n\", sendbuff);\n\t}\n\tIPACMDBG(\"sets the send buffer to %d\\n\", buf_size);\n\tif (setsockopt(*p_sk_fd, SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(int)) == -1) {\n    IPACMERR(\"Error setting socket opts\\n\");\n\t}\n\n\t/* Initialize socket addresses to null */\n\tmemset(p_sk_addr_loc, 0, sizeof(struct sockaddr_nl));\n\n\t/* Populate local socket address using specified groups */\n\tp_sk_addr_loc->nl_family = AF_NETLINK;\n\tp_sk_addr_loc->nl_pid = getpid();\n\tp_sk_addr_loc->nl_groups = grps;\n\n\t/* Bind socket to the local address, i.e. specified groups. This ensures\n\t that multicast messages for these groups are delivered over this\n\t socket. */\n\n\tif(bind(*p_sk_fd,\n\t\t\t\t\t(struct sockaddr *)p_sk_addr_loc,\n\t\t\t\t\tsizeof(struct sockaddr_nl)) < 0)\n\t{\n\t\tIPACMERR(\"Socket bind failed\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* Add fd to fdmap array and store read handler function ptr (up to MAX_NUM_OF_FD).*/\nstatic int ipa_nl_addfd_map\n(\n\t ipa_nl_sk_fd_set_info_t *info,\n\t int fd,\n\t ipa_sock_thrd_fd_read_f read_f\n\t )\n{\n\tif(info->num_fd < MAX_NUM_OF_FD)\n\t{\n\t\tFD_SET(fd, &info->fdset);\n\n\t\t/* Add fd to fdmap array and store read handler function ptr */\n\t\tinfo->sk_fds[info->num_fd].sk_fd = fd;\n\t\tinfo->sk_fds[info->num_fd].read_func = read_f;\n\n\t\t/* Increment number of fds stored in fdmap */\n\t\tinfo->num_fd++;\n\t\tif(info->max_fd < fd)\n\t\t\tinfo->max_fd = fd;\n\t}\n\telse\n\t{\n\t\treturn IPACM_FAILURE;\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*  start socket listener */\nstatic int ipa_nl_sock_listener_start\n(\n\t ipa_nl_sk_fd_set_info_t *sk_fd_set\n\t )\n{\n\tint i, ret;\n\n\twhile(true)\n\t{\n\t    for(i = 0; i < sk_fd_set->num_fd; i++ )\n\t\t{\n\t\t\tFD_SET(sk_fd_set->sk_fds[i].sk_fd, &(sk_fd_set->fdset));\n\t\t}\n\n\t\tif((ret = select(sk_fd_set->max_fd + 1, &(sk_fd_set->fdset), NULL, NULL, NULL)) < 0)\n\t\t{\n\t\t\tIPACMERR(\"ipa_nl select failed\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(i = 0; i < sk_fd_set->num_fd; i++)\n\t\t\t{\n\n\t\t\t\tif(FD_ISSET(sk_fd_set->sk_fds[i].sk_fd, &(sk_fd_set->fdset)))\n\t\t\t\t{\n\n\t\t\t\t\tif(sk_fd_set->sk_fds[i].read_func)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(IPACM_SUCCESS != ((sk_fd_set->sk_fds[i].read_func)(sk_fd_set->sk_fds[i].sk_fd)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Error on read callback[%d] fd=%d\\n\",\n\t\t\t\t\t\t\t\t\t\t\t i,\n\t\t\t\t\t\t\t\t\t\t\t sk_fd_set->sk_fds[i].sk_fd);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tFD_CLR(sk_fd_set->sk_fds[i].sk_fd, &(sk_fd_set->fdset));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"No read function\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t} /* end of for loop*/\n\t\t} /* end of else */\n\t} /* end of while */\n\n\treturn IPACM_SUCCESS;\n}\n\n/* allocate memory for ipa_nl__msg */\nstatic struct msghdr* ipa_nl_alloc_msg\n(\n\t uint32_t msglen\n\t )\n{\n\tunsigned char *buf = NULL;\n\tstruct sockaddr_nl *nladdr = NULL;\n\tstruct iovec *iov = NULL;\n\tstruct msghdr *msgh = NULL;\n\n\tif(IPA_NL_MSG_MAX_LEN < msglen)\n\t{\n\t\tIPACMERR(\"Netlink message exceeds maximum length\\n\");\n\t\treturn NULL;\n\t}\n\n\tmsgh = (struct msghdr *)malloc(sizeof(struct msghdr));\n\tif(msgh == NULL)\n\t{\n\t\tIPACMERR(\"Failed malloc for msghdr\\n\");\n\t\treturn NULL;\n\t}\n\n\tnladdr = (struct sockaddr_nl *)malloc(sizeof(struct sockaddr_nl));\n\tif(nladdr == NULL)\n\t{\n\t\tIPACMERR(\"Failed malloc for sockaddr\\n\");\n\t\tfree(msgh);\n\t\treturn NULL;\n\t}\n\n\tiov = (struct iovec *)malloc(sizeof(struct iovec));\n\tif(iov == NULL)\n\t{\n\t\tPERROR(\"Failed malloc for iovec\");\n\t\tfree(nladdr);\n\t\tfree(msgh);\n\t\treturn NULL;\n\t}\n\n\tbuf = (unsigned char *)malloc(msglen);\n\tif(buf == NULL)\n\t{\n\t\tIPACMERR(\"Failed malloc for mglen\\n\");\n\t\tfree(iov);\n\t\tfree(nladdr);\n\t\tfree(msgh);\n\t\treturn NULL;\n\t}\n\n\tmemset(nladdr, 0, sizeof(struct sockaddr_nl));\n\tnladdr->nl_family = AF_NETLINK;\n\n\tmemset(msgh, 0x0, sizeof(struct msghdr));\n\tmsgh->msg_name = nladdr;\n\tmsgh->msg_namelen = sizeof(struct sockaddr_nl);\n\tmsgh->msg_iov = iov;\n\tmsgh->msg_iovlen = 1;\n\n\tmemset(iov, 0x0, sizeof(struct iovec));\n\tiov->iov_base = buf;\n\tiov->iov_len = msglen;\n\n\treturn msgh;\n}\n\n/* release IPA message */\nstatic void ipa_nl_release_msg\n(\n\t struct msghdr *msgh\n\t )\n{\n\tunsigned char *buf = NULL;\n\tstruct sockaddr_nl *nladdr = NULL;\n\tstruct iovec *iov = NULL;\n\n\tif(NULL == msgh)\n\t{\n\t\treturn;\n\t}\n\n\tnladdr = (struct sockaddr_nl *)msgh->msg_name;\n\tiov = msgh->msg_iov;\n\tif(msgh->msg_iov)\n\t{\n\t\tbuf = (unsigned char *)msgh->msg_iov->iov_base;\n\t}\n\n\tif(buf)\n\t{\n\tfree(buf);\n\t}\n\tif(iov)\n\t{\n\tfree(iov);\n\t}\n\tif(nladdr)\n\t{\n\tfree(nladdr);\n\t}\n\tif(msgh)\n\t{\n\tfree(msgh);\n\t}\n\treturn;\n}\n\n/* receive and process nl message */\nstatic int ipa_nl_recv\n(\n\t int              fd,\n\t struct msghdr **msg_pptr,\n\t unsigned int  *msglen_ptr\n\t )\n{\n\tstruct msghdr *msgh = NULL;\n\tint rmsgl;\n\n\tmsgh = ipa_nl_alloc_msg(IPA_NL_MSG_MAX_LEN);\n\tif(NULL == msgh)\n\t{\n\t\tIPACMERR(\"Failed to allocate NL message\\n\");\n\t\tgoto error;\n\t}\n\n\n\t/* Receive message over the socket */\n\trmsgl = recvmsg(fd, msgh, 0);\n\n\t/* Verify that something was read */\n\tif(rmsgl <= 0)\n\t{\n\t\tPERROR(\"NL recv error\");\n\t\tgoto error;\n\t}\n\n\t/* Verify that NL address length in the received message is expected value */\n\tif(sizeof(struct sockaddr_nl) != msgh->msg_namelen)\n\t{\n\t\tIPACMERR(\"rcvd msg with namelen != sizeof sockaddr_nl\\n\");\n\t\tgoto error;\n\t}\n\n\t/* Verify that message was not truncated. This should not occur */\n\tif(msgh->msg_flags & MSG_TRUNC)\n\t{\n\t\tIPACMERR(\"Rcvd msg truncated!\\n\");\n\t\tgoto error;\n\t}\n\n\t*msg_pptr    = msgh;\n\t*msglen_ptr = rmsgl;\n\n\treturn IPACM_SUCCESS;\n\n/* An error occurred while receiving the message. Free all memory before\n\t\t\t\t returning. */\nerror:\n\tipa_nl_release_msg(msgh);\n\t*msg_pptr    = NULL;\n\t*msglen_ptr  = 0;\n\n\treturn IPACM_FAILURE;\n}\n\n/* decode the rtm netlink message */\nstatic int ipa_nl_decode_rtm_link\n(\n\t const char              *buffer,\n\t unsigned int             buflen,\n\t ipa_nl_link_info_t      *link_info\n)\n{\n\tstruct rtattr;\n\t/* NL message header */\n\tstruct nlmsghdr *nlh = (struct nlmsghdr *)buffer;\n\n\t/* Extract the header data */\n\tlink_info->metainfo = *(struct ifinfomsg *)NLMSG_DATA(nlh);\n\tbuflen -= sizeof(struct nlmsghdr);\n\n\treturn IPACM_SUCCESS;\n}\n\n/* Decode kernel address message parameters from Netlink attribute TLVs. */\nstatic int ipa_nl_decode_rtm_addr\n(\n\t const char              *buffer,\n\t unsigned int             buflen,\n\t ipa_nl_addr_info_t   *addr_info\n\t )\n{\n\tstruct nlmsghdr *nlh = (struct nlmsghdr *)buffer;  /* NL message header */\n\tstruct rtattr *rtah = NULL;\n\n\t/* Extract the header data */\n\taddr_info->metainfo = *((struct ifaddrmsg *)NLMSG_DATA(nlh));\n\tbuflen -= sizeof(struct nlmsghdr);\n\n\t/* Extract the available attributes */\n\taddr_info->attr_info.param_mask = IPA_NLA_PARAM_NONE;\n\n\trtah = IFA_RTA(NLMSG_DATA(nlh));\n\n\twhile(RTA_OK(rtah, buflen))\n\t{\n\t\tswitch(rtah->rta_type)\n\t\t{\n\n\t\tcase IFA_ADDRESS:\n\t\t\taddr_info->attr_info.prefix_addr.ss_family = addr_info->metainfo.ifa_family;\n\t\t\tIPACM_NL_COPY_ADDR( addr_info, prefix_addr );\n\t\t\taddr_info->attr_info.param_mask |= IPA_NLA_PARAM_PREFIXADDR;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\n\t\t}\n\t\t/* Advance to next attribute */\n\t\trtah = RTA_NEXT(rtah, buflen);\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* Decode kernel neighbor message parameters from Netlink attribute TLVs. */\nstatic int ipa_nl_decode_rtm_neigh\n(\n\t const char              *buffer,\n\t unsigned int             buflen,\n\t ipa_nl_neigh_info_t   *neigh_info\n\t )\n{\n\tstruct nlmsghdr *nlh = (struct nlmsghdr *)buffer;  /* NL message header */\n\tstruct rtattr *rtah = NULL;\n\n\t/* Extract the header data */\n\tneigh_info->metainfo = *((struct ndmsg *)NLMSG_DATA(nlh));\n\tbuflen -= sizeof(struct nlmsghdr);\n\n\t/* Extract the available attributes */\n\tneigh_info->attr_info.param_mask = IPA_NLA_PARAM_NONE;\n\n\trtah = NDA_RTA(NLMSG_DATA(nlh));\n\n\twhile(RTA_OK(rtah, buflen))\n\t{\n\t\tswitch(rtah->rta_type)\n\t\t{\n\n\t\tcase NDA_DST:\n\t\t\tneigh_info->attr_info.local_addr.ss_family = neigh_info->metainfo.ndm_family;\n\t\t\tIPACM_NL_COPY_ADDR( neigh_info, local_addr );\n\t\t\tbreak;\n\n\t\tcase NDA_LLADDR:\n\t\t\tmemcpy(neigh_info->attr_info.lladdr_hwaddr.sa_data,\n\t\t\t\t\t\t RTA_DATA(rtah),\n\t\t\t\t\t\t sizeof(neigh_info->attr_info.lladdr_hwaddr.sa_data));\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\n\t\t}\n\n\t\t/* Advance to next attribute */\n\t\trtah = RTA_NEXT(rtah, buflen);\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* Decode kernel route message parameters from Netlink attribute TLVs. */\nstatic int ipa_nl_decode_rtm_route\n(\n\t const char              *buffer,\n\t unsigned int             buflen,\n\t ipa_nl_route_info_t   *route_info\n\t )\n{\n\tstruct nlmsghdr *nlh = (struct nlmsghdr *)buffer;  /* NL message header */\n\tstruct rtattr *rtah = NULL;\n\n\t/* Extract the header data */\n\troute_info->metainfo = *((struct rtmsg *)NLMSG_DATA(nlh));\n\tbuflen -= sizeof(struct nlmsghdr);\n\n\troute_info->attr_info.param_mask = IPA_RTA_PARAM_NONE;\n\trtah = RTM_RTA(NLMSG_DATA(nlh));\n\n\twhile(RTA_OK(rtah, buflen))\n\t{\n\t\tswitch(rtah->rta_type)\n\t\t{\n\n\t\tcase RTA_DST:\n\t\t\t\troute_info->attr_info.dst_addr.ss_family = route_info->metainfo.rtm_family;\n\t\t\t\tIPACM_NL_COPY_ADDR( route_info, dst_addr );\n\t\t\t\troute_info->attr_info.param_mask |= IPA_RTA_PARAM_DST;\n\t\t\tbreak;\n\n\t\tcase RTA_SRC:\n\t\t\troute_info->attr_info.src_addr.ss_family = route_info->metainfo.rtm_family;\n\t\t\tIPACM_NL_COPY_ADDR( route_info, src_addr );\n\t\t\troute_info->attr_info.param_mask |= IPA_RTA_PARAM_SRC;\n\t\t\tbreak;\n\n\t\tcase RTA_GATEWAY:\n\t\t\troute_info->attr_info.gateway_addr.ss_family = route_info->metainfo.rtm_family;\n\t\t\tIPACM_NL_COPY_ADDR( route_info, gateway_addr );\n\t\t\troute_info->attr_info.param_mask |= IPA_RTA_PARAM_GATEWAY;\n\t\t\tbreak;\n\n\t\tcase RTA_IIF:\n\t\t\tmemcpy(&route_info->attr_info.iif_index,\n\t\t\t\t\t\t RTA_DATA(rtah),\n\t\t\t\t\t\t sizeof(route_info->attr_info.iif_index));\n\t\t\troute_info->attr_info.param_mask |= IPA_RTA_PARAM_IIF;\n\t\t\tbreak;\n\n\t\tcase RTA_OIF:\n\t\t\tmemcpy(&route_info->attr_info.oif_index,\n\t\t\t\t\t\t RTA_DATA(rtah),\n\t\t\t\t\t\t sizeof(route_info->attr_info.oif_index));\n\t\t\troute_info->attr_info.param_mask |= IPA_RTA_PARAM_OIF;\n\t\t\tbreak;\n\n\t\tcase RTA_PRIORITY:\n\t\t\tmemcpy(&route_info->attr_info.priority,\n\t\t\t\t\t\t RTA_DATA(rtah),\n\t\t\t\t\t\t sizeof(route_info->attr_info.priority));\n\t\t\troute_info->attr_info.param_mask |= IPA_RTA_PARAM_PRIORITY;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\n\t\t}\n\n\t\t/* Advance to next attribute */\n\t\trtah = RTA_NEXT(rtah, buflen);\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* decode the ipa nl-message */\nstatic int ipa_nl_decode_nlmsg\n(\n\t const char   *buffer,\n\t unsigned int  buflen,\n\t ipa_nl_msg_t  *msg_ptr\n\t )\n{\n\tchar dev_name[IF_NAME_LEN]={0};\n\tint ret_val, mask_value, mask_index, mask_value_v6;\n\tstruct nlmsghdr *nlh = (struct nlmsghdr *)buffer;\n\n\tuint32_t if_ipv4_addr =0, if_ipipv4_addr_mask =0, temp =0;\n\n\tipacm_cmd_q_data evt_data;\n\tipacm_event_data_all *data_all;\n\tipacm_event_data_fid *data_fid;\n\tipacm_event_data_addr *data_addr;\n\n\n\twhile(NLMSG_OK(nlh, buflen))\n\t{\n\t\tmemset(dev_name,0,IF_NAME_LEN);\n\t\tIPACMDBG(\"Received msg:%d from netlink\\n\", nlh->nlmsg_type)\n\t\tswitch(nlh->nlmsg_type)\n\t\t{\n\t\tcase RTM_NEWLINK:\n\t\t\tmsg_ptr->type = nlh->nlmsg_type;\n\t\t\tmsg_ptr->link_event = true;\n\t\t\tif(IPACM_SUCCESS != ipa_nl_decode_rtm_link(buffer, buflen, &(msg_ptr->nl_link_info)))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to decode rtm link message\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Got RTM_NEWLINK with below values\\n\");\n\t\t\t\tIPACMDBG(\"RTM_NEWLINK, ifi_change:%d\\n\", msg_ptr->nl_link_info.metainfo.ifi_change);\n\t\t\t\tIPACMDBG(\"RTM_NEWLINK, ifi_flags:%d\\n\", msg_ptr->nl_link_info.metainfo.ifi_flags);\n\t\t\t\tIPACMDBG(\"RTM_NEWLINK, ifi_index:%d\\n\", msg_ptr->nl_link_info.metainfo.ifi_index);\n\t\t\t\tIPACMDBG(\"RTM_NEWLINK, family:%d\\n\", msg_ptr->nl_link_info.metainfo.ifi_family);\n\n\t\t\t\tif (msg_ptr->nl_link_info.metainfo.ifi_family == AF_BRIDGE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" ignore this RTM_NEWLINK msg \\n\");\n\t\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t\t}\n\n\t\t\t\tif(IFF_UP & msg_ptr->nl_link_info.metainfo.ifi_change)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\"GOT useful newlink event\\n\");\n\t\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);\n\t\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\t\t\tif(data_fid == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_fid\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t\tdata_fid->if_index = msg_ptr->nl_link_info.metainfo.ifi_index;\n\n\t\t\t\t\tif(msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_UP)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Interface %s bring up with IP-family: %d \\n\", dev_name, msg_ptr->nl_link_info.metainfo.ifi_family);\n\t\t\t\t\t\t/* post link up to command queue */\n\t\t\t\t\t\tevt_data.event = IPA_LINK_UP_EVENT;\n\t\t\t\t\t\tIPACMDBG_H(\"Posting IPA_LINK_UP_EVENT with if index: %d\\n\",\n\t\t\t\t\t\t\t\t\t\t msg_ptr->nl_link_info.metainfo.ifi_index);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Interface %s bring down with IP-family: %d \\n\", dev_name, msg_ptr->nl_link_info.metainfo.ifi_family);\n\t\t\t\t\t\t/* post link down to command queue */\n\t\t\t\t\t\tevt_data.event = IPA_LINK_DOWN_EVENT;\n\t\t\t\t\t\tIPACMDBG_H(\"Posting IPA_LINK_DOWN_EVENT with if index: %d\\n\",\n\t\t\t\t\t\t\t\t\t\t data_fid->if_index);\n\t\t\t\t\t}\n\t\t\t\t\tevt_data.evt_data = data_fid;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t}\n\n\t\t\t\t/* Add IPACM support for ECM plug-in/plug_out */\n\t\t\t\t/*--------------------------------------------------------------------------\n                                   Check if the interface is running.If its a RTM_NEWLINK and the interface\n                                    is running then it means that its a link up event\n                                ---------------------------------------------------------------------------*/\n                                if((msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_RUNNING) &&\n                                   (msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_LOWER_UP))\n                                {\n\n\t\t\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\t\t\tif(data_fid == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_fid\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t\tdata_fid->if_index = msg_ptr->nl_link_info.metainfo.ifi_index;\n\n\t\t\t\t        ret_val = ipa_get_if_name(dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);\n\t\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t    IPACMDBG(\"Got a usb link_up event (Interface %s, %d) \\n\", dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);\n\n                                        /*--------------------------------------------------------------------------\n                                           Post LAN iface (ECM) link up event\n                                         ---------------------------------------------------------------------------*/\n                                        evt_data.event = IPA_USB_LINK_UP_EVENT;\n\t\t\t\t\tevt_data.evt_data = data_fid;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\tIPACMDBG(\"Posting usb IPA_LINK_UP_EVENT with if index: %d\\n\",\n\t\t\t\t\t\t\t\t\t\t data_fid->if_index);\n                                }\n                                else if(!(msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_LOWER_UP))\n                                {\n\t\t\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\t\t\tif(data_fid == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_fid\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t\tdata_fid->if_index = msg_ptr->nl_link_info.metainfo.ifi_index;\n\n\t\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);\n\t\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n         \t\t    IPACMDBG_H(\"Got a usb link_down event (Interface %s) \\n\", dev_name);\n\n                    /*--------------------------------------------------------------------------\n                       Post LAN iface (ECM) link down event\n                     ---------------------------------------------------------------------------*/\n                    evt_data.event = IPA_LINK_DOWN_EVENT;\n\t\t\t\t\tevt_data.evt_data = data_fid;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\tIPACMDBG_H(\"Posting usb IPA_LINK_DOWN_EVENT with if index: %d\\n\",\n\t\t\t\t\t\t\t\t\t\t data_fid->if_index);\n\n                                }\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase RTM_DELLINK:\n\t\t\tIPACMDBG(\"\\n GOT dellink event\\n\");\n\t\t\tmsg_ptr->type = nlh->nlmsg_type;\n\t\t\tmsg_ptr->link_event = true;\n\t\t\tIPACMDBG(\"entering rtm decode\\n\");\n\t\t\tif(IPACM_SUCCESS != ipa_nl_decode_rtm_link(buffer, buflen, &(msg_ptr->nl_link_info)))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to decode rtm link message\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG(\"Got RTM_DELLINK with below values\\n\");\n\t\t\t\tIPACMDBG(\"RTM_DELLINK, ifi_change:%d\\n\", msg_ptr->nl_link_info.metainfo.ifi_change);\n\t\t\t\tIPACMDBG(\"RTM_DELLINK, ifi_flags:%d\\n\", msg_ptr->nl_link_info.metainfo.ifi_flags);\n\t\t\t\tIPACMDBG(\"RTM_DELLINK, ifi_index:%d\\n\", msg_ptr->nl_link_info.metainfo.ifi_index);\n\t\t\t\tIPACMDBG(\"RTM_DELLINK, family:%d\\n\", msg_ptr->nl_link_info.metainfo.ifi_family);\n\n\t\t\t\tif (msg_ptr->nl_link_info.metainfo.ifi_family == AF_BRIDGE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" ignore this RTM_DELLINK msg \\n\");\n\t\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t\t}\n\n\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);\n\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tIPACMDBG(\"Interface %s bring down \\n\", dev_name);\n\n\t\t\t\t/* post link down to command queue */\n\t\t\t\tevt_data.event = IPA_LINK_DOWN_EVENT;\n\t\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\t\tif(data_fid == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_fid\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\n\t\t\t\tdata_fid->if_index = msg_ptr->nl_link_info.metainfo.ifi_index;\n\n\t\t\t\tIPACMDBG_H(\"posting IPA_LINK_DOWN_EVENT with if idnex:%d\\n\",\n\t\t\t\t\t\t\t\t data_fid->if_index);\n\t\t\t\tevt_data.evt_data = data_fid;\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t/* finish command queue */\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase RTM_NEWADDR:\n\t\t\tIPACMDBG(\"\\n GOT RTM_NEWADDR event\\n\");\n\t\t\tif(IPACM_SUCCESS != ipa_nl_decode_rtm_addr(buffer, buflen, &(msg_ptr->nl_addr_info)))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to decode rtm addr message\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_addr_info.metainfo.ifa_index);\n\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t}\n\t\t\t\tIPACMDBG(\"Interface %s \\n\", dev_name);\n\n\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\tif(data_addr == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\n\t\t\t\tif(AF_INET6 == msg_ptr->nl_addr_info.attr_info.prefix_addr.ss_family)\n\t\t\t\t{\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v6;\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"IFA_ADDRESS:\", msg_ptr->nl_addr_info.attr_info.prefix_addr );\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr, msg_ptr->nl_addr_info.attr_info.prefix_addr);\n\t\t\t\t\tdata_addr->ipv6_addr[0] = ntohl(data_addr->ipv6_addr[0]);\n\t\t\t\t\tdata_addr->ipv6_addr[1] = ntohl(data_addr->ipv6_addr[1]);\n\t\t\t\t\tdata_addr->ipv6_addr[2] = ntohl(data_addr->ipv6_addr[2]);\n\t\t\t\t\tdata_addr->ipv6_addr[3] = ntohl(data_addr->ipv6_addr[3]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v4;\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"IFA_ADDRESS:\", msg_ptr->nl_addr_info.attr_info.prefix_addr );\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( data_addr->ipv4_addr, msg_ptr->nl_addr_info.attr_info.prefix_addr);\n\t\t\t\t\tdata_addr->ipv4_addr = ntohl(data_addr->ipv4_addr);\n\n\t\t\t\t}\n\n\t\t\t\tevt_data.event = IPA_ADDR_ADD_EVENT;\n\t\t\t\tdata_addr->if_index = msg_ptr->nl_addr_info.metainfo.ifa_index;\n\t\t\t\tif(AF_INET6 == msg_ptr->nl_addr_info.attr_info.prefix_addr.ss_family)\n\t\t\t\t{\n\t\t\t\t    IPACMDBG(\"Posting IPA_ADDR_ADD_EVENT with if index:%d, ipv6 addr:0x%x:%x:%x:%x\\n\",\n\t\t\t\t\t\t\t\t data_addr->if_index,\n\t\t\t\t\t\t\t\t data_addr->ipv6_addr[0],\n\t\t\t\t\t\t\t\t data_addr->ipv6_addr[1],\n\t\t\t\t\t\t\t\t data_addr->ipv6_addr[2],\n\t\t\t\t\t\t\t\t data_addr->ipv6_addr[3]);\n                }\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\tIPACMDBG(\"Posting IPA_ADDR_ADD_EVENT with if index:%d, ipv4 addr:0x%x\\n\",\n\t\t\t\t\t\t\t\t data_addr->if_index,\n\t\t\t\t\t\t\t\t data_addr->ipv4_addr);\n\t\t\t\t}\n\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase RTM_NEWROUTE:\n\n\t\t\tif(IPACM_SUCCESS != ipa_nl_decode_rtm_route(buffer, buflen, &(msg_ptr->nl_route_info)))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to decode rtm route message\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\n\t\t\tIPACMDBG(\"In case RTM_NEWROUTE\\n\");\n\t\t\tIPACMDBG(\"rtm_type: %d\\n\", msg_ptr->nl_route_info.metainfo.rtm_type);\n\t\t\tIPACMDBG(\"rtm_type: %d\\n\", msg_ptr->nl_route_info.metainfo.rtm_type);\n\t\t\tIPACMDBG(\"protocol: %d\\n\", msg_ptr->nl_route_info.metainfo.rtm_protocol);\n\t\t\tIPACMDBG(\"rtm_scope: %d\\n\", msg_ptr->nl_route_info.metainfo.rtm_scope);\n\t\t\tIPACMDBG(\"rtm_table: %d\\n\", msg_ptr->nl_route_info.metainfo.rtm_table);\n\t\t\tIPACMDBG(\"rtm_family: %d\\n\", msg_ptr->nl_route_info.metainfo.rtm_family);\n\t\t\tIPACMDBG(\"param_mask: 0x%x\\n\", msg_ptr->nl_route_info.attr_info.param_mask);\n\n\t\t\t/* take care of route add default route & uniroute */\n\t\t\tif((msg_ptr->nl_route_info.metainfo.rtm_type == RTN_UNICAST) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_protocol == RTPROT_BOOT) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_scope == RT_SCOPE_UNIVERSE) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_table == RT_TABLE_MAIN))\n\t\t\t{\n\t\t\t\tIPACMDBG(\"\\n GOT RTM_NEWROUTE event\\n\");\n\n\t\t\t\tif(msg_ptr->nl_route_info.attr_info.param_mask & IPA_RTA_PARAM_DST)\n\t\t\t\t{\n\t\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_route_info.attr_info.oif_index);\n\t\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"route add -host\", msg_ptr->nl_route_info.attr_info.dst_addr );\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"gw\", msg_ptr->nl_route_info.attr_info.gateway_addr );\n\t\t\t\t\tIPACMDBG(\"dev %s\\n\",dev_name );\n\t\t\t\t\t/* insert to command queue */\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( if_ipv4_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\t\t\t\t\ttemp = (-1);\n\n\t\t\t\t\tevt_data.event = IPA_ROUTE_ADD_EVENT;\n\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\tdata_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v4;\n\t\t\t\t\tdata_addr->ipv4_addr = ntohl(if_ipv4_addr);\n\t\t\t\t\tdata_addr->ipv4_addr_mask = ntohl(if_ipipv4_addr_mask);\n\n\t\t\t\t\tIPACMDBG(\"Posting IPA_ROUTE_ADD_EVENT with if index:%d, ipv4 address 0x%x, mask:0x%x\\n\",\n\t\t\t\t\t\t\t\t\t data_addr->if_index,\n\t\t\t\t\t\t\t\t\t data_addr->ipv4_addr,\n\t\t\t\t\t\t\t\t\t data_addr->ipv4_addr_mask);\n\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t/* finish command queue */\n\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_route_info.attr_info.oif_index);\n\t\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(AF_INET6 == msg_ptr->nl_route_info.metainfo.rtm_family)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* insert to command queue */\n\t\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif(msg_ptr->nl_route_info.attr_info.param_mask & IPA_RTA_PARAM_PRIORITY)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMDBG_H(\"ip -6 route add default dev %s metric %d\\n\",\n\t\t\t\t\t\t\t\t\t\t\t dev_name,\n\t\t\t\t\t\t\t\t\t\t\t msg_ptr->nl_route_info.attr_info.priority);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMDBG_H(\"ip -6 route add default dev %s\\n\", dev_name);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\t\t\t\t\t\tdata_addr->ipv6_addr[0] = ntohl(data_addr->ipv6_addr[0]);\n\t\t\t\t\t\tdata_addr->ipv6_addr[1] = ntohl(data_addr->ipv6_addr[1]);\n\t\t\t\t\t\tdata_addr->ipv6_addr[2] = ntohl(data_addr->ipv6_addr[2]);\n\t\t\t\t\t\tdata_addr->ipv6_addr[3] = ntohl(data_addr->ipv6_addr[3]);\n\t\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr_mask, msg_ptr->nl_route_info.attr_info.dst_addr);\n\n\t\t\t\t\t\tdata_addr->ipv6_addr_mask[0] = ntohl(data_addr->ipv6_addr_mask[0]);\n\t\t\t\t\t\tdata_addr->ipv6_addr_mask[1] = ntohl(data_addr->ipv6_addr_mask[1]);\n\t\t\t\t\t\tdata_addr->ipv6_addr_mask[2] = ntohl(data_addr->ipv6_addr_mask[2]);\n\t\t\t\t\t\tdata_addr->ipv6_addr_mask[3] = ntohl(data_addr->ipv6_addr_mask[3]);\n\n\t\t\t\t\t\tevt_data.event = IPA_ROUTE_ADD_EVENT;\n\t\t\t\t\t\tdata_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;\n\t\t\t\t\t\tdata_addr->iptype = IPA_IP_v6;\n\n\t\t\t\t\t\tIPACMDBG(\"Posting IPA_ROUTE_ADD_EVENT with if index:%d, ipv6 address\\n\",\n\t\t\t\t\t\t\t\t\t\t data_addr->if_index);\n\t\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t\t/* finish command queue */\n\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"route add default gw \\n\", msg_ptr->nl_route_info.attr_info.gateway_addr );\n\t\t\t\t\t\tIPACMDBG_H(\"dev %s \\n\", dev_name);\n\t\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"dstIP:\", msg_ptr->nl_route_info.attr_info.dst_addr );\n\n\t\t\t\t\t\t/* insert to command queue */\n\t\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( if_ipv4_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\t\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( if_ipipv4_addr_mask, msg_ptr->nl_route_info.attr_info.dst_addr);\n\n\t\t\t\t\t\tevt_data.event = IPA_ROUTE_ADD_EVENT;\n\t\t\t\t\t\tdata_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;\n\t\t\t\t\t\tdata_addr->iptype = IPA_IP_v4;\n\t\t\t\t\t\tdata_addr->ipv4_addr = ntohl(if_ipv4_addr);\n\t\t\t\t\t\tdata_addr->ipv4_addr_mask = ntohl(if_ipipv4_addr_mask);\n\n            IPACMDBG_H(\"Posting IPA_ROUTE_ADD_EVENT with if index:%d, ipv4 addr:0x%x and maxk: 0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t data_addr->if_index,\n\t\t\t\t\t\t\t\t\t\t data_addr->ipv4_addr,\n\t\t\t\t\t\t\t\t\t\t data_addr->ipv4_addr_mask);\n\t\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t\t/* finish command queue */\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* ipv6 routing table */\n\t\t\tif((AF_INET6 == msg_ptr->nl_route_info.metainfo.rtm_family) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_type == RTN_UNICAST) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_protocol == RTPROT_KERNEL) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_table == RT_TABLE_MAIN))\n\t\t\t{\n\t\t\t\tIPACMDBG(\"\\n GOT valid v6-RTM_NEWROUTE event\\n\");\n\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_route_info.attr_info.oif_index);\n\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\n\t\t\t\tif(msg_ptr->nl_route_info.attr_info.param_mask & IPA_RTA_PARAM_DST)\n\t\t\t\t{\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"Route ADD DST:\", msg_ptr->nl_route_info.attr_info.dst_addr );\n\t\t\t\t\tIPACMDBG(\"%d, metric %d, dev %s\\n\",\n\t\t\t\t\t\t\t\t\t msg_ptr->nl_route_info.metainfo.rtm_dst_len,\n\t\t\t\t\t\t\t\t\t msg_ptr->nl_route_info.attr_info.priority,\n\t\t\t\t\t\t\t\t\t dev_name);\n\n\t\t\t\t\t/* insert to command queue */\n\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\t IPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\n\t\t\t\t\tdata_addr->ipv6_addr[0] = ntohl(data_addr->ipv6_addr[0]);\n\t\t\t\t\tdata_addr->ipv6_addr[1] = ntohl(data_addr->ipv6_addr[1]);\n\t\t\t\t\tdata_addr->ipv6_addr[2] = ntohl(data_addr->ipv6_addr[2]);\n\t\t\t\t\tdata_addr->ipv6_addr[3] = ntohl(data_addr->ipv6_addr[3]);\n\n\t\t\t\t\tmask_value_v6 = msg_ptr->nl_route_info.metainfo.rtm_dst_len;\n\t\t\t\t\tfor(mask_index = 0; mask_index < 4; mask_index++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(mask_value_v6 >= 32)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmask_v6(32, &data_addr->ipv6_addr_mask[mask_index]);\n\t\t\t\t\t\t\tmask_value_v6 -= 32;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmask_v6(mask_value_v6, &data_addr->ipv6_addr_mask[mask_index]);\n\t\t\t\t\t\t\tmask_value_v6 = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tIPACMDBG(\"ADD IPV6 MASK %d: %08x:%08x:%08x:%08x \\n\",\n\t\t\t\t\t\t\t\t\t msg_ptr->nl_route_info.metainfo.rtm_dst_len,\n\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[0],\n\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[1],\n\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[2],\n\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[3]);\n\n\t\t\t\t\tdata_addr->ipv6_addr_mask[0] = ntohl(data_addr->ipv6_addr_mask[0]);\n\t\t\t\t\tdata_addr->ipv6_addr_mask[1] = ntohl(data_addr->ipv6_addr_mask[1]);\n\t\t\t\t\tdata_addr->ipv6_addr_mask[2] = ntohl(data_addr->ipv6_addr_mask[2]);\n\t\t\t\t\tdata_addr->ipv6_addr_mask[3] = ntohl(data_addr->ipv6_addr_mask[3]);\n\n\t\t\t\t\tevt_data.event = IPA_ROUTE_ADD_EVENT;\n\t\t\t\t\tdata_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v6;\n\n\t\t\t\t\tIPACMDBG(\"Posting IPA_ROUTE_ADD_EVENT with if index:%d, ipv6 addr\\n\",\n\t\t\t\t\t\t\t\t\t data_addr->if_index);\n\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t/* finish command queue */\n\t\t\t\t}\n\t\t\t\tif(msg_ptr->nl_route_info.attr_info.param_mask & IPA_RTA_PARAM_GATEWAY)\n\t\t\t\t{\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"Route ADD ::/0  Next Hop:\", msg_ptr->nl_route_info.attr_info.gateway_addr );\n\t\t\t\t\tIPACMDBG(\" metric %d, dev %s\\n\",\n\t\t\t\t\t\t\t\t\t msg_ptr->nl_route_info.attr_info.priority,\n\t\t\t\t\t\t\t\t\t dev_name);\n\n\t\t\t\t\t/* insert to command queue */\n\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\n                    data_addr->ipv6_addr[0]=ntohl(data_addr->ipv6_addr[0]);\n                    data_addr->ipv6_addr[1]=ntohl(data_addr->ipv6_addr[1]);\n                    data_addr->ipv6_addr[2]=ntohl(data_addr->ipv6_addr[2]);\n                    data_addr->ipv6_addr[3]=ntohl(data_addr->ipv6_addr[3]);\n\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr_mask, msg_ptr->nl_route_info.attr_info.dst_addr);\n\n\t\t\t\t\tdata_addr->ipv6_addr_mask[0]=ntohl(data_addr->ipv6_addr_mask[0]);\n                    data_addr->ipv6_addr_mask[1]=ntohl(data_addr->ipv6_addr_mask[1]);\n                    data_addr->ipv6_addr_mask[2]=ntohl(data_addr->ipv6_addr_mask[2]);\n                    data_addr->ipv6_addr_mask[3]=ntohl(data_addr->ipv6_addr_mask[3]);\n\n\t\t\t\t\tevt_data.event = IPA_ROUTE_ADD_EVENT;\n\t\t\t\t\tdata_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v6;\n\n\t\t\t\t\tIPACMDBG(\"posting IPA_ROUTE_ADD_EVENT with if index:%d, ipv6 address\\n\",\n\t\t\t\t\t\t\t\t\t data_addr->if_index);\n\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t/* finish command queue */\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase RTM_DELROUTE:\n\t\t\tif(IPACM_SUCCESS != ipa_nl_decode_rtm_route(buffer, buflen, &(msg_ptr->nl_route_info)))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to decode rtm route message\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\t/* take care of route delete of default route & uniroute */\n\t\t\tif((msg_ptr->nl_route_info.metainfo.rtm_type == RTN_UNICAST) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_protocol == RTPROT_BOOT) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_scope == 0) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_table == RT_TABLE_MAIN))\n\t\t\t{\n\n\t\t\t\tif(msg_ptr->nl_route_info.attr_info.param_mask & IPA_RTA_PARAM_DST)\n\t\t\t\t{\n\t\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_route_info.attr_info.oif_index);\n\t\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"route del -host \", msg_ptr->nl_route_info.attr_info.dst_addr);\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \" gw \", msg_ptr->nl_route_info.attr_info.gateway_addr);\n\t\t\t\t\tIPACMDBG(\"dev %s\\n\", dev_name);\n\n\t\t\t\t\t/* insert to command queue */\n\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( if_ipv4_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\t\t\t\t\ttemp = (-1);\n\t\t\t\t\tif_ipipv4_addr_mask = ntohl(temp);\n\n\t\t\t\t\tevt_data.event = IPA_ROUTE_DEL_EVENT;\n\t\t\t\t\tdata_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v4;\n\t\t\t\t\tdata_addr->ipv4_addr = ntohl(if_ipv4_addr);\n\t\t\t\t\tdata_addr->ipv4_addr_mask = ntohl(if_ipipv4_addr_mask);\n\n\t\t\t\t\tIPACMDBG_H(\"Posting event IPA_ROUTE_DEL_EVENT with if index:%d, ipv4 address 0x%x, mask:0x%x\\n\",\n\t\t\t\t\t\t\t\t\t data_addr->if_index,\n\t\t\t\t\t\t\t\t\t data_addr->ipv4_addr,\n\t\t\t\t\t\t\t\t\t data_addr->ipv4_addr_mask);\n\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t/* finish command queue */\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_route_info.attr_info.oif_index);\n\t\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Error while getting interface name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\t/* insert to command queue */\n\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(AF_INET6 == msg_ptr->nl_route_info.metainfo.rtm_family)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(msg_ptr->nl_route_info.attr_info.param_mask & IPA_RTA_PARAM_PRIORITY)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMDBG(\"ip -6 route del default dev %s metric %d\\n\",\n\t\t\t\t\t\t\t\t\t\t\t dev_name,\n\t\t\t\t\t\t\t\t\t\t\t msg_ptr->nl_route_info.attr_info.priority);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMDBG(\"ip -6 route del default dev %s\\n\", dev_name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t IPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\n\t\t\t\t\t\tdata_addr->ipv6_addr[0] = ntohl(data_addr->ipv6_addr[0]);\n\t\t\t\t\t\tdata_addr->ipv6_addr[1] = ntohl(data_addr->ipv6_addr[1]);\n\t\t\t\t\t\tdata_addr->ipv6_addr[2] = ntohl(data_addr->ipv6_addr[2]);\n\t\t\t\t\t\tdata_addr->ipv6_addr[3] = ntohl(data_addr->ipv6_addr[3]);\n\n\t\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr_mask, msg_ptr->nl_route_info.attr_info.dst_addr);\n\n\t\t\t\t\t\tdata_addr->ipv6_addr_mask[0] = ntohl(data_addr->ipv6_addr_mask[0]);\n\t\t\t\t\t\tdata_addr->ipv6_addr_mask[1] = ntohl(data_addr->ipv6_addr_mask[1]);\n\t\t\t\t\t\tdata_addr->ipv6_addr_mask[2] = ntohl(data_addr->ipv6_addr_mask[2]);\n\t\t\t\t\t\tdata_addr->ipv6_addr_mask[3] = ntohl(data_addr->ipv6_addr_mask[3]);\n\t\t\t\t\t\tdata_addr->iptype = IPA_IP_v6;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"route del default gw\", msg_ptr->nl_route_info.attr_info.gateway_addr);\n\t\t\t\t\t\tIPACMDBG(\"dev %s\\n\", dev_name);\n\n\t\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( data_addr->ipv4_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\t\t\t\t\t\tdata_addr->ipv4_addr = ntohl(data_addr->ipv4_addr);\n\n\t\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( data_addr->ipv4_addr_mask, msg_ptr->nl_route_info.attr_info.dst_addr);\n\t\t\t\t\t\tdata_addr->ipv4_addr_mask = ntohl(data_addr->ipv4_addr_mask);\n\n\t\t\t\t\t\tdata_addr->iptype = IPA_IP_v4;\n\t\t\t\t\t}\n\n\t\t\t\t\tevt_data.event = IPA_ROUTE_DEL_EVENT;\n\t\t\t\t\tdata_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;\n\n\t\t\t\t\tIPACMDBG_H(\"Posting IPA_ROUTE_DEL_EVENT with if index:%d\\n\",\n\t\t\t\t\t\t\t\t\t data_addr->if_index);\n\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t/* finish command queue */\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* ipv6 routing table */\n\t\t\tif((AF_INET6 == msg_ptr->nl_route_info.metainfo.rtm_family) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_type == RTN_UNICAST) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_protocol == RTPROT_KERNEL) &&\n\t\t\t\t (msg_ptr->nl_route_info.metainfo.rtm_table == RT_TABLE_MAIN))\n\t\t\t{\n\t\t\t\tIPACMDBG(\"\\n GOT valid v6-RTM_DELROUTE event\\n\");\n\t\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_route_info.attr_info.oif_index);\n\t\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error while getting interface name\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\n\t\t\t\tif(msg_ptr->nl_route_info.attr_info.param_mask & IPA_RTA_PARAM_DST)\n\t\t\t\t{\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \"DEL\", msg_ptr->nl_route_info.attr_info.dst_addr);\n\t\t\t\t\tIPACMDBG(\"/%d, metric %d, dev %s\\n\",\n\t\t\t\t\t\t\t\t\t msg_ptr->nl_route_info.metainfo.rtm_dst_len,\n\t\t\t\t\t\t\t\t\t msg_ptr->nl_route_info.attr_info.priority,\n\t\t\t\t\t\t\t\t\t dev_name);\n\n\t\t\t\t\t/* insert to command queue */\n\t\t\t\t\tdata_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));\n\t\t\t\t\tif(data_addr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_addr\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_addr->ipv6_addr, msg_ptr->nl_route_info.attr_info.dst_addr);\n\n\t\t\t\t\tdata_addr->ipv6_addr[0] = ntohl(data_addr->ipv6_addr[0]);\n\t\t\t\t\tdata_addr->ipv6_addr[1] = ntohl(data_addr->ipv6_addr[1]);\n\t\t\t\t\tdata_addr->ipv6_addr[2] = ntohl(data_addr->ipv6_addr[2]);\n\t\t\t\t\tdata_addr->ipv6_addr[3] = ntohl(data_addr->ipv6_addr[3]);\n\n\t\t\t\t\tmask_value_v6 = msg_ptr->nl_route_info.metainfo.rtm_dst_len;\n\t\t\t\t\tfor(mask_index = 0; mask_index < 4; mask_index++)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG(\"%dst %d \\n\",\n\t\t\t\t\t\t\t\t\t\t mask_index,\n\t\t\t\t\t\t\t\t\t\t mask_value_v6);\n\t\t\t\t\t\tif(mask_value_v6 >= 32)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmask_v6(32, &data_addr->ipv6_addr_mask[mask_index]);\n\t\t\t\t\t\t\tmask_value_v6 -= 32;\n\t\t\t\t\t\t\tIPACMDBG(\"%dst: %08x \\n\",\n\t\t\t\t\t\t\t\t\t\t\t mask_index,\n\t\t\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[mask_index]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmask_v6(mask_value_v6, data_addr->ipv6_addr_mask);\n\t\t\t\t\t\t\tmask_value_v6 = 0;\n\t\t\t\t\t\t\tIPACMDBG(\"%dst: %08x \\n\",\n\t\t\t\t\t\t\t\t\t\t\t mask_index,\n\t\t\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[mask_index]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tIPACMDBG(\"DEL IPV6 MASK 0st: %08x \",\n\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[0]);\n\t\t\t\t\tIPACMDBG(\"1st: %08x \",\n\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[1]);\n\t\t\t\t\tIPACMDBG(\"2st: %08x \",\n\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[2]);\n\t\t\t\t\tIPACMDBG(\"3st: %08x \\n\",\n\t\t\t\t\t\t\t\t\t data_addr->ipv6_addr_mask[3]);\n\n\t\t\t\t\tdata_addr->ipv6_addr_mask[0] = ntohl(data_addr->ipv6_addr_mask[0]);\n\t\t\t\t\tdata_addr->ipv6_addr_mask[1] = ntohl(data_addr->ipv6_addr_mask[1]);\n\t\t\t\t\tdata_addr->ipv6_addr_mask[2] = ntohl(data_addr->ipv6_addr_mask[2]);\n\t\t\t\t\tdata_addr->ipv6_addr_mask[3] = ntohl(data_addr->ipv6_addr_mask[3]);\n\n\t\t\t\t\tevt_data.event = IPA_ROUTE_DEL_EVENT;\n\t\t\t\t\tdata_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;\n\t\t\t\t\tdata_addr->iptype = IPA_IP_v6;\n\n\t\t\t\t\tIPACMDBG_H(\"posting event IPA_ROUTE_DEL_EVENT with if index:%d, ipv4 address\\n\",\n\t\t\t\t\t\t\t\t\t data_addr->if_index);\n\t\t\t\t\tevt_data.evt_data = data_addr;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t/* finish command queue */\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase RTM_NEWNEIGH:\n\t\t\tif(IPACM_SUCCESS != ipa_nl_decode_rtm_neigh(buffer, buflen, &(msg_ptr->nl_neigh_info)))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to decode rtm neighbor message\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\n\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_neigh_info.metainfo.ndm_ifindex);\n\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error while getting interface index\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tIPACMDBG(\"\\n GOT RTM_NEWNEIGH event (%s) ip %d\\n\",dev_name,msg_ptr->nl_neigh_info.attr_info.local_addr.ss_family);\n\t\t\t}\n\n\t\t\t\t\t/* insert to command queue */\n\t\t    data_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));\n\t\t    if(data_all == NULL)\n\t\t\t\t\t{\n\t\t    \tIPACMERR(\"unable to allocate memory for event data_all\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t    memset(data_all, 0, sizeof(ipacm_event_data_all));\n\t\t    if(msg_ptr->nl_neigh_info.attr_info.local_addr.ss_family == AF_INET6)\n\t\t    {\n\t\t\t\tIPACM_NL_REPORT_ADDR( \" \", msg_ptr->nl_neigh_info.attr_info.local_addr);\n\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_all->ipv6_addr, msg_ptr->nl_neigh_info.attr_info.local_addr);\n\n                      data_all->ipv6_addr[0]=ntohl(data_all->ipv6_addr[0]);\n                      data_all->ipv6_addr[1]=ntohl(data_all->ipv6_addr[1]);\n                      data_all->ipv6_addr[2]=ntohl(data_all->ipv6_addr[2]);\n                      data_all->ipv6_addr[3]=ntohl(data_all->ipv6_addr[3]);\n\t\t    \tdata_all->iptype = IPA_IP_v6;\n\t\t    }\n\t\t    else if (msg_ptr->nl_neigh_info.attr_info.local_addr.ss_family == AF_INET)\n\t\t    {\n   \t\t\t\tIPACM_NL_REPORT_ADDR( \" \", msg_ptr->nl_neigh_info.attr_info.local_addr);\n\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( data_all->ipv4_addr, msg_ptr->nl_neigh_info.attr_info.local_addr);\n\t\t    \tdata_all->ipv4_addr = ntohl(data_all->ipv4_addr);\n\t\t    \tdata_all->iptype = IPA_IP_v4;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t        data_all->iptype = IPA_IP_v6;\n\t\t    }\n\n\t\t    IPACMDBG(\"NDA_LLADDR:MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[0],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[1],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[2],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[3],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[4],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[5]);\n\n\n\t\t    memcpy(data_all->mac_addr,\n\t\t    \t\t\t msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr.sa_data,\n\t\t    \t\t\t sizeof(data_all->mac_addr));\n\t\t    evt_data.event = IPA_NEW_NEIGH_EVENT;\n\t\t    data_all->if_index = msg_ptr->nl_neigh_info.metainfo.ndm_ifindex;\n\n\t\t    IPACMDBG_H(\"posting IPA_NEW_NEIGH_EVENT (%s):index:%d ip-family: %d\\n\",\n                                 dev_name,\n \t\t                    data_all->if_index,\n\t\t    \t\t\t\t msg_ptr->nl_neigh_info.attr_info.local_addr.ss_family);\n\t\t    evt_data.evt_data = data_all;\n\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t/* finish command queue */\n\t\t\tbreak;\n\n\t\tcase RTM_DELNEIGH:\n\t\t\tif(IPACM_SUCCESS != ipa_nl_decode_rtm_neigh(buffer, buflen, &(msg_ptr->nl_neigh_info)))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to decode rtm neighbor message\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\n\t\t\tret_val = ipa_get_if_name(dev_name, msg_ptr->nl_neigh_info.metainfo.ndm_ifindex);\n\t\t\tif(ret_val != IPACM_SUCCESS)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error while getting interface index\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG(\"\\n GOT RTM_DELNEIGH event (%s) ip %d\\n\",dev_name,msg_ptr->nl_neigh_info.attr_info.local_addr.ss_family);\n\t\t\t}\n\n\t\t\t\t/* insert to command queue */\n\t\t\t\tdata_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));\n\t\t\t\tif(data_all == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to allocate memory for event data_all\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\n\t\t    memset(data_all, 0, sizeof(ipacm_event_data_all));\n\t\t    if(msg_ptr->nl_neigh_info.attr_info.local_addr.ss_family == AF_INET6)\n\t\t\t\t{\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \" \", msg_ptr->nl_neigh_info.attr_info.local_addr);\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v6( data_all->ipv6_addr, msg_ptr->nl_neigh_info.attr_info.local_addr);\n\n\t\t\t\t\tdata_all->ipv6_addr[0] = ntohl(data_all->ipv6_addr[0]);\n\t\t\t\t\tdata_all->ipv6_addr[1] = ntohl(data_all->ipv6_addr[1]);\n\t\t\t\t\tdata_all->ipv6_addr[2] = ntohl(data_all->ipv6_addr[2]);\n\t\t\t\t\tdata_all->ipv6_addr[3] = ntohl(data_all->ipv6_addr[3]);\n\t\t\t\t\tdata_all->iptype = IPA_IP_v6;\n\t\t\t\t}\n\t\t    else if (msg_ptr->nl_neigh_info.attr_info.local_addr.ss_family == AF_INET)\n\t\t\t\t{\n\t\t\t\t\tIPACM_NL_REPORT_ADDR( \" \", msg_ptr->nl_neigh_info.attr_info.local_addr);\n\t\t\t\t\tIPACM_EVENT_COPY_ADDR_v4( data_all->ipv4_addr, msg_ptr->nl_neigh_info.attr_info.local_addr);\n\t\t\t\t\tdata_all->ipv4_addr = ntohl(data_all->ipv4_addr);\n\t\t\t\t\tdata_all->iptype = IPA_IP_v4;\n\t\t\t\t}\n\t\t    else\n\t\t    {\n\t\t        data_all->iptype = IPA_IP_v6;\n\t\t    }\n\n\t\t    IPACMDBG(\"NDA_LLADDR:MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[0],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[1],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[2],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[3],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[4],\n\t\t     (unsigned char)(msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr).sa_data[5]);\n\n\t\t\t\tmemcpy(data_all->mac_addr,\n\t\t\t\t\t\t\t msg_ptr->nl_neigh_info.attr_info.lladdr_hwaddr.sa_data,\n\t\t\t\t\t\t\t sizeof(data_all->mac_addr));\n\t\t    evt_data.event = IPA_DEL_NEIGH_EVENT;\n\t\t\t\tdata_all->if_index = msg_ptr->nl_neigh_info.metainfo.ndm_ifindex;\n\n\t\t    IPACMDBG_H(\"posting IPA_DEL_NEIGH_EVENT (%s):index:%d ip-family: %d\\n\",\n                                 dev_name,\n \t\t                    data_all->if_index,\n\t\t    \t\t\t\t msg_ptr->nl_neigh_info.attr_info.local_addr.ss_family);\n\t\t\t\tevt_data.evt_data = data_all;\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t/* finish command queue */\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tIPACMDBG(\" ignore NL event %d!!!\\n \", nlh->nlmsg_type);\n\t\t\tbreak;\n\n\t\t}\n\t\tnlh = NLMSG_NEXT(nlh, buflen);\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n\n/*  Virtual function registered to receive incoming messages over the NETLINK routing socket*/\nint ipa_nl_recv_msg(int fd)\n{\n\tstruct msghdr *msghdr = NULL;\n\tstruct iovec *iov = NULL;\n\tunsigned int msglen = 0;\n\tipa_nl_msg_t *nlmsg = NULL;\n\n\tnlmsg = (ipa_nl_msg_t *)malloc(sizeof(ipa_nl_msg_t));\n\tif(NULL == nlmsg)\n\t{\n\t\tIPACMERR(\"Failed alloc of nlmsg \\n\");\n\t\tgoto error;\n\t}\n\telse\n\t{\n\t\tif(IPACM_SUCCESS != ipa_nl_recv(fd, &msghdr, &msglen))\n\t\t{\n\t\t\tIPACMERR(\"Failed to receive nl message \\n\");\n\t\t\tgoto error;\n\t\t}\n\n\t\tif(msghdr== NULL)\n\t\t{\n\t\t\tIPACMERR(\" failed to get msghdr\\n\");\n\t\t\tgoto error;\n\t\t}\n\n\t\tiov = msghdr->msg_iov;\n\n\t\tmemset(nlmsg, 0, sizeof(ipa_nl_msg_t));\n\t\tif(IPACM_SUCCESS != ipa_nl_decode_nlmsg((char *)iov->iov_base, msglen, nlmsg))\n\t\t{\n\t\t\tIPACMERR(\"Failed to decode nl message \\n\");\n\t\t\tgoto error;\n\t\t}\n\t\t/* Release NetLink message buffer */\n\t\tif(msghdr)\n\t\t{\n\t\t\tipa_nl_release_msg(msghdr);\n\t\t}\n\t\tif(nlmsg)\n\t\t{\n\t\t\tfree(nlmsg);\n\t\t}\n\t}\n\n\treturn IPACM_SUCCESS;\n\nerror:\n\tif(msghdr)\n\t{\n\t\tipa_nl_release_msg(msghdr);\n\t}\n\tif(nlmsg)\n\t{\n\t\tfree(nlmsg);\n\t}\n\n\treturn IPACM_FAILURE;\n}\n\n/*  get ipa interface name */\nint ipa_get_if_name\n(\n\t char *if_name,\n\t int if_index\n\t )\n{\n\tint fd;\n\tstruct ifreq ifr;\n\n\tif((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)\n\t{\n\t\tIPACMERR(\"get interface name socket create failed \\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tmemset(&ifr, 0, sizeof(struct ifreq));\n\tifr.ifr_ifindex = if_index;\n\tIPACMDBG(\"Interface index %d\\n\", if_index);\n\n\tif(ioctl(fd, SIOCGIFNAME, &ifr) < 0)\n\t{\n\t\tIPACMERR(\"call_ioctl_on_dev: ioctl failed:\\n\");\n\t\tclose(fd);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t(void)strncpy(if_name, ifr.ifr_name, sizeof(ifr.ifr_name));\n\tIPACMDBG(\"interface name %s\\n\", ifr.ifr_name);\n\tclose(fd);\n\n\treturn IPACM_SUCCESS;\n}\n\n/* Initialization routine for listener on NetLink sockets interface */\nint ipa_nl_listener_init\n(\n\t unsigned int nl_type,\n\t unsigned int nl_groups,\n\t ipa_nl_sk_fd_set_info_t *sk_fdset,\n\t ipa_sock_thrd_fd_read_f read_f\n\t )\n{\n\tipa_nl_sk_info_t sk_info;\n\tint ret_val;\n\n\tmemset(&sk_info, 0, sizeof(ipa_nl_sk_info_t));\n\tIPACMDBG_H(\"Entering IPA NL listener init\\n\");\n\n\tif(ipa_nl_open_socket(&sk_info, nl_type, nl_groups) == IPACM_SUCCESS)\n\t{\n\t\tIPACMDBG_H(\"IPA Open netlink socket succeeds\\n\");\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"Netlink socket open failed\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* Add NETLINK socket to the list of sockets that the listener\n\t\t\t\t\t thread should listen on. */\n\n\tif(ipa_nl_addfd_map(sk_fdset, sk_info.sk_fd, read_f) != IPACM_SUCCESS)\n\t{\n\t\tIPACMERR(\"cannot add nl routing sock for reading\\n\");\n\t\tclose(sk_info.sk_fd);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* Start the socket listener thread */\n\tret_val = ipa_nl_sock_listener_start(sk_fdset);\n\n\tif(ret_val != IPACM_SUCCESS)\n\t{\n\t\tIPACMERR(\"Failed to start NL listener\\n\");\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* find the newroute subnet mask */\nint find_mask(int ip_v4_last, int *mask_value)\n{\n\n\tswitch(ip_v4_last)\n\t{\n\n\tcase 3:\n\t\t*mask_value = 252;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\n\tcase 7:\n\t\t*mask_value = 248;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\n\tcase 15:\n\t\t*mask_value = 240;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\n\tcase 31:\n\t\t*mask_value = 224;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\n\tcase 63:\n\t\t*mask_value = 192;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\n\tcase 127:\n\t\t*mask_value = 128;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\n\tcase 255:\n\t\t*mask_value = 0;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\n\tdefault:\n\t\treturn IPACM_FAILURE;\n\t\tbreak;\n\n\t}\n}\n\n/* map mask value for ipv6 */\nint mask_v6(int index, uint32_t *mask)\n{\n\tswitch(index)\n\t{\n\n\tcase 0:\n\t\t*mask = 0x00000000;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tcase 4:\n\t\t*mask = 0xf0000000;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tcase 8:\n\t\t*mask = 0xff000000;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tcase 12:\n\t\t*mask = 0xfff00000;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tcase 16:\n\t\t*mask = 0xffff0000;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tcase 20:\n\t\t*mask = 0xfffff000;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tcase 24:\n\t\t*mask = 0xffffff00;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tcase 28:\n\t\t*mask = 0xfffffff0;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tcase 32:\n\t\t*mask = 0xffffffff;\n\t\treturn IPACM_SUCCESS;\n\t\tbreak;\n\tdefault:\n\t\treturn IPACM_FAILURE;\n\t\tbreak;\n\n\t}\n}\n\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Routing.cpp",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_Routing.cpp\n\n\t@brief\n\tThis file implements the IPACM routing functionality.\n\n\t@Author\n\n*/\n\n#include <unistd.h>\n#include <sys/ioctl.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"IPACM_Routing.h\"\n#include <IPACM_Log.h>\n\nconst char *IPACM_Routing::DEVICE_NAME = \"/dev/ipa\";\n\nIPACM_Routing::IPACM_Routing()\n{\n\tm_fd = open(DEVICE_NAME, O_RDWR);\n\tif (0 == m_fd)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", DEVICE_NAME);\n\t}\n}\n\nIPACM_Routing::~IPACM_Routing()\n{\n\tclose(m_fd);\n}\n\nbool IPACM_Routing::DeviceNodeIsOpened()\n{\n\tint res = fcntl(m_fd, F_GETFL);\n\n\tif (m_fd > 0 && res >= 0) return true;\n\telse return false;\n\n}\n\nbool IPACM_Routing::AddRoutingRule(struct ipa_ioc_add_rt_rule *ruleTable)\n{\n\tint retval = 0;\n\n\tif (!DeviceNodeIsOpened())\n\t{\n\t\tIPACMERR(\"Device is not opened\\n\");\n\t\treturn false;\n\t}\n\n\tretval = ioctl(m_fd, IPA_IOC_ADD_RT_RULE, ruleTable);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"Failed adding routing rule %p\\n\", ruleTable);\n\t\treturn false;\n\t}\n\n\tIPACMDBG_H(\"Added routing rule %p\\n\", ruleTable);\n\treturn true;\n}\n\nbool IPACM_Routing::DeleteRoutingRule(struct ipa_ioc_del_rt_rule *ruleTable)\n{\n\tint retval = 0;\n\n\tif (!DeviceNodeIsOpened()) return false;\n\n\tretval = ioctl(m_fd, IPA_IOC_DEL_RT_RULE, ruleTable);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"Failed deleting routing rule table %p\\n\", ruleTable);\n\t\treturn false;\n\t}\n\n\tIPACMDBG_H(\"Deleted routing rule %p\\n\", ruleTable);\n\treturn true;\n}\n\nbool IPACM_Routing::Commit(enum ipa_ip_type ip)\n{\n\tint retval = 0;\n\n\tif (!DeviceNodeIsOpened()) return false;\n\n\tretval = ioctl(m_fd, IPA_IOC_COMMIT_RT, ip);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"Failed commiting routing rules.\\n\");\n\t\treturn false;\n\t}\n\n\tIPACMDBG_H(\"Commited routing rules to IPA HW.\\n\");\n\treturn true;\n}\n\nbool IPACM_Routing::Reset(enum ipa_ip_type ip)\n{\n\tint retval = 0;\n\n\tif (!DeviceNodeIsOpened()) return false;\n\n\tretval = ioctl(m_fd, IPA_IOC_RESET_RT, ip);\n\tretval |= ioctl(m_fd, IPA_IOC_COMMIT_RT, ip);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"Failed resetting routing block.\\n\");\n\t\treturn false;\n\t}\n\n\tIPACMDBG_H(\"Reset command issued to IPA routing block.\\n\");\n\treturn true;\n}\n\nbool IPACM_Routing::GetRoutingTable(struct ipa_ioc_get_rt_tbl *routingTable)\n{\n\tint retval = 0;\n\n\tif (!DeviceNodeIsOpened()) return false;\n\n\tretval = ioctl(m_fd, IPA_IOC_GET_RT_TBL, routingTable);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"IPA_IOCTL_GET_RT_TBL ioctl failed, routingTable =0x%p, retval=0x%x.\\n\", routingTable, retval);\n\t\treturn false;\n\t}\n\n\tIPACMDBG_H(\"IPA_IOCTL_GET_RT_TBL ioctl issued to IPA routing block.\\n\");\n\treturn true;\n}\n\nbool IPACM_Routing::PutRoutingTable(uint32_t routingTableHandle)\n{\n\tint retval = 0;\n\n\tif (!DeviceNodeIsOpened()) return false;\n\n\tretval = ioctl(m_fd, IPA_IOC_PUT_RT_TBL, routingTableHandle);\n\tif (retval)\n\t{\n\t\tIPACMERR(\"IPA_IOCTL_PUT_RT_TBL ioctl failed.\\n\");\n\t\treturn false;\n\t}\n\n\tIPACMDBG_H(\"IPA_IOCTL_PUT_RT_TBL ioctl issued to IPA routing block.\\n\");\n\treturn true;\n}\n\nbool IPACM_Routing::DeleteRoutingHdl(uint32_t rt_rule_hdl, ipa_ip_type ip)\n{\n\tconst uint8_t NUM_RULES = 1;\n\tstruct ipa_ioc_del_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_del *rt_rule_entry;\n\tbool res = true;\n\tint len = 0;\n\n\tif (rt_rule_hdl == 0)\n\t{\n\t\tIPACMERR(\" No route handle passed. Ignoring it\\n\");\n\t\treturn res;\n\t}\n\n\tlen = (sizeof(struct ipa_ioc_del_rt_rule)) + (NUM_RULES * sizeof(struct ipa_rt_rule_del));\n\trt_rule = (struct ipa_ioc_del_rt_rule *)malloc(len);\n\tif (rt_rule == NULL)\n\t{\n\t\tIPACMERR(\"unable to allocate memory for del route rule\\n\");\n\t\treturn false;\n\t}\n\n\tmemset(rt_rule, 0, len);\n\trt_rule->commit = 1;\n\trt_rule->num_hdls = NUM_RULES;\n\trt_rule->ip = ip;\n\n\trt_rule_entry = &rt_rule->hdl[0];\n\trt_rule_entry->status = -1;\n\trt_rule_entry->hdl = rt_rule_hdl;\n\n\tIPACMDBG_H(\"Deleting Route hdl:(0x%x) with ip type: %d\\n\", rt_rule_entry->hdl, ip);\n\tif ((false == DeleteRoutingRule(rt_rule)) ||\n\t\t\t(rt_rule_entry->status))\n\t{\n\t\tPERROR(\"Routing rule deletion failed!\\n\");\n\t\tgoto fail;\n\t\tres = false;\n\t}\n\nfail:\n\tfree(rt_rule);\n\n\treturn res;\n}\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t\t@file\n\t\tIPACM_Wan.cpp\n\n\t\t@brief\n\t\tThis file implements the WAN iface functionality.\n\n\t\t@Author\n\t\tSkylar Chang\n\n*/\n#include <string.h>\n#include <fcntl.h>\n#include <sys/ioctl.h>\n#include <IPACM_Wan.h>\n#include <IPACM_Xml.h>\n#include <IPACM_Log.h>\n#include \"IPACM_EvtDispatcher.h\"\n#include <IPACM_IfaceManager.h>\n#include \"linux/rmnet_ipa_fd_ioctl.h\"\n#include \"IPACM_Config.h\"\n#include \"IPACM_Defs.h\"\n#include <IPACM_ConntrackListener.h>\n#include \"linux/ipa_qmi_service_v01.h\"\n\nbool IPACM_Wan::wan_up = false;\nbool IPACM_Wan::wan_up_v6 = false;\n\nint IPACM_Wan::num_v4_flt_rule = 0;\nint IPACM_Wan::num_v6_flt_rule = 0;\n\nstruct ipa_flt_rule_add IPACM_Wan::flt_rule_v4[IPA_MAX_FLT_RULE];\nstruct ipa_flt_rule_add IPACM_Wan::flt_rule_v6[IPA_MAX_FLT_RULE];\n\nchar IPACM_Wan::wan_up_dev_name[IF_NAME_LEN];\n\nbool IPACM_Wan::backhaul_is_sta_mode = false;\nbool IPACM_Wan::is_ext_prop_set = false;\n\nint IPACM_Wan::num_ipv4_modem_pdn = 0;\nint IPACM_Wan::num_ipv6_modem_pdn = 0;\n\nbool IPACM_Wan::embms_is_on = false;\n\nuint32_t IPACM_Wan::backhaul_ipv6_prefix[2];\n\n#ifdef FEATURE_IPA_ANDROID\nint\tIPACM_Wan::ipa_if_num_tether_v4_total = 0;\nint\tIPACM_Wan::ipa_if_num_tether_v6_total = 0;\n\nint\tIPACM_Wan::ipa_if_num_tether_v4[IPA_MAX_IFACE_ENTRIES];\nint\tIPACM_Wan::ipa_if_num_tether_v6[IPA_MAX_IFACE_ENTRIES];\n#endif\n\nIPACM_Wan::IPACM_Wan(int iface_index,\n       ipacm_wan_iface_type is_sta_mode,\n       uint8_t *mac_addr) : IPACM_Iface(iface_index)\n{\n\tnum_firewall_v4 = 0;\n\tnum_firewall_v6 = 0;\n\twan_route_rule_v4_hdl = NULL;\n\twan_route_rule_v6_hdl = NULL;\n\twan_route_rule_v6_hdl_a5 = NULL;\n\twan_client = NULL;\n\n\tif(iface_query != NULL)\n\t{\n\t\twan_route_rule_v4_hdl = (uint32_t *)calloc(iface_query->num_tx_props, sizeof(uint32_t));\n\t\twan_route_rule_v6_hdl = (uint32_t *)calloc(iface_query->num_tx_props, sizeof(uint32_t));\n\t\twan_route_rule_v6_hdl_a5 = (uint32_t *)calloc(iface_query->num_tx_props, sizeof(uint32_t));\n\t\tIPACMDBG_H(\"IPACM->IPACM_Wan(%d) constructor: Tx:%d\\n\", ipa_if_num, iface_query->num_tx_props);\n\t}\n\tm_is_sta_mode = is_sta_mode;\n\n\tactive_v4 = false;\n\tactive_v6 = false;\n\theader_set_v4 = false;\n\theader_set_v6 = false;\n\theader_partial_default_wan_v4 = false;\n\theader_partial_default_wan_v6 = false;\n\thdr_hdl_sta_v4 = 0;\n\thdr_hdl_sta_v6 = 0;\n\tnum_ipv6_dest_flt_rule = 0;\n\tmemset(ipv6_dest_flt_rule_hdl, 0, MAX_DEFAULT_v6_ROUTE_RULES*sizeof(uint32_t));\n\tmemset(ipv6_prefix, 0, sizeof(ipv6_prefix));\n\text_prop = NULL;\n\n\tnum_wan_client = 0;\n\theader_name_count = 0;\n\tmemset(invalid_mac, 0, sizeof(invalid_mac));\n\tif(iface_query != NULL)\n\t{\n\t\twan_client_len = (sizeof(ipa_wan_client)) + (iface_query->num_tx_props * sizeof(wan_client_rt_hdl));\n\t\twan_client = (ipa_wan_client *)calloc(IPA_MAX_NUM_WAN_CLIENTS, wan_client_len);\n\t\tif (wan_client == NULL)\n\t\t{\n\t\t\tIPACMERR(\"unable to allocate memory\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"index:%d constructor: Tx properties:%d\\n\", iface_index, iface_query->num_tx_props);\n\t}\n\n\n\tif(m_is_sta_mode == Q6_WAN)\n\t{\n\t\tIPACMDBG_H(\"The new WAN interface is modem.\\n\");\n\t\tis_default_gateway = false;\n\t\tquery_ext_prop();\n\t}\n\telse\n\t{\n\t\tIPACMDBG_H(\"The new WAN interface is WLAN STA.\\n\");\n\t}\n\n\tif(m_is_sta_mode == WLAN_WAN)\n\t{\n\t\tmemcpy(ext_router_mac_addr, mac_addr,\n\t\t\tsizeof(ext_router_mac_addr));\n\t}\n\n\tm_fd_ipa = open(IPA_DEVICE_NAME, O_RDWR);\n\tif(0 == m_fd_ipa)\n\t{\n\t\tIPACMERR(\"Failed to open %s\\n\",IPA_DEVICE_NAME);\n\t}\n\n\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == EMBMS_IF)\n\t{\n\t\tIPACMDBG(\" IPACM->IPACM_Wan_eMBMS(%d)\\n\", ipa_if_num);\n\t\tembms_is_on = true;\n\t\tinstall_wan_filtering_rule(false);\n\t\t/* Add corresponding ipa_rm_resource_name of TX-endpoint up before IPV6 RT-rule set */\n\t\tif(tx_prop != NULL)\n\t\t{\n\t\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n        \tIPACM_Iface::ipacmcfg->AddRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe],false);\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMDBG(\" IPACM->IPACM_Wan(%d)\\n\", ipa_if_num);\n\t}\n\treturn;\n}\n\nIPACM_Wan::~IPACM_Wan()\n{\n\tIPACM_EvtDispatcher::deregistr(this);\n\tIPACM_IfaceManager::deregistr(this);\n\treturn;\n}\n\n/* handle new_address event */\nint IPACM_Wan::handle_addr_evt(ipacm_event_data_addr *data)\n{\n\tstruct ipa_ioc_add_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_add *rt_rule_entry;\n\tstruct ipa_ioc_add_flt_rule *flt_rule;\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\n\tconst int NUM_RULES = 1;\n\tint num_ipv6_addr, len;\n\tint res = IPACM_SUCCESS;\n\n\tif (data->iptype == IPA_IP_v6)\n\t{\n\t    for(num_ipv6_addr=0;num_ipv6_addr<num_dft_rt_v6;num_ipv6_addr++)\n\t    {\n               if((ipv6_addr[num_ipv6_addr][0] == data->ipv6_addr[0]) &&\n\t           (ipv6_addr[num_ipv6_addr][1] == data->ipv6_addr[1]) &&\n\t            (ipv6_addr[num_ipv6_addr][2] == data->ipv6_addr[2]) &&\n\t                (ipv6_addr[num_ipv6_addr][3] == data->ipv6_addr[3]))\n               {\n\t   \t\t   IPACMDBG_H(\"find matched ipv6 address, index:%d \\n\", num_ipv6_addr);\n\t           return IPACM_SUCCESS;\n\t           break;\n\t       }\n\t    }\n\t    rt_rule = (struct ipa_ioc_add_rt_rule *)\n\t    \t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t    \t\t\t\t\tNUM_RULES * sizeof(struct ipa_rt_rule_add));\n\n\t    if (!rt_rule)\n\t    {\n\t    \tIPACMERR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t    \treturn IPACM_FAILURE;\n\t    }\n\n\t    rt_rule->commit = 1;\n\t    rt_rule->num_rules = NUM_RULES;\n\t    rt_rule->ip = data->iptype;\n\t    \tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_v6.name);\n\n\t    rt_rule_entry = &rt_rule->rules[0];\n\t    rt_rule_entry->at_rear = false;\n\t    rt_rule_entry->rule.dst = iface_query->excp_pipe;  //go to A5\n\t    rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;\n\t    \trt_rule_entry->rule.attrib.u.v6.dst_addr[0] = data->ipv6_addr[0];\n\t    \trt_rule_entry->rule.attrib.u.v6.dst_addr[1] = data->ipv6_addr[1];\n\t    \trt_rule_entry->rule.attrib.u.v6.dst_addr[2] = data->ipv6_addr[2];\n\t    \trt_rule_entry->rule.attrib.u.v6.dst_addr[3] = data->ipv6_addr[3];\n\t    \trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t    \trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t    \trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t    \trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\t    \tipv6_addr[num_dft_rt_v6][0] = data->ipv6_addr[0];\n\t    \tipv6_addr[num_dft_rt_v6][1] = data->ipv6_addr[1];\n\t    \tipv6_addr[num_dft_rt_v6][2] = data->ipv6_addr[2];\n\t    \tipv6_addr[num_dft_rt_v6][3] = data->ipv6_addr[3];\n\n\t        if (false == m_routing.AddRoutingRule(rt_rule))\n\t        {\n\t        \tIPACMERR(\"Routing rule addition failed!\\n\");\n\t        \tres = IPACM_FAILURE;\n\t        \tgoto fail;\n\t    }\n\t        else if (rt_rule_entry->status)\n\t    {\n\t        \tIPACMERR(\"rt rule adding failed. Result=%d\\n\", rt_rule_entry->status);\n\t        \tres = rt_rule_entry->status;\n\t        \tgoto fail;\n\t        }\n\t    \tdft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6] = rt_rule_entry->rt_rule_hdl;\n\n            /* setup same rule for v6_wan table*/\n\t    \tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name);\n\t    if (false == m_routing.AddRoutingRule(rt_rule))\n\t    {\n\t    \tIPACMERR(\"Routing rule addition failed!\\n\");\n\t    \tres = IPACM_FAILURE;\n\t    \tgoto fail;\n\t    }\n\t    else if (rt_rule_entry->status)\n\t    {\n\t    \tIPACMERR(\"rt rule adding failed. Result=%d\\n\", rt_rule_entry->status);\n\t    \tres = rt_rule_entry->status;\n\t    \tgoto fail;\n\t    }\n\t    \tdft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6+1] = rt_rule_entry->rt_rule_hdl;\n\n\t    \tIPACMDBG_H(\"ipv6 wan iface rt-rule hdl=0x%x hdl=0x%x, num_dft_rt_v6: %d \\n\",\n\t    \t          dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6],\n\t    \t          dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6+1],num_dft_rt_v6);\n\n        if (num_dft_rt_v6 == 0)\n\t    {\n\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t{\n\t\t\t\tmodem_ipv6_pdn_index = num_ipv6_modem_pdn;\n\t\t\t\tnum_ipv6_modem_pdn++;\n\t\t\t\tIPACMDBG_H(\"Now the number of modem ipv6 pdn is %d.\\n\", num_ipv6_modem_pdn);\n\t\t\t\tinit_fl_rule_ex(data->iptype);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tinit_fl_rule(data->iptype);\n\t\t\t}\n\t    }\n\n\t\t/* add WAN DL interface IP specific flt rule for IPv6 when backhaul is not Q6 */\n\t\tif(m_is_sta_mode != Q6_WAN)\n\t\t{\n\t\t\tif(rx_prop != NULL && is_global_ipv6_addr(data->ipv6_addr)\n\t\t\t\t&& num_ipv6_dest_flt_rule < MAX_DEFAULT_v6_ROUTE_RULES)\n\t\t\t{\n\t\t\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);\n\n\t\t\t\tflt_rule = (struct ipa_ioc_add_flt_rule *)calloc(1, len);\n\t\t\t\tif (!flt_rule)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\n\t\t\t\tflt_rule->commit = 1;\n\t\t\t\tflt_rule->ep = rx_prop->rx[0].src_pipe;\n\t\t\t\tflt_rule->global = false;\n\t\t\t\tflt_rule->ip = IPA_IP_v6;\n\t\t\t\tflt_rule->num_rules = 1;\n\n\t\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\t\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\t\t\tflt_rule_entry.rule.to_uc = 0;\n\t\t\t\tflt_rule_entry.rule.eq_attrib_type = 0;\n\t\t\t\tflt_rule_entry.at_rear = true;\n\t\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\t\tflt_rule_entry.status = -1;\n\t\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\t\t\t\tmemcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));\n\n\t\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\t\tmemcpy(flt_rule_entry.rule.attrib.u.v6.dst_addr, data->ipv6_addr, sizeof(flt_rule_entry.rule.attrib.u.v6.dst_addr));\n\t\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\t\t\t\tmemcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\t\tif (m_filtering.AddFilteringRule(flt_rule) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error Adding Filtering rule, aborting...\\n\");\n\t\t\t\t\tfree(flt_rule);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tipv6_dest_flt_rule_hdl[num_ipv6_dest_flt_rule] = flt_rule->rules[0].flt_rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"IPv6 dest filter rule %d HDL:0x%x\\n\", num_ipv6_dest_flt_rule, ipv6_dest_flt_rule_hdl[num_ipv6_dest_flt_rule]);\n\t\t\t\t\tnum_ipv6_dest_flt_rule++;\n\t\t\t\t\tfree(flt_rule);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t/* store ipv6 prefix if the ipv6 address is not link local */\n\t\tif(is_global_ipv6_addr(data->ipv6_addr))\n\t\t{\n\t\t\tmemcpy(ipv6_prefix, data->ipv6_addr, sizeof(ipv6_prefix));\n\t\t}\n\t    num_dft_rt_v6++;\n    }\n\telse\n\t{\n\t\trt_rule = (struct ipa_ioc_add_rt_rule *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t\t\t\t\t\t\tNUM_RULES * sizeof(struct ipa_rt_rule_add));\n\n\t\tif (!rt_rule)\n\t\t{\n\t\tIPACMERR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\trt_rule->commit = 1;\n\t\trt_rule->num_rules = NUM_RULES;\n\t\trt_rule->ip = data->iptype;\n\t\trt_rule_entry = &rt_rule->rules[0];\n\t\trt_rule_entry->at_rear = false;\n\t\trt_rule_entry->rule.dst = iface_query->excp_pipe;  //go to A5\n\t\trt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;\n\t\t/* still need setup v4 default routing rule to A5*/\n\t\tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name);\n\t\trt_rule_entry->rule.attrib.u.v4.dst_addr      = data->ipv4_addr;\n\t\trt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\n\t\tif (false == m_routing.AddRoutingRule(rt_rule))\n\t\t{\n\t\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse if (rt_rule_entry->status)\n\t\t{\n\t\t\tIPACMERR(\"rt rule adding failed. Result=%d\\n\", rt_rule_entry->status);\n\t\t\tres = rt_rule_entry->status;\n\t\t\tgoto fail;\n\t\t}\n\t\tdft_rt_rule_hdl[0] = rt_rule_entry->rt_rule_hdl;\n\t\tIPACMDBG_H(\"ipv4 wan iface rt-rule hdll=0x%x\\n\", dft_rt_rule_hdl[0]);\n\t\t\t/* initial multicast/broadcast/fragment filter rule */\n\n\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t{\n\t\t\tmodem_ipv4_pdn_index = num_ipv4_modem_pdn;\n\t\t\tnum_ipv4_modem_pdn++;\n\t\t\tIPACMDBG_H(\"Now the number of modem ipv4 pdn is %d.\\n\", num_ipv4_modem_pdn);\n\t\t\tinit_fl_rule_ex(data->iptype);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tinit_fl_rule(data->iptype);\n\t\t}\n\n\t\twan_v4_addr = data->ipv4_addr;\n\t\tIPACMDBG_H(\"Receved wan address:0x%x\\n\",wan_v4_addr);\n\t}\n\n\tIPACMDBG_H(\"number of default route rules %d\\n\", num_dft_rt_v6);\n\nfail:\n\tfree(rt_rule);\n\n\treturn res;\n}\n\nvoid IPACM_Wan::event_callback(ipa_cm_event_id event, void *param)\n{\n\tint ipa_interface_index;\n\n\tswitch (event)\n\t{\n\tcase IPA_WLAN_LINK_DOWN_EVENT:\n\t\t{\n\t\t\tif(m_is_sta_mode == WLAN_WAN)\n\t\t\t{\n\t\t\t\tipacm_event_data_fid *data = (ipacm_event_data_fid *)param;\n\t\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Received IPA_WLAN_LINK_DOWN_EVENT\\n\");\n\t\t\t\t\thandle_down_evt();\n\t\t\t\t\t/* reset the STA-iface category to unknown */\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat = UNKNOWN_IF;\n\t\t\t\t\tIPACMDBG_H(\"IPA_WAN_STA (%s):ipa_index (%d) instance close \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ipa_if_num);\n\t\t\t\t\tIPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface\n\t\t\t\t\tdelete this;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_CFG_CHANGE_EVENT:\n\t\t{\n\t\t\tif ( (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat != ipa_if_cate) &&\n\t\t\t\t\t(m_is_sta_mode ==ECM_WAN))\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_CFG_CHANGE_EVENT and category changed(wan_mode:%d)\\n\", m_is_sta_mode);\n\t\t\t\t/* posting link-up event for cradle use-case */\n\t\t\t\tipacm_cmd_q_data evt_data;\n\t\t\t\tmemset(&evt_data, 0, sizeof(evt_data));\n\n\t\t\t\tipacm_event_data_fid *data_fid = NULL;\n\t\t\t\tdata_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));\n\t\t\t\tif(data_fid == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"unable to allocate memory for IPA_USB_LINK_UP_EVENT data_fid\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif(IPACM_Iface::ipa_get_if_index(dev_name, &(data_fid->if_index)))\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error while getting interface index for %s device\", dev_name);\n\t\t\t\t}\n\t\t\t\tevt_data.event = IPA_USB_LINK_UP_EVENT;\n\t\t\t\tevt_data.evt_data = data_fid;\n\t\t\t\tIPACMDBG_H(\"Posting event:%d\\n\", evt_data.event);\n\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\n\t\t\t\t/* delete previous instance */\n\t\t\t\thandle_down_evt();\n\t\t\t\tIPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface\n\t\t\t\tdelete this;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_LINK_DOWN_EVENT:\n\t\t{\n\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t{\n\t\t\t\tipacm_event_data_fid *data = (ipacm_event_data_fid *)param;\n\t\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Received IPA_LINK_DOWN_EVENT\\n\");\n\t\t\t\t\thandle_down_evt_ex();\n\t\t\t\t\tIPACMDBG_H(\"IPA_WAN_Q6 (%s):ipa_index (%d) instance close \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ipa_if_num);\n\t\t\t\t\tIPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface\n\t\t\t\t\tdelete this;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_is_sta_mode == ECM_WAN)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_LINK_DOWN_EVENT(wan_mode:%d)\\n\", m_is_sta_mode);\n\t\t\t\t/* delete previous instance */\n\t\t\t\thandle_down_evt();\n\t\t\t\tIPACMDBG_H(\"IPA_WAN_CRADLE (%s):ipa_index (%d) instance close \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ipa_if_num);\n\t\t\t\tIPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface\n\t\t\t\tdelete this;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_ADDR_ADD_EVENT:\n\t\t{\n\t\t\tipacm_event_data_addr *data = (ipacm_event_data_addr *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\n\t\t\tif ( (data->iptype == IPA_IP_v4 && data->ipv4_addr == 0) ||\n\t\t\t\t\t (data->iptype == IPA_IP_v6 &&\n\t\t\t\t\t\tdata->ipv6_addr[0] == 0 && data->ipv6_addr[1] == 0 &&\n\t\t\t\t\t  data->ipv6_addr[2] == 0 && data->ipv6_addr[3] == 0) )\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Invalid address, ignore IPA_ADDR_ADD_EVENT event\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Get IPA_ADDR_ADD_EVENT: IF ip type %d, incoming ip type %d\\n\", ip_type, data->iptype);\n\t\t\t\t/* check v4 not setup before, v6 can have 2 iface ip */\n\t\t\t\tif( ((data->iptype != ip_type) && (ip_type != IPA_IP_MAX))\n\t\t\t\t    || ((data->iptype==IPA_IP_v6) && (num_dft_rt_v6!=MAX_DEFAULT_v6_ROUTE_RULES)))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Got IPA_ADDR_ADD_EVENT ip-family:%d, v6 num %d: \\n\",data->iptype,num_dft_rt_v6);\n\t\t\t\t\thandle_addr_evt(data);\n\t\t\t\t\t/* checking if SW-RT_enable */\n\t\t\t\t\tif (IPACM_Iface::ipacmcfg->ipa_sw_rt_enable == true &&\n\t\t\t\t\t\t\tm_is_sta_mode != Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* handle software routing enable event*/\n\t\t\t\t\t\tIPACMDBG_H(\"IPA_SW_ROUTING_ENABLE for iface: %s \\n\",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);\n\t\t\t\t\t\thandle_software_routing_enable();\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\n\tcase IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT:\n\t\t{\n\t\t\tipacm_event_data_iptype *data = (ipacm_event_data_iptype *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT (Android) for ip-type (%d)\\n\", data->iptype);\n\t\t\t\t/* The special below condition is to handle default gateway */\n\t\t\t\tif ((data->iptype == IPA_IP_v4) && (ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX))\n\t\t\t\t{\n\t\t\t\t\tif (active_v4 == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"adding routing table(upstream), dev (%s) ip-type(%d)\\n\", dev_name,data->iptype);\n\t\t\t\t\t\thandle_route_add_evt(data->iptype);\n\t\t\t\t\t}\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\t\t/* using ipa_if_index, not netdev_index */\n\t\t\t\t\tpost_wan_up_tether_evt(data->iptype, iface_ipa_index_query(data->if_index_tether));\n#endif\n\t\t\t\t}\n\t\t\t\telse if ((data->iptype == IPA_IP_v6) && (ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX))\n\t\t\t\t{\n\t\t\t\t\tif (active_v6 == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"\\n get default v6 route (dst:00.00.00.00) upstream\\n\");\n\t\t\t\t\t\thandle_route_add_evt(data->iptype);\n\t\t\t\t\t}\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\t\t/* using ipa_if_index, not netdev_index */\n\t\t\t\t\tpost_wan_up_tether_evt(data->iptype, iface_ipa_index_query(data->if_index_tether));\n#endif\n\t\t\t\t}\n\t\t\t}\n\t\t\telse /* double check if current default iface is not itself */\n\t\t\t{\n\t\t\t\tif ((data->iptype == IPA_IP_v4) && (active_v4 == true))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Received v4 IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT for other iface (%s)\\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\tIPACMDBG_H(\"need clean default v4 route (dst:0.0.0.0) for old iface (%s)\\n\", dev_name);\n\t\t\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_wan_firewall_rule(IPA_IP_v4);\n\t\t\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t\t\t\thandle_route_del_evt_ex(IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_dft_firewall_rules(IPA_IP_v4);\n\t\t\t\t\t\thandle_route_del_evt(IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ((data->iptype == IPA_IP_v6) && (active_v6 == true))\n\t\t\t\t{\n\t\t\t\t    IPACMDBG_H(\"Received v6 IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT for other iface (%s)\\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\tIPACMDBG_H(\"need clean default v6 route for old iface (%s)\\n\", dev_name);\n\t\t\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_wan_firewall_rule(IPA_IP_v6);\n\t\t\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t\t\t\thandle_route_del_evt_ex(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_dft_firewall_rules(IPA_IP_v6);\n\t\t\t\t\t\thandle_route_del_evt(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT:\n\t\t{\n\t\t\tipacm_event_data_iptype *data = (ipacm_event_data_iptype *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT\\n\");\n\t\t\t\tif ((data->iptype == IPA_IP_v4) && (active_v4 == true))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"get del default v4 route (dst:0.0.0.0)\\n\");\n//\t\t\t\t\twan_v4_addr_gw_set = false; /* android requires CnE change too */\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\t\t/* using ipa_if_index, not netdev_index */\n\t\t\t\t\tpost_wan_down_tether_evt(data->iptype, iface_ipa_index_query(data->if_index_tether));\n\t\t\t\t\t/* no any ipv4 tether iface support*/\n\t\t\t\t\tif(IPACM_Wan::ipa_if_num_tether_v4_total != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"still have tether ipv4 client on upsteam iface\\n\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n#endif\n\t\t\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_wan_firewall_rule(IPA_IP_v4);\n\t\t\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t\t\t\thandle_route_del_evt_ex(IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_dft_firewall_rules(IPA_IP_v4);\n\t\t\t\t\t\thandle_route_del_evt(IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ((data->iptype == IPA_IP_v6) && (active_v6 == true))\n\t\t\t\t{\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\t\t/* using ipa_if_index, not netdev_index */\n\t\t\t\t\tpost_wan_down_tether_evt(data->iptype, iface_ipa_index_query(data->if_index_tether));\n\t\t\t\t\t/* no any ipv6 tether iface support*/\n\t\t\t\t\tif(IPACM_Wan::ipa_if_num_tether_v6_total != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"still have tether ipv6 client on upsteam iface\\n\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n#endif\n\t\t\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_wan_firewall_rule(IPA_IP_v6);\n\t\t\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t\t\t\thandle_route_del_evt_ex(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_dft_firewall_rules(IPA_IP_v6);\n\t\t\t\t\t\thandle_route_del_evt(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase IPA_NETWORK_STATS_UPDATE_EVENT:\n\t\t{\n\t\t\tipa_get_apn_data_stats_resp_msg_v01 *data = (ipa_get_apn_data_stats_resp_msg_v01 *)param;\n\t\t\tif (!data->apn_data_stats_list_valid)\n\t\t\t{\n\t\t\t\tIPACMERR(\"not valid APN\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\thandle_network_stats_update(data);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase IPA_ROUTE_ADD_EVENT:\n\t\t{\n\t\t\tipacm_event_data_addr *data = (ipacm_event_data_addr *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_ROUTE_ADD_EVENT\\n\");\n\t\t\t\tIPACMDBG_H(\"ipv4 addr 0x%x\\n\", data->ipv4_addr);\n\t\t\t\tIPACMDBG_H(\"ipv4 addr mask 0x%x\\n\", data->ipv4_addr_mask);\n\n\t\t\t\t/* The special below condition is to handle default gateway */\n\t\t\t\tif ((data->iptype == IPA_IP_v4) && (!data->ipv4_addr) && (!data->ipv4_addr_mask) && (active_v4 == false)\n\t\t\t\t\t&& (ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"adding routing table, dev (%s) ip-type(%d)\\n\", dev_name,data->iptype);\n\t\t\t\t\thandle_route_add_evt(data->iptype);\n\t\t\t\t}\n\t\t\t\telse if ((data->iptype == IPA_IP_v6) &&\n\t\t\t\t\t\t\t\t (!data->ipv6_addr[0]) && (!data->ipv6_addr[1]) && (!data->ipv6_addr[2]) && (!data->ipv6_addr[3]) && (active_v6 == false)\n\t\t\t\t\t\t\t\t && (ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"\\n get default v6 route (dst:00.00.00.00)\\n\");\n\t\t\t\t\tIPACMDBG_H(\" IPV6 value: %08x:%08x:%08x:%08x \\n\",\n\t\t\t\t\t\t\t\t\t data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n\t\t\t\thandle_route_add_evt(data->iptype);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse /* double check if current default iface is not itself */\n\t\t\t{\n\t\t\t\tif ((data->iptype == IPA_IP_v4) && (!data->ipv4_addr) && (!data->ipv4_addr_mask) && (active_v4 == true))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Received v4 IPA_ROUTE_ADD_EVENT for other iface (%s)\\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\tIPACMDBG_H(\"ipv4 addr 0x%x\\n\", data->ipv4_addr);\n\t\t\t\t\tIPACMDBG_H(\"ipv4 addr mask 0x%x\\n\", data->ipv4_addr_mask);\n\t\t\t\t\tIPACMDBG_H(\"need clean default v4 route (dst:0.0.0.0) for old iface (%s)\\n\", dev_name);\n\t\t\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_wan_firewall_rule(IPA_IP_v4);\n\t\t\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t\t\t\thandle_route_del_evt_ex(IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_dft_firewall_rules(IPA_IP_v4);\n\t\t\t\t\t\thandle_route_del_evt(IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ((data->iptype == IPA_IP_v6) && (!data->ipv6_addr[0]) && (!data->ipv6_addr[1]) && (!data->ipv6_addr[2]) && (!data->ipv6_addr[3]) && (active_v6 == true))\n\t\t\t\t{\n\t\t\t\t    IPACMDBG_H(\"Received v6 IPA_ROUTE_ADD_EVENT for other iface (%s)\\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);\n\t\t\t\t\tIPACMDBG_H(\"need clean default v6 route for old iface (%s)\\n\", dev_name);\n\t\t\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_wan_firewall_rule(IPA_IP_v6);\n\t\t\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t\t\t\thandle_route_del_evt_ex(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_dft_firewall_rules(IPA_IP_v6);\n\t\t\t\t\t\thandle_route_del_evt(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_ROUTE_DEL_EVENT:\n\t\t{\n\t\t\tipacm_event_data_addr *data = (ipacm_event_data_addr *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_ROUTE_DEL_EVENT\\n\");\n\t\t\t\tif ((data->iptype == IPA_IP_v4) && (!data->ipv4_addr) && (!data->ipv4_addr_mask) && (active_v4 == true))\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"get del default v4 route (dst:0.0.0.0)\\n\");\n\t\t\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_wan_firewall_rule(IPA_IP_v4);\n\t\t\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t\t\t\thandle_route_del_evt_ex(IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_dft_firewall_rules(IPA_IP_v4);\n\t\t\t\t\t\thandle_route_del_evt(IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ((data->iptype == IPA_IP_v6) && (!data->ipv6_addr[0]) && (!data->ipv6_addr[1]) && (!data->ipv6_addr[2]) && (!data->ipv6_addr[3]) && (active_v6 == true))\n\t\t\t\t{\n\n\t\t\t\t    IPACMDBG_H(\"get del default v6 route (dst:00.00.00.00)\\n\");\n\t\t\t\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_wan_firewall_rule(IPA_IP_v6);\n\t\t\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t\t\t\thandle_route_del_evt_ex(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdel_dft_firewall_rules(IPA_IP_v6);\n\t\t\t\t\t\thandle_route_del_evt(IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT:\n\t\t{\n\t\t\tipacm_event_data_all *data = (ipacm_event_data_all *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT in STA mode\\n\");\n\n\t\t\t\tif (m_is_sta_mode == WLAN_WAN)\n\t\t\t\t{\n\t\t\t\t\thandle_header_add_evt(ext_router_mac_addr);\n\t\t\t\t\tif (data->iptype == IPA_IP_v4 && data->ipv4_addr == wan_v4_addr)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Ignore IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT in STA mode\\n\");\n\t\t\t\t\t\tIPACMDBG_H(\"for its own ipv4 address\\n\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telse if (data->iptype == IPA_IP_v6)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (int num_ipv6_addr = 0; num_ipv6_addr < num_dft_rt_v6; num_ipv6_addr++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif ((ipv6_addr[num_ipv6_addr][0] == data->ipv6_addr[0]) &&\n\t\t\t\t\t\t\t\t(ipv6_addr[num_ipv6_addr][1] == data->ipv6_addr[1]) &&\n\t\t\t\t\t\t\t\t(ipv6_addr[num_ipv6_addr][2] == data->ipv6_addr[2]) &&\n\t\t\t\t\t\t\t\t(ipv6_addr[num_ipv6_addr][3] == data->ipv6_addr[3]))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"Ignore IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT in STA mode\\n\");\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"for its own ipv6 address\\n\");\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"wan-iface got client \\n\");\n\t\t\t\t/* first construc WAN-client full header */\n\t\t\t\tif(memcmp(data->mac_addr,\n\t\t\t\t\t\tinvalid_mac,\n\t\t\t\t\t\tsizeof(data->mac_addr)) == 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Received invalid Client MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t data->mac_addr[0], data->mac_addr[1], data->mac_addr[2],\n\t\t\t\t\t data->mac_addr[3], data->mac_addr[4], data->mac_addr[5]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\thandle_header_add_evt(data->mac_addr);\n\n\t\t\t\thandle_wan_hdr_init(data->mac_addr);\n\t\t\t\tIPACMDBG_H(\"construct wan header and route rules \\n\");\n\t\t\t\t/* Associate with IP and construct RT-rule */\n\t\t\t\tif (handle_wan_client_ipaddr(data) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thandle_wan_client_route_rule(data->mac_addr, data->iptype);\n\t\t\t\treturn;\n\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_SW_ROUTING_ENABLE:\n\t\tIPACMDBG_H(\"Received IPA_SW_ROUTING_ENABLE\\n\");\n\t\t/* handle software routing enable event */\n\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t{\n\t\t\tinstall_wan_filtering_rule(true);\n\t\t}\n\t\telse\n\t\t{\n\t\t\thandle_software_routing_enable();\n\t\t}\n\t\tbreak;\n\n\tcase IPA_SW_ROUTING_DISABLE:\n\t\tIPACMDBG_H(\"Received IPA_SW_ROUTING_DISABLE\\n\");\n\t\t/* handle software routing disable event */\n\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t{\n\t\t\t/* send current DL rules to modem */\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t\tsoftwarerouting_act = false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\thandle_software_routing_disable();\n\t\t}\n\t\tbreak;\n\n\tcase IPA_FIREWALL_CHANGE_EVENT:\n\t\tIPACMDBG_H(\"Received IPA_FIREWALL_CHANGE_EVENT\\n\");\n\n\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t{\n\t\t\tif(is_default_gateway == false)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Interface %s is not default gw, return.\\n\", dev_name);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif(ip_type == IPA_IP_v4)\n\t\t\t{\n\t\t\t\tdel_wan_firewall_rule(IPA_IP_v4);\n\t\t\t\tconfig_wan_firewall_rule(IPA_IP_v4);\n\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t}\n\t\t\telse if(ip_type == IPA_IP_v6)\n\t\t\t{\n\t\t\t\tdel_wan_firewall_rule(IPA_IP_v6);\n\t\t\t\tconfig_wan_firewall_rule(IPA_IP_v6);\n\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t}\n\t\t\telse if(ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\tdel_wan_firewall_rule(IPA_IP_v4);\n\t\t\t\tconfig_wan_firewall_rule(IPA_IP_v4);\n\n\t\t\t\tdel_wan_firewall_rule(IPA_IP_v6);\n\t\t\t\tconfig_wan_firewall_rule(IPA_IP_v6);\n\t\t\t\tinstall_wan_filtering_rule(false);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (active_v4)\n\t\t\t{\n\t\t\t\tdel_dft_firewall_rules(IPA_IP_v4);\n\t\t\t\tconfig_dft_firewall_rules(IPA_IP_v4);\n\t\t\t}\n\t\t\tif (active_v6)\n\t\t\t{\n\n\t\t\t\tdel_dft_firewall_rules(IPA_IP_v6);\n\t\t\t\tconfig_dft_firewall_rules(IPA_IP_v6);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn;\n}\n\n/* wan default route/filter rule configuration */\nint IPACM_Wan::handle_route_add_evt(ipa_ip_type iptype)\n{\n\n\t/* add default WAN route */\n\tstruct ipa_ioc_add_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_add *rt_rule_entry;\n\tstruct ipa_ioc_get_hdr sRetHeader;\n\tuint32_t cnt, tx_index = 0;\n\tconst int NUM = 1;\n\tipacm_cmd_q_data evt_data;\n\tstruct ipa_ioc_copy_hdr sCopyHeader; /* checking if partial header*/\n\n\tIPACMDBG_H(\"ip-type:%d\\n\", iptype);\n\n\t/* copy header from tx-property, see if partial or not */\n\t/* assume all tx-property uses the same header name for v4 or v6*/\n\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No tx properties, ignore default route setting\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tis_default_gateway = true;\n\tIPACMDBG_H(\"Default route is added to iface %s.\\n\", dev_name);\n\tmemcpy(backhaul_ipv6_prefix, ipv6_prefix, sizeof(backhaul_ipv6_prefix));\n\tIPACMDBG_H(\"Setup backhaul ipv6 prefix to be 0x%08x%08x.\\n\", backhaul_ipv6_prefix[0], backhaul_ipv6_prefix[1]);\n\n\tif (m_is_sta_mode !=Q6_WAN)\n\t{\n\t\tIPACM_Wan::backhaul_is_sta_mode\t= true;\n\t\tif((iptype==IPA_IP_v4) && (header_set_v4 != true))\n\t\t{\n\t\t\theader_partial_default_wan_v4 = true;\n\t\t\tIPACMDBG_H(\"STA ipv4-header haven't constructed \\n\");\n\t\t\treturn IPACM_SUCCESS;\n\t\t}\n\t\telse if((iptype==IPA_IP_v6) && (header_set_v6 != true))\n\t\t{\n\t\t\theader_partial_default_wan_v6 = true;\n\t\t\tIPACMDBG_H(\"STA ipv6-header haven't constructed \\n\");\n\t\t\treturn IPACM_SUCCESS;\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACM_Wan::backhaul_is_sta_mode\t= false;\n\t\tIPACMDBG_H(\"reset backhaul to LTE \\n\");\n\n\t\tif (iface_query != NULL && iface_query->num_ext_props > 0)\n\t\t{\n\t\t\tif(ext_prop == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Extended property is empty.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACM_Iface::ipacmcfg->SetQmapId(ext_prop->ext[0].mux_id);\n\t\t\t\tIPACMDBG_H(\"Setting up QMAP ID %d.\\n\", ext_prop->ext[0].mux_id);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"iface_query is empty.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n    for (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t{\n\t\tif(tx_prop->tx[cnt].ip==iptype)\n\t\tbreak;\n\t}\n\n\t//if(tx_prop->tx[cnt].hdr_name != NULL)\n\t{\n\t    memset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t    memcpy(sCopyHeader.name,\n\t    \t\t\t tx_prop->tx[cnt].hdr_name,\n\t    \t\t\t sizeof(sCopyHeader.name));\n\n\t    IPACMDBG_H(\"header name: %s\\n\", sCopyHeader.name);\n\t    if (m_header.CopyHeader(&sCopyHeader) == false)\n\t    {\n\t    \tIPACMERR(\"ioctl copy header failed\");\n\t    \treturn IPACM_FAILURE;\n\t    }\n\t    IPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t    if(sCopyHeader.is_partial)\n\t    {\n \t        IPACMDBG_H(\"Not setup default WAN routing rules cuz the header is not complete\\n\");\n            if(iptype==IPA_IP_v4)\n\t\t\t{\n\t\t\t\theader_partial_default_wan_v4 = true;\n            }\n\t\t\telse\n\t\t\t{\n\t\t\t\theader_partial_default_wan_v6 = true;\n\t\t\t}\n\t\t\treturn IPACM_SUCCESS;\n\t    }\n\t    else\n\t    {\n            if(iptype==IPA_IP_v4)\n\t\t\t{\n\t\t\t\theader_partial_default_wan_v4 = false;\n            }\n\t\t\telse\n\t\t\t{\n\t\t\t\theader_partial_default_wan_v6 = false;\n\t\t\t}\n\t    }\n    }\n\n\trt_rule = (struct ipa_ioc_add_rt_rule *)\n\t\t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t\t\t\t\t\tNUM * sizeof(struct ipa_rt_rule_add));\n\n\tif (!rt_rule)\n\t{\n\t\tIPACMERR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\trt_rule->commit = 1;\n\trt_rule->num_rules = (uint8_t)NUM;\n\trt_rule->ip = iptype;\n\n\n\tIPACMDBG_H(\" WAN table created %s \\n\", rt_rule->rt_tbl_name);\n\trt_rule_entry = &rt_rule->rules[0];\n\trt_rule_entry->at_rear = true;\n\n\tif(m_is_sta_mode != Q6_WAN)\n\t{\n\t\tIPACMDBG_H(\" WAN instance is in STA mode \\n\");\n\t\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t\tif(iptype != tx_prop->tx[tx_index].ip)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Tx:%d, ip-type: %d conflict ip-type: %d no RT-rule added\\n\",\n\t\t\t\t\t\t\t\t\ttx_index, tx_prop->tx[tx_index].ip,iptype);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (iptype == IPA_IP_v4)\n\t\t\t{\n\t    \t\tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v4.name);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t    \t\tstrcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_v6.name);\n\t\t\t}\n\n\t\t\t//if (tx_prop->tx[tx_index].hdr_name !=  NULL)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\" TX- header hdl %s \\n\", tx_prop->tx[tx_index].hdr_name);\n\t\t\t\tmemset(&sRetHeader, 0, sizeof(sRetHeader));\n\t\t\t\tstrncpy(sRetHeader.name,\n\t\t\t\t\t\t\t\ttx_prop->tx[tx_index].hdr_name,\n\t\t\t\t\t\t\t\tsizeof(tx_prop->tx[tx_index].hdr_name));\n\t\t\t\tif (false == m_header.GetHeaderHandle(&sRetHeader))\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"\\n ioctl failed\\n\");\n\t\t\t\t\tfree(rt_rule);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\trt_rule_entry->rule.hdr_hdl = sRetHeader.hdl;\n\t\t\t}\n\n\t\t\trt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\tmemcpy(&rt_rule_entry->rule.attrib,\n\t\t\t\t\t\t &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\t\t sizeof(rt_rule_entry->rule.attrib));\n\n\t\t\trt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\tif (iptype == IPA_IP_v4)\n\t\t\t{\n\t\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr      = 0;\n\t\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0;\n\n\t\t\t\tif (false == m_routing.AddRoutingRule(rt_rule))\n\t\t\t\t{\n\t\t    \t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t    \t\tfree(rt_rule);\n\t\t    \t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\twan_route_rule_v4_hdl[tx_index] = rt_rule_entry->rt_rule_hdl;\n\t\t\t\tIPACMDBG_H(\"Got ipv4 wan-route rule hdl:0x%x,tx:%d,ip-type: %d \\n\",\n\t\t\t\t\t\t\t wan_route_rule_v4_hdl[tx_index],\n\t\t\t\t\t\t\t tx_index,\n\t\t\t\t\t\t\t iptype);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0;\n\n\t\t\t\tif (false == m_routing.AddRoutingRule(rt_rule))\n\t\t\t\t{\n\t\t    \t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t    \t\tfree(rt_rule);\n\t\t    \t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\twan_route_rule_v6_hdl[tx_index] = rt_rule_entry->rt_rule_hdl;\n\t\t\t\tIPACMDBG_H(\"Set ipv6 wan-route rule hdl for v6_lan_table:0x%x,tx:%d,ip-type: %d \\n\",\n\t\t\t\t\t\t\t wan_route_rule_v6_hdl[tx_index],\n\t\t\t\t\t\t\t tx_index,\n\t\t\t\t\t\t\t iptype);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* add a catch-all rule in wan dl routing table */\n\n\tif (iptype == IPA_IP_v6)\n\t{\n    strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name);\n    memset(rt_rule_entry, 0, sizeof(struct ipa_rt_rule_add));\n\trt_rule_entry->at_rear = true;\n    rt_rule_entry->rule.dst = iface_query->excp_pipe;  //go to A5\n    rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;\n\trt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0;\n\trt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0;\n\trt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0;\n\trt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0;\n\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0;\n\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0;\n\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0;\n\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0;\n\n\tif (false == m_routing.AddRoutingRule(rt_rule))\n\t{\n\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\tfree(rt_rule);\n\t\treturn IPACM_FAILURE;\n\t}\n\twan_route_rule_v6_hdl_a5[0] = rt_rule_entry->rt_rule_hdl;\n\tIPACMDBG_H(\"Set ipv6 wan-route rule hdl for v6_wan_table:0x%x,tx:%d,ip-type: %d \\n\",\n\t\t\t\twan_route_rule_v6_hdl_a5[0],\n\t\t        0,\n\t\t        iptype);\n\t}\n\n\tipacm_event_iface_up *wanup_data;\n\twanup_data = (ipacm_event_iface_up *)malloc(sizeof(ipacm_event_iface_up));\n\tif (wanup_data == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(wanup_data, 0, sizeof(ipacm_event_iface_up));\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\t    IPACM_Wan::wan_up = true;\n\t\tactive_v4 = true;\n\t\tmemcpy(IPACM_Wan::wan_up_dev_name,\n\t\t\tdev_name,\n\t\t\t\tsizeof(IPACM_Wan::wan_up_dev_name));\n\n\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t{\n\t\t\tconfig_wan_firewall_rule(IPA_IP_v4);\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tconfig_dft_firewall_rules(IPA_IP_v4);\n\t\t}\n\n\t\tmemcpy(wanup_data->ifname, dev_name, sizeof(wanup_data->ifname));\n\t\twanup_data->ipv4_addr = wan_v4_addr;\n\t\tif (m_is_sta_mode!=Q6_WAN)\n\t\t{\n\t\t\twanup_data->is_sta = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\twanup_data->is_sta = false;\n\t\t}\n\t\tIPACMDBG_H(\"Posting IPA_HANDLE_WAN_UP with below information:\\n\");\n\t\tIPACMDBG_H(\"if_name:%s, ipv4_address:0x%x, is sta mode:%d\\n\",\n\t\t\twanup_data->ifname, wanup_data->ipv4_addr,  wanup_data->is_sta);\n\t\tmemset(&evt_data, 0, sizeof(evt_data));\n\t\tevt_data.event = IPA_HANDLE_WAN_UP;\n\t\tevt_data.evt_data = (void *)wanup_data;\n\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t}\n\telse\n\t{\n\t\tIPACM_Wan::wan_up_v6 = true;\n\t\tactive_v6 = true;\n\t\tmemcpy(IPACM_Wan::wan_up_dev_name,\n\t\t\tdev_name,\n\t\t\t\tsizeof(IPACM_Wan::wan_up_dev_name));\n\n\t\tif(m_is_sta_mode == Q6_WAN)\n\t\t{\n\t\t\tconfig_wan_firewall_rule(IPA_IP_v6);\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tconfig_dft_firewall_rules(IPA_IP_v6);\n\t\t}\n\n\t\tmemcpy(wanup_data->ifname, dev_name, sizeof(wanup_data->ifname));\n\t\tif (m_is_sta_mode!=Q6_WAN)\n\t\t{\n\t\t\twanup_data->is_sta = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\twanup_data->is_sta = false;\n\t\t}\n\t\tmemcpy(wanup_data->ipv6_prefix, ipv6_prefix, sizeof(wanup_data->ipv6_prefix));\n\t\tIPACMDBG_H(\"Posting IPA_HANDLE_WAN_UP_V6 with below information:\\n\");\n\t\tIPACMDBG_H(\"if_name:%s, is sta mode: %d\\n\", wanup_data->ifname, wanup_data->is_sta);\n\t\tIPACMDBG_H(\"ipv6 prefix: 0x%08x%08x.\\n\", ipv6_prefix[0], ipv6_prefix[1]);\n\t\tmemset(&evt_data, 0, sizeof(evt_data));\n\t\tevt_data.event = IPA_HANDLE_WAN_UP_V6;\n\t\tevt_data.evt_data = (void *)wanup_data;\n\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t}\n\n\t/* Add corresponding ipa_rm_resource_name of TX-endpoint up before IPV6 RT-rule set */\n\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\tIPACM_Iface::ipacmcfg->AddRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe],false);\n\n\treturn IPACM_SUCCESS;\n}\n\n/* wan default route/filter rule configuration */\nint IPACM_Wan::post_wan_up_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether)\n{\n\tipacm_cmd_q_data evt_data;\n\tipacm_event_iface_up_tehter *wanup_data;\n\n\twanup_data = (ipacm_event_iface_up_tehter *)malloc(sizeof(ipacm_event_iface_up_tehter));\n\tif (wanup_data == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(wanup_data, 0, sizeof(ipacm_event_iface_up_tehter));\n\n\twanup_data->if_index_tether = ipa_if_num_tether;\n\tif (m_is_sta_mode!=Q6_WAN)\n\t{\n\t\twanup_data->is_sta = true;\n\t}\n\telse\n\t{\n\t\twanup_data->is_sta = false;\n\t}\n\tIPACMDBG_H(\"Posting IPA_HANDLE_WAN_UP_TETHER with below information:\\n\");\n\tIPACMDBG_H(\"tether_if_name:%s, is sta mode:%d\\n\",\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name, wanup_data->is_sta);\n\tmemset(&evt_data, 0, sizeof(evt_data));\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tevt_data.event = IPA_HANDLE_WAN_UP_TETHER;\n\t\t/* Add support tether ifaces to its array*/\n\t\tIPACM_Wan::ipa_if_num_tether_v4[IPACM_Wan::ipa_if_num_tether_v4_total] = ipa_if_num_tether;\n\t\tIPACMDBG_H(\"adding tether iface(%s) ipa_if_num_tether_v4_total(%d) on wan_iface(%s)\\n\",\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name,\n\t\t\tIPACM_Wan::ipa_if_num_tether_v4_total,\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);\n\t\tIPACM_Wan::ipa_if_num_tether_v4_total++;\n\t}\n\telse\n\t{\n\t\tevt_data.event = IPA_HANDLE_WAN_UP_V6_TETHER;\n\t\tmemcpy(wanup_data->ipv6_prefix, ipv6_prefix, sizeof(wanup_data->ipv6_prefix));\n\t\t/* Add support tether ifaces to its array*/\n\t\tIPACM_Wan::ipa_if_num_tether_v6[IPACM_Wan::ipa_if_num_tether_v6_total] = ipa_if_num_tether;\n\t\tIPACMDBG_H(\"adding tether iface(%s) ipa_if_num_tether_v6_total(%d) on wan_iface(%s)\\n\",\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name,\n\t\t\tIPACM_Wan::ipa_if_num_tether_v6_total,\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);\n\t\tIPACM_Wan::ipa_if_num_tether_v6_total++;\n\t}\n\t\tevt_data.evt_data = (void *)wanup_data;\n\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\n\treturn IPACM_SUCCESS;\n}\n\n/* wan default route/filter rule configuration */\nint IPACM_Wan::post_wan_down_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether)\n{\n\tipacm_cmd_q_data evt_data;\n\tipacm_event_iface_up_tehter *wandown_data;\n\tint i, j;\n\n\twandown_data = (ipacm_event_iface_up_tehter *)malloc(sizeof(ipacm_event_iface_up_tehter));\n\tif (wandown_data == NULL)\n\t{\n\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(wandown_data, 0, sizeof(ipacm_event_iface_up_tehter));\n\n\twandown_data->if_index_tether = ipa_if_num_tether;\n\tif (m_is_sta_mode!=Q6_WAN)\n\t{\n\t\twandown_data->is_sta = true;\n\t}\n\telse\n\t{\n\t\twandown_data->is_sta = false;\n\t}\n\tIPACMDBG_H(\"Posting IPA_HANDLE_WAN_DOWN_TETHER with below information:\\n\");\n\tIPACMDBG_H(\"tether_if_name:%s, is sta mode:%d\\n\",\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name, wandown_data->is_sta);\n\tmemset(&evt_data, 0, sizeof(evt_data));\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tevt_data.event = IPA_HANDLE_WAN_DOWN_TETHER;\n\t\t/* delete support tether ifaces to its array*/\n\t\tfor (i=0; i < IPACM_Wan::ipa_if_num_tether_v4_total; i++)\n\t\t{\n\t\t\tif(IPACM_Wan::ipa_if_num_tether_v4[i] == ipa_if_num_tether)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Found tether client at position %d name(%s)\\n\", i,\n\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == IPACM_Wan::ipa_if_num_tether_v4_total)\n\t\t{\n\t\t\tIPACMDBG_H(\"Not finding the tether client.\\n\");\n\t\t\tfree(wandown_data);\n\t\t\treturn IPACM_SUCCESS;\n\t\t}\n\t\tfor(j = i+1; j < IPACM_Wan::ipa_if_num_tether_v4_total; j++)\n\t\t{\n\t\t\tIPACM_Wan::ipa_if_num_tether_v4[j-1] = IPACM_Wan::ipa_if_num_tether_v4[j];\n\t\t}\n\t\tIPACM_Wan::ipa_if_num_tether_v4_total--;\n\t\tIPACMDBG_H(\"Now the total num of ipa_if_num_tether_v4_total is %d on wan-iface(%s)\\n\",\n\t\t\tIPACM_Wan::ipa_if_num_tether_v4_total,\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);\n\t}\n\telse\n\t{\n\t\tevt_data.event = IPA_HANDLE_WAN_DOWN_V6_TETHER;\n\t\t/* delete support tether ifaces to its array*/\n\t\tfor (i=0; i < IPACM_Wan::ipa_if_num_tether_v6_total; i++)\n\t\t{\n\t\t\tif(IPACM_Wan::ipa_if_num_tether_v6[i] == ipa_if_num_tether)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Found tether client at position %d name(%s)\\n\", i,\n\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == IPACM_Wan::ipa_if_num_tether_v6_total)\n\t\t{\n\t\t\tIPACMDBG_H(\"Not finding the tether client.\\n\");\n\t\t\tfree(wandown_data);\n\t\t\treturn IPACM_SUCCESS;\n\t\t}\n\t\tfor(j = i+1; j < IPACM_Wan::ipa_if_num_tether_v6_total; j++)\n\t\t{\n\t\t\tIPACM_Wan::ipa_if_num_tether_v6[j-1] = IPACM_Wan::ipa_if_num_tether_v6[j];\n\t\t}\n\t\tIPACM_Wan::ipa_if_num_tether_v6_total--;\n\t\tIPACMDBG_H(\"Now the total num of ipa_if_num_tether_v6_total is %d on wan-iface(%s)\\n\",\n\t\t\tIPACM_Wan::ipa_if_num_tether_v6_total,\n\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);\n\t}\n\t\tevt_data.evt_data = (void *)wandown_data;\n\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\treturn IPACM_SUCCESS;\n}\n\n/* construct complete ethernet header */\nint IPACM_Wan::handle_header_add_evt(uint8_t *mac_addr)\n{\n  #define WAN_IFACE_INDEX_LEN 2\n\n\tuint32_t tx_index,cnt;\n\tint res = IPACM_SUCCESS, len = 0;\n\tchar index[WAN_IFACE_INDEX_LEN];\n\tstruct ipa_ioc_copy_hdr sCopyHeader;\n\tstruct ipa_ioc_add_hdr *pHeaderDescriptor = NULL;\n\n\t/* start of adding header */\n\n\tIPACMDBG_H(\"Received Client MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\tif((header_set_v4 == true) || (header_set_v6 == true))\n\t{\n\t\tIPACMDBG_H(\"Already add STA full header\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\t/* add header to IPA */\n\tlen = sizeof(struct ipa_ioc_add_hdr) + (1 * sizeof(struct ipa_hdr_add));\n\tpHeaderDescriptor = (struct ipa_ioc_add_hdr *)calloc(1, len);\n\tif (pHeaderDescriptor == NULL)\n\t{\n\t\tIPACMERR(\"calloc failed to allocate pHeaderDescriptor\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* copy partial header for v4 */\n        for (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t{\n\t\t   if(tx_prop->tx[cnt].ip==IPA_IP_v4)\n\t\t   {\n\t               memset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t               memcpy(sCopyHeader.name,\n\t\t\t\t tx_prop->tx[cnt].hdr_name,\n\t\t\t\t sizeof(sCopyHeader.name));\n\n\tIPACMDBG_H(\"header name: %s from tx: %d\\n\", sCopyHeader.name,cnt);\n\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t{\n\t\tIPACMERR(\"ioctl copy header failed\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tif(sCopyHeader.is_eth2_ofst_valid == false)\n\t{\n\t\teth2_ofst_v4 = 0;\n\t}\n\telse\n\t{\n\t\teth2_ofst_v4 = sCopyHeader.eth2_ofst;\n\t}\n\n\tIPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t{\n\t\tIPACMERR(\"header oversize\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\telse\n\t{\n\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t sCopyHeader.hdr,\n\t\t\t\t\t sCopyHeader.hdr_len);\n\t}\n\n\t/* copy client mac_addr to partial header */\n\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[eth2_ofst_v4], mac_addr,\n\t\t\t\t\t IPA_MAC_ADDR_SIZE); /* only copy 6 bytes mac-address */\n\n\tpHeaderDescriptor->commit = true;\n\tpHeaderDescriptor->num_hdrs = 1;\n\n\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\tsnprintf(index,sizeof(index), \"%d\", ipa_if_num);\n\tstrlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));\n\tif ( strlcat(pHeaderDescriptor->hdr[0].name, IPA_WAN_PARTIAL_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t{\n\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\tpHeaderDescriptor->hdr[0].status = -1;\n\n\tif (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t{\n\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\telse\n\t{\n\t        hdr_hdl_sta_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\theader_set_v4 = true;\n\t        IPACMDBG_H(\"add full header name: %s (%x)\\n\", pHeaderDescriptor->hdr[0].name, pHeaderDescriptor->hdr[0].hdr_hdl);\n\t}\n\n\t/* copy ipv4 full header to each TX endpoint property*/\n\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t{\n\t   if(tx_prop->tx[tx_index].ip==IPA_IP_v4)\n           {\n\t\t  memcpy(tx_prop->tx[tx_index].hdr_name, pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t sizeof(tx_prop->tx[tx_index].hdr_name));\n\t\t                 IPACMDBG_H(\"replace full header name: %s (%x) in tx:%d\\n\", tx_prop->tx[tx_index].hdr_name, pHeaderDescriptor->hdr[0].hdr_hdl,tx_index);\n                           }\n\t               }\n\t\t        break;\n\t\t   }\n\t}\n\n\t/* copy partial header for v6 */\n        for (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t{\n\t\t   if(tx_prop->tx[cnt].ip == IPA_IP_v6)\n\t\t   {\n\t                 IPACMDBG_H(\"Got partial v6-header name from %d tx props\\n\", cnt);\n\t                 memset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t                 memcpy(sCopyHeader.name,\n\t\t\t\t           tx_prop->tx[cnt].hdr_name,\n\t\t\t\t                   sizeof(sCopyHeader.name));\n\n\t\t\tIPACMDBG_H(\"header name: %s from tx: %d\\n\", sCopyHeader.name,cnt);\n\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"ioctl copy header failed\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tif(sCopyHeader.is_eth2_ofst_valid == false)\n\t\t\t{\n\t\t\t\teth2_ofst_v6 = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\teth2_ofst_v6 = sCopyHeader.eth2_ofst;\n\t\t\t}\n                     IPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n                     if (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n                     {\n                     \tIPACMERR(\"header oversize\\n\");\n                     \tres = IPACM_FAILURE;\n                     \tgoto fail;\n                     }\n                     else\n                     {\n                     \tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n                     \t\t\t\t sCopyHeader.hdr,\n                     \t\t\t\t sCopyHeader.hdr_len);\n                     }\n\n\t                 /* copy client mac_addr to partial header */\n\t                 memcpy(&pHeaderDescriptor->hdr[0].hdr[eth2_ofst_v6], mac_addr,\n\t                 \t\t\t\t IPA_MAC_ADDR_SIZE); /* only copy 6 bytes mac-address */\n\t                 pHeaderDescriptor->commit = true;\n\t                 pHeaderDescriptor->num_hdrs = 1;\n\n\t                 memset(pHeaderDescriptor->hdr[0].name, 0,\n\t                 \t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\t\t snprintf(index,sizeof(index), \"%d\", ipa_if_num);\n\t\t\t\t\t strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\t if (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WAN_PARTIAL_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t\t {\n\t\t\t\t\t \tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\t \tres = IPACM_FAILURE;\n\t\t\t\t\t \tgoto fail;\n\t\t\t\t\t }\n\t                 pHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t                 pHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t                 pHeaderDescriptor->hdr[0].is_partial = 0;\n\t                 pHeaderDescriptor->hdr[0].status = -1;\n\n\t                 if (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t                 \t\tpHeaderDescriptor->hdr[0].status != 0)\n\t                 {\n\t                 \tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t                 \tres = IPACM_FAILURE;\n\t                 \tgoto fail;\n\t                 }\n\t                 else\n\t                 {\n\t\t\t   header_set_v6 = true;\n\t                   hdr_hdl_sta_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t                   IPACMDBG_H(\"add full header name: %s (%x)\\n\", pHeaderDescriptor->hdr[0].name, pHeaderDescriptor->hdr[0].hdr_hdl);\n\t                 }\n\t                 /* copy ipv6 full header to each TX endpoint property*/\n\t                 for (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t                 {\n\t                    if(tx_prop->tx[tx_index].ip==IPA_IP_v6)\n                        {\n\t                 \t  memcpy(tx_prop->tx[tx_index].hdr_name, pHeaderDescriptor->hdr[0].name,\n\t                 \t\t\t\t sizeof(tx_prop->tx[tx_index].hdr_name));\n\t                 \t  IPACMDBG_H(\"replace full header name: %s (%x) in tx:%d\\n\", tx_prop->tx[tx_index].hdr_name, pHeaderDescriptor->hdr[0].hdr_hdl,tx_index);\n                        }\n                     }\n\t                 break;\n\t        }\n\t}\n\n    /* see if default routes are setup before constructing full header */\n    if(header_partial_default_wan_v4 == true)\n\t{\n\t   handle_route_add_evt(IPA_IP_v4);\n\t}\n\n    if(header_partial_default_wan_v6 == true)\n\t{\n\t   handle_route_add_evt(IPA_IP_v6);\n\t}\n\nfail:\n\tfree(pHeaderDescriptor);\n\n\treturn res;\n}\n\n/* for STA mode: add firewall rules */\nint IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype)\n{\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tint i, rule_v4 = 0, rule_v6 = 0, len;\n\n\tIPACMDBG_H(\"ip-family: %d; \\n\", iptype);\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\t/* default firewall is disable and the rule action is drop */\n\tmemset(&firewall_config, 0, sizeof(firewall_config));\n\tstrncpy(firewall_config.firewall_config_file, \"/etc/mobileap_firewall.xml\", sizeof(firewall_config.firewall_config_file));\n\n\t//if (firewall_config.firewall_config_file)\n\t{\n\t\tIPACMDBG_H(\"Firewall XML file is %s \\n\", firewall_config.firewall_config_file);\n\t\tif (IPACM_SUCCESS == IPACM_read_firewall_xml(firewall_config.firewall_config_file, &firewall_config))\n\t\t{\n\t\t\tIPACMDBG_H(\"QCMAP Firewall XML read OK \\n\");\n\t/* find the number of v4/v6 firewall rules */\n\tfor (i = 0; i < firewall_config.num_extd_firewall_entries; i++)\n\t{\n\t\tif (firewall_config.extd_firewall_entries[i].ip_vsn == 4)\n\t\t{\n\t\t\trule_v4++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\trule_v6++;\n\t\t}\n\t}\n\tIPACMDBG_H(\"firewall rule v4:%d v6:%d total:%d\\n\", rule_v4, rule_v6, firewall_config.num_extd_firewall_entries);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"QCMAP Firewall XML read failed, no that file, use default configuration \\n\");\n\t\t}\n\t}\n\t/*else\n\t{\n\t\tIPACMERR(\"No firewall xml mentioned \\n\");\n\t\treturn IPACM_FAILURE;\n\t}*/\n\n\t/* construct ipa_ioc_add_flt_rule with N firewall rules */\n\tipa_ioc_add_flt_rule *m_pFilteringTable = NULL;\n\tlen = sizeof(struct ipa_ioc_add_flt_rule) + 1 * sizeof(struct ipa_flt_rule_add);\n\tm_pFilteringTable = (struct ipa_ioc_add_flt_rule *)calloc(1, len);\n\tif (!m_pFilteringTable)\n\t{\n\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(iptype == IPA_IP_v6 && firewall_config.firewall_enable == true)\n\t{\n\t\tm_pFilteringTable->commit = 1;\n\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\tm_pFilteringTable->global = false;\n\t\tm_pFilteringTable->ip = IPA_IP_v6;\n\t\tm_pFilteringTable->num_rules = (uint8_t)1;\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\tmemcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(struct ipa_rule_attrib));\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_FRAG_HDR;\n\n\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error Adding RuleTable(0) to Filtering, aborting...\\n\");\n\t\t\tfree(m_pFilteringTable);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tipv6_frag_firewall_flt_rule_hdl = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t\tIPACMDBG_H(\"Installed IPv6 frag firewall rule, handle %d.\\n\", ipv6_frag_firewall_flt_rule_hdl);\n\t\t}\n\t}\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tif (rule_v4 == 0)\n\t\t{\n\t\t\tmemset(m_pFilteringTable, 0, len);\n\n\t\t\tm_pFilteringTable->commit = 1;\n\t\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\t\tm_pFilteringTable->global = false;\n\t\t\tm_pFilteringTable->ip = IPA_IP_v4;\n\t\t\tm_pFilteringTable->num_rules = (uint8_t)1;\n\n\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan_v4))\n\t\t\t{\n\t\t\t\tIPACMERR(\"m_routing.GetRoutingTable(rt_tbl_lan_v4) Failed.\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\n\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\tflt_rule_entry.status = -1;\n\n\t\t\t/* firewall disable, all traffic are allowed */\n                        if(firewall_config.firewall_enable == true)\n\t\t\t{\n\t\t\t    flt_rule_entry.at_rear = true;\n\n\t\t\t     /* default action for v4 is go DST_NAT unless user set to exception*/\n                             if(firewall_config.rule_action_accept == true)\n\t\t\t    {\n\t\t\t        flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\t\t    }\n\t\t\t    else\n\t\t\t    {\n\t\t\t        flt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT;\n                            }\n\t\t        }\n\t\t\telse\n\t\t\t{\n\t\t\t  flt_rule_entry.at_rear = true;\n\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT;\n                        }\n\n\t\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.hdl;\n\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t\t sizeof(struct ipa_rule_attrib));\n\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0x00000000;\n\n\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Adding RuleTable(0) to Filtering, aborting...\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t}\n\n\t\t\t/* copy filter hdls */\n\t\t\tdft_wan_fl_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmemset(m_pFilteringTable, 0, len);\n\n\t\t\tm_pFilteringTable->commit = 1;\n\t\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\t\tm_pFilteringTable->global = false;\n\t\t\tm_pFilteringTable->ip = IPA_IP_v4;\n\t\t\tm_pFilteringTable->num_rules = (uint8_t)1;\n\n\t\t\tIPACMDBG_H(\"Retreiving Routing handle for routing table name:%s\\n\",\n\t\t\t\t\t\t\t IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name);\n\t\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan_v4))\n\t\t\t{\n\t\t\t\tIPACMERR(\"m_routing.GetRoutingTable(&rt_tbl_lan_v4=0x%p) Failed.\\n\", &IPACM_Iface::ipacmcfg->rt_tbl_lan_v4);\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\tIPACMDBG_H(\"Routing handle for wan routing table:0x%x\\n\", IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.hdl);\n\n            if(firewall_config.firewall_enable == true)\n            {\n\t\t\trule_v4 = 0;\n\t\t\tfor (i = 0; i < firewall_config.num_extd_firewall_entries; i++)\n\t\t\t{\n\t\t\t\tif (firewall_config.extd_firewall_entries[i].ip_vsn == 4)\n\t\t\t\t{\n\t\t\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\t    \t\t\tflt_rule_entry.at_rear = true;\n\t\t\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\t\t\tflt_rule_entry.status = -1;\n\t\t\t\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.hdl;\n\n\t\t\t\t\t/* Accept v4 matched rules*/\n                                        if(firewall_config.rule_action_accept == true)\n\t\t\t                {\n\t\t\t                     flt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT;\n\t\t\t                }\n\t\t\t                else\n\t\t\t                {\n\t\t\t                     flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n                                        }\n\n\t\t\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t\t\t &firewall_config.extd_firewall_entries[i].attrib,\n\t\t\t\t\t\t\t\t sizeof(struct ipa_rule_attrib));\n\n\t\t\t\t\tIPACMDBG_H(\"rx property attrib mask: 0x%x\\n\", rx_prop->rx[0].attrib.attrib_mask);\n\t\t\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= rx_prop->rx[0].attrib.attrib_mask;\n\t\t\t\t\tflt_rule_entry.rule.attrib.meta_data_mask = rx_prop->rx[0].attrib.meta_data_mask;\n\t\t\t\t\tflt_rule_entry.rule.attrib.meta_data = rx_prop->rx[0].attrib.meta_data;\n\n\t\t\t\t\t/* check if the rule is define as TCP_UDP, split into 2 rules, 1 for TCP and 1 UDP */\n\t\t\t\t\tif (firewall_config.extd_firewall_entries[i].attrib.u.v4.protocol\n\t\t\t\t\t\t\t== IPACM_FIREWALL_IPPROTO_TCP_UDP)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* insert TCP rule*/\n\t\t\t\t\t\tflt_rule_entry.rule.attrib.u.v4.protocol = IPACM_FIREWALL_IPPROTO_TCP;\n\t\t\t\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\t\t\t\tIPACMDBG_H(\"Filter rule attrib mask: 0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[0].rule.attrib.attrib_mask);\n\t\t\t\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Error Adding RuleTable(0) to Filtering, aborting...\\n\");\n\t\t\t\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* save v4 firewall filter rule handler */\n\t\t\t\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[rule_v4].flt_rule_hdl,\n\t\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[rule_v4].status);\n\t\t\t\t\t\t\tfirewall_hdl_v4[rule_v4] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t\t\t\t\t\tnum_firewall_v4++;\n\t\t\t\t\t\t\trule_v4++;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* insert UDP rule*/\n\t\t\t\t\t\tflt_rule_entry.rule.attrib.u.v4.protocol = IPACM_FIREWALL_IPPROTO_UDP;\n\t\t\t\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\t\t\t\tIPACMDBG_H(\"Filter rule attrib mask: 0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[0].rule.attrib.attrib_mask);\n\t\t\t\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Error Adding RuleTable(0) to Filtering, aborting...\\n\");\n\t\t\t\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* save v4 firewall filter rule handler */\n\t\t\t\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[rule_v4].flt_rule_hdl,\n\t\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[rule_v4].status);\n\t\t\t\t\t\t\tfirewall_hdl_v4[rule_v4] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t\t\t\t\t\tnum_firewall_v4++;\n\t\t\t\t\t\t\trule_v4++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\t\t\t\tIPACMDBG_H(\"Filter rule attrib mask: 0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[0].rule.attrib.attrib_mask);\n\t\t\t\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Error Adding RuleTable(0) to Filtering, aborting...\\n\");\n\t\t\t\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* save v4 firewall filter rule handler */\n\t\t\t\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[rule_v4].flt_rule_hdl,\n\t\t\t\t\t\t\t\t\t\t\t m_pFilteringTable->rules[rule_v4].status);\n\t\t\t\t\t\t\tfirewall_hdl_v4[rule_v4] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t\t\t\t\t\tnum_firewall_v4++;\n\t\t\t\t\t\t\trule_v4++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} /* end of firewall ipv4 filter rule add for loop*/\n            }\n\t\t\t/* configure default filter rule */\n\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\tflt_rule_entry.status = -1;\n\n\t\t\t/* firewall disable, all traffic are allowed */\n                        if(firewall_config.firewall_enable == true)\n\t\t\t{\n\t\t\t     flt_rule_entry.at_rear = true;\n\n\t\t\t     /* default action for v4 is go DST_NAT unless user set to exception*/\n                             if(firewall_config.rule_action_accept == true)\n\t\t\t     {\n\t\t\t        flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\t\t     }\n\t\t\t     else\n\t\t\t     {\n\t\t\t       flt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT;\n                             }\n\t\t        }\n\t\t\telse\n\t\t\t{\n\t\t\t    flt_rule_entry.at_rear = true;\n\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT;\n                        }\n\n\t\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.hdl;\n\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t\t sizeof(struct ipa_rule_attrib));\n\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0x00000000;\n\n\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tIPACMDBG_H(\"Filter rule attrib mask: 0x%x\\n\",\n\t\t\t\t\t\t\t m_pFilteringTable->rules[0].rule.attrib.attrib_mask);\n\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Adding RuleTable(0) to Filtering, aborting...\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t}\n\n\t\t\t/* copy filter hdls */\n\t\t\tdft_wan_fl_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t}\n\n\t}\n\telse\n\t{\n\t\tif (rule_v6 == 0)\n\t\t{\n\t\t\tmemset(m_pFilteringTable, 0, len);\n\n\t\t\tm_pFilteringTable->commit = 1;\n\t\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\t\tm_pFilteringTable->global = false;\n\t\t\tm_pFilteringTable->ip = IPA_IP_v6;\n\t\t\tm_pFilteringTable->num_rules = (uint8_t)1;\n\n\t\t\t/* Construct ICMP rule */\n\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\t\t\tflt_rule_entry.at_rear = true;\n\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\tflt_rule_entry.status = -1;\n\t\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\t\tflt_rule_entry.rule.eq_attrib_type = 0;\n\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(struct ipa_rule_attrib));\n\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6;\n\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Adding Filtering rules, aborting...\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t}\n\t\t\t/* copy filter hdls */\n\t\t\tdft_wan_fl_hdl[2] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\n\t\t\t/* End of construct ICMP rule */\n\n\t\t\t/* v6 default route */\n\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\t\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_wan_v6)) //rt_tbl_wan_v6 rt_tbl_v6\n\t\t\t{\n\t\t\t\tIPACMERR(\"m_routing.GetRoutingTable(rt_tbl_wan_v6) Failed.\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\n\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\tflt_rule_entry.status = -1;\n\t\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.hdl;\n\n\t\t\t/* firewall disable, all traffic are allowed */\n                        if(firewall_config.firewall_enable == true)\n\t\t\t{\n\t\t\t   flt_rule_entry.at_rear = true;\n\n\t\t\t   /* default action for v6 is PASS_TO_ROUTE unless user set to exception*/\n                           if(firewall_config.rule_action_accept == true)\n\t\t\t   {\n\t\t\t       flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\t\t   }\n\t\t\t   else\n\t\t\t   {\n\t\t\t       flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n                           }\n\t\t        }\n\t\t\telse\n\t\t\t{\n\t\t\t  flt_rule_entry.at_rear = true;\n\t\t\t  flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n                        }\n\n\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t\t sizeof(struct ipa_rule_attrib));\n\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0X00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\n\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Adding Filtering rules, aborting...\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t}\n\n\t\t\t/* copy filter hdls */\n\t\t\tdft_wan_fl_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmemset(m_pFilteringTable, 0, len);\n\n\t\t\tm_pFilteringTable->commit = 1;\n\t\t\tm_pFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\t\t\tm_pFilteringTable->global = false;\n\t\t\tm_pFilteringTable->ip = IPA_IP_v6;\n\t\t\tm_pFilteringTable->num_rules = (uint8_t)1;\n\n\t\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_wan_v6))\n\t\t\t{\n\t\t\t\tIPACMERR(\"m_routing.GetRoutingTable(rt_tbl_wan_v6) Failed.\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\n            if(firewall_config.firewall_enable == true)\n            {\n\t\t\trule_v6 = 0;\n\t\t\tfor (i = 0; i < firewall_config.num_extd_firewall_entries; i++)\n\t\t\t{\n\t\t\t\tif (firewall_config.extd_firewall_entries[i].ip_vsn == 6)\n\t\t\t\t{\n\t\t\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\t    \t\t\tflt_rule_entry.at_rear = true;\n\t\t\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\t\t\tflt_rule_entry.status = -1;\n\n\t\t\t\t    /* matched rules for v6 go PASS_TO_ROUTE */\n                                    if(firewall_config.rule_action_accept == true)\n\t\t\t            {\n\t\t\t                flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\t\t            }\n\t\t\t            else\n\t\t\t            {\n\t\t\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n                                    }\n\n\t\t    \t\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.hdl;\n\t\t\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t\t\t &firewall_config.extd_firewall_entries[i].attrib,\n\t\t\t\t\t\t\t\t sizeof(struct ipa_rule_attrib));\n\t\t\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= rx_prop->rx[0].attrib.attrib_mask;\n\t\t\t\t\tflt_rule_entry.rule.attrib.meta_data_mask = rx_prop->rx[0].attrib.meta_data_mask;\n\t\t\t\t\tflt_rule_entry.rule.attrib.meta_data = rx_prop->rx[0].attrib.meta_data;\n\n\t\t\t\t\t/* check if the rule is define as TCP/UDP */\n\t\t\t\t\tif (firewall_config.extd_firewall_entries[i].attrib.u.v6.next_hdr == IPACM_FIREWALL_IPPROTO_TCP_UDP)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* insert TCP rule*/\n\t\t\t\t\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = IPACM_FIREWALL_IPPROTO_TCP;\n\t\t\t\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Error Adding Filtering rules, aborting...\\n\");\n\t\t\t\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* save v4 firewall filter rule handler */\n\t\t\t\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t\t\t\t\tfirewall_hdl_v6[rule_v6] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t\t\t\t\t\tnum_firewall_v6++;\n\t\t\t\t\t\t\trule_v6++;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* insert UDP rule*/\n\t\t\t\t\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = IPACM_FIREWALL_IPPROTO_UDP;\n\t\t\t\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Error Adding Filtering rules, aborting...\\n\");\n\t\t\t\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* save v6 firewall filter rule handler */\n\t\t\t\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t\t\t\t\tfirewall_hdl_v6[rule_v6] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t\t\t\t\t\tnum_firewall_v6++;\n\t\t\t\t\t\t\trule_v6++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\n\t\t\t\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Error Adding Filtering rules, aborting...\\n\");\n\t\t\t\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* save v6 firewall filter rule handler */\n\t\t\t\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t\t\t\t\tfirewall_hdl_v6[rule_v6] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t\t\t\t\t\tnum_firewall_v6++;\n\t\t\t\t\t\t\trule_v6++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} /* end of firewall ipv6 filter rule add for loop*/\n            }\n\n\t\t\t/* Construct ICMP rule */\n\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\t\t\tflt_rule_entry.at_rear = true;\n\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\tflt_rule_entry.status = -1;\n\t\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\t\tflt_rule_entry.rule.eq_attrib_type = 0;\n\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(struct ipa_rule_attrib));\n\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6;\n\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Adding Filtering rules, aborting...\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t}\n\t\t\t/* copy filter hdls */\n\t\t\tdft_wan_fl_hdl[2] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t\t/* End of construct ICMP rule */\n\n\t\t\t/* setup default wan filter rule */\n\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\tflt_rule_entry.status = -1;\n\t\t\tflt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.hdl;\n\n\t\t\t/* firewall disable, all traffic are allowed */\n                        if(firewall_config.firewall_enable == true)\n\t\t\t{\n\t\t\t   flt_rule_entry.at_rear = true;\n\n\t\t\t   /* default action for v6 is PASS_TO_ROUTE unless user set to exception*/\n               if(firewall_config.rule_action_accept == true)\n\t\t\t   {\n\t\t\t        flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\t\t   }\n\t\t\t   else\n\t\t\t   {\n\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n                           }\n\t\t        }\n\t\t\telse\n\t\t\t{\n\t\t\t  flt_rule_entry.at_rear = true;\n\t\t\t  flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n                        }\n\n\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t\t sizeof(struct ipa_rule_attrib));\n\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0X00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\n\t\t\tmemcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t\tif (false == m_filtering.AddFilteringRule(m_pFilteringTable))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Adding Filtering rules, aborting...\\n\");\n\t\t\t\tfree(m_pFilteringTable);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"flt rule hdl0=0x%x, status=0x%x\\n\", m_pFilteringTable->rules[0].flt_rule_hdl, m_pFilteringTable->rules[0].status);\n\t\t\t}\n\t\t\t/* copy filter hdls*/\n\t\t\tdft_wan_fl_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;\n\t\t}\n\t}\n\n\tif(m_pFilteringTable != NULL)\n\t{\n\t\tfree(m_pFilteringTable);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\n/* configure the initial firewall filter rules */\nint IPACM_Wan::config_dft_firewall_rules_ex(struct ipa_flt_rule_add *rules, int rule_offset, ipa_ip_type iptype)\n{\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tint i;\n\tint num_rules = 0, original_num_rules = 0;\n\tipa_ioc_get_rt_tbl_indx rt_tbl_idx;\n\tipa_ioc_generate_flt_eq flt_eq;\n\tint pos = rule_offset;\n\n\tIPACMDBG_H(\"ip-family: %d; \\n\", iptype);\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif(rules == NULL || rule_offset < 0)\n\t{\n\t\tIPACMERR(\"No filtering table is available.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* default firewall is disable and the rule action is drop */\n\tmemset(&firewall_config, 0, sizeof(firewall_config));\n\tstrncpy(firewall_config.firewall_config_file, \"/etc/mobileap_firewall.xml\", sizeof(firewall_config.firewall_config_file));\n\n\t//if (firewall_config.firewall_config_file)\n\t{\n\t\tIPACMDBG_H(\"Firewall XML file is %s \\n\", firewall_config.firewall_config_file);\n\t\tif (IPACM_SUCCESS == IPACM_read_firewall_xml(firewall_config.firewall_config_file, &firewall_config))\n\t\t{\n\t\t\tIPACMDBG_H(\"QCMAP Firewall XML read OK \\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"QCMAP Firewall XML read failed, no that file, use default configuration \\n\");\n\t\t}\n\t}\n\t/*else\n\t//{\n\t\tIPACMERR(\"No firewall xml mentioned \\n\");\n\t\treturn IPACM_FAILURE;\n\t}*/\n\n\t/* add IPv6 frag rule when firewall is enabled*/\n\tif(iptype == IPA_IP_v6 && firewall_config.firewall_enable == true)\n\t{\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\trt_tbl_idx.ip = IPA_IP_v6;\n\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\t\tIPACMDBG_H(\"IPv6 frag flt rule uses routing table index %d\\n\", rt_tbl_idx.idx);\n\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= rx_prop->rx[0].attrib.attrib_mask;\n\t\tflt_rule_entry.rule.attrib.meta_data_mask = rx_prop->rx[0].attrib.meta_data_mask;\n\t\tflt_rule_entry.rule.attrib.meta_data = rx_prop->rx[0].attrib.meta_data;\n\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_FRAG_HDR;\n\n\t\tchange_to_network_order(IPA_IP_v6, &flt_rule_entry.rule.attrib);\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = IPA_IP_v6;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t&flt_eq.eq_attrib,\n\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\tpos++;\n\t\tIPACM_Wan::num_v6_flt_rule++;\n\t}\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\toriginal_num_rules = IPACM_Wan::num_v4_flt_rule;\n\t\tif(firewall_config.firewall_enable == true)\n\t\t{\n\t\t\tfor (i = 0; i < firewall_config.num_extd_firewall_entries; i++)\n\t\t\t{\n\t\t\t\tif (firewall_config.extd_firewall_entries[i].ip_vsn == 4)\n\t\t\t\t{\n\t\t\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\t\t\t\tflt_rule_entry.at_rear = true;\n\t\t\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\t\t\tflt_rule_entry.status = -1;\n\n\t\t\t\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\t\t\t\tflt_rule_entry.rule.to_uc = 0;\n\t\t\t\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\n\t\t\t\t\t/* Accept v4 matched rules*/\n\t\t\t\t\tif(firewall_config.rule_action_accept == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\t\t\t\t}\n\n\t\t\t\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\t\t\t\trt_tbl_idx.ip = iptype;\n\t\t\t\t\tif(flt_rule_entry.rule.action == IPA_PASS_TO_ROUTING)\n\t\t\t\t\t{\n\t\t\t\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\t\t\t\t}\n\t\t\t\t\telse /*pass to dst nat*/\n\t\t\t\t\t{\n\t\t\t\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, IPA_RESOURCE_NAME_MAX);\n\t\t\t\t\t}\n\n\t\t\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\t\t\t\tIPACMDBG_H(\"Routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\t\t\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t&firewall_config.extd_firewall_entries[i].attrib,\n\t\t\t\t\t\tsizeof(struct ipa_rule_attrib));\n\n\t\t\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= rx_prop->rx[0].attrib.attrib_mask;\n\t\t\t\t\tflt_rule_entry.rule.attrib.meta_data_mask = rx_prop->rx[0].attrib.meta_data_mask;\n\t\t\t\t\tflt_rule_entry.rule.attrib.meta_data = rx_prop->rx[0].attrib.meta_data;\n\n\t\t\t\t\tchange_to_network_order(IPA_IP_v4, &flt_rule_entry.rule.attrib);\n\n\t\t\t\t\t/* check if the rule is define as TCP_UDP, split into 2 rules, 1 for TCP and 1 UDP */\n\t\t\t\t\tif (firewall_config.extd_firewall_entries[i].attrib.u.v4.protocol == IPACM_FIREWALL_IPPROTO_TCP_UDP)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* insert TCP rule*/\n\t\t\t\t\t\tflt_rule_entry.rule.attrib.u.v4.protocol = IPACM_FIREWALL_IPPROTO_TCP;\n\n\t\t\t\t\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\t\t\t\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\t\t\t\t\tflt_eq.ip = iptype;\n\t\t\t\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t\t\t&flt_eq.eq_attrib,\n\t\t\t\t\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\t\t\t\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tIPACMDBG_H(\"Filter rule attrib mask: 0x%x\\n\", rules[pos].rule.attrib.attrib_mask);\n\t\t\t\t\t\tpos++;\n\t\t\t\t\t\tnum_firewall_v4++;\n\t\t\t\t\t\tIPACM_Wan::num_v4_flt_rule++;\n\n\t\t\t\t\t\t/* insert UDP rule*/\n\t\t\t\t\t\tflt_rule_entry.rule.attrib.u.v4.protocol = IPACM_FIREWALL_IPPROTO_UDP;\n\n\t\t\t\t\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\t\t\t\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\t\t\t\t\tflt_eq.ip = iptype;\n\t\t\t\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t\t\t&flt_eq.eq_attrib,\n\t\t\t\t\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\t\t\t\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tIPACMDBG_H(\"Filter rule attrib mask: 0x%x\\n\", rules[pos].rule.attrib.attrib_mask);\n\t\t\t\t\t\tpos++;\n\t\t\t\t\t\tnum_firewall_v4++;\n\t\t\t\t\t\tIPACM_Wan::num_v4_flt_rule++;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\t\t\t\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\t\t\t\t\tflt_eq.ip = iptype;\n\t\t\t\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t\t\t&flt_eq.eq_attrib,\n\t\t\t\t\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\t\t\t\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tIPACMDBG_H(\"Filter rule attrib mask: 0x%x\\n\", rules[pos].rule.attrib.attrib_mask);\n\t\t\t\t\t\tpos++;\n\t\t\t\t\t\tnum_firewall_v4++;\n\t\t\t\t\t\tIPACM_Wan::num_v4_flt_rule++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} /* end of firewall ipv4 filter rule add for loop*/\n\t\t}\n\t\t/* configure default filter rule */\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\n\t\t/* firewall disable, all traffic are allowed */\n\t\tif(firewall_config.firewall_enable == true)\n\t\t{\n\t\t\t/* default action for v4 is go DST_NAT unless user set to exception*/\n\t\t\tif(firewall_config.rule_action_accept == true)\n\t\t\t{\n\t\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT;\n\t\t}\n\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\trt_tbl_idx.ip = iptype;\n\n\t\tif(flt_rule_entry.rule.action == IPA_PASS_TO_ROUTING)\n\t\t{\n\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\t}\n\t\telse /*pass to dst nat*/\n\t\t{\n\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, IPA_RESOURCE_NAME_MAX);\n\t\t}\n\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\tIPACMDBG_H(\"Routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t&rx_prop->rx[0].attrib,\n\t\t\tsizeof(struct ipa_rule_attrib));\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0x00000000;\n\n\t\tchange_to_network_order(IPA_IP_v4, &flt_rule_entry.rule.attrib);\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t&flt_eq.eq_attrib,\n\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\tIPACMDBG_H(\"Filter rule attrib mask: 0x%x\\n\",\trules[pos].rule.attrib.attrib_mask);\n\t\tpos++;\n\t\tnum_firewall_v4++;\n\t\tIPACM_Wan::num_v4_flt_rule++;\n\n\t\tnum_rules = IPACM_Wan::num_v4_flt_rule - original_num_rules - 1;\n\t}\n\telse\n\t{\n\t\toriginal_num_rules = IPACM_Wan::num_v6_flt_rule;\n\n\t\tif(firewall_config.firewall_enable == true)\n\t\t{\n\t\t\tfor (i = 0; i < firewall_config.num_extd_firewall_entries; i++)\n\t\t\t{\n\t\t\t\tif (firewall_config.extd_firewall_entries[i].ip_vsn == 6)\n\t\t\t\t{\n\t\t\t\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\t\t\t\tflt_rule_entry.at_rear = true;\n\t\t\t\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\t\t\t\tflt_rule_entry.status = -1;\n\n\t\t\t\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\t\t\t\tflt_rule_entry.rule.to_uc = 0;\n\t\t\t\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\t\t\t\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\n\t\t\t\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\t\t\t\trt_tbl_idx.ip = iptype;\n\n\t\t\t\t\t/* matched rules for v6 go PASS_TO_ROUTE */\n\t\t\t\t\tif(firewall_config.rule_action_accept == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\t\t\t\t}\n\t\t\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\t\t\t\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\t\t\t\tIPACMDBG_H(\"Routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\t\t\t\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t\t&firewall_config.extd_firewall_entries[i].attrib,\n\t\t\t\t\t\tsizeof(struct ipa_rule_attrib));\n\n\t\t\t\t\tflt_rule_entry.rule.attrib.attrib_mask |= rx_prop->rx[0].attrib.attrib_mask;\n\t\t\t\t\tflt_rule_entry.rule.attrib.meta_data_mask = rx_prop->rx[0].attrib.meta_data_mask;\n\t\t\t\t\tflt_rule_entry.rule.attrib.meta_data = rx_prop->rx[0].attrib.meta_data;\n\n\t\t\t\t\tchange_to_network_order(IPA_IP_v6, &flt_rule_entry.rule.attrib);\n\n\t\t\t\t\t/* check if the rule is define as TCP/UDP */\n\t\t\t\t\tif (firewall_config.extd_firewall_entries[i].attrib.u.v6.next_hdr == IPACM_FIREWALL_IPPROTO_TCP_UDP)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* insert TCP rule*/\n\t\t\t\t\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = IPACM_FIREWALL_IPPROTO_TCP;\n\n\t\t\t\t\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\t\t\t\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\t\t\t\t\tflt_eq.ip = iptype;\n\t\t\t\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t\t\t&flt_eq.eq_attrib,\n\t\t\t\t\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\t\t\t\t\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tpos++;\n\t\t\t\t\t\tnum_firewall_v6++;\n\t\t\t\t\t\tIPACM_Wan::num_v6_flt_rule++;\n\n\t\t\t\t\t\t/* insert UDP rule*/\n\t\t\t\t\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = IPACM_FIREWALL_IPPROTO_UDP;\n\n\t\t\t\t\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\t\t\t\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\t\t\t\t\tflt_eq.ip = iptype;\n\t\t\t\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t\t\t&flt_eq.eq_attrib,\n\t\t\t\t\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\t\t\t\t\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tpos++;\n\t\t\t\t\t\tnum_firewall_v6++;\n\t\t\t\t\t\tIPACM_Wan::num_v6_flt_rule++;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\t\t\t\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\t\t\t\t\tflt_eq.ip = iptype;\n\t\t\t\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t\t\t&flt_eq.eq_attrib,\n\t\t\t\t\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\t\t\t\t\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\t\t\t\tpos++;\n\t\t\t\t\t\tnum_firewall_v6++;\n\t\t\t\t\t\tIPACM_Wan::num_v6_flt_rule++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} /* end of firewall ipv6 filter rule add for loop*/\n\t\t}\n\n\t\t/* setup default wan filter rule */\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\trt_tbl_idx.ip = iptype;\n\t\t/* firewall disable, all traffic are allowed */\n\t\tif(firewall_config.firewall_enable == true)\n\t\t{\n\t\t\t/* default action for v6 is PASS_TO_ROUTE unless user set to exception*/\n\t\t\tif(firewall_config.rule_action_accept == true)\n\t\t\t{\n\t\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, IPA_RESOURCE_NAME_MAX);\n\t\t}\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\tIPACMDBG_H(\"Routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t&rx_prop->rx[1].attrib,\n\t\t\tsizeof(struct ipa_rule_attrib));\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0X00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\n\t\tchange_to_network_order(IPA_IP_v6, &flt_rule_entry.rule.attrib);\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t&flt_eq.eq_attrib,\n\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\t\tmemcpy(&(rules[pos]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\tpos++;\n\t\tnum_firewall_v6++;\n\t\tIPACM_Wan::num_v6_flt_rule++;\n\n\t\tnum_rules = IPACM_Wan::num_v6_flt_rule - original_num_rules - 1;\n\t}\n\tIPACMDBG_H(\"Constructed %d firewall rules for ip type %d\\n\", num_rules, iptype);\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wan::init_fl_rule_ex(ipa_ip_type iptype)\n{\n\tint res = IPACM_SUCCESS;\n\n\tchar *dev_wlan0=\"wlan0\";\n\tchar *dev_wlan1=\"wlan1\";\n\tchar *dev_ecm0=\"ecm0\";\n\n\t/* update the iface ip-type to be IPA_IP_v4, IPA_IP_v6 or both*/\n\tif (iptype == IPA_IP_v4)\n\t{\n\n\t\tif ((ip_type == IPA_IP_v4) || (ip_type == IPA_IP_MAX))\n\t\t{\n\t\t\tIPACMDBG_H(\" interface(%s:%d) already in ip-type %d\\n\", dev_name, ipa_if_num, ip_type);\n\t\t\treturn res;\n\t\t}\n\n\t\tif (ip_type == IPA_IP_v6)\n\t\t{\n\t\t\tip_type = IPA_IP_MAX;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tip_type = IPA_IP_v4;\n\t\t}\n\t\tIPACMDBG_H(\" interface(%s:%d) now ip-type is %d\\n\", dev_name, ipa_if_num, ip_type);\n\t}\n\telse\n\t{\n\t\tif ((ip_type == IPA_IP_v6) || (ip_type == IPA_IP_MAX))\n\t\t{\n\t\t\tIPACMDBG_H(\" interface(%s:%d) already in ip-type %d\\n\", dev_name, ipa_if_num, ip_type);\n\t\t\treturn res;\n\t\t}\n\n\t\tif (ip_type == IPA_IP_v4)\n\t\t{\n\t\t\tip_type = IPA_IP_MAX;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tip_type = IPA_IP_v6;\n\t\t}\n\n\t\tIPACMDBG_H(\" interface(%s:%d) now ip-type is %d\\n\", dev_name, ipa_if_num, ip_type);\n\t}\n\n\t/* ADD corresponding ipa_rm_resource_name of RX-endpoint before adding all IPV4V6 FT-rules */\n\tIPACMDBG_H(\" dun add producer dependency from %s with registered rx-prop\\n\", dev_name);\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tif(modem_ipv4_pdn_index == 0)\t//install ipv4 default modem DL filtering rules only once\n\t\t{\n\t\t\t/* reset the num_v4_flt_rule*/\n\t\t\tIPACM_Wan::num_v4_flt_rule = 0;\n\t\t\tadd_dft_filtering_rule(flt_rule_v4, IPACM_Wan::num_v4_flt_rule, IPA_IP_v4);\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tif(modem_ipv6_pdn_index == 0)\t//install ipv6 default modem DL filtering rules only once\n\t\t{\n\t\t\t/* reset the num_v6_flt_rule*/\n\t\t\tIPACM_Wan::num_v6_flt_rule = 0;\n\t\t\tadd_dft_filtering_rule(flt_rule_v6, IPACM_Wan::num_v6_flt_rule, IPA_IP_v6);\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\tinstall_wan_filtering_rule(false);\n\nfail:\n\treturn res;\n}\n\nint IPACM_Wan::add_icmp_alg_rules(struct ipa_flt_rule_add *rules, int rule_offset, ipa_ip_type iptype)\n{\n\tint res = IPACM_SUCCESS, i, original_num_rules = 0, num_rules = 0;\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tIPACM_Config* ipacm_config = IPACM_Iface::ipacmcfg;\n\tipa_ioc_generate_flt_eq flt_eq;\n\tipa_ioc_get_rt_tbl_indx rt_tbl_idx;\n\n\tif(rules == NULL || rule_offset < 0)\n\t{\n\t\tIPACMERR(\"No filtering table is available.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\toriginal_num_rules = IPACM_Wan::num_v4_flt_rule;\n\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\trt_tbl_idx.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG_H(\"WAN DL routing table %s has index %d\\n\", IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, rt_tbl_idx.idx);\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\t/* Configuring ICMP filtering rule */\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\t/* remove meta data mask */\n\t\tflt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;\n\t\tflt_rule_entry.rule.attrib.u.v4.protocol = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP;\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\tmemcpy(&(rules[rule_offset]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\tIPACM_Wan::num_v4_flt_rule++;\n\n\t\t/* Configure ALG filtering rules */\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\t/* remove meta data mask */\n\t\tflt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_SRC_PORT;\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;\n\t\tfor(i = 0; i < ipacm_config->ipa_num_alg_ports; i++)\n\t\t{\n\t\t\tflt_rule_entry.rule.attrib.src_port = ipacm_config->alg_table[i].port;\n\t\t\tflt_rule_entry.rule.attrib.u.v4.protocol = ipacm_config->alg_table[i].protocol;\n\n\t\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\t\tflt_eq.ip = iptype;\n\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\t\t\tmemcpy(&(rules[rule_offset + 1 + i]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\t\tIPACM_Wan::num_v4_flt_rule++;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\t/* remove meta data mask */\n\t\tflt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_PORT;\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;\n\t\tfor(i = 0; i < ipacm_config->ipa_num_alg_ports; i++)\n\t\t{\n\t\t\tflt_rule_entry.rule.attrib.dst_port = ipacm_config->alg_table[i].port;\n\t\t\tflt_rule_entry.rule.attrib.u.v4.protocol = ipacm_config->alg_table[i].protocol;\n\n\t\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\t\tflt_eq.ip = iptype;\n\t\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\t\tmemcpy(&(rules[rule_offset + ipacm_config->ipa_num_alg_ports + 1 + i]),\n\t\t\t\t&flt_rule_entry,\n\t\t\t\tsizeof(struct ipa_flt_rule_add));\n\t\t\tIPACM_Wan::num_v4_flt_rule++;\n\t\t}\n\t\tnum_rules = IPACM_Wan::num_v4_flt_rule - original_num_rules;\n\t}\n\telse /* IPv6 case */\n\t{\n\t\toriginal_num_rules = IPACM_Wan::num_v6_flt_rule;\n\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\trt_tbl_idx.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG_H(\"WAN DL routing table %s has index %d\\n\", IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, rt_tbl_idx.idx);\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\t/* Configuring ICMP filtering rule */\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[1].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\t/* remove meta data mask */\n\t\tflt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6;\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\tmemcpy(&(rules[rule_offset]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\tIPACM_Wan::num_v6_flt_rule++;\n\n\t\tnum_rules = IPACM_Wan::num_v6_flt_rule - original_num_rules;\n\t}\n\nfail:\n\tIPACMDBG_H(\"Constructed %d ICMP/ALG rules for ip type %d\\n\", num_rules, iptype);\n\t\treturn res;\n}\n\nint IPACM_Wan::query_ext_prop()\n{\n\tint fd, ret = IPACM_SUCCESS, cnt;\n\n\tif (iface_query->num_ext_props > 0)\n\t{\n\t\tfd = open(IPA_DEVICE_NAME, O_RDWR);\n\t\tIPACMDBG_H(\"iface query-property \\n\");\n\t\tif (0 == fd)\n\t\t{\n\t\t\tIPACMERR(\"Failed opening %s.\\n\", IPA_DEVICE_NAME);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\text_prop = (struct ipa_ioc_query_intf_ext_props *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_query_intf_ext_props) +\n\t\t\t\t\t\t\tiface_query->num_ext_props * sizeof(struct ipa_ioc_ext_intf_prop));\n\t\tif(ext_prop == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to allocate memory.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemcpy(ext_prop->name, dev_name,\n\t\t\t\t\t sizeof(dev_name));\n\t\text_prop->num_ext_props = iface_query->num_ext_props;\n\n\t\tIPACMDBG_H(\"Query extended property for iface %s\\n\", ext_prop->name);\n\n\t\tret = ioctl(fd, IPA_IOC_QUERY_INTF_EXT_PROPS, ext_prop);\n\t\tif (ret < 0)\n\t\t{\n\t\t\tIPACMERR(\"ioctl IPA_IOC_QUERY_INTF_EXT_PROPS failed\\n\");\n\t\t\t/* ext_prop memory will free when iface-down*/\n\t\t\tfree(ext_prop);\n\t\t\tclose(fd);\n\t\t\treturn ret;\n\t\t}\n\n\t\tIPACMDBG_H(\"Wan interface has %d tx props, %d rx props and %d ext props\\n\", iface_query->num_tx_props, iface_query->num_rx_props, iface_query->num_ext_props);\n\n\t\tfor (cnt = 0; cnt < ext_prop->num_ext_props; cnt++)\n\t\t{\n\t\t\tIPACMDBG_H(\"Ex(%d): ip-type: %d, mux_id: %d, flt_action: %d\\n, rt_tbl_idx: %d, flt_hdr: %d \\n\",\n\t\t\t\t\t\t\t cnt, ext_prop->ext[cnt].ip, ext_prop->ext[cnt].mux_id, ext_prop->ext[cnt].action, ext_prop->ext[cnt].rt_tbl_idx, ext_prop->ext[cnt].filter_hdl);\n\t\t}\n\n\t\tif(IPACM_Wan::is_ext_prop_set == false)\n\t\t{\n\t\t\tIPACM_Iface::ipacmcfg->SetExtProp(ext_prop);\n\t\t\tIPACM_Wan::is_ext_prop_set = true;\n\t\t}\n\t\tclose(fd);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wan::config_wan_firewall_rule(ipa_ip_type iptype)\n{\n\tint res = IPACM_SUCCESS;\n\n\tIPACMDBG_H(\"Configure WAN DL firewall rules.\\n\");\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tIPACM_Wan::num_v4_flt_rule = IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4;\n\t\tif(IPACM_FAILURE == add_icmp_alg_rules(flt_rule_v4, IPACM_Wan::num_v4_flt_rule, IPA_IP_v4))\n\t\t{\n\t\t\tIPACMERR(\"Failed to add ICMP and ALG port filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"Succeded in constructing ICMP/ALG rules for ip type %d\\n\", iptype);\n\n\t\tif(IPACM_FAILURE == config_dft_firewall_rules_ex(flt_rule_v4, IPACM_Wan::num_v4_flt_rule, IPA_IP_v4))\n\t\t{\n\t\t\tIPACMERR(\"Failed to add firewall filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"Succeded in constructing firewall rules for ip type %d\\n\", iptype);\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tIPACM_Wan::num_v6_flt_rule = IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6;\n\t\tif(IPACM_FAILURE == add_icmp_alg_rules(flt_rule_v6, IPACM_Wan::num_v6_flt_rule, IPA_IP_v6))\n\t\t{\n\t\t\tIPACMERR(\"Failed to add ICMP and ALG port filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"Succeded in constructing ICMP/ALG rules for ip type %d\\n\", iptype);\n\n\t\tif(IPACM_FAILURE == config_dft_firewall_rules_ex(flt_rule_v6, IPACM_Wan::num_v6_flt_rule, IPA_IP_v6))\n\t\t{\n\t\t\tIPACMERR(\"Failed to add firewall filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"Succeded in constructing firewall rules for ip type %d\\n\", iptype);\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\nfail:\n\treturn res;\n}\n\nint IPACM_Wan::add_dft_filtering_rule(struct ipa_flt_rule_add *rules, int rule_offset, ipa_ip_type iptype)\n{\n\tstruct ipa_ioc_get_rt_tbl_indx rt_tbl_idx;\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tstruct ipa_ioc_generate_flt_eq flt_eq;\n\tint res = IPACM_SUCCESS;\n\n\tif(rules == NULL)\n\t{\n\t\tIPACMERR(\"No filtering table available.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMERR(\"No tx property.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\trt_tbl_idx.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG_H(\"Routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\tIPACMDBG_H(\"rx property attrib mask:0x%x\\n\", rx_prop->rx[0].attrib.attrib_mask);\n\n\t\t/* Configuring Multicast Filtering Rule */\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\t/* remove meta data mask since we only install default flt rules once for all modem PDN*/\n\t\tflt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0xF0000000;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0xE0000000;\n\n\t\tchange_to_network_order(IPA_IP_v4, &flt_rule_entry.rule.attrib);\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\t\tmemcpy(&(rules[rule_offset]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* Configuring Broadcast Filtering Rule */\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\t\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0xFFFFFFFF;\n\n\t\tchange_to_network_order(IPA_IP_v4, &flt_rule_entry.rule.attrib);\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\t\tmemcpy(&(rules[rule_offset + 1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\tIPACM_Wan::num_v4_flt_rule += IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4;\n\t\tIPACMDBG_H(\"Constructed %d default filtering rules for ip type %d\\n\", IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4, iptype);\n\t}\n\telse\t/*insert rules for ipv6*/\n\t{\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\trt_tbl_idx.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG_H(\"Routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\t/* Configuring Multicast Filtering Rule */\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.attrib));\n\t\t/* remove meta data mask since we only install default flt rules once for all modem PDN*/\n\t\tflt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n\t\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFF000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0xFF000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0x00000000;\n\n\t\tchange_to_network_order(IPA_IP_v6, &flt_rule_entry.rule.attrib);\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\t\tmemcpy(&(rules[rule_offset]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* Configuring fe80::/10 Link-Scoped Unicast Filtering Rule */\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFC00000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0xFE800000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0x00000000;\n\n\t\tchange_to_network_order(IPA_IP_v6, &flt_rule_entry.rule.attrib);\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\tmemcpy(&(rules[rule_offset + 1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* Configuring fec0::/10 Reserved by IETF Filtering Rule */\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFC00000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0xFEC00000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0x00000000;\n\n\t\tchange_to_network_order(IPA_IP_v6, &flt_rule_entry.rule.attrib);\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = iptype;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\n\t\tmemcpy(&(rules[rule_offset + 2]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n#ifdef FEATURE_IPA_ANDROID\n\t\tIPACMDBG_H(\"Add TCP ctrl rules: total num %d\\n\", IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6);\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t\tflt_rule_entry.at_rear = true;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\n\t\tflt_rule_entry.rule.retain_hdr = 1;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\n\t\tflt_rule_entry.rule.eq_attrib.rule_eq_bitmap = 0;\n\n\t\tflt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<1);\n\t\tflt_rule_entry.rule.eq_attrib.protocol_eq_present = 1;\n\t\tflt_rule_entry.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;\n\n\t\tflt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<8);\n\t\tflt_rule_entry.rule.eq_attrib.num_ihl_offset_meq_32 = 1;\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;\n\n\t\t/* add TCP FIN rule*/\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\t\tmemcpy(&(rules[rule_offset + 3]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* add TCP SYN rule*/\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\t\tmemcpy(&(rules[rule_offset + 4]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\t/* add TCP RST rule*/\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);\n\t\tflt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);\n\t\tmemcpy(&(rules[rule_offset + 5]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n#endif\n\n\t\tIPACM_Wan::num_v6_flt_rule += IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6;\n\t\tIPACMDBG_H(\"Constructed %d default filtering rules for ip type %d\\n\", IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6, iptype);\n\t}\n\nfail:\n\treturn res;\n}\n\nint IPACM_Wan::del_wan_firewall_rule(ipa_ip_type iptype)\n{\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tIPACM_Wan::num_v4_flt_rule = IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4;\n\t\tmemset(&IPACM_Wan::flt_rule_v4[IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4], 0,\n\t\t\t(IPA_MAX_FLT_RULE - IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4) * sizeof(struct ipa_flt_rule_add));\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tIPACM_Wan::num_v6_flt_rule = IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6;\n\t\tmemset(&IPACM_Wan::flt_rule_v6[IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6], 0,\n\t\t\t(IPA_MAX_FLT_RULE - IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6) * sizeof(struct ipa_flt_rule_add));\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*for STA mode: clean firewall filter rules */\nint IPACM_Wan::del_dft_firewall_rules(ipa_ip_type iptype)\n{\n\t/* free v4 firewall filter rule */\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif ((iptype == IPA_IP_v4) && (active_v4 == true))\n\t{\n\t\tif (num_firewall_v4 > IPACM_MAX_FIREWALL_ENTRIES)\n\t\t{\n\t\t\tIPACMERR(\"the number of v4 firewall entries overflow, aborting...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tif (num_firewall_v4 != 0)\n\t\t{\n\t\t\tif (m_filtering.DeleteFilteringHdls(firewall_hdl_v4,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v4, num_firewall_v4) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Deleting Filtering rules, aborting...\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMDBG_H(\"No ipv4 firewall rules, no need deleted\\n\");\n\t\t}\n\n\t\tif (m_filtering.DeleteFilteringHdls(dft_wan_fl_hdl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v4, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting Filtering rules, aborting...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tnum_firewall_v4 = 0;\n\t}\n\n\t/* free v6 firewall filter rule */\n\tif ((iptype == IPA_IP_v6) && (active_v6 == true))\n\t{\n\t\tif (num_firewall_v6 > IPACM_MAX_FIREWALL_ENTRIES)\n\t\t{\n\t\t\tIPACMERR(\"the number of v6 firewall entries overflow, aborting...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tif (num_firewall_v6 != 0)\n\t\t{\n\t\t\tif (m_filtering.DeleteFilteringHdls(firewall_hdl_v6,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v6, num_firewall_v6) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Deleting Filtering rules, aborting...\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMDBG_H(\"No ipv6 firewall rules, no need deleted\\n\");\n\t\t}\n\n\t\tif (m_filtering.DeleteFilteringHdls(&dft_wan_fl_hdl[1],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v6, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting Filtering rules, aborting...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tif (m_filtering.DeleteFilteringHdls(&dft_wan_fl_hdl[2],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v6, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Deleting Filtering rules, aborting...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tif (m_filtering.DeleteFilteringHdls(&ipv6_frag_firewall_flt_rule_hdl, IPA_IP_v6, 1) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error deleting IPv6 frag filtering rules.\\n\");\n\t\t}\n\t\tnum_firewall_v6 = 0;\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* for STA mode: wan default route/filter rule delete */\nint IPACM_Wan::handle_route_del_evt(ipa_ip_type iptype)\n{\n\tuint32_t tx_index;\n\tipacm_cmd_q_data evt_data;\n\n\tIPACMDBG_H(\"got handle_route_del_evt with ip-family:%d \\n\", iptype);\n\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No tx properties, ignore delete default route setting\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tis_default_gateway = false;\n\tIPACMDBG_H(\"Default route is deleted to iface %s.\\n\", dev_name);\n\n\tif (((iptype == IPA_IP_v4) && (active_v4 == true)) ||\n\t\t\t((iptype == IPA_IP_v6) && (active_v6 == true)))\n\t{\n\n\t\t/* Delete corresponding ipa_rm_resource_name of TX-endpoint after delete IPV4/V6 RT-rule */\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\tIPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\n\t\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t    if(iptype != tx_prop->tx[tx_index].ip)\n\t\t    {\n\t\t    \tIPACMDBG_H(\"Tx:%d, ip-type: %d conflict ip-type: %d, no RT-rule deleted\\n\",\n\t\t    \t\t\t\t\t    tx_index, tx_prop->tx[tx_index].ip,iptype);\n\t\t    \tcontinue;\n\t\t    }\n\n\t\t\tif (iptype == IPA_IP_v4)\n\t\t\t{\n\t\t    \tIPACMDBG_H(\"Tx:%d, ip-type: %d match ip-type: %d, RT-rule deleted\\n\", tx_index, tx_prop->tx[tx_index].ip,iptype);\n\n\t\t\t\tif (m_routing.DeleteRoutingHdl(wan_route_rule_v4_hdl[tx_index], IPA_IP_v4) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"IP-family:%d, Routing rule(hdl:0x%x) deletion failed with tx_index %d!\\n\", IPA_IP_v4, wan_route_rule_v4_hdl[tx_index], tx_index);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t    \tIPACMDBG_H(\"Tx:%d, ip-type: %d match ip-type: %d, RT-rule deleted\\n\", tx_index, tx_prop->tx[tx_index].ip,iptype);\n\n\t\t\t\tif (m_routing.DeleteRoutingHdl(wan_route_rule_v6_hdl[tx_index], IPA_IP_v6) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"IP-family:%d, Routing rule(hdl:0x%x) deletion failed with tx_index %d!\\n\", IPA_IP_v6, wan_route_rule_v6_hdl[tx_index], tx_index);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/* Delete the default wan route*/\n\t\tif (iptype == IPA_IP_v6)\n\t\t{\n\t\t   \tIPACMDBG_H(\"ip-type %d: default v6 wan RT-rule deleted\\n\",iptype);\n\t\t\tif (m_routing.DeleteRoutingHdl(wan_route_rule_v6_hdl_a5[0], IPA_IP_v6) == false)\n\t\t\t{\n\t\t\tIPACMDBG_H(\"IP-family:%d, Routing rule(hdl:0x%x) deletion failed!\\n\",IPA_IP_v6,wan_route_rule_v6_hdl_a5[0]);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\tipacm_event_iface_up *wandown_data;\n\t\twandown_data = (ipacm_event_iface_up *)malloc(sizeof(ipacm_event_iface_up));\n\t\tif (wandown_data == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(wandown_data, 0, sizeof(ipacm_event_iface_up));\n\n\t\tif (iptype == IPA_IP_v4)\n\t\t{\n\t\t\twandown_data->ipv4_addr = wan_v4_addr;\n\t\t\tif (m_is_sta_mode!=Q6_WAN)\n\t\t\t{\n\t\t\t\twandown_data->is_sta = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\twandown_data->is_sta = false;\n\t\t\t}\n\t\t\tevt_data.event = IPA_HANDLE_WAN_DOWN;\n\t\t\tevt_data.evt_data = (void *)wandown_data;\n\t\t\t/* Insert IPA_HANDLE_WAN_DOWN to command queue */\n\t\t\tIPACMDBG_H(\"posting IPA_HANDLE_WAN_DOWN for IPv4 (%d.%d.%d.%d) \\n\",\n\t\t\t\t\t(unsigned char)(wandown_data->ipv4_addr),\n\t\t\t\t\t(unsigned char)(wandown_data->ipv4_addr >> 8),\n\t\t\t\t\t(unsigned char)(wandown_data->ipv4_addr >> 16),\n\t\t\t\t\t(unsigned char)(wandown_data->ipv4_addr >> 24));\n\n\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\tIPACMDBG_H(\"setup wan_up/active_v4= false \\n\");\n\t\t\tIPACM_Wan::wan_up = false;\n\t\t\tactive_v4 = false;\n\t\t\tif(IPACM_Wan::wan_up_v6)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"modem v6-call still up(%s), not reset\\n\", IPACM_Wan::wan_up_dev_name);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmemset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name));\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (m_is_sta_mode!=Q6_WAN)\n\t\t\t{\n\t\t\t\twandown_data->is_sta = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\twandown_data->is_sta = false;\n\t\t\t}\n\t\t\tmemcpy(wandown_data->ipv6_prefix, ipv6_prefix, sizeof(wandown_data->ipv6_prefix));\n\t\t\tevt_data.event = IPA_HANDLE_WAN_DOWN_V6;\n\t\t\tevt_data.evt_data = (void *)wandown_data;\n\t\t\t/* Insert IPA_HANDLE_WAN_DOWN to command queue */\n\t\t\tIPACMDBG_H(\"posting IPA_HANDLE_WAN_DOWN for IPv6 with prefix 0x%08x%08x\\n\", ipv6_prefix[0], ipv6_prefix[1]);\n\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\tIPACMDBG_H(\"setup wan_up_v6/active_v6= false \\n\");\n\t\t\tIPACM_Wan::wan_up_v6 = false;\n\t\t\tactive_v6 = false;\n\t\t\tif(IPACM_Wan::wan_up)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"modem v4-call still up(%s), not reset\\n\", IPACM_Wan::wan_up_dev_name);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmemset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name));\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMDBG_H(\" The default WAN routing rules are deleted already \\n\");\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wan::handle_route_del_evt_ex(ipa_ip_type iptype)\n{\n\tipacm_cmd_q_data evt_data;\n\n\tIPACMDBG_H(\"got handle_route_del_evt_ex with ip-family:%d \\n\", iptype);\n\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No tx properties, ignore delete default route setting\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tis_default_gateway = false;\n\tIPACMDBG_H(\"Default route is deleted to iface %s.\\n\", dev_name);\n\n\tif (((iptype == IPA_IP_v4) && (active_v4 == true)) ||\n\t\t((iptype == IPA_IP_v6) && (active_v6 == true)))\n\t{\n\n\t\t/* Delete corresponding ipa_rm_resource_name of TX-endpoint after delete IPV4/V6 RT-rule */\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\tIPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\n\t\t/* Delete the default route*/\n\t\tif (iptype == IPA_IP_v6)\n\t\t{\n\t\t\tIPACMDBG_H(\"ip-type %d: default v6 wan RT-rule deleted\\n\",iptype);\n\t\t\tif (m_routing.DeleteRoutingHdl(wan_route_rule_v6_hdl_a5[0], IPA_IP_v6) == false)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"IP-family:%d, Routing rule(hdl:0x%x) deletion failed!\\n\",IPA_IP_v6,wan_route_rule_v6_hdl_a5[0]);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\n\t\tipacm_event_iface_up *wandown_data;\n\t\twandown_data = (ipacm_event_iface_up *)malloc(sizeof(ipacm_event_iface_up));\n\t\tif (wandown_data == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(wandown_data, 0, sizeof(ipacm_event_iface_up));\n\n\t\tif (iptype == IPA_IP_v4)\n\t\t{\n\t\t\twandown_data->ipv4_addr = wan_v4_addr;\n\t\t\tif (m_is_sta_mode!=Q6_WAN)\n\t\t\t{\n\t\t\t\twandown_data->is_sta = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\twandown_data->is_sta = false;\n\t\t\t}\n\t\t\tevt_data.event = IPA_HANDLE_WAN_DOWN;\n\t\t\tevt_data.evt_data = (void *)wandown_data;\n\t\t\t/* Insert IPA_HANDLE_WAN_DOWN to command queue */\n\t\t\tIPACMDBG_H(\"posting IPA_HANDLE_WAN_DOWN for IPv4 with address: 0x%x\\n\", wan_v4_addr);\n\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\n\t\t\tIPACMDBG_H(\"setup wan_up/active_v4= false \\n\");\n\t\t\tIPACM_Wan::wan_up = false;\n\t\t\tactive_v4 = false;\n\t\t\tif(IPACM_Wan::wan_up_v6)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"modem v6-call still up(%s), not reset\\n\", IPACM_Wan::wan_up_dev_name);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmemset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name));\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (m_is_sta_mode!=Q6_WAN)\n\t\t\t{\n\t\t\t\twandown_data->is_sta = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\twandown_data->is_sta = false;\n\t\t\t}\n\t\t\tmemcpy(wandown_data->ipv6_prefix, ipv6_prefix, sizeof(wandown_data->ipv6_prefix));\n\t\t\tevt_data.event = IPA_HANDLE_WAN_DOWN_V6;\n\t\t\tevt_data.evt_data = (void *)wandown_data;\n\t\t\tIPACMDBG_H(\"posting IPA_HANDLE_WAN_DOWN_V6 for IPv6 with prefix 0x%08x%08x\\n\", ipv6_prefix[0], ipv6_prefix[1]);\n\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\n\t\t\tIPACMDBG_H(\"setup wan_up_v6/active_v6= false \\n\");\n\t\t\tIPACM_Wan::wan_up_v6 = false;\n\t\t\tactive_v6 = false;\n\t\t\tif(IPACM_Wan::wan_up)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"modem v4-call still up(%s), not reset\\n\", IPACM_Wan::wan_up_dev_name);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmemset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name));\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMDBG_H(\" The default WAN routing rules are deleted already \\n\");\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* configure the initial embms filter rules */\nint IPACM_Wan::config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, ipa_ioc_add_flt_rule *pFilteringTable_v6)\n{\n\tstruct ipa_flt_rule_add flt_rule_entry;\n\tstruct ipa_ioc_get_rt_tbl_indx rt_tbl_idx;\n\tstruct ipa_ioc_generate_flt_eq flt_eq;\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif(pFilteringTable_v4 == NULL || pFilteringTable_v6 == NULL)\n\t{\n\t\tIPACMERR(\"Either v4 or v6 filtering table is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* set up ipv4 odu rule*/\n\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\n\t/* get eMBMS ODU tbl index*/\n\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v4.name, IPA_RESOURCE_NAME_MAX);\n\trt_tbl_idx.ip = IPA_IP_v4;\n\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t{\n\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tIPACMDBG_H(\"Odu routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\tflt_rule_entry.flt_rule_hdl = -1;\n\tflt_rule_entry.status = -1;\n\tflt_rule_entry.at_rear = false;\n\n\tflt_rule_entry.rule.retain_hdr = 0;\n\tflt_rule_entry.rule.to_uc = 0;\n\tflt_rule_entry.rule.eq_attrib_type = 1;\n\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t sizeof(struct ipa_rule_attrib));\n\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\tflt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0x00000000;\n\tflt_rule_entry.rule.attrib.u.v4.dst_addr = 0x00000000;\n\n\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\tflt_eq.ip = IPA_IP_v4;\n\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t{\n\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\n\tmemcpy(&(pFilteringTable_v4->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t/* construc v6 rule */\n\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\t/* get eMBMS ODU tbl*/\n\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v6.name, IPA_RESOURCE_NAME_MAX);\n\trt_tbl_idx.ip = IPA_IP_v6;\n\tif(0 != ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx))\n\t{\n\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tIPACMDBG_H(\"Odu routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\tflt_rule_entry.flt_rule_hdl = -1;\n\tflt_rule_entry.status = -1;\n\tflt_rule_entry.at_rear = false;\n\n\tflt_rule_entry.rule.retain_hdr = 0;\n\tflt_rule_entry.rule.to_uc = 0;\n\tflt_rule_entry.rule.eq_attrib_type = 1;\n\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t &rx_prop->rx[0].attrib,\n\t\t\t\t sizeof(struct ipa_rule_attrib));\n\tflt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0x00000000;\n\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\tflt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\tflt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0X00000000;\n\tflt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\tflt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\tflt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\n\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\tflt_eq.ip = IPA_IP_v6;\n\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t{\n\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t &flt_eq.eq_attrib,\n\t\t\t\t sizeof(flt_rule_entry.rule.eq_attrib));\n\n\tmemcpy(&(pFilteringTable_v6->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\treturn IPACM_SUCCESS;\n}\n\n\n/*for STA mode: handle wan-iface down event */\nint IPACM_Wan::handle_down_evt()\n{\n\tint res = IPACM_SUCCESS;\n\tint i;\n\n\tIPACMDBG_H(\" wan handle_down_evt \\n\");\n\n\t/* Delete corresponding ipa_rm_resource_name of TX-endpoint after delete IPV4/V6 RT-rule */\n\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\tif (tx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\tIPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t}\n\n\t/* no iface address up, directly close iface*/\n\tif (ip_type == IPACM_IP_NULL)\n\t{\n\t\tgoto fail;\n\t}\n\n\t/* make sure default routing rules and firewall rules are deleted*/\n\tif (active_v4)\n\t{\n\t   \tif (rx_prop != NULL)\n\t    {\n\t\t\tdel_dft_firewall_rules(IPA_IP_v4);\n\t\t}\n\t\thandle_route_del_evt(IPA_IP_v4);\n\t\tIPACMDBG_H(\"Delete default v4 routing rules\\n\");\n\t}\n\n\tif (active_v6)\n\t{\n\t   \tif (rx_prop != NULL)\n\t    {\n\t\t\tdel_dft_firewall_rules(IPA_IP_v6);\n\t\t}\n\t\thandle_route_del_evt(IPA_IP_v6);\n\t\tIPACMDBG_H(\"Delete default v6 routing rules\\n\");\n\t}\n\n\t/* Delete default v4 RT rule */\n\tif (ip_type != IPA_IP_v6)\n\t{\n\t\tIPACMDBG_H(\"Delete default v4 routing rules\\n\");\n\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false)\n\t\t{\n\t\t   IPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\t/* delete default v6 RT rule */\n\tif (ip_type != IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"Delete default v6 routing rules\\n\");\n\t\t/* May have multiple ipv6 iface-routing rules*/\n\t\tfor (i = 0; i < 2*num_dft_rt_v6; i++)\n\t\t{\n\t\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+i], IPA_IP_v6) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\n\t\tIPACMDBG_H(\"finished delete default v6 RT rules\\n \");\n\t}\n\n\n\t/* clean wan-client header, routing rules */\n\tIPACMDBG_H(\"left %d wan clients need to be deleted \\n \", num_wan_client);\n\tfor (i = 0; i < num_wan_client; i++)\n\t{\n\t\t\t/* Del NAT rules before ipv4 RT rules are delete */\n\t\t\tif(get_client_memptr(wan_client, i)->ipv4_set == true)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Clean Nat Rules for ipv4:0x%x\\n\", get_client_memptr(wan_client, i)->v4_addr);\n\t\t\t\tCtList->HandleSTAClientDelEvt(get_client_memptr(wan_client, i)->v4_addr);\n\t\t\t}\n\n\t\t\tif (delete_wan_rtrules(i, IPA_IP_v4))\n\t\t\t{\n\t\t\t\tIPACMERR(\"unbale to delete wan-client v4 route rules for index %d\\n\", i);\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tif (delete_wan_rtrules(i, IPA_IP_v6))\n\t\t\t{\n\t\t\t\tIPACMERR(\"unbale to delete ecm-client v6 route rules for index %d\\n\", i);\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tIPACMDBG_H(\"Delete %d client header\\n\", num_wan_client);\n\n\n\t\t\tif(get_client_memptr(wan_client, i)->ipv4_header_set == true)\n\t\t\t{\n\t\t\t\tif (m_header.DeleteHeaderHdl(get_client_memptr(wan_client, i)->hdr_hdl_v4)\n\t\t\t\t\t== false)\n\t\t\t\t{\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(get_client_memptr(wan_client, i)->ipv6_header_set == true)\n\t\t\t{\n\t\t\tif (m_header.DeleteHeaderHdl(get_client_memptr(wan_client, i)->hdr_hdl_v6)\n\t\t\t\t\t== false)\n\t\t\t{\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\t}\n\t} /* end of for loop */\n\n\t/* free the edm clients cache */\n\tIPACMDBG_H(\"Free wan clients cache\\n\");\n\n\t/* check software routing fl rule hdl */\n\tif (softwarerouting_act == true)\n\t{\n\t\thandle_software_routing_disable();\n\t}\n\n\t/* free filter rule handlers */\n\tif (ip_type != IPA_IP_v6 && rx_prop != NULL)\n\t{\n\t\tif (m_filtering.DeleteFilteringHdls(dft_v4fl_rule_hdl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v4,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPV4_DEFAULT_FILTERTING_RULES) == false)\n\t\t{\n\t\t\tIPACMERR(\"Error Delete Filtering rules, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG_H(\"finished delete default v4 filtering rules\\n \");\n\t}\n\n\n\tif (ip_type != IPA_IP_v4 && rx_prop != NULL)\n\t{\n\t\tif (m_filtering.DeleteFilteringHdls(dft_v6fl_rule_hdl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPA_IP_v6,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIPV6_DEFAULT_FILTERTING_RULES) == false)\n\t\t{\n\t\t\tIPACMERR(\"ErrorDeleting Filtering rule, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tif(num_ipv6_dest_flt_rule > 0 && num_ipv6_dest_flt_rule <= MAX_DEFAULT_v6_ROUTE_RULES)\n\t\t{\n\t\t\tif(m_filtering.DeleteFilteringHdls(ipv6_dest_flt_rule_hdl,  IPA_IP_v6, num_ipv6_dest_flt_rule) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to delete ipv6 dest flt rules.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tIPACMDBG_H(\"finished delete default v6 filtering rules\\n \");\n\t}\n\n\t/* delete the complete header for STA mode*/\n    if((header_set_v4 == true) || (header_set_v6 == true))\n    {\n        if (m_header.DeleteHeaderHdl(hdr_hdl_sta_v4) == false)\n\t\t{\n\t\t    IPACMERR(\"ErrorDeleting STA header for v4, aborting...\\n\");\n\t\t  \tres = IPACM_FAILURE;\n\t\t  \tgoto fail;\n\t\t}\n\n\t\tif (m_header.DeleteHeaderHdl(hdr_hdl_sta_v6) == false)\n\t\t{\n\t\t    IPACMERR(\"ErrorDeleting STA header for v6, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\nfail:\n\tif (tx_prop != NULL)\n\t{\n\t\tfree(tx_prop);\n\t}\n\tif (rx_prop != NULL)\n\t{\n\t\tfree(rx_prop);\n\t}\n\tif (iface_query != NULL)\n\t{\n\t\tfree(iface_query);\n\t}\n\tif (wan_route_rule_v4_hdl != NULL)\n\t{\n\t\tfree(wan_route_rule_v4_hdl);\n\t}\n\tif (wan_route_rule_v6_hdl != NULL)\n\t{\n\t\tfree(wan_route_rule_v6_hdl);\n\t}\n\tif (wan_route_rule_v6_hdl_a5 != NULL)\n\t{\n\t\tfree(wan_route_rule_v6_hdl_a5);\n\t}\n\tif (wan_client != NULL)\n\t{\n\t\tfree(wan_client);\n\t}\n\tclose(m_fd_ipa);\n\treturn res;\n}\n\nint IPACM_Wan::handle_down_evt_ex()\n{\n\tint res = IPACM_SUCCESS;\n\tint i, tether_total;\n\tint ipa_if_num_tether_tmp[IPA_MAX_IFACE_ENTRIES];\n\n\tIPACMDBG_H(\" wan handle_down_evt \\n\");\n\n\t/* no iface address up, directly close iface*/\n\tif (ip_type == IPACM_IP_NULL)\n\t{\n\t\tgoto fail;\n\t}\n\n\t/* free ODU filter rule handlers */\n\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == EMBMS_IF)\n\t{\n\t\tembms_is_on = false;\n\t\t/* Delete corresponding ipa_rm_resource_name of TX-endpoint after delete IPV4/V6 RT-rule */\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tif (tx_prop != NULL)\n\t\t{\n\t\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\t\tIPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\t}\n\n\t\tif (rx_prop != NULL)\n\t\t{\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t\tIPACMDBG(\"finished delete embms filtering rule\\n \");\n\t\t}\n\t\tgoto fail;\n\t}\n\n\tif(ip_type == IPA_IP_v4)\n\t{\n\t\tnum_ipv4_modem_pdn--;\n\t\tIPACMDBG_H(\"Now the number of ipv4 modem pdn is %d.\\n\", num_ipv4_modem_pdn);\n\t\t/* only when default gw goes down we post WAN_DOWN event*/\n\t\tif(is_default_gateway == true)\n\t\t{\n\t\t\tIPACM_Wan::wan_up = false;\n\t\t\tdel_wan_firewall_rule(IPA_IP_v4);\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t\thandle_route_del_evt_ex(IPA_IP_v4);\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t/* posting wan_down_tether for all lan clients */\n\t\t\tfor (i=0; i < IPACM_Wan::ipa_if_num_tether_v4_total; i++)\n\t\t\t{\n\t\t\t\tipa_if_num_tether_tmp[i] = IPACM_Wan::ipa_if_num_tether_v4[i];\n\t\t\t}\n\t\t\ttether_total = IPACM_Wan::ipa_if_num_tether_v4_total;\n\t\t\tfor (i=0; i < tether_total; i++)\n\t\t\t{\n\t\t\t\tpost_wan_down_tether_evt(IPA_IP_v4, ipa_if_num_tether_tmp[i]);\n\t\t\t\tIPACMDBG_H(\"post_wan_down_tether_v4 iface(%d: %s)\\n\",\n\t\t\t\t\ti, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether_tmp[i]].iface_name);\n\t\t\t}\n#endif\n\t\t\tif(IPACM_Wan::wan_up_v6)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"modem v6-call still up(%s), not reset\\n\", IPACM_Wan::wan_up_dev_name);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmemset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name));\n\t\t\t}\n\t\t}\n\n\t\t/* only when the last ipv4 modem interface goes down, delete ipv4 default flt rules*/\n\t\tif(num_ipv4_modem_pdn == 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"Now the number of modem ipv4 interface is 0, delete default flt rules.\\n\");\n\t\tIPACM_Wan::num_v4_flt_rule = 0;\n\t\tmemset(IPACM_Wan::flt_rule_v4, 0, IPA_MAX_FLT_RULE * sizeof(struct ipa_flt_rule_add));\n\t\tinstall_wan_filtering_rule(false);\n\t\t}\n\n\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false)\n\t\t{\n\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\telse if(ip_type == IPA_IP_v6)\n\t{\n\t    if (num_dft_rt_v6 > 1)\n\t\t\tnum_ipv6_modem_pdn--;\n\t\tIPACMDBG_H(\"Now the number of ipv6 modem pdn is %d.\\n\", num_ipv6_modem_pdn);\n\t\t/* only when default gw goes down we post WAN_DOWN event*/\n\t\tif(is_default_gateway == true)\n\t\t{\n\t\t\tIPACM_Wan::wan_up_v6 = false;\n\t\t\tdel_wan_firewall_rule(IPA_IP_v6);\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t\thandle_route_del_evt_ex(IPA_IP_v6);\n#ifdef FEATURE_IPA_ANDROID //sky\n\t\t\t/* posting wan_down_tether for all lan clients */\n\t\t\tfor (i=0; i < IPACM_Wan::ipa_if_num_tether_v6_total; i++)\n\t\t\t{\n\t\t\t\tipa_if_num_tether_tmp[i] = IPACM_Wan::ipa_if_num_tether_v6[i];\n\t\t\t}\n\t\t\ttether_total = IPACM_Wan::ipa_if_num_tether_v6_total;\n\t\t\tfor (i=0; i < tether_total; i++)\n\t\t\t{\n\t\t\t\tpost_wan_down_tether_evt(IPA_IP_v6, ipa_if_num_tether_tmp[i]);\n\t\t\t\tIPACMDBG_H(\"post_wan_down_tether_v6 iface(%d: %s)\\n\",\n\t\t\t\t\ti, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether_tmp[i]].iface_name);\n\t\t\t}\n#endif\n\t\t\tif(IPACM_Wan::wan_up)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"modem v4-call still up(%s), not reset\\n\", IPACM_Wan::wan_up_dev_name);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmemset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name));\n\t\t\t}\n\t\t}\n\n\t\t/* only when the last ipv6 modem interface goes down, delete ipv6 default flt rules*/\n\t\tif(num_ipv6_modem_pdn == 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"Now the number of modem ipv6 interface is 0, delete default flt rules.\\n\");\n\t\tIPACM_Wan::num_v6_flt_rule = 0;\n\t\tmemset(IPACM_Wan::flt_rule_v6, 0, IPA_MAX_FLT_RULE * sizeof(struct ipa_flt_rule_add));\n\t\tinstall_wan_filtering_rule(false);\n\t\t}\n\n\t\tfor (i = 0; i < 2*num_dft_rt_v6; i++)\n\t\t{\n\t\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+i], IPA_IP_v6) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tnum_ipv4_modem_pdn--;\n\t\tIPACMDBG_H(\"Now the number of ipv4 modem pdn is %d.\\n\", num_ipv4_modem_pdn);\n\t    if (num_dft_rt_v6 > 1)\n\t\t\tnum_ipv6_modem_pdn--;\n\t\tIPACMDBG_H(\"Now the number of ipv6 modem pdn is %d.\\n\", num_ipv6_modem_pdn);\n\t\t/* only when default gw goes down we post WAN_DOWN event*/\n\t\tif(is_default_gateway == true)\n\t\t{\n\t\t\tIPACM_Wan::wan_up = false;\n\t\t\tdel_wan_firewall_rule(IPA_IP_v4);\n\t\t\thandle_route_del_evt_ex(IPA_IP_v4);\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t/* posting wan_down_tether for all lan clients */\n\t\t\tfor (i=0; i < IPACM_Wan::ipa_if_num_tether_v4_total; i++)\n\t\t\t{\n\t\t\t\tipa_if_num_tether_tmp[i] = IPACM_Wan::ipa_if_num_tether_v4[i];\n\t\t\t}\n\t\t\ttether_total = IPACM_Wan::ipa_if_num_tether_v4_total;\n\t\t\tfor (i=0; i < tether_total; i++)\n\t\t\t{\n\t\t\t\tpost_wan_down_tether_evt(IPA_IP_v4, ipa_if_num_tether_tmp[i]);\n\t\t\t\tIPACMDBG_H(\"post_wan_down_tether_v4 iface(%d: %s)\\n\",\n\t\t\t\t\ti, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether_tmp[i]].iface_name);\n\t\t\t}\n#endif\n\t\t\tIPACM_Wan::wan_up_v6 = false;\n\t\t\tdel_wan_firewall_rule(IPA_IP_v6);\n\t\t\thandle_route_del_evt_ex(IPA_IP_v6);\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t/* posting wan_down_tether for all lan clients */\n\t\t\tfor (i=0; i < IPACM_Wan::ipa_if_num_tether_v6_total; i++)\n\t\t\t{\n\t\t\t\tipa_if_num_tether_tmp[i] = IPACM_Wan::ipa_if_num_tether_v6[i];\n\t\t\t}\n\t\t\ttether_total = IPACM_Wan::ipa_if_num_tether_v6_total;\n\t\t\tfor (i=0; i < tether_total; i++)\n\t\t\t{\n\t\t\t\tpost_wan_down_tether_evt(IPA_IP_v6, ipa_if_num_tether_tmp[i]);\n\t\t\t\tIPACMDBG_H(\"post_wan_down_tether_v6 iface(%d: %s)\\n\",\n\t\t\t\t\ti, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether_tmp[i]].iface_name);\n\t\t\t}\n#endif\n\t\t\tmemset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name));\n\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t}\n\n\t\t/* only when the last ipv4 modem interface goes down, delete ipv4 default flt rules*/\n\t\tif(num_ipv4_modem_pdn == 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"Now the number of modem ipv4 interface is 0, delete default flt rules.\\n\");\n\t\t\tIPACM_Wan::num_v4_flt_rule = 0;\n\t\t\tmemset(IPACM_Wan::flt_rule_v4, 0, IPA_MAX_FLT_RULE * sizeof(struct ipa_flt_rule_add));\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t}\n\t\t/* only when the last ipv6 modem interface goes down, delete ipv6 default flt rules*/\n\t\tif(num_ipv6_modem_pdn == 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"Now the number of modem ipv6 interface is 0, delete default flt rules.\\n\");\n\t\t\tIPACM_Wan::num_v6_flt_rule = 0;\n\t\t\tmemset(IPACM_Wan::flt_rule_v6, 0, IPA_MAX_FLT_RULE * sizeof(struct ipa_flt_rule_add));\n\t\t\tinstall_wan_filtering_rule(false);\n\t\t}\n\n\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false)\n\t\t{\n\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tfor (i = 0; i < 2*num_dft_rt_v6; i++)\n\t\t{\n\t\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+i], IPA_IP_v6) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t}\n\n\t/* check software routing fl rule hdl */\n\tif (softwarerouting_act == true)\n\t{\n\t\thandle_software_routing_disable();\n\t}\n\n\t/* delete the complete header for STA mode*/\n\tif((header_set_v4 == true) || (header_set_v6 == true))\n\t{\n\t\tif (m_header.DeleteHeaderHdl(hdr_hdl_sta_v4) == false)\n\t\t{\n\t\t\tIPACMERR(\"ErrorDeleting STA header for v4, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tif (m_header.DeleteHeaderHdl(hdr_hdl_sta_v6) == false)\n\t\t{\n\t\t\tIPACMERR(\"ErrorDeleting STA header for v6, aborting...\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\nfail:\n\tif (tx_prop != NULL)\n\t{\n\t\tfree(tx_prop);\n\t}\n\tif (rx_prop != NULL)\n\t{\n\t\tfree(rx_prop);\n\t}\n\tif (ext_prop != NULL)\n\t{\n\t\tfree(ext_prop);\n\t}\n\tif (iface_query != NULL)\n\t{\n\t\tfree(iface_query);\n\t}\n\tif (wan_route_rule_v4_hdl != NULL)\n\t{\n\t\tfree(wan_route_rule_v4_hdl);\n\t}\n\tif (wan_route_rule_v6_hdl != NULL)\n\t{\n\t\tfree(wan_route_rule_v6_hdl);\n\t}\n\tif (wan_route_rule_v6_hdl_a5 != NULL)\n\t{\n\t\tfree(wan_route_rule_v6_hdl_a5);\n\t}\n\tif (wan_client != NULL)\n\t{\n\t\tfree(wan_client);\n\t}\n\tclose(m_fd_ipa);\n\treturn res;\n}\n\nint IPACM_Wan::install_wan_filtering_rule(bool is_sw_routing)\n{\n\tint len, res = IPACM_SUCCESS;\n\tuint8_t mux_id;\n\tipa_ioc_add_flt_rule *pFilteringTable_v4 = NULL;\n\tipa_ioc_add_flt_rule *pFilteringTable_v6 = NULL;\n\n\tmux_id = IPACM_Iface::ipacmcfg->GetQmapId();\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\tif (is_sw_routing == true ||\n\t\t\tIPACM_Iface::ipacmcfg->ipa_sw_rt_enable == true)\n\t{\n\t\t/* contruct SW-RT rules to Q6*/\n\t\tstruct ipa_flt_rule_add flt_rule_entry;\n\t\tstruct ipa_ioc_get_rt_tbl_indx rt_tbl_idx;\n\t\tipa_ioc_generate_flt_eq flt_eq;\n\n\t\tIPACMDBG(\"\\n\");\n\t\tif (softwarerouting_act == true)\n\t\t{\n\t\t\tIPACMDBG(\"already setup software_routing rule for (%s)iface ip-family %d\\n\",\n\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ip_type);\n\t\t\treturn IPACM_SUCCESS;\n\t\t}\n\n\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);\n\t\tpFilteringTable_v4 = (struct ipa_ioc_add_flt_rule*)malloc(len);\n\t\tif (pFilteringTable_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(pFilteringTable_v4, 0, len);\n\t\tIPACMDBG_H(\"Total number of WAN DL filtering rule for IPv4 is 1\\n\");\n\n\t\tpFilteringTable_v4->commit = 1;\n\t\tpFilteringTable_v4->ep = rx_prop->rx[0].src_pipe;\n\t\tpFilteringTable_v4->global = false;\n\t\tpFilteringTable_v4->ip = IPA_IP_v4;\n\t\tpFilteringTable_v4->num_rules = (uint8_t)1;\n\n\t\t/* Configuring Software-Routing Filtering Rule */\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\trt_tbl_idx.ip = IPA_IP_v4;\n\t\tif(ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx) < 0)\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tIPACMDBG_H(\"Routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\t\tflt_rule_entry.at_rear = false;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t&rx_prop->rx[0].attrib,\n\t\t\t\t\tsizeof(flt_rule_entry.rule.attrib));\n\t\tflt_rule_entry.rule.retain_hdr = 0;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = IPA_IP_v4;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t&flt_eq.eq_attrib,\n\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\t\tmemcpy(&(pFilteringTable_v4->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\n\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);\n\t\tpFilteringTable_v6 = (struct ipa_ioc_add_flt_rule*)malloc(len);\n\t\tif (pFilteringTable_v6 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\tfree(pFilteringTable_v4);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(pFilteringTable_v6, 0, len);\n\t\tIPACMDBG_H(\"Total number of WAN DL filtering rule for IPv6 is 1\\n\");\n\n\t\tpFilteringTable_v6->commit = 1;\n\t\tpFilteringTable_v6->ep = rx_prop->rx[0].src_pipe;\n\t\tpFilteringTable_v6->global = false;\n\t\tpFilteringTable_v6->ip = IPA_IP_v6;\n\t\tpFilteringTable_v6->num_rules = (uint8_t)1;\n\n\t\t/* Configuring Software-Routing Filtering Rule */\n\t\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));\n\t\tmemset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));\n\t\tstrncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);\n\t\trt_tbl_idx.ip = IPA_IP_v6;\n\t\tif(ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx) < 0)\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table index from name\\n\");\n\t\t\tfree(pFilteringTable_v4);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tIPACMDBG_H(\"Routing table %s has index %d\\n\", rt_tbl_idx.name, rt_tbl_idx.idx);\n\n\t\tflt_rule_entry.at_rear = false;\n\t\tflt_rule_entry.flt_rule_hdl = -1;\n\t\tflt_rule_entry.status = -1;\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;\n\t\tmemcpy(&flt_rule_entry.rule.attrib,\n\t\t\t\t\t&rx_prop->rx[0].attrib,\n\t\t\t\t\tsizeof(flt_rule_entry.rule.attrib));\n\t\tflt_rule_entry.rule.retain_hdr = 0;\n\t\tflt_rule_entry.rule.to_uc = 0;\n\t\tflt_rule_entry.rule.eq_attrib_type = 1;\n\n\t\tmemset(&flt_eq, 0, sizeof(flt_eq));\n\t\tmemcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));\n\t\tflt_eq.ip = IPA_IP_v6;\n\t\tif(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get eq_attrib\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t&flt_eq.eq_attrib,\n\t\t\tsizeof(flt_rule_entry.rule.eq_attrib));\n\t\tmemcpy(&(pFilteringTable_v6->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));\n\t\tsoftwarerouting_act = true;\n\t\t/* end of contruct SW-RT rules to Q6*/\n\t}\n\telse\n\t{\n\t\tif(embms_is_on == false)\n\t\t{\n\t\t\tif(IPACM_Wan::num_v4_flt_rule > 0)\n\t\t\t{\n\t\t\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + IPACM_Wan::num_v4_flt_rule * sizeof(struct ipa_flt_rule_add);\n\t\t\t\tpFilteringTable_v4 = (struct ipa_ioc_add_flt_rule*)malloc(len);\n\n\t\t\t\tIPACMDBG_H(\"Total number of WAN DL filtering rule for IPv4 is %d\\n\", IPACM_Wan::num_v4_flt_rule);\n\n\t\t\t\tif (pFilteringTable_v4 == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tpFilteringTable_v4->commit = 1;\n\t\t\t\tpFilteringTable_v4->ep = rx_prop->rx[0].src_pipe;\n\t\t\t\tpFilteringTable_v4->global = false;\n\t\t\t\tpFilteringTable_v4->ip = IPA_IP_v4;\n\t\t\t\tpFilteringTable_v4->num_rules = (uint8_t)IPACM_Wan::num_v4_flt_rule;\n\n\t\t\t\tmemcpy(pFilteringTable_v4->rules, IPACM_Wan::flt_rule_v4, IPACM_Wan::num_v4_flt_rule * sizeof(ipa_flt_rule_add));\n\t\t\t}\n\n\t\t\tif(IPACM_Wan::num_v6_flt_rule > 0)\n\t\t\t{\n\t\t\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + IPACM_Wan::num_v6_flt_rule * sizeof(struct ipa_flt_rule_add);\n\t\t\t\tpFilteringTable_v6 = (struct ipa_ioc_add_flt_rule*)malloc(len);\n\n\t\t\t\tIPACMDBG_H(\"Total number of WAN DL filtering rule for IPv6 is %d\\n\", IPACM_Wan::num_v6_flt_rule);\n\n\t\t\t\tif (pFilteringTable_v6 == NULL)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\t\t\tfree(pFilteringTable_v4);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\t\t\t\tpFilteringTable_v6->commit = 1;\n\t\t\t\tpFilteringTable_v6->ep = rx_prop->rx[0].src_pipe;\n\t\t\t\tpFilteringTable_v6->global = false;\n\t\t\t\tpFilteringTable_v6->ip = IPA_IP_v6;\n\t\t\t\tpFilteringTable_v6->num_rules = (uint8_t)IPACM_Wan::num_v6_flt_rule;\n\n\t\t\t\tmemcpy(pFilteringTable_v6->rules, IPACM_Wan::flt_rule_v6, IPACM_Wan::num_v6_flt_rule * sizeof(ipa_flt_rule_add));\n\t\t\t}\n\t\t}\n\t\telse\t//embms is on, always add 1 embms rule on top of WAN DL flt table\n\t\t{\n\t\t\t/* allocate ipv4 filtering table */\n\t\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + (1 + IPACM_Wan::num_v4_flt_rule) * sizeof(struct ipa_flt_rule_add);\n\t\t\tpFilteringTable_v4 = (struct ipa_ioc_add_flt_rule*)malloc(len);\n\t\t\tIPACMDBG_H(\"Total number of WAN DL filtering rule for IPv4 is %d\\n\", IPACM_Wan::num_v4_flt_rule + 1);\n\t\t\tif (pFilteringTable_v4 == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\tpFilteringTable_v4->commit = 1;\n\t\t\tpFilteringTable_v4->ep = rx_prop->rx[0].src_pipe;\n\t\t\tpFilteringTable_v4->global = false;\n\t\t\tpFilteringTable_v4->ip = IPA_IP_v4;\n\t\t\tpFilteringTable_v4->num_rules = (uint8_t)IPACM_Wan::num_v4_flt_rule + 1;\n\n\t\t\t/* allocate ipv6 filtering table */\n\t\t\tlen = sizeof(struct ipa_ioc_add_flt_rule) + (1 + IPACM_Wan::num_v6_flt_rule) * sizeof(struct ipa_flt_rule_add);\n\t\t\tpFilteringTable_v6 = (struct ipa_ioc_add_flt_rule*)malloc(len);\n\t\t\tIPACMDBG_H(\"Total number of WAN DL filtering rule for IPv6 is %d\\n\", IPACM_Wan::num_v6_flt_rule + 1);\n\t\t\tif (pFilteringTable_v6 == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\t\t\tfree(pFilteringTable_v4);\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\tpFilteringTable_v6->commit = 1;\n\t\t\tpFilteringTable_v6->ep = rx_prop->rx[0].src_pipe;\n\t\t\tpFilteringTable_v6->global = false;\n\t\t\tpFilteringTable_v6->ip = IPA_IP_v6;\n\t\t\tpFilteringTable_v6->num_rules = (uint8_t)IPACM_Wan::num_v6_flt_rule + 1;\n\n\t\t\tconfig_dft_embms_rules(pFilteringTable_v4, pFilteringTable_v6);\n\t\t\tif(IPACM_Wan::num_v4_flt_rule > 0)\n\t\t\t{\n\t\t\t\tmemcpy(&(pFilteringTable_v4->rules[1]), IPACM_Wan::flt_rule_v4, IPACM_Wan::num_v4_flt_rule * sizeof(ipa_flt_rule_add));\n\t\t\t}\n\n\t\t\tif(IPACM_Wan::num_v6_flt_rule > 0)\n\t\t\t{\n\t\t\t\tmemcpy(&(pFilteringTable_v6->rules[1]), IPACM_Wan::flt_rule_v6, IPACM_Wan::num_v6_flt_rule * sizeof(ipa_flt_rule_add));\n\t\t\t}\n\t\t}\n\t}\n\n\tif(false == m_filtering.AddWanDLFilteringRule(pFilteringTable_v4, pFilteringTable_v6, mux_id))\n\t{\n\t\tIPACMERR(\"Failed to install WAN DL filtering table.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\nfail:\n\tif(pFilteringTable_v4 != NULL)\n\t{\n\t\tfree(pFilteringTable_v4);\n\t}\n\tif(pFilteringTable_v6 != NULL)\n\t{\n\t\tfree(pFilteringTable_v6);\n\t}\n\treturn res;\n}\n\nvoid IPACM_Wan::change_to_network_order(ipa_ip_type iptype, ipa_rule_attrib* attrib)\n{\n\tif(attrib == NULL)\n\t{\n\t\tIPACMERR(\"Attribute pointer is NULL.\\n\");\n\t\treturn;\n\t}\n\n\tif(iptype == IPA_IP_v6)\n\t{\n\t\tint i;\n\t\tfor(i=0; i<4; i++)\n\t\t{\n\t\t\tattrib->u.v6.src_addr[i] = htonl(attrib->u.v6.src_addr[i]);\n\t\t\tattrib->u.v6.src_addr_mask[i] = htonl(attrib->u.v6.src_addr_mask[i]);\n\t\t\tattrib->u.v6.dst_addr[i] = htonl(attrib->u.v6.dst_addr[i]);\n\t\t\tattrib->u.v6.dst_addr_mask[i] = htonl(attrib->u.v6.dst_addr_mask[i]);\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMDBG_H(\"IP type is not IPv6, do nothing: %d\\n\", iptype);\n\t}\n\n\treturn;\n}\n\nbool IPACM_Wan::is_global_ipv6_addr(uint32_t* ipv6_addr)\n{\n\tif(ipv6_addr == NULL)\n\t{\n\t\tIPACMERR(\"IPv6 address is empty.\\n\");\n\t\treturn false;\n\t}\n\tIPACMDBG_H(\"Get ipv6 address with first word 0x%08x.\\n\", ipv6_addr[0]);\n\n\tuint32_t ipv6_link_local_prefix, ipv6_link_local_prefix_mask;\n\tipv6_link_local_prefix = 0xFE800000;\n\tipv6_link_local_prefix_mask = 0xFFC00000;\n\tif((ipv6_addr[0] & ipv6_link_local_prefix_mask) == (ipv6_link_local_prefix & ipv6_link_local_prefix_mask))\n\t{\n\t\tIPACMDBG_H(\"This IPv6 address is link local.\\n\");\n\t\treturn false;\n\t}\n\telse\n\t{\n\t\tIPACMDBG_H(\"This IPv6 address is not link local.\\n\");\n\t\treturn true;\n\t}\n}\n\n/* handle STA WAN-client */\n/* handle WAN client initial, construct full headers (tx property) */\nint IPACM_Wan::handle_wan_hdr_init(uint8_t *mac_addr)\n{\n\n#define WAN_IFACE_INDEX_LEN 2\n\n\tint res = IPACM_SUCCESS, len = 0;\n\tchar index[WAN_IFACE_INDEX_LEN];\n\tstruct ipa_ioc_copy_hdr sCopyHeader;\n\tstruct ipa_ioc_add_hdr *pHeaderDescriptor = NULL;\n\tuint32_t cnt;\n\tint clnt_indx;\n\n\tclnt_indx = get_wan_client_index(mac_addr);\n\n\tif (clnt_indx != IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMERR(\"eth client is found/attached already with index %d \\n\", clnt_indx);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* add header to IPA */\n\tif (num_wan_client >= IPA_MAX_NUM_WAN_CLIENTS)\n\t{\n\t\tIPACMERR(\"Reached maximum number(%d) of eth clients\\n\", IPA_MAX_NUM_WAN_CLIENTS);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"WAN client number: %d\\n\", num_wan_client);\n\n\tmemcpy(get_client_memptr(wan_client, num_wan_client)->mac,\n\t\t\t\t mac_addr,\n\t\t\t\t sizeof(get_client_memptr(wan_client, num_wan_client)->mac));\n\n\n\tIPACMDBG_H(\"Received Client MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\tIPACMDBG_H(\"stored MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t get_client_memptr(wan_client, num_wan_client)->mac[0],\n\t\t\t\t\t get_client_memptr(wan_client, num_wan_client)->mac[1],\n\t\t\t\t\t get_client_memptr(wan_client, num_wan_client)->mac[2],\n\t\t\t\t\t get_client_memptr(wan_client, num_wan_client)->mac[3],\n\t\t\t\t\t get_client_memptr(wan_client, num_wan_client)->mac[4],\n\t\t\t\t\t get_client_memptr(wan_client, num_wan_client)->mac[5]);\n\n\t/* add header to IPA */\n\tif(tx_prop != NULL)\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_hdr) + (1 * sizeof(struct ipa_hdr_add));\n\t\tpHeaderDescriptor = (struct ipa_ioc_add_hdr *)calloc(1, len);\n\t\tif (pHeaderDescriptor == NULL)\n\t\t{\n\t\t\tIPACMERR(\"calloc failed to allocate pHeaderDescriptor\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\t/* copy partial header for v4*/\n\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\t\t if(tx_prop->tx[cnt].ip==IPA_IP_v4)\n\t\t\t\t {\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"Got partial v4-header name from %d tx props\\n\", cnt);\n\t\t\t\t\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\t\t\t\t\tmemcpy(sCopyHeader.name,\n\t\t\t\t\t\t\t\t\t\t\t tx_prop->tx[cnt].hdr_name,\n\t\t\t\t\t\t\t\t\t\t\t sizeof(sCopyHeader.name));\n\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"header name: %s in tx:%d\\n\", sCopyHeader.name,cnt);\n\t\t\t\t\t\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tPERROR(\"ioctl copy header failed\");\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"header eth2_ofst_valid: %d, eth2_ofst: %d\\n\", sCopyHeader.is_eth2_ofst_valid, sCopyHeader.eth2_ofst);\n\t\t\t\t\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\"header oversize\\n\");\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t\t\t\t\t\t\t\t sCopyHeader.hdr,\n\t\t\t\t\t\t\t\t\t\t\t\t sCopyHeader.hdr_len);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t/* copy client mac_addr to partial header */\n\t\t\t\t\t\t\t\tIPACMDBG_H(\"header eth2_ofst_valid: %d, eth2_ofst: %d\\n\",\n\t\t\t\t\t\t\t\t\t\tsCopyHeader.is_eth2_ofst_valid, sCopyHeader.eth2_ofst);\n\t\t\t\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[eth2_ofst_v4], mac_addr, IPA_MAC_ADDR_SIZE); /* only copy 6 bytes mac-address */\n\n\t\t\t\t\t\t\t\tpHeaderDescriptor->commit = true;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->num_hdrs = 1;\n\n\t\t\t\t\t\t\t\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t\t\t\t\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\t\t\t\t\tsnprintf(index,sizeof(index), \"%d\", ipa_if_num);\n\t\t\t\t\t\t\t\tstrlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\t\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WAN_PARTIAL_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tsnprintf(index,sizeof(index), \"%d\", header_name_count);\n\t\t\t\t\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\t\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status = -1;\n\n\t\t\t\t\t if (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t\t\t\t\t {\n\t\t\t\t\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t }\n\n\t\t\t\t\tget_client_memptr(wan_client, num_wan_client)->hdr_hdl_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\t\t\t\tIPACMDBG_H(\"eth-client(%d) v4 full header name:%s header handle:(0x%x)\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\t num_wan_client,\n\t\t\t\t\t\t\t\t\t\t\t\t pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t\t\t\t\t\t\t\t get_client_memptr(wan_client, num_wan_client)->hdr_hdl_v4);\n\t\t\t\t\t\t\t\t\tget_client_memptr(wan_client, num_wan_client)->ipv4_header_set=true;\n\n\t\t\t\t\tbreak;\n\t\t\t\t }\n\t\t}\n\n\n\t\t/* copy partial header for v6*/\n\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\tif(tx_prop->tx[cnt].ip==IPA_IP_v6)\n\t\t\t{\n\n\t\t\t\tIPACMDBG_H(\"Got partial v6-header name from %d tx props\\n\", cnt);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name,\n\t\t\t\t\t\ttx_prop->tx[cnt].hdr_name,\n\t\t\t\t\t\t\tsizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG_H(\"header name: %s in tx:%d\\n\", sCopyHeader.name,cnt);\n\t\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tPERROR(\"ioctl copy header failed\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tIPACMDBG_H(\"header eth2_ofst_valid: %d, eth2_ofst: %d\\n\", sCopyHeader.is_eth2_ofst_valid, sCopyHeader.eth2_ofst);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t\t\tsCopyHeader.hdr,\n\t\t\t\t\t\t\t\tsCopyHeader.hdr_len);\n\t\t\t\t}\n\n\t\t\t\t/* copy client mac_addr to partial header */\n\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[eth2_ofst_v6], mac_addr, IPA_MAC_ADDR_SIZE); /* only copy 6 bytes mac-address */\n\n\t\t\t\tpHeaderDescriptor->commit = true;\n\t\t\t\tpHeaderDescriptor->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", ipa_if_num);\n\t\t\t\tstrlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WAN_PARTIAL_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", header_name_count);\n\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\t\t\t\tpHeaderDescriptor->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tget_client_memptr(wan_client, num_wan_client)->hdr_hdl_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\t\t\tIPACMDBG_H(\"eth-client(%d) v6 full header name:%s header handle:(0x%x)\\n\",\n\t\t\t\t\t\t num_wan_client,\n\t\t\t\t\t\t pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t\t\t\t\t get_client_memptr(wan_client, num_wan_client)->hdr_hdl_v6);\n\n\t\t\t\t\t\t\t\t\tget_client_memptr(wan_client, num_wan_client)->ipv6_header_set=true;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\t\t}\n\t\t/* initialize wifi client*/\n\t\tget_client_memptr(wan_client, num_wan_client)->route_rule_set_v4 = false;\n\t\tget_client_memptr(wan_client, num_wan_client)->route_rule_set_v6 = 0;\n\t\tget_client_memptr(wan_client, num_wan_client)->ipv4_set = false;\n\t\tget_client_memptr(wan_client, num_wan_client)->ipv6_set = 0;\n\t\tnum_wan_client++;\n\t\theader_name_count++; //keep increasing header_name_count\n\t\tres = IPACM_SUCCESS;\n\t\tIPACMDBG_H(\"eth client number: %d\\n\", num_wan_client);\n\t}\n\telse\n\t{\n\t\treturn res;\n\t}\nfail:\n\tfree(pHeaderDescriptor);\n\n\treturn res;\n}\n\n/*handle eth client */\nint IPACM_Wan::handle_wan_client_ipaddr(ipacm_event_data_all *data)\n{\n\tint clnt_indx;\n\tint v6_num;\n\n\tIPACMDBG_H(\"number of wan clients: %d\\n\", num_wan_client);\n\tIPACMDBG_H(\" event MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t data->mac_addr[0],\n\t\t\t\t\t data->mac_addr[1],\n\t\t\t\t\t data->mac_addr[2],\n\t\t\t\t\t data->mac_addr[3],\n\t\t\t\t\t data->mac_addr[4],\n\t\t\t\t\t data->mac_addr[5]);\n\n\tclnt_indx = get_wan_client_index(data->mac_addr);\n\n\t\tif (clnt_indx == IPACM_INVALID_INDEX)\n\t\t{\n\t\t\tIPACMERR(\"wan client not found/attached \\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\tIPACMDBG_H(\"Ip-type received %d\\n\", data->iptype);\n\tif (data->iptype == IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"ipv4 address: 0x%x\\n\", data->ipv4_addr);\n\t\tif (data->ipv4_addr != 0) /* not 0.0.0.0 */\n\t\t{\n\t\t\tif (get_client_memptr(wan_client, clnt_indx)->ipv4_set == false)\n\t\t\t{\n\t\t\t\tget_client_memptr(wan_client, clnt_indx)->v4_addr = data->ipv4_addr;\n\t\t\t\tget_client_memptr(wan_client, clnt_indx)->ipv4_set = true;\n\t\t\t\t/* Add NAT rules after ipv4 RT rules are set */\n\t\t\t\tCtList->HandleSTAClientAddEvt(data->ipv4_addr);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t   /* check if client got new IPv4 address*/\n\t\t\t   if(data->ipv4_addr == get_client_memptr(wan_client, clnt_indx)->v4_addr)\n\t\t\t   {\n\t\t\t     IPACMDBG_H(\"Already setup ipv4 addr for client:%d, ipv4 address didn't change\\n\", clnt_indx);\n\t\t\t\t return IPACM_FAILURE;\n\t\t\t   }\n\t\t\t   else\n\t\t\t   {\n\t\t\t\t\tIPACMDBG_H(\"ipv4 addr for client:%d is changed \\n\", clnt_indx);\n\t\t\t\t\t/* Del NAT rules before ipv4 RT rules are delete */\n\t\t\t\t\tCtList->HandleSTAClientDelEvt(get_client_memptr(wan_client, clnt_indx)->v4_addr);\n\t\t\t\t\tdelete_wan_rtrules(clnt_indx,IPA_IP_v4);\n\t\t\t\t\tget_client_memptr(wan_client, clnt_indx)->route_rule_set_v4 = false;\n\t\t\t\t\tget_client_memptr(wan_client, clnt_indx)->v4_addr = data->ipv4_addr;\n\t\t\t\t\t/* Add NAT rules after ipv4 RT rules are set */\n\t\t\t\t\tCtList->HandleSTAClientAddEvt(data->ipv4_addr);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\tIPACMDBG_H(\"Invalid client IPv4 address \\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif ((data->ipv6_addr[0] != 0) || (data->ipv6_addr[1] != 0) ||\n\t\t\t\t(data->ipv6_addr[2] != 0) || (data->ipv6_addr[3] || 0)) /* check if all 0 not valid ipv6 address */\n\t\t{\n\t\t   IPACMDBG_H(\"ipv6 address: 0x%x:%x:%x:%x\\n\", data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n                   if(get_client_memptr(wan_client, clnt_indx)->ipv6_set < IPV6_NUM_ADDR)\n\t\t   {\n\n\t\t       for(v6_num=0;v6_num < get_client_memptr(wan_client, clnt_indx)->ipv6_set;v6_num++)\n\t               {\n\t\t\t      if( data->ipv6_addr[0] == get_client_memptr(wan_client, clnt_indx)->v6_addr[v6_num][0] &&\n\t\t\t           data->ipv6_addr[1] == get_client_memptr(wan_client, clnt_indx)->v6_addr[v6_num][1] &&\n\t\t\t  \t        data->ipv6_addr[2]== get_client_memptr(wan_client, clnt_indx)->v6_addr[v6_num][2] &&\n\t\t\t  \t         data->ipv6_addr[3] == get_client_memptr(wan_client, clnt_indx)->v6_addr[v6_num][3])\n\t\t\t      {\n\t\t\t  \t    IPACMDBG_H(\"Already see this ipv6 addr for client:%d\\n\", clnt_indx);\n\t\t\t  \t    return IPACM_FAILURE; /* not setup the RT rules*/\n\t\t\t      }\n\t\t       }\n\n\t\t       /* not see this ipv6 before for wifi client*/\n\t\t\t   get_client_memptr(wan_client, clnt_indx)->v6_addr[get_client_memptr(wan_client, clnt_indx)->ipv6_set][0] = data->ipv6_addr[0];\n\t\t\t   get_client_memptr(wan_client, clnt_indx)->v6_addr[get_client_memptr(wan_client, clnt_indx)->ipv6_set][1] = data->ipv6_addr[1];\n\t\t\t   get_client_memptr(wan_client, clnt_indx)->v6_addr[get_client_memptr(wan_client, clnt_indx)->ipv6_set][2] = data->ipv6_addr[2];\n\t\t\t   get_client_memptr(wan_client, clnt_indx)->v6_addr[get_client_memptr(wan_client, clnt_indx)->ipv6_set][3] = data->ipv6_addr[3];\n\t\t\t   get_client_memptr(wan_client, clnt_indx)->ipv6_set++;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t         IPACMDBG_H(\"Already got 3 ipv6 addr for client:%d\\n\", clnt_indx);\n\t\t\t return IPACM_FAILURE; /* not setup the RT rules*/\n\t\t    }\n\t\t}\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*handle wan client routing rule*/\nint IPACM_Wan::handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype)\n{\n\tstruct ipa_ioc_add_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_add *rt_rule_entry;\n\tuint32_t tx_index;\n\tint wan_index,v6_num;\n\tconst int NUM = 1;\n\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tIPACMDBG_H(\"Received mac_addr MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\twan_index = get_wan_client_index(mac_addr);\n\tif (wan_index == IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMDBG_H(\"wan client not found/attached \\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif (iptype==IPA_IP_v4) {\n\t\tIPACMDBG_H(\"wan client index: %d, ip-type: %d, ipv4_set:%d, ipv4_rule_set:%d \\n\", wan_index, iptype,\n\t\t\t\t\t get_client_memptr(wan_client, wan_index)->ipv4_set,\n\t\t\t\t\t get_client_memptr(wan_client, wan_index)->route_rule_set_v4);\n\t} else {\n\t\tIPACMDBG_H(\"wan client index: %d, ip-type: %d, ipv6_set:%d, ipv6_rule_num:%d \\n\", wan_index, iptype,\n\t\t\t\t\t get_client_memptr(wan_client, wan_index)->ipv6_set,\n\t\t\t\t\t get_client_memptr(wan_client, wan_index)->route_rule_set_v6);\n\t}\n\n\t/* Add default routing rules if not set yet */\n\tif ((iptype == IPA_IP_v4\n\t\t\t && get_client_memptr(wan_client, wan_index)->route_rule_set_v4 == false\n\t\t\t && get_client_memptr(wan_client, wan_index)->ipv4_set == true)\n\t\t\t|| (iptype == IPA_IP_v6\n\t\t            && get_client_memptr(wan_client, wan_index)->route_rule_set_v6 < get_client_memptr(wan_client, wan_index)->ipv6_set\n\t\t\t\t\t))\n\t{\n\n        \t/* Add corresponding ipa_rm_resource_name of TX-endpoint up before IPV6 RT-rule set */\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);\n\t\tIPACM_Iface::ipacmcfg->AddRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe],false);\n\n\t\trt_rule = (struct ipa_ioc_add_rt_rule *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t\t\t\t\t\tNUM * sizeof(struct ipa_rt_rule_add));\n\n\t\tif (rt_rule == NULL)\n\t\t{\n\t\t\tPERROR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\trt_rule->commit = 1;\n\t\trt_rule->num_rules = (uint8_t)NUM;\n\t\trt_rule->ip = iptype;\n\n\t\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t\tif(iptype != tx_prop->tx[tx_index].ip)\n\t\t    {\n\t\t\t\tIPACMDBG_H(\"Tx:%d, ip-type: %d conflict ip-type: %d no RT-rule added\\n\",\n\t\t\t\t\t\ttx_index, tx_prop->tx[tx_index].ip,iptype);\n\t\t   \t        continue;\n\t\t    }\n\n\t\t\trt_rule_entry = &rt_rule->rules[0];\n\t\t\trt_rule_entry->at_rear = 0;\n\n\t\t\tif (iptype == IPA_IP_v4)\n\t\t\t{\n\t\t        IPACMDBG_H(\"client index(%d):ipv4 address: 0x%x\\n\", wan_index,\n\t\t  \t\t        get_client_memptr(wan_client, wan_index)->v4_addr);\n\n                IPACMDBG_H(\"client(%d): v4 header handle:(0x%x)\\n\",\n\t\t  \t\t\t\t wan_index,\n\t\t  \t\t\t\t get_client_memptr(wan_client, wan_index)->hdr_hdl_v4);\n\t\t\t\tstrncpy(rt_rule->rt_tbl_name,\n\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_wan_v4.name,\n\t\t\t\t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n\t\t\t    rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\t    memcpy(&rt_rule_entry->rule.attrib,\n\t\t\t\t\t\t &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\t\t sizeof(rt_rule_entry->rule.attrib));\n\t\t\t    rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t    rt_rule_entry->rule.hdr_hdl = get_client_memptr(wan_client, wan_index)->hdr_hdl_v4;\n\t\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr = get_client_memptr(wan_client, wan_index)->v4_addr;\n\t\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\n\t\t\t    if (false == m_routing.AddRoutingRule(rt_rule))\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t\t\t\tfree(rt_rule);\n\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t}\n\n\t\t\t    /* copy ipv4 RT hdl */\n\t\t\t\tget_client_memptr(wan_client, wan_index)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v4 =\n  \t   \t        rt_rule->rules[0].rt_rule_hdl;\n\t\t        IPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t\t\tget_client_memptr(wan_client, wan_index)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v4, iptype);\n  \t   \t    } else {\n\n\t\t        for(v6_num = get_client_memptr(wan_client, wan_index)->route_rule_set_v6;v6_num < get_client_memptr(wan_client, wan_index)->ipv6_set;v6_num++)\n\t\t\t    {\n                    IPACMDBG_H(\"client(%d): v6 header handle:(0x%x)\\n\",\n\t\t  \t    \t\t\t wan_index,\n\t\t  \t    \t\t\t get_client_memptr(wan_client, wan_index)->hdr_hdl_v6);\n\n\t\t            /* v6 LAN_RT_TBL */\n\t\t\t    \tstrncpy(rt_rule->rt_tbl_name,\n\t\t\t    \t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_v6.name,\n\t\t\t    \t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n\t\t            /* Support QCMAP LAN traffic feature, send to A5 */\n\t\t\t\t\trt_rule_entry->rule.dst = iface_query->excp_pipe;\n\t\t\t        memset(&rt_rule_entry->rule.attrib, 0, sizeof(rt_rule_entry->rule.attrib));\n\t\t   \t        rt_rule_entry->rule.hdr_hdl = 0;\n\t\t\t        rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = get_client_memptr(wan_client, wan_index)->v6_addr[v6_num][0];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = get_client_memptr(wan_client, wan_index)->v6_addr[v6_num][1];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = get_client_memptr(wan_client, wan_index)->v6_addr[v6_num][2];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = get_client_memptr(wan_client, wan_index)->v6_addr[v6_num][3];\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\n\t\t\t\t\tif (false == m_routing.AddRoutingRule(rt_rule))\n\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t\t\t\t\t\tfree(rt_rule);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t\t\t\t}\n\n\t\t            get_client_memptr(wan_client, wan_index)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6[v6_num] = rt_rule->rules[0].rt_rule_hdl;\n\t\t            IPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t            \t\t\t\t get_client_memptr(wan_client, wan_index)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6[v6_num], iptype);\n\n\t\t\t        /*Copy same rule to v6 WAN RT TBL*/\n\t\t\t\t\tstrncpy(rt_rule->rt_tbl_name,\n\t\t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name,\n\t\t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n                    /* Downlink traffic from Wan iface, directly through IPA */\n\t\t\t\t\trt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\t        memcpy(&rt_rule_entry->rule.attrib,\n\t\t\t\t\t\t &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\t\t sizeof(rt_rule_entry->rule.attrib));\n\t\t   \t        rt_rule_entry->rule.hdr_hdl = get_client_memptr(wan_client, wan_index)->hdr_hdl_v6;\n\t\t\t        rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = get_client_memptr(wan_client, wan_index)->v6_addr[v6_num][0];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = get_client_memptr(wan_client, wan_index)->v6_addr[v6_num][1];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = get_client_memptr(wan_client, wan_index)->v6_addr[v6_num][2];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = get_client_memptr(wan_client, wan_index)->v6_addr[v6_num][3];\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\n\t\t            if (false == m_routing.AddRoutingRule(rt_rule))\n\t\t            {\n\t\t\t\t\t\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\t\t\t\t\t\tfree(rt_rule);\n\t\t\t\t\t\t\treturn IPACM_FAILURE;\n\t\t            }\n\n\t\t            get_client_memptr(wan_client, wan_index)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6_wan[v6_num] = rt_rule->rules[0].rt_rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t            \t\t\t\t get_client_memptr(wan_client, wan_index)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6_wan[v6_num], iptype);\n\t\t\t    }\n\t\t\t}\n\n\t\t} /* end of for loop */\n\n\t\tfree(rt_rule);\n\n\t\tif (iptype == IPA_IP_v4)\n\t\t{\n\t\t\tget_client_memptr(wan_client, wan_index)->route_rule_set_v4 = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tget_client_memptr(wan_client, wan_index)->route_rule_set_v6 = get_client_memptr(wan_client, wan_index)->ipv6_set;\n\t\t}\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*handle eth client */\nint IPACM_Wan::handle_network_stats_update(ipa_get_apn_data_stats_resp_msg_v01 *data)\n{\n\tFILE *fp = NULL;\n\n\tfor (int apn_index =0; apn_index < data->apn_data_stats_list_len; apn_index++)\n\t{\n\t\tif(data->apn_data_stats_list[apn_index].mux_id == ext_prop->ext[0].mux_id)\n\t\t{\n\t\t\tIPACMDBG_H(\"Received IPA_TETHERING_STATS_UPDATE_NETWORK_STATS, MUX ID %d TX (P%lu/B%lu) RX (P%lu/B%lu)\\n\",\n\t\t\t\tdata->apn_data_stats_list[apn_index].mux_id,\n\t\t\t\t\tdata->apn_data_stats_list[apn_index].num_ul_packets,\n\t\t\t\t\t\tdata->apn_data_stats_list[apn_index].num_ul_bytes,\n\t\t\t\t\t\t\tdata->apn_data_stats_list[apn_index].num_dl_packets,\n\t\t\t\t\t\t\t\tdata->apn_data_stats_list[apn_index].num_dl_bytes);\n\t\t\tfp = fopen(IPA_NETWORK_STATS_FILE_NAME, \"w\");\n\t\t\tif ( fp == NULL )\n\t\t\t{\n\t\t\t\tIPACMERR(\"Failed to write pipe stats to %s, error is %d - %s\\n\",\n\t\t\t\t\t\tIPA_NETWORK_STATS_FILE_NAME, errno, strerror(errno));\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\n\t\t\tfprintf(fp, NETWORK_STATS,\n\t\t\t\tdev_name,\n\t\t\t\t\tdata->apn_data_stats_list[apn_index].num_ul_packets,\n\t\t\t\t\t\tdata->apn_data_stats_list[apn_index].num_ul_bytes,\n\t\t\t\t\t\t\tdata->apn_data_stats_list[apn_index].num_dl_packets,\n\t\t\t\t\t\t\t\tdata->apn_data_stats_list[apn_index].num_dl_bytes);\n\t\t\tfclose(fp);\n\t\t\tbreak;\n\t\t};\n\t}\n\treturn IPACM_SUCCESS;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n* Redistributions of source code must retain the above copyright\n\tnotice, this list of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above\n\tcopyright notice, this list of conditions and the following\n\tdisclaimer in the documentation and/or other materials provided\n\twith the distribution.\n* Neither the name of The Linux Foundation nor the names of its\n\tcontributors may be used to endorse or promote products derived\n\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n@file\nIPACM_Wlan.cpp\n\n@brief\nThis file implements the WLAN iface functionality.\n\n@Author\nSkylar Chang\n\n*/\n\n#include <string.h>\n#include <unistd.h>\n#include <sys/ioctl.h>\n#include <IPACM_Wlan.h>\n#include <IPACM_Netlink.h>\n#include <fcntl.h>\n#include <sys/inotify.h>\n#include <IPACM_Wan.h>\n#include <IPACM_Lan.h>\n#include <IPACM_IfaceManager.h>\n#include <IPACM_ConntrackListener.h>\n\n\n/* static member to store the number of total wifi clients within all APs*/\nint IPACM_Wlan::total_num_wifi_clients = 0;\n\nuint32_t* IPACM_Wlan::dummy_flt_rule_hdl_v4 = NULL;\nuint32_t* IPACM_Wlan::dummy_flt_rule_hdl_v6 = NULL;\nint IPACM_Wlan::num_wlan_ap_iface = 0;\n\nlan2lan_flt_rule_hdl IPACM_Wlan::self_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\nlan2lan_flt_rule_hdl IPACM_Wlan::self_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];\n\nlan2lan_flt_rule_hdl IPACM_Wlan::usb_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_USB_CLIENT];\nlan2lan_flt_rule_hdl IPACM_Wlan::usb_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_USB_CLIENT];\n\nIPACM_Wlan::IPACM_Wlan(int iface_index) : IPACM_Lan(iface_index)\n{\n#define WLAN_AMPDU_DEFAULT_FILTER_RULES 3\n\n\twlan_ap_index = IPACM_Wlan::num_wlan_ap_iface;\n\tif(wlan_ap_index < 0 || wlan_ap_index > 1)\n\t{\n\t\tIPACMERR(\"Wlan_ap_index is not correct: %d, not creating instance.\\n\", wlan_ap_index);\n\t\tif (tx_prop != NULL)\n\t\t{\n\t\t\tfree(tx_prop);\n\t\t}\n\t\tif (rx_prop != NULL)\n\t\t{\n\t\t\tfree(rx_prop);\n\t\t}\n\t\tif (iface_query != NULL)\n\t\t{\n\t\t\tfree(iface_query);\n\t\t}\n\t\tdelete this;\n\t\treturn;\n\t}\n\n\tnum_wifi_client = 0;\n\theader_name_count = 0;\n\twlan_client = NULL;\n\n\tif(iface_query != NULL)\n\t{\n\t\twlan_client_len = (sizeof(ipa_wlan_client)) + (iface_query->num_tx_props * sizeof(wlan_client_rt_hdl));\n\t\twlan_client = (ipa_wlan_client *)calloc(IPA_MAX_NUM_WIFI_CLIENTS, wlan_client_len);\n\t\tif (wlan_client == NULL)\n\t\t{\n\t\t\tIPACMERR(\"unable to allocate memory\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"index:%d constructor: Tx properties:%d\\n\", iface_index, iface_query->num_tx_props);\n\t}\n\tNat_App = NatApp::GetInstance();\n\tif (Nat_App == NULL)\n\t{\n\t\tIPACMERR(\"unable to get Nat App instance \\n\");\n\t\treturn;\n\t}\n\n\n\tIPACM_Wlan::num_wlan_ap_iface++;\n\tIPACMDBG_H(\"Now the number of wlan AP iface is %d\\n\", IPACM_Wlan::num_wlan_ap_iface);\n\tadd_dummy_flt_rule();\n\n\tmemset(wlan_guest_ap_flt_rule_hdl_v4, 0, IPA_MAX_PRIVATE_SUBNET_ENTRIES * sizeof(uint32_t));\n\twlan_guest_ap_flt_rule_hdl_v6 = 0;\n\tis_guest_ap = false;\n\tnum_usb_client = 0;\n\n\tmemset(eth_bridge_usb_client_flt_info, 0, IPA_LAN_TO_LAN_MAX_USB_CLIENT * sizeof(eth_bridge_client_flt_info));\n\tnum_usb_client = 0;\n\teth_bridge_wlan_client_rt_from_usb_info_v4 = NULL;\n\teth_bridge_wlan_client_rt_from_usb_info_v6 = NULL;\n\teth_bridge_wlan_client_rt_from_wlan_info_v4 = NULL;\n\teth_bridge_wlan_client_rt_from_wlan_info_v6 = NULL;\n\tif(tx_prop != NULL)\n\t{\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tclient_rt_info_size_v4 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v4 * sizeof(uint32_t);\n\t\teth_bridge_wlan_client_rt_from_usb_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v4);\n\t\teth_bridge_wlan_client_rt_from_wlan_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v4);\n\n\t\tclient_rt_info_size_v6 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v6 * sizeof(uint32_t);\n\t\teth_bridge_wlan_client_rt_from_usb_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v6);\n\t\teth_bridge_wlan_client_rt_from_wlan_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v6);\n#endif\n\t}\n\twlan_client_rt_from_usb_info_count_v4 = 0;\n\twlan_client_rt_from_usb_info_count_v6 = 0;\n\twlan_client_rt_from_wlan_info_count_v4 = 0;\n\twlan_client_rt_from_wlan_info_count_v6 = 0;\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tif(iface_query != NULL)\n\t{\n\t\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF && tx_prop != NULL)\n\t\t{\n\t\t\tif(IPACM_Lan::wlan_hdr_type != IPA_HDR_L2_NONE && tx_prop->tx[0].hdr_l2_type != IPACM_Lan::wlan_hdr_type)\n\t\t\t{\n\t\t\t\tIPACMERR(\"The WLAN header format is not consistent! Now header format is %d.\\n\", tx_prop->tx[0].hdr_l2_type);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(wlan_ap_index == 0)\n\t\t\t\t{\n\t\t\t\t\tif(eth_bridge_get_hdr_template_hdl(&IPACM_Lan::wlan_hdr_template_hdl) == IPACM_FAILURE)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMERR(\"Failed to setup wlan hdr template.\\n\");\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACM_Lan::wlan_hdr_type = tx_prop->tx[0].hdr_l2_type;\n\t\t\t\t\t\tadd_hdr_proc_ctx();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n#endif\n\n#ifdef FEATURE_IPA_ANDROID\n\t/* set the IPA-client pipe enum */\n\tif(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF)\n\t{\n\t\thandle_tethering_client(false, IPACM_CLIENT_WLAN);\n\t}\n#endif\n\treturn;\n}\n\n\nIPACM_Wlan::~IPACM_Wlan()\n{\n\tIPACM_EvtDispatcher::deregistr(this);\n\tIPACM_IfaceManager::deregistr(this);\n\treturn;\n}\n\nvoid IPACM_Wlan::event_callback(ipa_cm_event_id event, void *param)\n{\n\tif(is_active == false && event != IPA_LAN_DELETE_SELF)\n\t{\n\t\tIPACMDBG_H(\"The interface is no longer active, return.\\n\");\n\t\treturn;\n\t}\n\n\tint ipa_interface_index;\n\tint wlan_index;\n\tipacm_ext_prop* ext_prop;\n\tipacm_event_iface_up* data_wan;\n\tipacm_event_iface_up_tehter* data_wan_tether;\n\n\tswitch (event)\n\t{\n\n\tcase IPA_WLAN_LINK_DOWN_EVENT:\n\t\t{\n\t\t\tipacm_event_data_fid *data = (ipacm_event_data_fid *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_WLAN_LINK_DOWN_EVENT\\n\");\n\t\t\t\thandle_down_evt();\n\t\t\t\t/* reset the AP-iface category to unknown */\n\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat=UNKNOWN_IF;\n\t\t\t\tIPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface\n\t\t\t\tIPACM_Wlan::total_num_wifi_clients = (IPACM_Wlan::total_num_wifi_clients) - \\\n                                                                     (num_wifi_client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_PRIVATE_SUBNET_CHANGE_EVENT:\n\t\t{\n\t\t\tipacm_event_data_fid *data = (ipacm_event_data_fid *)param;\n\t\t\t/* internel event: data->if_index is ipa_if_index */\n\t\t\tif (data->if_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_PRIVATE_SUBNET_CHANGE_EVENT from itself posting, ignore\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_PRIVATE_SUBNET_CHANGE_EVENT from other LAN iface \\n\");\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\thandle_private_subnet_android(IPA_IP_v4);\n#endif\n\t\t\t\tIPACMDBG_H(\" delete old private subnet rules, use new sets \\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_LAN_DELETE_SELF:\n\t{\n\t\tipacm_event_data_fid *data = (ipacm_event_data_fid *)param;\n\t\tif(data->if_index == ipa_if_num)\n\t\t{\n\t\t\tIPACM_Wlan::num_wlan_ap_iface--;\n\t\t\tIPACMDBG_H(\"Now the number of wlan AP iface is %d\\n\", IPACM_Wlan::num_wlan_ap_iface);\n\t\t\tdel_dummy_flt_rule();\n\n\t\t\tIPACMDBG_H(\"Received IPA_LAN_DELETE_SELF event.\\n\");\n\t\t\tIPACMDBG_H(\"ipa_WLAN (%s):ipa_index (%d) instance close \\n\", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ipa_if_num);\n\t\t\tdelete this;\n\t\t}\n\t\tbreak;\n\t}\n\n\tcase IPA_ADDR_ADD_EVENT:\n\t\t{\n\t\t\tipacm_event_data_addr *data = (ipacm_event_data_addr *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\n\t\t\tif ( (data->iptype == IPA_IP_v4 && data->ipv4_addr == 0) ||\n\t\t\t\t\t (data->iptype == IPA_IP_v6 &&\n\t\t\t\t\t\tdata->ipv6_addr[0] == 0 && data->ipv6_addr[1] == 0 &&\n\t\t\t\t\t  data->ipv6_addr[2] == 0 && data->ipv6_addr[3] == 0) )\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Invalid address, ignore IPA_ADDR_ADD_EVENT event\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\t/* check v4 not setup before, v6 can have 2 iface ip */\n\t\t\t\tif( ((data->iptype != ip_type) && (ip_type != IPA_IP_MAX))\n\t\t\t\t    || ((data->iptype==IPA_IP_v6) && (num_dft_rt_v6!=MAX_DEFAULT_v6_ROUTE_RULES)))\n\t\t\t\t{\n\t\t\t\t  IPACMDBG_H(\"Got IPA_ADDR_ADD_EVENT ip-family:%d, v6 num %d: \\n\",data->iptype,num_dft_rt_v6);\n\t\t\t\t\t/* Post event to NAT */\n\t\t\t\t\tif (data->iptype == IPA_IP_v4)\n\t\t\t\t\t{\n\t\t\t\t\t\tipacm_cmd_q_data evt_data;\n\t\t\t\t\t\tipacm_event_iface_up *info;\n\n\t\t\t\t\t\tinfo = (ipacm_event_iface_up *)\n\t\t\t\t\t\t\t malloc(sizeof(ipacm_event_iface_up));\n\t\t\t\t\t\tif (info == NULL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMERR(\"Unable to allocate memory\\n\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmemcpy(info->ifname, dev_name, IF_NAME_LEN);\n\t\t\t\t\t\tinfo->ipv4_addr = data->ipv4_addr;\n\t\t\t\t\t\tinfo->addr_mask = IPACM_Iface::ipacmcfg->private_subnet_table[0].subnet_mask;\n\n\t\t\t\t\t\tevt_data.event = IPA_HANDLE_WLAN_UP;\n\t\t\t\t\t\tevt_data.evt_data = (void *)info;\n\n\t\t\t\t\t\t/* Insert IPA_HANDLE_WLAN_UP to command queue */\n\t\t\t\t\t\tIPACMDBG_H(\"posting IPA_HANDLE_WLAN_UP for IPv4 with below information\\n\");\n\t\t\t\t\t\tIPACMDBG_H(\"IPv4 address:0x%x, IPv4 address mask:0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t info->ipv4_addr, info->addr_mask);\n\t\t\t\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t\t\t\t}\n\t\t\t\t\tif ((num_dft_rt_v6 == 0) && (data->iptype == IPA_IP_v6) && (wlan_ap_index == 0))\n\t\t\t\t\t{\n\t\t\t\t\t\t\tinstall_ipv6_icmp_flt_rule();\n\t\t\t\t\t}\n\t\t\t\t\tif(handle_addr_evt(data) == IPACM_FAILURE)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n#ifdef FEATURE_IPA_ANDROID\n\t\t\t\t\tadd_dummy_private_subnet_flt_rule(data->iptype);\n\t\t\t\t\thandle_private_subnet_android(data->iptype);\n#else\n\t\t\t\t\tif(wlan_ap_index == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\thandle_private_subnet(data->iptype);\n\t\t\t\t\t}\n#endif\n\n\t\t\t\t\tif (IPACM_Wan::isWanUP(ipa_if_num))\n\t\t\t\t\t{\n\t\t\t\t\t\tif(data->iptype == IPA_IP_v4 || data->iptype == IPA_IP_MAX)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(IPACM_Wan::backhaul_is_sta_mode == false)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v4);\n\t\t\t\t\t\t\t\tIPACM_Lan::handle_wan_up_ex(ext_prop, IPA_IP_v4);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tIPACM_Lan::handle_wan_up(IPA_IP_v4);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif(IPACM_Wan::isWanUP_V6(ipa_if_num))\n\t\t\t\t\t{\n\t\t\t\t\t\tif((data->iptype == IPA_IP_v6 || data->iptype == IPA_IP_MAX) && num_dft_rt_v6 == 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(wlan_ap_index == 0) //install ipv6 prefix rule only once\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinstall_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(IPACM_Wan::backhaul_is_sta_mode == false)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v6);\n\t\t\t\t\t\t\t\tIPACM_Lan::handle_wan_up_ex(ext_prop, IPA_IP_v6);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tIPACM_Lan::handle_wan_up(IPA_IP_v6);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tIPACMDBG_H(\"posting IPA_HANDLE_WLAN_UP:Finished checking wan_up\\n\");\n\t\t\t\t\t/* checking if SW-RT_enable */\n\t\t\t\t\tif (IPACM_Iface::ipacmcfg->ipa_sw_rt_enable == true)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* handle software routing enable event*/\n\t\t\t\t\t\tIPACMDBG_H(\"IPA_SW_ROUTING_ENABLE for iface: %s \\n\",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);\n\t\t\t\t\t\thandle_software_routing_enable();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n#ifdef FEATURE_IPA_ANDROID\n\tcase IPA_HANDLE_WAN_UP_TETHER:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_UP_TETHER event\\n\");\n\n\t\tdata_wan_tether = (ipacm_event_iface_up_tehter*)param;\n\t\tif(data_wan_tether == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d, if_index_tether:%d tether_if_name:%s\\n\", data_wan_tether->is_sta,\n\t\t\t\t\tdata_wan_tether->if_index_tether,\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[data_wan_tether->if_index_tether].iface_name);\n\t\tif (data_wan_tether->if_index_tether == ipa_if_num)\n\t\t{\n\t\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\tif(data_wan_tether->is_sta == false)\n\t\t\t\t{\n\t\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v4);\n\t\t\t\t\tIPACM_Lan::handle_wan_up_ex(ext_prop, IPA_IP_v4);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACM_Lan::handle_wan_up(IPA_IP_v4);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_UP_V6_TETHER:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_UP_V6_TETHER event\\n\");\n\n\t\tdata_wan_tether = (ipacm_event_iface_up_tehter*)param;\n\t\tif(data_wan_tether == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d, if_index_tether:%d tether_if_name:%s\\n\", data_wan_tether->is_sta,\n\t\t\t\t\tdata_wan_tether->if_index_tether,\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[data_wan_tether->if_index_tether].iface_name);\n\t\tif (data_wan_tether->if_index_tether == ipa_if_num)\n\t\t{\n\t\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\tif(wlan_ap_index == 0) //install ipv6 prefix rule only once\n\t\t\t\t{\n\t\t\t\t\tinstall_ipv6_prefix_flt_rule(data_wan_tether->ipv6_prefix);\n\t\t\t\t}\n\t\t\t\tif(data_wan_tether->is_sta == false)\n\t\t\t\t{\n\t\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v6);\n\t\t\t\t\tIPACM_Lan::handle_wan_up_ex(ext_prop, IPA_IP_v6);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACM_Lan::handle_wan_up(IPA_IP_v6);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_DOWN_TETHER:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN_TETHER event\\n\");\n\t\tdata_wan_tether = (ipacm_event_iface_up_tehter*)param;\n\t\tif(data_wan_tether == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d, if_index_tether:%d tether_if_name:%s\\n\", data_wan_tether->is_sta,\n\t\t\t\t\tdata_wan_tether->if_index_tether,\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[data_wan_tether->if_index_tether].iface_name);\n\t\tif (data_wan_tether->if_index_tether == ipa_if_num)\n\t\t{\n\t\t\tif(data_wan_tether->is_sta == false && wlan_ap_index > 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"This is not the first AP instance and not STA mode, ignore WAN_DOWN event.\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (rx_prop != NULL)\n\t\t\t{\n\t\t\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t\t\t{\n\t\t\t\t\thandle_wan_down(data_wan_tether->is_sta);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_DOWN_V6_TETHER:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN_V6_TETHER event\\n\");\n\t\tdata_wan_tether = (ipacm_event_iface_up_tehter*)param;\n\t\tif(data_wan_tether == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d, if_index_tether:%d tether_if_name:%s\\n\", data_wan_tether->is_sta,\n\t\t\t\t\tdata_wan_tether->if_index_tether,\n\t\t\t\t\tIPACM_Iface::ipacmcfg->iface_table[data_wan_tether->if_index_tether].iface_name);\n\t\tif (data_wan_tether->if_index_tether == ipa_if_num)\n\t\t{\n\t\t\t/* clean up v6 RT rules*/\n\t\t\tIPACMDBG_H(\"Received IPA_WAN_V6_DOWN in WLAN-instance and need clean up client IPv6 address \\n\");\n\t\t\t/* reset wifi-client ipv6 rt-rules */\n\t\t\thandle_wlan_client_reset_rt(IPA_IP_v6);\n\n\t\t\tif(data_wan_tether->is_sta == false && wlan_ap_index > 0)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"This is not the first AP instance and not STA mode, ignore WAN_DOWN event.\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (rx_prop != NULL)\n\t\t\t{\n\t\t\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t\t\t{\n\t\t\t\t\thandle_wan_down_v6(data_wan_tether->is_sta);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n#else\n\tcase IPA_HANDLE_WAN_UP:\n\t{\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_UP event\\n\");\n\n\t\tdata_wan = (ipacm_event_iface_up*)param;\n\t\tif(data_wan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d\\n\", data_wan->is_sta);\n\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t{\n\t\tif(data_wan->is_sta == false)\n\t\t{\n\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v4);\n\t\t\t\tIPACM_Lan::handle_wan_up_ex(ext_prop, IPA_IP_v4);\n\t\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACM_Lan::handle_wan_up(IPA_IP_v4);\n\t\t}\n\t}\n\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_UP_V6:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_UP_V6 event\\n\");\n\n\t\tdata_wan = (ipacm_event_iface_up*)param;\n\t\tif(data_wan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d\\n\", data_wan->is_sta);\n\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t{\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t\teth_bridge_install_wlan_guest_ap_ipv6_flt_rule();\n#endif\n\t\t\tif(wlan_ap_index == 0) //install ipv6 prefix rule only once\n\t\t\t{\n\t\t\t\tinstall_ipv6_prefix_flt_rule(data_wan->ipv6_prefix);\n\t\t\t}\n\t\t\tif(data_wan->is_sta == false)\n\t\t\t{\n\t\t\t\text_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v6);\n\t\t\t\tIPACM_Lan::handle_wan_up_ex(ext_prop, IPA_IP_v6);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACM_Lan::handle_wan_up(IPA_IP_v6);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_DOWN:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN event\\n\");\n\t\tdata_wan = (ipacm_event_iface_up*)param;\n\t\tif(data_wan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d\\n\", data_wan->is_sta);\n\t\tif(data_wan->is_sta == false && wlan_ap_index > 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"This is not the first AP instance and not STA mode, ignore WAN_DOWN event.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif (rx_prop != NULL)\n\t\t{\n\t\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\thandle_wan_down(data_wan->is_sta);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_HANDLE_WAN_DOWN_V6:\n\t\tIPACMDBG_H(\"Received IPA_HANDLE_WAN_DOWN_V6 event\\n\");\n\t\tdata_wan = (ipacm_event_iface_up*)param;\n\t\tif(data_wan == NULL)\n\t\t{\n\t\t\tIPACMERR(\"No event data is found.\\n\");\n\t\t\treturn;\n\t\t}\n\t\t/* clean up v6 RT rules*/\n\t\tIPACMDBG_H(\"Received IPA_WAN_V6_DOWN in WLAN-instance and need clean up client IPv6 address \\n\");\n\t\t/* reset wifi-client ipv6 rt-rules */\n\t\thandle_wlan_client_reset_rt(IPA_IP_v6);\n\n\t\tIPACMDBG_H(\"Backhaul is sta mode?%d\\n\", data_wan->is_sta);\n\t\tif(data_wan->is_sta == false && wlan_ap_index > 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"This is not the first AP instance and not STA mode, ignore WAN_DOWN event.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif (rx_prop != NULL)\n\t\t{\n\t\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t\t{\n\t\t\t\thandle_wan_down_v6(data_wan->is_sta);\n\t\t\t}\n\t\t}\n\t\tbreak;\n#endif\n\n\tcase IPA_WLAN_CLIENT_ADD_EVENT_EX:\n\t\t{\n\t\t\tipacm_event_data_wlan_ex *data = (ipacm_event_data_wlan_ex *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t\t\tint i;\n\t\t\t\tfor(i=0; i<data->num_of_attribs; i++)\n\t\t\t\t{\n\t\t\t\t\tif(data->attribs[i].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teth_bridge_add_wlan_client_rt_rule(data->attribs[i].u.mac_addr, SRC_WLAN, IPA_IP_v4);\n\t\t\t\t\t\t\teth_bridge_add_wlan_client_rt_rule(data->attribs[i].u.mac_addr, SRC_WLAN, IPA_IP_v6);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(IPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid == true)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teth_bridge_add_wlan_client_rt_rule(data->attribs[i].u.mac_addr, SRC_USB, IPA_IP_v4);\n\t\t\t\t\t\t\teth_bridge_add_wlan_client_rt_rule(data->attribs[i].u.mac_addr, SRC_USB, IPA_IP_v6);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teth_bridge_add_self_client_flt_rule(data->attribs[i].u.mac_addr, IPA_IP_v4);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teth_bridge_add_self_client_flt_rule(data->attribs[i].u.mac_addr, IPA_IP_v6);\n\t\t\t\t\t\t}\n\t\t\t\t\t\teth_bridge_post_lan_client_event(data->attribs[i].u.mac_addr, IPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT);\n\t\t\t\t\t\teth_bridge_add_wlan_client(data->attribs[i].u.mac_addr, ipa_if_num);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n#endif\n\t\t\t\tIPACMDBG_H(\"Received IPA_WLAN_CLIENT_ADD_EVENT\\n\");\n\t\t\t\thandle_wlan_client_init_ex(data);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_WLAN_CLIENT_DEL_EVENT:\n\t\t{\n\t\t\tipacm_event_data_mac *data = (ipacm_event_data_mac *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_WLAN_CLIENT_DEL_EVENT\\n\");\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t\t\teth_bridge_del_wlan_client_rt_rule(data->mac_addr, SRC_WLAN);\n\t\t\t\tif(IPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid == true)\n\t\t\t\t{\n\t\t\t\t\teth_bridge_del_wlan_client_rt_rule(data->mac_addr, SRC_USB);\n\t\t\t\t}\n\t\t\t\teth_bridge_del_self_client_flt_rule(data->mac_addr);\n\t\t\t\teth_bridge_post_lan_client_event(data->mac_addr, IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT);\n\t\t\t\teth_bridge_del_wlan_client(data->mac_addr);\n#endif\n\t\t\t\t/* support lan2lan ipa-HW feature*/\n\t\t\t\thandle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_DISCONNECT, IPA_IP_v4);\n\t\t\t\thandle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_DISCONNECT, IPA_IP_v6);\n\t\t\t\thandle_wlan_client_down_evt(data->mac_addr);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_WLAN_CLIENT_POWER_SAVE_EVENT:\n\t\t{\n\t\t\tipacm_event_data_mac *data = (ipacm_event_data_mac *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_WLAN_CLIENT_POWER_SAVE_EVENT\\n\");\n\t\t\t\t/* support lan2lan ipa-HW feature*/\n\t\t\t\thandle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_POWER_SAVE, IPA_IP_v4);\n\t\t\t\thandle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_POWER_SAVE, IPA_IP_v6);\n\t\t\t\thandle_wlan_client_pwrsave(data->mac_addr);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_WLAN_CLIENT_RECOVER_EVENT:\n\t\t{\n\t\t\tipacm_event_data_mac *data = (ipacm_event_data_mac *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_WLAN_CLIENT_RECOVER_EVENT\\n\");\n\t\t\t\t/* support lan2lan ipa-HW feature*/\n\t\t\t\thandle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_POWER_RECOVER, IPA_IP_v4);\n\t\t\t\thandle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_POWER_RECOVER, IPA_IP_v6);\n\n\t\t\t\twlan_index = get_wlan_client_index(data->mac_addr);\n\t\t\t\tif ((wlan_index != IPACM_INVALID_INDEX) &&\n\t\t\t\t\t\t(get_client_memptr(wlan_client, wlan_index)->power_save_set == true))\n\t\t\t\t{\n\n\t\t\t\t\tIPACMDBG_H(\"change wlan client out of  power safe mode \\n\");\n\t\t\t\t\tget_client_memptr(wlan_client, wlan_index)->power_save_set = false;\n\n\t\t\t\t\t/* First add route rules and then nat rules */\n                    if(get_client_memptr(wlan_client, wlan_index)->ipv4_set == true) /* for ipv4 */\n\t\t\t\t    {\n\t\t\t\t\t\t     IPACMDBG_H(\"recover client index(%d):ipv4 address: 0x%x\\n\",\n\t\t\t\t\t\t\t\t\t\t wlan_index,\n\t\t\t\t\t\t\t\t\t\t get_client_memptr(wlan_client, wlan_index)->v4_addr);\n\n\t\t\t\t\t\tIPACMDBG_H(\"Adding Route Rules\\n\");\n\t\t\t\t\t    handle_wlan_client_route_rule(data->mac_addr, IPA_IP_v4);\n\n\t\t\t\t\t\tIPACMDBG_H(\"Adding Nat Rules\\n\");\n\t\t\t\t\t\tNat_App->ResetPwrSaveIf(get_client_memptr(wlan_client, wlan_index)->v4_addr);\n\t\t\t\t    }\n\n\t\t\t\t    if(get_client_memptr(wlan_client, wlan_index)->ipv6_set != 0) /* for ipv6 */\n\t\t\t\t    {\n\t\t\t\t\t    handle_wlan_client_route_rule(data->mac_addr, IPA_IP_v6);\n\t\t\t\t    }\n\t\t\t    }\n\t\t    }\n\t\t}\n\t\tbreak;\n\n\tcase IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT:\n\t\t{\n\t\t\tipacm_event_data_all *data = (ipacm_event_data_all *)param;\n\t\t\tipa_interface_index = iface_ipa_index_query(data->if_index);\n\t\t\tif (ipa_interface_index == ipa_if_num)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Received IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT\\n\");\n\t\t\t\tif (handle_wlan_client_ipaddr(data) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t/* support lan2lan ipa-hw feature */\n\t\t\t\thandle_lan2lan_client_active(data, IPA_LAN_CLIENT_ACTIVE);\n\n\t\t\t\thandle_wlan_client_route_rule(data->mac_addr, data->iptype);\n\t\t\t\tif (data->iptype == IPA_IP_v4)\n\t\t\t\t{\n\t\t\t\t\t/* Add NAT rules after ipv4 RT rules are set */\n\t\t\t\t\tCtList->HandleNeighIpAddrAddEvt(data);\n//\t\t\t\t\tNat_App->ResetPwrSaveIf(data->ipv4_addr);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\t\t/* handle software routing enable event, iface will update softwarerouting_act to true*/\n\tcase IPA_SW_ROUTING_ENABLE:\n\t\tIPACMDBG_H(\"Received IPA_SW_ROUTING_ENABLE\\n\");\n\t\tIPACM_Iface::handle_software_routing_enable();\n\t\tbreak;\n\n\t\t/* handle software routing disable event, iface will update softwarerouting_act to false*/\n\tcase IPA_SW_ROUTING_DISABLE:\n\t\tIPACMDBG_H(\"Received IPA_SW_ROUTING_DISABLE\\n\");\n\t\tIPACM_Iface::handle_software_routing_disable();\n\t\tbreak;\n\n\tcase IPA_ETH_BRIDGE_USB_CLIENT_ADD_EVENT:\n\t\t{\n\t\t\tIPACMDBG_H(\"Received IPA_ETH_BRIDGE_USB_CLIENT_ADD_EVENT event.\\n\");\n\t\t\tipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;\n\t\t\tif(mac != NULL)\n\t\t\t{\n\t\t\t\tif(wlan_ap_index == 0)\n\t\t\t\t{\n\t\t\t\t\tif(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)\n\t\t\t\t\t{\n\t\t\t\t\t\teth_bridge_add_usb_client_flt_rule(mac->mac_addr, IPA_IP_v4);\n\t\t\t\t\t}\n\t\t\t\t\tif(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)\n\t\t\t\t\t{\n\t\t\t\t\t\teth_bridge_add_usb_client_flt_rule(mac->mac_addr, IPA_IP_v6);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMERR(\"Event MAC is empty.\\n\");\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_ETH_BRIDGE_USB_CLIENT_DEL_EVENT:\n\t\t{\n\t\t\tIPACMDBG_H(\"Received IPA_ETH_BRIDGE_USB_CLIENT_DEL_EVENT event.\\n\");\n\t\t\tipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;\n\t\t\tif(mac != NULL)\n\t\t\t{\n\t\t\t\tif(wlan_ap_index == 0)\n\t\t\t\t{\n\t\t\t\t\tif(eth_bridge_del_usb_client_flt_rule(mac->mac_addr) == IPACM_FAILURE)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Failed to delete usb client MAC based flt rule.\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPACMERR(\"Event MAC is empty.\\n\");\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT:\n\t{\n\t\tIPACMDBG_H(\"Received IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT event.\\n\");\n\t\tint i;\n\t\tipacm_event_data_fid* fid = (ipacm_event_data_fid*)param;\n\t\tif(fid == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Event data is empty.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif(fid->if_index == ipa_if_num)\n\t\t{\n\t\t\tIPACMDBG_H(\"The event was sent by the same interface, ignore.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tfor(i=0; i<IPACM_Lan::num_wlan_client; i++)\n\t\t{\n\t\t\tif(IPACM_Lan::eth_bridge_wlan_client[i].ipa_if_num == ipa_if_num)\n\t\t\t{\n\t\t\t\teth_bridge_add_wlan_client_rt_rule(IPACM_Lan::eth_bridge_wlan_client[i].mac, SRC_USB, IPA_IP_v4);\n\t\t\t\teth_bridge_add_wlan_client_rt_rule(IPACM_Lan::eth_bridge_wlan_client[i].mac, SRC_USB, IPA_IP_v6);\n\t\t\t}\n\t\t}\n\t}\n\tbreak;\n\n\tcase IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT:\n\t{\n\t\tIPACMDBG_H(\"Received IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT event.\\n\");\n\t\tint i;\n\t\tipacm_event_data_fid* fid = (ipacm_event_data_fid*)param;\n\t\tif(fid == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Event data is empty.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif(fid->if_index == ipa_if_num)\n\t\t{\n\t\t\tIPACMDBG_H(\"The event was sent by the same interface, ignore.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tfor(i=0; i<IPACM_Lan::num_wlan_client; i++)\n\t\t{\n\t\t\tif(IPACM_Lan::eth_bridge_wlan_client[i].ipa_if_num == ipa_if_num)\n\t\t\t{\n\t\t\t\teth_bridge_del_wlan_client_rt_rule(IPACM_Lan::eth_bridge_wlan_client[i].mac, SRC_USB);\n\t\t\t}\n\t\t}\n\t}\n\tbreak;\n\n\tcase IPA_TETHERING_STATS_UPDATE_EVENT:\n\t{\n\t\tIPACMDBG_H(\"Received IPA_TETHERING_STATS_UPDATE_EVENT event.\\n\");\n\t\tif (IPACM_Wan::isWanUP(ipa_if_num) || IPACM_Wan::isWanUP_V6(ipa_if_num))\n\t\t{\n\t\t\tif(IPACM_Wan::backhaul_is_sta_mode == false) /* LTE */\n\t\t\t{\n\t\t\t\tipa_get_data_stats_resp_msg_v01 *data = (ipa_get_data_stats_resp_msg_v01 *)param;\n\t\t\t\tif (data->ipa_stats_type != QMI_IPA_STATS_TYPE_PIPE_V01)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"not valid pipe stats\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thandle_tethering_stats_event(data);\n\t\t\t};\n\t\t}\n\t}\n\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n\treturn;\n}\n\n/*Configure the initial filter rules */\nint IPACM_Wlan::init_fl_rule(ipa_ip_type iptype)\n{\n\tint res = IPACM_SUCCESS, len, offset;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable;\n\n\t/* update the iface ip-type to be IPA_IP_v4, IPA_IP_v6 or both*/\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tif ((ip_type == IPA_IP_v4) || (ip_type == IPA_IP_MAX))\n\t\t{\n\t\t\tIPACMDBG_H(\"Interface(%s:%d) already in ip-type %d\\n\", dev_name, ipa_if_num, ip_type);\n\t\t\treturn res;\n\t\t}\n\n\t\tif (ip_type == IPA_IP_v6)\n\t\t{\n\t\t\tip_type = IPA_IP_MAX;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tip_type = IPA_IP_v4;\n\t\t}\n\t\tIPACMDBG_H(\"Interface(%s:%d) now ip-type is %d\\n\", dev_name, ipa_if_num, ip_type);\n\t}\n\telse\n\t{\n\t\tif ((ip_type == IPA_IP_v6) || (ip_type == IPA_IP_MAX))\n\t\t{\n\t\t\tIPACMDBG_H(\"Interface(%s:%d) already in ip-type %d\\n\", dev_name, ipa_if_num, ip_type);\n\t\t\treturn res;\n\t\t}\n\n\t\tif (ip_type == IPA_IP_v4)\n\t\t{\n\t\t\tip_type = IPA_IP_MAX;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tip_type = IPA_IP_v6;\n\t\t}\n\n\t\tIPACMDBG_H(\"Interface(%s:%d) now ip-type is %d\\n\", dev_name, ipa_if_num, ip_type);\n\t}\n\n    /* ADD corresponding ipa_rm_resource_name of RX-endpoint before adding all IPV4V6 FT-rules */\n\tif(rx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", rx_prop->rx[0].src_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);\n\t\tIPACM_Iface::ipacmcfg->AddRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe],false);\n\t\tIPACMDBG_H(\"Add producer dependency from %s with registered rx-prop\\n\", dev_name);\n\t}\n\telse\n\t{\n\t\t/* Adding the check if no Rx property registered, no filter rules will be added */\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tif(wlan_ap_index != 0)\n\t{\n\t\tIPACMDBG_H(\"Install frag/multicast/broadcast rules only for the first AP.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n#endif\n\n\t/* construct ipa_ioc_add_flt_rule with default filter rules */\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv4 flt rule has not been installed.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\toffset = 0;\n#else\n#ifndef CT_OPT\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#else\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)\n\t\t\t\t+ NUM_TCP_CTL_FLT_RULE;\n#endif\n#endif\n\n#ifdef FEATURE_IPA_ANDROID\n\t\toffset = offset + wlan_ap_index * (IPA_MAX_PRIVATE_SUBNET_ENTRIES - IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#endif\n\t\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + (IPV4_DEFAULT_FILTERTING_RULES * sizeof(struct ipa_flt_rule_mdfy));\n\t\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule *)calloc(1, len);\n\t\tif (!pFilteringTable)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(pFilteringTable, 0, len);\n\n\t\tpFilteringTable->commit = 1;\n\t\tpFilteringTable->ip = iptype;\n\t\tpFilteringTable->num_rules = (uint8_t)IPV4_DEFAULT_FILTERTING_RULES;\n\n\t\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\tflt_rule.status = -1;\n\n\t\tflt_rule.rule.retain_hdr = 1;\n\t\tflt_rule.rule.to_uc = 0;\n\t\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\tflt_rule.rule.eq_attrib_type = 0;\n\n\t\t/* Configuring Fragment Filtering Rule */\n\t\tIPACMDBG_H(\"rx property attrib mask:0x%x\\n\", rx_prop->rx[0].attrib.attrib_mask);\n\t\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t/* remove meta data mask */\n\t\tflt_rule.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n#endif\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_FRAGMENT;\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset];\n\t\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\t/* Configuring Multicast Filtering Rule */\n\t\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t/* remove meta data mask */\n\t\tflt_rule.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n#endif\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = 0xF0000000;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr = 0xE0000000;\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+1];\n\t\tmemcpy(&(pFilteringTable->rules[1]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\t/* Configuring Broadcast Filtering Rule */\n\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr = 0xFFFFFFFF;\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+2];\n\t\tmemcpy(&(pFilteringTable->rules[2]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Failed to modify default ipv4 filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/* copy filter hdls */\n\t\t\tfor (int i = 0; i < IPV4_DEFAULT_FILTERTING_RULES; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tdft_v4fl_rule_hdl[i] = pFilteringTable->rules[i].rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"Default v4 filter Rule %d HDL:0x%x\\n\", i, dft_v4fl_rule_hdl[i]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding default v4 Filtering rule %d\\n\", i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v6 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv6 flt rule has not been installed.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\toffset = 1 + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT;\n#else\n#ifndef CT_OPT\n\t\toffset = wlan_ap_index * (IPV6_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR) + MAX_OFFLOAD_PAIR;\n#else\n\t\toffset = wlan_ap_index * (IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR)\n\t\t\t\t+ NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR;\n#endif\n#endif\n\n\t\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + (IPV6_DEFAULT_FILTERTING_RULES * sizeof(struct ipa_flt_rule_mdfy));\n\t\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule *)calloc(1, len);\n\t\tif (!pFilteringTable)\n\t\t{\n\t\t\tIPACMERR(\"Error Locate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(pFilteringTable, 0, len);\n\n\t\tpFilteringTable->commit = 1;\n\t\tpFilteringTable->ip = iptype;\n\t\tpFilteringTable->num_rules = (uint8_t)IPV6_DEFAULT_FILTERTING_RULES;\n\n\t\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\tflt_rule.status = -1;\n\n\t\tflt_rule.rule.retain_hdr = 1;\n\t\tflt_rule.rule.to_uc = 0;\n\t\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\tflt_rule.rule.eq_attrib_type = 0;\n\n\t\t/* Configuring Multicast Filtering Rule */\n\t\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t/* remove meta data mask */\n\t\tflt_rule.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n#endif\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = 0xFF000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[0] = 0XFF000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset];\n\t\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\t/* Configuring fe80::/10 Link-Scoped Unicast Filtering Rule */\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = 0XFFC00000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[0] = 0xFE800000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+1];\n\t\tmemcpy(&(pFilteringTable->rules[1]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\t/* Configuring fec0::/10 Reserved by IETF Filtering Rule */\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = 0XFFC00000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[0] = 0xFEC00000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[1] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[2] = 0x00000000;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[3] = 0X00000000;\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+2];\n\t\tmemcpy(&(pFilteringTable->rules[2]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n#ifdef FEATURE_IPA_ANDROID\n\t\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\tflt_rule.status = -1;\n\n\t\tflt_rule.rule.retain_hdr = 1;\n\t\tflt_rule.rule.to_uc = 0;\n\t\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\tflt_rule.rule.eq_attrib_type = 1;\n\n\t\tflt_rule.rule.eq_attrib.rule_eq_bitmap = 0;\n\n\t\tif(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA)\n\t\t{\n\t\t\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<14);\n\t\t\tflt_rule.rule.eq_attrib.metadata_meq32_present = 1;\n\t\t\tflt_rule.rule.eq_attrib.metadata_meq32.offset = 0;\n\t\t\tflt_rule.rule.eq_attrib.metadata_meq32.value = rx_prop->rx[0].attrib.meta_data;\n\t\t\tflt_rule.rule.eq_attrib.metadata_meq32.mask = rx_prop->rx[0].attrib.meta_data_mask;\n\t\t}\n\n\t\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<1);\n\t\tflt_rule.rule.eq_attrib.protocol_eq_present = 1;\n\t\tflt_rule.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;\n\n\t\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<8);\n\t\tflt_rule.rule.eq_attrib.num_ihl_offset_meq_32 = 1;\n\t\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;\n\n\t\t/* add TCP FIN rule*/\n\t\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\t\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+3];\n\t\tmemcpy(&(pFilteringTable->rules[3]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\t/* add TCP SYN rule*/\n\t\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\t\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+4];\n\t\tmemcpy(&(pFilteringTable->rules[4]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t\t/* add TCP RST rule*/\n\t\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);\n\t\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+5];\n\t\tmemcpy(&(pFilteringTable->rules[5]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n#endif\n\n\t\tif (m_filtering.ModifyFilteringRule(pFilteringTable) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to modify default ipv6 filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (int i = 0; i < IPV6_DEFAULT_FILTERTING_RULES; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tdft_v6fl_rule_hdl[i] = pFilteringTable->rules[i].rule_hdl;\n\t\t\t\t\tIPACMDBG_H(\"Default v6 Filter Rule %d HDL:0x%x\\n\", i, dft_v6fl_rule_hdl[i]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failing adding v6 default IPV6 rule %d\\n\", i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\treturn res;\n}\n\nint IPACM_Wlan::add_dummy_lan2lan_flt_rule(ipa_ip_type iptype)\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no rx_prop for iface %s, not able to add dummy lan2lan filtering rule.\\n\", dev_name);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tint offset;\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv4 flt rule has not been installed.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n#ifndef CT_OPT\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)\n\t\t\t\t\t\t+ IPV4_DEFAULT_FILTERTING_RULES;\n#else\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)\n\t\t\t\t\t\t+ NUM_TCP_CTL_FLT_RULE + IPV4_DEFAULT_FILTERTING_RULES;\n#endif\n\n#ifdef FEATURE_IPA_ANDROID\n\t\toffset = offset + wlan_ap_index * (IPA_MAX_PRIVATE_SUBNET_ENTRIES - IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#endif\n\t\tfor (int i = 0; i < MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tlan2lan_flt_rule_hdl_v4[i].rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+i];\n\t\t\tlan2lan_flt_rule_hdl_v4[i].valid = false;\n\t\t\tIPACMDBG_H(\"Lan2lan v4 flt rule %d hdl:0x%x\\n\", i, lan2lan_flt_rule_hdl_v4[i].rule_hdl);\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v6 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv6 flt rule has not been installed.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n#ifndef CT_OPT\n\t\toffset = wlan_ap_index * (IPV6_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR);\n#else\n\t\toffset = wlan_ap_index * (IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR)\n\t\t\t\t\t\t+ NUM_TCP_CTL_FLT_RULE;\n#endif\n\n\t\tfor (int i = 0; i < MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tlan2lan_flt_rule_hdl_v6[i].rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+i];\n\t\t\tlan2lan_flt_rule_hdl_v6[i].valid = false;\n\t\t\tIPACMDBG_H(\"Lan2lan v6 flt rule %d hdl:0x%x\\n\", i, lan2lan_flt_rule_hdl_v6[i].rule_hdl);\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/* configure private subnet filter rules*/\nint IPACM_Wlan::handle_private_subnet(ipa_ip_type iptype)\n{\n\tint i, len, res = IPACM_SUCCESS, offset;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable;\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv4 flt rule has not been installed.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\toffset = IPV4_DEFAULT_FILTERTING_RULES + IPACM_Iface::ipacmcfg->ipa_num_private_subnet + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT;\n#else\n#ifndef CT_OPT\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)\n\t\t\t\t+ IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR;\n#else\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)\n\t\t\t\t+ IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR;\n#endif\n#endif\n\n\t\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + (IPACM_Iface::ipacmcfg->ipa_num_private_subnet) * sizeof(struct ipa_flt_rule_mdfy);\n\t\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\t\tif (!pFilteringTable)\n\t\t{\n\t\t\tIPACMERR(\"Failed to allocate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(pFilteringTable, 0, len);\n\n\t\tpFilteringTable->commit = 1;\n\t\tpFilteringTable->ip = iptype;\n\t\tpFilteringTable->num_rules = (uint8_t)IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\n\t\t/* Make LAN-traffic always go A5, use default IPA-RT table */\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_default_v4))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\t\tflt_rule.status = -1;\n\n\t\tflt_rule.rule.retain_hdr = 1;\n\t\tflt_rule.rule.to_uc = 0;\n\t\tflt_rule.rule.action = IPA_PASS_TO_ROUTING;\n\t\tflt_rule.rule.eq_attrib_type = 0;\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_default_v4.hdl;\n\t\tIPACMDBG_H(\"Private filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_default_v4.name);\n\n\t\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\t/* remove meta data mask */\n\t\tflt_rule.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\n#endif\n\n\t\tfor (i = 0; i < (IPACM_Iface::ipacmcfg->ipa_num_private_subnet); i++)\n\t\t{\n\t\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+i];\n\t\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask;\n\t\t\tflt_rule.rule.attrib.u.v4.dst_addr = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr;\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\t\t}\n\n\t\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Failed to modify private subnet filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\t/* copy filter rule hdls */\n\t\tfor (i = 0; i < IPACM_Iface::ipacmcfg->ipa_num_private_subnet; i++)\n\t\t{\n\t\t\tprivate_fl_rule_hdl[i] = pFilteringTable->rules[i].rule_hdl;\n\t\t}\n\t}\n\telse\n\t{\n\t\treturn IPACM_SUCCESS;\n\t}\nfail:\n\tfree(pFilteringTable);\n\treturn res;\n}\n\n/* install UL filter rule from Q6 */\nint IPACM_Wlan::handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype)\n{\n\tipa_flt_rule_add flt_rule_entry;\n\tint len = 0, cnt, ret = IPACM_SUCCESS, offset;\n\tipa_ioc_add_flt_rule *pFilteringTable;\n\tipa_fltr_installed_notif_req_msg_v01 flt_index;\n\tint fd;\n\tint i;\n\n\tIPACMDBG_H(\"Set extended property rules in LAN\\n\");\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif(prop == NULL || prop->num_ext_props <= 0)\n\t{\n\t\tIPACMDBG_H(\"No extended property.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tif(wlan_ap_index > 0)\n\t{\n\t\tIPACMDBG_H(\"This is not the first WLAN AP, do not install modem UL rules.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tfd = open(IPA_DEVICE_NAME, O_RDWR);\n\tif (0 == fd)\n\t{\n\t\tIPACMERR(\"Failed opening %s.\\n\", IPA_DEVICE_NAME);\n\t}\n\n\tmemset(&flt_index, 0, sizeof(flt_index));\n\tflt_index.source_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, rx_prop->rx[0].src_pipe);\n\tflt_index.install_status = IPA_QMI_RESULT_SUCCESS_V01;\n\tflt_index.filter_index_list_len = prop->num_ext_props;\n\tflt_index.embedded_pipe_index_valid = 1;\n\tflt_index.embedded_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, IPA_CLIENT_APPS_LAN_WAN_PROD);\n\tflt_index.retain_header_valid = 1;\n\tflt_index.retain_header = 0;\n\tflt_index.embedded_call_mux_id_valid = 1;\n\tflt_index.embedded_call_mux_id = IPACM_Iface::ipacmcfg->GetQmapId();\n\n\tIPACMDBG_H(\"flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d\\n\", flt_index.source_pipe_index,\n\t\t\t\tflt_index.filter_index_list_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id);\n\n\tlen = sizeof(struct ipa_ioc_add_flt_rule) + prop->num_ext_props * sizeof(struct ipa_flt_rule_add);\n\tpFilteringTable = (struct ipa_ioc_add_flt_rule*)malloc(len);\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error Locate ipa_flt_rule_add memory...\\n\");\n\t\tclose(fd);\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\tpFilteringTable->global = false;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = prop->num_ext_props;\n\n\tmemset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add)); // Zero All Fields\n\tflt_rule_entry.at_rear = 1;\n\tflt_rule_entry.flt_rule_hdl = -1;\n\tflt_rule_entry.status = -1;\n\n\tflt_rule_entry.rule.retain_hdr = 0;\n\tflt_rule_entry.rule.to_uc = 0;\n\tflt_rule_entry.rule.eq_attrib_type = 1;\n\tif(iptype == IPA_IP_v4)\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_SRC_NAT;\n\telse if(iptype == IPA_IP_v6)\n\t\tflt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tif(iptype == IPA_IP_v4)\n\t{\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\toffset = IPV4_DEFAULT_FILTERTING_RULES + 2 * IPACM_Iface::ipacmcfg->ipa_num_private_subnet\n\t\t\t\t+ IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT;\n#else\n#ifndef CT_OPT\n\t\toffset = 2*(IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#else\n\t\toffset = 2*(IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#endif\n#ifdef FEATURE_IPA_ANDROID\n\t\toffset = offset + 2 * (IPA_MAX_PRIVATE_SUBNET_ENTRIES - IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#endif\n#endif\n\t}\n\telse\n\t{\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\toffset = IPV6_DEFAULT_FILTERTING_RULES + 1 + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT + NUM_IPV6_PREFIX_FLT_RULE\n\t\t\t\t+ NUM_IPV6_ICMP_FLT_RULE;\n#else\n#ifndef CT_OPT\n\t\toffset = 2*(IPV6_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR) + NUM_IPV6_PREFIX_FLT_RULE + NUM_IPV6_ICMP_FLT_RULE;\n#else\n\t\toffset = 2*(IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR) + NUM_IPV6_PREFIX_FLT_RULE + NUM_IPV6_ICMP_FLT_RULE;\n#endif\n#endif\n\t}\n\n\tfor(cnt=0; cnt<prop->num_ext_props; cnt++)\n\t{\n\t\tmemcpy(&flt_rule_entry.rule.eq_attrib,\n\t\t\t\t\t &prop->prop[cnt].eq_attrib,\n\t\t\t\t\t sizeof(prop->prop[cnt].eq_attrib));\n\t\tflt_rule_entry.rule.rt_tbl_idx = prop->prop[cnt].rt_tbl_idx;\n\t\tmemcpy(&pFilteringTable->rules[cnt], &flt_rule_entry, sizeof(flt_rule_entry));\n\n\t\tflt_index.filter_index_list[cnt].filter_index = offset+cnt;\n\t\tIPACMDBG_H(\"Modem UL filtering rule %d has index %d\\n\", cnt, offset+cnt);\n\n\t\tflt_index.filter_index_list[cnt].filter_handle = prop->prop[cnt].filter_hdl;\n\t}\n\n\tif(false == m_filtering.SendFilteringRuleIndex(&flt_index))\n\t{\n\t\tIPACMERR(\"Error sending filtering rule index, aborting...\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tif(false == m_filtering.AddFilteringRule(pFilteringTable))\n\t{\n\t\tIPACMERR(\"Error Adding RuleTable to Filtering, aborting...\\n\");\n\t\tret = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\telse\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tfor(i=0; i<pFilteringTable->num_rules; i++)\n\t\t\t{\n\t\t\t\twan_ul_fl_rule_hdl_v4[num_wan_ul_fl_rule_v4] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\tnum_wan_ul_fl_rule_v4++;\n\t\t\t}\n\t\t}\n\t\telse if(iptype == IPA_IP_v6)\n\t\t{\n\t\t\tfor(i=0; i<pFilteringTable->num_rules; i++)\n\t\t\t{\n\t\t\t\twan_ul_fl_rule_hdl_v6[num_wan_ul_fl_rule_v6] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\tnum_wan_ul_fl_rule_v6++;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\tclose(fd);\n\treturn ret;\n}\n\n/* handle wifi client initial,copy all partial headers (tx property) */\nint IPACM_Wlan::handle_wlan_client_init_ex(ipacm_event_data_wlan_ex *data)\n{\n\n#define WLAN_IFACE_INDEX_LEN 2\n\n\tint res = IPACM_SUCCESS, len = 0, i, evt_size;\n\tchar index[WLAN_IFACE_INDEX_LEN];\n\tstruct ipa_ioc_copy_hdr sCopyHeader;\n\tstruct ipa_ioc_add_hdr *pHeaderDescriptor = NULL;\n        uint32_t cnt;\n\n\t/* start of adding header */\n\tIPACMDBG_H(\"Wifi client number for this iface: %d & total number of wlan clients: %d\\n\",\n                 num_wifi_client,IPACM_Wlan::total_num_wifi_clients);\n\n\tif ((num_wifi_client >= IPA_MAX_NUM_WIFI_CLIENTS) ||\n\t\t\t(IPACM_Wlan::total_num_wifi_clients >= IPA_MAX_NUM_WIFI_CLIENTS))\n\t{\n\t\tIPACMERR(\"Reached maximum number of wlan clients\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Wifi client number: %d\\n\", num_wifi_client);\n\n\t/* add header to IPA */\n\tif(tx_prop != NULL)\n\t{\n\t\tlen = sizeof(struct ipa_ioc_add_hdr) + (1 * sizeof(struct ipa_hdr_add));\n\t\tpHeaderDescriptor = (struct ipa_ioc_add_hdr *)calloc(1, len);\n\t\tif (pHeaderDescriptor == NULL)\n\t\t{\n\t\t\tIPACMERR(\"calloc failed to allocate pHeaderDescriptor\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tevt_size = sizeof(ipacm_event_data_wlan_ex) + data->num_of_attribs * sizeof(struct ipa_wlan_hdr_attrib_val);\n\t\tget_client_memptr(wlan_client, num_wifi_client)->p_hdr_info = (ipacm_event_data_wlan_ex*)malloc(evt_size);\n\t\tmemcpy(get_client_memptr(wlan_client, num_wifi_client)->p_hdr_info, data, evt_size);\n\n\t\t/* copy partial header for v4*/\n\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\tif(tx_prop->tx[cnt].ip==IPA_IP_v4)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Got partial v4-header name from %d tx props\\n\", cnt);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name,\n\t\t\t\t\t\t\t tx_prop->tx[cnt].hdr_name,\n\t\t\t\t\t\t\t sizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG_H(\"header name: %s in tx:%d\\n\", sCopyHeader.name,cnt);\n\t\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tPERROR(\"ioctl copy header failed\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t\t\t\t sCopyHeader.hdr,\n\t\t\t\t\t\t\t\t sCopyHeader.hdr_len);\n\t\t\t\t}\n\n\t\t\t\tfor(i = 0; i < data->num_of_attribs; i++)\n\t\t\t\t{\n\t\t\t\t\tif(data->attribs[i].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemcpy(get_client_memptr(wlan_client, num_wifi_client)->mac,\n\t\t\t\t\t\t\t\tdata->attribs[i].u.mac_addr,\n\t\t\t\t\t\t\t\tsizeof(get_client_memptr(wlan_client, num_wifi_client)->mac));\n\n\t\t\t\t\t\t/* copy client mac_addr to partial header */\n\t\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[data->attribs[i].offset],\n\t\t\t\t\t\t\t\t\t get_client_memptr(wlan_client, num_wifi_client)->mac,\n\t\t\t\t\t\t\t\t\t IPA_MAC_ADDR_SIZE);\n\t\t\t\t\t}\n\t\t\t\t\telse if(data->attribs[i].attrib_type == WLAN_HDR_ATTRIB_STA_ID)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* copy client id to header */\n\t\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[data->attribs[i].offset],\n\t\t\t\t\t\t\t\t\t&data->attribs[i].u.sta_id, sizeof(data->attribs[i].u.sta_id));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"The attribute type is not expected!\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tpHeaderDescriptor->commit = true;\n\t\t\t\tpHeaderDescriptor->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", ipa_if_num);\n\t\t\t\tstrlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WLAN_PARTIAL_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", header_name_count);\n\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\t\t\t\tpHeaderDescriptor->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tget_client_memptr(wlan_client, num_wifi_client)->hdr_hdl_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\t\t\tIPACMDBG_H(\"client(%d) v4 full header name:%s header handle:(0x%x)\\n\",\n\t\t\t\t\t\t\t\t num_wifi_client,\n\t\t\t\t\t\t\t\t pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t\t\t\t get_client_memptr(wlan_client, num_wifi_client)->hdr_hdl_v4);\n\t\t\t\tget_client_memptr(wlan_client, num_wifi_client)->ipv4_header_set=true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* copy partial header for v6*/\n\t\tfor (cnt=0; cnt<tx_prop->num_tx_props; cnt++)\n\t\t{\n\t\t\tif(tx_prop->tx[cnt].ip==IPA_IP_v6)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Got partial v6-header name from %d tx props\\n\", cnt);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name,\n\t\t\t\t\t\t\t tx_prop->tx[cnt].hdr_name,\n\t\t\t\t\t\t\t sizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG_H(\"header name: %s in tx:%d\\n\", sCopyHeader.name,cnt);\n\t\t\t\tif (m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tPERROR(\"ioctl copy header failed\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeaderDescriptor->hdr[0].hdr,\n\t\t\t\t\t\t\t\t sCopyHeader.hdr,\n\t\t\t\t\t\t\t\t sCopyHeader.hdr_len);\n\t\t\t\t}\n\n\t\t\t\tfor(i = 0; i < data->num_of_attribs; i++)\n\t\t\t\t{\n\t\t\t\t\tif(data->attribs[i].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemcpy(get_client_memptr(wlan_client, num_wifi_client)->mac,\n\t\t\t\t\t\t\t\tdata->attribs[i].u.mac_addr,\n\t\t\t\t\t\t\t\tsizeof(get_client_memptr(wlan_client, num_wifi_client)->mac));\n\n\t\t\t\t\t\t/* copy client mac_addr to partial header */\n\t\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[data->attribs[i].offset],\n\t\t\t\t\t\t\t\tget_client_memptr(wlan_client, num_wifi_client)->mac,\n\t\t\t\t\t\t\t\tIPA_MAC_ADDR_SIZE);\n\t\t\t\t\t}\n\t\t\t\t\telse if (data->attribs[i].attrib_type == WLAN_HDR_ATTRIB_STA_ID)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* copy client id to header */\n\t\t\t\t\t\tmemcpy(&pHeaderDescriptor->hdr[0].hdr[data->attribs[i].offset],\n\t\t\t\t\t\t\t\t&data->attribs[i].u.sta_id, sizeof(data->attribs[i].u.sta_id));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"The attribute type is not expected!\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tpHeaderDescriptor->commit = true;\n\t\t\t\tpHeaderDescriptor->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeaderDescriptor->hdr[0].name, 0,\n\t\t\t\t\t\t\t sizeof(pHeaderDescriptor->hdr[0].name));\n\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", ipa_if_num);\n\t\t\t\tstrlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));\n\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WLAN_PARTIAL_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", header_name_count);\n\t\t\t\tif (strlcat(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeaderDescriptor->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeaderDescriptor->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeaderDescriptor->hdr[0].is_partial = 0;\n\t\t\t\tpHeaderDescriptor->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeaderDescriptor) == false ||\n\t\t\t\t\t\tpHeaderDescriptor->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"ioctl IPA_IOC_ADD_HDR failed: %d\\n\", pHeaderDescriptor->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tget_client_memptr(wlan_client, num_wifi_client)->hdr_hdl_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;\n\t\t\t\tIPACMDBG_H(\"client(%d) v6 full header name:%s header handle:(0x%x)\\n\",\n\t\t\t\t\t\t\t\t num_wifi_client,\n\t\t\t\t\t\t\t\t pHeaderDescriptor->hdr[0].name,\n\t\t\t\t\t\t\t\t\t\t\t get_client_memptr(wlan_client, num_wifi_client)->hdr_hdl_v6);\n\n\t\t\t\tget_client_memptr(wlan_client, num_wifi_client)->ipv6_header_set=true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* initialize wifi client*/\n\t\tget_client_memptr(wlan_client, num_wifi_client)->route_rule_set_v4 = false;\n\t\tget_client_memptr(wlan_client, num_wifi_client)->route_rule_set_v6 = 0;\n\t\tget_client_memptr(wlan_client, num_wifi_client)->ipv4_set = false;\n\t\tget_client_memptr(wlan_client, num_wifi_client)->ipv6_set = 0;\n\t\tget_client_memptr(wlan_client, num_wifi_client)->power_save_set=false;\n\t\tnum_wifi_client++;\n\t\theader_name_count++; //keep increasing header_name_count\n\t\tIPACM_Wlan::total_num_wifi_clients++;\n\t\tres = IPACM_SUCCESS;\n\t\tIPACMDBG_H(\"Wifi client number: %d\\n\", num_wifi_client);\n\t}\n\telse\n\t{\n\t\treturn res;\n\t}\n\nfail:\n\tfree(pHeaderDescriptor);\n\treturn res;\n}\n\n/*handle wifi client */\nint IPACM_Wlan::handle_wlan_client_ipaddr(ipacm_event_data_all *data)\n{\n\tint clnt_indx;\n\tint v6_num;\n\n\tIPACMDBG_H(\"number of wifi clients: %d\\n\", num_wifi_client);\n\tIPACMDBG_H(\" event MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t data->mac_addr[0],\n\t\t\t\t\t data->mac_addr[1],\n\t\t\t\t\t data->mac_addr[2],\n\t\t\t\t\t data->mac_addr[3],\n\t\t\t\t\t data->mac_addr[4],\n\t\t\t\t\t data->mac_addr[5]);\n\n\tclnt_indx = get_wlan_client_index(data->mac_addr);\n\n\t\tif (clnt_indx == IPACM_INVALID_INDEX)\n\t\t{\n\t\t\tIPACMERR(\"wlan client not found/attached \\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\tIPACMDBG_H(\"Ip-type received %d\\n\", data->iptype);\n\tif (data->iptype == IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"ipv4 address: 0x%x\\n\", data->ipv4_addr);\n\t\tif (data->ipv4_addr != 0) /* not 0.0.0.0 */\n\t\t{\n\t\t\tif (get_client_memptr(wlan_client, clnt_indx)->ipv4_set == false)\n\t\t\t{\n\t\t\t\tget_client_memptr(wlan_client, clnt_indx)->v4_addr = data->ipv4_addr;\n\t\t\t\tget_client_memptr(wlan_client, clnt_indx)->ipv4_set = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t   /* check if client got new IPv4 address*/\n\t\t\t   if(data->ipv4_addr == get_client_memptr(wlan_client, clnt_indx)->v4_addr)\n\t\t\t   {\n\t\t\t     IPACMDBG_H(\"Already setup ipv4 addr for client:%d, ipv4 address didn't change\\n\", clnt_indx);\n\t\t\t\t return IPACM_FAILURE;\n\t\t\t   }\n\t\t\t   else\n\t\t\t   {\n\t\t\t     IPACMDBG_H(\"ipv4 addr for client:%d is changed \\n\", clnt_indx);\n\t\t\t\t /* delete NAT rules first */\n\t\t\t\t CtList->HandleNeighIpAddrDelEvt(get_client_memptr(wlan_client, clnt_indx)->v4_addr);\n\t\t\t     delete_default_qos_rtrules(clnt_indx,IPA_IP_v4);\n\t\t         get_client_memptr(wlan_client, clnt_indx)->route_rule_set_v4 = false;\n\t\t\t     get_client_memptr(wlan_client, clnt_indx)->v4_addr = data->ipv4_addr;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\t    IPACMDBG_H(\"Invalid client IPv4 address \\n\");\n\t\t    return IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif ((data->ipv6_addr[0] != 0) || (data->ipv6_addr[1] != 0) ||\n\t\t\t\t(data->ipv6_addr[2] != 0) || (data->ipv6_addr[3] || 0)) /* check if all 0 not valid ipv6 address */\n\t\t{\n\t\t   IPACMDBG_H(\"ipv6 address: 0x%x:%x:%x:%x\\n\", data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);\n                   if(get_client_memptr(wlan_client, clnt_indx)->ipv6_set < IPV6_NUM_ADDR)\n\t\t   {\n\n\t\t       for(v6_num=0;v6_num < get_client_memptr(wlan_client, clnt_indx)->ipv6_set;v6_num++)\n\t               {\n\t\t\t      if( data->ipv6_addr[0] == get_client_memptr(wlan_client, clnt_indx)->v6_addr[v6_num][0] &&\n\t\t\t           data->ipv6_addr[1] == get_client_memptr(wlan_client, clnt_indx)->v6_addr[v6_num][1] &&\n\t\t\t  \t        data->ipv6_addr[2]== get_client_memptr(wlan_client, clnt_indx)->v6_addr[v6_num][2] &&\n\t\t\t  \t         data->ipv6_addr[3] == get_client_memptr(wlan_client, clnt_indx)->v6_addr[v6_num][3])\n\t\t\t      {\n\t\t\t  \t    IPACMDBG_H(\"Already see this ipv6 addr for client:%d\\n\", clnt_indx);\n\t\t\t  \t    return IPACM_FAILURE; /* not setup the RT rules*/\n\t\t\t  \t\tbreak;\n\t\t\t      }\n\t\t       }\n\n\t\t       /* not see this ipv6 before for wifi client*/\n\t\t\t   get_client_memptr(wlan_client, clnt_indx)->v6_addr[get_client_memptr(wlan_client, clnt_indx)->ipv6_set][0] = data->ipv6_addr[0];\n\t\t\t   get_client_memptr(wlan_client, clnt_indx)->v6_addr[get_client_memptr(wlan_client, clnt_indx)->ipv6_set][1] = data->ipv6_addr[1];\n\t\t\t   get_client_memptr(wlan_client, clnt_indx)->v6_addr[get_client_memptr(wlan_client, clnt_indx)->ipv6_set][2] = data->ipv6_addr[2];\n\t\t\t   get_client_memptr(wlan_client, clnt_indx)->v6_addr[get_client_memptr(wlan_client, clnt_indx)->ipv6_set][3] = data->ipv6_addr[3];\n\t\t\t   get_client_memptr(wlan_client, clnt_indx)->ipv6_set++;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t         IPACMDBG_H(\"Already got 3 ipv6 addr for client:%d\\n\", clnt_indx);\n\t\t\t return IPACM_FAILURE; /* not setup the RT rules*/\n\t\t    }\n\t\t}\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*handle wifi client routing rule*/\nint IPACM_Wlan::handle_wlan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype)\n{\n\tstruct ipa_ioc_add_rt_rule *rt_rule;\n\tstruct ipa_rt_rule_add *rt_rule_entry;\n\tuint32_t tx_index;\n\tint wlan_index,v6_num;\n\tconst int NUM = 1;\n\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tIPACMDBG_H(\"Received mac_addr MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t\t\t\t\t mac_addr[0], mac_addr[1], mac_addr[2],\n\t\t\t\t\t mac_addr[3], mac_addr[4], mac_addr[5]);\n\n\twlan_index = get_wlan_client_index(mac_addr);\n\tif (wlan_index == IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMDBG_H(\"wlan client not found/attached \\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\t/* during power_save mode, even receive IP_ADDR_ADD, not setting RT rules*/\n\tif (get_client_memptr(wlan_client, wlan_index)->power_save_set == true)\n\t{\n\t\tIPACMDBG_H(\"wlan client is in power safe mode \\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n        if (iptype==IPA_IP_v4)\n\t{\n\tIPACMDBG_H(\"wlan client index: %d, ip-type: %d, ipv4_set:%d, ipv4_rule_set:%d \\n\", wlan_index, iptype,\n\t\t\t\t\t get_client_memptr(wlan_client, wlan_index)->ipv4_set,\n\t\t\t\t\t get_client_memptr(wlan_client, wlan_index)->route_rule_set_v4);\n\t}\n        else\n\t{\n\t  IPACMDBG_H(\"wlan client index: %d, ip-type: %d, ipv6_set:%d, ipv6_rule_num:%d \\n\", wlan_index, iptype,\n\t\t\t\t\t get_client_memptr(wlan_client, wlan_index)->ipv6_set,\n\t\t\t\t\t get_client_memptr(wlan_client, wlan_index)->route_rule_set_v6);\n\t}\n\n\n\t/* Add default  Qos routing rules if not set yet */\n\tif ((iptype == IPA_IP_v4\n\t\t\t && get_client_memptr(wlan_client, wlan_index)->route_rule_set_v4 == false\n\t\t\t && get_client_memptr(wlan_client, wlan_index)->ipv4_set == true)\n\t\t\t|| (iptype == IPA_IP_v6\n\t\t            && get_client_memptr(wlan_client, wlan_index)->route_rule_set_v6 < get_client_memptr(wlan_client, wlan_index)->ipv6_set\n\t\t\t\t\t))\n\t{\n\t\trt_rule = (struct ipa_ioc_add_rt_rule *)\n\t\t\t calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +\n\t\t\t\t\t\tNUM * sizeof(struct ipa_rt_rule_add));\n\n\t\tif (rt_rule == NULL)\n\t\t{\n\t\t\tPERROR(\"Error Locate ipa_ioc_add_rt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\t        rt_rule->commit = 1;\n\t                rt_rule->num_rules = (uint8_t)NUM;\n\t\t        rt_rule->ip = iptype;\n\n\n\t\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n  \t        {\n\n\t\t        if(iptype != tx_prop->tx[tx_index].ip)\n\t\t        {\n\t\t   \t        IPACMDBG_H(\"Tx:%d, ip-type: %d conflict ip-type: %d no RT-rule added\\n\",\n\t\t   \t  \t\t\t\t    tx_index, tx_prop->tx[tx_index].ip,iptype);\n\t\t   \t        continue;\n\t\t        }\n\n  \t   \t        rt_rule_entry = &rt_rule->rules[0];\n\t\t\trt_rule_entry->at_rear = 0;\n\n\t\t\tif (iptype == IPA_IP_v4)\n\t\t\t{\n\t\t                IPACMDBG_H(\"client index(%d):ipv4 address: 0x%x\\n\", wlan_index,\n\t\t  \t\t\t\t        get_client_memptr(wlan_client, wlan_index)->v4_addr);\n\n                                IPACMDBG_H(\"client(%d): v4 header handle:(0x%x)\\n\",\n\t\t  \t\t\t\t wlan_index,\n\t\t  \t\t\t\t get_client_memptr(wlan_client, wlan_index)->hdr_hdl_v4);\n\t\t\t\tstrncpy(rt_rule->rt_tbl_name,\n\t\t\t\t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name,\n\t\t\t\t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n\n\t\t\t        rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\t        memcpy(&rt_rule_entry->rule.attrib,\n\t\t\t\t\t\t &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\t\t sizeof(rt_rule_entry->rule.attrib));\n\t\t\t        rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t        rt_rule_entry->rule.hdr_hdl = get_client_memptr(wlan_client, wlan_index)->hdr_hdl_v4;\n\t\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr = get_client_memptr(wlan_client, wlan_index)->v4_addr;\n\t\t\t\trt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;\n\n\t\t\t        if (false == m_routing.AddRoutingRule(rt_rule))\n  \t                        {\n  \t          \t            IPACMERR(\"Routing rule addition failed!\\n\");\n  \t          \t            free(rt_rule);\n  \t          \t            return IPACM_FAILURE;\n\t\t\t        }\n\n\t\t\t        /* copy ipv4 RT hdl */\n\t\t                get_client_memptr(wlan_client, wlan_index)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v4 =\n  \t   \t                rt_rule->rules[0].rt_rule_hdl;\n\t\t                IPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t      \t        get_client_memptr(wlan_client, wlan_index)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v4, iptype);\n  \t   \t        }\n  \t   \t        else\n  \t   \t        {\n\t\t            for(v6_num = get_client_memptr(wlan_client, wlan_index)->route_rule_set_v6;v6_num < get_client_memptr(wlan_client, wlan_index)->ipv6_set;v6_num++)\n\t\t\t    {\n                                IPACMDBG_H(\"client(%d): v6 header handle:(0x%x)\\n\",\n\t\t  \t    \t\t\t wlan_index,\n\t\t  \t    \t\t\t get_client_memptr(wlan_client, wlan_index)->hdr_hdl_v6);\n\n\t\t                /* v6 LAN_RT_TBL */\n\t\t\t    \tstrncpy(rt_rule->rt_tbl_name,\n\t\t\t    \t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_v6.name,\n\t\t\t    \t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n\t\t                /* Support QCMAP LAN traffic feature, send to A5 */\n\t\t\t\trt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;\n\t\t\t        memset(&rt_rule_entry->rule.attrib, 0, sizeof(rt_rule_entry->rule.attrib));\n\t\t   \t        rt_rule_entry->rule.hdr_hdl = 0;\n\t\t\t        rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = get_client_memptr(wlan_client, wlan_index)->v6_addr[v6_num][0];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = get_client_memptr(wlan_client, wlan_index)->v6_addr[v6_num][1];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = get_client_memptr(wlan_client, wlan_index)->v6_addr[v6_num][2];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = get_client_memptr(wlan_client, wlan_index)->v6_addr[v6_num][3];\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\n   \t                        if (false == m_routing.AddRoutingRule(rt_rule))\n  \t                        {\n  \t                \t    IPACMERR(\"Routing rule addition failed!\\n\");\n  \t                \t    free(rt_rule);\n  \t                \t    return IPACM_FAILURE;\n\t\t\t        }\n\n\t\t                get_client_memptr(wlan_client, wlan_index)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6[v6_num] = rt_rule->rules[0].rt_rule_hdl;\n\t\t                IPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t            \t\t\t\t get_client_memptr(wlan_client, wlan_index)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6[v6_num], iptype);\n\n\t\t\t        /*Copy same rule to v6 WAN RT TBL*/\n  \t                        strncpy(rt_rule->rt_tbl_name,\n  \t                 \t\t\t\t\tIPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name,\n  \t                 \t\t\t\t\tsizeof(rt_rule->rt_tbl_name));\n\n                                /* Downlink traffic from Wan iface, directly through IPA */\n\t\t\t\trt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;\n\t\t\t        memcpy(&rt_rule_entry->rule.attrib,\n\t\t\t\t\t\t &tx_prop->tx[tx_index].attrib,\n\t\t\t\t\t\t sizeof(rt_rule_entry->rule.attrib));\n\t\t   \t        rt_rule_entry->rule.hdr_hdl = get_client_memptr(wlan_client, wlan_index)->hdr_hdl_v6;\n\t\t\t        rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = get_client_memptr(wlan_client, wlan_index)->v6_addr[v6_num][0];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = get_client_memptr(wlan_client, wlan_index)->v6_addr[v6_num][1];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = get_client_memptr(wlan_client, wlan_index)->v6_addr[v6_num][2];\n\t\t   \t        rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = get_client_memptr(wlan_client, wlan_index)->v6_addr[v6_num][3];\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;\n\t\t\t\trt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;\n\n\t\t               if (false == m_routing.AddRoutingRule(rt_rule))\n\t\t               {\n\t\t\t           IPACMERR(\"Routing rule addition failed!\\n\");\n\t\t\t           free(rt_rule);\n\t\t\t           return IPACM_FAILURE;\n\t\t               }\n\n\t\t                get_client_memptr(wlan_client, wlan_index)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6_wan[v6_num] = rt_rule->rules[0].rt_rule_hdl;\n\n\t\t\t\tIPACMDBG_H(\"tx:%d, rt rule hdl=%x ip-type: %d\\n\", tx_index,\n\t\t            \t\t\t\t get_client_memptr(wlan_client, wlan_index)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6_wan[v6_num], iptype);\n\t\t\t    }\n\t\t\t}\n\n  \t        } /* end of for loop */\n\n\t\tfree(rt_rule);\n\n\t\tif (iptype == IPA_IP_v4)\n\t\t{\n\t\t\tget_client_memptr(wlan_client, wlan_index)->route_rule_set_v4 = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tget_client_memptr(wlan_client, wlan_index)->route_rule_set_v6 = get_client_memptr(wlan_client, wlan_index)->ipv6_set;\n\t\t}\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\n/*handle wifi client power-save mode*/\nint IPACM_Wlan::handle_wlan_client_pwrsave(uint8_t *mac_addr)\n{\n\tint clt_indx;\n\tIPACMDBG_H(\"wlan->handle_wlan_client_pwrsave();\\n\");\n\n\tclt_indx = get_wlan_client_index(mac_addr);\n\tif (clt_indx == IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMDBG_H(\"wlan client not attached\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n        if (get_client_memptr(wlan_client, clt_indx)->power_save_set == false)\n\t{\n\t\t/* First reset nat rules and then route rules */\n\t    if(get_client_memptr(wlan_client, clt_indx)->ipv4_set == true)\n\t    {\n\t\t\tIPACMDBG_H(\"Deleting Nat Rules\\n\");\n\t\t\tNat_App->UpdatePwrSaveIf(get_client_memptr(wlan_client, clt_indx)->v4_addr);\n \t     }\n\n\t\tIPACMDBG_H(\"Deleting default qos Route Rules\\n\");\n\t\tdelete_default_qos_rtrules(clt_indx, IPA_IP_v4);\n\t\tdelete_default_qos_rtrules(clt_indx, IPA_IP_v6);\n                get_client_memptr(wlan_client, clt_indx)->power_save_set = true;\n\t}\n\telse\n\t{\n\t\tIPACMDBG_H(\"wlan client already in power-save mode\\n\");\n\t}\n    return IPACM_SUCCESS;\n}\n\n/*handle wifi client del mode*/\nint IPACM_Wlan::handle_wlan_client_down_evt(uint8_t *mac_addr)\n{\n\tint clt_indx;\n\tuint32_t tx_index;\n\tint num_wifi_client_tmp = num_wifi_client;\n\tint num_v6;\n\n\tIPACMDBG_H(\"total client: %d\\n\", num_wifi_client_tmp);\n\n\tclt_indx = get_wlan_client_index(mac_addr);\n\tif (clt_indx == IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMDBG_H(\"wlan client not attached\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\t/* First reset nat rules and then route rules */\n\tif(get_client_memptr(wlan_client, clt_indx)->ipv4_set == true)\n\t{\n\t        IPACMDBG_H(\"Clean Nat Rules for ipv4:0x%x\\n\", get_client_memptr(wlan_client, clt_indx)->v4_addr);\n\t\t\tCtList->HandleNeighIpAddrDelEvt(get_client_memptr(wlan_client, clt_indx)->v4_addr);\n \t}\n\n\tif (delete_default_qos_rtrules(clt_indx, IPA_IP_v4))\n\t{\n\t\tIPACMERR(\"unbale to delete v4 default qos route rules for index: %d\\n\", clt_indx);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif (delete_default_qos_rtrules(clt_indx, IPA_IP_v6))\n\t{\n\t\tIPACMERR(\"unbale to delete v6 default qos route rules for indexn: %d\\n\", clt_indx);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/* Delete wlan client header */\n\tif(get_client_memptr(wlan_client, clt_indx)->ipv4_header_set == true)\n\t{\n\tif (m_header.DeleteHeaderHdl(get_client_memptr(wlan_client, clt_indx)->hdr_hdl_v4)\n\t\t\t== false)\n\t{\n\t\treturn IPACM_FAILURE;\n\t}\n\t\tget_client_memptr(wlan_client, clt_indx)->ipv4_header_set = false;\n\t}\n\n\tif(get_client_memptr(wlan_client, clt_indx)->ipv6_header_set == true)\n\t{\n\tif (m_header.DeleteHeaderHdl(get_client_memptr(wlan_client, clt_indx)->hdr_hdl_v6)\n\t\t\t== false)\n\t{\n\t\treturn IPACM_FAILURE;\n\t}\n\t\tget_client_memptr(wlan_client, clt_indx)->ipv6_header_set = false;\n\t}\n\n\t/* Reset ip_set to 0*/\n\tget_client_memptr(wlan_client, clt_indx)->ipv4_set = false;\n\tget_client_memptr(wlan_client, clt_indx)->ipv6_set = 0;\n\tget_client_memptr(wlan_client, clt_indx)->ipv4_header_set = false;\n\tget_client_memptr(wlan_client, clt_indx)->ipv6_header_set = false;\n\tget_client_memptr(wlan_client, clt_indx)->route_rule_set_v4 = false;\n\tget_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 = 0;\n\tfree(get_client_memptr(wlan_client, clt_indx)->p_hdr_info);\n\n\tfor (; clt_indx < num_wifi_client_tmp - 1; clt_indx++)\n\t{\n\t\tget_client_memptr(wlan_client, clt_indx)->p_hdr_info = get_client_memptr(wlan_client, (clt_indx + 1))->p_hdr_info;\n\n\t\tmemcpy(get_client_memptr(wlan_client, clt_indx)->mac,\n\t\t\t\t\t get_client_memptr(wlan_client, (clt_indx + 1))->mac,\n\t\t\t\t\t sizeof(get_client_memptr(wlan_client, clt_indx)->mac));\n\n\t\tget_client_memptr(wlan_client, clt_indx)->hdr_hdl_v4 = get_client_memptr(wlan_client, (clt_indx + 1))->hdr_hdl_v4;\n\t\tget_client_memptr(wlan_client, clt_indx)->hdr_hdl_v6 = get_client_memptr(wlan_client, (clt_indx + 1))->hdr_hdl_v6;\n\t\tget_client_memptr(wlan_client, clt_indx)->v4_addr = get_client_memptr(wlan_client, (clt_indx + 1))->v4_addr;\n\n\t\tget_client_memptr(wlan_client, clt_indx)->ipv4_set = get_client_memptr(wlan_client, (clt_indx + 1))->ipv4_set;\n\t\tget_client_memptr(wlan_client, clt_indx)->ipv6_set = get_client_memptr(wlan_client, (clt_indx + 1))->ipv6_set;\n\t\tget_client_memptr(wlan_client, clt_indx)->ipv4_header_set = get_client_memptr(wlan_client, (clt_indx + 1))->ipv4_header_set;\n\t\tget_client_memptr(wlan_client, clt_indx)->ipv6_header_set = get_client_memptr(wlan_client, (clt_indx + 1))->ipv6_header_set;\n\n\t\tget_client_memptr(wlan_client, clt_indx)->route_rule_set_v4 = get_client_memptr(wlan_client, (clt_indx + 1))->route_rule_set_v4;\n\t\tget_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 = get_client_memptr(wlan_client, (clt_indx + 1))->route_rule_set_v6;\n\n                for(num_v6=0;num_v6< get_client_memptr(wlan_client, clt_indx)->ipv6_set;num_v6++)\n\t        {\n\t\t    get_client_memptr(wlan_client, clt_indx)->v6_addr[num_v6][0] = get_client_memptr(wlan_client, (clt_indx + 1))->v6_addr[num_v6][0];\n\t\t    get_client_memptr(wlan_client, clt_indx)->v6_addr[num_v6][1] = get_client_memptr(wlan_client, (clt_indx + 1))->v6_addr[num_v6][1];\n\t\t    get_client_memptr(wlan_client, clt_indx)->v6_addr[num_v6][2] = get_client_memptr(wlan_client, (clt_indx + 1))->v6_addr[num_v6][2];\n\t\t    get_client_memptr(wlan_client, clt_indx)->v6_addr[num_v6][3] = get_client_memptr(wlan_client, (clt_indx + 1))->v6_addr[num_v6][3];\n                }\n\n\t\tfor (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)\n\t\t{\n\t\t\tget_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v4 =\n\t\t\t\t get_client_memptr(wlan_client, (clt_indx + 1))->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v4;\n\n\t\t\tfor(num_v6=0;num_v6< get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6;num_v6++)\n\t\t\t{\n\t\t\t  get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6[num_v6] =\n\t\t\t   \t get_client_memptr(wlan_client, (clt_indx + 1))->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6[num_v6];\n\t\t\t  get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6_wan[num_v6] =\n\t\t\t   \t get_client_memptr(wlan_client, (clt_indx + 1))->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6_wan[num_v6];\n\t\t    }\n\t\t}\n\t}\n\n\tIPACMDBG_H(\" %d wifi client deleted successfully \\n\", num_wifi_client);\n\tnum_wifi_client = num_wifi_client - 1;\n\tIPACM_Wlan::total_num_wifi_clients = IPACM_Wlan::total_num_wifi_clients - 1;\n\tIPACMDBG_H(\" Number of wifi client: %d\\n\", num_wifi_client);\n\n\treturn IPACM_SUCCESS;\n}\n\n/*handle wlan iface down event*/\nint IPACM_Wlan::handle_down_evt()\n{\n\tint res = IPACM_SUCCESS, i;\n\n\tIPACMDBG_H(\"WLAN ip-type: %d \\n\", ip_type);\n\t/* no iface address up, directly close iface*/\n\tif (ip_type == IPACM_IP_NULL)\n\t{\n\t\tIPACMERR(\"Invalid iptype: 0x%x\\n\", ip_type);\n\t\tgoto fail;\n\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tif(wlan_ap_index == 0)\n\t{\n\t\tIPACM_Lan::wlan_hdr_type = IPA_HDR_L2_NONE;\n\t\tIPACM_Lan::wlan_hdr_template_hdl = 0;\n\t\tdel_hdr_proc_ctx();\n\t}\n#endif\n\n\t/* delete wan filter rule */\n\tif (IPACM_Wan::isWanUP(ipa_if_num) && rx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"LAN IF goes down, backhaul type %d\\n\", IPACM_Wan::backhaul_is_sta_mode);\n\t\tIPACM_Lan::handle_wan_down(IPACM_Wan::backhaul_is_sta_mode);\n\t}\n\n\tif (IPACM_Wan::isWanUP_V6(ipa_if_num) && rx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"LAN IF goes down, backhaul type %d\\n\", IPACM_Wan::backhaul_is_sta_mode);\n\t\tIPACM_Lan::handle_wan_down_v6(IPACM_Wan::backhaul_is_sta_mode);\n\t}\n\tIPACMDBG_H(\"finished deleting wan filtering rules\\n \");\n\n\t/* Delete v4 filtering rules */\n\tif (ip_type != IPA_IP_v6 && rx_prop != NULL)\n\t{\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tif(wlan_ap_index == 0)\n\t\t{\n\t\t\t/* delete default filter rules */\n\t\t\tfor(i=0; i<IPV4_DEFAULT_FILTERTING_RULES; i++)\n\t\t\t{\n\t\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, dft_v4fl_rule_hdl[i]) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error deleting dft IPv4 flt rules.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#else\n\t\t/* delete default filter rules */\n\t\tfor(i=0; i<IPV4_DEFAULT_FILTERTING_RULES; i++)\n\t\t{\n\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, dft_v4fl_rule_hdl[i]) == IPACM_FAILURE)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error deleting dft IPv4 flt rules.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n#endif\n\t\tIPACMDBG_H(\"Deleted default v4 filter rules successfully.\\n\");\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tif(is_guest_ap == true)\n\t\t{\n\t\t\tIPACMDBG_H(\"Delete wlan guest ap v4 flt rules.\\n\");\n\t\t\tfor(i=0; i<IPACM_Iface::ipacmcfg->ipa_num_private_subnet; i++)\n\t\t\t{\n\t\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, wlan_guest_ap_flt_rule_hdl_v4[i]) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error deleting wlan guest ap IPv4 flt rules.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tIPACMDBG_H(\"Deleted guest ap v4 filter rules successfully.\\n\");\n#endif\n\n\t\t/* delete icmp filter rules */\n\t\tif(wlan_ap_index == 0)\n\t\t{\n\t\t\tif(m_filtering.DeleteFilteringHdls(ipv6_icmp_flt_rule_hdl, IPA_IP_v6, NUM_IPV6_ICMP_FLT_RULE) == false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error Deleting ICMPv6 Filtering Rule, aborting...\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n#ifndef FEATURE_ETH_BRIDGE_LE\n#ifdef CT_OPT\n\t\tIPACMDBG_H(\"Delete tcp control flt rules.\\n\");\n\t\t/* Delete tcp control flt rules */\n\t\tfor(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)\n\t\t{\n\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, tcp_ctl_flt_rule_hdl_v4[i]) == IPACM_FAILURE)\n\t\t\t{\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n#endif\n\t\tIPACMDBG_H(\"Delete lan2lan v4 flt rules.\\n\");\n\t\t/* delete lan2lan ipv4 flt rules */\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, lan2lan_flt_rule_hdl_v4[i].rule_hdl) == IPACM_FAILURE)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error deleting lan2lan IPv4 flt rules.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n#endif\n\n\t\tIPACMDBG_H(\"Delete private v4 filter rules\\n\");\n\t\t/* delete private-ipv4 filter rules */\n#ifdef FEATURE_IPA_ANDROID\n\t\tfor(i=0; i<IPA_MAX_PRIVATE_SUBNET_ENTRIES; i++)\n\t\t{\n\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, private_fl_rule_hdl[i]) == IPACM_FAILURE)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error deleting private subnet IPv4 flt rules.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n#else\n\t\tif(wlan_ap_index == 0)\n\t\t{\n\t\t\tfor(i=0; i<IPACM_Iface::ipacmcfg->ipa_num_private_subnet; i++)\n\t\t\t{\n\t\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, private_fl_rule_hdl[i]) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Error deleting private subnet IPv4 flt rules.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tIPACMDBG_H(\"Deleted private subnet v4 filter rules successfully.\\n\");\n#endif\n\t}\n\n\t/* Delete v6 filtering rules */\n\tif (ip_type != IPA_IP_v4 && rx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"Delete default %d v6 filter rules\\n\", IPV6_DEFAULT_FILTERTING_RULES);\n\t\t/* delete default filter rules */\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tif(wlan_ap_index == 0)\n\t\t{\n\t\t\tfor(i=0; i<IPV6_DEFAULT_FILTERTING_RULES; i++)\n\t\t\t{\n\t\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, dft_v6fl_rule_hdl[i]) == IPACM_FAILURE)\n\t\t\t\t{\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#else\n\t\tfor(i=0; i<IPV6_DEFAULT_FILTERTING_RULES; i++)\n\t\t{\n\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, dft_v6fl_rule_hdl[i]) == IPACM_FAILURE)\n\t\t\t{\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n#endif\n\t\tIPACMDBG_H(\"Deleted default v6 filter rules successfully.\\n\");\n\n#ifndef FEATURE_ETH_BRIDGE_LE\n#ifdef CT_OPT\n\t\tIPACMDBG_H(\"Delete tcp control flt rules.\\n\");\n\t\t/* Delete tcp control flt rules */\n\t\tfor(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)\n\t\t{\n\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, tcp_ctl_flt_rule_hdl_v6[i]) == IPACM_FAILURE)\n\t\t\t{\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n#endif\n\t\tIPACMDBG_H(\"Delete lan2lan v6 flt rules.\\n\");\n\t\t/* delete lan2lan ipv4 flt rules */\n\t\tfor(i=0; i<MAX_OFFLOAD_PAIR; i++)\n\t\t{\n\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, lan2lan_flt_rule_hdl_v6[i].rule_hdl) == IPACM_FAILURE)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error deleting lan2lan IPv4 flt rules.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n#endif\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tif(is_guest_ap == true)\n\t\t{\n\t\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, wlan_guest_ap_flt_rule_hdl_v6) == IPACM_FAILURE)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Error deleting wlan guest ap IPv6 flt rules.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tIPACMDBG_H(\"Deleted wlan guest ap v6 filter rules successfully.\\n\");\n#endif\n\t}\n\tIPACMDBG_H(\"finished delete filtering rules\\n \");\n\n\t/* Delete default v4 RT rule */\n\tif (ip_type != IPA_IP_v6)\n\t{\n\t\tIPACMDBG_H(\"Delete default v4 routing rules\\n\");\n\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4)\n\t\t\t\t== false)\n\t\t{\n\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\t/* Delete default v6 RT rule */\n\tif (ip_type != IPA_IP_v4)\n\t{\n\t\tIPACMDBG_H(\"Delete default v6 routing rules\\n\");\n\t\t/* May have multiple ipv6 iface-RT rules */\n\t\tfor (i = 0; i < 2*num_dft_rt_v6; i++)\n\t\t{\n\t\t\tif (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+i], IPA_IP_v6)\n\t\t\t\t\t== false)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Routing rule deletion failed!\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t}\n\tIPACMDBG_H(\"finished deleting default RT rules\\n \");\n\n\t/* check software routing fl rule hdl */\n\tif (softwarerouting_act == true && rx_prop != NULL )\n\t{\n\t\tIPACMDBG_H(\"Delete sw routing filtering rules\\n\");\n\t\tIPACM_Iface::handle_software_routing_disable();\n\t}\n\tIPACMDBG_H(\"finished delete software-routing filtering rules\\n \");\n\n\n\t/* clean wifi-client header, routing rules */\n\t/* clean wifi client rule*/\n\tIPACMDBG_H(\"left %d wifi clients need to be deleted \\n \", num_wifi_client);\n\n\tfor (i = 0; i < num_wifi_client; i++)\n\t{\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\teth_bridge_del_wlan_client(get_client_memptr(wlan_client, i)->mac);\n\t\teth_bridge_del_self_client_flt_rule(get_client_memptr(wlan_client, i)->mac);\n\t\teth_bridge_post_lan_client_event(get_client_memptr(wlan_client, i)->mac, IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT);\n\t\teth_bridge_del_wlan_client_rt_rule(get_client_memptr(wlan_client, i)->mac, SRC_WLAN);\n\t\teth_bridge_del_wlan_client_rt_rule(get_client_memptr(wlan_client, i)->mac, SRC_USB);\n#endif\n\t\t/* First reset nat rules and then route rules */\n\t\tif(get_client_memptr(wlan_client, i)->ipv4_set == true)\n\t\t{\n\t        IPACMDBG_H(\"Clean Nat Rules for ipv4:0x%x\\n\", get_client_memptr(wlan_client, i)->v4_addr);\n\t\t\tCtList->HandleNeighIpAddrDelEvt(get_client_memptr(wlan_client, i)->v4_addr);\n\t\t}\n\n\t\tif (delete_default_qos_rtrules(i, IPA_IP_v4))\n\t\t{\n\t\t\tIPACMERR(\"unbale to delete v4 default qos route rules for index: %d\\n\", i);\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tif (delete_default_qos_rtrules(i, IPA_IP_v6))\n\t\t{\n\t\t\tIPACMERR(\"unbale to delete v6 default qos route rules for index: %d\\n\", i);\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tIPACMDBG_H(\"Delete %d client header\\n\", num_wifi_client);\n\n\t\thandle_lan2lan_msg_post(get_client_memptr(wlan_client, i)->mac, IPA_LAN_CLIENT_DISCONNECT, IPA_IP_v4);\n\t\thandle_lan2lan_msg_post(get_client_memptr(wlan_client, i)->mac, IPA_LAN_CLIENT_DISCONNECT, IPA_IP_v6);\n\n        if(get_client_memptr(wlan_client, i)->ipv4_header_set == true)\n        {\n\t\t\tif (m_header.DeleteHeaderHdl(get_client_memptr(wlan_client, i)->hdr_hdl_v4)\n\t\t\t\t== false)\n\t\t\t{\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\n        if(get_client_memptr(wlan_client, i)->ipv6_header_set == true)\n        {\n\t\t\tif (m_header.DeleteHeaderHdl(get_client_memptr(wlan_client, i)->hdr_hdl_v6)\n\t\t\t\t\t== false)\n\t\t\t{\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t} /* end of for loop */\n\n\t/* free the wlan clients cache */\n\tIPACMDBG_H(\"Free wlan clients cache\\n\");\n\n\t/* Delete private subnet*/\n#ifdef FEATURE_IPA_ANDROID\n\tif (ip_type != IPA_IP_v6)\n\t{\n\t\tIPACMDBG_H(\"current IPACM private subnet_addr number(%d)\\n\", IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n\t\tIPACMDBG_H(\" Delete IPACM private subnet_addr as: 0x%x \\n\", if_ipv4_subnet);\n\t\tif(IPACM_Iface::ipacmcfg->DelPrivateSubnet(if_ipv4_subnet, ipa_if_num) == false)\n\t\t{\n\t\t\tIPACMERR(\" can't Delete IPACM private subnet_addr as: 0x%x \\n\", if_ipv4_subnet);\n\t\t}\n\t}\n\t/* reset the IPA-client pipe enum */\n\thandle_tethering_client(true, IPACM_CLIENT_WLAN);\n#endif /* defined(FEATURE_IPA_ANDROID)*/\n\nfail:\n\t/* Delete corresponding ipa_rm_resource_name of RX-endpoint after delete all IPV4V6 FT-rule */\n\tif (rx_prop != NULL)\n\t{\n\t\tIPACMDBG_H(\"dev %s add producer dependency\\n\", dev_name);\n\t\tIPACMDBG_H(\"depend Got pipe %d rm index : %d \\n\", rx_prop->rx[0].src_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);\n\t\tIPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);\n\t\tfree(rx_prop);\n\t}\n\n\tfor (i = 0; i < num_wifi_client; i++)\n\t{\n\t\tif(get_client_memptr(wlan_client, i)->p_hdr_info != NULL)\n\t\t{\n\t\t\tfree(get_client_memptr(wlan_client, i)->p_hdr_info);\n\t\t}\n\t}\n\tif(wlan_client != NULL)\n\t{\n\t\tfree(wlan_client);\n\t}\n\tif (tx_prop != NULL)\n\t{\n\t\tfree(tx_prop);\n\t}\n\n\tif (iface_query != NULL)\n\t{\n\t\tfree(iface_query);\n\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\tif(eth_bridge_usb_client_rt_info_v4 != NULL)\n\t{\n\t\tfree(eth_bridge_usb_client_rt_info_v4);\n\t}\n\tif(eth_bridge_usb_client_rt_info_v6 != NULL)\n\t{\n\t\tfree(eth_bridge_usb_client_rt_info_v6);\n\t}\n\tif(eth_bridge_wlan_client_rt_from_usb_info_v4 != NULL)\n\t{\n\t\tfree(eth_bridge_wlan_client_rt_from_usb_info_v4);\n\t}\n\tif(eth_bridge_wlan_client_rt_from_usb_info_v6 != NULL)\n\t{\n\t\tfree(eth_bridge_wlan_client_rt_from_usb_info_v6);\n\t}\n\tif(eth_bridge_wlan_client_rt_from_wlan_info_v4 != NULL)\n\t{\n\t\tfree(eth_bridge_wlan_client_rt_from_wlan_info_v4);\n\t}\n\tif(eth_bridge_wlan_client_rt_from_wlan_info_v6 != NULL)\n\t{\n\t\tfree(eth_bridge_wlan_client_rt_from_wlan_info_v6);\n\t}\n#endif\n\tis_active = false;\n\tpost_del_self_evt();\n\n\treturn res;\n}\n\n/*handle reset wifi-client rt-rules */\nint IPACM_Wlan::handle_wlan_client_reset_rt(ipa_ip_type iptype)\n{\n\tint i, res = IPACM_SUCCESS;\n\n\t/* clean wifi-client routing rules */\n\tIPACMDBG_H(\"left %d wifi clients to reset ip-type(%d) rules \\n \", num_wifi_client, iptype);\n\n\tfor (i = 0; i < num_wifi_client; i++)\n\t{\n\t\t/* Reset RT rules */\n\t\tres = delete_default_qos_rtrules(i, iptype);\n\t\tif (res != IPACM_SUCCESS)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete old iptype(%d) rules.\\n\", iptype);\n\t\t\treturn res;\n\t\t}\n\t\t/* Pass info to LAN2LAN module */\n\t\tres = handle_lan2lan_msg_post(get_client_memptr(wlan_client, i)->mac, IPA_LAN_CLIENT_DISCONNECT, iptype);\n\t\tif (res != IPACM_SUCCESS)\n\t\t{\n\t\t\tIPACMERR(\"Failed to posting delete old iptype(%d) address.\\n\", iptype);\n\t\t\treturn res;\n\t\t}\n\t\t/* Reset ip-address */\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tget_client_memptr(wlan_client, i)->ipv4_set = false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tget_client_memptr(wlan_client, i)->ipv6_set = 0;\n\t\t}\n\t} /* end of for loop */\n\treturn res;\n}\n\n/*handle lan2lan internal mesg posting*/\nint IPACM_Wlan::handle_lan2lan_msg_post(uint8_t *mac_addr, ipa_cm_event_id event,ipa_ip_type iptype)\n{\n\tint client_index;\n\tclient_index = get_wlan_client_index(mac_addr);\n\tif (client_index == IPACM_INVALID_INDEX)\n\t{\n\t\tIPACMDBG_H(\"wlan client not attached\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tipacm_event_lan_client* lan_client;\n\tipacm_cmd_q_data evt_data;\n\tif((get_client_memptr(wlan_client, client_index)->ipv4_set == true)\n\t\t&& (iptype == IPA_IP_v4)) /* handle ipv4 case*/\n\t{\n\t\tif(ip_type != IPA_IP_v4 && ip_type != IPA_IP_MAX)\n\t\t{\n\t\t\tIPACMERR(\"Client has IPv4 addr but iface does not have IPv4 up.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\tlan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));\n\t\tif(lan_client == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Unable to allocate memory.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(lan_client, 0, sizeof(ipacm_event_lan_client));\n\n\t\tlan_client->iptype = IPA_IP_v4;\n\t\tlan_client->ipv4_addr = get_client_memptr(wlan_client, client_index)->v4_addr;\n\t\tlan_client->p_iface = this;\n\n\t\tmemset(&evt_data, 0, sizeof(evt_data));\n\t\tevt_data.event = event;\n\t\tevt_data.evt_data = (void*)lan_client;\n\n\t\tIPACMDBG_H(\"Posting event: %d\\n\",event);\n\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t}\n\n\tif((get_client_memptr(wlan_client, client_index)->ipv6_set > 0)\n\t\t&& (iptype == IPA_IP_v6)) /* handle v6 case: may be multiple v6 addr */\n\t{\n\t\tif(ip_type != IPA_IP_v6 && ip_type != IPA_IP_MAX)\n\t\t{\n\t\t\tIPACMERR(\"Client has IPv6 addr but iface does not have IPv6 up.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tint i;\n\n\t\tfor(i=0; i<get_client_memptr(wlan_client, client_index)->ipv6_set; i++)\n\t\t{\n\t\t\tlan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));\n\t\t\tif(lan_client == NULL)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Unable to allocate memory.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t\tmemset(lan_client, 0, sizeof(ipacm_event_lan_client));\n\n\t\t\tlan_client->iptype = IPA_IP_v6;\n\t\t\tmemcpy(lan_client->ipv6_addr, get_client_memptr(wlan_client, client_index)->v6_addr[i], 4*sizeof(uint32_t));\n\t\t\tlan_client->p_iface = this;\n\n\t\t\tmemset(&evt_data, 0, sizeof(evt_data));\n\t\t\tevt_data.event = event;\n\t\t\tevt_data.evt_data = (void*)lan_client;\n\n\t\t\tIPACMDBG_H(\"Posting event: %d\\n\",event);\n\t\t\tIPACM_EvtDispatcher::PostEvt(&evt_data);\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wlan::add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl)\n{\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMERR(\"There is no tx_prop, cannot add header.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(src_mac == NULL || dst_mac == NULL)\n\t{\n\t\tIPACMERR(\"Either src_mac or dst_mac is null, cannot add header.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(hdr_hdl == NULL)\n\t{\n\t\tIPACMERR(\"Header handle is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tint i, j, k, len;\n\tint res = IPACM_SUCCESS;\n\tchar index[4];\n\tstruct ipa_ioc_copy_hdr sCopyHeader;\n\tstruct ipa_ioc_add_hdr *pHeader;\n\n\tIPACMDBG_H(\"Get lan2lan header request, src_mac: 0x%02x%02x%02x%02x%02x%02x dst_mac: 0x%02x%02x%02x%02x%02x%02x\\n\",\n\t\t\tsrc_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], dst_mac[0], dst_mac[1],\n\t\t\tdst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]);\n\n\tlen = sizeof(struct ipa_ioc_add_hdr) + sizeof(struct ipa_hdr_add);\n\tpHeader = (struct ipa_ioc_add_hdr *)malloc(len);\n\tif (pHeader == NULL)\n\t{\n\t\tIPACMERR(\"Failed to allocate header\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pHeader, 0, len);\n\n\tif(iptype == IPA_IP_v4)\n\t{\t\t/* copy partial header for v4*/\n\t\tfor(i=0; i<tx_prop->num_tx_props; i++)\n\t\t{\n\t\t\tif(tx_prop->tx[i].ip == IPA_IP_v4)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Got v4-header name from %d tx props\\n\", i);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG_H(\"Header name: %s\\n\", sCopyHeader.name);\n\t\t\t\tif(m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Copy header failed\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"Header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);\n\t\t\t\t}\n\n\t\t\t\tfor(j=0; j<num_wifi_client; j++)\t//Add src/dst mac to the header\n\t\t\t\t{\n\t\t\t\t\tif(memcmp(dst_mac, get_client_memptr(wlan_client, j)->mac, IPA_MAC_ADDR_SIZE) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(j == num_wifi_client)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Not able to find the wifi client from mac addr.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Find wifi client at position %d\\n\", j);\n\t\t\t\t\tfor(k = 0; k < get_client_memptr(wlan_client, j)->p_hdr_info->num_of_attribs; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset],\n\t\t\t\t\t\t\t\t\tdst_mac, IPA_MAC_ADDR_SIZE);\n\t\t\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset + IPA_MAC_ADDR_SIZE],\n\t\t\t\t\t\t\t\t\tsrc_mac, IPA_MAC_ADDR_SIZE);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].attrib_type == WLAN_HDR_ATTRIB_STA_ID)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset],\n\t\t\t\t\t\t\t\t\t&get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].u.sta_id,\n\t\t\t\t\t\t\t\t\tsizeof(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].u.sta_id));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMDBG_H(\"The attribute type is not expected!\\n\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tpHeader->commit = true;\n\t\t\t\tpHeader->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));\n\t\t\t\tstrlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_WLAN_HDR_NAME_V4, sizeof(pHeader->hdr[0].name));\n\n\t\t\t\tfor(j=0; j<MAX_OFFLOAD_PAIR; j++)\n\t\t\t\t{\n\t\t\t\t\tif( lan2lan_hdr_hdl_v4[j].valid == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Construct lan2lan hdr with index %d.\\n\", j);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(j == MAX_OFFLOAD_PAIR)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to find an available hdr index.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tlan2lan_hdr_hdl_v4[j].valid = true;\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", j);\n\n\t\t\t\tif (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeader->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tpHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeader->hdr[0].is_partial = 0;\n\t\t\t\tpHeader->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeader->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Ioctl IPA_IOC_ADD_HDR failed with status: %d\\n\", pHeader->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tIPACMDBG_H(\"Installed v4 full header %s header handle 0x%08x\\n\", pHeader->hdr[0].name,\n\t\t\t\t\t\t\tpHeader->hdr[0].hdr_hdl);\n\t\t\t\t*hdr_hdl = pHeader->hdr[0].hdr_hdl;\n\t\t\t\tlan2lan_hdr_hdl_v4[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\t\t/* copy partial header for v6*/\n\t\tfor(i=0; i<tx_prop->num_tx_props; i++)\n\t\t{\n\t\t\tif(tx_prop->tx[i].ip == IPA_IP_v6)\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Got v6-header name from %d tx props\\n\", i);\n\t\t\t\tmemset(&sCopyHeader, 0, sizeof(sCopyHeader));\n\t\t\t\tmemcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));\n\n\t\t\t\tIPACMDBG_H(\"Header name: %s\\n\", sCopyHeader.name);\n\t\t\t\tif(m_header.CopyHeader(&sCopyHeader) == false)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Copy header failed\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\n\t\t\t\tIPACMDBG_H(\"Header length: %d, paritial: %d\\n\", sCopyHeader.hdr_len, sCopyHeader.is_partial);\n\t\t\t\tif (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Header oversize\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);\n\t\t\t\t}\n\n\t\t\t\tfor(j=0; j<num_wifi_client; j++)\t//Add src/dst mac to the header\n\t\t\t\t{\n\t\t\t\t\tif(memcmp(dst_mac, get_client_memptr(wlan_client, j)->mac, IPA_MAC_ADDR_SIZE) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(j == num_wifi_client)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Not able to find the wifi client from mac addr.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"Find wifi client at position %d\\n\", j);\n\t\t\t\t\tfor(k = 0; k < get_client_memptr(wlan_client, j)->p_hdr_info->num_of_attribs; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset],\n\t\t\t\t\t\t\t\t\tdst_mac, IPA_MAC_ADDR_SIZE);\n\t\t\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset + IPA_MAC_ADDR_SIZE],\n\t\t\t\t\t\t\t\t\tsrc_mac, IPA_MAC_ADDR_SIZE);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].attrib_type == WLAN_HDR_ATTRIB_STA_ID)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset],\n\t\t\t\t\t\t\t\t\t&get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].u.sta_id,\n\t\t\t\t\t\t\t\t\tsizeof(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].u.sta_id));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIPACMDBG_H(\"The attribute type is not expected!\\n\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tpHeader->commit = true;\n\t\t\t\tpHeader->num_hdrs = 1;\n\n\t\t\t\tmemset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));\n\t\t\t\tstrlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_WLAN_HDR_NAME_V6, sizeof(pHeader->hdr[0].name));\n\n\n\t\t\t\tfor(j=0; j<MAX_OFFLOAD_PAIR; j++)\n\t\t\t\t{\n\t\t\t\t\tif( lan2lan_hdr_hdl_v6[j].valid == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tIPACMDBG_H(\"Construct lan2lan hdr with index %d.\\n\", j);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(j == MAX_OFFLOAD_PAIR)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed to find an available hdr index.\\n\");\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tlan2lan_hdr_hdl_v6[j].valid = true;\n\t\t\t\tsnprintf(index,sizeof(index), \"%d\", j);\n\n\t\t\t\tif (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\" header name construction failed exceed length (%d)\\n\", strlen(pHeader->hdr[0].name));\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tpHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;\n\t\t\t\tpHeader->hdr[0].is_partial = 0;\n\t\t\t\tpHeader->hdr[0].hdr_hdl = -1;\n\t\t\t\tpHeader->hdr[0].status = -1;\n\n\t\t\t\tif (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Ioctl IPA_IOC_ADD_HDR failed with status: %d\\n\", pHeader->hdr[0].status);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t\tIPACMDBG_H(\"Installed v6 full header %s header handle 0x%08x\\n\", pHeader->hdr[0].name,\n\t\t\t\t\t\t\tpHeader->hdr[0].hdr_hdl);\n\t\t\t\t*hdr_hdl = pHeader->hdr[0].hdr_hdl;\n\t\t\t\tlan2lan_hdr_hdl_v6[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t}\n\nfail:\n\tfree(pHeader);\n\treturn res;\n}\n\n/* add dummy filtering rules for WLAN AP-AP mode support */\nvoid IPACM_Wlan::add_dummy_flt_rule()\n{\n\tint num_v4_dummy_rule, num_v6_dummy_rule;\n\n\tif(IPACM_Wlan::num_wlan_ap_iface == 1)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 != NULL || IPACM_Wlan::dummy_flt_rule_hdl_v6 != NULL)\n\t\t{\n\t\t\tIPACMERR(\"Either v4 or v6 dummy filtering rule handle is not empty.\\n\");\n\t\t\treturn;\n\t\t}\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tnum_v4_dummy_rule = IPV4_DEFAULT_FILTERTING_RULES + IPACM_Iface::ipacmcfg->ipa_num_private_subnet + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\t\tnum_v6_dummy_rule = IPV6_DEFAULT_FILTERTING_RULES + 1 + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT;\n#else\n#ifndef CT_OPT\n\t\tnum_v4_dummy_rule = 2*(IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n\t\tnum_v6_dummy_rule = 2*(IPV6_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR);\n#else\n\t\tnum_v4_dummy_rule = 2*(IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n\t\tnum_v6_dummy_rule = 2*(IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR);\n#endif\n#ifdef FEATURE_IPA_ANDROID\n\t\tnum_v4_dummy_rule = num_v4_dummy_rule - 2* IPACM_Iface::ipacmcfg->ipa_num_private_subnet + 2 * IPA_MAX_PRIVATE_SUBNET_ENTRIES;\n#endif\n#endif\n\n\t\tIPACM_Wlan::dummy_flt_rule_hdl_v4 = (uint32_t*)malloc(num_v4_dummy_rule * sizeof(uint32_t));\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Failed to allocate memory.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tIPACM_Wlan::dummy_flt_rule_hdl_v6 = (uint32_t*)malloc(num_v6_dummy_rule * sizeof(uint32_t));\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v6 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Failed to allocate memory.\\n\");\n\t\t\tfree(IPACM_Wlan::dummy_flt_rule_hdl_v4);\n\t\t\tIPACM_Wlan::dummy_flt_rule_hdl_v4 = NULL;\n\t\t\treturn;\n\t\t}\n\t\tmemset(IPACM_Wlan::dummy_flt_rule_hdl_v4, 0, num_v4_dummy_rule * sizeof(uint32_t));\n\t\tmemset(IPACM_Wlan::dummy_flt_rule_hdl_v6, 0, num_v6_dummy_rule * sizeof(uint32_t));\n\n\t\tinstall_dummy_flt_rule(IPA_IP_v4, num_v4_dummy_rule);\n\t\tinstall_dummy_flt_rule(IPA_IP_v6, num_v6_dummy_rule);\n\t}\n\treturn;\n}\n\n/* install dummy filtering rules for WLAN AP-AP mode support */\nint IPACM_Wlan::install_dummy_flt_rule(ipa_ip_type iptype, int num_rule)\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no rx_prop for iface %s, not able to add dummy filtering rule.\\n\", dev_name);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tint i, len, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_add flt_rule;\n\tipa_ioc_add_flt_rule* pFilteringTable;\n\n\tlen = sizeof(struct ipa_ioc_add_flt_rule) + num_rule * sizeof(struct ipa_flt_rule_add);\n\n\tpFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);\n\tif (pFilteringTable == NULL)\n\t{\n\t\tIPACMERR(\"Error allocate flt table memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ep = rx_prop->rx[0].src_pipe;\n\tpFilteringTable->global = false;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = num_rule;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));\n\n\tflt_rule.rule.retain_hdr = 0;\n\tflt_rule.at_rear = true;\n\tflt_rule.flt_rule_hdl = -1;\n\tflt_rule.status = -1;\n\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\n\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,\n\t\t\tsizeof(flt_rule.rule.attrib));\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v4.src_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.src_addr = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;\n\t\tflt_rule.rule.attrib.u.v4.dst_addr = ~0;\n\n\t\tfor(i=0; i<num_rule; i++)\n\t\t{\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error adding dummy ipv4 flt rule\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/* copy filter rule hdls */\n\t\t\tfor (int i = 0; i < num_rule; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tIPACM_Wlan::dummy_flt_rule_hdl_v4[i] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\tIPACMDBG(\"Dummy v4 flt rule %d hdl:0x%x\\n\", i, IPACM_Wlan::dummy_flt_rule_hdl_v4[i]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding dummy v4 flt rule %d\\n\", i);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if(iptype == IPA_IP_v6)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr_mask[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.src_addr[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[0] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[1] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[2] = ~0;\n\t\tflt_rule.rule.attrib.u.v6.dst_addr[3] = ~0;\n\n\t\tfor(i=0; i<num_rule; i++)\n\t\t{\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));\n\t\t}\n\n\t\tif (false == m_filtering.AddFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Error adding dummy ipv6 flt rule\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/* copy filter rule hdls */\n\t\t\tfor (int i = 0; i < num_rule; i++)\n\t\t\t{\n\t\t\t\tif (pFilteringTable->rules[i].status == 0)\n\t\t\t\t{\n\t\t\t\t\tIPACM_Wlan::dummy_flt_rule_hdl_v6[i] = pFilteringTable->rules[i].flt_rule_hdl;\n\t\t\t\t\tIPACMDBG(\"Lan2lan v6 flt rule %d hdl:0x%x\\n\", i, IPACM_Wlan::dummy_flt_rule_hdl_v6[i]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tIPACMERR(\"Failed adding v6 flt rule %d\\n\", i);\n\t\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"IP type is not expected.\\n\");\n\t\tgoto fail;\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\treturn res;\n}\n\n/* delete dummy flt rule for WLAN AP-AP mode support*/\nvoid IPACM_Wlan::del_dummy_flt_rule()\n{\n\tint num_v4_dummy_rule, num_v6_dummy_rule;\n\n\tif(IPACM_Wlan::num_wlan_ap_iface == 0)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL || IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Either v4 or v6 dummy flt rule is empty.\\n\");\n\t\t\treturn;\n\t\t}\n#ifndef CT_OPT\n\t\tnum_v4_dummy_rule = 2*(IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n\t\tnum_v6_dummy_rule = 2*(IPV6_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR);\n#else\n\t\tnum_v4_dummy_rule = 2*(IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n\t\tnum_v6_dummy_rule = 2*(IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR);\n#endif\n#ifdef FEATURE_IPA_ANDROID\n\t\tnum_v4_dummy_rule = num_v4_dummy_rule - 2* IPACM_Iface::ipacmcfg->ipa_num_private_subnet + 2 * IPA_MAX_PRIVATE_SUBNET_ENTRIES;\n#endif\n\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tnum_v4_dummy_rule = IPV4_DEFAULT_FILTERTING_RULES + IPACM_Iface::ipacmcfg->ipa_num_private_subnet + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\t\tnum_v6_dummy_rule = IPV6_DEFAULT_FILTERTING_RULES + 1 + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT;\n#endif\n\n\t\tif(m_filtering.DeleteFilteringHdls(IPACM_Wlan::dummy_flt_rule_hdl_v4, IPA_IP_v4, num_v4_dummy_rule) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete ipv4 dummy flt rules.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif(m_filtering.DeleteFilteringHdls(IPACM_Wlan::dummy_flt_rule_hdl_v6, IPA_IP_v6, num_v6_dummy_rule) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete ipv6 dummy flt rules.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tfree(IPACM_Wlan::dummy_flt_rule_hdl_v4);\n\t\tIPACM_Wlan::dummy_flt_rule_hdl_v4 = NULL;\n\t\tfree(IPACM_Wlan::dummy_flt_rule_hdl_v6);\n\t\tIPACM_Wlan::dummy_flt_rule_hdl_v6 = NULL;\n#ifdef FEATURE_ETH_BRIDGE_LE\n\t\tmemset(self_client_flt_rule_hdl_v4, 0, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(lan2lan_flt_rule_hdl));\n\t\tmemset(self_client_flt_rule_hdl_v6, 0, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(lan2lan_flt_rule_hdl));\n\t\tmemset(usb_client_flt_rule_hdl_v4, 0, IPA_LAN_TO_LAN_MAX_USB_CLIENT * sizeof(lan2lan_flt_rule_hdl));\n\t\tmemset(usb_client_flt_rule_hdl_v6, 0, IPA_LAN_TO_LAN_MAX_USB_CLIENT * sizeof(lan2lan_flt_rule_hdl));\n#endif\n\t}\n\treturn;\n}\n\n/* install TCP control filter rules */\nvoid IPACM_Wlan::install_tcp_ctl_flt_rule(ipa_ip_type iptype)\n{\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn;\n\t}\n\n\tint i, len, res = IPACM_SUCCESS, offset;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable;\n\n\tif (iptype == IPA_IP_v4)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv4 flt rule has not been installed.\\n\");\n\t\t\treturn;\n\t\t}\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#ifdef FEATURE_IPA_ANDROID\n\t\toffset = offset + wlan_ap_index * (IPA_MAX_PRIVATE_SUBNET_ENTRIES - IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#endif\n\t}\n\telse\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v6 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv6 flt rule has not been installed.\\n\");\n\t\t\treturn;\n\t\t}\n\t\toffset = wlan_ap_index * (IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR);\n\t}\n\n\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + NUM_TCP_CTL_FLT_RULE * sizeof(struct ipa_flt_rule_mdfy);\n\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\tif (!pFilteringTable)\n\t{\n\t\tIPACMERR(\"Failed to allocate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\treturn;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = NUM_TCP_CTL_FLT_RULE;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\tflt_rule.status = -1;\n\n\tflt_rule.rule.retain_hdr = 1;\n\tflt_rule.rule.to_uc = 0;\n\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\tflt_rule.rule.eq_attrib_type = 1;\n\n\tflt_rule.rule.eq_attrib.rule_eq_bitmap = 0;\n\n\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<14);\n\tflt_rule.rule.eq_attrib.metadata_meq32_present = 1;\n\tflt_rule.rule.eq_attrib.metadata_meq32.offset = 0;\n\tflt_rule.rule.eq_attrib.metadata_meq32.value = rx_prop->rx[0].attrib.meta_data;\n\tflt_rule.rule.eq_attrib.metadata_meq32.mask = rx_prop->rx[0].attrib.meta_data_mask;\n\n\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<1);\n\tflt_rule.rule.eq_attrib.protocol_eq_present = 1;\n\tflt_rule.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;\n\n\t/* add TCP FIN rule*/\n\tflt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<8);\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);\n\tflt_rule.rule.eq_attrib.num_ihl_offset_meq_32 = 1;\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset];\n\t}\n\telse\n\t{\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset];\n\t}\n\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t/* add TCP SYN rule*/\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+1];\n\t}\n\telse\n\t{\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+1];\n\t}\n\tmemcpy(&(pFilteringTable->rules[1]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\t/* add TCP RST rule*/\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);\n\tflt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+2];\n\t}\n\telse\n\t{\n\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+2];\n\t}\n\tmemcpy(&(pFilteringTable->rules[2]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t{\n\t\tIPACMERR(\"Failed to modify tcp control filtering rules.\\n\");\n\t\tgoto fail;\n\t}\n\telse\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tfor(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)\n\t\t\t{\n\t\t\t\ttcp_ctl_flt_rule_hdl_v4[i] = pFilteringTable->rules[i].rule_hdl;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)\n\t\t\t{\n\t\t\t\ttcp_ctl_flt_rule_hdl_v6[i] = pFilteringTable->rules[i].rule_hdl;\n\t\t\t}\n\t\t}\n\t}\n\nfail:\n\tfree(pFilteringTable);\n\treturn;\n}\n\nint IPACM_Wlan::add_dummy_private_subnet_flt_rule(ipa_ip_type iptype)\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no rx_prop for iface %s, not able to add dummy lan2lan filtering rule.\\n\", dev_name);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tint offset;\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv4 flt rule has not been installed.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n#ifndef CT_OPT\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)\n\t\t\t\t\t\t+ IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR;\n#else\n\t\toffset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)\n\t\t\t\t\t\t+ IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + NUM_TCP_CTL_FLT_RULE;\n#endif\n\n#ifdef FEATURE_IPA_ANDROID\n\t\toffset = offset + wlan_ap_index * (IPA_MAX_PRIVATE_SUBNET_ENTRIES - IPACM_Iface::ipacmcfg->ipa_num_private_subnet);\n#endif\n\t\tfor (int i = 0; i < IPA_MAX_PRIVATE_SUBNET_ENTRIES; i++)\n\t\t{\n\t\t\tprivate_fl_rule_hdl[i] = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+i];\n\t\t\tIPACMDBG_H(\"Private subnet v4 flt rule %d hdl:0x%x\\n\", i, private_fl_rule_hdl[i]);\n\t\t}\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wlan::eth_bridge_add_wlan_guest_ap_flt_rule(ipa_ip_type iptype)\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no rx_prop for iface %s, not able to add wlan guest ap filtering rule.\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\tif(is_guest_ap == false)\n\t{\n\t\tIPACMDBG_H(\"This is not WLAN guest AP, do nothing.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tint len, i, offset, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable = NULL;\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tif(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)\n\t\t{\n\t\t\tIPACMERR(\"Dummy ipv4 flt rule has not been installed.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\n\t\toffset = IPV4_DEFAULT_FILTERTING_RULES;\n\t\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + (IPACM_Iface::ipacmcfg->ipa_num_private_subnet) * sizeof(struct ipa_flt_rule_mdfy);\n\t\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\t\tif (!pFilteringTable)\n\t\t{\n\t\t\tIPACMERR(\"Failed to allocate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t\tmemset(pFilteringTable, 0, len);\n\n\t\tpFilteringTable->commit = 1;\n\t\tpFilteringTable->ip = iptype;\n\t\tpFilteringTable->num_rules = (uint8_t)IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\n\t\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\t\tflt_rule.status = -1;\n\n\t\tflt_rule.rule.retain_hdr = 1;\n\t\tflt_rule.rule.to_uc = 0;\n\t\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\t\tflt_rule.rule.eq_attrib_type = 0;\n\n\t\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\n\t\tfor (i = 0; i < (IPACM_Iface::ipacmcfg->ipa_num_private_subnet); i++)\n\t\t{\n\t\t\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+i];\n\t\t\tflt_rule.rule.attrib.u.v4.dst_addr_mask = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask;\n\t\t\tflt_rule.rule.attrib.u.v4.dst_addr = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr;\n\t\t\tmemcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\t\t}\n\n\t\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t\t{\n\t\t\tIPACMERR(\"Failed to modify wlan guest AP IPv4 filtering rules.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\n\t\t/* copy filter rule hdls */\n\t\tfor (i = 0; i < IPACM_Iface::ipacmcfg->ipa_num_private_subnet; i++)\n\t\t{\n\t\t\twlan_guest_ap_flt_rule_hdl_v4[i] = pFilteringTable->rules[i].rule_hdl;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif(IPACM_Wan::wan_up_v6 == true)\n\t\t{\n\t\t\teth_bridge_install_wlan_guest_ap_ipv6_flt_rule();\n\t\t}\n\t}\nfail:\n\tif(pFilteringTable != NULL)\n\t{\n\t\tfree(pFilteringTable);\n\t}\n\treturn res;\n}\n\nint IPACM_Wlan::eth_bridge_install_wlan_guest_ap_ipv6_flt_rule()\n{\n\tif(rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"There is no rx_prop for iface %s, not able to add wlan guest ap filtering rule.\\n\", dev_name);\n\t\treturn IPACM_SUCCESS;\n\t}\n\tif(is_guest_ap == false)\n\t{\n\t\tIPACMDBG_H(\"This is not WLAN guest AP, do nothing.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\n\tint len, offset, res = IPACM_SUCCESS;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable = NULL;\n\n\tif(IPACM_Wlan::dummy_flt_rule_hdl_v6 == NULL)\n\t{\n\t\tIPACMERR(\"Dummy ipv6 flt rule has not been installed.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\toffset = 0;\n\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);\n\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\tif (!pFilteringTable)\n\t{\n\t\tIPACMERR(\"Failed to allocate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ip = IPA_IP_v6;\n\tpFilteringTable->num_rules = 1;\n\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\tflt_rule.status = -1;\n\n\tflt_rule.rule.retain_hdr = 1;\n\tflt_rule.rule.to_uc = 0;\n\tflt_rule.rule.action = IPA_PASS_TO_EXCEPTION;\n\tflt_rule.rule.eq_attrib_type = 0;\n\n\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\tflt_rule.rule.attrib.u.v6.dst_addr[0] = IPACM_Wan::backhaul_ipv6_prefix[0];\n\tflt_rule.rule.attrib.u.v6.dst_addr[1] = IPACM_Wan::backhaul_ipv6_prefix[1];\n\tflt_rule.rule.attrib.u.v6.dst_addr[2] = 0x0;\n\tflt_rule.rule.attrib.u.v6.dst_addr[3] = 0x0;\n\tflt_rule.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;\n\tflt_rule.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;\n\tflt_rule.rule.attrib.u.v6.dst_addr_mask[2] = 0x0;\n\tflt_rule.rule.attrib.u.v6.dst_addr_mask[3] = 0x0;\n\n\tflt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset];\n\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\n\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t{\n\t\tIPACMERR(\"Failed to modify wlan guest AP IPv6 filtering rules.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\t/* copy filter rule hdls */\n\twlan_guest_ap_flt_rule_hdl_v6 = pFilteringTable->rules[0].rule_hdl;\n\nfail:\n\tif(pFilteringTable != NULL)\n\t{\n\t\tfree(pFilteringTable);\n\t}\n\treturn res;\n}\n\nint IPACM_Wlan::eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype)\n{\n\tint i, offset;\n\tif(wlan_ap_index == 0)\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\toffset = IPV4_DEFAULT_FILTERTING_RULES + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;\n\t\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t\t{\n\t\t\t\tself_client_flt_rule_hdl_v4[i].rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+i];\n\t\t\t\tself_client_flt_rule_hdl_v4[i].valid = true;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\toffset = 1;\n\t\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t\t{\n\t\t\t\tself_client_flt_rule_hdl_v6[i].rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+i];\n\t\t\t\tself_client_flt_rule_hdl_v6[i].valid = true;\n\t\t\t}\n\t\t}\n\t\tIPACMDBG_H(\"Get %d flt rule hdls for wlan clients ip type: %d.\\n\", IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, iptype);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wlan::eth_bridge_handle_dummy_usb_client_flt_rule(ipa_ip_type iptype)\n{\n\tint i, offset;\n\tif(wlan_ap_index == 0)\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\toffset = IPV4_DEFAULT_FILTERTING_RULES + IPACM_Iface::ipacmcfg->ipa_num_private_subnet + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT;\n\t\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_USB_CLIENT; i++)\n\t\t\t{\n\t\t\t\tusb_client_flt_rule_hdl_v4[i].rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+i];\n\t\t\t\tusb_client_flt_rule_hdl_v4[i].valid = true;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\toffset = 1 + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT;\n\t\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_USB_CLIENT; i++)\n\t\t\t{\n\t\t\t\tusb_client_flt_rule_hdl_v6[i].rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+i];\n\t\t\t\tusb_client_flt_rule_hdl_v6[i].valid = true;\n\t\t\t}\n\t\t}\n\t\tIPACMDBG_H(\"Get %d flt rule hdls for usb clients ip type: %d.\\n\", IPA_LAN_TO_LAN_MAX_USB_CLIENT, iptype);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wlan::eth_bridge_add_usb_client_flt_rule(uint8_t* mac, ipa_ip_type iptype)\n{\n\tint i, len, res = IPACM_SUCCESS, client_position;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable = NULL;\n\tbool client_is_found = false;\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == false)\n\t{\n\t\tIPACMDBG_H(\"WLAN to USB hdr proc ctx has not been set, don't add USB client specific flt rule.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tfor(i=0; i<num_usb_client; i++)\n\t{\n\t\tif(memcmp(eth_bridge_usb_client_flt_info[i].mac, mac, sizeof(eth_bridge_usb_client_flt_info[i].mac)) == 0)\n\t\t{\n\t\t\tclient_is_found = true;\n\t\t\tclient_position = i;\n\t\t\tif( (iptype == IPA_IP_v4 && eth_bridge_usb_client_flt_info[i].flt_rule_set_v4 == true)\n\t\t\t\t|| (iptype == IPA_IP_v6 && eth_bridge_usb_client_flt_info[i].flt_rule_set_v6 == true))\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Flt rule for iptype %d has been set.\\n\", iptype);\n\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(client_is_found == false && num_usb_client == IPA_LAN_TO_LAN_MAX_USB_CLIENT)\n\t{\n\t\tIPACMDBG_H(\"The usb client flt table is already full.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);\n\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\tif (!pFilteringTable)\n\t{\n\t\tIPACMERR(\"Failed to allocate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tIPACMDBG_H(\"Receive USB client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\t/* add mac based rule on flt table */\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = 1;\n\n\t/* point to USB-WLAN routing table */\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\tflt_rule.status = -1;\n\n\tflt_rule.rule.retain_hdr = 0;\n\tflt_rule.rule.to_uc = 0;\n\tflt_rule.rule.action = IPA_PASS_TO_ROUTING;\n\tflt_rule.rule.eq_attrib_type = 0;\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v4))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v4.hdl;\n\t\tIPACMDBG_H(\"WLAN->USB IPv4 filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v4.name);\n\t}\n\telse\n\t{\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v6))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v6.hdl;\n\t\tIPACMDBG_H(\"WLAN->USB IPv6 filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v6.name);\n\t}\n\n\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n\tif(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_ETHERNET_II)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;\n\t}\n\telse if(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_802_3)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"WLAN hdr type is not expected.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\tmemcpy(flt_rule.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule.rule.attrib.dst_mac_addr));\n\tmemset(flt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule.rule.attrib.dst_mac_addr_mask));\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_USB_CLIENT; i++)\n\t\t{\n\t\t\tif(usb_client_flt_rule_hdl_v4[i].valid == true)\n\t\t\t{\n\t\t\t\tflt_rule.rule_hdl = usb_client_flt_rule_hdl_v4[i].rule_hdl;\n\t\t\t\tusb_client_flt_rule_hdl_v4[i].valid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == IPA_LAN_TO_LAN_MAX_USB_CLIENT)\n\t\t{\n\t\t\tIPACMDBG_H(\"Cannot find a valid flt rule hdl.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_USB_CLIENT; i++)\n\t\t{\n\t\t\tif(usb_client_flt_rule_hdl_v6[i].valid == true)\n\t\t\t{\n\t\t\t\tflt_rule.rule_hdl = usb_client_flt_rule_hdl_v6[i].rule_hdl;\n\t\t\t\tusb_client_flt_rule_hdl_v6[i].valid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == IPA_LAN_TO_LAN_MAX_USB_CLIENT)\n\t\t{\n\t\t\tIPACMDBG_H(\"Cannot find a valid flt rule hdl.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t{\n\t\tIPACMERR(\"Failed to add wlan client filtering rules.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tif(client_is_found == false)\n\t{\n\t\tclient_position = num_usb_client;\n\t\tnum_usb_client++;\n\t}\n\n\tmemcpy(eth_bridge_usb_client_flt_info[client_position].mac, mac, sizeof(eth_bridge_usb_client_flt_info[client_position].mac));\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\teth_bridge_usb_client_flt_info[client_position].flt_rule_set_v4 = true;\n\t\teth_bridge_usb_client_flt_info[client_position].flt_rule_hdl_v4 = usb_client_flt_rule_hdl_v4[i].rule_hdl;\n\t}\n\telse\n\t{\n\t\teth_bridge_usb_client_flt_info[client_position].flt_rule_set_v6 = true;\n\t\teth_bridge_usb_client_flt_info[client_position].flt_rule_hdl_v6 = usb_client_flt_rule_hdl_v6[i].rule_hdl;\n\t}\n\nfail:\n\tif(pFilteringTable == NULL)\n\t{\n\t\tfree(pFilteringTable);\n\t}\n\treturn res;\n}\n\nint IPACM_Wlan::eth_bridge_del_usb_client_flt_rule(uint8_t* mac)\n{\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Client MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Receive USB client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\tint i, j, res = IPACM_SUCCESS;\n\tfor(i=0; i<num_usb_client; i++)\n\t{\n\t\tif(memcmp(eth_bridge_usb_client_flt_info[i].mac, mac, sizeof(eth_bridge_usb_client_flt_info[i].mac)) == 0)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(i == num_usb_client)\n\t{\n\t\tIPACMERR(\"Do not find the usb client.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(eth_bridge_usb_client_flt_info[i].flt_rule_set_v4 == true)\n\t{\n\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, eth_bridge_usb_client_flt_info[i].flt_rule_hdl_v4) == IPACM_SUCCESS)\n\t\t{\n\t\t\tfor(j=0; j<IPA_LAN_TO_LAN_MAX_USB_CLIENT; j++)\n\t\t\t{\n\t\t\t\tif(usb_client_flt_rule_hdl_v4[j].rule_hdl == eth_bridge_usb_client_flt_info[i].flt_rule_hdl_v4)\n\t\t\t\t{\n\t\t\t\t\tusb_client_flt_rule_hdl_v4[j].valid = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(j == IPA_LAN_TO_LAN_MAX_USB_CLIENT)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Not finding the rule handle in handle pool.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete the usb client specific flt rule.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\tif(eth_bridge_usb_client_flt_info[i].flt_rule_set_v6 == true)\n\t{\n\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, eth_bridge_usb_client_flt_info[i].flt_rule_hdl_v6) == IPACM_SUCCESS)\n\t\t{\n\t\t\tfor(j=0; j<IPA_LAN_TO_LAN_MAX_USB_CLIENT; j++)\n\t\t\t{\n\t\t\t\tif(usb_client_flt_rule_hdl_v6[j].rule_hdl == eth_bridge_usb_client_flt_info[i].flt_rule_hdl_v6)\n\t\t\t\t{\n\t\t\t\t\tusb_client_flt_rule_hdl_v6[j].valid = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(j == IPA_LAN_TO_LAN_MAX_USB_CLIENT)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Not finding the rule handle in handle pool.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete the usb client specific flt rule.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tfor(j=i+1; j<num_usb_client; j++)\n\t{\n\t\tmemcpy(&(eth_bridge_usb_client_flt_info[j-1]), &(eth_bridge_usb_client_flt_info[j]), sizeof(eth_bridge_client_flt_info));\n\t}\n\tmemset(&(eth_bridge_usb_client_flt_info[num_usb_client-1]), 0, sizeof(eth_bridge_client_flt_info));\n\tnum_usb_client--;\n\n\treturn res;\n}\n\nint IPACM_Wlan::eth_bridge_add_self_client_flt_rule(uint8_t* mac, ipa_ip_type iptype)\n{\n\tint i, len, res = IPACM_SUCCESS, client_position;\n\tstruct ipa_flt_rule_mdfy flt_rule;\n\tstruct ipa_ioc_mdfy_flt_rule* pFilteringTable = NULL;\n\tbool client_is_found = false;\n\n\tif (rx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"No rx properties registered for iface %s\\n\", dev_name);\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == false)\n\t{\n\t\tIPACMDBG_H(\"WLAN to WLAN hdr proc ctx has not been set, don't add WLAN client specific flt rule.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tfor(i=0; i<wlan_client_flt_info_count; i++)\n\t{\n\t\tif(memcmp(eth_bridge_wlan_client_flt_info[i].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[i].mac)) == 0)\n\t\t{\n\t\t\tclient_is_found = true;\n\t\t\tclient_position = i;\n\t\t\tif( (iptype == IPA_IP_v4 && eth_bridge_wlan_client_flt_info[i].flt_rule_set_v4 == true)\n\t\t\t\t|| (iptype == IPA_IP_v6 && eth_bridge_wlan_client_flt_info[i].flt_rule_set_v6 == true))\n\t\t\t{\n\t\t\t\tIPACMDBG_H(\"Flt rule for iptype %d has been set.\\n\", iptype);\n\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(client_is_found == false && wlan_client_flt_info_count == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t{\n\t\tIPACMDBG_H(\"The wlan client flt table is already full.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tlen = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);\n\tpFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);\n\tif (!pFilteringTable)\n\t{\n\t\tIPACMERR(\"Failed to allocate ipa_ioc_mdfy_flt_rule memory...\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(pFilteringTable, 0, len);\n\n\tIPACMDBG_H(\"Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\t/* add mac based rule on IPv4 table */\n\tpFilteringTable->commit = 1;\n\tpFilteringTable->ip = iptype;\n\tpFilteringTable->num_rules = 1;\n\n\t/* point to USB-WLAN routing table */\n\tmemset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));\n\tflt_rule.status = -1;\n\n\tflt_rule.rule.retain_hdr = 0;\n\tflt_rule.rule.to_uc = 0;\n\tflt_rule.rule.action = IPA_PASS_TO_ROUTING;\n\tflt_rule.rule.eq_attrib_type = 0;\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v4))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v4.hdl;\n\t\tIPACMDBG_H(\"WLAN->WLAN IPv4 filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v4.name);\n\t}\n\telse\n\t{\n\t\tif (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v6))\n\t\t{\n\t\t\tIPACMERR(\"Failed to get routing table handle.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tflt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v6.hdl;\n\t\tIPACMDBG_H(\"WLAN->WLAN IPv4 filter rule use table: %s\\n\",IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v6.name);\n\t}\n\n\tmemcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));\n\tflt_rule.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);\t//remove meta data mask\n\tif(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_ETHERNET_II)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;\n\t}\n\telse if(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_802_3)\n\t{\n\t\tflt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;\n\t}\n\telse\n\t{\n\t\tIPACMERR(\"WLAN hdr type is not expected.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\tmemcpy(flt_rule.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule.rule.attrib.dst_mac_addr));\n\tmemset(flt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule.rule.attrib.dst_mac_addr_mask));\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t{\n\t\t\tif(self_client_flt_rule_hdl_v4[i].valid == true)\n\t\t\t{\n\t\t\t\tflt_rule.rule_hdl = self_client_flt_rule_hdl_v4[i].rule_hdl;\n\t\t\t\tself_client_flt_rule_hdl_v4[i].valid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t{\n\t\t\tIPACMDBG_H(\"Cannot find a valid flt rule hdl.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)\n\t\t{\n\t\t\tif(self_client_flt_rule_hdl_v6[i].valid == true)\n\t\t\t{\n\t\t\t\tflt_rule.rule_hdl = self_client_flt_rule_hdl_v6[i].rule_hdl;\n\t\t\t\tself_client_flt_rule_hdl_v6[i].valid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t{\n\t\t\tIPACMDBG_H(\"Cannot find a valid flt rule hdl.\\n\");\n\t\t\tres = IPACM_FAILURE;\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\tmemcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));\n\tif (false == m_filtering.ModifyFilteringRule(pFilteringTable))\n\t{\n\t\tIPACMERR(\"Failed to add self client filtering rules.\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\n\tif(client_is_found == false)\n\t{\n\t\tclient_position = wlan_client_flt_info_count;\n\t\twlan_client_flt_info_count++;\n\t}\n\n\tmemcpy(eth_bridge_wlan_client_flt_info[client_position].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[client_position].mac));\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\teth_bridge_wlan_client_flt_info[client_position].flt_rule_set_v4 = true;\n\t\teth_bridge_wlan_client_flt_info[client_position].flt_rule_hdl_v4 = self_client_flt_rule_hdl_v4[i].rule_hdl;\n\t}\n\telse\n\t{\n\t\teth_bridge_wlan_client_flt_info[client_position].flt_rule_set_v6 = true;\n\t\teth_bridge_wlan_client_flt_info[client_position].flt_rule_hdl_v6 = self_client_flt_rule_hdl_v6[i].rule_hdl;\n\t}\n\nfail:\n\tif(pFilteringTable == NULL)\n\t{\n\t\tfree(pFilteringTable);\n\t}\n\treturn res;\n}\n\nint IPACM_Wlan::eth_bridge_del_self_client_flt_rule(uint8_t* mac)\n{\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Client MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\tint i, j, res = IPACM_SUCCESS;\n\tfor(i=0; i<wlan_client_flt_info_count; i++)\n\t{\n\t\tif(memcmp(eth_bridge_wlan_client_flt_info[i].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[i].mac)) == 0)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(i == wlan_client_flt_info_count)\n\t{\n\t\tIPACMERR(\"Do not find the wlan client.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tif(eth_bridge_wlan_client_flt_info[i].flt_rule_set_v4 == true)\n\t{\n\t\tif(reset_to_dummy_flt_rule(IPA_IP_v4, eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v4) == IPACM_SUCCESS)\n\t\t{\n\t\t\tfor(j=0; j<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; j++)\n\t\t\t{\n\t\t\t\tif(self_client_flt_rule_hdl_v4[j].rule_hdl == eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v4)\n\t\t\t\t{\n\t\t\t\t\tself_client_flt_rule_hdl_v4[j].valid = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(j == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Not finding the rule handle in handle pool.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete the wlan client specific flt rule.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\tif(eth_bridge_wlan_client_flt_info[i].flt_rule_set_v6 == true)\n\t{\n\t\tif(reset_to_dummy_flt_rule(IPA_IP_v6, eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v6) == IPACM_SUCCESS)\n\t\t{\n\t\t\tfor(j=0; j<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; j++)\n\t\t\t{\n\t\t\t\tif(self_client_flt_rule_hdl_v6[j].rule_hdl == eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v6)\n\t\t\t\t{\n\t\t\t\t\tself_client_flt_rule_hdl_v6[j].valid = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(j == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Not finding the rule handle in handle pool.\\n\");\n\t\t\t\treturn IPACM_FAILURE;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete the wlan client specific flt rule.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tfor(j=i+1; j<wlan_client_flt_info_count; j++)\n\t{\n\t\tmemcpy(&(eth_bridge_wlan_client_flt_info[j-1]), &(eth_bridge_wlan_client_flt_info[j]), sizeof(eth_bridge_client_flt_info));\n\t}\n\tmemset(&(eth_bridge_wlan_client_flt_info[wlan_client_flt_info_count-1]), 0, sizeof(eth_bridge_client_flt_info));\n\twlan_client_flt_info_count--;\n\n\treturn res;\n}\n\nint IPACM_Wlan::eth_bridge_install_cache_usb_client_flt_rule(ipa_ip_type iptype)\n{\n\tint i;\n\n\tIPACMDBG_H(\"There are %d usb clients cached.\\n\", IPACM_Lan::num_usb_client);\n\tfor(i=0; i<IPACM_Lan::num_usb_client; i++)\n\t{\n\t\teth_bridge_add_usb_client_flt_rule(IPACM_Lan::eth_bridge_usb_client[i].mac, iptype);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wlan::eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype)\n{\n\tint i;\n\n\tIPACMDBG_H(\"There are %d wlan clients cached.\\n\", IPACM_Lan::num_wlan_client);\n\tfor(i=0; i<IPACM_Lan::num_wlan_client; i++)\n\t{\n\t\teth_bridge_add_self_client_flt_rule(IPACM_Lan::eth_bridge_wlan_client[i].mac, iptype);\n\t}\n\treturn IPACM_SUCCESS;\n}\n\nint IPACM_Wlan::eth_bridge_add_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype)\n{\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"Tx prop is empty, not adding routing rule.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Client MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tif( (src == SRC_WLAN && wlan_client_rt_from_wlan_info_count_v4 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t\t|| (src == SRC_USB && wlan_client_rt_from_usb_info_count_v4 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT))\n\t\t{\n\t\t\tIPACMDBG_H(\"WLAN client number has reached maximum.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif( (src == SRC_WLAN && wlan_client_rt_from_wlan_info_count_v6 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t\t\t|| (src == SRC_USB && wlan_client_rt_from_usb_info_count_v6 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT))\n\t\t{\n\t\t\tIPACMDBG_H(\"WLAN client number has reached maximum.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\tif( (src == SRC_WLAN && IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == false)\n\t\t|| (src == SRC_USB && IPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid == false) )\n\t{\n\t\tIPACMDBG_H(\"Hdr proc ctx has not been set for source %d, don't add WLAN client routing rule.\\n\", src);\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\tint i, len, res = IPACM_SUCCESS;\n\tstruct ipa_ioc_add_rt_rule* rt_rule_table = NULL;\n\tstruct ipa_rt_rule_add rt_rule;\n\tint position, num_rt_rule;\n\n\tif(src == SRC_WLAN)\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tfor(i=0; i<wlan_client_rt_from_wlan_info_count_v4; i++)\n\t\t\t{\n\t\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, SRC_WLAN, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, SRC_WLAN, iptype)->mac)) == 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"The client's routing rule was added before.\\n\");\n\t\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v4, src, iptype)->mac, mac,\n\t\t\t\t\tsizeof(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v4, src, iptype)->mac));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(i=0; i<wlan_client_rt_from_wlan_info_count_v6; i++)\n\t\t\t{\n\t\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, SRC_WLAN, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, SRC_WLAN, iptype)->mac)) == 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"The client's routing rule was added before.\\n\");\n\t\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v6, src, iptype)->mac, mac,\n\t\t\t\t\tsizeof(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v6, src, iptype)->mac));\n\t\t}\n\t}\n\telse\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tfor(i=0; i<wlan_client_rt_from_usb_info_count_v4; i++)\n\t\t\t{\n\t\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, SRC_USB, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, SRC_USB, iptype)->mac)) == 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"The client's routing rule was added before.\\n\");\n\t\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_usb_info_count_v4, src, iptype)->mac, mac,\n\t\t\t\t\tsizeof(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_usb_info_count_v4, src, iptype)->mac));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(i=0; i<wlan_client_rt_from_usb_info_count_v6; i++)\n\t\t\t{\n\t\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, SRC_USB, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, SRC_USB, iptype)->mac)) == 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG_H(\"The client's routing rule was added before.\\n\");\n\t\t\t\t\treturn IPACM_SUCCESS;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_usb_info_count_v6, src, iptype)->mac, mac,\n\t\t\t\t\tsizeof(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_usb_info_count_v6, src, iptype)->mac));\n\t\t}\n\t}\n\n\tif(iptype == IPA_IP_v4)\n\t{\n\t\tnum_rt_rule = each_client_rt_rule_count_v4;\n\t}\n\telse\n\t{\n\t\tnum_rt_rule = each_client_rt_rule_count_v6;\n\t}\n\n\tlen = sizeof(ipa_ioc_add_rt_rule) + num_rt_rule * sizeof(ipa_rt_rule_add);\n\trt_rule_table = (ipa_ioc_add_rt_rule*)malloc(len);\n\tif(rt_rule_table == NULL)\n\t{\n\t\tIPACMERR(\"Failed to allocate memory.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\tmemset(rt_rule_table, 0, len);\n\n\trt_rule_table->commit = 1;\n\trt_rule_table->ip = iptype;\n\trt_rule_table->num_rules = num_rt_rule;\n\tif(src == SRC_WLAN)\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tstrncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tstrncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));\n\t\t}\n\t}\n\telse\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tstrncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tstrncpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_usb_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));\n\t\t}\n\t}\n\n\tmemset(&rt_rule, 0, sizeof(ipa_rt_rule_add));\n\trt_rule.at_rear = false;\n\trt_rule.status = -1;\n\trt_rule.rt_rule_hdl = -1;\n\n\trt_rule.rule.hdr_hdl = 0;\n\tif(src == SRC_WLAN)\n\t{\n\t\trt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl;\n\t}\n\telse\n\t{\n\t\trt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::usb_to_wlan_hdr_proc_ctx.proc_ctx_hdl;\n\t}\n\tposition = 0;\n\tfor(i=0; i<iface_query->num_tx_props; i++)\n\t{\n\t\tif(tx_prop->tx[i].ip == iptype)\n\t\t{\n\t\t\tif(position >= num_rt_rule)\n\t\t\t{\n\t\t\t\tIPACMERR(\"Number of routing rules already exceeds limit.\\n\");\n\t\t\t\tres = IPACM_FAILURE;\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\trt_rule.rule.dst = tx_prop->tx[i].dst_pipe;\n\t\t\tmemcpy(&rt_rule.rule.attrib, &tx_prop->tx[i].attrib, sizeof(rt_rule.rule.attrib));\n\t\t\tif(src == SRC_WLAN)\t//src is WLAN means packet is from WLAN\n\t\t\t{\n\t\t\t\tif(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_ETHERNET_II)\n\t\t\t\t{\n\t\t\t\t\trt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\trt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\t//packet is from USB\n\t\t\t{\n\t\t\t\tif(IPACM_Lan::usb_hdr_type == IPA_HDR_L2_ETHERNET_II)\n\t\t\t\t{\n\t\t\t\t\trt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\trt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemcpy(rt_rule.rule.attrib.dst_mac_addr, mac, sizeof(rt_rule.rule.attrib.dst_mac_addr));\n\t\t\tmemset(rt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(rt_rule.rule.attrib.dst_mac_addr_mask));\n\n\t\t\tmemcpy(&(rt_rule_table->rules[position]), &rt_rule, sizeof(rt_rule_table->rules[position]));\n\t\t\tposition++;\n\t\t}\n\t}\n\n\tif(false == m_routing.AddRoutingRule(rt_rule_table))\n\t{\n\t\tIPACMERR(\"Routing rule addition failed!\\n\");\n\t\tres = IPACM_FAILURE;\n\t\tgoto fail;\n\t}\n\telse\n\t{\n\t\tif(src == SRC_WLAN)\n\t\t{\n\t\t\tfor(i=0; i<num_rt_rule; i++)\n\t\t\t{\n\t\t\t\tif(iptype == IPA_IP_v4)\n\t\t\t\t{\n\t\t\t\t\teth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v4, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\teth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v6, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(iptype == IPA_IP_v4)\n\t\t\t{\n\t\t\t\twlan_client_rt_from_wlan_info_count_v4++;\n\t\t\t\tIPACMDBG_H(\"Now the number of IPv4 rt rule on wlan-wlan rt table is %d.\\n\", wlan_client_rt_from_wlan_info_count_v4);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\twlan_client_rt_from_wlan_info_count_v6++;\n\t\t\t\tIPACMDBG_H(\"Now the number of IPv6 rt rule on wlan-wlan rt table is %d.\\n\", wlan_client_rt_from_wlan_info_count_v6);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(i=0; i<num_rt_rule; i++)\n\t\t\t{\n\t\t\t\tif(iptype == IPA_IP_v4)\n\t\t\t\t{\n\t\t\t\t\teth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_usb_info_count_v4, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\teth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_usb_info_count_v6, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(iptype == IPA_IP_v4)\n\t\t\t{\n\t\t\t\twlan_client_rt_from_usb_info_count_v4++;\n\t\t\t\tIPACMDBG_H(\"Now the number of IPv4 rt rule on usb-wlan rt table is %d.\\n\", wlan_client_rt_from_usb_info_count_v4);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\twlan_client_rt_from_usb_info_count_v6++;\n\t\t\t\tIPACMDBG_H(\"Now the number of IPv6 rt rule on usb-wlan rt table is %d.\\n\", wlan_client_rt_from_usb_info_count_v6);\n\t\t\t}\n\t\t}\n\t}\n\nfail:\n\tif(rt_rule_table != NULL)\n\t{\n\t\tfree(rt_rule_table);\n\t}\n\treturn res;\n}\n\nint IPACM_Wlan::eth_bridge_del_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src)\n{\n\tif(tx_prop == NULL)\n\t{\n\t\tIPACMDBG_H(\"Tx prop is empty, not deleting routing rule.\\n\");\n\t\treturn IPACM_SUCCESS;\n\t}\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Client MAC address is empty.\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\tIPACMDBG_H(\"Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\\n\", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);\n\n\tint i, position;\n\n\t/* first delete the rt rules from IPv4 rt table*/\n\tif(src == SRC_WLAN)\n\t{\n\t\tfor(i=0; i<wlan_client_rt_from_wlan_info_count_v4; i++)\n\t\t{\n\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac)) == 0)\n\t\t\t{\n\t\t\t\tposition = i;\n\t\t\t\tIPACMDBG_H(\"The client is found at position %d.\\n\", position);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == wlan_client_rt_from_wlan_info_count_v4)\n\t\t{\n\t\t\tIPACMERR(\"The client is not found.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(i=0; i<wlan_client_rt_from_usb_info_count_v4; i++)\n\t\t{\n\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac)) == 0)\n\t\t\t{\n\t\t\t\tposition = i;\n\t\t\t\tIPACMDBG_H(\"The client is found at position %d.\\n\", position);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == wlan_client_rt_from_usb_info_count_v4)\n\t\t{\n\t\t\tIPACMERR(\"The client is not found.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tfor(i=0; i<each_client_rt_rule_count_v4; i++)\n\t{\n\t\tif(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, src, IPA_IP_v4)->rt_rule_hdl[i], IPA_IP_v4) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete routing rule %d.\\n\", i);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tif(src == SRC_WLAN)\n\t{\n\t\tfor(i=position+1; i<wlan_client_rt_from_wlan_info_count_v4; i++)\n\t\t{\n\t\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4), client_rt_info_size_v4);\n\t\t}\n\t\tmemset(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v4-1, src, IPA_IP_v4), 0, client_rt_info_size_v4);\n\t\twlan_client_rt_from_wlan_info_count_v4--;\n\t\tIPACMDBG_H(\"Now the number of IPv4 rt rule from wlan info is %d.\\n\", wlan_client_rt_from_wlan_info_count_v4);\n\t}\n\telse\n\t{\n\t\tfor(i=position+1; i<wlan_client_rt_from_usb_info_count_v4; i++)\n\t\t{\n\t\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4), client_rt_info_size_v4);\n\t\t}\n\t\tmemset(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_usb_info_count_v4-1, src, IPA_IP_v4), 0, client_rt_info_size_v4);\n\t\twlan_client_rt_from_usb_info_count_v4--;\n\t\tIPACMDBG_H(\"Now the number of IPv4 rt rule from usb info is %d.\\n\", wlan_client_rt_from_usb_info_count_v4);\n\t}\n\n\t/*delete rt rules from IPv6 rt table */\n\tif(src == SRC_WLAN)\n\t{\n\t\tfor(i=0; i<wlan_client_rt_from_wlan_info_count_v6; i++)\n\t\t{\n\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac)) == 0)\n\t\t\t{\n\t\t\t\tposition = i;\n\t\t\t\tIPACMDBG_H(\"The client is found at position %d.\\n\", position);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == wlan_client_rt_from_wlan_info_count_v6)\n\t\t{\n\t\t\tIPACMERR(\"The client is not found.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(i=0; i<wlan_client_rt_from_usb_info_count_v6; i++)\n\t\t{\n\t\t\tif(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac)) == 0)\n\t\t\t{\n\t\t\t\tposition = i;\n\t\t\t\tIPACMDBG_H(\"The client is found at position %d.\\n\", position);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(i == wlan_client_rt_from_usb_info_count_v6)\n\t\t{\n\t\t\tIPACMERR(\"The client is not found.\\n\");\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tfor(i=0; i<each_client_rt_rule_count_v6; i++)\n\t{\n\t\tif(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, src, IPA_IP_v6)->rt_rule_hdl[i], IPA_IP_v6) == false)\n\t\t{\n\t\t\tIPACMERR(\"Failed to delete routing rule %d.\\n\", i);\n\t\t\treturn IPACM_FAILURE;\n\t\t}\n\t}\n\n\tif(src == SRC_WLAN)\n\t{\n\t\tfor(i=position+1; i<wlan_client_rt_from_wlan_info_count_v6; i++)\n\t\t{\n\t\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6), client_rt_info_size_v6);\n\t\t}\n\t\tmemset(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v6-1, src, IPA_IP_v6), 0, client_rt_info_size_v6);\n\t\twlan_client_rt_from_wlan_info_count_v6--;\n\t\tIPACMDBG_H(\"Now the number of IPv6 rt rule from wlan info is %d.\\n\", wlan_client_rt_from_wlan_info_count_v6);\n\t}\n\telse\n\t{\n\t\tfor(i=position+1; i<wlan_client_rt_from_usb_info_count_v6; i++)\n\t\t{\n\t\t\tmemcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6), client_rt_info_size_v6);\n\t\t}\n\t\tmemset(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_usb_info_count_v6-1, src, IPA_IP_v6), 0, client_rt_info_size_v6);\n\t\twlan_client_rt_from_usb_info_count_v6--;\n\t\tIPACMDBG_H(\"Now the number of IPv6 rt rule from usb info is %d.\\n\", wlan_client_rt_from_usb_info_count_v6);\n\t}\n\n\treturn IPACM_SUCCESS;\n}\n\neth_bridge_client_rt_info* IPACM_Wlan::eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype)\n{\n\tvoid* result;\n\tif(src == SRC_WLAN)\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tresult = (void*)((char*)eth_bridge_wlan_client_rt_from_wlan_info_v4 + index * client_rt_info_size_v4);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult = (void*)((char*)eth_bridge_wlan_client_rt_from_wlan_info_v6 + index * client_rt_info_size_v6);\n\t\t}\n\t}\n\telse\n\t{\n\t\tif(iptype == IPA_IP_v4)\n\t\t{\n\t\t\tresult = (void*)((char*)eth_bridge_wlan_client_rt_from_usb_info_v4 + index * client_rt_info_size_v4);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult = (void*)((char*)eth_bridge_wlan_client_rt_from_usb_info_v6 + index * client_rt_info_size_v6);\n\t\t}\n\t}\n\treturn (eth_bridge_client_rt_info*)result;\n}\n\nvoid IPACM_Wlan::eth_bridge_add_wlan_client(uint8_t* mac, int if_num)\n{\n\tif(IPACM_Lan::num_wlan_client == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)\n\t{\n\t\tIPACMDBG_H(\"WLAN client table is already full.\\n\");\n\t\treturn;\n\t}\n\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Mac address is empty.\\n\");\n\t\treturn;\n\t}\n\n\tmemcpy(IPACM_Lan::eth_bridge_wlan_client[IPACM_Lan::num_wlan_client].mac, mac, sizeof(IPACM_Lan::eth_bridge_wlan_client[IPACM_Lan::num_wlan_client].mac));\n\tIPACM_Lan::eth_bridge_wlan_client[IPACM_Lan::num_wlan_client].ipa_if_num = if_num;\n\tIPACM_Lan::num_wlan_client++;\n\treturn;\n}\n\nvoid IPACM_Wlan::eth_bridge_del_wlan_client(uint8_t* mac)\n{\n\tif(mac == NULL)\n\t{\n\t\tIPACMERR(\"Mac address is empty.\\n\");\n\t\treturn;\n\t}\n\n\tint i, j;\n\tfor(i=0; i<IPACM_Lan::num_wlan_client; i++)\n\t{\n\t\tif(memcmp(IPACM_Lan::eth_bridge_wlan_client[i].mac, mac, sizeof(IPACM_Lan::eth_bridge_wlan_client[i].mac)) == 0)\n\t\t{\n\t\t\tIPACMDBG_H(\"Found WLAN client at position %d.\\n\", i);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(i == IPACM_Lan::num_wlan_client)\n\t{\n\t\tIPACMDBG_H(\"Not finding the WLAN client.\\n\");\n\t\treturn;\n\t}\n\n\tfor(j=i+1; j<IPACM_Lan::num_wlan_client; j++)\n\t{\n\t\tmemcpy(IPACM_Lan::eth_bridge_wlan_client[j-1].mac, IPACM_Lan::eth_bridge_wlan_client[j].mac, sizeof(IPACM_Lan::eth_bridge_wlan_client[j].mac));\n\t\tIPACM_Lan::eth_bridge_wlan_client[j-1].ipa_if_num = IPACM_Lan::eth_bridge_wlan_client[j].ipa_if_num;\n\t}\n\tIPACM_Lan::num_wlan_client--;\n\treturn;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_Xml.cpp",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n * Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\n   copyright notice, this list of conditions and the following\n   disclaimer in the documentation and/or other materials provided\n   with the distribution.\n * Neither the name of The Linux Foundation nor the names of its\n   contributors may be used to endorse or promote products derived\n   from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n  @file\n   IPACM_Xml.cpp\n\n  @brief\n   This file implements the XML specific parsing functionality.\n\n  @Author\n   Skylar Chang/Shihuan Liu\n*/\n\n#include <sys/socket.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n\n#include \"IPACM_Xml.h\"\n#include \"IPACM_Log.h\"\n#include \"IPACM_Netlink.h\"\n\nstatic char* IPACM_read_content_element\n(\n\t xmlNode* element\n);\n\nstatic int32_t IPACM_util_icmp_string\n(\n\t const char* xml_str,\n\t const char* str\n);\n\nstatic int ipacm_cfg_xml_parse_tree\n(\n\t xmlNode* xml_node,\n\t IPACM_conf_t *config\n);\n\nstatic int IPACM_firewall_xml_parse_tree\n(\n\t xmlNode* xml_node,\n\t IPACM_firewall_conf_t *config\n);\n\n/*Reads content (stored as child) of the element */\nstatic char* IPACM_read_content_element\n(\n\t xmlNode* element\n)\n{\n\txmlNode* child_ptr;\n\n\tfor (child_ptr  = element->children;\n\t\t\t child_ptr != NULL;\n\t\t\t child_ptr  = child_ptr->next)\n\t{\n\t\tif (child_ptr->type == XML_TEXT_NODE)\n\t\t{\n\t\t\treturn (char*)child_ptr->content;\n\t\t}\n\t}\n\treturn NULL;\n}\n\n/* insensitive comparison of a libxml's string (xml_str) and a regular string (str)*/\nstatic int32_t IPACM_util_icmp_string\n(\n\t const char* xml_str,\n\t const char* str\n)\n{\n\tint32_t ret = -1;\n\n\tif (NULL != xml_str && NULL != str)\n\t{\n\t\tuint32_t len1 = strlen(str);\n\t\tuint32_t len2 = strlen(xml_str);\n\t\t/* If the lengths match, do the string comparison */\n\t\tif (len1 == len2)\n\t\t{\n\t\t\tret = strncasecmp(xml_str, str, len1);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\n/* This function read IPACM XML and populate the IPA CM Cfg */\nint ipacm_read_cfg_xml(char *xml_file, IPACM_conf_t *config)\n{\n\txmlDocPtr doc = NULL;\n\txmlNode* root = NULL;\n\tint ret_val = IPACM_SUCCESS;\n\n\t/* Invoke the XML parser and obtain the parse tree */\n\tdoc = xmlReadFile(xml_file, \"UTF-8\", XML_PARSE_NOBLANKS);\n\tif (doc == NULL) {\n\t\tIPACMDBG_H(\"IPACM_xml_parse: libxml returned parse error!\\n\");\n\t\treturn IPACM_FAILURE;\n\t}\n\n\t/*Get the root of the tree*/\n\troot = xmlDocGetRootElement(doc);\n\n\tmemset(config, 0, sizeof(IPACM_conf_t));\n\n\t/* parse the xml tree returned by libxml */\n\tret_val = ipacm_cfg_xml_parse_tree(root, config);\n\n\tif (ret_val != IPACM_SUCCESS)\n\t{\n\t\tIPACMDBG_H(\"IPACM_xml_parse: ipacm_cfg_xml_parse_tree returned parse error!\\n\");\n\t}\n\n\t/* Free up the libxml's parse tree */\n\txmlFreeDoc(doc);\n\n\treturn ret_val;\n}\n\n/* This function traverses the xml tree*/\nstatic int ipacm_cfg_xml_parse_tree\n(\n\t xmlNode* xml_node,\n\t IPACM_conf_t *config\n)\n{\n\tint32_t ret_val = IPACM_SUCCESS;\n\tint str_size;\n\tchar* content;\n\tchar content_buf[MAX_XML_STR_LEN];\n\n\tif (NULL == xml_node)\n\t\treturn ret_val;\n\n\twhile ( xml_node != NULL &&\n\t\t\t\t ret_val == IPACM_SUCCESS)\n\t{\n\t\tswitch (xml_node->type)\n\t\t{\n\t\tcase XML_ELEMENT_NODE:\n\t\t\t{\n\t\t\t\tif (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t system_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ODU_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPACMCFG_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPACMIFACECFG_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IFACE_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPACMPRIVATESUBNETCFG_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t SUBNET_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPACMALG_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ALG_TAG) == 0 ||\n\t\t\t\t\t\tIPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPACMNat_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tif (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIFACE_TAG))\n\t\t\t\t\t{\n\t\t\t\t\t\t/* increase iface entry number */\n\t\t\t\t\t\tconfig->iface_config.num_iface_entries++;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSUBNET_TAG))\n\t\t\t\t\t{\n\t\t\t\t\t\t/* increase iface entry number */\n\t\t\t\t\t\tconfig->private_subnet_config.num_subnet_entries++;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tALG_TAG))\n\t\t\t\t\t{\n\t\t\t\t\t\t/* increase iface entry number */\n\t\t\t\t\t\tconfig->alg_config.num_alg_entries++;\n\t\t\t\t\t}\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = ipacm_cfg_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t config);\n\t\t\t\t}\n\t\t\t\telse if (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tODUMODE_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tIPACMDBG(\"inside ODU-XML\\n\");\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tif (0 == strncasecmp(content_buf, ODU_ROUTER_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->router_mode_enable = true;\n\t\t\t\t\t\t\tIPACMDBG(\"router-mode enable %d\\n\", config->router_mode_enable);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (0 == strncasecmp(content_buf, ODU_BRIDGE_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->router_mode_enable = false;\n\t\t\t\t\t\t\tIPACMDBG(\"router-mode enable %d\\n\", config->router_mode_enable);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNAME_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tstrncpy(config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].iface_name, content_buf, str_size);\n\t\t\t\t\t\tIPACMDBG_H(\"Name %s\\n\", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].iface_name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tCATEGORY_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tif (0 == strncasecmp(content_buf, WANIF_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat = WAN_IF;\n\t\t\t\t\t\t\tIPACMDBG_H(\"Category %d\\n\", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (0 == strncasecmp(content_buf, LANIF_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat = LAN_IF;\n\t\t\t\t\t\t\tIPACMDBG_H(\"Category %d\\n\", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (0 == strncasecmp(content_buf, WLANIF_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat = WLAN_IF;\n\t\t\t\t\t\t\tIPACMDBG_H(\"Category %d\\n\", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse  if (0 == strncasecmp(content_buf, VIRTUALIF_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat = VIRTUAL_IF;\n\t\t\t\t\t\t\tIPACMDBG_H(\"Category %d\\n\", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse  if (0 == strncasecmp(content_buf, UNKNOWNIF_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat = UNKNOWN_IF;\n\t\t\t\t\t\t\tIPACMDBG_H(\"Category %d\\n\", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse  if (0 == strncasecmp(content_buf, ETHIF_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat = ETH_IF;\n\t\t\t\t\t\t\tIPACMDBG_H(\"Category %d\\n\", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse  if (0 == strncasecmp(content_buf, ODUIF_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat = ODU_IF;\n\t\t\t\t\t\t\tIPACMDBG(\"Category %d\\n\", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].if_cat);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSUBNETADDRESS_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tcontent_buf[MAX_XML_STR_LEN-1] = '\\0';\n\t\t\t\t\t\tconfig->private_subnet_config.private_subnet_entries[config->private_subnet_config.num_subnet_entries - 1].subnet_addr\n\t\t\t\t\t\t\t = ntohl(inet_addr(content_buf));\n\t\t\t\t\t\tIPACMDBG_H(\"subnet_addr: %s \\n\", content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSUBNETMASK_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tcontent_buf[MAX_XML_STR_LEN-1] = '\\0';\n\t\t\t\t\t\tconfig->private_subnet_config.private_subnet_entries[config->private_subnet_config.num_subnet_entries - 1].subnet_mask\n\t\t\t\t\t\t\t = ntohl(inet_addr(content_buf));\n\t\t\t\t\t\tIPACMDBG_H(\"subnet_mask: %s \\n\", content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tProtocol_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tcontent_buf[MAX_XML_STR_LEN-1] = '\\0';\n\n\t\t\t\t\t\tif (0 == strncasecmp(content_buf, TCP_PROTOCOL_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->alg_config.alg_entries[config->alg_config.num_alg_entries - 1].protocol = IPPROTO_TCP;\n\t\t\t\t\t\t\tIPACMDBG_H(\"Protocol %s: %d\\n\", content_buf, config->alg_config.alg_entries[config->alg_config.num_alg_entries - 1].protocol);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (0 == strncasecmp(content_buf, UDP_PROTOCOL_TAG, str_size))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconfig->alg_config.alg_entries[config->alg_config.num_alg_entries - 1].protocol = IPPROTO_UDP;\n\t\t\t\t\t\t\tIPACMDBG_H(\"Protocol %s: %d\\n\", content_buf, config->alg_config.alg_entries[config->alg_config.num_alg_entries - 1].protocol);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tPort_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->alg_config.alg_entries[config->alg_config.num_alg_entries - 1].port\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t\tIPACMDBG_H(\"port %d\\n\", config->alg_config.alg_entries[config->alg_config.num_alg_entries - 1].port);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNAT_MaxEntries_TAG) == 0)\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->nat_max_entries = atoi(content_buf);\n\t\t\t\t\t\tIPACMDBG_H(\"Nat Table Max Entries %d\\n\", config->nat_max_entries);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\t/* go to sibling */\n\t\txml_node = xml_node->next;\n\t} /* end while */\n\treturn ret_val;\n}\n\n/* This function read QCMAP CM Firewall XML and populate the QCMAP CM Cfg */\nint IPACM_read_firewall_xml(char *xml_file, IPACM_firewall_conf_t *config)\n{\n\txmlDocPtr doc = NULL;\n\txmlNode* root = NULL;\n\tint ret_val;\n\n\tIPACM_ASSERT(xml_file != NULL);\n\tIPACM_ASSERT(config != NULL);\n\n\t/* invoke the XML parser and obtain the parse tree */\n\tdoc = xmlReadFile(xml_file, \"UTF-8\", XML_PARSE_NOBLANKS);\n    if (doc == NULL) {\n        IPACMDBG_H(\"IPACM_xml_parse: libxml returned parse error\\n\");\n\t\treturn IPACM_FAILURE;\n    }\n\t/*get the root of the tree*/\n\troot = xmlDocGetRootElement(doc);\n\n\t/* parse the xml tree returned by libxml*/\n\tret_val = IPACM_firewall_xml_parse_tree(root, config);\n\n\tif (ret_val != IPACM_SUCCESS)\n\t{\n\t\tIPACMDBG_H(\"IPACM_xml_parse: ipacm_firewall_xml_parse_tree returned parse error!\\n\");\n\t}\n\n\t/* free the tree */\n    xmlFreeDoc(doc);\n\n\treturn ret_val;\n}\n\n\n/* This function traverses the firewall xml tree */\nstatic int IPACM_firewall_xml_parse_tree\n(\n\t xmlNode* xml_node,\n\t IPACM_firewall_conf_t *config\n)\n{\n\tint mask_value_v6, mask_index;\n\tint32_t ret_val = IPACM_SUCCESS;\n\tchar *content;\n\tint str_size;\n\tchar content_buf[MAX_XML_STR_LEN];\n\tstruct in6_addr ip6_addr;\n\n\tIPACM_ASSERT(config != NULL);\n\n\tif (NULL == xml_node)\n\t\treturn ret_val;\n\n\twhile ( xml_node != NULL &&\n\t\t\t\t ret_val == IPACM_SUCCESS)\n\t{\n\t\tswitch (xml_node->type)\n\t\t{\n\n\t\tcase XML_ELEMENT_NODE:\n\t\t\t{\n\t\t\t\tif (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsystem_TAG) ||\n\t\t\t\t\t\t0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tMobileAPFirewallCfg_TAG) ||\n\t\t\t\t\t\t0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFirewall_TAG) ||\n\n\t\t\t\t\t\t0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFirewallEnabled_TAG)  ||\n\t\t\t\t\t\t0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFirewallPktsAllowed_TAG)\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t{\n\t\t\t\t\tif (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFirewall_TAG))\n\t\t\t\t\t{\n\t\t\t\t\t\t/* increase firewall entry num */\n\t\t\t\t\t\tconfig->num_extd_firewall_entries++;\n\t\t\t\t\t}\n\n\n\t\t\t\t\tif (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFirewallPktsAllowed_TAG))\n\t\t\t\t\t{\n\t\t\t\t\t\t/* setup action of matched rules */\n\t\t\t\t\t    content = IPACM_read_content_element(xml_node);\n\t\t\t\t\t    if (content)\n\t\t\t\t\t    {\n\t\t\t\t\t\t        str_size = strlen(content);\n\t\t\t\t\t\t        memset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\t        memcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\t\tif (atoi(content_buf)==1)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t    \t            config->rule_action_accept = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t    \t            config->rule_action_accept = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t    \t                IPACMDBG_H(\" Allow traffic which matches rules ?:%d\\n\",config->rule_action_accept);\n\t\t\t\t\t    }\n\t\t\t\t        }\n\n\t\t\t\t\tif (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFirewallEnabled_TAG))\n\t\t\t\t\t{\n\t\t\t\t\t\t/* setup if firewall enable or not */\n\t\t\t\t\t    content = IPACM_read_content_element(xml_node);\n\t\t\t\t\t    if (content)\n\t\t\t\t\t    {\n\t\t\t\t\t\t        str_size = strlen(content);\n\t\t\t\t\t\t        memset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\t        memcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\t\tif (atoi(content_buf)==1)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t    \t            config->firewall_enable = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t        else\n\t\t\t\t\t\t\t{\n\t\t\t\t\t    \t            config->firewall_enable = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t    \t                IPACMDBG_H(\" Firewall Enable?:%d\\n\", config->firewall_enable);\n\t\t\t\t            }\n\t\t\t\t\t}\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPFamily_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].ip_vsn\n\t\t\t\t\t\t\t = (firewall_ip_version_enum)atoi(content_buf);\n\t\t\t\t\t\tIPACMDBG_H(\"\\n IP family type is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].ip_vsn);\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV4SourceAddress_TAG))\n\t\t\t\t{\n\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_SRC_ADDR;\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV4SourceIPAddress_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tcontent_buf[MAX_XML_STR_LEN-1] = '\\0';\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.src_addr\n\t\t\t\t\t\t\t = ntohl(inet_addr(content_buf));\n\t\t\t\t\t\tIPACMDBG_H(\"IPv4 source address is: %s \\n\", content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV4SourceSubnetMask_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tcontent_buf[MAX_XML_STR_LEN-1] = '\\0';\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.src_addr_mask\n\t\t\t\t\t\t\t = ntohl(inet_addr(content_buf));\n\t\t\t\t\t\tIPACMDBG_H(\"IPv4 source subnet mask is: %s \\n\", content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV4DestinationAddress_TAG))\n\t\t\t\t{\n\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_DST_ADDR;\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV4DestinationIPAddress_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tcontent_buf[MAX_XML_STR_LEN-1] = '\\0';\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.dst_addr\n\t\t\t\t\t\t\t = ntohl(inet_addr(content_buf));\n\t\t\t\t\t\tIPACMDBG_H(\"IPv4 destination address is: %s \\n\", content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV4DestinationSubnetMask_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tcontent_buf[MAX_XML_STR_LEN-1] = '\\0';\n\t\t\t\t\t\t\tif (content_buf > 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.dst_addr_mask\n\t\t\t\t\t\t\t = ntohl(inet_addr(content_buf));\n\t\t\t\t\t\tIPACMDBG_H(\"IPv4 destination subnet mask is: %s \\n\", content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV4TypeOfService_TAG))\n\t\t\t\t{\n\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_TOS;\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TOSValue_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos\n\t\t\t\t\t\t\t = atoi(content_buf);\n\n\t\t\t\t\t\tIPACMDBG_H(\"\\n IPV4 TOS val is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TOSMask_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos\n\t\t\t\t\t\t\t &= atoi(content_buf);\n\n\t\t\t\t\t\tIPACMDBG_H(\"\\n IPv4 TOS mask is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV4NextHeaderProtocol_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_PROTOCOL;\n\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.protocol = atoi(content_buf);\n\n\t\t\t\t\t\tIPACMDBG_H(\"\\n IPv4 next header prot is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.protocol);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV6SourceAddress_TAG))\n\t\t\t\t{\n\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |=\n\t\t\t\t\t\t IPA_FLT_SRC_ADDR;\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV6SourceIPAddress_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tinet_pton(AF_INET6, content_buf, &ip6_addr);\n\t\t\t\t\t\tmemcpy(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr,\n\t\t\t\t\t\t\t\t\t ip6_addr.s6_addr, IPACM_IPV6_ADDR_LEN * sizeof(uint8_t));\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[0]=ntohl(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[0]);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[1]=ntohl(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[1]);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[2]=ntohl(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[2]);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[3]=ntohl(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[3]);\n\n\t\t\t\t\t\tIPACMDBG_H(\"\\n ipv6 source addr is %d \\n \",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV6SourcePrefix_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tmask_value_v6 = atoi(content_buf);\n\t\t\t\t\t\tfor (mask_index = 0; mask_index < 4; mask_index++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (mask_value_v6 >= 32)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmask_v6(32, &(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr_mask[mask_index]));\n\t\t\t\t\t\t\t\tmask_value_v6 -= 32;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmask_v6(mask_value_v6, &(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.src_addr_mask[mask_index]));\n\t\t\t\t\t\t\t\tmask_value_v6 = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tIPACMDBG_H(\"\\n ipv6 source prefix is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t atoi(content_buf));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV6DestinationAddress_TAG))\n\t\t\t\t{\n\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |=\n\t\t\t\t\t\t IPA_FLT_DST_ADDR;\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV6DestinationIPAddress_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tinet_pton(AF_INET6, content_buf, &ip6_addr);\n\t\t\t\t\t\tmemcpy(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr,\n\t\t\t\t\t\t\t\t\t ip6_addr.s6_addr, IPACM_IPV6_ADDR_LEN * sizeof(uint8_t));\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[0]=ntohl(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[0]);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[1]=ntohl(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[1]);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[2]=ntohl(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[2]);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[3]=ntohl(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[3]);\n\t\t\t\t\t\tIPACMDBG_H(\"\\n ipv6 dest addr is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV6DestinationPrefix_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tmask_value_v6 = atoi(content_buf);\n\t\t\t\t\t\tfor (mask_index = 0; mask_index < 4; mask_index++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (mask_value_v6 >= 32)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmask_v6(32, &(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr_mask[mask_index]));\n\t\t\t\t\t\t\t\tmask_value_v6 -= 32;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmask_v6(mask_value_v6, &(config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.dst_addr_mask[mask_index]));\n\t\t\t\t\t\t\t\tmask_value_v6 = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tIPACMDBG_H(\"\\n ipv6 dest prefix is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t atoi(content_buf));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV6TrafficClass_TAG))\n\t\t\t\t{\n\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_TC;\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TrfClsValue_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.tc\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t\tIPACMDBG_H(\"\\n ipv6 trf class val is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.tc);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TrfClsMask_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.tc\n\t\t\t\t\t\t\t &= atoi(content_buf);\n\n\t\t\t\t\t\tIPACMDBG_H(\"\\n ipv6 trf class mask is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t atoi(content_buf));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t IPV6NextHeaderProtocol_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_NEXT_HDR;\n\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.next_hdr\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t\tIPACMDBG_H(\"\\n ipv6 next header protocol is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v6.next_hdr);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCPSource_TAG))\n\t\t\t\t{\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCPSourcePort_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCPSourceRange_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tif (atoi(content_buf) != 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_SRC_PORT_RANGE;\n \t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_lo\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port;\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_hi\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port + atoi(content_buf);\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port\n\t\t\t\t\t\t\t = 0;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n tcp source port from %d to %d \\n\",\n\t\t\t\t\t\t                 config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_lo,\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_hi);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t       config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_SRC_PORT;\n                           IPACMDBG_H(\"\\n tcp source port= %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCPDestination_TAG))\n\t\t\t\t{\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCPDestinationPort_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCPDestinationRange_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tif(atoi(content_buf)!=0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_DST_PORT_RANGE;\n \t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_lo\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port;\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_hi\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port + atoi(content_buf);\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port\n\t\t\t\t\t\t\t = 0;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n tcp dest port from %d to %d \\n\",\n\t\t\t\t\t\t                 config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_lo,\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_hi);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t      config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_DST_PORT;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n tcp dest port= %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t UDPSource_TAG))\n\t\t\t\t{\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t UDPSourcePort_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t UDPSourceRange_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tif(atoi(content_buf)!=0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_SRC_PORT_RANGE;\n \t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_lo\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port;\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_hi\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port + atoi(content_buf);\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port\n\t\t\t\t\t\t\t = 0;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n udp source port from %d to %d \\n\",\n\t\t\t\t\t\t                 config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_lo,\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_hi);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t      config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_SRC_PORT;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n udp source port= %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port);\n\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t UDPDestination_TAG))\n\t\t\t\t{\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t UDPDestinationPort_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t UDPDestinationRange_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tif(atoi(content_buf)!=0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_DST_PORT_RANGE;\n \t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_lo\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port;\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_hi\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port + atoi(content_buf);\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port\n\t\t\t\t\t\t\t = 0;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n UDP dest port from %d to %d \\n\",\n\t\t\t\t\t\t                 config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_lo,\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_hi);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t      config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_DST_PORT;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n UDP dest port= %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port);\n\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ICMPType_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.type = atoi(content_buf);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_TYPE;\n\t\t\t\t\t\tIPACMDBG_H(\"\\n icmp type is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.type);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ICMPCode_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.code = atoi(content_buf);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_CODE;\n\t\t\t\t\t\tIPACMDBG_H(\"\\n icmp code is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.code);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ESPSPI_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.spi = atoi(content_buf);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_SPI;\n\t\t\t\t\t\tIPACMDBG_H(\"\\n esp spi is %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.spi);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCP_UDPSource_TAG))\n\t\t\t\t{\n\t\t\t\t\t/* go to child */\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCP_UDPSourcePort_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content,str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCP_UDPSourceRange_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tif(atoi(content_buf)!=0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_SRC_PORT_RANGE;\n \t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_lo\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port;\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_hi\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port + atoi(content_buf);\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port\n\t\t\t\t\t\t\t = 0;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n tcp_udp source port from %d to %d \\n\",\n\t\t\t\t\t\t                 config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_lo,\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port_hi);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t  \t\t\t\t      config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_SRC_PORT;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n tcp_udp source port= %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.src_port);\n\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCP_UDPDestination_TAG))\n\t\t\t\t{\n\t\t\t\t\tret_val = IPACM_firewall_xml_parse_tree(xml_node->children,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig);\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCP_UDPDestinationPort_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tconfig->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port\n\t\t\t\t\t\t\t = atoi(content_buf);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (0 == IPACM_util_icmp_string((char*)xml_node->name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t TCP_UDPDestinationRange_TAG))\n\t\t\t\t{\n\t\t\t\t\tcontent = IPACM_read_content_element(xml_node);\n\t\t\t\t\tif (content)\n\t\t\t\t\t{\n\t\t\t\t\t\tstr_size = strlen(content);\n\t\t\t\t\t\tmemset(content_buf, 0, sizeof(content_buf));\n\t\t\t\t\t\tmemcpy(content_buf, (void *)content, str_size);\n\t\t\t\t\t\tif(atoi(content_buf)!=0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_DST_PORT_RANGE;\n \t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_lo\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port;\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_hi\n\t\t\t\t\t\t\t = config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port + atoi(content_buf);\n\t\t\t\t\t\t  config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port\n\t\t\t\t\t\t\t = 0;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n tcp_udp dest port from %d to %d \\n\",\n\t\t\t\t\t\t                 config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_lo,\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port_hi);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t      config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |= IPA_FLT_DST_PORT;\n\t\t\t\t\t\t  IPACMDBG_H(\"\\n tcp_udp dest port= %d \\n\",\n\t\t\t\t\t\t\t\t\t\t config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.dst_port);\n\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\t/* go to sibling */\n\t\txml_node = xml_node->next;\n\t} /* end while */\n\treturn ret_val;\n}\n\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/IPACM_cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<system xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"ipacm_cfg.xsd\">\n\t<ODUCFG>\n\t\t<Mode>router</Mode>\n\t</ODUCFG>\n\t<IPACM>\n\t\t<IPACMIface>\n\t\t\t<Iface>\n\t\t\t   <Name>rndis0</Name>\n\t\t\t   <Category>LAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>ecm0</Name>\n\t\t\t   <Category>LAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>rmnet_data0</Name>\n\t\t\t   <Category>WAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>rmnet_data1</Name>\n\t\t\t   <Category>WAN</Category>\n\t\t\t</Iface>\t\t\t\n\t\t\t<Iface>\n\t\t\t   <Name>rmnet_data2</Name>\n\t\t\t   <Category>WAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>rmnet_data3</Name>\n\t\t\t   <Category>WAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>rmnet_data4</Name>\n\t\t\t   <Category>WAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>rmnet_data5</Name>\n\t\t\t   <Category>WAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>rmnet_data6</Name>\n\t\t\t   <Category>WAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>rmnet_data7</Name>\n\t\t\t   <Category>WAN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>wlan0</Name>\n\t\t\t   <Category>UNKNOWN</Category>\n\t\t\t</Iface>\t\t\t\n\t\t\t<Iface>\n\t\t\t   <Name>wlan1</Name>\n\t\t\t   <Category>UNKNOWN</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>eth0</Name>\n\t\t\t   <Category>ODU</Category>\n\t\t\t</Iface>\n\t\t\t<Iface>\n\t\t\t   <Name>bridge0</Name>\n\t\t\t   <Category>VIRTUAL</Category>\n\t\t    </Iface>\n\t\t</IPACMIface>\n\t\t<IPACMPrivateSubnet>\n\t\t\t<Subnet>\n  \t\t\t   <SubnetAddress>192.168.225.0</SubnetAddress>\n  \t\t\t   <SubnetMask>255.255.255.0</SubnetMask>\n\t\t    </Subnet>\t\t\n\t\t</IPACMPrivateSubnet>\n\t\t<IPACMALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>TCP</Protocol>\n  \t\t\t   <Port>21</Port>\n\t\t\t   <Description>FTP</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>TCP</Protocol>\n  \t\t\t   <Port>554</Port>\n\t\t\t   <Description>RTSP</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>TCP</Protocol>\n  \t\t\t   <Port>5060</Port>\n\t\t\t   <Description>SIP</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>UDP</Protocol>\n  \t\t\t   <Port>5060</Port>\n\t\t\t   <Description>SIP</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>TCP</Protocol>\n  \t\t\t   <Port>1723</Port>\n\t\t\t   <Description>PPTP</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>UDP</Protocol>\n  \t\t\t   <Port>69</Port>\n\t\t\t   <Description>TFTP</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>UDP</Protocol>\n  \t\t\t   <Port>53</Port>\n\t\t\t   <Description>DNS</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>TCP</Protocol>\n  \t\t\t   <Port>53</Port>\n\t\t\t   <Description>DNS</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>UDP</Protocol>\n  \t\t\t   <Port>10080</Port>\n\t\t\t   <Description>AMANDA</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>UDP</Protocol>\n  \t\t\t   <Port>1719</Port>\n\t\t\t   <Description>H323</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>TCP</Protocol>\n  \t\t\t   <Port>1720</Port>\n\t\t\t   <Description>H323</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>TCP</Protocol>\n  \t\t\t   <Port>6667</Port>\n\t\t\t   <Description>IRC</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>UDP</Protocol>\n  \t\t\t   <Port>137</Port>\n\t\t\t   <Description>NETBIOS_NS</Description>\n\t\t    </ALG>\n\t\t\t<ALG>\n  \t\t\t   <Protocol>TCP</Protocol>\n  \t\t\t   <Port>6566</Port>\n\t\t\t   <Description>SANE</Description>\n\t\t    </ALG>\n\t\t</IPACMALG>\n\t\t<IPACMNAT>\t\t\n \t        <MaxNatEntries>500</MaxNatEntries>\n\t\t</IPACMNAT>\n\t\t</IPACM>\n</system>"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/Makefile.am",
    "content": "AM_CPPFLAGS = -I./../inc \\\n\t      -I$(top_srcdir)/ipanat/inc \\\n\t      ${LIBXML_CFLAGS}\nAM_CPPFLAGS += -Wall -Wundef -Wno-trigraphs\nAM_CPPFLAGS\t+= -DDEBUG -g -DFEATURE_ETH_BRIDGE_LE\n\nipacm_SOURCES =\tIPACM_Main.cpp \\\n\t\tIPACM_Conntrack_NATApp.cpp\\\n\t\tIPACM_ConntrackClient.cpp \\\n\t\tIPACM_ConntrackListener.cpp \\\n\t\tIPACM_EvtDispatcher.cpp \\\n\t\tIPACM_Config.cpp \\\n\t\tIPACM_CmdQueue.cpp \\\n\t\tIPACM_Log.cpp \\\n\t\tIPACM_Filtering.cpp \\\n\t\tIPACM_Routing.cpp \\\n\t\tIPACM_Header.cpp \\\n\t\tIPACM_Lan.cpp \\\n\t\tIPACM_Iface.cpp \\\n\t\tIPACM_Wlan.cpp \\\n\t\tIPACM_Wan.cpp \\\n\t\tIPACM_IfaceManager.cpp \\\n\t\tIPACM_Neighbor.cpp \\\n\t\tIPACM_Netlink.cpp \\\n\t\tIPACM_Xml.cpp \\\n\t\tIPACM_LanToLan.cpp\n\nbin_PROGRAMS  =  ipacm\n\nrequiredlibs =  ${LIBXML_LIB} -lxml2 -lpthread -lnetfilter_conntrack -lnfnetlink\\\n               ../../ipanat/src/libipanat.la\n\nipacm_LDADD =  $(requiredlibs)\n\nAM_CPPFLAGS += \"-std=c++0x\"\n\nLOCAL_MODULE := libipanat\nLOCAL_PRELINK_MODULE := false\ninclude $(BUILD_SHARED_LIBRARY)\n\netcdir = ${sysconfdir}\netc_SCRIPTS = IPACM_cfg.xml\n\ninit_ddir = ${sysconfdir}/init.d\ninit_d_SCRIPTS = start_ipacm_le\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/mobileap_firewall.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<system xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"mobileap_firewall_cfg.xsd\">\n\t<MobileAPFirewallCfg>\t\t\t\t\t\n\t<FirewallEnabled>1</FirewallEnabled> \n      <FirewallPktsAllowed>0</FirewallPktsAllowed> \n\t</MobileAPFirewallCfg>\n</system>\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipacm/src/start_ipacm_le",
    "content": "#! /bin/sh\n#\n################################ \n# Copyright (c) 2013, The Linux Foundation. All rights reserved.\n\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n# * Redistributions of source code must retain the above copyright\n#   notice, this list of conditions and the following disclaimer.\n# * Redistributions in binary form must reproduce the above\n#   copyright notice, this list of conditions and the following\n#   disclaimer in the documentation and/or other materials provided\n#   with the distribution.\n# * Neither the name of The Linux Foundation nor the names of its\n#   contributors may be used to endorse or promote products derived\n#   from this software without specific prior written permission.\n\n# THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n################################\n\n# ipacm   init.d script to start the data-ipa Software's ipacm daemon\n\nset -e\n\ncase \"$1\" in\n  start)\n        echo -n \"Starting ipacm: \"\n        start-stop-daemon -S -b -a ipacm\n        echo \"done\"\n        ;;\n  stop)\n        echo -n \"Stopping ipacm: \"\n        start-stop-daemon -K -n ipacm\n        echo \"done\"\n        ;;\n  restart)\n        $0 stop\n        $0 start\n        ;;\n  *)\n        echo \"Usage ipacm { start | stop | restart}\" >&2\n        exit 1\n        ;;\nesac\n\nexit 0\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drv.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include \"string.h\"  /* memset */\n#include \"stdlib.h\"  /* free, malloc */\n#include \"stdint.h\"  /* uint32_t */\n\n/**\n * struct ipa_nat_ipv4_rule - To hold ipv4 nat rule\n * @target_ip: destination ip address\n * @private_ip: private ip address\n * @target_port: destination port\n * @private_port: private port\n * @protocol: protocol of rule (tcp/udp)\n */\ntypedef struct {\n\tuint32_t target_ip;\n\tuint32_t private_ip;\n\tuint16_t target_port;\n\tuint16_t private_port;\n\tuint16_t public_port;\n\tuint8_t  protocol;\n} ipa_nat_ipv4_rule;\n\n/**\n * ipa_nat_add_ipv4_tbl() - create ipv4 nat table\n * @public_ip_addr: [in] public ipv4 address\n * @number_of_entries: [in]  number of nat entries\n * @table_handle: [out] Handle of new ipv4 nat table\n *\n * To create new ipv4 nat table\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_add_ipv4_tbl(uint32_t public_ip_addr,\n\t\t\t\tuint16_t number_of_entries,\n\t\t\t\tuint32_t *table_handle);\n\n/**\n * ipa_nat_del_ipv4_tbl() - delete ipv4 table\n * @table_handle: [in] Handle of ipv4 nat table\n *\n * To delete given ipv4 nat table\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_del_ipv4_tbl(uint32_t table_handle);\n\n/**\n * ipa_nat_add_ipv4_rule() - to insert new ipv4 rule\n * @table_handle: [in] handle of ipv4 nat table\n * @rule: [in]  Pointer to new rule\n * @rule_handle: [out] Return the handle to rule\n *\n * To insert new ipv4 nat rule into ipv4 nat table\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_add_ipv4_rule(uint32_t table_handle,\n\t\t\t\tconst ipa_nat_ipv4_rule * rule,\n\t\t\t\tuint32_t *rule_handle);\n\n/**\n * ipa_nat_del_ipv4_rule() - to delete ipv4 nat rule\n * @table_handle: [in] handle of ipv4 nat table\n * @rule_handle: [in] ipv4 nat rule handle\n *\n * To insert new ipv4 nat rule into ipv4 nat table\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_del_ipv4_rule(uint32_t table_handle,\n\t\t\t\tuint32_t rule_handle);\n\n\n/**\n * ipa_nat_query_timestamp() - to query timestamp\n * @table_handle: [in] handle of ipv4 nat table\n * @rule_handle: [in] ipv4 nat rule handle\n * @time_stamp: [out] time stamp of rule\n *\n * To retrieve the timestamp that lastly the\n * nat rule was accessed\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_query_timestamp(uint32_t  table_handle,\n\t\t\t\tuint32_t  rule_handle,\n\t\t\t\tuint32_t  *time_stamp);\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drvi.h",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef IPA_NAT_DRVI_H\n#define IPA_NAT_DRVI_H\n\n#include <unistd.h>\n#include <stdio.h>\n#include <sys/ioctl.h>\n#include <fcntl.h>\n#include <sys/mman.h>\n#include <linux/msm_ipa.h>\n#include <netinet/in.h>\n#include <sys/inotify.h>\n#include <errno.h>\n\n#include \"ipa_nat_logi.h\"\n\n#define NAT_DUMP\n\n/*======= IMPLEMENTATION related data structures and functions ======= */\n#ifdef IPA_ON_R3PC\n#define NAT_MMAP_MEM_SIZE (2 * 1024UL * 1024UL - 1)\n#endif\n\n#define IPA_DEV_NAME       \"/dev/ipa\"\n#define NAT_DEV_DIR        \"/dev\"\n#define NAT_DEV_NAME       \"ipaNatTable\"\n#define NAT_DEV_FULL_NAME  \"/dev/ipaNatTable\"\n\n#define IPA_NAT_TABLE_VALID 1\n#define IPA_NAT_MAX_IP4_TBLS   1\n#define IPA_NAT_BASE_TABLE_PERCENTAGE       .8\n#define IPA_NAT_EXPANSION_TABLE_PERCENTAGE  .2\n\n#define IPA_NAT_NUM_OF_BASE_TABLES      2\n#define IPA_NAT_UNUSED_BASE_ENTRIES     2\n\n#define IPA_NAT_RULE_FLAG_FIELD_OFFSET        18\n#define IPA_NAT_RULE_NEXT_FIELD_OFFSET        8\n#define IPA_NAT_RULE_PROTO_FIELD_OFFSET       22\n\n#define IPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET       2\n#define IPA_NAT_INDEX_RULE_NAT_INDEX_FIELD_OFFSET  0\n\n#define IPA_NAT_RULE_FLAG_FIELD_SIZE       2\n#define IPA_NAT_RULE_NEXTFIELD_FIELD_SIZE  2\n\n#define IPA_NAT_FLAG_ENABLE_BIT_MASK  0x8000\n#define IPA_NAT_FLAG_DISABLE_BIT_MASK 0x0000\n\n#define IPA_NAT_FLAG_ENABLE_BIT  1\n#define IPA_NAT_FLAG_DISABLE_BIT 0\n\n#define IPA_NAT_INVALID_PROTO_FIELD_VALUE 0xFF00\n#define IPA_NAT_INVALID_PROTO_FIELD_CMP   0xFF\n\n#define IPA_NAT_INVALID_INDEX 0xFF\n#define IPA_NAT_INVALID_NAT_ENTRY 0x0\n\n#define INDX_TBL_ENTRY_SIZE_IN_BITS  16\n\n/* ----------- Rule id -----------------------\n\n   ------------------------------------------------\n   |  3bits   |    12 bits       |     1 bit      |\n   ------------------------------------------------\n   | reserved | index into table |  0 - base      |\n   |          |                  |  1 - expansion |\n   ------------------------------------------------\n\n*/\n#define IPA_NAT_RULE_HDL_TBL_TYPE_BITS        0x1\n#define IPA_NAT_RULE_HDL_TBL_TYPE_MASK        0x1\n\n/* ----------- sw specif parameter -----\n   ------------------------------------\n   |     16 bits     |     16 bits    |\n   ------------------------------------\n   |  index table    |  prev index    |\n   |     entry       |                |\n   ------------------------------------\n-----------------------------------------*/\n#define IPA_NAT_SW_PARAM_PREV_INDX_BYTE       0\n#define IPA_NAT_SW_PARAM_INDX_TBL_ENTRY_BYTE  1\n\ntypedef enum {\n\tIPA_NAT_BASE_TBL        = 0,\n\tIPA_NAT_EXPN_TBL        = 1,\n\tIPA_NAT_INDX_TBL        = 2,\n\tIPA_NAT_INDEX_EXPN_TBL  = 3,\n} nat_table_type;\n\ntypedef enum {\n\tNEXT_INDEX_FIELD,\n\tPUBLIC_PORT_FILED,\n\tPRIVATE_PORT_FIELD,\n\tTARGET_PORT_FIELD,\n\tIP_CHKSUM_FIELD,\n\tENABLE_FIELD,\n\tTIME_STAMP_FIELD,\n\tPROTOCOL_FIELD,\n\tTCP_UDP_CHKSUM_FIELD,\n\tSW_SPEC_PARAM_PREV_INDEX_FIELD,\n\tSW_SPEC_PARAM_INDX_TBL_ENTRY_FIELD,\n\tINDX_TBL_TBL_ENTRY_FIELD,\n\tINDX_TBL_NEXT_INDEX_FILED\n} ipa_nat_rule_field_type;\n\n/*\n\t---------------------------------------------\n\t|     3      |    2    |    1    |    0      |\n\t---------------------------------------------\n\t| Public Port(2B)     | Next Index(2B)       |\n\t---------------------------------------------\n*/\ntypedef struct {\n\tuint32_t next_index:16;\n\tuint32_t public_port:16;\n} next_index_pub_port;\n\n\n/*\n\t---------------------------------------------\n\t|     3      |    2    |    1    |    0      |\n\t---------------------------------------------\n  |       Flags(2B)     | IP check sum Diff(2B)|\n\t|EN|FIN|Resv |        |                      |\n\t---------------------------------------------\n*/\ntypedef struct {\n\tuint32_t ip_chksum:16;\n\tuint32_t rsvd1:14;\n\tuint32_t redirect:1;\n\tuint32_t enable:1;\n} ipcksum_enbl;\n\n\n/*\n\t---------------------------------------\n\t|   7    |    6    |   5    |    4    |\n\t---------------------------------------\n  | Proto   |      TimeStamp(3B)        |\n\t| (1B)    |                           |\n\t---------------------------------------\n*/\ntypedef struct {\n\tuint32_t time_stamp:24;\n\tuint32_t protocol:8;\n} time_stamp_proto;\n\n\n/*\n\t---------------------------------------------\n\t|     3      |    2    |    1    |    0      |\n\t---------------------------------------------\n  |       next_index     | Table entry         |\n\t----------------------------------------------\n*/\ntypedef struct {\n\tuint16_t tbl_entry;\n\tuint16_t next_index;\n} tbl_ent_nxt_indx;\n\n/*--------------------------------------------------\n   32 bit sw_spec_params is interpreted as follows\n   ------------------------------------\n   |     16 bits     |     16 bits    |\n   ------------------------------------\n   |  index table    |  prev index    |\n   |     entry       |                |\n\t ------------------------------------\n--------------------------------------------------*/\ntypedef struct {\n\tuint16_t prev_index;\n\tuint16_t index_table_entry;\n} sw_spec_params;\n\n/*------------------------  NAT Table Entry  ---------------------------------------\n\n  -----------------------------------------------------------------------------------\n  |   7    |    6    |   5    |    4    |     3      |    2    |    1    |    0      |\n  -----------------------------------------------------------------------------------\n  |             Target IP(4B)           |             Private IP(4B)                 |\n  -----------------------------------------------------------------------------------\n  |Target Port(2B)   | Private Port(2B) | Public Port(2B)     | Next Index(2B)       |\n  -----------------------------------------------------------------------------------\n  | Proto   |      TimeStamp(3B)        |       Flags(2B)     | IP check sum Diff(2B)|\n  | (1B)    |                           |EN|FIN|Resv |        |                      |\n  -----------------------------------------------------------------------------------\n  | TCP/UDP checksum |  Reserved(2B)    |    SW Specific Parameters(4B)              |\n  |    diff (2B)                        |                                            |\n  -----------------------------------------------------------------------------------\n\n  Dont change below structure definition.\n  It should be same as above(little endian order)\n  -------------------------------------------------------------------------------*/\nstruct ipa_nat_rule {\n\tuint64_t private_ip:32;\n\tuint64_t target_ip:32;\n\n\tuint64_t nxt_indx_pub_port:32;\n\tuint64_t private_port:16;\n\tuint64_t target_port:16;\n\n\tuint64_t ip_cksm_enbl:32;\n\tuint64_t ts_proto:32;\n\n  /*--------------------------------------------------\n   32 bit sw_spec_params is interpreted as follows\n   ------------------------------------\n   |     16 bits     |     16 bits    |\n   ------------------------------------\n   |  index table    |  prev index    |\n   |     entry       |                |\n\t ------------------------------------\n  --------------------------------------------------*/\n\tuint64_t sw_spec_params:32;\n\n\tuint64_t rsvd2:16;\n\tuint64_t tcp_udp_chksum:16;\n};\n\nstruct ipa_nat_sw_rule {\n\tuint64_t private_ip:32;\n\tuint64_t target_ip:32;\n\n\tuint64_t next_index:16;\n\tuint64_t public_port:16;\n\tuint64_t private_port:16;\n\tuint64_t target_port:16;\n\n\tuint64_t ip_chksum:16;\n\tuint64_t rsvd1:14;\n\tuint64_t redirect:1;\n\tuint64_t enable:1;\n\tuint64_t time_stamp:24;\n\tuint64_t protocol:8;\n\n  /*--------------------------------------------------\n   32 bit sw_spec_params is interpreted as follows\n   ------------------------------------\n   |     16 bits     |     16 bits    |\n   ------------------------------------\n   |  index table    |  prev index    |\n   |     entry       |                |\n   ------------------------------------\n  --------------------------------------------------*/\n\tuint64_t prev_index:16;\n\tuint64_t indx_tbl_entry:16;\n\tuint64_t rsvd2:16;\n\tuint64_t tcp_udp_chksum:16;\n};\n#define IPA_NAT_TABLE_ENTRY_SIZE        32\n#define IPA_NAT_INDEX_TABLE_ENTRY_SIZE  4\n\nstruct ipa_nat_indx_tbl_rule {\n\tuint32_t tbl_entry_nxt_indx;\n};\n\nstruct ipa_nat_sw_indx_tbl_rule {\n\tuint16_t tbl_entry;\n\tuint16_t next_index;\n};\n\nstruct ipa_nat_indx_tbl_meta_info {\n\tuint16_t prev_index;\n};\n\nstruct ipa_nat_ip4_table_cache {\n\tuint8_t valid;\n\tuint32_t public_addr;\n\n\tint nat_fd;\n\tint size;\n\tuint32_t tbl_addr_offset;\n\tchar table_name[IPA_RESOURCE_NAME_MAX];\n\n\tchar  *ipv4_rules_addr;\n\tchar  *index_table_addr;\n\tuint16_t   table_entries;\n\n\tchar *ipv4_expn_rules_addr;\n\tchar *index_table_expn_addr;\n\tuint16_t  expn_table_entries;\n\n\tstruct ipa_nat_indx_tbl_meta_info *index_expn_table_meta;\n\n\tuint16_t *rule_id_array;\n#ifdef IPA_ON_R3PC\n\tuint32_t mmap_offset;\n#endif\n};\n\nstruct ipa_nat_cache {\n\tstruct ipa_nat_ip4_table_cache ip4_tbl[IPA_NAT_MAX_IP4_TBLS];\n\tint ipa_fd;\n\tuint8_t table_cnt;\n};\n\nstruct ipa_nat_indx_tbl_sw_rule {\n\tuint16_t tbl_entry;\n\tuint16_t next_index;\n\tuint16_t prev_index;\n};\n\ntypedef enum {\n\tIPA_NAT_DEL_TYPE_ONLY_ONE,\n\tIPA_NAT_DEL_TYPE_HEAD,\n\tIPA_NAT_DEL_TYPE_MIDDLE,\n\tIPA_NAT_DEL_TYPE_LAST,\n} del_type;\n\n/**\n * ipa_nati_parse_ipv4_rule_hdl() - prase rule handle\n * @tbl_hdl:\t[in] nat table rule\n * @rule_hdl: [in] nat rule handle\n * @expn_tbl: [out] expansion table or not\n * @tbl_entry: [out] index into table\n *\n * Parse the rule handle to retrieve the nat table\n * type and entry of nat table\n *\n * Returns:\tNone\n */\nvoid ipa_nati_parse_ipv4_rule_hdl(uint8_t tbl_hdl,\n\t\t\t\tuint16_t rule_hdl,\n\t\t\t\tuint8_t *expn_tbl,\n\t\t\t\tuint16_t *tbl_entry);\n\n/**\n * ipa_nati_make_rule_hdl() - makes nat rule handle\n * @tbl_hdl: [in] nat table handle\n * @tbl_entry: [in]  nat table entry\n *\n * Calculate the nat rule handle which from\n * nat entry which will be returned to client of\n * nat driver\n *\n * Returns:\t>0 nat rule handle\n */\nuint16_t ipa_nati_make_rule_hdl(uint16_t tbl_hdl,\n\t\t\t\tuint16_t tbl_entry);\n\nuint32_t ipa_nati_get_index_entry_offset(\n\t\t\t\tstruct ipa_nat_ip4_table_cache*,\n\t\t\t\tnat_table_type tbl_type,\n\t\t\t\tuint16_t indx_tbl_entry);\nuint32_t ipa_nati_get_entry_offset(\n\t\t\t\tstruct ipa_nat_ip4_table_cache*,\n\t\t\t\tnat_table_type tbl_type,\n\t\t\t\tuint16_t  tbl_entry);\n\nint ipa_nati_add_ipv4_tbl(uint32_t public_ip_addr,\n\t\t\t\tuint16_t number_of_entries,\n\t\t\t\tuint32_t *table_hanle);\n\nint ipa_nati_alloc_table(uint16_t number_of_entries,\n\t\t\t\tstruct ipa_ioc_nat_alloc_mem *mem,\n\t\t\t\tuint16_t*, uint16_t*);\n\nint ipa_nati_update_cache(struct ipa_ioc_nat_alloc_mem *,\n\t\t\t\tuint32_t public_ip_addr,\n\t\t\t\tuint16_t tbl_entries,\n\t\t\t\tuint16_t expn_tbl_entries);\n\nint ipa_nati_del_ipv4_table(uint32_t tbl_hdl);\nint ipa_nati_reset_ipv4_table(uint32_t tbl_hdl);\nint ipa_nati_post_ipv4_init_cmd(uint8_t tbl_index);\n\nint ipa_nati_query_timestamp(uint32_t  tbl_hdl,\n\t\t\t\tuint32_t  rule_hdl,\n\t\t\t\tuint32_t  *time_stamp);\n\nint ipa_nati_add_ipv4_rule(uint32_t tbl_hdl,\n\t\t\t\tconst ipa_nat_ipv4_rule *clnt_rule,\n\t\t\t\tuint32_t *rule_hdl);\n\nint ipa_nati_generate_rule(uint32_t tbl_hdl,\n\t\t\t\tconst ipa_nat_ipv4_rule *clnt_rule,\n\t\t\t\tstruct ipa_nat_sw_rule *rule,\n\t\t\t\tstruct ipa_nat_indx_tbl_sw_rule *index_sw_rule,\n\t\t\t\tuint16_t *tbl_entry,\n\t\t\t\tuint16_t *indx_tbl_entry);\n\nuint16_t ipa_nati_expn_tbl_free_entry(struct ipa_nat_rule *expn_tbl,\n\t\t\t\tuint16_t size);\n\nuint16_t ipa_nati_generate_tbl_rule(const ipa_nat_ipv4_rule *clnt_rule,\n\t\t\t\tstruct ipa_nat_sw_rule *sw_rule,\n\t\t\t\tstruct ipa_nat_ip4_table_cache *tbl_ptr);\n\nuint16_t ipa_nati_generate_index_rule(const ipa_nat_ipv4_rule *clnt_rule,\n\t\t\t\tstruct ipa_nat_indx_tbl_sw_rule *sw_rule,\n\t\t\t\tstruct ipa_nat_ip4_table_cache *tbl_ptr);\n\nuint16_t ipa_nati_index_expn_get_free_entry(struct ipa_nat_indx_tbl_rule *tbl,\n\t\t\t\tuint16_t size);\n\nvoid ipa_nati_copy_ipv4_rule_to_hw(\n\t\t\t\tstruct ipa_nat_ip4_table_cache *ipv4_cache,\n\t\t\t\tstruct ipa_nat_sw_rule *rule,\n\t\t\t\tuint16_t entry, uint8_t tbl_index);\n\nvoid ipa_nati_copy_ipv4_index_rule_to_hw(\n\t\t\t\tstruct ipa_nat_ip4_table_cache *ipv4_cache,\n\t\t\t\tstruct ipa_nat_indx_tbl_sw_rule *indx_sw_rule,\n\t\t\t\tuint16_t entry, uint8_t tbl_index);\n\nvoid ipa_nati_write_next_index(uint8_t tbl_indx,\n\t\t\t\tnat_table_type tbl_type,\n\t\t\t\tuint16_t value,\n\t\t\t\tuint32_t offset);\n\nint ipa_nati_post_ipv4_dma_cmd(uint8_t tbl_indx,\n\t\t\t\tuint16_t entry);\n\nint ipa_nati_del_ipv4_rule(uint32_t tbl_hdl,\n\t\t\t\tuint32_t rule_hdl);\n\nint ipa_nati_post_del_dma_cmd(uint8_t tbl_indx,\n\t\t\t\tuint16_t tbl_entry,\n\t\t\t\tuint8_t expn_tbl,\n\t\t\t\tdel_type rule_pos);\n\nvoid ipa_nati_find_index_rule_pos(\n\t\t\t\tstruct ipa_nat_ip4_table_cache *cache_ptr,\n\t\t\t\tuint16_t tbl_entry,\n\t\t\t\tdel_type *rule_pos);\n\nvoid ipa_nati_del_dead_ipv4_head_nodes(uint8_t tbl_indx);\nvoid ipa_nati_find_rule_pos(struct ipa_nat_ip4_table_cache *cache_ptr,\n\t\t\t\tuint8_t expn_tbl,\n\t\t\t\tuint16_t tbl_entry,\n\t\t\t\tdel_type *rule_pos);\nvoid ipa_nati_del_dead_ipv4_head_nodes(uint8_t tbl_indx);\n\nuint16_t Read16BitFieldValue(uint32_t param,\n\t\t\t\tipa_nat_rule_field_type fld_type);\n\n/* ========================================================\n\t\t\t\t\t\t\t\tDebug functions\n   ========================================================*/\n#ifdef NAT_DUMP\nvoid ipa_nati_print_rule(struct ipa_nat_rule*, uint32_t);\nvoid ipa_nat_dump_ipv4_table(uint32_t);\nvoid ipa_nati_print_index_rule(struct ipa_nat_indx_tbl_rule*,\n\t\t\t\tuint32_t, uint16_t);\nint ipa_nati_query_nat_rules(uint32_t, nat_table_type);\n#endif\n\n#endif /* #ifndef IPA_NAT_DRVI_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/inc/ipa_nat_logi.h",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tipa_nat_logi.h\n\n\t@brief\n\tThis file implements the IPAM log functionality.\n\n\t@Author\n\t\n\n*/\n\n#ifndef IPA_NAT_LOGI_H\n#define IPA_NAT_LOGI_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#include <stdio.h>\n#include <string.h>\n#include <syslog.h>\n\n#define PERROR(fmt) printf(\"%s:%d %s()\", __FILE__, __LINE__, __FUNCTION__);\\\n                    perror(fmt);\n\n#define IPAERR(fmt, ...)  printf(\"ERR: %s:%d %s() \" fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\n\n#ifdef DEBUG\n#define IPADBG(fmt, ...) printf(\"%s:%d %s() \" fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\n\n#define IPADUMP(fmt, ...) printf(fmt, ##__VA_ARGS__);\n\n#else\n#define IPADBG(fmt, ...)\n#define IPADUMP(fmt, ...)\n#endif\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* IPA_NAT_LOGI_H */\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/src/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_C_INCLUDES := $(LOCAL_PATH)/../inc\nLOCAL_C_INCLUDES += $(LOCAL_PATH)\nLOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include\nLOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr\n\nLOCAL_SRC_FILES := ipa_nat_drv.c \\\n                   ipa_nat_drvi.c\n\nLOCAL_CFLAGS := -DDEBUG\nLOCAL_MODULE := libipanat\nLOCAL_MODULE_TAGS := optional\nLOCAL_PRELINK_MODULE := false\n\ninclude $(BUILD_SHARED_LIBRARY)\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/src/Makefile.am",
    "content": "AM_CFLAGS = -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs\nAM_CFLAGS += -I./../inc\n#AM_CFLAGS += -DDEBUG -g\n\ncommon_CFLAGS =  -DUSE_GLIB @GLIB_CFLAGS@\ncommon_LDFLAGS = -lrt @GLIB_LIBS@\n\nc_sources   = ipa_nat_drv.c \\\n              ipa_nat_drvi.c \\\n              ipa_nat_logi.c\n\nlibrary_includedir = $(pkgincludedir)\nlibrary_include_HEADERS = ./../inc/ipa_nat_drvi.h \\\n                          ./../inc/ipa_nat_drv.h \\\n                          ./../inc/ipa_nat_logi.h\n\nlib_LTLIBRARIES = libipanat.la\nlibipanat_la_C = @C@\nlibipanat_la_SOURCES = $(c_sources)\nlibipanat_la_CFLAGS = $(AM_CFLAGS) $(common_CFLAGS)\nlibipanat_la_LDFLAGS = -shared $(common_LDFLAGS) -version-info 1:0:0\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/src/ipa_nat_drv.c",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include \"ipa_nat_drv.h\"\n#include \"ipa_nat_drvi.h\"\n\n/**\n * ipa_nat_add_ipv4_tbl() - create ipv4 nat table\n * @public_ip_addr: [in] public ipv4 address\n * @number_of_entries: [in]  number of nat entries\n * @table_handle: [out] Handle of new ipv4 nat table\n *\n * To create new ipv4 nat table\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_add_ipv4_tbl(uint32_t public_ip_addr,\n\t\tuint16_t number_of_entries,\n\t\tuint32_t *tbl_hdl)\n{\n  int ret;\n\n  if (NULL == tbl_hdl || 0 == number_of_entries) {\n    IPAERR(\"Invalid parameters \\n\");\n    return -EINVAL;\n  }\n\n  ret = ipa_nati_add_ipv4_tbl(public_ip_addr,\n\t\t\t\t\t\t\t\tnumber_of_entries,\n\t\t\t\t\t\t\t\ttbl_hdl);\n  if (ret != 0) {\n    IPAERR(\"unable to add table \\n\");\n    return -EINVAL;\n  }\n  IPADBG(\"Returning table handle 0x%x\\n\", *tbl_hdl);\n\n  return ret;\n} /* __ipa_nat_add_ipv4_tbl() */\n\n/**\n * ipa_nat_del_ipv4_tbl() - delete ipv4 table\n * @table_handle: [in] Handle of ipv4 nat table\n *\n * To delete given ipv4 nat table\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_del_ipv4_tbl(uint32_t tbl_hdl)\n{\n  if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||\n      tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {\n    IPAERR(\"invalid table handle passed \\n\");\n    return -EINVAL;\n  }\n  IPADBG(\"Passed Table Handle: 0x%x\\n\", tbl_hdl);\n\n  return ipa_nati_del_ipv4_table(tbl_hdl);\n}\n\n/**\n * ipa_nat_add_ipv4_rule() - to insert new ipv4 rule\n * @table_handle: [in] handle of ipv4 nat table\n * @rule: [in]  Pointer to new rule\n * @rule_handle: [out] Return the handle to rule\n *\n * To insert new ipv4 nat rule into ipv4 nat table\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_add_ipv4_rule(uint32_t tbl_hdl,\n\t\tconst ipa_nat_ipv4_rule *clnt_rule,\n\t\tuint32_t *rule_hdl)\n{\n  int result = -EINVAL;\n\n  if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||\n      tbl_hdl > IPA_NAT_MAX_IP4_TBLS || NULL == rule_hdl ||\n      NULL == clnt_rule) {\n    IPAERR(\"invalide table handle passed \\n\");\n    return result;\n  }\n  IPADBG(\"Passed Table handle: 0x%x\\n\", tbl_hdl);\n\n  if (ipa_nati_add_ipv4_rule(tbl_hdl, clnt_rule, rule_hdl) != 0) {\n\t\treturn result;\n\t}\n\n  IPADBG(\"returning rule handle 0x%x\\n\", *rule_hdl);\n  return 0;\n}\n\n\n/**\n * ipa_nat_del_ipv4_rule() - to delete ipv4 nat rule\n * @table_handle: [in] handle of ipv4 nat table\n * @rule_handle: [in] ipv4 nat rule handle\n *\n * To insert new ipv4 nat rule into ipv4 nat table\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_del_ipv4_rule(uint32_t tbl_hdl,\n\t\tuint32_t rule_hdl)\n{\n  int result = -EINVAL;\n\n  if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||\n      IPA_NAT_INVALID_NAT_ENTRY == rule_hdl) {\n    IPAERR(\"invalide parameters\\n\");\n    return result;\n  }\n  IPADBG(\"Passed Table: 0x%x and rule handle 0x%x\\n\", tbl_hdl, rule_hdl);\n\n  result = ipa_nati_del_ipv4_rule(tbl_hdl, rule_hdl);\n  if (result) {\n    IPAERR(\"unable to delete rule from hw \\n\");\n    return result;\n  }\n\n  return 0;\n}\n\n/**\n * ipa_nat_query_timestamp() - to query timestamp\n * @table_handle: [in] handle of ipv4 nat table\n * @rule_handle: [in] ipv4 nat rule handle\n * @time_stamp: [out] time stamp of rule\n *\n * To retrieve the timestamp that lastly the\n * nat rule was accessed\n *\n * Returns:\t0  On Success, negative on failure\n */\nint ipa_nat_query_timestamp(uint32_t  tbl_hdl,\n\t\tuint32_t  rule_hdl,\n\t\tuint32_t  *time_stamp)\n{\n\n  if (0 == tbl_hdl || tbl_hdl > IPA_NAT_MAX_IP4_TBLS ||\n      NULL == time_stamp) {\n    IPAERR(\"invalid parameters passed \\n\");\n    return -EINVAL;\n  }\n  IPADBG(\"Passed Table: 0x%x and rule handle 0x%x\\n\", tbl_hdl, rule_hdl);\n\n  return ipa_nati_query_timestamp(tbl_hdl, rule_hdl, time_stamp);\n}\n\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/src/ipa_nat_drvi.c",
    "content": "/*\nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include \"ipa_nat_drv.h\"\n#include \"ipa_nat_drvi.h\"\n\n#ifdef USE_GLIB\n#include <glib.h>\n#define strlcpy g_strlcpy\n#endif\n\nstruct ipa_nat_cache ipv4_nat_cache;\n\n/* ------------------------------------------\n\t\tUTILITY FUNCTIONS START\n\t --------------------------------------------*/\n\n/**\n * UpdateSwSpecParams() - updates sw specific params\n * @rule: [in/out] nat table rule\n * @param_type: [in] which param need to update\n * @value: [in] value of param\n *\n * Update SW specific params in the passed rule.\n *\n * Returns: None\n */\nvoid UpdateSwSpecParams(struct ipa_nat_rule *rule,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuint8_t param_type,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuint32_t value)\n{\n\tuint32_t temp = rule->sw_spec_params;\n\n\tif (IPA_NAT_SW_PARAM_INDX_TBL_ENTRY_BYTE == param_type) {\n\t\tvalue = (value << INDX_TBL_ENTRY_SIZE_IN_BITS);\n\t\ttemp &= 0x0000FFFF;\n\t} else {\n\t\ttemp &= 0xFFFF0000;\n\t}\n\n\ttemp = (temp | value);\n\trule->sw_spec_params = temp;\n\treturn;\n}\n\n/**\n * Read8BitFieldValue()\n * @rule: [in/out]\n * @param_type: [in]\n * @value: [in]\n *\n *\n *\n * Returns: None\n */\n\nuint8_t Read8BitFieldValue(uint32_t param,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tipa_nat_rule_field_type fld_type)\n{\n\tvoid *temp = (void *)&param;\n\n\tswitch (fld_type) {\n\n\tcase PROTOCOL_FIELD:\n\t\treturn ((time_stamp_proto *)temp)->protocol;\n\n\tdefault:\n\t\tIPAERR(\"Invalid Field type passed\\n\");\n\t\treturn 0;\n\t}\n}\n\nuint16_t Read16BitFieldValue(uint32_t param,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ipa_nat_rule_field_type fld_type)\n{\n\tvoid *temp = (void *)&param;\n\n\tswitch (fld_type) {\n\n\tcase NEXT_INDEX_FIELD:\n\t\treturn ((next_index_pub_port *)temp)->next_index;\n\n\tcase PUBLIC_PORT_FILED:\n\t\treturn ((next_index_pub_port *)temp)->public_port;\n\n\tcase ENABLE_FIELD:\n\t\treturn ((ipcksum_enbl *)temp)->enable;\n\n\tcase SW_SPEC_PARAM_PREV_INDEX_FIELD:\n\t\treturn ((sw_spec_params *)temp)->prev_index;\n\n\tcase SW_SPEC_PARAM_INDX_TBL_ENTRY_FIELD:\n\t\treturn ((sw_spec_params *)temp)->index_table_entry;\n\n\tcase INDX_TBL_TBL_ENTRY_FIELD:\n\t\treturn ((tbl_ent_nxt_indx *)temp)->tbl_entry;\n\n\tcase INDX_TBL_NEXT_INDEX_FILED:\n\t\treturn ((tbl_ent_nxt_indx *)temp)->next_index;\n\n#ifdef NAT_DUMP\n\tcase IP_CHKSUM_FIELD:\n\t\treturn ((ipcksum_enbl *)temp)->ip_chksum;\n#endif\n\n\tdefault:\n\t\tIPAERR(\"Invalid Field type passed\\n\");\n\t\treturn 0;\n\t}\n}\n\nuint32_t Read32BitFieldValue(uint32_t param,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ipa_nat_rule_field_type fld_type)\n{\n\n\tvoid *temp = (void *)&param;\n\n\tswitch (fld_type) {\n\n\tcase TIME_STAMP_FIELD:\n\t\treturn ((time_stamp_proto *)temp)->time_stamp;\n\n\tdefault:\n\t\tIPAERR(\"Invalid Field type passed\\n\");\n\t\treturn 0;\n\t}\n}\n\n\n/**\n * CreateNatDevice() - Create nat devices\n * @mem: [in] name of device that need to create\n *\n * Create Nat device and Register for file create\n * notification in given directory and wait till\n * receive notification\n *\n * Returns: 0 on success, negative on failure\n */\nint CreateNatDevice(struct ipa_ioc_nat_alloc_mem *mem)\n{\n\tint ret;\n\n\tret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_ALLOC_NAT_MEM, mem);\n\tif (ret != 0) {\n\t\tperror(\"CreateNatDevice(): ioctl error value\");\n\t\tIPAERR(\"unable to post nat mem init. Error ;%d\\n\", ret);\n\t\tIPADBG(\"ipa fd %d\\n\", ipv4_nat_cache.ipa_fd);\n\t\treturn -EINVAL;\n\t}\n\tIPADBG(\"posted IPA_IOC_ALLOC_NAT_MEM to kernel successfully\\n\");\n\treturn 0;\n}\n\n/**\n * GetNearest2Power() - Returns the nearest power of 2\n * @num: [in] given number\n * @ret: [out] nearest power of 2\n *\n * Returns the nearest power of 2 for a\n * given number\n *\n * Returns: 0 on success, negative on failure\n */\nint GetNearest2Power(uint16_t num, uint16_t *ret)\n{\n\tuint16_t number = num;\n\tuint16_t tmp = 1;\n\t*ret = 0;\n\n\tif (0 == num) {\n\t\treturn -EINVAL;\n\t}\n\n\tif (1 == num) {\n\t\t*ret = 2;\n\t\treturn 0;\n\t}\n\n\tfor (;;) {\n\t\tif (1 == num) {\n\t\t\tif (number != tmp) {\n\t\t\t\ttmp *= 2;\n\t\t\t}\n\n\t\t\t*ret = tmp;\n\t\t\treturn 0;\n\t\t}\n\n\t\tnum >>= 1;\n\t\ttmp *= 2;\n\t}\n\n\treturn -EINVAL;\n}\n\n/**\n * GetNearestEven() - Returns the nearest even number\n * @num: [in] given number\n * @ret: [out] nearest even number\n *\n * Returns the nearest even number for a given number\n *\n * Returns: 0 on success, negative on failure\n */\nvoid GetNearestEven(uint16_t num, uint16_t *ret)\n{\n\n\tif (num < 2) {\n\t\t*ret = 2;\n\t\treturn;\n\t}\n\n\twhile ((num % 2) != 0) {\n\t\tnum = num + 1;\n\t}\n\n\t*ret = num;\n\treturn;\n}\n\n/**\n * dst_hash() - Find the index into ipv4 base table\n * @trgt_ip: [in] Target IP address\n * @trgt_port: [in]  Target port\n * @public_port: [in]  Public port\n * @proto: [in] Protocol (TCP/IP)\n * @size: [in] size of the ipv4 base Table\n *\n * This hash method is used to find the hash index of new nat\n * entry into ipv4 base table. In case of zero index, the\n * new entry will be stored into N-1 index where N is size of\n * ipv4 base table\n *\n * Returns: >0 index into ipv4 base table, negative on failure\n */\nstatic uint16_t dst_hash(uint32_t trgt_ip, uint16_t trgt_port,\n\t\t\t\tuint16_t public_port, uint8_t proto,\n\t\t\t\tuint16_t size)\n{\n\tuint16_t hash = ((uint16_t)(trgt_ip)) ^ ((uint16_t)(trgt_ip >> 16)) ^\n\t\t (trgt_port) ^ (public_port) ^ (proto);\n\n\tIPADBG(\"trgt_ip: 0x%x trgt_port: 0x%x\\n\", trgt_ip, trgt_port);\n\tIPADBG(\"public_port: 0x%x\\n\", public_port);\n\tIPADBG(\"proto: 0x%x size: 0x%x\\n\", proto, size);\n\n\thash = (hash & size);\n\n\t/* If the hash resulted to zero then set it to maximum value\n\t\t as zero is unused entry in nat tables */\n\tif (0 == hash) {\n\t\treturn size;\n\t}\n\n\tIPADBG(\"dst_hash returning value: %d\\n\", hash);\n\treturn hash;\n}\n\n/**\n * src_hash() - Find the index into ipv4 index base table\n * @priv_ip: [in] Private IP address\n * @priv_port: [in]  Private port\n * @trgt_ip: [in]  Target IP address\n * @trgt_port: [in] Target Port\n * @proto: [in]  Protocol (TCP/IP)\n * @size: [in] size of the ipv4 index base Table\n *\n * This hash method is used to find the hash index of new nat\n * entry into ipv4 index base table. In case of zero index, the\n * new entry will be stored into N-1 index where N is size of\n * ipv4 index base table\n *\n * Returns: >0 index into ipv4 index base table, negative on failure\n */\nstatic uint16_t src_hash(uint32_t priv_ip, uint16_t priv_port,\n\t\t\t\tuint32_t trgt_ip, uint16_t trgt_port,\n\t\t\t\tuint8_t proto, uint16_t size)\n{\n\tuint16_t hash =  ((uint16_t)(priv_ip)) ^ ((uint16_t)(priv_ip >> 16)) ^\n\t\t (priv_port) ^\n\t\t ((uint16_t)(trgt_ip)) ^ ((uint16_t)(trgt_ip >> 16)) ^\n\t\t (trgt_port) ^ (proto);\n\n\tIPADBG(\"priv_ip: 0x%x priv_port: 0x%x\\n\", priv_ip, priv_port);\n\tIPADBG(\"trgt_ip: 0x%x trgt_port: 0x%x\\n\", trgt_ip, trgt_port);\n\tIPADBG(\"proto: 0x%x size: 0x%x\\n\", proto, size);\n\n\thash = (hash & size);\n\n\t/* If the hash resulted to zero then set it to maximum value\n\t\t as zero is unused entry in nat tables */\n\tif (0 == hash) {\n\t\treturn size;\n\t}\n\n\tIPADBG(\"src_hash returning value: %d\\n\", hash);\n\treturn hash;\n}\n\n/**\n * ipa_nati_calc_ip_cksum() - Calculate the source nat\n *\t\t\t\t\t\t\t\t\t\t\t\t\t\t IP checksum diff\n * @pub_ip_addr: [in] public ip address\n * @priv_ip_addr: [in]\tPrivate ip address\n *\n * source nat ip checksum different is calculated as\n * public_ip_addr - private_ip_addr\n * Here we are using 1's complement to represent -ve number.\n * So take 1's complement of private ip addr and add it\n * to public ip addr.\n *\n * Returns: >0 ip checksum diff\n */\nstatic uint16_t ipa_nati_calc_ip_cksum(uint32_t pub_ip_addr,\n\t\t\t\t\t\t\t\t\t\tuint32_t priv_ip_addr)\n{\n\tuint16_t ret;\n\tuint32_t cksum = 0;\n\n\t/* Add LSB(2 bytes) of public ip address to cksum */\n\tcksum += (pub_ip_addr & 0xFFFF);\n\n\t/* Add MSB(2 bytes) of public ip address to cksum\n\t\tand check for carry forward(CF), if any add it\n\t*/\n\tcksum += (pub_ip_addr>>16);\n\tif (cksum >> 16) {\n\t\tcksum = (cksum & 0x0000FFFF);\n\t\tcksum += 1;\n\t}\n\n\t/* Calculate the 1's complement of private ip address */\n\tpriv_ip_addr = (~priv_ip_addr);\n\n\t/* Add LSB(2 bytes) of private ip address to cksum\n\t\t and check for carry forward(CF), if any add it\n\t*/\n\tcksum += (priv_ip_addr & 0xFFFF);\n\tif (cksum >> 16) {\n\t\tcksum = (cksum & 0x0000FFFF);\n\t\tcksum += 1;\n\t}\n\n\t/* Add MSB(2 bytes) of private ip address to cksum\n\t\t and check for carry forward(CF), if any add it\n\t*/\n\tcksum += (priv_ip_addr>>16);\n\tif (cksum >> 16) {\n\t\tcksum = (cksum & 0x0000FFFF);\n\t\tcksum += 1;\n\t}\n\n\t/* Return the LSB(2 bytes) of checksum\t*/\n\tret = (uint16_t)cksum;\n\treturn ret;\n}\n\n/**\n * ipa_nati_calc_tcp_udp_cksum() - Calculate the source nat\n *\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTCP/UDP checksum diff\n * @pub_ip_addr: [in] public ip address\n * @pub_port: [in] public tcp/udp port\n * @priv_ip_addr: [in]\tPrivate ip address\n * @priv_port: [in] Private tcp/udp prot\n *\n * source nat tcp/udp checksum is calculated as\n * (pub_ip_addr + pub_port) - (priv_ip_addr + priv_port)\n * Here we are using 1's complement to represent -ve number.\n * So take 1's complement of prviate ip addr &private port\n * and add it public ip addr & public port.\n *\n * Returns: >0 tcp/udp checksum diff\n */\nstatic uint16_t ipa_nati_calc_tcp_udp_cksum(uint32_t pub_ip_addr,\n\t\t\t\t\t\t\t\t\t\tuint16_t pub_port,\n\t\t\t\t\t\t\t\t\t\tuint32_t priv_ip_addr,\n\t\t\t\t\t\t\t\t\t\tuint16_t priv_port)\n{\n\tuint16_t ret = 0;\n\tuint32_t cksum = 0;\n\n\t/* Add LSB(2 bytes) of public ip address to cksum */\n\tcksum += (pub_ip_addr & 0xFFFF);\n\n\t/* Add MSB(2 bytes) of public ip address to cksum\n\t\tand check for carry forward(CF), if any add it\n\t*/\n\tcksum += (pub_ip_addr>>16);\n\tif (cksum >> 16) {\n\t\tcksum = (cksum & 0x0000FFFF);\n\t\tcksum += 1;\n\t}\n\n\t/* Add public port to cksum and\n\t\t check for carry forward(CF), if any add it */\n\tcksum += pub_port;\n\tif (cksum >> 16) {\n\t\tcksum = (cksum & 0x0000FFFF);\n\t\tcksum += 1;\n\t}\n\n\t/* Calculate the 1's complement of private ip address */\n\tpriv_ip_addr = (~priv_ip_addr);\n\n\t/* Add LSB(2 bytes) of private ip address to cksum\n\t\t and check for carry forward(CF), if any add it\n\t*/\n\tcksum += (priv_ip_addr & 0xFFFF);\n\tif (cksum >> 16) {\n\t\tcksum = (cksum & 0x0000FFFF);\n\t\tcksum += 1;\n\t}\n\n\t/* Add MSB(2 bytes) of private ip address to cksum\n\t\t and check for carry forward(CF), if any add\n\t*/\n\tcksum += (priv_ip_addr>>16);\n\tif (cksum >> 16) {\n\t\tcksum = (cksum & 0x0000FFFF);\n\t\tcksum += 1;\n\t}\n\n\t/* Calculate the 1's complement of private port */\n\tpriv_port = (~priv_port);\n\n\t/* Add public port to cksum and\n\t check for carry forward(CF), if any add it */\n\tcksum += priv_port;\n\tif (cksum >> 16) {\n\t\tcksum = (cksum & 0x0000FFFF);\n\t\tcksum += 1;\n\t}\n\n\t/* return the LSB(2 bytes) of checksum */\n\tret = (uint16_t)cksum;\n\treturn ret;\n}\n\n/**\n * ipa_nati_make_rule_hdl() - makes nat rule handle\n * @tbl_hdl: [in] nat table handle\n * @tbl_entry: [in]  nat table entry\n *\n * Calculate the nat rule handle which from\n * nat entry which will be returned to client of\n * nat driver\n *\n * Returns: >0 nat rule handle\n */\nuint16_t ipa_nati_make_rule_hdl(uint16_t tbl_hdl,\n\t\t\t\tuint16_t tbl_entry)\n{\n\tstruct ipa_nat_ip4_table_cache *tbl_ptr;\n\tuint16_t rule_hdl = 0;\n\tuint16_t cnt = 0;\n\n\ttbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_hdl-1];\n\n\tif (tbl_entry >= tbl_ptr->table_entries) {\n\t\t/* Update the index into table */\n\t\trule_hdl = tbl_entry - tbl_ptr->table_entries;\n\t\trule_hdl = (rule_hdl << IPA_NAT_RULE_HDL_TBL_TYPE_BITS);\n\t\t/* Update the table type mask */\n\t\trule_hdl = (rule_hdl | IPA_NAT_RULE_HDL_TBL_TYPE_MASK);\n\t} else {\n\t\trule_hdl = tbl_entry;\n\t\trule_hdl = (rule_hdl << IPA_NAT_RULE_HDL_TBL_TYPE_BITS);\n\t}\n\n\tfor (; cnt < (tbl_ptr->table_entries + tbl_ptr->expn_table_entries); cnt++) {\n\t\tif (IPA_NAT_INVALID_NAT_ENTRY == tbl_ptr->rule_id_array[cnt]) {\n\t\t\ttbl_ptr->rule_id_array[cnt] = rule_hdl;\n\t\t\treturn cnt + 1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/**\n * ipa_nati_parse_ipv4_rule_hdl() - prase rule handle\n * @tbl_hdl:\t[in] nat table rule\n * @rule_hdl: [in] nat rule handle\n * @expn_tbl: [out] expansion table or not\n * @tbl_entry: [out] index into table\n *\n * Parse the rule handle to retrieve the nat table\n * type and entry of nat table\n *\n * Returns: None\n */\nvoid ipa_nati_parse_ipv4_rule_hdl(uint8_t tbl_index,\n\t\t\t\tuint16_t rule_hdl, uint8_t *expn_tbl,\n\t\t\t\tuint16_t *tbl_entry)\n{\n\tstruct ipa_nat_ip4_table_cache *tbl_ptr;\n\tuint16_t rule_id;\n\n\t*expn_tbl = 0;\n\t*tbl_entry = IPA_NAT_INVALID_NAT_ENTRY;\n\ttbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_index];\n\n\tif (rule_hdl >= (tbl_ptr->table_entries + tbl_ptr->expn_table_entries)) {\n\t\tIPAERR(\"invalid rule handle\\n\");\n\t\treturn;\n\t}\n\n\trule_id = tbl_ptr->rule_id_array[rule_hdl-1];\n\n\t/* Retrieve the table type */\n\t*expn_tbl = 0;\n\tif (rule_id & IPA_NAT_RULE_HDL_TBL_TYPE_MASK) {\n\t\t*expn_tbl = 1;\n\t}\n\n\t/* Retrieve the table entry */\n\t*tbl_entry = (rule_id >> IPA_NAT_RULE_HDL_TBL_TYPE_BITS);\n\treturn;\n}\n\nuint32_t ipa_nati_get_entry_offset(struct ipa_nat_ip4_table_cache *cache_ptr,\n\t\t\t\t\t\tnat_table_type tbl_type,\n\t\t\t\t\t\tuint16_t\ttbl_entry)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\tuint32_t ret = 0;\n\n\tif (IPA_NAT_EXPN_TBL == tbl_type) {\n\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;\n\t} else {\n\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_rules_addr;\n\t}\n\n\tret = (char *)&tbl_ptr[tbl_entry] - (char *)tbl_ptr;\n\tret += cache_ptr->tbl_addr_offset;\n\treturn ret;\n}\n\nuint32_t ipa_nati_get_index_entry_offset(struct ipa_nat_ip4_table_cache *cache_ptr,\n\t\t\t\t\t\t\t\tnat_table_type tbl_type,\n\t\t\t\t\t\t\t\tuint16_t indx_tbl_entry)\n{\n\tstruct ipa_nat_indx_tbl_rule *indx_tbl_ptr;\n\tuint32_t ret = 0;\n\n\tif (IPA_NAT_INDEX_EXPN_TBL == tbl_type) {\n\t\tindx_tbl_ptr =\n\t\t\t (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_expn_addr;\n\t} else {\n\t\tindx_tbl_ptr =\n\t\t\t (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_addr;\n\t}\n\n\tret = (char *)&indx_tbl_ptr[indx_tbl_entry] - (char *)indx_tbl_ptr;\n\tret += cache_ptr->tbl_addr_offset;\n\treturn ret;\n}\n\n/* ------------------------------------------\n\t\tUTILITY FUNCTIONS END\n--------------------------------------------*/\n\n/* ------------------------------------------\n\t Main Functions\n--------------------------------------------**/\nvoid ipa_nati_reset_tbl(uint8_t tbl_indx)\n{\n\tuint16_t table_entries = ipv4_nat_cache.ip4_tbl[tbl_indx].table_entries;\n\tuint16_t expn_table_entries = ipv4_nat_cache.ip4_tbl[tbl_indx].expn_table_entries;\n\n\t/* Base table */\n\tIPADBG(\"memset() base table to 0, %p\\n\",\n\t\t\t\t ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_rules_addr);\n\n\tmemset(ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_rules_addr,\n\t\t\t\t 0,\n\t\t\t\t IPA_NAT_TABLE_ENTRY_SIZE * table_entries);\n\n\t/* Base expansino table */\n\tIPADBG(\"memset() expn base table to 0, %p\\n\",\n\t\t\t\t ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_expn_rules_addr);\n\n\tmemset(ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_expn_rules_addr,\n\t\t\t\t 0,\n\t\t\t\t IPA_NAT_TABLE_ENTRY_SIZE * expn_table_entries);\n\n\t/* Index table */\n\tIPADBG(\"memset() index table to 0, %p\\n\",\n\t\t\t\t ipv4_nat_cache.ip4_tbl[tbl_indx].index_table_addr);\n\n\tmemset(ipv4_nat_cache.ip4_tbl[tbl_indx].index_table_addr,\n\t\t\t\t 0,\n\t\t\t\t IPA_NAT_INDEX_TABLE_ENTRY_SIZE * table_entries);\n\n\t/* Index expansion table */\n\tIPADBG(\"memset() index expn table to 0, %p\\n\",\n\t\t\t\t ipv4_nat_cache.ip4_tbl[tbl_indx].index_table_expn_addr);\n\n\tmemset(ipv4_nat_cache.ip4_tbl[tbl_indx].index_table_expn_addr,\n\t\t\t\t 0,\n\t\t\t\t IPA_NAT_INDEX_TABLE_ENTRY_SIZE * expn_table_entries);\n\n\tIPADBG(\"returning from ipa_nati_reset_tbl()\\n\");\n\treturn;\n}\n\nint ipa_nati_add_ipv4_tbl(uint32_t public_ip_addr,\n\t\t\t\tuint16_t number_of_entries,\n\t\t\t\tuint32_t *tbl_hdl)\n{\n\tstruct ipa_ioc_nat_alloc_mem mem;\n\tuint8_t tbl_indx = ipv4_nat_cache.table_cnt;\n\tuint16_t table_entries, expn_table_entries;\n\tint ret;\n\n\t*tbl_hdl = 0;\n\t/* Allocate table */\n\tmemset(&mem, 0, sizeof(mem));\n\tret = ipa_nati_alloc_table(number_of_entries,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t &mem,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t &table_entries,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t &expn_table_entries);\n\tif (0 != ret) {\n\t\tIPAERR(\"unable to allocate nat table\\n\");\n\t\treturn -ENOMEM;\n\t}\n\n\t/* Update the cache\n\t\t The (IPA_NAT_UNUSED_BASE_ENTRIES/2) indicates zero entry entries\n\t\t for both base and expansion table\n\t*/\n\tret = ipa_nati_update_cache(&mem,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpublic_ip_addr,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttable_entries,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\texpn_table_entries);\n\tif (0 != ret) {\n\t\tIPAERR(\"unable to update cache Error: %d\\n\", ret);\n\t\treturn -EINVAL;\n\t}\n\n\t/* Reset the nat table before posting init cmd */\n\tipa_nati_reset_tbl(tbl_indx);\n\n\t/* Initialize the ipa hw with nat table dimensions */\n\tret = ipa_nati_post_ipv4_init_cmd(tbl_indx);\n\tif (0 != ret) {\n\t\tIPAERR(\"unable to post nat_init command Error %d\\n\", ret);\n\t\treturn -EINVAL;\n\t}\n\n\t/* Return table handle */\n\tipv4_nat_cache.table_cnt++;\n\t*tbl_hdl = ipv4_nat_cache.table_cnt;\n\n#ifdef NAT_DUMP\n\tipa_nat_dump_ipv4_table(*tbl_hdl);\n#endif\n\treturn 0;\n}\n\nint ipa_nati_alloc_table(uint16_t number_of_entries,\n\t\t\t\tstruct ipa_ioc_nat_alloc_mem *mem,\n\t\t\t\tuint16_t *table_entries,\n\t\t\t\tuint16_t *expn_table_entries)\n{\n\tint fd = 0, ret;\n\tuint16_t total_entries;\n\n\t/* Copy the table name */\n\tstrlcpy(mem->dev_name, NAT_DEV_NAME, IPA_RESOURCE_NAME_MAX);\n\n\t/* Calculate the size for base table and expansion table */\n\t*table_entries = (uint16_t)(number_of_entries * IPA_NAT_BASE_TABLE_PERCENTAGE);\n\tif (*table_entries == 0) {\n\t\t*table_entries = 1;\n\t}\n\tif (GetNearest2Power(*table_entries, table_entries)) {\n\t\tIPAERR(\"unable to calculate power of 2\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t*expn_table_entries = (uint16_t)(number_of_entries * IPA_NAT_EXPANSION_TABLE_PERCENTAGE);\n\tGetNearestEven(*expn_table_entries, expn_table_entries);\n\n\ttotal_entries = (*table_entries)+(*expn_table_entries);\n\n\t/* Calclate the memory size for both table and index table entries */\n\tmem->size = (IPA_NAT_TABLE_ENTRY_SIZE * total_entries);\n\tIPADBG(\"Nat Table size: %d\\n\", mem->size);\n\tmem->size += (IPA_NAT_INDEX_TABLE_ENTRY_SIZE * total_entries);\n\tIPADBG(\"Nat Base and Index Table size: %d\\n\", mem->size);\n\n\tif (!ipv4_nat_cache.ipa_fd) {\n\t\tfd = open(IPA_DEV_NAME, O_RDONLY);\n\t\tif (fd < 0) {\n\t\t\tperror(\"ipa_nati_alloc_table(): open error value:\");\n\t\t\tIPAERR(\"unable to open ipa device\\n\");\n\t\t\treturn -EIO;\n\t\t}\n\t\tipv4_nat_cache.ipa_fd = fd;\n\t}\n\n\tret = CreateNatDevice(mem);\n\treturn ret;\n}\n\n\nint ipa_nati_update_cache(struct ipa_ioc_nat_alloc_mem *mem,\n\t\t\t\tuint32_t public_addr,\n\t\t\t\tuint16_t tbl_entries,\n\t\t\t\tuint16_t expn_tbl_entries)\n{\n\tuint32_t index = ipv4_nat_cache.table_cnt;\n\tchar *ipv4_rules_addr = NULL;\n\n\tint fd = 0;\n\tint flags = MAP_SHARED;\n\tint prot = PROT_READ | PROT_WRITE;\n\toff_t offset = 0;\n#ifdef IPA_ON_R3PC\n\tint ret = 0;\n\tuint32_t nat_mem_offset = 0;\n#endif\n\n\tipv4_nat_cache.ip4_tbl[index].valid = IPA_NAT_TABLE_VALID;\n\tipv4_nat_cache.ip4_tbl[index].public_addr = public_addr;\n\tipv4_nat_cache.ip4_tbl[index].size = mem->size;\n\tipv4_nat_cache.ip4_tbl[index].tbl_addr_offset = mem->offset;\n\n\tipv4_nat_cache.ip4_tbl[index].table_entries = tbl_entries;\n\tipv4_nat_cache.ip4_tbl[index].expn_table_entries = expn_tbl_entries;\n\n\tIPADBG(\"num of ipv4 rules:%d\\n\", tbl_entries);\n\tIPADBG(\"num of ipv4 expn rules:%d\\n\", expn_tbl_entries);\n\n\t/* allocate memory for nat index expansion table */\n\tif (NULL == ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta) {\n\t\tipv4_nat_cache.ip4_tbl[index].index_expn_table_meta =\n\t\t\t malloc(sizeof(struct ipa_nat_indx_tbl_meta_info) * expn_tbl_entries);\n\n\t\tif (NULL == ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta) {\n\t\t\tIPAERR(\"Fail to allocate ipv4 index expansion table meta\\n\");\n\t\t\treturn 0;\n\t\t}\n\n\t\tmemset(ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta,\n\t\t\t\t\t 0,\n\t\t\t\t\t sizeof(struct ipa_nat_indx_tbl_meta_info) * expn_tbl_entries);\n\t}\n\n\t/* Allocate memory for rule_id_array */\n\tif (NULL == ipv4_nat_cache.ip4_tbl[index].rule_id_array) {\n\t\tipv4_nat_cache.ip4_tbl[index].rule_id_array =\n\t\t\t malloc(sizeof(uint16_t) * (tbl_entries + expn_tbl_entries));\n\n\t\tif (NULL == ipv4_nat_cache.ip4_tbl[index].rule_id_array) {\n\t\t\tIPAERR(\"Fail to allocate rule id array\\n\");\n\t\t\treturn 0;\n\t\t}\n\n\t\tmemset(ipv4_nat_cache.ip4_tbl[index].rule_id_array,\n\t\t\t\t\t 0,\n\t\t\t\t\t sizeof(uint16_t) * (tbl_entries + expn_tbl_entries));\n\t}\n\n\n\t/* open the nat table */\n\tstrlcpy(mem->dev_name, NAT_DEV_FULL_NAME, IPA_RESOURCE_NAME_MAX);\n\tfd = open(mem->dev_name, O_RDWR);\n\tif (fd < 0) {\n\t\tperror(\"ipa_nati_update_cache(): open error value:\");\n\t\tIPAERR(\"unable to open nat device. Error:%d\\n\", fd);\n\t\treturn -EIO;\n\t}\n\n\t/* copy the nat table name */\n\tstrlcpy(ipv4_nat_cache.ip4_tbl[index].table_name,\n\t\t\t\t\tmem->dev_name,\n\t\t\t\t\tIPA_RESOURCE_NAME_MAX);\n\tipv4_nat_cache.ip4_tbl[index].nat_fd = fd;\n\n\t/* open the nat device Table */\n#ifndef IPA_ON_R3PC\n\tipv4_rules_addr = (void *)mmap(NULL, mem->size,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t prot, flags,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t fd, offset);\n#else\n\tIPADBG(\"user space r3pc\\n\");\n\tipv4_rules_addr = (void *)mmap((caddr_t)0, NAT_MMAP_MEM_SIZE,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t prot, flags,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t fd, offset);\n#endif\n\tif (NULL == ipv4_rules_addr) {\n\t\tperror(\"unable to mmap the memory\\n\");\n\t\treturn -EINVAL;\n\t}\n\n#ifdef IPA_ON_R3PC\n\tret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_GET_NAT_OFFSET, &nat_mem_offset);\n\tif (ret != 0) {\n\t\tperror(\"ipa_nati_post_ipv4_init_cmd(): ioctl error value\");\n\t\tIPAERR(\"unable to post ant offset cmd Error: %d\\n\", ret);\n\t\tIPADBG(\"ipa fd %d\\n\", ipv4_nat_cache.ipa_fd);\n\t\treturn -EIO;\n\t}\n\tipv4_rules_addr += nat_mem_offset;\n\tipv4_nat_cache.ip4_tbl[index].mmap_offset = nat_mem_offset;\n#endif\n\n\tIPADBG(\"mmap return value 0x%lx\\n\", (long unsigned int)ipv4_rules_addr);\n\n\tipv4_nat_cache.ip4_tbl[index].ipv4_rules_addr = ipv4_rules_addr;\n\n\tipv4_nat_cache.ip4_tbl[index].ipv4_expn_rules_addr =\n\tipv4_rules_addr + (IPA_NAT_TABLE_ENTRY_SIZE * tbl_entries);\n\n\tipv4_nat_cache.ip4_tbl[index].index_table_addr =\n\tipv4_rules_addr + (IPA_NAT_TABLE_ENTRY_SIZE * (tbl_entries + expn_tbl_entries));\n\n\tipv4_nat_cache.ip4_tbl[index].index_table_expn_addr =\n\tipv4_rules_addr +\n\t(IPA_NAT_TABLE_ENTRY_SIZE * (tbl_entries + expn_tbl_entries))+\n\t(IPA_NAT_INDEX_TABLE_ENTRY_SIZE * tbl_entries);\n\n\treturn 0;\n}\n\n/* comment: check the implementation once\n\t offset should be in terms of byes */\nint ipa_nati_post_ipv4_init_cmd(uint8_t tbl_index)\n{\n\tstruct ipa_ioc_v4_nat_init cmd;\n\tuint32_t offset = ipv4_nat_cache.ip4_tbl[tbl_index].tbl_addr_offset;\n\tint ret;\n\n\tcmd.tbl_index = tbl_index;\n\n\tcmd.ipv4_rules_offset = offset;\n\tcmd.expn_rules_offset = cmd.ipv4_rules_offset +\n\t(ipv4_nat_cache.ip4_tbl[tbl_index].table_entries * IPA_NAT_TABLE_ENTRY_SIZE);\n\n\tcmd.index_offset = cmd.expn_rules_offset +\n\t(ipv4_nat_cache.ip4_tbl[tbl_index].expn_table_entries * IPA_NAT_TABLE_ENTRY_SIZE);\n\n\tcmd.index_expn_offset = cmd.index_offset +\n\t(ipv4_nat_cache.ip4_tbl[tbl_index].table_entries * IPA_NAT_INDEX_TABLE_ENTRY_SIZE);\n\n\tcmd.table_entries  = ipv4_nat_cache.ip4_tbl[tbl_index].table_entries - 1;\n\tcmd.expn_table_entries = ipv4_nat_cache.ip4_tbl[tbl_index].expn_table_entries;\n\n\tcmd.ip_addr = ipv4_nat_cache.ip4_tbl[tbl_index].public_addr;\n\n\tret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_V4_INIT_NAT, &cmd);\n\tif (ret != 0) {\n\t\tperror(\"ipa_nati_post_ipv4_init_cmd(): ioctl error value\");\n\t\tIPAERR(\"unable to post init cmd Error: %d\\n\", ret);\n\t\tIPADBG(\"ipa fd %d\\n\", ipv4_nat_cache.ipa_fd);\n\t\treturn -EINVAL;\n\t}\n\tIPADBG(\"Posted IPA_IOC_V4_INIT_NAT to kernel successfully\\n\");\n\n\treturn 0;\n}\n\nint ipa_nati_del_ipv4_table(uint32_t tbl_hdl)\n{\n\tuint8_t index = (uint8_t)(tbl_hdl - 1);\n\tvoid *addr = (void *)ipv4_nat_cache.ip4_tbl[index].ipv4_rules_addr;\n\tstruct ipa_ioc_v4_nat_del del_cmd;\n\tint ret;\n\n\tif (!ipv4_nat_cache.ip4_tbl[index].valid) {\n\t\tIPAERR(\"invalid table handle passed\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t/* unmap the device memory from user space */\n#ifndef IPA_ON_R3PC\n\tmunmap(addr, ipv4_nat_cache.ip4_tbl[index].size);\n#else\n\taddr = (char *)addr - ipv4_nat_cache.ip4_tbl[index].mmap_offset;\n\tmunmap(addr, NAT_MMAP_MEM_SIZE);\n#endif\n\n\t/* close the file descriptor of nat device */\n\tif (close(ipv4_nat_cache.ip4_tbl[index].nat_fd)) {\n\t\tIPAERR(\"unable to close the file descriptor\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tdel_cmd.table_index = index;\n\tdel_cmd.public_ip_addr = ipv4_nat_cache.ip4_tbl[index].public_addr;\n\tret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_V4_DEL_NAT, &del_cmd);\n\tif (ret != 0) {\n\t\tperror(\"ipa_nati_del_ipv4_table(): ioctl error value\");\n\t\tIPAERR(\"unable to post nat del command init Error: %d\\n\", ret);\n\t\tIPADBG(\"ipa fd %d\\n\", ipv4_nat_cache.ipa_fd);\n\t\treturn -EINVAL;\n\t}\n\tIPADBG(\"posted IPA_IOC_V4_DEL_NAT to kernel successfully\\n\");\n\n\tfree(ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta);\n\tfree(ipv4_nat_cache.ip4_tbl[index].rule_id_array);\n\n\tmemset(&ipv4_nat_cache.ip4_tbl[index],\n\t\t\t\t 0,\n\t\t\t\t sizeof(ipv4_nat_cache.ip4_tbl[index]));\n\n\t/* Decrease the table count by 1*/\n\tipv4_nat_cache.table_cnt--;\n\n\treturn 0;\n}\n\nint ipa_nati_query_timestamp(uint32_t  tbl_hdl,\n\t\t\t\tuint32_t  rule_hdl,\n\t\t\t\tuint32_t  *time_stamp)\n{\n\tuint8_t tbl_index = (uint8_t)(tbl_hdl - 1);\n\tuint8_t expn_tbl = 0;\n\tuint16_t tbl_entry = 0;\n\tstruct ipa_nat_rule *tbl_ptr = NULL;\n\n\tif (!ipv4_nat_cache.ip4_tbl[tbl_index].valid) {\n\t\tIPAERR(\"invalid table handle\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tipa_nati_parse_ipv4_rule_hdl(tbl_index, (uint16_t)rule_hdl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t &expn_tbl, &tbl_entry);\n\n\ttbl_ptr =\n\t(struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_index].ipv4_rules_addr;\n\tif (expn_tbl) {\n\t\ttbl_ptr =\n\t\t\t (struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_index].ipv4_expn_rules_addr;\n\t}\n\n\t*time_stamp = Read32BitFieldValue(tbl_ptr[tbl_entry].ts_proto,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTIME_STAMP_FIELD);\n\treturn 0;\n}\n\nint ipa_nati_add_ipv4_rule(uint32_t tbl_hdl,\n\t\t\t\tconst ipa_nat_ipv4_rule *clnt_rule,\n\t\t\t\tuint32_t *rule_hdl)\n{\n\tstruct ipa_nat_ip4_table_cache *tbl_ptr;\n\tstruct ipa_nat_sw_rule sw_rule;\n\tstruct ipa_nat_indx_tbl_sw_rule index_sw_rule;\n\tuint16_t new_entry, new_index_tbl_entry;\n\n\tmemset(&sw_rule, 0, sizeof(sw_rule));\n\tmemset(&index_sw_rule, 0, sizeof(index_sw_rule));\n\n\t/* Generate rule from client input */\n\tif (ipa_nati_generate_rule(tbl_hdl, clnt_rule,\n\t\t\t\t\t&sw_rule, &index_sw_rule,\n\t\t\t\t\t&new_entry, &new_index_tbl_entry)) {\n\t\tIPAERR(\"unable to generate rule\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\ttbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_hdl-1];\n\tipa_nati_copy_ipv4_rule_to_hw(tbl_ptr, &sw_rule, new_entry, (uint8_t)(tbl_hdl-1));\n\tipa_nati_copy_ipv4_index_rule_to_hw(tbl_ptr,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&index_sw_rule,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnew_index_tbl_entry,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(uint8_t)(tbl_hdl-1));\n\n\tIPADBG(\"new entry:%d, new index entry: %d\\n\", new_entry, new_index_tbl_entry);\n\tif (ipa_nati_post_ipv4_dma_cmd((uint8_t)(tbl_hdl - 1), new_entry)) {\n\t\tIPAERR(\"unable to post dma command\\n\");\n\t\treturn -EIO;\n\t}\n\n\t/* Generate rule handle */\n\t*rule_hdl  = ipa_nati_make_rule_hdl((uint16_t)tbl_hdl, new_entry);\n\tif (!(*rule_hdl)) {\n\t\tIPAERR(\"unable to generate rule handle\\n\");\n\t\treturn -EINVAL;\n\t}\n\n#ifdef NAT_DUMP\n\tipa_nat_dump_ipv4_table(tbl_hdl);\n#endif\n\n\treturn 0;\n}\n\nint ipa_nati_generate_rule(uint32_t tbl_hdl,\n\t\t\t\tconst ipa_nat_ipv4_rule *clnt_rule,\n\t\t\t\tstruct ipa_nat_sw_rule *rule,\n\t\t\t\tstruct ipa_nat_indx_tbl_sw_rule *index_sw_rule,\n\t\t\t\tuint16_t *tbl_entry,\n\t\t\t\tuint16_t *indx_tbl_entry)\n{\n\tstruct ipa_nat_ip4_table_cache *tbl_ptr;\n\tuint16_t tmp;\n\n\tif (NULL == clnt_rule || NULL == index_sw_rule ||\n\t\t\tNULL == rule || NULL == tbl_entry  ||\n\t\t\tNULL == indx_tbl_entry) {\n\t\tIPAERR(\"invalid parameters\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\ttbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_hdl-1];\n\n\t*tbl_entry = ipa_nati_generate_tbl_rule(clnt_rule,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trule,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttbl_ptr);\n\tif (IPA_NAT_INVALID_NAT_ENTRY == *tbl_entry) {\n\t\tIPAERR(\"unable to generate table entry\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tindex_sw_rule->tbl_entry = *tbl_entry;\n\t*indx_tbl_entry = ipa_nati_generate_index_rule(clnt_rule,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t index_sw_rule,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t tbl_ptr);\n\tif (IPA_NAT_INVALID_NAT_ENTRY == *indx_tbl_entry) {\n\t\tIPAERR(\"unable to generate index table entry\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\trule->indx_tbl_entry = *indx_tbl_entry;\n\tif (*indx_tbl_entry >= tbl_ptr->table_entries) {\n\t\ttmp = *indx_tbl_entry - tbl_ptr->table_entries;\n\t\ttbl_ptr->index_expn_table_meta[tmp].prev_index = index_sw_rule->prev_index;\n\t}\n\n\treturn 0;\n}\n\nuint16_t ipa_nati_generate_tbl_rule(const ipa_nat_ipv4_rule *clnt_rule,\n\t\t\t\t\t\tstruct ipa_nat_sw_rule *sw_rule,\n\t\t\t\t\t\tstruct ipa_nat_ip4_table_cache *tbl_ptr)\n{\n\tuint32_t pub_ip_addr;\n\tuint16_t prev = 0, nxt_indx = 0, new_entry;\n\tstruct ipa_nat_rule *tbl = NULL, *expn_tbl = NULL;\n\n\tpub_ip_addr = tbl_ptr->public_addr;\n\n\ttbl = (struct ipa_nat_rule *)tbl_ptr->ipv4_rules_addr;\n\texpn_tbl = (struct ipa_nat_rule *)tbl_ptr->ipv4_expn_rules_addr;\n\n\t/* copy the values from client rule to sw rule */\n\tsw_rule->private_ip = clnt_rule->private_ip;\n\tsw_rule->private_port = clnt_rule->private_port;\n\tsw_rule->protocol = clnt_rule->protocol;\n\tsw_rule->public_port = clnt_rule->public_port;\n\tsw_rule->target_ip = clnt_rule->target_ip;\n\tsw_rule->target_port = clnt_rule->target_port;\n\n\t/* consider only public and private ip fields */\n\tsw_rule->ip_chksum = ipa_nati_calc_ip_cksum(pub_ip_addr,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclnt_rule->private_ip);\n\n\tif (IPPROTO_TCP == sw_rule->protocol ||\n\t\t\tIPPROTO_UDP == sw_rule->protocol) {\n\t\t/* consider public and private ip & port fields */\n\t\tsw_rule->tcp_udp_chksum = ipa_nati_calc_tcp_udp_cksum(\n\t\t\t pub_ip_addr,\n\t\t\t clnt_rule->public_port,\n\t\t\t clnt_rule->private_ip,\n\t\t\t clnt_rule->private_port);\n\t}\n\n\tsw_rule->rsvd1 = 0;\n\tsw_rule->enable = IPA_NAT_FLAG_DISABLE_BIT;\n\tsw_rule->next_index = 0;\n\n\t/*\n\t\tSW sets this timer to 0.\n\t\tThe assumption is that 0 is an invalid clock value and no clock\n\t\twraparounds are expected\n\t*/\n\tsw_rule->time_stamp = 0;\n\tsw_rule->rsvd2 = 0;\n\tsw_rule->prev_index = 0;\n\tsw_rule->indx_tbl_entry = 0;\n\n\tnew_entry = dst_hash(clnt_rule->target_ip,\n\t\t\t\t\t\t\t\t\t\t\t clnt_rule->target_port,\n\t\t\t\t\t\t\t\t\t\t\t clnt_rule->public_port,\n\t\t\t\t\t\t\t\t\t\t\t clnt_rule->protocol,\n\t\t\t\t\t\t\t\t\t\t\t tbl_ptr->table_entries-1);\n\n\t/* check whether there is any collision\n\t\t if no collision return */\n\tif (!Read16BitFieldValue(tbl[new_entry].ip_cksm_enbl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t ENABLE_FIELD)) {\n\t\tsw_rule->prev_index = 0;\n\t\tIPADBG(\"Destination Nat New Entry Index %d\\n\", new_entry);\n\t\treturn new_entry;\n\t}\n\n\t/* First collision */\n\tif (Read16BitFieldValue(tbl[new_entry].nxt_indx_pub_port,\n\t\t\t\t\t\t\t\t\t\t\t\t\tNEXT_INDEX_FIELD) == IPA_NAT_INVALID_NAT_ENTRY) {\n\t\tsw_rule->prev_index = new_entry;\n\t} else { /* check for more than one collision\t*/\n\t\t/* Find the IPA_NAT_DEL_TYPE_LAST entry in list */\n\t\tnxt_indx = Read16BitFieldValue(tbl[new_entry].nxt_indx_pub_port,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t NEXT_INDEX_FIELD);\n\n\t\twhile (nxt_indx != IPA_NAT_INVALID_NAT_ENTRY) {\n\t\t\tprev = nxt_indx;\n\n\t\t\tnxt_indx -= tbl_ptr->table_entries;\n\t\t\tnxt_indx = Read16BitFieldValue(expn_tbl[nxt_indx].nxt_indx_pub_port,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t NEXT_INDEX_FIELD);\n\n\t\t\t/* Handling error case */\n\t\t\tif (prev == nxt_indx) {\n\t\t\t\tIPAERR(\"Error: Prev index:%d and next:%d index should not be same\\n\", prev, nxt_indx);\n\t\t\t\treturn IPA_NAT_INVALID_NAT_ENTRY;\n\t\t\t}\n\t\t}\n\n\t\tsw_rule->prev_index = prev;\n\t}\n\n\t/* On collision check for the free entry in expansion table */\n\tnew_entry = ipa_nati_expn_tbl_free_entry(expn_tbl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t tbl_ptr->expn_table_entries);\n\n\tif (IPA_NAT_INVALID_NAT_ENTRY == new_entry) {\n\t\t/* Expansion table is full return*/\n\t\tIPAERR(\"expansion table is full\\n\");\n\t\treturn IPA_NAT_INVALID_NAT_ENTRY;\n\t}\n\tnew_entry += tbl_ptr->table_entries;\n\n\tIPADBG(\"new entry index %d\\n\", new_entry);\n\treturn new_entry;\n}\n\n/* returns expn table entry index */\nuint16_t ipa_nati_expn_tbl_free_entry(struct ipa_nat_rule *expn_tbl,\n\t\t\t\t\t\tuint16_t size)\n{\n\tint cnt;\n\n\tfor (cnt = 1; cnt < size; cnt++) {\n\t\tif (!Read16BitFieldValue(expn_tbl[cnt].ip_cksm_enbl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ENABLE_FIELD)) {\n\t\t\tIPADBG(\"new expansion table entry index %d\\n\", cnt);\n\t\t\treturn cnt;\n\t\t}\n\t}\n\n\tIPAERR(\"nat expansion table is full\\n\");\n\treturn 0;\n}\n\nuint16_t ipa_nati_generate_index_rule(const ipa_nat_ipv4_rule *clnt_rule,\n\t\t\t\t\t\tstruct ipa_nat_indx_tbl_sw_rule *sw_rule,\n\t\t\t\t\t\tstruct ipa_nat_ip4_table_cache *tbl_ptr)\n{\n\tstruct ipa_nat_indx_tbl_rule *indx_tbl, *indx_expn_tbl;\n\tuint16_t prev = 0, nxt_indx = 0, new_entry;\n\n\tindx_tbl =\n\t(struct ipa_nat_indx_tbl_rule *)tbl_ptr->index_table_addr;\n\tindx_expn_tbl =\n\t(struct ipa_nat_indx_tbl_rule *)tbl_ptr->index_table_expn_addr;\n\n\tnew_entry = src_hash(clnt_rule->private_ip,\n\t\t\t\t\t\t\t\t\t\t\t clnt_rule->private_port,\n\t\t\t\t\t\t\t\t\t\t\t clnt_rule->target_ip,\n\t\t\t\t\t\t\t\t\t\t\t clnt_rule->target_port,\n\t\t\t\t\t\t\t\t\t\t\t clnt_rule->protocol,\n\t\t\t\t\t\t\t\t\t\t\t tbl_ptr->table_entries-1);\n\n\t/* check whether there is any collision\n\t\t if no collision return */\n\tif (!Read16BitFieldValue(indx_tbl[new_entry].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\t\t\t\t\t\t\t INDX_TBL_TBL_ENTRY_FIELD)) {\n\t\tsw_rule->prev_index = 0;\n\t\tIPADBG(\"Source Nat Index Table Entry %d\\n\", new_entry);\n\t\treturn new_entry;\n\t}\n\n\t/* check for more than one collision\t*/\n\tif (Read16BitFieldValue(indx_tbl[new_entry].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\t\t\t\t\t\t\tINDX_TBL_NEXT_INDEX_FILED) == IPA_NAT_INVALID_NAT_ENTRY) {\n\t\tsw_rule->prev_index = new_entry;\n\t\tIPADBG(\"First collosion. Entry %d\\n\", new_entry);\n\t} else {\n\t\t/* Find the IPA_NAT_DEL_TYPE_LAST entry in list */\n\t\tnxt_indx = Read16BitFieldValue(indx_tbl[new_entry].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t INDX_TBL_NEXT_INDEX_FILED);\n\n\t\twhile (nxt_indx != IPA_NAT_INVALID_NAT_ENTRY) {\n\t\t\tprev = nxt_indx;\n\n\t\t\tnxt_indx -= tbl_ptr->table_entries;\n\t\t\tnxt_indx = Read16BitFieldValue(indx_expn_tbl[nxt_indx].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t INDX_TBL_NEXT_INDEX_FILED);\n\n\t\t\t/* Handling error case */\n\t\t\tif (prev == nxt_indx) {\n\t\t\t\tIPAERR(\"Error: Prev:%d and next:%d index should not be same\\n\", prev, nxt_indx);\n\t\t\t\treturn IPA_NAT_INVALID_NAT_ENTRY;\n\t\t\t}\n\t\t}\n\n\t\tsw_rule->prev_index = prev;\n\t}\n\n\t/* On collision check for the free entry in expansion table */\n\tnew_entry = ipa_nati_index_expn_get_free_entry(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t indx_expn_tbl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t tbl_ptr->expn_table_entries);\n\n\tif (IPA_NAT_INVALID_NAT_ENTRY == new_entry) {\n\t\t/* Expansion table is full return*/\n\t\tIPAERR(\"index expansion table is full\\n\");\n\t\treturn IPA_NAT_INVALID_NAT_ENTRY;\n\t}\n\tnew_entry += tbl_ptr->table_entries;\n\n\n\tif (sw_rule->prev_index == new_entry) {\n\t\tIPAERR(\"Error: prev_entry:%d \", sw_rule->prev_index);\n\t\tIPAERR(\"and new_entry:%d should not be same \", new_entry);\n\t\tIPAERR(\"infinite loop detected\\n\");\n\t\treturn IPA_NAT_INVALID_NAT_ENTRY;\n\t}\n\n\tIPADBG(\"index table entry %d\\n\", new_entry);\n\treturn new_entry;\n}\n\n/* returns index expn table entry index */\nuint16_t ipa_nati_index_expn_get_free_entry(\n\t\t\t\t\t\tstruct ipa_nat_indx_tbl_rule *indx_tbl,\n\t\t\t\t\t\tuint16_t size)\n{\n\tint cnt;\n\tfor (cnt = 1; cnt < size; cnt++) {\n\t\tif (!Read16BitFieldValue(indx_tbl[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t INDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\treturn cnt;\n\t\t}\n\t}\n\n\tIPAERR(\"nat index expansion table is full\\n\");\n\treturn 0;\n}\n\nvoid ipa_nati_write_next_index(uint8_t tbl_indx,\n\t\t\t\tnat_table_type tbl_type,\n\t\t\t\tuint16_t value,\n\t\t\t\tuint32_t offset)\n{\n\tstruct ipa_ioc_nat_dma_cmd *cmd;\n\n\tIPADBG(\"Updating next index field of table %d on collosion using dma\\n\", tbl_type);\n\tIPADBG(\"table index: %d, value: %d offset;%d\\n\", tbl_indx, value, offset);\n\n\tcmd = (struct ipa_ioc_nat_dma_cmd *)\n\tmalloc(sizeof(struct ipa_ioc_nat_dma_cmd)+\n\t\t\t\t sizeof(struct ipa_ioc_nat_dma_one));\n\tif (NULL == cmd) {\n\t\tIPAERR(\"unable to allocate memory\\n\");\n\t\treturn;\n\t}\n\n\tcmd->dma[0].table_index = tbl_indx;\n\tcmd->dma[0].base_addr = tbl_type;\n\tcmd->dma[0].data = value;\n\tcmd->dma[0].offset = offset;\n\n\tcmd->entries = 1;\n\tif (ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_NAT_DMA, cmd)) {\n\t\tperror(\"ipa_nati_post_ipv4_dma_cmd(): ioctl error value\");\n\t\tIPAERR(\"unable to call dma icotl to update next index\\n\");\n\t\tIPAERR(\"ipa fd %d\\n\", ipv4_nat_cache.ipa_fd);\n\t\tgoto fail;\n\t}\n\nfail:\n\tfree(cmd);\n\n\treturn;\n}\n\nvoid ipa_nati_copy_ipv4_rule_to_hw(\n\t\t\t\tstruct ipa_nat_ip4_table_cache *ipv4_cache,\n\t\t\t\tstruct ipa_nat_sw_rule *rule,\n\t\t\t\tuint16_t entry, uint8_t tbl_index)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\tuint16_t prev_entry = rule->prev_index;\n\tnat_table_type tbl_type;\n\tuint32_t offset = 0;\n\n\tif (entry < ipv4_cache->table_entries) {\n\t\ttbl_ptr = (struct ipa_nat_rule *)ipv4_cache->ipv4_rules_addr;\n\n\t\tmemcpy(&tbl_ptr[entry],\n\t\t\t\t\t rule,\n\t\t\t\t\t sizeof(struct ipa_nat_rule));\n\t} else {\n\t\ttbl_ptr = (struct ipa_nat_rule *)ipv4_cache->ipv4_expn_rules_addr;\n\t\tmemcpy(&tbl_ptr[entry - ipv4_cache->table_entries],\n\t\t\t\t\t rule,\n\t\t\t\t\t sizeof(struct ipa_nat_rule));\n\t}\n\n\t/* Update the previos entry next_index */\n\tif (IPA_NAT_INVALID_NAT_ENTRY != prev_entry) {\n\n\t\tif (prev_entry < ipv4_cache->table_entries) {\n\t\t\ttbl_type = IPA_NAT_BASE_TBL;\n\t\t\ttbl_ptr = (struct ipa_nat_rule *)ipv4_cache->ipv4_rules_addr;\n\t\t} else {\n\t\t\ttbl_type = IPA_NAT_EXPN_TBL;\n\t\t\t/* tbp_ptr is already pointing to expansion table\n\t\t\t\t no need to initialize it */\n\t\t\tprev_entry = prev_entry - ipv4_cache->table_entries;\n\t\t}\n\n\t\toffset = ipa_nati_get_entry_offset(ipv4_cache, tbl_type, prev_entry);\n\t\toffset += IPA_NAT_RULE_NEXT_FIELD_OFFSET;\n\n\t\tipa_nati_write_next_index(tbl_index, tbl_type, entry, offset);\n\t}\n\n\treturn;\n}\n\nvoid ipa_nati_copy_ipv4_index_rule_to_hw(\n\t\t\t\tstruct ipa_nat_ip4_table_cache *ipv4_cache,\n\t\t\t\tstruct ipa_nat_indx_tbl_sw_rule *indx_sw_rule,\n\t\t\t\tuint16_t entry,\n\t\t\t\tuint8_t tbl_index)\n{\n\tstruct ipa_nat_indx_tbl_rule *tbl_ptr;\n\tstruct ipa_nat_sw_indx_tbl_rule sw_rule;\n\tuint16_t prev_entry = indx_sw_rule->prev_index;\n\tnat_table_type tbl_type;\n\tuint16_t offset = 0;\n\n\tsw_rule.next_index = indx_sw_rule->next_index;\n\tsw_rule.tbl_entry = indx_sw_rule->tbl_entry;\n\n\tif (entry < ipv4_cache->table_entries) {\n\t\ttbl_ptr = (struct ipa_nat_indx_tbl_rule *)ipv4_cache->index_table_addr;\n\n\t\tmemcpy(&tbl_ptr[entry],\n\t\t\t\t\t &sw_rule,\n\t\t\t\t\t sizeof(struct ipa_nat_indx_tbl_rule));\n\t} else {\n\t\ttbl_ptr = (struct ipa_nat_indx_tbl_rule *)ipv4_cache->index_table_expn_addr;\n\n\t\tmemcpy(&tbl_ptr[entry - ipv4_cache->table_entries],\n\t\t\t\t\t &sw_rule,\n\t\t\t\t\t sizeof(struct ipa_nat_indx_tbl_rule));\n\t}\n\n\t/* Update the next field of previous entry on collosion */\n\tif (IPA_NAT_INVALID_NAT_ENTRY != prev_entry) {\n\t\tif (prev_entry < ipv4_cache->table_entries) {\n\t\t\ttbl_type = IPA_NAT_INDX_TBL;\n\t\t\ttbl_ptr = (struct ipa_nat_indx_tbl_rule *)ipv4_cache->index_table_addr;\n\t\t} else {\n\t\t\ttbl_type = IPA_NAT_INDEX_EXPN_TBL;\n\t\t\t/* tbp_ptr is already pointing to expansion table\n\t\t\t no need to initialize it */\n\t\t\tprev_entry = prev_entry - ipv4_cache->table_entries;\n\t\t}\n\n\t\toffset = ipa_nati_get_index_entry_offset(ipv4_cache, tbl_type, prev_entry);\n\t\toffset += IPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET;\n\n\t\tIPADBG(\"Updating next index field of index table on collosion using dma()\\n\");\n\t\tipa_nati_write_next_index(tbl_index, tbl_type, entry, offset);\n\t}\n\n\treturn;\n}\n\nint ipa_nati_post_ipv4_dma_cmd(uint8_t tbl_indx,\n\t\t\t\tuint16_t entry)\n{\n\tstruct ipa_ioc_nat_dma_cmd *cmd;\n\tstruct ipa_nat_rule *tbl_ptr;\n\tuint32_t offset = ipv4_nat_cache.ip4_tbl[tbl_indx].tbl_addr_offset;\n\tint ret = 0;\n\n\tcmd = (struct ipa_ioc_nat_dma_cmd *)\n\tmalloc(sizeof(struct ipa_ioc_nat_dma_cmd)+\n\t\t\t\t sizeof(struct ipa_ioc_nat_dma_one));\n\tif (NULL == cmd) {\n\t\tIPAERR(\"unable to allocate memory\\n\");\n\t\treturn -ENOMEM;\n\t}\n\n\tif (entry < ipv4_nat_cache.ip4_tbl[tbl_indx].table_entries) {\n\t\ttbl_ptr =\n\t\t\t (struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_rules_addr;\n\n\t\tcmd->dma[0].table_index = tbl_indx;\n\t\tcmd->dma[0].base_addr = IPA_NAT_BASE_TBL;\n\t\tcmd->dma[0].data = IPA_NAT_FLAG_ENABLE_BIT_MASK;\n\n\t\tcmd->dma[0].offset = (char *)&tbl_ptr[entry] - (char *)tbl_ptr;\n\t\tcmd->dma[0].offset += IPA_NAT_RULE_FLAG_FIELD_OFFSET;\n\t} else {\n\t\ttbl_ptr =\n\t\t\t (struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_expn_rules_addr;\n\t\tentry = entry - ipv4_nat_cache.ip4_tbl[tbl_indx].table_entries;\n\n\t\tcmd->dma[0].table_index = tbl_indx;\n\t\tcmd->dma[0].base_addr = IPA_NAT_EXPN_TBL;\n\t\tcmd->dma[0].data = IPA_NAT_FLAG_ENABLE_BIT_MASK;\n\n\t\tcmd->dma[0].offset = (char *)&tbl_ptr[entry] - (char *)tbl_ptr;\n\t\tcmd->dma[0].offset += IPA_NAT_RULE_FLAG_FIELD_OFFSET;\n\t\tcmd->dma[0].offset += offset;\n\t}\n\n\tcmd->entries = 1;\n\tif (ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_NAT_DMA, cmd)) {\n\t\tperror(\"ipa_nati_post_ipv4_dma_cmd(): ioctl error value\");\n\t\tIPAERR(\"unable to call dma icotl\\n\");\n\t\tIPADBG(\"ipa fd %d\\n\", ipv4_nat_cache.ipa_fd);\n\t\tret = -EIO;\n\t\tgoto fail;\n\t}\n\tIPADBG(\"posted IPA_IOC_NAT_DMA to kernel successfully during add operation\\n\");\n\n\nfail:\n\tfree(cmd);\n\n\treturn ret;\n}\n\n\nint ipa_nati_del_ipv4_rule(uint32_t tbl_hdl,\n\t\t\t\tuint32_t rule_hdl)\n{\n\tuint8_t expn_tbl;\n\tuint16_t tbl_entry;\n\tstruct ipa_nat_ip4_table_cache *tbl_ptr;\n\tdel_type rule_pos;\n\tuint8_t tbl_indx = (uint8_t)(tbl_hdl - 1);\n\n\t/* Parse the rule handle */\n\tipa_nati_parse_ipv4_rule_hdl(tbl_indx, (uint16_t)rule_hdl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t &expn_tbl, &tbl_entry);\n\tif (IPA_NAT_INVALID_NAT_ENTRY == tbl_entry) {\n\t\tIPAERR(\"Invalid Rule Entry\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tIPADBG(\"Delete below rule\\n\");\n\tIPADBG(\"tbl_entry:%d expn_tbl:%d\\n\", tbl_entry, expn_tbl);\n\n\ttbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_indx];\n\tif (!tbl_ptr->valid) {\n\t\tIPAERR(\"invalid table handle\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tipa_nati_find_rule_pos(tbl_ptr, expn_tbl,\n\t\t\t\t\t\t\t\t\t\t\t\t tbl_entry, &rule_pos);\n\tIPADBG(\"rule_pos:%d\\n\", rule_pos);\n\n\tif (ipa_nati_post_del_dma_cmd(tbl_indx, tbl_entry,\n\t\t\t\t\texpn_tbl, rule_pos)) {\n\t\treturn -EINVAL;\n\t}\n\n\tipa_nati_del_dead_ipv4_head_nodes(tbl_indx);\n\n\t/* Reset rule_id_array entry */\n\tipv4_nat_cache.ip4_tbl[tbl_indx].rule_id_array[rule_hdl-1] =\n\tIPA_NAT_INVALID_NAT_ENTRY;\n\n#ifdef NAT_DUMP\n\tIPADBG(\"Dumping Table after deleting rule\\n\");\n\tipa_nat_dump_ipv4_table(tbl_hdl);\n#endif\n\n\treturn 0;\n}\n\nvoid ReorderCmds(struct ipa_ioc_nat_dma_cmd *cmd, int size)\n{\n\tint indx_tbl_start = 0, cnt, cnt1;\n\tstruct ipa_ioc_nat_dma_cmd *tmp;\n\n\tIPADBG(\"called ReorderCmds() with entries :%d\\n\", cmd->entries);\n\n\tfor (cnt = 0; cnt < cmd->entries; cnt++) {\n\t\tif (cmd->dma[cnt].base_addr == IPA_NAT_INDX_TBL ||\n\t\t\t\tcmd->dma[cnt].base_addr == IPA_NAT_INDEX_EXPN_TBL) {\n\t\t\tindx_tbl_start = cnt;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (indx_tbl_start == 0) {\n\t\tIPADBG(\"Reorder not needed\\n\");\n\t\treturn;\n\t}\n\n\ttmp = (struct ipa_ioc_nat_dma_cmd *)malloc(size);\n\tif (tmp == NULL) {\n\t\tIPAERR(\"unable to allocate memory\\n\");\n\t\treturn;\n\t}\n\n\tcnt1 = 0;\n\ttmp->entries = cmd->entries;\n\tfor (cnt = indx_tbl_start; cnt < cmd->entries; cnt++) {\n\t\ttmp->dma[cnt1] = cmd->dma[cnt];\n\t\tcnt1++;\n\t}\n\n\tfor (cnt = 0; cnt < indx_tbl_start; cnt++) {\n\t\ttmp->dma[cnt1] = cmd->dma[cnt];\n\t\tcnt1++;\n\t}\n\n\tmemset(cmd, 0, size);\n\tmemcpy(cmd, tmp, size);\n\tfree(tmp);\n\n\treturn;\n}\n\nint ipa_nati_post_del_dma_cmd(uint8_t tbl_indx,\n\t\t\t\tuint16_t cur_tbl_entry,\n\t\t\t\tuint8_t expn_tbl,\n\t\t\t\tdel_type rule_pos)\n{\n\n#define MAX_DMA_ENTRIES_FOR_DEL 3\n\n\tstruct ipa_nat_ip4_table_cache *cache_ptr;\n\tstruct ipa_nat_indx_tbl_rule *indx_tbl_ptr;\n\tstruct ipa_nat_rule *tbl_ptr;\n\tint ret = 0, size = 0;\n\n\tuint16_t indx_tbl_entry = IPA_NAT_INVALID_NAT_ENTRY;\n\tdel_type indx_rule_pos;\n\n\tstruct ipa_ioc_nat_dma_cmd *cmd;\n\tuint8_t no_of_cmds = 0;\n\n\tuint16_t prev_entry = IPA_NAT_INVALID_NAT_ENTRY;\n\tuint16_t next_entry = IPA_NAT_INVALID_NAT_ENTRY;\n\tuint16_t indx_next_entry = IPA_NAT_INVALID_NAT_ENTRY;\n\tuint16_t indx_next_next_entry = IPA_NAT_INVALID_NAT_ENTRY;\n\tuint16_t table_entry;\n\n\tsize = sizeof(struct ipa_ioc_nat_dma_cmd)+\n\t(MAX_DMA_ENTRIES_FOR_DEL * sizeof(struct ipa_ioc_nat_dma_one));\n\n\tcmd = (struct ipa_ioc_nat_dma_cmd *)malloc(size);\n\tif (NULL == cmd) {\n\t\tIPAERR(\"unable to allocate memory\\n\");\n\t\treturn -ENOMEM;\n\t}\n\n\tcache_ptr = &ipv4_nat_cache.ip4_tbl[tbl_indx];\n\tif (!expn_tbl) {\n\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_rules_addr;\n\t} else {\n\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;\n\t}\n\n\n\tif (!Read16BitFieldValue(tbl_ptr[cur_tbl_entry].ip_cksm_enbl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t ENABLE_FIELD)) {\n\t\tIPAERR(\"Deleting invalid(not enabled) rule\\n\");\n\t\tret = -EINVAL;\n\t\tgoto fail;\n\t}\n\n\tindx_tbl_entry =\n\t\tRead16BitFieldValue(tbl_ptr[cur_tbl_entry].sw_spec_params,\n\t\tSW_SPEC_PARAM_INDX_TBL_ENTRY_FIELD);\n\n\t/* ================================================\n\t Base Table rule Deletion\n\t ================================================*/\n\t/* Just delete the current rule by disabling the flag field */\n\tif (IPA_NAT_DEL_TYPE_ONLY_ONE == rule_pos) {\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_BASE_TBL;\n\t\tcmd->dma[no_of_cmds].data = IPA_NAT_FLAG_DISABLE_BIT_MASK;\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\t ipa_nati_get_entry_offset(cache_ptr,\n\t\t\t\t\tcmd->dma[no_of_cmds].base_addr,\n\t\t\t\t\tcur_tbl_entry);\n\t\tcmd->dma[no_of_cmds].offset += IPA_NAT_RULE_FLAG_FIELD_OFFSET;\n\t}\n\n\t/* Just update the protocol field to invalid */\n\telse if (IPA_NAT_DEL_TYPE_HEAD == rule_pos) {\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_BASE_TBL;\n\t\tcmd->dma[no_of_cmds].data = IPA_NAT_INVALID_PROTO_FIELD_VALUE;\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\t ipa_nati_get_entry_offset(cache_ptr,\n\t\t\t\t\tcmd->dma[no_of_cmds].base_addr,\n\t\t\t\t\tcur_tbl_entry);\n\t\tcmd->dma[no_of_cmds].offset += IPA_NAT_RULE_PROTO_FIELD_OFFSET;\n\n\t\tIPADBG(\"writing invalid proto: 0x%x\\n\", cmd->dma[no_of_cmds].data);\n\t}\n\n\t/*\n\t\t\t Update the previous entry of next_index field value\n\t\t\t with current entry next_index field value\n\t*/\n\telse if (IPA_NAT_DEL_TYPE_MIDDLE == rule_pos) {\n\t\tprev_entry =\n\t\t\tRead16BitFieldValue(tbl_ptr[cur_tbl_entry].sw_spec_params,\n\t\t\t\tSW_SPEC_PARAM_PREV_INDEX_FIELD);\n\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\t\tcmd->dma[no_of_cmds].data =\n\t\t\tRead16BitFieldValue(tbl_ptr[cur_tbl_entry].nxt_indx_pub_port,\n\t\t\t\t\tNEXT_INDEX_FIELD);\n\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_BASE_TBL;\n\t\tif (prev_entry >= cache_ptr->table_entries) {\n\t\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_EXPN_TBL;\n\t\t\tprev_entry -= cache_ptr->table_entries;\n\t\t}\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\tipa_nati_get_entry_offset(cache_ptr,\n\t\t\t\tcmd->dma[no_of_cmds].base_addr, prev_entry);\n\n\t\tcmd->dma[no_of_cmds].offset += IPA_NAT_RULE_NEXT_FIELD_OFFSET;\n\t}\n\n\t/*\n\t\t\t Reset the previous entry of next_index field with 0\n\t*/\n\telse if (IPA_NAT_DEL_TYPE_LAST == rule_pos) {\n\t\tprev_entry =\n\t\t\tRead16BitFieldValue(tbl_ptr[cur_tbl_entry].sw_spec_params,\n\t\t\t\tSW_SPEC_PARAM_PREV_INDEX_FIELD);\n\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\t\tcmd->dma[no_of_cmds].data = IPA_NAT_INVALID_NAT_ENTRY;\n\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_BASE_TBL;\n\t\tif (prev_entry >= cache_ptr->table_entries) {\n\t\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_EXPN_TBL;\n\t\t\tprev_entry -= cache_ptr->table_entries;\n\t\t}\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\tipa_nati_get_entry_offset(cache_ptr,\n\t\t\t\tcmd->dma[no_of_cmds].base_addr, prev_entry);\n\n\t\tcmd->dma[no_of_cmds].offset += IPA_NAT_RULE_NEXT_FIELD_OFFSET;\n\t}\n\n\t/* ================================================\n\t Base Table rule Deletion End\n\t ================================================*/\n\n\t/* ================================================\n\t Index Table rule Deletion\n\t ================================================*/\n\tipa_nati_find_index_rule_pos(cache_ptr,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t indx_tbl_entry,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t &indx_rule_pos);\n\tIPADBG(\"Index table entry: 0x%x\\n\", indx_tbl_entry);\n\tIPADBG(\"and position: %d\\n\", indx_rule_pos);\n\tif (indx_tbl_entry >= cache_ptr->table_entries) {\n\t\tindx_tbl_entry -= cache_ptr->table_entries;\n\t\tindx_tbl_ptr =\n\t\t\t (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_expn_addr;\n\t} else {\n\t\tindx_tbl_ptr =\n\t\t\t (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_addr;\n\t}\n\n\t/* Just delete the current rule by resetting nat_table_index field to 0 */\n\tif (IPA_NAT_DEL_TYPE_ONLY_ONE == indx_rule_pos) {\n\t\tno_of_cmds++;\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\t\tcmd->dma[no_of_cmds].data = IPA_NAT_INVALID_NAT_ENTRY;\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\tipa_nati_get_index_entry_offset(cache_ptr,\n\t\t\tcmd->dma[no_of_cmds].base_addr,\n\t\t\tindx_tbl_entry);\n\n\t\tcmd->dma[no_of_cmds].offset +=\n\t\t\tIPA_NAT_INDEX_RULE_NAT_INDEX_FIELD_OFFSET;\n\t}\n\n\t/* copy the next entry values to current entry */\n\telse if (IPA_NAT_DEL_TYPE_HEAD == indx_rule_pos) {\n\t\tnext_entry =\n\t\t\tRead16BitFieldValue(indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx,\n\t\t\t\tINDX_TBL_NEXT_INDEX_FILED);\n\n\t\tnext_entry -= cache_ptr->table_entries;\n\n\t\tno_of_cmds++;\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\n\t\t/* Copy the nat_table_index field value of next entry */\n\t\tindx_tbl_ptr =\n\t\t\t (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_expn_addr;\n\t\tcmd->dma[no_of_cmds].data =\n\t\t\tRead16BitFieldValue(indx_tbl_ptr[next_entry].tbl_entry_nxt_indx,\n\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD);\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\tipa_nati_get_index_entry_offset(cache_ptr,\n\t\t\t\t\tcmd->dma[no_of_cmds].base_addr,\n\t\t\t\t\tindx_tbl_entry);\n\n\t\tcmd->dma[no_of_cmds].offset +=\n\t\t\tIPA_NAT_INDEX_RULE_NAT_INDEX_FIELD_OFFSET;\n\n\t\t/* Copy the next_index field value of next entry */\n\t\tno_of_cmds++;\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\t\tcmd->dma[no_of_cmds].data =\n\t\t\tRead16BitFieldValue(indx_tbl_ptr[next_entry].tbl_entry_nxt_indx,\n\t\t\t\tINDX_TBL_NEXT_INDEX_FILED);\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\tipa_nati_get_index_entry_offset(cache_ptr,\n\t\t\t\tcmd->dma[no_of_cmds].base_addr, indx_tbl_entry);\n\n\t\tcmd->dma[no_of_cmds].offset +=\n\t\t\tIPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET;\n\t\tindx_next_entry = next_entry;\n\t}\n\n\t/*\n\t\t\t Update the previous entry of next_index field value\n\t\t\t with current entry next_index field value\n\t*/\n\telse if (IPA_NAT_DEL_TYPE_MIDDLE == indx_rule_pos) {\n\t\tprev_entry = cache_ptr->index_expn_table_meta[indx_tbl_entry].prev_index;\n\n\t\tno_of_cmds++;\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\t\tcmd->dma[no_of_cmds].data =\n\t\t\tRead16BitFieldValue(indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx,\n\t\t\t\tINDX_TBL_NEXT_INDEX_FILED);\n\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;\n\t\tif (prev_entry >= cache_ptr->table_entries) {\n\t\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_INDEX_EXPN_TBL;\n\t\t\tprev_entry -= cache_ptr->table_entries;\n\t\t}\n\n\t\tIPADBG(\"prev_entry: %d update with cur next_index: %d\\n\",\n\t\t\t\tprev_entry, cmd->dma[no_of_cmds].data);\n\t\tIPADBG(\"prev_entry: %d exist in table_type:%d\\n\",\n\t\t\t\tprev_entry, cmd->dma[no_of_cmds].base_addr);\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\tipa_nati_get_index_entry_offset(cache_ptr,\n\t\t\t\tcmd->dma[no_of_cmds].base_addr, prev_entry);\n\n\t\tcmd->dma[no_of_cmds].offset +=\n\t\t\tIPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET;\n\t}\n\n\t/* Reset the previous entry next_index field with 0 */\n\telse if (IPA_NAT_DEL_TYPE_LAST == indx_rule_pos) {\n\t\tprev_entry = cache_ptr->index_expn_table_meta[indx_tbl_entry].prev_index;\n\n\t\tno_of_cmds++;\n\t\tcmd->dma[no_of_cmds].table_index = tbl_indx;\n\t\tcmd->dma[no_of_cmds].data = IPA_NAT_INVALID_NAT_ENTRY;\n\n\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;\n\t\tif (prev_entry >= cache_ptr->table_entries) {\n\t\t\tcmd->dma[no_of_cmds].base_addr = IPA_NAT_INDEX_EXPN_TBL;\n\t\t\tprev_entry -= cache_ptr->table_entries;\n\t\t}\n\n\t\tIPADBG(\"Reseting prev_entry: %d next_index\\n\", prev_entry);\n\t\tIPADBG(\"prev_entry: %d exist in table_type:%d\\n\",\n\t\t\tprev_entry, cmd->dma[no_of_cmds].base_addr);\n\n\t\tcmd->dma[no_of_cmds].offset =\n\t\t\t ipa_nati_get_index_entry_offset(cache_ptr,\n\t\t\t\t\tcmd->dma[no_of_cmds].base_addr, prev_entry);\n\n\t\tcmd->dma[no_of_cmds].offset +=\n\t\t\tIPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET;\n\t}\n\n\t/* ================================================\n\t Index Table rule Deletion End\n\t ================================================*/\n\tcmd->entries = no_of_cmds + 1;\n\n\tif (cmd->entries > 1) {\n\t\tReorderCmds(cmd, size);\n\t}\n\tif (ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_NAT_DMA, cmd)) {\n\t\tperror(\"ipa_nati_post_del_dma_cmd(): ioctl error value\");\n\t\tIPAERR(\"unable to post cmd\\n\");\n\t\tIPADBG(\"ipa fd %d\\n\", ipv4_nat_cache.ipa_fd);\n\t\tret = -EIO;\n\t\tgoto fail;\n\t}\n\n\t/* if entry exist in IPA_NAT_DEL_TYPE_MIDDLE of list\n\t\t\t Update the previous entry in sw specific parameters\n\t*/\n\tif (IPA_NAT_DEL_TYPE_MIDDLE == rule_pos) {\n\t\t/* Retrieve the current entry prev_entry value */\n\t\tprev_entry =\n\t\t\tRead16BitFieldValue(tbl_ptr[cur_tbl_entry].sw_spec_params,\n\t\t\t\tSW_SPEC_PARAM_PREV_INDEX_FIELD);\n\n\t\t/* Retrieve the next entry */\n\t\tnext_entry =\n\t\t\tRead16BitFieldValue(tbl_ptr[cur_tbl_entry].nxt_indx_pub_port,\n\t\t\t\tNEXT_INDEX_FIELD);\n\n\t\tnext_entry -= cache_ptr->table_entries;\n\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;\n\n\t\t/* copy the current entry prev_entry value to next entry*/\n\t\tUpdateSwSpecParams(&tbl_ptr[next_entry],\n\t\t\t\t\t\t\t\t\t\t\t IPA_NAT_SW_PARAM_PREV_INDX_BYTE,\n\t\t\t\t\t\t\t\t\t\t\t prev_entry);\n\t}\n\n\t/* Reset the other field values of current delete entry\n\t\t\t In case of IPA_NAT_DEL_TYPE_HEAD, don't reset */\n\tif (IPA_NAT_DEL_TYPE_HEAD != rule_pos) {\n\t\tmemset(&tbl_ptr[cur_tbl_entry], 0, sizeof(struct ipa_nat_rule));\n\t}\n\n\tif (indx_rule_pos == IPA_NAT_DEL_TYPE_HEAD) {\n\n    /* Update next next entry previous value to current\n       entry as we moved the next entry values\n       to current entry */\n\t\tindx_next_next_entry =\n\t\t\tRead16BitFieldValue(indx_tbl_ptr[indx_next_entry].tbl_entry_nxt_indx,\n\t\t\t\tINDX_TBL_NEXT_INDEX_FILED);\n\n\t\tif (indx_next_next_entry != 0 &&\n\t\t\tindx_next_next_entry >= cache_ptr->table_entries) {\n\n\t\t\tIPADBG(\"Next Next entry: %d\\n\", indx_next_next_entry);\n\t\t\tindx_next_next_entry -= cache_ptr->table_entries;\n\n\t\t\tIPADBG(\"Updating entry: %d prev index to: %d\\n\",\n\t\t\t\tindx_next_next_entry, indx_tbl_entry);\n\t\t\tcache_ptr->index_expn_table_meta[indx_next_next_entry].prev_index =\n\t\t\t\t indx_tbl_entry;\n\t\t}\n\n    /* Now reset the next entry as we copied\n\t\t\t\tthe next entry to current entry */\n\t\tIPADBG(\"Resetting, index table entry(Proper): %d\\n\",\n\t\t\t(cache_ptr->table_entries + indx_next_entry));\n\n    /* This resets both table entry and next index values */\n\t\tindx_tbl_ptr[indx_next_entry].tbl_entry_nxt_indx = 0;\n\n\t\t/*\n\t\t\t\t In case of IPA_NAT_DEL_TYPE_HEAD, update the sw specific parameters\n\t\t\t\t (index table entry) of base table entry\n\t\t*/\n\t\tindx_tbl_ptr =\n\t\t\t (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_addr;\n\t\ttable_entry =\n\t\t\t\tRead16BitFieldValue(indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx,\n\t\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD);\n\n\t\tif (table_entry >= cache_ptr->table_entries) {\n\t\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;\n\t\t\ttable_entry -= cache_ptr->table_entries;\n\t\t} else {\n\t\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_rules_addr;\n\t\t}\n\n\t\tUpdateSwSpecParams(&tbl_ptr[table_entry],\n\t\t\t\tIPA_NAT_SW_PARAM_INDX_TBL_ENTRY_BYTE,\n\t\t\t\tindx_tbl_entry);\n\t} else {\n\t\t/* Update the prev_entry value (in index_expn_table_meta)\n\t\t\t\t for the next_entry in list with current entry prev_entry value\n\t\t*/\n\t\tif (IPA_NAT_DEL_TYPE_MIDDLE == indx_rule_pos) {\n\t\t\tnext_entry =\n\t\t\t\tRead16BitFieldValue(indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx,\n\t\t\t\t\tINDX_TBL_NEXT_INDEX_FILED);\n\n\t\t\tif (next_entry >= cache_ptr->table_entries) {\n\t\t\t\tnext_entry -= cache_ptr->table_entries;\n\t\t\t}\n\n\t\t\tcache_ptr->index_expn_table_meta[next_entry].prev_index =\n\t\t\t\t cache_ptr->index_expn_table_meta[indx_tbl_entry].prev_index;\n\n\t\t\tcache_ptr->index_expn_table_meta[indx_tbl_entry].prev_index =\n\t\t\t\t IPA_NAT_INVALID_NAT_ENTRY;\n\t\t}\n\n\t\tIPADBG(\"At, indx_tbl_entry value: %d\\n\", indx_tbl_entry);\n\t\tIPADBG(\"At, indx_tbl_entry member address: %p\\n\",\n\t\t\t\t\t &indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx);\n\n\t\tindx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx = 0;\n\n\t}\n\nfail:\n\tfree(cmd);\n\n\treturn ret;\n}\n\nvoid ipa_nati_find_index_rule_pos(\n\t\t\t\tstruct ipa_nat_ip4_table_cache *cache_ptr,\n\t\t\t\tuint16_t tbl_entry,\n\t\t\t\tdel_type *rule_pos)\n{\n\tstruct ipa_nat_indx_tbl_rule *tbl_ptr;\n\n\tif (tbl_entry >= cache_ptr->table_entries) {\n\t\ttbl_ptr =\n\t\t\t (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_expn_addr;\n\n\t\ttbl_entry -= cache_ptr->table_entries;\n\t\tif (Read16BitFieldValue(tbl_ptr[tbl_entry].tbl_entry_nxt_indx,\n\t\t\t\t\tINDX_TBL_NEXT_INDEX_FILED) == IPA_NAT_INVALID_NAT_ENTRY) {\n\t\t\t*rule_pos = IPA_NAT_DEL_TYPE_LAST;\n\t\t} else {\n\t\t\t*rule_pos = IPA_NAT_DEL_TYPE_MIDDLE;\n\t\t}\n\t} else {\n\t\ttbl_ptr =\n\t\t\t (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_addr;\n\n\t\tif (Read16BitFieldValue(tbl_ptr[tbl_entry].tbl_entry_nxt_indx,\n\t\t\t\t\tINDX_TBL_NEXT_INDEX_FILED) == IPA_NAT_INVALID_NAT_ENTRY) {\n\t\t\t*rule_pos = IPA_NAT_DEL_TYPE_ONLY_ONE;\n\t\t} else {\n\t\t\t*rule_pos = IPA_NAT_DEL_TYPE_HEAD;\n\t\t}\n\t}\n}\n\nvoid ipa_nati_find_rule_pos(struct ipa_nat_ip4_table_cache *cache_ptr,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuint8_t expn_tbl,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuint16_t tbl_entry,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdel_type *rule_pos)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\n\tif (expn_tbl) {\n\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;\n\t\tif (Read16BitFieldValue(tbl_ptr[tbl_entry].nxt_indx_pub_port,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tNEXT_INDEX_FIELD) == IPA_NAT_INVALID_NAT_ENTRY) {\n\t\t\t*rule_pos = IPA_NAT_DEL_TYPE_LAST;\n\t\t} else {\n\t\t\t*rule_pos = IPA_NAT_DEL_TYPE_MIDDLE;\n\t\t}\n\t} else {\n\t\ttbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_rules_addr;\n\t\tif (Read16BitFieldValue(tbl_ptr[tbl_entry].nxt_indx_pub_port,\n\t\t\t\t\tNEXT_INDEX_FIELD) == IPA_NAT_INVALID_NAT_ENTRY) {\n\t\t\t*rule_pos = IPA_NAT_DEL_TYPE_ONLY_ONE;\n\t\t} else {\n\t\t\t*rule_pos = IPA_NAT_DEL_TYPE_HEAD;\n\t\t}\n\t}\n}\n\nvoid ipa_nati_del_dead_ipv4_head_nodes(uint8_t tbl_indx)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\tuint16_t cnt;\n\n\ttbl_ptr =\n\t(struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_rules_addr;\n\n\tfor (cnt = 0;\n\t\t\t cnt < ipv4_nat_cache.ip4_tbl[tbl_indx].table_entries;\n\t\t\t cnt++) {\n\n\t\tif (Read8BitFieldValue(tbl_ptr[cnt].ts_proto,\n\t\t\t\t\tPROTOCOL_FIELD) == IPA_NAT_INVALID_PROTO_FIELD_CMP\n\t\t\t\t&&\n\t\t\t\tRead16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,\n\t\t\t\t\tNEXT_INDEX_FIELD) == IPA_NAT_INVALID_NAT_ENTRY) {\n\t\t\t/* Delete the IPA_NAT_DEL_TYPE_HEAD node */\n\t\t\tIPADBG(\"deleting the dead node 0x%x\\n\", cnt);\n\t\t\tmemset(&tbl_ptr[cnt], 0, sizeof(struct ipa_nat_rule));\n\t\t}\n\t} /* end of for loop */\n\n\treturn;\n}\n\n\n/* ========================================================\n\t\t\t\t\t\tDebug functions\n\t ========================================================*/\n#ifdef NAT_DUMP\nvoid ipa_nat_dump_ipv4_table(uint32_t tbl_hdl)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\tstruct ipa_nat_indx_tbl_rule *indx_tbl_ptr;\n\tint cnt;\n\tuint8_t atl_one = 0;\n\n\tif (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||\n\t\t\ttbl_hdl > IPA_NAT_MAX_IP4_TBLS) {\n\t\tIPAERR(\"invalid table handle passed\\n\");\n\t\treturn;\n\t}\n\n\t/* Print ipv4 rules */\n\tIPADBG(\"Dumping ipv4 active rules:\\n\");\n\ttbl_ptr = (struct ipa_nat_rule *)\n\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;\n\tfor (cnt = 0;\n\t\t\t cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,\n\t\t\t\t\tENABLE_FIELD)) {\n\t\t\tatl_one = 1;\n\t\t\tipa_nati_print_rule(&tbl_ptr[cnt], cnt);\n\t\t}\n\t}\n\tif (!atl_one) {\n\t\tIPADBG(\"No active base rules, total: %d\\n\",\n\t\t\t\t\t ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries);\n\t}\n\tatl_one = 0;\n\n\t/* Print ipv4 expansion rules */\n\tIPADBG(\"Dumping ipv4 active expansion rules:\\n\");\n\ttbl_ptr = (struct ipa_nat_rule *)\n\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;\n\tfor (cnt = 0;\n\t\t\t cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,\n\t\t\t\t\tENABLE_FIELD)) {\n\t\t\tatl_one = 1;\n\t\t\tipa_nati_print_rule(&tbl_ptr[cnt],\n\t\t\t\t(cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries));\n\t\t}\n\t}\n\tif (!atl_one) {\n\t\tIPADBG(\"No active base expansion rules, total: %d\\n\",\n\t\t\t\t\t ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries);\n\t}\n\tatl_one = 0;\n\n\t/* Print ipv4 index rules */\n\tIPADBG(\"Dumping ipv4 index active rules:\\n\");\n\tindx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;\n\tfor (cnt = 0;\n\t\t\t cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\tatl_one = 1;\n\t\t\tipa_nati_print_index_rule(&indx_tbl_ptr[cnt], cnt, 0);\n\t\t}\n\t}\n\tif (!atl_one) {\n\t\tIPADBG(\"No active index table rules, total:%d\\n\",\n\t\t\t\t\t ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries);\n\t}\n\tatl_one = 0;\n\n\n\t/* Print ipv4 index expansion rules */\n\tIPADBG(\"Dumping ipv4 index expansion active rules:\\n\");\n\tindx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;\n\tfor (cnt = 0;\n\t\t\t cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\tatl_one = 1;\n\t\t\tipa_nati_print_index_rule(&indx_tbl_ptr[cnt],\n\t\t\t\t(cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries),\n\t\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_expn_table_meta[cnt].prev_index);\n\t\t}\n\t}\n\tif (!atl_one) {\n\t\tIPADBG(\"No active index expansion rules, total:%d\\n\",\n\t\t\t\t\t ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries);\n\t}\n\tatl_one = 0;\n\n}\n\nvoid ipa_nati_print_rule(\n\t\tstruct ipa_nat_rule *param,\n\t\tuint32_t rule_id)\n{\n\tstruct ipa_nat_sw_rule sw_rule;\n\tmemcpy(&sw_rule, param, sizeof(sw_rule));\n\tuint32_t ip_addr;\n\n\tIPADUMP(\"rule-id:%d  \", rule_id);\n\tip_addr = sw_rule.target_ip;\n\tIPADUMP(\"Trgt-IP:%d.%d.%d.%d\t\",\n\t\t\t\t((ip_addr & 0xFF000000) >> 24), ((ip_addr & 0x00FF0000) >> 16),\n\t\t\t((ip_addr & 0x0000FF00) >> 8), ((ip_addr & 0x000000FF)));\n\n\tIPADUMP(\"Trgt-Port:%d  Priv-Port:%d  \", sw_rule.target_port, sw_rule.private_port);\n\n\tip_addr = sw_rule.private_ip;\n\tIPADUMP(\"Priv-IP:%d.%d.%d.%d \",\n\t\t\t\t\t\t\t((ip_addr & 0xFF000000) >> 24), ((ip_addr & 0x00FF0000) >> 16),\n\t\t\t\t\t\t\t((ip_addr & 0x0000FF00) >> 8), ((ip_addr & 0x000000FF)));\n\n\tIPADUMP(\"Pub-Port:%d\tNxt-indx:%d  \", sw_rule.public_port, sw_rule.next_index);\n\tIPADUMP(\"IP-cksm-delta:0x%x  En-bit:0x%x\t\", sw_rule.ip_chksum, sw_rule.enable);\n\tIPADUMP(\"TS:0x%x\tProto:0x%x\t\", sw_rule.time_stamp, sw_rule.protocol);\n\tIPADUMP(\"Prv-indx:%d\tindx_tbl_entry:%d\t\", sw_rule.prev_index, sw_rule.indx_tbl_entry);\n\tIPADUMP(\"Tcp-udp-cksum-delta:0x%x\", sw_rule.tcp_udp_chksum);\n\tIPADUMP(\"\\n\");\n\treturn;\n}\n\nvoid ipa_nati_print_index_rule(\n\t\tstruct ipa_nat_indx_tbl_rule *param,\n\t\tuint32_t rule_id, uint16_t prev_indx)\n{\n\tstruct ipa_nat_sw_indx_tbl_rule sw_rule;\n\tmemcpy(&sw_rule, param, sizeof(sw_rule));\n\n\tIPADUMP(\"rule-id:%d  Table_entry:%d  Next_index:%d, prev_indx:%d\",\n\t\t\t\t\t  rule_id, sw_rule.tbl_entry, sw_rule.next_index, prev_indx);\n\tIPADUMP(\"\\n\");\n\treturn;\n}\n\nint ipa_nati_query_nat_rules(\n\t\tuint32_t tbl_hdl,\n\t\tnat_table_type tbl_type)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\tstruct ipa_nat_indx_tbl_rule *indx_tbl_ptr;\n\tint cnt = 0, ret = 0;\n\n\tif (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||\n\t\t\ttbl_hdl > IPA_NAT_MAX_IP4_TBLS) {\n\t\tIPAERR(\"invalid table handle passed\\n\");\n\t\treturn ret;\n\t}\n\n\t/* Print ipv4 rules */\n\tif (tbl_type == IPA_NAT_BASE_TBL) {\n\t\tIPADBG(\"Counting ipv4 active rules:\\n\");\n\t\ttbl_ptr = (struct ipa_nat_rule *)\n\t\t\t ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].ipv4_rules_addr;\n\t\tfor (cnt = 0;\n\t\t\t\t cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\t\t cnt++) {\n\t\t\tif (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,\n\t\t\t\t\t\tENABLE_FIELD)) {\n\t\t\t\tret++;\n\t\t\t}\n\t\t}\n\t\tif (!ret) {\n\t\t\tIPADBG(\"No active base rules\\n\");\n\t\t}\n\n\t\tIPADBG(\"Number of active base rules: %d\\n\", ret);\n\t}\n\n\t/* Print ipv4 expansion rules */\n\tif (tbl_type == IPA_NAT_EXPN_TBL) {\n\t\tIPADBG(\"Counting ipv4 active expansion rules:\\n\");\n\t\ttbl_ptr = (struct ipa_nat_rule *)\n\t\t\t ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].ipv4_expn_rules_addr;\n\t\tfor (cnt = 0;\n\t\t\t\t cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;\n\t\t\t\t cnt++) {\n\t\t\tif (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,\n\t\t\t\t\t\tENABLE_FIELD)) {\n\t\t\t\tret++;\n\t\t\t}\n\t\t}\n\t\tif (!ret) {\n\t\t\tIPADBG(\"No active base expansion rules\\n\");\n\t\t}\n\n\t\tIPADBG(\"Number of active base expansion rules: %d\\n\", ret);\n\t}\n\n\t/* Print ipv4 index rules */\n\tif (tbl_type == IPA_NAT_INDX_TBL) {\n\t\tIPADBG(\"Counting ipv4 index active rules:\\n\");\n\t\tindx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\t\t\t ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].index_table_addr;\n\t\tfor (cnt = 0;\n\t\t\t\t cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\t\t cnt++) {\n\t\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\t\tret++;\n\t\t\t}\n\t\t}\n\t\tif (!ret) {\n\t\t\tIPADBG(\"No active index table rules\\n\");\n\t\t}\n\n\t\tIPADBG(\"Number of active index table rules: %d\\n\", ret);\n\t}\n\n\t/* Print ipv4 index expansion rules */\n\tif (tbl_type == IPA_NAT_INDEX_EXPN_TBL) {\n\t\tIPADBG(\"Counting ipv4 index expansion active rules:\\n\");\n\t\tindx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\t\t\t ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].index_table_expn_addr;\n\t\tfor (cnt = 0;\n\t\t\t\t cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;\n\t\t\t\t cnt++) {\n\t\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\t\t\t\tret++;\n\t\t\t}\n\t\t}\n\n\t\tif (!ret)\n\t\t\tIPADBG(\"No active index expansion rules\\n\");\n\n\t\tIPADBG(\"Number of active index expansion rules: %d\\n\", ret);\n\t}\n\n\treturn ret;\n}\n#endif\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/src/ipa_nat_logi.c",
    "content": "/* \nCopyright (c) 2013, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\t\t* Redistributions of source code must retain the above copyright\n\t\t\tnotice, this list of conditions and the following disclaimer.\n\t\t* Redistributions in binary form must reproduce the above\n\t\t\tcopyright notice, this list of conditions and the following\n\t\t\tdisclaimer in the documentation and/or other materials provided\n\t\t\twith the distribution.\n\t\t* Neither the name of The Linux Foundation nor the names of its\n\t\t\tcontributors may be used to endorse or promote products derived\n\t\t\tfrom this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n/*!\n\t@file\n\tIPACM_log.cpp\n\n\t@brief\n\tThis file implements the IPAM log functionality.\n\n\t@Author\n\tSkylar Chang\n\n*/\n#include \"ipa_nat_logi.h\"\n#include <stdlib.h>\n#include <unistd.h>\n\nvoid log_nat_message(char *msg)\n{\n\t return;\n}\n\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/Android.mk",
    "content": "ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))\nifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH)))\n\nLOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_C_INCLUDES := $(LOCAL_PATH)/\nLOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ipanat/inc\n\nLOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include\nLOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr\n\nLOCAL_MODULE := ipa_nat_test\nLOCAL_SRC_FILES := ipa_nat_test000.c \\\n\t\tipa_nat_test001.c \\\n\t\tipa_nat_test002.c \\\n\t\tipa_nat_test003.c \\\n\t\tipa_nat_test004.c \\\n\t\tipa_nat_test005.c \\\n\t\tipa_nat_test006.c \\\n\t\tipa_nat_test007.c \\\n\t\tipa_nat_test008.c \\\n\t\tipa_nat_test009.c \\\n\t\tipa_nat_test010.c \\\n\t\tipa_nat_test011.c \\\n\t\tipa_nat_test012.c \\\n\t\tipa_nat_test013.c \\\n\t\tipa_nat_test014.c \\\n\t\tipa_nat_test015.c \\\n\t\tipa_nat_test016.c \\\n\t\tipa_nat_test017.c \\\n\t\tipa_nat_test018.c \\\n\t\tipa_nat_test019.c \\\n\t\tipa_nat_test020.c \\\n\t\tipa_nat_test021.c \\\n\t\tipa_nat_test022.c \\\n\t\tmain.c\n\n\nLOCAL_SHARED_LIBRARIES := libipanat\n\nLOCAL_MODULE_TAGS := debug\nLOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/kernel-tests/ip_accelerator\n\ninclude $(BUILD_EXECUTABLE)\n\nendif # $(TARGET_ARCH)\nendif\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/Makefile.am",
    "content": "AM_CPPFLAGS = -I./../inc \\\n\t      -I$(top_srcdir)/ipanat/inc\n\nAM_CPPFLAGS += -Wall -Wundef -Wno-trigraphs\nAM_CPPFLAGS += -g\n\nipanattest_SOURCES = ipa_nat_test000.c \\\n\t\tipa_nat_test001.c \\\n\t\tipa_nat_test002.c \\\n\t\tipa_nat_test003.c \\\n\t\tipa_nat_test004.c \\\n\t\tipa_nat_test005.c \\\n\t\tipa_nat_test006.c \\\n\t\tipa_nat_test007.c \\\n\t\tipa_nat_test008.c \\\n\t\tipa_nat_test009.c \\\n\t\tipa_nat_test010.c \\\n\t\tipa_nat_test011.c \\\n\t\tipa_nat_test012.c \\\n\t\tipa_nat_test013.c \\\n\t\tipa_nat_test014.c \\\n\t\tipa_nat_test015.c \\\n\t\tipa_nat_test016.c \\\n\t\tipa_nat_test017.c \\\n\t\tipa_nat_test018.c \\\n\t\tipa_nat_test019.c \\\n\t\tipa_nat_test020.c \\\n\t\tipa_nat_test021.c \\\n\t\tipa_nat_test022.c \\\n\t\tmain.c\n\n\nbin_PROGRAMS  =  ipanattest\n\nrequiredlibs =  ../src/libipanat.la\n\nipanattest_LDADD =  $(requiredlibs)\n\nLOCAL_MODULE := libipanat\nLOCAL_PRELINK_MODULE := false\ninclude $(BUILD_SHARED_LIBRARY)\n\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/README.txt",
    "content": "1 To run this suite separately(each test case creates table and delete table) use below command\n   - To execute test suite nt times with n entries, command \"ipanatest sep nt n\"\n\n  Example:  To execute test suite 1 time with 100 entries, command \"ipanattest sep 100\"\n\n\n2. To run test suite not separately(creates table and delete table only once) use below command\n   - To execute test suite nt times with n entries, command \"ipanatest reg nt n\"\n\n   Example: To execute test suite 5 times with 32 entries, command \"ipanattest reg 5 32\"\n\n\n3. To run inotify regression test use command, \"ipanattest inotify nt\"\n\n   Example: To execute inotify 5 times, command \"ipanattest inotify 5\"\n\n\n4. if we just give command \"ipanattest\", runs test suite 1 time with 100 entries (non separate)\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test.h",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*===========================================================================\n\n                     INCLUDE FILES FOR MODULE\n\n===========================================================================*/\n#include \"stdint.h\"  /* uint32_t */\n#include \"stdio.h\"\n#include <netinet/in.h> /* for proto definitions */\n\n#define u32 uint32_t\n#define u16 uint16_t\n#define u8  uint8_t\n\n/*============ Preconditions to run NAT Test cases =========*/\n#define IPA_NAT_TEST_PRE_COND_TE  20\n\n#define CHECK_ERR1(x, tbl_hdl) \\\n  if(ipa_nat_validate_ipv4_table(tbl_hdl)) { \\\n    if(sep) {\\\n       ipa_nat_del_ipv4_tbl(tbl_hdl); \\\n     }\\\n    return -1;\\\n  }\\\n  if(x) { \\\n    IPAERR(\"%d\\n\", ret); \\\n    if(sep) {\\\n      ipa_nat_del_ipv4_tbl(tbl_hdl); \\\n     }\\\n     return -1; \\\n  }\n\n#define CHECK_ERR(x) if(x) { \\\n    IPAERR(\"%d\\n\", ret); \\\n    return -1;\\\n }\n\n#if 0\n#define CHECK_ERR(x) if(x) { \\\n    IPAERR(\"%d\\n\", ret); \\\n    if(sep) {\\\n      ipa_nat_del_ipv4_tbl(tbl_hdl); \\\n    }\\\n    return -1;\\\n }\n#endif\n\n#define IPADBG(fmt, args...) printf(\" %s:%d \" fmt, __FUNCTION__, __LINE__, ## args)\n#define IPAERR(fmt, args...) printf(\" %s:%d \" fmt, __FUNCTION__, __LINE__, ## args)\n\n#define NAT_DUMP\nint ipa_nat_validate_ipv4_table(u32);\n\nint ipa_nat_test000(int, u32, u8);\nint ipa_nat_test001(int, u32, u8);\nint ipa_nat_test002(int, u32, u8);\nint ipa_nat_test003(int, u32, u8);\nint ipa_nat_test004(int, u32, u8);\nint ipa_nat_test005(int, u32, u8);\nint ipa_nat_test006(int, u32, u8);\nint ipa_nat_test007(int, u32, u8);\nint ipa_nat_test008(int, u32, u8);\nint ipa_nat_test009(int, u32, u8);\nint ipa_nat_test010(int, u32, u8);\nint ipa_nat_test011(int, u32, u8);\nint ipa_nat_test012(int, u32, u8);\nint ipa_nat_test013(int, u32, u8);\nint ipa_nat_test014(int, u32, u8);\nint ipa_nat_test015(int, u32, u8);\nint ipa_nat_test016(int, u32, u8);\nint ipa_nat_test017(int, u32, u8);\nint ipa_nat_test018(int, u32, u8);\nint ipa_nat_test019(int, u32, u8);\nint ipa_nat_test020(int, u32, u8);\nint ipa_nat_test021(int, int);\nint ipa_nat_test022(int, u32, u8);\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test000.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test000.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. Delete ipv4 table\n*/\n/*===========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test000(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\n\tint ret;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\tif (0 != ret)\n\t{\n\t\tIPAERR(\"unable to create ipv4 nat table and returning Error:%d\\n\", ret);\n\t\treturn -1;\n\t}\n\tIPADBG(\"create nat ipv4 table successfully() \\n\");\n\n\tIPADBG(\"calling ipa_nat_del_ipv4_tbl() \\n\");\n\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\tif (0 != ret)\n\t{\n\t\tIPAERR(\"Unable to delete ipv4 nat table %d\\n\", ret);\n\t\treturn -1;\n\t}\n\tIPADBG(\"deleted ipv4 nat table successfully. Test passed \\n\");\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test001.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test001.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. Add ipv4 rule\n\t3. Delete ipv4 table\n*/\n/*===========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test001(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s()\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test002.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test002.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. Add ipv4 rule\n\t3. delete ipv4 rule\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test002(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s()\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test003.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n/*=========================================================================*/\n/*!\n\t@file\n\tIPA_NAT_ipa_nat_test003.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. Add ipv4 rule\n\t3. Add ipv4 rule\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test003(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl, rule_hdl1;\n\tipa_nat_ipv4_rule ipv4_rule;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test004.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test004.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. Query nat table handle\n\t3. Delete ipv4 table\n*/\n/*===========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test004(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret = 0;\n\tu32 tbl_hdl1 = 0;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl1);\n\t\tif(ret == 0)\n\t\t{\n\t\t\tIPAERR(\"able to delete table using invalid table handle\\n\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test005.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test005.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. Add ipv4 rule\n\t3. Delete ipv4 rule\n\t4. Add ipv4 rule\n\t5. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test005(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret = 0;\n\tu32 rule_hdl, rule_hdl1;\n\tipa_nat_ipv4_rule ipv4_rule;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tif (sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\t\tCHECK_ERR(ret);\n\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test006.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test006.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same ipv rules\n\t3. delete first followed by second\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test006(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret=0;\n\tu32 rule_hdl, rule_hdl1;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test007.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test007.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same ipv rules\n\t3. delete second followed by first\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test007(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl, rule_hdl1;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test008.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test008.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add 2 distinct rules\n\t3. delete first followed by second\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test008(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl, rule_hdl1;\n\tipa_nat_ipv4_rule ipv4_rule, ipv4_rule1;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\tipv4_rule1.target_ip = 0xC1171602; /* 193.23.22.2 */\n\tipv4_rule1.target_port = 1234;\n\tipv4_rule1.private_ip = 0xC2171602; /* 194.23.22.2 */\n\tipv4_rule1.private_port = 5678;\n\tipv4_rule1.protocol = IPPROTO_TCP;\n\tipv4_rule1.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test009.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test009.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add 2 distinct rules\n\t3. delete second followed by first\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test009(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl, rule_hdl1;\n\tipa_nat_ipv4_rule ipv4_rule, ipv4_rule1;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tipv4_rule1.target_ip = 0xC1171602; /* 193.23.22.2 */\n\tipv4_rule1.target_port = 1234;\n\tipv4_rule1.private_ip = 0xC2171602; /* 194.23.22.2 */\n\tipv4_rule1.private_port = 5678;\n\tipv4_rule1.protocol = IPPROTO_TCP;\n\tipv4_rule1.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test010.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test010.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add 3 distinct ipv4 rules\n\t3. delete first, second followed by last\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test010(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl, rule_hdl1, rule_hdl2;\n\tipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tipv4_rule1.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule1.target_port = 1235;\n\tipv4_rule1.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule1.private_port = 5679;\n\tipv4_rule1.protocol = IPPROTO_TCP;\n\tipv4_rule1.public_port = 9051;\n\n\tipv4_rule2.target_ip = 0xC1171602; /* 193.23.22.2 */\n\tipv4_rule2.target_port = 1235;\n\tipv4_rule2.private_ip = 0xC2171602; /* 194.23.22.2 */\n\tipv4_rule2.private_port = 5679;\n\tipv4_rule2.protocol = IPPROTO_TCP;\n\tipv4_rule2.public_port = 9051;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test011.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test011.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add 3 distinct ipv4 rules\n\t3. delete second, first followed by last\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test011(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl, rule_hdl1, rule_hdl2;\n\tipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tipv4_rule1.target_ip = 0xF1181601;\n\tipv4_rule1.target_port = 1555;\n\tipv4_rule1.private_ip = 0xF2151601;\n\tipv4_rule1.private_port = 5999;\n\tipv4_rule1.protocol = IPPROTO_TCP;\n\tipv4_rule1.public_port = 9111;\n\n\tipv4_rule2.target_ip = 0xC1166602;\n\tipv4_rule2.target_port = 1555;\n\tipv4_rule2.private_ip = 0xC2155602;\n\tipv4_rule2.private_port = 5777;\n\tipv4_rule2.protocol = IPPROTO_TCP;\n\tipv4_rule2.public_port = 9000;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test012.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test012.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add 3 distinct ipv4 rules\n\t3. Delete third, second, first\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\n\nint ipa_nat_test012(int totoal_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl, rule_hdl1, rule_hdl2;\n\tipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tipv4_rule1.target_ip = 0xD1171601;\n\tipv4_rule1.target_port = 3512;\n\tipv4_rule1.private_ip = 0xD2471601;\n\tipv4_rule1.private_port = 9997;\n\tipv4_rule1.protocol = IPPROTO_TCP;\n\tipv4_rule1.public_port = 8881;\n\n\tipv4_rule2.target_ip = 0xC1172452;\n\tipv4_rule2.target_port = 1895;\n\tipv4_rule2.private_ip = 0xC2172452;\n\tipv4_rule2.private_port = 6668;\n\tipv4_rule2.protocol = IPPROTO_TCP;\n\tipv4_rule2.public_port = 5551;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, totoal_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test013.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test013.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add 3 distinct ipv4 rules\n\t3. Delete third, first and second\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test013(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl, rule_hdl1, rule_hdl2;\n\tipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tipv4_rule1.target_ip = 0xC1171609; /* 193.23.22.9 */\n\tipv4_rule1.target_port = 1235;\n\tipv4_rule1.private_ip = 0xC2171609; /* 194.23.22.9 */\n\tipv4_rule1.private_port = 6579;\n\tipv4_rule1.protocol = IPPROTO_TCP;\n\tipv4_rule1.public_port = 8951;\n\n\tipv4_rule2.target_ip = 0xC1171606; /* 193.23.22.6 */\n\tipv4_rule2.target_port = 1235;\n\tipv4_rule2.private_ip = 0xC2171606; /* 194.23.22.6 */\n\tipv4_rule2.private_port = 7956;\n\tipv4_rule2.protocol = IPPROTO_TCP;\n\tipv4_rule2.public_port = 5109;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test014.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test014.cpp\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same 3 ipv rules\n\t3. delete first, second and third\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test014(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl1, rule_hdl2, rule_hdl3;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s()\\n\", __FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test015.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test015.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same 3 ipv rules\n\t3. delete first, third and second\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\n\nint ipa_nat_test015(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl1, rule_hdl2, rule_hdl3;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test016.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test016.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same 3 ipv rules\n\t3. delete second, first and third\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test016(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl1, rule_hdl2, rule_hdl3;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test017.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test017.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same 3 ipv rules\n\t3. delete second, third and first\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test017(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl1, rule_hdl2, rule_hdl3;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test018.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test018.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same 3 ipv rules\n\t3. delete third, second and first\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test018(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl1, rule_hdl2, rule_hdl3;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test019.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test019.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same 3 ipv rules\n\t3. delete third, first and second\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test019(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl1, rule_hdl2, rule_hdl3;\n\tipa_nat_ipv4_rule ipv4_rule;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test020.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test020.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same 4 ipv rules\n\t3. delete third, second, fourth and first\n\t4. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test020(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl1, rule_hdl2, rule_hdl3, rule_hdl4;\n\tipa_nat_ipv4_rule ipv4_rule;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl4);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl4);\n\tCHECK_ERR(ret);\n\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR(ret);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR(ret);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test021.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test021.c\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test021(int total_entries, int reg)\n{\n\n\tint ret, i;\n\tu32 tbl_hdl;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tfor(i=0; i<reg; i++)\n\t{\n\t\tIPADBG(\"executing %d th time:\\n\",i);\n\n\t\tIPADBG(\"calling ipa_nat_add_ipv4_tbl() \\n\");\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tif (0 != ret)\n\t\t{\n\t\t\tIPAERR(\"unable to create ipv4 nat table and returning Error:%d\\n\", ret);\n\t\t\tIPADBG(\"executed %d times:\\n\",i);\n\t\t\treturn -1;\n\t\t}\n\t\tIPADBG(\"create nat ipv4 table successfully() \\n\");\n\n\t\tIPADBG(\"calling ipa_nat_del_ipv4_tbl() \\n\");\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tif (0 != ret)\n\t\t{\n\t\t\tIPAERR(\"Unable to delete ipv4 nat table %d\\n\", ret);\n\t\t\tIPADBG(\"executed %d times:\\n\",i);\n\t\t\treturn -1;\n\t\t}\n\t\tIPADBG(\"deleted ipv4 nat table successfully. Test passed \\n\");\n\t}\n\n\tIPADBG(\"executed %d times:\\n\",(i+1));\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/ipa_nat_test022.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n/*=========================================================================*/\n/*!\n\t@file\n\tipa_nat_test022.cpp\n\n\t@brief\n\tVerify the following scenario:\n\t1. Add ipv4 table\n\t2. add same 3 ipv rules\n  3. delete Head and last entry\n  4. add 2 new same ip4 entries\n  5. Add head entry again\n\t6. Delete ipv4 table\n*/\n/*=========================================================================*/\n\n#include \"ipa_nat_test.h\"\n#include \"ipa_nat_drv.h\"\n\nint ipa_nat_test022(int total_entries, u32 tbl_hdl, u8 sep)\n{\n\tint ret;\n\tu32 rule_hdl1, rule_hdl2, rule_hdl3;\n\tipa_nat_ipv4_rule ipv4_rule, ipv4_rule2;\n\tu32 rule_hdl21, rule_hdl22;\n\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\t/* Rule 1 */\n\tipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */\n\tipv4_rule.private_port = 5678;\n\tipv4_rule.protocol = IPPROTO_TCP;\n\tipv4_rule.public_port = 9050;\n\n\t/* Rule 2*/\n\tipv4_rule.target_ip = 0xC1171604; /* 193.23.22.4 */\n\tipv4_rule.target_port = 1234;\n\tipv4_rule.private_ip = 0xC2171603; /* 194.23.22.3 */\n\tipv4_rule.private_port = 5680;\n\tipv4_rule.protocol = IPPROTO_UDP;\n\tipv4_rule.public_port = 9066;\n\n\tIPADBG(\"%s():\\n\",__FUNCTION__);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\tCHECK_ERR1(ret, tbl_hdl);\n\t}\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);\n\tCHECK_ERR1(ret, tbl_hdl);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);\n\tCHECK_ERR1(ret, tbl_hdl);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR1(ret, tbl_hdl);\n\n\t/* Delete head entry */\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);\n\tCHECK_ERR1(ret, tbl_hdl);\n\n\t/* Delete Last Entry */\n\tret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);\n\tCHECK_ERR1(ret, tbl_hdl);\n\n\t/* Add 2 different Entries */\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl21);\n\tCHECK_ERR1(ret, tbl_hdl);\n\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl22);\n\tCHECK_ERR1(ret, tbl_hdl);\n\n\t/* Add first entry again */\n\tret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);\n\tCHECK_ERR1(ret, tbl_hdl);\n\n\tif(sep)\n\t{\n\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\tCHECK_ERR1(ret, tbl_hdl);\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "data-ipa-cfg-mgr/ipanat/test/main.c",
    "content": "/*\n * Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *  * Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above\n *    copyright notice, this list of conditions and the following\n *    disclaimer in the documentation and/or other materials provided\n *    with the distribution.\n *  * Neither the name of The Linux Foundation nor the names of its\n *    contributors may be used to endorse or promote products derived\n *    from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <unistd.h>\n#include <string.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n\n#include \"ipa_nat_drv.h\"\n#include \"ipa_nat_drvi.h\"\n#include \"ipa_nat_test.h\"\n\nextern struct ipa_nat_cache ipv4_nat_cache;\n\nint chk_for_loop(u32 tbl_hdl)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\tstruct ipa_nat_indx_tbl_rule *indx_tbl_ptr;\n\tint cnt;\n\tuint16_t cur_entry;\n\n\tif (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||\n\t\t\ttbl_hdl > IPA_NAT_MAX_IP4_TBLS) {\n\t\tIPAERR(\"invalid table handle passed \\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tIPADBG(\"checking ipv4 rules:\\n\");\n\ttbl_ptr = (struct ipa_nat_rule *)\n\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;\n\tfor (cnt = 0;\n\t\tcnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\tcnt++) {\n\t\tif (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,ENABLE_FIELD)) {\n\t\t\tif(Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,\n\t\t\t\t\t\t\tNEXT_INDEX_FIELD) == cnt)\n\t\t\t{\n\t\t\t\tIPAERR(\"Infinite loop detected, entry\\n\");\n\t\t\t\tipa_nati_print_rule(&tbl_ptr[cnt], cnt);\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Print ipv4 expansion rules */\n\tIPADBG(\"checking ipv4 active expansion rules:\\n\");\n\ttbl_ptr = (struct ipa_nat_rule *)\n\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;\n\tfor (cnt = 0;\n\t\tcnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;\n\t\tcnt++) {\n\t\tif (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,\n\t\t\t\t\t\t\t\tENABLE_FIELD)) {\n\t\t\tcur_entry =\n\t\t\t\tcnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\tif (Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,\n\t\t\t\t\t\t\tNEXT_INDEX_FIELD) == cur_entry)\n\t\t\t{\n\t\t\t\tIPAERR(\"Infinite loop detected\\n\");\n\t\t\t\tipa_nati_print_rule(&tbl_ptr[cnt],\n\t\t\t\t\t(cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries));\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Print ipv4 index rules */\n\tIPADBG(\"checking ipv4 index active rules: \\n\");\n\tindx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;\n\tfor (cnt = 0;\n\t\t cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\tINDX_TBL_NEXT_INDEX_FILED) == cnt)\n\t\t\t{\n\t\t\t\tIPAERR(\"Infinite loop detected\\n\");\n\t\t\t\tipa_nati_print_index_rule(&indx_tbl_ptr[cnt], cnt, 0);\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Print ipv4 index expansion rules */\n\tIPADBG(\"Checking ipv4 index expansion active rules: \\n\");\n\tindx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;\n\tfor (cnt = 0;\n\t\tcnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\tcur_entry =\n\t\t\t\tcnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\tINDX_TBL_NEXT_INDEX_FILED) == cur_entry)\n\t\t\t{\n\t\t\t\tIPAERR(\"Infinite loop detected\\n\");\n\t\t\t\tipa_nati_print_index_rule(&indx_tbl_ptr[cnt],\n\t\t\t\t\t(cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries),\n\t\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl - 1].index_expn_table_meta[cnt].prev_index);\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\nuint8_t is_base_entry_valid(u32 tbl_hdl, u16 entry)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\n\tif (entry >\n\t\tipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries)\n\t{\n\t\ttbl_ptr = (struct ipa_nat_rule *)\n\t\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;\n\t\tentry -=\n\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t}\n\telse\n\t{\n\t\ttbl_ptr = (struct ipa_nat_rule *)\n\t\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;\n\t}\n\treturn (Read16BitFieldValue(tbl_ptr[entry].ip_cksm_enbl,\n\t\t\t\t\t\t\tENABLE_FIELD));\n}\n\nuint8_t is_index_entry_valid(u32 tbl_hdl, u16 entry)\n{\n\tstruct ipa_nat_indx_tbl_rule *tbl_ptr;\n\n\tif (entry >\n\t\tipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries)\n\t{\n\t\ttbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\t\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;\n\t\tentry -=\n\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t}\n\telse\n\t{\n\t\ttbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\t\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;\n\t}\n\tif (Read16BitFieldValue(tbl_ptr[entry].tbl_entry_nxt_indx,\n\t\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\treturn 1;\n\t}\n\telse\n\t{\n\t\treturn 0;\n\t}\n}\n\nint chk_for_validity(u32 tbl_hdl)\n{\n\tstruct ipa_nat_rule *tbl_ptr;\n\tstruct ipa_nat_indx_tbl_rule *indx_tbl_ptr;\n\tuint16_t nxt_index, prv_index;\n\tint cnt;\n\n\tif (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||\n\t\t\ttbl_hdl > IPA_NAT_MAX_IP4_TBLS) {\n\t\tIPAERR(\"invalid table handle passed \\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t/* Validate base table next_indx and prev_indx values */\n\tIPADBG(\"Validating ipv4 active rules: \\n\");\n\ttbl_ptr = (struct ipa_nat_rule *)\n\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;\n\tfor (cnt = 0;\n\t\tcnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,\n\t\t\t\t\t\tENABLE_FIELD)) {\n\t\t\tnxt_index =\n\t\t\tRead16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,\n\t\t\t\t\t\tNEXT_INDEX_FIELD);\n\t\t\tif (!is_base_entry_valid(tbl_hdl, nxt_index)) {\n\t\t\t\tIPAERR(\"Invalid next index found, entry:%d\\n\", cnt);\n\t\t\t}\n\t\t}\n\t}\n\n\tIPADBG(\"Validating ipv4 expansion active rules: \\n\");\n\ttbl_ptr = (struct ipa_nat_rule *)\n\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;\n\tfor (cnt = 0;\n\t\tcnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,\n\t\t\t\t\t\t\tENABLE_FIELD)) {\n\t\t\t/* Validate next index */\n\t\t\tnxt_index =\n\t\t\t\tRead16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,\n\t\t\t\t\t\t\t\t\tNEXT_INDEX_FIELD);\n\t\t\tif (!is_base_entry_valid(tbl_hdl, nxt_index)) {\n\t\t\t\tIPAERR(\"Invalid next index found, entry:%d\\n\", cnt);\n\t\t\t}\n\t\t\t/* Validate previous index */\n\t\t\tprv_index =\n\t\t\t\tRead16BitFieldValue(tbl_ptr[cnt].sw_spec_params,\n\t\t\t\t\t\tSW_SPEC_PARAM_PREV_INDEX_FIELD);\n\t\t\tif (!is_base_entry_valid(tbl_hdl, prv_index)) {\n\t\t\t\tIPAERR(\"Invalid Previous index found, entry:%d\\n\", cnt);\n\t\t\t}\n\t\t}\n\t}\n\n\tIPADBG(\"Validating ipv4 index active rules: \\n\");\n\tindx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\t\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;\n\tfor (cnt = 0;\n\t\tcnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\tnxt_index =\n\t\t\t\tRead16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\tINDX_TBL_NEXT_INDEX_FILED);\n\t\t\tif (!is_index_entry_valid(tbl_hdl, nxt_index)) {\n\t\t\t\tIPAERR(\"Invalid next index found, entry:%d\\n\", cnt);\n\t\t\t}\n\t\t}\n\t}\n\n\tIPADBG(\"Validating ipv4 index expansion active rules: \\n\");\n\tindx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)\n\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;\n\tfor (cnt = 0;\n\t\tcnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;\n\t\t\t cnt++) {\n\t\tif (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\t\tINDX_TBL_TBL_ENTRY_FIELD)) {\n\t\t\t/* Validate next index*/\n\t\t\tnxt_index =\n\t\t\t\tRead16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,\n\t\t\t\t\t\t\t\tINDX_TBL_NEXT_INDEX_FILED);\n\t\t\tif (!is_index_entry_valid(tbl_hdl, nxt_index)) {\n\t\t\t\tIPAERR(\"Invalid next index found, entry:%d\\n\", cnt);\n\t\t\t}\n\n\t\t\t/* Validate previous index*/\n\t\t\tprv_index =\n\t\t\t\tipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_expn_table_meta[cnt].prev_index;\n\n\t\t\tif (!is_index_entry_valid(tbl_hdl, prv_index)) {\n\t\t\t\tIPAERR(\"Invalid Previous index found, entry:%d\\n\", cnt);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nint ipa_nat_validate_ipv4_table(u32 tbl_hdl)\n{\n\tint ret = 0;\n\n\tret = chk_for_loop(tbl_hdl);\n\tif (ret)\n\t\treturn ret;\n\tret = chk_for_validity(tbl_hdl);\n\n\treturn ret;\n}\n\nint main(int argc, char* argv[])\n{\n\tint exec = 0, pass = 0, ret;\n\tint cnt, nt=1;\n\tint total_entries = 100;\n\tu8 sep = 0;\n\tu32 tbl_hdl = 0;\n\tu32 pub_ip_add = 0x011617c0;   /* \"192.23.22.1\" */\n\n\tIPADBG(\"ipa_nat_testing user space nat driver\\n\");\n\n\tif (argc == 4)\n\t{\n\t\tif (!strncmp(argv[1], \"reg\", 3))\n\t\t{\n\t\t\tnt = atoi(argv[2]);\n\t\t\ttotal_entries = atoi(argv[3]);\n\t\t\tIPADBG(\"Reg: %d, Nat Entries: %d\\n\", nt, total_entries);\n\t\t}\n\t\telse if (!strncmp(argv[1], \"sep\", 3))\n\t\t{\n\t\t\tsep = 1;\n\t\t\tnt = atoi(argv[2]);\n\t\t\ttotal_entries = atoi(argv[3]);\n\t\t}\n\t}\n\telse if (argc == 3)\n\t{\n\t\tif (!strncmp(argv[1], \"inotify\", 7))\n\t\t{\n\t\t\tipa_nat_test021(total_entries, atoi(argv[2]));\n\t\t\treturn 0;\n\t\t}\n\t\telse if (!strncmp(argv[1], \"sep\", 3))\n\t\t{\n\t\t\tsep = 1;\n\t\t\ttotal_entries = atoi(argv[2]);\n\t\t}\n\t}\n\telse if (argc == 2)\n\t{\n\t\ttotal_entries = atoi(argv[1]);\n\t\tIPADBG(\"Nat Entries: %d\\n\", total_entries);\n\t}\n\n\n\tfor (cnt=0; cnt<nt; cnt++)\n\t{\n\t\tIPADBG(\"%s():Executing %d time \\n\",__FUNCTION__, cnt);\n\n\t\tif (!sep)\n\t\t{\n\t\t\tret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);\n\t\t\tCHECK_ERR(ret);\n\t\t}\n\n\t\tif (sep)\n\t\t{\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\t\tret = ipa_nat_test000(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\t\tret = ipa_nat_test001(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\t\t}\n\n\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\tret = ipa_nat_test002(total_entries, tbl_hdl, sep);\n\t\tif (!ret)\n\t\t{\n\t\t\tpass++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t}\n\t\texec++;\n\n\t\tif (sep)\n\t\t{\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\t\tret = ipa_nat_test003(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\t\tret = ipa_nat_test004(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\t\tret = ipa_nat_test005(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\t\t}\n\n\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\tret = ipa_nat_test006(total_entries, tbl_hdl, sep);\n\t\tif (!ret)\n\t\t{\n\t\t\tpass++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t}\n\t\texec++;\n\n\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\tret = ipa_nat_test007(total_entries, tbl_hdl, sep);\n\t\tif (!ret)\n\t\t{\n\t\t\tpass++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t}\n\t\texec++;\n\n\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\tret = ipa_nat_test008(total_entries, tbl_hdl, sep);\n\t\tif (!ret)\n\t\t{\n\t\t\tpass++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t}\n\t\texec++;\n\n\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test00%d\\n\", exec);\n\t\tret = ipa_nat_test009(total_entries, tbl_hdl, sep);\n\t\tif (!ret)\n\t\t{\n\t\t\tpass++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tIPAERR(\"ipa_nat_test00%d Fail\\n\", exec);\n\t\t}\n\t\texec++;\n\n\t\tif (total_entries >= IPA_NAT_TEST_PRE_COND_TE)\n\t\t{\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test010(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test011(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test012(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test013(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test014(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test015(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test016(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test017(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test018(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test019(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test020(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\n\t\t\tIPADBG(\"\\n\\nExecuting ipa_nat_test0%d\\n\", exec);\n\t\t\tret = ipa_nat_test022(total_entries, tbl_hdl, sep);\n\t\t\tif (!ret)\n\t\t\t{\n\t\t\t\tpass++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tIPAERR(\"ipa_nat_test0%d Fail\\n\", exec);\n\t\t\t}\n\t\t\texec++;\n\t\t}\n\n\t\tif (!sep)\n\t\t{\n\t\t\tret = ipa_nat_del_ipv4_tbl(tbl_hdl);\n\t\t\tCHECK_ERR(ret);\n\t\t}\n\t}\n\t/*=======  Printing Results ==========*/\n\tIPADBG(\"Total ipa_nat Tests Run:%d, Pass:%d, Fail:%d\\n\",exec, pass, exec-pass);\n\treturn 0;\n}\n"
  },
  {
    "path": "device.mk",
    "content": "#\n# Copyright (C) 2015 The CyanogenMod Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n$(call inherit-product-if-exists, vendor/oneplus/oneplus2/oneplus2-vendor.mk)\n\n# Overlays\nDEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay\n\n# Permissions\nPRODUCT_COPY_FILES += \\\n    external/ant-wireless/antradio-library/com.dsi.ant.antradio_library.xml:system/etc/permissions/com.dsi.ant.antradio_library.xml \\\n    frameworks/native/data/etc/android.hardware.audio.low_latency.xml:system/etc/permissions/android.hardware.audio.low_latency.xml \\\n    frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml \\\n    frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml \\\n    frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:system/etc/permissions/android.hardware.camera.flash-autofocus.xml \\\n    frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \\\n    frameworks/native/data/etc/android.hardware.camera.full.xml:system/etc/permissions/android.hardware.camera.full.xml \\\n    frameworks/native/data/etc/android.hardware.camera.raw.xml:system/etc/permissions/android.hardware.camera.raw.xml \\\n    frameworks/native/data/etc/android.hardware.fingerprint.xml:system/etc/permissions/android.hardware.fingerprint.xml \\\n    frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \\\n    frameworks/native/data/etc/android.hardware.hdmi.cec.xml:system/etc/permissions/android.hardware.hdmi.cec.xml \\\n    frameworks/native/data/etc/android.hardware.opengles.aep.xml:system/etc/permissions/android.hardware.opengles.aep.xml \\\n    frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:system/etc/permissions/android.hardware.sensor.accelerometer.xml \\\n    frameworks/native/data/etc/android.hardware.sensor.compass.xml:system/etc/permissions/android.hardware.sensor.compass.xml \\\n    frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml \\\n    frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:system/etc/permissions/android.hardware.sensor.gyroscope.xml \\\n    frameworks/native/data/etc/android.hardware.sensor.proximity.xml:system/etc/permissions/android.hardware.sensor.proximity.xml \\\n    frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:system/etc/permissions/android.hardware.sensor.stepcounter.xml \\\n    frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:system/etc/permissions/android.hardware.sensor.stepdetector.xml \\\n    frameworks/native/data/etc/android.hardware.telephony.cdma.xml:system/etc/permissions/android.hardware.telephony.cdma.xml \\\n    frameworks/native/data/etc/android.software.sip.voip.xml:system/etc/permissions/android.software.sip.voip.xml \\\n    frameworks/native/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml \\\n    frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \\\n    frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml \\\n    frameworks/native/data/etc/android.hardware.usb.host.xml:system/etc/permissions/android.hardware.usb.host.xml \\\n    frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \\\n    frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml \\\n    frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \\\n    frameworks/native/data/etc/android.hardware.opengles.aep.xml:system/etc/permissions/android.hardware.opengles.aep.xml \\\n    frameworks/native/data/etc/android.hardware.vr.high_performance.xml:system/etc/permissions/android.hardware.vr.high_performance.xml \\\n    frameworks/native/data/etc/android.hardware.vulkan.level-0.xml:system/etc/permissions/android.hardware.vulkan.level.xml \\\n    frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:system/etc/permissions/android.hardware.vulkan.version.xml\n\n# Device uses high-density artwork where available\nPRODUCT_AAPT_CONFIG := normal\nPRODUCT_AAPT_PREF_CONFIG := xxhdpi\n\n# Boot animation\nTARGET_SCREEN_HEIGHT := 1920\nTARGET_SCREEN_WIDTH := 1080\n\n$(call inherit-product, frameworks/native/build/phone-xxxhdpi-4096-dalvik-heap.mk)\n$(call inherit-product, frameworks/native/build/phone-xxxhdpi-4096-hwui-memory.mk)\n\n# Haters gonna hate..\nPRODUCT_CHARACTERISTICS := nosdcard\n\n# Audio\nPRODUCT_PACKAGES += \\\n    audiod \\\n    audio.a2dp.default \\\n    audio.primary.msm8994 \\\n    audio.r_submix.default \\\n    audio.usb.default \\\n    audio_policy.msm8994 \\\n    libaudio-resampler \\\n    libqcompostprocbundle \\\n    libqcomvisualizer \\\n    libqcomvoiceprocessing \\\n    tinymix\n\nPRODUCT_COPY_FILES += \\\n    $(LOCAL_PATH)/audio/aanc_tuning_mixer.txt:system/etc/aanc_tuning_mixer.txt \\\n    $(LOCAL_PATH)/audio/audio_effects.conf:system/vendor/etc/audio_effects.conf \\\n    $(LOCAL_PATH)/audio/audio_output_policy.conf:system/vendor/etc/audio_output_policy.conf \\\n    $(LOCAL_PATH)/audio/audio_platform_info.xml:system/etc/audio_platform_info.xml \\\n    $(LOCAL_PATH)/audio/audio_policy.conf:system/etc/audio_policy.conf \\\n    $(LOCAL_PATH)/audio/listen_platform_info.xml:system/etc/listen_platform_info.xml \\\n    $(LOCAL_PATH)/audio/mixer_paths.xml:system/etc/mixer_paths.xml \\\n    $(LOCAL_PATH)/audio/sound_trigger_mixer_paths.xml:system/etc/sound_trigger_mixer_paths.xml \\\n    $(LOCAL_PATH)/audio/sound_trigger_platform_info.xml:system/etc/sound_trigger_platform_info.xml\n\n# ANT+\nPRODUCT_PACKAGES += \\\n    AntHalService \\\n    com.dsi.ant.antradio_library \\\n    libantradio\n\n# Camera\nPRODUCT_PACKAGES += \\\n    camera.msm8994 \\\n    libshim_camera \\\n    libshim_ims-camera \\\n    sensors.hal.tof \\\n    Snap\n\n# Connectivity Engine support (CNE)\nPRODUCT_PACKAGES += \\\n    cneapiclient \\\n    com.quicinc.cne \\\n    libcnefeatureconfig \\\n    services-ext\n\n# Display\nPRODUCT_PACKAGES += \\\n    copybit.msm8994 \\\n    gralloc.msm8994 \\\n    hwcomposer.msm8994 \\\n    memtrack.msm8994 \\\n    liboverlay \\\n    libtinyxml\n\n# Doze mode\nPRODUCT_PACKAGES += \\\n    OneplusDoze\n\n# Filesystem management tools\nPRODUCT_PACKAGES += \\\n    e2fsck \\\n    make_ext4fs \\\n    setup_fs\n\n# Fingerprint sensor\nPRODUCT_PACKAGES += \\\n    fingerprintd\n\n# For android_filesystem_config.h\nPRODUCT_PACKAGES += \\\n    fs_config_files\n\n# Gello\nPRODUCT_PACKAGES += \\\n    Gello\n\n# GPS\nPRODUCT_PACKAGES += \\\n    gps.msm8994 \\\n    flp.conf \\\n    gps.conf \\\n    izat.conf \\\n    lowi.conf \\\n    quipc.conf \\\n    sap.conf \\\n    xtwifi.conf\n\n# IPv6\nPRODUCT_PACKAGES += \\\n    ebtables \\\n    ethertypes\n\n# IRQ\nPRODUCT_COPY_FILES += \\\n    $(LOCAL_PATH)/configs/msm_irqbalance.conf:system/vendor/etc/msm_irqbalance.conf\n\n# IRSC\nPRODUCT_COPY_FILES += \\\n    $(LOCAL_PATH)/configs/sec_config:system/etc/sec_config\n\n# Keylayouts\nPRODUCT_COPY_FILES += \\\n    $(LOCAL_PATH)/keylayout/fpc1020.kl:system/usr/keylayout/fpc1020.kl \\\n    $(LOCAL_PATH)/keylayout/synaptics.kl:system/usr/keylayout/synaptics.kl\n\n# Lights\nPRODUCT_PACKAGES += \\\n    lights.msm8994\n\n# LiveDisplay native\nPRODUCT_PACKAGES += \\\n    libjni_livedisplay\n\n# Media\nPRODUCT_COPY_FILES += \\\n    $(LOCAL_PATH)/configs/media_codecs.xml:system/etc/media_codecs.xml \\\n    $(LOCAL_PATH)/configs/media_codecs_performance.xml:system/etc/media_codecs_performance.xml \\\n    $(LOCAL_PATH)/configs/media_profiles.xml:system/etc/media_profiles.xml\n\nPRODUCT_COPY_FILES += \\\n    frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \\\n    frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \\\n    frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml\n\n# OMX\nPRODUCT_PACKAGES += \\\n    libc2dcolorconvert \\\n    libdashplayer \\\n    libdivxdrmdecrypt \\\n    libextmedia_jni \\\n    libOmxAacEnc \\\n    libOmxAmrEnc \\\n    libOmxCore \\\n    libOmxEvrcEnc \\\n    libOmxQcelp13Enc \\\n    libOmxSwVencMpeg4 \\\n    libOmxSwVencHevc \\\n    libOmxVdec \\\n    libOmxVdecHevc \\\n    libOmxVenc \\\n    libOmxVidcCommon \\\n    libstagefrighthw \\\n    libstagefright_soft_flacdec\n\n# Power\nPRODUCT_PACKAGES += \\\n    power.msm8994\n\n# Ramdisk\nPRODUCT_PACKAGES += \\\n    init.qcom.bt.sh \\\n    init.zram.sh\n\nPRODUCT_PACKAGES += \\\n    fstab.qcom \\\n    init.qcom.power.rc \\\n    init.qcom.rc \\\n    init.qcom.sh \\\n    init.qcom.usb.rc \\\n    init.qcom.usb.sh \\\n    ueventd.qcom.rc\n\n# RIL\nPRODUCT_PACKAGES += \\\n    librmnetctl \\\n    libxml2\n\nPRODUCT_PACKAGES += telephony-ext\nPRODUCT_BOOT_JARS += telephony-ext\n\n# Sensors\nPRODUCT_PACKAGES += \\\n    sensors.msm8994 \\\n    sensors.ssc.wrapper\n\nPRODUCT_COPY_FILES += \\\n    $(LOCAL_PATH)/configs/sensors/hals.conf:system/etc/sensors/hals.conf\n\n# USB\nPRODUCT_PACKAGES += \\\n    com.android.future.usb.accessory\n\n# VR\nPRODUCT_PACKAGES += \\\n    vr.msm8994\n\n# MIDI feature\nPRODUCT_COPY_FILES += \\\n    frameworks/native/data/etc/android.software.midi.xml:system/etc/permissions/android.software.midi.xml\n\n# WiFi\nPRODUCT_PACKAGES += \\\n    ipacm \\\n    ipacm-diag \\\n    IPACM_cfg.xml \\\n    hostapd \\\n    libwpa_client \\\n    wpa_supplicant \\\n    wpa_supplicant.conf\n\nPRODUCT_COPY_FILES += \\\n    $(LOCAL_PATH)/wifi/hostapd.accept:system/etc/hostapd/hostapd.accept \\\n    $(LOCAL_PATH)/wifi/hostapd.conf:system/etc/hostapd/hostapd_default.conf \\\n    $(LOCAL_PATH)/wifi/hostapd.deny:system/etc/hostapd/hostapd.deny \\\n    $(LOCAL_PATH)/wifi/p2p_supplicant_overlay.conf:system/etc/wifi/p2p_supplicant_overlay.conf \\\n    $(LOCAL_PATH)/wifi/wpa_supplicant_overlay.conf:system/etc/wifi/wpa_supplicant_overlay.conf\n\nPRODUCT_COPY_FILES += \\\n    $(LOCAL_PATH)/wifi/WCNSS_cfg.dat:system/etc/wifi/WCNSS_cfg.dat \\\n    $(LOCAL_PATH)/wifi/WCNSS_qcom_cfg.ini:system/etc/wifi/WCNSS_qcom_cfg.ini\n\n# Inherit from oppo-common\n$(call inherit-product, device/oppo/common/common.mk)\n"
  },
  {
    "path": "doze/Android.mk",
    "content": "LOCAL_PATH:= $(call my-dir)\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE_TAGS := optional\n\nLOCAL_SRC_FILES := $(call all-java-files-under, src)\n\nLOCAL_PACKAGE_NAME := OneplusDoze\nLOCAL_CERTIFICATE := platform\nLOCAL_PRIVILEGED_MODULE := true\nLOCAL_STATIC_JAVA_LIBRARIES := \\\n    android-support-v4 \\\n    android-support-v13 \\\n    android-support-v7-recyclerview \\\n    android-support-v7-preference \\\n    android-support-v7-appcompat \\\n    android-support-v14-preference \\\n    org.cyanogenmod.platform.internal\n\nLOCAL_RESOURCE_DIR := \\\n    $(LOCAL_PATH)/res \\\n    $(LOCAL_PATH)/../../../../packages/resources/devicesettings/res \\\n    frameworks/support/v7/preference/res \\\n    frameworks/support/v14/preference/res \\\n    frameworks/support/v7/appcompat/res \\\n    frameworks/support/v7/recyclerview/res\n\nLOCAL_AAPT_FLAGS := --auto-add-overlay \\\n    --extra-packages android.support.v7.preference:android.support.v14.preference:android.support.v17.preference:android.support.v7.appcompat:android.support.v7.recyclerview\n\nLOCAL_PROGUARD_FLAG_FILES := proguard.flags\n\ninclude frameworks/base/packages/SettingsLib/common.mk\n\ninclude $(BUILD_PACKAGE)\n\ninclude $(call all-makefiles-under,$(LOCAL_PATH))\n"
  },
  {
    "path": "doze/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.cyanogenmod.settings.doze\"\n    android:versionCode=\"1\"\n    android:versionName=\"1.0\"\n    android:sharedUserId=\"android.uid.system\">\n\n    <uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\"/>\n    <uses-permission android:name=\"android.permission.WAKE_LOCK\" />\n    <uses-permission android:name=\"cyanogenmod.permission.MANAGE_REMOTE_PREFERENCES\" />\n\n    <uses-sdk\n        android:minSdkVersion=\"24\"\n        android:targetSdkVersion=\"24\"/>\n\n    <application\n        android:label=\"@string/device_settings_app_name\"\n        android:persistent=\"true\">\n\n        <receiver android:name=\"com.cyanogenmod.settings.doze.DozeReceiver\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.BOOT_COMPLETED\" />\n                <action android:name=\"cyanogenmod.intent.action.UPDATE_PREFERENCE\" />\n                <category android:name=\"android.intent.category.DEFAULT\" />\n            </intent-filter>\n        </receiver>\n\n        <service android:name=\"com.cyanogenmod.settings.doze.DozeService\"\n                 android:permission=\"OneplusDozeService\">\n        </service>\n\n        <activity\n            android:name=\".DozeSettings\"\n            android:label=\"@string/ambient_display_title\"\n            android:theme=\"@style/DozeSettings\">\n            <intent-filter>\n                <action android:name=\"org.cyanogenmod.settings.device.DOZE_SETTINGS\" />\n                <category android:name=\"android.intent.category.DEFAULT\" />\n            </intent-filter>\n            <meta-data\n                android:name=\"org.cyanogenmod.settings.summary.receiver\"\n                android:value=\"com.cyanogenmod.settings.doze.DozeReceiver\" />\n            <meta-data\n                android:name=\"org.cyanogenmod.settings.summary.key\"\n                android:value=\"doze_device_settings\" />\n        </activity>\n\n    </application>\n</manifest>\n"
  },
  {
    "path": "doze/proguard.flags",
    "content": "-keepclasseswithmembers class * {\n    public <init>(android.content.Context, android.util.AttributeSet);\n}\n\n-keep class ** extends android.support.v14.preference.PreferenceFragment\n-keep class com.cyanogenmod.settings.doze.* {\n  *;\n}\n"
  },
  {
    "path": "doze/res/drawable/ic_settings_doze.xml",
    "content": "<!--\nCopyright (C) 2014 The Android Open Source Project\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n         http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n-->\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        android:width=\"64dp\"\n        android:height=\"64dp\"\n        android:viewportWidth=\"64\"\n        android:viewportHeight=\"64\">\n\n    <group\n            android:translateY=\"-988.583\">\n        <path\n                android:fillColor=\"@android:color/white\"\n                android:pathData=\"M15.0133\n1051.24c-1.3615-0.2479-2.37425-1.2789-2.57968-2.6262-0.06554-0.4298-0.06571-55.8484-0.00018-56.28\n0.09875-0.65024 0.367851-1.20544 0.812983-1.6773 0.402211-0.42637\n0.920053-0.7356 1.49909-0.8952l0.299302-0.0825h16.845 16.845l0.291174\n0.0804c1.24697 0.34447 2.13039 1.32473 2.32019 2.57456 0.06515 0.42898 0.06541\n55.8484 0.0003 56.28-0.188067 1.2461-1.07608 2.2305-2.32306 2.5752l-0.288567\n0.08h-16.755c-13.5267 0-16.7958\n0-16.9665-0.034zm29.8065-31.1862v-19.23h-12.99-12.99v19.23 19.23h12.99\n12.99v-19.23zm-13.459\n11.687c-1.03547-0.2354-1.77837-1.1208-1.83292-2.1845l-0.01654-0.3225h1.87175c1.02946\n0 2.10645 0.01 2.3933 0.02l0.521553 0.02-0.01945 0.253c-0.02847 0.3705-0.09559\n0.6134-0.267159 0.9672-0.135477 0.2794-0.18522 0.3474-0.439626 0.6013-0.31197\n0.3114-0.571617 0.4707-0.976866 0.5995-0.269196 0.085-0.949163 0.111-1.23404\n0.046zm-9.04096-4.1842v-0.6872l1.10534-1.0831 1.10534-1.0831\n0.02483-1.2072c0.01366-0.664 0.02781-2.213 0.03145-3.4422 0.007-2.3727\n0.01776-2.5909 0.162279-3.3 0.234013-1.1483 0.861931-2.2993 1.7263-3.1643\n0.762874-0.7634 1.91951-1.4813 3.00204-1.8633 0.262572-0.093 0.512691-0.1813\n0.555819-0.1969l0.07842-0.029 0.01577-0.426c0.01284-0.3469 0.03018-0.4706\n0.09332-0.666 0.197394-0.6109 0.642609-1.0525 1.21018-1.2004 0.365688-0.095\n0.860153-0.043 1.2089 0.1282 0.234414 0.1149 0.589851 0.4783 0.725931 0.7422\n0.171483 0.3325 0.207933 0.491 0.225975 0.9825 0.01148 0.3126 0.02671 0.4425\n0.0519 0.4425 0.01961 0 0.2844 0.088 0.588423 0.1954 2.74734 0.9715 4.21726\n2.7794 4.71985 5.805 0.171696 1.0336 0.211308 1.7926 0.259098 4.9646l0.03345\n2.22 1.10911 1.095 1.1091 1.095-0.0014 0.6825-0.0014 0.6825h-9.57-9.57v-0.6872z\" />\n    </group>\n</vector>\n"
  },
  {
    "path": "doze/res/drawable/switchbar_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2014 The Android Open Source Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n\n<ripple xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:color=\"?android:attr/colorControlHighlight\">\n    <item android:drawable=\"@color/switch_bar_background\" />\n</ripple>\n\n"
  },
  {
    "path": "doze/res/layout/doze.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2014, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:orientation=\"vertical\"\n              android:layout_height=\"match_parent\"\n              android:layout_width=\"match_parent\">\n\n    <include layout=\"@layout/switch_bar\" />\n\n</LinearLayout>\n\n"
  },
  {
    "path": "doze/res/layout/switch_bar.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2016 The Android Open Source Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/switch_bar\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"?android:attr/actionBarSize\"\n    android:background=\"@drawable/switchbar_background\"\n    android:paddingStart=\"16dp\"\n    android:paddingEnd=\"16dp\"\n    android:clickable=\"true\"\n    android:gravity=\"center\">\n\n    <TextView android:id=\"@+id/switch_text\"\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"0dp\"\n        android:layout_weight=\"1\"\n        android:layout_gravity=\"center_vertical\"\n        android:paddingStart=\"48dp\"\n        android:maxLines=\"2\"\n        android:ellipsize=\"end\"\n        android:textAppearance=\"@android:style/TextAppearance.Material.Title\"\n        android:textColor=\"?android:attr/textColorPrimaryInverse\"\n        android:textAlignment=\"viewStart\"\n        android:text=\"@string/switch_bar_on\" />\n\n    <Switch\n        android:id=\"@android:id/switch_widget\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center_vertical\"\n        android:background=\"@null\"\n        android:theme=\"@style/ThemeOverlay.SwitchBar\" />\n\n</LinearLayout>\n"
  },
  {
    "path": "doze/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*  \n * Copyright 2010, The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *  \n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */ \n-->\n<resources>\n    <color name=\"switch_bar_background\">#ff37474f</color>\n    <color name=\"switch_accent_color\">#ff7fcac3</color>\n    <color name=\"system_secondary_color\">#ff37474F</color>\n</resources>\n"
  },
  {
    "path": "doze/res/values/styles.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2016 The CyanogenMod Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n  \n          http://www.apache.org/licenses/LICENSE-2.0\n  \n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<resources xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <style name=\"DozeSettings\" parent=\"@android:style/Theme.Material.Settings\">\n        <item name=\"android:windowActionBar\">false</item>\n        <item name=\"preferenceTheme\">@style/DozePreferenceTheme</item>\n    </style>\n\n    <style name=\"DozePreferenceTheme\" parent=\"@android:style/Theme.Material.Settings\">\n        <item name=\"dropdownPreferenceStyle\">@style/Preference.DropDown.Material</item>\n    </style>\n\n    <style name=\"ThemeOverlay.SwitchBar\" parent=\"@android:style/ThemeOverlay\">\n        <item name=\"android:colorAccent\">@color/switch_accent_color</item>\n    </style>\n\n    <style name=\"ThemeOverlay.SwitchBar.Secondary\" parent=\"@android:style/ThemeOverlay\">\n        <item name=\"android:colorAccent\">@color/system_secondary_color</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "doze/res/xml/doze_settings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n     Copyright (C) 2015 The CyanogenMod Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\"\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <PreferenceCategory\n        android:key=\"tilt_sensor\"\n        android:title=\"@string/tilt_sensor_title\" >\n\n        <SwitchPreference\n            android:key=\"gesture_pick_up\"\n            android:defaultValue=\"false\"\n            android:title=\"@string/pick_up_gesture_title\"\n            android:summary=\"@string/pick_up_gesture_summary\" />\n\n    </PreferenceCategory>\n\n    <PreferenceCategory\n        android:key=\"proximity_sensor\"\n        android:title=\"@string/proximity_sensor_title\" >\n\n        <SwitchPreference\n            android:key=\"gesture_hand_wave\"\n            android:defaultValue=\"false\"\n            android:title=\"@string/hand_wave_gesture_title\"\n            android:summary=\"@string/hand_wave_gesture_summary\" />\n\n        <SwitchPreference\n            android:key=\"gesture_pocket\"\n            android:defaultValue=\"false\"\n            android:title=\"@string/pocket_gesture_title\"\n            android:summary=\"@string/pocket_gesture_summary\" />\n\n    </PreferenceCategory>\n\n</PreferenceScreen>\n"
  },
  {
    "path": "doze/src/com/cyanogenmod/settings/doze/BootCompletedReceiver.java",
    "content": "/*\n * Copyright (c) 2015 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.cyanogenmod.settings.doze;\n\nimport android.content.BroadcastReceiver;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.util.Log;\n\npublic class BootCompletedReceiver extends BroadcastReceiver {\n\n    private static final boolean DEBUG = false;\n    private static final String TAG = \"OneplusDoze\";\n\n    @Override\n    public void onReceive(final Context context, Intent intent) {\n        if (Utils.isDozeEnabled(context) && Utils.sensorsEnabled(context)) {\n            if (DEBUG) Log.d(TAG, \"Starting service\");\n            Utils.startService(context);\n        }\n    }\n\n}\n"
  },
  {
    "path": "doze/src/com/cyanogenmod/settings/doze/DozeReceiver.java",
    "content": "/*\n * Copyright (C) 2016 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.cyanogenmod.settings.doze;\n\nimport android.content.Context;\nimport android.content.Intent;\nimport android.util.Log;\n\nimport cyanogenmod.preference.RemotePreferenceUpdater;\n\npublic class DozeReceiver extends RemotePreferenceUpdater {\n\n    private static final boolean DEBUG = false;\n    private static final String TAG = \"OneplusDoze\";\n\n    private static final String DOZE_CATEGORY_KEY = \"doze_device_settings\";\n\n    @Override\n    public void onReceive(Context context, Intent intent) {\n        super.onReceive(context, intent);\n\n        if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {\n            if (Utils.isDozeEnabled(context) && Utils.sensorsEnabled(context)) {\n                if (DEBUG) Log.d(TAG, \"Starting service\");\n                Utils.startService(context);\n            }\n        }\n    }\n\n    @Override\n    public String getSummary(Context context, String key) {\n        if (DOZE_CATEGORY_KEY.equals(key)) {\n            return DozeSettingsFragment.getDozeSummary(context);\n        }\n        return null;\n    }\n\n    static void notifyChanged(Context context) {\n        notifyChanged(context, DOZE_CATEGORY_KEY);\n    }\n}\n"
  },
  {
    "path": "doze/src/com/cyanogenmod/settings/doze/DozeService.java",
    "content": "/*\n * Copyright (c) 2015 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.cyanogenmod.settings.doze;\n\nimport android.app.Service;\nimport android.content.BroadcastReceiver;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.IntentFilter;\nimport android.os.IBinder;\nimport android.util.Log;\n\npublic class DozeService extends Service {\n    private static final String TAG = \"DozeService\";\n    private static final boolean DEBUG = false;\n\n    private ProximitySensor mProximitySensor;\n    private TiltSensor mTiltSensor;\n\n    @Override\n    public void onCreate() {\n        if (DEBUG) Log.d(TAG, \"Creating service\");\n        mProximitySensor = new ProximitySensor(this);\n        mTiltSensor = new TiltSensor(this);\n\n        IntentFilter screenStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);\n        screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);\n        registerReceiver(mScreenStateReceiver, screenStateFilter);\n    }\n\n    @Override\n    public int onStartCommand(Intent intent, int flags, int startId) {\n        if (DEBUG) Log.d(TAG, \"Starting service\");\n        return START_STICKY;\n    }\n\n    @Override\n    public void onDestroy() {\n        if (DEBUG) Log.d(TAG, \"Destroying service\");\n        super.onDestroy();\n        this.unregisterReceiver(mScreenStateReceiver);\n        mProximitySensor.disable();\n        mTiltSensor.disable();\n    }\n\n    @Override\n    public IBinder onBind(Intent intent) {\n        return null;\n    }\n\n    private void onDisplayOn() {\n        if (DEBUG) Log.d(TAG, \"Display on\");\n        if (Utils.pickUpEnabled(this)) {\n            mTiltSensor.disable();\n        }\n        if (Utils.handwaveGestureEnabled(this) ||\n                Utils.pocketGestureEnabled(this)) {\n            mProximitySensor.disable();\n        }\n    }\n\n    private void onDisplayOff() {\n        if (DEBUG) Log.d(TAG, \"Display off\");\n        if (Utils.pickUpEnabled(this)) {\n            mTiltSensor.enable();\n        }\n        if (Utils.handwaveGestureEnabled(this) ||\n                Utils.pocketGestureEnabled(this)) {\n            mProximitySensor.enable();\n        }\n    }\n\n    private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {\n        @Override\n        public void onReceive(Context context, Intent intent) {\n            if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {\n                onDisplayOn();\n            } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {\n                onDisplayOff();\n            }\n        }\n    };\n}\n"
  },
  {
    "path": "doze/src/com/cyanogenmod/settings/doze/DozeSettings.java",
    "content": "/*\n * Copyright (C) 2016 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.cyanogenmod.settings.doze;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport android.view.MenuItem;\n\nimport com.android.settingslib.drawer.SettingsDrawerActivity;\n\n/**\n * Created by shade on 10/14/16.\n */\n\npublic class DozeSettings extends SettingsDrawerActivity {\n\n    private static final String TAG_DOZE = \"doze\";\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        setContentView(R.layout.doze);\n\n        getFragmentManager().beginTransaction().replace(R.id.content_frame,\n                new DozeSettingsFragment(), TAG_DOZE).commit();\n    }\n\n    @Override\n    public boolean onOptionsItemSelected(MenuItem item) {\n        if (item.getItemId() == android.R.id.home) {\n            onBackPressed();\n            return true;\n        }\n        return false;\n    }\n}\n"
  },
  {
    "path": "doze/src/com/cyanogenmod/settings/doze/DozeSettingsFragment.java",
    "content": "/*\n * Copyright (C) 2015 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.cyanogenmod.settings.doze;\n\nimport android.app.ActionBar;\nimport android.app.Activity;\nimport android.app.AlertDialog;\nimport android.app.Dialog;\nimport android.app.DialogFragment;\nimport android.content.Context;\nimport android.content.DialogInterface;\nimport android.content.SharedPreferences;\nimport android.database.ContentObserver;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.support.v14.preference.PreferenceFragment;\nimport android.support.v14.preference.SwitchPreference;\nimport android.support.v7.preference.Preference;\nimport android.support.v7.preference.Preference.OnPreferenceChangeListener;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.CompoundButton;\nimport android.widget.Switch;\n\npublic class DozeSettingsFragment extends PreferenceFragment implements OnPreferenceChangeListener,\n        CompoundButton.OnCheckedChangeListener {\n\n    private SharedPreferences mPreferences;\n\n    private Switch mSwitch;\n\n    private SwitchPreference mPickUpPreference;\n    private SwitchPreference mHandwavePreference;\n    private SwitchPreference mPocketPreference;\n\n    private ContentObserver mDozeObserver = new ContentObserver(new Handler()) {\n        @Override\n        public void onChange(boolean selfChange) {\n            super.onChange(selfChange);\n\n            boolean enabled = Utils.isDozeEnabled(getActivity());\n\n            updateSwitches(Utils.isDozeEnabled(getActivity()));\n            DozeReceiver.notifyChanged(getActivity());\n        }\n    };\n\n    static String getDozeSummary(Context context) {\n        if (Utils.isDozeEnabled(context)) {\n            return context.getString(R.string.ambient_display_summary_on);\n        }\n        return context.getString(R.string.ambient_display_summary_off);\n    }\n\n    @Override\n    public void onActivityCreated(Bundle savedInstanceState) {\n        super.onActivityCreated(savedInstanceState);\n        getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);\n    }\n\n    @Override\n    public View onCreateView(LayoutInflater inflater, ViewGroup container,\n                             Bundle savedInstanceState) {\n        final View view = LayoutInflater.from(getContext()).inflate(R.layout.doze, container, false);\n        ((ViewGroup) view).addView(super.onCreateView(inflater, container, savedInstanceState));\n        return view;\n    }\n\n    @Override\n    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {\n        addPreferencesFromResource(R.xml.doze_settings);\n\n        // get shared preference\n        mPreferences = getActivity().getSharedPreferences(\"doze_settings\", Activity.MODE_PRIVATE);\n\n        if (savedInstanceState == null && !mPreferences.getBoolean(\"first_help_shown\", false)) {\n            showHelp();\n        }\n\n        mPickUpPreference =\n                (SwitchPreference) findPreference(Utils.GESTURE_PICK_UP_KEY);\n        mPickUpPreference.setOnPreferenceChangeListener(this);\n\n        mHandwavePreference =\n                (SwitchPreference) findPreference(Utils.GESTURE_HAND_WAVE_KEY);\n        mHandwavePreference.setOnPreferenceChangeListener(this);\n\n        mPocketPreference =\n                (SwitchPreference) findPreference(Utils.GESTURE_POCKET_KEY);\n        mPocketPreference.setOnPreferenceChangeListener(this);\n    }\n\n    @Override\n    public void onResume() {\n        super.onResume();\n        getActivity().getContentResolver().registerContentObserver(\n                Utils.DOZE_ENABLED_URI, false, mDozeObserver);\n        updateSwitches(Utils.isDozeEnabled(getActivity()));\n    }\n\n    @Override\n    public void onPause() {\n        super.onPause();\n        getActivity().getContentResolver().unregisterContentObserver(mDozeObserver);\n    }\n\n    private void updateSwitches(boolean enabled) {\n        mPickUpPreference.setEnabled(enabled);\n        mHandwavePreference.setEnabled(enabled);\n        mPocketPreference.setEnabled(enabled);\n    }\n\n    @Override\n    public void onViewCreated(View view, Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n\n        View switchBar = view.findViewById(R.id.switch_bar);\n        mSwitch = (Switch) switchBar.findViewById(android.R.id.switch_widget);\n        mSwitch.setChecked(Utils.isDozeEnabled(getActivity()));\n        mSwitch.setOnCheckedChangeListener(this);\n\n        switchBar.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                mSwitch.setChecked(!mSwitch.isChecked());\n            }\n        });\n    }\n\n\n    @Override\n    public boolean onPreferenceChange(Preference preference, Object newValue) {\n        final String key = preference.getKey();\n        final boolean value = (Boolean) newValue;\n        if (Utils.GESTURE_PICK_UP_KEY.equals(key)) {\n            mPickUpPreference.setChecked(value);\n        } else if (Utils.GESTURE_HAND_WAVE_KEY.equals(key)) {\n            mHandwavePreference.setChecked(value);\n        } else if (Utils.GESTURE_POCKET_KEY.equals(key)) {\n            mPocketPreference.setChecked(value);\n        } else {\n            return false;\n        }\n\n        Utils.startService(getActivity());\n        return true;\n    }\n\n    @Override\n    public void onCheckedChanged(CompoundButton compoundButton, boolean b) {\n        Utils.enableDoze(b, getActivity());\n    }\n\n    public static class HelpDialogFragment extends DialogFragment {\n        @Override\n        public Dialog onCreateDialog(Bundle savedInstanceState) {\n            return new AlertDialog.Builder(getActivity())\n                    .setTitle(R.string.doze_settings_help_title)\n                    .setMessage(R.string.doze_settings_help_text)\n                    .setNegativeButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {\n                        @Override\n                        public void onClick(DialogInterface dialog, int which) {\n                            dialog.cancel();\n                        }\n                    })\n                    .create();\n        }\n\n        @Override\n        public void onCancel(DialogInterface dialog) {\n            getActivity().getSharedPreferences(\"doze_settings\", Activity.MODE_PRIVATE)\n                    .edit()\n                    .putBoolean(\"first_help_shown\", true)\n                    .commit();\n        }\n    }\n\n    private void showHelp() {\n        HelpDialogFragment fragment = new HelpDialogFragment();\n        fragment.show(getFragmentManager(), \"help_dialog\");\n    }\n}\n"
  },
  {
    "path": "doze/src/com/cyanogenmod/settings/doze/ProximitySensor.java",
    "content": "/*\n * Copyright (c) 2015 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.cyanogenmod.settings.doze;\n\nimport android.content.Context;\nimport android.hardware.Sensor;\nimport android.hardware.SensorEvent;\nimport android.hardware.SensorEventListener;\nimport android.hardware.SensorManager;\nimport android.util.Log;\n\npublic class ProximitySensor implements SensorEventListener {\n\n    private static final boolean DEBUG = false;\n    private static final String TAG = \"ProximitySensor\";\n\n    private static final int POCKET_DELTA_NS = 1000 * 1000 * 1000;\n\n    private SensorManager mSensorManager;\n    private Sensor mSensor;\n    private Context mContext;\n\n    private boolean mSawNear = false;\n    private long mInPocketTime = 0;\n\n    public ProximitySensor(Context context) {\n        mContext = context;\n        mSensorManager = (SensorManager)\n                mContext.getSystemService(Context.SENSOR_SERVICE);\n        mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);\n    }\n\n    @Override\n    public void onSensorChanged(SensorEvent event) {\n        boolean isNear = event.values[0] < mSensor.getMaximumRange();\n        if (mSawNear && !isNear) {\n            if (shouldPulse(event.timestamp)) {\n                Utils.launchDozePulse(mContext);\n            }\n        } else {\n            mInPocketTime = event.timestamp;\n        }\n        mSawNear = isNear;\n    }\n\n    private boolean shouldPulse(long timestamp) {\n        long delta = timestamp - mInPocketTime;\n\n        if (Utils.handwaveGestureEnabled(mContext)\n                    && Utils.pocketGestureEnabled(mContext)) {\n            return true;\n        } else if (Utils.handwaveGestureEnabled(mContext)\n                    && !Utils.pocketGestureEnabled(mContext)) {\n            return delta < POCKET_DELTA_NS;\n        } else if (!Utils.handwaveGestureEnabled(mContext)\n                    && Utils.pocketGestureEnabled(mContext)) {\n            return delta >= POCKET_DELTA_NS;\n        }\n        return false;\n    }\n\n    @Override\n    public void onAccuracyChanged(Sensor sensor, int accuracy) {\n        /* Empty */\n    }\n\n    protected void enable() {\n        if (DEBUG) Log.d(TAG, \"Enabling\");\n        mSensorManager.registerListener(this, mSensor,\n                SensorManager.SENSOR_DELAY_NORMAL);\n    }\n\n    protected void disable() {\n        if (DEBUG) Log.d(TAG, \"Disabling\");\n        mSensorManager.unregisterListener(this, mSensor);\n    }\n}\n"
  },
  {
    "path": "doze/src/com/cyanogenmod/settings/doze/TiltSensor.java",
    "content": "/*\n * Copyright (c) 2015 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.cyanogenmod.settings.doze;\n\nimport android.content.Context;\nimport android.hardware.Sensor;\nimport android.hardware.SensorEvent;\nimport android.hardware.SensorEventListener;\nimport android.hardware.SensorManager;\nimport android.os.PowerManager;\nimport android.os.PowerManager.WakeLock;\nimport android.os.SystemClock;\nimport android.util.Log;\n\npublic class TiltSensor implements SensorEventListener {\n\n    private static final boolean DEBUG = false;\n    private static final String TAG = \"TiltSensor\";\n\n    private static final int SENSOR_WAKELOCK_DURATION = 200;\n    private static final int BATCH_LATENCY_IN_MS = 100;\n    private static final int MIN_PULSE_INTERVAL_MS = 2500;\n\n    private PowerManager mPowerManager;\n    private SensorManager mSensorManager;\n    private Sensor mSensor;\n    private WakeLock mSensorWakeLock;\n    private Context mContext;\n\n    private long mEntryTimestamp;\n\n    public TiltSensor(Context context) {\n        mContext = context;\n        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);\n        mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);\n        mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_TILT_DETECTOR);\n        mSensorWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,\n                \"SensorWakeLock\");\n    }\n\n    @Override\n    public void onSensorChanged(SensorEvent event) {\n        if (DEBUG) Log.d(TAG, \"Got sensor event: \" + event.values[0]);\n\n        long delta = SystemClock.elapsedRealtime() - mEntryTimestamp;\n        if (delta < MIN_PULSE_INTERVAL_MS) {\n            return;\n        } else {\n            mEntryTimestamp = SystemClock.elapsedRealtime();\n        }\n\n        if (event.values[0] == 1) {\n            Utils.launchDozePulse(mContext);\n        }\n    }\n\n    @Override\n    public void onAccuracyChanged(Sensor sensor, int accuracy) {\n        /* Empty */\n    }\n\n    protected void enable() {\n        if (DEBUG) Log.d(TAG, \"Enabling\");\n        mSensorManager.registerListener(this, mSensor,\n                SensorManager.SENSOR_DELAY_NORMAL, BATCH_LATENCY_IN_MS * 1000);\n        mEntryTimestamp = SystemClock.elapsedRealtime();\n    }\n\n    protected void disable() {\n        if (DEBUG) Log.d(TAG, \"Disabling\");\n        mSensorManager.unregisterListener(this, mSensor);\n    }\n}\n"
  },
  {
    "path": "doze/src/com/cyanogenmod/settings/doze/Utils.java",
    "content": "/*\n * Copyright (c) 2015 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.cyanogenmod.settings.doze;\n\nimport android.content.Context;\nimport android.content.Intent;\nimport android.net.Uri;\nimport android.os.UserHandle;\nimport android.support.v7.preference.PreferenceManager;\nimport android.provider.Settings;\nimport android.util.Log;\n\nimport static android.provider.Settings.Secure.DOZE_ENABLED;\n\npublic final class Utils {\n\n    private static final String TAG = \"DozeUtils\";\n    private static final boolean DEBUG = false;\n\n    private static final String DOZE_INTENT = \"com.android.systemui.doze.pulse\";\n\n    protected static final String AMBIENT_DISPLAY_KEY = \"doze_enabled\";\n    protected static final String GESTURE_PICK_UP_KEY = \"gesture_pick_up\";\n    protected static final String GESTURE_HAND_WAVE_KEY = \"gesture_hand_wave\";\n    protected static final String GESTURE_POCKET_KEY = \"gesture_pocket\";\n\n    public static final Uri DOZE_ENABLED_URI = Settings.Secure.getUriFor(DOZE_ENABLED);\n\n    protected static void startService(Context context) {\n        if (DEBUG) Log.d(TAG, \"Starting service\");\n        context.startService(new Intent(context, DozeService.class));\n    }\n\n    protected static void stopService(Context context) {\n        if (DEBUG) Log.d(TAG, \"Stopping service\");\n        context.stopService(new Intent(context, DozeService.class));\n    }\n\n    protected static boolean isDozeEnabled(Context context) {\n        return Settings.Secure.getInt(context.getContentResolver(),\n                DOZE_ENABLED, 1) != 0;\n    }\n\n    protected static boolean enableDoze(boolean enable, Context context) {\n        boolean dozeEnabled = Settings.Secure.putInt(context.getContentResolver(),\n                              DOZE_ENABLED, enable ? 1 : 0);\n        if (enable) {\n            startService(context);\n        } else {\n            stopService(context);\n        }\n        return dozeEnabled;\n    }\n\n    protected static void launchDozePulse(Context context) {\n        if (DEBUG) Log.d(TAG, \"Launch doze pulse\");\n        context.sendBroadcastAsUser(new Intent(DOZE_INTENT),\n                new UserHandle(UserHandle.USER_CURRENT));\n    }\n\n    protected static boolean pickUpEnabled(Context context) {\n        return PreferenceManager.getDefaultSharedPreferences(context)\n                .getBoolean(GESTURE_PICK_UP_KEY, false);\n    }\n\n    protected static boolean handwaveGestureEnabled(Context context) {\n        return PreferenceManager.getDefaultSharedPreferences(context)\n                .getBoolean(GESTURE_HAND_WAVE_KEY, false);\n    }\n\n    protected static boolean pocketGestureEnabled(Context context) {\n        return PreferenceManager.getDefaultSharedPreferences(context)\n                .getBoolean(GESTURE_POCKET_KEY, false);\n    }\n\n    protected static boolean sensorsEnabled(Context context) {\n        return pickUpEnabled(context) || handwaveGestureEnabled(context)\n                || pocketGestureEnabled(context);\n    }\n}\n"
  },
  {
    "path": "extract-files.sh",
    "content": "#!/bin/bash\n#\n# Copyright (C) 2016 The CyanogenMod Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\nset -e\n\nDEVICE=oneplus2\nVENDOR=oneplus\n\n# Load extractutils and do some sanity checks\nMY_DIR=\"${BASH_SOURCE%/*}\"\nif [[ ! -d \"$MY_DIR\" ]]; then MY_DIR=\"$PWD\"; fi\n\nCM_ROOT=\"$MY_DIR\"/../../..\n\nHELPER=\"$CM_ROOT\"/vendor/cm/build/tools/extract_utils.sh\nif [ ! -f \"$HELPER\" ]; then\n    echo \"Unable to find helper script at $HELPER\"\n    exit 1\nfi\n. \"$HELPER\"\n\nif [ $# -eq 0 ]; then\n  SRC=adb\nelse\n  if [ $# -eq 1 ]; then\n    SRC=$1\n  else\n    echo \"$0: bad number of arguments\"\n    echo \"\"\n    echo \"usage: $0 [PATH_TO_EXPANDED_ROM]\"\n    echo \"\"\n    echo \"If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from\"\n    echo \"the device using adb pull.\"\n    exit 1\n  fi\nfi\n\n# Initialize the helper\nsetup_vendor \"$DEVICE\" \"$VENDOR\" \"$CM_ROOT\"\n\nextract \"$MY_DIR\"/proprietary-files.txt \"$SRC\"\n\n\"$MY_DIR\"/setup-makefiles.sh\n"
  },
  {
    "path": "gps/Android.mk",
    "content": "#\n# Copyright (C) 2015 The CyanogenMod Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\nLOCAL_PATH := $(call my-dir)\n\ninclude $(call all-subdir-makefiles,$(LOCAL_PATH))\n"
  },
  {
    "path": "gps/CleanSpec.mk",
    "content": "# Copyright (C) 2007 The Android Open Source Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n# If you don't need to do a full clean build but would like to touch\n# a file or delete some intermediate files, add a clean step to the end\n# of the list.  These steps will only be run once, if they haven't been\n# run before.\n#\n# E.g.:\n#     $(call add-clean-step, touch -c external/sqlite/sqlite3.h)\n#     $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)\n#\n# Always use \"touch -c\" and \"rm -f\" or \"rm -rf\" to gracefully deal with\n# files that are missing or have been moved.\n#\n# Use $(PRODUCT_OUT) to get to the \"out/target/product/blah/\" directory.\n# Use $(OUT_DIR) to refer to the \"out\" directory.\n#\n# If you need to re-do something that's already mentioned, just copy\n# the command and add it to the bottom of the list.  E.g., if a change\n# that you made last week required touching a file and a change you\n# made today requires touching the same file, just copy the old\n# touch step and add it to the end of the list.\n#\n# ************************************************\n# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST\n# ************************************************\n\n# For example:\n#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)\n#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)\n#$(call add-clean-step, find $(OUT_DIR) -type f -name \"IGTalkSession*\" -print0 | xargs -0 rm -f)\n#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)\n\n# ************************************************\n# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST\n# ************************************************\n$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libloc_api*)\n"
  },
  {
    "path": "gps/Makefile.am",
    "content": "# Makefile.am - Automake script for gps loc_api\n#\n\nACLOCAL_AMFLAGS = -I m4\n\nSUBDIRS = utils loc_api/libloc_api_50001 loc_api/loc_api_v02\n\npkgconfigdir = $(libdir)/pkgconfig\npkgconfig_DATA = loc-api.pc\nEXTRA_DIST = $(pkgconfig_DATA)\n"
  },
  {
    "path": "gps/configure.ac",
    "content": "# configure.ac -- Autoconf script for gps loc_api\n#\n# Process this file with autoconf to produce a configure script\n\n# Requires autoconf tool later than 2.61\nAC_PREREQ(2.61)\n# Initialize the gps loc_api package version 1.0.0\nAC_INIT([loc-api],1.0.0)\n# Does not strictly follow GNU Coding standards\nAM_INIT_AUTOMAKE([foreign])\n# Disables auto rebuilding of configure, Makefile.ins\nAM_MAINTAINER_MODE\n# Verifies the --srcdir is correct by checking for the path\nAC_CONFIG_SRCDIR([utils/loc_cfg.cpp])\n# defines some macros variable to be included by source\nAC_CONFIG_HEADERS([config.h])\nAC_CONFIG_MACRO_DIR([m4])\n\n# Checks for programs.\nAC_PROG_LIBTOOL\nAC_PROG_CXX\nAC_PROG_CC\nAM_PROG_CC_C_O\nAC_PROG_AWK\nAC_PROG_CPP\nAC_PROG_INSTALL\nAC_PROG_LN_S\nAC_PROG_MAKE_SET\nPKG_PROG_PKG_CONFIG\n\n# Checks for libraries.\nPKG_CHECK_MODULES([QMIF], [qmi-framework])\nAC_SUBST([QMIF_CFLAGS])\nAC_SUBST([QMIF_LIBS])\n\nAC_ARG_WITH([libhardware_includes],\n      AC_HELP_STRING([--with-libhardware-includes=@<:@dir@:>@],\n         [Specify the location of the libhardware headers]),\n      [libhardware_incdir=$withval],\n      with_libhardware_includes=no)\n\nif test \"x$with_libhardware_includes\" != \"xno\"; then\n   CPPFLAGS=\"${CPPFLAGS} -I${libhardware_incdir}\"\nfi\n\nAC_ARG_WITH([core_includes],\n      AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],\n         [Specify the location of the core headers]),\n      [core_incdir=$withval],\n      with_core_includes=no)\n\nif test \"x$with_core_includes\" != \"xno\"; then\n   CPPFLAGS=\"${CPPFLAGS} -I${core_incdir}\"\nfi\n\nAC_SUBST([CPPFLAGS])\n\nAC_ARG_WITH([glib],\n      AC_HELP_STRING([--with-glib],\n         [enable glib, building HLOS systems which use glib]))\n\nif (test \"x${with_glib}\" = \"xyes\"); then\n        AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])\n        PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,\n                                AC_MSG_ERROR(GThread >= 2.16 is required))\n        PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,\n                                AC_MSG_ERROR(GLib >= 2.16 is required))\n        GLIB_CFLAGS=\"$GLIB_CFLAGS $GTHREAD_CFLAGS\"\n        GLIB_LIBS=\"$GLIB_LIBS $GTHREAD_LIBS\"\n\n        AC_SUBST(GLIB_CFLAGS)\n        AC_SUBST(GLIB_LIBS)\nfi\n\nAM_CONDITIONAL(USE_GLIB, test \"x${with_glib}\" = \"xyes\")\n\nAC_CONFIG_FILES([ \\\n        Makefile \\\n        utils/Makefile \\\n        loc_api/libloc_api_50001/Makefile \\\n        loc_api/loc_api_v02/Makefile \\\n        loc-api.pc \\\n        ])\n\nAC_OUTPUT\n"
  },
  {
    "path": "gps/core/Android.mk",
    "content": "ifneq ($(BUILD_TINY_ANDROID),true)\n\nLOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE := libloc_core\nLOCAL_MODULE_OWNER := qcom\n\nLOCAL_MODULE_TAGS := optional\n\nifeq ($(TARGET_DEVICE),apq8026_lw)\nLOCAL_CFLAGS += -DPDK_FEATURE_SET\nelse ifeq ($(BOARD_VENDOR_QCOM_LOC_PDK_FEATURE_SET),true)\nLOCAL_CFLAGS += -DPDK_FEATURE_SET\nendif\n\nLOCAL_SHARED_LIBRARIES := \\\n    libutils \\\n    libcutils \\\n    libgps.utils \\\n    libdl\n\nLOCAL_SRC_FILES += \\\n    LocApiBase.cpp \\\n    LocAdapterBase.cpp \\\n    ContextBase.cpp \\\n    LocDualContext.cpp \\\n    loc_core_log.cpp\n\nLOCAL_CFLAGS += \\\n     -fno-short-enums \\\n     -D_ANDROID_\n\nLOCAL_C_INCLUDES:= \\\n    $(TARGET_OUT_HEADERS)/gps.utils \\\n    $(TARGET_OUT_HEADERS)/libflp\n\nLOCAL_COPY_HEADERS_TO:= libloc_core/\nLOCAL_COPY_HEADERS:= \\\n    LocApiBase.h \\\n    LocAdapterBase.h \\\n    ContextBase.h \\\n    LocDualContext.h \\\n    LBSProxyBase.h \\\n    UlpProxyBase.h \\\n    gps_extended_c.h \\\n    gps_extended.h \\\n    loc_core_log.h \\\n    LocAdapterProxyBase.h \\\n    fused_location_extended.h\n\nLOCAL_PRELINK_MODULE := false\n\ninclude $(BUILD_SHARED_LIBRARY)\n\nendif # not BUILD_TINY_ANDROID\n"
  },
  {
    "path": "gps/core/ContextBase.cpp",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_CtxBase\"\n\n#include <dlfcn.h>\n#include <cutils/sched_policy.h>\n#include <unistd.h>\n#include <ContextBase.h>\n#include <msg_q.h>\n#include <loc_target.h>\n#include <log_util.h>\n#include <loc_log.h>\n\nnamespace loc_core {\n\nLBSProxyBase* ContextBase::getLBSProxy(const char* libName)\n{\n    LBSProxyBase* proxy = NULL;\n    LOC_LOGD(\"%s:%d]: getLBSProxy libname: %s\\n\", __func__, __LINE__, libName);\n    void* lib = dlopen(libName, RTLD_NOW);\n\n    if ((void*)NULL != lib) {\n        getLBSProxy_t* getter = (getLBSProxy_t*)dlsym(lib, \"getLBSProxy\");\n        if (NULL != getter) {\n            proxy = (*getter)();\n        }\n    }\n    if (NULL == proxy) {\n        proxy = new LBSProxyBase();\n    }\n    LOC_LOGD(\"%s:%d]: Exiting\\n\", __func__, __LINE__);\n    return proxy;\n}\n\nLocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)\n{\n    LocApiBase* locApi = NULL;\n\n    // first if can not be MPQ\n    if (TARGET_MPQ != loc_get_target()) {\n        if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask, this))) {\n            void *handle = NULL;\n            //try to see if LocApiV02 is present\n            if((handle = dlopen(\"libloc_api_v02.so\", RTLD_NOW)) != NULL) {\n                LOC_LOGD(\"%s:%d]: libloc_api_v02.so is present\", __func__, __LINE__);\n                getLocApi_t* getter = (getLocApi_t*)dlsym(handle, \"getLocApi\");\n                if(getter != NULL) {\n                    LOC_LOGD(\"%s:%d]: getter is not NULL for LocApiV02\", __func__, __LINE__);\n                    locApi = (*getter)(mMsgTask, exMask, this);\n                }\n            }\n            // only RPC is the option now\n            else {\n                LOC_LOGD(\"%s:%d]: libloc_api_v02.so is NOT present. Trying RPC\",\n                         __func__, __LINE__);\n                handle = dlopen(\"libloc_api-rpc-qc.so\", RTLD_NOW);\n                if (NULL != handle) {\n                    getLocApi_t* getter = (getLocApi_t*)dlsym(handle, \"getLocApi\");\n                    if (NULL != getter) {\n                        LOC_LOGD(\"%s:%d]: getter is not NULL in RPC\", __func__, __LINE__);\n                        locApi = (*getter)(mMsgTask, exMask, this);\n                    }\n                }\n            }\n        }\n    }\n\n    // locApi could still be NULL at this time\n    // we would then create a dummy one\n    if (NULL == locApi) {\n        locApi = new LocApiBase(mMsgTask, exMask, this);\n    }\n\n    return locApi;\n}\n\nContextBase::ContextBase(const MsgTask* msgTask,\n                         LOC_API_ADAPTER_EVENT_MASK_T exMask,\n                         const char* libName) :\n    mLBSProxy(getLBSProxy(libName)),\n    mMsgTask(msgTask),\n    mLocApi(createLocApi(exMask)),\n    mLocApiProxy(mLocApi->getLocApiProxy())\n{\n}\n\n}\n"
  },
  {
    "path": "gps/core/ContextBase.h",
    "content": "/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef __LOC_CONTEXT_BASE__\n#define __LOC_CONTEXT_BASE__\n\n#include <stdbool.h>\n#include <ctype.h>\n#include <MsgTask.h>\n#include <LocApiBase.h>\n#include <LBSProxyBase.h>\n\nnamespace loc_core {\n\nclass LocAdapterBase;\n\nclass ContextBase {\n    static LBSProxyBase* getLBSProxy(const char* libName);\n    LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask);\nprotected:\n    const LBSProxyBase* mLBSProxy;\n    const MsgTask* mMsgTask;\n    LocApiBase* mLocApi;\n    LocApiProxyBase *mLocApiProxy;\npublic:\n    ContextBase(const MsgTask* msgTask,\n                LOC_API_ADAPTER_EVENT_MASK_T exMask,\n                const char* libName);\n    inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; }\n\n    inline const MsgTask* getMsgTask() { return mMsgTask; }\n    inline LocApiBase* getLocApi() { return mLocApi; }\n    inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }\n    inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); }\n    inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); }\n    inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); }\n    inline void requestUlp(LocAdapterBase* adapter,\n                           unsigned long capabilities) {\n        mLBSProxy->requestUlp(adapter, capabilities);\n    }\n    inline IzatDevId_t getIzatDevId() const {\n        return mLBSProxy->getIzatDevId();\n    }\n    inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); }\n};\n\n} // namespace loc_core\n\n#endif //__LOC_CONTEXT_BASE__\n"
  },
  {
    "path": "gps/core/LBSProxyBase.h",
    "content": "/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef IZAT_PROXY_BASE_H\n#define IZAT_PROXY_BASE_H\n#include <gps_extended.h>\n#include <MsgTask.h>\n\nnamespace loc_core {\n\nclass LocApiBase;\nclass LocAdapterBase;\nclass ContextBase;\n\nclass LBSProxyBase {\n    friend class ContextBase;\n    inline virtual LocApiBase*\n        getLocApi(const MsgTask* msgTask,\n                  LOC_API_ADAPTER_EVENT_MASK_T exMask,\n                  ContextBase* context) const {\n        return NULL;\n    }\nprotected:\n    inline LBSProxyBase() {}\npublic:\n    inline virtual ~LBSProxyBase() {}\n    inline virtual void requestUlp(LocAdapterBase* adapter,\n                                   unsigned long capabilities) const {}\n    inline virtual bool hasAgpsExtendedCapabilities() const { return false; }\n    inline virtual bool hasCPIExtendedCapabilities() const { return false; }\n    inline virtual void modemPowerVote(bool power) const {}\n    virtual void injectFeatureConfig(ContextBase* context) const {}\n    inline virtual IzatDevId_t getIzatDevId() const { return 0; }\n};\n\ntypedef LBSProxyBase* (getLBSProxy_t)();\n\n} // namespace loc_core\n\n#endif // IZAT_PROXY_BASE_H\n"
  },
  {
    "path": "gps/core/LocAdapterBase.cpp",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_LocAdapterBase\"\n\n#include <dlfcn.h>\n#include <LocAdapterBase.h>\n#include <loc_target.h>\n#include <log_util.h>\n#include <LocAdapterProxyBase.h>\n\nnamespace loc_core {\n\n// This is the top level class, so the constructor will\n// always gets called. Here we prepare for the default.\n// But if getLocApi(targetEnumType target) is overriden,\n// the right locApi should get created.\nLocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,\n                               ContextBase* context, LocAdapterProxyBase *adapterProxyBase) :\n    mEvtMask(mask), mContext(context),\n    mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase),\n    mMsgTask(context->getMsgTask())\n{\n    mLocApi->addAdapter(this);\n}\n\nvoid LocAdapterBase::handleEngineUpEvent()\n{\n    if (mLocAdapterProxyBase) {\n        mLocAdapterProxyBase->handleEngineUpEvent();\n    }\n}\n\nvoid LocAdapterBase::handleEngineDownEvent()\n{\n    if (mLocAdapterProxyBase) {\n        mLocAdapterProxyBase->handleEngineDownEvent();\n    }\n}\n\nvoid LocAdapterBase::\n    reportPosition(UlpLocation &location,\n                   GpsLocationExtended &locationExtended,\n                   void* locationExt,\n                   enum loc_sess_status status,\n                   LocPosTechMask loc_technology_mask) {\n    if (mLocAdapterProxyBase == NULL ||\n        !mLocAdapterProxyBase->reportPosition(location,\n                                              locationExtended,\n                                              status,\n                                              loc_technology_mask)) {\n        DEFAULT_IMPL()\n    }\n}\n\nvoid LocAdapterBase::\n    reportSv(QcomSvStatus &svStatus,\n             GpsLocationExtended &locationExtended,\n             void* svExt)\nDEFAULT_IMPL()\n\n\nvoid LocAdapterBase::\n    reportStatus(GpsStatusValue status)\nDEFAULT_IMPL()\n\n\nvoid LocAdapterBase::\n    reportNmea(const char* nmea, int length)\nDEFAULT_IMPL()\n\nbool LocAdapterBase::\n    reportXtraServer(const char* url1, const char* url2,\n                     const char* url3, const int maxlength)\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    requestXtraData()\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    requestTime()\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    requestLocation()\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    requestATL(int connHandle, AGpsType agps_type)\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    releaseATL(int connHandle)\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    requestSuplES(int connHandle)\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    reportDataCallOpened()\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    reportDataCallClosed()\nDEFAULT_IMPL(false)\n\nbool LocAdapterBase::\n    requestNiNotify(GpsNiNotification &notify, const void* data)\nDEFAULT_IMPL(false)\n\nvoid LocAdapterBase::\n    reportGpsMeasurementData(GpsData &gpsMeasurementData)\nDEFAULT_IMPL()\n} // namespace loc_core\n"
  },
  {
    "path": "gps/core/LocAdapterBase.h",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_API_ADAPTER_BASE_H\n#define LOC_API_ADAPTER_BASE_H\n\n#include <gps_extended.h>\n#include <UlpProxyBase.h>\n#include <ContextBase.h>\n\nnamespace loc_core {\n\nclass LocAdapterProxyBase;\n\nclass LocAdapterBase {\nprotected:\n    LOC_API_ADAPTER_EVENT_MASK_T mEvtMask;\n    ContextBase* mContext;\n    LocApiBase* mLocApi;\n    LocAdapterProxyBase* mLocAdapterProxyBase;\n    const MsgTask* mMsgTask;\n\n    inline LocAdapterBase(const MsgTask* msgTask) :\n        mEvtMask(0), mContext(NULL), mLocApi(NULL),\n        mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {}\npublic:\n    inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }\n    LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,\n                   ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL);\n    inline LOC_API_ADAPTER_EVENT_MASK_T\n        checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {\n        return mEvtMask & mask;\n    }\n\n    inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const {\n        return mEvtMask;\n    }\n\n    inline void sendMsg(const LocMsg* msg) const {\n        mMsgTask->sendMsg(msg);\n    }\n\n    inline void sendMsg(const LocMsg* msg) {\n        mMsgTask->sendMsg(msg);\n    }\n\n    inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event,\n                       loc_registration_mask_status isEnabled)\n    {\n        mEvtMask =\n            isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event);\n\n        mLocApi->updateEvtMask();\n    }\n\n    // This will be overridden by the individual adapters\n    // if necessary.\n    inline virtual void setUlpProxy(UlpProxyBase* ulp) {}\n    virtual void handleEngineUpEvent();\n    virtual void handleEngineDownEvent();\n    inline virtual void setPositionModeInt(LocPosMode& posMode) {}\n    virtual void startFixInt() {}\n    virtual void stopFixInt() {}\n    virtual void getZppInt() {}\n    virtual void reportPosition(UlpLocation &location,\n                                GpsLocationExtended &locationExtended,\n                                void* locationExt,\n                                enum loc_sess_status status,\n                                LocPosTechMask loc_technology_mask);\n    virtual void reportSv(QcomSvStatus &svStatus,\n                          GpsLocationExtended &locationExtended,\n                          void* svExt);\n    virtual void reportStatus(GpsStatusValue status);\n    virtual void reportNmea(const char* nmea, int length);\n    virtual bool reportXtraServer(const char* url1, const char* url2,\n                                  const char* url3, const int maxlength);\n    virtual bool requestXtraData();\n    virtual bool requestTime();\n    virtual bool requestLocation();\n    virtual bool requestATL(int connHandle, AGpsType agps_type);\n    virtual bool releaseATL(int connHandle);\n    virtual bool requestSuplES(int connHandle);\n    virtual bool reportDataCallOpened();\n    virtual bool reportDataCallClosed();\n    virtual bool requestNiNotify(GpsNiNotification &notify,\n                                 const void* data);\n    inline virtual bool isInSession() { return false; }\n    ContextBase* getContext() const { return mContext; }\n    virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData);\n};\n\n} // namespace loc_core\n\n#endif //LOC_API_ADAPTER_BASE_H\n"
  },
  {
    "path": "gps/core/LocAdapterProxyBase.h",
    "content": "/* Copyright (c) 2014 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_ADAPTER_PROXY_BASE_H\n#define LOC_ADAPTER_PROXY_BASE_H\n\n#include <ContextBase.h>\n#include <gps_extended.h>\n\nnamespace loc_core {\n\nclass LocAdapterProxyBase {\nprivate:\n    LocAdapterBase *mLocAdapterBase;\nprotected:\n    inline LocAdapterProxyBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,\n                   ContextBase* context):\n                   mLocAdapterBase(new LocAdapterBase(mask, context, this)) {\n    }\n    inline virtual ~LocAdapterProxyBase() {\n        delete mLocAdapterBase;\n    }\n    ContextBase* getContext() const {\n        return mLocAdapterBase->getContext();\n    }\n    inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event,\n                              loc_registration_mask_status isEnabled) {\n        mLocAdapterBase->updateEvtMask(event,isEnabled);\n    }\n\npublic:\n    inline virtual void handleEngineUpEvent() {};\n    inline virtual void handleEngineDownEvent() {};\n    inline virtual bool reportPosition(UlpLocation &location,\n                                       GpsLocationExtended &locationExtended,\n                                       enum loc_sess_status status,\n                                       LocPosTechMask loc_technology_mask) {\n        return false;\n    }\n};\n\n} // namespace loc_core\n\n#endif //LOC_ADAPTER_PROXY_BASE_H\n"
  },
  {
    "path": "gps/core/LocApiBase.cpp",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_LocApiBase\"\n\n#include <dlfcn.h>\n#include <LocApiBase.h>\n#include <LocAdapterBase.h>\n#include <log_util.h>\n#include <LocDualContext.h>\n\nnamespace loc_core {\n\n#define TO_ALL_LOCADAPTERS(call) TO_ALL_ADAPTERS(mLocAdapters, (call))\n#define TO_1ST_HANDLING_LOCADAPTERS(call) TO_1ST_HANDLING_ADAPTER(mLocAdapters, (call))\n\nint hexcode(char *hexstring, int string_size,\n            const char *data, int data_size)\n{\n   int i;\n   for (i = 0; i < data_size; i++)\n   {\n      char ch = data[i];\n      if (i*2 + 3 <= string_size)\n      {\n         snprintf(&hexstring[i*2], 3, \"%02X\", ch);\n      }\n      else {\n         break;\n      }\n   }\n   return i;\n}\n\nint decodeAddress(char *addr_string, int string_size,\n                   const char *data, int data_size)\n{\n    const char addr_prefix = 0x91;\n    int i, idxOutput = 0;\n\n    if (!data || !addr_string) { return 0; }\n\n    if (data[0] != addr_prefix)\n    {\n        LOC_LOGW(\"decodeAddress: address prefix is not 0x%x but 0x%x\", addr_prefix, data[0]);\n        addr_string[0] = '\\0';\n        return 0; // prefix not correct\n    }\n\n    for (i = 1; i < data_size; i++)\n    {\n        unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4;\n        if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; }\n        if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; }\n    }\n\n    addr_string[idxOutput] = '\\0'; // Terminates the string\n\n    return idxOutput;\n}\n\nstruct LocSsrMsg : public LocMsg {\n    LocApiBase* mLocApi;\n    inline LocSsrMsg(LocApiBase* locApi) :\n        LocMsg(), mLocApi(locApi)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mLocApi->close();\n        mLocApi->open(mLocApi->getEvtMask());\n    }\n    inline void locallog() {\n        LOC_LOGV(\"LocSsrMsg\");\n    }\n    inline virtual void log() {\n        locallog();\n    }\n};\n\nstruct LocOpenMsg : public LocMsg {\n    LocApiBase* mLocApi;\n    LOC_API_ADAPTER_EVENT_MASK_T mMask;\n    inline LocOpenMsg(LocApiBase* locApi,\n                      LOC_API_ADAPTER_EVENT_MASK_T mask) :\n        LocMsg(), mLocApi(locApi), mMask(mask)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mLocApi->open(mMask);\n    }\n    inline void locallog() {\n        LOC_LOGV(\"%s:%d]: LocOpen Mask: %x\\n\",\n                 __func__, __LINE__, mMask);\n    }\n    inline virtual void log() {\n        locallog();\n    }\n};\n\nLocApiBase::LocApiBase(const MsgTask* msgTask,\n                       LOC_API_ADAPTER_EVENT_MASK_T excludedMask,\n                       ContextBase* context) :\n    mExcludedMask(excludedMask), mMsgTask(msgTask),\n    mMask(0), mSupportedMsg(0), mContext(context)\n{\n    memset(mLocAdapters, 0, sizeof(mLocAdapters));\n}\n\nLOC_API_ADAPTER_EVENT_MASK_T LocApiBase::getEvtMask()\n{\n    LOC_API_ADAPTER_EVENT_MASK_T mask = 0;\n\n    TO_ALL_LOCADAPTERS(mask |= mLocAdapters[i]->getEvtMask());\n\n    return mask & ~mExcludedMask;\n}\n\nbool LocApiBase::isInSession()\n{\n    bool inSession = false;\n\n    for (int i = 0;\n         !inSession && i < MAX_ADAPTERS && NULL != mLocAdapters[i];\n         i++) {\n        inSession = mLocAdapters[i]->isInSession();\n    }\n\n    return inSession;\n}\n\nvoid LocApiBase::addAdapter(LocAdapterBase* adapter)\n{\n    for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {\n        if (mLocAdapters[i] == NULL) {\n            mLocAdapters[i] = adapter;\n            mMsgTask->sendMsg(new LocOpenMsg(this,\n                                             (adapter->getEvtMask())));\n            break;\n        }\n    }\n}\n\nvoid LocApiBase::removeAdapter(LocAdapterBase* adapter)\n{\n    for (int i = 0;\n         i < MAX_ADAPTERS && NULL != mLocAdapters[i];\n         i++) {\n        if (mLocAdapters[i] == adapter) {\n            mLocAdapters[i] = NULL;\n\n            // shift the rest of the adapters up so that the pointers\n            // in the array do not have holes.  This should be more\n            // performant, because the array maintenance is much much\n            // less frequent than event handlings, which need to linear\n            // search all the adapters\n            int j = i;\n            while (++i < MAX_ADAPTERS && mLocAdapters[i] != NULL);\n\n            // i would be MAX_ADAPTERS or point to a NULL\n            i--;\n            // i now should point to a none NULL adapter within valid\n            // range although i could be equal to j, but it won't hurt.\n            // No need to check it, as it gains nothing.\n            mLocAdapters[j] = mLocAdapters[i];\n            // this makes sure that we exit the for loop\n            mLocAdapters[i] = NULL;\n\n            // if we have an empty list of adapters\n            if (0 == i) {\n                close();\n            } else {\n                // else we need to remove the bit\n                mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));\n            }\n        }\n    }\n}\n\nvoid LocApiBase::updateEvtMask()\n{\n    mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));\n}\n\nvoid LocApiBase::handleEngineUpEvent()\n{\n    // This will take care of renegotiating the loc handle\n    mMsgTask->sendMsg(new LocSsrMsg(this));\n\n    LocDualContext::injectFeatureConfig(mContext);\n\n    // loop through adapters, and deliver to all adapters.\n    TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent());\n}\n\nvoid LocApiBase::handleEngineDownEvent()\n{\n    // loop through adapters, and deliver to all adapters.\n    TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());\n}\n\nvoid LocApiBase::reportPosition(UlpLocation &location,\n                                GpsLocationExtended &locationExtended,\n                                void* locationExt,\n                                enum loc_sess_status status,\n                                LocPosTechMask loc_technology_mask)\n{\n    // print the location info before delivering\n    LOC_LOGV(\"flags: %d\\n  source: %d\\n  latitude: %f\\n  longitude: %f\\n  \"\n             \"altitude: %f\\n  speed: %f\\n  bearing: %f\\n  accuracy: %f\\n  \"\n             \"timestamp: %lld\\n  rawDataSize: %d\\n  rawData: %p\\n  \"\n             \"Session status: %d\\n Technology mask: %u\",\n             location.gpsLocation.flags, location.position_source,\n             location.gpsLocation.latitude, location.gpsLocation.longitude,\n             location.gpsLocation.altitude, location.gpsLocation.speed,\n             location.gpsLocation.bearing, location.gpsLocation.accuracy,\n             location.gpsLocation.timestamp, location.rawDataSize,\n             location.rawData, status, loc_technology_mask);\n    // loop through adapters, and deliver to all adapters.\n    TO_ALL_LOCADAPTERS(\n        mLocAdapters[i]->reportPosition(location,\n                                        locationExtended,\n                                        locationExt,\n                                        status,\n                                        loc_technology_mask)\n    );\n}\n\nvoid LocApiBase::reportSv(QcomSvStatus &svStatus,\n                  GpsLocationExtended &locationExtended,\n                  void* svExt)\n{\n    // print the SV info before delivering\n    LOC_LOGV(\"num sv: %d\\n  ephemeris mask: %dxn  almanac mask: %x\\n  gps/glo/bds in use\"\n             \" mask: %x/%x/%x\\n      sv: prn         snr       elevation      azimuth\",\n             svStatus.num_svs, svStatus.ephemeris_mask,\n             svStatus.almanac_mask, svStatus.gps_used_in_fix_mask,\n             svStatus.glo_used_in_fix_mask, svStatus.bds_used_in_fix_mask);\n    for (int i = 0; i < svStatus.num_svs && i < GPS_MAX_SVS; i++) {\n        LOC_LOGV(\"   %d:   %d    %f    %f    %f\",\n                 i,\n                 svStatus.sv_list[i].prn,\n                 svStatus.sv_list[i].snr,\n                 svStatus.sv_list[i].elevation,\n                 svStatus.sv_list[i].azimuth);\n    }\n    // loop through adapters, and deliver to all adapters.\n    TO_ALL_LOCADAPTERS(\n        mLocAdapters[i]->reportSv(svStatus,\n                                     locationExtended,\n                                     svExt)\n    );\n}\n\nvoid LocApiBase::reportStatus(GpsStatusValue status)\n{\n    // loop through adapters, and deliver to all adapters.\n    TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportStatus(status));\n}\n\nvoid LocApiBase::reportNmea(const char* nmea, int length)\n{\n    // loop through adapters, and deliver to all adapters.\n    TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportNmea(nmea, length));\n}\n\nvoid LocApiBase::reportXtraServer(const char* url1, const char* url2,\n                                  const char* url3, const int maxlength)\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportXtraServer(url1, url2, url3, maxlength));\n\n}\n\nvoid LocApiBase::requestXtraData()\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestXtraData());\n}\n\nvoid LocApiBase::requestTime()\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestTime());\n}\n\nvoid LocApiBase::requestLocation()\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestLocation());\n}\n\nvoid LocApiBase::requestATL(int connHandle, AGpsType agps_type)\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestATL(connHandle, agps_type));\n}\n\nvoid LocApiBase::releaseATL(int connHandle)\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->releaseATL(connHandle));\n}\n\nvoid LocApiBase::requestSuplES(int connHandle)\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestSuplES(connHandle));\n}\n\nvoid LocApiBase::reportDataCallOpened()\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallOpened());\n}\n\nvoid LocApiBase::reportDataCallClosed()\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->reportDataCallClosed());\n}\n\nvoid LocApiBase::requestNiNotify(GpsNiNotification &notify, const void* data)\n{\n    // loop through adapters, and deliver to the first handling adapter.\n    TO_1ST_HANDLING_LOCADAPTERS(mLocAdapters[i]->requestNiNotify(notify, data));\n}\n\nvoid LocApiBase::saveSupportedMsgList(uint64_t supportedMsgList)\n{\n    mSupportedMsg = supportedMsgList;\n}\n\nvoid* LocApiBase :: getSibling()\n    DEFAULT_IMPL(NULL)\n\nLocApiProxyBase* LocApiBase :: getLocApiProxy()\n    DEFAULT_IMPL(NULL)\n\nvoid LocApiBase::reportGpsMeasurementData(GpsData &gpsMeasurementData)\n{\n    // loop through adapters, and deliver to all adapters.\n    TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGpsMeasurementData(gpsMeasurementData));\n}\n\nenum loc_api_adapter_err LocApiBase::\n   open(LOC_API_ADAPTER_EVENT_MASK_T mask)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    close()\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    startFix(const LocPosMode& posMode)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    stopFix()\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    deleteAidingData(GpsAidingData f)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    enableData(int enable)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setAPN(char* apn, int len)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    injectPosition(double latitude, double longitude, float accuracy)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setXtraData(char* data, int length)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    requestXtraServer()\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n   atlOpenStatus(int handle, int is_succ, char* apn,\n                 AGpsBearerType bear, AGpsType agpsType)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    atlCloseStatus(int handle, int is_succ)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setPositionMode(const LocPosMode& posMode)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setServer(const char* url, int len)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setServer(unsigned int ip, int port,\n              LocServerType type)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    informNiResponse(GpsUserResponseType userResponse,\n                     const void* passThroughData)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setSUPLVersion(uint32_t version)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setLPPConfig(uint32_t profile)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setSensorControlConfig(int sensorUsage,\n                           int sensorProvider)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,\n                        float gyroBiasVarianceRandomWalk,\n                        bool accelBiasVarianceRandomWalk_valid,\n                        float accelBiasVarianceRandomWalk,\n                        bool angleBiasVarianceRandomWalk_valid,\n                        float angleBiasVarianceRandomWalk,\n                        bool rateBiasVarianceRandomWalk_valid,\n                        float rateBiasVarianceRandomWalk,\n                        bool velocityBiasVarianceRandomWalk_valid,\n                        float velocityBiasVarianceRandomWalk)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setSensorPerfControlConfig(int controlMode,\n                               int accelSamplesPerBatch,\n                               int accelBatchesPerSec,\n                               int gyroSamplesPerBatch,\n                               int gyroBatchesPerSec,\n                               int accelSamplesPerBatchHigh,\n                               int accelBatchesPerSecHigh,\n                               int gyroSamplesPerBatchHigh,\n                               int gyroBatchesPerSecHigh,\n                               int algorithmConfig)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setExtPowerConfig(int isBatteryCharging)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n    setAGLONASSProtocol(unsigned long aGlonassProtocol)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n   getWwanZppFix(GpsLocation& zppLoc)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nenum loc_api_adapter_err LocApiBase::\n   getBestAvailableZppFix(GpsLocation& zppLoc)\n{\n   memset(&zppLoc, 0, sizeof(zppLoc));\n   DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n}\n\nenum loc_api_adapter_err LocApiBase::\n   getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask)\n{\n   memset(&zppLoc, 0, sizeof(zppLoc));\n   memset(&tech_mask, 0, sizeof(tech_mask));\n   DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n}\n\nint LocApiBase::\n    initDataServiceClient()\nDEFAULT_IMPL(-1)\n\nint LocApiBase::\n    openAndStartDataCall()\nDEFAULT_IMPL(-1)\n\nvoid LocApiBase::\n    stopDataCall()\nDEFAULT_IMPL()\n\nvoid LocApiBase::\n    closeDataCall()\nDEFAULT_IMPL()\n\nint LocApiBase::\n    setGpsLock(LOC_GPS_LOCK_MASK lock)\nDEFAULT_IMPL(-1)\n\nvoid LocApiBase::\n    installAGpsCert(const DerEncodedCertificate* pData,\n                    size_t length,\n                    uint32_t slotBitMask)\nDEFAULT_IMPL()\n\nint LocApiBase::\n    getGpsLock()\nDEFAULT_IMPL(-1)\n\nenum loc_api_adapter_err LocApiBase::\n    setXtraVersionCheck(enum xtra_version_check check)\nDEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)\n\nint LocApiBase::\n    updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event,\n                           loc_registration_mask_status isEnabled)\nDEFAULT_IMPL(-1)\n\nbool LocApiBase::\n    gnssConstellationConfig()\nDEFAULT_IMPL(false)\n\n} // namespace loc_core\n"
  },
  {
    "path": "gps/core/LocApiBase.h",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_API_BASE_H\n#define LOC_API_BASE_H\n\n#include <stddef.h>\n#include <ctype.h>\n#include <gps_extended.h>\n#include <MsgTask.h>\n#include <log_util.h>\n\nnamespace loc_core {\nclass ContextBase;\n\nint hexcode(char *hexstring, int string_size,\n            const char *data, int data_size);\nint decodeAddress(char *addr_string, int string_size,\n                  const char *data, int data_size);\n\n#define MAX_ADAPTERS          10\n\n#define TO_ALL_ADAPTERS(adapters, call)                                \\\n    for (int i = 0; i < MAX_ADAPTERS && NULL != (adapters)[i]; i++) {  \\\n        call;                                                          \\\n    }\n\n#define TO_1ST_HANDLING_ADAPTER(adapters, call)                              \\\n    for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);\n\nenum xtra_version_check {\n    DISABLED,\n    AUTO,\n    XTRA2,\n    XTRA3\n};\n\nclass LocAdapterBase;\nstruct LocSsrMsg;\nstruct LocOpenMsg;\n\nclass LocApiProxyBase {\npublic:\n    inline LocApiProxyBase() {}\n    inline virtual ~LocApiProxyBase() {}\n    inline virtual void* getSibling2() { return NULL; }\n};\n\nclass LocApiBase {\n    friend struct LocSsrMsg;\n    //LocOpenMsg calls open() which makes it necessary to declare\n    //it as a friend\n    friend struct LocOpenMsg;\n    friend class ContextBase;\n    const MsgTask* mMsgTask;\n    ContextBase *mContext;\n    LocAdapterBase* mLocAdapters[MAX_ADAPTERS];\n    uint64_t mSupportedMsg;\n\nprotected:\n    virtual enum loc_api_adapter_err\n        open(LOC_API_ADAPTER_EVENT_MASK_T mask);\n    virtual enum loc_api_adapter_err\n        close();\n    LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();\n    LOC_API_ADAPTER_EVENT_MASK_T mMask;\n    LocApiBase(const MsgTask* msgTask,\n               LOC_API_ADAPTER_EVENT_MASK_T excludedMask,\n               ContextBase* context = NULL);\n    inline virtual ~LocApiBase() { close(); }\n    bool isInSession();\n    const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;\n\npublic:\n    inline void sendMsg(const LocMsg* msg) const {\n        mMsgTask->sendMsg(msg);\n    }\n\n    void addAdapter(LocAdapterBase* adapter);\n    void removeAdapter(LocAdapterBase* adapter);\n\n    // upward calls\n    void handleEngineUpEvent();\n    void handleEngineDownEvent();\n    void reportPosition(UlpLocation &location,\n                        GpsLocationExtended &locationExtended,\n                        void* locationExt,\n                        enum loc_sess_status status,\n                        LocPosTechMask loc_technology_mask =\n                                  LOC_POS_TECH_MASK_DEFAULT);\n    void reportSv(QcomSvStatus &svStatus,\n                  GpsLocationExtended &locationExtended,\n                  void* svExt);\n    void reportStatus(GpsStatusValue status);\n    void reportNmea(const char* nmea, int length);\n    void reportXtraServer(const char* url1, const char* url2,\n                          const char* url3, const int maxlength);\n    void requestXtraData();\n    void requestTime();\n    void requestLocation();\n    void requestATL(int connHandle, AGpsType agps_type);\n    void releaseATL(int connHandle);\n    void requestSuplES(int connHandle);\n    void reportDataCallOpened();\n    void reportDataCallClosed();\n    void requestNiNotify(GpsNiNotification &notify, const void* data);\n    void saveSupportedMsgList(uint64_t supportedMsgList);\n    void reportGpsMeasurementData(GpsData &gpsMeasurementData);\n\n    // downward calls\n    // All below functions are to be defined by adapter specific modules:\n    // RPC, QMI, etc.  The default implementation is empty.\n\n    virtual void* getSibling();\n    virtual LocApiProxyBase* getLocApiProxy();\n    virtual enum loc_api_adapter_err\n        startFix(const LocPosMode& posMode);\n    virtual enum loc_api_adapter_err\n        stopFix();\n    virtual enum loc_api_adapter_err\n        deleteAidingData(GpsAidingData f);\n    virtual enum loc_api_adapter_err\n        enableData(int enable);\n    virtual enum loc_api_adapter_err\n        setAPN(char* apn, int len);\n    virtual enum loc_api_adapter_err\n        injectPosition(double latitude, double longitude, float accuracy);\n    virtual enum loc_api_adapter_err\n        setTime(GpsUtcTime time, int64_t timeReference, int uncertainty);\n    virtual enum loc_api_adapter_err\n        setXtraData(char* data, int length);\n    virtual enum loc_api_adapter_err\n        requestXtraServer();\n    virtual enum loc_api_adapter_err\n        atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType);\n    virtual enum loc_api_adapter_err\n        atlCloseStatus(int handle, int is_succ);\n    virtual enum loc_api_adapter_err\n        setPositionMode(const LocPosMode& posMode);\n    virtual enum loc_api_adapter_err\n        setServer(const char* url, int len);\n    virtual enum loc_api_adapter_err\n        setServer(unsigned int ip, int port,\n                  LocServerType type);\n    virtual enum loc_api_adapter_err\n        informNiResponse(GpsUserResponseType userResponse, const void* passThroughData);\n    virtual enum loc_api_adapter_err\n        setSUPLVersion(uint32_t version);\n    virtual enum loc_api_adapter_err\n        setLPPConfig(uint32_t profile);\n    virtual enum loc_api_adapter_err\n        setSensorControlConfig(int sensorUsage, int sensorProvider);\n    virtual enum loc_api_adapter_err\n        setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,\n                            float gyroBiasVarianceRandomWalk,\n                            bool accelBiasVarianceRandomWalk_valid,\n                            float accelBiasVarianceRandomWalk,\n                            bool angleBiasVarianceRandomWalk_valid,\n                            float angleBiasVarianceRandomWalk,\n                            bool rateBiasVarianceRandomWalk_valid,\n                            float rateBiasVarianceRandomWalk,\n                            bool velocityBiasVarianceRandomWalk_valid,\n                            float velocityBiasVarianceRandomWalk);\n    virtual enum loc_api_adapter_err\n        setSensorPerfControlConfig(int controlMode,\n                               int accelSamplesPerBatch,\n                               int accelBatchesPerSec,\n                               int gyroSamplesPerBatch,\n                               int gyroBatchesPerSec,\n                               int accelSamplesPerBatchHigh,\n                               int accelBatchesPerSecHigh,\n                               int gyroSamplesPerBatchHigh,\n                               int gyroBatchesPerSecHigh,\n                               int algorithmConfig);\n    virtual enum loc_api_adapter_err\n        setExtPowerConfig(int isBatteryCharging);\n    virtual enum loc_api_adapter_err\n        setAGLONASSProtocol(unsigned long aGlonassProtocol);\n    virtual enum loc_api_adapter_err\n        getWwanZppFix(GpsLocation & zppLoc);\n    virtual enum loc_api_adapter_err\n        getBestAvailableZppFix(GpsLocation & zppLoc);\n    virtual enum loc_api_adapter_err\n        getBestAvailableZppFix(GpsLocation & zppLoc, LocPosTechMask & tech_mask);\n    virtual int initDataServiceClient();\n    virtual int openAndStartDataCall();\n    virtual void stopDataCall();\n    virtual void closeDataCall();\n    virtual void installAGpsCert(const DerEncodedCertificate* pData,\n                                 size_t length,\n                                 uint32_t slotBitMask);\n    inline virtual void setInSession(bool inSession) {}\n    inline bool isMessageSupported (LocCheckingMessagesID msgID) const {\n        if (msgID > (sizeof(mSupportedMsg) << 3)) {\n            return false;\n        } else {\n            uint32_t messageChecker = 1 << msgID;\n            return (messageChecker & mSupportedMsg) == messageChecker;\n        }\n    }\n    void updateEvtMask();\n\n    /*Values for lock\n      1 = Do not lock any position sessions\n      2 = Lock MI position sessions\n      3 = Lock MT position sessions\n      4 = Lock all position sessions\n     */\n    virtual int setGpsLock(LOC_GPS_LOCK_MASK lock);\n    /*\n      Returns\n      Current value of GPS Lock on success\n      -1 on failure\n     */\n    virtual int getGpsLock(void);\n\n    virtual enum loc_api_adapter_err setXtraVersionCheck(enum xtra_version_check check);\n\n    /*\n      Update gps reporting events\n     */\n    virtual int updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event,\n                                       loc_registration_mask_status isEnabled);\n    /*\n      Check if the modem support the service\n     */\n    virtual bool gnssConstellationConfig();\n};\n\ntypedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask,\n                                  LOC_API_ADAPTER_EVENT_MASK_T exMask,\n                                  ContextBase *context);\n\n} // namespace loc_core\n\n#endif //LOC_API_BASE_H\n"
  },
  {
    "path": "gps/core/LocDualContext.cpp",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_DualCtx\"\n\n#include <cutils/sched_policy.h>\n#include <unistd.h>\n#include <LocDualContext.h>\n#include <msg_q.h>\n#include <log_util.h>\n#include <loc_log.h>\n\nnamespace loc_core {\n\n// nothing exclude for foreground\nconst LOC_API_ADAPTER_EVENT_MASK_T\nLocDualContext::mFgExclMask = 0;\n// excluded events for background clients\nconst LOC_API_ADAPTER_EVENT_MASK_T\nLocDualContext::mBgExclMask =\n    (LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |\n     LOC_API_ADAPTER_BIT_SATELLITE_REPORT |\n     LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |\n     LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT |\n     LOC_API_ADAPTER_BIT_IOCTL_REPORT |\n     LOC_API_ADAPTER_BIT_STATUS_REPORT |\n     LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT |\n     LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT);\n\nconst MsgTask* LocDualContext::mMsgTask = NULL;\nContextBase* LocDualContext::mFgContext = NULL;\nContextBase* LocDualContext::mBgContext = NULL;\nContextBase* LocDualContext::mInjectContext = NULL;\n// the name must be shorter than 15 chars\nconst char* LocDualContext::mLocationHalName = \"Loc_hal_worker\";\nconst char* LocDualContext::mLBSLibName = \"liblbs_core.so\";\n\npthread_mutex_t LocDualContext::mGetLocContextMutex = PTHREAD_MUTEX_INITIALIZER;\n\nconst MsgTask* LocDualContext::getMsgTask(LocThread::tCreate tCreator,\n                                          const char* name, bool joinable)\n{\n    if (NULL == mMsgTask) {\n        mMsgTask = new MsgTask(tCreator, name, joinable);\n    }\n    return mMsgTask;\n}\n\ninline\nconst MsgTask* LocDualContext::getMsgTask(const char* name, bool joinable) {\n    return getMsgTask((LocThread::tCreate)NULL, name, joinable);\n}\n\nContextBase* LocDualContext::getLocFgContext(LocThread::tCreate tCreator,\n            LocMsg* firstMsg, const char* name, bool joinable)\n{\n    pthread_mutex_lock(&LocDualContext::mGetLocContextMutex);\n    LOC_LOGD(\"%s:%d]: querying ContextBase with tCreator\", __func__, __LINE__);\n    if (NULL == mFgContext) {\n        LOC_LOGD(\"%s:%d]: creating msgTask with tCreator\", __func__, __LINE__);\n        const MsgTask* msgTask = getMsgTask(tCreator, name, joinable);\n        mFgContext = new LocDualContext(msgTask,\n                                        mFgExclMask);\n    }\n    if(NULL == mInjectContext) {\n        LOC_LOGD(\"%s:%d]: mInjectContext is FgContext\", __func__, __LINE__);\n        mInjectContext = mFgContext;\n        injectFeatureConfig(mInjectContext);\n    }\n    pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);\n\n    if (firstMsg) {\n        mFgContext->sendMsg(firstMsg);\n    }\n\n    return mFgContext;\n}\n\nContextBase* LocDualContext::getLocBgContext(LocThread::tCreate tCreator,\n            LocMsg* firstMsg, const char* name, bool joinable)\n{\n    pthread_mutex_lock(&LocDualContext::mGetLocContextMutex);\n    LOC_LOGD(\"%s:%d]: querying ContextBase with tCreator\", __func__, __LINE__);\n    if (NULL == mBgContext) {\n        LOC_LOGD(\"%s:%d]: creating msgTask with tCreator\", __func__, __LINE__);\n        const MsgTask* msgTask = getMsgTask(tCreator, name, joinable);\n        mBgContext = new LocDualContext(msgTask,\n                                        mBgExclMask);\n    }\n    if(NULL == mInjectContext) {\n        LOC_LOGD(\"%s:%d]: mInjectContext is BgContext\", __func__, __LINE__);\n        mInjectContext = mBgContext;\n        injectFeatureConfig(mInjectContext);\n    }\n    pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);\n\n    if (firstMsg) {\n        mBgContext->sendMsg(firstMsg);\n    }\n\n    return mBgContext;\n}\n\nvoid LocDualContext :: injectFeatureConfig(ContextBase *curContext)\n{\n    LOC_LOGD(\"%s:%d]: Enter\", __func__, __LINE__);\n    if(curContext == mInjectContext) {\n        LOC_LOGD(\"%s:%d]: Calling LBSProxy (%p) to inject feature config\",\n                 __func__, __LINE__, ((LocDualContext *)mInjectContext)->mLBSProxy);\n        ((LocDualContext *)mInjectContext)->mLBSProxy->injectFeatureConfig(curContext);\n    }\n    LOC_LOGD(\"%s:%d]: Exit\", __func__, __LINE__);\n}\n\nLocDualContext::LocDualContext(const MsgTask* msgTask,\n                               LOC_API_ADAPTER_EVENT_MASK_T exMask) :\n    ContextBase(msgTask, exMask, mLBSLibName)\n{\n}\n\n}\n"
  },
  {
    "path": "gps/core/LocDualContext.h",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef __LOC_ENG_CONTEXT__\n#define __LOC_ENG_CONTEXT__\n\n#include <stdbool.h>\n#include <ctype.h>\n#include <dlfcn.h>\n#include <ContextBase.h>\n\nnamespace loc_core {\n\nclass LocDualContext : public ContextBase {\n    static const MsgTask* mMsgTask;\n    static ContextBase* mFgContext;\n    static ContextBase* mBgContext;\n    static ContextBase* mInjectContext;\n    static const MsgTask* getMsgTask(LocThread::tCreate tCreator,\n                                     const char* name, bool joinable = true);\n    static const MsgTask* getMsgTask(const char* name, bool joinable = true);\n    static pthread_mutex_t mGetLocContextMutex;\n\nprotected:\n    LocDualContext(const MsgTask* msgTask,\n                   LOC_API_ADAPTER_EVENT_MASK_T exMask);\n    inline virtual ~LocDualContext() {}\n\npublic:\n    static const char* mLBSLibName;\n    static const LOC_API_ADAPTER_EVENT_MASK_T mFgExclMask;\n    static const LOC_API_ADAPTER_EVENT_MASK_T mBgExclMask;\n    static const char* mLocationHalName;\n\n    static ContextBase* getLocFgContext(LocThread::tCreate tCreator, LocMsg* firstMsg,\n                                        const char* name, bool joinable = true);\n    inline static ContextBase* getLocFgContext(const char* name, bool joinable = true) {\n        return getLocFgContext(NULL, NULL, name, joinable);\n    }\n    static ContextBase* getLocBgContext(LocThread::tCreate tCreator, LocMsg* firstMsg,\n                                        const char* name, bool joinable = true);\n    inline static ContextBase* getLocBgContext(const char* name, bool joinable = true) {\n        return getLocBgContext(NULL, NULL, name, joinable);\n    }\n\n    static void injectFeatureConfig(ContextBase *context);\n};\n\n}\n\n#endif //__LOC_ENG_CONTEXT__\n"
  },
  {
    "path": "gps/core/UlpProxyBase.h",
    "content": "/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef ULP_PROXY_BASE_H\n#define ULP_PROXY_BASE_H\n\n#include <gps_extended.h>\n#include \"fused_location_extended.h\"\n\nnamespace loc_core {\n\nclass LocAdapterBase;\n\nclass UlpProxyBase {\npublic:\n    LocPosMode mPosMode;\n    bool mFixSet;\n    inline UlpProxyBase() {\n        mPosMode.mode = LOC_POSITION_MODE_INVALID;\n        mFixSet = false;\n    }\n    inline virtual ~UlpProxyBase() {}\n    inline virtual bool sendStartFix() { mFixSet = true; return false; }\n    inline virtual bool sendStopFix() { mFixSet = false; return false; }\n    inline virtual bool sendFixMode(LocPosMode &params) {\n        mPosMode = params;\n        return false;\n    }\n\n    inline virtual bool reportPosition(UlpLocation &location,\n                                       GpsLocationExtended &locationExtended,\n                                       void* locationExt,\n                                       enum loc_sess_status status,\n                                       LocPosTechMask loc_technology_mask) {\n        return false;\n    }\n    inline virtual bool reportSv(QcomSvStatus &svStatus,\n                                 GpsLocationExtended &locationExtended,\n                                 void* svExt) {\n        return false;\n    }\n    inline virtual bool reportStatus(GpsStatusValue status) {\n        return false;\n    }\n    inline virtual void setAdapter(LocAdapterBase* adapter) {}\n    inline virtual void setCapabilities(unsigned long capabilities) {}\n    inline virtual bool reportBatchingSession(FlpExtBatchOptions &options,\n                                              bool active) {\n        return false;\n    }\n    inline virtual bool reportPositions(const FlpExtLocation* locations,\n                                        int32_t number_of_locations) {\n        return false;\n    }\n};\n\n} // namespace loc_core\n\n#endif // ULP_PROXY_BASE_H\n"
  },
  {
    "path": "gps/core/fused_location_extended.h",
    "content": "/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef FUSED_LOCATION_EXTENDED_H\n#define FUSED_LOCATION_EXTENDED_H\n\n/** Batching default ID for dummy batching session*/\n#define GPS_BATCHING_DEFAULT_ID                 1\n\n/** This cap is used to decide the FLP session cache\nsize on AP. If the BATCH_SIZE in flp.conf is less than\nGPS_AP_BATCHING_SIZE_CAP, FLP session cache size will\nbe twice the BATCH_SIZE defined in flp.conf. Otherwise,\nFLP session cache size will be equal to the BATCH_SIZE.*/\n#define GPS_AP_BATCHING_SIZE_CAP               40\n\n#define GPS_BATCHING_OPERATION_SUCCEESS         1\n#define GPS_BATCHING_OPERATION_FAILURE          0\n\n/** GPS extended batching flags*/\n#define GPS_EXT_BATCHING_ON_FULL        0x0000001\n#define GPS_EXT_BATCHING_ON_FIX         0x000000\n\ntypedef struct {\n    double max_power_allocation_mW;\n    uint32_t sources_to_use;\n    uint32_t flags;\n    int64_t period_ns;\n} FlpExtBatchOptions;\n\n/** GpsLocationExtended has valid latitude and longitude. */\n#define GPS_LOCATION_EXTENDED_HAS_LAT_LONG   (1U<<0)\n/** GpsLocationExtended has valid altitude. */\n#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE   (1U<<1)\n/** GpsLocationExtended has valid speed. */\n#define GPS_LOCATION_EXTENDED_HAS_SPEED      (1U<<2)\n/** GpsLocationExtended has valid bearing. */\n#define GPS_LOCATION_EXTENDED_HAS_BEARING    (1U<<4)\n/** GpsLocationExtended has valid accuracy. */\n#define GPS_LOCATION_EXTENDED_HAS_ACCURACY   (1U<<8)\n\n/** GPS extended supports geofencing */\n#define GPS_EXTENDED_CAPABILITY_GEOFENCE     0x0000001\n/** GPS extended supports batching */\n#define GPS_EXTENDED_CAPABILITY_BATCHING     0x0000002\n\ntypedef struct FlpExtLocation_s {\n    size_t          size;\n    uint16_t        flags;\n    double          latitude;\n    double          longitude;\n    double          altitude;\n    float           speed;\n    float           bearing;\n    float           accuracy;\n    int64_t         timestamp;\n    uint32_t        sources_used;\n} FlpExtLocation;\n\n#endif /* FUSED_LOCATION_EXTENDED_H */\n"
  },
  {
    "path": "gps/core/gps_extended.h",
    "content": "/* Copyright (c) 2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef GPS_EXTENDED_H\n#define GPS_EXTENDED_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#include <gps_extended_c.h>\n\nstruct LocPosMode\n{\n    LocPositionMode mode;\n    GpsPositionRecurrence recurrence;\n    uint32_t min_interval;\n    uint32_t preferred_accuracy;\n    uint32_t preferred_time;\n    char credentials[14];\n    char provider[8];\n    LocPosMode(LocPositionMode m, GpsPositionRecurrence recr,\n               uint32_t gap, uint32_t accu, uint32_t time,\n               const char* cred, const char* prov) :\n        mode(m), recurrence(recr),\n        min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap),\n        preferred_accuracy(accu), preferred_time(time) {\n        memset(credentials, 0, sizeof(credentials));\n        memset(provider, 0, sizeof(provider));\n        if (NULL != cred) {\n            memcpy(credentials, cred, sizeof(credentials)-1);\n        }\n        if (NULL != prov) {\n            memcpy(provider, prov, sizeof(provider)-1);\n        }\n    }\n\n    inline LocPosMode() :\n        mode(LOC_POSITION_MODE_MS_BASED),\n        recurrence(GPS_POSITION_RECURRENCE_PERIODIC),\n        min_interval(MIN_POSSIBLE_FIX_INTERVAL),\n        preferred_accuracy(50), preferred_time(120000) {\n        memset(credentials, 0, sizeof(credentials));\n        memset(provider, 0, sizeof(provider));\n    }\n\n    inline bool equals(const LocPosMode &anotherMode) const\n    {\n        return anotherMode.mode == mode &&\n            anotherMode.recurrence == recurrence &&\n            anotherMode.min_interval == min_interval &&\n            anotherMode.preferred_accuracy == preferred_accuracy &&\n            anotherMode.preferred_time == preferred_time &&\n            !strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) &&\n            !strncmp(anotherMode.provider, provider, sizeof(provider)-1);\n    }\n\n    void logv() const;\n};\n\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* GPS_EXTENDED_H */\n\n"
  },
  {
    "path": "gps/core/gps_extended_c.h",
    "content": "/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef GPS_EXTENDED_C_H\n#define GPS_EXTENDED_C_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#include <ctype.h>\n#include <stdbool.h>\n#include <stdlib.h>\n#include <string.h>\n#include <hardware/gps.h>\n\n/** Location has valid source information. */\n#define LOCATION_HAS_SOURCE_INFO   0x0020\n/** GpsLocation has valid \"is indoor?\" flag */\n#define GPS_LOCATION_HAS_IS_INDOOR   0x0040\n/** GpsLocation has valid floor number */\n#define GPS_LOCATION_HAS_FLOOR_NUMBER   0x0080\n/** GpsLocation has valid map URL*/\n#define GPS_LOCATION_HAS_MAP_URL   0x0100\n/** GpsLocation has valid map index */\n#define GPS_LOCATION_HAS_MAP_INDEX   0x0200\n\n/** Sizes for indoor fields */\n#define GPS_LOCATION_MAP_URL_SIZE 400\n#define GPS_LOCATION_MAP_INDEX_SIZE 16\n\n/** Position source is ULP */\n#define ULP_LOCATION_IS_FROM_HYBRID   0x0001\n/** Position source is GNSS only */\n#define ULP_LOCATION_IS_FROM_GNSS     0x0002\n/** Position source is ZPP only */\n#define ULP_LOCATION_IS_FROM_ZPP      0x0004\n/** Position is from a Geofence Breach Event */\n#define ULP_LOCATION_IS_FROM_GEOFENCE 0X0008\n/** Position is from Hardware FLP */\n#define ULP_LOCATION_IS_FROM_HW_FLP   0x0010\n/** Position is from NLP */\n#define ULP_LOCATION_IS_FROM_NLP      0x0020\n/** Position is from PIP */\n#define ULP_LOCATION_IS_FROM_PIP      0x0040\n\n#define ULP_MIN_INTERVAL_INVALID 0xffffffff\n\n/*Emergency SUPL*/\n#define GPS_NI_TYPE_EMERGENCY_SUPL    4\n\n#define AGPS_CERTIFICATE_MAX_LENGTH 2000\n#define AGPS_CERTIFICATE_MAX_SLOTS 10\n\nenum loc_registration_mask_status {\n    LOC_REGISTRATION_MASK_ENABLED,\n    LOC_REGISTRATION_MASK_DISABLED\n};\n\ntypedef struct {\n    /** set to sizeof(UlpLocation) */\n    size_t          size;\n    GpsLocation     gpsLocation;\n    /* Provider indicator for HYBRID or GPS */\n    uint16_t        position_source;\n    /*allows HAL to pass additional information related to the location */\n    int             rawDataSize;         /* in # of bytes */\n    void            * rawData;\n    bool            is_indoor;\n    float           floor_number;\n    char            map_url[GPS_LOCATION_MAP_URL_SIZE];\n    unsigned char   map_index[GPS_LOCATION_MAP_INDEX_SIZE];\n} UlpLocation;\n\n/** AGPS type */\ntypedef int16_t AGpsExtType;\n#define AGPS_TYPE_INVALID       -1\n#define AGPS_TYPE_ANY           0\n#define AGPS_TYPE_SUPL          1\n#define AGPS_TYPE_C2K           2\n#define AGPS_TYPE_WWAN_ANY      3\n#define AGPS_TYPE_WIFI          4\n#define AGPS_TYPE_SUPL_ES       5\n\n/** SSID length */\n#define SSID_BUF_SIZE (32+1)\n\ntypedef int16_t AGpsBearerType;\n#define AGPS_APN_BEARER_INVALID    -1\n#define AGPS_APN_BEARER_IPV4        0\n#define AGPS_APN_BEARER_IPV6        1\n#define AGPS_APN_BEARER_IPV4V6      2\n\n/** GPS extended callback structure. */\ntypedef struct {\n    /** set to sizeof(GpsCallbacks) */\n    size_t      size;\n    gps_set_capabilities set_capabilities_cb;\n    gps_acquire_wakelock acquire_wakelock_cb;\n    gps_release_wakelock release_wakelock_cb;\n    gps_create_thread create_thread_cb;\n    gps_request_utc_time request_utc_time_cb;\n} GpsExtCallbacks;\n\n/** Callback to report the xtra server url to the client.\n *  The client should use this url when downloading xtra unless overwritten\n *  in the gps.conf file\n */\ntypedef void (* report_xtra_server)(const char*, const char*, const char*);\n\n/** Callback structure for the XTRA interface. */\ntypedef struct {\n    gps_xtra_download_request download_request_cb;\n    gps_create_thread create_thread_cb;\n    report_xtra_server report_xtra_server_cb;\n} GpsXtraExtCallbacks;\n\n/** Represents the status of AGPS. */\ntypedef struct {\n    /** set to sizeof(AGpsExtStatus) */\n    size_t          size;\n\n    AGpsExtType type;\n    AGpsStatusValue status;\n    uint32_t        ipv4_addr;\n    struct sockaddr_storage addr;\n    char            ssid[SSID_BUF_SIZE];\n    char            password[SSID_BUF_SIZE];\n} AGpsExtStatus;\n\n/** Callback with AGPS status information.\n *  Can only be called from a thread created by create_thread_cb.\n */\ntypedef void (* agps_status_extended)(AGpsExtStatus* status);\n\n/** Callback structure for the AGPS interface. */\ntypedef struct {\n    agps_status_extended status_cb;\n    gps_create_thread create_thread_cb;\n} AGpsExtCallbacks;\n\n\n/** GPS NI callback structure. */\ntypedef struct\n{\n    /**\n     * Sends the notification request from HAL to GPSLocationProvider.\n     */\n    gps_ni_notify_callback notify_cb;\n    gps_create_thread create_thread_cb;\n} GpsNiExtCallbacks;\n\ntypedef enum loc_server_type {\n    LOC_AGPS_CDMA_PDE_SERVER,\n    LOC_AGPS_CUSTOM_PDE_SERVER,\n    LOC_AGPS_MPC_SERVER,\n    LOC_AGPS_SUPL_SERVER\n} LocServerType;\n\ntypedef enum loc_position_mode_type {\n    LOC_POSITION_MODE_INVALID = -1,\n    LOC_POSITION_MODE_STANDALONE = 0,\n    LOC_POSITION_MODE_MS_BASED,\n    LOC_POSITION_MODE_MS_ASSISTED,\n    LOC_POSITION_MODE_RESERVED_1,\n    LOC_POSITION_MODE_RESERVED_2,\n    LOC_POSITION_MODE_RESERVED_3,\n    LOC_POSITION_MODE_RESERVED_4,\n    LOC_POSITION_MODE_RESERVED_5\n\n} LocPositionMode;\n\n#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */\n\n/** Flags to indicate which values are valid in a GpsLocationExtended. */\ntypedef uint16_t GpsLocationExtendedFlags;\n/** GpsLocationExtended has valid pdop, hdop, vdop. */\n#define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001\n/** GpsLocationExtended has valid altitude mean sea level. */\n#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002\n/** UlpLocation has valid magnetic deviation. */\n#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004\n/** UlpLocation has valid mode indicator. */\n#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008\n/** GpsLocationExtended has valid vertical uncertainty */\n#define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010\n/** GpsLocationExtended has valid speed uncertainty */\n#define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020\n/** GpsLocationExtended has valid heading uncertainty */\n#define GPS_LOCATION_EXTENDED_HAS_BEARING_UNC 0x0040\n/** GpsLocationExtended has valid horizontal reliability */\n#define GPS_LOCATION_EXTENDED_HAS_HOR_RELIABILITY 0x0080\n/** GpsLocationExtended has valid vertical reliability */\n#define GPS_LOCATION_EXTENDED_HAS_VERT_RELIABILITY 0x0100\n\ntypedef enum {\n    LOC_RELIABILITY_NOT_SET = 0,\n    LOC_RELIABILITY_VERY_LOW = 1,\n    LOC_RELIABILITY_LOW = 2,\n    LOC_RELIABILITY_MEDIUM = 3,\n    LOC_RELIABILITY_HIGH = 4\n}LocReliability;\n\n/** Represents gps location extended. */\ntypedef struct {\n    /** set to sizeof(GpsLocationExtended) */\n    size_t          size;\n    /** Contains GpsLocationExtendedFlags bits. */\n    uint16_t        flags;\n    /** Contains the Altitude wrt mean sea level */\n    float           altitudeMeanSeaLevel;\n    /** Contains Position Dilusion of Precision. */\n    float           pdop;\n    /** Contains Horizontal Dilusion of Precision. */\n    float           hdop;\n    /** Contains Vertical Dilusion of Precision. */\n    float           vdop;\n    /** Contains Magnetic Deviation. */\n    float           magneticDeviation;\n    /** vertical uncertainty in meters */\n    float           vert_unc;\n    /** speed uncertainty in m/s */\n    float           speed_unc;\n    /** heading uncertainty in degrees (0 to 359.999) */\n    float           bearing_unc;\n    /** horizontal reliability. */\n    LocReliability  horizontal_reliability;\n    /** vertical reliability. */\n    LocReliability  vertical_reliability;\n} GpsLocationExtended;\n\n/** Represents SV status. */\ntypedef struct {\n    /** set to sizeof(QcomSvStatus) */\n    size_t          size;\n\n    /** Number of SVs currently visible. */\n    int         num_svs;\n\n    /** Contains an array of SV information. */\n    GpsSvInfo   sv_list[GPS_MAX_SVS];\n\n    /** Represents a bit mask indicating which SVs\n     * have ephemeris data.\n     */\n    uint32_t    ephemeris_mask;\n\n    /** Represents a bit mask indicating which SVs\n     * have almanac data.\n     */\n    uint32_t    almanac_mask;\n\n    /**\n     * Represents a bit mask indicating which GPS SVs\n     * were used for computing the most recent position fix.\n     */\n    uint32_t    gps_used_in_fix_mask;\n\n    /**\n     * Represents a bit mask indicating which GLONASS SVs\n     * were used for computing the most recent position fix.\n     */\n    uint32_t    glo_used_in_fix_mask;\n\n    /**\n     * Represents a bit mask indicating which BDS SVs\n     * were used for computing the most recent position fix.\n     */\n    uint64_t    bds_used_in_fix_mask;\n\n} QcomSvStatus;\n\nenum loc_sess_status {\n    LOC_SESS_SUCCESS,\n    LOC_SESS_INTERMEDIATE,\n    LOC_SESS_FAILURE\n};\n\ntypedef uint32_t LocPosTechMask;\n#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000)\n#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001)\n#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002)\n#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004)\n#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008)\n#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010)\n#define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020)\n#define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040)\n#define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080)\n\ntypedef enum {\n  LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,\n  LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,\n  LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,\n  LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,\n  LOC_ENG_IF_REQUEST_SENDER_ID_MODEM,\n  LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN\n} loc_if_req_sender_id_e_type;\n\n\n#define smaller_of(a, b) (((a) > (b)) ? (b) : (a))\n#define MAX_APN_LEN 100\n\n// This will be overridden by the individual adapters\n// if necessary.\n#define DEFAULT_IMPL(rtv)                                     \\\n{                                                             \\\n    LOC_LOGD(\"%s: default implementation invoked\", __func__); \\\n    return rtv;                                               \\\n}\n\nenum loc_api_adapter_err {\n    LOC_API_ADAPTER_ERR_SUCCESS             = 0,\n    LOC_API_ADAPTER_ERR_GENERAL_FAILURE     = 1,\n    LOC_API_ADAPTER_ERR_UNSUPPORTED         = 2,\n    LOC_API_ADAPTER_ERR_INVALID_HANDLE      = 4,\n    LOC_API_ADAPTER_ERR_INVALID_PARAMETER   = 5,\n    LOC_API_ADAPTER_ERR_ENGINE_BUSY         = 6,\n    LOC_API_ADAPTER_ERR_PHONE_OFFLINE       = 7,\n    LOC_API_ADAPTER_ERR_TIMEOUT             = 8,\n    LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9,\n    LOC_API_ADAPTER_ERR_INTERNAL            = 10,\n\n    /* equating engine down to phone offline, as they are the same errror */\n    LOC_API_ADAPTER_ERR_ENGINE_DOWN         = LOC_API_ADAPTER_ERR_PHONE_OFFLINE,\n    LOC_API_ADAPTER_ERR_FAILURE             = 101,\n    LOC_API_ADAPTER_ERR_UNKNOWN\n};\n\nenum loc_api_adapter_event_index {\n    LOC_API_ADAPTER_REPORT_POSITION = 0,               // Position report comes in loc_parsed_position_s_type\n    LOC_API_ADAPTER_REPORT_SATELLITE,                  // Satellite in view report\n    LOC_API_ADAPTER_REPORT_NMEA_1HZ,                   // NMEA report at 1HZ rate\n    LOC_API_ADAPTER_REPORT_NMEA_POSITION,              // NMEA report at position report rate\n    LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY,          // NI notification/verification request\n    LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA,           // Assistance data, eg: time, predicted orbits request\n    LOC_API_ADAPTER_REQUEST_LOCATION_SERVER,           // Request for location server\n    LOC_API_ADAPTER_REPORT_IOCTL,                      // Callback report for loc_ioctl\n    LOC_API_ADAPTER_REPORT_STATUS,                     // Misc status report: eg, engine state\n    LOC_API_ADAPTER_REQUEST_WIFI,                      //\n    LOC_API_ADAPTER_SENSOR_STATUS,                     //\n    LOC_API_ADAPTER_REQUEST_TIME_SYNC,                 //\n    LOC_API_ADAPTER_REPORT_SPI,                        //\n    LOC_API_ADAPTER_REPORT_NI_GEOFENCE,                //\n    LOC_API_ADAPTER_GEOFENCE_GEN_ALERT,                //\n    LOC_API_ADAPTER_REPORT_GENFENCE_BREACH,            //\n    LOC_API_ADAPTER_PEDOMETER_CTRL,                    //\n    LOC_API_ADAPTER_MOTION_CTRL,                       //\n    LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA,              // Wifi ap data\n    LOC_API_ADAPTER_BATCH_FULL,                        // Batching on full\n    LOC_API_ADAPTER_BATCHED_POSITION_REPORT,           // Batching on fix\n    LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT,    //\n    LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ,              // GDT upload start request\n    LOC_API_ADAPTER_GDT_UPLOAD_END_REQ,                // GDT upload end request\n    LOC_API_ADAPTER_GNSS_MEASUREMENT,                  // GNSS Measurement report\n    LOC_API_ADAPTER_REQUEST_TIMEZONE,                  // Timezone injection request\n    LOC_API_ADAPTER_EVENT_MAX\n};\n\n#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT           (1<<LOC_API_ADAPTER_REPORT_POSITION)\n#define LOC_API_ADAPTER_BIT_SATELLITE_REPORT                 (1<<LOC_API_ADAPTER_REPORT_SATELLITE)\n#define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT                  (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)\n#define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT             (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)\n#define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST         (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)\n#define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST          (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)\n#define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST          (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)\n#define LOC_API_ADAPTER_BIT_IOCTL_REPORT                     (1<<LOC_API_ADAPTER_REPORT_IOCTL)\n#define LOC_API_ADAPTER_BIT_STATUS_REPORT                    (1<<LOC_API_ADAPTER_REPORT_STATUS)\n#define LOC_API_ADAPTER_BIT_REQUEST_WIFI                     (1<<LOC_API_ADAPTER_REQUEST_WIFI)\n#define LOC_API_ADAPTER_BIT_SENSOR_STATUS                    (1<<LOC_API_ADAPTER_SENSOR_STATUS)\n#define LOC_API_ADAPTER_BIT_REQUEST_TIME_SYNC                (1<<LOC_API_ADAPTER_REQUEST_TIME_SYNC)\n#define LOC_API_ADAPTER_BIT_REPORT_SPI                       (1<<LOC_API_ADAPTER_REPORT_SPI)\n#define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE               (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)\n#define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT               (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)\n#define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH           (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)\n#define LOC_API_ADAPTER_BIT_BATCHED_GENFENCE_BREACH_REPORT   (1<<LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT)\n#define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL                   (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)\n#define LOC_API_ADAPTER_BIT_MOTION_CTRL                      (1<<LOC_API_ADAPTER_MOTION_CTRL)\n#define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA             (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)\n#define LOC_API_ADAPTER_BIT_BATCH_FULL                       (1<<LOC_API_ADAPTER_BATCH_FULL)\n#define LOC_API_ADAPTER_BIT_BATCHED_POSITION_REPORT          (1<<LOC_API_ADAPTER_BATCHED_POSITION_REPORT)\n#define LOC_API_ADAPTER_BIT_GDT_UPLOAD_BEGIN_REQ             (1<<LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ)\n#define LOC_API_ADAPTER_BIT_GDT_UPLOAD_END_REQ               (1<<LOC_API_ADAPTER_GDT_UPLOAD_END_REQ)\n#define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT                 (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT)\n#define LOC_API_ADAPTER_BIT_REQUEST_TIMEZONE                 (1<<LOC_API_ADAPTER_REQUEST_TIMEZONE)\n\ntypedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;\n\ntypedef enum loc_api_adapter_msg_to_check_supported {\n    LOC_API_ADAPTER_MESSAGE_LOCATION_BATCHING,               // Batching 1.0\n    LOC_API_ADAPTER_MESSAGE_BATCHED_GENFENCE_BREACH,         // Geofence Batched Breach\n    LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING,          // DBT 2.0\n    LOC_API_ADAPTER_MESSAGE_ADAPTIVE_LOCATION_BATCHING,      // Batching 1.5\n    LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING, // Batching 2.0\n\n    LOC_API_ADAPTER_MESSAGE_MAX\n} LocCheckingMessagesID;\n\ntypedef int IzatDevId_t;\n\ntypedef uint32_t LOC_GPS_LOCK_MASK;\n#define isGpsLockNone(lock) ((lock) == 0)\n#define isGpsLockMO(lock) ((lock) & ((LOC_GPS_LOCK_MASK)1))\n#define isGpsLockMT(lock) ((lock) & ((LOC_GPS_LOCK_MASK)2))\n#define isGpsLockAll(lock) (((lock) & ((LOC_GPS_LOCK_MASK)3)) == 3)\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* GPS_EXTENDED_C_H */\n"
  },
  {
    "path": "gps/core/loc_core_log.cpp",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_core_log\"\n\n#include <loc_log.h>\n#include <log_util.h>\n#include <loc_core_log.h>\n\nvoid LocPosMode::logv() const\n{\n    LOC_LOGV (\"Position mode: %s\\n  Position recurrence: %s\\n  \"\n              \"min interval: %d\\n  preferred accuracy: %d\\n  \"\n              \"preferred time: %d\\n  credentials: %s  provider: %s\",\n              loc_get_position_mode_name(mode),\n              loc_get_position_recurrence_name(recurrence),\n              min_interval,\n              preferred_accuracy,\n              preferred_time,\n              credentials,\n              provider);\n}\n\n/* GPS status names */\nstatic loc_name_val_s_type gps_status_name[] =\n{\n    NAME_VAL( GPS_STATUS_NONE ),\n    NAME_VAL( GPS_STATUS_SESSION_BEGIN ),\n    NAME_VAL( GPS_STATUS_SESSION_END ),\n    NAME_VAL( GPS_STATUS_ENGINE_ON ),\n    NAME_VAL( GPS_STATUS_ENGINE_OFF ),\n};\nstatic int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type);\n\n/* Find Android GPS status name */\nconst char* loc_get_gps_status_name(GpsStatusValue gps_status)\n{\n   return loc_get_name_from_val(gps_status_name, gps_status_num,\n         (long) gps_status);\n}\n\n\n\nstatic loc_name_val_s_type loc_eng_position_modes[] =\n{\n    NAME_VAL( LOC_POSITION_MODE_STANDALONE ),\n    NAME_VAL( LOC_POSITION_MODE_MS_BASED ),\n    NAME_VAL( LOC_POSITION_MODE_MS_ASSISTED ),\n    NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ),\n    NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ),\n    NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ),\n    NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ),\n    NAME_VAL( LOC_POSITION_MODE_RESERVED_5 )\n};\nstatic int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_position_mode_name(GpsPositionMode mode)\n{\n    return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);\n}\n\n\n\nstatic loc_name_val_s_type loc_eng_position_recurrences[] =\n{\n    NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ),\n    NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE )\n};\nstatic int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_position_recurrence_name(GpsPositionRecurrence recur)\n{\n    return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);\n}\n\n\n\nstatic loc_name_val_s_type loc_eng_aiding_data_bits[] =\n{\n    NAME_VAL( GPS_DELETE_EPHEMERIS ),\n    NAME_VAL( GPS_DELETE_ALMANAC ),\n    NAME_VAL( GPS_DELETE_POSITION ),\n    NAME_VAL( GPS_DELETE_TIME ),\n    NAME_VAL( GPS_DELETE_IONO ),\n    NAME_VAL( GPS_DELETE_UTC ),\n    NAME_VAL( GPS_DELETE_HEALTH ),\n    NAME_VAL( GPS_DELETE_SVDIR ),\n    NAME_VAL( GPS_DELETE_SVSTEER ),\n    NAME_VAL( GPS_DELETE_SADATA ),\n    NAME_VAL( GPS_DELETE_RTI ),\n    NAME_VAL( GPS_DELETE_CELLDB_INFO ),\n    NAME_VAL( GPS_DELETE_ALL)\n};\nstatic int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_aiding_data_mask_names(GpsAidingData data)\n{\n    return NULL;\n}\n\n\nstatic loc_name_val_s_type loc_eng_agps_types[] =\n{\n    NAME_VAL( AGPS_TYPE_INVALID ),\n    NAME_VAL( AGPS_TYPE_ANY ),\n    NAME_VAL( AGPS_TYPE_SUPL ),\n    NAME_VAL( AGPS_TYPE_C2K ),\n    NAME_VAL( AGPS_TYPE_WWAN_ANY )\n};\nstatic int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_agps_type_name(AGpsType type)\n{\n    return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);\n}\n\n\nstatic loc_name_val_s_type loc_eng_ni_types[] =\n{\n    NAME_VAL( GPS_NI_TYPE_VOICE ),\n    NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),\n    NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ),\n    NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL )\n};\nstatic int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_ni_type_name(GpsNiType type)\n{\n    return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);\n}\n\n\nstatic loc_name_val_s_type loc_eng_ni_responses[] =\n{\n    NAME_VAL( GPS_NI_RESPONSE_ACCEPT ),\n    NAME_VAL( GPS_NI_RESPONSE_DENY ),\n    NAME_VAL( GPS_NI_RESPONSE_DENY )\n};\nstatic int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_ni_response_name(GpsUserResponseType response)\n{\n    return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);\n}\n\n\nstatic loc_name_val_s_type loc_eng_ni_encodings[] =\n{\n    NAME_VAL( GPS_ENC_NONE ),\n    NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ),\n    NAME_VAL( GPS_ENC_SUPL_UTF8 ),\n    NAME_VAL( GPS_ENC_SUPL_UCS2 ),\n    NAME_VAL( GPS_ENC_UNKNOWN )\n};\nstatic int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_ni_encoding_name(GpsNiEncodingType encoding)\n{\n    return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);\n}\n\nstatic loc_name_val_s_type loc_eng_agps_bears[] =\n{\n    NAME_VAL( AGPS_APN_BEARER_INVALID ),\n    NAME_VAL( AGPS_APN_BEARER_IPV4 ),\n    NAME_VAL( AGPS_APN_BEARER_IPV6 ),\n    NAME_VAL( AGPS_APN_BEARER_IPV4V6 )\n};\nstatic int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_agps_bear_name(AGpsBearerType bearer)\n{\n    return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer);\n}\n\nstatic loc_name_val_s_type loc_eng_server_types[] =\n{\n    NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ),\n    NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ),\n    NAME_VAL( LOC_AGPS_MPC_SERVER ),\n    NAME_VAL( LOC_AGPS_SUPL_SERVER )\n};\nstatic int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_server_type_name(LocServerType type)\n{\n    return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type);\n}\n\nstatic loc_name_val_s_type loc_eng_position_sess_status_types[] =\n{\n    NAME_VAL( LOC_SESS_SUCCESS ),\n    NAME_VAL( LOC_SESS_INTERMEDIATE ),\n    NAME_VAL( LOC_SESS_FAILURE )\n};\nstatic int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_position_sess_status_name(enum loc_sess_status status)\n{\n    return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status);\n}\n\nstatic loc_name_val_s_type loc_eng_agps_status_names[] =\n{\n    NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ),\n    NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ),\n    NAME_VAL( GPS_AGPS_DATA_CONNECTED ),\n    NAME_VAL( GPS_AGPS_DATA_CONN_DONE ),\n    NAME_VAL( GPS_AGPS_DATA_CONN_FAILED )\n};\nstatic int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_agps_status_name(AGpsStatusValue status)\n{\n    return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);\n}\n"
  },
  {
    "path": "gps/core/loc_core_log.h",
    "content": "/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_CORE_LOG_H\n#define LOC_CORE_LOG_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#include <ctype.h>\n#include <gps_extended.h>\n\nconst char* loc_get_gps_status_name(GpsStatusValue gps_status);\nconst char* loc_get_position_mode_name(GpsPositionMode mode);\nconst char* loc_get_position_recurrence_name(GpsPositionRecurrence recur);\nconst char* loc_get_aiding_data_mask_names(GpsAidingData data);\nconst char* loc_get_agps_type_name(AGpsType type);\nconst char* loc_get_ni_type_name(GpsNiType type);\nconst char* loc_get_ni_response_name(GpsUserResponseType response);\nconst char* loc_get_ni_encoding_name(GpsNiEncodingType encoding);\nconst char* loc_get_agps_bear_name(AGpsBearerType bear);\nconst char* loc_get_server_type_name(LocServerType type);\nconst char* loc_get_position_sess_status_name(enum loc_sess_status status);\nconst char* loc_get_agps_status_name(AGpsStatusValue status);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_CORE_LOG_H */\n"
  },
  {
    "path": "gps/etc/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := flp.conf\nLOCAL_MODULE_TAGS := optional\nLOCAL_MODULE_CLASS := ETC\nLOCAL_MODULE_PATH  := $(TARGET_OUT_ETC)/\nLOCAL_SRC_FILES := flp.conf\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := gps.conf\nLOCAL_MODULE_TAGS := optional\nLOCAL_MODULE_CLASS := ETC\nLOCAL_MODULE_PATH  := $(TARGET_OUT_ETC)/\nLOCAL_SRC_FILES := gps.conf\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := izat.conf\nLOCAL_MODULE_TAGS := optional\nLOCAL_MODULE_CLASS := ETC\nLOCAL_MODULE_PATH  := $(TARGET_OUT_ETC)/\nLOCAL_SRC_FILES := izat.conf\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := lowi.conf\nLOCAL_MODULE_TAGS := optional\nLOCAL_MODULE_CLASS := ETC\nLOCAL_MODULE_PATH  := $(TARGET_OUT_ETC)/\nLOCAL_SRC_FILES := lowi.conf\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := sap.conf\nLOCAL_MODULE_TAGS := optional\nLOCAL_MODULE_CLASS := ETC\nLOCAL_MODULE_PATH  := $(TARGET_OUT_ETC)/\nLOCAL_SRC_FILES := sap.conf\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := xtwifi.conf\nLOCAL_MODULE_TAGS := optional\nLOCAL_MODULE_CLASS := ETC\nLOCAL_MODULE_PATH  := $(TARGET_OUT_ETC)/\nLOCAL_SRC_FILES := xtwifi.conf\ninclude $(BUILD_PREBUILT)\n"
  },
  {
    "path": "gps/etc/flp.conf",
    "content": "###################################\n#####       FLP settings      #####\n###################################\n\n###################################\n# FLP BATCHING SIZE\n###################################\n# The number of batched locations\n# requested to modem. The desired number\n# defined below may not be satisfied, as\n# the modem can only return the number\n# of batched locations that can be allocated,\n# which is limited by memory. The default\n# batch size defined as 20 as below.\nBATCH_SIZE=20\n\n###################################\n# FLP BATCHING SESSION TIMEOUT\n###################################\n# Duration with which batch session timeout\n# happens in milliseconds. If not specified\n# or set to zero, batching session timeout\n# defaults to 20 seconds by the modem.\n# BATCH_SESSION_TIMEOUT=20000\n\n###################################\n# FLP CAPABILITIES BIT MASK\n###################################\n# GEOFENCE = 0x01\n# BATCHING = 0x02\n# default = GEOFENCE | BATCHING\nCAPABILITIES=0x03\n\n###################################\n# FLP BATCHING ACCURACY\n###################################\n# Set to one of the defined values below\n# to define the accuracy of batching.\n# If not specified, accuracy defaults\n# to LOW.\n# FLP BATCHING ACCURACY values:\n# Low accuracy = 0\n# Medium accuracy = 1\n# High accuracy = 2\nACCURACY=0\n\n###################################\n# FLP GEOFENCE RESPONSIVENESS\n###################################\n# If set to one of the defined values below,\n# it will override the responsiveness for\n# FLP geofence, which implements the fused\n# location API. If not set to a value defined\n# below, which is default, it will not\n# override the responsivness.\n# FLP_GEOFENCE_RESPONSIVENESS_OVERRIDE Values:\n# 1: LOW responsiveness\n# 2: MEDIUM responsiveness\n# 3: HIGH responsiveness\nFLP_GEOFENCE_RESPONSIVENESS_OVERRIDE = 0\n"
  },
  {
    "path": "gps/etc/gps.conf",
    "content": "#Uncommenting these urls would only enable\n#the power up auto injection and force injection(test case).\n#XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra2.bin\n#XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra2.bin\n#XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra2.bin\n\n#ifdef VENDOR_EDIT\n# zuoyonghua@oneplus.cn add gps xtra server for speed up gps cold start\nXTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin\nXTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin\nXTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin\n#endif\n\n#Version check for XTRA\n#DISABLE = 0\n#AUTO    = 1\n#XTRA2   = 2\n#XTRA3   = 3\nXTRA_VERSION_CHECK=0\n\n# Error Estimate\n# _SET = 1\n# _CLEAR = 0\nERR_ESTIMATE=0\n\n#Test\nNTP_SERVER=time.gpsonextra.net\n#Asia\n# NTP_SERVER=asia.pool.ntp.org\n#Europe\n# NTP_SERVER=europe.pool.ntp.org\n#North America\n# NTP_SERVER=north-america.pool.ntp.org\n\n# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info\n#               4 - Debug, 5 - Verbose\n# If DEBUG_LEVEL is commented, Android's logging levels will be used\nDEBUG_LEVEL = 2\n\n# Intermediate position report, 1=enable, 0=disable\nINTERMEDIATE_POS=0\n\n# Below bit mask configures how GPS functionalities\n# should be locked when user turns off GPS on Settings\n# Set bit 0x1 if MO GPS functionalities are to be locked\n# Set bit 0x2 if NI GPS functionalities are to be locked\n# default - non is locked for backward compatibility\n#GPS_LOCK = 0\n\n# supl version 1.0\nSUPL_VER=0x10000\n\n# Emergency SUPL, 1=enable, 0=disable\nSUPL_ES=0\n\n#Choose PDN for Emergency SUPL\n#1 - Use emergency PDN\n#0 - Use regular SUPL PDN for Emergency SUPL\nUSE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=1\n\n#SUPL_MODE is a bit mask set in config.xml per carrier by default.\n#If it is uncommented here, this value will over write the value from\n#config.xml.\n#MSA=0X2\n#MSB=0X1\n#SUPL_MODE=\n\n# GPS Capabilities bit mask\n# SCHEDULING = 0x01\n# MSB = 0x02\n# MSA = 0x04\n# ON_DEMAND_TIME = 0x10\n# GEOFENCE = 0x20\n# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE\nCAPABILITIES=0x31\n\n# Accuracy threshold for intermediate positions\n# less accurate positions are ignored, 0 for passing all positions\n# ACCURACY_THRES=5000\n\n################################\n##### AGPS server settings #####\n################################\n\n# FOR SUPL SUPPORT, set the following\n# SUPL_HOST=supl.host.com or IP\n# SUPL_PORT=1234\n\n# FOR C2K PDE SUPPORT, set the following\n# C2K_HOST=c2k.pde.com or IP\n# C2K_PORT=1234\n\n# Bitmask of slots that are available\n# for write/install to, where 1s indicate writable,\n# and the default value is 0 where no slots\n# are writable. For example, AGPS_CERT_WRITABLE_MASK\n# of b1000001010 makes 3 slots available\n# and the remaining 7 slots unwritable.\n#AGPS_CERT_WRITABLE_MASK=0\n\n####################################\n#  LTE Positioning Profile Settings\n####################################\n# 0: Enable RRLP on LTE(Default)\n# 1: Enable LPP_User_Plane on LTE\n# 2: Enable LPP_Control_Plane\n# 3: Enable both LPP_User_Plane and LPP_Control_Plane\nLPP_PROFILE = 0\n\n################################\n# EXTRA SETTINGS\n################################\n# NMEA provider (1=Modem Processor, 0=Application Processor)\nNMEA_PROVIDER=0\n# Mark if it is a SGLTE target (1=SGLTE, 0=nonSGLTE)\nSGLTE_TARGET=0\n\n##################################################\n# Select Positioning Protocol on A-GLONASS system\n##################################################\n# 0x1: RRC CPlane\n# 0x2: RRLP UPlane\n# 0x4: LLP Uplane\n#ifndef zuoyonghua@oneplus.cn enable all bit mask for GLONASS\n#A_GLONASS_POS_PROTOCOL_SELECT = 0\n#else\nA_GLONASS_POS_PROTOCOL_SELECT = 15\n#endif\n"
  },
  {
    "path": "gps/etc/izat.conf",
    "content": "#########################################\n# Log verbosity control for izat modules\n#########################################\n# OFF = 0, ERROR = 1, WARNING = 2, INFO = 3, DEBUG = 4, VERBOSE = 5\nIZAT_DEBUG_LEVEL = 2\n\n##################################################\n# Select WIFI Wait Timeout value in seconds for SUPL\n##################################################\nWIFI_WAIT_TIMEOUT_SELECT = 0\n\n################################\n# NLP Settings\n################################\n# NLP_MODE  1: GNP Only, 2: QNP Only, 3: Combo\n# NLP_TOLERANCE_TIME_FIRST: Time in ms used in Combo mode\n# to determine how much Tolerance for first position\n# NLP_TOLERANCE_TIME_AFTER: Time in ms used in Combo mode\n# to determine how much Tolerance for positions after first\n# NLP_THRESHOLD: Sets how many failures needed before\n# switching preferred NLP in Combo mode\n# NLP_ACCURACY_MULTIPLE: Determines how far off the accuracy\n# must be, in multiples, between two NLP location reports to\n# be considered much worse accuracy. Used in switching logic\n# NLP COMBO MODE USES QNP WITH NO EULA CONSENT: Determines\n# whether or not to still send network location requests to\n# QNP when the EULA is not consented to by the user. QNP can\n# still return ZPP locations or injected locations even\n# without EULA consent, but the uncertainty can be high.\nNLP_MODE = 3\nNLP_TOLERANCE_TIME_FIRST = 5000\nNLP_TOLERANCE_TIME_AFTER = 20000\nNLP_THRESHOLD = 3\nNLP_ACCURACY_MULTIPLE = 2\nNLP_COMBO_MODE_USES_QNP_WITH_NO_EULA_CONSENT = 1\n\n# Threshold period for ZPP triggers\nZPP_TRIGGER_THRESHOLD=60000\n\n###################################\n# GEOFENCE SERVICES\n###################################\n# If set to one of the defined values below, it will override\n# the responsiveness for geofence services, which implements\n# the Proximity Alert API. If not set to a value defined below,\n# which is default, it will not override the responsivness.\n# The geofence HAL API is unaffected by this value.\n# GEOFENCE_SERVICES_RESPONSIVENESS_OVERRIDE Values:\n# 1: LOW responsiveness\n# 2: MEDIUM responsiveness\n# 3: HIGH responsiveness\nGEOFENCE_SERVICES_RESPONSIVENESS_OVERRIDE = 0\n\n#####################################\n# IZAT PREMIUM FEATURE SETTINGS\n#####################################\n#Possible states of a feature:\n#DISABLED\n#BASIC\n#PREMIUM\n\n#GTP_CELL_PROC valid options:\n# AP\n# MODEM\nGTP_CELL_PROC=MODEM\n\n#GTP_CELL valid modes:\n# DISABLED\n# BASIC\nGTP_CELL=DISABLED\n\n#GTP_WIFI valid modes:\n# DISABLED\n# BASIC\nGTP_WIFI=DISABLED\n\n#GTP_WAA valid modes:\n# DISABLED\n# BASIC\nGTP_WAA=DISABLED\n\n#SAP valid modes:\n# DISABLED\n# BASIC\n# PREMIUM\nSAP=DISABLED\n\n#ODCPI valid modes:\n#DISABLED\n#BASIC\nODCPI=DISABLED\n\n#FREE_WIFI_SCAN_INJECT valid modes:\n#DISABLED\n#BASIC\nFREE_WIFI_SCAN_INJECT=DISABLED\n\n#SUPL_WIFI valid modes:\n#DISABLED\n#BASIC\nSUPL_WIFI=DISABLED\n\n#WIFI_SUPPLICANT_INFO valid modes:\n#DISABLED\n#BASIC\nWIFI_SUPPLICANT_INFO=DISABLED\n\n#####################################\n# Location process launcher settings\n#####################################\n\n#Values for PROCESS_STATE:\n# ENABLED\n# DISABLED\n\n#FEATURE MASKS:\n# GTP-WIFI    0X03\n# GTP-AP-CELL 0X0c\n# GTP-MP-CELL 0xc00\n# GTP-WAA     0X300\n# SAP         0Xc0\n# ODCPI      0x1000\n# FREE_WIFI_SCAN_INJECT   0x2000\n# SUPL_WIFI   0x4000\n# WIFI_SUPPLICANT_INFO   0x8000\n\n#Values for PLATFORMS can be:\n#1. Any valid values obtained from ro.board.platform separated by single space. For example: msm8960 msm8226\n#2. all -> for All platforms\n\n#Values for BASEBAND can be:\n#1. Any valid values obtained from ro.baseband separated by single space. For example: sglte sglte2\n#2. all -> for all basebands\n\n#Valyes for LEAN_TARGETS can be:\n#ENABLED  -> if this process is supposed to run on lean and mean targets\n#DISABLED -> if this process is to be disabled on lean and mean targets\nPROCESS_NAME=/system/bin/garden_app\nPROCESS_ARGUMENT=-u 0 -q 0 -j 0 -g 0 -l 0 -Z 0 -T 1\nPROCESS_STATE=DISABLED\nPROCESS_GROUPS=gps net_raw\nPREMIUM_FEATURE=0\nIZAT_FEATURE_MASK=0\nPLATFORMS=all\nBASEBAND=auto\nLEAN_TARGETS=DISABLED\n\nPROCESS_NAME=/system/bin/gpsone_daemon\nPROCESS_ARGUMENT=\nPROCESS_STATE=DISABLED\nPROCESS_GROUPS=inet net_raw\nPREMIUM_FEATURE=0\nIZAT_FEATURE_MASK=0\nPLATFORMS=msm7630_fusion\nBASEBAND=svlte2a sglte sglte2\nLEAN_TARGETS=DISABLED\n\nPROCESS_NAME=/system/bin/lowi-server\nPROCESS_ARGUMENT=\nPROCESS_STATE=DISABLED\nPROCESS_GROUPS=gps net_admin wifi inet qcom_diag net_raw\nPREMIUM_FEATURE=0\nIZAT_FEATURE_MASK=0xf303\nPLATFORMS=all\nBASEBAND=all\nLEAN_TARGETS=DISABLED\n\nPROCESS_NAME=/system/bin/xtwifi-inet-agent\nPROCESS_ARGUMENT=\nPROCESS_STATE=DISABLED\nPROCESS_GROUPS=inet gps\nPREMIUM_FEATURE=1\nIZAT_FEATURE_MASK=0xc0f\nPLATFORMS=all\nBASEBAND=all\nLEAN_TARGETS=DISABLED\n\nPROCESS_NAME=/system/bin/xtwifi-client\nPROCESS_ARGUMENT=\nPROCESS_STATE=DISABLED\nPROCESS_GROUPS=net_admin wifi inet gps net_raw rfs_shared\nPREMIUM_FEATURE=1\nIZAT_FEATURE_MASK=0xf0f\nPLATFORMS=all\nBASEBAND=all\nLEAN_TARGETS=DISABLED\n\nPROCESS_NAME=/system/vendor/bin/slim_daemon\nPROCESS_ARGUMENT=\nPROCESS_STATE=DISABLED\nPROCESS_GROUPS=gps net_raw qcom_diag\nPREMIUM_FEATURE=1\nIZAT_FEATURE_MASK=0xf0\nPLATFORMS=all\nBASEBAND=all\nLEAN_TARGETS=DISABLED\n"
  },
  {
    "path": "gps/etc/lowi.conf",
    "content": "#*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*\n#\n# LOWI Config file\n#\n# GENERAL DESCRIPTION\n#  This file contains the config params for LOWI\n#\n# Copyright (c) 2012-2013 Qualcomm Atheros, Inc.\n#  All Rights Reserved.\n#  Qualcomm Atheros Confidential and Proprietary.\n#\n# Export of this technology or software is regulated by the U.S. Government.\n# Diversion contrary to U.S. law prohibited.\n#=============================================================================*/\n\n# X86 ONLY - UBUNTU:\n# Copy this file in the same directory where the executable is\n\n# The RSSI threshold used in the RTT outlier detection in half decibels. Default value recommended by the\n# system team currently is -140 (corresponding to -70 dB).\nLOWI_RSSI_THRESHOLD_FOR_RTT = -140\n\n# Number of measurment per AP for RTS/CTS\nLOWI_RTS_CTS_NUM_MEAS = 5\n\n# Maximum Number of Outstanding Requests supported\nLOWI_MAX_OUTSTANDING_REQUEST = 255\n\n# Maximum number of records in Cache\nLOWI_MAX_NUM_CACHE_RECORDS = 200\n\n# Default threshold before issuing another fresh scan (ms)\nLOWI_FRESH_SCAN_THRESHOLD = 500\n\n# Timeout in case no result is reported by the driver (seconds)\nLOWI_NO_RESULT_WAIT_TOLERANCE = 10\n\n# Use Fake Wifi driver. Only valid for engineering builds\nLOWI_USE_FAKE_WIFI_DRIVER = 0\n\n# Use ROME Wifi driver. Only valid for engineering builds\n# Will be removed later only for development support\nLOWI_USE_ROME_WIFI_DRIVER = 0\n\n# Use LOWI LP.\n# When enabled the Discovery Request will be routed to LOWI-LP\nLOWI_USE_LOWI_LP = 1\n\n# Log level\n# EL_LOG_OFF = 0, EL_ERROR = 1, EL_WARNING = 2, EL_INFO = 3, EL_DEBUG = 4, EL_VERBOSE = 5, EL_LOG_ALL = 100\nLOWI_LOG_LEVEL = 2\n"
  },
  {
    "path": "gps/etc/sap.conf",
    "content": "################################\n# Sensor Settings\n################################\n#The following parameters are optional.\n#Internal defaults support MEMS sensors\n#native to most handset devices.\n#Device specific sensor characterization\n#for improved performance is possible as\n#described in SAP application notes.\n#GYRO_BIAS_RANDOM_WALK=\n#ACCEL_RANDOM_WALK_SPECTRAL_DENSITY=\n#ANGLE_RANDOM_WALK_SPECTRAL_DENSITY=\n#RATE_RANDOM_WALK_SPECTRAL_DENSITY=\n#VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY=\n\n# Sensor Sampling Rate Parameters for Low-Data Rate Filter (should be greater than 0)\n# used in loc_eng_reinit\nSENSOR_ACCEL_BATCHES_PER_SEC=2\nSENSOR_ACCEL_SAMPLES_PER_BATCH=5\nSENSOR_GYRO_BATCHES_PER_SEC=2\nSENSOR_GYRO_SAMPLES_PER_BATCH=5\n# Sensor Sampling Rate Parameters for High-Data Rate Filter (should be greater than 0)\nSENSOR_ACCEL_BATCHES_PER_SEC_HIGH=4\nSENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH=25\nSENSOR_GYRO_BATCHES_PER_SEC_HIGH=4\nSENSOR_GYRO_SAMPLES_PER_BATCH_HIGH=25\n\n# Sensor Control Mode (0=AUTO, 1=FORCE_ON)\n# used in loc_eng_reinit\nSENSOR_CONTROL_MODE=0\n\n# Enable or Disable Sensors for GPS use (0=Enable, 1=Disable)\n# used in loc_eng_reinit\nSENSOR_USAGE=0\n\n# Choose GSIFF sensor provider (1=Snapdragon Sensors Core, 2=Android NDK)\nSENSOR_PROVIDER=1\n\n# Bit mask used to define which sensor algorithms are used.\n# Setting each bit has the following definition:\n#  0x1 - DISABLE_INS_POSITIONING_FILTER\n#  0x0 - ENABLE_INS_POSITIONING_FILTER\nSENSOR_ALGORITHM_CONFIG_MASK=0x1\n\n# Time source used by Sensor HAL\n# Setting this value controls accuracy of location sensor services.\n#  0 - Unknown\n#  1 - CLOCK_BOOTTIME\n#  2 - CLOCK_MONOTONIC\n#  3 - CLOCK_REALTIME\n#  4 - CLOCK_BOOTTIME using Alarm timer interface\nNDK_PROVIDER_TIME_SOURCE=1\n\n"
  },
  {
    "path": "gps/etc/xtwifi.conf",
    "content": "#GTP AP Project client core config file\n#\n#GENERAL DESCRIPTION\n#This is used by client core\n#\n#Copyright (c) 2012-2014 Qualcomm Atheros, Inc.\n#All Rights Reserved.\n#Qualcomm Atheros Confidential and Proprietary.\n\n# Log verbosity control for most of the GTP WiFi system, including native and\n# Java componenets\n# OFF = 0, ERROR = 1, WARNING = 2, INFO = 3, DEBUG = 4, VERBOSE = 5, ALL = 100\nDEBUG_GLOBAL_LOG_LEVEL = 2\n\n# this is used at the server side to distinguish uploads from different maker/model\n# default \"Qualcomm\"\nOEM_ID_IN_REQUEST_TO_SERVER = \"Qualcomm\"\n\n# this is used at the server side to distinguish uploads from different maker/model\n# default \"UNKNOWN\"\nMODEL_ID_IN_REQUEST_TO_SERVER = \"UNKNOWN\"\n\n##############################################################################\n# GTP-WiFi positioning config                                                #\n##############################################################################\n\n# URL for the server position request\nXT_SERVER_ROOT_URL = https://gtpa1.izatcloud.net:443/uds/v2\n\n# size, in bytes, of the cache on device\nSIZE_BYTE_TOTAL_CACHE = 5000000\n\n# value 0: (default) use the async LOWI wifi scanner\n# value 10: FAKE AP wifi scanner\nWIFI_SCANNER_CHOICE = 0\n\n##############################################################################\n# XT-WiFi crowd sourcing config                                              #\n##############################################################################\n# Use server suggestion for crowd sourcing configuration\nENABLE_SERVER_SUGGESTION_FOR_CROWD_SOURCING = 1\n\n# Maximum number of APs to be collected for upload\nNUM_MAX_AP_PER_UPLOAD = 16383\n# Number of minutes between upload: 24 hours\nINTERVAL_MIN_UPLOAD = 1440\n# Number of minutes between forced upload: 5 days\nINTERVAL_MIN_FORCED_UPLOAD = 7200\n\n# The minimum time between two collected AP data sets in seconds\nINTERVAL_SEC_AP_SETS_COLLECT = 10\n# Timeout for scan interval when phone is on: 600 seconds (10 minute)\nINTERVAL_SEC_SCAN = 600\n# Timeout for scan interval when phone has not continusouly on for INTERVAL_MIN_SCAN\nINTERVAL_MIN_FORCED_SCAN = 480\n\n# Maximum number of Cell DB records for upload\nWWAN_MAX_CELLDB_RECORDS_PER_UPLOAD = 1000\n\n##############################################################################\n# GTP AP cell config                                                         #\n##############################################################################\n# This item specifies the RIL server name.\n# This configure item can not be removed in Android target.\nXTRAT_WWAN_LITE_LOC_RIL_SERVER_NAME = \"OS-Agent\"\n\n# Maximum total number of SNA records cached in mobile storage.\n# Max allowed value is 10000\n# Min value is 100\nXTRAT_WWAN_LITE_MAX_DL_SNA = 10000\n\n# Maximum total number of BSA records cached in mobile storage.\n# Max allowed value is 65000\n# Min value is 100\nXTRAT_WWAN_LITE_MAX_DL_BSA = 65000\n\n##############################################################################\n# Qualcomm Network Location Provider config                                  #\n##############################################################################\n# Accuracy Threshold for NLP position. Position exceeds thsi threshold will be filtered out.\n# Default is 25000 meters.\nLARGE_ACCURACY_THRESHOLD_TO_FILTER_NLP_POSITION = 25000"
  },
  {
    "path": "gps/loc-api.pc.in",
    "content": "prefix=@prefix@\nexec_prefix=@exec_prefix@\nlibdir=@libdir@\nincludedir=@includedir@\n\nName: loc-api\nDescription: Qualcomm GPS Location API\nVersion: @VERSION@\nLibs: -L${libdir} -lgps_utils_so -lloc_adapter_so -lloc_eng_so -lgps_default_so -lloc_api\nCflags: -I${includedir}/loc-api/libloc_api_50001 -I${includedir}/loc-api/utils -I${includedir}/ -I${includedir}/loc-api\n"
  },
  {
    "path": "gps/loc_api/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\n\n# add RPC dirs if RPC is available\nifneq ($(TARGET_NO_RPC),true)\n\nGPS_DIR_LIST += $(LOCAL_PATH)/libloc_api-rpc-50001/\n\nendif #TARGET_NO_RPC\n\nGPS_DIR_LIST += $(LOCAL_PATH)/libloc_api_50001/\n\n#call the subfolders\ninclude $(addsuffix Android.mk, $(GPS_DIR_LIST))\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/Android.mk",
    "content": "ifeq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION),50001)\ninclude $(call all-subdir-makefiles)\nendif\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/Android.mk",
    "content": "LOCAL_PATH:= $(call my-dir)\ninclude $(CLEAR_VARS)\n\nRPC_INC:=rpc_inc\n\nsource_files:= \\\n    src/loc_api_rpc_glue.c \\\n    src/loc_api_sync_call.c \\\n    src/loc_apicb_appinit.c \\\n    src/loc_api_fixup.c \\\n    src/loc_api_log.c \\\n    src/LocApiRpc.cpp\n\nLOCAL_SRC_FILES:= $(source_files)\n\nLOCAL_CFLAGS:=-fno-short-enums\nLOCAL_CFLAGS+=-DDEBUG -DUSE_QCOM_AUTO_RPC -DUSE_QCOM_AUTO_RPC\nLOCAL_CFLAGS+=$(GPS_FEATURES)\n\n# for loc_api_fixup.c\nLOCAL_CFLAGS+=-DADD_XDR_FLOAT -DADD_XDR_BOOL\n\nLOCAL_SHARED_LIBRARIES:= \\\n    librpc \\\n    libutils \\\n    libcutils \\\n    libcommondefs \\\n    libgps.utils \\\n    libloc_core\n\nLOCAL_STATIC_LIBRARIES := \\\n    libloc_api_rpcgen\n\nLOCAL_PRELINK_MODULE:= false\n\nLOCAL_C_INCLUDES:= \\\n    $(LOCAL_PATH) \\\n    $(LOCAL_PATH)/rpc_inc \\\n    $(TARGET_OUT_HEADERS)/gps.utils \\\n    $(TARGET_OUT_HEADERS)/libloc_core \\\n    $(TARGET_OUT_HEADERS)/loc_api/rpcgen/inc \\\n    $(TARGET_OUT_HEADERS)/libcommondefs/rpcgen/inc \\\n    $(TARGET_OUT_HEADERS)/librpc \\\n    $(TARGET_OUT_HEADERS)/libloc-rpc/rpc_inc \\\n    $(TOP)/hardware/msm7k/librpc\n\nLOCAL_COPY_HEADERS_TO:= libloc_api-rpc-qc/$(RPC_INC)\nLOCAL_COPY_HEADERS:= \\\n    $(RPC_INC)/loc_api_rpc_glue.h \\\n    $(RPC_INC)/loc_api_fixup.h \\\n    $(RPC_INC)/loc_api_sync_call.h \\\n    $(RPC_INC)/loc_apicb_appinit.h \\\n    $(RPC_INC)/LocApiRpc.h\n\nLOCAL_MODULE:= libloc_api-rpc-qc\nLOCAL_MODULE_OWNER := qcom\n\nLOCAL_MODULE_TAGS := optional\n\ninclude $(BUILD_SHARED_LIBRARY)\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/Makefile.am",
    "content": "AM_CFLAGS = \\\n   -I../../../utils \\\n   -I../../../platform_lib_abstractions \\\n   -I./rpc_inc \\\n   -I../libloc_api-rpc-stub/inc \\\n   -I../../libloc_api_50001 \\\n   $(MSM7K_CFLAGS) \\\n   -DUSE_QCOM_AUTO_RPC\n\nrequiredlibs = \\\n   ../../../utils/libgps_utils_so.la \\\n   $(MSM7K_LIBS)\n\nh_sources = \\\n    rpc_inc/loc_api_rpc_glue.h \\\n    rpc_inc/loc_api_fixup.h \\\n    rpc_inc/loc_api_sync_call.h \\\n    rpc_inc/loc_apicb_appinit.h \\\n\nc_sources = \\\n    src/loc_api_rpc_glue.c \\\n    src/loc_api_sync_call.c \\\n    src/loc_apicb_appinit.c \\\n    src/loc_api_fixup.c \\\n    src/loc_api_log.c \\\n    src/LocApiRpcAdapter.cpp \\\n\n\nlibrary_includedir = $(pkgincludedir)/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc\nlibrary_include_HEADERS = $(h_sources)\nlibloc_api_rpc_qc_la_SOURCES = $(c_sources) $(h_sources)\n\nif USE_GLIB\nlibloc_api_rpc_qc_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@\nlibloc_api_rpc_qc_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0\nlibloc_api_rpc_qc_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@\nelse\nlibloc_api_rpc_qc_la_CFLAGS = $(AM_CFLAGS)\nlibloc_api_rpc_qc_la_LDFLAGS = -lpthread -shared -version-info 1:0:0\nlibloc_api_rpc_qc_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)\nendif\n\nlibloc_api_rpc_qc_la_LIBADD = $(requiredlibs) -lstdc++\n\n#Create and Install Libraries\nlib_LTLIBRARIES = libloc_api_rpc_qc.la\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h",
    "content": "/* Copyright (c) 2011,2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_API_RPC_H\n#define LOC_API_RPC_H\n\n#include <rpc/rpc.h>\n#include <loc_api_rpcgen_common_rpc.h>\n#include <loc_api_rpc_glue.h>\n#include <LocApiBase.h>\n#include <loc_log.h>\n\nusing namespace loc_core;\n\nclass LocApiRpc : public LocApiBase {\nprotected:\n    // RPC communication establishment\n    rpc_loc_client_handle_type client_handle;\n\nprivate:\n    int dataEnableLastSet;\n    char apnLastSet[MAX_APN_LEN];\n\n    static const LOC_API_ADAPTER_EVENT_MASK_T maskAll;\n    static const rpc_loc_event_mask_type locBits[];\n    static rpc_loc_event_mask_type convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask);\n    static rpc_loc_lock_e_type convertGpsLockMask(LOC_GPS_LOCK_MASK lockMask);\n    static enum loc_api_adapter_err convertErr(int rpcErr);\n    static GpsNiEncodingType convertNiEncodingType(int loc_encoding);\n    static int NIEventFillVerfiyType(GpsNiNotification &notif,\n                              rpc_loc_ni_notify_verify_e_type notif_priv);\n\n    void reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr);\n    void reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr);\n    void reportStatus(const rpc_loc_status_event_s_type *status_report_ptr);\n    void reportNmea(const rpc_loc_nmea_report_s_type *nmea_report_ptr);\n    void ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr);\n    void NIEvent(const rpc_loc_ni_event_s_type *ni_req_ptr);\n\nprotected:\n    virtual enum loc_api_adapter_err\n        open(LOC_API_ADAPTER_EVENT_MASK_T mask);\n    virtual enum loc_api_adapter_err\n        close();\n\npublic:\n    LocApiRpc(const MsgTask* msgTask,\n              LOC_API_ADAPTER_EVENT_MASK_T exMask);\n    ~LocApiRpc();\n\n    virtual int locEventCB(rpc_loc_client_handle_type client_handle,\n                   rpc_loc_event_mask_type loc_event,\n                   const rpc_loc_event_payload_u_type* loc_event_payload);\n\n    void locRpcGlobalCB(CLIENT* clnt, enum rpc_reset_event event);\n\n    // RPC adapter interface implementations\n    virtual enum loc_api_adapter_err\n        startFix(const LocPosMode& posMode);\n    virtual enum loc_api_adapter_err\n        stopFix();\n    virtual enum loc_api_adapter_err\n        setPositionMode(const LocPosMode& mode);\n    inline virtual enum loc_api_adapter_err\n        enableData(int enable) { return enableData(enable, false); }\n    virtual enum loc_api_adapter_err\n        enableData(int enable, boolean force);\n    virtual enum loc_api_adapter_err\n        setTime(GpsUtcTime time, int64_t timeReference, int uncertainty);\n    virtual enum loc_api_adapter_err\n        injectPosition(double latitude, double longitude, float accuracy);\n    virtual enum loc_api_adapter_err\n        deleteAidingData(GpsAidingData f);\n    virtual enum loc_api_adapter_err\n        informNiResponse(GpsUserResponseType userResponse, const void* passThroughData);\n    inline virtual enum loc_api_adapter_err\n        setAPN(char* apn, int len) { return setAPN(apn, len, false); }\n    virtual enum loc_api_adapter_err\n        setAPN(char* apn, int len, boolean force);\n    virtual enum loc_api_adapter_err\n        setServer(const char* url, int len);\n    virtual enum loc_api_adapter_err\n        setServer(unsigned int ip, int port, LocServerType type);\n    virtual enum loc_api_adapter_err\n        setXtraData(char* data, int length);\n    virtual enum loc_api_adapter_err\n        requestXtraServer();\n    virtual enum loc_api_adapter_err\n        atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType);\n    virtual enum loc_api_adapter_err\n        atlCloseStatus(int handle, int is_succ);\n    virtual enum loc_api_adapter_err\n        setSUPLVersion(uint32_t version);\n    virtual void setInSession(bool inSession);\n\n    /*Values for lock\n      1 = Do not lock any position sessions\n      2 = Lock MI position sessions\n      3 = Lock MT position sessions\n      4 = Lock all position sessions\n    */\n    virtual int setGpsLock(LOC_GPS_LOCK_MASK lock);\n    /*\n     Returns\n     Current value of GPS Lock on success\n     -1 on failure\n     */\n    virtual int getGpsLock(void);\n};\n\nextern \"C\" LocApiBase* getLocApi(const MsgTask* msgTask,\n                                 LOC_API_ADAPTER_EVENT_MASK_T exMask,\n                                 ContextBase *context);\n\n#endif //LOC_API_RPC_H\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/debug.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DEBUG_H\n#define DEBUG_H\n\n#include <stdio.h>\n\n#define LOG_TAG \"LocSvc_rpc\"\n#include <utils/Log.h>\n\n#define PRINT(x...) do {                                    \\\n        fprintf(stdout, \"%s(%d) \", __FUNCTION__, __LINE__); \\\n        fprintf(stdout, ##x);                               \\\n        ALOGD(x);                               \\\n    } while(0)\n\n#ifdef DEBUG\n#define D PRINT\n#else\n#define D(x...) do { } while(0)\n#endif\n\n#ifdef VERBOSE\n#define V PRINT\n#else\n#define V(x...) do { } while(0)\n#endif\n\n#define E(x...) do {                                        \\\n        fprintf(stderr, \"%s(%d) \", __FUNCTION__, __LINE__); \\\n        fprintf(stderr, ##x);                               \\\n        ALOGE(x);                                            \\\n    } while(0)\n\n#define FAILIF(cond, msg...) do {                                              \\\n        if (__builtin_expect (cond, 0)) {                                      \\\n            fprintf(stderr, \"%s:%s:(%d): \", __FILE__, __FUNCTION__, __LINE__); \\\n            fprintf(stderr, ##msg);                                            \\\n            ALOGE(##msg);                                                       \\\n        }                                                                      \\\n    } while(0)\n\n#endif/*DEBUG_H*/\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/loc_api_fixup.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef  LOC_API_FIXUP_H\n#define LOC_API_FIXUP_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#ifndef NULLPROC\n#define NULLPROC 0\n#endif /* NULLPROC */\n\n#ifdef ADD_XDR_FLOAT\n\nextern bool_t xdr_float (XDR *__xdrs, float *__fp);\nextern bool_t xdr_double (XDR *__xdrs, double *__dp);\n\n#endif /* ADD_XDR_FLOAT */\n\n#ifdef ADD_XDR_BOOL\nextern bool_t xdr_bool(XDR *__xdrs, int *__bp);\n#endif /* ADD_XDR_BOOL */\n\n#define RPC_LOC_API_MAJOR_VERSION_NUMBER   1\n#define RPC_LOC_API_MINOR_VERSION_NUMBER   0\n\n// Return value for loc_open in case of failure.\n#define RPC_LOC_CLIENT_HANDLE_INVALID     -1\n\n// Return value of loc api calls for loc_close, loc_start_fix, loc_stop_fix and loc_ioctl\n// These are also the status for the ioctl callback\n#define RPC_LOC_API_SUCCESS           0\n#define RPC_LOC_API_GENERAL_FAILURE   1\n#define RPC_LOC_API_UNSUPPORTED       2\n#define RPC_LOC_API_INVALID_HANDLE    4\n#define RPC_LOC_API_INVALID_PARAMETER 5\n#define RPC_LOC_API_ENGINE_BUSY       6\n#define RPC_LOC_API_PHONE_OFFLINE     7\n#define RPC_LOC_API_TIMEOUT           8\n\n// Special return value for loc api calls in case of RPC failure\n#define RPC_LOC_API_RPC_FAILURE       (-1234)\n// Special return value for modem restart incurred RPC failure\n#define RPC_LOC_API_RPC_MODEM_RESTART       (-1235)\n\n#define RPC_LOC_API_MAX_SV_COUNT                      80\n#define RPC_LOC_API_MAX_NMEA_STRING_LENGTH            1200\n\n// Maximum server address that will be used in location API\n#define RPC_LOC_API_MAX_SERVER_ADDR_LENGTH            256\n#define RPC_LOC_API_MAX_NUM_PREDICTED_ORBITS_SERVERS  3\n#define RPC_LOC_API_MAX_NUM_NTP_SERVERS               3\n\n#define RPC_LOC_EVENT_PARSED_POSITION_REPORT             0x00000001 // Position report comes in loc_parsed_position_s_type\n#define RPC_LOC_EVENT_SATELLITE_REPORT                   0x00000002 // Satellite in view report\n#define RPC_LOC_EVENT_NMEA_1HZ_REPORT                    0x00000004 // NMEA report at 1HZ rate\n#define RPC_LOC_EVENT_NMEA_POSITION_REPORT               0x00000008 // NMEA report at position report rate\n#define RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST           0x00000010 // NI notification/verification request\n#define RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST            0x00000020 // Assistance data, eg: time, predicted orbits request\n#define RPC_LOC_EVENT_LOCATION_SERVER_REQUEST            0x00000040 // Request for location server\n#define RPC_LOC_EVENT_IOCTL_REPORT                       0x00000080 // Callback report for loc_ioctl\n#define RPC_LOC_EVENT_STATUS_REPORT                      0x00000100 // Misc status report: eg, engine state\n\n#define RPC_LOC_POS_VALID_SESSION_STATUS                 0x00000001\n#define RPC_LOC_POS_VALID_TIMESTAMP_CALENDAR             0x00000002\n#define RPC_LOC_POS_VALID_TIMESTAMP_UTC                  0x00000004\n#define RPC_LOC_POS_VALID_LEAP_SECONDS                   0x00000008\n#define RPC_LOC_POS_VALID_TIME_UNC                       0x00000010\n#define RPC_LOC_POS_VALID_LATITUDE                       0x00000020\n#define RPC_LOC_POS_VALID_LONGITUDE                      0x00000040\n#define RPC_LOC_POS_VALID_ALTITUDE_WRT_ELLIPSOID         0x00000080\n#define RPC_LOC_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL    0x00000100\n#define RPC_LOC_POS_VALID_SPEED_HORIZONTAL               0x00000200\n#define RPC_LOC_POS_VALID_SPEED_VERTICAL                 0x00000400\n#define RPC_LOC_POS_VALID_HEADING                        0x00000800\n#define RPC_LOC_POS_VALID_HOR_UNC_CIRCULAR               0x00001000\n#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_SEMI_MAJ          0x00002000\n#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_SEMI_MIN          0x00004000\n#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_ORIENT_AZIMUTH    0x00008000\n#define RPC_LOC_POS_VALID_VERTICAL_UNC                   0x00010000\n#define RPC_LOC_POS_VALID_SPEED_UNC                      0x00020000\n#define RPC_LOC_POS_VALID_HEADING_UNC                    0x00040000\n#define RPC_LOC_POS_VALID_CONFIDENCE_HORIZONTAL          0x00080000\n#define RPC_LOC_POS_VALID_CONFIDENCE_VERTICAL            0x00100000\n#define RPC_LOC_POS_VALID_MAGNETIC_VARIATION             0x00200000\n#define RPC_LOC_POS_VALID_TECHNOLOGY_MASK                0x00400000\n\n#define RPC_LOC_POS_TECH_SATELLITE 0x00000001\n#define RPC_LOC_POS_TECH_CELLID    0x00000002\n#define RPC_LOC_POS_TECH_WIFI      0x00000004\n\n#define RPC_LOC_SV_INFO_VALID_SYSTEM         0x00000001\n#define RPC_LOC_SV_INFO_VALID_PRN            0x00000002\n#define RPC_LOC_SV_INFO_VALID_HEALTH_STATUS  0x00000004\n#define RPC_LOC_SV_INFO_VALID_PROCESS_STATUS 0x00000008\n#define RPC_LOC_SV_INFO_VALID_HAS_EPH        0x00000010\n#define RPC_LOC_SV_INFO_VALID_HAS_ALM        0x00000020\n#define RPC_LOC_SV_INFO_VALID_ELEVATION      0x00000040\n#define RPC_LOC_SV_INFO_VALID_AZIMUTH        0x00000080\n#define RPC_LOC_SV_INFO_VALID_SNR            0x00000100\n\n#define RPC_LOC_GNSS_INFO_VALID_POS_DOP           0x00000001\n#define RPC_LOC_GNSS_INFO_VALID_HOR_DOP           0x00000002\n#define RPC_LOC_GNSS_INFO_VALID_VERT_DOP          0x00000004\n#define RPC_LOC_GNSS_INFO_VALID_ALTITUDE_ASSUMED  0x00000008\n#define RPC_LOC_GNSS_INFO_VALID_SV_COUNT          0x00000010\n#define RPC_LOC_GNSS_INFO_VALID_SV_LIST           0x00000020\n\n#define RPC_LOC_NI_MAX_REQUESTOR_ID_LENGTH          200\n#define RPC_LOC_NI_SUPL_HASH_LENGTH                 8\n#define RPC_LOC_NI_SUPL_SLP_SESSION_ID_BYTE_LENGTH  4\n#define RPC_LOC_NI_MAX_CLIENT_NAME_LENGTH           64\n#define RPC_LOC_NI_MAX_EXT_CLIENT_ADDRESS           20\n#define RPC_LOC_NI_CODEWORD_LENGTH                  20\n\n#define RPC_LOC_NI_SUPL_QOP_VALID         0x01\n#define RPC_LOC_NI_SUPL_QOP_VERACC_VALID  0x02\n#define RPC_LOC_NI_SUPL_QOP_MAXAGE_VALID  0x04\n#define RPC_LOC_NI_SUPL_QOP_DELAY_VALID   0x08\n\n#define RPC_LOC_FIX_CRIT_VALID_RECURRENCE_TYPE                  0x00000001\n#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_OPERATION_MODE         0x00000002\n#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_ACCURACY               0x00000004\n#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_RESPONSE_TIME          0x00000008\n#define RPC_LOC_FIX_CRIT_VALID_INTERMEDIATE_POS_REPORT_ENABLED  0x00000010\n#define RPC_LOC_FIX_CRIT_VALID_NOTIFY_TYPE                      0x00000020\n#define RPC_LOC_FIX_CRIT_VALID_MIN_INTERVAL                     0x00000040\n#define RPC_LOC_FIX_CRIT_VALID_MIN_DISTANCE                     0x00000080\n#define RPC_LOC_FIX_CRIT_VALID_MIN_DIST_SAMPLE_INTERVAL         0x00000100\n\n#define RPC_LOC_ASSIST_POS_VALID_TIMESTAMP_UTC                0x00000001\n#define RPC_LOC_ASSIST_POS_VALID_LATITUDE                     0x00000002\n#define RPC_LOC_ASSIST_POS_VALID_LONGITUDE                    0x00000004\n#define RPC_LOC_ASSIST_POS_VALID_ALTITUDE_WRT_ELLIPSOID       0x00000008\n#define RPC_LOC_ASSIST_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL  0x00000010\n#define RPC_LOC_ASSIST_POS_VALID_HOR_UNC_CIRCULAR             0x00000020\n#define RPC_LOC_ASSIST_POS_VALID_VERT_UNC                     0x00000040\n#define RPC_LOC_ASSIST_POS_VALID_CONFIDENCE_HORIZONTAL        0x00000080\n#define RPC_LOC_ASSIST_POS_VALID_CONFIDENCE_VERTICAL          0x00000100\n#define RPC_LOC_ASSIST_POS_VALID_TIMESTAMP_AGE                0x00000200\n\n#define RPC_LOC_ASSIST_DATA_ALL         0xFFFFFFFF\n\n#define RPC_LOC_NMEA_MASK_ALL    0xffff\n#define RPC_LOC_NMEA_MASK_GGA    0x0001\n#define RPC_LOC_NMEA_MASK_RMC    0x0002\n#define RPC_LOC_NMEA_MASK_GSV    0x0004\n#define RPC_LOC_NMEA_MASK_GSA    0x0008\n#define RPC_LOC_NMEA_MASK_VTG    0x0010\n\n/* EFS data access */\n#define RPC_LOC_EFS_MAX_PATH_LEN_BYTES  64     /* Max file name length in bytes that can be written*/\n#define RPC_LOC_EFS_MAX_FILE_LEN_BYTES  2000   /* Max file size in bytes that can be written */\n\n/* WIPER valid information flag in log report */\n#define RPC_LOC_WIPER_LOG_TIME_VALID 0x01\n#define RPC_LOC_WIPER_LOG_POS_VALID 0x02\n#define RPC_LOC_WIPER_LOG_AP_SET_VALID 0x04\n\n/* General WIPER defines */\n#define RPC_LOC_WIPER_MAC_ADDR_LENGTH  6              // Do not change this number since it affects RPC and log packet sizes\n#define RPC_LOC_WIPER_MAX_REPORTED_APS_PER_LOG_MSG 50 // Do not change this number since it affects RPC and log packet sizes\n\n/* WIPER AP Qualifier */\n#define RPC_LOC_WIPER_AP_QUALIFIER_BEING_USED 0x1  /* AP is being used by WPS */\n#define RPC_LOC_WIPER_AP_QUALIFIER_HIDDEN_SSID 0x2 /* AP does not broadcast SSID */\n#define RPC_LOC_WIPER_AP_QUALIFIER_PRIVATE 0x4     /* AP has encryption turned on */\n#define RPC_LOC_WIPER_AP_QUALIFIER_INFRASTRUCTURE_MODE 0x8     /* AP is in infrastructure mode and not in ad-hoc/unknown mode */\n\n/* flags for notification */\n#define  RPC_LOC_NI_CLIENT_NAME_PRESENT             0x0001\n#define  RPC_LOC_NI_CLIENT_EXTADDR_PRESENT          0x0002\n#define  RPC_LOC_NI_DEF_LOCATION_TYPE_PRESENT       0x0010\n#define  RPC_LOC_NI_REQUESTOR_ID_PRESENT            0x0020\n#define  RPC_LOC_NI_CODEWORD_PRESENT                0x0040\n#define  RPC_LOC_NI_SERVICE_TYPE_ID_PRESENT         0x0080\n#define  RPC_LOC_NI_ENCODING_TYPE_PRESENT           0x0100\n\n/* below are for RPC_LOC_IOCTL_SET_LBS_APN_PROFILE data */\n/* values for apn_profiles[0].srv_system_type */\n#define LOC_APN_PROFILE_SRV_SYS_CDMA  0x01\n#define LOC_APN_PROFILE_SRV_SYS_HDR   0x02\n#define LOC_APN_PROFILE_SRV_SYS_GSM   0x04\n#define LOC_APN_PROFILE_SRV_SYS_WCDMA 0x08\n#define LOC_APN_PROFILE_SRV_SYS_LTE   0x10\n#define LOC_APN_PROFILE_SRV_SYS_MAX   0x1F\n/* values for apn_profiles[0].pdp_type */\n#define LOC_APN_PROFILE_PDN_TYPE_IPV4    0x01\n#define LOC_APN_PROFILE_PDN_TYPE_IPV6    0x02\n#define LOC_APN_PROFILE_PDN_TYPE_IPV4V6  0x03\n#define LOC_APN_PROFILE_PDN_TYPE_PPP     0x04\n#define LOC_APN_PROFILE_PDN_TYPE_MAX     0x04\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_API_FIXUP_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/loc_api_log.h",
    "content": "/* Copyright (c) 2011 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_API_LOG_H\n#define LOC_API_LOG_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#include <ctype.h>\n#include \"loc_api_rpcgen_common_rpc.h\"\n\nextern int loc_callback_log(\n      rpc_loc_event_mask_type               loc_event,              /* event mask           */\n      const rpc_loc_event_payload_u_type*   loc_event_payload       /* payload              */\n);\n\nextern const char* loc_get_event_atl_open_name(rpc_loc_server_request_e_type loc_event_atl_open);\nextern const char* loc_get_event_name(rpc_loc_event_mask_type loc_event_mask);\nextern const char* loc_get_ioctl_type_name(rpc_loc_ioctl_e_type ioctl_type);\nextern const char* loc_get_ioctl_status_name(uint32 status);\nextern const char* loc_get_sess_status_name(rpc_loc_session_status_e_type status);\nextern const char* loc_get_engine_state_name(rpc_loc_engine_state_e_type state);\nextern const char* loc_get_fix_session_state_name(rpc_loc_fix_session_state_e_type state);\nextern const char* loc_get_rpc_reset_event_name(enum rpc_reset_event event);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_API_LOG_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/loc_api_rpc_glue.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef LOC_API_RPC_GLUE_H\n#define LOC_API_RPC_GLUE_H\n\n/* Include RPC headers */\n#ifdef USE_LOCAL_RPC\n#include \"rpc_inc/loc_api_common.h\"\n#include \"rpc_inc/loc_api.h\"\n#include \"rpc_inc/loc_api_cb.h\"\n#endif\n\n#ifdef USE_QCOM_AUTO_RPC\n#include \"loc_api_rpcgen_rpc.h\"\n#include \"loc_api_rpcgen_common_rpc.h\"\n#include \"loc_api_rpcgen_cb_rpc.h\"\n#endif\n\n/* Boolean */\n/* Other data types in comdef.h are defined in rpc stubs, so fix it here */\ntypedef unsigned char boolean;\n#define TRUE 1\n#define FALSE 0\n\n#include \"loc_api_fixup.h\"\n#include \"loc_api_sync_call.h\"\n#include <rpc/clnt.h>\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\nextern int loc_api_glue_init(void);\nextern int loc_api_null(void);\n\ntypedef int32 (loc_event_cb_f_type)(\n    void*                                 userData,\n    rpc_loc_client_handle_type            loc_handle,             /* handle of the client */\n    rpc_loc_event_mask_type               loc_event,              /* event mask           */\n    const rpc_loc_event_payload_u_type*   loc_event_payload       /* payload              */\n);\n\ntypedef void (loc_reset_notif_cb_f_type)(\n    void*                                 userData,\n    CLIENT*                               clnt,\n    enum rpc_reset_event                  event\n);\n\nextern rpc_loc_client_handle_type loc_open(\n    rpc_loc_event_mask_type       event_reg_mask,\n    loc_event_cb_f_type           *event_callback,\n    loc_reset_notif_cb_f_type     *rpc_global_cb,\n    void*                         userData\n);\n\nextern int32 loc_close\n(\n      rpc_loc_client_handle_type handle\n);\n\nextern void loc_clear\n(\n      rpc_loc_client_handle_type handle\n);\n\nextern int32 loc_start_fix\n(\n      rpc_loc_client_handle_type handle\n);\n\nextern int32 loc_stop_fix\n(\n      rpc_loc_client_handle_type handle\n);\n\nextern int32 loc_ioctl\n(\n      rpc_loc_client_handle_type           handle,\n      rpc_loc_ioctl_e_type                 ioctl_type,\n      rpc_loc_ioctl_data_u_type*           ioctl_data\n);\n\nextern int loc_eng_ioctl\n(\n      rpc_loc_client_handle_type           handle,\n      rpc_loc_ioctl_e_type                 ioctl_type,\n      rpc_loc_ioctl_data_u_type*           ioctl_data_ptr,\n      uint32                               timeout_msec,\n      rpc_loc_ioctl_callback_s_type       *cb_data_ptr\n);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_API_RPC_GLUE_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/loc_api_sync_call.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef LOC_API_CB_SYNC_H\n#define LOC_API_CB_SYNC_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n#include \"loc_api_rpc_glue.h\"\n#define LOC_SYNC_CALL_SLOTS_MAX 8\n\ntypedef struct {\n   pthread_mutex_t                lock;\n\n   /* Client ID */\n   rpc_loc_client_handle_type     loc_handle;\n\n   /* Callback waiting conditional variable */\n   pthread_cond_t                 loc_cb_arrived_cond;\n\n   /* Callback waiting data block, protected by loc_cb_data_mutex */\n   boolean                        in_use;\n   boolean                        signal_sent;\n   boolean                        not_available;\n   rpc_loc_event_mask_type        loc_cb_wait_event_mask;        /* event to wait for */\n   rpc_loc_ioctl_e_type           ioctl_type;                    /* ioctl to wait for */\n   rpc_loc_event_payload_u_type   loc_cb_received_payload;       /* received payload */\n   rpc_loc_event_mask_type        loc_cb_received_event_mask;    /* received event   */\n} loc_sync_call_slot_s_type;\n\ntypedef struct {\n   int                            num_of_slots;\n   loc_sync_call_slot_s_type      slots[LOC_SYNC_CALL_SLOTS_MAX];\n} loc_sync_call_slot_array_s_type;\n\n/* Init function */\nvoid loc_api_sync_call_init();\n\n/* Destroy function */\nvoid loc_api_sync_call_destroy();\n\n/* Process Loc API callbacks to wake up blocked user threads */\nvoid loc_api_callback_process_sync_call(\n      rpc_loc_client_handle_type            loc_handle,             /* handle of the client */\n      rpc_loc_event_mask_type               loc_event,              /* event mask           */\n      const rpc_loc_event_payload_u_type*   loc_event_payload       /* payload              */\n);\n\n/* Reentrant synchronous IOCTL call, using Loc API return code */\nint loc_api_sync_ioctl\n(\n      rpc_loc_client_handle_type           handle,\n      rpc_loc_ioctl_e_type                 ioctl_type,\n      rpc_loc_ioctl_data_u_type*           ioctl_data_ptr,\n      uint32                               timeout_msec,\n      rpc_loc_ioctl_callback_s_type       *cb_data_ptr\n);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_API_CB_SYNC_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/loc_apicb_appinit.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef LOC_APICB_APPINIT_H\n#define LOC_APICB_APPINIT_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n /* Initialization function for callbacks */\nextern int loc_apicb_app_init();\nextern void loc_apicb_app_deinit();\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_APICB_APPINIT_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_api_rpc\"\n\n#include <unistd.h>\n#include <math.h>\n#ifndef USE_GLIB\n#include <utils/SystemClock.h>\n#endif /* USE_GLIB */\n#include <LocApiRpc.h>\n#include <LocAdapterBase.h>\n#include <loc_api_fixup.h>\n#include <loc_api_rpc_glue.h>\n#include <log_util.h>\n#include <loc_log.h>\n#include <loc_api_log.h>\n#ifdef USE_GLIB\n#include <glib.h>\n#endif\n#include <librpc.h>\n#include <platform_lib_includes.h>\n\nusing namespace loc_core;\n\n#define LOC_XTRA_INJECT_DEFAULT_TIMEOUT (3100)\n#define XTRA_BLOCK_SIZE                 (3072)\n#define LOC_IOCTL_DEFAULT_TIMEOUT 1000 // 1000 milli-seconds\n#define LOC_NI_NOTIF_KEY_ADDRESS           \"Address\"\n\n/*===========================================================================\nFUNCTION    loc_event_cb\n\nDESCRIPTION\n   This is the callback function registered by loc_open.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   RPC_LOC_API_SUCCESS\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int32 loc_event_cb\n(\n    void*                                user,\n    rpc_loc_client_handle_type           client_handle,\n    rpc_loc_event_mask_type              loc_event,\n    const rpc_loc_event_payload_u_type*  loc_event_payload\n)\n{\n    MODEM_LOG_CALLFLOW(%s, loc_get_event_name(loc_event));\n    loc_callback_log(loc_event, loc_event_payload);\n    int32 ret_val = ((LocApiRpc*)user)->locEventCB(client_handle, loc_event, loc_event_payload);\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_rpc_global_cb\n\nDESCRIPTION\n   This is the callback function registered by loc_open for RPC global events\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   RPC_LOC_API_SUCCESS\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_rpc_global_cb(void* user, CLIENT* clnt, enum rpc_reset_event event)\n{\n    MODEM_LOG_CALLFLOW(%s, loc_get_rpc_reset_event_name(event));\n    ((LocApiRpc*)user)->locRpcGlobalCB(clnt, event);\n    EXIT_LOG(%p, VOID_RET);\n}\n\nconst LOC_API_ADAPTER_EVENT_MASK_T LocApiRpc::maskAll =\n    LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |\n    LOC_API_ADAPTER_BIT_SATELLITE_REPORT |\n    LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST |\n    LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST |\n    LOC_API_ADAPTER_BIT_IOCTL_REPORT |\n    LOC_API_ADAPTER_BIT_STATUS_REPORT |\n    LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |\n    LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST;\n\nconst rpc_loc_event_mask_type LocApiRpc::locBits[] =\n{\n    RPC_LOC_EVENT_PARSED_POSITION_REPORT,\n    RPC_LOC_EVENT_SATELLITE_REPORT,\n    RPC_LOC_EVENT_NMEA_1HZ_REPORT,\n    RPC_LOC_EVENT_NMEA_POSITION_REPORT,\n    RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST,\n    RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST,\n    RPC_LOC_EVENT_LOCATION_SERVER_REQUEST,\n    RPC_LOC_EVENT_IOCTL_REPORT,\n    RPC_LOC_EVENT_STATUS_REPORT,\n    RPC_LOC_EVENT_WPS_NEEDED_REQUEST\n};\n\n// constructor\nLocApiRpc::LocApiRpc(const MsgTask* msgTask,\n                     LOC_API_ADAPTER_EVENT_MASK_T exMask,\n                     ContextBase* context) :\n    LocApiBase(msgTask, exMask, context),\n    client_handle(RPC_LOC_CLIENT_HANDLE_INVALID),\n    dataEnableLastSet(-1)\n{\n    memset(apnLastSet, 0, sizeof(apnLastSet));\n    loc_api_glue_init();\n}\n\nLocApiRpc::~LocApiRpc()\n{\n    close();\n}\n\nrpc_loc_event_mask_type\nLocApiRpc::convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask)\n{\n    rpc_loc_event_mask_type newMask = 0;\n\n    for (unsigned int i = 0, bit=1; 0 != mask; i++, bit<<=1) {\n        if (mask & bit) {\n            newMask |= locBits[i];\n            mask ^= bit;\n        }\n    }\n\n    return newMask;\n}\n\nrpc_loc_lock_e_type\nLocApiRpc::convertGpsLockMask(LOC_GPS_LOCK_MASK lockMask)\n{\n    if (isGpsLockAll(lockMask))\n        return RPC_LOC_LOCK_ALL;\n    if (isGpsLockMO(lockMask))\n        return RPC_LOC_LOCK_MI;\n    if (isGpsLockMT(lockMask))\n        return RPC_LOC_LOCK_MT;\n    if (isGpsLockNone(lockMask))\n        return RPC_LOC_LOCK_NONE;\n    return (rpc_loc_lock_e_type)lockMask;\n}\n\nenum loc_api_adapter_err\nLocApiRpc::convertErr(int rpcErr)\n{\n    switch(rpcErr)\n    {\n    case RPC_LOC_API_SUCCESS:\n        return LOC_API_ADAPTER_ERR_SUCCESS;\n    case RPC_LOC_API_GENERAL_FAILURE:\n        return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;\n    case RPC_LOC_API_UNSUPPORTED:\n        return LOC_API_ADAPTER_ERR_UNSUPPORTED;\n    case RPC_LOC_API_INVALID_HANDLE:\n        return LOC_API_ADAPTER_ERR_INVALID_HANDLE;\n    case RPC_LOC_API_INVALID_PARAMETER:\n        return LOC_API_ADAPTER_ERR_INVALID_PARAMETER;\n    case RPC_LOC_API_ENGINE_BUSY:\n        return LOC_API_ADAPTER_ERR_ENGINE_BUSY;\n    case RPC_LOC_API_PHONE_OFFLINE:\n        return LOC_API_ADAPTER_ERR_PHONE_OFFLINE;\n    case RPC_LOC_API_TIMEOUT:\n        return LOC_API_ADAPTER_ERR_TIMEOUT;\n    case RPC_LOC_API_RPC_MODEM_RESTART:\n        return LOC_API_ADAPTER_ERR_ENGINE_DOWN;\n    case RPC_LOC_API_RPC_FAILURE:\n        return LOC_API_ADAPTER_ERR_FAILURE;\n    default:\n        return LOC_API_ADAPTER_ERR_UNKNOWN;\n    }\n}\n\nvoid LocApiRpc::locRpcGlobalCB(CLIENT* clnt, enum rpc_reset_event event)\n{\n    static rpc_loc_engine_state_e_type last_state = RPC_LOC_ENGINE_STATE_MAX;\n\n    switch (event) {\n    case RPC_SUBSYSTEM_RESTART_BEGIN:\n        if (RPC_LOC_ENGINE_STATE_OFF != last_state) {\n            last_state = RPC_LOC_ENGINE_STATE_OFF;\n            handleEngineDownEvent();\n        }\n        break;\n    case RPC_SUBSYSTEM_RESTART_END:\n        if (RPC_LOC_ENGINE_STATE_ON != last_state) {\n            last_state = RPC_LOC_ENGINE_STATE_ON;\n            handleEngineUpEvent();\n        }\n        break;\n    }\n}\n\nint32 LocApiRpc::locEventCB(rpc_loc_client_handle_type client_handle,\n                     rpc_loc_event_mask_type loc_event,\n                     const rpc_loc_event_payload_u_type* loc_event_payload)\n{\n    // Parsed report\n    if (loc_event & RPC_LOC_EVENT_PARSED_POSITION_REPORT)\n    {\n        reportPosition(&loc_event_payload->rpc_loc_event_payload_u_type_u.\n                       parsed_location_report);\n    }\n\n    // Satellite report\n    if (loc_event & RPC_LOC_EVENT_SATELLITE_REPORT)\n    {\n        reportSv(&loc_event_payload->rpc_loc_event_payload_u_type_u.gnss_report);\n    }\n\n    // Status report\n    if (loc_event & RPC_LOC_EVENT_STATUS_REPORT)\n    {\n        reportStatus(&loc_event_payload->rpc_loc_event_payload_u_type_u.status_report);\n    }\n\n    // NMEA\n    if (loc_event & RPC_LOC_EVENT_NMEA_1HZ_REPORT)\n    {\n        reportNmea(&(loc_event_payload->rpc_loc_event_payload_u_type_u.nmea_report));\n    }\n    // XTRA support: supports only XTRA download\n    if (loc_event & RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST)\n    {\n        if (loc_event_payload->rpc_loc_event_payload_u_type_u.assist_data_request.event ==\n            RPC_LOC_ASSIST_DATA_PREDICTED_ORBITS_REQ)\n        {\n            requestXtraData();\n        } else if (loc_event_payload->rpc_loc_event_payload_u_type_u.assist_data_request.event ==\n                   RPC_LOC_ASSIST_DATA_TIME_REQ)\n        {\n            requestTime();\n        } else if (loc_event_payload->rpc_loc_event_payload_u_type_u.assist_data_request.event ==\n                   RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ)\n        {\n            requestLocation();\n        }\n    }\n\n    // AGPS data request\n    if (loc_event & RPC_LOC_EVENT_LOCATION_SERVER_REQUEST)\n    {\n        ATLEvent(&loc_event_payload->rpc_loc_event_payload_u_type_u.\n                 loc_server_request);\n    }\n\n    // NI notify request\n    if (loc_event & RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST)\n    {\n        NIEvent(&loc_event_payload->rpc_loc_event_payload_u_type_u.ni_request);\n    }\n\n    return RPC_LOC_API_SUCCESS;//We simply want to return sucess here as we do not want to\n    // cause any issues in RPC thread context\n}\n\nenum loc_api_adapter_err\nLocApiRpc::open(LOC_API_ADAPTER_EVENT_MASK_T mask)\n{\n    enum loc_api_adapter_err ret_val = LOC_API_ADAPTER_ERR_SUCCESS;\n\n    // RPC does not dynamically update the event mask. And in the\n    // case of RPC, all we support are positioning (gps + agps)\n    // masks anyways, so we simply mask all of them on always.\n    // After doing so the first time in a power cycle, we know there\n    // will the following if condition will never be true any more.\n    mask = maskAll;\n\n    if (mask != mMask) {\n        if (RPC_LOC_CLIENT_HANDLE_INVALID != client_handle) {\n            close();\n        }\n\n        mMask = mask;\n        // it is important to cap the mask here, because not all LocApi's\n        // can enable the same bits, e.g. foreground and bckground.\n        client_handle = loc_open(convertMask(mask),\n                                 loc_event_cb,\n                                 loc_rpc_global_cb, this);\n\n        if (client_handle < 0) {\n            mMask = 0;\n            client_handle = RPC_LOC_CLIENT_HANDLE_INVALID;\n            ret_val = LOC_API_ADAPTER_ERR_INVALID_HANDLE;\n        }\n    }\n\n    return ret_val;\n}\n\nenum loc_api_adapter_err\nLocApiRpc::close()\n{\n    if (RPC_LOC_CLIENT_HANDLE_INVALID != client_handle) {\n        loc_clear(client_handle);\n    }\n\n    loc_close(client_handle);\n    mMask = 0;\n    client_handle = RPC_LOC_CLIENT_HANDLE_INVALID;\n\n    return LOC_API_ADAPTER_ERR_SUCCESS;\n}\n\nenum loc_api_adapter_err\nLocApiRpc::startFix(const LocPosMode& posMode) {\n   LOC_LOGD(\"LocApiRpc::startFix() called\");\n   return convertErr(\n       loc_start_fix(client_handle)\n       );\n}\n\nenum loc_api_adapter_err\nLocApiRpc::stopFix() {\n   LOC_LOGD(\"LocApiRpc::stopFix() called\");\n   return convertErr(\n       loc_stop_fix(client_handle)\n       );\n}\n\nenum loc_api_adapter_err\nLocApiRpc::setPositionMode(const LocPosMode& posMode)\n{\n    rpc_loc_ioctl_data_u_type    ioctl_data;\n    rpc_loc_fix_criteria_s_type *fix_criteria_ptr =\n        &ioctl_data.rpc_loc_ioctl_data_u_type_u.fix_criteria;\n    rpc_loc_ioctl_e_type         ioctl_type = RPC_LOC_IOCTL_SET_FIX_CRITERIA;\n    rpc_loc_operation_mode_e_type op_mode;\n    int                          ret_val;\n    const LocPosMode* fixCriteria = &posMode;\n\n    ALOGD (\"loc_eng_set_position mode, client = %d, interval = %d, mode = %d\\n\",\n          (int32) client_handle, fixCriteria->min_interval, fixCriteria->mode);\n\n    switch (fixCriteria->mode)\n    {\n    case LOC_POSITION_MODE_MS_BASED:\n        op_mode = RPC_LOC_OPER_MODE_MSB;\n        break;\n    case LOC_POSITION_MODE_MS_ASSISTED:\n        op_mode = RPC_LOC_OPER_MODE_MSA;\n        break;\n    case LOC_POSITION_MODE_RESERVED_1:\n        op_mode = RPC_LOC_OPER_MODE_SPEED_OPTIMAL;\n        break;\n    case LOC_POSITION_MODE_RESERVED_2:\n        op_mode = RPC_LOC_OPER_MODE_ACCURACY_OPTIMAL;\n        break;\n    case LOC_POSITION_MODE_RESERVED_3:\n        op_mode = RPC_LOC_OPER_MODE_DATA_OPTIMAL;\n        break;\n    case LOC_POSITION_MODE_RESERVED_4:\n    case LOC_POSITION_MODE_RESERVED_5:\n        op_mode = RPC_LOC_OPER_MODE_MSA;\n        fix_criteria_ptr->preferred_response_time  = 0;\n        break;\n    default:\n        op_mode = RPC_LOC_OPER_MODE_STANDALONE;\n    }\n\n    fix_criteria_ptr->valid_mask = RPC_LOC_FIX_CRIT_VALID_PREFERRED_OPERATION_MODE |\n                                   RPC_LOC_FIX_CRIT_VALID_RECURRENCE_TYPE;\n    fix_criteria_ptr->min_interval = fixCriteria->min_interval;\n    fix_criteria_ptr->preferred_operation_mode = op_mode;\n\n    fix_criteria_ptr->min_interval = fixCriteria->min_interval;\n    fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_MIN_INTERVAL;\n\n    if (fixCriteria->preferred_accuracy > 0) {\n        fix_criteria_ptr->preferred_accuracy = fixCriteria->preferred_accuracy;\n        fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_PREFERRED_ACCURACY;\n    }\n    if (fixCriteria->preferred_time > 0) {\n        fix_criteria_ptr->preferred_response_time = fixCriteria->preferred_time;\n        fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_PREFERRED_RESPONSE_TIME;\n    }\n\n    switch (fixCriteria->recurrence) {\n    case GPS_POSITION_RECURRENCE_SINGLE:\n        fix_criteria_ptr->recurrence_type = RPC_LOC_SINGLE_FIX;\n        break;\n    case GPS_POSITION_RECURRENCE_PERIODIC:\n    default:\n        fix_criteria_ptr->recurrence_type = RPC_LOC_PERIODIC_FIX;\n        break;\n    }\n    ioctl_data.disc = ioctl_type;\n\n    ret_val = loc_eng_ioctl (client_handle,\n                             ioctl_type,\n                             &ioctl_data,\n                             LOC_IOCTL_DEFAULT_TIMEOUT,\n                             NULL /* No output information is expected*/);\n\n    return convertErr(ret_val);\n}\n\nenum loc_api_adapter_err\nLocApiRpc::setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)\n{\n    rpc_loc_ioctl_data_u_type        ioctl_data;\n    rpc_loc_assist_data_time_s_type *time_info_ptr;\n    rpc_loc_ioctl_e_type             ioctl_type = RPC_LOC_IOCTL_INJECT_UTC_TIME;\n    int                              ret_val;\n\n    LOC_LOGD (\"loc_eng_inject_time, uncertainty = %d\\n\", uncertainty);\n\n    time_info_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.assistance_data_time;\n    time_info_ptr->time_utc = time;\n    time_info_ptr->time_utc += (int64_t)(ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION - timeReference);\n    time_info_ptr->uncertainty = uncertainty; // Uncertainty in ms\n\n    ioctl_data.disc = ioctl_type;\n\n    ret_val = loc_eng_ioctl (client_handle,\n                             ioctl_type,\n                             &ioctl_data,\n                             LOC_IOCTL_DEFAULT_TIMEOUT,\n                             NULL /* No output information is expected*/);\n\n    return convertErr(ret_val);\n}\n\nenum loc_api_adapter_err\nLocApiRpc::injectPosition(double latitude, double longitude, float accuracy)\n{\n    /* IOCTL data */\n    rpc_loc_ioctl_data_u_type ioctl_data;\n    rpc_loc_assist_data_pos_s_type *assistance_data_position =\n        &ioctl_data.rpc_loc_ioctl_data_u_type_u.assistance_data_position;\n    int                          ret_val;\n\n    /************************************************\n     * Fill in latitude, longitude & accuracy\n     ************************************************/\n\n    /* This combo is required */\n    assistance_data_position->valid_mask =\n        RPC_LOC_ASSIST_POS_VALID_LATITUDE |\n        RPC_LOC_ASSIST_POS_VALID_LONGITUDE |\n        RPC_LOC_ASSIST_POS_VALID_HOR_UNC_CIRCULAR |\n        RPC_LOC_ASSIST_POS_VALID_CONFIDENCE_HORIZONTAL;\n\n    assistance_data_position->latitude = latitude;\n    assistance_data_position->longitude = longitude;\n    assistance_data_position->hor_unc_circular = accuracy; /* Meters assumed */\n    assistance_data_position->confidence_horizontal = 63;  /* 63% (1 std dev) assumed */\n\n    /* Log */\n    LOC_LOGD(\"Inject coarse position Lat=%lf, Lon=%lf, Acc=%.2lf\\n\",\n             (double) assistance_data_position->latitude,\n             (double) assistance_data_position->longitude,\n             (double) assistance_data_position->hor_unc_circular);\n\n    ret_val = loc_eng_ioctl( client_handle,\n                             RPC_LOC_IOCTL_INJECT_POSITION,\n                             &ioctl_data,\n                             LOC_IOCTL_DEFAULT_TIMEOUT,\n                             NULL /* No output information is expected*/);\n    return convertErr(ret_val);\n}\n\nenum loc_api_adapter_err\nLocApiRpc::informNiResponse(GpsUserResponseType userResponse,\n                                   const void* passThroughData)\n{\n    rpc_loc_ioctl_data_u_type data;\n    rpc_loc_ioctl_callback_s_type callback_payload;\n\n    memcpy(&data.rpc_loc_ioctl_data_u_type_u.user_verify_resp.ni_event_pass_back,\n           passThroughData, sizeof (rpc_loc_ni_event_s_type));\n\n    rpc_loc_ni_user_resp_e_type resp;\n    switch (userResponse)\n    {\n    case GPS_NI_RESPONSE_ACCEPT:\n        data.rpc_loc_ioctl_data_u_type_u.user_verify_resp.user_resp =\n            RPC_LOC_NI_LCS_NOTIFY_VERIFY_ACCEPT;\n        break;\n    case GPS_NI_RESPONSE_DENY:\n        data.rpc_loc_ioctl_data_u_type_u.user_verify_resp.user_resp =\n            RPC_LOC_NI_LCS_NOTIFY_VERIFY_DENY;\n        break;\n    case GPS_NI_RESPONSE_NORESP:\n    default:\n        data.rpc_loc_ioctl_data_u_type_u.user_verify_resp.user_resp =\n            RPC_LOC_NI_LCS_NOTIFY_VERIFY_NORESP;\n        break;\n    }\n\n    return convertErr(\n        loc_eng_ioctl(client_handle,\n                      RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE,\n                      &data,\n                      LOC_IOCTL_DEFAULT_TIMEOUT,\n                      &callback_payload)\n        );\n}\n\nenum loc_api_adapter_err\nLocApiRpc::setAPN(char* apn, int len, boolean force)\n{\n    enum loc_api_adapter_err rtv = LOC_API_ADAPTER_ERR_SUCCESS;\n    int size = sizeof(apnLastSet);\n    if (force || memcmp(apnLastSet, apn, size)) {\n        if (len < size) {\n            // size will be not larger than its original value\n            size = len + 1;\n        }\n        memcpy(apnLastSet, apn, size);\n\n        if (!isInSession()) {\n            rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_LBS_APN_PROFILE, {0}};\n            ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].srv_system_type = LOC_APN_PROFILE_SRV_SYS_MAX;\n            ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].pdp_type = LOC_APN_PROFILE_PDN_TYPE_IPV4;\n            memcpy(&(ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].apn_name), apn, size);\n\n            rtv = convertErr(\n                loc_eng_ioctl (client_handle,\n                               RPC_LOC_IOCTL_SET_LBS_APN_PROFILE,\n                               &ioctl_data,\n                               LOC_IOCTL_DEFAULT_TIMEOUT,\n                               NULL)\n                );\n        }\n    }\n    return rtv;\n}\n\nvoid LocApiRpc::setInSession(bool inSession)\n{\n    if (!inSession) {\n        enableData(dataEnableLastSet, true);\n        setAPN(apnLastSet, sizeof(apnLastSet)-1, true);\n    }\n}\n\nenum loc_api_adapter_err\nLocApiRpc::setServer(const char* url, int len)\n{\n    rpc_loc_ioctl_data_u_type         ioctl_data;\n    rpc_loc_server_info_s_type       *server_info_ptr;\n    rpc_loc_ioctl_e_type              ioctl_cmd;\n\n    ioctl_cmd = RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR;\n    ioctl_data.disc = ioctl_cmd;\n    server_info_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.server_addr;\n    server_info_ptr->addr_type = RPC_LOC_SERVER_ADDR_URL;\n    server_info_ptr->addr_info.disc = server_info_ptr->addr_type;\n    server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.length = len;\n#if (AMSS_VERSION==3200)\n    server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr.addr_val = (char*) url;\n    server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr.addr_len= len;\n#else\n    strlcpy(server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr, url,\n            sizeof server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr);\n#endif /* #if (AMSS_VERSION==3200) */\n    LOC_LOGD (\"loc_eng_set_server, addr = %s\\n\", url);\n\n    return convertErr(\n        loc_eng_ioctl (client_handle,\n                       ioctl_cmd,\n                       &ioctl_data,\n                       LOC_IOCTL_DEFAULT_TIMEOUT,\n                       NULL /* No output information is expected*/)\n        );\n}\n\nenum loc_api_adapter_err\nLocApiRpc::setServer(unsigned int ip, int port, LocServerType type)\n{\n    rpc_loc_ioctl_data_u_type         ioctl_data;\n    rpc_loc_server_info_s_type       *server_info_ptr;\n    rpc_loc_ioctl_e_type              ioctl_cmd;\n\n    switch (type) {\n    case LOC_AGPS_MPC_SERVER:\n        ioctl_cmd = RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR;\n        break;\n    case LOC_AGPS_CUSTOM_PDE_SERVER:\n        ioctl_cmd = RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR;\n        break;\n    default:\n        ioctl_cmd = RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR;\n        break;\n    }\n    ioctl_data.disc = ioctl_cmd;\n    server_info_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.server_addr;\n    server_info_ptr->addr_type = RPC_LOC_SERVER_ADDR_IPV4;\n    server_info_ptr->addr_info.disc = server_info_ptr->addr_type;\n    server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.ipv4.addr = ip;\n    server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.ipv4.port = port;\n    LOC_LOGD (\"setServer, addr = %X:%d\\n\", (unsigned int) ip, (unsigned int) port);\n\n    return convertErr(\n        loc_eng_ioctl (client_handle,\n                       ioctl_cmd,\n                       &ioctl_data,\n                       LOC_IOCTL_DEFAULT_TIMEOUT,\n                       NULL /* No output information is expected*/)\n        );\n}\n\nenum loc_api_adapter_err\nLocApiRpc::enableData(int enable, boolean force)\n{\n    enum loc_api_adapter_err rtv = LOC_API_ADAPTER_ERR_SUCCESS;\n    if (force || dataEnableLastSet != enable) {\n        dataEnableLastSet = enable;\n\n        if (!isInSession()) {\n            rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_DATA_ENABLE, {0}};\n\n            ioctl_data.rpc_loc_ioctl_data_u_type_u.data_enable = enable;\n            rtv =  convertErr(\n                loc_eng_ioctl (client_handle,\n                               RPC_LOC_IOCTL_SET_DATA_ENABLE,\n                               &ioctl_data,\n                               LOC_IOCTL_DEFAULT_TIMEOUT,\n                               NULL)\n                );\n        }\n    }\n    return rtv;\n}\n\nenum loc_api_adapter_err\nLocApiRpc::deleteAidingData(GpsAidingData bits)\n{\n    rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_DELETE_ASSIST_DATA, {0}};\n    ioctl_data.rpc_loc_ioctl_data_u_type_u.assist_data_delete.type = bits;\n\n    return convertErr(\n        loc_eng_ioctl (client_handle,\n                       RPC_LOC_IOCTL_DELETE_ASSIST_DATA,\n                       &ioctl_data,\n                       LOC_IOCTL_DEFAULT_TIMEOUT,\n                       NULL)\n        );\n}\n\nvoid LocApiRpc::reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr)\n{\n    LocPosTechMask tech_Mask = LOC_POS_TECH_MASK_DEFAULT;\n\n    UlpLocation location = {0};\n    GpsLocationExtended locationExtended = {0};\n\n    location.size = sizeof(location);\n    locationExtended.size = sizeof(locationExtended);\n    if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SESSION_STATUS)\n    {\n        // Process the position from final and intermediate reports\n        if (location_report_ptr->session_status == RPC_LOC_SESS_STATUS_SUCCESS ||\n            location_report_ptr->session_status == RPC_LOC_SESS_STATUS_IN_PROGESS)\n        {\n            // Latitude & Longitude\n            if ((location_report_ptr->valid_mask & RPC_LOC_POS_VALID_LATITUDE) &&\n                (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_LONGITUDE) &&\n                (location_report_ptr->latitude != 0 ||\n                 location_report_ptr->longitude != 0))\n            {\n                location.gpsLocation.flags    |= GPS_LOCATION_HAS_LAT_LONG;\n                location.gpsLocation.latitude  = location_report_ptr->latitude;\n                location.gpsLocation.longitude = location_report_ptr->longitude;\n\n                // Time stamp (UTC)\n                if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_TIMESTAMP_UTC)\n                {\n                    location.gpsLocation.timestamp = location_report_ptr->timestamp_utc;\n                }\n\n                // Altitude\n                if (location_report_ptr->valid_mask &  RPC_LOC_POS_VALID_ALTITUDE_WRT_ELLIPSOID )\n                {\n                    location.gpsLocation.flags    |= GPS_LOCATION_HAS_ALTITUDE;\n                    location.gpsLocation.altitude = location_report_ptr->altitude_wrt_ellipsoid;\n                }\n\n                // Speed\n                if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SPEED_HORIZONTAL)\n                {\n                    location.gpsLocation.flags    |= GPS_LOCATION_HAS_SPEED;\n                    location.gpsLocation.speed = location_report_ptr->speed_horizontal;\n                }\n\n                // Heading\n                if (location_report_ptr->valid_mask &  RPC_LOC_POS_VALID_HEADING)\n                {\n                    location.gpsLocation.flags    |= GPS_LOCATION_HAS_BEARING;\n                    location.gpsLocation.bearing = location_report_ptr->heading;\n                }\n\n                // Uncertainty (circular)\n                if ( (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_HOR_UNC_CIRCULAR) )\n                {\n                    location.gpsLocation.flags    |= GPS_LOCATION_HAS_ACCURACY;\n                    location.gpsLocation.accuracy = location_report_ptr->hor_unc_circular;\n                }\n\n                // Technology Mask\n\n                tech_Mask  |= location_report_ptr->technology_mask;\n                //Mark the location source as from GNSS\n                location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO;\n                location.position_source = ULP_LOCATION_IS_FROM_GNSS;\n                if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL)\n                {\n                    locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL;\n                    locationExtended.altitudeMeanSeaLevel = location_report_ptr->altitude_wrt_mean_sea_level;\n                }\n\n                if (location_report_ptr->valid_mask &  RPC_LOC_POS_VALID_MAGNETIC_VARIATION )\n                {\n                    locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_MAG_DEV;\n                    locationExtended.magneticDeviation = location_report_ptr->magnetic_deviation;\n                }\n\n                if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_VERTICAL_UNC)\n                {\n                   locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_VERT_UNC;\n                   locationExtended.vert_unc = location_report_ptr->vert_unc;\n                }\n\n                if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SPEED_UNC)\n                {\n                   locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_SPEED_UNC;\n                   locationExtended.speed_unc = location_report_ptr->speed_unc;\n                }\n\n                LOC_LOGV(\"reportPosition: fire callback\\n\");\n                enum loc_sess_status fixStatus =\n                    (location_report_ptr->session_status\n                     == RPC_LOC_SESS_STATUS_IN_PROGESS ?\n                     LOC_SESS_INTERMEDIATE : LOC_SESS_SUCCESS);\n                LocApiBase::reportPosition(location,\n                                           locationExtended,\n                                           (void*)location_report_ptr,\n                                           fixStatus,\n                                           tech_Mask);\n            }\n        }\n        else\n        {\n            LocApiBase::reportPosition(location,\n                                       locationExtended,\n                                       NULL,\n                                       LOC_SESS_FAILURE);\n            LOC_LOGV(\"loc_eng_report_position: ignore position report \"\n                     \"when session status = %d\\n\",\n                     location_report_ptr->session_status);\n        }\n    }\n    else\n    {\n        LOC_LOGV(\"loc_eng_report_position: ignore position report \"\n                 \"when session status is not set\\n\");\n    }\n}\n\nvoid LocApiRpc::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr)\n{\n    GnssSvStatus     SvStatus = {0};\n    GpsLocationExtended locationExtended = {0};\n    locationExtended.size = sizeof(locationExtended);\n    int             num_svs_max = 0;\n    const rpc_loc_sv_info_s_type *sv_info_ptr;\n\n    if (gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_COUNT)\n    {\n        num_svs_max = gnss_report_ptr->sv_count;\n        if (num_svs_max > GPS_MAX_SVS)\n        {\n            num_svs_max = GPS_MAX_SVS;\n        }\n    }\n\n    if (gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_LIST)\n    {\n        SvStatus.num_svs = 0;\n\n        for (int i = 0; i < num_svs_max; i++)\n        {\n            sv_info_ptr = &(gnss_report_ptr->sv_list.sv_list_val[i]);\n            if (sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_SYSTEM)\n            {\n                if (sv_info_ptr->system == RPC_LOC_SV_SYSTEM_GPS)\n                {\n                    SvStatus.sv_list[SvStatus.num_svs].size = sizeof(GpsSvInfo);\n                    SvStatus.sv_list[SvStatus.num_svs].prn = sv_info_ptr->prn;\n\n                    // We only have the data field to report gps eph and alm mask\n                    if ((sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_HAS_EPH) &&\n                        (sv_info_ptr->has_eph == 1))\n                    {\n                        SvStatus.ephemeris_mask |= (1 << (sv_info_ptr->prn-1));\n                    }\n\n                    if ((sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_HAS_ALM) &&\n                        (sv_info_ptr->has_alm == 1))\n                    {\n                        SvStatus.almanac_mask |= (1 << (sv_info_ptr->prn-1));\n                    }\n\n                    if ((sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_PROCESS_STATUS) &&\n                        (sv_info_ptr->process_status == RPC_LOC_SV_STATUS_TRACK))\n                    {\n                        SvStatus.gps_used_in_fix_mask |= (1 << (sv_info_ptr->prn-1));\n                    }\n                }\n                // SBAS: GPS RPN: 120-151,\n                // In exteneded measurement report, we follow nmea standard, which is from 33-64.\n                else if (sv_info_ptr->system == RPC_LOC_SV_SYSTEM_SBAS)\n                {\n                    SvStatus.sv_list[SvStatus.num_svs].prn = sv_info_ptr->prn + 33 - 120;\n                }\n                // Gloness: Slot id: 1-32\n                // In extended measurement report, we follow nmea standard, which is 65-96\n                else if (sv_info_ptr->system == RPC_LOC_SV_SYSTEM_GLONASS)\n                {\n                    if ((sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_PROCESS_STATUS) &&\n                        (sv_info_ptr->process_status == RPC_LOC_SV_STATUS_TRACK))\n                    {\n                        SvStatus.glo_used_in_fix_mask |= (1 << (sv_info_ptr->prn-1));\n                    }\n\n                    SvStatus.sv_list[SvStatus.num_svs].prn = sv_info_ptr->prn + (65-1);\n                }\n                // Unsupported SV system\n                else\n                {\n                    continue;\n                }\n            }\n\n            if (sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_SNR)\n            {\n                SvStatus.sv_list[SvStatus.num_svs].snr = sv_info_ptr->snr;\n            }\n\n            if (sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_ELEVATION)\n            {\n                SvStatus.sv_list[SvStatus.num_svs].elevation = sv_info_ptr->elevation;\n            }\n\n            if (sv_info_ptr->valid_mask & RPC_LOC_SV_INFO_VALID_AZIMUTH)\n            {\n                SvStatus.sv_list[SvStatus.num_svs].azimuth = sv_info_ptr->azimuth;\n            }\n\n            SvStatus.num_svs++;\n        }\n    }\n\n    if ((gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_POS_DOP) &&\n        (gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_HOR_DOP) &&\n        (gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_VERT_DOP))\n    {\n        locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_DOP;\n        locationExtended.pdop = gnss_report_ptr->position_dop;\n        locationExtended.hdop = gnss_report_ptr->horizontal_dop;\n        locationExtended.vdop = gnss_report_ptr->vertical_dop;\n    }\n\n    if (SvStatus.num_svs >= 0)\n    {\n        LocApiBase::reportSv(SvStatus,\n                             locationExtended,\n                             (void*)gnss_report_ptr);\n    }\n}\n\nvoid LocApiRpc::reportStatus(const rpc_loc_status_event_s_type *status_report_ptr)\n{\n\n    if (status_report_ptr->event == RPC_LOC_STATUS_EVENT_ENGINE_STATE) {\n        if (status_report_ptr->payload.rpc_loc_status_event_payload_u_type_u.engine_state == RPC_LOC_ENGINE_STATE_ON)\n        {\n            LocApiBase::reportStatus(GPS_STATUS_ENGINE_ON);\n            LocApiBase::reportStatus(GPS_STATUS_SESSION_BEGIN);\n        }\n        else if (status_report_ptr->payload.rpc_loc_status_event_payload_u_type_u.engine_state == RPC_LOC_ENGINE_STATE_OFF)\n        {\n            LocApiBase::reportStatus(GPS_STATUS_SESSION_END);\n            LocApiBase::reportStatus(GPS_STATUS_ENGINE_OFF);\n        }\n        else\n        {\n            LocApiBase::reportStatus(GPS_STATUS_NONE);\n        }\n    }\n\n}\n\nvoid LocApiRpc::reportNmea(const rpc_loc_nmea_report_s_type *nmea_report_ptr)\n{\n\n#if (AMSS_VERSION==3200)\n    LocApiBase::reportNmea(nmea_report_ptr->nmea_sentences.nmea_sentences_val,\n                           nmea_report_ptr->nmea_sentences.nmea_sentences_len);\n#else\n    LocApiBase::reportNmea(nmea_report_ptr->nmea_sentences,\n                           nmea_report_ptr->length);\n    LOC_LOGD(\"loc_eng_report_nmea: $%c%c%c\\n\",\n             nmea_report_ptr->nmea_sentences[3],\n             nmea_report_ptr->nmea_sentences[4],\n             nmea_report_ptr->nmea_sentences[5]);\n#endif /* #if (AMSS_VERSION==3200) */\n}\n\nenum loc_api_adapter_err\nLocApiRpc::setXtraData(char* data, int length)\n{\n    int     rpc_ret_val = RPC_LOC_API_GENERAL_FAILURE;\n    int     total_parts;\n    uint8   part;\n    uint16  part_len;\n    uint16  len_injected;\n    rpc_loc_ioctl_data_u_type            ioctl_data;\n    rpc_loc_ioctl_e_type                 ioctl_type = RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA;\n    rpc_loc_predicted_orbits_data_s_type *predicted_orbits_data_ptr;\n\n    LOC_LOGD(\"qct_loc_eng_inject_xtra_data, xtra size = %d, data ptr = 0x%lx\\n\", length, (long) data);\n\n    predicted_orbits_data_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.predicted_orbits_data;\n    predicted_orbits_data_ptr->format_type = RPC_LOC_PREDICTED_ORBITS_XTRA;\n    predicted_orbits_data_ptr->total_size = length;\n    total_parts = (length - 1) / XTRA_BLOCK_SIZE + 1;\n    predicted_orbits_data_ptr->total_parts = total_parts;\n\n    len_injected = 0; // O bytes injected\n    ioctl_data.disc = ioctl_type;\n\n    // XTRA injection starts with part 1\n    for (part = 1; part <= total_parts; part++)\n    {\n        predicted_orbits_data_ptr->part = part;\n        predicted_orbits_data_ptr->part_len = XTRA_BLOCK_SIZE;\n        if (XTRA_BLOCK_SIZE > (length - len_injected))\n        {\n            predicted_orbits_data_ptr->part_len = length - len_injected;\n        }\n        predicted_orbits_data_ptr->data_ptr.data_ptr_len = predicted_orbits_data_ptr->part_len;\n        predicted_orbits_data_ptr->data_ptr.data_ptr_val = data + len_injected;\n\n        LOC_LOGD(\"qct_loc_eng_inject_xtra_data, part %d/%d, len = %d, total = %d\\n\",\n                 predicted_orbits_data_ptr->part,\n                 total_parts,\n                 predicted_orbits_data_ptr->part_len,\n                 len_injected);\n\n        if (part < total_parts)\n        {\n            // No callback in this case\n            rpc_ret_val = loc_ioctl (client_handle,\n                                     ioctl_type,\n                                     &ioctl_data);\n\n            if (rpc_ret_val != RPC_LOC_API_SUCCESS)\n            {\n                LOC_LOGE(\"loc_ioctl for xtra error: %s\\n\", loc_get_ioctl_status_name(rpc_ret_val));\n                break;\n            }\n            //Add a delay of 10 ms so that repeated RPC calls dont starve the modem processor\n            usleep(10 * 1000);\n        }\n        else // part == total_parts\n        {\n            // Last part injection, will need to wait for callback\n            if (!loc_eng_ioctl(client_handle,\n                               ioctl_type,\n                               &ioctl_data,\n                               LOC_XTRA_INJECT_DEFAULT_TIMEOUT,\n                               NULL))\n            {\n                rpc_ret_val = RPC_LOC_API_GENERAL_FAILURE;\n            }\n            break; // done with injection\n        }\n\n        len_injected += predicted_orbits_data_ptr->part_len;\n        LOC_LOGD(\"loc_ioctl XTRA injected length: %d\\n\", len_injected);\n    }\n\n    return convertErr(rpc_ret_val);\n}\n\n/* Request the Xtra Server Url from the modem */\nenum loc_api_adapter_err\nLocApiRpc::requestXtraServer()\n{\n    loc_api_adapter_err           err;\n    rpc_loc_ioctl_data_u_type     data;\n    rpc_loc_ioctl_callback_s_type callback_data;\n\n    err = convertErr(loc_eng_ioctl(client_handle,\n                                   RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE,\n                                   &data,\n                                   LOC_IOCTL_DEFAULT_TIMEOUT,\n                                   &callback_data));\n\n    if (LOC_API_ADAPTER_ERR_SUCCESS != err)\n    {\n        LOC_LOGE(\"RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE failed!: err=%d\\n\", err);\n        return err;\n    }\n    else if (RPC_LOC_SESS_STATUS_SUCCESS != callback_data.status)\n    {\n        LOC_LOGE(\"RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE failed!: status=%ld\\n\", callback_data.status);\n        return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;\n    }\n    else if (RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE != callback_data.type)\n    {\n        LOC_LOGE(\"RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE is not the type expected! type=%d\\n\", callback_data.type);\n        return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;\n    }\n    else if (RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE != callback_data.data.disc)\n    {\n        LOC_LOGE(\"RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE is not the disc expected! disc=%d\\n\", callback_data.data.disc);\n        return LOC_API_ADAPTER_ERR_GENERAL_FAILURE;\n    }\n\n    reportXtraServer(callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.\n                     predicted_orbits_data_source.servers[0],\n                     callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.\n                     predicted_orbits_data_source.servers[1],\n                     callback_data.data.rpc_loc_ioctl_callback_data_u_type_u.\n                     predicted_orbits_data_source.servers[2],\n                     255);\n\n    return LOC_API_ADAPTER_ERR_SUCCESS;\n}\n\nenum loc_api_adapter_err\nLocApiRpc::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType)\n{\n    rpc_loc_server_open_status_e_type open_status = is_succ ? RPC_LOC_SERVER_OPEN_SUCCESS : RPC_LOC_SERVER_OPEN_FAIL;\n   rpc_loc_ioctl_data_u_type           ioctl_data;\n\n    if (AGPS_TYPE_INVALID == agpsType) {\n        rpc_loc_server_open_status_s_type  *conn_open_status_ptr =\n            &ioctl_data.rpc_loc_ioctl_data_u_type_u.conn_open_status;\n\n        // Fill in data\n        ioctl_data.disc = RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS;\n        conn_open_status_ptr->conn_handle = handle;\n        conn_open_status_ptr->open_status = open_status;\n#if (AMSS_VERSION==3200)\n        conn_open_status_ptr->apn_name = apn; /* requires APN */\n#else\n        if (is_succ) {\n            strlcpy(conn_open_status_ptr->apn_name, apn,\n                    sizeof conn_open_status_ptr->apn_name);\n        } else {\n            conn_open_status_ptr->apn_name[0] = 0;\n        }\n#endif /* #if (AMSS_VERSION==3200) */\n\n        LOC_LOGD(\"ATL RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS open %s, APN name = [%s]\\n\",\n                 log_succ_fail_string(is_succ),\n                 apn);\n    } else {\n        rpc_loc_server_multi_open_status_s_type  *conn_multi_open_status_ptr =\n            &ioctl_data.rpc_loc_ioctl_data_u_type_u.multi_conn_open_status;\n\n        // Fill in data\n        ioctl_data.disc = RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS;\n        conn_multi_open_status_ptr->conn_handle = handle;\n        conn_multi_open_status_ptr->open_status = open_status;\n        if (is_succ) {\n            strlcpy(conn_multi_open_status_ptr->apn_name, apn,\n                    sizeof conn_multi_open_status_ptr->apn_name);\n        } else {\n            conn_multi_open_status_ptr->apn_name[0] = 0;\n        }\n\n        switch(bearer)\n        {\n        case AGPS_APN_BEARER_IPV4:\n            conn_multi_open_status_ptr->pdp_type = RPC_LOC_SERVER_PDP_IP;\n            break;\n        case AGPS_APN_BEARER_IPV6:\n            conn_multi_open_status_ptr->pdp_type = RPC_LOC_SERVER_PDP_IPV6;\n            break;\n        case AGPS_APN_BEARER_IPV4V6:\n            conn_multi_open_status_ptr->pdp_type = RPC_LOC_SERVER_PDP_IPV4V6;\n            break;\n        default:\n            conn_multi_open_status_ptr->pdp_type = RPC_LOC_SERVER_PDP_PPP;\n        }\n\n        LOC_LOGD(\"ATL RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS open %s, APN name = [%s], pdp_type = %d\\n\",\n                 log_succ_fail_string(is_succ),\n                 apn,\n                 conn_multi_open_status_ptr->pdp_type);\n    }\n\n    // Make the IOCTL call\n    return convertErr(\n        loc_eng_ioctl(client_handle,\n                      ioctl_data.disc,\n                      &ioctl_data,\n                      LOC_IOCTL_DEFAULT_TIMEOUT,\n                      NULL)\n        );\n}\n\nenum loc_api_adapter_err\nLocApiRpc::atlCloseStatus(int handle, int is_succ)\n{\n    rpc_loc_ioctl_data_u_type           ioctl_data;\n    ioctl_data.disc = RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS;\n\n    rpc_loc_server_close_status_s_type *conn_close_status_ptr =\n        &ioctl_data.rpc_loc_ioctl_data_u_type_u.conn_close_status;\n    conn_close_status_ptr->conn_handle = handle;\n    conn_close_status_ptr->close_status = is_succ ? RPC_LOC_SERVER_CLOSE_SUCCESS : RPC_LOC_SERVER_CLOSE_FAIL;\n\n    // Make the IOCTL call\n    return convertErr(\n        loc_eng_ioctl(client_handle,\n                      ioctl_data.disc,\n                      &ioctl_data,\n                      LOC_IOCTL_DEFAULT_TIMEOUT,\n                      NULL)\n        );\n}\n\nvoid LocApiRpc::ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr)\n{\n    int connHandle;\n    AGpsType agps_type;\n\n    LOC_LOGV(\"RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST event %s)\",\n             loc_get_event_atl_open_name(server_request_ptr->event));\n    switch (server_request_ptr->event)\n    {\n    case RPC_LOC_SERVER_REQUEST_MULTI_OPEN:\n        connHandle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.multi_open_req.conn_handle;\n        if (server_request_ptr->payload.rpc_loc_server_request_u_type_u.multi_open_req.connection_type\n            == RPC_LOC_SERVER_CONNECTION_LBS) {\n            agps_type = AGPS_TYPE_SUPL;\n            LOC_LOGV(\"ATLEvent: event - RPC_LOC_SERVER_REQUEST_MULTI_OPEN\\n            type - AGPS_TYPE_SUPL\\n            handle - %d\", connHandle);\n        } else {\n            agps_type = AGPS_TYPE_WWAN_ANY;\n            LOC_LOGV(\"ATLEvent: event - RPC_LOC_SERVER_REQUEST_MULTI_OPEN\\n            type - AGPS_TYPE_WWAN_ANY\\n            handle - %d\", connHandle);\n        }\n        requestATL(connHandle, agps_type);\n        break;\n    case RPC_LOC_SERVER_REQUEST_OPEN:\n        connHandle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.open_req.conn_handle;\n        LOC_LOGV(\"ATLEvent: event - RPC_LOC_SERVER_REQUEST_OPEN\\n            handle - %d\", connHandle);\n        requestATL(connHandle, AGPS_TYPE_INVALID);\n        break;\n    case RPC_LOC_SERVER_REQUEST_CLOSE:\n        connHandle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.close_req.conn_handle;\n        LOC_LOGV(\"ATLEvent: event - RPC_LOC_SERVER_REQUEST_CLOSE\\n            handle - %d\", connHandle);\n        releaseATL(connHandle);\n        break;\n    default:\n        LOC_LOGE(\"ATLEvent: event type %d invalid\", server_request_ptr->event);\n   }\n}\n\nvoid LocApiRpc::NIEvent(const rpc_loc_ni_event_s_type *ni_req)\n{\n    GpsNiNotification notif = {0};\n\n    switch (ni_req->event)\n    {\n    case RPC_LOC_NI_EVENT_VX_NOTIFY_VERIFY_REQ:\n    {\n        const rpc_loc_ni_vx_notify_verify_req_s_type *vx_req =\n            &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.vx_req;\n        LOC_LOGI(\"VX Notification\");\n        notif.ni_type = GPS_NI_TYPE_VOICE;\n        // Requestor ID\n        hexcode(notif.requestor_id, sizeof notif.requestor_id,\n                vx_req->requester_id.requester_id,\n                vx_req->requester_id.requester_id_length);\n        notif.text_encoding = 0; // No text and no encoding\n        notif.requestor_id_encoding = convertNiEncodingType(vx_req->encoding_scheme);\n        NIEventFillVerfiyType(notif, vx_req->notification_priv_type);\n    }\n        break;\n\n    case RPC_LOC_NI_EVENT_UMTS_CP_NOTIFY_VERIFY_REQ:\n    {\n        const rpc_loc_ni_umts_cp_notify_verify_req_s_type *umts_cp_req =\n            &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.umts_cp_req;\n        LOC_LOGI(\"UMTS CP Notification\\n\");\n        notif.ni_type= GPS_NI_TYPE_UMTS_CTRL_PLANE;         // Stores notification text\n#if (AMSS_VERSION==3200)\n        hexcode(notif.text, sizeof notif.text,\n                umts_cp_req->notification_text.notification_text_val,\n                umts_cp_req->notification_length);\n        hexcode(notif.requestor_id, sizeof notif.requestor_id,\n                umts_cp_req->requestor_id.requestor_id_string.requestor_id_string_val,\n                umts_cp_req->requestor_id.string_len);\n#else\n        hexcode(notif.text, sizeof notif.text,\n                umts_cp_req->notification_text,\n                umts_cp_req->notification_length);\n        hexcode(notif.requestor_id, sizeof notif.requestor_id,\n                umts_cp_req->requestor_id.requestor_id_string,\n                umts_cp_req->requestor_id.string_len);\n#endif\n        notif.text_encoding = convertNiEncodingType(umts_cp_req->datacoding_scheme);\n        notif.requestor_id_encoding = notif.text_encoding;\n        NIEventFillVerfiyType(notif, umts_cp_req->notification_priv_type);\n\n        // LCS address (using extras field)\n        if (umts_cp_req->ext_client_address_data.ext_client_address_len != 0)\n        {\n            // Copy LCS Address into notif.extras in the format: Address = 012345\n            strlcat(notif.extras, LOC_NI_NOTIF_KEY_ADDRESS, sizeof notif.extras);\n            strlcat(notif.extras, \" = \", sizeof notif.extras);\n            int addr_len = 0;\n            const char *address_source = NULL;\n\n#if (AMSS_VERSION==3200)\n            address_source = umts_cp_req->ext_client_address_data.ext_client_address.ext_client_address_val;\n#else\n            address_source = umts_cp_req->ext_client_address_data.ext_client_address;\n#endif /* #if (AMSS_VERSION==3200) */\n\n            char lcs_addr[32]; // Decoded LCS address for UMTS CP NI\n            addr_len = decodeAddress(lcs_addr, sizeof lcs_addr, address_source,\n                                     umts_cp_req->ext_client_address_data.ext_client_address_len);\n\n            // The address is ASCII string\n            if (addr_len)\n            {\n                strlcat(notif.extras, lcs_addr, sizeof notif.extras);\n            }\n        }\n    }\n        break;\n\n    case RPC_LOC_NI_EVENT_SUPL_NOTIFY_VERIFY_REQ:\n    {\n        const rpc_loc_ni_supl_notify_verify_req_s_type *supl_req =\n            &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.supl_req;\n        LOC_LOGI(\"SUPL Notification\\n\");\n        notif.ni_type = GPS_NI_TYPE_UMTS_SUPL;\n\n        if (supl_req->flags & RPC_LOC_NI_CLIENT_NAME_PRESENT)\n        {\n#if (AMSS_VERSION==3200)\n            hexcode(notif.text, sizeof notif.text,\n                    supl_req->client_name.client_name_string.client_name_string_val,   /* buffer */\n                    supl_req->client_name.string_len                                   /* length */\n            );\n#else\n            hexcode(notif.text, sizeof notif.text,\n                            supl_req->client_name.client_name_string,   /* buffer */\n                            supl_req->client_name.string_len            /* length */\n            );\n#endif /* #if (AMSS_VERSION==3200) */\n            LOC_LOGV(\"SUPL NI: client_name: %s len=%d\", notif.text, supl_req->client_name.string_len);\n        }\n        else {\n            LOC_LOGV(\"SUPL NI: client_name not present.\");\n        }\n\n        // Requestor ID\n        if (supl_req->flags & RPC_LOC_NI_REQUESTOR_ID_PRESENT)\n        {\n#if (AMSS_VERSION==3200)\n            hexcode(notif.requestor_id, sizeof notif.requestor_id,\n                    supl_req->requestor_id.requestor_id_string.requestor_id_string_val,  /* buffer */\n                    supl_req->requestor_id.string_len                                    /* length */\n                );\n#else\n            hexcode(notif.requestor_id, sizeof notif.requestor_id,\n                    supl_req->requestor_id.requestor_id_string,  /* buffer */\n                    supl_req->requestor_id.string_len            /* length */\n                );\n#endif /* #if (AMSS_VERSION==3200) */\n            LOC_LOGV(\"SUPL NI: requestor_id: %s len=%d\", notif.requestor_id, supl_req->requestor_id.string_len);\n        }\n        else {\n            LOC_LOGV(\"SUPL NI: requestor_id not present.\");\n        }\n\n        // Encoding type\n        if (supl_req->flags & RPC_LOC_NI_ENCODING_TYPE_PRESENT)\n        {\n            notif.text_encoding = convertNiEncodingType(supl_req->datacoding_scheme);\n            notif.requestor_id_encoding = notif.text_encoding;\n        }\n        else {\n            notif.text_encoding = notif.requestor_id_encoding = GPS_ENC_UNKNOWN;\n        }\n\n        NIEventFillVerfiyType(notif, ni_req->payload.rpc_loc_ni_event_payload_u_type_u.supl_req.notification_priv_type);\n    }\n        break;\n\n    default:\n        LOC_LOGE(\"Unknown NI event: %x\\n\", (int) ni_req->event);\n        return;\n    }\n\n    // this copy will get freed in loc_eng_ni when loc_ni_respond() is called\n    rpc_loc_ni_event_s_type *copy = (rpc_loc_ni_event_s_type *)malloc(sizeof(*copy));\n    memcpy(copy, ni_req, sizeof(*copy));\n    requestNiNotify(notif, (const void*)copy);\n}\n\nint LocApiRpc::NIEventFillVerfiyType(GpsNiNotification &notif,\n                                rpc_loc_ni_notify_verify_e_type notif_priv)\n{\n   switch (notif_priv)\n   {\n   case RPC_LOC_NI_USER_NO_NOTIFY_NO_VERIFY:\n       notif.notify_flags = 0;\n       notif.default_response = GPS_NI_RESPONSE_NORESP;\n       return 1;\n   case RPC_LOC_NI_USER_NOTIFY_ONLY:\n       notif.notify_flags = GPS_NI_NEED_NOTIFY;\n       notif.default_response = GPS_NI_RESPONSE_NORESP;\n       return 1;\n   case RPC_LOC_NI_USER_NOTIFY_VERIFY_ALLOW_NO_RESP:\n       notif.notify_flags = GPS_NI_NEED_NOTIFY | GPS_NI_NEED_VERIFY;\n       notif.default_response = GPS_NI_RESPONSE_ACCEPT;\n       return 1;\n   case RPC_LOC_NI_USER_NOTIFY_VERIFY_NOT_ALLOW_NO_RESP:\n       notif.notify_flags = GPS_NI_NEED_NOTIFY | GPS_NI_NEED_VERIFY;\n       notif.default_response = GPS_NI_RESPONSE_DENY;\n       return 1;\n   case RPC_LOC_NI_USER_PRIVACY_OVERRIDE:\n       notif.notify_flags = GPS_NI_PRIVACY_OVERRIDE;\n       notif.default_response = GPS_NI_RESPONSE_NORESP;\n       return 1;\n   default:\n      return 0;\n   }\n}\n\nenum loc_api_adapter_err\nLocApiRpc::setSUPLVersion(uint32_t version)\n{\n   rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_SUPL_VERSION, {0}};\n   ioctl_data.rpc_loc_ioctl_data_u_type_u.supl_version = (int)version;\n   return convertErr(\n       loc_eng_ioctl (client_handle,\n                      RPC_LOC_IOCTL_SET_SUPL_VERSION,\n                      &ioctl_data,\n                      LOC_IOCTL_DEFAULT_TIMEOUT,\n                      NULL)\n       );\n}\n\nGpsNiEncodingType LocApiRpc::convertNiEncodingType(int loc_encoding)\n{\n   switch (loc_encoding)\n   {\n   case RPC_LOC_NI_SUPL_UTF8:\n       return GPS_ENC_SUPL_UTF8;\n   case RPC_LOC_NI_SUPL_UCS2:\n       return GPS_ENC_SUPL_UCS2;\n   case RPC_LOC_NI_SUPL_GSM_DEFAULT:\n      return GPS_ENC_SUPL_GSM_DEFAULT;\n   case RPC_LOC_NI_SS_LANGUAGE_UNSPEC:\n      return GPS_ENC_SUPL_GSM_DEFAULT; // SS_LANGUAGE_UNSPEC = GSM\n   default:\n       return GPS_ENC_UNKNOWN;\n   }\n}\n\nLocApiBase* getLocApi(const MsgTask* msgTask,\n                      LOC_API_ADAPTER_EVENT_MASK_T exMask,\n                      ContextBase *context) {\n    return new LocApiRpc(msgTask, exMask, context);\n}\n\n/*Values for lock\n  1 = Do not lock any position sessions\n  2 = Lock MI position sessions\n  3 = Lock MT position sessions\n  4 = Lock all position sessions\n*/\nint LocApiRpc::setGpsLock(LOC_GPS_LOCK_MASK lockMask)\n{\n    rpc_loc_ioctl_data_u_type    ioctl_data;\n    boolean ret_val;\n    LOC_LOGD(\"%s:%d]: lock: %x\\n\", __func__, __LINE__, lockMask);\n    ioctl_data.rpc_loc_ioctl_data_u_type_u.engine_lock = convertGpsLockMask(lockMask);\n    ioctl_data.disc = RPC_LOC_IOCTL_SET_ENGINE_LOCK;\n    ret_val = loc_eng_ioctl (loc_eng_data.client_handle,\n                            RPC_LOC_IOCTL_SET_ENGINE_LOCK,\n                            &ioctl_data,\n                            LOC_IOCTL_DEFAULT_TIMEOUT,\n                            NULL /* No output information is expected*/);\n\n    LOC_LOGD(\"%s:%d]: ret_val: %d\\n\", __func__, __LINE__, (int)ret_val);\n    return (ret_val == TRUE ? 0 : -1);\n}\n\n/*\n  Returns\n  Current value of GPS lock on success\n  -1 on failure\n*/\nint LocApiRpc :: getGpsLock()\n{\n    rpc_loc_ioctl_data_u_type    ioctl_data;\n    rpc_loc_ioctl_callback_s_type callback_payload;\n    boolean ret_val;\n    int ret=0;\n    LOC_LOGD(\"%s:%d]: Enter\\n\", __func__, __LINE__);\n    ret_val = loc_eng_ioctl (loc_eng_data.client_handle,\n                            RPC_LOC_IOCTL_GET_ENGINE_LOCK,\n                            &ioctl_data,\n                            LOC_IOCTL_DEFAULT_TIMEOUT,\n                            &callback_payload);\n    if(ret_val == TRUE) {\n        ret = (int)callback_payload.data.engine_lock;\n        LOC_LOGD(\"%s:%d]: Lock type: %d\\n\", __func__, __LINE__, ret);\n    }\n    else {\n        LOC_LOGE(\"%s:%d]: Ioctl failed\", __func__, __LINE__);\n        ret = -1;\n    }\n    LOC_LOGD(\"%s:%d]: Exit\\n\", __func__, __LINE__);\n    return ret;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_fixup.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include <rpc/rpc.h>\n\n#include \"loc_api_fixup.h\"\n\n#ifdef ADD_XDR_FLOAT\n\nint\nxdr_float(xdrp, fp)\n        XDR *xdrp;\n        float *fp;\n{\n        return xdr_long(xdrp, (long*)fp);\n}\n\nint\nxdr_double(xdrp, dp)\n        XDR *xdrp;\n        double *dp;\n{\n                return xdr_long(xdrp, (long*)dp + 1)\n                                && xdr_long(xdrp, (long*)dp);\n}\n\n#endif /* ADD_XDR_FLOAT */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_log.c",
    "content": "/* Copyright (c) 2011 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_api_rpc_glue\"\n\n#include \"loc_api_log.h\"\n#include \"loc_log.h\"\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n#include \"rpc/rpc.h\"\n#include \"loc_api_fixup.h\"\n\n/* Event names */\nloc_name_val_s_type loc_event_name[] =\n   {\n      NAME_VAL( RPC_LOC_EVENT_PARSED_POSITION_REPORT ),\n      NAME_VAL( RPC_LOC_EVENT_SATELLITE_REPORT ),\n      NAME_VAL( RPC_LOC_EVENT_NMEA_1HZ_REPORT ),\n      NAME_VAL( RPC_LOC_EVENT_NMEA_POSITION_REPORT ),\n      NAME_VAL( RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST ),\n      NAME_VAL( RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST ),\n      NAME_VAL( RPC_LOC_EVENT_LOCATION_SERVER_REQUEST ),\n      NAME_VAL( RPC_LOC_EVENT_IOCTL_REPORT ),\n      NAME_VAL( RPC_LOC_EVENT_STATUS_REPORT ),\n      NAME_VAL( RPC_LOC_EVENT_WPS_NEEDED_REQUEST ),\n   };\nint loc_event_num = sizeof loc_event_name / sizeof(loc_name_val_s_type);\n\n/* Event names */\nloc_name_val_s_type loc_event_atl_open_name[] =\n   {\n      NAME_VAL( RPC_LOC_SERVER_REQUEST_OPEN ),\n      NAME_VAL( RPC_LOC_SERVER_REQUEST_CLOSE ),\n      NAME_VAL( RPC_LOC_SERVER_REQUEST_MULTI_OPEN )\n   };\nint loc_event_atl_open_num = sizeof loc_event_atl_open_name / sizeof(loc_name_val_s_type);\n\n/* Finds the first event found in the mask */\nconst char* loc_get_event_atl_open_name(rpc_loc_server_request_e_type loc_event_atl_open)\n{\n   return loc_get_name_from_val(loc_event_atl_open_name, loc_event_atl_open_num,\n         (long) loc_event_atl_open);\n}\n\n/* IOCTL Type names */\nloc_name_val_s_type loc_ioctl_type_name[] =\n   {\n      NAME_VAL( RPC_LOC_IOCTL_GET_API_VERSION ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_FIX_CRITERIA ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_FIX_CRITERIA ),\n      NAME_VAL( RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE ),\n      NAME_VAL( RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA ),\n      NAME_VAL( RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY ),\n      NAME_VAL( RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD ),\n      NAME_VAL( RPC_LOC_IOCTL_INJECT_UTC_TIME ),\n      NAME_VAL( RPC_LOC_IOCTL_INJECT_RTC_VALUE ),\n      NAME_VAL( RPC_LOC_IOCTL_INJECT_POSITION ),\n      NAME_VAL( RPC_LOC_IOCTL_QUERY_ENGINE_STATE ),\n      NAME_VAL( RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG),\n      NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS ),\n      NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS ),\n      NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS ),\n      NAME_VAL( RPC_LOC_IOCTL_SEND_WIPER_POSITION_REPORT ),\n      NAME_VAL( RPC_LOC_IOCTL_NOTIFY_WIPER_STATUS ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_ENGINE_LOCK ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_ENGINE_LOCK ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_SBAS_CONFIG ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_SBAS_CONFIG ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_NMEA_TYPES ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_NMEA_TYPES ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_ON_DEMAND_LPM ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_ON_DEMAND_LPM ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_LBS_APN_PROFILE ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_LBS_APN_PROFILE ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_DATA_ENABLE ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_SUPL_VERSION ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_SUPL_VERSION ),\n      NAME_VAL( RPC_LOC_IOCTL_DELETE_ASSIST_DATA ),\n      NAME_VAL( RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR ),\n      NAME_VAL( RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR ),\n   };\nint loc_ioctl_type_num = sizeof loc_ioctl_type_name / sizeof(loc_name_val_s_type);\n\n/* IOCTL Status names */\nloc_name_val_s_type loc_ioctl_status_name[] =\n   {\n      NAME_VAL( RPC_LOC_API_SUCCESS ),\n      NAME_VAL( RPC_LOC_API_GENERAL_FAILURE ),\n      NAME_VAL( RPC_LOC_API_UNSUPPORTED ),\n      NAME_VAL( RPC_LOC_API_INVALID_HANDLE ),\n      NAME_VAL( RPC_LOC_API_INVALID_PARAMETER ),\n      NAME_VAL( RPC_LOC_API_ENGINE_BUSY ),\n      NAME_VAL( RPC_LOC_API_PHONE_OFFLINE ),\n      NAME_VAL( RPC_LOC_API_TIMEOUT ),\n      NAME_VAL( RPC_LOC_API_RPC_FAILURE ),\n      NAME_VAL( RPC_LOC_API_RPC_MODEM_RESTART )\n   };\nint loc_ioctl_status_num = sizeof loc_ioctl_status_name / sizeof(loc_name_val_s_type);\n\n/* Fix session status names */\nloc_name_val_s_type loc_sess_status_name[] =\n   {\n      NAME_VAL( RPC_LOC_SESS_STATUS_SUCCESS ),\n      NAME_VAL( RPC_LOC_SESS_STATUS_IN_PROGESS ),\n      NAME_VAL( RPC_LOC_SESS_STATUS_GENERAL_FAILURE ),\n      NAME_VAL( RPC_LOC_SESS_STATUS_TIMEOUT ),\n      NAME_VAL( RPC_LOC_SESS_STATUS_USER_END ),\n      NAME_VAL( RPC_LOC_SESS_STATUS_BAD_PARAMETER ),\n      NAME_VAL( RPC_LOC_SESS_STATUS_PHONE_OFFLINE ),\n      NAME_VAL( RPC_LOC_SESS_STATUS_USER_END ),\n      NAME_VAL( RPC_LOC_SESS_STATUS_ENGINE_LOCKED )\n   };\nint loc_sess_status_num = sizeof loc_sess_status_name / sizeof(loc_name_val_s_type);\n\n/* Engine state names */\nloc_name_val_s_type loc_engine_state_name[] =\n   {\n      NAME_VAL( RPC_LOC_ENGINE_STATE_ON ),\n      NAME_VAL( RPC_LOC_ENGINE_STATE_OFF )\n   };\nint loc_engine_state_num = sizeof loc_engine_state_name / sizeof(loc_name_val_s_type);\n\n/* Fix session state names */\nloc_name_val_s_type loc_fix_session_state_name[] =\n   {\n      NAME_VAL( RPC_LOC_FIX_SESSION_STATE_BEGIN ),\n      NAME_VAL( RPC_LOC_FIX_SESSION_STATE_END )\n   };\nint loc_fix_session_state_num = sizeof loc_fix_session_state_name / sizeof(loc_name_val_s_type);\n\n\nstatic const char* log_final_interm_string(int is_final)\n{\n   return is_final ? \"final\" : \"intermediate\";\n}\n\n/* Logs parsed report */\nstatic void log_parsed_report(const rpc_loc_parsed_position_s_type *parsed_report)\n{\n   rpc_loc_session_status_e_type status = parsed_report->session_status;\n   LOC_LOGD(\"Session status: %s   Valid mask: 0x%X\\n\",\n         loc_get_sess_status_name(status),\n         (uint) parsed_report->valid_mask);\n   LOC_LOGD(\"Latitude:  %.7f (%s)\\n\", parsed_report->latitude,\n         log_final_interm_string(\n               (parsed_report->valid_mask & RPC_LOC_POS_VALID_LATITUDE) &&\n               parsed_report->session_status == RPC_LOC_SESS_STATUS_SUCCESS));\n   LOC_LOGD(\"Longitude: %.7f\\n\", parsed_report->longitude);\n   LOC_LOGD(\"Accuracy: %.7f\\n\", parsed_report->hor_unc_circular);\n}\n\n/* Logs status report */\nstatic void log_status_report(const rpc_loc_status_event_s_type *status_event)\n{\n   rpc_loc_status_event_e_type event = status_event->event;\n   switch (event) {\n   case RPC_LOC_STATUS_EVENT_ENGINE_STATE:\n      LOC_LOGD(\"Engine state: %s\\n\",\n            loc_get_engine_state_name(\n                  status_event->payload.rpc_loc_status_event_payload_u_type_u.engine_state));\n      break;\n   case RPC_LOC_STATUS_EVENT_FIX_SESSION_STATE:\n      LOC_LOGD(\"Fix session state: %s\\n\",\n            loc_get_fix_session_state_name(\n                  status_event->payload.rpc_loc_status_event_payload_u_type_u.fix_session_state));\n      break;\n   default:\n      break;\n   }\n}\n\n/* Logs valid fields in the GNSS SV constellation report */\nstatic void log_satellite_report(const rpc_loc_gnss_info_s_type *gnss)\n{\n   if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_POS_DOP)\n   {\n      LOC_LOGV(\"position dop: %.3f\\n\", (float) gnss->position_dop);\n   }\n   if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_HOR_DOP)\n   {\n      LOC_LOGV(\"horizontal dop: %.3f\\n\", (float) gnss->horizontal_dop);\n   }\n   if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_VERT_DOP)\n   {\n      LOC_LOGV(\"vertical dop: %.3f\\n\", (float) gnss->vertical_dop);\n   }\n   if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_ALTITUDE_ASSUMED)\n   {\n      LOC_LOGV(\"altitude assumed: %d\\n\", (int) gnss->altitude_assumed);\n   }\n   if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_COUNT)\n   {\n      LOC_LOGD(\"sv count: %d\\n\", (int) gnss->sv_count);\n   }\n   if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_LIST)\n   {\n      LOC_LOGV(\"sv list: \");\n\n      if (gnss->sv_count)\n      {\n         LOC_LOGV(\"\\n\\tsys\\tprn\\thlth\\tproc\\teph\\talm\\telev\\tazi\\tsnr\\n\");\n      }\n      else {\n         LOC_LOGV(\"empty\\n\");\n      }\n\n      int i;\n      for (i = 0; i < gnss->sv_count; i++)\n      {\n         const rpc_loc_sv_info_s_type *sv = &gnss->sv_list.sv_list_val[i];\n         rpc_loc_sv_info_valid_mask_type mask = sv->valid_mask;\n         LOC_LOGV(\"  %d: \\t%d\\t%d\\t%d\\t%d\\t%d\\t%d\\t%.3f\\t%.3f\\t%.3f\\n\", i,\n               CHECK_MASK(int,   sv->system,         mask, RPC_LOC_SV_INFO_VALID_SYSTEM),\n               CHECK_MASK(int,   sv->prn,            mask, RPC_LOC_SV_INFO_VALID_PRN),\n               CHECK_MASK(int,   sv->health_status,  mask, RPC_LOC_SV_INFO_VALID_HEALTH_STATUS),\n               CHECK_MASK(int,   sv->process_status, mask, RPC_LOC_SV_INFO_VALID_PROCESS_STATUS),\n               CHECK_MASK(int,   sv->has_eph,        mask, RPC_LOC_SV_INFO_VALID_HAS_EPH),\n               CHECK_MASK(int,   sv->has_alm,        mask, RPC_LOC_SV_INFO_VALID_HAS_ALM),\n               CHECK_MASK(float, sv->elevation,      mask, RPC_LOC_SV_INFO_VALID_ELEVATION),\n               CHECK_MASK(float, sv->azimuth,        mask, RPC_LOC_SV_INFO_VALID_AZIMUTH),\n               CHECK_MASK(float, sv->snr,            mask, RPC_LOC_SV_INFO_VALID_SNR)\n         );\n      }\n   }\n}\n\n/* Logs a callback event */\nint loc_callback_log(\n      rpc_loc_event_mask_type               loc_event,              /* event mask           */\n      const rpc_loc_event_payload_u_type*   loc_event_payload       /* payload              */\n)\n{\n   switch (loc_event)\n   {\n   case RPC_LOC_EVENT_SATELLITE_REPORT:\n      log_satellite_report(&loc_event_payload->\n            rpc_loc_event_payload_u_type_u.gnss_report);\n      break;\n   case RPC_LOC_EVENT_STATUS_REPORT:\n      log_status_report(&loc_event_payload->\n            rpc_loc_event_payload_u_type_u.status_report);\n      break;\n   case RPC_LOC_EVENT_PARSED_POSITION_REPORT:\n      log_parsed_report(&loc_event_payload->\n            rpc_loc_event_payload_u_type_u.parsed_location_report);\n      break;\n   default:\n      break;\n   }\n\n   return 0;\n}\n\n/* Finds the first event found in the mask */\nconst char* loc_get_event_name(rpc_loc_event_mask_type loc_event_mask)\n{\n   return loc_get_name_from_mask(loc_event_name, loc_event_num,\n         (long) loc_event_mask);\n}\n\n/* Finds IOCTL type name */\nconst char* loc_get_ioctl_type_name(rpc_loc_ioctl_e_type ioctl_type)\n{\n   return loc_get_name_from_val(loc_ioctl_type_name, loc_ioctl_type_num,\n         (long) ioctl_type);\n}\n\n/* Finds IOCTL status name */\nconst char* loc_get_ioctl_status_name(uint32 status)\n{\n   return loc_get_name_from_val(loc_ioctl_status_name, loc_ioctl_status_num,\n         (long) status);\n}\n\n/* Finds session status name */\nconst char* loc_get_sess_status_name(rpc_loc_session_status_e_type status)\n{\n   return loc_get_name_from_val(loc_sess_status_name, loc_sess_status_num,\n         (long) status);\n}\n\n/* Find engine state name */\nconst char* loc_get_engine_state_name(rpc_loc_engine_state_e_type state)\n{\n   return loc_get_name_from_val(loc_engine_state_name, loc_engine_state_num,\n         (long) state);\n}\n\n/* Find engine state name */\nconst char* loc_get_fix_session_state_name(rpc_loc_fix_session_state_e_type state)\n{\n   return loc_get_name_from_val(loc_fix_session_state_name, loc_fix_session_state_num,\n         (long) state);\n}\n\n/* Event names */\nloc_name_val_s_type rpc_reset_event_name[] =\n{\n    NAME_VAL( RPC_SUBSYSTEM_RESTART_BEGIN ),\n    NAME_VAL( RPC_SUBSYSTEM_RESTART_END )\n};\nint rpc_reset_event_num = sizeof rpc_reset_event_name / sizeof(loc_name_val_s_type);\n\nconst char* loc_get_rpc_reset_event_name(enum rpc_reset_event event)\n{\n    return loc_get_name_from_val(rpc_reset_event_name, rpc_reset_event_num, event);\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_rpc_glue.c",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*=====================================================================\n\n                     INCLUDE FILES FOR MODULE\n\n======================================================================*/\n#include <stdio.h>\n#include <pthread.h>\n#include <errno.h>\n#include <string.h>\n#include <sys/select.h>\n#include <sys/time.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <sys/mman.h>\n#include <unistd.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <loc_api_log.h>\n\n#include <rpc/rpc.h>\n\n/* Include RPC headers */\n#include \"rpc_inc/loc_api_rpc_glue.h\"\n\n/* Callback init */\n#include \"rpc_inc/loc_apicb_appinit.h\"\n\n/* Logging */\n#define LOG_TAG \"LocSvc_api_rpc_glue\"\n#define LOG_NDDEBUG 0\n#ifndef USE_GLIB\n#include <utils/Log.h>\n#endif /* USE_GLIB */\n\n/* Logging Improvement */\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n/*Maximum number of Modem init*/\n#define RPC_TRY_NUM 10\n\n/*Maximum number of Modem init*/\n#define RPC_TRY_NUM 10\n\n/* Uncomment to force ALOGD messages */\n// #define ALOGD ALOGI\n\n/*=====================================================================\n     External declarations\n======================================================================*/\n\nCLIENT* loc_api_clnt = NULL;\n\n/* Callback ID and pointer */\n#define LOC_API_CB_MAX_CLIENTS 16\ntypedef struct\n{\n    uint32 cb_id;                        /* same as rpc/types.h */\n    loc_event_cb_f_type *cb_func;      /* callback func */\n    loc_reset_notif_cb_f_type *rpc_cb; /* callback from RPC */\n    rpc_loc_client_handle_type handle; /* stores handle for client closing */\n    void* user;                        /* user's own data handle */\n} loc_glue_cb_entry_s_type;\n\nloc_glue_cb_entry_s_type loc_glue_callback_table[LOC_API_CB_MAX_CLIENTS];\n\n#define RPC_FUNC_VERSION_BASE(a,b) a ## b\n#define RPC_FUNC_VERSION(a,b) RPC_FUNC_VERSION_BASE(a,b)\n\n#define RPC_CALLBACK_FUNC_VERSION_BASE(a,v,b) a ## v ## b\n#define RPC_CALLBACK_FUNC_VERSION(a,v,b) RPC_CALLBACK_FUNC_VERSION_BASE(a,v,b)\n\n#define LOC_GLUE_CHECK_INIT(ret_type) \\\n   if (loc_api_clnt == NULL) { EXIT_LOG_CALLFLOW(%d, RPC_LOC_API_RPC_FAILURE); return (ret_type) RPC_LOC_API_RPC_FAILURE; }\n\n#define LOC_GLUE_CHECK_RESULT(stat, ret_type) \\\n  if (stat != RPC_SUCCESS) { \\\n      LOC_LOGE(\"%s:%d] failure code %d\", __func__, __LINE__, stat); \\\n      return (ret_type)((stat == RPC_SUBSYSTEM_RESTART) ? \\\n                        RPC_LOC_API_RPC_MODEM_RESTART : RPC_LOC_API_RPC_FAILURE); \\\n  }\n\n/* Callback functions */\n/* Returns 1 if successful */\nbool_t rpc_loc_event_cb_f_type_svc(\n      rpc_loc_event_cb_f_type_args *argp,\n      rpc_loc_event_cb_f_type_rets *ret,\n      struct svc_req *req)\n{\n    // The lower word of cd_id is the index\n    int index = argp->cb_id & 0xFFFF;\n\n    /* Callback not registered, or unexpected ID (shouldn't happen) */\n    if (index >= LOC_API_CB_MAX_CLIENTS || loc_glue_callback_table[index].cb_func == NULL)\n    {\n        LOC_LOGE(\"Warning: No callback handler %d.\\n\", index);\n        ret->loc_event_cb_f_type_result = 0;\n        return 1; /* simply return */\n    }\n\n    LOC_LOGV(\"proc: %x  prog: %x  vers: %x\\n\",\n         (int) req->rq_proc,\n         (int) req->rq_prog,\n         (int) req->rq_vers);\n\n    LOC_LOGV(\"Callback received: %x (cb_id=%p handle=%d ret_ptr=%d)\\n\",\n         (int) argp->loc_event,\n               argp->cb_id,\n         (int) argp->loc_handle,\n         (int) ret);\n\n    /* Forward callback to real callback procedure */\n    rpc_loc_client_handle_type        loc_handle = argp->loc_handle;\n    rpc_loc_event_mask_type           loc_event  = argp->loc_event;\n    const rpc_loc_event_payload_u_type*  loc_event_payload =\n        (const rpc_loc_event_payload_u_type*) argp->loc_event_payload;\n\n    /* Gives control to synchronous call handler */\n    loc_api_callback_process_sync_call(loc_handle, loc_event, loc_event_payload);\n\n    int32 rc = (loc_glue_callback_table[index].cb_func)(loc_glue_callback_table[index].user,\n                                                        loc_handle, loc_event, loc_event_payload);\n\n    LOC_LOGV(\"cb_func=%p\", loc_glue_callback_table[index].cb_func);\n\n    ret->loc_event_cb_f_type_result = rc;\n\n    return 1; /* ok */\n}\n\nint loc_apicbprog_freeresult (SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)\n{\n   xdr_free (xdr_result, result);\n\n   /*\n    * Insert additional freeing code here, if needed\n    */\n   // LOC_LOGD(\"***** loc_apicbprog_freeresult\\n\");\n\n   return 1;\n}\n\n/*===========================================================================\n\nFUNCTION rpc_loc_event_cb_f_type_<version>_svc (MACRO)\n\nDESCRIPTION\n   Callback function for Loc API\n\nRETURN VALUE\n   1 for success\n   0 for failure\n\n===========================================================================*/\nbool_t RPC_CALLBACK_FUNC_VERSION(rpc_loc_event_cb_f_type_, RPC_LOC_EVENT_CB_F_TYPE_VERSION, _svc) (\n      rpc_loc_event_cb_f_type_args *argp,\n      rpc_loc_event_cb_f_type_rets *ret,\n      struct svc_req *req)\n{\n   return rpc_loc_event_cb_f_type_svc(argp, ret, req);\n}\n\n/*===========================================================================\n\nFUNCTION loc_apicbprog_<version>_freeresult (MACRO)\n\nDESCRIPTION\n   Free up RPC data structure\n\nRETURN VALUE\n   1 for success\n   0 for failure\n\n===========================================================================*/\n#define VERSION_CONCAT(MAJOR,MINOR) MAJOR##MINOR\n#define loc_apicb_prog_VER_freeresult(M,N) \\\nint RPC_CALLBACK_FUNC_VERSION(loc_apicbprog_, VERSION_CONCAT(M,N), _freeresult) \\\n(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result) \\\n{ \\\n   return loc_apicbprog_freeresult(transp, xdr_result, result); \\\n}\n\n/* Define all of the possible minors */\nloc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0001);\nloc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0002);\nloc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0003);\nloc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0004);\nloc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0005);\nloc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0006);\n\n/*===========================================================================\n\nFUNCTION rpc_loc_api_cb_null_<version>_svc (MACRO) [Patch for wrong RPCGEN stubs]\n\nDESCRIPTION\n   Null callback function for Loc API\n\nRETURN VALUE\n   1 for success\n\n===========================================================================*/\n#define rpc_loc_api_cb_null_VER_svc(M,N) \\\nbool_t RPC_CALLBACK_FUNC_VERSION(rpc_loc_api_cb_null_, VERSION_CONCAT(M,N), _svc) ( \\\n      void *a, int *b, struct svc_req *req) \\\n{ \\\n   return 1; \\\n}\n\n/* Define all of the possible minors */\nrpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0001);\nrpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0002);\nrpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0003);\nrpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0004);\nrpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0005);\nrpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0006);\n\nstatic void loc_api_glue_rpc_cb(CLIENT* client, enum rpc_reset_event event)\n{\n    int i;\n    for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++) {\n        if (NULL != loc_glue_callback_table[i].rpc_cb) {\n            loc_glue_callback_table[i].rpc_cb(loc_glue_callback_table[i].user, client, event);\n        }\n    }\n}\n\n/*===========================================================================\n\nFUNCTION loc_api_glue_init\n\nDESCRIPTION\n   Initiates the RPC client\n\nRETURN VALUE\n   1 for success\n   0 for failure\n\n===========================================================================*/\nint loc_api_glue_init(void)\n{\n   if (loc_api_clnt == NULL)\n   {\n      /* Initialize data */\n      int i;\n      int pid = getpid();\n      for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)\n      {\n          loc_glue_callback_table[i].cb_id = i | (pid << 16);\n          loc_glue_callback_table[i].cb_func = NULL;\n          loc_glue_callback_table[i].handle = -1;\n          loc_glue_callback_table[i].rpc_cb = NULL;\n          loc_glue_callback_table[i].user = NULL;\n      }\n\n      /* Print msg */\n      LOC_LOGV(\"Trying to create RPC client...\\n\");\n      loc_api_clnt = clnt_create(NULL, LOC_APIPROG, LOC_APIVERS, NULL);\n      LOC_LOGV(\"Created loc_api_clnt ---- %x\\n\", (unsigned int)loc_api_clnt);\n\n      if (loc_api_clnt == NULL)\n      {\n         LOC_LOGE(\"Error: cannot create RPC client.\\n\");\n         return 0;\n      }\n\n      /* Init RPC callbacks */\n      loc_api_sync_call_init();\n\n      int rc = loc_apicb_app_init();\n      if (rc >= 0)\n      {\n         LOC_LOGD(\"Loc API RPC client initialized.\\n\");\n         clnt_register_reset_notification_cb(loc_api_clnt, loc_api_glue_rpc_cb);\n      }\n      else {\n         LOC_LOGE(\"Loc API callback initialization failed.\\n\");\n         return 0;\n      }\n   }\n\n   return 1;\n}\n\nrpc_loc_client_handle_type loc_open (\n    rpc_loc_event_mask_type       event_reg_mask,\n    loc_event_cb_f_type           *event_callback,\n    loc_reset_notif_cb_f_type     *rpc_cb,\n    void*                         userData\n)\n{\n    int try_num = RPC_TRY_NUM;\n    ENTRY_LOG();\n    LOC_GLUE_CHECK_INIT(rpc_loc_client_handle_type);\n\n    rpc_loc_client_handle_type ret_val;\n\n    rpc_loc_open_args args;\n    args.event_reg_mask = event_reg_mask;\n\n    int i, j = LOC_API_CB_MAX_CLIENTS;\n    for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)\n    {\n        if (loc_glue_callback_table[i].user == userData)\n        {\n            LOC_LOGW(\"Client already opened service (callback=%p)...\\n\",\n                  event_callback);\n            break;\n        } else if (j == LOC_API_CB_MAX_CLIENTS &&\n                   loc_glue_callback_table[i].user == NULL) {\n            j = i;\n        }\n    }\n\n    if (i == LOC_API_CB_MAX_CLIENTS)\n    {\n        i = j;\n    }\n\n    if (i == LOC_API_CB_MAX_CLIENTS)\n    {\n        LOC_LOGE(\"Too many clients opened at once...\\n\");\n        return RPC_LOC_CLIENT_HANDLE_INVALID;\n    }\n\n    loc_glue_callback_table[i].cb_func = event_callback;\n    loc_glue_callback_table[i].rpc_cb = rpc_cb;\n    loc_glue_callback_table[i].user = userData;\n\n    args.event_callback = loc_glue_callback_table[i].cb_id;\n    LOC_LOGV(\"cb_id=%d, func=0x%x\", i, (unsigned int) event_callback);\n\n    rpc_loc_open_rets rets;\n    enum clnt_stat stat = RPC_SUCCESS;\n\n    EXIT_LOG_CALLFLOW(%s, \"loc client open\");\n\n     /*try more for rpc_loc_open_xx()*/\n\n    do\n    {\n        stat = RPC_FUNC_VERSION(rpc_loc_open_, RPC_LOC_OPEN_VERSION)(&args, &rets, loc_api_clnt);\n        ret_val = (rpc_loc_client_handle_type) rets.loc_open_result;\n        try_num--;\n\n    }while( (RPC_SUCCESS != stat||0 > ret_val) && 0 != try_num );\n\n    LOC_GLUE_CHECK_RESULT(stat, int32);\n\n    /* save the handle in the table */\n    loc_glue_callback_table[i].handle = (rpc_loc_client_handle_type) rets.loc_open_result;\n\n    return ret_val;\n\n}\n\nint32 loc_close\n(\n      rpc_loc_client_handle_type handle\n)\n{\n    ENTRY_LOG();\n    LOC_GLUE_CHECK_INIT(int32);\n\n    int32 ret_val;\n\n    rpc_loc_close_args args;\n    args.handle = handle;\n\n    rpc_loc_close_rets rets;\n    enum clnt_stat stat = RPC_SUCCESS;\n\n    EXIT_LOG_CALLFLOW(%s, \"loc client close\");\n    stat = RPC_FUNC_VERSION(rpc_loc_close_, RPC_LOC_CLOSE_VERSION)(&args, &rets, loc_api_clnt);\n\n    loc_clear(handle);\n\n    LOC_GLUE_CHECK_RESULT(stat, int32);\n    ret_val = (int32) rets.loc_close_result;\n\n    return ret_val;\n}\n\nvoid loc_clear(rpc_loc_client_handle_type handle) {\n    /* Clean the client's callback function in callback table */\n    int i;\n    for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)\n    {\n        if (loc_glue_callback_table[i].handle == handle)\n        {\n            /* Found the client */\n            loc_glue_callback_table[i].cb_func = NULL;\n            loc_glue_callback_table[i].rpc_cb = NULL;\n            loc_glue_callback_table[i].handle = -1;\n            loc_glue_callback_table[i].user = NULL;\n            break;\n        }\n    }\n\n    if (i == LOC_API_CB_MAX_CLIENTS)\n    {\n        LOC_LOGW(\"Handle not found (handle=%d)...\\n\", (int) handle);\n    }\n}\n\nint32 loc_start_fix\n(\n      rpc_loc_client_handle_type handle\n)\n{\n    ENTRY_LOG();\n    LOC_GLUE_CHECK_INIT(int32);\n\n    int32 ret_val;\n\n    rpc_loc_start_fix_args args;\n    args.handle = handle;\n\n    rpc_loc_start_fix_rets rets;\n    enum clnt_stat stat = RPC_SUCCESS;\n\n    EXIT_LOG_CALLFLOW(%s, \"loc start fix\");\n    stat = RPC_FUNC_VERSION(rpc_loc_start_fix_, RPC_LOC_START_FIX_VERSION)(&args, &rets, loc_api_clnt);\n    LOC_GLUE_CHECK_RESULT(stat, int32);\n\n    ret_val = (int32) rets.loc_start_fix_result;\n\n    return ret_val;\n}\n\nint32 loc_stop_fix\n(\n      rpc_loc_client_handle_type handle\n)\n{\n    ENTRY_LOG();\n    LOC_GLUE_CHECK_INIT(int32);\n\n    int32 ret_val;\n\n    rpc_loc_stop_fix_args args;\n    args.handle = handle;\n\n    rpc_loc_stop_fix_rets rets;\n    enum clnt_stat stat = RPC_SUCCESS;\n\n    EXIT_LOG_CALLFLOW(%s, \"loc stop fix\");\n    stat = RPC_FUNC_VERSION(rpc_loc_stop_fix_, RPC_LOC_STOP_FIX_VERSION)(&args, &rets, loc_api_clnt);\n    LOC_GLUE_CHECK_RESULT(stat, int32);\n\n    ret_val = (int32) rets.loc_stop_fix_result;\n\n    return ret_val;\n}\n\nint32 loc_ioctl\n(\n      rpc_loc_client_handle_type           handle,\n      rpc_loc_ioctl_e_type                 ioctl_type,\n      rpc_loc_ioctl_data_u_type*           ioctl_data\n)\n{\n    ENTRY_LOG();\n    LOC_GLUE_CHECK_INIT(int32);\n\n    int32 ret_val;\n\n    rpc_loc_ioctl_args args;\n    args.handle = handle;\n    args.ioctl_data = ioctl_data;\n    args.ioctl_type = ioctl_type;\n    if (ioctl_data != NULL)\n    {\n        /* Assign ioctl union discriminator */\n        ioctl_data->disc = ioctl_type;\n\n        /* In case the user hasn't filled in other disc fields,\n           automatically fill them in here */\n        switch (ioctl_type)\n        {\n        case RPC_LOC_IOCTL_GET_API_VERSION:\n            break;\n        case RPC_LOC_IOCTL_SET_FIX_CRITERIA:\n            break;\n        case RPC_LOC_IOCTL_GET_FIX_CRITERIA:\n            break;\n        case RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE:\n            break;\n        case RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA:\n            break;\n        case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY:\n            break;\n        case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE:\n            break;\n        case RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD:\n            break;\n        case RPC_LOC_IOCTL_INJECT_UTC_TIME:\n            break;\n        case RPC_LOC_IOCTL_INJECT_RTC_VALUE:\n            break;\n        case RPC_LOC_IOCTL_INJECT_POSITION:\n            break;\n        case RPC_LOC_IOCTL_QUERY_ENGINE_STATE:\n            break;\n        case RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS:\n            break;\n        case RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS:\n            break;\n        case RPC_LOC_IOCTL_SET_ENGINE_LOCK:\n            break;\n        case RPC_LOC_IOCTL_GET_ENGINE_LOCK:\n            break;\n        case RPC_LOC_IOCTL_SET_SBAS_CONFIG:\n            break;\n        case RPC_LOC_IOCTL_GET_SBAS_CONFIG:\n            break;\n        case RPC_LOC_IOCTL_SET_NMEA_TYPES:\n            break;\n        case RPC_LOC_IOCTL_GET_NMEA_TYPES:\n            break;\n        case RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR:\n        case RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR:\n        case RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR:\n        case RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR:\n            args.ioctl_data->rpc_loc_ioctl_data_u_type_u.server_addr.addr_info.disc =\n                args.ioctl_data->rpc_loc_ioctl_data_u_type_u.server_addr.addr_type;\n            break;\n        case RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR:\n        case RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR:\n        case RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR:\n        case RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR:\n            break;\n        case RPC_LOC_IOCTL_SET_ON_DEMAND_LPM:\n            break;\n        case RPC_LOC_IOCTL_GET_ON_DEMAND_LPM:\n            break;\n        case RPC_LOC_IOCTL_DELETE_ASSIST_DATA:\n            break;\n        default:\n            break;\n        } /* switch */\n    } /* ioctl_data != NULL */\n\n    rpc_loc_ioctl_rets rets;\n    enum clnt_stat stat = RPC_SUCCESS;\n\n    EXIT_LOG_CALLFLOW(%s, loc_get_ioctl_type_name(ioctl_type));\n    stat = RPC_FUNC_VERSION(rpc_loc_ioctl_, RPC_LOC_IOCTL_VERSION)(&args, &rets, loc_api_clnt);\n    LOC_GLUE_CHECK_RESULT(stat, int32);\n\n    ret_val = (int32) rets.loc_ioctl_result;\n\n    return ret_val;\n}\n\n/* Returns 0 if error */\nint32 loc_api_null(void)\n{\n    LOC_GLUE_CHECK_INIT(int32);\n\n    int32 rets;\n    enum clnt_stat stat = RPC_SUCCESS;\n\n    clnt_unregister_reset_notification_cb(loc_api_clnt);\n    stat = RPC_FUNC_VERSION(rpc_loc_api_null_, RPC_LOC_API_NULL_VERSION)(NULL, &rets, loc_api_clnt);\n    LOC_GLUE_CHECK_RESULT(stat, int32);\n\n    return (int32) rets;\n}\n\n/*===========================================================================\n\nFUNCTION    loc_eng_ioctl\n\nDESCRIPTION\n   This function calls loc_ioctl and waits for the callback result before\n   returning back to the user.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   TRUE                 if successful\n   FALSE                if failed\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_ioctl\n(\n      rpc_loc_client_handle_type           handle,\n      rpc_loc_ioctl_e_type                 ioctl_type,\n      rpc_loc_ioctl_data_u_type*           ioctl_data_ptr,\n      uint32                               timeout_msec,\n      rpc_loc_ioctl_callback_s_type       *cb_data_ptr\n)\n{\n    int ret_val = RPC_LOC_API_SUCCESS;\n\n    ret_val = loc_api_sync_ioctl(handle, ioctl_type, ioctl_data_ptr, timeout_msec, cb_data_ptr);\n\n    LOC_LOGD(\"loc_eng_ioctl result: client = %d, ioctl_type = %s, returt %s\\n\",\n             (int32) handle,\n             loc_get_ioctl_type_name(ioctl_type),\n             loc_get_ioctl_status_name(ret_val) );\n\n    return ret_val;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_api_sync_call.c",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include <stdio.h>\n#include <assert.h>\n#include <errno.h>\n#include <sys/time.h>\n#include <string.h>\n#include <pthread.h>\n\n#include <rpc/rpc.h>\n#include <loc_api_rpc_glue.h>\n#include \"loc_api_sync_call.h\"\n\n/* Logging */\n#define LOG_TAG \"LocSvc_api_rpc_glue\"\n// #define LOG_NDDEBUG 0\n#ifndef USE_GLIB\n#include <utils/Log.h>\n#endif /* USE_GLIB */\n\n/***************************************************************************\n *                 DATA FOR ASYNCHRONOUS RPC PROCESSING\n **************************************************************************/\nloc_sync_call_slot_array_s_type loc_sync_data;\n\npthread_mutex_t loc_sync_call_mutex = PTHREAD_MUTEX_INITIALIZER;\nboolean loc_sync_call_inited = 0;\n\n/*===========================================================================\n\nFUNCTION    loc_api_sync_call_init\n\nDESCRIPTION\n   Initialize this module\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   none\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_api_sync_call_init()\n{\n   pthread_mutex_lock(&loc_sync_call_mutex);\n   if (loc_sync_call_inited == 1) {\n       pthread_mutex_unlock(&loc_sync_call_mutex);\n       return;\n   }\n   loc_sync_call_inited = 1;\n\n   loc_sync_data.num_of_slots = LOC_SYNC_CALL_SLOTS_MAX;\n\n   int i;\n   for (i = 0; i < loc_sync_data.num_of_slots; i++)\n   {\n      loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];\n\n      pthread_mutex_init(&slot->lock, NULL);\n      pthread_cond_init(&slot->loc_cb_arrived_cond, NULL);\n\n      slot->not_available = 0;\n      slot->in_use = 0;\n      slot->loc_handle = -1;\n      slot->loc_cb_wait_event_mask = 0;       /* event to wait   */\n      slot->loc_cb_received_event_mask = 0;   /* received event   */\n   }\n\n   pthread_mutex_unlock(&loc_sync_call_mutex);\n}\n\n/*===========================================================================\n\nFUNCTION    loc_api_sync_call_destroy\n\nDESCRIPTION\n   Initialize this module\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   none\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_api_sync_call_destroy()\n{\n   int i;\n\n   pthread_mutex_lock(&loc_sync_call_mutex);\n   if (loc_sync_call_inited == 0) {\n       pthread_mutex_unlock(&loc_sync_call_mutex);\n       return;\n   }\n   loc_sync_call_inited = 0;\n\n   for (i = 0; i < loc_sync_data.num_of_slots; i++)\n   {\n      loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];\n\n      pthread_mutex_lock(&slot->lock);\n\n      slot->not_available = 1;\n\n      pthread_mutex_unlock(&slot->lock);\n\n      pthread_cond_destroy(&slot->loc_cb_arrived_cond);\n      pthread_mutex_destroy(&slot->lock);\n   }\n\n   pthread_mutex_unlock(&loc_sync_call_mutex);\n}\n\n/*===========================================================================\n\nFUNCTION    loc_match_callback\n\nDESCRIPTION\n   Checks if an awaited event has arrived\n\nRETURN VALUE\n   TRUE                 arrived\n   FALSE                not matching\n\n===========================================================================*/\nstatic boolean loc_match_callback(\n      rpc_loc_event_mask_type             wait_mask,\n      rpc_loc_ioctl_e_type                wait_ioctl,\n      rpc_loc_event_mask_type             event_mask,\n      const rpc_loc_event_payload_u_type  *callback_payload\n)\n{\n   if ((event_mask & wait_mask) == 0) return FALSE;\n\n   if (event_mask != RPC_LOC_EVENT_IOCTL_REPORT || wait_ioctl == 0 ||\n        ( (callback_payload != NULL) &&\n         callback_payload->rpc_loc_event_payload_u_type_u.ioctl_report.type == wait_ioctl) )\n      return TRUE;\n\n   return FALSE;\n}\n\n/*===========================================================================\n\nFUNCTION    loc_api_callback_process_sync_call\n\nDESCRIPTION\n   Wakes up blocked API calls to check if the needed callback has arrived\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   none\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_api_callback_process_sync_call(\n      rpc_loc_client_handle_type            loc_handle,             /* handle of the client */\n      rpc_loc_event_mask_type               loc_event,              /* event mask           */\n      const rpc_loc_event_payload_u_type*   loc_event_payload       /* payload              */\n)\n{\n   int i;\n\n   ALOGV(\"loc_handle = 0x%lx, loc_event = 0x%lx\", loc_handle, loc_event);\n   for (i = 0; i < loc_sync_data.num_of_slots; i++)\n   {\n      loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];\n\n      pthread_mutex_lock(&slot->lock);\n\n      if (slot->in_use &&\n          slot->signal_sent == 0 &&\n          slot->loc_handle == loc_handle &&\n          loc_match_callback(slot->loc_cb_wait_event_mask, slot->ioctl_type, loc_event, loc_event_payload))\n      {\n         memcpy(&slot->loc_cb_received_payload, loc_event_payload, sizeof (rpc_loc_event_payload_u_type));\n\n         slot->loc_cb_received_event_mask = loc_event;\n\n         ALOGV(\"signal slot %d in_use %d, loc_handle 0x%lx, event_mask 0x%1x, ioctl_type %d\", i, slot->in_use, slot->loc_handle, (int) slot->loc_cb_wait_event_mask, (int) slot->ioctl_type);\n         pthread_cond_signal(&slot->loc_cb_arrived_cond);\n         slot->signal_sent = 1;\n\n         pthread_mutex_unlock(&slot->lock);\n         break;\n      } else {\n         /* do nothing */\n      }\n\n      pthread_mutex_unlock(&slot->lock);\n   }\n}\n\n/*===========================================================================\n\nFUNCTION    loc_lock_a_slot\n\nDESCRIPTION\n   Allocates a buffer slot for the synchronous API call\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Select ID (>=0)     : successful\n   -1                  : buffer full\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_lock_a_slot()\n{\n   int i, select_id = -1; /* no free buffer */\n\n   for (i = 0; i < loc_sync_data.num_of_slots; i++)\n   {\n      loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];\n      if (pthread_mutex_trylock(&slot->lock) == EBUSY)\n      {\n         ALOGV(\"trylock EBUSY : %d\", i);\n         continue;\n      }\n\n      if (!slot->in_use && !slot->not_available)\n      {\n         select_id = i;\n         /* Return from here and leave the mutex locked.\n          * will unlock it in loc_unlock_slot()\n          */\n         break;\n      }\n      /* ALOGV(\"slot %d in_use = %d, not_available = %d : %d\", i, slot->in_use, slot->not_available, i); */\n      pthread_mutex_unlock(&slot->lock);\n   }\n\n   return select_id;\n}\n\n/*===========================================================================\n\nFUNCTION    loc_unlock_slot\n\nDESCRIPTION\n   Unlocks a buffer slot\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_unlock_slot(int select_id)\n{\n   pthread_mutex_unlock(&loc_sync_data.slots[select_id].lock);\n}\n\n/*===========================================================================\n\nFUNCTION    loc_lock_slot\n\nDESCRIPTION\n   Locks a specific slot that was previously locked from loc_lock_a_slot\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_lock_slot(int select_id)\n{\n    pthread_mutex_lock(&loc_sync_data.slots[select_id].lock);\n}\n\n/*===========================================================================\n\nFUNCTION    loc_set_slot_in_use\n\nDESCRIPTION\n   Sets the in_use flag of slot to true or false.\n   Should be called only after the slot is locked\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_set_slot_in_use(int select_id, boolean in_use)\n{\n    loc_sync_data.slots[select_id].in_use = in_use;\n    if (in_use == 1)\n        loc_sync_data.slots[select_id].signal_sent = 0;\n}\n\n/*===========================================================================\n\nFUNCTION    loc_api_save_callback\n\nDESCRIPTION\n   Selects which callback or IOCTL event to wait for.\n\n   The event_mask specifies the event(s). If it is RPC_LOC_EVENT_IOCTL_REPORT,\n   then ioctl_type specifies the IOCTL event.\n\n   If ioctl_type is non-zero, RPC_LOC_EVENT_IOCTL_REPORT is automatically added.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Select ID (>=0)     : successful\n   -1                  : out of buffer\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_api_save_callback(\n      int                              select_id,            /* Selected slot */\n      rpc_loc_client_handle_type       loc_handle,           /* Client handle */\n      rpc_loc_event_mask_type          event_mask,           /* Event mask to wait for */\n      rpc_loc_ioctl_e_type             ioctl_type            /* IOCTL type to wait for */\n)\n{\n   loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[select_id];\n\n   slot->loc_handle = loc_handle;\n\n   slot->loc_cb_wait_event_mask = event_mask;\n   slot->ioctl_type = ioctl_type;\n   if (ioctl_type) slot->loc_cb_wait_event_mask |= RPC_LOC_EVENT_IOCTL_REPORT;\n\n   return;\n}\n\n/*===========================================================================\n\nFUNCTION    loc_save_user_payload\n\nDESCRIPTION\n   Saves received payload into user data structures\n\nRETURN VALUE\n   None\n\n===========================================================================*/\nstatic void loc_save_user_payload(\n      rpc_loc_event_payload_u_type  *user_cb_payload,\n      rpc_loc_ioctl_callback_s_type *user_ioctl_buffer,\n      const rpc_loc_event_payload_u_type  *received_cb_payload\n)\n{\n   if (user_cb_payload)\n   {\n      memcpy(user_cb_payload, received_cb_payload,\n            sizeof (rpc_loc_event_payload_u_type));\n   }\n   if (user_ioctl_buffer)\n   {\n      memcpy(user_ioctl_buffer,\n            &received_cb_payload->rpc_loc_event_payload_u_type_u.ioctl_report,\n            sizeof *user_ioctl_buffer);\n   }\n}\n\n/*===========================================================================\n\nFUNCTION    loc_api_wait_callback\n\nDESCRIPTION\n   Waits for a selected callback. The wait expires in timeout_seconds seconds.\n\n   If the function is called before an existing wait has finished, it will\n   immediately return EBUSY.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   RPC_LOC_API_SUCCESS              if successful (0)\n   RPC_LOC_API_TIMEOUT              if timed out\n   RPC_LOC_API_ENGINE_BUSY          if already in a wait\n   RPC_LOC_API_INVALID_PARAMETER    if callback is not yet selected\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_api_wait_callback(\n      int select_id,        /* ID from loc_select_callback() */\n      int timeout_seconds,  /* Timeout in this number of seconds  */\n      rpc_loc_event_payload_u_type     *callback_payload,    /* Pointer to callback payload buffer, can be NULL */\n      rpc_loc_ioctl_callback_s_type    *ioctl_payload        /* Pointer to IOCTL payload, can be NULL */\n)\n{\n   int ret_val = RPC_LOC_API_SUCCESS;  /* the return value of this function: 0 = no error */\n   int rc = 0;                         /* return code from pthread calls */\n\n   struct timespec expire_time;\n\n   loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[select_id];\n\n   clock_gettime(CLOCK_REALTIME, &expire_time);\n   expire_time.tv_sec += timeout_seconds;\n\n   /* Waiting */\n   while (slot->signal_sent == 0 && rc != ETIMEDOUT) {\n       rc = pthread_cond_timedwait(&slot->loc_cb_arrived_cond,\n             &slot->lock, &expire_time);\n   }\n\n   if (rc == ETIMEDOUT)\n   {\n      ret_val = RPC_LOC_API_TIMEOUT; /* Timed out */\n      ALOGE(\"TIMEOUT: %d\", select_id);\n   }\n   else {\n      /* Obtained the first awaited callback */\n      ret_val = RPC_LOC_API_SUCCESS;       /* Successful */\n      loc_save_user_payload(callback_payload, ioctl_payload, &slot->loc_cb_received_payload);\n   }\n\n   return ret_val;\n}\n\n/*===========================================================================\n\nFUNCTION    loc_api_sync_ioctl\n\nDESCRIPTION\n   Synchronous IOCTL call (reentrant version)\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Loc API error code (0 = success)\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_api_sync_ioctl\n(\n      rpc_loc_client_handle_type           handle,\n      rpc_loc_ioctl_e_type                 ioctl_type,\n      rpc_loc_ioctl_data_u_type*           ioctl_data_ptr,\n      uint32                               timeout_msec,\n      rpc_loc_ioctl_callback_s_type       *cb_data_ptr\n)\n{\n   int                              rc = -1;\n   int                              select_id;\n   rpc_loc_ioctl_callback_s_type    callback_data;\n\n   select_id = loc_lock_a_slot();\n\n   if (select_id < 0 || select_id >= loc_sync_data.num_of_slots)\n   {\n      ALOGE(\"slot not available ioctl_type = %s\",\n           loc_get_ioctl_type_name(ioctl_type));\n      return rc;\n   }\n\n   loc_set_slot_in_use(select_id, 1); // set slot in use to true\n\n   // Select the callback we are waiting for\n   loc_api_save_callback(select_id, handle, 0, ioctl_type);\n\n   loc_unlock_slot(select_id); // slot is unlocked, but in_use is still true\n\n   // we want to avoid keeping the slot locked during the loc_ioctl because the rpc\n   // framework will also lock a different mutex during this call, and typically\n   // locking two different mutexes at the same time can lead to deadlock.\n   rc =  loc_ioctl(handle, ioctl_type, ioctl_data_ptr);\n\n   loc_lock_slot(select_id);\n\n   if (rc != RPC_LOC_API_SUCCESS)\n   {\n      ALOGE(\"loc_ioctl failed select_id = %d, ioctl_type %s, returned %s\",\n           select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));\n   }\n   else {\n      ALOGV(\"select_id = %d, ioctl_type %d, returned RPC_LOC_API_SUCCESS\",\n          select_id, ioctl_type);\n      // Wait for the callback of loc_ioctl\n      if ((rc = loc_api_wait_callback(select_id, timeout_msec / 1000, NULL, &callback_data)) != 0)\n      {\n         // Callback waiting failed\n         ALOGE(\"callback wait failed select_id = %d, ioctl_type %s, returned %s\",\n              select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));\n      }\n      else\n      {\n         if (cb_data_ptr) memcpy(cb_data_ptr, &callback_data, sizeof *cb_data_ptr);\n         if (callback_data.status != RPC_LOC_API_SUCCESS)\n         {\n            rc = callback_data.status;\n            ALOGE(\"callback status failed select_id = %d, ioctl_type %s, returned %s\",\n                 select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));\n         } else {\n            ALOGV(\"callback status success select_id = %d, ioctl_type %d, returned %d\",\n                select_id, ioctl_type, rc);\n         }\n      } /* wait callback */\n   } /* loc_ioctl */\n\n   loc_set_slot_in_use(select_id, 0); // set slot in use to false\n   loc_unlock_slot(select_id);\n\n   return rc;\n}\n\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/loc_apicb_appinit.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include \"rpc/rpc.h\"\n\n/* Include RPC headers */\n#ifdef USE_LOCAL_RPC\n#include \"rpc_inc/loc_api_common.h\"\n#include \"rpc_inc/loc_api.h\"\n#include \"rpc_inc/loc_api_cb.h\"\n#endif\n\n#ifdef USE_QCOM_AUTO_RPC\n#include \"loc_api_rpcgen_rpc.h\"\n#include \"loc_api_rpcgen_common_rpc.h\"\n#include \"loc_api_rpcgen_cb_rpc.h\"\n#endif\n\n#include \"rpc_inc/loc_api_fixup.h\"\n#include \"loc_apicb_appinit.h\"\n\n#define RPC_FUNC_VERSION_BASE(a,b) a ## b\n#define RPC_CB_FUNC_VERS(a,b) RPC_FUNC_VERSION_BASE(a,b)\n\nstatic SVCXPRT* svrPort = NULL;\n\nextern void RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001)(struct svc_req *rqstp, register SVCXPRT *transp);\n\nint loc_apicb_app_init(void)\n{\n\n  /* Register a callback server to use the loc_apicbprog_* function  */\n  if (svrPort == NULL) {\n        svrPort = svcrtr_create();\n  }\n  if (!svrPort) return -1;\n\n  xprt_register(svrPort);\n  if(svc_register(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001, RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001),0))\n  {\n     return 0;\n  }\n  else\n  {\n    return -1;\n  }\n}\n\nvoid loc_apicb_app_deinit(void)\n{\n   if (svrPort == NULL)\n   {\n      return;\n   }\n\n   svc_unregister(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001);\n   xprt_unregister(svrPort);\n   svc_destroy(svrPort);\n   svrPort = NULL;\n}\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\n# functions\nLOC_RPCGEN_APIS_PATH := $(TARGET_OUT_INTERMEDIATES)/loc_api/libloc_api_rpcgen_intermediates\nLOC_RPCGEN_APIS_PATH_FL := ../../../../../$(TARGET_OUT_INTERMEDIATES)/loc_api/libloc_api_rpcgen_intermediates\n\nLOCAL_MODULE := libloc_api_rpcgen\nLOCAL_MODULE_OWNER := qcom\n\nLOCAL_SHARED_LIBRARIES := \\\n    librpc \\\n    libcommondefs\n\nLOCAL_SRC_FILES += \\\n    src/loc_api_rpcgen_cb_xdr.c \\\n    src/loc_api_rpcgen_common_xdr.c \\\n    src/loc_api_rpcgen_cb_svc.c \\\n    src/loc_api_rpcgen_clnt.c \\\n    src/loc_api_rpcgen_xdr.c\n\nLOCAL_C_INCLUDES += hardware/msm7k/librpc\nLOCAL_C_INCLUDES += $(LOC_RPCGEN_APIS_PATH)/../../SHARED_LIBRARIES/libcommondefs_intermediates/inc\nLOCAL_C_INCLUDES += $(LOCAL_PATH)/inc\nLOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libcommondefs/rpcgen/inc\n\nLOCAL_COPY_HEADERS_TO := loc_api/rpcgen/inc\nLOCAL_COPY_HEADERS := inc/loc_api_rpcgen_rpc.h\nLOCAL_COPY_HEADERS += inc/loc_api_rpcgen_common_rpc.h\nLOCAL_COPY_HEADERS += inc/loc_api_rpcgen_cb_rpc.h\nLOCAL_COPY_HEADERS += inc/loc_apicb_appinit.h\n\nLOCAL_LDLIBS += -lpthread\nLOCAL_PRELINK_MODULE := false\ninclude $(BUILD_STATIC_LIBRARY)\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/Makefile.am",
    "content": "AM_CFLAGS = \\\n   -I../../../utils \\\n   -I./inc \\\n   $(MSM7K_CFLAGS)\n\nrequiredlibs = \\\n    ../../../utils/libgps_utils_so.la \\\n    $(MSM7K_LIBS)\n\nh_sources = \\\n    inc/loc_api_rpcgen_rpc.h \\\n    inc/loc_api_rpcgen_common_rpc.h \\\n    inc/loc_api_rpcgen_cb_rpc.h \\\n    inc/loc_apicb_appinit.h\n\nc_sources = \\\n    src/loc_api_rpcgen_cb_xdr.c \\\n    src/loc_api_rpcgen_common_xdr.c \\\n    src/loc_api_rpcgen_cb_svc.c \\\n    src/loc_api_rpcgen_clnt.c \\\n    src/loc_api_rpcgen_xdr.c\n\n\n\nlibrary_includedir = $(pkgincludedir)/libloc_api-rpc-50001/libloc_api-rpc-stub/inc\nlibrary_include_HEADERS = $(h_sources)\nlibloc_api_rpcgen_la_SOURCES = $(c_sources) $(h_sources)\n\nif USE_GLIB\nlibloc_api_rpcgen_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@\nlibloc_api_rpcgen_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0\nlibloc_api_rpcgen_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@\nelse\nlibloc_api_rpcgen_la_CFLAGS = $(AM_CFLAGS)\nlibloc_api_rpcgen_la_LDFLAGS = -lpthread -shared -version-info 1:0:0\nlibloc_api_rpcgen_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)\nendif\n\nlibloc_api_rpcgen_la_LIBADD = $(requiredlibs) -lstdc++\n\n#Create and Install Libraries\nlib_LTLIBRARIES = libloc_api_rpcgen.la\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/inc/loc_api_rpcgen_cb_rpc.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#ifndef _LOC_API_CB_RPC_H_RPCGEN\n#define _LOC_API_CB_RPC_H_RPCGEN\n\n#include \"librpc.h\"\n#include \"commondefs_rpcgen_rpc.h\"\n#include \"loc_api_rpcgen_common_rpc.h\"\n\n#include <pthread.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\nstruct rpc_loc_event_cb_f_type_args {\n    rpc_uint32 cb_id;\n    rpc_loc_client_handle_type loc_handle;\n    rpc_loc_event_mask_type loc_event;\n    rpc_loc_event_payload_u_type *loc_event_payload;\n};\ntypedef struct rpc_loc_event_cb_f_type_args rpc_loc_event_cb_f_type_args;\n\nstruct rpc_loc_event_cb_f_type_rets {\n    rpc_int32 loc_event_cb_f_type_result;\n};\ntypedef struct rpc_loc_event_cb_f_type_rets rpc_loc_event_cb_f_type_rets;\n#define LOC_APICBVERS 0x00050006\n\n#define LOC_APICBPROG 0x3100008C\n#define LOC_APICBVERS_0001 0x00050001\n\n#if defined(__STDC__) || defined(__cplusplus)\n#define rpc_loc_event_cb_f_type 1\nextern  enum clnt_stat rpc_loc_event_cb_f_type_0x00050001(rpc_loc_event_cb_f_type_args *, rpc_loc_event_cb_f_type_rets *, CLIENT *);\nextern  bool_t rpc_loc_event_cb_f_type_0x00050001_svc(rpc_loc_event_cb_f_type_args *, rpc_loc_event_cb_f_type_rets *, struct svc_req *);\nextern int loc_apicbprog_0x00050001_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\n#define rpc_loc_event_cb_f_type 1\nextern  enum clnt_stat rpc_loc_event_cb_f_type_0x00050001();\nextern  bool_t rpc_loc_event_cb_f_type_0x00050001_svc();\nextern int loc_apicbprog_0x00050001_freeresult ();\n#endif /* K&R C */\n#define LOC_APICBVERS_0002 0x00050002\n\n#if defined(__STDC__) || defined(__cplusplus)\n#define rpc_loc_api_cb_null 0xffffff00\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050002(void *, int *, CLIENT *);\nextern  bool_t rpc_loc_api_cb_null_0x00050002_svc(void *, int *, struct svc_req *);\nextern int loc_apicbprog_0x00050002_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\n#define rpc_loc_api_cb_null 0xffffff00\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050002();\nextern  bool_t rpc_loc_api_cb_null_0x00050002_svc();\nextern int loc_apicbprog_0x00050002_freeresult ();\n#endif /* K&R C */\n#define LOC_APICBVERS_0003 0x00050003\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050003(void *, int *, CLIENT *);\nextern  bool_t rpc_loc_api_cb_null_0x00050003_svc(void *, int *, struct svc_req *);\nextern int loc_apicbprog_0x00050003_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050003();\nextern  bool_t rpc_loc_api_cb_null_0x00050003_svc();\nextern int loc_apicbprog_0x00050003_freeresult ();\n#endif /* K&R C */\n#define LOC_APICBVERS_0004 0x00050004\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050004(void *, int *, CLIENT *);\nextern  bool_t rpc_loc_api_cb_null_0x00050004_svc(void *, int *, struct svc_req *);\nextern int loc_apicbprog_0x00050004_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050004();\nextern  bool_t rpc_loc_api_cb_null_0x00050004_svc();\nextern int loc_apicbprog_0x00050004_freeresult ();\n#endif /* K&R C */\n#define LOC_APICBVERS_0005 0x00050005\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050005(void *, int *, CLIENT *);\nextern  bool_t rpc_loc_api_cb_null_0x00050005_svc(void *, int *, struct svc_req *);\nextern int loc_apicbprog_0x00050005_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050005();\nextern  bool_t rpc_loc_api_cb_null_0x00050005_svc();\nextern int loc_apicbprog_0x00050005_freeresult ();\n#endif /* K&R C */\n#define LOC_APICBVERS_0006 0x00050006\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050006(void *, int *, CLIENT *);\nextern  bool_t rpc_loc_api_cb_null_0x00050006_svc(void *, int *, struct svc_req *);\nextern int loc_apicbprog_0x00050006_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_cb_null_0x00050006();\nextern  bool_t rpc_loc_api_cb_null_0x00050006_svc();\nextern int loc_apicbprog_0x00050006_freeresult ();\n#endif /* K&R C */\n\n/* the xdr functions */\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  bool_t xdr_rpc_loc_event_cb_f_type_args (XDR *, rpc_loc_event_cb_f_type_args*);\nextern  bool_t xdr_rpc_loc_event_cb_f_type_rets (XDR *, rpc_loc_event_cb_f_type_rets*);\n\n#else /* K&R C */\nextern bool_t xdr_rpc_loc_event_cb_f_type_args ();\nextern bool_t xdr_rpc_loc_event_cb_f_type_rets ();\n\n#endif /* K&R C */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !_LOC_API_CB_RPC_H_RPCGEN */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/inc/loc_api_rpcgen_common_rpc.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#ifndef _LOC_API_COMMON_RPC_H_RPCGEN\n#define _LOC_API_COMMON_RPC_H_RPCGEN\n\n#include \"librpc.h\"\n#include \"commondefs_rpcgen_rpc.h\"\n\n#include <pthread.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define LOC_API_TOOLVERS 0x00040030\n#define LOC_API_FEATURES 0x00000001\n#define RPC_LOC_EVENT_STATUS_REPORT 0x00000100\n#define RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST 0x00000020\n#define RPC_LOC_EVENT_WPS_NEEDED_REQUEST 0x00000200\n#define RPC_LOC_EVENT_SATELLITE_REPORT 0x00000002\n#define RPC_LOC_EVENT_PARSED_POSITION_REPORT 0x00000001\n#define RPC_LOC_EVENT_RESERVED 0x8000000000000000\n#define RPC_LOC_EVENT_LOCATION_SERVER_REQUEST 0x00000040\n#define RPC_LOC_EVENT_NMEA_POSITION_REPORT 0x00000008\n#define RPC_LOC_EVENT_IOCTL_REPORT 0x00000080\n#define RPC_LOC_EVENT_NMEA_1HZ_REPORT 0x00000004\n#define RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST 0x00000010\n#define RPC_LOC_API_CB_NULL_VERSION 0x00050002\n#define RPC_LOC_EVENT_CB_F_TYPE_VERSION 0x00050001\n#define RPC_LOC_API_API_VERSIONS_VERSION 0x00050001\n#define RPC_LOC_STOP_FIX_VERSION 0x00050001\n#define RPC_LOC_START_FIX_VERSION 0x00050001\n#define RPC_LOC_IOCTL_VERSION 0x00050001\n#define RPC_LOC_CLOSE_VERSION 0x00050001\n#define RPC_LOC_API_RPC_GLUE_CODE_INFO_REMOTE_VERSION 0x00050001\n#define RPC_LOC_OPEN_VERSION 0x00050001\n#define RPC_LOC_API_NULL_VERSION 0x00050001\n#define RPC_LOC_API_API_MAJOR_NUM 0x0005\n#define RPC_LOC_APIAPI_VERSION_IS_HASHKEY 0\n\ntypedef rpc_int32 rpc_loc_client_handle_type;\n\ntypedef rpc_uint64 rpc_loc_event_mask_type;\n\ntypedef rpc_uint64 rpc_loc_position_valid_mask_type;\n\ntypedef rpc_uint32 rpc_loc_pos_technology_mask_type;\n\nenum rpc_loc_session_status_e_type {\n    RPC_LOC_SESS_STATUS_SUCCESS = 0,\n    RPC_LOC_SESS_STATUS_IN_PROGESS = 1,\n    RPC_LOC_SESS_STATUS_GENERAL_FAILURE = 2,\n    RPC_LOC_SESS_STATUS_TIMEOUT = 3,\n    RPC_LOC_SESS_STATUS_USER_END = 4,\n    RPC_LOC_SESS_STATUS_BAD_PARAMETER = 5,\n    RPC_LOC_SESS_STATUS_PHONE_OFFLINE = 6,\n    RPC_LOC_SESS_STATUS_ENGINE_LOCKED = 7,\n    RPC_LOC_SESS_STATUS_MAX = 268435456,\n};\ntypedef enum rpc_loc_session_status_e_type rpc_loc_session_status_e_type;\n\nstruct rpc_loc_calendar_time_s_type {\n    rpc_uint16 year;\n    u_char month;\n    u_char day_of_week;\n    u_char day;\n    u_char hour;\n    u_char minute;\n    u_char second;\n    rpc_uint16 millisecond;\n};\ntypedef struct rpc_loc_calendar_time_s_type rpc_loc_calendar_time_s_type;\n\nstruct rpc_loc_parsed_position_s_type {\n    rpc_loc_position_valid_mask_type valid_mask;\n    rpc_loc_session_status_e_type session_status;\n    rpc_loc_calendar_time_s_type timestamp_calendar;\n    rpc_uint64 timestamp_utc;\n    rpc_uint8 leap_seconds;\n    float time_unc;\n    double latitude;\n    double longitude;\n    float altitude_wrt_ellipsoid;\n    float altitude_wrt_mean_sea_level;\n    float speed_horizontal;\n    float speed_vertical;\n    float heading;\n    float hor_unc_circular;\n    float hor_unc_ellipse_semi_major;\n    float hor_unc_ellipse_semi_minor;\n    float hor_unc_ellipse_orient_azimuth;\n    float vert_unc;\n    float speed_unc;\n    float heading_unc;\n    u_char confidence_horizontal;\n    u_char confidence_vertical;\n    float magnetic_deviation;\n    rpc_loc_pos_technology_mask_type technology_mask;\n};\ntypedef struct rpc_loc_parsed_position_s_type rpc_loc_parsed_position_s_type;\n\nenum rpc_loc_sv_system_e_type {\n    RPC_LOC_SV_SYSTEM_GPS = 1,\n    RPC_LOC_SV_SYSTEM_GALILEO = 2,\n    RPC_LOC_SV_SYSTEM_SBAS = 3,\n    RPC_LOC_SV_SYSTEM_COMPASS = 4,\n    RPC_LOC_SV_SYSTEM_GLONASS = 5,\n    RPC_LOC_SV_SYSTEM_MAX = 268435456,\n};\ntypedef enum rpc_loc_sv_system_e_type rpc_loc_sv_system_e_type;\n\nenum rpc_loc_sv_status_e_type {\n    RPC_LOC_SV_STATUS_IDLE = 1,\n    RPC_LOC_SV_STATUS_SEARCH = 2,\n    RPC_LOC_SV_STATUS_TRACK = 3,\n    RPC_LOC_SV_STATUS_MAX = 268435456,\n};\ntypedef enum rpc_loc_sv_status_e_type rpc_loc_sv_status_e_type;\n\ntypedef rpc_uint32 rpc_loc_sv_info_valid_mask_type;\n\nstruct rpc_loc_sv_info_s_type {\n    rpc_loc_sv_info_valid_mask_type valid_mask;\n    rpc_loc_sv_system_e_type system;\n    rpc_uint8 prn;\n    rpc_uint8 health_status;\n    rpc_loc_sv_status_e_type process_status;\n    rpc_boolean has_eph;\n    rpc_boolean has_alm;\n    float elevation;\n    float azimuth;\n    float snr;\n};\ntypedef struct rpc_loc_sv_info_s_type rpc_loc_sv_info_s_type;\n\ntypedef rpc_uint32 rpc_loc_gnss_info_valid_mask_type;\n\nstruct rpc_loc_gnss_info_s_type {\n    rpc_loc_gnss_info_valid_mask_type valid_mask;\n    float position_dop;\n    float horizontal_dop;\n    float vertical_dop;\n    rpc_boolean altitude_assumed;\n    rpc_uint16 sv_count;\n    struct {\n        u_int sv_list_len;\n        rpc_loc_sv_info_s_type *sv_list_val;\n    } sv_list;\n};\ntypedef struct rpc_loc_gnss_info_s_type rpc_loc_gnss_info_s_type;\n\nstruct rpc_loc_nmea_report_s_type {\n    rpc_uint16 length;\n    char nmea_sentences[200];\n};\ntypedef struct rpc_loc_nmea_report_s_type rpc_loc_nmea_report_s_type;\n\nenum rpc_loc_status_event_e_type {\n    RPC_LOC_STATUS_EVENT_ENGINE_STATE = 1,\n    RPC_LOC_STATUS_EVENT_FIX_SESSION_STATE = 2,\n    RPC_LOC_STATUS_EVENT_MAX = 268435456,\n};\ntypedef enum rpc_loc_status_event_e_type rpc_loc_status_event_e_type;\n\nenum rpc_loc_engine_state_e_type {\n    RPC_LOC_ENGINE_STATE_ON = 1,\n    RPC_LOC_ENGINE_STATE_OFF = 2,\n    RPC_LOC_ENGINE_STATE_MAX = 268435456,\n};\ntypedef enum rpc_loc_engine_state_e_type rpc_loc_engine_state_e_type;\n\nenum rpc_loc_fix_session_state_e_type {\n    RPC_LOC_FIX_SESSION_STATE_BEGIN = 1,\n    RPC_LOC_FIX_SESSION_STATE_END = 2,\n    RPC_LOC_FIX_SESSION_STATE_MAX = 268435456,\n};\ntypedef enum rpc_loc_fix_session_state_e_type rpc_loc_fix_session_state_e_type;\n\nstruct rpc_loc_status_event_payload_u_type {\n    rpc_loc_status_event_e_type disc;\n    union {\n        rpc_loc_engine_state_e_type engine_state;\n        rpc_loc_fix_session_state_e_type fix_session_state;\n    } rpc_loc_status_event_payload_u_type_u;\n};\ntypedef struct rpc_loc_status_event_payload_u_type rpc_loc_status_event_payload_u_type;\n\nstruct rpc_loc_status_event_s_type {\n    rpc_loc_status_event_e_type event;\n    rpc_loc_status_event_payload_u_type payload;\n};\ntypedef struct rpc_loc_status_event_s_type rpc_loc_status_event_s_type;\n\nenum rpc_loc_server_addr_e_type {\n    RPC_LOC_SERVER_ADDR_IPV4 = 1,\n    RPC_LOC_SERVER_ADDR_URL = 2,\n    RPC_LOC_SERVER_ADDR_IPV6 = 3,\n    RPC_LOC_SERVER_ADDR_MAX = 268435456,\n};\ntypedef enum rpc_loc_server_addr_e_type rpc_loc_server_addr_e_type;\n\nstruct rpc_loc_server_addr_ipv4_type {\n    rpc_uint32 addr;\n    rpc_uint16 port;\n};\ntypedef struct rpc_loc_server_addr_ipv4_type rpc_loc_server_addr_ipv4_type;\n\nstruct rpc_loc_server_addr_url_type {\n    rpc_uint16 length;\n    char addr[256];\n};\ntypedef struct rpc_loc_server_addr_url_type rpc_loc_server_addr_url_type;\n\nstruct rpc_loc_server_addr_ipv6_type {\n    rpc_uint16 addr[8];\n    rpc_uint32 port;\n};\ntypedef struct rpc_loc_server_addr_ipv6_type rpc_loc_server_addr_ipv6_type;\n\nstruct rpc_loc_server_addr_u_type {\n    rpc_loc_server_addr_e_type disc;\n    union {\n        rpc_loc_server_addr_ipv4_type ipv4;\n        rpc_loc_server_addr_url_type url;\n        rpc_loc_server_addr_ipv6_type ipv6;\n    } rpc_loc_server_addr_u_type_u;\n};\ntypedef struct rpc_loc_server_addr_u_type rpc_loc_server_addr_u_type;\n\nstruct rpc_loc_server_info_s_type {\n    rpc_loc_server_addr_e_type addr_type;\n    rpc_loc_server_addr_u_type addr_info;\n};\ntypedef struct rpc_loc_server_info_s_type rpc_loc_server_info_s_type;\n\nenum rpc_loc_ni_notify_verify_e_type {\n    RPC_LOC_NI_USER_NO_NOTIFY_NO_VERIFY = 1,\n    RPC_LOC_NI_USER_NOTIFY_ONLY = 2,\n    RPC_LOC_NI_USER_NOTIFY_VERIFY_ALLOW_NO_RESP = 3,\n    RPC_LOC_NI_USER_NOTIFY_VERIFY_NOT_ALLOW_NO_RESP = 4,\n    RPC_LOC_NI_USER_PRIVACY_OVERRIDE = 5,\n    RPC_LOC_NI_USER_NOTIFY_VERITY_TYPE_MAX = 268435456,\n};\ntypedef enum rpc_loc_ni_notify_verify_e_type rpc_loc_ni_notify_verify_e_type;\n\nenum rpc_loc_ni_event_e_type {\n    RPC_LOC_NI_EVENT_VX_NOTIFY_VERIFY_REQ = 1,\n    RPC_LOC_NI_EVENT_SUPL_NOTIFY_VERIFY_REQ = 2,\n    RPC_LOC_NI_EVENT_UMTS_CP_NOTIFY_VERIFY_REQ = 3,\n    RPC_LOC_NI_EVENT_VX_SERVICE_INTERACTION_REQ = 4,\n    RPC_LOC_NI_EVENT_MAX = 268435456,\n};\ntypedef enum rpc_loc_ni_event_e_type rpc_loc_ni_event_e_type;\n\nenum rpc_loc_ni_datacoding_scheme_e_type {\n    RPC_LOC_NI_PRESUPL_ISO646IRV = 0,\n    RPC_LOC_NI_PRESUPL_ISO8859 = 1,\n    RPC_LOC_NI_PRESUPL_UTF8 = 2,\n    RPC_LOC_NI_PRESUPL_UTF16 = 3,\n    RPC_LOC_NI_PRESUPL_UCS2 = 4,\n    RPC_LOC_NI_PRESUPL_GSM_DEFAULT = 5,\n    RPC_LOC_NI_PRESUPL_SHIFT_JIS = 6,\n    RPC_LOC_NI_PRESUPL_JIS = 7,\n    RPC_LOC_NI_PRESUPL_EUC = 8,\n    RPC_LOC_NI_PRESUPL_GB2312 = 9,\n    RPC_LOC_NI_PRESUPL_CNS11643 = 10,\n    RPC_LOC_NI_PRESUPL_KSC1001 = 11,\n    RPC_LOC_NI_PRESUPL_ENCODING_UNKNOWN = 2147483647,\n    RPC_LOC_NI_SS_GERMAN = 12,\n    RPC_LOC_NI_SS_ENGLISH = 13,\n    RPC_LOC_NI_SS_ITALIAN = 14,\n    RPC_LOC_NI_SS_FRENCH = 15,\n    RPC_LOC_NI_SS_SPANISH = 16,\n    RPC_LOC_NI_SS_DUTCH = 17,\n    RPC_LOC_NI_SS_SWEDISH = 18,\n    RPC_LOC_NI_SS_DANISH = 19,\n    RPC_LOC_NI_SS_PORTUGUESE = 20,\n    RPC_LOC_NI_SS_FINNISH = 21,\n    RPC_LOC_NI_SS_NORWEGIAN = 22,\n    RPC_LOC_NI_SS_GREEK = 23,\n    RPC_LOC_NI_SS_TURKISH = 24,\n    RPC_LOC_NI_SS_HUNGARIAN = 25,\n    RPC_LOC_NI_SS_POLISH = 26,\n    RPC_LOC_NI_SS_LANGUAGE_UNSPEC = 27,\n    RPC_LOC_NI_SUPL_UTF8 = 28,\n    RPC_LOC_NI_SUPL_UCS2 = 29,\n    RPC_LOC_NI_SUPL_GSM_DEFAULT = 30,\n    RPC_LOC_NI_SUPL_ENCODING_UNKNOWN = 2147483647,\n};\ntypedef enum rpc_loc_ni_datacoding_scheme_e_type rpc_loc_ni_datacoding_scheme_e_type;\n\nenum rpc_loc_ni_vx_requester_id_encoding_scheme_e_type {\n    RPC_LOC_NI_VX_OCTET = 0,\n    RPC_LOC_NI_VX_EXN_PROTOCOL_MSG = 1,\n    RPC_LOC_NI_VX_ASCII = 2,\n    RPC_LOC_NI_VX_IA5 = 3,\n    RPC_LOC_NI_VX_UNICODE = 4,\n    RPC_LOC_NI_VX_SHIFT_JIS = 5,\n    RPC_LOC_NI_VX_KOREAN = 6,\n    RPC_LOC_NI_VX_LATIN_HEBREW = 7,\n    RPC_LOC_NI_VX_LATIN = 8,\n    RPC_LOC_NI_VX_GSM = 9,\n    RPC_LOC_NI_VX_ENCODING_TYPE_MAX = 268435456,\n};\ntypedef enum rpc_loc_ni_vx_requester_id_encoding_scheme_e_type rpc_loc_ni_vx_requester_id_encoding_scheme_e_type;\n\nenum rpc_loc_ni_vx_pos_mode_e_type {\n    RPC_LOC_VX_MS_ASSISTED_ONLY = 1,\n    RPC_LOC_VX_MS_BASED_ONLY = 2,\n    RPC_LOC_VX_MS_ASSISTED_PREF_MSBASED_ALLWD = 3,\n    RPC_LOC_VX_MS_BASED_PREF_ASSISTED_ALLWD = 4,\n    RPC_LOC_VX_POS_MODE_MAX = 268435456,\n};\ntypedef enum rpc_loc_ni_vx_pos_mode_e_type rpc_loc_ni_vx_pos_mode_e_type;\n\nstruct rpc_loc_ni_vx_requester_id_s_type {\n    u_char requester_id_length;\n    char requester_id[200];\n};\ntypedef struct rpc_loc_ni_vx_requester_id_s_type rpc_loc_ni_vx_requester_id_s_type;\n\nstruct rpc_loc_ni_vx_notify_verify_req_s_type {\n    rpc_loc_ni_notify_verify_e_type notification_priv_type;\n    u_char pos_qos_incl;\n    u_char pos_qos;\n    rpc_uint32 num_fixes;\n    rpc_uint32 tbf;\n    rpc_loc_ni_vx_pos_mode_e_type pos_mode;\n    rpc_loc_ni_vx_requester_id_encoding_scheme_e_type encoding_scheme;\n    rpc_loc_ni_vx_requester_id_s_type requester_id;\n    rpc_uint16 user_resp_timer_val;\n};\ntypedef struct rpc_loc_ni_vx_notify_verify_req_s_type rpc_loc_ni_vx_notify_verify_req_s_type;\n\nenum rpc_loc_ni_supl_pos_method_e_type {\n    RPC_LOC_NI_POSMETHOD_AGPS_SETASSISTED = 1,\n    RPC_LOC_NI_POSMETHOD_AGPS_SETBASED = 2,\n    RPC_LOC_NI_POSMETHOD_AGPS_SETASSISTED_PREF = 3,\n    RPC_LOC_NI_POSMETHOD_AGPS_SETBASED_PREF = 4,\n    RPC_LOC_NI_POSMETHOD_AUTONOMOUS_GPS = 5,\n    RPC_LOC_NI_POSMETHOD_AFLT = 6,\n    RPC_LOC_NI_POSMETHOD_ECID = 7,\n    RPC_LOC_NI_POSMETHOD_EOTD = 8,\n    RPC_LOC_NI_POSMETHOD_OTDOA = 9,\n    RPC_LOC_NI_POSMETHOD_NO_POSITION = 10,\n    RPC_LOC_NI_POSMETHOD_MAX = 268435456,\n};\ntypedef enum rpc_loc_ni_supl_pos_method_e_type rpc_loc_ni_supl_pos_method_e_type;\n\nstruct rpc_loc_ni_supl_slp_session_id_s_type {\n    u_char presence;\n    char session_id[4];\n    rpc_loc_server_info_s_type slp_address;\n};\ntypedef struct rpc_loc_ni_supl_slp_session_id_s_type rpc_loc_ni_supl_slp_session_id_s_type;\n\nstruct rpc_loc_ni_requestor_id_s_type {\n    u_char data_coding_scheme;\n    char requestor_id_string[200];\n    u_char string_len;\n};\ntypedef struct rpc_loc_ni_requestor_id_s_type rpc_loc_ni_requestor_id_s_type;\n\nstruct rpc_loc_ni_supl_client_name_s_type {\n    u_char data_coding_scheme;\n    char client_name_string[64];\n    u_char string_len;\n};\ntypedef struct rpc_loc_ni_supl_client_name_s_type rpc_loc_ni_supl_client_name_s_type;\n\nstruct rpc_loc_ni_supl_qop_s_type {\n    u_char bit_mask;\n    u_char horacc;\n    u_char veracc;\n    rpc_uint16 maxLocAge;\n    u_char delay;\n};\ntypedef struct rpc_loc_ni_supl_qop_s_type rpc_loc_ni_supl_qop_s_type;\n\nstruct rpc_loc_ni_supl_notify_verify_req_s_type {\n    rpc_loc_ni_notify_verify_e_type notification_priv_type;\n    rpc_uint16 flags;\n    rpc_loc_ni_supl_slp_session_id_s_type supl_slp_session_id;\n    char supl_hash[8];\n    rpc_loc_ni_datacoding_scheme_e_type datacoding_scheme;\n    rpc_loc_ni_supl_pos_method_e_type pos_method;\n    rpc_loc_ni_requestor_id_s_type requestor_id;\n    rpc_loc_ni_supl_client_name_s_type client_name;\n    rpc_loc_ni_supl_qop_s_type supl_qop;\n    rpc_uint16 user_response_timer;\n};\ntypedef struct rpc_loc_ni_supl_notify_verify_req_s_type rpc_loc_ni_supl_notify_verify_req_s_type;\n\nstruct rpc_loc_ni_ext_client_address_s_type {\n    u_char ext_client_address_len;\n    char ext_client_address[20];\n};\ntypedef struct rpc_loc_ni_ext_client_address_s_type rpc_loc_ni_ext_client_address_s_type;\n\nenum rpc_loc_ni_location_type_e_type {\n    RPC_LOC_NI_LOCATIONTYPE_CURRENT_LOCATION = 1,\n    RPC_LOC_NI_LOCATIONTYPE_CURRENT_OR_LAST_KNOWN_LOCATION = 2,\n    RPC_LOC_NI_LOCATIONTYPE_INITIAL_LOCATION = 3,\n    RPC_LOC_NI_LOCATIONTYPE_MAX = 268435456,\n};\ntypedef enum rpc_loc_ni_location_type_e_type rpc_loc_ni_location_type_e_type;\n\nstruct rpc_loc_ni_deferred_location_s_type {\n    u_char unused_bits;\n    u_char ms_available;\n};\ntypedef struct rpc_loc_ni_deferred_location_s_type rpc_loc_ni_deferred_location_s_type;\n\nstruct rpc_loc_ni_codeword_string_s_type {\n    u_char data_coding_scheme;\n    char lcs_codeword_string[20];\n    u_char string_len;\n};\ntypedef struct rpc_loc_ni_codeword_string_s_type rpc_loc_ni_codeword_string_s_type;\n\nstruct rpc_loc_ni_service_type_id_s_type {\n    u_char lcs_service_type_id;\n};\ntypedef struct rpc_loc_ni_service_type_id_s_type rpc_loc_ni_service_type_id_s_type;\n\nstruct rpc_loc_ni_umts_cp_notify_verify_req_s_type {\n    rpc_loc_ni_notify_verify_e_type notification_priv_type;\n    u_char invoke_id;\n    rpc_uint16 flags;\n    u_char notification_length;\n    char notification_text[64];\n    rpc_loc_ni_datacoding_scheme_e_type datacoding_scheme;\n    rpc_loc_ni_ext_client_address_s_type ext_client_address_data;\n    rpc_loc_ni_location_type_e_type location_type;\n    rpc_loc_ni_deferred_location_s_type deferred_location;\n    rpc_loc_ni_requestor_id_s_type requestor_id;\n    rpc_loc_ni_codeword_string_s_type codeword_string;\n    rpc_loc_ni_service_type_id_s_type service_type_id;\n    rpc_uint16 user_response_timer;\n};\ntypedef struct rpc_loc_ni_umts_cp_notify_verify_req_s_type rpc_loc_ni_umts_cp_notify_verify_req_s_type;\n\nenum rpc_loc_ni_service_interaction_e_type {\n    RPC_LOC_NI_SERVICE_INTERACTION_ONGOING_NI_INCOMING_MO = 1,\n    RPC_LOC_NI_SERVICE_INTERACTION_MAX = 268435456,\n};\ntypedef enum rpc_loc_ni_service_interaction_e_type rpc_loc_ni_service_interaction_e_type;\n\nstruct rpc_loc_ni_vx_service_interaction_req_s_type {\n    rpc_loc_ni_vx_notify_verify_req_s_type ni_vx_req;\n    rpc_loc_ni_service_interaction_e_type service_interation_type;\n};\ntypedef struct rpc_loc_ni_vx_service_interaction_req_s_type rpc_loc_ni_vx_service_interaction_req_s_type;\n\nstruct rpc_loc_ni_event_payload_u_type {\n    rpc_loc_ni_event_e_type disc;\n    union {\n        rpc_loc_ni_vx_notify_verify_req_s_type vx_req;\n        rpc_loc_ni_supl_notify_verify_req_s_type supl_req;\n        rpc_loc_ni_umts_cp_notify_verify_req_s_type umts_cp_req;\n        rpc_loc_ni_vx_service_interaction_req_s_type service_interaction_req;\n    } rpc_loc_ni_event_payload_u_type_u;\n};\ntypedef struct rpc_loc_ni_event_payload_u_type rpc_loc_ni_event_payload_u_type;\n\nstruct rpc_loc_ni_event_s_type {\n    rpc_loc_ni_event_e_type event;\n    rpc_loc_ni_event_payload_u_type payload;\n};\ntypedef struct rpc_loc_ni_event_s_type rpc_loc_ni_event_s_type;\n\nenum rpc_loc_assist_data_request_e_type {\n    RPC_LOC_ASSIST_DATA_TIME_REQ = 1,\n    RPC_LOC_ASSIST_DATA_PREDICTED_ORBITS_REQ = 2,\n    RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ = 3,\n    RPC_LOC_ASSIST_DATA_MAX = 268435456,\n};\ntypedef enum rpc_loc_assist_data_request_e_type rpc_loc_assist_data_request_e_type;\n\ntypedef char *rpc_struct_loc_time_download_source_s_type_servers_ptr;\n\ntypedef rpc_struct_loc_time_download_source_s_type_servers_ptr rpc_struct_loc_time_download_source_s_type_servers[3];\n\nstruct rpc_loc_time_download_source_s_type {\n    rpc_uint32 delay_threshold;\n    rpc_struct_loc_time_download_source_s_type_servers servers;\n};\ntypedef struct rpc_loc_time_download_source_s_type rpc_loc_time_download_source_s_type;\n\ntypedef char *rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr;\n\ntypedef rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr rpc_struct_loc_predicted_orbits_data_source_s_type_servers[3];\n\nstruct rpc_loc_predicted_orbits_data_source_s_type {\n    rpc_uint32 max_file_size;\n    rpc_uint32 max_part_size;\n    rpc_struct_loc_predicted_orbits_data_source_s_type_servers servers;\n};\ntypedef struct rpc_loc_predicted_orbits_data_source_s_type rpc_loc_predicted_orbits_data_source_s_type;\n\nstruct rpc_loc_pos_inj_request_s_type {\n    rpc_uint32 flags;\n    double latitude;\n    double longitude;\n    rpc_uint32 position_uncertainty;\n    rpc_uint64 timestamp;\n};\ntypedef struct rpc_loc_pos_inj_request_s_type rpc_loc_pos_inj_request_s_type;\n\nstruct rpc_loc_assist_data_request_payload_u_type {\n    rpc_loc_assist_data_request_e_type disc;\n    union {\n        rpc_loc_time_download_source_s_type time_download;\n        rpc_loc_predicted_orbits_data_source_s_type data_download;\n        rpc_loc_pos_inj_request_s_type pos_injection;\n    } rpc_loc_assist_data_request_payload_u_type_u;\n};\ntypedef struct rpc_loc_assist_data_request_payload_u_type rpc_loc_assist_data_request_payload_u_type;\n\nstruct rpc_loc_assist_data_request_s_type {\n    rpc_loc_assist_data_request_e_type event;\n    rpc_loc_assist_data_request_payload_u_type payload;\n};\ntypedef struct rpc_loc_assist_data_request_s_type rpc_loc_assist_data_request_s_type;\n\ntypedef rpc_uint32 rpc_loc_server_connection_handle;\n\nenum rpc_loc_server_protocol_e_type {\n    RPC_LOC_SERVER_PROTOCOL_DEFAULT = 0,\n    RPC_LOC_SERVER_PROTOCOL_SUPL = 1,\n    RPC_LOC_SERVER_PROTOCOL_VX_MPC = 2,\n    RPC_LOC_SERVER_PROTOCOL_VX_PDE = 3,\n    RPC_LOC_SERVER_PROTOCOL_MAX = 16777216,\n};\ntypedef enum rpc_loc_server_protocol_e_type rpc_loc_server_protocol_e_type;\n\nenum rpc_loc_server_connection_e_type {\n    RPC_LOC_SERVER_CONNECTION_LBS = 0,\n    RPC_LOC_SERVER_CONNECTION_WWAN_INTERNET = 0 + 1,\n    RPC_LOC_SERVER_CONNECTION_MAX = 16777216,\n};\ntypedef enum rpc_loc_server_connection_e_type rpc_loc_server_connection_e_type;\n\nenum rpc_loc_server_request_e_type {\n    RPC_LOC_SERVER_REQUEST_OPEN = 1,\n    RPC_LOC_SERVER_REQUEST_CLOSE = 2,\n    RPC_LOC_SERVER_REQUEST_MULTI_OPEN = 3,\n    RPC_LOC_SERVER_REQUEST_MAX = 268435456,\n};\ntypedef enum rpc_loc_server_request_e_type rpc_loc_server_request_e_type;\n\nstruct rpc_loc_server_open_req_s_type {\n    rpc_loc_server_connection_handle conn_handle;\n    rpc_loc_server_protocol_e_type protocol;\n};\ntypedef struct rpc_loc_server_open_req_s_type rpc_loc_server_open_req_s_type;\n\nstruct rpc_loc_server_multi_open_req_s_type {\n    rpc_loc_server_connection_handle conn_handle;\n    rpc_loc_server_protocol_e_type protocol;\n    rpc_loc_server_connection_e_type connection_type;\n};\ntypedef struct rpc_loc_server_multi_open_req_s_type rpc_loc_server_multi_open_req_s_type;\n\nstruct rpc_loc_server_close_req_s_type {\n    rpc_loc_server_connection_handle conn_handle;\n};\ntypedef struct rpc_loc_server_close_req_s_type rpc_loc_server_close_req_s_type;\n\nstruct rpc_loc_server_request_u_type {\n    rpc_loc_server_request_e_type disc;\n    union {\n        rpc_loc_server_open_req_s_type open_req;\n        rpc_loc_server_close_req_s_type close_req;\n        rpc_loc_server_multi_open_req_s_type multi_open_req;\n    } rpc_loc_server_request_u_type_u;\n};\ntypedef struct rpc_loc_server_request_u_type rpc_loc_server_request_u_type;\n\nstruct rpc_loc_server_request_s_type {\n    rpc_loc_server_request_e_type event;\n    rpc_loc_server_request_u_type payload;\n};\ntypedef struct rpc_loc_server_request_s_type rpc_loc_server_request_s_type;\n\nenum rpc_loc_qwip_request_e_type {\n    RPC_LOC_QWIP_START_PERIODIC_HI_FREQ_FIXES = 0,\n    RPC_LOC_QWIP_START_PERIODIC_KEEP_WARM = 0 + 1,\n    RPC_LOC_QWIP_STOP_PERIODIC_FIXES = 0 + 2,\n    RPC_LOC_QWIP_SUSPEND = 0 + 3,\n    RPC_LOC_QWIP_REQUEST_MAX = 268435456,\n};\ntypedef enum rpc_loc_qwip_request_e_type rpc_loc_qwip_request_e_type;\n\nstruct rpc_loc_qwip_request_s_type {\n    rpc_loc_qwip_request_e_type request_type;\n    rpc_uint16 tbf_ms;\n};\ntypedef struct rpc_loc_qwip_request_s_type rpc_loc_qwip_request_s_type;\n\nstruct rpc_loc_reserved_payload_s_type {\n    rpc_uint16 data_size;\n    struct {\n        u_int data_len;\n        char *data_val;\n    } data;\n};\ntypedef struct rpc_loc_reserved_payload_s_type rpc_loc_reserved_payload_s_type;\n\nenum rpc_loc_ioctl_e_type {\n    RPC_LOC_IOCTL_GET_API_VERSION = 1,\n    RPC_LOC_IOCTL_SET_FIX_CRITERIA = 2,\n    RPC_LOC_IOCTL_GET_FIX_CRITERIA = 3,\n    RPC_LOC_IOCTL_SERVICE_START_INDEX = 400,\n    RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE = 400,\n    RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA = 401,\n    RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY = 402,\n    RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE = 403,\n    RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD = 404,\n    RPC_LOC_IOCTL_INJECT_UTC_TIME = 405,\n    RPC_LOC_IOCTL_INJECT_RTC_VALUE = 406,\n    RPC_LOC_IOCTL_INJECT_POSITION = 407,\n    RPC_LOC_IOCTL_QUERY_ENGINE_STATE = 408,\n    RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS = 409,\n    RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS = 410,\n    RPC_LOC_IOCTL_SEND_WIPER_POSITION_REPORT = 411,\n    RPC_LOC_IOCTL_NOTIFY_WIPER_STATUS = 412,\n    RPC_LOC_IOCTL_ACCESS_EFS_DATA = 413,\n    RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG = 414,\n    RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS = 415,\n    RPC_LOC_IOCTL_NV_SETTINGS_START_INDEX = 800,\n    RPC_LOC_IOCTL_SET_ENGINE_LOCK = 800,\n    RPC_LOC_IOCTL_GET_ENGINE_LOCK = 801,\n    RPC_LOC_IOCTL_SET_SBAS_CONFIG = 802,\n    RPC_LOC_IOCTL_GET_SBAS_CONFIG = 803,\n    RPC_LOC_IOCTL_SET_NMEA_TYPES = 804,\n    RPC_LOC_IOCTL_GET_NMEA_TYPES = 805,\n    RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR = 806,\n    RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR = 807,\n    RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR = 808,\n    RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR = 809,\n    RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR = 810,\n    RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR = 811,\n    RPC_LOC_IOCTL_SET_ON_DEMAND_LPM = 812,\n    RPC_LOC_IOCTL_GET_ON_DEMAND_LPM = 813,\n    RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL = 814,\n    RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL = 815,\n    RPC_LOC_IOCTL_SET_LBS_APN_PROFILE = 816,\n    RPC_LOC_IOCTL_GET_LBS_APN_PROFILE = 817,\n    RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE = 818,\n    RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE = 819,\n    RPC_LOC_IOCTL_SET_DATA_ENABLE = 820,\n    RPC_LOC_IOCTL_SET_SUPL_VERSION = 821,\n    RPC_LOC_IOCTL_GET_SUPL_VERSION = 822,\n    RPC_LOC_IOCTL_PROPRIETARY_START_INDEX = 1000,\n    RPC_LOC_IOCTL_DELETE_ASSIST_DATA = 1000,\n    RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR = 1001,\n    RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR = 1002,\n    RPC_LOC_IOCTL_RESERVED_CMD = 8000,\n    RPC_LOC_IOCTL_THIRD_PARTY_START_INDEX = 1073741824,\n};\ntypedef enum rpc_loc_ioctl_e_type rpc_loc_ioctl_e_type;\n\nstruct rpc_loc_api_version_s_type {\n    u_char major;\n    u_char minor;\n};\ntypedef struct rpc_loc_api_version_s_type rpc_loc_api_version_s_type;\n\nenum rpc_loc_fix_recurrence_e_type {\n    RPC_LOC_PERIODIC_FIX = 1,\n    RPC_LOC_SINGLE_FIX = 2,\n    RPC_LOC_FIX_SESSION_TYPE_MAX = 268435456,\n};\ntypedef enum rpc_loc_fix_recurrence_e_type rpc_loc_fix_recurrence_e_type;\n\nenum rpc_loc_operation_mode_e_type {\n    RPC_LOC_OPER_MODE_DEFAULT = 1,\n    RPC_LOC_OPER_MODE_MSB = 2,\n    RPC_LOC_OPER_MODE_MSA = 3,\n    RPC_LOC_OPER_MODE_STANDALONE = 4,\n    RPC_LOC_OPER_MODE_SPEED_OPTIMAL = 5,\n    RPC_LOC_OPER_MODE_ACCURACY_OPTIMAL = 6,\n    RPC_LOC_OPER_MODE_DATA_OPTIMAL = 7,\n    RPC_LOC_OPER_MODE_CELL_ID = 8,\n    RPC_LOC_OPER_MODE_MAX = 268435456,\n};\ntypedef enum rpc_loc_operation_mode_e_type rpc_loc_operation_mode_e_type;\n\nenum rpc_loc_notify_e_type {\n    RPC_LOC_NOTIFY_ON_INTERVAL = 1,\n    RPC_LOC_NOTIFY_ON_DISTANCE = 2,\n    RPC_LOC_NOTIFY_ON_ANY = 3,\n    RPC_LOC_NOTIFY_ON_ALL = 4,\n    RPC_LOC_NOTIFY_TYPE_MAX = 268435456,\n};\ntypedef enum rpc_loc_notify_e_type rpc_loc_notify_e_type;\n\nstruct rpc_loc_fix_criteria_s_type {\n    rpc_uint32 valid_mask;\n    rpc_loc_fix_recurrence_e_type recurrence_type;\n    rpc_loc_operation_mode_e_type preferred_operation_mode;\n    rpc_uint32 preferred_accuracy;\n    rpc_uint32 preferred_response_time;\n    rpc_boolean intermediate_pos_report_enabled;\n    rpc_loc_notify_e_type notify_type;\n    rpc_uint32 min_interval;\n    float min_distance;\n    rpc_uint32 min_dist_sample_interval;\n};\ntypedef struct rpc_loc_fix_criteria_s_type rpc_loc_fix_criteria_s_type;\n\nenum rpc_loc_ni_user_resp_e_type {\n    RPC_LOC_NI_LCS_NOTIFY_VERIFY_ACCEPT = 1,\n    RPC_LOC_NI_LCS_NOTIFY_VERIFY_DENY = 2,\n    RPC_LOC_NI_LCS_NOTIFY_VERIFY_NORESP = 3,\n    RPC_LOC_NI_LCS_NOTIFY_VERIFY_MAX = 268435456,\n};\ntypedef enum rpc_loc_ni_user_resp_e_type rpc_loc_ni_user_resp_e_type;\n\nstruct rpc_loc_user_verify_s_type {\n    rpc_loc_ni_user_resp_e_type user_resp;\n    rpc_loc_ni_event_s_type ni_event_pass_back;\n};\ntypedef struct rpc_loc_user_verify_s_type rpc_loc_user_verify_s_type;\n\nenum rpc_loc_predicted_orbits_data_format_e_type {\n    RPC_LOC_PREDICTED_ORBITS_XTRA = 0,\n    RPC_LOC_PREDICTED_ORBITS_FORMAT_MAX = 268435456,\n};\ntypedef enum rpc_loc_predicted_orbits_data_format_e_type rpc_loc_predicted_orbits_data_format_e_type;\n\nstruct rpc_loc_predicted_orbits_data_s_type {\n    rpc_loc_predicted_orbits_data_format_e_type format_type;\n    rpc_uint32 total_size;\n    rpc_uint8 total_parts;\n    rpc_uint8 part;\n    rpc_uint16 part_len;\n    struct {\n        u_int data_ptr_len;\n        char *data_ptr_val;\n    } data_ptr;\n};\ntypedef struct rpc_loc_predicted_orbits_data_s_type rpc_loc_predicted_orbits_data_s_type;\n\nstruct rpc_loc_predicted_orbits_data_validity_report_s_type {\n    rpc_uint64 start_time_utc;\n    rpc_uint16 valid_duration_hrs;\n};\ntypedef struct rpc_loc_predicted_orbits_data_validity_report_s_type rpc_loc_predicted_orbits_data_validity_report_s_type;\n\nstruct rpc_loc_predicted_orbits_auto_download_config_s_type {\n    rpc_boolean enable;\n    u_char auto_check_every_hrs;\n};\ntypedef struct rpc_loc_predicted_orbits_auto_download_config_s_type rpc_loc_predicted_orbits_auto_download_config_s_type;\n\nstruct rpc_loc_assist_data_time_s_type {\n    rpc_uint64 time_utc;\n    rpc_uint32 uncertainty;\n};\ntypedef struct rpc_loc_assist_data_time_s_type rpc_loc_assist_data_time_s_type;\n\ntypedef rpc_uint64 rpc_loc_assist_pos_valid_mask_type;\n\nstruct rpc_loc_assist_data_pos_s_type {\n    rpc_loc_assist_pos_valid_mask_type valid_mask;\n    rpc_uint64 timestamp_utc;\n    double latitude;\n    double longitude;\n    float altitude_wrt_ellipsoid;\n    float altitude_wrt_mean_sea_level;\n    float hor_unc_circular;\n    float vert_unc;\n    u_char confidence_horizontal;\n    u_char confidence_vertical;\n    rpc_int32 timestamp_age;\n};\ntypedef struct rpc_loc_assist_data_pos_s_type rpc_loc_assist_data_pos_s_type;\n\nenum rpc_loc_server_open_status_e_type {\n    RPC_LOC_SERVER_OPEN_SUCCESS = 1,\n    RPC_LOC_SERVER_OPEN_FAIL = 2,\n    RPC_LOC_SERVER_OPEN_STATUS_MAX = 268435456,\n};\ntypedef enum rpc_loc_server_open_status_e_type rpc_loc_server_open_status_e_type;\n\nenum rpc_loc_server_pdp_type_e_type {\n    RPC_LOC_SERVER_PDP_IP = 0,\n    RPC_LOC_SERVER_PDP_PPP = 0 + 1,\n    RPC_LOC_SERVER_PDP_IPV6 = 0 + 2,\n    RPC_LOC_SERVER_PDP_IPV4V6 = 0 + 3,\n    RPC_LOC_SERVER_PDP_MAX = 268435456,\n};\ntypedef enum rpc_loc_server_pdp_type_e_type rpc_loc_server_pdp_type_e_type;\n\nstruct rpc_loc_server_open_status_s_type {\n    rpc_loc_server_connection_handle conn_handle;\n    rpc_loc_server_open_status_e_type open_status;\n    char apn_name[100];\n};\ntypedef struct rpc_loc_server_open_status_s_type rpc_loc_server_open_status_s_type;\n\nstruct rpc_loc_server_multi_open_status_s_type {\n    rpc_loc_server_connection_handle conn_handle;\n    rpc_loc_server_open_status_e_type open_status;\n    rpc_loc_server_pdp_type_e_type pdp_type;\n    char apn_name[100];\n};\ntypedef struct rpc_loc_server_multi_open_status_s_type rpc_loc_server_multi_open_status_s_type;\n\nenum rpc_loc_server_close_status_e_type {\n    RPC_LOC_SERVER_CLOSE_SUCCESS = 1,\n    RPC_LOC_SERVER_CLOSE_FAIL = 2,\n    RPC_LOC_SERVER_CLOSE_STATUS_MAX = 268435456,\n};\ntypedef enum rpc_loc_server_close_status_e_type rpc_loc_server_close_status_e_type;\n\nstruct rpc_loc_server_close_status_s_type {\n    rpc_loc_server_connection_handle conn_handle;\n    rpc_loc_server_close_status_e_type close_status;\n};\ntypedef struct rpc_loc_server_close_status_s_type rpc_loc_server_close_status_s_type;\n\nstruct rpc_loc_wiper_fix_time_s_type {\n    rpc_uint32 slow_clock_count;\n};\ntypedef struct rpc_loc_wiper_fix_time_s_type rpc_loc_wiper_fix_time_s_type;\n\nstruct rpc_loc_wiper_fix_pos_s_type {\n    rpc_int32 lat;\n    rpc_int32 lon;\n    rpc_uint16 HEPE;\n    rpc_uint8 num_of_aps_used;\n    rpc_uint8 fix_error_code;\n};\ntypedef struct rpc_loc_wiper_fix_pos_s_type rpc_loc_wiper_fix_pos_s_type;\n\nstruct rpc_loc_wiper_ap_info_s_type {\n    char mac_addr[6];\n    rpc_int32 rssi;\n    rpc_uint16 channel;\n    rpc_uint8 ap_qualifier;\n};\ntypedef struct rpc_loc_wiper_ap_info_s_type rpc_loc_wiper_ap_info_s_type;\n\nstruct rpc_loc_wiper_ap_set_s_type {\n    rpc_uint8 num_of_aps;\n    rpc_loc_wiper_ap_info_s_type ap_info[50];\n};\ntypedef struct rpc_loc_wiper_ap_set_s_type rpc_loc_wiper_ap_set_s_type;\n\nstruct rpc_loc_wiper_position_report_s_type {\n    rpc_uint8 wiper_valid_info_flag;\n    rpc_loc_wiper_fix_time_s_type wiper_fix_time;\n    rpc_loc_wiper_fix_pos_s_type wiper_fix_position;\n    rpc_loc_wiper_ap_set_s_type wiper_ap_set;\n};\ntypedef struct rpc_loc_wiper_position_report_s_type rpc_loc_wiper_position_report_s_type;\n\nenum rpc_loc_wiper_status_e_type {\n    RPC_LOC_WIPER_STATUS_AVAILABLE = 1,\n    RPC_LOC_WIPER_STATUS_UNAVAILABLE = 2,\n    RPC_LOC_WIPER_STATUS_E_SIZE = 268435456,\n};\ntypedef enum rpc_loc_wiper_status_e_type rpc_loc_wiper_status_e_type;\n\nenum rpc_loc_fs_operation_e_type {\n    RPC_LOC_FS_CREATE_WRITE_FILE = 1,\n    RPC_LOC_FS_APPEND_FILE = 2,\n    RPC_LOC_FS_DELETE_FILE = 3,\n    RPC_LOC_FS_READ_FILE = 4,\n    RPC_LOC_FS_MAX = 268435456,\n};\ntypedef enum rpc_loc_fs_operation_e_type rpc_loc_fs_operation_e_type;\n\nstruct rpc_loc_efs_data_s_type {\n    char filename[64];\n    rpc_loc_fs_operation_e_type operation;\n    rpc_uint32 total_size;\n    struct {\n        u_int data_ptr_len;\n        char *data_ptr_val;\n    } data_ptr;\n    rpc_uint32 part_len;\n    rpc_uint8 part;\n    rpc_uint8 total_parts;\n    rpc_uint32 reserved;\n};\ntypedef struct rpc_loc_efs_data_s_type rpc_loc_efs_data_s_type;\n\nenum rpc_loc_error_estimate_config_e_type {\n    RPC_LOC_ERROR_ESTIMATE_CONFIG_SET = 1,\n    RPC_LOC_ERROR_ESTIMATE_CONFIG_CLEAR = 2,\n    RPC_LOC_ERROR_ESTIMATE_MAX = 268435456,\n};\ntypedef enum rpc_loc_error_estimate_config_e_type rpc_loc_error_estimate_config_e_type;\n\nstruct rpc_loc_apn_profiles_type {\n    rpc_uint32 srv_system_type;\n    rpc_uint32 pdp_type;\n    rpc_uint32 reserved;\n    char apn_name[100];\n};\ntypedef struct rpc_loc_apn_profiles_type rpc_loc_apn_profiles_type;\n\nenum rpc_loc_lock_e_type {\n    RPC_LOC_LOCK_NONE = 1,\n    RPC_LOC_LOCK_MI = 2,\n    RPC_LOC_LOCK_MT = 3,\n    RPC_LOC_LOCK_ALL = 4,\n    RPC_LOC_LOCK_MAX = 268435456,\n};\ntypedef enum rpc_loc_lock_e_type rpc_loc_lock_e_type;\n\ntypedef rpc_uint32 rpc_loc_nmea_sentence_type;\n\ntypedef rpc_uint32 rpc_loc_assist_data_type;\n\nstruct rpc_loc_assist_data_delete_s_type {\n    rpc_loc_assist_data_type type;\n    rpc_uint32 reserved[8];\n};\ntypedef struct rpc_loc_assist_data_delete_s_type rpc_loc_assist_data_delete_s_type;\n\nstruct rpc_loc_ioctl_data_u_type {\n    rpc_loc_ioctl_e_type disc;\n    union {\n        rpc_loc_fix_criteria_s_type fix_criteria;\n        rpc_loc_user_verify_s_type user_verify_resp;\n        rpc_loc_predicted_orbits_data_s_type predicted_orbits_data;\n        rpc_loc_predicted_orbits_auto_download_config_s_type predicted_orbits_auto_download;\n        rpc_loc_assist_data_time_s_type assistance_data_time;\n        rpc_loc_assist_data_pos_s_type assistance_data_position;\n        rpc_loc_server_open_status_s_type conn_open_status;\n        rpc_loc_server_close_status_s_type conn_close_status;\n        rpc_loc_wiper_position_report_s_type wiper_pos;\n        rpc_loc_wiper_status_e_type wiper_status;\n        rpc_loc_lock_e_type engine_lock;\n        rpc_boolean sbas_mode;\n        rpc_loc_nmea_sentence_type nmea_types;\n        rpc_boolean on_demand_lpm;\n        rpc_loc_server_info_s_type server_addr;\n        rpc_loc_assist_data_delete_s_type assist_data_delete;\n        rpc_loc_efs_data_s_type efs_data;\n        rpc_loc_error_estimate_config_e_type error_estimate_config;\n        rpc_uint8 xtra_t_session_control;\n        rpc_loc_apn_profiles_type apn_profiles[6];\n        rpc_boolean data_enable;\n        rpc_uint32 supl_version;\n        rpc_loc_server_multi_open_status_s_type multi_conn_open_status;\n        rpc_loc_reserved_payload_s_type reserved;\n    } rpc_loc_ioctl_data_u_type_u;\n};\ntypedef struct rpc_loc_ioctl_data_u_type rpc_loc_ioctl_data_u_type;\n\nstruct rpc_loc_ioctl_callback_data_u_type {\n    rpc_loc_ioctl_e_type disc;\n    union {\n        rpc_loc_api_version_s_type api_version;\n        rpc_loc_fix_criteria_s_type fix_criteria;\n        rpc_loc_lock_e_type engine_lock;\n        rpc_boolean sbas_mode;\n        rpc_loc_nmea_sentence_type nmea_types;\n        rpc_boolean on_demand_lpm;\n        rpc_loc_server_info_s_type server_addr;\n        rpc_loc_predicted_orbits_data_source_s_type predicted_orbits_data_source;\n        rpc_loc_predicted_orbits_data_validity_report_s_type predicted_orbits_data_validity;\n        rpc_uint8 xtra_t_session_control;\n        rpc_loc_apn_profiles_type apn_profiles[6];\n        rpc_uint32 supl_version;\n    } rpc_loc_ioctl_callback_data_u_type_u;\n};\ntypedef struct rpc_loc_ioctl_callback_data_u_type rpc_loc_ioctl_callback_data_u_type;\n\nstruct rpc_loc_ioctl_callback_s_type {\n    rpc_loc_ioctl_e_type type;\n    rpc_int32 status;\n    rpc_loc_ioctl_callback_data_u_type data;\n};\ntypedef struct rpc_loc_ioctl_callback_s_type rpc_loc_ioctl_callback_s_type;\n\nstruct rpc_loc_event_payload_u_type {\n    u_quad_t disc;\n    union {\n        rpc_loc_parsed_position_s_type parsed_location_report;\n        rpc_loc_gnss_info_s_type gnss_report;\n        rpc_loc_nmea_report_s_type nmea_report;\n        rpc_loc_ni_event_s_type ni_request;\n        rpc_loc_assist_data_request_s_type assist_data_request;\n        rpc_loc_server_request_s_type loc_server_request;\n        rpc_loc_ioctl_callback_s_type ioctl_report;\n        rpc_loc_status_event_s_type status_report;\n        rpc_loc_qwip_request_s_type qwip_request;\n        rpc_loc_reserved_payload_s_type reserved;\n    } rpc_loc_event_payload_u_type_u;\n};\ntypedef struct rpc_loc_event_payload_u_type rpc_loc_event_payload_u_type;\n\n/* the xdr functions */\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  bool_t xdr_rpc_loc_client_handle_type (XDR *, rpc_loc_client_handle_type*);\nextern  bool_t xdr_rpc_loc_event_mask_type (XDR *, rpc_loc_event_mask_type*);\nextern  bool_t xdr_rpc_loc_position_valid_mask_type (XDR *, rpc_loc_position_valid_mask_type*);\nextern  bool_t xdr_rpc_loc_pos_technology_mask_type (XDR *, rpc_loc_pos_technology_mask_type*);\nextern  bool_t xdr_rpc_loc_session_status_e_type (XDR *, rpc_loc_session_status_e_type*);\nextern  bool_t xdr_rpc_loc_calendar_time_s_type (XDR *, rpc_loc_calendar_time_s_type*);\nextern  bool_t xdr_rpc_loc_parsed_position_s_type (XDR *, rpc_loc_parsed_position_s_type*);\nextern  bool_t xdr_rpc_loc_sv_system_e_type (XDR *, rpc_loc_sv_system_e_type*);\nextern  bool_t xdr_rpc_loc_sv_status_e_type (XDR *, rpc_loc_sv_status_e_type*);\nextern  bool_t xdr_rpc_loc_sv_info_valid_mask_type (XDR *, rpc_loc_sv_info_valid_mask_type*);\nextern  bool_t xdr_rpc_loc_sv_info_s_type (XDR *, rpc_loc_sv_info_s_type*);\nextern  bool_t xdr_rpc_loc_gnss_info_valid_mask_type (XDR *, rpc_loc_gnss_info_valid_mask_type*);\nextern  bool_t xdr_rpc_loc_gnss_info_s_type (XDR *, rpc_loc_gnss_info_s_type*);\nextern  bool_t xdr_rpc_loc_nmea_report_s_type (XDR *, rpc_loc_nmea_report_s_type*);\nextern  bool_t xdr_rpc_loc_status_event_e_type (XDR *, rpc_loc_status_event_e_type*);\nextern  bool_t xdr_rpc_loc_engine_state_e_type (XDR *, rpc_loc_engine_state_e_type*);\nextern  bool_t xdr_rpc_loc_fix_session_state_e_type (XDR *, rpc_loc_fix_session_state_e_type*);\nextern  bool_t xdr_rpc_loc_status_event_payload_u_type (XDR *, rpc_loc_status_event_payload_u_type*);\nextern  bool_t xdr_rpc_loc_status_event_s_type (XDR *, rpc_loc_status_event_s_type*);\nextern  bool_t xdr_rpc_loc_server_addr_e_type (XDR *, rpc_loc_server_addr_e_type*);\nextern  bool_t xdr_rpc_loc_server_addr_ipv4_type (XDR *, rpc_loc_server_addr_ipv4_type*);\nextern  bool_t xdr_rpc_loc_server_addr_url_type (XDR *, rpc_loc_server_addr_url_type*);\nextern  bool_t xdr_rpc_loc_server_addr_ipv6_type (XDR *, rpc_loc_server_addr_ipv6_type*);\nextern  bool_t xdr_rpc_loc_server_addr_u_type (XDR *, rpc_loc_server_addr_u_type*);\nextern  bool_t xdr_rpc_loc_server_info_s_type (XDR *, rpc_loc_server_info_s_type*);\nextern  bool_t xdr_rpc_loc_ni_notify_verify_e_type (XDR *, rpc_loc_ni_notify_verify_e_type*);\nextern  bool_t xdr_rpc_loc_ni_event_e_type (XDR *, rpc_loc_ni_event_e_type*);\nextern  bool_t xdr_rpc_loc_ni_datacoding_scheme_e_type (XDR *, rpc_loc_ni_datacoding_scheme_e_type*);\nextern  bool_t xdr_rpc_loc_ni_vx_requester_id_encoding_scheme_e_type (XDR *, rpc_loc_ni_vx_requester_id_encoding_scheme_e_type*);\nextern  bool_t xdr_rpc_loc_ni_vx_pos_mode_e_type (XDR *, rpc_loc_ni_vx_pos_mode_e_type*);\nextern  bool_t xdr_rpc_loc_ni_vx_requester_id_s_type (XDR *, rpc_loc_ni_vx_requester_id_s_type*);\nextern  bool_t xdr_rpc_loc_ni_vx_notify_verify_req_s_type (XDR *, rpc_loc_ni_vx_notify_verify_req_s_type*);\nextern  bool_t xdr_rpc_loc_ni_supl_pos_method_e_type (XDR *, rpc_loc_ni_supl_pos_method_e_type*);\nextern  bool_t xdr_rpc_loc_ni_supl_slp_session_id_s_type (XDR *, rpc_loc_ni_supl_slp_session_id_s_type*);\nextern  bool_t xdr_rpc_loc_ni_requestor_id_s_type (XDR *, rpc_loc_ni_requestor_id_s_type*);\nextern  bool_t xdr_rpc_loc_ni_supl_client_name_s_type (XDR *, rpc_loc_ni_supl_client_name_s_type*);\nextern  bool_t xdr_rpc_loc_ni_supl_qop_s_type (XDR *, rpc_loc_ni_supl_qop_s_type*);\nextern  bool_t xdr_rpc_loc_ni_supl_notify_verify_req_s_type (XDR *, rpc_loc_ni_supl_notify_verify_req_s_type*);\nextern  bool_t xdr_rpc_loc_ni_ext_client_address_s_type (XDR *, rpc_loc_ni_ext_client_address_s_type*);\nextern  bool_t xdr_rpc_loc_ni_location_type_e_type (XDR *, rpc_loc_ni_location_type_e_type*);\nextern  bool_t xdr_rpc_loc_ni_deferred_location_s_type (XDR *, rpc_loc_ni_deferred_location_s_type*);\nextern  bool_t xdr_rpc_loc_ni_codeword_string_s_type (XDR *, rpc_loc_ni_codeword_string_s_type*);\nextern  bool_t xdr_rpc_loc_ni_service_type_id_s_type (XDR *, rpc_loc_ni_service_type_id_s_type*);\nextern  bool_t xdr_rpc_loc_ni_umts_cp_notify_verify_req_s_type (XDR *, rpc_loc_ni_umts_cp_notify_verify_req_s_type*);\nextern  bool_t xdr_rpc_loc_ni_service_interaction_e_type (XDR *, rpc_loc_ni_service_interaction_e_type*);\nextern  bool_t xdr_rpc_loc_ni_vx_service_interaction_req_s_type (XDR *, rpc_loc_ni_vx_service_interaction_req_s_type*);\nextern  bool_t xdr_rpc_loc_ni_event_payload_u_type (XDR *, rpc_loc_ni_event_payload_u_type*);\nextern  bool_t xdr_rpc_loc_ni_event_s_type (XDR *, rpc_loc_ni_event_s_type*);\nextern  bool_t xdr_rpc_loc_assist_data_request_e_type (XDR *, rpc_loc_assist_data_request_e_type*);\nextern  bool_t xdr_rpc_struct_loc_time_download_source_s_type_servers_ptr (XDR *, rpc_struct_loc_time_download_source_s_type_servers_ptr*);\nextern  bool_t xdr_rpc_struct_loc_time_download_source_s_type_servers (XDR *, rpc_struct_loc_time_download_source_s_type_servers);\nextern  bool_t xdr_rpc_loc_time_download_source_s_type (XDR *, rpc_loc_time_download_source_s_type*);\nextern  bool_t xdr_rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr (XDR *, rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr*);\nextern  bool_t xdr_rpc_struct_loc_predicted_orbits_data_source_s_type_servers (XDR *, rpc_struct_loc_predicted_orbits_data_source_s_type_servers);\nextern  bool_t xdr_rpc_loc_predicted_orbits_data_source_s_type (XDR *, rpc_loc_predicted_orbits_data_source_s_type*);\nextern  bool_t xdr_rpc_loc_pos_inj_request_s_type (XDR *, rpc_loc_pos_inj_request_s_type*);\nextern  bool_t xdr_rpc_loc_assist_data_request_payload_u_type (XDR *, rpc_loc_assist_data_request_payload_u_type*);\nextern  bool_t xdr_rpc_loc_assist_data_request_s_type (XDR *, rpc_loc_assist_data_request_s_type*);\nextern  bool_t xdr_rpc_loc_server_connection_handle (XDR *, rpc_loc_server_connection_handle*);\nextern  bool_t xdr_rpc_loc_server_protocol_e_type (XDR *, rpc_loc_server_protocol_e_type*);\nextern  bool_t xdr_rpc_loc_server_connection_e_type (XDR *, rpc_loc_server_connection_e_type*);\nextern  bool_t xdr_rpc_loc_server_request_e_type (XDR *, rpc_loc_server_request_e_type*);\nextern  bool_t xdr_rpc_loc_server_open_req_s_type (XDR *, rpc_loc_server_open_req_s_type*);\nextern  bool_t xdr_rpc_loc_server_multi_open_req_s_type (XDR *, rpc_loc_server_multi_open_req_s_type*);\nextern  bool_t xdr_rpc_loc_server_close_req_s_type (XDR *, rpc_loc_server_close_req_s_type*);\nextern  bool_t xdr_rpc_loc_server_request_u_type (XDR *, rpc_loc_server_request_u_type*);\nextern  bool_t xdr_rpc_loc_server_request_s_type (XDR *, rpc_loc_server_request_s_type*);\nextern  bool_t xdr_rpc_loc_qwip_request_e_type (XDR *, rpc_loc_qwip_request_e_type*);\nextern  bool_t xdr_rpc_loc_qwip_request_s_type (XDR *, rpc_loc_qwip_request_s_type*);\nextern  bool_t xdr_rpc_loc_reserved_payload_s_type (XDR *, rpc_loc_reserved_payload_s_type*);\nextern  bool_t xdr_rpc_loc_ioctl_e_type (XDR *, rpc_loc_ioctl_e_type*);\nextern  bool_t xdr_rpc_loc_api_version_s_type (XDR *, rpc_loc_api_version_s_type*);\nextern  bool_t xdr_rpc_loc_fix_recurrence_e_type (XDR *, rpc_loc_fix_recurrence_e_type*);\nextern  bool_t xdr_rpc_loc_operation_mode_e_type (XDR *, rpc_loc_operation_mode_e_type*);\nextern  bool_t xdr_rpc_loc_notify_e_type (XDR *, rpc_loc_notify_e_type*);\nextern  bool_t xdr_rpc_loc_fix_criteria_s_type (XDR *, rpc_loc_fix_criteria_s_type*);\nextern  bool_t xdr_rpc_loc_ni_user_resp_e_type (XDR *, rpc_loc_ni_user_resp_e_type*);\nextern  bool_t xdr_rpc_loc_user_verify_s_type (XDR *, rpc_loc_user_verify_s_type*);\nextern  bool_t xdr_rpc_loc_predicted_orbits_data_format_e_type (XDR *, rpc_loc_predicted_orbits_data_format_e_type*);\nextern  bool_t xdr_rpc_loc_predicted_orbits_data_s_type (XDR *, rpc_loc_predicted_orbits_data_s_type*);\nextern  bool_t xdr_rpc_loc_predicted_orbits_data_validity_report_s_type (XDR *, rpc_loc_predicted_orbits_data_validity_report_s_type*);\nextern  bool_t xdr_rpc_loc_predicted_orbits_auto_download_config_s_type (XDR *, rpc_loc_predicted_orbits_auto_download_config_s_type*);\nextern  bool_t xdr_rpc_loc_assist_data_time_s_type (XDR *, rpc_loc_assist_data_time_s_type*);\nextern  bool_t xdr_rpc_loc_assist_pos_valid_mask_type (XDR *, rpc_loc_assist_pos_valid_mask_type*);\nextern  bool_t xdr_rpc_loc_assist_data_pos_s_type (XDR *, rpc_loc_assist_data_pos_s_type*);\nextern  bool_t xdr_rpc_loc_server_open_status_e_type (XDR *, rpc_loc_server_open_status_e_type*);\nextern  bool_t xdr_rpc_loc_server_pdp_type_e_type (XDR *, rpc_loc_server_pdp_type_e_type*);\nextern  bool_t xdr_rpc_loc_server_open_status_s_type (XDR *, rpc_loc_server_open_status_s_type*);\nextern  bool_t xdr_rpc_loc_server_multi_open_status_s_type (XDR *, rpc_loc_server_multi_open_status_s_type*);\nextern  bool_t xdr_rpc_loc_server_close_status_e_type (XDR *, rpc_loc_server_close_status_e_type*);\nextern  bool_t xdr_rpc_loc_server_close_status_s_type (XDR *, rpc_loc_server_close_status_s_type*);\nextern  bool_t xdr_rpc_loc_wiper_fix_time_s_type (XDR *, rpc_loc_wiper_fix_time_s_type*);\nextern  bool_t xdr_rpc_loc_wiper_fix_pos_s_type (XDR *, rpc_loc_wiper_fix_pos_s_type*);\nextern  bool_t xdr_rpc_loc_wiper_ap_info_s_type (XDR *, rpc_loc_wiper_ap_info_s_type*);\nextern  bool_t xdr_rpc_loc_wiper_ap_set_s_type (XDR *, rpc_loc_wiper_ap_set_s_type*);\nextern  bool_t xdr_rpc_loc_wiper_position_report_s_type (XDR *, rpc_loc_wiper_position_report_s_type*);\nextern  bool_t xdr_rpc_loc_wiper_status_e_type (XDR *, rpc_loc_wiper_status_e_type*);\nextern  bool_t xdr_rpc_loc_fs_operation_e_type (XDR *, rpc_loc_fs_operation_e_type*);\nextern  bool_t xdr_rpc_loc_efs_data_s_type (XDR *, rpc_loc_efs_data_s_type*);\nextern  bool_t xdr_rpc_loc_error_estimate_config_e_type (XDR *, rpc_loc_error_estimate_config_e_type*);\nextern  bool_t xdr_rpc_loc_apn_profiles_type (XDR *, rpc_loc_apn_profiles_type*);\nextern  bool_t xdr_rpc_loc_lock_e_type (XDR *, rpc_loc_lock_e_type*);\nextern  bool_t xdr_rpc_loc_nmea_sentence_type (XDR *, rpc_loc_nmea_sentence_type*);\nextern  bool_t xdr_rpc_loc_assist_data_type (XDR *, rpc_loc_assist_data_type*);\nextern  bool_t xdr_rpc_loc_assist_data_delete_s_type (XDR *, rpc_loc_assist_data_delete_s_type*);\nextern  bool_t xdr_rpc_loc_ioctl_data_u_type (XDR *, rpc_loc_ioctl_data_u_type*);\nextern  bool_t xdr_rpc_loc_ioctl_callback_data_u_type (XDR *, rpc_loc_ioctl_callback_data_u_type*);\nextern  bool_t xdr_rpc_loc_ioctl_callback_s_type (XDR *, rpc_loc_ioctl_callback_s_type*);\nextern  bool_t xdr_rpc_loc_event_payload_u_type (XDR *, rpc_loc_event_payload_u_type*);\n\n#else /* K&R C */\nextern bool_t xdr_rpc_loc_client_handle_type ();\nextern bool_t xdr_rpc_loc_event_mask_type ();\nextern bool_t xdr_rpc_loc_position_valid_mask_type ();\nextern bool_t xdr_rpc_loc_pos_technology_mask_type ();\nextern bool_t xdr_rpc_loc_session_status_e_type ();\nextern bool_t xdr_rpc_loc_calendar_time_s_type ();\nextern bool_t xdr_rpc_loc_parsed_position_s_type ();\nextern bool_t xdr_rpc_loc_sv_system_e_type ();\nextern bool_t xdr_rpc_loc_sv_status_e_type ();\nextern bool_t xdr_rpc_loc_sv_info_valid_mask_type ();\nextern bool_t xdr_rpc_loc_sv_info_s_type ();\nextern bool_t xdr_rpc_loc_gnss_info_valid_mask_type ();\nextern bool_t xdr_rpc_loc_gnss_info_s_type ();\nextern bool_t xdr_rpc_loc_nmea_report_s_type ();\nextern bool_t xdr_rpc_loc_status_event_e_type ();\nextern bool_t xdr_rpc_loc_engine_state_e_type ();\nextern bool_t xdr_rpc_loc_fix_session_state_e_type ();\nextern bool_t xdr_rpc_loc_status_event_payload_u_type ();\nextern bool_t xdr_rpc_loc_status_event_s_type ();\nextern bool_t xdr_rpc_loc_server_addr_e_type ();\nextern bool_t xdr_rpc_loc_server_addr_ipv4_type ();\nextern bool_t xdr_rpc_loc_server_addr_url_type ();\nextern bool_t xdr_rpc_loc_server_addr_ipv6_type ();\nextern bool_t xdr_rpc_loc_server_addr_u_type ();\nextern bool_t xdr_rpc_loc_server_info_s_type ();\nextern bool_t xdr_rpc_loc_ni_notify_verify_e_type ();\nextern bool_t xdr_rpc_loc_ni_event_e_type ();\nextern bool_t xdr_rpc_loc_ni_datacoding_scheme_e_type ();\nextern bool_t xdr_rpc_loc_ni_vx_requester_id_encoding_scheme_e_type ();\nextern bool_t xdr_rpc_loc_ni_vx_pos_mode_e_type ();\nextern bool_t xdr_rpc_loc_ni_vx_requester_id_s_type ();\nextern bool_t xdr_rpc_loc_ni_vx_notify_verify_req_s_type ();\nextern bool_t xdr_rpc_loc_ni_supl_pos_method_e_type ();\nextern bool_t xdr_rpc_loc_ni_supl_slp_session_id_s_type ();\nextern bool_t xdr_rpc_loc_ni_requestor_id_s_type ();\nextern bool_t xdr_rpc_loc_ni_supl_client_name_s_type ();\nextern bool_t xdr_rpc_loc_ni_supl_qop_s_type ();\nextern bool_t xdr_rpc_loc_ni_supl_notify_verify_req_s_type ();\nextern bool_t xdr_rpc_loc_ni_ext_client_address_s_type ();\nextern bool_t xdr_rpc_loc_ni_location_type_e_type ();\nextern bool_t xdr_rpc_loc_ni_deferred_location_s_type ();\nextern bool_t xdr_rpc_loc_ni_codeword_string_s_type ();\nextern bool_t xdr_rpc_loc_ni_service_type_id_s_type ();\nextern bool_t xdr_rpc_loc_ni_umts_cp_notify_verify_req_s_type ();\nextern bool_t xdr_rpc_loc_ni_service_interaction_e_type ();\nextern bool_t xdr_rpc_loc_ni_vx_service_interaction_req_s_type ();\nextern bool_t xdr_rpc_loc_ni_event_payload_u_type ();\nextern bool_t xdr_rpc_loc_ni_event_s_type ();\nextern bool_t xdr_rpc_loc_assist_data_request_e_type ();\nextern bool_t xdr_rpc_struct_loc_time_download_source_s_type_servers_ptr ();\nextern bool_t xdr_rpc_struct_loc_time_download_source_s_type_servers ();\nextern bool_t xdr_rpc_loc_time_download_source_s_type ();\nextern bool_t xdr_rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr ();\nextern bool_t xdr_rpc_struct_loc_predicted_orbits_data_source_s_type_servers ();\nextern bool_t xdr_rpc_loc_predicted_orbits_data_source_s_type ();\nextern bool_t xdr_rpc_loc_pos_inj_request_s_type ();\nextern bool_t xdr_rpc_loc_assist_data_request_payload_u_type ();\nextern bool_t xdr_rpc_loc_assist_data_request_s_type ();\nextern bool_t xdr_rpc_loc_server_connection_handle ();\nextern bool_t xdr_rpc_loc_server_protocol_e_type ();\nextern bool_t xdr_rpc_loc_server_connection_e_type ();\nextern bool_t xdr_rpc_loc_server_request_e_type ();\nextern bool_t xdr_rpc_loc_server_open_req_s_type ();\nextern bool_t xdr_rpc_loc_server_multi_open_req_s_type ();\nextern bool_t xdr_rpc_loc_server_close_req_s_type ();\nextern bool_t xdr_rpc_loc_server_request_u_type ();\nextern bool_t xdr_rpc_loc_server_request_s_type ();\nextern bool_t xdr_rpc_loc_qwip_request_e_type ();\nextern bool_t xdr_rpc_loc_qwip_request_s_type ();\nextern bool_t xdr_rpc_loc_reserved_payload_s_type ();\nextern bool_t xdr_rpc_loc_ioctl_e_type ();\nextern bool_t xdr_rpc_loc_api_version_s_type ();\nextern bool_t xdr_rpc_loc_fix_recurrence_e_type ();\nextern bool_t xdr_rpc_loc_operation_mode_e_type ();\nextern bool_t xdr_rpc_loc_notify_e_type ();\nextern bool_t xdr_rpc_loc_fix_criteria_s_type ();\nextern bool_t xdr_rpc_loc_ni_user_resp_e_type ();\nextern bool_t xdr_rpc_loc_user_verify_s_type ();\nextern bool_t xdr_rpc_loc_predicted_orbits_data_format_e_type ();\nextern bool_t xdr_rpc_loc_predicted_orbits_data_s_type ();\nextern bool_t xdr_rpc_loc_predicted_orbits_data_validity_report_s_type ();\nextern bool_t xdr_rpc_loc_predicted_orbits_auto_download_config_s_type ();\nextern bool_t xdr_rpc_loc_assist_data_time_s_type ();\nextern bool_t xdr_rpc_loc_assist_pos_valid_mask_type ();\nextern bool_t xdr_rpc_loc_assist_data_pos_s_type ();\nextern bool_t xdr_rpc_loc_server_open_status_e_type ();\nextern bool_t xdr_rpc_loc_server_pdp_type_e_type ();\nextern bool_t xdr_rpc_loc_server_open_status_s_type ();\nextern bool_t xdr_rpc_loc_server_multi_open_status_s_type ();\nextern bool_t xdr_rpc_loc_server_close_status_e_type ();\nextern bool_t xdr_rpc_loc_server_close_status_s_type ();\nextern bool_t xdr_rpc_loc_wiper_fix_time_s_type ();\nextern bool_t xdr_rpc_loc_wiper_fix_pos_s_type ();\nextern bool_t xdr_rpc_loc_wiper_ap_info_s_type ();\nextern bool_t xdr_rpc_loc_wiper_ap_set_s_type ();\nextern bool_t xdr_rpc_loc_wiper_position_report_s_type ();\nextern bool_t xdr_rpc_loc_wiper_status_e_type ();\nextern bool_t xdr_rpc_loc_fs_operation_e_type ();\nextern bool_t xdr_rpc_loc_efs_data_s_type ();\nextern bool_t xdr_rpc_loc_error_estimate_config_e_type ();\nextern bool_t xdr_rpc_loc_apn_profiles_type ();\nextern bool_t xdr_rpc_loc_lock_e_type ();\nextern bool_t xdr_rpc_loc_nmea_sentence_type ();\nextern bool_t xdr_rpc_loc_assist_data_type ();\nextern bool_t xdr_rpc_loc_assist_data_delete_s_type ();\nextern bool_t xdr_rpc_loc_ioctl_data_u_type ();\nextern bool_t xdr_rpc_loc_ioctl_callback_data_u_type ();\nextern bool_t xdr_rpc_loc_ioctl_callback_s_type ();\nextern bool_t xdr_rpc_loc_event_payload_u_type ();\n\n#endif /* K&R C */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !_LOC_API_COMMON_RPC_H_RPCGEN */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/inc/loc_api_rpcgen_rpc.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#ifndef _LOC_API_RPC_H_RPCGEN\n#define _LOC_API_RPC_H_RPCGEN\n\n#include \"librpc.h\"\n#include \"commondefs_rpcgen_rpc.h\"\n#include \"loc_api_rpcgen_common_rpc.h\"\n\n#include <pthread.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\ntypedef struct {\n    u_int rpc_loc_api_api_versions_return_type_len;\n    rpc_uint32 *rpc_loc_api_api_versions_return_type_val;\n} rpc_loc_api_api_versions_return_type;\n\ntypedef rpc_uint32 rpc_loc_event_cb_f_type;\n\nstruct rpc_loc_open_args {\n    rpc_loc_event_mask_type event_reg_mask;\n    rpc_loc_event_cb_f_type event_callback;\n};\ntypedef struct rpc_loc_open_args rpc_loc_open_args;\n\nstruct rpc_loc_close_args {\n    rpc_loc_client_handle_type handle;\n};\ntypedef struct rpc_loc_close_args rpc_loc_close_args;\n\nstruct rpc_loc_start_fix_args {\n    rpc_loc_client_handle_type handle;\n};\ntypedef struct rpc_loc_start_fix_args rpc_loc_start_fix_args;\n\nstruct rpc_loc_stop_fix_args {\n    rpc_loc_client_handle_type handle;\n};\ntypedef struct rpc_loc_stop_fix_args rpc_loc_stop_fix_args;\n\nstruct rpc_loc_ioctl_args {\n    rpc_loc_client_handle_type handle;\n    rpc_loc_ioctl_e_type ioctl_type;\n    rpc_loc_ioctl_data_u_type *ioctl_data;\n};\ntypedef struct rpc_loc_ioctl_args rpc_loc_ioctl_args;\n\nstruct rpc_loc_api_api_version_s_args {\n    rpc_boolean len_not_null;\n};\ntypedef struct rpc_loc_api_api_version_s_args rpc_loc_api_api_version_s_args;\n\nstruct rpc_loc_api_rpc_glue_code_info_remote_rets {\n    rpc_uint32 toolvers;\n    rpc_uint32 features;\n    rpc_uint32 proghash;\n    rpc_uint32 cbproghash;\n};\ntypedef struct rpc_loc_api_rpc_glue_code_info_remote_rets rpc_loc_api_rpc_glue_code_info_remote_rets;\n\nstruct rpc_loc_open_rets {\n    rpc_loc_client_handle_type loc_open_result;\n};\ntypedef struct rpc_loc_open_rets rpc_loc_open_rets;\n\nstruct rpc_loc_close_rets {\n    rpc_int32 loc_close_result;\n};\ntypedef struct rpc_loc_close_rets rpc_loc_close_rets;\n\nstruct rpc_loc_start_fix_rets {\n    rpc_int32 loc_start_fix_result;\n};\ntypedef struct rpc_loc_start_fix_rets rpc_loc_start_fix_rets;\n\nstruct rpc_loc_stop_fix_rets {\n    rpc_int32 loc_stop_fix_result;\n};\ntypedef struct rpc_loc_stop_fix_rets rpc_loc_stop_fix_rets;\n\nstruct rpc_loc_ioctl_rets {\n    rpc_int32 loc_ioctl_result;\n};\ntypedef struct rpc_loc_ioctl_rets rpc_loc_ioctl_rets;\n\nstruct rpc_loc_api_api_versions_rets {\n    rpc_loc_api_api_versions_return_type loc_api_api_versions_result;\n    rpc_uint32 *len;\n};\ntypedef struct rpc_loc_api_api_versions_rets rpc_loc_api_api_versions_rets;\n#define LOC_APIVERS 0x00050006\n\n#define LOC_APIPROG 0x3000008C\n#define LOC_APIVERS_0001 0x00050001\n\n#if defined(__STDC__) || defined(__cplusplus)\n#define rpc_loc_api_null 0\nextern  enum clnt_stat rpc_loc_api_null_0x00050001(void *, void *, CLIENT *);\nextern  bool_t rpc_loc_api_null_0x00050001_svc(void *, void *, struct svc_req *);\n#define rpc_loc_api_rpc_glue_code_info_remote 1\nextern  enum clnt_stat rpc_loc_api_rpc_glue_code_info_remote_0x00050001(void *, rpc_loc_api_rpc_glue_code_info_remote_rets *, CLIENT *);\nextern  bool_t rpc_loc_api_rpc_glue_code_info_remote_0x00050001_svc(void *, rpc_loc_api_rpc_glue_code_info_remote_rets *, struct svc_req *);\n#define rpc_loc_open 2\nextern  enum clnt_stat rpc_loc_open_0x00050001(rpc_loc_open_args *, rpc_loc_open_rets *, CLIENT *);\nextern  bool_t rpc_loc_open_0x00050001_svc(rpc_loc_open_args *, rpc_loc_open_rets *, struct svc_req *);\n#define rpc_loc_close 3\nextern  enum clnt_stat rpc_loc_close_0x00050001(rpc_loc_close_args *, rpc_loc_close_rets *, CLIENT *);\nextern  bool_t rpc_loc_close_0x00050001_svc(rpc_loc_close_args *, rpc_loc_close_rets *, struct svc_req *);\n#define rpc_loc_start_fix 4\nextern  enum clnt_stat rpc_loc_start_fix_0x00050001(rpc_loc_start_fix_args *, rpc_loc_start_fix_rets *, CLIENT *);\nextern  bool_t rpc_loc_start_fix_0x00050001_svc(rpc_loc_start_fix_args *, rpc_loc_start_fix_rets *, struct svc_req *);\n#define rpc_loc_stop_fix 5\nextern  enum clnt_stat rpc_loc_stop_fix_0x00050001(rpc_loc_stop_fix_args *, rpc_loc_stop_fix_rets *, CLIENT *);\nextern  bool_t rpc_loc_stop_fix_0x00050001_svc(rpc_loc_stop_fix_args *, rpc_loc_stop_fix_rets *, struct svc_req *);\n#define rpc_loc_ioctl 6\nextern  enum clnt_stat rpc_loc_ioctl_0x00050001(rpc_loc_ioctl_args *, rpc_loc_ioctl_rets *, CLIENT *);\nextern  bool_t rpc_loc_ioctl_0x00050001_svc(rpc_loc_ioctl_args *, rpc_loc_ioctl_rets *, struct svc_req *);\n#define rpc_loc_api_api_versions 0xFFFFFFFF\nextern  enum clnt_stat rpc_loc_api_api_versions_0x00050001(void *, rpc_loc_api_api_versions_rets *, CLIENT *);\nextern  bool_t rpc_loc_api_api_versions_0x00050001_svc(void *, rpc_loc_api_api_versions_rets *, struct svc_req *);\nextern int loc_apiprog_0x00050001_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\n#define rpc_loc_api_null 0\nextern  enum clnt_stat rpc_loc_api_null_0x00050001();\nextern  bool_t rpc_loc_api_null_0x00050001_svc();\n#define rpc_loc_api_rpc_glue_code_info_remote 1\nextern  enum clnt_stat rpc_loc_api_rpc_glue_code_info_remote_0x00050001();\nextern  bool_t rpc_loc_api_rpc_glue_code_info_remote_0x00050001_svc();\n#define rpc_loc_open 2\nextern  enum clnt_stat rpc_loc_open_0x00050001();\nextern  bool_t rpc_loc_open_0x00050001_svc();\n#define rpc_loc_close 3\nextern  enum clnt_stat rpc_loc_close_0x00050001();\nextern  bool_t rpc_loc_close_0x00050001_svc();\n#define rpc_loc_start_fix 4\nextern  enum clnt_stat rpc_loc_start_fix_0x00050001();\nextern  bool_t rpc_loc_start_fix_0x00050001_svc();\n#define rpc_loc_stop_fix 5\nextern  enum clnt_stat rpc_loc_stop_fix_0x00050001();\nextern  bool_t rpc_loc_stop_fix_0x00050001_svc();\n#define rpc_loc_ioctl 6\nextern  enum clnt_stat rpc_loc_ioctl_0x00050001();\nextern  bool_t rpc_loc_ioctl_0x00050001_svc();\n#define rpc_loc_api_api_versions 0xFFFFFFFF\nextern  enum clnt_stat rpc_loc_api_api_versions_0x00050001();\nextern  bool_t rpc_loc_api_api_versions_0x00050001_svc();\nextern int loc_apiprog_0x00050001_freeresult ();\n#endif /* K&R C */\n#define LOC_APIVERS_0002 0x00050002\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_null_0x00050002(void *, void *, CLIENT *);\nextern  bool_t rpc_loc_api_null_0x00050002_svc(void *, void *, struct svc_req *);\nextern int loc_apiprog_0x00050002_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_null_0x00050002();\nextern  bool_t rpc_loc_api_null_0x00050002_svc();\nextern int loc_apiprog_0x00050002_freeresult ();\n#endif /* K&R C */\n#define LOC_APIVERS_0003 0x00050003\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_null_0x00050003(void *, void *, CLIENT *);\nextern  bool_t rpc_loc_api_null_0x00050003_svc(void *, void *, struct svc_req *);\nextern int loc_apiprog_0x00050003_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_null_0x00050003();\nextern  bool_t rpc_loc_api_null_0x00050003_svc();\nextern int loc_apiprog_0x00050003_freeresult ();\n#endif /* K&R C */\n#define LOC_APIVERS_0004 0x00050004\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_null_0x00050004(void *, void *, CLIENT *);\nextern  bool_t rpc_loc_api_null_0x00050004_svc(void *, void *, struct svc_req *);\nextern int loc_apiprog_0x00050004_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_null_0x00050004();\nextern  bool_t rpc_loc_api_null_0x00050004_svc();\nextern int loc_apiprog_0x00050004_freeresult ();\n#endif /* K&R C */\n#define LOC_APIVERS_0005 0x00050005\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_null_0x00050005(void *, void *, CLIENT *);\nextern  bool_t rpc_loc_api_null_0x00050005_svc(void *, void *, struct svc_req *);\nextern int loc_apiprog_0x00050005_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_null_0x00050005();\nextern  bool_t rpc_loc_api_null_0x00050005_svc();\nextern int loc_apiprog_0x00050005_freeresult ();\n#endif /* K&R C */\n#define LOC_APIVERS_0006 0x00050006\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  enum clnt_stat rpc_loc_api_null_0x00050006(void *, void *, CLIENT *);\nextern  bool_t rpc_loc_api_null_0x00050006_svc(void *, void *, struct svc_req *);\nextern int loc_apiprog_0x00050006_freeresult (SVCXPRT *, xdrproc_t, caddr_t);\n\n#else /* K&R C */\nextern  enum clnt_stat rpc_loc_api_null_0x00050006();\nextern  bool_t rpc_loc_api_null_0x00050006_svc();\nextern int loc_apiprog_0x00050006_freeresult ();\n#endif /* K&R C */\n\n/* the xdr functions */\n\n#if defined(__STDC__) || defined(__cplusplus)\nextern  bool_t xdr_rpc_loc_api_api_versions_return_type (XDR *, rpc_loc_api_api_versions_return_type*);\nextern  bool_t xdr_rpc_loc_event_cb_f_type (XDR *, rpc_loc_event_cb_f_type*);\nextern  bool_t xdr_rpc_loc_open_args (XDR *, rpc_loc_open_args*);\nextern  bool_t xdr_rpc_loc_close_args (XDR *, rpc_loc_close_args*);\nextern  bool_t xdr_rpc_loc_start_fix_args (XDR *, rpc_loc_start_fix_args*);\nextern  bool_t xdr_rpc_loc_stop_fix_args (XDR *, rpc_loc_stop_fix_args*);\nextern  bool_t xdr_rpc_loc_ioctl_args (XDR *, rpc_loc_ioctl_args*);\nextern  bool_t xdr_rpc_loc_api_api_version_s_args (XDR *, rpc_loc_api_api_version_s_args*);\nextern  bool_t xdr_rpc_loc_api_rpc_glue_code_info_remote_rets (XDR *, rpc_loc_api_rpc_glue_code_info_remote_rets*);\nextern  bool_t xdr_rpc_loc_open_rets (XDR *, rpc_loc_open_rets*);\nextern  bool_t xdr_rpc_loc_close_rets (XDR *, rpc_loc_close_rets*);\nextern  bool_t xdr_rpc_loc_start_fix_rets (XDR *, rpc_loc_start_fix_rets*);\nextern  bool_t xdr_rpc_loc_stop_fix_rets (XDR *, rpc_loc_stop_fix_rets*);\nextern  bool_t xdr_rpc_loc_ioctl_rets (XDR *, rpc_loc_ioctl_rets*);\nextern  bool_t xdr_rpc_loc_api_api_versions_rets (XDR *, rpc_loc_api_api_versions_rets*);\n\n#else /* K&R C */\nextern bool_t xdr_rpc_loc_api_api_versions_return_type ();\nextern bool_t xdr_rpc_loc_event_cb_f_type ();\nextern bool_t xdr_rpc_loc_open_args ();\nextern bool_t xdr_rpc_loc_close_args ();\nextern bool_t xdr_rpc_loc_start_fix_args ();\nextern bool_t xdr_rpc_loc_stop_fix_args ();\nextern bool_t xdr_rpc_loc_ioctl_args ();\nextern bool_t xdr_rpc_loc_api_api_version_s_args ();\nextern bool_t xdr_rpc_loc_api_rpc_glue_code_info_remote_rets ();\nextern bool_t xdr_rpc_loc_open_rets ();\nextern bool_t xdr_rpc_loc_close_rets ();\nextern bool_t xdr_rpc_loc_start_fix_rets ();\nextern bool_t xdr_rpc_loc_stop_fix_rets ();\nextern bool_t xdr_rpc_loc_ioctl_rets ();\nextern bool_t xdr_rpc_loc_api_api_versions_rets ();\n\n#endif /* K&R C */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !_LOC_API_RPC_H_RPCGEN */\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/inc/loc_apicb_appinit.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n/* Initialization function for callbacks */\nint loc_apicb_app_init();\n\nvoid loc_apicb_app_deinit();\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/src/loc_api_rpcgen_cb_svc.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#include \"loc_api_rpcgen_cb_rpc.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <rpc/pmap_clnt.h>\n#include <string.h>\n#include <memory.h>\n#include <sys/socket.h>\n#include <netinet/in.h>\n\n#ifndef SIG_PF\n#define SIG_PF void(*)(int)\n#endif\n\nvoid\nloc_apicbprog_0x00050001(struct svc_req *rqstp, register SVCXPRT *transp)\n{\n    union {\n        rpc_loc_event_cb_f_type_args rpc_loc_event_cb_f_type_0x00050001_arg;\n    } argument;\n    union {\n        rpc_loc_event_cb_f_type_rets rpc_loc_event_cb_f_type_0x00050001_res;\n    } result;\n    bool_t retval;\n    xdrproc_t _xdr_argument, _xdr_result;\n    bool_t (*local)(char *, void *, struct svc_req *);\n\n    switch (rqstp->rq_proc) {\n    case NULLPROC:\n        (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);\n        return;\n\n    case rpc_loc_event_cb_f_type:\n        _xdr_argument = (xdrproc_t) xdr_rpc_loc_event_cb_f_type_args;\n        _xdr_result = (xdrproc_t) xdr_rpc_loc_event_cb_f_type_rets;\n        local = (bool_t (*) (char *, void *,  struct svc_req *))rpc_loc_event_cb_f_type_0x00050001_svc;\n        break;\n\n    default:\n        svcerr_noproc (transp);\n        return;\n    }\n    memset ((char *)&argument, 0, sizeof (argument));\n    if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        svcerr_decode (transp);\n        return;\n    }\n    retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);\n    if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {\n        svcerr_systemerr (transp);\n    }\n    if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        fprintf (stderr, \"%s\", \"unable to free arguments\");\n        exit (1);\n    }\n    if (!loc_apicbprog_0x00050001_freeresult (transp, _xdr_result, (caddr_t) &result))\n        fprintf (stderr, \"%s\", \"unable to free results\");\n\n    return;\n}\n\nvoid\nloc_apicbprog_0x00050002(struct svc_req *rqstp, register SVCXPRT *transp)\n{\n    union {\n        int fill;\n    } argument;\n    union {\n        int rpc_loc_api_cb_null_0x00050002_res;\n    } result;\n    bool_t retval;\n    xdrproc_t _xdr_argument, _xdr_result;\n    bool_t (*local)(char *, void *, struct svc_req *);\n\n    switch (rqstp->rq_proc) {\n    case NULLPROC:\n        (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);\n        return;\n\n    case rpc_loc_api_cb_null:\n        _xdr_argument = (xdrproc_t) xdr_void;\n        _xdr_result = (xdrproc_t) xdr_int;\n        local = (bool_t (*) (char *, void *,  struct svc_req *))rpc_loc_api_cb_null_0x00050002_svc;\n        break;\n\n    default:\n        svcerr_noproc (transp);\n        return;\n    }\n    memset ((char *)&argument, 0, sizeof (argument));\n    if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        svcerr_decode (transp);\n        return;\n    }\n    retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);\n    if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {\n        svcerr_systemerr (transp);\n    }\n    if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        fprintf (stderr, \"%s\", \"unable to free arguments\");\n        exit (1);\n    }\n    if (!loc_apicbprog_0x00050002_freeresult (transp, _xdr_result, (caddr_t) &result))\n        fprintf (stderr, \"%s\", \"unable to free results\");\n\n    return;\n}\n\nvoid\nloc_apicbprog_0x00050003(struct svc_req *rqstp, register SVCXPRT *transp)\n{\n    union {\n        int fill;\n    } argument;\n    union {\n        int rpc_loc_api_cb_null_0x00050003_res;\n    } result;\n    bool_t retval;\n    xdrproc_t _xdr_argument, _xdr_result;\n    bool_t (*local)(char *, void *, struct svc_req *);\n\n    switch (rqstp->rq_proc) {\n    case NULLPROC:\n        (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);\n        return;\n\n    case rpc_loc_api_cb_null:\n        _xdr_argument = (xdrproc_t) xdr_void;\n        _xdr_result = (xdrproc_t) xdr_int;\n        local = (bool_t (*) (char *, void *,  struct svc_req *))rpc_loc_api_cb_null_0x00050003_svc;\n        break;\n\n    default:\n        svcerr_noproc (transp);\n        return;\n    }\n    memset ((char *)&argument, 0, sizeof (argument));\n    if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        svcerr_decode (transp);\n        return;\n    }\n    retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);\n    if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {\n        svcerr_systemerr (transp);\n    }\n    if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        fprintf (stderr, \"%s\", \"unable to free arguments\");\n        exit (1);\n    }\n    if (!loc_apicbprog_0x00050003_freeresult (transp, _xdr_result, (caddr_t) &result))\n        fprintf (stderr, \"%s\", \"unable to free results\");\n\n    return;\n}\n\nvoid\nloc_apicbprog_0x00050004(struct svc_req *rqstp, register SVCXPRT *transp)\n{\n    union {\n        int fill;\n    } argument;\n    union {\n        int rpc_loc_api_cb_null_0x00050004_res;\n    } result;\n    bool_t retval;\n    xdrproc_t _xdr_argument, _xdr_result;\n    bool_t (*local)(char *, void *, struct svc_req *);\n\n    switch (rqstp->rq_proc) {\n    case NULLPROC:\n        (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);\n        return;\n\n    case rpc_loc_api_cb_null:\n        _xdr_argument = (xdrproc_t) xdr_void;\n        _xdr_result = (xdrproc_t) xdr_int;\n        local = (bool_t (*) (char *, void *,  struct svc_req *))rpc_loc_api_cb_null_0x00050004_svc;\n        break;\n\n    default:\n        svcerr_noproc (transp);\n        return;\n    }\n    memset ((char *)&argument, 0, sizeof (argument));\n    if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        svcerr_decode (transp);\n        return;\n    }\n    retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);\n    if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {\n        svcerr_systemerr (transp);\n    }\n    if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        fprintf (stderr, \"%s\", \"unable to free arguments\");\n        exit (1);\n    }\n    if (!loc_apicbprog_0x00050004_freeresult (transp, _xdr_result, (caddr_t) &result))\n        fprintf (stderr, \"%s\", \"unable to free results\");\n\n    return;\n}\n\nvoid\nloc_apicbprog_0x00050005(struct svc_req *rqstp, register SVCXPRT *transp)\n{\n    union {\n        int fill;\n    } argument;\n    union {\n        int rpc_loc_api_cb_null_0x00050005_res;\n    } result;\n    bool_t retval;\n    xdrproc_t _xdr_argument, _xdr_result;\n    bool_t (*local)(char *, void *, struct svc_req *);\n\n    switch (rqstp->rq_proc) {\n    case NULLPROC:\n        (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);\n        return;\n\n    case rpc_loc_api_cb_null:\n        _xdr_argument = (xdrproc_t) xdr_void;\n        _xdr_result = (xdrproc_t) xdr_int;\n        local = (bool_t (*) (char *, void *,  struct svc_req *))rpc_loc_api_cb_null_0x00050005_svc;\n        break;\n\n    default:\n        svcerr_noproc (transp);\n        return;\n    }\n    memset ((char *)&argument, 0, sizeof (argument));\n    if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        svcerr_decode (transp);\n        return;\n    }\n    retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);\n    if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {\n        svcerr_systemerr (transp);\n    }\n    if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        fprintf (stderr, \"%s\", \"unable to free arguments\");\n        exit (1);\n    }\n    if (!loc_apicbprog_0x00050005_freeresult (transp, _xdr_result, (caddr_t) &result))\n        fprintf (stderr, \"%s\", \"unable to free results\");\n\n    return;\n}\n\nvoid\nloc_apicbprog_0x00050006(struct svc_req *rqstp, register SVCXPRT *transp)\n{\n    union {\n        int fill;\n    } argument;\n    union {\n        int rpc_loc_api_cb_null_0x00050006_res;\n    } result;\n    bool_t retval;\n    xdrproc_t _xdr_argument, _xdr_result;\n    bool_t (*local)(char *, void *, struct svc_req *);\n\n    switch (rqstp->rq_proc) {\n    case NULLPROC:\n        (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);\n        return;\n\n    case rpc_loc_api_cb_null:\n        _xdr_argument = (xdrproc_t) xdr_void;\n        _xdr_result = (xdrproc_t) xdr_int;\n        local = (bool_t (*) (char *, void *,  struct svc_req *))rpc_loc_api_cb_null_0x00050006_svc;\n        break;\n\n    default:\n        svcerr_noproc (transp);\n        return;\n    }\n    memset ((char *)&argument, 0, sizeof (argument));\n    if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        svcerr_decode (transp);\n        return;\n    }\n    retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);\n    if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {\n        svcerr_systemerr (transp);\n    }\n    if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {\n        fprintf (stderr, \"%s\", \"unable to free arguments\");\n        exit (1);\n    }\n    if (!loc_apicbprog_0x00050006_freeresult (transp, _xdr_result, (caddr_t) &result))\n        fprintf (stderr, \"%s\", \"unable to free results\");\n\n    return;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/src/loc_api_rpcgen_cb_xdr.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#include \"loc_api_rpcgen_cb_rpc.h\"\n\nbool_t\nxdr_rpc_loc_event_cb_f_type_args (XDR *xdrs, rpc_loc_event_cb_f_type_args *objp)\n{\n;\n\n     if (!xdr_rpc_uint32 (xdrs, &objp->cb_id))\n         return FALSE;\n     if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->loc_handle))\n         return FALSE;\n     if (!xdr_rpc_loc_event_mask_type (xdrs, &objp->loc_event))\n         return FALSE;\n     if (!xdr_pointer (xdrs, (char **)&objp->loc_event_payload, sizeof (rpc_loc_event_payload_u_type), (xdrproc_t) xdr_rpc_loc_event_payload_u_type))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_event_cb_f_type_rets (XDR *xdrs, rpc_loc_event_cb_f_type_rets *objp)\n{\n;\n\n     if (!xdr_rpc_int32 (xdrs, &objp->loc_event_cb_f_type_result))\n         return FALSE;\n    return TRUE;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/src/loc_api_rpcgen_clnt.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#include <memory.h> /* for memset */\n#include \"loc_api_rpcgen_rpc.h\"\n\n/* Default timeout can be changed using clnt_control() */\nstatic struct timeval TIMEOUT = { 25, 0 };\n\nenum clnt_stat\nrpc_loc_api_null_0x00050001(void *argp, void *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_api_null,\n        (xdrproc_t) xdr_void, (caddr_t) argp,\n        (xdrproc_t) xdr_void, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_api_rpc_glue_code_info_remote_0x00050001(void *argp, rpc_loc_api_rpc_glue_code_info_remote_rets *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_api_rpc_glue_code_info_remote,\n        (xdrproc_t) xdr_void, (caddr_t) argp,\n        (xdrproc_t) xdr_rpc_loc_api_rpc_glue_code_info_remote_rets, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_open_0x00050001(rpc_loc_open_args *argp, rpc_loc_open_rets *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_open,\n        (xdrproc_t) xdr_rpc_loc_open_args, (caddr_t) argp,\n        (xdrproc_t) xdr_rpc_loc_open_rets, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_close_0x00050001(rpc_loc_close_args *argp, rpc_loc_close_rets *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_close,\n        (xdrproc_t) xdr_rpc_loc_close_args, (caddr_t) argp,\n        (xdrproc_t) xdr_rpc_loc_close_rets, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_start_fix_0x00050001(rpc_loc_start_fix_args *argp, rpc_loc_start_fix_rets *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_start_fix,\n        (xdrproc_t) xdr_rpc_loc_start_fix_args, (caddr_t) argp,\n        (xdrproc_t) xdr_rpc_loc_start_fix_rets, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_stop_fix_0x00050001(rpc_loc_stop_fix_args *argp, rpc_loc_stop_fix_rets *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_stop_fix,\n        (xdrproc_t) xdr_rpc_loc_stop_fix_args, (caddr_t) argp,\n        (xdrproc_t) xdr_rpc_loc_stop_fix_rets, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_ioctl_0x00050001(rpc_loc_ioctl_args *argp, rpc_loc_ioctl_rets *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_ioctl,\n        (xdrproc_t) xdr_rpc_loc_ioctl_args, (caddr_t) argp,\n        (xdrproc_t) xdr_rpc_loc_ioctl_rets, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_api_api_versions_0x00050001(void *argp, rpc_loc_api_api_versions_rets *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_api_api_versions,\n        (xdrproc_t) xdr_void, (caddr_t) argp,\n        (xdrproc_t) xdr_rpc_loc_api_api_versions_rets, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_api_null_0x00050002(void *argp, void *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_api_null,\n        (xdrproc_t) xdr_void, (caddr_t) argp,\n        (xdrproc_t) xdr_void, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_api_null_0x00050003(void *argp, void *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_api_null,\n        (xdrproc_t) xdr_void, (caddr_t) argp,\n        (xdrproc_t) xdr_void, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_api_null_0x00050004(void *argp, void *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_api_null,\n        (xdrproc_t) xdr_void, (caddr_t) argp,\n        (xdrproc_t) xdr_void, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_api_null_0x00050005(void *argp, void *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_api_null,\n        (xdrproc_t) xdr_void, (caddr_t) argp,\n        (xdrproc_t) xdr_void, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n\nenum clnt_stat\nrpc_loc_api_null_0x00050006(void *argp, void *clnt_res, CLIENT *clnt)\n{\n    return (clnt_call(clnt, rpc_loc_api_null,\n        (xdrproc_t) xdr_void, (caddr_t) argp,\n        (xdrproc_t) xdr_void, (caddr_t) clnt_res,\n        TIMEOUT));\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/src/loc_api_rpcgen_common_xdr.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#include \"loc_api_rpcgen_common_rpc.h\"\n\nbool_t\nxdr_rpc_loc_client_handle_type (XDR *xdrs, rpc_loc_client_handle_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_int32 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_event_mask_type (XDR *xdrs, rpc_loc_event_mask_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint64 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_position_valid_mask_type (XDR *xdrs, rpc_loc_position_valid_mask_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint64 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_pos_technology_mask_type (XDR *xdrs, rpc_loc_pos_technology_mask_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_session_status_e_type (XDR *xdrs, rpc_loc_session_status_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_calendar_time_s_type (XDR *xdrs, rpc_loc_calendar_time_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint16 (xdrs, &objp->year))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->month))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->day_of_week))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->day))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->hour))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->minute))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->second))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->millisecond))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_parsed_position_s_type (XDR *xdrs, rpc_loc_parsed_position_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_position_valid_mask_type (xdrs, &objp->valid_mask))\n         return FALSE;\n     if (!xdr_rpc_loc_session_status_e_type (xdrs, &objp->session_status))\n         return FALSE;\n     if (!xdr_rpc_loc_calendar_time_s_type (xdrs, &objp->timestamp_calendar))\n         return FALSE;\n     if (!xdr_rpc_uint64 (xdrs, &objp->timestamp_utc))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->leap_seconds))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->time_unc))\n         return FALSE;\n     if (!xdr_double (xdrs, &objp->latitude))\n         return FALSE;\n     if (!xdr_double (xdrs, &objp->longitude))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->altitude_wrt_ellipsoid))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->altitude_wrt_mean_sea_level))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->speed_horizontal))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->speed_vertical))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->heading))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->hor_unc_circular))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->hor_unc_ellipse_semi_major))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->hor_unc_ellipse_semi_minor))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->hor_unc_ellipse_orient_azimuth))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->vert_unc))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->speed_unc))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->heading_unc))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->confidence_horizontal))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->confidence_vertical))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->magnetic_deviation))\n         return FALSE;\n     if (!xdr_rpc_loc_pos_technology_mask_type (xdrs, &objp->technology_mask))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_sv_system_e_type (XDR *xdrs, rpc_loc_sv_system_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_sv_status_e_type (XDR *xdrs, rpc_loc_sv_status_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_sv_info_valid_mask_type (XDR *xdrs, rpc_loc_sv_info_valid_mask_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_sv_info_s_type (XDR *xdrs, rpc_loc_sv_info_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_sv_info_valid_mask_type (xdrs, &objp->valid_mask))\n         return FALSE;\n     if (!xdr_rpc_loc_sv_system_e_type (xdrs, &objp->system))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->prn))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->health_status))\n         return FALSE;\n     if (!xdr_rpc_loc_sv_status_e_type (xdrs, &objp->process_status))\n         return FALSE;\n     if (!xdr_rpc_boolean (xdrs, &objp->has_eph))\n         return FALSE;\n     if (!xdr_rpc_boolean (xdrs, &objp->has_alm))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->elevation))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->azimuth))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->snr))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_gnss_info_valid_mask_type (XDR *xdrs, rpc_loc_gnss_info_valid_mask_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_gnss_info_s_type (XDR *xdrs, rpc_loc_gnss_info_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_gnss_info_valid_mask_type (xdrs, &objp->valid_mask))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->position_dop))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->horizontal_dop))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->vertical_dop))\n         return FALSE;\n     if (!xdr_rpc_boolean (xdrs, &objp->altitude_assumed))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->sv_count))\n         return FALSE;\n     if (!xdr_array (xdrs, (char **)&objp->sv_list.sv_list_val, (u_int *) &objp->sv_list.sv_list_len, 80,\n        sizeof (rpc_loc_sv_info_s_type), (xdrproc_t) xdr_rpc_loc_sv_info_s_type))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_nmea_report_s_type (XDR *xdrs, rpc_loc_nmea_report_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_uint16 (xdrs, &objp->length))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->nmea_sentences, 200))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_status_event_e_type (XDR *xdrs, rpc_loc_status_event_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_engine_state_e_type (XDR *xdrs, rpc_loc_engine_state_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_fix_session_state_e_type (XDR *xdrs, rpc_loc_fix_session_state_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_status_event_payload_u_type (XDR *xdrs, rpc_loc_status_event_payload_u_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_status_event_e_type (xdrs, &objp->disc))\n         return FALSE;\n    switch (objp->disc) {\n    case RPC_LOC_STATUS_EVENT_ENGINE_STATE:\n         if (!xdr_rpc_loc_engine_state_e_type (xdrs, &objp->rpc_loc_status_event_payload_u_type_u.engine_state))\n             return FALSE;\n        break;\n    case RPC_LOC_STATUS_EVENT_FIX_SESSION_STATE:\n         if (!xdr_rpc_loc_fix_session_state_e_type (xdrs, &objp->rpc_loc_status_event_payload_u_type_u.fix_session_state))\n             return FALSE;\n        break;\n    default:\n        break;\n    }\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_status_event_s_type (XDR *xdrs, rpc_loc_status_event_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_status_event_e_type (xdrs, &objp->event))\n         return FALSE;\n     if (!xdr_rpc_loc_status_event_payload_u_type (xdrs, &objp->payload))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_addr_e_type (XDR *xdrs, rpc_loc_server_addr_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_addr_ipv4_type (XDR *xdrs, rpc_loc_server_addr_ipv4_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, &objp->addr))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->port))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_addr_url_type (XDR *xdrs, rpc_loc_server_addr_url_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_uint16 (xdrs, &objp->length))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->addr, 256))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_addr_ipv6_type (XDR *xdrs, rpc_loc_server_addr_ipv6_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_vector (xdrs, (char *)objp->addr, 8,\n        sizeof (rpc_uint16), (xdrproc_t) xdr_rpc_uint16))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->port))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_addr_u_type (XDR *xdrs, rpc_loc_server_addr_u_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_server_addr_e_type (xdrs, &objp->disc))\n         return FALSE;\n    switch (objp->disc) {\n    case RPC_LOC_SERVER_ADDR_IPV4:\n         if (!xdr_rpc_loc_server_addr_ipv4_type (xdrs, &objp->rpc_loc_server_addr_u_type_u.ipv4))\n             return FALSE;\n        break;\n    case RPC_LOC_SERVER_ADDR_URL:\n         if (!xdr_rpc_loc_server_addr_url_type (xdrs, &objp->rpc_loc_server_addr_u_type_u.url))\n             return FALSE;\n        break;\n    case RPC_LOC_SERVER_ADDR_IPV6:\n         if (!xdr_rpc_loc_server_addr_ipv6_type (xdrs, &objp->rpc_loc_server_addr_u_type_u.ipv6))\n             return FALSE;\n        break;\n    default:\n        break;\n    }\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_info_s_type (XDR *xdrs, rpc_loc_server_info_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_server_addr_e_type (xdrs, &objp->addr_type))\n         return FALSE;\n     if (!xdr_rpc_loc_server_addr_u_type (xdrs, &objp->addr_info))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_notify_verify_e_type (XDR *xdrs, rpc_loc_ni_notify_verify_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_event_e_type (XDR *xdrs, rpc_loc_ni_event_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_datacoding_scheme_e_type (XDR *xdrs, rpc_loc_ni_datacoding_scheme_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_vx_requester_id_encoding_scheme_e_type (XDR *xdrs, rpc_loc_ni_vx_requester_id_encoding_scheme_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_vx_pos_mode_e_type (XDR *xdrs, rpc_loc_ni_vx_pos_mode_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_vx_requester_id_s_type (XDR *xdrs, rpc_loc_ni_vx_requester_id_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_u_char (xdrs, &objp->requester_id_length))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->requester_id, 200))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_vx_notify_verify_req_s_type (XDR *xdrs, rpc_loc_ni_vx_notify_verify_req_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_ni_notify_verify_e_type (xdrs, &objp->notification_priv_type))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->pos_qos_incl))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->pos_qos))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->num_fixes))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->tbf))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_vx_pos_mode_e_type (xdrs, &objp->pos_mode))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_vx_requester_id_encoding_scheme_e_type (xdrs, &objp->encoding_scheme))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_vx_requester_id_s_type (xdrs, &objp->requester_id))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->user_resp_timer_val))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_supl_pos_method_e_type (XDR *xdrs, rpc_loc_ni_supl_pos_method_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_supl_slp_session_id_s_type (XDR *xdrs, rpc_loc_ni_supl_slp_session_id_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_u_char (xdrs, &objp->presence))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->session_id, 4))\n         return FALSE;\n     if (!xdr_rpc_loc_server_info_s_type (xdrs, &objp->slp_address))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_requestor_id_s_type (XDR *xdrs, rpc_loc_ni_requestor_id_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_u_char (xdrs, &objp->data_coding_scheme))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->requestor_id_string, 200))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->string_len))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_supl_client_name_s_type (XDR *xdrs, rpc_loc_ni_supl_client_name_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_u_char (xdrs, &objp->data_coding_scheme))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->client_name_string, 64))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->string_len))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_supl_qop_s_type (XDR *xdrs, rpc_loc_ni_supl_qop_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_u_char (xdrs, &objp->bit_mask))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->horacc))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->veracc))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->maxLocAge))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->delay))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_supl_notify_verify_req_s_type (XDR *xdrs, rpc_loc_ni_supl_notify_verify_req_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_loc_ni_notify_verify_e_type (xdrs, &objp->notification_priv_type))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->flags))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_supl_slp_session_id_s_type (xdrs, &objp->supl_slp_session_id))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->supl_hash, 8))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_datacoding_scheme_e_type (xdrs, &objp->datacoding_scheme))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_supl_pos_method_e_type (xdrs, &objp->pos_method))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_requestor_id_s_type (xdrs, &objp->requestor_id))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_supl_client_name_s_type (xdrs, &objp->client_name))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_supl_qop_s_type (xdrs, &objp->supl_qop))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->user_response_timer))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_ext_client_address_s_type (XDR *xdrs, rpc_loc_ni_ext_client_address_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_u_char (xdrs, &objp->ext_client_address_len))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->ext_client_address, 20))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_location_type_e_type (XDR *xdrs, rpc_loc_ni_location_type_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_deferred_location_s_type (XDR *xdrs, rpc_loc_ni_deferred_location_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_u_char (xdrs, &objp->unused_bits))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->ms_available))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_codeword_string_s_type (XDR *xdrs, rpc_loc_ni_codeword_string_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_u_char (xdrs, &objp->data_coding_scheme))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->lcs_codeword_string, 20))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->string_len))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_service_type_id_s_type (XDR *xdrs, rpc_loc_ni_service_type_id_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_u_char (xdrs, &objp->lcs_service_type_id))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_umts_cp_notify_verify_req_s_type (XDR *xdrs, rpc_loc_ni_umts_cp_notify_verify_req_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_loc_ni_notify_verify_e_type (xdrs, &objp->notification_priv_type))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->invoke_id))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->flags))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->notification_length))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->notification_text, 64))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_datacoding_scheme_e_type (xdrs, &objp->datacoding_scheme))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_ext_client_address_s_type (xdrs, &objp->ext_client_address_data))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_location_type_e_type (xdrs, &objp->location_type))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_deferred_location_s_type (xdrs, &objp->deferred_location))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_requestor_id_s_type (xdrs, &objp->requestor_id))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_codeword_string_s_type (xdrs, &objp->codeword_string))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_service_type_id_s_type (xdrs, &objp->service_type_id))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->user_response_timer))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_service_interaction_e_type (XDR *xdrs, rpc_loc_ni_service_interaction_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_vx_service_interaction_req_s_type (XDR *xdrs, rpc_loc_ni_vx_service_interaction_req_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_ni_vx_notify_verify_req_s_type (xdrs, &objp->ni_vx_req))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_service_interaction_e_type (xdrs, &objp->service_interation_type))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_event_payload_u_type (XDR *xdrs, rpc_loc_ni_event_payload_u_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_ni_event_e_type (xdrs, &objp->disc))\n         return FALSE;\n    switch (objp->disc) {\n    case RPC_LOC_NI_EVENT_VX_NOTIFY_VERIFY_REQ:\n         if (!xdr_rpc_loc_ni_vx_notify_verify_req_s_type (xdrs, &objp->rpc_loc_ni_event_payload_u_type_u.vx_req))\n             return FALSE;\n        break;\n    case RPC_LOC_NI_EVENT_SUPL_NOTIFY_VERIFY_REQ:\n         if (!xdr_rpc_loc_ni_supl_notify_verify_req_s_type (xdrs, &objp->rpc_loc_ni_event_payload_u_type_u.supl_req))\n             return FALSE;\n        break;\n    case RPC_LOC_NI_EVENT_UMTS_CP_NOTIFY_VERIFY_REQ:\n         if (!xdr_rpc_loc_ni_umts_cp_notify_verify_req_s_type (xdrs, &objp->rpc_loc_ni_event_payload_u_type_u.umts_cp_req))\n             return FALSE;\n        break;\n    case RPC_LOC_NI_EVENT_VX_SERVICE_INTERACTION_REQ:\n         if (!xdr_rpc_loc_ni_vx_service_interaction_req_s_type (xdrs, &objp->rpc_loc_ni_event_payload_u_type_u.service_interaction_req))\n             return FALSE;\n        break;\n    default:\n        break;\n    }\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_event_s_type (XDR *xdrs, rpc_loc_ni_event_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_ni_event_e_type (xdrs, &objp->event))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_event_payload_u_type (xdrs, &objp->payload))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_assist_data_request_e_type (XDR *xdrs, rpc_loc_assist_data_request_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_struct_loc_time_download_source_s_type_servers_ptr (XDR *xdrs, rpc_struct_loc_time_download_source_s_type_servers_ptr *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_string (xdrs, objp, 256))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_struct_loc_time_download_source_s_type_servers (XDR *xdrs, rpc_struct_loc_time_download_source_s_type_servers objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_vector (xdrs, (char *)objp, 3,\n        sizeof (rpc_struct_loc_time_download_source_s_type_servers_ptr), (xdrproc_t) xdr_rpc_struct_loc_time_download_source_s_type_servers_ptr))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_time_download_source_s_type (XDR *xdrs, rpc_loc_time_download_source_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, &objp->delay_threshold))\n         return FALSE;\n     if (!xdr_rpc_struct_loc_time_download_source_s_type_servers (xdrs, objp->servers))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr (XDR *xdrs, rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_string (xdrs, objp, 256))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_struct_loc_predicted_orbits_data_source_s_type_servers (XDR *xdrs, rpc_struct_loc_predicted_orbits_data_source_s_type_servers objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_vector (xdrs, (char *)objp, 3,\n        sizeof (rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr), (xdrproc_t) xdr_rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_predicted_orbits_data_source_s_type (XDR *xdrs, rpc_loc_predicted_orbits_data_source_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, &objp->max_file_size))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->max_part_size))\n         return FALSE;\n     if (!xdr_rpc_struct_loc_predicted_orbits_data_source_s_type_servers (xdrs, objp->servers))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_pos_inj_request_s_type (XDR *xdrs, rpc_loc_pos_inj_request_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, &objp->flags))\n         return FALSE;\n     if (!xdr_double (xdrs, &objp->latitude))\n         return FALSE;\n     if (!xdr_double (xdrs, &objp->longitude))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->position_uncertainty))\n         return FALSE;\n     if (!xdr_rpc_uint64 (xdrs, &objp->timestamp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_assist_data_request_payload_u_type (XDR *xdrs, rpc_loc_assist_data_request_payload_u_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_assist_data_request_e_type (xdrs, &objp->disc))\n         return FALSE;\n    switch (objp->disc) {\n    case RPC_LOC_ASSIST_DATA_TIME_REQ:\n         if (!xdr_rpc_loc_time_download_source_s_type (xdrs, &objp->rpc_loc_assist_data_request_payload_u_type_u.time_download))\n             return FALSE;\n        break;\n    case RPC_LOC_ASSIST_DATA_PREDICTED_ORBITS_REQ:\n         if (!xdr_rpc_loc_predicted_orbits_data_source_s_type (xdrs, &objp->rpc_loc_assist_data_request_payload_u_type_u.data_download))\n             return FALSE;\n        break;\n    case RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ:\n         if (!xdr_rpc_loc_pos_inj_request_s_type (xdrs, &objp->rpc_loc_assist_data_request_payload_u_type_u.pos_injection))\n             return FALSE;\n        break;\n    default:\n        break;\n    }\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_assist_data_request_s_type (XDR *xdrs, rpc_loc_assist_data_request_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_assist_data_request_e_type (xdrs, &objp->event))\n         return FALSE;\n     if (!xdr_rpc_loc_assist_data_request_payload_u_type (xdrs, &objp->payload))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_connection_handle (XDR *xdrs, rpc_loc_server_connection_handle *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_protocol_e_type (XDR *xdrs, rpc_loc_server_protocol_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_connection_e_type (XDR *xdrs, rpc_loc_server_connection_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_request_e_type (XDR *xdrs, rpc_loc_server_request_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_open_req_s_type (XDR *xdrs, rpc_loc_server_open_req_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_server_connection_handle (xdrs, &objp->conn_handle))\n         return FALSE;\n     if (!xdr_rpc_loc_server_protocol_e_type (xdrs, &objp->protocol))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_multi_open_req_s_type (XDR *xdrs, rpc_loc_server_multi_open_req_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_server_connection_handle (xdrs, &objp->conn_handle))\n         return FALSE;\n     if (!xdr_rpc_loc_server_protocol_e_type (xdrs, &objp->protocol))\n         return FALSE;\n     if (!xdr_rpc_loc_server_connection_e_type (xdrs, &objp->connection_type))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_close_req_s_type (XDR *xdrs, rpc_loc_server_close_req_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_server_connection_handle (xdrs, &objp->conn_handle))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_request_u_type (XDR *xdrs, rpc_loc_server_request_u_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_server_request_e_type (xdrs, &objp->disc))\n         return FALSE;\n    switch (objp->disc) {\n    case RPC_LOC_SERVER_REQUEST_OPEN:\n         if (!xdr_rpc_loc_server_open_req_s_type (xdrs, &objp->rpc_loc_server_request_u_type_u.open_req))\n             return FALSE;\n        break;\n    case RPC_LOC_SERVER_REQUEST_CLOSE:\n         if (!xdr_rpc_loc_server_close_req_s_type (xdrs, &objp->rpc_loc_server_request_u_type_u.close_req))\n             return FALSE;\n        break;\n    case RPC_LOC_SERVER_REQUEST_MULTI_OPEN:\n         if (!xdr_rpc_loc_server_multi_open_req_s_type (xdrs, &objp->rpc_loc_server_request_u_type_u.multi_open_req))\n             return FALSE;\n        break;\n    default:\n        break;\n    }\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_request_s_type (XDR *xdrs, rpc_loc_server_request_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_server_request_e_type (xdrs, &objp->event))\n         return FALSE;\n     if (!xdr_rpc_loc_server_request_u_type (xdrs, &objp->payload))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_qwip_request_e_type (XDR *xdrs, rpc_loc_qwip_request_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_qwip_request_s_type (XDR *xdrs, rpc_loc_qwip_request_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_qwip_request_e_type (xdrs, &objp->request_type))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->tbf_ms))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_reserved_payload_s_type (XDR *xdrs, rpc_loc_reserved_payload_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint16 (xdrs, &objp->data_size))\n         return FALSE;\n     if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ioctl_e_type (XDR *xdrs, rpc_loc_ioctl_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_api_version_s_type (XDR *xdrs, rpc_loc_api_version_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_u_char (xdrs, &objp->major))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->minor))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_fix_recurrence_e_type (XDR *xdrs, rpc_loc_fix_recurrence_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_operation_mode_e_type (XDR *xdrs, rpc_loc_operation_mode_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_notify_e_type (XDR *xdrs, rpc_loc_notify_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_fix_criteria_s_type (XDR *xdrs, rpc_loc_fix_criteria_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, &objp->valid_mask))\n         return FALSE;\n     if (!xdr_rpc_loc_fix_recurrence_e_type (xdrs, &objp->recurrence_type))\n         return FALSE;\n     if (!xdr_rpc_loc_operation_mode_e_type (xdrs, &objp->preferred_operation_mode))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->preferred_accuracy))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->preferred_response_time))\n         return FALSE;\n     if (!xdr_rpc_boolean (xdrs, &objp->intermediate_pos_report_enabled))\n         return FALSE;\n     if (!xdr_rpc_loc_notify_e_type (xdrs, &objp->notify_type))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->min_interval))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->min_distance))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->min_dist_sample_interval))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ni_user_resp_e_type (XDR *xdrs, rpc_loc_ni_user_resp_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_user_verify_s_type (XDR *xdrs, rpc_loc_user_verify_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_ni_user_resp_e_type (xdrs, &objp->user_resp))\n         return FALSE;\n     if (!xdr_rpc_loc_ni_event_s_type (xdrs, &objp->ni_event_pass_back))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_predicted_orbits_data_format_e_type (XDR *xdrs, rpc_loc_predicted_orbits_data_format_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_predicted_orbits_data_s_type (XDR *xdrs, rpc_loc_predicted_orbits_data_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_predicted_orbits_data_format_e_type (xdrs, &objp->format_type))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->total_size))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->total_parts))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->part))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->part_len))\n         return FALSE;\n     if (!xdr_bytes (xdrs, (char **)&objp->data_ptr.data_ptr_val, (u_int *) &objp->data_ptr.data_ptr_len, ~0))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_predicted_orbits_data_validity_report_s_type (XDR *xdrs, rpc_loc_predicted_orbits_data_validity_report_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint64 (xdrs, &objp->start_time_utc))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->valid_duration_hrs))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_predicted_orbits_auto_download_config_s_type (XDR *xdrs, rpc_loc_predicted_orbits_auto_download_config_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_boolean (xdrs, &objp->enable))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->auto_check_every_hrs))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_assist_data_time_s_type (XDR *xdrs, rpc_loc_assist_data_time_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint64 (xdrs, &objp->time_utc))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->uncertainty))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_assist_pos_valid_mask_type (XDR *xdrs, rpc_loc_assist_pos_valid_mask_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint64 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_assist_data_pos_s_type (XDR *xdrs, rpc_loc_assist_data_pos_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_assist_pos_valid_mask_type (xdrs, &objp->valid_mask))\n         return FALSE;\n     if (!xdr_rpc_uint64 (xdrs, &objp->timestamp_utc))\n         return FALSE;\n     if (!xdr_double (xdrs, &objp->latitude))\n         return FALSE;\n     if (!xdr_double (xdrs, &objp->longitude))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->altitude_wrt_ellipsoid))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->altitude_wrt_mean_sea_level))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->hor_unc_circular))\n         return FALSE;\n     if (!xdr_float (xdrs, &objp->vert_unc))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->confidence_horizontal))\n         return FALSE;\n     if (!xdr_u_char (xdrs, &objp->confidence_vertical))\n         return FALSE;\n     if (!xdr_rpc_int32 (xdrs, &objp->timestamp_age))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_open_status_e_type (XDR *xdrs, rpc_loc_server_open_status_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_pdp_type_e_type (XDR *xdrs, rpc_loc_server_pdp_type_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_open_status_s_type (XDR *xdrs, rpc_loc_server_open_status_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_loc_server_connection_handle (xdrs, &objp->conn_handle))\n         return FALSE;\n     if (!xdr_rpc_loc_server_open_status_e_type (xdrs, &objp->open_status))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->apn_name, 100))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_multi_open_status_s_type (XDR *xdrs, rpc_loc_server_multi_open_status_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_loc_server_connection_handle (xdrs, &objp->conn_handle))\n         return FALSE;\n     if (!xdr_rpc_loc_server_open_status_e_type (xdrs, &objp->open_status))\n         return FALSE;\n     if (!xdr_rpc_loc_server_pdp_type_e_type (xdrs, &objp->pdp_type))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->apn_name, 100))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_close_status_e_type (XDR *xdrs, rpc_loc_server_close_status_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_server_close_status_s_type (XDR *xdrs, rpc_loc_server_close_status_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_server_connection_handle (xdrs, &objp->conn_handle))\n         return FALSE;\n     if (!xdr_rpc_loc_server_close_status_e_type (xdrs, &objp->close_status))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_wiper_fix_time_s_type (XDR *xdrs, rpc_loc_wiper_fix_time_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, &objp->slow_clock_count))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_wiper_fix_pos_s_type (XDR *xdrs, rpc_loc_wiper_fix_pos_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_int32 (xdrs, &objp->lat))\n         return FALSE;\n     if (!xdr_rpc_int32 (xdrs, &objp->lon))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->HEPE))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->num_of_aps_used))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->fix_error_code))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_wiper_ap_info_s_type (XDR *xdrs, rpc_loc_wiper_ap_info_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_opaque (xdrs, objp->mac_addr, 6))\n         return FALSE;\n     if (!xdr_rpc_int32 (xdrs, &objp->rssi))\n         return FALSE;\n     if (!xdr_rpc_uint16 (xdrs, &objp->channel))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->ap_qualifier))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_wiper_ap_set_s_type (XDR *xdrs, rpc_loc_wiper_ap_set_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_uint8 (xdrs, &objp->num_of_aps))\n         return FALSE;\n     if (!xdr_vector (xdrs, (char *)objp->ap_info, 50,\n        sizeof (rpc_loc_wiper_ap_info_s_type), (xdrproc_t) xdr_rpc_loc_wiper_ap_info_s_type))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_wiper_position_report_s_type (XDR *xdrs, rpc_loc_wiper_position_report_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint8 (xdrs, &objp->wiper_valid_info_flag))\n         return FALSE;\n     if (!xdr_rpc_loc_wiper_fix_time_s_type (xdrs, &objp->wiper_fix_time))\n         return FALSE;\n     if (!xdr_rpc_loc_wiper_fix_pos_s_type (xdrs, &objp->wiper_fix_position))\n         return FALSE;\n     if (!xdr_rpc_loc_wiper_ap_set_s_type (xdrs, &objp->wiper_ap_set))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_wiper_status_e_type (XDR *xdrs, rpc_loc_wiper_status_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_fs_operation_e_type (XDR *xdrs, rpc_loc_fs_operation_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_efs_data_s_type (XDR *xdrs, rpc_loc_efs_data_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_opaque (xdrs, objp->filename, 64))\n         return FALSE;\n     if (!xdr_rpc_loc_fs_operation_e_type (xdrs, &objp->operation))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->total_size))\n         return FALSE;\n     if (!xdr_bytes (xdrs, (char **)&objp->data_ptr.data_ptr_val, (u_int *) &objp->data_ptr.data_ptr_len, ~0))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->part_len))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->part))\n         return FALSE;\n     if (!xdr_rpc_uint8 (xdrs, &objp->total_parts))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->reserved))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_error_estimate_config_e_type (XDR *xdrs, rpc_loc_error_estimate_config_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_apn_profiles_type (XDR *xdrs, rpc_loc_apn_profiles_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_uint32 (xdrs, &objp->srv_system_type))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->pdp_type))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->reserved))\n         return FALSE;\n     if (!xdr_opaque (xdrs, objp->apn_name, 100))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_lock_e_type (XDR *xdrs, rpc_loc_lock_e_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_enum (xdrs, (enum_t *) objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_nmea_sentence_type (XDR *xdrs, rpc_loc_nmea_sentence_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_assist_data_type (XDR *xdrs, rpc_loc_assist_data_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_uint32 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_assist_data_delete_s_type (XDR *xdrs, rpc_loc_assist_data_delete_s_type *objp)\n{\n    register int32_t *buf;\n\n    int i;\n     if (!xdr_rpc_loc_assist_data_type (xdrs, &objp->type))\n         return FALSE;\n     if (!xdr_vector (xdrs, (char *)objp->reserved, 8,\n        sizeof (rpc_uint32), (xdrproc_t) xdr_rpc_uint32))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ioctl_data_u_type (XDR *xdrs, rpc_loc_ioctl_data_u_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_ioctl_e_type (xdrs, &objp->disc))\n         return FALSE;\n    switch (objp->disc) {\n    case RPC_LOC_IOCTL_SET_FIX_CRITERIA:\n         if (!xdr_rpc_loc_fix_criteria_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.fix_criteria))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE:\n         if (!xdr_rpc_loc_user_verify_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.user_verify_resp))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA:\n         if (!xdr_rpc_loc_predicted_orbits_data_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.predicted_orbits_data))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD:\n         if (!xdr_rpc_loc_predicted_orbits_auto_download_config_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.predicted_orbits_auto_download))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_INJECT_UTC_TIME:\n         if (!xdr_rpc_loc_assist_data_time_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.assistance_data_time))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_INJECT_POSITION:\n         if (!xdr_rpc_loc_assist_data_pos_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.assistance_data_position))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS:\n         if (!xdr_rpc_loc_server_open_status_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.conn_open_status))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS:\n         if (!xdr_rpc_loc_server_close_status_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.conn_close_status))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SEND_WIPER_POSITION_REPORT:\n         if (!xdr_rpc_loc_wiper_position_report_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.wiper_pos))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_NOTIFY_WIPER_STATUS:\n         if (!xdr_rpc_loc_wiper_status_e_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.wiper_status))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_ENGINE_LOCK:\n         if (!xdr_rpc_loc_lock_e_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.engine_lock))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_SBAS_CONFIG:\n         if (!xdr_rpc_boolean (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.sbas_mode))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_NMEA_TYPES:\n         if (!xdr_rpc_loc_nmea_sentence_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.nmea_types))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_ON_DEMAND_LPM:\n         if (!xdr_rpc_boolean (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.on_demand_lpm))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR:\n    case RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR:\n    case RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR:\n    case RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR:\n         if (!xdr_rpc_loc_server_info_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.server_addr))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_DELETE_ASSIST_DATA:\n         if (!xdr_rpc_loc_assist_data_delete_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.assist_data_delete))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_ACCESS_EFS_DATA:\n         if (!xdr_rpc_loc_efs_data_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.efs_data))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG:\n         if (!xdr_rpc_loc_error_estimate_config_e_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.error_estimate_config))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL:\n         if (!xdr_rpc_uint8 (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.xtra_t_session_control))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_LBS_APN_PROFILE:\n    case RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE:\n         if (!xdr_vector (xdrs, (char *)objp->rpc_loc_ioctl_data_u_type_u.apn_profiles, 6,\n            sizeof (rpc_loc_apn_profiles_type), (xdrproc_t) xdr_rpc_loc_apn_profiles_type))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_DATA_ENABLE:\n         if (!xdr_rpc_boolean (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.data_enable))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_SET_SUPL_VERSION:\n         if (!xdr_rpc_uint32 (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.supl_version))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS:\n         if (!xdr_rpc_loc_server_multi_open_status_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.multi_conn_open_status))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_RESERVED_CMD:\n         if (!xdr_rpc_loc_reserved_payload_s_type (xdrs, &objp->rpc_loc_ioctl_data_u_type_u.reserved))\n             return FALSE;\n        break;\n    default:\n        break;\n    }\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ioctl_callback_data_u_type (XDR *xdrs, rpc_loc_ioctl_callback_data_u_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_ioctl_e_type (xdrs, &objp->disc))\n         return FALSE;\n    switch (objp->disc) {\n    case RPC_LOC_IOCTL_GET_API_VERSION:\n         if (!xdr_rpc_loc_api_version_s_type (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.api_version))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_FIX_CRITERIA:\n         if (!xdr_rpc_loc_fix_criteria_s_type (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.fix_criteria))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_ENGINE_LOCK:\n         if (!xdr_rpc_loc_lock_e_type (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.engine_lock))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_SBAS_CONFIG:\n         if (!xdr_rpc_boolean (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.sbas_mode))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_NMEA_TYPES:\n         if (!xdr_rpc_loc_nmea_sentence_type (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.nmea_types))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_ON_DEMAND_LPM:\n         if (!xdr_rpc_boolean (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.on_demand_lpm))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR:\n    case RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR:\n    case RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR:\n    case RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR:\n         if (!xdr_rpc_loc_server_info_s_type (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.server_addr))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE:\n         if (!xdr_rpc_loc_predicted_orbits_data_source_s_type (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.predicted_orbits_data_source))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY:\n         if (!xdr_rpc_loc_predicted_orbits_data_validity_report_s_type (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.predicted_orbits_data_validity))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL:\n         if (!xdr_rpc_uint8 (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.xtra_t_session_control))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_LBS_APN_PROFILE:\n    case RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE:\n         if (!xdr_vector (xdrs, (char *)objp->rpc_loc_ioctl_callback_data_u_type_u.apn_profiles, 6,\n            sizeof (rpc_loc_apn_profiles_type), (xdrproc_t) xdr_rpc_loc_apn_profiles_type))\n             return FALSE;\n        break;\n    case RPC_LOC_IOCTL_GET_SUPL_VERSION:\n         if (!xdr_rpc_uint32 (xdrs, &objp->rpc_loc_ioctl_callback_data_u_type_u.supl_version))\n             return FALSE;\n        break;\n    default:\n        break;\n    }\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ioctl_callback_s_type (XDR *xdrs, rpc_loc_ioctl_callback_s_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_rpc_loc_ioctl_e_type (xdrs, &objp->type))\n         return FALSE;\n     if (!xdr_rpc_int32 (xdrs, &objp->status))\n         return FALSE;\n     if (!xdr_rpc_loc_ioctl_callback_data_u_type (xdrs, &objp->data))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_event_payload_u_type (XDR *xdrs, rpc_loc_event_payload_u_type *objp)\n{\n    register int32_t *buf;\n\n     if (!xdr_u_quad_t (xdrs, &objp->disc))\n         return FALSE;\n    switch (objp->disc) {\n    case RPC_LOC_EVENT_PARSED_POSITION_REPORT:\n         if (!xdr_rpc_loc_parsed_position_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.parsed_location_report))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_SATELLITE_REPORT:\n         if (!xdr_rpc_loc_gnss_info_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.gnss_report))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_NMEA_POSITION_REPORT:\n    case RPC_LOC_EVENT_NMEA_1HZ_REPORT:\n         if (!xdr_rpc_loc_nmea_report_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.nmea_report))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST:\n         if (!xdr_rpc_loc_ni_event_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.ni_request))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST:\n         if (!xdr_rpc_loc_assist_data_request_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.assist_data_request))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_LOCATION_SERVER_REQUEST:\n         if (!xdr_rpc_loc_server_request_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.loc_server_request))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_IOCTL_REPORT:\n         if (!xdr_rpc_loc_ioctl_callback_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.ioctl_report))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_STATUS_REPORT:\n         if (!xdr_rpc_loc_status_event_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.status_report))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_WPS_NEEDED_REQUEST:\n         if (!xdr_rpc_loc_qwip_request_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.qwip_request))\n             return FALSE;\n        break;\n    case RPC_LOC_EVENT_RESERVED:\n         if (!xdr_rpc_loc_reserved_payload_s_type (xdrs, &objp->rpc_loc_event_payload_u_type_u.reserved))\n             return FALSE;\n        break;\n    default:\n        break;\n    }\n    return TRUE;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/src/loc_api_rpcgen_xdr.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#include \"loc_api_rpcgen_rpc.h\"\n\nbool_t\nxdr_rpc_loc_api_api_versions_return_type (XDR *xdrs, rpc_loc_api_api_versions_return_type *objp)\n{\n;\n\n     if (!xdr_array (xdrs, (char **)&objp->rpc_loc_api_api_versions_return_type_val, (u_int *) &objp->rpc_loc_api_api_versions_return_type_len, ~0,\n        sizeof (rpc_uint32), (xdrproc_t) xdr_rpc_uint32))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_event_cb_f_type (XDR *xdrs, rpc_loc_event_cb_f_type *objp)\n{\n;\n\n     if (!xdr_rpc_uint32 (xdrs, objp))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_open_args (XDR *xdrs, rpc_loc_open_args *objp)\n{\n;\n\n     if (!xdr_rpc_loc_event_mask_type (xdrs, &objp->event_reg_mask))\n         return FALSE;\n     if (!xdr_rpc_loc_event_cb_f_type (xdrs, &objp->event_callback))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_close_args (XDR *xdrs, rpc_loc_close_args *objp)\n{\n;\n\n     if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_start_fix_args (XDR *xdrs, rpc_loc_start_fix_args *objp)\n{\n;\n\n     if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_stop_fix_args (XDR *xdrs, rpc_loc_stop_fix_args *objp)\n{\n;\n\n     if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ioctl_args (XDR *xdrs, rpc_loc_ioctl_args *objp)\n{\n;\n\n     if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))\n         return FALSE;\n     if (!xdr_rpc_loc_ioctl_e_type (xdrs, &objp->ioctl_type))\n         return FALSE;\n     if (!xdr_pointer (xdrs, (char **)&objp->ioctl_data, sizeof (rpc_loc_ioctl_data_u_type), (xdrproc_t) xdr_rpc_loc_ioctl_data_u_type))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_api_api_version_s_args (XDR *xdrs, rpc_loc_api_api_version_s_args *objp)\n{\n;\n\n     if (!xdr_rpc_boolean (xdrs, &objp->len_not_null))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_api_rpc_glue_code_info_remote_rets (XDR *xdrs, rpc_loc_api_rpc_glue_code_info_remote_rets *objp)\n{\n;\n\n     if (!xdr_rpc_uint32 (xdrs, &objp->toolvers))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->features))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->proghash))\n         return FALSE;\n     if (!xdr_rpc_uint32 (xdrs, &objp->cbproghash))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_open_rets (XDR *xdrs, rpc_loc_open_rets *objp)\n{\n;\n\n     if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->loc_open_result))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_close_rets (XDR *xdrs, rpc_loc_close_rets *objp)\n{\n;\n\n     if (!xdr_rpc_int32 (xdrs, &objp->loc_close_result))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_start_fix_rets (XDR *xdrs, rpc_loc_start_fix_rets *objp)\n{\n;\n\n     if (!xdr_rpc_int32 (xdrs, &objp->loc_start_fix_result))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_stop_fix_rets (XDR *xdrs, rpc_loc_stop_fix_rets *objp)\n{\n;\n\n     if (!xdr_rpc_int32 (xdrs, &objp->loc_stop_fix_result))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_ioctl_rets (XDR *xdrs, rpc_loc_ioctl_rets *objp)\n{\n;\n\n     if (!xdr_rpc_int32 (xdrs, &objp->loc_ioctl_result))\n         return FALSE;\n    return TRUE;\n}\n\nbool_t\nxdr_rpc_loc_api_api_versions_rets (XDR *xdrs, rpc_loc_api_api_versions_rets *objp)\n{\n;\n\n     if (!xdr_rpc_loc_api_api_versions_return_type (xdrs, &objp->loc_api_api_versions_result))\n         return FALSE;\n     if (!xdr_pointer (xdrs, (char **)&objp->len, sizeof (rpc_uint32), (xdrproc_t) xdr_rpc_uint32))\n         return FALSE;\n    return TRUE;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/src/loc_apicb_appinit.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#include \"librpc.h\"\n#include \"loc_api_rpcgen_rpc.h\"\n#include \"loc_api_rpcgen_cb_rpc.h\"\n\n\n#define RPC_FUNC_VERSION_BASE(a,b) a ## b\n#define RPC_CB_FUNC_VERS(a,b) RPC_FUNC_VERSION_BASE(a,b)\n\n\nstatic SVCXPRT* svrPort = NULL;\n\nextern void RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001)(struct svc_req *rqstp, register SVCXPRT *transp);\n\nint loc_apicb_app_init(void)\n{\n\n  /* Register a callback server to use the loc_apicbprog_0x00010001  */\n  if (svrPort == NULL) {\n        svrPort = svcrtr_create();\n  }\n  if (!svrPort) return -1;\n\n  xprt_register(svrPort);\n\n\n\n  if(svc_register(svrPort, LOC_APICBPROG,LOC_APICBVERS_0001, RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001),0))\n  {\n     return 0;\n  }\n  else\n  {\n    return -1;\n  }\n}\nvoid loc_apicb_app_deinit(void)\n{\n\n   if (svrPort == NULL)\n   {\n      return;\n   }\n\n\n  svc_unregister(svrPort, LOC_APICBPROG,LOC_APICBVERS_0001);\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/xdr/loc_api.xdr",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/* LOC_API TOOL VERSION: 4.48 */\n/* GENERATED: TUE JUN 14 2011 */\n/*=============================================================================\n                             L O C _ A P I . X D R\n\nGENERAL DESCRIPTION\n  This is an AUTO GENERATED file that provides an xdr compatible definition of\n  the loc_api API.\n\n  ---------------------------------------------------------------------------\n\n\n  ---------------------------------------------------------------------------\n=============================================================================*/\n\n/*=============================================================================\n\n                              Edit History\n\n                             AUTO GENERATED\n\nGenerated by following versions of Htorpc modules:\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/htorpc.pl#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Start.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Htoxdr.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/XDR.pm#3\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Output.pm#5\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Parser.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Metacomments.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/SymbolTable.pm#1\n\nloc_api Definition File(s):\nId: //source/qcom/qct/modem/api/gps/main/latest/loc_api.h#24\n=============================================================================*/\n/*=============================================================================\n$Header$\n=============================================================================*/\n\n\n\ntypedef rpc_uint32 rpc_loc_api_api_versions_return_type<>;\n\n/*\n * Declare an rpc_uint32 type for each callback type in the API\n */\ntypedef rpc_uint32 rpc_loc_event_cb_f_type;\n\n\n\n/*\n * These are struct declarations for the function arguments\n */\n\nstruct rpc_loc_open_args {\n  rpc_loc_event_mask_type event_reg_mask;\n  rpc_loc_event_cb_f_type event_callback;\n};\n\nstruct rpc_loc_close_args {\n  rpc_loc_client_handle_type handle;\n};\n\nstruct rpc_loc_start_fix_args {\n  rpc_loc_client_handle_type handle;\n};\n\nstruct rpc_loc_stop_fix_args {\n  rpc_loc_client_handle_type handle;\n};\n\nstruct rpc_loc_ioctl_args {\n  rpc_loc_client_handle_type handle;\n  rpc_loc_ioctl_e_type ioctl_type;\n  rpc_loc_ioctl_data_u_type *ioctl_data;\n};\n\n\n\nstruct rpc_loc_api_api_version_s_args {\n  rpc_boolean len_not_null;\n};\n\n/*\n * These are struct declarations for the function results\n */\n\nstruct rpc_loc_api_rpc_glue_code_info_remote_rets {\n  rpc_uint32 toolvers;   /* Tool version */\n  rpc_uint32 features;   /* Features turned on in the code.\n                          * 0x00000001    ONCRPC Server Cleanup Support\n                          */\n  rpc_uint32 proghash;   /* Unique hash value for the API XDR definition */\n  rpc_uint32 cbproghash; /* Unique hash value for the Callbacks' XDR definition */\n};\n\nstruct rpc_loc_open_rets {\n  rpc_loc_client_handle_type loc_open_result;\n};\n\nstruct rpc_loc_close_rets {\n  rpc_int32 loc_close_result;\n};\n\nstruct rpc_loc_start_fix_rets {\n  rpc_int32 loc_start_fix_result;\n};\n\nstruct rpc_loc_stop_fix_rets {\n  rpc_int32 loc_stop_fix_result;\n};\n\nstruct rpc_loc_ioctl_rets {\n  rpc_int32 loc_ioctl_result;\n};\n\n struct rpc_loc_api_api_versions_rets {\n  rpc_loc_api_api_versions_return_type loc_api_api_versions_result;\n  rpc_uint32 *len;\n};\n\n/*\n * XDR definition of the LOC_API program ( vers. 0x00050006 )\n */\n\nprogram LOC_APIPROG {\n  version LOC_APIVERS_0001 {\n\n\tvoid\n\t\trpc_loc_api_null( void ) = 0;\n\n\trpc_loc_api_rpc_glue_code_info_remote_rets\n\t\trpc_loc_api_rpc_glue_code_info_remote( void ) = 1;\n\n\trpc_loc_open_rets\n\t\trpc_loc_open( rpc_loc_open_args ) = 2;\n\n\trpc_loc_close_rets\n\t\trpc_loc_close( rpc_loc_close_args ) = 3;\n\n\trpc_loc_start_fix_rets\n\t\trpc_loc_start_fix( rpc_loc_start_fix_args ) = 4;\n\n\trpc_loc_stop_fix_rets\n\t\trpc_loc_stop_fix( rpc_loc_stop_fix_args ) = 5;\n\n\trpc_loc_ioctl_rets\n\t\trpc_loc_ioctl( rpc_loc_ioctl_args ) = 6;\n\n\trpc_loc_api_api_versions_rets\n\t\trpc_loc_api_api_versions( void ) = 0xFFFFFFFF;\n\n\n\n\n  } = 0x00050001;\n\nversion LOC_APIVERS_0002 {\n\n/* Following elements added in enum rpc_loc_assist_data_request_e_type in 0x00050002\nRPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ\n*/\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050002\nRPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL\nRPC_LOC_IOCTL_RESERVED_CMD\nRPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL\n*/\n\n\tvoid\n\trpc_loc_api_null( void ) = 0;\n\n      } = 0x00050002;\n\nversion LOC_APIVERS_0003 {\n\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050003\nRPC_LOC_IOCTL_SET_DATA_ENABLE\nRPC_LOC_IOCTL_SET_LBS_APN_PROFILE\nRPC_LOC_IOCTL_GET_XTRA_APN_PROFILE\nRPC_LOC_IOCTL_GET_LBS_APN_PROFILE\nRPC_LOC_IOCTL_SET_XTRA_APN_PROFILE\n*/\n\n\tvoid\n\trpc_loc_api_null( void ) = 0;\n\n      } = 0x00050003;\n\nversion LOC_APIVERS_0004 {\n\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050004\nRPC_LOC_IOCTL_GET_SUPL_VERSION\nRPC_LOC_IOCTL_SET_SUPL_VERSION\n*/\n\n\tvoid\n\trpc_loc_api_null( void ) = 0;\n\n      } = 0x00050004;\n\nversion LOC_APIVERS_0005 {\n\n/* Following elements added in enum rpc_loc_server_addr_e_type in 0x00050005\nRPC_LOC_SERVER_ADDR_IPV6\n*/\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050005\nRPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG\n*/\n\n\tvoid\n\trpc_loc_api_null( void ) = 0;\n\n      } = 0x00050005;\n\n\n\n    version LOC_APIVERS_0006 {\n\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050006\nRPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS\n*/\n/* Following elements added in enum rpc_loc_server_request_e_type in 0x00050006\nRPC_LOC_SERVER_REQUEST_MULTI_OPEN\n*/\n\n\tvoid\n\trpc_loc_api_null( void ) = 0;\n\n      } = 0x00050006;\n\n\n} = 0x3000008C;\n\nconst LOC_APIVERS = 0x00050006;\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/xdr/loc_api_cb.xdr",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/* LOC_API TOOL VERSION: 4.48 */\n/* GENERATED: TUE JUN 14 2011 */\n/*=============================================================================\n                          L O C _ A P I _ C B . X D R\n\nGENERAL DESCRIPTION\n  This is an AUTO GENERATED file that provides an xdr compatible definition of\n  an api that represents the grouping of the different callback functions the\n  loc_api API supports.\n\n  ---------------------------------------------------------------------------\n\n\n  ---------------------------------------------------------------------------\n=============================================================================*/\n\n/*=============================================================================\n\n                              Edit History\n\n                             AUTO GENERATED\n\nGenerated by following versions of Htorpc modules:\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/htorpc.pl#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Start.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Htoxdr.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/XDR.pm#3\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Output.pm#5\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Parser.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Metacomments.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/SymbolTable.pm#1\n\nloc_api Definition File(s):\nId: //source/qcom/qct/modem/api/gps/main/latest/loc_api.h#24\n=============================================================================*/\n/*=============================================================================\n$Header$\n=============================================================================*/\n\n\n\n\n/*\n * These are struct declarations for the function arguments\n */\n\nstruct rpc_loc_event_cb_f_type_args {\n  rpc_uint32 cb_id;\n  rpc_loc_client_handle_type loc_handle;\n  rpc_loc_event_mask_type loc_event;\n  rpc_loc_event_payload_u_type *loc_event_payload;\n};\n\n\n\n\n\n/*\n * These are struct declaratios for the function results\n */\n\nstruct rpc_loc_event_cb_f_type_rets {\n  rpc_int32 loc_event_cb_f_type_result;\n};\n\n\n\n/*\n * XDR definition of the LOC_API callback program ( vers. 0x00050006 )\n */\n\nprogram LOC_APICBPROG {\n  version LOC_APICBVERS_0001 {\n\n\trpc_loc_event_cb_f_type_rets\n\t\trpc_loc_event_cb_f_type( rpc_loc_event_cb_f_type_args ) = 1;\n\n\n\n\n  } = 0x00050001;\n\nversion LOC_APICBVERS_0002 {\n\n/* Following elements added in enum rpc_loc_assist_data_request_e_type in 0x00050002\nRPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ\n*/\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050002\nRPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL\nRPC_LOC_IOCTL_RESERVED_CMD\nRPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL\n*/\n\n\tint\n\trpc_loc_api_cb_null( void ) = 0xffffff00;\n\n      } = 0x00050002;\n\nversion LOC_APICBVERS_0003 {\n\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050003\nRPC_LOC_IOCTL_SET_DATA_ENABLE\nRPC_LOC_IOCTL_SET_LBS_APN_PROFILE\nRPC_LOC_IOCTL_GET_XTRA_APN_PROFILE\nRPC_LOC_IOCTL_GET_LBS_APN_PROFILE\nRPC_LOC_IOCTL_SET_XTRA_APN_PROFILE\n*/\n\n\tint\n\trpc_loc_api_cb_null( void ) = 0xffffff00;\n\n      } = 0x00050003;\n\nversion LOC_APICBVERS_0004 {\n\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050004\nRPC_LOC_IOCTL_GET_SUPL_VERSION\nRPC_LOC_IOCTL_SET_SUPL_VERSION\n*/\n\n\tint\n\trpc_loc_api_cb_null( void ) = 0xffffff00;\n\n      } = 0x00050004;\n\nversion LOC_APICBVERS_0005 {\n\n/* Following elements added in enum rpc_loc_server_addr_e_type in 0x00050005\nRPC_LOC_SERVER_ADDR_IPV6\n*/\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050005\nRPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG\n*/\n\n\tint\n\trpc_loc_api_cb_null( void ) = 0xffffff00;\n\n      } = 0x00050005;\n\n\n\n    version LOC_APICBVERS_0006 {\n\n/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050006\nRPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS\n*/\n/* Following elements added in enum rpc_loc_server_request_e_type in 0x00050006\nRPC_LOC_SERVER_REQUEST_MULTI_OPEN\n*/\n\n\tint\n\trpc_loc_api_cb_null( void ) = 0xffffff00;\n\n      } = 0x00050006;\n\n\n} = 0x3100008C;\n\nconst LOC_APICBVERS = 0x00050006;\n"
  },
  {
    "path": "gps/loc_api/libloc_api-rpc-50001/libloc_api-rpc-stub/xdr/loc_api_common.xdr",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n/* LOC_API TOOL VERSION: 4.48 */\n/* GENERATED: TUE JUN 14 2011 */\n/*=============================================================================\n                      L O C _ A P I _ C O M M O N . X D R\n\nGENERAL DESCRIPTION\n  This is an AUTO GENERATED file that provides an xdr compatible definition of\n  an api that represents the grouping of the different callback functions the\n  loc_api API supports.\n\n  ---------------------------------------------------------------------------\n\n\n  ---------------------------------------------------------------------------\n=============================================================================*/\n\n/*=============================================================================\n\n                              Edit History\n\n                             AUTO GENERATED\n\nGenerated by following versions of Htorpc modules:\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/htorpc.pl#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Start.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Htoxdr.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/XDR.pm#3\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Output.pm#5\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Parser.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Metacomments.pm#1\nId: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/SymbolTable.pm#1\n\nloc_api Definition File(s):\nId: //source/qcom/qct/modem/api/gps/main/latest/loc_api.h#24\n=============================================================================*/\n/*=============================================================================\n$Header$\n=============================================================================*/\n\n\n\nconst LOC_API_TOOLVERS = 0x00040030;\nconst LOC_API_FEATURES = 0x00000001;\n\nconst RPC_LOC_EVENT_STATUS_REPORT = 0x00000100;\n\nconst RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST = 0x00000020;\n\nconst RPC_LOC_EVENT_WPS_NEEDED_REQUEST = 0x00000200;\n\nconst RPC_LOC_EVENT_SATELLITE_REPORT = 0x00000002;\n\nconst RPC_LOC_EVENT_PARSED_POSITION_REPORT = 0x00000001;\n\nconst RPC_LOC_EVENT_RESERVED = 0x8000000000000000;\n\nconst RPC_LOC_EVENT_LOCATION_SERVER_REQUEST = 0x00000040;\n\nconst RPC_LOC_EVENT_NMEA_POSITION_REPORT = 0x00000008;\n\nconst RPC_LOC_EVENT_IOCTL_REPORT = 0x00000080;\n\nconst RPC_LOC_EVENT_NMEA_1HZ_REPORT = 0x00000004;\n\nconst RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST = 0x00000010;\n\nconst RPC_LOC_API_CB_NULL_VERSION = 0x00050002;\nconst RPC_LOC_EVENT_CB_F_TYPE_VERSION = 0x00050001;\nconst RPC_LOC_API_API_VERSIONS_VERSION = 0x00050001;\nconst RPC_LOC_STOP_FIX_VERSION = 0x00050001;\nconst RPC_LOC_START_FIX_VERSION = 0x00050001;\nconst RPC_LOC_IOCTL_VERSION = 0x00050001;\nconst RPC_LOC_CLOSE_VERSION = 0x00050001;\nconst RPC_LOC_API_RPC_GLUE_CODE_INFO_REMOTE_VERSION = 0x00050001;\nconst RPC_LOC_OPEN_VERSION = 0x00050001;\nconst RPC_LOC_API_NULL_VERSION = 0x00050001;\nconst RPC_LOC_API_API_MAJOR_NUM = 0x0005;\nconst RPC_LOC_APIAPI_VERSION_IS_HASHKEY = 0;\n\ntypedef rpc_int32 rpc_loc_client_handle_type;\n\ntypedef rpc_uint64 rpc_loc_event_mask_type;\n\ntypedef rpc_uint64 rpc_loc_position_valid_mask_type;\n\ntypedef rpc_uint32 rpc_loc_pos_technology_mask_type;\n\nenum rpc_loc_session_status_e_type {\n  RPC_LOC_SESS_STATUS_SUCCESS = 0,\n  RPC_LOC_SESS_STATUS_IN_PROGESS = 1,\n  RPC_LOC_SESS_STATUS_GENERAL_FAILURE = 2,\n  RPC_LOC_SESS_STATUS_TIMEOUT = 3,\n  RPC_LOC_SESS_STATUS_USER_END = 4,\n  RPC_LOC_SESS_STATUS_BAD_PARAMETER = 5,\n  RPC_LOC_SESS_STATUS_PHONE_OFFLINE = 6,\n  RPC_LOC_SESS_STATUS_ENGINE_LOCKED = 7,\n  RPC_LOC_SESS_STATUS_MAX = 268435456\n};\n\nstruct rpc_loc_calendar_time_s_type {\n  rpc_uint16 year;\n  unsigned char month;\n  unsigned char day_of_week;\n  unsigned char day;\n  unsigned char hour;\n  unsigned char minute;\n  unsigned char second;\n  rpc_uint16 millisecond;\n};\n\nstruct rpc_loc_parsed_position_s_type {\n  rpc_loc_position_valid_mask_type valid_mask;\n  rpc_loc_session_status_e_type session_status;\n  rpc_loc_calendar_time_s_type timestamp_calendar;\n  rpc_uint64 timestamp_utc;\n  rpc_uint8 leap_seconds;\n  float time_unc;\n  double latitude;\n  double longitude;\n  float altitude_wrt_ellipsoid;\n  float altitude_wrt_mean_sea_level;\n  float speed_horizontal;\n  float speed_vertical;\n  float heading;\n  float hor_unc_circular;\n  float hor_unc_ellipse_semi_major;\n  float hor_unc_ellipse_semi_minor;\n  float hor_unc_ellipse_orient_azimuth;\n  float vert_unc;\n  float speed_unc;\n  float heading_unc;\n  unsigned char confidence_horizontal;\n  unsigned char confidence_vertical;\n  float magnetic_deviation;\n  rpc_loc_pos_technology_mask_type technology_mask;\n};\n\nenum rpc_loc_sv_system_e_type {\n  RPC_LOC_SV_SYSTEM_GPS = 1,\n  RPC_LOC_SV_SYSTEM_GALILEO = 2,\n  RPC_LOC_SV_SYSTEM_SBAS = 3,\n  RPC_LOC_SV_SYSTEM_COMPASS = 4,\n  RPC_LOC_SV_SYSTEM_GLONASS = 5,\n  RPC_LOC_SV_SYSTEM_MAX = 268435456\n};\n\nenum rpc_loc_sv_status_e_type {\n  RPC_LOC_SV_STATUS_IDLE = 1,\n  RPC_LOC_SV_STATUS_SEARCH = 2,\n  RPC_LOC_SV_STATUS_TRACK = 3,\n  RPC_LOC_SV_STATUS_MAX = 268435456\n};\n\ntypedef rpc_uint32 rpc_loc_sv_info_valid_mask_type;\n\nstruct rpc_loc_sv_info_s_type {\n  rpc_loc_sv_info_valid_mask_type valid_mask;\n  rpc_loc_sv_system_e_type system;\n  rpc_uint8 prn;\n  rpc_uint8 health_status;\n  rpc_loc_sv_status_e_type process_status;\n  rpc_boolean has_eph;\n  rpc_boolean has_alm;\n  float elevation;\n  float azimuth;\n  float snr;\n};\n\ntypedef rpc_uint32 rpc_loc_gnss_info_valid_mask_type;\n\nstruct rpc_loc_gnss_info_s_type {\n  rpc_loc_gnss_info_valid_mask_type valid_mask;\n  float position_dop;\n  float horizontal_dop;\n  float vertical_dop;\n  rpc_boolean altitude_assumed;\n  rpc_uint16 sv_count;\n    rpc_loc_sv_info_s_type sv_list<80>; /* EVAL:[LOC_API_MAX_SV_COUNT]*/\n};\n\nstruct rpc_loc_nmea_report_s_type {\n  rpc_uint16 length;\n  opaque nmea_sentences[200];\n};\n\nenum rpc_loc_status_event_e_type {\n  RPC_LOC_STATUS_EVENT_ENGINE_STATE = 1,\n  RPC_LOC_STATUS_EVENT_FIX_SESSION_STATE = 2,\n  RPC_LOC_STATUS_EVENT_MAX = 268435456\n};\n\nenum rpc_loc_engine_state_e_type {\n  RPC_LOC_ENGINE_STATE_ON = 1,\n  RPC_LOC_ENGINE_STATE_OFF = 2,\n  RPC_LOC_ENGINE_STATE_MAX = 268435456\n};\n\nenum rpc_loc_fix_session_state_e_type {\n  RPC_LOC_FIX_SESSION_STATE_BEGIN = 1,\n  RPC_LOC_FIX_SESSION_STATE_END = 2,\n  RPC_LOC_FIX_SESSION_STATE_MAX = 268435456\n};\n\nunion rpc_loc_status_event_payload_u_type switch (rpc_loc_status_event_e_type disc) {\n  case RPC_LOC_STATUS_EVENT_ENGINE_STATE:\n    rpc_loc_engine_state_e_type engine_state;\n  case RPC_LOC_STATUS_EVENT_FIX_SESSION_STATE:\n    rpc_loc_fix_session_state_e_type fix_session_state;\n  default:\n    void;\n};\n\nstruct rpc_loc_status_event_s_type {\n  rpc_loc_status_event_e_type event;\n  rpc_loc_status_event_payload_u_type payload;\n};\n\nenum rpc_loc_server_addr_e_type {\n  RPC_LOC_SERVER_ADDR_IPV4 = 1,\n  RPC_LOC_SERVER_ADDR_URL = 2,\n  RPC_LOC_SERVER_ADDR_IPV6 = 3,\n  RPC_LOC_SERVER_ADDR_MAX = 268435456\n};\n\nstruct rpc_loc_server_addr_ipv4_type {\n  rpc_uint32 addr;\n  rpc_uint16 port;\n};\n\nstruct rpc_loc_server_addr_url_type {\n  rpc_uint16 length;\n  opaque addr[256];\n};\n\nstruct rpc_loc_server_addr_ipv6_type {\n  rpc_uint16 addr[8];\n  rpc_uint32 port;\n};\n\nunion rpc_loc_server_addr_u_type switch (rpc_loc_server_addr_e_type disc) {\n  case RPC_LOC_SERVER_ADDR_IPV4:\n    rpc_loc_server_addr_ipv4_type ipv4;\n  case RPC_LOC_SERVER_ADDR_URL:\n    rpc_loc_server_addr_url_type url;\n  case RPC_LOC_SERVER_ADDR_IPV6:\n    rpc_loc_server_addr_ipv6_type ipv6;\n  default:\n    void;\n};\n\nstruct rpc_loc_server_info_s_type {\n  rpc_loc_server_addr_e_type addr_type;\n  rpc_loc_server_addr_u_type addr_info;\n};\n\nenum rpc_loc_ni_notify_verify_e_type {\n  RPC_LOC_NI_USER_NO_NOTIFY_NO_VERIFY = 1,\n  RPC_LOC_NI_USER_NOTIFY_ONLY = 2,\n  RPC_LOC_NI_USER_NOTIFY_VERIFY_ALLOW_NO_RESP = 3,\n  RPC_LOC_NI_USER_NOTIFY_VERIFY_NOT_ALLOW_NO_RESP = 4,\n  RPC_LOC_NI_USER_PRIVACY_OVERRIDE = 5,\n  RPC_LOC_NI_USER_NOTIFY_VERITY_TYPE_MAX = 268435456\n};\n\nenum rpc_loc_ni_event_e_type {\n  RPC_LOC_NI_EVENT_VX_NOTIFY_VERIFY_REQ = 1,\n  RPC_LOC_NI_EVENT_SUPL_NOTIFY_VERIFY_REQ = 2,\n  RPC_LOC_NI_EVENT_UMTS_CP_NOTIFY_VERIFY_REQ = 3,\n  RPC_LOC_NI_EVENT_VX_SERVICE_INTERACTION_REQ = 4,\n  RPC_LOC_NI_EVENT_MAX = 268435456\n};\n\nenum rpc_loc_ni_datacoding_scheme_e_type {\n  RPC_LOC_NI_PRESUPL_ISO646IRV = 0,\n  RPC_LOC_NI_PRESUPL_ISO8859 = 1,\n  RPC_LOC_NI_PRESUPL_UTF8 = 2,\n  RPC_LOC_NI_PRESUPL_UTF16 = 3,\n  RPC_LOC_NI_PRESUPL_UCS2 = 4,\n  RPC_LOC_NI_PRESUPL_GSM_DEFAULT = 5,\n  RPC_LOC_NI_PRESUPL_SHIFT_JIS = 6,\n  RPC_LOC_NI_PRESUPL_JIS = 7,\n  RPC_LOC_NI_PRESUPL_EUC = 8,\n  RPC_LOC_NI_PRESUPL_GB2312 = 9,\n  RPC_LOC_NI_PRESUPL_CNS11643 = 10,\n  RPC_LOC_NI_PRESUPL_KSC1001 = 11,\n  RPC_LOC_NI_PRESUPL_ENCODING_UNKNOWN = 2147483647,\n  RPC_LOC_NI_SS_GERMAN = 12,\n  RPC_LOC_NI_SS_ENGLISH = 13,\n  RPC_LOC_NI_SS_ITALIAN = 14,\n  RPC_LOC_NI_SS_FRENCH = 15,\n  RPC_LOC_NI_SS_SPANISH = 16,\n  RPC_LOC_NI_SS_DUTCH = 17,\n  RPC_LOC_NI_SS_SWEDISH = 18,\n  RPC_LOC_NI_SS_DANISH = 19,\n  RPC_LOC_NI_SS_PORTUGUESE = 20,\n  RPC_LOC_NI_SS_FINNISH = 21,\n  RPC_LOC_NI_SS_NORWEGIAN = 22,\n  RPC_LOC_NI_SS_GREEK = 23,\n  RPC_LOC_NI_SS_TURKISH = 24,\n  RPC_LOC_NI_SS_HUNGARIAN = 25,\n  RPC_LOC_NI_SS_POLISH = 26,\n  RPC_LOC_NI_SS_LANGUAGE_UNSPEC = 27,\n  RPC_LOC_NI_SUPL_UTF8 = 28,\n  RPC_LOC_NI_SUPL_UCS2 = 29,\n  RPC_LOC_NI_SUPL_GSM_DEFAULT = 30,\n  RPC_LOC_NI_SUPL_ENCODING_UNKNOWN = 2147483647\n};\n\nenum rpc_loc_ni_vx_requester_id_encoding_scheme_e_type {\n  RPC_LOC_NI_VX_OCTET = 0,\n  RPC_LOC_NI_VX_EXN_PROTOCOL_MSG = 1,\n  RPC_LOC_NI_VX_ASCII = 2,\n  RPC_LOC_NI_VX_IA5 = 3,\n  RPC_LOC_NI_VX_UNICODE = 4,\n  RPC_LOC_NI_VX_SHIFT_JIS = 5,\n  RPC_LOC_NI_VX_KOREAN = 6,\n  RPC_LOC_NI_VX_LATIN_HEBREW = 7,\n  RPC_LOC_NI_VX_LATIN = 8,\n  RPC_LOC_NI_VX_GSM = 9,\n  RPC_LOC_NI_VX_ENCODING_TYPE_MAX = 268435456\n};\n\nenum rpc_loc_ni_vx_pos_mode_e_type {\n  RPC_LOC_VX_MS_ASSISTED_ONLY = 1,\n  RPC_LOC_VX_MS_BASED_ONLY = 2,\n  RPC_LOC_VX_MS_ASSISTED_PREF_MSBASED_ALLWD = 3,\n  RPC_LOC_VX_MS_BASED_PREF_ASSISTED_ALLWD = 4,\n  RPC_LOC_VX_POS_MODE_MAX = 268435456\n};\n\nstruct rpc_loc_ni_vx_requester_id_s_type {\n  unsigned char requester_id_length;\n  opaque requester_id[200];\n};\n\nstruct rpc_loc_ni_vx_notify_verify_req_s_type {\n  rpc_loc_ni_notify_verify_e_type notification_priv_type;\n  unsigned char pos_qos_incl;\n  unsigned char pos_qos;\n  rpc_uint32 num_fixes;\n  rpc_uint32 tbf;\n  rpc_loc_ni_vx_pos_mode_e_type pos_mode;\n  rpc_loc_ni_vx_requester_id_encoding_scheme_e_type encoding_scheme;\n  rpc_loc_ni_vx_requester_id_s_type requester_id;\n  rpc_uint16 user_resp_timer_val;\n};\n\nenum rpc_loc_ni_supl_pos_method_e_type {\n  RPC_LOC_NI_POSMETHOD_AGPS_SETASSISTED = 1,\n  RPC_LOC_NI_POSMETHOD_AGPS_SETBASED = 2,\n  RPC_LOC_NI_POSMETHOD_AGPS_SETASSISTED_PREF = 3,\n  RPC_LOC_NI_POSMETHOD_AGPS_SETBASED_PREF = 4,\n  RPC_LOC_NI_POSMETHOD_AUTONOMOUS_GPS = 5,\n  RPC_LOC_NI_POSMETHOD_AFLT = 6,\n  RPC_LOC_NI_POSMETHOD_ECID = 7,\n  RPC_LOC_NI_POSMETHOD_EOTD = 8,\n  RPC_LOC_NI_POSMETHOD_OTDOA = 9,\n  RPC_LOC_NI_POSMETHOD_NO_POSITION = 10,\n  RPC_LOC_NI_POSMETHOD_MAX = 268435456\n};\n\nstruct rpc_loc_ni_supl_slp_session_id_s_type {\n  unsigned char presence;\n  opaque session_id[4];\n  rpc_loc_server_info_s_type slp_address;\n};\n\nstruct rpc_loc_ni_requestor_id_s_type {\n  unsigned char data_coding_scheme;\n  opaque requestor_id_string[200];\n  unsigned char string_len;\n};\n\nstruct rpc_loc_ni_supl_client_name_s_type {\n  unsigned char data_coding_scheme;\n  opaque client_name_string[64];\n  unsigned char string_len;\n};\n\nstruct rpc_loc_ni_supl_qop_s_type {\n  unsigned char bit_mask;\n  unsigned char horacc;\n  unsigned char veracc;\n  rpc_uint16 maxLocAge;\n  unsigned char delay;\n};\n\nstruct rpc_loc_ni_supl_notify_verify_req_s_type {\n  rpc_loc_ni_notify_verify_e_type notification_priv_type;\n  rpc_uint16 flags;\n  rpc_loc_ni_supl_slp_session_id_s_type supl_slp_session_id;\n  opaque supl_hash[8];\n  rpc_loc_ni_datacoding_scheme_e_type datacoding_scheme;\n  rpc_loc_ni_supl_pos_method_e_type pos_method;\n  rpc_loc_ni_requestor_id_s_type requestor_id;\n  rpc_loc_ni_supl_client_name_s_type client_name;\n  rpc_loc_ni_supl_qop_s_type supl_qop;\n  rpc_uint16 user_response_timer;\n};\n\nstruct rpc_loc_ni_ext_client_address_s_type {\n  unsigned char ext_client_address_len;\n  opaque ext_client_address[20];\n};\n\nenum rpc_loc_ni_location_type_e_type {\n  RPC_LOC_NI_LOCATIONTYPE_CURRENT_LOCATION = 1,\n  RPC_LOC_NI_LOCATIONTYPE_CURRENT_OR_LAST_KNOWN_LOCATION = 2,\n  RPC_LOC_NI_LOCATIONTYPE_INITIAL_LOCATION = 3,\n  RPC_LOC_NI_LOCATIONTYPE_MAX = 268435456\n};\n\nstruct rpc_loc_ni_deferred_location_s_type {\n  unsigned char unused_bits;\n  unsigned char ms_available;\n};\n\nstruct rpc_loc_ni_codeword_string_s_type {\n  unsigned char data_coding_scheme;\n  opaque lcs_codeword_string[20];\n  unsigned char string_len;\n};\n\nstruct rpc_loc_ni_service_type_id_s_type {\n  unsigned char lcs_service_type_id;\n};\n\nstruct rpc_loc_ni_umts_cp_notify_verify_req_s_type {\n  rpc_loc_ni_notify_verify_e_type notification_priv_type;\n  unsigned char invoke_id;\n  rpc_uint16 flags;\n  unsigned char notification_length;\n  opaque notification_text[64];\n  rpc_loc_ni_datacoding_scheme_e_type datacoding_scheme;\n  rpc_loc_ni_ext_client_address_s_type ext_client_address_data;\n  rpc_loc_ni_location_type_e_type location_type;\n  rpc_loc_ni_deferred_location_s_type deferred_location;\n  rpc_loc_ni_requestor_id_s_type requestor_id;\n  rpc_loc_ni_codeword_string_s_type codeword_string;\n  rpc_loc_ni_service_type_id_s_type service_type_id;\n  rpc_uint16 user_response_timer;\n};\n\nenum rpc_loc_ni_service_interaction_e_type {\n  RPC_LOC_NI_SERVICE_INTERACTION_ONGOING_NI_INCOMING_MO = 1,\n  RPC_LOC_NI_SERVICE_INTERACTION_MAX = 268435456\n};\n\nstruct rpc_loc_ni_vx_service_interaction_req_s_type {\n  rpc_loc_ni_vx_notify_verify_req_s_type ni_vx_req;\n  rpc_loc_ni_service_interaction_e_type service_interation_type;\n};\n\nunion rpc_loc_ni_event_payload_u_type switch (rpc_loc_ni_event_e_type disc) {\n  case RPC_LOC_NI_EVENT_VX_NOTIFY_VERIFY_REQ:\n    rpc_loc_ni_vx_notify_verify_req_s_type vx_req;\n  case RPC_LOC_NI_EVENT_SUPL_NOTIFY_VERIFY_REQ:\n    rpc_loc_ni_supl_notify_verify_req_s_type supl_req;\n  case RPC_LOC_NI_EVENT_UMTS_CP_NOTIFY_VERIFY_REQ:\n    rpc_loc_ni_umts_cp_notify_verify_req_s_type umts_cp_req;\n  case RPC_LOC_NI_EVENT_VX_SERVICE_INTERACTION_REQ:\n    rpc_loc_ni_vx_service_interaction_req_s_type service_interaction_req;\n  default:\n    void;\n};\n\nstruct rpc_loc_ni_event_s_type {\n  rpc_loc_ni_event_e_type event;\n  rpc_loc_ni_event_payload_u_type payload;\n};\n\nenum rpc_loc_assist_data_request_e_type {\n  RPC_LOC_ASSIST_DATA_TIME_REQ = 1,\n  RPC_LOC_ASSIST_DATA_PREDICTED_ORBITS_REQ = 2,\n  RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ = 3,\n  RPC_LOC_ASSIST_DATA_MAX = 268435456\n};\n\ntypedef string rpc_struct_loc_time_download_source_s_type_servers_ptr<256>; /* EVAL:[LOC_API_MAX_SERVER_ADDR_LENGTH]*/\n\ntypedef rpc_struct_loc_time_download_source_s_type_servers_ptr rpc_struct_loc_time_download_source_s_type_servers[3];\n\nstruct rpc_loc_time_download_source_s_type {\n  rpc_uint32 delay_threshold;\n  rpc_struct_loc_time_download_source_s_type_servers servers;\n};\n\ntypedef string rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr<LOC_API_MAX_SERVER_ADDR_LENGTH>;\n\ntypedef rpc_struct_loc_predicted_orbits_data_source_s_type_servers_ptr rpc_struct_loc_predicted_orbits_data_source_s_type_servers[3];\n\nstruct rpc_loc_predicted_orbits_data_source_s_type {\n  rpc_uint32 max_file_size;\n  rpc_uint32 max_part_size;\n  rpc_struct_loc_predicted_orbits_data_source_s_type_servers servers;\n};\n\nstruct rpc_loc_pos_inj_request_s_type {\n  rpc_uint32 flags;\n  double latitude;\n  double longitude;\n  rpc_uint32 position_uncertainty;\n  rpc_uint64 timestamp;\n};\n\nunion rpc_loc_assist_data_request_payload_u_type switch (rpc_loc_assist_data_request_e_type disc) {\n  case RPC_LOC_ASSIST_DATA_TIME_REQ:\n    rpc_loc_time_download_source_s_type time_download;\n  case RPC_LOC_ASSIST_DATA_PREDICTED_ORBITS_REQ:\n    rpc_loc_predicted_orbits_data_source_s_type data_download;\n  case RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ:\n    rpc_loc_pos_inj_request_s_type pos_injection;\n  default:\n    void;\n};\n\nstruct rpc_loc_assist_data_request_s_type {\n  rpc_loc_assist_data_request_e_type event;\n  rpc_loc_assist_data_request_payload_u_type payload;\n};\n\ntypedef rpc_uint32 rpc_loc_server_connection_handle;\n\nenum rpc_loc_server_protocol_e_type {\n  RPC_LOC_SERVER_PROTOCOL_DEFAULT = 0,\n  RPC_LOC_SERVER_PROTOCOL_SUPL = 1,\n  RPC_LOC_SERVER_PROTOCOL_VX_MPC = 2,\n  RPC_LOC_SERVER_PROTOCOL_VX_PDE = 3,\n  RPC_LOC_SERVER_PROTOCOL_MAX = 16777216\n};\n\nenum rpc_loc_server_connection_e_type {\n  RPC_LOC_SERVER_CONNECTION_LBS = 0,\n  RPC_LOC_SERVER_CONNECTION_WWAN_INTERNET,\n  RPC_LOC_SERVER_CONNECTION_MAX = 16777216\n};\n\nenum rpc_loc_server_request_e_type {\n  RPC_LOC_SERVER_REQUEST_OPEN = 1,\n  RPC_LOC_SERVER_REQUEST_CLOSE = 2,\n  RPC_LOC_SERVER_REQUEST_MULTI_OPEN = 3,\n  RPC_LOC_SERVER_REQUEST_MAX = 268435456\n};\n\nstruct rpc_loc_server_open_req_s_type {\n  rpc_loc_server_connection_handle conn_handle;\n  rpc_loc_server_protocol_e_type protocol;\n};\n\nstruct rpc_loc_server_multi_open_req_s_type {\n  rpc_loc_server_connection_handle conn_handle;\n  rpc_loc_server_protocol_e_type protocol;\n  rpc_loc_server_connection_e_type connection_type;\n};\n\nstruct rpc_loc_server_close_req_s_type {\n  rpc_loc_server_connection_handle conn_handle;\n};\n\nunion rpc_loc_server_request_u_type switch (rpc_loc_server_request_e_type disc) {\n  case RPC_LOC_SERVER_REQUEST_OPEN:\n    rpc_loc_server_open_req_s_type open_req;\n  case RPC_LOC_SERVER_REQUEST_CLOSE:\n    rpc_loc_server_close_req_s_type close_req;\n  case RPC_LOC_SERVER_REQUEST_MULTI_OPEN:\n    rpc_loc_server_multi_open_req_s_type multi_open_req;\n  default:\n    void;\n};\n\nstruct rpc_loc_server_request_s_type {\n  rpc_loc_server_request_e_type event;\n  rpc_loc_server_request_u_type payload;\n};\n\nenum rpc_loc_qwip_request_e_type {\n  RPC_LOC_QWIP_START_PERIODIC_HI_FREQ_FIXES = 0,\n  RPC_LOC_QWIP_START_PERIODIC_KEEP_WARM,\n  RPC_LOC_QWIP_STOP_PERIODIC_FIXES,\n  RPC_LOC_QWIP_SUSPEND,\n  RPC_LOC_QWIP_REQUEST_MAX = 268435456\n};\n\nstruct rpc_loc_qwip_request_s_type {\n  rpc_loc_qwip_request_e_type request_type;\n  rpc_uint16 tbf_ms;\n};\n\nstruct rpc_loc_reserved_payload_s_type {\n  rpc_uint16 data_size;\n  opaque data<>;\n};\n\nenum rpc_loc_ioctl_e_type {\n  RPC_LOC_IOCTL_GET_API_VERSION = 1,\n  RPC_LOC_IOCTL_SET_FIX_CRITERIA = 2,\n  RPC_LOC_IOCTL_GET_FIX_CRITERIA = 3,\n  RPC_LOC_IOCTL_SERVICE_START_INDEX = 400,\n  RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE = 400,\n  RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA = 401,\n  RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY = 402,\n  RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE = 403,\n  RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD = 404,\n  RPC_LOC_IOCTL_INJECT_UTC_TIME = 405,\n  RPC_LOC_IOCTL_INJECT_RTC_VALUE = 406,\n  RPC_LOC_IOCTL_INJECT_POSITION = 407,\n  RPC_LOC_IOCTL_QUERY_ENGINE_STATE = 408,\n  RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS = 409,\n  RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS = 410,\n  RPC_LOC_IOCTL_SEND_WIPER_POSITION_REPORT = 411,\n  RPC_LOC_IOCTL_NOTIFY_WIPER_STATUS = 412,\n  RPC_LOC_IOCTL_ACCESS_EFS_DATA = 413,\n  RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG = 414,\n  RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS = 415,\n  RPC_LOC_IOCTL_NV_SETTINGS_START_INDEX = 800,\n  RPC_LOC_IOCTL_SET_ENGINE_LOCK = 800,\n  RPC_LOC_IOCTL_GET_ENGINE_LOCK = 801,\n  RPC_LOC_IOCTL_SET_SBAS_CONFIG = 802,\n  RPC_LOC_IOCTL_GET_SBAS_CONFIG = 803,\n  RPC_LOC_IOCTL_SET_NMEA_TYPES = 804,\n  RPC_LOC_IOCTL_GET_NMEA_TYPES = 805,\n  RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR = 806,\n  RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR = 807,\n  RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR = 808,\n  RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR = 809,\n  RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR = 810,\n  RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR = 811,\n  RPC_LOC_IOCTL_SET_ON_DEMAND_LPM = 812,\n  RPC_LOC_IOCTL_GET_ON_DEMAND_LPM = 813,\n  RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL = 814,\n  RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL = 815,\n  RPC_LOC_IOCTL_SET_LBS_APN_PROFILE = 816,\n  RPC_LOC_IOCTL_GET_LBS_APN_PROFILE = 817,\n  RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE = 818,\n  RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE = 819,\n  RPC_LOC_IOCTL_SET_DATA_ENABLE = 820,\n  RPC_LOC_IOCTL_SET_SUPL_VERSION = 821,\n  RPC_LOC_IOCTL_GET_SUPL_VERSION = 822,\n  RPC_LOC_IOCTL_PROPRIETARY_START_INDEX = 1000,\n  RPC_LOC_IOCTL_DELETE_ASSIST_DATA = 1000,\n  RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR = 1001,\n  RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR = 1002,\n  RPC_LOC_IOCTL_RESERVED_CMD = 8000,\n  RPC_LOC_IOCTL_THIRD_PARTY_START_INDEX = 1073741824\n};\n\nstruct rpc_loc_api_version_s_type {\n  unsigned char major;\n  unsigned char minor;\n};\n\nenum rpc_loc_fix_recurrence_e_type {\n  RPC_LOC_PERIODIC_FIX = 1,\n  RPC_LOC_SINGLE_FIX = 2,\n  RPC_LOC_FIX_SESSION_TYPE_MAX = 268435456\n};\n\nenum rpc_loc_operation_mode_e_type {\n  RPC_LOC_OPER_MODE_DEFAULT = 1,\n  RPC_LOC_OPER_MODE_MSB = 2,\n  RPC_LOC_OPER_MODE_MSA = 3,\n  RPC_LOC_OPER_MODE_STANDALONE = 4,\n  RPC_LOC_OPER_MODE_SPEED_OPTIMAL = 5,\n  RPC_LOC_OPER_MODE_ACCURACY_OPTIMAL = 6,\n  RPC_LOC_OPER_MODE_DATA_OPTIMAL = 7,\n  RPC_LOC_OPER_MODE_CELL_ID = 8,\n  RPC_LOC_OPER_MODE_MAX = 268435456\n};\n\nenum rpc_loc_notify_e_type {\n  RPC_LOC_NOTIFY_ON_INTERVAL = 1,\n  RPC_LOC_NOTIFY_ON_DISTANCE = 2,\n  RPC_LOC_NOTIFY_ON_ANY = 3,\n  RPC_LOC_NOTIFY_ON_ALL = 4,\n  RPC_LOC_NOTIFY_TYPE_MAX = 268435456\n};\n\nstruct rpc_loc_fix_criteria_s_type {\n  rpc_uint32 valid_mask;\n  rpc_loc_fix_recurrence_e_type recurrence_type;\n  rpc_loc_operation_mode_e_type preferred_operation_mode;\n  rpc_uint32 preferred_accuracy;\n  rpc_uint32 preferred_response_time;\n  rpc_boolean intermediate_pos_report_enabled;\n  rpc_loc_notify_e_type notify_type;\n  rpc_uint32 min_interval;\n  float min_distance;\n  rpc_uint32 min_dist_sample_interval;\n};\n\nenum rpc_loc_ni_user_resp_e_type {\n  RPC_LOC_NI_LCS_NOTIFY_VERIFY_ACCEPT = 1,\n  RPC_LOC_NI_LCS_NOTIFY_VERIFY_DENY = 2,\n  RPC_LOC_NI_LCS_NOTIFY_VERIFY_NORESP = 3,\n  RPC_LOC_NI_LCS_NOTIFY_VERIFY_MAX = 268435456\n};\n\nstruct rpc_loc_user_verify_s_type {\n  rpc_loc_ni_user_resp_e_type user_resp;\n  rpc_loc_ni_event_s_type ni_event_pass_back;\n};\n\nenum rpc_loc_predicted_orbits_data_format_e_type {\n  RPC_LOC_PREDICTED_ORBITS_XTRA = 0,\n  RPC_LOC_PREDICTED_ORBITS_FORMAT_MAX = 268435456\n};\n\nstruct rpc_loc_predicted_orbits_data_s_type {\n  rpc_loc_predicted_orbits_data_format_e_type format_type;\n  rpc_uint32 total_size;\n  rpc_uint8 total_parts;\n  rpc_uint8 part;\n  rpc_uint16 part_len;\n  opaque data_ptr<>;\n};\n\nstruct rpc_loc_predicted_orbits_data_validity_report_s_type {\n  rpc_uint64 start_time_utc;\n  rpc_uint16 valid_duration_hrs;\n};\n\nstruct rpc_loc_predicted_orbits_auto_download_config_s_type {\n  rpc_boolean enable;\n  unsigned char auto_check_every_hrs;\n};\n\nstruct rpc_loc_assist_data_time_s_type {\n  rpc_uint64 time_utc;\n  rpc_uint32 uncertainty;\n};\n\ntypedef rpc_uint64 rpc_loc_assist_pos_valid_mask_type;\n\nstruct rpc_loc_assist_data_pos_s_type {\n  rpc_loc_assist_pos_valid_mask_type valid_mask;\n  rpc_uint64 timestamp_utc;\n  double latitude;\n  double longitude;\n  float altitude_wrt_ellipsoid;\n  float altitude_wrt_mean_sea_level;\n  float hor_unc_circular;\n  float vert_unc;\n  unsigned char confidence_horizontal;\n  unsigned char confidence_vertical;\n  rpc_int32 timestamp_age;\n};\n\nenum rpc_loc_server_open_status_e_type {\n  RPC_LOC_SERVER_OPEN_SUCCESS = 1,\n  RPC_LOC_SERVER_OPEN_FAIL = 2,\n  RPC_LOC_SERVER_OPEN_STATUS_MAX = 268435456\n};\n\nenum rpc_loc_server_pdp_type_e_type {\n  RPC_LOC_SERVER_PDP_IP = 0,\n  RPC_LOC_SERVER_PDP_PPP,\n  RPC_LOC_SERVER_PDP_IPV6,\n  RPC_LOC_SERVER_PDP_IPV4V6,\n  RPC_LOC_SERVER_PDP_MAX = 268435456\n};\n\nstruct rpc_loc_server_open_status_s_type {\n  rpc_loc_server_connection_handle conn_handle;\n  rpc_loc_server_open_status_e_type open_status;\n  opaque apn_name[100];\n};\n\nstruct rpc_loc_server_multi_open_status_s_type {\n  rpc_loc_server_connection_handle conn_handle;\n  rpc_loc_server_open_status_e_type open_status;\n  rpc_loc_server_pdp_type_e_type pdp_type;\n  opaque apn_name[100];\n};\n\nenum rpc_loc_server_close_status_e_type {\n  RPC_LOC_SERVER_CLOSE_SUCCESS = 1,\n  RPC_LOC_SERVER_CLOSE_FAIL = 2,\n  RPC_LOC_SERVER_CLOSE_STATUS_MAX = 268435456\n};\n\nstruct rpc_loc_server_close_status_s_type {\n  rpc_loc_server_connection_handle conn_handle;\n  rpc_loc_server_close_status_e_type close_status;\n};\n\nstruct rpc_loc_wiper_fix_time_s_type {\n  rpc_uint32 slow_clock_count;\n};\n\nstruct rpc_loc_wiper_fix_pos_s_type {\n  rpc_int32 lat;\n  rpc_int32 lon;\n  rpc_uint16 HEPE;\n  rpc_uint8 num_of_aps_used;\n  rpc_uint8 fix_error_code;\n};\n\nstruct rpc_loc_wiper_ap_info_s_type {\n  opaque mac_addr[6];\n  rpc_int32 rssi;\n  rpc_uint16 channel;\n  rpc_uint8 ap_qualifier;\n};\n\nstruct rpc_loc_wiper_ap_set_s_type {\n  rpc_uint8 num_of_aps;\n  rpc_loc_wiper_ap_info_s_type ap_info[50];\n};\n\nstruct rpc_loc_wiper_position_report_s_type {\n  rpc_uint8 wiper_valid_info_flag;\n  rpc_loc_wiper_fix_time_s_type wiper_fix_time;\n  rpc_loc_wiper_fix_pos_s_type wiper_fix_position;\n  rpc_loc_wiper_ap_set_s_type wiper_ap_set;\n};\n\nenum rpc_loc_wiper_status_e_type {\n  RPC_LOC_WIPER_STATUS_AVAILABLE = 1,\n  RPC_LOC_WIPER_STATUS_UNAVAILABLE = 2,\n  RPC_LOC_WIPER_STATUS_E_SIZE = 268435456\n};\n\nenum rpc_loc_fs_operation_e_type {\n  RPC_LOC_FS_CREATE_WRITE_FILE = 1,\n  RPC_LOC_FS_APPEND_FILE = 2,\n  RPC_LOC_FS_DELETE_FILE = 3,\n  RPC_LOC_FS_READ_FILE = 4,\n  RPC_LOC_FS_MAX = 268435456\n};\n\nstruct rpc_loc_efs_data_s_type {\n  opaque filename[64];\n  rpc_loc_fs_operation_e_type operation;\n  rpc_uint32 total_size;\n  opaque data_ptr<>;\n  rpc_uint32 part_len;\n  rpc_uint8 part;\n  rpc_uint8 total_parts;\n  rpc_uint32 reserved;\n};\n\nenum rpc_loc_error_estimate_config_e_type {\n  RPC_LOC_ERROR_ESTIMATE_CONFIG_SET = 1,\n  RPC_LOC_ERROR_ESTIMATE_CONFIG_CLEAR = 2,\n  RPC_LOC_ERROR_ESTIMATE_MAX = 268435456\n};\n\nstruct rpc_loc_apn_profiles_type {\n  rpc_uint32 srv_system_type;\n  rpc_uint32 pdp_type;\n  rpc_uint32 reserved;\n  opaque apn_name[100];\n};\n\nenum rpc_loc_lock_e_type {\n  RPC_LOC_LOCK_NONE = 1,\n  RPC_LOC_LOCK_MI = 2,\n  RPC_LOC_LOCK_MT = 3,\n  RPC_LOC_LOCK_ALL = 4,\n  RPC_LOC_LOCK_MAX = 268435456\n};\n\ntypedef rpc_uint32 rpc_loc_nmea_sentence_type;\n\ntypedef rpc_uint32 rpc_loc_assist_data_type;\n\nstruct rpc_loc_assist_data_delete_s_type {\n  rpc_loc_assist_data_type type;\n  rpc_uint32 reserved[8];\n};\n\nunion rpc_loc_ioctl_data_u_type switch (rpc_loc_ioctl_e_type disc) {\n  case RPC_LOC_IOCTL_SET_FIX_CRITERIA:\n    rpc_loc_fix_criteria_s_type fix_criteria;\n  case RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE:\n    rpc_loc_user_verify_s_type user_verify_resp;\n  case RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA:\n    rpc_loc_predicted_orbits_data_s_type predicted_orbits_data;\n  case RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD:\n    rpc_loc_predicted_orbits_auto_download_config_s_type predicted_orbits_auto_download;\n  case RPC_LOC_IOCTL_INJECT_UTC_TIME:\n    rpc_loc_assist_data_time_s_type assistance_data_time;\n  case RPC_LOC_IOCTL_INJECT_POSITION:\n    rpc_loc_assist_data_pos_s_type assistance_data_position;\n  case RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS:\n    rpc_loc_server_open_status_s_type conn_open_status;\n  case RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS:\n    rpc_loc_server_close_status_s_type conn_close_status;\n  case RPC_LOC_IOCTL_SEND_WIPER_POSITION_REPORT:\n    rpc_loc_wiper_position_report_s_type wiper_pos;\n  case RPC_LOC_IOCTL_NOTIFY_WIPER_STATUS:\n    rpc_loc_wiper_status_e_type wiper_status;\n  case RPC_LOC_IOCTL_SET_ENGINE_LOCK:\n    rpc_loc_lock_e_type engine_lock;\n  case RPC_LOC_IOCTL_SET_SBAS_CONFIG:\n    rpc_boolean sbas_mode;\n  case RPC_LOC_IOCTL_SET_NMEA_TYPES:\n    rpc_loc_nmea_sentence_type nmea_types;\n  case RPC_LOC_IOCTL_SET_ON_DEMAND_LPM:\n    rpc_boolean on_demand_lpm;\n  case  RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR:\n  case  RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR:\n  case  RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR:\n  case  RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR:\n    rpc_loc_server_info_s_type server_addr;\n  case RPC_LOC_IOCTL_DELETE_ASSIST_DATA:\n    rpc_loc_assist_data_delete_s_type assist_data_delete;\n  case RPC_LOC_IOCTL_ACCESS_EFS_DATA:\n    rpc_loc_efs_data_s_type efs_data;\n  case RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG:\n    rpc_loc_error_estimate_config_e_type error_estimate_config;\n  case RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL:\n    rpc_uint8 xtra_t_session_control;\n  case  RPC_LOC_IOCTL_SET_LBS_APN_PROFILE:\n  case  RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE:\n    rpc_loc_apn_profiles_type apn_profiles[6];\n  case RPC_LOC_IOCTL_SET_DATA_ENABLE:\n    rpc_boolean data_enable;\n  case RPC_LOC_IOCTL_SET_SUPL_VERSION:\n    rpc_uint32 supl_version;\n  case RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS:\n    rpc_loc_server_multi_open_status_s_type multi_conn_open_status;\n  case RPC_LOC_IOCTL_RESERVED_CMD:\n    rpc_loc_reserved_payload_s_type reserved;\n  default:\n    void;\n};\n\nunion rpc_loc_ioctl_callback_data_u_type switch (rpc_loc_ioctl_e_type disc) {\n  case RPC_LOC_IOCTL_GET_API_VERSION:\n    rpc_loc_api_version_s_type api_version;\n  case RPC_LOC_IOCTL_GET_FIX_CRITERIA:\n    rpc_loc_fix_criteria_s_type fix_criteria;\n  case RPC_LOC_IOCTL_GET_ENGINE_LOCK:\n    rpc_loc_lock_e_type engine_lock;\n  case RPC_LOC_IOCTL_GET_SBAS_CONFIG:\n    rpc_boolean sbas_mode;\n  case RPC_LOC_IOCTL_GET_NMEA_TYPES:\n    rpc_loc_nmea_sentence_type nmea_types;\n  case RPC_LOC_IOCTL_GET_ON_DEMAND_LPM:\n    rpc_boolean on_demand_lpm;\n  case  RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR:\n  case  RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR:\n  case  RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR:\n  case  RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR:\n    rpc_loc_server_info_s_type server_addr;\n  case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE:\n    rpc_loc_predicted_orbits_data_source_s_type predicted_orbits_data_source;\n  case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY:\n    rpc_loc_predicted_orbits_data_validity_report_s_type predicted_orbits_data_validity;\n  case RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL:\n    rpc_uint8 xtra_t_session_control;\n  case  RPC_LOC_IOCTL_GET_LBS_APN_PROFILE:\n  case  RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE:\n    rpc_loc_apn_profiles_type apn_profiles[6];\n  case RPC_LOC_IOCTL_GET_SUPL_VERSION:\n    rpc_uint32 supl_version;\n  default:\n    void;\n};\n\nstruct rpc_loc_ioctl_callback_s_type {\n  rpc_loc_ioctl_e_type type;\n  rpc_int32 status;\n  rpc_loc_ioctl_callback_data_u_type data;\n};\n\nunion rpc_loc_event_payload_u_type switch (unsigned hyper disc) {\n  case RPC_LOC_EVENT_PARSED_POSITION_REPORT:\n    rpc_loc_parsed_position_s_type parsed_location_report;\n  case RPC_LOC_EVENT_SATELLITE_REPORT:\n    rpc_loc_gnss_info_s_type gnss_report;\n  case RPC_LOC_EVENT_NMEA_POSITION_REPORT:\n  case RPC_LOC_EVENT_NMEA_1HZ_REPORT:\n    rpc_loc_nmea_report_s_type nmea_report;\n  case RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST:\n    rpc_loc_ni_event_s_type ni_request;\n  case RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST:\n    rpc_loc_assist_data_request_s_type assist_data_request;\n  case RPC_LOC_EVENT_LOCATION_SERVER_REQUEST:\n    rpc_loc_server_request_s_type loc_server_request;\n  case RPC_LOC_EVENT_IOCTL_REPORT:\n    rpc_loc_ioctl_callback_s_type ioctl_report;\n  case RPC_LOC_EVENT_STATUS_REPORT:\n    rpc_loc_status_event_s_type status_report;\n  case RPC_LOC_EVENT_WPS_NEEDED_REQUEST:\n    rpc_loc_qwip_request_s_type qwip_request;\n  case RPC_LOC_EVENT_RESERVED:\n    rpc_loc_reserved_payload_s_type reserved;\n  default:\n    void;\n};\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/Android.mk",
    "content": "ifneq ($(BUILD_TINY_ANDROID),true)\n#Compile this library only for builds with the latest modem image\n\nLOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE := libloc_eng\nLOCAL_MODULE_OWNER := qcom\n\nLOCAL_MODULE_TAGS := optional\n\nLOCAL_SHARED_LIBRARIES := \\\n    libutils \\\n    libcutils \\\n    libdl \\\n    liblog \\\n    libloc_core \\\n    libgps.utils\n\nLOCAL_SRC_FILES += \\\n    loc_eng.cpp \\\n    loc_eng_agps.cpp \\\n    loc_eng_xtra.cpp \\\n    loc_eng_ni.cpp \\\n    loc_eng_log.cpp \\\n    loc_eng_nmea.cpp \\\n    LocEngAdapter.cpp\n\nLOCAL_SRC_FILES += \\\n    loc_eng_dmn_conn.cpp \\\n    loc_eng_dmn_conn_handler.cpp \\\n    loc_eng_dmn_conn_thread_helper.c \\\n    loc_eng_dmn_conn_glue_msg.c \\\n    loc_eng_dmn_conn_glue_pipe.c\n\nLOCAL_CFLAGS += \\\n     -fno-short-enums \\\n     -D_ANDROID_\n\nLOCAL_C_INCLUDES:= \\\n    $(TARGET_OUT_HEADERS)/gps.utils \\\n    $(TARGET_OUT_HEADERS)/libloc_core \\\n    $(LOCAL_PATH) \\\n    $(TARGET_OUT_HEADERS)/libflp\n\nLOCAL_COPY_HEADERS_TO:= libloc_eng/\nLOCAL_COPY_HEADERS:= \\\n   LocEngAdapter.h \\\n   loc.h \\\n   loc_eng.h \\\n   loc_eng_xtra.h \\\n   loc_eng_ni.h \\\n   loc_eng_agps.h \\\n   loc_eng_msg.h \\\n   loc_eng_log.h\n\nLOCAL_PRELINK_MODULE := false\n\ninclude $(BUILD_SHARED_LIBRARY)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE := gps.$(TARGET_BOARD_PLATFORM)\nLOCAL_MODULE_OWNER := qcom\n\nLOCAL_MODULE_TAGS := optional\n\n## Libs\n\nLOCAL_SHARED_LIBRARIES := \\\n    libutils \\\n    libcutils \\\n    liblog \\\n    libloc_eng \\\n    libloc_core \\\n    libgps.utils \\\n    libdl\n\nifneq ($(filter $(TARGET_DEVICE), apq8084 msm8960), false)\nendif\n\nLOCAL_SRC_FILES += \\\n    loc.cpp \\\n    gps.c\n\nLOCAL_CFLAGS += \\\n    -fno-short-enums \\\n    -D_ANDROID_ \\\n\nifeq ($(TARGET_USES_QCOM_BSP), true)\nLOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP\nendif\n\n## Includes\nLOCAL_C_INCLUDES:= \\\n    $(TARGET_OUT_HEADERS)/gps.utils \\\n    $(TARGET_OUT_HEADERS)/libloc_core \\\n    $(TARGET_OUT_HEADERS)/libflp\n\nLOCAL_PRELINK_MODULE := false\nLOCAL_MODULE_RELATIVE_PATH := hw\n\ninclude $(BUILD_SHARED_LIBRARY)\n\nendif # not BUILD_TINY_ANDROID\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/LocEngAdapter.cpp",
    "content": "/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_EngAdapter\"\n\n#include <sys/stat.h>\n#include <errno.h>\n#include <ctype.h>\n#include <cutils/properties.h>\n#include <LocEngAdapter.h>\n#include \"loc_eng_msg.h\"\n#include \"loc_log.h\"\n\n#define CHIPSET_SERIAL_NUMBER_MAX_LEN 16\n#define USER_AGENT_MAX_LEN 512\n\nusing namespace loc_core;\n\nLocInternalAdapter::LocInternalAdapter(LocEngAdapter* adapter) :\n    LocAdapterBase(adapter->getMsgTask()),\n    mLocEngAdapter(adapter)\n{\n}\nvoid LocInternalAdapter::setPositionModeInt(LocPosMode& posMode) {\n    sendMsg(new LocEngPositionMode(mLocEngAdapter, posMode));\n}\nvoid LocInternalAdapter::startFixInt() {\n    sendMsg(new LocEngStartFix(mLocEngAdapter));\n}\nvoid LocInternalAdapter::stopFixInt() {\n    sendMsg(new LocEngStopFix(mLocEngAdapter));\n}\nvoid LocInternalAdapter::getZppInt() {\n    sendMsg(new LocEngGetZpp(mLocEngAdapter));\n}\n\nLocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,\n                             void* owner, ContextBase* context,\n                             LocThread::tCreate tCreator) :\n    LocAdapterBase(mask,\n                   //Get the AFW context if VzW context has not already been intialized in\n                   //loc_ext\n                   context == NULL?\n                   LocDualContext::getLocFgContext(tCreator,\n                                                   NULL,\n                                                   LocDualContext::mLocationHalName,\n                                                   false)\n                   :context),\n    mOwner(owner), mInternalAdapter(new LocInternalAdapter(this)),\n    mUlp(new UlpProxyBase()), mNavigating(false),\n    mSupportsAgpsRequests(false),\n    mSupportsPositionInjection(false),\n    mSupportsTimeInjection(false),\n    mPowerVote(0)\n{\n    memset(&mFixCriteria, 0, sizeof(mFixCriteria));\n    mFixCriteria.mode = LOC_POSITION_MODE_INVALID;\n    LOC_LOGD(\"LocEngAdapter created\");\n}\n\ninline\nLocEngAdapter::~LocEngAdapter()\n{\n    delete mInternalAdapter;\n    LOC_LOGV(\"LocEngAdapter deleted\");\n}\n\nvoid LocEngAdapter::setXtraUserAgent() {\n    struct LocSetXtraUserAgent : public LocMsg {\n        const ContextBase* const mContext;\n        inline LocSetXtraUserAgent(ContextBase* context) :\n            LocMsg(), mContext(context) {\n        }\n        virtual void proc() const {\n            char release[PROPERTY_VALUE_MAX];\n            char manufacture[PROPERTY_VALUE_MAX];\n            char model[PROPERTY_VALUE_MAX];\n            char carrier[PROPERTY_VALUE_MAX];\n            char board[PROPERTY_VALUE_MAX];\n            char brand[PROPERTY_VALUE_MAX];\n            char chipsetsn[CHIPSET_SERIAL_NUMBER_MAX_LEN];\n            char userAgent[USER_AGENT_MAX_LEN];\n            const char defVal[] = \"-\";\n\n            property_get(\"ro.build.version.release\", release,     defVal);\n            property_get(\"ro.product.manufacturer\",  manufacture, defVal);\n            property_get(\"ro.product.model\", model,   defVal);\n            property_get(\"ro.carrier\",       carrier, defVal);\n            property_get(\"ro.product.board\", board,   defVal);\n            property_get(\"ro.product.brand\", brand,   defVal);\n            getChipsetSerialNo(chipsetsn, sizeof(chipsetsn), defVal);\n\n            snprintf(userAgent, sizeof(userAgent), \"A/%s/%s/%s/%s/%s/QCX3/s%u/-/%s/-/%s/-/-/-\",\n                     release, manufacture, model, board, carrier,\n                     mContext->getIzatDevId(), chipsetsn, brand);\n\n            for (int i = 0; i < sizeof(userAgent) && userAgent[i]; i++) {\n                if (' ' == userAgent[i]) userAgent[i] = '#';\n            }\n\n            saveUserAgentString(userAgent, strlen(userAgent));\n            LOC_LOGV(\"%s] UserAgent %s\", __func__, userAgent);\n        }\n\n        void saveUserAgentString(const char* data, const int len) const {\n            const char XTRA_FOLDER[] = \"/data/misc/location/xtra\";\n            const char USER_AGENT_FILE[] = \"/data/misc/location/xtra/useragent.txt\";\n\n            if (data == NULL || len < 1) {\n                LOC_LOGE(\"%s:%d]: invalid input data = %p len = %d\", __func__, __LINE__, data, len);\n                return;\n            }\n\n            struct stat s;\n            int err = stat(XTRA_FOLDER, &s);\n            if (err < 0) {\n                if (ENOENT == errno) {\n                    if (mkdir(XTRA_FOLDER, 0700) < 0) {\n                        LOC_LOGE(\"%s:%d]: make XTRA_FOLDER failed\", __func__, __LINE__);\n                        return;\n                    }\n                } else {\n                    LOC_LOGE(\"%s:%d]: XTRA_FOLDER invalid\", __func__, __LINE__);\n                    return;\n                }\n            }\n\n            FILE* file = fopen(USER_AGENT_FILE, \"wt\");\n            if (file == NULL) {\n                LOC_LOGE(\"%s:%d]: open USER_AGENT_FILE failed\", __func__, __LINE__);\n                return;\n            }\n\n            size_t written = fwrite(data, 1, len, file);\n            fclose(file);\n            file = NULL;\n\n            // set file permission\n            chmod(USER_AGENT_FILE, 0600);\n\n            if (written != len) {\n                LOC_LOGE(\"%s:%d]: write USER_AGENT_FILE failed\", __func__, __LINE__);\n            }\n        }\n\n        void getChipsetSerialNo(char buf[], int buflen, const char def[]) const {\n            const char SOC_SERIAL_NUMBER[] = \"/sys/devices/soc0/serial_number\";\n\n            FILE* file = fopen(SOC_SERIAL_NUMBER, \"rt\");\n            if (file == NULL) {\n                // use default upon unreadable file\n                strlcpy(buf, def, buflen);\n\n            } else {\n                size_t size = fread(buf, 1, buflen - 1, file);\n                if (size == 0) {\n                   // use default upon empty file\n                   strlcpy(buf, def, buflen);\n\n                } else {\n                   buf[size] = '\\0';\n                }\n\n                fclose(file);\n\n                // remove trailing spaces\n                size_t len = strlen(buf);\n                while (--len >= 0 && isspace(buf[len])) {\n                    buf[len] = '\\0';\n                }\n            }\n\n            return;\n        }\n\n    };\n\n    sendMsg(new LocSetXtraUserAgent(mContext));\n}\n\nvoid LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {\n    struct LocSetUlpProxy : public LocMsg {\n        LocAdapterBase* mAdapter;\n        UlpProxyBase* mUlp;\n        inline LocSetUlpProxy(LocAdapterBase* adapter, UlpProxyBase* ulp) :\n            LocMsg(), mAdapter(adapter), mUlp(ulp) {\n        }\n        virtual void proc() const {\n            LOC_LOGV(\"%s] ulp %p adapter %p\", __func__,\n                     mUlp, mAdapter);\n            mAdapter->setUlpProxy(mUlp);\n        }\n    };\n\n    sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp));\n}\n\nvoid LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)\n{\n    if (ulp == mUlp) {\n        //This takes care of the case when double initalization happens\n        //and we get the same object back for UlpProxyBase . Do nothing\n        return;\n    }\n\n    LOC_LOGV(\"%s] %p\", __func__, ulp);\n    if (NULL == ulp) {\n        LOC_LOGE(\"%s:%d]: ulp pointer is NULL\", __func__, __LINE__);\n        ulp = new UlpProxyBase();\n    }\n\n    if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) {\n        // need to send this mode and start msg to ULP\n        ulp->sendFixMode(mUlp->mPosMode);\n    }\n\n    if(mUlp->mFixSet) {\n        ulp->sendStartFix();\n    }\n\n    delete mUlp;\n    mUlp = ulp;\n}\n\nint LocEngAdapter::setGpsLockMsg(LOC_GPS_LOCK_MASK lockMask)\n{\n    struct LocEngAdapterGpsLock : public LocMsg {\n        LocEngAdapter* mAdapter;\n        LOC_GPS_LOCK_MASK mLockMask;\n        inline LocEngAdapterGpsLock(LocEngAdapter* adapter, LOC_GPS_LOCK_MASK lockMask) :\n            LocMsg(), mAdapter(adapter), mLockMask(lockMask)\n        {\n            locallog();\n        }\n        inline virtual void proc() const {\n            mAdapter->setGpsLock(mLockMask);\n        }\n        inline  void locallog() const {\n            LOC_LOGV(\"LocEngAdapterGpsLock - mLockMask: %x\", mLockMask);\n        }\n        inline virtual void log() const {\n            locallog();\n        }\n    };\n    sendMsg(new LocEngAdapterGpsLock(this, lockMask));\n    return 0;\n}\n\nvoid LocEngAdapter::requestPowerVote()\n{\n    if (getPowerVoteRight()) {\n        /* Power voting without engine lock:\n         * 101: vote down, 102-104 - vote up\n         * These codes are used not to confuse with actual engine lock\n         * functionality, that can't be used in SSR scenario, as it\n         * conflicts with initialization sequence.\n         */\n        bool powerUp = getPowerVote();\n        LOC_LOGV(\"LocEngAdapterVotePower - Vote Power: %d\", (int)powerUp);\n        setGpsLock(powerUp ? 103 : 101);\n    }\n}\n\nvoid LocInternalAdapter::reportPosition(UlpLocation &location,\n                                        GpsLocationExtended &locationExtended,\n                                        void* locationExt,\n                                        enum loc_sess_status status,\n                                        LocPosTechMask loc_technology_mask)\n{\n    sendMsg(new LocEngReportPosition(mLocEngAdapter,\n                                     location,\n                                     locationExtended,\n                                     locationExt,\n                                     status,\n                                     loc_technology_mask));\n}\n\n\nvoid LocEngAdapter::reportPosition(UlpLocation &location,\n                                   GpsLocationExtended &locationExtended,\n                                   void* locationExt,\n                                   enum loc_sess_status status,\n                                   LocPosTechMask loc_technology_mask)\n{\n    if (! mUlp->reportPosition(location,\n                               locationExtended,\n                               locationExt,\n                               status,\n                               loc_technology_mask )) {\n        mInternalAdapter->reportPosition(location,\n                                         locationExtended,\n                                         locationExt,\n                                         status,\n                                         loc_technology_mask);\n    }\n}\n\nvoid LocInternalAdapter::reportSv(QcomSvStatus &svStatus,\n                                  GpsLocationExtended &locationExtended,\n                                  void* svExt){\n    sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus,\n                               locationExtended, svExt));\n}\n\nvoid LocEngAdapter::reportSv(QcomSvStatus &svStatus,\n                             GpsLocationExtended &locationExtended,\n                             void* svExt)\n{\n\n    // We want to send SV info to ULP to help it in determining GNSS\n    // signal strength ULP will forward the SV reports to HAL without\n    // any modifications\n    if (! mUlp->reportSv(svStatus, locationExtended, svExt)) {\n        mInternalAdapter->reportSv(svStatus, locationExtended, svExt);\n    }\n}\n\nvoid LocEngAdapter::setInSession(bool inSession)\n{\n    mNavigating = inSession;\n    mLocApi->setInSession(inSession);\n    if (!mNavigating) {\n        mFixCriteria.mode = LOC_POSITION_MODE_INVALID;\n    }\n}\n\nvoid LocInternalAdapter::reportStatus(GpsStatusValue status)\n{\n    sendMsg(new LocEngReportStatus(mLocEngAdapter, status));\n}\n\nvoid LocEngAdapter::reportStatus(GpsStatusValue status)\n{\n    if (!mUlp->reportStatus(status)) {\n        mInternalAdapter->reportStatus(status);\n    }\n}\n\ninline\nvoid LocEngAdapter::reportNmea(const char* nmea, int length)\n{\n    sendMsg(new LocEngReportNmea(mOwner, nmea, length));\n}\n\ninline\nbool LocEngAdapter::reportXtraServer(const char* url1,\n                                        const char* url2,\n                                        const char* url3,\n                                        const int maxlength)\n{\n    if (mSupportsAgpsRequests) {\n        sendMsg(new LocEngReportXtraServer(mOwner, url1,\n                                           url2, url3, maxlength));\n    }\n    return mSupportsAgpsRequests;\n}\n\ninline\nbool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type)\n{\n    if (mSupportsAgpsRequests) {\n        sendMsg(new LocEngRequestATL(mOwner,\n                                     connHandle, agps_type));\n    }\n    return mSupportsAgpsRequests;\n}\n\ninline\nbool LocEngAdapter::releaseATL(int connHandle)\n{\n    if (mSupportsAgpsRequests) {\n        sendMsg(new LocEngReleaseATL(mOwner, connHandle));\n    }\n    return mSupportsAgpsRequests;\n}\n\ninline\nbool LocEngAdapter::requestXtraData()\n{\n    if (mSupportsAgpsRequests) {\n        sendMsg(new LocEngRequestXtra(mOwner));\n    }\n    return mSupportsAgpsRequests;\n}\n\ninline\nbool LocEngAdapter::requestTime()\n{\n    if (mSupportsAgpsRequests) {\n        sendMsg(new LocEngRequestTime(mOwner));\n    }\n    return mSupportsAgpsRequests;\n}\n\ninline\nbool LocEngAdapter::requestNiNotify(GpsNiNotification &notif, const void* data)\n{\n    if (mSupportsAgpsRequests) {\n        notif.size = sizeof(notif);\n        notif.timeout = LOC_NI_NO_RESPONSE_TIME;\n\n        sendMsg(new LocEngRequestNi(mOwner, notif, data));\n    }\n    return mSupportsAgpsRequests;\n}\n\ninline\nbool LocEngAdapter::requestSuplES(int connHandle)\n{\n    if (mSupportsAgpsRequests)\n        sendMsg(new LocEngRequestSuplEs(mOwner, connHandle));\n    return mSupportsAgpsRequests;\n}\n\ninline\nbool LocEngAdapter::reportDataCallOpened()\n{\n    if(mSupportsAgpsRequests)\n        sendMsg(new LocEngSuplEsOpened(mOwner));\n    return mSupportsAgpsRequests;\n}\n\ninline\nbool LocEngAdapter::reportDataCallClosed()\n{\n    if(mSupportsAgpsRequests)\n        sendMsg(new LocEngSuplEsClosed(mOwner));\n    return mSupportsAgpsRequests;\n}\n\ninline\nvoid LocEngAdapter::handleEngineDownEvent()\n{\n    sendMsg(new LocEngDown(mOwner));\n}\n\ninline\nvoid LocEngAdapter::handleEngineUpEvent()\n{\n    sendMsg(new LocEngUp(mOwner));\n}\n\nenum loc_api_adapter_err LocEngAdapter::setTime(GpsUtcTime time,\n                                                int64_t timeReference,\n                                                int uncertainty)\n{\n    loc_api_adapter_err result = LOC_API_ADAPTER_ERR_SUCCESS;\n\n    LOC_LOGD(\"%s:%d]: mSupportsTimeInjection is %d\",\n             __func__, __LINE__, mSupportsTimeInjection);\n\n    if (mSupportsTimeInjection) {\n        LOC_LOGD(\"%s:%d]: Injecting time\", __func__, __LINE__);\n        result = mLocApi->setTime(time, timeReference, uncertainty);\n    } else {\n        mSupportsTimeInjection = true;\n    }\n    return result;\n}\n\nenum loc_api_adapter_err LocEngAdapter::setXtraVersionCheck(int check)\n{\n    enum loc_api_adapter_err ret;\n    ENTRY_LOG();\n    enum xtra_version_check eCheck;\n    switch (check) {\n    case 0:\n        eCheck = DISABLED;\n        break;\n    case 1:\n        eCheck = AUTO;\n        break;\n    case 2:\n        eCheck = XTRA2;\n        break;\n    case 3:\n        eCheck = XTRA3;\n        break;\n    default:\n        eCheck = DISABLED;\n    }\n    ret = mLocApi->setXtraVersionCheck(eCheck);\n    EXIT_LOG(%d, ret);\n    return ret;\n}\n\nvoid LocEngAdapter::reportGpsMeasurementData(GpsData &gpsMeasurementData)\n{\n    sendMsg(new LocEngReportGpsMeasurement(mOwner,\n                                           gpsMeasurementData));\n}\n\n/*\n  Update Registration Mask\n */\nvoid LocEngAdapter::updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event,\n                                           loc_registration_mask_status isEnabled)\n{\n    LOC_LOGD(\"entering %s\", __func__);\n    int result = LOC_API_ADAPTER_ERR_FAILURE;\n    result = mLocApi->updateRegistrationMask(event, isEnabled);\n    if (result == LOC_API_ADAPTER_ERR_SUCCESS) {\n        LOC_LOGD(\"%s] update registration mask succeed.\", __func__);\n    } else {\n        LOC_LOGE(\"%s] update registration mask failed.\", __func__);\n    }\n}\n\n/*\n  Set Gnss Constellation Config\n */\nbool LocEngAdapter::gnssConstellationConfig()\n{\n    LOC_LOGD(\"entering %s\", __func__);\n    bool result = false;\n    result = mLocApi->gnssConstellationConfig();\n    return result;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/LocEngAdapter.h",
    "content": "/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_API_ENG_ADAPTER_H\n#define LOC_API_ENG_ADAPTER_H\n\n#include <ctype.h>\n#include <hardware/gps.h>\n#include <loc.h>\n#include <loc_eng_log.h>\n#include <log_util.h>\n#include <LocAdapterBase.h>\n#include <LocDualContext.h>\n#include <UlpProxyBase.h>\n#include <platform_lib_includes.h>\n\n#define MAX_URL_LEN 256\n\nusing namespace loc_core;\n\nclass LocEngAdapter;\n\nclass LocInternalAdapter : public LocAdapterBase {\n    LocEngAdapter* mLocEngAdapter;\npublic:\n    LocInternalAdapter(LocEngAdapter* adapter);\n\n    virtual void reportPosition(UlpLocation &location,\n                                GpsLocationExtended &locationExtended,\n                                void* locationExt,\n                                enum loc_sess_status status,\n                                LocPosTechMask loc_technology_mask);\n    virtual void reportSv(QcomSvStatus &svStatus,\n                          GpsLocationExtended &locationExtended,\n                          void* svExt);\n    virtual void reportStatus(GpsStatusValue status);\n    virtual void setPositionModeInt(LocPosMode& posMode);\n    virtual void startFixInt();\n    virtual void stopFixInt();\n    virtual void getZppInt();\n    virtual void setUlpProxy(UlpProxyBase* ulp);\n};\n\ntypedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp);\n\nclass LocEngAdapter : public LocAdapterBase {\n    void* mOwner;\n    LocInternalAdapter* mInternalAdapter;\n    UlpProxyBase* mUlp;\n    LocPosMode mFixCriteria;\n    bool mNavigating;\n    // mPowerVote is encoded as\n    // mPowerVote & 0x20 -- powerVoteRight\n    // mPowerVote & 0x10 -- power On / Off\n    unsigned int mPowerVote;\n    static const unsigned int POWER_VOTE_RIGHT = 0x20;\n    static const unsigned int POWER_VOTE_VALUE = 0x10;\n\npublic:\n    bool mSupportsAgpsRequests;\n    bool mSupportsPositionInjection;\n    bool mSupportsTimeInjection;\n\n    LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,\n                  void* owner, ContextBase* context,\n                  LocThread::tCreate tCreator);\n    virtual ~LocEngAdapter();\n\n    virtual void setUlpProxy(UlpProxyBase* ulp);\n    void setXtraUserAgent();\n    inline void requestUlp(unsigned long capabilities) {\n        mContext->requestUlp(mInternalAdapter, capabilities);\n    }\n    inline LocInternalAdapter* getInternalAdapter() { return mInternalAdapter; }\n    inline UlpProxyBase* getUlpProxy() { return mUlp; }\n    inline void* getOwner() { return mOwner; }\n    inline bool hasAgpsExtendedCapabilities() {\n        return mContext->hasAgpsExtendedCapabilities();\n    }\n    inline bool hasCPIExtendedCapabilities() {\n        return mContext->hasCPIExtendedCapabilities();\n    }\n    inline const MsgTask* getMsgTask() { return mMsgTask; }\n\n    inline enum loc_api_adapter_err\n        startFix()\n    {\n        return mLocApi->startFix(mFixCriteria);\n    }\n    inline enum loc_api_adapter_err\n        stopFix()\n    {\n        return mLocApi->stopFix();\n    }\n    inline enum loc_api_adapter_err\n        deleteAidingData(GpsAidingData f)\n    {\n        return mLocApi->deleteAidingData(f);\n    }\n    inline enum loc_api_adapter_err\n        enableData(int enable)\n    {\n        return mLocApi->enableData(enable);\n    }\n    inline enum loc_api_adapter_err\n        setAPN(char* apn, int len)\n    {\n        return mLocApi->setAPN(apn, len);\n    }\n    inline enum loc_api_adapter_err\n        injectPosition(double latitude, double longitude, float accuracy)\n    {\n        return mLocApi->injectPosition(latitude, longitude, accuracy);\n    }\n    inline enum loc_api_adapter_err\n        setXtraData(char* data, int length)\n    {\n        return mLocApi->setXtraData(data, length);\n    }\n    inline enum loc_api_adapter_err\n        requestXtraServer()\n    {\n        return mLocApi->requestXtraServer();\n    }\n    inline enum loc_api_adapter_err\n        atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType)\n    {\n        return mLocApi->atlOpenStatus(handle, is_succ, apn, bearer, agpsType);\n    }\n    inline enum loc_api_adapter_err\n        atlCloseStatus(int handle, int is_succ)\n    {\n        return mLocApi->atlCloseStatus(handle, is_succ);\n    }\n    inline enum loc_api_adapter_err\n        setPositionMode(const LocPosMode *posMode)\n    {\n        if (NULL != posMode) {\n            mFixCriteria = *posMode;\n        }\n        return mLocApi->setPositionMode(mFixCriteria);\n    }\n    inline enum loc_api_adapter_err\n        setServer(const char* url, int len)\n    {\n        return mLocApi->setServer(url, len);\n    }\n    inline enum loc_api_adapter_err\n        setServer(unsigned int ip, int port,\n                  LocServerType type)\n    {\n        return mLocApi->setServer(ip, port, type);\n    }\n    inline enum loc_api_adapter_err\n        informNiResponse(GpsUserResponseType userResponse, const void* passThroughData)\n    {\n        return mLocApi->informNiResponse(userResponse, passThroughData);\n    }\n    inline enum loc_api_adapter_err\n        setSUPLVersion(uint32_t version)\n    {\n        return mLocApi->setSUPLVersion(version);\n    }\n    inline enum loc_api_adapter_err\n        setLPPConfig(uint32_t profile)\n    {\n        return mLocApi->setLPPConfig(profile);\n    }\n    inline enum loc_api_adapter_err\n        setSensorControlConfig(int sensorUsage, int sensorProvider)\n    {\n        return mLocApi->setSensorControlConfig(sensorUsage, sensorProvider);\n    }\n    inline enum loc_api_adapter_err\n        setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,\n                            bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk,\n                            bool angleBiasVarianceRandomWalk_valid, float angleBiasVarianceRandomWalk,\n                            bool rateBiasVarianceRandomWalk_valid, float rateBiasVarianceRandomWalk,\n                            bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk)\n    {\n        return mLocApi->setSensorProperties(gyroBiasVarianceRandomWalk_valid, gyroBiasVarianceRandomWalk,\n                                           accelBiasVarianceRandomWalk_valid, accelBiasVarianceRandomWalk,\n                                           angleBiasVarianceRandomWalk_valid, angleBiasVarianceRandomWalk,\n                                           rateBiasVarianceRandomWalk_valid, rateBiasVarianceRandomWalk,\n                                           velocityBiasVarianceRandomWalk_valid, velocityBiasVarianceRandomWalk);\n    }\n    inline virtual enum loc_api_adapter_err\n        setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec,\n                            int gyroSamplesPerBatch, int gyroBatchesPerSec,\n                            int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,\n                            int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig)\n    {\n        return mLocApi->setSensorPerfControlConfig(controlMode, accelSamplesPerBatch, accelBatchesPerSec,\n                                                  gyroSamplesPerBatch, gyroBatchesPerSec,\n                                                  accelSamplesPerBatchHigh, accelBatchesPerSecHigh,\n                                                  gyroSamplesPerBatchHigh, gyroBatchesPerSecHigh,\n                                                  algorithmConfig);\n    }\n    inline virtual enum loc_api_adapter_err\n        setExtPowerConfig(int isBatteryCharging)\n    {\n        return mLocApi->setExtPowerConfig(isBatteryCharging);\n    }\n    inline virtual enum loc_api_adapter_err\n        setAGLONASSProtocol(unsigned long aGlonassProtocol)\n    {\n        return mLocApi->setAGLONASSProtocol(aGlonassProtocol);\n    }\n    inline virtual int initDataServiceClient()\n    {\n        return mLocApi->initDataServiceClient();\n    }\n    inline virtual int openAndStartDataCall()\n    {\n        return mLocApi->openAndStartDataCall();\n    }\n    inline virtual void stopDataCall()\n    {\n        mLocApi->stopDataCall();\n    }\n    inline virtual void closeDataCall()\n    {\n        mLocApi->closeDataCall();\n    }\n    inline enum loc_api_adapter_err\n        getZpp(GpsLocation &zppLoc, LocPosTechMask &tech_mask)\n    {\n        return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask);\n    }\n    enum loc_api_adapter_err setTime(GpsUtcTime time,\n                                     int64_t timeReference,\n                                     int uncertainty);\n    enum loc_api_adapter_err setXtraVersionCheck(int check);\n    inline virtual void installAGpsCert(const DerEncodedCertificate* pData,\n                                        size_t length,\n                                        uint32_t slotBitMask)\n    {\n        mLocApi->installAGpsCert(pData, length, slotBitMask);\n    }\n    virtual void handleEngineDownEvent();\n    virtual void handleEngineUpEvent();\n    virtual void reportPosition(UlpLocation &location,\n                                GpsLocationExtended &locationExtended,\n                                void* locationExt,\n                                enum loc_sess_status status,\n                                LocPosTechMask loc_technology_mask);\n    virtual void reportSv(QcomSvStatus &svStatus,\n                          GpsLocationExtended &locationExtended,\n                          void* svExt);\n    virtual void reportStatus(GpsStatusValue status);\n    virtual void reportNmea(const char* nmea, int length);\n    virtual bool reportXtraServer(const char* url1, const char* url2,\n                                  const char* url3, const int maxlength);\n    virtual bool requestXtraData();\n    virtual bool requestTime();\n    virtual bool requestATL(int connHandle, AGpsType agps_type);\n    virtual bool releaseATL(int connHandle);\n    virtual bool requestNiNotify(GpsNiNotification &notify, const void* data);\n    virtual bool requestSuplES(int connHandle);\n    virtual bool reportDataCallOpened();\n    virtual bool reportDataCallClosed();\n    virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData);\n\n    inline const LocPosMode& getPositionMode() const\n    {return mFixCriteria;}\n    inline virtual bool isInSession()\n    { return mNavigating; }\n    void setInSession(bool inSession);\n\n    // Permit/prohibit power voting\n    inline void setPowerVoteRight(bool powerVoteRight) {\n        mPowerVote = powerVoteRight ? (mPowerVote | POWER_VOTE_RIGHT) :\n                                      (mPowerVote & ~POWER_VOTE_RIGHT);\n    }\n    inline bool getPowerVoteRight() const {\n        return (mPowerVote & POWER_VOTE_RIGHT) != 0 ;\n    }\n    // Set the power voting up/down and do actual operation if permitted\n    inline void setPowerVote(bool powerOn) {\n        mPowerVote = powerOn ? (mPowerVote | POWER_VOTE_VALUE) :\n                               (mPowerVote & ~POWER_VOTE_VALUE);\n        requestPowerVote();\n        mContext->modemPowerVote(powerOn);\n    }\n    inline bool getPowerVote() const {\n        return (mPowerVote & POWER_VOTE_VALUE) != 0 ;\n    }\n    // Do power voting according to last settings if permitted\n    void requestPowerVote();\n\n    /*Values for lock\n      1 = Do not lock any position sessions\n      2 = Lock MI position sessions\n      3 = Lock MT position sessions\n      4 = Lock all position sessions\n    */\n    inline int setGpsLock(LOC_GPS_LOCK_MASK lock)\n    {\n        return mLocApi->setGpsLock(lock);\n    }\n\n    int setGpsLockMsg(LOC_GPS_LOCK_MASK lock);\n\n    /*\n      Returns\n      Current value of GPS lock on success\n      -1 on failure\n     */\n    inline int getGpsLock()\n    {\n        return mLocApi->getGpsLock();\n    }\n\n    /*\n      Update Registration Mask\n     */\n    void updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event,\n                                loc_registration_mask_status isEnabled);\n\n    /*\n      Set Gnss Constellation Config\n     */\n    bool gnssConstellationConfig();\n};\n\n#endif //LOC_API_ENG_ADAPTER_H\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/Makefile.am",
    "content": "AM_CFLAGS = \\\n     -I../../utils \\\n     -I../../platform_lib_abstractions \\\n     -fno-short-enums \\\n     -DFEATURE_GNSS_BIT_API\n\nlibloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocEngAdapter.cpp\n\nif USE_GLIB\nlibloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@\nlibloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0\nlibloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@\nelse\nlibloc_adapter_so_la_CFLAGS = $(AM_CFLAGS)\nlibloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0\nlibloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)\nendif\nlibloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la\n\n\nlibloc_eng_so_la_SOURCES = \\\n    loc_eng.cpp \\\n    loc_eng_agps.cpp \\\n    loc_eng_xtra.cpp \\\n    loc_eng_ni.cpp \\\n    loc_eng_log.cpp \\\n    loc_eng_dmn_conn.cpp \\\n    loc_eng_dmn_conn_handler.cpp \\\n    loc_eng_dmn_conn_thread_helper.c \\\n    loc_eng_dmn_conn_glue_msg.c \\\n    loc_eng_dmn_conn_glue_pipe.c\n\n\nif USE_GLIB\nlibloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@\nlibloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0\nlibloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@\nelse\nlibloc_eng_so_la_CFLAGS = $(AM_CFLAGS)\nlibloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0\nlibloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)\nendif\n\nlibloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la\n\n\nlibgps_default_so_la_SOURCES = \\\n      loc.cpp \\\n      gps.c\n\nif USE_GLIB\nlibgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@\nlibgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0\nlibgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@\nelse\nlibgps_default_so_la_CFLAGS = $(AM_CFLAGS)\nlibgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0\nlibgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)\nendif\n\nlibgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la\n\nlibrary_include_HEADERS = \\\n   LocEngAdapter.h \\\n   loc.h \\\n   loc_eng.h \\\n   loc_eng_xtra.h \\\n   loc_eng_ni.h \\\n   loc_eng_agps.h \\\n   loc_eng_msg.h \\\n   loc_eng_log.h\n\nlibrary_includedir = $(pkgincludedir)/libloc_api_50001\n\n#Create and Install libraries\nlib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la libgps_default_so.la\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/gps.c",
    "content": "/* Copyright (c) 2011,2015 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#include <hardware/gps.h>\n\n#include <stdlib.h>\n#include <string.h>\n\nextern const GpsInterface* get_gps_interface();\n\nconst GpsInterface* gps__get_gps_interface(struct gps_device_t* dev)\n{\n    return get_gps_interface();\n}\n\nstatic int open_gps(const struct hw_module_t* module, char const* name,\n        struct hw_device_t** device)\n{\n    struct gps_device_t *dev = (struct gps_device_t *) malloc(sizeof(struct gps_device_t));\n\n    if(dev == NULL)\n        return -1;\n\n    memset(dev, 0, sizeof(*dev));\n\n    dev->common.tag = HARDWARE_DEVICE_TAG;\n    dev->common.version = 0;\n    dev->common.module = (struct hw_module_t*)module;\n    dev->get_gps_interface = gps__get_gps_interface;\n\n    *device = (struct hw_device_t*)dev;\n    return 0;\n}\n\nstatic struct hw_module_methods_t gps_module_methods = {\n    .open = open_gps\n};\n\nstruct hw_module_t HAL_MODULE_INFO_SYM = {\n    .tag = HARDWARE_MODULE_TAG,\n    .module_api_version = 1,\n    .hal_api_version = 0,\n    .id = GPS_HARDWARE_MODULE_ID,\n    .name = \"loc_api GPS Module\",\n    .author = \"Qualcomm USA, Inc.\",\n    .methods = &gps_module_methods,\n};\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc.cpp",
    "content": "/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_afw\"\n\n#include <hardware/gps.h>\n#include <gps_extended.h>\n#include <loc_eng.h>\n#include <loc_target.h>\n#include <loc_log.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <dlfcn.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <LocDualContext.h>\n#include <cutils/properties.h>\n\nusing namespace loc_core;\n\n#define LOC_PM_CLIENT_NAME \"GPS\"\n\n//Globals defns\nstatic gps_location_callback gps_loc_cb = NULL;\nstatic gps_sv_status_callback gps_sv_cb = NULL;\n\nstatic void local_loc_cb(UlpLocation* location, void* locExt);\nstatic void local_sv_cb(GpsSvStatus* sv_status, void* svExt);\n\nstatic const GpsGeofencingInterface* get_geofence_interface(void);\n\n// Function declarations for sLocEngInterface\nstatic int  loc_init(GpsCallbacks* callbacks);\nstatic int  loc_start();\nstatic int  loc_stop();\nstatic void loc_cleanup();\nstatic int  loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty);\nstatic int  loc_inject_location(double latitude, double longitude, float accuracy);\nstatic void loc_delete_aiding_data(GpsAidingData f);\nstatic int  loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence,\n                                  uint32_t min_interval, uint32_t preferred_accuracy,\n                                  uint32_t preferred_time);\nstatic const void* loc_get_extension(const char* name);\n// Defines the GpsInterface in gps.h\nstatic const GpsInterface sLocEngInterface =\n{\n   sizeof(GpsInterface),\n   loc_init,\n   loc_start,\n   loc_stop,\n   loc_cleanup,\n   loc_inject_time,\n   loc_inject_location,\n   loc_delete_aiding_data,\n   loc_set_position_mode,\n   loc_get_extension\n};\n\n// Function declarations for sLocEngAGpsInterface\nstatic void loc_agps_init(AGpsCallbacks* callbacks);\nstatic int  loc_agps_open(const char* apn);\nstatic int  loc_agps_closed();\nstatic int  loc_agps_open_failed();\nstatic int  loc_agps_set_server(AGpsType type, const char *hostname, int port);\nstatic int  loc_agps_open_with_apniptype( const char* apn, ApnIpType apnIpType);\n\nstatic const AGpsInterface sLocEngAGpsInterface =\n{\n   sizeof(AGpsInterface),\n   loc_agps_init,\n   loc_agps_open,\n   loc_agps_closed,\n   loc_agps_open_failed,\n   loc_agps_set_server,\n   loc_agps_open_with_apniptype\n};\n\nstatic int loc_xtra_init(GpsXtraCallbacks* callbacks);\nstatic int loc_xtra_inject_data(char* data, int length);\n\nstatic const GpsXtraInterface sLocEngXTRAInterface =\n{\n    sizeof(GpsXtraInterface),\n    loc_xtra_init,\n    loc_xtra_inject_data\n};\n\nstatic void loc_ni_init(GpsNiCallbacks *callbacks);\nstatic void loc_ni_respond(int notif_id, GpsUserResponseType user_response);\n\nstatic const GpsNiInterface sLocEngNiInterface =\n{\n   sizeof(GpsNiInterface),\n   loc_ni_init,\n   loc_ni_respond,\n};\n\nstatic int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks);\nstatic void loc_gps_measurement_close();\n\nstatic const GpsMeasurementInterface sLocEngGpsMeasurementInterface =\n{\n    sizeof(GpsMeasurementInterface),\n    loc_gps_measurement_init,\n    loc_gps_measurement_close\n};\n\nstatic void loc_agps_ril_init( AGpsRilCallbacks* callbacks );\nstatic void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct);\nstatic void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid);\nstatic void loc_agps_ril_ni_message(uint8_t *msg, size_t len);\nstatic void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info);\nstatic void loc_agps_ril_update_network_availability(int avaiable, const char* apn);\n\nstatic const AGpsRilInterface sLocEngAGpsRilInterface =\n{\n   sizeof(AGpsRilInterface),\n   loc_agps_ril_init,\n   loc_agps_ril_set_ref_location,\n   loc_agps_ril_set_set_id,\n   loc_agps_ril_ni_message,\n   loc_agps_ril_update_network_state,\n   loc_agps_ril_update_network_availability\n};\n\nstatic int loc_agps_install_certificates(const DerEncodedCertificate* certificates,\n                                         size_t length);\nstatic int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints,\n                                        size_t length);\n\nstatic const SuplCertificateInterface sLocEngAGpsCertInterface =\n{\n    sizeof(SuplCertificateInterface),\n    loc_agps_install_certificates,\n    loc_agps_revoke_certificates\n};\n\nstatic void loc_configuration_update(const char* config_data, int32_t length);\n\nstatic const GnssConfigurationInterface sLocEngConfigInterface =\n{\n    sizeof(GnssConfigurationInterface),\n    loc_configuration_update\n};\n\nstatic loc_eng_data_s_type loc_afw_data;\nstatic int gss_fd = -1;\nstatic int sGnssType = GNSS_UNKNOWN;\n/*===========================================================================\nFUNCTION    gps_get_hardware_interface\n\nDESCRIPTION\n   Returns the GPS hardware interaface based on LOC API\n   if GPS is enabled.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nconst GpsInterface* gps_get_hardware_interface ()\n{\n    ENTRY_LOG_CALLFLOW();\n    const GpsInterface* ret_val;\n\n    char propBuf[PROPERTY_VALUE_MAX];\n\n    loc_eng_read_config();\n\n    // check to see if GPS should be disabled\n    property_get(\"gps.disable\", propBuf, \"\");\n    if (propBuf[0] == '1')\n    {\n        LOC_LOGD(\"gps_get_interface returning NULL because gps.disable=1\\n\");\n        ret_val = NULL;\n    } else {\n        ret_val = &sLocEngInterface;\n    }\n\n    loc_eng_read_config();\n\n    EXIT_LOG(%p, ret_val);\n    return ret_val;\n}\n\n// for gps.c\nextern \"C\" const GpsInterface* get_gps_interface()\n{\n    unsigned int target = TARGET_DEFAULT;\n    loc_eng_read_config();\n\n    target = loc_get_target();\n    LOC_LOGD(\"Target name check returned %s\", loc_get_target_name(target));\n\n    sGnssType = getTargetGnssType(target);\n    switch (sGnssType)\n    {\n    case GNSS_GSS:\n    case GNSS_AUTO:\n        //APQ8064\n        gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);\n        gss_fd = open(\"/dev/gss\", O_RDONLY);\n        if (gss_fd < 0) {\n            LOC_LOGE(\"GSS open failed: %s\\n\", strerror(errno));\n        }\n        else {\n            LOC_LOGD(\"GSS open success! CAPABILITIES %0lx\\n\",\n                     gps_conf.CAPABILITIES);\n        }\n        break;\n    case GNSS_NONE:\n        //MPQ8064\n        LOC_LOGE(\"No GPS HW on this target. Not returning interface.\");\n        return NULL;\n    case GNSS_QCA1530:\n        // qca1530 chip is present\n        gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);\n        LOC_LOGD(\"qca1530 present: CAPABILITIES %0lx\\n\", gps_conf.CAPABILITIES);\n        break;\n    }\n    return &sLocEngInterface;\n}\n\n/*===========================================================================\nFUNCTION    loc_init\n\nDESCRIPTION\n   Initialize the location engine, this include setting up global datas\n   and registers location engien with loc api service.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/Ax\n\n===========================================================================*/\nstatic int loc_init(GpsCallbacks* callbacks)\n{\n    int retVal = -1;\n    ENTRY_LOG();\n    LOC_API_ADAPTER_EVENT_MASK_T event;\n\n    if (NULL == callbacks) {\n        LOC_LOGE(\"loc_init failed. cb = NULL\\n\");\n        EXIT_LOG(%d, retVal);\n        return retVal;\n    }\n\n    event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |\n            LOC_API_ADAPTER_BIT_SATELLITE_REPORT |\n            LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST |\n            LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST |\n            LOC_API_ADAPTER_BIT_IOCTL_REPORT |\n            LOC_API_ADAPTER_BIT_STATUS_REPORT |\n            LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |\n            LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST;\n\n    LocCallbacks clientCallbacks = {local_loc_cb, /* location_cb */\n                                    callbacks->status_cb, /* status_cb */\n                                    local_sv_cb, /* sv_status_cb */\n                                    callbacks->nmea_cb, /* nmea_cb */\n                                    callbacks->set_capabilities_cb, /* set_capabilities_cb */\n                                    callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */\n                                    callbacks->release_wakelock_cb, /* release_wakelock_cb */\n                                    callbacks->create_thread_cb, /* create_thread_cb */\n                                    NULL, /* location_ext_parser */\n                                    NULL, /* sv_ext_parser */\n                                    callbacks->request_utc_time_cb, /* request_utc_time_cb */\n                                    };\n\n    gps_loc_cb = callbacks->location_cb;\n    gps_sv_cb = callbacks->sv_status_cb;\n\n    retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL);\n    loc_afw_data.adapter->mSupportsAgpsRequests = !loc_afw_data.adapter->hasAgpsExtendedCapabilities();\n    loc_afw_data.adapter->mSupportsPositionInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities();\n    loc_afw_data.adapter->mSupportsTimeInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities();\n    loc_afw_data.adapter->setGpsLockMsg(0);\n    loc_afw_data.adapter->requestUlp(getCarrierCapabilities());\n    loc_afw_data.adapter->setXtraUserAgent();\n\n    if(retVal) {\n        LOC_LOGE(\"loc_eng_init() fail!\");\n        goto err;\n    }\n\n    loc_afw_data.adapter->setPowerVoteRight(loc_get_target() == TARGET_QCA1530);\n    loc_afw_data.adapter->setPowerVote(true);\n\n    LOC_LOGD(\"loc_eng_init() success!\");\n\nerr:\n    EXIT_LOG(%d, retVal);\n    return retVal;\n}\n\n/*===========================================================================\nFUNCTION    loc_cleanup\n\nDESCRIPTION\n   Cleans location engine. The location client handle will be released.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_cleanup()\n{\n    ENTRY_LOG();\n\n    loc_afw_data.adapter->setPowerVote(false);\n    loc_afw_data.adapter->setGpsLockMsg(gps_conf.GPS_LOCK);\n\n    loc_eng_cleanup(loc_afw_data);\n    gps_loc_cb = NULL;\n    gps_sv_cb = NULL;\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\nFUNCTION    loc_start\n\nDESCRIPTION\n   Starts the tracking session\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_start()\n{\n    ENTRY_LOG();\n    int ret_val = loc_eng_start(loc_afw_data);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_stop\n\nDESCRIPTION\n   Stops the tracking session\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_stop()\n{\n    ENTRY_LOG();\n    int ret_val = -1;\n    ret_val = loc_eng_stop(loc_afw_data);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_set_position_mode\n\nDESCRIPTION\n   Sets the mode and fix frequency for the tracking session.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int  loc_set_position_mode(GpsPositionMode mode,\n                                  GpsPositionRecurrence recurrence,\n                                  uint32_t min_interval,\n                                  uint32_t preferred_accuracy,\n                                  uint32_t preferred_time)\n{\n    ENTRY_LOG();\n    int ret_val = -1;\n    LocPositionMode locMode;\n    switch (mode) {\n    case GPS_POSITION_MODE_MS_BASED:\n        locMode = LOC_POSITION_MODE_MS_BASED;\n        break;\n    case GPS_POSITION_MODE_MS_ASSISTED:\n        locMode = LOC_POSITION_MODE_MS_ASSISTED;\n        break;\n    default:\n        locMode = LOC_POSITION_MODE_STANDALONE;\n        break;\n    }\n\n    LocPosMode params(locMode, recurrence, min_interval,\n                      preferred_accuracy, preferred_time, NULL, NULL);\n    ret_val = loc_eng_set_position_mode(loc_afw_data, params);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_inject_time\n\nDESCRIPTION\n   This is used by Java native function to do time injection.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty)\n{\n    ENTRY_LOG();\n    int ret_val = 0;\n\n    ret_val = loc_eng_inject_time(loc_afw_data, time,\n                                  timeReference, uncertainty);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n\n/*===========================================================================\nFUNCTION    loc_inject_location\n\nDESCRIPTION\n   This is used by Java native function to do location injection.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0          : Successful\n   error code : Failure\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nstatic int loc_inject_location(double latitude, double longitude, float accuracy)\n{\n    ENTRY_LOG();\n\n    int ret_val = 0;\n    ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n\n/*===========================================================================\nFUNCTION    loc_delete_aiding_data\n\nDESCRIPTION\n   This is used by Java native function to delete the aiding data. The function\n   updates the global variable for the aiding data to be deleted. If the GPS\n   engine is off, the aiding data will be deleted. Otherwise, the actual action\n   will happen when gps engine is turned off.\n\nDEPENDENCIES\n   Assumes the aiding data type specified in GpsAidingData matches with\n   LOC API specification.\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_delete_aiding_data(GpsAidingData f)\n{\n    ENTRY_LOG();\n    loc_eng_delete_aiding_data(loc_afw_data, f);\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\nconst GpsGeofencingInterface* get_geofence_interface(void)\n{\n    ENTRY_LOG();\n    void *handle;\n    const char *error;\n    typedef const GpsGeofencingInterface* (*get_gps_geofence_interface_function) (void);\n    get_gps_geofence_interface_function get_gps_geofence_interface;\n    static const GpsGeofencingInterface* geofence_interface = NULL;\n\n    dlerror();    /* Clear any existing error */\n\n    handle = dlopen (\"libgeofence.so\", RTLD_NOW);\n\n    if (!handle)\n    {\n        if ((error = dlerror()) != NULL)  {\n            LOC_LOGE (\"%s, dlopen for libgeofence.so failed, error = %s\\n\", __func__, error);\n           }\n        goto exit;\n    }\n    dlerror();    /* Clear any existing error */\n    get_gps_geofence_interface = (get_gps_geofence_interface_function)dlsym(handle, \"gps_geofence_get_interface\");\n    if ((error = dlerror()) != NULL || NULL == get_gps_geofence_interface)  {\n        LOC_LOGE (\"%s, dlsym for get_gps_geofence_interface failed, error = %s\\n\", __func__, error);\n        goto exit;\n     }\n\n    geofence_interface = get_gps_geofence_interface();\n\nexit:\n    EXIT_LOG(%d, geofence_interface == NULL);\n    return geofence_interface;\n}\n/*===========================================================================\nFUNCTION    loc_get_extension\n\nDESCRIPTION\n   Get the gps extension to support XTRA.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   The GPS extension interface.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nconst void* loc_get_extension(const char* name)\n{\n    ENTRY_LOG();\n    const void* ret_val = NULL;\n\n   LOC_LOGD(\"%s:%d] For Interface = %s\\n\",__func__, __LINE__, name);\n   if (strcmp(name, GPS_XTRA_INTERFACE) == 0)\n   {\n       ret_val = &sLocEngXTRAInterface;\n   }\n   else if (strcmp(name, AGPS_INTERFACE) == 0)\n   {\n       ret_val = &sLocEngAGpsInterface;\n   }\n   else if (strcmp(name, GPS_NI_INTERFACE) == 0)\n   {\n       ret_val = &sLocEngNiInterface;\n   }\n   else if (strcmp(name, AGPS_RIL_INTERFACE) == 0)\n   {\n       char baseband[PROPERTY_VALUE_MAX];\n       property_get(\"ro.baseband\", baseband, \"msm\");\n       if (strcmp(baseband, \"csfb\") == 0)\n       {\n           ret_val = &sLocEngAGpsRilInterface;\n       }\n   }\n   else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0)\n   {\n       if ((gps_conf.CAPABILITIES | GPS_CAPABILITY_GEOFENCING) == gps_conf.CAPABILITIES ){\n           ret_val = get_geofence_interface();\n       }\n   }\n   else if (strcmp(name, SUPL_CERTIFICATE_INTERFACE) == 0)\n   {\n       ret_val = &sLocEngAGpsCertInterface;\n   }\n   else if (strcmp(name, GNSS_CONFIGURATION_INTERFACE) == 0)\n   {\n       ret_val = &sLocEngConfigInterface;\n   }\n   else if (strcmp(name, GPS_MEASUREMENT_INTERFACE) == 0)\n   {\n       ret_val = &sLocEngGpsMeasurementInterface;\n   }\n   else\n   {\n      LOC_LOGE (\"get_extension: Invalid interface passed in\\n\");\n   }\n    EXIT_LOG(%p, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_agps_init\n\nDESCRIPTION\n   Initialize the AGps interface.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_agps_init(AGpsCallbacks* callbacks)\n{\n    ENTRY_LOG();\n    loc_eng_agps_init(loc_afw_data, (AGpsExtCallbacks*)callbacks);\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\nFUNCTION    loc_agps_open\n\nDESCRIPTION\n   This function is called when on-demand data connection opening is successful.\nIt should inform ARM 9 about the data open result.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_agps_open(const char* apn)\n{\n    ENTRY_LOG();\n    AGpsType agpsType = AGPS_TYPE_SUPL;\n    AGpsBearerType bearerType = AGPS_APN_BEARER_IPV4;\n    int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_agps_open_with_apniptype\n\nDESCRIPTION\n   This function is called when on-demand data connection opening is successful.\nIt should inform ARM 9 about the data open result.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int  loc_agps_open_with_apniptype(const char* apn, ApnIpType apnIpType)\n{\n    ENTRY_LOG();\n    AGpsType agpsType = AGPS_TYPE_SUPL;\n    AGpsBearerType bearerType;\n\n    switch (apnIpType) {\n        case APN_IP_IPV4:\n            bearerType = AGPS_APN_BEARER_IPV4;\n            break;\n        case APN_IP_IPV6:\n            bearerType = AGPS_APN_BEARER_IPV6;\n            break;\n        case APN_IP_IPV4V6:\n            bearerType = AGPS_APN_BEARER_IPV4V6;\n            break;\n        default:\n            bearerType = AGPS_APN_BEARER_INVALID;\n            break;\n    }\n\n    int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_agps_closed\n\nDESCRIPTION\n   This function is called when on-demand data connection closing is done.\nIt should inform ARM 9 about the data close result.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_agps_closed()\n{\n    ENTRY_LOG();\n    AGpsType agpsType = AGPS_TYPE_SUPL;\n    int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_agps_open_failed\n\nDESCRIPTION\n   This function is called when on-demand data connection opening has failed.\nIt should inform ARM 9 about the data open result.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_agps_open_failed()\n{\n    ENTRY_LOG();\n    AGpsType agpsType = AGPS_TYPE_SUPL;\n    int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_agps_set_server\n\nDESCRIPTION\n   If loc_eng_set_server is called before loc_eng_init, it doesn't work. This\n   proxy buffers server settings and calls loc_eng_set_server when the client is\n   open.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_agps_set_server(AGpsType type, const char* hostname, int port)\n{\n    ENTRY_LOG();\n    LocServerType serverType;\n    switch (type) {\n    case AGPS_TYPE_SUPL:\n        serverType = LOC_AGPS_SUPL_SERVER;\n        break;\n    case AGPS_TYPE_C2K:\n        serverType = LOC_AGPS_CDMA_PDE_SERVER;\n        break;\n    default:\n        serverType = LOC_AGPS_SUPL_SERVER;\n    }\n    int ret_val = loc_eng_set_server_proxy(loc_afw_data, serverType, hostname, port);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTIONf571\n    loc_xtra_init\n\nDESCRIPTION\n   Initialize XTRA module.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_xtra_init(GpsXtraCallbacks* callbacks)\n{\n    ENTRY_LOG();\n    GpsXtraExtCallbacks extCallbacks;\n    memset(&extCallbacks, 0, sizeof(extCallbacks));\n    extCallbacks.download_request_cb = callbacks->download_request_cb;\n    int ret_val = loc_eng_xtra_init(loc_afw_data, &extCallbacks);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n\n/*===========================================================================\nFUNCTION    loc_xtra_inject_data\n\nDESCRIPTION\n   Initialize XTRA module.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_xtra_inject_data(char* data, int length)\n{\n    ENTRY_LOG();\n    int ret_val = -1;\n    if( (data != NULL) && ((unsigned int)length <= XTRA_DATA_MAX_SIZE))\n        ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length);\n    else\n        LOC_LOGE(\"%s, Could not inject XTRA data. Buffer address: %p, length: %d\",\n                 __func__, data, length);\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_gps_measurement_init\n\nDESCRIPTION\n   This function initializes the gps measurement interface\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks)\n{\n    ENTRY_LOG();\n    int ret_val = loc_eng_gps_measurement_init(loc_afw_data,\n                                               callbacks);\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_gps_measurement_close\n\nDESCRIPTION\n   This function closes the gps measurement interface\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_gps_measurement_close()\n{\n    ENTRY_LOG();\n    loc_eng_gps_measurement_close(loc_afw_data);\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\nFUNCTION    loc_ni_init\n\nDESCRIPTION\n   This function initializes the NI interface\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_ni_init(GpsNiCallbacks *callbacks)\n{\n    ENTRY_LOG();\n    loc_eng_ni_init(loc_afw_data,(GpsNiExtCallbacks*) callbacks);\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\nFUNCTION    loc_ni_respond\n\nDESCRIPTION\n   This function sends an NI respond to the modem processor\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_ni_respond(int notif_id, GpsUserResponseType user_response)\n{\n    ENTRY_LOG();\n    loc_eng_ni_respond(loc_afw_data, notif_id, user_response);\n    EXIT_LOG(%s, VOID_RET);\n}\n\n// Below stub functions are members of sLocEngAGpsRilInterface\nstatic void loc_agps_ril_init( AGpsRilCallbacks* callbacks ) {}\nstatic void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) {}\nstatic void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid) {}\nstatic void loc_agps_ril_ni_message(uint8_t *msg, size_t len) {}\nstatic void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info) {}\n\n/*===========================================================================\nFUNCTION    loc_agps_ril_update_network_availability\n\nDESCRIPTION\n   Sets data call allow vs disallow flag to modem\n   This is the only member of sLocEngAGpsRilInterface implemented.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_agps_ril_update_network_availability(int available, const char* apn)\n{\n    ENTRY_LOG();\n    loc_eng_agps_ril_update_network_availability(loc_afw_data, available, apn);\n    EXIT_LOG(%s, VOID_RET);\n}\n\nstatic int loc_agps_install_certificates(const DerEncodedCertificate* certificates,\n                                         size_t length)\n{\n    ENTRY_LOG();\n    int ret_val = loc_eng_agps_install_certificates(loc_afw_data, certificates, length);\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\nstatic int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints,\n                                        size_t length)\n{\n    ENTRY_LOG();\n    LOC_LOGE(\"%s:%d]: agps_revoke_certificates not supported\");\n    int ret_val = AGPS_CERTIFICATE_ERROR_GENERIC;\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\nstatic void loc_configuration_update(const char* config_data, int32_t length)\n{\n    ENTRY_LOG();\n    loc_eng_configuration_update(loc_afw_data, config_data, length);\n    switch (sGnssType)\n    {\n    case GNSS_GSS:\n    case GNSS_AUTO:\n    case GNSS_QCA1530:\n        //APQ\n        gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);\n        break;\n    }\n    EXIT_LOG(%s, VOID_RET);\n}\n\nstatic void local_loc_cb(UlpLocation* location, void* locExt)\n{\n    ENTRY_LOG();\n    if (NULL != location) {\n        CALLBACK_LOG_CALLFLOW(\"location_cb - from\", %d, location->position_source);\n\n        if (NULL != gps_loc_cb) {\n            gps_loc_cb(&location->gpsLocation);\n        }\n    }\n    EXIT_LOG(%s, VOID_RET);\n}\n\nstatic void local_sv_cb(GpsSvStatus* sv_status, void* svExt)\n{\n    ENTRY_LOG();\n    if (NULL != gps_sv_cb) {\n        CALLBACK_LOG_CALLFLOW(\"sv_status_cb -\", %d, sv_status->num_svs);\n        gps_sv_cb(sv_status);\n    }\n    EXIT_LOG(%s, VOID_RET);\n}\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc.h",
    "content": "/* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef __LOC_H__\n#define __LOC_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#include <ctype.h>\n#include <cutils/properties.h>\n#include <hardware/gps.h>\n#include <gps_extended.h>\n\n#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/\n\ntypedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt);\ntypedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt);\ntypedef void* (*loc_ext_parser)(void* data);\n\ntypedef struct {\n    loc_location_cb_ext location_cb;\n    gps_status_callback status_cb;\n    loc_sv_status_cb_ext sv_status_cb;\n    gps_nmea_callback nmea_cb;\n    gps_set_capabilities set_capabilities_cb;\n    gps_acquire_wakelock acquire_wakelock_cb;\n    gps_release_wakelock release_wakelock_cb;\n    gps_create_thread create_thread_cb;\n    loc_ext_parser location_ext_parser;\n    loc_ext_parser sv_ext_parser;\n    gps_request_utc_time request_utc_time_cb;\n} LocCallbacks;\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif //__LOC_H__\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng.cpp",
    "content": "/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_eng\"\n\n#include <stdint.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <unistd.h>\n#include <dlfcn.h>\n#include <ctype.h>\n#include <math.h>\n#include <pthread.h>\n#include <arpa/inet.h>\n#include <netinet/in.h>         /* struct sockaddr_in */\n#include <sys/socket.h>\n#include <sys/time.h>\n#include <netdb.h>\n#include <time.h>\n#include <new>\n#include <LocEngAdapter.h>\n\n#include <cutils/sched_policy.h>\n#ifndef USE_GLIB\n#include <utils/SystemClock.h>\n#include <utils/Log.h>\n#endif /* USE_GLIB */\n\n#ifdef USE_GLIB\n#include <glib.h>\n#include <sys/syscall.h>\n#endif /* USE_GLIB */\n\n#include <string.h>\n\n#include <loc_eng.h>\n#include <loc_eng_ni.h>\n#include <loc_eng_dmn_conn.h>\n#include <loc_eng_dmn_conn_handler.h>\n#include <loc_eng_msg.h>\n#include <loc_eng_nmea.h>\n#include <msg_q.h>\n#include <loc.h>\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n#include \"loc_core_log.h\"\n#include \"loc_eng_log.h\"\n\n#define SUCCESS TRUE\n#define FAILURE FALSE\n\n#ifndef GPS_CONF_FILE\n#define GPS_CONF_FILE            \"/etc/gps.conf\"   //??? platform independent\n#endif\n\n#ifndef SAP_CONF_FILE\n#define SAP_CONF_FILE            \"/etc/sap.conf\"\n#endif\n\n#define XTRA1_GPSONEXTRA         \"xtra1.gpsonextra.net\"\n\nusing namespace loc_core;\n\nboolean configAlreadyRead = false;\nunsigned int agpsStatus = 0;\nloc_gps_cfg_s_type gps_conf;\nloc_sap_cfg_s_type sap_conf;\n\n/* Parameter spec table */\nstatic loc_param_s_type gps_conf_table[] =\n{\n  {\"GPS_LOCK\",                       &gps_conf.GPS_LOCK,                       NULL, 'n'},\n  {\"SUPL_VER\",                       &gps_conf.SUPL_VER,                       NULL, 'n'},\n  {\"LPP_PROFILE\",                    &gps_conf.LPP_PROFILE,                    NULL, 'n'},\n  {\"A_GLONASS_POS_PROTOCOL_SELECT\",  &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT,  NULL, 'n'},\n  {\"AGPS_CERT_WRITABLE_MASK\",        &gps_conf.AGPS_CERT_WRITABLE_MASK,        NULL, 'n'},\n  {\"SUPL_MODE\",                      &gps_conf.SUPL_MODE,                      NULL, 'n'},\n  {\"INTERMEDIATE_POS\",               &gps_conf.INTERMEDIATE_POS,               NULL, 'n'},\n  {\"ACCURACY_THRES\",                 &gps_conf.ACCURACY_THRES,                 NULL, 'n'},\n  {\"NMEA_PROVIDER\",                  &gps_conf.NMEA_PROVIDER,                  NULL, 'n'},\n  {\"CAPABILITIES\",                   &gps_conf.CAPABILITIES,                   NULL, 'n'},\n  {\"XTRA_VERSION_CHECK\",             &gps_conf.XTRA_VERSION_CHECK,             NULL, 'n'},\n  {\"XTRA_SERVER_1\",                  &gps_conf.XTRA_SERVER_1,                  NULL, 's'},\n  {\"XTRA_SERVER_2\",                  &gps_conf.XTRA_SERVER_2,                  NULL, 's'},\n  {\"XTRA_SERVER_3\",                  &gps_conf.XTRA_SERVER_3,                  NULL, 's'},\n  {\"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL\",  &gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL,          NULL, 'n'},\n};\n\nstatic loc_param_s_type sap_conf_table[] =\n{\n  {\"GYRO_BIAS_RANDOM_WALK\",          &sap_conf.GYRO_BIAS_RANDOM_WALK,          &sap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},\n  {\"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY\",     &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY,    &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},\n  {\"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY\",     &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY,    &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},\n  {\"RATE_RANDOM_WALK_SPECTRAL_DENSITY\",      &sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY,     &sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},\n  {\"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY\",  &sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},\n  {\"SENSOR_ACCEL_BATCHES_PER_SEC\",   &sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC,   NULL, 'n'},\n  {\"SENSOR_ACCEL_SAMPLES_PER_BATCH\", &sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'},\n  {\"SENSOR_GYRO_BATCHES_PER_SEC\",    &sap_conf.SENSOR_GYRO_BATCHES_PER_SEC,    NULL, 'n'},\n  {\"SENSOR_GYRO_SAMPLES_PER_BATCH\",  &sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH,  NULL, 'n'},\n  {\"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH\",   &sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH,   NULL, 'n'},\n  {\"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH\", &sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},\n  {\"SENSOR_GYRO_BATCHES_PER_SEC_HIGH\",    &sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH,    NULL, 'n'},\n  {\"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH\",  &sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH,  NULL, 'n'},\n  {\"SENSOR_CONTROL_MODE\",            &sap_conf.SENSOR_CONTROL_MODE,            NULL, 'n'},\n  {\"SENSOR_USAGE\",                   &sap_conf.SENSOR_USAGE,                   NULL, 'n'},\n  {\"SENSOR_ALGORITHM_CONFIG_MASK\",   &sap_conf.SENSOR_ALGORITHM_CONFIG_MASK,   NULL, 'n'},\n  {\"SENSOR_PROVIDER\",                &sap_conf.SENSOR_PROVIDER,                NULL, 'n'}\n};\n\nstatic void loc_default_parameters(void)\n{\n   /*Defaults for gps.conf*/\n   gps_conf.INTERMEDIATE_POS = 0;\n   gps_conf.ACCURACY_THRES = 0;\n   gps_conf.NMEA_PROVIDER = 0;\n   gps_conf.GPS_LOCK = 0;\n   gps_conf.SUPL_VER = 0x10000;\n   gps_conf.SUPL_MODE = 0x3;\n   gps_conf.CAPABILITIES = 0x7;\n   /* LTE Positioning Profile configuration is disable by default*/\n   gps_conf.LPP_PROFILE = 0;\n   /*By default no positioning protocol is selected on A-GLONASS system*/\n   gps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;\n   /*XTRA version check is disabled by default*/\n   gps_conf.XTRA_VERSION_CHECK=0;\n   /*Use emergency PDN by default*/\n   gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1;\n\n   /*Defaults for sap.conf*/\n   sap_conf.GYRO_BIAS_RANDOM_WALK = 0;\n   sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2;\n   sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5;\n   sap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2;\n   sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5;\n   sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4;\n   sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25;\n   sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4;\n   sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25;\n   sap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */\n   sap_conf.SENSOR_USAGE = 0; /* Enabled */\n   sap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/\n   /* Values MUST be set by OEMs in configuration for sensor-assisted\n      navigation to work. There are NO default values */\n   sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0;\n   sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0;\n   sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0;\n   sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0;\n   sap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0;\n   sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;\n   sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;\n   sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;\n   sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;\n   /* default provider is SSC */\n   sap_conf.SENSOR_PROVIDER = 1;\n\n   /* None of the 10 slots for agps certificates are writable by default */\n   gps_conf.AGPS_CERT_WRITABLE_MASK = 0;\n}\n\n// 2nd half of init(), singled out for\n// modem restart to use.\nstatic int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data);\nstatic void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data);\n\nstatic int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data,\n                              LocServerType type, const char *hostname, int port);\n// Internal functions\nstatic void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data,\n                                  GpsStatusValue status);\nstatic void loc_eng_report_status(loc_eng_data_s_type &loc_eng_data,\n                                  GpsStatusValue status);\nstatic void loc_eng_process_conn_request(loc_eng_data_s_type &loc_eng_data,\n                                         int connHandle, AGpsType agps_type);\nstatic void loc_eng_agps_close_status(loc_eng_data_s_type &loc_eng_data, int is_succ);\nstatic void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) ;\nstatic void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) ;\n\nstatic int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data);\nstatic int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data);\nstatic int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data);\nstatic void deleteAidingData(loc_eng_data_s_type &logEng);\nstatic AgpsStateMachine*\ngetAgpsStateMachine(loc_eng_data_s_type& logEng, AGpsExtType agpsType);\nstatic int dataCallCb(void *cb_data);\nstatic void update_aiding_data_for_deletion(loc_eng_data_s_type& loc_eng_data) {\n    if (loc_eng_data.engine_status != GPS_STATUS_ENGINE_ON &&\n        loc_eng_data.aiding_data_for_deletion != 0)\n    {\n        loc_eng_data.adapter->deleteAidingData(loc_eng_data.aiding_data_for_deletion);\n        loc_eng_data.aiding_data_for_deletion = 0;\n    }\n}\n\nstatic void* noProc(void* data)\n{\n    return NULL;\n}\n\n/*********************************************************************\n * definitions of the static messages used in the file\n *********************************************************************/\n//        case LOC_ENG_MSG_REQUEST_NI:\nLocEngRequestNi::LocEngRequestNi(void* locEng,\n                                 GpsNiNotification &notif,\n                                 const void* data) :\n    LocMsg(), mLocEng(locEng), mNotify(notif), mPayload(data) {\n    locallog();\n}\nvoid LocEngRequestNi::proc() const {\n    loc_eng_ni_request_handler(*((loc_eng_data_s_type*)mLocEng),\n                               &mNotify, mPayload);\n}\nvoid LocEngRequestNi::locallog() const\n{\n    LOC_LOGV(\"id: %d\\n  type: %s\\n  flags: %d\\n  time out: %d\\n  \"\n             \"default response: %s\\n  requestor id encoding: %s\\n\"\n             \"  text encoding: %s\\n  passThroughData: %p\",\n             mNotify.notification_id,\n             loc_get_ni_type_name(mNotify.ni_type),\n             mNotify.notify_flags,\n             mNotify.timeout,\n             loc_get_ni_response_name(mNotify.default_response),\n             loc_get_ni_encoding_name(mNotify.requestor_id_encoding),\n             loc_get_ni_encoding_name(mNotify.text_encoding),\n             mPayload);\n}\ninline void LocEngRequestNi::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_INFORM_NI_RESPONSE:\n// in loc_eng_ni.cpp\n\n//        case LOC_ENG_MSG_START_FIX:\nLocEngStartFix::LocEngStartFix(LocEngAdapter* adapter) :\n    LocMsg(), mAdapter(adapter)\n{\n    locallog();\n}\ninline void LocEngStartFix::proc() const\n{\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner();\n    loc_eng_start_handler(*locEng);\n}\ninline void LocEngStartFix::locallog() const\n{\n    LOC_LOGV(\"LocEngStartFix\");\n}\ninline void LocEngStartFix::log() const\n{\n    locallog();\n}\nvoid LocEngStartFix::send() const {\n    mAdapter->sendMsg(this);\n}\n\n//        case LOC_ENG_MSG_STOP_FIX:\nLocEngStopFix::LocEngStopFix(LocEngAdapter* adapter) :\n    LocMsg(), mAdapter(adapter)\n{\n    locallog();\n}\ninline void LocEngStopFix::proc() const\n{\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner();\n    loc_eng_stop_handler(*locEng);\n}\ninline void LocEngStopFix::locallog() const\n{\n    LOC_LOGV(\"LocEngStopFix\");\n}\ninline void LocEngStopFix::log() const\n{\n    locallog();\n}\nvoid LocEngStopFix::send() const {\n    mAdapter->sendMsg(this);\n}\n\n//        case LOC_ENG_MSG_SET_POSITION_MODE:\nLocEngPositionMode::LocEngPositionMode(LocEngAdapter* adapter,\n                                       LocPosMode &mode) :\n    LocMsg(), mAdapter(adapter), mPosMode(mode)\n{\n    mPosMode.logv();\n}\ninline void LocEngPositionMode::proc() const {\n    mAdapter->setPositionMode(&mPosMode);\n}\ninline void LocEngPositionMode::log() const {\n    mPosMode.logv();\n}\nvoid LocEngPositionMode::send() const {\n    mAdapter->sendMsg(this);\n}\n\nLocEngGetZpp::LocEngGetZpp(LocEngAdapter* adapter) :\n    LocMsg(), mAdapter(adapter)\n{\n    locallog();\n}\ninline void LocEngGetZpp::proc() const\n{\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mAdapter->getOwner();\n    loc_eng_get_zpp_handler(*locEng);\n}\ninline void LocEngGetZpp::locallog() const\n{\n    LOC_LOGV(\"LocEngGetZpp\");\n}\ninline void LocEngGetZpp::log() const\n{\n    locallog();\n}\nvoid LocEngGetZpp::send() const {\n    mAdapter->sendMsg(this);\n}\n\nstruct LocEngSetTime : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const GpsUtcTime mTime;\n    const int64_t mTimeReference;\n    const int mUncertainty;\n    inline LocEngSetTime(LocEngAdapter* adapter,\n                         GpsUtcTime t, int64_t tf, int unc) :\n        LocMsg(), mAdapter(adapter),\n        mTime(t), mTimeReference(tf), mUncertainty(unc)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setTime(mTime, mTimeReference, mUncertainty);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"time: %lld\\n  timeReference: %lld\\n  uncertainty: %d\",\n                 mTime, mTimeReference, mUncertainty);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n //       case LOC_ENG_MSG_INJECT_LOCATION:\nstruct LocEngInjectLocation : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const double mLatitude;\n    const double mLongitude;\n    const float mAccuracy;\n    inline LocEngInjectLocation(LocEngAdapter* adapter,\n                                double lat, double lon, float accur) :\n        LocMsg(), mAdapter(adapter),\n        mLatitude(lat), mLongitude(lon), mAccuracy(accur)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->injectPosition(mLatitude, mLongitude, mAccuracy);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"latitude: %f\\n  longitude: %f\\n  accuracy: %f\",\n                 mLatitude, mLongitude, mAccuracy);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_SET_SERVER_IPV4:\nstruct LocEngSetServerIpv4 : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const unsigned int mNlAddr;\n    const int mPort;\n    const LocServerType mServerType;\n    inline LocEngSetServerIpv4(LocEngAdapter* adapter,\n                               unsigned int ip,\n                               int port,\n                               LocServerType type) :\n        LocMsg(), mAdapter(adapter),\n        mNlAddr(ip), mPort(port), mServerType(type)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setServer(mNlAddr, mPort, mServerType);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngSetServerIpv4 - addr: %x, port: %d, type: %s\",\n                 mNlAddr, mPort, loc_get_server_type_name(mServerType));\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_SET_SERVER_URL:\nstruct LocEngSetServerUrl : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const int mLen;\n    char* mUrl;\n    inline LocEngSetServerUrl(LocEngAdapter* adapter,\n                              char* urlString,\n                              int url_len) :\n        LocMsg(), mAdapter(adapter),\n        mLen(url_len), mUrl(new char[mLen+1])\n    {\n        memcpy((void*)mUrl, (void*)urlString, url_len);\n        mUrl[mLen] = 0;\n        locallog();\n    }\n    inline ~LocEngSetServerUrl()\n    {\n        delete[] mUrl;\n    }\n    inline virtual void proc() const {\n        mAdapter->setServer(mUrl, mLen);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngSetServerUrl - url: %s\", mUrl);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_A_GLONASS_PROTOCOL:\nstruct LocEngAGlonassProtocol : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const unsigned long mAGlonassProtocl;\n    inline LocEngAGlonassProtocol(LocEngAdapter* adapter,\n                                  unsigned long protocol) :\n        LocMsg(), mAdapter(adapter), mAGlonassProtocl(protocol)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setAGLONASSProtocol(mAGlonassProtocl);\n    }\n    inline  void locallog() const {\n        LOC_LOGV(\"A-GLONASS protocol: 0x%lx\", mAGlonassProtocl);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_SUPL_VERSION:\nstruct LocEngSuplVer : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const int mSuplVer;\n    inline LocEngSuplVer(LocEngAdapter* adapter,\n                         int suplVer) :\n        LocMsg(), mAdapter(adapter), mSuplVer(suplVer)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setSUPLVersion(mSuplVer);\n    }\n    inline  void locallog() const {\n        LOC_LOGV(\"SUPL Version: %d\", mSuplVer);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\nstruct LocEngSuplMode : public LocMsg {\n    UlpProxyBase* mUlp;\n\n    inline LocEngSuplMode(UlpProxyBase* ulp) :\n        LocMsg(), mUlp(ulp)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mUlp->setCapabilities(getCarrierCapabilities());\n    }\n    inline  void locallog() const {\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_LPP_CONFIG:\nstruct LocEngLppConfig : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const int mLppConfig;\n    inline LocEngLppConfig(LocEngAdapter* adapter,\n                           int lppConfig) :\n        LocMsg(), mAdapter(adapter), mLppConfig(lppConfig)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setLPPConfig(mLppConfig);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngLppConfig - profile: %d\", mLppConfig);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG:\nstruct LocEngSensorControlConfig : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const int mSensorsDisabled;\n    const int mSensorProvider;\n    inline LocEngSensorControlConfig(LocEngAdapter* adapter,\n                                     int sensorsDisabled, int sensorProvider) :\n        LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled),\n        mSensorProvider(sensorProvider)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setSensorControlConfig(mSensorsDisabled, mSensorProvider);\n    }\n    inline  void locallog() const {\n        LOC_LOGV(\"LocEngSensorControlConfig - Sensors Disabled: %d, Sensor Provider: %d\",\n                 mSensorsDisabled, mSensorProvider);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_SET_SENSOR_PROPERTIES:\nstruct LocEngSensorProperties : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const bool mGyroBiasVarianceRandomWalkValid;\n    const float mGyroBiasVarianceRandomWalk;\n    const bool mAccelRandomWalkValid;\n    const float mAccelRandomWalk;\n    const bool mAngleRandomWalkValid;\n    const float mAngleRandomWalk;\n    const bool mRateRandomWalkValid;\n    const float mRateRandomWalk;\n    const bool mVelocityRandomWalkValid;\n    const float mVelocityRandomWalk;\n    inline LocEngSensorProperties(LocEngAdapter* adapter,\n                                  bool gyroBiasRandomWalk_valid,\n                                  float gyroBiasRandomWalk,\n                                  bool accelRandomWalk_valid,\n                                  float accelRandomWalk,\n                                  bool angleRandomWalk_valid,\n                                  float angleRandomWalk,\n                                  bool rateRandomWalk_valid,\n                                  float rateRandomWalk,\n                                  bool velocityRandomWalk_valid,\n                                  float velocityRandomWalk) :\n        LocMsg(), mAdapter(adapter),\n        mGyroBiasVarianceRandomWalkValid(gyroBiasRandomWalk_valid),\n        mGyroBiasVarianceRandomWalk(gyroBiasRandomWalk),\n        mAccelRandomWalkValid(accelRandomWalk_valid),\n        mAccelRandomWalk(accelRandomWalk),\n        mAngleRandomWalkValid(angleRandomWalk_valid),\n        mAngleRandomWalk(angleRandomWalk),\n        mRateRandomWalkValid(rateRandomWalk_valid),\n        mRateRandomWalk(rateRandomWalk),\n        mVelocityRandomWalkValid(velocityRandomWalk_valid),\n        mVelocityRandomWalk(velocityRandomWalk)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setSensorProperties(mGyroBiasVarianceRandomWalkValid,\n                                      mGyroBiasVarianceRandomWalk,\n                                      mAccelRandomWalkValid,\n                                      mAccelRandomWalk,\n                                      mAngleRandomWalkValid,\n                                      mAngleRandomWalk,\n                                      mRateRandomWalkValid,\n                                      mRateRandomWalk,\n                                      mVelocityRandomWalkValid,\n                                      mVelocityRandomWalk);\n    }\n    inline  void locallog() const {\n        LOC_LOGV(\"Sensor properties validity, Gyro Random walk: %d \"\n                 \"Accel Random Walk: %d \"\n                 \"Angle Random Walk: %d Rate Random Walk: %d \"\n                 \"Velocity Random Walk: %d\\n\"\n                 \"Sensor properties, Gyro Random walk: %f \"\n                 \"Accel Random Walk: %f \"\n                 \"Angle Random Walk: %f Rate Random Walk: %f \"\n                 \"Velocity Random Walk: %f\",\n                 mGyroBiasVarianceRandomWalkValid,\n                 mAccelRandomWalkValid,\n                 mAngleRandomWalkValid,\n                 mRateRandomWalkValid,\n                 mVelocityRandomWalkValid,\n                 mGyroBiasVarianceRandomWalk,\n                 mAccelRandomWalk,\n                 mAngleRandomWalk,\n                 mRateRandomWalk,\n                 mVelocityRandomWalk\n            );\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG:\nstruct LocEngSensorPerfControlConfig : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const int mControlMode;\n    const int mAccelSamplesPerBatch;\n    const int mAccelBatchesPerSec;\n    const int mGyroSamplesPerBatch;\n    const int mGyroBatchesPerSec;\n    const int mAccelSamplesPerBatchHigh;\n    const int mAccelBatchesPerSecHigh;\n    const int mGyroSamplesPerBatchHigh;\n    const int mGyroBatchesPerSecHigh;\n    const int mAlgorithmConfig;\n    inline LocEngSensorPerfControlConfig(LocEngAdapter* adapter,\n                                         int controlMode,\n                                         int accelSamplesPerBatch,\n                                         int accelBatchesPerSec,\n                                         int gyroSamplesPerBatch,\n                                         int gyroBatchesPerSec,\n                                         int accelSamplesPerBatchHigh,\n                                         int accelBatchesPerSecHigh,\n                                         int gyroSamplesPerBatchHigh,\n                                         int gyroBatchesPerSecHigh,\n                                         int algorithmConfig) :\n        LocMsg(), mAdapter(adapter),\n        mControlMode(controlMode),\n        mAccelSamplesPerBatch(accelSamplesPerBatch),\n        mAccelBatchesPerSec(accelBatchesPerSec),\n        mGyroSamplesPerBatch(gyroSamplesPerBatch),\n        mGyroBatchesPerSec(gyroBatchesPerSec),\n        mAccelSamplesPerBatchHigh(accelSamplesPerBatchHigh),\n        mAccelBatchesPerSecHigh(accelBatchesPerSecHigh),\n        mGyroSamplesPerBatchHigh(gyroSamplesPerBatchHigh),\n        mGyroBatchesPerSecHigh(gyroBatchesPerSecHigh),\n        mAlgorithmConfig(algorithmConfig)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setSensorPerfControlConfig(mControlMode,\n                                             mAccelSamplesPerBatch,\n                                             mAccelBatchesPerSec,\n                                             mGyroSamplesPerBatch,\n                                             mGyroBatchesPerSec,\n                                             mAccelSamplesPerBatchHigh,\n                                             mAccelBatchesPerSecHigh,\n                                             mGyroSamplesPerBatchHigh,\n                                             mGyroBatchesPerSecHigh,\n                                             mAlgorithmConfig);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"Sensor Perf Control Config (performanceControlMode)(%u) \"\n                 \"accel(#smp,#batches) (%u,%u) \"\n                 \"gyro(#smp,#batches) (%u,%u), \"\n                 \"accel_high(#smp,#batches) (%u,%u) \"\n                 \"gyro_high(#smp,#batches) (%u,%u), \"\n                 \"algorithmConfig(%u)\\n\",\n                 mControlMode,\n                 mAccelSamplesPerBatch, mAccelBatchesPerSec,\n                 mGyroSamplesPerBatch, mGyroBatchesPerSec,\n                 mAccelSamplesPerBatchHigh, mAccelBatchesPerSecHigh,\n                 mGyroSamplesPerBatchHigh, mGyroBatchesPerSecHigh,\n                 mAlgorithmConfig);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_EXT_POWER_CONFIG:\nstruct LocEngExtPowerConfig : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const int mIsBatteryCharging;\n    inline LocEngExtPowerConfig(LocEngAdapter* adapter,\n                                int isBatteryCharging) :\n        LocMsg(), mAdapter(adapter),\n        mIsBatteryCharging(isBatteryCharging)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->setExtPowerConfig(mIsBatteryCharging);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngExtPowerConfig - isBatteryCharging: %d\",\n                 mIsBatteryCharging);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_REPORT_POSITION:\nLocEngReportPosition::LocEngReportPosition(LocAdapterBase* adapter,\n                                           UlpLocation &loc,\n                                           GpsLocationExtended &locExtended,\n                                           void* locExt,\n                                           enum loc_sess_status st,\n                                           LocPosTechMask technology) :\n    LocMsg(), mAdapter(adapter), mLocation(loc),\n    mLocationExtended(locExtended),\n    mLocationExt(((loc_eng_data_s_type*)\n                  ((LocEngAdapter*)\n                   (mAdapter))->getOwner())->location_ext_parser(locExt)),\n    mStatus(st), mTechMask(technology)\n{\n    locallog();\n}\nvoid LocEngReportPosition::proc() const {\n    LocEngAdapter* adapter = (LocEngAdapter*)mAdapter;\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner();\n\n    if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION) {\n        bool reported = false;\n        if (locEng->location_cb != NULL) {\n            if (LOC_SESS_FAILURE == mStatus) {\n                // in case we want to handle the failure case\n                locEng->location_cb(NULL, NULL);\n                reported = true;\n            }\n            // what's in the else if is... (line by line)\n            // 1. this is a final fix; and\n            //   1.1 it is a Satellite fix; or\n            //   1.2 it is a sensor fix\n            // 2. (must be intermediate fix... implicit)\n            //   2.1 we accepte intermediate; and\n            //   2.2 it is NOT the case that\n            //   2.2.1 there is inaccuracy; and\n            //   2.2.2 we care about inaccuracy; and\n            //   2.2.3 the inaccuracy exceeds our tolerance\n            else if ((LOC_SESS_SUCCESS == mStatus &&\n                      ((LOC_POS_TECH_MASK_SATELLITE |\n                        LOC_POS_TECH_MASK_SENSORS   |\n                        LOC_POS_TECH_MASK_HYBRID) &\n                       mTechMask)) ||\n                     (LOC_SESS_INTERMEDIATE == locEng->intermediateFix &&\n                      !((mLocation.gpsLocation.flags &\n                         GPS_LOCATION_HAS_ACCURACY) &&\n                        (gps_conf.ACCURACY_THRES != 0) &&\n                        (mLocation.gpsLocation.accuracy >\n                         gps_conf.ACCURACY_THRES)))) {\n                locEng->location_cb((UlpLocation*)&(mLocation),\n                                    (void*)mLocationExt);\n                reported = true;\n            }\n        }\n\n        // if we have reported this fix\n        if (reported &&\n            // and if this is a singleshot\n            GPS_POSITION_RECURRENCE_SINGLE ==\n            locEng->adapter->getPositionMode().recurrence) {\n            if (LOC_SESS_INTERMEDIATE == mStatus) {\n                // modem could be still working for a final fix,\n                // although we no longer need it.  So stopFix().\n                locEng->adapter->stopFix();\n            }\n            // turn off the session flag.\n            locEng->adapter->setInSession(false);\n        }\n\n        LOC_LOGV(\"LocEngReportPosition::proc() - generateNmea: %d, position source: %d, \"\n                 \"engine_status: %d, isInSession: %d\",\n                        locEng->generateNmea, mLocation.position_source,\n                        locEng->engine_status, locEng->adapter->isInSession());\n\n        if (locEng->generateNmea &&\n            locEng->adapter->isInSession())\n        {\n            unsigned char generate_nmea = reported &&\n                                          (mStatus != LOC_SESS_FAILURE);\n            loc_eng_nmea_generate_pos(locEng, mLocation, mLocationExtended,\n                                      generate_nmea);\n        }\n\n        // Free the allocated memory for rawData\n        UlpLocation* gp = (UlpLocation*)&(mLocation);\n        if (gp != NULL && gp->rawData != NULL)\n        {\n            delete (char*)gp->rawData;\n            gp->rawData = NULL;\n            gp->rawDataSize = 0;\n        }\n    }\n}\nvoid LocEngReportPosition::locallog() const {\n    LOC_LOGV(\"LocEngReportPosition\");\n}\nvoid LocEngReportPosition::log() const {\n    locallog();\n}\nvoid LocEngReportPosition::send() const {\n    mAdapter->sendMsg(this);\n}\n\n\n//        case LOC_ENG_MSG_REPORT_SV:\nLocEngReportSv::LocEngReportSv(LocAdapterBase* adapter,\n                               QcomSvStatus &sv,\n                               GpsLocationExtended &locExtended,\n                               void* svExt) :\n    LocMsg(), mAdapter(adapter), mSvStatus(sv),\n    mLocationExtended(locExtended),\n    mSvExt(((loc_eng_data_s_type*)\n            ((LocEngAdapter*)\n             (mAdapter))->getOwner())->sv_ext_parser(svExt))\n{\n    locallog();\n}\nvoid LocEngReportSv::proc() const {\n    LocEngAdapter* adapter = (LocEngAdapter*)mAdapter;\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner();\n\n    if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION)\n    {\n        if (locEng->sv_status_cb != NULL) {\n            locEng->sv_status_cb((GpsSvStatus*)&(mSvStatus),\n                                 (void*)mSvExt);\n        }\n\n        if (locEng->generateNmea)\n        {\n            loc_eng_nmea_generate_sv(locEng, mSvStatus, mLocationExtended);\n        }\n    }\n}\nvoid LocEngReportSv::locallog() const {\n    LOC_LOGV(\"%s:%d] LocEngReportSv\",__func__, __LINE__);\n}\ninline void LocEngReportSv::log() const {\n    locallog();\n}\nvoid LocEngReportSv::send() const {\n    mAdapter->sendMsg(this);\n}\n\n//        case LOC_ENG_MSG_REPORT_STATUS:\nLocEngReportStatus::LocEngReportStatus(LocAdapterBase* adapter,\n                                       GpsStatusValue engineStatus) :\n    LocMsg(),  mAdapter(adapter), mStatus(engineStatus)\n{\n    locallog();\n}\ninline void LocEngReportStatus::proc() const\n{\n    LocEngAdapter* adapter = (LocEngAdapter*)mAdapter;\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)adapter->getOwner();\n\n    loc_eng_report_status(*locEng, mStatus);\n    update_aiding_data_for_deletion(*locEng);\n}\ninline void LocEngReportStatus::locallog() const {\n    LOC_LOGV(\"LocEngReportStatus\");\n}\ninline void LocEngReportStatus::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_REPORT_NMEA:\nLocEngReportNmea::LocEngReportNmea(void* locEng,\n                                   const char* data, int len) :\n    LocMsg(), mLocEng(locEng), mNmea(new char[len]), mLen(len)\n{\n    memcpy((void*)mNmea, (void*)data, len);\n    locallog();\n}\nvoid LocEngReportNmea::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng;\n\n    struct timeval tv;\n    gettimeofday(&tv, (struct timezone *) NULL);\n    int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;\n    CALLBACK_LOG_CALLFLOW(\"nmea_cb\", %d, mLen);\n\n    if (locEng->nmea_cb != NULL)\n        locEng->nmea_cb(now, mNmea, mLen);\n}\ninline void LocEngReportNmea::locallog() const {\n    LOC_LOGV(\"LocEngReportNmea\");\n}\ninline void LocEngReportNmea::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_REPORT_XTRA_SERVER:\nLocEngReportXtraServer::LocEngReportXtraServer(void* locEng,\n                                               const char *url1,\n                                               const char *url2,\n                                               const char *url3,\n                                               const int maxlength) :\n    LocMsg(), mLocEng(locEng), mMaxLen(maxlength),\n    mServers(new char[3*(mMaxLen+1)])\n{\n    char * cptr = mServers;\n    memset(mServers, 0, 3*(mMaxLen+1));\n\n    // Override modem URLs with uncommented gps.conf urls\n    if( gps_conf.XTRA_SERVER_1[0] != '\\0' ) {\n        url1 = &gps_conf.XTRA_SERVER_1[0];\n    }\n    if( gps_conf.XTRA_SERVER_2[0] != '\\0' ) {\n        url2 = &gps_conf.XTRA_SERVER_2[0];\n    }\n    if( gps_conf.XTRA_SERVER_3[0] != '\\0' ) {\n        url3 = &gps_conf.XTRA_SERVER_3[0];\n    }\n    // copy non xtra1.gpsonextra.net URLs into the forwarding buffer.\n    if( NULL == strcasestr(url1, XTRA1_GPSONEXTRA) ) {\n        strlcpy(cptr, url1, mMaxLen + 1);\n        cptr += mMaxLen + 1;\n    }\n    if( NULL == strcasestr(url2, XTRA1_GPSONEXTRA) ) {\n        strlcpy(cptr, url2, mMaxLen + 1);\n        cptr += mMaxLen + 1;\n    }\n    if( NULL == strcasestr(url3, XTRA1_GPSONEXTRA) ) {\n        strlcpy(cptr, url3, mMaxLen + 1);\n    }\n    locallog();\n}\n\nvoid LocEngReportXtraServer::proc() const {\n    loc_eng_xtra_data_s_type* locEngXtra =\n        &(((loc_eng_data_s_type*)mLocEng)->xtra_module_data);\n\n    if (locEngXtra->report_xtra_server_cb != NULL) {\n        CALLBACK_LOG_CALLFLOW(\"report_xtra_server_cb\", %s, mServers);\n        locEngXtra->report_xtra_server_cb(mServers,\n                                          &(mServers[mMaxLen+1]),\n                                          &(mServers[(mMaxLen+1)<<1]));\n    } else {\n        LOC_LOGE(\"Callback function for request xtra is NULL\");\n    }\n}\ninline void LocEngReportXtraServer::locallog() const {\n    LOC_LOGV(\"LocEngReportXtraServers: server1: %s\\n  server2: %s\\n\"\n             \"  server3: %s\\n\",\n             mServers, &mServers[mMaxLen+1], &mServers[(mMaxLen+1)<<1]);\n}\ninline void LocEngReportXtraServer::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_REQUEST_BIT:\n//        case LOC_ENG_MSG_RELEASE_BIT:\nLocEngReqRelBIT::LocEngReqRelBIT(void* locEng, AGpsExtType type,\n                                 int ipv4, char* ipv6, bool isReq) :\n    LocMsg(), mLocEng(locEng), mType(type), mIPv4Addr(ipv4),\n    mIPv6Addr(ipv6 ? new char[16] : NULL), mIsReq(isReq) {\n    if (NULL != ipv6)\n        memcpy(mIPv6Addr, ipv6, 16);\n    locallog();\n}\ninline LocEngReqRelBIT::~LocEngReqRelBIT() {\n    if (mIPv6Addr) {\n        delete[] mIPv6Addr;\n    }\n}\nvoid LocEngReqRelBIT::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    BITSubscriber s(getAgpsStateMachine(*locEng, mType),\n                    mIPv4Addr, mIPv6Addr);\n    AgpsStateMachine* sm = (AgpsStateMachine*)s.mStateMachine;\n\n    if (mIsReq) {\n        sm->subscribeRsrc((Subscriber*)&s);\n    } else {\n        sm->unsubscribeRsrc((Subscriber*)&s);\n    }\n}\ninline void LocEngReqRelBIT::locallog() const {\n    LOC_LOGV(\"LocEngRequestBIT - ipv4: %d.%d.%d.%d, ipv6: %s\",\n             (unsigned char)mIPv4Addr,\n             (unsigned char)(mIPv4Addr>>8),\n             (unsigned char)(mIPv4Addr>>16),\n             (unsigned char)(mIPv4Addr>>24),\n             NULL != mIPv6Addr ? mIPv6Addr : \"\");\n}\ninline void LocEngReqRelBIT::log() const {\n    locallog();\n}\nvoid LocEngReqRelBIT::send() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    locEng->adapter->sendMsg(this);\n}\n\n//        case LOC_ENG_MSG_RELEASE_BIT:\nstruct LocEngReleaseBIT : public LocMsg {\n    const BITSubscriber mSubscriber;\n    inline LocEngReleaseBIT(const AgpsStateMachine* stateMachine,\n                            unsigned int ipv4, char* ipv6) :\n        LocMsg(),\n        mSubscriber(stateMachine, ipv4, ipv6)\n    {\n        locallog();\n    }\n    inline virtual void proc() const\n    {\n        AgpsStateMachine* sm = (AgpsStateMachine*)mSubscriber.mStateMachine;\n        sm->unsubscribeRsrc((Subscriber*)&mSubscriber);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngReleaseBIT - ipv4: %d.%d.%d.%d, ipv6: %s\",\n                 (unsigned char)(mSubscriber.ID>>24),\n                 (unsigned char)(mSubscriber.ID>>16),\n                 (unsigned char)(mSubscriber.ID>>8),\n                 (unsigned char)mSubscriber.ID,\n                 NULL != mSubscriber.mIPv6Addr ? mSubscriber.mIPv6Addr : \"\");\n    }\n    virtual void log() const {\n        locallog();\n    }\n};\n\n//        LocEngSuplEsOpened\nLocEngSuplEsOpened::LocEngSuplEsOpened(void* locEng) :\n    LocMsg(), mLocEng(locEng) {\n    locallog();\n}\nvoid LocEngSuplEsOpened::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    if (locEng->ds_nif) {\n        AgpsStateMachine* sm = locEng->ds_nif;\n        sm->onRsrcEvent(RSRC_GRANTED);\n    }\n}\nvoid LocEngSuplEsOpened::locallog() const {\n    LOC_LOGV(\"LocEngSuplEsOpened\");\n}\nvoid LocEngSuplEsOpened::log() const {\n    locallog();\n}\n\n//        LocEngSuplEsClosed\nLocEngSuplEsClosed::LocEngSuplEsClosed(void* locEng) :\n    LocMsg(), mLocEng(locEng) {\n    locallog();\n}\nvoid LocEngSuplEsClosed::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    if (locEng->ds_nif) {\n        AgpsStateMachine* sm = locEng->ds_nif;\n        sm->onRsrcEvent(RSRC_RELEASED);\n    }\n}\nvoid LocEngSuplEsClosed::locallog() const {\n    LOC_LOGV(\"LocEngSuplEsClosed\");\n}\nvoid LocEngSuplEsClosed::log() const {\n    locallog();\n}\n\n\n//        case LOC_ENG_MSG_REQUEST_SUPL_ES:\nLocEngRequestSuplEs::LocEngRequestSuplEs(void* locEng, int id) :\n    LocMsg(), mLocEng(locEng), mID(id) {\n    locallog();\n}\nvoid LocEngRequestSuplEs::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    if (locEng->ds_nif) {\n        AgpsStateMachine* sm = locEng->ds_nif;\n        DSSubscriber s(sm, mID);\n        sm->subscribeRsrc((Subscriber*)&s);\n    }\n    else if (locEng->agnss_nif) {\n        AgpsStateMachine *sm = locEng->agnss_nif;\n        ATLSubscriber s(mID,\n                        sm,\n                        locEng->adapter,\n                        false);\n        sm->subscribeRsrc((Subscriber*)&s);\n        LOC_LOGD(\"%s:%d]: Using regular ATL for SUPL ES\", __func__, __LINE__);\n    }\n    else {\n        locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, -1);\n    }\n}\ninline void LocEngRequestSuplEs::locallog() const {\n    LOC_LOGV(\"LocEngRequestSuplEs\");\n}\ninline void LocEngRequestSuplEs::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_REQUEST_ATL:\nLocEngRequestATL::LocEngRequestATL(void* locEng, int id,\n                                   AGpsExtType agps_type) :\n    LocMsg(), mLocEng(locEng), mID(id), mType(agps_type) {\n    locallog();\n}\nvoid LocEngRequestATL::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    AgpsStateMachine* sm = (AgpsStateMachine*)\n                           getAgpsStateMachine(*locEng, mType);\n    if (sm) {\n        ATLSubscriber s(mID,\n                        sm,\n                        locEng->adapter,\n                        AGPS_TYPE_INVALID == mType);\n        sm->subscribeRsrc((Subscriber*)&s);\n    } else {\n        locEng->adapter->atlOpenStatus(mID, 0, NULL, -1, mType);\n    }\n}\ninline void LocEngRequestATL::locallog() const {\n    LOC_LOGV(\"LocEngRequestATL\");\n}\ninline void LocEngRequestATL::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_RELEASE_ATL:\nLocEngReleaseATL::LocEngReleaseATL(void* locEng, int id) :\n    LocMsg(), mLocEng(locEng), mID(id) {\n    locallog();\n}\nvoid LocEngReleaseATL::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n\n   if (locEng->agnss_nif) {\n        ATLSubscriber s1(mID, locEng->agnss_nif, locEng->adapter, false);\n        if (locEng->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) {\n            LOC_LOGD(\"%s:%d]: Unsubscribed from agnss_nif\",\n                     __func__, __LINE__);\n            return;\n        }\n    }\n\n    if (locEng->internet_nif) {\n        ATLSubscriber s2(mID, locEng->internet_nif, locEng->adapter, false);\n        if (locEng->internet_nif->unsubscribeRsrc((Subscriber*)&s2)) {\n            LOC_LOGD(\"%s:%d]: Unsubscribed from internet_nif\",\n                     __func__, __LINE__);\n            return;\n        }\n    }\n\n    if (locEng->ds_nif) {\n        DSSubscriber s3(locEng->ds_nif, mID);\n        if (locEng->ds_nif->unsubscribeRsrc((Subscriber*)&s3)) {\n            LOC_LOGD(\"%s:%d]: Unsubscribed from ds_nif\",\n                     __func__, __LINE__);\n            return;\n        }\n    }\n\n    LOC_LOGW(\"%s:%d]: Could not release ATL. \"\n             \"No subscribers found\\n\",\n             __func__, __LINE__);\n    locEng->adapter->atlCloseStatus(mID, 0);\n}\ninline void LocEngReleaseATL::locallog() const {\n    LOC_LOGV(\"LocEngReleaseATL\");\n}\ninline void LocEngReleaseATL::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_REQUEST_WIFI:\n//        case LOC_ENG_MSG_RELEASE_WIFI:\nLocEngReqRelWifi::LocEngReqRelWifi(void* locEng, AGpsExtType type,\n                                   loc_if_req_sender_id_e_type sender_id,\n                                   char* s, char* p, bool isReq) :\n    LocMsg(), mLocEng(locEng), mType(type), mSenderId(sender_id),\n    mSSID(NULL == s ? NULL : new char[SSID_BUF_SIZE]),\n    mPassword(NULL == p ? NULL : new char[SSID_BUF_SIZE]),\n    mIsReq(isReq) {\n    if (NULL != s)\n        strlcpy(mSSID, s, SSID_BUF_SIZE);\n    if (NULL != p)\n        strlcpy(mPassword, p, SSID_BUF_SIZE);\n    locallog();\n}\nLocEngReqRelWifi::~LocEngReqRelWifi() {\n    if (NULL != mSSID) {\n        delete[] mSSID;\n    }\n    if (NULL != mPassword) {\n        delete[] mPassword;\n    }\n}\nvoid LocEngReqRelWifi::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    if (locEng->wifi_nif) {\n        WIFISubscriber s(locEng->wifi_nif, mSSID, mPassword, mSenderId);\n        if (mIsReq) {\n            locEng->wifi_nif->subscribeRsrc((Subscriber*)&s);\n        } else {\n            locEng->wifi_nif->unsubscribeRsrc((Subscriber*)&s);\n        }\n    } else {\n        locEng->adapter->atlOpenStatus(mSenderId, 0, NULL, -1, mType);\n    }\n}\ninline void LocEngReqRelWifi::locallog() const {\n    LOC_LOGV(\"%s - senderId: %d, ssid: %s, password: %s\",\n             mIsReq ? \"LocEngRequestWifi\" : \"LocEngReleaseWifi\",\n             mSenderId,\n             NULL != mSSID ? mSSID : \"\",\n             NULL != mPassword ? mPassword : \"\");\n}\ninline void LocEngReqRelWifi::log() const {\n    locallog();\n}\nvoid LocEngReqRelWifi::send() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    locEng->adapter->sendMsg(this);\n}\n\n//        case LOC_ENG_MSG_REQUEST_XTRA_DATA:\nLocEngRequestXtra::LocEngRequestXtra(void* locEng) :\n    mLocEng(locEng) {\n    locallog();\n}\nvoid LocEngRequestXtra::proc() const\n{\n    loc_eng_xtra_data_s_type* locEngXtra =\n        &(((loc_eng_data_s_type*)mLocEng)->xtra_module_data);\n\n    if (locEngXtra->download_request_cb != NULL) {\n        CALLBACK_LOG_CALLFLOW(\"download_request_cb\", %p, mLocEng);\n        locEngXtra->download_request_cb();\n    } else {\n        LOC_LOGE(\"Callback function for request xtra is NULL\");\n    }\n}\ninline void LocEngRequestXtra::locallog() const {\n    LOC_LOGV(\"LocEngReqXtra\");\n}\ninline void LocEngRequestXtra::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_REQUEST_TIME:\nLocEngRequestTime::LocEngRequestTime(void* locEng) :\n    LocMsg(), mLocEng(locEng)\n{\n    locallog();\n}\nvoid LocEngRequestTime::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    if (gps_conf.CAPABILITIES & GPS_CAPABILITY_ON_DEMAND_TIME) {\n        if (locEng->request_utc_time_cb != NULL) {\n            locEng->request_utc_time_cb();\n        } else {\n            LOC_LOGE(\"Callback function for request time is NULL\");\n        }\n    }\n}\ninline void LocEngRequestTime::locallog() const {\n    LOC_LOGV(\"LocEngReqTime\");\n}\ninline void LocEngRequestTime::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_DELETE_AIDING_DATA:\nstruct LocEngDelAidData : public LocMsg {\n    loc_eng_data_s_type* mLocEng;\n    const GpsAidingData mType;\n    inline LocEngDelAidData(loc_eng_data_s_type* locEng,\n                            GpsAidingData f) :\n        LocMsg(), mLocEng(locEng), mType(f)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mLocEng->aiding_data_for_deletion = mType;\n        update_aiding_data_for_deletion(*mLocEng);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"aiding data msak %d\", mType);\n    }\n    virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_ENABLE_DATA:\nstruct LocEngEnableData : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const int mEnable;\n    char* mAPN;\n    const int mLen;\n    inline LocEngEnableData(LocEngAdapter* adapter,\n                            const char* name, int len, int enable) :\n        LocMsg(), mAdapter(adapter),\n        mEnable(enable), mAPN(NULL), mLen(len)\n    {\n        if (NULL != name) {\n            mAPN = new char[len+1];\n            memcpy((void*)mAPN, (void*)name, len);\n            mAPN[len] = 0;\n        }\n        locallog();\n    }\n    inline ~LocEngEnableData() {\n        if (NULL != mAPN) {\n            delete[] mAPN;\n        }\n    }\n    inline virtual void proc() const {\n        mAdapter->enableData(mEnable);\n        if (NULL != mAPN) {\n            mAdapter->setAPN(mAPN, mLen);\n        }\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"apn: %s\\n  enable: %d\",\n                 (NULL == mAPN) ? \"NULL\" : mAPN, mEnable);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_INJECT_XTRA_DATA:\n// loc_eng_xtra.cpp\n\n//        case LOC_ENG_MSG_SET_CAPABILITIES:\nstruct LocEngSetCapabilities : public LocMsg {\n    loc_eng_data_s_type* mLocEng;\n    inline LocEngSetCapabilities(loc_eng_data_s_type* locEng) :\n        LocMsg(), mLocEng(locEng)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        if (NULL != mLocEng->set_capabilities_cb) {\n            LOC_LOGV(\"calling set_capabilities_cb 0x%x\",\n                     gps_conf.CAPABILITIES);\n            mLocEng->set_capabilities_cb(gps_conf.CAPABILITIES);\n        } else {\n            LOC_LOGV(\"set_capabilities_cb is NULL.\\n\");\n        }\n    }\n    inline void locallog() const\n    {\n        LOC_LOGV(\"LocEngSetCapabilities\");\n    }\n    inline virtual void log() const\n    {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_LOC_INIT:\nstruct LocEngInit : public LocMsg {\n    loc_eng_data_s_type* mLocEng;\n    inline LocEngInit(loc_eng_data_s_type* locEng) :\n        LocMsg(), mLocEng(locEng)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        loc_eng_reinit(*mLocEng);\n        // set the capabilities\n        mLocEng->adapter->sendMsg(new LocEngSetCapabilities(mLocEng));\n    }\n    inline void locallog() const\n    {\n        LOC_LOGV(\"LocEngInit\");\n    }\n    inline virtual void log() const\n    {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_REQUEST_XTRA_SERVER:\n// loc_eng_xtra.cpp\n\n//        case LOC_ENG_MSG_ATL_OPEN_SUCCESS:\nstruct LocEngAtlOpenSuccess : public LocMsg {\n    AgpsStateMachine* mStateMachine;\n    const int mLen;\n    char* mAPN;\n    const AGpsBearerType mBearerType;\n    inline LocEngAtlOpenSuccess(AgpsStateMachine* statemachine,\n                                const char* name,\n                                int len,\n                                AGpsBearerType btype) :\n        LocMsg(),\n        mStateMachine(statemachine), mLen(len),\n        mAPN(new char[len+1]), mBearerType(btype)\n    {\n        memcpy((void*)mAPN, (void*)name, len);\n        mAPN[len] = 0;\n        locallog();\n    }\n    inline ~LocEngAtlOpenSuccess()\n    {\n        delete[] mAPN;\n    }\n    inline virtual void proc() const {\n        mStateMachine->setBearer(mBearerType);\n        mStateMachine->setAPN(mAPN, mLen);\n        mStateMachine->onRsrcEvent(RSRC_GRANTED);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngAtlOpenSuccess agps type: %s\\n  apn: %s\\n\"\n                 \"  bearer type: %s\",\n                 loc_get_agps_type_name(mStateMachine->getType()),\n                 mAPN,\n                 loc_get_agps_bear_name(mBearerType));\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_ATL_CLOSED:\nstruct LocEngAtlClosed : public LocMsg {\n    AgpsStateMachine* mStateMachine;\n    inline LocEngAtlClosed(AgpsStateMachine* statemachine) :\n        LocMsg(), mStateMachine(statemachine) {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mStateMachine->onRsrcEvent(RSRC_RELEASED);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngAtlClosed\");\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_ATL_OPEN_FAILED:\nstruct LocEngAtlOpenFailed : public LocMsg {\n    AgpsStateMachine* mStateMachine;\n    inline LocEngAtlOpenFailed(AgpsStateMachine* statemachine) :\n        LocMsg(), mStateMachine(statemachine) {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mStateMachine->onRsrcEvent(RSRC_DENIED);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngAtlOpenFailed\");\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_ENGINE_DOWN:\nLocEngDown::LocEngDown(void* locEng) :\n    LocMsg(), mLocEng(locEng) {\n    locallog();\n}\ninline void LocEngDown::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    loc_eng_handle_engine_down(*locEng);\n}\ninline void LocEngDown::locallog() const {\n    LOC_LOGV(\"LocEngDown\");\n}\ninline void LocEngDown::log() const {\n    locallog();\n}\n\n//        case LOC_ENG_MSG_ENGINE_UP:\nLocEngUp::LocEngUp(void* locEng) :\n    LocMsg(), mLocEng(locEng) {\n    locallog();\n}\ninline void LocEngUp::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*)mLocEng;\n    loc_eng_handle_engine_up(*locEng);\n}\ninline void LocEngUp::locallog() const {\n    LOC_LOGV(\"LocEngUp\");\n}\ninline void LocEngUp::log() const {\n    locallog();\n}\n\nstruct LocEngDataClientInit : public LocMsg {\n    loc_eng_data_s_type* mLocEng;\n    inline LocEngDataClientInit(loc_eng_data_s_type* locEng) :\n        LocMsg(), mLocEng(locEng) {\n        locallog();\n    }\n    virtual void proc() const {\n        loc_eng_data_s_type *locEng = (loc_eng_data_s_type *)mLocEng;\n        if(!locEng->adapter->initDataServiceClient()) {\n            locEng->ds_nif = new DSStateMachine(servicerTypeExt,\n                                               (void *)dataCallCb,\n                                               locEng->adapter);\n        }\n    }\n    void locallog() const {\n        LOC_LOGV(\"LocEngDataClientInit\\n\");\n    }\n    virtual void log() const {\n        locallog();\n    }\n};\n\nstruct LocEngInstallAGpsCert : public LocMsg {\n    LocEngAdapter* mpAdapter;\n    const size_t mNumberOfCerts;\n    const uint32_t mSlotBitMask;\n    DerEncodedCertificate* mpData;\n    inline LocEngInstallAGpsCert(LocEngAdapter* adapter,\n                              const DerEncodedCertificate* pData,\n                              size_t numberOfCerts,\n                              uint32_t slotBitMask) :\n        LocMsg(), mpAdapter(adapter),\n        mNumberOfCerts(numberOfCerts), mSlotBitMask(slotBitMask),\n        mpData(new DerEncodedCertificate[mNumberOfCerts])\n    {\n        for (int i=0; i < mNumberOfCerts; i++) {\n            mpData[i].data = new u_char[pData[i].length];\n            if (mpData[i].data) {\n                memcpy(mpData[i].data, (void*)pData[i].data, pData[i].length);\n                mpData[i].length = pData[i].length;\n            } else {\n                LOC_LOGE(\"malloc failed for cert#%d\", i);\n                break;\n            }\n        }\n        locallog();\n    }\n    inline ~LocEngInstallAGpsCert()\n    {\n        for (int i=0; i < mNumberOfCerts; i++) {\n            if (mpData[i].data) {\n                delete[] mpData[i].data;\n            }\n        }\n        delete[] mpData;\n    }\n    inline virtual void proc() const {\n        mpAdapter->installAGpsCert(mpData, mNumberOfCerts, mSlotBitMask);\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngInstallAGpsCert - certs=%u mask=%u\",\n                 mNumberOfCerts, mSlotBitMask);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\nstruct LocEngUpdateRegistrationMask : public LocMsg {\n    loc_eng_data_s_type* mLocEng;\n    LOC_API_ADAPTER_EVENT_MASK_T mMask;\n    loc_registration_mask_status mIsEnabled;\n    inline LocEngUpdateRegistrationMask(loc_eng_data_s_type* locEng,\n                                        LOC_API_ADAPTER_EVENT_MASK_T mask,\n                                        loc_registration_mask_status isEnabled) :\n        LocMsg(), mLocEng(locEng), mMask(mask), mIsEnabled(isEnabled) {\n        locallog();\n    }\n    inline virtual void proc() const {\n        loc_eng_data_s_type *locEng = (loc_eng_data_s_type *)mLocEng;\n        locEng->adapter->updateRegistrationMask(mMask,\n                                                mIsEnabled);\n    }\n    void locallog() const {\n        LOC_LOGV(\"LocEngUpdateRegistrationMask\\n\");\n    }\n    virtual void log() const {\n        locallog();\n    }\n};\n\nstruct LocEngGnssConstellationConfig : public LocMsg {\n    LocEngAdapter* mAdapter;\n    inline LocEngGnssConstellationConfig(LocEngAdapter* adapter) :\n        LocMsg(), mAdapter(adapter) {\n        locallog();\n    }\n    inline virtual void proc() const {\n        if (mAdapter->gnssConstellationConfig()) {\n            LOC_LOGV(\"Modem supports GNSS measurements\\n\");\n            gps_conf.CAPABILITIES |= GPS_CAPABILITY_MEASUREMENTS;\n        } else {\n            LOC_LOGV(\"Modem does not support GNSS measurements\\n\");\n        }\n    }\n    void locallog() const {\n        LOC_LOGV(\"LocEngGnssConstellationConfig\\n\");\n    }\n    virtual void log() const {\n        locallog();\n    }\n};\n\n//        case LOC_ENG_MSG_REPORT_GNSS_MEASUREMENT:\nLocEngReportGpsMeasurement::LocEngReportGpsMeasurement(void* locEng,\n                                                       GpsData &gpsData) :\n    LocMsg(), mLocEng(locEng), mGpsData(gpsData)\n{\n    locallog();\n}\nvoid LocEngReportGpsMeasurement::proc() const {\n    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng;\n    if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION)\n    {\n        if (locEng->gps_measurement_cb != NULL) {\n            locEng->gps_measurement_cb((GpsData*)&(mGpsData));\n        }\n    }\n}\nvoid LocEngReportGpsMeasurement::locallog() const {\n    IF_LOC_LOGV {\n        LOC_LOGV(\"%s:%d]: Received in GPS HAL.\"\n                 \"GNSS Measurements count: %d \\n\",\n                 __func__, __LINE__, mGpsData.measurement_count);\n        for (int i =0; i< mGpsData.measurement_count && i < GPS_MAX_SVS; i++) {\n                LOC_LOGV(\" GNSS measurement data in GPS HAL: \\n\"\n                         \" GPS_HAL => Measurement ID | prn | time_offset_ns | state |\"\n                         \" received_gps_tow_ns| c_n0_dbhz | pseudorange_rate_mps |\"\n                         \" pseudorange_rate_uncertainty_mps |\"\n                         \" accumulated_delta_range_state | flags \\n\"\n                         \" GPS_HAL => %d | %d | %f | %d | %lld | %f | %f | %f | %d | %d \\n\",\n                         i,\n                         mGpsData.measurements[i].prn,\n                         mGpsData.measurements[i].time_offset_ns,\n                         mGpsData.measurements[i].state,\n                         mGpsData.measurements[i].received_gps_tow_ns,\n                         mGpsData.measurements[i].c_n0_dbhz,\n                         mGpsData.measurements[i].pseudorange_rate_mps,\n                         mGpsData.measurements[i].pseudorange_rate_uncertainty_mps,\n                         mGpsData.measurements[i].accumulated_delta_range_state,\n                         mGpsData.measurements[i].flags);\n        }\n        LOC_LOGV(\" GPS_HAL => Clocks Info: type | time_ns \\n\"\n                 \" GPS_HAL => Clocks Info: %d | %lld\", mGpsData.clock.type,\n                 mGpsData.clock.time_ns);\n    }\n}\ninline void LocEngReportGpsMeasurement::log() const {\n    locallog();\n}\n\n/*********************************************************************\n * Initialization checking macros\n *********************************************************************/\n#define STATE_CHECK(ctx, x, ret) \\\n    if (!(ctx))                  \\\n  {                              \\\n      /* Not intialized, abort */\\\n      LOC_LOGE(\"%s: log_eng state error: %s\", __func__, x); \\\n      EXIT_LOG(%s, x);                                            \\\n      ret;                                                        \\\n  }\n#define INIT_CHECK(ctx, ret) STATE_CHECK(ctx, \"instance not initialized\", ret)\n\nuint32_t getCarrierCapabilities() {\n    #define carrierMSA (uint32_t)0x2\n    #define carrierMSB (uint32_t)0x1\n    #define gpsConfMSA (uint32_t)0x4\n    #define gpsConfMSB (uint32_t)0x2\n    uint32_t capabilities = gps_conf.CAPABILITIES;\n    if ((gps_conf.SUPL_MODE & carrierMSA) != carrierMSA) {\n        capabilities &= ~gpsConfMSA;\n    }\n    if ((gps_conf.SUPL_MODE & carrierMSB) != carrierMSB) {\n        capabilities &= ~gpsConfMSB;\n    }\n\n    LOC_LOGV(\"getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x\",\n             gps_conf.CAPABILITIES, gps_conf.SUPL_MODE, capabilities);\n    return capabilities;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_init\n\nDESCRIPTION\n   Initialize the location engine, this include setting up global datas\n   and registers location engien with loc api service.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,\n                 LOC_API_ADAPTER_EVENT_MASK_T event, ContextBase* context)\n\n{\n    int ret_val = 0;\n\n    ENTRY_LOG_CALLFLOW();\n    if (NULL == callbacks || 0 == event) {\n        LOC_LOGE(\"loc_eng_init: bad parameters cb %p eMask %d\", callbacks, event);\n        ret_val = -1;\n        EXIT_LOG(%d, ret_val);\n        return ret_val;\n    }\n\n    STATE_CHECK((NULL == loc_eng_data.adapter),\n                \"instance already initialized\", return 0);\n\n    memset(&loc_eng_data, 0, sizeof (loc_eng_data));\n\n    // Save callbacks\n    loc_eng_data.location_cb  = callbacks->location_cb;\n    loc_eng_data.sv_status_cb = callbacks->sv_status_cb;\n    loc_eng_data.status_cb    = callbacks->status_cb;\n    loc_eng_data.nmea_cb      = callbacks->nmea_cb;\n    loc_eng_data.set_capabilities_cb = callbacks->set_capabilities_cb;\n    loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb;\n    loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb;\n    loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb;\n    loc_eng_data.location_ext_parser = callbacks->location_ext_parser ?\n        callbacks->location_ext_parser : noProc;\n    loc_eng_data.sv_ext_parser = callbacks->sv_ext_parser ?\n        callbacks->sv_ext_parser : noProc;\n    loc_eng_data.intermediateFix = gps_conf.INTERMEDIATE_POS;\n    // initial states taken care of by the memset above\n    // loc_eng_data.engine_status -- GPS_STATUS_NONE;\n    // loc_eng_data.fix_session_status -- GPS_STATUS_NONE;\n    // loc_eng_data.mute_session_state -- LOC_MUTE_SESS_NONE;\n\n    if ((event & LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT) && (gps_conf.NMEA_PROVIDER == NMEA_PROVIDER_AP))\n    {\n        event = event ^ LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; // unregister for modem NMEA report\n        loc_eng_data.generateNmea = true;\n    }\n    else\n    {\n        loc_eng_data.generateNmea = false;\n    }\n\n    loc_eng_data.adapter =\n        new LocEngAdapter(event, &loc_eng_data, context,\n                          (LocThread::tCreate)callbacks->create_thread_cb);\n\n    LOC_LOGD(\"loc_eng_init created client, id = %p\\n\",\n             loc_eng_data.adapter);\n    loc_eng_data.adapter->sendMsg(new LocEngInit(&loc_eng_data));\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\nstatic int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG();\n    int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;\n    LocEngAdapter* adapter = loc_eng_data.adapter;\n\n    adapter->sendMsg(new LocEngGnssConstellationConfig(adapter));\n    adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER));\n    adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE));\n    adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE,\n                                                   sap_conf.SENSOR_PROVIDER));\n    adapter->sendMsg(new LocEngAGlonassProtocol(adapter, gps_conf.A_GLONASS_POS_PROTOCOL_SELECT));\n\n    /* Make sure at least one of the sensor property is specified by the user in the gps.conf file. */\n    if( sap_conf.GYRO_BIAS_RANDOM_WALK_VALID ||\n        sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||\n        sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||\n        sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||\n        sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) {\n        adapter->sendMsg(new LocEngSensorProperties(adapter,\n                                                    sap_conf.GYRO_BIAS_RANDOM_WALK_VALID,\n                                                    sap_conf.GYRO_BIAS_RANDOM_WALK,\n                                                    sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID,\n                                                    sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY,\n                                                    sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,\n                                                    sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY,\n                                                    sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,\n                                                    sap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY,\n                                                    sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID,\n                                                    sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY));\n    }\n\n    adapter->sendMsg(new LocEngSensorPerfControlConfig(adapter,\n                                                       sap_conf.SENSOR_CONTROL_MODE,\n                                                       sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH,\n                                                       sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC,\n                                                       sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH,\n                                                       sap_conf.SENSOR_GYRO_BATCHES_PER_SEC,\n                                                       sap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH,\n                                                       sap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH,\n                                                       sap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH,\n                                                       sap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH,\n                                                       sap_conf.SENSOR_ALGORITHM_CONFIG_MASK));\n\n    adapter->sendMsg(new LocEngEnableData(adapter, NULL, 0, (agpsStatus ? 1:0)));\n\n    loc_eng_xtra_version_check(loc_eng_data, gps_conf.XTRA_VERSION_CHECK);\n\n    LOC_LOGD(\"loc_eng_reinit reinit() successful\");\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_cleanup\n\nDESCRIPTION\n   Cleans location engine. The location client handle will be released.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter, return);\n\n    // XTRA has no state, so we are fine with it.\n\n    // we need to check and clear NI\n#if 0\n    // we need to check and clear ATL\n    if (NULL != loc_eng_data.agnss_nif) {\n        delete loc_eng_data.agnss_nif;\n        loc_eng_data.agnss_nif = NULL;\n    }\n    if (NULL != loc_eng_data.internet_nif) {\n        delete loc_eng_data.internet_nif;\n        loc_eng_data.internet_nif = NULL;\n    }\n#endif\n    if (loc_eng_data.adapter->isInSession())\n    {\n        LOC_LOGD(\"loc_eng_cleanup: fix not stopped. stop it now.\");\n        loc_eng_stop(loc_eng_data);\n    }\n\n#if 0 // can't afford to actually clean up, for many reason.\n\n    LOC_LOGD(\"loc_eng_init: client opened. close it now.\");\n    delete loc_eng_data.adapter;\n    loc_eng_data.adapter = NULL;\n\n    loc_eng_dmn_conn_loc_api_server_unblock();\n    loc_eng_dmn_conn_loc_api_server_join();\n\n#endif\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\n\n/*===========================================================================\nFUNCTION    loc_eng_start\n\nDESCRIPTION\n   Starts the tracking session\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_start(loc_eng_data_s_type &loc_eng_data)\n{\n   ENTRY_LOG_CALLFLOW();\n   INIT_CHECK(loc_eng_data.adapter, return -1);\n\n   if(! loc_eng_data.adapter->getUlpProxy()->sendStartFix())\n   {\n       loc_eng_data.adapter->sendMsg(new LocEngStartFix(loc_eng_data.adapter));\n   }\n\n   EXIT_LOG(%d, 0);\n   return 0;\n}\n\nstatic int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data)\n{\n   ENTRY_LOG();\n   int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;\n\n   if (!loc_eng_data.adapter->isInSession()) {\n       ret_val = loc_eng_data.adapter->startFix();\n\n       if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS ||\n           ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN ||\n           ret_val == LOC_API_ADAPTER_ERR_PHONE_OFFLINE ||\n           ret_val == LOC_API_ADAPTER_ERR_INTERNAL)\n       {\n           loc_eng_data.adapter->setInSession(TRUE);\n       }\n   }\n\n   EXIT_LOG(%d, ret_val);\n   return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_stop_wrapper\n\nDESCRIPTION\n   Stops the tracking session\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_stop(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter, return -1);\n\n    if(! loc_eng_data.adapter->getUlpProxy()->sendStopFix())\n    {\n        loc_eng_data.adapter->sendMsg(new LocEngStopFix(loc_eng_data.adapter));\n    }\n\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n\nstatic int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data)\n{\n   ENTRY_LOG();\n   int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;\n\n   if (loc_eng_data.adapter->isInSession()) {\n\n       ret_val = loc_eng_data.adapter->stopFix();\n       loc_eng_data.adapter->setInSession(FALSE);\n   }\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_mute_one_session\n\nDESCRIPTION\n   Mutes one session\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: Success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG();\n    loc_eng_data.mute_session_state = LOC_MUTE_SESS_WAIT;\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_set_position_mode\n\nDESCRIPTION\n   Sets the mode and fix frequency for the tracking session.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data,\n                              LocPosMode &params)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter, return -1);\n\n    // The position mode for AUTO/GSS/QCA1530 can only be standalone\n    if (!(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB) &&\n        !(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) &&\n        (params.mode != LOC_POSITION_MODE_STANDALONE)) {\n        params.mode = LOC_POSITION_MODE_STANDALONE;\n        LOC_LOGD(\"Position mode changed to standalone for target with AUTO/GSS/qca1530.\");\n    }\n\n    if(! loc_eng_data.adapter->getUlpProxy()->sendFixMode(params))\n    {\n        LocEngAdapter* adapter = loc_eng_data.adapter;\n        adapter->sendMsg(new LocEngPositionMode(adapter, params));\n    }\n\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_inject_time\n\nDESCRIPTION\n   This is used by Java native function to do time injection.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, GpsUtcTime time,\n                        int64_t timeReference, int uncertainty)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter, return -1);\n    LocEngAdapter* adapter = loc_eng_data.adapter;\n\n    adapter->sendMsg(new LocEngSetTime(adapter, time, timeReference,\n                                       uncertainty));\n\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n\n\n/*===========================================================================\nFUNCTION    loc_eng_inject_location\n\nDESCRIPTION\n   This is used by Java native function to do location injection.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0          : Successful\n   error code : Failure\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nint loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data, double latitude,\n                            double longitude, float accuracy)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter, return -1);\n    LocEngAdapter* adapter = loc_eng_data.adapter;\n    if(adapter->mSupportsPositionInjection)\n    {\n        adapter->sendMsg(new LocEngInjectLocation(adapter, latitude, longitude,\n                                                  accuracy));\n    }\n\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n\n\n/*===========================================================================\nFUNCTION    loc_eng_delete_aiding_data\n\nDESCRIPTION\n   This is used by Java native function to delete the aiding data. The function\n   updates the global variable for the aiding data to be deleted. If the GPS\n   engine is off, the aiding data will be deleted. Otherwise, the actual action\n   will happen when gps engine is turned off.\n\nDEPENDENCIES\n   Assumes the aiding data type specified in GpsAidingData matches with\n   LOC API specification.\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data, GpsAidingData f)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter, return);\n\n    loc_eng_data.adapter->sendMsg(new LocEngDelAidData(&loc_eng_data, f));\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\n\nFUNCTION    loc_inform_gps_state\n\nDESCRIPTION\n   Informs the GPS Provider about the GPS status\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, GpsStatusValue status)\n{\n    ENTRY_LOG();\n\n    if (loc_eng_data.status_cb)\n    {\n        GpsStatus gs = { sizeof(gs),status };\n        CALLBACK_LOG_CALLFLOW(\"status_cb\", %s,\n                              loc_get_gps_status_name(gs.status));\n        loc_eng_data.status_cb(&gs);\n    }\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\nstatic int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data)\n{\n   ENTRY_LOG();\n   int ret_val = LOC_API_ADAPTER_ERR_SUCCESS;\n   UlpLocation location;\n   LocPosTechMask tech_mask = LOC_POS_TECH_MASK_DEFAULT;\n   GpsLocationExtended locationExtended;\n   memset(&locationExtended, 0, sizeof (GpsLocationExtended));\n   locationExtended.size = sizeof(locationExtended);\n\n   ret_val = loc_eng_data.adapter->getZpp(location.gpsLocation, tech_mask);\n  //Mark the location source as from ZPP\n  location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO;\n  location.position_source = ULP_LOCATION_IS_FROM_ZPP;\n\n  loc_eng_data.adapter->getUlpProxy()->reportPosition(location,\n                                     locationExtended,\n                                     NULL,\n                                     LOC_SESS_SUCCESS,\n                                     tech_mask);\n\n  EXIT_LOG(%d, ret_val);\n  return ret_val;\n}\n\n/*\n  Callback function passed to Data Services State Machine\n  This becomes part of the state machine's servicer and\n  is used to send requests to the data services client\n*/\nstatic int dataCallCb(void *cb_data)\n{\n    LOC_LOGD(\"Enter dataCallCb\\n\");\n    int ret=0;\n    if(cb_data != NULL) {\n        dsCbData *cbData = (dsCbData *)cb_data;\n        LocEngAdapter *locAdapter = (LocEngAdapter *)cbData->mAdapter;\n        if(cbData->action == GPS_REQUEST_AGPS_DATA_CONN) {\n            LOC_LOGD(\"dataCallCb GPS_REQUEST_AGPS_DATA_CONN\\n\");\n            ret =  locAdapter->openAndStartDataCall();\n        }\n        else if(cbData->action == GPS_RELEASE_AGPS_DATA_CONN) {\n            LOC_LOGD(\"dataCallCb GPS_RELEASE_AGPS_DATA_CONN\\n\");\n            locAdapter->stopDataCall();\n        }\n    }\n    else {\n        LOC_LOGE(\"NULL argument received. Failing.\\n\");\n        ret = -1;\n        goto err;\n    }\n\nerr:\n    LOC_LOGD(\"Exit dataCallCb ret = %d\\n\", ret);\n    return ret;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_agps_reinit\n\nDESCRIPTION\n   2nd half of loc_eng_agps_init(), singled out for modem restart to use.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_eng_agps_reinit(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG();\n\n    // Set server addresses which came before init\n    if (loc_eng_data.supl_host_set)\n    {\n        loc_eng_set_server(loc_eng_data, LOC_AGPS_SUPL_SERVER,\n                           loc_eng_data.supl_host_buf,\n                           loc_eng_data.supl_port_buf);\n    }\n\n    if (loc_eng_data.c2k_host_set)\n    {\n        loc_eng_set_server(loc_eng_data, LOC_AGPS_CDMA_PDE_SERVER,\n                           loc_eng_data.c2k_host_buf,\n                           loc_eng_data.c2k_port_buf);\n    }\n    EXIT_LOG(%s, VOID_RET);\n}\n/*===========================================================================\nFUNCTION    loc_eng_agps_init\n\nDESCRIPTION\n   Initialize the AGps interface.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* callbacks)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter, return);\n    STATE_CHECK((NULL == loc_eng_data.agps_status_cb),\n                \"agps instance already initialized\",\n                return);\n    if (callbacks == NULL) {\n        LOC_LOGE(\"loc_eng_agps_init: bad parameters cb %p\", callbacks);\n        EXIT_LOG(%s, VOID_RET);\n        return;\n    }\n    LocEngAdapter* adapter = loc_eng_data.adapter;\n    loc_eng_data.agps_status_cb = callbacks->status_cb;\n\n    loc_eng_data.internet_nif = new AgpsStateMachine(servicerTypeAgps,\n                                                     (void *)loc_eng_data.agps_status_cb,\n                                                     AGPS_TYPE_WWAN_ANY,\n                                                     false);\n    loc_eng_data.wifi_nif = new AgpsStateMachine(servicerTypeAgps,\n                                                 (void *)loc_eng_data.agps_status_cb,\n                                                 AGPS_TYPE_WIFI,\n                                                 true);\n\n    if ((gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) ||\n        (gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB)) {\n        loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps,\n                                                      (void *)loc_eng_data.agps_status_cb,\n                                                      AGPS_TYPE_SUPL,\n                                                      false);\n\n        if (adapter->mSupportsAgpsRequests) {\n            if(gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) {\n                loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data));\n            }\n            loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb,\n                                                   NULL, NULL, &loc_eng_data);\n        }\n        loc_eng_agps_reinit(loc_eng_data);\n    }\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\nstatic void deleteAidingData(loc_eng_data_s_type &logEng) {\n    if (logEng.engine_status != GPS_STATUS_ENGINE_ON &&\n        logEng.aiding_data_for_deletion != 0) {\n        logEng.adapter->deleteAidingData(logEng.aiding_data_for_deletion);\n        logEng.aiding_data_for_deletion = 0;\n    }\n}\n\nstatic AgpsStateMachine*\ngetAgpsStateMachine(loc_eng_data_s_type &locEng, AGpsExtType agpsType) {\n    AgpsStateMachine* stateMachine;\n    switch (agpsType) {\n    case AGPS_TYPE_WIFI: {\n        stateMachine = locEng.wifi_nif;\n        break;\n    }\n    case AGPS_TYPE_INVALID:\n    case AGPS_TYPE_SUPL: {\n        stateMachine = locEng.agnss_nif;\n        break;\n    }\n    case AGPS_TYPE_SUPL_ES: {\n        locEng.ds_nif ?\n            stateMachine = locEng.ds_nif:\n            stateMachine = locEng.agnss_nif;\n        break;\n    }\n    default:\n        stateMachine  = locEng.internet_nif;\n    }\n    return stateMachine;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_agps_open\n\nDESCRIPTION\n   This function is called when on-demand data connection opening is successful.\nIt should inform engine about the data open result.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType,\n                     const char* apn, AGpsBearerType bearerType)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb,\n               return -1);\n\n    if (apn == NULL)\n    {\n        LOC_LOGE(\"APN Name NULL\\n\");\n        return 0;\n    }\n\n    LOC_LOGD(\"loc_eng_agps_open APN name = [%s]\", apn);\n\n    int apn_len = smaller_of(strlen (apn), MAX_APN_LEN);\n    AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType);\n\n    loc_eng_data.adapter->sendMsg(\n        new LocEngAtlOpenSuccess(sm, apn, apn_len, bearerType));\n\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_agps_closed\n\nDESCRIPTION\n   This function is called when on-demand data connection closing is done.\nIt should inform engine about the data close result.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb,\n               return -1);\n\n    AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType);\n    loc_eng_data.adapter->sendMsg(new LocEngAtlClosed(sm));\n\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_agps_open_failed\n\nDESCRIPTION\n   This function is called when on-demand data connection opening has failed.\nIt should inform engine about the data open result.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType)\n{\n    ENTRY_LOG_CALLFLOW();\n    INIT_CHECK(loc_eng_data.adapter && loc_eng_data.agps_status_cb,\n               return -1);\n\n    AgpsStateMachine* sm = getAgpsStateMachine(loc_eng_data, agpsType);\n    loc_eng_data.adapter->sendMsg(new LocEngAtlOpenFailed(sm));\n\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n\n/*===========================================================================\n\nFUNCTION resolve_in_addr\n\nDESCRIPTION\n   Translates a hostname to in_addr struct\n\nDEPENDENCIES\n   n/a\n\nRETURN VALUE\n   TRUE if successful\n\nSIDE EFFECTS\n   n/a\n\n===========================================================================*/\nstatic boolean resolve_in_addr(const char *host_addr, struct in_addr *in_addr_ptr)\n{\n    ENTRY_LOG();\n    boolean ret_val = TRUE;\n\n    struct hostent             *hp;\n    hp = gethostbyname(host_addr);\n    if (hp != NULL) /* DNS OK */\n    {\n        memcpy(in_addr_ptr, hp->h_addr_list[0], hp->h_length);\n    }\n    else\n    {\n        /* Try IP representation */\n        if (inet_aton(host_addr, in_addr_ptr) == 0)\n        {\n            /* IP not valid */\n            LOC_LOGE(\"DNS query on '%s' failed\\n\", host_addr);\n            ret_val = FALSE;\n        }\n    }\n\n    EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_set_server\n\nDESCRIPTION\n   This is used to set the default AGPS server. Server address is obtained\n   from gps.conf.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data,\n                              LocServerType type, const char* hostname, int port)\n{\n    ENTRY_LOG();\n    int ret = 0;\n    LocEngAdapter* adapter = loc_eng_data.adapter;\n\n    if (LOC_AGPS_SUPL_SERVER == type) {\n        char url[MAX_URL_LEN];\n        unsigned int len = 0;\n        const char nohost[] = \"NONE\";\n        if (hostname == NULL ||\n            strncasecmp(nohost, hostname, sizeof(nohost)) == 0) {\n            url[0] = NULL;\n        } else {\n            len = snprintf(url, sizeof(url), \"%s:%u\", hostname, (unsigned) port);\n        }\n\n        if (sizeof(url) > len) {\n            adapter->sendMsg(new LocEngSetServerUrl(adapter, url, len));\n        }\n    } else if (LOC_AGPS_CDMA_PDE_SERVER == type ||\n               LOC_AGPS_CUSTOM_PDE_SERVER == type ||\n               LOC_AGPS_MPC_SERVER == type) {\n        struct in_addr addr;\n        if (!resolve_in_addr(hostname, &addr))\n        {\n            LOC_LOGE(\"loc_eng_set_server, hostname %s cannot be resolved.\\n\", hostname);\n            ret = -2;\n        } else {\n            unsigned int ip = htonl(addr.s_addr);\n            adapter->sendMsg(new LocEngSetServerIpv4(adapter, ip, port, type));\n        }\n    } else {\n        LOC_LOGE(\"loc_eng_set_server, type %d cannot be resolved.\\n\", type);\n    }\n\n    EXIT_LOG(%d, ret);\n    return ret;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_set_server_proxy\n\nDESCRIPTION\n   If loc_eng_set_server is called before loc_eng_init, it doesn't work. This\n   proxy buffers server settings and calls loc_eng_set_server when the client is\n   open.\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data,\n                             LocServerType type,\n                             const char* hostname, int port)\n{\n    ENTRY_LOG_CALLFLOW();\n    int ret_val = 0;\n\n    LOC_LOGV(\"save the address, type: %d, hostname: %s, port: %d\",\n             (int) type, hostname, port);\n    switch (type)\n    {\n    case LOC_AGPS_SUPL_SERVER:\n        strlcpy(loc_eng_data.supl_host_buf, hostname,\n                sizeof(loc_eng_data.supl_host_buf));\n        loc_eng_data.supl_port_buf = port;\n        loc_eng_data.supl_host_set = 1;\n        break;\n    case LOC_AGPS_CDMA_PDE_SERVER:\n        strlcpy(loc_eng_data.c2k_host_buf, hostname,\n                sizeof(loc_eng_data.c2k_host_buf));\n        loc_eng_data.c2k_port_buf = port;\n        loc_eng_data.c2k_host_set = 1;\n        break;\n    default:\n        LOC_LOGE(\"loc_eng_set_server_proxy, unknown server type = %d\", (int) type);\n    }\n\n    if (NULL != loc_eng_data.adapter)\n    {\n        ret_val = loc_eng_set_server(loc_eng_data, type, hostname, port);\n    }\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_agps_ril_update_network_availability\n\nDESCRIPTION\n   Sets data call allow vs disallow flag to modem\n   This is the only member of sLocEngAGpsRilInterface implemented.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,\n                                                  int available, const char* apn)\n{\n    ENTRY_LOG_CALLFLOW();\n\n    //This is to store the status of data availability over the network.\n    //If GPS is not enabled, the INIT_CHECK will fail and the modem will\n    //not be updated with the network's availability. Since the data status\n    //can change before GPS is enabled the, storing the status will enable\n    //us to inform the modem after GPS is enabled\n    agpsStatus = available;\n\n    INIT_CHECK(loc_eng_data.adapter, return);\n    if (apn != NULL)\n    {\n        LOC_LOGD(\"loc_eng_agps_ril_update_network_availability: APN Name = [%s]\\n\", apn);\n        int apn_len = smaller_of(strlen (apn), MAX_APN_LEN);\n        LocEngAdapter* adapter = loc_eng_data.adapter;\n        adapter->sendMsg(new LocEngEnableData(adapter, apn,  apn_len, available));\n    }\n    EXIT_LOG(%s, VOID_RET);\n}\n\nint loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data,\n                                      const DerEncodedCertificate* certificates,\n                                      size_t numberOfCerts)\n{\n    ENTRY_LOG_CALLFLOW();\n    int ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS;\n\n    uint32_t slotBitMask = gps_conf.AGPS_CERT_WRITABLE_MASK;\n    uint32_t slotCount = 0;\n    for (uint32_t slotBitMaskCounter=slotBitMask; slotBitMaskCounter; slotCount++) {\n        slotBitMaskCounter &= slotBitMaskCounter - 1;\n    }\n    LOC_LOGD(\"SlotBitMask=%u SlotCount=%u NumberOfCerts=%u\",\n             slotBitMask, slotCount, numberOfCerts);\n\n    LocEngAdapter* adapter = loc_eng_data.adapter;\n\n    if (numberOfCerts == 0) {\n        LOC_LOGE(\"No certs to install, since numberOfCerts is zero\");\n        ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS;\n    } else if (!adapter) {\n        LOC_LOGE(\"adapter is null!\");\n        ret_val = AGPS_CERTIFICATE_ERROR_GENERIC;\n    } else if (slotCount < numberOfCerts) {\n        LOC_LOGE(\"Not enough cert slots (%u) to install %u certs!\",\n                 slotCount, numberOfCerts);\n        ret_val = AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES;\n    } else {\n        for (int i=0; i < numberOfCerts; ++i)\n        {\n            if (certificates[i].length > AGPS_CERTIFICATE_MAX_LENGTH) {\n                LOC_LOGE(\"cert#(%u) length of %u is too big! greater than %u\",\n                        certificates[i].length, AGPS_CERTIFICATE_MAX_LENGTH);\n                ret_val = AGPS_CERTIFICATE_ERROR_GENERIC;\n                break;\n            }\n        }\n\n        if (ret_val == AGPS_CERTIFICATE_OPERATION_SUCCESS) {\n            adapter->sendMsg(new LocEngInstallAGpsCert(adapter,\n                                                       certificates,\n                                                       numberOfCerts,\n                                                       slotBitMask));\n        }\n    }\n\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\nvoid loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data,\n                                   const char* config_data, int32_t length)\n{\n    ENTRY_LOG_CALLFLOW();\n\n    if (config_data && length > 0) {\n        loc_gps_cfg_s_type gps_conf_tmp = gps_conf;\n        UTIL_UPDATE_CONF(config_data, length, gps_conf_table);\n        LocEngAdapter* adapter = loc_eng_data.adapter;\n\n        // it is possible that HAL is not init'ed at this time\n        if (adapter) {\n            if (gps_conf_tmp.SUPL_VER != gps_conf.SUPL_VER) {\n                adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER));\n            }\n            if (gps_conf_tmp.LPP_PROFILE != gps_conf.LPP_PROFILE) {\n                adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE));\n            }\n            if (gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT != gps_conf.A_GLONASS_POS_PROTOCOL_SELECT) {\n                adapter->sendMsg(new LocEngAGlonassProtocol(adapter,\n                                                            gps_conf.A_GLONASS_POS_PROTOCOL_SELECT));\n            }\n            if (gps_conf_tmp.SUPL_MODE != gps_conf.SUPL_MODE) {\n                adapter->sendMsg(new LocEngSuplMode(adapter->getUlpProxy()));\n            }\n        }\n\n        gps_conf_tmp.SUPL_VER = gps_conf.SUPL_VER;\n        gps_conf_tmp.LPP_PROFILE = gps_conf.LPP_PROFILE;\n        gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT = gps_conf.A_GLONASS_POS_PROTOCOL_SELECT;\n        gps_conf_tmp.GPS_LOCK = gps_conf.GPS_LOCK;\n        gps_conf = gps_conf_tmp;\n    }\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_report_status\n\nDESCRIPTION\n   Reports GPS engine state to Java layer.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   N/A\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void loc_eng_report_status (loc_eng_data_s_type &loc_eng_data, GpsStatusValue status)\n{\n    ENTRY_LOG();\n    // Switch from WAIT to MUTE, for \"engine on\" or \"session begin\" event\n    if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_ENGINE_ON)\n    {\n        if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_WAIT)\n        {\n            LOC_LOGD(\"loc_eng_report_status: mute_session_state changed from WAIT to IN SESSION\");\n            loc_eng_data.mute_session_state = LOC_MUTE_SESS_IN_SESSION;\n        }\n    }\n\n    // Switch off MUTE session\n    if (loc_eng_data.mute_session_state == LOC_MUTE_SESS_IN_SESSION &&\n        (status == GPS_STATUS_SESSION_END || status == GPS_STATUS_ENGINE_OFF))\n    {\n        LOC_LOGD(\"loc_eng_report_status: mute_session_state changed from IN SESSION to NONE\");\n        loc_eng_data.mute_session_state = LOC_MUTE_SESS_NONE;\n    }\n\n    // Session End is not reported during Android navigating state\n    boolean navigating = loc_eng_data.adapter->isInSession();\n    if (status != GPS_STATUS_NONE &&\n        !(status == GPS_STATUS_SESSION_END && navigating) &&\n        !(status == GPS_STATUS_SESSION_BEGIN && !navigating))\n    {\n        if (loc_eng_data.mute_session_state != LOC_MUTE_SESS_IN_SESSION)\n        {\n            // Inform GpsLocationProvider about mNavigating status\n            loc_inform_gps_status(loc_eng_data, status);\n        }\n        else {\n            LOC_LOGD(\"loc_eng_report_status: muting the status report.\");\n        }\n    }\n\n    // Only keeps ENGINE ON/OFF in engine_status\n    if (status == GPS_STATUS_ENGINE_ON || status == GPS_STATUS_ENGINE_OFF)\n    {\n        loc_eng_data.engine_status = status;\n    }\n\n    // Only keeps SESSION BEGIN/END in fix_session_status\n    if (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_SESSION_END)\n    {\n        loc_eng_data.fix_session_status = status;\n    }\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\nFUNCTION loc_eng_handle_engine_down\n         loc_eng_handle_engine_up\n\nDESCRIPTION\n   Calls this function when it is detected that modem restart is happening.\n   Either we detected the modem is down or received modem up event.\n   This must be called from the deferred thread to avoid race condition.\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG();\n    loc_eng_ni_reset_on_engine_restart(loc_eng_data);\n    loc_eng_report_status(loc_eng_data, GPS_STATUS_ENGINE_OFF);\n    EXIT_LOG(%s, VOID_RET);\n}\n\nvoid loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG();\n    loc_eng_reinit(loc_eng_data);\n\n    loc_eng_data.adapter->requestPowerVote();\n\n    if (loc_eng_data.agps_status_cb != NULL) {\n        if (loc_eng_data.agnss_nif)\n            loc_eng_data.agnss_nif->dropAllSubscribers();\n        if (loc_eng_data.internet_nif)\n            loc_eng_data.internet_nif->dropAllSubscribers();\n\n        loc_eng_agps_reinit(loc_eng_data);\n    }\n\n    // modem is back up.  If we crashed in the middle of navigating, we restart.\n    if (loc_eng_data.adapter->isInSession()) {\n        // This sets the copy in adapter to modem\n        loc_eng_data.adapter->setInSession(false);\n        loc_eng_data.adapter->sendMsg(new LocEngStartFix(loc_eng_data.adapter));\n    }\n    EXIT_LOG(%s, VOID_RET);\n}\n\n#ifdef USE_GLIB\n/*===========================================================================\nFUNCTION set_sched_policy\n\nDESCRIPTION\n   Local copy of this function which bypasses android set_sched_policy\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic int set_sched_policy(int tid, SchedPolicy policy)\n{\n    return 0;\n}\n#endif /* USE_GLIB */\n\n/*===========================================================================\nFUNCTION    loc_eng_read_config\n\nDESCRIPTION\n   Initiates the reading of the gps config file stored in /etc dir\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_read_config(void)\n{\n    ENTRY_LOG_CALLFLOW();\n    if(configAlreadyRead == false)\n    {\n      // Initialize our defaults before reading of configuration file overwrites them.\n      loc_default_parameters();\n      // We only want to parse the conf file once. This is a good place to ensure that.\n      // In fact one day the conf file should go into context.\n      UTIL_READ_CONF(GPS_CONF_FILE, gps_conf_table);\n      UTIL_READ_CONF(SAP_CONF_FILE, sap_conf_table);\n      configAlreadyRead = true;\n    } else {\n      LOC_LOGV(\"GPS Config file has already been read\\n\");\n    }\n\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_gps_measurement_init\n\nDESCRIPTION\n   Initialize gps measurement module.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data,\n                                 GpsMeasurementCallbacks* callbacks)\n{\n    ENTRY_LOG_CALLFLOW();\n\n    STATE_CHECK((NULL == loc_eng_data.gps_measurement_cb),\n                \"gps measurement already initialized\",\n                return GPS_MEASUREMENT_ERROR_ALREADY_INIT);\n    STATE_CHECK((callbacks != NULL),\n                \"callbacks can not be NULL\",\n                return GPS_MEASUREMENT_ERROR_GENERIC);\n    STATE_CHECK(loc_eng_data.adapter,\n                \"GpsInterface must be initialized first\",\n                return GPS_MEASUREMENT_ERROR_GENERIC);\n\n    // updated the mask\n    LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT;\n    loc_eng_data.adapter->sendMsg(new LocEngUpdateRegistrationMask(\n                                                        &loc_eng_data,\n                                                        event,\n                                                        LOC_REGISTRATION_MASK_ENABLED));\n    // set up the callback\n    loc_eng_data.gps_measurement_cb = callbacks->measurement_callback;\n    LOC_LOGD (\"%s, event masks updated successfully\", __func__);\n\n    return GPS_MEASUREMENT_OPERATION_SUCCESS;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_gps_measurement_close\n\nDESCRIPTION\n   Close gps measurement module.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   N/A\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG_CALLFLOW();\n\n    INIT_CHECK(loc_eng_data.adapter, return);\n\n    // updated the mask\n    LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT;\n    loc_eng_data.adapter->sendMsg(new LocEngUpdateRegistrationMask(\n                                                          &loc_eng_data,\n                                                          event,\n                                                          LOC_REGISTRATION_MASK_DISABLED));\n    // set up the callback\n    loc_eng_data.gps_measurement_cb = NULL;\n    EXIT_LOG(%d, 0);\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng.h",
    "content": "/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_ENG_H\n#define LOC_ENG_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n// Uncomment to keep all LOG messages (LOGD, LOGI, LOGV, etc.)\n#define MAX_NUM_ATL_CONNECTIONS  2\n\n// Define boolean type to be used by libgps on loc api module\ntypedef unsigned char boolean;\n\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#ifndef FALSE\n#define FALSE 0\n#endif\n\n#include <loc.h>\n#include <loc_eng_xtra.h>\n#include <loc_eng_ni.h>\n#include <loc_eng_agps.h>\n#include <loc_cfg.h>\n#include <loc_log.h>\n#include <log_util.h>\n#include <loc_eng_agps.h>\n#include <LocEngAdapter.h>\n\n// The data connection minimal open time\n#define DATA_OPEN_MIN_TIME        1  /* sec */\n\n// The system sees GPS engine turns off after inactive for this period of time\n#define GPS_AUTO_OFF_TIME         2  /* secs */\n#define SUCCESS              TRUE\n#define FAILURE                 FALSE\n#define INVALID_ATL_CONNECTION_HANDLE -1\n\n#define MAX_XTRA_SERVER_URL_LENGTH 256\n\nenum loc_nmea_provider_e_type {\n    NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA\n    NMEA_PROVIDER_MP // Modem Processor Provider of NMEA\n};\n\nenum loc_mute_session_e_type {\n   LOC_MUTE_SESS_NONE = 0,\n   LOC_MUTE_SESS_WAIT,\n   LOC_MUTE_SESS_IN_SESSION\n};\n\n// Module data\ntypedef struct loc_eng_data_s\n{\n    LocEngAdapter                  *adapter;\n    loc_location_cb_ext            location_cb;\n    gps_status_callback            status_cb;\n    loc_sv_status_cb_ext           sv_status_cb;\n    agps_status_extended           agps_status_cb;\n    gps_nmea_callback              nmea_cb;\n    gps_ni_notify_callback         ni_notify_cb;\n    gps_set_capabilities           set_capabilities_cb;\n    gps_acquire_wakelock           acquire_wakelock_cb;\n    gps_release_wakelock           release_wakelock_cb;\n    gps_request_utc_time           request_utc_time_cb;\n    gps_measurement_callback       gps_measurement_cb;\n    boolean                        intermediateFix;\n    AGpsStatusValue                agps_status;\n    loc_eng_xtra_data_s_type       xtra_module_data;\n    loc_eng_ni_data_s_type         loc_eng_ni_data;\n\n    // AGPS state machines\n    AgpsStateMachine*              agnss_nif;\n    AgpsStateMachine*              internet_nif;\n    AgpsStateMachine*              wifi_nif;\n    //State machine for Data Services\n    AgpsStateMachine*              ds_nif;\n\n    // GPS engine status\n    GpsStatusValue                 engine_status;\n    GpsStatusValue                 fix_session_status;\n\n    // Aiding data information to be deleted, aiding data can only be deleted when GPS engine is off\n    GpsAidingData                  aiding_data_for_deletion;\n\n    // For muting session broadcast\n    loc_mute_session_e_type        mute_session_state;\n\n    // For nmea generation\n    boolean generateNmea;\n    uint32_t sv_used_mask;\n    float hdop;\n    float pdop;\n    float vdop;\n\n    // Address buffers, for addressing setting before init\n    int    supl_host_set;\n    char   supl_host_buf[101];\n    int    supl_port_buf;\n    int    c2k_host_set;\n    char   c2k_host_buf[101];\n    int    c2k_port_buf;\n    int    mpc_host_set;\n    char   mpc_host_buf[101];\n    int    mpc_port_buf;\n\n    loc_ext_parser location_ext_parser;\n    loc_ext_parser sv_ext_parser;\n} loc_eng_data_s_type;\n\n/* GPS.conf support */\n/* NOTE: the implementaiton of the parser casts number\n   fields to 32 bit. To ensure all 'n' fields working,\n   they must all be 32 bit fields. */\ntypedef struct loc_gps_cfg_s\n{\n    uint32_t       INTERMEDIATE_POS;\n    uint32_t       ACCURACY_THRES;\n    uint32_t       SUPL_VER;\n    uint32_t       SUPL_MODE;\n    uint32_t       CAPABILITIES;\n    uint32_t       LPP_PROFILE;\n    uint32_t       XTRA_VERSION_CHECK;\n    char        XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH];\n    char        XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH];\n    char        XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH];\n    uint32_t       USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL;\n    uint32_t       NMEA_PROVIDER;\n    uint32_t       GPS_LOCK;\n    uint32_t       A_GLONASS_POS_PROTOCOL_SELECT;\n    uint32_t       AGPS_CERT_WRITABLE_MASK;\n} loc_gps_cfg_s_type;\n\n/* NOTE: the implementaiton of the parser casts number\n   fields to 32 bit. To ensure all 'n' fields working,\n   they must all be 32 bit fields. */\n/* Meanwhile, *_valid fields are 8 bit fields, and 'f'\n   fields are double. Rigid as they are, it is the\n   the status quo, until the parsing mechanism is\n   change, that is. */\ntypedef struct\n{\n    uint8_t        GYRO_BIAS_RANDOM_WALK_VALID;\n    double         GYRO_BIAS_RANDOM_WALK;\n    uint32_t       SENSOR_ACCEL_BATCHES_PER_SEC;\n    uint32_t       SENSOR_ACCEL_SAMPLES_PER_BATCH;\n    uint32_t       SENSOR_GYRO_BATCHES_PER_SEC;\n    uint32_t       SENSOR_GYRO_SAMPLES_PER_BATCH;\n    uint32_t       SENSOR_ACCEL_BATCHES_PER_SEC_HIGH;\n    uint32_t       SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH;\n    uint32_t       SENSOR_GYRO_BATCHES_PER_SEC_HIGH;\n    uint32_t       SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH;\n    uint32_t       SENSOR_CONTROL_MODE;\n    uint32_t       SENSOR_USAGE;\n    uint32_t       SENSOR_ALGORITHM_CONFIG_MASK;\n    uint8_t        ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID;\n    double         ACCEL_RANDOM_WALK_SPECTRAL_DENSITY;\n    uint8_t        ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;\n    double         ANGLE_RANDOM_WALK_SPECTRAL_DENSITY;\n    uint8_t        RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;\n    double         RATE_RANDOM_WALK_SPECTRAL_DENSITY;\n    uint8_t        VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;\n    double         VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;\n    uint32_t       SENSOR_PROVIDER;\n} loc_sap_cfg_s_type;\n\nextern loc_gps_cfg_s_type gps_conf;\nextern loc_sap_cfg_s_type sap_conf;\n\n\nuint32_t getCarrierCapabilities();\n\n//loc_eng functions\nint  loc_eng_init(loc_eng_data_s_type &loc_eng_data,\n                  LocCallbacks* callbacks,\n                  LOC_API_ADAPTER_EVENT_MASK_T event,\n                  ContextBase* context);\nint  loc_eng_start(loc_eng_data_s_type &loc_eng_data);\nint  loc_eng_stop(loc_eng_data_s_type &loc_eng_data);\nvoid loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data);\nint  loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data,\n                         GpsUtcTime time, int64_t timeReference,\n                         int uncertainty);\nint  loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data,\n                             double latitude, double longitude,\n                             float accuracy);\nvoid loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data,\n                                GpsAidingData f);\nint  loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data,\n                               LocPosMode &params);\nconst void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data,\n                                  const char* name);\nint  loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data,\n                              LocServerType type, const char *hostname, int port);\nvoid loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data);\nint loc_eng_read_config(void);\n\n//loc_eng_agps functions\nvoid loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data,\n                       AGpsExtCallbacks* callbacks);\nint  loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType,\n                      const char* apn, AGpsBearerType bearerType);\nint  loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);\nint  loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);\nvoid loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,\n                                                  int avaiable, const char* apn);\nint loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data,\n                                      const DerEncodedCertificate* certificates,\n                                      size_t length);\n\n//loc_eng_xtra functions\nint  loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,\n                       GpsXtraExtCallbacks* callbacks);\nint  loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,\n                             char* data, int length);\nint  loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data);\nvoid loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data, int check);\n\n//loc_eng_ni functions\nextern void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data,\n                            GpsNiExtCallbacks *callbacks);\nextern void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,\n                               int notif_id, GpsUserResponseType user_response);\nextern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,\n                                   const GpsNiNotification *notif,\n                                   const void* passThrough);\nextern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data);\n\nvoid loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data,\n                                   const char* config_data, int32_t length);\nint loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data,\n                                 GpsMeasurementCallbacks* callbacks);\nvoid loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif // LOC_ENG_H\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_agps.cpp",
    "content": "/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_eng\"\n\n#include <loc_eng_agps.h>\n#include <loc_eng_log.h>\n#include <log_util.h>\n#include <platform_lib_includes.h>\n#include <loc_eng_dmn_conn_handler.h>\n#include <loc_eng_dmn_conn.h>\n#include <sys/time.h>\n\n//======================================================================\n// C callbacks\n//======================================================================\n\n// This is given to linked_list_add as the dealloc callback\n// data -- an instance of Subscriber\nstatic void deleteObj(void* data)\n{\n    delete (Subscriber*)data;\n}\n\n// This is given to linked_list_search() as the comparison callback\n// when the state manchine needs to process for particular subscriber\n// fromCaller -- caller provides this obj\n// fromList -- linked_list_search() function take this one from list\nstatic bool hasSubscriber(void* fromCaller, void* fromList)\n{\n    Notification* notification = (Notification*)fromCaller;\n    Subscriber* s1 = (Subscriber*)fromList;\n\n    return s1->forMe(*notification);\n}\n\n// This is gvien to linked_list_search() to notify subscriber objs\n// when the state machine needs to inform all subscribers of resource\n// status changes, e.g. when resource is GRANTED.\n// fromCaller -- caller provides this ptr to a Notification obj.\n// fromList -- linked_list_search() function take this one from list\nstatic bool notifySubscriber(void* fromCaller, void* fromList)\n{\n    Notification* notification = (Notification*)fromCaller;\n    Subscriber* s1 = (Subscriber*)fromList;\n\n    // we notify every subscriber indiscriminatively\n    // each subscriber decides if this notification is interesting.\n    return s1->notifyRsrcStatus(*notification) &&\n           // if we do not want to delete the subscriber from the\n           // the list, we must set this to false so this function\n           // returns false\n           notification->postNotifyDelete;\n}\n\n//======================================================================\n// Notification\n//======================================================================\nconst int Notification::BROADCAST_ALL = 0x80000000;\nconst int Notification::BROADCAST_ACTIVE = 0x80000001;\nconst int Notification::BROADCAST_INACTIVE = 0x80000002;\nconst unsigned char DSStateMachine::MAX_START_DATA_CALL_RETRIES = 4;\nconst unsigned int DSStateMachine::DATA_CALL_RETRY_DELAY_MSEC = 500;\n//======================================================================\n// Subscriber:  BITSubscriber / ATLSubscriber / WIFISubscriber\n//======================================================================\nbool Subscriber::forMe(Notification &notification)\n{\n    if (NULL != notification.rcver) {\n        return equals(notification.rcver);\n    } else {\n        return Notification::BROADCAST_ALL == notification.groupID ||\n            (Notification::BROADCAST_ACTIVE == notification.groupID &&\n             !isInactive()) ||\n            (Notification::BROADCAST_INACTIVE == notification.groupID &&\n             isInactive());\n    }\n}\nbool BITSubscriber::equals(const Subscriber *s) const\n{\n    BITSubscriber* bitS = (BITSubscriber*)s;\n\n    return (ID == bitS->ID &&\n            (INADDR_NONE != (unsigned int)ID ||\n             0 == strncmp(mIPv6Addr, bitS->mIPv6Addr, sizeof(mIPv6Addr))));\n}\n\nbool BITSubscriber::notifyRsrcStatus(Notification &notification)\n{\n    bool notify = forMe(notification);\n\n    if (notify) {\n        switch(notification.rsrcStatus)\n        {\n        case RSRC_UNSUBSCRIBE:\n        case RSRC_RELEASED:\n            loc_eng_dmn_conn_loc_api_server_data_conn(\n                LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,\n                GPSONE_LOC_API_IF_RELEASE_SUCCESS);\n            break;\n        case RSRC_DENIED:\n            loc_eng_dmn_conn_loc_api_server_data_conn(\n                LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,\n                GPSONE_LOC_API_IF_FAILURE);\n            break;\n        case RSRC_GRANTED:\n            loc_eng_dmn_conn_loc_api_server_data_conn(\n                LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,\n                GPSONE_LOC_API_IF_REQUEST_SUCCESS);\n            break;\n        default:\n            notify = false;\n        }\n    }\n\n    return notify;\n}\n\nbool ATLSubscriber::notifyRsrcStatus(Notification &notification)\n{\n    bool notify = forMe(notification);\n\n    if (notify) {\n        switch(notification.rsrcStatus)\n        {\n        case RSRC_UNSUBSCRIBE:\n        case RSRC_RELEASED:\n            ((LocEngAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);\n            break;\n        case RSRC_DENIED:\n        {\n            AGpsExtType type = mBackwardCompatibleMode ?\n                              AGPS_TYPE_INVALID : mStateMachine->getType();\n            ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,\n                                            (char*)mStateMachine->getAPN(),\n                                            mStateMachine->getBearer(),\n                                            type);\n        }\n            break;\n        case RSRC_GRANTED:\n        {\n            AGpsExtType type = mBackwardCompatibleMode ?\n                              AGPS_TYPE_INVALID : mStateMachine->getType();\n            ((LocEngAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,\n                                            (char*)mStateMachine->getAPN(),\n                                            mStateMachine->getBearer(),\n                                            type);\n        }\n            break;\n        default:\n            notify = false;\n        }\n    }\n\n    return notify;\n}\n\nbool WIFISubscriber::notifyRsrcStatus(Notification &notification)\n{\n    bool notify = forMe(notification);\n\n    if (notify) {\n        switch(notification.rsrcStatus)\n        {\n        case RSRC_UNSUBSCRIBE:\n            break;\n        case RSRC_RELEASED:\n            loc_eng_dmn_conn_loc_api_server_data_conn(\n                senderId,\n                GPSONE_LOC_API_IF_RELEASE_SUCCESS);\n            break;\n        case RSRC_DENIED:\n            loc_eng_dmn_conn_loc_api_server_data_conn(\n                senderId,\n                GPSONE_LOC_API_IF_FAILURE);\n            break;\n        case RSRC_GRANTED:\n            loc_eng_dmn_conn_loc_api_server_data_conn(\n                senderId,\n                GPSONE_LOC_API_IF_REQUEST_SUCCESS);\n            break;\n        default:\n            notify = false;\n        }\n    }\n\n    return notify;\n}\nbool DSSubscriber::notifyRsrcStatus(Notification &notification)\n{\n    bool notify = forMe(notification);\n    LOC_LOGD(\"DSSubscriber::notifyRsrcStatus. notify:%d \\n\",(int)(notify));\n    if(notify) {\n        switch(notification.rsrcStatus) {\n        case RSRC_UNSUBSCRIBE:\n        case RSRC_RELEASED:\n        case RSRC_DENIED:\n        case RSRC_GRANTED:\n            ((DSStateMachine *)mStateMachine)->informStatus(notification.rsrcStatus, ID);\n            break;\n        default:\n            notify = false;\n        }\n    }\n    return notify;\n}\nvoid DSSubscriber :: setInactive()\n{\n    mIsInactive = true;\n    ((DSStateMachine *)mStateMachine)->informStatus(RSRC_UNSUBSCRIBE, ID);\n}\n//======================================================================\n// AgpsState:  AgpsReleasedState / AgpsPendingState / AgpsAcquiredState\n//======================================================================\n\n// AgpsReleasedState\nclass AgpsReleasedState : public AgpsState\n{\n    friend class AgpsStateMachine;\n\n    inline AgpsReleasedState(AgpsStateMachine* stateMachine) :\n        AgpsState(stateMachine)\n    { mReleasedState = this; }\n\n    inline ~AgpsReleasedState() {}\npublic:\n    virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);\n    inline virtual char* whoami() {return (char*)\"AgpsReleasedState\";}\n};\n\nAgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)\n{\n    LOC_LOGD(\"AgpsReleasedState::onRsrcEvent; event:%d\\n\", (int)event);\n    if (mStateMachine->hasSubscribers()) {\n        LOC_LOGE(\"Error: %s subscriber list not empty!!!\", whoami());\n        // I don't know how to recover from it.  I am adding this rather\n        // for debugging purpose.\n    }\n\n    AgpsState* nextState = this;\n    switch (event)\n    {\n    case RSRC_SUBSCRIBE:\n    {\n        // no notification until we get RSRC_GRANTED\n        // but we need to add subscriber to the list\n        mStateMachine->addSubscriber((Subscriber*)data);\n        // request from connecivity service for NIF\n        //The if condition is added so that if the data call setup fails\n        //for DS State Machine, we want to retry in released state.\n        //for AGps State Machine, sendRsrcRequest() will always return success\n        if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) {\n            // move the state to PENDING\n            nextState = mPendingState;\n        }\n    }\n    break;\n\n    case RSRC_UNSUBSCRIBE:\n    {\n        // the list should really be empty, nothing to remove.\n        // but we might as well just tell the client it is\n        // unsubscribed.  False tolerance, right?\n        Subscriber* subscriber = (Subscriber*) data;\n        Notification notification(subscriber, event, false);\n        subscriber->notifyRsrcStatus(notification);\n    }\n        // break;\n    case RSRC_GRANTED:\n    case RSRC_RELEASED:\n    case RSRC_DENIED:\n    default:\n        LOC_LOGW(\"%s: unrecognized event %d\", whoami(), event);\n        // no state change.\n        break;\n    }\n\n    LOC_LOGD(\"onRsrcEvent, old state %s, new state %s, event %d\",\n             whoami(), nextState->whoami(), event);\n    return nextState;\n}\n\n// AgpsPendingState\nclass AgpsPendingState : public AgpsState\n{\n    friend class AgpsStateMachine;\n\n    inline AgpsPendingState(AgpsStateMachine* stateMachine) :\n        AgpsState(stateMachine)\n    { mPendingState = this; }\n\n    inline ~AgpsPendingState() {}\npublic:\n    virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);\n    inline virtual char* whoami() {return (char*)\"AgpsPendingState\";}\n};\n\nAgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data)\n{\n    AgpsState* nextState = this;;\n    LOC_LOGD(\"AgpsPendingState::onRsrcEvent; event:%d\\n\", (int)event);\n    switch (event)\n    {\n    case RSRC_SUBSCRIBE:\n    {\n        // already requested for NIF resource,\n        // do nothing until we get RSRC_GRANTED indication\n        // but we need to add subscriber to the list\n        mStateMachine->addSubscriber((Subscriber*)data);\n        // no state change.\n    }\n        break;\n\n    case RSRC_UNSUBSCRIBE:\n    {\n        Subscriber* subscriber = (Subscriber*) data;\n        if (subscriber->waitForCloseComplete()) {\n            subscriber->setInactive();\n        } else {\n            // auto notify this subscriber of the unsubscribe\n            Notification notification(subscriber, event, true);\n            mStateMachine->notifySubscribers(notification);\n        }\n\n        // now check if there is any subscribers left\n        if (!mStateMachine->hasSubscribers()) {\n            // no more subscribers, move to RELEASED state\n            nextState = mReleasedState;\n\n            // tell connecivity service we can release NIF\n            mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);\n        } else if (!mStateMachine->hasActiveSubscribers()) {\n            // only inactive subscribers, move to RELEASING state\n            nextState = mReleasingState;\n\n            // tell connecivity service we can release NIF\n            mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);\n        }\n    }\n    break;\n\n    case RSRC_GRANTED:\n    {\n        nextState = mAcquiredState;\n        Notification notification(Notification::BROADCAST_ACTIVE, event, false);\n        // notify all subscribers NIF resource GRANTED\n        // by setting false, we keep subscribers on the linked list\n        mStateMachine->notifySubscribers(notification);\n    }\n        break;\n\n    case RSRC_RELEASED:\n        // no state change.\n        // we are expecting either GRANTED or DENIED.  Handling RELEASED\n        // may like break our state machine in race conditions.\n        break;\n\n    case RSRC_DENIED:\n    {\n        nextState = mReleasedState;\n        Notification notification(Notification::BROADCAST_ALL, event, true);\n        // notify all subscribers NIF resource RELEASED or DENIED\n        // by setting true, we remove subscribers from the linked list\n        mStateMachine->notifySubscribers(notification);\n    }\n        break;\n\n    default:\n        LOC_LOGE(\"%s: unrecognized event %d\", whoami(), event);\n        // no state change.\n    }\n\n    LOC_LOGD(\"onRsrcEvent, old state %s, new state %s, event %d\",\n             whoami(), nextState->whoami(), event);\n    return nextState;\n}\n\n\nclass AgpsAcquiredState : public AgpsState\n{\n    friend class AgpsStateMachine;\n\n    inline AgpsAcquiredState(AgpsStateMachine* stateMachine) :\n        AgpsState(stateMachine)\n    { mAcquiredState = this; }\n\n    inline ~AgpsAcquiredState() {}\npublic:\n    virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);\n    inline virtual char* whoami() { return (char*)\"AgpsAcquiredState\"; }\n};\n\n\nAgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data)\n{\n    AgpsState* nextState = this;\n    LOC_LOGD(\"AgpsAcquiredState::onRsrcEvent; event:%d\\n\", (int)event);\n    switch (event)\n    {\n    case RSRC_SUBSCRIBE:\n    {\n        // we already have the NIF resource, simply notify subscriber\n        Subscriber* subscriber = (Subscriber*) data;\n        // we have rsrc in hand, so grant it right away\n        Notification notification(subscriber, RSRC_GRANTED, false);\n        subscriber->notifyRsrcStatus(notification);\n        // add subscriber to the list\n        mStateMachine->addSubscriber(subscriber);\n        // no state change.\n    }\n        break;\n\n    case RSRC_UNSUBSCRIBE:\n    {\n        Subscriber* subscriber = (Subscriber*) data;\n        if (subscriber->waitForCloseComplete()) {\n            subscriber->setInactive();\n        } else {\n            // auto notify this subscriber of the unsubscribe\n            Notification notification(subscriber, event, true);\n            mStateMachine->notifySubscribers(notification);\n        }\n\n        // now check if there is any subscribers left\n        if (!mStateMachine->hasSubscribers()) {\n            // no more subscribers, move to RELEASED state\n            nextState = mReleasedState;\n\n            // tell connecivity service we can release NIF\n            mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);\n        } else if (!mStateMachine->hasActiveSubscribers()) {\n            // only inactive subscribers, move to RELEASING state\n            nextState = mReleasingState;\n\n            // tell connecivity service we can release NIF\n            mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);\n        }\n    }\n        break;\n\n    case RSRC_GRANTED:\n        LOC_LOGW(\"%s: %d, RSRC_GRANTED already received\", whoami(), event);\n        // no state change.\n        break;\n\n    case RSRC_RELEASED:\n    {\n        LOC_LOGW(\"%s: %d, a force rsrc release\", whoami(), event);\n        nextState = mReleasedState;\n        Notification notification(Notification::BROADCAST_ALL, event, true);\n        // by setting true, we remove subscribers from the linked list\n        mStateMachine->notifySubscribers(notification);\n    }\n        break;\n\n    case RSRC_DENIED:\n        // no state change.\n        // we are expecting RELEASED.  Handling DENIED\n        // may like break our state machine in race conditions.\n        break;\n\n    default:\n        LOC_LOGE(\"%s: unrecognized event %d\", whoami(), event);\n        // no state change.\n    }\n\n    LOC_LOGD(\"onRsrcEvent, old state %s, new state %s, event %d\",\n             whoami(), nextState->whoami(), event);\n    return nextState;\n}\n\n// AgpsPendingState\nclass AgpsReleasingState : public AgpsState\n{\n    friend class AgpsStateMachine;\n\n    inline AgpsReleasingState(AgpsStateMachine* stateMachine) :\n        AgpsState(stateMachine)\n    { mReleasingState = this; }\n\n    inline ~AgpsReleasingState() {}\npublic:\n    virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);\n    inline virtual char* whoami() {return (char*)\"AgpsReleasingState\";}\n};\n\nAgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)\n{\n    AgpsState* nextState = this;;\n    LOC_LOGD(\"AgpsReleasingState::onRsrcEvent; event:%d\\n\", (int)event);\n\n   switch (event)\n    {\n    case RSRC_SUBSCRIBE:\n    {\n        // already requested for NIF resource,\n        // do nothing until we get RSRC_GRANTED indication\n        // but we need to add subscriber to the list\n        mStateMachine->addSubscriber((Subscriber*)data);\n        // no state change.\n    }\n        break;\n\n    case RSRC_UNSUBSCRIBE:\n    {\n        Subscriber* subscriber = (Subscriber*) data;\n        if (subscriber->waitForCloseComplete()) {\n            subscriber->setInactive();\n        } else {\n            // auto notify this subscriber of the unsubscribe\n            Notification notification(subscriber, event, true);\n            mStateMachine->notifySubscribers(notification);\n        }\n\n        // now check if there is any subscribers left\n        if (!mStateMachine->hasSubscribers()) {\n            // no more subscribers, move to RELEASED state\n            nextState = mReleasedState;\n        }\n    }\n        break;\n\n    case RSRC_DENIED:\n        // A race condition subscriber unsubscribes before AFW denies resource.\n    case RSRC_RELEASED:\n    {\n        nextState = mAcquiredState;\n        Notification notification(Notification::BROADCAST_INACTIVE, event, true);\n        // notify all subscribers that are active NIF resource RELEASE\n        // by setting false, we keep subscribers on the linked list\n        mStateMachine->notifySubscribers(notification);\n\n        if (mStateMachine->hasActiveSubscribers()) {\n            nextState = mPendingState;\n            // request from connecivity service for NIF\n            mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN);\n        } else {\n            nextState = mReleasedState;\n        }\n    }\n        break;\n\n    case RSRC_GRANTED:\n    default:\n        LOC_LOGE(\"%s: unrecognized event %d\", whoami(), event);\n        // no state change.\n    }\n\n    LOC_LOGD(\"onRsrcEvent, old state %s, new state %s, event %d\",\n             whoami(), nextState->whoami(), event);\n    return nextState;\n}\n//======================================================================\n//Servicer\n//======================================================================\nServicer* Servicer :: getServicer(servicerType type, void *cb_func)\n{\n    LOC_LOGD(\" Enter getServicer type:%d\\n\", (int)type);\n    switch(type) {\n    case servicerTypeNoCbParam:\n        return (new Servicer(cb_func));\n    case servicerTypeExt:\n        return (new ExtServicer(cb_func));\n    case servicerTypeAgps:\n        return (new AGpsServicer(cb_func));\n    default:\n        return NULL;\n    }\n}\n\nint Servicer :: requestRsrc(void *cb_data)\n{\n    callback();\n    return 0;\n}\n\nint ExtServicer :: requestRsrc(void *cb_data)\n{\n    int ret=-1;\n    LOC_LOGD(\"Enter ExtServicer :: requestRsrc\\n\");\n    ret = callbackExt(cb_data);\n    LOC_LOGD(\"Exit ExtServicer :: requestRsrc\\n\");\n    return(ret);\n}\n\nint AGpsServicer :: requestRsrc(void *cb_data)\n{\n    callbackAGps((AGpsStatus *)cb_data);\n    return 0;\n}\n\n//======================================================================\n// AgpsStateMachine\n//======================================================================\n\nAgpsStateMachine::AgpsStateMachine(servicerType servType,\n                                   void *cb_func,\n                                   AGpsExtType type,\n                                   bool enforceSingleSubscriber) :\n    mStatePtr(new AgpsReleasedState(this)),mType(type),\n    mAPN(NULL),\n    mAPNLen(0),\n    mBearer(AGPS_APN_BEARER_INVALID),\n    mEnforceSingleSubscriber(enforceSingleSubscriber),\n    mServicer(Servicer :: getServicer(servType, (void *)cb_func))\n{\n    linked_list_init(&mSubscribers);\n\n    // setting up mReleasedState\n    mStatePtr->mPendingState = new AgpsPendingState(this);\n    mStatePtr->mAcquiredState = new AgpsAcquiredState(this);\n    mStatePtr->mReleasingState = new AgpsReleasingState(this);\n\n    // setting up mAcquiredState\n    mStatePtr->mAcquiredState->mReleasedState = mStatePtr;\n    mStatePtr->mAcquiredState->mPendingState = mStatePtr->mPendingState;\n    mStatePtr->mAcquiredState->mReleasingState = mStatePtr->mReleasingState;\n\n    // setting up mPendingState\n    mStatePtr->mPendingState->mAcquiredState = mStatePtr->mAcquiredState;\n    mStatePtr->mPendingState->mReleasedState = mStatePtr;\n    mStatePtr->mPendingState->mReleasingState = mStatePtr->mReleasingState;\n\n    // setting up mReleasingState\n    mStatePtr->mReleasingState->mReleasedState = mStatePtr;\n    mStatePtr->mReleasingState->mPendingState = mStatePtr->mPendingState;\n    mStatePtr->mReleasingState->mAcquiredState = mStatePtr->mAcquiredState;\n}\n\nAgpsStateMachine::~AgpsStateMachine()\n{\n    dropAllSubscribers();\n\n    // free the 3 states.  We must read out all 3 pointers first.\n    // Otherwise we run the risk of getting pointers from already\n    // freed memory.\n    AgpsState* acquiredState = mStatePtr->mAcquiredState;\n    AgpsState* releasedState = mStatePtr->mReleasedState;\n    AgpsState* pendindState = mStatePtr->mPendingState;\n    AgpsState* releasingState = mStatePtr->mReleasingState;\n\n    delete acquiredState;\n    delete releasedState;\n    delete pendindState;\n    delete releasingState;\n    delete mServicer;\n    linked_list_destroy(&mSubscribers);\n\n    if (NULL != mAPN) {\n        delete[] mAPN;\n        mAPN = NULL;\n    }\n}\n\nvoid AgpsStateMachine::setAPN(const char* apn, unsigned int len)\n{\n    if (NULL != mAPN) {\n        delete mAPN;\n    }\n\n    if (NULL != apn) {\n        mAPN = new char[len+1];\n        memcpy(mAPN, apn, len);\n        mAPN[len] = NULL;\n\n        mAPNLen = len;\n    } else {\n        mAPN = NULL;\n        mAPNLen = 0;\n    }\n}\n\nvoid AgpsStateMachine::onRsrcEvent(AgpsRsrcStatus event)\n{\n    switch (event)\n    {\n    case RSRC_GRANTED:\n    case RSRC_RELEASED:\n    case RSRC_DENIED:\n        mStatePtr = mStatePtr->onRsrcEvent(event, NULL);\n        break;\n    default:\n        LOC_LOGW(\"AgpsStateMachine: unrecognized event %d\", event);\n        break;\n    }\n}\n\nvoid AgpsStateMachine::notifySubscribers(Notification& notification) const\n{\n    if (notification.postNotifyDelete) {\n        // just any non NULL value to get started\n        Subscriber* s = (Subscriber*)~0;\n        while (NULL != s) {\n            s = NULL;\n            // if the last param sets to true, _search will delete\n            // the node from the list for us.  But the problem is\n            // once that is done, _search returns, leaving the\n            // rest of the list unprocessed.  So we need a loop.\n            linked_list_search(mSubscribers, (void**)&s, notifySubscriber,\n                               (void*)&notification, true);\n            delete s;\n        }\n    } else {\n        // no loop needed if it the last param sets to false, which\n        // mean nothing gets deleted from the list.\n        linked_list_search(mSubscribers, NULL, notifySubscriber,\n                           (void*)&notification, false);\n    }\n}\n\nvoid AgpsStateMachine::addSubscriber(Subscriber* subscriber) const\n{\n    Subscriber* s = NULL;\n    Notification notification((const Subscriber*)subscriber);\n    linked_list_search(mSubscribers, (void**)&s,\n                       hasSubscriber, (void*)&notification, false);\n\n    if (NULL == s) {\n        linked_list_add(mSubscribers, subscriber->clone(), deleteObj);\n    }\n}\n\nint AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const\n{\n    Subscriber* s = NULL;\n    Notification notification(Notification::BROADCAST_ACTIVE);\n    linked_list_search(mSubscribers, (void**)&s, hasSubscriber,\n                       (void*)&notification, false);\n\n    if ((NULL == s) == (GPS_RELEASE_AGPS_DATA_CONN == action)) {\n        AGpsExtStatus nifRequest;\n        nifRequest.size = sizeof(nifRequest);\n        nifRequest.type = mType;\n        nifRequest.status = action;\n\n        if (s == NULL) {\n            nifRequest.ipv4_addr = INADDR_NONE;\n            memset(&nifRequest.addr, 0,  sizeof(nifRequest.addr));\n            nifRequest.ssid[0] = '\\0';\n            nifRequest.password[0] = '\\0';\n        } else {\n            s->setIPAddresses(nifRequest.addr);\n            s->setWifiInfo(nifRequest.ssid, nifRequest.password);\n        }\n\n        CALLBACK_LOG_CALLFLOW(\"agps_cb\", %s, loc_get_agps_status_name(action));\n        mServicer->requestRsrc((void *)&nifRequest);\n    }\n    return 0;\n}\n\nvoid AgpsStateMachine::subscribeRsrc(Subscriber *subscriber)\n{\n  if (mEnforceSingleSubscriber && hasSubscribers()) {\n      Notification notification(Notification::BROADCAST_ALL, RSRC_DENIED, true);\n      notifySubscriber(&notification, subscriber);\n  } else {\n      mStatePtr = mStatePtr->onRsrcEvent(RSRC_SUBSCRIBE, (void*)subscriber);\n  }\n}\n\nbool AgpsStateMachine::unsubscribeRsrc(Subscriber *subscriber)\n{\n    Subscriber* s = NULL;\n    Notification notification((const Subscriber*)subscriber);\n    linked_list_search(mSubscribers, (void**)&s,\n                       hasSubscriber, (void*)&notification, false);\n\n    if (NULL != s) {\n        mStatePtr = mStatePtr->onRsrcEvent(RSRC_UNSUBSCRIBE, (void*)s);\n        return true;\n    }\n    return false;\n}\n\nbool AgpsStateMachine::hasActiveSubscribers() const\n{\n    Subscriber* s = NULL;\n    Notification notification(Notification::BROADCAST_ACTIVE);\n    linked_list_search(mSubscribers, (void**)&s,\n                       hasSubscriber, (void*)&notification, false);\n    return NULL != s;\n}\n\n//======================================================================\n// DSStateMachine\n//======================================================================\nvoid delay_callback(void *callbackData, int result)\n{\n    if(callbackData) {\n        DSStateMachine *DSSMInstance = (DSStateMachine *)callbackData;\n        DSSMInstance->retryCallback();\n    }\n    else {\n        LOC_LOGE(\" NULL argument received. Failing.\\n\");\n        goto err;\n    }\nerr:\n    return;\n}\n\nDSStateMachine :: DSStateMachine(servicerType type, void *cb_func,\n                                 LocEngAdapter* adapterHandle):\n    AgpsStateMachine(type, cb_func, AGPS_TYPE_INVALID,false),\n    mLocAdapter(adapterHandle)\n{\n    LOC_LOGD(\"%s:%d]: New DSStateMachine\\n\", __func__, __LINE__);\n    mRetries = 0;\n}\n\nvoid DSStateMachine :: retryCallback(void)\n{\n    DSSubscriber *subscriber = NULL;\n    Notification notification(Notification::BROADCAST_ACTIVE);\n    linked_list_search(mSubscribers, (void**)&subscriber, hasSubscriber,\n                       (void*)&notification, false);\n    if(subscriber)\n        mLocAdapter->requestSuplES(subscriber->ID);\n    else\n        LOC_LOGE(\"DSStateMachine :: retryCallback: No subscriber found.\" \\\n                 \"Cannot retry data call\\n\");\n    return;\n}\n\nint DSStateMachine :: sendRsrcRequest(AGpsStatusValue action) const\n{\n    DSSubscriber* s = NULL;\n    dsCbData cbData;\n    int ret=-1;\n    int connHandle=-1;\n    LOC_LOGD(\"Enter DSStateMachine :: sendRsrcRequest\\n\");\n    Notification notification(Notification::BROADCAST_ACTIVE);\n    linked_list_search(mSubscribers, (void**)&s, hasSubscriber,\n                       (void*)&notification, false);\n    if(s) {\n        connHandle = s->ID;\n        LOC_LOGD(\"DSStateMachine :: sendRsrcRequest - subscriber found\\n\");\n    }\n    else\n        LOC_LOGD(\"DSStateMachine :: sendRsrcRequest - No subscriber found\\n\");\n\n    cbData.action = action;\n    cbData.mAdapter = mLocAdapter;\n    ret = mServicer->requestRsrc((void *)&cbData);\n    //Only the request to start data call returns a success/failure\n    //The request to stop data call will always succeed\n    //Hence, the below block will only be executed when the\n    //request to start the data call fails\n    switch(ret) {\n    case LOC_API_ADAPTER_ERR_ENGINE_BUSY:\n        LOC_LOGD(\"DSStateMachine :: sendRsrcRequest - Failure returned: %d\\n\",ret);\n        ((DSStateMachine *)this)->incRetries();\n        if(mRetries > MAX_START_DATA_CALL_RETRIES) {\n            LOC_LOGE(\" Failed to start Data call. Fallback to normal ATL SUPL\\n\");\n            informStatus(RSRC_DENIED, connHandle);\n        }\n        else {\n            if(loc_timer_start(DATA_CALL_RETRY_DELAY_MSEC, delay_callback, (void *)this)) {\n                LOC_LOGE(\"Error: Could not start delay thread\\n\");\n                ret = -1;\n                goto err;\n            }\n        }\n        break;\n    case LOC_API_ADAPTER_ERR_UNSUPPORTED:\n        LOC_LOGE(\"No profile found for emergency call. Fallback to normal SUPL ATL\\n\");\n        informStatus(RSRC_DENIED, connHandle);\n        break;\n    case LOC_API_ADAPTER_ERR_SUCCESS:\n        LOC_LOGD(\"%s:%d]: Request to start data call sent\\n\", __func__, __LINE__);\n        break;\n    case -1:\n        //One of the ways this case can be encountered is if the callback function\n        //receives a null argument, it just exits with -1 error\n        LOC_LOGE(\"Error: Something went wrong somewhere. Falling back to normal SUPL ATL\\n\");\n        informStatus(RSRC_DENIED, connHandle);\n        break;\n    default:\n        LOC_LOGE(\"%s:%d]: Unrecognized return value\\n\", __func__, __LINE__);\n    }\nerr:\n    LOC_LOGD(\"EXIT DSStateMachine :: sendRsrcRequest; ret = %d\\n\", ret);\n    return ret;\n}\n\nvoid DSStateMachine :: onRsrcEvent(AgpsRsrcStatus event)\n{\n    void* currState = (void *)mStatePtr;\n    LOC_LOGD(\"Enter DSStateMachine :: onRsrcEvent. event = %d\\n\", (int)event);\n    switch (event)\n    {\n    case RSRC_GRANTED:\n        LOC_LOGD(\"DSStateMachine :: onRsrcEvent RSRC_GRANTED\\n\");\n        mStatePtr = mStatePtr->onRsrcEvent(event, NULL);\n        break;\n    case RSRC_RELEASED:\n        LOC_LOGD(\"DSStateMachine :: onRsrcEvent RSRC_RELEASED\\n\");\n        mStatePtr = mStatePtr->onRsrcEvent(event, NULL);\n        //To handle the case where we get a RSRC_RELEASED in\n        //pending state, we translate that to a RSRC_DENIED state\n        //since the callback from DSI is either RSRC_GRANTED or RSRC_RELEASED\n        //for when the call is connected or disconnected respectively.\n        if((void *)mStatePtr != currState)\n            break;\n        else {\n            event = RSRC_DENIED;\n            LOC_LOGE(\" Switching event to RSRC_DENIED\\n\");\n        }\n    case RSRC_DENIED:\n        mStatePtr = mStatePtr->onRsrcEvent(event, NULL);\n        break;\n    default:\n        LOC_LOGW(\"AgpsStateMachine: unrecognized event %d\", event);\n        break;\n    }\n    LOC_LOGD(\"Exit DSStateMachine :: onRsrcEvent. event = %d\\n\", (int)event);\n}\n\nvoid DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const\n{\n    LOC_LOGD(\"DSStateMachine :: informStatus. Status=%d\\n\",(int)status);\n    switch(status) {\n    case RSRC_UNSUBSCRIBE:\n        mLocAdapter->atlCloseStatus(ID, 1);\n        break;\n    case RSRC_RELEASED:\n        mLocAdapter->closeDataCall();\n        break;\n    case RSRC_DENIED:\n        ((DSStateMachine *)this)->mRetries = 0;\n        mLocAdapter->requestATL(ID, AGPS_TYPE_SUPL);\n        break;\n    case RSRC_GRANTED:\n        mLocAdapter->atlOpenStatus(ID, 1,\n                                                     NULL,\n                                                     AGPS_APN_BEARER_INVALID,\n                                                     AGPS_TYPE_INVALID);\n        break;\n    default:\n        LOC_LOGW(\"DSStateMachine :: informStatus - unknown status\");\n    }\n    return;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_agps.h",
    "content": "/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef __LOC_ENG_AGPS_H__\n#define __LOC_ENG_AGPS_H__\n\n#include <stdbool.h>\n#include <ctype.h>\n#include <string.h>\n#include <arpa/inet.h>\n#include <hardware/gps.h>\n#include <gps_extended.h>\n#include <loc_core_log.h>\n#include <linked_list.h>\n#include <loc_timer.h>\n#include <LocEngAdapter.h>\n\n// forward declaration\nclass AgpsStateMachine;\nclass Subscriber;\n\n// NIF resource events\ntypedef enum {\n    RSRC_SUBSCRIBE,\n    RSRC_UNSUBSCRIBE,\n    RSRC_GRANTED,\n    RSRC_RELEASED,\n    RSRC_DENIED,\n    RSRC_STATUS_MAX\n} AgpsRsrcStatus;\n\ntypedef enum {\n    servicerTypeNoCbParam,\n    servicerTypeAgps,\n    servicerTypeExt\n}servicerType;\n\n//DS Callback struct\ntypedef struct {\n    LocEngAdapter *mAdapter;\n    AGpsStatusValue action;\n}dsCbData;\n\n// information bundle for subscribers\nstruct Notification {\n    // goes to every subscriber\n    static const int BROADCAST_ALL;\n    // goes to every ACTIVE subscriber\n    static const int BROADCAST_ACTIVE;\n    // goes to every INACTIVE subscriber\n    static const int BROADCAST_INACTIVE;\n\n    // go to a specific subscriber\n    const Subscriber* rcver;\n    // broadcast\n    const int groupID;\n    // the new resource status event\n    const AgpsRsrcStatus rsrcStatus;\n    // should the subscriber be deleted after the notification\n    const bool postNotifyDelete;\n\n    // convenient constructor\n    inline Notification(const int broadcast,\n                        const AgpsRsrcStatus status,\n                        const bool deleteAfterwards) :\n        rcver(NULL), groupID(broadcast), rsrcStatus(status),\n        postNotifyDelete(deleteAfterwards) {}\n\n    // convenient constructor\n    inline Notification(const Subscriber* subscriber,\n                        const AgpsRsrcStatus status,\n                        const bool deleteAfterwards) :\n        rcver(subscriber), groupID(-1), rsrcStatus(status),\n        postNotifyDelete(deleteAfterwards) {}\n\n    // convenient constructor\n    inline Notification(const int broadcast) :\n        rcver(NULL), groupID(broadcast), rsrcStatus(RSRC_STATUS_MAX),\n        postNotifyDelete(false) {}\n\n    // convenient constructor\n    inline Notification(const Subscriber* subscriber) :\n        rcver(subscriber), groupID(-1), rsrcStatus(RSRC_STATUS_MAX),\n        postNotifyDelete(false) {}\n};\n\nclass AgpsState {\n    // allows AgpsStateMachine to access private data\n    // no class members are public.  We don't want\n    // anyone but state machine to use state.\n    friend class AgpsStateMachine;\n    friend class DSStateMachine;\n    // state transitions are done here.\n    // Each state implements its own transitions (of course).\n    inline virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data) = 0;\n\nprotected:\n    // handle back to state machine\n    const AgpsStateMachine* mStateMachine;\n    // each state has pointers to all 3 states\n    // one of which is to itself.\n    AgpsState* mReleasedState;\n    AgpsState* mAcquiredState;\n    AgpsState* mPendingState;\n    AgpsState* mReleasingState;\n\n    inline AgpsState(const AgpsStateMachine *stateMachine) :\n        mStateMachine(stateMachine),\n        mReleasedState(NULL),\n        mAcquiredState(NULL),\n        mPendingState(NULL),\n        mReleasingState(NULL) {}\n    virtual ~AgpsState() {}\n\npublic:\n    // for logging purpose\n    inline virtual char* whoami() = 0;\n};\n\nclass Servicer {\n    void (*callback)(void);\npublic:\n    static Servicer* getServicer(servicerType type, void *cb_func);\n    virtual int requestRsrc(void *cb_data);\n    Servicer() {}\n    Servicer(void *cb_func)\n    { callback = (void(*)(void))(cb_func); }\n    virtual ~Servicer(){}\n    inline virtual char *whoami() {return (char*)\"Servicer\";}\n};\n\nclass ExtServicer : public Servicer {\n    int (*callbackExt)(void *cb_data);\npublic:\n    int requestRsrc(void *cb_data);\n    ExtServicer() {}\n    ExtServicer(void *cb_func)\n    { callbackExt = (int(*)(void *))(cb_func); }\n    virtual ~ExtServicer(){}\n    inline virtual char *whoami() {return (char*)\"ExtServicer\";}\n};\n\nclass AGpsServicer : public Servicer {\n    void (*callbackAGps)(AGpsStatus* status);\npublic:\n    int requestRsrc(void *cb_data);\n    AGpsServicer() {}\n    AGpsServicer(void *cb_func)\n    { callbackAGps = (void(*)(AGpsStatus *))(cb_func); }\n    virtual ~AGpsServicer(){}\n    inline virtual char *whoami() {return (char*)\"AGpsServicer\";}\n};\n\nclass AgpsStateMachine {\nprotected:\n    // a linked list of subscribers.\n    void* mSubscribers;\n    //handle to whoever provides the service\n    Servicer *mServicer;\n    // allows AgpsState to access private data\n    // each state is really internal data to the\n    // state machine, so it should be able to\n    // access anything within the state machine.\n    friend class AgpsState;\n    // pointer to the current state.\n    AgpsState* mStatePtr;\nprivate:\n    // NIF type: AGNSS or INTERNET.\n    const AGpsExtType mType;\n    // apn to the NIF.  Each state machine tracks\n    // resource state of a particular NIF.  For each\n    // NIF, there is also an active APN.\n    char* mAPN;\n    // for convenience, we don't do strlen each time.\n    unsigned int mAPNLen;\n    // bear\n    AGpsBearerType mBearer;\n    // ipv4 address for routing\n    bool mEnforceSingleSubscriber;\n\npublic:\n    AgpsStateMachine(servicerType servType, void *cb_func,\n                     AGpsExtType type, bool enforceSingleSubscriber);\n    virtual ~AgpsStateMachine();\n\n    // self explanatory methods below\n    void setAPN(const char* apn, unsigned int len);\n    inline const char* getAPN() const { return (const char*)mAPN; }\n    inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; }\n    inline AGpsBearerType getBearer() const { return mBearer; }\n    inline AGpsExtType getType() const { return (AGpsExtType)mType; }\n\n    // someone, a ATL client or BIT, is asking for NIF\n    void subscribeRsrc(Subscriber *subscriber);\n\n    // someone, a ATL client or BIT, is done with NIF\n    bool unsubscribeRsrc(Subscriber *subscriber);\n\n    // add a subscriber in the linked list, if not already there.\n    void addSubscriber(Subscriber* subscriber) const;\n\n    virtual void onRsrcEvent(AgpsRsrcStatus event);\n\n    // put the data together and send the FW\n    virtual int sendRsrcRequest(AGpsStatusValue action) const;\n\n    //if list is empty, linked_list_empty returns 1\n    //else if list is not empty, returns 0\n    //so hasSubscribers() returns 1 if list is not empty\n    //and returns 0 if list is empty\n    inline bool hasSubscribers() const\n    { return !linked_list_empty(mSubscribers); }\n\n    bool hasActiveSubscribers() const;\n\n    inline void dropAllSubscribers() const\n    { linked_list_flush(mSubscribers); }\n\n    // private. Only a state gets to call this.\n    void notifySubscribers(Notification& notification) const;\n\n};\n\nclass DSStateMachine : public AgpsStateMachine {\n    static const unsigned char MAX_START_DATA_CALL_RETRIES;\n    static const unsigned int DATA_CALL_RETRY_DELAY_MSEC;\n    LocEngAdapter* mLocAdapter;\n    unsigned char mRetries;\npublic:\n    DSStateMachine(servicerType type,\n                   void *cb_func,\n                   LocEngAdapter* adapterHandle);\n    int sendRsrcRequest(AGpsStatusValue action) const;\n    void onRsrcEvent(AgpsRsrcStatus event);\n    void retryCallback();\n    void informStatus(AgpsRsrcStatus status, int ID) const;\n    inline void incRetries() {mRetries++;}\n    inline virtual char *whoami() {return (char*)\"DSStateMachine\";}\n};\n\n// each subscriber is a AGPS client.  In the case of ATL, there could be\n// multiple clients from modem.  In the case of BIT, there is only one\n// cilent from BIT daemon.\nstruct Subscriber {\n    const uint32_t ID;\n    const AgpsStateMachine* mStateMachine;\n    inline Subscriber(const int id,\n                      const AgpsStateMachine* stateMachine) :\n        ID(id), mStateMachine(stateMachine) {}\n    inline virtual ~Subscriber() {}\n\n    virtual void setIPAddresses(uint32_t &v4, char* v6) = 0;\n    virtual void setIPAddresses(struct sockaddr_storage& addr) = 0;\n    inline virtual void setWifiInfo(char* ssid, char* password)\n    { ssid[0] = 0; password[0] = 0; }\n\n    inline virtual bool equals(const Subscriber *s) const\n    { return ID == s->ID; }\n\n    // notifies a subscriber a new NIF resource status, usually\n    // either GRANTE, DENIED, or RELEASED\n    virtual bool notifyRsrcStatus(Notification &notification) = 0;\n\n    virtual bool waitForCloseComplete() { return false; }\n    virtual void setInactive() {}\n    virtual bool isInactive() { return false; }\n\n    virtual Subscriber* clone() = 0;\n    // checks if this notification is for me, i.e.\n    // either has my id, or has a broadcast id.\n    bool forMe(Notification &notification);\n};\n\n// BITSubscriber, created with requests from BIT daemon\nstruct BITSubscriber : public Subscriber {\n    char mIPv6Addr[16];\n\n    inline BITSubscriber(const AgpsStateMachine* stateMachine,\n                         unsigned int ipv4, char* ipv6) :\n        Subscriber(ipv4, stateMachine)\n    {\n        if (NULL == ipv6) {\n            mIPv6Addr[0] = 0;\n        } else {\n            memcpy(mIPv6Addr, ipv6, sizeof(mIPv6Addr));\n        }\n    }\n\n    virtual bool notifyRsrcStatus(Notification &notification);\n\n    inline virtual void setIPAddresses(uint32_t &v4, char* v6)\n    { v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); }\n\n    inline virtual void setIPAddresses(struct sockaddr_storage& addr)\n    { addr.ss_family = AF_INET6;/*todo: convert mIPv6Addr into addr */ }\n\n    virtual Subscriber* clone()\n    {\n        return new BITSubscriber(mStateMachine, ID, mIPv6Addr);\n    }\n\n    virtual bool equals(const Subscriber *s) const;\n    inline virtual ~BITSubscriber(){}\n};\n\n// ATLSubscriber, created with requests from ATL\nstruct ATLSubscriber : public Subscriber {\n    const LocEngAdapter* mLocAdapter;\n    const bool mBackwardCompatibleMode;\n    inline ATLSubscriber(const int id,\n                         const AgpsStateMachine* stateMachine,\n                         const LocEngAdapter* adapter,\n                         const bool compatibleMode) :\n        Subscriber(id, stateMachine), mLocAdapter(adapter),\n        mBackwardCompatibleMode(compatibleMode){}\n    virtual bool notifyRsrcStatus(Notification &notification);\n\n    inline virtual void setIPAddresses(uint32_t &v4, char* v6)\n    { v4 = INADDR_NONE; v6[0] = 0; }\n\n    inline virtual void setIPAddresses(struct sockaddr_storage& addr)\n    { addr.ss_family = AF_INET6; }\n\n    inline virtual Subscriber* clone()\n    {\n        return new ATLSubscriber(ID, mStateMachine, mLocAdapter,\n                                 mBackwardCompatibleMode);\n    }\n    inline virtual ~ATLSubscriber(){}\n};\n\n// WIFISubscriber, created with requests from MSAPM or QuIPC\nstruct WIFISubscriber : public Subscriber {\n    char * mSSID;\n    char * mPassword;\n    loc_if_req_sender_id_e_type senderId;\n    bool mIsInactive;\n    inline WIFISubscriber(const AgpsStateMachine* stateMachine,\n                         char * ssid, char * password, loc_if_req_sender_id_e_type sender_id) :\n        Subscriber(sender_id, stateMachine),\n        mSSID(NULL == ssid ? NULL : new char[SSID_BUF_SIZE]),\n        mPassword(NULL == password ? NULL : new char[SSID_BUF_SIZE]),\n        senderId(sender_id)\n    {\n      if (NULL != mSSID)\n          strlcpy(mSSID, ssid, SSID_BUF_SIZE);\n      if (NULL != mPassword)\n          strlcpy(mPassword, password, SSID_BUF_SIZE);\n      mIsInactive = false;\n    }\n\n    virtual bool notifyRsrcStatus(Notification &notification);\n\n    inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}\n\n    inline virtual void setIPAddresses(struct sockaddr_storage& addr)\n    { addr.ss_family = AF_INET6; }\n\n    inline virtual void setWifiInfo(char* ssid, char* password)\n    {\n      if (NULL != mSSID)\n          strlcpy(ssid, mSSID, SSID_BUF_SIZE);\n      else\n          ssid[0] = '\\0';\n      if (NULL != mPassword)\n          strlcpy(password, mPassword, SSID_BUF_SIZE);\n      else\n          password[0] = '\\0';\n    }\n\n    inline virtual bool waitForCloseComplete() { return true; }\n\n    inline virtual void setInactive() { mIsInactive = true; }\n    inline virtual bool isInactive() { return mIsInactive; }\n\n    virtual Subscriber* clone()\n    {\n        return new WIFISubscriber(mStateMachine, mSSID, mPassword, senderId);\n    }\n    inline virtual ~WIFISubscriber(){}\n};\n\nstruct DSSubscriber : public Subscriber {\n    bool mIsInactive;\n    inline DSSubscriber(const AgpsStateMachine *stateMachine,\n                         const int id) :\n        Subscriber(id, stateMachine)\n    {\n        mIsInactive = false;\n    }\n    inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}\n    inline virtual void setIPAddresses(struct sockaddr_storage& addr)\n    { addr.ss_family = AF_INET6; }\n    virtual Subscriber* clone()\n    {return new DSSubscriber(mStateMachine, ID);}\n    virtual bool notifyRsrcStatus(Notification &notification);\n    inline virtual bool waitForCloseComplete() { return true; }\n    virtual void setInactive();\n    inline virtual bool isInactive()\n    { return mIsInactive; }\n    inline virtual ~DSSubscriber(){}\n    inline virtual char *whoami() {return (char*)\"DSSubscriber\";}\n};\n\n#endif //__LOC_ENG_AGPS_H__\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.cpp",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <linux/stat.h>\n#include <fcntl.h>\n#include <linux/types.h>\n#include <unistd.h>\n#include <errno.h>\n#include <grp.h>\n#include <sys/stat.h>\n\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n#include \"loc_eng_dmn_conn_glue_msg.h\"\n#include \"loc_eng_dmn_conn_handler.h\"\n#include \"loc_eng_dmn_conn.h\"\n#include \"loc_eng_msg.h\"\n\nstatic int loc_api_server_msgqid;\nstatic int loc_api_resp_msgqid;\nstatic int quipc_msgqid;\nstatic int msapm_msgqid;\nstatic int msapu_msgqid;\n\nstatic const char * global_loc_api_q_path = GPSONE_LOC_API_Q_PATH;\nstatic const char * global_loc_api_resp_q_path = GPSONE_LOC_API_RESP_Q_PATH;\nstatic const char * global_quipc_ctrl_q_path = QUIPC_CTRL_Q_PATH;\nstatic const char * global_msapm_ctrl_q_path = MSAPM_CTRL_Q_PATH;\nstatic const char * global_msapu_ctrl_q_path = MSAPU_CTRL_Q_PATH;\n\nstatic int loc_api_server_proc_init(void *context)\n{\n    loc_api_server_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_q_path, O_RDWR);\n    //change mode/group for the global_loc_api_q_path pipe\n    int result = chmod (global_loc_api_q_path, 0660);\n    if (result != 0)\n    {\n        LOC_LOGE(\"failed to change mode for %s, error = %s\\n\", global_loc_api_q_path, strerror(errno));\n    }\n\n    struct group * gps_group = getgrnam(\"gps\");\n    if (gps_group != NULL)\n    {\n       result = chown (global_loc_api_q_path, -1, gps_group->gr_gid);\n       if (result != 0)\n       {\n          LOC_LOGE(\"chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\\n\",\n                   global_loc_api_q_path, gps_group->gr_gid, result, strerror(errno));\n       }\n    }\n    else\n    {\n       LOC_LOGE(\"getgrnam for gps failed, error code = %d\\n\",  errno);\n    }\n\n    loc_api_resp_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_resp_q_path, O_RDWR);\n\n    //change mode/group for the global_loc_api_resp_q_path pipe\n    result = chmod (global_loc_api_resp_q_path, 0660);\n    if (result != 0)\n    {\n        LOC_LOGE(\"failed to change mode for %s, error = %s\\n\", global_loc_api_resp_q_path, strerror(errno));\n    }\n\n    if (gps_group != NULL)\n    {\n       result = chown (global_loc_api_resp_q_path, -1, gps_group->gr_gid);\n       if (result != 0)\n       {\n          LOC_LOGE(\"chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\\n\",\n                   global_loc_api_resp_q_path,\n                   gps_group->gr_gid, result, strerror(errno));\n       }\n    }\n\n    quipc_msgqid = loc_eng_dmn_conn_glue_msgget(global_quipc_ctrl_q_path, O_RDWR);\n    msapm_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapm_ctrl_q_path , O_RDWR);\n    msapu_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapu_ctrl_q_path , O_RDWR);\n\n    LOC_LOGD(\"%s:%d] loc_api_server_msgqid = %d\\n\", __func__, __LINE__, loc_api_server_msgqid);\n    return 0;\n}\n\nstatic int loc_api_server_proc_pre(void *context)\n{\n    return 0;\n}\n\nstatic int loc_api_server_proc(void *context)\n{\n    int length, sz;\n    int result = 0;\n    static int cnt = 0;\n    struct ctrl_msgbuf * p_cmsgbuf;\n    struct ctrl_msgbuf cmsg_resp;\n\n    sz = sizeof(struct ctrl_msgbuf) + 256;\n    p_cmsgbuf = (struct ctrl_msgbuf *) malloc(sz);\n\n    if (!p_cmsgbuf) {\n        LOC_LOGE(\"%s:%d] Out of memory\\n\", __func__, __LINE__);\n        return -1;\n    }\n\n    cnt ++;\n    LOC_LOGD(\"%s:%d] %d listening on %s...\\n\", __func__, __LINE__, cnt, (char *) context);\n    length = loc_eng_dmn_conn_glue_msgrcv(loc_api_server_msgqid, p_cmsgbuf, sz);\n    if (length <= 0) {\n        free(p_cmsgbuf);\n        LOC_LOGE(\"%s:%d] fail receiving msg from gpsone_daemon, retry later\\n\", __func__, __LINE__);\n        usleep(1000);\n        return -1;\n    }\n\n    LOC_LOGD(\"%s:%d] received ctrl_type = %d\\n\", __func__, __LINE__, p_cmsgbuf->ctrl_type);\n    switch(p_cmsgbuf->ctrl_type) {\n        case GPSONE_LOC_API_IF_REQUEST:\n            result = loc_eng_dmn_conn_loc_api_server_if_request_handler(p_cmsgbuf, length);\n            break;\n\n        case GPSONE_LOC_API_IF_RELEASE:\n            result = loc_eng_dmn_conn_loc_api_server_if_release_handler(p_cmsgbuf, length);\n            break;\n\n        case GPSONE_UNBLOCK:\n            LOC_LOGD(\"%s:%d] GPSONE_UNBLOCK\\n\", __func__, __LINE__);\n            break;\n\n        default:\n            LOC_LOGE(\"%s:%d] unsupported ctrl_type = %d\\n\",\n                __func__, __LINE__, p_cmsgbuf->ctrl_type);\n            break;\n    }\n\n    free(p_cmsgbuf);\n    return 0;\n}\n\nstatic int loc_api_server_proc_post(void *context)\n{\n    LOC_LOGD(\"%s:%d]\\n\", __func__, __LINE__);\n    loc_eng_dmn_conn_glue_msgremove( global_loc_api_q_path, loc_api_server_msgqid);\n    loc_eng_dmn_conn_glue_msgremove( global_loc_api_resp_q_path, loc_api_resp_msgqid);\n    loc_eng_dmn_conn_glue_msgremove( global_quipc_ctrl_q_path, quipc_msgqid);\n    loc_eng_dmn_conn_glue_msgremove( global_msapm_ctrl_q_path, msapm_msgqid);\n    loc_eng_dmn_conn_glue_msgremove( global_msapu_ctrl_q_path, msapu_msgqid);\n    return 0;\n}\n\nstatic int loc_eng_dmn_conn_unblock_proc(void)\n{\n    struct ctrl_msgbuf cmsgbuf;\n    cmsgbuf.ctrl_type = GPSONE_UNBLOCK;\n    LOC_LOGD(\"%s:%d]\\n\", __func__, __LINE__);\n    loc_eng_dmn_conn_glue_msgsnd(loc_api_server_msgqid, & cmsgbuf, sizeof(cmsgbuf));\n    return 0;\n}\n\nstatic struct loc_eng_dmn_conn_thelper thelper;\n\nint loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread   create_thread_cb,\n    const char * loc_api_q_path, const char * resp_q_path, void *agps_handle)\n{\n    int result;\n\n    loc_api_handle = agps_handle;\n\n    if (loc_api_q_path) global_loc_api_q_path = loc_api_q_path;\n    if (resp_q_path)    global_loc_api_resp_q_path = resp_q_path;\n\n    result = loc_eng_dmn_conn_launch_thelper( &thelper,\n        loc_api_server_proc_init,\n        loc_api_server_proc_pre,\n        loc_api_server_proc,\n        loc_api_server_proc_post,\n        create_thread_cb,\n        (char *) global_loc_api_q_path);\n    if (result != 0) {\n        LOC_LOGE(\"%s:%d]\\n\", __func__, __LINE__);\n        return -1;\n    }\n    return 0;\n}\n\nint loc_eng_dmn_conn_loc_api_server_unblock(void)\n{\n    loc_eng_dmn_conn_unblock_thelper(&thelper);\n    loc_eng_dmn_conn_unblock_proc();\n    return 0;\n}\n\nint loc_eng_dmn_conn_loc_api_server_join(void)\n{\n    loc_eng_dmn_conn_join_thelper(&thelper);\n    return 0;\n}\n\nint loc_eng_dmn_conn_loc_api_server_data_conn(int sender_id, int status) {\n  struct ctrl_msgbuf cmsgbuf;\n  LOC_LOGD(\"%s:%d] quipc_msgqid = %d\\n\", __func__, __LINE__, quipc_msgqid);\n  cmsgbuf.ctrl_type = GPSONE_LOC_API_RESPONSE;\n  cmsgbuf.cmsg.cmsg_response.result = status;\n  switch (sender_id) {\n    case LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC: {\n      LOC_LOGD(\"%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC\", __func__, __LINE__);\n      if (loc_eng_dmn_conn_glue_msgsnd(quipc_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {\n        LOC_LOGD(\"%s:%d] error! conn_glue_msgsnd failed\\n\", __func__, __LINE__);\n        return -1;\n      }\n      break;\n    }\n    case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM: {\n      LOC_LOGD(\"%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM\", __func__, __LINE__);\n      if (loc_eng_dmn_conn_glue_msgsnd(msapm_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {\n        LOC_LOGD(\"%s:%d] error! conn_glue_msgsnd failed\\n\", __func__, __LINE__);\n        return -1;\n      }\n      break;\n    }\n    case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU: {\n      LOC_LOGD(\"%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU\", __func__, __LINE__);\n      if (loc_eng_dmn_conn_glue_msgsnd(msapu_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {\n        LOC_LOGD(\"%s:%d] error! conn_glue_msgsnd failed\\n\", __func__, __LINE__);\n        return -1;\n      }\n      break;\n    }\n    case LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON: {\n      LOC_LOGD(\"%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON\", __func__, __LINE__);\n      if (loc_eng_dmn_conn_glue_msgsnd(loc_api_resp_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {\n        LOC_LOGD(\"%s:%d] error! conn_glue_msgsnd failed\\n\", __func__, __LINE__);\n        return -1;\n      }\n      break;\n    }\n    default: {\n      LOC_LOGD(\"%s:%d] invalid sender ID!\", __func__, __LINE__);\n    }\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn.h",
    "content": "/* Copyright (c) 2011-2012,2014 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_ENG_DATA_SERVER_H\n#define LOC_ENG_DATA_SERVER_H\n\n#include \"loc_eng_dmn_conn_thread_helper.h\"\n\n#ifdef _ANDROID_\n\n#define GPSONE_LOC_API_Q_PATH \"/data/misc/location/gpsone_d/gpsone_loc_api_q\"\n#define GPSONE_LOC_API_RESP_Q_PATH \"/data/misc/location/gpsone_d/gpsone_loc_api_resp_q\"\n#define QUIPC_CTRL_Q_PATH \"/data/misc/location/gpsone_d/quipc_ctrl_q\"\n#define MSAPM_CTRL_Q_PATH \"/data/misc/location/gpsone_d/msapm_ctrl_q\"\n#define MSAPU_CTRL_Q_PATH \"/data/misc/location/gpsone_d/msapu_ctrl_q\"\n\n#else\n\n#define GPSONE_LOC_API_Q_PATH \"/tmp/gpsone_loc_api_q\"\n#define GPSONE_LOC_API_RESP_Q_PATH \"/tmp/gpsone_loc_api_resp_q\"\n#define QUIPC_CTRL_Q_PATH \"/tmp/quipc_ctrl_q\"\n#define MSAPM_CTRL_Q_PATH \"/tmp/msapm_ctrl_q\"\n#define MSAPU_CTRL_Q_PATH \"/tmp/msapu_ctrl_q\"\n\n#endif\n\nint loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread   create_thread_cb,\n    const char * loc_api_q_path, const char * ctrl_q_path, void *agps_handle);\nint loc_eng_dmn_conn_loc_api_server_unblock(void);\nint loc_eng_dmn_conn_loc_api_server_join(void);\nint loc_eng_dmn_conn_loc_api_server_data_conn(int, int);\n\n#endif /* LOC_ENG_DATA_SERVER_H */\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#include <linux/stat.h>\n#include <fcntl.h>\n\n#include <linux/types.h>\n\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n#include \"loc_eng_dmn_conn_glue_msg.h\"\n#include \"loc_eng_dmn_conn_handler.h\"\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_msgget\n\nDESCRIPTION\n   This function get a message queue\n\n   q_path - name path of the message queue\n   mode -\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   message queue id\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode)\n{\n    int msgqid;\n    msgqid = loc_eng_dmn_conn_glue_pipeget(q_path, mode);\n    return msgqid;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_msgremove\n\nDESCRIPTION\n   remove a message queue\n\n   q_path - name path of the message queue\n   msgqid - message queue id\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid)\n{\n    int result;\n    result = loc_eng_dmn_conn_glue_piperemove(q_path, msgqid);\n    return result;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_msgsnd\n\nDESCRIPTION\n   Send a message\n\n   msgqid - message queue id\n   msgp - pointer to the message to be sent\n   msgsz - size of the message\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   number of bytes sent out or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz)\n{\n    int result;\n    struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp;\n    pmsg->msgsz = msgsz;\n\n    result = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, msgsz);\n    if (result != (int) msgsz) {\n        LOC_LOGE(\"%s:%d] pipe broken %d, msgsz = %d\\n\", __func__, __LINE__, result, (int) msgsz);\n        return -1;\n    }\n\n    return result;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_msgrcv\n\nDESCRIPTION\n   receive a message\n\n   msgqid - message queue id\n   msgp - pointer to the buffer to hold the message\n   msgsz - size of the buffer\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   number of bytes received or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgbufsz)\n{\n    int result;\n    struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp;\n\n    result = loc_eng_dmn_conn_glue_piperead(msgqid, &(pmsg->msgsz), sizeof(pmsg->msgsz));\n    if (result != sizeof(pmsg->msgsz)) {\n        LOC_LOGE(\"%s:%d] pipe broken %d\\n\", __func__, __LINE__, result);\n        return -1;\n    }\n\n    if (msgbufsz < pmsg->msgsz) {\n        LOC_LOGE(\"%s:%d] msgbuf is too small %d < %d\\n\", __func__, __LINE__, (int) msgbufsz, (int) pmsg->msgsz);\n        return -1;\n    }\n\n    result = loc_eng_dmn_conn_glue_piperead(msgqid, (uint8_t *) msgp + sizeof(pmsg->msgsz), pmsg->msgsz - sizeof(pmsg->msgsz));\n    if (result != (int) (pmsg->msgsz - sizeof(pmsg->msgsz))) {\n        LOC_LOGE(\"%s:%d] pipe broken %d, msgsz = %d\\n\", __func__, __LINE__, result, (int) pmsg->msgsz);\n        return -1;\n    }\n\n    return pmsg->msgsz;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_msgunblock\n\nDESCRIPTION\n   unblock a message queue\n\n   msgqid - message queue id\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_msgunblock(int msgqid)\n{\n    return loc_eng_dmn_conn_glue_pipeunblock(msgqid);\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_msgflush\n\nDESCRIPTION\n   flush out the message in a queue\n\n   msgqid - message queue id\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   number of bytes that are flushed out.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_msgflush(int msgqid)\n{\n    int length;\n    char buf[128];\n\n    do {\n        length = loc_eng_dmn_conn_glue_piperead(msgqid, buf, 128);\n        LOC_LOGD(\"%s:%d] %s\\n\", __func__, __LINE__, buf);\n    } while(length);\n    return length;\n}\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_msg.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_ENG_DMN_CONN_GLUE_MSG_H\n#define LOC_ENG_DMN_CONN_GLUE_MSG_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n#include <linux/types.h>\n#include \"loc_eng_dmn_conn_glue_pipe.h\"\n\nint loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode);\nint loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid);\nint loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz);\nint loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgsz);\nint loc_eng_dmn_conn_glue_msgflush(int msgqid);\nint loc_eng_dmn_conn_glue_msgunblock(int msgqid);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* LOC_ENG_DMN_CONN_GLUE_MSG_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.c",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#include <string.h>\n#include <unistd.h>\n#include <errno.h>\n\n// #include <linux/stat.h>\n#include <fcntl.h>\n// #include <linux/types.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n\n#include \"loc_eng_dmn_conn_glue_pipe.h\"\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_pipeget\n\nDESCRIPTION\n   create a named pipe.\n\n   pipe_name - pipe name path\n   mode - mode\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode)\n{\n    int fd;\n    int result;\n\n    LOC_LOGD(\"%s, mode = %d\\n\", pipe_name, mode);\n    result = mkfifo(pipe_name, 0660);\n\n    if ((result == -1) && (errno != EEXIST)) {\n        LOC_LOGE(\"failed: %s\\n\", strerror(errno));\n        return result;\n    }\n\n    // The mode in mkfifo is not honoured and does not provide the\n    // group permissions. Doing chmod to add group permissions.\n    result = chmod (pipe_name, 0660);\n    if (result != 0){\n        LOC_LOGE (\"%s failed to change mode for %s, error = %s\\n\", __func__,\n              pipe_name, strerror(errno));\n    }\n\n    fd = open(pipe_name, mode);\n    if (fd <= 0)\n    {\n        LOC_LOGE(\"failed: %s\\n\", strerror(errno));\n    }\n    LOC_LOGD(\"fd = %d, %s\\n\", fd, pipe_name);\n    return fd;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_piperemove\n\nDESCRIPTION\n   remove a pipe\n\n    pipe_name - pipe name path\n    fd - fd for the pipe\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd)\n{\n    close(fd);\n    if (pipe_name) unlink(pipe_name);\n    LOC_LOGD(\"fd = %d, %s\\n\", fd, pipe_name);\n    return 0;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_pipewrite\n\nDESCRIPTION\n   write to a pipe\n\n   fd - fd of a pipe\n   buf - buffer for the data to write\n   sz - size of the data in buffer\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   number of bytes written or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz)\n{\n    int result;\n\n    result = write(fd, buf, sz);\n\n    /* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */\n\n    /* LOC_LOGD(\"fd = %d, buf = 0x%lx, size = %d, result = %d\\n\", fd, (long) buf, (int) sz, (int) result); */\n    return result;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_piperead\n\nDESCRIPTION\n   read from a pipe\n\n   fd - fd for the pipe\n   buf - buffer to hold the data read from pipe\n   sz - size of the buffer\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   number of bytes read from pipe or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz)\n{\n    int len;\n\n    len = read(fd, buf, sz);\n\n    /* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */\n\n    /* LOC_LOGD(\"fd = %d, buf = 0x%lx, size = %d, len = %d\\n\", fd, (long) buf, (int) sz, len); */\n    return len;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_glue_pipeunblock\n\nDESCRIPTION\n   unblock a pipe\n\n   fd - fd for the pipe\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0 for success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_glue_pipeunblock(int fd)\n{\n    int result;\n    struct flock flock_v;\n    LOC_LOGD(\"\\n\");\n//    result = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY);\n    flock_v.l_type = F_UNLCK;\n    flock_v.l_len = 32;\n    result = fcntl(fd, F_SETLK, &flock_v);\n    if (result < 0) {\n        LOC_LOGE(\"fcntl failure, %s\\n\", strerror(errno));\n    }\n\n    return result;\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_glue_pipe.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_ENG_DMN_CONN_GLUE_PIPE_H\n#define LOC_ENG_DMN_CONN_GLUE_PIPE_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#include <linux/types.h>\n\nint loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode);\nint loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd);\nint loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz);\nint loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz);\n\nint loc_eng_dmn_conn_glue_pipeflush(int fd);\nint loc_eng_dmn_conn_glue_pipeunblock(int fd);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* LOC_ENG_DMN_CONN_GLUE_PIPE_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.cpp",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n#include \"loc_eng_msg.h\"\n#include \"loc_eng_dmn_conn.h\"\n#include \"loc_eng_dmn_conn_handler.h\"\n\nvoid* loc_api_handle = NULL;\n\nint loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len)\n{\n    LOC_LOGD(\"%s:%d]\\n\", __func__, __LINE__);\n#ifndef DEBUG_DMN_LOC_API\n    if (NULL == loc_api_handle) {\n        LOC_LOGE(\"%s:%d] NO agps data handle\\n\", __func__, __LINE__);\n        return 1;\n    }\n\n    if (NULL != loc_api_handle) {\n        AGpsExtType type;\n        switch (pmsg->cmsg.cmsg_if_request.type) {\n          case IF_REQUEST_TYPE_SUPL:\n          {\n            LOC_LOGD(\"IF_REQUEST_TYPE_SUPL\");\n            type = AGPS_TYPE_SUPL;\n            break;\n          }\n          case IF_REQUEST_TYPE_WIFI:\n          {\n            LOC_LOGD(\"IF_REQUEST_TYPE_WIFI\");\n            type = AGPS_TYPE_WIFI;\n            break;\n          }\n          case IF_REQUEST_TYPE_ANY:\n          {\n            LOC_LOGD(\"IF_REQUEST_TYPE_ANY\");\n            type = AGPS_TYPE_ANY;\n            break;\n          }\n          default:\n          {\n            LOC_LOGD(\"invalid IF_REQUEST_TYPE!\");\n            return -1;\n          }\n        }\n        switch (pmsg->cmsg.cmsg_if_request.sender_id) {\n          case IF_REQUEST_SENDER_ID_QUIPC:\n          {\n            LOC_LOGD(\"IF_REQUEST_SENDER_ID_QUIPC\");\n            LocEngReqRelWifi* msg =\n                new LocEngReqRelWifi(loc_api_handle,\n                                     type,\n                                     LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC,\n                                     (char*)pmsg->cmsg.cmsg_if_request.ssid,\n                                     (char*)pmsg->cmsg.cmsg_if_request.password,\n                                     true);\n            msg->send();\n            break;\n          }\n          case IF_REQUEST_SENDER_ID_MSAPM:\n          {\n            LOC_LOGD(\"IF_REQUEST_SENDER_ID_MSAPM\");\n            LocEngReqRelWifi* msg =\n                new LocEngReqRelWifi(loc_api_handle,\n                                     type,\n                                     LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,\n                                     (char*)pmsg->cmsg.cmsg_if_request.ssid,\n                                     (char*)pmsg->cmsg.cmsg_if_request.password,\n                                     true);\n            msg->send();\n            break;\n          }\n          case IF_REQUEST_SENDER_ID_MSAPU:\n          {\n            LOC_LOGD(\"IF_REQUEST_SENDER_ID_MSAPU\");\n            LocEngReqRelWifi* msg =\n                new LocEngReqRelWifi(loc_api_handle,\n                                     type,\n                                     LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,\n                                     (char*)pmsg->cmsg.cmsg_if_request.ssid,\n                                     (char*)pmsg->cmsg.cmsg_if_request.password,\n                                     true);\n            msg->send();\n            break;\n          }\n          case IF_REQUEST_SENDER_ID_GPSONE_DAEMON:\n          {\n            LOC_LOGD(\"IF_REQUEST_SENDER_ID_GPSONE_DAEMON\");\n            LocEngReqRelBIT* msg =\n                new LocEngReqRelBIT(loc_api_handle,\n                                    type,\n                                    pmsg->cmsg.cmsg_if_request.ipv4_addr,\n                                    (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr,\n                                    true);\n            msg->send();\n            break;\n          }\n          default:\n          {\n            LOC_LOGD(\"invalid IF_REQUEST_SENDER_ID!\");\n            return -1;\n          }\n        }\n    }\n\n#else\n   loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_REQUEST_SUCCESS);\n#endif\n    return 0;\n}\n\nint loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len)\n{\n    LOC_LOGD(\"%s:%d]\\n\", __func__, __LINE__);\n#ifndef DEBUG_DMN_LOC_API\n    AGpsExtType type;\n    switch (pmsg->cmsg.cmsg_if_request.type) {\n      case IF_REQUEST_TYPE_SUPL:\n      {\n        LOC_LOGD(\"IF_REQUEST_TYPE_SUPL\");\n        type = AGPS_TYPE_SUPL;\n        break;\n      }\n      case IF_REQUEST_TYPE_WIFI:\n      {\n        LOC_LOGD(\"IF_REQUEST_TYPE_WIFI\");\n        type = AGPS_TYPE_WIFI;\n        break;\n      }\n      case IF_REQUEST_TYPE_ANY:\n      {\n        LOC_LOGD(\"IF_REQUEST_TYPE_ANY\");\n        type = AGPS_TYPE_ANY;\n        break;\n      }\n      default:\n      {\n        LOC_LOGD(\"invalid IF_REQUEST_TYPE!\");\n        return -1;\n      }\n    }\n    switch (pmsg->cmsg.cmsg_if_request.sender_id) {\n      case IF_REQUEST_SENDER_ID_QUIPC:\n      {\n        LOC_LOGD(\"IF_REQUEST_SENDER_ID_QUIPC\");\n        LocEngReqRelWifi* msg =\n            new LocEngReqRelWifi(loc_api_handle,\n                                 type,\n                                 LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC,\n                                 (char*)pmsg->cmsg.cmsg_if_request.ssid,\n                                 (char*)pmsg->cmsg.cmsg_if_request.password,\n                                 false);\n        msg->send();\n        break;\n      }\n      case IF_REQUEST_SENDER_ID_MSAPM:\n      {\n        LOC_LOGD(\"IF_REQUEST_SENDER_ID_MSAPM\");\n        LocEngReqRelWifi* msg =\n            new LocEngReqRelWifi(loc_api_handle,\n                                 type,\n                                 LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,\n                                 (char*)pmsg->cmsg.cmsg_if_request.ssid,\n                                 (char*)pmsg->cmsg.cmsg_if_request.password,\n                                 false);\n        msg->send();\n        break;\n      }\n      case IF_REQUEST_SENDER_ID_MSAPU:\n      {\n        LOC_LOGD(\"IF_REQUEST_SENDER_ID_MSAPU\");\n        LocEngReqRelWifi* msg =\n            new LocEngReqRelWifi(loc_api_handle,\n                                 type,\n                                 LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,\n                                 (char*)pmsg->cmsg.cmsg_if_request.ssid,\n                                 (char*)pmsg->cmsg.cmsg_if_request.password,\n                                 false);\n        msg->send();\n        break;\n      }\n      case IF_REQUEST_SENDER_ID_GPSONE_DAEMON:\n      {\n        LOC_LOGD(\"IF_REQUEST_SENDER_ID_GPSONE_DAEMON\");\n        LocEngReqRelBIT* msg =\n            new LocEngReqRelBIT(loc_api_handle,\n                                type,\n                                pmsg->cmsg.cmsg_if_request.ipv4_addr,\n                                (char*)pmsg->cmsg.cmsg_if_request.ipv6_addr,\n                                false);\n        msg->send();\n        break;\n      }\n      default:\n      {\n        LOC_LOGD(\"invalid IF_REQUEST_SENDER_ID!\");\n        return -1;\n      }\n    }\n#else\n   loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_RELEASE_SUCCESS);\n#endif\n    return 0;\n}\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_handler.h",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_ENG_DATA_SERVER_HANDLER\n#define LOC_ENG_DATA_SERVER_HANDLER\n\n#include <linux/types.h>\n#include <arpa/inet.h>\n\n//for SSID_BUF_SIZE\n#include <hardware/gps.h>\n\n#ifndef SSID_BUF_SIZE\n    #define SSID_BUF_SIZE (32+1)\n#endif\n\nenum {\n    /* 0x0 - 0xEF is reserved for daemon internal */\n    GPSONE_LOC_API_IF_REQUEST   = 0xF0,\n    GPSONE_LOC_API_IF_RELEASE,\n    GPSONE_LOC_API_RESPONSE,\n    GPSONE_UNBLOCK,\n};\n\nenum {\n    GPSONE_LOC_API_IF_REQUEST_SUCCESS = 0xF0,\n    GPSONE_LOC_API_IF_RELEASE_SUCCESS,\n    GPSONE_LOC_API_IF_FAILURE,\n};\n\n\nstruct ctrl_msg_response {\n    int result;\n};\n\nstruct ctrl_msg_unblock {\n    int reserved;\n};\n\ntypedef enum {\n  IF_REQUEST_TYPE_SUPL = 0,\n  IF_REQUEST_TYPE_WIFI,\n  IF_REQUEST_TYPE_ANY\n} ctrl_if_req_type_e_type;\n\ntypedef enum {\n  IF_REQUEST_SENDER_ID_QUIPC = 0,\n  IF_REQUEST_SENDER_ID_MSAPM,\n  IF_REQUEST_SENDER_ID_MSAPU,\n  IF_REQUEST_SENDER_ID_GPSONE_DAEMON,\n  IF_REQUEST_SENDER_ID_MODEM\n} ctrl_if_req_sender_id_e_type;\n\nstruct ctrl_msg_if_request {\n    ctrl_if_req_type_e_type type;\n    ctrl_if_req_sender_id_e_type sender_id;\n    unsigned long ipv4_addr;\n    unsigned char ipv6_addr[16];\n    char ssid[SSID_BUF_SIZE];\n    char password[SSID_BUF_SIZE];\n};\n\n/* do not change this structure */\nstruct ctrl_msgbuf {\n    size_t msgsz;\n    uint16_t reserved1;\n    uint32_t reserved2;\n    uint8_t ctrl_type;\n    union {\n        struct ctrl_msg_response   cmsg_response;\n        struct ctrl_msg_unblock    cmsg_unblock;\n        struct ctrl_msg_if_request cmsg_if_request;\n    } cmsg;\n};\n\nextern void* loc_api_handle;\n\nint loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len);\nint loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len);\n\n#endif /* LOC_ENG_DATA_SERVER_HANDLER */\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#include <stdio.h>\n\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n#include \"loc_eng_dmn_conn_thread_helper.h\"\n\n/*===========================================================================\nFUNCTION    thelper_signal_init\n\nDESCRIPTION\n   This function will initialize the conditional variable resources.\n\n   thelper - thelper instance\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper)\n{\n    int result;\n    thelper->thread_exit  = 0;\n    thelper->thread_ready = 0;\n    result = pthread_cond_init( &thelper->thread_cond, NULL);\n    if (result) {\n        return result;\n    }\n\n    result = pthread_mutex_init(&thelper->thread_mutex, NULL);\n    if (result) {\n        pthread_cond_destroy(&thelper->thread_cond);\n    }\n    return result;\n}\n\n/*===========================================================================\nFUNCTION\n\nDESCRIPTION\n   This function will destroy the conditional variable resources\n\n    thelper - pointer to thelper instance\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper)\n{\n    int result, ret_result = 0;\n    result = pthread_cond_destroy( &thelper->thread_cond);\n    if (result) {\n        ret_result = result;\n    }\n\n    result = pthread_mutex_destroy(&thelper->thread_mutex);\n    if (result) {\n        ret_result = result;\n    }\n\n    return ret_result;\n}\n\n/*===========================================================================\nFUNCTION    thelper_signal_wait\n\nDESCRIPTION\n   This function will be blocked on the conditional variable until thelper_signal_ready\n   is called\n\n    thelper - pointer to thelper instance\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper)\n{\n    int result = 0;\n\n    pthread_mutex_lock(&thelper->thread_mutex);\n    if (!thelper->thread_ready && !thelper->thread_exit) {\n        result = pthread_cond_wait(&thelper->thread_cond, &thelper->thread_mutex);\n    }\n\n    if (thelper->thread_exit) {\n        result = -1;\n    }\n    pthread_mutex_unlock(&thelper->thread_mutex);\n\n    return result;\n}\n\n/*===========================================================================\nFUNCTION     thelper_signal_ready\n\nDESCRIPTION\n   This function will wake up the conditional variable\n\n    thelper - pointer to thelper instance\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper)\n{\n    int result;\n\n    LOC_LOGD(\"%s:%d] 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n\n    pthread_mutex_lock(&thelper->thread_mutex);\n    thelper->thread_ready = 1;\n    result = pthread_cond_signal(&thelper->thread_cond);\n    pthread_mutex_unlock(&thelper->thread_mutex);\n\n    return result;\n}\n\n/*===========================================================================\nFUNCTION     thelper_signal_block\n\nDESCRIPTION\n   This function will set the thread ready to 0 to block the thelper_signal_wait\n\n    thelper - pointer to thelper instance\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   if thread_ready is set\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper)\n{\n    int result = thelper->thread_ready;\n\n    LOC_LOGD(\"%s:%d] 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n\n    pthread_mutex_lock(&thelper->thread_mutex);\n    thelper->thread_ready = 0;\n    pthread_mutex_unlock(&thelper->thread_mutex);\n\n    return result;\n}\n\n/*===========================================================================\nFUNCTION    thelper_main\n\nDESCRIPTION\n   This function is the main thread. It will be launched as a child thread\n\n    data - pointer to the instance\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   NULL\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic void * thelper_main(void *data)\n{\n    int result = 0;\n    struct loc_eng_dmn_conn_thelper * thelper = (struct loc_eng_dmn_conn_thelper *) data;\n\n    if (thelper->thread_proc_init) {\n        result = thelper->thread_proc_init(thelper->thread_context);\n        if (result < 0) {\n            thelper->thread_exit = 1;\n            thelper_signal_ready(thelper);\n            LOC_LOGE(\"%s:%d] error: 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n            return NULL;\n        }\n    }\n\n    thelper_signal_ready(thelper);\n\n    if (thelper->thread_proc_pre) {\n        result = thelper->thread_proc_pre(thelper->thread_context);\n        if (result < 0) {\n            thelper->thread_exit = 1;\n            LOC_LOGE(\"%s:%d] error: 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n            return NULL;\n        }\n    }\n\n    do {\n        if (thelper->thread_proc) {\n            result = thelper->thread_proc(thelper->thread_context);\n            if (result < 0) {\n                thelper->thread_exit = 1;\n                LOC_LOGE(\"%s:%d] error: 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n            }\n        }\n    } while (thelper->thread_exit == 0);\n\n    if (thelper->thread_proc_post) {\n        result = thelper->thread_proc_post(thelper->thread_context);\n    }\n\n    if (result != 0) {\n        LOC_LOGE(\"%s:%d] error: 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n    }\n    return NULL;\n}\n\nstatic void thelper_main_2(void *data)\n{\n    thelper_main(data);\n    return;\n}\n\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_launch_thelper\n\nDESCRIPTION\n   This function will initialize the thread context and launch the thelper_main\n\n    thelper - pointer to thelper instance\n    thread_proc_init - The initialization function pointer\n    thread_proc_pre  - The function to call before task loop and after initialization\n    thread_proc      - The task loop\n    thread_proc_post - The function to call after the task loop\n    context          - the context for the above four functions\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper,\n    int (*thread_proc_init) (void * context),\n    int (*thread_proc_pre) (void * context),\n    int (*thread_proc) (void * context),\n    int (*thread_proc_post) (void * context),\n    thelper_create_thread   create_thread_cb,\n    void * context)\n{\n    int result;\n\n    thelper_signal_init(thelper);\n\n    if (context) {\n        thelper->thread_context    = context;\n    }\n\n    thelper->thread_proc_init  = thread_proc_init;\n    thelper->thread_proc_pre   = thread_proc_pre;\n    thelper->thread_proc       = thread_proc;\n    thelper->thread_proc_post  = thread_proc_post;\n\n    LOC_LOGD(\"%s:%d] 0x%lx call pthread_create\\n\", __func__, __LINE__, (long) thelper);\n    if (create_thread_cb) {\n        result = 0;\n        thelper->thread_id = create_thread_cb(\"loc_eng_dmn_conn\",\n            thelper_main_2, (void *)thelper);\n    } else {\n        result = pthread_create(&thelper->thread_id, NULL,\n            thelper_main, (void *)thelper);\n    }\n\n    if (result != 0) {\n        LOC_LOGE(\"%s:%d] 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n        return -1;\n    }\n\n    LOC_LOGD(\"%s:%d] 0x%lx pthread_create done\\n\", __func__, __LINE__, (long) thelper);\n\n    thelper_signal_wait(thelper);\n\n    LOC_LOGD(\"%s:%d] 0x%lx pthread ready\\n\", __func__, __LINE__, (long) thelper);\n    return thelper->thread_exit;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_unblock_thelper\n\nDESCRIPTION\n   This function unblocks thelper_main to release the thread\n\n    thelper - pointer to thelper instance\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper)\n{\n    LOC_LOGD(\"%s:%d] 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n    thelper->thread_exit = 1;\n    return 0;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_dmn_conn_join_thelper\n\n    thelper - pointer to thelper instance\n\nDESCRIPTION\n   This function will wait for the thread of thelper_main to finish\n\nDEPENDENCIES\n   None\n\nRETURN VALUE\n   0: success or negative value for failure\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper)\n{\n    int result;\n\n    LOC_LOGD(\"%s:%d] 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n    result = pthread_join(thelper->thread_id, NULL);\n    if (result != 0) {\n        LOC_LOGE(\"%s:%d] 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n    }\n    LOC_LOGD(\"%s:%d] 0x%lx\\n\", __func__, __LINE__, (long) thelper);\n\n    thelper_signal_destroy(thelper);\n\n    return result;\n}\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_dmn_conn_thread_helper.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef __LOC_ENG_DMN_CONN_THREAD_HELPER_H__\n#define __LOC_ENG_DMN_CONN_THREAD_HELPER_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#include <pthread.h>\n\nstruct loc_eng_dmn_conn_thelper {\n    unsigned char   thread_exit;\n    unsigned char   thread_ready;\n    pthread_cond_t  thread_cond;\n    pthread_mutex_t thread_mutex;\n    pthread_t       thread_id;\n    void *          thread_context;\n    int             (*thread_proc_init) (void * context);\n    int             (*thread_proc_pre)  (void * context);\n    int             (*thread_proc)      (void * context);\n    int             (*thread_proc_post) (void * context);\n};\n\ntypedef pthread_t (* thelper_create_thread)(const char* name, void (*start)(void *), void* arg);\nint loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper,\n    int (*thread_proc_init) (void * context),\n    int (*thread_proc_pre)  (void * context),\n    int (*thread_proc)      (void * context),\n    int (*thread_proc_post) (void * context),\n    thelper_create_thread   create_thread_cb,\n    void * context);\n\nint loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper);\nint loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper);\n\n/* if only need to use signal */\nint thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper);\nint thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper);\nint thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper);\nint thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper);\nint thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ */\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_log.cpp",
    "content": "/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_eng\"\n\n#include \"loc_log.h\"\n#include \"loc_eng_log.h\"\n\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_log.h",
    "content": "/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_ENG_LOG_H\n#define LOC_ENG_LOG_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#include <ctype.h>\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_ENG_LOG_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_msg.h",
    "content": "/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_ENG_MSG_H\n#define LOC_ENG_MSG_H\n\n\n#include <hardware/gps.h>\n#include <gps_extended.h>\n#include <stdlib.h>\n#include <string.h>\n#include <log_util.h>\n#include <loc_eng_log.h>\n#include <loc_eng.h>\n#include <MsgTask.h>\n#include <LocEngAdapter.h>\n\n#ifndef SSID_BUF_SIZE\n    #define SSID_BUF_SIZE (32+1)\n#endif\n#ifdef USE_GLIB\n\n#include <glib.h>\n\n#endif /* USE_GLIB */\n#include \"platform_lib_includes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\nusing namespace loc_core;\n\nstruct LocEngPositionMode : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const LocPosMode mPosMode;\n    LocEngPositionMode(LocEngAdapter* adapter, LocPosMode &mode);\n    virtual void proc() const;\n    virtual void log() const;\n    void send() const;\n};\n\n\nstruct LocEngStartFix : public LocMsg {\n    LocEngAdapter* mAdapter;\n    LocEngStartFix(LocEngAdapter* adapter);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n    void send() const;\n};\n\nstruct LocEngStopFix : public LocMsg {\n    LocEngAdapter* mAdapter;\n    LocEngStopFix(LocEngAdapter* adapter);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n    void send() const;\n};\n\nstruct LocEngReportPosition : public LocMsg {\n    LocAdapterBase* mAdapter;\n    const UlpLocation mLocation;\n    const GpsLocationExtended mLocationExtended;\n    const void* mLocationExt;\n    const enum loc_sess_status mStatus;\n    const LocPosTechMask mTechMask;\n    LocEngReportPosition(LocAdapterBase* adapter,\n                         UlpLocation &loc,\n                         GpsLocationExtended &locExtended,\n                         void* locExt,\n                         enum loc_sess_status st,\n                         LocPosTechMask technology);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n    void send() const;\n};\n\nstruct LocEngReportSv : public LocMsg {\n    LocAdapterBase* mAdapter;\n    const QcomSvStatus mSvStatus;\n    const GpsLocationExtended mLocationExtended;\n    const void* mSvExt;\n    LocEngReportSv(LocAdapterBase* adapter,\n                   QcomSvStatus &sv,\n                   GpsLocationExtended &locExtended,\n                   void* svExtended);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n    void send() const;\n};\n\nstruct LocEngReportStatus : public LocMsg {\n    LocAdapterBase* mAdapter;\n    const GpsStatusValue mStatus;\n    LocEngReportStatus(LocAdapterBase* adapter,\n                       GpsStatusValue engineStatus);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngReportNmea : public LocMsg {\n    void* mLocEng;\n    char* const mNmea;\n    const int mLen;\n    LocEngReportNmea(void* locEng,\n                     const char* data, int len);\n    inline virtual ~LocEngReportNmea()\n    {\n        delete[] mNmea;\n    }\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngReportXtraServer : public LocMsg {\n    void* mLocEng;\n    int mMaxLen;\n    char *mServers;\n    LocEngReportXtraServer(void* locEng,\n                           const char *url1, const char *url2,\n                           const char *url3, const int maxlength);\n    inline virtual ~LocEngReportXtraServer()\n    {\n        delete[] mServers;\n    }\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngSuplEsOpened : public LocMsg {\n    void* mLocEng;\n    LocEngSuplEsOpened(void* locEng);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngSuplEsClosed : public LocMsg {\n    void* mLocEng;\n    LocEngSuplEsClosed(void* locEng);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngRequestSuplEs : public LocMsg {\n    void* mLocEng;\n    const int mID;\n    LocEngRequestSuplEs(void* locEng, int id);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngRequestATL : public LocMsg {\n    void* mLocEng;\n    const int mID;\n    const AGpsExtType mType;\n    LocEngRequestATL(void* locEng, int id,\n                     AGpsExtType agps_type);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngReleaseATL : public LocMsg {\n    void* mLocEng;\n    const int mID;\n    LocEngReleaseATL(void* locEng, int id);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngReqRelBIT : public LocMsg {\n    void* mLocEng;\n    const AGpsExtType mType;\n    const int mIPv4Addr;\n    char* const mIPv6Addr;\n    const bool mIsReq;\n    LocEngReqRelBIT(void* instance, AGpsExtType type,\n                    int ipv4, char* ipv6, bool isReq);\n    virtual ~LocEngReqRelBIT();\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n    void send() const;\n};\n\nstruct LocEngReqRelWifi : public LocMsg {\n    void* mLocEng;\n    const AGpsExtType mType;\n    const loc_if_req_sender_id_e_type mSenderId;\n    char* const mSSID;\n    char* const mPassword;\n    const bool mIsReq;\n    LocEngReqRelWifi(void* locEng, AGpsExtType type,\n                     loc_if_req_sender_id_e_type sender_id,\n                     char* s, char* p, bool isReq);\n    virtual ~LocEngReqRelWifi();\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n    void send() const;\n};\n\nstruct LocEngRequestXtra : public LocMsg {\n    void* mLocEng;\n    LocEngRequestXtra(void* locEng);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngRequestTime : public LocMsg {\n    void* mLocEng;\n    LocEngRequestTime(void* locEng);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngRequestNi : public LocMsg {\n    void* mLocEng;\n    const GpsNiNotification mNotify;\n    const void *mPayload;\n    LocEngRequestNi(void* locEng,\n                    GpsNiNotification &notif,\n                    const void* data);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngDown : public LocMsg {\n    void* mLocEng;\n    LocEngDown(void* locEng);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngUp : public LocMsg {\n    void* mLocEng;\n    LocEngUp(void* locEng);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\nstruct LocEngGetZpp : public LocMsg {\n    LocEngAdapter* mAdapter;\n    LocEngGetZpp(LocEngAdapter* adapter);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n    void send() const;\n};\n\nstruct LocEngReportGpsMeasurement : public LocMsg {\n    void* mLocEng;\n    const GpsData mGpsData;\n    LocEngReportGpsMeasurement(void* locEng,\n                               GpsData &gpsData);\n    virtual void proc() const;\n    void locallog() const;\n    virtual void log() const;\n};\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* LOC_ENG_MSG_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_ni.cpp",
    "content": "/* Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_eng\"\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <sys/time.h>\n#include <pthread.h>\n#include <errno.h>\n#include <string.h>\n#include <ctype.h>\n#include <unistd.h>\n#include <time.h>\n#include <MsgTask.h>\n\n#include <loc_eng.h>\n\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n\nusing namespace loc_core;\n\n/*=============================================================================\n *\n *                             DATA DECLARATION\n *\n *============================================================================*/\n\n/*=============================================================================\n *\n *                             FUNCTION DECLARATIONS\n *\n *============================================================================*/\nstatic void* ni_thread_proc(void *args);\n\nstruct LocEngInformNiResponse : public LocMsg {\n    LocEngAdapter* mAdapter;\n    const GpsUserResponseType mResponse;\n    const void *mPayload;\n    inline LocEngInformNiResponse(LocEngAdapter* adapter,\n                                  GpsUserResponseType resp,\n                                  const void* data) :\n        LocMsg(), mAdapter(adapter),\n        mResponse(resp), mPayload(data)\n    {\n        locallog();\n    }\n    inline ~LocEngInformNiResponse()\n    {\n        // this is a bit weird since mPayload is not\n        // allocated by this class.  But there is no better way.\n        // mPayload actually won't be NULL here.\n        free((void*)mPayload);\n    }\n    inline virtual void proc() const\n    {\n        mAdapter->informNiResponse(mResponse, mPayload);\n    }\n    inline void locallog() const\n    {\n        LOC_LOGV(\"LocEngInformNiResponse - \"\n                 \"response: %s\\n  mPayload: %p\",\n                 loc_get_ni_response_name(mResponse),\n                 mPayload);\n    }\n    inline virtual void log() const\n    {\n        locallog();\n    }\n};\n\n/*===========================================================================\n\nFUNCTION loc_eng_ni_request_handler\n\nDESCRIPTION\n   Displays the NI request and awaits user input. If a previous request is\n   in session, it is ignored.\n\nRETURN VALUE\n   none\n\n===========================================================================*/\nvoid loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,\n                            const GpsNiNotification *notif,\n                            const void* passThrough)\n{\n    ENTRY_LOG();\n    char lcs_addr[32]; // Decoded LCS address for UMTS CP NI\n    loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;\n    loc_eng_ni_session_s_type* pSession = NULL;\n\n    if (NULL == loc_eng_data.ni_notify_cb) {\n        EXIT_LOG(%s, \"loc_eng_ni_init hasn't happened yet.\");\n        return;\n    }\n\n    if (notif->ni_type == GPS_NI_TYPE_EMERGENCY_SUPL) {\n        if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {\n            LOC_LOGW(\"loc_eng_ni_request_handler, supl es NI in progress, new supl es NI ignored, type: %d\",\n                     notif->ni_type);\n            if (NULL != passThrough) {\n                free((void*)passThrough);\n            }\n        } else {\n            pSession = &loc_eng_ni_data_p->sessionEs;\n        }\n    } else {\n        if (NULL != loc_eng_ni_data_p->session.rawRequest ||\n            NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {\n            LOC_LOGW(\"loc_eng_ni_request_handler, supl NI in progress, new supl NI ignored, type: %d\",\n                     notif->ni_type);\n            if (NULL != passThrough) {\n                free((void*)passThrough);\n            }\n        } else {\n            pSession = &loc_eng_ni_data_p->session;\n        }\n    }\n\n\n    if (pSession) {\n        /* Save request */\n        pSession->rawRequest = (void*)passThrough;\n        pSession->reqID = ++loc_eng_ni_data_p->reqIDCounter;\n        pSession->adapter = loc_eng_data.adapter;\n\n        /* Fill in notification */\n        ((GpsNiNotification*)notif)->notification_id = pSession->reqID;\n\n        if (notif->notify_flags == GPS_NI_PRIVACY_OVERRIDE)\n        {\n            loc_eng_mute_one_session(loc_eng_data);\n        }\n\n        /* Log requestor ID and text for debugging */\n        LOC_LOGI(\"Notification: notif_type: %d, timeout: %d, default_resp: %d\", notif->ni_type, notif->timeout, notif->default_response);\n        LOC_LOGI(\"              requestor_id: %s (encoding: %d)\", notif->requestor_id, notif->requestor_id_encoding);\n        LOC_LOGI(\"              text: %s text (encoding: %d)\", notif->text, notif->text_encoding);\n        if (notif->extras[0])\n        {\n            LOC_LOGI(\"              extras: %s\", notif->extras);\n        }\n\n        /* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though\n         * the OEM layer in java does not do so.\n         **/\n        pSession->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME);\n        LOC_LOGI(\"Automatically sends 'no response' in %d seconds (to clear status)\\n\", pSession->respTimeLeft);\n\n        int rc = 0;\n        rc = pthread_create(&pSession->thread, NULL, ni_thread_proc, pSession);\n        if (rc)\n        {\n            LOC_LOGE(\"Loc NI thread is not created.\\n\");\n        }\n        rc = pthread_detach(pSession->thread);\n        if (rc)\n        {\n            LOC_LOGE(\"Loc NI thread is not detached.\\n\");\n        }\n\n        CALLBACK_LOG_CALLFLOW(\"ni_notify_cb - id\", %d, notif->notification_id);\n        loc_eng_data.ni_notify_cb((GpsNiNotification*)notif);\n    }\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\n\nFUNCTION ni_thread_proc\n\n===========================================================================*/\nstatic void* ni_thread_proc(void *args)\n{\n    ENTRY_LOG();\n\n    loc_eng_ni_session_s_type* pSession = (loc_eng_ni_session_s_type*)args;\n    int rc = 0;          /* return code from pthread calls */\n\n    struct timeval present_time;\n    struct timespec expire_time;\n\n    LOC_LOGD(\"Starting Loc NI thread...\\n\");\n    pthread_mutex_lock(&pSession->tLock);\n    /* Calculate absolute expire time */\n    gettimeofday(&present_time, NULL);\n    expire_time.tv_sec  = present_time.tv_sec + pSession->respTimeLeft;\n    expire_time.tv_nsec = present_time.tv_usec * 1000;\n    LOC_LOGD(\"ni_thread_proc-Time out set for abs time %ld with delay %d sec\\n\",\n             (long) expire_time.tv_sec, pSession->respTimeLeft );\n\n    while (!pSession->respRecvd)\n    {\n        rc = pthread_cond_timedwait(&pSession->tCond,\n                                    &pSession->tLock,\n                                    &expire_time);\n        if (rc == ETIMEDOUT)\n        {\n            pSession->resp = GPS_NI_RESPONSE_NORESP;\n            LOC_LOGD(\"ni_thread_proc-Thread time out after valting for specified time. Ret Val %d\\n\",rc );\n            break;\n        }\n    }\n    LOC_LOGD(\"ni_thread_proc-Java layer has sent us a user response and return value from \"\n             \"pthread_cond_timedwait = %d\\n\",rc );\n    pSession->respRecvd = FALSE; /* Reset the user response flag for the next session*/\n\n    LOC_LOGD(\"pSession->resp is %d\\n\",pSession->resp);\n\n    // adding this check to support modem restart, in which case, we need the thread\n    // to exit without calling sending data. We made sure that rawRequest is NULL in\n    // loc_eng_ni_reset_on_engine_restart()\n    LocEngAdapter* adapter = pSession->adapter;\n    LocEngInformNiResponse *msg = NULL;\n\n    if (NULL != pSession->rawRequest) {\n        if (pSession->resp != GPS_NI_RESPONSE_IGNORE) {\n            LOC_LOGD(\"pSession->resp != GPS_NI_RESPONSE_IGNORE \\n\");\n            msg = new LocEngInformNiResponse(adapter,\n                                             pSession->resp,\n                                             pSession->rawRequest);\n        } else {\n            LOC_LOGD(\"this is the ignore reply for SUPL ES\\n\");\n            free(pSession->rawRequest);\n        }\n        pSession->rawRequest = NULL;\n    }\n    pthread_mutex_unlock(&pSession->tLock);\n\n    pSession->respTimeLeft = 0;\n    pSession->reqID = 0;\n\n    if (NULL != msg) {\n        LOC_LOGD(\"ni_thread_proc: adapter->sendMsg(msg)\\n\");\n        adapter->sendMsg(msg);\n    }\n\n    EXIT_LOG(%s, VOID_RET);\n    return NULL;\n}\n\nvoid loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG();\n    loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;\n\n    if (NULL == loc_eng_data.ni_notify_cb) {\n        EXIT_LOG(%s, \"loc_eng_ni_init hasn't happened yet.\");\n        return;\n    }\n\n    // only if modem has requested but then died.\n    if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {\n        free(loc_eng_ni_data_p->sessionEs.rawRequest);\n        loc_eng_ni_data_p->sessionEs.rawRequest = NULL;\n\n        pthread_mutex_lock(&loc_eng_ni_data_p->sessionEs.tLock);\n        // the goal is to wake up ni_thread_proc\n        // and let it exit.\n        loc_eng_ni_data_p->sessionEs.respRecvd = TRUE;\n        pthread_cond_signal(&loc_eng_ni_data_p->sessionEs.tCond);\n        pthread_mutex_unlock(&loc_eng_ni_data_p->sessionEs.tLock);\n    }\n\n    if (NULL != loc_eng_ni_data_p->session.rawRequest) {\n        free(loc_eng_ni_data_p->session.rawRequest);\n        loc_eng_ni_data_p->session.rawRequest = NULL;\n\n        pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);\n        // the goal is to wake up ni_thread_proc\n        // and let it exit.\n        loc_eng_ni_data_p->session.respRecvd = TRUE;\n        pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);\n        pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);\n    }\n\n    EXIT_LOG(%s, VOID_RET);\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_ni_init\n\nDESCRIPTION\n   This function initializes the NI interface\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiExtCallbacks *callbacks)\n{\n    ENTRY_LOG_CALLFLOW();\n\n    if(callbacks == NULL)\n        EXIT_LOG(%s, \"loc_eng_ni_init: failed, cb is NULL\");\n    else if (NULL == callbacks->notify_cb) {\n        EXIT_LOG(%s, \"loc_eng_ni_init: failed, no cb.\");\n    } else if (NULL != loc_eng_data.ni_notify_cb) {\n        EXIT_LOG(%s, \"loc_eng_ni_init: already inited.\");\n    } else {\n        loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;\n        loc_eng_ni_data_p->sessionEs.respTimeLeft = 0;\n        loc_eng_ni_data_p->sessionEs.respRecvd = FALSE;\n        loc_eng_ni_data_p->sessionEs.rawRequest = NULL;\n        loc_eng_ni_data_p->sessionEs.reqID = 0;\n        pthread_cond_init(&loc_eng_ni_data_p->sessionEs.tCond, NULL);\n        pthread_mutex_init(&loc_eng_ni_data_p->sessionEs.tLock, NULL);\n\n        loc_eng_ni_data_p->session.respTimeLeft = 0;\n        loc_eng_ni_data_p->session.respRecvd = FALSE;\n        loc_eng_ni_data_p->session.rawRequest = NULL;\n        loc_eng_ni_data_p->session.reqID = 0;\n        pthread_cond_init(&loc_eng_ni_data_p->session.tCond, NULL);\n        pthread_mutex_init(&loc_eng_ni_data_p->session.tLock, NULL);\n\n        loc_eng_data.ni_notify_cb = callbacks->notify_cb;\n        EXIT_LOG(%s, VOID_RET);\n    }\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_ni_respond\n\nDESCRIPTION\n   This function receives user response from upper layer framework\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,\n                        int notif_id, GpsUserResponseType user_response)\n{\n    ENTRY_LOG_CALLFLOW();\n    loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;\n    loc_eng_ni_session_s_type* pSession = NULL;\n\n    if (NULL == loc_eng_data.ni_notify_cb) {\n        EXIT_LOG(%s, \"loc_eng_ni_init hasn't happened yet.\");\n        return;\n    }\n\n    if (notif_id == loc_eng_ni_data_p->sessionEs.reqID &&\n        NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {\n        pSession = &loc_eng_ni_data_p->sessionEs;\n        // ignore any SUPL NI non-Es session if a SUPL NI ES is accepted\n        if (user_response == GPS_NI_RESPONSE_ACCEPT &&\n            NULL != loc_eng_ni_data_p->session.rawRequest) {\n                pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);\n                loc_eng_ni_data_p->session.resp = GPS_NI_RESPONSE_IGNORE;\n                loc_eng_ni_data_p->session.respRecvd = TRUE;\n                pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);\n                pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);\n        }\n    } else if (notif_id == loc_eng_ni_data_p->session.reqID &&\n        NULL != loc_eng_ni_data_p->session.rawRequest) {\n        pSession = &loc_eng_ni_data_p->session;\n    }\n\n    if (pSession) {\n        LOC_LOGI(\"loc_eng_ni_respond: send user response %d for notif %d\", user_response, notif_id);\n        pthread_mutex_lock(&pSession->tLock);\n        pSession->resp = user_response;\n        pSession->respRecvd = TRUE;\n        pthread_cond_signal(&pSession->tCond);\n        pthread_mutex_unlock(&pSession->tLock);\n    }\n    else {\n        LOC_LOGE(\"loc_eng_ni_respond: notif_id %d not an active session\", notif_id);\n    }\n\n    EXIT_LOG(%s, VOID_RET);\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_ni.h",
    "content": "/* Copyright (c) 2009,2011,2014 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_ENG_NI_H\n#define LOC_ENG_NI_H\n\n#include <stdbool.h>\n#include <LocEngAdapter.h>\n\n#define LOC_NI_NO_RESPONSE_TIME            20                      /* secs */\n#define LOC_NI_NOTIF_KEY_ADDRESS           \"Address\"\n#define GPS_NI_RESPONSE_IGNORE             4\n\ntypedef struct {\n    pthread_t               thread;            /* NI thread */\n    int                     respTimeLeft;       /* examine time for NI response */\n    bool                    respRecvd;   /* NI User reponse received or not from Java layer*/\n    void*                   rawRequest;\n    int                     reqID;         /* ID to check against response */\n    GpsUserResponseType     resp;\n    pthread_cond_t          tCond;\n    pthread_mutex_t         tLock;\n    LocEngAdapter*          adapter;\n} loc_eng_ni_session_s_type;\n\ntypedef struct {\n    loc_eng_ni_session_s_type session;    /* SUPL NI Session */\n    loc_eng_ni_session_s_type sessionEs;  /* Emergency SUPL NI Session */\n    int reqIDCounter;\n} loc_eng_ni_data_s_type;\n\n\n#endif /* LOC_ENG_NI_H */\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_nmea.cpp",
    "content": "/* Copyright (c) 2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_eng_nmea\"\n#define GPS_PRN_START 1\n#define GPS_PRN_END   32\n#define GLONASS_PRN_START 65\n#define GLONASS_PRN_END   96\n#include <loc_eng.h>\n#include <loc_eng_nmea.h>\n#include <math.h>\n#include \"log_util.h\"\n\n/*===========================================================================\nFUNCTION    loc_eng_nmea_send\n\nDESCRIPTION\n   send out NMEA sentence\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   Total length of the nmea sentence\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p)\n{\n    struct timeval tv;\n    gettimeofday(&tv, (struct timezone *) NULL);\n    int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;\n    CALLBACK_LOG_CALLFLOW(\"nmea_cb\", %p, pNmea);\n    if (loc_eng_data_p->nmea_cb != NULL)\n        loc_eng_data_p->nmea_cb(now, pNmea, length);\n    LOC_LOGD(\"NMEA <%s\", pNmea);\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_nmea_put_checksum\n\nDESCRIPTION\n   Generate NMEA sentences generated based on position report\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   Total length of the nmea sentence\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_nmea_put_checksum(char *pNmea, int maxSize)\n{\n    uint8_t checksum = 0;\n    int length = 0;\n\n    pNmea++; //skip the $\n    while (*pNmea != '\\0')\n    {\n        checksum ^= *pNmea++;\n        length++;\n    }\n\n    int checksumLength = snprintf(pNmea,(maxSize-length-1),\"*%02X\\r\\n\", checksum);\n    return (length + checksumLength);\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_nmea_generate_pos\n\nDESCRIPTION\n   Generate NMEA sentences generated based on position report\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,\n                               const UlpLocation &location,\n                               const GpsLocationExtended &locationExtended,\n                               unsigned char generate_nmea)\n{\n    ENTRY_LOG();\n    time_t utcTime(location.gpsLocation.timestamp/1000);\n    tm * pTm = gmtime(&utcTime);\n    if (NULL == pTm) {\n        LOC_LOGE(\"gmtime failed\");\n        return;\n    }\n\n    char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};\n    char* pMarker = sentence;\n    int lengthRemaining = sizeof(sentence);\n    int length = 0;\n    int utcYear = pTm->tm_year % 100; // 2 digit year\n    int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero\n    int utcDay = pTm->tm_mday;\n    int utcHours = pTm->tm_hour;\n    int utcMinutes = pTm->tm_min;\n    int utcSeconds = pTm->tm_sec;\n\n    if (generate_nmea) {\n        // ------------------\n        // ------$GPGSA------\n        // ------------------\n\n        uint32_t svUsedCount = 0;\n        uint32_t svUsedList[32] = {0};\n        uint32_t mask = loc_eng_data_p->sv_used_mask;\n        for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++)\n        {\n            if (mask & 1)\n                svUsedList[svUsedCount++] = i;\n            mask = mask >> 1;\n        }\n        // clear the cache so they can't be used again\n        loc_eng_data_p->sv_used_mask = 0;\n\n        char fixType;\n        if (svUsedCount == 0)\n            fixType = '1'; // no fix\n        else if (svUsedCount <= 3)\n            fixType = '2'; // 2D fix\n        else\n            fixType = '3'; // 3D fix\n\n        length = snprintf(pMarker, lengthRemaining, \"$GPGSA,A,%c,\", fixType);\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        for (uint8_t i = 0; i < 12; i++) // only the first 12 sv go in sentence\n        {\n            if (i < svUsedCount)\n                length = snprintf(pMarker, lengthRemaining, \"%02d,\", svUsedList[i]);\n            else\n                length = snprintf(pMarker, lengthRemaining, \",\");\n\n            if (length < 0 || length >= lengthRemaining)\n            {\n                LOC_LOGE(\"NMEA Error in string formatting\");\n                return;\n            }\n            pMarker += length;\n            lengthRemaining -= length;\n        }\n\n        if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)\n        {   // dop is in locationExtended, (QMI)\n            length = snprintf(pMarker, lengthRemaining, \"%.1f,%.1f,%.1f\",\n                              locationExtended.pdop,\n                              locationExtended.hdop,\n                              locationExtended.vdop);\n        }\n        else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)\n        {   // dop was cached from sv report (RPC)\n            length = snprintf(pMarker, lengthRemaining, \"%.1f,%.1f,%.1f\",\n                              loc_eng_data_p->pdop,\n                              loc_eng_data_p->hdop,\n                              loc_eng_data_p->vdop);\n        }\n        else\n        {   // no dop\n            length = snprintf(pMarker, lengthRemaining, \",,\");\n        }\n\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n\n        // ------------------\n        // ------$GPVTG------\n        // ------------------\n\n        pMarker = sentence;\n        lengthRemaining = sizeof(sentence);\n\n        if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING)\n        {\n            float magTrack = location.gpsLocation.bearing;\n            if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)\n            {\n                float magTrack = location.gpsLocation.bearing - locationExtended.magneticDeviation;\n                if (magTrack < 0.0)\n                    magTrack += 360.0;\n                else if (magTrack > 360.0)\n                    magTrack -= 360.0;\n            }\n\n            length = snprintf(pMarker, lengthRemaining, \"$GPVTG,%.1lf,T,%.1lf,M,\", location.gpsLocation.bearing, magTrack);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining, \"$GPVTG,,T,,M,\");\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED)\n        {\n            float speedKnots = location.gpsLocation.speed * (3600.0/1852.0);\n            float speedKmPerHour = location.gpsLocation.speed * 3.6;\n\n            length = snprintf(pMarker, lengthRemaining, \"%.1lf,N,%.1lf,K,\", speedKnots, speedKmPerHour);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining, \",N,,K,\");\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))\n            length = snprintf(pMarker, lengthRemaining, \"%c\", 'N'); // N means no fix\n        else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)\n            length = snprintf(pMarker, lengthRemaining, \"%c\", 'A'); // A means autonomous\n        else\n            length = snprintf(pMarker, lengthRemaining, \"%c\", 'D'); // D means differential\n\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n\n        // ------------------\n        // ------$GPRMC------\n        // ------------------\n\n        pMarker = sentence;\n        lengthRemaining = sizeof(sentence);\n\n        length = snprintf(pMarker, lengthRemaining, \"$GPRMC,%02d%02d%02d,A,\" ,\n                          utcHours, utcMinutes, utcSeconds);\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)\n        {\n            double latitude = location.gpsLocation.latitude;\n            double longitude = location.gpsLocation.longitude;\n            char latHemisphere;\n            char lonHemisphere;\n            double latMinutes;\n            double lonMinutes;\n\n            if (latitude > 0)\n            {\n                latHemisphere = 'N';\n            }\n            else\n            {\n                latHemisphere = 'S';\n                latitude *= -1.0;\n            }\n\n            if (longitude < 0)\n            {\n                lonHemisphere = 'W';\n                longitude *= -1.0;\n            }\n            else\n            {\n                lonHemisphere = 'E';\n            }\n\n            latMinutes = fmod(latitude * 60.0 , 60.0);\n            lonMinutes = fmod(longitude * 60.0 , 60.0);\n\n            length = snprintf(pMarker, lengthRemaining, \"%02d%09.6lf,%c,%03d%09.6lf,%c,\",\n                              (uint8_t)floor(latitude), latMinutes, latHemisphere,\n                              (uint8_t)floor(longitude),lonMinutes, lonHemisphere);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining,\",,,,\");\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED)\n        {\n            float speedKnots = location.gpsLocation.speed * (3600.0/1852.0);\n            length = snprintf(pMarker, lengthRemaining, \"%.1lf,\", speedKnots);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining, \",\");\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING)\n        {\n            length = snprintf(pMarker, lengthRemaining, \"%.1lf,\", location.gpsLocation.bearing);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining, \",\");\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        length = snprintf(pMarker, lengthRemaining, \"%2.2d%2.2d%2.2d,\",\n                          utcDay, utcMonth, utcYear);\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)\n        {\n            float magneticVariation = locationExtended.magneticDeviation;\n            char direction;\n            if (magneticVariation < 0.0)\n            {\n                direction = 'W';\n                magneticVariation *= -1.0;\n            }\n            else\n            {\n                direction = 'E';\n            }\n\n            length = snprintf(pMarker, lengthRemaining, \"%.1lf,%c,\",\n                              magneticVariation, direction);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining, \",,\");\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))\n            length = snprintf(pMarker, lengthRemaining, \"%c\", 'N'); // N means no fix\n        else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)\n            length = snprintf(pMarker, lengthRemaining, \"%c\", 'A'); // A means autonomous\n        else\n            length = snprintf(pMarker, lengthRemaining, \"%c\", 'D'); // D means differential\n\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n\n        // ------------------\n        // ------$GPGGA------\n        // ------------------\n\n        pMarker = sentence;\n        lengthRemaining = sizeof(sentence);\n\n        length = snprintf(pMarker, lengthRemaining, \"$GPGGA,%02d%02d%02d,\" ,\n                          utcHours, utcMinutes, utcSeconds);\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)\n        {\n            double latitude = location.gpsLocation.latitude;\n            double longitude = location.gpsLocation.longitude;\n            char latHemisphere;\n            char lonHemisphere;\n            double latMinutes;\n            double lonMinutes;\n\n            if (latitude > 0)\n            {\n                latHemisphere = 'N';\n            }\n            else\n            {\n                latHemisphere = 'S';\n                latitude *= -1.0;\n            }\n\n            if (longitude < 0)\n            {\n                lonHemisphere = 'W';\n                longitude *= -1.0;\n            }\n            else\n            {\n                lonHemisphere = 'E';\n            }\n\n            latMinutes = fmod(latitude * 60.0 , 60.0);\n            lonMinutes = fmod(longitude * 60.0 , 60.0);\n\n            length = snprintf(pMarker, lengthRemaining, \"%02d%09.6lf,%c,%03d%09.6lf,%c,\",\n                              (uint8_t)floor(latitude), latMinutes, latHemisphere,\n                              (uint8_t)floor(longitude),lonMinutes, lonHemisphere);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining,\",,,,\");\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        char gpsQuality;\n        if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))\n            gpsQuality = '0'; // 0 means no fix\n        else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->adapter->getPositionMode().mode)\n            gpsQuality = '1'; // 1 means GPS fix\n        else\n            gpsQuality = '2'; // 2 means DGPS fix\n\n        if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)\n        {   // dop is in locationExtended, (QMI)\n            length = snprintf(pMarker, lengthRemaining, \"%c,%02d,%.1f,\",\n                              gpsQuality, svUsedCount, locationExtended.hdop);\n        }\n        else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)\n        {   // dop was cached from sv report (RPC)\n            length = snprintf(pMarker, lengthRemaining, \"%c,%02d,%.1f,\",\n                              gpsQuality, svUsedCount, loc_eng_data_p->hdop);\n        }\n        else\n        {   // no hdop\n            length = snprintf(pMarker, lengthRemaining, \"%c,%02d,,\",\n                              gpsQuality, svUsedCount);\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)\n        {\n            length = snprintf(pMarker, lengthRemaining, \"%.1lf,M,\",\n                              locationExtended.altitudeMeanSeaLevel);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining,\",,\");\n        }\n\n        if (length < 0 || length >= lengthRemaining)\n        {\n            LOC_LOGE(\"NMEA Error in string formatting\");\n            return;\n        }\n        pMarker += length;\n        lengthRemaining -= length;\n\n        if ((location.gpsLocation.flags & GPS_LOCATION_HAS_ALTITUDE) &&\n            (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL))\n        {\n            length = snprintf(pMarker, lengthRemaining, \"%.1lf,M,,\",\n                              location.gpsLocation.altitude - locationExtended.altitudeMeanSeaLevel);\n        }\n        else\n        {\n            length = snprintf(pMarker, lengthRemaining,\",,,\");\n        }\n\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n\n    }\n    //Send blank NMEA reports for non-final fixes\n    else {\n        strlcpy(sentence, \"$GPGSA,A,1,,,,,,,,,,,,,,,\", sizeof(sentence));\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n\n        strlcpy(sentence, \"$GPVTG,,T,,M,,N,,K,N\", sizeof(sentence));\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n\n        strlcpy(sentence, \"$GPRMC,,V,,,,,,,,,,N\", sizeof(sentence));\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n\n        strlcpy(sentence, \"$GPGGA,,,,,,0,,,,,,,,\", sizeof(sentence));\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n    }\n    // clear the dop cache so they can't be used again\n    loc_eng_data_p->pdop = 0;\n    loc_eng_data_p->hdop = 0;\n    loc_eng_data_p->vdop = 0;\n\n    EXIT_LOG(%d, 0);\n}\n\n\n\n/*===========================================================================\nFUNCTION    loc_eng_nmea_generate_sv\n\nDESCRIPTION\n   Generate NMEA sentences generated based on sv report\n\nDEPENDENCIES\n   NONE\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p,\n                              const QcomSvStatus &svStatus, const GpsLocationExtended &locationExtended)\n{\n    ENTRY_LOG();\n\n    char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};\n    char* pMarker = sentence;\n    int lengthRemaining = sizeof(sentence);\n    int length = 0;\n    int svCount = svStatus.num_svs;\n    int sentenceCount = 0;\n    int sentenceNumber = 1;\n    int svNumber = 1;\n    int gpsCount = 0;\n    int glnCount = 0;\n\n    //Count GPS SVs for saparating GPS from GLONASS and throw others\n\n    for(svNumber=1; svNumber <= svCount; svNumber++) {\n        if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START)&&\n            (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) )\n        {\n            gpsCount++;\n        }\n        else if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) &&\n                 (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) )\n        {\n            glnCount++;\n        }\n    }\n\n    // ------------------\n    // ------$GPGSV------\n    // ------------------\n\n    if (gpsCount <= 0)\n    {\n        // no svs in view, so just send a blank $GPGSV sentence\n        strlcpy(sentence, \"$GPGSV,1,1,0,\", sizeof(sentence));\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n    }\n    else\n    {\n        svNumber = 1;\n        sentenceNumber = 1;\n        sentenceCount = gpsCount/4 + (gpsCount % 4 != 0);\n\n        while (sentenceNumber <= sentenceCount)\n        {\n            pMarker = sentence;\n            lengthRemaining = sizeof(sentence);\n\n            length = snprintf(pMarker, lengthRemaining, \"$GPGSV,%d,%d,%02d\",\n                          sentenceCount, sentenceNumber, gpsCount);\n\n            if (length < 0 || length >= lengthRemaining)\n            {\n                LOC_LOGE(\"NMEA Error in string formatting\");\n                return;\n            }\n            pMarker += length;\n            lengthRemaining -= length;\n\n            for (int i=0; (svNumber <= svCount) && (i < 4);  svNumber++)\n            {\n                if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START) &&\n                    (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) )\n                {\n                    length = snprintf(pMarker, lengthRemaining,\",%02d,%02d,%03d,\",\n                                  svStatus.sv_list[svNumber-1].prn,\n                                  (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int\n                                  (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int\n\n                    if (length < 0 || length >= lengthRemaining)\n                    {\n                        LOC_LOGE(\"NMEA Error in string formatting\");\n                        return;\n                    }\n                    pMarker += length;\n                    lengthRemaining -= length;\n\n                    if (svStatus.sv_list[svNumber-1].snr > 0)\n                    {\n                        length = snprintf(pMarker, lengthRemaining,\"%02d\",\n                                         (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int\n\n                        if (length < 0 || length >= lengthRemaining)\n                        {\n                            LOC_LOGE(\"NMEA Error in string formatting\");\n                            return;\n                        }\n                        pMarker += length;\n                        lengthRemaining -= length;\n                    }\n\n                    i++;\n               }\n\n            }\n\n            length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n            loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n            sentenceNumber++;\n\n        }  //while\n\n    } //if\n\n    // ------------------\n    // ------$GLGSV------\n    // ------------------\n\n    if (glnCount <= 0)\n    {\n        // no svs in view, so just send a blank $GLGSV sentence\n        strlcpy(sentence, \"$GLGSV,1,1,0,\", sizeof(sentence));\n        length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n        loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n    }\n    else\n    {\n        svNumber = 1;\n        sentenceNumber = 1;\n        sentenceCount = glnCount/4 + (glnCount % 4 != 0);\n\n        while (sentenceNumber <= sentenceCount)\n        {\n            pMarker = sentence;\n            lengthRemaining = sizeof(sentence);\n\n            length = snprintf(pMarker, lengthRemaining, \"$GLGSV,%d,%d,%02d\",\n                          sentenceCount, sentenceNumber, glnCount);\n\n            if (length < 0 || length >= lengthRemaining)\n            {\n                LOC_LOGE(\"NMEA Error in string formatting\");\n                return;\n            }\n            pMarker += length;\n            lengthRemaining -= length;\n\n            for (int i=0; (svNumber <= svCount) && (i < 4);  svNumber++)\n            {\n                if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) &&\n                    (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) )      {\n\n                    length = snprintf(pMarker, lengthRemaining,\",%02d,%02d,%03d,\",\n                                  svStatus.sv_list[svNumber-1].prn,\n                                  (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int\n                                  (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int\n\n                    if (length < 0 || length >= lengthRemaining)\n                    {\n                        LOC_LOGE(\"NMEA Error in string formatting\");\n                        return;\n                    }\n                    pMarker += length;\n                    lengthRemaining -= length;\n\n                    if (svStatus.sv_list[svNumber-1].snr > 0)\n                    {\n                        length = snprintf(pMarker, lengthRemaining,\"%02d\",\n                                         (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int\n\n                        if (length < 0 || length >= lengthRemaining)\n                        {\n                            LOC_LOGE(\"NMEA Error in string formatting\");\n                            return;\n                        }\n                        pMarker += length;\n                        lengthRemaining -= length;\n                    }\n\n                    i++;\n               }\n\n            }\n\n            length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));\n            loc_eng_nmea_send(sentence, length, loc_eng_data_p);\n            sentenceNumber++;\n\n        }  //while\n\n    }//if\n\n    // cache the used in fix mask, as it will be needed to send $GPGSA\n    // during the position report\n    loc_eng_data_p->sv_used_mask = svStatus.gps_used_in_fix_mask;\n\n    // For RPC, the DOP are sent during sv report, so cache them\n    // now to be sent during position report.\n    // For QMI, the DOP will be in position report.\n    if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)\n    {\n        loc_eng_data_p->pdop = locationExtended.pdop;\n        loc_eng_data_p->hdop = locationExtended.hdop;\n        loc_eng_data_p->vdop = locationExtended.vdop;\n    }\n    else\n    {\n        loc_eng_data_p->pdop = 0;\n        loc_eng_data_p->hdop = 0;\n        loc_eng_data_p->vdop = 0;\n    }\n\n    EXIT_LOG(%d, 0);\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_nmea.h",
    "content": "/* Copyright (c) 2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_ENG_NMEA_H\n#define LOC_ENG_NMEA_H\n\n#include <hardware/gps.h>\n#include <gps_extended.h>\n\n#define NMEA_SENTENCE_MAX_LENGTH 200\n\nvoid loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p);\nint loc_eng_nmea_put_checksum(char *pNmea, int maxSize);\nvoid loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const QcomSvStatus &svStatus, const GpsLocationExtended &locationExtended);\nvoid loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea);\n\n#endif // LOC_ENG_NMEA_H\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_xtra.cpp",
    "content": "/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_eng\"\n\n#include <loc_eng.h>\n#include <MsgTask.h>\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n\nusing namespace loc_core;\n\nstruct LocEngRequestXtraServer : public LocMsg {\n    LocEngAdapter* mAdapter;\n    inline LocEngRequestXtraServer(LocEngAdapter* adapter) :\n        LocMsg(), mAdapter(adapter)\n    {\n        locallog();\n    }\n    inline virtual void proc() const {\n        mAdapter->requestXtraServer();\n    }\n    inline void locallog() const {\n        LOC_LOGV(\"LocEngRequestXtraServer\");\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\nstruct LocEngInjectXtraData : public LocMsg {\n    LocEngAdapter* mAdapter;\n    char* mData;\n    const int mLen;\n    inline LocEngInjectXtraData(LocEngAdapter* adapter,\n                                char* data, int len):\n        LocMsg(), mAdapter(adapter),\n        mData(new char[len]), mLen(len)\n    {\n        memcpy((void*)mData, (void*)data, len);\n        locallog();\n    }\n    inline ~LocEngInjectXtraData()\n    {\n        delete[] mData;\n    }\n    inline virtual void proc() const {\n        mAdapter->setXtraData(mData, mLen);\n    }\n    inline  void locallog() const {\n        LOC_LOGV(\"length: %d\\n  data: %p\", mLen, mData);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\nstruct LocEngSetXtraVersionCheck : public LocMsg {\n    LocEngAdapter *mAdapter;\n    int mCheck;\n    inline LocEngSetXtraVersionCheck(LocEngAdapter* adapter,\n                                        int check):\n        mAdapter(adapter), mCheck(check) {}\n    inline virtual void proc() const {\n        locallog();\n        mAdapter->setXtraVersionCheck(mCheck);\n    }\n    inline void locallog() const {\n        LOC_LOGD(\"%s:%d]: mCheck: %d\",\n                 __func__, __LINE__, mCheck);\n    }\n    inline virtual void log() const {\n        locallog();\n    }\n};\n\n/*===========================================================================\nFUNCTION    loc_eng_xtra_init\n\nDESCRIPTION\n   Initialize XTRA module.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   0: success\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,\n                       GpsXtraExtCallbacks* callbacks)\n{\n    int ret_val = -1;\n    loc_eng_xtra_data_s_type *xtra_module_data_ptr;\n    ENTRY_LOG();\n\n    if(callbacks == NULL) {\n        LOC_LOGE(\"loc_eng_xtra_init: failed, cb is NULL\");\n    } else {\n        xtra_module_data_ptr = &loc_eng_data.xtra_module_data;\n        xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;\n        xtra_module_data_ptr->report_xtra_server_cb = callbacks->report_xtra_server_cb;\n\n        ret_val = 0;\n    }\n    EXIT_LOG(%d, ret_val);\n    return ret_val;\n}\n\n/*===========================================================================\nFUNCTION    loc_eng_xtra_inject_data\n\nDESCRIPTION\n   Injects XTRA file into the engine but buffers the data if engine is busy.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,\n                             char* data, int length)\n{\n    ENTRY_LOG();\n    LocEngAdapter* adapter = loc_eng_data.adapter;\n    adapter->sendMsg(new LocEngInjectXtraData(adapter, data, length));\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n/*===========================================================================\nFUNCTION    loc_eng_xtra_request_server\n\nDESCRIPTION\n   Request the Xtra server url from the modem\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   0\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data)\n{\n    ENTRY_LOG();\n    LocEngAdapter* adapter = loc_eng_data.adapter;\n    adapter->sendMsg(new LocEngRequestXtraServer(adapter));\n    EXIT_LOG(%d, 0);\n    return 0;\n}\n/*===========================================================================\nFUNCTION    loc_eng_xtra_version_check\n\nDESCRIPTION\n   Injects the enable/disable value for checking XTRA version\n   that is specified in gps.conf\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   none\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nvoid loc_eng_xtra_version_check(loc_eng_data_s_type &loc_eng_data,\n                                int check)\n{\n    ENTRY_LOG();\n    LocEngAdapter *adapter = loc_eng_data.adapter;\n    adapter->sendMsg(new LocEngSetXtraVersionCheck(adapter, check));\n    EXIT_LOG(%d, 0);\n}\n"
  },
  {
    "path": "gps/loc_api/libloc_api_50001/loc_eng_xtra.h",
    "content": "/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_ENG_XTRA_H\n#define LOC_ENG_XTRA_H\n\n#include <hardware/gps.h>\n\n// Module data\ntypedef struct\n{\n   // loc_eng_ioctl_cb_data_s_type   ioctl_cb_data;\n   gps_xtra_download_request      download_request_cb;\n   report_xtra_server             report_xtra_server_cb;\n\n   // XTRA data buffer\n   char                          *xtra_data_for_injection;  // NULL if no pending data\n   int                            xtra_data_len;\n} loc_eng_xtra_data_s_type;\n\n#endif // LOC_ENG_XTRA_H\n"
  },
  {
    "path": "gps/utils/Android.mk",
    "content": "ifneq ($(BUILD_TINY_ANDROID),true)\n#Compile this library only for builds with the latest modem image\n\nLOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\n## Libs\nLOCAL_SHARED_LIBRARIES := \\\n    libutils \\\n    libcutils \\\n    liblog\n\nLOCAL_SRC_FILES += \\\n    loc_log.cpp \\\n    loc_cfg.cpp \\\n    msg_q.c \\\n    linked_list.c \\\n    loc_target.cpp \\\n    platform_lib_abstractions/elapsed_millis_since_boot.cpp \\\n    LocHeap.cpp \\\n    LocTimer.cpp \\\n    LocThread.cpp \\\n    MsgTask.cpp \\\n    loc_misc_utils.cpp\n\nLOCAL_CFLAGS += \\\n     -fno-short-enums \\\n     -D_ANDROID_ \\\n     -std=c++11\n\nifeq ($(TARGET_BUILD_VARIANT),user)\n   LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER\nendif\n\nLOCAL_LDFLAGS += -Wl,--export-dynamic\n\n## Includes\nLOCAL_C_INCLUDES:= \\\n    $(LOCAL_PATH)/platform_lib_abstractions\n\nLOCAL_COPY_HEADERS_TO:= gps.utils/\nLOCAL_COPY_HEADERS:= \\\n   loc_log.h \\\n   loc_cfg.h \\\n   log_util.h \\\n   linked_list.h \\\n   msg_q.h \\\n   MsgTask.h \\\n   LocHeap.h \\\n   LocThread.h \\\n   LocTimer.h \\\n   loc_target.h \\\n   loc_timer.h \\\n   LocSharedLock.h \\\n   platform_lib_abstractions/platform_lib_includes.h \\\n   platform_lib_abstractions/platform_lib_time.h \\\n   platform_lib_abstractions/platform_lib_macros.h \\\n   loc_misc_utils.h\n\nLOCAL_MODULE := libgps.utils\nLOCAL_CLANG := false\n\nLOCAL_MODULE_TAGS := optional\n\nLOCAL_PRELINK_MODULE := false\n\ninclude $(BUILD_SHARED_LIBRARY)\nendif # not BUILD_TINY_ANDROID\n"
  },
  {
    "path": "gps/utils/LocHeap.cpp",
    "content": "/* Copyright (c) 2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#include <LocHeap.h>\n\nclass LocHeapNode {\n    friend class LocHeap;\n\n    // size of of the subtree, excluding self, 1 if no subtree\n    int mSize;\n    LocHeapNode* mLeft;\n    LocHeapNode* mRight;\n    LocRankable* mData;\npublic:\n    inline LocHeapNode(LocRankable& data) :\n        mSize(1), mLeft(NULL), mRight(NULL), mData(&data) {}\n    ~LocHeapNode();\n\n    // this only swaps the data of the two nodes, so no\n    // detach / re-attached is necessary\n    void swap(LocHeapNode& node);\n\n    LocRankable* detachData();\n\n    // push a node into the tree stucture, keeping sorted by rank\n    void push(LocHeapNode& node);\n\n    // pop the head node out of the tree stucture. keeping sorted by rank\n    static LocHeapNode* pop(LocHeapNode*& top);\n\n    // remove a specific node from the tree\n    // returns the pointer to the node removed, which would be either the\n    //         same as input (if successfully removed); or NULL (if failed).\n    static LocHeapNode* remove(LocHeapNode*& top, LocRankable& data);\n\n    // convenience method to compare data ranking\n    inline bool outRanks(LocHeapNode& node) { return mData->outRanks(*node.mData); }\n    inline bool outRanks(LocRankable& data) { return mData->outRanks(data); }\n\n    // checks if mSize is correct, AND this node is the highest ranking\n    // of the entire subtree\n    bool checkNodes();\n\n    inline int getSize() { return mSize; }\n};\n\ninline\nLocHeapNode::~LocHeapNode() {\n    if (mLeft) {\n        delete mLeft;\n        mLeft = NULL;\n    }\n    if (mRight) {\n        delete mRight;\n        mRight = NULL;\n    }\n    if (mData) {\n        mData = NULL;\n    }\n}\n\ninline\nvoid LocHeapNode::swap(LocHeapNode& node) {\n    LocRankable* tmpData = node.mData;\n    node.mData = mData;\n    mData = tmpData;\n}\n\ninline\nLocRankable* LocHeapNode::detachData()  {\n    LocRankable* data = mData;\n    mData = NULL;\n    return data;\n}\n\n// push keeps the tree sorted by rank, it also tries to balance the\n// tree by adding the new node to the smaller of the subtrees.\n// The pointer to the tree and internal links never change. If the\n// mData of tree top ranks lower than that of the incoming node,\n// mData will be swapped with that of the incoming node to ensure\n// ranking, no restructuring the container nodes.\nvoid LocHeapNode::push(LocHeapNode& node) {\n    // ensure the current node ranks higher than in the incoming one\n    if (node.outRanks(*this)) {\n        swap(node);\n    }\n\n    // now drop the new node (ensured lower than *this) into a subtree\n    if (NULL == mLeft) {\n        mLeft = &node;\n    } else if (NULL == mRight) {\n        mRight = &node;\n    } else if (mLeft->mSize <= mRight->mSize) {\n        mLeft->push(node);\n    } else {\n        mRight->push(node);\n    }\n    mSize++;\n}\n\n// pop keeps the tree sorted by rank, but it does not try to balance\n// the tree. It recursively swaps with the higher ranked top of the\n// subtrees.\n// The return is a popped out node from leaf level, that has the data\n// swapped all the way down from the top. The pinter to the tree and\n// internal links will not be changed or restructured, except for the\n// node that is popped out.\n// If the return pointer == this, this the last node in the tree.\nLocHeapNode* LocHeapNode::pop(LocHeapNode*& top) {\n    // we know the top has the highest ranking at this point, else\n    // the tree is broken. This top will be popped out.  But we need\n    // a node from the left or right child, whichever ranks higher,\n    // to replace the current top. This then will need to be done\n    // recursively to the leaf level. So we swap the mData of the\n    // current top node all the way down to the leaf level.\n    LocHeapNode* poppedNode = top;\n    // top is losing a node in its subtree\n    top->mSize--;\n    if (top->mLeft || top->mRight) {\n        // if mLeft is NULL, mRight for sure is NOT NULL, take that;\n        // else if mRight is NULL, mLeft for sure is NOT, take that;\n        // else we take the address of whatever has higher ranking mData\n        LocHeapNode*& subTop = (NULL == top->mLeft) ? top->mRight :\n            ((NULL == top->mRight) ? top->mLeft :\n             (top->mLeft->outRanks(*(top->mRight)) ? top->mLeft : top->mRight));\n        // swap mData, the tree top gets updated with the new data.\n        top->swap(*subTop);\n        // pop out from the subtree\n        poppedNode = pop(subTop);\n    } else {\n        // if the top has only single node\n        // detach the poppedNode from the tree\n        // subTop is the reference of ether mLeft or mRight\n        // NOT a local stack pointer. so it MUST be NULL'ed here.\n        top = NULL;\n    }\n\n    return poppedNode;\n}\n\n// navigating through the tree and find the node that hass the input\n// data. Since this is a heap, we do recursive linear search.\n// returns the pointer to the node removed, which would be either the\n//         same as input (if successfully removed); or NULL (if failed).\nLocHeapNode* LocHeapNode::remove(LocHeapNode*& top, LocRankable& data) {\n    LocHeapNode* removedNode = NULL;\n    // this is the node, by address\n    if (&data == (LocRankable*)(top->mData)) {\n        // pop this node out\n        removedNode = pop(top);\n    } else if (!data.outRanks(*top->mData)) {\n        // subtrees might have this node\n        if (top->mLeft) {\n            removedNode = remove(top->mLeft, data);\n        }\n        // if we did not find in mLeft, and mRight is not empty\n        if (!removedNode && top->mRight) {\n            removedNode = remove(top->mRight, data);\n        }\n\n        // top lost a node in its subtree\n        if (removedNode) {\n            top->mSize--;\n        }\n    }\n\n    return removedNode;\n}\n\n// checks if mSize is correct, AND this node is the highest ranking\n// of the entire subtree\nbool LocHeapNode::checkNodes() {\n    // size of the current subtree\n    int totalSize = mSize;\n    if (mLeft) {\n        // check the consistency of left subtree\n        if (mLeft->outRanks(*this) || !mLeft->checkNodes()) {\n            return false;\n        }\n        // subtract the size of left subtree (with subtree head)\n        totalSize -= mLeft->mSize;\n    }\n\n    if (mRight) {\n        // check the consistency of right subtree\n        if (mRight->outRanks(*this) || !mRight->checkNodes()) {\n            return false;\n        }\n        // subtract the size of right subtree (with subtree head)\n        totalSize -= mRight->mSize;\n    }\n\n    // for the tree nodes to consistent, totalSize must be 1 now\n    return totalSize == 1;\n}\n\nLocHeap::~LocHeap() {\n    if (mTree) {\n        delete mTree;\n    }\n}\n\nvoid LocHeap::push(LocRankable& node) {\n    LocHeapNode* heapNode = new LocHeapNode(node);\n    if (!mTree) {\n        mTree = heapNode;\n    } else {\n        mTree->push(*heapNode);\n    }\n}\n\nLocRankable* LocHeap::peek() {\n    LocRankable* top = NULL;\n    if (mTree) {\n        top = mTree->mData;\n    }\n    return top;\n}\n\nLocRankable* LocHeap::pop() {\n    LocRankable* locNode = NULL;\n    if (mTree) {\n        // mTree may become NULL after this call\n        LocHeapNode* heapNode = LocHeapNode::pop(mTree);\n        locNode = heapNode->detachData();\n        delete heapNode;\n    }\n    return locNode;\n}\n\nLocRankable* LocHeap::remove(LocRankable& rankable) {\n    LocRankable* locNode = NULL;\n    if (mTree) {\n        // mTree may become NULL after this call\n        LocHeapNode* heapNode = LocHeapNode::remove(mTree, rankable);\n        if (heapNode) {\n            locNode = heapNode->detachData();\n            delete heapNode;\n        }\n    }\n    return locNode;\n}\n\n#ifdef __LOC_UNIT_TEST__\nbool LocHeap::checkTree() {\n    return ((NULL == mTree) || mTree->checkNodes());\n}\nuint32_t LocHeap::getTreeSize() {\n    return (NULL == mTree) ? 0 : mTree->getSize();\n}\n#endif\n\n#ifdef __LOC_DEBUG__\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n\nclass LocHeapDebug : public LocHeap {\npublic:\n    bool checkTree() {\n        return ((NULL == mTree) || mTree->checkNodes());\n    }\n\n    uint32_t getTreeSize() {\n        return (NULL == mTree) ? 0 : (mTree->getSize());\n    }\n};\n\nclass LocHeapDebugData : public LocRankable {\n    const int mID;\npublic:\n    LocHeapDebugData(int id) : mID(id) {}\n    inline virtual int ranks(LocRankable& rankable) {\n        LocHeapDebugData* testData = dynamic_cast<LocHeapDebugData*>(&rankable);\n        return testData->mID - mID;\n    }\n};\n\n// For Linux command line testing:\n// compilation: g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../vendor/qcom/proprietary/gps-internal/unit-tests/fakes_for_host -I../../../../system/core/include LocHeap.cpp\n// test: valgrind --leak-check=full ./a.out 100\nint main(int argc, char** argv) {\n    srand(time(NULL));\n    int tries = atoi(argv[1]);\n    int checks = tries >> 3;\n    LocHeapDebug heap;\n    int treeSize = 0;\n\n    for (int i = 0; i < tries; i++) {\n        if (i % checks == 0 && !heap.checkTree()) {\n            printf(\"tree check failed before %dth op\\n\", i);\n        }\n        int r = rand();\n\n        if (r & 1) {\n            LocHeapDebugData* data = new LocHeapDebugData(r >> 1);\n            heap.push(dynamic_cast<LocRankable&>(*data));\n            treeSize++;\n        } else {\n            LocRankable* rankable = heap.pop();\n            if (rankable) {\n                delete rankable;\n            }\n            treeSize ? treeSize-- : 0;\n        }\n\n        printf(\"%s: %d == %d\\n\", (r&1)?\"push\":\"pop\", treeSize, heap.getTreeSize());\n        if (treeSize != heap.getTreeSize()) {\n            printf(\"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\\n\");\n            tries = i+1;\n            break;\n        }\n    }\n\n    if (!heap.checkTree()) {\n        printf(\"!!!!!!!!!!tree check failed at the end after %d ops!!!!!!!\\n\", tries);\n    } else {\n        printf(\"success!\\n\");\n    }\n\n    for (LocRankable* data = heap.pop(); NULL != data; data = heap.pop()) {\n        delete data;\n    }\n\n    return 0;\n}\n\n#endif\n"
  },
  {
    "path": "gps/utils/LocHeap.h",
    "content": "/* Copyright (c) 2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef __LOC_HEAP__\n#define __LOC_HEAP__\n\n#include <stddef.h>\n#include <string.h>\n\n// abstract class to be implemented by client to provide a rankable class\nclass LocRankable {\npublic:\n    virtual inline ~LocRankable() {}\n\n    // method to rank objects of such type for sorting purposes.\n    // The pointer of the input node would be stored in the heap.\n    // >0 if ranks higher than the input;\n    // ==0 if equally ranks with the input;\n    // <0 if ranks lower than the input\n    virtual int ranks(LocRankable& rankable) = 0;\n\n    // convenient method to rank objects of such type for sorting purposes.\n    inline bool outRanks(LocRankable& rankable) { return ranks(rankable) > 0; }\n};\n\n// opaque class to provide service implementation.\nclass LocHeapNode;\n\n// a heap whose left and right children are not sorted. It is sorted only vertically,\n// i.e. parent always ranks higher than children, if they exist. Ranking algorithm is\n// implemented in Rankable. The reason that there is no sort between children is to\n// help beter balance the tree with lower cost. When a node is pushed to the tree,\n// it is guaranteed that the subtree that is smaller gets to have the new node.\nclass LocHeap {\nprotected:\n    LocHeapNode* mTree;\npublic:\n    inline LocHeap() : mTree(NULL) {}\n    ~LocHeap();\n\n    // push keeps the tree sorted by rank, it also tries to balance the\n    // tree by adding the new node to the smaller of the subtrees.\n    // node is reference to an obj that is managed by client, that client\n    //      creates and destroyes. The destroy should happen after the\n    //      node is popped out from the heap.\n    void push(LocRankable& node);\n\n    // Peeks the node data on tree top, which has currently the highest ranking\n    // There is no change the tree structure with this operation\n    // Returns NULL if the tree is empty, otherwise pointer to the node data of\n    //         the tree top.\n    LocRankable* peek();\n\n    // pop keeps the tree sorted by rank, but it does not try to balance\n    // the tree.\n    // Return - pointer to the node popped out, or NULL if heap is already empty\n    LocRankable* pop();\n\n    // navigating through the tree and find the node that ranks the same\n    // as the input data, then remove it from the tree. Rank is implemented\n    // by rankable obj.\n    // returns the pointer to the node removed; or NULL (if failed).\n    LocRankable* remove(LocRankable& rankable);\n\n#ifdef __LOC_UNIT_TEST__\n    bool checkTree();\n    uint32_t getTreeSize();\n#endif\n};\n\n#endif //__LOC_HEAP__\n"
  },
  {
    "path": "gps/utils/LocSharedLock.h",
    "content": "/* Copyright (c) 2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef __LOC_SHARED_LOCK__\n#define __LOC_SHARED_LOCK__\n\n#include <stddef.h>\n#include <pthread.h>\n\n// This is a utility created for use cases such that there are more than\n// one client who need to share the same lock, but it is not predictable\n// which of these clients is to last to go away. This shared lock deletes\n// itself when the last client calls its drop() method. To add a cient,\n// this share lock's share() method has to be called, so that the obj\n// can maintain an accurate client count.\nclass LocSharedLock {\n    uint32_t mRef;\n    pthread_mutex_t mMutex;\n    inline ~LocSharedLock() { pthread_mutex_destroy(&mMutex); }\npublic:\n    // first client to create this LockSharedLock\n    inline LocSharedLock() : mRef(1) { pthread_mutex_init(&mMutex, NULL); }\n    // following client(s) are to *share()* this lock created by the first client\n    inline LocSharedLock* share() { mRef++; return this; }\n    // whe a client no longer needs this shared lock, drop() shall be called.\n    inline void drop() { if (0 == --mRef) delete this; }\n    // locking the lock to enter critical section\n    inline void lock() { pthread_mutex_lock(&mMutex); }\n    // unlocking the lock to leave the critical section\n    inline void unlock() { pthread_mutex_unlock(&mMutex); }\n};\n\n#endif //__LOC_SHARED_LOCK__\n"
  },
  {
    "path": "gps/utils/LocThread.cpp",
    "content": "/* Copyright (c) 2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#include <LocThread.h>\n#include <string.h>\n#include <pthread.h>\n\nclass LocThreadDelegate {\n    LocRunnable* mRunnable;\n    bool mJoinable;\n    pthread_t mThandle;\n    pthread_mutex_t mMutex;\n    int mRefCount;\n    ~LocThreadDelegate();\n    LocThreadDelegate(LocThread::tCreate creator, const char* threadName,\n                      LocRunnable* runnable, bool joinable);\n    void destroy();\npublic:\n    static LocThreadDelegate* create(LocThread::tCreate creator,\n            const char* threadName, LocRunnable* runnable, bool joinable);\n    void stop();\n    // bye() is for the parent thread to go away. if joinable,\n    // parent must stop the spawned thread, join, and then\n    // destroy(); if detached, the parent can go straight\n    // ahead to destroy()\n    inline void bye() { mJoinable ? stop() : destroy(); }\n    inline bool isRunning() { return (NULL != mRunnable); }\n    static void* threadMain(void* arg);\n};\n\n// it is important to note that internal members must be\n// initialized to values as if pthread_create succeeds.\n// This is to avoid the race condition between the threads,\n// once the thread is created, some of these values will\n// be check in the spawned thread, and must set correctly\n// then and there.\n// However, upon pthread_create failure, the data members\n// must be set to  indicate failure, e.g. mRunnable, and\n// threashold approprietly for destroy(), e.g. mRefCount.\nLocThreadDelegate::LocThreadDelegate(LocThread::tCreate creator,\n        const char* threadName, LocRunnable* runnable, bool joinable) :\n    mRunnable(runnable), mJoinable(joinable), mThandle(NULL),\n    mMutex(PTHREAD_MUTEX_INITIALIZER), mRefCount(2) {\n\n    // set up thread name, if nothing is passed in\n    if (!threadName) {\n        threadName = \"LocThread\";\n    }\n\n    // create the thread here, then if successful\n    // and a name is given, we set the thread name\n    if (creator) {\n        mThandle = creator(threadName, threadMain, this);\n    } else if (pthread_create(&mThandle, NULL, threadMain, this)) {\n        // pthread_create() failed\n        mThandle = NULL;\n    }\n\n    if (mThandle) {\n        // set thread name\n        char lname[16];\n        int len = sizeof(lname) - 1;\n        memcpy(lname, threadName, len);\n        lname[len] = 0;\n        // set the thread name here\n        pthread_setname_np(mThandle, lname);\n\n        // detach, if not joinable\n        if (!joinable) {\n            pthread_detach(mThandle);\n        }\n    } else {\n        // must set these values upon failure\n        mRunnable = NULL;\n        mJoinable = false;\n        mRefCount = 1;\n    }\n}\n\ninline\nLocThreadDelegate::~LocThreadDelegate() {\n    // at this point nothing should need done any more\n}\n\n// factory method so that we could return NULL upon failure\nLocThreadDelegate* LocThreadDelegate::create(LocThread::tCreate creator,\n        const char* threadName, LocRunnable* runnable, bool joinable) {\n    LocThreadDelegate* thread = NULL;\n    if (runnable) {\n        thread = new LocThreadDelegate(creator, threadName, runnable, joinable);\n        if (thread && !thread->isRunning()) {\n            thread->destroy();\n            thread = NULL;\n        }\n    }\n\n    return thread;\n}\n\n// The order is importang\n// NULLing mRunnalbe stops the while loop in threadMain()\n// join() if mJoinble must come before destroy() call, as\n// the obj must remain alive at this time so that mThandle\n// remains valud.\nvoid LocThreadDelegate::stop() {\n    // mRunnable and mJoinable are reset on different triggers.\n    // mRunnable may get nulled on the spawned thread's way out;\n    //           or here.\n    // mJouinable (if ever been true) gets falsed when client\n    //            thread triggers stop, with either a stop()\n    //            call or the client releases thread obj handle.\n    if (mRunnable) {\n        mRunnable = NULL;\n    }\n    if (mJoinable) {\n        mJoinable = false;\n        pthread_join(mThandle, NULL);\n    }\n    // call destroy() to possibly delete the obj\n    destroy();\n}\n\n// method for clients to call to release the obj\n// when it is a detached thread, the client thread\n// and the spawned thread can both try to destroy()\n// asynchronously. And we delete this obj when\n// mRefCount becomes 0.\nvoid LocThreadDelegate::destroy() {\n    // else case shouldn't happen, unless there is a\n    // leaking obj. But only our code here has such\n    // obj, so if we test our code well, else case\n    // will never happen\n    if (mRefCount > 0) {\n        // we need a flag on the stack\n        bool callDelete = false;\n\n        // critical section between threads\n        pthread_mutex_lock(&mMutex);\n        // last destroy() call\n        callDelete = (1 == mRefCount--);\n        pthread_mutex_unlock(&mMutex);\n\n        // upon last destroy() call we delete this obj\n        if (callDelete) {\n            delete this;\n        }\n    }\n}\n\nvoid* LocThreadDelegate::threadMain(void* arg) {\n    LocThreadDelegate* locThread = (LocThreadDelegate*)(arg);\n\n    if (locThread) {\n        LocRunnable* runnable = locThread->mRunnable;\n\n        if (runnable) {\n            if (locThread->isRunning()) {\n                runnable->prerun();\n            }\n\n            while (locThread->isRunning() && runnable->run());\n\n            if (locThread->isRunning()) {\n                runnable->postrun();\n            }\n\n            // at this time, locThread->mRunnable may or may not be NULL\n            // NULL it just to be safe and clean, as we want the field\n            // in the released memory slot to be NULL.\n            locThread->mRunnable = NULL;\n            delete runnable;\n        }\n        locThread->destroy();\n    }\n\n    return NULL;\n}\n\nLocThread::~LocThread() {\n    if (mThread) {\n        mThread->bye();\n        mThread = NULL;\n    }\n}\n\nbool LocThread::start(tCreate creator, const char* threadName, LocRunnable* runnable, bool joinable) {\n    bool success = false;\n    if (!mThread) {\n        mThread = LocThreadDelegate::create(creator, threadName, runnable, joinable);\n        // true only if thread is created successfully\n        success = (NULL != mThread);\n    }\n    return success;\n}\n\nvoid LocThread::stop() {\n    if (mThread) {\n        mThread->stop();\n        mThread = NULL;\n    }\n}\n\n#ifdef __LOC_DEBUG__\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <unistd.h>\n\nclass LocRunnableTest1 : public LocRunnable {\n    int mID;\npublic:\n    LocRunnableTest1(int id) : LocRunnable(), mID(id) {}\n    virtual bool run() {\n        printf(\"LocRunnableTest1: %d\\n\", mID++);\n        sleep(1);\n        return true;\n    }\n};\n\n// on linux command line:\n// compile: g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -std=c++0x -I. -I../../../../vendor/qcom/proprietary/gps-internal/unit-tests/fakes_for_host -I../../../../system/core/include -lpthread LocThread.cpp\n// test detached thread: valgrind ./a.out 0\n// test joinable thread: valgrind ./a.out 1\nint main(int argc, char** argv) {\n    LocRunnableTest1 test(10);\n\n    LocThread thread;\n    thread.start(\"LocThreadTest\", test, atoi(argv[1]));\n\n    sleep(10);\n\n    thread.stop();\n\n    sleep(5);\n\n    return 0;\n}\n\n#endif\n"
  },
  {
    "path": "gps/utils/LocThread.h",
    "content": "/* Copyright (c) 2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef __LOC_THREAD__\n#define __LOC_THREAD__\n\n#include <stddef.h>\n#include <pthread.h>\n\n// abstract class to be implemented by client to provide a runnable class\n// which gets scheduled by LocThread\nclass LocRunnable {\npublic:\n    inline LocRunnable() {}\n    inline virtual ~LocRunnable() {}\n\n    // The method to be implemented by thread clients\n    // and be scheduled by LocThread\n    // This method will be repeated called until it returns false; or\n    // until thread is stopped.\n    virtual bool run() = 0;\n\n    // The method to be run before thread loop (conditionally repeatedly)\n    // calls run()\n    inline virtual void prerun() {}\n\n    // The method to be run after thread loop (conditionally repeatedly)\n    // calls run()\n    inline virtual void postrun() {}\n};\n\n// opaque class to provide service implementation.\nclass LocThreadDelegate;\n\n// A utility class to create a thread and run LocRunnable\n// caller passes in.\nclass LocThread {\n    LocThreadDelegate* mThread;\npublic:\n    inline LocThread() : mThread(NULL) {}\n    virtual ~LocThread();\n\n    typedef pthread_t (*tCreate)(const char* name, void* (*start)(void*), void* arg);\n    // client starts thread with a runnable, which implements\n    // the logics to fun in the created thread context.\n    // The thread could be either joinable or detached.\n    // runnable is an obj managed by client. Client creates and\n    //          frees it (but must be after stop() is called, or\n    //          this LocThread obj is deleted).\n    //          The obj will be deleted by LocThread if start()\n    //          returns true. Else it is client's responsibility\n    //          to delete the object\n    // Returns 0 if success; false if failure.\n    bool start(tCreate creator, const char* threadName, LocRunnable* runnable, bool joinable = true);\n    inline bool start(const char* threadName, LocRunnable* runnable, bool joinable = true) {\n        return start(NULL, threadName, runnable, joinable);\n    }\n\n    // NOTE: if this is a joinable thread, this stop may block\n    // for a while until the thread is joined.\n    void stop();\n\n    // thread status check\n    inline bool isRunning() { return NULL != mThread; }\n};\n\n#endif //__LOC_THREAD__\n"
  },
  {
    "path": "gps/utils/LocTimer.cpp",
    "content": "/* Copyright (c) 2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n#include <errno.h>\n#include <loc_timer.h>\n#include <sys/timerfd.h>\n#include <sys/epoll.h>\n#include <LocTimer.h>\n#include <LocHeap.h>\n#include <LocThread.h>\n#include <LocSharedLock.h>\n#include <MsgTask.h>\n\n#ifdef __HOST_UNIT_TEST__\n#define EPOLLWAKEUP 0\n#define CLOCK_BOOTTIME CLOCK_MONOTONIC\n#define CLOCK_BOOTTIME_ALARM CLOCK_MONOTONIC\n#endif\n\n/*\nThere are implementations of 5 classes in this file:\nLocTimer, LocTimerDelegate, LocTimerContainer, LocTimerPollTask, LocTimerWrapper\n\nLocTimer - client front end, interface for client to start / stop timers, also\n           to provide a callback.\nLocTimerDelegate - an internal timer entity, which also is a LocRankable obj.\n                   Its life cycle is different than that of LocTimer. It gets\n                   created when LocTimer::start() is called, and gets deleted\n                   when it expires or clients calls the hosting LocTimer obj's\n                   stop() method. When a LocTimerDelegate obj is ticking, it\n                   stays in the corresponding LocTimerContainer. When expired\n                   or stopped, the obj is removed from the container. Since it\n                   is also a LocRankable obj, and LocTimerContainer also is a\n                   heap, its ranks() implementation decides where it is placed\n                   in the heap.\nLocTimerContainer - core of the timer service. It is a container (derived from\n                    LocHeap) for LocTimerDelegate (implements LocRankable) objs.\n                    There are 2 of such containers, one for sw timers (or Linux\n                    timers) one for hw timers (or Linux alarms). It adds one of\n                    each (those that expire the soonest) to kernel via services\n                    provided by LocTimerPollTask. All the heap management on the\n                    LocTimerDelegate objs are done in the MsgTask context, such\n                    that synchronization is ensured.\nLocTimerPollTask - is a class that wraps timerfd and epoll POXIS APIs. It also\n                   both implements LocRunnalbe with epoll_wait() in the run()\n                   method. It is also a LocThread client, so as to loop the run\n                   method.\nLocTimerWrapper - a LocTimer client itself, to implement the existing C API with\n                  APIs, loc_timer_start() and loc_timer_stop().\n\n*/\n\nclass LocTimerPollTask;\n\n// This is a multi-functaional class that:\n// * extends the LocHeap class for the detection of head update upon add / remove\n//   events. When that happens, soonest time out changes, so timerfd needs update.\n// * contains the timers, and add / remove them into the heap\n// * provides and maps 2 of such containers, one for timers (or  mSwTimers), one\n//   for alarms (or mHwTimers);\n// * provides a polling thread;\n// * provides a MsgTask thread for synchronized add / remove / timer client callback.\nclass LocTimerContainer : public LocHeap {\n    // mutex to synchronize getters of static members\n    static pthread_mutex_t mMutex;\n    // Container of timers\n    static LocTimerContainer* mSwTimers;\n    // Container of alarms\n    static LocTimerContainer* mHwTimers;\n    // Msg task to provider msg Q, sender and reader.\n    static MsgTask* mMsgTask;\n    // Poll task to provide epoll call and threading to poll.\n    static LocTimerPollTask* mPollTask;\n    // timer / alarm fd\n    int mDevFd;\n    // ctor\n    LocTimerContainer(bool wakeOnExpire);\n    // dtor\n    ~LocTimerContainer();\n    static MsgTask* getMsgTaskLocked();\n    static LocTimerPollTask* getPollTaskLocked();\n    // extend LocHeap and pop if the top outRanks input\n    LocTimerDelegate* popIfOutRanks(LocTimerDelegate& timer);\n    // update the timer POSIX calls with updated soonest timer spec\n    void updateSoonestTime(LocTimerDelegate* priorTop);\n\npublic:\n    // factory method to control the creation of mSwTimers / mHwTimers\n    static LocTimerContainer* get(bool wakeOnExpire);\n\n    LocTimerDelegate* getSoonestTimer();\n    int getTimerFd();\n    // add a timer / alarm obj into the container\n    void add(LocTimerDelegate& timer);\n    // remove a timer / alarm obj from the container\n    void remove(LocTimerDelegate& timer);\n    // handling of timer / alarm expiration\n    void expire();\n};\n\n// This class implements the polling thread that epolls imer / alarm fds.\n// The LocRunnable::run() contains the actual polling.  The other methods\n// will be run in the caller's thread context to add / remove timer / alarm\n// fds the kernel, while the polling is blocked on epoll_wait() call.\n// Since the design is that we have maximally 2 polls, one for all the\n// timers; one for all the alarms, we will poll at most on 2 fds.  But it\n// is possile that all we have are only timers or alarms at one time, so we\n// allow dynamically add / remove fds we poll on. The design decision of\n// having 1 fd per container of timer / alarm is such that, we may not need\n// to make a system call each time a timer / alarm is added / removed, unless\n// that changes the \"soonest\" time out of that of all the timers / alarms.\nclass LocTimerPollTask : public LocRunnable {\n    // the epoll fd\n    const int mFd;\n    // the thread that calls run() method\n    LocThread* mThread;\n    friend class LocThreadDelegate;\n    // dtor\n    ~LocTimerPollTask();\npublic:\n    // ctor\n    LocTimerPollTask();\n    // this obj will be deleted once thread is deleted\n    void destroy();\n    // add a container of timers. Each contain has a unique device fd, i.e.\n    // either timer or alarm fd, and a heap of timers / alarms. It is expected\n    // that container would have written to the device fd with the soonest\n    // time out value in the heap at the time of calling this method. So all\n    // this method does is to add the fd of the input container to the poll\n    // and also add the pointer of the container to the event data ptr, such\n    // when poll_wait wakes up on events, we know who is the owner of the fd.\n    void addPoll(LocTimerContainer& timerContainer);\n    // remove a fd that is assciated with a container. The expectation is that\n    // the atual timer would have been removed from the container.\n    void removePoll(LocTimerContainer& timerContainer);\n    // The polling thread context will call this method. This is where\n    // epoll_wait() is blocking and waiting for events..\n    virtual bool run();\n};\n\n// Internal class of timer obj. It gets born when client calls LocTimer::start();\n// and gets deleted when client calls LocTimer::stop() or when the it expire()'s.\n// This class implements LocRankable::ranks() so that when an obj is added into\n// the container (of LocHeap), it gets placed in sorted order.\nclass LocTimerDelegate : public LocRankable {\n    friend class LocTimerContainer;\n    friend class LocTimer;\n    LocTimer* mClient;\n    LocSharedLock* mLock;\n    struct timespec mFutureTime;\n    LocTimerContainer* mContainer;\n    // not a complete obj, just ctor for LocRankable comparisons\n    inline LocTimerDelegate(struct timespec& delay)\n        : mClient(NULL), mLock(NULL), mFutureTime(delay), mContainer(NULL) {}\n    inline ~LocTimerDelegate() { if (mLock) { mLock->drop(); mLock = NULL; } }\npublic:\n    LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire);\n    void destroyLocked();\n    // LocRankable virtual method\n    virtual int ranks(LocRankable& rankable);\n    void expire();\n    inline struct timespec getFutureTime() { return mFutureTime; }\n};\n\n/***************************LocTimerContainer methods***************************/\n\n// Most of these static recources are created on demand. They however are never\n// destoyed. The theory is that there are processes that link to this util lib\n// but never use timer, then these resources would never need to be created.\n// For those processes that do use timer, it will likely also need to every\n// once in a while. It might be cheaper keeping them around.\npthread_mutex_t LocTimerContainer::mMutex = PTHREAD_MUTEX_INITIALIZER;\nLocTimerContainer* LocTimerContainer::mSwTimers = NULL;\nLocTimerContainer* LocTimerContainer::mHwTimers = NULL;\nMsgTask* LocTimerContainer::mMsgTask = NULL;\nLocTimerPollTask* LocTimerContainer::mPollTask = NULL;\n\n// ctor - initialize timer heaps\n// A container for swTimer (timer) is created, when wakeOnExpire is true; or\n// HwTimer (alarm), when wakeOnExpire is false.\nLocTimerContainer::LocTimerContainer(bool wakeOnExpire) :\n    mDevFd(timerfd_create(wakeOnExpire ? CLOCK_BOOTTIME_ALARM : CLOCK_BOOTTIME, 0)) {\n\n    if ((-1 == mDevFd) && (errno == EINVAL)) {\n        LOC_LOGW(\"%s: timerfd_create failure, fallback to CLOCK_MONOTONIC - %s\",\n            __FUNCTION__, strerror(errno));\n        mDevFd = timerfd_create(CLOCK_MONOTONIC, 0);\n    }\n\n    if (-1 != mDevFd) {\n        // ensure we have the necessary resources created\n        LocTimerContainer::getPollTaskLocked();\n        LocTimerContainer::getMsgTaskLocked();\n    } else {\n        LOC_LOGE(\"%s: timerfd_create failure - %s\", __FUNCTION__, strerror(errno));\n    }\n}\n\n// dtor\n// we do not ever destroy the static resources.\ninline\nLocTimerContainer::~LocTimerContainer() {\n    close(mDevFd);\n}\n\nLocTimerContainer* LocTimerContainer::get(bool wakeOnExpire) {\n    // get the reference of either mHwTimer or mSwTimers per wakeOnExpire\n    LocTimerContainer*& container = wakeOnExpire ? mHwTimers : mSwTimers;\n    // it is cheap to check pointer first than locking mutext unconditionally\n    if (!container) {\n        pthread_mutex_lock(&mMutex);\n        // let's check one more time to be safe\n        if (!container) {\n            container = new LocTimerContainer(wakeOnExpire);\n            // timerfd_create failure\n            if (-1 == container->getTimerFd()) {\n                delete container;\n                container = NULL;\n            }\n        }\n        pthread_mutex_unlock(&mMutex);\n    }\n    return container;\n}\n\nMsgTask* LocTimerContainer::getMsgTaskLocked() {\n    // it is cheap to check pointer first than locking mutext unconditionally\n    if (!mMsgTask) {\n        mMsgTask = new MsgTask(\"LocTimerMsgTask\", false);\n    }\n    return mMsgTask;\n}\n\nLocTimerPollTask* LocTimerContainer::getPollTaskLocked() {\n    // it is cheap to check pointer first than locking mutext unconditionally\n    if (!mPollTask) {\n        mPollTask = new LocTimerPollTask();\n    }\n    return mPollTask;\n}\n\ninline\nLocTimerDelegate* LocTimerContainer::getSoonestTimer() {\n    return (LocTimerDelegate*)(peek());\n}\n\ninline\nint LocTimerContainer::getTimerFd() {\n    return mDevFd;\n}\n\nvoid LocTimerContainer::updateSoonestTime(LocTimerDelegate* priorTop) {\n    LocTimerDelegate* curTop = getSoonestTimer();\n\n    // check if top has changed\n    if (curTop != priorTop) {\n        struct itimerspec delay = {0};\n        bool toSetTime = false;\n        // if tree is empty now, we remove poll and disarm timer\n        if (!curTop) {\n            mPollTask->removePoll(*this);\n            // setting the values to disarm timer\n            delay.it_value.tv_sec = 0;\n            delay.it_value.tv_nsec = 0;\n            toSetTime = true;\n        } else if (!priorTop || curTop->outRanks(*priorTop)) {\n            // do this first to avoid race condition, in case settime is called\n            // with too small an interval\n            mPollTask->addPoll(*this);\n            delay.it_value = curTop->getFutureTime();\n            toSetTime = true;\n        }\n        if (toSetTime) {\n            timerfd_settime(getTimerFd(), TFD_TIMER_ABSTIME, &delay, NULL);\n        }\n    }\n}\n\n// all the heap management is done in the MsgTask context.\ninline\nvoid LocTimerContainer::add(LocTimerDelegate& timer) {\n    struct MsgTimerPush : public LocMsg {\n        LocTimerContainer* mTimerContainer;\n        LocHeapNode* mTree;\n        LocTimerDelegate* mTimer;\n        inline MsgTimerPush(LocTimerContainer& container, LocTimerDelegate& timer) :\n            LocMsg(), mTimerContainer(&container), mTimer(&timer) {}\n        inline virtual void proc() const {\n            LocTimerDelegate* priorTop = mTimerContainer->getSoonestTimer();\n            mTimerContainer->push((LocRankable&)(*mTimer));\n            mTimerContainer->updateSoonestTime(priorTop);\n        }\n    };\n\n    mMsgTask->sendMsg(new MsgTimerPush(*this, timer));\n}\n\n// all the heap management is done in the MsgTask context.\nvoid LocTimerContainer::remove(LocTimerDelegate& timer) {\n    struct MsgTimerRemove : public LocMsg {\n        LocTimerContainer* mTimerContainer;\n        LocTimerDelegate* mTimer;\n        inline MsgTimerRemove(LocTimerContainer& container, LocTimerDelegate& timer) :\n            LocMsg(), mTimerContainer(&container), mTimer(&timer) {}\n        inline virtual void proc() const {\n            LocTimerDelegate* priorTop = mTimerContainer->getSoonestTimer();\n\n            // update soonest timer only if mTimer is actually removed from\n            // mTimerContainer AND mTimer is not priorTop.\n            if (priorTop == ((LocHeap*)mTimerContainer)->remove((LocRankable&)*mTimer)) {\n                // if passing in NULL, we tell updateSoonestTime to update\n                // kernel with the current top timer interval.\n                mTimerContainer->updateSoonestTime(NULL);\n            }\n            // all timers are deleted here, and only here.\n            delete mTimer;\n        }\n    };\n\n    mMsgTask->sendMsg(new MsgTimerRemove(*this, timer));\n}\n\n// all the heap management is done in the MsgTask context.\n// Upon expire, we check and continuously pop the heap until\n// the top node's timeout is in the future.\nvoid LocTimerContainer::expire() {\n    struct MsgTimerExpire : public LocMsg {\n        LocTimerContainer* mTimerContainer;\n        inline MsgTimerExpire(LocTimerContainer& container) :\n            LocMsg(), mTimerContainer(&container) {}\n        inline virtual void proc() const {\n            struct timespec now;\n            // get time spec of now\n            clock_gettime(CLOCK_BOOTTIME, &now);\n            LocTimerDelegate timerOfNow(now);\n            // pop everything in the heap that outRanks now, i.e. has time older than now\n            // and then call expire() on that timer.\n            for (LocTimerDelegate* timer = (LocTimerDelegate*)mTimerContainer->pop();\n                 NULL != timer;\n                 timer = mTimerContainer->popIfOutRanks(timerOfNow)) {\n                // the timer delegate obj will be deleted before the return of this call\n                timer->expire();\n            }\n            mTimerContainer->updateSoonestTime(NULL);\n        }\n    };\n\n    struct itimerspec delay = {0};\n    timerfd_settime(getTimerFd(), TFD_TIMER_ABSTIME, &delay, NULL);\n    mPollTask->removePoll(*this);\n    mMsgTask->sendMsg(new MsgTimerExpire(*this));\n}\n\nLocTimerDelegate* LocTimerContainer::popIfOutRanks(LocTimerDelegate& timer) {\n    LocTimerDelegate* poppedNode = NULL;\n    if (mTree && !timer.outRanks(*peek())) {\n        poppedNode = (LocTimerDelegate*)(pop());\n    }\n\n    return poppedNode;\n}\n\n\n/***************************LocTimerPollTask methods***************************/\n\ninline\nLocTimerPollTask::LocTimerPollTask()\n    : mFd(epoll_create(2)), mThread(new LocThread()) {\n    // before a next call returens, a thread will be created. The run() method\n    // could already be running in parallel. Also, since each of the objs\n    // creates a thread, the container will make sure that there will be only\n    // one of such obj for our timer implementation.\n    if (!mThread->start(\"LocTimerPollTask\", this)) {\n        delete mThread;\n        mThread = NULL;\n    }\n}\n\ninline\nLocTimerPollTask::~LocTimerPollTask() {\n    // when fs is closed, epoll_wait() should fail run() should return false\n    // and the spawned thread should exit.\n    close(mFd);\n}\n\nvoid LocTimerPollTask::destroy() {\n    if (mThread) {\n        LocThread* thread = mThread;\n        mThread = NULL;\n        delete thread;\n    } else {\n        delete this;\n    }\n}\n\nvoid LocTimerPollTask::addPoll(LocTimerContainer& timerContainer) {\n    struct epoll_event ev;\n    memset(&ev, 0, sizeof(ev));\n\n    ev.events = EPOLLIN | EPOLLWAKEUP;\n    ev.data.fd = timerContainer.getTimerFd();\n    // it is important that we set this context pointer with the input\n    // timer container this is how we know which container should handle\n    // which expiration.\n    ev.data.ptr = &timerContainer;\n\n    epoll_ctl(mFd, EPOLL_CTL_ADD, timerContainer.getTimerFd(), &ev);\n}\n\ninline\nvoid LocTimerPollTask::removePoll(LocTimerContainer& timerContainer) {\n    epoll_ctl(mFd, EPOLL_CTL_DEL, timerContainer.getTimerFd(), NULL);\n}\n\n// The polling thread context will call this method. If run() method needs to\n// be repetitvely called, it must return true from the previous call.\nbool LocTimerPollTask::run() {\n    struct epoll_event ev[2];\n\n    // we have max 2 descriptors to poll from\n    int fds = epoll_wait(mFd, ev, 2, -1);\n\n    // we pretty much want to continually poll until the fd is closed\n    bool rerun = (fds > 0) || (errno == EINTR);\n\n    if (fds > 0) {\n        // we may have 2 events\n        for (int i = 0; i < fds; i++) {\n            // each fd has a context pointer associated with the right timer container\n            LocTimerContainer* container = (LocTimerContainer*)(ev[i].data.ptr);\n            if (container) {\n                container->expire();\n            } else {\n                epoll_ctl(mFd, EPOLL_CTL_DEL, ev[i].data.fd, NULL);\n            }\n        }\n    }\n\n    // if rerun is true, we are requesting to be scheduled again\n    return rerun;\n}\n\n/***************************LocTimerDelegate methods***************************/\n\ninline\nLocTimerDelegate::LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire)\n    : mClient(&client),\n      mLock(mClient->mLock->share()),\n      mFutureTime(futureTime),\n      mContainer(LocTimerContainer::get(wakeOnExpire)) {\n    // adding the timer into the container\n    mContainer->add(*this);\n}\n\ninline\nvoid LocTimerDelegate::destroyLocked() {\n    // client handle will likely be deleted soon after this\n    // method returns. Nulling this handle so that expire()\n    // won't call the callback on the dead handle any more.\n    mClient = NULL;\n\n    if (mContainer) {\n        LocTimerContainer* container = mContainer;\n        mContainer = NULL;\n        if (container) {\n            container->remove(*this);\n        }\n    } // else we do not do anything. No such *this* can be\n      // created and reached here with mContainer ever been\n      // a non NULL. So *this* must have reached the if clause\n      // once, and we want it reach there only once.\n}\n\nint LocTimerDelegate::ranks(LocRankable& rankable) {\n    int rank = -1;\n    LocTimerDelegate* timer = (LocTimerDelegate*)(&rankable);\n    if (timer) {\n        // larger time ranks lower!!!\n        // IOW, if input obj has bigger tv_sec, this obj outRanks higher\n        rank = timer->mFutureTime.tv_sec - mFutureTime.tv_sec;\n    }\n    return rank;\n}\n\ninline\nvoid LocTimerDelegate::expire() {\n    // keeping a copy of client pointer to be safe\n    // when timeOutCallback() is called at the end of this\n    // method, *this* obj may be already deleted.\n    LocTimer* client = mClient;\n    // force a stop, which will lead to delete of this obj\n    if (client && client->stop()) {\n        // calling client callback with a pointer save on the stack\n        // only if stop() returns true, i.e. it hasn't been stopped\n        // already.\n        client->timeOutCallback();\n    }\n}\n\n\n/***************************LocTimer methods***************************/\nLocTimer::LocTimer() : mTimer(NULL), mLock(new LocSharedLock()) {\n}\n\nLocTimer::~LocTimer() {\n    stop();\n    if (mLock) {\n        mLock->drop();\n        mLock = NULL;\n    }\n}\n\nbool LocTimer::start(unsigned int timeOutInMs, bool wakeOnExpire) {\n    bool success = false;\n    mLock->lock();\n    if (!mTimer) {\n        struct timespec futureTime;\n        clock_gettime(CLOCK_BOOTTIME, &futureTime);\n        futureTime.tv_sec += timeOutInMs / 1000;\n        futureTime.tv_nsec += (timeOutInMs % 1000) * 1000000;\n        if (futureTime.tv_nsec >= 1000000000) {\n            futureTime.tv_sec += futureTime.tv_nsec / 1000000000;\n            futureTime.tv_nsec %= 1000000000;\n        }\n        mTimer = new LocTimerDelegate(*this, futureTime, wakeOnExpire);\n        // if mTimer is non 0, success should be 0; or vice versa\n        success = (NULL != mTimer);\n    }\n    mLock->unlock();\n    return success;\n}\n\nbool LocTimer::stop() {\n    bool success = false;\n    mLock->lock();\n    if (mTimer) {\n        LocTimerDelegate* timer = mTimer;\n        mTimer = NULL;\n        if (timer) {\n            timer->destroyLocked();\n            success = true;\n        }\n    }\n    mLock->unlock();\n    return success;\n}\n\n/***************************LocTimerWrapper methods***************************/\n//////////////////////////////////////////////////////////////////////////\n// This section below wraps for the C style APIs\n//////////////////////////////////////////////////////////////////////////\nclass LocTimerWrapper : public LocTimer {\n    loc_timer_callback mCb;\n    void* mCallerData;\n    LocTimerWrapper* mMe;\n    static pthread_mutex_t mMutex;\n    inline ~LocTimerWrapper() { mCb = NULL; mMe = NULL; }\npublic:\n    inline LocTimerWrapper(loc_timer_callback cb, void* callerData) :\n        mCb(cb), mCallerData(callerData), mMe(this) {\n    }\n    void destroy() {\n        pthread_mutex_lock(&mMutex);\n        if (NULL != mCb && this == mMe) {\n            delete this;\n        }\n        pthread_mutex_unlock(&mMutex);\n    }\n    virtual void timeOutCallback() {\n        loc_timer_callback cb = mCb;\n        void* callerData = mCallerData;\n        if (cb) {\n            cb(callerData, 0);\n        }\n        destroy();\n    }\n};\n\npthread_mutex_t LocTimerWrapper::mMutex = PTHREAD_MUTEX_INITIALIZER;\n\nvoid* loc_timer_start(uint64_t msec, loc_timer_callback cb_func,\n                      void *caller_data, bool wake_on_expire)\n{\n    LocTimerWrapper* locTimerWrapper = NULL;\n\n    if (cb_func) {\n        locTimerWrapper = new LocTimerWrapper(cb_func, caller_data);\n\n        if (locTimerWrapper) {\n            locTimerWrapper->start(msec, wake_on_expire);\n        }\n    }\n\n    return locTimerWrapper;\n}\n\nvoid loc_timer_stop(void*&  handle)\n{\n    if (handle) {\n        LocTimerWrapper* locTimerWrapper = (LocTimerWrapper*)(handle);\n        locTimerWrapper->destroy();\n        handle = NULL;\n    }\n}\n\n//////////////////////////////////////////////////////////////////////////\n// This section above wraps for the C style APIs\n//////////////////////////////////////////////////////////////////////////\n\n#ifdef __LOC_DEBUG__\n\ndouble getDeltaSeconds(struct timespec from, struct timespec to) {\n    return (double)to.tv_sec + (double)to.tv_nsec / 1000000000\n        - from.tv_sec - (double)from.tv_nsec / 1000000000;\n}\n\nstruct timespec getNow() {\n    struct timespec now;\n    clock_gettime(CLOCK_BOOTTIME, &now);\n    return now;\n}\n\nclass LocTimerTest : public LocTimer, public LocRankable {\n    int mTimeOut;\n    const struct timespec mTimeOfBirth;\n    inline struct timespec getTimerWrapper(int timeout) {\n        struct timespec now;\n        clock_gettime(CLOCK_BOOTTIME, &now);\n        now.tv_sec += timeout;\n        return now;\n    }\npublic:\n    inline LocTimerTest(int timeout) : LocTimer(), LocRankable(),\n            mTimeOut(timeout), mTimeOfBirth(getTimerWrapper(0)) {}\n    inline virtual int ranks(LocRankable& rankable) {\n        LocTimerTest* timer = dynamic_cast<LocTimerTest*>(&rankable);\n        return timer->mTimeOut - mTimeOut;\n    }\n    inline virtual void timeOutCallback() {\n        printf(\"timeOutCallback() - \");\n        deviation();\n    }\n    double deviation() {\n        struct timespec now = getTimerWrapper(0);\n        double delta = getDeltaSeconds(mTimeOfBirth, now);\n        printf(\"%lf: %lf\\n\", delta, delta * 100 / mTimeOut);\n        return delta / mTimeOut;\n    }\n};\n\n// For Linux command line testing:\n// compilation:\n//     g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../system/core/include -o LocHeap.o LocHeap.cpp\n//     g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -std=c++0x -I. -I../../../../system/core/include -lpthread -o LocThread.o LocThread.cpp\n//     g++ -D__LOC_HOST_DEBUG__ -D__LOC_DEBUG__ -g -I. -I../../../../system/core/include -o LocTimer.o LocTimer.cpp\nint main(int argc, char** argv) {\n    struct timespec timeOfStart=getNow();\n    srand(time(NULL));\n    int tries = atoi(argv[1]);\n    int checks = tries >> 3;\n    LocTimerTest** timerArray = new LocTimerTest*[tries];\n    memset(timerArray, NULL, tries);\n\n    for (int i = 0; i < tries; i++) {\n        int r = rand() % tries;\n        LocTimerTest* timer = new LocTimerTest(r);\n        if (timerArray[r]) {\n            if (!timer->stop()) {\n                printf(\"%lf:\\n\", getDeltaSeconds(timeOfStart, getNow()));\n                printf(\"ERRER: %dth timer, id %d, not running when it should be\\n\", i, r);\n                exit(0);\n            } else {\n                printf(\"stop() - %d\\n\", r);\n                delete timer;\n                timerArray[r] = NULL;\n            }\n        } else {\n            if (!timer->start(r, false)) {\n                printf(\"%lf:\\n\", getDeltaSeconds(timeOfStart, getNow()));\n                printf(\"ERRER: %dth timer, id %d, running when it should not be\\n\", i, r);\n                exit(0);\n            } else {\n                printf(\"stop() - %d\\n\", r);\n                timerArray[r] = timer;\n            }\n        }\n    }\n\n    for (int i = 0; i < tries; i++) {\n        if (timerArray[i]) {\n            if (!timerArray[i]->stop()) {\n                printf(\"%lf:\\n\", getDeltaSeconds(timeOfStart, getNow()));\n                printf(\"ERRER: %dth timer, not running when it should be\\n\", i);\n                exit(0);\n            } else {\n                printf(\"stop() - %d\\n\", i);\n                delete timerArray[i];\n                timerArray[i] = NULL;\n            }\n        }\n    }\n\n    delete[] timerArray;\n\n    return 0;\n}\n\n#endif\n"
  },
  {
    "path": "gps/utils/LocTimer.h",
    "content": "/* Copyright (c) 2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef __LOC_TIMER_CPP_H__\n#define __LOC_TIMER_CPP_H__\n\n#include <stddef.h>\n#include <log_util.h>\n\n// opaque class to provide service implementation.\nclass LocTimerDelegate;\nclass LocSharedLock;\n\n// LocTimer client must extend this class and implementthe callback.\n// start() / stop() methods are to arm / disarm timer.\nclass LocTimer\n{\n    LocTimerDelegate* mTimer;\n    LocSharedLock* mLock;\n    // don't really want mLock to be manipulated by clients, yet LocTimer\n    // has to have a reference to the lock so that the delete of LocTimer\n    // and LocTimerDelegate can work together on their share resources.\n    friend class LocTimerDelegate;\n\npublic:\n    LocTimer();\n    virtual ~LocTimer();\n\n    // timeOutInMs:  timeout delay in ms\n    // wakeOnExpire: true if to wake up CPU (if sleeping) upon timer\n    //                        expiration and notify the client.\n    //               false if to wait until next time CPU wakes up (if\n    //                        sleeping) and then notify the client.\n    // return:       true on success;\n    //               false on failure, e.g. timer is already running.\n    bool start(uint32_t timeOutInMs, bool wakeOnExpire);\n\n    // return:       true on success;\n    //               false on failure, e.g. timer is not running.\n    bool stop();\n\n    //  LocTimer client Should implement this method.\n    //  This method is used for timeout calling back to client. This method\n    //  should be short enough (eg: send a message to your own thread).\n    virtual void timeOutCallback() = 0;\n};\n\n#endif //__LOC_DELAY_H__\n"
  },
  {
    "path": "gps/utils/Makefile.am",
    "content": "AM_CFLAGS = -Wundef \\\n         -MD \\\n         -Wno-trigraphs \\\n         -g -O0 \\\n         -fno-inline \\\n         -fno-short-enums \\\n         -fpic \\\n         -I../platform_lib_abstractions\n\nlibgps_utils_so_la_h_sources = log_util.h \\\n            msg_q.h \\\n            linked_list.h \\\n            loc_cfg.h \\\n            loc_log.h \\\n            ../platform_lib_abstractions/platform_lib_includes.h \\\n            ../platform_lib_abstractions/platform_lib_time.h \\\n            ../platform_lib_abstractions/platform_lib_macros.h\n\nlibgps_utils_so_la_c_sources = linked_list.c \\\n            msg_q.c \\\n            loc_cfg.cpp \\\n            loc_log.cpp \\\n            ../platform_lib_abstractions/elapsed_millis_since_boot.cpp\n\nlibrary_includedir = $(pkgincludedir)/utils\n\nlibrary_include_HEADERS = $(libgps_utils_so_la_h_sources)\n\nlibgps_utils_so_la_SOURCES = $(libgps_utils_so_la_c_sources)\n\nif USE_GLIB\nlibgps_utils_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@\nlibgps_utils_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0\nlibgps_utils_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@\nelse\nlibgps_utils_so_la_CFLAGS = $(AM_CFLAGS)\nlibgps_utils_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0\nlibgps_utils_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)\nendif\n\nlibgps_utils_so_la_LIBADD = -lstdc++ -lcutils\n\n#Create and Install libraries\nlib_LTLIBRARIES = libgps_utils_so.la\n"
  },
  {
    "path": "gps/utils/MsgTask.cpp",
    "content": "/* Copyright (c) 2011-2013,2015 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_MsgTask\"\n\n#include <cutils/sched_policy.h>\n#include <unistd.h>\n#include <MsgTask.h>\n#include <msg_q.h>\n#include <log_util.h>\n#include <loc_log.h>\n\nstatic void LocMsgDestroy(void* msg) {\n    delete (LocMsg*)msg;\n}\n\nMsgTask::MsgTask(LocThread::tCreate tCreator,\n                 const char* threadName, bool joinable) :\n    mQ(msg_q_init2()), mThread(new LocThread()) {\n    if (!mThread->start(tCreator, threadName, this, joinable)) {\n        delete mThread;\n        mThread = NULL;\n    }\n}\n\nMsgTask::MsgTask(const char* threadName, bool joinable) :\n    mQ(msg_q_init2()), mThread(new LocThread()) {\n    if (!mThread->start(threadName, this, joinable)) {\n        delete mThread;\n        mThread = NULL;\n    }\n}\n\nMsgTask::~MsgTask() {\n    msg_q_flush((void*)mQ);\n    msg_q_destroy((void**)&mQ);\n}\n\nvoid MsgTask::destroy() {\n    msg_q_unblock((void*)mQ);\n    if (mThread) {\n        LocThread* thread = mThread;\n        mThread = NULL;\n        delete thread;\n    } else {\n        delete this;\n    }\n}\n\nvoid MsgTask::sendMsg(const LocMsg* msg) const {\n    msg_q_snd((void*)mQ, (void*)msg, LocMsgDestroy);\n}\n\nvoid MsgTask::prerun() {\n    // make sure we do not run in background scheduling group\n    set_sched_policy(gettid(), SP_FOREGROUND);\n}\n\nbool MsgTask::run() {\n    LOC_LOGD(\"MsgTask::loop() listening ...\\n\");\n    LocMsg* msg;\n    msq_q_err_type result = msg_q_rcv((void*)mQ, (void **)&msg);\n    if (eMSG_Q_SUCCESS != result) {\n        LOC_LOGE(\"%s:%d] fail receiving msg: %s\\n\", __func__, __LINE__,\n                 loc_get_msg_q_status(result));\n        return false;\n    }\n\n    msg->log();\n    // there is where each individual msg handling is invoked\n    msg->proc();\n\n    delete msg;\n\n    return true;\n}\n"
  },
  {
    "path": "gps/utils/MsgTask.h",
    "content": "/* Copyright (c) 2011-2013,2015 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef __MSG_TASK__\n#define __MSG_TASK__\n\n#include <LocThread.h>\n\nstruct LocMsg {\n    inline LocMsg() {}\n    inline virtual ~LocMsg() {}\n    virtual void proc() const = 0;\n    inline virtual void log() const {}\n};\n\nclass MsgTask : public LocRunnable {\n    const void* mQ;\n    LocThread* mThread;\n    friend class LocThreadDelegate;\nprotected:\n    virtual ~MsgTask();\npublic:\n    MsgTask(LocThread::tCreate tCreator, const char* threadName = NULL, bool joinable = true);\n    MsgTask(const char* threadName = NULL, bool joinable = true);\n    // this obj will be deleted once thread is deleted\n    void destroy();\n    void sendMsg(const LocMsg* msg) const;\n    // Overrides of LocRunnable methods\n    // This method will be repeated called until it returns false; or\n    // until thread is stopped.\n    virtual bool run();\n\n    // The method to be run before thread loop (conditionally repeatedly)\n    // calls run()\n    virtual void prerun();\n\n    // The method to be run after thread loop (conditionally repeatedly)\n    // calls run()\n    inline virtual void postrun() {}\n};\n\n#endif //__MSG_TASK__\n"
  },
  {
    "path": "gps/utils/linked_list.c",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include \"linked_list.h\"\n#include <stdio.h>\n#include <string.h>\n\n#define LOG_TAG \"LocSvc_utils_ll\"\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n#include <stdlib.h>\n#include <stdint.h>\n\ntypedef struct list_element {\n   struct list_element* next;\n   struct list_element* prev;\n   void* data_ptr;\n   void (*dealloc_func)(void*);\n}list_element;\n\ntypedef struct list_state {\n   list_element* p_head;\n   list_element* p_tail;\n} list_state;\n\n/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */\n\n/*===========================================================================\n\n  FUNCTION:   linked_list_init\n\n  ===========================================================================*/\nlinked_list_err_type linked_list_init(void** list_data)\n{\n   if( list_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid list parameter!\\n\", __FUNCTION__);\n      return eLINKED_LIST_INVALID_PARAMETER;\n   }\n\n   list_state* tmp_list;\n   tmp_list = (list_state*)calloc(1, sizeof(list_state));\n   if( tmp_list == NULL )\n   {\n      LOC_LOGE(\"%s: Unable to allocate space for list!\\n\", __FUNCTION__);\n      return eLINKED_LIST_FAILURE_GENERAL;\n   }\n\n   tmp_list->p_head = NULL;\n   tmp_list->p_tail = NULL;\n\n   *list_data = tmp_list;\n\n   return eLINKED_LIST_SUCCESS;\n}\n\n/*===========================================================================\n\n  FUNCTION:   linked_list_destroy\n\n  ===========================================================================*/\nlinked_list_err_type linked_list_destroy(void** list_data)\n{\n   if( list_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid list parameter!\\n\", __FUNCTION__);\n      return eLINKED_LIST_INVALID_HANDLE;\n   }\n\n   list_state* p_list = (list_state*)*list_data;\n\n   linked_list_flush(p_list);\n\n   free(*list_data);\n   *list_data = NULL;\n\n   return eLINKED_LIST_SUCCESS;\n}\n\n/*===========================================================================\n\n  FUNCTION:   linked_list_add\n\n  ===========================================================================*/\nlinked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*))\n{\n   LOC_LOGD(\"%s: Adding to list data_obj = 0x%08X\\n\", __FUNCTION__, data_obj);\n   if( list_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid list parameter!\\n\", __FUNCTION__);\n      return eLINKED_LIST_INVALID_HANDLE;\n   }\n\n   if( data_obj == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid input parameter!\\n\", __FUNCTION__);\n      return eLINKED_LIST_INVALID_PARAMETER;\n   }\n\n   list_state* p_list = (list_state*)list_data;\n   list_element* elem = (list_element*)malloc(sizeof(list_element));\n   if( elem == NULL )\n   {\n      LOC_LOGE(\"%s: Memory allocation failed\\n\", __FUNCTION__);\n      return eLINKED_LIST_FAILURE_GENERAL;\n   }\n\n   /* Copy data to newly created element */\n   elem->data_ptr = data_obj;\n   elem->next = NULL;\n   elem->prev = NULL;\n   elem->dealloc_func = dealloc;\n\n   /* Replace head element */\n   list_element* tmp = p_list->p_head;\n   p_list->p_head = elem;\n   /* Point next to the previous head element */\n   p_list->p_head->next = tmp;\n\n   if( tmp != NULL )\n   {\n      tmp->prev = p_list->p_head;\n   }\n   else\n   {\n      p_list->p_tail = p_list->p_head;\n   }\n\n   return eLINKED_LIST_SUCCESS;\n}\n\n/*===========================================================================\n\n  FUNCTION:   linked_list_remove\n\n  ===========================================================================*/\nlinked_list_err_type linked_list_remove(void* list_data, void **data_obj)\n{\n   LOC_LOGD(\"%s: Removing from list\\n\", __FUNCTION__);\n   if( list_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid list parameter!\\n\", __FUNCTION__);\n      return eLINKED_LIST_INVALID_HANDLE;\n   }\n\n   if( data_obj == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid input parameter!\\n\", __FUNCTION__);\n      return eLINKED_LIST_INVALID_PARAMETER;\n   }\n\n   list_state* p_list = (list_state*)list_data;\n   if( p_list->p_tail == NULL )\n   {\n      return eLINKED_LIST_UNAVAILABLE_RESOURCE;\n   }\n\n   list_element* tmp = p_list->p_tail;\n\n   /* Replace tail element */\n   p_list->p_tail = tmp->prev;\n\n   if( p_list->p_tail != NULL )\n   {\n      p_list->p_tail->next = NULL;\n   }\n   else\n   {\n      p_list->p_head = p_list->p_tail;\n   }\n\n   /* Copy data to output param */\n   *data_obj = tmp->data_ptr;\n\n   /* Free allocated list element */\n   free(tmp);\n\n   return eLINKED_LIST_SUCCESS;\n}\n\n/*===========================================================================\n\n  FUNCTION:   linked_list_empty\n\n  ===========================================================================*/\nint linked_list_empty(void* list_data)\n{\n   if( list_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid list parameter!\\n\", __FUNCTION__);\n      return (int)eLINKED_LIST_INVALID_HANDLE;\n   }\n   else\n   {\n      list_state* p_list = (list_state*)list_data;\n      return p_list->p_head == NULL ? 1 : 0;\n   }\n}\n\n/*===========================================================================\n\n  FUNCTION:   linked_list_flush\n\n  ===========================================================================*/\nlinked_list_err_type linked_list_flush(void* list_data)\n{\n   if( list_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid list parameter!\\n\", __FUNCTION__);\n      return eLINKED_LIST_INVALID_HANDLE;\n   }\n\n   list_state* p_list = (list_state*)list_data;\n\n   /* Remove all dynamically allocated elements */\n   while( p_list->p_head != NULL )\n   {\n      list_element* tmp = p_list->p_head->next;\n\n      /* Free data pointer if told to do so. */\n      if( p_list->p_head->dealloc_func != NULL )\n      {\n         p_list->p_head->dealloc_func(p_list->p_head->data_ptr);\n      }\n\n      /* Free list element */\n      free(p_list->p_head);\n\n      p_list->p_head = tmp;\n   }\n\n   p_list->p_tail = NULL;\n\n   return eLINKED_LIST_SUCCESS;\n}\n\n/*===========================================================================\n\n  FUNCTION:   linked_list_search\n\n  ===========================================================================*/\nlinked_list_err_type linked_list_search(void* list_data, void **data_p,\n                                        bool (*equal)(void* data_0, void* data),\n                                        void* data_0, bool rm_if_found)\n{\n   LOC_LOGD(\"%s: Search the list\\n\", __FUNCTION__);\n   if( list_data == NULL || NULL == equal )\n   {\n      LOC_LOGE(\"%s: Invalid list parameter! list_data %p equal %p\\n\",\n               __FUNCTION__, list_data, equal);\n      return eLINKED_LIST_INVALID_HANDLE;\n   }\n\n   list_state* p_list = (list_state*)list_data;\n   if( p_list->p_tail == NULL )\n   {\n      return eLINKED_LIST_UNAVAILABLE_RESOURCE;\n   }\n\n   list_element* tmp = p_list->p_head;\n\n   if (NULL != data_p) {\n     *data_p = NULL;\n   }\n\n   while (NULL != tmp) {\n     if ((*equal)(data_0, tmp->data_ptr)) {\n       if (NULL != data_p) {\n         *data_p = tmp->data_ptr;\n       }\n\n       if (rm_if_found) {\n         if (NULL == tmp->prev) {\n           p_list->p_head = tmp->next;\n         } else {\n           tmp->prev->next = tmp->next;\n         }\n\n         if (NULL == tmp->next) {\n           p_list->p_tail = tmp->prev;\n         } else {\n           tmp->next->prev = tmp->prev;\n         }\n\n         tmp->prev = tmp->next = NULL;\n\n         // dealloc data if it is not copied out && caller\n         // has given us a dealloc function pointer.\n         if (NULL == data_p && NULL != tmp->dealloc_func) {\n             tmp->dealloc_func(tmp->data_ptr);\n         }\n         free(tmp);\n       }\n\n       tmp = NULL;\n     } else {\n       tmp = tmp->next;\n     }\n   }\n\n   return eLINKED_LIST_SUCCESS;\n}\n\n"
  },
  {
    "path": "gps/utils/linked_list.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n#ifndef __LINKED_LIST_H__\n#define __LINKED_LIST_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#include <stdbool.h>\n#include <stdlib.h>\n\n/** Linked List Return Codes */\ntypedef enum\n{\n  eLINKED_LIST_SUCCESS                             = 0,\n     /**< Request was successful. */\n  eLINKED_LIST_FAILURE_GENERAL                     = -1,\n     /**< Failed because of a general failure. */\n  eLINKED_LIST_INVALID_PARAMETER                   = -2,\n     /**< Failed because the request contained invalid parameters. */\n  eLINKED_LIST_INVALID_HANDLE                      = -3,\n     /**< Failed because an invalid handle was specified. */\n  eLINKED_LIST_UNAVAILABLE_RESOURCE                = -4,\n     /**< Failed because an there were not enough resources. */\n  eLINKED_LIST_INSUFFICIENT_BUFFER                 = -5,\n     /**< Failed because an the supplied buffer was too small. */\n}linked_list_err_type;\n\n/*===========================================================================\nFUNCTION    linked_list_init\n\nDESCRIPTION\n   Initializes internal structures for linked list.\n\n   list_data: State of list to be initialized.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nlinked_list_err_type linked_list_init(void** list_data);\n\n/*===========================================================================\nFUNCTION    linked_list_destroy\n\nDESCRIPTION\n   Destroys internal structures for linked list.\n\n   p_list_data: State of list to be destroyed.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nlinked_list_err_type linked_list_destroy(void** list_data);\n\n/*===========================================================================\nFUNCTION    linked_list_add\n\nDESCRIPTION\n   Adds an element to the head of the linked list. The passed in data pointer\n   is not modified or freed. Passed in data_obj is expected to live throughout\n   the use of the linked_list (i.e. data is not allocated internally)\n\n   p_list_data:  List to add data to the head of.\n   data_obj:     Pointer to data to add into list\n   dealloc:      Function used to deallocate memory for this element. Pass NULL\n                 if you do not want data deallocated during a flush operation\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nlinked_list_err_type linked_list_add(void* list_data, void *data_obj, void (*dealloc)(void*));\n\n/*===========================================================================\nFUNCTION    linked_list_remove\n\nDESCRIPTION\n   Retrieves data from the list tail. data_obj is the tail element from the list\n   passed in by linked_list_add.\n\n   p_list_data:  List to remove the tail from.\n   data_obj:     Pointer to data removed from list\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nlinked_list_err_type linked_list_remove(void* list_data, void **data_obj);\n\n/*===========================================================================\nFUNCTION    linked_list_empty\n\nDESCRIPTION\n   Tells whether the list currently contains any elements\n\n   p_list_data:  List to check if empty.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   0/FALSE : List contains elements\n   1/TRUE  : List is Empty\n   Otherwise look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nint linked_list_empty(void* list_data);\n\n/*===========================================================================\nFUNCTION    linked_list_flush\n\nDESCRIPTION\n   Removes all elements from the list and deallocates them using the provided\n   dealloc function while adding elements.\n\n   p_list_data:  List to remove all elements from.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nlinked_list_err_type linked_list_flush(void* list_data);\n\n/*===========================================================================\nFUNCTION    linked_list_search\n\nDESCRIPTION\n   Searches for an element in the linked list.\n\n   p_list_data:  List handle.\n   data_p:       to be stored with the data found; NUll if no match.\n                 if data_p passed in as NULL, then no write to it.\n   equal:        Function ptr takes in a list element, and returns\n                 indication if this the one looking for.\n   data_0:       The data being compared against.\n   rm_if_found:  Should data be removed if found?\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nlinked_list_err_type linked_list_search(void* list_data, void **data_p,\n                                        bool (*equal)(void* data_0, void* data),\n                                        void* data_0, bool rm_if_found);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* __LINKED_LIST_H__ */\n"
  },
  {
    "path": "gps/utils/loc_cfg.cpp",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_utils_cfg\"\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <pthread.h>\n#include <string.h>\n#include <ctype.h>\n#include <unistd.h>\n#include <time.h>\n#include <loc_cfg.h>\n#include <log_util.h>\n#include <loc_misc_utils.h>\n#ifdef USE_GLIB\n#include <glib.h>\n#endif\n#include \"platform_lib_includes.h\"\n\n/*=============================================================================\n *\n *                          GLOBAL DATA DECLARATION\n *\n *============================================================================*/\n\n/* Parameter data */\nstatic uint32_t DEBUG_LEVEL = 0xff;\nstatic uint32_t TIMESTAMP = 0;\n\n/* Parameter spec table */\nstatic loc_param_s_type loc_param_table[] =\n{\n    {\"DEBUG_LEVEL\",    &DEBUG_LEVEL, NULL,    'n'},\n    {\"TIMESTAMP\",      &TIMESTAMP,   NULL,    'n'},\n};\nint loc_param_num = sizeof(loc_param_table) / sizeof(loc_param_s_type);\n\ntypedef struct loc_param_v_type\n{\n    char* param_name;\n    char* param_str_value;\n    int param_int_value;\n    double param_double_value;\n}loc_param_v_type;\n\n/*===========================================================================\nFUNCTION loc_set_config_entry\n\nDESCRIPTION\n   Potentially sets a given configuration table entry based on the passed in\n   configuration value. This is done by using a string comparison of the\n   parameter names and those found in the configuration file.\n\nPARAMETERS:\n   config_entry: configuration entry in the table to possibly set\n   config_value: value to store in the entry if the parameter names match\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nint loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)\n{\n    int ret=-1;\n    if(NULL == config_entry || NULL == config_value)\n    {\n        LOC_LOGE(\"%s: INVALID config entry or parameter\", __FUNCTION__);\n        return ret;\n    }\n\n    if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&\n        config_entry->param_ptr)\n    {\n        switch (config_entry->param_type)\n        {\n        case 's':\n            if (strcmp(config_value->param_str_value, \"NULL\") == 0)\n            {\n                *((char*)config_entry->param_ptr) = '\\0';\n            }\n            else {\n                strlcpy((char*) config_entry->param_ptr,\n                        config_value->param_str_value,\n                        LOC_MAX_PARAM_STRING + 1);\n            }\n            /* Log INI values */\n            LOC_LOGD(\"%s: PARAM %s = %s\", __FUNCTION__,\n                     config_entry->param_name, (char*)config_entry->param_ptr);\n\n            if(NULL != config_entry->param_set)\n            {\n                *(config_entry->param_set) = 1;\n            }\n            ret = 0;\n            break;\n        case 'n':\n            *((int *)config_entry->param_ptr) = config_value->param_int_value;\n            /* Log INI values */\n            LOC_LOGD(\"%s: PARAM %s = %d\", __FUNCTION__,\n                     config_entry->param_name, config_value->param_int_value);\n\n            if(NULL != config_entry->param_set)\n            {\n                *(config_entry->param_set) = 1;\n            }\n            ret = 0;\n            break;\n        case 'f':\n            *((double *)config_entry->param_ptr) = config_value->param_double_value;\n            /* Log INI values */\n            LOC_LOGD(\"%s: PARAM %s = %f\", __FUNCTION__,\n                     config_entry->param_name, config_value->param_double_value);\n\n            if(NULL != config_entry->param_set)\n            {\n                *(config_entry->param_set) = 1;\n            }\n            ret = 0;\n            break;\n        default:\n            LOC_LOGE(\"%s: PARAM %s parameter type must be n, f, or s\",\n                     __FUNCTION__, config_entry->param_name);\n        }\n    }\n    return ret;\n}\n\n/*===========================================================================\nFUNCTION loc_fill_conf_item\n\nDESCRIPTION\n   Takes a line of configuration item and sets defined values based on\n   the passed in configuration table. This table maps strings to values to\n   set along with the type of each of these values.\n\nPARAMETERS:\n   input_buf : buffer contanis config item\n   config_table: table definition of strings to places to store information\n   table_length: length of the configuration table\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   0: Number of records in the config_table filled with input_buf\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nint loc_fill_conf_item(char* input_buf,\n                       loc_param_s_type* config_table, uint32_t table_length)\n{\n    int ret = 0;\n\n    if (input_buf && config_table) {\n        char *lasts;\n        loc_param_v_type config_value;\n        memset(&config_value, 0, sizeof(config_value));\n\n        /* Separate variable and value */\n        config_value.param_name = strtok_r(input_buf, \"=\", &lasts);\n        /* skip lines that do not contain \"=\" */\n        if (config_value.param_name) {\n            config_value.param_str_value = strtok_r(NULL, \"=\", &lasts);\n\n            /* skip lines that do not contain two operands */\n            if (config_value.param_str_value) {\n                /* Trim leading and trailing spaces */\n                loc_util_trim_space(config_value.param_name);\n                loc_util_trim_space(config_value.param_str_value);\n\n                /* Parse numerical value */\n                if ((strlen(config_value.param_str_value) >=3) &&\n                    (config_value.param_str_value[0] == '0') &&\n                    (tolower(config_value.param_str_value[1]) == 'x'))\n                {\n                    /* hex */\n                    config_value.param_int_value = (int) strtol(&config_value.param_str_value[2],\n                                                                (char**) NULL, 16);\n                }\n                else {\n                    config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */\n                    config_value.param_int_value = atoi(config_value.param_str_value); /* dec */\n                }\n\n                for(uint32_t i = 0; NULL != config_table && i < table_length; i++)\n                {\n                    if(!loc_set_config_entry(&config_table[i], &config_value)) {\n                        ret += 1;\n                    }\n                }\n            }\n        }\n    }\n\n    return ret;\n}\n\n/*===========================================================================\nFUNCTION loc_read_conf_r (repetitive)\n\nDESCRIPTION\n   Reads the specified configuration file and sets defined values based on\n   the passed in configuration table. This table maps strings to values to\n   set along with the type of each of these values.\n   The difference between this and loc_read_conf is that this function returns\n   the file pointer position at the end of filling a config table. Also, it\n   reads a fixed number of parameters at a time which is equal to the length\n   of the configuration table. This functionality enables the caller to\n   repeatedly call the function to read data from the same file.\n\nPARAMETERS:\n   conf_fp : file pointer\n   config_table: table definition of strings to places to store information\n   table_length: length of the configuration table\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   0: Table filled successfully\n   1: No more parameters to read\n  -1: Error filling table\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nint loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length)\n{\n    int ret=0;\n\n    unsigned int num_params=table_length;\n    if(conf_fp == NULL) {\n        LOC_LOGE(\"%s:%d]: ERROR: File pointer is NULL\\n\", __func__, __LINE__);\n        ret = -1;\n        goto err;\n    }\n\n    /* Clear all validity bits */\n    for(uint32_t i = 0; NULL != config_table && i < table_length; i++)\n    {\n        if(NULL != config_table[i].param_set)\n        {\n            *(config_table[i].param_set) = 0;\n        }\n    }\n\n    char input_buf[LOC_MAX_PARAM_LINE];  /* declare a char array */\n\n    LOC_LOGD(\"%s:%d]: num_params: %d\\n\", __func__, __LINE__, num_params);\n    while(num_params)\n    {\n        if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) {\n            LOC_LOGD(\"%s:%d]: fgets returned NULL\\n\", __func__, __LINE__);\n            break;\n        }\n\n        num_params -= loc_fill_conf_item(input_buf, config_table, table_length);\n    }\n\nerr:\n    return ret;\n}\n\n/*===========================================================================\nFUNCTION loc_udpate_conf\n\nDESCRIPTION\n   Parses the passed in buffer for configuration items, and update the table\n   that is also passed in.\n\nReads the specified configuration file and sets defined values based on\n   the passed in configuration table. This table maps strings to values to\n   set along with the type of each of these values.\n\nPARAMETERS:\n   conf_data: configuration items in bufferas a string\n   length: strlen(conf_data)\n   config_table: table definition of strings to places to store information\n   table_length: length of the configuration table\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   number of the records in the table that is updated at time of return.\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nint loc_update_conf(const char* conf_data, int32_t length,\n                    loc_param_s_type* config_table, uint32_t table_length)\n{\n    int ret = -1;\n\n    if (conf_data && length && config_table && table_length) {\n        // make a copy, so we do not tokenize the original data\n        char* conf_copy = (char*)malloc(length+1);\n\n        if (conf_copy != NULL)\n        {\n            memcpy(conf_copy, conf_data, length);\n            // we hard NULL the end of string to be safe\n            conf_copy[length] = 0;\n\n            // start with one record off\n            uint32_t num_params = table_length - 1;\n            char* saveptr = NULL;\n            char* input_buf = strtok_r(conf_copy, \"\\n\", &saveptr);\n            ret = 0;\n\n            LOC_LOGD(\"%s:%d]: num_params: %d\\n\", __func__, __LINE__, num_params);\n            while(num_params && input_buf) {\n                ret++;\n                num_params -= loc_fill_conf_item(input_buf, config_table, table_length);\n                input_buf = strtok_r(NULL, \"\\n\", &saveptr);\n            }\n            free(conf_copy);\n        }\n    }\n\n    return ret;\n}\n\n/*===========================================================================\nFUNCTION loc_read_conf\n\nDESCRIPTION\n   Reads the specified configuration file and sets defined values based on\n   the passed in configuration table. This table maps strings to values to\n   set along with the type of each of these values.\n\nPARAMETERS:\n   conf_file_name: configuration file to read\n   config_table: table definition of strings to places to store information\n   table_length: length of the configuration table\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nvoid loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table,\n                   uint32_t table_length)\n{\n    FILE *conf_fp = NULL;\n    char *lasts;\n    loc_param_v_type config_value;\n    uint32_t i;\n\n    if((conf_fp = fopen(conf_file_name, \"r\")) != NULL)\n    {\n        LOC_LOGD(\"%s: using %s\", __FUNCTION__, conf_file_name);\n        if(table_length && config_table) {\n            loc_read_conf_r(conf_fp, config_table, table_length);\n            rewind(conf_fp);\n        }\n        loc_read_conf_r(conf_fp, loc_param_table, loc_param_num);\n        fclose(conf_fp);\n    }\n    /* Initialize logging mechanism with parsed data */\n    loc_logger_init(DEBUG_LEVEL, TIMESTAMP);\n}\n"
  },
  {
    "path": "gps/utils/loc_cfg.h",
    "content": "/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_CFG_H\n#define LOC_CFG_H\n\n#include <stdio.h>\n#include <stdint.h>\n\n#define LOC_MAX_PARAM_NAME                 80\n#define LOC_MAX_PARAM_STRING               80\n#define LOC_MAX_PARAM_LINE    (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING)\n\n#define UTIL_UPDATE_CONF(conf_data, len, config_table) \\\n    loc_update_conf((conf_data), (len), (config_table), \\\n                    sizeof(config_table) / sizeof(config_table[0]))\n\n#define UTIL_READ_CONF_DEFAULT(filename) \\\n    loc_read_conf((filename), NULL, 0);\n\n#define UTIL_READ_CONF(filename, config_table) \\\n    loc_read_conf((filename), (config_table), sizeof(config_table) / sizeof(config_table[0]))\n\n/*=============================================================================\n *\n *                        MODULE TYPE DECLARATION\n *\n *============================================================================*/\ntypedef struct\n{\n  char                           param_name[LOC_MAX_PARAM_NAME];\n  void                          *param_ptr;\n  uint8_t                       *param_set;   /* was this value set by config file? */\n  char                           param_type;  /* 'n' for number,\n                                                 's' for string,\n                                                 'f' for float */\n} loc_param_s_type;\n\n/*=============================================================================\n *\n *                          MODULE EXTERNAL DATA\n *\n *============================================================================*/\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*=============================================================================\n *\n *                       MODULE EXPORTED FUNCTIONS\n *\n *============================================================================*/\nvoid loc_read_conf(const char* conf_file_name,\n                   loc_param_s_type* config_table,\n                   uint32_t table_length);\nint loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table,\n                    uint32_t table_length);\nint loc_update_conf(const char* conf_data, int32_t length,\n                    loc_param_s_type* config_table, uint32_t table_length);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_CFG_H */\n"
  },
  {
    "path": "gps/utils/loc_log.cpp",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#define LOG_NDDEBUG 0\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <sys/time.h>\n#include \"loc_log.h\"\n#include \"msg_q.h\"\n#ifdef USE_GLIB\n#include <time.h>\n#endif /* USE_GLIB  */\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n\n#define  BUFFER_SIZE  120\n\n// Logging Improvements\nconst char *loc_logger_boolStr[]={\"False\",\"True\"};\nconst char VOID_RET[]   = \"None\";\nconst char FROM_AFW[]   = \"===>\";\nconst char TO_MODEM[]   = \"--->\";\nconst char FROM_MODEM[] = \"<---\";\nconst char TO_AFW[]     = \"<===\";\nconst char EXIT_TAG[]   = \"Exiting\";\nconst char ENTRY_TAG[]  = \"Entering\";\nconst char EXIT_ERROR_TAG[]  = \"Exiting with error\";\n\n/* Logging Mechanism */\nloc_logger_s_type loc_logger;\n\n/* Get names from value */\nconst char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask)\n{\n   int i;\n   for (i = 0; i < table_size; i++)\n   {\n      if (table[i].val & (long) mask)\n      {\n         return table[i].name;\n      }\n   }\n   return UNKNOWN_STR;\n}\n\n/* Get names from value */\nconst char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value)\n{\n   int i;\n   for (i = 0; i < table_size; i++)\n   {\n      if (table[i].val == (long) value)\n      {\n         return table[i].name;\n      }\n   }\n   return UNKNOWN_STR;\n}\n\nstatic loc_name_val_s_type loc_msg_q_status[] =\n{\n    NAME_VAL( eMSG_Q_SUCCESS ),\n    NAME_VAL( eMSG_Q_FAILURE_GENERAL ),\n    NAME_VAL( eMSG_Q_INVALID_PARAMETER ),\n    NAME_VAL( eMSG_Q_INVALID_HANDLE ),\n    NAME_VAL( eMSG_Q_UNAVAILABLE_RESOURCE ),\n    NAME_VAL( eMSG_Q_INSUFFICIENT_BUFFER )\n};\nstatic int loc_msg_q_status_num = sizeof(loc_msg_q_status) / sizeof(loc_name_val_s_type);\n\n/* Find msg_q status name */\nconst char* loc_get_msg_q_status(int status)\n{\n   return loc_get_name_from_val(loc_msg_q_status, loc_msg_q_status_num, (long) status);\n}\n\nconst char* log_succ_fail_string(int is_succ)\n{\n   return is_succ? \"successful\" : \"failed\";\n}\n\n//Target names\nloc_name_val_s_type target_name[] =\n{\n    NAME_VAL(GNSS_NONE),\n    NAME_VAL(GNSS_MSM),\n    NAME_VAL(GNSS_GSS),\n    NAME_VAL(GNSS_MDM),\n    NAME_VAL(GNSS_QCA1530),\n    NAME_VAL(GNSS_AUTO),\n    NAME_VAL(GNSS_UNKNOWN)\n};\n\nstatic int target_name_num = sizeof(target_name)/sizeof(loc_name_val_s_type);\n\n/*===========================================================================\n\nFUNCTION loc_get_target_name\n\nDESCRIPTION\n   Returns pointer to a string that contains name of the target\n\n   XX:XX:XX.000\\0\n\nRETURN VALUE\n   The target name string\n\n===========================================================================*/\nconst char *loc_get_target_name(unsigned int target)\n{\n    int index = 0;\n    static char ret[BUFFER_SIZE];\n\n    index =  getTargetGnssType(target);\n    if( index >= target_name_num || index < 0)\n        index = target_name_num - 1;\n\n    if( (target & HAS_SSC) == HAS_SSC ) {\n        snprintf(ret, sizeof(ret), \" %s with SSC\",\n           loc_get_name_from_val(target_name, target_name_num, (long)index) );\n    }\n    else {\n       snprintf(ret, sizeof(ret), \" %s  without SSC\",\n           loc_get_name_from_val(target_name, target_name_num, (long)index) );\n    }\n    return ret;\n}\n\n\n/*===========================================================================\n\nFUNCTION loc_get_time\n\nDESCRIPTION\n   Logs a callback event header.\n   The pointer time_string should point to a buffer of at least 13 bytes:\n\n   XX:XX:XX.000\\0\n\nRETURN VALUE\n   The time string\n\n===========================================================================*/\nchar *loc_get_time(char *time_string, unsigned long buf_size)\n{\n   struct timeval now;     /* sec and usec     */\n   struct tm now_tm;       /* broken-down time */\n   char hms_string[80];    /* HH:MM:SS         */\n\n   gettimeofday(&now, NULL);\n   localtime_r(&now.tv_sec, &now_tm);\n\n   strftime(hms_string, sizeof hms_string, \"%H:%M:%S\", &now_tm);\n   snprintf(time_string, buf_size, \"%s.%03d\", hms_string, (int) (now.tv_usec / 1000));\n\n   return time_string;\n}\n\n\n/*===========================================================================\nFUNCTION loc_logger_init\n\nDESCRIPTION\n   Initializes the state of DEBUG_LEVEL and TIMESTAMP\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nvoid loc_logger_init(unsigned long debug, unsigned long timestamp)\n{\n   loc_logger.DEBUG_LEVEL = debug;\n#ifdef TARGET_BUILD_VARIANT_USER\n   // force user builds to 2 or less\n   if (loc_logger.DEBUG_LEVEL > 2) {\n       loc_logger.DEBUG_LEVEL = 2;\n   }\n#endif\n   loc_logger.TIMESTAMP   = timestamp;\n}\n\n\n/*===========================================================================\nFUNCTION get_timestamp\n\nDESCRIPTION\n   Generates a timestamp using the current system time\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Char pointer to the parameter str\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nchar * get_timestamp(char *str, unsigned long buf_size)\n{\n  struct timeval tv;\n  struct timezone tz;\n  int hh, mm, ss;\n  gettimeofday(&tv, &tz);\n  hh = tv.tv_sec/3600%24;\n  mm = (tv.tv_sec%3600)/60;\n  ss = tv.tv_sec%60;\n  snprintf(str, buf_size, \"%02d:%02d:%02d.%06ld\", hh, mm, ss, tv.tv_usec);\n  return str;\n}\n\n"
  },
  {
    "path": "gps/utils/loc_log.h",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef LOC_LOG_H\n#define LOC_LOG_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#include <ctype.h>\n#include \"loc_target.h\"\n\ntypedef struct\n{\n   char                 name[128];\n   long                 val;\n} loc_name_val_s_type;\n\n#define NAME_VAL(x) {\"\" #x \"\", x }\n\n#define UNKNOWN_STR \"UNKNOWN\"\n\n#define CHECK_MASK(type, value, mask_var, mask) \\\n   ((mask_var & mask) ? (type) value : (type) (-1))\n\n/* Get names from value */\nconst char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask);\nconst char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value);\nconst char* loc_get_msg_q_status(int status);\nconst char* loc_get_target_name(unsigned int target);\n\nextern const char* log_succ_fail_string(int is_succ);\n\nextern char *loc_get_time(char *time_string, unsigned long buf_size);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LOC_LOG_H */\n"
  },
  {
    "path": "gps/utils/loc_misc_utils.cpp",
    "content": "/* Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#include <stdio.h>\n#include <string.h>\n#include <log_util.h>\n#include <loc_misc_utils.h>\n#include <ctype.h>\n\n#define LOG_NDDEBUG 0\n#define LOG_TAG \"LocSvc_misc_utils\"\n\nint loc_util_split_string(char *raw_string, char **split_strings_ptr,\n                          int max_num_substrings, char delimiter)\n{\n    int raw_string_index=0;\n    int num_split_strings=0;\n    unsigned char end_string=0;\n    int raw_string_length=0;\n\n    if(!raw_string || !split_strings_ptr) {\n        LOC_LOGE(\"%s:%d]: NULL parameters\", __func__, __LINE__);\n        num_split_strings = -1;\n        goto err;\n    }\n    LOC_LOGD(\"%s:%d]: raw string: %s\\n\", __func__, __LINE__, raw_string);\n    raw_string_length = strlen(raw_string) + 1;\n    split_strings_ptr[num_split_strings] = &raw_string[raw_string_index];\n    for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) {\n        if(raw_string[raw_string_index] == '\\0')\n            end_string=1;\n        if((raw_string[raw_string_index] == delimiter) || end_string) {\n            raw_string[raw_string_index] = '\\0';\n            LOC_LOGD(\"%s:%d]: split string: %s\\n\",\n                     __func__, __LINE__, split_strings_ptr[num_split_strings]);\n            num_split_strings++;\n            if(((raw_string_index + 1) < raw_string_length) &&\n               (num_split_strings < max_num_substrings)) {\n                split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1];\n            }\n            else {\n                break;\n            }\n        }\n        if(end_string)\n            break;\n    }\nerr:\n    LOC_LOGD(\"%s:%d]: num_split_strings: %d\\n\", __func__, __LINE__, num_split_strings);\n    return num_split_strings;\n}\n\nvoid loc_util_trim_space(char *org_string)\n{\n    char *scan_ptr, *write_ptr;\n    char *first_nonspace = NULL, *last_nonspace = NULL;\n\n    if(org_string == NULL) {\n        LOC_LOGE(\"%s:%d]: NULL parameter\", __func__, __LINE__);\n        goto err;\n    }\n\n    scan_ptr = write_ptr = org_string;\n\n    while (*scan_ptr) {\n        //Find the first non-space character\n        if ( !isspace(*scan_ptr) && first_nonspace == NULL) {\n            first_nonspace = scan_ptr;\n        }\n        //Once the first non-space character is found in the\n        //above check, keep shifting the characters to the left\n        //to replace the spaces\n        if (first_nonspace != NULL) {\n            *(write_ptr++) = *scan_ptr;\n            //Keep track of which was the last non-space character\n            //encountered\n            //last_nonspace will not be updated in the case where\n            //the string ends with spaces\n            if ( !isspace(*scan_ptr)) {\n                last_nonspace = write_ptr;\n            }\n        }\n        scan_ptr++;\n    }\n    //Add NULL terminator after the last non-space character\n    if (last_nonspace) { *last_nonspace = '\\0'; }\nerr:\n    return;\n}\n"
  },
  {
    "path": "gps/utils/loc_misc_utils.h",
    "content": "/* Copyright (c) 2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef _LOC_MISC_UTILS_H_\n#define _LOC_MISC_UTILS_H_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*===========================================================================\nFUNCTION loc_split_string\n\nDESCRIPTION:\n    This function is used to split a delimiter separated string into\n    sub-strings. This function does not allocate new memory to store the split\n    strings. Instead, it places '\\0' in places of delimiters and assings the\n    starting address of the substring within the raw string as the string address\n    The input raw_string no longer remains to be a collection of sub-strings\n    after this function is executed.\n    Please make a copy of the input string before calling this function if\n    necessary\n\nPARAMETERS:\n    char *raw_string: is the original string with delimiter separated substrings\n    char **split_strings_ptr: is the arraw of pointers which will hold the addresses\n                              of individual substrings\n    int max_num_substrings: is the maximum number of substrings that are expected\n                            by the caller. The array of pointers in the above parameter\n                            is usually this long\n    char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';'\n\nDEPENDENCIES\n    N/A\n\nRETURN VALUE\n    int Number of split strings\n\nSIDE EFFECTS\n    The input raw_string no longer remains a delimiter separated single string.\n\nEXAMPLE\n    delimiter = ' ' //space\n    raw_string = \"hello new user\" //delimiter is space ' '\n    addresses  =  0123456789abcd\n    split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains \"hello\"\n    split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains \"new\"\n    split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains \"user\"\n\n===========================================================================*/\nint loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings,\n                     char delimiter);\n\n/*===========================================================================\nFUNCTION trim_space\n\nDESCRIPTION\n   Removes leading and trailing spaces of the string\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   None\n\nSIDE EFFECTS\n   N/A\n===========================================================================*/\nvoid loc_util_trim_space(char *org_string);\n#ifdef __cplusplus\n}\n#endif\n\n#endif //_LOC_MISC_UTILS_H_\n"
  },
  {
    "path": "gps/utils/loc_target.cpp",
    "content": "/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <hardware/gps.h>\n#include <cutils/properties.h>\n#include \"loc_target.h\"\n#include \"loc_log.h\"\n#include \"log_util.h\"\n\n#define APQ8064_ID_1 \"109\"\n#define APQ8064_ID_2 \"153\"\n#define MPQ8064_ID_1 \"130\"\n#define MSM8930_ID_1 \"142\"\n#define MSM8930_ID_2 \"116\"\n#define APQ8030_ID_1 \"157\"\n#define APQ8074_ID_1 \"184\"\n\n#define LINE_LEN 100\n#define STR_LIQUID    \"Liquid\"\n#define STR_SURF      \"Surf\"\n#define STR_MTP       \"MTP\"\n#define STR_APQ       \"apq\"\n#define STR_AUTO      \"auto\"\n#define IS_STR_END(c) ((c) == '\\0' || (c) == '\\n' || (c) == '\\r')\n#define LENGTH(s) (sizeof(s) - 1)\n#define GPS_CHECK_NO_ERROR 0\n#define GPS_CHECK_NO_GPS_HW 1\n/* When system server is started, it uses 20 seconds as ActivityManager\n * timeout. After that it sends SIGSTOP signal to process.\n */\n#define QCA1530_DETECT_TIMEOUT 15\n#define QCA1530_DETECT_PRESENT \"yes\"\n#define QCA1530_DETECT_PROGRESS \"detect\"\n\nstatic unsigned int gTarget = (unsigned int)-1;\n\nstatic int read_a_line(const char * file_path, char * line, int line_size)\n{\n    FILE *fp;\n    int result = 0;\n\n    * line = '\\0';\n    fp = fopen(file_path, \"r\" );\n    if( fp == NULL ) {\n        LOC_LOGE(\"open failed: %s: %s\\n\", file_path, strerror(errno));\n        result = -1;\n    } else {\n        int len;\n        fgets(line, line_size, fp);\n        len = strlen(line);\n        len = len < line_size - 1? len : line_size - 1;\n        line[len] = '\\0';\n        LOC_LOGD(\"cat %s: %s\", file_path, line);\n        fclose(fp);\n    }\n    return result;\n}\n\n/*!\n * \\brief Checks if QCA1530 is avalable.\n *\n * Function verifies if qca1530 SoC is configured on the device. The test is\n * based on property value. For 1530 scenario, the value shall be one of the\n * following: \"yes\", \"no\", \"detect\". All other values are treated equally to\n * \"no\". When the value is \"detect\" the system waits for SoC detection to\n * finish before returning result.\n *\n * \\retval true - QCA1530 is available.\n * \\retval false - QCA1530 is not available.\n */\nstatic bool is_qca1530(void)\n{\n    static const char qca1530_property_name[] = \"sys.qca1530\";\n    bool res = false;\n    int ret, i;\n    char buf[PROPERTY_VALUE_MAX];\n\n    memset(buf, 0, sizeof(buf));\n\n    for (i = 0; i < QCA1530_DETECT_TIMEOUT; ++i)\n    {\n        ret = property_get(qca1530_property_name, buf, NULL);\n        if (ret < 0)\n        {\n            LOC_LOGV( \"qca1530: property %s is not accessible, ret=%d\",\n                  qca1530_property_name,\n                  ret);\n\n            break;\n        }\n\n        LOC_LOGV( \"qca1530: property %s is set to %s\",\n                  qca1530_property_name,\n                  buf);\n\n        if (!memcmp(buf, QCA1530_DETECT_PRESENT,\n                    sizeof(QCA1530_DETECT_PRESENT)))\n        {\n            res = true;\n            break;\n        }\n        if (!memcmp(buf, QCA1530_DETECT_PROGRESS,\n                    sizeof(QCA1530_DETECT_PROGRESS)))\n        {\n            LOC_LOGV(\"qca1530: SoC detection is in progress.\");\n            sleep(1);\n            continue;\n        }\n        break;\n    }\n\n    LOC_LOGD(\"qca1530: detected=%s\", res ? \"true\" : \"false\");\n    return res;\n}\n\n/*The character array passed to this function should have length\n  of atleast PROPERTY_VALUE_MAX*/\nvoid loc_get_target_baseband(char *baseband, int array_length)\n{\n    if(baseband && (array_length >= PROPERTY_VALUE_MAX)) {\n        property_get(\"ro.baseband\", baseband, \"\");\n        LOC_LOGD(\"%s:%d]: Baseband: %s\\n\", __func__, __LINE__, baseband);\n    }\n    else {\n        LOC_LOGE(\"%s:%d]: NULL parameter or array length less than PROPERTY_VALUE_MAX\\n\",\n                 __func__, __LINE__);\n    }\n}\n\n/*The character array passed to this function should have length\n  of atleast PROPERTY_VALUE_MAX*/\nvoid loc_get_platform_name(char *platform_name, int array_length)\n{\n    if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) {\n        property_get(\"ro.board.platform\", platform_name, \"\");\n        LOC_LOGD(\"%s:%d]: Target name: %s\\n\", __func__, __LINE__, platform_name);\n    }\n    else {\n        LOC_LOGE(\"%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\\n\",\n                 __func__, __LINE__);\n    }\n}\n\nunsigned int loc_get_target(void)\n{\n    if (gTarget != (unsigned int)-1)\n        return gTarget;\n\n    static const char hw_platform[]      = \"/sys/devices/soc0/hw_platform\";\n    static const char id[]               = \"/sys/devices/soc0/soc_id\";\n    static const char hw_platform_dep[]  =\n        \"/sys/devices/system/soc/soc0/hw_platform\";\n    static const char id_dep[]           = \"/sys/devices/system/soc/soc0/id\";\n    static const char mdm[]              = \"/dev/mdm\"; // No such file or directory\n\n    char rd_hw_platform[LINE_LEN];\n    char rd_id[LINE_LEN];\n    char rd_mdm[LINE_LEN];\n    char baseband[LINE_LEN];\n\n    if (is_qca1530()) {\n        gTarget = TARGET_QCA1530;\n        goto detected;\n    }\n\n    loc_get_target_baseband(baseband, sizeof(baseband));\n\n    if (!access(hw_platform, F_OK)) {\n        read_a_line(hw_platform, rd_hw_platform, LINE_LEN);\n    } else {\n        read_a_line(hw_platform_dep, rd_hw_platform, LINE_LEN);\n    }\n    if (!access(id, F_OK)) {\n        read_a_line(id, rd_id, LINE_LEN);\n    } else {\n        read_a_line(id_dep, rd_id, LINE_LEN);\n    }\n    if( !memcmp(baseband, STR_AUTO, LENGTH(STR_AUTO)) )\n    {\n          gTarget = TARGET_AUTO;\n          goto detected;\n    }\n    if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){\n\n        if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1))\n            && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) )\n            gTarget = TARGET_MPQ;\n        else\n            gTarget = TARGET_APQ_SA;\n    }\n    else {\n        if( (!memcmp(rd_hw_platform, STR_LIQUID, LENGTH(STR_LIQUID))\n             && IS_STR_END(rd_hw_platform[LENGTH(STR_LIQUID)])) ||\n            (!memcmp(rd_hw_platform, STR_SURF,   LENGTH(STR_SURF))\n             && IS_STR_END(rd_hw_platform[LENGTH(STR_SURF)])) ||\n            (!memcmp(rd_hw_platform, STR_MTP,   LENGTH(STR_MTP))\n             && IS_STR_END(rd_hw_platform[LENGTH(STR_MTP)]))) {\n\n            if (!read_a_line( mdm, rd_mdm, LINE_LEN))\n                gTarget = TARGET_MDM;\n        }\n        else if( (!memcmp(rd_id, MSM8930_ID_1, LENGTH(MSM8930_ID_1))\n                   && IS_STR_END(rd_id[LENGTH(MSM8930_ID_1)])) ||\n                  (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2))\n                   && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) )\n             gTarget = TARGET_MSM_NO_SSC;\n        else\n             gTarget = TARGET_UNKNOWN;\n    }\n\ndetected:\n    LOC_LOGD(\"HAL: %s returned %d\", __FUNCTION__, gTarget);\n    return gTarget;\n}\n\n/*Reads the property ro.lean to identify if this is a lean target\n  Returns:\n  0 if not a lean and mean target\n  1 if this is a lean and mean target\n*/\nint loc_identify_lean_target()\n{\n    int ret = 0;\n    char lean_target[PROPERTY_VALUE_MAX];\n    property_get(\"ro.lean\", lean_target, \"\");\n    LOC_LOGD(\"%s:%d]: lean target: %s\\n\", __func__, __LINE__, lean_target);\n    return !(strncmp(lean_target, \"true\", PROPERTY_VALUE_MAX));\n}\n"
  },
  {
    "path": "gps/utils/loc_target.h",
    "content": "/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n#ifndef LOC_TARGET_H\n#define LOC_TARGET_H\n#define TARGET_SET(gnss,ssc) ( (gnss<<1)|ssc )\n#define TARGET_DEFAULT       TARGET_SET(GNSS_MSM, HAS_SSC)\n#define TARGET_MDM           TARGET_SET(GNSS_MDM, HAS_SSC)\n#define TARGET_APQ_SA        TARGET_SET(GNSS_GSS, NO_SSC)\n#define TARGET_MPQ           TARGET_SET(GNSS_NONE,NO_SSC)\n#define TARGET_MSM_NO_SSC    TARGET_SET(GNSS_MSM, NO_SSC)\n#define TARGET_QCA1530       TARGET_SET(GNSS_QCA1530, NO_SSC)\n#define TARGET_AUTO          TARGET_SET(GNSS_AUTO, NO_SSC)\n#define TARGET_UNKNOWN       TARGET_SET(GNSS_UNKNOWN, NO_SSC)\n#define getTargetGnssType(target)  (target>>1)\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\nunsigned int loc_get_target(void);\n\n/*The character array passed to this function should have length\n  of atleast PROPERTY_VALUE_MAX*/\nvoid loc_get_target_baseband(char *baseband, int array_length);\n/*The character array passed to this function should have length\n  of atleast PROPERTY_VALUE_MAX*/\nvoid loc_get_platform_name(char *platform_name, int array_length);\n/*Reads the property ro.lean to identify if this is a lean target\n  Returns:\n  0 if not a lean and mean target\n  1 if this is a lean and mean target*/\nint loc_identify_lean_target();\n\n/* Please remember to update 'target_name' in loc_log.cpp,\n   if do any changes to this enum. */\ntypedef enum {\n    GNSS_NONE = 0,\n    GNSS_MSM,\n    GNSS_GSS,\n    GNSS_MDM,\n    GNSS_QCA1530,\n    GNSS_AUTO,\n    GNSS_UNKNOWN\n}GNSS_TARGET;\n\ntypedef enum {\n    NO_SSC = 0,\n    HAS_SSC\n}SSC_TYPE;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /*LOC_TARGET_H*/\n"
  },
  {
    "path": "gps/utils/loc_timer.h",
    "content": "/* Copyright (c) 2013,2015 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef __LOC_DELAY_H__\n#define __LOC_DELAY_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n#include <stddef.h>\n\n/*\n    user_data: client context pointer, passthrough. Originally received\n               from calling client when loc_timer_start() is called.\n    result:    0 if timer successfully timed out; else timer failed.\n*/\ntypedef void (*loc_timer_callback)(void *user_data, int32_t result);\n\n\n/*\n    delay_msec:         timeout value for the timer.\n    cb_func:            callback function pointer, implemented by client.\n                        Can not be NULL.\n    user_data:          client context pointer, passthrough.  Will be\n                        returned when loc_timer_callback() is called.\n    wakeOnExpire:       true if to wake up CPU (if sleeping) upon timer\n                                expiration and notify the client.\n                        false if to wait until next time CPU wakes up (if\n                                 sleeping) and then notify the client.\n    Returns the handle, which can be used to stop the timer\n                        NULL, if timer start fails (e.g. if cb_func is NULL).\n*/\nvoid* loc_timer_start(uint64_t delay_msec,\n                      loc_timer_callback cb_func,\n                      void *user_data,\n                      bool wake_on_expire=false);\n\n/*\n    handle becomes invalid upon the return of the callback\n*/\nvoid loc_timer_stop(void*& handle);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif //__LOC_DELAY_H__\n"
  },
  {
    "path": "gps/utils/log_util.h",
    "content": "/* Copyright (c) 2011-2014 The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#ifndef __LOG_UTIL_H__\n#define __LOG_UTIL_H__\n\n#ifndef USE_GLIB\n#include <utils/Log.h>\n#endif /* USE_GLIB */\n\n#ifdef USE_GLIB\n\n#include <stdio.h>\n#include <sys/types.h>\n#include <unistd.h>\n\n#ifndef LOG_TAG\n#define LOG_TAG \"GPS_UTILS\"\n\n#endif  // LOG_TAG\n\n#endif /* USE_GLIB */\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n/*=============================================================================\n *\n *                         LOC LOGGER TYPE DECLARATION\n *\n *============================================================================*/\n/* LOC LOGGER */\ntypedef struct loc_logger_s\n{\n  unsigned long  DEBUG_LEVEL;\n  unsigned long  TIMESTAMP;\n} loc_logger_s_type;\n\n/*=============================================================================\n *\n *                               EXTERNAL DATA\n *\n *============================================================================*/\nextern loc_logger_s_type loc_logger;\n\n// Logging Improvements\nextern const char *loc_logger_boolStr[];\n\nextern const char *boolStr[];\nextern const char VOID_RET[];\nextern const char FROM_AFW[];\nextern const char TO_MODEM[];\nextern const char FROM_MODEM[];\nextern const char TO_AFW[];\nextern const char EXIT_TAG[];\nextern const char ENTRY_TAG[];\nextern const char EXIT_ERROR_TAG[];\n\n/*=============================================================================\n *\n *                        MODULE EXPORTED FUNCTIONS\n *\n *============================================================================*/\nextern void loc_logger_init(unsigned long debug, unsigned long timestamp);\nextern char* get_timestamp(char* str, unsigned long buf_size);\n\n#ifndef DEBUG_DMN_LOC_API\n\n/* LOGGING MACROS */\n/*loc_logger.DEBUG_LEVEL is initialized to 0xff in loc_cfg.cpp\n  if that value remains unchanged, it means gps.conf did not\n  provide a value and we default to the initial value to use\n  Android's logging levels*/\n#define IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5))\n\n#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5))\n\n#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5))\n\n#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5))\n\n#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5))\n\n#define LOC_LOGE(...) \\\nIF_LOC_LOGE { ALOGE(\"E/\" __VA_ARGS__); } \\\nelse if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE(\"E/\" __VA_ARGS__); }\n\n#define LOC_LOGW(...) \\\nIF_LOC_LOGW { ALOGE(\"W/\" __VA_ARGS__); }  \\\nelse if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW(\"W/\" __VA_ARGS__); }\n\n#define LOC_LOGI(...) \\\nIF_LOC_LOGI { ALOGE(\"I/\" __VA_ARGS__); }   \\\nelse if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI(\"I/\" __VA_ARGS__); }\n\n#define LOC_LOGD(...) \\\nIF_LOC_LOGD { ALOGE(\"D/\" __VA_ARGS__); }   \\\nelse if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD(\"D/\" __VA_ARGS__); }\n\n#define LOC_LOGV(...) \\\nIF_LOC_LOGV { ALOGE(\"V/\" __VA_ARGS__); }   \\\nelse if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV(\"V/\" __VA_ARGS__); }\n\n#else /* DEBUG_DMN_LOC_API */\n\n#define LOC_LOGE(...) ALOGE(\"E/\" __VA_ARGS__)\n\n#define LOC_LOGW(...) ALOGW(\"W/\" __VA_ARGS__)\n\n#define LOC_LOGI(...) ALOGI(\"I/\" __VA_ARGS__)\n\n#define LOC_LOGD(...) ALOGD(\"D/\" __VA_ARGS__)\n\n#define LOC_LOGV(...) ALOGV(\"V/\" __VA_ARGS__)\n\n#endif /* DEBUG_DMN_LOC_API */\n\n/*=============================================================================\n *\n *                          LOGGING IMPROVEMENT MACROS\n *\n *============================================================================*/\n#define LOG_(LOC_LOG, ID, WHAT, SPEC, VAL)                                    \\\n    do {                                                                      \\\n        if (loc_logger.TIMESTAMP) {                                           \\\n            char ts[32];                                                      \\\n            LOC_LOG(\"[%s] %s %s line %d \" #SPEC,                              \\\n                     get_timestamp(ts, sizeof(ts)), ID, WHAT, __LINE__, VAL); \\\n        } else {                                                              \\\n            LOC_LOG(\"%s %s line %d \" #SPEC,                                   \\\n                     ID, WHAT, __LINE__, VAL);                                \\\n        }                                                                     \\\n    } while(0)\n\n#define LOG_I(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGI, ID, WHAT, SPEC, VAL)\n#define LOG_V(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGV, ID, WHAT, SPEC, VAL)\n#define LOG_E(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGE, ID, WHAT, SPEC, VAL)\n\n#define ENTRY_LOG() LOG_V(ENTRY_TAG, __func__, %s, \"\")\n#define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __func__, SPEC, VAL)\n#define EXIT_LOG_WITH_ERROR(SPEC, VAL)                       \\\n    if (VAL != 0) {                                          \\\n        LOG_E(EXIT_ERROR_TAG, __func__, SPEC, VAL);          \\\n    } else {                                                 \\\n        LOG_V(EXIT_TAG, __func__, SPEC, VAL);                \\\n    }\n\n\n// Used for logging callflow from Android Framework\n#define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __func__, %s, \"\")\n// Used for logging callflow to Modem\n#define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __func__, SPEC, VAL)\n// Used for logging callflow from Modem(TO_MODEM, __func__, %s, \"\")\n#define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __func__, SPEC, VAL)\n// Used for logging callflow to Android Framework\n#define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL)\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // __LOG_UTIL_H__\n"
  },
  {
    "path": "gps/utils/msg_q.c",
    "content": "/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation, nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include \"msg_q.h\"\n\n#define LOG_TAG \"LocSvc_utils_q\"\n#include \"log_util.h\"\n#include \"platform_lib_includes.h\"\n#include \"linked_list.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <pthread.h>\n\ntypedef struct msg_q {\n   void* msg_list;                  /* Linked list to store information */\n   pthread_cond_t  list_cond;       /* Condition variable for waiting on msg queue */\n   pthread_mutex_t list_mutex;      /* Mutex for exclusive access to message queue */\n   int unblocked;                   /* Has this message queue been unblocked? */\n} msg_q;\n\n/*===========================================================================\nFUNCTION    convert_linked_list_err_type\n\nDESCRIPTION\n   Converts from one set of enum values to another.\n\n   linked_list_val: Value to convert to msg_q_enum_type\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Corresponding linked_list_enum_type in msg_q_enum_type\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nstatic msq_q_err_type convert_linked_list_err_type(linked_list_err_type linked_list_val)\n{\n   switch( linked_list_val )\n   {\n   case eLINKED_LIST_SUCCESS:\n      return eMSG_Q_SUCCESS;\n   case eLINKED_LIST_INVALID_PARAMETER:\n      return eMSG_Q_INVALID_PARAMETER;\n   case eLINKED_LIST_INVALID_HANDLE:\n      return eMSG_Q_INVALID_HANDLE;\n   case eLINKED_LIST_UNAVAILABLE_RESOURCE:\n      return eMSG_Q_UNAVAILABLE_RESOURCE;\n   case eLINKED_LIST_INSUFFICIENT_BUFFER:\n      return eMSG_Q_INSUFFICIENT_BUFFER;\n\n   case eLINKED_LIST_FAILURE_GENERAL:\n   default:\n      return eMSG_Q_FAILURE_GENERAL;\n   }\n}\n\n/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */\n\n/*===========================================================================\n\n  FUNCTION:   msg_q_init\n\n  ===========================================================================*/\nmsq_q_err_type msg_q_init(void** msg_q_data)\n{\n   if( msg_q_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid msg_q_data parameter!\\n\", __FUNCTION__);\n      return eMSG_Q_INVALID_PARAMETER;\n   }\n\n   msg_q* tmp_msg_q;\n   tmp_msg_q = (msg_q*)calloc(1, sizeof(msg_q));\n   if( tmp_msg_q == NULL )\n   {\n      LOC_LOGE(\"%s: Unable to allocate space for message queue!\\n\", __FUNCTION__);\n      return eMSG_Q_FAILURE_GENERAL;\n   }\n\n   if( linked_list_init(&tmp_msg_q->msg_list) != 0 )\n   {\n      LOC_LOGE(\"%s: Unable to initialize storage list!\\n\", __FUNCTION__);\n      free(tmp_msg_q);\n      return eMSG_Q_FAILURE_GENERAL;\n   }\n\n   if( pthread_mutex_init(&tmp_msg_q->list_mutex, NULL) != 0 )\n   {\n      LOC_LOGE(\"%s: Unable to initialize list mutex!\\n\", __FUNCTION__);\n      linked_list_destroy(&tmp_msg_q->msg_list);\n      free(tmp_msg_q);\n      return eMSG_Q_FAILURE_GENERAL;\n   }\n\n   if( pthread_cond_init(&tmp_msg_q->list_cond, NULL) != 0 )\n   {\n      LOC_LOGE(\"%s: Unable to initialize msg q cond var!\\n\", __FUNCTION__);\n      linked_list_destroy(&tmp_msg_q->msg_list);\n      pthread_mutex_destroy(&tmp_msg_q->list_mutex);\n      free(tmp_msg_q);\n      return eMSG_Q_FAILURE_GENERAL;\n   }\n\n   tmp_msg_q->unblocked = 0;\n\n   *msg_q_data = tmp_msg_q;\n\n   return eMSG_Q_SUCCESS;\n}\n\n/*===========================================================================\n\n  FUNCTION:   msg_q_init2\n\n  ===========================================================================*/\nconst void* msg_q_init2()\n{\n  void* q = NULL;\n  if (eMSG_Q_SUCCESS != msg_q_init(&q)) {\n    q = NULL;\n  }\n  return q;\n}\n\n/*===========================================================================\n\n  FUNCTION:   msg_q_destroy\n\n  ===========================================================================*/\nmsq_q_err_type msg_q_destroy(void** msg_q_data)\n{\n   if( msg_q_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid msg_q_data parameter!\\n\", __FUNCTION__);\n      return eMSG_Q_INVALID_HANDLE;\n   }\n\n   msg_q* p_msg_q = (msg_q*)*msg_q_data;\n\n   linked_list_destroy(&p_msg_q->msg_list);\n   pthread_mutex_destroy(&p_msg_q->list_mutex);\n   pthread_cond_destroy(&p_msg_q->list_cond);\n\n   p_msg_q->unblocked = 0;\n\n   free(*msg_q_data);\n   *msg_q_data = NULL;\n\n   return eMSG_Q_SUCCESS;\n}\n\n/*===========================================================================\n\n  FUNCTION:   msg_q_snd\n\n  ===========================================================================*/\nmsq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*))\n{\n   msq_q_err_type rv;\n   if( msg_q_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid msg_q_data parameter!\\n\", __FUNCTION__);\n      return eMSG_Q_INVALID_HANDLE;\n   }\n   if( msg_obj == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid msg_obj parameter!\\n\", __FUNCTION__);\n      return eMSG_Q_INVALID_PARAMETER;\n   }\n\n   msg_q* p_msg_q = (msg_q*)msg_q_data;\n\n   pthread_mutex_lock(&p_msg_q->list_mutex);\n   LOC_LOGD(\"%s: Sending message with handle = 0x%08X\\n\", __FUNCTION__, msg_obj);\n\n   if( p_msg_q->unblocked )\n   {\n      LOC_LOGE(\"%s: Message queue has been unblocked.\\n\", __FUNCTION__);\n      pthread_mutex_unlock(&p_msg_q->list_mutex);\n      return eMSG_Q_UNAVAILABLE_RESOURCE;\n   }\n\n   rv = convert_linked_list_err_type(linked_list_add(p_msg_q->msg_list, msg_obj, dealloc));\n\n   /* Show data is in the message queue. */\n   pthread_cond_signal(&p_msg_q->list_cond);\n\n   pthread_mutex_unlock(&p_msg_q->list_mutex);\n\n   LOC_LOGD(\"%s: Finished Sending message with handle = 0x%08X\\n\", __FUNCTION__, msg_obj);\n\n   return rv;\n}\n\n/*===========================================================================\n\n  FUNCTION:   msg_q_rcv\n\n  ===========================================================================*/\nmsq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj)\n{\n   msq_q_err_type rv;\n   if( msg_q_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid msg_q_data parameter!\\n\", __FUNCTION__);\n      return eMSG_Q_INVALID_HANDLE;\n   }\n\n   if( msg_obj == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid msg_obj parameter!\\n\", __FUNCTION__);\n      return eMSG_Q_INVALID_PARAMETER;\n   }\n\n   msg_q* p_msg_q = (msg_q*)msg_q_data;\n\n   LOC_LOGD(\"%s: Waiting on message\\n\", __FUNCTION__);\n\n   pthread_mutex_lock(&p_msg_q->list_mutex);\n\n   if( p_msg_q->unblocked )\n   {\n      LOC_LOGE(\"%s: Message queue has been unblocked.\\n\", __FUNCTION__);\n      pthread_mutex_unlock(&p_msg_q->list_mutex);\n      return eMSG_Q_UNAVAILABLE_RESOURCE;\n   }\n\n   /* Wait for data in the message queue */\n   while( linked_list_empty(p_msg_q->msg_list) && !p_msg_q->unblocked )\n   {\n      pthread_cond_wait(&p_msg_q->list_cond, &p_msg_q->list_mutex);\n   }\n\n   rv = convert_linked_list_err_type(linked_list_remove(p_msg_q->msg_list, msg_obj));\n\n   pthread_mutex_unlock(&p_msg_q->list_mutex);\n\n   LOC_LOGD(\"%s: Received message 0x%08X rv = %d\\n\", __FUNCTION__, *msg_obj, rv);\n\n   return rv;\n}\n\n/*===========================================================================\n\n  FUNCTION:   msg_q_flush\n\n  ===========================================================================*/\nmsq_q_err_type msg_q_flush(void* msg_q_data)\n{\n   msq_q_err_type rv;\n   if ( msg_q_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid msg_q_data parameter!\\n\", __FUNCTION__);\n      return eMSG_Q_INVALID_HANDLE;\n   }\n\n   msg_q* p_msg_q = (msg_q*)msg_q_data;\n\n   LOC_LOGD(\"%s: Flushing Message Queue\\n\", __FUNCTION__);\n\n   pthread_mutex_lock(&p_msg_q->list_mutex);\n\n   /* Remove all elements from the list */\n   rv = convert_linked_list_err_type(linked_list_flush(p_msg_q->msg_list));\n\n   pthread_mutex_unlock(&p_msg_q->list_mutex);\n\n   LOC_LOGD(\"%s: Message Queue flushed\\n\", __FUNCTION__);\n\n   return rv;\n}\n\n/*===========================================================================\n\n  FUNCTION:   msg_q_unblock\n\n  ===========================================================================*/\nmsq_q_err_type msg_q_unblock(void* msg_q_data)\n{\n   if ( msg_q_data == NULL )\n   {\n      LOC_LOGE(\"%s: Invalid msg_q_data parameter!\\n\", __FUNCTION__);\n      return eMSG_Q_INVALID_HANDLE;\n   }\n\n   msg_q* p_msg_q = (msg_q*)msg_q_data;\n   pthread_mutex_lock(&p_msg_q->list_mutex);\n\n   if( p_msg_q->unblocked )\n   {\n      LOC_LOGE(\"%s: Message queue has been unblocked.\\n\", __FUNCTION__);\n      pthread_mutex_unlock(&p_msg_q->list_mutex);\n      return eMSG_Q_UNAVAILABLE_RESOURCE;\n   }\n\n   LOC_LOGD(\"%s: Unblocking Message Queue\\n\", __FUNCTION__);\n   /* Unblocking message queue */\n   p_msg_q->unblocked = 1;\n\n   /* Allow all the waiters to wake up */\n   pthread_cond_broadcast(&p_msg_q->list_cond);\n\n   pthread_mutex_unlock(&p_msg_q->list_mutex);\n\n   LOC_LOGD(\"%s: Message Queue unblocked\\n\", __FUNCTION__);\n\n   return eMSG_Q_SUCCESS;\n}\n"
  },
  {
    "path": "gps/utils/msg_q.h",
    "content": "/* Copyright (c) 2011, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef __MSG_Q_H__\n#define __MSG_Q_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#include <stdlib.h>\n\n/** Linked List Return Codes */\ntypedef enum\n{\n  eMSG_Q_SUCCESS                             = 0,\n     /**< Request was successful. */\n  eMSG_Q_FAILURE_GENERAL                     = -1,\n     /**< Failed because of a general failure. */\n  eMSG_Q_INVALID_PARAMETER                   = -2,\n     /**< Failed because the request contained invalid parameters. */\n  eMSG_Q_INVALID_HANDLE                      = -3,\n     /**< Failed because an invalid handle was specified. */\n  eMSG_Q_UNAVAILABLE_RESOURCE                = -4,\n     /**< Failed because an there were not enough resources. */\n  eMSG_Q_INSUFFICIENT_BUFFER                 = -5,\n     /**< Failed because an the supplied buffer was too small. */\n}msq_q_err_type;\n\n/*===========================================================================\nFUNCTION    msg_q_init\n\nDESCRIPTION\n   Initializes internal structures for message queue.\n\n   msg_q_data: pointer to an opaque Q handle to be returned; NULL if fails\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nmsq_q_err_type msg_q_init(void** msg_q_data);\n\n/*===========================================================================\nFUNCTION    msg_q_init2\n\nDESCRIPTION\n   Initializes internal structures for message queue.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   opaque handle to the Q created; NULL if create fails\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nconst void* msg_q_init2();\n\n/*===========================================================================\nFUNCTION    msg_q_destroy\n\nDESCRIPTION\n   Releases internal structures for message queue.\n\n   msg_q_data: State of message queue to be released.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nmsq_q_err_type msg_q_destroy(void** msg_q_data);\n\n/*===========================================================================\nFUNCTION    msg_q_snd\n\nDESCRIPTION\n   Sends data to the message queue. The passed in data pointer\n   is not modified or freed. Passed in msg_obj is expected to live throughout\n   the use of the msg_q (i.e. data is not allocated internally)\n\n   msg_q_data: Message Queue to add the element to.\n   msgp:       Pointer to data to add into message queue.\n   dealloc:    Function used to deallocate memory for this element. Pass NULL\n               if you do not want data deallocated during a flush operation\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nmsq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*));\n\n/*===========================================================================\nFUNCTION    msg_q_rcv\n\nDESCRIPTION\n   Retrieves data from the message queue. msg_obj is the oldest message received\n   and pointer is simply removed from message queue.\n\n   msg_q_data: Message Queue to copy data from into msgp.\n   msg_obj:    Pointer to space to copy msg_q contents to.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nmsq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj);\n\n/*===========================================================================\nFUNCTION    msg_q_flush\n\nDESCRIPTION\n   Function removes all elements from the message queue.\n\n   msg_q_data: Message Queue to remove elements from.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nmsq_q_err_type msg_q_flush(void* msg_q_data);\n\n/*===========================================================================\nFUNCTION    msg_q_unblock\n\nDESCRIPTION\n   This function will stop use of the message queue. All waiters will wake up\n   and likely receive nothing from the queue resulting in a negative return\n   value. The message queue can no longer be used until it is destroyed\n   and initialized again after calling this function.\n\n   msg_q_data: Message queue to unblock.\n\nDEPENDENCIES\n   N/A\n\nRETURN VALUE\n   Look at error codes above.\n\nSIDE EFFECTS\n   N/A\n\n===========================================================================*/\nmsq_q_err_type msg_q_unblock(void* msg_q_data);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* __MSG_Q_H__ */\n"
  },
  {
    "path": "gps/utils/platform_lib_abstractions/elapsed_millis_since_boot.cpp",
    "content": "/* Copyright (c) 2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include <stdlib.h>\n#include <sys/time.h>\n#include \"platform_lib_time.h\"\n\nint64_t systemTime(int clock)\n{\n    struct timeval t;\n    t.tv_sec = t.tv_usec = 0;\n    gettimeofday(&t, NULL);\n    return t.tv_sec*1000000LL + t.tv_usec;\n}\n\n\nint64_t elapsedMillisSinceBoot()\n{\n    int64_t t_us = systemTime(0);\n    return (int64_t) t_us / 1000LL;\n}\n"
  },
  {
    "path": "gps/utils/platform_lib_abstractions/platform_lib_includes.h",
    "content": "/* Copyright (c) 2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef _PLATFORM_LIB_INCLUDES_H_\n#define _PLATFORM_LIB_INCLUDES_H_\n\n#include \"platform_lib_time.h\"\n#include \"platform_lib_macros.h\"\n\n#endif\n"
  },
  {
    "path": "gps/utils/platform_lib_abstractions/platform_lib_macros.h",
    "content": "/* Copyright (c) 2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef __PLATFORM_LIB_MACROS_H__\n#define __PLATFORM_LIB_MACROS_H__\n\n#include <sys/time.h>\n\n#define TS_PRINTF(format, x...)                                \\\n{                                                              \\\n  struct timeval tv;                                           \\\n  struct timezone tz;                                          \\\n  int hh, mm, ss;                                              \\\n  gettimeofday(&tv, &tz);                                      \\\n  hh = tv.tv_sec/3600%24;                                      \\\n  mm = (tv.tv_sec%3600)/60;                                    \\\n  ss = tv.tv_sec%60;                                           \\\n  fprintf(stdout,\"%02d:%02d:%02d.%06ld]\" format \"\\n\", hh, mm, ss, tv.tv_usec,##x);    \\\n}\n\n\n#ifdef USE_GLIB\n\n#define strlcat g_strlcat\n#define strlcpy g_strlcpy\n\n#define ALOGE(format, x...) TS_PRINTF(\"E/%s (%d): \" format , LOG_TAG, getpid(), ##x)\n#define ALOGW(format, x...) TS_PRINTF(\"W/%s (%d): \" format , LOG_TAG, getpid(), ##x)\n#define ALOGI(format, x...) TS_PRINTF(\"I/%s (%d): \" format , LOG_TAG, getpid(), ##x)\n#define ALOGD(format, x...) TS_PRINTF(\"D/%s (%d): \" format , LOG_TAG, getpid(), ##x)\n#define ALOGV(format, x...) TS_PRINTF(\"V/%s (%d): \" format , LOG_TAG, getpid(), ##x)\n\n#define GETTID_PLATFORM_LIB_ABSTRACTION (syscall(SYS_gettid))\n\n#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION createPthread\n#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (elapsedMillisSinceBoot())\n\n\n#else\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\npid_t gettid(void);\n\n#ifdef __cplusplus\n}\n#endif\n\n#define GETTID_PLATFORM_LIB_ABSTRACTION (gettid())\n#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION android::AndroidRuntime::createJavaThread\n#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION  (android::elapsedRealtime())\n\n#endif\n\n#endif\n"
  },
  {
    "path": "gps/utils/platform_lib_abstractions/platform_lib_time.h",
    "content": "/* Copyright (c) 2013, The Linux Foundation. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials provided\n *       with the distribution.\n *     * Neither the name of The Linux Foundation nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef _PLATFORM_LIB_TIME_H_\n#define _PLATFORM_LIB_TIME_H_\n\nint64_t systemTime(int clock);\nint64_t elapsedMillisSinceBoot();\n\n#endif\n"
  },
  {
    "path": "include/camera/CameraParametersExtra.h",
    "content": "/*\n * Copyright (C) 2016 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define CAMERA_PARAMETERS_EXTRA_C \\\nconst char CameraParameters::KEY_APP_MASK[] = \"app-mask\";\n\n#define CAMERA_PARAMETERS_EXTRA_H \\\n    static const char KEY_APP_MASK[];\n"
  },
  {
    "path": "include/telephony/ril.h",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_RIL_H\n#define ANDROID_RIL_H 1\n\n#include <stdlib.h>\n#include <stdint.h>\n#include <telephony/ril_cdma_sms.h>\n#include <telephony/ril_nv_items.h>\n#include <telephony/ril_msim.h>\n\n#ifndef FEATURE_UNIT_TEST\n#include <sys/time.h>\n#endif /* !FEATURE_UNIT_TEST */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n#if defined(ANDROID_SIM_COUNT_2)\n#define SIM_COUNT 2\n#elif defined(ANDROID_SIM_COUNT_3)\n#define SIM_COUNT 3\n#elif defined(ANDROID_SIM_COUNT_4)\n#define SIM_COUNT 4\n#else\n#define SIM_COUNT 1\n#endif\n\n#ifndef ANDROID_MULTI_SIM\n#define SIM_COUNT 1\n#endif\n\n/*\n * RIL version.\n * Value of RIL_VERSION should not be changed in future. Here onwards,\n * when a new change is supposed to be introduced  which could involve new\n * schemes added like Wakelocks, data structures added/updated, etc, we would\n * just document RIL version associated with that change below. When OEM updates its\n * RIL with those changes, they would return that new RIL version during RIL_REGISTER.\n * We should make use of the returned version by vendor to identify appropriate scheme\n * or data structure version to use.\n *\n * Documentation of RIL version and associated changes\n * RIL_VERSION = 12 : This version corresponds to updated data structures namely\n *                    RIL_Data_Call_Response_v11, RIL_SIM_IO_v6, RIL_CardStatus_v6,\n *                    RIL_SimRefreshResponse_v7, RIL_CDMA_CallWaiting_v6,\n *                    RIL_LTE_SignalStrength_v8, RIL_SignalStrength_v10, RIL_CellIdentityGsm_v12\n *                    RIL_CellIdentityWcdma_v12, RIL_CellIdentityLte_v12,RIL_CellInfoGsm_v12,\n *                    RIL_CellInfoWcdma_v12, RIL_CellInfoLte_v12, RIL_CellInfo_v12.\n *\n * RIL_VERSION = 13 : This version includes new wakelock semantics and as the first\n *                    strongly versioned version it enforces structure use.\n * RIL_VERSION = 14 : New data structures are added, namely RIL_CarrierMatchType,\n *                    RIL_Carrier, RIL_CarrierRestrictions and RIL_PCO_Data.\n *                    New commands added: RIL_REQUEST_SET_CARRIER_RESTRICTIONS,\n *                    RIL_REQUEST_SET_CARRIER_RESTRICTIONS and\n *                    RIL_UNSOL_PCO_DATA\n */\n#if defined(USE_RIL_VERSION_10)\n#define RIL_VERSION 10\n#define LAST_IMPRECISE_RIL_VERSION 10\n#elif defined(USE_RIL_VERSION_11)\n#define RIL_VERSION 11\n#define LAST_IMPRECISE_RIL_VERSION 11\n#else\n#define RIL_VERSION 12\n#define LAST_IMPRECISE_RIL_VERSION 12 // Better self-documented name\n#endif\n#define RIL_VERSION_MIN 6 /* Minimum RIL_VERSION supported */\n\n#define CDMA_ALPHA_INFO_BUFFER_LENGTH 64\n#define CDMA_NUMBER_INFO_BUFFER_LENGTH 81\n\n#define MAX_RILDS 3\n#define MAX_SOCKET_NAME_LENGTH 6\n#define MAX_CLIENT_ID_LENGTH 2\n#define MAX_DEBUG_SOCKET_NAME_LENGTH 12\n#define MAX_QEMU_PIPE_NAME_LENGTH  11\n#define MAX_UUID_LENGTH 64\n\n\ntypedef void * RIL_Token;\n\ntypedef enum {\n    RIL_SOCKET_1,\n#if (SIM_COUNT >= 2)\n    RIL_SOCKET_2,\n#if (SIM_COUNT >= 3)\n    RIL_SOCKET_3,\n#endif\n#if (SIM_COUNT >= 4)\n    RIL_SOCKET_4,\n#endif\n#endif\n    RIL_SOCKET_NUM\n} RIL_SOCKET_ID;\n\n\ntypedef enum {\n    RIL_E_SUCCESS = 0,\n    RIL_E_RADIO_NOT_AVAILABLE = 1,     /* If radio did not start or is resetting */\n    RIL_E_GENERIC_FAILURE = 2,\n    RIL_E_PASSWORD_INCORRECT = 3,      /* for PIN/PIN2 methods only! */\n    RIL_E_SIM_PIN2 = 4,                /* Operation requires SIM PIN2 to be entered */\n    RIL_E_SIM_PUK2 = 5,                /* Operation requires SIM PIN2 to be entered */\n    RIL_E_REQUEST_NOT_SUPPORTED = 6,\n    RIL_E_CANCELLED = 7,\n    RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8, /* data ops are not allowed during voice\n                                                   call on a Class C GPRS device */\n    RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9,  /* data ops are not allowed before device\n                                                   registers in network */\n    RIL_E_SMS_SEND_FAIL_RETRY = 10,             /* fail to send sms and need retry */\n    RIL_E_SIM_ABSENT = 11,                      /* fail to set the location where CDMA subscription\n                                                   shall be retrieved because of SIM or RUIM\n                                                   card absent */\n    RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12,      /* fail to find CDMA subscription from specified\n                                                   location */\n    RIL_E_MODE_NOT_SUPPORTED = 13,              /* HW does not support preferred network type */\n    RIL_E_FDN_CHECK_FAILURE = 14,               /* command failed because recipient is not on FDN list */\n    RIL_E_ILLEGAL_SIM_OR_ME = 15,               /* network selection failed due to\n                                                   illegal SIM or ME */\n    RIL_E_MISSING_RESOURCE = 16,                /* no logical channel available */\n    RIL_E_NO_SUCH_ELEMENT = 17,                  /* application not found on SIM */\n    RIL_E_DIAL_MODIFIED_TO_USSD = 18,           /* DIAL request modified to USSD */\n    RIL_E_DIAL_MODIFIED_TO_SS = 19,             /* DIAL request modified to SS */\n    RIL_E_DIAL_MODIFIED_TO_DIAL = 20,           /* DIAL request modified to DIAL with different\n                                                   data */\n    RIL_E_USSD_MODIFIED_TO_DIAL = 21,           /* USSD request modified to DIAL */\n    RIL_E_USSD_MODIFIED_TO_SS = 22,             /* USSD request modified to SS */\n    RIL_E_USSD_MODIFIED_TO_USSD = 23,           /* USSD request modified to different USSD\n                                                   request */\n    RIL_E_SS_MODIFIED_TO_DIAL = 24,             /* SS request modified to DIAL */\n    RIL_E_SS_MODIFIED_TO_USSD = 25,             /* SS request modified to USSD */\n    RIL_E_SUBSCRIPTION_NOT_SUPPORTED = 26,      /* Subscription not supported by RIL */\n    RIL_E_SS_MODIFIED_TO_SS = 27,               /* SS request modified to different SS request */\n    RIL_E_LCE_NOT_SUPPORTED = 36,               /* LCE service not supported(36 in RILConstants.java) */\n    RIL_E_NO_MEMORY = 37,                       /* Not sufficient memory to process the request */\n    RIL_E_INTERNAL_ERR = 38,                    /* Hit unexpected vendor internal error scenario */\n    RIL_E_SYSTEM_ERR = 39,                      /* Hit platform or system error */\n    RIL_E_MODEM_ERR = 40,                       /* Hit unexpected modem error */\n    RIL_E_INVALID_STATE = 41,                   /* Unexpected request for the current state */\n    RIL_E_NO_RESOURCES = 42,                    /* Not sufficient resource to process the request */\n    RIL_E_SIM_ERR = 43,                         /* Received error from SIM card */\n    RIL_E_INVALID_ARGUMENTS = 44,               /* Received invalid arguments in request */\n    RIL_E_INVALID_SIM_STATE = 45,               /* Can not process the request in current SIM state */\n    RIL_E_INVALID_MODEM_STATE = 46,             /* Can not process the request in current Modem state */\n    RIL_E_INVALID_CALL_ID = 47,                 /* Received invalid call id in request */\n    RIL_E_NO_SMS_TO_ACK = 48,                   /* ACK received when there is no SMS to ack */\n    RIL_E_NETWORK_ERR = 49,                     /* Received error from network */\n    RIL_E_REQUEST_RATE_LIMITED = 50,            /* Operation denied due to overly-frequent requests */\n    RIL_E_SIM_BUSY = 51,                        /* SIM is busy */\n    RIL_E_SIM_FULL = 52,                        /* The target EF is full */\n    RIL_E_NETWORK_REJECT = 53,                  /* Request is rejected by network */\n    RIL_E_OPERATION_NOT_ALLOWED = 54,           /* Not allowed the request now */\n    RIL_E_EMPTY_RECORD = 55,                    /* The request record is empty */\n    RIL_E_INVALID_SMS_FORMAT = 56,              /* Invalid sms format */\n    RIL_E_ENCODING_ERR = 57,                    /* Message not encoded properly */\n    RIL_E_INVALID_SMSC_ADDRESS = 58,            /* SMSC address specified is invalid */\n    RIL_E_NO_SUCH_ENTRY = 59,                   /* No such entry present to perform the request */\n    RIL_E_NETWORK_NOT_READY = 60,               /* Network is not ready to perform the request */\n    RIL_E_NOT_PROVISIONED = 61,                 /* Device doesnot have this value provisioned */\n    RIL_E_NO_SUBSCRIPTION = 62,                 /* Device doesnot have subscription */\n    RIL_E_NO_NETWORK_FOUND = 63,                /* Network cannot be found */\n    RIL_E_DEVICE_IN_USE = 64,                   /* Operation cannot be performed because the device\n                                                   is currently in use */\n    RIL_E_ABORTED = 65,                         /* Operation aborted */\n    // OEM specific error codes. To be used by OEM when they don't want to reveal\n    // specific error codes which would be replaced by Generic failure.\n    RIL_E_OEM_ERROR_1 = 501,\n    RIL_E_OEM_ERROR_2 = 502,\n    RIL_E_OEM_ERROR_3 = 503,\n    RIL_E_OEM_ERROR_4 = 504,\n    RIL_E_OEM_ERROR_5 = 505,\n    RIL_E_OEM_ERROR_6 = 506,\n    RIL_E_OEM_ERROR_7 = 507,\n    RIL_E_OEM_ERROR_8 = 508,\n    RIL_E_OEM_ERROR_9 = 509,\n    RIL_E_OEM_ERROR_10 = 510,\n    RIL_E_OEM_ERROR_11 = 511,\n    RIL_E_OEM_ERROR_12 = 512,\n    RIL_E_OEM_ERROR_13 = 513,\n    RIL_E_OEM_ERROR_14 = 514,\n    RIL_E_OEM_ERROR_15 = 515,\n    RIL_E_OEM_ERROR_16 = 516,\n    RIL_E_OEM_ERROR_17 = 517,\n    RIL_E_OEM_ERROR_18 = 518,\n    RIL_E_OEM_ERROR_19 = 519,\n    RIL_E_OEM_ERROR_20 = 520,\n    RIL_E_OEM_ERROR_21 = 521,\n    RIL_E_OEM_ERROR_22 = 522,\n    RIL_E_OEM_ERROR_23 = 523,\n    RIL_E_OEM_ERROR_24 = 524,\n    RIL_E_OEM_ERROR_25 = 525\n} RIL_Errno;\n\ntypedef enum {\n    RIL_CALL_ACTIVE = 0,\n    RIL_CALL_HOLDING = 1,\n    RIL_CALL_DIALING = 2,    /* MO call only */\n    RIL_CALL_ALERTING = 3,   /* MO call only */\n    RIL_CALL_INCOMING = 4,   /* MT call only */\n    RIL_CALL_WAITING = 5     /* MT call only */\n} RIL_CallState;\n\ntypedef enum {\n    RADIO_STATE_OFF = 0,                   /* Radio explictly powered off (eg CFUN=0) */\n    RADIO_STATE_UNAVAILABLE = 1,           /* Radio unavailable (eg, resetting or not booted) */\n    /* States 2-9 below are deprecated. Just leaving them here for backward compatibility. */\n    RADIO_STATE_SIM_NOT_READY = 2,         /* Radio is on, but the SIM interface is not ready */\n    RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3,  /* SIM PIN locked, PUK required, network\n                                              personalization locked, or SIM absent */\n    RADIO_STATE_SIM_READY = 4,             /* Radio is on and SIM interface is available */\n    RADIO_STATE_RUIM_NOT_READY = 5,        /* Radio is on, but the RUIM interface is not ready */\n    RADIO_STATE_RUIM_READY = 6,            /* Radio is on and the RUIM interface is available */\n    RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7, /* RUIM PIN locked, PUK required, network\n                                              personalization locked, or RUIM absent */\n    RADIO_STATE_NV_NOT_READY = 8,          /* Radio is on, but the NV interface is not available */\n    RADIO_STATE_NV_READY = 9,              /* Radio is on and the NV interface is available */\n    RADIO_STATE_ON = 10                    /* Radio is on */\n} RIL_RadioState;\n\ntypedef enum {\n    RADIO_TECH_UNKNOWN = 0,\n    RADIO_TECH_GPRS = 1,\n    RADIO_TECH_EDGE = 2,\n    RADIO_TECH_UMTS = 3,\n    RADIO_TECH_IS95A = 4,\n    RADIO_TECH_IS95B = 5,\n    RADIO_TECH_1xRTT =  6,\n    RADIO_TECH_EVDO_0 = 7,\n    RADIO_TECH_EVDO_A = 8,\n    RADIO_TECH_HSDPA = 9,\n    RADIO_TECH_HSUPA = 10,\n    RADIO_TECH_HSPA = 11,\n    RADIO_TECH_EVDO_B = 12,\n    RADIO_TECH_EHRPD = 13,\n    RADIO_TECH_LTE = 14,\n    RADIO_TECH_HSPAP = 15, // HSPA+\n    RADIO_TECH_GSM = 16, // Only supports voice\n    RADIO_TECH_TD_SCDMA = 17,\n    RADIO_TECH_IWLAN = 18,\n    RADIO_TECH_LTE_CA = 19\n} RIL_RadioTechnology;\n\ntypedef enum {\n    RAF_UNKNOWN =  (1 <<  RADIO_TECH_UNKNOWN),\n    RAF_GPRS = (1 << RADIO_TECH_GPRS),\n    RAF_EDGE = (1 << RADIO_TECH_EDGE),\n    RAF_UMTS = (1 << RADIO_TECH_UMTS),\n    RAF_IS95A = (1 << RADIO_TECH_IS95A),\n    RAF_IS95B = (1 << RADIO_TECH_IS95B),\n    RAF_1xRTT = (1 << RADIO_TECH_1xRTT),\n    RAF_EVDO_0 = (1 << RADIO_TECH_EVDO_0),\n    RAF_EVDO_A = (1 << RADIO_TECH_EVDO_A),\n    RAF_HSDPA = (1 << RADIO_TECH_HSDPA),\n    RAF_HSUPA = (1 << RADIO_TECH_HSUPA),\n    RAF_HSPA = (1 << RADIO_TECH_HSPA),\n    RAF_EVDO_B = (1 << RADIO_TECH_EVDO_B),\n    RAF_EHRPD = (1 << RADIO_TECH_EHRPD),\n    RAF_LTE = (1 << RADIO_TECH_LTE),\n    RAF_HSPAP = (1 << RADIO_TECH_HSPAP),\n    RAF_GSM = (1 << RADIO_TECH_GSM),\n    RAF_TD_SCDMA = (1 << RADIO_TECH_TD_SCDMA),\n    RAF_LTE_CA = (1 << RADIO_TECH_LTE_CA)\n} RIL_RadioAccessFamily;\n\ntypedef enum {\n    BAND_MODE_UNSPECIFIED = 0,      //\"unspecified\" (selected by baseband automatically)\n    BAND_MODE_EURO = 1,             //\"EURO band\" (GSM-900 / DCS-1800 / WCDMA-IMT-2000)\n    BAND_MODE_USA = 2,              //\"US band\" (GSM-850 / PCS-1900 / WCDMA-850 / WCDMA-PCS-1900)\n    BAND_MODE_JPN = 3,              //\"JPN band\" (WCDMA-800 / WCDMA-IMT-2000)\n    BAND_MODE_AUS = 4,              //\"AUS band\" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000)\n    BAND_MODE_AUS_2 = 5,            //\"AUS band 2\" (GSM-900 / DCS-1800 / WCDMA-850)\n    BAND_MODE_CELL_800 = 6,         //\"Cellular\" (800-MHz Band)\n    BAND_MODE_PCS = 7,              //\"PCS\" (1900-MHz Band)\n    BAND_MODE_JTACS = 8,            //\"Band Class 3\" (JTACS Band)\n    BAND_MODE_KOREA_PCS = 9,        //\"Band Class 4\" (Korean PCS Band)\n    BAND_MODE_5_450M = 10,          //\"Band Class 5\" (450-MHz Band)\n    BAND_MODE_IMT2000 = 11,         //\"Band Class 6\" (2-GMHz IMT2000 Band)\n    BAND_MODE_7_700M_2 = 12,        //\"Band Class 7\" (Upper 700-MHz Band)\n    BAND_MODE_8_1800M = 13,         //\"Band Class 8\" (1800-MHz Band)\n    BAND_MODE_9_900M = 14,          //\"Band Class 9\" (900-MHz Band)\n    BAND_MODE_10_800M_2 = 15,       //\"Band Class 10\" (Secondary 800-MHz Band)\n    BAND_MODE_EURO_PAMR_400M = 16,  //\"Band Class 11\" (400-MHz European PAMR Band)\n    BAND_MODE_AWS = 17,             //\"Band Class 15\" (AWS Band)\n    BAND_MODE_USA_2500M = 18        //\"Band Class 16\" (US 2.5-GHz Band)\n} RIL_RadioBandMode;\n\ntypedef enum {\n    RC_PHASE_CONFIGURED = 0,  // LM is configured is initial value and value after FINISH completes\n    RC_PHASE_START      = 1,  // START is sent before Apply and indicates that an APPLY will be\n                              // forthcoming with these same parameters\n    RC_PHASE_APPLY      = 2,  // APPLY is sent after all LM's receive START and returned\n                              // RIL_RadioCapability.status = 0, if any START's fail no\n                              // APPLY will be sent\n    RC_PHASE_UNSOL_RSP  = 3,  // UNSOL_RSP is sent with RIL_UNSOL_RADIO_CAPABILITY\n    RC_PHASE_FINISH     = 4   // FINISH is sent after all commands have completed. If an error\n                              // occurs in any previous command the RIL_RadioAccessesFamily and\n                              // logicalModemUuid fields will be the prior configuration thus\n                              // restoring the configuration to the previous value. An error\n                              // returned by this command will generally be ignored or may\n                              // cause that logical modem to be removed from service.\n} RadioCapabilityPhase;\n\ntypedef enum {\n    RC_STATUS_NONE       = 0, // This parameter has no meaning with RC_PHASE_START,\n                              // RC_PHASE_APPLY\n    RC_STATUS_SUCCESS    = 1, // Tell modem the action transaction of set radio\n                              // capability was success with RC_PHASE_FINISH\n    RC_STATUS_FAIL       = 2, // Tell modem the action transaction of set radio\n                              // capability is fail with RC_PHASE_FINISH.\n} RadioCapabilityStatus;\n\n#define RIL_RADIO_CAPABILITY_VERSION 1\ntypedef struct {\n    int version;            // Version of structure, RIL_RADIO_CAPABILITY_VERSION\n    int session;            // Unique session value defined by framework returned in all \"responses/unsol\"\n    int phase;              // CONFIGURED, START, APPLY, FINISH\n    int rat;                // RIL_RadioAccessFamily for the radio\n    char logicalModemUuid[MAX_UUID_LENGTH]; // A UUID typically \"com.xxxx.lmX where X is the logical modem.\n    int status;             // Return status and an input parameter for RC_PHASE_FINISH\n} RIL_RadioCapability;\n\n// Do we want to split Data from Voice and the use\n// RIL_RadioTechnology for get/setPreferredVoice/Data ?\ntypedef enum {\n    PREF_NET_TYPE_GSM_WCDMA                = 0, /* GSM/WCDMA (WCDMA preferred) */\n    PREF_NET_TYPE_GSM_ONLY                 = 1, /* GSM only */\n    PREF_NET_TYPE_WCDMA                    = 2, /* WCDMA  */\n    PREF_NET_TYPE_GSM_WCDMA_AUTO           = 3, /* GSM/WCDMA (auto mode, according to PRL) */\n    PREF_NET_TYPE_CDMA_EVDO_AUTO           = 4, /* CDMA and EvDo (auto mode, according to PRL) */\n    PREF_NET_TYPE_CDMA_ONLY                = 5, /* CDMA only */\n    PREF_NET_TYPE_EVDO_ONLY                = 6, /* EvDo only */\n    PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7, /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL) */\n    PREF_NET_TYPE_LTE_CDMA_EVDO            = 8, /* LTE, CDMA and EvDo */\n    PREF_NET_TYPE_LTE_GSM_WCDMA            = 9, /* LTE, GSM/WCDMA */\n    PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA  = 10, /* LTE, CDMA, EvDo, GSM/WCDMA */\n    PREF_NET_TYPE_LTE_ONLY                 = 11, /* LTE only */\n    PREF_NET_TYPE_LTE_WCDMA                = 12,  /* LTE/WCDMA */\n    PREF_NET_TYPE_TD_SCDMA_ONLY            = 13, /* TD-SCDMA only */\n    PREF_NET_TYPE_TD_SCDMA_WCDMA           = 14, /* TD-SCDMA and WCDMA */\n    PREF_NET_TYPE_TD_SCDMA_LTE             = 15, /* TD-SCDMA and LTE */\n    PREF_NET_TYPE_TD_SCDMA_GSM             = 16, /* TD-SCDMA and GSM */\n    PREF_NET_TYPE_TD_SCDMA_GSM_LTE         = 17, /* TD-SCDMA,GSM and LTE */\n    PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA       = 18, /* TD-SCDMA, GSM/WCDMA */\n    PREF_NET_TYPE_TD_SCDMA_WCDMA_LTE       = 19, /* TD-SCDMA, WCDMA and LTE */\n    PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_LTE   = 20, /* TD-SCDMA, GSM/WCDMA and LTE */\n    PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_CDMA_EVDO_AUTO  = 21, /* TD-SCDMA, GSM/WCDMA, CDMA and EvDo */\n    PREF_NET_TYPE_TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA   = 22  /* TD-SCDMA, LTE, CDMA, EvDo GSM/WCDMA */\n} RIL_PreferredNetworkType;\n\n/* Source for cdma subscription */\ntypedef enum {\n   CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM = 0,\n   CDMA_SUBSCRIPTION_SOURCE_NV = 1\n} RIL_CdmaSubscriptionSource;\n\n/* User-to-User signaling Info activation types derived from 3GPP 23.087 v8.0 */\ntypedef enum {\n    RIL_UUS_TYPE1_IMPLICIT = 0,\n    RIL_UUS_TYPE1_REQUIRED = 1,\n    RIL_UUS_TYPE1_NOT_REQUIRED = 2,\n    RIL_UUS_TYPE2_REQUIRED = 3,\n    RIL_UUS_TYPE2_NOT_REQUIRED = 4,\n    RIL_UUS_TYPE3_REQUIRED = 5,\n    RIL_UUS_TYPE3_NOT_REQUIRED = 6\n} RIL_UUS_Type;\n\n/* User-to-User Signaling Information data coding schemes. Possible values for\n * Octet 3 (Protocol Discriminator field) in the UUIE. The values have been\n * specified in section 10.5.4.25 of 3GPP TS 24.008 */\ntypedef enum {\n    RIL_UUS_DCS_USP = 0,          /* User specified protocol */\n    RIL_UUS_DCS_OSIHLP = 1,       /* OSI higher layer protocol */\n    RIL_UUS_DCS_X244 = 2,         /* X.244 */\n    RIL_UUS_DCS_RMCF = 3,         /* Reserved for system mangement\n                                     convergence function */\n    RIL_UUS_DCS_IA5c = 4          /* IA5 characters */\n} RIL_UUS_DCS;\n\n/* User-to-User Signaling Information defined in 3GPP 23.087 v8.0\n * This data is passed in RIL_ExtensionRecord and rec contains this\n * structure when type is RIL_UUS_INFO_EXT_REC */\ntypedef struct {\n  RIL_UUS_Type    uusType;    /* UUS Type */\n  RIL_UUS_DCS     uusDcs;     /* UUS Data Coding Scheme */\n  int             uusLength;  /* Length of UUS Data */\n  char *          uusData;    /* UUS Data */\n} RIL_UUS_Info;\n\n/* CDMA Signal Information Record as defined in C.S0005 section 3.7.5.5 */\ntypedef struct {\n  char isPresent;    /* non-zero if signal information record is present */\n  char signalType;   /* as defined 3.7.5.5-1 */\n  char alertPitch;   /* as defined 3.7.5.5-2 */\n  char signal;       /* as defined 3.7.5.5-3, 3.7.5.5-4 or 3.7.5.5-5 */\n} RIL_CDMA_SignalInfoRecord;\n\ntypedef struct {\n    RIL_CallState   state;\n    int             index;      /* Connection Index for use with, eg, AT+CHLD */\n    int             toa;        /* type of address, eg 145 = intl */\n    char            isMpty;     /* nonzero if is mpty call */\n    char            isMT;       /* nonzero if call is mobile terminated */\n    char            als;        /* ALS line indicator if available\n                                   (0 = line 1) */\n    char            isVoice;    /* nonzero if this is is a voice call */\n    char            isVoicePrivacy;     /* nonzero if CDMA voice privacy mode is active */\n    char *          number;     /* Remote party number */\n    int             numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */\n    char *          name;       /* Remote party name */\n    int             namePresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */\n    RIL_UUS_Info *  uusInfo;    /* NULL or Pointer to User-User Signaling Information */\n} RIL_Call;\n\n/* Deprecated, use RIL_Data_Call_Response_v6 */\ntypedef struct {\n    int             cid;        /* Context ID, uniquely identifies this call */\n    int             active;     /* 0=inactive, 1=active/physical link down, 2=active/physical link up */\n    char *          type;       /* One of the PDP_type values in TS 27.007 section 10.1.1.\n                                   For example, \"IP\", \"IPV6\", \"IPV4V6\", or \"PPP\". */\n    char *          apn;        /* ignored */\n    char *          address;    /* An address, e.g., \"192.0.1.3\" or \"2001:db8::1\". */\n} RIL_Data_Call_Response_v4;\n\n/*\n * Returned by RIL_REQUEST_SETUP_DATA_CALL, RIL_REQUEST_DATA_CALL_LIST\n * and RIL_UNSOL_DATA_CALL_LIST_CHANGED, on error status != 0.\n */\ntypedef struct {\n    int             status;     /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */\n    int             suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry\n                                           back-off timer value RIL wants to override the one\n                                           pre-configured in FW.\n                                           The unit is miliseconds.\n                                           The value < 0 means no value is suggested.\n                                           The value 0 means retry should be done ASAP.\n                                           The value of INT_MAX(0x7fffffff) means no retry. */\n    int             cid;        /* Context ID, uniquely identifies this call */\n    int             active;     /* 0=inactive, 1=active/physical link down, 2=active/physical link up */\n    char *          type;       /* One of the PDP_type values in TS 27.007 section 10.1.1.\n                                   For example, \"IP\", \"IPV6\", \"IPV4V6\", or \"PPP\". If status is\n                                   PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported\n                                   such as \"IP\" or \"IPV6\" */\n    char *          ifname;     /* The network interface name */\n    char *          addresses;  /* A space-delimited list of addresses with optional \"/\" prefix length,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11/16 2001:db8::1/64\".\n                                   May not be empty, typically 1 IPv4 or 1 IPv6 or\n                                   one of each. If the prefix length is absent the addresses\n                                   are assumed to be point to point with IPv4 having a prefix\n                                   length of 32 and IPv6 128. */\n    char *          dnses;      /* A space-delimited list of DNS server addresses,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11 2001:db8::1\".\n                                   May be empty. */\n    char *          gateways;   /* A space-delimited list of default gateway addresses,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11 2001:db8::1\".\n                                   May be empty in which case the addresses represent point\n                                   to point connections. */\n} RIL_Data_Call_Response_v6;\n\ntypedef struct {\n    int             status;     /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */\n    int             suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry\n                                           back-off timer value RIL wants to override the one\n                                           pre-configured in FW.\n                                           The unit is miliseconds.\n                                           The value < 0 means no value is suggested.\n                                           The value 0 means retry should be done ASAP.\n                                           The value of INT_MAX(0x7fffffff) means no retry. */\n    int             cid;        /* Context ID, uniquely identifies this call */\n    int             active;     /* 0=inactive, 1=active/physical link down, 2=active/physical link up */\n    char *          type;       /* One of the PDP_type values in TS 27.007 section 10.1.1.\n                                   For example, \"IP\", \"IPV6\", \"IPV4V6\", or \"PPP\". If status is\n                                   PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported\n                                   such as \"IP\" or \"IPV6\" */\n    char *          ifname;     /* The network interface name */\n    char *          addresses;  /* A space-delimited list of addresses with optional \"/\" prefix length,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11/16 2001:db8::1/64\".\n                                   May not be empty, typically 1 IPv4 or 1 IPv6 or\n                                   one of each. If the prefix length is absent the addresses\n                                   are assumed to be point to point with IPv4 having a prefix\n                                   length of 32 and IPv6 128. */\n    char *          dnses;      /* A space-delimited list of DNS server addresses,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11 2001:db8::1\".\n                                   May be empty. */\n    char *          gateways;   /* A space-delimited list of default gateway addresses,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11 2001:db8::1\".\n                                   May be empty in which case the addresses represent point\n                                   to point connections. */\n    char *          pcscf;    /* the Proxy Call State Control Function address\n                                 via PCO(Protocol Configuration Option) for IMS client. */\n} RIL_Data_Call_Response_v9;\n\ntypedef struct {\n    int             status;     /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */\n    int             suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry\n                                           back-off timer value RIL wants to override the one\n                                           pre-configured in FW.\n                                           The unit is miliseconds.\n                                           The value < 0 means no value is suggested.\n                                           The value 0 means retry should be done ASAP.\n                                           The value of INT_MAX(0x7fffffff) means no retry. */\n    int             cid;        /* Context ID, uniquely identifies this call */\n    int             active;     /* 0=inactive, 1=active/physical link down, 2=active/physical link up */\n    char *          type;       /* One of the PDP_type values in TS 27.007 section 10.1.1.\n                                   For example, \"IP\", \"IPV6\", \"IPV4V6\", or \"PPP\". If status is\n                                   PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported\n                                   such as \"IP\" or \"IPV6\" */\n    char *          ifname;     /* The network interface name */\n    char *          addresses;  /* A space-delimited list of addresses with optional \"/\" prefix length,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11/16 2001:db8::1/64\".\n                                   May not be empty, typically 1 IPv4 or 1 IPv6 or\n                                   one of each. If the prefix length is absent the addresses\n                                   are assumed to be point to point with IPv4 having a prefix\n                                   length of 32 and IPv6 128. */\n    char *          dnses;      /* A space-delimited list of DNS server addresses,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11 2001:db8::1\".\n                                   May be empty. */\n    char *          gateways;   /* A space-delimited list of default gateway addresses,\n                                   e.g., \"192.0.1.3\" or \"192.0.1.11 2001:db8::1\".\n                                   May be empty in which case the addresses represent point\n                                   to point connections. */\n    char *          pcscf;    /* the Proxy Call State Control Function address\n                                 via PCO(Protocol Configuration Option) for IMS client. */\n    int             mtu;        /* MTU received from network\n                                   Value <= 0 means network has either not sent a value or\n                                   sent an invalid value */\n} RIL_Data_Call_Response_v11;\n\ntypedef enum {\n    RADIO_TECH_3GPP = 1, /* 3GPP Technologies - GSM, WCDMA */\n    RADIO_TECH_3GPP2 = 2 /* 3GPP2 Technologies - CDMA */\n} RIL_RadioTechnologyFamily;\n\ntypedef struct {\n    RIL_RadioTechnologyFamily tech;\n    unsigned char             retry;       /* 0 == not retry, nonzero == retry */\n    int                       messageRef;  /* Valid field if retry is set to nonzero.\n                                              Contains messageRef from RIL_SMS_Response\n                                              corresponding to failed MO SMS.\n                                            */\n\n    union {\n        /* Valid field if tech is RADIO_TECH_3GPP2. See RIL_REQUEST_CDMA_SEND_SMS */\n        RIL_CDMA_SMS_Message* cdmaMessage;\n\n        /* Valid field if tech is RADIO_TECH_3GPP. See RIL_REQUEST_SEND_SMS */\n        char**                gsmMessage;   /* This is an array of pointers where pointers\n                                               are contiguous but elements pointed by those pointers\n                                               are not contiguous\n                                            */\n    } message;\n} RIL_IMS_SMS_Message;\n\ntypedef struct {\n    int messageRef;   /* TP-Message-Reference for GSM,\n                         and BearerData MessageId for CDMA\n                         (See 3GPP2 C.S0015-B, v2.0, table 4.5-1). */\n    char *ackPDU;     /* or NULL if n/a */\n    int errorCode;    /* See 3GPP 27.005, 3.2.5 for GSM/UMTS,\n                         3GPP2 N.S0005 (IS-41C) Table 171 for CDMA,\n                         -1 if unknown or not applicable*/\n} RIL_SMS_Response;\n\n/** Used by RIL_REQUEST_WRITE_SMS_TO_SIM */\ntypedef struct {\n    int status;     /* Status of message.  See TS 27.005 3.1, \"<stat>\": */\n                    /*      0 = \"REC UNREAD\"    */\n                    /*      1 = \"REC READ\"      */\n                    /*      2 = \"STO UNSENT\"    */\n                    /*      3 = \"STO SENT\"      */\n    char * pdu;     /* PDU of message to write, as an ASCII hex string less the SMSC address,\n                       the TP-layer length is \"strlen(pdu)/2\". */\n    char * smsc;    /* SMSC address in GSM BCD format prefixed by a length byte\n                       (as expected by TS 27.005) or NULL for default SMSC */\n} RIL_SMS_WriteArgs;\n\n/** Used by RIL_REQUEST_DIAL */\ntypedef struct {\n    char * address;\n    int clir;\n            /* (same as 'n' paremeter in TS 27.007 7.7 \"+CLIR\"\n             * clir == 0 on \"use subscription default value\"\n             * clir == 1 on \"CLIR invocation\" (restrict CLI presentation)\n             * clir == 2 on \"CLIR suppression\" (allow CLI presentation)\n             */\n    RIL_UUS_Info *  uusInfo;    /* NULL or Pointer to User-User Signaling Information */\n} RIL_Dial;\n\ntypedef struct {\n    int unknown;\n    int command;    /* one of the commands listed for TS 27.007 +CRSM*/\n    int fileid;     /* EF id */\n    char *path;     /* \"pathid\" from TS 27.007 +CRSM command.\n                       Path is in hex asciii format eg \"7f205f70\"\n                       Path must always be provided.\n                     */\n    int p1;\n    int p2;\n    int p3;\n    char *data;     /* May be NULL*/\n    char *pin2;     /* May be NULL*/\n} RIL_SIM_IO_v5;\n\ntypedef struct {\n    int unknown;\n    int command;    /* one of the commands listed for TS 27.007 +CRSM*/\n    int fileid;     /* EF id */\n    char *path;     /* \"pathid\" from TS 27.007 +CRSM command.\n                       Path is in hex asciii format eg \"7f205f70\"\n                       Path must always be provided.\n                     */\n    int p1;\n    int p2;\n    int p3;\n    char *data;     /* May be NULL*/\n    char *pin2;     /* May be NULL*/\n    char *aidPtr;   /* AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. */\n} RIL_SIM_IO_v6;\n\n/* Used by RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL and\n * RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC. */\ntypedef struct {\n    int sessionid;  /* \"sessionid\" from TS 27.007 +CGLA command. Should be\n                       ignored for +CSIM command. */\n\n    /* Following fields are used to derive the APDU (\"command\" and \"length\"\n       values in TS 27.007 +CSIM and +CGLA commands). */\n    int cla;\n    int instruction;\n    int p1;\n    int p2;\n    int p3;         /* A negative P3 implies a 4 byte APDU. */\n    char *data;     /* May be NULL. In hex string format. */\n} RIL_SIM_APDU;\n\ntypedef struct {\n    int sw1;\n    int sw2;\n    char *simResponse;  /* In hex string format ([a-fA-F0-9]*), except for SIM_AUTHENTICATION\n                           response for which it is in Base64 format, see 3GPP TS 31.102 7.1.2 */\n} RIL_SIM_IO_Response;\n\n/* See also com.android.internal.telephony.gsm.CallForwardInfo */\n\ntypedef struct {\n    int             status;     /*\n                                 * For RIL_REQUEST_QUERY_CALL_FORWARD_STATUS\n                                 * status 1 = active, 0 = not active\n                                 *\n                                 * For RIL_REQUEST_SET_CALL_FORWARD:\n                                 * status is:\n                                 * 0 = disable\n                                 * 1 = enable\n                                 * 2 = interrogate\n                                 * 3 = registeration\n                                 * 4 = erasure\n                                 */\n\n    int             reason;      /* from TS 27.007 7.11 \"reason\" */\n    int             serviceClass;/* From 27.007 +CCFC/+CLCK \"class\"\n                                    See table for Android mapping from\n                                    MMI service code\n                                    0 means user doesn't input class */\n    int             toa;         /* \"type\" from TS 27.007 7.11 */\n    char *          number;      /* \"number\" from TS 27.007 7.11. May be NULL */\n    int             timeSeconds; /* for CF no reply only */\n}RIL_CallForwardInfo;\n\ntypedef struct {\n   char * cid;         /* Combination of LAC and Cell Id in 32 bits in GSM.\n                        * Upper 16 bits is LAC and lower 16 bits\n                        * is CID (as described in TS 27.005)\n                        * Primary Scrambling Code (as described in TS 25.331)\n                        *         in 9 bits in UMTS\n                        * Valid values are hexadecimal 0x0000 - 0xffffffff.\n                        */\n   int    rssi;        /* Received RSSI in GSM,\n                        * Level index of CPICH Received Signal Code Power in UMTS\n                        */\n} RIL_NeighboringCell;\n\ntypedef struct {\n  char lce_status;                 /* LCE service status:\n                                    * -1 = not supported;\n                                    * 0 = stopped;\n                                    * 1 = active.\n                                    */\n  unsigned int actual_interval_ms; /* actual LCE reporting interval,\n                                    * meaningful only if LCEStatus = 1.\n                                    */\n} RIL_LceStatusInfo;\n\ntypedef struct {\n  unsigned int last_hop_capacity_kbps; /* last-hop cellular capacity: kilobits/second. */\n  unsigned char confidence_level;      /* capacity estimate confidence: 0-100 */\n  unsigned char lce_suspended;         /* LCE report going to be suspended? (e.g., radio\n                                        * moves to inactive state or network type change)\n                                        * 1 = suspended;\n                                        * 0 = not suspended.\n                                        */\n} RIL_LceDataInfo;\n\ntypedef enum {\n    RIL_MATCH_ALL = 0,          /* Apply to all carriers with the same mcc/mnc */\n    RIL_MATCH_SPN = 1,          /* Use SPN and mcc/mnc to identify the carrier */\n    RIL_MATCH_IMSI_PREFIX = 2,  /* Use IMSI prefix and mcc/mnc to identify the carrier */\n    RIL_MATCH_GID1 = 3,         /* Use GID1 and mcc/mnc to identify the carrier */\n    RIL_MATCH_GID2 = 4,         /* Use GID2 and mcc/mnc to identify the carrier */\n} RIL_CarrierMatchType;\n\ntypedef struct {\n    const char * mcc;\n    const char * mnc;\n    RIL_CarrierMatchType match_type;   /* Specify match type for the carrier.\n                                        * If it’s RIL_MATCH_ALL, match_data is null;\n                                        * otherwise, match_data is the value for the match type.\n                                        */\n    const char * match_data;\n} RIL_Carrier;\n\ntypedef struct {\n  int32_t len_allowed_carriers;         /* length of array allowed_carriers */\n  int32_t len_excluded_carriers;        /* length of array excluded_carriers */\n  RIL_Carrier * allowed_carriers;       /* whitelist for allowed carriers */\n  RIL_Carrier * excluded_carriers;      /* blacklist for explicitly excluded carriers\n                                         * which match allowed_carriers. Eg. allowed_carriers match\n                                         * mcc/mnc, excluded_carriers has same mcc/mnc and gid1\n                                         * is ABCD. It means except the carrier whose gid1 is ABCD,\n                                         * all carriers with the same mcc/mnc are allowed.\n                                         */\n} RIL_CarrierRestrictions;\n\n/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */\ntypedef enum {\n    CALL_FAIL_UNOBTAINABLE_NUMBER = 1,\n    CALL_FAIL_NO_ROUTE_TO_DESTINATION = 3,\n    CALL_FAIL_CHANNEL_UNACCEPTABLE = 6,\n    CALL_FAIL_OPERATOR_DETERMINED_BARRING = 8,\n    CALL_FAIL_NORMAL = 16,\n    CALL_FAIL_BUSY = 17,\n    CALL_FAIL_NO_USER_RESPONDING = 18,\n    CALL_FAIL_NO_ANSWER_FROM_USER = 19,\n    CALL_FAIL_CALL_REJECTED = 21,\n    CALL_FAIL_NUMBER_CHANGED = 22,\n    CALL_FAIL_PREEMPTION = 25,\n    CALL_FAIL_DESTINATION_OUT_OF_ORDER = 27,\n    CALL_FAIL_INVALID_NUMBER_FORMAT = 28,\n    CALL_FAIL_FACILITY_REJECTED = 29,\n    CALL_FAIL_RESP_TO_STATUS_ENQUIRY = 30,\n    CALL_FAIL_NORMAL_UNSPECIFIED = 31,\n    CALL_FAIL_CONGESTION = 34,\n    CALL_FAIL_NETWORK_OUT_OF_ORDER = 38,\n    CALL_FAIL_TEMPORARY_FAILURE = 41,\n    CALL_FAIL_SWITCHING_EQUIPMENT_CONGESTION = 42,\n    CALL_FAIL_ACCESS_INFORMATION_DISCARDED = 43,\n    CALL_FAIL_REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE = 44,\n    CALL_FAIL_RESOURCES_UNAVAILABLE_OR_UNSPECIFIED = 47,\n    CALL_FAIL_QOS_UNAVAILABLE = 49,\n    CALL_FAIL_REQUESTED_FACILITY_NOT_SUBSCRIBED = 50,\n    CALL_FAIL_INCOMING_CALLS_BARRED_WITHIN_CUG = 55,\n    CALL_FAIL_BEARER_CAPABILITY_NOT_AUTHORIZED = 57,\n    CALL_FAIL_BEARER_CAPABILITY_UNAVAILABLE = 58,\n    CALL_FAIL_SERVICE_OPTION_NOT_AVAILABLE = 63,\n    CALL_FAIL_BEARER_SERVICE_NOT_IMPLEMENTED = 65,\n    CALL_FAIL_ACM_LIMIT_EXCEEDED = 68,\n    CALL_FAIL_REQUESTED_FACILITY_NOT_IMPLEMENTED = 69,\n    CALL_FAIL_ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE = 70,\n    CALL_FAIL_SERVICE_OR_OPTION_NOT_IMPLEMENTED = 79,\n    CALL_FAIL_INVALID_TRANSACTION_IDENTIFIER = 81,\n    CALL_FAIL_USER_NOT_MEMBER_OF_CUG = 87,\n    CALL_FAIL_INCOMPATIBLE_DESTINATION = 88,\n    CALL_FAIL_INVALID_TRANSIT_NW_SELECTION = 91,\n    CALL_FAIL_SEMANTICALLY_INCORRECT_MESSAGE = 95,\n    CALL_FAIL_INVALID_MANDATORY_INFORMATION = 96,\n    CALL_FAIL_MESSAGE_TYPE_NON_IMPLEMENTED = 97,\n    CALL_FAIL_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 98,\n    CALL_FAIL_INFORMATION_ELEMENT_NON_EXISTENT = 99,\n    CALL_FAIL_CONDITIONAL_IE_ERROR = 100,\n    CALL_FAIL_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 101,\n    CALL_FAIL_RECOVERY_ON_TIMER_EXPIRED = 102,\n    CALL_FAIL_PROTOCOL_ERROR_UNSPECIFIED = 111,\n    CALL_FAIL_INTERWORKING_UNSPECIFIED = 127,\n    CALL_FAIL_CALL_BARRED = 240,\n    CALL_FAIL_FDN_BLOCKED = 241,\n    CALL_FAIL_IMSI_UNKNOWN_IN_VLR = 242,\n    CALL_FAIL_IMEI_NOT_ACCEPTED = 243,\n    CALL_FAIL_DIAL_MODIFIED_TO_USSD = 244, /* STK Call Control */\n    CALL_FAIL_DIAL_MODIFIED_TO_SS = 245,\n    CALL_FAIL_DIAL_MODIFIED_TO_DIAL = 246,\n    CALL_FAIL_CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000,\n    CALL_FAIL_CDMA_DROP = 1001,\n    CALL_FAIL_CDMA_INTERCEPT = 1002,\n    CALL_FAIL_CDMA_REORDER = 1003,\n    CALL_FAIL_CDMA_SO_REJECT = 1004,\n    CALL_FAIL_CDMA_RETRY_ORDER = 1005,\n    CALL_FAIL_CDMA_ACCESS_FAILURE = 1006,\n    CALL_FAIL_CDMA_PREEMPTED = 1007,\n    CALL_FAIL_CDMA_NOT_EMERGENCY = 1008, /* For non-emergency number dialed\n                                            during emergency callback mode */\n    CALL_FAIL_CDMA_ACCESS_BLOCKED = 1009, /* CDMA network access probes blocked */\n    CALL_FAIL_ERROR_UNSPECIFIED = 0xffff /* This error will be deprecated soon,\n                                            vendor code should make sure to map error\n                                            code to specific error */\n} RIL_LastCallFailCause;\n\ntypedef struct {\n  RIL_LastCallFailCause cause_code;\n  char *                vendor_cause;\n} RIL_LastCallFailCauseInfo;\n\n/* See RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE */\ntypedef enum {\n    PDP_FAIL_NONE = 0, /* No error, connection ok */\n\n    /* an integer cause code defined in TS 24.008\n       section 6.1.3.1.3 or TS 24.301 Release 8+ Annex B.\n       If the implementation does not have access to the exact cause codes,\n       then it should return one of the following values,\n       as the UI layer needs to distinguish these\n       cases for error notification and potential retries. */\n    PDP_FAIL_OPERATOR_BARRED = 0x08,               /* no retry */\n    PDP_FAIL_NAS_SIGNALLING = 0x0E,\n    PDP_FAIL_LLC_SNDCP = 0x19,\n    PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A,\n    PDP_FAIL_MISSING_UKNOWN_APN = 0x1B,            /* no retry */\n    PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C,      /* no retry */\n    PDP_FAIL_USER_AUTHENTICATION = 0x1D,           /* no retry */\n    PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E,        /* no retry */\n    PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F,\n    PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20,  /* no retry */\n    PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21, /* no retry */\n    PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22,\n    PDP_FAIL_NSAPI_IN_USE = 0x23,                  /* no retry */\n    PDP_FAIL_REGULAR_DEACTIVATION = 0x24,          /* possibly restart radio,\n                                                      based on framework config */\n    PDP_FAIL_QOS_NOT_ACCEPTED = 0x25,\n    PDP_FAIL_NETWORK_FAILURE = 0x26,\n    PDP_FAIL_UMTS_REACTIVATION_REQ = 0x27,\n    PDP_FAIL_FEATURE_NOT_SUPP = 0x28,\n    PDP_FAIL_TFT_SEMANTIC_ERROR = 0x29,\n    PDP_FAIL_TFT_SYTAX_ERROR = 0x2A,\n    PDP_FAIL_UNKNOWN_PDP_CONTEXT = 0x2B,\n    PDP_FAIL_FILTER_SEMANTIC_ERROR = 0x2C,\n    PDP_FAIL_FILTER_SYTAX_ERROR = 0x2D,\n    PDP_FAIL_PDP_WITHOUT_ACTIVE_TFT = 0x2E,\n    PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32,             /* no retry */\n    PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33,             /* no retry */\n    PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34,\n    PDP_FAIL_ESM_INFO_NOT_RECEIVED = 0x35,\n    PDP_FAIL_PDN_CONN_DOES_NOT_EXIST = 0x36,\n    PDP_FAIL_MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED = 0x37,\n    PDP_FAIL_MAX_ACTIVE_PDP_CONTEXT_REACHED = 0x41,\n    PDP_FAIL_UNSUPPORTED_APN_IN_CURRENT_PLMN = 0x42,\n    PDP_FAIL_INVALID_TRANSACTION_ID = 0x51,\n    PDP_FAIL_MESSAGE_INCORRECT_SEMANTIC = 0x5F,\n    PDP_FAIL_INVALID_MANDATORY_INFO = 0x60,\n    PDP_FAIL_MESSAGE_TYPE_UNSUPPORTED = 0x61,\n    PDP_FAIL_MSG_TYPE_NONCOMPATIBLE_STATE = 0x62,\n    PDP_FAIL_UNKNOWN_INFO_ELEMENT = 0x63,\n    PDP_FAIL_CONDITIONAL_IE_ERROR = 0x64,\n    PDP_FAIL_MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE = 0x65,\n    PDP_FAIL_PROTOCOL_ERRORS = 0x6F,             /* no retry */\n    PDP_FAIL_APN_TYPE_CONFLICT = 0x70,\n    PDP_FAIL_INVALID_PCSCF_ADDR = 0x71,\n    PDP_FAIL_INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN = 0x72,\n    PDP_FAIL_EMM_ACCESS_BARRED = 0x73,\n    PDP_FAIL_EMERGENCY_IFACE_ONLY = 0x74,\n    PDP_FAIL_IFACE_MISMATCH = 0x75,\n    PDP_FAIL_COMPANION_IFACE_IN_USE = 0x76,\n    PDP_FAIL_IP_ADDRESS_MISMATCH = 0x77,\n    PDP_FAIL_IFACE_AND_POL_FAMILY_MISMATCH = 0x78,\n    PDP_FAIL_EMM_ACCESS_BARRED_INFINITE_RETRY = 0x79,\n    PDP_FAIL_AUTH_FAILURE_ON_EMERGENCY_CALL = 0x7A,\n\n    // OEM specific error codes. To be used by OEMs when they don't want to\n    // reveal error code which would be replaced by PDP_FAIL_ERROR_UNSPECIFIED\n    PDP_FAIL_OEM_DCFAILCAUSE_1 = 0x1001,\n    PDP_FAIL_OEM_DCFAILCAUSE_2 = 0x1002,\n    PDP_FAIL_OEM_DCFAILCAUSE_3 = 0x1003,\n    PDP_FAIL_OEM_DCFAILCAUSE_4 = 0x1004,\n    PDP_FAIL_OEM_DCFAILCAUSE_5 = 0x1005,\n    PDP_FAIL_OEM_DCFAILCAUSE_6 = 0x1006,\n    PDP_FAIL_OEM_DCFAILCAUSE_7 = 0x1007,\n    PDP_FAIL_OEM_DCFAILCAUSE_8 = 0x1008,\n    PDP_FAIL_OEM_DCFAILCAUSE_9 = 0x1009,\n    PDP_FAIL_OEM_DCFAILCAUSE_10 = 0x100A,\n    PDP_FAIL_OEM_DCFAILCAUSE_11 = 0x100B,\n    PDP_FAIL_OEM_DCFAILCAUSE_12 = 0x100C,\n    PDP_FAIL_OEM_DCFAILCAUSE_13 = 0x100D,\n    PDP_FAIL_OEM_DCFAILCAUSE_14 = 0x100E,\n    PDP_FAIL_OEM_DCFAILCAUSE_15 = 0x100F,\n\n    /* Not mentioned in the specification */\n    PDP_FAIL_VOICE_REGISTRATION_FAIL = -1,\n    PDP_FAIL_DATA_REGISTRATION_FAIL = -2,\n\n   /* reasons for data call drop - network/modem disconnect */\n    PDP_FAIL_SIGNAL_LOST = -3,\n    PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,/* preferred technology has changed, should retry\n                                             with parameters appropriate for new technology */\n    PDP_FAIL_RADIO_POWER_OFF = -5,        /* data call was disconnected because radio was resetting,\n                                             powered off - no retry */\n    PDP_FAIL_TETHERED_CALL_ACTIVE = -6,   /* data call was disconnected by modem because tethered\n                                             mode was up on same APN/data profile - no retry until\n                                             tethered call is off */\n\n    PDP_FAIL_ERROR_UNSPECIFIED = 0xffff,  /* retry silently. Will be deprecated soon as\n                                             new error codes are added making this unnecessary */\n} RIL_DataCallFailCause;\n\n/* See RIL_REQUEST_SETUP_DATA_CALL */\ntypedef enum {\n    RIL_DATA_PROFILE_DEFAULT    = 0,\n    RIL_DATA_PROFILE_TETHERED   = 1,\n    RIL_DATA_PROFILE_IMS        = 2,\n    RIL_DATA_PROFILE_FOTA       = 3,\n    RIL_DATA_PROFILE_CBS        = 4,\n    RIL_DATA_PROFILE_OEM_BASE   = 1000,    /* Start of OEM-specific profiles */\n    RIL_DATA_PROFILE_INVALID    = 0xFFFFFFFF\n} RIL_DataProfile;\n\n/* Used by RIL_UNSOL_SUPP_SVC_NOTIFICATION */\ntypedef struct {\n    int     notificationType;   /*\n                                 * 0 = MO intermediate result code\n                                 * 1 = MT unsolicited result code\n                                 */\n    int     code;               /* See 27.007 7.17\n                                   \"code1\" for MO\n                                   \"code2\" for MT. */\n    int     index;              /* CUG index. See 27.007 7.17. */\n    int     type;               /* \"type\" from 27.007 7.17 (MT only). */\n    char *  number;             /* \"number\" from 27.007 7.17\n                                   (MT only, may be NULL). */\n} RIL_SuppSvcNotification;\n\n#define RIL_CARD_MAX_APPS     8\n\ntypedef enum {\n    RIL_CARDSTATE_ABSENT     = 0,\n    RIL_CARDSTATE_PRESENT    = 1,\n    RIL_CARDSTATE_ERROR      = 2,\n    RIL_CARDSTATE_RESTRICTED = 3  /* card is present but not usable due to carrier restrictions.*/\n} RIL_CardState;\n\ntypedef enum {\n    RIL_PERSOSUBSTATE_UNKNOWN                   = 0, /* initial state */\n    RIL_PERSOSUBSTATE_IN_PROGRESS               = 1, /* in between each lock transition */\n    RIL_PERSOSUBSTATE_READY                     = 2, /* when either SIM or RUIM Perso is finished\n                                                        since each app can only have 1 active perso\n                                                        involved */\n    RIL_PERSOSUBSTATE_SIM_NETWORK               = 3,\n    RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET        = 4,\n    RIL_PERSOSUBSTATE_SIM_CORPORATE             = 5,\n    RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER      = 6,\n    RIL_PERSOSUBSTATE_SIM_SIM                   = 7,\n    RIL_PERSOSUBSTATE_SIM_NETWORK_PUK           = 8, /* The corresponding perso lock is blocked */\n    RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK    = 9,\n    RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK         = 10,\n    RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK  = 11,\n    RIL_PERSOSUBSTATE_SIM_SIM_PUK               = 12,\n    RIL_PERSOSUBSTATE_RUIM_NETWORK1             = 13,\n    RIL_PERSOSUBSTATE_RUIM_NETWORK2             = 14,\n    RIL_PERSOSUBSTATE_RUIM_HRPD                 = 15,\n    RIL_PERSOSUBSTATE_RUIM_CORPORATE            = 16,\n    RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER     = 17,\n    RIL_PERSOSUBSTATE_RUIM_RUIM                 = 18,\n    RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK         = 19, /* The corresponding perso lock is blocked */\n    RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK         = 20,\n    RIL_PERSOSUBSTATE_RUIM_HRPD_PUK             = 21,\n    RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK        = 22,\n    RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23,\n    RIL_PERSOSUBSTATE_RUIM_RUIM_PUK             = 24\n} RIL_PersoSubstate;\n\ntypedef enum {\n    RIL_APPSTATE_UNKNOWN               = 0,\n    RIL_APPSTATE_DETECTED              = 1,\n    RIL_APPSTATE_PIN                   = 2, /* If PIN1 or UPin is required */\n    RIL_APPSTATE_PUK                   = 3, /* If PUK1 or Puk for UPin is required */\n    RIL_APPSTATE_SUBSCRIPTION_PERSO    = 4, /* perso_substate should be look at\n                                               when app_state is assigned to this value */\n    RIL_APPSTATE_READY                 = 5\n} RIL_AppState;\n\ntypedef enum {\n    RIL_PINSTATE_UNKNOWN              = 0,\n    RIL_PINSTATE_ENABLED_NOT_VERIFIED = 1,\n    RIL_PINSTATE_ENABLED_VERIFIED     = 2,\n    RIL_PINSTATE_DISABLED             = 3,\n    RIL_PINSTATE_ENABLED_BLOCKED      = 4,\n    RIL_PINSTATE_ENABLED_PERM_BLOCKED = 5\n} RIL_PinState;\n\ntypedef enum {\n  RIL_APPTYPE_UNKNOWN = 0,\n  RIL_APPTYPE_SIM     = 1,\n  RIL_APPTYPE_USIM    = 2,\n  RIL_APPTYPE_RUIM    = 3,\n  RIL_APPTYPE_CSIM    = 4,\n  RIL_APPTYPE_ISIM    = 5\n} RIL_AppType;\n\ntypedef struct\n{\n  RIL_AppType      app_type;\n  RIL_AppState     app_state;\n  RIL_PersoSubstate perso_substate; /* applicable only if app_state ==\n                                       RIL_APPSTATE_SUBSCRIPTION_PERSO */\n  char             *aid_ptr;        /* null terminated string, e.g., from 0xA0, 0x00 -> 0x41,\n                                       0x30, 0x30, 0x30 */\n  char             *app_label_ptr;  /* null terminated string */\n  int              pin1_replaced;   /* applicable to USIM, CSIM & ISIM */\n  RIL_PinState     pin1;\n  RIL_PinState     pin2;\n} RIL_AppStatus;\n\n/* Deprecated, use RIL_CardStatus_v6 */\ntypedef struct\n{\n  RIL_CardState card_state;\n  RIL_PinState  universal_pin_state;             /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */\n  int           gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */\n  int           cdma_subscription_app_index;     /* value < RIL_CARD_MAX_APPS, -1 if none */\n  int           num_applications;                /* value <= RIL_CARD_MAX_APPS */\n  RIL_AppStatus applications[RIL_CARD_MAX_APPS];\n} RIL_CardStatus_v5;\n\ntypedef struct\n{\n  RIL_CardState card_state;\n  RIL_PinState  universal_pin_state;             /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */\n  int           gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */\n  int           cdma_subscription_app_index;     /* value < RIL_CARD_MAX_APPS, -1 if none */\n  int           ims_subscription_app_index;      /* value < RIL_CARD_MAX_APPS, -1 if none */\n  int           num_applications;                /* value <= RIL_CARD_MAX_APPS */\n  RIL_AppStatus applications[RIL_CARD_MAX_APPS];\n} RIL_CardStatus_v6;\n\n/** The result of a SIM refresh, returned in data[0] of RIL_UNSOL_SIM_REFRESH\n *      or as part of RIL_SimRefreshResponse_v7\n */\ntypedef enum {\n    /* A file on SIM has been updated.  data[1] contains the EFID. */\n    SIM_FILE_UPDATE = 0,\n    /* SIM initialized.  All files should be re-read. */\n    SIM_INIT = 1,\n    /* SIM reset.  SIM power required, SIM may be locked and all files should be re-read. */\n    SIM_RESET = 2\n} RIL_SimRefreshResult;\n\ntypedef struct {\n    RIL_SimRefreshResult result;\n    int                  ef_id; /* is the EFID of the updated file if the result is */\n                                /* SIM_FILE_UPDATE or 0 for any other result. */\n    char *               aid;   /* is AID(application ID) of the card application */\n                                /* See ETSI 102.221 8.1 and 101.220 4 */\n                                /*     For SIM_FILE_UPDATE result it can be set to AID of */\n                                /*         application in which updated EF resides or it can be */\n                                /*         NULL if EF is outside of an application. */\n                                /*     For SIM_INIT result this field is set to AID of */\n                                /*         application that caused REFRESH */\n                                /*     For SIM_RESET result it is NULL. */\n} RIL_SimRefreshResponse_v7;\n\n/* Deprecated, use RIL_CDMA_CallWaiting_v6 */\ntypedef struct {\n    char *          number;             /* Remote party number */\n    int             numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */\n    char *          name;               /* Remote party name */\n    RIL_CDMA_SignalInfoRecord signalInfoRecord;\n} RIL_CDMA_CallWaiting_v5;\n\ntypedef struct {\n    char *          number;             /* Remote party number */\n    int             numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */\n    char *          name;               /* Remote party name */\n    RIL_CDMA_SignalInfoRecord signalInfoRecord;\n    /* Number type/Number plan required to support International Call Waiting */\n    int             number_type;        /* 0=Unknown, 1=International, 2=National,\n                                           3=Network specific, 4=subscriber */\n    int             number_plan;        /* 0=Unknown, 1=ISDN, 3=Data, 4=Telex, 8=Nat'l, 9=Private */\n} RIL_CDMA_CallWaiting_v6;\n\n/**\n * Which types of Cell Broadcast Message (CBM) are to be received by the ME\n *\n * uFromServiceID - uToServiceID defines a range of CBM message identifiers\n * whose value is 0x0000 - 0xFFFF as defined in TS 23.041 9.4.1.2.2 for GMS\n * and 9.4.4.2.2 for UMTS. All other values can be treated as empty\n * CBM message ID.\n *\n * uFromCodeScheme - uToCodeScheme defines a range of CBM data coding schemes\n * whose value is 0x00 - 0xFF as defined in TS 23.041 9.4.1.2.3 for GMS\n * and 9.4.4.2.3 for UMTS.\n * All other values can be treated as empty CBM data coding scheme.\n *\n * selected 0 means message types specified in <fromServiceId, toServiceId>\n * and <fromCodeScheme, toCodeScheme>are not accepted, while 1 means accepted.\n *\n * Used by RIL_REQUEST_GSM_GET_BROADCAST_CONFIG and\n * RIL_REQUEST_GSM_SET_BROADCAST_CONFIG.\n */\ntypedef struct {\n    int fromServiceId;\n    int toServiceId;\n    int fromCodeScheme;\n    int toCodeScheme;\n    unsigned char selected;\n} RIL_GSM_BroadcastSmsConfigInfo;\n\n/* No restriction at all including voice/SMS/USSD/SS/AV64 and packet data. */\n#define RIL_RESTRICTED_STATE_NONE           0x00\n/* Block emergency call due to restriction. But allow all normal voice/SMS/USSD/SS/AV64. */\n#define RIL_RESTRICTED_STATE_CS_EMERGENCY   0x01\n/* Block all normal voice/SMS/USSD/SS/AV64 due to restriction. Only Emergency call allowed. */\n#define RIL_RESTRICTED_STATE_CS_NORMAL      0x02\n/* Block all voice/SMS/USSD/SS/AV64 including emergency call due to restriction.*/\n#define RIL_RESTRICTED_STATE_CS_ALL         0x04\n/* Block packet data access due to restriction. */\n#define RIL_RESTRICTED_STATE_PS_ALL         0x10\n\n/* The status for an OTASP/OTAPA session */\ntypedef enum {\n    CDMA_OTA_PROVISION_STATUS_SPL_UNLOCKED,\n    CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED,\n    CDMA_OTA_PROVISION_STATUS_A_KEY_EXCHANGED,\n    CDMA_OTA_PROVISION_STATUS_SSD_UPDATED,\n    CDMA_OTA_PROVISION_STATUS_NAM_DOWNLOADED,\n    CDMA_OTA_PROVISION_STATUS_MDN_DOWNLOADED,\n    CDMA_OTA_PROVISION_STATUS_IMSI_DOWNLOADED,\n    CDMA_OTA_PROVISION_STATUS_PRL_DOWNLOADED,\n    CDMA_OTA_PROVISION_STATUS_COMMITTED,\n    CDMA_OTA_PROVISION_STATUS_OTAPA_STARTED,\n    CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED,\n    CDMA_OTA_PROVISION_STATUS_OTAPA_ABORTED\n} RIL_CDMA_OTA_ProvisionStatus;\n\ntypedef struct {\n    int signalStrength;  /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */\n    int bitErrorRate;    /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */\n} RIL_GW_SignalStrength;\n\ntypedef struct {\n    int signalStrength;  /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */\n    int bitErrorRate;    /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */\n    int timingAdvance;   /* Timing Advance in bit periods. 1 bit period = 48/13 us.\n                          * INT_MAX denotes invalid value */\n} RIL_GSM_SignalStrength_v12;\n\ntypedef struct {\n    int signalStrength;  /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */\n    int bitErrorRate;    /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */\n} RIL_SignalStrengthWcdma;\n\ntypedef struct {\n    int dbm;  /* Valid values are positive integers.  This value is the actual RSSI value\n               * multiplied by -1.  Example: If the actual RSSI is -75, then this response\n               * value will be 75.\n               */\n    int ecio; /* Valid values are positive integers.  This value is the actual Ec/Io multiplied\n               * by -10.  Example: If the actual Ec/Io is -12.5 dB, then this response value\n               * will be 125.\n               */\n} RIL_CDMA_SignalStrength;\n\n\ntypedef struct {\n    int dbm;  /* Valid values are positive integers.  This value is the actual RSSI value\n               * multiplied by -1.  Example: If the actual RSSI is -75, then this response\n               * value will be 75.\n               */\n    int ecio; /* Valid values are positive integers.  This value is the actual Ec/Io multiplied\n               * by -10.  Example: If the actual Ec/Io is -12.5 dB, then this response value\n               * will be 125.\n               */\n    int signalNoiseRatio; /* Valid values are 0-8.  8 is the highest signal to noise ratio. */\n} RIL_EVDO_SignalStrength;\n\ntypedef struct {\n    int signalStrength;  /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */\n    int rsrp;            /* The current Reference Signal Receive Power in dBm multipled by -1.\n                          * Range: 44 to 140 dBm\n                          * INT_MAX: 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP TS 36.133 9.1.4 */\n    int rsrq;            /* The current Reference Signal Receive Quality in dB multiplied by -1.\n                          * Range: 20 to 3 dB.\n                          * INT_MAX: 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP TS 36.133 9.1.7 */\n    int rssnr;           /* The current reference signal signal-to-noise ratio in 0.1 dB units.\n                          * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).\n                          * INT_MAX : 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP TS 36.101 8.1.1 */\n    int cqi;             /* The current Channel Quality Indicator.\n                          * Range: 0 to 15.\n                          * INT_MAX : 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */\n} RIL_LTE_SignalStrength;\n\ntypedef struct {\n    int signalStrength;  /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */\n    int rsrp;            /* The current Reference Signal Receive Power in dBm multipled by -1.\n                          * Range: 44 to 140 dBm\n                          * INT_MAX: 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP TS 36.133 9.1.4 */\n    int rsrq;            /* The current Reference Signal Receive Quality in dB multiplied by -1.\n                          * Range: 20 to 3 dB.\n                          * INT_MAX: 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP TS 36.133 9.1.7 */\n    int rssnr;           /* The current reference signal signal-to-noise ratio in 0.1 dB units.\n                          * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).\n                          * INT_MAX : 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP TS 36.101 8.1.1 */\n    int cqi;             /* The current Channel Quality Indicator.\n                          * Range: 0 to 15.\n                          * INT_MAX : 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */\n    int timingAdvance;   /* timing advance in micro seconds for a one way trip from cell to device.\n                          * Approximate distance can be calculated using 300m/us * timingAdvance.\n                          * Range: 0 to 0x7FFFFFFE\n                          * INT_MAX : 0x7FFFFFFF denotes invalid value.\n                          * Reference: 3GPP 36.321 section 6.1.3.5\n                          * also: http://www.cellular-planningoptimization.com/2010/02/timing-advance-with-calculation.html */\n} RIL_LTE_SignalStrength_v8;\n\ntypedef struct {\n    int rscp;    /* The Received Signal Code Power in dBm multipled by -1.\n                  * Range : 25 to 120\n                  * INT_MAX: 0x7FFFFFFF denotes invalid value.\n                  * Reference: 3GPP TS 25.123, section 9.1.1.1 */\n} RIL_TD_SCDMA_SignalStrength;\n\n/* Deprecated, use RIL_SignalStrength_v6 */\ntypedef struct {\n    RIL_GW_SignalStrength   GW_SignalStrength;\n    RIL_CDMA_SignalStrength CDMA_SignalStrength;\n    RIL_EVDO_SignalStrength EVDO_SignalStrength;\n} RIL_SignalStrength_v5;\n\ntypedef struct {\n    RIL_GW_SignalStrength   GW_SignalStrength;\n    RIL_CDMA_SignalStrength CDMA_SignalStrength;\n    RIL_EVDO_SignalStrength EVDO_SignalStrength;\n    RIL_LTE_SignalStrength  LTE_SignalStrength;\n} RIL_SignalStrength_v6;\n\ntypedef struct {\n    RIL_GW_SignalStrength       GW_SignalStrength;\n    RIL_CDMA_SignalStrength     CDMA_SignalStrength;\n    RIL_EVDO_SignalStrength     EVDO_SignalStrength;\n    RIL_LTE_SignalStrength_v8   LTE_SignalStrength;\n} RIL_SignalStrength_v8;\n\ntypedef struct {\n    RIL_GW_SignalStrength       GW_SignalStrength;\n    RIL_CDMA_SignalStrength     CDMA_SignalStrength;\n    RIL_EVDO_SignalStrength     EVDO_SignalStrength;\n    RIL_LTE_SignalStrength_v8   LTE_SignalStrength;\n    RIL_TD_SCDMA_SignalStrength TD_SCDMA_SignalStrength;\n} RIL_SignalStrength_v10;\n\ntypedef struct {\n    int mcc;    /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */\n    int mnc;    /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */\n    int lac;    /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown  */\n    int cid;    /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown  */\n} RIL_CellIdentityGsm;\n\ntypedef struct {\n    int mcc;    /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */\n    int mnc;    /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */\n    int lac;    /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown  */\n    int cid;    /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown  */\n    int arfcn;  /* 16-bit GSM Absolute RF channel number, INT_MAX if unknown */\n    uint8_t bsic;/* 6-bit Base Station Identity Code, 0xFF if unknown */\n} RIL_CellIdentityGsm_v12;\n\ntypedef struct {\n    int mcc;    /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown  */\n    int mnc;    /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown  */\n    int lac;    /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown  */\n    int cid;    /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown  */\n    int psc;    /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511, INT_MAX if unknown */\n} RIL_CellIdentityWcdma;\n\ntypedef struct {\n    int mcc;    /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown  */\n    int mnc;    /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown  */\n    int lac;    /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown  */\n    int cid;    /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown  */\n    int psc;    /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511, INT_MAX if unknown */\n    int uarfcn; /* 16-bit UMTS Absolute RF Channel Number, INT_MAX if unknown */\n} RIL_CellIdentityWcdma_v12;\n\ntypedef struct {\n    int networkId;      /* Network Id 0..65535, INT_MAX if unknown */\n    int systemId;       /* CDMA System Id 0..32767, INT_MAX if unknown  */\n    int basestationId;  /* Base Station Id 0..65535, INT_MAX if unknown  */\n    int longitude;      /* Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.\n                         * It is represented in units of 0.25 seconds and ranges from -2592000\n                         * to 2592000, both values inclusive (corresponding to a range of -180\n                         * to +180 degrees). INT_MAX if unknown */\n\n    int latitude;       /* Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.\n                         * It is represented in units of 0.25 seconds and ranges from -1296000\n                         * to 1296000, both values inclusive (corresponding to a range of -90\n                         * to +90 degrees). INT_MAX if unknown */\n} RIL_CellIdentityCdma;\n\ntypedef struct {\n    int mcc;    /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown  */\n    int mnc;    /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown  */\n    int ci;     /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */\n    int pci;    /* physical cell id 0..503, INT_MAX if unknown  */\n    int tac;    /* 16-bit tracking area code, INT_MAX if unknown  */\n} RIL_CellIdentityLte;\n\ntypedef struct {\n    int mcc;    /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown  */\n    int mnc;    /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown  */\n    int ci;     /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */\n    int pci;    /* physical cell id 0..503, INT_MAX if unknown  */\n    int tac;    /* 16-bit tracking area code, INT_MAX if unknown  */\n    int earfcn; /* 18-bit LTE Absolute RC Channel Number, INT_MAX if unknown */\n} RIL_CellIdentityLte_v12;\n\ntypedef struct {\n    int mcc;    /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown  */\n    int mnc;    /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown  */\n    int lac;    /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown  */\n    int cid;    /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown  */\n    int cpid;    /* 8-bit Cell Parameters ID described in TS 25.331, 0..127, INT_MAX if unknown */\n} RIL_CellIdentityTdscdma;\n\ntypedef struct {\n  RIL_CellIdentityGsm   cellIdentityGsm;\n  RIL_GW_SignalStrength signalStrengthGsm;\n} RIL_CellInfoGsm;\n\ntypedef struct {\n  RIL_CellIdentityGsm_v12   cellIdentityGsm;\n  RIL_GSM_SignalStrength_v12 signalStrengthGsm;\n} RIL_CellInfoGsm_v12;\n\ntypedef struct {\n  RIL_CellIdentityWcdma cellIdentityWcdma;\n  RIL_SignalStrengthWcdma signalStrengthWcdma;\n} RIL_CellInfoWcdma;\n\ntypedef struct {\n  RIL_CellIdentityWcdma_v12 cellIdentityWcdma;\n  RIL_SignalStrengthWcdma signalStrengthWcdma;\n} RIL_CellInfoWcdma_v12;\n\ntypedef struct {\n  RIL_CellIdentityCdma      cellIdentityCdma;\n  RIL_CDMA_SignalStrength   signalStrengthCdma;\n  RIL_EVDO_SignalStrength   signalStrengthEvdo;\n} RIL_CellInfoCdma;\n\ntypedef struct {\n  RIL_CellIdentityLte        cellIdentityLte;\n  RIL_LTE_SignalStrength_v8  signalStrengthLte;\n} RIL_CellInfoLte;\n\ntypedef struct {\n  RIL_CellIdentityLte_v12    cellIdentityLte;\n  RIL_LTE_SignalStrength_v8  signalStrengthLte;\n} RIL_CellInfoLte_v12;\n\ntypedef struct {\n  RIL_CellIdentityTdscdma cellIdentityTdscdma;\n  RIL_TD_SCDMA_SignalStrength signalStrengthTdscdma;\n} RIL_CellInfoTdscdma;\n\n// Must be the same as CellInfo.TYPE_XXX\ntypedef enum {\n  RIL_CELL_INFO_TYPE_GSM    = 1,\n  RIL_CELL_INFO_TYPE_CDMA   = 2,\n  RIL_CELL_INFO_TYPE_LTE    = 3,\n  RIL_CELL_INFO_TYPE_WCDMA  = 4,\n  RIL_CELL_INFO_TYPE_TD_SCDMA  = 5\n} RIL_CellInfoType;\n\n// Must be the same as CellInfo.TIMESTAMP_TYPE_XXX\ntypedef enum {\n    RIL_TIMESTAMP_TYPE_UNKNOWN = 0,\n    RIL_TIMESTAMP_TYPE_ANTENNA = 1,\n    RIL_TIMESTAMP_TYPE_MODEM = 2,\n    RIL_TIMESTAMP_TYPE_OEM_RIL = 3,\n    RIL_TIMESTAMP_TYPE_JAVA_RIL = 4,\n} RIL_TimeStampType;\n\ntypedef struct {\n  RIL_CellInfoType  cellInfoType;   /* cell type for selecting from union CellInfo */\n  int               registered;     /* !0 if this cell is registered 0 if not registered */\n  RIL_TimeStampType timeStampType;  /* type of time stamp represented by timeStamp */\n  uint64_t          timeStamp;      /* Time in nanos as returned by ril_nano_time */\n  union {\n    RIL_CellInfoGsm     gsm;\n    RIL_CellInfoCdma    cdma;\n    RIL_CellInfoLte     lte;\n    RIL_CellInfoWcdma   wcdma;\n    RIL_CellInfoTdscdma tdscdma;\n  } CellInfo;\n} RIL_CellInfo;\n\ntypedef struct {\n  RIL_CellInfoType  cellInfoType;   /* cell type for selecting from union CellInfo */\n  int               registered;     /* !0 if this cell is registered 0 if not registered */\n  RIL_TimeStampType timeStampType;  /* type of time stamp represented by timeStamp */\n  uint64_t          timeStamp;      /* Time in nanos as returned by ril_nano_time */\n  union {\n    RIL_CellInfoGsm_v12     gsm;\n    RIL_CellInfoCdma        cdma;\n    RIL_CellInfoLte_v12     lte;\n    RIL_CellInfoWcdma_v12   wcdma;\n    RIL_CellInfoTdscdma     tdscdma;\n  } CellInfo;\n} RIL_CellInfo_v12;\n\n/* Names of the CDMA info records (C.S0005 section 3.7.5) */\ntypedef enum {\n  RIL_CDMA_DISPLAY_INFO_REC,\n  RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC,\n  RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC,\n  RIL_CDMA_CONNECTED_NUMBER_INFO_REC,\n  RIL_CDMA_SIGNAL_INFO_REC,\n  RIL_CDMA_REDIRECTING_NUMBER_INFO_REC,\n  RIL_CDMA_LINE_CONTROL_INFO_REC,\n  RIL_CDMA_EXTENDED_DISPLAY_INFO_REC,\n  RIL_CDMA_T53_CLIR_INFO_REC,\n  RIL_CDMA_T53_RELEASE_INFO_REC,\n  RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC\n} RIL_CDMA_InfoRecName;\n\n/* Display Info Rec as defined in C.S0005 section 3.7.5.1\n   Extended Display Info Rec as defined in C.S0005 section 3.7.5.16\n   Note: the Extended Display info rec contains multiple records of the\n   form: display_tag, display_len, and display_len occurrences of the\n   chari field if the display_tag is not 10000000 or 10000001.\n   To save space, the records are stored consecutively in a byte buffer.\n   The display_tag, display_len and chari fields are all 1 byte.\n*/\n\ntypedef struct {\n  char alpha_len;\n  char alpha_buf[CDMA_ALPHA_INFO_BUFFER_LENGTH];\n} RIL_CDMA_DisplayInfoRecord;\n\n/* Called Party Number Info Rec as defined in C.S0005 section 3.7.5.2\n   Calling Party Number Info Rec as defined in C.S0005 section 3.7.5.3\n   Connected Number Info Rec as defined in C.S0005 section 3.7.5.4\n*/\n\ntypedef struct {\n  char len;\n  char buf[CDMA_NUMBER_INFO_BUFFER_LENGTH];\n  char number_type;\n  char number_plan;\n  char pi;\n  char si;\n} RIL_CDMA_NumberInfoRecord;\n\n/* Redirecting Number Information Record as defined in C.S0005 section 3.7.5.11 */\ntypedef enum {\n  RIL_REDIRECTING_REASON_UNKNOWN = 0,\n  RIL_REDIRECTING_REASON_CALL_FORWARDING_BUSY = 1,\n  RIL_REDIRECTING_REASON_CALL_FORWARDING_NO_REPLY = 2,\n  RIL_REDIRECTING_REASON_CALLED_DTE_OUT_OF_ORDER = 9,\n  RIL_REDIRECTING_REASON_CALL_FORWARDING_BY_THE_CALLED_DTE = 10,\n  RIL_REDIRECTING_REASON_CALL_FORWARDING_UNCONDITIONAL = 15,\n  RIL_REDIRECTING_REASON_RESERVED\n} RIL_CDMA_RedirectingReason;\n\ntypedef struct {\n  RIL_CDMA_NumberInfoRecord redirectingNumber;\n  /* redirectingReason is set to RIL_REDIRECTING_REASON_UNKNOWN if not included */\n  RIL_CDMA_RedirectingReason redirectingReason;\n} RIL_CDMA_RedirectingNumberInfoRecord;\n\n/* Line Control Information Record as defined in C.S0005 section 3.7.5.15 */\ntypedef struct {\n  char lineCtrlPolarityIncluded;\n  char lineCtrlToggle;\n  char lineCtrlReverse;\n  char lineCtrlPowerDenial;\n} RIL_CDMA_LineControlInfoRecord;\n\n/* T53 CLIR Information Record */\ntypedef struct {\n  char cause;\n} RIL_CDMA_T53_CLIRInfoRecord;\n\n/* T53 Audio Control Information Record */\ntypedef struct {\n  char upLink;\n  char downLink;\n} RIL_CDMA_T53_AudioControlInfoRecord;\n\ntypedef struct {\n\n  RIL_CDMA_InfoRecName name;\n\n  union {\n    /* Display and Extended Display Info Rec */\n    RIL_CDMA_DisplayInfoRecord           display;\n\n    /* Called Party Number, Calling Party Number, Connected Number Info Rec */\n    RIL_CDMA_NumberInfoRecord            number;\n\n    /* Signal Info Rec */\n    RIL_CDMA_SignalInfoRecord            signal;\n\n    /* Redirecting Number Info Rec */\n    RIL_CDMA_RedirectingNumberInfoRecord redir;\n\n    /* Line Control Info Rec */\n    RIL_CDMA_LineControlInfoRecord       lineCtrl;\n\n    /* T53 CLIR Info Rec */\n    RIL_CDMA_T53_CLIRInfoRecord          clir;\n\n    /* T53 Audio Control Info Rec */\n    RIL_CDMA_T53_AudioControlInfoRecord  audioCtrl;\n  } rec;\n} RIL_CDMA_InformationRecord;\n\n#define RIL_CDMA_MAX_NUMBER_OF_INFO_RECS 10\n\ntypedef struct {\n  char numberOfInfoRecs;\n  RIL_CDMA_InformationRecord infoRec[RIL_CDMA_MAX_NUMBER_OF_INFO_RECS];\n} RIL_CDMA_InformationRecords;\n\n/* See RIL_REQUEST_NV_READ_ITEM */\ntypedef struct {\n  RIL_NV_Item itemID;\n} RIL_NV_ReadItem;\n\n/* See RIL_REQUEST_NV_WRITE_ITEM */\ntypedef struct {\n  RIL_NV_Item   itemID;\n  char *        value;\n} RIL_NV_WriteItem;\n\ntypedef enum {\n    HANDOVER_STARTED = 0,\n    HANDOVER_COMPLETED = 1,\n    HANDOVER_FAILED = 2,\n    HANDOVER_CANCELED = 3\n} RIL_SrvccState;\n\n/* hardware configuration reported to RILJ. */\ntypedef enum {\n   RIL_HARDWARE_CONFIG_MODEM = 0,\n   RIL_HARDWARE_CONFIG_SIM = 1,\n} RIL_HardwareConfig_Type;\n\ntypedef enum {\n   RIL_HARDWARE_CONFIG_STATE_ENABLED = 0,\n   RIL_HARDWARE_CONFIG_STATE_STANDBY = 1,\n   RIL_HARDWARE_CONFIG_STATE_DISABLED = 2,\n} RIL_HardwareConfig_State;\n\ntypedef struct {\n   int rilModel;\n   uint32_t rat; /* bitset - ref. RIL_RadioTechnology. */\n   int maxVoice;\n   int maxData;\n   int maxStandby;\n} RIL_HardwareConfig_Modem;\n\ntypedef struct {\n   char modemUuid[MAX_UUID_LENGTH];\n} RIL_HardwareConfig_Sim;\n\ntypedef struct {\n  RIL_HardwareConfig_Type type;\n  char uuid[MAX_UUID_LENGTH];\n  RIL_HardwareConfig_State state;\n  union {\n     RIL_HardwareConfig_Modem modem;\n     RIL_HardwareConfig_Sim sim;\n  } cfg;\n} RIL_HardwareConfig;\n\ntypedef enum {\n  SS_CFU,\n  SS_CF_BUSY,\n  SS_CF_NO_REPLY,\n  SS_CF_NOT_REACHABLE,\n  SS_CF_ALL,\n  SS_CF_ALL_CONDITIONAL,\n  SS_CLIP,\n  SS_CLIR,\n  SS_COLP,\n  SS_COLR,\n  SS_WAIT,\n  SS_BAOC,\n  SS_BAOIC,\n  SS_BAOIC_EXC_HOME,\n  SS_BAIC,\n  SS_BAIC_ROAMING,\n  SS_ALL_BARRING,\n  SS_OUTGOING_BARRING,\n  SS_INCOMING_BARRING\n} RIL_SsServiceType;\n\ntypedef enum {\n  SS_ACTIVATION,\n  SS_DEACTIVATION,\n  SS_INTERROGATION,\n  SS_REGISTRATION,\n  SS_ERASURE\n} RIL_SsRequestType;\n\ntypedef enum {\n  SS_ALL_TELE_AND_BEARER_SERVICES,\n  SS_ALL_TELESEVICES,\n  SS_TELEPHONY,\n  SS_ALL_DATA_TELESERVICES,\n  SS_SMS_SERVICES,\n  SS_ALL_TELESERVICES_EXCEPT_SMS\n} RIL_SsTeleserviceType;\n\n#define SS_INFO_MAX 4\n#define NUM_SERVICE_CLASSES 7\n\ntypedef struct {\n  int numValidIndexes; /* This gives the number of valid values in cfInfo.\n                       For example if voice is forwarded to one number and data\n                       is forwarded to a different one then numValidIndexes will be\n                       2 indicating total number of valid values in cfInfo.\n                       Similarly if all the services are forwarded to the same\n                       number then the value of numValidIndexes will be 1. */\n\n  RIL_CallForwardInfo cfInfo[NUM_SERVICE_CLASSES]; /* This is the response data\n                                                      for SS request to query call\n                                                      forward status. see\n                                                      RIL_REQUEST_QUERY_CALL_FORWARD_STATUS */\n} RIL_CfData;\n\ntypedef struct {\n  RIL_SsServiceType serviceType;\n  RIL_SsRequestType requestType;\n  RIL_SsTeleserviceType teleserviceType;\n  int serviceClass;\n  RIL_Errno result;\n\n  union {\n    int ssInfo[SS_INFO_MAX]; /* This is the response data for most of the SS GET/SET\n                                RIL requests. E.g. RIL_REQUSET_GET_CLIR returns\n                                two ints, so first two values of ssInfo[] will be\n                                used for response if serviceType is SS_CLIR and\n                                requestType is SS_INTERROGATION */\n\n    RIL_CfData cfData;\n  };\n} RIL_StkCcUnsolSsResponse;\n\n/**\n * Data connection power state\n */\ntypedef enum {\n    RIL_DC_POWER_STATE_LOW      = 1,        // Low power state\n    RIL_DC_POWER_STATE_MEDIUM   = 2,        // Medium power state\n    RIL_DC_POWER_STATE_HIGH     = 3,        // High power state\n    RIL_DC_POWER_STATE_UNKNOWN  = INT32_MAX // Unknown state\n} RIL_DcPowerStates;\n\n/**\n * Data connection real time info\n */\ntypedef struct {\n    uint64_t                    time;       // Time in nanos as returned by ril_nano_time\n    RIL_DcPowerStates           powerState; // Current power state\n} RIL_DcRtInfo;\n\n/**\n * Data profile to modem\n */\ntypedef struct {\n    /* id of the data profile */\n    int profileId;\n    /* the APN to connect to */\n    char* apn;\n    /** one of the PDP_type values in TS 27.007 section 10.1.1.\n     * For example, \"IP\", \"IPV6\", \"IPV4V6\", or \"PPP\".\n     */\n    char* protocol;\n    /** authentication protocol used for this PDP context\n     * (None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3)\n     */\n    int authType;\n    /* the username for APN, or NULL */\n    char* user;\n    /* the password for APN, or NULL */\n    char* password;\n    /* the profile type, TYPE_COMMON-0, TYPE_3GPP-1, TYPE_3GPP2-2 */\n    int type;\n    /* the period in seconds to limit the maximum connections */\n    int maxConnsTime;\n    /* the maximum connections during maxConnsTime */\n    int maxConns;\n    /** the required wait time in seconds after a successful UE initiated\n     * disconnect of a given PDN connection before the device can send\n     * a new PDN connection request for that given PDN\n     */\n    int waitTime;\n    /* true to enable the profile, 0 to disable, 1 to enable */\n    int enabled;\n} RIL_DataProfileInfo;\n\n/* Tx Power Levels */\n#define RIL_NUM_TX_POWER_LEVELS     5\n\ntypedef struct {\n\n  /* period (in ms) when modem is power collapsed */\n  uint32_t sleep_mode_time_ms;\n\n  /* period (in ms) when modem is awake and in idle mode*/\n  uint32_t idle_mode_time_ms;\n\n  /* period (in ms) for which Tx is active */\n  uint32_t tx_mode_time_ms[RIL_NUM_TX_POWER_LEVELS];\n\n  /* period (in ms) for which Rx is active */\n  uint32_t rx_mode_time_ms;\n} RIL_ActivityStatsInfo;\n\ntypedef struct {\n    uint8_t p2; /* P2 parameter */\n    char * aidPtr; /* AID value, See ETSI 102.221 and 101.220*/\n\n} RIL_CafOpenChannelParams;\n\n#define RIL_NUM_ADN_RECORDS      10\n#define RIL_MAX_NUM_AD_COUNT     4\n#define RIL_MAX_NUM_EMAIL_COUNT  2\n\ntypedef struct {\n    int       record_id;\n    char*     name;\n    char*     number;\n    int       email_elements;\n    char*     email[RIL_MAX_NUM_EMAIL_COUNT];\n    int       anr_elements;\n    char*     ad_number[RIL_MAX_NUM_AD_COUNT];\n} RIL_AdnRecordInfo;\n\ntypedef struct {\n    int               record_elements;\n    RIL_AdnRecordInfo adn_record_info[RIL_NUM_ADN_RECORDS];\n} RIL_AdnRecord_v1;\n\n/**\n * RIL_REQUEST_GET_SIM_STATUS\n *\n * Requests status of the SIM interface and the SIM card\n *\n * \"data\" is NULL\n *\n * \"response\" is const RIL_CardStatus_v6 *\n *\n * Valid errors:\n *  Must never fail\n */\n#define RIL_REQUEST_GET_SIM_STATUS 1\n\n/**\n * RIL_REQUEST_ENTER_SIM_PIN\n *\n * Supplies SIM PIN. Only called if RIL_CardStatus has RIL_APPSTATE_PIN state\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is PIN value\n * ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n *\n * \"response\" is int *\n * ((int *)response)[0] is the number of retries remaining, or -1 if unknown\n *\n * Valid errors:\n *\n * SUCCESS\n * RADIO_NOT_AVAILABLE (radio resetting)\n * GENERIC_FAILURE\n * PASSWORD_INCORRECT\n */\n\n#define RIL_REQUEST_ENTER_SIM_PIN 2\n\n/**\n * RIL_REQUEST_ENTER_SIM_PUK\n *\n * Supplies SIM PUK and new PIN.\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is PUK value\n * ((const char **)data)[1] is new PIN value\n * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n *\n * \"response\" is int *\n * ((int *)response)[0] is the number of retries remaining, or -1 if unknown\n *\n * Valid errors:\n *\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  PASSWORD_INCORRECT\n *     (PUK is invalid)\n */\n\n#define RIL_REQUEST_ENTER_SIM_PUK 3\n\n/**\n * RIL_REQUEST_ENTER_SIM_PIN2\n *\n * Supplies SIM PIN2. Only called following operation where SIM_PIN2 was\n * returned as a a failure from a previous operation.\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is PIN2 value\n * ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n *\n * \"response\" is int *\n * ((int *)response)[0] is the number of retries remaining, or -1 if unknown\n *\n * Valid errors:\n *\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  PASSWORD_INCORRECT\n */\n\n#define RIL_REQUEST_ENTER_SIM_PIN2 4\n\n/**\n * RIL_REQUEST_ENTER_SIM_PUK2\n *\n * Supplies SIM PUK2 and new PIN2.\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is PUK2 value\n * ((const char **)data)[1] is new PIN2 value\n * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n *\n * \"response\" is int *\n * ((int *)response)[0] is the number of retries remaining, or -1 if unknown\n *\n * Valid errors:\n *\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  PASSWORD_INCORRECT\n *     (PUK2 is invalid)\n */\n\n#define RIL_REQUEST_ENTER_SIM_PUK2 5\n\n/**\n * RIL_REQUEST_CHANGE_SIM_PIN\n *\n * Supplies old SIM PIN and new PIN.\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is old PIN value\n * ((const char **)data)[1] is new PIN value\n * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n *\n * \"response\" is int *\n * ((int *)response)[0] is the number of retries remaining, or -1 if unknown\n *\n * Valid errors:\n *\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  PASSWORD_INCORRECT\n *     (old PIN is invalid)\n *\n */\n\n#define RIL_REQUEST_CHANGE_SIM_PIN 6\n\n\n/**\n * RIL_REQUEST_CHANGE_SIM_PIN2\n *\n * Supplies old SIM PIN2 and new PIN2.\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is old PIN2 value\n * ((const char **)data)[1] is new PIN2 value\n * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n *\n * \"response\" is int *\n * ((int *)response)[0] is the number of retries remaining, or -1 if unknown\n *\n * Valid errors:\n *\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  PASSWORD_INCORRECT\n *     (old PIN2 is invalid)\n *\n */\n\n#define RIL_REQUEST_CHANGE_SIM_PIN2 7\n\n/**\n * RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION\n *\n * Requests that network personlization be deactivated\n *\n * \"data\" is const char **\n * ((const char **)(data))[0]] is network depersonlization code\n *\n * \"response\" is int *\n * ((int *)response)[0] is the number of retries remaining, or -1 if unknown\n *\n * Valid errors:\n *\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  PASSWORD_INCORRECT\n *     (code is invalid)\n */\n\n#define RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION 8\n\n/**\n * RIL_REQUEST_GET_CURRENT_CALLS\n *\n * Requests current call list\n *\n * \"data\" is NULL\n *\n * \"response\" must be a \"const RIL_Call **\"\n *\n * Valid errors:\n *\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  NO_MEMORY\n *  GENERIC_FAILURE\n *      (request will be made again in a few hundred msec)\n */\n\n#define RIL_REQUEST_GET_CURRENT_CALLS 9\n\n\n/**\n * RIL_REQUEST_DIAL\n *\n * Initiate voice call\n *\n * \"data\" is const RIL_Dial *\n * \"response\" is NULL\n *\n * This method is never used for supplementary service codes\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  DIAL_MODIFIED_TO_USSD\n *  DIAL_MODIFIED_TO_SS\n *  DIAL_MODIFIED_TO_DIAL\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  INVALID_STATE\n *  NO_RESOURCES\n *  INTERNAL_ERR\n *  FDN_CHECK_FAILURE\n *  MODEM_ERR\n *  NO_SUBSCRIPTION\n *  NO_NETWORK_FOUND\n *  INVALID_CALL_ID\n *  DEVICE_IN_USE\n *  MODE_NOT_SUPPORTED\n *  ABORTED\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_DIAL 10\n\n/**\n * RIL_REQUEST_GET_IMSI\n *\n * Get the SIM IMSI\n *\n * Only valid when radio state is \"RADIO_STATE_ON\"\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n * \"response\" is a const char * containing the IMSI\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_GET_IMSI 11\n\n/**\n * RIL_REQUEST_HANGUP\n *\n * Hang up a specific line (like AT+CHLD=1x)\n *\n * After this HANGUP request returns, RIL should show the connection is NOT\n * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.\n *\n * \"data\" is an int *\n * (int *)data)[0] contains Connection index (value of 'x' in CHLD above)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  INVALID_STATE\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  INVALID_CALL_ID\n *  INVALID_ARGUMENTS\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_HANGUP 12\n\n/**\n * RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND\n *\n * Hang up waiting or held (like AT+CHLD=0)\n *\n * After this HANGUP request returns, RIL should show the connection is NOT\n * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_STATE\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  INVALID_CALL_ID\n *  NO_RESOURCES\n *  OPERATION_NOT_ALLOWED\n *  INVALID_ARGUMENTS\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13\n\n/**\n * RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND\n *\n * Hang up waiting or held (like AT+CHLD=1)\n *\n * After this HANGUP request returns, RIL should show the connection is NOT\n * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_STATE\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  OPERATION_NOT_ALLOWED\n *  INVALID_ARGUMENTS\n *  NO_RESOURCES\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14\n\n/**\n * RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE\n *\n * Switch waiting or holding call and active call (like AT+CHLD=2)\n *\n * State transitions should be is follows:\n *\n * If call 1 is waiting and call 2 is active, then if this re\n *\n *   BEFORE                               AFTER\n * Call 1   Call 2                 Call 1       Call 2\n * ACTIVE   HOLDING                HOLDING     ACTIVE\n * ACTIVE   WAITING                HOLDING     ACTIVE\n * HOLDING  WAITING                HOLDING     ACTIVE\n * ACTIVE   IDLE                   HOLDING     IDLE\n * IDLE     IDLE                   IDLE        IDLE\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_STATE\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_STATE\n *  INVALID_ARGUMENTS\n *  INVALID_CALL_ID\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE 15\n#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15\n\n/**\n * RIL_REQUEST_CONFERENCE\n *\n * Conference holding and active (like AT+CHLD=3)\n\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_STATE\n *  INVALID_CALL_ID\n *  INVALID_ARGUMENTS\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_CONFERENCE 16\n\n/**\n * RIL_REQUEST_UDUB\n *\n * Send UDUB (user determined used busy) to ringing or\n * waiting call answer)(RIL_BasicRequest r);\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_STATE\n *  NO_RESOURCES\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  OPERATION_NOT_ALLOWED\n *  INVALID_ARGUMENTS\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_UDUB 17\n\n/**\n * RIL_REQUEST_LAST_CALL_FAIL_CAUSE\n *\n * Requests the failure cause code for the most recently terminated call\n *\n * \"data\" is NULL\n * \"response\" is a \"int *\"\n * ((int *)response)[0] is RIL_LastCallFailCause.  GSM failure reasons are\n * mapped to cause codes defined in TS 24.008 Annex H where possible. CDMA\n * failure reasons are derived from the possible call failure scenarios\n * described in the \"CDMA IS-2000 Release A (C.S0005-A v6.0)\" standard.\n *\n * The implementation should return CALL_FAIL_ERROR_UNSPECIFIED for blocked\n * MO calls by restricted state (See RIL_UNSOL_RESTRICTED_STATE_CHANGED)\n *\n * If the implementation does not have access to the exact cause codes,\n * then it should return one of the values listed in RIL_LastCallFailCause,\n * as the UI layer needs to distinguish these cases for tone generation or\n * error notification.\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  NO_MEMORY\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE\n */\n#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18\n\n/**\n * RIL_REQUEST_SIGNAL_STRENGTH\n *\n * Requests current signal strength and associated information\n *\n * Must succeed if radio is on.\n *\n * \"data\" is NULL\n *\n * \"response\" is a const RIL_SignalStrength *\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n */\n#define RIL_REQUEST_SIGNAL_STRENGTH 19\n\n/**\n * RIL_REQUEST_VOICE_REGISTRATION_STATE\n *\n * Request current registration state\n *\n * \"data\" is NULL\n * \"response\" is a \"char **\"\n * ((const char **)response)[0] is registration state 0-6,\n *              0 - Not registered, MT is not currently searching\n *                  a new operator to register\n *              1 - Registered, home network\n *              2 - Not registered, but MT is currently searching\n *                  a new operator to register\n *              3 - Registration denied\n *              4 - Unknown\n *              5 - Registered, roaming\n *             10 - Same as 0, but indicates that emergency calls\n *                  are enabled.\n *             12 - Same as 2, but indicates that emergency calls\n *                  are enabled.\n *             13 - Same as 3, but indicates that emergency calls\n *                  are enabled.\n *             14 - Same as 4, but indicates that emergency calls\n *                  are enabled.\n *\n * ((const char **)response)[1] is LAC if registered on a GSM/WCDMA system or\n *                              NULL if not.Valid LAC are 0x0000 - 0xffff\n * ((const char **)response)[2] is CID if registered on a * GSM/WCDMA or\n *                              NULL if not.\n *                                 Valid CID are 0x00000000 - 0xffffffff\n *                                    In GSM, CID is Cell ID (see TS 27.007)\n *                                            in 16 bits\n *                                    In UMTS, CID is UMTS Cell Identity\n *                                             (see TS 25.331) in 28 bits\n * ((const char **)response)[3] indicates the available voice radio technology,\n *                              valid values as defined by RIL_RadioTechnology.\n * ((const char **)response)[4] is Base Station ID if registered on a CDMA\n *                              system or NULL if not.  Base Station ID in\n *                              decimal format\n * ((const char **)response)[5] is Base Station latitude if registered on a\n *                              CDMA system or NULL if not. Base Station\n *                              latitude is a decimal number as specified in\n *                              3GPP2 C.S0005-A v6.0. It is represented in\n *                              units of 0.25 seconds and ranges from -1296000\n *                              to 1296000, both values inclusive (corresponding\n *                              to a range of -90 to +90 degrees).\n * ((const char **)response)[6] is Base Station longitude if registered on a\n *                              CDMA system or NULL if not. Base Station\n *                              longitude is a decimal number as specified in\n *                              3GPP2 C.S0005-A v6.0. It is represented in\n *                              units of 0.25 seconds and ranges from -2592000\n *                              to 2592000, both values inclusive (corresponding\n *                              to a range of -180 to +180 degrees).\n * ((const char **)response)[7] is concurrent services support indicator if\n *                              registered on a CDMA system 0-1.\n *                                   0 - Concurrent services not supported,\n *                                   1 - Concurrent services supported\n * ((const char **)response)[8] is System ID if registered on a CDMA system or\n *                              NULL if not. Valid System ID are 0 - 32767\n * ((const char **)response)[9] is Network ID if registered on a CDMA system or\n *                              NULL if not. Valid System ID are 0 - 65535\n * ((const char **)response)[10] is the TSB-58 Roaming Indicator if registered\n *                               on a CDMA or EVDO system or NULL if not. Valid values\n *                               are 0-255.\n * ((const char **)response)[11] indicates whether the current system is in the\n *                               PRL if registered on a CDMA or EVDO system or NULL if\n *                               not. 0=not in the PRL, 1=in the PRL\n * ((const char **)response)[12] is the default Roaming Indicator from the PRL,\n *                               if registered on a CDMA or EVDO system or NULL if not.\n *                               Valid values are 0-255.\n * ((const char **)response)[13] if registration state is 3 (Registration\n *                               denied) this is an enumerated reason why\n *                               registration was denied.  See 3GPP TS 24.008,\n *                               10.5.3.6 and Annex G.\n *                                 0 - General\n *                                 1 - Authentication Failure\n *                                 2 - IMSI unknown in HLR\n *                                 3 - Illegal MS\n *                                 4 - Illegal ME\n *                                 5 - PLMN not allowed\n *                                 6 - Location area not allowed\n *                                 7 - Roaming not allowed\n *                                 8 - No Suitable Cells in this Location Area\n *                                 9 - Network failure\n *                                10 - Persistent location update reject\n *                                11 - PLMN not allowed\n *                                12 - Location area not allowed\n *                                13 - Roaming not allowed in this Location Area\n *                                15 - No Suitable Cells in this Location Area\n *                                17 - Network Failure\n *                                20 - MAC Failure\n *                                21 - Sync Failure\n *                                22 - Congestion\n *                                23 - GSM Authentication unacceptable\n *                                25 - Not Authorized for this CSG\n *                                32 - Service option not supported\n *                                33 - Requested service option not subscribed\n *                                34 - Service option temporarily out of order\n *                                38 - Call cannot be identified\n *                                48-63 - Retry upon entry into a new cell\n *                                95 - Semantically incorrect message\n *                                96 - Invalid mandatory information\n *                                97 - Message type non-existent or not implemented\n *                                98 - Message not compatible with protocol state\n *                                99 - Information element non-existent or not implemented\n *                               100 - Conditional IE error\n *                               101 - Message not compatible with protocol state\n *                               111 - Protocol error, unspecified\n * ((const char **)response)[14] is the Primary Scrambling Code of the current\n *                               cell as described in TS 25.331, in hexadecimal\n *                               format, or NULL if unknown or not registered\n *                               to a UMTS network.\n *\n * Please note that registration state 4 (\"unknown\") is treated\n * as \"out of service\" in the Android telephony system\n *\n * Registration state 3 can be returned if Location Update Reject\n * (with cause 17 - Network Failure) is received repeatedly from the network,\n * to facilitate \"managed roaming\"\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20\n\n/**\n * RIL_REQUEST_DATA_REGISTRATION_STATE\n *\n * Request current DATA registration state\n *\n * \"data\" is NULL\n * \"response\" is a \"char **\"\n * ((const char **)response)[0] is registration state 0-5 from TS 27.007 10.1.20 AT+CGREG\n * ((const char **)response)[1] is LAC if registered or NULL if not\n * ((const char **)response)[2] is CID if registered or NULL if not\n * ((const char **)response)[3] indicates the available data radio technology,\n *                              valid values as defined by RIL_RadioTechnology.\n * ((const char **)response)[4] if registration state is 3 (Registration\n *                               denied) this is an enumerated reason why\n *                               registration was denied.  See 3GPP TS 24.008,\n *                               Annex G.6 \"Additonal cause codes for GMM\".\n *      7 == GPRS services not allowed\n *      8 == GPRS services and non-GPRS services not allowed\n *      9 == MS identity cannot be derived by the network\n *      10 == Implicitly detached\n *      14 == GPRS services not allowed in this PLMN\n *      16 == MSC temporarily not reachable\n *      40 == No PDP context activated\n * ((const char **)response)[5] The maximum number of simultaneous Data Calls that can be\n *                              established using RIL_REQUEST_SETUP_DATA_CALL.\n *\n * The values at offsets 6..10 are optional LTE location information in decimal.\n * If a value is unknown that value may be NULL. If all values are NULL,\n * none need to be present.\n *  ((const char **)response)[6] is TAC, a 16-bit Tracking Area Code.\n *  ((const char **)response)[7] is CID, a 0-503 Physical Cell Identifier.\n *  ((const char **)response)[8] is ECI, a 28-bit E-UTRAN Cell Identifier.\n *  ((const char **)response)[9] is CSGID, a 27-bit Closed Subscriber Group Identity.\n *  ((const char **)response)[10] is TADV, a 6-bit timing advance value.\n *\n * LAC and CID are in hexadecimal format.\n * valid LAC are 0x0000 - 0xffff\n * valid CID are 0x00000000 - 0x0fffffff\n *\n * Please note that registration state 4 (\"unknown\") is treated\n * as \"out of service\" in the Android telephony system\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_DATA_REGISTRATION_STATE 21\n\n/**\n * RIL_REQUEST_OPERATOR\n *\n * Request current operator ONS or EONS\n *\n * \"data\" is NULL\n * \"response\" is a \"const char **\"\n * ((const char **)response)[0] is long alpha ONS or EONS\n *                                  or NULL if unregistered\n *\n * ((const char **)response)[1] is short alpha ONS or EONS\n *                                  or NULL if unregistered\n * ((const char **)response)[2] is 5 or 6 digit numeric code (MCC + MNC)\n *                                  or NULL if unregistered\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_OPERATOR 22\n\n/**\n * RIL_REQUEST_RADIO_POWER\n *\n * Toggle radio on and off (for \"airplane\" mode)\n * If the radio is is turned off/on the radio modem subsystem\n * is expected return to an initialized state. For instance,\n * any voice and data calls will be terminated and all associated\n * lists emptied.\n *\n * \"data\" is int *\n * ((int *)data)[0] is > 0 for \"Radio On\"\n * ((int *)data)[0] is == 0 for \"Radio Off\"\n *\n * \"response\" is NULL\n *\n * Turn radio on if \"on\" > 0\n * Turn radio off if \"on\" == 0\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_RADIO_POWER 23\n\n/**\n * RIL_REQUEST_DTMF\n *\n * Send a DTMF tone\n *\n * If the implementation is currently playing a tone requested via\n * RIL_REQUEST_DTMF_START, that tone should be cancelled and the new tone\n * should be played instead\n *\n * \"data\" is a char * containing a single character with one of 12 values: 0-9,*,#\n * \"response\" is NULL\n *\n * FIXME should this block/mute microphone?\n * How does this interact with local DTMF feedback?\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  NO_RESOURCES\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_DTMF_STOP, RIL_REQUEST_DTMF_START\n *\n */\n#define RIL_REQUEST_DTMF 24\n\n/**\n * RIL_REQUEST_SEND_SMS\n *\n * Send an SMS message\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is SMSC address in GSM BCD format prefixed\n *      by a length byte (as expected by TS 27.005) or NULL for default SMSC\n * ((const char **)data)[1] is SMS in PDU format as an ASCII hex string\n *      less the SMSC address\n *      TP-Layer-Length is be \"strlen(((const char **)data)[1])/2\"\n *\n * \"response\" is a const RIL_SMS_Response *\n *\n * Based on the return error, caller decides to resend if sending sms\n * fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332)\n * and GENERIC_FAILURE means no retry (i.e. error cause is 500)\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SMS_SEND_FAIL_RETRY\n *  FDN_CHECK_FAILURE\n *  NETWORK_REJECT\n *  INVALID_STATE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  INVALID_SMS_FORMAT\n *  SYSTEM_ERR\n *  ENCODING_ERR\n *  INVALID_SMSC_ADDRESS\n *  MODEM_ERR\n *  NETWORK_ERR\n *  MODE_NOT_SUPPORTED\n *  GENERIC_FAILURE\n *\n * FIXME how do we specify TP-Message-Reference if we need to resend?\n */\n#define RIL_REQUEST_SEND_SMS 25\n\n\n/**\n * RIL_REQUEST_SEND_SMS_EXPECT_MORE\n *\n * Send an SMS message. Identical to RIL_REQUEST_SEND_SMS,\n * except that more messages are expected to be sent soon. If possible,\n * keep SMS relay protocol link open (eg TS 27.005 AT+CMMS command)\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is SMSC address in GSM BCD format prefixed\n *      by a length byte (as expected by TS 27.005) or NULL for default SMSC\n * ((const char **)data)[1] is SMS in PDU format as an ASCII hex string\n *      less the SMSC address\n *      TP-Layer-Length is be \"strlen(((const char **)data)[1])/2\"\n *\n * \"response\" is a const RIL_SMS_Response *\n *\n * Based on the return error, caller decides to resend if sending sms\n * fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332)\n * and GENERIC_FAILURE means no retry (i.e. error cause is 500)\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SMS_SEND_FAIL_RETRY\n *  NETWORK_REJECT\n *  INVALID_STATE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  INVALID_SMS_FORMAT\n *  SYSTEM_ERR\n *  REQUEST_RATE_LIMITED\n *  FDN_CHECK_FAILURE\n *  MODEM_ERR\n *  NETWORK_ERR\n *  ENCODING_ERR\n *  INVALID_SMSC_ADDRESS\n *  MODE_NOT_SUPPORTED\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26\n\n\n/**\n * RIL_REQUEST_SETUP_DATA_CALL\n *\n * Setup a packet data connection. If RIL_Data_Call_Response_v6.status\n * return success it is added to the list of data calls and a\n * RIL_UNSOL_DATA_CALL_LIST_CHANGED is sent. The call remains in the\n * list until RIL_REQUEST_DEACTIVATE_DATA_CALL is issued or the\n * radio is powered off/on. This list is returned by RIL_REQUEST_DATA_CALL_LIST\n * and RIL_UNSOL_DATA_CALL_LIST_CHANGED.\n *\n * The RIL is expected to:\n *  - Create one data call context.\n *  - Create and configure a dedicated interface for the context\n *  - The interface must be point to point.\n *  - The interface is configured with one or more addresses and\n *    is capable of sending and receiving packets. The prefix length\n *    of the addresses must be /32 for IPv4 and /128 for IPv6.\n *  - Must NOT change the linux routing table.\n *  - Support up to RIL_REQUEST_DATA_REGISTRATION_STATE response[5]\n *    number of simultaneous data call contexts.\n *\n * \"data\" is a const char **\n * ((const char **)data)[0] Radio technology to use: 0-CDMA, 1-GSM/UMTS, 2...\n *                          for values above 2 this is RIL_RadioTechnology + 2.\n * ((const char **)data)[1] is a RIL_DataProfile (support is optional)\n * ((const char **)data)[2] is the APN to connect to if radio technology is GSM/UMTS. This APN will\n *                          override the one in the profile. NULL indicates no APN overrride.\n * ((const char **)data)[3] is the username for APN, or NULL\n * ((const char **)data)[4] is the password for APN, or NULL\n * ((const char **)data)[5] is the PAP / CHAP auth type. Values:\n *                          0 => PAP and CHAP is never performed.\n *                          1 => PAP may be performed; CHAP is never performed.\n *                          2 => CHAP may be performed; PAP is never performed.\n *                          3 => PAP / CHAP may be performed - baseband dependent.\n * ((const char **)data)[6] is the connection type to request must be one of the\n *                          PDP_type values in TS 27.007 section 10.1.1.\n *                          For example, \"IP\", \"IPV6\", \"IPV4V6\", or \"PPP\".\n * ((const char **)data)[7] Optional connection property parameters, format to be defined.\n *\n * \"response\" is a RIL_Data_Call_Response_v11\n *\n * FIXME may need way to configure QoS settings\n *\n * Valid errors:\n *  SUCCESS should be returned on both success and failure of setup with\n *  the RIL_Data_Call_Response_v6.status containing the actual status.\n *  For all other errors the RIL_Data_Call_Resonse_v6 is ignored.\n *\n *  Other errors could include:\n *    RADIO_NOT_AVAILABLE, GENERIC_FAILURE, OP_NOT_ALLOWED_BEFORE_REG_TO_NW,\n *    OP_NOT_ALLOWED_DURING_VOICE_CALL and REQUEST_NOT_SUPPORTED.\n *\n * See also: RIL_REQUEST_DEACTIVATE_DATA_CALL\n */\n#define RIL_REQUEST_SETUP_DATA_CALL 27\n\n\n/**\n * RIL_REQUEST_SIM_IO\n *\n * Request SIM I/O operation.\n * This is similar to the TS 27.007 \"restricted SIM\" operation\n * where it assumes all of the EF selection will be done by the\n * callee.\n *\n * \"data\" is a const RIL_SIM_IO_v6 *\n * Please note that RIL_SIM_IO has a \"PIN2\" field which may be NULL,\n * or may specify a PIN2 for operations that require a PIN2 (eg\n * updating FDN records)\n *\n * \"response\" is a const RIL_SIM_IO_Response *\n *\n * Arguments and responses that are unused for certain\n * values of \"command\" should be ignored or set to NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *  SIM_PIN2\n *  SIM_PUK2\n */\n#define RIL_REQUEST_SIM_IO 28\n\n/**\n * RIL_REQUEST_SEND_USSD\n *\n * Send a USSD message\n *\n * If a USSD session already exists, the message should be sent in the\n * context of that session. Otherwise, a new session should be created.\n *\n * The network reply should be reported via RIL_UNSOL_ON_USSD\n *\n * Only one USSD session may exist at a time, and the session is assumed\n * to exist until:\n *   a) The android system invokes RIL_REQUEST_CANCEL_USSD\n *   b) The implementation sends a RIL_UNSOL_ON_USSD with a type code\n *      of \"0\" (USSD-Notify/no further action) or \"2\" (session terminated)\n *\n * \"data\" is a const char * containing the USSD request in UTF-8 format\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  FDN_CHECK_FAILURE\n *  USSD_MODIFIED_TO_DIAL\n *  USSD_MODIFIED_TO_SS\n *  USSD_MODIFIED_TO_USSD\n *  SIM_BUSY\n *  OPERATION_NOT_ALLOWED\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  ABORTED\n *  SYSTEM_ERR\n *  INVALID_STATE\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_CANCEL_USSD, RIL_UNSOL_ON_USSD\n */\n\n#define RIL_REQUEST_SEND_USSD 29\n\n/**\n * RIL_REQUEST_CANCEL_USSD\n *\n * Cancel the current USSD session if one exists\n *\n * \"data\" is null\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SIM_BUSY\n *  OPERATION_NOT_ALLOWED\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  INVALID_STATE\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_CANCEL_USSD 30\n\n/**\n * RIL_REQUEST_GET_CLIR\n *\n * Gets current CLIR status\n * \"data\" is NULL\n * \"response\" is int *\n * ((int *)data)[0] is \"n\" parameter from TS 27.007 7.7\n * ((int *)data)[1] is \"m\" parameter from TS 27.007 7.7\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  FDN_CHECK_FAILURE\n *  SYSTEM_ERR\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_GET_CLIR 31\n\n/**\n * RIL_REQUEST_SET_CLIR\n *\n * \"data\" is int *\n * ((int *)data)[0] is \"n\" parameter from TS 27.007 7.7\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  INVALID_ARGUMENTS\n *  SYSTEM_ERR\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SET_CLIR 32\n\n/**\n * RIL_REQUEST_QUERY_CALL_FORWARD_STATUS\n *\n * \"data\" is const RIL_CallForwardInfo *\n *\n * \"response\" is const RIL_CallForwardInfo **\n * \"response\" points to an array of RIL_CallForwardInfo *'s, one for\n * each distinct registered phone number.\n *\n * For example, if data is forwarded to +18005551212 and voice is forwarded\n * to +18005559999, then two separate RIL_CallForwardInfo's should be returned\n *\n * If, however, both data and voice are forwarded to +18005551212, then\n * a single RIL_CallForwardInfo can be returned with the service class\n * set to \"data + voice = 3\")\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  FDN_CHECK_FAILURE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33\n\n\n/**\n * RIL_REQUEST_SET_CALL_FORWARD\n *\n * Configure call forward rule\n *\n * \"data\" is const RIL_CallForwardInfo *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_STATE\n *  FDN_CHECK_FAILURE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SET_CALL_FORWARD 34\n\n\n/**\n * RIL_REQUEST_QUERY_CALL_WAITING\n *\n * Query current call waiting state\n *\n * \"data\" is const int *\n * ((const int *)data)[0] is the TS 27.007 service class to query.\n * \"response\" is a const int *\n * ((const int *)response)[0] is 0 for \"disabled\" and 1 for \"enabled\"\n *\n * If ((const int *)response)[0] is = 1, then ((const int *)response)[1]\n * must follow, with the TS 27.007 service class bit vector of services\n * for which call waiting is enabled.\n *\n * For example, if ((const int *)response)[0]  is 1 and\n * ((const int *)response)[1] is 3, then call waiting is enabled for data\n * and voice and disabled for everything else\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  FDN_CHECK_FAILURE\n *  INVALID_ARGUMENTS\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_QUERY_CALL_WAITING 35\n\n\n/**\n * RIL_REQUEST_SET_CALL_WAITING\n *\n * Configure current call waiting state\n *\n * \"data\" is const int *\n * ((const int *)data)[0] is 0 for \"disabled\" and 1 for \"enabled\"\n * ((const int *)data)[1] is the TS 27.007 service class bit vector of\n *                           services to modify\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_STATE\n *  FDN_CHECK_FAILURE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SET_CALL_WAITING 36\n\n/**\n * RIL_REQUEST_SMS_ACKNOWLEDGE\n *\n * Acknowledge successful or failed receipt of SMS previously indicated\n * via RIL_UNSOL_RESPONSE_NEW_SMS\n *\n * \"data\" is int *\n * ((int *)data)[0] is 1 on successful receipt\n *                  (basically, AT+CNMA=1 from TS 27.005\n *                  is 0 on failed receipt\n *                  (basically, AT+CNMA=2 from TS 27.005)\n * ((int *)data)[1] if data[0] is 0, this contains the failure cause as defined\n *                  in TS 23.040, 9.2.3.22. Currently only 0xD3 (memory\n *                  capacity exceeded) and 0xFF (unspecified error) are\n *                  reported.\n *\n * \"response\" is NULL\n *\n * FIXME would like request that specified RP-ACK/RP-ERROR PDU\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SMS_ACKNOWLEDGE  37\n\n/**\n * RIL_REQUEST_GET_IMEI - DEPRECATED\n *\n * Get the device IMEI, including check digit\n *\n * The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY\n * Valid when RadioState is not RADIO_STATE_UNAVAILABLE\n *\n * \"data\" is NULL\n * \"response\" is a const char * containing the IMEI\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_GET_IMEI 38\n\n/**\n * RIL_REQUEST_GET_IMEISV - DEPRECATED\n *\n * Get the device IMEISV, which should be two decimal digits\n *\n * The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY\n * Valid when RadioState is not RADIO_STATE_UNAVAILABLE\n *\n * \"data\" is NULL\n * \"response\" is a const char * containing the IMEISV\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_GET_IMEISV 39\n\n\n/**\n * RIL_REQUEST_ANSWER\n *\n * Answer incoming call\n *\n * Will not be called for WAITING calls.\n * RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE will be used in this case\n * instead\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_STATE\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_ANSWER 40\n\n/**\n * RIL_REQUEST_DEACTIVATE_DATA_CALL\n *\n * Deactivate packet data connection and remove from the\n * data call list if SUCCESS is returned. Any other return\n * values should also try to remove the call from the list,\n * but that may not be possible. In any event a\n * RIL_REQUEST_RADIO_POWER off/on must clear the list. An\n * RIL_UNSOL_DATA_CALL_LIST_CHANGED is not expected to be\n * issued because of an RIL_REQUEST_DEACTIVATE_DATA_CALL.\n *\n * \"data\" is const char **\n * ((char**)data)[0] indicating CID\n * ((char**)data)[1] indicating Disconnect Reason\n *                   0 => No specific reason specified\n *                   1 => Radio shutdown requested\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_SETUP_DATA_CALL\n */\n#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41\n\n/**\n * RIL_REQUEST_QUERY_FACILITY_LOCK\n *\n * Query the status of a facility lock state\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is the facility string code from TS 27.007 7.4\n *                      (eg \"AO\" for BAOC, \"SC\" for SIM lock)\n * ((const char **)data)[1] is the password, or \"\" if not required\n * ((const char **)data)[2] is the TS 27.007 service class bit vector of\n *                           services to query\n * ((const char **)data)[3] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n *                            This is only applicable in the case of Fixed Dialing Numbers\n *                            (FDN) requests.\n *\n * \"response\" is an int *\n * ((const int *)response) 0 is the TS 27.007 service class bit vector of\n *                           services for which the specified barring facility\n *                           is active. \"0\" means \"disabled for all\"\n *\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  INTERNAL_ERR\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  FDN_CHECK_FAILURE\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_QUERY_FACILITY_LOCK 42\n\n/**\n * RIL_REQUEST_SET_FACILITY_LOCK\n *\n * Enable/disable one facility lock\n *\n * \"data\" is const char **\n *\n * ((const char **)data)[0] = facility string code from TS 27.007 7.4\n * (eg \"AO\" for BAOC)\n * ((const char **)data)[1] = \"0\" for \"unlock\" and \"1\" for \"lock\"\n * ((const char **)data)[2] = password\n * ((const char **)data)[3] = string representation of decimal TS 27.007\n *                            service class bit vector. Eg, the string\n *                            \"1\" means \"set this facility for voice services\"\n * ((const char **)data)[4] = AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.\n *                            This is only applicable in the case of Fixed Dialing Numbers\n *                            (FDN) requests.\n *\n * \"response\" is int *\n * ((int *)response)[0] is the number of retries remaining, or -1 if unknown\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  INVALID_ARGUMENTS\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  MODEM_ERR\n *  INVALID_STATE\n *  FDN_CHECK_FAILURE\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_SET_FACILITY_LOCK 43\n\n/**\n * RIL_REQUEST_CHANGE_BARRING_PASSWORD\n *\n * Change call barring facility password\n *\n * \"data\" is const char **\n *\n * ((const char **)data)[0] = facility string code from TS 27.007 7.4\n * (eg \"AO\" for BAOC)\n * ((const char **)data)[1] = old password\n * ((const char **)data)[2] = new password\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  SYSTEM_ERR\n *  FDN_CHECK_FAILURE\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44\n\n/**\n * RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE\n *\n * Query current network selectin mode\n *\n * \"data\" is NULL\n *\n * \"response\" is int *\n * ((const int *)response)[0] is\n *     0 for automatic selection\n *     1 for manual selection\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45\n\n/**\n * RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC\n *\n * Specify that the network should be selected automatically\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * This request must not respond until the new operator is selected\n * and registered\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  ILLEGAL_SIM_OR_ME\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n *\n * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and\n *       no retries needed, such as illegal SIM or ME.\n *       Returns GENERIC_FAILURE for all other causes that might be\n *       fixed by retries.\n *\n */\n#define RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC 46\n\n/**\n * RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL\n *\n * Manually select a specified network.\n *\n * \"data\" is const char * specifying MCCMNC of network to select (eg \"310170\")\n * \"response\" is NULL\n *\n * This request must not respond until the new operator is selected\n * and registered\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  ILLEGAL_SIM_OR_ME\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n *\n * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and\n *       no retries needed, such as illegal SIM or ME.\n *       Returns GENERIC_FAILURE for all other causes that might be\n *       fixed by retries.\n *\n */\n#define RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL 47\n\n/**\n * RIL_REQUEST_QUERY_AVAILABLE_NETWORKS\n *\n * Scans for available networks\n *\n * \"data\" is NULL\n * \"response\" is const char ** that should be an array of n*4 strings, where\n *    n is the number of available networks\n * For each available network:\n *\n * ((const char **)response)[n+0] is long alpha ONS or EONS\n * ((const char **)response)[n+1] is short alpha ONS or EONS\n * ((const char **)response)[n+2] is 5 or 6 digit numeric code (MCC + MNC)\n * ((const char **)response)[n+3] is a string value of the status:\n *           \"unknown\"\n *           \"available\"\n *           \"current\"\n *           \"forbidden\"\n *\n * This request must not respond until the new operator is selected\n * and registered\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48\n\n/**\n * RIL_REQUEST_DTMF_START\n *\n * Start playing a DTMF tone. Continue playing DTMF tone until\n * RIL_REQUEST_DTMF_STOP is received\n *\n * If a RIL_REQUEST_DTMF_START is received while a tone is currently playing,\n * it should cancel the previous tone and play the new one.\n *\n * \"data\" is a char *\n * ((char *)data)[0] is a single character with one of 12 values: 0-9,*,#\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  NO_RESOURCES\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_STOP\n */\n#define RIL_REQUEST_DTMF_START 49\n\n/**\n * RIL_REQUEST_DTMF_STOP\n *\n * Stop playing a currently playing DTMF tone.\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  OPERATION_NOT_ALLOWED\n *  NO_RESOURCES\n *  NO_MEMORY\n *  INVALID_ARGUMENTS\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_START\n */\n#define RIL_REQUEST_DTMF_STOP 50\n\n/**\n * RIL_REQUEST_BASEBAND_VERSION\n *\n * Return string value indicating baseband version, eg\n * response from AT+CGMR\n *\n * \"data\" is NULL\n * \"response\" is const char * containing version string for log reporting\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  EMPTY_RECORD\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_BASEBAND_VERSION 51\n\n/**\n * RIL_REQUEST_SEPARATE_CONNECTION\n *\n * Separate a party from a multiparty call placing the multiparty call\n * (less the specified party) on hold and leaving the specified party\n * as the only other member of the current (active) call\n *\n * Like AT+CHLD=2x\n *\n * See TS 22.084 1.3.8.2 (iii)\n * TS 22.030 6.5.5 \"Entering \"2X followed by send\"\n * TS 27.007 \"AT+CHLD=2x\"\n *\n * \"data\" is an int *\n * (int *)data)[0] contains Connection index (value of 'x' in CHLD above) \"response\" is NULL\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_ARGUMENTS\n *  INVALID_STATE\n *  NO_RESOURCES\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  INVALID_STATE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SEPARATE_CONNECTION 52\n\n\n/**\n * RIL_REQUEST_SET_MUTE\n *\n * Turn on or off uplink (microphone) mute.\n *\n * Will only be sent while voice call is active.\n * Will always be reset to \"disable mute\" when a new voice call is initiated\n *\n * \"data\" is an int *\n * (int *)data)[0] is 1 for \"enable mute\" and 0 for \"disable mute\"\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_SET_MUTE 53\n\n/**\n * RIL_REQUEST_GET_MUTE\n *\n * Queries the current state of the uplink mute setting\n *\n * \"data\" is NULL\n * \"response\" is an int *\n * (int *)response)[0] is 1 for \"mute enabled\" and 0 for \"mute disabled\"\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  SS_MODIFIED_TO_DIAL\n *  SS_MODIFIED_TO_USSD\n *  SS_MODIFIED_TO_SS\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_GET_MUTE 54\n\n/**\n * RIL_REQUEST_QUERY_CLIP\n *\n * Queries the status of the CLIP supplementary service\n *\n * (for MMI code \"*#30#\")\n *\n * \"data\" is NULL\n * \"response\" is an int *\n * (int *)response)[0] is 1 for \"CLIP provisioned\"\n *                           and 0 for \"CLIP not provisioned\"\n *                           and 2 for \"unknown, e.g. no network etc\"\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  FDN_CHECK_FAILURE\n *  GENERIC_FAILURE\n */\n\n#define RIL_REQUEST_QUERY_CLIP 55\n\n/**\n * RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE - Deprecated use the status\n * field in RIL_Data_Call_Response_v6.\n *\n * Requests the failure cause code for the most recently failed PDP\n * context or CDMA data connection active\n * replaces RIL_REQUEST_LAST_PDP_FAIL_CAUSE\n *\n * \"data\" is NULL\n *\n * \"response\" is a \"int *\"\n * ((int *)response)[0] is an integer cause code defined in TS 24.008\n *   section 6.1.3.1.3 or close approximation\n *\n * If the implementation does not have access to the exact cause codes,\n * then it should return one of the values listed in\n * RIL_DataCallFailCause, as the UI layer needs to distinguish these\n * cases for error notification\n * and potential retries.\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_LAST_CALL_FAIL_CAUSE\n *\n * Deprecated use the status field in RIL_Data_Call_Response_v6.\n */\n\n#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56\n\n/**\n * RIL_REQUEST_DATA_CALL_LIST\n *\n * Returns the data call list. An entry is added when a\n * RIL_REQUEST_SETUP_DATA_CALL is issued and removed on a\n * RIL_REQUEST_DEACTIVATE_DATA_CALL. The list is emptied\n * when RIL_REQUEST_RADIO_POWER off/on is issued.\n *\n * \"data\" is NULL\n * \"response\" is an array of RIL_Data_Call_Response_v6\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *\n * See also: RIL_UNSOL_DATA_CALL_LIST_CHANGED\n */\n\n#define RIL_REQUEST_DATA_CALL_LIST 57\n\n/**\n * RIL_REQUEST_RESET_RADIO - DEPRECATED\n *\n * Request a radio reset. The RIL implementation may postpone\n * the reset until after this request is responded to if the baseband\n * is presently busy.\n *\n * The request is DEPRECATED, use RIL_REQUEST_RADIO_POWER\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  REQUEST_NOT_SUPPORTED\n */\n\n#define RIL_REQUEST_RESET_RADIO 58\n\n/**\n * RIL_REQUEST_OEM_HOOK_RAW\n *\n * This request reserved for OEM-specific uses. It passes raw byte arrays\n * back and forth.\n *\n * It can be invoked on the Java side from\n * com.android.internal.telephony.Phone.invokeOemRilRequestRaw()\n *\n * \"data\" is a char * of bytes copied from the byte[] data argument in java\n * \"response\" is a char * of bytes that will returned via the\n * caller's \"response\" Message here:\n * (byte[])(((AsyncResult)response.obj).result)\n *\n * An error response here will result in\n * (((AsyncResult)response.obj).result) == null and\n * (((AsyncResult)response.obj).exception) being an instance of\n * com.android.internal.telephony.gsm.CommandException\n *\n * Valid errors:\n *  All\n */\n\n#define RIL_REQUEST_OEM_HOOK_RAW 59\n\n/**\n * RIL_REQUEST_OEM_HOOK_STRINGS\n *\n * This request reserved for OEM-specific uses. It passes strings\n * back and forth.\n *\n * It can be invoked on the Java side from\n * com.android.internal.telephony.Phone.invokeOemRilRequestStrings()\n *\n * \"data\" is a const char **, representing an array of null-terminated UTF-8\n * strings copied from the \"String[] strings\" argument to\n * invokeOemRilRequestStrings()\n *\n * \"response\" is a const char **, representing an array of null-terminated UTF-8\n * stings that will be returned via the caller's response message here:\n *\n * (String[])(((AsyncResult)response.obj).result)\n *\n * An error response here will result in\n * (((AsyncResult)response.obj).result) == null and\n * (((AsyncResult)response.obj).exception) being an instance of\n * com.android.internal.telephony.gsm.CommandException\n *\n * Valid errors:\n *  All\n */\n\n#define RIL_REQUEST_OEM_HOOK_STRINGS 60\n\n/**\n * RIL_REQUEST_SCREEN_STATE\n *\n * Indicates the current state of the screen.  When the screen is off, the\n * RIL should notify the baseband to suppress certain notifications (eg,\n * signal strength and changes in LAC/CID or BID/SID/NID/latitude/longitude)\n * in an effort to conserve power.  These notifications should resume when the\n * screen is on.\n *\n * \"data\" is int *\n * ((int *)data)[0] is == 1 for \"Screen On\"\n * ((int *)data)[0] is == 0 for \"Screen Off\"\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SCREEN_STATE 61\n\n\n/**\n * RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION\n *\n * Enables/disables supplementary service related notifications\n * from the network.\n *\n * Notifications are reported via RIL_UNSOL_SUPP_SVC_NOTIFICATION.\n *\n * \"data\" is int *\n * ((int *)data)[0] is == 1 for notifications enabled\n * ((int *)data)[0] is == 0 for notifications disabled\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SIM_BUSY\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  GENERIC_FAILURE\n *\n * See also: RIL_UNSOL_SUPP_SVC_NOTIFICATION.\n */\n#define RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION 62\n\n/**\n * RIL_REQUEST_WRITE_SMS_TO_SIM\n *\n * Stores a SMS message to SIM memory.\n *\n * \"data\" is RIL_SMS_WriteArgs *\n *\n * \"response\" is int *\n * ((const int *)response)[0] is the record index where the message is stored.\n *\n * Valid errors:\n *  SUCCESS\n *  SIM_FULL\n *  INVALID_ARGUMENTS\n *  INVALID_SMS_FORMAT\n *  INTERNAL_ERR\n *  MODEM_ERR\n *  ENCODING_ERR\n *  NO_MEMORY\n *  NO_RESOURCES\n *  INVALID_MODEM_STATE\n *  MODE_NOT_SUPPORTED\n *  INVALID_SMSC_ADDRESS\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_WRITE_SMS_TO_SIM 63\n\n/**\n * RIL_REQUEST_DELETE_SMS_ON_SIM\n *\n * Deletes a SMS message from SIM memory.\n *\n * \"data\" is int  *\n * ((int *)data)[0] is the record index of the message to delete.\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  SIM_FULL\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  NO_SUCH_ENTRY\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_DELETE_SMS_ON_SIM 64\n\n/**\n * RIL_REQUEST_SET_BAND_MODE\n *\n * Assign a specified band for RF configuration.\n *\n * \"data\" is int *\n * ((int *)data)[0] is a RIL_RadioBandMode\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE\n */\n#define RIL_REQUEST_SET_BAND_MODE 65\n\n/**\n * RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE\n *\n * Query the list of band mode supported by RF.\n *\n * \"data\" is NULL\n *\n * \"response\" is int *\n * \"response\" points to an array of int's, the int[0] is the size of array;\n * subsequent values are a list of RIL_RadioBandMode listing supported modes.\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_SET_BAND_MODE\n */\n#define RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE 66\n\n/**\n * RIL_REQUEST_STK_GET_PROFILE\n *\n * Requests the profile of SIM tool kit.\n * The profile indicates the SAT/USAT features supported by ME.\n * The SAT/USAT features refer to 3GPP TS 11.14 and 3GPP TS 31.111\n *\n * \"data\" is NULL\n *\n * \"response\" is a const char * containing SAT/USAT profile\n * in hexadecimal format string starting with first byte of terminal profile\n *\n * Valid errors:\n *  RIL_E_SUCCESS\n *  RIL_E_RADIO_NOT_AVAILABLE (radio resetting)\n *  RIL_E_GENERIC_FAILURE\n */\n#define RIL_REQUEST_STK_GET_PROFILE 67\n\n/**\n * RIL_REQUEST_STK_SET_PROFILE\n *\n * Download the STK terminal profile as part of SIM initialization\n * procedure\n *\n * \"data\" is a const char * containing SAT/USAT profile\n * in hexadecimal format string starting with first byte of terminal profile\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  RIL_E_SUCCESS\n *  RIL_E_RADIO_NOT_AVAILABLE (radio resetting)\n *  RIL_E_GENERIC_FAILURE\n */\n#define RIL_REQUEST_STK_SET_PROFILE 68\n\n/**\n * RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND\n *\n * Requests to send a SAT/USAT envelope command to SIM.\n * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111\n *\n * \"data\" is a const char * containing SAT/USAT command\n * in hexadecimal format string starting with command tag\n *\n * \"response\" is a const char * containing SAT/USAT response\n * in hexadecimal format string starting with first byte of response\n * (May be NULL)\n *\n * Valid errors:\n *  RIL_E_SUCCESS\n *  RIL_E_RADIO_NOT_AVAILABLE (radio resetting)\n *  SIM_BUSY\n *  OPERATION_NOT_ALLOWED\n *  RIL_E_GENERIC_FAILURE\n */\n#define RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND 69\n\n/**\n * RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE\n *\n * Requests to send a terminal response to SIM for a received\n * proactive command\n *\n * \"data\" is a const char * containing SAT/USAT response\n * in hexadecimal format string starting with first byte of response data\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  RIL_E_SUCCESS\n *  RIL_E_RADIO_NOT_AVAILABLE (radio resetting)\n *  RIL_E_OPERATION_NOT_ALLOWED\n *  RIL_E_GENERIC_FAILURE\n */\n#define RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE 70\n\n/**\n * RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM\n *\n * When STK application gets RIL_UNSOL_STK_CALL_SETUP, the call actually has\n * been initialized by ME already. (We could see the call has been in the 'call\n * list') So, STK application needs to accept/reject the call according as user\n * operations.\n *\n * \"data\" is int *\n * ((int *)data)[0] is > 0 for \"accept\" the call setup\n * ((int *)data)[0] is == 0 for \"reject\" the call setup\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  RIL_E_SUCCESS\n *  RIL_E_RADIO_NOT_AVAILABLE (radio resetting)\n *  RIL_E_OPERATION_NOT_ALLOWED\n *  RIL_E_GENERIC_FAILURE\n */\n#define RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM 71\n\n/**\n * RIL_REQUEST_EXPLICIT_CALL_TRANSFER\n *\n * Connects the two calls and disconnects the subscriber from both calls.\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  INVALID_STATE\n *  NO_RESOURCES\n *  NO_MEMORY\n *  INVALID_ARGUMENTS\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  INVALID_STATE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_EXPLICIT_CALL_TRANSFER 72\n\n/**\n * RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE\n *\n * Requests to set the preferred network type for searching and registering\n * (CS/PS domain, RAT, and operation mode)\n *\n * \"data\" is int * which is RIL_PreferredNetworkType\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  OPERATION_NOT_ALLOWED\n *  MODE_NOT_SUPPORTED\n */\n#define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73\n\n/**\n * RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE\n *\n * Query the preferred network type (CS/PS domain, RAT, and operation mode)\n * for searching and registering\n *\n * \"data\" is NULL\n *\n * \"response\" is int *\n * ((int *)reponse)[0] is == RIL_PreferredNetworkType\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE\n */\n#define RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE 74\n\n/**\n * RIL_REQUEST_NEIGHBORING_CELL_IDS\n *\n * Request neighboring cell id in GSM network\n *\n * \"data\" is NULL\n * \"response\" must be a \" const RIL_NeighboringCell** \"\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75\n\n/**\n * RIL_REQUEST_SET_LOCATION_UPDATES\n *\n * Enables/disables network state change notifications due to changes in\n * LAC and/or CID (for GSM) or BID/SID/NID/latitude/longitude (for CDMA).\n * Basically +CREG=2 vs. +CREG=1 (TS 27.007).\n *\n * Note:  The RIL implementation should default to \"updates enabled\"\n * when the screen is on and \"updates disabled\" when the screen is off.\n *\n * \"data\" is int *\n * ((int *)data)[0] is == 1 for updates enabled (+CREG=2)\n * ((int *)data)[0] is == 0 for updates disabled (+CREG=1)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n * See also: RIL_REQUEST_SCREEN_STATE, RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED\n */\n#define RIL_REQUEST_SET_LOCATION_UPDATES 76\n\n/**\n * RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE\n *\n * Request to set the location where the CDMA subscription shall\n * be retrieved\n *\n * \"data\" is int *\n * ((int *)data)[0] is == RIL_CdmaSubscriptionSource\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *  SIM_ABSENT\n *  SUBSCRIPTION_NOT_AVAILABLE\n *\n * See also: RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE\n */\n#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE 77\n\n/**\n * RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE\n *\n * Request to set the roaming preferences in CDMA\n *\n * \"data\" is int *\n * ((int *)data)[0] is == 0 for Home Networks only, as defined in PRL\n * ((int *)data)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL\n * ((int *)data)[0] is == 2 for Roaming on Any Network, as defined in the PRL\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78\n\n/**\n * RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE\n *\n * Request the actual setting of the roaming preferences in CDMA in the modem\n *\n * \"data\" is NULL\n *\n * \"response\" is int *\n * ((int *)response)[0] is == 0 for Home Networks only, as defined in PRL\n * ((int *)response)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL\n * ((int *)response)[0] is == 2 for Roaming on Any Network, as defined in the PRL\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79\n\n/**\n * RIL_REQUEST_SET_TTY_MODE\n *\n * Request to set the TTY mode\n *\n * \"data\" is int *\n * ((int *)data)[0] is == 0 for TTY off\n * ((int *)data)[0] is == 1 for TTY Full\n * ((int *)data)[0] is == 2 for TTY HCO (hearing carryover)\n * ((int *)data)[0] is == 3 for TTY VCO (voice carryover)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMOR\n *  INVALID_ARGUMENTS\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORYY\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SET_TTY_MODE 80\n\n/**\n * RIL_REQUEST_QUERY_TTY_MODE\n *\n * Request the setting of TTY mode\n *\n * \"data\" is NULL\n *\n * \"response\" is int *\n * ((int *)response)[0] is == 0 for TTY off\n * ((int *)response)[0] is == 1 for TTY Full\n * ((int *)response)[0] is == 2 for TTY HCO (hearing carryover)\n * ((int *)response)[0] is == 3 for TTY VCO (voice carryover)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  INVALID_ARGUMENTS\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_QUERY_TTY_MODE 81\n\n/**\n * RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE\n *\n * Request to set the preferred voice privacy mode used in voice\n * scrambling\n *\n * \"data\" is int *\n * ((int *)data)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask)\n * ((int *)data)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  INVALID_CALL_ID\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82\n\n/**\n * RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE\n *\n * Request the setting of preferred voice privacy mode\n *\n * \"data\" is NULL\n *\n * \"response\" is int *\n * ((int *)response)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask)\n * ((int *)response)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  NO_MEMORY\n *  INVALID_ARGUMENTS\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83\n\n/**\n * RIL_REQUEST_CDMA_FLASH\n *\n * Send FLASH\n *\n * \"data\" is const char *\n * ((const char *)data)[0] is a FLASH string\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  INVALID_STATE\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_FLASH 84\n\n/**\n * RIL_REQUEST_CDMA_BURST_DTMF\n *\n * Send DTMF string\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is a DTMF string\n * ((const char **)data)[1] is the DTMF ON length in milliseconds, or 0 to use\n *                          default\n * ((const char **)data)[2] is the DTMF OFF length in milliseconds, or 0 to use\n *                          default\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INTERNAL_ERR\n *  INVALID_CALL_ID\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_BURST_DTMF 85\n\n/**\n * RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY\n *\n * Takes a 26 digit string (20 digit AKEY + 6 digit checksum).\n * If the checksum is valid the 20 digit AKEY is written to NV,\n * replacing the existing AKEY no matter what it was before.\n *\n * \"data\" is const char *\n * ((const char *)data)[0] is a 26 digit string (ASCII digits '0'-'9')\n *                         where the last 6 digits are a checksum of the\n *                         first 20, as specified in TR45.AHAG\n *                         \"Common Cryptographic Algorithms, Revision D.1\n *                         Section 2.2\"\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86\n\n/**\n * RIL_REQUEST_CDMA_SEND_SMS\n *\n * Send a CDMA SMS message\n *\n * \"data\" is const RIL_CDMA_SMS_Message *\n *\n * \"response\" is a const RIL_SMS_Response *\n *\n * Based on the return error, caller decides to resend if sending sms\n * fails. The CDMA error class is derived as follows,\n * SUCCESS is error class 0 (no error)\n * SMS_SEND_FAIL_RETRY is error class 2 (temporary failure)\n * and GENERIC_FAILURE is error class 3 (permanent and no retry)\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SMS_SEND_FAIL_RETRY\n *  NETWORK_REJECT\n *  INVALID_STATE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  INVALID_SMS_FORMAT\n *  SYSTEM_ERR\n *  FDN_CHECK_FAILURE\n *  MODEM_ERR\n *  NETWORK_ERR\n *  ENCODING_ERR\n *  INVALID_SMSC_ADDRESS\n *  MODE_NOT_SUPPORTED\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_SEND_SMS 87\n\n/**\n * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE\n *\n * Acknowledge the success or failure in the receipt of SMS\n * previously indicated via RIL_UNSOL_RESPONSE_CDMA_NEW_SMS\n *\n * \"data\" is const RIL_CDMA_SMS_Ack *\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  NO_SMS_TO_ACK\n *  INVALID_STATE\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  INVALID_STATE\n *  MODE_NOT_SUPPORTED\n *  NETWORK_NOT_READY\n *  INVALID_MODEM_STATE\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88\n\n/**\n * RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG\n *\n * Request the setting of GSM/WCDMA Cell Broadcast SMS config.\n *\n * \"data\" is NULL\n *\n * \"response\" is a const RIL_GSM_BroadcastSmsConfigInfo **\n * \"responselen\" is count * sizeof (RIL_GSM_BroadcastSmsConfigInfo *)\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_STATE\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  SYSTEM_ERR\n *  NO_RESOURCES\n *  MODEM_ERR\n *  SYSTEM_ERR\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG 89\n\n/**\n * RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG\n *\n * Set GSM/WCDMA Cell Broadcast SMS config\n *\n * \"data\" is a const RIL_GSM_BroadcastSmsConfigInfo **\n * \"datalen\" is count * sizeof(RIL_GSM_BroadcastSmsConfigInfo *)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_STATE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  REQUEST_RATE_LIMITED\n *  MODEM_ERR\n *  SYSTEM_ERR\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG 90\n\n/**\n * RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION\n *\n* Enable or disable the reception of GSM/WCDMA Cell Broadcast SMS\n *\n * \"data\" is const int *\n * (const int *)data[0] indicates to activate or turn off the\n * reception of GSM/WCDMA Cell Broadcast SMS, 0-1,\n *                       0 - Activate, 1 - Turn off\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_STATE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  REQUEST_RATE_LIMITED\n *  MODEM_ERR\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION 91\n\n/**\n * RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG\n *\n * Request the setting of CDMA Broadcast SMS config\n *\n * \"data\" is NULL\n *\n * \"response\" is a const RIL_CDMA_BroadcastSmsConfigInfo **\n * \"responselen\" is count * sizeof (RIL_CDMA_BroadcastSmsConfigInfo *)\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_STATE\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  SYSTEM_ERR\n *  NO_RESOURCES\n *  MODEM_ERR\n *  SYSTEM_ERR\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG 92\n\n/**\n * RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG\n *\n * Set CDMA Broadcast SMS config\n *\n * \"data\" is an const RIL_CDMA_BroadcastSmsConfigInfo **\n * \"datalen\" is count * sizeof(const RIL_CDMA_BroadcastSmsConfigInfo *)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_STATE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  REQUEST_RATE_LIMITED\n *  MODEM_ERR\n *  SYSTEM_ERR\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG 93\n\n/**\n * RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION\n *\n * Enable or disable the reception of CDMA Broadcast SMS\n *\n * \"data\" is const int *\n * (const int *)data[0] indicates to activate or turn off the\n * reception of CDMA Broadcast SMS, 0-1,\n *                       0 - Activate, 1 - Turn off\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_STATE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  REQUEST_RATE_LIMITED\n *  MODEM_ERR\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION 94\n\n/**\n * RIL_REQUEST_CDMA_SUBSCRIPTION\n *\n * Request the device MDN / H_SID / H_NID.\n *\n * The request is only allowed when CDMA subscription is available.  When CDMA\n * subscription is changed, application layer should re-issue the request to\n * update the subscription information.\n *\n * If a NULL value is returned for any of the device id, it means that error\n * accessing the device.\n *\n * \"response\" is const char **\n * ((const char **)response)[0] is MDN if CDMA subscription is available\n * ((const char **)response)[1] is a comma separated list of H_SID (Home SID) if\n *                              CDMA subscription is available, in decimal format\n * ((const char **)response)[2] is a comma separated list of H_NID (Home NID) if\n *                              CDMA subscription is available, in decimal format\n * ((const char **)response)[3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available\n * ((const char **)response)[4] is PRL version if CDMA subscription is available\n *\n * Valid errors:\n *  SUCCESS\n *  RIL_E_SUBSCRIPTION_NOT_AVAILABLE\n */\n\n#define RIL_REQUEST_CDMA_SUBSCRIPTION 95\n\n/**\n * RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM\n *\n * Stores a CDMA SMS message to RUIM memory.\n *\n * \"data\" is RIL_CDMA_SMS_WriteArgs *\n *\n * \"response\" is int *\n * ((const int *)response)[0] is the record index where the message is stored.\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SIM_FULL\n *  INVALID_ARGUMENTS\n *  INVALID_SMS_FORMAT\n *  INTERNAL_ERR\n *  MODEM_ERR\n *  ENCODING_ERR\n *  NO_MEMORY\n *  NO_RESOURCES\n *  INVALID_MODEM_STATE\n *  MODE_NOT_SUPPORTED\n *  INVALID_SMSC_ADDRESS\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 96\n\n/**\n * RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM\n *\n * Deletes a CDMA SMS message from RUIM memory.\n *\n * \"data\" is int  *\n * ((int *)data)[0] is the record index of the message to delete.\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  SYSTEM_ERR\n *  MODEM_ERR\n *  NO_SUCH_ENTRY\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 97\n\n/**\n * RIL_REQUEST_DEVICE_IDENTITY\n *\n * Request the device ESN / MEID / IMEI / IMEISV.\n *\n * The request is always allowed and contains GSM and CDMA device identity;\n * it substitutes the deprecated requests RIL_REQUEST_GET_IMEI and\n * RIL_REQUEST_GET_IMEISV.\n *\n * If a NULL value is returned for any of the device id, it means that error\n * accessing the device.\n *\n * When CDMA subscription is changed the ESN/MEID may change.  The application\n * layer should re-issue the request to update the device identity in this case.\n *\n * \"response\" is const char **\n * ((const char **)response)[0] is IMEI if GSM subscription is available\n * ((const char **)response)[1] is IMEISV if GSM subscription is available\n * ((const char **)response)[2] is ESN if CDMA subscription is available\n * ((const char **)response)[3] is MEID if CDMA subscription is available\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_DEVICE_IDENTITY 98\n\n/**\n * RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE\n *\n * Request the radio's system selection module to exit emergency\n * callback mode.  RIL will not respond with SUCCESS until the modem has\n * completely exited from Emergency Callback Mode.\n *\n * \"data\" is NULL\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99\n\n/**\n * RIL_REQUEST_GET_SMSC_ADDRESS\n *\n * Queries the default Short Message Service Center address on the device.\n *\n * \"data\" is NULL\n *\n * \"response\" is const char * containing the SMSC address.\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  NO_MEMORY\n *  REQUEST_RATE_LIMITED\n *  SYSTEM_ERR\n *  INTERNAL_ERR\n *  MODEM_ERR\n *  INVALID_ARGUMENTS\n *  INVALID_MODEM_STATE\n *  NOT_PROVISIONED\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_GET_SMSC_ADDRESS 100\n\n/**\n * RIL_REQUEST_SET_SMSC_ADDRESS\n *\n * Sets the default Short Message Service Center address on the device.\n *\n * \"data\" is const char * containing the SMSC address.\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  INVALID_SMS_FORMAT\n *  NO_MEMORY\n *  SYSTEM_ERR\n *  REQUEST_RATE_LIMITED\n *  MODEM_ERR\n *  NO_RESOURCES\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_SET_SMSC_ADDRESS 101\n\n/**\n * RIL_REQUEST_REPORT_SMS_MEMORY_STATUS\n *\n * Indicates whether there is storage available for new SMS messages.\n *\n * \"data\" is int *\n * ((int *)data)[0] is 1 if memory is available for storing new messages\n *                  is 0 if memory capacity is exceeded\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  INVALID_ARGUMENTS\n *  NO_MEMORY\n *  INVALID_STATE\n *  SYSTEM_ERR\n *  REQUEST_RATE_LIMITED\n *  MODEM_ERR\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_REPORT_SMS_MEMORY_STATUS 102\n\n/**\n * RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING\n *\n * Indicates that the StkSerivce is running and is\n * ready to receive RIL_UNSOL_STK_XXXXX commands.\n *\n * \"data\" is NULL\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103\n\n/**\n * RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE\n *\n * Request to query the location where the CDMA subscription shall\n * be retrieved\n *\n * \"data\" is NULL\n *\n * \"response\" is int *\n * ((int *)data)[0] is == RIL_CdmaSubscriptionSource\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *  SUBSCRIPTION_NOT_AVAILABLE\n *\n * See also: RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE\n */\n#define RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE 104\n\n/**\n * RIL_REQUEST_ISIM_AUTHENTICATION\n *\n * Request the ISIM application on the UICC to perform AKA\n * challenge/response algorithm for IMS authentication\n *\n * \"data\" is a const char * containing the challenge string in Base64 format\n * \"response\" is a const char * containing the response in Base64 format\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_ISIM_AUTHENTICATION 105\n\n/**\n * RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU\n *\n * Acknowledge successful or failed receipt of SMS previously indicated\n * via RIL_UNSOL_RESPONSE_NEW_SMS, including acknowledgement TPDU to send\n * as the RP-User-Data element of the RP-ACK or RP-ERROR PDU.\n *\n * \"data\" is const char **\n * ((const char **)data)[0] is \"1\" on successful receipt (send RP-ACK)\n *                          is \"0\" on failed receipt (send RP-ERROR)\n * ((const char **)data)[1] is the acknowledgement TPDU in hexadecimal format\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106\n\n/**\n * RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS\n *\n * Requests to send a SAT/USAT envelope command to SIM.\n * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111.\n *\n * This request has one difference from RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND:\n * the SW1 and SW2 status bytes from the UICC response are returned along with\n * the response data, using the same structure as RIL_REQUEST_SIM_IO.\n *\n * The RIL implementation shall perform the normal processing of a '91XX'\n * response in SW1/SW2 to retrieve the pending proactive command and send it\n * as an unsolicited response, as RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND does.\n *\n * \"data\" is a const char * containing the SAT/USAT command\n * in hexadecimal format starting with command tag\n *\n * \"response\" is a const RIL_SIM_IO_Response *\n *\n * Valid errors:\n *  RIL_E_SUCCESS\n *  RIL_E_RADIO_NOT_AVAILABLE (radio resetting)\n *  SIM_BUSY\n *  OPERATION_NOT_ALLOWED\n *  RIL_E_GENERIC_FAILURE\n */\n#define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107\n\n/**\n * RIL_REQUEST_VOICE_RADIO_TECH\n *\n * Query the radio technology type (3GPP/3GPP2) used for voice. Query is valid only\n * when radio state is not RADIO_STATE_UNAVAILABLE\n *\n * \"data\" is NULL\n * \"response\" is int *\n * ((int *) response)[0] is of type const RIL_RadioTechnology\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_VOICE_RADIO_TECH 108\n\n/**\n * RIL_REQUEST_GET_CELL_INFO_LIST\n *\n * Request all of the current cell information known to the radio. The radio\n * must a list of all current cells, including the neighboring cells. If for a particular\n * cell information isn't known then the appropriate unknown value will be returned.\n * This does not cause or change the rate of RIL_UNSOL_CELL_INFO_LIST.\n *\n * \"data\" is NULL\n *\n * \"response\" is an array of  RIL_CellInfo_v12.\n */\n#define RIL_REQUEST_GET_CELL_INFO_LIST 109\n\n/**\n * RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE\n *\n * Sets the minimum time between when RIL_UNSOL_CELL_INFO_LIST should be invoked.\n * A value of 0, means invoke RIL_UNSOL_CELL_INFO_LIST when any of the reported\n * information changes. Setting the value to INT_MAX(0x7fffffff) means never issue\n * a RIL_UNSOL_CELL_INFO_LIST.\n *\n * \"data\" is int *\n * ((int *)data)[0] is minimum time in milliseconds\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE 110\n\n/**\n * RIL_REQUEST_SET_INITIAL_ATTACH_APN\n *\n * Set an apn to initial attach network\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  SUBSCRIPTION_NOT_AVAILABLE\n */\n#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111\n\n/**\n * RIL_REQUEST_IMS_REGISTRATION_STATE\n *\n * Request current IMS registration state\n *\n * \"data\" is NULL\n *\n * \"response\" is int *\n * ((int *)response)[0] is registration state:\n *              0 - Not registered\n *              1 - Registered\n *\n * If ((int*)response)[0] is = 1, then ((int *) response)[1]\n * must follow with IMS SMS format:\n *\n * ((int *) response)[1] is of type RIL_RadioTechnologyFamily\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_IMS_REGISTRATION_STATE 112\n\n/**\n * RIL_REQUEST_IMS_SEND_SMS\n *\n * Send a SMS message over IMS\n *\n * \"data\" is const RIL_IMS_SMS_Message *\n *\n * \"response\" is a const RIL_SMS_Response *\n *\n * Based on the return error, caller decides to resend if sending sms\n * fails. SMS_SEND_FAIL_RETRY means retry, and other errors means no retry.\n * In case of retry, data is encoded based on Voice Technology available.\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  SMS_SEND_FAIL_RETRY\n *  FDN_CHECK_FAILURE\n *  NETWORK_REJECT\n *  INVALID_ARGUMENTS\n *  INVALID_STATE\n *  NO_MEMORY\n *  INVALID_SMS_FORMAT\n *  SYSTEM_ERR\n *  REQUEST_RATE_LIMITED\n *  MODEM_ERR\n *  NETWORK_ERR\n *  ENCODING_ERR\n *  INVALID_SMSC_ADDRESS\n *  MODE_NOT_SUPPORTED\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_IMS_SEND_SMS 113\n\n/**\n * RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC\n *\n * Request APDU exchange on the basic channel. This command reflects TS 27.007\n * \"generic SIM access\" operation (+CSIM). The modem must ensure proper function\n * of GSM/CDMA, and filter commands appropriately. It should filter\n * channel management and SELECT by DF name commands.\n *\n * \"data\" is a const RIL_SIM_APDU *\n * \"sessionid\" field should be ignored.\n *\n * \"response\" is a const RIL_SIM_IO_Response *\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC 114\n\n/**\n * RIL_REQUEST_SIM_OPEN_CHANNEL\n *\n * Open a new logical channel and select the given application. This command\n * reflects TS 27.007 \"open logical channel\" operation (+CCHO).\n *\n * \"data\" is const char * and set to AID value, See ETSI 102.221 and 101.220.\n *\n * \"response\" is int *\n * ((int *)data)[0] contains the session id of the logical channel.\n * ((int *)data)[1] onwards may optionally contain the select response for the\n *     open channel command with one byte per integer.\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *  MISSING_RESOURCE\n *  NO_SUCH_ELEMENT\n */\n#define RIL_REQUEST_SIM_OPEN_CHANNEL 115\n\n/**\n * RIL_REQUEST_SIM_CLOSE_CHANNEL\n *\n * Close a previously opened logical channel. This command reflects TS 27.007\n * \"close logical channel\" operation (+CCHC).\n *\n * \"data\" is int *\n * ((int *)data)[0] is the session id of logical the channel to close.\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SIM_CLOSE_CHANNEL 116\n\n/**\n * RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL\n *\n * Exchange APDUs with a UICC over a previously opened logical channel. This\n * command reflects TS 27.007 \"generic logical channel access\" operation\n * (+CGLA). The modem should filter channel management and SELECT by DF name\n * commands.\n *\n * \"data\" is a const RIL_SIM_APDU*\n *\n * \"response\" is a const RIL_SIM_IO_Response *\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL 117\n\n/**\n * RIL_REQUEST_NV_READ_ITEM\n *\n * Read one of the radio NV items defined in RadioNVItems.java / ril_nv_items.h.\n * This is used for device configuration by some CDMA operators.\n *\n * \"data\" is a const RIL_NV_ReadItem *\n *\n * \"response\" is const char * containing the contents of the NV item\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_NV_READ_ITEM 118\n\n/**\n * RIL_REQUEST_NV_WRITE_ITEM\n *\n * Write one of the radio NV items defined in RadioNVItems.java / ril_nv_items.h.\n * This is used for device configuration by some CDMA operators.\n *\n * \"data\" is a const RIL_NV_WriteItem *\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_NV_WRITE_ITEM 119\n\n/**\n * RIL_REQUEST_NV_WRITE_CDMA_PRL\n *\n * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage.\n * This is used for device configuration by some CDMA operators.\n *\n * \"data\" is a const char * containing the PRL as a byte array\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_NV_WRITE_CDMA_PRL 120\n\n/**\n * RIL_REQUEST_NV_RESET_CONFIG\n *\n * Reset the radio NV configuration to the factory state.\n * This is used for device configuration by some CDMA operators.\n *\n * \"data\" is int *\n * ((int *)data)[0] is 1 to reload all NV items\n * ((int *)data)[0] is 2 for erase NV reset (SCRTN)\n * ((int *)data)[0] is 3 for factory reset (RTN)\n *\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_NV_RESET_CONFIG 121\n\n /** RIL_REQUEST_SET_UICC_SUBSCRIPTION\n * FIXME This API needs to have more documentation.\n *\n * Selection/de-selection of a subscription from a SIM card\n * \"data\" is const  RIL_SelectUiccSub*\n\n *\n * \"response\" is NULL\n *\n *  Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  SUBSCRIPTION_NOT_SUPPORTED\n *\n */\n#define RIL_REQUEST_SET_UICC_SUBSCRIPTION  122\n\n/**\n *  RIL_REQUEST_ALLOW_DATA\n *\n *  Tells the modem whether data calls are allowed or not\n *\n * \"data\" is int *\n * FIXME slotId and aid will be added.\n * ((int *)data)[0] is == 0 to allow data calls\n * ((int *)data)[0] is == 1 to disallow data calls\n *\n * \"response\" is NULL\n *\n *  Valid errors:\n *\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *\n */\n#define RIL_REQUEST_ALLOW_DATA  123\n\n/**\n * RIL_REQUEST_GET_HARDWARE_CONFIG\n *\n * Request all of the current hardware (modem and sim) associated\n * with the RIL.\n *\n * \"data\" is NULL\n *\n * \"response\" is an array of  RIL_HardwareConfig.\n */\n#define RIL_REQUEST_GET_HARDWARE_CONFIG 124\n\n/**\n * RIL_REQUEST_SIM_AUTHENTICATION\n *\n * Returns the response of SIM Authentication through RIL to a\n * challenge request.\n *\n * \"data\" Base64 encoded string containing challenge:\n *      int   authContext;          P2 value of authentication command, see P2 parameter in\n *                                  3GPP TS 31.102 7.1.2\n *      char *authData;             the challenge string in Base64 format, see 3GPP\n *                                  TS 31.102 7.1.2\n *      char *aid;                  AID value, See ETSI 102.221 8.1 and 101.220 4,\n *                                  NULL if no value\n *\n * \"response\" Base64 encoded strings containing response:\n *      int   sw1;                  Status bytes per 3GPP TS 31.102 section 7.3\n *      int   sw2;\n *      char *simResponse;          Response in Base64 format, see 3GPP TS 31.102 7.1.2\n */\n#define RIL_REQUEST_SIM_AUTHENTICATION 125\n\n/**\n * RIL_REQUEST_GET_DC_RT_INFO\n *\n * The request is DEPRECATED, use RIL_REQUEST_GET_ACTIVITY_INFO\n * Requests the Data Connection Real Time Info\n *\n * \"data\" is NULL\n *\n * \"response\" is the most recent RIL_DcRtInfo\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *\n * See also: RIL_UNSOL_DC_RT_INFO_CHANGED\n */\n#define RIL_REQUEST_GET_DC_RT_INFO 126\n\n/**\n * RIL_REQUEST_SET_DC_RT_INFO_RATE\n *\n * The request is DEPRECATED\n * This is the minimum number of milliseconds between successive\n * RIL_UNSOL_DC_RT_INFO_CHANGED messages and defines the highest rate\n * at which RIL_UNSOL_DC_RT_INFO_CHANGED's will be sent. A value of\n * 0 means send as fast as possible.\n *\n * \"data\" The number of milliseconds as an int\n *\n * \"response\" is null\n *\n * Valid errors:\n *  SUCCESS must not fail\n */\n#define RIL_REQUEST_SET_DC_RT_INFO_RATE 127\n\n/**\n * RIL_REQUEST_SET_DATA_PROFILE\n *\n * Set data profile in modem\n * Modem should erase existed profiles from framework, and apply new profiles\n * \"data\" is an const RIL_DataProfileInfo **\n * \"datalen\" is count * sizeof(const RIL_DataProfileInfo *)\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE (radio resetting)\n *  GENERIC_FAILURE\n *  SUBSCRIPTION_NOT_AVAILABLE\n */\n#define RIL_REQUEST_SET_DATA_PROFILE 128\n\n/**\n * RIL_REQUEST_SHUTDOWN\n *\n * Device is shutting down. All further commands are ignored\n * and RADIO_NOT_AVAILABLE must be returned.\n *\n * \"data\" is null\n * \"response\" is NULL\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SHUTDOWN 129\n\n/**\n * RIL_REQUEST_GET_RADIO_CAPABILITY\n *\n * Used to get phone radio capablility.\n *\n * \"data\" is the RIL_RadioCapability structure\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_GET_RADIO_CAPABILITY 130\n\n/**\n * RIL_REQUEST_SET_RADIO_CAPABILITY\n *\n * Used to set the phones radio capability. Be VERY careful\n * using this request as it may cause some vendor modems to reset. Because\n * of the possible modem reset any RIL commands after this one may not be\n * processed.\n *\n * \"data\" is the RIL_RadioCapability structure\n *\n * \"response\" is the RIL_RadioCapability structure, used to feedback return status\n *\n * Valid errors:\n *  SUCCESS means a RIL_UNSOL_RADIO_CAPABILITY will be sent within 30 seconds.\n *  RADIO_NOT_AVAILABLE\n *  OPERATION_NOT_ALLOWED\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_SET_RADIO_CAPABILITY 131\n\n/**\n * RIL_REQUEST_START_LCE\n *\n * Start Link Capacity Estimate (LCE) service if supported by the radio.\n *\n * \"data\" is const int *\n * ((const int*)data)[0] specifies the desired reporting interval (ms).\n * ((const int*)data)[1] specifies the LCE service mode. 1: PULL; 0: PUSH.\n *\n * \"response\" is the RIL_LceStatusInfo.\n *\n * Valid errors:\n * SUCCESS\n * RADIO_NOT_AVAILABLE\n * LCE_NOT_SUPPORTED\n */\n#define RIL_REQUEST_START_LCE 132\n\n/**\n * RIL_REQUEST_STOP_LCE\n *\n * Stop Link Capacity Estimate (LCE) service, the STOP operation should be\n * idempotent for the radio modem.\n *\n * \"response\" is the RIL_LceStatusInfo.\n *\n * Valid errors:\n * SUCCESS\n * RADIO_NOT_AVAILABLE\n * LCE_NOT_SUPPORTED\n */\n#define RIL_REQUEST_STOP_LCE 133\n\n/**\n * RIL_REQUEST_PULL_LCEDATA\n *\n * Pull LCE service for capacity information.\n *\n * \"response\" is the RIL_LceDataInfo.\n *\n * Valid errors:\n * SUCCESS\n * RADIO_NOT_AVAILABLE\n * LCE_NOT_SUPPORTED\n */\n#define RIL_REQUEST_PULL_LCEDATA 134\n\n/**\n * RIL_REQUEST_GET_ACTIVITY_INFO\n *\n * Get modem activity statisitics info.\n *\n * There can be multiple RIL_REQUEST_GET_ACTIVITY_INFO calls to modem.\n * Once the response for the request is sent modem will clear\n * current statistics information.\n *\n * \"data\" is null\n * \"response\" is const RIL_ActivityStatsInfo *\n *\n * Valid errors:\n *\n * SUCCESS\n * RADIO_NOT_AVAILABLE (radio resetting)\n * GENERIC_FAILURE\n */\n#define RIL_REQUEST_GET_ACTIVITY_INFO 135\n\n/**\n * RIL_REQUEST_SIM_GET_ATR\n *\n * Get the ATR from SIM Card\n *\n * Only valid when radio state is \"RADIO_STATE_ON\"\n *\n * \"data\" is const int *\n * ((const int *)data)[0] contains the slot index on the SIM from which ATR is requested.\n *\n * \"response\" is a const char * containing the ATR, See ETSI 102.221 8.1 and ISO/IEC 7816 3\n *\n * Valid errors:\n *\n * SUCCESS\n * RADIO_NOT_AVAILABLE (radio resetting)\n * GENERIC_FAILURE\n */\n#define RIL_REQUEST_SIM_GET_ATR 136\n\n/**\n * RIL_REQUEST_CAF_SIM_OPEN_CHANNEL_WITH_P2\n *\n * Open a new logical channel and select the given application. This command\n * reflects TS 27.007 \"open logical channel\" operation (+CCHO). This request\n * also specifies the P2 parameter.\n *\n * \"data\" is a const RIL_CafOpenChannelParam *\n *\n * \"response\" is int *\n * ((int *)data)[0] contains the session id of the logical channel.\n * ((int *)data)[1] onwards may optionally contain the select response for the\n *     open channel command with one byte per integer.\n *\n * Valid errors:\n *  SUCCESS\n *  RADIO_NOT_AVAILABLE\n *  GENERIC_FAILURE\n *  MISSING_RESOURCE\n *  NO_SUCH_ELEMENT\n */\n#define RIL_REQUEST_CAF_SIM_OPEN_CHANNEL_WITH_P2 137\n\n/**\n * RIL_REQUEST_GET_ADN_RECORD\n *\n * Requests ADN count record of the SIM card\n *\n * \"data\" is NULL\n *\n * \"response\" is const int *\n * ((int *)data)[0] is the max adn count.\n * ((int *)data)[1] is the valid adn count.\n * ((int *)data)[2] is the max email count.\n * ((int *)data)[3] is the max anr count.\n *\n * Valid errors:\n *  SUCCESS\n *  GENERIC_FAILURE\n */\n#define RIL_REQUEST_GET_ADN_RECORD 138\n\n/**\n * RIL_REQUEST_UPDATE_ADN_RECORD\n *\n * Requests ADN count of the the SIM card\n *\n * \"data\" is RIL_AdnRecordInfo *\n *\n * \"response\" is const int *\n *\n * Valid errors:\n *  Must never fail\n */\n#define RIL_REQUEST_UPDATE_ADN_RECORD 139\n\n/**\n * RIL_REQUEST_SET_CARRIER_RESTRICTIONS\n *\n * Set carrier restrictions for this sim slot. Expected modem behavior:\n *  If never receives this command\n *  - Must allow all carriers\n *  Receives this command with data being NULL\n *  - Must allow all carriers. If a previously allowed SIM is present, modem must not reload\n *    the SIM. If a previously disallowed SIM is present, reload the SIM and notify Android.\n *  Receives this command with a list of carriers\n *  - Only allow specified carriers, persist across power cycles and FDR. If a present SIM\n *    is in the allowed list, modem must not reload the SIM. If a present SIM is *not* in\n *    the allowed list, modem must detach from the registered network and only keep emergency\n *    service, and notify Android SIM refresh reset with new SIM state being\n *    RIL_CARDSTATE_RESTRICTED. Emergency service must be enabled.\n *\n * \"data\" is const RIL_CarrierRestrictions *\n * A list of allowed carriers and possibly a list of excluded carriers.\n * If data is NULL, means to clear previous carrier restrictions and allow all carriers\n *\n * \"response\" is int *\n * ((int *)data)[0] contains the number of allowed carriers which have been set correctly.\n * On success, it should match the length of list data->allowed_carriers.\n * If data is NULL, the value must be 0.\n *\n * Valid errors:\n *  RIL_E_SUCCESS\n *  RIL_E_INVALID_ARGUMENTS\n *  RIL_E_RADIO_NOT_AVAILABLE\n *  RIL_E_REQUEST_NOT_SUPPORTED\n */\n#define RIL_REQUEST_SET_CARRIER_RESTRICTIONS 140\n\n/**\n * RIL_REQUEST_GET_CARRIER_RESTRICTIONS\n *\n * Get carrier restrictions for this sim slot. Expected modem behavior:\n *  Return list of allowed carriers, or null if all carriers are allowed.\n *\n * \"data\" is NULL\n *\n * \"response\" is const RIL_CarrierRestrictions *.\n * If response is NULL, it means all carriers are allowed.\n *\n * Valid errors:\n *  RIL_E_SUCCESS\n *  RIL_E_RADIO_NOT_AVAILABLE\n *  RIL_E_REQUEST_NOT_SUPPORTED\n */\n#define RIL_REQUEST_GET_CARRIER_RESTRICTIONS 141\n\n/***********************************************************************/\n\n/**\n * RIL_RESPONSE_ACKNOWLEDGEMENT\n *\n * This is used by Asynchronous solicited messages and Unsolicited messages\n * to acknowledge the receipt of those messages in RIL.java so that the ack\n * can be used to let ril.cpp to release wakelock.\n *\n * Valid errors\n * SUCCESS\n * RADIO_NOT_AVAILABLE\n */\n\n#define RIL_RESPONSE_ACKNOWLEDGEMENT 800\n\n/***********************************************************************/\n\n\n#define RIL_UNSOL_RESPONSE_BASE 1000\n\n/**\n * RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED\n *\n * Indicate when value of RIL_RadioState has changed.\n *\n * Callee will invoke RIL_RadioStateRequest method on main thread\n *\n * \"data\" is NULL\n */\n\n#define RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED 1000\n\n\n/**\n * RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED\n *\n * Indicate when call state has changed\n *\n * Callee will invoke RIL_REQUEST_GET_CURRENT_CALLS on main thread\n *\n * \"data\" is NULL\n *\n * Response should be invoked on, for example,\n * \"RING\", \"BUSY\", \"NO CARRIER\", and also call state\n * transitions (DIALING->ALERTING ALERTING->ACTIVE)\n *\n * Redundent or extraneous invocations are tolerated\n */\n#define RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED 1001\n\n\n/**\n * RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED\n *\n * Called when the voice network state changed\n *\n * Callee will invoke the following requests on main thread:\n *\n * RIL_REQUEST_VOICE_REGISTRATION_STATE\n * RIL_REQUEST_OPERATOR\n *\n * \"data\" is NULL\n *\n * FIXME should this happen when SIM records are loaded? (eg, for\n * EONS)\n */\n#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 1002\n\n/**\n * RIL_UNSOL_RESPONSE_NEW_SMS\n *\n * Called when new SMS is received.\n *\n * \"data\" is const char *\n * This is a pointer to a string containing the PDU of an SMS-DELIVER\n * as an ascii string of hex digits. The PDU starts with the SMSC address\n * per TS 27.005 (+CMT:)\n *\n * Callee will subsequently confirm the receipt of thei SMS with a\n * RIL_REQUEST_SMS_ACKNOWLEDGE\n *\n * No new RIL_UNSOL_RESPONSE_NEW_SMS\n * or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a\n * RIL_REQUEST_SMS_ACKNOWLEDGE has been received\n */\n\n#define RIL_UNSOL_RESPONSE_NEW_SMS 1003\n\n/**\n * RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT\n *\n * Called when new SMS Status Report is received.\n *\n * \"data\" is const char *\n * This is a pointer to a string containing the PDU of an SMS-STATUS-REPORT\n * as an ascii string of hex digits. The PDU starts with the SMSC address\n * per TS 27.005 (+CDS:).\n *\n * Callee will subsequently confirm the receipt of the SMS with a\n * RIL_REQUEST_SMS_ACKNOWLEDGE\n *\n * No new RIL_UNSOL_RESPONSE_NEW_SMS\n * or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a\n * RIL_REQUEST_SMS_ACKNOWLEDGE has been received\n */\n\n#define RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT 1004\n\n/**\n * RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM\n *\n * Called when new SMS has been stored on SIM card\n *\n * \"data\" is const int *\n * ((const int *)data)[0] contains the slot index on the SIM that contains\n * the new message\n */\n\n#define RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM 1005\n\n/**\n * RIL_UNSOL_ON_USSD\n *\n * Called when a new USSD message is received.\n *\n * \"data\" is const char **\n * ((const char **)data)[0] points to a type code, which is\n *  one of these string values:\n *      \"0\"   USSD-Notify -- text in ((const char **)data)[1]\n *      \"1\"   USSD-Request -- text in ((const char **)data)[1]\n *      \"2\"   Session terminated by network\n *      \"3\"   other local client (eg, SIM Toolkit) has responded\n *      \"4\"   Operation not supported\n *      \"5\"   Network timeout\n *\n * The USSD session is assumed to persist if the type code is \"1\", otherwise\n * the current session (if any) is assumed to have terminated.\n *\n * ((const char **)data)[1] points to a message string if applicable, which\n * should always be in UTF-8.\n */\n#define RIL_UNSOL_ON_USSD 1006\n/* Previously #define RIL_UNSOL_ON_USSD_NOTIFY 1006   */\n\n/**\n * RIL_UNSOL_ON_USSD_REQUEST\n *\n * Obsolete. Send via RIL_UNSOL_ON_USSD\n */\n#define RIL_UNSOL_ON_USSD_REQUEST 1007\n\n/**\n * RIL_UNSOL_NITZ_TIME_RECEIVED\n *\n * Called when radio has received a NITZ time message\n *\n * \"data\" is const char * pointing to NITZ time string\n * in the form \"yy/mm/dd,hh:mm:ss(+/-)tz,dt\"\n */\n#define RIL_UNSOL_NITZ_TIME_RECEIVED  1008\n\n/**\n * RIL_UNSOL_SIGNAL_STRENGTH\n *\n * Radio may report signal strength rather han have it polled.\n *\n * \"data\" is a const RIL_SignalStrength *\n */\n#define RIL_UNSOL_SIGNAL_STRENGTH  1009\n\n\n/**\n * RIL_UNSOL_DATA_CALL_LIST_CHANGED\n *\n * \"data\" is an array of RIL_Data_Call_Response_v6 identical to that\n * returned by RIL_REQUEST_DATA_CALL_LIST. It is the complete list\n * of current data contexts including new contexts that have been\n * activated. A data call is only removed from this list when the\n * framework sends a RIL_REQUEST_DEACTIVATE_DATA_CALL or the radio\n * is powered off/on.\n *\n * See also: RIL_REQUEST_DATA_CALL_LIST\n */\n\n#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 1010\n\n/**\n * RIL_UNSOL_SUPP_SVC_NOTIFICATION\n *\n * Reports supplementary service related notification from the network.\n *\n * \"data\" is a const RIL_SuppSvcNotification *\n *\n */\n\n#define RIL_UNSOL_SUPP_SVC_NOTIFICATION 1011\n\n/**\n * RIL_UNSOL_STK_SESSION_END\n *\n * Indicate when STK session is terminated by SIM.\n *\n * \"data\" is NULL\n */\n#define RIL_UNSOL_STK_SESSION_END 1012\n\n/**\n * RIL_UNSOL_STK_PROACTIVE_COMMAND\n *\n * Indicate when SIM issue a STK proactive command to applications\n *\n * \"data\" is a const char * containing SAT/USAT proactive command\n * in hexadecimal format string starting with command tag\n *\n */\n#define RIL_UNSOL_STK_PROACTIVE_COMMAND 1013\n\n/**\n * RIL_UNSOL_STK_EVENT_NOTIFY\n *\n * Indicate when SIM notifies applcations some event happens.\n * Generally, application does not need to have any feedback to\n * SIM but shall be able to indicate appropriate messages to users.\n *\n * \"data\" is a const char * containing SAT/USAT commands or responses\n * sent by ME to SIM or commands handled by ME, in hexadecimal format string\n * starting with first byte of response data or command tag\n *\n */\n#define RIL_UNSOL_STK_EVENT_NOTIFY 1014\n\n/**\n * RIL_UNSOL_STK_CALL_SETUP\n *\n * Indicate when SIM wants application to setup a voice call.\n *\n * \"data\" is const int *\n * ((const int *)data)[0] contains timeout value (in milliseconds)\n */\n#define RIL_UNSOL_STK_CALL_SETUP 1015\n\n/**\n * RIL_UNSOL_SIM_SMS_STORAGE_FULL\n *\n * Indicates that SMS storage on the SIM is full.  Sent when the network\n * attempts to deliver a new SMS message.  Messages cannot be saved on the\n * SIM until space is freed.  In particular, incoming Class 2 messages\n * cannot be stored.\n *\n * \"data\" is null\n *\n */\n#define RIL_UNSOL_SIM_SMS_STORAGE_FULL 1016\n\n/**\n * RIL_UNSOL_SIM_REFRESH\n *\n * Indicates that file(s) on the SIM have been updated, or the SIM\n * has been reinitialized.\n *\n * In the case where RIL is version 6 or older:\n * \"data\" is an int *\n * ((int *)data)[0] is a RIL_SimRefreshResult.\n * ((int *)data)[1] is the EFID of the updated file if the result is\n * SIM_FILE_UPDATE or NULL for any other result.\n *\n * In the case where RIL is version 7:\n * \"data\" is a RIL_SimRefreshResponse_v7 *\n *\n * Note: If the SIM state changes as a result of the SIM refresh (eg,\n * SIM_READY -> SIM_LOCKED_OR_ABSENT), RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED\n * should be sent.\n */\n#define RIL_UNSOL_SIM_REFRESH 1017\n\n/**\n * RIL_UNSOL_CALL_RING\n *\n * Ring indication for an incoming call (eg, RING or CRING event).\n * There must be at least one RIL_UNSOL_CALL_RING at the beginning\n * of a call and sending multiple is optional. If the system property\n * ro.telephony.call_ring.multiple is false then the upper layers\n * will generate the multiple events internally. Otherwise the vendor\n * ril must generate multiple RIL_UNSOL_CALL_RING if\n * ro.telephony.call_ring.multiple is true or if it is absent.\n *\n * The rate of these events is controlled by ro.telephony.call_ring.delay\n * and has a default value of 3000 (3 seconds) if absent.\n *\n * \"data\" is null for GSM\n * \"data\" is const RIL_CDMA_SignalInfoRecord * if CDMA\n */\n#define RIL_UNSOL_CALL_RING 1018\n\n/**\n * RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED\n *\n * Indicates that SIM state changes.\n *\n * Callee will invoke RIL_REQUEST_GET_SIM_STATUS on main thread\n\n * \"data\" is null\n */\n#define RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED 1019\n\n/**\n * RIL_UNSOL_RESPONSE_CDMA_NEW_SMS\n *\n * Called when new CDMA SMS is received\n *\n * \"data\" is const RIL_CDMA_SMS_Message *\n *\n * Callee will subsequently confirm the receipt of the SMS with\n * a RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE\n *\n * No new RIL_UNSOL_RESPONSE_CDMA_NEW_SMS should be sent until\n * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE has been received\n *\n */\n#define RIL_UNSOL_RESPONSE_CDMA_NEW_SMS 1020\n\n/**\n * RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS\n *\n * Called when new Broadcast SMS is received\n *\n * \"data\" can be one of the following:\n * If received from GSM network, \"data\" is const char of 88 bytes\n * which indicates each page of a CBS Message sent to the MS by the\n * BTS as coded in 3GPP 23.041 Section 9.4.1.2.\n * If received from UMTS network, \"data\" is const char of 90 up to 1252\n * bytes which contain between 1 and 15 CBS Message pages sent as one\n * packet to the MS by the BTS as coded in 3GPP 23.041 Section 9.4.2.2.\n *\n */\n#define RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS 1021\n\n/**\n * RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL\n *\n * Indicates that SMS storage on the RUIM is full.  Messages\n * cannot be saved on the RUIM until space is freed.\n *\n * \"data\" is null\n *\n */\n#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022\n\n/**\n * RIL_UNSOL_RESTRICTED_STATE_CHANGED\n *\n * Indicates a restricted state change (eg, for Domain Specific Access Control).\n *\n * Radio need send this msg after radio off/on cycle no matter it is changed or not.\n *\n * \"data\" is an int *\n * ((int *)data)[0] contains a bitmask of RIL_RESTRICTED_STATE_* values.\n */\n#define RIL_UNSOL_RESTRICTED_STATE_CHANGED 1023\n\n/**\n * RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE\n *\n * Indicates that the radio system selection module has\n * autonomously entered emergency callback mode.\n *\n * \"data\" is null\n *\n */\n#define RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE 1024\n\n/**\n * RIL_UNSOL_CDMA_CALL_WAITING\n *\n * Called when CDMA radio receives a call waiting indication.\n *\n * \"data\" is const RIL_CDMA_CallWaiting *\n *\n */\n#define RIL_UNSOL_CDMA_CALL_WAITING 1025\n\n/**\n * RIL_UNSOL_CDMA_OTA_PROVISION_STATUS\n *\n * Called when CDMA radio receives an update of the progress of an\n * OTASP/OTAPA call.\n *\n * \"data\" is const int *\n *  For CDMA this is an integer OTASP/OTAPA status listed in\n *  RIL_CDMA_OTA_ProvisionStatus.\n *\n */\n#define RIL_UNSOL_CDMA_OTA_PROVISION_STATUS 1026\n\n/**\n * RIL_UNSOL_CDMA_INFO_REC\n *\n * Called when CDMA radio receives one or more info recs.\n *\n * \"data\" is const RIL_CDMA_InformationRecords *\n *\n */\n#define RIL_UNSOL_CDMA_INFO_REC 1027\n\n/**\n * RIL_UNSOL_OEM_HOOK_RAW\n *\n * This is for OEM specific use.\n *\n * \"data\" is a byte[]\n */\n#define RIL_UNSOL_OEM_HOOK_RAW 1028\n\n/**\n * RIL_UNSOL_RINGBACK_TONE\n *\n * Indicates that nework doesn't have in-band information,  need to\n * play out-band tone.\n *\n * \"data\" is an int *\n * ((int *)data)[0] == 0 for stop play ringback tone.\n * ((int *)data)[0] == 1 for start play ringback tone.\n */\n#define RIL_UNSOL_RINGBACK_TONE 1029\n\n/**\n * RIL_UNSOL_RESEND_INCALL_MUTE\n *\n * Indicates that framework/application need reset the uplink mute state.\n *\n * There may be situations where the mute state becomes out of sync\n * between the application and device in some GSM infrastructures.\n *\n * \"data\" is null\n */\n#define RIL_UNSOL_RESEND_INCALL_MUTE 1030\n\n/**\n * RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED\n *\n * Called when CDMA subscription source changed.\n *\n * \"data\" is int *\n * ((int *)data)[0] is == RIL_CdmaSubscriptionSource\n */\n#define RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED 1031\n\n/**\n * RIL_UNSOL_CDMA_PRL_CHANGED\n *\n * Called when PRL (preferred roaming list) changes.\n *\n * \"data\" is int *\n * ((int *)data)[0] is PRL_VERSION as would be returned by RIL_REQUEST_CDMA_SUBSCRIPTION\n */\n#define RIL_UNSOL_CDMA_PRL_CHANGED 1032\n\n/**\n * RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE\n *\n * Called when Emergency Callback Mode Ends\n *\n * Indicates that the radio system selection module has\n * proactively exited emergency callback mode.\n *\n * \"data\" is NULL\n *\n */\n#define RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE 1033\n\n/**\n * RIL_UNSOL_RIL_CONNECTED\n *\n * Called the ril connects and returns the version\n *\n * \"data\" is int *\n * ((int *)data)[0] is RIL_VERSION\n */\n#define RIL_UNSOL_RIL_CONNECTED 1034\n\n/**\n * RIL_UNSOL_VOICE_RADIO_TECH_CHANGED\n *\n * Indicates that voice technology has changed. Contains new radio technology\n * as a data in the message.\n *\n * \"data\" is int *\n * ((int *)data)[0] is of type const RIL_RadioTechnology\n *\n */\n#define RIL_UNSOL_VOICE_RADIO_TECH_CHANGED 1035\n\n/**\n * RIL_UNSOL_CELL_INFO_LIST\n *\n * Same information as returned by RIL_REQUEST_GET_CELL_INFO_LIST, but returned\n * at the rate no greater than specified by RIL_REQUEST_SET_UNSOL_CELL_INFO_RATE.\n *\n * \"data\" is NULL\n *\n * \"response\" is an array of RIL_CellInfo_v12.\n */\n#define RIL_UNSOL_CELL_INFO_LIST 1036\n\n/**\n * RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED\n *\n * Called when IMS registration state has changed\n *\n * To get IMS registration state and IMS SMS format, callee needs to invoke the\n * following request on main thread:\n *\n * RIL_REQUEST_IMS_REGISTRATION_STATE\n *\n * \"data\" is NULL\n *\n */\n#define RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED 1037\n\n/**\n * RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED\n *\n * Indicated when there is a change in subscription status.\n * This event will be sent in the following scenarios\n *  - subscription readiness at modem, which was selected by telephony layer\n *  - when subscription is deactivated by modem due to UICC card removal\n *  - When network invalidates the subscription i.e. attach reject due to authentication reject\n *\n * \"data\" is const int *\n * ((const int *)data)[0] == 0 for Subscription Deactivated\n * ((const int *)data)[0] == 1 for Subscription Activated\n *\n */\n#define RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED 1038\n\n/**\n * RIL_UNSOL_SRVCC_STATE_NOTIFY\n *\n * Called when Single Radio Voice Call Continuity(SRVCC)\n * progress state has changed\n *\n * \"data\" is int *\n * ((int *)data)[0] is of type const RIL_SrvccState\n *\n */\n\n#define RIL_UNSOL_SRVCC_STATE_NOTIFY 1039\n\n/**\n * RIL_UNSOL_HARDWARE_CONFIG_CHANGED\n *\n * Called when the hardware configuration associated with the RILd changes\n *\n * \"data\" is an array of RIL_HardwareConfig\n *\n */\n#define RIL_UNSOL_HARDWARE_CONFIG_CHANGED 1040\n\n/**\n * RIL_UNSOL_DC_RT_INFO_CHANGED\n *\n * The message is DEPRECATED, use RIL_REQUEST_GET_ACTIVITY_INFO\n * Sent when the DC_RT_STATE changes but the time\n * between these messages must not be less than the\n * value set by RIL_REQUEST_SET_DC_RT_RATE.\n *\n * \"data\" is the most recent RIL_DcRtInfo\n *\n */\n#define RIL_UNSOL_DC_RT_INFO_CHANGED 1041\n\n/**\n * RIL_UNSOL_RADIO_CAPABILITY\n *\n * Sent when RIL_REQUEST_SET_RADIO_CAPABILITY completes.\n * Returns the phone radio capability exactly as\n * RIL_REQUEST_GET_RADIO_CAPABILITY and should be the\n * same set as sent by RIL_REQUEST_SET_RADIO_CAPABILITY.\n *\n * \"data\" is the RIL_RadioCapability structure\n */\n#define RIL_UNSOL_RADIO_CAPABILITY 1042\n\n/*\n * RIL_UNSOL_ON_SS\n *\n * Called when SS response is received when DIAL/USSD/SS is changed to SS by\n * call control.\n *\n * \"data\" is const RIL_StkCcUnsolSsResponse *\n *\n */\n#define RIL_UNSOL_ON_SS 1043\n\n/**\n * RIL_UNSOL_STK_CC_ALPHA_NOTIFY\n *\n * Called when there is an ALPHA from UICC during Call Control.\n *\n * \"data\" is const char * containing ALPHA string from UICC in UTF-8 format.\n *\n */\n#define RIL_UNSOL_STK_CC_ALPHA_NOTIFY 1044\n\n/**\n * RIL_UNSOL_LCEDATA_RECV\n *\n * Called when there is an incoming Link Capacity Estimate (LCE) info report.\n *\n * \"data\" is the RIL_LceDataInfo structure.\n *\n */\n#define RIL_UNSOL_LCEDATA_RECV 1045\n\n/**\n * RIL_UNSOL_RESPONSE_ADN_INIT_DONE\n *\n * Called when the ADN has already init done,\n *\n * \"data\" is NULL.\n *\n */\n#define RIL_UNSOL_RESPONSE_ADN_INIT_DONE 1046\n\n/**\n * RIL_UNSOL_RESPONSE_ADN_RECORDS\n *\n * Called when there is a group of ADN record report,\n *\n * \"data\" is the RIL_ADN structure.\n *\n */\n#define RIL_UNSOL_RESPONSE_ADN_RECORDS 1047\n\n /**\n  * RIL_UNSOL_PCO_DATA\n  *\n  * Called when there is new Carrier PCO data received for a data call.  Ideally\n  * only new data will be forwarded, though this is not required.  Multiple\n  * boxes of carrier PCO data for a given call should result in a series of\n  * RIL_UNSOL_PCO_DATA calls.\n  *\n  * \"data\" is the RIL_PCO_Data structure.\n  *\n  */\n#define RIL_UNSOL_PCO_DATA 1049\n\n/***********************************************************************/\n\n\n#if defined(ANDROID_MULTI_SIM)\n/**\n * RIL_Request Function pointer\n *\n * @param request is one of RIL_REQUEST_*\n * @param data is pointer to data defined for that RIL_REQUEST_*\n *        data is owned by caller, and should not be modified or freed by callee\n *        structures passed as data may contain pointers to non-contiguous memory\n * @param t should be used in subsequent call to RIL_onResponse\n * @param datalen is the length of \"data\" which is defined as other argument. It may or may\n *        not be equal to sizeof(data). Refer to the documentation of individual structures\n *        to find if pointers listed in the structure are contiguous and counted in the datalen\n *        length or not.\n *        (Eg: RIL_IMS_SMS_Message where we don't have datalen equal to sizeof(data))\n *\n */\ntypedef void (*RIL_RequestFunc) (int request, void *data,\n                                    size_t datalen, RIL_Token t, RIL_SOCKET_ID socket_id);\n\n/**\n * This function should return the current radio state synchronously\n */\ntypedef RIL_RadioState (*RIL_RadioStateRequest)(RIL_SOCKET_ID socket_id);\n\n#else\n/* Backward compatible */\n\n/**\n * RIL_Request Function pointer\n *\n * @param request is one of RIL_REQUEST_*\n * @param data is pointer to data defined for that RIL_REQUEST_*\n *        data is owned by caller, and should not be modified or freed by callee\n *        structures passed as data may contain pointers to non-contiguous memory\n * @param t should be used in subsequent call to RIL_onResponse\n * @param datalen is the length of \"data\" which is defined as other argument. It may or may\n *        not be equal to sizeof(data). Refer to the documentation of individual structures\n *        to find if pointers listed in the structure are contiguous and counted in the datalen\n *        length or not.\n *        (Eg: RIL_IMS_SMS_Message where we don't have datalen equal to sizeof(data))\n *\n */\ntypedef void (*RIL_RequestFunc) (int request, void *data,\n                                    size_t datalen, RIL_Token t);\n\n/**\n * This function should return the current radio state synchronously\n */\ntypedef RIL_RadioState (*RIL_RadioStateRequest)();\n\n#endif\n\n\n/**\n * This function returns \"1\" if the specified RIL_REQUEST code is\n * supported and 0 if it is not\n *\n * @param requestCode is one of RIL_REQUEST codes\n */\n\ntypedef int (*RIL_Supports)(int requestCode);\n\n/**\n * This function is called from a separate thread--not the\n * thread that calls RIL_RequestFunc--and indicates that a pending\n * request should be cancelled.\n *\n * On cancel, the callee should do its best to abandon the request and\n * call RIL_onRequestComplete with RIL_Errno CANCELLED at some later point.\n *\n * Subsequent calls to  RIL_onRequestComplete for this request with\n * other results will be tolerated but ignored. (That is, it is valid\n * to ignore the cancellation request)\n *\n * RIL_Cancel calls should return immediately, and not wait for cancellation\n *\n * Please see ITU v.250 5.6.1 for how one might implement this on a TS 27.007\n * interface\n *\n * @param t token wants to be canceled\n */\n\ntypedef void (*RIL_Cancel)(RIL_Token t);\n\ntypedef void (*RIL_TimedCallback) (void *param);\n\n/**\n * Return a version string for your RIL implementation\n */\ntypedef const char * (*RIL_GetVersion) (void);\n\ntypedef struct {\n    int version;        /* set to RIL_VERSION */\n    RIL_RequestFunc onRequest;\n    RIL_RadioStateRequest onStateRequest;\n    RIL_Supports supports;\n    RIL_Cancel onCancel;\n    RIL_GetVersion getVersion;\n} RIL_RadioFunctions;\n\ntypedef struct {\n    char *apn;\n    char *protocol;\n    int authtype;\n    char *username;\n    char *password;\n} RIL_InitialAttachApn;\n\ntypedef struct {\n    int authContext;            /* P2 value of authentication command, see P2 parameter in\n                                   3GPP TS 31.102 7.1.2 */\n    char *authData;             /* the challenge string in Base64 format, see 3GPP\n                                   TS 31.102 7.1.2 */\n    char *aid;                  /* AID value, See ETSI 102.221 8.1 and 101.220 4,\n                                   NULL if no value. */\n} RIL_SimAuthentication;\n\ntypedef struct {\n    int cid;             /* Context ID, uniquely identifies this call */\n    char *bearer_proto;  /* One of the PDP_type values in TS 27.007 section 10.1.1.\n                            For example, \"IP\", \"IPV6\", \"IPV4V6\" */\n    int pco_id;          /* The protocol ID for this box.  Note that only IDs from\n                            FF00H - FFFFH are accepted.  If more than one is included\n                            from the network, multiple calls should be made to send all\n                            of them. */\n    int contents_length; /* The number of octets in the contents. */\n    char *contents;      /* Carrier-defined content.  It is binary, opaque and\n                            loosely defined in LTE Layer 3 spec 24.008 */\n} RIL_PCO_Data;\n\n#ifdef RIL_SHLIB\nstruct RIL_Env {\n    /**\n     * \"t\" is parameter passed in on previous call to RIL_Notification\n     * routine.\n     *\n     * If \"e\" != SUCCESS, then response can be null/is ignored\n     *\n     * \"response\" is owned by caller, and should not be modified or\n     * freed by callee\n     *\n     * RIL_onRequestComplete will return as soon as possible\n     */\n    void (*OnRequestComplete)(RIL_Token t, RIL_Errno e,\n                           void *response, size_t responselen);\n\n#if defined(ANDROID_MULTI_SIM)\n    /**\n     * \"unsolResponse\" is one of RIL_UNSOL_RESPONSE_*\n     * \"data\" is pointer to data defined for that RIL_UNSOL_RESPONSE_*\n     *\n     * \"data\" is owned by caller, and should not be modified or freed by callee\n     */\n    void (*OnUnsolicitedResponse)(int unsolResponse, const void *data, size_t datalen, RIL_SOCKET_ID socket_id);\n#else\n    /**\n     * \"unsolResponse\" is one of RIL_UNSOL_RESPONSE_*\n     * \"data\" is pointer to data defined for that RIL_UNSOL_RESPONSE_*\n     *\n     * \"data\" is owned by caller, and should not be modified or freed by callee\n     */\n    void (*OnUnsolicitedResponse)(int unsolResponse, const void *data, size_t datalen);\n#endif\n    /**\n     * Call user-specifed \"callback\" function on on the same thread that\n     * RIL_RequestFunc is called. If \"relativeTime\" is specified, then it specifies\n     * a relative time value at which the callback is invoked. If relativeTime is\n     * NULL or points to a 0-filled structure, the callback will be invoked as\n     * soon as possible\n     */\n\n    void (*RequestTimedCallback) (RIL_TimedCallback callback,\n                                   void *param, const struct timeval *relativeTime);\n   /**\n    * \"t\" is parameter passed in on previous call RIL_Notification routine\n    *\n    * RIL_onRequestAck will be called by vendor when an Async RIL request was received\n    * by them and an ack needs to be sent back to java ril.\n    */\n    void (*OnRequestAck) (RIL_Token t);\n};\n\n\n/**\n *  RIL implementations must defined RIL_Init\n *  argc and argv will be command line arguments intended for the RIL implementation\n *  Return NULL on error\n *\n * @param env is environment point defined as RIL_Env\n * @param argc number of arguments\n * @param argv list fo arguments\n *\n */\nconst RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **argv);\n\n/**\n *  If BT SAP(SIM Access Profile) is supported, then RIL implementations must define RIL_SAP_Init\n *  for initializing RIL_RadioFunctions used for BT SAP communcations. It is called whenever RILD\n *  starts or modem restarts. Returns handlers for SAP related request that are made on SAP\n *  sepecific socket, analogous to the RIL_RadioFunctions returned by the call to RIL_Init\n *  and used on the general RIL socket.\n *  argc and argv will be command line arguments intended for the RIL implementation\n *  Return NULL on error.\n *\n * @param env is environment point defined as RIL_Env\n * @param argc number of arguments\n * @param argv list fo arguments\n *\n */\nconst RIL_RadioFunctions *RIL_SAP_Init(const struct RIL_Env *env, int argc, char **argv);\n\n#else /* RIL_SHLIB */\n\n/**\n * Call this once at startup to register notification routine\n *\n * @param callbacks user-specifed callback function\n */\nvoid RIL_register (const RIL_RadioFunctions *callbacks);\n\n\n/**\n *\n * RIL_onRequestComplete will return as soon as possible\n *\n * @param t is parameter passed in on previous call to RIL_Notification\n *          routine.\n * @param e error code\n *          if \"e\" != SUCCESS, then response can be null/is ignored\n * @param response is owned by caller, and should not be modified or\n *                 freed by callee\n * @param responselen the length of response in byte\n */\nvoid RIL_onRequestComplete(RIL_Token t, RIL_Errno e,\n                           void *response, size_t responselen);\n\n/**\n * RIL_onRequestAck will be called by vendor when an Async RIL request was received by them and\n * an ack needs to be sent back to java ril. This doesn't mark the end of the command or it's\n * results, just that the command was received and will take a while. After sending this Ack\n * its vendor's responsibility to make sure that AP is up whenever needed while command is\n * being processed.\n *\n * @param t is parameter passed in on previous call to RIL_Notification\n *          routine.\n */\nvoid RIL_onRequestAck(RIL_Token t);\n\n#if defined(ANDROID_MULTI_SIM)\n/**\n * @param unsolResponse is one of RIL_UNSOL_RESPONSE_*\n * @param data is pointer to data defined for that RIL_UNSOL_RESPONSE_*\n *     \"data\" is owned by caller, and should not be modified or freed by callee\n * @param datalen the length of data in byte\n */\n\nvoid RIL_onUnsolicitedResponse(int unsolResponse, const void *data,\n                                size_t datalen, RIL_SOCKET_ID socket_id);\n#else\n/**\n * @param unsolResponse is one of RIL_UNSOL_RESPONSE_*\n * @param data is pointer to data defined for that RIL_UNSOL_RESPONSE_*\n *     \"data\" is owned by caller, and should not be modified or freed by callee\n * @param datalen the length of data in byte\n */\n\nvoid RIL_onUnsolicitedResponse(int unsolResponse, const void *data,\n                                size_t datalen);\n#endif\n\n/**\n * Call user-specifed \"callback\" function on on the same thread that\n * RIL_RequestFunc is called. If \"relativeTime\" is specified, then it specifies\n * a relative time value at which the callback is invoked. If relativeTime is\n * NULL or points to a 0-filled structure, the callback will be invoked as\n * soon as possible\n *\n * @param callback user-specifed callback function\n * @param param parameter list\n * @param relativeTime a relative time value at which the callback is invoked\n */\n\nvoid RIL_requestTimedCallback (RIL_TimedCallback callback,\n                               void *param, const struct timeval *relativeTime);\n\n#endif /* RIL_SHLIB */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /*ANDROID_RIL_H*/\n"
  },
  {
    "path": "init/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE_TAGS := optional\nLOCAL_C_INCLUDES := system/core/init\nLOCAL_CFLAGS := -Wall\nLOCAL_SRC_FILES := init_oneplus2.cpp\nLOCAL_MODULE := libinit_oneplus2\n\ninclude $(BUILD_STATIC_LIBRARY)\n"
  },
  {
    "path": "init/init_oneplus2.cpp",
    "content": "/*\n   Copyright (c) 2016, The CyanogenMod Project\n\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions are\n   met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n   ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n   BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n   BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n   OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include <stdlib.h>\n\n#include \"vendor_init.h\"\n#include \"property_service.h\"\n#include \"log.h\"\n#include \"util.h\"\n\nvoid init_variant_properties() {\n\n    std::string device = property_get(\"ro.cm.device\");\n    std::string rf_version;\n\n    if (device != \"oneplus2\")\n        return;\n\n    rf_version = property_get(\"ro.boot.rf_v1\");\n\n    if (rf_version == \"14\") {\n        /* Chinese */\n        property_set(\"ro.product.model\", \"ONE A2001\");\n        property_set(\"ro.rf_version\", \"TDD_FDD_Ch_All\");\n        property_set(\"telephony.lteOnCdmaDevice\", \"1\");\n        property_set(\"ro.telephony.default_network\", \"20,20\");\n    } else if (rf_version == \"24\") {\n        /* Asia/Europe */\n        property_set(\"ro.product.model\", \"ONE A2003\");\n        property_set(\"ro.rf_version\", \"TDD_FDD_Eu\");\n        property_set(\"ro.telephony.default_network\", \"9,9\");\n    } else if (rf_version == \"34\") {\n        /* America */\n        property_set(\"ro.product.model\", \"ONE A2005\");\n        property_set(\"ro.rf_version\", \"TDD_FDD_Am\");\n        property_set(\"telephony.lteOnCdmaDevice\", \"1\");\n        property_set(\"ro.telephony.default_network\", \"9,9\");\n    }\n}\n\nvoid vendor_load_properties() {\n    init_variant_properties();\n}\n"
  },
  {
    "path": "keylayout/fpc1020.kl",
    "content": "# Copyright (c) 2012, 2014 The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n#       copyright notice, this list of conditions and the following\n#       disclaimer in the documentation and/or other materials provided\n#       with the distribution.\n#     * Neither the name of The Linux Foundation nor the names of its\n#       contributors may be used to endorse or promote products derived\n#       from this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nkey 102   HOME VIRTUAL\nkey 116   POWER\nkey 60    F2\n"
  },
  {
    "path": "keylayout/synaptics.kl",
    "content": "# Copyright (c) 2012, 2014 The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n#       copyright notice, this list of conditions and the following\n#       disclaimer in the documentation and/or other materials provided\n#       with the distribution.\n#     * Neither the name of The Linux Foundation nor the names of its\n#       contributors may be used to endorse or promote products derived\n#       from this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nkey 158   APP_SWITCH VIRTUAL\nkey 580   BACK VIRTUAL\nkey 143   WAKEUP VIRTUAL\n"
  },
  {
    "path": "liblight/Android.mk",
    "content": "# Copyright (C) 2014 The CyanogenMod Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nLOCAL_PATH:= $(call my-dir)\n# HAL module implemenation stored in\n# hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.board.platform>.so\ninclude $(CLEAR_VARS)\n\nLOCAL_SRC_FILES := lights.c\nLOCAL_MODULE_RELATIVE_PATH    := hw\nLOCAL_SHARED_LIBRARIES := liblog libcutils\n\nLOCAL_MODULE := lights.msm8994\nLOCAL_MODULE_TAGS := optional\n\ninclude $(BUILD_SHARED_LIBRARY)\n"
  },
  {
    "path": "liblight/NOTICE",
    "content": "\n   Copyright (c) 2008, The Android Open Source Project\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n"
  },
  {
    "path": "liblight/lights.c",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n * Copyright (C) 2014 The Linux Foundation. All rights reserved.\n * Copyright (C) 2015 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"lights\"\n\n#include <cutils/log.h>\n\n#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <pthread.h>\n\n#include <sys/ioctl.h>\n#include <sys/types.h>\n\n#include <hardware/lights.h>\n\n/******************************************************************************/\n\nstatic pthread_once_t g_init = PTHREAD_ONCE_INIT;\nstatic pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;\nstatic struct light_state_t g_attention;\nstatic struct light_state_t g_notification;\nstatic struct light_state_t g_battery;\n\nchar const*const RED_LED_FILE\n        = \"/sys/class/leds/red/brightness\";\n\nchar const*const GREEN_LED_FILE\n        = \"/sys/class/leds/green/brightness\";\n\nchar const*const BLUE_LED_FILE\n        = \"/sys/class/leds/blue/brightness\";\n\nchar const*const LCD_FILE\n        = \"/sys/class/leds/lcd-backlight/brightness\";\n\nconst char*const BUTTONS_FILE\n        = \"/sys/class/leds/button-backlight/brightness\";\n\nchar const*const RED_DUTY_PCTS_FILE\n        = \"/sys/class/leds/red/duty_pcts\";\n\nchar const*const GREEN_DUTY_PCTS_FILE\n        = \"/sys/class/leds/green/duty_pcts\";\n\nchar const*const BLUE_DUTY_PCTS_FILE\n        = \"/sys/class/leds/blue/duty_pcts\";\n\nchar const*const RED_START_IDX_FILE\n        = \"/sys/class/leds/red/start_idx\";\n\nchar const*const GREEN_START_IDX_FILE\n        = \"/sys/class/leds/green/start_idx\";\n\nchar const*const BLUE_START_IDX_FILE\n        = \"/sys/class/leds/blue/start_idx\";\n\nchar const*const RED_PAUSE_LO_FILE\n        = \"/sys/class/leds/red/pause_lo\";\n\nchar const*const GREEN_PAUSE_LO_FILE\n        = \"/sys/class/leds/green/pause_lo\";\n\nchar const*const BLUE_PAUSE_LO_FILE\n        = \"/sys/class/leds/blue/pause_lo\";\n\nchar const*const RED_PAUSE_HI_FILE\n        = \"/sys/class/leds/red/pause_hi\";\n\nchar const*const GREEN_PAUSE_HI_FILE\n        = \"/sys/class/leds/green/pause_hi\";\n\nchar const*const BLUE_PAUSE_HI_FILE\n        = \"/sys/class/leds/blue/pause_hi\";\n\nchar const*const RED_RAMP_STEP_MS_FILE\n        = \"/sys/class/leds/red/ramp_step_ms\";\n\nchar const*const GREEN_RAMP_STEP_MS_FILE\n        = \"/sys/class/leds/green/ramp_step_ms\";\n\nchar const*const BLUE_RAMP_STEP_MS_FILE\n        = \"/sys/class/leds/blue/ramp_step_ms\";\n\nchar const*const RED_BLINK_FILE\n        = \"/sys/class/leds/red/blink\";\n\nchar const*const GREEN_BLINK_FILE\n        = \"/sys/class/leds/green/blink\";\n\nchar const*const BLUE_BLINK_FILE\n        = \"/sys/class/leds/blue/blink\";\n\n#define RAMP_SIZE 8\nstatic int BRIGHTNESS_RAMP[RAMP_SIZE]\n        = { 0, 12, 25, 37, 50, 72, 85, 100 };\n#define RAMP_STEP_DURATION 50\n\n/**\n * device methods\n */\n\nvoid init_globals(void)\n{\n    // init the mutex\n    pthread_mutex_init(&g_lock, NULL);\n}\n\nstatic int\nwrite_int(char const* path, int value)\n{\n    int fd;\n    static int already_warned = 0;\n\n    fd = open(path, O_RDWR);\n    if (fd >= 0) {\n        char buffer[20];\n        int bytes = snprintf(buffer, sizeof(buffer), \"%d\\n\", value);\n        ssize_t amt = write(fd, buffer, (size_t)bytes);\n        close(fd);\n        return amt == -1 ? -errno : 0;\n    } else {\n        if (already_warned == 0) {\n            ALOGE(\"write_int failed to open %s\\n\", path);\n            already_warned = 1;\n        }\n        return -errno;\n    }\n}\n\nstatic int\nwrite_str(char const* path, char* value)\n{\n    int fd;\n    static int already_warned = 0;\n\n    fd = open(path, O_RDWR);\n    if (fd >= 0) {\n        char buffer[1024];\n        int bytes = snprintf(buffer, sizeof(buffer), \"%s\\n\", value);\n        ssize_t amt = write(fd, buffer, (size_t)bytes);\n        close(fd);\n        return amt == -1 ? -errno : 0;\n    } else {\n        if (already_warned == 0) {\n            ALOGE(\"write_int failed to open %s\\n\", path);\n            already_warned = 1;\n        }\n        return -errno;\n    }\n}\n\nstatic int\nis_lit(struct light_state_t const* state)\n{\n    return state->color & 0x00ffffff;\n}\n\nstatic int\nrgb_to_brightness(struct light_state_t const* state)\n{\n    int color = state->color & 0x00ffffff;\n    return ((77*((color>>16)&0x00ff))\n            + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;\n}\n\nstatic int\nset_light_backlight(struct light_device_t* dev,\n        struct light_state_t const* state)\n{\n    int err = 0;\n    int brightness = rgb_to_brightness(state);\n    if(!dev) {\n        return -1;\n    }\n    pthread_mutex_lock(&g_lock);\n    err = write_int(LCD_FILE, brightness);\n    pthread_mutex_unlock(&g_lock);\n    return err;\n}\n\nstatic int\nset_light_buttons(struct light_device_t *dev,\n        const struct light_state_t *state)\n{\n    int err = 0;\n    int brightness = rgb_to_brightness(state);\n    if(!dev) {\n        return -1;\n    }\n    pthread_mutex_lock(&g_lock);\n    err = write_int(BUTTONS_FILE, brightness);\n    pthread_mutex_unlock(&g_lock);\n    return err;\n}\n\nstatic char*\nget_scaled_duty_pcts(int brightness)\n{\n    char *buf = malloc(5 * RAMP_SIZE * sizeof(char));\n    char *pad = \"\";\n    int i = 0;\n\n    memset(buf, 0, 5 * RAMP_SIZE * sizeof(char));\n\n    for (i = 0; i < RAMP_SIZE; i++) {\n        char temp[5] = \"\";\n        snprintf(temp, sizeof(temp), \"%s%d\", pad, (BRIGHTNESS_RAMP[i] * brightness / 255));\n        strcat(buf, temp);\n        pad = \",\";\n    }\n    ALOGV(\"%s: brightness=%d duty=%s\", __func__, brightness, buf);\n    return buf;\n}\n\nstatic int\nset_speaker_light_locked(struct light_device_t* dev,\n        struct light_state_t const* state)\n{\n    int red, green, blue, blink;\n    int onMS, offMS, stepDuration, pauseHi;\n    unsigned int colorRGB;\n    char *duty;\n\n    if(!dev) {\n        return -1;\n    }\n\n    switch (state->flashMode) {\n        case LIGHT_FLASH_TIMED:\n            onMS = state->flashOnMS;\n            offMS = state->flashOffMS;\n            break;\n        case LIGHT_FLASH_NONE:\n        default:\n            onMS = 0;\n            offMS = 0;\n            break;\n    }\n\n    colorRGB = state->color;\n\n    ALOGV(\"set_speaker_light_locked mode %d, colorRGB=%08X, onMS=%d, offMS=%d\\n\",\n            state->flashMode, colorRGB, onMS, offMS);\n\n    red = (colorRGB >> 16) & 0xFF;\n    green = (colorRGB >> 8) & 0xFF;\n    blue = colorRGB & 0xFF;\n    // bias for true white\n    if (colorRGB != 0 && red == green && green == blue) {\n        blue = (blue * 171) / 256;\n    }\n    blink = onMS > 0 && offMS > 0;\n\n    // disable all blinking to start\n    write_int(RED_BLINK_FILE, 0);\n    write_int(GREEN_BLINK_FILE, 0);\n    write_int(BLUE_BLINK_FILE, 0);\n\n    if (blink) {\n        stepDuration = RAMP_STEP_DURATION;\n        pauseHi = onMS - (stepDuration * RAMP_SIZE * 2);\n        if (stepDuration * RAMP_SIZE * 2 > onMS) {\n            stepDuration = onMS / (RAMP_SIZE * 2);\n            pauseHi = 0;\n        }\n\n        // red\n        write_int(RED_START_IDX_FILE, 0);\n        duty = get_scaled_duty_pcts(red);    \n        write_str(RED_DUTY_PCTS_FILE, duty);\n        write_int(RED_PAUSE_LO_FILE, offMS);\n        // The led driver is configured to ramp up then ramp\n        // down the lut. This effectively doubles the ramp duration.\n        write_int(RED_PAUSE_HI_FILE, pauseHi);\n        write_int(RED_RAMP_STEP_MS_FILE, stepDuration);\n        free(duty);\n\n        // green\n        write_int(GREEN_START_IDX_FILE, RAMP_SIZE);\n        duty = get_scaled_duty_pcts(green);\n        write_str(GREEN_DUTY_PCTS_FILE, duty);\n        write_int(GREEN_PAUSE_LO_FILE, offMS);\n        // The led driver is configured to ramp up then ramp\n        // down the lut. This effectively doubles the ramp duration.\n        write_int(GREEN_PAUSE_HI_FILE, pauseHi);\n        write_int(GREEN_RAMP_STEP_MS_FILE, stepDuration);\n        free(duty);\n\n        // blue\n        write_int(BLUE_START_IDX_FILE, RAMP_SIZE * 2);\n        duty = get_scaled_duty_pcts(blue);\n        write_str(BLUE_DUTY_PCTS_FILE, duty);\n        write_int(BLUE_PAUSE_LO_FILE, offMS);\n        // The led driver is configured to ramp up then ramp\n        // down the lut. This effectively doubles the ramp duration.\n        write_int(BLUE_PAUSE_HI_FILE, pauseHi);\n        write_int(BLUE_RAMP_STEP_MS_FILE, stepDuration);\n        free(duty);\n\n        // start the party\n        write_int(RED_BLINK_FILE, red);\n        write_int(GREEN_BLINK_FILE, green);\n        write_int(BLUE_BLINK_FILE, blue);\n\n    } else {\n        write_int(RED_LED_FILE, red);\n        write_int(GREEN_LED_FILE, green);\n        write_int(BLUE_LED_FILE, blue);\n    }\n\n\n    return 0;\n}\n\nstatic void\nhandle_speaker_light_locked(struct light_device_t* dev)\n{\n    if (is_lit(&g_attention)) {\n        set_speaker_light_locked(dev, &g_attention);\n    } else if (is_lit(&g_notification)) {\n        set_speaker_light_locked(dev, &g_notification);\n    } else {\n        set_speaker_light_locked(dev, &g_battery);\n    }\n}\n\nstatic int\nset_light_battery(struct light_device_t* dev,\n        struct light_state_t const* state)\n{\n    pthread_mutex_lock(&g_lock);\n    g_battery = *state;\n    handle_speaker_light_locked(dev);\n    pthread_mutex_unlock(&g_lock);\n    return 0;\n}\n\nstatic int\nset_light_notifications(struct light_device_t* dev,\n        struct light_state_t const* state)\n{\n    pthread_mutex_lock(&g_lock);\n\n    unsigned int brightness;\n    unsigned int color;\n    unsigned int rgb[3];\n\n    g_notification = *state;\n\n    // If a brightness has been applied by the user\n    brightness = (g_notification.color & 0xFF000000) >> 24;\n    if (brightness > 0 && brightness < 0xFF) {\n\n        // Retrieve each of the RGB colors\n        color = g_notification.color & 0x00FFFFFF;\n        rgb[0] = (color >> 16) & 0xFF;\n        rgb[1] = (color >> 8) & 0xFF;\n        rgb[2] = color & 0xFF;\n\n        // Apply the brightness level\n        if (rgb[0] > 0)\n            rgb[0] = (rgb[0] * brightness) / 0xFF;\n        if (rgb[1] > 0)\n            rgb[1] = (rgb[1] * brightness) / 0xFF;\n        if (rgb[2] > 0)\n            rgb[2] = (rgb[2] * brightness) / 0xFF;\n\n        // Update with the new color\n        g_notification.color = (rgb[0] << 16) + (rgb[1] << 8) + rgb[2];\n    }\n\n    handle_speaker_light_locked(dev);\n    pthread_mutex_unlock(&g_lock);\n    return 0;\n}\n\nstatic int\nset_light_attention(struct light_device_t* dev,\n        struct light_state_t const* state)\n{\n    pthread_mutex_lock(&g_lock);\n    g_attention = *state;\n    handle_speaker_light_locked(dev);\n    pthread_mutex_unlock(&g_lock);\n    return 0;\n}\n\n/** Close the lights device */\nstatic int\nclose_lights(struct light_device_t *dev)\n{\n    if (dev) {\n        free(dev);\n    }\n    return 0;\n}\n\n\n/******************************************************************************/\n\n/**\n * module methods\n */\n\n/** Open a new instance of a lights device using name */\nstatic int open_lights(const struct hw_module_t* module, char const* name,\n        struct hw_device_t** device)\n{\n    int (*set_light)(struct light_device_t* dev,\n            struct light_state_t const* state);\n\n    if (0 == strcmp(LIGHT_ID_BACKLIGHT, name))\n        set_light = set_light_backlight;\n    else if (0 == strcmp(LIGHT_ID_BUTTONS, name))\n        set_light = set_light_buttons;\n    else if (0 == strcmp(LIGHT_ID_BATTERY, name))\n        set_light = set_light_battery;\n    else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name))\n        set_light = set_light_notifications;\n    else if (0 == strcmp(LIGHT_ID_ATTENTION, name))\n        set_light = set_light_attention;\n    else\n        return -EINVAL;\n\n    pthread_once(&g_init, init_globals);\n\n    struct light_device_t *dev = malloc(sizeof(struct light_device_t));\n\n    if(!dev)\n        return -ENOMEM;\n\n    memset(dev, 0, sizeof(*dev));\n\n    dev->common.tag = HARDWARE_DEVICE_TAG;\n    dev->common.version = 0;\n    dev->common.module = (struct hw_module_t*)module;\n    dev->common.close = (int (*)(struct hw_device_t*))close_lights;\n    dev->set_light = set_light;\n\n    *device = (struct hw_device_t*)dev;\n    return 0;\n}\n\nstatic struct hw_module_methods_t lights_module_methods = {\n    .open =  open_lights,\n};\n\n/*\n * The lights Module\n */\nstruct hw_module_t HAL_MODULE_INFO_SYM = {\n    .tag = HARDWARE_MODULE_TAG,\n    .version_major = 1,\n    .version_minor = 0,\n    .id = LIGHTS_HARDWARE_MODULE_ID,\n    .name = \"Lights Module\",\n    .author = \"The CyanogenMod Project\",\n    .methods = &lights_module_methods,\n};\n"
  },
  {
    "path": "libshims/Android.mk",
    "content": "# Copyright 2010 The Android Open Source Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nCAMERA_CLIENT_LOCAL_PATH:= $(call my-dir)\ninclude $(CLEAR_VARS)\n\nLOCAL_PATH := $(CAMERA_CLIENT_LOCAL_PATH)\n\nLOCAL_SRC_FILES:= \\\n\tCamera.cpp \\\n\tCameraMetadata.cpp \\\n\tCaptureResult.cpp \\\n\tCameraParameters2.cpp \\\n\tICamera.cpp \\\n\tICameraClient.cpp \\\n\tICameraService.cpp \\\n\tICameraServiceListener.cpp \\\n\tICameraServiceProxy.cpp \\\n\tICameraRecordingProxy.cpp \\\n\tICameraRecordingProxyListener.cpp \\\n\tcamera2/ICameraDeviceUser.cpp \\\n\tcamera2/ICameraDeviceCallbacks.cpp \\\n\tcamera2/CaptureRequest.cpp \\\n\tcamera2/OutputConfiguration.cpp \\\n\tCameraBase.cpp \\\n\tCameraUtils.cpp \\\n\tVendorTagDescriptor.cpp \\\n\tCameraParameters.cpp\n\nLOCAL_SHARED_LIBRARIES := \\\n\tlibcutils \\\n\tlibutils \\\n\tliblog \\\n\tlibbinder \\\n\tlibhardware \\\n\tlibui \\\n\tlibgui \\\n\tlibcamera_metadata\n\nLOCAL_C_INCLUDES += \\\n\t$(LOCAL_PATH)/include \\\n\tsystem/media/camera/include \\\n\tsystem/media/private/camera/include\n\nLOCAL_MODULE:= libshim_ims-camera\n\ninclude $(BUILD_SHARED_LIBRARY)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_SRC_FILES := camera.cpp\nLOCAL_MODULE := libshim_camera\nLOCAL_MODULE_TAGS := optional\nLOCAL_MODULE_CLASS := SHARED_LIBRARIES\nLOCAL_32_BIT_ONLY := true\nLOCAL_SHARED_LIBRARIES := libgui libui\n\ninclude $(BUILD_SHARED_LIBRARY)\n"
  },
  {
    "path": "libshims/Camera.cpp",
    "content": "/*\n**\n** Copyright (C) 2008, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n//#define LOG_NDEBUG 0\n#define LOG_TAG \"Camera\"\n#include <utils/Log.h>\n#include <utils/threads.h>\n#include <utils/String16.h>\n#include <binder/IPCThreadState.h>\n#include <binder/IServiceManager.h>\n#include <binder/IMemory.h>\n\n#include <camera/Camera.h>\n#include <camera/ICameraRecordingProxyListener.h>\n#include <camera/ICameraService.h>\n#include <camera/ICamera.h>\n\n#include <gui/IGraphicBufferProducer.h>\n#include <gui/Surface.h>\n\nnamespace android {\n\nCamera::Camera(int cameraId)\n    : CameraBase(cameraId)\n{\n}\n\nCameraTraits<Camera>::TCamConnectService CameraTraits<Camera>::fnConnectService =\n        &ICameraService::connect;\n\n// construct a camera client from an existing camera remote\nsp<Camera> Camera::create(const sp<ICamera>& camera)\n{\n     ALOGV(\"create\");\n     if (camera == 0) {\n         ALOGE(\"camera remote is a NULL pointer\");\n         return 0;\n     }\n\n    sp<Camera> c = new Camera(-1);\n    if (camera->connect(c) == NO_ERROR) {\n        c->mStatus = NO_ERROR;\n        c->mCamera = camera;\n        IInterface::asBinder(camera)->linkToDeath(c);\n        return c;\n    }\n    return 0;\n}\n\nCamera::~Camera()\n{\n    // We don't need to call disconnect() here because if the CameraService\n    // thinks we are the owner of the hardware, it will hold a (strong)\n    // reference to us, and we can't possibly be here. We also don't want to\n    // call disconnect() here if we are in the same process as mediaserver,\n    // because we may be invoked by CameraService::Client::connect() and will\n    // deadlock if we call any method of ICamera here.\n}\n\nsp<Camera> Camera::connect(int cameraId, const String16& clientPackageName,\n        int clientUid)\n{\n    return CameraBaseT::connect(cameraId, clientPackageName, clientUid);\n}\n\nstatus_t Camera::connectLegacy(int cameraId, int halVersion,\n        const String16& clientPackageName,\n        int clientUid,\n        sp<Camera>& camera)\n{\n    ALOGV(\"%s: connect legacy camera device\", __FUNCTION__);\n    sp<Camera> c = new Camera(cameraId);\n    sp<ICameraClient> cl = c;\n    status_t status = NO_ERROR;\n    const sp<ICameraService>& cs = CameraBaseT::getCameraService();\n\n    if (cs != 0) {\n        status = cs.get()->connectLegacy(cl, cameraId, halVersion, clientPackageName,\n                                        clientUid, /*out*/c->mCamera);\n    }\n    if (status == OK && c->mCamera != 0) {\n        IInterface::asBinder(c->mCamera)->linkToDeath(c);\n        c->mStatus = NO_ERROR;\n        camera = c;\n    } else {\n        ALOGW(\"An error occurred while connecting to camera %d: %d (%s)\",\n                cameraId, status, strerror(-status));\n        c.clear();\n    }\n    return status;\n}\n\nstatus_t Camera::reconnect()\n{\n    ALOGV(\"reconnect\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->connect(this);\n}\n\nstatus_t Camera::lock()\n{\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->lock();\n}\n\nstatus_t Camera::unlock()\n{\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->unlock();\n}\n\n// pass the buffered IGraphicBufferProducer to the camera service\nstatus_t Camera::setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)\n{\n    ALOGV(\"setPreviewTarget(%p)\", bufferProducer.get());\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    ALOGD_IF(bufferProducer == 0, \"app passed NULL surface\");\n    return c->setPreviewTarget(bufferProducer);\n}\n\n// start preview mode\nstatus_t Camera::startPreview()\n{\n    ALOGV(\"startPreview\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->startPreview();\n}\n\nstatus_t Camera::storeMetaDataInBuffers(bool enabled)\n{\n    ALOGV(\"storeMetaDataInBuffers: %s\",\n            enabled? \"true\": \"false\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->storeMetaDataInBuffers(enabled);\n}\n\n// start recording mode, must call setPreviewTarget first\nstatus_t Camera::startRecording()\n{\n    ALOGV(\"startRecording\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->startRecording();\n}\n\n// stop preview mode\nvoid Camera::stopPreview()\n{\n    ALOGV(\"stopPreview\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return;\n    c->stopPreview();\n}\n\n// stop recording mode\nvoid Camera::stopRecording()\n{\n    ALOGV(\"stopRecording\");\n    {\n        Mutex::Autolock _l(mLock);\n        mRecordingProxyListener.clear();\n    }\n    sp <ICamera> c = mCamera;\n    if (c == 0) return;\n    c->stopRecording();\n}\n\n// release a recording frame\nvoid Camera::releaseRecordingFrame(const sp<IMemory>& mem)\n{\n    ALOGV(\"releaseRecordingFrame\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return;\n    c->releaseRecordingFrame(mem);\n}\n\n// get preview state\nbool Camera::previewEnabled()\n{\n    ALOGV(\"previewEnabled\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return false;\n    return c->previewEnabled();\n}\n\n// get recording state\nbool Camera::recordingEnabled()\n{\n    ALOGV(\"recordingEnabled\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return false;\n    return c->recordingEnabled();\n}\n\nstatus_t Camera::autoFocus()\n{\n    ALOGV(\"autoFocus\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->autoFocus();\n}\n\nstatus_t Camera::cancelAutoFocus()\n{\n    ALOGV(\"cancelAutoFocus\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->cancelAutoFocus();\n}\n\n// take a picture\nstatus_t Camera::takePicture(int msgType)\n{\n    ALOGV(\"takePicture: 0x%x\", msgType);\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->takePicture(msgType);\n}\n\n// set preview/capture parameters - key/value pairs\nstatus_t Camera::setParameters(const String8& params)\n{\n    ALOGV(\"setParameters\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->setParameters(params);\n}\n\n// get preview/capture parameters - key/value pairs\nString8 Camera::getParameters() const\n{\n    ALOGV(\"getParameters\");\n    String8 params;\n    sp <ICamera> c = mCamera;\n    if (c != 0) params = mCamera->getParameters();\n    return params;\n}\n\n// send command to camera driver\nstatus_t Camera::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)\n{\n    ALOGV(\"sendCommand\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->sendCommand(cmd, arg1, arg2);\n}\n\nvoid Camera::setListener(const sp<CameraListener>& listener)\n{\n    Mutex::Autolock _l(mLock);\n    mListener = listener;\n}\n\nvoid Camera::setRecordingProxyListener(const sp<ICameraRecordingProxyListener>& listener)\n{\n    Mutex::Autolock _l(mLock);\n    mRecordingProxyListener = listener;\n}\n\nvoid Camera::setPreviewCallbackFlags(int flag)\n{\n    ALOGV(\"setPreviewCallbackFlags\");\n    sp <ICamera> c = mCamera;\n    if (c == 0) return;\n    mCamera->setPreviewCallbackFlag(flag);\n}\n\nstatus_t Camera::setPreviewCallbackTarget(\n        const sp<IGraphicBufferProducer>& callbackProducer)\n{\n    sp <ICamera> c = mCamera;\n    if (c == 0) return NO_INIT;\n    return c->setPreviewCallbackTarget(callbackProducer);\n}\n\n// callback from camera service\nvoid Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)\n{\n    return CameraBaseT::notifyCallback(msgType, ext1, ext2);\n}\n\n// callback from camera service when frame or image is ready\nvoid Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,\n                          camera_frame_metadata_t *metadata)\n{\n    sp<CameraListener> listener;\n    {\n        Mutex::Autolock _l(mLock);\n        listener = mListener;\n    }\n    if (listener != NULL) {\n        listener->postData(msgType, dataPtr, metadata);\n    }\n}\n\n// callback from camera service when timestamped frame is ready\nvoid Camera::dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr)\n{\n    // If recording proxy listener is registered, forward the frame and return.\n    // The other listener (mListener) is ignored because the receiver needs to\n    // call releaseRecordingFrame.\n    sp<ICameraRecordingProxyListener> proxylistener;\n    {\n        Mutex::Autolock _l(mLock);\n        proxylistener = mRecordingProxyListener;\n    }\n    if (proxylistener != NULL) {\n        proxylistener->dataCallbackTimestamp(timestamp, msgType, dataPtr);\n        return;\n    }\n\n    sp<CameraListener> listener;\n    {\n        Mutex::Autolock _l(mLock);\n        listener = mListener;\n    }\n\n    if (listener != NULL) {\n        listener->postDataTimestamp(timestamp, msgType, dataPtr);\n    } else {\n        ALOGW(\"No listener was set. Drop a recording frame.\");\n        releaseRecordingFrame(dataPtr);\n    }\n}\n\nsp<ICameraRecordingProxy> Camera::getRecordingProxy() {\n    ALOGV(\"getProxy\");\n    return new RecordingProxy(this);\n}\n\nstatus_t Camera::RecordingProxy::startRecording(const sp<ICameraRecordingProxyListener>& listener)\n{\n    ALOGV(\"RecordingProxy::startRecording\");\n    mCamera->setRecordingProxyListener(listener);\n    mCamera->reconnect();\n    return mCamera->startRecording();\n}\n\nvoid Camera::RecordingProxy::stopRecording()\n{\n    ALOGV(\"RecordingProxy::stopRecording\");\n    mCamera->stopRecording();\n}\n\nvoid Camera::RecordingProxy::releaseRecordingFrame(const sp<IMemory>& mem)\n{\n    ALOGV(\"RecordingProxy::releaseRecordingFrame\");\n    mCamera->releaseRecordingFrame(mem);\n}\n\nCamera::RecordingProxy::RecordingProxy(const sp<Camera>& camera)\n{\n    mCamera = camera;\n}\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/CameraBase.cpp",
    "content": "/*\n**\n** Copyright (C) 2013, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n//#define LOG_NDEBUG 0\n#define LOG_TAG \"CameraBase\"\n#include <utils/Log.h>\n#include <utils/threads.h>\n#include <utils/Mutex.h>\n\n#include <binder/IPCThreadState.h>\n#include <binder/IServiceManager.h>\n#include <binder/IMemory.h>\n\n#include <camera/CameraBase.h>\n#include <camera/ICameraService.h>\n\n// needed to instantiate\n#include <camera/Camera.h>\n\n#include <system/camera_metadata.h>\n\nnamespace android {\n\nnamespace {\n    sp<ICameraService>        gCameraService;\n    const int                 kCameraServicePollDelay = 500000; // 0.5s\n    const char*               kCameraServiceName      = \"media.camera\";\n\n    Mutex                     gLock;\n\n    class DeathNotifier : public IBinder::DeathRecipient\n    {\n    public:\n        DeathNotifier() {\n        }\n\n        virtual void binderDied(const wp<IBinder>& /*who*/) {\n            ALOGV(\"binderDied\");\n            Mutex::Autolock _l(gLock);\n            gCameraService.clear();\n            ALOGW(\"Camera service died!\");\n        }\n    };\n\n    sp<DeathNotifier>         gDeathNotifier;\n}; // namespace anonymous\n\n///////////////////////////////////////////////////////////\n// CameraBase definition\n///////////////////////////////////////////////////////////\n\n// establish binder interface to camera service\ntemplate <typename TCam, typename TCamTraits>\nconst sp<ICameraService>& CameraBase<TCam, TCamTraits>::getCameraService()\n{\n    Mutex::Autolock _l(gLock);\n    if (gCameraService.get() == 0) {\n        sp<IServiceManager> sm = defaultServiceManager();\n        sp<IBinder> binder;\n        do {\n            binder = sm->getService(String16(kCameraServiceName));\n            if (binder != 0) {\n                break;\n            }\n            ALOGW(\"CameraService not published, waiting...\");\n            usleep(kCameraServicePollDelay);\n        } while(true);\n        if (gDeathNotifier == NULL) {\n            gDeathNotifier = new DeathNotifier();\n        }\n        binder->linkToDeath(gDeathNotifier);\n        gCameraService = interface_cast<ICameraService>(binder);\n    }\n    ALOGE_IF(gCameraService == 0, \"no CameraService!?\");\n    return gCameraService;\n}\n\ntemplate <typename TCam, typename TCamTraits>\nsp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId,\n                                               const String16& clientPackageName,\n                                               int clientUid)\n{\n    ALOGV(\"%s: connect\", __FUNCTION__);\n    sp<TCam> c = new TCam(cameraId);\n    sp<TCamCallbacks> cl = c;\n    status_t status = NO_ERROR;\n    const sp<ICameraService>& cs = getCameraService();\n\n    if (cs != 0) {\n        TCamConnectService fnConnectService = TCamTraits::fnConnectService;\n        status = (cs.get()->*fnConnectService)(cl, cameraId, clientPackageName, clientUid,\n                                             /*out*/ c->mCamera);\n    }\n    if (status == OK && c->mCamera != 0) {\n        IInterface::asBinder(c->mCamera)->linkToDeath(c);\n        c->mStatus = NO_ERROR;\n    } else {\n        ALOGW(\"An error occurred while connecting to camera: %d\", cameraId);\n        c.clear();\n    }\n    return c;\n}\n\ntemplate <typename TCam, typename TCamTraits>\nvoid CameraBase<TCam, TCamTraits>::disconnect()\n{\n    ALOGV(\"%s: disconnect\", __FUNCTION__);\n    if (mCamera != 0) {\n        mCamera->disconnect();\n        IInterface::asBinder(mCamera)->unlinkToDeath(this);\n        mCamera = 0;\n    }\n    ALOGV(\"%s: disconnect (done)\", __FUNCTION__);\n}\n\ntemplate <typename TCam, typename TCamTraits>\nCameraBase<TCam, TCamTraits>::CameraBase(int cameraId) :\n    mStatus(UNKNOWN_ERROR),\n    mCameraId(cameraId)\n{\n}\n\ntemplate <typename TCam, typename TCamTraits>\nCameraBase<TCam, TCamTraits>::~CameraBase()\n{\n}\n\ntemplate <typename TCam, typename TCamTraits>\nsp<typename TCamTraits::TCamUser> CameraBase<TCam, TCamTraits>::remote()\n{\n    return mCamera;\n}\n\ntemplate <typename TCam, typename TCamTraits>\nstatus_t CameraBase<TCam, TCamTraits>::getStatus()\n{\n    return mStatus;\n}\n\ntemplate <typename TCam, typename TCamTraits>\nvoid CameraBase<TCam, TCamTraits>::binderDied(const wp<IBinder>& /*who*/) {\n    ALOGW(\"mediaserver's remote binder Camera object died\");\n    notifyCallback(CAMERA_MSG_ERROR, CAMERA_ERROR_SERVER_DIED, /*ext2*/0);\n}\n\ntemplate <typename TCam, typename TCamTraits>\nvoid CameraBase<TCam, TCamTraits>::setListener(const sp<TCamListener>& listener)\n{\n    Mutex::Autolock _l(mLock);\n    mListener = listener;\n}\n\n// callback from camera service\ntemplate <typename TCam, typename TCamTraits>\nvoid CameraBase<TCam, TCamTraits>::notifyCallback(int32_t msgType,\n                                                  int32_t ext1,\n                                                  int32_t ext2)\n{\n    sp<TCamListener> listener;\n    {\n        Mutex::Autolock _l(mLock);\n        listener = mListener;\n    }\n    if (listener != NULL) {\n        listener->notify(msgType, ext1, ext2);\n    }\n}\n\ntemplate <typename TCam, typename TCamTraits>\nint CameraBase<TCam, TCamTraits>::getNumberOfCameras() {\n    const sp<ICameraService> cs = getCameraService();\n\n    if (!cs.get()) {\n        // as required by the public Java APIs\n        return 0;\n    }\n    return cs->getNumberOfCameras();\n}\n\n// this can be in BaseCamera but it should be an instance method\ntemplate <typename TCam, typename TCamTraits>\nstatus_t CameraBase<TCam, TCamTraits>::getCameraInfo(int cameraId,\n                               struct CameraInfo* cameraInfo) {\n    const sp<ICameraService>& cs = getCameraService();\n    if (cs == 0) return UNKNOWN_ERROR;\n    return cs->getCameraInfo(cameraId, cameraInfo);\n}\n\ntemplate <typename TCam, typename TCamTraits>\nstatus_t CameraBase<TCam, TCamTraits>::addServiceListener(\n                            const sp<ICameraServiceListener>& listener) {\n    const sp<ICameraService>& cs = getCameraService();\n    if (cs == 0) return UNKNOWN_ERROR;\n    return cs->addListener(listener);\n}\n\ntemplate <typename TCam, typename TCamTraits>\nstatus_t CameraBase<TCam, TCamTraits>::removeServiceListener(\n                            const sp<ICameraServiceListener>& listener) {\n    const sp<ICameraService>& cs = getCameraService();\n    if (cs == 0) return UNKNOWN_ERROR;\n    return cs->removeListener(listener);\n}\n\ntemplate class CameraBase<Camera>;\n\n} // namespace android\n"
  },
  {
    "path": "libshims/CameraMetadata.cpp",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// #define LOG_NDEBUG 0\n\n#define LOG_TAG \"Camera2-Metadata\"\n#include <utils/Log.h>\n#include <utils/Errors.h>\n\n#include <camera/CameraMetadata.h>\n#include <binder/Parcel.h>\n\nnamespace android {\n\n#define ALIGN_TO(val, alignment) \\\n    (((uintptr_t)(val) + ((alignment) - 1)) & ~((alignment) - 1))\n\ntypedef Parcel::WritableBlob WritableBlob;\ntypedef Parcel::ReadableBlob ReadableBlob;\n\nCameraMetadata::CameraMetadata() :\n        mBuffer(NULL), mLocked(false) {\n}\n\nCameraMetadata::CameraMetadata(size_t entryCapacity, size_t dataCapacity) :\n        mLocked(false)\n{\n    mBuffer = allocate_camera_metadata(entryCapacity, dataCapacity);\n}\n\nCameraMetadata::CameraMetadata(const CameraMetadata &other) :\n        mLocked(false) {\n    mBuffer = clone_camera_metadata(other.mBuffer);\n}\n\nCameraMetadata::CameraMetadata(camera_metadata_t *buffer) :\n        mBuffer(NULL), mLocked(false) {\n    acquire(buffer);\n}\n\nCameraMetadata &CameraMetadata::operator=(const CameraMetadata &other) {\n    return operator=(other.mBuffer);\n}\n\nCameraMetadata &CameraMetadata::operator=(const camera_metadata_t *buffer) {\n    if (mLocked) {\n        ALOGE(\"%s: Assignment to a locked CameraMetadata!\", __FUNCTION__);\n        return *this;\n    }\n\n    if (CC_LIKELY(buffer != mBuffer)) {\n        camera_metadata_t *newBuffer = clone_camera_metadata(buffer);\n        clear();\n        mBuffer = newBuffer;\n    }\n    return *this;\n}\n\nCameraMetadata::~CameraMetadata() {\n    mLocked = false;\n    clear();\n}\n\nconst camera_metadata_t* CameraMetadata::getAndLock() const {\n    mLocked = true;\n    return mBuffer;\n}\n\nstatus_t CameraMetadata::unlock(const camera_metadata_t *buffer) {\n    if (!mLocked) {\n        ALOGE(\"%s: Can't unlock a non-locked CameraMetadata!\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    if (buffer != mBuffer) {\n        ALOGE(\"%s: Can't unlock CameraMetadata with wrong pointer!\",\n                __FUNCTION__);\n        return BAD_VALUE;\n    }\n    mLocked = false;\n    return OK;\n}\n\ncamera_metadata_t* CameraMetadata::release() {\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return NULL;\n    }\n    camera_metadata_t *released = mBuffer;\n    mBuffer = NULL;\n    return released;\n}\n\nvoid CameraMetadata::clear() {\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return;\n    }\n    if (mBuffer) {\n        free_camera_metadata(mBuffer);\n        mBuffer = NULL;\n    }\n}\n\nvoid CameraMetadata::acquire(camera_metadata_t *buffer) {\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return;\n    }\n    clear();\n    mBuffer = buffer;\n\n    ALOGE_IF(validate_camera_metadata_structure(mBuffer, /*size*/NULL) != OK,\n             \"%s: Failed to validate metadata structure %p\",\n             __FUNCTION__, buffer);\n}\n\nvoid CameraMetadata::acquire(CameraMetadata &other) {\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return;\n    }\n    acquire(other.release());\n}\n\nstatus_t CameraMetadata::append(const CameraMetadata &other) {\n    return append(other.mBuffer);\n}\n\nstatus_t CameraMetadata::append(const camera_metadata_t* other) {\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    size_t extraEntries = get_camera_metadata_entry_count(other);\n    size_t extraData = get_camera_metadata_data_count(other);\n    resizeIfNeeded(extraEntries, extraData);\n\n    return append_camera_metadata(mBuffer, other);\n}\n\nsize_t CameraMetadata::entryCount() const {\n    return (mBuffer == NULL) ? 0 :\n            get_camera_metadata_entry_count(mBuffer);\n}\n\nbool CameraMetadata::isEmpty() const {\n    return entryCount() == 0;\n}\n\nstatus_t CameraMetadata::sort() {\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    return sort_camera_metadata(mBuffer);\n}\n\nstatus_t CameraMetadata::checkType(uint32_t tag, uint8_t expectedType) {\n    int tagType = get_camera_metadata_tag_type(tag);\n    if ( CC_UNLIKELY(tagType == -1)) {\n        ALOGE(\"Update metadata entry: Unknown tag %d\", tag);\n        return INVALID_OPERATION;\n    }\n    if ( CC_UNLIKELY(tagType != expectedType) ) {\n        ALOGE(\"Mismatched tag type when updating entry %s (%d) of type %s; \"\n                \"got type %s data instead \",\n                get_camera_metadata_tag_name(tag), tag,\n                camera_metadata_type_names[tagType],\n                camera_metadata_type_names[expectedType]);\n        return INVALID_OPERATION;\n    }\n    return OK;\n}\n\nstatus_t CameraMetadata::update(uint32_t tag,\n        const int32_t *data, size_t data_count) {\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    if ( (res = checkType(tag, TYPE_INT32)) != OK) {\n        return res;\n    }\n    return updateImpl(tag, (const void*)data, data_count);\n}\n\nstatus_t CameraMetadata::update(uint32_t tag,\n        const uint8_t *data, size_t data_count) {\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    if ( (res = checkType(tag, TYPE_BYTE)) != OK) {\n        return res;\n    }\n    return updateImpl(tag, (const void*)data, data_count);\n}\n\nstatus_t CameraMetadata::update(uint32_t tag,\n        const float *data, size_t data_count) {\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    if ( (res = checkType(tag, TYPE_FLOAT)) != OK) {\n        return res;\n    }\n    return updateImpl(tag, (const void*)data, data_count);\n}\n\nstatus_t CameraMetadata::update(uint32_t tag,\n        const int64_t *data, size_t data_count) {\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    if ( (res = checkType(tag, TYPE_INT64)) != OK) {\n        return res;\n    }\n    return updateImpl(tag, (const void*)data, data_count);\n}\n\nstatus_t CameraMetadata::update(uint32_t tag,\n        const double *data, size_t data_count) {\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    if ( (res = checkType(tag, TYPE_DOUBLE)) != OK) {\n        return res;\n    }\n    return updateImpl(tag, (const void*)data, data_count);\n}\n\nstatus_t CameraMetadata::update(uint32_t tag,\n        const camera_metadata_rational_t *data, size_t data_count) {\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    if ( (res = checkType(tag, TYPE_RATIONAL)) != OK) {\n        return res;\n    }\n    return updateImpl(tag, (const void*)data, data_count);\n}\n\nstatus_t CameraMetadata::update(uint32_t tag,\n        const String8 &string) {\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    if ( (res = checkType(tag, TYPE_BYTE)) != OK) {\n        return res;\n    }\n    // string.size() doesn't count the null termination character.\n    return updateImpl(tag, (const void*)string.string(), string.size() + 1);\n}\n\nstatus_t CameraMetadata::updateImpl(uint32_t tag, const void *data,\n        size_t data_count) {\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    int type = get_camera_metadata_tag_type(tag);\n    if (type == -1) {\n        ALOGE(\"%s: Tag %d not found\", __FUNCTION__, tag);\n        return BAD_VALUE;\n    }\n    // Safety check - ensure that data isn't pointing to this metadata, since\n    // that would get invalidated if a resize is needed\n    size_t bufferSize = get_camera_metadata_size(mBuffer);\n    uintptr_t bufAddr = reinterpret_cast<uintptr_t>(mBuffer);\n    uintptr_t dataAddr = reinterpret_cast<uintptr_t>(data);\n    if (dataAddr > bufAddr && dataAddr < (bufAddr + bufferSize)) {\n        ALOGE(\"%s: Update attempted with data from the same metadata buffer!\",\n                __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n\n    size_t data_size = calculate_camera_metadata_entry_data_size(type,\n            data_count);\n\n    res = resizeIfNeeded(1, data_size);\n\n    if (res == OK) {\n        camera_metadata_entry_t entry;\n        res = find_camera_metadata_entry(mBuffer, tag, &entry);\n        if (res == NAME_NOT_FOUND) {\n            res = add_camera_metadata_entry(mBuffer,\n                    tag, data, data_count);\n        } else if (res == OK) {\n            res = update_camera_metadata_entry(mBuffer,\n                    entry.index, data, data_count, NULL);\n        }\n    }\n\n    if (res != OK) {\n        ALOGE(\"%s: Unable to update metadata entry %s.%s (%x): %s (%d)\",\n                __FUNCTION__, get_camera_metadata_section_name(tag),\n                get_camera_metadata_tag_name(tag), tag, strerror(-res), res);\n    }\n\n    IF_ALOGV() {\n        ALOGE_IF(validate_camera_metadata_structure(mBuffer, /*size*/NULL) !=\n                 OK,\n\n                 \"%s: Failed to validate metadata structure after update %p\",\n                 __FUNCTION__, mBuffer);\n    }\n\n    return res;\n}\n\nbool CameraMetadata::exists(uint32_t tag) const {\n    camera_metadata_ro_entry entry;\n    return find_camera_metadata_ro_entry(mBuffer, tag, &entry) == 0;\n}\n\ncamera_metadata_entry_t CameraMetadata::find(uint32_t tag) {\n    status_t res;\n    camera_metadata_entry entry;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        entry.count = 0;\n        return entry;\n    }\n    res = find_camera_metadata_entry(mBuffer, tag, &entry);\n    if (CC_UNLIKELY( res != OK )) {\n        entry.count = 0;\n        entry.data.u8 = NULL;\n    }\n    return entry;\n}\n\ncamera_metadata_ro_entry_t CameraMetadata::find(uint32_t tag) const {\n    status_t res;\n    camera_metadata_ro_entry entry;\n    res = find_camera_metadata_ro_entry(mBuffer, tag, &entry);\n    if (CC_UNLIKELY( res != OK )) {\n        entry.count = 0;\n        entry.data.u8 = NULL;\n    }\n    return entry;\n}\n\nstatus_t CameraMetadata::erase(uint32_t tag) {\n    camera_metadata_entry_t entry;\n    status_t res;\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n    res = find_camera_metadata_entry(mBuffer, tag, &entry);\n    if (res == NAME_NOT_FOUND) {\n        return OK;\n    } else if (res != OK) {\n        ALOGE(\"%s: Error looking for entry %s.%s (%x): %s %d\",\n                __FUNCTION__,\n                get_camera_metadata_section_name(tag),\n                get_camera_metadata_tag_name(tag), tag, strerror(-res), res);\n        return res;\n    }\n    res = delete_camera_metadata_entry(mBuffer, entry.index);\n    if (res != OK) {\n        ALOGE(\"%s: Error deleting entry %s.%s (%x): %s %d\",\n                __FUNCTION__,\n                get_camera_metadata_section_name(tag),\n                get_camera_metadata_tag_name(tag), tag, strerror(-res), res);\n    }\n    return res;\n}\n\nvoid CameraMetadata::dump(int fd, int verbosity, int indentation) const {\n    dump_indented_camera_metadata(mBuffer, fd, verbosity, indentation);\n}\n\nstatus_t CameraMetadata::resizeIfNeeded(size_t extraEntries, size_t extraData) {\n    if (mBuffer == NULL) {\n        mBuffer = allocate_camera_metadata(extraEntries * 2, extraData * 2);\n        if (mBuffer == NULL) {\n            ALOGE(\"%s: Can't allocate larger metadata buffer\", __FUNCTION__);\n            return NO_MEMORY;\n        }\n    } else {\n        size_t currentEntryCount = get_camera_metadata_entry_count(mBuffer);\n        size_t currentEntryCap = get_camera_metadata_entry_capacity(mBuffer);\n        size_t newEntryCount = currentEntryCount +\n                extraEntries;\n        newEntryCount = (newEntryCount > currentEntryCap) ?\n                newEntryCount * 2 : currentEntryCap;\n\n        size_t currentDataCount = get_camera_metadata_data_count(mBuffer);\n        size_t currentDataCap = get_camera_metadata_data_capacity(mBuffer);\n        size_t newDataCount = currentDataCount +\n                extraData;\n        newDataCount = (newDataCount > currentDataCap) ?\n                newDataCount * 2 : currentDataCap;\n\n        if (newEntryCount > currentEntryCap ||\n                newDataCount > currentDataCap) {\n            camera_metadata_t *oldBuffer = mBuffer;\n            mBuffer = allocate_camera_metadata(newEntryCount,\n                    newDataCount);\n            if (mBuffer == NULL) {\n                ALOGE(\"%s: Can't allocate larger metadata buffer\", __FUNCTION__);\n                return NO_MEMORY;\n            }\n            append_camera_metadata(mBuffer, oldBuffer);\n            free_camera_metadata(oldBuffer);\n        }\n    }\n    return OK;\n}\n\nstatus_t CameraMetadata::readFromParcel(const Parcel& data,\n                                        camera_metadata_t** out) {\n\n    status_t err = OK;\n\n    camera_metadata_t* metadata = NULL;\n\n    if (out) {\n        *out = NULL;\n    }\n\n    // See CameraMetadata::writeToParcel for parcel data layout diagram and explanation.\n    // arg0 = blobSize (int32)\n    int32_t blobSizeTmp = -1;\n    if ((err = data.readInt32(&blobSizeTmp)) != OK) {\n        ALOGE(\"%s: Failed to read metadata size (error %d %s)\",\n              __FUNCTION__, err, strerror(-err));\n        return err;\n    }\n    const size_t blobSize = static_cast<size_t>(blobSizeTmp);\n    const size_t alignment = get_camera_metadata_alignment();\n\n    // Special case: zero blob size means zero sized (NULL) metadata.\n    if (blobSize == 0) {\n        ALOGV(\"%s: Read 0-sized metadata\", __FUNCTION__);\n        return OK;\n    }\n\n    if (blobSize <= alignment) {\n        ALOGE(\"%s: metadata blob is malformed, blobSize(%zu) should be larger than alignment(%zu)\",\n                __FUNCTION__, blobSize, alignment);\n        return BAD_VALUE;\n    }\n\n    const size_t metadataSize = blobSize - alignment;\n\n    // NOTE: this doesn't make sense to me. shouldn't the blob\n    // know how big it is? why do we have to specify the size\n    // to Parcel::readBlob ?\n    ReadableBlob blob;\n    // arg1 = metadata (blob)\n    do {\n        if ((err = data.readBlob(blobSize, &blob)) != OK) {\n            ALOGE(\"%s: Failed to read metadata blob (sized %zu). Possible \"\n                  \" serialization bug. Error %d %s\",\n                  __FUNCTION__, blobSize, err, strerror(-err));\n            break;\n        }\n\n        // arg2 = offset (blob)\n        // Must be after blob since we don't know offset until after writeBlob.\n        int32_t offsetTmp;\n        if ((err = data.readInt32(&offsetTmp)) != OK) {\n            ALOGE(\"%s: Failed to read metadata offsetTmp (error %d %s)\",\n                  __FUNCTION__, err, strerror(-err));\n            break;\n        }\n        const size_t offset = static_cast<size_t>(offsetTmp);\n        if (offset >= alignment) {\n            ALOGE(\"%s: metadata offset(%zu) should be less than alignment(%zu)\",\n                    __FUNCTION__, blobSize, alignment);\n            err = BAD_VALUE;\n            break;\n        }\n\n        const uintptr_t metadataStart = reinterpret_cast<uintptr_t>(blob.data()) + offset;\n        const camera_metadata_t* tmp =\n                       reinterpret_cast<const camera_metadata_t*>(metadataStart);\n        ALOGV(\"%s: alignment is: %zu, metadata start: %p, offset: %zu\",\n                __FUNCTION__, alignment, tmp, offset);\n        metadata = allocate_copy_camera_metadata_checked(tmp, metadataSize);\n        if (metadata == NULL) {\n            // We consider that allocation only fails if the validation\n            // also failed, therefore the readFromParcel was a failure.\n            ALOGE(\"%s: metadata allocation and copy failed\", __FUNCTION__);\n            err = BAD_VALUE;\n        }\n    } while(0);\n    blob.release();\n\n    if (out) {\n        ALOGV(\"%s: Set out metadata to %p\", __FUNCTION__, metadata);\n        *out = metadata;\n    } else if (metadata != NULL) {\n        ALOGV(\"%s: Freed camera metadata at %p\", __FUNCTION__, metadata);\n        free_camera_metadata(metadata);\n    }\n\n    return err;\n}\n\nstatus_t CameraMetadata::writeToParcel(Parcel& data,\n                                       const camera_metadata_t* metadata) {\n    status_t res = OK;\n\n    /**\n     * Below is the camera metadata parcel layout:\n     *\n     * |--------------------------------------------|\n     * |             arg0: blobSize                 |\n     * |              (length = 4)                  |\n     * |--------------------------------------------|<--Skip the rest if blobSize == 0.\n     * |                                            |\n     * |                                            |\n     * |              arg1: blob                    |\n     * | (length = variable, see arg1 layout below) |\n     * |                                            |\n     * |                                            |\n     * |--------------------------------------------|\n     * |              arg2: offset                  |\n     * |              (length = 4)                  |\n     * |--------------------------------------------|\n     */\n\n    // arg0 = blobSize (int32)\n    if (metadata == NULL) {\n        // Write zero blobSize for null metadata.\n        return data.writeInt32(0);\n    }\n\n    /**\n     * Always make the blob size sufficiently larger, as we need put alignment\n     * padding and metadata into the blob. Since we don't know the alignment\n     * offset before writeBlob. Then write the metadata to aligned offset.\n     */\n    const size_t metadataSize = get_camera_metadata_compact_size(metadata);\n    const size_t alignment = get_camera_metadata_alignment();\n    const size_t blobSize = metadataSize + alignment;\n    res = data.writeInt32(static_cast<int32_t>(blobSize));\n    if (res != OK) {\n        return res;\n    }\n\n    size_t offset = 0;\n    /**\n     * arg1 = metadata (blob).\n     *\n     * The blob size is the sum of front padding size, metadata size and back padding\n     * size, which is equal to metadataSize + alignment.\n     *\n     * The blob layout is:\n     * |------------------------------------|<----Start address of the blob (unaligned).\n     * |           front padding            |\n     * |          (size = offset)           |\n     * |------------------------------------|<----Aligned start address of metadata.\n     * |                                    |\n     * |                                    |\n     * |            metadata                |\n     * |       (size = metadataSize)        |\n     * |                                    |\n     * |                                    |\n     * |------------------------------------|\n     * |           back padding             |\n     * |     (size = alignment - offset)    |\n     * |------------------------------------|<----End address of blob.\n     *                                            (Blob start address + blob size).\n     */\n    WritableBlob blob;\n    do {\n        res = data.writeBlob(blobSize, false, &blob);\n        if (res != OK) {\n            break;\n        }\n        const uintptr_t metadataStart = ALIGN_TO(blob.data(), alignment);\n        offset = metadataStart - reinterpret_cast<uintptr_t>(blob.data());\n        ALOGV(\"%s: alignment is: %zu, metadata start: %p, offset: %zu\",\n                __FUNCTION__, alignment,\n                reinterpret_cast<const void *>(metadataStart), offset);\n        copy_camera_metadata(reinterpret_cast<void*>(metadataStart), metadataSize, metadata);\n\n        // Not too big of a problem since receiving side does hard validation\n        // Don't check the size since the compact size could be larger\n        if (validate_camera_metadata_structure(metadata, /*size*/NULL) != OK) {\n            ALOGW(\"%s: Failed to validate metadata %p before writing blob\",\n                   __FUNCTION__, metadata);\n        }\n\n    } while(false);\n    blob.release();\n\n    // arg2 = offset (int32)\n    res = data.writeInt32(static_cast<int32_t>(offset));\n\n    return res;\n}\n\nstatus_t CameraMetadata::readFromParcel(Parcel *parcel) {\n\n    ALOGV(\"%s: parcel = %p\", __FUNCTION__, parcel);\n\n    status_t res = OK;\n\n    if (parcel == NULL) {\n        ALOGE(\"%s: parcel is null\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n\n    camera_metadata *buffer = NULL;\n    // TODO: reading should return a status code, in case validation fails\n    res = CameraMetadata::readFromParcel(*parcel, &buffer);\n\n    if (res != NO_ERROR) {\n        ALOGE(\"%s: Failed to read from parcel. Metadata is unchanged.\",\n              __FUNCTION__);\n        return res;\n    }\n\n    clear();\n    mBuffer = buffer;\n\n    return OK;\n}\n\nstatus_t CameraMetadata::writeToParcel(Parcel *parcel) const {\n\n    ALOGV(\"%s: parcel = %p\", __FUNCTION__, parcel);\n\n    if (parcel == NULL) {\n        ALOGE(\"%s: parcel is null\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    return CameraMetadata::writeToParcel(*parcel, mBuffer);\n}\n\nvoid CameraMetadata::swap(CameraMetadata& other) {\n    if (mLocked) {\n        ALOGE(\"%s: CameraMetadata is locked\", __FUNCTION__);\n        return;\n    } else if (other.mLocked) {\n        ALOGE(\"%s: Other CameraMetadata is locked\", __FUNCTION__);\n        return;\n    }\n\n    camera_metadata* thisBuf = mBuffer;\n    camera_metadata* otherBuf = other.mBuffer;\n\n    other.mBuffer = thisBuf;\n    mBuffer = otherBuf;\n}\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/CameraParameters.cpp",
    "content": "/*\n**\n** Copyright 2008, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n#define LOG_TAG \"CameraParams\"\n#include <utils/Log.h>\n\n#include <string.h>\n#include <stdlib.h>\n#include <camera/CameraParameters.h>\n#include <camera/CameraParametersExtra.h>\n#include <system/graphics.h>\n\nnamespace android {\n// Parameter keys to communicate between camera application and driver.\nconst char CameraParameters::KEY_PREVIEW_SIZE[] = \"preview-size\";\nconst char CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES[] = \"preview-size-values\";\nconst char CameraParameters::KEY_PREVIEW_FORMAT[] = \"preview-format\";\nconst char CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS[] = \"preview-format-values\";\nconst char CameraParameters::KEY_PREVIEW_FRAME_RATE[] = \"preview-frame-rate\";\nconst char CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES[] = \"preview-frame-rate-values\";\nconst char CameraParameters::KEY_PREVIEW_FPS_RANGE[] = \"preview-fps-range\";\nconst char CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE[] = \"preview-fps-range-values\";\nconst char CameraParameters::KEY_PICTURE_SIZE[] = \"picture-size\";\nconst char CameraParameters::KEY_SUPPORTED_PICTURE_SIZES[] = \"picture-size-values\";\nconst char CameraParameters::KEY_PICTURE_FORMAT[] = \"picture-format\";\nconst char CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS[] = \"picture-format-values\";\nconst char CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH[] = \"jpeg-thumbnail-width\";\nconst char CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT[] = \"jpeg-thumbnail-height\";\nconst char CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[] = \"jpeg-thumbnail-size-values\";\nconst char CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY[] = \"jpeg-thumbnail-quality\";\nconst char CameraParameters::KEY_JPEG_QUALITY[] = \"jpeg-quality\";\nconst char CameraParameters::KEY_ROTATION[] = \"rotation\";\nconst char CameraParameters::KEY_GPS_LATITUDE[] = \"gps-latitude\";\nconst char CameraParameters::KEY_GPS_LONGITUDE[] = \"gps-longitude\";\nconst char CameraParameters::KEY_GPS_ALTITUDE[] = \"gps-altitude\";\nconst char CameraParameters::KEY_GPS_TIMESTAMP[] = \"gps-timestamp\";\nconst char CameraParameters::KEY_GPS_PROCESSING_METHOD[] = \"gps-processing-method\";\nconst char CameraParameters::KEY_WHITE_BALANCE[] = \"whitebalance\";\nconst char CameraParameters::KEY_SUPPORTED_WHITE_BALANCE[] = \"whitebalance-values\";\nconst char CameraParameters::KEY_EFFECT[] = \"effect\";\nconst char CameraParameters::KEY_SUPPORTED_EFFECTS[] = \"effect-values\";\nconst char CameraParameters::KEY_ANTIBANDING[] = \"antibanding\";\nconst char CameraParameters::KEY_SUPPORTED_ANTIBANDING[] = \"antibanding-values\";\nconst char CameraParameters::KEY_SCENE_MODE[] = \"scene-mode\";\nconst char CameraParameters::KEY_SUPPORTED_SCENE_MODES[] = \"scene-mode-values\";\nconst char CameraParameters::KEY_FLASH_MODE[] = \"flash-mode\";\nconst char CameraParameters::KEY_SUPPORTED_FLASH_MODES[] = \"flash-mode-values\";\nconst char CameraParameters::KEY_FOCUS_MODE[] = \"focus-mode\";\nconst char CameraParameters::KEY_SUPPORTED_FOCUS_MODES[] = \"focus-mode-values\";\nconst char CameraParameters::KEY_MAX_NUM_FOCUS_AREAS[] = \"max-num-focus-areas\";\nconst char CameraParameters::KEY_FOCUS_AREAS[] = \"focus-areas\";\nconst char CameraParameters::KEY_FOCAL_LENGTH[] = \"focal-length\";\nconst char CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE[] = \"horizontal-view-angle\";\nconst char CameraParameters::KEY_VERTICAL_VIEW_ANGLE[] = \"vertical-view-angle\";\nconst char CameraParameters::KEY_EXPOSURE_COMPENSATION[] = \"exposure-compensation\";\nconst char CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION[] = \"max-exposure-compensation\";\nconst char CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION[] = \"min-exposure-compensation\";\nconst char CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP[] = \"exposure-compensation-step\";\nconst char CameraParameters::KEY_AUTO_EXPOSURE_LOCK[] = \"auto-exposure-lock\";\nconst char CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED[] = \"auto-exposure-lock-supported\";\nconst char CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK[] = \"auto-whitebalance-lock\";\nconst char CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED[] = \"auto-whitebalance-lock-supported\";\nconst char CameraParameters::KEY_MAX_NUM_METERING_AREAS[] = \"max-num-metering-areas\";\nconst char CameraParameters::KEY_METERING_AREAS[] = \"metering-areas\";\nconst char CameraParameters::KEY_ZOOM[] = \"zoom\";\nconst char CameraParameters::KEY_MAX_ZOOM[] = \"max-zoom\";\nconst char CameraParameters::KEY_ZOOM_RATIOS[] = \"zoom-ratios\";\nconst char CameraParameters::KEY_ZOOM_SUPPORTED[] = \"zoom-supported\";\nconst char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = \"smooth-zoom-supported\";\nconst char CameraParameters::KEY_FOCUS_DISTANCES[] = \"focus-distances\";\nconst char CameraParameters::KEY_VIDEO_FRAME_FORMAT[] = \"video-frame-format\";\nconst char CameraParameters::KEY_VIDEO_SIZE[] = \"video-size\";\nconst char CameraParameters::KEY_SUPPORTED_VIDEO_SIZES[] = \"video-size-values\";\nconst char CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = \"preferred-preview-size-for-video\";\nconst char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW[] = \"max-num-detected-faces-hw\";\nconst char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_SW[] = \"max-num-detected-faces-sw\";\nconst char CameraParameters::KEY_RECORDING_HINT[] = \"recording-hint\";\nconst char CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED[] = \"video-snapshot-supported\";\nconst char CameraParameters::KEY_VIDEO_STABILIZATION[] = \"video-stabilization\";\nconst char CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED[] = \"video-stabilization-supported\";\nconst char CameraParameters::KEY_LIGHTFX[] = \"light-fx\";\n\nconst char CameraParameters::TRUE[] = \"true\";\nconst char CameraParameters::FALSE[] = \"false\";\nconst char CameraParameters::FOCUS_DISTANCE_INFINITY[] = \"Infinity\";\n\n// Values for white balance settings.\nconst char CameraParameters::WHITE_BALANCE_AUTO[] = \"auto\";\nconst char CameraParameters::WHITE_BALANCE_INCANDESCENT[] = \"incandescent\";\nconst char CameraParameters::WHITE_BALANCE_FLUORESCENT[] = \"fluorescent\";\nconst char CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT[] = \"warm-fluorescent\";\nconst char CameraParameters::WHITE_BALANCE_DAYLIGHT[] = \"daylight\";\nconst char CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT[] = \"cloudy-daylight\";\nconst char CameraParameters::WHITE_BALANCE_TWILIGHT[] = \"twilight\";\nconst char CameraParameters::WHITE_BALANCE_SHADE[] = \"shade\";\nconst char CameraParameters::WHITE_BALANCE_MANUAL_CCT[] = \"manual-cct\";\n\n// Values for effect settings.\nconst char CameraParameters::EFFECT_NONE[] = \"none\";\nconst char CameraParameters::EFFECT_MONO[] = \"mono\";\nconst char CameraParameters::EFFECT_NEGATIVE[] = \"negative\";\nconst char CameraParameters::EFFECT_SOLARIZE[] = \"solarize\";\nconst char CameraParameters::EFFECT_SEPIA[] = \"sepia\";\nconst char CameraParameters::EFFECT_POSTERIZE[] = \"posterize\";\nconst char CameraParameters::EFFECT_WHITEBOARD[] = \"whiteboard\";\nconst char CameraParameters::EFFECT_BLACKBOARD[] = \"blackboard\";\nconst char CameraParameters::EFFECT_AQUA[] = \"aqua\";\n\n// Values for antibanding settings.\nconst char CameraParameters::ANTIBANDING_AUTO[] = \"auto\";\nconst char CameraParameters::ANTIBANDING_50HZ[] = \"50hz\";\nconst char CameraParameters::ANTIBANDING_60HZ[] = \"60hz\";\nconst char CameraParameters::ANTIBANDING_OFF[] = \"off\";\n\n// Values for flash mode settings.\nconst char CameraParameters::FLASH_MODE_OFF[] = \"off\";\nconst char CameraParameters::FLASH_MODE_AUTO[] = \"auto\";\nconst char CameraParameters::FLASH_MODE_ON[] = \"on\";\nconst char CameraParameters::FLASH_MODE_RED_EYE[] = \"red-eye\";\nconst char CameraParameters::FLASH_MODE_TORCH[] = \"torch\";\n\n// Values for scene mode settings.\nconst char CameraParameters::SCENE_MODE_AUTO[] = \"auto\";\nconst char CameraParameters::SCENE_MODE_ACTION[] = \"action\";\nconst char CameraParameters::SCENE_MODE_PORTRAIT[] = \"portrait\";\nconst char CameraParameters::SCENE_MODE_LANDSCAPE[] = \"landscape\";\nconst char CameraParameters::SCENE_MODE_NIGHT[] = \"night\";\nconst char CameraParameters::SCENE_MODE_NIGHT_PORTRAIT[] = \"night-portrait\";\nconst char CameraParameters::SCENE_MODE_THEATRE[] = \"theatre\";\nconst char CameraParameters::SCENE_MODE_BEACH[] = \"beach\";\nconst char CameraParameters::SCENE_MODE_SNOW[] = \"snow\";\nconst char CameraParameters::SCENE_MODE_SUNSET[] = \"sunset\";\nconst char CameraParameters::SCENE_MODE_STEADYPHOTO[] = \"steadyphoto\";\nconst char CameraParameters::SCENE_MODE_FIREWORKS[] = \"fireworks\";\nconst char CameraParameters::SCENE_MODE_SPORTS[] = \"sports\";\nconst char CameraParameters::SCENE_MODE_PARTY[] = \"party\";\nconst char CameraParameters::SCENE_MODE_CANDLELIGHT[] = \"candlelight\";\nconst char CameraParameters::SCENE_MODE_BARCODE[] = \"barcode\";\nconst char CameraParameters::SCENE_MODE_HDR[] = \"hdr\";\n\nconst char CameraParameters::PIXEL_FORMAT_YUV422SP[] = \"yuv422sp\";\nconst char CameraParameters::PIXEL_FORMAT_YUV420SP[] = \"yuv420sp\";\nconst char CameraParameters::PIXEL_FORMAT_YUV422I[] = \"yuv422i-yuyv\";\nconst char CameraParameters::PIXEL_FORMAT_YUV420P[]  = \"yuv420p\";\nconst char CameraParameters::PIXEL_FORMAT_RGB565[] = \"rgb565\";\nconst char CameraParameters::PIXEL_FORMAT_RGBA8888[] = \"rgba8888\";\nconst char CameraParameters::PIXEL_FORMAT_JPEG[] = \"jpeg\";\nconst char CameraParameters::PIXEL_FORMAT_BAYER_RGGB[] = \"bayer-rggb\";\nconst char CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE[] = \"android-opaque\";\n\n// Values for focus mode settings.\nconst char CameraParameters::FOCUS_MODE_AUTO[] = \"auto\";\nconst char CameraParameters::FOCUS_MODE_INFINITY[] = \"infinity\";\nconst char CameraParameters::FOCUS_MODE_MACRO[] = \"macro\";\nconst char CameraParameters::FOCUS_MODE_FIXED[] = \"fixed\";\nconst char CameraParameters::FOCUS_MODE_EDOF[] = \"edof\";\nconst char CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO[] = \"continuous-video\";\nconst char CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE[] = \"continuous-picture\";\nconst char CameraParameters::FOCUS_MODE_MANUAL_POSITION[] = \"manual\";\n\n// Values for light fx settings\nconst char CameraParameters::LIGHTFX_LOWLIGHT[] = \"low-light\";\nconst char CameraParameters::LIGHTFX_HDR[] = \"high-dynamic-range\";\n\n#ifdef CAMERA_PARAMETERS_EXTRA_C\nCAMERA_PARAMETERS_EXTRA_C\n#endif\n\nCameraParameters::CameraParameters()\n                : mMap()\n{\n}\n\nCameraParameters::~CameraParameters()\n{\n}\n\nString8 CameraParameters::flatten() const\n{\n    String8 flattened(\"\");\n    size_t size = mMap.size();\n\n    for (size_t i = 0; i < size; i++) {\n        String8 k, v;\n        k = mMap.keyAt(i);\n        v = mMap.valueAt(i);\n\n        flattened += k;\n        flattened += \"=\";\n        flattened += v;\n        if (i != size-1)\n            flattened += \";\";\n    }\n\n    return flattened;\n}\n\nvoid CameraParameters::unflatten(const String8 &params)\n{\n    const char *a = params.string();\n    const char *b;\n\n    mMap.clear();\n\n    for (;;) {\n        // Find the bounds of the key name.\n        b = strchr(a, '=');\n        if (b == 0)\n            break;\n\n        // Create the key string.\n        String8 k(a, (size_t)(b-a));\n\n        // Find the value.\n        a = b+1;\n        b = strchr(a, ';');\n        if (b == 0) {\n            // If there's no semicolon, this is the last item.\n            String8 v(a);\n            mMap.add(k, v);\n            break;\n        }\n\n        String8 v(a, (size_t)(b-a));\n        mMap.add(k, v);\n        a = b+1;\n    }\n}\n\n\nvoid CameraParameters::set(const char *key, const char *value)\n{\n    if (key == NULL || value == NULL)\n        return;\n\n    // XXX i think i can do this with strspn()\n    if (strchr(key, '=') || strchr(key, ';')) {\n        //XXX ALOGE(\"Key \\\"%s\\\"contains invalid character (= or ;)\", key);\n        return;\n    }\n\n    if (strchr(value, '=') || strchr(value, ';')) {\n        //XXX ALOGE(\"Value \\\"%s\\\"contains invalid character (= or ;)\", value);\n        return;\n    }\n#ifdef QCOM_HARDWARE\n    // qcom cameras default to delivering an extra zero-exposure frame on HDR.\n    // The android SDK only wants one frame, so disable this unless the app\n    // explicitly asks for it\n    if (!get(\"hdr-need-1x\")) {\n        mMap.replaceValueFor(String8(\"hdr-need-1x\"), String8(\"false\"));\n    }\n#endif\n\n    mMap.replaceValueFor(String8(key), String8(value));\n}\n\nvoid CameraParameters::set(const char *key, int value)\n{\n    char str[16];\n    sprintf(str, \"%d\", value);\n    set(key, str);\n}\n\nvoid CameraParameters::setFloat(const char *key, float value)\n{\n    char str[16];  // 14 should be enough. We overestimate to be safe.\n    snprintf(str, sizeof(str), \"%g\", value);\n    set(key, str);\n}\n\nconst char *CameraParameters::get(const char *key) const\n{\n    String8 v = mMap.valueFor(String8(key));\n    if (v.length() == 0)\n        return 0;\n    return v.string();\n}\n\nint CameraParameters::getInt(const char *key) const\n{\n    const char *v = get(key);\n    if (v == 0)\n        return -1;\n    return strtol(v, 0, 0);\n}\n\nfloat CameraParameters::getFloat(const char *key) const\n{\n    const char *v = get(key);\n    if (v == 0) return -1;\n    return strtof(v, 0);\n}\n\nvoid CameraParameters::remove(const char *key)\n{\n    mMap.removeItem(String8(key));\n}\n\n// Parse string like \"640x480\" or \"10000,20000\"\nstatic int parse_pair(const char *str, int *first, int *second, char delim,\n                      char **endptr = NULL)\n{\n    // Find the first integer.\n    char *end;\n    int w = (int)strtol(str, &end, 10);\n    // If a delimeter does not immediately follow, give up.\n    if (*end != delim) {\n        ALOGE(\"Cannot find delimeter (%c) in str=%s\", delim, str);\n        return -1;\n    }\n\n    // Find the second integer, immediately after the delimeter.\n    int h = (int)strtol(end+1, &end, 10);\n\n    *first = w;\n    *second = h;\n\n    if (endptr) {\n        *endptr = end;\n    }\n\n    return 0;\n}\n\nstatic void parseSizesList(const char *sizesStr, Vector<Size> &sizes)\n{\n    if (sizesStr == 0) {\n        return;\n    }\n\n    char *sizeStartPtr = (char *)sizesStr;\n\n    while (true) {\n        int width, height;\n        int success = parse_pair(sizeStartPtr, &width, &height, 'x',\n                                 &sizeStartPtr);\n        if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\\0')) {\n            ALOGE(\"Picture sizes string \\\"%s\\\" contains invalid character.\", sizesStr);\n            return;\n        }\n        sizes.push(Size(width, height));\n\n        if (*sizeStartPtr == '\\0') {\n            return;\n        }\n        sizeStartPtr++;\n    }\n}\n\nvoid CameraParameters::setPreviewSize(int width, int height)\n{\n    char str[32];\n    sprintf(str, \"%dx%d\", width, height);\n    set(KEY_PREVIEW_SIZE, str);\n}\n\nvoid CameraParameters::getPreviewSize(int *width, int *height) const\n{\n    *width = *height = -1;\n    // Get the current string, if it doesn't exist, leave the -1x-1\n    const char *p = get(KEY_PREVIEW_SIZE);\n    if (p == 0)  return;\n    parse_pair(p, width, height, 'x');\n}\n\nvoid CameraParameters::getPreferredPreviewSizeForVideo(int *width, int *height) const\n{\n    *width = *height = -1;\n    const char *p = get(KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO);\n    if (p == 0)  return;\n    parse_pair(p, width, height, 'x');\n}\n\nvoid CameraParameters::getSupportedPreviewSizes(Vector<Size> &sizes) const\n{\n    const char *previewSizesStr = get(KEY_SUPPORTED_PREVIEW_SIZES);\n    parseSizesList(previewSizesStr, sizes);\n}\n\nvoid CameraParameters::setVideoSize(int width, int height)\n{\n    char str[32];\n    sprintf(str, \"%dx%d\", width, height);\n    set(KEY_VIDEO_SIZE, str);\n}\n\nvoid CameraParameters::getVideoSize(int *width, int *height) const\n{\n    *width = *height = -1;\n    const char *p = get(KEY_VIDEO_SIZE);\n    if (p == 0) return;\n    parse_pair(p, width, height, 'x');\n}\n\nvoid CameraParameters::getSupportedVideoSizes(Vector<Size> &sizes) const\n{\n    const char *videoSizesStr = get(KEY_SUPPORTED_VIDEO_SIZES);\n    parseSizesList(videoSizesStr, sizes);\n}\n\nvoid CameraParameters::setPreviewFrameRate(int fps)\n{\n    set(KEY_PREVIEW_FRAME_RATE, fps);\n}\n\nint CameraParameters::getPreviewFrameRate() const\n{\n    return getInt(KEY_PREVIEW_FRAME_RATE);\n}\n\nvoid CameraParameters::getPreviewFpsRange(int *min_fps, int *max_fps) const\n{\n    *min_fps = *max_fps = -1;\n    const char *p = get(KEY_PREVIEW_FPS_RANGE);\n    if (p == 0) return;\n    parse_pair(p, min_fps, max_fps, ',');\n}\n\nvoid CameraParameters::setPreviewFormat(const char *format)\n{\n    set(KEY_PREVIEW_FORMAT, format);\n}\n\nconst char *CameraParameters::getPreviewFormat() const\n{\n    return get(KEY_PREVIEW_FORMAT);\n}\n\nvoid CameraParameters::setPictureSize(int width, int height)\n{\n    char str[32];\n    sprintf(str, \"%dx%d\", width, height);\n    set(KEY_PICTURE_SIZE, str);\n}\n\nvoid CameraParameters::getPictureSize(int *width, int *height) const\n{\n    *width = *height = -1;\n    // Get the current string, if it doesn't exist, leave the -1x-1\n    const char *p = get(KEY_PICTURE_SIZE);\n    if (p == 0) return;\n    parse_pair(p, width, height, 'x');\n}\n\nvoid CameraParameters::getSupportedPictureSizes(Vector<Size> &sizes) const\n{\n    const char *pictureSizesStr = get(KEY_SUPPORTED_PICTURE_SIZES);\n    parseSizesList(pictureSizesStr, sizes);\n}\n\nvoid CameraParameters::setPictureFormat(const char *format)\n{\n    set(KEY_PICTURE_FORMAT, format);\n}\n\nconst char *CameraParameters::getPictureFormat() const\n{\n    return get(KEY_PICTURE_FORMAT);\n}\n\nvoid CameraParameters::dump() const\n{\n    ALOGD(\"dump: mMap.size = %zu\", mMap.size());\n    for (size_t i = 0; i < mMap.size(); i++) {\n        String8 k, v;\n        k = mMap.keyAt(i);\n        v = mMap.valueAt(i);\n        ALOGD(\"%s: %s\\n\", k.string(), v.string());\n    }\n}\n\nstatus_t CameraParameters::dump(int fd, const Vector<String16>& /*args*/) const\n{\n    const size_t SIZE = 256;\n    char buffer[SIZE];\n    String8 result;\n    snprintf(buffer, 255, \"CameraParameters::dump: mMap.size = %zu\\n\", mMap.size());\n    result.append(buffer);\n    for (size_t i = 0; i < mMap.size(); i++) {\n        String8 k, v;\n        k = mMap.keyAt(i);\n        v = mMap.valueAt(i);\n        snprintf(buffer, 255, \"\\t%s: %s\\n\", k.string(), v.string());\n        result.append(buffer);\n    }\n    write(fd, result.string(), result.size());\n    return NO_ERROR;\n}\n\nvoid CameraParameters::getSupportedPreviewFormats(Vector<int>& formats) const {\n    const char* supportedPreviewFormats =\n          get(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS);\n\n    if (supportedPreviewFormats == NULL) {\n        ALOGW(\"%s: No supported preview formats.\", __FUNCTION__);\n        return;\n    }\n\n    String8 fmtStr(supportedPreviewFormats);\n    char* prevFmts = fmtStr.lockBuffer(fmtStr.size());\n\n    char* savePtr;\n    char* fmt = strtok_r(prevFmts, \",\", &savePtr);\n    while (fmt) {\n        int actual = previewFormatToEnum(fmt);\n        if (actual != -1) {\n            formats.add(actual);\n        }\n        fmt = strtok_r(NULL, \",\", &savePtr);\n    }\n    fmtStr.unlockBuffer(fmtStr.size());\n}\n\n\nint CameraParameters::previewFormatToEnum(const char* format) {\n    return\n        !format ?\n            HAL_PIXEL_FORMAT_YCrCb_420_SP :\n        !strcmp(format, PIXEL_FORMAT_YUV422SP) ?\n            HAL_PIXEL_FORMAT_YCbCr_422_SP : // NV16\n        !strcmp(format, PIXEL_FORMAT_YUV420SP) ?\n            HAL_PIXEL_FORMAT_YCrCb_420_SP : // NV21\n        !strcmp(format, PIXEL_FORMAT_YUV422I) ?\n            HAL_PIXEL_FORMAT_YCbCr_422_I :  // YUY2\n        !strcmp(format, PIXEL_FORMAT_YUV420P) ?\n            HAL_PIXEL_FORMAT_YV12 :         // YV12\n        !strcmp(format, PIXEL_FORMAT_RGB565) ?\n            HAL_PIXEL_FORMAT_RGB_565 :      // RGB565\n        !strcmp(format, PIXEL_FORMAT_RGBA8888) ?\n            HAL_PIXEL_FORMAT_RGBA_8888 :    // RGB8888\n        !strcmp(format, PIXEL_FORMAT_BAYER_RGGB) ?\n            HAL_PIXEL_FORMAT_RAW16 :   // Raw sensor data\n        -1;\n}\n\nbool CameraParameters::isEmpty() const {\n    return mMap.isEmpty();\n}\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/CameraParameters2.cpp",
    "content": "/*\n**\n** Copyright 2008, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n#define LOG_TAG \"CameraParams2\"\n// #define LOG_NDEBUG 0\n#include <utils/Log.h>\n\n#include <string.h>\n#include <stdlib.h>\n#include <camera/CameraParameters2.h>\n\nnamespace android {\n\nCameraParameters2::CameraParameters2()\n                : mMap()\n{\n}\n\nCameraParameters2::~CameraParameters2()\n{\n}\n\nString8 CameraParameters2::flatten() const\n{\n    String8 flattened(\"\");\n    size_t size = mMap.size();\n\n    for (size_t i = 0; i < size; i++) {\n        String8 k, v;\n        k = mMap.keyAt(i);\n        v = mMap.valueAt(i);\n\n        flattened += k;\n        flattened += \"=\";\n        flattened += v;\n        if (i != size-1)\n            flattened += \";\";\n    }\n\n    ALOGV(\"%s: Flattened params = %s\", __FUNCTION__, flattened.string());\n\n    return flattened;\n}\n\nvoid CameraParameters2::unflatten(const String8 &params)\n{\n    const char *a = params.string();\n    const char *b;\n\n    mMap.clear();\n\n    for (;;) {\n        // Find the bounds of the key name.\n        b = strchr(a, '=');\n        if (b == 0)\n            break;\n\n        // Create the key string.\n        String8 k(a, (size_t)(b-a));\n\n        // Find the value.\n        a = b+1;\n        b = strchr(a, ';');\n        if (b == 0) {\n            // If there's no semicolon, this is the last item.\n            String8 v(a);\n            mMap.add(k, v);\n            break;\n        }\n\n        String8 v(a, (size_t)(b-a));\n        mMap.add(k, v);\n        a = b+1;\n    }\n}\n\n\nvoid CameraParameters2::set(const char *key, const char *value)\n{\n    // XXX i think i can do this with strspn()\n    if (strchr(key, '=') || strchr(key, ';')) {\n        //XXX ALOGE(\"Key \\\"%s\\\"contains invalid character (= or ;)\", key);\n        return;\n    }\n\n    if (strchr(value, '=') || strchr(value, ';')) {\n        //XXX ALOGE(\"Value \\\"%s\\\"contains invalid character (= or ;)\", value);\n        return;\n    }\n\n    // Replacing a value updates the key's order to be the new largest order\n    ssize_t res = mMap.replaceValueFor(String8(key), String8(value));\n    LOG_ALWAYS_FATAL_IF(res < 0, \"replaceValueFor(%s,%s) failed\", key, value);\n}\n\nvoid CameraParameters2::set(const char *key, int value)\n{\n    char str[16];\n    sprintf(str, \"%d\", value);\n    set(key, str);\n}\n\nvoid CameraParameters2::setFloat(const char *key, float value)\n{\n    char str[16];  // 14 should be enough. We overestimate to be safe.\n    snprintf(str, sizeof(str), \"%g\", value);\n    set(key, str);\n}\n\nconst char *CameraParameters2::get(const char *key) const\n{\n    ssize_t idx = mMap.indexOfKey(String8(key));\n    if (idx < 0) {\n        return NULL;\n    } else {\n        return mMap.valueAt(idx).string();\n    }\n}\n\nint CameraParameters2::getInt(const char *key) const\n{\n    const char *v = get(key);\n    if (v == 0)\n        return -1;\n    return strtol(v, 0, 0);\n}\n\nfloat CameraParameters2::getFloat(const char *key) const\n{\n    const char *v = get(key);\n    if (v == 0) return -1;\n    return strtof(v, 0);\n}\n\nstatus_t CameraParameters2::compareSetOrder(const char *key1, const char *key2,\n        int *order) const {\n    if (key1 == NULL) {\n        ALOGE(\"%s: key1 must not be NULL\", __FUNCTION__);\n        return BAD_VALUE;\n    } else if (key2 == NULL) {\n        ALOGE(\"%s: key2 must not be NULL\", __FUNCTION__);\n        return BAD_VALUE;\n    } else if (order == NULL) {\n        ALOGE(\"%s: order must not be NULL\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    ssize_t index1 = mMap.indexOfKey(String8(key1));\n    ssize_t index2 = mMap.indexOfKey(String8(key2));\n    if (index1 < 0) {\n        ALOGW(\"%s: Key1 (%s) was not set\", __FUNCTION__, key1);\n        return NAME_NOT_FOUND;\n    } else if (index2 < 0) {\n        ALOGW(\"%s: Key2 (%s) was not set\", __FUNCTION__, key2);\n        return NAME_NOT_FOUND;\n    }\n\n    *order = (index1 == index2) ? 0  :\n             (index1 < index2)  ? -1 :\n             1;\n\n    return OK;\n}\n\nvoid CameraParameters2::remove(const char *key)\n{\n    mMap.removeItem(String8(key));\n}\n\n// Parse string like \"640x480\" or \"10000,20000\"\nstatic int parse_pair(const char *str, int *first, int *second, char delim,\n                      char **endptr = NULL)\n{\n    // Find the first integer.\n    char *end;\n    int w = (int)strtol(str, &end, 10);\n    // If a delimeter does not immediately follow, give up.\n    if (*end != delim) {\n        ALOGE(\"Cannot find delimeter (%c) in str=%s\", delim, str);\n        return -1;\n    }\n\n    // Find the second integer, immediately after the delimeter.\n    int h = (int)strtol(end+1, &end, 10);\n\n    *first = w;\n    *second = h;\n\n    if (endptr) {\n        *endptr = end;\n    }\n\n    return 0;\n}\n\nstatic void parseSizesList(const char *sizesStr, Vector<Size> &sizes)\n{\n    if (sizesStr == 0) {\n        return;\n    }\n\n    char *sizeStartPtr = (char *)sizesStr;\n\n    while (true) {\n        int width, height;\n        int success = parse_pair(sizeStartPtr, &width, &height, 'x',\n                                 &sizeStartPtr);\n        if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\\0')) {\n            ALOGE(\"Picture sizes string \\\"%s\\\" contains invalid character.\", sizesStr);\n            return;\n        }\n        sizes.push(Size(width, height));\n\n        if (*sizeStartPtr == '\\0') {\n            return;\n        }\n        sizeStartPtr++;\n    }\n}\n\nvoid CameraParameters2::setPreviewSize(int width, int height)\n{\n    char str[32];\n    sprintf(str, \"%dx%d\", width, height);\n    set(CameraParameters::KEY_PREVIEW_SIZE, str);\n}\n\nvoid CameraParameters2::getPreviewSize(int *width, int *height) const\n{\n    *width = *height = -1;\n    // Get the current string, if it doesn't exist, leave the -1x-1\n    const char *p = get(CameraParameters::KEY_PREVIEW_SIZE);\n    if (p == 0)  return;\n    parse_pair(p, width, height, 'x');\n}\n\nvoid CameraParameters2::getPreferredPreviewSizeForVideo(int *width, int *height) const\n{\n    *width = *height = -1;\n    const char *p = get(CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO);\n    if (p == 0)  return;\n    parse_pair(p, width, height, 'x');\n}\n\nvoid CameraParameters2::getSupportedPreviewSizes(Vector<Size> &sizes) const\n{\n    const char *previewSizesStr = get(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES);\n    parseSizesList(previewSizesStr, sizes);\n}\n\nvoid CameraParameters2::setVideoSize(int width, int height)\n{\n    char str[32];\n    sprintf(str, \"%dx%d\", width, height);\n    set(CameraParameters::KEY_VIDEO_SIZE, str);\n}\n\nvoid CameraParameters2::getVideoSize(int *width, int *height) const\n{\n    *width = *height = -1;\n    const char *p = get(CameraParameters::KEY_VIDEO_SIZE);\n    if (p == 0) return;\n    parse_pair(p, width, height, 'x');\n}\n\nvoid CameraParameters2::getSupportedVideoSizes(Vector<Size> &sizes) const\n{\n    const char *videoSizesStr = get(CameraParameters::KEY_SUPPORTED_VIDEO_SIZES);\n    parseSizesList(videoSizesStr, sizes);\n}\n\nvoid CameraParameters2::setPreviewFrameRate(int fps)\n{\n    set(CameraParameters::KEY_PREVIEW_FRAME_RATE, fps);\n}\n\nint CameraParameters2::getPreviewFrameRate() const\n{\n    return getInt(CameraParameters::KEY_PREVIEW_FRAME_RATE);\n}\n\nvoid CameraParameters2::getPreviewFpsRange(int *min_fps, int *max_fps) const\n{\n    *min_fps = *max_fps = -1;\n    const char *p = get(CameraParameters::KEY_PREVIEW_FPS_RANGE);\n    if (p == 0) return;\n    parse_pair(p, min_fps, max_fps, ',');\n}\n\nvoid CameraParameters2::setPreviewFpsRange(int min_fps, int max_fps)\n{\n    String8 str = String8::format(\"%d,%d\", min_fps, max_fps);\n    set(CameraParameters::KEY_PREVIEW_FPS_RANGE, str.string());\n}\n\nvoid CameraParameters2::setPreviewFormat(const char *format)\n{\n    set(CameraParameters::KEY_PREVIEW_FORMAT, format);\n}\n\nconst char *CameraParameters2::getPreviewFormat() const\n{\n    return get(CameraParameters::KEY_PREVIEW_FORMAT);\n}\n\nvoid CameraParameters2::setPictureSize(int width, int height)\n{\n    char str[32];\n    sprintf(str, \"%dx%d\", width, height);\n    set(CameraParameters::KEY_PICTURE_SIZE, str);\n}\n\nvoid CameraParameters2::getPictureSize(int *width, int *height) const\n{\n    *width = *height = -1;\n    // Get the current string, if it doesn't exist, leave the -1x-1\n    const char *p = get(CameraParameters::KEY_PICTURE_SIZE);\n    if (p == 0) return;\n    parse_pair(p, width, height, 'x');\n}\n\nvoid CameraParameters2::getSupportedPictureSizes(Vector<Size> &sizes) const\n{\n    const char *pictureSizesStr = get(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES);\n    parseSizesList(pictureSizesStr, sizes);\n}\n\nvoid CameraParameters2::setPictureFormat(const char *format)\n{\n    set(CameraParameters::KEY_PICTURE_FORMAT, format);\n}\n\nconst char *CameraParameters2::getPictureFormat() const\n{\n    return get(CameraParameters::KEY_PICTURE_FORMAT);\n}\n\nvoid CameraParameters2::dump() const\n{\n    ALOGD(\"dump: mMap.size = %d\", mMap.size());\n    for (size_t i = 0; i < mMap.size(); i++) {\n        String8 k, v;\n        k = mMap.keyAt(i);\n        v = mMap.valueAt(i);\n        ALOGD(\"%s: %s\\n\", k.string(), v.string());\n    }\n}\n\nstatus_t CameraParameters2::dump(int fd, const Vector<String16>& args) const\n{\n    (void)args;\n    const size_t SIZE = 256;\n    char buffer[SIZE];\n    String8 result;\n    snprintf(buffer, 255, \"CameraParameters2::dump: mMap.size = %zu\\n\", mMap.size());\n    result.append(buffer);\n    for (size_t i = 0; i < mMap.size(); i++) {\n        String8 k, v;\n        k = mMap.keyAt(i);\n        v = mMap.valueAt(i);\n        snprintf(buffer, 255, \"\\t%s: %s\\n\", k.string(), v.string());\n        result.append(buffer);\n    }\n    write(fd, result.string(), result.size());\n    return NO_ERROR;\n}\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/CameraUtils.cpp",
    "content": "/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"CameraUtils\"\n//#define LOG_NDEBUG 0\n\n#include <camera/CameraUtils.h>\n\n#include <system/window.h>\n#include <system/graphics.h>\n\n#include <utils/Log.h>\n\nnamespace android {\n\nstatus_t CameraUtils::getRotationTransform(const CameraMetadata& staticInfo,\n                /*out*/int32_t* transform) {\n    ALOGV(\"%s\", __FUNCTION__);\n\n    if (transform == NULL) {\n        ALOGW(\"%s: null transform\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    *transform = 0;\n\n    camera_metadata_ro_entry_t entry = staticInfo.find(ANDROID_SENSOR_ORIENTATION);\n    if (entry.count == 0) {\n        ALOGE(\"%s: Can't find android.sensor.orientation in static metadata!\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n\n    camera_metadata_ro_entry_t entryFacing = staticInfo.find(ANDROID_LENS_FACING);\n    if (entry.count == 0) {\n        ALOGE(\"%s: Can't find android.lens.facing in static metadata!\", __FUNCTION__);\n        return INVALID_OPERATION;\n    }\n\n    int32_t& flags = *transform;\n\n    bool mirror = (entryFacing.data.u8[0] == ANDROID_LENS_FACING_FRONT);\n    int orientation = entry.data.i32[0];\n    if (!mirror) {\n        switch (orientation) {\n            case 0:\n                flags = 0;\n                break;\n            case 90:\n                flags = NATIVE_WINDOW_TRANSFORM_ROT_90;\n                break;\n            case 180:\n                flags = NATIVE_WINDOW_TRANSFORM_ROT_180;\n                break;\n            case 270:\n                flags = NATIVE_WINDOW_TRANSFORM_ROT_270;\n                break;\n            default:\n                ALOGE(\"%s: Invalid HAL android.sensor.orientation value: %d\",\n                      __FUNCTION__, orientation);\n                return INVALID_OPERATION;\n        }\n    } else {\n        // Front camera needs to be horizontally flipped for mirror-like behavior.\n        // Note: Flips are applied before rotates; using XOR here as some of these flags are\n        // composed in terms of other flip/rotation flags, and are not bitwise-ORable.\n        switch (orientation) {\n            case 0:\n                flags = NATIVE_WINDOW_TRANSFORM_FLIP_H;\n                break;\n            case 90:\n                flags = NATIVE_WINDOW_TRANSFORM_FLIP_H ^\n                        NATIVE_WINDOW_TRANSFORM_ROT_270;\n                break;\n            case 180:\n                flags = NATIVE_WINDOW_TRANSFORM_FLIP_H ^\n                        NATIVE_WINDOW_TRANSFORM_ROT_180;\n                break;\n            case 270:\n                flags = NATIVE_WINDOW_TRANSFORM_FLIP_H ^\n                        NATIVE_WINDOW_TRANSFORM_ROT_90;\n\n                break;\n            default:\n                ALOGE(\"%s: Invalid HAL android.sensor.orientation value: %d\",\n                      __FUNCTION__, orientation);\n                return INVALID_OPERATION;\n        }\n\n    }\n\n    /**\n     * This magic flag makes surfaceflinger un-rotate the buffers\n     * to counter the extra global device UI rotation whenever the user\n     * physically rotates the device.\n     *\n     * By doing this, the camera buffer always ends up aligned\n     * with the physical camera for a \"see through\" effect.\n     *\n     * In essence, the buffer only gets rotated during preview use-cases.\n     * The user is still responsible to re-create streams of the proper\n     * aspect ratio, or the preview will end up looking non-uniformly\n     * stretched.\n     */\n    flags |= NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;\n\n    ALOGV(\"%s: final transform = 0x%x\", __FUNCTION__, flags);\n\n    return OK;\n}\n\n\n} /* namespace android */\n"
  },
  {
    "path": "libshims/CaptureResult.cpp",
    "content": "/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"Camera-CaptureResult\"\n#include <utils/Log.h>\n\n#include <camera/CaptureResult.h>\n#include <binder/Parcel.h>\n\nnamespace android {\n\nbool CaptureResultExtras::isValid() {\n    return requestId >= 0;\n}\n\nstatus_t CaptureResultExtras::readFromParcel(Parcel *parcel) {\n    if (parcel == NULL) {\n        ALOGE(\"%s: Null parcel\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    parcel->readInt32(&requestId);\n    parcel->readInt32(&burstId);\n    parcel->readInt32(&afTriggerId);\n    parcel->readInt32(&precaptureTriggerId);\n    parcel->readInt64(&frameNumber);\n    parcel->readInt32(&partialResultCount);\n\n    return OK;\n}\n\nstatus_t CaptureResultExtras::writeToParcel(Parcel *parcel) const {\n    if (parcel == NULL) {\n        ALOGE(\"%s: Null parcel\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    parcel->writeInt32(requestId);\n    parcel->writeInt32(burstId);\n    parcel->writeInt32(afTriggerId);\n    parcel->writeInt32(precaptureTriggerId);\n    parcel->writeInt64(frameNumber);\n    parcel->writeInt32(partialResultCount);\n\n    return OK;\n}\n\nCaptureResult::CaptureResult() :\n        mMetadata(), mResultExtras() {\n}\n\nCaptureResult::CaptureResult(const CaptureResult &otherResult) {\n    mResultExtras = otherResult.mResultExtras;\n    mMetadata = otherResult.mMetadata;\n}\n\nstatus_t CaptureResult::readFromParcel(Parcel *parcel) {\n\n    ALOGV(\"%s: parcel = %p\", __FUNCTION__, parcel);\n\n    if (parcel == NULL) {\n        ALOGE(\"%s: parcel is null\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    mMetadata.clear();\n\n    status_t res = OK;\n    res = mMetadata.readFromParcel(parcel);\n    if (res != OK) {\n        ALOGE(\"%s: Failed to read metadata from parcel.\",\n              __FUNCTION__);\n        return res;\n    }\n    ALOGV(\"%s: Read metadata from parcel\", __FUNCTION__);\n\n    res = mResultExtras.readFromParcel(parcel);\n    if (res != OK) {\n        ALOGE(\"%s: Failed to read result extras from parcel.\",\n                __FUNCTION__);\n        return res;\n    }\n    ALOGV(\"%s: Read result extras from parcel\", __FUNCTION__);\n\n    return OK;\n}\n\nstatus_t CaptureResult::writeToParcel(Parcel *parcel) const {\n\n    ALOGV(\"%s: parcel = %p\", __FUNCTION__, parcel);\n\n    if (parcel == NULL) {\n        ALOGE(\"%s: parcel is null\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    status_t res;\n\n    res = mMetadata.writeToParcel(parcel);\n    if (res != OK) {\n        ALOGE(\"%s: Failed to write metadata to parcel\", __FUNCTION__);\n        return res;\n    }\n    ALOGV(\"%s: Wrote metadata to parcel\", __FUNCTION__);\n\n    res = mResultExtras.writeToParcel(parcel);\n    if (res != OK) {\n        ALOGE(\"%s: Failed to write result extras to parcel\", __FUNCTION__);\n        return res;\n    }\n    ALOGV(\"%s: Wrote result extras to parcel\", __FUNCTION__);\n\n    return OK;\n}\n\n}\n"
  },
  {
    "path": "libshims/ICamera.cpp",
    "content": "/*\n**\n** Copyright 2008, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n//#define LOG_NDEBUG 0\n#define LOG_TAG \"ICamera\"\n#include <utils/Log.h>\n#include <stdint.h>\n#include <sys/types.h>\n#include <binder/Parcel.h>\n#include <camera/ICamera.h>\n#include <gui/IGraphicBufferProducer.h>\n#include <gui/Surface.h>\n\nnamespace android {\n\nenum {\n    DISCONNECT = IBinder::FIRST_CALL_TRANSACTION,\n    SET_PREVIEW_TARGET,\n    SET_PREVIEW_CALLBACK_FLAG,\n    SET_PREVIEW_CALLBACK_TARGET,\n    START_PREVIEW,\n    STOP_PREVIEW,\n    AUTO_FOCUS,\n    CANCEL_AUTO_FOCUS,\n    TAKE_PICTURE,\n    SET_PARAMETERS,\n    GET_PARAMETERS,\n    SEND_COMMAND,\n    CONNECT,\n    LOCK,\n    UNLOCK,\n    PREVIEW_ENABLED,\n    START_RECORDING,\n    STOP_RECORDING,\n    RECORDING_ENABLED,\n    RELEASE_RECORDING_FRAME,\n    STORE_META_DATA_IN_BUFFERS,\n};\n\nclass BpCamera: public BpInterface<ICamera>\n{\npublic:\n    BpCamera(const sp<IBinder>& impl)\n        : BpInterface<ICamera>(impl)\n    {\n    }\n\n    // disconnect from camera service\n    void disconnect()\n    {\n        ALOGV(\"disconnect\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(DISCONNECT, data, &reply);\n        reply.readExceptionCode();\n    }\n\n    // pass the buffered IGraphicBufferProducer to the camera service\n    status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)\n    {\n        ALOGV(\"setPreviewTarget\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        sp<IBinder> b(IInterface::asBinder(bufferProducer));\n        data.writeStrongBinder(b);\n        remote()->transact(SET_PREVIEW_TARGET, data, &reply);\n        return reply.readInt32();\n    }\n\n    // set the preview callback flag to affect how the received frames from\n    // preview are handled. See Camera.h for details.\n    void setPreviewCallbackFlag(int flag)\n    {\n        ALOGV(\"setPreviewCallbackFlag(%d)\", flag);\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        data.writeInt32(flag);\n        remote()->transact(SET_PREVIEW_CALLBACK_FLAG, data, &reply);\n    }\n\n    status_t setPreviewCallbackTarget(\n            const sp<IGraphicBufferProducer>& callbackProducer)\n    {\n        ALOGV(\"setPreviewCallbackTarget\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        sp<IBinder> b(IInterface::asBinder(callbackProducer));\n        data.writeStrongBinder(b);\n        remote()->transact(SET_PREVIEW_CALLBACK_TARGET, data, &reply);\n        return reply.readInt32();\n    }\n\n    // start preview mode, must call setPreviewTarget first\n    status_t startPreview()\n    {\n        ALOGV(\"startPreview\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(START_PREVIEW, data, &reply);\n        return reply.readInt32();\n    }\n\n    // start recording mode, must call setPreviewTarget first\n    status_t startRecording()\n    {\n        ALOGV(\"startRecording\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(START_RECORDING, data, &reply);\n        return reply.readInt32();\n    }\n\n    // stop preview mode\n    void stopPreview()\n    {\n        ALOGV(\"stopPreview\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(STOP_PREVIEW, data, &reply);\n    }\n\n    // stop recording mode\n    void stopRecording()\n    {\n        ALOGV(\"stopRecording\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(STOP_RECORDING, data, &reply);\n    }\n\n    void releaseRecordingFrame(const sp<IMemory>& mem)\n    {\n        ALOGV(\"releaseRecordingFrame\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(mem));\n        remote()->transact(RELEASE_RECORDING_FRAME, data, &reply);\n    }\n\n    status_t storeMetaDataInBuffers(bool enabled)\n    {\n        ALOGV(\"storeMetaDataInBuffers: %s\", enabled? \"true\": \"false\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        data.writeInt32(enabled);\n        remote()->transact(STORE_META_DATA_IN_BUFFERS, data, &reply);\n        return reply.readInt32();\n    }\n\n    // check preview state\n    bool previewEnabled()\n    {\n        ALOGV(\"previewEnabled\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(PREVIEW_ENABLED, data, &reply);\n        return reply.readInt32();\n    }\n\n    // check recording state\n    bool recordingEnabled()\n    {\n        ALOGV(\"recordingEnabled\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(RECORDING_ENABLED, data, &reply);\n        return reply.readInt32();\n    }\n\n    // auto focus\n    status_t autoFocus()\n    {\n        ALOGV(\"autoFocus\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(AUTO_FOCUS, data, &reply);\n        status_t ret = reply.readInt32();\n        return ret;\n    }\n\n    // cancel focus\n    status_t cancelAutoFocus()\n    {\n        ALOGV(\"cancelAutoFocus\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(CANCEL_AUTO_FOCUS, data, &reply);\n        status_t ret = reply.readInt32();\n        return ret;\n    }\n\n    // take a picture - returns an IMemory (ref-counted mmap)\n    status_t takePicture(int msgType)\n    {\n        ALOGV(\"takePicture: 0x%x\", msgType);\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        data.writeInt32(msgType);\n        remote()->transact(TAKE_PICTURE, data, &reply);\n        status_t ret = reply.readInt32();\n        return ret;\n    }\n\n    // set preview/capture parameters - key/value pairs\n    status_t setParameters(const String8& params)\n    {\n        ALOGV(\"setParameters\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        data.writeString8(params);\n        remote()->transact(SET_PARAMETERS, data, &reply);\n        return reply.readInt32();\n    }\n\n    // get preview/capture parameters - key/value pairs\n    String8 getParameters() const\n    {\n        ALOGV(\"getParameters\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(GET_PARAMETERS, data, &reply);\n        return reply.readString8();\n    }\n    virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)\n    {\n        ALOGV(\"sendCommand\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        data.writeInt32(cmd);\n        data.writeInt32(arg1);\n        data.writeInt32(arg2);\n        remote()->transact(SEND_COMMAND, data, &reply);\n        return reply.readInt32();\n    }\n    virtual status_t connect(const sp<ICameraClient>& cameraClient)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(cameraClient));\n        remote()->transact(CONNECT, data, &reply);\n        return reply.readInt32();\n    }\n    virtual status_t lock()\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(LOCK, data, &reply);\n        return reply.readInt32();\n    }\n    virtual status_t unlock()\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());\n        remote()->transact(UNLOCK, data, &reply);\n        return reply.readInt32();\n    }\n};\n\nIMPLEMENT_META_INTERFACE(Camera, \"android.hardware.ICamera\");\n\n// ----------------------------------------------------------------------\n\nstatus_t BnCamera::onTransact(\n    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)\n{\n    switch(code) {\n        case DISCONNECT: {\n            ALOGV(\"DISCONNECT\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            disconnect();\n            reply->writeNoException();\n            return NO_ERROR;\n        } break;\n        case SET_PREVIEW_TARGET: {\n            ALOGV(\"SET_PREVIEW_TARGET\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            sp<IGraphicBufferProducer> st =\n                interface_cast<IGraphicBufferProducer>(data.readStrongBinder());\n            reply->writeInt32(setPreviewTarget(st));\n            return NO_ERROR;\n        } break;\n        case SET_PREVIEW_CALLBACK_FLAG: {\n            ALOGV(\"SET_PREVIEW_CALLBACK_TYPE\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            int callback_flag = data.readInt32();\n            setPreviewCallbackFlag(callback_flag);\n            return NO_ERROR;\n        } break;\n        case SET_PREVIEW_CALLBACK_TARGET: {\n            ALOGV(\"SET_PREVIEW_CALLBACK_TARGET\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            sp<IGraphicBufferProducer> cp =\n                interface_cast<IGraphicBufferProducer>(data.readStrongBinder());\n            reply->writeInt32(setPreviewCallbackTarget(cp));\n            return NO_ERROR;\n        }\n        case START_PREVIEW: {\n            ALOGV(\"START_PREVIEW\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            reply->writeInt32(startPreview());\n            return NO_ERROR;\n        } break;\n        case START_RECORDING: {\n            ALOGV(\"START_RECORDING\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            reply->writeInt32(startRecording());\n            return NO_ERROR;\n        } break;\n        case STOP_PREVIEW: {\n            ALOGV(\"STOP_PREVIEW\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            stopPreview();\n            return NO_ERROR;\n        } break;\n        case STOP_RECORDING: {\n            ALOGV(\"STOP_RECORDING\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            stopRecording();\n            return NO_ERROR;\n        } break;\n        case RELEASE_RECORDING_FRAME: {\n            ALOGV(\"RELEASE_RECORDING_FRAME\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());\n            releaseRecordingFrame(mem);\n            return NO_ERROR;\n        } break;\n        case STORE_META_DATA_IN_BUFFERS: {\n            ALOGV(\"STORE_META_DATA_IN_BUFFERS\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            bool enabled = data.readInt32();\n            reply->writeInt32(storeMetaDataInBuffers(enabled));\n            return NO_ERROR;\n        } break;\n        case PREVIEW_ENABLED: {\n            ALOGV(\"PREVIEW_ENABLED\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            reply->writeInt32(previewEnabled());\n            return NO_ERROR;\n        } break;\n        case RECORDING_ENABLED: {\n            ALOGV(\"RECORDING_ENABLED\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            reply->writeInt32(recordingEnabled());\n            return NO_ERROR;\n        } break;\n        case AUTO_FOCUS: {\n            ALOGV(\"AUTO_FOCUS\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            reply->writeInt32(autoFocus());\n            return NO_ERROR;\n        } break;\n        case CANCEL_AUTO_FOCUS: {\n            ALOGV(\"CANCEL_AUTO_FOCUS\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            reply->writeInt32(cancelAutoFocus());\n            return NO_ERROR;\n        } break;\n        case TAKE_PICTURE: {\n            ALOGV(\"TAKE_PICTURE\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            int msgType = data.readInt32();\n            reply->writeInt32(takePicture(msgType));\n            return NO_ERROR;\n        } break;\n        case SET_PARAMETERS: {\n            ALOGV(\"SET_PARAMETERS\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            String8 params(data.readString8());\n            reply->writeInt32(setParameters(params));\n            return NO_ERROR;\n         } break;\n        case GET_PARAMETERS: {\n            ALOGV(\"GET_PARAMETERS\");\n            CHECK_INTERFACE(ICamera, data, reply);\n             reply->writeString8(getParameters());\n            return NO_ERROR;\n         } break;\n        case SEND_COMMAND: {\n            ALOGV(\"SEND_COMMAND\");\n            CHECK_INTERFACE(ICamera, data, reply);\n            int command = data.readInt32();\n            int arg1 = data.readInt32();\n            int arg2 = data.readInt32();\n            reply->writeInt32(sendCommand(command, arg1, arg2));\n            return NO_ERROR;\n         } break;\n        case CONNECT: {\n            CHECK_INTERFACE(ICamera, data, reply);\n            sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder());\n            reply->writeInt32(connect(cameraClient));\n            return NO_ERROR;\n        } break;\n        case LOCK: {\n            CHECK_INTERFACE(ICamera, data, reply);\n            reply->writeInt32(lock());\n            return NO_ERROR;\n        } break;\n        case UNLOCK: {\n            CHECK_INTERFACE(ICamera, data, reply);\n            reply->writeInt32(unlock());\n            return NO_ERROR;\n        } break;\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n\n// ----------------------------------------------------------------------------\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/ICameraClient.cpp",
    "content": "/*\n**\n** Copyright 2008, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\"); \n** you may not use this file except in compliance with the License. \n** You may obtain a copy of the License at \n**\n**     http://www.apache.org/licenses/LICENSE-2.0 \n**\n** Unless required by applicable law or agreed to in writing, software \n** distributed under the License is distributed on an \"AS IS\" BASIS, \n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n** See the License for the specific language governing permissions and \n** limitations under the License.\n*/\n\n//#define LOG_NDEBUG 0\n#define LOG_TAG \"ICameraClient\"\n#include <utils/Log.h>\n#include <stdint.h>\n#include <sys/types.h>\n#include <camera/ICameraClient.h>\n\nnamespace android {\n\nenum {\n    NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,\n    DATA_CALLBACK,\n    DATA_CALLBACK_TIMESTAMP,\n};\n\nclass BpCameraClient: public BpInterface<ICameraClient>\n{\npublic:\n    BpCameraClient(const sp<IBinder>& impl)\n        : BpInterface<ICameraClient>(impl)\n    {\n    }\n\n    // generic callback from camera service to app\n    void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)\n    {\n        ALOGV(\"notifyCallback\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());\n        data.writeInt32(msgType);\n        data.writeInt32(ext1);\n        if ((msgType == CAMERA_MSG_PREVIEW_FRAME) && (ext1 == CAMERA_FRAME_DATA_FD)) {\n            ALOGD(\"notifyCallback: CAMERA_MSG_PREVIEW_FRAME fd = %d\", ext2);\n            data.writeFileDescriptor(ext2);\n        } else {\n            data.writeInt32(ext2);\n        }\n        remote()->transact(NOTIFY_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);\n    }\n\n    // generic data callback from camera service to app with image data\n    void dataCallback(int32_t msgType, const sp<IMemory>& imageData,\n                      camera_frame_metadata_t *metadata)\n    {\n        ALOGV(\"dataCallback\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());\n        data.writeInt32(msgType);\n        data.writeStrongBinder(IInterface::asBinder(imageData));\n        if (metadata) {\n            data.writeInt32(metadata->number_of_faces);\n            data.write(metadata->faces, sizeof(camera_face_t) * metadata->number_of_faces);\n        }\n        remote()->transact(DATA_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);\n    }\n\n    // generic data callback from camera service to app with image data\n    void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& imageData)\n    {\n        ALOGV(\"dataCallback\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());\n        data.writeInt64(timestamp);\n        data.writeInt32(msgType);\n        data.writeStrongBinder(IInterface::asBinder(imageData));\n        remote()->transact(DATA_CALLBACK_TIMESTAMP, data, &reply, IBinder::FLAG_ONEWAY);\n    }\n};\n\nIMPLEMENT_META_INTERFACE(CameraClient, \"android.hardware.ICameraClient\");\n\n// ----------------------------------------------------------------------\n\nstatus_t BnCameraClient::onTransact(\n    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)\n{\n    switch(code) {\n        case NOTIFY_CALLBACK: {\n            ALOGV(\"NOTIFY_CALLBACK\");\n            CHECK_INTERFACE(ICameraClient, data, reply);\n            int32_t msgType = data.readInt32();\n            int32_t ext1    = data.readInt32();\n            int32_t ext2    = 0;\n            if ((msgType == CAMERA_MSG_PREVIEW_FRAME) && (ext1 == CAMERA_FRAME_DATA_FD)) {\n                ext2 = data.readFileDescriptor();\n                ALOGD(\"onTransact: CAMERA_MSG_PREVIEW_FRAME fd = %d\", ext2);\n            } else {\n                ext2 = data.readInt32();\n            }\n            notifyCallback(msgType, ext1, ext2);\n            return NO_ERROR;\n        } break;\n        case DATA_CALLBACK: {\n            ALOGV(\"DATA_CALLBACK\");\n            CHECK_INTERFACE(ICameraClient, data, reply);\n            int32_t msgType = data.readInt32();\n            sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder());\n            camera_frame_metadata_t *metadata = NULL;\n            if (data.dataAvail() > 0) {\n                metadata = new camera_frame_metadata_t;\n                metadata->number_of_faces = data.readInt32();\n                metadata->faces = (camera_face_t *) data.readInplace(\n                        sizeof(camera_face_t) * metadata->number_of_faces);\n            }\n            dataCallback(msgType, imageData, metadata);\n            if (metadata) delete metadata;\n            return NO_ERROR;\n        } break;\n        case DATA_CALLBACK_TIMESTAMP: {\n            ALOGV(\"DATA_CALLBACK_TIMESTAMP\");\n            CHECK_INTERFACE(ICameraClient, data, reply);\n            nsecs_t timestamp = data.readInt64();\n            int32_t msgType = data.readInt32();\n            sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder());\n            dataCallbackTimestamp(timestamp, msgType, imageData);\n            return NO_ERROR;\n        } break;\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n\n// ----------------------------------------------------------------------------\n\n}; // namespace android\n\n"
  },
  {
    "path": "libshims/ICameraRecordingProxy.cpp",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n//#define LOG_NDEBUG 0\n#define LOG_TAG \"ICameraRecordingProxy\"\n#include <camera/ICameraRecordingProxy.h>\n#include <camera/ICameraRecordingProxyListener.h>\n#include <binder/IMemory.h>\n#include <binder/Parcel.h>\n#include <stdint.h>\n#include <utils/Log.h>\n\nnamespace android {\n\nenum {\n    START_RECORDING = IBinder::FIRST_CALL_TRANSACTION,\n    STOP_RECORDING,\n    RELEASE_RECORDING_FRAME,\n};\n\nuint8_t ICameraRecordingProxy::baseObject = 0;\n\nsize_t ICameraRecordingProxy::getCommonBaseAddress() {\n    return (size_t)&baseObject;\n}\n\nclass BpCameraRecordingProxy: public BpInterface<ICameraRecordingProxy>\n{\npublic:\n    BpCameraRecordingProxy(const sp<IBinder>& impl)\n        : BpInterface<ICameraRecordingProxy>(impl)\n    {\n    }\n\n    status_t startRecording(const sp<ICameraRecordingProxyListener>& listener)\n    {\n        ALOGV(\"startRecording\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(listener));\n        remote()->transact(START_RECORDING, data, &reply);\n        return reply.readInt32();\n    }\n\n    void stopRecording()\n    {\n        ALOGV(\"stopRecording\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());\n        remote()->transact(STOP_RECORDING, data, &reply);\n    }\n\n    void releaseRecordingFrame(const sp<IMemory>& mem)\n    {\n        ALOGV(\"releaseRecordingFrame\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(mem));\n        remote()->transact(RELEASE_RECORDING_FRAME, data, &reply);\n    }\n};\n\nIMPLEMENT_META_INTERFACE(CameraRecordingProxy, \"android.hardware.ICameraRecordingProxy\");\n\n// ----------------------------------------------------------------------\n\nstatus_t BnCameraRecordingProxy::onTransact(\n    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)\n{\n    switch(code) {\n        case START_RECORDING: {\n            ALOGV(\"START_RECORDING\");\n            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);\n            sp<ICameraRecordingProxyListener> listener =\n                interface_cast<ICameraRecordingProxyListener>(data.readStrongBinder());\n            reply->writeInt32(startRecording(listener));\n            return NO_ERROR;\n        } break;\n        case STOP_RECORDING: {\n            ALOGV(\"STOP_RECORDING\");\n            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);\n            stopRecording();\n            return NO_ERROR;\n        } break;\n        case RELEASE_RECORDING_FRAME: {\n            ALOGV(\"RELEASE_RECORDING_FRAME\");\n            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);\n            sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());\n            releaseRecordingFrame(mem);\n            return NO_ERROR;\n        } break;\n\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n\n// ----------------------------------------------------------------------------\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/ICameraRecordingProxyListener.cpp",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n//#define LOG_NDEBUG 0\n#define LOG_TAG \"ICameraRecordingProxyListener\"\n#include <camera/ICameraRecordingProxyListener.h>\n#include <binder/IMemory.h>\n#include <binder/Parcel.h>\n#include <utils/Log.h>\n\nnamespace android {\n\nenum {\n    DATA_CALLBACK_TIMESTAMP = IBinder::FIRST_CALL_TRANSACTION,\n};\n\nclass BpCameraRecordingProxyListener: public BpInterface<ICameraRecordingProxyListener>\n{\npublic:\n    BpCameraRecordingProxyListener(const sp<IBinder>& impl)\n        : BpInterface<ICameraRecordingProxyListener>(impl)\n    {\n    }\n\n    void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& imageData)\n    {\n        ALOGV(\"dataCallback\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraRecordingProxyListener::getInterfaceDescriptor());\n        data.writeInt64(timestamp);\n        data.writeInt32(msgType);\n        data.writeStrongBinder(IInterface::asBinder(imageData));\n        remote()->transact(DATA_CALLBACK_TIMESTAMP, data, &reply, IBinder::FLAG_ONEWAY);\n    }\n};\n\nIMPLEMENT_META_INTERFACE(CameraRecordingProxyListener, \"android.hardware.ICameraRecordingProxyListener\");\n\n// ----------------------------------------------------------------------\n\nstatus_t BnCameraRecordingProxyListener::onTransact(\n    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)\n{\n    switch(code) {\n        case DATA_CALLBACK_TIMESTAMP: {\n            ALOGV(\"DATA_CALLBACK_TIMESTAMP\");\n            CHECK_INTERFACE(ICameraRecordingProxyListener, data, reply);\n            nsecs_t timestamp = data.readInt64();\n            int32_t msgType = data.readInt32();\n            sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder());\n            dataCallbackTimestamp(timestamp, msgType, imageData);\n            return NO_ERROR;\n        } break;\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n\n// ----------------------------------------------------------------------------\n\n}; // namespace android\n\n"
  },
  {
    "path": "libshims/ICameraService.cpp",
    "content": "/*\n**\n** Copyright 2008, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n#define LOG_TAG \"BpCameraService\"\n#include <utils/Log.h>\n#include <utils/Errors.h>\n#include <utils/String16.h>\n\n#include <inttypes.h>\n#include <stdint.h>\n#include <sys/types.h>\n\n#include <binder/Parcel.h>\n#include <binder/IPCThreadState.h>\n#include <binder/IServiceManager.h>\n\n#include <camera/ICameraService.h>\n#include <camera/ICameraServiceListener.h>\n#include <camera/ICamera.h>\n#include <camera/ICameraClient.h>\n#include <camera/camera2/ICameraDeviceUser.h>\n#include <camera/camera2/ICameraDeviceCallbacks.h>\n#include <camera/CameraMetadata.h>\n#include <camera/VendorTagDescriptor.h>\n\nnamespace android {\n\nnamespace {\n\nenum {\n    EX_SECURITY = -1,\n    EX_BAD_PARCELABLE = -2,\n    EX_ILLEGAL_ARGUMENT = -3,\n    EX_NULL_POINTER = -4,\n    EX_ILLEGAL_STATE = -5,\n    EX_HAS_REPLY_HEADER = -128,  // special; see below\n};\n\nstatic bool readExceptionCode(Parcel& reply) {\n    int32_t exceptionCode = reply.readExceptionCode();\n\n    if (exceptionCode != 0) {\n        const char* errorMsg;\n        switch(exceptionCode) {\n            case EX_SECURITY:\n                errorMsg = \"Security\";\n                break;\n            case EX_BAD_PARCELABLE:\n                errorMsg = \"BadParcelable\";\n                break;\n            case EX_NULL_POINTER:\n                errorMsg = \"NullPointer\";\n                break;\n            case EX_ILLEGAL_STATE:\n                errorMsg = \"IllegalState\";\n                break;\n            // Binder should be handling this code inside Parcel::readException\n            // but lets have a to-string here anyway just in case.\n            case EX_HAS_REPLY_HEADER:\n                errorMsg = \"HasReplyHeader\";\n                break;\n            default:\n                errorMsg = \"Unknown\";\n        }\n\n        ALOGE(\"Binder transmission error %s (%d)\", errorMsg, exceptionCode);\n        return true;\n    }\n\n    return false;\n}\n\n};\n\nclass BpCameraService: public BpInterface<ICameraService>\n{\npublic:\n    BpCameraService(const sp<IBinder>& impl)\n        : BpInterface<ICameraService>(impl)\n    {\n    }\n\n    // get number of cameras available that support standard camera operations\n    virtual int32_t getNumberOfCameras()\n    {\n        return getNumberOfCameras(CAMERA_TYPE_BACKWARD_COMPATIBLE);\n    }\n\n    // get number of cameras available of a given type\n    virtual int32_t getNumberOfCameras(int type)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeInt32(type);\n        remote()->transact(BnCameraService::GET_NUMBER_OF_CAMERAS, data, &reply);\n\n        if (readExceptionCode(reply)) return 0;\n        return reply.readInt32();\n    }\n\n    // get information about a camera\n    virtual status_t getCameraInfo(int cameraId,\n                                   struct CameraInfo* cameraInfo) {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeInt32(cameraId);\n        remote()->transact(BnCameraService::GET_CAMERA_INFO, data, &reply);\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        status_t result = reply.readInt32();\n        if (reply.readInt32() != 0) {\n            cameraInfo->facing = reply.readInt32();\n            cameraInfo->orientation = reply.readInt32();\n        }\n        return result;\n    }\n\n    // get camera characteristics (static metadata)\n    virtual status_t getCameraCharacteristics(int cameraId,\n                                              CameraMetadata* cameraInfo) {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeInt32(cameraId);\n        remote()->transact(BnCameraService::GET_CAMERA_CHARACTERISTICS, data, &reply);\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        status_t result = reply.readInt32();\n\n        CameraMetadata out;\n        if (reply.readInt32() != 0) {\n            out.readFromParcel(&reply);\n        }\n\n        if (cameraInfo != NULL) {\n            cameraInfo->swap(out);\n        }\n\n        return result;\n    }\n\n    // Get enumeration and description of vendor tags for camera\n    virtual status_t getCameraVendorTagDescriptor(/*out*/sp<VendorTagDescriptor>& desc) {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        remote()->transact(BnCameraService::GET_CAMERA_VENDOR_TAG_DESCRIPTOR, data, &reply);\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        status_t result = reply.readInt32();\n\n        if (reply.readInt32() != 0) {\n            sp<VendorTagDescriptor> d;\n            if (VendorTagDescriptor::createFromParcel(&reply, /*out*/d) == OK) {\n                desc = d;\n            }\n        }\n        return result;\n    }\n\n    // connect to camera service (android.hardware.Camera)\n    virtual status_t connect(const sp<ICameraClient>& cameraClient, int cameraId,\n                             const String16 &clientPackageName, int clientUid,\n                             /*out*/\n                             sp<ICamera>& device)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(cameraClient));\n        data.writeInt32(cameraId);\n        data.writeString16(clientPackageName);\n        data.writeInt32(clientUid);\n\n        status_t status;\n        status = remote()->transact(BnCameraService::CONNECT, data, &reply);\n        if (status != OK) return status;\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        status = reply.readInt32();\n        if (reply.readInt32() != 0) {\n            device = interface_cast<ICamera>(reply.readStrongBinder());\n        }\n        return status;\n    }\n\n    // connect to camera service (android.hardware.Camera)\n    virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient, int cameraId,\n                             int halVersion,\n                             const String16 &clientPackageName, int clientUid,\n                             /*out*/sp<ICamera>& device)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(cameraClient));\n        data.writeInt32(cameraId);\n        data.writeInt32(halVersion);\n        data.writeString16(clientPackageName);\n        data.writeInt32(clientUid);\n\n        status_t status;\n        status = remote()->transact(BnCameraService::CONNECT_LEGACY, data, &reply);\n        if (status != OK) return status;\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        status = reply.readInt32();\n        if (reply.readInt32() != 0) {\n            device = interface_cast<ICamera>(reply.readStrongBinder());\n        }\n        return status;\n    }\n\n    virtual status_t setTorchMode(const String16& cameraId, bool enabled,\n            const sp<IBinder>& clientBinder)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeString16(cameraId);\n        data.writeInt32(enabled ? 1 : 0);\n        data.writeStrongBinder(clientBinder);\n        remote()->transact(BnCameraService::SET_TORCH_MODE, data, &reply);\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        return reply.readInt32();\n    }\n\n    // connect to camera service (android.hardware.camera2.CameraDevice)\n    virtual status_t connectDevice(\n            const sp<ICameraDeviceCallbacks>& cameraCb,\n            int cameraId,\n            const String16& clientPackageName,\n            int clientUid,\n            /*out*/\n            sp<ICameraDeviceUser>& device)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(cameraCb));\n        data.writeInt32(cameraId);\n        data.writeString16(clientPackageName);\n        data.writeInt32(clientUid);\n\n        status_t status;\n        status = remote()->transact(BnCameraService::CONNECT_DEVICE, data, &reply);\n        if (status != OK) return status;\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        status = reply.readInt32();\n        if (reply.readInt32() != 0) {\n            device = interface_cast<ICameraDeviceUser>(reply.readStrongBinder());\n        }\n        return status;\n    }\n\n    virtual status_t addListener(const sp<ICameraServiceListener>& listener)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(listener));\n        remote()->transact(BnCameraService::ADD_LISTENER, data, &reply);\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        return reply.readInt32();\n    }\n\n    virtual status_t removeListener(const sp<ICameraServiceListener>& listener)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeStrongBinder(IInterface::asBinder(listener));\n        remote()->transact(BnCameraService::REMOVE_LISTENER, data, &reply);\n\n        if (readExceptionCode(reply)) return -EPROTO;\n        return reply.readInt32();\n    }\n\n    virtual status_t getLegacyParameters(int cameraId, String16* parameters) {\n        if (parameters == NULL) {\n            ALOGE(\"%s: parameters must not be null\", __FUNCTION__);\n            return BAD_VALUE;\n        }\n\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n\n        data.writeInt32(cameraId);\n        remote()->transact(BnCameraService::GET_LEGACY_PARAMETERS, data, &reply);\n        if (readExceptionCode(reply)) return -EPROTO;\n\n        status_t res = data.readInt32();\n        int32_t length = data.readInt32(); // -1 means null\n        if (length > 0) {\n            *parameters = data.readString16();\n        } else {\n            *parameters = String16();\n        }\n\n        return res;\n    }\n\n    virtual status_t supportsCameraApi(int cameraId, int apiVersion) {\n        Parcel data, reply;\n\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeInt32(cameraId);\n        data.writeInt32(apiVersion);\n        remote()->transact(BnCameraService::SUPPORTS_CAMERA_API, data, &reply);\n        if (readExceptionCode(reply)) return -EPROTO;\n\n        status_t res = data.readInt32();\n        return res;\n    }\n\n    virtual void notifySystemEvent(int32_t eventId, const int32_t* args, size_t len) {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());\n        data.writeInt32(eventId);\n        data.writeInt32Array(len, args);\n        remote()->transact(BnCameraService::NOTIFY_SYSTEM_EVENT, data, &reply,\n                IBinder::FLAG_ONEWAY);\n    }\n\n};\n\nIMPLEMENT_META_INTERFACE(CameraService, \"android.hardware.ICameraService\");\n\n// ----------------------------------------------------------------------\n\nstatus_t BnCameraService::onTransact(\n    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)\n{\n    switch(code) {\n        case GET_NUMBER_OF_CAMERAS: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            reply->writeNoException();\n            reply->writeInt32(getNumberOfCameras(data.readInt32()));\n            return NO_ERROR;\n        } break;\n        case GET_CAMERA_INFO: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            CameraInfo cameraInfo = CameraInfo();\n            memset(&cameraInfo, 0, sizeof(cameraInfo));\n            status_t result = getCameraInfo(data.readInt32(), &cameraInfo);\n            reply->writeNoException();\n            reply->writeInt32(result);\n\n            // Fake a parcelable object here\n            reply->writeInt32(1); // means the parcelable is included\n            reply->writeInt32(cameraInfo.facing);\n            reply->writeInt32(cameraInfo.orientation);\n            return NO_ERROR;\n        } break;\n        case GET_CAMERA_CHARACTERISTICS: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            CameraMetadata info;\n            status_t result = getCameraCharacteristics(data.readInt32(), &info);\n            reply->writeNoException();\n            reply->writeInt32(result);\n\n            // out-variables are after exception and return value\n            reply->writeInt32(1); // means the parcelable is included\n            info.writeToParcel(reply);\n            return NO_ERROR;\n        } break;\n        case GET_CAMERA_VENDOR_TAG_DESCRIPTOR: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            sp<VendorTagDescriptor> d;\n            status_t result = getCameraVendorTagDescriptor(d);\n            reply->writeNoException();\n            reply->writeInt32(result);\n\n            // out-variables are after exception and return value\n            if (d == NULL) {\n                reply->writeInt32(0);\n            } else {\n                reply->writeInt32(1); // means the parcelable is included\n                d->writeToParcel(reply);\n            }\n            return NO_ERROR;\n        } break;\n        case CONNECT: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            sp<ICameraClient> cameraClient =\n                    interface_cast<ICameraClient>(data.readStrongBinder());\n            int32_t cameraId = data.readInt32();\n            const String16 clientName = data.readString16();\n            int32_t clientUid = data.readInt32();\n            sp<ICamera> camera;\n            status_t status = connect(cameraClient, cameraId,\n                    clientName, clientUid, /*out*/camera);\n            reply->writeNoException();\n            reply->writeInt32(status);\n            if (camera != NULL) {\n                reply->writeInt32(1);\n                reply->writeStrongBinder(IInterface::asBinder(camera));\n            } else {\n                reply->writeInt32(0);\n            }\n            return NO_ERROR;\n        } break;\n        case CONNECT_DEVICE: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            sp<ICameraDeviceCallbacks> cameraClient =\n                interface_cast<ICameraDeviceCallbacks>(data.readStrongBinder());\n            int32_t cameraId = data.readInt32();\n            const String16 clientName = data.readString16();\n            int32_t clientUid = data.readInt32();\n            sp<ICameraDeviceUser> camera;\n            status_t status = connectDevice(cameraClient, cameraId,\n                    clientName, clientUid, /*out*/camera);\n            reply->writeNoException();\n            reply->writeInt32(status);\n            if (camera != NULL) {\n                reply->writeInt32(1);\n                reply->writeStrongBinder(IInterface::asBinder(camera));\n            } else {\n                reply->writeInt32(0);\n            }\n            return NO_ERROR;\n        } break;\n        case ADD_LISTENER: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            sp<ICameraServiceListener> listener =\n                interface_cast<ICameraServiceListener>(data.readStrongBinder());\n            reply->writeNoException();\n            reply->writeInt32(addListener(listener));\n            return NO_ERROR;\n        } break;\n        case REMOVE_LISTENER: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            sp<ICameraServiceListener> listener =\n                interface_cast<ICameraServiceListener>(data.readStrongBinder());\n            reply->writeNoException();\n            reply->writeInt32(removeListener(listener));\n            return NO_ERROR;\n        } break;\n        case GET_LEGACY_PARAMETERS: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            int cameraId = data.readInt32();\n            String16 parameters;\n\n            reply->writeNoException();\n            // return value\n            reply->writeInt32(getLegacyParameters(cameraId, &parameters));\n            // out parameters\n            reply->writeInt32(1); // parameters is always available\n            reply->writeString16(parameters);\n            return NO_ERROR;\n        } break;\n        case SUPPORTS_CAMERA_API: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            int cameraId = data.readInt32();\n            int apiVersion = data.readInt32();\n\n            reply->writeNoException();\n            // return value\n            reply->writeInt32(supportsCameraApi(cameraId, apiVersion));\n            return NO_ERROR;\n        } break;\n        case CONNECT_LEGACY: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            sp<ICameraClient> cameraClient =\n                    interface_cast<ICameraClient>(data.readStrongBinder());\n            int32_t cameraId = data.readInt32();\n            int32_t halVersion = data.readInt32();\n            const String16 clientName = data.readString16();\n            int32_t clientUid = data.readInt32();\n            sp<ICamera> camera;\n            status_t status = connectLegacy(cameraClient, cameraId, halVersion,\n                    clientName, clientUid, /*out*/camera);\n            reply->writeNoException();\n            reply->writeInt32(status);\n            if (camera != NULL) {\n                reply->writeInt32(1);\n                reply->writeStrongBinder(IInterface::asBinder(camera));\n            } else {\n                reply->writeInt32(0);\n            }\n            return NO_ERROR;\n        } break;\n        case SET_TORCH_MODE: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            String16 cameraId = data.readString16();\n            bool enabled = data.readInt32() != 0 ? true : false;\n            const sp<IBinder> clientBinder = data.readStrongBinder();\n            status_t status = setTorchMode(cameraId, enabled, clientBinder);\n            reply->writeNoException();\n            reply->writeInt32(status);\n            return NO_ERROR;\n        } break;\n        case NOTIFY_SYSTEM_EVENT: {\n            CHECK_INTERFACE(ICameraService, data, reply);\n            int32_t eventId = data.readInt32();\n            int32_t len = data.readInt32();\n            if (len < 0) {\n                ALOGE(\"%s: Received poorly formatted length in binder request: notifySystemEvent.\",\n                        __FUNCTION__);\n                return FAILED_TRANSACTION;\n            }\n            if (len > 512) {\n                ALOGE(\"%s: Length %\" PRIi32 \" too long in binder request: notifySystemEvent.\",\n                        __FUNCTION__, len);\n                return FAILED_TRANSACTION;\n            }\n            int32_t events[len];\n            memset(events, 0, sizeof(int32_t) * len);\n            status_t status = data.read(events, sizeof(int32_t) * len);\n            if (status != NO_ERROR) {\n                ALOGE(\"%s: Received poorly formatted binder request: notifySystemEvent.\",\n                        __FUNCTION__);\n                return FAILED_TRANSACTION;\n            }\n            notifySystemEvent(eventId, events, len);\n            return NO_ERROR;\n        } break;\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n\n// ----------------------------------------------------------------------------\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/ICameraServiceListener.cpp",
    "content": "/*\n**\n** Copyright 2013, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n#include <stdint.h>\n#include <sys/types.h>\n\n#include <binder/Parcel.h>\n#include <binder/IPCThreadState.h>\n#include <binder/IServiceManager.h>\n\n#include <camera/ICameraServiceListener.h>\n\nnamespace android {\n\nnamespace {\n    enum {\n        STATUS_CHANGED = IBinder::FIRST_CALL_TRANSACTION,\n        TORCH_STATUS_CHANGED,\n    };\n}; // namespace anonymous\n\nclass BpCameraServiceListener: public BpInterface<ICameraServiceListener>\n{\n\npublic:\n    BpCameraServiceListener(const sp<IBinder>& impl)\n        : BpInterface<ICameraServiceListener>(impl)\n    {\n    }\n\n    virtual void onStatusChanged(Status status, int32_t cameraId)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraServiceListener::getInterfaceDescriptor());\n\n        data.writeInt32(static_cast<int32_t>(status));\n        data.writeInt32(cameraId);\n\n        remote()->transact(STATUS_CHANGED,\n                           data,\n                           &reply,\n                           IBinder::FLAG_ONEWAY);\n    }\n\n    virtual void onTorchStatusChanged(TorchStatus status, const String16 &cameraId)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraServiceListener::getInterfaceDescriptor());\n\n        data.writeInt32(static_cast<int32_t>(status));\n        data.writeString16(cameraId);\n\n        remote()->transact(TORCH_STATUS_CHANGED,\n                           data,\n                           &reply,\n                           IBinder::FLAG_ONEWAY);\n    }\n};\n\nIMPLEMENT_META_INTERFACE(CameraServiceListener, \"android.hardware.ICameraServiceListener\");\n\n// ----------------------------------------------------------------------\n\nstatus_t BnCameraServiceListener::onTransact(uint32_t code, const Parcel& data, Parcel* reply,\n        uint32_t flags) {\n    switch(code) {\n        case STATUS_CHANGED: {\n            CHECK_INTERFACE(ICameraServiceListener, data, reply);\n\n            Status status = static_cast<Status>(data.readInt32());\n            int32_t cameraId = data.readInt32();\n\n            onStatusChanged(status, cameraId);\n\n            return NO_ERROR;\n        } break;\n        case TORCH_STATUS_CHANGED: {\n            CHECK_INTERFACE(ICameraServiceListener, data, reply);\n\n            TorchStatus status = static_cast<TorchStatus>(data.readInt32());\n            String16 cameraId = data.readString16();\n\n            onTorchStatusChanged(status, cameraId);\n\n            return NO_ERROR;\n        } break;\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n\n// ----------------------------------------------------------------------------\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/ICameraServiceProxy.cpp",
    "content": "/*\n * Copyright (C) 2015 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"BpCameraServiceProxy\"\n\n#include <stdint.h>\n\n#include <binder/Parcel.h>\n\n#include <camera/ICameraServiceProxy.h>\n\nnamespace android {\n\nclass BpCameraServiceProxy: public BpInterface<ICameraServiceProxy> {\npublic:\n    BpCameraServiceProxy(const sp<IBinder>& impl) : BpInterface<ICameraServiceProxy>(impl) {}\n\n    virtual void pingForUserUpdate() {\n        Parcel data;\n        data.writeInterfaceToken(ICameraServiceProxy::getInterfaceDescriptor());\n        remote()->transact(BnCameraServiceProxy::PING_FOR_USER_UPDATE, data, nullptr,\n                IBinder::FLAG_ONEWAY);\n    }\n\n    virtual void notifyCameraState(String16 cameraId, CameraState newCameraState) {\n        Parcel data;\n        data.writeInterfaceToken(ICameraServiceProxy::getInterfaceDescriptor());\n        data.writeString16(cameraId);\n        data.writeInt32(newCameraState);\n        remote()->transact(BnCameraServiceProxy::NOTIFY_CAMERA_STATE, data, nullptr,\n                IBinder::FLAG_ONEWAY);\n    }\n\n};\n\n\nIMPLEMENT_META_INTERFACE(CameraServiceProxy, \"android.hardware.ICameraServiceProxy\");\n\nstatus_t BnCameraServiceProxy::onTransact(uint32_t code, const Parcel& data, Parcel* reply,\n        uint32_t flags) {\n    switch(code) {\n        case PING_FOR_USER_UPDATE: {\n            CHECK_INTERFACE(ICameraServiceProxy, data, reply);\n            pingForUserUpdate();\n            return NO_ERROR;\n        } break;\n        case NOTIFY_CAMERA_STATE: {\n            CHECK_INTERFACE(ICameraServiceProxy, data, reply);\n            String16 cameraId = data.readString16();\n            CameraState newCameraState =\n                static_cast<CameraState>(data.readInt32());\n            notifyCameraState(cameraId, newCameraState);\n            return NO_ERROR;\n        } break;\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n}; // namespace android\n"
  },
  {
    "path": "libshims/VendorTagDescriptor.cpp",
    "content": "/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"VendorTagDescriptor\"\n\n#include <binder/Parcel.h>\n#include <utils/Errors.h>\n#include <utils/Log.h>\n#include <utils/Mutex.h>\n#include <utils/Vector.h>\n#include <utils/SortedVector.h>\n#include <system/camera_metadata.h>\n#include <camera_metadata_hidden.h>\n\n#include \"camera/VendorTagDescriptor.h\"\n\n#include <stdio.h>\n#include <string.h>\n\nnamespace android {\n\nextern \"C\" {\n\nstatic int vendor_tag_descriptor_get_tag_count(const vendor_tag_ops_t* v);\nstatic void vendor_tag_descriptor_get_all_tags(const vendor_tag_ops_t* v, uint32_t* tagArray);\nstatic const char* vendor_tag_descriptor_get_section_name(const vendor_tag_ops_t* v, uint32_t tag);\nstatic const char* vendor_tag_descriptor_get_tag_name(const vendor_tag_ops_t* v, uint32_t tag);\nstatic int vendor_tag_descriptor_get_tag_type(const vendor_tag_ops_t* v, uint32_t tag);\n\n} /* extern \"C\" */\n\n\nstatic Mutex sLock;\nstatic sp<VendorTagDescriptor> sGlobalVendorTagDescriptor;\n\nVendorTagDescriptor::VendorTagDescriptor() {}\n\nVendorTagDescriptor::~VendorTagDescriptor() {\n    size_t len = mReverseMapping.size();\n    for (size_t i = 0; i < len; ++i)  {\n        delete mReverseMapping[i];\n    }\n}\n\nstatus_t VendorTagDescriptor::createDescriptorFromOps(const vendor_tag_ops_t* vOps,\n            /*out*/\n            sp<VendorTagDescriptor>& descriptor) {\n    if (vOps == NULL) {\n        ALOGE(\"%s: vendor_tag_ops argument was NULL.\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    int tagCount = vOps->get_tag_count(vOps);\n    if (tagCount < 0 || tagCount > INT32_MAX) {\n        ALOGE(\"%s: tag count %d from vendor ops is invalid.\", __FUNCTION__, tagCount);\n        return BAD_VALUE;\n    }\n\n    Vector<uint32_t> tagArray;\n    LOG_ALWAYS_FATAL_IF(tagArray.resize(tagCount) != tagCount,\n            \"%s: too many (%u) vendor tags defined.\", __FUNCTION__, tagCount);\n\n    vOps->get_all_tags(vOps, /*out*/tagArray.editArray());\n\n    sp<VendorTagDescriptor> desc = new VendorTagDescriptor();\n    desc->mTagCount = tagCount;\n\n    SortedVector<String8> sections;\n    KeyedVector<uint32_t, String8> tagToSectionMap;\n\n    for (size_t i = 0; i < static_cast<size_t>(tagCount); ++i) {\n        uint32_t tag = tagArray[i];\n        if (tag < CAMERA_METADATA_VENDOR_TAG_BOUNDARY) {\n            ALOGE(\"%s: vendor tag %d not in vendor tag section.\", __FUNCTION__, tag);\n            return BAD_VALUE;\n        }\n        const char *tagName = vOps->get_tag_name(vOps, tag);\n        if (tagName == NULL) {\n            ALOGE(\"%s: no tag name defined for vendor tag %d.\", __FUNCTION__, tag);\n            return BAD_VALUE;\n        }\n        desc->mTagToNameMap.add(tag, String8(tagName));\n        const char *sectionName = vOps->get_section_name(vOps, tag);\n        if (sectionName == NULL) {\n            ALOGE(\"%s: no section name defined for vendor tag %d.\", __FUNCTION__, tag);\n            return BAD_VALUE;\n        }\n\n        String8 sectionString(sectionName);\n\n        sections.add(sectionString);\n        tagToSectionMap.add(tag, sectionString);\n\n        int tagType = vOps->get_tag_type(vOps, tag);\n        if (tagType < 0 || tagType >= NUM_TYPES) {\n            ALOGE(\"%s: tag type %d from vendor ops does not exist.\", __FUNCTION__, tagType);\n            return BAD_VALUE;\n        }\n        desc->mTagToTypeMap.add(tag, tagType);\n    }\n\n    desc->mSections = sections;\n\n    for (size_t i = 0; i < static_cast<size_t>(tagCount); ++i) {\n        uint32_t tag = tagArray[i];\n        String8 sectionString = tagToSectionMap.valueFor(tag);\n\n        // Set up tag to section index map\n        ssize_t index = sections.indexOf(sectionString);\n        LOG_ALWAYS_FATAL_IF(index < 0, \"index %zd must be non-negative\", index);\n        desc->mTagToSectionMap.add(tag, static_cast<uint32_t>(index));\n\n        // Set up reverse mapping\n        ssize_t reverseIndex = -1;\n        if ((reverseIndex = desc->mReverseMapping.indexOfKey(sectionString)) < 0) {\n            KeyedVector<String8, uint32_t>* nameMapper = new KeyedVector<String8, uint32_t>();\n            reverseIndex = desc->mReverseMapping.add(sectionString, nameMapper);\n        }\n        desc->mReverseMapping[reverseIndex]->add(desc->mTagToNameMap.valueFor(tag), tag);\n    }\n\n    descriptor = desc;\n    return OK;\n}\n\nstatus_t VendorTagDescriptor::createFromParcel(const Parcel* parcel,\n            /*out*/\n            sp<VendorTagDescriptor>& descriptor) {\n    status_t res = OK;\n    if (parcel == NULL) {\n        ALOGE(\"%s: parcel argument was NULL.\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    int32_t tagCount = 0;\n    if ((res = parcel->readInt32(&tagCount)) != OK) {\n        ALOGE(\"%s: could not read tag count from parcel\", __FUNCTION__);\n        return res;\n    }\n\n    if (tagCount < 0 || tagCount > INT32_MAX) {\n        ALOGE(\"%s: tag count %d from vendor ops is invalid.\", __FUNCTION__, tagCount);\n        return BAD_VALUE;\n    }\n\n    sp<VendorTagDescriptor> desc = new VendorTagDescriptor();\n    desc->mTagCount = tagCount;\n\n    uint32_t tag, sectionIndex;\n    uint32_t maxSectionIndex = 0;\n    int32_t tagType;\n    Vector<uint32_t> allTags;\n    for (int32_t i = 0; i < tagCount; ++i) {\n        if ((res = parcel->readInt32(reinterpret_cast<int32_t*>(&tag))) != OK) {\n            ALOGE(\"%s: could not read tag id from parcel for index %d\", __FUNCTION__, i);\n            break;\n        }\n        if (tag < CAMERA_METADATA_VENDOR_TAG_BOUNDARY) {\n            ALOGE(\"%s: vendor tag %d not in vendor tag section.\", __FUNCTION__, tag);\n            res = BAD_VALUE;\n            break;\n        }\n        if ((res = parcel->readInt32(&tagType)) != OK) {\n            ALOGE(\"%s: could not read tag type from parcel for tag %d\", __FUNCTION__, tag);\n            break;\n        }\n        if (tagType < 0 || tagType >= NUM_TYPES) {\n            ALOGE(\"%s: tag type %d from vendor ops does not exist.\", __FUNCTION__, tagType);\n            res = BAD_VALUE;\n            break;\n        }\n        String8 tagName = parcel->readString8();\n        if (tagName.isEmpty()) {\n            ALOGE(\"%s: parcel tag name was NULL for tag %d.\", __FUNCTION__, tag);\n            res = NOT_ENOUGH_DATA;\n            break;\n        }\n\n        if ((res = parcel->readInt32(reinterpret_cast<int32_t*>(&sectionIndex))) != OK) {\n            ALOGE(\"%s: could not read section index for tag %d.\", __FUNCTION__, tag);\n            break;\n        }\n\n        maxSectionIndex = (maxSectionIndex >= sectionIndex) ? maxSectionIndex : sectionIndex;\n\n        allTags.add(tag);\n        desc->mTagToNameMap.add(tag, tagName);\n        desc->mTagToSectionMap.add(tag, sectionIndex);\n        desc->mTagToTypeMap.add(tag, tagType);\n    }\n\n    if (res != OK) {\n        return res;\n    }\n\n    size_t sectionCount = 0;\n    if (tagCount > 0) {\n        if ((res = parcel->readInt32(reinterpret_cast<int32_t*>(&sectionCount))) != OK) {\n            ALOGE(\"%s: could not read section count for.\", __FUNCTION__);\n            return res;\n        }\n        if (sectionCount < (maxSectionIndex + 1)) {\n            ALOGE(\"%s: Incorrect number of sections defined, received %zu, needs %d.\",\n                    __FUNCTION__, sectionCount, (maxSectionIndex + 1));\n            return BAD_VALUE;\n        }\n        LOG_ALWAYS_FATAL_IF(desc->mSections.setCapacity(sectionCount) <= 0,\n                \"Vector capacity must be positive\");\n        for (size_t i = 0; i < sectionCount; ++i) {\n            String8 sectionName = parcel->readString8();\n            if (sectionName.isEmpty()) {\n                ALOGE(\"%s: parcel section name was NULL for section %zu.\",\n                      __FUNCTION__, i);\n                return NOT_ENOUGH_DATA;\n            }\n            desc->mSections.add(sectionName);\n        }\n    }\n\n    LOG_ALWAYS_FATAL_IF(static_cast<size_t>(tagCount) != allTags.size(),\n                        \"tagCount must be the same as allTags size\");\n    // Set up reverse mapping\n    for (size_t i = 0; i < static_cast<size_t>(tagCount); ++i) {\n        uint32_t tag = allTags[i];\n        String8 sectionString = desc->mSections[desc->mTagToSectionMap.valueFor(tag)];\n\n        ssize_t reverseIndex = -1;\n        if ((reverseIndex = desc->mReverseMapping.indexOfKey(sectionString)) < 0) {\n            KeyedVector<String8, uint32_t>* nameMapper = new KeyedVector<String8, uint32_t>();\n            reverseIndex = desc->mReverseMapping.add(sectionString, nameMapper);\n        }\n        desc->mReverseMapping[reverseIndex]->add(desc->mTagToNameMap.valueFor(tag), tag);\n    }\n\n    descriptor = desc;\n    return res;\n}\n\nint VendorTagDescriptor::getTagCount() const {\n    size_t size = mTagToNameMap.size();\n    if (size == 0) {\n        return VENDOR_TAG_COUNT_ERR;\n    }\n    return size;\n}\n\nvoid VendorTagDescriptor::getTagArray(uint32_t* tagArray) const {\n    size_t size = mTagToNameMap.size();\n    for (size_t i = 0; i < size; ++i) {\n        tagArray[i] = mTagToNameMap.keyAt(i);\n    }\n}\n\nconst char* VendorTagDescriptor::getSectionName(uint32_t tag) const {\n    ssize_t index = mTagToSectionMap.indexOfKey(tag);\n    if (index < 0) {\n        return VENDOR_SECTION_NAME_ERR;\n    }\n    return mSections[mTagToSectionMap.valueAt(index)].string();\n}\n\nconst char* VendorTagDescriptor::getTagName(uint32_t tag) const {\n    ssize_t index = mTagToNameMap.indexOfKey(tag);\n    if (index < 0) {\n        return VENDOR_TAG_NAME_ERR;\n    }\n    return mTagToNameMap.valueAt(index).string();\n}\n\nint VendorTagDescriptor::getTagType(uint32_t tag) const {\n    ssize_t index = mTagToNameMap.indexOfKey(tag);\n    if (index < 0) {\n        return VENDOR_TAG_TYPE_ERR;\n    }\n    return mTagToTypeMap.valueFor(tag);\n}\n\nstatus_t VendorTagDescriptor::writeToParcel(Parcel* parcel) const {\n    status_t res = OK;\n    if (parcel == NULL) {\n        ALOGE(\"%s: parcel argument was NULL.\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    if ((res = parcel->writeInt32(mTagCount)) != OK) {\n        return res;\n    }\n\n    size_t size = mTagToNameMap.size();\n    uint32_t tag, sectionIndex;\n    int32_t tagType;\n    for (size_t i = 0; i < size; ++i) {\n        tag = mTagToNameMap.keyAt(i);\n        String8 tagName = mTagToNameMap[i];\n        sectionIndex = mTagToSectionMap.valueFor(tag);\n        tagType = mTagToTypeMap.valueFor(tag);\n        if ((res = parcel->writeInt32(tag)) != OK) break;\n        if ((res = parcel->writeInt32(tagType)) != OK) break;\n        if ((res = parcel->writeString8(tagName)) != OK) break;\n        if ((res = parcel->writeInt32(sectionIndex)) != OK) break;\n    }\n\n    size_t numSections = mSections.size();\n    if (numSections > 0) {\n        if ((res = parcel->writeInt32(numSections)) != OK) return res;\n        for (size_t i = 0; i < numSections; ++i) {\n            if ((res = parcel->writeString8(mSections[i])) != OK) return res;\n        }\n    }\n\n    return res;\n}\n\nSortedVector<String8> VendorTagDescriptor::getAllSectionNames() const {\n    return mSections;\n}\n\nstatus_t VendorTagDescriptor::lookupTag(String8 name, String8 section, /*out*/uint32_t* tag) const {\n    ssize_t index = mReverseMapping.indexOfKey(section);\n    if (index < 0) {\n        ALOGE(\"%s: Section '%s' does not exist.\", __FUNCTION__, section.string());\n        return BAD_VALUE;\n    }\n\n    ssize_t nameIndex = mReverseMapping[index]->indexOfKey(name);\n    if (nameIndex < 0) {\n        ALOGE(\"%s: Tag name '%s' does not exist.\", __FUNCTION__, name.string());\n        return BAD_VALUE;\n    }\n\n    if (tag != NULL) {\n        *tag = mReverseMapping[index]->valueAt(nameIndex);\n    }\n    return OK;\n}\n\nvoid VendorTagDescriptor::dump(int fd, int verbosity, int indentation) const {\n\n    size_t size = mTagToNameMap.size();\n    if (size == 0) {\n        dprintf(fd, \"%*sDumping configured vendor tag descriptors: None set\\n\",\n                indentation, \"\");\n        return;\n    }\n\n    dprintf(fd, \"%*sDumping configured vendor tag descriptors: %zu entries\\n\",\n            indentation, \"\", size);\n    for (size_t i = 0; i < size; ++i) {\n        uint32_t tag =  mTagToNameMap.keyAt(i);\n\n        if (verbosity < 1) {\n            dprintf(fd, \"%*s0x%x\\n\", indentation + 2, \"\", tag);\n            continue;\n        }\n        String8 name = mTagToNameMap.valueAt(i);\n        uint32_t sectionId = mTagToSectionMap.valueFor(tag);\n        String8 sectionName = mSections[sectionId];\n        int type = mTagToTypeMap.valueFor(tag);\n        const char* typeName = (type >= 0 && type < NUM_TYPES) ?\n                camera_metadata_type_names[type] : \"UNKNOWN\";\n        dprintf(fd, \"%*s0x%x (%s) with type %d (%s) defined in section %s\\n\", indentation + 2,\n            \"\", tag, name.string(), type, typeName, sectionName.string());\n    }\n\n}\n\nstatus_t VendorTagDescriptor::setAsGlobalVendorTagDescriptor(const sp<VendorTagDescriptor>& desc) {\n    status_t res = OK;\n    Mutex::Autolock al(sLock);\n    sGlobalVendorTagDescriptor = desc;\n\n    vendor_tag_ops_t* opsPtr = NULL;\n    if (desc != NULL) {\n        opsPtr = &(desc->mVendorOps);\n        opsPtr->get_tag_count = vendor_tag_descriptor_get_tag_count;\n        opsPtr->get_all_tags = vendor_tag_descriptor_get_all_tags;\n        opsPtr->get_section_name = vendor_tag_descriptor_get_section_name;\n        opsPtr->get_tag_name = vendor_tag_descriptor_get_tag_name;\n        opsPtr->get_tag_type = vendor_tag_descriptor_get_tag_type;\n    }\n    if((res = set_camera_metadata_vendor_ops(opsPtr)) != OK) {\n        ALOGE(\"%s: Could not set vendor tag descriptor, received error %s (%d).\"\n                , __FUNCTION__, strerror(-res), res);\n    }\n    return res;\n}\n\nvoid VendorTagDescriptor::clearGlobalVendorTagDescriptor() {\n    Mutex::Autolock al(sLock);\n    set_camera_metadata_vendor_ops(NULL);\n    sGlobalVendorTagDescriptor.clear();\n}\n\nsp<VendorTagDescriptor> VendorTagDescriptor::getGlobalVendorTagDescriptor() {\n    Mutex::Autolock al(sLock);\n    return sGlobalVendorTagDescriptor;\n}\n\nextern \"C\" {\n\nint vendor_tag_descriptor_get_tag_count(const vendor_tag_ops_t* /*v*/) {\n    Mutex::Autolock al(sLock);\n    if (sGlobalVendorTagDescriptor == NULL) {\n        ALOGE(\"%s: Vendor tag descriptor not initialized.\", __FUNCTION__);\n        return VENDOR_TAG_COUNT_ERR;\n    }\n    return sGlobalVendorTagDescriptor->getTagCount();\n}\n\nvoid vendor_tag_descriptor_get_all_tags(const vendor_tag_ops_t* /*v*/, uint32_t* tagArray) {\n    Mutex::Autolock al(sLock);\n    if (sGlobalVendorTagDescriptor == NULL) {\n        ALOGE(\"%s: Vendor tag descriptor not initialized.\", __FUNCTION__);\n        return;\n    }\n    sGlobalVendorTagDescriptor->getTagArray(tagArray);\n}\n\nconst char* vendor_tag_descriptor_get_section_name(const vendor_tag_ops_t* /*v*/, uint32_t tag) {\n    Mutex::Autolock al(sLock);\n    if (sGlobalVendorTagDescriptor == NULL) {\n        ALOGE(\"%s: Vendor tag descriptor not initialized.\", __FUNCTION__);\n        return VENDOR_SECTION_NAME_ERR;\n    }\n    return sGlobalVendorTagDescriptor->getSectionName(tag);\n}\n\nconst char* vendor_tag_descriptor_get_tag_name(const vendor_tag_ops_t* /*v*/, uint32_t tag) {\n    Mutex::Autolock al(sLock);\n    if (sGlobalVendorTagDescriptor == NULL) {\n        ALOGE(\"%s: Vendor tag descriptor not initialized.\", __FUNCTION__);\n        return VENDOR_TAG_NAME_ERR;\n    }\n    return sGlobalVendorTagDescriptor->getTagName(tag);\n}\n\nint vendor_tag_descriptor_get_tag_type(const vendor_tag_ops_t* /*v*/, uint32_t tag) {\n    Mutex::Autolock al(sLock);\n    if (sGlobalVendorTagDescriptor == NULL) {\n        ALOGE(\"%s: Vendor tag descriptor not initialized.\", __FUNCTION__);\n        return VENDOR_TAG_TYPE_ERR;\n    }\n    return sGlobalVendorTagDescriptor->getTagType(tag);\n}\n\n} /* extern \"C\" */\n} /* namespace android */\n"
  },
  {
    "path": "libshims/camera.cpp",
    "content": "/*\n * Copyright (C) 2016 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <stdio.h>\n#include <string>\n\nextern \"C\" {\n\nextern ssize_t _ZN7android13SensorManager13getSensorListEPPKPKNS_6SensorE(void*, void*);\n\nssize_t _ZNK7android13SensorManager13getSensorListEPPKPKNS_6SensorE(void* thiz, void* list) {\n    return _ZN7android13SensorManager13getSensorListEPPKPKNS_6SensorE(thiz, list);\n}\n\n}\n\n// GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,\n//               uint32_t inUsage, std::string requestorName = \"<Unknown>\");\nextern \"C\" void _ZN7android13GraphicBufferC1EjjijNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(\n    uint32_t inWidth, uint32_t inHeight, int inFormat, uint32_t inUsage,\n    std::string requestorName);\n\nextern \"C\" void _ZN7android13GraphicBufferC1Ejjij(\n    uint32_t inWidth, uint32_t inHeight, int inFormat, uint32_t inUsage) {\n  std::string requestorName = \"<Unknown>\";\n  _ZN7android13GraphicBufferC1EjjijNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(\n      inWidth, inHeight, inFormat, inUsage, requestorName);\n}\n\n"
  },
  {
    "path": "libshims/camera2/CaptureRequest.cpp",
    "content": "/*\n**\n** Copyright 2013, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n// #define LOG_NDEBUG 0\n#define LOG_TAG \"CameraRequest\"\n#include <utils/Log.h>\n\n#include <camera/camera2/CaptureRequest.h>\n\n#include <binder/Parcel.h>\n#include <gui/Surface.h>\n\nnamespace android {\n\nstatus_t CaptureRequest::readFromParcel(Parcel* parcel) {\n    if (parcel == NULL) {\n        ALOGE(\"%s: Null parcel\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    mMetadata.clear();\n    mSurfaceList.clear();\n\n    status_t err;\n\n    if ((err = mMetadata.readFromParcel(parcel)) != OK) {\n        ALOGE(\"%s: Failed to read metadata from parcel\", __FUNCTION__);\n        return err;\n    }\n    ALOGV(\"%s: Read metadata from parcel\", __FUNCTION__);\n\n    int32_t size;\n    if ((err = parcel->readInt32(&size)) != OK) {\n        ALOGE(\"%s: Failed to read surface list size from parcel\", __FUNCTION__);\n        return err;\n    }\n    ALOGV(\"%s: Read surface list size = %d\", __FUNCTION__, size);\n\n    // Do not distinguish null arrays from 0-sized arrays.\n    for (int i = 0; i < size; ++i) {\n        // Parcel.writeParcelableArray\n        size_t len;\n        const char16_t* className = parcel->readString16Inplace(&len);\n        ALOGV(\"%s: Read surface class = %s\", __FUNCTION__,\n              className != NULL ? String8(className).string() : \"<null>\");\n\n        if (className == NULL) {\n            continue;\n        }\n\n        // Surface.writeToParcel\n        const char16_t* name = parcel->readString16Inplace(&len);\n        ALOGV(\"%s: Read surface name = %s\", __FUNCTION__,\n            name != NULL ? String8(name).string() : \"<null>\");\n        sp<IBinder> binder(parcel->readStrongBinder());\n        ALOGV(\"%s: Read surface binder = %p\",\n              __FUNCTION__, binder.get());\n\n        sp<Surface> surface;\n\n        if (binder != NULL) {\n            sp<IGraphicBufferProducer> gbp =\n                    interface_cast<IGraphicBufferProducer>(binder);\n            surface = new Surface(gbp);\n        }\n\n        mSurfaceList.push_back(surface);\n    }\n\n    int isReprocess = 0;\n    if ((err = parcel->readInt32(&isReprocess)) != OK) {\n        ALOGE(\"%s: Failed to read reprocessing from parcel\", __FUNCTION__);\n        return err;\n    }\n    mIsReprocess = (isReprocess != 0);\n\n    return OK;\n}\n\nstatus_t CaptureRequest::writeToParcel(Parcel* parcel) const {\n    if (parcel == NULL) {\n        ALOGE(\"%s: Null parcel\", __FUNCTION__);\n        return BAD_VALUE;\n    }\n\n    status_t err;\n\n    if ((err = mMetadata.writeToParcel(parcel)) != OK) {\n        return err;\n    }\n\n    int32_t size = static_cast<int32_t>(mSurfaceList.size());\n\n    // Send 0-sized arrays when it's empty. Do not send null arrays.\n    parcel->writeInt32(size);\n\n    for (int32_t i = 0; i < size; ++i) {\n        sp<Surface> surface = mSurfaceList[i];\n\n        sp<IBinder> binder;\n        if (surface != 0) {\n            binder = IInterface::asBinder(surface->getIGraphicBufferProducer());\n        }\n\n        // not sure if readParcelableArray does this, hard to tell from source\n        parcel->writeString16(String16(\"android.view.Surface\"));\n\n        // Surface.writeToParcel\n        parcel->writeString16(String16(\"unknown_name\"));\n        // Surface.nativeWriteToParcel\n        parcel->writeStrongBinder(binder);\n    }\n\n    parcel->writeInt32(mIsReprocess ? 1 : 0);\n\n    return OK;\n}\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/camera2/ICameraDeviceCallbacks.cpp",
    "content": "/*\n**\n** Copyright 2013, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n//#define LOG_NDEBUG 0\n#define LOG_TAG \"ICameraDeviceCallbacks\"\n#include <utils/Log.h>\n#include <stdint.h>\n#include <sys/types.h>\n\n#include <binder/Parcel.h>\n#include <gui/IGraphicBufferProducer.h>\n#include <gui/Surface.h>\n#include <utils/Mutex.h>\n\n#include <camera/camera2/ICameraDeviceCallbacks.h>\n#include \"camera/CameraMetadata.h\"\n#include \"camera/CaptureResult.h\"\n\nnamespace android {\n\nenum {\n    CAMERA_ERROR = IBinder::FIRST_CALL_TRANSACTION,\n    CAMERA_IDLE,\n    CAPTURE_STARTED,\n    RESULT_RECEIVED,\n    PREPARED\n};\n\nclass BpCameraDeviceCallbacks: public BpInterface<ICameraDeviceCallbacks>\n{\npublic:\n    BpCameraDeviceCallbacks(const sp<IBinder>& impl)\n        : BpInterface<ICameraDeviceCallbacks>(impl)\n    {\n    }\n\n    void onDeviceError(CameraErrorCode errorCode, const CaptureResultExtras& resultExtras)\n    {\n        ALOGV(\"onDeviceError\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceCallbacks::getInterfaceDescriptor());\n        data.writeInt32(static_cast<int32_t>(errorCode));\n        data.writeInt32(1); // to mark presence of CaptureResultExtras object\n        resultExtras.writeToParcel(&data);\n        remote()->transact(CAMERA_ERROR, data, &reply, IBinder::FLAG_ONEWAY);\n        data.writeNoException();\n    }\n\n    void onDeviceIdle()\n    {\n        ALOGV(\"onDeviceIdle\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceCallbacks::getInterfaceDescriptor());\n        remote()->transact(CAMERA_IDLE, data, &reply, IBinder::FLAG_ONEWAY);\n        data.writeNoException();\n    }\n\n    void onCaptureStarted(const CaptureResultExtras& result, int64_t timestamp)\n    {\n        ALOGV(\"onCaptureStarted\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceCallbacks::getInterfaceDescriptor());\n        data.writeInt32(1); // to mark presence of CaptureResultExtras object\n        result.writeToParcel(&data);\n        data.writeInt64(timestamp);\n        remote()->transact(CAPTURE_STARTED, data, &reply, IBinder::FLAG_ONEWAY);\n        data.writeNoException();\n    }\n\n    void onResultReceived(const CameraMetadata& metadata,\n            const CaptureResultExtras& resultExtras) {\n        ALOGV(\"onResultReceived\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceCallbacks::getInterfaceDescriptor());\n        data.writeInt32(1); // to mark presence of metadata object\n        metadata.writeToParcel(&data);\n        data.writeInt32(1); // to mark presence of CaptureResult object\n        resultExtras.writeToParcel(&data);\n        remote()->transact(RESULT_RECEIVED, data, &reply, IBinder::FLAG_ONEWAY);\n        data.writeNoException();\n    }\n\n    void onPrepared(int streamId)\n    {\n        ALOGV(\"onPrepared\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceCallbacks::getInterfaceDescriptor());\n        data.writeInt32(streamId);\n        remote()->transact(PREPARED, data, &reply, IBinder::FLAG_ONEWAY);\n        data.writeNoException();\n    }\n\n};\n\nIMPLEMENT_META_INTERFACE(CameraDeviceCallbacks,\n                         \"android.hardware.camera2.ICameraDeviceCallbacks\");\n\n// ----------------------------------------------------------------------\n\nstatus_t BnCameraDeviceCallbacks::onTransact(\n    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)\n{\n    ALOGV(\"onTransact - code = %d\", code);\n    switch(code) {\n        case CAMERA_ERROR: {\n            ALOGV(\"onDeviceError\");\n            CHECK_INTERFACE(ICameraDeviceCallbacks, data, reply);\n            CameraErrorCode errorCode =\n                    static_cast<CameraErrorCode>(data.readInt32());\n            CaptureResultExtras resultExtras;\n            if (data.readInt32() != 0) {\n                resultExtras.readFromParcel(const_cast<Parcel*>(&data));\n            } else {\n                ALOGE(\"No CaptureResultExtras object is present!\");\n            }\n            onDeviceError(errorCode, resultExtras);\n            data.readExceptionCode();\n            return NO_ERROR;\n        } break;\n        case CAMERA_IDLE: {\n            ALOGV(\"onDeviceIdle\");\n            CHECK_INTERFACE(ICameraDeviceCallbacks, data, reply);\n            onDeviceIdle();\n            data.readExceptionCode();\n            return NO_ERROR;\n        } break;\n        case CAPTURE_STARTED: {\n            ALOGV(\"onCaptureStarted\");\n            CHECK_INTERFACE(ICameraDeviceCallbacks, data, reply);\n            CaptureResultExtras result;\n            if (data.readInt32() != 0) {\n                result.readFromParcel(const_cast<Parcel*>(&data));\n            } else {\n                ALOGE(\"No CaptureResultExtras object is present in result!\");\n            }\n            int64_t timestamp = data.readInt64();\n            onCaptureStarted(result, timestamp);\n            data.readExceptionCode();\n            return NO_ERROR;\n        } break;\n        case RESULT_RECEIVED: {\n            ALOGV(\"onResultReceived\");\n            CHECK_INTERFACE(ICameraDeviceCallbacks, data, reply);\n            CameraMetadata metadata;\n            if (data.readInt32() != 0) {\n                metadata.readFromParcel(const_cast<Parcel*>(&data));\n            } else {\n                ALOGW(\"No metadata object is present in result\");\n            }\n            CaptureResultExtras resultExtras;\n            if (data.readInt32() != 0) {\n                resultExtras.readFromParcel(const_cast<Parcel*>(&data));\n            } else {\n                ALOGW(\"No capture result extras object is present in result\");\n            }\n            onResultReceived(metadata, resultExtras);\n            data.readExceptionCode();\n            return NO_ERROR;\n        } break;\n        case PREPARED: {\n            ALOGV(\"onPrepared\");\n            CHECK_INTERFACE(ICameraDeviceCallbacks, data, reply);\n            CaptureResultExtras result;\n            int streamId = data.readInt32();\n            onPrepared(streamId);\n            data.readExceptionCode();\n            return NO_ERROR;\n        } break;\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n\n// ----------------------------------------------------------------------------\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/camera2/ICameraDeviceUser.cpp",
    "content": "/*\n**\n** Copyright 2013, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n// #define LOG_NDEBUG 0\n#define LOG_TAG \"ICameraDeviceUser\"\n#include <utils/Log.h>\n#include <stdint.h>\n#include <sys/types.h>\n#include <binder/Parcel.h>\n#include <camera/camera2/ICameraDeviceUser.h>\n#include <gui/IGraphicBufferProducer.h>\n#include <gui/Surface.h>\n#include <camera/CameraMetadata.h>\n#include <camera/camera2/CaptureRequest.h>\n#include <camera/camera2/OutputConfiguration.h>\n\nnamespace android {\n\ntypedef Parcel::WritableBlob WritableBlob;\ntypedef Parcel::ReadableBlob ReadableBlob;\n\nenum {\n    DISCONNECT = IBinder::FIRST_CALL_TRANSACTION,\n    SUBMIT_REQUEST,\n    SUBMIT_REQUEST_LIST,\n    CANCEL_REQUEST,\n    BEGIN_CONFIGURE,\n    END_CONFIGURE,\n    DELETE_STREAM,\n    CREATE_STREAM,\n    CREATE_INPUT_STREAM,\n    GET_INPUT_SURFACE,\n    CREATE_DEFAULT_REQUEST,\n    GET_CAMERA_INFO,\n    WAIT_UNTIL_IDLE,\n    FLUSH,\n    PREPARE,\n    TEAR_DOWN,\n    PREPARE2\n};\n\nnamespace {\n    // Read empty strings without printing a false error message.\n    String16 readMaybeEmptyString16(const Parcel& parcel) {\n        size_t len;\n        const char16_t* str = parcel.readString16Inplace(&len);\n        if (str != NULL) {\n            return String16(str, len);\n        } else {\n            return String16();\n        }\n    }\n};\n\nclass BpCameraDeviceUser : public BpInterface<ICameraDeviceUser>\n{\npublic:\n    BpCameraDeviceUser(const sp<IBinder>& impl)\n        : BpInterface<ICameraDeviceUser>(impl)\n    {\n    }\n\n    // disconnect from camera service\n    void disconnect()\n    {\n        ALOGV(\"disconnect\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        remote()->transact(DISCONNECT, data, &reply);\n        reply.readExceptionCode();\n    }\n\n    virtual int submitRequest(sp<CaptureRequest> request, bool repeating,\n                              int64_t *lastFrameNumber)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n\n        // arg0 = CaptureRequest\n        if (request != 0) {\n            data.writeInt32(1);\n            request->writeToParcel(&data);\n        } else {\n            data.writeInt32(0);\n        }\n\n        // arg1 = streaming (bool)\n        data.writeInt32(repeating);\n\n        remote()->transact(SUBMIT_REQUEST, data, &reply);\n\n        reply.readExceptionCode();\n        status_t res = reply.readInt32();\n\n        status_t resFrameNumber = BAD_VALUE;\n        if (reply.readInt32() != 0) {\n            if (lastFrameNumber != NULL) {\n                resFrameNumber = reply.readInt64(lastFrameNumber);\n            }\n        }\n\n        if (res < 0 || (resFrameNumber != NO_ERROR)) {\n            res = FAILED_TRANSACTION;\n        }\n        return res;\n    }\n\n    virtual int submitRequestList(List<sp<CaptureRequest> > requestList, bool repeating,\n                                  int64_t *lastFrameNumber)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n\n        data.writeInt32(requestList.size());\n\n        for (List<sp<CaptureRequest> >::iterator it = requestList.begin();\n                it != requestList.end(); ++it) {\n            sp<CaptureRequest> request = *it;\n            if (request != 0) {\n                data.writeInt32(1);\n                if (request->writeToParcel(&data) != OK) {\n                    return BAD_VALUE;\n                }\n            } else {\n                data.writeInt32(0);\n            }\n        }\n\n        data.writeInt32(repeating);\n\n        remote()->transact(SUBMIT_REQUEST_LIST, data, &reply);\n\n        reply.readExceptionCode();\n        status_t res = reply.readInt32();\n\n        status_t resFrameNumber = BAD_VALUE;\n        if (reply.readInt32() != 0) {\n            if (lastFrameNumber != NULL) {\n                resFrameNumber = reply.readInt64(lastFrameNumber);\n            }\n        }\n        if (res < 0 || (resFrameNumber != NO_ERROR)) {\n            res = FAILED_TRANSACTION;\n        }\n        return res;\n    }\n\n    virtual status_t cancelRequest(int requestId, int64_t *lastFrameNumber)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        data.writeInt32(requestId);\n\n        remote()->transact(CANCEL_REQUEST, data, &reply);\n\n        reply.readExceptionCode();\n        status_t res = reply.readInt32();\n\n        status_t resFrameNumber = BAD_VALUE;\n        if (reply.readInt32() != 0) {\n            if (lastFrameNumber != NULL) {\n                resFrameNumber = reply.readInt64(lastFrameNumber);\n            }\n        }\n        if ((res != NO_ERROR) || (resFrameNumber != NO_ERROR)) {\n            res = FAILED_TRANSACTION;\n        }\n        return res;\n    }\n\n    virtual status_t beginConfigure()\n    {\n        ALOGV(\"beginConfigure\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        remote()->transact(BEGIN_CONFIGURE, data, &reply);\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\n    virtual status_t endConfigure(bool isConstrainedHighSpeed)\n    {\n        ALOGV(\"endConfigure\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        data.writeInt32(isConstrainedHighSpeed);\n\n        remote()->transact(END_CONFIGURE, data, &reply);\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\n    virtual status_t deleteStream(int streamId)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        data.writeInt32(streamId);\n\n        remote()->transact(DELETE_STREAM, data, &reply);\n\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\n    virtual status_t createStream(const OutputConfiguration& outputConfiguration)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        if (outputConfiguration.getGraphicBufferProducer() != NULL) {\n            data.writeInt32(1); // marker that OutputConfiguration is not null. Mimic aidl behavior\n            outputConfiguration.writeToParcel(data);\n        } else {\n            data.writeInt32(0);\n        }\n        remote()->transact(CREATE_STREAM, data, &reply);\n\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\n    virtual status_t createInputStream(int width, int height, int format)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        data.writeInt32(width);\n        data.writeInt32(height);\n        data.writeInt32(format);\n\n        remote()->transact(CREATE_INPUT_STREAM, data, &reply);\n\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\n    // get the buffer producer of the input stream\n    virtual status_t getInputBufferProducer(\n            sp<IGraphicBufferProducer> *producer) {\n        if (producer == NULL) {\n            return BAD_VALUE;\n        }\n\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n\n        remote()->transact(GET_INPUT_SURFACE, data, &reply);\n\n        reply.readExceptionCode();\n        status_t result = reply.readInt32() ;\n        if (result != OK) {\n            return result;\n        }\n\n        sp<IGraphicBufferProducer> bp = NULL;\n        if (reply.readInt32() != 0) {\n            String16 name = readMaybeEmptyString16(reply);\n            bp = interface_cast<IGraphicBufferProducer>(\n                    reply.readStrongBinder());\n        }\n\n        *producer = bp;\n\n        return *producer == NULL ? INVALID_OPERATION : OK;\n    }\n\n    // Create a request object from a template.\n    virtual status_t createDefaultRequest(int templateId,\n                                          /*out*/\n                                          CameraMetadata* request)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        data.writeInt32(templateId);\n        remote()->transact(CREATE_DEFAULT_REQUEST, data, &reply);\n\n        reply.readExceptionCode();\n        status_t result = reply.readInt32();\n\n        CameraMetadata out;\n        if (reply.readInt32() != 0) {\n            out.readFromParcel(&reply);\n        }\n\n        if (request != NULL) {\n            request->swap(out);\n        }\n        return result;\n    }\n\n\n    virtual status_t getCameraInfo(CameraMetadata* info)\n    {\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        remote()->transact(GET_CAMERA_INFO, data, &reply);\n\n        reply.readExceptionCode();\n        status_t result = reply.readInt32();\n\n        CameraMetadata out;\n        if (reply.readInt32() != 0) {\n            out.readFromParcel(&reply);\n        }\n\n        if (info != NULL) {\n            info->swap(out);\n        }\n\n        return result;\n    }\n\n    virtual status_t waitUntilIdle()\n    {\n        ALOGV(\"waitUntilIdle\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        remote()->transact(WAIT_UNTIL_IDLE, data, &reply);\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\n    virtual status_t flush(int64_t *lastFrameNumber)\n    {\n        ALOGV(\"flush\");\n        Parcel data, reply;\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        remote()->transact(FLUSH, data, &reply);\n        reply.readExceptionCode();\n        status_t res = reply.readInt32();\n\n        status_t resFrameNumber = BAD_VALUE;\n        if (reply.readInt32() != 0) {\n            if (lastFrameNumber != NULL) {\n                resFrameNumber = reply.readInt64(lastFrameNumber);\n            }\n        }\n        if ((res != NO_ERROR) || (resFrameNumber != NO_ERROR)) {\n            res = FAILED_TRANSACTION;\n        }\n        return res;\n    }\n\n    virtual status_t prepare(int streamId)\n    {\n        ALOGV(\"prepare\");\n        Parcel data, reply;\n\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        data.writeInt32(streamId);\n\n        remote()->transact(PREPARE, data, &reply);\n\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\n    virtual status_t prepare2(int maxCount, int streamId)\n    {\n        ALOGV(\"prepare2\");\n        Parcel data, reply;\n\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        data.writeInt32(maxCount);\n        data.writeInt32(streamId);\n\n        remote()->transact(PREPARE2, data, &reply);\n\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\n    virtual status_t tearDown(int streamId)\n    {\n        ALOGV(\"tearDown\");\n        Parcel data, reply;\n\n        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());\n        data.writeInt32(streamId);\n\n        remote()->transact(TEAR_DOWN, data, &reply);\n\n        reply.readExceptionCode();\n        return reply.readInt32();\n    }\n\nprivate:\n\n\n};\n\nIMPLEMENT_META_INTERFACE(CameraDeviceUser,\n                         \"android.hardware.camera2.ICameraDeviceUser\");\n\n// ----------------------------------------------------------------------\n\nstatus_t BnCameraDeviceUser::onTransact(\n    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)\n{\n    switch(code) {\n        case DISCONNECT: {\n            ALOGV(\"DISCONNECT\");\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            disconnect();\n            reply->writeNoException();\n            return NO_ERROR;\n        } break;\n        case SUBMIT_REQUEST: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n\n            // arg0 = request\n            sp<CaptureRequest> request;\n            if (data.readInt32() != 0) {\n                request = new CaptureRequest();\n                request->readFromParcel(const_cast<Parcel*>(&data));\n            }\n\n            // arg1 = streaming (bool)\n            bool repeating = data.readInt32();\n\n            // return code: requestId (int32)\n            reply->writeNoException();\n            int64_t lastFrameNumber = -1;\n            reply->writeInt32(submitRequest(request, repeating, &lastFrameNumber));\n            reply->writeInt32(1);\n            reply->writeInt64(lastFrameNumber);\n\n            return NO_ERROR;\n        } break;\n        case SUBMIT_REQUEST_LIST: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n\n            List<sp<CaptureRequest> > requestList;\n            int requestListSize = data.readInt32();\n            for (int i = 0; i < requestListSize; i++) {\n                if (data.readInt32() != 0) {\n                    sp<CaptureRequest> request = new CaptureRequest();\n                    if (request->readFromParcel(const_cast<Parcel*>(&data)) != OK) {\n                        return BAD_VALUE;\n                    }\n                    requestList.push_back(request);\n                } else {\n                    sp<CaptureRequest> request = 0;\n                    requestList.push_back(request);\n                    ALOGE(\"A request is missing. Sending in null request.\");\n                }\n            }\n\n            bool repeating = data.readInt32();\n\n            reply->writeNoException();\n            int64_t lastFrameNumber = -1;\n            reply->writeInt32(submitRequestList(requestList, repeating, &lastFrameNumber));\n            reply->writeInt32(1);\n            reply->writeInt64(lastFrameNumber);\n\n            return NO_ERROR;\n        } break;\n        case CANCEL_REQUEST: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            int requestId = data.readInt32();\n            reply->writeNoException();\n            int64_t lastFrameNumber = -1;\n            reply->writeInt32(cancelRequest(requestId, &lastFrameNumber));\n            reply->writeInt32(1);\n            reply->writeInt64(lastFrameNumber);\n            return NO_ERROR;\n        } break;\n        case DELETE_STREAM: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            int streamId = data.readInt32();\n            reply->writeNoException();\n            reply->writeInt32(deleteStream(streamId));\n            return NO_ERROR;\n        } break;\n        case CREATE_STREAM: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n\n            status_t ret = BAD_VALUE;\n            if (data.readInt32() != 0) {\n                OutputConfiguration outputConfiguration(data);\n                ret = createStream(outputConfiguration);\n            } else {\n                ALOGE(\"%s: cannot take an empty OutputConfiguration\", __FUNCTION__);\n            }\n\n            reply->writeNoException();\n            ALOGV(\"%s: CREATE_STREAM: write noException\", __FUNCTION__);\n            reply->writeInt32(ret);\n            ALOGV(\"%s: CREATE_STREAM: write ret = %d\", __FUNCTION__, ret);\n\n            return NO_ERROR;\n        } break;\n        case CREATE_INPUT_STREAM: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            int width, height, format;\n\n            width = data.readInt32();\n            height = data.readInt32();\n            format = data.readInt32();\n            status_t ret = createInputStream(width, height, format);\n\n            reply->writeNoException();\n            reply->writeInt32(ret);\n            return NO_ERROR;\n\n        } break;\n        case GET_INPUT_SURFACE: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n\n            sp<IGraphicBufferProducer> bp;\n            status_t ret = getInputBufferProducer(&bp);\n            sp<IBinder> b(IInterface::asBinder(ret == OK ? bp : NULL));\n\n            reply->writeNoException();\n            reply->writeInt32(ret);\n            reply->writeInt32(1);\n            reply->writeString16(String16(\"camera input\")); // name of surface\n            reply->writeStrongBinder(b);\n\n            return NO_ERROR;\n        } break;\n        case CREATE_DEFAULT_REQUEST: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n\n            int templateId = data.readInt32();\n\n            CameraMetadata request;\n            status_t ret;\n            ret = createDefaultRequest(templateId, &request);\n\n            reply->writeNoException();\n            reply->writeInt32(ret);\n\n            // out-variables are after exception and return value\n            reply->writeInt32(1); // to mark presence of metadata object\n            request.writeToParcel(const_cast<Parcel*>(reply));\n\n            return NO_ERROR;\n        } break;\n        case GET_CAMERA_INFO: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n\n            CameraMetadata info;\n            status_t ret;\n            ret = getCameraInfo(&info);\n\n            reply->writeNoException();\n            reply->writeInt32(ret);\n\n            // out-variables are after exception and return value\n            reply->writeInt32(1); // to mark presence of metadata object\n            info.writeToParcel(reply);\n\n            return NO_ERROR;\n        } break;\n        case WAIT_UNTIL_IDLE: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            reply->writeNoException();\n            reply->writeInt32(waitUntilIdle());\n            return NO_ERROR;\n        } break;\n        case FLUSH: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            reply->writeNoException();\n            int64_t lastFrameNumber = -1;\n            reply->writeInt32(flush(&lastFrameNumber));\n            reply->writeInt32(1);\n            reply->writeInt64(lastFrameNumber);\n            return NO_ERROR;\n        }\n        case BEGIN_CONFIGURE: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            reply->writeNoException();\n            reply->writeInt32(beginConfigure());\n            return NO_ERROR;\n        } break;\n        case END_CONFIGURE: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            bool isConstrainedHighSpeed = data.readInt32();\n            reply->writeNoException();\n            reply->writeInt32(endConfigure(isConstrainedHighSpeed));\n            return NO_ERROR;\n        } break;\n        case PREPARE: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            int streamId = data.readInt32();\n            reply->writeNoException();\n            reply->writeInt32(prepare(streamId));\n            return NO_ERROR;\n        } break;\n        case TEAR_DOWN: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            int streamId = data.readInt32();\n            reply->writeNoException();\n            reply->writeInt32(tearDown(streamId));\n            return NO_ERROR;\n        } break;\n        case PREPARE2: {\n            CHECK_INTERFACE(ICameraDeviceUser, data, reply);\n            int maxCount = data.readInt32();\n            int streamId = data.readInt32();\n            reply->writeNoException();\n            reply->writeInt32(prepare2(maxCount, streamId));\n            return NO_ERROR;\n        } break;\n        default:\n            return BBinder::onTransact(code, data, reply, flags);\n    }\n}\n\n// ----------------------------------------------------------------------------\n\n}; // namespace android\n"
  },
  {
    "path": "libshims/camera2/OutputConfiguration.cpp",
    "content": "/*\n**\n** Copyright 2015, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n#define LOG_TAG \"OutputConfiguration\"\n#include <utils/Log.h>\n\n#include <camera/camera2/OutputConfiguration.h>\n#include <binder/Parcel.h>\n\nnamespace android {\n\n\nconst int OutputConfiguration::INVALID_ROTATION = -1;\n\n// Read empty strings without printing a false error message.\nString16 OutputConfiguration::readMaybeEmptyString16(const Parcel& parcel) {\n    size_t len;\n    const char16_t* str = parcel.readString16Inplace(&len);\n    if (str != NULL) {\n        return String16(str, len);\n    } else {\n        return String16();\n    }\n}\n\nsp<IGraphicBufferProducer> OutputConfiguration::getGraphicBufferProducer() const {\n    return mGbp;\n}\n\nint OutputConfiguration::getRotation() const {\n    return mRotation;\n}\n\nOutputConfiguration::OutputConfiguration(const Parcel& parcel) {\n    status_t err;\n    int rotation = 0;\n    if ((err = parcel.readInt32(&rotation)) != OK) {\n        ALOGE(\"%s: Failed to read rotation from parcel\", __FUNCTION__);\n        mGbp = NULL;\n        mRotation = INVALID_ROTATION;\n        return;\n    }\n\n    String16 name = readMaybeEmptyString16(parcel);\n    const sp<IGraphicBufferProducer>& gbp =\n            interface_cast<IGraphicBufferProducer>(parcel.readStrongBinder());\n    mGbp = gbp;\n    mRotation = rotation;\n\n    ALOGV(\"%s: OutputConfiguration: bp = %p, name = %s\", __FUNCTION__,\n          gbp.get(), String8(name).string());\n}\n\nOutputConfiguration::OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation) {\n    mGbp = gbp;\n    mRotation = rotation;\n}\n\nstatus_t OutputConfiguration::writeToParcel(Parcel& parcel) const {\n\n    parcel.writeInt32(mRotation);\n    parcel.writeString16(String16(\"unknown_name\")); // name of surface\n    sp<IBinder> b(IInterface::asBinder(mGbp));\n    parcel.writeStrongBinder(b);\n\n    return OK;\n}\n\n}; // namespace android\n\n"
  },
  {
    "path": "libshims/include/camera/Camera.h",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_CAMERA_H\n#define ANDROID_HARDWARE_CAMERA_H\n\n#include <utils/Timers.h>\n#include <gui/IGraphicBufferProducer.h>\n#include <system/camera.h>\n#include <camera/ICameraClient.h>\n#include <camera/ICameraRecordingProxy.h>\n#include <camera/ICameraRecordingProxyListener.h>\n#include <camera/ICameraService.h>\n#include <camera/ICamera.h>\n#include <camera/CameraBase.h>\n\nnamespace android {\n\nclass Surface;\nclass String8;\nclass String16;\n\n// ref-counted object for callbacks\nclass CameraListener: virtual public RefBase\n{\npublic:\n    virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0;\n    virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr,\n                          camera_frame_metadata_t *metadata) = 0;\n    virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0;\n};\n\nclass Camera;\n\ntemplate <>\nstruct CameraTraits<Camera>\n{\n    typedef CameraListener        TCamListener;\n    typedef ICamera               TCamUser;\n    typedef ICameraClient         TCamCallbacks;\n    typedef status_t (ICameraService::*TCamConnectService)(const sp<ICameraClient>&,\n                                                           int, const String16&, int,\n                                                           /*out*/\n                                                           sp<ICamera>&);\n    static TCamConnectService     fnConnectService;\n};\n\n\nclass Camera :\n    public CameraBase<Camera>,\n    public BnCameraClient\n{\npublic:\n    enum {\n        USE_CALLING_UID = ICameraService::USE_CALLING_UID\n    };\n\n            // construct a camera client from an existing remote\n    static  sp<Camera>  create(const sp<ICamera>& camera);\n    static  sp<Camera>  connect(int cameraId,\n                                const String16& clientPackageName,\n                                int clientUid);\n\n    static  status_t  connectLegacy(int cameraId, int halVersion,\n                                     const String16& clientPackageName,\n                                     int clientUid, sp<Camera>& camera);\n\n            virtual     ~Camera();\n\n            status_t    reconnect();\n            status_t    lock();\n            status_t    unlock();\n\n            // pass the buffered IGraphicBufferProducer to the camera service\n            status_t    setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer);\n\n            // start preview mode, must call setPreviewTarget first\n            status_t    startPreview();\n\n            // stop preview mode\n            void        stopPreview();\n\n            // get preview state\n            bool        previewEnabled();\n\n            // start recording mode, must call setPreviewTarget first\n            status_t    startRecording();\n\n            // stop recording mode\n            void        stopRecording();\n\n            // get recording state\n            bool        recordingEnabled();\n\n            // release a recording frame\n            void        releaseRecordingFrame(const sp<IMemory>& mem);\n\n            // autoFocus - status returned from callback\n            status_t    autoFocus();\n\n            // cancel auto focus\n            status_t    cancelAutoFocus();\n\n            // take a picture - picture returned from callback\n            status_t    takePicture(int msgType);\n\n            // set preview/capture parameters - key/value pairs\n            status_t    setParameters(const String8& params);\n\n            // get preview/capture parameters - key/value pairs\n            String8     getParameters() const;\n\n            // send command to camera driver\n            status_t    sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);\n\n            // tell camera hal to store meta data or real YUV in video buffers.\n            status_t    storeMetaDataInBuffers(bool enabled);\n\n            void        setListener(const sp<CameraListener>& listener);\n            void        setRecordingProxyListener(const sp<ICameraRecordingProxyListener>& listener);\n\n            // Configure preview callbacks to app. Only one of the older\n            // callbacks or the callback surface can be active at the same time;\n            // enabling one will disable the other if active. Flags can be\n            // disabled by calling it with CAMERA_FRAME_CALLBACK_FLAG_NOOP, and\n            // Target by calling it with a NULL interface.\n            void        setPreviewCallbackFlags(int preview_callback_flag);\n            status_t    setPreviewCallbackTarget(\n                    const sp<IGraphicBufferProducer>& callbackProducer);\n\n            sp<ICameraRecordingProxy> getRecordingProxy();\n\n    // ICameraClient interface\n    virtual void        notifyCallback(int32_t msgType, int32_t ext, int32_t ext2);\n    virtual void        dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,\n                                     camera_frame_metadata_t *metadata);\n    virtual void        dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);\n\n    class RecordingProxy : public BnCameraRecordingProxy\n    {\n    public:\n        RecordingProxy(const sp<Camera>& camera);\n\n        // ICameraRecordingProxy interface\n        virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener);\n        virtual void stopRecording();\n        virtual void releaseRecordingFrame(const sp<IMemory>& mem);\n\n    private:\n        sp<Camera>         mCamera;\n    };\n\nprotected:\n                        Camera(int cameraId);\n                        Camera(const Camera&);\n                        Camera& operator=(const Camera);\n\n    sp<ICameraRecordingProxyListener>  mRecordingProxyListener;\n\n    friend class        CameraBase;\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/CameraBase.h",
    "content": "/*\n * Copyright (C) 2013 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_CAMERA_BASE_H\n#define ANDROID_HARDWARE_CAMERA_BASE_H\n\n#include <utils/Mutex.h>\n#include <camera/ICameraService.h>\n\nstruct camera_frame_metadata;\n\nnamespace android {\n\nstruct CameraInfo {\n    /**\n     * The direction that the camera faces to. It should be CAMERA_FACING_BACK\n     * or CAMERA_FACING_FRONT.\n     */\n    int facing;\n\n    /**\n     * The orientation of the camera image. The value is the angle that the\n     * camera image needs to be rotated clockwise so it shows correctly on the\n     * display in its natural orientation. It should be 0, 90, 180, or 270.\n     *\n     * For example, suppose a device has a naturally tall screen. The\n     * back-facing camera sensor is mounted in landscape. You are looking at\n     * the screen. If the top side of the camera sensor is aligned with the\n     * right edge of the screen in natural orientation, the value should be\n     * 90. If the top side of a front-facing camera sensor is aligned with the\n     * right of the screen, the value should be 270.\n     */\n    int orientation;\n};\n\ntemplate <typename TCam>\nstruct CameraTraits {\n};\n\ntemplate <typename TCam, typename TCamTraits = CameraTraits<TCam> >\nclass CameraBase : public IBinder::DeathRecipient\n{\npublic:\n    typedef typename TCamTraits::TCamListener       TCamListener;\n    typedef typename TCamTraits::TCamUser           TCamUser;\n    typedef typename TCamTraits::TCamCallbacks      TCamCallbacks;\n    typedef typename TCamTraits::TCamConnectService TCamConnectService;\n\n    static sp<TCam>      connect(int cameraId,\n                                 const String16& clientPackageName,\n                                 int clientUid);\n    virtual void         disconnect();\n\n    void                 setListener(const sp<TCamListener>& listener);\n\n    static int           getNumberOfCameras();\n\n    static status_t      getCameraInfo(int cameraId,\n                                       /*out*/\n                                       struct CameraInfo* cameraInfo);\n\n    static status_t      addServiceListener(\n                                    const sp<ICameraServiceListener>& listener);\n\n    static status_t      removeServiceListener(\n                                    const sp<ICameraServiceListener>& listener);\n\n    sp<TCamUser>         remote();\n\n    // Status is set to 'UNKNOWN_ERROR' after successful (re)connection\n    status_t             getStatus();\n\nprotected:\n    CameraBase(int cameraId);\n    virtual              ~CameraBase();\n\n    ////////////////////////////////////////////////////////\n    // TCamCallbacks implementation\n    ////////////////////////////////////////////////////////\n    virtual void         notifyCallback(int32_t msgType, int32_t ext,\n                                        int32_t ext2);\n\n    ////////////////////////////////////////////////////////\n    // Common instance variables\n    ////////////////////////////////////////////////////////\n    Mutex                            mLock;\n\n    virtual void                     binderDied(const wp<IBinder>& who);\n\n    // helper function to obtain camera service handle\n    static const sp<ICameraService>& getCameraService();\n\n    sp<TCamUser>                     mCamera;\n    status_t                         mStatus;\n\n    sp<TCamListener>                 mListener;\n\n    const int                        mCameraId;\n\n    typedef CameraBase<TCam>         CameraBaseT;\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/CameraMetadata.h",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_CLIENT_CAMERA2_CAMERAMETADATA_CPP\n#define ANDROID_CLIENT_CAMERA2_CAMERAMETADATA_CPP\n\n#include \"system/camera_metadata.h\"\n#include <utils/String8.h>\n#include <utils/Vector.h>\n\nnamespace android {\nclass Parcel;\n\n/**\n * A convenience wrapper around the C-based camera_metadata_t library.\n */\nclass CameraMetadata {\n  public:\n    /** Creates an empty object; best used when expecting to acquire contents\n     * from elsewhere */\n    CameraMetadata();\n    /** Creates an object with space for entryCapacity entries, with\n     * dataCapacity extra storage */\n    CameraMetadata(size_t entryCapacity, size_t dataCapacity = 10);\n\n    ~CameraMetadata();\n\n    /** Takes ownership of passed-in buffer */\n    CameraMetadata(camera_metadata_t *buffer);\n    /** Clones the metadata */\n    CameraMetadata(const CameraMetadata &other);\n\n    /**\n     * Assignment clones metadata buffer.\n     */\n    CameraMetadata &operator=(const CameraMetadata &other);\n    CameraMetadata &operator=(const camera_metadata_t *buffer);\n\n    /**\n     * Get reference to the underlying metadata buffer. Ownership remains with\n     * the CameraMetadata object, but non-const CameraMetadata methods will not\n     * work until unlock() is called. Note that the lock has nothing to do with\n     * thread-safety, it simply prevents the camera_metadata_t pointer returned\n     * here from being accidentally invalidated by CameraMetadata operations.\n     */\n    const camera_metadata_t* getAndLock() const;\n\n    /**\n     * Unlock the CameraMetadata for use again. After this unlock, the pointer\n     * given from getAndLock() may no longer be used. The pointer passed out\n     * from getAndLock must be provided to guarantee that the right object is\n     * being unlocked.\n     */\n    status_t unlock(const camera_metadata_t *buffer);\n\n    /**\n     * Release a raw metadata buffer to the caller. After this call,\n     * CameraMetadata no longer references the buffer, and the caller takes\n     * responsibility for freeing the raw metadata buffer (using\n     * free_camera_metadata()), or for handing it to another CameraMetadata\n     * instance.\n     */\n    camera_metadata_t* release();\n\n    /**\n     * Clear the metadata buffer and free all storage used by it\n     */\n    void clear();\n\n    /**\n     * Acquire a raw metadata buffer from the caller. After this call,\n     * the caller no longer owns the raw buffer, and must not free or manipulate it.\n     * If CameraMetadata already contains metadata, it is freed.\n     */\n    void acquire(camera_metadata_t* buffer);\n\n    /**\n     * Acquires raw buffer from other CameraMetadata object. After the call, the argument\n     * object no longer has any metadata.\n     */\n    void acquire(CameraMetadata &other);\n\n    /**\n     * Append metadata from another CameraMetadata object.\n     */\n    status_t append(const CameraMetadata &other);\n\n    /**\n     * Append metadata from a raw camera_metadata buffer\n     */\n    status_t append(const camera_metadata* other);\n\n    /**\n     * Number of metadata entries.\n     */\n    size_t entryCount() const;\n\n    /**\n     * Is the buffer empty (no entires)\n     */\n    bool isEmpty() const;\n\n    /**\n     * Sort metadata buffer for faster find\n     */\n    status_t sort();\n\n    /**\n     * Update metadata entry. Will create entry if it doesn't exist already, and\n     * will reallocate the buffer if insufficient space exists. Overloaded for\n     * the various types of valid data.\n     */\n    status_t update(uint32_t tag,\n            const uint8_t *data, size_t data_count);\n    status_t update(uint32_t tag,\n            const int32_t *data, size_t data_count);\n    status_t update(uint32_t tag,\n            const float *data, size_t data_count);\n    status_t update(uint32_t tag,\n            const int64_t *data, size_t data_count);\n    status_t update(uint32_t tag,\n            const double *data, size_t data_count);\n    status_t update(uint32_t tag,\n            const camera_metadata_rational_t *data, size_t data_count);\n    status_t update(uint32_t tag,\n            const String8 &string);\n\n    template<typename T>\n    status_t update(uint32_t tag, Vector<T> data) {\n        return update(tag, data.array(), data.size());\n    }\n\n    /**\n     * Check if a metadata entry exists for a given tag id\n     *\n     */\n    bool exists(uint32_t tag) const;\n\n    /**\n     * Get metadata entry by tag id\n     */\n    camera_metadata_entry find(uint32_t tag);\n\n    /**\n     * Get metadata entry by tag id, with no editing\n     */\n    camera_metadata_ro_entry find(uint32_t tag) const;\n\n    /**\n     * Delete metadata entry by tag\n     */\n    status_t erase(uint32_t tag);\n\n    /**\n     * Swap the underlying camera metadata between this and the other\n     * metadata object.\n     */\n    void swap(CameraMetadata &other);\n\n    /**\n     * Dump contents into FD for debugging. The verbosity levels are\n     * 0: Tag entry information only, no data values\n     * 1: Level 0 plus at most 16 data values per entry\n     * 2: All information\n     *\n     * The indentation parameter sets the number of spaces to add to the start\n     * each line of output.\n     */\n    void dump(int fd, int verbosity = 1, int indentation = 0) const;\n\n    /**\n     * Serialization over Binder\n     */\n\n    // Metadata object is unchanged when reading from parcel fails.\n    status_t readFromParcel(Parcel *parcel);\n    status_t writeToParcel(Parcel *parcel) const;\n\n    /**\n      * Caller becomes the owner of the new metadata\n      * 'const Parcel' doesnt prevent us from calling the read functions.\n      *  which is interesting since it changes the internal state\n      *\n      * NULL can be returned when no metadata was sent, OR if there was an issue\n      * unpacking the serialized data (i.e. bad parcel or invalid structure).\n      */\n    static status_t readFromParcel(const Parcel &parcel,\n                                   camera_metadata_t** out);\n    /**\n      * Caller retains ownership of metadata\n      * - Write 2 (int32 + blob) args in the current position\n      */\n    static status_t writeToParcel(Parcel &parcel,\n                                  const camera_metadata_t* metadata);\n\n  private:\n    camera_metadata_t *mBuffer;\n    mutable bool       mLocked;\n\n    /**\n     * Check if tag has a given type\n     */\n    status_t checkType(uint32_t tag, uint8_t expectedType);\n\n    /**\n     * Base update entry method\n     */\n    status_t updateImpl(uint32_t tag, const void *data, size_t data_count);\n\n    /**\n     * Resize metadata buffer if needed by reallocating it and copying it over.\n     */\n    status_t resizeIfNeeded(size_t extraEntries, size_t extraData);\n\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/CameraParameters.h",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_CAMERA_PARAMETERS_H\n#define ANDROID_HARDWARE_CAMERA_PARAMETERS_H\n\n#include <utils/KeyedVector.h>\n#include <utils/String8.h>\n#include <camera/CameraParametersExtra.h>\n\nnamespace android {\n\nstruct Size {\n    int width;\n    int height;\n\n    Size() {\n        width = 0;\n        height = 0;\n    }\n\n    Size(int w, int h) {\n        width = w;\n        height = h;\n    }\n};\n\nclass CameraParameters\n{\npublic:\n    CameraParameters();\n    CameraParameters(const String8 &params) { unflatten(params); }\n    ~CameraParameters();\n\n    String8 flatten() const;\n    void unflatten(const String8 &params);\n\n    void set(const char *key, const char *value);\n    void set(const char *key, int value);\n    void setFloat(const char *key, float value);\n    const char *get(const char *key) const;\n    int getInt(const char *key) const;\n    float getFloat(const char *key) const;\n\n    void remove(const char *key);\n\n    void setPreviewSize(int width, int height);\n    void getPreviewSize(int *width, int *height) const;\n    void getSupportedPreviewSizes(Vector<Size> &sizes) const;\n\n    // Set the dimensions in pixels to the given width and height\n    // for video frames. The given width and height must be one\n    // of the supported dimensions returned from\n    // getSupportedVideoSizes(). Must not be called if\n    // getSupportedVideoSizes() returns an empty Vector of Size.\n    void setVideoSize(int width, int height);\n    // Retrieve the current dimensions (width and height)\n    // in pixels for video frames, which must be one of the\n    // supported dimensions returned from getSupportedVideoSizes().\n    // Must not be called if getSupportedVideoSizes() returns an\n    // empty Vector of Size.\n    void getVideoSize(int *width, int *height) const;\n    // Retrieve a Vector of supported dimensions (width and height)\n    // in pixels for video frames. If sizes returned from the method\n    // is empty, the camera does not support calls to setVideoSize()\n    // or getVideoSize(). In adddition, it also indicates that\n    // the camera only has a single output, and does not have\n    // separate output for video frames and preview frame.\n    void getSupportedVideoSizes(Vector<Size> &sizes) const;\n    // Retrieve the preferred preview size (width and height) in pixels\n    // for video recording. The given width and height must be one of\n    // supported preview sizes returned from getSupportedPreviewSizes().\n    // Must not be called if getSupportedVideoSizes() returns an empty\n    // Vector of Size. If getSupportedVideoSizes() returns an empty\n    // Vector of Size, the width and height returned from this method\n    // is invalid, and is \"-1x-1\".\n    void getPreferredPreviewSizeForVideo(int *width, int *height) const;\n\n    void setPreviewFrameRate(int fps);\n    int getPreviewFrameRate() const;\n    void getPreviewFpsRange(int *min_fps, int *max_fps) const;\n    void setPreviewFormat(const char *format);\n    const char *getPreviewFormat() const;\n    void setPictureSize(int width, int height);\n    void getPictureSize(int *width, int *height) const;\n    void getSupportedPictureSizes(Vector<Size> &sizes) const;\n    void setPictureFormat(const char *format);\n    const char *getPictureFormat() const;\n\n    void dump() const;\n    status_t dump(int fd, const Vector<String16>& args) const;\n\n    /**\n     * Returns a Vector containing the supported preview formats\n     * as enums given in graphics.h.\n     */\n    void getSupportedPreviewFormats(Vector<int>& formats) const;\n\n    // Returns true if no keys are present\n    bool isEmpty() const;\n\n    // Parameter keys to communicate between camera application and driver.\n    // The access (read/write, read only, or write only) is viewed from the\n    // perspective of applications, not driver.\n\n    // Preview frame size in pixels (width x height).\n    // Example value: \"480x320\". Read/Write.\n    static const char KEY_PREVIEW_SIZE[];\n    // Supported preview frame sizes in pixels.\n    // Example value: \"800x600,480x320\". Read only.\n    static const char KEY_SUPPORTED_PREVIEW_SIZES[];\n    // The current minimum and maximum preview fps. This controls the rate of\n    // preview frames received (CAMERA_MSG_PREVIEW_FRAME). The minimum and\n    // maximum fps must be one of the elements from\n    // KEY_SUPPORTED_PREVIEW_FPS_RANGE parameter.\n    // Example value: \"10500,26623\"\n    static const char KEY_PREVIEW_FPS_RANGE[];\n    // The supported preview fps (frame-per-second) ranges. Each range contains\n    // a minimum fps and maximum fps. If minimum fps equals to maximum fps, the\n    // camera outputs frames in fixed frame rate. If not, the camera outputs\n    // frames in auto frame rate. The actual frame rate fluctuates between the\n    // minimum and the maximum. The list has at least one element. The list is\n    // sorted from small to large (first by maximum fps and then minimum fps).\n    // Example value: \"(10500,26623),(15000,26623),(30000,30000)\"\n    static const char KEY_SUPPORTED_PREVIEW_FPS_RANGE[];\n    // The image format for preview frames. See CAMERA_MSG_PREVIEW_FRAME in\n    // frameworks/av/include/camera/Camera.h. The default is\n    // PIXEL_FORMAT_YUV420SP. Example value: \"yuv420sp\" or PIXEL_FORMAT_XXX\n    // constants. Read/write.\n    static const char KEY_PREVIEW_FORMAT[];\n    // Supported image formats for preview frames.\n    // Example value: \"yuv420sp,yuv422i-yuyv\". Read only.\n    static const char KEY_SUPPORTED_PREVIEW_FORMATS[];\n    // Number of preview frames per second. This is the target frame rate. The\n    // actual frame rate depends on the driver.\n    // Example value: \"15\". Read/write.\n    static const char KEY_PREVIEW_FRAME_RATE[];\n    // Supported number of preview frames per second.\n    // Example value: \"24,15,10\". Read.\n    static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[];\n    // The dimensions for captured pictures in pixels (width x height).\n    // Example value: \"1024x768\". Read/write.\n    static const char KEY_PICTURE_SIZE[];\n    // Supported dimensions for captured pictures in pixels.\n    // Example value: \"2048x1536,1024x768\". Read only.\n    static const char KEY_SUPPORTED_PICTURE_SIZES[];\n    // The image format for captured pictures. See CAMERA_MSG_COMPRESSED_IMAGE\n    // in frameworks/base/include/camera/Camera.h.\n    // Example value: \"jpeg\" or PIXEL_FORMAT_XXX constants. Read/write.\n    static const char KEY_PICTURE_FORMAT[];\n    // Supported image formats for captured pictures.\n    // Example value: \"jpeg,rgb565\". Read only.\n    static const char KEY_SUPPORTED_PICTURE_FORMATS[];\n    // The width (in pixels) of EXIF thumbnail in Jpeg picture.\n    // Example value: \"512\". Read/write.\n    static const char KEY_JPEG_THUMBNAIL_WIDTH[];\n    // The height (in pixels) of EXIF thumbnail in Jpeg picture.\n    // Example value: \"384\". Read/write.\n    static const char KEY_JPEG_THUMBNAIL_HEIGHT[];\n    // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail\n    // in EXIF.\n    // Example value: \"512x384,320x240,0x0\". Read only.\n    static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];\n    // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,\n    // with 100 being the best.\n    // Example value: \"90\". Read/write.\n    static const char KEY_JPEG_THUMBNAIL_QUALITY[];\n    // Jpeg quality of captured picture. The range is 1 to 100, with 100 being\n    // the best.\n    // Example value: \"90\". Read/write.\n    static const char KEY_JPEG_QUALITY[];\n    // The rotation angle in degrees relative to the orientation of the camera.\n    // This affects the pictures returned from CAMERA_MSG_COMPRESSED_IMAGE. The\n    // camera driver may set orientation in the EXIF header without rotating the\n    // picture. Or the driver may rotate the picture and the EXIF thumbnail. If\n    // the Jpeg picture is rotated, the orientation in the EXIF header will be\n    // missing or 1 (row #0 is top and column #0 is left side).\n    //\n    // Note that the JPEG pictures of front-facing cameras are not mirrored\n    // as in preview display.\n    //\n    // For example, suppose the natural orientation of the device is portrait.\n    // The device is rotated 270 degrees clockwise, so the device orientation is\n    // 270. Suppose a back-facing camera sensor is mounted in landscape and the\n    // top side of the camera sensor is aligned with the right edge of the\n    // display in natural orientation. So the camera orientation is 90. The\n    // rotation should be set to 0 (270 + 90).\n    //\n    // Example value: \"0\" or \"90\" or \"180\" or \"270\". Write only.\n    static const char KEY_ROTATION[];\n    // GPS latitude coordinate. GPSLatitude and GPSLatitudeRef will be stored in\n    // JPEG EXIF header.\n    // Example value: \"25.032146\" or \"-33.462809\". Write only.\n    static const char KEY_GPS_LATITUDE[];\n    // GPS longitude coordinate. GPSLongitude and GPSLongitudeRef will be stored\n    // in JPEG EXIF header.\n    // Example value: \"121.564448\" or \"-70.660286\". Write only.\n    static const char KEY_GPS_LONGITUDE[];\n    // GPS altitude. GPSAltitude and GPSAltitudeRef will be stored in JPEG EXIF\n    // header.\n    // Example value: \"21.0\" or \"-5\". Write only.\n    static const char KEY_GPS_ALTITUDE[];\n    // GPS timestamp (UTC in seconds since January 1, 1970). This should be\n    // stored in JPEG EXIF header.\n    // Example value: \"1251192757\". Write only.\n    static const char KEY_GPS_TIMESTAMP[];\n    // GPS Processing Method\n    // Example value: \"GPS\" or \"NETWORK\". Write only.\n    static const char KEY_GPS_PROCESSING_METHOD[];\n    // Current white balance setting.\n    // Example value: \"auto\" or WHITE_BALANCE_XXX constants. Read/write.\n    static const char KEY_WHITE_BALANCE[];\n    // Supported white balance settings.\n    // Example value: \"auto,incandescent,daylight\". Read only.\n    static const char KEY_SUPPORTED_WHITE_BALANCE[];\n    // Current color effect setting.\n    // Example value: \"none\" or EFFECT_XXX constants. Read/write.\n    static const char KEY_EFFECT[];\n    // Supported color effect settings.\n    // Example value: \"none,mono,sepia\". Read only.\n    static const char KEY_SUPPORTED_EFFECTS[];\n    // Current antibanding setting.\n    // Example value: \"auto\" or ANTIBANDING_XXX constants. Read/write.\n    static const char KEY_ANTIBANDING[];\n    // Supported antibanding settings.\n    // Example value: \"auto,50hz,60hz,off\". Read only.\n    static const char KEY_SUPPORTED_ANTIBANDING[];\n    // Current scene mode.\n    // Example value: \"auto\" or SCENE_MODE_XXX constants. Read/write.\n    static const char KEY_SCENE_MODE[];\n    // Supported scene mode settings.\n    // Example value: \"auto,night,fireworks\". Read only.\n    static const char KEY_SUPPORTED_SCENE_MODES[];\n    // Current flash mode.\n    // Example value: \"auto\" or FLASH_MODE_XXX constants. Read/write.\n    static const char KEY_FLASH_MODE[];\n    // Supported flash modes.\n    // Example value: \"auto,on,off\". Read only.\n    static const char KEY_SUPPORTED_FLASH_MODES[];\n    // Current focus mode. This will not be empty. Applications should call\n    // CameraHardwareInterface.autoFocus to start the focus if focus mode is\n    // FOCUS_MODE_AUTO or FOCUS_MODE_MACRO.\n    // Example value: \"auto\" or FOCUS_MODE_XXX constants. Read/write.\n    static const char KEY_FOCUS_MODE[];\n    // Supported focus modes.\n    // Example value: \"auto,macro,fixed\". Read only.\n    static const char KEY_SUPPORTED_FOCUS_MODES[];\n    // The maximum number of focus areas supported. This is the maximum length\n    // of KEY_FOCUS_AREAS.\n    // Example value: \"0\" or \"2\". Read only.\n    static const char KEY_MAX_NUM_FOCUS_AREAS[];\n    // Current focus areas.\n    //\n    // Before accessing this parameter, apps should check\n    // KEY_MAX_NUM_FOCUS_AREAS first to know the maximum number of focus areas\n    // first. If the value is 0, focus area is not supported.\n    //\n    // Each focus area is a five-element int array. The first four elements are\n    // the rectangle of the area (left, top, right, bottom). The direction is\n    // relative to the sensor orientation, that is, what the sensor sees. The\n    // direction is not affected by the rotation or mirroring of\n    // CAMERA_CMD_SET_DISPLAY_ORIENTATION. Coordinates range from -1000 to 1000.\n    // (-1000,-1000) is the upper left point. (1000, 1000) is the lower right\n    // point. The width and height of focus areas cannot be 0 or negative.\n    //\n    // The fifth element is the weight. Values for weight must range from 1 to\n    // 1000.  The weight should be interpreted as a per-pixel weight - all\n    // pixels in the area have the specified weight. This means a small area\n    // with the same weight as a larger area will have less influence on the\n    // focusing than the larger area. Focus areas can partially overlap and the\n    // driver will add the weights in the overlap region.\n    //\n    // A special case of single focus area (0,0,0,0,0) means driver to decide\n    // the focus area. For example, the driver may use more signals to decide\n    // focus areas and change them dynamically. Apps can set (0,0,0,0,0) if they\n    // want the driver to decide focus areas.\n    //\n    // Focus areas are relative to the current field of view (KEY_ZOOM). No\n    // matter what the zoom level is, (-1000,-1000) represents the top of the\n    // currently visible camera frame. The focus area cannot be set to be\n    // outside the current field of view, even when using zoom.\n    //\n    // Focus area only has effect if the current focus mode is FOCUS_MODE_AUTO,\n    // FOCUS_MODE_MACRO, FOCUS_MODE_CONTINUOUS_VIDEO, or\n    // FOCUS_MODE_CONTINUOUS_PICTURE.\n    // Example value: \"(-10,-10,0,0,300),(0,0,10,10,700)\". Read/write.\n    static const char KEY_FOCUS_AREAS[];\n    // Focal length in millimeter.\n    // Example value: \"4.31\". Read only.\n    static const char KEY_FOCAL_LENGTH[];\n    // Horizontal angle of view in degrees.\n    // Example value: \"54.8\". Read only.\n    static const char KEY_HORIZONTAL_VIEW_ANGLE[];\n    // Vertical angle of view in degrees.\n    // Example value: \"42.5\". Read only.\n    static const char KEY_VERTICAL_VIEW_ANGLE[];\n    // Exposure compensation index. 0 means exposure is not adjusted.\n    // Example value: \"-5\" or \"5\". Read/write.\n    static const char KEY_EXPOSURE_COMPENSATION[];\n    // The maximum exposure compensation index (>=0).\n    // Example value: \"6\". Read only.\n    static const char KEY_MAX_EXPOSURE_COMPENSATION[];\n    // The minimum exposure compensation index (<=0).\n    // Example value: \"-6\". Read only.\n    static const char KEY_MIN_EXPOSURE_COMPENSATION[];\n    // The exposure compensation step. Exposure compensation index multiply by\n    // step eqals to EV. Ex: if exposure compensation index is -6 and step is\n    // 0.3333, EV is -2.\n    // Example value: \"0.333333333\" or \"0.5\". Read only.\n    static const char KEY_EXPOSURE_COMPENSATION_STEP[];\n    // The state of the auto-exposure lock. \"true\" means that\n    // auto-exposure is locked to its current value and will not\n    // change. \"false\" means the auto-exposure routine is free to\n    // change exposure values. If auto-exposure is already locked,\n    // setting this to true again has no effect (the driver will not\n    // recalculate exposure values). Changing exposure compensation\n    // settings will still affect the exposure settings while\n    // auto-exposure is locked. Stopping preview or taking a still\n    // image will not change the lock. In conjunction with\n    // exposure compensation, this allows for capturing multi-exposure\n    // brackets with known relative exposure values. Locking\n    // auto-exposure after open but before the first call to\n    // startPreview may result in severely over- or under-exposed\n    // images.  The driver will not change the AE lock after\n    // auto-focus completes.\n    static const char KEY_AUTO_EXPOSURE_LOCK[];\n    // Whether locking the auto-exposure is supported. \"true\" means it is, and\n    // \"false\" or this key not existing means it is not supported.\n    static const char KEY_AUTO_EXPOSURE_LOCK_SUPPORTED[];\n    // The state of the auto-white balance lock. \"true\" means that\n    // auto-white balance is locked to its current value and will not\n    // change. \"false\" means the auto-white balance routine is free to\n    // change white balance values. If auto-white balance is already\n    // locked, setting this to true again has no effect (the driver\n    // will not recalculate white balance values). Stopping preview or\n    // taking a still image will not change the lock. In conjunction\n    // with exposure compensation, this allows for capturing\n    // multi-exposure brackets with fixed white balance. Locking\n    // auto-white balance after open but before the first call to\n    // startPreview may result in severely incorrect color.  The\n    // driver will not change the AWB lock after auto-focus\n    // completes.\n    static const char KEY_AUTO_WHITEBALANCE_LOCK[];\n    // Whether locking the auto-white balance is supported. \"true\"\n    // means it is, and \"false\" or this key not existing means it is\n    // not supported.\n    static const char KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED[];\n\n    // The maximum number of metering areas supported. This is the maximum\n    // length of KEY_METERING_AREAS.\n    // Example value: \"0\" or \"2\". Read only.\n    static const char KEY_MAX_NUM_METERING_AREAS[];\n    // Current metering areas. Camera driver uses these areas to decide\n    // exposure.\n    //\n    // Before accessing this parameter, apps should check\n    // KEY_MAX_NUM_METERING_AREAS first to know the maximum number of metering\n    // areas first. If the value is 0, metering area is not supported.\n    //\n    // Each metering area is a rectangle with specified weight. The direction is\n    // relative to the sensor orientation, that is, what the sensor sees. The\n    // direction is not affected by the rotation or mirroring of\n    // CAMERA_CMD_SET_DISPLAY_ORIENTATION. Coordinates of the rectangle range\n    // from -1000 to 1000. (-1000, -1000) is the upper left point. (1000, 1000)\n    // is the lower right point. The width and height of metering areas cannot\n    // be 0 or negative.\n    //\n    // The fifth element is the weight. Values for weight must range from 1 to\n    // 1000.  The weight should be interpreted as a per-pixel weight - all\n    // pixels in the area have the specified weight. This means a small area\n    // with the same weight as a larger area will have less influence on the\n    // metering than the larger area. Metering areas can partially overlap and\n    // the driver will add the weights in the overlap region.\n    //\n    // A special case of all-zero single metering area means driver to decide\n    // the metering area. For example, the driver may use more signals to decide\n    // metering areas and change them dynamically. Apps can set all-zero if they\n    // want the driver to decide metering areas.\n    //\n    // Metering areas are relative to the current field of view (KEY_ZOOM).\n    // No matter what the zoom level is, (-1000,-1000) represents the top of the\n    // currently visible camera frame. The metering area cannot be set to be\n    // outside the current field of view, even when using zoom.\n    //\n    // No matter what metering areas are, the final exposure are compensated\n    // by KEY_EXPOSURE_COMPENSATION.\n    // Example value: \"(-10,-10,0,0,300),(0,0,10,10,700)\". Read/write.\n    static const char KEY_METERING_AREAS[];\n    // Current zoom value.\n    // Example value: \"0\" or \"6\". Read/write.\n    static const char KEY_ZOOM[];\n    // Maximum zoom value.\n    // Example value: \"6\". Read only.\n    static const char KEY_MAX_ZOOM[];\n    // The zoom ratios of all zoom values. The zoom ratio is in 1/100\n    // increments. Ex: a zoom of 3.2x is returned as 320. The number of list\n    // elements is KEY_MAX_ZOOM + 1. The first element is always 100. The last\n    // element is the zoom ratio of zoom value KEY_MAX_ZOOM.\n    // Example value: \"100,150,200,250,300,350,400\". Read only.\n    static const char KEY_ZOOM_RATIOS[];\n    // Whether zoom is supported. Zoom is supported if the value is \"true\". Zoom\n    // is not supported if the value is not \"true\" or the key does not exist.\n    // Example value: \"true\". Read only.\n    static const char KEY_ZOOM_SUPPORTED[];\n    // Whether if smooth zoom is supported. Smooth zoom is supported if the\n    // value is \"true\". It is not supported if the value is not \"true\" or the\n    // key does not exist.\n    // See CAMERA_CMD_START_SMOOTH_ZOOM, CAMERA_CMD_STOP_SMOOTH_ZOOM, and\n    // CAMERA_MSG_ZOOM in frameworks/base/include/camera/Camera.h.\n    // Example value: \"true\". Read only.\n    static const char KEY_SMOOTH_ZOOM_SUPPORTED[];\n\n    // The distances (in meters) from the camera to where an object appears to\n    // be in focus. The object is sharpest at the optimal focus distance. The\n    // depth of field is the far focus distance minus near focus distance.\n    //\n    // Focus distances may change after starting auto focus, canceling auto\n    // focus, or starting the preview. Applications can read this anytime to get\n    // the latest focus distances. If the focus mode is FOCUS_MODE_CONTINUOUS,\n    // focus distances may change from time to time.\n    //\n    // This is intended to estimate the distance between the camera and the\n    // subject. After autofocus, the subject distance may be within near and far\n    // focus distance. However, the precision depends on the camera hardware,\n    // autofocus algorithm, the focus area, and the scene. The error can be\n    // large and it should be only used as a reference.\n    //\n    // Far focus distance > optimal focus distance > near focus distance. If\n    // the far focus distance is infinity, the value should be \"Infinity\" (case\n    // sensitive). The format is three float values separated by commas. The\n    // first is near focus distance. The second is optimal focus distance. The\n    // third is far focus distance.\n    // Example value: \"0.95,1.9,Infinity\" or \"0.049,0.05,0.051\". Read only.\n    static const char KEY_FOCUS_DISTANCES[];\n\n    // The current dimensions in pixels (width x height) for video frames.\n    // The width and height must be one of the supported sizes retrieved\n    // via KEY_SUPPORTED_VIDEO_SIZES.\n    // Example value: \"1280x720\". Read/write.\n    static const char KEY_VIDEO_SIZE[];\n    // A list of the supported dimensions in pixels (width x height)\n    // for video frames. See CAMERA_MSG_VIDEO_FRAME for details in\n    // frameworks/base/include/camera/Camera.h.\n    // Example: \"176x144,1280x720\". Read only.\n    static const char KEY_SUPPORTED_VIDEO_SIZES[];\n\n    // The maximum number of detected faces supported by hardware face\n    // detection. If the value is 0, hardware face detection is not supported.\n    // Example: \"5\". Read only\n    static const char KEY_MAX_NUM_DETECTED_FACES_HW[];\n\n    // The maximum number of detected faces supported by software face\n    // detection. If the value is 0, software face detection is not supported.\n    // Example: \"5\". Read only\n    static const char KEY_MAX_NUM_DETECTED_FACES_SW[];\n\n    // Preferred preview frame size in pixels for video recording.\n    // The width and height must be one of the supported sizes retrieved\n    // via KEY_SUPPORTED_PREVIEW_SIZES. This key can be used only when\n    // getSupportedVideoSizes() does not return an empty Vector of Size.\n    // Camcorder applications are recommended to set the preview size\n    // to a value that is not larger than the preferred preview size.\n    // In other words, the product of the width and height of the\n    // preview size should not be larger than that of the preferred\n    // preview size. In addition, we recommend to choos a preview size\n    // that has the same aspect ratio as the resolution of video to be\n    // recorded.\n    // Example value: \"800x600\". Read only.\n    static const char KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[];\n\n    // The image format for video frames. See CAMERA_MSG_VIDEO_FRAME in\n    // frameworks/base/include/camera/Camera.h.\n    // Example value: \"yuv420sp\" or PIXEL_FORMAT_XXX constants. Read only.\n    static const char KEY_VIDEO_FRAME_FORMAT[];\n\n    // Sets the hint of the recording mode. If this is true, MediaRecorder.start\n    // may be faster or has less glitches. This should be called before starting\n    // the preview for the best result. But it is allowed to change the hint\n    // while the preview is active. The default value is false.\n    //\n    // The apps can still call Camera.takePicture when the hint is true. The\n    // apps can call MediaRecorder.start when the hint is false. But the\n    // performance may be worse.\n    // Example value: \"true\" or \"false\". Read/write.\n    static const char KEY_RECORDING_HINT[];\n\n    // Returns true if video snapshot is supported. That is, applications\n    // can call Camera.takePicture during recording. Applications do not need to\n    // call Camera.startPreview after taking a picture. The preview will be\n    // still active. Other than that, taking a picture during recording is\n    // identical to taking a picture normally. All settings and methods related\n    // to takePicture work identically. Ex: KEY_PICTURE_SIZE,\n    // KEY_SUPPORTED_PICTURE_SIZES, KEY_JPEG_QUALITY, KEY_ROTATION, and etc.\n    // The picture will have an EXIF header. FLASH_MODE_AUTO and FLASH_MODE_ON\n    // also still work, but the video will record the flash.\n    //\n    // Applications can set shutter callback as null to avoid the shutter\n    // sound. It is also recommended to set raw picture and post view callbacks\n    // to null to avoid the interrupt of preview display.\n    //\n    // Field-of-view of the recorded video may be different from that of the\n    // captured pictures.\n    // Example value: \"true\" or \"false\". Read only.\n    static const char KEY_VIDEO_SNAPSHOT_SUPPORTED[];\n\n    // The state of the video stabilization. If set to true, both the\n    // preview stream and the recorded video stream are stabilized by\n    // the camera. Only valid to set if KEY_VIDEO_STABILIZATION_SUPPORTED is\n    // set to true.\n    //\n    // The value of this key can be changed any time the camera is\n    // open. If preview or recording is active, it is acceptable for\n    // there to be a slight video glitch when video stabilization is\n    // toggled on and off.\n    //\n    // This only stabilizes video streams (between-frames stabilization), and\n    // has no effect on still image capture.\n    static const char KEY_VIDEO_STABILIZATION[];\n\n    // Returns true if video stabilization is supported. That is, applications\n    // can set KEY_VIDEO_STABILIZATION to true and have a stabilized preview\n    // stream and record stabilized videos.\n    static const char KEY_VIDEO_STABILIZATION_SUPPORTED[];\n\n    // Supported modes for special effects with light.\n    // Example values: \"lowlight,hdr\".\n    static const char KEY_LIGHTFX[];\n\n    // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.\n    static const char TRUE[];\n    static const char FALSE[];\n\n    // Value for KEY_FOCUS_DISTANCES.\n    static const char FOCUS_DISTANCE_INFINITY[];\n\n    // Values for white balance settings.\n    static const char WHITE_BALANCE_AUTO[];\n    static const char WHITE_BALANCE_INCANDESCENT[];\n    static const char WHITE_BALANCE_FLUORESCENT[];\n    static const char WHITE_BALANCE_WARM_FLUORESCENT[];\n    static const char WHITE_BALANCE_DAYLIGHT[];\n    static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[];\n    static const char WHITE_BALANCE_TWILIGHT[];\n    static const char WHITE_BALANCE_SHADE[];\n    static const char WHITE_BALANCE_MANUAL_CCT[];\n\n    // Values for effect settings.\n    static const char EFFECT_NONE[];\n    static const char EFFECT_MONO[];\n    static const char EFFECT_NEGATIVE[];\n    static const char EFFECT_SOLARIZE[];\n    static const char EFFECT_SEPIA[];\n    static const char EFFECT_POSTERIZE[];\n    static const char EFFECT_WHITEBOARD[];\n    static const char EFFECT_BLACKBOARD[];\n    static const char EFFECT_AQUA[];\n\n    // Values for antibanding settings.\n    static const char ANTIBANDING_AUTO[];\n    static const char ANTIBANDING_50HZ[];\n    static const char ANTIBANDING_60HZ[];\n    static const char ANTIBANDING_OFF[];\n\n    // Values for flash mode settings.\n    // Flash will not be fired.\n    static const char FLASH_MODE_OFF[];\n    // Flash will be fired automatically when required. The flash may be fired\n    // during preview, auto-focus, or snapshot depending on the driver.\n    static const char FLASH_MODE_AUTO[];\n    // Flash will always be fired during snapshot. The flash may also be\n    // fired during preview or auto-focus depending on the driver.\n    static const char FLASH_MODE_ON[];\n    // Flash will be fired in red-eye reduction mode.\n    static const char FLASH_MODE_RED_EYE[];\n    // Constant emission of light during preview, auto-focus and snapshot.\n    // This can also be used for video recording.\n    static const char FLASH_MODE_TORCH[];\n\n    // Values for scene mode settings.\n    static const char SCENE_MODE_AUTO[];\n    static const char SCENE_MODE_ACTION[];\n    static const char SCENE_MODE_PORTRAIT[];\n    static const char SCENE_MODE_LANDSCAPE[];\n    static const char SCENE_MODE_NIGHT[];\n    static const char SCENE_MODE_NIGHT_PORTRAIT[];\n    static const char SCENE_MODE_THEATRE[];\n    static const char SCENE_MODE_BEACH[];\n    static const char SCENE_MODE_SNOW[];\n    static const char SCENE_MODE_SUNSET[];\n    static const char SCENE_MODE_STEADYPHOTO[];\n    static const char SCENE_MODE_FIREWORKS[];\n    static const char SCENE_MODE_SPORTS[];\n    static const char SCENE_MODE_PARTY[];\n    static const char SCENE_MODE_CANDLELIGHT[];\n    // Applications are looking for a barcode. Camera driver will be optimized\n    // for barcode reading.\n    static const char SCENE_MODE_BARCODE[];\n    // A high-dynamic range mode. In this mode, the HAL module will use a\n    // capture strategy that extends the dynamic range of the captured\n    // image in some fashion. Only the final image is returned.\n    static const char SCENE_MODE_HDR[];\n\n    // Pixel color formats for KEY_PREVIEW_FORMAT, KEY_PICTURE_FORMAT,\n    // and KEY_VIDEO_FRAME_FORMAT\n    static const char PIXEL_FORMAT_YUV422SP[];\n    static const char PIXEL_FORMAT_YUV420SP[]; // NV21\n    static const char PIXEL_FORMAT_YUV422I[]; // YUY2\n    static const char PIXEL_FORMAT_YUV420P[]; // YV12\n    static const char PIXEL_FORMAT_RGB565[];\n    static const char PIXEL_FORMAT_RGBA8888[];\n    static const char PIXEL_FORMAT_JPEG[];\n    // Raw bayer format used for images, which is 10 bit precision samples\n    // stored in 16 bit words. The filter pattern is RGGB.\n    static const char PIXEL_FORMAT_BAYER_RGGB[];\n    // Pixel format is not known to the framework\n    static const char PIXEL_FORMAT_ANDROID_OPAQUE[];\n\n    // Values for focus mode settings.\n    // Auto-focus mode. Applications should call\n    // CameraHardwareInterface.autoFocus to start the focus in this mode.\n    static const char FOCUS_MODE_AUTO[];\n    // Focus is set at infinity. Applications should not call\n    // CameraHardwareInterface.autoFocus in this mode.\n    static const char FOCUS_MODE_INFINITY[];\n    // Macro (close-up) focus mode. Applications should call\n    // CameraHardwareInterface.autoFocus to start the focus in this mode.\n    static const char FOCUS_MODE_MACRO[];\n    // Focus is fixed. The camera is always in this mode if the focus is not\n    // adjustable. If the camera has auto-focus, this mode can fix the\n    // focus, which is usually at hyperfocal distance. Applications should\n    // not call CameraHardwareInterface.autoFocus in this mode.\n    static const char FOCUS_MODE_FIXED[];\n    // Extended depth of field (EDOF). Focusing is done digitally and\n    // continuously. Applications should not call\n    // CameraHardwareInterface.autoFocus in this mode.\n    static const char FOCUS_MODE_EDOF[];\n    // Continuous auto focus mode intended for video recording. The camera\n    // continuously tries to focus. This is the best choice for video\n    // recording because the focus changes smoothly . Applications still can\n    // call CameraHardwareInterface.takePicture in this mode but the subject may\n    // not be in focus. Auto focus starts when the parameter is set.\n    //\n    // Applications can call CameraHardwareInterface.autoFocus in this mode. The\n    // focus callback will immediately return with a boolean that indicates\n    // whether the focus is sharp or not. The focus position is locked after\n    // autoFocus call. If applications want to resume the continuous focus,\n    // cancelAutoFocus must be called. Restarting the preview will not resume\n    // the continuous autofocus. To stop continuous focus, applications should\n    // change the focus mode to other modes.\n    static const char FOCUS_MODE_CONTINUOUS_VIDEO[];\n    // Continuous auto focus mode intended for taking pictures. The camera\n    // continuously tries to focus. The speed of focus change is more aggressive\n    // than FOCUS_MODE_CONTINUOUS_VIDEO. Auto focus starts when the parameter is\n    // set.\n    //\n    // Applications can call CameraHardwareInterface.autoFocus in this mode. If\n    // the autofocus is in the middle of scanning, the focus callback will\n    // return when it completes. If the autofocus is not scanning, focus\n    // callback will immediately return with a boolean that indicates whether\n    // the focus is sharp or not. The apps can then decide if they want to take\n    // a picture immediately or to change the focus mode to auto, and run a full\n    // autofocus cycle. The focus position is locked after autoFocus call. If\n    // applications want to resume the continuous focus, cancelAutoFocus must be\n    // called. Restarting the preview will not resume the continuous autofocus.\n    // To stop continuous focus, applications should change the focus mode to\n    // other modes.\n    static const char FOCUS_MODE_CONTINUOUS_PICTURE[];\n\n    static const char FOCUS_MODE_MANUAL_POSITION[];\n\n    // Values for light special effects\n    // Low-light enhancement mode\n    static const char LIGHTFX_LOWLIGHT[];\n    // High-dynamic range mode\n    static const char LIGHTFX_HDR[];\n\n#ifdef CAMERA_PARAMETERS_EXTRA_H\nCAMERA_PARAMETERS_EXTRA_H\n#endif\n\n    /**\n     * Returns the the supported preview formats as an enum given in graphics.h\n     * corrsponding to the format given in the input string or -1 if no such\n     * conversion exists.\n     */\n    static int previewFormatToEnum(const char* format);\n\nprivate:\n    DefaultKeyedVector<String8,String8>    mMap;\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/CameraParameters2.h",
    "content": "/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_CAMERA_PARAMETERS2_H\n#define ANDROID_HARDWARE_CAMERA_PARAMETERS2_H\n\n#include <utils/Vector.h>\n#include <utils/String8.h>\n#include \"CameraParameters.h\"\n\nnamespace android {\n\n/**\n * A copy of CameraParameters plus ABI-breaking changes. Needed\n * because some camera HALs directly link to CameraParameters and cannot\n * tolerate an ABI change.\n */\nclass CameraParameters2\n{\npublic:\n    CameraParameters2();\n    CameraParameters2(const String8 &params) { unflatten(params); }\n    ~CameraParameters2();\n\n    String8 flatten() const;\n    void unflatten(const String8 &params);\n\n    void set(const char *key, const char *value);\n    void set(const char *key, int value);\n    void setFloat(const char *key, float value);\n    // Look up string value by key.\n    // -- The string remains valid until the next set/remove of the same key,\n    //    or until the map gets cleared.\n    const char *get(const char *key) const;\n    int getInt(const char *key) const;\n    float getFloat(const char *key) const;\n\n    // Compare the order that key1 was set vs the order that key2 was set.\n    //\n    // Sets the order parameter to an integer less than, equal to, or greater\n    // than zero if key1's set order was respectively, to be less than, to\n    // match, or to be greater than key2's set order.\n    //\n    // Error codes:\n    //  * NAME_NOT_FOUND - if either key has not been set previously\n    //  * BAD_VALUE - if any of the parameters are NULL\n    status_t compareSetOrder(const char *key1, const char *key2,\n            /*out*/\n            int *order) const;\n\n    void remove(const char *key);\n\n    void setPreviewSize(int width, int height);\n    void getPreviewSize(int *width, int *height) const;\n    void getSupportedPreviewSizes(Vector<Size> &sizes) const;\n\n    // Set the dimensions in pixels to the given width and height\n    // for video frames. The given width and height must be one\n    // of the supported dimensions returned from\n    // getSupportedVideoSizes(). Must not be called if\n    // getSupportedVideoSizes() returns an empty Vector of Size.\n    void setVideoSize(int width, int height);\n    // Retrieve the current dimensions (width and height)\n    // in pixels for video frames, which must be one of the\n    // supported dimensions returned from getSupportedVideoSizes().\n    // Must not be called if getSupportedVideoSizes() returns an\n    // empty Vector of Size.\n    void getVideoSize(int *width, int *height) const;\n    // Retrieve a Vector of supported dimensions (width and height)\n    // in pixels for video frames. If sizes returned from the method\n    // is empty, the camera does not support calls to setVideoSize()\n    // or getVideoSize(). In adddition, it also indicates that\n    // the camera only has a single output, and does not have\n    // separate output for video frames and preview frame.\n    void getSupportedVideoSizes(Vector<Size> &sizes) const;\n    // Retrieve the preferred preview size (width and height) in pixels\n    // for video recording. The given width and height must be one of\n    // supported preview sizes returned from getSupportedPreviewSizes().\n    // Must not be called if getSupportedVideoSizes() returns an empty\n    // Vector of Size. If getSupportedVideoSizes() returns an empty\n    // Vector of Size, the width and height returned from this method\n    // is invalid, and is \"-1x-1\".\n    void getPreferredPreviewSizeForVideo(int *width, int *height) const;\n\n    void setPreviewFrameRate(int fps);\n    int getPreviewFrameRate() const;\n    void getPreviewFpsRange(int *min_fps, int *max_fps) const;\n    void setPreviewFpsRange(int min_fps, int max_fps);\n    void setPreviewFormat(const char *format);\n    const char *getPreviewFormat() const;\n    void setPictureSize(int width, int height);\n    void getPictureSize(int *width, int *height) const;\n    void getSupportedPictureSizes(Vector<Size> &sizes) const;\n    void setPictureFormat(const char *format);\n    const char *getPictureFormat() const;\n\n    void dump() const;\n    status_t dump(int fd, const Vector<String16>& args) const;\n\nprivate:\n\n    // Quick and dirty map that maintains insertion order\n    template <typename KeyT, typename ValueT>\n    struct OrderedKeyedVector {\n\n        ssize_t add(const KeyT& key, const ValueT& value) {\n            return mList.add(Pair(key, value));\n        }\n\n        size_t size() const {\n            return mList.size();\n        }\n\n        const KeyT& keyAt(size_t idx) const {\n            return mList[idx].mKey;\n        }\n\n        const ValueT& valueAt(size_t idx) const {\n            return mList[idx].mValue;\n        }\n\n        const ValueT& valueFor(const KeyT& key) const {\n            ssize_t i = indexOfKey(key);\n            LOG_ALWAYS_FATAL_IF(i<0, \"%s: key not found\", __PRETTY_FUNCTION__);\n\n            return valueAt(i);\n        }\n\n        ssize_t indexOfKey(const KeyT& key) const {\n                size_t vectorIdx = 0;\n                for (; vectorIdx < mList.size(); ++vectorIdx) {\n                    if (mList[vectorIdx].mKey == key) {\n                        return (ssize_t) vectorIdx;\n                    }\n                }\n\n                return NAME_NOT_FOUND;\n        }\n\n        ssize_t removeItem(const KeyT& key) {\n            size_t vectorIdx = (size_t) indexOfKey(key);\n\n            if (vectorIdx < 0) {\n                return vectorIdx;\n            }\n\n            return mList.removeAt(vectorIdx);\n        }\n\n        void clear() {\n            mList.clear();\n        }\n\n        // Same as removing and re-adding. The key's index changes to max.\n        ssize_t replaceValueFor(const KeyT& key, const ValueT& value) {\n            removeItem(key);\n            return add(key, value);\n        }\n\n    private:\n\n        struct Pair {\n            Pair() : mKey(), mValue() {}\n            Pair(const KeyT& key, const ValueT& value) :\n                    mKey(key),\n                    mValue(value) {}\n            KeyT   mKey;\n            ValueT mValue;\n        };\n\n        Vector<Pair> mList;\n    };\n\n    /**\n     * Order matters: Keys that are set() later are stored later in the map.\n     *\n     * If two keys have meaning that conflict, then the later-set key\n     * wins.\n     *\n     * For example, preview FPS and preview FPS range conflict since only\n     * we only want to use the FPS range if that's the last thing that was set.\n     * So in that case, only use preview FPS range if it was set later than\n     * the preview FPS.\n     */\n    OrderedKeyedVector<String8,String8>    mMap;\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/CameraParametersExtra.h",
    "content": "// Overload this file in your device specific config if you need\n// to add extra camera parameters.\n// A typical file would look like this:\n/*\n * Copyright (C) 2014 The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*\n#define CAMERA_PARAMETERS_EXTRA_C \\\nconst char CameraParameters::KEY_SUPPORTED_BURST_NUM[] = \"supported-burst-num\"; \\\nconst char CameraParameters::KEY_BURST_NUM[] = \"burst-num\"; \\\nconst char CameraParameters::KEY_SUPPORTED_HDR_MODES[] = \"supported-hdr-modes\"; \\\nconst char CameraParameters::KEY_HDR_MODE[] = \"hdr-mode\"; \\\nconst char CameraParameters::HDR_MODE_OFF[] = \"hdr-mode-off\"; \\\nconst char CameraParameters::HDR_MODE_HDR[] = \"hdr-mode-hdr\";\n\n#define CAMERA_PARAMETERS_EXTRA_H \\\n    static const char KEY_SUPPORTED_BURST_NUM[]; \\\n    static const char KEY_BURST_NUM[]; \\\n    static const char KEY_SUPPORTED_HDR_MODES[]; \\\n    static const char KEY_HDR_MODE[]; \\\n    static const char HDR_MODE_OFF[]; \\\n    static const char HDR_MODE_HDR[];\n*/\n"
  },
  {
    "path": "libshims/include/camera/CameraUtils.h",
    "content": "/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_CAMERA_CLIENT_CAMERAUTILS_H\n#define ANDROID_CAMERA_CLIENT_CAMERAUTILS_H\n\n#include <camera/CameraMetadata.h>\n#include <utils/Errors.h>\n\n#include <stdint.h>\n\nnamespace android {\n\n/**\n * CameraUtils contains utility methods that are shared between the native\n * camera client, and the camera service.\n */\nclass CameraUtils {\n    public:\n        /**\n         * Calculate the ANativeWindow transform from the static camera\n         * metadata.  This is based on the sensor orientation and lens facing\n         * attributes of the camera device.\n         *\n         * Returns OK on success, or a negative error code.\n         */\n        static status_t getRotationTransform(const CameraMetadata& staticInfo,\n                /*out*/int32_t* transform);\n    private:\n        CameraUtils();\n};\n\n} /* namespace android */\n\n#endif /* ANDROID_CAMERA_CLIENT_CAMERAUTILS_H */\n\n"
  },
  {
    "path": "libshims/include/camera/CaptureResult.h",
    "content": "/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_CAPTURERESULT_H\n#define ANDROID_HARDWARE_CAPTURERESULT_H\n\n#include <utils/RefBase.h>\n#include <camera/CameraMetadata.h>\n\nnamespace android {\n\n/**\n * CaptureResultExtras is a structure to encapsulate various indices for a capture result.\n * These indices are framework-internal and not sent to the HAL.\n */\nstruct CaptureResultExtras {\n    /**\n     * An integer to index the request sequence that this result belongs to.\n     */\n    int32_t requestId;\n\n    /**\n     * An integer to index this result inside a request sequence, starting from 0.\n     */\n    int32_t burstId;\n\n    /**\n     * TODO: Add documentation for this field.\n     */\n    int32_t afTriggerId;\n\n    /**\n     * TODO: Add documentation for this field.\n     */\n    int32_t precaptureTriggerId;\n\n    /**\n     * A 64bit integer to index the frame number associated with this result.\n     */\n    int64_t frameNumber;\n\n    /**\n     * The partial result count (index) for this capture result.\n     */\n    int32_t partialResultCount;\n\n    /**\n     * Constructor initializes object as invalid by setting requestId to be -1.\n     */\n    CaptureResultExtras()\n        : requestId(-1),\n          burstId(0),\n          afTriggerId(0),\n          precaptureTriggerId(0),\n          frameNumber(0),\n          partialResultCount(0) {\n    }\n\n    /**\n     * This function returns true if it's a valid CaptureResultExtras object.\n     * Otherwise, returns false. It is valid only when requestId is non-negative.\n     */\n    bool isValid();\n\n    status_t                readFromParcel(Parcel* parcel);\n    status_t                writeToParcel(Parcel* parcel) const;\n};\n\nstruct CaptureResult : public virtual LightRefBase<CaptureResult> {\n    CameraMetadata          mMetadata;\n    CaptureResultExtras     mResultExtras;\n\n    CaptureResult();\n\n    CaptureResult(const CaptureResult& otherResult);\n\n    status_t                readFromParcel(Parcel* parcel);\n    status_t                writeToParcel(Parcel* parcel) const;\n};\n\n}\n\n#endif /* ANDROID_HARDWARE_CAPTURERESULT_H */\n"
  },
  {
    "path": "libshims/include/camera/ICamera.h",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_ICAMERA_H\n#define ANDROID_HARDWARE_ICAMERA_H\n\n#include <utils/RefBase.h>\n#include <binder/IInterface.h>\n#include <binder/Parcel.h>\n#include <binder/IMemory.h>\n#include <utils/String8.h>\n#include <camera/Camera.h>\n\nnamespace android {\n\nclass ICameraClient;\nclass IGraphicBufferProducer;\nclass Surface;\n\nclass ICamera: public IInterface\n{\n    /**\n     * Keep up-to-date with ICamera.aidl in frameworks/base\n     */\npublic:\n    DECLARE_META_INTERFACE(Camera);\n\n    virtual void            disconnect() = 0;\n\n    // connect new client with existing camera remote\n    virtual status_t        connect(const sp<ICameraClient>& client) = 0;\n\n    // prevent other processes from using this ICamera interface\n    virtual status_t        lock() = 0;\n\n    // allow other processes to use this ICamera interface\n    virtual status_t        unlock() = 0;\n\n    // pass the buffered IGraphicBufferProducer to the camera service\n    virtual status_t        setPreviewTarget(\n            const sp<IGraphicBufferProducer>& bufferProducer) = 0;\n\n    // set the preview callback flag to affect how the received frames from\n    // preview are handled. Enabling preview callback flags disables any active\n    // preview callback surface set by setPreviewCallbackTarget().\n    virtual void            setPreviewCallbackFlag(int flag) = 0;\n    // set a buffer interface to use for client-received preview frames instead\n    // of preview callback buffers. Passing a valid interface here disables any\n    // active preview callbacks set by setPreviewCallbackFlag(). Passing NULL\n    // disables the use of the callback target.\n    virtual status_t        setPreviewCallbackTarget(\n            const sp<IGraphicBufferProducer>& callbackProducer) = 0;\n\n    // start preview mode, must call setPreviewTarget first\n    virtual status_t        startPreview() = 0;\n\n    // stop preview mode\n    virtual void            stopPreview() = 0;\n\n    // get preview state\n    virtual bool            previewEnabled() = 0;\n\n    // start recording mode\n    virtual status_t        startRecording() = 0;\n\n    // stop recording mode\n    virtual void            stopRecording() = 0;\n\n    // get recording state\n    virtual bool            recordingEnabled() = 0;\n\n    // release a recording frame\n    virtual void            releaseRecordingFrame(const sp<IMemory>& mem) = 0;\n\n    // auto focus\n    virtual status_t        autoFocus() = 0;\n\n    // cancel auto focus\n    virtual status_t        cancelAutoFocus() = 0;\n\n    /*\n     * take a picture.\n     * @param msgType the message type an application selectively turn on/off\n     * on a photo-by-photo basis. The supported message types are:\n     * CAMERA_MSG_SHUTTER, CAMERA_MSG_RAW_IMAGE, CAMERA_MSG_COMPRESSED_IMAGE,\n     * and CAMERA_MSG_POSTVIEW_FRAME. Any other message types will be ignored.\n     */\n    virtual status_t        takePicture(int msgType) = 0;\n\n    // set preview/capture parameters - key/value pairs\n    virtual status_t        setParameters(const String8& params) = 0;\n\n    // get preview/capture parameters - key/value pairs\n    virtual String8         getParameters() const = 0;\n\n    // send command to camera driver\n    virtual status_t        sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0;\n\n    // tell the camera hal to store meta data or real YUV data in video buffers.\n    virtual status_t        storeMetaDataInBuffers(bool enabled) = 0;\n};\n\n// ----------------------------------------------------------------------------\n\nclass BnCamera: public BnInterface<ICamera>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/ICameraClient.h",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_ICAMERA_APP_H\n#define ANDROID_HARDWARE_ICAMERA_APP_H\n\n#include <utils/RefBase.h>\n#include <binder/IInterface.h>\n#include <binder/Parcel.h>\n#include <binder/IMemory.h>\n#include <utils/Timers.h>\n#include <system/camera.h>\n\nnamespace android {\n\nclass ICameraClient: public IInterface\n{\n    /**\n     * Keep up-to-date with ICameraClient.aidl in frameworks/base\n     */\npublic:\n    DECLARE_META_INTERFACE(CameraClient);\n\n    virtual void            notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) = 0;\n    virtual void            dataCallback(int32_t msgType, const sp<IMemory>& data,\n                                         camera_frame_metadata_t *metadata) = 0;\n    virtual void            dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& data) = 0;\n};\n\n// ----------------------------------------------------------------------------\n\nclass BnCameraClient: public BnInterface<ICameraClient>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/ICameraRecordingProxy.h",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H\n#define ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H\n\n#include <binder/IInterface.h>\n#include <utils/RefBase.h>\n\nnamespace android {\n\nclass ICameraRecordingProxyListener;\nclass IMemory;\nclass Parcel;\n\n/*\n * The purpose of ICameraRecordingProxy and ICameraRecordingProxyListener is to\n * allow applications using the camera during recording.\n *\n * Camera service allows only one client at a time. Since camcorder application\n * needs to own the camera to do things like zoom, the media recorder cannot\n * access the camera directly during recording. So ICameraRecordingProxy is a\n * proxy of ICamera, which allows the media recorder to start/stop the recording\n * and release recording frames. ICameraRecordingProxyListener is an interface\n * that allows the recorder to receive video frames during recording.\n *\n * ICameraRecordingProxy\n *   startRecording()\n *   stopRecording()\n *   releaseRecordingFrame()\n *\n * ICameraRecordingProxyListener\n *   dataCallbackTimestamp()\n\n * The camcorder app opens the camera and starts the preview. The app passes\n * ICamera and ICameraRecordingProxy to the media recorder by\n * MediaRecorder::setCamera(). The recorder uses ICamera to setup the camera in\n * MediaRecorder::start(). After setup, the recorder disconnects from camera\n * service. The recorder calls ICameraRecordingProxy::startRecording() and\n * passes a ICameraRecordingProxyListener to the app. The app connects back to\n * camera service and starts the recording. The app owns the camera and can do\n * things like zoom. The media recorder receives the video frames from the\n * listener and releases them by ICameraRecordingProxy::releaseRecordingFrame.\n * The recorder calls ICameraRecordingProxy::stopRecording() to stop the\n * recording.\n *\n * The call sequences are as follows:\n * 1. The app: Camera.unlock().\n * 2. The app: MediaRecorder.setCamera().\n * 3. Start recording\n *    (1) The app: MediaRecorder.start().\n *    (2) The recorder: ICamera.unlock() and ICamera.disconnect().\n *    (3) The recorder: ICameraRecordingProxy.startRecording().\n *    (4) The app: ICamera.reconnect().\n *    (5) The app: ICamera.startRecording().\n * 4. During recording\n *    (1) The recorder: receive frames from ICameraRecordingProxyListener.dataCallbackTimestamp()\n *    (2) The recorder: release frames by ICameraRecordingProxy.releaseRecordingFrame().\n * 5. Stop recording\n *    (1) The app: MediaRecorder.stop()\n *    (2) The recorder: ICameraRecordingProxy.stopRecording().\n *    (3) The app: ICamera.stopRecording().\n */\n\nclass ICameraRecordingProxy: public IInterface\n{\npublic:\n    DECLARE_META_INTERFACE(CameraRecordingProxy);\n\n    virtual status_t        startRecording(const sp<ICameraRecordingProxyListener>& listener) = 0;\n    virtual void            stopRecording() = 0;\n    virtual void            releaseRecordingFrame(const sp<IMemory>& mem) = 0;\n\n    // b/28466701\n    static  size_t          getCommonBaseAddress();\n  private:\n\n    static  uint8_t         baseObject;\n};\n\n// ----------------------------------------------------------------------------\n\nclass BnCameraRecordingProxy: public BnInterface<ICameraRecordingProxy>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/ICameraRecordingProxyListener.h",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_LISTENER_H\n#define ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_LISTENER_H\n\n#include <binder/IInterface.h>\n#include <stdint.h>\n#include <utils/RefBase.h>\n#include <utils/Timers.h>\n\nnamespace android {\n\nclass Parcel;\nclass IMemory;\n\nclass ICameraRecordingProxyListener: public IInterface\n{\npublic:\n    DECLARE_META_INTERFACE(CameraRecordingProxyListener);\n\n    virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType,\n                                       const sp<IMemory>& data) = 0;\n};\n\n// ----------------------------------------------------------------------------\n\nclass BnCameraRecordingProxyListener: public BnInterface<ICameraRecordingProxyListener>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/ICameraService.h",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_ICAMERASERVICE_H\n#define ANDROID_HARDWARE_ICAMERASERVICE_H\n\n#include <utils/RefBase.h>\n#include <binder/IInterface.h>\n#include <binder/Parcel.h>\n\nnamespace android {\n\nclass ICamera;\nclass ICameraClient;\nclass ICameraServiceListener;\nclass ICameraDeviceUser;\nclass ICameraDeviceCallbacks;\nclass CameraMetadata;\nclass VendorTagDescriptor;\nclass String16;\n\nclass ICameraService : public IInterface\n{\npublic:\n    /**\n     * Keep up-to-date with ICameraService.aidl in frameworks/base\n     */\n    enum {\n        GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION,\n        GET_CAMERA_INFO,\n        CONNECT,\n        CONNECT_DEVICE,\n        ADD_LISTENER,\n        REMOVE_LISTENER,\n        GET_CAMERA_CHARACTERISTICS,\n        GET_CAMERA_VENDOR_TAG_DESCRIPTOR,\n        GET_LEGACY_PARAMETERS,\n        SUPPORTS_CAMERA_API,\n        CONNECT_LEGACY,\n        SET_TORCH_MODE,\n        NOTIFY_SYSTEM_EVENT,\n    };\n\n    enum {\n        USE_CALLING_UID = -1\n    };\n\n    enum {\n        API_VERSION_1 = 1,\n        API_VERSION_2 = 2,\n    };\n\n    enum {\n        CAMERA_TYPE_BACKWARD_COMPATIBLE = 0,\n        CAMERA_TYPE_ALL = 1,\n    };\n\n    enum {\n        CAMERA_HAL_API_VERSION_UNSPECIFIED = -1\n    };\n\n    /**\n     * Keep up-to-date with declarations in\n     * frameworks/base/services/core/java/com/android/server/camera/CameraService.java\n     *\n     * These event codes are intended to be used with the notifySystemEvent call.\n     */\n    enum {\n        NO_EVENT = 0,\n        USER_SWITCHED,\n    };\n\npublic:\n    DECLARE_META_INTERFACE(CameraService);\n\n    // Get the number of cameras that support basic color camera operation\n    // (type CAMERA_TYPE_BACKWARD_COMPATIBLE)\n    virtual int32_t  getNumberOfCameras() = 0;\n    // Get the number of cameras of the specified type, one of CAMERA_TYPE_*\n    // enums\n    virtual int32_t  getNumberOfCameras(int cameraType) = 0;\n    virtual status_t getCameraInfo(int cameraId,\n            /*out*/\n            struct CameraInfo* cameraInfo) = 0;\n\n    virtual status_t getCameraCharacteristics(int cameraId,\n            /*out*/\n            CameraMetadata* cameraInfo) = 0;\n\n    virtual status_t getCameraVendorTagDescriptor(\n            /*out*/\n            sp<VendorTagDescriptor>& desc) = 0;\n\n    // Returns 'OK' if operation succeeded\n    // - Errors: ALREADY_EXISTS if the listener was already added\n    virtual status_t addListener(const sp<ICameraServiceListener>& listener)\n                                                                            = 0;\n    // Returns 'OK' if operation succeeded\n    // - Errors: BAD_VALUE if specified listener was not in the listener list\n    virtual status_t removeListener(const sp<ICameraServiceListener>& listener)\n                                                                            = 0;\n    /**\n     * clientPackageName and clientUid are used for permissions checking.  if\n     * clientUid == USE_CALLING_UID, then the calling UID is used instead. Only\n     * trusted callers can set a clientUid other than USE_CALLING_UID.\n     */\n    virtual status_t connect(const sp<ICameraClient>& cameraClient,\n            int cameraId,\n            const String16& clientPackageName,\n            int clientUid,\n            /*out*/\n            sp<ICamera>& device) = 0;\n\n    virtual status_t connectDevice(\n            const sp<ICameraDeviceCallbacks>& cameraCb,\n            int cameraId,\n            const String16& clientPackageName,\n            int clientUid,\n            /*out*/\n            sp<ICameraDeviceUser>& device) = 0;\n\n    virtual status_t getLegacyParameters(\n            int cameraId,\n            /*out*/\n            String16* parameters) = 0;\n\n    /**\n     * Returns OK if device supports camera2 api,\n     * returns -EOPNOTSUPP if it doesn't.\n     */\n    virtual status_t supportsCameraApi(\n            int cameraId, int apiVersion) = 0;\n\n    /**\n     * Connect the device as a legacy device for a given HAL version.\n     * For halVersion, use CAMERA_API_DEVICE_VERSION_* for a particular\n     * version, or CAMERA_HAL_API_VERSION_UNSPECIFIED for a service-selected version.\n     */\n    virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient,\n            int cameraId, int halVersion,\n            const String16& clientPackageName,\n            int clientUid,\n            /*out*/\n            sp<ICamera>& device) = 0;\n\n    /**\n     * Turn on or off a camera's torch mode. Torch mode will be turned off by\n     * camera service if the lastest client binder that turns it on dies.\n     *\n     * return values:\n     * 0:       on a successful operation.\n     * -ENOSYS: the camera device doesn't support this operation. It it returned\n     *          if and only if android.flash.into.available is false.\n     * -EBUSY:  the camera device is opened.\n     * -EINVAL: camera_id is invalid or clientBinder is NULL when enabling a\n     *          torch mode.\n     */\n    virtual status_t setTorchMode(const String16& cameraId, bool enabled,\n            const sp<IBinder>& clientBinder) = 0;\n\n    /**\n     * Notify the camera service of a system event.  Should only be called from system_server.\n     */\n    virtual void notifySystemEvent(int32_t eventId, const int32_t* args, size_t length) = 0;\n};\n\n// ----------------------------------------------------------------------------\n\nclass BnCameraService: public BnInterface<ICameraService>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/ICameraServiceListener.h",
    "content": "/*\n * Copyright (C) 2013 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_ICAMERASERVICE_LISTENER_H\n#define ANDROID_HARDWARE_ICAMERASERVICE_LISTENER_H\n\n#include <utils/RefBase.h>\n#include <binder/IInterface.h>\n#include <binder/Parcel.h>\n#include <hardware/camera_common.h>\n\nnamespace android {\n\nclass ICameraServiceListener : public IInterface\n{\n    /**\n     * Keep up-to-date with ICameraServiceListener.aidl in frameworks/base\n     */\npublic:\n\n    /**\n     * Initial status will be transmitted with onStatusChange immediately\n     * after this listener is added to the service listener list.\n     *\n     * Allowed transitions:\n     *\n     *     (Any)               -> NOT_PRESENT\n     *     NOT_PRESENT         -> PRESENT\n     *     NOT_PRESENT         -> ENUMERATING\n     *     ENUMERATING         -> PRESENT\n     *     PRESENT             -> NOT_AVAILABLE\n     *     NOT_AVAILABLE       -> PRESENT\n     *\n     * A state will never immediately transition back to itself.\n     */\n    enum Status {\n        // Device physically unplugged\n        STATUS_NOT_PRESENT      = CAMERA_DEVICE_STATUS_NOT_PRESENT,\n        // Device physically has been plugged in\n        //  and the camera can be used exlusively\n        STATUS_PRESENT          = CAMERA_DEVICE_STATUS_PRESENT,\n        // Device physically has been plugged in\n        //   but it will not be connect-able until enumeration is complete\n        STATUS_ENUMERATING      = CAMERA_DEVICE_STATUS_ENUMERATING,\n\n        // Camera can be used exclusively\n        STATUS_AVAILABLE        = STATUS_PRESENT, // deprecated, will be removed\n\n        // Camera is in use by another app and cannot be used exclusively\n        STATUS_NOT_AVAILABLE    = 0x80000000,\n\n        // Use to initialize variables only\n        STATUS_UNKNOWN          = 0xFFFFFFFF,\n    };\n\n    /**\n     * The torch mode status of a camera.\n     *\n     * Initial status will be transmitted with onTorchStatusChanged immediately\n     * after this listener is added to the service listener list.\n     *\n     * The enums should be set to values matching\n     * include/hardware/camera_common.h\n     */\n    enum TorchStatus {\n        // The camera's torch mode has become not available to use via\n        // setTorchMode().\n        TORCH_STATUS_NOT_AVAILABLE  = TORCH_MODE_STATUS_NOT_AVAILABLE,\n        // The camera's torch mode is off and available to be turned on via\n        // setTorchMode().\n        TORCH_STATUS_AVAILABLE_OFF  = TORCH_MODE_STATUS_AVAILABLE_OFF,\n        // The camera's torch mode is on and available to be turned off via\n        // setTorchMode().\n        TORCH_STATUS_AVAILABLE_ON   = TORCH_MODE_STATUS_AVAILABLE_ON,\n\n        // Use to initialize variables only\n        TORCH_STATUS_UNKNOWN        = 0xFFFFFFFF,\n    };\n\n    DECLARE_META_INTERFACE(CameraServiceListener);\n\n    virtual void onStatusChanged(Status status, int32_t cameraId) = 0;\n\n    virtual void onTorchStatusChanged(TorchStatus status, const String16& cameraId) = 0;\n};\n\n// ----------------------------------------------------------------------------\n\nclass BnCameraServiceListener : public BnInterface<ICameraServiceListener>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/ICameraServiceProxy.h",
    "content": "/*\n * Copyright (C) 2015 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_ICAMERASERVICEPROXY_H\n#define ANDROID_HARDWARE_ICAMERASERVICEPROXY_H\n\n#include <utils/RefBase.h>\n#include <binder/IInterface.h>\n#include <binder/Parcel.h>\n\nnamespace android {\n\n/**\n * Interface from native camera service to managed-side camera service proxy.\n *\n * Keep in sync with frameworks/base/core/java/android/hardware/ICameraServiceProxy.aidl\n *\n */\nclass ICameraServiceProxy : public IInterface {\npublic:\n    enum {\n        PING_FOR_USER_UPDATE = IBinder::FIRST_CALL_TRANSACTION,\n        NOTIFY_CAMERA_STATE\n    };\n\n    enum CameraState {\n        CAMERA_STATE_OPEN,\n        CAMERA_STATE_ACTIVE,\n        CAMERA_STATE_IDLE,\n        CAMERA_STATE_CLOSED\n    };\n\n    DECLARE_META_INTERFACE(CameraServiceProxy);\n\n    virtual void pingForUserUpdate() = 0;\n    virtual void notifyCameraState(String16 cameraId, CameraState newCameraState) = 0;\n};\n\nclass BnCameraServiceProxy: public BnInterface<ICameraServiceProxy>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n\n\n}; // namespace android\n\n#endif // ANDROID_HARDWARE_ICAMERASERVICEPROXY_H\n"
  },
  {
    "path": "libshims/include/camera/VendorTagDescriptor.h",
    "content": "/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef VENDOR_TAG_DESCRIPTOR_H\n\n#include <utils/Vector.h>\n#include <utils/KeyedVector.h>\n#include <utils/String8.h>\n#include <utils/RefBase.h>\n#include <system/camera_vendor_tags.h>\n\n#include <stdint.h>\n\nnamespace android {\n\nclass Parcel;\n\n/**\n * VendorTagDescriptor objects are parcelable containers for the vendor tag\n * definitions provided, and are typically used to pass the vendor tag\n * information enumerated by the HAL to clients of the camera service.\n */\nclass VendorTagDescriptor\n        : public LightRefBase<VendorTagDescriptor> {\n    public:\n        virtual ~VendorTagDescriptor();\n\n        /**\n         * The following 'get*' methods implement the corresponding\n         * functions defined in\n         * system/media/camera/include/system/camera_vendor_tags.h\n         */\n\n        // Returns the number of vendor tags defined.\n        int getTagCount() const;\n\n        // Returns an array containing the id's of vendor tags defined.\n        void getTagArray(uint32_t* tagArray) const;\n\n        // Returns the section name string for a given vendor tag id.\n        const char* getSectionName(uint32_t tag) const;\n\n        // Returns the tag name string for a given vendor tag id.\n        const char* getTagName(uint32_t tag) const;\n\n        // Returns the tag type for a given vendor tag id.\n        int getTagType(uint32_t tag) const;\n\n        /**\n         * Write the VendorTagDescriptor object into the given parcel.\n         *\n         * Returns OK on success, or a negative error code.\n         */\n        status_t writeToParcel(\n                /*out*/\n                Parcel* parcel) const;\n\n        /**\n         * Convenience method to get a vector containing all vendor tag\n         * sections, or an empty vector if none are defined.\n         */\n        SortedVector<String8> getAllSectionNames() const;\n\n        /**\n         * Lookup the tag id for a given tag name and section.\n         *\n         * Returns OK on success, or a negative error code.\n         */\n        status_t lookupTag(String8 name, String8 section, /*out*/uint32_t* tag) const;\n\n        /**\n         * Dump the currently configured vendor tags to a file descriptor.\n         */\n        void dump(int fd, int verbosity, int indentation) const;\n\n        // Static methods:\n\n        /**\n         * Create a VendorTagDescriptor object from the given parcel.\n         *\n         * Returns OK on success, or a negative error code.\n         */\n        static status_t createFromParcel(const Parcel* parcel,\n                /*out*/\n                sp<VendorTagDescriptor>& descriptor);\n\n        /**\n         * Create a VendorTagDescriptor object from the given vendor_tag_ops_t\n         * struct.\n         *\n         * Returns OK on success, or a negative error code.\n         */\n        static status_t createDescriptorFromOps(const vendor_tag_ops_t* vOps,\n                /*out*/\n                sp<VendorTagDescriptor>& descriptor);\n\n        /**\n         * Sets the global vendor tag descriptor to use for this process.\n         * Camera metadata operations that access vendor tags will use the\n         * vendor tag definitions set this way.\n         *\n         * Returns OK on success, or a negative error code.\n         */\n        static status_t setAsGlobalVendorTagDescriptor(const sp<VendorTagDescriptor>& desc);\n\n        /**\n         * Clears the global vendor tag descriptor used by this process.\n         */\n        static void clearGlobalVendorTagDescriptor();\n\n        /**\n         * Returns the global vendor tag descriptor used by this process.\n         * This will contain NULL if no vendor tags are defined.\n         */\n        static sp<VendorTagDescriptor> getGlobalVendorTagDescriptor();\n    protected:\n        VendorTagDescriptor();\n        KeyedVector<String8, KeyedVector<String8, uint32_t>*> mReverseMapping;\n        KeyedVector<uint32_t, String8> mTagToNameMap;\n        KeyedVector<uint32_t, uint32_t> mTagToSectionMap; // Value is offset in mSections\n        KeyedVector<uint32_t, int32_t> mTagToTypeMap;\n        SortedVector<String8> mSections;\n        // must be int32_t to be compatible with Parcel::writeInt32\n        int32_t mTagCount;\n    private:\n        vendor_tag_ops mVendorOps;\n};\n\n} /* namespace android */\n\n#define VENDOR_TAG_DESCRIPTOR_H\n#endif /* VENDOR_TAG_DESCRIPTOR_H */\n"
  },
  {
    "path": "libshims/include/camera/camera2/CaptureRequest.h",
    "content": "/*\n * Copyright (C) 2013 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_PHOTOGRAPHY_CAPTUREREQUEST_H\n#define ANDROID_HARDWARE_PHOTOGRAPHY_CAPTUREREQUEST_H\n\n#include <utils/RefBase.h>\n#include <utils/Vector.h>\n#include <camera/CameraMetadata.h>\n\nnamespace android {\n\nclass Surface;\n\nstruct CaptureRequest : public virtual RefBase {\npublic:\n\n    CameraMetadata          mMetadata;\n    Vector<sp<Surface> >    mSurfaceList;\n    bool                    mIsReprocess;\n\n    /**\n     * Keep impl up-to-date with CaptureRequest.java in frameworks/base\n     */\n    status_t                readFromParcel(Parcel* parcel);\n    status_t                writeToParcel(Parcel* parcel) const;\n};\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/camera2/ICameraDeviceCallbacks.h",
    "content": "/*\n * Copyright (C) 2013 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_PHOTOGRAPHY_CALLBACKS_H\n#define ANDROID_HARDWARE_PHOTOGRAPHY_CALLBACKS_H\n\n#include <utils/RefBase.h>\n#include <binder/IInterface.h>\n#include <binder/Parcel.h>\n#include <binder/IMemory.h>\n#include <utils/Timers.h>\n#include <system/camera.h>\n\n#include <camera/CaptureResult.h>\n\nnamespace android {\nclass CameraMetadata;\n\n\nclass ICameraDeviceCallbacks : public IInterface\n{\n    /**\n     * Keep up-to-date with ICameraDeviceCallbacks.aidl in frameworks/base\n     */\npublic:\n    DECLARE_META_INTERFACE(CameraDeviceCallbacks);\n\n    /**\n     * Error codes for CAMERA_MSG_ERROR\n     */\n    enum CameraErrorCode {\n        ERROR_CAMERA_INVALID_ERROR = -1, // To indicate all invalid error codes\n        ERROR_CAMERA_DISCONNECTED = 0,\n        ERROR_CAMERA_DEVICE = 1,\n        ERROR_CAMERA_SERVICE = 2,\n        ERROR_CAMERA_REQUEST = 3,\n        ERROR_CAMERA_RESULT = 4,\n        ERROR_CAMERA_BUFFER = 5,\n    };\n\n    // One way\n    virtual void            onDeviceError(CameraErrorCode errorCode,\n                                          const CaptureResultExtras& resultExtras) = 0;\n\n    // One way\n    virtual void            onDeviceIdle() = 0;\n\n    // One way\n    virtual void            onCaptureStarted(const CaptureResultExtras& resultExtras,\n                                             int64_t timestamp) = 0;\n\n    // One way\n    virtual void            onResultReceived(const CameraMetadata& metadata,\n                                             const CaptureResultExtras& resultExtras) = 0;\n\n    // One way\n    virtual void            onPrepared(int streamId) = 0;\n};\n\n// ----------------------------------------------------------------------------\n\nclass BnCameraDeviceCallbacks : public BnInterface<ICameraDeviceCallbacks>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/camera2/ICameraDeviceUser.h",
    "content": "/*\n * Copyright (C) 2013 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_PHOTOGRAPHY_ICAMERADEVICEUSER_H\n#define ANDROID_HARDWARE_PHOTOGRAPHY_ICAMERADEVICEUSER_H\n\n#include <binder/IInterface.h>\n#include <binder/Parcel.h>\n#include <utils/List.h>\n\nstruct camera_metadata;\n\nnamespace android {\n\nclass ICameraDeviceUserClient;\nclass IGraphicBufferProducer;\nclass CaptureRequest;\nclass CameraMetadata;\nclass OutputConfiguration;\n\nenum {\n    NO_IN_FLIGHT_REPEATING_FRAMES = -1,\n};\n\nclass ICameraDeviceUser : public IInterface\n{\n    /**\n     * Keep up-to-date with ICameraDeviceUser.aidl in frameworks/base\n     */\npublic:\n    DECLARE_META_INTERFACE(CameraDeviceUser);\n\n    virtual void            disconnect() = 0;\n\n    /**\n     * Request Handling\n     **/\n\n    /**\n     * For streaming requests, output lastFrameNumber is the last frame number\n     * of the previous repeating request.\n     * For non-streaming requests, output lastFrameNumber is the expected last\n     * frame number of the current request.\n     */\n    virtual int             submitRequest(sp<CaptureRequest> request,\n                                          bool streaming = false,\n                                          /*out*/\n                                          int64_t* lastFrameNumber = NULL) = 0;\n\n    /**\n     * For streaming requests, output lastFrameNumber is the last frame number\n     * of the previous repeating request.\n     * For non-streaming requests, output lastFrameNumber is the expected last\n     * frame number of the current request.\n     */\n    virtual int             submitRequestList(List<sp<CaptureRequest> > requestList,\n                                              bool streaming = false,\n                                              /*out*/\n                                              int64_t* lastFrameNumber = NULL) = 0;\n\n    /**\n     * Output lastFrameNumber is the last frame number of the previous repeating request.\n     */\n    virtual status_t        cancelRequest(int requestId,\n                                          /*out*/\n                                          int64_t* lastFrameNumber = NULL) = 0;\n\n    /**\n     * Begin the device configuration.\n     *\n     * <p>\n     * beginConfigure must be called before any call to deleteStream, createStream,\n     * or endConfigure.  It is not valid to call this when the device is not idle.\n     * <p>\n     */\n    virtual status_t        beginConfigure() = 0;\n\n    /**\n     * End the device configuration.\n     *\n     * <p>\n     * endConfigure must be called after stream configuration is complete (i.e. after\n     * a call to beginConfigure and subsequent createStream/deleteStream calls).  This\n     * must be called before any requests can be submitted.\n     * <p>\n     */\n    virtual status_t        endConfigure(bool isConstrainedHighSpeed = false) = 0;\n\n    virtual status_t        deleteStream(int streamId) = 0;\n\n    virtual status_t        createStream(const OutputConfiguration& outputConfiguration) = 0;\n\n    /**\n     * Create an input stream of width, height, and format (one of\n     * HAL_PIXEL_FORMAT_*)\n     *\n     * Return stream ID if it's a non-negative value. status_t if it's a\n     * negative value.\n     */\n    virtual status_t        createInputStream(int width, int height, int format) = 0;\n\n    // get the buffer producer of the input stream\n    virtual status_t        getInputBufferProducer(\n            sp<IGraphicBufferProducer> *producer) = 0;\n\n    // Create a request object from a template.\n    virtual status_t        createDefaultRequest(int templateId,\n                                                 /*out*/\n                                                 CameraMetadata* request) = 0;\n    // Get static camera metadata\n    virtual status_t        getCameraInfo(/*out*/\n                                          CameraMetadata* info) = 0;\n\n    // Wait until all the submitted requests have finished processing\n    virtual status_t        waitUntilIdle() =  0;\n\n    /**\n     * Flush all pending and in-progress work as quickly as possible.\n     * Output lastFrameNumber is the last frame number of the previous repeating request.\n     */\n    virtual status_t        flush(/*out*/\n                                  int64_t* lastFrameNumber = NULL) = 0;\n\n    /**\n     * Preallocate buffers for a given output stream asynchronously.\n     */\n    virtual status_t        prepare(int streamId) = 0;\n\n    /**\n     * Preallocate up to maxCount buffers for a given output stream asynchronously.\n     */\n    virtual status_t        prepare2(int maxCount, int streamId) = 0;\n\n    /**\n     * Free all unused buffers for a given output stream.\n     */\n    virtual status_t        tearDown(int streamId) = 0;\n\n};\n\n// ----------------------------------------------------------------------------\n\nclass BnCameraDeviceUser: public BnInterface<ICameraDeviceUser>\n{\npublic:\n    virtual status_t    onTransact( uint32_t code,\n                                    const Parcel& data,\n                                    Parcel* reply,\n                                    uint32_t flags = 0);\n};\n\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "libshims/include/camera/camera2/OutputConfiguration.h",
    "content": "/*\n * Copyright (C) 2015 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H\n#define ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H\n\n#include <utils/RefBase.h>\n#include <gui/IGraphicBufferProducer.h>\n\nnamespace android {\n\nclass Surface;\n\nclass OutputConfiguration : public virtual RefBase {\npublic:\n\n    static const int INVALID_ROTATION;\n    sp<IGraphicBufferProducer> getGraphicBufferProducer() const;\n    int                        getRotation() const;\n\n    /**\n     * Keep impl up-to-date with OutputConfiguration.java in frameworks/base\n     */\n    status_t                   writeToParcel(Parcel& parcel) const;\n    // getGraphicBufferProducer will be NULL if error occurred\n    // getRotation will be INVALID_ROTATION if error occurred\n    OutputConfiguration(const Parcel& parcel);\n\n    OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation);\n\nprivate:\n    sp<IGraphicBufferProducer> mGbp;\n    int                        mRotation;\n\n    // helper function\n    static String16 readMaybeEmptyString16(const Parcel& parcel);\n};\n}; // namespace android\n\n#endif\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2013, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Array of light sensor LUX values to define our levels for auto backlight brightness support.\n         The N entries of this array define N  1 zones as follows:\n\n         Zone 0:        0 <= LUX < array[0]\n         Zone 1:        array[0] <= LUX < array[1]\n         ...\n         Zone N:        array[N - 1] <= LUX < array[N]\n         Zone N + 1     array[N] <= LUX < infinity\n\n         Must be overridden in platform specific overlays -->\n    <integer-array name=\"config_autoBrightnessLevels\">\n        <item>5</item>\n        <item>40</item>\n        <item>100</item>\n        <item>325</item>\n        <item>600</item>\n        <item>1250</item>\n        <item>2200</item>\n        <item>4000</item>\n        <item>10000</item>\n    </integer-array>\n\n    <!-- Array of output values for LCD backlight corresponding to the LUX values\n         in the config_autoBrightnessLevels array.  This array should have size one greater\n         than the size of the config_autoBrightnessLevels array.\n         This must be overridden in platform specific overlays -->\n    <integer-array name=\"config_autoBrightnessLcdBacklightValues\">\n        <item>11</item>\n        <item>22</item>\n        <item>47</item>\n        <item>61</item>\n        <item>84</item>\n        <item>107</item>\n        <item>154</item>\n        <item>212</item>\n        <item>245</item>\n        <item>255</item>\n    </integer-array>\n\n    <!-- Minimum screen brightness allowed by the power manager. -->\n    <integer name=\"config_screenBrightnessDim\">6</integer>\n\n    <!-- Minimum screen brightness setting allowed by the power manager.\n         The user is forbidden from setting the brightness below this level. -->\n    <integer name=\"config_screenBrightnessSettingMinimum\">1</integer>\n\n    <!-- Default screen brightness setting.\n         Must be in the range specified by minimum and maximum. -->\n    <integer name=\"config_screenBrightnessSettingDefault\">55</integer>\n\n    <!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->\n    <bool name=\"config_intrusiveNotificationLed\">true</bool>\n\n    <!-- Is the battery LED intrusive? Used to decide if there should be a disable option -->\n    <bool name=\"config_intrusiveBatteryLed\">true</bool>\n\n    <!-- Button illumination -->\n    <bool name=\"config_deviceHasVariableButtonBrightness\">true</bool>\n\n    <!-- Vibrator pattern for feedback about a long screen/key press -->\n    <integer-array name=\"config_longPressVibePattern\">\n        <item>0</item>\n        <item>1</item>\n        <item>20</item>\n        <item>21</item>\n    </integer-array>\n\n    <!-- Vibrator pattern for feedback about touching a virtual key -->\n    <integer-array name=\"config_virtualKeyVibePattern\">\n        <item>0</item>\n        <item>10</item>\n        <item>20</item>\n        <item>30</item>\n    </integer-array>\n\n    <!-- Vibrator pattern for a very short but reliable vibration for soft keyboard tap -->\n    <integer-array name=\"config_keyboardTapVibePattern\">\n        <item>40</item>\n    </integer-array>\n\n    <!-- When true use the linux /dev/input/event subsystem to detect the switch changes\n     on the headphone/microphone jack. When false use the older uevent framework -->\n    <bool name=\"config_useDevInputEventForAudioJack\">true</bool>\n\n    <!-- Set to true to add links to Cell Broadcast app from Settings and MMS app. -->\n    <bool name=\"config_cellBroadcastAppLinks\">true</bool>\n\n    <!-- Hardware keys present on the device, stored as a bit field.\n         This integer should equal the sum of the corresponding value for each\n         of the following keys present:\n             1 - Home\n             2 - Back\n             4 - Menu\n             8 - Assistant (search)\n            16 - App switch\n            32 - Camera\n            64 - Volume rocker\n         For example, a device with Home, Back and Menu keys would set this\n         config to 7. -->\n    <integer name=\"config_deviceHardwareKeys\">83</integer>\n\n    <!-- Hardware keys present on the device with the ability to wake, stored as a bit field.\n         This integer should equal the sum of the corresponding value for each\n         of the following keys present:\n             1 - Home\n             2 - Back\n             4 - Menu\n             8 - Assistant (search)\n            16 - App switch\n            32 - Camera\n            64 - Volume rocker\n         For example, a device with Home, Back and Menu keys would set this\n         config to 7. -->\n    <integer name=\"config_deviceHardwareWakeKeys\">64</integer>\n\n    <!-- Control the behavior when the user long presses the home button\n            0 - Nothing\n            1 - Menu key\n            2 - Recent apps view in SystemUI\n            3 - Launch assist intent\n            4 - Voice Search\n            5 - In-app Search\n        This needs to match the constants in\n        policy/src/com/android/internal/policy/impl/PhoneWindowManager.java\n    -->\n    <integer name=\"config_longPressOnHomeBehavior\">3</integer>\n\n    <!-- Control the behavior when the user long presses the app switch button.\n            0 - Nothing\n            1 - Menu key\n            2 - Recent apps view in SystemUI\n            3 - Launch assist intent\n            4 - Voice Search\n            5 - In-app Search\n         This needs to match the constants in\n         policy/src/com/android/internal/policy/impl/PhoneWindowManager.java\n    -->\n    <integer name=\"config_longPressOnAppSwitchBehavior\">1</integer>\n\n    <!-- Boolean indicating whether the wifi chipset has dual frequency band support -->\n    <bool translatable=\"false\" name=\"config_wifi_dual_band_support\">true</bool>\n\n    <!-- Wifi driver supports batched scan -->\n    <bool translatable=\"false\" name=\"config_wifi_batched_scan_supported\">true</bool>\n\n    <!-- Boolean indicating whether the wifi chipset supports background scanning mechanism.\n         This mechanism allows the host to remain in suspend state and the dongle to actively\n         scan and wake the host when a configured SSID is detected by the dongle. This chipset\n         capability can provide power savings when wifi needs to be always kept on. -->\n    <bool translatable=\"false\" name=\"config_wifi_background_scan_support\">true</bool>\n\n    <!-- This string array should be overridden by the device to present a list of network\n         attributes.  This is used by the connectivity manager to decide which networks can coexist\n         based on the hardware -->\n    <!-- An Array of \"[Connection name],[ConnectivityManager.TYPE_xxxx],\n         [associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet]  -->\n    <!-- the 5th element \"resore-time\" indicates the number of milliseconds to delay\n         before automatically restore the default connection.  Set -1 if the connection\n         does not require auto-restore. -->\n    <!-- the 6th element indicates boot-time dependency-met value. -->\n    <string-array translatable=\"false\" name=\"networkAttributes\">\n        <item>wifi,1,1,1,-1,true</item>\n        <item>mobile,0,0,0,-1,true</item>\n        <item>mobile_mms,2,0,4,60000,true</item>\n        <item>mobile_supl,3,0,2,60000,true</item>\n        <item>mobile_dun,4,0,2,60000,true</item>\n        <item>mobile_hipri,5,0,3,60000,true</item>\n        <item>mobile_fota,10,0,2,60000,true</item>\n        <item>mobile_ims,11,0,2,60000,true</item>\n        <item>mobile_cbs,12,0,2,60000,true</item>\n        <item>bluetooth,7,7,2,-1,true</item>\n        <item>ethernet,9,9,9,-1,true</item>\n    </string-array>\n\n    <!-- This string array should be overridden by the device to present a list of radio\n         attributes.  This is used by the connectivity manager to decide which networks can coexist\n         based on the hardware -->\n    <!-- An Array of \"[ConnectivityManager connectionType],\n                      [# simultaneous connection types]\"  -->\n    <string-array translatable=\"false\" name=\"radioAttributes\">\n       <item>\"1,1\"</item>\n       <item>\"0,1\"</item>\n       <item>\"7,1\"</item>\n    </string-array>\n\n    <!-- List of regexpressions describing the interface (if any) that represent tetherable\n         USB interfaces.  If the device doesn't want to support tething over USB this should\n         be empty.  An example would be \"usb.*\" -->\n    <string-array translatable=\"false\" name=\"config_tether_usb_regexs\">\n        <item>\"usb\\\\d\"</item>\n        <item>\"rndis\\\\d\"</item>\n    </string-array>\n\n    <!-- List of regexpressions describing the interface (if any) that represent tetherable\n         Wifi interfaces.  If the device doesn't want to support tethering over Wifi this\n         should be empty.  An example would be \"softap.*\" -->\n    <string-array translatable=\"false\" name=\"config_tether_wifi_regexs\">\n        <item>\"wlan0\"</item>\n    </string-array>\n\n    <!-- List of regexpressions describing the interface (if any) that represent tetherable\n         bluetooth interfaces.  If the device doesn't want to support tethering over bluetooth this\n         should be empty. -->\n    <string-array translatable=\"false\" name=\"config_tether_bluetooth_regexs\">\n        <item>\"bnep\\\\d\"</item>\n        <item>\"bt-pan\"</item>\n    </string-array>\n\n    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->\n    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or\n    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->\n    <integer-array translatable=\"false\" name=\"config_tether_upstream_types\">\n        <item>0</item>\n        <item>1</item>\n        <item>4</item>\n        <item>5</item>\n        <item>7</item>\n    </integer-array>\n\n    <!-- Boolean indicddating if restoring network selection should be skipped -->\n    <!-- The restoring is handled by modem if it is true -->\n    <bool name=\"skip_restoring_network_selection\">true</bool>\n\n    <!-- MMS user agent string -->\n    <string name=\"config_mms_user_agent\" translatable=\"false\">Android-Mms/2.0</string>\n\n    <!-- MMS user agent prolfile url -->\n    <string name=\"config_mms_user_agent_profile_url\" translatable=\"false\"\n            >http://www.google.com/oha/rdf/ua-profile-kila.xml</string>\n\n    <!-- Flag indicating if the speed up audio on mt call code should be executed -->\n    <bool name=\"config_speed_up_audio_on_mt_calls\">true</bool>\n\n    <!-- If this is true, the screen will come on when you unplug usb/power/whatever. -->\n    <bool name=\"config_unplugTurnsOnScreen\">true</bool>\n\n    <!-- Whether WiFi display is supported by this device.\n         There are many prerequisites for this feature to work correctly.\n         Here are a few of them:\n         * The WiFi radio must support WiFi P2P.\n         * The WiFi radio must support concurrent connections to the WiFi display and\n           to an access point.\n         * The Audio Flinger audio_policy.conf file must specify a rule for the \"r_submix\"\n           remote submix module.  This module is used to record and stream system\n           audio output to the WiFi display encoder in the media server.\n         * The remote submix module \"audio.r_submix.default\" must be installed on the device.\n         * The device must be provisioned with HDCP keys (for protected content).\n    -->\n    <bool name=\"config_enableWifiDisplay\">true</bool>\n\n    <!-- Set to true to add links to Cell Broadcast app from Settings and MMS app. -->\n    <bool name=\"config_cellBroadcastAppLinks\">true</bool>\n\n    <!-- Set to true if the wifi display supports compositing content stored\n         in gralloc protected buffers.  For this to be true, there must exist\n         a protected hardware path for surface flinger to composite and send\n         protected buffers to the wifi display video encoder.\n\n         If this flag is false, we advise applications not to use protected\n         buffers (if possible) when presenting content to a wifi display because\n         the content may be blanked.\n\n         This flag controls whether the {@link Display#FLAG_SUPPORTS_PROTECTED_BUFFERS}\n         flag is set for wifi displays.\n    -->\n    <bool name=\"config_wifiDisplaySupportsProtectedBuffers\">true</bool>\n\n    <!-- Device specific options -->\n\n    <!-- Flag indicating whether the we should enable the automatic brightness in Settings.\n         Software implementation will be used if config_hardware_auto_brightness_available is not set -->\n    <bool name=\"config_automatic_brightness_available\">true</bool>\n\n    <!-- Indicate whether closing the lid causes the device to go to sleep and opening\n         it causes the device to wake up.\n         The default is false. -->\n    <bool name=\"config_lidControlsSleep\">true</bool>\n\n    <!-- Indicate whether to allow the device to suspend when the screen is off\n         due to the proximity sensor.  This resource should only be set to true\n         if the sensor HAL correctly handles the proximity sensor as a wake-up source.\n         Otherwise, the device may fail to wake out of suspend reliably.\n         The default is false. -->\n    <bool name=\"config_suspendWhenScreenOffDueToProximity\">true</bool>\n\n    <!-- Is the device capable of hot swapping an ICC Card -->\n    <bool name=\"config_hotswapCapable\">true</bool>\n\n    <!-- Flag specifying whether VoLTE & VT is available on device -->\n    <bool name=\"config_device_volte_available\">true</bool>\n\n    <!-- Flag specifying whether VoLTE should be available for carrier: independent of\n         carrier provisioning. If false: hard disabled. If true: then depends on carrier\n         provisioning, availability etc -->\n    <bool name=\"config_carrier_volte_available\">true</bool>\n\n    <!-- Flag specifying whether VT is available on device -->\n    <bool name=\"config_device_vt_available\">true</bool>\n\n    <!-- Flag specifying whether VT should be available for carrier: independent of\n         carrier provisioning. If false: hard disabled. If true: then depends on carrier\n         provisioning, availability etc -->\n    <bool name=\"config_carrier_vt_available\">true</bool>\n\n    <!--  Maximum number of supported users -->\n    <integer name=\"config_multiuserMaximumUsers\">4</integer>\n    <!--  Whether Multiuser UI should be shown -->\n    <bool name=\"config_enableMultiUserUI\">true</bool>\n\n    <!-- Screen brightness used to dim the screen while dozing in a very low power state.\n         May be less than the minimum allowed brightness setting\n         that can be set by the user. -->\n    <integer name=\"config_screenBrightnessDoze\">17</integer>\n\n    <!-- If true, the doze component is not started until after the screen has been\n          turned off and the screen off animation has been performed. -->\n    <bool name=\"config_dozeAfterScreenOff\">true</bool>\n\n    <!-- Power Management: Specifies whether to decouple the interactive state of the\n         device from the display on/off state.\n         When false, setInteractive(..., true) will be called before the display is turned on\n         and setInteractive(..., false) will be called after the display is turned off.\n         This mode provides best compatibility for devices that expect the interactive\n         state to be tied to the display state.\n         When true, setInteractive(...) will be called independently of whether the display\n         is being turned on or off.  This mode enables the power manager to reduce\n         clocks and disable the touch controller while the display is on.\n         This resource should be set to \"true\" when a doze component has been specified\n         to maximize power savings but not all devices support it.\n         Refer to power.h for details.\n    -->\n    <bool name=\"config_powerDecoupleInteractiveModeFromDisplay\">true</bool>\n\n    <string name=\"config_dozeComponent\">com.android.systemui/com.android.systemui.doze.DozeService</string>\n\n    <!-- Whether device supports double tap to wake -->\n    <bool name=\"config_supportDoubleTapWake\">true</bool>\n\n    <string-array name=\"config_mobile_tcp_buffers\">\n        <item>lte:2097152,4194304,8388608,262144,524288,1048576</item>\n        <item>lte_ca:2097152,4194304,8388608,262144,524288,1048576</item>\n        <item>umts:4094,87380,1220608,4096,16384,1220608</item>\n        <item>hspa:4094,87380,1220608,4096,16384,1220608</item>\n        <item>hsupa:4094,87380,1220608,4096,16384,1220608</item>\n        <item>hsdpa:4094,87380,1220608,4096,16384,1220608</item>\n        <item>hspap:4094,87380,1220608,4096,16384,1220608</item>\n        <item>edge:4093,26280,35040,4096,16384,35040</item>\n        <item>gprs:4092,8760,11680,4096,8760,11680</item>\n        <item>evdo:4094,87380,524288,4096,16384,262144</item>\n    </string-array>\n\n    <!-- Configure wifi tcp buffersizes in the form:\n         rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max -->\n    <string name=\"config_wifi_tcp_buffers\" translatable=\"false\">524288,2097152,4194304,262144,524288,1048576</string>\n\n    <!-- Boolean indicating if current platform supports BLE peripheral mode -->\n    <bool name=\"config_bluetooth_le_peripheral_mode_supported\">true</bool>\n\n    <!-- Operating volatage for bluetooth controller. -->\n    <integer name=\"config_bluetooth_operating_voltage_mv\">3300</integer>\n\n    <!-- Set this to true to enable the platform's auto-power-save modes like doze and\n         app standby.  These are not enabled by default because they require a standard\n         cloud-to-device messaging service for apps to interact correctly with the modes\n         (such as to be able to deliver an instant message to the device even when it is\n         dozing).  This should be enabled if you have such services and expect apps to\n         correctly use them when installed on your device.  Otherwise, keep this disabled\n         so that applications can still use their own mechanisms. -->\n    <bool name=\"config_enableAutoPowerModes\">true</bool>\n\n    <!-- Enable overlay for all location components. -->\n    <string name=\"config_networkLocationProviderPackageName\" translatable=\"false\">com.qualcomm.location</string>\n    <string name=\"config_fusedLocationProviderPackageName\" translatable=\"false\">com.qualcomm.location</string>\n\n    <!-- Default list of files pinned by the Pinner Service -->\n    <string-array translatable=\"false\" name=\"config_defaultPinnerServiceFiles\">\n        <item>\"/system/framework/arm64/boot-framework.oat\"</item>\n        <item>\"/system/framework/oat/arm64/services.odex\"</item>\n        <item>\"/system/framework/arm64/boot.oat\"</item>\n        <item>\"/system/framework/arm64/boot-core-libart.oat\"</item>\n   </string-array>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc204-mnc04/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <!-- VZW -->\n        <item>*86;BAE0000000000000</item>\n    </string-array>\n\n    <!-- Use ERI text for network name on CDMA LTE -->\n    <bool name=\"config_LTE_eri_for_network_name\">false</bool>\n\n    <!-- String containing the apn value for tethering.  May be overriden by secure settings\n         TETHER_DUN_APN.  Value is a comma separated series of strings:\n         \"name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type\",\n         Or string format of ApnSettingV3.\n         note that empty fields can be ommitted: \"name,apn,,,,,,,,,310,260,,DUN\" -->\n    <string-array translatable=\"false\" name=\"config_tether_apndata\">\n        <item>[ApnSettingV3]HOT mobile PC,pc.hotm,,,,,,,,,204,04,,DUN,,,true,0,,,,,,,spn,HOT mobile</item>\n    </string-array>\n\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK</string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc208-mnc10/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- String containing the apn value for tethering.  May be overriden by secure settings\n         TETHER_DUN_APN.  Value is a comma separated series of strings:\n         \"name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type\",\n         Or string format of ApnSettingV3.\n         note that empty fields can be ommitted: \"name,apn,,,,,,,,,310,260,,DUN\" -->\n    <string-array translatable=\"false\" name=\"config_tether_apndata\">\n        <item>SFR option modem,websfr,,,,,,,,,208,10,,DUN</item>\n        <item>[ApnSettingV3]INTERNET NRJ,internetnrj,,,,,,,,,208,10,,DUN,,,true,0,,,,,,,gid,4E</item>\n        <item>[ApnSettingV3]Auchan,wap65,,,,,,,,,208,10,,DUN,,,true,0,,,,,,,spn,A MOBILE</item>\n        <item>[ApnSettingV3]LeclercMobile,wap66,,,,,,,,,208,10,,DUN,,,true,0,,,,,,,spn,LeclercMobile</item>\n        <item>[ApnSettingV3]Coriolis,fnetcoriolis,,,,,,,,,208,10,,DUN,,,true,0,,,,,,,gid,12</item>\n        <item>[ApnSettingV3]La Poste Mobile modem,websfr,,,,,,,,,208,10,,DUN,,,true,0,,,,,,,gid,4C</item>\n        <item>[ApnSettingV3]Darty Surf Mails,wap68,,,,,,,,,208,10,,DUN,,,true,0,,,,,,,gid,44</item>\n    </string-array>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc214-mnc01/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc234-mnc15/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>121</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc262-mnc01/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>3311</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc262-mnc07/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>+491793000333</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc262-mnc08/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>+491793000333</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc268-mnc01/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc302-mnc220/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Values for TELUS GPS configuration -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.telusmobility.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>LPP_PROFILE=2</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=0</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc302-mnc370/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- String containing the apn value for tethering.  May be overriden by secure settings\n         TETHER_DUN_APN.  Value is a comma separated series of strings:\n         \"name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type\",\n         Or string format of ApnSettingV3.\n         note that empty fields can be ommitted: \"name,apn,,,,,,,,,310,260,,DUN\" -->\n    <string-array translatable=\"false\" name=\"config_tether_apndata\">\n        <item>[ApnSettingV3]Fido Tethering,ltedata.apn,,,,,,,,,302,370,,DUN,IPV4V6,,true,,,,,,,,,</item>\n    </string-array>\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc302-mnc610/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <!-- Values for GPS configuration (Bell) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>LPP_PROFILE=2</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=0</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc302-mnc720/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- String containing the apn value for tethering.  May be overriden by secure settings\n         TETHER_DUN_APN.  Value is a comma separated series of strings:\n         \"name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type\",\n         Or string format of ApnSettingV3.\n         note that empty fields can be ommitted: \"name,apn,,,,,,,,,310,260,,DUN\" -->\n    <string-array translatable=\"false\" name=\"config_tether_apndata\">\n        <item>[ApnSettingV3]Rogers Tethering,ltedata.apn,,,,,,,,,302,720,,DUN,IPV4V6,IPV4V6,true,,,,,,,,,</item>\n    </string-array>\n\n    <!-- Values for GPS configuration (Rogers) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>LPP_PROFILE=2</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=0</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc004/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>*86</item>\n    </string-array>\n\n    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->\n    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or\n    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->\n    <integer-array translatable=\"false\" name=\"config_tether_upstream_types\">\n        <item>1</item>\n        <item>4</item>\n        <item>7</item>\n        <item>9</item>\n    </integer-array>\n\n    <!-- Use ERI text for network name on CDMA LTE -->\n    <bool name=\"config_LTE_eri_for_network_name\">false</bool>\n\n    <!-- Values for GPS configuration (Verizon) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>LPP_PROFILE=3</item>\n        <item>GPS_LOCK=3</item>\n        <item>SUPL_MODE=0</item>\n        <item>SUPL_ES=1</item>\n    </string-array>\n\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK</string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc070/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc090/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc120/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- The VoiceMail default value is displayed to my own number if it is true -->\n    <bool name=\"config_telephony_use_own_number_for_voicemail\">true</bool>\n\n    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->\n    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or\n    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->\n    <integer-array translatable=\"false\" name=\"config_tether_upstream_types\">\n        <item>1</item>\n        <item>4</item>\n        <item>7</item>\n        <item>9</item>\n    </integer-array>\n\n    <!-- Default network policy warning threshold, in megabytes. -->\n    <integer name=\"config_networkPolicyDefaultWarning\">51200</integer>\n\n    <!-- Sometimes, PDU has garbages. So, need to use valid index -->\n    <integer name=\"config_valid_wappush_index\">4</integer>\n\n    <!-- Values for GPS configuration (Sprint) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n\n    <!-- sms encoded as octet is decoded by utf8 decoder. if it is true -->\n    <bool name=\"config_sms_utf8_support\">true</bool>\n\n    <!-- Sprint need a 3s delay for 3way call -->\n    <integer name=\"config_cdma_3waycall_flash_delay\">300</integer>\n\n\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc150/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc170/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc260/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->\n    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or\n    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->\n    <integer-array translatable=\"false\" name=\"config_tether_upstream_types\">\n        <item>1</item>\n        <item>4</item>\n        <item>7</item>\n        <item>9</item>\n    </integer-array>\n\n    <!-- String containing the apn value for tethering.  May be overriden by secure settings\n     TETHER_DUN_APN.  Value is a comma separated series of strings:\n     \"name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type\"\n     note that empty fields can be ommitted: \"name,apn,,,,,,,,,310,260,,DUN\" -->\n    <string-array translatable=\"false\" name=\"config_tether_apndata\">\n        <item>T-Mobile Tethering,pcweb.tmobile.com,,,,,,,,,310,260,,DUN</item>\n        <item>[ApnSettingV3]MetroPCS Tethering,pcweb.metropcs.com,,,,,,,,,310,260,,DUN,,,true,0,,,,,,,gid,6D</item>\n    </string-array>\n\n    <!-- Configure mobile tcp buffer sizes in the form:\n         rat-name:rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max\n         If no value is found for the rat-name in use, the system default will be applied.\n    -->\n    <string-array name=\"config_mobile_tcp_buffers\">\n        <item>umts:21135,131070,1056768,6144,24576,165312</item>\n        <item>hspa:18300,131070,1056768,6144,24576,393216</item>\n        <item>hsdpa:18300,131070,1056768,6144,24576,393216</item>\n        <item>hsupa:6141,131070,1056768,6144,24576,393216</item>\n        <item>hspap:31455,131070,1830912,6144,24576,1830912</item>\n        <item>edge:8192,26280,704512,4096,16384,110208</item>\n        <item>gprs:8192,8760,704512,4096,8760,110208</item>\n        <item>lte:786432,1572864,3840000,786432,1572864,3840000</item>\n    </string-array>\n\n    <!-- Values for GPS configuration (T-Mobile) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=1</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc380/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc410/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Configure mobile tcp buffer sizes in the form:\n         rat-name:rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max\n         If no value is found for the rat-name in use, the system default will be applied.\n    -->\n    <string-array name=\"config_mobile_tcp_buffers\">\n        <item>umts:131072,262144,1452032,4096,16384,399360</item>\n        <item>hspa:131072,262144,1452032,4096,16384,399360</item>\n        <item>hsdpa:131072,262144,1452032,4096,16384,399360</item>\n        <item>hsupa:131072,262144,1452032,4096,16384,399360</item>\n        <item>hspap:131072,262144,1452032,4096,16384,399360</item>\n        <item>edge:4093,26280,35040,4096,16384,35040</item>\n        <item>gprs:4092,8760,11680,4096,8760,11680</item>\n        <item>evdo:4094,87380,262144,4096,16384,262144</item>\n        <item>lte:524288,1048576,8388608,262144,524288,4194304</item>\n    </string-array>\n\n    <!-- Values for GPS configuration (AT&T) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=1</item>\n        <item>LPP_PROFILE=3</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n\n    <!-- If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 this is the Values\n         that should be used instead. A value of RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means\n         there is no replacement value and VoLTE is assumed to be supported -->\n    <integer name=\"config_volte_replacement_rat\">3</integer>\n\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc560/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc310-mnc680/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc180/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc220/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc221/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc222/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc223/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc224/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc225/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=1</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc226/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc227/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc228/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc229/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc480/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>*86</item>\n    </string-array>\n\n    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->\n    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or\n    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->\n    <integer-array translatable=\"false\" name=\"config_tether_upstream_types\">\n        <item>1</item>\n        <item>4</item>\n        <item>7</item>\n        <item>9</item>\n    </integer-array>\n\n    <!-- Use ERI text for network name on CDMA LTE -->\n    <bool name=\"config_LTE_eri_for_network_name\">false</bool>\n\n    <!-- Values for GPS configuration (Verizon) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=3</item>\n        <item>SUPL_MODE=0</item>\n        <item>SUPL_ES=1</item>\n    </string-array>\n\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc490/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <!-- The VoiceMail default value is displayed to my own number if it is true -->\n    <bool name=\"config_telephony_use_own_number_for_voicemail\">true</bool>\n\n    <!-- Configure mobile network MTU. Carrier specific value is set here. -->\n    <integer name=\"config_mobile_mtu\">1422</integer>\n\n    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->\n    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or\n    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->\n    <integer-array translatable=\"false\" name=\"config_tether_upstream_types\">\n      <item>1</item>\n      <item>4</item>\n      <item>7</item>\n      <item>9</item>\n    </integer-array>\n\n    <!-- Default network policy warning threshold, in megabytes. -->\n    <integer name=\"config_networkPolicyDefaultWarning\">51200</integer>\n\n    <!-- Values for GPS configuration (Sprint) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n\n    <!-- Sprint need a 3s delay for 3way call -->\n    <integer name=\"config_cdma_3waycall_flash_delay\">300</integer>\n\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc580/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc581/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc582/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc583/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc584/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc585/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc586/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc587/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc588/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc589/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (US Cellular) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc311-mnc870/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <!-- The VoiceMail default value is displayed to my own number if it is true -->\n    <bool name=\"config_telephony_use_own_number_for_voicemail\">true</bool>\n\n    <!-- Configure mobile network MTU. Carrier specific value is set here. -->\n    <integer name=\"config_mobile_mtu\">1422</integer>\n\n    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->\n    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or\n    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->\n    <integer-array translatable=\"false\" name=\"config_tether_upstream_types\">\n      <item>1</item>\n      <item>4</item>\n      <item>7</item>\n      <item>9</item>\n    </integer-array>\n\n    <!-- Default network policy warning threshold, in megabytes. -->\n    <integer name=\"config_networkPolicyDefaultWarning\">51200</integer>\n\n    <!-- Values for GPS configuration (Sprint) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>SUPL_HOST=supl.google.com</item>\n        <item>SUPL_PORT=7275</item>\n        <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra3grc.bin</item>\n        <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra3grc.bin</item>\n        <item>NTP_SERVER=north-america.pool.ntp.org</item>\n        <item>SUPL_VER=0x20000</item>\n        <item>NMEA_PROVIDER=0</item>\n        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>\n        <item>ERR_ESTIMATE=0</item>\n        <item>INTERMEDIATE_POS=0</item>\n        <item>GPS_LOCK=3</item>\n        <item>LPP_PROFILE=2</item>\n        <item>SUPL_MODE=1</item>\n        <item>SUPL_ES=0</item>\n    </string-array>\n\n    <!-- Sprint need a 3s delay for 3way call -->\n    <integer name=\"config_cdma_3waycall_flash_delay\">300</integer>\n\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc312-mnc530/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Entitlement APP provisioning for Tethering -->\n    <string-array translatable=\"false\" name=\"config_mobile_hotspot_provision_app\">\n        <item>com.google.android.carrierentitlement</item>\n        <item>com.google.android.carrierentitlement.CarrierEntitlementActivity</item>\n    </string-array>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_app_no_ui\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK\n    </string>\n    <string translatable=\"false\" name=\"config_mobile_hotspot_provision_response\">\n         com.google.android.carrierentitlement.SILENT_ENTITLEMENT_CHECK_RESULT\n    </string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc316-mnc010/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Configure mobile network MTU. Carrier specific value is set here.\n    -->\n    <integer name=\"config_mobile_mtu\">1422</integer>\n\n    <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->\n    <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or\n    <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->\n    <integer-array translatable=\"false\" name=\"config_tether_upstream_types\">\n      <item>1</item>\n      <item>4</item>\n      <item>7</item>\n      <item>9</item>\n    </integer-array>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc330-mnc110/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc334-mnc020/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc334-mnc050/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc334-mnc090/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n\n    <!-- String containing the apn value for tethering.  May be overriden by secure settings\n         TETHER_DUN_APN.  Value is a comma separated series of strings:\n         \"name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type\",\n         Or string format of ApnSettingV3.\n         note that empty fields can be ommitted: \"name,apn,,,,,,,,,310,260,,DUN\" -->\n    <string-array translatable=\"false\" name=\"config_tether_apndata\">\n      <item>Modem,modem.nexteldata.com.mx,,,,,,,,,334,090,,DUN</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc334-mnc30/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc370-mnc02/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc404-mnc01/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources>\n    <bool name=\"config_use_sim_language_file\">false</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc840/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc840/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc854/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc855/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc855/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc856/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc856/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc857/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc857/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc858/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc858/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc859/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc859/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc860/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc860/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc861/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc861/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc862/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc862/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc863/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc863/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc864/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc864/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc865/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc865/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc866/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc866/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc867/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc867/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc868/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc868/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc869/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc869/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc870/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc870/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc871/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc871/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc872/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc872/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc873/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc873/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc874/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <!-- Values for GPS configuration (Reliance) -->\n    <string-array translatable=\"false\" name=\"config_gpsParameters\">\n        <item>LPP_PROFILE=2</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc405-mnc874/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <!-- Template for showing cellular network operator name while WFC is active -->\n    <string name=\"wfcSpnFormat\">Wi-Fi Calling</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc505-mnc01/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>+61101</item>\n    </string-array>\n\n    <bool name=\"config_auto_attach_data_on_creation\">false</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc505-mnc11/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>+61101</item>\n    </string-array>\n\n    <bool name=\"config_auto_attach_data_on_creation\">false</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc505-mnc71/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>+61101</item>\n    </string-array>\n\n    <bool name=\"config_auto_attach_data_on_creation\">false</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc505-mnc72/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <string-array translatable=\"false\" name=\"config_default_vm_number\">\n        <item>+61101</item>\n    </string-array>\n\n    <bool name=\"config_auto_attach_data_on_creation\">false</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc706-mnc01/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc712-mnc03/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc714-mnc03/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc716-mnc06/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc716-mnc10/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc716-mnc17/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc722-mnc02/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc722-mnc07/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc722-mnc310/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc722-mnc34/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n\n    <!-- String containing the apn value for tethering.  May be overriden by secure settings\n         TETHER_DUN_APN.  Value is a comma separated series of strings:\n         \"name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type\",\n         Or string format of ApnSettingV3.\n         note that empty fields can be ommitted: \"name,apn,,,,,,,,,310,260,,DUN\" -->\n    <string-array translatable=\"false\" name=\"config_tether_apndata\">\n        <item>Personal Internet Movil,internet.personal.com,,,internet,internet,,,,,722,34,1,DUN</item>\n    </string-array>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc722-mnc340/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc722-mnc341/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc722-mnc36/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc02/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc03/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc04/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc05/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc06/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc10/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc11/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc16/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc23/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc24/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc31/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc724-mnc39/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc730-mnc01/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc730-mnc02/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc730-mnc09/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc730-mnc10/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc732-mnc101/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc732-mnc103/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc732-mnc111/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc732-mnc12/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc732-mnc123/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc732-mnc130/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc734-mnc04/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc740-mnc01/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc744-mnc02/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/values-mcc748-mnc10/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2016, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n    <bool name=\"config_sms_force_7bit_encoding\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/core/res/res/xml/power_profile.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n**\n** Copyright 2009, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\")\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<device name=\"Android\">\n    <!-- All values are in mAh except as noted -->\n    <item name=\"none\">0</item>\n    <item name=\"screen.on\">80</item>\n    <item name=\"screen.full\">240</item>\n    <item name=\"bluetooth.active\">93.5</item>\n    <item name=\"bluetooth.on\">1</item>\n    <item name=\"wifi.on\">1</item>\n    <item name=\"wifi.active\">115</item>\n    <item name=\"wifi.scan\">200</item>\n    <item name=\"dsp.audio\">30</item>\n    <item name=\"dsp.video\">123</item>\n    <item name=\"gps.on\">90</item>\n    <!-- The current consumed by the radio when it is scanning for a signal -->\n    <item name=\"radio.active\">159</item>\n    <item name=\"radio.scanning\">41</item>\n    <!-- Current consumed by the radio at different signal strengths, when paging -->\n    <array name=\"radio.on\"> <!-- Strength 0 to BINS-1 -->\n        <value>3.9</value>\n        <value>2.8</value>\n    </array>\n\n    <!-- Different CPU speeds as reported in\n         /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state -->\n    <array name=\"cpu.speeds.cluster0\">\n        <value>384000</value> <!-- 384 MHz CPU speed -->\n        <value>460800</value> <!-- 460.8 MHz CPU speed -->\n        <value>600000</value> <!-- 600 MHz CPU speed -->\n        <value>672000</value> <!-- 672 MHz CPU speed -->\n        <value>768000</value> <!-- 768 MHz CPU speed -->\n        <value>864000</value> <!-- 864 MHz CPU speed -->\n        <value>960000</value> <!-- 960 MHz CPU speed -->\n        <value>1248000</value> <!-- 1248 MHz CPU speed -->\n        <value>1344000</value> <!-- 1344 MHz CPU speed -->\n        <value>1478400</value> <!-- 1478.4 MHz CPU speed -->\n        <value>1555200</value> <!-- 1555.2 MHz CPU speed -->\n    </array>\n    <array name=\"cpu.speeds.cluster1\">\n        <value>384000</value> <!-- 384 MHz CPU speed -->\n        <value>480000</value> <!-- 480 MHz CPU speed -->\n        <value>633600</value> <!-- 633.6 MHz CPU speed -->\n        <value>768000</value> <!-- 768 MHz CPU speed -->\n        <value>864000</value> <!-- 864 MHz CPU speed -->\n        <value>960000</value> <!-- 960 MHz CPU speed -->\n        <value>1248000</value> <!-- 1248 MHz CPU speed -->\n        <value>1344000</value> <!-- 1344 MHz CPU speed -->\n        <value>1440000</value> <!-- 1440 MHz CPU speed -->\n        <value>1536000</value> <!-- 1536 MHz CPU speed -->\n        <value>1632000</value> <!-- 1632 MHz CPU speed -->\n        <value>1766000</value> <!-- 1766 MHz CPU speed -->\n    </array>\n    <!-- Power consumption when CPU is idle -->\n    <item name=\"cpu.idle\">5.58</item>\n    <item name=\"cpu.awake\">4.92</item>\n    <!-- Power consumption at different speeds -->\n    <array name=\"cpu.active.cluster0\">\n        <value>24.14</value> <!-- 384 MHz CPU speed -->\n        <value>27.2</value> <!-- 460.8 MHz CPU speed -->\n        <value>32.3</value> <!-- 600 MHz CPU speed -->\n        <value>36.94</value> <!-- 672 MHz CPU speed -->\n        <value>41.57</value> <!-- 768 MHz CPU speed -->\n        <value>49.87</value> <!-- 864 MHz CPU speed -->\n        <value>57.84</value> <!-- 960 MHz CPU speed -->\n        <value>79.8</value> <!-- 1248 MHz CPU speed -->\n        <value>88.81</value> <!-- 1344 MHz CPU speed -->\n        <value>102.4</value> <!-- 1478.4 MHz CPU speed -->\n        <value>110.9</value> <!-- 1555.2 MHz CPU speed -->\n    </array>\n    <array name=\"cpu.active.cluster1\">\n        <value>86.83</value> <!-- 384 MHz CPU speed -->\n        <value>103.24</value> <!-- 480 MHz CPU speed -->\n        <value>129.38</value> <!-- 633.6 MHz CPU speed -->\n        <value>155.42</value> <!-- 768 MHz CPU speed -->\n        <value>177.99</value> <!-- 864 MHz CPU speed -->\n        <value>195.55</value> <!-- 960 MHz CPU speed -->\n        <value>265.09</value> <!-- 1248 MHz CPU speed -->\n        <value>292.77</value> <!-- 1344 MHz CPU speed -->\n        <value>322.13</value> <!-- 1440 MHz CPU speed -->\n        <value>348.19</value> <!-- 1536 MHz CPU speed -->\n        <value>370.18</value> <!-- 1632 MHz CPU speed -->\n        <value>405.51</value> <!-- 1766 MHz CPU speed -->\n    </array>\n    <array name=\"cpu.clusters.cores\">\n        <value>4</value> <!-- Cluster 0 has 4 cores (cpu0, cpu1, cpu2, cpu3) -->\n        <value>4</value> <!-- Cluster 1 has 4 cores (cpu4, cpu5, cpu6, cpu7) -->\n    </array>\n\n    <!-- This is the battery capacity in mAh -->\n    <item name=\"battery.capacity\">3300</item>\n\n    <array name=\"wifi.batchedscan\"> <!-- mA.  Current figures based on .0801 s/c and 75.48mA while scanning -->\n        <value>.0002</value> <!-- 1-8/hr -->\n        <value>.002</value>  <!-- 9-64/hr -->\n        <value>.02</value>   <!-- 65-512/hr -->\n        <value>.2</value>    <!-- 513-4,096/hr -->\n        <value>2</value>    <!-- 4097-/hr -->\n    </array>\n</device>\n"
  },
  {
    "path": "overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/**\n * Copyright (c) 2012, The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n-->\n<resources>\n    <!-- 30 seconds for default screen timeout -->\n    <integer name=\"def_screen_off_timeout\">60000</integer>\n    <!-- Set the automatic brightness mode on by default -->\n    <bool name=\"def_screen_brightness_automatic_mode\">true</bool>\n    <!-- Default screen brightness, from 0 to 255. 87 is 34%. -->\n    <integer name=\"def_screen_brightness\">82</integer>\n</resources>\n"
  },
  {
    "path": "overlay/frameworks/base/packages/SystemUI/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2013, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds. -->\n<resources>\n\n    <!-- Doze: does this device support STATE_DOZE and STATE_DOZE_SUSPEND?  -->\n    <bool name=\"doze_display_state_supported\">true</bool>\n\n    <!-- Doze: when to pulse after a buzzworthy notification arrives -->\n    <string name=\"doze_pulse_schedule\" translatable=\"false\">10s,30s,60s,180s</string>\n\n    <!-- Doze: check proximity sensor before pulsing from intent? -->\n    <bool name=\"doze_proximity_check_before_pulse_intent\">true</bool>\n\n    <!-- Doze: pulse parameter - delay to wait for the screen to wake up after an intent -->\n    <integer name=\"doze_pulse_delay_in_intent\">0</integer>\n\n    <!-- Control whether status bar should distinguish HSPA data icon form UMTS\n    data icon on devices -->\n    <bool name=\"config_hspa_data_distinguishable\">true</bool>\n\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc030/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc070/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc080/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc150/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc170/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc280/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc380/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc410/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc560/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/frameworks/opt/telephony/resources/res/values-mcc310-mnc680/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n\n<!-- These resources are around just to allow their values to be customized\n     for different hardware and product builds.  Do not translate. -->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n    <!-- Configuration for displaying 14 digit IMEI Number -->\n</resources>\n\n"
  },
  {
    "path": "overlay/packages/apps/Bluetooth/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved.\n\n     Redistribution and use in source and binary forms, with or without\n     modification, are permitted (subject to the limitations in the\n     disclaimer below) provided that the following conditions are met:\n\n        * Redistributions of source code must retain the above copyright\n          notice, this list of conditions and the following disclaimer.\n        * Redistributions in binary form must reproduce the above\n          copyright notice, this list of conditions and the following\n          disclaimer in the documentation and/or other materials provided\n          with the distribution.\n        * Neither the name of the Linux Foundation nor the names of its\n          contributors may be used to endorse or promote products derived\n          from this software without specific prior written permission.\n\n     NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE\n     GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT\n     HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED\n     WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n     BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n     OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n     IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n<resources>\n    <bool name=\"profile_supported_hfpclient\">true</bool>\n    <bool name=\"profile_supported_avrcp_controller\">true</bool>\n    <bool name=\"profile_supported_a2dp_sink\">true</bool>\n    <bool name=\"profile_supported_sap\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/CarrierConfig/res/xml/vendor.xml",
    "content": "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<!--Copyright (c) 2016, The Linux Foundation. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n    * Neither the name of The Linux Foundation nor the names of its\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.-->\n\n<carrier_config_list>\n    <!-- Below are some sample filters for various scenarios.\n         You can have multiple carrier_config blocks.\n         blocks for various filters. For more info visit DefaultCarrierConfigService.java\n\n        <carrier_config mcc=\"1234\">\n        //Configs applicable for mcc=1234 and any mnc\n        </carrier_config>\n\n        <carrier_config mcc=\"1234\" mnc=\"678\">\n        //Configs applicable for mcc=1234 and mnc=678\n        </carrier_config>\n\n        <carrier_config device=\"msm8996\">\n        //Configs applicable for msms8996.\n        </carrier_config>-->\n\n    <carrier_config>\n        <boolean name=\"apn_expand_bool\" value=\"true\" />\n        <boolean name=\"world_phone_bool\" value=\"true\" />\n        <boolean name=\"allow_adding_apns_bool\" value=\"true\" />\n        <boolean name=\"hide_preferred_network_type_bool\" value=\"false\" />\n        <boolean name=\"show_cdma_choices_bool\" value=\"true\" />\n        <boolean name=\"allow_video_call_in_low_battery\" value=\"true\" />\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"false\" />\n        <!-- Determines whether UI extensions for video calls should be used or not -->\n        <boolean name=\"video_call_use_ext\" value=\"true\" />\n        <!-- Determines if a customized video ui support is required or not -->\n        <boolean name=\"use_custom_video_ui\" value=\"false\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"false\" />\n        <boolean name=\"config_carrier_cs_retry_available\" value=\"false\" />\n        <!-- Controls modify call capabilities\n             FALSE - default capabilities will be retained\n             TRUE - remove modify call capabilities which will hide modify call button -->\n        <boolean name=\"remove_modify_call_capability\" value=\"false\" />\n        <!-- Config to show/hide Video quality toast -->\n        <boolean name=\"show_video_quality_toast\" value=\"true\"/>\n        <!-- Config to show/hide call session event toast like player start/stop -->\n        <boolean name=\"show_call_session_event_toast\" value=\"true\"/>\n        <!-- Config to show/hide data usage toast -->\n        <boolean name=\"show_data_usage_toast\" value=\"true\"/>\n\n    </carrier_config>\n\n    <carrier_config mcc=\"222\" mnc=\"01\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"840\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"854\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"855\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"856\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"857\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"858\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"859\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"860\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"861\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"862\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"863\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"864\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"865\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"866\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"867\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"868\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"869\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"870\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"871\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"872\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"873\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"405\" mnc=\"874\">\n        <boolean name=\"config_display_wfc_mode\" value=\"false\" />\n        <int name=\"carrier_default_wfc_ims_mode_int\" value=\"2\" />\n        <boolean name=\"video_call_use_ext\" value=\"false\" />\n        <boolean name=\"use_custom_video_ui\" value=\"true\" />\n        <boolean name=\"config_hide_preview_in_vt_confcall\" value=\"true\" />\n        <boolean name=\"config_carrier_specific_network_type_display\" value=\"true\"/>\n        <boolean name=\"remove_modify_call_capability\" value=\"true\" />\n        <boolean name=\"config_dds_switch_alert_dialog_supported\" value=\"true\"/>\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"450\" mnc=\"05\">\n        <boolean name=\"allow_video_call_in_low_battery\" value=\"false\" />\n        <boolean name=\"config_carrier_cs_retry_available\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"450\" mnc=\"06\">\n        <boolean name=\"allow_video_call_in_low_battery\" value=\"false\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"450\" mnc=\"08\">\n        <boolean name=\"allow_video_call_in_low_battery\" value=\"false\" />\n        <boolean name=\"config_carrier_cs_retry_available\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"00\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n        <boolean name=\"check_mobile_data_for_cf\" value=\"true\" />\n        <boolean name=\"config_enable_callbarring_over_ims\" value=\"true\" />\n        <boolean name=\"config_spn_override_enabled\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n        <boolean name=\"config_disable_clir_over_ut\" value=\"true\" />\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"01\">\n        <boolean name=\"config_spn_override_enabled\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"02\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n        <boolean name=\"check_mobile_data_for_cf\" value=\"true\" />\n        <boolean name=\"config_enable_callbarring_over_ims\" value=\"true\" />\n        <boolean name=\"config_spn_override_enabled\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n        <boolean name=\"config_disable_clir_over_ut\" value=\"true\" />\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"03\">\n        <boolean name=\"ascii_7_bit_support_for_long_message\" value=\"true\" />\n        <boolean name=\"cdma_cw_cf_enabled_bool\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"04\">\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"05\">\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n        <boolean name=\"config_show_orig_dial_string_for_cdma\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"06\">\n        <boolean name=\"config_spn_override_enabled\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"07\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n        <boolean name=\"check_mobile_data_for_cf\" value=\"true\" />\n        <boolean name=\"config_enable_callbarring_over_ims\" value=\"true\" />\n        <boolean name=\"config_spn_override_enabled\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n        <boolean name=\"config_disable_clir_over_ut\" value=\"true\" />\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"08\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n        <boolean name=\"check_mobile_data_for_cf\" value=\"true\" />\n        <boolean name=\"config_enable_callbarring_over_ims\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n        <boolean name=\"config_disable_clir_over_ut\" value=\"true\" />\n        <boolean name=\"show_video_quality_toast\" value=\"false\"/>\n        <boolean name=\"show_call_session_event_toast\" value=\"false\"/>\n        <boolean name=\"show_data_usage_toast\" value=\"false\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"09\">\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"10\">\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"11\">\n        <boolean name=\"ascii_7_bit_support_for_long_message\" value=\"true\" />\n        <boolean name=\"cdma_cw_cf_enabled_bool\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n        <boolean name=\"config_show_orig_dial_string_for_cdma\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"460\" mnc=\"12\">\n        <boolean name=\"ascii_7_bit_support_for_long_message\" value=\"true\" />\n        <boolean name=\"cdma_cw_cf_enabled_bool\" value=\"true\" />\n        <boolean name=\"allow_emergency_numbers_in_call_log_bool\" value=\"true\"/>\n        <boolean name=\"config_show_orig_dial_string_for_cdma\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"030\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"070\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"080\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"030\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"150\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"170\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"280\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"380\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"410\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"560\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"680\">\n        <boolean name=\"config_enable_display_14digit_imei\" value=\"true\" />\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"260\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"160\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"200\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"210\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"220\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"230\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"240\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"250\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"270\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"300\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"310\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"490\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"530\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"580\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"590\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"640\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"660\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n    <carrier_config mcc=\"310\" mnc=\"800\">\n        <boolean name=\"config_enable_mms_with_mobile_data_off\" value=\"true\" />\n    </carrier_config>\n\n</carrier_config_list>\n"
  },
  {
    "path": "overlay/packages/apps/CellBroadcastReceiver/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--Copyright (c) 2012, The Linux Foundation. All rights reserved.\n\n    Not a Contribution, Apache license notifications and license are retained\n    for attribution purposes only.\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n\n<resources>\n    <!-- Whether to enable ETWS settings (Japan) -->\n    <bool name=\"show_etws_settings\">true</bool>\n    <!-- Whether to enable CMAS settings (United States) -->\n    <bool name=\"show_cmas_settings\">true</bool>\n    <!-- Whether to enable channel 50 settings (Brazil) -->\n    <bool name=\"show_brazil_settings\">true</bool>\n    <!-- Whether to enable channel 50 and 60 settings (India)\n    <bool name=\"show_india_settings\">true</bool> -->\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/Dialer/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n     Copyright (C) 2016 The CyanogenMod Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<resources>\n    <bool name=\"call_recording_enabled\">true</bool>\n    <integer name=\"call_recording_audio_source\">4</integer>\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/Mms/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n    Copyright (c) 2014, The Linux Foundation. All rights reserved.\n\n    Redistribution and use in source and binary forms, with or without\n    modification, are permitted provided that the following conditions are\n    met:\n        * Redistributions of source code must retain the above copyright\n          notice, this list of conditions and the following disclaimer.\n        * Redistributions in binary form must reproduce the above\n          copyright notice, this list of conditions and the following\n          disclaimer in the documentation and/or other materials provided\n          with the distribution.\n        * Neither the name of The Linux Foundation nor the names of its\n          contributors may be used to endorse or promote products derived\n          from this software without specific prior written permission.\n\n    THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n    ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n    BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n    OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n    IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\n-->\n\n<resources>\n   <!-- configuration for SMS save location preference -->\n   <bool name=\"config_savelocation\">true</bool>\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/Settings/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2013 The CyanogenMod Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n\n<resources>\n  <bool name=\"config_show_volumeRockerWake\">true</bool>\n\n  <!-- Defines the location of the fingerprint sensor on the device\n       0 = back\n       1 = front\n       2 = left side\n       3 = right side\n  -->\n  <integer name=\"config_fingerprintSensorLocation\">1</integer>\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/Settings/res/values/dimens.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2009 The Android Open Source Project\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n          http://www.apache.org/licenses/LICENSE-2.0\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n\n<resources>\n    <dimen name=\"fingerprint_dot_radius\">5dp</dimen>\n    <item name=\"fingerprint_sensor_location_fraction_y\" type=\"fraction\">73.91%</item>\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/Snap/res/values/arrays.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n     Copyright (C) 2013-2015 The CyanogenMod Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n \n\t<string-array name=\"pref_camera_scenemode_entries\" translatable=\"false\">\n        <item>@string/pref_camera_scenemode_entry_auto</item>\n        <item>@string/pref_camera_scenemode_entry_steadyphoto</item>\n        <item>@string/pref_camera_scenemode_entry_hdr</item>\n\t\t<item>@string/pref_camera_scenemode_entry_asd</item>\n\t\t<item>@string/pref_camera_advanced_feature_entry_chromaflash</item>\n        <item>@string/pref_camera_scenemode_entry_sports</item>\n\t</string-array>\n\n    <string-array name=\"pref_camera_scenemode_entryvalues\" translatable=\"false\">\n\t\t<item>auto</item>\n\t\t<item>steadyphoto</item>\n\t\t<item>hdr</item>\n\t\t<item>asd</item>\n\t\t<item>chroma-flash-on</item>\n\t\t<item>sports</item>\n\t</string-array>\n\n    <array name=\"scenemode_thumbnails\" translatable=\"false\">\n\t\t<item>@drawable/ic_scene_mode_auto</item>\n        <item>@drawable/ic_scene_mode_entry_steadyphoto</item>\n        <item>@drawable/ic_scene_mode_hdr</item>\n        <item>@drawable/ic_scene_mode_smartauto</item>\n        <item>@drawable/ic_scene_mode_entry_dark</item>\n\t\t<item>@drawable/ic_scene_mode_sports</item>\n\t</array>\n\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/Snap/res/values/cm_strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n     Copyright (C) 2013-2015 The CyanogenMod Project\n    \n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n    \n          http://www.apache.org/licenses/LICENSE-2.0\n    \n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n--> \n<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n\n    <string name=\"pref_camera_scenemode_entry_sports\">Burst</string>\n    <string name=\"pref_camera_scenemode_entry_steadyphoto\">ClearShot</string>\n\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/Snap/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2012 The Android Open Source Project\n                   2015 The CyanogenMod Project\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n          http://www.apache.org/licenses/LICENSE-2.0\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n\n<!-- Camera app resources that may need to be customized\n     for different hardware or product builds. -->\n<resources>\n    <!-- This value may be tweaked to save memory on low RAM devices. The value\n         is the percentage of camera preview height/width to scale to. -->\n    <integer name=\"panorama_frame_size_reduction\">100</integer>\n\n    <!-- A list of scenemodes where Longshot should be enabled. Comma separated.\n         An empty list will use the default restrictions. If defined, longshot\n         will be enabled ONLY for these scenemodes and disabled for others. -->\n    <string-array name=\"longshot_scenemodes\">\n        <item>sports</item>\n    </string-array>\n\n</resources>\n"
  },
  {
    "path": "overlay/packages/apps/Snap/res/values/qcomstrings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n    Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.\n    Copyright (C) 2014-2016 The CyanogenMod Project\n\n    Not a Contribution.\n\n    Copyright (C) 2007 The Android Open Source Project\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n-->\n<resources>\n    <!-- HDR needs 1x frame -->\n    <string name=\"pref_camera_hdr_need_1x_default\" translatable=\"false\">false</string>\n    <string name=\"pref_camera_auto_hdr_default\" translatable=\"false\">enable</string>\n    <string name=\"pref_camera_scenedetect_default\" translatable=\"false\">on</string>\n    <string name=\"pref_camera_dis_default\" translatable=\"false\">enable</string>\n    <string name=\"pref_camera_longshot_default\" translatable=\"false\">on</string>\n    <string name=\"pref_video_quality_default\" translatable=\"false\">1920x1080</string>\n</resources>\n"
  },
  {
    "path": "overlay/packages/services/Telecomm/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved.\n\n     Redistribution and use in source and binary forms, with or without\n     modification, are permitted (subject to the limitations in the\n     disclaimer below) provided that the following conditions are met:\n\n        * Redistributions of source code must retain the above copyright\n          notice, this list of conditions and the following disclaimer.\n        * Redistributions in binary form must reproduce the above\n          copyright notice, this list of conditions and the following\n          disclaimer in the documentation and/or other materials provided\n          with the distribution.\n        * Neither the name of the Linux Foundation nor the names of its\n          contributors may be used to endorse or promote products derived\n          from this software without specific prior written permission.\n\n     NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE\n     GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT\n     HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED\n     WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n     BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n     OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n     IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-->\n<!-- Telecomm app resources that may need to be customized\n     for different hardware or product builds. -->\n<resources>\n    <!-- Flag indicating if the tty is enabled -->\n    <bool name=\"tty_enabled\">true</bool>\n    <!-- Flag indicating if the speed up audio on mt call code should be executed \n    <bool name=\"config_speed_up_audio_on_mt_calls\">true</bool> --> \n</resources>\n"
  },
  {
    "path": "overlay/packages/services/Telephony/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--Copyright (c) 2013, The Linux Foundation. All rights reserved.\n\n    Not a Contribution, Apache license notifications and license are retained\n    for attribution purposes only.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\"); you\n    may not use this file except in compliance with the License.  You may\n    obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n    implied.  See the License for the specific language governing\n    permissions and limitations under the License. -->\n\n<!-- Phone app resources that may need to be customized\n     for different hardware or product builds. -->\n<resources>\n    <!-- Determine whether we should show the \"listen for instructions\" screen after\n         successfully placing the OTA call -->\n    <integer name=\"OtaShowListeningScreen\">1</integer>\n\n    <!-- Flag indicating if the phone is a world phone -->\n    <bool name=\"world_phone\">true</bool>\n\n    <!-- Flag indicating if dtmf tone type is enabled -->\n    <bool name=\"dtmf_type_enabled\">true</bool>\n\n    <!-- Determine whether calls to mute the microphone in PhoneUtils\n         are routed through the android.media.AudioManager class (true) or through\n         the com.android.internal.telephony.Phone interface (false). -->\n    <bool name=\"send_mic_mute_to_AudioManager\">true</bool>\n\n    <!-- If this is true, the SIM card (through Customer Service Profile EF file) will be\n         able to prevent manual operator selection. If false, this SIM setting will be\n         ignored and manual operator selection will always be available. See\n         CPHS4_2.WW6, CPHS B.4.7.1 for more information -->\n    <bool name=\"csp_enabled\">true</bool>\n\n    <!-- Show Preferred Network Type options in No SIM case -->\n    <bool name=\"config_no_sim_display_network_modes\">true</bool>\n\n    <!-- Flag indicating if hac is enabled -->\n    <bool name=\"hac_enabled\">true</bool>\n\n    <!-- Show enabled lte option for lte device -->\n    <bool name=\"config_enabled_lte\" translatable=\"false\">true</bool>\n\n    <!-- Show APN Settings for some CDMA carriers -->\n    <bool name=\"config_show_apn_setting_cdma\">true</bool>\n\n    <!-- Allows the telephony HFA logic to run even if we're not in setup wizard. -->\n    <bool name=\"config_allow_hfa_outside_of_setup_wizard\">false</bool>\n</resources>\n"
  },
  {
    "path": "overlay/vendor/cmsdk/cm/res/res/values/config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n     Copyright (C) 2015-2016 The CyanogenMod Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<resources>\n\n    <!-- Default value for proximity check on screen wake\n     NOTE ! - Enable for devices that have a fast response proximity sensor (ideally < 300ms)-->\n    <bool name=\"config_proximityCheckOnWake\">true</bool>\n    <integer name=\"config_proximityCheckTimeout\">100</integer>\n    <bool name=\"config_proximityCheckOnWakeEnabledByDefault\">true</bool>\n\n    <!-- Ambient lux at which to enable outdoor mode when LiveDisplay is enabled -->\n    <integer name=\"config_outdoorAmbientLux\">12000</integer>\n\n    <!-- All the capabilities of the LEDs on this device, stored as a bit field.\n         This integer should equal the sum of the corresponding value for each\n         of the following capabilities present:\n\n         LIGHTS_RGB_NOTIFICATION_LED = 1\n         LIGHTS_RGB_BATTERY_LED = 2\n         LIGHTS_MULTIPLE_NOTIFICATION_LED = 4\n         LIGHTS_PULSATING_LED = 8\n         LIGHTS_SEGMENTED_BATTERY_LED = 16\n         LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS = 32\n\n         For example, a device support pulsating, RGB notification and\n         battery LEDs would set this config to 11. -->\n    <integer name=\"config_deviceLightCapabilities\">43</integer>\n\n\n</resources>\n"
  },
  {
    "path": "proprietary-files.txt",
    "content": "# ACDB\netc/acdbdata/MTP/MTP_Bluetooth_cal.acdb\netc/acdbdata/MTP/MTP_General_cal.acdb\netc/acdbdata/MTP/MTP_Global_cal.acdb\netc/acdbdata/MTP/MTP_Handset_cal.acdb\netc/acdbdata/MTP/MTP_Hdmi_cal.acdb\netc/acdbdata/MTP/MTP_Headset_cal.acdb\netc/acdbdata/MTP/MTP_Speaker_cal.acdb\n\n# ADSP\nbin/adsprpcd\nvendor/lib/libadsprpc.so\nvendor/lib/libfastcvopt.so\nvendor/lib64/libadsprpc.so\n\n# Audio\netc/firmware/tfa98xx.cnt\nvendor/lib/libacdb-fts.so\nvendor/lib/libacdbloader.so\nvendor/lib/libacdbrtac.so\nvendor/lib/libadiertac.so\nvendor/lib/libaudcal.so\nvendor/lib/libhwdaphal.so\nvendor/lib/soundfx/libqcbassboost.so\nvendor/lib/soundfx/libqcreverb.so\nvendor/lib/soundfx/libqcvirt.so\nvendor/lib64/libacdb-fts.so\nvendor/lib64/libacdbloader.so\nvendor/lib64/libacdbrtac.so\nvendor/lib64/libadiertac.so\nvendor/lib64/libaudcal.so\nvendor/lib64/libhwdaphal.so\n\n# Bluetooth\nbin/btnvtool\nbin/hci_qcomm_init\nbin/wcnss_filter\netc/firmware/nvm_tlv.bin\netc/firmware/nvm_tlv_1.3.bin\netc/firmware/nvm_tlv_2.1.bin\netc/firmware/nvm_tlv_3.0.bin\netc/firmware/nvm_tlv_3.2.bin\netc/firmware/rampatch_tlv.img\netc/firmware/rampatch_tlv_1.3.tlv\netc/firmware/rampatch_tlv_2.1.tlv\netc/firmware/rampatch_tlv_3.0.tlv\netc/firmware/rampatch_tlv_3.2.tlv\nvendor/lib/libbtnv.so\nvendor/lib64/libbtnv.so\n\n# Camera\nbin/mm-qcamera-app\nbin/mm-qcamera-daemon\nlib/hw/camera.msm8994.so:lib/hw/camera.vendor.msm8994.so\nlib/libFNVfbEngineLib.so\nlib/libmm-qcamera.so\nlib/libmmcamera_interface.so\nlib/libmmjpeg_interface.so\nlib/libmorpho_video_refiner.so\nlib/libopcamerahw_interface.so\nlib/libqomx_core.so\nlib64/libopcamera.so\nlib64/libopcameralib.so\nvendor/lib/libfastcvadsp_stub.so\nvendor/lib/libflash_pmic.so\nvendor/lib/libjpegdhw.so\nvendor/lib/libjpegdmahw.so\nvendor/lib/libjpegehw.so\nvendor/lib/libmmcamera2_c2d_module.so\nvendor/lib/libmmcamera2_cpp_module.so\nvendor/lib/libmmcamera2_frame_algorithm.so\nvendor/lib/libmmcamera2_iface_modules.so\nvendor/lib/libmmcamera2_imglib_modules.so\nvendor/lib/libmmcamera2_is.so\nvendor/lib/libmmcamera2_isp_modules.so\nvendor/lib/libmmcamera2_pp_buf_mgr.so\nvendor/lib/libmmcamera2_pproc_modules.so\nvendor/lib/libmmcamera2_q3a_core.so\nvendor/lib/libmmcamera2_sensor_debug.so\nvendor/lib/libmmcamera2_sensor_modules.so\nvendor/lib/libmmcamera2_stats_algorithm.so\nvendor/lib/libmmcamera2_stats_modules.so\nvendor/lib/libmmcamera2_vpe_module.so\nvendor/lib/libmmcamera2_wnr_module.so\nvendor/lib/libmmcamera_cac2_lib.so\nvendor/lib/libmmcamera_eeprom_util.so\nvendor/lib/libmmcamera_eztune_module.so\nvendor/lib/libmmcamera_faceproc.so\nvendor/lib/libmmcamera_hdr_gb_lib.so\nvendor/lib/libmmcamera_imglib.so\nvendor/lib/libmmcamera_pdaf.so\nvendor/lib/libmmcamera_pdafcamif.so\nvendor/lib/libmmcamera_ppbase_module.so\nvendor/lib/libmmcamera_tintless_algo.so\nvendor/lib/libmmcamera_tintless_bg_pca_algo.so\nvendor/lib/libmmcamera_tuning.so\nvendor/lib/libmmcamera_vpu_module.so\nvendor/lib/libmmipl.so\nvendor/lib/libmmjpeg.so\nvendor/lib/libmmqjpeg_codec.so\nvendor/lib/libmmqjpegdma.so\nvendor/lib/liboemcamera.so\nvendor/lib/libois_rohm_bu63165gwl.so\nvendor/lib/libqomx_jpegdec.so\nvendor/lib/libqomx_jpegenc_pipe.so\nvendor/lib64/libmmcamera2_q3a_core.so\nvendor/lib64/libmmcamera2_sensor_debug.so\nvendor/lib64/libmmcamera2_stats_algorithm.so\n\n# Camera actuators\nvendor/lib/libactuator_rohm_bu63165gwl.so\nvendor/lib/libactuator_rohm_bu63165gwl_camcorder.so\nvendor/lib/libactuator_rohm_bu63165gwl_camera.so\n\n# Camera chromatix\nvendor/lib/libchromatix_ov13860_common.so\nvendor/lib/libchromatix_ov13860_cpp_hfr.so\nvendor/lib/libchromatix_ov13860_cpp_liveshot.so\nvendor/lib/libchromatix_ov13860_cpp_panorama.so\nvendor/lib/libchromatix_ov13860_cpp_preview.so\nvendor/lib/libchromatix_ov13860_cpp_snapshot.so\nvendor/lib/libchromatix_ov13860_cpp_video.so\nvendor/lib/libchromatix_ov13860_cpp_zsl.so\nvendor/lib/libchromatix_ov13860_default_video.so\nvendor/lib/libchromatix_ov13860_hfr.so\nvendor/lib/libchromatix_ov13860_liveshot.so\nvendor/lib/libchromatix_ov13860_panorama.so\nvendor/lib/libchromatix_ov13860_postproc.so\nvendor/lib/libchromatix_ov13860_preview.so\nvendor/lib/libchromatix_ov13860_quarter_size_video.so\nvendor/lib/libchromatix_ov13860_snapshot.so\nvendor/lib/libchromatix_ov13860_zsl.so\nvendor/lib/libchromatix_ov5648_15fps_cpp_liveshot.so\nvendor/lib/libchromatix_ov5648_15fps_cpp_preview.so\nvendor/lib/libchromatix_ov5648_15fps_cpp_snapshot.so\nvendor/lib/libchromatix_ov5648_15fps_cpp_video.so\nvendor/lib/libchromatix_ov5648_15fps_postproc.so\nvendor/lib/libchromatix_ov5648_15fps_preview.so\nvendor/lib/libchromatix_ov5648_15fps_snapshot.so\nvendor/lib/libchromatix_ov5648_15fps_video.so\nvendor/lib/libchromatix_ov5648_30fps_cpp_liveshot.so\nvendor/lib/libchromatix_ov5648_30fps_cpp_preview.so\nvendor/lib/libchromatix_ov5648_30fps_cpp_snapshot.so\nvendor/lib/libchromatix_ov5648_30fps_cpp_video.so\nvendor/lib/libchromatix_ov5648_30fps_postproc.so\nvendor/lib/libchromatix_ov5648_30fps_preview.so\nvendor/lib/libchromatix_ov5648_30fps_snapshot.so\nvendor/lib/libchromatix_ov5648_30fps_video.so\nvendor/lib/libchromatix_ov5648_common.so\n\n# Camera firmware\netc/firmware/cpp_firmware_v1_1_1.fw\netc/firmware/cpp_firmware_v1_1_6.fw\netc/firmware/cpp_firmware_v1_2_0.fw\netc/firmware/cpp_firmware_v1_4_0.fw\netc/firmware/cpp_firmware_v1_6_0.fw\netc/firmware/cpp_firmware_v1_8_0.fw\n\n# Camera sensors\nvendor/lib/libmmcamera_isp_abf44.so\nvendor/lib/libmmcamera_isp_bcc44.so\nvendor/lib/libmmcamera_isp_be_stats44.so\nvendor/lib/libmmcamera_isp_bf_scale_stats46.so\nvendor/lib/libmmcamera_isp_bf_stats44.so\nvendor/lib/libmmcamera_isp_bg_stats46.so\nvendor/lib/libmmcamera_isp_bhist_stats44.so\nvendor/lib/libmmcamera_isp_bpc44.so\nvendor/lib/libmmcamera_isp_chroma_enhan40.so\nvendor/lib/libmmcamera_isp_chroma_suppress40.so\nvendor/lib/libmmcamera_isp_clamp_encoder40.so\nvendor/lib/libmmcamera_isp_clamp_video40.so\nvendor/lib/libmmcamera_isp_clamp_viewfinder40.so\nvendor/lib/libmmcamera_isp_clf46.so\nvendor/lib/libmmcamera_isp_color_correct46.so\nvendor/lib/libmmcamera_isp_color_xform_encoder46.so\nvendor/lib/libmmcamera_isp_color_xform_video46.so\nvendor/lib/libmmcamera_isp_color_xform_viewfinder46.so\nvendor/lib/libmmcamera_isp_cs_stats46.so\nvendor/lib/libmmcamera_isp_demosaic44.so\nvendor/lib/libmmcamera_isp_demux40.so\nvendor/lib/libmmcamera_isp_fovcrop_encoder46.so\nvendor/lib/libmmcamera_isp_fovcrop_video46.so\nvendor/lib/libmmcamera_isp_fovcrop_viewfinder46.so\nvendor/lib/libmmcamera_isp_gamma44.so\nvendor/lib/libmmcamera_isp_gic46.so\nvendor/lib/libmmcamera_isp_gtm46.so\nvendor/lib/libmmcamera_isp_hdr46.so\nvendor/lib/libmmcamera_isp_hdr_be_stats46.so\nvendor/lib/libmmcamera_isp_ihist_stats46.so\nvendor/lib/libmmcamera_isp_linearization40.so\nvendor/lib/libmmcamera_isp_ltm44.so\nvendor/lib/libmmcamera_isp_mce40.so\nvendor/lib/libmmcamera_isp_mesh_rolloff44.so\nvendor/lib/libmmcamera_isp_pedestal_correct46.so\nvendor/lib/libmmcamera_isp_rs_stats46.so\nvendor/lib/libmmcamera_isp_scaler_encoder46.so\nvendor/lib/libmmcamera_isp_scaler_video46.so\nvendor/lib/libmmcamera_isp_scaler_viewfinder46.so\nvendor/lib/libmmcamera_isp_sce40.so\nvendor/lib/libmmcamera_isp_sub_module.so\nvendor/lib/libmmcamera_isp_wb46.so\nvendor/lib/libmmcamera_ov13860.so\nvendor/lib/libmmcamera_ov13860_eeprom.so\nvendor/lib/libmmcamera_ov5648.so\nvendor/lib/libmmcamera_ov5648_eeprom.so\n\n# CNE\nbin/cnd\netc/cne/SwimConfig.xml\netc/cne/andsfCne.xml\netc/permissions/ConnectivityExt.xml\netc/permissions/cneapiclient.xml\netc/permissions/com.quicinc.cne.xml\nframework/ConnectivityExt.jar\nframework/cneapiclient.jar\nframework/com.quicinc.cne.jar\n-priv-app/CNEService/CNEService.apk|df1c3a80a4a1a36915f423a7969cff1cdedddcb2\nvendor/lib/libNimsWrap.so\nvendor/lib/libcne.so\nvendor/lib/libcneapiclient.so\nvendor/lib/libcneconn.so\nvendor/lib/libcneqmiutils.so\nvendor/lib/libvendorconn.so\nvendor/lib/libwqe.so\nvendor/lib/libxml.so\nvendor/lib64/libNimsWrap.so\nvendor/lib64/libcne.so\nvendor/lib64/libcneapiclient.so\nvendor/lib64/libcneconn.so\nvendor/lib64/libcneqmiutils.so\nvendor/lib64/libvendorconn.so\nvendor/lib64/libwqe.so\nvendor/lib64/libxml.so\n\n# Display calibration\n-etc/pp_calib_data_jd35695_1080p_cmd_mode_dsi_panel.xml\n\n# DPM\nbin/dpmd\netc/dpm/dpm.conf\netc/dpm/nsrm/NsrmConfiguration.xml\netc/permissions/com.qti.dpmframework.xml\netc/permissions/dpmapi.xml\nframework/com.qti.dpmframework.jar\nframework/dpmapi.jar\nframework/tcmclient.jar\n-priv-app/dpmserviceapp/dpmserviceapp.apk|27f91229cdbcec87edaf23c6b821c64a108dad83\nvendor/lib/libdpmctmgr.so\nvendor/lib/libdpmfdmgr.so\nvendor/lib/libdpmframework.so\nvendor/lib/libdpmnsrm.so\nvendor/lib/libdpmtcm.so\nvendor/lib64/libdpmctmgr.so\nvendor/lib64/libdpmfdmgr.so\nvendor/lib64/libdpmframework.so\nvendor/lib64/libdpmnsrm.so\nvendor/lib64/libdpmtcm.so\n\n# DRM\nbin/qseecomd\nvendor/lib/libQSEEComAPI.so\nvendor/lib64/libQSEEComAPI.so\nvendor/lib64/libdrmfs.so\nvendor/lib64/libdrmtime.so\nvendor/lib64/librpmb.so\nvendor/lib64/libssd.so\n\n# Fingerprint sensor\netc/firmware/fingerprints.b00\netc/firmware/fingerprints.b01\netc/firmware/fingerprints.b02\netc/firmware/fingerprints.b03\netc/firmware/fingerprints.mdt\nlib/hw/fingerprint.msm8994.so\nlib/lib_fpc_tac_shared.so\nlib64/hw/fingerprint.msm8994.so\nlib64/lib_fpc_tac_shared.so\n\n# Gatekeeper\nvendor/lib/hw/gatekeeper.msm8994.so\nvendor/lib64/hw/gatekeeper.msm8994.so\n\n# GPS\nbin/loc_launcher\netc/permissions/com.qti.location.sdk.xml\netc/permissions/com.qualcomm.location.xml\nframework/com.qti.location.sdk.jar|5f813d74715b42dc5175563cd5027269c5fe08fb\n-lib/libloc_api_v02.so\n-lib/libloc_ds_api.so\n-lib64/libloc_api_v02.so\n-lib64/libloc_ds_api.so\n-priv-app/com.qualcomm.location/com.qualcomm.location.apk|11c5e4aacb2e346645b9ab37f7f01d08a16e9297\nvendor/bin/slim_daemon\nvendor/lib/hw/flp.default.so\nvendor/lib/libdataitems.so\nvendor/lib/libflp.so\nvendor/lib/libgeofence.so\nvendor/lib/libizat_core.so\nvendor/lib/liblbs_core.so\nvendor/lib/liblocationservice.so\nvendor/lib/liblocationservice_glue.so\nvendor/lib/liblowi_client.so\nvendor/lib/libquipc_os_api.so\nvendor/lib/libulp2.so\nvendor/lib/libxt_native.so\nvendor/lib/libxtadapter.so\nvendor/lib/libxtwifi_ulp_adaptor.so\nvendor/lib64/hw/flp.default.so\nvendor/lib64/libalarmservice_jni.so\nvendor/lib64/libdataitems.so\nvendor/lib64/libflp.so\nvendor/lib64/libgeofence.so\nvendor/lib64/libizat_core.so\nvendor/lib64/liblbs_core.so\nvendor/lib64/liblocationservice.so\nvendor/lib64/liblocationservice_glue.so\nvendor/lib64/liblowi_client.so\nvendor/lib64/liblowi_wifihal.so\nvendor/lib64/libquipc_os_api.so\nvendor/lib64/libulp2.so\nvendor/lib64/libxtadapter.so\nvendor/lib64/libxtwifi_ulp_adaptor.so\n\n# Graphics\nvendor/lib/egl/libQTapGLES.so\nvendor/lib/egl/libq3dtools_esx.so\nvendor/lib/libOpenCL.so\nvendor/lib64/egl/libQTapGLES.so\nvendor/lib64/egl/libq3dtools_esx.so\nvendor/lib64/libOpenCL.so\n\n# Graphics firmware\netc/firmware/a420_pfp.fw\netc/firmware/a420_pm4.fw\n\n# Keystore\nvendor/lib/hw/keystore.msm8994.so\nvendor/lib64/hw/keystore.msm8994.so\n\n# Listen\nvendor/lib/hw/sound_trigger.primary.msm8994.so\n\n# Media\nvendor/lib/libDivxDrm.so\nvendor/lib/libI420colorconvert.so\nvendor/lib/libOmxAacDec.so\nvendor/lib/libOmxAmrwbplusDec.so\nvendor/lib/libOmxEvrcDec.so\nvendor/lib/libOmxQcelp13Dec.so\nvendor/lib/libOmxWmaDec.so\nvendor/lib/libSHIMDivxDrm.so\nvendor/lib/libmm-color-convertor.so\nvendor/lib/libmmosal.so\nvendor/lib64/libDivxDrm.so\nvendor/lib64/libI420colorconvert.so\nvendor/lib64/libOmxAacDec.so\nvendor/lib64/libOmxAmrwbplusDec.so\nvendor/lib64/libOmxWmaDec.so\nvendor/lib64/libSHIMDivxDrm.so\nvendor/lib64/libmm-color-convertor.so\nvendor/lib64/libmmosal.so\n\n# Media firmware\netc/firmware/venus.b00\netc/firmware/venus.b01\netc/firmware/venus.b02\netc/firmware/venus.b03\netc/firmware/venus.b04\netc/firmware/venus.mbn\netc/firmware/venus.mdt\n\n# Network\n-priv-app/QtiTetherService/QtiTetherService.apk|1f88a499a74cff043a296637db1c1dcecaafdee7\nvendor/lib/libconnctrl.so\nvendor/lib64/libconnctrl.so\nvendor/lib64/libQtiTether.so\n\n# Perf\nbin/energy-awareness\nbin/msm_irqbalance\nvendor/bin/perfd\nvendor/etc/perf-profile0.conf\nvendor/etc/perf-profile1.conf\nvendor/etc/perf-profile2.conf\nvendor/etc/perf-profile3.conf\nvendor/etc/perf-profile4.conf\nvendor/etc/perf-profile5.conf\nvendor/lib/libqti-perfd-client.so\nvendor/lib64/libqti-perfd-client.so\n\n# Peripheral manager\nbin/pm-proxy\nbin/pm-service\nvendor/lib/libperipheral_client.so\nvendor/lib64/libperipheral_client.so\n\n# Postprocessing\nbin/mm-pp-daemon\nvendor/lib/libdisp-aba.so\nvendor/lib/libmm-abl-oem.so\n-vendor/lib/libmm-abl.so\nvendor/lib/libmm-als.so\nvendor/lib64/libdisp-aba.so\nvendor/lib64/libmm-abl-oem.so\n-vendor/lib64/libmm-abl.so\nvendor/lib64/libmm-als.so\n\n# QMI\nbin/irsc_util\netc/permissions/qti_permissions.xml\n-vendor/lib/libdiag.so\nvendor/lib/libdsi_netctrl.so\n-vendor/lib/libdsutils.so\n-vendor/lib/libidl.so\n-vendor/lib/libqcci_legacy.so\nvendor/lib/libqdi.so\nvendor/lib/libqdp.so\n-vendor/lib/libqmi.so\n-vendor/lib/libqmi_cci.so\nvendor/lib/libqmi_client_helper.so\n-vendor/lib/libqmi_client_qmux.so\nvendor/lib/libqmi_common_so.so\nvendor/lib/libqmi_csi.so\nvendor/lib/libqmi_encdec.so\n-vendor/lib/libqmiservices.so\nvendor/lib/libsmemlog.so\n-vendor/lib64/libdiag.so\nvendor/lib64/libdsi_netctrl.so\n-vendor/lib64/libdsutils.so\n-vendor/lib64/libidl.so\n-vendor/lib64/libqcci_legacy.so\nvendor/lib64/libqdi.so\nvendor/lib64/libqdp.so\n-vendor/lib64/libqmi.so\n-vendor/lib64/libqmi_cci.so\nvendor/lib64/libqmi_client_helper.so\n-vendor/lib64/libqmi_client_qmux.so\nvendor/lib64/libqmi_common_so.so\nvendor/lib64/libqmi_csi.so\nvendor/lib64/libqmi_encdec.so\n-vendor/lib64/libqmiservices.so\nvendor/lib64/libsmemlog.so\n\n# Radio\n-app/datastatusnotification/datastatusnotification.apk|d5b8dbdfb9010758dffec92851937ded0bcca43b\n-app/fastdormancy/fastdormancy.apk|3a7ba6ce1796fea35932b68a465071a1db72fef1\n-app/QtiTelephonyService/QtiTelephonyService.apk|b3bd4921c583936d82d40582bde113fd58622efb\n-app/shutdownlistener/shutdownlistener.apk|5423f30ebab40e4a5b6609048681e060531e1eea\nbin/ipacm-diag\nbin/netmgrd\nbin/qmuxd\nbin/radish\nbin/rfs_access\nbin/rmt_storage\netc/data/dsi_config.xml\netc/data/netmgr_config.xml\netc/data/qmi_config.xml\netc/permissions/qcnvitems.xml\netc/permissions/qcrilhook.xml\netc/permissions/telephonyservice.xml\n-framework/qcnvitems.jar|8f1a22639392cef4e62bde005430a14bfa42d17e\n-framework/qcrilhook.jar|e94696ceea03cd31e159dc7fc10c5d694fe9fd94\nframework/qti-telephony-common.jar|fbd9aa168759bca89327643a23a7d32aaa78f79a\nframework/QtiTelephonyServicelibrary.jar|1d4ff53f9229caaa91fe3994757bcd359a18b756\nlib64/libparam.so\n-priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk|8d6a447cc4ee0ca78f6abb042b484c52775db9ed\nvendor/bin/qti\n-vendor/lib/libmdmdetect.so\nvendor/lib64/libconfigdb.so\nvendor/lib64/liblqe.so\n-vendor/lib64/libmdmdetect.so\nvendor/lib64/libnetmgr.so\nvendor/lib64/libqcmaputils.so\nvendor/lib64/libril-qc-qmi-1.so\nvendor/lib64/libril-qc-radioconfig.so\nvendor/lib64/libril-qcril-hook-oem.so\nvendor/lib64/libsystem_health_mon.so\nvendor/qcril.db\n\n# Radio - IMS\nbin/ims_rtp_daemon\nbin/imscmservice\nbin/imsdatadaemon\nbin/imsqmidaemon\nvendor/lib64/lib-dplmedia.so\nvendor/lib64/lib-ims-rcscmjni.so\nvendor/lib64/lib-imsSDP.so\nvendor/lib64/lib-imscamera.so\nvendor/lib64/lib-imsdpl.so\nvendor/lib64/lib-imsqimf.so\nvendor/lib64/lib-imsrcs.so\nvendor/lib64/lib-imsrcscm.so\nvendor/lib64/lib-imsrcscmclient.so\nvendor/lib64/lib-imsrcscmservice.so\nvendor/lib64/lib-imss.so\nvendor/lib64/lib-imsvt.so\nvendor/lib64/lib-imsxml.so\nvendor/lib64/lib-rcsimssjni.so\nvendor/lib64/lib-rtpcommon.so\nvendor/lib64/lib-rtpcore.so\nvendor/lib64/lib-rtpdaemoninterface.so\nvendor/lib64/lib-rtpsl.so\nvendor/lib64/libimscamera_jni.so\nvendor/lib64/libimsmedia_jni.so\nvendor/lib64/librcc.so\nvendor/lib64/libvoice-svc.so\n-vendor/app/ims/ims.apk|21f343af6b656ad1dc890b18fed940ad61e31fb0\n-vendor/app/imssettings/imssettings.apk|87ada7621f77f9cf8efa27ebb46157c98df3a7cc\n\n# Sensors\nbin/sensors.qcom\netc/sensors/sensor_def_qcomdev.conf\nvendor/lib/hw/activity_recognition.msm8994.so\nvendor/lib/libsensor1.so\nvendor/lib/libsensor_reg.so\nvendor/lib/libsensor_thresh.so\nvendor/lib/libsensor_user_cal.so\nvendor/lib/sensors.ssc.so\nvendor/lib64/hw/activity_recognition.msm8994.so\nvendor/lib64/libsensor1.so\nvendor/lib64/libsensor_reg.so\nvendor/lib64/libsensor_thresh.so\nvendor/lib64/libsensor_user_cal.so\nvendor/lib64/sensors.ssc.so\n\n# Thermal\netc/thermal-engine.conf\nvendor/bin/thermal-engine\nvendor/lib/libthermalclient.so\nvendor/lib64/libthermalclient.so\nvendor/lib64/libthermalioctl.so\n\n# Time services\n-app/TimeService/TimeService.apk|5198efe6b554038a5c96962b381517a0274a26df\nbin/time_daemon\nvendor/lib/libTimeService.so\n-vendor/lib/libtime_genoff.so\nvendor/lib64/libTimeService.so\n-vendor/lib64/libtime_genoff.so\n\n# TP Firmware\netc/firmware/tp/14049/14049_FW_S1302.img\netc/firmware/tp/14049/14049_FW_S3320_jdi.img\n\n# Widevine\nvendor/lib/libWVStreamControlAPI_L3.so\nvendor/lib/libwvdrm_L3.so\nvendor/lib/mediadrm/libwvdrmengine.so\n\n# Wifi\nbin/cnss-daemon\nbin/cnss_diag\n-lib64/libwpa_qmi_eap_proxy.so\n"
  },
  {
    "path": "rootdir/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\n\n# Device init scripts\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= fstab.qcom\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/fstab.qcom\nLOCAL_MODULE_PATH\t:= $(TARGET_ROOT_OUT)\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= init.qcom.power.rc\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/init.qcom.power.rc\nLOCAL_MODULE_PATH\t:= $(TARGET_ROOT_OUT)\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= init.qcom.rc\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/init.qcom.rc\nLOCAL_MODULE_PATH\t:= $(TARGET_ROOT_OUT)\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= init.qcom.sh\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/init.qcom.sh\nLOCAL_MODULE_PATH\t:= $(TARGET_ROOT_OUT)\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= init.qcom.usb.rc\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/init.qcom.usb.rc\nLOCAL_MODULE_PATH\t:= $(TARGET_ROOT_OUT)\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= init.qcom.usb.sh\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/init.qcom.usb.sh\nLOCAL_MODULE_PATH\t:= $(TARGET_ROOT_OUT)\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= ueventd.qcom.rc\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/ueventd.qcom.rc\nLOCAL_MODULE_PATH\t:= $(TARGET_ROOT_OUT)\ninclude $(BUILD_PREBUILT)\n\n# Configuration scripts\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= init.qcom.bt.sh\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/init.qcom.bt.sh\ninclude $(BUILD_PREBUILT)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE\t\t:= init.zram.sh\nLOCAL_MODULE_TAGS\t:= optional eng\nLOCAL_MODULE_CLASS\t:= ETC\nLOCAL_SRC_FILES\t\t:= etc/init.zram.sh\ninclude $(BUILD_PREBUILT)\n"
  },
  {
    "path": "rootdir/etc/fstab.qcom",
    "content": "# Android fstab file.\n# The filesystem that contains the filesystem checker binary (typically /system) cannot\n# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK\n\n#TODO: Add 'check' as fs_mgr_flags with data partition.\n# Currently we dont have e2fsck compiled. So fs check would failed.\n\n#<src>                                                <mnt_point>       <type>  <mnt_flags and options>                                                                                         <fs_mgr_flags>\n/dev/block/bootdevice/by-name/boot                    /boot             emmc    defaults                                                                                                        defaults\n/dev/block/bootdevice/by-name/recovery                /recovery         emmc    defaults                                                                                                        defaults\n/dev/block/bootdevice/by-name/system                  /system           ext4    ro,barrier=1                                                                                                    wait\n/dev/block/bootdevice/by-name/userdata                /data             ext4    nosuid,nodev,barrier=1                                                                                          wait,check,encryptable=footer\n/dev/block/bootdevice/by-name/userdata                /data             f2fs    rw,discard,nosuid,nodev,noatime,inline_xattr                                                                    wait,check,encryptable=footer\n/dev/block/bootdevice/by-name/cache                   /cache            ext4    nosuid,nodev,barrier=1                                                                                          wait\n/dev/block/bootdevice/by-name/cache                   /cache            f2fs    rw,discard,nosuid,nodev,noatime,inline_xattr                                                                    wait\n/dev/block/bootdevice/by-name/persist                 /persist          ext4    nosuid,nodev,barrier=1                                                                                          wait\n/dev/block/bootdevice/by-name/modem                   /firmware         vfat    ro,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337,context=u:object_r:firmware_file:s0                    wait\n/dev/block/bootdevice/by-name/bluetooth               /bt_firmware      vfat    ro,shortname=lower,uid=1002,gid=3002,dmask=222,fmask=333,context=u:object_r:bt_firmware_file:s0                 wait\n\n/devices/soc.0/f9200000.ssusb/f9200000.dwc3/xhci-hcd* auto              auto    defaults                                                                                                        voldmanaged=usbdisk:auto\n"
  },
  {
    "path": "rootdir/etc/init.qcom.bt.sh",
    "content": "#!/system/bin/sh\n# Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above copyright\n#       notice, this list of conditions and the following disclaimer in the\n#       documentation and/or other materials provided with the distribution.\n#     * Neither the name of The Linux Foundation nor\n#       the names of its contributors may be used to endorse or promote\n#       products derived from this software without specific prior written\n#       permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n# NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#\n\n#Read the arguments passed to the script\nconfig=\"$1\"\n\nBLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto\nLOG_TAG=\"qcom-bluetooth\"\nLOG_NAME=\"${0}:\"\n\nhciattach_pid=\"\"\n\nloge ()\n{\n  /system/bin/log -t $LOG_TAG -p e \"$LOG_NAME $@\"\n}\n\nlogi ()\n{\n  /system/bin/log -t $LOG_TAG -p i \"$LOG_NAME $@\"\n}\n\nfailed ()\n{\n  loge \"$1: exit code $2\"\n  exit $2\n}\n\nprogram_bdaddr ()\n{\n  /system/bin/btnvtool -O\n  logi \"Bluetooth Address programmed successfully\"\n}\n\n#\n# enable bluetooth profiles dynamically\n#\nconfig_bt ()\n{\n  baseband=`getprop ro.baseband`\n  target=`getprop ro.board.platform`\n  if [ -f /sys/devices/soc0/soc_id ]; then\n    soc_hwid=`cat /sys/devices/soc0/soc_id`\n  else\n    soc_hwid=`cat /sys/devices/system/soc/soc0/id`\n  fi\n  btsoc=`getprop qcom.bluetooth.soc`\n\n  case $baseband in\n    \"apq\")\n        setprop ro.qualcomm.bluetooth.opp true\n        setprop ro.qualcomm.bluetooth.ftp true\n        setprop ro.qualcomm.bluetooth.nap false\n        setprop ro.bluetooth.sap false\n        setprop ro.bluetooth.dun false\n        # For MPQ as baseband is same for both\n        case $soc_hwid in\n          \"130\")\n              setprop ro.qualcomm.bluetooth.hsp true\n              setprop ro.qualcomm.bluetooth.hfp true\n              setprop ro.qualcomm.bluetooth.pbap false\n              setprop ro.qualcomm.bluetooth.map false\n              ;;\n          *)\n              setprop ro.qualcomm.bluetooth.hsp false\n              setprop ro.qualcomm.bluetooth.hfp false\n              setprop ro.qualcomm.bluetooth.pbap true\n              setprop ro.qualcomm.bluetooth.map true\n              ;;\n        esac\n        ;;\n    \"mdm\" | \"svlte2a\" | \"svlte1\" | \"csfb\")\n        setprop ro.qualcomm.bluetooth.opp true\n        setprop ro.qualcomm.bluetooth.hfp true\n        setprop ro.qualcomm.bluetooth.hsp true\n        setprop ro.qualcomm.bluetooth.pbap true\n        setprop ro.qualcomm.bluetooth.ftp true\n        setprop ro.qualcomm.bluetooth.map true\n        setprop ro.qualcomm.bluetooth.nap true\n        setprop ro.bluetooth.sap true\n        case $target in\n          \"apq8084\")\n              setprop ro.bluetooth.dun true\n              logi \"Enabling BT-DUN for APQ8084\"\n              ;;\n          *)\n              setprop ro.bluetooth.dun false\n              ;;\n        esac\n        ;;\n    \"msm\")\n        setprop ro.qualcomm.bluetooth.opp true\n        setprop ro.qualcomm.bluetooth.hfp true\n        setprop ro.qualcomm.bluetooth.hsp true\n        setprop ro.qualcomm.bluetooth.pbap true\n        setprop ro.qualcomm.bluetooth.ftp true\n        setprop ro.qualcomm.bluetooth.nap true\n        setprop ro.bluetooth.sap true\n        setprop ro.bluetooth.dun true\n        case $btsoc in\n          \"ath3k\")\n              setprop ro.qualcomm.bluetooth.map false\n              ;;\n          *)\n              setprop ro.qualcomm.bluetooth.map true\n              ;;\n        esac\n        ;;\n    *)\n        setprop ro.qualcomm.bluetooth.opp true\n        setprop ro.qualcomm.bluetooth.hfp true\n        setprop ro.qualcomm.bluetooth.hsp true\n        setprop ro.qualcomm.bluetooth.pbap true\n        setprop ro.qualcomm.bluetooth.ftp true\n        setprop ro.qualcomm.bluetooth.map true\n        setprop ro.qualcomm.bluetooth.nap true\n        setprop ro.bluetooth.sap true\n        setprop ro.bluetooth.dun true\n        ;;\n  esac\n\n  #Enable Bluetooth Profiles specific to target Dynamically\n  case $target in\n    \"msm8960\")\n       if [ \"$btsoc\" != \"ath3k\" ] && [ \"$soc_hwid\" != \"130\" ]\n       then\n           setprop ro.bluetooth.hfp.ver 1.6\n           setprop ro.qualcomm.bt.hci_transport smd\n       fi\n       ;;\n    \"msm8974\" | \"msm8226\" | \"msm8610\" | \"msm8916\" | \"msm8909\" )\n       if [ \"$btsoc\" != \"ath3k\" ]\n       then\n           setprop ro.bluetooth.hfp.ver 1.6\n           setprop ro.qualcomm.bt.hci_transport smd\n       fi\n       ;;\n    \"apq8084\" | \"mpq8092\" | \"msm8994\" | \"msm8992\" )\n       if [ \"$btsoc\" != \"rome\" ]\n       then\n           setprop ro.qualcomm.bt.hci_transport smd\n       elif [ \"$btsoc\" = \"rome\" ]\n       then\n           setprop ro.bluetooth.hfp.ver 1.6\n       fi\n       ;;\n    *)\n       ;;\n  esac\n\nif [ -f /system/etc/bluetooth/stack.conf ]; then\nstack=`cat /system/etc/bluetooth/stack.conf`\nfi\n\ncase \"$stack\" in\n    \"bluez\")\n\t   logi \"Bluetooth stack is $stack\"\n\t   setprop ro.qc.bluetooth.stack $stack\n\t   reason=`getprop vold.decrypt`\n\t   case \"$reason\" in\n\t       \"trigger_restart_framework\")\n\t           start dbus\n\t           ;;\n\t   esac\n        ;;\n    *)\n\t   logi \"Bluetooth stack is Bluedroid\"\n        ;;\nesac\n\n}\n\nstart_hciattach ()\n{\n  /system/bin/hciattach -n $BTS_DEVICE $BTS_TYPE $BTS_BAUD &\n  hciattach_pid=$!\n  logi \"start_hciattach: pid = $hciattach_pid\"\n  echo 1 > $BLUETOOTH_SLEEP_PATH\n}\n\nkill_hciattach ()\n{\n  echo 0 > $BLUETOOTH_SLEEP_PATH\n  logi \"kill_hciattach: pid = $hciattach_pid\"\n  ## careful not to kill zero or null!\n  kill -TERM $hciattach_pid\n  # this shell doesn't exit now -- wait returns for normal exit\n}\n\nlogi \"init.qcom.bt.sh config = $config\"\ncase \"$config\" in\n    \"onboot\")\n        program_bdaddr\n        config_bt\n        exit 0\n        ;;\n    *)\n        ;;\nesac\n\n# mimic hciattach options parsing -- maybe a waste of effort\nUSAGE=\"hciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow] [bdaddr]\"\n\nwhile getopts \"blnpt:s:\" f\ndo\n  case $f in\n  b | l | n | p)  opt_flags=\"$opt_flags -$f\" ;;\n  t)      timeout=$OPTARG;;\n  s)      initial_speed=$OPTARG;;\n  \\?)     echo $USAGE; exit 1;;\n  esac\ndone\nshift $(($OPTIND-1))\n\n# Note that \"hci_qcomm_init -e\" prints expressions to set the shell variables\n# BTS_DEVICE, BTS_TYPE, BTS_BAUD, and BTS_ADDRESS.\n\n#Selectively Disable sleep\nBOARD=`getprop ro.board.platform`\nSTACK=`getprop ro.qc.bluetooth.stack`\n\n# BR/EDR & LE power class configurations\nPOWER_CLASS=`getprop qcom.bt.dev_power_class`\nLE_POWER_CLASS=`getprop qcom.bt.le_dev_pwr_class`\n\n#find the transport type\nTRANSPORT=`getprop ro.qualcomm.bt.hci_transport`\nlogi \"Transport : $TRANSPORT\"\ncase $STACK in\n    \"bluez\")\n       logi \"** Bluez stack **\"\n    ;;\n    *)\n       logi \"** Bluedroid stack **\"\n       setprop bluetooth.status off\n    ;;\nesac\n\n\ncase $POWER_CLASS in\n  1) PWR_CLASS=\"-p 0\" ;\n     logi \"Power Class: 1\";;\n  2) PWR_CLASS=\"-p 1\" ;\n     logi \"Power Class: 2\";;\n  3) PWR_CLASS=\"-p 2\" ;\n     logi \"Power Class: CUSTOM\";;\n  *) PWR_CLASS=\"\";\n     logi \"Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM)\";\n     logi \"Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3>\";;\nesac\n\ncase $LE_POWER_CLASS in\n  1) LE_PWR_CLASS=\"-P 0\" ;\n     logi \"LE Power Class: 1\";;\n  2) LE_PWR_CLASS=\"-P 1\" ;\n     logi \"LE Power Class: 2\";;\n  3) LE_PWR_CLASS=\"-P 2\" ;\n     logi \"LE Power Class: CUSTOM\";;\n  *) LE_PWR_CLASS=\"-P 1\";\n     logi \"LE Power Class: Ignored. Default(2) used (1-CLASS1/2-CLASS2/3-CUSTOM)\";\n     logi \"LE Power Class: To override, Before turning BT ON; setprop qcom.bt.le_dev_pwr_class <1 or 2 or 3>\";;\nesac\n\neval $(/system/bin/hci_qcomm_init -e $PWR_CLASS $LE_PWR_CLASS && echo \"exit_code_hci_qcomm_init=0\" || echo \"exit_code_hci_qcomm_init=1\")\n\ncase $exit_code_hci_qcomm_init in\n  0) logi \"Bluetooth QSoC firmware download succeeded, $BTS_DEVICE $BTS_TYPE $BTS_BAUD $BTS_ADDRESS\";;\n  *) failed \"Bluetooth QSoC firmware download failed\" $exit_code_hci_qcomm_init;\n     case $STACK in\n         \"bluez\")\n            logi \"** Bluez stack **\"\n         ;;\n         *)\n            logi \"** Bluedroid stack **\"\n            setprop bluetooth.status off\n        ;;\n     esac\n\n     exit $exit_code_hci_qcomm_init;;\nesac\n\n# init does SIGTERM on ctl.stop for service\ntrap \"kill_hciattach\" TERM INT\n\ncase $TRANSPORT in\n    \"smd\")\n       case $STACK in\n           \"bluez\")\n              logi \"** Bluez stack **\"\n              echo 1 > /sys/module/hci_smd/parameters/hcismd_set\n           ;;\n           *)\n              logi \"** Bluedroid stack **\"\n              setprop bluetooth.status on\n           ;;\n       esac\n     ;;\n     *)\n        logi \"start hciattach\"\n        start_hciattach\n        case $STACK in\n            \"bluez\")\n               logi \"Bluetooth is turning On with Bluez stack \"\n            ;;\n            *)\n               logi \"** Bluedroid stack **\"\n               setprop bluetooth.status on\n            ;;\n        esac\n\n        wait $hciattach_pid\n        logi \"Bluetooth stopped\"\n     ;;\nesac\n\nexit 0\n"
  },
  {
    "path": "rootdir/etc/init.qcom.power.rc",
    "content": "on boot\n    # add a cpuset for the camera daemon\n    # we want all the little cores for camera\n    mkdir /dev/cpuset/camera-daemon\n    write /dev/cpuset/camera-daemon/cpus 0\n    write /dev/cpuset/camera-daemon/mems 0\n    chown system system /dev/cpuset/camera-daemon\n    chown system system /dev/cpuset/camera-daemon/tasks\n    chmod 0664 /dev/cpuset/camera-daemon/tasks\n\n    # update foreground cpuset now that processors are up\n    # reserve CPU 3 for the top app and camera daemon\n    write /dev/cpuset/foreground/cpus 0-2,4-7\n    write /dev/cpuset/foreground/boost/cpus 4-7\n    write /dev/cpuset/background/cpus 0\n    write /dev/cpuset/system-background/cpus 0-2\n    write /dev/cpuset/top-app/cpus 0-7\n    write /dev/cpuset/camera-daemon/cpus 0-3\n\non enable-low-power\n\n    # Ensure at most one A57 is online when thermal hotplug is disabled\n    write /sys/devices/system/cpu/cpu5/online 0\n    write /sys/devices/system/cpu/cpu6/online 0\n    write /sys/devices/system/cpu/cpu7/online 0\n\n    # Limit A57 max freq from msm_perf module in case CPU 4 is offline\n    write /sys/module/msm_performance/parameters/cpu_max_freq \"4:960000 5:960000 6:960000 7:960000\"\n\n    # Disable thermal bcl hotplug to switch governor\n    write /sys/module/msm_thermal/core_control/enabled 0\n    write /sys/devices/soc.0/qcom,bcl.62/mode \"disable\"\n    write /sys/devices/soc.0/qcom,bcl.62/hotplug_mask 0\n    write /sys/devices/soc.0/qcom,bcl.62/hotplug_soc_mask 0\n    write /sys/devices/soc.0/qcom,bcl.62/mode \"enable\"\n\n    # Tune governor for little cores\n    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor \"interactive\"\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load 1\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif 1\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay 19000\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load 90\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate 20000\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq 960000\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy 1\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads 80\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time 40000\n    write /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis 80000\n    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 384000\n\n    # Tune governors for big cores\n    write /sys/devices/system/cpu/cpu4/online 1\n    write /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor \"interactive\"\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load 1\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif 1\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay \"19000 1400000:39000 1700000:19000\"\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load 90\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate 20000\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq 1248000\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy 1\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads \"85 1500000:90 1800000:70\"\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time 40000\n    write /sys/devices/system/cpu/cpu4/cpufreq/interactive/max_freq_hysteresis 80000\n    write /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq 384000\n\n    # Insert core_ctl module and use conservative paremeters\n    insmod /system/lib/modules/hcube.ko\n    write /sys/devices/system/cpu/cpu4/core_ctl/max_cpus 1\n\n    # Re-enable thermal and BCL hotplug\n    write /sys/module/msm_thermal/core_control/enabled 1\n    write /sys/devices/soc.0/qcom,bcl.62/mode \"disable\"\n    write /sys/devices/soc.0/qcom,bcl.62/hotplug_mask 192\n    write /sys/devices/soc.0/qcom,bcl.62/hotplug_soc_mask 240\n    write /sys/devices/soc.0/qcom,bcl.62/mode \"enable\"\n\n    # Enable low power modes\n    write /sys/module/lpm_levels/parameters/sleep_disabled 0\n\n    # Restore CPU 4 max freq from msm_performance\n    write /sys/module/msm_performance/parameters/cpu_max_freq \"4:4294967295 5:4294967295 6:4294967295 7:4294967295\"\n\n    # Input boost configuration\n    write /sys/module/cpu_boost/parameters/input_boost_freq \"0:1344000\"\n    write /sys/module/cpu_boost/parameters/input_boost_ms 40\n\n    # Configure core_ctl module parameters\n    write /sys/devices/system/cpu/cpu4/core_ctl/max_cpus 4\n    write /sys/devices/system/cpu/cpu4/core_ctl/min_cpus 0\n    write /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres 70\n    write /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres 20\n    write /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms  100\n    write /sys/devices/system/cpu/cpu4/core_ctl/is_big_cluster 1\n    write /sys/devices/system/cpu/cpu4/core_ctl/task_thres 4\n\n    # enable H-Cube tunings for big cores\n    write /sys/devices/system/cpu/cpu4/core_ctl/hc_on 1\n    write /sys/devices/system/cpu/cpu4/core_ctl/hc_down_scale_on 1\n    write /sys/devices/system/cpu/cpu4/core_ctl/hc_thres_on 1\n    write /sys/devices/system/cpu/cpu4/core_ctl/hc_ro_use_gourd 1\n    write /sys/devices/system/cpu/cpu4/core_ctl/hc_correl_lvs \"0 0 768000 1248000\"\n    write /sys/devices/system/cpu/cpu4/core_ctl/hc_correl_use_pcost 1\n\n    # Setting big.LITTLE scheduler parameters\n    write /proc/sys/kernel/sched_migration_fixup 1\n    write /proc/sys/kernel/sched_small_task 30\n    write /proc/sys/kernel/sched_mostly_idle_load 20\n    write /proc/sys/kernel/sched_mostly_idle_nr_run 3\n    write /proc/sys/kernel/sched_upmigrate 99\n    write /proc/sys/kernel/sched_downmigrate 85\n    write /proc/sys/kernel/sched_freq_inc_notify 400000\n    write /proc/sys/kernel/sched_freq_dec_notify 400000\n    write /proc/sys/kernel/sched_boost 0\n\n    # Enable rps static configuration\n    write /sys/class/net/rmnet_ipa0/queues/rx-0/rps_cpus 8\n    write /sys/class/devfreq/qcom,cpubw.33/governor \"bw_hwmon\"\n    write /sys/class/devfreq/qcom,mincpubw.34/governor \"cpufreq\"\n\n    # Set Memory parameters\n    write /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk 0\n    write /sys/module/lowmemorykiller/parameters/minfree \"18432,23040,27648,32256,55296,80640\"\n    write /sys/module/lowmemorykiller/parameters/vmpressure_file_min 81250\n\n    # Set perfd properties\n    rm /data/system/perfd/default_values\n    setprop ro.min_freq_0 384000\n    setprop ro.min_freq_4 384000\n    start perfd\n\nservice charger /charger\n    class charger\n    group log\n    seclabel u:r:healthd:s0\n\non charger\n    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor \"powersave\"\n    write /sys/devices/system/cpu/cpu1/online 0\n    write /sys/devices/system/cpu/cpu2/online 0\n    write /sys/devices/system/cpu/cpu3/online 0\n    write /sys/module/lpm_levels/parameters/sleep_disabled 0\n\non class_start:late_start\n    trigger enable-low-power\n\non property:init.svc.recovery=running\n    trigger enable-low-power\n\non property:dev.bootcomplete=1\n    setprop sys.io.scheduler \"bfq\"\n"
  },
  {
    "path": "rootdir/etc/init.qcom.rc",
    "content": "# Copyright (c) 2009-2012, 2014-2015, The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above copyright\n#       notice, this list of conditions and the following disclaimer in the\n#       documentation and/or other materials provided with the distribution.\n#     * Neither the name of The Linux Foundation nor\n#       the names of its contributors may be used to endorse or promote\n#       products derived from this software without specific prior written\n#       permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n# NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#\n\nimport init.qcom.power.rc\nimport init.qcom.usb.rc\n\non early-init\n    symlink /data/tombstones /tombstones\n\n    # Setup zram options\n    write /sys/block/zram0/comp_algorithm lz4\n    write /proc/sys/vm/swappiness 100\n\non early-fs\n    mkdir /firmware 0771 system system\n    mkdir /bt_firmware 0771 system system\n    mkdir /persist 0771 system system\n\n    mount_all /fstab.qcom\n\non init\n    export LD_SHIM_LIBS \"/system/vendor/lib64/lib-imscamera.so|libshim_ims-camera.so:/system/lib/libopcamerahw_interface.so|libshim_camera.so:/system/lib/libFNVfbEngineLib.so|libshim_camera.so\"\n\n    chmod 0644 /proc/cmdline\n\n    symlink /sdcard /storage/sdcard0\n\n    # Slow Motion Scheduling Group\n    mkdir /dev/cpuctl/smsg\n    chown system system /dev/cpuctl/smsg/tasks\n    chown system system /dev/cpuctl/smsg/cpu.cfs_period_us\n    chown system system /dev/cpuctl/smsg/cpu.cfs_quota_us\n    chown system system /dev/cpuctl/smsg/cpu.cfs_quota_us_per_task\n    chmod 0666 /dev/cpuctl/smsg/tasks\n    write /dev/cpuctl/smsg/cpu.shares 52\n    write /dev/cpuctl/smsg/cpu.upmigrate_discourage 1\n\n    # Add for fpc fingerprints permission\n    chmod -h 777 /dev/qseecom\n    chmod 0664 /sys/bus/spi/devices/spi12.0/irq\n    chown system system /sys/bus/spi/devices/spi12.0/irq\n    chmod 0660 /sys/bus/spi/devices/spi12.0/report_home\n    chown system system /sys/bus/spi/devices/spi12.0/report_home\n    chmod 0660 /sys/devices/soc/soc:fpc_fpc1020/update_info\n    chown system system /sys/devices/soc/soc:fpc_fpc1020/update_info\n    chmod 0660 /sys/bus/spi/devices/spi12.0/screen_state\n    chown system system /sys/bus/spi/devices/spi12.0/screen_state\n    chmod 0660 /sys/bus/spi/devices/spi12.0/clk_enable\n    chown system system /sys/bus/spi/devices/spi12.0/clk_enable\n\n    # Laser AF\n    chown system system /dev/stmvl6180_ranging\n    symlink /dev/input/event2 /dev/stm_sensor\n\n    # Leds permission\n    chown system system /sys/class/leds/led:flash_0/brightness\n    chown system system /sys/class/leds/led:flash_1/brightness\n\n    # Torch\n    chown system system /sys/class/leds/led:torch_0/brightness\n    chmod 0666 /sys/class/leds/led:torch_0/brightness\n    chown system system /sys/class/leds/led:torch_1/brightness\n    chmod 0666 /sys/class/leds/led:torch_1/brightness\n\n    # Scheduler\n    chown system system /sys/module/cpu_boost/parameters/sysctl_thermal_aware_scheduling\n\n    # Display color calibration\n    chown system system /sys/devices/platform/kcal_ctrl.0/kcal\n    chown system system /sys/devices/platform/kcal_ctrl.0/kcal_enable\n    chown system system /sys/devices/platform/kcal_ctrl.0/kcal_cont\n    chown system system /sys/devices/platform/kcal_ctrl.0/kcal_hue\n    chown system system /sys/devices/platform/kcal_ctrl.0/kcal_invert\n    chown system system /sys/devices/platform/kcal_ctrl.0/kcal_min\n    chown system system /sys/devices/platform/kcal_ctrl.0/kcal_sat\n    chown system system /sys/devices/platform/kcal_ctrl.0/kcal_val\n\n    # Touchscreen\n    chown system radio /proc/touchpanel/double_tap_enable\n    chmod 0660 /proc/touchpanel/double_tap_enable\n\n    chown root system /proc/touchpanel/camera_enable\n    chmod 0660 /proc/touchpanel/camera_enable\n\n    chown root system /proc/touchpanel/music_enable\n    chmod 0660 /proc/touchpanel/music_enable\n\n    chown root system /proc/touchpanel/flashlight_enable\n    chmod 0660 /proc/touchpanel/flashlight_enable\n\n    # Buttons\n    chown root system /proc/s1302/key_rep\n    chmod 0660 /proc/s1302/key_rep\n\n    chown root system /proc/s1302/virtual_key\n    chmod 0660 /proc/s1302/virtual_key\n\n    chown root system /proc/tri-state-key/keyCode_top\n    chmod 0660 /proc/tri-state-key/keyCode_top\n\n    chown root system /proc/tri-state-key/keyCode_middle\n    chmod 0660 /proc/tri-state-key/keyCode_middle\n\n    chown root system /proc/tri-state-key/keyCode_bottom\n    chmod 0660 /proc/tri-state-key/keyCode_bottom\n\n    # PCC Calibration\n    chown system system /sys/devices/virtual/graphics/fb0/rgb\n    chmod 0660 /sys/devices/virtual/graphics/fb0/rgb\n\n    # for product mode flashlight\n    chown system system /proc/qcom_flash\n\n    # Modify for RGB light support\n    chown system system /sys/class/leds/red/pause_lo\n    chown system system /sys/class/leds/blue/pause_lo\n    chown system system /sys/class/leds/green/pause_lo\n\n    chown system system /sys/class/leds/red/pause_hi\n    chown system system /sys/class/leds/blue/pause_hi\n    chown system system /sys/class/leds/green/pause_hi\n\n    chown system system /sys/class/leds/red/blink\n    chown system system /sys/class/leds/blue/blink\n    chown system system /sys/class/leds/green/blink\n\n    # Modify for RGB breath effect control support\n    chown system system /sys/class/leds/red/ramp_step_ms\n    chown system system /sys/class/leds/blue/ramp_step_ms\n    chown system system /sys/class/leds/green/ramp_step_ms\n\n    chown system system /sys/class/leds/red/duty_pcts\n    chown system system /sys/class/leds/blue/duty_pcts\n    chown system system /sys/class/leds/green/duty_pcts\n\n    chmod 660 /sys/class/leds/red/ramp_step_ms\n    chmod 660 /sys/class/leds/green/ramp_step_ms\n    chmod 660 /sys/class/leds/blue/ramp_step_ms\n\n    chmod 660 /sys/class/leds/red/duty_pcts\n    chmod 660 /sys/class/leds/green/duty_pcts\n    chmod 660 /sys/class/leds/blue/duty_pcts\n\n    # GPU Tuning\n    chown root system /sys/class/kgsl/kgsl-3d0/dispatch/inflight\n    chmod 0660 /sys/class/kgsl/kgsl-3d0/dispatch/inflight\n    chown root system /sys/class/kgsl/kgsl-3d0/dispatch/inflight_low_latency\n    chmod 0660 /sys/class/kgsl/kgsl-3d0/dispatch/inflight_low_latency\n\n    # Enable cgroup_freezer\n    mkdir /sys/fs/cgroup/freezer 0750 root system\n    mount cgroup none /sys/fs/cgroup/freezer  freezer\n    chmod 777 /sys/fs/cgroup/freezer\n\n    write /sys/module/printk/parameters/print_wall_time 1\n\n    # Access permission for secure touch\n    chmod 0660 /sys/devices/soc.0/f9924000.i2c/i2c-2/2-0020/input/input0/secure_touch_enable\n    chmod 0440 /sys/devices/soc.0/f9924000.i2c/i2c-2/2-0020/input/input0/secure_touch\n    chmod 0660 /sys/devices/soc.0/f9924000.i2c/i2c-2/2-004a/secure_touch_enable\n    chmod 0440 /sys/devices/soc.0/f9924000.i2c/i2c-2/2-004a/secure_touch\n    chown system drmrpc /sys/devices/soc.0/f9924000.i2c/i2c-2/2-0020/input/input0/secure_touch_enable\n    chown system drmrpc /sys/devices/soc.0/f9924000.i2c/i2c-2/2-0020/input/input0/secure_touch\n    chown system drmrpc /sys/devices/soc.0/f9924000.i2c/i2c-2/2-004a/secure_touch_enable\n    chown system drmrpc /sys/devices/soc.0/f9924000.i2c/i2c-2/2-004a/secure_touch\n    write /proc/sys/kernel/sched_boost 1\n    write /proc/sys/vm/dirty_ratio 15\n    write /proc/sys/vm/dirty_background_ratio 1\n\n    # Modify for drv2605 support\n    chmod 0666 /dev/drv2605\n    chown system system /dev/drv2605\n\non early-boot\n    # set RLIMIT_MEMLOCK to 64MB\n    setrlimit 8 67108864 67108864\n\n    write /sys/kernel/boot_adsp/boot 1\n\non boot\n    start rmt_storage\n    start rfs_access\n\n    chown bluetooth bluetooth /sys/module/bluetooth_power/parameters/power\n    chown bluetooth net_bt /sys/class/rfkill/rfkill0/type\n    chown bluetooth net_bt /sys/class/rfkill/rfkill0/state\n    chown bluetooth bluetooth /proc/bluetooth/sleep/proto\n    chown bluetooth bluetooth /sys/module/hci_uart/parameters/ath_lpm\n    chown bluetooth bluetooth /sys/module/hci_uart/parameters/ath_btwrite\n    chown system system /sys/module/sco/parameters/disable_esco\n    chown bluetooth bluetooth /sys/module/hci_smd/parameters/hcismd_set\n    chmod 0660 /sys/module/bluetooth_power/parameters/power\n    chmod 0660 /sys/module/hci_smd/parameters/hcismd_set\n    chmod 0660 /sys/class/rfkill/rfkill0/state\n    chmod 0660 /proc/bluetooth/sleep/proto\n    chown bluetooth net_bt /dev/ttyHS0\n    chmod 0660 /sys/module/hci_uart/parameters/ath_lpm\n    chmod 0660 /sys/module/hci_uart/parameters/ath_btwrite\n    chmod 0660 /dev/ttyHS0\n    chown bluetooth bluetooth /sys/devices/platform/msm_serial_hs.0/clock\n    chmod 0660 /sys/devices/platform/msm_serial_hs.0/clock\n\n    chmod 0660 /dev/ttyHS2\n    chown bluetooth bluetooth /dev/ttyHS2\n\n    chown bluetooth net_bt /sys/class/rfkill/rfkill0/device/extldo\n    chmod 0660 /sys/class/rfkill/rfkill0/device/extldo\n\n    # Create QMUX deamon socket area\n    mkdir /dev/socket/qmux_radio 0770 radio radio\n    chmod 2770 /dev/socket/qmux_radio\n    mkdir /dev/socket/qmux_audio 0770 media audio\n    chmod 2770 /dev/socket/qmux_audio\n    mkdir /dev/socket/qmux_bluetooth 0770 bluetooth bluetooth\n    chmod 2770 /dev/socket/qmux_bluetooth\n    mkdir /dev/socket/qmux_gps 0770 gps gps\n    chmod 2770 /dev/socket/qmux_gps\n\n    # Create NETMGR daemon socket area\n    mkdir /dev/socket/netmgr 0750 radio radio\n\n    setprop wifi.interface wlan0\n\n    setprop ro.telephony.call_ring.multiple false\n\n    # Remove SUID bit for iproute2 ip tool\n    chmod 0755 /system/bin/ip\n    chmod 0444 /sys/devices/platform/msm_hsusb/gadget/usb_state\n\n    setprop net.tcp.2g_init_rwnd 10\n\n    # Assign TCP buffer thresholds to be ceiling value of technology maximums\n    # Increased technology maximums should be reflected here.\n    write /proc/sys/net/core/rmem_max  8388608\n    write /proc/sys/net/core/wmem_max  8388608\n\n    #To allow interfaces to get v6 address when tethering is enabled\n    write /proc/sys/net/ipv6/conf/rmnet0/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet1/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet2/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet3/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet4/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet5/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet6/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet7/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_sdio0/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_sdio1/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_sdio2/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_sdio3/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_sdio4/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_sdio5/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_sdio6/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_sdio7/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_usb0/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_usb1/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_usb2/accept_ra 2\n    write /proc/sys/net/ipv6/conf/rmnet_usb3/accept_ra 2\n\n    # To prevent out of order acknowledgements from making\n    # connection tracking to treat them as not belonging to\n    # the connection they belong to.\n    # Otherwise, a weird issue happens in which some long\n    # connections on high-throughput links get dropped when\n    # an ack packet comes out of order\n    write /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal 1\n\n    # create symlink for fb1 as HDMI\n    symlink /dev/graphics/fb1 /dev/graphics/hdmi\n\n    # MDP idle notifier\n    chown system graphics /sys/class/graphics/fb0/idle_time\n    chmod 0664 /sys/class/graphics/fb0/idle_time\n\n    # setup permissions for fb1 related nodes\n    chown system graphics /sys/class/graphics/fb0/idle_time\n    chown system graphics /sys/class/graphics/fb0/dynamic_fps\n    chown system graphics /sys/class/graphics/fb0/dyn_pu\n    chown system graphics /sys/class/graphics/fb0/modes\n    chown system graphics /sys/class/graphics/fb0/mode\n\n    chmod 0664 /sys/devices/virtual/graphics/fb0/idle_time\n    chmod 0664 /sys/devices/virtual/graphics/fb0/dynamic_fps\n    chmod 0664 /sys/devices/virtual/graphics/fb0/dyn_pu\n    chmod 0664 /sys/devices/virtual/graphics/fb0/modes\n    chmod 0664 /sys/devices/virtual/graphics/fb0/mode\n\n    chown system graphics /sys/class/graphics/fb1/hpd\n    chown system graphics /sys/class/graphics/fb1/res_info\n    chown system graphics /sys/class/graphics/fb1/vendor_name\n    chown system graphics /sys/class/graphics/fb1/product_description\n    chown system graphics /sys/class/graphics/fb1/video_mode\n    chown system graphics /sys/class/graphics/fb1/format_3d\n    chown system graphics /sys/class/graphics/fb1/s3d_mode\n    chown system graphics /sys/class/graphics/fb1/cec/enable\n    chown system graphics /sys/class/graphics/fb1/cec/logical_addr\n    chown system graphics /sys/class/graphics/fb1/cec/rd_msg\n    chown system graphics /sys/class/graphics/fb1/pa\n    chown system graphics /sys/class/graphics/fb1/cec/wr_msg\n    chown system graphics /sys/class/graphics/fb1/hdcp/tp\n\n    chmod 0664 /sys/devices/virtual/graphics/fb1/hpd\n    chmod 0664 /sys/devices/virtual/graphics/fb1/res_info\n    chmod 0664 /sys/devices/virtual/graphics/fb1/vendor_name\n    chmod 0664 /sys/devices/virtual/graphics/fb1/product_description\n    chmod 0664 /sys/devices/virtual/graphics/fb1/video_mode\n    chmod 0664 /sys/devices/virtual/graphics/fb1/format_3d\n    chmod 0664 /sys/devices/virtual/graphics/fb1/s3d_mode\n    chmod 0664 /sys/devices/virtual/graphics/fb1/cec/enable\n    chmod 0664 /sys/devices/virtual/graphics/fb1/cec/logical_addr\n    chmod 0664 /sys/devices/virtual/graphics/fb1/cec/rd_msg\n    chmod 0664 /sys/devices/virtual/graphics/fb1/pa\n    chmod 0664 /sys/devices/virtual/graphics/fb1/cec/wr_msg\n    chmod 0664 /sys/devices/virtual/graphics/fb1/hdcp/tp\n\n    # Allow access for CCID command/response timeout configuration\n    chown system system /sys/module/ccid_bridge/parameters/bulk_msg_timeout\n\n    # Mark the copy complete flag to not completed\n    write /data/misc/radio/copy_complete 0\n    chown radio radio /data/misc/radio/copy_complete\n    chmod 0660 /data/misc/radio/copy_complete\n\n# msm specific files that need to be created on /data\non post-fs-data\n    mkdir /data/tombstones 0771 system system\n    mkdir /tombstones/modem 0771 system system\n    mkdir /tombstones/lpass 0771 system system\n    mkdir /tombstones/wcnss 0771 system system\n    mkdir /tombstones/dsps 0771 system system\n    mkdir /persist/data/sfs 0700 system system\n    mkdir /persist/data/tz 0700 system system\n    mkdir /data/usf 0700 system system\n    mkdir /data/misc/sfs/sfs 0700 system system\n    mkdir /data/misc/sfs/tz 0700 system system\n    mkdir /data/misc/dts 0770 media audio\n    mkdir /data/oemnvitems 0771 radio radio\n\n    # Fingerint\n    mkdir /data/misc/fp 0700 system system\n    mkdir /data/fpc_images 0770 system system\n    mkdir /data/fpc_images/verify 0770 system system\n    mkdir /data/fpc_images/enroll 0770 system system\n    mkdir /data/fpc 0770 system system\n\n    # Create directory for TZ Apps\n    mkdir /data/misc/qsee 0770 system system\n\n    # We will remap this as /mnt/sdcard with the sdcard fuse tool\n    mkdir /data/misc/camera 0770 camera camera\n\n    # Create folder for mm-qcamera-daemon\n    mkdir /data/camera 0770 media camera\n\n    # Create directory for IPA\n    mkdir /data/misc/ipa 0700 net_admin net_admin\n\n    mkdir /data/misc/bluetooth 0770 bluetooth bluetooth\n\n    # Create the directories used by the Wireless subsystem\n    mkdir /data/misc/wifi 0770 wifi wifi\n    mkdir /data/misc/wifi/sockets 0770 wifi wifi\n    mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi\n    mkdir /data/misc/dhcp 0770 dhcp dhcp\n    chown dhcp dhcp /data/misc/dhcp\n\n    # Create the directories used by CnE subsystem\n    mkdir /data/connectivity 0771 system system\n    chown system system /data/connectivity\n\n    # Create the directories used by DPM subsystem\n    mkdir /data/dpm 0771 system system\n    chown system system /data/dpm\n\n    mkdir /data/dpm/fdMgr 0771 system system\n    chown system system /data/dpm/fdMgr\n\n    mkdir /data/dpm/nsrm 0771 system system\n    chown system system /data/dpm/nsrm\n\n    # Create directory used by audio subsystem\n    mkdir /data/misc/audio 0770 audio audio\n\n    # Create directory for audio delta files\n    mkdir /data/misc/audio/acdbdata 0770 media audio\n    mkdir /data/misc/audio/acdbdata/delta 0770 media audio\n\n    # Create directory used by the DASH client\n    mkdir /data/misc/dash 0770 media audio\n\n    # Create directory used by display clients\n    mkdir /data/misc/display 0770 system graphics\n    mkdir /persist/display 0770 system graphics\n\n    # Mounting of persist is moved to 'on emmc-fs' and 'on fs' sections\n    # We chown/chmod /persist again so because mount is run as root + defaults\n    chown system system /persist\n    chmod 0771 /persist\n    chmod 0664 /sys/devices/platform/msm_sdcc.1/polling\n    chmod 0664 /sys/devices/platform/msm_sdcc.2/polling\n    chmod 0664 /sys/devices/platform/msm_sdcc.3/polling\n    chmod 0664 /sys/devices/platform/msm_sdcc.4/polling\n\n    # Chown polling nodes as needed from UI running on system server\n    chown system system /sys/devices/platform/msm_sdcc.1/polling\n    chown system system /sys/devices/platform/msm_sdcc.2/polling\n    chown system system /sys/devices/platform/msm_sdcc.3/polling\n    chown system system /sys/devices/platform/msm_sdcc.4/polling\n\n    # Create the symlink to qcn wpa_supplicant folder for ar6000 wpa_supplicant\n    mkdir /data/system 0775 system system\n    #symlink /data/misc/wifi/wpa_supplicant /data/system/wpa_supplicant\n\n    # Create directories for Location services\n    mkdir /data/misc/location 0770 gps gps\n    mkdir /data/misc/location/mq 0770 gps gps\n    mkdir /data/misc/location/xtwifi 0770 gps gps\n    mkdir /data/misc/location/gpsone_d 0770 system gps\n    mkdir /data/misc/location/quipc 0770 gps system\n    mkdir /data/misc/location/gsiff 0770 gps gps\n\n    # Create directory from IMS services\n    mkdir /data/shared 0755\n    chown system system /data/shared\n\n    # Create directory for FOTA\n    mkdir /data/fota 0771\n    chown system system /data/fota\n\n    # Create directory for hostapd\n    mkdir /data/hostapd 0770 system wifi\n\n    # Create /data/time folder for time-services\n    mkdir /data/time/ 0700 system system\n\n    mkdir /data/audio/ 0770 media audio\n\n    # Create a folder for audio delta files\n    mkdir /data/audio/acdbdata 0770 media audio\n    mkdir /data/audio/acdbdata/delta 0770 media audio\n\n    setprop vold.post_fs_data_done 1\n\n    # Create a folder for SRS to be able to create a usercfg file\n    mkdir /data/data/media 0770 media media\n\n    # Create PERFD deamon related dirs\n    mkdir /data/misc/perfd 0755 root system\n    chmod 2755 /data/misc/perfd\n    mkdir /data/system/perfd 0770 root system\n    chmod 2770 /data/system/perfd\n\n# start camera server as daemon\nservice qcamerasvr /system/bin/mm-qcamera-daemon\n    class late_start\n    user camera\n    group camera system inet input graphics\n    writepid /dev/cpuset/camera-daemon/tasks\n\nservice qseecomd /system/bin/qseecomd\n    class core\n    user root\n    group root\n    writepid /dev/cpuset/system-background/tasks\n\nservice perfd /system/vendor/bin/perfd\n    class main\n    user root\n    disabled\n    writepid /dev/cpuset/system-background/tasks\n\nservice per_mgr /system/bin/pm-service\n    class late_start\n    user system\n    group system net_raw\n    writepid /dev/cpuset/system-background/tasks\n\nservice per_proxy /system/bin/pm-proxy\n    class late_start\n    user system\n    group system net_raw\n    writepid /dev/cpuset/system-background/tasks\n    disabled\n\non property:init.svc.per_mgr=running\n    start per_proxy\n\non property:sys.shutdown.requested=*\n    stop per_proxy\n\nservice zram-init /system/bin/sh /system/etc/init.zram.sh\n    class late_start\n    user root\n    disabled\n    oneshot\n\nservice fingerprintd /system/bin/fingerprintd\n    class late_start\n    user system\n    group system\n    writepid /dev/cpuset/system-background/tasks\n\nservice thermal-engine /system/vendor/bin/thermal-engine\n    class main\n    user root\n    socket thermal-send-client stream 0666 system system\n    socket thermal-recv-client stream 0660 system system\n    socket thermal-recv-passive-client stream 0666 system system\n    group root\n    writepid /dev/cpuset/system-background/tasks\n\nservice time_daemon /system/bin/time_daemon\n    class late_start\n    user root\n    group root\n    writepid /dev/cpuset/system-background/tasks\n\nservice adsprpcd /system/bin/adsprpcd\n    class main\n    user media\n    group media\n\nservice imsqmidaemon /system/bin/imsqmidaemon\n    class main\n    user system\n    socket ims_qmid stream 0660 system radio\n    group radio log diag\n\nservice imsdatadaemon /system/bin/imsdatadaemon\n    class main\n    user system\n    socket ims_datad stream 0660 system radio\n    group system wifi radio inet log diag\n    disabled\n\non property:sys.ims.QMI_DAEMON_STATUS=1\n    start imsdatadaemon\n\nservice ims_rtp_daemon /system/bin/ims_rtp_daemon\n   class main\n   user system\n   socket ims_rtpd stream 0660 system radio\n   group radio diag inet log\n   disabled\n\non property:sys.ims.DATA_DAEMON_STATUS=1\n    start ims_rtp_daemon\n\nservice imscmservice /system/bin/imscmservice\n   class main\n   user system\n   group radio diag log\n\nservice usf_tester /system/bin/usf_tester\n    user system\n    group system inet\n    disabled\n\nservice usf_epos /system/bin/usf_epos\n    class main\n    user system\n    group system inet\n    disabled\n\nservice usf_gesture /system/bin/usf_gesture\n    user system\n    group system inet\n    disabled\n\nservice usf_sync_gesture /system/bin/usf_sync_gesture\n    user system\n    group system inet audio\n    disabled\n\nservice usf_p2p /system/bin/usf_p2p\n    user system\n    group system inet\n    disabled\n\nservice usf_hovering /system/bin/usf_hovering\n    user system\n    group system inet\n    disabled\n\nservice usf_proximity /system/bin/usf_proximity\n    user system\n    group system inet\n    disabled\n\nservice usf_pairing /system/bin/usf_pairing\n    user system\n    group system inet\n    disabled\n\nservice usf_sw_calib /system/bin/usf_sw_calib\n    user system\n    group system inet\n    disabled\n\nservice usf-post-boot /system/bin/sh /system/etc/usf_post_boot.sh\n    class late_start\n    user root\n    disabled\n    oneshot\n\non property:init.svc.bootanim=running\n    write /sys/module/lpm_levels/system/a53/cpu0/retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a53/cpu1/retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a53/cpu2/retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a53/cpu3/retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a57/cpu4/retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a57/cpu5/retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a57/cpu6/retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a57/cpu7/retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a57/a57-l2-retention/idle_enabled 0\n    write /sys/module/lpm_levels/system/a53/a53-l2-retention/idle_enabled 0\n    write /sys/module/lpm_levels/parameters/sleep_disabled 0\n\non property:init.svc.bootanim=stopped\n    start usf-post-boot\n\nservice energy-awareness /system/bin/energy-awareness\n    class main\n    user root\n    group system\n    oneshot\n\non property:sys.boot_completed=1\n    start zram-init\n    write /dev/kmsg \"Boot completed \"\n\n# corefile limit and ETB enabling\non property:persist.debug.trace=1\n    mkdir /data/core 0777 root root\n    write /proc/sys/kernel/core_pattern \"/data/core/%E.%p.%e\"\n    write /sys/devices/system/cpu/cpu1/online 1\n    write /sys/devices/system/cpu/cpu2/online 1\n    write /sys/devices/system/cpu/cpu3/online 1\n    write /sys/bus/coresight/devices/coresight-etm0/enable 0\n    write /sys/bus/coresight/devices/coresight-etm1/enable 0\n    write /sys/bus/coresight/devices/coresight-etm2/enable 0\n    write /sys/bus/coresight/devices/coresight-etm3/enable 0\n    write /sys/bus/coresight/devices/coresight-etm0/reset 1\n    write /sys/bus/coresight/devices/coresight-etm1/reset 1\n    write /sys/bus/coresight/devices/coresight-etm2/reset 1\n    write /sys/bus/coresight/devices/coresight-etm3/reset 1\n    write /sys/bus/coresight/devices/coresight-etm0/enable 1\n    write /sys/bus/coresight/devices/coresight-etm1/enable 1\n    write /sys/bus/coresight/devices/coresight-etm2/enable 1\n    write /sys/bus/coresight/devices/coresight-etm3/enable 1\n    write /sys/module/coresight_event/parameters/event_abort_enable 1\n\non property:bluetooth.isEnabled=true\n    write /sys/class/bluetooth/hci0/idle_timeout 7000\n\non property:bluetooth.sap.status=running\n    start bt-sap\n\non property:bluetooth.sap.status=stopped\n    stop bt-sap\n\non property:bluetooth.dun.status=running\n    start bt-dun\n\non property:bluetooth.dun.status=stopped\n    stop bt-dun\n\non property:ro.bluetooth.ftm_enabled=true\n    start ftmd\n\non property:bluetooth.startbtsnoop=true\n    start btsnoop\n\non property:bluetooth.startbtsnoop=false\n    stop btsnoop\n\nservice ppd /system/bin/mm-pp-daemon\n    class late_start\n    disabled\n    user system\n    socket pps stream 0660 system system\n    group system graphics\n\non property:init.svc.surfaceflinger=stopped\n    stop ppd\n\non property:init.svc.surfaceflinger=running\n    start ppd\n\non property:vold.decrypt=trigger_restart_framework\n    start config_bluetooth\n\non property:persist.env.fastdorm.enabled=true\n    setprop persist.radio.data_no_toggle 1\n\nservice cnd /system/bin/cnd\n    class main\n    socket cnd stream 660 root inet\n\nservice dpmd /system/bin/dpmd\n    class late_start\n    socket dpmd stream 660 root system\n\nservice irsc_util /system/bin/irsc_util \"/etc/sec_config\"\n    class main\n    user root\n    oneshot\n\nservice rmt_storage /system/bin/rmt_storage\n    class core\n    user root\n    writepid /dev/cpuset/system-background/tasks\n\nservice rfs_access /system/bin/rfs_access\n    class core\n    user root\n    group system net_raw\n\non property:wc_transport.start_hci=true\n    start start_hci_filter\n\non property:wc_transport.start_hci=false\n    stop start_hci_filter\n\n# begin qrd patch for bluetoot cts test 2015 06 23 zuoyonghua@oneplus.cn\nservice start_hci_filter /system/bin/wcnss_filter\n    class late_start\n    user bluetooth\n    group bluetooth qcom_diag\n    disabled\n\non property:wc_transport.start_root=true\n    start hci_filter_root\n\non property:wc_transport.start_root=false\n    stop hci_filter_root\n\nservice hci_filter_root /system/bin/wcnss_filter\n    class late_start\n    user bluetooth\n    group bluetooth qcom_diag net_bt_stack system\n    disabled\n\nservice config_bluetooth /system/bin/sh /system/etc/init.qcom.bt.sh \"onboot\"\n    class core\n    user root\n    oneshot\n\nservice hciattach /system/bin/sh /system/etc/init.qcom.bt.sh\n    class late_start\n    user bluetooth\n    group bluetooth net_bt_admin\n    disabled\n    oneshot\n\non property:bluetooth.hciattach=true\n    start hciattach\n\non property:bluetooth.hciattach=false\n    setprop bluetooth.status off\n\nservice bt-dun /system/bin/dun-server /dev/smd7 /dev/rfcomm0\n    class late_start\n    user bluetooth\n    group bluetooth net_bt_admin inet\n    disabled\n    oneshot\n\nservice bt-sap /system/bin/sapd 15\n    user bluetooth\n    group bluetooth net_bt_admin\n    class late_start\n    disabled\n    oneshot\n\nservice btsnoop /system/bin/btsnoop\n    user bluetooth\n    group bluetooth net_bt_admin sdcard_rw sdcard_r\n    class late_start\n    disabled\n    oneshot\n\nservice ftmd /system/bin/logwrapper /system/bin/ftmdaemon\n    class late_start\n    user root\n    group bluetooth net_bt_admin misc net_bt_stack qcom_diag net_bt\n    disabled\n    oneshot\n\n# QMUX must be in multiple groups to support external process connections\nservice qmuxd /system/bin/qmuxd\n    class main\n    user root\n    group radio audio bluetooth gps qcom_diag\n    writepid /dev/cpuset/system-background/tasks\n\nservice netmgrd /system/bin/netmgrd\n    class main\n    writepid /dev/cpuset/system-background/tasks\n\nservice ipacm-diag /system/bin/ipacm-diag\n    class main\n    user system\n    socket ipacm_log_file dgram 660 system net_admin\n    group net_admin qcom_diag\n\nservice ipacm /system/bin/ipacm\n    class main\n    user net_admin\n    group net_admin inet\n\nservice qti /system/vendor/bin/qti\n    class main\n    user radio\n    group radio net_raw qcom_diag usb net_admin\n    writepid /dev/cpuset/system-background/tasks\n    disabled\n\nservice sensors /system/bin/sensors.qcom\n    class late_start\n    user root\n    group root\n    disabled\n\non property:ro.use_data_netmgrd=false\n    # netmgr not supported on specific target\n    stop netmgrd\n\n# Adjust socket buffer to enlarge TCP receive window for high bandwidth\n# but only if ro.data.large_tcp_window_size property is set.\non property:ro.data.large_tcp_window_size=true\n    write /proc/sys/net/ipv4/tcp_adv_win_scale  2\n\non property:sys.sysctl.tcp_adv_win_scale=*\n    write /proc/sys/net/ipv4/tcp_adv_win_scale ${sys.sysctl.tcp_adv_win_scale}\n\nservice amp_init /system/bin/amploader -i\n    class late_start\n    user root\n    disabled\n    oneshot\n\nservice amp_load /system/bin/amploader -l 7000\n    class late_start\n    user root\n    disabled\n    oneshot\n\nservice amp_unload /system/bin/amploader -u\n    class late_start\n    user root\n    disabled\n    oneshot\n\nservice p2p_supplicant /system/bin/wpa_supplicant \\\n    -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \\\n    -I/system/etc/wifi/p2p_supplicant_overlay.conf -N \\\n    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \\\n    -I/system/etc/wifi/wpa_supplicant_overlay.conf \\\n    -O/data/misc/wifi/sockets -puse_p2p_group_interface=1 -dd \\\n    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0\n    # we will start as root and wpa_supplicant will switch to user wifi\n    # after setting up the capabilities required for WEXT\n    # user wifi\n    # group wifi inet keystore\n    class main\n    socket wpa_wlan0 dgram 660 wifi wifi\n    disabled\n    oneshot\n\nservice wpa_supplicant /system/bin/wpa_supplicant \\\n    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \\\n    -I/system/etc/wifi/wpa_supplicant_overlay.conf \\\n    -O/data/misc/wifi/sockets -dd \\\n    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0\n    # we will start as root and wpa_supplicant will switch to user wifi\n    # after setting up the capabilities required for WEXT\n    # user wifi\n    # group wifi inet keystore\n    class main\n    socket wpa_wlan0 dgram 660 wifi wifi\n    disabled\n    oneshot\n\nservice ptt_socket_app /system/bin/ptt_socket_app -d\n    class main\n    user root\n    group root\n    oneshot\n\nservice ptt_ffbm /system/bin/ptt_socket_app -f -d\n    user root\n    group root\n    disabled\n    oneshot\n\nservice ftm_ffbm /system/bin/ftmdaemon\n    user root\n    group root\n    disabled\n    oneshot\n\nservice cnss_diag /system/bin/cnss_diag -q -f\n    class main\n    user root\n    group root\n    disabled\n\non property:cnss_diag.load=true\n    start cnss_diag\n\non property:cnss_diag.load=false\n    stop cnss_diag\n\nservice cnss-daemon /system/bin/cnss-daemon -n -l\n    class late_start\n\nservice loc_launcher /system/bin/loc_launcher\n    #loc_launcher will start as root and set its uid to gps\n    class late_start\n    group gps inet net_raw diag net_admin wifi\n\nservice drmdiag /system/bin/drmdiagapp\n    class late_start\n    user root\n    disabled\n    oneshot\n\non property:drmdiag.load=1\n    start drmdiag\n\non property:drmdiag.load=0\n    stop drmdiag\n\nservice qcom-sh /system/bin/sh /init.qcom.sh\n    class late_start\n    user root\n    oneshot\n\nservice hostapd /system/bin/hostapd /data/hostapd/hostapd.conf\n    class late_start\n    user root\n    group root\n    oneshot\n    disabled\n\nservice ims_regmanager /system/bin/exe-ims-regmanagerprocessnative\n    class late_start\n    group net_bt_admin inet radio wifi\n    disabled\n\non property:persist.ims.regmanager.mode=1\n    start ims_regmanager\n\non property:ro.data.large_tcp_window_size=true\n    # Adjust socket buffer to enlarge TCP receive window for high bandwidth (e.g. DO-RevB)\n    write /proc/sys/net/ipv4/tcp_adv_win_scale  2\n\nservice battery_monitor /system/bin/battery_monitor\n    user system\n    group system\n    disabled\n\nservice ril-daemon2 /system/bin/rild -c 2\n    class main\n    socket rild2 stream 660 root radio\n    socket rild-debug2 stream 660 radio system\n    user root\n    group radio cache inet misc audio sdcard_r sdcard_rw diag qcom_diag log\n\nservice profiler_daemon /system/bin/profiler_daemon\n    class late_start\n    user root\n    group root\n    disabled\n\nservice ssr_diag /system/bin/ssr_diag\n    class late_start\n    user system\n    group system\n    disabled\n\nservice hvdcp /system/bin/hvdcp\n    class core\n    user root\n    disabled\n\non property:persist.usb.hvdcp.detect=true\n    start hvdcp\n\non property:persist.usb.hvdcp.detect=false\n    stop hvdcp\n\nservice charger_monitor /system/bin/charger_monitor\n    user root\n    group root\n    disabled\n\nservice qbcharger /charger -m 1\n    disabled\n    oneshot\n\non property:sys.qbcharger.enable=true\n    start qbcharger\n\non property:sys.qbcharger.enable=false\n    stop qbcharger\n\nservice msm_irqbalance /system/bin/msm_irqbalance -f /system/vendor/etc/msm_irqbalance.conf\n    socket msm_irqbalance seqpacket 660 root system\n    class main\n    user root\n    group root\n    disabled\n    writepid /dev/cpuset/system-background/tasks\n"
  },
  {
    "path": "rootdir/etc/init.qcom.sh",
    "content": "#!/system/bin/sh\n# Copyright (c) 2009-2015, The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above copyright\n#       notice, this list of conditions and the following disclaimer in the\n#       documentation and/or other materials provided with the distribution.\n#     * Neither the name of The Linux Foundation nor\n#       the names of its contributors may be used to endorse or promote\n#       products derived from this software without specific prior written\n#       permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n# NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#\n\ntarget=`getprop ro.board.platform`\nif [ -f /sys/devices/soc0/soc_id ]; then\n    platformid=`cat /sys/devices/soc0/soc_id`\nelse\n    platformid=`cat /sys/devices/system/soc/soc0/id`\nfi\n#\n# Function to start sensors for DSPS enabled platforms\n#\n# VENDOR_EDIT\n# qiuchangping@BSP 2015-04-16 add begin for gyro sensitity calibration\nstart_sensors()\n{\n    if [ -c /dev/msm_dsps -o -c /dev/sensors ]; then\n        mkdir -p /persist/sensors\n        chmod -h 775 /persist/sensors\n        chmod -h 664 /persist/sensors/sensors_settings\n        chown -h system.root /persist/sensors/sensors_settings\n        chmod -h 664 /persist/sensors/gyro_sensitity_cal\n        chown -h system.root /persist/sensors/gyro_sensitity_cal\n\n        mkdir -p /data/misc/sensors\n        chmod -h 775 /data/misc/sensors\n\n        start sensors\n    fi\n}\n# qiucahngping@BSP add end\n\nstart_battery_monitor()\n{\n\tif ls /sys/bus/spmi/devices/qpnp-bms-*/fcc_data ; then\n\t\tchown -h root.system /sys/module/pm8921_bms/parameters/*\n\t\tchown -h root.system /sys/module/qpnp_bms/parameters/*\n\t\tchown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_data\n\t\tchown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_temp\n\t\tchown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_chgcyl\n\t\tchmod 0660 /sys/module/qpnp_bms/parameters/*\n\t\tchmod 0660 /sys/module/pm8921_bms/parameters/*\n\t\tmkdir -p /data/bms\n\t\tchown -h root.system /data/bms\n\t\tchmod 0770 /data/bms\n\t\tstart battery_monitor\n\tfi\n}\n\nstart_charger_monitor()\n{\n\tif ls /sys/module/qpnp_charger/parameters/charger_monitor; then\n\t\tchown -h root.system /sys/module/qpnp_charger/parameters/*\n\t\tchown -h root.system /sys/class/power_supply/battery/input_current_max\n\t\tchown -h root.system /sys/class/power_supply/battery/input_current_trim\n\t\tchown -h root.system /sys/class/power_supply/battery/input_current_settled\n\t\tchown -h root.system /sys/class/power_supply/battery/voltage_min\n\t\tchmod 0664 /sys/class/power_supply/battery/input_current_max\n\t\tchmod 0664 /sys/class/power_supply/battery/input_current_trim\n\t\tchmod 0664 /sys/class/power_supply/battery/input_current_settled\n\t\tchmod 0664 /sys/class/power_supply/battery/voltage_min\n\t\tchmod 0664 /sys/module/qpnp_charger/parameters/charger_monitor\n\t\tstart charger_monitor\n\tfi\n}\n\nstart_vm_bms()\n{\n\tif [ -e /dev/vm_bms ]; then\n\t\tchown -h root.system /sys/class/power_supply/bms/current_now\n\t\tchown -h root.system /sys/class/power_supply/bms/voltage_ocv\n\t\tchmod 0664 /sys/class/power_supply/bms/current_now\n\t\tchmod 0664 /sys/class/power_supply/bms/voltage_ocv\n\t\tstart vm_bms\n\tfi\n}\n\nstart_msm_irqbalance_8939()\n{\n\tif [ -f /system/bin/msm_irqbalance ]; then\n\t\tcase \"$platformid\" in\n\t\t    \"239\")\n\t\t\tstart msm_irqbalance;;\n\t\tesac\n\tfi\n}\n\nstart_msm_irqbalance()\n{\n\tif [ -f /system/bin/msm_irqbalance ]; then\n\t\tstart msm_irqbalance\n\tfi\n}\n\nbaseband=`getprop ro.baseband`\n#\n# Suppress default route installation during RA for IPV6; user space will take\n# care of this\n# exception default ifc\nfor file in /proc/sys/net/ipv6/conf/*\ndo\n  echo 0 > $file/accept_ra_defrtr\ndone\necho 1 > /proc/sys/net/ipv6/conf/default/accept_ra_defrtr\n\ncase \"$baseband\" in\n        \"svlte2a\")\n        start bridgemgrd\n        ;;\nesac\n\nstart_sensors\n\ncase \"$target\" in\n    \"msm7630_surf\" | \"msm7630_1x\" | \"msm7630_fusion\")\n        if [ -f /sys/devices/soc0/hw_platform ]; then\n            value=`cat /sys/devices/soc0/hw_platform`\n        else\n            value=`cat /sys/devices/system/soc/soc0/hw_platform`\n        fi\n        case \"$value\" in\n            \"Fluid\")\n             start profiler_daemon;;\n        esac\n        ;;\n    \"msm8660\" )\n        if [ -f /sys/devices/soc0/hw_platform ]; then\n            platformvalue=`cat /sys/devices/soc0/hw_platform`\n        else\n            platformvalue=`cat /sys/devices/system/soc/soc0/hw_platform`\n        fi\n        case \"$platformvalue\" in\n            \"Fluid\")\n                start profiler_daemon;;\n        esac\n        ;;\n    \"msm8960\")\n        case \"$baseband\" in\n            \"msm\")\n                start_battery_monitor;;\n        esac\n\n        if [ -f /sys/devices/soc0/hw_platform ]; then\n            platformvalue=`cat /sys/devices/soc0/hw_platform`\n        else\n            platformvalue=`cat /sys/devices/system/soc/soc0/hw_platform`\n        fi\n        case \"$platformvalue\" in\n             \"Fluid\")\n                 start profiler_daemon;;\n             \"Liquid\")\n                 start profiler_daemon;;\n        esac\n        ;;\n    \"msm8974\")\n        platformvalue=`cat /sys/devices/soc0/hw_platform`\n        case \"$platformvalue\" in\n             \"Fluid\")\n                 start profiler_daemon;;\n             \"Liquid\")\n                 start profiler_daemon;;\n        esac\n        case \"$baseband\" in\n            \"msm\")\n                start_battery_monitor\n                ;;\n        esac\n        start_charger_monitor\n        ;;\n    \"apq8084\")\n        platformvalue=`cat /sys/devices/soc0/hw_platform`\n        case \"$platformvalue\" in\n             \"Fluid\")\n                 start profiler_daemon;;\n             \"Liquid\")\n                 start profiler_daemon;;\n        esac\n        ;;\n    \"msm8226\")\n        start_charger_monitor\n        ;;\n    \"msm8610\")\n        start_charger_monitor\n        ;;\n    \"msm8916\")\n        start_vm_bms\n        start_msm_irqbalance_8939\n        if [ -f /sys/devices/soc0/soc_id ]; then\n            soc_id=`cat /sys/devices/soc0/soc_id`\n        else\n            soc_id=`cat /sys/devices/system/soc/soc0/id`\n        fi\n\n        if [ -f /sys/devices/soc0/platform_subtype_id ]; then\n             platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id`\n        fi\n        if [ -f /sys/devices/soc0/hw_platform ]; then\n             hw_platform=`cat /sys/devices/soc0/hw_platform`\n        fi\n        case \"$soc_id\" in\n             \"239\")\n                  case \"$hw_platform\" in\n                       \"Surf\")\n                            case \"$platform_subtype_id\" in\n                                 \"1\")\n                                      setprop qemu.hw.mainkeys 0\n                                      ;;\n                            esac\n                            ;;\n                       \"MTP\")\n                          case \"$platform_subtype_id\" in\n                               \"3\")\n                                    setprop qemu.hw.mainkeys 0\n                                    ;;\n                          esac\n                          ;;\n                  esac\n                  ;;\n        esac\n        ;;\n    \"msm8994\" | \"msm8992\")\n        start_msm_irqbalance\n        ;;\n    \"msm8909\")\n        start_vm_bms\n        ;;\nesac\n\nbootmode=`getprop ro.bootmode`\nemmc_boot=`getprop ro.boot.emmc`\ncase \"$emmc_boot\"\n    in \"true\")\n        if [ \"$bootmode\" != \"charger\" ]; then # start rmt_storage and rfs_access\n            start rmt_storage\n            start rfs_access\n        fi\n    ;;\nesac\n\n#\n# Make modem config folder and copy firmware config to that folder\n#\nrm -rf /data/misc/radio/modem_config\nmkdir /data/misc/radio/modem_config\n#ifdef VENDOR_EDIT\n# Modify /data/misc/radio/modem_config authority to 770 from 660, and modify the target path to /system/etc/firmware/mbn_ota/, by hanqingpu@oneplus.cn, 20150530\nchmod 770 /data/misc/radio/modem_config\ncp -r /system/etc/firmware/mbn_ota/* /data/misc/radio/modem_config\n#endif /*VENDOR_EDIT*/\nchown -hR radio.radio /data/misc/radio/modem_config\necho 1 > /data/misc/radio/copy_complete\n"
  },
  {
    "path": "rootdir/etc/init.qcom.usb.rc",
    "content": "# Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above copyright\n#       notice, this list of conditions and the following disclaimer in the\n#       documentation and/or other materials provided with the distribution.\n#     * Neither the name of The Linux Foundation nor\n#       the names of its contributors may be used to endorse or promote\n#       products derived from this software without specific prior written\n#       permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n# NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#\n\non init\n    write /sys/class/android_usb/android0/f_rndis/wceis 1\n    write /sys/class/android_usb/android0/iSerial ${ro.serialno}\n\non charger\n    setprop persist.sys.usb.config mass_storage\n\non fs\n    mkdir /dev/usb-ffs 0770 shell shell\n    mkdir /dev/usb-ffs/adb 0770 shell shell\n    mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000\n    write /sys/class/android_usb/android0/f_ffs/aliases adb\n    setprop persist.sys.usb.config adb\n\nservice qcom-usb-sh /system/bin/sh /init.qcom.usb.sh\n    class core\n    user root\n    oneshot\n\n# Following are the parameters required for usb functionality. They provide configurable options like\n# product_id/vendor id and allows specifying required functions:\n#\n# Required parameters:\n#\n# /sys/class/android_usb/android0/enable: Enables/disables usb composition\n# Value: 0 (disable), 1 (enable)\n#\n# /sys/class/android_usb/android0/idVendor: Stores Vendor ID\n# Value: 05c6 (Vendor id for Qualcomm Inc)\n#\n# /sys/class/android_usb/android0/idProduct: Stores Product id corresponding to usb composition\n# Value: 0x9xxx for composite interface, 0xFxxx for single interface\n#\n# /sys/class/android_usb/android0/f_diag/clients: Stores name of clients representing a diag interface.\n# Value: Passed one per interface. e.g. diag[,diag_mdm, diag_qsc, diag_mdm2]\n#\n# /sys/class/android_usb/android0/functions: Stores name of the function drivers used in usb composition.\n# Value: Passed one per function driver. e.g. diag[,adb]\n#\n#Optional parameters:\n#\n# /sys/class/android_usb/android0/f_serial/transports: Stores type of underlying transports used to\n# communicate to serial interface.\n# Value: Passed one per interface. One value represents control and data transport together.\n# e.g. smd[,sdio,tty,hsic]\n# Only required if serial interface is present.\n#\n# /sys/class/android_usb/android0/f_serial/transport_names: Stores name of the underlying transports\n# used to communicate to serial interface. This is used to distinguish between more than one interface\n# using same transport type.\n# Value: Passed one per interface. One value represents control and data transport together.\n# e.g. serial_hsic[,serial_hsusb]\n# Only required for transport type hsic, optional for other transport types.\n#\n# /sys/class/android_usb/android0/f_rmnet/transports: Stores type of underlying transports used to\n# communicate to rmnet interface.\n# Value: Passed two per interface as control, data transport type pair.\n# e.g. smd,bam[,hsuart,hsuart]\n# Only required if rmnet interface is present.\n#\n# /sys/class/android_usb/android0/f_rmnet/transport_names: Stores name of the underlying transports\n# used to communicate to rmnet interface. This is used to distinguish between more than one interface\n# using same transport type.\n# Value: Passed one per interface. One value represents control and data transport together.\n# e.g. rmnet_hsic[,rmnet_hsusb]\n# Only required for transport type hsic, optional for other transport types.\n\n# USB compositions\non property:sys.usb.config=diag,serial_tty,serial_smd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9002\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports tty,smd\n    write /sys/class/android_usb/android0/functions diag,serial\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_tty,serial_smd,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9020\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n    write /sys/class/android_usb/android0/functions diag,adb,serial\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 901D\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/functions diag,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 900E\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/functions diag\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,rmnet_bam,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9091\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,rmnet_qti_bam,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9091\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,rmnet_bam\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9092\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,rmnet_qti_bam\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9092\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9025\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,acm_smd,acm_tty,rmnet_bam,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903D\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_acm/acm_transports smd,tty\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam\n    write /sys/class/android_usb/android0/functions diag,adb,acm,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_bam,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9026\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,acm_smd,acm_tty,rmnet_bam,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903E\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_acm/acm_transports smd,tty\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,serial_sdio,serial_smd,rmnet_smd_sdio,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9037\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports sdio,smd\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet_smd_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,acm_sdio,acm_smd,rmnet_smd_sdio,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903B\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_acm/acm_transports sdio,smd\n    write /sys/class/android_usb/android0/functions diag,adb,acm,rmnet_smd_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,serial_sdio,serial_smd,rmnet_smd_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9038\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports sdio,smd\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet_smd_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,acm_sdio,acm_smd,rmnet_smd_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903C\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_acm/acm_transports sdio,smd\n    write /sys/class/android_usb/android0/functions diag,acm,rmnet_smd_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,serial_sdio,serial_tty,rmnet_sdio,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9031\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports sdio,tty\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,acm_sdio,acm_tty,rmnet_sdio,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903B\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_acm/acm_transports sdio,tty\n    write /sys/class/android_usb/android0/functions diag,adb,acm,rmnet_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,serial_sdio,serial_tty,rmnet_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9032\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports sdio,tty\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,acm_sdio,acm_tty,rmnet_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903C\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_acm/acm_transports sdio,tty\n    write /sys/class/android_usb/android0/functions diag,acm,rmnet_sdio,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_tty,serial_tty,rmnet_smd,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9025\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports tty,tty\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    start port-bridge\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,acm_tty,acm_tty,rmnet_smd,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903D\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_acm/acm_transports tty,tty\n    write /sys/class/android_usb/android0/functions diag,adb,acm,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    start port-bridge\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_tty,serial_tty,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9026\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports tty,tty\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start port-bridge\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,acm_tty,acm_tty,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903E\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_acm/acm_transports tty,tty\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_smd,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9025\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,acm_smd,acm_tty,rmnet_smd,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903D\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_acm/acm_transports smd,tty\n    write /sys/class/android_usb/android0/functions diag,adb,acm,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    start port-bridge\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9026\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,acm_smd,acm_tty,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903E\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_acm/acm_transports smd,tty\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet_smd,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\n# RmNet using USB BAM to IPA BAM\non property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_ipa,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9025\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_ipa,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9026\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,rmnet_ipa,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9091\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,serial_smd,rmnet_ipa\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9092\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 3 composition\non property:sys.usb.config=diag,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9025\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports hsic,tty\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_rmnet/transport_names rmnet_hsic\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/module/mdm_bridge/parameters/rx_rmnet_buffer_size 16384\n    write /sys/module/mdm_bridge/parameters/max_rx_urbs 20\n    write /sys/module/g_android/parameters/ghsic_data_rx_req_size 16384\n    write /sys/module/g_android/parameters/ghsic_data_rmnet_rx_q_size 20\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 3 composition with diag_mdm and adb\non property:sys.usb.config=diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9031\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports hsic,tty\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_rmnet/transport_names rmnet_hsic\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/module/mdm_bridge/parameters/rx_rmnet_buffer_size 16384\n    write /sys/module/mdm_bridge/parameters/max_rx_urbs 20\n    write /sys/module/g_android/parameters/ghsic_data_rx_req_size 16384\n    write /sys/module/g_android/parameters/ghsic_data_rmnet_rx_q_size 20\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 3 composition with diag_mdm\non property:sys.usb.config=diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9032\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports hsic,tty\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_rmnet/transport_names rmnet_hsic\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/module/mdm_bridge/parameters/rx_rmnet_buffer_size 16384\n    write /sys/module/mdm_bridge/parameters/max_rx_urbs 20\n    write /sys/module/g_android/parameters/ghsic_data_rx_req_size 16384\n    write /sys/module/g_android/parameters/ghsic_data_rmnet_rx_q_size 20\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 3 DSDA composition with adb\non property:sys.usb.config=diag,diag_mdm,diag_qsc,serial_hsic,serial_hsuart,rmnet_hsic,rmnet_hsuart,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9065\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm,diag_qsc\n    write /sys/class/android_usb/android0/f_serial/transports hsic,hsuart\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic,serial_hsuart\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic,hsuart,hsuart\n    write /sys/class/android_usb/android0/f_rmnet/transport_names rmnet_hsic,rmnet_hsuart\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/module/mdm_bridge/parameters/rx_rmnet_buffer_size 16384\n    write /sys/module/mdm_bridge/parameters/max_rx_urbs 20\n    write /sys/module/g_android/parameters/ghsic_data_rx_req_size 16384\n    write /sys/module/g_android/parameters/ghsic_data_rmnet_rx_q_size 20\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 3 DSDA composition without adb\non property:sys.usb.config=diag,diag_mdm,diag_qsc,serial_hsic,serial_hsuart,rmnet_hsic,rmnet_hsuart,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9066\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm,diag_qsc\n    write /sys/class/android_usb/android0/f_serial/transports hsic,hsuart\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic,serial_hsuart\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic,hsuart,hsuart\n    write /sys/class/android_usb/android0/f_rmnet/transport_names rmnet_hsic,rmnet_hsuart\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/module/mdm_bridge/parameters/rx_rmnet_buffer_size 16384\n    write /sys/module/mdm_bridge/parameters/max_rx_urbs 20\n    write /sys/module/g_android/parameters/ghsic_data_rx_req_size 16384\n    write /sys/module/g_android/parameters/ghsic_data_rmnet_rx_q_size 20\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 3 DSDA2 composition with adb\non property:sys.usb.config=diag,diag_mdm,diag_mdm2,serial_hsic,serial_hsusb,rmnet_hsic,rmnet_hsusb,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9065\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm,diag_mdm2\n    write /sys/class/android_usb/android0/f_serial/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic,serial_hsusb\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic,hsic,hsic\n    write /sys/class/android_usb/android0/f_rmnet/transport_names rmnet_hsic,rmnet_hsusb\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/module/mdm_bridge/parameters/rx_rmnet_buffer_size 16384\n    write /sys/module/mdm_bridge/parameters/max_rx_urbs 20\n    write /sys/module/g_android/parameters/ghsic_data_rx_req_size 16384\n    write /sys/module/g_android/parameters/ghsic_data_rmnet_rx_q_size 20\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 3 DSDA2 composition without adb\non property:sys.usb.config=diag,diag_mdm,diag_mdm2,serial_hsic,serial_hsusb,rmnet_hsic,rmnet_hsusb,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9066\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm,diag_mdm2\n    write /sys/class/android_usb/android0/f_serial/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic,serial_hsusb\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic,hsic,hsic\n    write /sys/class/android_usb/android0/f_rmnet/transport_names rmnet_hsic,rmnet_hsusb\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/module/mdm_bridge/parameters/rx_rmnet_buffer_size 16384\n    write /sys/module/mdm_bridge/parameters/max_rx_urbs 20\n    write /sys/module/g_android/parameters/ghsic_data_rx_req_size 16384\n    write /sys/module/g_android/parameters/ghsic_data_rmnet_rx_q_size 20\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion PCIe composition with diag_mdm and adb\n# Serial & RmNet bridged in userspace with tty and qti/ether\non property:sys.usb.config=diag,diag_mdm,serial_tty,rmnet_qti_ether,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9035\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports tty\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,ether\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion PCIe composition with diag_mdm\n# Serial & RmNet bridged in userspace with tty and qti/ether\non property:sys.usb.config=diag,diag_mdm,serial_hsic,rmnet_hsic,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9036\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports tty\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,ether\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion HSIC/PCIe Hybrid composition with diag_mdm and adb\n# RmNet is bridged over PCIe using qti,ether ctrl/data transports\non property:sys.usb.config=diag,diag_mdm,serial_hsic,rmnet_qti_ether,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9035\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports hsic\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,ether\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion HSIC/PCIe Hybrid composition with diag_mdm\n# RmNet is bridged over PCIe using qti,ether ctrl/data transports\non property:sys.usb.config=diag,diag_mdm,serial_hsic,rmnet_hsic,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9036\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_serial/transports hsic\n    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,ether\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 2.2 composition with diag_qsc and adb\non property:sys.usb.config=diag,diag_qsc,serial_smd,serial_tty,serial_hsuart,rmnet_hsuart,mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9053\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_qsc\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty,hsuart\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam,hsuart,hsuart\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# Fusion 2.2 composition with diag_qsc\non property:sys.usb.config=diag,diag_qsc,serial_smd,serial_tty,serial_hsuart,rmnet_hsuart,mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9054\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_qsc\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty,hsuart\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam,hsuart,hsuart\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=rndis\n    setprop sys.usb.config rndis,${persist.sys.usb.config.extra}\n\non property:sys.usb.config=rndis,none\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct F00E\n    write /sys/class/android_usb/android0/functions rndis\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state rndis\n\non property:sys.usb.config=rndis,adb\n    setprop sys.usb.config rndis,${persist.sys.usb.config.extra},adb\n\non property:sys.usb.config=rndis,none,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9024\n    write /sys/class/android_usb/android0/functions rndis,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state rndis,adb\n\non property:sys.usb.config=rndis,diag\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 902C\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/functions rndis,diag\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state rndis\n\non property:sys.usb.config=rndis,diag,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 902D\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/functions rndis,diag,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state rndis,adb\n\non property:sys.usb.config=rndis,serial_smd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 90B3\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/functions rndis,serial\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state rndis\n\non property:sys.usb.config=rndis,serial_smd,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 90B4\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/functions rndis,serial,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state rndis,adb\n\non property:sys.usb.config=rndis,serial_smd,diag\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 90B5\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/functions rndis,serial,diag\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state rndis\n\non property:sys.usb.config=rndis,serial_smd,diag,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 90B6\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd\n    write /sys/class/android_usb/android0/functions rndis,serial,diag,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state rndis,adb\n\non property:sys.usb.config=rndis,diag,diag_mdm\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9041\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/functions rndis,diag\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state rndis\n\non property:sys.usb.config=rndis,diag,diag_mdm,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9042\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/functions rndis,diag,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state rndis,adb\n\non property:sys.usb.config=rndis,diag,diag_mdm,diag_qsc\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9086\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm,diag_qsc\n    write /sys/class/android_usb/android0/functions rndis,diag\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state rndis\n\non property:sys.usb.config=rndis,diag,diag_mdm,diag_qsc,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9087\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm,diag_qsc\n    write /sys/class/android_usb/android0/functions rndis,diag,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state rndis,adb\n\non property:sys.usb.config=ptp\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 904D\n    write /sys/class/android_usb/android0/functions ptp\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=ptp,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 904E\n    write /sys/class/android_usb/android0/functions ptp,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mtp\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct F003\n    write /sys/class/android_usb/android0/functions mtp\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mtp,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9039\n    write /sys/class/android_usb/android0/functions mtp,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mtp,diag\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 901B\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/functions mtp,diag\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mtp,diag,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903A\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/functions mtp,diag,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mtp,diag,diag_mdm\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9040\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/functions mtp,diag\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mtp,diag,diag_mdm,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 903F\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/functions mtp,diag,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mtp,diag,diag_mdm,diag_qsc\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9088\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm,diag_qsc\n    write /sys/class/android_usb/android0/functions mtp,diag\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mtp,diag,diag_mdm,diag_qsc,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9089\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm,diag_qsc\n    write /sys/class/android_usb/android0/functions mtp,diag,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,ccid\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9045\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/functions diag,ccid\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,ccid,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9044\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/functions diag,adb,ccid\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=mass_storage,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9015\n    write /sys/class/android_usb/android0/functions adb,mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n#Mass-storage only composition\non property:sys.usb.config=mass_storage\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct F000\n    write /sys/class/android_usb/android0/functions mass_storage\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,qdss\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 904A\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,qdss,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9060\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,qdss\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9099\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,qdss,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9098\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,qdss,rmnet_bam\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9083\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,rmnet\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,qdss,rmnet_qti_bam\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9083\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,rmnet\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,qdss,rmnet_bam,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9084\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,adb,rmnet\n    write /sys/module/dwc3/parameters/tx_fifo_resize_enable 1\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,qdss,rmnet_qti_bam,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9084\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,adb,rmnet\n    write /sys/module/dwc3/parameters/tx_fifo_resize_enable 1\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,qdss,rmnet_ipa\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9083\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,rmnet\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,qdss,rmnet_ipa,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9084\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,adb,rmnet\n    write /sys/module/dwc3/parameters/tx_fifo_resize_enable 1\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,qdss,rmnet_hsic\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 909B\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,rmnet\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,qdss,rmnet_hsic,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 909A\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions diag,qdss,adb,rmnet\n    write /sys/module/dwc3/parameters/tx_fifo_resize_enable 1\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,qdss_apq,qdss_mdm,rmnet_hsic\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 90A3\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 0\n    write /sys/class/android_usb/android0/f_qdss/transports bam,hsic\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam,qdss_hsic\n    write /sys/class/android_usb/android0/functions diag,qdss,rmnet\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=diag,diag_mdm,qdss_apq,qdss_mdm,rmnet_hsic,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 90A2\n    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm\n    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 0\n    write /sys/class/android_usb/android0/f_qdss/transports bam,hsic\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam,qdss_hsic\n    write /sys/class/android_usb/android0/functions diag,qdss,adb,rmnet\n    write /sys/module/dwc3/parameters/tx_fifo_resize_enable 1\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=rndis,diag,qdss\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9081\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions rndis,diag,qdss\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=rndis,diag,qdss,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 9082\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 1\n    write /sys/class/android_usb/android0/f_qdss/transports bam\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/functions rndis,diag,qdss,adb\n    write /sys/module/dwc3/parameters/tx_fifo_resize_enable 1\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# same as 9025, plus data packet logging (DPL) using QDSS\non property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_ipa,mass_storage,dpl,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 90AD\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n# DPL is implemented using QDSS\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 0\n    write /sys/class/android_usb/android0/f_qdss/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage,qdss\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\n# same as 9026, plus data packet logging (DPL)\non property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_ipa,mass_storage,dpl\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 90B0\n    write /sys/class/android_usb/android0/f_diag/clients diag\n    write /sys/class/android_usb/android0/f_serial/transports smd,tty\n# DPL is implemented using QDSS\n    write /sys/class/android_usb/android0/f_qdss/debug_intf 0\n    write /sys/class/android_usb/android0/f_qdss/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/f_qdss/transport_names qdss_bam\n    write /sys/class/android_usb/android0/f_rmnet/transports qti,bam2bam_ipa\n    write /sys/class/android_usb/android0/functions diag,serial,rmnet,mass_storage,qdss\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=ncm\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 0525\n    write /sys/class/android_usb/android0/idProduct A4A1\n    write /sys/class/android_usb/android0/functions ncm\n    write /sys/class/android_usb/android0/enable 1\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=ncm,adb\n    stop adbd\n    write /sys/class/android_usb/android0/enable 0\n    write /sys/class/android_usb/android0/idVendor 05C6\n    write /sys/class/android_usb/android0/idProduct 908C\n    write /sys/class/android_usb/android0/functions ncm,adb\n    write /sys/class/android_usb/android0/enable 1\n    start adbd\n    setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=midi\n     write /sys/class/android_usb/android0/enable 0\n     write /sys/class/android_usb/android0/idVendor 05C6\n     write /sys/class/android_usb/android0/idProduct 90BA\n     write /sys/class/android_usb/android0/functions midi\n     write /sys/class/android_usb/android0/enable 1\n     setprop sys.usb.state ${sys.usb.config}\n\non property:sys.usb.config=midi,adb\n     stop adbd\n     write /sys/class/android_usb/android0/enable 0\n     write /sys/class/android_usb/android0/idVendor 05C6\n     write /sys/class/android_usb/android0/idProduct 90BB\n     write /sys/class/android_usb/android0/functions midi,adb\n     write /sys/class/android_usb/android0/enable 1\n     start adbd\n     setprop sys.usb.state ${sys.usb.config}\n"
  },
  {
    "path": "rootdir/etc/init.qcom.usb.sh",
    "content": "#!/system/bin/sh\n# Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n#       copyright notice, this list of conditions and the following\n#       disclaimer in the documentation and/or other materials provided\n#       with the distribution.\n#     * Neither the name of The Linux Foundation nor the names of its\n#       contributors may be used to endorse or promote products derived\n#      from this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR IMPLIED\n# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT\n# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\n# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#\n#\nchown -h root.system /sys/devices/platform/msm_hsusb/gadget/wakeup\nchmod -h 220 /sys/devices/platform/msm_hsusb/gadget/wakeup\n\n# Target as specified in build.prop at compile-time\ntarget=`getprop ro.board.platform`\n\n# Set platform variables\nif [ -d /sys/devices/soc0 ]; then\n    soc_hwplatform=`cat /sys/devices/soc0/hw_platform` 2> /dev/null\n    soc_id=`cat /sys/devices/soc0/soc_id` 2> /dev/null\nelse\n    soc_hwplatform=`cat /sys/devices/system/soc/soc0/hw_platform` 2> /dev/null\nfi\n\n#\n# soc_id may specify additional chip variants not captured in ro.board.platform\n# so allow for additional target differentiation based on that\n#\ncase $soc_id in\n    \"252\")\n        target=\"apq8092\"\n    ;;\n    \"253\")\n        target=\"apq8094\"\n    ;;\nesac\n\n#\n# Allow persistent usb charging disabling\n# User needs to set usb charging disabled in persist.usb.chgdisabled\n#\nusbchgdisabled=`getprop persist.usb.chgdisabled`\ncase \"$usbchgdisabled\" in\n    \"\") ;; #Do nothing here\n    * )\n    case $target in\n        \"msm8660\")\n        echo \"$usbchgdisabled\" > /sys/module/pmic8058_charger/parameters/disabled\n        echo \"$usbchgdisabled\" > /sys/module/smb137b/parameters/disabled\n\t;;\n        \"msm8960\")\n        echo \"$usbchgdisabled\" > /sys/module/pm8921_charger/parameters/disabled\n\t;;\n    esac\nesac\n\nusbcurrentlimit=`getprop persist.usb.currentlimit`\ncase \"$usbcurrentlimit\" in\n    \"\") ;; #Do nothing here\n    * )\n    case $target in\n        \"msm8960\")\n        echo \"$usbcurrentlimit\" > /sys/module/pm8921_charger/parameters/usb_max_current\n\t;;\n    esac\nesac\n\n#\n# Check ESOC for external MDM\n#\n# Note: currently only a single MDM is supported\n#\nif [ -d /sys/bus/esoc/devices ]; then\nfor f in /sys/bus/esoc/devices/*; do\n    if [ -d $f ]; then\n        esoc_name=`cat $f/esoc_name`\n        if [ \"$esoc_name\" = \"MDM9x25\" -o \"$esoc_name\" = \"MDM9x35\" ]; then\n            esoc_link=`cat $f/esoc_link`\n            break\n        fi\n    fi\ndone\nfi\n\n#\n# Allow USB enumeration with default PID/VID\n#\nbaseband=`getprop ro.baseband`\necho 1  > /sys/class/android_usb/f_mass_storage/lun/nofua\nusb_config=`getprop persist.sys.usb.config`\ncase \"$usb_config\" in\n    \"\" | \"adb\" | \"none\") #USB persist config not set, select default configuration\n      case \"$esoc_link\" in\n          \"HSIC\")\n              setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb\n              setprop persist.rmnet.mux enabled\n          ;;\n          \"HSIC+PCIe\")\n              setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,rmnet_qti_ether,mass_storage,adb\n          ;;\n          \"PCIe\")\n              setprop persist.sys.usb.config diag,diag_mdm,serial_tty,rmnet_qti_ether,mass_storage,adb\n          ;;\n          *)\n          case \"$baseband\" in\n              \"mdm\")\n                   setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb\n              ;;\n              \"mdm2\")\n                   setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb\n              ;;\n              \"sglte\")\n                   setprop persist.sys.usb.config diag,diag_qsc,serial_smd,serial_tty,serial_hsuart,rmnet_hsuart,mass_storage,adb\n              ;;\n              \"dsda\" | \"sglte2\")\n                   setprop persist.sys.usb.config diag,diag_mdm,diag_qsc,serial_hsic,serial_hsuart,rmnet_hsic,rmnet_hsuart,mass_storage,adb\n              ;;\n              \"dsda2\")\n                   setprop persist.sys.usb.config diag,diag_mdm,diag_mdm2,serial_hsic,serial_hsusb,rmnet_hsic,rmnet_hsusb,mass_storage,adb\n              ;;\n              *)\n\t\tcase \"$target\" in\n                        \"msm8916\")\n                            setprop persist.sys.usb.config diag,serial_smd,rmnet_bam,adb\n                        ;;\n                        \"apq8094\" | \"apq8092\")\n                            setprop persist.sys.usb.config diag,adb\n                        ;;\n                        \"msm8994\" | \"msm8992\")\n                            #[BSP-66]-Anderson-Disable_set_the_property.\n                            #This will ause BSP-66 issue and cause all the port enable in default.\n                            #setprop persist.sys.usb.config diag,serial_smd,serial_tty,rmnet_ipa,mass_storage,adb\n                        ;;\n                        \"msm8909\")\n                            setprop persist.sys.usb.config diag,serial_smd,rmnet_qti_bam,adb\n                        ;;\n                        *)\n                            setprop persist.sys.usb.config diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb\n                        ;;\n                    esac\n              ;;\n          esac\n          ;;\n      esac\n    ;;\n    * ) ;; #USB persist config exists, do nothing\nesac\n\n#VENDOR_EDIT\n#echo boot mode to kmsg\nboot_mode=`getprop ro.boot.ftm_mode`\necho \"boot_mode: $boot_mode\" > /dev/kmsg\ncase \"$boot_mode\" in\n    \"ftm_at\" | \"ftm_rf\" | \"ftm_wlan\" | \"ftm_mos\")\n        echo \"FTM FORCE diag,adb\" > /dev/kmsg\n        setprop persist.sys.usb.config diag,adb\n    ;;\nesac\n\nusb_config=`getprop persist.sys.usb.config`\necho \"AFTER: $usb_config\" > /dev/kmsg\n#VENDOR_EDIT end\n\n#\n# Do target specific things\n#\ncase \"$target\" in\n    \"msm8974\")\n# Select USB BAM - 2.0 or 3.0\n        echo ssusb > /sys/bus/platform/devices/usb_bam/enable\n    ;;\n    \"apq8084\")\n\tif [ \"$baseband\" == \"apq\" ]; then\n\t\techo \"msm_hsic_host\" > /sys/bus/platform/drivers/xhci_msm_hsic/unbind\n\tfi\n    ;;\n    \"msm8226\")\n         if [ -e /sys/bus/platform/drivers/msm_hsic_host ]; then\n             if [ ! -L /sys/bus/usb/devices/1-1 ]; then\n                 echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/unbind\n             fi\n         fi\n    ;;\n    \"msm8994\" | \"msm8992\")\n        echo BAM2BAM_IPA > /sys/class/android_usb/android0/f_rndis_qc/rndis_transports\n    ;;\nesac\n\n#\n# set module params for embedded rmnet devices\n#\nrmnetmux=`getprop persist.rmnet.mux`\ncase \"$baseband\" in\n    \"mdm\" | \"dsda\" | \"sglte2\")\n        case \"$rmnetmux\" in\n            \"enabled\")\n                    echo 1 > /sys/module/rmnet_usb/parameters/mux_enabled\n                    echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links\n                    echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev\n            ;;\n        esac\n        echo 1 > /sys/module/rmnet_usb/parameters/rmnet_data_init\n        # Allow QMUX daemon to assign port open wait time\n        chown -h radio.radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait\n    ;;\n    \"dsda2\")\n          echo 2 > /sys/module/rmnet_usb/parameters/no_rmnet_devs\n          echo hsicctl,hsusbctl > /sys/module/rmnet_usb/parameters/rmnet_dev_names\n          case \"$rmnetmux\" in\n               \"enabled\") #mux is neabled on both mdms\n                      echo 3 > /sys/module/rmnet_usb/parameters/mux_enabled\n                      echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links\n                      echo 17 > write /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev\n               ;;\n               \"enabled_hsic\") #mux is enabled on hsic mdm\n                      echo 1 > /sys/module/rmnet_usb/parameters/mux_enabled\n                      echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links\n                      echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev\n               ;;\n               \"enabled_hsusb\") #mux is enabled on hsusb mdm\n                      echo 2 > /sys/module/rmnet_usb/parameters/mux_enabled\n                      echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links\n                      echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev\n               ;;\n          esac\n          echo 1 > /sys/module/rmnet_usb/parameters/rmnet_data_init\n          # Allow QMUX daemon to assign port open wait time\n          chown -h radio.radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait\n    ;;\nesac\n\n#\n# Add support for exposing lun0 as cdrom in mass-storage\n#\ncdromname=\"/system/etc/cdrom_install.iso\"\ncase \"$target\" in\n\t\"msm8226\" | \"msm8610\" | \"msm8916\")\n\t\tcase $soc_hwplatform in\n\t\t\t\"QRD\")\n\t\t\t\techo \"mounting usbcdrom lun\"\n\t\t\t\techo $cdromname > /sys/class/android_usb/android0/f_mass_storage/rom/file\n\t\t\t\tchmod 0444 /sys/class/android_usb/android0/f_mass_storage/rom/file\n\t\t\t\t;;\n\t\tesac\n\t\t;;\nesac\n\n#\n# Initialize RNDIS Diag option. If unset, set it to 'none'.\n#\ndiag_extra=`getprop persist.sys.usb.config.extra`\nif [ \"$diag_extra\" == \"\" ]; then\n\tsetprop persist.sys.usb.config.extra none\nfi\n"
  },
  {
    "path": "rootdir/etc/init.zram.sh",
    "content": "#!/system/bin/sh\n\necho 536870912 > /sys/block/zram0/disksize\nmkswap /dev/block/zram0\nswapon /dev/block/zram0 -p 32758\n"
  },
  {
    "path": "rootdir/etc/ueventd.qcom.rc",
    "content": "# Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are met:\n#     * Redistributions of source code must retain the above copyright\n#       notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above copyright\n#       notice, this list of conditions and the following disclaimer in the\n#       documentation and/or other materials provided with the distribution.\n#     * Neither the name of The Linux Foundation nor\n#       the names of its contributors may be used to endorse or promote\n#       products derived from this software without specific prior written\n#       permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n# NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#\n\n# the DIAG device node is not world writable/readable.\n/dev/diag                 0660   system     qcom_diag\n\n/dev/genlock              0666   system     system\n/dev/kgsl                 0666   system     system\n/dev/kgsl-3d0             0666   system     system\n/dev/kgsl-2d0             0666   root       root\n/dev/kgsl-2d1             0666   root       root\n/dev/ion                  0664   system     system\n/dev/rtc0                 0600   system     system\n/dev/smd0                 0660   system     system\n/dev/smd4                 0660   system     system\n/dev/smd_cxm_qmi          0640   radio      radio\n/dev/smd5                 0660   system     system\n/dev/smd6                 0660   system     system\n/dev/smd7                 0660   bluetooth  bluetooth\n/dev/ccid_bridge          0660   system     system\n/dev/ipa                  0660   net_admin  net_admin\n/dev/wwan_ioctl           0660   net_admin  net_admin\n/dev/ipaNatTable          0660   net_admin  net_admin\n/dev/rmnet_ctrl           0660   usb        usb\n/dev/dpl_ctrl             0660   usb        usb\n\n#permissions for CSVT\n/dev/smd11                0660   radio      radio\n\n/dev/radio0               0640   system     system\n/dev/rfcomm0              0660   bluetooth  bluetooth\n/dev/ttyUSB0              0660   bluetooth  bluetooth\n/dev/smdcntl0             0640   radio      radio\n/dev/smdcntl1             0640   radio      radio\n/dev/smdcntl2             0640   radio      radio\n/dev/smdcntl3             0640   radio      radio\n/dev/smdcntl4             0640   radio      radio\n/dev/smdcntl5             0640   radio      radio\n/dev/smdcntl6             0640   radio      radio\n/dev/smdcntl7             0640   radio      radio\n/dev/smdcntl8             0640   radio      radio\n/dev/smdcnt_rev0          0640   radio      radio\n/dev/smdcnt_rev1          0640   radio      radio\n/dev/smdcnt_rev2          0640   radio      radio\n/dev/smdcnt_rev3          0640   radio      radio\n/dev/smdcnt_rev4          0640   radio      radio\n/dev/smdcnt_rev5          0640   radio      radio\n/dev/smdcnt_rev6          0640   radio      radio\n/dev/smdcnt_rev7          0640   radio      radio\n/dev/smdcnt_rev8          0640   radio      radio\n/dev/smuxctl32            0640   radio      radio\n/dev/sdioctl0             0640   radio      radio\n/dev/sdioctl1             0640   radio      radio\n/dev/sdioctl2             0640   radio      radio\n/dev/sdioctl3             0640   radio      radio\n/dev/sdioctl4             0640   radio      radio\n/dev/sdioctl5             0640   radio      radio\n/dev/sdioctl6             0640   radio      radio\n/dev/sdioctl7             0640   radio      radio\n/dev/sdioctl8             0640   radio      radio\n/dev/rmnet_mux_ctrl       0640   radio      radio\n/dev/hsicctl0             0640   radio      radio\n/dev/hsicctl1             0640   radio      radio\n/dev/hsicctl2             0640   radio      radio\n/dev/hsicctl3             0640   radio      radio\n/dev/hsicctl4             0640   radio      radio\n/dev/hsicctl5             0640   radio      radio\n/dev/hsicctl6             0640   radio      radio\n/dev/hsicctl7             0640   radio      radio\n/dev/hsicctl8             0640   radio      radio\n/dev/hsicctl9             0640   radio      radio\n/dev/hsicctl10            0640   radio      radio\n/dev/hsicctl11            0640   radio      radio\n/dev/hsicctl12            0640   radio      radio\n/dev/hsicctl13            0640   radio      radio\n/dev/hsicctl14            0640   radio      radio\n/dev/hsicctl15            0640   radio      radio\n/dev/hsicctl16            0640   radio      radio\n/dev/mhi_pipe_14          0640   radio      radio\n/dev/mhi_pipe_16          0640   radio      radio\n/dev/mhi_pipe_32          0640   radio      radio\n/dev/video*               0660   system     camera\n/dev/media*               0660   system     camera\n/dev/v4l-subdev*          0660   system     camera\n#changhua.li modify from 660 to 666 for alipay use tz\n/dev/qseecom              0666   system     drmrpc\n/dev/seemplog             0660   system     system\n/dev/pft                  0660   system     drmrpc\n/dev/gemini0              0660   system     camera\n/dev/jpeg0                0660   system     camera\n/dev/jpeg1                0660   system     camera\n/dev/jpeg2                0660   system     camera\n/dev/jpeg3                0660   system     camera\n/dev/adsprpc-smd          0664   system     system\n/dev/system_health_monitor 0640  radio      system\n/dev/msm_camera/*         0660   system     camera\n/dev/gemini/              0660   system     camera\n/dev/mercury0             0660   system     camera\n/dev/msm_vidc_reg         0660   system     audio\n/dev/msm_vidc_dec         0660   system     audio\n/dev/msm_vidc_dec_sec     0660   system     audio\n/dev/msm_vidc_enc         0660   system     audio\n/dev/msm_rotator          0660   system     system\n/dev/hw_random            0600   root       root\n/dev/adsprpc-smd          0664   system     system\n\n#permissions for audio\n/dev/audio_slimslave      0660   system     audio\n/dev/msm_qcelp            0660   system     audio\n/dev/msm_evrc             0660   system     audio\n/dev/msm_wma              0660   system     audio\n/dev/msm_wmapro           0660   system     audio\n/dev/msm_amrnb            0660   system     audio\n/dev/msm_amrwb            0660   system     audio\n/dev/msm_amrwbplus        0660   system     audio\n/dev/msm_aac              0660   system     audio\n/dev/msm_multi_aac        0660   system     audio\n/dev/msm_aac_in           0660   system     audio\n/dev/msm_qcelp_in         0660   system     audio\n/dev/msm_evrc_in          0660   system     audio\n/dev/msm_amrnb_in         0640   system     audio\n/dev/msm_a2dp_in          0660   system     audio\n/dev/msm_ac3              0660   system     audio\n/dev/msm_audio_cal        0660   system     audio\n/dev/msm_hweffects        0660   system     audio\n/dev/msm_cad              0660   system     audio\n/dev/msm_fm               0660   system     audio\n/dev/msm_mvs              0660   system     audio\n/dev/msm_pcm_lp_dec       0660   system     audio\n/dev/msm_preproc_ctl      0660   system     audio\n/dev/msm_rtac             0660   system     audio\n/dev/msm_voicememo        0660   system     audio\n/dev/radio0               0640   fm_radio   fm_radio\n/dev/smd3                 0660   bluetooth  net_bt_stack\n/dev/smd2                 0660   bluetooth  net_bt_stack\n/dev/ttyHSL1              0660   system     system\n/dev/ttyHS1               0660   system     system\n/dev/mdm                  0660   system     radio\n/sys/devices/virtual/smdpkt/smdcntl*       open_timeout   0664 radio radio\n/dev/sdio_tty_ciq_00      0660   system     system\n/dev/tty_sdio_00          0660   system     system\n/dev/ttyGS0               0660   system     system\n/dev/i2c-5                0660   media       media\n/dev/voice_svc            0660   system     audio\n/dev/avtimer              0660   system     audio\n\n# DVB devices\n/dev/dvb/adapter0/demux*  0440   media       media\n/dev/dvb/adapter0/dvr*    0660   media       media\n/dev/dvb/adapter0/video*  0660   media       media\n\n# Broadcast devices\n/dev/tsc_mux0             0660   media       media\n/dev/tsc_ci0              0660   media       media\n\n# sensors\n/sys/devices/i2c-12/12-*  pollrate_ms 0664 system system\n/sys/devices/f9925000.i2c/i2c-0/0-*                 enable         0660    input    system\n/sys/devices/f9925000.i2c/i2c-0/0-*                 poll_delay     0660    input    system\n/sys/devices/soc.0/78b6000.i2c/i2c-0/0-*            enable         0660    input    system\n/sys/devices/soc.0/78b6000.i2c/i2c-0/0-*            poll_delay     0660    input    system\n/sys/devices/soc.0/78b6000.i2c/i2c-0/0-*            enable_wakeup  0660    input    system\n/sys/devices/soc.0/78b6000.i2c/i2c-0/0-*            max_latency    0660    input    system\n/sys/devices/soc.0/78b6000.i2c/i2c-0/0-*            flush          0660    input    system\n/sys/devices/soc.0/78b6000.i2c/i2c-0/0-*            calibrate      0660    input    system\n/sys/devices/soc.0/78b5000.i2c/i2c-1/1-*            enable         0660    input    system\n/sys/devices/soc.0/78b5000.i2c/i2c-1/1-*            poll_delay     0660    input    system\n/sys/devices/soc.0/78b5000.i2c/i2c-1/1-*            enable_wakeup  0660    input    system\n/sys/devices/soc.0/78b5000.i2c/i2c-1/1-*            max_latency    0660    input    system\n/sys/devices/soc.0/78b5000.i2c/i2c-1/1-*            flush          0660    input    system\n/sys/devices/soc.0/78b5000.i2c/i2c-1/1-*            calibrate      0660    input    system\n/sys/devices/virtual/optical_sensors/proximity      ps_adc         0660    input    system\n/sys/devices/virtual/optical_sensors/proximity      ps_poll_delay  0660    input    system\n/sys/devices/virtual/optical_sensors/lightsensor    ls_auto        0660    input    system\n/sys/devices/virtual/optical_sensors/lightsensor    ls_poll_delay  0660    input    system\n/sys/devices/virtual/input/input*                   poll           0660    input    system\n/sys/devices/virtual/input/input*                   pollrate_ms    0660    input    system\n\n# UIO devices\n/dev/uio0                 0660   system     system\n/dev/uio1                 0660   system     system\n/dev/uio2                 0660   system     system\n\n# SSR devices\n/dev/subsys_*         0640   system     system\n\n# Ultrasound device\n/dev/usf1                 0660   system     system\n\n# Ramdump devices\n/dev/ramdump*             0640   system     system\n\n# Add device block for FRP\n/dev/block/bootdevice/by-name/config    0660   system     system\n\n# Fingerprint sensor\n/dev/fpc1020\t\t 0660\tsystem\tsystem\n"
  },
  {
    "path": "sensors/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE := sensors.ssc.wrapper\nLOCAL_PROPRIETARY_MODULE := true\n\nLOCAL_SRC_FILES := \\\n    SensorsWrapper.c\n\nLOCAL_SHARED_LIBRARIES := libdl liblog\n\ninclude $(BUILD_SHARED_LIBRARY)\n"
  },
  {
    "path": "sensors/SensorsWrapper.c",
    "content": "/* Copyright (C) 2016, The CyanogenMod Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <hardware/sensors.h>\n#include <dlfcn.h>\n#include <pthread.h>\n#include <errno.h>\n#include <string.h>\n#include <stdlib.h>\n#include <limits.h>\n\n#include <cutils/log.h>\n\n#ifdef __aarch64__\n#define HAL_VENDOR_PATH \"/vendor/lib64\"\n#else\n#define HAL_VENDOR_PATH \"/vendor/lib\"\n#endif\n\nint global_sensors_count = -1;\nstruct sensor_t* global_sensors_list = 0;\nstruct hw_module_t* global_sensor_module = 0;\npthread_once_t init_sensors_once = PTHREAD_ONCE_INIT;\n\nstatic int open_sensors(__unused const struct hw_module_t* hw_module,\n                        __unused const char* name,\n                        struct hw_device_t** hw_device_out);\nstatic int module__get_sensors_list(__unused struct sensors_module_t* module,\n                                    struct sensor_t const** list);\n\nstatic struct hw_module_methods_t sensors_module_methods = {\n    .open = open_sensors\n};\n\nstruct sensors_module_t HAL_MODULE_INFO_SYM = {\n    .common = {\n        .tag = HARDWARE_MODULE_TAG,\n        .version_major = 1,\n        .version_minor = 0,\n        .id = SENSORS_HARDWARE_MODULE_ID,\n        .name = \"Sensors wrapper\",\n        .author = \"The CyanogenMod Project\",\n        .methods = &sensors_module_methods,\n        .dso = NULL,\n        .reserved = {0}\n    },\n    .get_sensors_list = module__get_sensors_list,\n    .set_operation_mode = 0\n};\n\n/* Initialize the sensor by loading the underlying sensor\n * Called only once in a thread safe manner */\nvoid init_sensors(void) {\n    void* handle;\n    int idx;\n    int sensors_count;\n    const struct sensor_t* sensors_list = 0;\n\n    handle = dlopen(HAL_VENDOR_PATH\"/sensors.ssc.so\", RTLD_NOW);\n\n    if (!handle) {\n        ALOGE(\"init_sensors: dlopen() failed to load \\\"sensors.ssc.so\\\"\");\n        goto fail;\n    }\n\n    global_sensor_module = (struct hw_module_t*)\n        dlsym(handle, HAL_MODULE_INFO_SYM_AS_STR);\n    if (!global_sensor_module) {\n        ALOGE(\"init_sensors: dlsym() failed to load driver details\");\n        goto fail;\n    }\n\n    /* Lazy initialize based on driver providing data */\n    HAL_MODULE_INFO_SYM.set_operation_mode =\n        ((struct sensors_module_t*)global_sensor_module)->set_operation_mode;\n\n    sensors_count =\n        ((struct sensors_module_t*)global_sensor_module)->get_sensors_list(\n            (struct sensors_module_t*)global_sensor_module, &sensors_list);\n\n    /* Check if there are any underlying sensors provided */\n    if (sensors_count <= 0) {\n        ALOGE(\"get_sensors_list() did not return any sensors\");\n        return;\n    }\n\n    global_sensors_list = calloc(sensors_count, sizeof(struct sensor_t));\n    if (!global_sensors_list) {\n        ALOGE(\"calloc() failed to allocate memory\");\n        goto fail;\n    }\n\n    /* Let us make sure it is set to 0 to avoid overruns */\n    global_sensors_count = 0;\n    for (idx = 0; idx < sensors_count; ++idx) {\n        if (SENSOR_TYPE_ROTATION_VECTOR == sensors_list[idx].type) {\n            ALOGV(\"Skipping sensor: SENSOR_TYPE_ROTATION_VECTOR\");\n            continue;\n        }\n\n        memcpy(&global_sensors_list[global_sensors_count],\n               &sensors_list[idx], sizeof(struct sensor_t));\n        ++global_sensors_count;\n    }\n\n    /* Looks good: Update the handle in the module */\n    global_sensor_module->dso = handle;\n\n    return;\n\nfail:\n    global_sensors_count = 0;\n    global_sensor_module = 0;\n\n    if (handle) {\n        dlclose(handle);\n    }\n\n    if (global_sensors_list) {\n        free(global_sensors_list);\n        global_sensors_list = 0;\n    }\n\n    return;\n}\n\nint module__get_sensors_list(__unused struct sensors_module_t* module,\n                             struct sensor_t const** list) {\n    int idx;\n    ALOGV(\"module__get_sensors_list start\");\n    pthread_once(&init_sensors_once, init_sensors);\n\n    *list = global_sensors_list;\n\n    ALOGV(\"global_sensors_count: %d\", global_sensors_count);\n    for (idx = 0; idx < global_sensors_count; ++idx) {\n        ALOGV(\"sensor type: %d\", global_sensors_list[idx].type);\n    }\n\n    return (global_sensors_count > 0) ? global_sensors_count : 0;\n}\n\nint open_sensors(__unused const struct hw_module_t* hw_module,\n                 __unused const char* name,\n                 struct hw_device_t** hw_device_out) {\n    ALOGV(\"open_sensors begin...\");\n    pthread_once(&init_sensors_once, init_sensors);\n\n    if (global_sensor_module) {\n        sensors_open(global_sensor_module,\n                     (struct sensors_poll_device_t**)hw_device_out);\n\n        /* Hook the current driver to intercept function calls */\n        if (*hw_device_out) {\n            (*hw_device_out)->module = global_sensor_module;\n        }\n    }\n\n    ALOGV(\"...open_sensors end\");\n    return (*hw_device_out) ? 0 : -EINVAL;\n}\n"
  },
  {
    "path": "sepolicy/audioserver.te",
    "content": "allow audioserver system_data_file:sock_file write;\nallow audioserver rootfs:lnk_file getattr;\n"
  },
  {
    "path": "sepolicy/cam_sysfs.te",
    "content": "allow cam_sysfs sysfs:filesystem associate;\n"
  },
  {
    "path": "sepolicy/cameraserver.te",
    "content": "allow cameraserver system_data_file:sock_file write;\n"
  },
  {
    "path": "sepolicy/dpmd.te",
    "content": "allow dpmd mm-qcamerad:dir search;\nallow dpmd mm-qcamerad:file read;\ndontaudit dpmd self:capability sys_ptrace;\n"
  },
  {
    "path": "sepolicy/file.te",
    "content": "type proc_touchpanel, fs_type;\ntype cam_proc, file_type;\ntype cam_sysfs, fs_type;\ntype cam_blob, file_type;\ntype nv_data_file, file_type;\ntype stm_sensor, file_type;\n"
  },
  {
    "path": "sepolicy/file_contexts",
    "content": "# We have a couple of non-standard NV partitions\n/dev/block/bootdevice/by-name/oem_dycnvbk                       u:object_r:modem_efs_partition_device:s0\n/dev/block/bootdevice/by-name/oem_stanvbk                       u:object_r:modem_efs_partition_device:s0\n\n# FRP partition\n/dev/block/bootdevice/by-name/config                            u:object_r:frp_block_device:s0\n\n/persist/.genmac                                                u:object_r:wifi_data_file:s0\n\n/sys/devices/soc.0/f9928000.i2c/i2c-6/6-0029/enable_ps_sensor   u:object_r:cam_sysfs:s0\n/sys/devices/soc.0/f9928000.i2c/i2c-6/6-0029/set_delay_ms       u:object_r:cam_sysfs:s0\n/dev/input/event2                                               u:object_r:stm_sensor:s0\n\n/data/oemnvitems(/.*)?                                          u:object_r:nv_data_file:s0\n"
  },
  {
    "path": "sepolicy/fingerprintd.te",
    "content": "allow fingerprintd sysfs:file write;\nallow fingerprintd system_data_file:dir { write remove_name add_name };\nallow fingerprintd system_data_file:sock_file { create unlink };\nallow fingerprintd tee_device:chr_file { read write ioctl open };\nallow fingerprintd firmware_file:dir search;\n"
  },
  {
    "path": "sepolicy/genfs_contexts",
    "content": "genfscon proc /qcom_flash    u:object_r:cam_proc:s0\ngenfscon proc /laser_info    u:object_r:cam_proc:s0\ngenfscon proc /touchpanel    u:object_r:proc_touchpanel:s0\ngenfscon proc /s1302         u:object_r:proc_touchpanel:s0\ngenfscon proc /tri-state-key u:object_r:proc_touchpanel:s0\n"
  },
  {
    "path": "sepolicy/ims.te",
    "content": "allow ims system_prop:property_service set;\n"
  },
  {
    "path": "sepolicy/init.te",
    "content": "allow init cam_sysfs:file relabelto;\nallow init proc_dirty_ratio:file write;\n"
  },
  {
    "path": "sepolicy/ipacm-diag.te",
    "content": "allow ipacm-diag property_socket:sock_file write;\nallow ipacm-diag init:unix_stream_socket connectto;\nallow ipacm-diag system_prop:property_service set;\n"
  },
  {
    "path": "sepolicy/kernel.te",
    "content": "allow kernel sysfs:file write;\n"
  },
  {
    "path": "sepolicy/mediacodec.te",
    "content": "allow mediacodec system_data_file:sock_file write;\nallow mediacodec mpctl_socket:dir search;\nallow mediacodec rootfs:lnk_file getattr;\n"
  },
  {
    "path": "sepolicy/mediadrmserver.te",
    "content": "﻿allow mediadrmserver rootfs:lnk_file getattr;\n"
  },
  {
    "path": "sepolicy/mediaserver.te",
    "content": "allow mediaserver system_server:unix_stream_socket { read write };\nallow mediaserver sensorservice_service:service_manager find;\nallow mediaserver audio_device:chr_file { ioctl open read write };\nallow mediaserver system_data_file:sock_file write;\n"
  },
  {
    "path": "sepolicy/mm-pp-daemon.te",
    "content": "allow mm-pp-daemon diag_device:chr_file { ioctl open read write };\n"
  },
  {
    "path": "sepolicy/mm-qcamerad.te",
    "content": "allow mm-qcamerad cam_sysfs:file { open read write };\nallow mm-qcamerad stm_sensor:chr_file { ioctl open read };\nallow mm-qcamerad system_file:file execmod;\n"
  },
  {
    "path": "sepolicy/netmgrd.te",
    "content": "allow netmgrd self:capability dac_override;\n"
  },
  {
    "path": "sepolicy/per_mgr.te",
    "content": "allow per_mgr self:capability net_raw;\n"
  },
  {
    "path": "sepolicy/perfd.te",
    "content": "allow perfd system_data_file:sock_file write;\nallow perfd system_data_file:dir { add_name remove_name write };\nallow perfd system_data_file:sock_file { create setattr unlink };\n"
  },
  {
    "path": "sepolicy/priv_app.te",
    "content": "allow priv_app device:dir { read open };\nallow priv_app rfs_system_file:dir getattr;\n"
  },
  {
    "path": "sepolicy/qmuxd.te",
    "content": "allow qmuxd property_socket:sock_file write;\nallow qmuxd diag_device:chr_file { ioctl open read write };\nallow qmuxd init:unix_stream_socket connectto;\nallow qmuxd system_prop:property_service set;\n"
  },
  {
    "path": "sepolicy/qti_init_shell.te",
    "content": "allow qti_init_shell bluetooth_loader_exec:file { read open };\nallow qti_init_shell btnvtool_exec:file { read getattr open execute execute_no_trans };\nallow qti_init_shell kmsg_device:chr_file { write open };\nallow qti_init_shell persist_bluetooth_file:dir search;\nallow qti_init_shell persist_bluetooth_file:file { read getattr open };\nallow qti_init_shell smem_log_device:chr_file { read write ioctl open };\n"
  },
  {
    "path": "sepolicy/radio.te",
    "content": "allow radio system_app_data_file:dir getattr;\n"
  },
  {
    "path": "sepolicy/rild.te",
    "content": "allow rild nv_data_file:dir { getattr search write add_name };\nallow rild nv_data_file:file { write open create };\n"
  },
  {
    "path": "sepolicy/sensors.te",
    "content": "allow sensors cam_sysfs:file getattr;\nallow sensors device:dir { write add_name };\nallow sensors input_device:chr_file { relabelfrom getattr link };\nallow sensors stm_sensor:chr_file relabelto;\nallow sensors input_device:dir search;\n"
  },
  {
    "path": "sepolicy/sysinit.te",
    "content": "﻿allow sysinit rootfs:lnk_file getattr;\n"
  },
  {
    "path": "sepolicy/system_app.te",
    "content": "allow system_app proc_touchpanel:dir search;\nallow system_app proc_touchpanel:file { write getattr open read };\nallow system_app qmuxd_socket:dir search;\nallow system_app cne_service:service_manager add;\nallow system_app dpmservice:service_manager add;\nallow system_app qtitetherservice_service:service_manager add;\nallow system_app dpmd_data_file:dir { search write add_name };\nallow system_app dpmd_data_file:file create;\n\ndontaudit system_app netd_service:service_manager find;\n"
  },
  {
    "path": "sepolicy/system_server.te",
    "content": "allow system_server persist_file:dir { read write };\nallow system_server proc_touchpanel:dir search;\nallow system_server proc_touchpanel:file { write open getattr read };\nallow system_server stm_sensor:chr_file { read write ioctl open };\nallow system_app dpmd_data_file:dir { getattr open read };\nallow system_app dpmd_data_file:file { getattr lock open read setattr write };\nallow system_app dpmd_socket:sock_file write;\nallow system_app ipa_dev:chr_file { ioctl open read write };\nallow system_app qmuxd:unix_stream_socket connectto;\nallow system_app qmuxd_socket:dir { add_name write };\nallow system_app qmuxd_socket:sock_file { create setattr write };\nallow system_server unlabeled:file unlink;\nallow system_server user_profile_data_file:dir { read open };\n"
  },
  {
    "path": "sepolicy/tee.te",
    "content": "allow tee vfat:file { read getattr open };\n"
  },
  {
    "path": "sepolicy/thermal-engine.te",
    "content": "allow thermal-engine property_socket:sock_file write;\nallow thermal-engine init:unix_stream_socket connectto;\nallow thermal-engine system_prop:property_service set;\n"
  },
  {
    "path": "sepolicy/time_daemon.te",
    "content": "allow time_daemon property_socket:sock_file write;\nallow time_daemon init:unix_stream_socket connectto;\nallow time_daemon system_prop:property_service set;\n"
  },
  {
    "path": "sepolicy/ueventd.te",
    "content": "allow ueventd vfat:dir search;\nallow ueventd vfat:file { read open };\nallow ueventd stm_sensor:chr_file { create setattr };\nallow ueventd cam_sysfs:file getattr;\n"
  },
  {
    "path": "sepolicy/vold.te",
    "content": "allow vold proc_touchpanel:dir { read open };\n"
  },
  {
    "path": "sepolicy/wcnss_filter.te",
    "content": "﻿allow wcnss_filter rootfs:lnk_file getattr;\n"
  },
  {
    "path": "sepolicy/wcnss_service.te",
    "content": "allow wcnss_service self:capability { setgid setuid };\n"
  },
  {
    "path": "setup-makefiles.sh",
    "content": "#!/bin/bash\n#\n# Copyright (C) 2016 The CyanogenMod Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\nset -e\n\n# Required!\nDEVICE=oneplus2\nVENDOR=oneplus\n\n# Load extractutils and do some sanity checks\nMY_DIR=\"${BASH_SOURCE%/*}\"\nif [[ ! -d \"$MY_DIR\" ]]; then MY_DIR=\"$PWD\"; fi\n\nCM_ROOT=\"$MY_DIR\"/../../..\n\nHELPER=\"$CM_ROOT\"/vendor/cm/build/tools/extract_utils.sh\nif [ ! -f \"$HELPER\" ]; then\n    echo \"Unable to find helper script at $HELPER\"\n    exit 1\nfi\n. \"$HELPER\"\n\n# Initialize the helper\nsetup_vendor \"$DEVICE\" \"$VENDOR\" \"$CM_ROOT\"\n\n# Copyright headers and guards\nwrite_headers\n\n# The standard blobs\nwrite_makefiles \"$MY_DIR\"/proprietary-files.txt\n\ncat << EOF >> \"$ANDROIDMK\"\n\nEOF\n\nprintf '\\n%s\\n' \"\\$(call inherit-product, vendor/qcom/binaries/msm8994/graphics/graphics-vendor.mk)\" >> \"$PRODUCTMK\"\n\n# We are done!\nwrite_footers\n\n"
  },
  {
    "path": "system.prop",
    "content": "# system.prop for OnePlus2\n\n# Audio\naudio.offload.video=true\npersist.audio.fluence.voicecall=true\npersist.audio.fluence.voicerec=false\npersist.audio.fluence.speaker=true\nro.qc.sdk.audio.fluencetype=fluence\nro.qc.sdk.audio.ssr=false\npersist.audio.ssr.3mic=false\nmedia.aac_51_output_enabled=true\naudio.offload.pcm.16bit.enable=true\naudio.offload.pcm.24bit.enable=true\nuse.voice.path.for.pcm.voip=true\naudio.offload.multiple.enabled=true\naudio.offload.gapless.enabled=true\nmm.enable.smoothstreaming=true\naudio.offload.buffer.size.kb=32\ntunnel.audio.encode=false\n\n# Bluetooth\nbluetooth.hfp.client=1\nqcom.bluetooth.soc=rome\nro.bluetooth.a4wp=true\nro.bluetooth.wipower=true\n\n# Camera\npersist.camera.HAL3.enabled=0\npersist.camera.cpp.duplication=false\nvidc.debug.perf.mode=2\nvidc.enc.dcvs.extra-buff-count=2\nmedia.stagefright.legacyencoder=true\nmedia.stagefright.less-secure=true\n\n# CEC\nro.hdmi.device_type=4\npersist.sys.hdmi.addr.playback=4\nro.hdmi.enable=true\npersist.speaker.prot.enable=false\npersist.spkr.cal.duration=0\nqcom.hw.aac.encoder=true\n\n# CNE\npersist.cne.feature=1\n\n# Data Power Manager (DPM)\npersist.dpm.feature=7\npersist.env.fastdorm.enabled=true\npersist.sys.dpmd.nsrm=3\n\n# Debug logging for DPM & CNE can be enabled via:\n# Push libdpmlog.so to system/vendor/lib|64\n#persist.dpm.nsrm.bkg.evt=3955\n#persist.dpm.loglevel=7825\n\n# Dex2oat limits\ndalvik.vm.boot-dex2oat-threads=4\ndalvik.vm.dex2oat-threads=2\ndalvik.vm.image-dex2oat-threads=4\n\n# GPS\npersist.gps.qc_nlp_in_use=1\npersist.loc.nlp_name=com.qualcomm.location\nro.gps.agps_provider=1\nro.pip.gated=0\n\n# Graphics\npersist.hwc.mdpcomp.enable=true\ndalvik.vm.heapsize=36m\nro.qualcomm.cabl=0\nro.sf.lcd_density=480\nro.opengles.version=196610\n\n# QC vendor extension\nro.vendor.extension_library=libqti-perfd-client.so\nro.frp.pst=/dev/block/bootdevice/by-name/config\ndrm.service.enabled=true\n\n# RIL\nrild.libpath=/vendor/lib64/libril-qc-qmi-1.so\nrild.libargs=-d /dev/smd0\npersist.rild.nitz_plmn=\npersist.rild.nitz_long_ons_0=\npersist.rild.nitz_long_ons_1=\npersist.rild.nitz_long_ons_2=\npersist.rild.nitz_long_ons_3=\npersist.rild.nitz_short_ons_0=\npersist.rild.nitz_short_ons_1=\npersist.rild.nitz_short_ons_2=\npersist.rild.nitz_short_ons_3=\nril.subscription.types=NV,RUIM\nDEVICE_PROVISIONED=1\ntelephony.lteOnGsmDevice=1\npersist.radio.multisim.config=dsds\npersist.radio.apm_sim_not_pwdn=1\npersist.radio.sib16_support=1\npersist.radio.sw_mbn_update=0\npersist.radio.start_ota_daemon=1\npersist.radio.rat_on=combine\npersist.data.qmi.adb_logmask=0\n\n# Sensors\nro.qc.sdk.sensors.gestures=true\nro.qc.sdk.gestures.camera=false\nro.qc.sdk.camera.facialproc=false\n\n# Storage\nro.sys.sdcardfs=true\n\n# Time services\npersist.timed.enable=true\n\n# Wifi\npersist.data.iwlan.enable=true\n"
  },
  {
    "path": "tftp.mk",
    "content": "#########################################################################\n# Create Folder Structure\n#########################################################################\n\n$(shell rm -rf $(TARGET_OUT)/rfs/)\n\n#To be enabled when prepopulation support is needed for the read_write folder\n# $(shell rm -rf  $(TARGET_OUT_DATA)/rfs/)\n# $(shell mkdir -p $(TARGET_OUT_DATA)/rfs/msm/mpss/)\n# $(shell mkdir -p $(TARGET_OUT_DATA)/rfs/msm/adsp/)\n# $(shell mkdir -p $(TARGET_OUT_DATA)/rfs/mdm/mpss/)\n# $(shell mkdir -p $(TARGET_OUT_DATA)/rfs/mdm/adsp/)\n\n#########################################################################\n# MSM Folders\n#########################################################################\n$(shell mkdir -p $(TARGET_OUT)/rfs/msm/mpss/readonly)\n$(shell mkdir -p $(TARGET_OUT)/rfs/msm/adsp/readonly)\n\n$(shell ln -s /data/tombstones/modem $(TARGET_OUT)/rfs/msm/mpss/ramdumps)\n$(shell ln -s /persist/rfs/msm/mpss $(TARGET_OUT)/rfs/msm/mpss/readwrite)\n$(shell ln -s /persist/rfs/shared $(TARGET_OUT)/rfs/msm/mpss/shared)\n$(shell ln -s /persist/hlos_rfs/shared $(TARGET_OUT)/rfs/msm/mpss/hlos)\n$(shell ln -s /firmware $(TARGET_OUT)/rfs/msm/mpss/readonly/firmware)\n\n$(shell ln -s /data/tombstones/lpass $(TARGET_OUT)/rfs/msm/adsp/ramdumps)\n$(shell ln -s /persist/rfs/msm/adsp $(TARGET_OUT)/rfs/msm/adsp/readwrite)\n$(shell ln -s /persist/rfs/shared $(TARGET_OUT)/rfs/msm/adsp/shared)\n$(shell ln -s /persist/hlos_rfs/shared $(TARGET_OUT)/rfs/msm/adsp/hlos)\n$(shell ln -s /firmware $(TARGET_OUT)/rfs/msm/adsp/readonly/firmware)\n\n#########################################################################\n# MDM Folders\n#########################################################################\n$(shell mkdir -p $(TARGET_OUT)/rfs/mdm/mpss/readonly)\n$(shell mkdir -p $(TARGET_OUT)/rfs/mdm/adsp/readonly)\n$(shell mkdir -p $(TARGET_OUT)/rfs/mdm/sparrow/readonly)\n\n$(shell ln -s /data/tombstones/modem $(TARGET_OUT)/rfs/mdm/mpss/ramdumps)\n$(shell ln -s /persist/rfs/mdm/mpss $(TARGET_OUT)/rfs/mdm/mpss/readwrite)\n$(shell ln -s /persist/rfs/shared $(TARGET_OUT)/rfs/mdm/mpss/shared)\n$(shell ln -s /persist/hlos_rfs/shared $(TARGET_OUT)/rfs/mdm/mpss/hlos)\n$(shell ln -s /firmware $(TARGET_OUT)/rfs/mdm/mpss/readonly/firmware)\n\n$(shell ln -s /data/tombstones/lpass $(TARGET_OUT)/rfs/mdm/adsp/ramdumps)\n$(shell ln -s /persist/rfs/mdm/adsp $(TARGET_OUT)/rfs/mdm/adsp/readwrite)\n$(shell ln -s /persist/rfs/shared $(TARGET_OUT)/rfs/mdm/adsp/shared)\n$(shell ln -s /persist/hlos_rfs/shared $(TARGET_OUT)/rfs/mdm/adsp/hlos)\n$(shell ln -s /firmware $(TARGET_OUT)/rfs/mdm/adsp/readonly/firmware)\n\n$(shell ln -s /data/tombstones/sparrow $(TARGET_OUT)/rfs/mdm/sparrow/ramdumps)\n$(shell ln -s /persist/rfs/mdm/sparrow $(TARGET_OUT)/rfs/mdm/sparrow/readwrite)\n$(shell ln -s /persist/rfs/shared $(TARGET_OUT)/rfs/mdm/sparrow/shared)\n$(shell ln -s /persist/hlos_rfs/shared $(TARGET_OUT)/rfs/mdm/sparrow/hlos)\n$(shell ln -s /firmware $(TARGET_OUT)/rfs/mdm/sparrow/readonly/firmware)\n\n#########################################################################\n# APQ Folders\n#########################################################################\n$(shell mkdir -p $(TARGET_OUT)/rfs/apq/gnss/readonly)\n\n$(shell ln -s /data/tombstones/modem $(TARGET_OUT)/rfs/apq/gnss/ramdumps)\n$(shell ln -s /persist/rfs/apq/gnss $(TARGET_OUT)/rfs/apq/gnss/readwrite)\n$(shell ln -s /persist/rfs/shared $(TARGET_OUT)/rfs/apq/gnss/shared)\n$(shell ln -s /persist/hlos_rfs/shared $(TARGET_OUT)/rfs/apq/gnss/hlos)\n$(shell ln -s /firmware $(TARGET_OUT)/rfs/apq/gnss/readonly/firmware)\n"
  },
  {
    "path": "vendorsetup.sh",
    "content": "add_lunch_combo cm_oneplus2-user\nadd_lunch_combo cm_oneplus2-userdebug\nadd_lunch_combo cm_oneplus2-eng\n"
  },
  {
    "path": "vr/Android.mk",
    "content": "# Copyright 2016 The Android Open Source Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nLOCAL_PATH:= $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_SRC_FILES := vr.c\nLOCAL_MODULE_RELATIVE_PATH := hw\nLOCAL_SHARED_LIBRARIES := liblog libcutils\nLOCAL_CFLAGS += -Wno-unused-parameter\nLOCAL_MODULE := vr.$(TARGET_BOARD_PLATFORM)\nLOCAL_MODULE_TAGS := optional\n\ninclude $(BUILD_SHARED_LIBRARY)\n"
  },
  {
    "path": "vr/vr.c",
    "content": "/*\n * Copyright (C) 2016 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"VrHALImpl\"\n\n#include <cutils/log.h>\n\n#include <errno.h>\n#include <fcntl.h>\n#include <string.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n\n#include <hardware/vr.h>\n#include <hardware/hardware.h>\n\n\n// OnePlus2 has two inflight numbers. By default, inflight=15 and inflight_low_latency=4.\n// Inflight is only used when there is a single GL context, when there is more than one\n// context, inflight_low_latency is used. Since we are only interested in affecting\n// performance when there is context preemption, we only have to modify the low latency\n// parameter.\nstatic const int DEFAULT_GPU_INFLIGHT = 4;\nstatic const int VR_MODE_GPU_INFLIGHT = 2;\nstatic const char* GPU_INFLIGHT_PATH = \"/sys/class/kgsl/kgsl-3d0/dispatch/inflight_low_latency\";\n\n/**\n * Write 'len' characters from 'input' character array into file at path 'outFile.'\n *\n * Return 0 on success, or a negative error code.\n */\nstatic int write_string(const char* input, size_t len, const char* outFile) {\n    int fd = -1;\n    ssize_t err = 0;\n\n    // Check input strings.\n    if (input == NULL || outFile == NULL) {\n        ALOGE(\"%s: Invalid input to write\", __FUNCTION__);\n        return -1;\n    }\n\n    // Open file, check for errors.\n    fd = open(outFile, O_WRONLY);\n    if (fd < 0) {\n        ALOGE(\"%s: Failed to open file %s, error %s (%d)\", __FUNCTION__, outFile, strerror(errno),\n              -errno);\n        return -errno;\n    }\n\n    // Write file, check for errors.\n    err = write(fd, input, len);\n    if (err < 0) {\n        ALOGE(\"%s: Failed to write file %s, error %s (%d)\", __FUNCTION__, outFile, strerror(errno),\n              -errno);\n        close(fd);\n        return -errno;\n    }\n\n    // Close and return success.\n    close(fd);\n    return 0;\n}\n\n/**\n * Write integer 'input' formatted as a character string into the file at path 'outFile.'\n *\n * Return 0 on success, or a negative error code.\n */\nstatic int write_int(int input, const char* outFile) {\n    char buffer[128] = {0,};\n    int bytes = snprintf(buffer, sizeof(buffer), \"%d\", input);\n\n    if (bytes < 0 || (size_t) bytes >= sizeof(buffer)) {\n        ALOGE(\"%s: Failed to format integer %d\", __FUNCTION__, input);\n        return -EINVAL;\n    }\n\n    return write_string(buffer, (size_t) bytes, outFile);\n}\n\n// Set global display/GPU/scheduler configuration to used for VR apps.\nstatic void set_vr_performance_configuration() {\n    int err = 0;\n\n    // Set in-flight buffers to 2.\n    err = write_int(VR_MODE_GPU_INFLIGHT, GPU_INFLIGHT_PATH);\n\n    if (err < 0) {\n        ALOGW(\"%s: Error while setting configuration for VR mode.\", __FUNCTION__);\n    }\n}\n\n// Reset to default global display/GPU/scheduler configuration.\nstatic void unset_vr_performance_configuration() {\n    int err = 0;\n\n    // Set in-flight buffers back to default (15).\n    err = write_int(DEFAULT_GPU_INFLIGHT, GPU_INFLIGHT_PATH);\n\n    if (err < 0) {\n        ALOGW(\"%s: Error while setting configuration for VR mode.\", __FUNCTION__);\n    }\n}\n\nstatic void vr_init(struct vr_module *module) {\n    // NOOP\n}\n\nstatic void vr_set_vr_mode(struct vr_module *module, bool enabled) {\n    if (enabled) {\n        set_vr_performance_configuration();\n    } else {\n        unset_vr_performance_configuration();\n    }\n}\n\nstatic struct hw_module_methods_t vr_module_methods = {\n    .open = NULL, // There are no devices for this HAL interface.\n};\n\n\nvr_module_t HAL_MODULE_INFO_SYM = {\n    .common = {\n        .tag                = HARDWARE_MODULE_TAG,\n        .module_api_version = VR_MODULE_API_VERSION_1_0,\n        .hal_api_version    = HARDWARE_HAL_API_VERSION,\n        .id                 = VR_HARDWARE_MODULE_ID,\n        .name               = \"OnePlus2 VR HAL\",\n        .author             = \"The Android Open Source Project\",\n        .methods            = &vr_module_methods,\n    },\n\n    .init = vr_init,\n    .set_vr_mode = vr_set_vr_mode,\n};\n"
  },
  {
    "path": "wifi/WCNSS_qcom_cfg.ini",
    "content": "# This file allows user to override the factory\n\n# defaults for the WLAN Driver\n\n\n# Enable IMPS or not\ngEnableImps=1\n\n# Enable/Disable Idle Scan\n\ngEnableIdleScan=0\n\n\n# Increase sleep duration (seconds) during IMPS\n# 0 implies no periodic wake up from IMPS. Periodic wakeup is\n# unnecessary if Idle Scan is disabled.\ngImpsModSleepTime=0\n\n\n# Enable BMPS or not\ngEnableBmps=1\n\n# Enable suspend or not\n\n# 1: Enable standby, 2: Enable Deep sleep, 3: Enable Mcast/Bcast Filter\n\ngEnableSuspend=3\n\n\n# Phy Mode (auto, b, g, n, etc)\n# Valid values are 0-9, with 0 = Auto, 4 = 11n, 9 = 11ac\n# 1 = 11abg, 2 = 11b, 3 = 11g, 5 = 11g only, 6 = 11n only\n# 7 = 11b only 8 = 11ac only.\ngDot11Mode=0\n\n\n# CSR Roaming Enable(1) Disable(0)\n\ngRoamingTime=0\n\n\n# Assigned MAC Addresses - This will be used until NV items are in place\n\n# Each byte of MAC address is represented in Hex format as XX\n\nIntf0MacAddress=000AF58989FF\nIntf1MacAddress=000AF58989FE\nIntf2MacAddress=000AF58989FD\n\nIntf3MacAddress=000AF58989FC\n\n\n# UAPSD service interval for VO,VI, BE, BK traffic\n\nInfraUapsdVoSrvIntv=0\n\nInfraUapsdViSrvIntv=0\n\nInfraUapsdBeSrvIntv=0\n\nInfraUapsdBkSrvIntv=0\n\n# Flag to allow STA send AddTspec even when ACM is Off\ngAddTSWhenACMIsOff=1\n\n# Make 1x1 the default antenna configuration\n\ngNumRxAnt=1\n\n\n# Beacon filtering frequency (unit in beacon intervals)\n\ngNthBeaconFilter=50\n\n\n# Enable WAPI or not\n\n# WAPIIsEnabled=0\n\n\n# Flags to filter Mcast abd Bcast RX packets.\n\n# Value 0: No filtering, 1: Filter all Multicast.\n\n# 2: Filter all Broadcast. 3: Filter all Mcast abd Bcast\n\nMcastBcastFilter=3\n\n\n#Flag to enable HostARPOffload feature or not\n\nhostArpOffload=1\n\n#Flag to enable TCPChkSumOffld feature or not\n\ngEnableTCPChkSumOffld=0\n\n#Flag to enable HostNSOffload feature or not\n\nhostNSOffload=1\n\n#Flag to enable IPChkSumOffld feature or not\n\ngEnableIPChecksumOffload=0\n\n#SoftAP Related Parameters\n\n# AP MAc addr\n\ngAPMacAddr=000AF589dcab\n\n\n# 802.11n Protection flag\n\ngEnableApProt=1\n\n\n#Enable OBSS protection\n\ngEnableApOBSSProt=1\n\n\n#Enable/Disable UAPSD for SoftAP\n\ngEnableApUapsd=1\n\n\n# Fixed Rate\n\ngFixedRate=0\n\n\n# Maximum Tx power\n\n# gTxPowerCap=30\n\n\n# Fragmentation Threshold\n\n# gFragmentationThreshold=2346\n\n\n# RTS threshold\n\n#RTSThreshold=1048576\n\n\n# Intra-BSS forward\n\ngDisableIntraBssFwd=0\n\n\n# WMM Enable/Disable\n\nWmmIsEnabled=0\n\n\n# 802.11d support\n\ng11dSupportEnabled=1\n\n# 802.11h support\n\ng11hSupportEnabled=1\n\n# DFS Master Capability\ngEnableDFSMasterCap=1\n\n# ESE Support and fast transition\nEseEnabled=1\nImplicitQosIsEnabled=0\ngNeighborScanTimerPeriod=200\n\ngNeighborLookupThreshold=76\ngNeighborReassocThreshold=81\n\ngNeighborScanChannelMinTime=20\ngNeighborScanChannelMaxTime=30\ngMaxNeighborReqTries=3\n\n# Legacy (non-ESE, non-802.11r) Fast Roaming Support\n# To enable, set FastRoamEnabled=1\n# To disable, set FastRoamEnabled=0\nFastRoamEnabled=1\n\n#Check if the AP to which we are roaming is better than current AP in terms of RSSI.\n#Checking is disabled if set to Zero.Otherwise it will use this value as to how better\n#the RSSI of the new/roamable AP should be for roaming\n# ifdef VENDOR_EDIT\nRoamRssiDiff=5\n# else\n#RoamRssiDiff=3\n# endif /* VENDOR_EDIT */\n\n# If the RSSI of any available candidate is better than currently associated\n# AP by at least gImmediateRoamRssiDiff, then being to roam immediately (without\n# registering for reassoc threshold).\n# NOTE: Value of 0 means that we would register for reassoc threshold.\ngImmediateRoamRssiDiff=10\n\n# To enable, set gRoamIntraBand=1 (Roaming within band)\n# To disable, set gRoamIntraBand=0 (Roaming across band)\ngRoamIntraBand=0\n\n# SAP Country code\n\n# Default Country Code is 2 bytes, 3rd byte is optional indoor or out door.\n\n# Example\n\n#   US Indoor, USI\n\n#   Korea Outdoor, KRO\n\n#   Japan without optional byte, JP\n\n#   France without optional byte, FR\n\n#gAPCntryCode=USI\n\n\n#Short Guard Interval Enable/disable\n\ngShortGI20Mhz=1\n\ngShortGI40Mhz=1\n\n\n#Auto Shutdown  Value in seconds. A value of 0 means Auto shutoff is disabled\n\ngAPAutoShutOff=0\n\n#Auto Shutdown wlan : Value in Seconds. 0 means disabled. Max 1 day = 86400 sec\ngWlanAutoShutdown = 0\n\n\n# SAP auto channel selection configuration\n\n# 0 = disable auto channel selection\n\n# 1 = enable auto channel selection, channel provided by supplicant will be ignored\n\ngApAutoChannelSelection=0\n\n\n# Listen Energy Detect Mode Configuration\n\n# Valid values 0-128\n\n# 128 means disable Energy Detect feature\n\n# 0-9 are threshold code and 7 is recommended value from system if feature is to be enabled.\n\n# 10-128 are reserved.\n\n# The EDET threshold mapping is as follows in 3dB step:\n\n# 0 = -60 dBm\n\n# 1 = -63 dBm\n\n# 2 = -66 dBm\n\n# ...\n\n# 7 = -81 dBm\n\n# 8 = -84 dBm\n\n# 9 = -87 dBm\n\n# Note: Any of these settings are valid. Setting 0 would yield the highest power saving (in a noisy environment) at the cost of more range. The range impact is approximately #calculated as:\n\n#\n\n#  Range Loss  (dB)  =  EDET threshold level (dBm) + 97 dBm.\n\n#\n\ngEnablePhyAgcListenMode=128\n\n\n#Preferred band (both or 2.4 only or 5 only)\n\nBandCapability=0\n\n\n#Beacon Early Termination (1 = enable the BET feature, 0 = disable)\n\nenableBeaconEarlyTermination=0\n\nbeaconEarlyTerminationWakeInterval=3\n\n\n#SOFTAP Channel Range selection\n\ngAPChannelSelectStartChannel=1\n\ngAPChannelSelectEndChannel=11\n\n\n#SOFTAP Channel Range selection Operating band\n\n# 0:2.4GHZ 1: LOW-5GHZ 2:MID-5GHZ 3:HIGH-5GHZ 4: 4.9HZ BAND\n\ngAPChannelSelectOperatingBand=0\n\n\n#Channel Bonding\ngChannelBondingMode5GHz=1\ngChannelBondingMode24GHz=0\n\n\n#Enable Keep alive with non-zero period value\n\ngStaKeepAlivePeriod = 30\n\n#Say gGoKeepAlivePeriod(5 seconds) and gGoLinkMonitorPeriod(10 seconds).\n#For every 10 seconds DUT send Qos Null frame(i.e., Keep Alive frame if link is idle for last 10 seconds.)\n#For both active and power save clients.\n\n#Power save clients: DUT set TIM bit from 10th second onwards and till client honors TIM bit.\n#If doesn't honor for 5 seconds then DUT remove client.\n\n#Active clients: DUT send Qos Null frame for 10th seconds onwards if it is not success still we try on\n#11th second if not tries on 12th and so on till 15th second. Hence before disconnection DUT will send 5 NULL frames.\n#Hence in any case DUT will detect client got removed in (10+5) seconds. i.e., (gGoKeepAlivePeriod + gGoLinkMonitorPeriod)..\n\n#gGoLinkMonitorPeriod/ gApLinkMonitorPeriod is period where link is idle and it is period\n#where we send NULL frame.\n\n#gApLinkMonitorPeriod = 10\n\n#gGoLinkMonitorPeriod = 10\n\n#gGoKeepAlivePeriod/gApKeepAlivePeriod is time to spend to check whether frame are succeed to send or not.\n#Hence total effective detection time is gGoLinkMonitorPeriod+ gGoKeepAlivePeriod/gApLinkMonitorPeriod+ gApKeepAlivePeriod.\n\n\ngGoKeepAlivePeriod = 20\n\ngApKeepAlivePeriod = 20\n\n\n#If set will start with active scan after driver load, otherwise will start with\n\n#passive scan to find out the domain\n\ngEnableBypass11d=1\n\n\n#If set to 0, will not scan DFS channels\n\ngEnableDFSChnlScan=1\n\n\ngVhtChannelWidth=2\ngEnableLogp=1\n\n\n# Enable Automatic Tx Power control\n\ngEnableAutomaticTxPowerControl=1\n\n# 0 for OLPC 1 for CLPC and SCPC\ngEnableCloseLoop=1\n\n#Data Inactivity Timeout when in powersave (in ms)\ngDataInactivityTimeout=200\n\n# VHT Tx/Rx MCS values\n# Valid values are 0,1,2. If commented out, the default value is 0.\n# 0=MCS0-7, 1=MCS0-8, 2=MCS0-9\ngVhtRxMCS=2\ngVhtTxMCS=2\n\n# VHT Tx/Rx MCS values for 2x2\n# Valid values are 0,1,2. If commented out, the default value is 0.\n# 0=MCS0-7, 1=MCS0-8, 2=MCS0-9\ngEnable2x2=1\ngVhtRxMCS2x2=2\ngVhtTxMCS2x2=2\n\n# Enable Tx beamforming\ngTxBFEnable=1\n\n# Enable Tx beamforming in VHT20MHz\n# Valid values are 0,1. If commented out, the default value is 0.\n# 0=disable, 1=enable\ngEnableTxBFin20MHz=1\n\n# Set txchainmask and rxchainmask\n# These parameters are used only if gEnable2x2 is 0\n# Valid values are 1,2\n# Set gSetTxChainmask1x1=1 or gSetRxChainmask1x1=1 to select chain0.\n# Set gSetTxChainmask1x1=2 or gSetRxChainmask1x1=2 to select chain1.\ngSetTxChainmask1x1=1\ngSetRxChainmask1x1=1\n\n# Enable CRDA regulatory support by settings default country code\n#gCrdaDefaultCountryCode=TW\n\n# Scan Timing Parameters\n# gPassiveMaxChannelTime=110\n# gPassiveMinChannelTime=60\ngActiveMaxChannelTime=40\ngActiveMinChannelTime=20\n\n#If set to 0, MCC is not allowed.\ngEnableMCCMode=1\n\n# MCC to SCC Switch mode: 0-Disable 1-Enable 2-Force SCC if same band\ngWlanMccToSccSwitchMode = 0\n\n# 1=enable STBC; 0=disable STBC\ngEnableRXSTBC=1\n\n# 1=enable tx STBC; 0=disable\ngEnableTXSTBC=1\n\n# 1=enable rx LDPC; 0=disable\ngEnableRXLDPC=1\n\n# Enable Active mode offload\ngEnableActiveModeOffload=1\n\n#Enable Scan Results Aging based on timer\n#Timer value is in seconds\n#If Set to 0 it will not enable the feature\ngScanAgingTime=0\n\n#Enable Scan Results Aging based on number of scans\n# ifdef VENDOR_EDIT\n# use default value 3\n#gScanResultAgeCount=1\n# endif /* VENDOR_EDIT */\n\n#Enable Power saving mechanism Based on Android Framework\n#If set to 0 Driver internally control the Power saving mechanism\n#If set to 1 Android Framwrok control the Power saving mechanism\nisAndroidPsEn=0\n\n#Enable thermal mitigation\ngThermalMitigationEnable=0\n\ngEnableFastRoamInConcurrency=1\n\n#List of Country codes for which 11ac needs to be disabled\n#Each country code must be delimited by comma(,)\ngListOfNon11acCountryCode=RU,UA,ZA\n\n#Maxium Channel time in msec\ngMaxMediumTime = 6000\n\n# 802.11K support\ngRrmEnable=1\ngRrmOperChanMax=8\ngRrmNonOperChanMax=8\ngRrmRandIntvl=100\n\n#Scan offload\ngEnableDirectedScanOffload=1\n\n#FlexConnect Power Factor\n#Default is set to 0 (disable)\ngFlexConnectPowerFactor=0\n\n#Disable split scan, the FW will take care of it\ngNumChanCombinedConc=60\n\n#Enable Power Save offload\ngEnablePowerSaveOffload=1\n\n#Enable firmware uart print\ngEnablefwprint=0\n\n#Enable firmware log\ngEnablefwlog=1\n\n#IPA config\ngIPAEnable=0x00\ngIPADescSize=800\ngIPAPreFilterEnable=1\ngIPARMEnable=1\ngIPAIPv6Enable=1\n\n#P2P Listen offload\ngEnableP2pListenOffload=1\n\n# Maximum Receive AMPDU size (VHT only. Valid values: 0->8k 1->16k 2->32k 3->64k 4->128k)\ngVhtAmpduLenExponent=7\n\n# Maximum MPDU length (VHT only. Valid values: 0->3895 octets, 1->7991 octets, 2->11454 octets)\ngVhtMpduLen=2\n\n# Maximum number of wow filters required\n#gMaxWoWFilters=22\n\n# WOW Enable/Disable.\n# 0 - Disable both magic pattern match and pattern byte match.\n# 1 - Enable magic pattern match on all interfaces.\n# 2 - Enable pattern byte match on all interfaces.\n# 3 - Enable both magic patter and pattern byte match on all interfaces.\n# Default value of gEnableWoW is 3.\n# gEnableWoW=0\n\n# Enable or Disable MCC Adaptive Scheduler at the FW\n# 1=Enable (default), 0=Disable\ngEnableMCCAdaptiveScheduler=1\n\n#Enable or Disable p2p device address administered\nisP2pDeviceAddrAdministrated=0\n\n#Enable Rx thread\ngEnableRxThread=1\n\n# Set Thermal Power limit\nTxPower2g=10\nTxPower5g=10\n\n# Remove Overlap channel restriction\ngEnableOverLapCh=0\n\n#Enable VHT on 2.4Ghz\ngEnableVhtFor24GHzBand=1\n\n#Enable or Disable 5G early beacon termination\ngEnable5gEBT=1\n\n#Maximum number of offload peers supported\n# gMaxOffloadPeers=2\n\n# controlling the following offload patterns\n# through ini parameter. Default value is 1\n# to disable set it to zero. ssdp = 0\n# Setup multicast pattern for mDNS 224.0.0.251,\n# SSDP 239.255.255.250 and LLMNR 224.0.0.252\n\n\nssdp = 0\n\n#Enable Memory Deep Sleep\ngEnableMemDeepSleep=1\n\n# Bus bandwidth threshold values in terms of number of packets\ngBusBandwidthHighThreshold=2000\ngBusBandwidthMediumThreshold=500\ngBusBandwidthLowThreshold=150\n\n# Bus bandwidth compute timeout value in ms\ngBusBandwidthComputeInterval=100\n\n# Regulatory Setting; 0=STRICT; 1=CUSTOM\ngRegulatoryChangeCountry=1\n\n# Maximum number of concurrent connections\ngMaxConcurrentActiveSessions=2\n\n# Radar PRI multiplier\ngDFSradarMappingPriMultiplier=4\n\ngPNOScanSupport=1\n\n# Enable/Disable RX full reorder offload\ngReorderOffloadSupported=1\n\n# userspace country code setting shld take priority\ngCountryCodePriority=1\n\n#Enable/Disable LPASS support\n# 0 to disable, 1 to enable\ngEnableLpassSupport=0\n\n# Enable(1)/Disable(0) SIFS burst\ngEnableSifsBurst=1\n\n# Enable or Disable Multi-user MIMO\n# 1=Enable (default), 0=Disable\ngEnableMuBformee=1\n\n# Enable/Disable channel avoidance for SAP in SCC scenario\n# 0 - disable\n# 1 - enable\ngSapSccChanAvoidance=0\n\n# RA filtering rate limit param, the current value would not\n# help if the lifetime in RA is less than 3*60=3min. Then\n# we need to change it, though it is uncommon.\n# gRAFilterEnable=0\ngRArateLimitInterval=60\n\n# Inactivity time (in ms) to end TX Service Period while in IBSS power save mode\ngIbssTxSpEndInactivityTime=10\n\n# Enable support for TDLS\n#  0 - disable\n#  1 - enable\ngEnableTDLSSupport=1\n\n# Enable support for Implicit Trigger of TDLS. That is, wlan driver shall\n# initiate TDLS Discovery towards a peer whenever setup criteria (throughput\n# and RSSI) is met and then will initiate teardown when teardown criteria\n# (idle packet count and RSSI) is met.\n#  0 - disable\n#  1 - enable\ngEnableTDLSImplicitTrigger=1\n\n# Enable TDLS External Control. That is, user space application has to\n# first configure a peer MAC in wlan driver towards which TDLS is desired.\n# Device will establish TDLS only towards those configured peers whenever\n# TDLS criteria (throughput and RSSI threshold) is met and teardown TDLS\n# when teardown criteria (idle packet count and RSSI) is met. However,\n# device will accept TDLS connection if it is initiated from any other peer,\n# even if that peer is not configured.\n#  0 - disable\n#  1 - enable\n# For TDLS External Control, Implicit Trigger must also be enabled.\ngTDLSExternalControl=1\n\n# Enable support for TDLS off-channel operation\n#  0 - disable\n#  1 - enable\n# TDLS off-channel operation will be invoked when there is only one\n# TDLS connection.\ngEnableTDLSOffChannel=1\n\n# Enable/Disable Roaming Offload Support (a.k.a Key Management Offload)\n# 0 to disable, 1 to enable\ngRoamOffloadEnabled=0\n\ngEnableSelfRecovery=1\n\n# Enable Runtime PM Feature.\n# Enabling this feature will put target wow and shutdown pcie link\n# when inactivity is detected in WLAN Driver.\n# This feature is inactive when beaconing interfaces are active with\n# clients associated.\n# 0 - disable\n# 1 - enable\ngRuntimePM=0\n\n# When gRuntimePM is disabled gRuntimeAutoTime won't take effect.\n# The Time is in msec.\n# 100 is min, 10000 is max, 500 is default.\ngRuntimePMDelay=500\n\n# Enable to check FW hash if secure FW feature is enabled. It's for defconfig\n# builds only since it will be ignored in performance/release builds.\ngEnableFWHashCheck=1\n\n#Enable TDLS Scan\ngEnableTDLSScan=1\n\n#Disable scanning for DFS channels while roaming\ngAllowDFSChannelRoam=0\n\n# jeff.lin, 2015.12.17, reduce the scan time while turning WiFi on\n# ifdef VENDOR_EDIT\ngInitialScanNoDFSChnl=1\ngInitialDwellTime=20\n# endif\n\n# ifdef VENDOR_EDIT\ngSoftApMaxPeers=15\ngRoamBmissFirstBcnt=30\ngRoamBmissFinalBcnt=30\nRTSThreshold=2437\ngTcpDelAckThresholdHigh=10000\n# endif /* VENDOR_EDIT */\n\nEND\n\n# Note: Configuration parser would not read anything past the END marker\n\n"
  },
  {
    "path": "wifi/hostapd.accept",
    "content": "# List of MAC addresses that are allowed to authenticate (IEEE 802.11)\n# with the AP. Optional VLAN ID can be assigned for clients based on the\n# MAC address if dynamic VLANs (hostapd.conf dynamic_vlan option) are used.\n"
  },
  {
    "path": "wifi/hostapd.conf",
    "content": "##### hostapd configuration file ##############################################\n# Empty lines and lines starting with # are ignored\n\n# AP netdevice name (without 'ap' postfix, i.e., wlan0 uses wlan0ap for\n# management frames); ath0 for madwifi\ninterface=wlan0\n\n# In case of madwifi and nl80211 driver interfaces, an additional configuration\n# parameter, bridge, must be used to notify hostapd if the interface is\n# included in a bridge. This parameter is not used with Host AP driver.\n#bridge=br0\n\n# Driver interface type (hostap/wired/madwifi/prism54/test/none/nl80211/bsd);\n# default: hostap). nl80211 is used with all Linux mac80211 drivers.\n# Use driver=none if building hostapd as a standalone RADIUS server that does\n# not control any wireless/wired driver.\ndriver=nl80211\n\n# hostapd event logger configuration\n#\n# Two output method: syslog and stdout (only usable if not forking to\n# background).\n#\n# Module bitfield (ORed bitfield of modules that will be logged; -1 = all\n# modules):\n# bit 0 (1) = IEEE 802.11\n# bit 1 (2) = IEEE 802.1X\n# bit 2 (4) = RADIUS\n# bit 3 (8) = WPA\n# bit 4 (16) = driver interface\n# bit 5 (32) = IAPP\n# bit 6 (64) = MLME\n#\n# Levels (minimum value for logged events):\n#  0 = verbose debugging\n#  1 = debugging\n#  2 = informational messages\n#  3 = notification\n#  4 = warning\n#\nlogger_syslog=-1\nlogger_syslog_level=2\nlogger_stdout=-1\nlogger_stdout_level=2\n\n# Dump file for state information (on SIGUSR1)\ndump_file=/tmp/hostapd.dump\n\n# Interface for separate control program. If this is specified, hostapd\n# will create this directory and a UNIX domain socket for listening to requests\n# from external programs (CLI/GUI, etc.) for status information and\n# configuration. The socket file will be named based on the interface name, so\n# multiple hostapd processes/interfaces can be run at the same time if more\n# than one interface is used.\n# /var/run/hostapd is the recommended directory for sockets and by default,\n# hostapd_cli will use it when trying to connect with hostapd.\nctrl_interface=/data/misc/wifi/hostapd\n\n\n# Access control for the control interface can be configured by setting the\n# directory to allow only members of a group to use sockets. This way, it is\n# possible to run hostapd as root (since it needs to change network\n# configuration and open raw sockets) and still allow GUI/CLI components to be\n# run as non-root users. However, since the control interface can be used to\n# change the network configuration, this access needs to be protected in many\n# cases. By default, hostapd is configured to use gid 0 (root). If you\n# want to allow non-root users to use the contron interface, add a new group\n# and change this value to match with that group. Add users that should have\n# control interface access to this group.\n#\n# This variable can be a group name or gid.\n#ctrl_interface_group=wheel\n#ctrl_interface_group=0\n\n\n##### IEEE 802.11 related configuration #######################################\n\n# SSID to be used in IEEE 802.11 management frames\nssid=QualcommSoftAP\n\n# Country code (ISO/IEC 3166-1). Used to set regulatory domain.\n# Set as needed to indicate country in which device is operating.\n# This can limit available channels and transmit power.\n#country_code=US\n\n# Enable IEEE 802.11d. This advertises the country_code and the set of allowed\n# channels and transmit power levels based on the regulatory limits. The\n# country_code setting must be configured with the correct country for\n# IEEE 802.11d functions.\n# (default: 0 = disabled)\n#ieee80211d=1\n\n# Operation mode (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g,\n# n =  IEEE 802.11n, g_only = IEEE 802.11g_only, n_only = IEEE 802.11n_only,\n# Default: IEEE 802.11n\nhw_mode=g\n\n# Channel number (IEEE 802.11)\n# (default: 0, i.e., not set)\n# Please note that some drivers (e.g., madwifi) do not use this value from\n# hostapd and the channel will need to be configuration separately with\n# iwconfig.\nchannel=6\n\n# Beacon interval in kus (1.024 ms) (default: 100; range 15..65535)\nbeacon_int=100\n\n# DTIM (delivery trafic information message) period (range 1..255):\n# number of beacons between DTIMs (1 = every beacon includes DTIM element)\n# (default: 2)\ndtim_period=2\n\n# Maximum number of stations allowed in station table. New stations will be\n# rejected after the station table is full. IEEE 802.11 has a limit of 2007\n# different association IDs, so this number should not be larger than that.\n# (default: 2007)\nmax_num_sta=255\n\n# RTS/CTS threshold; 2347 = disabled (default); range 0..2347\n# If this field is not included in hostapd.conf, hostapd will not control\n# RTS threshold and 'iwconfig wlan# rts <val>' can be used to set it.\n#rts_threshold=2347\n\n# Fragmentation threshold; 2346 = disabled (default); range 256..2346\n# If this field is not included in hostapd.conf, hostapd will not control\n# fragmentation threshold and 'iwconfig wlan# frag <val>' can be used to set\n# it.\n#fragm_threshold=2346\n\n# Rate configuration\n# Default is to enable all rates supported by the hardware. This configuration\n# item allows this list be filtered so that only the listed rates will be left\n# in the list. If the list is empty, all rates are used. This list can have\n# entries that are not in the list of rates the hardware supports (such entries\n# are ignored). The entries in this list are in 100 kbps, i.e., 11 Mbps = 110.\n# If this item is present, at least one rate have to be matching with the rates\n# hardware supports.\n# default: use the most common supported rate setting for the selected\n# hw_mode (i.e., this line can be removed from configuration file in most\n# cases)\n#supported_rates=10 20 55 110 60 90 120 180 240 360 480 540\n\n# Basic rate set configuration\n# List of rates (in 100 kbps) that are included in the basic rate set.\n# If this item is not included, usually reasonable default set is used.\n# This basic rates set is currently used for g-only profile\n#basic_rates=60\n\n# Short Preamble\n# This parameter can be used to enable optional use of short preamble for\n# frames sent at 2 Mbps, 5.5 Mbps, and 11 Mbps to improve network performance.\n# This applies only to IEEE 802.11b-compatible networks and this should only be\n# enabled if the local hardware supports use of short preamble. If any of the\n# associated STAs do not support short preamble, use of short preamble will be\n# disabled (and enabled when such STAs disassociate) dynamically.\n# 0 = do not allow use of short preamble (default)\n# 1 = allow use of short preamble\n#preamble=1\n\n# Station MAC address -based authentication\n# Please note that this kind of access control requires a driver that uses\n# hostapd to take care of management frame processing and as such, this can be\n# used with driver=hostap or driver=nl80211, but not with driver=madwifi.\n# 0 = accept unless in deny list\n# 1 = deny unless in accept list\n# 2 = use external RADIUS server (accept/deny lists are searched first)\nmacaddr_acl=0\n\n# Accept/deny lists are read from separate files (containing list of\n# MAC addresses, one per line). Use absolute path name to make sure that the\n# files can be read on SIGHUP configuration reloads.\naccept_mac_file=/data/misc/wifi/hostapd.accept\ndeny_mac_file=/data/misc/wifi/hostapd.deny\n\n# IEEE 802.11 specifies two authentication algorithms. hostapd can be\n# configured to allow both of these or only one. Open system authentication\n# should be used with IEEE 802.1X.\n# Bit fields of allowed authentication algorithms:\n# bit 0 = Open System Authentication\n# bit 1 = Shared Key Authentication (requires WEP)\nauth_algs=3\n\n# Send empty SSID in beacons and ignore probe request frames that do not\n# specify full SSID, i.e., require stations to know SSID.\n# default: disabled (0)\n# 1 = send empty (length=0) SSID in beacon and ignore probe request for\n#     broadcast SSID\n# 2 = clear SSID (ASCII 0), but keep the original length (this may be required\n#     with some clients that do not support empty SSID) and ignore probe\n#     requests for broadcast SSID\nignore_broadcast_ssid=0\n\n# TX queue parameters (EDCF / bursting)\n# default for all these fields: not set, use hardware defaults\n# tx_queue_<queue name>_<param>\n# queues: data0, data1, data2, data3, after_beacon, beacon\n#\t\t(data0 is the highest priority queue)\n# parameters:\n#   aifs: AIFS (default 2)\n#   cwmin: cwMin (1, 3, 7, 15, 31, 63, 127, 255, 511, 1023)\n#   cwmax: cwMax (1, 3, 7, 15, 31, 63, 127, 255, 511, 1023); cwMax >= cwMin\n#   burst: maximum length (in milliseconds with precision of up to 0.1 ms) for\n#          bursting\n#\n# Default WMM parameters (IEEE 802.11 draft; 11-03-0504-03-000e):\n# These parameters are used by the access point when transmitting frames\n# to the clients.\n#\n# Low priority / AC_BK = background\n#tx_queue_data3_aifs=7\n#tx_queue_data3_cwmin=15\n#tx_queue_data3_cwmax=1023\n#tx_queue_data3_burst=0\n# Note: for IEEE 802.11b mode: cWmin=31 cWmax=1023 burst=0\n#\n# Normal priority / AC_BE = best effort\n#tx_queue_data2_aifs=3\n#tx_queue_data2_cwmin=15\n#tx_queue_data2_cwmax=63\n#tx_queue_data2_burst=0\n# Note: for IEEE 802.11b mode: cWmin=31 cWmax=127 burst=0\n#\n# High priority / AC_VI = video\n#tx_queue_data1_aifs=1\n#tx_queue_data1_cwmin=7\n#tx_queue_data1_cwmax=15\n#tx_queue_data1_burst=3.0\n# Note: for IEEE 802.11b mode: cWmin=15 cWmax=31 burst=6.0\n#\n# Highest priority / AC_VO = voice\n#tx_queue_data0_aifs=1\n#tx_queue_data0_cwmin=3\n#tx_queue_data0_cwmax=7\n#tx_queue_data0_burst=1.5\n# Note: for IEEE 802.11b mode: cWmin=7 cWmax=15 burst=3.3\n#\n# Special queues; normally not user configurable\n#\n#tx_queue_after_beacon_aifs=2\n#tx_queue_after_beacon_cwmin=15\n#tx_queue_after_beacon_cwmax=1023\n#tx_queue_after_beacon_burst=0\n#\n#tx_queue_beacon_aifs=2\n#tx_queue_beacon_cwmin=3\n#tx_queue_beacon_cwmax=7\n#tx_queue_beacon_burst=1.5\n\n# 802.1D Tag (= UP) to AC mappings\n# WMM specifies following mapping of data frames to different ACs. This mapping\n# can be configured using Linux QoS/tc and sch_pktpri.o module.\n# 802.1D Tag\t802.1D Designation\tAccess Category\tWMM Designation\n# 1\t\tBK\t\t\tAC_BK\t\tBackground\n# 2\t\t-\t\t\tAC_BK\t\tBackground\n# 0\t\tBE\t\t\tAC_BE\t\tBest Effort\n# 3\t\tEE\t\t\tAC_BE\t\tBest Effort\n# 4\t\tCL\t\t\tAC_VI\t\tVideo\n# 5\t\tVI\t\t\tAC_VI\t\tVideo\n# 6\t\tVO\t\t\tAC_VO\t\tVoice\n# 7\t\tNC\t\t\tAC_VO\t\tVoice\n# Data frames with no priority information: AC_BE\n# Management frames: AC_VO\n# PS-Poll frames: AC_BE\n\n# Default WMM parameters (IEEE 802.11 draft; 11-03-0504-03-000e):\n# for 802.11a or 802.11g networks\n# These parameters are sent to WMM clients when they associate.\n# The parameters will be used by WMM clients for frames transmitted to the\n# access point.\n#\n# note - txop_limit is in units of 32microseconds\n# note - acm is admission control mandatory flag. 0 = admission control not\n# required, 1 = mandatory\n# note - here cwMin and cmMax are in exponent form. the actual cw value used\n# will be (2^n)-1 where n is the value given here\n#\nwmm_enabled=1\n#\n# Low priority / AC_BK = background\nwmm_ac_bk_cwmin=4\nwmm_ac_bk_cwmax=10\nwmm_ac_bk_aifs=7\nwmm_ac_bk_txop_limit=0\nwmm_ac_bk_acm=0\n# Note: for IEEE 802.11b mode: cWmin=5 cWmax=10\n#\n# Normal priority / AC_BE = best effort\nwmm_ac_be_aifs=3\nwmm_ac_be_cwmin=4\nwmm_ac_be_cwmax=10\nwmm_ac_be_txop_limit=0\nwmm_ac_be_acm=0\n# Note: for IEEE 802.11b mode: cWmin=5 cWmax=7\n#\n# High priority / AC_VI = video\nwmm_ac_vi_aifs=2\nwmm_ac_vi_cwmin=3\nwmm_ac_vi_cwmax=4\nwmm_ac_vi_txop_limit=94\nwmm_ac_vi_acm=0\n# Note: for IEEE 802.11b mode: cWmin=4 cWmax=5 txop_limit=188\n#\n# Highest priority / AC_VO = voice\nwmm_ac_vo_aifs=2\nwmm_ac_vo_cwmin=2\nwmm_ac_vo_cwmax=3\nwmm_ac_vo_txop_limit=47\nwmm_ac_vo_acm=0\n# Note: for IEEE 802.11b mode: cWmin=3 cWmax=4 burst=102\n\n# Static WEP key configuration\n#\n# The key number to use when transmitting.\n# It must be between 0 and 3, and the corresponding key must be set.\n# default: not set\n#wep_default_key=0\n# The WEP keys to use.\n# A key may be a quoted string or unquoted hexadecimal digits.\n# The key length should be 5, 13, or 16 characters, or 10, 26, or 32\n# digits, depending on whether 40-bit (64-bit), 104-bit (128-bit), or\n# 128-bit (152-bit) WEP is used.\n# Only the default key must be supplied; the others are optional.\n# default: not set\n#wep_key0=1234567890\n#wep_key1=1234567890\n#wep_key2=1234567890\n#wep_key3=1234567890\n\n# Station inactivity limit\n#\n# If a station does not send anything in ap_max_inactivity seconds, an\n# empty data frame is sent to it in order to verify whether it is\n# still in range. If this frame is not ACKed, the station will be\n# disassociated and then deauthenticated. This feature is used to\n# clear station table of old entries when the STAs move out of the\n# range.\n#\n# The station can associate again with the AP if it is still in range;\n# this inactivity poll is just used as a nicer way of verifying\n# inactivity; i.e., client will not report broken connection because\n# disassociation frame is not sent immediately without first polling\n# the STA with a data frame.\n# default: 300 (i.e., 5 minutes)\n#ap_max_inactivity=300\n\n# Enable/disable internal bridge for packets between associated stations.\n#\n# When IEEE 802.11 is used in managed mode, packets are usually send through\n# the AP even if they are from a wireless station to another wireless station.\n# This functionality requires that the AP has a bridge functionality that sends\n# frames back to the same interface if their destination is another associated\n# station. In addition, broadcast/multicast frames from wireless stations will\n# be sent both to the host system net stack (e.g., to eventually wired network)\n# and back to the wireless interface.\n#\n# The internal bridge is implemented within the wireless kernel module and it\n# bypasses kernel filtering (netfilter/iptables/ebtables). If direct\n# communication between the stations needs to be prevented, the internal\n# bridge can be disabled by setting bridge_packets=0.\n#\n# Note: If this variable is not included in hostapd.conf, hostapd does not\n# change the configuration and iwpriv can be used to set the value with\n# 'iwpriv wlan# param 10 0' command. If the variable is in hostapd.conf,\n# hostapd will override possible iwpriv configuration whenever configuration\n# file is reloaded.\n#\n# default: do not control from hostapd (80211.o defaults to 1=enabled)\n#bridge_packets=1\n\n# Maximum allowed Listen Interval (how many Beacon periods STAs are allowed to\n# remain asleep). Default: 65535 (no limit apart from field size)\n#max_listen_interval=100\n\n# Client isolation can be used to prevent low-level bridging of frames between\n# associated stations in the BSS. By default, this bridging is allowed.\n#ap_isolate=1\n\n##### IEEE 802.11n related configuration ######################################\n\n# ieee80211n: Whether IEEE 802.11n (HT) is enabled\n# 0 = disabled (default)\n# 1 = enabled\n# Note: You will also need to enable WMM for full HT functionality.\nieee80211n=1\n\n#require_ht=1\n\n# ht_capab: HT capabilities (list of flags)\n# LDPC coding capability: [LDPC] = supported\n# Supported channel width set: [HT40-] = both 20 MHz and 40 MHz with secondary\n#\tchannel below the primary channel; [HT40+] = both 20 MHz and 40 MHz\n#\twith secondary channel below the primary channel\n#\t(20 MHz only if neither is set)\n#\tNote: There are limits on which channels can be used with HT40- and\n#\tHT40+. Following table shows the channels that may be available for\n#\tHT40- and HT40+ use per IEEE 802.11n Annex J:\n#\tfreq\t\tHT40-\t\tHT40+\n#\t2.4 GHz\t\t5-13\t\t1-7 (1-9 in Europe/Japan)\n#\t5 GHz\t\t40,48,56,64\t36,44,52,60\n#\t(depending on the location, not all of these channels may be available\n#\tfor use)\n# Spatial Multiplexing (SM) Power Save: [SMPS-STATIC] or [SMPS-DYNAMIC]\n#\t(SMPS disabled if neither is set)\n# HT-greenfield: [GF] (disabled if not set)\n# Short GI for 20 MHz: [SHORT-GI-20] (disabled if not set)\n# Short GI for 40 MHz: [SHORT-GI-40] (disabled if not set)\n# Tx STBC: [TX-STBC] (disabled if not set)\n# Rx STBC: [RX-STBC1] (one spatial stream), [RX-STBC12] (one or two spatial\n#\tstreams), or [RX-STBC123] (one, two, or three spatial streams); Rx STBC\n#\tdisabled if none of these set\n# HT-delayed Block Ack: [DELAYED-BA] (disabled if not set)\n# Maximum A-MSDU length: [MAX-AMSDU-7935] for 7935 octets (3839 octets if not\n#\tset)\n# DSSS/CCK Mode in 40 MHz: [DSSS_CCK-40] = allowed (not allowed if not set)\n# PSMP support: [PSMP] (disabled if not set)\n# L-SIG TXOP protection support: [LSIG-TXOP-PROT] (disabled if not set)\n# QcHostapd:\n# LOWER byte for associated stations\n# UPPER byte for overlapping stations\n# each byte will have the following info\n# bit15 bit14 bit13     bit12  bit11 bit10    bit9     bit8\n# OBSS  RIFS  LSIG_TXOP NON_GF HT20  FROM_11G FROM_11B FROM_11A\n# bit7  bit6  bit5      bit4   bit3  bit2     bit1     bit0\n# OBSS  RIFS  LSIG_TXOP NON_GF HT_20 FROM_11G FROM_11B FROM_11A\n#ht_capab=[HT40-] [SHORT-GI-20] [SHORT-GI-40]\nht_capab=[SHORT-GI-20] [GF] [DSSS_CCK-40] [LSIG-TXOP-PROT]\n#ht_capab=[LDPC] [HT40-] [HT40+] [SMPS-STATIC] [SMPS-DYNAMIC] [GF] [SHORT-GI-20] [SHORT-GI-40] [TX-STBC] [RX-STBC1] [RX-STBC12] [RX-STBC123] [DELAYED-BA] [MAX-AMSDU-7935] [DSSS_CCK-40] [PSMP] [LSIG-TXOP-PROT]\n\n##### IEEE 802.1X-2004 related configuration ##################################\n\n# Require IEEE 802.1X authorization\n#ieee8021x=1\n\n# IEEE 802.1X/EAPOL version\n# hostapd is implemented based on IEEE Std 802.1X-2004 which defines EAPOL\n# version 2. However, there are many client implementations that do not handle\n# the new version number correctly (they seem to drop the frames completely).\n# In order to make hostapd interoperate with these clients, the version number\n# can be set to the older version (1) with this configuration value.\n#eapol_version=2\n\n# Optional displayable message sent with EAP Request-Identity. The first \\0\n# in this string will be converted to ASCII-0 (nul). This can be used to\n# separate network info (comma separated list of attribute=value pairs); see,\n# e.g., RFC 4284.\n#eap_message=hello\n#eap_message=hello\\0networkid=netw,nasid=foo,portid=0,NAIRealms=example.com\n\n# WEP rekeying (disabled if key lengths are not set or are set to 0)\n# Key lengths for default/broadcast and individual/unicast keys:\n# 5 = 40-bit WEP (also known as 64-bit WEP with 40 secret bits)\n# 13 = 104-bit WEP (also known as 128-bit WEP with 104 secret bits)\n#wep_key_len_broadcast=5\n#wep_key_len_unicast=5\n# Rekeying period in seconds. 0 = do not rekey (i.e., set keys only once)\n#wep_rekey_period=300\n\n# EAPOL-Key index workaround (set bit7) for WinXP Supplicant (needed only if\n# only broadcast keys are used)\neapol_key_index_workaround=0\n\n# EAP reauthentication period in seconds (default: 3600 seconds; 0 = disable\n# reauthentication).\n#eap_reauth_period=3600\n\n# Use PAE group address (01:80:c2:00:00:03) instead of individual target\n# address when sending EAPOL frames with driver=wired. This is the most common\n# mechanism used in wired authentication, but it also requires that the port\n# is only used by one station.\n#use_pae_group_addr=1\n\n##### Integrated EAP server ###################################################\n\n# Optionally, hostapd can be configured to use an integrated EAP server\n# to process EAP authentication locally without need for an external RADIUS\n# server. This functionality can be used both as a local authentication server\n# for IEEE 802.1X/EAPOL and as a RADIUS server for other devices.\n\n# Use integrated EAP server instead of external RADIUS authentication\n# server. This is also needed if hostapd is configured to act as a RADIUS\n# authentication server.\neap_server=1\n\n# Path for EAP server user database\n#eap_user_file=/etc/hostapd.eap_user\n\n# CA certificate (PEM or DER file) for EAP-TLS/PEAP/TTLS\n#ca_cert=/etc/hostapd.ca.pem\n\n# Server certificate (PEM or DER file) for EAP-TLS/PEAP/TTLS\n#server_cert=/etc/hostapd.server.pem\n\n# Private key matching with the server certificate for EAP-TLS/PEAP/TTLS\n# This may point to the same file as server_cert if both certificate and key\n# are included in a single file. PKCS#12 (PFX) file (.p12/.pfx) can also be\n# used by commenting out server_cert and specifying the PFX file as the\n# private_key.\n#private_key=/etc/hostapd.server.prv\n\n# Passphrase for private key\n#private_key_passwd=secret passphrase\n\n# Enable CRL verification.\n# Note: hostapd does not yet support CRL downloading based on CDP. Thus, a\n# valid CRL signed by the CA is required to be included in the ca_cert file.\n# This can be done by using PEM format for CA certificate and CRL and\n# concatenating these into one file. Whenever CRL changes, hostapd needs to be\n# restarted to take the new CRL into use.\n# 0 = do not verify CRLs (default)\n# 1 = check the CRL of the user certificate\n# 2 = check all CRLs in the certificate path\n#check_crl=1\n\n# dh_file: File path to DH/DSA parameters file (in PEM format)\n# This is an optional configuration file for setting parameters for an\n# ephemeral DH key exchange. In most cases, the default RSA authentication does\n# not use this configuration. However, it is possible setup RSA to use\n# ephemeral DH key exchange. In addition, ciphers with DSA keys always use\n# ephemeral DH keys. This can be used to achieve forward secrecy. If the file\n# is in DSA parameters format, it will be automatically converted into DH\n# params. This parameter is required if anonymous EAP-FAST is used.\n# You can generate DH parameters file with OpenSSL, e.g.,\n# \"openssl dhparam -out /etc/hostapd.dh.pem 1024\"\n#dh_file=/etc/hostapd.dh.pem\n\n# Configuration data for EAP-SIM database/authentication gateway interface.\n# This is a text string in implementation specific format. The example\n# implementation in eap_sim_db.c uses this as the UNIX domain socket name for\n# the HLR/AuC gateway (e.g., hlr_auc_gw). In this case, the path uses \"unix:\"\n# prefix.\n#eap_sim_db=unix:/tmp/hlr_auc_gw.sock\n\n# Encryption key for EAP-FAST PAC-Opaque values. This key must be a secret,\n# random value. It is configured as a 16-octet value in hex format. It can be\n# generated, e.g., with the following command:\n# od -tx1 -v -N16 /dev/random | colrm 1 8 | tr -d ' '\n#pac_opaque_encr_key=000102030405060708090a0b0c0d0e0f\n\n# EAP-FAST authority identity (A-ID)\n# A-ID indicates the identity of the authority that issues PACs. The A-ID\n# should be unique across all issuing servers. In theory, this is a variable\n# length field, but due to some existing implementations required A-ID to be\n# 16 octets in length, it is strongly recommended to use that length for the\n# field to provided interoperability with deployed peer implementation. This\n# field is configured in hex format.\n#eap_fast_a_id=101112131415161718191a1b1c1d1e1f\n\n# EAP-FAST authority identifier information (A-ID-Info)\n# This is a user-friendly name for the A-ID. For example, the enterprise name\n# and server name in a human-readable format. This field is encoded as UTF-8.\n#eap_fast_a_id_info=test server\n\n# Enable/disable different EAP-FAST provisioning modes:\n#0 = provisioning disabled\n#1 = only anonymous provisioning allowed\n#2 = only authenticated provisioning allowed\n#3 = both provisioning modes allowed (default)\n#eap_fast_prov=3\n\n# EAP-FAST PAC-Key lifetime in seconds (hard limit)\n#pac_key_lifetime=604800\n\n# EAP-FAST PAC-Key refresh time in seconds (soft limit on remaining hard\n# limit). The server will generate a new PAC-Key when this number of seconds\n# (or fewer) of the lifetime remains.\n#pac_key_refresh_time=86400\n\n# EAP-SIM and EAP-AKA protected success/failure indication using AT_RESULT_IND\n# (default: 0 = disabled).\n#eap_sim_aka_result_ind=1\n\n# Trusted Network Connect (TNC)\n# If enabled, TNC validation will be required before the peer is allowed to\n# connect. Note: This is only used with EAP-TTLS and EAP-FAST. If any other\n# EAP method is enabled, the peer will be allowed to connect without TNC.\n#tnc=1\n\n\n##### IEEE 802.11f - Inter-Access Point Protocol (IAPP) #######################\n\n# Interface to be used for IAPP broadcast packets\n#iapp_interface=eth0\n\n\n##### RADIUS client configuration #############################################\n# for IEEE 802.1X with external Authentication Server, IEEE 802.11\n# authentication with external ACL for MAC addresses, and accounting\n\n# The own IP address of the access point (used as NAS-IP-Address)\nown_ip_addr=127.0.0.1\n\n# Optional NAS-Identifier string for RADIUS messages. When used, this should be\n# a unique to the NAS within the scope of the RADIUS server. For example, a\n# fully qualified domain name can be used here.\n# When using IEEE 802.11r, nas_identifier must be set and must be between 1 and\n# 48 octets long.\n#nas_identifier=ap.example.com\n\n# RADIUS authentication server\n#auth_server_addr=127.0.0.1\n#auth_server_port=1812\n#auth_server_shared_secret=secret\n\n# RADIUS accounting server\n#acct_server_addr=127.0.0.1\n#acct_server_port=1813\n#acct_server_shared_secret=secret\n\n# Secondary RADIUS servers; to be used if primary one does not reply to\n# RADIUS packets. These are optional and there can be more than one secondary\n# server listed.\n#auth_server_addr=127.0.0.2\n#auth_server_port=1812\n#auth_server_shared_secret=secret2\n#\n#acct_server_addr=127.0.0.2\n#acct_server_port=1813\n#acct_server_shared_secret=secret2\n\n# Retry interval for trying to return to the primary RADIUS server (in\n# seconds). RADIUS client code will automatically try to use the next server\n# when the current server is not replying to requests. If this interval is set,\n# primary server will be retried after configured amount of time even if the\n# currently used secondary server is still working.\n#radius_retry_primary_interval=600\n\n\n# Interim accounting update interval\n# If this is set (larger than 0) and acct_server is configured, hostapd will\n# send interim accounting updates every N seconds. Note: if set, this overrides\n# possible Acct-Interim-Interval attribute in Access-Accept message. Thus, this\n# value should not be configured in hostapd.conf, if RADIUS server is used to\n# control the interim interval.\n# This value should not be less 600 (10 minutes) and must not be less than\n# 60 (1 minute).\n#radius_acct_interim_interval=600\n\n# Dynamic VLAN mode; allow RADIUS authentication server to decide which VLAN\n# is used for the stations. This information is parsed from following RADIUS\n# attributes based on RFC 3580 and RFC 2868: Tunnel-Type (value 13 = VLAN),\n# Tunnel-Medium-Type (value 6 = IEEE 802), Tunnel-Private-Group-ID (value\n# VLANID as a string). vlan_file option below must be configured if dynamic\n# VLANs are used. Optionally, the local MAC ACL list (accept_mac_file) can be\n# used to set static client MAC address to VLAN ID mapping.\n# 0 = disabled (default)\n# 1 = option; use default interface if RADIUS server does not include VLAN ID\n# 2 = required; reject authentication if RADIUS server does not include VLAN ID\n#dynamic_vlan=0\n\n# VLAN interface list for dynamic VLAN mode is read from a separate text file.\n# This list is used to map VLAN ID from the RADIUS server to a network\n# interface. Each station is bound to one interface in the same way as with\n# multiple BSSIDs or SSIDs. Each line in this text file is defining a new\n# interface and the line must include VLAN ID and interface name separated by\n# white space (space or tab).\n#vlan_file=/etc/hostapd.vlan\n\n# Interface where 802.1q tagged packets should appear when a RADIUS server is\n# used to determine which VLAN a station is on.  hostapd creates a bridge for\n# each VLAN.  Then hostapd adds a VLAN interface (associated with the interface\n# indicated by 'vlan_tagged_interface') and the appropriate wireless interface\n# to the bridge.\n#vlan_tagged_interface=eth0\n\n\n##### RADIUS authentication server configuration ##############################\n\n# hostapd can be used as a RADIUS authentication server for other hosts. This\n# requires that the integrated EAP server is also enabled and both\n# authentication services are sharing the same configuration.\n\n# File name of the RADIUS clients configuration for the RADIUS server. If this\n# commented out, RADIUS server is disabled.\n#radius_server_clients=/etc/hostapd.radius_clients\n\n# The UDP port number for the RADIUS authentication server\n#radius_server_auth_port=1812\n\n# Use IPv6 with RADIUS server (IPv4 will also be supported using IPv6 API)\n#radius_server_ipv6=1\n\n\n##### WPA/IEEE 802.11i configuration ##########################################\n\n# Enable WPA. Setting this variable configures the AP to require WPA (either\n# WPA-PSK or WPA-RADIUS/EAP based on other configuration). For WPA-PSK, either\n# wpa_psk or wpa_passphrase must be set and wpa_key_mgmt must include WPA-PSK.\n# For WPA-RADIUS/EAP, ieee8021x must be set (but without dynamic WEP keys),\n# RADIUS authentication server must be configured, and WPA-EAP must be included\n# in wpa_key_mgmt.\n# This field is a bit field that can be used to enable WPA (IEEE 802.11i/D3.0)\n# and/or WPA2 (full IEEE 802.11i/RSN):\n# bit0 = WPA\n# bit1 = IEEE 802.11i/RSN (WPA2) (dot11RSNAEnabled)\n#wpa=1\n\n# WPA pre-shared keys for WPA-PSK. This can be either entered as a 256-bit\n# secret in hex format (64 hex digits), wpa_psk, or as an ASCII passphrase\n# (8..63 characters) that will be converted to PSK. This conversion uses SSID\n# so the PSK changes when ASCII passphrase is used and the SSID is changed.\n# wpa_psk (dot11RSNAConfigPSKValue)\n# wpa_passphrase (dot11RSNAConfigPSKPassPhrase)\n#wpa_psk=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\n#wpa_passphrase=qualcomm\n\n# Optionally, WPA PSKs can be read from a separate text file (containing list\n# of (PSK,MAC address) pairs. This allows more than one PSK to be configured.\n# Use absolute path name to make sure that the files can be read on SIGHUP\n# configuration reloads.\n#wpa_psk_file=/etc/hostapd.wpa_psk\n\n# Set of accepted key management algorithms (WPA-PSK, WPA-EAP, or both). The\n# entries are separated with a space. WPA-PSK-SHA256 and WPA-EAP-SHA256 can be\n# added to enable SHA256-based stronger algorithms.\n# (dot11RSNAConfigAuthenticationSuitesTable)\n#wpa_key_mgmt=WPA-PSK\n#wpa_key_mgmt=WPA-EAP\n\n# Set of accepted cipher suites (encryption algorithms) for pairwise keys\n# (unicast packets). This is a space separated list of algorithms:\n# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]\n# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]\n# Group cipher suite (encryption algorithm for broadcast and multicast frames)\n# is automatically selected based on this configuration. If only CCMP is\n# allowed as the pairwise cipher, group cipher will also be CCMP. Otherwise,\n# TKIP will be used as the group cipher.\n# (dot11RSNAConfigPairwiseCiphersTable)\n# Pairwise cipher for WPA (v1) (default: TKIP)\n#wpa_pairwise=TKIP CCMP\n# Pairwise cipher for RSN/WPA2 (default: use wpa_pairwise value)\n#rsn_pairwise=CCMP\n\n# Time interval for rekeying GTK (broadcast/multicast encryption keys) in\n# seconds. (dot11RSNAConfigGroupRekeyTime)\nwpa_group_rekey=86400\n\n# Rekey GTK when any STA that possesses the current GTK is leaving the BSS.\n# (dot11RSNAConfigGroupRekeyStrict)\n#wpa_strict_rekey=1\n\n# Time interval for rekeying GMK (master key used internally to generate GTKs\n# (in seconds).\n#wpa_gmk_rekey=86400\n\n# Maximum lifetime for PTK in seconds. This can be used to enforce rekeying of\n# PTK to mitigate some attacks against TKIP deficiencies.\n#wpa_ptk_rekey=600\n\n# Enable IEEE 802.11i/RSN/WPA2 pre-authentication. This is used to speed up\n# roaming be pre-authenticating IEEE 802.1X/EAP part of the full RSN\n# authentication and key handshake before actually associating with a new AP.\n# (dot11RSNAPreauthenticationEnabled)\n#rsn_preauth=1\n#\n# Space separated list of interfaces from which pre-authentication frames are\n# accepted (e.g., 'eth0' or 'eth0 wlan0wds0'. This list should include all\n# interface that are used for connections to other APs. This could include\n# wired interfaces and WDS links. The normal wireless data interface towards\n# associated stations (e.g., wlan0) should not be added, since\n# pre-authentication is only used with APs other than the currently associated\n# one.\n#rsn_preauth_interfaces=eth0\n\n# peerkey: Whether PeerKey negotiation for direct links (IEEE 802.11e) is\n# allowed. This is only used with RSN/WPA2.\n# 0 = disabled (default)\n# 1 = enabled\n#peerkey=1\n\n# ieee80211w: Whether management frame protection (MFP) is enabled\n# 0 = disabled (default)\n# 1 = optional\n# 2 = required\n#ieee80211w=0\n\n# Association SA Query maximum timeout (in TU = 1.024 ms; for MFP)\n# (maximum time to wait for a SA Query response)\n# dot11AssociationSAQueryMaximumTimeout, 1...4294967295\n#assoc_sa_query_max_timeout=1000\n\n# Association SA Query retry timeout (in TU = 1.024 ms; for MFP)\n# (time between two subsequent SA Query requests)\n# dot11AssociationSAQueryRetryTimeout, 1...4294967295\n#assoc_sa_query_retry_timeout=201\n\n\n# okc: Opportunistic Key Caching (aka Proactive Key Caching)\n# Allow PMK cache to be shared opportunistically among configured interfaces\n# and BSSes (i.e., all configurations within a single hostapd process).\n# 0 = disabled (default)\n# 1 = enabled\n#okc=1\n\n\n##### IEEE 802.11r configuration ##############################################\n\n# Mobility Domain identifier (dot11FTMobilityDomainID, MDID)\n# MDID is used to indicate a group of APs (within an ESS, i.e., sharing the\n# same SSID) between which a STA can use Fast BSS Transition.\n# 2-octet identifier as a hex string.\n#mobility_domain=a1b2\n\n# PMK-R0 Key Holder identifier (dot11FTR0KeyHolderID)\n# 1 to 48 octet identifier.\n# This is configured with nas_identifier (see RADIUS client section above).\n\n# Default lifetime of the PMK-RO in minutes; range 1..65535\n# (dot11FTR0KeyLifetime)\n#r0_key_lifetime=10000\n\n# PMK-R1 Key Holder identifier (dot11FTR1KeyHolderID)\n# 6-octet identifier as a hex string.\n#r1_key_holder=000102030405\n\n# Reassociation deadline in time units (TUs / 1.024 ms; range 1000..65535)\n# (dot11FTReassociationDeadline)\n#reassociation_deadline=1000\n\n# List of R0KHs in the same Mobility Domain\n# format: <MAC address> <NAS Identifier> <128-bit key as hex string>\n# This list is used to map R0KH-ID (NAS Identifier) to a destination MAC\n# address when requesting PMK-R1 key from the R0KH that the STA used during the\n# Initial Mobility Domain Association.\n#r0kh=02:01:02:03:04:05 r0kh-1.example.com 000102030405060708090a0b0c0d0e0f\n#r0kh=02:01:02:03:04:06 r0kh-2.example.com 00112233445566778899aabbccddeeff\n# And so on.. One line per R0KH.\n\n# List of R1KHs in the same Mobility Domain\n# format: <MAC address> <R0KH-ID> <128-bit key as hex string>\n# This list is used to map R1KH-ID to a destination MAC address when sending\n# PMK-R1 key from the R0KH. This is also the list of authorized R1KHs in the MD\n# that can request PMK-R1 keys.\n#r1kh=02:01:02:03:04:05 02:11:22:33:44:55 000102030405060708090a0b0c0d0e0f\n#r1kh=02:01:02:03:04:06 02:11:22:33:44:66 00112233445566778899aabbccddeeff\n# And so on.. One line per R1KH.\n\n# Whether PMK-R1 push is enabled at R0KH\n# 0 = do not push PMK-R1 to all configured R1KHs (default)\n# 1 = push PMK-R1 to all configured R1KHs whenever a new PMK-R0 is derived\n#pmk_r1_push=1\n\n##### Passive scanning ########################################################\n# Scan different channels every N seconds. 0 = disable passive scanning.\n#passive_scan_interval=60\n\n# Listen N usecs on each channel when doing passive scanning.\n# This value plus the time needed for changing channels should be less than\n# 32 milliseconds (i.e. 32000 usec) to avoid interruptions to normal\n# operations. Time needed for channel changing varies based on the used wlan\n# hardware.\n# default: disabled (0)\n#passive_scan_listen=10000\n\n# Passive scanning mode:\n# 0 = scan all supported modes (802.11a/b/g/Turbo) (default)\n# 1 = scan only the mode that is currently used for normal operations\n#passive_scan_mode=1\n\n# Maximum number of entries kept in AP table (either for passive scanning or\n# for detecting Overlapping Legacy BSS Condition). The oldest entry will be\n# removed when adding a new entry that would make the list grow over this\n# limit. Note! Wi-Fi certification for IEEE 802.11g requires that OLBC is\n# enabled, so this field should not be set to 0 when using IEEE 802.11g.\n# default: 255\n#ap_table_max_size=255\n\n# Number of seconds of no frames received after which entries may be deleted\n# from the AP table. Since passive scanning is not usually performed frequently\n# this should not be set to very small value. In addition, there is no\n# guarantee that every scan cycle will receive beacon frames from the\n# neighboring APs.\n# default: 60\n#ap_table_expiration_time=3600\n\n\n##### Wi-Fi Protected Setup (WPS) #############################################\n\n# WPS state\n# 0 = WPS disabled (default)\n# 1 = WPS enabled, not configured\n# 2 = WPS enabled, configured\n#wps_state=2\n\n# AP can be configured into a locked state where new WPS Registrar are not\n# accepted, but previously authorized Registrars (including the internal one)\n# can continue to add new Enrollees.\nap_setup_locked=1\n\n# Universally Unique IDentifier (UUID; see RFC 4122) of the device\n# This value is used as the UUID for the internal WPS Registrar. If the AP\n# is also using UPnP, this value should be set to the device's UPnP UUID.\n# If not configured, UUID will be generated based on the local MAC address.\n#uuid=12345678-9abc-def0-1234-56789abcdef0\n\n# Note: If wpa_psk_file is set, WPS is used to generate random, per-device PSKs\n# that will be appended to the wpa_psk_file. If wpa_psk_file is not set, the\n# default PSK (wpa_psk/wpa_passphrase) will be delivered to Enrollees. Use of\n# per-device PSKs is recommended as the more secure option (i.e., make sure to\n# set wpa_psk_file when using WPS with WPA-PSK).\n\n# When an Enrollee requests access to the network with PIN method, the Enrollee\n# PIN will need to be entered for the Registrar. PIN request notifications are\n# sent to hostapd ctrl_iface monitor. In addition, they can be written to a\n# text file that could be used, e.g., to populate the AP administration UI with\n# pending PIN requests. If the following variable is set, the PIN requests will\n# be written to the configured file.\n#wps_pin_requests=/var/run/hostapd_wps_pin_requests\n\n# Device Name\n# User-friendly description of device; up to 32 octets encoded in UTF-8\n#device_name=Wireless AP\n\n# Manufacturer\n# The manufacturer of the device (up to 64 ASCII characters)\n#manufacturer=Qualcomm\n\n# Model Name\n# Model of the device (up to 32 ASCII characters)\n#model_name=QualcommSoftAP\n\n# Model Number\n# Additional device description (up to 32 ASCII characters)\n#model_number=123\n\n# Serial Number\n# Serial number of the device (up to 32 characters)\n#serial_number=12345\n\n# Primary Device Type\n# Used format: <categ>-<OUI>-<subcateg>\n# categ = Category as an integer value\n# OUI = OUI and type octet as a 4-octet hex-encoded value; 0050F204 for\n#       default WPS OUI\n# subcateg = OUI-specific Sub Category as an integer value\n# Examples:\n#   1-0050F204-1 (Computer / PC)\n#   1-0050F204-2 (Computer / Server)\n#   5-0050F204-1 (Storage / NAS)\n#   6-0050F204-1 (Network Infrastructure / AP)\n#device_type=6-0050F204-1\n\n# OS Version\n# 4-octet operating system version number (hex string)\n#os_version=01020300\n\n# Config Methods\n# List of the supported configuration methods\nconfig_methods=label display push_button keypad\n\n# Access point PIN for initial configuration and adding Registrars\n# If not set, hostapd will not allow external WPS Registrars to control the\n# access point.\n#ap_pin=12345670\n\n# Skip building of automatic WPS credential\n# This can be used to allow the automatically generated Credential attribute to\n# be replaced with pre-configured Credential(s).\n#skip_cred_build=1\n\n# Additional Credential attribute(s)\n# This option can be used to add pre-configured Credential attributes into M8\n# message when acting as a Registrar. If skip_cred_build=1, this data will also\n# be able to override the Credential attribute that would have otherwise been\n# automatically generated based on network configuration. This configuration\n# option points to an external file that much contain the WPS Credential\n# attribute(s) as binary data.\n#extra_cred=hostapd.cred\n\n# Credential processing\n#   0 = process received credentials internally (default)\n#   1 = do not process received credentials; just pass them over ctrl_iface to\n#\texternal program(s)\n#   2 = process received credentials internally and pass them over ctrl_iface\n#\tto external program(s)\n# Note: With wps_cred_processing=1, skip_cred_build should be set to 1 and\n# extra_cred be used to provide the Credential data for Enrollees.\n#\n# wps_cred_processing=1 will disabled automatic updates of hostapd.conf file\n# both for Credential processing and for marking AP Setup Locked based on\n# validation failures of AP PIN. An external program is responsible on updating\n# the configuration appropriately in this case.\n#wps_cred_processing=0\n\n# AP Settings Attributes for M7\n# By default, hostapd generates the AP Settings Attributes for M7 based on the\n# current configuration. It is possible to override this by providing a file\n# with pre-configured attributes. This is similar to extra_cred file format,\n# but the AP Settings attributes are not encapsulated in a Credential\n# attribute.\n#ap_settings=hostapd.ap_settings\n\n# WPS UPnP interface\n# If set, support for external Registrars is enabled.\n#upnp_iface=br0\n\n# Friendly Name (required for UPnP)\n# Short description for end use. Should be less than 64 characters.\n#friendly_name=Qualcomm Access Point\n\n# Manufacturer URL (optional for UPnP)\n#manufacturer_url=http://www.qualcomm.com/\n\n# Model Description (recommended for UPnP)\n# Long description for end user. Should be less than 128 characters.\n#model_description=Wireless Access Point\n\n# Model URL (optional for UPnP)\n#model_url=http://www.qualcomm.com/\n\n# Universal Product Code (optional for UPnP)\n# 12-digit, all-numeric code that identifies the consumer package.\n#upc=123456789012\n\n##### Multiple BSSID support ##################################################\n#\n# Above configuration is using the default interface (wlan#, or multi-SSID VLAN\n# interfaces). Other BSSIDs can be added by using separator 'bss' with\n# default interface name to be allocated for the data packets of the new BSS.\n#\n# hostapd will generate BSSID mask based on the BSSIDs that are\n# configured. hostapd will verify that dev_addr & MASK == dev_addr. If this is\n# not the case, the MAC address of the radio must be changed before starting\n# hostapd (ifconfig wlan0 hw ether <MAC addr>).\n#\n# BSSIDs are assigned in order to each BSS, unless an explicit BSSID is\n# specified using the 'bssid' parameter.\n# If an explicit BSSID is specified, it must be chosen such that it:\n# - results in a valid MASK that covers it and the dev_addr\n# - is not the same as the MAC address of the radio\n# - is not the same as any other explicitly specified BSSID\n#\n# Please note that hostapd uses some of the values configured for the first BSS\n# as the defaults for the following BSSes. However, it is recommended that all\n# BSSes include explicit configuration of all relevant configuration items.\n#\n#bss=wlan0_0\n#ssid=test2\n# most of the above items can be used here (apart from radio interface specific\n# items, like channel)\n\n#bss=wlan0_1\n#bssid=00:13:10:95:fe:0b\n# ...\n"
  },
  {
    "path": "wifi/hostapd.deny",
    "content": "# List of MAC addresses that are not allowed to authenticate (IEEE 802.11)\n# with the AP.\n"
  },
  {
    "path": "wifi/p2p_supplicant_overlay.conf",
    "content": "disable_scan_offload=1\np2p_search_delay=100\n"
  },
  {
    "path": "wifi/wpa_supplicant_overlay.conf",
    "content": "disable_scan_offload=1\np2p_disabled=1\n"
  }
]