Initial Commit4
This commit is contained in:
74
Android.mk
74
Android.mk
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2016 The Android Open-Source Project
|
||||
# Copyright (C) 2016 The CyanogenMod Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,12 +12,80 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
ifneq ($(filter potter, $(TARGET_DEVICE)),)
|
||||
ifneq ($(filter potter,$(TARGET_DEVICE)),)
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
FIRMWARE_ADSP_IMAGES := \
|
||||
adsp.b00 adsp.b01 adsp.b02 adsp.b03 adsp.b04 adsp.b05 adsp.b06 \
|
||||
adsp.b07 adsp.b08 adsp.b09 adsp.b10 adsp.b11 adsp.b12 adsp.b13 \
|
||||
adsp.mdt
|
||||
|
||||
FIRMWARE_ADSP_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_MODEM_IMAGES)))
|
||||
$(FIRMWARE_ADSP_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
|
||||
@echo "ADSP Firmware link: $@"
|
||||
@mkdir -p $(dir $@)
|
||||
@rm -rf $@
|
||||
$(hide) ln -sf /firmware/image/$(notdir $@) $@
|
||||
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_ADSP_SYMLINKS)
|
||||
|
||||
FIRMWARE_FINGERPRINT_IMAGES := \
|
||||
fpctzappfingerprint.b00 fpctzappfingerprint.b01 fpctzappfingerprint.b02 \
|
||||
fpctzappfingerprint.b03 fpctzappfingerprint.b04 fpctzappfingerprint.b05 \
|
||||
fpctzappfingerprint.b06 fpctzappfingerprint.mdt
|
||||
|
||||
FIRMWARE_FINGERPRINT_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_FINGERPRINT_IMAGES)))
|
||||
$(FIRMWARE_FINGERPRINT_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
|
||||
@echo "Fingerprint Firmware link: $@"
|
||||
@mkdir -p $(dir $@)
|
||||
@rm -rf $@
|
||||
$(hide) ln -sf /firmware/image/$(notdir $@) $@
|
||||
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_FINGERPRINT_SYMLINKS)
|
||||
|
||||
FIRMWARE_MODEM_IMAGES := \
|
||||
modem.b00 modem.b01 modem.b02 modem.b04 modem.b05 modem.b06 \
|
||||
modem.b07 modem.b08 modem.b09 modem.b10 modem.b11 modem.b12 \
|
||||
modem.b13 modem.b16 modem.b17 modem.b18 modem.b19 modem.b20 \
|
||||
modem.mdt
|
||||
|
||||
FIRMWARE_MODEM_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_MODEM_IMAGES)))
|
||||
$(FIRMWARE_MODEM_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
|
||||
@echo "Modem Firmware link: $@"
|
||||
@mkdir -p $(dir $@)
|
||||
@rm -rf $@
|
||||
$(hide) ln -sf /firmware/image/$(notdir $@) $@
|
||||
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_MODEM_SYMLINKS)
|
||||
|
||||
FIRMWARE_WCNSS_IMAGES := \
|
||||
wcnss.b00 wcnss.b01 wcnss.b02 wcnss.b04 wcnss.b06 \
|
||||
wcnss.b09 wcnss.b10 wcnss.b11 wcnss.b12 wcnss.mdt
|
||||
|
||||
FIRMWARE_WCNSS_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_WCNSS_IMAGES)))
|
||||
$(FIRMWARE_WCNSS_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
|
||||
@echo "WCNSS Firmware link: $@"
|
||||
@mkdir -p $(dir $@)
|
||||
@rm -rf $@
|
||||
$(hide) ln -sf /firmware/image/$(notdir $@) $@
|
||||
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_WCNSS_SYMLINKS)
|
||||
|
||||
FIRMWARE_WIDEVINE_IMAGES := \
|
||||
widevine.b00 widevine.b01 widevine.b02 widevine.b03 \
|
||||
widevine.b04 widevine.b05 widevine.b06 widevine.mdt
|
||||
|
||||
FIRMWARE_WIDEVINE_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_WIDEVINE_IMAGES)))
|
||||
$(FIRMWARE_WIDEVINE_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
|
||||
@echo "Widevine Firmware link: $@"
|
||||
@mkdir -p $(dir $@)
|
||||
@rm -rf $@
|
||||
$(hide) ln -sf /firmware/image/$(notdir $@) $@
|
||||
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_WIDEVINE_SYMLINKS)
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
|
||||
endif
|
||||
145
BoardConfig.mk
145
BoardConfig.mk
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright (C) 2015-2016 The Android Open-Source Project
|
||||
# Copyright (C) 2016 The CyanogenMod Project
|
||||
# Copyright (C) 2017 The LineageOS Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,66 +13,138 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
-include vendor/motorola/potter/BoardConfigVendor.mk
|
||||
|
||||
DEVICE_PATH := device/motorola/potter
|
||||
|
||||
TARGET_RECOVERY_DEVICE_DIRS := $(DEVICE_PATH)
|
||||
BOARD_VENDOR := motorola-qcom
|
||||
|
||||
TARGET_ARCH := arm
|
||||
TARGET_CPU_ABI := armeabi-v7a
|
||||
TARGET_CPU_ABI2 := armeabi
|
||||
TARGET_CPU_VARIANT := cortex-a53
|
||||
TARGET_ARCH_VARIANT := armv7-a-neon
|
||||
TARGET_CPU_SMP := true
|
||||
ARCH_ARM_HAVE_TLS_REGISTER := true
|
||||
|
||||
TARGET_GLOBAL_CFLAGS += -mfpu=neon -mfloat-abi=softfp
|
||||
TARGET_GLOBAL_CPPFLAGS += -mfpu=neon -mfloat-abi=softfp
|
||||
TARGET_SPECIFIC_HEADER_PATH := $(VENDOR_PATH)/include
|
||||
|
||||
# Platform
|
||||
TARGET_BOARD_PLATFORM := msm8953
|
||||
TARGET_BOARD_PLATFORM_GPU := qcom-adreno506
|
||||
|
||||
# Bootloader
|
||||
TARGET_BOOTLOADER_BOARD_NAME := MSM8953
|
||||
TARGET_NO_BOOTLOADER := true
|
||||
|
||||
#TARGET_PREBUILT_KERNEL := $(DEVICE_PATH)/boot.img-zImage
|
||||
#TARGET_PREBUILT_DTB := $(DEVICE_PATH)/boot.img-dt
|
||||
# Architecture
|
||||
TARGET_ARCH := arm
|
||||
TARGET_ARCH_VARIANT := armv7-a-neon
|
||||
TARGET_CPU_ABI := armeabi-v7a
|
||||
TARGET_CPU_ABI2 := armeabi
|
||||
TARGET_CPU_VARIANT := cortex-a53
|
||||
|
||||
BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci vmalloc=350M androidboot.selinux=permissive
|
||||
# Asserts
|
||||
TARGET_OTA_ASSERT_DEVICE := potter,potter_retail
|
||||
|
||||
# Init
|
||||
TARGET_INIT_VENDOR_LIB := libinit_potter
|
||||
TARGET_RECOVERY_DEVICE_MODULES := libinit_potter
|
||||
|
||||
# Kernel
|
||||
BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=30 msm_rtb.filter=0x237
|
||||
BOARD_KERNEL_CMDLINE += ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 vmalloc=350M
|
||||
BOARD_KERNEL_BASE := 0x80000000
|
||||
BOARD_KERNEL_SEPARATED_DT := true
|
||||
BOARD_RAMDISK_OFFSET := 0x01000000
|
||||
BOARD_KERNEL_LZ4C_DT := true
|
||||
BOARD_KERNEL_PAGESIZE := 2048
|
||||
BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x01000000
|
||||
BOARD_CUSTOM_BOOTIMG_MK := $(DEVICE_PATH)/mkbootimg.mk
|
||||
KERNEL_TOOLCHAIN_PREFIX := arm-linux-androidkernel-
|
||||
BOARD_KERNEL_SEPARATED_DT := true
|
||||
BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x01000000 --tags_offset 0x00000100
|
||||
TARGET_KERNEL_ARCH := arm
|
||||
TARGET_KERNEL_CONFIG := addison_potter
|
||||
TARGET_KERNEL_SOURCE := kernel/motorola/msm8953
|
||||
|
||||
BOARD_USES_QCOM_HARDWARE := true
|
||||
# Audio
|
||||
AUDIO_FEATURE_ENABLED_COMPRESS_VOIP := true
|
||||
AUDIO_FEATURE_ENABLED_EXTN_FORMATS := true
|
||||
AUDIO_FEATURE_ENABLED_FLAC_OFFLOAD := true
|
||||
AUDIO_FEATURE_ENABLED_FLUENCE := true
|
||||
AUDIO_FEATURE_ENABLED_HFP := true
|
||||
AUDIO_FEATURE_ENABLED_KPI_OPTIMIZE := true
|
||||
AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS := true
|
||||
AUDIO_FEATURE_ENABLED_PCM_OFFLOAD := true
|
||||
AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24 := true
|
||||
BOARD_USES_ALSA_AUDIO := true
|
||||
USE_CUSTOM_AUDIO_POLICY := 1
|
||||
USE_XML_AUDIO_POLICY_CONF := 1
|
||||
|
||||
# Bluetooth
|
||||
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(DEVICE_PATH)/bluetooth
|
||||
BOARD_HAVE_BLUETOOTH := true
|
||||
BOARD_HAVE_BLUETOOTH_QCOM := true
|
||||
BLUETOOTH_HCI_USE_MCT := true
|
||||
|
||||
# Camera
|
||||
TARGET_CAMERASERVICE_CLOSES_NATIVE_HANDLES := true
|
||||
USE_DEVICE_SPECIFIC_CAMERA := true
|
||||
|
||||
# Charger
|
||||
BACKLIGHT_PATH := /sys/class/leds/lcd-backlight/brightness
|
||||
BOARD_CHARGER_ENABLE_SUSPEND := true
|
||||
BOARD_NO_CHARGER_LED := true
|
||||
|
||||
# CMHW
|
||||
BOARD_USES_CYANOGEN_HARDWARE := true
|
||||
BOARD_HARDWARE_CLASS += hardware/cyanogen/cmhw
|
||||
|
||||
# Crypto
|
||||
TARGET_HW_DISK_ENCRYPTION := true
|
||||
|
||||
# Display
|
||||
BOARD_USES_ADRENO := true
|
||||
NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3
|
||||
OVERRIDE_RS_DRIVER := libRSDriver_adreno.so
|
||||
TARGET_USES_C2D_COMPOSITION := true
|
||||
TARGET_USES_ION := true
|
||||
USE_OPENGL_RENDERER := true
|
||||
|
||||
# Keymaster
|
||||
TARGET_PROVIDES_KEYMASTER := true
|
||||
|
||||
# Lights
|
||||
TARGET_PROVIDES_LIBLIGHT := true
|
||||
|
||||
# Media
|
||||
TARGET_USES_MEDIA_EXTENSIONS := true
|
||||
|
||||
# Partitions
|
||||
BOARD_FLASH_BLOCK_SIZE := 131072
|
||||
BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
|
||||
BOARD_BOOTIMAGE_PARTITION_SIZE := 16777216 # 16384 * 1024 mmcblk0p37
|
||||
BOARD_CACHEIMAGE_PARTITION_SIZE := 268435456 # 262144 * 1024 mmcblk0p52
|
||||
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 16879616 # 16484 * 1024 mmcblk0p38
|
||||
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 4294967296 # 4194304 * 1024 mmcblk0p53
|
||||
BOARD_USERDATAIMAGE_PARTITION_SIZE := 25614597120 # 25014255 * 1024 mmcblk0p54
|
||||
|
||||
# don't take forever to wipe
|
||||
BOARD_SUPPRESS_SECURE_ERASE := true
|
||||
#COMMON_GLOBAL_CFLAGS += -DNO_SECURE_DISCARD
|
||||
# Power
|
||||
TARGET_POWERHAL_VARIANT := qcom
|
||||
|
||||
# Crypto
|
||||
TARGET_HW_DISK_ENCRYPTION := true
|
||||
TW_INCLUDE_CRYPTO := true
|
||||
# Qualcomm support
|
||||
BOARD_USES_QCOM_HARDWARE := true
|
||||
|
||||
# TWRP
|
||||
RECOVERY_SDCARD_ON_DATA := true
|
||||
TARGET_RECOVERY_FSTAB := device/motorola/potter/twrp.fstab
|
||||
TARGET_RECOVERY_PIXEL_FORMAT := RGB_565
|
||||
TARGET_RECOVERY_QCOM_RTC_FIX := true
|
||||
# Radio
|
||||
BOARD_PROVIDES_LIBRIL := true
|
||||
BOARD_PROVIDES_RILD := true
|
||||
|
||||
# Recovery
|
||||
BOARD_HAS_NO_SELECT_BUTTON := true
|
||||
TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/rootdir/etc/fstab.qcom
|
||||
TARGET_USERIMAGES_USE_EXT4 := true
|
||||
TARGET_USERIMAGES_USE_F2FS := true
|
||||
TW_NEW_ION_HEAP := true
|
||||
TW_THEME := portrait_hdpi
|
||||
TW_SCREEN_BLANK_ON_BOOT := true
|
||||
|
||||
# SELinux
|
||||
include device/qcom/sepolicy/sepolicy.mk
|
||||
BOARD_SEPOLICY_DIRS += $(DEVICE_PATH)/sepolicy
|
||||
|
||||
# Wifi
|
||||
BOARD_HAS_QCOM_WLAN := true
|
||||
BOARD_WLAN_DEVICE := qcwcn
|
||||
BOARD_HOSTAPD_DRIVER := NL80211
|
||||
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_qcwcn
|
||||
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
|
||||
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_qcwcn
|
||||
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/wlan.ko"
|
||||
WIFI_DRIVER_MODULE_NAME := "wlan"
|
||||
WPA_SUPPLICANT_VERSION := VER_0_8_X
|
||||
37
android_filesystem_config.h
Normal file
37
android_filesystem_config.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
# Copyright (c) 2016, The Linux Foundation. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of The Linux Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <private/android_filesystem_config.h>
|
||||
|
||||
#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS
|
||||
const struct fs_path_config android_device_files[] = {
|
||||
// { 00755, AID_UID, AID_GID, (1ULL << CAPABILITY), "PATH_TO_BINARY" },
|
||||
{ 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/imsdatadaemon" },
|
||||
{ 00755, AID_SYSTEM, AID_RADIO, (1ULL << CAP_NET_BIND_SERVICE), "system/bin/ims_rtp_daemon" },
|
||||
};
|
||||
286
audio/audio_effects.conf
Normal file
286
audio/audio_effects.conf
Normal file
@@ -0,0 +1,286 @@
|
||||
# List of effect libraries to load. Each library element must contain a "path" element
|
||||
# giving the full path of the library .so file.
|
||||
# libraries {
|
||||
# <lib name> {
|
||||
# path <lib path>
|
||||
# }
|
||||
# }
|
||||
libraries {
|
||||
bundle {
|
||||
path /system/lib/soundfx/libbundlewrapper.so
|
||||
}
|
||||
reverb {
|
||||
path /system/lib/soundfx/libreverbwrapper.so
|
||||
}
|
||||
visualizer_sw {
|
||||
path /system/lib/soundfx/libvisualizer.so
|
||||
}
|
||||
visualizer_hw {
|
||||
path /system/lib/soundfx/libqcomvisualizer.so
|
||||
}
|
||||
downmix {
|
||||
path /system/lib/soundfx/libdownmix.so
|
||||
}
|
||||
loudness_enhancer {
|
||||
path /system/lib/soundfx/libldnhncr.so
|
||||
}
|
||||
proxy {
|
||||
path /system/lib/soundfx/libeffectproxy.so
|
||||
}
|
||||
offload_bundle {
|
||||
path /system/lib/soundfx/libqcompostprocbundle.so
|
||||
}
|
||||
audio_pre_processing {
|
||||
path /system/lib/soundfx/libqcomvoiceprocessing.so
|
||||
}
|
||||
}
|
||||
|
||||
# Default pre-processing library. Add to audio_effect.conf "libraries" section if
|
||||
# audio HAL implements support for default software audio pre-processing effects
|
||||
#
|
||||
# pre_processing {
|
||||
# path /system/lib/soundfx/libaudiopreprocessing.so
|
||||
# }
|
||||
|
||||
# list of effects to load. Each effect element must contain a "library" and a "uuid" element.
|
||||
# The value of the "library" element must correspond to the name of one library element in the
|
||||
# "libraries" element.
|
||||
# The name of the effect element is indicative, only the value of the "uuid" element
|
||||
# designates the effect.
|
||||
# The uuid is the implementation specific UUID as specified by the effect vendor. This is not the
|
||||
# generic effect type UUID.
|
||||
# effects {
|
||||
# <fx name> {
|
||||
# library <lib name>
|
||||
# uuid <effect uuid>
|
||||
# }
|
||||
# ...
|
||||
# }
|
||||
|
||||
effects {
|
||||
|
||||
# additions for the proxy implementation
|
||||
# Proxy implementation
|
||||
#effectname {
|
||||
#library proxy
|
||||
#uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
|
||||
# SW implemetation of the effect. Added as a node under the proxy to
|
||||
# indicate this as a sub effect.
|
||||
#libsw {
|
||||
#library libSW
|
||||
#uuid yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
|
||||
#} End of SW effect
|
||||
|
||||
# HW implementation of the effect. Added as a node under the proxy to
|
||||
# indicate this as a sub effect.
|
||||
#libhw {
|
||||
#library libHW
|
||||
#uuid zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
|
||||
#}End of HW effect
|
||||
#} End of effect proxy
|
||||
|
||||
bassboost {
|
||||
library proxy
|
||||
uuid 14804144-a5ee-4d24-aa88-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library bundle
|
||||
uuid 8631f300-72e2-11df-b57e-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid 2c4a8c24-1581-487f-94f6-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
virtualizer {
|
||||
library proxy
|
||||
uuid d3467faa-acc7-4d34-acaf-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library bundle
|
||||
uuid 1d4033c0-8557-11df-9f2d-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid 509a4498-561a-4bea-b3b1-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
equalizer {
|
||||
library proxy
|
||||
uuid c8e70ecd-48ca-456e-8a4f-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library bundle
|
||||
uuid ce772f20-847d-11df-bb17-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid a0dac280-401c-11e3-9379-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
volume {
|
||||
library bundle
|
||||
uuid 119341a0-8469-11df-81f9-0002a5d5c51b
|
||||
}
|
||||
reverb_env_aux {
|
||||
library proxy
|
||||
uuid 48404ac9-d202-4ccc-bf84-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library reverb
|
||||
uuid 4a387fc0-8ab3-11df-8bad-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid 79a18026-18fd-4185-8233-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
reverb_env_ins {
|
||||
library proxy
|
||||
uuid b707403a-a1c1-4291-9573-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library reverb
|
||||
uuid c7a511a0-a3bb-11df-860e-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid eb64ea04-973b-43d2-8f5e-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
reverb_pre_aux {
|
||||
library proxy
|
||||
uuid 1b78f587-6d1c-422e-8b84-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library reverb
|
||||
uuid f29a1400-a3bb-11df-8ddc-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid 6987be09-b142-4b41-9056-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
reverb_pre_ins {
|
||||
library proxy
|
||||
uuid f3e178d2-ebcb-408e-8357-0002a5d5c51b
|
||||
|
||||
libsw {
|
||||
library reverb
|
||||
uuid 172cdf00-a3bc-11df-a72f-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library offload_bundle
|
||||
uuid aa2bebf6-47cf-4613-9bca-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
visualizer {
|
||||
library proxy
|
||||
uuid 1d0a1a53-7d5d-48f2-8e71-27fbd10d842c
|
||||
|
||||
libsw {
|
||||
library visualizer_sw
|
||||
uuid d069d9e0-8329-11df-9168-0002a5d5c51b
|
||||
}
|
||||
|
||||
libhw {
|
||||
library visualizer_hw
|
||||
uuid 7a8044a0-1a71-11e3-a184-0002a5d5c51b
|
||||
}
|
||||
}
|
||||
downmix {
|
||||
library downmix
|
||||
uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f
|
||||
}
|
||||
hw_acc {
|
||||
library offload_bundle
|
||||
uuid 7d1580bd-297f-4683-9239-e475b6d1d69f
|
||||
}
|
||||
loudness_enhancer {
|
||||
library loudness_enhancer
|
||||
uuid fa415329-2034-4bea-b5dc-5b381c8d1e2c
|
||||
}
|
||||
aec {
|
||||
library audio_pre_processing
|
||||
uuid 0f8d0d2a-59e5-45fe-b6e4-248c8a799109
|
||||
}
|
||||
ns {
|
||||
library audio_pre_processing
|
||||
uuid 1d97bb0b-9e2f-4403-9ae3-58c2554306f8
|
||||
}
|
||||
}
|
||||
|
||||
# Default pre-processing effects. Add to audio_effect.conf "effects" section if
|
||||
# audio HAL implements support for them.
|
||||
#
|
||||
# agc {
|
||||
# library pre_processing
|
||||
# uuid aa8130e0-66fc-11e0-bad0-0002a5d5c51b
|
||||
# }
|
||||
# aec {
|
||||
# library pre_processing
|
||||
# uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b
|
||||
# }
|
||||
# ns {
|
||||
# library pre_processing
|
||||
# uuid c06c8400-8e06-11e0-9cb6-0002a5d5c51b
|
||||
# }
|
||||
|
||||
# Audio preprocessor configurations.
|
||||
# The pre processor configuration consists in a list of elements each describing
|
||||
# pre processor settings for a given input source. Valid input source names are:
|
||||
# "mic", "camcorder", "voice_recognition", "voice_communication"
|
||||
# Each input source element contains a list of effects elements. The name of the effect
|
||||
# element must be the name of one of the effects in the "effects" list of the file.
|
||||
# Each effect element may optionally contain a list of parameters and their
|
||||
# default value to apply when the pre processor effect is created.
|
||||
# A parameter is defined by a "param" element and a "value" element. Each of these elements
|
||||
# consists in one or more elements specifying a type followed by a value.
|
||||
# The types defined are: "int", "short", "float", "bool" and "string"
|
||||
# When both "param" and "value" are a single int, a simple form is allowed where just
|
||||
# the param and value pair is present in the parameter description
|
||||
# pre_processing {
|
||||
# <input source name> {
|
||||
# <fx name> {
|
||||
# <param 1 name> {
|
||||
# param {
|
||||
# int|short|float|bool|string <value>
|
||||
# [ int|short|float|bool|string <value> ]
|
||||
# ...
|
||||
# }
|
||||
# value {
|
||||
# int|short|float|bool|string <value>
|
||||
# [ int|short|float|bool|string <value> ]
|
||||
# ...
|
||||
# }
|
||||
# }
|
||||
# <param 2 name > {<param> <value>}
|
||||
# ...
|
||||
# }
|
||||
# ...
|
||||
# }
|
||||
# ...
|
||||
# }
|
||||
|
||||
# Added aec, ns effects for voice_commuincation, which are supported by the board
|
||||
|
||||
pre_processing {
|
||||
voice_communication {
|
||||
aec {
|
||||
}
|
||||
ns {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# TODO: add default audio pre processor configurations after debug and tuning phase
|
||||
#
|
||||
56
audio/audio_output_policy.conf
Normal file
56
audio/audio_output_policy.conf
Normal file
@@ -0,0 +1,56 @@
|
||||
# List of profiles for the output device session where stream is routed.
|
||||
# A stream opened with the inputs attributes which match the "flags" and
|
||||
# "formats" as specified in the profile is routed to a device at
|
||||
# sample rate specified under "sampling_rates" and bit width under
|
||||
# "bit_width" and the topology extracted from the acdb data against
|
||||
# the "app_type".
|
||||
#
|
||||
# the flags and formats are specified using the strings corresponding to
|
||||
# enums in audio.h and audio_policy.h. They are concatenated with "|"
|
||||
# without space or "\n".
|
||||
# the flags and formats should match the ones in "audio_policy.conf"
|
||||
|
||||
outputs {
|
||||
default {
|
||||
flags AUDIO_OUTPUT_FLAG_PRIMARY
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
sampling_rates 48000
|
||||
bit_width 16
|
||||
app_type 69937
|
||||
}
|
||||
deep_buffer {
|
||||
flags AUDIO_OUTPUT_FLAG_DEEP_BUFFER
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
sampling_rates 48000
|
||||
bit_width 16
|
||||
app_type 69936
|
||||
}
|
||||
direct {
|
||||
flags AUDIO_OUTPUT_FLAG_DIRECT
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
sampling_rates 48000
|
||||
bit_width 16
|
||||
app_type 69936
|
||||
}
|
||||
direct_pcm {
|
||||
flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_DIRECT_PCM
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
sampling_rates 44100|48000|96000|192000
|
||||
bit_width 16
|
||||
app_type 69936
|
||||
}
|
||||
compress_offload_16 {
|
||||
flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING
|
||||
formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_AC3|AUDIO_FORMAT_E_AC3|AUDIO_FORMAT_PCM_16_BIT_OFFLOAD|AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_AAC_LC|AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2|AUDIO_FORMAT_WMA|AUDIO_FORMAT_WMA_PRO|AUDIO_FORMAT_VORBIS|AUDIO_FORMAT_AAC_ADTS_LC|AUDIO_FORMAT_AAC_ADTS_HE_V1|AUDIO_FORMAT_AAC_ADTS_HE_V2
|
||||
sampling_rates 44100|48000
|
||||
bit_width 16
|
||||
app_type 69936
|
||||
}
|
||||
compress_offload_24 {
|
||||
flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING
|
||||
formats AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_VORBIS
|
||||
sampling_rates 44100|48000|96000|192000
|
||||
bit_width 24
|
||||
app_type 69940
|
||||
}
|
||||
}
|
||||
97
audio/audio_platform_info_extcodec.xml
Normal file
97
audio/audio_platform_info_extcodec.xml
Normal file
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<audio_platform_info>
|
||||
|
||||
<acdb_ids>
|
||||
<!-- Output devices -->
|
||||
<device name="SND_DEVICE_OUT_VOICE_HANDSET" acdb_id="7" />
|
||||
<device name="SND_DEVICE_OUT_VOICE_HANDSET_TMUS" acdb_id="7" />
|
||||
<device name="SND_DEVICE_OUT_HEADPHONES" acdb_id="9" />
|
||||
<device name="SND_DEVICE_OUT_MOD_HEADPHONES" acdb_id="9" />
|
||||
<device name="SND_DEVICE_OUT_MOD_SPKR_MOD_HEADPHONES" acdb_id="9" />
|
||||
<device name="SND_DEVICE_OUT_INT_SPKR_MOD_HEADPHONES" acdb_id="9" />
|
||||
<device name="SND_DEVICE_OUT_MOD_SPKR_INT_HEADPHONES" acdb_id="9" />
|
||||
<device name="SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES" acdb_id="9" />
|
||||
<device name="SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES" acdb_id="9" />
|
||||
<device name="SND_DEVICE_OUT_SPEAKER" acdb_id="14" />
|
||||
<device name="SND_DEVICE_OUT_SPEAKER_PROTECTED" acdb_id="14" />
|
||||
<device name="SND_DEVICE_OUT_SPEAKER_REVERSE" acdb_id="14" />
|
||||
<device name="SND_DEVICE_OUT_SPEAKER_SAFE" acdb_id="14" />
|
||||
<device name="SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED" acdb_id="15" />
|
||||
<device name="SND_DEVICE_OUT_INT_SPKR_MOD_HDMI" acdb_id="18" />
|
||||
<device name="SND_DEVICE_OUT_MOD_HDMI" acdb_id="18" />
|
||||
<device name="SND_DEVICE_OUT_MOD_SPKR_INT_HDMI" acdb_id="18" />
|
||||
<device name="SND_DEVICE_OUT_MOD_SPKR_MOD_HDMI" acdb_id="18" />
|
||||
<device name="SND_DEVICE_OUT_SPEAKER_AND_HDMI" acdb_id="18" />
|
||||
<device name="SND_DEVICE_OUT_INT_SPKR_MOD_LINE" acdb_id="77" />
|
||||
<device name="SND_DEVICE_OUT_MOD_SPKR_MOD_LINE" acdb_id="77" />
|
||||
<device name="SND_DEVICE_OUT_MOD_VOICE_LINE" acdb_id="78" />
|
||||
<device name="SND_DEVICE_OUT_MOD_VOICE_LINE_INT_MIC" acdb_id="78" />
|
||||
<device name="SND_DEVICE_OUT_VOICE_LINE" acdb_id="78" />
|
||||
<device name="SND_DEVICE_OUT_VOLTE_NB_ANC_HANDSET" acdb_id="200" />
|
||||
<device name="SND_DEVICE_OUT_VOLTE_NB_HANDSET_TMUS" acdb_id="200" />
|
||||
<device name="SND_DEVICE_OUT_MOD_VOICE_SPEAKER_EXTREF" acdb_id="214" />
|
||||
<device name="SND_DEVICE_OUT_MOD_VOICE_SPEAKER_MODEC" acdb_id="214" />
|
||||
<device name="SND_DEVICE_OUT_MOD_SPEAKER" acdb_id="215" />
|
||||
<device name="SND_DEVICE_OUT_MOD_VOICE_SPEAKER_INTREF" acdb_id="216" />
|
||||
<device name="SND_DEVICE_OUT_MOD_VOLTE_NB_SPEAKER_EXTREF" acdb_id="217" />
|
||||
<device name="SND_DEVICE_OUT_MOD_VOLTE_NB_SPEAKER_MODEC" acdb_id="217" />
|
||||
<device name="SND_DEVICE_OUT_MOD_VOLTE_NB_SPEAKER_INTREF" acdb_id="218" />
|
||||
<device name="SND_DEVICE_OUT_VOLTE_NB_TX" acdb_id="245" />
|
||||
|
||||
<!-- Input devices -->
|
||||
<device name="SND_DEVICE_IN_CAPTURE_VI_FEEDBACK" acdb_id="0" />
|
||||
<device name="SND_DEVICE_IN_HANDSET_MIC_AEC" acdb_id="4" />
|
||||
<device name="SND_DEVICE_IN_HANDSET_MIC_AEC_NS" acdb_id="4" />
|
||||
<device name="SND_DEVICE_IN_HANDSET_MIC_NS" acdb_id="4" />
|
||||
<device name="SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC" acdb_id="4" />
|
||||
<device name="SND_DEVICE_IN_SPEAKER_MIC_AEC" acdb_id="11" />
|
||||
<device name="SND_DEVICE_IN_SPEAKER_MIC_AEC_NS" acdb_id="11" />
|
||||
<device name="SND_DEVICE_IN_SPEAKER_MIC_NS" acdb_id="11" />
|
||||
<device name="SND_DEVICE_IN_UNPROCESSED_MIC" acdb_id="11" />
|
||||
<device name="SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE" acdb_id="35" />
|
||||
<device name="SND_DEVICE_IN_VOICE_DMIC_TMUS" acdb_id="41" />
|
||||
<device name="SND_DEVICE_IN_MOD_VOICE_SPEAKER_INT_MIC" acdb_id="43" />
|
||||
<device name="SND_DEVICE_IN_UNPROCESSED_STEREO_MIC" acdb_id="43" />
|
||||
<device name="SND_DEVICE_IN_HEADSET_MIC_AEC" acdb_id="47" />
|
||||
<device name="SND_DEVICE_IN_MOD_HEADSET_MIC_AEC" acdb_id="47" />
|
||||
<device name="SND_DEVICE_IN_MOD_CAMCORDER" acdb_id="50" />
|
||||
<device name="SND_DEVICE_IN_VOICE_REC_MIC_AEC" acdb_id="62" />
|
||||
<device name="SND_DEVICE_IN_VOICE_REC_MIC_NS" acdb_id="62" />
|
||||
<device name="SND_DEVICE_IN_HANDSET_DMIC_AEC" acdb_id="111" />
|
||||
<device name="SND_DEVICE_IN_HANDSET_DMIC_NS" acdb_id="111" />
|
||||
<device name="SND_DEVICE_IN_SPEAKER_DMIC_AEC" acdb_id="117" />
|
||||
<device name="SND_DEVICE_IN_SPEAKER_DMIC_NS" acdb_id="117" />
|
||||
<device name="SND_DEVICE_IN_QUAD_MIC" acdb_id="125" />
|
||||
<device name="SND_DEVICE_IN_THREE_MIC" acdb_id="125" />
|
||||
<device name="SND_DEVICE_IN_MOD_VOICE_MIC" acdb_id="211" />
|
||||
<device name="SND_DEVICE_IN_MOD_SPEAKER_INT_MIC_AEC_EXTREF" acdb_id="224" />
|
||||
<device name="SND_DEVICE_IN_MOD_SPEAKER_INT_MIC_AEC_NS_EXTREF" acdb_id="224" />
|
||||
<device name="SND_DEVICE_IN_MOD_SPEAKER_INT_MIC_AEC_INTREF" acdb_id="225" />
|
||||
<device name="SND_DEVICE_IN_MOD_SPEAKER_INT_MIC_AEC_NS_INTREF" acdb_id="225" />
|
||||
<device name="SND_DEVICE_IN_MOD_MIC_AEC" acdb_id="226" />
|
||||
<device name="SND_DEVICE_IN_MOD_MIC_AEC_NS" acdb_id="226" />
|
||||
<device name="SND_DEVICE_IN_MOD_MIC_NS" acdb_id="226" />
|
||||
</acdb_ids>
|
||||
|
||||
<pcm_ids>
|
||||
<usecase name="USECASE_AUDIO_PLAYBACK_LOW_LATENCY" type="out" id="12" />
|
||||
<usecase name="USECASE_AUDIO_RECORD_LOW_LATENCY" type="in" id="12" />
|
||||
<usecase name="USECASE_VOICEMMODE1_CALL" type="in" id="35" />
|
||||
<usecase name="USECASE_VOICEMMODE1_CALL" type="out" id="35" />
|
||||
<usecase name="USECASE_VOICEMMODE2_CALL" type="in" id="36" />
|
||||
<usecase name="USECASE_VOICEMMODE2_CALL" type="out" id="36" />
|
||||
<usecase name="USECASE_AUDIO_DSM_FEEDBACK" type="in" id="61" />
|
||||
<usecase name="USECASE_MOTVR_COMMAND" type="in" id="40" />
|
||||
<usecase name="USECASE_MOTVR_TRACE" type="in" id="41" />
|
||||
</pcm_ids>
|
||||
|
||||
<backend_names>
|
||||
<device name="SND_DEVICE_OUT_HEADPHONES" backend="headphones" />
|
||||
<device name="SND_DEVICE_OUT_LINE" backend="headphones" />
|
||||
</backend_names>
|
||||
|
||||
<config_params>
|
||||
<param key="input_mic_max_count" value="3"/>
|
||||
</config_params>
|
||||
|
||||
</audio_platform_info>
|
||||
191
audio/audio_policy_configuration.xml
Normal file
191
audio/audio_policy_configuration.xml
Normal file
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!-- Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<audioPolicyConfiguration version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<globalConfiguration speaker_drc_enabled="true"/>
|
||||
|
||||
<modules>
|
||||
<module name="primary" halVersion="2.0">
|
||||
<attachedDevices>
|
||||
<item>Speaker</item>
|
||||
<item>Earpiece</item>
|
||||
<item>Telephony Tx</item>
|
||||
<item>Built-In Mic</item>
|
||||
<item>Built-In Back Mic</item>
|
||||
<item>Telephony Rx</item>
|
||||
</attachedDevices>
|
||||
<defaultOutputDevice>Speaker</defaultOutputDevice>
|
||||
<mixPorts>
|
||||
<mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY|AUDIO_OUTPUT_FLAG_FAST">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="44100,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
|
||||
</mixPort>
|
||||
<mixPort name="deep_buffer" role="source"
|
||||
flags="AUDIO_OUTPUT_FLAG_DEEP_BUFFER">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
|
||||
channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
|
||||
</mixPort>
|
||||
<mixPort name="compressed_offload" role="source"
|
||||
flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING">
|
||||
<profile name="" format="AUDIO_FORMAT_MP3"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
|
||||
channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
|
||||
<profile name="" format="AUDIO_FORMAT_AAC_LC"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000"
|
||||
channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
|
||||
<profile name="" format="AUDIO_FORMAT_AAC_HE_V1"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000"
|
||||
channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
|
||||
<profile name="" format="AUDIO_FORMAT_AAC_HE_V2"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000"
|
||||
channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
|
||||
<profile name="" format="AUDIO_FORMAT_FLAC"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
|
||||
channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
|
||||
</mixPort>
|
||||
<mixPort name="voice_tx" role="source">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
|
||||
</mixPort>
|
||||
<mixPort name="primary input" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
|
||||
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3"/>
|
||||
</mixPort>
|
||||
<mixPort name="fast input" role="sink" flags="AUDIO_INPUT_FLAG_FAST">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
|
||||
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3"/>
|
||||
</mixPort>
|
||||
<mixPort name="voice_rx" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_MONO"/>
|
||||
</mixPort>
|
||||
</mixPorts>
|
||||
<devicePorts>
|
||||
<devicePort tagName="Earpiece" type="AUDIO_DEVICE_OUT_EARPIECE" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="Speaker" type="AUDIO_DEVICE_OUT_SPEAKER" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="Wired Headset" type="AUDIO_DEVICE_OUT_WIRED_HEADSET" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="Wired Headphones" type="AUDIO_DEVICE_OUT_WIRED_HEADPHONE" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="Line" type="AUDIO_DEVICE_OUT_LINE" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="BT SCO" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="BT SCO Car Kit" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="BT SCO All" type="AUDIO_DEVICE_OUT_ALL_SCO" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="Telephony Tx" type="AUDIO_DEVICE_OUT_TELEPHONY_TX" role="sink">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/>
|
||||
</devicePort>
|
||||
|
||||
<devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
|
||||
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="Built-In Back Mic" type="AUDIO_DEVICE_IN_BACK_MIC" role="source">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
|
||||
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="Wired Headset Mic" type="AUDIO_DEVICE_IN_WIRED_HEADSET" role="source">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
|
||||
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="BT SCO Headset Mic" type="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET" role="source">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
|
||||
</devicePort>
|
||||
<devicePort tagName="Telephony Rx" type="AUDIO_DEVICE_IN_TELEPHONY_RX" role="source">
|
||||
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
|
||||
samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
|
||||
</devicePort>
|
||||
</devicePorts>
|
||||
<routes>
|
||||
<route type="mix" sink="Earpiece"
|
||||
sources="primary output,deep_buffer"/>
|
||||
<route type="mix" sink="Speaker"
|
||||
sources="primary output,deep_buffer,compressed_offload"/>
|
||||
<route type="mix" sink="Wired Headset"
|
||||
sources="primary output,deep_buffer,compressed_offload"/>
|
||||
<route type="mix" sink="Wired Headphones"
|
||||
sources="primary output,deep_buffer,compressed_offload"/>
|
||||
<route type="mix" sink="Line"
|
||||
sources="primary output,deep_buffer,compressed_offload"/>
|
||||
<route type="mix" sink="BT SCO"
|
||||
sources="primary output,deep_buffer"/>
|
||||
<route type="mix" sink="BT SCO Headset"
|
||||
sources="primary output,deep_buffer"/>
|
||||
<route type="mix" sink="BT SCO Car Kit"
|
||||
sources="primary output,deep_buffer"/>
|
||||
<route type="mix" sink="BT SCO All"
|
||||
sources="primary output,deep_buffer"/>
|
||||
<route type="mix" sink="Telephony Tx"
|
||||
sources="voice_tx"/>
|
||||
<route type="mix" sink="primary input"
|
||||
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>
|
||||
<route type="mix" sink="fast input"
|
||||
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>
|
||||
<route type="mix" sink="voice_rx"
|
||||
sources="Telephony Rx"/>
|
||||
</routes>
|
||||
|
||||
</module>
|
||||
|
||||
<!-- A2dp Audio HAL -->
|
||||
<xi:include href="a2dp_audio_policy_configuration.xml"/>
|
||||
|
||||
<!-- Usb Audio HAL -->
|
||||
<xi:include href="usb_audio_policy_configuration.xml"/>
|
||||
|
||||
<!-- Remote Submix Audio HAL -->
|
||||
<xi:include href="r_submix_audio_policy_configuration.xml"/>
|
||||
|
||||
</modules>
|
||||
|
||||
<!-- Volume section -->
|
||||
<xi:include href="audio_policy_volumes.xml"/>
|
||||
<xi:include href="default_volume_tables.xml"/>
|
||||
|
||||
</audioPolicyConfiguration>
|
||||
1198
audio/mixer_paths_wcd9306.xml
Normal file
1198
audio/mixer_paths_wcd9306.xml
Normal file
File diff suppressed because it is too large
Load Diff
27
bluetooth/bdroid_buildcfg.h
Normal file
27
bluetooth/bdroid_buildcfg.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BDROID_BUILDCFG_H
|
||||
#define _BDROID_BUILDCFG_H
|
||||
|
||||
#include <cutils/properties.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BTM_DEF_LOCAL_NAME "Moto Z Play"
|
||||
#define BTA_DISABLE_DELAY 1000 /* in milliseconds */
|
||||
#define BLUETOOTH_QTI_SW TRUE
|
||||
#define BLE_VND_INCLUDED TRUE
|
||||
#endif
|
||||
16
camera/Android.mk
Normal file
16
camera/Android.mk
Normal file
@@ -0,0 +1,16 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_C_INCLUDES := system/media/camera/include
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
CameraWrapper.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libhardware liblog libcamera_client libutils libcutils
|
||||
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
|
||||
LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM)
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
609
camera/CameraWrapper.cpp
Normal file
609
camera/CameraWrapper.cpp
Normal file
@@ -0,0 +1,609 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file CameraWrapper.cpp
|
||||
*
|
||||
* This file wraps a vendor camera module.
|
||||
*
|
||||
*/
|
||||
|
||||
//#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "CameraWrapper"
|
||||
#include <cutils/log.h>
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#include <utils/threads.h>
|
||||
#include <utils/String8.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/camera.h>
|
||||
#include <camera/Camera.h>
|
||||
#include <camera/CameraParameters.h>
|
||||
|
||||
#define BACK_CAMERA 0
|
||||
#define FRONT_CAMERA 1
|
||||
|
||||
#define OPEN_RETRIES 10
|
||||
#define OPEN_RETRY_MSEC 40
|
||||
|
||||
using namespace android;
|
||||
|
||||
static Mutex gCameraWrapperLock;
|
||||
static camera_module_t *gVendorModule = 0;
|
||||
|
||||
static char **fixed_set_params = NULL;
|
||||
|
||||
static int camera_device_open(const hw_module_t *module, const char *name,
|
||||
hw_device_t **device);
|
||||
static int camera_get_number_of_cameras(void);
|
||||
static int camera_get_camera_info(int camera_id, struct camera_info *info);
|
||||
|
||||
static struct hw_module_methods_t camera_module_methods = {
|
||||
.open = camera_device_open
|
||||
};
|
||||
|
||||
camera_module_t HAL_MODULE_INFO_SYM = {
|
||||
.common = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.version_major = 1,
|
||||
.version_minor = 0,
|
||||
.id = CAMERA_HARDWARE_MODULE_ID,
|
||||
.name = "Moto Z Play Camera Wrapper",
|
||||
.author = "The LineageOS Project",
|
||||
.methods = &camera_module_methods,
|
||||
.dso = NULL, /* remove compilation warnings */
|
||||
.reserved = {0}, /* remove compilation warnings */
|
||||
},
|
||||
.get_number_of_cameras = camera_get_number_of_cameras,
|
||||
.get_camera_info = camera_get_camera_info,
|
||||
.set_callbacks = NULL, /* remove compilation warnings */
|
||||
.get_vendor_tag_ops = NULL, /* remove compilation warnings */
|
||||
.open_legacy = NULL, /* remove compilation warnings */
|
||||
.set_torch_mode = NULL, /* remove compilation warnings */
|
||||
.init = NULL, /* remove compilation warnings */
|
||||
.reserved = {0}, /* remove compilation warnings */
|
||||
};
|
||||
|
||||
|
||||
typedef struct wrapper_camera_device {
|
||||
camera_device_t base;
|
||||
int id;
|
||||
camera_device_t *vendor;
|
||||
} wrapper_camera_device_t;
|
||||
|
||||
#define VENDOR_CALL(device, func, ...) ({ \
|
||||
wrapper_camera_device_t *__wrapper_dev = (wrapper_camera_device_t*) device; \
|
||||
__wrapper_dev->vendor->ops->func(__wrapper_dev->vendor, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define CAMERA_ID(device) (((wrapper_camera_device_t *)(device))->id)
|
||||
|
||||
static int check_vendor_module()
|
||||
{
|
||||
int rv = 0;
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
if (gVendorModule)
|
||||
return 0;
|
||||
|
||||
rv = hw_get_module_by_class("camera", "vendor",
|
||||
(const hw_module_t**)&gVendorModule);
|
||||
if (rv)
|
||||
ALOGE("failed to open vendor camera module");
|
||||
return rv;
|
||||
}
|
||||
|
||||
static char *camera_fixup_getparams(int id, const char *settings)
|
||||
{
|
||||
CameraParameters params;
|
||||
params.unflatten(String8(settings));
|
||||
|
||||
#if !LOG_NDEBUG
|
||||
ALOGV("%s: original parameters:", __FUNCTION__);
|
||||
params.dump();
|
||||
#endif
|
||||
|
||||
params.set("longshot-supported", "false");
|
||||
params.set("video-stabilization-supported", "false");
|
||||
|
||||
#if !LOG_NDEBUG
|
||||
ALOGV("%s: fixed parameters:", __FUNCTION__);
|
||||
params.dump();
|
||||
#endif
|
||||
|
||||
String8 strParams = params.flatten();
|
||||
char *ret = strdup(strParams.string());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *camera_fixup_setparams(int id, const char *settings)
|
||||
{
|
||||
CameraParameters params;
|
||||
params.unflatten(String8(settings));
|
||||
|
||||
#if !LOG_NDEBUG
|
||||
ALOGV("%s: original parameters:", __FUNCTION__);
|
||||
params.dump();
|
||||
#endif
|
||||
|
||||
#if !LOG_NDEBUG
|
||||
ALOGV("%s: fixed parameters:", __FUNCTION__);
|
||||
params.dump();
|
||||
#endif
|
||||
|
||||
String8 strParams = params.flatten();
|
||||
if (fixed_set_params[id])
|
||||
free(fixed_set_params[id]);
|
||||
fixed_set_params[id] = strdup(strParams.string());
|
||||
char *ret = fixed_set_params[id];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* implementation of camera_device_ops functions
|
||||
*******************************************************************/
|
||||
|
||||
static int camera_set_preview_window(struct camera_device *device,
|
||||
struct preview_stream_ops *window)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, set_preview_window, window);
|
||||
}
|
||||
|
||||
static void camera_set_callbacks(struct camera_device *device,
|
||||
camera_notify_callback notify_cb,
|
||||
camera_data_callback data_cb,
|
||||
camera_data_timestamp_callback data_cb_timestamp,
|
||||
camera_request_memory get_memory,
|
||||
void *user)
|
||||
{
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp,
|
||||
get_memory, user);
|
||||
}
|
||||
|
||||
static void camera_enable_msg_type(struct camera_device *device,
|
||||
int32_t msg_type)
|
||||
{
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
VENDOR_CALL(device, enable_msg_type, msg_type);
|
||||
}
|
||||
|
||||
static void camera_disable_msg_type(struct camera_device *device,
|
||||
int32_t msg_type)
|
||||
{
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
VENDOR_CALL(device, disable_msg_type, msg_type);
|
||||
}
|
||||
|
||||
static int camera_msg_type_enabled(struct camera_device *device,
|
||||
int32_t msg_type)
|
||||
{
|
||||
if (!device)
|
||||
return 0;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, msg_type_enabled, msg_type);
|
||||
}
|
||||
|
||||
static int camera_start_preview(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, start_preview);
|
||||
}
|
||||
|
||||
static void camera_stop_preview(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
VENDOR_CALL(device, stop_preview);
|
||||
}
|
||||
|
||||
static int camera_preview_enabled(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, preview_enabled);
|
||||
}
|
||||
|
||||
static int camera_store_meta_data_in_buffers(struct camera_device *device,
|
||||
int enable)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, store_meta_data_in_buffers, enable);
|
||||
}
|
||||
|
||||
static int camera_start_recording(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, start_recording);
|
||||
}
|
||||
|
||||
static void camera_stop_recording(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
VENDOR_CALL(device, stop_recording);
|
||||
}
|
||||
|
||||
static int camera_recording_enabled(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, recording_enabled);
|
||||
}
|
||||
|
||||
static void camera_release_recording_frame(struct camera_device *device,
|
||||
const void *opaque)
|
||||
{
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
VENDOR_CALL(device, release_recording_frame, opaque);
|
||||
}
|
||||
|
||||
static int camera_auto_focus(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, auto_focus);
|
||||
}
|
||||
|
||||
static int camera_cancel_auto_focus(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, cancel_auto_focus);
|
||||
}
|
||||
|
||||
static int camera_take_picture(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, take_picture);
|
||||
}
|
||||
|
||||
static int camera_cancel_picture(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, cancel_picture);
|
||||
}
|
||||
|
||||
static int camera_set_parameters(struct camera_device *device,
|
||||
const char *params)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
char *tmp = NULL;
|
||||
tmp = camera_fixup_setparams(CAMERA_ID(device), params);
|
||||
|
||||
int ret = VENDOR_CALL(device, set_parameters, tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *camera_get_parameters(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return NULL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
char *params = VENDOR_CALL(device, get_parameters);
|
||||
|
||||
char *tmp = camera_fixup_getparams(CAMERA_ID(device), params);
|
||||
VENDOR_CALL(device, put_parameters, params);
|
||||
params = tmp;
|
||||
return params;
|
||||
}
|
||||
|
||||
static void camera_put_parameters(struct camera_device *device, char *params)
|
||||
{
|
||||
if (params)
|
||||
free(params);
|
||||
}
|
||||
|
||||
static int camera_send_command(struct camera_device *device,
|
||||
int32_t cmd, int32_t arg1, int32_t arg2)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, send_command, cmd, arg1, arg2);
|
||||
}
|
||||
|
||||
static void camera_release(struct camera_device *device)
|
||||
{
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
VENDOR_CALL(device, release);
|
||||
}
|
||||
|
||||
static int camera_dump(struct camera_device *device, int fd)
|
||||
{
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||
|
||||
return VENDOR_CALL(device, dump, fd);
|
||||
}
|
||||
|
||||
extern "C" void heaptracker_free_leaked_memory(void);
|
||||
|
||||
static int camera_device_close(hw_device_t *device)
|
||||
{
|
||||
int ret = 0;
|
||||
wrapper_camera_device_t *wrapper_dev = NULL;
|
||||
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
Mutex::Autolock lock(gCameraWrapperLock);
|
||||
|
||||
if (!device) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (int i = 0; i < camera_get_number_of_cameras(); i++) {
|
||||
if (fixed_set_params[i])
|
||||
free(fixed_set_params[i]);
|
||||
}
|
||||
|
||||
wrapper_dev = (wrapper_camera_device_t*) device;
|
||||
|
||||
wrapper_dev->vendor->common.close((hw_device_t*)wrapper_dev->vendor);
|
||||
if (wrapper_dev->base.ops)
|
||||
free(wrapper_dev->base.ops);
|
||||
free(wrapper_dev);
|
||||
done:
|
||||
#ifdef HEAPTRACKER
|
||||
heaptracker_free_leaked_memory();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* implementation of camera_module functions
|
||||
*******************************************************************/
|
||||
|
||||
/* open device handle to one of the cameras
|
||||
*
|
||||
* assume camera service will keep singleton of each camera
|
||||
* so this function will always only be called once per camera instance
|
||||
*/
|
||||
|
||||
static int camera_device_open(const hw_module_t *module, const char *name,
|
||||
hw_device_t **device)
|
||||
{
|
||||
int rv = 0;
|
||||
int num_cameras = 0;
|
||||
int cameraid;
|
||||
wrapper_camera_device_t *camera_device = NULL;
|
||||
camera_device_ops_t *camera_ops = NULL;
|
||||
|
||||
Mutex::Autolock lock(gCameraWrapperLock);
|
||||
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
if (name != NULL) {
|
||||
if (check_vendor_module())
|
||||
return -EINVAL;
|
||||
|
||||
cameraid = atoi(name);
|
||||
num_cameras = gVendorModule->get_number_of_cameras();
|
||||
|
||||
fixed_set_params = (char **) malloc(sizeof(char *) * num_cameras);
|
||||
if (!fixed_set_params) {
|
||||
ALOGE("parameter memory allocation fail");
|
||||
rv = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
memset(fixed_set_params, 0, sizeof(char *) * num_cameras);
|
||||
|
||||
if (cameraid > num_cameras) {
|
||||
ALOGE("camera service provided cameraid out of bounds, "
|
||||
"cameraid = %d, num supported = %d",
|
||||
cameraid, num_cameras);
|
||||
rv = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
camera_device = (wrapper_camera_device_t*)malloc(sizeof(*camera_device));
|
||||
if (!camera_device) {
|
||||
ALOGE("camera_device allocation fail");
|
||||
rv = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
memset(camera_device, 0, sizeof(*camera_device));
|
||||
camera_device->id = cameraid;
|
||||
|
||||
int retries = OPEN_RETRIES;
|
||||
bool retry;
|
||||
do {
|
||||
rv = gVendorModule->common.methods->open(
|
||||
(const hw_module_t*)gVendorModule, name,
|
||||
(hw_device_t**)&(camera_device->vendor));
|
||||
retry = --retries > 0 && rv;
|
||||
if (retry)
|
||||
usleep(OPEN_RETRY_MSEC * 1000);
|
||||
} while (retry);
|
||||
if (rv) {
|
||||
ALOGE("vendor camera open fail");
|
||||
goto fail;
|
||||
}
|
||||
ALOGV("%s: got vendor camera device 0x%08X",
|
||||
__FUNCTION__, (uintptr_t)(camera_device->vendor));
|
||||
|
||||
camera_ops = (camera_device_ops_t*)malloc(sizeof(*camera_ops));
|
||||
if (!camera_ops) {
|
||||
ALOGE("camera_ops allocation fail");
|
||||
rv = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
memset(camera_ops, 0, sizeof(*camera_ops));
|
||||
|
||||
camera_device->base.common.tag = HARDWARE_DEVICE_TAG;
|
||||
camera_device->base.common.version = CAMERA_MODULE_API_VERSION_1_0;
|
||||
camera_device->base.common.module = (hw_module_t *)(module);
|
||||
camera_device->base.common.close = camera_device_close;
|
||||
camera_device->base.ops = camera_ops;
|
||||
|
||||
camera_ops->set_preview_window = camera_set_preview_window;
|
||||
camera_ops->set_callbacks = camera_set_callbacks;
|
||||
camera_ops->enable_msg_type = camera_enable_msg_type;
|
||||
camera_ops->disable_msg_type = camera_disable_msg_type;
|
||||
camera_ops->msg_type_enabled = camera_msg_type_enabled;
|
||||
camera_ops->start_preview = camera_start_preview;
|
||||
camera_ops->stop_preview = camera_stop_preview;
|
||||
camera_ops->preview_enabled = camera_preview_enabled;
|
||||
camera_ops->store_meta_data_in_buffers = camera_store_meta_data_in_buffers;
|
||||
camera_ops->start_recording = camera_start_recording;
|
||||
camera_ops->stop_recording = camera_stop_recording;
|
||||
camera_ops->recording_enabled = camera_recording_enabled;
|
||||
camera_ops->release_recording_frame = camera_release_recording_frame;
|
||||
camera_ops->auto_focus = camera_auto_focus;
|
||||
camera_ops->cancel_auto_focus = camera_cancel_auto_focus;
|
||||
camera_ops->take_picture = camera_take_picture;
|
||||
camera_ops->cancel_picture = camera_cancel_picture;
|
||||
camera_ops->set_parameters = camera_set_parameters;
|
||||
camera_ops->get_parameters = camera_get_parameters;
|
||||
camera_ops->put_parameters = camera_put_parameters;
|
||||
camera_ops->send_command = camera_send_command;
|
||||
camera_ops->release = camera_release;
|
||||
camera_ops->dump = camera_dump;
|
||||
|
||||
*device = &camera_device->base.common;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
fail:
|
||||
if (camera_device) {
|
||||
free(camera_device);
|
||||
camera_device = NULL;
|
||||
}
|
||||
if (camera_ops) {
|
||||
free(camera_ops);
|
||||
camera_ops = NULL;
|
||||
}
|
||||
*device = NULL;
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int camera_get_number_of_cameras(void)
|
||||
{
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
if (check_vendor_module())
|
||||
return 0;
|
||||
return gVendorModule->get_number_of_cameras();
|
||||
}
|
||||
|
||||
static int camera_get_camera_info(int camera_id, struct camera_info *info)
|
||||
{
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
if (check_vendor_module())
|
||||
return 0;
|
||||
return gVendorModule->get_camera_info(camera_id, info);
|
||||
}
|
||||
41
cmactions/Android.mk
Normal file
41
cmactions/Android.mk
Normal file
@@ -0,0 +1,41 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := CMActions
|
||||
LOCAL_CERTIFICATE := platform
|
||||
LOCAL_PRIVILEGED_MODULE := true
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android-support-v14-preference \
|
||||
android-support-v7-appcompat \
|
||||
android-support-v7-preference \
|
||||
android-support-v7-recyclerview \
|
||||
org.cyanogenmod.platform.internal
|
||||
|
||||
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||
|
||||
LOCAL_RESOURCE_DIR := \
|
||||
$(LOCAL_PATH)/res \
|
||||
$(LOCAL_PATH)/../../../../packages/resources/devicesettings/res \
|
||||
frameworks/support/v14/preference/res \
|
||||
frameworks/support/v7/appcompat/res \
|
||||
frameworks/support/v7/preference/res \
|
||||
frameworks/support/v7/recyclerview/res
|
||||
|
||||
LOCAL_AAPT_FLAGS := --auto-add-overlay \
|
||||
--extra-packages android.support.v14.preference:android.support.v7.appcompat:android.support.v7.preference:android.support.v7.recyclerview
|
||||
|
||||
ifneq ($(INCREMENTAL_BUILDS),)
|
||||
LOCAL_PROGUARD_ENABLED := disabled
|
||||
LOCAL_JACK_ENABLED := incremental
|
||||
endif
|
||||
|
||||
include frameworks/base/packages/SettingsLib/common.mk
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
59
cmactions/AndroidManifest.xml
Normal file
59
cmactions/AndroidManifest.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cyanogenmod.settings.device"
|
||||
android:sharedUserId="android.uid.system"
|
||||
>
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<protected-broadcast android:name="com.android.systemui.doze.pulse" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="@string/device_settings_app_name"
|
||||
android:persistent="true">
|
||||
|
||||
<receiver android:name="com.cyanogenmod.settings.device.BootCompletedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name="ServiceWrapper" android:permission="ServiceWrapper">
|
||||
<intent-filter>
|
||||
<action android:name="ServiceWrapper"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".DozePreferenceActivity"
|
||||
android:label="@string/ambient_display_title"
|
||||
android:theme="@style/CMActions">
|
||||
<intent-filter>
|
||||
<action android:name="org.cyanogenmod.settings.device.DOZE_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".TouchscreenGesturePreferenceActivity"
|
||||
android:label="@string/screen_gestures_panel_title"
|
||||
android:theme="@style/CMActions">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.action.EXTRA_SETTINGS" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.device" />
|
||||
<meta-data
|
||||
android:name="com.android.settings.icon"
|
||||
android:resource="@drawable/ic_settings_gestures" />
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
9
cmactions/proguard.flags
Normal file
9
cmactions/proguard.flags
Normal file
@@ -0,0 +1,9 @@
|
||||
-keep class org.cyanogenmod.CMActions.* {
|
||||
*;
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keep class ** extends android.support.v14.preference.PreferenceFragment
|
||||
32
cmactions/res/drawable/ic_settings_gestures.xml
Normal file
32
cmactions/res/drawable/ic_settings_gestures.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) 2015 The CyanogenMod Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M4.7,6.9c0.7-0.7,1.4-1.4,1.7-1.2c0.5,0.2,0,1-0.3,1.5c-0.2,0.4-2.8,3.9-2.8,6.3c0,1.3,0.5,2.3,1.3,3
|
||||
c0.7,0.6,1.7,0.7,2.6,0.5c1.1-0.3,1.9-1.4,3-2.8c1.2-1.5,2.8-3.4,4-3.4c1.6,0,1.6,1,1.7,1.8c-3.7,0.6-5.3,3.7-5.3,5.4
|
||||
s1.4,3.1,3.2,3.1c1.6,0,4.3-1.3,4.6-6.1H21v-2.5h-2.4c-0.1-1.7-1.1-4.2-4-4.2c-2.2,0-4.1,1.9-4.9,2.8c-0.6,0.7-2,2.5-2.3,2.7
|
||||
c-0.2,0.3-0.7,0.8-1.1,0.8c-0.4,0-0.7-0.8-0.4-1.9c0.3-1.1,1.4-2.9,1.8-3.5C8.5,8,9.1,7.2,9.1,5.9C9.1,3.7,7.4,3,6.6,3
|
||||
C5.3,3,4.1,4,3.9,4.3C3.5,4.6,3.2,4.9,3,5.2L4.7,6.9z
|
||||
M13.9,18.6c-0.3,0-0.7-0.3-0.7-0.7c0-0.6,0.7-2.2,2.8-2.8
|
||||
C15.8,17.8,14.6,18.6,13.9,18.6z" />
|
||||
</vector>
|
||||
21
cmactions/res/values/styles.xml
Normal file
21
cmactions/res/values/styles.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 The CyanogenMod Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<style name="CMActions" parent="@android:style/Theme.Material.Settings">
|
||||
<item name="preferenceTheme">@android:style/Theme.Material.Settings</item>
|
||||
</style>
|
||||
</resources>
|
||||
45
cmactions/res/xml/doze_panel.xml
Normal file
45
cmactions/res/xml/doze_panel.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017 The LineageOS Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="ambient_display_key"
|
||||
android:title="@string/ambient_display_title">
|
||||
|
||||
<cyanogenmod.preference.SecureSettingSwitchPreference
|
||||
android:key="doze_enabled"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/ambient_display_enable_title"
|
||||
android:summary="@string/ambient_display_enable_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_pick_up"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/pick_up_gesture_title"
|
||||
android:summary="@string/pick_up_gesture_summary"
|
||||
android:dependency="doze_enabled" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_hand_wave"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/hand_wave_gesture_title"
|
||||
android:summary="@string/hand_wave_gesture_summary"
|
||||
android:dependency="doze_enabled" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
69
cmactions/res/xml/gesture_panel.xml
Normal file
69
cmactions/res/xml/gesture_panel.xml
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015-2016 The CyanogenMod Project
|
||||
Copyright (C) 2017 The LineageOS Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="actions_key"
|
||||
android:title="@string/actions_title">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_camera_action"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/camera_gesture_title"
|
||||
android:summary="@string/camera_gesture_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_chop_chop"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/chop_chop_gesture_title"
|
||||
android:summary="@string/chop_chop_gesture_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_ir_silencer"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/hand_wave_silencer_title"
|
||||
android:summary="@string/hand_wave_silencer_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_flip_to_mute"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/flip_to_mute_title"
|
||||
android:summary="@string/flip_to_mute_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_lift_to_silence"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/lift_to_silence_title"
|
||||
android:summary="@string/lift_to_silence_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="fp_key"
|
||||
android:title="@string/fingerprint_title" >
|
||||
|
||||
|
||||
<SwitchPreference
|
||||
android:key="fp_home"
|
||||
android:title="@string/fingerprint_as_home_title"
|
||||
android:summary="@string/fingerprint_as_home_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cyanogenmod.settings.device.ServiceWrapper.LocalBinder;
|
||||
|
||||
import org.cyanogenmod.internal.util.FileUtils;
|
||||
|
||||
public class BootCompletedReceiver extends BroadcastReceiver {
|
||||
static final String TAG = "CMActions";
|
||||
private ServiceWrapper mServiceWrapper;
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, Intent intent) {
|
||||
Log.i(TAG, "Booting");
|
||||
|
||||
// Restore nodes to saved preference values
|
||||
for (String pref : Constants.sButtonPrefKeys) {
|
||||
String value = Constants.isPreferenceEnabled(context, pref) ? "1" : "0";
|
||||
String node = Constants.sBooleanNodePreferenceMap.get(pref);
|
||||
|
||||
if (!FileUtils.writeLine(node, value)) {
|
||||
Log.w(TAG, "Write to node " + node +
|
||||
" failed while restoring saved preference values");
|
||||
}
|
||||
}
|
||||
|
||||
context.startService(new Intent(context, ServiceWrapper.class));
|
||||
}
|
||||
|
||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
LocalBinder binder = (LocalBinder) service;
|
||||
mServiceWrapper = binder.getService();
|
||||
mServiceWrapper.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName className) {
|
||||
mServiceWrapper = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class CMActionsService extends IntentService implements ScreenStateNotifier,
|
||||
UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions";
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private final DozePulseAction mDozePulseAction;
|
||||
private final PowerManager mPowerManager;
|
||||
private final PowerManager.WakeLock mWakeLock;
|
||||
private final ScreenReceiver mScreenReceiver;
|
||||
private final SensorHelper mSensorHelper;
|
||||
|
||||
private final List<ScreenStateNotifier> mScreenStateNotifiers = new LinkedList<ScreenStateNotifier>();
|
||||
private final List<UpdatedStateNotifier> mUpdatedStateNotifiers =
|
||||
new LinkedList<UpdatedStateNotifier>();
|
||||
|
||||
public CMActionsService(Context context) {
|
||||
super("CMActionService");
|
||||
mContext = context;
|
||||
|
||||
Log.d(TAG, "Starting");
|
||||
|
||||
CMActionsSettings cmActionsSettings = new CMActionsSettings(context, this);
|
||||
mSensorHelper = new SensorHelper(context);
|
||||
mScreenReceiver = new ScreenReceiver(context, this);
|
||||
|
||||
mDozePulseAction = new DozePulseAction(context);
|
||||
mScreenStateNotifiers.add(mDozePulseAction);
|
||||
|
||||
// Actionable sensors get screen on/off notifications
|
||||
mScreenStateNotifiers.add(new GlanceSensor(cmActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
mScreenStateNotifiers.add(new ProximitySensor(cmActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
mScreenStateNotifiers.add(new StowSensor(cmActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
|
||||
// Other actions that are always enabled
|
||||
mUpdatedStateNotifiers.add(new CameraActivationSensor(cmActionsSettings, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new ChopChopSensor(cmActionsSettings, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new ProximitySilencer(cmActionsSettings, context, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new FlipToMute(cmActionsSettings, context, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new LiftToSilence(cmActionsSettings, context, mSensorHelper));
|
||||
|
||||
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "CMActionsWakeLock");
|
||||
updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOn() {
|
||||
if (!mWakeLock.isHeld()) {
|
||||
mWakeLock.acquire();
|
||||
}
|
||||
for (ScreenStateNotifier screenStateNotifier : mScreenStateNotifiers) {
|
||||
screenStateNotifier.screenTurnedOn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOff() {
|
||||
if (mWakeLock.isHeld()) {
|
||||
mWakeLock.release();
|
||||
}
|
||||
for (ScreenStateNotifier screenStateNotifier : mScreenStateNotifiers) {
|
||||
screenStateNotifier.screenTurnedOff();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateState() {
|
||||
if (mPowerManager.isInteractive()) {
|
||||
screenTurnedOn();
|
||||
} else {
|
||||
screenTurnedOff();
|
||||
}
|
||||
for (UpdatedStateNotifier notifier : mUpdatedStateNotifiers) {
|
||||
notifier.updateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class CMActionsSettings {
|
||||
private static final String TAG = "CMActions";
|
||||
|
||||
private static final String GESTURE_CAMERA_ACTION_KEY = "gesture_camera_action";
|
||||
private static final String GESTURE_CHOP_CHOP_KEY = "gesture_chop_chop";
|
||||
private static final String GESTURE_PICK_UP_KEY = "gesture_pick_up";
|
||||
private static final String GESTURE_IR_WAKEUP_KEY = "gesture_hand_wave";
|
||||
private static final String GESTURE_IR_SILENCER_KEY = "gesture_ir_silencer";
|
||||
private static final String GESTURE_FLIP_TO_MUTE_KEY = "gesture_flip_to_mute";
|
||||
private static final String GESTURE_LIFT_TO_SILENCE_KEY = "gesture_lift_to_silence";
|
||||
|
||||
private final Context mContext;
|
||||
private final UpdatedStateNotifier mUpdatedStateNotifier;
|
||||
|
||||
private boolean mCameraGestureEnabled;
|
||||
private boolean mChopChopEnabled;
|
||||
private boolean mPickUpGestureEnabled;
|
||||
private boolean mIrWakeUpEnabled;
|
||||
private boolean mIrSilencerEnabled;
|
||||
private boolean mFlipToMuteEnabled;
|
||||
private boolean mLiftToSilenceEnabled;
|
||||
|
||||
public CMActionsSettings(Context context, UpdatedStateNotifier updatedStateNotifier) {
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
loadPreferences(sharedPrefs);
|
||||
sharedPrefs.registerOnSharedPreferenceChangeListener(mPrefListener);
|
||||
mContext = context;
|
||||
mUpdatedStateNotifier = updatedStateNotifier;
|
||||
}
|
||||
|
||||
public boolean isCameraGestureEnabled() {
|
||||
return mCameraGestureEnabled;
|
||||
}
|
||||
|
||||
public boolean isChopChopGestureEnabled() {
|
||||
return mChopChopEnabled;
|
||||
}
|
||||
|
||||
public static boolean isDozeEnabled(ContentResolver contentResolver) {
|
||||
return (Settings.Secure.getInt(contentResolver, Settings.Secure.DOZE_ENABLED, 1) != 0);
|
||||
}
|
||||
|
||||
public boolean isDozeEnabled() {
|
||||
return isDozeEnabled(mContext.getContentResolver());
|
||||
}
|
||||
|
||||
public boolean isIrWakeupEnabled() {
|
||||
return isDozeEnabled() && mIrWakeUpEnabled;
|
||||
}
|
||||
|
||||
public boolean isPickUpEnabled() {
|
||||
return isDozeEnabled() && mPickUpGestureEnabled;
|
||||
}
|
||||
|
||||
public boolean isIrSilencerEnabled() {
|
||||
return mIrSilencerEnabled;
|
||||
}
|
||||
|
||||
public boolean isFlipToMuteEnabled() {
|
||||
return mFlipToMuteEnabled;
|
||||
}
|
||||
|
||||
public boolean isLiftToSilenceEnabled() {
|
||||
return mLiftToSilenceEnabled;
|
||||
}
|
||||
|
||||
public void cameraAction() {
|
||||
new CameraActivationAction(mContext).action();
|
||||
}
|
||||
|
||||
public void chopChopAction() {
|
||||
new TorchAction(mContext).action();
|
||||
}
|
||||
|
||||
private void loadPreferences(SharedPreferences sharedPreferences) {
|
||||
mCameraGestureEnabled = sharedPreferences.getBoolean(GESTURE_CAMERA_ACTION_KEY, true);
|
||||
mChopChopEnabled = sharedPreferences.getBoolean(GESTURE_CHOP_CHOP_KEY, true);
|
||||
mIrWakeUpEnabled = sharedPreferences.getBoolean(GESTURE_IR_WAKEUP_KEY, true);
|
||||
mPickUpGestureEnabled = sharedPreferences.getBoolean(GESTURE_PICK_UP_KEY, true);
|
||||
mIrSilencerEnabled = sharedPreferences.getBoolean(GESTURE_IR_SILENCER_KEY, false);
|
||||
mFlipToMuteEnabled = sharedPreferences.getBoolean(GESTURE_FLIP_TO_MUTE_KEY, false);
|
||||
mLiftToSilenceEnabled = sharedPreferences.getBoolean(GESTURE_LIFT_TO_SILENCE_KEY, false);
|
||||
}
|
||||
|
||||
private SharedPreferences.OnSharedPreferenceChangeListener mPrefListener =
|
||||
new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
boolean updated = true;
|
||||
|
||||
if (GESTURE_CAMERA_ACTION_KEY.equals(key)) {
|
||||
mCameraGestureEnabled = sharedPreferences.getBoolean(GESTURE_CAMERA_ACTION_KEY, true);
|
||||
} else if (GESTURE_CHOP_CHOP_KEY.equals(key)) {
|
||||
mChopChopEnabled = sharedPreferences.getBoolean(GESTURE_CHOP_CHOP_KEY, true);
|
||||
} else if (GESTURE_IR_WAKEUP_KEY.equals(key)) {
|
||||
mIrWakeUpEnabled = sharedPreferences.getBoolean(GESTURE_IR_WAKEUP_KEY, true);
|
||||
} else if (GESTURE_PICK_UP_KEY.equals(key)) {
|
||||
mPickUpGestureEnabled = sharedPreferences.getBoolean(GESTURE_PICK_UP_KEY, true);
|
||||
} else if (GESTURE_IR_SILENCER_KEY.equals(key)) {
|
||||
mIrSilencerEnabled = sharedPreferences.getBoolean(GESTURE_IR_SILENCER_KEY, false);
|
||||
} else if (GESTURE_FLIP_TO_MUTE_KEY.equals(key)) {
|
||||
mFlipToMuteEnabled = sharedPreferences.getBoolean(GESTURE_FLIP_TO_MUTE_KEY, false);
|
||||
} else if (GESTURE_LIFT_TO_SILENCE_KEY.equals(key)) {
|
||||
mLiftToSilenceEnabled = sharedPreferences.getBoolean(GESTURE_LIFT_TO_SILENCE_KEY, false);
|
||||
} else {
|
||||
updated = false;
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
mUpdatedStateNotifier.updateState();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
|
||||
public class CameraActivationAction implements SensorAction {
|
||||
private static final String TAG = "CMActions";
|
||||
|
||||
private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
|
||||
|
||||
private final Context mContext;
|
||||
private final KeyguardManager mKeyguardManager;
|
||||
private final PackageManager mPackageManager;
|
||||
private final PowerManager mPowerManager;
|
||||
|
||||
public CameraActivationAction(Context context) {
|
||||
mContext = context;
|
||||
mKeyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
mPackageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action() {
|
||||
vibrate();
|
||||
turnScreenOn();
|
||||
if (mKeyguardManager.inKeyguardRestrictedInputMode()) {
|
||||
launchSecureCamera();
|
||||
} else {
|
||||
launchCamera();
|
||||
}
|
||||
}
|
||||
|
||||
private void vibrate() {
|
||||
Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
v.vibrate(500);
|
||||
}
|
||||
|
||||
private void turnScreenOn() {
|
||||
PowerManager.WakeLock wl = mPowerManager.newWakeLock(
|
||||
PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
|
||||
wl.acquire(TURN_SCREEN_ON_WAKE_LOCK_MS);
|
||||
}
|
||||
|
||||
private void launchCamera() {
|
||||
Intent intent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
|
||||
if (getBestActivityInfo(intent) != null) {
|
||||
// Only launch if we can succeed, but let the user pick the action
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void launchSecureCamera() {
|
||||
// Keyguard won't allow a picker, try to pick the secure intent in the package
|
||||
// that would be the one used for a default action of launching the camera
|
||||
Intent normalIntent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
|
||||
Intent secureIntent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE);
|
||||
ActivityInfo normalActivity = getBestActivityInfo(normalIntent);
|
||||
ActivityInfo secureActivity = getBestActivityInfo(secureIntent, normalActivity);
|
||||
if (secureActivity != null) {
|
||||
secureIntent.setComponent(componentName(secureActivity));
|
||||
mContext.startActivity(secureIntent);
|
||||
}
|
||||
}
|
||||
|
||||
private Intent createIntent(String intentName) {
|
||||
Intent intent = new Intent(intentName);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
|
||||
return intent;
|
||||
}
|
||||
|
||||
private ActivityInfo getBestActivityInfo(Intent intent) {
|
||||
ResolveInfo resolveInfo = mPackageManager.resolveActivity(intent, 0);
|
||||
if (resolveInfo != null) {
|
||||
return resolveInfo.activityInfo;
|
||||
} else {
|
||||
// If the resolving failed, just find our own best match
|
||||
return getBestActivityInfo(intent, null);
|
||||
}
|
||||
}
|
||||
|
||||
private ActivityInfo getBestActivityInfo(Intent intent, ActivityInfo match) {
|
||||
List <ResolveInfo> activities = mPackageManager.queryIntentActivities(intent, 0);
|
||||
ActivityInfo best = null;
|
||||
if (activities.size() > 0) {
|
||||
best = activities.get(0).activityInfo;
|
||||
if (match != null) {
|
||||
String packageName = match.applicationInfo.packageName;
|
||||
for (int i = activities.size()-1; i >= 0; i--) {
|
||||
ActivityInfo activityInfo = activities.get(i).activityInfo;
|
||||
if (packageName.equals(activityInfo.applicationInfo.packageName)) {
|
||||
best = activityInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
private ComponentName componentName(ActivityInfo activity) {
|
||||
return new ComponentName(activity.applicationInfo.packageName, activity.name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class CameraActivationSensor implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-CameraSensor";
|
||||
|
||||
private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
|
||||
private final Sensor mSensor;
|
||||
|
||||
private boolean mIsEnabled;
|
||||
|
||||
public CameraActivationSensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensor = sensorHelper.getCameraActivationSensor();
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void updateState() {
|
||||
if (mCMActionsSettings.isCameraGestureEnabled() && !mIsEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mIsEnabled = true;
|
||||
} else if (! mCMActionsSettings.isCameraGestureEnabled() && mIsEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mIsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
Log.d(TAG, "activate camera");
|
||||
if (mIsEnabled) mCMActionsSettings.cameraAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-ChopChopSensor";
|
||||
|
||||
private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final Sensor mSensor;
|
||||
private final Sensor mProx;
|
||||
|
||||
private boolean mIsEnabled;
|
||||
private boolean mProxIsCovered;
|
||||
|
||||
public ChopChopSensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensor = sensorHelper.getChopChopSensor();
|
||||
mProx = sensorHelper.getProximitySensor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void updateState() {
|
||||
if (mCMActionsSettings.isChopChopGestureEnabled() && !mIsEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
mSensorHelper.registerListener(mProx, mProxListener);
|
||||
mIsEnabled = true;
|
||||
} else if (! mCMActionsSettings.isChopChopGestureEnabled() && mIsEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mSensorHelper.unregisterListener(this);
|
||||
mSensorHelper.unregisterListener(mProxListener);
|
||||
mIsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
Log.d(TAG, "chop chop triggered");
|
||||
if (mProxIsCovered) {
|
||||
Log.d(TAG, "proximity sensor covered, ignoring chop-chop");
|
||||
return;
|
||||
}
|
||||
mCMActionsSettings.chopChopAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
|
||||
private SensorEventListener mProxListener = new SensorEventListener() {
|
||||
@Override
|
||||
public synchronized void onSensorChanged(SensorEvent event) {
|
||||
mProxIsCovered = event.values[0] < mProx.getMaximumRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
53
cmactions/src/com/cyanogenmod/settings/device/Constants.java
Normal file
53
cmactions/src/com/cyanogenmod/settings/device/Constants.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public class Constants {
|
||||
|
||||
// Swap keys
|
||||
public static final String FP_HOME_KEY = "fp_home";
|
||||
|
||||
// Swap nodes
|
||||
public static final String FP_HOME_NODE = "/sys/homebutton/enable";
|
||||
|
||||
// Holds <preference_key> -> <proc_node> mapping
|
||||
public static final Map<String, String> sBooleanNodePreferenceMap = new HashMap<>();
|
||||
|
||||
// Holds <preference_key> -> <default_values> mapping
|
||||
public static final Map<String, Object> sNodeDefaultMap = new HashMap<>();
|
||||
|
||||
public static final String[] sButtonPrefKeys = {
|
||||
FP_HOME_KEY,
|
||||
};
|
||||
|
||||
static {
|
||||
sBooleanNodePreferenceMap.put(FP_HOME_KEY, FP_HOME_NODE);
|
||||
sNodeDefaultMap.put(FP_HOME_KEY, false);
|
||||
}
|
||||
|
||||
public static boolean isPreferenceEnabled(Context context, String key) {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return preferences.getBoolean(key, (Boolean) sNodeDefaultMap.get(key));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceCategory;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.view.MenuItem;
|
||||
|
||||
public class DozePreferenceActivity extends PreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(android.R.id.content, new DozePreferenceFragment()).commit();
|
||||
}
|
||||
|
||||
public class DozePreferenceFragment extends PreferenceFragment {
|
||||
private static final String KEY_AMBIENT_DISPLAY_ENABLE = "doze_enabled";
|
||||
|
||||
private SwitchPreference mAmbientDisplayPreference;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.doze_panel);
|
||||
boolean dozeEnabled = CMActionsSettings.isDozeEnabled(getActivity().getContentResolver());
|
||||
mAmbientDisplayPreference = (SwitchPreference) findPreference(KEY_AMBIENT_DISPLAY_ENABLE);
|
||||
// Read from DOZE_ENABLED secure setting
|
||||
mAmbientDisplayPreference.setChecked(dozeEnabled);
|
||||
mAmbientDisplayPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean enable = (boolean) newValue;
|
||||
return enableDoze(enable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean enableDoze(boolean enable) {
|
||||
return Settings.Secure.putInt(getContext().getContentResolver(),
|
||||
Settings.Secure.DOZE_ENABLED, enable ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
public class DozePulseAction implements SensorAction, ScreenStateNotifier {
|
||||
private static final String TAG = "CMActions";
|
||||
|
||||
private static final int DELAY_BETWEEN_DOZES_IN_MS = 1500;
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private long mLastDoze;
|
||||
|
||||
public DozePulseAction(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOn() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOff() {
|
||||
mLastDoze = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void action() {
|
||||
if (mayDoze()) {
|
||||
Log.d(TAG, "Sending doze.pulse intent");
|
||||
mContext.sendBroadcast(new Intent("com.android.systemui.doze.pulse"));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean mayDoze() {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now - mLastDoze > DELAY_BETWEEN_DOZES_IN_MS) {
|
||||
Log.d(TAG, "Allowing doze");
|
||||
mLastDoze = now;
|
||||
return true;
|
||||
} else {
|
||||
Log.d(TAG, "Denying doze");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
123
cmactions/src/com/cyanogenmod/settings/device/FlipToMute.java
Normal file
123
cmactions/src/com/cyanogenmod/settings/device/FlipToMute.java
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.util.Log;
|
||||
|
||||
public class FlipToMute implements UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-FlipToMute";
|
||||
|
||||
private final NotificationManager mNotificationManager;
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final Sensor mFlatDown;
|
||||
private final Sensor mStow;
|
||||
|
||||
private boolean mIsEnabled;
|
||||
private boolean mIsFlatDown;
|
||||
private boolean mIsStowed;
|
||||
private int mFilter;
|
||||
private Context mContext;
|
||||
private Receiver mReceiver;
|
||||
|
||||
public FlipToMute(CMActionsSettings cmActionsSettings, Context context,
|
||||
SensorHelper sensorHelper) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mContext = context;
|
||||
mSensorHelper = sensorHelper;
|
||||
mFlatDown = sensorHelper.getFlatDownSensor();
|
||||
mStow = sensorHelper.getStowSensor();
|
||||
mNotificationManager =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mFilter = mNotificationManager.getCurrentInterruptionFilter();
|
||||
mReceiver = new Receiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState() {
|
||||
if (mCMActionsSettings.isFlipToMuteEnabled() && !mIsEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.registerListener(mFlatDown, mFlatDownListener);
|
||||
mSensorHelper.registerListener(mStow, mStowListener);
|
||||
mContext.registerReceiver(mReceiver,
|
||||
new IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED));
|
||||
mIsEnabled = true;
|
||||
} else if (!mCMActionsSettings.isFlipToMuteEnabled() && mIsEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mSensorHelper.unregisterListener(mFlatDownListener);
|
||||
mSensorHelper.unregisterListener(mStowListener);
|
||||
mContext.unregisterReceiver(mReceiver);
|
||||
mIsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private SensorEventListener mFlatDownListener = new SensorEventListener() {
|
||||
@Override
|
||||
public synchronized void onSensorChanged(SensorEvent event) {
|
||||
mIsFlatDown = (event.values[0] != 0);
|
||||
sensorChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
||||
}
|
||||
};
|
||||
|
||||
private SensorEventListener mStowListener = new SensorEventListener() {
|
||||
@Override
|
||||
public synchronized void onSensorChanged(SensorEvent event) {
|
||||
mIsStowed = (event.values[0] != 0);
|
||||
sensorChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
||||
}
|
||||
};
|
||||
|
||||
private void sensorChange() {
|
||||
|
||||
Log.d(TAG, "event: " + mIsFlatDown + " mIsStowed=" + mIsStowed);
|
||||
|
||||
if (mIsFlatDown && mIsStowed) {
|
||||
mNotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY);
|
||||
Log.d(TAG, "Interrupt filter: Allow priority");
|
||||
} else if (!mIsFlatDown) {
|
||||
mNotificationManager.setInterruptionFilter(mFilter);
|
||||
Log.d(TAG, "Interrupt filter: Restore");
|
||||
}
|
||||
}
|
||||
|
||||
public class Receiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!mIsFlatDown && !mIsStowed) {
|
||||
mFilter = mNotificationManager.getCurrentInterruptionFilter();
|
||||
Log.d(TAG, "Interrupt filter: Backup");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.TriggerEvent;
|
||||
import android.hardware.TriggerEventListener;
|
||||
import android.util.Log;
|
||||
|
||||
public class GlanceSensor implements ScreenStateNotifier {
|
||||
private static final String TAG = "CMActions-GlanceSensor";
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final SensorAction mSensorAction;
|
||||
private final Sensor mSensor;
|
||||
|
||||
private boolean mEnabled;
|
||||
|
||||
public GlanceSensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper,
|
||||
SensorAction action) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensorAction = action;
|
||||
|
||||
mSensor = sensorHelper.getGlanceSensor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOn() {
|
||||
if (mEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mSensorHelper.cancelTriggerSensor(mSensor, mGlanceListener);
|
||||
mEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOff() {
|
||||
if (mCMActionsSettings.isPickUpEnabled() && !mEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.requestTriggerSensor(mSensor, mGlanceListener);
|
||||
mEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private TriggerEventListener mGlanceListener = new TriggerEventListener() {
|
||||
@Override
|
||||
public void onTrigger(TriggerEvent event) {
|
||||
Log.d(TAG, "triggered");
|
||||
mSensorAction.action();
|
||||
mSensorHelper.requestTriggerSensor(mSensor, mGlanceListener);
|
||||
}
|
||||
};
|
||||
}
|
||||
105
cmactions/src/com/cyanogenmod/settings/device/LiftToSilence.java
Normal file
105
cmactions/src/com/cyanogenmod/settings/device/LiftToSilence.java
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class LiftToSilence extends PhoneStateListener implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-LiftToSilence";
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final Sensor mFlatUpSensor;
|
||||
private final Sensor mStowSensor;
|
||||
|
||||
private final TelecomManager mTelecomManager;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
|
||||
private boolean mIsRinging;
|
||||
private boolean mIsStowed;
|
||||
private boolean mLastFlatUp;
|
||||
|
||||
public LiftToSilence(CMActionsSettings cmActionsSettings, Context context,
|
||||
SensorHelper sensorHelper) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mFlatUpSensor = sensorHelper.getFlatUpSensor();
|
||||
mStowSensor = sensorHelper.getStowSensor();
|
||||
mTelecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
|
||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState() {
|
||||
if (mCMActionsSettings.isLiftToSilenceEnabled()) {
|
||||
mTelephonyManager.listen(this, LISTEN_CALL_STATE);
|
||||
} else {
|
||||
mTelephonyManager.listen(this, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onCallStateChanged(int state, String incomingNumber) {
|
||||
if (state == TelephonyManager.CALL_STATE_RINGING && !mIsRinging) {
|
||||
Log.d(TAG, "Ringing started");
|
||||
mSensorHelper.registerListener(mFlatUpSensor, this);
|
||||
mSensorHelper.registerListener(mStowSensor, mStowListener);
|
||||
mIsRinging = true;
|
||||
} else if (state != TelephonyManager.CALL_STATE_RINGING && mIsRinging) {
|
||||
Log.d(TAG, "Ringing stopped");
|
||||
mSensorHelper.unregisterListener(this);
|
||||
mSensorHelper.unregisterListener(mStowListener);
|
||||
mIsRinging = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void onSensorChanged(SensorEvent event) {
|
||||
boolean thisFlatUp = (event.values[0] != 0);
|
||||
|
||||
Log.d(TAG, "event: " + thisFlatUp + " mLastFlatUp=" + mLastFlatUp + " mIsStowed=" +
|
||||
mIsStowed);
|
||||
|
||||
if (mLastFlatUp && !thisFlatUp && !mIsStowed) {
|
||||
mTelecomManager.silenceRinger();
|
||||
}
|
||||
mLastFlatUp = thisFlatUp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
||||
}
|
||||
|
||||
private SensorEventListener mStowListener = new SensorEventListener() {
|
||||
@Override
|
||||
public synchronized void onSensorChanged(SensorEvent event) {
|
||||
mIsStowed = (event.values[0] != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.util.Log;
|
||||
|
||||
public class ProximitySensor implements ScreenStateNotifier, SensorEventListener {
|
||||
private static final String TAG = "CMActions-ProximitySensor";
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final SensorAction mSensorAction;
|
||||
private final Sensor mSensor;
|
||||
|
||||
private boolean mEnabled;
|
||||
|
||||
private boolean mSawNear = false;
|
||||
|
||||
public ProximitySensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper,
|
||||
SensorAction action) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensorAction = action;
|
||||
|
||||
mSensor = sensorHelper.getProximitySensor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOn() {
|
||||
if (mEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mSensorHelper.unregisterListener(this);
|
||||
mEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOff() {
|
||||
if (mCMActionsSettings.isIrWakeupEnabled() && !mEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
mEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
boolean isNear = event.values[0] < mSensor.getMaximumRange();
|
||||
if (mSawNear && !isNear) {
|
||||
Log.d(TAG, "wave triggered");
|
||||
mSensorAction.action();
|
||||
}
|
||||
mSawNear = isNear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import static android.telephony.TelephonyManager.*;
|
||||
|
||||
public class ProximitySilencer extends PhoneStateListener implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-ProximitySilencer";
|
||||
|
||||
private static final int SILENCE_DELAY_MS = 500;
|
||||
|
||||
private final TelecomManager mTelecomManager;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final Sensor mSensor;
|
||||
private boolean mIsRinging;
|
||||
private long mRingStartedMs;
|
||||
private boolean mCoveredRinging;
|
||||
|
||||
public ProximitySilencer(CMActionsSettings cmActionsSettings, Context context,
|
||||
SensorHelper sensorHelper) {
|
||||
mTelecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
|
||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensor = sensorHelper.getProximitySensor();
|
||||
mCoveredRinging = false;
|
||||
mIsRinging = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState() {
|
||||
if (mCMActionsSettings.isIrSilencerEnabled()) {
|
||||
mTelephonyManager.listen(this, LISTEN_CALL_STATE);
|
||||
} else {
|
||||
mTelephonyManager.listen(this, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onSensorChanged(SensorEvent event) {
|
||||
boolean isNear = event.values[0] < mSensor.getMaximumRange();
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
if (isNear){
|
||||
if (mIsRinging && (now - mRingStartedMs >= SILENCE_DELAY_MS)){
|
||||
mCoveredRinging = true;
|
||||
} else {
|
||||
mCoveredRinging = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isNear && mIsRinging) {
|
||||
Log.d(TAG, "event: [" + event.values.length + "]: " + event.values[0] + ", " +
|
||||
event.values[1] + ", " + event.values[2] + " covered " + Boolean.toString(mCoveredRinging));
|
||||
if (mCoveredRinging) {
|
||||
Log.d(TAG, "Silencing ringer");
|
||||
mTelecomManager.silenceRinger();
|
||||
} else {
|
||||
Log.d(TAG, "Ignoring silence gesture: " + now + " is too close to " +
|
||||
mRingStartedMs + ", delay=" + SILENCE_DELAY_MS + " or covered " + Boolean.toString(mCoveredRinging));
|
||||
}
|
||||
mCoveredRinging = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onCallStateChanged(int state, String incomingNumber) {
|
||||
if (state == CALL_STATE_RINGING && !mIsRinging) {
|
||||
Log.d(TAG, "Ringing started");
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
mIsRinging = true;
|
||||
mRingStartedMs = System.currentTimeMillis();
|
||||
} else if (state != CALL_STATE_RINGING && mIsRinging) {
|
||||
Log.d(TAG, "Ringing stopped");
|
||||
mSensorHelper.unregisterListener(this);
|
||||
mIsRinging = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor mSensor, int accuracy) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
public class ScreenReceiver extends BroadcastReceiver {
|
||||
private final ScreenStateNotifier mNotifier;
|
||||
|
||||
public ScreenReceiver(Context context, ScreenStateNotifier notifier) {
|
||||
mNotifier = notifier;
|
||||
|
||||
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
context.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
||||
mNotifier.screenTurnedOff();
|
||||
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
|
||||
mNotifier.screenTurnedOn();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
interface ScreenStateNotifier {
|
||||
public void screenTurnedOn();
|
||||
public void screenTurnedOff();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
interface SensorAction {
|
||||
public void action();
|
||||
}
|
||||
116
cmactions/src/com/cyanogenmod/settings/device/SensorHelper.java
Normal file
116
cmactions/src/com/cyanogenmod/settings/device/SensorHelper.java
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.TriggerEventListener;
|
||||
import android.util.Log;
|
||||
|
||||
public class SensorHelper {
|
||||
private static final String TAG = "CMActions";
|
||||
|
||||
private static final int SENSOR_TYPE_MMI_CAMERA_ACTIVATION = 65540;
|
||||
private static final int SENSOR_TYPE_MMI_CHOP_CHOP = 65546;
|
||||
private static final int SENSOR_TYPE_MMI_FLAT_UP = 65537;
|
||||
private static final int SENSOR_TYPE_MMI_FLAT_DOWN = 65538;
|
||||
private static final int SENSOR_TYPE_MMI_STOW = 65539;
|
||||
|
||||
private static final int BATCH_LATENCY_IN_MS = 100;
|
||||
|
||||
private final Context mContext;
|
||||
private final SensorManager mSensorManager;
|
||||
|
||||
public SensorHelper(Context context) {
|
||||
mContext = context;
|
||||
mSensorManager = (SensorManager) mContext .getSystemService(Context.SENSOR_SERVICE);
|
||||
dumpSensorsList();
|
||||
}
|
||||
|
||||
private void dumpSensorsList() {
|
||||
try {
|
||||
FileOutputStream out = mContext.openFileOutput("sensors.txt", Context.MODE_PRIVATE);
|
||||
OutputStreamWriter writer = new OutputStreamWriter(out);
|
||||
|
||||
List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL);
|
||||
for (Sensor sensor : sensorList) {
|
||||
writer.write("sensor " + sensor.getType() + " = " + sensor.getName()
|
||||
+ " max batch: " + sensor.getFifoMaxEventCount() + " isWakeUp: " + sensor.isWakeUpSensor() + "\n");
|
||||
}
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Sensor getCameraActivationSensor() {
|
||||
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_CAMERA_ACTIVATION, true);
|
||||
}
|
||||
|
||||
public Sensor getChopChopSensor() {
|
||||
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_CHOP_CHOP, true);
|
||||
}
|
||||
|
||||
public Sensor getFlatUpSensor() {
|
||||
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_FLAT_UP, true);
|
||||
}
|
||||
|
||||
public Sensor getFlatDownSensor() {
|
||||
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_FLAT_DOWN, true);
|
||||
}
|
||||
|
||||
public Sensor getGlanceSensor() {
|
||||
return mSensorManager.getDefaultSensor(Sensor.TYPE_GLANCE_GESTURE, true);
|
||||
}
|
||||
|
||||
public Sensor getProximitySensor() {
|
||||
return mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true);
|
||||
}
|
||||
|
||||
public Sensor getStowSensor() {
|
||||
return mSensorManager.getDefaultSensor(SENSOR_TYPE_MMI_STOW, true);
|
||||
}
|
||||
|
||||
public void registerListener(Sensor sensor, SensorEventListener listener) {
|
||||
if (!mSensorManager.registerListener(listener, sensor,
|
||||
SensorManager.SENSOR_DELAY_NORMAL, BATCH_LATENCY_IN_MS * 1000)) {
|
||||
throw new RuntimeException("Failed to registerListener for sensor " + sensor);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterListener(SensorEventListener listener) {
|
||||
mSensorManager.unregisterListener(listener);
|
||||
}
|
||||
|
||||
/* TriggerSensor */
|
||||
public void requestTriggerSensor(Sensor sensor, TriggerEventListener listener) {
|
||||
if (!mSensorManager.requestTriggerSensor(listener, sensor)) {
|
||||
throw new RuntimeException("Failed to requestTriggerSensor for sensor " + sensor);
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelTriggerSensor(Sensor sensor, TriggerEventListener listener) {
|
||||
mSensorManager.cancelTriggerSensor(listener, sensor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
public class ServiceWrapper extends android.app.Service {
|
||||
static final String TAG = "CMActions-ServiceWrapper";
|
||||
|
||||
private final IBinder mBinder = new LocalBinder();
|
||||
private CMActionsService mCmActionsService;
|
||||
|
||||
public interface ServiceCallback {
|
||||
void sendResults(int resultCode, Bundle b);
|
||||
}
|
||||
|
||||
public class LocalBinder extends Binder {
|
||||
ServiceWrapper getService() {
|
||||
// Return this instance of the service so clients can call public
|
||||
// methods
|
||||
return ServiceWrapper.this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Log.i(TAG, "onCreate");
|
||||
super.onCreate();
|
||||
mCmActionsService = new CMActionsService(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
Log.i(TAG, "onBind");
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setCallback(ServiceCallback callback) {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
Log.i(TAG, "start");
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
public class StowSensor implements ScreenStateNotifier, SensorEventListener {
|
||||
private static final String TAG = "CMActions-StowSensor";
|
||||
private static final int IN_POCKET_MIN_TIME = 5000;
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final SensorAction mSensorAction;
|
||||
private final Sensor mSensor;
|
||||
|
||||
private boolean mEnabled;
|
||||
private boolean mLastStowed;
|
||||
private long isStowedTime;
|
||||
|
||||
public StowSensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper,
|
||||
SensorAction action) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensorAction = action;
|
||||
|
||||
mSensor = sensorHelper.getStowSensor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOn() {
|
||||
if (mEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mSensorHelper.unregisterListener(this);
|
||||
mEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void screenTurnedOff() {
|
||||
if (!mCMActionsSettings.isIrWakeupEnabled() &&
|
||||
mCMActionsSettings.isPickUpEnabled() && !mEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
mEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
boolean thisStowed = (event.values[0] != 0);
|
||||
if(thisStowed){
|
||||
isStowedTime = System.currentTimeMillis();
|
||||
} else if (mLastStowed && !thisStowed) {
|
||||
long inPocketTime = System.currentTimeMillis() - isStowedTime;
|
||||
if(inPocketTime >= IN_POCKET_MIN_TIME){
|
||||
Log.d(TAG, "Triggered after " + inPocketTime / 1000 + " seconds");
|
||||
mSensorAction.action();
|
||||
}
|
||||
}
|
||||
mLastStowed = thisStowed;
|
||||
Log.d(TAG, "event: " + thisStowed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.os.Vibrator;
|
||||
import android.util.Log;
|
||||
|
||||
public class TorchAction implements SensorAction {
|
||||
private static final String TAG = "CMActions";
|
||||
|
||||
private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
|
||||
|
||||
private CameraManager mCameraManager;
|
||||
private final Vibrator mVibrator;
|
||||
private String mRearCameraId;
|
||||
private static boolean mTorchEnabled;
|
||||
|
||||
public TorchAction(Context mContext) {
|
||||
mCameraManager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
|
||||
mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
try {
|
||||
for (final String cameraId : mCameraManager.getCameraIdList()) {
|
||||
CameraCharacteristics characteristics =
|
||||
mCameraManager.getCameraCharacteristics(cameraId);
|
||||
int cOrientation = characteristics.get(CameraCharacteristics.LENS_FACING);
|
||||
if (cOrientation == CameraCharacteristics.LENS_FACING_BACK) {
|
||||
mRearCameraId = cameraId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (CameraAccessException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action() {
|
||||
mVibrator.vibrate(250);
|
||||
if (mRearCameraId != null) {
|
||||
try {
|
||||
mCameraManager.setTorchMode(mRearCameraId, !mTorchEnabled);
|
||||
mTorchEnabled = !mTorchEnabled;
|
||||
} catch (CameraAccessException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyTorchCallback extends CameraManager.TorchCallback {
|
||||
|
||||
@Override
|
||||
public void onTorchModeChanged(String cameraId, boolean enabled) {
|
||||
if (!cameraId.equals(mRearCameraId))
|
||||
return;
|
||||
mTorchEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTorchModeUnavailable(String cameraId) {
|
||||
if (!cameraId.equals(mRearCameraId))
|
||||
return;
|
||||
mTorchEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settingslib.drawer.SettingsDrawerActivity;
|
||||
|
||||
public class TouchscreenGesturePreferenceActivity extends SettingsDrawerActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.content_frame, new TouchscreenGesturePreferenceFragment()).commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.NotificationManager;
|
||||
import android.os.Bundle;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceCategory;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.cyanogenmod.internal.util.FileUtils;
|
||||
import org.cyanogenmod.internal.util.ScreenType;
|
||||
|
||||
public class TouchscreenGesturePreferenceFragment extends PreferenceFragment {
|
||||
private SwitchPreference mFlipPref;
|
||||
private NotificationManager mNotificationManager;
|
||||
private boolean mFlipClick = false;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.gesture_panel);
|
||||
mNotificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mFlipPref = (SwitchPreference) findPreference("gesture_flip_to_mute");
|
||||
mFlipPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (!mNotificationManager.isNotificationPolicyAccessGranted()) {
|
||||
mFlipPref.setChecked(false);
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setTitle(getString(R.string.flip_to_mute_title))
|
||||
.setMessage(getString(R.string.dnd_access))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mFlipClick = true;
|
||||
startActivity(new Intent(
|
||||
android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS));
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
//Users may deny DND access after giving it
|
||||
if (!mNotificationManager.isNotificationPolicyAccessGranted()) {
|
||||
mFlipPref.setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPreferencesFromResource(int preferencesResId) {
|
||||
super.addPreferencesFromResource(preferencesResId);
|
||||
// Initialize node preferences
|
||||
for (String pref : Constants.sBooleanNodePreferenceMap.keySet()) {
|
||||
SwitchPreference b = (SwitchPreference) findPreference(pref);
|
||||
if (b == null) continue;
|
||||
b.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String node = Constants.sBooleanNodePreferenceMap.get(preference.getKey());
|
||||
if (!TextUtils.isEmpty(node)) {
|
||||
Boolean value = (Boolean) newValue;
|
||||
FileUtils.writeLine(node, value ? "1" : "0");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
String node = Constants.sBooleanNodePreferenceMap.get(pref);
|
||||
if (new File(node).exists()) {
|
||||
String curNodeValue = FileUtils.readOneLine(node);
|
||||
b.setChecked(curNodeValue.equals("1"));
|
||||
} else {
|
||||
b.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (mNotificationManager.isNotificationPolicyAccessGranted() && mFlipClick) {
|
||||
mFlipPref.setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
|
||||
interface UpdatedStateNotifier {
|
||||
public void updateState();
|
||||
}
|
||||
135
configs/camera/msm8953_mot_camera.xml
Normal file
135
configs/camera/msm8953_mot_camera.xml
Normal file
@@ -0,0 +1,135 @@
|
||||
<!--
|
||||
Copyright (c) 2015 Qualcomm Technologies, Inc.
|
||||
All Rights Reserved.
|
||||
Confidential and Proprietary - Qualcomm Technologies, Inc.
|
||||
-->
|
||||
<!--
|
||||
CameraModuleConfig :
|
||||
This node must be added for each module prosent in the device.
|
||||
It contain all information about the module present.
|
||||
The number of nodes of CameraModuleConfig indicate number of modules
|
||||
to be probed on the device.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
*CameraId :
|
||||
Camera Id is the Slot number in which the mode is plugged.
|
||||
Valid values are 0, 1, 2 and 3.
|
||||
*SensorName :
|
||||
Name of the sensor present on the module.
|
||||
The sensor library name should be of the form libmmcamera_<SensorName>.so
|
||||
ActuatorName :
|
||||
Name of the actuator on this module.
|
||||
The actuator library name should be of the form libactuator_<ActuatorName>.so.
|
||||
If there is no actuator remove the <ActuatorName> node.
|
||||
EepromName :
|
||||
Name of the eeprom on this module.
|
||||
Eeprom lib name should be of the form libmmcamera_<EepromName>_eeprom.so
|
||||
If there is no eeprom remove the <EepromName> node.
|
||||
FlashName :
|
||||
Name of the flash on this module.
|
||||
The flash library name should be of the form libflash_<FlashName>.so.
|
||||
If there is no flash remove the <FlashName> node.
|
||||
ChromatixName :
|
||||
Name of the tuning xml file.
|
||||
Tuning file contains the list of chromatix library names.
|
||||
If there is no tuning xml file remove the <ChromatixName> node.
|
||||
Position :
|
||||
Position of the sensor module. Valid values are 0, 1 and 2.
|
||||
For CAMERA_POSITION_BACK use 0.
|
||||
For CAMERA_POSITION_FRONT use 1.
|
||||
For CAMERA_POSITON_BACK_AUX use 2.
|
||||
MountAngle :
|
||||
Angle at which the sensor is mounted. Valid values are 0, 90, 180, 270 and 360.
|
||||
To use default mountangle mentioned in kernel use 360.
|
||||
|
||||
CsiInfo : This node contains information about the receiver configuration.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
*CSIDCore :
|
||||
CSID core to receive the data. Valid values are 0, 1, 2 and 3.
|
||||
*LaneMask :
|
||||
Mask to mention which lane is enabled.
|
||||
LaneMask[0] for DL0.
|
||||
LaneMask[1] for CLK.
|
||||
LaneMask[2] for DL1.
|
||||
LaneMask[3] for DL2.
|
||||
LaneMask[4] for DL3
|
||||
*LaneAssign :
|
||||
Number which describes the lane mapping between sensor and PHY.
|
||||
LaneAssign[0:3] is sensor lane number connected to data lane 0 of a PHY on the MSM side
|
||||
LaneAssign[4:7] is sensor lane number connected to data lane 2 of a PHY on the MSM side
|
||||
LaneAssign[8:11] is sensor lane number connected to data lane 3 of a PHY on the MSM side
|
||||
LaneAssign[12:15] is sensor lane number connected to data lane 4 of a PHY on the MSM side
|
||||
|
||||
NOTE : Lane 1 is reserved for the clock lane. Wiring and setting it to a data lane is prohibited.
|
||||
ComboMode :
|
||||
Flag to enable combo mode.
|
||||
This flag is enabled if multiple sensors are using same CSI-PHY receiver
|
||||
|
||||
LensInfo : Information of the lens present in the module.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
*FocalLength :
|
||||
FocalLength of the lens in micometers.
|
||||
Distance between the center of curvature to the focal point.
|
||||
*FNumber :
|
||||
FNumber of the lens.
|
||||
*TotalFocusDistance : The total distance in meters the lens could focus.
|
||||
*HorizontalViewAngle : HorizontalViewAngle in degrees
|
||||
*VerticalViewAngle : VerticalViewAngle in degrees
|
||||
*MinFocusDistance : Minimum distance in meters the lens could focus.
|
||||
|
||||
*VARIABLES MARKED WITH ASTRICK (*) ARE MANDATORY.
|
||||
|
||||
-->
|
||||
|
||||
<CameraConfigurationRoot>
|
||||
<CameraModuleConfig>
|
||||
<CameraId>1</CameraId>
|
||||
<SensorName>mot_imx362</SensorName>
|
||||
<EepromName>imx362</EepromName>
|
||||
<ActuatorName>mot_ak7371</ActuatorName>
|
||||
<FlashName>pmic</FlashName>
|
||||
<ChromatixName>mot_imx362_chromatix</ChromatixName>
|
||||
<ModesSupported>1</ModesSupported>
|
||||
<Position>BACK</Position>
|
||||
<MountAngle>90</MountAngle>
|
||||
<CSIInfo>
|
||||
<CSIDCore>0</CSIDCore>
|
||||
<LaneMask>0x1F</LaneMask>
|
||||
<LaneAssign>0x4320</LaneAssign>
|
||||
<ComboMode>0</ComboMode>
|
||||
</CSIInfo>
|
||||
<LensInfo>
|
||||
<FocalLength>4.28</FocalLength>
|
||||
<FNumber>1.7</FNumber>
|
||||
<TotalFocusDistance>0.187</TotalFocusDistance>
|
||||
<HorizontalViewAngle>65.0</HorizontalViewAngle>
|
||||
<VerticalViewAngle>51.0</VerticalViewAngle>
|
||||
<MinFocusDistance>0.1</MinFocusDistance>
|
||||
</LensInfo>
|
||||
</CameraModuleConfig>
|
||||
<CameraModuleConfig>
|
||||
<CameraId>2</CameraId>
|
||||
<SensorName>mot_ov5695</SensorName>
|
||||
<EepromName>ov5695</EepromName>
|
||||
<ChromatixName>mot_ov5695_chromatix</ChromatixName>
|
||||
<ModesSupported>1</ModesSupported>
|
||||
<Position>FRONT</Position>
|
||||
<MountAngle>270</MountAngle>
|
||||
<CSIInfo>
|
||||
<CSIDCore>2</CSIDCore>
|
||||
<LaneMask>0x07</LaneMask>
|
||||
<LaneAssign>0x4320</LaneAssign>
|
||||
<ComboMode>0</ComboMode>
|
||||
</CSIInfo>
|
||||
<LensInfo>
|
||||
<FocalLength>2.44</FocalLength>
|
||||
<FNumber>2.2</FNumber>
|
||||
<TotalFocusDistance>1.26</TotalFocusDistance>
|
||||
<HorizontalViewAngle>72.95</HorizontalViewAngle>
|
||||
<VerticalViewAngle>57.60</VerticalViewAngle>
|
||||
<MinFocusDistance>0.1</MinFocusDistance>
|
||||
</LensInfo>
|
||||
</CameraModuleConfig>
|
||||
</CameraConfigurationRoot>
|
||||
124
configs/camera/ov16860_chromatix.xml
Normal file
124
configs/camera/ov16860_chromatix.xml
Normal file
@@ -0,0 +1,124 @@
|
||||
<!--
|
||||
Copyright (c) 2015 Qualcomm Technologies, Inc.
|
||||
All Rights Reserved.
|
||||
Confidential and Proprietary - Qualcomm Technologies, Inc.
|
||||
-->
|
||||
|
||||
<!--
|
||||
CommonChromatixInfo:
|
||||
CommonChromatixInfo is the information about chromatix needed for
|
||||
various use cases.
|
||||
Ex:- Preview, Snapshot, ZSL, HFR, HDR, Video, Liveshot for ISP, CPP,
|
||||
3A and SW PostProc.
|
||||
Entries in this node are common for all sensor modes.
|
||||
|
||||
ResolutionChromatixInfo:
|
||||
ResolutionChromatixInfo is the information about chromatix needed for
|
||||
various use cases.
|
||||
Ex:- Preview, Snapshot, ZSL, HFR, HDR, Video, Liveshot for ISP, CPP,
|
||||
3A and SW PostProc.
|
||||
Entries in this node are specific to sensor resolution.
|
||||
|
||||
ChromatixName:
|
||||
Contains the list of chromatix names for all modules.
|
||||
special_mode_mask:
|
||||
It is the bit mask for special modes, which is used for
|
||||
chromatix selection.
|
||||
Special modes can be any mode that needs a special chromatix.
|
||||
Ex:- scene mode, DZOOM mode, OIS capture mode, flash mode
|
||||
This is applicable for CommonChromatixInfo and
|
||||
ResolutionChromatixInfo.
|
||||
special_mode_mask="0" means none of the special modes are
|
||||
selected.
|
||||
sensor_resolution_index:
|
||||
It is the sensor resolution index for which chromatix libraries
|
||||
will be choosen.
|
||||
It is applicable only in ResolutionChromatixInfo.
|
||||
|
||||
ISPCommon :
|
||||
Common tuning library name for ISP
|
||||
ISPPreview :
|
||||
Preview tuning library name for ISP
|
||||
ISPSnapshot :
|
||||
Snapshot tuning library name for ISP
|
||||
CPPCommon :
|
||||
Common tuning library name for CPP
|
||||
CPPPreview :
|
||||
Preview tuning library name for CPP
|
||||
CPPSnapshot :
|
||||
Snapshot tuning library name for CPP
|
||||
CPPLiveshot :
|
||||
Liveshot tuning library name for CPP
|
||||
PostProc :
|
||||
Tuning library name for postproc module
|
||||
A3Preview :
|
||||
Preview tuning library for 3A
|
||||
A3Video :
|
||||
Video tuning library for 3A
|
||||
|
||||
Order of Resolution Pick:
|
||||
Assume the current sensor mode is "r" and special mode mask is "s".
|
||||
Chromatix for a module and type is choosen in this order till we find a
|
||||
valid chroamtix file name or else NULL is returned.
|
||||
1) From ResolutionChromatixInfo node for which sensor_resolution_index
|
||||
is "r" and special_mode_mask is "s".
|
||||
2) From CommonChromatixInfo node for which special_mode_mask is "s".
|
||||
3) From ResolutionChromatixInfo node for which sensor_resolution_index
|
||||
is "r" and special_mode_mask is "0".
|
||||
4) From CommonChromatixInfo node for which special_mode_mask is "0".
|
||||
5) NULL is returned if we dont find in any of the above cases.
|
||||
|
||||
special_mode_mask values:
|
||||
SENSOR_SPECIAL_MODE_NONE = 0,
|
||||
SENSOR_SPECIAL_MODE_FLASH = 1,
|
||||
SENSOR_SPECIAL_MODE_ZOOM_UPSCALE = 2,
|
||||
SENSOR_SPECIAL_MODE_ZOOM_DOWNSCALE = 4,
|
||||
SENSOR_SPECIAL_MODE_OIS_CAPTURE = 8,
|
||||
-->
|
||||
|
||||
<ChromatixConfigurationRoot>
|
||||
<CommonChromatixInfo>
|
||||
<ChromatixName special_mode_mask="0">
|
||||
<ISPCommon>ov16860_common</ISPCommon>
|
||||
<PostProc>ov16860_postproc</PostProc>
|
||||
<CPPPreview>ov16860_cpp_snapshot</CPPPreview>
|
||||
<CPPSnapshot>ov16860_cpp_snapshot</CPPSnapshot>
|
||||
</ChromatixName>
|
||||
<ChromatixName special_mode_mask="MOT_4K_VIDEO">
|
||||
<ISPVideo>ov16860_video_4k</ISPVideo>
|
||||
<CPPVideo>ov16860_cpp_video_4k</CPPVideo>
|
||||
<CPPLiveshot>ov16860_cpp_liveshot_4k</CPPLiveshot>
|
||||
<A3Video>ov16860_4k_video_3a</A3Video>
|
||||
</ChromatixName>
|
||||
<ChromatixName special_mode_mask="MOT_ALTM_IHDR_VIDEO">
|
||||
<ISPVideo>ov16860_default_ihdr_video</ISPVideo>
|
||||
<CPPLiveshot>ov16860_cpp_liveshot_ihdr</CPPLiveshot>
|
||||
<A3Video>ov16860_ihdr_video_3a</A3Video>
|
||||
</ChromatixName>
|
||||
<ChromatixName special_mode_mask="MOT_4K_IHDR_VIDEO">
|
||||
<ISPVideo>ov16860_ihdr_video_4k</ISPVideo>
|
||||
<CPPLiveshot>ov16860_cpp_liveshot_4k_ihdr</CPPLiveshot>
|
||||
<A3Video>ov16860_4k_ihdr_video_3a</A3Video>
|
||||
</ChromatixName>
|
||||
</CommonChromatixInfo>
|
||||
<ResolutionChromatixInfo>
|
||||
<ChromatixName sensor_resolution_index="0" special_mode_mask="0">
|
||||
<ISPPreview>ov16860_snapshot</ISPPreview>
|
||||
<ISPSnapshot>ov16860_snapshot</ISPSnapshot>
|
||||
<ISPVideo>ov16860_default_video</ISPVideo>
|
||||
<CPPVideo>ov16860_cpp_video</CPPVideo>
|
||||
<CPPLiveshot>ov16860_cpp_liveshot</CPPLiveshot>
|
||||
<A3Preview>ov16860_zsl_preview_3a</A3Preview>
|
||||
<A3Video>ov16860_zsl_video_3a</A3Video>
|
||||
</ChromatixName>
|
||||
<ChromatixName sensor_resolution_index="1" special_mode_mask="0">
|
||||
<ISPPreview>ov16860_hfr_120</ISPPreview>
|
||||
<ISPSnapshot>ov16860_hfr_120</ISPSnapshot>
|
||||
<ISPVideo>ov16860_hfr_120</ISPVideo>
|
||||
<CPPLiveshot>ov16860_cpp_liveshot</CPPLiveshot>
|
||||
<CPPVideo>ov16860_cpp_hfr_120</CPPVideo>
|
||||
<A3Preview>ov16860_hfr_120_3a</A3Preview>
|
||||
<A3Video>ov16860_hfr_120_3a</A3Video>
|
||||
</ChromatixName>
|
||||
</ResolutionChromatixInfo>
|
||||
</ChromatixConfigurationRoot>
|
||||
110
configs/camera/ov5693_chromatix.xml
Normal file
110
configs/camera/ov5693_chromatix.xml
Normal file
@@ -0,0 +1,110 @@
|
||||
<!--
|
||||
Copyright (c) 2015 Qualcomm Technologies, Inc.
|
||||
All Rights Reserved.
|
||||
Confidential and Proprietary - Qualcomm Technologies, Inc.
|
||||
-->
|
||||
|
||||
<!--
|
||||
CommonChromatixInfo:
|
||||
CommonChromatixInfo is the information about chromatix needed for
|
||||
various use cases.
|
||||
Ex:- Preview, Snapshot, ZSL, HFR, HDR, Video, Liveshot for ISP, CPP,
|
||||
3A and SW PostProc.
|
||||
Entries in this node are common for all sensor modes.
|
||||
|
||||
ResolutionChromatixInfo:
|
||||
ResolutionChromatixInfo is the information about chromatix needed for
|
||||
various use cases.
|
||||
Ex:- Preview, Snapshot, ZSL, HFR, HDR, Video, Liveshot for ISP, CPP,
|
||||
3A and SW PostProc.
|
||||
Entries in this node are specific to sensor resolution.
|
||||
|
||||
ChromatixName:
|
||||
Contains the list of chromatix names for all modules.
|
||||
special_mode_mask:
|
||||
It is the bit mask for special modes, which is used for
|
||||
chromatix selection.
|
||||
Special modes can be any mode that needs a special chromatix.
|
||||
Ex:- scene mode, DZOOM mode, OIS capture mode, flash mode
|
||||
This is applicable for CommonChromatixInfo and
|
||||
ResolutionChromatixInfo.
|
||||
special_mode_mask="0" means none of the special modes are
|
||||
selected.
|
||||
sensor_resolution_index:
|
||||
It is the sensor resolution index for which chromatix libraries
|
||||
will be choosen.
|
||||
It is applicable only in ResolutionChromatixInfo.
|
||||
|
||||
ISPCommon :
|
||||
Common tuning library name for ISP
|
||||
ISPPreview :
|
||||
Preview tuning library name for ISP
|
||||
ISPSnapshot :
|
||||
Snapshot tuning library name for ISP
|
||||
CPPCommon :
|
||||
Common tuning library name for CPP
|
||||
CPPPreview :
|
||||
Preview tuning library name for CPP
|
||||
CPPSnapshot :
|
||||
Snapshot tuning library name for CPP
|
||||
CPPLiveshot :
|
||||
Liveshot tuning library name for CPP
|
||||
PostProc :
|
||||
Tuning library name for postproc module
|
||||
A3Preview :
|
||||
Preview tuning library for 3A
|
||||
A3Video :
|
||||
Video tuning library for 3A
|
||||
|
||||
Order of Resolution Pick:
|
||||
Assume the current sensor mode is "r" and special mode mask is "s".
|
||||
Chromatix for a module and type is choosen in this order till we find a
|
||||
valid chroamtix file name or else NULL is returned.
|
||||
1) From ResolutionChromatixInfo node for which sensor_resolution_index
|
||||
is "r" and special_mode_mask is "s".
|
||||
2) From CommonChromatixInfo node for which special_mode_mask is "s".
|
||||
3) From ResolutionChromatixInfo node for which sensor_resolution_index
|
||||
is "r" and special_mode_mask is "0".
|
||||
4) From CommonChromatixInfo node for which special_mode_mask is "0".
|
||||
5) NULL is returned if we dont find in any of the above cases.
|
||||
|
||||
special_mode_mask values:
|
||||
SENSOR_SPECIAL_MODE_NONE = 0,
|
||||
SENSOR_SPECIAL_MODE_FLASH = 1,
|
||||
SENSOR_SPECIAL_MODE_ZOOM_UPSCALE = 2,
|
||||
SENSOR_SPECIAL_MODE_ZOOM_DOWNSCALE = 4,
|
||||
SENSOR_SPECIAL_MODE_OIS_CAPTURE = 8,
|
||||
-->
|
||||
|
||||
<ChromatixConfigurationRoot>
|
||||
<CommonChromatixInfo>
|
||||
<ChromatixName special_mode_mask="0">
|
||||
<ISPCommon>ov5693_common</ISPCommon>
|
||||
<PostProc>ov5693_postproc</PostProc>
|
||||
<CPPPreview>ov5693_cpp_snapshot</CPPPreview>
|
||||
<CPPSnapshot>ov5693_cpp_snapshot</CPPSnapshot>
|
||||
<CPPLiveshot>ov5693_cpp_liveshot</CPPLiveshot>
|
||||
</ChromatixName>
|
||||
</CommonChromatixInfo>
|
||||
<ResolutionChromatixInfo>
|
||||
<ChromatixName sensor_resolution_index="0" special_mode_mask="0">
|
||||
<ISPPreview>ov5693_snapshot</ISPPreview>
|
||||
<ISPSnapshot>ov5693_snapshot</ISPSnapshot>
|
||||
<ISPVideo>ov5693_default_video</ISPVideo>
|
||||
<ISPLiveshot>ov5693_snapshot</ISPLiveshot>
|
||||
<CPPVideo>ov5693_cpp_video</CPPVideo>
|
||||
<A3Preview>ov5693_snapshot_3a</A3Preview>
|
||||
<A3Video>ov5693_default_video_3a</A3Video>
|
||||
</ChromatixName>
|
||||
<ChromatixName sensor_resolution_index="1" special_mode_mask="0">
|
||||
<ISPPreview>ov5693_hfr_120</ISPPreview>
|
||||
<ISPSnapshot>ov5693_hfr_120</ISPSnapshot>
|
||||
<ISPVideo>ov5693_hfr_120</ISPVideo>
|
||||
<ISPLiveshot>ov5693_hfr_120</ISPLiveshot>
|
||||
<CPPVideo>ov5693_cpp_hfr_120</CPPVideo>
|
||||
<A3Preview>ov5693_hfr_120_3a</A3Preview>
|
||||
<A3Video>ov5693_hfr_120_3a</A3Video>
|
||||
</ChromatixName>
|
||||
</ResolutionChromatixInfo>
|
||||
</ChromatixConfigurationRoot>
|
||||
|
||||
5
configs/com.motorola.cameraone.xml
Normal file
5
configs/com.motorola.cameraone.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
<permissions>
|
||||
<feature name="com.motorola.cameraone" />
|
||||
</permissions>
|
||||
403
configs/libnfc-brcm.conf
Normal file
403
configs/libnfc-brcm.conf
Normal file
@@ -0,0 +1,403 @@
|
||||
###################### Start of libnfc-common.conf #######################
|
||||
|
||||
###############################################################################
|
||||
# Application options
|
||||
APPL_TRACE_LEVEL=0xFF
|
||||
PROTOCOL_TRACE_LEVEL=0xFFFFFFFF
|
||||
|
||||
###############################################################################
|
||||
# performance measurement
|
||||
# Change this setting to control how often USERIAL log the performance (throughput)
|
||||
# data on read/write/poll
|
||||
# defailt is to log performance dara for every 100 read or write
|
||||
#REPORT_PERFORMANCE_MEASURE=100
|
||||
|
||||
###############################################################################
|
||||
# File used for NFA storage
|
||||
NFA_STORAGE="/data/nfc"
|
||||
|
||||
###############################################################################
|
||||
# Snooze Mode Settings
|
||||
#
|
||||
# By default snooze mode is enabled. Set SNOOZE_MODE_CFG byte[0] to 0
|
||||
# to disable.
|
||||
#
|
||||
# If SNOOZE_MODE_CFG is not provided, the default settings are used:
|
||||
# They are as follows:
|
||||
# 8 Sleep Mode (0=Disabled 1=UART 8=SPI/I2C)
|
||||
# 0 Idle Threshold Host
|
||||
# 0 Idle Threshold HC
|
||||
# 0 NFC Wake active mode (0=ActiveLow 1=ActiveHigh)
|
||||
# 1 Host Wake active mode (0=ActiveLow 1=ActiveHigh)
|
||||
#
|
||||
#SNOOZE_MODE_CFG={08:00:00:00:01}
|
||||
|
||||
###############################################################################
|
||||
# Insert a delay in milliseconds after NFC_WAKE and before write to NFCC
|
||||
#NFC_WAKE_DELAY=20
|
||||
|
||||
###############################################################################
|
||||
# Various Delay settings (in ms) used in USERIAL
|
||||
# POWER_ON_DELAY
|
||||
# Delay after turning on chip, before writing to transport (default 300)
|
||||
# PRE_POWER_OFF_DELAY
|
||||
# Delay after deasserting NFC-Wake before turn off chip (default 0)
|
||||
# POST_POWER_OFF_DELAY
|
||||
# Delay after turning off chip, before USERIAL_close returns (default 0)
|
||||
#
|
||||
#POWER_ON_DELAY=300
|
||||
#PRE_POWER_OFF_DELAY=0
|
||||
#POST_POWER_OFF_DELAY=0
|
||||
|
||||
###############################################################################
|
||||
# Maximum time (ms) to wait for RESET NTF after setting REG_PU to high
|
||||
# The default is 1000.
|
||||
#NFCC_ENABLE_TIMEOUT=0
|
||||
|
||||
###############################################################################
|
||||
# LPTD mode configuration
|
||||
# byte[0] is the length of the remaining bytes in this value
|
||||
# if set to 0, LPTD params will NOT be sent to NFCC (i.e. disabled).
|
||||
# byte[1] is the param id it should be set to B9.
|
||||
# byte[2] is the length of the LPTD parameters
|
||||
# byte[3] indicates if LPTD is enabled
|
||||
# if set to 0, LPTD will be disabled (parameters will still be sent).
|
||||
# byte[4-n] are the LPTD parameters.
|
||||
# By default, LPTD is enabled and default settings are used.
|
||||
# See nfc_hal_dm_cfg.c for defaults
|
||||
#LPTD_CFG={23:B9:21:01:02:FF:FF:04:A0:0F:40:00:80:02:02:10:00:00:00:31:0C:30:00:00:00:00:00:00:00:00:00:00:00:00:00:00}
|
||||
|
||||
###############################################################################
|
||||
# Startup Configuration (100 bytes maximum)
|
||||
#
|
||||
# For the 0xCA parameter, byte[9] (marked by 'AA') is for UICC0, and byte[10] (marked by BB) is
|
||||
# for UICC1. The values are defined as:
|
||||
# 0 : UICCx only supports ISO_DEP in low power mode.
|
||||
# 2 : UICCx only supports Mifare in low power mode.
|
||||
# 3 : UICCx supports both ISO_DEP and Mifare in low power mode.
|
||||
#
|
||||
# AA BB
|
||||
#NFA_DM_START_UP_CFG={1F:CB:01:01:A5:01:01:CA:14:00:00:00:00:06:E8:03:00:00:00:00:00:00:00:00:00:00:00:00:00:80:01:01}
|
||||
|
||||
###############################################################################
|
||||
# Startup Vendor Specific Configuration (100 bytes maximum);
|
||||
# byte[0] TLV total len = 0x5
|
||||
# byte[1] NCI_MTS_CMD|NCI_GID_PROP = 0x2f
|
||||
# byte[2] NCI_MSG_FRAME_LOG = 0x9
|
||||
# byte[3] 2
|
||||
# byte[4] 0=turn off RF frame logging; 1=turn on
|
||||
# byte[5] 0=turn off SWP frame logging; 1=turn on
|
||||
# NFA_DM_START_UP_VSC_CFG={05:2F:09:02:01:01}
|
||||
|
||||
###############################################################################
|
||||
# Antenna Configuration - This data is used when setting 0xC8 config item
|
||||
# at startup (before discovery is started). If not used, no value is sent.
|
||||
#
|
||||
# The settings for this value are documented here:
|
||||
# http://wcgbu.broadcom.com/wpan/PM/Project%20Document%20Library/bcm20791B0/
|
||||
# Design/Doc/PHY%20register%20settings/BCM20791-B2-1027-02_PHY_Recommended_Reg_Settings.xlsx
|
||||
# This document is maintained by Paul Forshaw.
|
||||
#
|
||||
# The values marked as ?? should be tweaked per antenna or customer/app:
|
||||
# {20:C8:1E:06:??:00:??:??:??:00:??:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:??:01:00:00:40:04}
|
||||
# array[0] = 0x20 is length of the payload from array[1] to the end
|
||||
# array[1] = 0xC8 is PREINIT_DSP_CFG
|
||||
#PREINIT_DSP_CFG={20:C8:1E:06:1F:00:0F:03:3C:00:04:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:48:01:00:00:40:04}
|
||||
|
||||
###############################################################################
|
||||
# Configure crystal frequency when internal LPO can't detect the frequency.
|
||||
#XTAL_FREQUENCY=0
|
||||
###############################################################################
|
||||
# Configure the default Destination Gate used by HCI (the default is 4, which
|
||||
# is the ETSI loopback gate.
|
||||
NFA_HCI_DEFAULT_DEST_GATE=0xF0
|
||||
|
||||
###############################################################################
|
||||
# Configure the single default SE to use. The default is to use the first
|
||||
# SE that is detected by the stack. This value might be used when the phone
|
||||
# supports multiple SE (e.g. 0xF3 and 0xF4) but you want to force it to use
|
||||
# one of them (e.g. 0xF4).
|
||||
#ACTIVE_SE=0xF3
|
||||
|
||||
###############################################################################
|
||||
# Configure the default NfcA/IsoDep techology and protocol route. Can be
|
||||
# either a secure element (e.g. 0xF4) or the host (0x00)
|
||||
#DEFAULT_ISODEP_ROUTE=0x00
|
||||
|
||||
###############################################################################
|
||||
# Configure the NFC Extras to open and use a static pipe. If the value is
|
||||
# not set or set to 0, then the default is use a dynamic pipe based on a
|
||||
# destination gate (see NFA_HCI_DEFAULT_DEST_GATE). Note there is a value
|
||||
# for each UICC (where F3="UICC0" and F4="UICC1")
|
||||
#NFA_HCI_STATIC_PIPE_ID_F3=0x70
|
||||
#NFA_HCI_STATIC_PIPE_ID_01=0x19
|
||||
NFA_HCI_STATIC_PIPE_ID_C0=0x19
|
||||
###############################################################################
|
||||
# When disconnecting from Oberthur secure element, perform a warm-reset of
|
||||
# the secure element to deselect the applet.
|
||||
# The default hex value of the command is 0x3. If this variable is undefined,
|
||||
# then this feature is not used.
|
||||
#OBERTHUR_WARM_RESET_COMMAND=0x03
|
||||
|
||||
###############################################################################
|
||||
# Force UICC to only listen to the following technology(s).
|
||||
# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
|
||||
# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B | NFA_TECHNOLOGY_MASK_F
|
||||
UICC_LISTEN_TECH_MASK=0x07
|
||||
|
||||
# Forcing HOST to listen for a selected technology
|
||||
# 0x00 : Disable Host Listen
|
||||
# 0x01 : Enable Host Listen for Tech A
|
||||
# 0x02 : Enable Host Listen for Tech B
|
||||
# 0x03 : Enable Host Listen for Tech AB
|
||||
HOST_LISTEN_TECH_MASK=0x03
|
||||
|
||||
###############################################################################
|
||||
# Enabling/Disabling Forward functionality
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_FWD_FUNCTIONALITY_ENABLE=0x01
|
||||
|
||||
###############################################################################
|
||||
# Allow UICC to be powered off if there is no traffic.
|
||||
# Timeout is in ms. If set to 0, then UICC will not be powered off.
|
||||
#UICC_IDLE_TIMEOUT=30000
|
||||
UICC_IDLE_TIMEOUT=0
|
||||
|
||||
###############################################################################
|
||||
# AID for Empty Select command
|
||||
# If specified, this AID will be substituted when an Empty SELECT command is
|
||||
# detected. The first byte is the length of the AID. Maximum length is 16.
|
||||
AID_FOR_EMPTY_SELECT={08:A0:00:00:01:51:00:00:00}
|
||||
###############################################################################
|
||||
# Maximum Number of Credits to be allowed by the NFCC
|
||||
# This value overrides what the NFCC specifices allowing the host to have
|
||||
# the control to work-around transport limitations. If this value does
|
||||
# not exist or is set to 0, the NFCC will provide the number of credits.
|
||||
MAX_RF_DATA_CREDITS=1
|
||||
|
||||
###############################################################################
|
||||
# This setting allows you to disable registering the T4t Virtual SE that causes
|
||||
# the NFCC to send PPSE requests to the DH.
|
||||
# The default setting is enabled (i.e. T4t Virtual SE is registered).
|
||||
#REGISTER_VIRTUAL_SE=1
|
||||
|
||||
###############################################################################
|
||||
# When screen is turned off, specify the desired power state of the controller.
|
||||
# 0: power-off-sleep state; DEFAULT
|
||||
# 1: full-power state
|
||||
# 2: screen-off card-emulation (CE4/CE3/CE1 modes are used)
|
||||
SCREEN_OFF_POWER_STATE=1
|
||||
|
||||
###############################################################################
|
||||
# Firmware patch file
|
||||
# If the value is not set then patch download is disabled.
|
||||
#FW_PATCH="/vendor/firmware/bcm2079x_firmware.ncd"
|
||||
|
||||
###############################################################################
|
||||
# Firmware pre-patch file (sent before the above patch file)
|
||||
# If the value is not set then pre-patch is not used.
|
||||
#FW_PRE_PATCH="/vendor/firmware/bcm2079x_pre_firmware.ncd"
|
||||
|
||||
###############################################################################
|
||||
# Firmware patch format
|
||||
# 1 = HCD
|
||||
# 2 = NCD (default)
|
||||
#NFA_CONFIG_FORMAT=2
|
||||
|
||||
###############################################################################
|
||||
# SPD Debug mode
|
||||
# If set to 1, any failure of downloading a patch will trigger a hard-stop
|
||||
#SPD_DEBUG=0
|
||||
|
||||
###############################################################################
|
||||
# SPD Max Retry Count
|
||||
# The number of attempts to download a patch before giving up (defualt is 3).
|
||||
# Note, this resets after a power-cycle.
|
||||
#SPD_MAX_RETRY_COUNT=3
|
||||
|
||||
###############################################################################
|
||||
# transport driver
|
||||
#
|
||||
# TRANSPORT_DRIVER=<driver>
|
||||
#
|
||||
# where <driver> can be, for example:
|
||||
# "/dev/ttyS" (UART)
|
||||
# "/dev/bcmi2cnfc" (I2C)
|
||||
# "hwtun" (HW Tunnel)
|
||||
# "/dev/bcmspinfc" (SPI)
|
||||
# "/dev/btusb0" (BT USB)
|
||||
#TRANSPORT_DRIVER="/dev/bcm2079x-i2c"
|
||||
|
||||
###############################################################################
|
||||
# power control driver
|
||||
# Specify a kernel driver that support ioctl commands to control NFC_EN and
|
||||
# NFC_WAKE gpio signals.
|
||||
#
|
||||
# POWER_CONTRL_DRIVER=<driver>
|
||||
# where <driver> can be, for example:
|
||||
# "/dev/nfcpower"
|
||||
# "/dev/bcmi2cnfc" (I2C)
|
||||
# "/dev/bcmspinfc" (SPI)
|
||||
# i2c and spi driver may be used to control NFC_EN and NFC_WAKE signal
|
||||
#POWER_CONTROL_DRIVER="/dev/bcm2079x-i2c"
|
||||
|
||||
###############################################################################
|
||||
# I2C transport driver options
|
||||
# Mako does not support 10-bit I2C addresses
|
||||
# Revert to 7-bit address
|
||||
#BCMI2CNFC_ADDRESS=0x77
|
||||
|
||||
###############################################################################
|
||||
# I2C transport driver try to read multiple packets in read() if data is available
|
||||
# remove the comment below to enable this feature
|
||||
#READ_MULTIPLE_PACKETS=1
|
||||
|
||||
###############################################################################
|
||||
# SPI transport driver options
|
||||
#SPI_NEGOTIATION={0A:F0:00:01:00:00:00:FF:FF:00:00}
|
||||
|
||||
###############################################################################
|
||||
# UART transport driver options
|
||||
#
|
||||
# PORT=1,2,3,...
|
||||
# BAUD=115200, 19200, 9600, 4800,
|
||||
# DATABITS=8, 7, 6, 5
|
||||
# PARITY="even" | "odd" | "none"
|
||||
# STOPBITS="0" | "1" | "1.5" | "2"
|
||||
|
||||
#UART_PORT=2
|
||||
#UART_BAUD=115200
|
||||
#UART_DATABITS=8
|
||||
#UART_PARITY="none"
|
||||
#UART_STOPBITS="1"
|
||||
|
||||
###############################################################################
|
||||
# Insert a delay in microseconds per byte after a write to NFCC.
|
||||
# after writing a block of data to the NFCC, delay this an amopunt of time before
|
||||
# writing next block of data. the delay is calculated as below
|
||||
# NFC_WRITE_DELAY * (number of byte written) / 1000 milliseconds
|
||||
# e.g. after 259 bytes is written, delay (259 * 20 / 1000) 5 ms before next write
|
||||
#NFC_WRITE_DELAY=20
|
||||
|
||||
###############################################################################
|
||||
# Maximum Number of Credits to be allowed by the NFCC
|
||||
# This value overrides what the NFCC specifices allowing the host to have
|
||||
# the control to work-around transport limitations. If this value does
|
||||
# not exist or is set to 0, the NFCC will provide the number of credits.
|
||||
MAX_RF_DATA_CREDITS=1
|
||||
|
||||
###############################################################################
|
||||
# Default poll duration (in ms)
|
||||
# The defualt is 500ms if not set (see nfc_target.h)
|
||||
#NFA_DM_DISC_DURATION_POLL=333
|
||||
###############################################################################
|
||||
# Antenna Configuration - This data is used when setting 0xC8 config item
|
||||
# at startup (before discovery is started). If not used, no value is sent.
|
||||
#
|
||||
# The settings for this value are documented here:
|
||||
# http://wcgbu.broadcom.com/wpan/PM/Project%20Document%20Library/bcm20791B0/
|
||||
# Design/Doc/PHY%20register%20settings/BCM20791-B2-1027-02_PHY_Recommended_Reg_Settings.xlsx
|
||||
# This document is maintained by Paul Forshaw.
|
||||
#
|
||||
# The values marked as ?? should be tweaked per antenna or customer/app:
|
||||
# {20:C8:1E:06:??:00:??:??:??:00:??:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:??:01:00:00:40:04}
|
||||
# array[0] = 0x20 is length of the payload from array[1] to the end
|
||||
# array[1] = 0xC8 is PREINIT_DSP_CFG
|
||||
#PREINIT_DSP_CFG={20:C8:1E:06:1F:00:0F:03:3C:00:04:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:48:01:00:00:40:04}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Choose the presence-check algorithm for type-4 tag. If not defined, the default value is 1.
|
||||
# 0 NFA_RW_PRES_CHK_DEFAULT; Let stack selects an algorithm
|
||||
# 1 NFA_RW_PRES_CHK_I_BLOCK; ISO-DEP protocol's empty I-block
|
||||
# 2 NFA_RW_PRES_CHK_RESET; Deactivate to Sleep, then re-activate
|
||||
# 3 NFA_RW_PRES_CHK_RB_CH0; Type-4 tag protocol's ReadBinary command on channel 0
|
||||
# 4 NFA_RW_PRES_CHK_RB_CH3; Type-4 tag protocol's ReadBinary command on channel 3
|
||||
PRESENCE_CHECK_ALGORITHM=1
|
||||
|
||||
###############################################################################
|
||||
# Force tag polling for the following technology(s).
|
||||
# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
|
||||
# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B |
|
||||
# NFA_TECHNOLOGY_MASK_F | NFA_TECHNOLOGY_MASK_ISO15693 |
|
||||
# NFA_TECHNOLOGY_MASK_B_PRIME | NFA_TECHNOLOGY_MASK_KOVIO |
|
||||
# NFA_TECHNOLOGY_MASK_A_ACTIVE | NFA_TECHNOLOGY_MASK_F_ACTIVE.
|
||||
#
|
||||
# Notable bits:
|
||||
# NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */
|
||||
# NFA_TECHNOLOGY_MASK_B 0x02 /* NFC Technology B */
|
||||
# NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */
|
||||
# NFA_TECHNOLOGY_MASK_ISO15693 0x08 /* Proprietary Technology */
|
||||
# NFA_TECHNOLOGY_MASK_KOVIO 0x20 /* Proprietary Technology */
|
||||
# NFA_TECHNOLOGY_MASK_A_ACTIVE 0x40 /* NFC Technology A active mode */
|
||||
# NFA_TECHNOLOGY_MASK_F_ACTIVE 0x80 /* NFC Technology F active mode */
|
||||
POLLING_TECH_MASK=0xEF
|
||||
|
||||
###############################################################################
|
||||
# Force P2P to only listen for the following technology(s).
|
||||
# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h.
|
||||
# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_F |
|
||||
# NFA_TECHNOLOGY_MASK_A_ACTIVE | NFA_TECHNOLOGY_MASK_F_ACTIVE
|
||||
#
|
||||
# Notable bits:
|
||||
# NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */
|
||||
# NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */
|
||||
# NFA_TECHNOLOGY_MASK_A_ACTIVE 0x40 /* NFC Technology A active mode */
|
||||
# NFA_TECHNOLOGY_MASK_F_ACTIVE 0x80 /* NFC Technology F active mode */
|
||||
P2P_LISTEN_TECH_MASK=0xC5
|
||||
|
||||
PRESERVE_STORAGE=0x01
|
||||
|
||||
###############################################################################
|
||||
# Override the stack default for NFA_EE_MAX_EE_SUPPORTED set in nfc_target.h.
|
||||
# The value is set to 3 by default as it assumes we will discover 0xF2,
|
||||
# 0xF3, and 0xF4. If a platform will exclude and SE, this value can be reduced
|
||||
# so that the stack will not wait any longer than necessary.
|
||||
|
||||
# Maximum EE supported number
|
||||
# NXP PN547C2 0x02
|
||||
# NXP PN65T 0x03
|
||||
# NXP PN548C2 0x02
|
||||
# NXP PN66T 0x03
|
||||
NFA_MAX_EE_SUPPORTED=0x02
|
||||
|
||||
###############################################################################
|
||||
# NCI Hal Module name
|
||||
NCI_HAL_MODULE="nfc_nci.pn54x"
|
||||
|
||||
##############################################################################
|
||||
# Deactivate notification wait time out in seconds used in ETSI Reader mode
|
||||
# 0 - Infinite wait
|
||||
NFA_DM_DISC_NTF_TIMEOUT=100
|
||||
|
||||
###############################################################################
|
||||
# AID_MATCHING constants
|
||||
# AID_MATCHING_EXACT_ONLY 0x00
|
||||
# AID_MATCHING_EXACT_OR_PREFIX 0x01
|
||||
# AID_MATCHING_PREFIX_ONLY 0x02
|
||||
AID_MATCHING_MODE=0x01
|
||||
|
||||
###############################################################################
|
||||
# Default Secure Element route id
|
||||
DEFAULT_OFFHOST_ROUTE=0x02
|
||||
|
||||
###############################################################################
|
||||
# Vendor Specific Proprietary Protocol & Discovery Configuration
|
||||
# Set to 0xFF if unsupported
|
||||
# byte[0] NCI_PROTOCOL_18092_ACTIVE
|
||||
# byte[1] NCI_PROTOCOL_B_PRIME
|
||||
# byte[2] NCI_PROTOCOL_DUAL
|
||||
# byte[3] NCI_PROTOCOL_15693
|
||||
# byte[4] NCI_PROTOCOL_KOVIO
|
||||
# byte[5] NCI_PROTOCOL_MIFARE
|
||||
# byte[6] NCI_DISCOVERY_TYPE_POLL_KOVIO
|
||||
# byte[7] NCI_DISCOVERY_TYPE_POLL_B_PRIME
|
||||
# byte[8] NCI_DISCOVERY_TYPE_LISTEN_B_PRIME
|
||||
NFA_PROPRIETARY_CFG={05:FF:FF:06:81:80:70:FF:FF}
|
||||
|
||||
#################################################################################
|
||||
# Bail out mode
|
||||
# If set to 1, NFCC is using bail out mode for either Type A or Type B poll.
|
||||
NFA_POLL_BAIL_OUT_MODE=0x01
|
||||
#################################################################################
|
||||
361
configs/libnfc-nxp.conf
Normal file
361
configs/libnfc-nxp.conf
Normal file
@@ -0,0 +1,361 @@
|
||||
###############################################################################
|
||||
## Modified by Motorola Mobility LLC
|
||||
## Version : 3.5.2 (2016/06/21)
|
||||
## added RF Blk 4 (21 to 22) and rf blk 5 (from 47 to 77) and rf blk 6 (from 10 to 00)
|
||||
## This file is used by NFC NXP NCI HAL(external/libnfc-nci/halimpl/pn547)
|
||||
## and NFC Service Java Native Interface Extensions (packages/apps/Nfc/nci/jni/extns/pn547)
|
||||
## CLIF_ANA_TX_AMPLITUDE_REG_TYPE_B_TERMINAL_M
|
||||
## CLIF_ANA_TX_AMPLITUDE_REG_TYPE_B_TERMINAL_M change 90 to 00
|
||||
|
||||
###############################################################################
|
||||
# Application options
|
||||
# Logging Levels
|
||||
# NXPLOG_DEFAULT_LOGLEVEL 0x01
|
||||
# ANDROID_LOG_DEBUG 0x03
|
||||
# ANDROID_LOG_WARN 0x02
|
||||
# ANDROID_LOG_ERROR 0x01
|
||||
# ANDROID_LOG_SILENT 0x00
|
||||
#
|
||||
NXPLOG_EXTNS_LOGLEVEL=0x03
|
||||
NXPLOG_NCIHAL_LOGLEVEL=0x03
|
||||
NXPLOG_NCIX_LOGLEVEL=0x03
|
||||
NXPLOG_NCIR_LOGLEVEL=0x03
|
||||
NXPLOG_FWDNLD_LOGLEVEL=0x03
|
||||
NXPLOG_TML_LOGLEVEL=0x03
|
||||
|
||||
###############################################################################
|
||||
# Nfc Device Node name
|
||||
NXP_NFC_DEV_NODE="/dev/pn544"
|
||||
|
||||
###############################################################################
|
||||
# Extension for Mifare reader enable
|
||||
MIFARE_READER_ENABLE=0x01
|
||||
|
||||
###############################################################################
|
||||
# Vzw Feature enable
|
||||
VZW_FEATURE_ENABLE=0x01
|
||||
|
||||
###############################################################################
|
||||
# File name for Firmware
|
||||
NXP_FW_NAME="libpn548ad_fw.so"
|
||||
|
||||
###############################################################################
|
||||
# System clock source selection configuration
|
||||
#define CLK_SRC_XTAL 1
|
||||
#define CLK_SRC_PLL 2
|
||||
|
||||
NXP_SYS_CLK_SRC_SEL=0x01
|
||||
|
||||
###############################################################################
|
||||
# System clock frequency selection configuration
|
||||
#define CLK_FREQ_13MHZ 1
|
||||
#define CLK_FREQ_19_2MHZ 2
|
||||
#define CLK_FREQ_24MHZ 3
|
||||
#define CLK_FREQ_26MHZ 4
|
||||
#define CLK_FREQ_38_4MHZ 5
|
||||
#define CLK_FREQ_52MHZ 6
|
||||
|
||||
NXP_SYS_CLK_FREQ_SEL=0x04
|
||||
|
||||
###############################################################################
|
||||
# The timeout value to be used for clock request acknowledgment
|
||||
# min value = 0x01 to max = 0x06
|
||||
|
||||
NXP_SYS_CLOCK_TO_CFG=0x01
|
||||
|
||||
###############################################################################
|
||||
# NXP proprietary settings
|
||||
NXP_ACT_PROP_EXTN={2F, 02, 00}
|
||||
|
||||
###############################################################################
|
||||
# NFC forum profile settings
|
||||
NXP_NFC_PROFILE_EXTN={20, 02, 05, 01, A0, 44, 01, 00}
|
||||
|
||||
###############################################################################
|
||||
# NFCC Configuration Control
|
||||
# Allow NFCC to manage RF Config 0x01
|
||||
# Don't allow NFCC to manage RF Config 0x00
|
||||
NXP_NFC_MERGE_RF_PARAMS={20, 02, 04, 01, 85, 01, 01}
|
||||
|
||||
###############################################################################
|
||||
# Standby enable settings
|
||||
NXP_CORE_STANDBY={2F, 00, 01, 01}
|
||||
|
||||
###############################################################################
|
||||
# NXP TVDD configurations settings
|
||||
# Allow NFCC to configure External TVDD, There are currently three
|
||||
#configurations (1, 2 and 3) are supported, out of them only one can be
|
||||
#supported.
|
||||
|
||||
NXP_EXT_TVDD_CFG=0x02
|
||||
|
||||
#config1:SLALM, 3.3V for both RM and CM
|
||||
NXP_EXT_TVDD_CFG_1={20, 02, 0B, 02, A0, 66, 01, 00, A0, 0E, 03, 02, 09, 00}
|
||||
|
||||
#config2: use DCDC in CE, use Tx_Pwr_Req, set CFG2 mode, SLALM,
|
||||
#monitoring 5V from DCDC, 4.7V for both RM and CM, DCDCWaitTime=4.2ms
|
||||
NXP_EXT_TVDD_CFG_2={20, 02, 0B, 02, A0, 66, 01, 00, A0, 0E, 03, 56, 64, 0A}
|
||||
|
||||
#config3: use DCDC in CE, use Tx_Pwr_Req, SLALM, monitoring 5V from DCDC,
|
||||
#DCDCWaitTime=4.2ms
|
||||
NXP_EXT_TVDD_CFG_3={20, 02, 0B, 02, A0, 66, 01, 01, A0, 0E, 03, 52, 64, 0A}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
NXP_RF_CONF_BLK_1={
|
||||
20, 02, 1E, 2,
|
||||
A0, 1D, 11, 54, 33, 14, 17, 00, AA, 85, 00, 80, 55, 2A, 04, 00, 63, 00, 00, 00,
|
||||
A0, 0D, 06, 06, 03, 00, 6F, 00, 20
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
NXP_RF_CONF_BLK_2={
|
||||
20, 02, 13, 02,
|
||||
A0, 0D, 06, 06, 30, B0, 00, 10, 00,
|
||||
A0, 0D, 06, 7C, 30, B0, 00, 10, 00
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
NXP_RF_CONF_BLK_3={
|
||||
20, 02, 07, 01,
|
||||
A0, 0D, 03, 00, 40, 03
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
# RF_CLIF_CFG_BR_106_I_RXA_P CLIF_ANA_RX_REG change from 21 to 22
|
||||
NXP_RF_CONF_BLK_4={
|
||||
20, 02, 1D, 04,
|
||||
A0, 0D, 04, 34, 44, 22, 00,
|
||||
A0, 0D, 04, 46, 44, 22, 00,
|
||||
A0, 0D, 04, 56, 44, 22, 00,
|
||||
A0, 0D, 04, 5C, 44, 26, 00
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform, Min_level
|
||||
# RF_CLIF_CFG_BR_106_I_RXA_P CLIF_SIGPRO_RM_CONFIG1_REG change from 47 to 77
|
||||
NXP_RF_CONF_BLK_5={
|
||||
20, 02, 0A, 01,
|
||||
A0, 0D, 06, 34, 2D, 24, 77, 0C, 00
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
# RF_CLIF_CFG_BR_106_I_TXA CLIF_ANA_TX_AMPLITUDE_REG change from 10 to 00
|
||||
# RF_CLIF_CFG_BR_106_T_TXB
|
||||
NXP_RF_CONF_BLK_6={
|
||||
20, 02, 2E, 05,
|
||||
A0, 0D, 06, 32, 42, F8, 00, FF, FF,
|
||||
A0, 0D, 06, 44, 42, 88, 00, FF, FF,
|
||||
A0, 0D, 06, 54, 42, 88, 00, FF, FF,
|
||||
A0, 0D, 06, 5A, 42, 90, 00, FF, FF,
|
||||
A0, 0D, 06, 98, 42, 00, 00, FF, FF
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
## Set configuration optimization decision setting
|
||||
## Enable = 0x01
|
||||
## Disable = 0x00
|
||||
NXP_SET_CONFIG_ALWAYS=0x01
|
||||
|
||||
###############################################################################
|
||||
# Core configuration extensions
|
||||
# It includes
|
||||
# Wired mode settings A0ED, A0EE
|
||||
# Tag Detector A040, A041, A043
|
||||
# Low Power mode A007
|
||||
# Clock settings A002, A003
|
||||
# PbF settings A008
|
||||
NXP_CORE_CONF_EXTN={20, 02, 1D, 07,
|
||||
A0, EC, 01, 01,
|
||||
A0, ED, 01, 00,
|
||||
A0, 5E, 01, 01,
|
||||
A0, 40, 01, 01,
|
||||
A0, DD, 01, 2D,
|
||||
A0, 41, 01, 02,
|
||||
A0, 96, 01, 01
|
||||
}
|
||||
# A0, 41, 01, 02,
|
||||
# A0, 43, 01, 04,
|
||||
# A0, 02, 01, 01,
|
||||
# A0, 03, 01, 11,
|
||||
# A0, 07, 01, 03,
|
||||
# A0, 08, 01, 01
|
||||
# }
|
||||
|
||||
###############################################################################
|
||||
# Core configuration rf field filter settings to enable set to 01 to disable set to 00 last bit
|
||||
NXP_CORE_RF_FIELD={ 20, 02, 05, 01, A0, 62, 01, 01
|
||||
}
|
||||
###############################################################################
|
||||
# To enable i2c fragmentation set i2c fragmentation enable 0x01 to disable set to 0x00
|
||||
NXP_I2C_FRAGMENTATION_ENABLED=0x00
|
||||
|
||||
###############################################################################
|
||||
# Core configuration settings
|
||||
NXP_CORE_CONF={ 20, 02, 31, 0F,
|
||||
28, 01, 00,
|
||||
21, 01, 00,
|
||||
30, 01, 08,
|
||||
31, 01, 03,
|
||||
33, 04, 01, 02, 03, 04,
|
||||
54, 01, 06,
|
||||
50, 01, 02,
|
||||
5B, 01, 00,
|
||||
60, 01, 0E,
|
||||
80, 01, 01,
|
||||
81, 01, 01,
|
||||
82, 01, 0E,
|
||||
18, 01, 01,
|
||||
32, 01, 60,
|
||||
38, 01, 01
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Mifare Classic Key settings
|
||||
#NXP_CORE_MFCKEY_SETTING={20, 02, 25,04, A0, 51, 06, A0, A1, A2, A3, A4, A5,
|
||||
# A0, 52, 06, D3, F7, D3, F7, D3, F7,
|
||||
# A0, 53, 06, FF, FF, FF, FF, FF, FF,
|
||||
# A0, 54, 06, 00, 00, 00, 00, 00, 00}
|
||||
|
||||
###############################################################################
|
||||
# Default SE Options
|
||||
# No secure element 0x00
|
||||
# eSE 0x01
|
||||
# UICC 0x02
|
||||
|
||||
NXP_DEFAULT_SE=0x02
|
||||
|
||||
###############################################################################
|
||||
#Enable SWP full power mode when phone is power off
|
||||
NXP_SWP_FULL_PWR_ON=0x00
|
||||
|
||||
###############################################################################
|
||||
#### Select the CHIP ####
|
||||
#PN547C2 0x01
|
||||
#PN65T 0x02
|
||||
#PN548AD 0x03
|
||||
#PN66T 0x04
|
||||
|
||||
NXP_NFC_CHIP=0x03
|
||||
|
||||
###############################################################################
|
||||
# CE when Screen state is locked
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_CE_ROUTE_STRICT_DISABLE=0x01
|
||||
|
||||
#Timeout in secs to get NFCEE Discover notification
|
||||
NXP_DEFAULT_NFCEE_DISC_TIMEOUT=20
|
||||
|
||||
NXP_DEFAULT_NFCEE_TIMEOUT=0x06
|
||||
|
||||
#Timeout in secs
|
||||
NXP_SWP_RD_START_TIMEOUT=0x0A
|
||||
|
||||
#Timeout in secs
|
||||
NXP_SWP_RD_TAG_OP_TIMEOUT=0x01
|
||||
|
||||
###############################################################################
|
||||
#Set the default AID route Location :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# host 0x00
|
||||
# eSE 0x01
|
||||
# UICC 0x02
|
||||
DEFAULT_AID_ROUTE=0x02
|
||||
|
||||
###############################################################################
|
||||
#Set the Mifare Desfire route Location :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# host 0x00
|
||||
# eSE 0x01
|
||||
# UICC 0x02
|
||||
DEFAULT_DESFIRE_ROUTE=0x02
|
||||
|
||||
###############################################################################
|
||||
#Set the Mifare CLT route Location :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# host 0x00
|
||||
# eSE 0x01
|
||||
# UICC 0x02
|
||||
DEFAULT_MIFARE_CLT_ROUTE=0x02
|
||||
|
||||
###############################################################################
|
||||
#Set the default AID Power state :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# bit pos 0 = Switch On
|
||||
# bit pos 1 = Switch Off
|
||||
# bit pos 2 = Battery Off
|
||||
# bit pos 3 = Screen Lock
|
||||
# bit pos 4 = Screen Off
|
||||
DEFAULT_AID_PWR_STATE=0x9
|
||||
|
||||
###############################################################################
|
||||
#Set the Mifare Desfire Power state :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# bit pos 0 = Switch On
|
||||
# bit pos 1 = Switch Off
|
||||
# bit pos 2 = Battery Off
|
||||
# bit pos 3 = Screen Lock
|
||||
# bit pos 4 = Screen Off
|
||||
DEFAULT_DESFIRE_PWR_STATE=0x1B
|
||||
|
||||
###############################################################################
|
||||
#Set the Mifare CLT Power state :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# bit pos 0 = Switch On
|
||||
# bit pos 1 = Switch Off
|
||||
# bit pos 2 = Battery Off
|
||||
# bit pos 3 = Screen Lock
|
||||
# bit pos 4 = Screen Off
|
||||
DEFAULT_MIFARE_CLT_PWR_STATE=0x1B
|
||||
|
||||
###############################################################################
|
||||
# AID Matching platform options
|
||||
# AID_MATCHING_L 0x01
|
||||
# AID_MATCHING_K 0x02
|
||||
AID_MATCHING_PLATFORM=0x01
|
||||
###############################################################################
|
||||
#CHINA_TIANJIN_RF_SETTING
|
||||
#Enable 0x01
|
||||
#Disable 0x00
|
||||
NXP_CHINA_TIANJIN_RF_ENABLED=0x01
|
||||
###############################################################################
|
||||
#SWP_SWITCH_TIMEOUT_SETTING
|
||||
# Allowed range of swp timeout setting is 0x00 to 0x3C [0 - 60].
|
||||
# Timeout in milliseconds, for example
|
||||
# No Timeout 0x00
|
||||
# 10 millisecond timeout 0x0A
|
||||
NXP_SWP_SWITCH_TIMEOUT=0x0A
|
||||
###############################################################################
|
||||
#Dynamic RSSI feature enable
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_AGC_DEBUG_ENABLE=0x00
|
||||
|
||||
###############################################################################
|
||||
#Config to allow adding aids
|
||||
#NFC on/off is required after this config
|
||||
#1 = enabling adding aid to NFCC routing table.
|
||||
#0 = disabling adding aid to NFCC routing table.
|
||||
NXP_ENABLE_ADD_AID=0x01
|
||||
################################################################################
|
||||
# Enable/Disable checking default proto SE Id
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_CHECK_DEFAULT_PROTO_SE_ID=0x01
|
||||
|
||||
###############################################################################
|
||||
# UICC mode supported
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_DUAL_UICC_ENABLE=0x00
|
||||
346
configs/libnfc-nxp_ds.conf
Normal file
346
configs/libnfc-nxp_ds.conf
Normal file
@@ -0,0 +1,346 @@
|
||||
###############################################################################
|
||||
## Modified by Motorola Mobility LLC
|
||||
## Version : 3.5.2 (2016/05/26)
|
||||
## Dual SIM with switcher HW
|
||||
|
||||
## This file is used by NFC NXP NCI HAL(external/libnfc-nci/halimpl/pn547)
|
||||
## and NFC Service Java Native Interface Extensions (packages/apps/Nfc/nci/jni/extns/pn547)
|
||||
|
||||
###############################################################################
|
||||
# Application options
|
||||
# Logging Levels
|
||||
# NXPLOG_DEFAULT_LOGLEVEL 0x01
|
||||
# ANDROID_LOG_DEBUG 0x03
|
||||
# ANDROID_LOG_WARN 0x02
|
||||
# ANDROID_LOG_ERROR 0x01
|
||||
# ANDROID_LOG_SILENT 0x00
|
||||
#
|
||||
NXPLOG_EXTNS_LOGLEVEL=0x03
|
||||
NXPLOG_NCIHAL_LOGLEVEL=0x03
|
||||
NXPLOG_NCIX_LOGLEVEL=0x03
|
||||
NXPLOG_NCIR_LOGLEVEL=0x03
|
||||
NXPLOG_FWDNLD_LOGLEVEL=0x03
|
||||
NXPLOG_TML_LOGLEVEL=0x03
|
||||
|
||||
###############################################################################
|
||||
# Nfc Device Node name
|
||||
NXP_NFC_DEV_NODE="/dev/pn544"
|
||||
|
||||
###############################################################################
|
||||
# Extension for Mifare reader enable
|
||||
MIFARE_READER_ENABLE=0x01
|
||||
|
||||
###############################################################################
|
||||
# Vzw Feature enable
|
||||
VZW_FEATURE_ENABLE=0x01
|
||||
|
||||
###############################################################################
|
||||
# File name for Firmware
|
||||
NXP_FW_NAME="libpn548ad_fw.so"
|
||||
|
||||
###############################################################################
|
||||
# System clock source selection configuration
|
||||
#define CLK_SRC_XTAL 1
|
||||
#define CLK_SRC_PLL 2
|
||||
|
||||
NXP_SYS_CLK_SRC_SEL=0x01
|
||||
|
||||
###############################################################################
|
||||
# System clock frequency selection configuration
|
||||
#define CLK_FREQ_13MHZ 1
|
||||
#define CLK_FREQ_19_2MHZ 2
|
||||
#define CLK_FREQ_24MHZ 3
|
||||
#define CLK_FREQ_26MHZ 4
|
||||
#define CLK_FREQ_38_4MHZ 5
|
||||
#define CLK_FREQ_52MHZ 6
|
||||
|
||||
NXP_SYS_CLK_FREQ_SEL=0x04
|
||||
|
||||
###############################################################################
|
||||
# The timeout value to be used for clock request acknowledgment
|
||||
# min value = 0x01 to max = 0x06
|
||||
|
||||
NXP_SYS_CLOCK_TO_CFG=0x01
|
||||
|
||||
###############################################################################
|
||||
# NXP proprietary settings
|
||||
NXP_ACT_PROP_EXTN={2F, 02, 00}
|
||||
|
||||
###############################################################################
|
||||
# NFC forum profile settings
|
||||
NXP_NFC_PROFILE_EXTN={20, 02, 05, 01, A0, 44, 01, 00}
|
||||
|
||||
###############################################################################
|
||||
# NFCC Configuration Control
|
||||
# Allow NFCC to manage RF Config 0x01
|
||||
# Don't allow NFCC to manage RF Config 0x00
|
||||
NXP_NFC_MERGE_RF_PARAMS={20, 02, 04, 01, 85, 01, 01}
|
||||
|
||||
###############################################################################
|
||||
# Standby enable settings
|
||||
NXP_CORE_STANDBY={2F, 00, 01, 01}
|
||||
|
||||
###############################################################################
|
||||
# NXP TVDD configurations settings
|
||||
# Allow NFCC to configure External TVDD, There are currently three
|
||||
#configurations (1, 2 and 3) are supported, out of them only one can be
|
||||
#supported.
|
||||
|
||||
NXP_EXT_TVDD_CFG=0x02
|
||||
|
||||
#config1:SLALM, 3.3V for both RM and CM
|
||||
NXP_EXT_TVDD_CFG_1={20, 02, 0B, 02, A0, 66, 01, 00, A0, 0E, 03, 02, 09, 00}
|
||||
|
||||
#config2: use DCDC in CE, use Tx_Pwr_Req, set CFG2 mode, SLALM,
|
||||
#monitoring 5V from DCDC, 4.7V for both RM and CM, DCDCWaitTime=4.2ms
|
||||
# No Dual SIM
|
||||
#NXP_EXT_TVDD_CFG_2={20, 02, 0B, 02, A0, 66, 01, 00, A0, 0E, 03, 56, 64, 0A}
|
||||
# Dual SIM - bit 7 of the second value should be set to 1
|
||||
NXP_EXT_TVDD_CFG_2={20, 02, 0B, 02, A0, 66, 01, 00, A0, 0E, 03, 56, E4, 0A}
|
||||
|
||||
#config3: use DCDC in CE, use Tx_Pwr_Req, SLALM, monitoring 5V from DCDC,
|
||||
#DCDCWaitTime=4.2ms
|
||||
NXP_EXT_TVDD_CFG_3={20, 02, 0B, 02, A0, 66, 01, 01, A0, 0E, 03, 52, 64, 0A}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
NXP_RF_CONF_BLK_1={
|
||||
20, 02, 1E, 2,
|
||||
A0, 1D, 11, 54, 33, 14, 17, 00, AA, 85, 00, 80, 55, 2A, 04, 00, 63, 00, 00, 00,
|
||||
A0, 0D, 06, 06, 03, 00, 73, 00, 20
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
NXP_RF_CONF_BLK_2={
|
||||
20, 02, 13, 02,
|
||||
A0, 0D, 06, 06, 30, B0, 00, 10, 00,
|
||||
A0, 0D, 06, 7C, 30, B0, 00, 10, 00
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
NXP_RF_CONF_BLK_3={
|
||||
20, 02, 07, 01,
|
||||
A0, 0D, 03, 00, 40, 03
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
#NXP_RF_CONF_BLK_4={
|
||||
#}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform, Min_level
|
||||
#NXP_RF_CONF_BLK_5={
|
||||
#}
|
||||
|
||||
###############################################################################
|
||||
# NXP RF configuration ALM/PLM settings
|
||||
# This section needs to be updated with the correct values based on the platform
|
||||
#NXP_RF_CONF_BLK_6={
|
||||
#}
|
||||
|
||||
###############################################################################
|
||||
## Set configuration optimization decision setting
|
||||
## Enable = 0x01
|
||||
## Disable = 0x00
|
||||
NXP_SET_CONFIG_ALWAYS=0x01
|
||||
|
||||
###############################################################################
|
||||
# Core configuration extensions
|
||||
# It includes
|
||||
# Wired mode settings A0ED, A0EE
|
||||
# Tag Detector A040, A041, A043
|
||||
# Low Power mode A007
|
||||
# Clock settings A002, A003
|
||||
# PbF settings A008
|
||||
NXP_CORE_CONF_EXTN={20, 02, 1D, 07,
|
||||
A0, EC, 01, 11,
|
||||
A0, ED, 01, 00,
|
||||
A0, 5E, 01, 01,
|
||||
A0, 40, 01, 01,
|
||||
A0, DD, 01, 2D,
|
||||
A0, 41, 01, 02,
|
||||
A0, 96, 01, 01
|
||||
}
|
||||
# A0, 41, 01, 02,
|
||||
# A0, 43, 01, 04,
|
||||
# A0, 02, 01, 01,
|
||||
# A0, 03, 01, 11,
|
||||
# A0, 07, 01, 03,
|
||||
# A0, 08, 01, 01
|
||||
# }
|
||||
|
||||
###############################################################################
|
||||
# Core configuration rf field filter settings to enable set to 01 to disable set to 00 last bit
|
||||
NXP_CORE_RF_FIELD={ 20, 02, 05, 01, A0, 62, 01, 01
|
||||
}
|
||||
###############################################################################
|
||||
# To enable i2c fragmentation set i2c fragmentation enable 0x01 to disable set to 0x00
|
||||
NXP_I2C_FRAGMENTATION_ENABLED=0x00
|
||||
|
||||
###############################################################################
|
||||
# Core configuration settings
|
||||
NXP_CORE_CONF={ 20, 02, 31, 0F,
|
||||
28, 01, 00,
|
||||
21, 01, 00,
|
||||
30, 01, 08,
|
||||
31, 01, 03,
|
||||
33, 04, 01, 02, 03, 04,
|
||||
54, 01, 06,
|
||||
50, 01, 02,
|
||||
5B, 01, 00,
|
||||
60, 01, 0E,
|
||||
80, 01, 01,
|
||||
81, 01, 01,
|
||||
82, 01, 0E,
|
||||
18, 01, 01,
|
||||
32, 01, 60,
|
||||
38, 01, 01
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Mifare Classic Key settings
|
||||
#NXP_CORE_MFCKEY_SETTING={20, 02, 25,04, A0, 51, 06, A0, A1, A2, A3, A4, A5,
|
||||
# A0, 52, 06, D3, F7, D3, F7, D3, F7,
|
||||
# A0, 53, 06, FF, FF, FF, FF, FF, FF,
|
||||
# A0, 54, 06, 00, 00, 00, 00, 00, 00}
|
||||
|
||||
###############################################################################
|
||||
# Default SE Options
|
||||
# No secure element 0x00
|
||||
# eSE 0x01
|
||||
# UICC 0x02
|
||||
|
||||
NXP_DEFAULT_SE=0x02
|
||||
|
||||
###############################################################################
|
||||
#Enable SWP full power mode when phone is power off
|
||||
NXP_SWP_FULL_PWR_ON=0x00
|
||||
|
||||
###############################################################################
|
||||
#### Select the CHIP ####
|
||||
#PN547C2 0x01
|
||||
#PN65T 0x02
|
||||
#PN548AD 0x03
|
||||
#PN66T 0x04
|
||||
|
||||
NXP_NFC_CHIP=0x03
|
||||
|
||||
###############################################################################
|
||||
# CE when Screen state is locked
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_CE_ROUTE_STRICT_DISABLE=0x01
|
||||
|
||||
#Timeout in secs to get NFCEE Discover notification
|
||||
NXP_DEFAULT_NFCEE_DISC_TIMEOUT=20
|
||||
|
||||
NXP_DEFAULT_NFCEE_TIMEOUT=0x06
|
||||
|
||||
#Timeout in secs
|
||||
NXP_SWP_RD_START_TIMEOUT=0x0A
|
||||
|
||||
#Timeout in secs
|
||||
NXP_SWP_RD_TAG_OP_TIMEOUT=0x01
|
||||
|
||||
###############################################################################
|
||||
#Set the default AID route Location :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# host 0x00
|
||||
# eSE 0x01
|
||||
# UICC 0x02
|
||||
DEFAULT_AID_ROUTE=0x00
|
||||
|
||||
###############################################################################
|
||||
#Set the Mifare Desfire route Location :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# host 0x00
|
||||
# eSE 0x01
|
||||
# UICC 0x02
|
||||
DEFAULT_DESFIRE_ROUTE=0x02
|
||||
|
||||
###############################################################################
|
||||
#Set the Mifare CLT route Location :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# host 0x00
|
||||
# eSE 0x01
|
||||
# UICC 0x02
|
||||
DEFAULT_MIFARE_CLT_ROUTE=0x02
|
||||
|
||||
###############################################################################
|
||||
#Set the default AID Power state :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# bit pos 0 = Switch On
|
||||
# bit pos 1 = Switch Off
|
||||
# bit pos 2 = Battery Off
|
||||
# bit pos 3 = Screen Lock
|
||||
# bit pos 4 = Screen Off
|
||||
DEFAULT_AID_PWR_STATE=0x9
|
||||
|
||||
###############################################################################
|
||||
#Set the Mifare Desfire Power state :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# bit pos 0 = Switch On
|
||||
# bit pos 1 = Switch Off
|
||||
# bit pos 2 = Battery Off
|
||||
# bit pos 3 = Screen Lock
|
||||
# bit pos 4 = Screen Off
|
||||
DEFAULT_DESFIRE_PWR_STATE=0x1B
|
||||
|
||||
###############################################################################
|
||||
#Set the Mifare CLT Power state :
|
||||
#This settings will be used when application does not set this parameter
|
||||
# bit pos 0 = Switch On
|
||||
# bit pos 1 = Switch Off
|
||||
# bit pos 2 = Battery Off
|
||||
# bit pos 3 = Screen Lock
|
||||
# bit pos 4 = Screen Off
|
||||
DEFAULT_MIFARE_CLT_PWR_STATE=0x1B
|
||||
|
||||
###############################################################################
|
||||
# AID Matching platform options
|
||||
# AID_MATCHING_L 0x01
|
||||
# AID_MATCHING_K 0x02
|
||||
AID_MATCHING_PLATFORM=0x01
|
||||
###############################################################################
|
||||
#CHINA_TIANJIN_RF_SETTING
|
||||
#Enable 0x01
|
||||
#Disable 0x00
|
||||
NXP_CHINA_TIANJIN_RF_ENABLED=0x01
|
||||
###############################################################################
|
||||
#SWP_SWITCH_TIMEOUT_SETTING
|
||||
# Allowed range of swp timeout setting is 0x00 to 0x3C [0 - 60].
|
||||
# Timeout in milliseconds, for example
|
||||
# No Timeout 0x00
|
||||
# 10 millisecond timeout 0x0A
|
||||
NXP_SWP_SWITCH_TIMEOUT=0x0A
|
||||
###############################################################################
|
||||
#Dynamic RSSI feature enable
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_AGC_DEBUG_ENABLE=0x00
|
||||
|
||||
###############################################################################
|
||||
#Config to allow adding aids
|
||||
#NFC on/off is required after this config
|
||||
#1 = enabling adding aid to NFCC routing table.
|
||||
#0 = disabling adding aid to NFCC routing table.
|
||||
NXP_ENABLE_ADD_AID=0x01
|
||||
################################################################################
|
||||
# Enable/Disable checking default proto SE Id
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_CHECK_DEFAULT_PROTO_SE_ID=0x01
|
||||
|
||||
###############################################################################
|
||||
# UICC mode supported
|
||||
# Disable 0x00
|
||||
# Enable 0x01
|
||||
NXP_DUAL_UICC_ENABLE=0x01
|
||||
177
configs/media_codecs.xml
Normal file
177
configs/media_codecs.xml
Normal file
@@ -0,0 +1,177 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2013 The Android Open Source Project
|
||||
Copyright (C) 2015-2016 The Linux Foundation. All rights reserved.
|
||||
Not a contribution.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<MediaCodecs>
|
||||
<Include href="media_codecs_google_audio.xml" />
|
||||
<Include href="media_codecs_google_telephony.xml" />
|
||||
<Settings>
|
||||
<Setting name="max-video-encoder-input-buffers" value="11" />
|
||||
</Settings>
|
||||
<Encoders>
|
||||
<!-- Video Hardware -->
|
||||
<MediaCodec name="OMX.qcom.video.encoder.hevc" type="video/hevc" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Quirk name="requires-loaded-to-idle-after-allocation" />
|
||||
<Limit name="size" min="176x64" max="3840x2160" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="972000" />
|
||||
<Limit name="bitrate" range="1-100000000" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.avc" type="video/avc" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Quirk name="requires-loaded-to-idle-after-allocation" />
|
||||
<Limit name="size" min="96x64" max="3840x2160" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="972000" />
|
||||
<Limit name="bitrate" range="1-100000000" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.mpeg4" type="video/mp4v-es" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Quirk name="requires-loaded-to-idle-after-allocation"/>
|
||||
<Limit name="size" min="96x64" max="1920x1088" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-40000000" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.h263" type="video/3gpp" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Quirk name="requires-loaded-to-idle-after-allocation" />
|
||||
<Limit name="size" min="96x64" max="864x480" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="48600" />
|
||||
<Limit name="bitrate" range="1-2000000" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.vp8" type="video/x-vnd.on2.vp8" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Quirk name="requires-loaded-to-idle-after-allocation" />
|
||||
<Limit name="size" min="96x64" max="1920x1088" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-40000000" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
</Encoders>
|
||||
<Decoders>
|
||||
<!-- Video Hardware -->
|
||||
<MediaCodec name="OMX.qcom.video.decoder.avc" type="video/avc" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Limit name="size" min="64x64" max="3840x2160" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="972000" />
|
||||
<Limit name="bitrate" range="1-100000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.avc.secure" type="video/avc" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Limit name="size" min="64x64" max="1920x1088" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="489600" />
|
||||
<Limit name="bitrate" range="1-60000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Feature name="secure-playback" required="true" />
|
||||
<Limit name="concurrent-instances" max="3" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.mpeg2" type="video/mpeg2" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Limit name="size" min="96x64" max="1920x1088" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="244800" />
|
||||
<Limit name="bitrate" range="1-40000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.mpeg4" type="video/mp4v-es" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Limit name="size" min="64x64" max="1920x1088" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="489600" />
|
||||
<Limit name="bitrate" range="1-60000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.h263" type="video/3gpp" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Limit name="size" min="64x64" max="864x480" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="48600" />
|
||||
<Limit name="bitrate" range="1-2000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.hevc" type="video/hevc" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Limit name="size" min="64x64" max="3840x2160" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="972000" />
|
||||
<Limit name="bitrate" range="1-100000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.vp8" type="video/x-vnd.on2.vp8" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Limit name="size" min="64x64" max="3840x2160" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="972000" />
|
||||
<Limit name="bitrate" range="1-100000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.vp9" type="video/x-vnd.on2.vp9" >
|
||||
<Quirk name="requires-allocate-on-input-ports" />
|
||||
<Quirk name="requires-allocate-on-output-ports" />
|
||||
<Limit name="size" min="64x64" max="3840x2160" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="972000" />
|
||||
<Limit name="bitrate" range="1-100000000" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Limit name="concurrent-instances" max="16" />
|
||||
</MediaCodec>
|
||||
<!-- Audio Software -->
|
||||
<MediaCodec name="OMX.qti.audio.decoder.flac" type="audio/flac" />
|
||||
</Decoders>
|
||||
<Include href="media_codecs_google_video.xml" />
|
||||
</MediaCodecs>
|
||||
138
configs/media_codecs_performance.xml
Normal file
138
configs/media_codecs_performance.xml
Normal file
@@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Not a Contribution.
|
||||
|
||||
Copyright 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<MediaCodecs>
|
||||
<Encoders>
|
||||
<MediaCodec name="OMX.google.h263.encoder" type="video/3gpp" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="374-377" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.h264.encoder" type="video/avc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="245-250" />
|
||||
<Limit name="measured-frame-rate-720x480" range="96-97" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="48-48" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="24-24" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.mpeg4.encoder" type="video/mp4v-es" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="382-385" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.vp8.encoder" type="video/x-vnd.on2.vp8" update="true">
|
||||
<Limit name="measured-frame-rate-320x180" range="111-112" />
|
||||
<Limit name="measured-frame-rate-640x360" range="37-37" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="33-33" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="19-19" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.avc" type="video/avc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="282-285" />
|
||||
<Limit name="measured-frame-rate-720x480" range="83-83" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="36-36" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="32-32" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.h263" type="video/3gpp" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="355-358" />
|
||||
<Limit name="measured-frame-rate-352x288" range="283-284" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.hevc" type="video/hevc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="269-272" />
|
||||
<Limit name="measured-frame-rate-720x480" range="83-83" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="36-36" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="32-32" />
|
||||
<Limit name="measured-frame-rate-3840x2160" range="9-9" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.mpeg4" type="video/mp4v-es" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="356-359" />
|
||||
<Limit name="measured-frame-rate-352x288" range="277-278" />
|
||||
<Limit name="measured-frame-rate-640x480" range="149-150" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.encoder.vp8" type="video/x-vnd.on2.vp8" update="true">
|
||||
<Limit name="measured-frame-rate-320x180" range="267-271" />
|
||||
<Limit name="measured-frame-rate-640x360" range="126-126" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="34-34" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="30-30" />
|
||||
</MediaCodec>
|
||||
</Encoders>
|
||||
<Decoders>
|
||||
<MediaCodec name="OMX.google.h263.decoder" type="video/3gpp" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="185-191" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.h264.decoder" type="video/avc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="317-326" />
|
||||
<Limit name="measured-frame-rate-720x480" range="132-133" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="57-57" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="24-24" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.hevc.decoder" type="video/hevc" update="true">
|
||||
<Limit name="measured-frame-rate-352x288" range="460-471" />
|
||||
<Limit name="measured-frame-rate-640x360" range="238-240" />
|
||||
<Limit name="measured-frame-rate-720x480" range="218-220" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="97-98" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="54-54" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.mpeg4.decoder" type="video/mp4v-es" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="205-210" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.vp8.decoder" type="video/x-vnd.on2.vp8" update="true">
|
||||
<Limit name="measured-frame-rate-320x180" range="631-634" />
|
||||
<Limit name="measured-frame-rate-640x360" range="179-182" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="40-41" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="17-17" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.google.vp9.decoder" type="video/x-vnd.on2.vp9" update="true">
|
||||
<Limit name="measured-frame-rate-320x180" range="376-382" />
|
||||
<Limit name="measured-frame-rate-640x360" range="183-183" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="90-91" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="50-50" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.avc" type="video/avc" update="true">
|
||||
<Limit name="measured-frame-rate-320x240" range="270-275" />
|
||||
<Limit name="measured-frame-rate-720x480" range="230-233" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="133-134" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="53-53" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.h263" type="video/3gpp" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="422-429" />
|
||||
<Limit name="measured-frame-rate-352x288" range="427-431" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.hevc" type="video/hevc" update="true">
|
||||
<Limit name="measured-frame-rate-352x288" range="341-345" />
|
||||
<Limit name="measured-frame-rate-640x360" range="266-269" />
|
||||
<Limit name="measured-frame-rate-720x480" range="250-252" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="120-121" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="56-56" />
|
||||
<Limit name="measured-frame-rate-3840x2160" range="13-13" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.mpeg4" type="video/mp4v-es" update="true">
|
||||
<Limit name="measured-frame-rate-176x144" range="428-433" />
|
||||
<Limit name="measured-frame-rate-480x360" range="409-412" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.vp8" type="video/x-vnd.on2.vp8" update="true">
|
||||
<Limit name="measured-frame-rate-320x180" range="434-436" />
|
||||
<Limit name="measured-frame-rate-640x360" range="357-358" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="321-321" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="148-148" />
|
||||
</MediaCodec>
|
||||
<MediaCodec name="OMX.qcom.video.decoder.vp9" type="video/x-vnd.on2.vp9" update="true">
|
||||
<Limit name="measured-frame-rate-320x180" range="422-424" />
|
||||
<Limit name="measured-frame-rate-640x360" range="305-306" />
|
||||
<Limit name="measured-frame-rate-1280x720" range="308-309" />
|
||||
<Limit name="measured-frame-rate-1920x1080" range="161-161" />
|
||||
<Limit name="measured-frame-rate-3840x2160" range="36-36" />
|
||||
</MediaCodec>
|
||||
</Decoders>
|
||||
</MediaCodecs>
|
||||
515
configs/media_profiles.xml
Normal file
515
configs/media_profiles.xml
Normal file
@@ -0,0 +1,515 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2013 The Android Open Source Project
|
||||
Copyright (C) 2015-2016 The Linux Foundation. All rights reserved.
|
||||
Not a contribution.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!DOCTYPE MediaSettings [
|
||||
<!ELEMENT MediaSettings (CamcorderProfiles,
|
||||
EncoderOutputFileFormat+,
|
||||
VideoEncoderCap+,
|
||||
AudioEncoderCap+,
|
||||
VideoDecoderCap,
|
||||
AudioDecoderCap)>
|
||||
<!ELEMENT CamcorderProfiles (EncoderProfile+, ImageEncoding+, ImageDecoding, Camera)>
|
||||
<!ELEMENT EncoderProfile (Video, Audio)>
|
||||
<!ATTLIST EncoderProfile quality (high|low) #REQUIRED>
|
||||
<!ATTLIST EncoderProfile fileFormat (mp4|3gp) #REQUIRED>
|
||||
<!ATTLIST EncoderProfile duration (30|60) #REQUIRED>
|
||||
<!ATTLIST EncoderProfile cameraId (0|1) #REQUIRED>
|
||||
<!ELEMENT Video EMPTY>
|
||||
<!ATTLIST Video codec (h264|h263|m4v) #REQUIRED>
|
||||
<!ATTLIST Video bitRate CDATA #REQUIRED>
|
||||
<!ATTLIST Video width CDATA #REQUIRED>
|
||||
<!ATTLIST Video height CDATA #REQUIRED>
|
||||
<!ATTLIST Video frameRate CDATA #REQUIRED>
|
||||
<!ELEMENT Audio EMPTY>
|
||||
<!ATTLIST Audio codec (amrnb|amrwb|aac|lpcm) #REQUIRED>
|
||||
<!ATTLIST Audio bitRate CDATA #REQUIRED>
|
||||
<!ATTLIST Audio sampleRate CDATA #REQUIRED>
|
||||
<!ATTLIST Audio channels (1|2|6) #REQUIRED>
|
||||
<!ELEMENT ImageEncoding EMPTY>
|
||||
<!ATTLIST ImageEncoding quality (90|80|70|60|50|40) #REQUIRED>
|
||||
<!ELEMENT ImageDecoding EMPTY>
|
||||
<!ATTLIST ImageDecoding memCap CDATA #REQUIRED>
|
||||
<!ELEMENT Camera EMPTY>
|
||||
<!ELEMENT EncoderOutputFileFormat EMPTY>
|
||||
<!ATTLIST EncoderOutputFileFormat name (mp4|3gp) #REQUIRED>
|
||||
<!ELEMENT VideoEncoderCap EMPTY>
|
||||
<!ATTLIST VideoEncoderCap name (h264|h263|m4v|wmv) #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap enabled (true|false) #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap minBitRate CDATA #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap maxBitRate CDATA #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap minFrameWidth CDATA #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap maxFrameWidth CDATA #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap minFrameHeight CDATA #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap maxFrameHeight CDATA #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap minFrameRate CDATA #REQUIRED>
|
||||
<!ATTLIST VideoEncoderCap maxFrameRate CDATA #REQUIRED>
|
||||
<!ELEMENT AudioEncoderCap EMPTY>
|
||||
<!ATTLIST AudioEncoderCap name (amrnb|amrwb|aac|heaac|aaceld|wma|lpcm) #REQUIRED>
|
||||
<!ATTLIST AudioEncoderCap enabled (true|false) #REQUIRED>
|
||||
<!ATTLIST AudioEncoderCap minBitRate CDATA #REQUIRED>
|
||||
<!ATTLIST AudioEncoderCap maxBitRate CDATA #REQUIRED>
|
||||
<!ATTLIST AudioEncoderCap minSampleRate CDATA #REQUIRED>
|
||||
<!ATTLIST AudioEncoderCap maxSampleRate CDATA #REQUIRED>
|
||||
<!ATTLIST AudioEncoderCap minChannels (1|2|6) #REQUIRED>
|
||||
<!ATTLIST AudioEncoderCap maxChannels (1|2|6) #REQUIRED>
|
||||
<!ELEMENT VideoDecoderCap EMPTY>
|
||||
<!ATTLIST VideoDecoderCap name (wmv) #REQUIRED>
|
||||
<!ATTLIST VideoDecoderCap enabled (true|false) #REQUIRED>
|
||||
<!ELEMENT AudioDecoderCap EMPTY>
|
||||
<!ATTLIST AudioDecoderCap name (wma) #REQUIRED>
|
||||
<!ATTLIST AudioDecoderCap enabled (true|false) #REQUIRED>
|
||||
]>
|
||||
<!--
|
||||
This file is used to declare the multimedia profiles and capabilities
|
||||
on an android-powered device.
|
||||
-->
|
||||
<MediaSettings>
|
||||
<!-- Each camcorder profile defines a set of predefined configuration parameters -->
|
||||
<!-- Back Camera -->
|
||||
<CamcorderProfiles cameraId="0">
|
||||
|
||||
<EncoderProfile quality="low" fileFormat="3gp" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="128000"
|
||||
width="320"
|
||||
height="240"
|
||||
frameRate="15" />
|
||||
|
||||
<Audio codec="amrnb"
|
||||
bitRate="12200"
|
||||
sampleRate="8000"
|
||||
channels="1" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="high" fileFormat="mp4" duration="10">
|
||||
<Video codec="h264"
|
||||
bitRate="51000000"
|
||||
width="3840"
|
||||
height="2160"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="qvga" fileFormat="3gp" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="128000"
|
||||
width="320"
|
||||
height="240"
|
||||
frameRate="15" />
|
||||
|
||||
<Audio codec="amrnb"
|
||||
bitRate="12200"
|
||||
sampleRate="8000"
|
||||
channels="1" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="480p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="6000000"
|
||||
width="720"
|
||||
height="480"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="720p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="10000000"
|
||||
width="1280"
|
||||
height="720"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="1080p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="17000000"
|
||||
width="1920"
|
||||
height="1080"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="2160p" fileFormat="mp4" duration="10">
|
||||
<Video codec="h264"
|
||||
bitRate="51000000"
|
||||
width="3840"
|
||||
height="2160"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapselow" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="512000"
|
||||
width="320"
|
||||
height="240"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="amrnb"
|
||||
bitRate="12200"
|
||||
sampleRate="8000"
|
||||
channels="1" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="51000000"
|
||||
width="3840"
|
||||
height="2160"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapseqvga" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="512000"
|
||||
width="320"
|
||||
height="240"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="amrnb"
|
||||
bitRate="12200"
|
||||
sampleRate="8000"
|
||||
channels="1" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="6000000"
|
||||
width="640"
|
||||
height="480"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="10000000"
|
||||
width="1280"
|
||||
height="720"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapse1080p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="17000000"
|
||||
width="1920"
|
||||
height="1080"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapse2160p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="51000000"
|
||||
width="3840"
|
||||
height="2160"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
|
||||
<ImageEncoding quality="95" />
|
||||
<ImageEncoding quality="80" />
|
||||
<ImageEncoding quality="70" />
|
||||
<ImageDecoding memCap="20000000" />
|
||||
|
||||
</CamcorderProfiles>
|
||||
<!-- Front Camera -->
|
||||
<CamcorderProfiles cameraId="1">
|
||||
|
||||
<EncoderProfile quality="low" fileFormat="3gp" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="128000"
|
||||
width="320"
|
||||
height="240"
|
||||
frameRate="15" />
|
||||
|
||||
<Audio codec="amrnb"
|
||||
bitRate="12200"
|
||||
sampleRate="8000"
|
||||
channels="1" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="high" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="17000000"
|
||||
width="1920"
|
||||
height="1080"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="qvga" fileFormat="3gp" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="128000"
|
||||
width="320"
|
||||
height="240"
|
||||
frameRate="15" />
|
||||
|
||||
<Audio codec="amrnb"
|
||||
bitRate="12200"
|
||||
sampleRate="8000"
|
||||
channels="1" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="480p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="6000000"
|
||||
width="720"
|
||||
height="480"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="720p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="10000000"
|
||||
width="1280"
|
||||
height="720"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="1080p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="17000000"
|
||||
width="1920"
|
||||
height="1080"
|
||||
frameRate="30" />
|
||||
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapselow" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="512000"
|
||||
width="320"
|
||||
height="240"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="amrnb"
|
||||
bitRate="12200"
|
||||
sampleRate="8000"
|
||||
channels="1" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="17000000"
|
||||
width="1920"
|
||||
height="1080"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapseqvga" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="512000"
|
||||
width="320"
|
||||
height="240"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="amrnb"
|
||||
bitRate="12200"
|
||||
sampleRate="8000"
|
||||
channels="1" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="6000000"
|
||||
width="640"
|
||||
height="480"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="10000000"
|
||||
width="1280"
|
||||
height="720"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
<EncoderProfile quality="timelapse1080p" fileFormat="mp4" duration="30">
|
||||
<Video codec="h264"
|
||||
bitRate="17000000"
|
||||
width="1920"
|
||||
height="1080"
|
||||
frameRate="30" />
|
||||
|
||||
<!-- audio setting is ignored -->
|
||||
<Audio codec="aac"
|
||||
bitRate="128000"
|
||||
sampleRate="48000"
|
||||
channels="2" />
|
||||
</EncoderProfile>
|
||||
|
||||
|
||||
<ImageEncoding quality="95" />
|
||||
<ImageEncoding quality="80" />
|
||||
<ImageEncoding quality="70" />
|
||||
<ImageDecoding memCap="20000000" />
|
||||
|
||||
</CamcorderProfiles>
|
||||
|
||||
<EncoderOutputFileFormat name="3gp" />
|
||||
<EncoderOutputFileFormat name="mp4" />
|
||||
|
||||
<!--
|
||||
If a codec is not enabled, it is invisible to the applications
|
||||
In other words, the applications won't be able to use the codec
|
||||
or query the capabilities of the codec at all if it is disabled
|
||||
-->
|
||||
<VideoEncoderCap name="h264" enabled="true"
|
||||
minBitRate="64000" maxBitRate="60000000"
|
||||
minFrameWidth="176" maxFrameWidth="3840"
|
||||
minFrameHeight="144" maxFrameHeight="2160"
|
||||
minFrameRate="15" maxFrameRate="60" />
|
||||
|
||||
<VideoEncoderCap name="h263" enabled="true"
|
||||
minBitRate="64000" maxBitRate="2000000"
|
||||
minFrameWidth="176" maxFrameWidth="720"
|
||||
minFrameHeight="144" maxFrameHeight="480"
|
||||
minFrameRate="15" maxFrameRate="30" />
|
||||
|
||||
<VideoEncoderCap name="m4v" enabled="true"
|
||||
minBitRate="64000" maxBitRate="20000000"
|
||||
minFrameWidth="176" maxFrameWidth="1920"
|
||||
minFrameHeight="144" maxFrameHeight="1080"
|
||||
minFrameRate="15" maxFrameRate="30" />
|
||||
|
||||
<AudioEncoderCap name="aac" enabled="true"
|
||||
minBitRate="8000" maxBitRate="156000"
|
||||
minSampleRate="8000" maxSampleRate="48000"
|
||||
minChannels="1" maxChannels="2" />
|
||||
|
||||
<AudioEncoderCap name="heaac" enabled="true"
|
||||
minBitRate="8000" maxBitRate="128000"
|
||||
minSampleRate="16000" maxSampleRate="48000"
|
||||
minChannels="1" maxChannels="2" />
|
||||
|
||||
<AudioEncoderCap name="aaceld" enabled="true"
|
||||
minBitRate="16000" maxBitRate="384000"
|
||||
minSampleRate="16000" maxSampleRate="48000"
|
||||
minChannels="1" maxChannels="2" />
|
||||
|
||||
<AudioEncoderCap name="amrwb" enabled="true"
|
||||
minBitRate="6600" maxBitRate="23850"
|
||||
minSampleRate="16000" maxSampleRate="16000"
|
||||
minChannels="1" maxChannels="1" />
|
||||
|
||||
<AudioEncoderCap name="amrnb" enabled="true"
|
||||
minBitRate="5525" maxBitRate="12200"
|
||||
minSampleRate="8000" maxSampleRate="8000"
|
||||
minChannels="1" maxChannels="1" />
|
||||
|
||||
<!--
|
||||
FIXME:
|
||||
We do not check decoder capabilities at present
|
||||
At present, we only check whether windows media is visible
|
||||
for TEST applications. For other applications, we do
|
||||
not perform any checks at all.
|
||||
-->
|
||||
<!-- IKVPREL2KK-2424 Disable WMV and WMA support -->
|
||||
<VideoDecoderCap name="wmv" enabled="false"/>
|
||||
<AudioDecoderCap name="wma" enabled="false"/>
|
||||
</MediaSettings>
|
||||
34
configs/qdcm_calib_data_mipi_mot_cmd_smd_1080p_549.xml
Normal file
34
configs/qdcm_calib_data_mipi_mot_cmd_smd_1080p_549.xml
Normal file
File diff suppressed because one or more lines are too long
321
configs/sec_config
Normal file
321
configs/sec_config
Normal file
@@ -0,0 +1,321 @@
|
||||
/* IPC Security Config */
|
||||
/* <GPS QMI Service ID - 16>:<GPS QMI Instance ID - all instances>:<Client Group ID> */
|
||||
16:4294967295:1000:1021
|
||||
/* <LOWI QMI Service ID - 38>:<LOWI QMI Instance ID - all instances>:<Client Group ID> */
|
||||
56:4294967295:1021
|
||||
/* Allow SS CTL service to be used by system and net_raw processes */
|
||||
43:4294967295:1000:3004
|
||||
/* <UIMHTTP QMI Service ID - 16>:<UIMHTTP QMI Instance ID - all instances>:<Client Group ID> */
|
||||
71:4294967295:1001
|
||||
/* <UIMRMT QMI Service ID - 16>:<UIMRMT QMI Instance ID - all instances>:<Client Group ID> */
|
||||
50:4294967295:1001
|
||||
/* QMI-SLIM service permitted to gps and net_raw */
|
||||
55:4294967295:1021
|
||||
/* Allow Sensor services to be used by sensor process */
|
||||
256:4294967295:1000:1006:1013:1021:1047:3011
|
||||
257:4294967295:1000:1006:1013:1021:1047:3011
|
||||
258:4294967295:1000:1006:1013:1021:1047:3011
|
||||
259:4294967295:1000:1006:1013:1021:1047:3011
|
||||
260:4294967295:1000:1006:1013:1021:1047:3011
|
||||
261:4294967295:1000:1006:1013:1021:1047:3011
|
||||
262:4294967295:1000:1006:1013:1021:1047:3011
|
||||
263:4294967295:1000:1006:1013:1021:1047:3011
|
||||
264:4294967295:1000:1006:1013:1021:1047:3011
|
||||
265:4294967295:1000:1006:1013:1021:1047:3011
|
||||
266:4294967295:1000:1006:1013:1021:1047:3011
|
||||
267:4294967295:1000:1006:1013:1021:1047:3011
|
||||
268:4294967295:1000:1006:1013:1021:1047:3011
|
||||
269:4294967295:1000:1006:1013:1021:1047:3011
|
||||
270:4294967295:1000:1006:1013:1021:1047:3011
|
||||
271:4294967295:1000:1006:1013:1021:1047:3011
|
||||
272:4294967295:1000:1006:1013:1021:1047:3011
|
||||
273:4294967295:1000:1006:1013:1021:1047:3011
|
||||
274:4294967295:1000:1006:1013:1021:1047:3011
|
||||
275:4294967295:1000:1006:1013:1021:1047:3011
|
||||
276:4294967295:1000:1006:1013:1021:1047:3011
|
||||
277:4294967295:1000:1006:1013:1021:1047:3011
|
||||
278:4294967295:1000:1006:1013:1021:1047:3011
|
||||
279:4294967295:1000:1006:1013:1021:1047:3011
|
||||
280:4294967295:1000:1006:1013:1021:1047:3011
|
||||
281:4294967295:1000:1006:1013:1021:1047:3011
|
||||
282:4294967295:1000:1006:1013:1021:1047:3011
|
||||
283:4294967295:1000:1006:1013:1021:1047:3011
|
||||
284:4294967295:1000:1006:1013:1021:1047:3011
|
||||
285:4294967295:1000:1006:1013:1021:1047:3011
|
||||
286:4294967295:1000:1006:1013:1021:1047:3011
|
||||
287:4294967295:1000:1006:1013:1021:1047:3011
|
||||
288:4294967295:1000:1006:1013:1021:1047:3011
|
||||
289:4294967295:1000:1006:1013:1021:1047:3011
|
||||
290:4294967295:1000:1006:1013:1021:1047:3011
|
||||
291:4294967295:1000:1006:1013:1021:1047:3011
|
||||
292:4294967295:1000:1006:1013:1021:1047:3011
|
||||
293:4294967295:1000:1006:1013:1021:1047:3011
|
||||
294:4294967295:1000:1006:1013:1021:1047:3011
|
||||
295:4294967295:1000:1006:1013:1021:1047:3011
|
||||
296:4294967295:1000:1006:1013:1021:1047:3011
|
||||
297:4294967295:1000:1006:1013:1021:1047:3011
|
||||
298:4294967295:1000:1006:1013:1021:1047:3011
|
||||
299:4294967295:1000:1006:1013:1021:1047:3011
|
||||
300:4294967295:1000:1006:1013:1021:1047:3011
|
||||
301:4294967295:1000:1006:1013:1021:1047:3011
|
||||
302:4294967295:1000:1006:1013:1021:1047:3011
|
||||
303:4294967295:1000:1006:1013:1021:1047:3011
|
||||
304:4294967295:1000:1006:1013:1021:1047:3011
|
||||
305:4294967295:1000:1006:1013:1021:1047:3011
|
||||
306:4294967295:1000:1006:1013:1021:1047:3011
|
||||
307:4294967295:1000:1006:1013:1021:1047:3011
|
||||
308:4294967295:1000:1006:1013:1021:1047:3011
|
||||
309:4294967295:1000:1006:1013:1021:1047:3011
|
||||
310:4294967295:1000:1006:1013:1021:1047:3011
|
||||
311:4294967295:1000:1006:1013:1021:1047:3011
|
||||
312:4294967295:1000:1006:1013:1021:1047:3011
|
||||
313:4294967295:1000:1006:1013:1021:1047:3011
|
||||
314:4294967295:1000:1006:1013:1021:1047:3011
|
||||
315:4294967295:1000:1006:1013:1021:1047:3011
|
||||
316:4294967295:1000:1006:1013:1021:1047:3011
|
||||
317:4294967295:1000:1006:1013:1021:1047:3011
|
||||
318:4294967295:1000:1006:1013:1021:1047:3011
|
||||
319:4294967295:1000:1006:1013:1021:1047:3011
|
||||
320:4294967295:1000:1006:1013:1021:1047:3011
|
||||
321:4294967295:1000:1006:1013:1021:1047:3011
|
||||
322:4294967295:1000:1006:1013:1021:1047:3011
|
||||
323:4294967295:1000:1006:1013:1021:1047:3011
|
||||
324:4294967295:1000:1006:1013:1021:1047:3011
|
||||
325:4294967295:1000:1006:1013:1021:1047:3011
|
||||
326:4294967295:1000:1006:1013:1021:1047:3011
|
||||
327:4294967295:1000:1006:1013:1021:1047:3011
|
||||
328:4294967295:1000:1006:1013:1021:1047:3011
|
||||
329:4294967295:1000:1006:1013:1021:1047:3011
|
||||
330:4294967295:1000:1006:1013:1021:1047:3011
|
||||
331:4294967295:1000:1006:1013:1021:1047:3011
|
||||
332:4294967295:1000:1006:1013:1021:1047:3011
|
||||
333:4294967295:1000:1006:1013:1021:1047:3011
|
||||
334:4294967295:1000:1006:1013:1021:1047:3011
|
||||
335:4294967295:1000:1006:1013:1021:1047:3011
|
||||
336:4294967295:1000:1006:1013:1021:1047:3011
|
||||
337:4294967295:1000:1006:1013:1021:1047:3011
|
||||
338:4294967295:1000:1006:1013:1021:1047:3011
|
||||
339:4294967295:1000:1006:1013:1021:1047:3011
|
||||
340:4294967295:1000:1006:1013:1021:1047:3011
|
||||
341:4294967295:1000:1006:1013:1021:1047:3011
|
||||
342:4294967295:1000:1006:1013:1021:1047:3011
|
||||
343:4294967295:1000:1006:1013:1021:1047:3011
|
||||
344:4294967295:1000:1006:1013:1021:1047:3011
|
||||
345:4294967295:1000:1006:1013:1021:1047:3011
|
||||
346:4294967295:1000:1006:1013:1021:1047:3011
|
||||
347:4294967295:1000:1006:1013:1021:1047:3011
|
||||
348:4294967295:1000:1006:1013:1021:1047:3011
|
||||
349:4294967295:1000:1006:1013:1021:1047:3011
|
||||
350:4294967295:1000:1006:1013:1021:1047:3011
|
||||
351:4294967295:1000:1006:1013:1021:1047:3011
|
||||
352:4294967295:1000:1006:1013:1021:1047:3011
|
||||
353:4294967295:1000:1006:1013:1021:1047:3011
|
||||
354:4294967295:1000:1006:1013:1021:1047:3011
|
||||
355:4294967295:1000:1006:1013:1021:1047:3011
|
||||
356:4294967295:1000:1006:1013:1021:1047:3011
|
||||
357:4294967295:1000:1006:1013:1021:1047:3011
|
||||
358:4294967295:1000:1006:1013:1021:1047:3011
|
||||
359:4294967295:1000:1006:1013:1021:1047:3011
|
||||
360:4294967295:1000:1006:1013:1021:1047:3011
|
||||
361:4294967295:1000:1006:1013:1021:1047:3011
|
||||
362:4294967295:1000:1006:1013:1021:1047:3011
|
||||
363:4294967295:1000:1006:1013:1021:1047:3011
|
||||
364:4294967295:1000:1006:1013:1021:1047:3011
|
||||
365:4294967295:1000:1006:1013:1021:1047:3011
|
||||
366:4294967295:1000:1006:1013:1021:1047:3011
|
||||
367:4294967295:1000:1006:1013:1021:1047:3011
|
||||
368:4294967295:1000:1006:1013:1021:1047:3011
|
||||
369:4294967295:1000:1006:1013:1021:1047:3011
|
||||
370:4294967295:1000:1006:1013:1021:1047:3011
|
||||
371:4294967295:1000:1006:1013:1021:1047:3011
|
||||
372:4294967295:1000:1006:1013:1021:1047:3011
|
||||
373:4294967295:1000:1006:1013:1021:1047:3011
|
||||
374:4294967295:1000:1006:1013:1021:1047:3011
|
||||
375:4294967295:1000:1006:1013:1021:1047:3011
|
||||
376:4294967295:1000:1006:1013:1021:1047:3011
|
||||
377:4294967295:1000:1006:1013:1021:1047:3011
|
||||
378:4294967295:1000:1006:1013:1021:1047:3011
|
||||
379:4294967295:1000:1006:1013:1021:1047:3011
|
||||
380:4294967295:1000:1006:1013:1021:1047:3011
|
||||
381:4294967295:1000:1006:1013:1021:1047:3011
|
||||
382:4294967295:1000:1006:1013:1021:1047:3011
|
||||
383:4294967295:1000:1006:1013:1021:1047:3011
|
||||
384:4294967295:1000:1006:1013:1021:1047:3011
|
||||
385:4294967295:1000:1006:1013:1021:1047:3011
|
||||
386:4294967295:1000:1006:1013:1021:1047:3011
|
||||
387:4294967295:1000:1006:1013:1021:1047:3011
|
||||
388:4294967295:1000:1006:1013:1021:1047:3011
|
||||
389:4294967295:1000:1006:1013:1021:1047:3011
|
||||
390:4294967295:1000:1006:1013:1021:1047:3011
|
||||
391:4294967295:1000:1006:1013:1021:1047:3011
|
||||
392:4294967295:1000:1006:1013:1021:1047:3011
|
||||
393:4294967295:1000:1006:1013:1021:1047:3011
|
||||
394:4294967295:1000:1006:1013:1021:1047:3011
|
||||
395:4294967295:1000:1006:1013:1021:1047:3011
|
||||
396:4294967295:1000:1006:1013:1021:1047:3011
|
||||
397:4294967295:1000:1006:1013:1021:1047:3011
|
||||
398:4294967295:1000:1006:1013:1021:1047:3011
|
||||
399:4294967295:1000:1006:1013:1021:1047:3011
|
||||
400:4294967295:1000:1006:1013:1021:1047:3011
|
||||
401:4294967295:1000:1006:1013:1021:1047:3011
|
||||
402:4294967295:1000:1006:1013:1021:1047:3011
|
||||
403:4294967295:1000:1006:1013:1021:1047:3011
|
||||
404:4294967295:1000:1006:1013:1021:1047:3011
|
||||
405:4294967295:1000:1006:1013:1021:1047:3011
|
||||
406:4294967295:1000:1006:1013:1021:1047:3011
|
||||
407:4294967295:1000:1006:1013:1021:1047:3011
|
||||
408:4294967295:1000:1006:1013:1021:1047:3011
|
||||
409:4294967295:1000:1006:1013:1021:1047:3011
|
||||
410:4294967295:1000:1006:1013:1021:1047:3011
|
||||
411:4294967295:1000:1006:1013:1021:1047:3011
|
||||
412:4294967295:1000:1006:1013:1021:1047:3011
|
||||
413:4294967295:1000:1006:1013:1021:1047:3011
|
||||
414:4294967295:1000:1006:1013:1021:1047:3011
|
||||
415:4294967295:1000:1006:1013:1021:1047:3011
|
||||
416:4294967295:1000:1006:1013:1021:1047:3011
|
||||
417:4294967295:1000:1006:1013:1021:1047:3011
|
||||
418:4294967295:1000:1006:1013:1021:1047:3011
|
||||
419:4294967295:1000:1006:1013:1021:1047:3011
|
||||
420:4294967295:1000:1006:1013:1021:1047:3011
|
||||
421:4294967295:1000:1006:1013:1021:1047:3011
|
||||
422:4294967295:1000:1006:1013:1021:1047:3011
|
||||
423:4294967295:1000:1006:1013:1021:1047:3011
|
||||
424:4294967295:1000:1006:1013:1021:1047:3011
|
||||
425:4294967295:1000:1006:1013:1021:1047:3011
|
||||
426:4294967295:1000:1006:1013:1021:1047:3011
|
||||
427:4294967295:1000:1006:1013:1021:1047:3011
|
||||
428:4294967295:1000:1006:1013:1021:1047:3011
|
||||
429:4294967295:1000:1006:1013:1021:1047:3011
|
||||
430:4294967295:1000:1006:1013:1021:1047:3011
|
||||
431:4294967295:1000:1006:1013:1021:1047:3011
|
||||
432:4294967295:1000:1006:1013:1021:1047:3011
|
||||
433:4294967295:1000:1006:1013:1021:1047:3011
|
||||
434:4294967295:1000:1006:1013:1021:1047:3011
|
||||
435:4294967295:1000:1006:1013:1021:1047:3011
|
||||
436:4294967295:1000:1006:1013:1021:1047:3011
|
||||
437:4294967295:1000:1006:1013:1021:1047:3011
|
||||
438:4294967295:1000:1006:1013:1021:1047:3011
|
||||
439:4294967295:1000:1006:1013:1021:1047:3011
|
||||
440:4294967295:1000:1006:1013:1021:1047:3011
|
||||
441:4294967295:1000:1006:1013:1021:1047:3011
|
||||
442:4294967295:1000:1006:1013:1021:1047:3011
|
||||
443:4294967295:1000:1006:1013:1021:1047:3011
|
||||
444:4294967295:1000:1006:1013:1021:1047:3011
|
||||
445:4294967295:1000:1006:1013:1021:1047:3011
|
||||
446:4294967295:1000:1006:1013:1021:1047:3011
|
||||
447:4294967295:1000:1006:1013:1021:1047:3011
|
||||
448:4294967295:1000:1006:1013:1021:1047:3011
|
||||
449:4294967295:1000:1006:1013:1021:1047:3011
|
||||
450:4294967295:1000:1006:1013:1021:1047:3011
|
||||
451:4294967295:1000:1006:1013:1021:1047:3011
|
||||
452:4294967295:1000:1006:1013:1021:1047:3011
|
||||
453:4294967295:1000:1006:1013:1021:1047:3011
|
||||
454:4294967295:1000:1006:1013:1021:1047:3011
|
||||
455:4294967295:1000:1006:1013:1021:1047:3011
|
||||
456:4294967295:1000:1006:1013:1021:1047:3011
|
||||
457:4294967295:1000:1006:1013:1021:1047:3011
|
||||
458:4294967295:1000:1006:1013:1021:1047:3011
|
||||
459:4294967295:1000:1006:1013:1021:1047:3011
|
||||
460:4294967295:1000:1006:1013:1021:1047:3011
|
||||
461:4294967295:1000:1006:1013:1021:1047:3011
|
||||
462:4294967295:1000:1006:1013:1021:1047:3011
|
||||
463:4294967295:1000:1006:1013:1021:1047:3011
|
||||
464:4294967295:1000:1006:1013:1021:1047:3011
|
||||
465:4294967295:1000:1006:1013:1021:1047:3011
|
||||
466:4294967295:1000:1006:1013:1021:1047:3011
|
||||
467:4294967295:1000:1006:1013:1021:1047:3011
|
||||
468:4294967295:1000:1006:1013:1021:1047:3011
|
||||
469:4294967295:1000:1006:1013:1021:1047:3011
|
||||
470:4294967295:1000:1006:1013:1021:1047:3011
|
||||
471:4294967295:1000:1006:1013:1021:1047:3011
|
||||
472:4294967295:1000:1006:1013:1021:1047:3011
|
||||
473:4294967295:1000:1006:1013:1021:1047:3011
|
||||
474:4294967295:1000:1006:1013:1021:1047:3011
|
||||
475:4294967295:1000:1006:1013:1021:1047:3011
|
||||
476:4294967295:1000:1006:1013:1021:1047:3011
|
||||
477:4294967295:1000:1006:1013:1021:1047:3011
|
||||
478:4294967295:1000:1006:1013:1021:1047:3011
|
||||
479:4294967295:1000:1006:1013:1021:1047:3011
|
||||
480:4294967295:1000:1006:1013:1021:1047:3011
|
||||
481:4294967295:1000:1006:1013:1021:1047:3011
|
||||
482:4294967295:1000:1006:1013:1021:1047:3011
|
||||
483:4294967295:1000:1006:1013:1021:1047:3011
|
||||
484:4294967295:1000:1006:1013:1021:1047:3011
|
||||
485:4294967295:1000:1006:1013:1021:1047:3011
|
||||
486:4294967295:1000:1006:1013:1021:1047:3011
|
||||
487:4294967295:1000:1006:1013:1021:1047:3011
|
||||
488:4294967295:1000:1006:1013:1021:1047:3011
|
||||
489:4294967295:1000:1006:1013:1021:1047:3011
|
||||
490:4294967295:1000:1006:1013:1021:1047:3011
|
||||
491:4294967295:1000:1006:1013:1021:1047:3011
|
||||
492:4294967295:1000:1006:1013:1021:1047:3011
|
||||
493:4294967295:1000:1006:1013:1021:1047:3011
|
||||
494:4294967295:1000:1006:1013:1021:1047:3011
|
||||
495:4294967295:1000:1006:1013:1021:1047:3011
|
||||
496:4294967295:1000:1006:1013:1021:1047:3011
|
||||
497:4294967295:1000:1006:1013:1021:1047:3011
|
||||
498:4294967295:1000:1006:1013:1021:1047:3011
|
||||
499:4294967295:1000:1006:1013:1021:1047:3011
|
||||
500:4294967295:1000:1006:1013:1021:1047:3011
|
||||
501:4294967295:1000:1006:1013:1021:1047:3011
|
||||
502:4294967295:1000:1006:1013:1021:1047:3011
|
||||
503:4294967295:1000:1006:1013:1021:1047:3011
|
||||
504:4294967295:1000:1006:1013:1021:1047:3011
|
||||
505:4294967295:1000:1006:1013:1021:1047:3011
|
||||
506:4294967295:1000:1006:1013:1021:1047:3011
|
||||
507:4294967295:1000:1006:1013:1021:1047:3011
|
||||
508:4294967295:1000:1006:1013:1021:1047:3011
|
||||
509:4294967295:1000:1006:1013:1021:1047:3011
|
||||
510:4294967295:1000:1006:1013:1021:1047:3011
|
||||
511:4294967295:1000:1006:1013:1021:1047:3011
|
||||
/* Allow RCS service to aquire net_raw permission */
|
||||
18:4294967295:1001:3004
|
||||
/* Allow QMID service to aquire net_raw permission */
|
||||
3:4294967295:1001:3004
|
||||
2:4294967295:1001:3004
|
||||
42:4294967295:1001:3004
|
||||
18:4294967295:1001:3004
|
||||
9:4294967295:1001:3004
|
||||
1:4294967295:1001:3004:1000
|
||||
4:4294967295:1001:3004
|
||||
7:4294967295:1001:3004
|
||||
8:4294967295:1001:3004:1000
|
||||
68:4294967295:1001:3004
|
||||
/* DPM */
|
||||
47:4294967295:1001:3004
|
||||
/* Allow communication to some QMI services with radio privilages */
|
||||
/* Format is <Service id>:<all instances>:<radio> */
|
||||
/* PBM */
|
||||
12:4294967295:1001
|
||||
/* WMS */
|
||||
5:4294967295:1001
|
||||
/* IMS VT */
|
||||
32:4294967295:1001
|
||||
/* IMSP */
|
||||
31:4294967295:1001
|
||||
/* PDC */
|
||||
36:4294967295:1001
|
||||
/* SAR */
|
||||
17:4294967295:1001
|
||||
/* RFRPE */
|
||||
41:4294967295:1001
|
||||
/*UIM*/
|
||||
11:4294967295:1001
|
||||
/*CAT*/
|
||||
10:4294967295:1001
|
||||
/*IMSA*/
|
||||
33:4294967295:1001
|
||||
/* CSVT */
|
||||
29:4294967295:1001
|
||||
/*LTE*/
|
||||
70:4294967295:1001
|
||||
/* Allow Data dpmd to access QMI DFS */
|
||||
48:4294967295:1000:3004
|
||||
/* DIAG */
|
||||
4097:4294967295:2002:2950:3009
|
||||
/* <WLFW QMI Service ID - 0x45>:<WLFW QMI Instance ID - all instances>:<Client Group ID> */
|
||||
69:4294967295:1000
|
||||
/* <WLPS QMI Service ID - 0x39>:<WLFW QMI Instance ID - all instances>:<Client Group ID> */
|
||||
57:4294967295:1000
|
||||
/* MOTEXT */
|
||||
228:4294967295:1001:3004
|
||||
110
configs/thermal-engine-potter.conf
Normal file
110
configs/thermal-engine-potter.conf
Normal file
@@ -0,0 +1,110 @@
|
||||
[FRONT_TEMP]
|
||||
algo_type virtual
|
||||
trip_sensor msm_therm
|
||||
set_point -18000
|
||||
set_point_clr -20000
|
||||
sensors msm_therm pa_therm0 chg_therm batt_temp
|
||||
weights 110 100 85 110
|
||||
offsets -2000 -2000 -2000 -2000
|
||||
sampling 10000
|
||||
math 0
|
||||
sys_temp
|
||||
|
||||
[REPORT-FRONT-TEMP]
|
||||
algo_type monitor
|
||||
sampling 300000
|
||||
sensor FRONT_TEMP
|
||||
thresholds 45000
|
||||
thresholds_clr 43000
|
||||
actions report
|
||||
action_info 1
|
||||
|
||||
[BACK_TEMP]
|
||||
algo_type virtual
|
||||
trip_sensor msm_therm
|
||||
set_point -18000
|
||||
set_point_clr -20000
|
||||
sensors msm_therm pa_therm0 chg_therm batt_temp
|
||||
weights 110 100 85 110
|
||||
offsets -1000 -1000 -1000 -1000
|
||||
sampling 10000
|
||||
math 0
|
||||
sys_temp
|
||||
|
||||
[REPORT-BACK-TEMP]
|
||||
algo_type monitor
|
||||
sampling 300000
|
||||
sensor BACK_TEMP
|
||||
thresholds 45000
|
||||
thresholds_clr 43000
|
||||
actions report
|
||||
action_info 1
|
||||
|
||||
[SS-BATT-BATT]
|
||||
algo_type ss
|
||||
sampling 5000
|
||||
sensor batt_therm
|
||||
device battery
|
||||
set_point 44000
|
||||
set_point_clr 42000
|
||||
|
||||
[SS-CHG-BATT]
|
||||
algo_type ss
|
||||
sampling 5000
|
||||
sensor chg_therm
|
||||
device battery
|
||||
set_point 43000
|
||||
set_point_clr 41000
|
||||
|
||||
[SS-MSM-CLUSTER0]
|
||||
algo_type ss
|
||||
sampling 1000
|
||||
sensor msm_therm
|
||||
device cluster0
|
||||
set_point 49000
|
||||
set_point_clr 44000
|
||||
device_max_limit 1401600
|
||||
|
||||
[VIRTUAL-CPUS]
|
||||
algo_type virtual
|
||||
trip_sensor tsens_tz_sensor9
|
||||
set_point 75000
|
||||
set_point_clr 65000
|
||||
sensors tsens_tz_sensor9 tsens_tz_sensor10 tsens_tz_sensor11 tsens_tz_sensor12 tsens_tz_sensor13 tsens_tz_sensor4 tsens_tz_sensor5 tsens_tz_sensor6 tsens_tz_sensor7 tsens_tz_sensor8
|
||||
sampling 50
|
||||
math 2
|
||||
|
||||
[SS-GPU]
|
||||
algo_type ss
|
||||
sampling 250
|
||||
sensor gpu
|
||||
device gpu
|
||||
set_point 95000
|
||||
set_point_clr 65000
|
||||
|
||||
[SS-POPMEM]
|
||||
algo_type ss
|
||||
disable
|
||||
sampling 250
|
||||
sensor pop_mem
|
||||
device cluster0
|
||||
set_point 70000
|
||||
set_point_clr 55000
|
||||
time_constant 2
|
||||
|
||||
[SS-CPUS-ALL]
|
||||
algo_type ss
|
||||
sampling 50
|
||||
sensor VIRTUAL-CPUS
|
||||
device cluster0
|
||||
set_point 95000
|
||||
set_point_clr 55000
|
||||
|
||||
[MONITOR-CAMERA-MSM]
|
||||
algo_type monitor
|
||||
sampling 1000
|
||||
sensor msm_therm
|
||||
thresholds 52000 56000
|
||||
thresholds_clr 47000 53000
|
||||
actions camera camera
|
||||
action_info 1 2
|
||||
18
data-ipa-cfg-mgr/Android.mk
Normal file
18
data-ipa-cfg-mgr/Android.mk
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Copyright (C) 2016 The CyanogenMod Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(call first-makefiles-under,$(LOCAL_PATH))
|
||||
3
data-ipa-cfg-mgr/Makefile.am
Normal file
3
data-ipa-cfg-mgr/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
SUBDIRS = ipanat/src ipacm/src/
|
||||
57
data-ipa-cfg-mgr/configure.ac
Normal file
57
data-ipa-cfg-mgr/configure.ac
Normal file
@@ -0,0 +1,57 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.65])
|
||||
AC_INIT(data-ipa, 1.0.0)
|
||||
AM_INIT_AUTOMAKE(data-ipa, 1.0.0)
|
||||
AC_OUTPUT(Makefile ipanat/src/Makefile ipacm/src/Makefile)
|
||||
AC_CONFIG_SRCDIR([ipanat/src/ipa_nat_drv.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_CXX
|
||||
|
||||
PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
|
||||
AC_SUBST([LIBXML_CFLAGS])
|
||||
AC_SUBST([LIBXML_LIBS])
|
||||
|
||||
# Checks for libraries.
|
||||
|
||||
AC_ARG_WITH(sanitized-headers,
|
||||
AS_HELP_STRING([--with-sanitized-headers=DIR],
|
||||
[Specify the location of the sanitized Linux headers]),
|
||||
[CPPFLAGS="$CPPFLAGS -idirafter $withval"])
|
||||
|
||||
AC_ARG_WITH([glib],
|
||||
AC_HELP_STRING([--with-glib],
|
||||
[enable glib, building HLOS systems which use glib]))
|
||||
|
||||
if (test "x${with_glib}" = "xyes"); then
|
||||
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
|
||||
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
|
||||
AC_MSG_ERROR(GThread >= 2.16 is required))
|
||||
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
|
||||
AC_MSG_ERROR(GLib >= 2.16 is required))
|
||||
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
|
||||
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
|
||||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
|
||||
|
||||
# Checks for header files.
|
||||
AC_CHECK_HEADERS([fcntl.h netinet/in.h sys/ioctl.h unistd.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_TYPE_OFF_T
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_MALLOC
|
||||
AC_FUNC_MMAP
|
||||
AC_CHECK_FUNCS([memset munmap])
|
||||
|
||||
AC_OUTPUT
|
||||
109
data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h
Normal file
109
data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_CmdQueue.h
|
||||
|
||||
@brief
|
||||
This file implements the IPAM Comment Queue definitions
|
||||
|
||||
@Author
|
||||
|
||||
*/
|
||||
#ifndef IPA_CONNTRACK_MESSAGE_H
|
||||
#define IPA_CONNTRACK_MESSAGE_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include "IPACM_Defs.h"
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Event data required by IPA_CM
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
typedef struct _ipacm_cmd_q_data {
|
||||
ipa_cm_event_id event;
|
||||
void *evt_data;
|
||||
}ipacm_cmd_q_data;
|
||||
|
||||
typedef struct cmd_s
|
||||
{
|
||||
void (*callback_ptr)(ipacm_cmd_q_data *);
|
||||
ipacm_cmd_q_data data;
|
||||
}cmd_t;
|
||||
|
||||
class Message
|
||||
{
|
||||
private:
|
||||
Message *m_next;
|
||||
|
||||
public:
|
||||
cmd_t evt;
|
||||
|
||||
Message()
|
||||
{
|
||||
m_next = NULL;
|
||||
evt.callback_ptr = NULL;
|
||||
}
|
||||
~Message() { }
|
||||
void setnext(Message *item) { m_next = item; }
|
||||
Message* getnext() { return m_next; }
|
||||
};
|
||||
|
||||
class MessageQueue
|
||||
{
|
||||
|
||||
private:
|
||||
Message *Head;
|
||||
Message *Tail;
|
||||
Message* dequeue(void);
|
||||
static MessageQueue *inst_internal;
|
||||
static MessageQueue *inst_external;
|
||||
|
||||
MessageQueue()
|
||||
{
|
||||
Head = NULL;
|
||||
Tail = NULL;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
~MessageQueue() { }
|
||||
void enqueue(Message *item);
|
||||
|
||||
static void* Process(void *);
|
||||
static MessageQueue* getInstanceInternal();
|
||||
static MessageQueue* getInstanceExternal();
|
||||
|
||||
};
|
||||
|
||||
#endif /* IPA_CONNTRACK_MESSAGE_H */
|
||||
|
||||
357
data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h
Normal file
357
data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h
Normal file
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Config.h
|
||||
|
||||
@brief
|
||||
This file implements the IPACM Configuration from XML file
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_CONFIG_H
|
||||
#define IPACM_CONFIG_H
|
||||
|
||||
#include "IPACM_Defs.h"
|
||||
#include "IPACM_Xml.h"
|
||||
#include "IPACM_EvtDispatcher.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char iface_name[IPA_IFACE_NAME_LEN];
|
||||
}NatIfaces;
|
||||
|
||||
/* for IPACM rm dependency use*/
|
||||
typedef struct _ipa_rm_client
|
||||
{
|
||||
ipa_rm_resource_name producer_rm1;
|
||||
ipa_rm_resource_name consumer_rm1;
|
||||
ipa_rm_resource_name producer_rm2;
|
||||
ipa_rm_resource_name consumer_rm2;
|
||||
bool producer1_up; /* only monitor producer_rm1, not monitor producer_rm2 */
|
||||
bool consumer1_up; /* only monitor consumer_rm1, not monitor consumer_rm2 */
|
||||
bool rm_set; /* once producer1_up and consumer1_up, will add bi-directional dependency */
|
||||
bool rx_bypass_ipa; /* support WLAN may not register RX-property, should not add dependency */
|
||||
}ipa_rm_client;
|
||||
|
||||
#define MAX_NUM_EXT_PROPS 25
|
||||
|
||||
/* used to hold extended properties */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t num_ext_props;
|
||||
ipa_ioc_ext_intf_prop prop[MAX_NUM_EXT_PROPS];
|
||||
} ipacm_ext_prop;
|
||||
|
||||
/* iface */
|
||||
class IPACM_Config
|
||||
{
|
||||
public:
|
||||
|
||||
/* IPACM ipa_client map to rm_resource*/
|
||||
ipa_rm_resource_name ipa_client_rm_map_tbl[IPA_CLIENT_MAX];
|
||||
|
||||
/* IPACM monitored rm_depency table */
|
||||
ipa_rm_client ipa_rm_tbl[IPA_MAX_RM_ENTRY];
|
||||
|
||||
/* IPACM rm_depency a2 endpoint check*/
|
||||
int ipa_rm_a2_check;
|
||||
|
||||
/* Store interested interface and their configuration from XML file */
|
||||
ipa_ifi_dev_name_t *iface_table;
|
||||
|
||||
/* Store interested ALG port from XML file */
|
||||
ipacm_alg *alg_table;
|
||||
|
||||
/* Store private subnet configuration from XML file */
|
||||
ipa_private_subnet private_subnet_table[IPA_MAX_PRIVATE_SUBNET_ENTRIES];
|
||||
|
||||
/* Store the non nat iface names */
|
||||
NatIfaces *pNatIfaces;
|
||||
|
||||
/* Store the bridge iface names */
|
||||
char ipa_virtual_iface_name[IPA_IFACE_NAME_LEN];
|
||||
|
||||
/* Store the number of interface IPACM read from XML file */
|
||||
int ipa_num_ipa_interfaces;
|
||||
|
||||
int ipa_num_private_subnet;
|
||||
|
||||
int ipa_num_alg_ports;
|
||||
|
||||
int ipa_nat_max_entries;
|
||||
|
||||
bool ipacm_odu_router_mode;
|
||||
|
||||
bool ipacm_odu_enable;
|
||||
|
||||
bool ipacm_odu_embms_enable;
|
||||
|
||||
bool ipacm_ip_passthrough_mode;
|
||||
|
||||
int ipa_nat_iface_entries;
|
||||
|
||||
/* Store the total number of wlan guest ap configured */
|
||||
int ipa_num_wlan_guest_ap;
|
||||
|
||||
/* Max valid rm entry */
|
||||
int ipa_max_valid_rm_entry;
|
||||
|
||||
/* Store SW-enable or not */
|
||||
bool ipa_sw_rt_enable;
|
||||
|
||||
/* Store bridge mode or not */
|
||||
bool ipa_bridge_enable;
|
||||
|
||||
/* Store bridge netdev mac */
|
||||
uint8_t bridge_mac[IPA_MAC_ADDR_SIZE];
|
||||
|
||||
/* Store the flt rule count for each producer client*/
|
||||
int flt_rule_count_v4[IPA_CLIENT_CONS - IPA_CLIENT_PROD];
|
||||
int flt_rule_count_v6[IPA_CLIENT_CONS - IPA_CLIENT_PROD];
|
||||
|
||||
/* IPACM routing table name for v4/v6 */
|
||||
struct ipa_ioc_get_rt_tbl rt_tbl_lan_v4, rt_tbl_wan_v4, rt_tbl_default_v4, rt_tbl_v6, rt_tbl_wan_v6;
|
||||
struct ipa_ioc_get_rt_tbl rt_tbl_wan_dl;
|
||||
struct ipa_ioc_get_rt_tbl rt_tbl_odu_v4, rt_tbl_odu_v6;
|
||||
|
||||
bool isMCC_Mode;
|
||||
|
||||
/* To return the instance */
|
||||
static IPACM_Config* GetInstance();
|
||||
|
||||
const char* getEventName(ipa_cm_event_id event_id);
|
||||
|
||||
inline void increaseFltRuleCount(int index, ipa_ip_type iptype, int increment)
|
||||
{
|
||||
if((index >= IPA_CLIENT_CONS - IPA_CLIENT_PROD) || (index < 0))
|
||||
{
|
||||
IPACMERR("Index is out of range: %d.\n", index);
|
||||
return;
|
||||
}
|
||||
if(iptype == IPA_IP_v4)
|
||||
{
|
||||
flt_rule_count_v4[index] += increment;
|
||||
IPACMDBG_H("Now num of v4 flt rules on client %d is %d.\n", index, flt_rule_count_v4[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
flt_rule_count_v6[index] += increment;
|
||||
IPACMDBG_H("Now num of v6 flt rules on client %d is %d.\n", index, flt_rule_count_v6[index]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
inline void decreaseFltRuleCount(int index, ipa_ip_type iptype, int decrement)
|
||||
{
|
||||
if((index >= IPA_CLIENT_CONS - IPA_CLIENT_PROD) || (index < 0))
|
||||
{
|
||||
IPACMERR("Index is out of range: %d.\n", index);
|
||||
return;
|
||||
}
|
||||
if(iptype == IPA_IP_v4)
|
||||
{
|
||||
flt_rule_count_v4[index] -= decrement;
|
||||
IPACMDBG_H("Now num of v4 flt rules on client %d is %d.\n", index, flt_rule_count_v4[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
flt_rule_count_v6[index] -= decrement;
|
||||
IPACMDBG_H("Now num of v6 flt rules on client %d is %d.\n", index, flt_rule_count_v6[index]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
inline int getFltRuleCount(int index, ipa_ip_type iptype)
|
||||
{
|
||||
if((index >= IPA_CLIENT_CONS - IPA_CLIENT_PROD) || (index < 0))
|
||||
{
|
||||
IPACMERR("Index is out of range: %d.\n", index);
|
||||
return -1;
|
||||
}
|
||||
if(iptype == IPA_IP_v4)
|
||||
{
|
||||
return flt_rule_count_v4[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return flt_rule_count_v6[index];
|
||||
}
|
||||
}
|
||||
|
||||
inline int GetAlgPortCnt()
|
||||
{
|
||||
return ipa_num_alg_ports;
|
||||
}
|
||||
|
||||
int GetAlgPorts(int nPorts, ipacm_alg *pAlgPorts);
|
||||
|
||||
inline int GetNatMaxEntries(void)
|
||||
{
|
||||
return ipa_nat_max_entries;
|
||||
}
|
||||
|
||||
inline int GetNatIfacesCnt()
|
||||
{
|
||||
return ipa_nat_iface_entries;
|
||||
}
|
||||
int GetNatIfaces(int nPorts, NatIfaces *ifaces);
|
||||
|
||||
/* for IPACM resource manager dependency usage */
|
||||
void AddRmDepend(ipa_rm_resource_name rm1,bool rx_bypass_ipa);
|
||||
|
||||
void DelRmDepend(ipa_rm_resource_name rm1);
|
||||
|
||||
int AddNatIfaces(char *dev_name);
|
||||
|
||||
int DelNatIfaces(char *dev_name);
|
||||
|
||||
inline void SetQmapId(uint8_t id)
|
||||
{
|
||||
qmap_id = id;
|
||||
}
|
||||
|
||||
inline uint8_t GetQmapId()
|
||||
{
|
||||
return qmap_id;
|
||||
}
|
||||
|
||||
int SetExtProp(ipa_ioc_query_intf_ext_props *prop);
|
||||
|
||||
ipacm_ext_prop* GetExtProp(ipa_ip_type ip_type);
|
||||
|
||||
int DelExtProp(ipa_ip_type ip_type);
|
||||
|
||||
int Init(void);
|
||||
|
||||
inline bool isPrivateSubnet(uint32_t ip_addr)
|
||||
{
|
||||
for(int cnt=0; cnt<ipa_num_private_subnet; cnt++)
|
||||
{
|
||||
if(private_subnet_table[cnt].subnet_addr ==
|
||||
(private_subnet_table[cnt].subnet_mask & ip_addr))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
inline bool AddPrivateSubnet(uint32_t ip_addr, int ipa_if_index)
|
||||
{
|
||||
ipacm_cmd_q_data evt_data;
|
||||
ipacm_event_data_fid *data_fid;
|
||||
uint32_t subnet_mask = ~0;
|
||||
for(int cnt=0; cnt<ipa_num_private_subnet; cnt++)
|
||||
{
|
||||
if(private_subnet_table[cnt].subnet_addr == ip_addr)
|
||||
{
|
||||
IPACMDBG("Already has private subnet_addr as: 0x%x in entry(%d) \n", ip_addr, cnt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(ipa_num_private_subnet < IPA_MAX_PRIVATE_SUBNET_ENTRIES)
|
||||
{
|
||||
IPACMDBG("Add IPACM private subnet_addr as: 0x%x in entry(%d) \n", ip_addr, ipa_num_private_subnet);
|
||||
private_subnet_table[ipa_num_private_subnet].subnet_addr = ip_addr;
|
||||
private_subnet_table[ipa_num_private_subnet].subnet_mask = (subnet_mask >> 8) << 8;
|
||||
ipa_num_private_subnet++;
|
||||
|
||||
/* IPACM private subnet set changes */
|
||||
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event data_fid\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
data_fid->if_index = ipa_if_index; // already ipa index, not fid index
|
||||
evt_data.event = IPA_PRIVATE_SUBNET_CHANGE_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
|
||||
/* Insert IPA_PRIVATE_SUBNET_CHANGE_EVENT to command queue */
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
return true;
|
||||
}
|
||||
IPACMERR("IPACM private subnet_addr overflow, total entry(%d)\n", ipa_num_private_subnet);
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool DelPrivateSubnet(uint32_t ip_addr, int ipa_if_index)
|
||||
{
|
||||
ipacm_cmd_q_data evt_data;
|
||||
ipacm_event_data_fid *data_fid;
|
||||
for(int cnt=0; cnt<ipa_num_private_subnet; cnt++)
|
||||
{
|
||||
if(private_subnet_table[cnt].subnet_addr == ip_addr)
|
||||
{
|
||||
IPACMDBG("Found private subnet_addr as: 0x%x in entry(%d) \n", ip_addr, cnt);
|
||||
for (; cnt < ipa_num_private_subnet - 1; cnt++)
|
||||
{
|
||||
private_subnet_table[cnt].subnet_addr = private_subnet_table[cnt+1].subnet_addr;
|
||||
}
|
||||
ipa_num_private_subnet = ipa_num_private_subnet - 1;
|
||||
|
||||
/* IPACM private subnet set changes */
|
||||
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event data_fid\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
data_fid->if_index = ipa_if_index; // already ipa index, not fid index
|
||||
evt_data.event = IPA_PRIVATE_SUBNET_CHANGE_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
|
||||
/* Insert IPA_PRIVATE_SUBNET_CHANGE_EVENT to command queue */
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
IPACMDBG("can't find private subnet_addr as: 0x%x \n", ip_addr);
|
||||
return false;
|
||||
}
|
||||
#endif /* defined(FEATURE_IPA_ANDROID)*/
|
||||
|
||||
static const char *DEVICE_NAME_ODU;
|
||||
|
||||
private:
|
||||
static IPACM_Config *pInstance;
|
||||
static const char *DEVICE_NAME;
|
||||
IPACM_Config(void);
|
||||
int m_fd; /* File descriptor of the IPA device node /dev/ipa */
|
||||
uint8_t qmap_id;
|
||||
ipacm_ext_prop ext_prop_v4;
|
||||
ipacm_ext_prop ext_prop_v6;
|
||||
};
|
||||
|
||||
#endif /* IPACM_CONFIG */
|
||||
104
data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackClient.h
Normal file
104
data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackClient.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef IPACM_CONNTRACK_FILTER_H
|
||||
#define IPACM_CONNTRACK_FILTER_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "IPACM_ConntrackClient.h"
|
||||
#include "IPACM_CmdQueue.h"
|
||||
#include "IPACM_Conntrack_NATApp.h"
|
||||
#include "IPACM_EvtDispatcher.h"
|
||||
#include "IPACM_Defs.h"
|
||||
|
||||
#ifndef IPACM_DEBUG
|
||||
#define IPACM_DEBUG
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
|
||||
#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
|
||||
#include <sys/inotify.h>
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define UDP_TIMEOUT_UPDATE 20
|
||||
#define BROADCAST_IPV4_ADDR 0xFFFFFFFF
|
||||
|
||||
class IPACM_ConntrackClient
|
||||
{
|
||||
|
||||
private:
|
||||
static IPACM_ConntrackClient *pInstance;
|
||||
|
||||
struct nfct_handle *tcp_hdl;
|
||||
struct nfct_handle *udp_hdl;
|
||||
struct nfct_filter *tcp_filter;
|
||||
struct nfct_filter *udp_filter;
|
||||
static int IPA_Conntrack_Filters_Ignore_Local_Addrs(struct nfct_filter *filter);
|
||||
static int IPA_Conntrack_Filters_Ignore_Bridge_Addrs(struct nfct_filter *filter);
|
||||
static int IPA_Conntrack_Filters_Ignore_Local_Iface(struct nfct_filter *, ipacm_event_iface_up *);
|
||||
IPACM_ConntrackClient();
|
||||
|
||||
public:
|
||||
static int IPAConntrackEventCB(enum nf_conntrack_msg_type type,
|
||||
struct nf_conntrack *ct,
|
||||
void *data);
|
||||
|
||||
static int IPA_Conntrack_UDP_Filter_Init(void);
|
||||
static int IPA_Conntrack_TCP_Filter_Init(void);
|
||||
static void* TCPRegisterWithConnTrack(void *);
|
||||
static void* UDPRegisterWithConnTrack(void *);
|
||||
static void* UDPConnTimeoutUpdate(void *);
|
||||
|
||||
static void UpdateUDPFilters(void *, bool);
|
||||
static void UpdateTCPFilters(void *, bool);
|
||||
static void Read_TcpUdp_Timeout(char *in, int len);
|
||||
|
||||
static IPACM_ConntrackClient* GetInstance();
|
||||
|
||||
#ifdef IPACM_DEBUG
|
||||
#define iptodot(X,Y) \
|
||||
IPACMLOG(" %s(0x%x): %d.%d.%d.%d\n", X, Y, ((Y>>24) & 0xFF), ((Y>>16) & 0xFF), ((Y>>8) & 0xFF), (Y & 0xFF));
|
||||
#endif
|
||||
|
||||
#define log_nat(A,B,C,D,E,F) \
|
||||
IPACMDBG_H("protocol %d Private IP: %d.%d.%d.%d\t Target IP: %d.%d.%d.%d\t private port: %d public port: %d %s",A,((B>>24) & 0xFF), ((B>>16) & 0xFF), ((B>>8) & 0xFF), (B & 0xFF), ((C>>24) & 0xFF), ((C>>16) & 0xFF),((C>>8) & 0xFF),(C & 0xFF),D,E,F);
|
||||
|
||||
};
|
||||
|
||||
#endif /* IPACM_CONNTRACK_FILTER_H */
|
||||
123
data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h
Normal file
123
data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef IPACM_CONNTRACK_LISTENER
|
||||
#define IPACM_CONNTRACK_LISTENER
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "IPACM_CmdQueue.h"
|
||||
#include "IPACM_Conntrack_NATApp.h"
|
||||
#include "IPACM_Listener.h"
|
||||
#ifdef CT_OPT
|
||||
#include "IPACM_LanToLan.h"
|
||||
#endif
|
||||
|
||||
#define MAX_IFACE_ADDRESS 50
|
||||
#define MAX_STA_CLNT_IFACES 10
|
||||
#define STA_CLNT_SUBNET_MASK 0xFFFFFF00
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct _nat_entry_bundle
|
||||
{
|
||||
struct nf_conntrack *ct;
|
||||
enum nf_conntrack_msg_type type;
|
||||
nat_table_entry *rule;
|
||||
bool isTempEntry;
|
||||
|
||||
}nat_entry_bundle;
|
||||
|
||||
class IPACM_ConntrackListener : public IPACM_Listener
|
||||
{
|
||||
|
||||
private:
|
||||
bool isCTReg;
|
||||
bool isNatThreadStart;
|
||||
bool WanUp;
|
||||
NatApp *nat_inst;
|
||||
|
||||
int NatIfaceCnt;
|
||||
int StaClntCnt;
|
||||
NatIfaces *pNatIfaces;
|
||||
uint32_t nat_iface_ipv4_addr[MAX_IFACE_ADDRESS];
|
||||
uint32_t nonnat_iface_ipv4_addr[MAX_IFACE_ADDRESS];
|
||||
uint32_t sta_clnt_ipv4_addr[MAX_STA_CLNT_IFACES];
|
||||
IPACM_Config *pConfig;
|
||||
#ifdef CT_OPT
|
||||
IPACM_LanToLan *p_lan2lan;
|
||||
#endif
|
||||
|
||||
void ProcessCTMessage(void *);
|
||||
void ProcessTCPorUDPMsg(struct nf_conntrack *,
|
||||
enum nf_conntrack_msg_type, u_int8_t);
|
||||
void TriggerWANUp(void *);
|
||||
void TriggerWANDown(uint32_t);
|
||||
int CreateNatThreads(void);
|
||||
int CreateConnTrackThreads(void);
|
||||
bool AddIface(nat_table_entry *, bool *);
|
||||
void AddORDeleteNatEntry(const nat_entry_bundle *);
|
||||
void PopulateTCPorUDPEntry(struct nf_conntrack *, uint32_t, nat_table_entry *);
|
||||
void CheckSTAClient(const nat_table_entry *, bool *);
|
||||
int CheckNatIface(ipacm_event_data_all *, bool *);
|
||||
void HandleNonNatIPAddr(void *, bool);
|
||||
|
||||
#ifdef CT_OPT
|
||||
void ProcessCTV6Message(void *);
|
||||
void HandleLan2Lan(struct nf_conntrack *,
|
||||
enum nf_conntrack_msg_type, nat_table_entry* );
|
||||
#endif
|
||||
|
||||
public:
|
||||
char wan_ifname[IPA_IFACE_NAME_LEN];
|
||||
uint32_t wan_ipaddr;
|
||||
bool isStaMode;
|
||||
IPACM_ConntrackListener();
|
||||
void event_callback(ipa_cm_event_id, void *data);
|
||||
inline bool isWanUp()
|
||||
{
|
||||
return WanUp;
|
||||
}
|
||||
|
||||
void HandleNeighIpAddrAddEvt(ipacm_event_data_all *);
|
||||
void HandleNeighIpAddrDelEvt(uint32_t);
|
||||
void HandleSTAClientAddEvt(uint32_t);
|
||||
void HandleSTAClientDelEvt(uint32_t);
|
||||
};
|
||||
|
||||
extern IPACM_ConntrackListener *CtList;
|
||||
|
||||
#endif /* IPACM_CONNTRACK_LISTENER */
|
||||
133
data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h
Normal file
133
data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef IPACM_CONNTRACK_NATAPP_H
|
||||
#define IPACM_CONNTRACK_NATAPP_H
|
||||
|
||||
#include <string.h> /* for stderror */
|
||||
#include <stdlib.h>
|
||||
#include <cstdio> /* for perror */
|
||||
|
||||
#include "IPACM_Config.h"
|
||||
#include "IPACM_Xml.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
|
||||
#include <ipa_nat_drv.h>
|
||||
}
|
||||
|
||||
#define MAX_TEMP_ENTRIES 25
|
||||
|
||||
#define IPACM_TCP_FULL_FILE_NAME "/proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_established"
|
||||
#define IPACM_UDP_FULL_FILE_NAME "/proc/sys/net/ipv4/netfilter/ip_conntrack_udp_timeout_stream"
|
||||
|
||||
typedef struct _nat_table_entry
|
||||
{
|
||||
uint32_t private_ip;
|
||||
uint16_t private_port;
|
||||
|
||||
uint32_t target_ip;
|
||||
uint16_t target_port;
|
||||
|
||||
uint32_t public_ip;
|
||||
uint16_t public_port;
|
||||
|
||||
u_int8_t protocol;
|
||||
uint32_t timestamp;
|
||||
|
||||
bool dst_nat;
|
||||
bool enabled;
|
||||
uint32_t rule_hdl;
|
||||
|
||||
}nat_table_entry;
|
||||
|
||||
#define CHK_TBL_HDL() if(nat_table_hdl == 0){ return -1; }
|
||||
|
||||
class NatApp
|
||||
{
|
||||
private:
|
||||
|
||||
static NatApp *pInstance;
|
||||
|
||||
nat_table_entry *cache;
|
||||
nat_table_entry temp[MAX_TEMP_ENTRIES];
|
||||
uint32_t pub_ip_addr;
|
||||
uint32_t pub_ip_addr_pre;
|
||||
uint32_t nat_table_hdl;
|
||||
|
||||
int curCnt, max_entries;
|
||||
|
||||
ipacm_alg *pALGPorts;
|
||||
uint16_t nALGPort;
|
||||
|
||||
uint32_t tcp_timeout;
|
||||
uint32_t udp_timeout;
|
||||
|
||||
uint32_t PwrSaveIfs[IPA_MAX_NUM_WIFI_CLIENTS];
|
||||
|
||||
struct nf_conntrack *ct;
|
||||
struct nfct_handle *ct_hdl;
|
||||
|
||||
NatApp();
|
||||
int Init();
|
||||
|
||||
void UpdateCTUdpTs(nat_table_entry *, uint32_t);
|
||||
bool ChkForDup(const nat_table_entry *);
|
||||
bool isAlgPort(uint8_t, uint16_t);
|
||||
void Reset();
|
||||
bool isPwrSaveIf(uint32_t);
|
||||
|
||||
public:
|
||||
static NatApp* GetInstance();
|
||||
|
||||
int AddTable(uint32_t);
|
||||
uint32_t GetTableHdl(uint32_t);
|
||||
int DeleteTable(uint32_t);
|
||||
|
||||
int AddEntry(const nat_table_entry *);
|
||||
int DeleteEntry(const nat_table_entry *);
|
||||
|
||||
void UpdateUDPTimeStamp();
|
||||
|
||||
int UpdatePwrSaveIf(uint32_t);
|
||||
int ResetPwrSaveIf(uint32_t);
|
||||
int DelEntriesOnClntDiscon(uint32_t);
|
||||
int DelEntriesOnSTAClntDiscon(uint32_t);
|
||||
|
||||
void Read_TcpUdp_Timeout(void);
|
||||
|
||||
void AddTempEntry(const nat_table_entry *);
|
||||
void CacheEntry(const nat_table_entry *);
|
||||
void DeleteTempEntry(const nat_table_entry *);
|
||||
void FlushTempEntries(uint32_t, bool, bool isDummy = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* IPACM_CONNTRACK_NATAPP_H */
|
||||
354
data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h
Normal file
354
data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h
Normal file
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Defs.h
|
||||
|
||||
@brief
|
||||
This file implements the common definitions amon all ifaces.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPA_CM_DEFS_H
|
||||
#define IPA_CM_DEFS_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
#include "IPACM_Log.h"
|
||||
|
||||
#ifdef USE_GLIB
|
||||
#include <glib.h>
|
||||
#define strlcpy g_strlcpy
|
||||
#define strlcat g_strlcat
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
|
||||
#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
|
||||
}
|
||||
|
||||
#define IF_NAME_LEN 16
|
||||
#define IPA_MAX_FILE_LEN 64
|
||||
#define IPA_IFACE_NAME_LEN 16
|
||||
#define IPA_ALG_PROTOCOL_NAME_LEN 10
|
||||
|
||||
#define IPA_WLAN_PARTIAL_HDR_OFFSET 0 // dst mac first then src mac
|
||||
#define IPA_ODU_PARTIAL_HDR_OFFSET 8 // dst mac first then src mac
|
||||
#define IPA_WLAN_PARTIAL_HDR_NAME_v4 "IEEE802_3_v4"
|
||||
#define IPA_WLAN_PARTIAL_HDR_NAME_v6 "IEEE802_3_v6"
|
||||
#define IPA_DUMMY_ETH_HDR_NAME_v6 "ETH_dummy_v6"
|
||||
#define IPA_WAN_PARTIAL_HDR_NAME_v4 "IEEE802_3_STA_v4"
|
||||
#define IPA_WAN_PARTIAL_HDR_NAME_v6 "IEEE802_3_STA_v6"
|
||||
#define IPA_ETH_HDR_NAME_v4 "IPACM_ETH_v4"
|
||||
#define IPA_ETH_HDR_NAME_v6 "IPACM_ETH_v6"
|
||||
#define IPA_ODU_HDR_NAME_v4 "IPACM_ODU_v4"
|
||||
#define IPA_ODU_HDR_NAME_v6 "IPACM_ODU_v6"
|
||||
|
||||
|
||||
#define IPA_MAX_IFACE_ENTRIES 20
|
||||
#define IPA_MAX_PRIVATE_SUBNET_ENTRIES 3
|
||||
#define IPA_MAX_ALG_ENTRIES 20
|
||||
#define IPA_MAX_RM_ENTRY 6
|
||||
|
||||
#define IPV4_ADDR_LINKLOCAL 0xA9FE0000
|
||||
#define IPV4_ADDR_LINKLOCAL_MASK 0xFFFF0000
|
||||
|
||||
#define V4_DEFAULT_ROUTE_TABLE_NAME "ipa_dflt_rt"
|
||||
#define V4_LAN_ROUTE_TABLE_NAME "COMRTBLLANv4"
|
||||
#define V4_WAN_ROUTE_TABLE_NAME "WANRTBLv4"
|
||||
#define WAN_DL_ROUTE_TABLE_NAME "ipa_dflt_wan_rt"
|
||||
#define V6_COMMON_ROUTE_TABLE_NAME "COMRTBLv6"
|
||||
#define V6_WAN_ROUTE_TABLE_NAME "WANRTBLv6"
|
||||
#define V4_ODU_ROUTE_TABLE_NAME "ODURTBLv4"
|
||||
#define V6_ODU_ROUTE_TABLE_NAME "ODURTBLv6"
|
||||
|
||||
#define WWAN_QMI_IOCTL_DEVICE_NAME "/dev/wwan_ioctl"
|
||||
#define IPA_DEVICE_NAME "/dev/ipa"
|
||||
#define MAX_NUM_PROP 2
|
||||
|
||||
#ifndef FEATURE_IPA_V3
|
||||
#define IPA_MAX_FLT_RULE 50
|
||||
#else
|
||||
#define IPA_MAX_FLT_RULE 100
|
||||
#endif
|
||||
|
||||
#define TCP_FIN_SHIFT 16
|
||||
#define TCP_SYN_SHIFT 17
|
||||
#define TCP_RST_SHIFT 18
|
||||
#define NUM_IPV6_PREFIX_FLT_RULE 1
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Return values indicating error status
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#define IPACM_SUCCESS 0 /* Successful operation */
|
||||
#define IPACM_FAILURE -1 /* Unsuccessful operation */
|
||||
|
||||
#define IPACM_IP_NULL (ipa_ip_type)0xFF
|
||||
#define IPACM_INVALID_INDEX (ipa_ip_type)0xFF
|
||||
|
||||
#define IPA_MAX_NUM_WIFI_CLIENTS 32
|
||||
#define IPA_MAX_NUM_WAN_CLIENTS 10
|
||||
#define IPA_MAX_NUM_ETH_CLIENTS 15
|
||||
#define IPA_MAX_NUM_AMPDU_RULE 15
|
||||
#define IPA_MAC_ADDR_SIZE 6
|
||||
|
||||
/*===========================================================================
|
||||
GLOBAL DEFINITIONS AND DECLARATIONS
|
||||
===========================================================================*/
|
||||
typedef enum
|
||||
{
|
||||
IPA_CFG_CHANGE_EVENT, /* NULL */
|
||||
IPA_PRIVATE_SUBNET_CHANGE_EVENT, /* ipacm_event_data_fid */
|
||||
IPA_FIREWALL_CHANGE_EVENT, /* NULL */
|
||||
IPA_LINK_UP_EVENT, /* ipacm_event_data_fid */
|
||||
IPA_LINK_DOWN_EVENT, /* ipacm_event_data_fid */
|
||||
IPA_USB_LINK_UP_EVENT, /* ipacm_event_data_fid */
|
||||
IPA_BRIDGE_LINK_UP_EVENT, /* ipacm_event_data_all */
|
||||
IPA_WAN_EMBMS_LINK_UP_EVENT, /* ipacm_event_data_mac */
|
||||
IPA_ADDR_ADD_EVENT, /* ipacm_event_data_addr */
|
||||
IPA_ADDR_DEL_EVENT, /* no use */
|
||||
IPA_ROUTE_ADD_EVENT, /* ipacm_event_data_addr */
|
||||
IPA_ROUTE_DEL_EVENT, /* ipacm_event_data_addr */
|
||||
IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT, /* ipacm_event_data_fid */
|
||||
IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, /* ipacm_event_data_fid */
|
||||
IPA_WLAN_AP_LINK_UP_EVENT, /* ipacm_event_data_mac */
|
||||
IPA_WLAN_STA_LINK_UP_EVENT, /* ipacm_event_data_mac */
|
||||
IPA_WLAN_LINK_DOWN_EVENT, /* ipacm_event_data_mac */
|
||||
IPA_WLAN_CLIENT_ADD_EVENT, /* ipacm_event_data_mac */
|
||||
IPA_WLAN_CLIENT_ADD_EVENT_EX, /* ipacm_event_data_wlan_ex */
|
||||
IPA_WLAN_CLIENT_DEL_EVENT, /* ipacm_event_data_mac */
|
||||
IPA_WLAN_CLIENT_POWER_SAVE_EVENT, /* ipacm_event_data_mac */
|
||||
IPA_WLAN_CLIENT_RECOVER_EVENT, /* ipacm_event_data_mac */
|
||||
IPA_NEW_NEIGH_EVENT, /* ipacm_event_data_all */
|
||||
IPA_DEL_NEIGH_EVENT, /* ipacm_event_data_all */
|
||||
IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, /* ipacm_event_data_all */
|
||||
IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT, /* ipacm_event_data_all */
|
||||
IPA_SW_ROUTING_ENABLE, /* NULL */
|
||||
IPA_SW_ROUTING_DISABLE, /* NULL */
|
||||
IPA_PROCESS_CT_MESSAGE, /* ipacm_ct_evt_data */
|
||||
IPA_PROCESS_CT_MESSAGE_V6, /* ipacm_ct_evt_data */
|
||||
IPA_LAN_TO_LAN_NEW_CONNECTION, /* ipacm_event_connection */
|
||||
IPA_LAN_TO_LAN_DEL_CONNECTION, /* ipacm_event_connection */
|
||||
IPA_WLAN_SWITCH_TO_SCC, /* No Data */
|
||||
IPA_WLAN_SWITCH_TO_MCC, /* No Data */
|
||||
IPA_CRADLE_WAN_MODE_SWITCH, /* ipacm_event_cradle_wan_mode */
|
||||
IPA_WAN_XLAT_CONNECT_EVENT, /* ipacm_event_data_fid */
|
||||
IPA_TETHERING_STATS_UPDATE_EVENT, /* ipacm_event_data_fid */
|
||||
IPA_NETWORK_STATS_UPDATE_EVENT, /* ipacm_event_data_fid */
|
||||
|
||||
IPA_EXTERNAL_EVENT_MAX,
|
||||
|
||||
IPA_HANDLE_WAN_UP, /* ipacm_event_iface_up */
|
||||
IPA_HANDLE_WAN_DOWN, /* ipacm_event_iface_up */
|
||||
IPA_HANDLE_WAN_UP_V6, /* NULL */
|
||||
IPA_HANDLE_WAN_DOWN_V6, /* NULL */
|
||||
IPA_HANDLE_WAN_UP_TETHER, /* ipacm_event_iface_up_tehter */
|
||||
IPA_HANDLE_WAN_DOWN_TETHER, /* ipacm_event_iface_up_tehter */
|
||||
IPA_HANDLE_WAN_UP_V6_TETHER, /* ipacm_event_iface_up_tehter */
|
||||
IPA_HANDLE_WAN_DOWN_V6_TETHER, /* ipacm_event_iface_up_tehter */
|
||||
IPA_HANDLE_WLAN_UP, /* ipacm_event_iface_up */
|
||||
IPA_HANDLE_LAN_UP, /* ipacm_event_iface_up */
|
||||
IPA_ETH_BRIDGE_IFACE_UP, /* ipacm_event_eth_bridge*/
|
||||
IPA_ETH_BRIDGE_IFACE_DOWN, /* ipacm_event_eth_bridge*/
|
||||
IPA_ETH_BRIDGE_CLIENT_ADD, /* ipacm_event_eth_bridge */
|
||||
IPA_ETH_BRIDGE_CLIENT_DEL, /* ipacm_event_eth_bridge*/
|
||||
IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH, /* ipacm_event_eth_bridge*/
|
||||
IPA_LAN_DELETE_SELF, /* ipacm_event_data_fid */
|
||||
IPACM_EVENT_MAX
|
||||
} ipa_cm_event_id;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t num_rule;
|
||||
uint32_t rule_hdl[MAX_NUM_PROP];
|
||||
} lan_to_lan_rt_rule_hdl;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LAN_IF = 0,
|
||||
WLAN_IF,
|
||||
WAN_IF,
|
||||
VIRTUAL_IF,
|
||||
ETH_IF,
|
||||
EMBMS_IF,
|
||||
ODU_IF,
|
||||
UNKNOWN_IF
|
||||
} ipacm_iface_type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ROUTER = 0,
|
||||
BRIDGE
|
||||
} ipacm_cradle_iface_mode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FULL,
|
||||
INTERNET
|
||||
} ipacm_wlan_access_mode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct nf_conntrack *ct;
|
||||
enum nf_conntrack_msg_type type;
|
||||
}ipacm_ct_evt_data;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char iface_name[IPA_IFACE_NAME_LEN];
|
||||
ipacm_iface_type if_cat;
|
||||
ipacm_cradle_iface_mode if_mode;
|
||||
ipacm_wlan_access_mode wlan_mode;
|
||||
int netlink_interface_index;
|
||||
} ipa_ifi_dev_name_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t subnet_addr;
|
||||
uint32_t subnet_mask;
|
||||
} ipa_private_subnet;
|
||||
|
||||
|
||||
typedef struct _ipacm_event_data_all
|
||||
{
|
||||
enum ipa_ip_type iptype;
|
||||
int if_index;
|
||||
uint32_t ipv4_addr;
|
||||
uint32_t ipv6_addr[4];
|
||||
uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
|
||||
} ipacm_event_data_all;
|
||||
|
||||
class IPACM_Lan;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ipacm_cradle_iface_mode cradle_wan_mode;
|
||||
} ipacm_event_cradle_wan_mode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IPACM_Lan *p_iface;
|
||||
ipa_ip_type iptype;
|
||||
uint8_t mac_addr[6];
|
||||
} ipacm_event_eth_bridge;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
enum ipa_ip_type iptype;
|
||||
uint32_t src_ipv4_addr;
|
||||
uint32_t dst_ipv4_addr;
|
||||
uint32_t src_ipv6_addr[4];
|
||||
uint32_t dst_ipv6_addr[4];
|
||||
} ipacm_event_connection;
|
||||
|
||||
typedef struct _ipacm_event_data_fid
|
||||
{
|
||||
int if_index;
|
||||
} ipacm_event_data_fid;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ipacm_iface_type if_cat;
|
||||
} ipacm_event_data_if_cat;
|
||||
|
||||
typedef struct _ipacm_event_data_iptype
|
||||
{
|
||||
int if_index;
|
||||
int if_index_tether;
|
||||
enum ipa_ip_type iptype;
|
||||
#ifdef IPA_WAN_MSG_IPv6_ADDR_GW_LEN
|
||||
uint32_t ipv4_addr_gw;
|
||||
uint32_t ipv6_addr_gw[4];
|
||||
#endif
|
||||
} ipacm_event_data_iptype;
|
||||
|
||||
|
||||
typedef struct _ipacm_event_data_addr
|
||||
{
|
||||
enum ipa_ip_type iptype;
|
||||
int if_index;
|
||||
uint32_t ipv4_addr_gw;
|
||||
uint32_t ipv4_addr;
|
||||
uint32_t ipv4_addr_mask;
|
||||
uint32_t ipv6_addr[4];
|
||||
uint32_t ipv6_addr_mask[4];
|
||||
uint32_t ipv6_addr_gw[4];
|
||||
} ipacm_event_data_addr;
|
||||
|
||||
typedef struct _ipacm_event_data_mac
|
||||
{
|
||||
int if_index;
|
||||
int ipa_if_cate;
|
||||
uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
|
||||
} ipacm_event_data_mac;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int if_index;
|
||||
uint8_t num_of_attribs;
|
||||
struct ipa_wlan_hdr_attrib_val attribs[0];
|
||||
} ipacm_event_data_wlan_ex;
|
||||
|
||||
typedef struct _ipacm_event_iface_up
|
||||
{
|
||||
char ifname[IPA_IFACE_NAME_LEN];
|
||||
uint32_t ipv4_addr;
|
||||
uint32_t addr_mask;
|
||||
uint32_t ipv6_prefix[2];
|
||||
bool is_sta;
|
||||
uint8_t xlat_mux_id;
|
||||
}ipacm_event_iface_up;
|
||||
|
||||
typedef struct _ipacm_event_iface_up_tether
|
||||
{
|
||||
uint32_t if_index_tether;
|
||||
uint32_t ipv6_prefix[2];
|
||||
bool is_sta;
|
||||
}ipacm_event_iface_up_tehter;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Q6_WAN = 0,
|
||||
WLAN_WAN,
|
||||
ECM_WAN
|
||||
} ipacm_wan_iface_type;
|
||||
|
||||
typedef struct _ipacm_ifacemgr_data
|
||||
{
|
||||
int if_index;
|
||||
ipacm_wan_iface_type if_type;
|
||||
uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
|
||||
}ipacm_ifacemgr_data;
|
||||
|
||||
#endif /* IPA_CM_DEFS_H */
|
||||
76
data-ipa-cfg-mgr/ipacm/inc/IPACM_EvtDispatcher.h
Normal file
76
data-ipa-cfg-mgr/ipacm/inc/IPACM_EvtDispatcher.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@file
|
||||
IPACM_EvtDispatcher.h
|
||||
|
||||
@brief
|
||||
This file implements the IPAM event dispatcher definitions
|
||||
|
||||
@Author
|
||||
|
||||
*/
|
||||
#ifndef IPACM_EvtDispatcher_H
|
||||
#define IPACM_EvtDispatcher_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <IPACM_CmdQueue.h>
|
||||
#include "IPACM_Defs.h"
|
||||
#include "IPACM_Listener.h"
|
||||
|
||||
/* queue */
|
||||
typedef struct _cmd_evts
|
||||
{
|
||||
ipa_cm_event_id event;
|
||||
IPACM_Listener *obj;
|
||||
//int ipa_interface_index;
|
||||
_cmd_evts *next;
|
||||
} cmd_evts;
|
||||
|
||||
|
||||
|
||||
class IPACM_EvtDispatcher
|
||||
{
|
||||
public:
|
||||
|
||||
/* api for all iface instances to register events */
|
||||
static int registr(ipa_cm_event_id event, IPACM_Listener *obj);
|
||||
|
||||
/* api for all iface instances to de-register events */
|
||||
static int deregistr(IPACM_Listener *obj);
|
||||
|
||||
static int PostEvt(ipacm_cmd_q_data *);
|
||||
static void ProcessEvt(ipacm_cmd_q_data *);
|
||||
|
||||
private:
|
||||
static cmd_evts *head;
|
||||
};
|
||||
|
||||
#endif /* IPACM_EvtDispatcher_H */
|
||||
76
data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h
Normal file
76
data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@file
|
||||
IPACM_Filtering.h
|
||||
|
||||
@brief
|
||||
This file implements the IPACM filtering definitions
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
|
||||
#ifndef IPACM_FILTERING_H
|
||||
#define IPACM_FILTERING_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
#include <IPACM_Defs.h>
|
||||
#include <linux/rmnet_ipa_fd_ioctl.h>
|
||||
|
||||
class IPACM_Filtering
|
||||
{
|
||||
public:
|
||||
IPACM_Filtering();
|
||||
~IPACM_Filtering();
|
||||
bool AddFilteringRule(struct ipa_ioc_add_flt_rule const *ruleTable);
|
||||
bool AddFilteringRuleAfter(struct ipa_ioc_add_flt_rule_after const *ruleTable);
|
||||
bool DeleteFilteringRule(struct ipa_ioc_del_flt_rule *ruleTable);
|
||||
bool Commit(enum ipa_ip_type ip);
|
||||
bool Reset(enum ipa_ip_type ip);
|
||||
bool DeviceNodeIsOpened();
|
||||
bool DeleteFilteringHdls(uint32_t *flt_rule_hdls,
|
||||
ipa_ip_type ip,
|
||||
uint8_t num_rules);
|
||||
|
||||
bool 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);
|
||||
bool SendFilteringRuleIndex(struct ipa_fltr_installed_notif_req_msg_v01* table);
|
||||
bool ModifyFilteringRule(struct ipa_ioc_mdfy_flt_rule* ruleTable);
|
||||
ipa_filter_action_enum_v01 GetQmiFilterAction(ipa_flt_action action);
|
||||
|
||||
private:
|
||||
static const char *DEVICE_NAME;
|
||||
int fd; /* File descriptor of the IPA device node /dev/ipa */
|
||||
};
|
||||
|
||||
#endif //IPACM_FILTERING_H
|
||||
|
||||
70
data-ipa-cfg-mgr/ipacm/inc/IPACM_Header.h
Normal file
70
data-ipa-cfg-mgr/ipacm/inc/IPACM_Header.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* IPACM_Header.h
|
||||
*
|
||||
* Created on: Jun 20, 2012
|
||||
* Author: tatias
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef IPACM_HEADER_H
|
||||
#define IPACM_HEADER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "linux/msm_ipa.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class IPACM_Header
|
||||
{
|
||||
private:
|
||||
int m_fd;
|
||||
public:
|
||||
bool AddHeader(struct ipa_ioc_add_hdr *pHeaderTable);
|
||||
bool DeleteHeader(struct ipa_ioc_del_hdr *pHeaderTable);
|
||||
bool GetHeaderHandle(struct ipa_ioc_get_hdr *pHeaderStruct);
|
||||
bool CopyHeader(struct ipa_ioc_copy_hdr *pCopyHeaderStruct);
|
||||
bool Commit();
|
||||
bool Reset();
|
||||
bool DeleteHeaderHdl(uint32_t hdr_hdl);
|
||||
bool AddHeaderProcCtx(struct ipa_ioc_add_hdr_proc_ctx* pHeader);
|
||||
bool DeleteHeaderProcCtx(uint32_t hdl);
|
||||
|
||||
IPACM_Header();
|
||||
~IPACM_Header();
|
||||
bool DeviceNodeIsOpened();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
153
data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h
Normal file
153
data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_iface.h
|
||||
|
||||
@brief
|
||||
This file implements the basis Iface definitions.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_IFACE_H
|
||||
#define IPACM_IFACE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <IPACM_CmdQueue.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
#include "IPACM_Routing.h"
|
||||
#include "IPACM_Filtering.h"
|
||||
#include "IPACM_Header.h"
|
||||
#include "IPACM_EvtDispatcher.h"
|
||||
#include "IPACM_Xml.h"
|
||||
#include "IPACM_Log.h"
|
||||
#include "IPACM_Config.h"
|
||||
#include "IPACM_Defs.h"
|
||||
#include <string.h>
|
||||
|
||||
/* current support 2 ipv6-address*/
|
||||
#define MAX_DEFAULT_v4_ROUTE_RULES 1
|
||||
#define MAX_DEFAULT_v6_ROUTE_RULES 2
|
||||
#define IPV4_DEFAULT_FILTERTING_RULES 3
|
||||
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
#define IPV6_DEFAULT_FILTERTING_RULES 6
|
||||
#else
|
||||
#define IPV6_DEFAULT_FILTERTING_RULES 3
|
||||
#endif
|
||||
|
||||
#define IPV6_DEFAULT_LAN_FILTERTING_RULES 1
|
||||
#define IPV6_NUM_ADDR 3
|
||||
#define MAX_SOFTWAREROUTING_FILTERTING_RULES 2
|
||||
#define INVALID_IFACE -1
|
||||
|
||||
/* iface */
|
||||
class IPACM_Iface :public IPACM_Listener
|
||||
{
|
||||
public:
|
||||
|
||||
/* Static class for reading IPACM configuration from XML file*/
|
||||
static IPACM_Config *ipacmcfg;
|
||||
|
||||
/* IPACM interface id */
|
||||
int ipa_if_num;
|
||||
|
||||
/* IPACM interface category */
|
||||
ipacm_iface_type ipa_if_cate;
|
||||
|
||||
/* IPACM interface name */
|
||||
char dev_name[IF_NAME_LEN];
|
||||
|
||||
/* IPACM interface iptype v4, v6 or both */
|
||||
ipa_ip_type ip_type;
|
||||
|
||||
/* IPACM interface v6 ip-address*/
|
||||
uint32_t ipv6_addr[MAX_DEFAULT_v6_ROUTE_RULES][4];
|
||||
|
||||
uint32_t software_routing_fl_rule_hdl[MAX_SOFTWAREROUTING_FILTERTING_RULES];
|
||||
|
||||
bool softwarerouting_act;
|
||||
|
||||
/* IPACM number of default route rules for ipv6*/
|
||||
int num_dft_rt_v6;
|
||||
|
||||
uint32_t dft_v4fl_rule_hdl[IPV4_DEFAULT_FILTERTING_RULES];
|
||||
uint32_t dft_v6fl_rule_hdl[IPV6_DEFAULT_FILTERTING_RULES + IPV6_DEFAULT_LAN_FILTERTING_RULES];
|
||||
/* create additional set of v6 RT-rules in Wanv6RT table*/
|
||||
uint32_t dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+2*MAX_DEFAULT_v6_ROUTE_RULES];
|
||||
|
||||
ipa_ioc_query_intf *iface_query;
|
||||
ipa_ioc_query_intf_tx_props *tx_prop;
|
||||
ipa_ioc_query_intf_rx_props *rx_prop;
|
||||
|
||||
virtual int handle_down_evt() = 0;
|
||||
|
||||
virtual int handle_addr_evt(ipacm_event_data_addr *data) = 0;
|
||||
|
||||
IPACM_Iface(int iface_index);
|
||||
|
||||
virtual void event_callback(ipa_cm_event_id event,
|
||||
void *data) = 0;
|
||||
|
||||
/* Query ipa_interface_index by given linux interface_index */
|
||||
static int iface_ipa_index_query(int interface_index);
|
||||
|
||||
/* Query ipa_interface ipv4_addr by given linux interface_index */
|
||||
static void iface_addr_query(int interface_index);
|
||||
|
||||
/*Query the IPA endpoint property */
|
||||
int query_iface_property(void);
|
||||
|
||||
/*Configure the initial filter rules */
|
||||
virtual int init_fl_rule(ipa_ip_type iptype);
|
||||
|
||||
/* Change IP Type.*/
|
||||
void config_ip_type(ipa_ip_type iptype);
|
||||
|
||||
/* Get interface index */
|
||||
virtual int ipa_get_if_index(char * if_name, int * if_index);
|
||||
|
||||
static IPACM_Routing m_routing;
|
||||
static IPACM_Filtering m_filtering;
|
||||
static IPACM_Header m_header;
|
||||
|
||||
/* software routing enable */
|
||||
virtual int handle_software_routing_enable(void);
|
||||
|
||||
/* software routing disable */
|
||||
virtual int handle_software_routing_disable(void);
|
||||
|
||||
private:
|
||||
|
||||
static const char *DEVICE_NAME;
|
||||
};
|
||||
|
||||
#endif /* IPACM_IFACE_H */
|
||||
90
data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h
Normal file
90
data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_IfaceManager.h
|
||||
|
||||
@brief
|
||||
This file implements the IPAM iface_manager definitions
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_IFACEMANAGER_H
|
||||
#define IPACM_IFACEMANAGER_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <IPACM_CmdQueue.h>
|
||||
|
||||
#include "IPACM_Routing.h"
|
||||
#include "IPACM_Filtering.h"
|
||||
#include "IPACM_Listener.h"
|
||||
#include "IPACM_Iface.h"
|
||||
|
||||
#define IPA_INSTANCE_NOT_FOUND 0
|
||||
#define IPA_INSTANCE_FOUND 1
|
||||
|
||||
/* queue */
|
||||
typedef struct _iface_instances
|
||||
{
|
||||
/* Linux interface id */
|
||||
int ipa_if_index;
|
||||
IPACM_Listener *obj;
|
||||
_iface_instances *next;
|
||||
} iface_instances;
|
||||
|
||||
|
||||
class IPACM_IfaceManager : public IPACM_Listener
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
IPACM_IfaceManager();
|
||||
|
||||
void event_callback(ipa_cm_event_id event,
|
||||
void *data);
|
||||
|
||||
/* api for all iface instances to de-register instances */
|
||||
static int deregistr(IPACM_Listener *param);
|
||||
|
||||
|
||||
private:
|
||||
int create_iface_instance(ipacm_ifacemgr_data *);
|
||||
|
||||
/* api to register instances */
|
||||
int registr(int ipa_if_index, IPACM_Listener *obj);
|
||||
|
||||
int SearchInstance(int ipa_if_index);
|
||||
|
||||
static iface_instances *head;
|
||||
|
||||
};
|
||||
|
||||
#endif /* IPACM_IFACEMANAGER_H */
|
||||
390
data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h
Normal file
390
data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h
Normal file
@@ -0,0 +1,390 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Lan.h
|
||||
|
||||
@brief
|
||||
This file implements the LAN iface definitions
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_LAN_H
|
||||
#define IPACM_LAN_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
|
||||
#include "IPACM_CmdQueue.h"
|
||||
#include "IPACM_Iface.h"
|
||||
#include "IPACM_Routing.h"
|
||||
#include "IPACM_Filtering.h"
|
||||
#include "IPACM_Config.h"
|
||||
#include "IPACM_Conntrack_NATApp.h"
|
||||
|
||||
#define IPA_WAN_DEFAULT_FILTER_RULE_HANDLES 1
|
||||
#define IPA_PRIV_SUBNET_FILTER_RULE_HANDLES 3
|
||||
#define IPA_NUM_ODU_ROUTE_RULES 2
|
||||
#define MAX_WAN_UL_FILTER_RULES MAX_NUM_EXT_PROPS
|
||||
#define NUM_IPV4_ICMP_FLT_RULE 1
|
||||
#define NUM_IPV6_ICMP_FLT_RULE 1
|
||||
|
||||
/* ndc bandwidth ipatetherstats <ifaceIn> <ifaceOut> */
|
||||
/* <in->out_bytes> <in->out_pkts> <out->in_bytes> <out->in_pkts */
|
||||
|
||||
#define PIPE_STATS "%s %s %lu %lu %lu %lu"
|
||||
#define IPA_PIPE_STATS_FILE_NAME "/data/misc/ipa/tether_stats"
|
||||
|
||||
/* store each lan-iface unicast routing rule and its handler*/
|
||||
struct ipa_lan_rt_rule
|
||||
{
|
||||
ipa_ip_type ip;
|
||||
uint32_t v4_addr;
|
||||
uint32_t v4_addr_mask;
|
||||
uint32_t v6_addr[4];
|
||||
uint32_t rt_rule_hdl[0];
|
||||
};
|
||||
|
||||
/* Support multiple eth client */
|
||||
typedef struct _eth_client_rt_hdl
|
||||
{
|
||||
uint32_t eth_rt_rule_hdl_v4;
|
||||
uint32_t eth_rt_rule_hdl_v6[IPV6_NUM_ADDR];
|
||||
uint32_t eth_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];
|
||||
}eth_client_rt_hdl;
|
||||
|
||||
typedef struct _ipa_eth_client
|
||||
{
|
||||
uint8_t mac[IPA_MAC_ADDR_SIZE];
|
||||
uint32_t v4_addr;
|
||||
uint32_t v6_addr[IPV6_NUM_ADDR][4];
|
||||
uint32_t hdr_hdl_v4;
|
||||
uint32_t hdr_hdl_v6;
|
||||
bool route_rule_set_v4;
|
||||
int route_rule_set_v6;
|
||||
bool ipv4_set;
|
||||
int ipv6_set;
|
||||
bool ipv4_header_set;
|
||||
bool ipv6_header_set;
|
||||
eth_client_rt_hdl eth_rt_hdl[0]; /* depends on number of tx properties */
|
||||
}ipa_eth_client;
|
||||
|
||||
|
||||
/* lan iface */
|
||||
class IPACM_Lan : public IPACM_Iface
|
||||
{
|
||||
public:
|
||||
|
||||
IPACM_Lan(int iface_index);
|
||||
~IPACM_Lan();
|
||||
|
||||
/* store lan's wan-up filter rule handlers */
|
||||
uint32_t lan_wan_fl_rule_hdl[IPA_WAN_DEFAULT_FILTER_RULE_HANDLES];
|
||||
|
||||
/* store private-subnet filter rule handlers */
|
||||
uint32_t private_fl_rule_hdl[IPA_MAX_PRIVATE_SUBNET_ENTRIES];
|
||||
|
||||
/* LAN-iface's callback function */
|
||||
void event_callback(ipa_cm_event_id event, void *data);
|
||||
|
||||
virtual int handle_wan_up(ipa_ip_type ip_type);
|
||||
|
||||
/* configure filter rule for wan_up event*/
|
||||
virtual int handle_wan_up_ex(ipacm_ext_prop* ext_prop, ipa_ip_type iptype, uint8_t xlat_mux_id);
|
||||
|
||||
/* delete filter rule for wan_down event*/
|
||||
virtual int handle_wan_down(bool is_sta_mode);
|
||||
|
||||
/* delete filter rule for wan_down event*/
|
||||
virtual int handle_wan_down_v6(bool is_sta_mode);
|
||||
|
||||
/* configure private subnet filter rules*/
|
||||
virtual int handle_private_subnet(ipa_ip_type iptype);
|
||||
|
||||
/* handle new_address event*/
|
||||
int handle_addr_evt(ipacm_event_data_addr *data);
|
||||
|
||||
int handle_addr_evt_odu_bridge(ipacm_event_data_addr* data);
|
||||
|
||||
int handle_del_ipv6_addr(ipacm_event_data_all *data);
|
||||
|
||||
static bool odu_up;
|
||||
|
||||
/* install UL filter rule from Q6 */
|
||||
virtual int handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype, uint8_t xlat_mux_id);
|
||||
|
||||
int handle_cradle_wan_mode_switch(bool is_wan_bridge_mode);
|
||||
|
||||
int install_ipv4_icmp_flt_rule();
|
||||
|
||||
|
||||
/* add header processing context and return handle to lan2lan controller */
|
||||
int eth_bridge_add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_hdr_type, uint32_t *hdl);
|
||||
|
||||
/* add routing rule and return handle to lan2lan controller */
|
||||
int eth_bridge_add_rt_rule(uint8_t *mac, char *rt_tbl_name, uint32_t hdr_proc_ctx_hdl,
|
||||
ipa_hdr_l2_type peer_l2_hdr_type, ipa_ip_type iptype, uint32_t *rt_rule_hdl, int *rt_rule_count);
|
||||
|
||||
/* modify routing rule*/
|
||||
int eth_bridge_modify_rt_rule(uint8_t *mac, uint32_t hdr_proc_ctx_hdl,
|
||||
ipa_hdr_l2_type peer_l2_hdr_type, ipa_ip_type iptype, uint32_t *rt_rule_hdl, int rt_rule_count);
|
||||
|
||||
/* add filtering rule and return handle to lan2lan controller */
|
||||
int eth_bridge_add_flt_rule(uint8_t *mac, uint32_t rt_tbl_hdl, ipa_ip_type iptype, uint32_t *flt_rule_hdl);
|
||||
|
||||
/* delete filtering rule */
|
||||
int eth_bridge_del_flt_rule(uint32_t flt_rule_hdl, ipa_ip_type iptype);
|
||||
|
||||
/* delete routing rule */
|
||||
int eth_bridge_del_rt_rule(uint32_t rt_rule_hdl, ipa_ip_type iptype);
|
||||
|
||||
/* delete header processing context */
|
||||
int eth_bridge_del_hdr_proc_ctx(uint32_t hdr_proc_ctx_hdl);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
int each_client_rt_rule_count[IPA_IP_MAX];
|
||||
|
||||
uint32_t eth_bridge_flt_rule_offset[IPA_IP_MAX];
|
||||
|
||||
/* mac address has to be provided for client related events */
|
||||
void eth_bridge_post_event(ipa_cm_event_id evt, ipa_ip_type iptype, uint8_t *mac);
|
||||
|
||||
|
||||
|
||||
virtual int add_dummy_private_subnet_flt_rule(ipa_ip_type iptype);
|
||||
|
||||
int handle_private_subnet_android(ipa_ip_type iptype);
|
||||
|
||||
int reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl);
|
||||
|
||||
virtual int install_ipv6_prefix_flt_rule(uint32_t* prefix);
|
||||
|
||||
virtual void delete_ipv6_prefix_flt_rule();
|
||||
|
||||
int install_ipv6_icmp_flt_rule();
|
||||
|
||||
void post_del_self_evt();
|
||||
|
||||
/* handle tethering stats */
|
||||
int handle_tethering_stats_event(ipa_get_data_stats_resp_msg_v01 *data);
|
||||
|
||||
/* handle tethering client */
|
||||
int handle_tethering_client(bool reset, ipacm_client_enum ipa_client);
|
||||
|
||||
/* store ipv4 UL filter rule handlers from Q6*/
|
||||
uint32_t wan_ul_fl_rule_hdl_v4[MAX_WAN_UL_FILTER_RULES];
|
||||
|
||||
/* store ipv6 UL filter rule handlers from Q6*/
|
||||
uint32_t wan_ul_fl_rule_hdl_v6[MAX_WAN_UL_FILTER_RULES];
|
||||
|
||||
uint32_t ipv4_icmp_flt_rule_hdl[NUM_IPV4_ICMP_FLT_RULE];
|
||||
|
||||
uint32_t ipv6_prefix_flt_rule_hdl[NUM_IPV6_PREFIX_FLT_RULE];
|
||||
uint32_t ipv6_icmp_flt_rule_hdl[NUM_IPV6_ICMP_FLT_RULE];
|
||||
|
||||
int num_wan_ul_fl_rule_v4;
|
||||
int num_wan_ul_fl_rule_v6;
|
||||
|
||||
bool is_active;
|
||||
bool modem_ul_v4_set;
|
||||
bool modem_ul_v6_set;
|
||||
|
||||
uint32_t if_ipv4_subnet;
|
||||
|
||||
uint32_t ipv6_prefix[2];
|
||||
|
||||
private:
|
||||
|
||||
/* get hdr proc ctx type given source and destination l2 hdr type */
|
||||
ipa_hdr_proc_type eth_bridge_get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2);
|
||||
|
||||
/* get partial header (header template of hdr proc ctx) */
|
||||
int eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl);
|
||||
|
||||
|
||||
/* dynamically allocate lan iface's unicast routing rule structure */
|
||||
|
||||
bool is_mode_switch; /* indicate mode switch, need post internal up event */
|
||||
|
||||
int eth_client_len;
|
||||
|
||||
ipa_eth_client *eth_client;
|
||||
|
||||
int header_name_count;
|
||||
|
||||
int num_eth_client;
|
||||
|
||||
NatApp *Nat_App;
|
||||
|
||||
int ipv6_set;
|
||||
|
||||
uint32_t ODU_hdr_hdl_v4, ODU_hdr_hdl_v6;
|
||||
|
||||
uint32_t *odu_route_rule_v4_hdl;
|
||||
|
||||
uint32_t *odu_route_rule_v6_hdl;
|
||||
|
||||
bool ipv4_header_set;
|
||||
|
||||
bool ipv6_header_set;
|
||||
|
||||
inline ipa_eth_client* get_client_memptr(ipa_eth_client *param, int cnt)
|
||||
{
|
||||
char *ret = ((char *)param) + (eth_client_len * cnt);
|
||||
return (ipa_eth_client *)ret;
|
||||
}
|
||||
|
||||
inline int get_eth_client_index(uint8_t *mac_addr)
|
||||
{
|
||||
int cnt;
|
||||
int num_eth_client_tmp = num_eth_client;
|
||||
|
||||
IPACMDBG_H("Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
|
||||
for(cnt = 0; cnt < num_eth_client_tmp; cnt++)
|
||||
{
|
||||
IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
get_client_memptr(eth_client, cnt)->mac[0],
|
||||
get_client_memptr(eth_client, cnt)->mac[1],
|
||||
get_client_memptr(eth_client, cnt)->mac[2],
|
||||
get_client_memptr(eth_client, cnt)->mac[3],
|
||||
get_client_memptr(eth_client, cnt)->mac[4],
|
||||
get_client_memptr(eth_client, cnt)->mac[5]);
|
||||
|
||||
if(memcmp(get_client_memptr(eth_client, cnt)->mac,
|
||||
mac_addr,
|
||||
sizeof(get_client_memptr(eth_client, cnt)->mac)) == 0)
|
||||
{
|
||||
IPACMDBG_H("Matched client index: %d\n", cnt);
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
|
||||
return IPACM_INVALID_INDEX;
|
||||
}
|
||||
|
||||
inline int delete_eth_rtrules(int clt_indx, ipa_ip_type iptype)
|
||||
{
|
||||
uint32_t tx_index;
|
||||
uint32_t rt_hdl;
|
||||
int num_v6;
|
||||
|
||||
if(iptype == IPA_IP_v4)
|
||||
{
|
||||
for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
|
||||
{
|
||||
if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(eth_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */
|
||||
{
|
||||
IPACMDBG_H("Delete client index %d ipv4 RT-rules for tx:%d\n",clt_indx,tx_index);
|
||||
rt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v4;
|
||||
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
}
|
||||
} /* end of for loop */
|
||||
|
||||
/* clean the ipv4 RT rules for eth-client:clt_indx */
|
||||
if(get_client_memptr(eth_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */
|
||||
{
|
||||
get_client_memptr(eth_client, clt_indx)->route_rule_set_v4 = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(iptype == IPA_IP_v6)
|
||||
{
|
||||
for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
|
||||
{
|
||||
if((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */
|
||||
{
|
||||
for(num_v6 =0;num_v6 < get_client_memptr(eth_client, clt_indx)->route_rule_set_v6;num_v6++)
|
||||
{
|
||||
IPACMDBG_H("Delete client index %d ipv6 RT-rules for %d-st ipv6 for tx:%d\n", clt_indx,num_v6,tx_index);
|
||||
rt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6[num_v6];
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
rt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6_wan[num_v6];
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* end of for loop */
|
||||
|
||||
/* clean the ipv6 RT rules for eth-client:clt_indx */
|
||||
if(get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */
|
||||
{
|
||||
get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
/* handle eth client initial, construct full headers (tx property) */
|
||||
int handle_eth_hdr_init(uint8_t *mac_addr);
|
||||
|
||||
/* handle eth client ip-address */
|
||||
int handle_eth_client_ipaddr(ipacm_event_data_all *data);
|
||||
|
||||
/* handle eth client routing rule*/
|
||||
int handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
|
||||
|
||||
/*handle eth client del mode*/
|
||||
int handle_eth_client_down_evt(uint8_t *mac_addr);
|
||||
|
||||
/* handle odu client initial, construct full headers (tx property) */
|
||||
int handle_odu_hdr_init(uint8_t *mac_addr);
|
||||
|
||||
/* handle odu default route rule configuration */
|
||||
int handle_odu_route_add();
|
||||
|
||||
/* handle odu default route rule deletion */
|
||||
int handle_odu_route_del();
|
||||
|
||||
/*handle lan iface down event*/
|
||||
int handle_down_evt();
|
||||
|
||||
/*handle reset usb-client rt-rules */
|
||||
int handle_lan_client_reset_rt(ipa_ip_type iptype);
|
||||
};
|
||||
|
||||
#endif /* IPACM_LAN_H */
|
||||
202
data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h
Normal file
202
data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* IPACM_LanToLan.h
|
||||
*
|
||||
* Created on: Mar 4th, 2014
|
||||
* Author: Shihuan Liu
|
||||
*/
|
||||
|
||||
#ifndef IPACM_LANTOLAN_H
|
||||
#define IPACM_LANTOLAN_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "linux/msm_ipa.h"
|
||||
#include "IPACM_Iface.h"
|
||||
#include "IPACM_Defs.h"
|
||||
#include "IPACM_Lan.h"
|
||||
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
#include <libxml/list.h>
|
||||
#else/* defined(FEATURE_IPA_ANDROID) */
|
||||
#include <list>
|
||||
#endif /* ndefined(FEATURE_IPA_ANDROID)*/
|
||||
|
||||
#define MAX_NUM_CACHED_CLIENT_ADD_EVENT 10
|
||||
#define MAX_NUM_IFACE 10
|
||||
#define MAX_NUM_CLIENT 16
|
||||
|
||||
struct rt_rule_info
|
||||
{
|
||||
int num_hdl[IPA_IP_MAX]; /* one client may need more than one routing rules on the same routing table depending on tx_prop */
|
||||
uint32_t rule_hdl[IPA_IP_MAX][MAX_NUM_PROP];
|
||||
};
|
||||
|
||||
struct client_info
|
||||
{
|
||||
uint8_t mac_addr[6];
|
||||
rt_rule_info inter_iface_rt_rule_hdl[IPA_HDR_L2_MAX]; /* routing rule handles of inter interface communication based on source l2 header type */
|
||||
rt_rule_info intra_iface_rt_rule_hdl; /* routing rule handles of inter interface communication */
|
||||
};
|
||||
|
||||
struct flt_rule_info
|
||||
{
|
||||
client_info *p_client;
|
||||
uint32_t flt_rule_hdl[IPA_IP_MAX];
|
||||
};
|
||||
|
||||
struct peer_iface_info
|
||||
{
|
||||
class IPACM_LanToLan_Iface *peer;
|
||||
char rt_tbl_name_for_rt[IPA_IP_MAX][IPA_RESOURCE_NAME_MAX];
|
||||
char rt_tbl_name_for_flt[IPA_IP_MAX][IPA_RESOURCE_NAME_MAX];
|
||||
list<flt_rule_info> flt_rule;
|
||||
};
|
||||
|
||||
class IPACM_LanToLan_Iface
|
||||
{
|
||||
public:
|
||||
IPACM_LanToLan_Iface(IPACM_Lan *p_iface);
|
||||
~IPACM_LanToLan_Iface();
|
||||
|
||||
void add_client_rt_rule_for_new_iface();
|
||||
|
||||
void add_all_inter_interface_client_flt_rule(ipa_ip_type iptype);
|
||||
|
||||
void add_all_intra_interface_client_flt_rule(ipa_ip_type iptype);
|
||||
|
||||
void handle_down_event();
|
||||
|
||||
void handle_wlan_scc_mcc_switch();
|
||||
|
||||
void handle_intra_interface_info();
|
||||
|
||||
void handle_new_iface_up(char rt_tbl_name_for_flt[][IPA_RESOURCE_NAME_MAX], char rt_tbl_name_for_rt[][IPA_RESOURCE_NAME_MAX],
|
||||
IPACM_LanToLan_Iface *peer_iface);
|
||||
|
||||
void handle_client_add(uint8_t *mac);
|
||||
|
||||
void handle_client_del(uint8_t *mac);
|
||||
|
||||
void print_data_structure_info();
|
||||
|
||||
IPACM_Lan* get_iface_pointer();
|
||||
|
||||
bool get_m_is_ip_addr_assigned(ipa_ip_type iptype);
|
||||
|
||||
void set_m_is_ip_addr_assigned(ipa_ip_type iptype, bool value);
|
||||
|
||||
bool get_m_support_inter_iface_offload();
|
||||
|
||||
bool get_m_support_intra_iface_offload();
|
||||
|
||||
void increment_ref_cnt_peer_l2_hdr_type(ipa_hdr_l2_type peer_l2_type);
|
||||
|
||||
void decrement_ref_cnt_peer_l2_hdr_type(ipa_hdr_l2_type peer_l2_type);
|
||||
|
||||
private:
|
||||
|
||||
IPACM_Lan *m_p_iface;
|
||||
bool m_is_ip_addr_assigned[IPA_IP_MAX];
|
||||
bool m_support_inter_iface_offload;
|
||||
bool m_support_intra_iface_offload;
|
||||
|
||||
int ref_cnt_peer_l2_hdr_type[IPA_HDR_L2_MAX]; /* reference count of l2 header type of peer interfaces */
|
||||
uint32_t hdr_proc_ctx_for_inter_interface[IPA_HDR_L2_MAX];
|
||||
uint32_t hdr_proc_ctx_for_intra_interface;
|
||||
|
||||
list<client_info> m_client_info; /* client list */
|
||||
list<peer_iface_info> m_peer_iface_info; /* peer information list */
|
||||
|
||||
/* The following members are for intra-interface communication*/
|
||||
peer_iface_info m_intra_interface_info;
|
||||
|
||||
void add_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client);
|
||||
|
||||
void add_client_flt_rule(peer_iface_info *peer, client_info *client, ipa_ip_type iptype);
|
||||
|
||||
void del_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client);
|
||||
|
||||
void del_client_flt_rule(peer_iface_info *peer, client_info *client);
|
||||
|
||||
void add_client_rt_rule(peer_iface_info *peer, client_info *client);
|
||||
|
||||
void del_client_rt_rule(peer_iface_info *peer, client_info *client);
|
||||
|
||||
void clear_all_flt_rule_for_one_peer_iface(peer_iface_info *peer);
|
||||
|
||||
void clear_all_rt_rule_for_one_peer_iface(peer_iface_info *peer);
|
||||
|
||||
void add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type);
|
||||
|
||||
void del_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type);
|
||||
|
||||
void print_peer_info(peer_iface_info *peer_info);
|
||||
|
||||
};
|
||||
|
||||
class IPACM_LanToLan : public IPACM_Listener
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
IPACM_LanToLan();
|
||||
|
||||
private:
|
||||
|
||||
~IPACM_LanToLan();
|
||||
|
||||
list<class IPACM_LanToLan_Iface> m_iface;
|
||||
|
||||
list<ipacm_event_eth_bridge> m_cached_client_add_event;
|
||||
|
||||
void handle_iface_up(ipacm_event_eth_bridge *data);
|
||||
|
||||
void handle_iface_down(ipacm_event_eth_bridge *data);
|
||||
|
||||
void handle_client_add(ipacm_event_eth_bridge *data);
|
||||
|
||||
void handle_client_del(ipacm_event_eth_bridge *data);
|
||||
|
||||
void handle_wlan_scc_mcc_switch(ipacm_event_eth_bridge *data);
|
||||
|
||||
void handle_new_iface_up(IPACM_LanToLan_Iface *new_iface, IPACM_LanToLan_Iface *exist_iface);
|
||||
|
||||
void event_callback(ipa_cm_event_id event, void* param);
|
||||
|
||||
void handle_cached_client_add_event(IPACM_Lan *p_iface);
|
||||
|
||||
void clear_cached_client_add_event(IPACM_Lan *p_iface);
|
||||
|
||||
void print_data_structure_info();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
54
data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h
Normal file
54
data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Listener.h
|
||||
|
||||
@brief
|
||||
This file implements the abstract class notifier.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_LISTENER_H
|
||||
#define IPACM_LISTENER_H
|
||||
|
||||
#include "IPACM_Defs.h"
|
||||
#include "IPACM_CmdQueue.h"
|
||||
|
||||
/* abstract class notifier */
|
||||
class IPACM_Listener
|
||||
{
|
||||
public:
|
||||
virtual void event_callback(ipa_cm_event_id event, void *data) = 0;
|
||||
virtual ~IPACM_Listener(void) {};
|
||||
};
|
||||
|
||||
#endif /* IPACM_LISTENER_H */
|
||||
102
data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h
Normal file
102
data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_log.h
|
||||
|
||||
@brief
|
||||
This file implements the IPAM log functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
|
||||
#ifndef IPACM_LOG_H
|
||||
#define IPACM_LOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#define MAX_BUF_LEN 256
|
||||
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
#define IPACMLOG_FILE "/dev/socket/ipacm_log_file"
|
||||
#else/* defined(FEATURE_IPA_ANDROID) */
|
||||
#define IPACMLOG_FILE "/etc/ipacm_log_file"
|
||||
#endif /* defined(NOT FEATURE_IPA_ANDROID)*/
|
||||
|
||||
typedef struct ipacm_log_buffer_s {
|
||||
char user_data[MAX_BUF_LEN];
|
||||
} ipacm_log_buffer_t;
|
||||
|
||||
void ipacm_log_send( void * user_data);
|
||||
|
||||
static char buffer_send[MAX_BUF_LEN];
|
||||
static char dmesg_cmd[MAX_BUF_LEN];
|
||||
|
||||
#define IPACMDBG_DMESG(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
|
||||
snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s: " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\
|
||||
ipacm_log_send (buffer_send);\
|
||||
printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
|
||||
memset(dmesg_cmd, 0, MAX_BUF_LEN);\
|
||||
snprintf(dmesg_cmd, MAX_BUF_LEN, "echo %s > /dev/kmsg", buffer_send);\
|
||||
system(dmesg_cmd);
|
||||
#ifdef DEBUG
|
||||
#define PERROR(fmt) memset(buffer_send, 0, MAX_BUF_LEN);\
|
||||
snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s()", __FILE__, __LINE__, __FUNCTION__);\
|
||||
ipacm_log_send (buffer_send); \
|
||||
perror(fmt);
|
||||
#define IPACMERR(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
|
||||
snprintf(buffer_send,MAX_BUF_LEN,"ERROR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\
|
||||
ipacm_log_send (buffer_send);\
|
||||
printf("ERROR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
|
||||
#define IPACMDBG_H(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
|
||||
snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\
|
||||
ipacm_log_send (buffer_send);\
|
||||
printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
|
||||
#else
|
||||
#define PERROR(fmt) perror(fmt)
|
||||
#define IPACMERR(fmt, ...) printf("ERR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
|
||||
#define IPACMDBG_H(fmt, ...) printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
|
||||
#endif
|
||||
#define IPACMDBG(fmt, ...) printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
|
||||
#define IPACMLOG(fmt, ...) printf(fmt, ##__VA_ARGS__);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPACM_LOG_H */
|
||||
81
data-ipa-cfg-mgr/ipacm/inc/IPACM_Neighbor.h
Normal file
81
data-ipa-cfg-mgr/ipacm/inc/IPACM_Neighbor.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Neighbor.h
|
||||
|
||||
@brief
|
||||
This file implements the functionality of handling IPACM Neighbor events.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_NEIGHBOR_H
|
||||
#define IPACM_NEIGHBOR_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <IPACM_CmdQueue.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
#include "IPACM_Routing.h"
|
||||
#include "IPACM_Filtering.h"
|
||||
#include "IPACM_Listener.h"
|
||||
#include "IPACM_Iface.h"
|
||||
|
||||
#define IPA_MAX_NUM_NEIGHBOR_CLIENTS 100
|
||||
|
||||
struct ipa_neighbor_client
|
||||
{
|
||||
uint8_t mac_addr[6];
|
||||
int iface_index;
|
||||
uint32_t v4_addr;
|
||||
int ipa_if_num;
|
||||
};
|
||||
|
||||
class IPACM_Neighbor : public IPACM_Listener
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
IPACM_Neighbor();
|
||||
|
||||
void event_callback(ipa_cm_event_id event,
|
||||
void *data);
|
||||
|
||||
private:
|
||||
|
||||
int num_neighbor_client;
|
||||
|
||||
int circular_index;
|
||||
|
||||
ipa_neighbor_client neighbor_client[IPA_MAX_NUM_NEIGHBOR_CLIENTS];
|
||||
|
||||
};
|
||||
|
||||
#endif /* IPACM_NEIGHBOR_H */
|
||||
223
data-ipa-cfg-mgr/ipacm/inc/IPACM_Netlink.h
Normal file
223
data-ipa-cfg-mgr/ipacm/inc/IPACM_Netlink.h
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPA_Netlink.h
|
||||
|
||||
@brief
|
||||
IPACM Netlink Messaging Implementation File
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_NETLINK_H
|
||||
#define IPACM_NETLINK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_addr.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <netinet/in.h>
|
||||
#include "IPACM_Defs.h"
|
||||
|
||||
#define MAX_NUM_OF_FD 10
|
||||
#define IPA_NL_MSG_MAX_LEN (2048)
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Type representing enumeration of NetLink event indication messages
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Types representing parsed NetLink message
|
||||
---------------------------------------------------------------------------*/
|
||||
#define IPA_NLA_PARAM_NONE (0x0000)
|
||||
#define IPA_NLA_PARAM_PREFIXADDR (0x0001)
|
||||
#define IPA_NLA_PARAM_LOCALADDR (0x0002)
|
||||
#define IPA_NLA_PARAM_LABELNAME (0x0004)
|
||||
#define IPA_NLA_PARAM_BCASTADDR (0x0008)
|
||||
#define IPA_NLA_PARAM_ACASTADDR (0x0010)
|
||||
#define IPA_NLA_PARAM_MCASTADDR (0x0020)
|
||||
#define IPA_NLA_PARAM_CACHEINFO (0x0080)
|
||||
#define IPA_NLA_PARAM_PROTOINFO (0x0100)
|
||||
#define IPA_NLA_PARAM_FLAGS (0x0200)
|
||||
|
||||
#define IPA_RTA_PARAM_NONE (0x0000)
|
||||
#define IPA_RTA_PARAM_DST (0x0001)
|
||||
#define IPA_RTA_PARAM_SRC (0x0002)
|
||||
#define IPA_RTA_PARAM_GATEWAY (0x0004)
|
||||
#define IPA_RTA_PARAM_IIF (0x0008)
|
||||
#define IPA_RTA_PARAM_OIF (0x0010)
|
||||
#define IPA_RTA_PARAM_CACHEINFO (0x0020)
|
||||
#define IPA_RTA_PARAM_PRIORITY (0x0080)
|
||||
#define IPA_RTA_PARAM_METRICS (0x0100)
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Type representing function callback registered with a socket listener
|
||||
thread for reading from a socket on receipt of an incoming message
|
||||
---------------------------------------------------------------------------*/
|
||||
typedef int (*ipa_sock_thrd_fd_read_f)(int fd);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IPA_INIT = 0,
|
||||
IPA_LINK_UP_WAIT,
|
||||
IPA_LINK_UP,
|
||||
IPA_LINK_DOWN_WAIT,
|
||||
IPA_LINK_DOWN
|
||||
} ipa_nl_state_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int sk_fd;
|
||||
ipa_sock_thrd_fd_read_f read_func;
|
||||
} ipa_nl_sk_fd_map_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ipa_nl_sk_fd_map_info_t sk_fds[MAX_NUM_OF_FD];
|
||||
fd_set fdset;
|
||||
int num_fd;
|
||||
int max_fd;
|
||||
} ipa_nl_sk_fd_set_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int sk_fd; /* socket descriptor */
|
||||
struct sockaddr_nl sk_addr_loc; /* local address of socket */
|
||||
} ipa_nl_sk_info_t;
|
||||
|
||||
typedef struct ipa_nl_addr_s {
|
||||
struct sockaddr_storage ip_addr;
|
||||
unsigned int mask;
|
||||
} ipa_nl_addr_t;
|
||||
|
||||
typedef struct ipa_nl_proto_info_s {
|
||||
unsigned int param_mask;
|
||||
unsigned int flags;
|
||||
struct ifla_cacheinfo cache_info;
|
||||
} ipa_nl_proto_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct ifinfomsg metainfo; /* from header */
|
||||
} ipa_nl_link_info_t;
|
||||
|
||||
|
||||
|
||||
typedef struct ipa_nl_addr_info_s {
|
||||
struct ifaddrmsg metainfo; /* from header */
|
||||
struct /* attributes */
|
||||
{
|
||||
unsigned int param_mask;
|
||||
unsigned char label_name[IF_NAME_LEN];
|
||||
struct sockaddr_storage prefix_addr;
|
||||
struct sockaddr_storage local_addr;
|
||||
struct sockaddr_storage bcast_addr;
|
||||
struct sockaddr_storage acast_addr;
|
||||
struct sockaddr_storage mcast_addr;
|
||||
} attr_info;
|
||||
} ipa_nl_addr_info_t;
|
||||
|
||||
|
||||
typedef struct ipa_nl_neigh_info_s {
|
||||
struct ndmsg metainfo; /* from header */
|
||||
struct /* attributes */
|
||||
{
|
||||
unsigned int param_mask;
|
||||
struct sockaddr_storage local_addr;
|
||||
struct sockaddr lladdr_hwaddr;
|
||||
} attr_info;
|
||||
} ipa_nl_neigh_info_t;
|
||||
|
||||
|
||||
|
||||
typedef struct ipa_nl_route_info_s {
|
||||
struct rtmsg metainfo; /* from header */
|
||||
struct /* attributes */
|
||||
{
|
||||
unsigned int param_mask;
|
||||
struct sockaddr_storage dst_addr;
|
||||
struct sockaddr_storage src_addr;
|
||||
struct sockaddr_storage gateway_addr;
|
||||
struct sockaddr_storage mark_addr;
|
||||
struct rta_cacheinfo cache_info;
|
||||
__u32 iif_index; /* Link index */
|
||||
__u32 oif_index; /* Link index */
|
||||
__u32 priority;
|
||||
__u32 metrics;
|
||||
ipa_nl_proto_info_t proto_info;
|
||||
} attr_info;
|
||||
} ipa_nl_route_info_t;
|
||||
|
||||
#define IPA_FLOW_TYPE_INVALID (-1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int type;
|
||||
bool link_event;
|
||||
/* Optional parameters */
|
||||
ipa_nl_link_info_t nl_link_info;
|
||||
ipa_nl_addr_info_t nl_addr_info;
|
||||
ipa_nl_neigh_info_t nl_neigh_info;
|
||||
ipa_nl_route_info_t nl_route_info;
|
||||
} ipa_nl_msg_t;
|
||||
|
||||
/* Initialization routine for listener on NetLink sockets interface */
|
||||
int ipa_nl_listener_init
|
||||
(
|
||||
unsigned int nl_type,
|
||||
unsigned int nl_groups,
|
||||
ipa_nl_sk_fd_set_info_t *sk_fdset,
|
||||
ipa_sock_thrd_fd_read_f read_f
|
||||
);
|
||||
|
||||
/* Virtual function registered to receive incoming messages over the NETLINK routing socket*/
|
||||
int ipa_nl_recv_msg(int fd);
|
||||
|
||||
/* map mask value for ipv6 */
|
||||
int mask_v6(int index, uint32_t *mask);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPACM_NETLINK_H */
|
||||
78
data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h
Normal file
78
data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Routing.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPACM routing functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef IPACM_ROUTING_H
|
||||
#define IPACM_ROUTING_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
#include <IPACM_Defs.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class IPACM_Routing
|
||||
{
|
||||
public:
|
||||
IPACM_Routing();
|
||||
~IPACM_Routing();
|
||||
|
||||
bool AddRoutingRule(struct ipa_ioc_add_rt_rule *ruleTable);
|
||||
bool DeleteRoutingRule(struct ipa_ioc_del_rt_rule *ruleTable);
|
||||
|
||||
bool Commit(enum ipa_ip_type ip);
|
||||
bool Reset(enum ipa_ip_type ip);
|
||||
|
||||
bool GetRoutingTable(struct ipa_ioc_get_rt_tbl *routingTable);
|
||||
|
||||
bool DeviceNodeIsOpened();
|
||||
bool DeleteRoutingHdl(uint32_t rt_rule_hdl, ipa_ip_type ip);
|
||||
|
||||
bool ModifyRoutingRule(struct ipa_ioc_mdfy_rt_rule *);
|
||||
|
||||
private:
|
||||
static const char *DEVICE_NAME;
|
||||
int m_fd; /* File descriptor of the IPA device node /dev/ipa */
|
||||
|
||||
bool PutRoutingTable(uint32_t routingTableHandle);
|
||||
};
|
||||
|
||||
#endif //IPACM_ROUTING_H
|
||||
|
||||
499
data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h
Normal file
499
data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h
Normal file
@@ -0,0 +1,499 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Wan.cpp
|
||||
|
||||
@brief
|
||||
This file implements the WAN iface functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_WAN_H
|
||||
#define IPACM_WAN_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <IPACM_CmdQueue.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
#include "IPACM_Routing.h"
|
||||
#include "IPACM_Filtering.h"
|
||||
#include <IPACM_Iface.h>
|
||||
#include <IPACM_Defs.h>
|
||||
#include <IPACM_Xml.h>
|
||||
|
||||
#define IPA_NUM_DEFAULT_WAN_FILTER_RULES 3 /*1 for v4, 2 for v6*/
|
||||
#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4 2
|
||||
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6 6
|
||||
#else
|
||||
#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6 3
|
||||
#endif
|
||||
|
||||
#define NETWORK_STATS "%s %lu %lu %lu %lu"
|
||||
#define IPA_NETWORK_STATS_FILE_NAME "/data/misc/ipa/network_stats"
|
||||
|
||||
typedef struct _wan_client_rt_hdl
|
||||
{
|
||||
uint32_t wan_rt_rule_hdl_v4;
|
||||
uint32_t wan_rt_rule_hdl_v6[IPV6_NUM_ADDR];
|
||||
uint32_t wan_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];
|
||||
}wan_client_rt_hdl;
|
||||
|
||||
typedef struct _ipa_wan_client
|
||||
{
|
||||
ipacm_event_data_wlan_ex* p_hdr_info;
|
||||
uint8_t mac[IPA_MAC_ADDR_SIZE];
|
||||
uint32_t v4_addr;
|
||||
uint32_t v6_addr[IPV6_NUM_ADDR][4];
|
||||
uint32_t hdr_hdl_v4;
|
||||
uint32_t hdr_hdl_v6;
|
||||
bool route_rule_set_v4;
|
||||
int route_rule_set_v6;
|
||||
bool ipv4_set;
|
||||
int ipv6_set;
|
||||
bool ipv4_header_set;
|
||||
bool ipv6_header_set;
|
||||
bool power_save_set;
|
||||
wan_client_rt_hdl wan_rt_hdl[0]; /* depends on number of tx properties */
|
||||
}ipa_wan_client;
|
||||
|
||||
/* wan iface */
|
||||
class IPACM_Wan : public IPACM_Iface
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static bool wan_up;
|
||||
static bool wan_up_v6;
|
||||
static uint8_t xlat_mux_id;
|
||||
/* IPACM interface name */
|
||||
static char wan_up_dev_name[IF_NAME_LEN];
|
||||
static uint32_t curr_wan_ip;
|
||||
IPACM_Wan(int, ipacm_wan_iface_type, uint8_t *);
|
||||
virtual ~IPACM_Wan();
|
||||
|
||||
static bool isWanUP(int ipa_if_num_tether)
|
||||
{
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
int i;
|
||||
for (i=0; i < ipa_if_num_tether_v4_total;i++)
|
||||
{
|
||||
if (ipa_if_num_tether_v4[i] == ipa_if_num_tether)
|
||||
{
|
||||
IPACMDBG_H("support ipv4 tether_iface(%s)\n",
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
|
||||
return wan_up;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return wan_up;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool isWanUP_V6(int ipa_if_num_tether)
|
||||
{
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
int i;
|
||||
for (i=0; i < ipa_if_num_tether_v6_total;i++)
|
||||
{
|
||||
if (ipa_if_num_tether_v6[i] == ipa_if_num_tether)
|
||||
{
|
||||
IPACMDBG_H("support ipv6 tether_iface(%s)\n",
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
|
||||
return wan_up_v6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return wan_up_v6;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t getWANIP()
|
||||
{
|
||||
return curr_wan_ip;
|
||||
}
|
||||
|
||||
static bool getXlat_Mux_Id()
|
||||
{
|
||||
return xlat_mux_id;
|
||||
}
|
||||
|
||||
void event_callback(ipa_cm_event_id event,
|
||||
void *data);
|
||||
|
||||
static struct ipa_flt_rule_add flt_rule_v4[IPA_MAX_FLT_RULE];
|
||||
static struct ipa_flt_rule_add flt_rule_v6[IPA_MAX_FLT_RULE];
|
||||
|
||||
static int num_v4_flt_rule;
|
||||
static int num_v6_flt_rule;
|
||||
|
||||
ipacm_wan_iface_type m_is_sta_mode;
|
||||
static bool backhaul_is_sta_mode;
|
||||
static bool is_ext_prop_set;
|
||||
static uint32_t backhaul_ipv6_prefix[2];
|
||||
|
||||
static bool embms_is_on;
|
||||
static bool backhaul_is_wan_bridge;
|
||||
|
||||
static bool isWan_Bridge_Mode()
|
||||
{
|
||||
return backhaul_is_wan_bridge;
|
||||
}
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
/* IPACM interface id */
|
||||
static int ipa_if_num_tether_v4_total;
|
||||
static int ipa_if_num_tether_v4[IPA_MAX_IFACE_ENTRIES];
|
||||
static int ipa_if_num_tether_v6_total;
|
||||
static int ipa_if_num_tether_v6[IPA_MAX_IFACE_ENTRIES];
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
bool is_ipv6_frag_firewall_flt_rule_installed;
|
||||
uint32_t ipv6_frag_firewall_flt_rule_hdl;
|
||||
uint32_t *wan_route_rule_v4_hdl;
|
||||
uint32_t *wan_route_rule_v6_hdl;
|
||||
uint32_t *wan_route_rule_v6_hdl_a5;
|
||||
uint32_t hdr_hdl_sta_v4;
|
||||
uint32_t hdr_hdl_sta_v6;
|
||||
uint32_t firewall_hdl_v4[IPACM_MAX_FIREWALL_ENTRIES];
|
||||
uint32_t firewall_hdl_v6[IPACM_MAX_FIREWALL_ENTRIES];
|
||||
uint32_t dft_wan_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
|
||||
uint32_t ipv6_dest_flt_rule_hdl[MAX_DEFAULT_v6_ROUTE_RULES];
|
||||
int num_ipv6_dest_flt_rule;
|
||||
uint32_t ODU_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
|
||||
int num_firewall_v4,num_firewall_v6;
|
||||
uint32_t wan_v4_addr;
|
||||
uint32_t wan_v4_addr_gw;
|
||||
uint32_t wan_v6_addr_gw[4];
|
||||
bool wan_v4_addr_set;
|
||||
bool wan_v4_addr_gw_set;
|
||||
bool wan_v6_addr_gw_set;
|
||||
bool active_v4;
|
||||
bool active_v6;
|
||||
bool header_set_v4;
|
||||
bool header_set_v6;
|
||||
bool header_partial_default_wan_v4;
|
||||
bool header_partial_default_wan_v6;
|
||||
uint8_t ext_router_mac_addr[IPA_MAC_ADDR_SIZE];
|
||||
uint8_t netdev_mac[IPA_MAC_ADDR_SIZE];
|
||||
|
||||
static int num_ipv4_modem_pdn;
|
||||
|
||||
static int num_ipv6_modem_pdn;
|
||||
|
||||
int modem_ipv4_pdn_index;
|
||||
|
||||
int modem_ipv6_pdn_index;
|
||||
|
||||
bool is_default_gateway;
|
||||
|
||||
uint32_t ipv6_prefix[2];
|
||||
|
||||
/* IPACM firewall Configuration file*/
|
||||
IPACM_firewall_conf_t firewall_config;
|
||||
|
||||
/* STA mode wan-client*/
|
||||
int wan_client_len;
|
||||
ipa_wan_client *wan_client;
|
||||
int header_name_count;
|
||||
int num_wan_client;
|
||||
uint8_t invalid_mac[IPA_MAC_ADDR_SIZE];
|
||||
bool is_xlat;
|
||||
|
||||
/* update network stats for CNE */
|
||||
int ipa_network_stats_fd;
|
||||
uint32_t hdr_hdl_dummy_v6;
|
||||
uint32_t hdr_proc_hdl_dummy_v6;
|
||||
|
||||
inline ipa_wan_client* get_client_memptr(ipa_wan_client *param, int cnt)
|
||||
{
|
||||
char *ret = ((char *)param) + (wan_client_len * cnt);
|
||||
return (ipa_wan_client *)ret;
|
||||
}
|
||||
|
||||
inline int get_wan_client_index(uint8_t *mac_addr)
|
||||
{
|
||||
int cnt;
|
||||
int num_wan_client_tmp = num_wan_client;
|
||||
|
||||
IPACMDBG_H("Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
|
||||
for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
|
||||
{
|
||||
IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
get_client_memptr(wan_client, cnt)->mac[0],
|
||||
get_client_memptr(wan_client, cnt)->mac[1],
|
||||
get_client_memptr(wan_client, cnt)->mac[2],
|
||||
get_client_memptr(wan_client, cnt)->mac[3],
|
||||
get_client_memptr(wan_client, cnt)->mac[4],
|
||||
get_client_memptr(wan_client, cnt)->mac[5]);
|
||||
|
||||
if(memcmp(get_client_memptr(wan_client, cnt)->mac,
|
||||
mac_addr,
|
||||
sizeof(get_client_memptr(wan_client, cnt)->mac)) == 0)
|
||||
{
|
||||
IPACMDBG_H("Matched client index: %d\n", cnt);
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
|
||||
return IPACM_INVALID_INDEX;
|
||||
}
|
||||
|
||||
inline int get_wan_client_index_ipv4(uint32_t ipv4_addr)
|
||||
{
|
||||
int cnt;
|
||||
int num_wan_client_tmp = num_wan_client;
|
||||
|
||||
IPACMDBG_H("Passed IPv4 %x\n", ipv4_addr);
|
||||
|
||||
for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
|
||||
{
|
||||
if (get_client_memptr(wan_client, cnt)->ipv4_set)
|
||||
{
|
||||
IPACMDBG_H("stored IPv4 %x\n", get_client_memptr(wan_client, cnt)->v4_addr);
|
||||
|
||||
if(ipv4_addr == get_client_memptr(wan_client, cnt)->v4_addr)
|
||||
{
|
||||
IPACMDBG_H("Matched client index: %d\n", cnt);
|
||||
IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
get_client_memptr(wan_client, cnt)->mac[0],
|
||||
get_client_memptr(wan_client, cnt)->mac[1],
|
||||
get_client_memptr(wan_client, cnt)->mac[2],
|
||||
get_client_memptr(wan_client, cnt)->mac[3],
|
||||
get_client_memptr(wan_client, cnt)->mac[4],
|
||||
get_client_memptr(wan_client, cnt)->mac[5]);
|
||||
IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
|
||||
get_client_memptr(wan_client, cnt)->ipv4_header_set,
|
||||
get_client_memptr(wan_client, cnt)->ipv6_header_set);
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
return IPACM_INVALID_INDEX;
|
||||
}
|
||||
|
||||
inline int get_wan_client_index_ipv6(uint32_t* ipv6_addr)
|
||||
{
|
||||
int cnt, v6_num;
|
||||
int num_wan_client_tmp = num_wan_client;
|
||||
|
||||
IPACMDBG_H("Get ipv6 address 0x%08x.0x%08x.0x%08x.0x%08x\n", ipv6_addr[0], ipv6_addr[1], ipv6_addr[2], ipv6_addr[3]);
|
||||
|
||||
for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
|
||||
{
|
||||
if (get_client_memptr(wan_client, cnt)->ipv6_set)
|
||||
{
|
||||
for(v6_num=0;v6_num < get_client_memptr(wan_client, cnt)->ipv6_set;v6_num++)
|
||||
{
|
||||
|
||||
IPACMDBG_H("stored IPv6 0x%08x.0x%08x.0x%08x.0x%08x\n", get_client_memptr(wan_client, cnt)->v6_addr[v6_num][0],
|
||||
get_client_memptr(wan_client, cnt)->v6_addr[v6_num][1],
|
||||
get_client_memptr(wan_client, cnt)->v6_addr[v6_num][2],
|
||||
get_client_memptr(wan_client, cnt)->v6_addr[v6_num][3]);
|
||||
|
||||
if(ipv6_addr[0] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][0] &&
|
||||
ipv6_addr[1] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][1] &&
|
||||
ipv6_addr[2]== get_client_memptr(wan_client, cnt)->v6_addr[v6_num][2] &&
|
||||
ipv6_addr[3] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][3])
|
||||
{
|
||||
IPACMDBG_H("Matched client index: %d\n", cnt);
|
||||
IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
get_client_memptr(wan_client, cnt)->mac[0],
|
||||
get_client_memptr(wan_client, cnt)->mac[1],
|
||||
get_client_memptr(wan_client, cnt)->mac[2],
|
||||
get_client_memptr(wan_client, cnt)->mac[3],
|
||||
get_client_memptr(wan_client, cnt)->mac[4],
|
||||
get_client_memptr(wan_client, cnt)->mac[5]);
|
||||
IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
|
||||
get_client_memptr(wan_client, cnt)->ipv4_header_set,
|
||||
get_client_memptr(wan_client, cnt)->ipv6_header_set);
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return IPACM_INVALID_INDEX;
|
||||
}
|
||||
|
||||
inline int delete_wan_rtrules(int clt_indx, ipa_ip_type iptype)
|
||||
{
|
||||
uint32_t tx_index;
|
||||
uint32_t rt_hdl;
|
||||
int num_v6;
|
||||
|
||||
if(iptype == IPA_IP_v4)
|
||||
{
|
||||
for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
|
||||
{
|
||||
if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */
|
||||
{
|
||||
IPACMDBG_H("Delete client index %d ipv4 Qos rules for tx:%d \n",clt_indx,tx_index);
|
||||
rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v4;
|
||||
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
}
|
||||
} /* end of for loop */
|
||||
|
||||
/* clean the 4 Qos ipv4 RT rules for client:clt_indx */
|
||||
if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */
|
||||
{
|
||||
get_client_memptr(wan_client, clt_indx)->route_rule_set_v4 = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(iptype == IPA_IP_v6)
|
||||
{
|
||||
for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
|
||||
{
|
||||
|
||||
if((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */
|
||||
{
|
||||
for(num_v6 =0;num_v6 < get_client_memptr(wan_client, clt_indx)->route_rule_set_v6;num_v6++)
|
||||
{
|
||||
IPACMDBG_H("Delete client index %d ipv6 Qos rules for %d-st ipv6 for tx:%d\n", clt_indx,num_v6,tx_index);
|
||||
rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6[num_v6];
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6_wan[num_v6];
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} /* end of for loop */
|
||||
|
||||
/* clean the 4 Qos ipv6 RT rules for client:clt_indx */
|
||||
if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */
|
||||
{
|
||||
get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
int handle_wan_hdr_init(uint8_t *mac_addr);
|
||||
int handle_wan_client_ipaddr(ipacm_event_data_all *data);
|
||||
int handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
|
||||
|
||||
/* handle new_address event */
|
||||
int handle_addr_evt(ipacm_event_data_addr *data);
|
||||
|
||||
/* wan default route/filter rule configuration */
|
||||
int handle_route_add_evt(ipa_ip_type iptype);
|
||||
|
||||
/* construct complete STA ethernet header */
|
||||
int handle_sta_header_add_evt();
|
||||
|
||||
bool check_dft_firewall_rules_attr_mask(IPACM_firewall_conf_t *firewall_config);
|
||||
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
/* wan posting supported tether_iface */
|
||||
int post_wan_up_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);
|
||||
|
||||
int post_wan_down_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);
|
||||
#endif
|
||||
int config_dft_firewall_rules(ipa_ip_type iptype);
|
||||
|
||||
/* configure the initial firewall filter rules */
|
||||
int config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, ipa_ioc_add_flt_rule *pFilteringTable_v6);
|
||||
|
||||
int handle_route_del_evt(ipa_ip_type iptype);
|
||||
|
||||
int del_dft_firewall_rules(ipa_ip_type iptype);
|
||||
|
||||
int handle_down_evt();
|
||||
|
||||
/*handle wan-iface down event */
|
||||
int handle_down_evt_ex();
|
||||
|
||||
/* wan default route/filter rule delete */
|
||||
int handle_route_del_evt_ex(ipa_ip_type iptype);
|
||||
|
||||
/* configure the initial firewall filter rules */
|
||||
int config_dft_firewall_rules_ex(struct ipa_flt_rule_add* rules, int rule_offset,
|
||||
ipa_ip_type iptype);
|
||||
|
||||
/* init filtering rule in wan dl filtering table */
|
||||
int init_fl_rule_ex(ipa_ip_type iptype);
|
||||
|
||||
/* add ICMP and ALG rules in wan dl filtering table */
|
||||
int add_icmp_alg_rules(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
|
||||
|
||||
/* query extended property */
|
||||
int query_ext_prop();
|
||||
|
||||
ipa_ioc_query_intf_ext_props *ext_prop;
|
||||
|
||||
int config_wan_firewall_rule(ipa_ip_type iptype);
|
||||
|
||||
int del_wan_firewall_rule(ipa_ip_type iptype);
|
||||
|
||||
int add_dft_filtering_rule(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
|
||||
|
||||
int install_wan_filtering_rule(bool is_sw_routing);
|
||||
|
||||
void change_to_network_order(ipa_ip_type iptype, ipa_rule_attrib* attrib);
|
||||
|
||||
bool is_global_ipv6_addr(uint32_t* ipv6_addr);
|
||||
|
||||
void handle_wlan_SCC_MCC_switch(bool, ipa_ip_type);
|
||||
|
||||
void handle_wan_client_SCC_MCC_switch(bool, ipa_ip_type);
|
||||
|
||||
int handle_network_stats_evt();
|
||||
|
||||
int m_fd_ipa;
|
||||
|
||||
int handle_network_stats_update(ipa_get_apn_data_stats_resp_msg_v01 *data);
|
||||
|
||||
/* construct dummy ethernet header */
|
||||
int add_dummy_rx_hdr();
|
||||
};
|
||||
|
||||
#endif /* IPACM_WAN_H */
|
||||
240
data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h
Normal file
240
data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Wlan.h
|
||||
|
||||
@brief
|
||||
This file implements the WLAN iface functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#ifndef IPACM_WLAN_H
|
||||
#define IPACM_WLAN_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <IPACM_CmdQueue.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
#include "IPACM_Routing.h"
|
||||
#include "IPACM_Filtering.h"
|
||||
#include "IPACM_Lan.h"
|
||||
#include "IPACM_Iface.h"
|
||||
#include "IPACM_Conntrack_NATApp.h"
|
||||
|
||||
typedef struct _wlan_client_rt_hdl
|
||||
{
|
||||
uint32_t wifi_rt_rule_hdl_v4;
|
||||
uint32_t wifi_rt_rule_hdl_v6[IPV6_NUM_ADDR];
|
||||
uint32_t wifi_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];
|
||||
}wlan_client_rt_hdl;
|
||||
|
||||
typedef struct _ipa_wlan_client
|
||||
{
|
||||
ipacm_event_data_wlan_ex* p_hdr_info;
|
||||
uint8_t mac[IPA_MAC_ADDR_SIZE];
|
||||
uint32_t v4_addr;
|
||||
uint32_t v6_addr[IPV6_NUM_ADDR][4];
|
||||
uint32_t hdr_hdl_v4;
|
||||
uint32_t hdr_hdl_v6;
|
||||
bool route_rule_set_v4;
|
||||
int route_rule_set_v6;
|
||||
bool ipv4_set;
|
||||
int ipv6_set;
|
||||
bool ipv4_header_set;
|
||||
bool ipv6_header_set;
|
||||
bool power_save_set;
|
||||
wlan_client_rt_hdl wifi_rt_hdl[0]; /* depends on number of tx properties */
|
||||
}ipa_wlan_client;
|
||||
|
||||
/* wlan iface */
|
||||
class IPACM_Wlan : public IPACM_Lan
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
IPACM_Wlan(int iface_index);
|
||||
virtual ~IPACM_Wlan(void);
|
||||
|
||||
static int total_num_wifi_clients;
|
||||
|
||||
void event_callback(ipa_cm_event_id event, void *data);
|
||||
|
||||
bool is_guest_ap();
|
||||
|
||||
private:
|
||||
|
||||
bool m_is_guest_ap;
|
||||
|
||||
/* handle wlan access mode switch in ethernet bridging*/
|
||||
void eth_bridge_handle_wlan_mode_switch();
|
||||
|
||||
|
||||
int wlan_client_len;
|
||||
ipa_wlan_client *wlan_client;
|
||||
|
||||
int header_name_count;
|
||||
int num_wifi_client;
|
||||
|
||||
int wlan_ap_index;
|
||||
|
||||
static int num_wlan_ap_iface;
|
||||
|
||||
NatApp *Nat_App;
|
||||
|
||||
inline ipa_wlan_client* get_client_memptr(ipa_wlan_client *param, int cnt)
|
||||
{
|
||||
char *ret = ((char *)param) + (wlan_client_len * cnt);
|
||||
return (ipa_wlan_client *)ret;
|
||||
}
|
||||
|
||||
inline int get_wlan_client_index(uint8_t *mac_addr)
|
||||
{
|
||||
int cnt;
|
||||
int num_wifi_client_tmp = num_wifi_client;
|
||||
|
||||
IPACMDBG_H("Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
|
||||
for(cnt = 0; cnt < num_wifi_client_tmp; cnt++)
|
||||
{
|
||||
IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
get_client_memptr(wlan_client, cnt)->mac[0],
|
||||
get_client_memptr(wlan_client, cnt)->mac[1],
|
||||
get_client_memptr(wlan_client, cnt)->mac[2],
|
||||
get_client_memptr(wlan_client, cnt)->mac[3],
|
||||
get_client_memptr(wlan_client, cnt)->mac[4],
|
||||
get_client_memptr(wlan_client, cnt)->mac[5]);
|
||||
|
||||
if(memcmp(get_client_memptr(wlan_client, cnt)->mac,
|
||||
mac_addr,
|
||||
sizeof(get_client_memptr(wlan_client, cnt)->mac)) == 0)
|
||||
{
|
||||
IPACMDBG_H("Matched client index: %d\n", cnt);
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
|
||||
return IPACM_INVALID_INDEX;
|
||||
}
|
||||
|
||||
inline int delete_default_qos_rtrules(int clt_indx, ipa_ip_type iptype)
|
||||
{
|
||||
uint32_t tx_index;
|
||||
uint32_t rt_hdl;
|
||||
int num_v6;
|
||||
|
||||
if(iptype == IPA_IP_v4)
|
||||
{
|
||||
for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
|
||||
{
|
||||
if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(wlan_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */
|
||||
{
|
||||
IPACMDBG_H("Delete client index %d ipv4 Qos rules for tx:%d \n",clt_indx,tx_index);
|
||||
rt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v4;
|
||||
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
}
|
||||
} /* end of for loop */
|
||||
|
||||
/* clean the 4 Qos ipv4 RT rules for client:clt_indx */
|
||||
if(get_client_memptr(wlan_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */
|
||||
{
|
||||
get_client_memptr(wlan_client, clt_indx)->route_rule_set_v4 = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(iptype == IPA_IP_v6)
|
||||
{
|
||||
for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
|
||||
{
|
||||
|
||||
if((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */
|
||||
{
|
||||
for(num_v6 =0;num_v6 < get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6;num_v6++)
|
||||
{
|
||||
IPACMDBG_H("Delete client index %d ipv6 Qos rules for %d-st ipv6 for tx:%d\n", clt_indx,num_v6,tx_index);
|
||||
rt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6[num_v6];
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
rt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6_wan[num_v6];
|
||||
if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} /* end of for loop */
|
||||
|
||||
/* clean the 4 Qos ipv6 RT rules for client:clt_indx */
|
||||
if(get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */
|
||||
{
|
||||
get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
/* for handle wifi client initial,copy all partial headers (tx property) */
|
||||
int handle_wlan_client_init_ex(ipacm_event_data_wlan_ex *data);
|
||||
|
||||
/*handle wifi client */
|
||||
int handle_wlan_client_ipaddr(ipacm_event_data_all *data);
|
||||
|
||||
/*handle wifi client routing rule*/
|
||||
int handle_wlan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
|
||||
|
||||
/*handle wifi client power-save mode*/
|
||||
int handle_wlan_client_pwrsave(uint8_t *mac_addr);
|
||||
|
||||
/*handle wifi client del mode*/
|
||||
int handle_wlan_client_down_evt(uint8_t *mac_addr);
|
||||
|
||||
/*handle wlan iface down event*/
|
||||
int handle_down_evt();
|
||||
|
||||
/*handle reset wifi-client rt-rules */
|
||||
int handle_wlan_client_reset_rt(ipa_ip_type iptype);
|
||||
|
||||
void handle_SCC_MCC_switch(ipa_ip_type);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* IPACM_WLAN_H */
|
||||
303
data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h
Normal file
303
data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h
Normal file
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Xml.h
|
||||
|
||||
@brief
|
||||
This file implements the XML specific parsing functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang/Shihuan Liu
|
||||
|
||||
*/
|
||||
#ifndef IPACM_XML_H
|
||||
#define IPACM_XML_H
|
||||
|
||||
#include <linux/msm_ipa.h>
|
||||
#include "IPACM_Defs.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdint.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define IPACM_ASSERT(a) \
|
||||
if (!(a)) { \
|
||||
fprintf(stderr, "%s, %d: assertion (a) failed!", \
|
||||
__FILE__, \
|
||||
__LINE__); \
|
||||
abort(); \
|
||||
}
|
||||
|
||||
/* Max allowed size of the XML file (2 MB) */
|
||||
#define IPACM_XML_MAX_FILESIZE (2 << 20)
|
||||
#define IPACM_MAX_FIREWALL_ENTRIES 50
|
||||
#define IPACM_IPV6_ADDR_LEN 16
|
||||
|
||||
/* Defines for clipping space or space & quotes (single, double) */
|
||||
#define IPACM_XML_CLIP_SPACE " "
|
||||
#define IPACM_XML_CLIP_SPACE_QUOTES " '\""
|
||||
|
||||
#define MAX_XML_STR_LEN 120
|
||||
|
||||
/* IPA Config Entries */
|
||||
#define system_TAG "system"
|
||||
#define ODU_TAG "ODUCFG"
|
||||
#define ODUMODE_TAG "OduMode"
|
||||
#define ODUEMBMS_OFFLOAD_TAG "eMBMS_offload"
|
||||
#define ODU_ROUTER_TAG "router"
|
||||
#define ODU_BRIDGE_TAG "bridge"
|
||||
#define IPACMCFG_TAG "IPACM"
|
||||
#define IPACMIFACECFG_TAG "IPACMIface"
|
||||
#define IFACE_TAG "Iface"
|
||||
#define NAME_TAG "Name"
|
||||
#define CATEGORY_TAG "Category"
|
||||
#define MODE_TAG "Mode"
|
||||
#define IPACMPRIVATESUBNETCFG_TAG "IPACMPrivateSubnet"
|
||||
#define SUBNET_TAG "Subnet"
|
||||
#define SUBNETADDRESS_TAG "SubnetAddress"
|
||||
#define SUBNETMASK_TAG "SubnetMask"
|
||||
#define WANIF_TAG "WAN"
|
||||
#define LANIF_TAG "LAN"
|
||||
#define WLANIF_TAG "WLAN"
|
||||
#define WLAN_FULL_MODE_TAG "full"
|
||||
#define WLAN_INTERNET_MODE_TAG "internet"
|
||||
#define WLAN_MODE_TAG "WlanMode"
|
||||
#define VIRTUALIF_TAG "VIRTUAL"
|
||||
#define UNKNOWNIF_TAG "UNKNOWN"
|
||||
#define ODUIF_TAG "ODU"
|
||||
#define EMBMSIF_TAG "EMBMS"
|
||||
#define ETHIF_TAG "ETH"
|
||||
#define IFACE_ROUTER_MODE_TAG "ROUTER"
|
||||
#define IFACE_BRIDGE_MODE_TAG "BRIDGE"
|
||||
#define IPACMALG_TAG "IPACMALG"
|
||||
#define ALG_TAG "ALG"
|
||||
#define Protocol_TAG "Protocol"
|
||||
#define Port_TAG "Port"
|
||||
#define TCP_PROTOCOL_TAG "TCP"
|
||||
#define UDP_PROTOCOL_TAG "UDP"
|
||||
|
||||
/* FIREWALL Config Entries */
|
||||
#define Firewall_TAG "Firewall"
|
||||
#define MobileAPFirewallCfg_TAG "MobileAPFirewallCfg"
|
||||
#define FirewallEnabled_TAG "FirewallEnabled"
|
||||
#define FirewallPktsAllowed_TAG "FirewallPktsAllowed"
|
||||
|
||||
#define IPFamily_TAG "IPFamily"
|
||||
#define IPV4SourceAddress_TAG "IPV4SourceAddress"
|
||||
#define IPV4SourceIPAddress_TAG "IPV4SourceIPAddress"
|
||||
#define IPV4SourceSubnetMask_TAG "IPV4SourceSubnetMask"
|
||||
|
||||
#define IPV4DestinationAddress_TAG "IPV4DestinationAddress"
|
||||
#define IPV4DestinationIPAddress_TAG "IPV4DestinationIPAddress"
|
||||
#define IPV4DestinationSubnetMask_TAG "IPV4DestinationSubnetMask"
|
||||
|
||||
#define IPV4TypeOfService_TAG "IPV4TypeOfService"
|
||||
#define TOSValue_TAG "TOSValue"
|
||||
#define TOSMask_TAG "TOSMask"
|
||||
|
||||
#define IPV4NextHeaderProtocol_TAG "IPV4NextHeaderProtocol"
|
||||
|
||||
#define IPV6SourceAddress_TAG "IPV6SourceAddress"
|
||||
#define IPV6SourceIPAddress_TAG "IPV6SourceIPAddress"
|
||||
#define IPV6SourcePrefix_TAG "IPV6SourcePrefix"
|
||||
|
||||
#define IPV6DestinationAddress_TAG "IPV6DestinationAddress"
|
||||
#define IPV6DestinationIPAddress_TAG "IPV6DestinationIPAddress"
|
||||
#define IPV6DestinationPrefix_TAG "IPV6DestinationPrefix"
|
||||
|
||||
#define IPV6TrafficClass_TAG "IPV6TrafficClass"
|
||||
#define TrfClsValue_TAG "TrfClsValue"
|
||||
#define TrfClsMask_TAG "TrfClsMask"
|
||||
|
||||
#define IPV6NextHeaderProtocol_TAG "IPV6NextHeaderProtocol"
|
||||
|
||||
#define TCPSource_TAG "TCPSource"
|
||||
#define TCPSourcePort_TAG "TCPSourcePort"
|
||||
#define TCPSourceRange_TAG "TCPSourceRange"
|
||||
|
||||
#define TCPDestination_TAG "TCPDestination"
|
||||
#define TCPDestinationPort_TAG "TCPDestinationPort"
|
||||
#define TCPDestinationRange_TAG "TCPDestinationRange"
|
||||
|
||||
#define UDPSource_TAG "UDPSource"
|
||||
#define UDPSourcePort_TAG "UDPSourcePort"
|
||||
#define UDPSourceRange_TAG "UDPSourceRange"
|
||||
|
||||
#define UDPDestination_TAG "UDPDestination"
|
||||
#define UDPDestinationPort_TAG "UDPDestinationPort"
|
||||
#define UDPDestinationRange_TAG "UDPDestinationRange"
|
||||
|
||||
#define ICMPType_TAG "ICMPType"
|
||||
#define ICMPCode_TAG "ICMPCode"
|
||||
|
||||
#define ESP_TAG "ESP"
|
||||
#define ESPSPI_TAG "ESPSPI"
|
||||
|
||||
#define TCP_UDPSource_TAG "TCP_UDPSource"
|
||||
#define TCP_UDPSourcePort_TAG "TCP_UDPSourcePort"
|
||||
#define TCP_UDPSourceRange_TAG "TCP_UDPSourceRange"
|
||||
|
||||
#define TCP_UDPDestination_TAG "TCP_UDPDestination"
|
||||
#define TCP_UDPDestinationPort_TAG "TCP_UDPDestinationPort"
|
||||
#define TCP_UDPDestinationRange_TAG "TCP_UDPDestinationRange"
|
||||
|
||||
#define IPACMNat_TAG "IPACMNAT"
|
||||
#define NAT_MaxEntries_TAG "MaxNatEntries"
|
||||
|
||||
#define IP_PassthroughFlag_TAG "IPPassthroughFlag"
|
||||
#define IP_PassthroughMode_TAG "IPPassthroughMode"
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
IP protocol numbers - use in dss_socket() to identify protocols.
|
||||
Also contains the extension header types for IPv6.
|
||||
---------------------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
IPACM_FIREWALL_IPV6_BASE_HDR = 4, /* IPv6 Base Header */
|
||||
IPACM_FIREWALL_IPPROTO_HOP_BY_HOP_OPT_HDR = 0, /* Hop-by-hop Option Header */
|
||||
IPACM_FIREWALL_IPPROTO_ICMP = 1, /* ICMP protocol */
|
||||
IPACM_FIREWALL_IPPROTO_IGMP = 2, /* IGMP protocol */
|
||||
IPACM_FIREWALL_IPPROTO_IP = IPACM_FIREWALL_IPV6_BASE_HDR, /* IPv4 */
|
||||
IPACM_FIREWALL_IPPROTO_TCP = 6, /* TCP Protocol */
|
||||
IPACM_FIREWALL_IPPROTO_UDP = 17, /* UDP Protocol */
|
||||
IPACM_FIREWALL_IPPROTO_IPV6 = 41, /* IPv6 */
|
||||
IPACM_FIREWALL_IPPROTO_ROUTING_HDR = 43, /* Routing Header */
|
||||
IPACM_FIREWALL_IPPROTO_FRAG_HDR = 44, /* Fragmentation Header */
|
||||
IPACM_FIREWALL_IPPROTO_GRE = 47, /* GRE Protocol */
|
||||
IPACM_FIREWALL_IPPROTO_ESP = 50, /* ESP Protocol */
|
||||
IPACM_FIREWALL_IPPROTO_AH = 51, /* Authentication Header */
|
||||
IPACM_FIREWALL_IPPROTO_ICMP6 = 58, /* ICMPv6 */
|
||||
IPACM_FIREWALL_NO_NEXT_HDR = 59, /* No Next Header for IPv6 */
|
||||
IPACM_FIREWALL_IPPROTO_DEST_OPT_HDR = 60, /* Destination Options Header */
|
||||
IPACM_FIREWALL_IPPROTO_MOBILITY_HDR = 135, /* Mobility Header */
|
||||
IPACM_FIREWALL_IPPROTO_TCP_UDP = 253 /* Unspecified protocol used for IPACM */
|
||||
} ipacm_firewall_ip_protocol_enum_type;
|
||||
|
||||
/* define as mobileap firewall rule format*/
|
||||
typedef enum
|
||||
{
|
||||
IP_V4 = 4,
|
||||
IP_V6 = 6
|
||||
} firewall_ip_version_enum;
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Extended FireWall Entry Configuration.
|
||||
---------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
struct ipa_rule_attrib attrib;
|
||||
firewall_ip_version_enum ip_vsn;
|
||||
} IPACM_extd_firewall_entry_conf_t;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Extended FireWall configuration.
|
||||
---------------------------------------------------------------------------*/
|
||||
typedef union
|
||||
{
|
||||
IPACM_extd_firewall_entry_conf_t extd_firewall_entry;
|
||||
} IPACM_extd_firewall_conf_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char firewall_config_file[IPA_MAX_FILE_LEN];
|
||||
uint8_t num_extd_firewall_entries;
|
||||
IPACM_extd_firewall_entry_conf_t extd_firewall_entries[IPACM_MAX_FIREWALL_ENTRIES];
|
||||
bool rule_action_accept;
|
||||
bool firewall_enable;
|
||||
} IPACM_firewall_conf_t;
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t num_iface_entries;
|
||||
ipa_ifi_dev_name_t iface_entries[IPA_MAX_IFACE_ENTRIES];
|
||||
} ipacm_iface_conf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t num_subnet_entries;
|
||||
ipa_private_subnet private_subnet_entries[IPA_MAX_PRIVATE_SUBNET_ENTRIES];
|
||||
} ipacm_private_subnet_conf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t protocol;
|
||||
uint16_t port;
|
||||
} ipacm_alg;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t num_alg_entries;
|
||||
ipacm_alg alg_entries[IPA_MAX_ALG_ENTRIES];
|
||||
} ipacm_alg_conf_t;
|
||||
|
||||
|
||||
typedef struct _IPACM_conf_t
|
||||
{
|
||||
ipacm_iface_conf_t iface_config;
|
||||
ipacm_private_subnet_conf_t private_subnet_config;
|
||||
ipacm_alg_conf_t alg_config;
|
||||
int nat_max_entries;
|
||||
bool odu_enable;
|
||||
bool router_mode_enable;
|
||||
bool odu_embms_enable;
|
||||
int num_wlan_guest_ap;
|
||||
bool ip_passthrough_mode;
|
||||
} IPACM_conf_t;
|
||||
|
||||
/* This function read IPACM XML configuration*/
|
||||
int ipacm_read_cfg_xml
|
||||
(
|
||||
char *xml_file, /* Filename and path */
|
||||
IPACM_conf_t *config /* Mobile AP config data */
|
||||
);
|
||||
|
||||
/* This function reads QCMAP Firewall XML and store in IPACM Firewall stucture */
|
||||
int IPACM_read_firewall_xml
|
||||
(
|
||||
char *xml_file, /* Filename and path */
|
||||
IPACM_firewall_conf_t *config /* Mobile AP config data */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //IPACM_XML
|
||||
98
data-ipa-cfg-mgr/ipacm/src/Android.mk
Normal file
98
data-ipa-cfg-mgr/ipacm/src/Android.mk
Normal file
@@ -0,0 +1,98 @@
|
||||
BOARD_PLATFORM_LIST := msm8916
|
||||
BOARD_PLATFORM_LIST += msm8909
|
||||
ifneq ($(call is-board-platform-in-list,$(BOARD_PLATFORM_LIST)),true)
|
||||
ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
|
||||
ifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH)))
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../src
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../inc
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ipanat/inc
|
||||
ifeq ($(call is-platform-sdk-version-at-least,20),true)
|
||||
LOCAL_C_INCLUDES += external/icu/icu4c/source/common
|
||||
else
|
||||
LOCAL_C_INCLUDES += external/icu4c/common
|
||||
endif
|
||||
LOCAL_C_INCLUDES += external/libxml2/include
|
||||
LOCAL_C_INCLUDES += external/libnetfilter_conntrack/include
|
||||
LOCAL_C_INCLUDES += external/libnfnetlink/include
|
||||
|
||||
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
|
||||
|
||||
|
||||
LOCAL_CFLAGS := -v
|
||||
LOCAL_CFLAGS += -DFEATURE_IPA_ANDROID
|
||||
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
|
||||
LOCAL_CFLAGS += -DDEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_BOARD_PLATFORM),msmcobalt)
|
||||
LOCAL_CFLAGS += -DFEATURE_IPA_V3
|
||||
endif
|
||||
|
||||
filetoadd = bionic/libc/kernel/arch-arm/asm/posix_types.h
|
||||
LOCAL_CFLAGS += $(shell if [ -a $(filetoadd) ] ; then echo -include $(filetoadd) ; fi ;)
|
||||
filetoadd = bionic/libc/kernel/arch-arm/asm/byteorder.h
|
||||
LOCAL_CFLAGS += $(shell if [ -a $(filetoadd) ] ; then echo -include $(filetoadd) ; fi ;)
|
||||
|
||||
LOCAL_SRC_FILES := IPACM_Main.cpp \
|
||||
IPACM_EvtDispatcher.cpp \
|
||||
IPACM_Config.cpp \
|
||||
IPACM_CmdQueue.cpp \
|
||||
IPACM_Filtering.cpp \
|
||||
IPACM_Routing.cpp \
|
||||
IPACM_Header.cpp \
|
||||
IPACM_Lan.cpp \
|
||||
IPACM_Iface.cpp \
|
||||
IPACM_Wlan.cpp \
|
||||
IPACM_Wan.cpp \
|
||||
IPACM_IfaceManager.cpp \
|
||||
IPACM_Neighbor.cpp \
|
||||
IPACM_Netlink.cpp \
|
||||
IPACM_Xml.cpp \
|
||||
IPACM_Conntrack_NATApp.cpp\
|
||||
IPACM_ConntrackClient.cpp \
|
||||
IPACM_ConntrackListener.cpp \
|
||||
IPACM_Log.cpp
|
||||
|
||||
LOCAL_MODULE := ipacm
|
||||
LOCAL_CLANG := false
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := libipanat
|
||||
LOCAL_SHARED_LIBRARIES += libxml2
|
||||
LOCAL_SHARED_LIBRARIES += libnfnetlink
|
||||
LOCAL_SHARED_LIBRARIES += libnetfilter_conntrack
|
||||
LOCAL_CLANG := true
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
################################################################################
|
||||
|
||||
define ADD_TEST
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := $1
|
||||
LOCAL_SRC_FILES := $1
|
||||
LOCAL_MODULE_CLASS := ipacm
|
||||
LOCAL_MODULE_TAGS := debug
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
endef
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := IPACM_cfg.xml
|
||||
LOCAL_MODULE_CLASS := ETC
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_OWNER := ipacm
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
endif # $(TARGET_ARCH)
|
||||
endif
|
||||
endif
|
||||
205
data-ipa-cfg-mgr/ipacm/src/IPACM_CmdQueue.cpp
Normal file
205
data-ipa-cfg-mgr/ipacm/src/IPACM_CmdQueue.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_CmdQueue.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPAM Comment Queue functionality
|
||||
|
||||
@Author
|
||||
Sunil
|
||||
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "IPACM_CmdQueue.h"
|
||||
#include "IPACM_Log.h"
|
||||
#include "IPACM_Iface.h"
|
||||
|
||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_cond_t cond_var = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
MessageQueue* MessageQueue::inst_internal = NULL;
|
||||
MessageQueue* MessageQueue::inst_external = NULL;
|
||||
|
||||
MessageQueue* MessageQueue::getInstanceInternal()
|
||||
{
|
||||
if(inst_internal == NULL)
|
||||
{
|
||||
inst_internal = new MessageQueue();
|
||||
if(inst_internal == NULL)
|
||||
{
|
||||
IPACMERR("unable to create internal Message Queue instance\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return inst_internal;
|
||||
}
|
||||
|
||||
MessageQueue* MessageQueue::getInstanceExternal()
|
||||
{
|
||||
if(inst_external == NULL)
|
||||
{
|
||||
inst_external = new MessageQueue();
|
||||
if(inst_external == NULL)
|
||||
{
|
||||
IPACMERR("unable to create external Message Queue instance\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return inst_external;
|
||||
}
|
||||
|
||||
void MessageQueue::enqueue(Message *item)
|
||||
{
|
||||
if(!Head)
|
||||
{
|
||||
Tail = item;
|
||||
Head = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Tail == NULL)
|
||||
{
|
||||
IPACMDBG("Tail is null\n");
|
||||
Head->setnext(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
Tail->setnext(item);
|
||||
}
|
||||
Tail = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Message* MessageQueue::dequeue(void)
|
||||
{
|
||||
if(Head == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Message *tmp = Head;
|
||||
Head = Head->getnext();
|
||||
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void* MessageQueue::Process(void *param)
|
||||
{
|
||||
MessageQueue *MsgQueueInternal = NULL;
|
||||
MessageQueue *MsgQueueExternal = NULL;
|
||||
Message *item = NULL;
|
||||
IPACMDBG("MessageQueue::Process()\n");
|
||||
|
||||
MsgQueueInternal = MessageQueue::getInstanceInternal();
|
||||
if(MsgQueueInternal == NULL)
|
||||
{
|
||||
IPACMERR("unable to start internal cmd queue process\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MsgQueueExternal = MessageQueue::getInstanceExternal();
|
||||
if(MsgQueueExternal == NULL)
|
||||
{
|
||||
IPACMERR("unable to start external cmd queue process\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(pthread_mutex_lock(&mutex) != 0)
|
||||
{
|
||||
IPACMERR("unable to lock the mutex\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = MsgQueueInternal->dequeue();
|
||||
if(item == NULL)
|
||||
{
|
||||
item = MsgQueueExternal->dequeue();
|
||||
if(item)
|
||||
{
|
||||
IPACMDBG("Get event %s from external queue.\n",
|
||||
IPACM_Iface::ipacmcfg->getEventName(item->evt.data.event));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG("Get event %s from internal queue.\n",
|
||||
IPACM_Iface::ipacmcfg->getEventName(item->evt.data.event));
|
||||
}
|
||||
|
||||
if(item == NULL)
|
||||
{
|
||||
IPACMDBG("Waiting for Message\n");
|
||||
|
||||
if(pthread_cond_wait(&cond_var, &mutex) != 0)
|
||||
{
|
||||
IPACMERR("unable to lock the mutex\n");
|
||||
|
||||
if(pthread_mutex_unlock(&mutex) != 0)
|
||||
{
|
||||
IPACMERR("unable to unlock the mutex\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(pthread_mutex_unlock(&mutex) != 0)
|
||||
{
|
||||
IPACMERR("unable to unlock the mutex\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pthread_mutex_unlock(&mutex) != 0)
|
||||
{
|
||||
IPACMERR("unable to unlock the mutex\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IPACMDBG("Processing item %p event ID: %d\n",item,item->evt.data.event);
|
||||
item->evt.callback_ptr(&item->evt.data);
|
||||
delete item;
|
||||
item = NULL;
|
||||
}
|
||||
|
||||
} /* Go forever until a termination indication is received */
|
||||
|
||||
}
|
||||
824
data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp
Normal file
824
data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp
Normal file
@@ -0,0 +1,824 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Config.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPACM Configuration from XML file
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#include <IPACM_Config.h>
|
||||
#include <IPACM_Log.h>
|
||||
#include <IPACM_Iface.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
IPACM_Config *IPACM_Config::pInstance = NULL;
|
||||
const char *IPACM_Config::DEVICE_NAME = "/dev/ipa";
|
||||
const char *IPACM_Config::DEVICE_NAME_ODU = "/dev/odu_ipa_bridge";
|
||||
|
||||
#define __stringify(x...) #x
|
||||
|
||||
const char *ipacm_event_name[] = {
|
||||
__stringify(IPA_CFG_CHANGE_EVENT), /* NULL */
|
||||
__stringify(IPA_PRIVATE_SUBNET_CHANGE_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_FIREWALL_CHANGE_EVENT), /* NULL */
|
||||
__stringify(IPA_LINK_UP_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_LINK_DOWN_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_USB_LINK_UP_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_BRIDGE_LINK_UP_EVENT), /* ipacm_event_data_all */
|
||||
__stringify(IPA_WAN_EMBMS_LINK_UP_EVENT), /* ipacm_event_data_mac */
|
||||
__stringify(IPA_ADDR_ADD_EVENT), /* ipacm_event_data_addr */
|
||||
__stringify(IPA_ADDR_DEL_EVENT), /* no use */
|
||||
__stringify(IPA_ROUTE_ADD_EVENT), /* ipacm_event_data_addr */
|
||||
__stringify(IPA_ROUTE_DEL_EVENT), /* ipacm_event_data_addr */
|
||||
__stringify(IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_WLAN_AP_LINK_UP_EVENT), /* ipacm_event_data_mac */
|
||||
__stringify(IPA_WLAN_STA_LINK_UP_EVENT), /* ipacm_event_data_mac */
|
||||
__stringify(IPA_WLAN_LINK_DOWN_EVENT), /* ipacm_event_data_mac */
|
||||
__stringify(IPA_WLAN_CLIENT_ADD_EVENT), /* ipacm_event_data_mac */
|
||||
__stringify(IPA_WLAN_CLIENT_ADD_EVENT_EX), /* ipacm_event_data_wlan_ex */
|
||||
__stringify(IPA_WLAN_CLIENT_DEL_EVENT), /* ipacm_event_data_mac */
|
||||
__stringify(IPA_WLAN_CLIENT_POWER_SAVE_EVENT), /* ipacm_event_data_mac */
|
||||
__stringify(IPA_WLAN_CLIENT_RECOVER_EVENT), /* ipacm_event_data_mac */
|
||||
__stringify(IPA_NEW_NEIGH_EVENT), /* ipacm_event_data_all */
|
||||
__stringify(IPA_DEL_NEIGH_EVENT), /* ipacm_event_data_all */
|
||||
__stringify(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT), /* ipacm_event_data_all */
|
||||
__stringify(IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT), /* ipacm_event_data_all */
|
||||
__stringify(IPA_SW_ROUTING_ENABLE), /* NULL */
|
||||
__stringify(IPA_SW_ROUTING_DISABLE), /* NULL */
|
||||
__stringify(IPA_PROCESS_CT_MESSAGE), /* ipacm_ct_evt_data */
|
||||
__stringify(IPA_PROCESS_CT_MESSAGE_V6), /* ipacm_ct_evt_data */
|
||||
__stringify(IPA_LAN_TO_LAN_NEW_CONNECTION), /* ipacm_event_connection */
|
||||
__stringify(IPA_LAN_TO_LAN_DEL_CONNECTION), /* ipacm_event_connection */
|
||||
__stringify(IPA_WLAN_SWITCH_TO_SCC), /* No Data */
|
||||
__stringify(IPA_WLAN_SWITCH_TO_MCC), /* No Data */
|
||||
__stringify(IPA_CRADLE_WAN_MODE_SWITCH), /* ipacm_event_cradle_wan_mode */
|
||||
__stringify(IPA_WAN_XLAT_CONNECT_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_TETHERING_STATS_UPDATE_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_NETWORK_STATS_UPDATE_EVENT), /* ipacm_event_data_fid */
|
||||
__stringify(IPA_EXTERNAL_EVENT_MAX),
|
||||
__stringify(IPA_HANDLE_WAN_UP), /* ipacm_event_iface_up */
|
||||
__stringify(IPA_HANDLE_WAN_DOWN), /* ipacm_event_iface_up */
|
||||
__stringify(IPA_HANDLE_WAN_UP_V6), /* NULL */
|
||||
__stringify(IPA_HANDLE_WAN_DOWN_V6), /* NULL */
|
||||
__stringify(IPA_HANDLE_WAN_UP_TETHER), /* ipacm_event_iface_up_tehter */
|
||||
__stringify(IPA_HANDLE_WAN_DOWN_TETHER), /* ipacm_event_iface_up_tehter */
|
||||
__stringify(IPA_HANDLE_WAN_UP_V6_TETHER), /* ipacm_event_iface_up_tehter */
|
||||
__stringify(IPA_HANDLE_WAN_DOWN_V6_TETHER), /* ipacm_event_iface_up_tehter */
|
||||
__stringify(IPA_HANDLE_WLAN_UP), /* ipacm_event_iface_up */
|
||||
__stringify(IPA_HANDLE_LAN_UP), /* ipacm_event_iface_up */
|
||||
__stringify(IPA_ETH_BRIDGE_IFACE_UP), /* ipacm_event_eth_bridge*/
|
||||
__stringify(IPA_ETH_BRIDGE_IFACE_DOWN), /* ipacm_event_eth_bridge*/
|
||||
__stringify(IPA_ETH_BRIDGE_CLIENT_ADD), /* ipacm_event_eth_bridge*/
|
||||
__stringify(IPA_ETH_BRIDGE_CLIENT_DEL), /* ipacm_event_eth_bridge*/
|
||||
__stringify(IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH), /* ipacm_event_eth_bridge*/
|
||||
__stringify(IPA_LAN_DELETE_SELF), /* ipacm_event_data_fid */
|
||||
__stringify(IPACM_EVENT_MAX),
|
||||
};
|
||||
|
||||
IPACM_Config::IPACM_Config()
|
||||
{
|
||||
iface_table = NULL;
|
||||
alg_table = NULL;
|
||||
pNatIfaces = NULL;
|
||||
memset(&ipa_client_rm_map_tbl, 0, sizeof(ipa_client_rm_map_tbl));
|
||||
memset(&ipa_rm_tbl, 0, sizeof(ipa_rm_tbl));
|
||||
ipa_rm_a2_check=0;
|
||||
ipacm_odu_enable = false;
|
||||
ipacm_odu_router_mode = false;
|
||||
ipa_num_wlan_guest_ap = 0;
|
||||
|
||||
ipa_num_ipa_interfaces = 0;
|
||||
ipa_num_private_subnet = 0;
|
||||
ipa_num_alg_ports = 0;
|
||||
ipa_nat_max_entries = 0;
|
||||
ipa_nat_iface_entries = 0;
|
||||
ipa_sw_rt_enable = false;
|
||||
ipa_bridge_enable = false;
|
||||
isMCC_Mode = false;
|
||||
ipa_max_valid_rm_entry = 0;
|
||||
|
||||
memset(&rt_tbl_default_v4, 0, sizeof(rt_tbl_default_v4));
|
||||
memset(&rt_tbl_lan_v4, 0, sizeof(rt_tbl_lan_v4));
|
||||
memset(&rt_tbl_wan_v4, 0, sizeof(rt_tbl_wan_v4));
|
||||
memset(&rt_tbl_v6, 0, sizeof(rt_tbl_v6));
|
||||
memset(&rt_tbl_wan_v6, 0, sizeof(rt_tbl_wan_v6));
|
||||
memset(&rt_tbl_wan_dl, 0, sizeof(rt_tbl_wan_dl));
|
||||
memset(&rt_tbl_odu_v4, 0, sizeof(rt_tbl_odu_v4));
|
||||
memset(&rt_tbl_odu_v6, 0, sizeof(rt_tbl_odu_v6));
|
||||
|
||||
memset(&ext_prop_v4, 0, sizeof(ext_prop_v4));
|
||||
memset(&ext_prop_v6, 0, sizeof(ext_prop_v6));
|
||||
|
||||
qmap_id = ~0;
|
||||
|
||||
memset(flt_rule_count_v4, 0, (IPA_CLIENT_CONS - IPA_CLIENT_PROD)*sizeof(int));
|
||||
memset(flt_rule_count_v6, 0, (IPA_CLIENT_CONS - IPA_CLIENT_PROD)*sizeof(int));
|
||||
memset(bridge_mac, 0, IPA_MAC_ADDR_SIZE*sizeof(uint8_t));
|
||||
|
||||
IPACMDBG_H(" create IPACM_Config constructor\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int IPACM_Config::Init(void)
|
||||
{
|
||||
/* Read IPACM Config file */
|
||||
char IPACM_config_file[IPA_MAX_FILE_LEN];
|
||||
IPACM_conf_t *cfg;
|
||||
cfg = (IPACM_conf_t *)malloc(sizeof(IPACM_conf_t));
|
||||
if(cfg == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate cfg memory.\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
uint32_t subnet_addr;
|
||||
uint32_t subnet_mask;
|
||||
int i, ret = IPACM_SUCCESS;
|
||||
struct in_addr in_addr_print;
|
||||
|
||||
m_fd = open(DEVICE_NAME, O_RDWR);
|
||||
if (0 > m_fd)
|
||||
{
|
||||
IPACMERR("Failed opening %s.\n", DEVICE_NAME);
|
||||
}
|
||||
strncpy(IPACM_config_file, "/etc/IPACM_cfg.xml", sizeof(IPACM_config_file));
|
||||
|
||||
IPACMDBG_H("\n IPACM XML file is %s \n", IPACM_config_file);
|
||||
if (IPACM_SUCCESS == ipacm_read_cfg_xml(IPACM_config_file, cfg))
|
||||
{
|
||||
IPACMDBG_H("\n IPACM XML read OK \n");
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR("\n IPACM XML read failed \n");
|
||||
ret = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Check wlan AP-AP access mode configuration */
|
||||
if (cfg->num_wlan_guest_ap == 2)
|
||||
{
|
||||
IPACMDBG_H("IPACM_Config::Both wlan APs can not be configured in guest ap mode. \n");
|
||||
IPACMDBG_H("IPACM_Config::configure both APs in full access mode or at least one in guest ap mode. \n");
|
||||
ret = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
/* Construct IPACM Iface table */
|
||||
ipa_num_ipa_interfaces = cfg->iface_config.num_iface_entries;
|
||||
if (iface_table != NULL)
|
||||
{
|
||||
free(iface_table);
|
||||
iface_table = NULL;
|
||||
IPACMDBG_H("RESET IPACM_Config::iface_table\n");
|
||||
}
|
||||
iface_table = (ipa_ifi_dev_name_t *)calloc(ipa_num_ipa_interfaces,
|
||||
sizeof(ipa_ifi_dev_name_t));
|
||||
if(iface_table == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate iface_table memory.\n");
|
||||
ret = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (i = 0; i < cfg->iface_config.num_iface_entries; i++)
|
||||
{
|
||||
strncpy(iface_table[i].iface_name, cfg->iface_config.iface_entries[i].iface_name, sizeof(iface_table[i].iface_name));
|
||||
iface_table[i].if_cat = cfg->iface_config.iface_entries[i].if_cat;
|
||||
iface_table[i].if_mode = cfg->iface_config.iface_entries[i].if_mode;
|
||||
iface_table[i].wlan_mode = cfg->iface_config.iface_entries[i].wlan_mode;
|
||||
IPACMDBG_H("IPACM_Config::iface_table[%d] = %s, cat=%d, mode=%d wlan-mode=%d \n", i, iface_table[i].iface_name,
|
||||
iface_table[i].if_cat, iface_table[i].if_mode, iface_table[i].wlan_mode);
|
||||
/* copy bridge interface name to ipacmcfg */
|
||||
if( iface_table[i].if_cat == VIRTUAL_IF)
|
||||
{
|
||||
strlcpy(ipa_virtual_iface_name, iface_table[i].iface_name, sizeof(ipa_virtual_iface_name));
|
||||
IPACMDBG_H("ipa_virtual_iface_name(%s) \n", ipa_virtual_iface_name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Construct IPACM Private_Subnet table */
|
||||
memset(&private_subnet_table, 0, sizeof(private_subnet_table));
|
||||
ipa_num_private_subnet = cfg->private_subnet_config.num_subnet_entries;
|
||||
|
||||
for (i = 0; i < cfg->private_subnet_config.num_subnet_entries; i++)
|
||||
{
|
||||
memcpy(&private_subnet_table[i].subnet_addr,
|
||||
&cfg->private_subnet_config.private_subnet_entries[i].subnet_addr,
|
||||
sizeof(cfg->private_subnet_config.private_subnet_entries[i].subnet_addr));
|
||||
|
||||
memcpy(&private_subnet_table[i].subnet_mask,
|
||||
&cfg->private_subnet_config.private_subnet_entries[i].subnet_mask,
|
||||
sizeof(cfg->private_subnet_config.private_subnet_entries[i].subnet_mask));
|
||||
|
||||
subnet_addr = htonl(private_subnet_table[i].subnet_addr);
|
||||
memcpy(&in_addr_print,&subnet_addr,sizeof(in_addr_print));
|
||||
IPACMDBG_H("%dst::private_subnet_table= %s \n ", i,
|
||||
inet_ntoa(in_addr_print));
|
||||
|
||||
subnet_mask = htonl(private_subnet_table[i].subnet_mask);
|
||||
memcpy(&in_addr_print,&subnet_mask,sizeof(in_addr_print));
|
||||
IPACMDBG_H("%dst::private_subnet_table= %s \n ", i,
|
||||
inet_ntoa(in_addr_print));
|
||||
}
|
||||
|
||||
/* Construct IPACM ALG table */
|
||||
ipa_num_alg_ports = cfg->alg_config.num_alg_entries;
|
||||
if (alg_table != NULL)
|
||||
{
|
||||
free(alg_table);
|
||||
alg_table = NULL;
|
||||
IPACMDBG_H("RESET IPACM_Config::alg_table \n");
|
||||
}
|
||||
alg_table = (ipacm_alg *)calloc(ipa_num_alg_ports,
|
||||
sizeof(ipacm_alg));
|
||||
if(alg_table == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate alg_table memory.\n");
|
||||
ret = IPACM_FAILURE;
|
||||
free(iface_table);
|
||||
goto fail;;
|
||||
}
|
||||
for (i = 0; i < cfg->alg_config.num_alg_entries; i++)
|
||||
{
|
||||
alg_table[i].protocol = cfg->alg_config.alg_entries[i].protocol;
|
||||
alg_table[i].port = cfg->alg_config.alg_entries[i].port;
|
||||
IPACMDBG_H("IPACM_Config::ipacm_alg[%d] = %d, port=%d\n", i, alg_table[i].protocol, alg_table[i].port);
|
||||
}
|
||||
|
||||
ipa_nat_max_entries = cfg->nat_max_entries;
|
||||
IPACMDBG_H("Nat Maximum Entries %d\n", ipa_nat_max_entries);
|
||||
|
||||
/* Find ODU is either router mode or bridge mode*/
|
||||
ipacm_odu_enable = cfg->odu_enable;
|
||||
ipacm_odu_router_mode = cfg->router_mode_enable;
|
||||
ipacm_odu_embms_enable = cfg->odu_embms_enable;
|
||||
IPACMDBG_H("ipacm_odu_enable %d\n", ipacm_odu_enable);
|
||||
IPACMDBG_H("ipacm_odu_mode %d\n", ipacm_odu_router_mode);
|
||||
IPACMDBG_H("ipacm_odu_embms_enable %d\n", ipacm_odu_embms_enable);
|
||||
|
||||
ipacm_ip_passthrough_mode = cfg->ip_passthrough_mode;
|
||||
IPACMDBG_H("ipacm_ip_passthrough_mode %d. \n", ipacm_ip_passthrough_mode);
|
||||
|
||||
ipa_num_wlan_guest_ap = cfg->num_wlan_guest_ap;
|
||||
IPACMDBG_H("ipa_num_wlan_guest_ap %d\n",ipa_num_wlan_guest_ap);
|
||||
|
||||
/* Allocate more non-nat entries if the monitored iface dun have Tx/Rx properties */
|
||||
if (pNatIfaces != NULL)
|
||||
{
|
||||
free(pNatIfaces);
|
||||
pNatIfaces = NULL;
|
||||
IPACMDBG_H("RESET IPACM_Config::pNatIfaces \n");
|
||||
}
|
||||
ipa_nat_iface_entries = 0;
|
||||
pNatIfaces = (NatIfaces *)calloc(ipa_num_ipa_interfaces, sizeof(NatIfaces));
|
||||
if (pNatIfaces == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate nat ifaces\n");
|
||||
ret = IPACM_FAILURE;
|
||||
free(iface_table);
|
||||
free(alg_table);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Construct the routing table ictol name in iface static member*/
|
||||
rt_tbl_default_v4.ip = IPA_IP_v4;
|
||||
strncpy(rt_tbl_default_v4.name, V4_DEFAULT_ROUTE_TABLE_NAME, sizeof(rt_tbl_default_v4.name));
|
||||
|
||||
rt_tbl_lan_v4.ip = IPA_IP_v4;
|
||||
strncpy(rt_tbl_lan_v4.name, V4_LAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_lan_v4.name));
|
||||
|
||||
rt_tbl_wan_v4.ip = IPA_IP_v4;
|
||||
strncpy(rt_tbl_wan_v4.name, V4_WAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_wan_v4.name));
|
||||
|
||||
rt_tbl_v6.ip = IPA_IP_v6;
|
||||
strncpy(rt_tbl_v6.name, V6_COMMON_ROUTE_TABLE_NAME, sizeof(rt_tbl_v6.name));
|
||||
|
||||
rt_tbl_wan_v6.ip = IPA_IP_v6;
|
||||
strncpy(rt_tbl_wan_v6.name, V6_WAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_wan_v6.name));
|
||||
|
||||
rt_tbl_odu_v4.ip = IPA_IP_v4;
|
||||
strncpy(rt_tbl_odu_v4.name, V4_ODU_ROUTE_TABLE_NAME, sizeof(rt_tbl_odu_v4.name));
|
||||
|
||||
rt_tbl_odu_v6.ip = IPA_IP_v6;
|
||||
strncpy(rt_tbl_odu_v6.name, V6_ODU_ROUTE_TABLE_NAME, sizeof(rt_tbl_odu_v6.name));
|
||||
|
||||
rt_tbl_wan_dl.ip = IPA_IP_MAX;
|
||||
strncpy(rt_tbl_wan_dl.name, WAN_DL_ROUTE_TABLE_NAME, sizeof(rt_tbl_wan_dl.name));
|
||||
|
||||
/* Construct IPACM ipa_client map to rm_resource table */
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_WLAN1_PROD]= IPA_RM_RESOURCE_WLAN_PROD;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_USB_PROD]= IPA_RM_RESOURCE_USB_PROD;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_A5_WLAN_AMPDU_PROD]= IPA_RM_RESOURCE_HSIC_PROD;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_A2_EMBEDDED_PROD]= IPA_RM_RESOURCE_Q6_PROD;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_A2_TETHERED_PROD]= IPA_RM_RESOURCE_Q6_PROD;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_APPS_LAN_WAN_PROD]= IPA_RM_RESOURCE_Q6_PROD;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_WLAN1_CONS]= IPA_RM_RESOURCE_WLAN_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_WLAN2_CONS]= IPA_RM_RESOURCE_WLAN_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_WLAN3_CONS]= IPA_RM_RESOURCE_WLAN_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_WLAN4_CONS]= IPA_RM_RESOURCE_WLAN_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_USB_CONS]= IPA_RM_RESOURCE_USB_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_A2_EMBEDDED_CONS]= IPA_RM_RESOURCE_Q6_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_A2_TETHERED_CONS]= IPA_RM_RESOURCE_Q6_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_APPS_WAN_CONS]= IPA_RM_RESOURCE_Q6_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_ODU_PROD]= IPA_RM_RESOURCE_ODU_ADAPT_PROD;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_ODU_EMB_CONS]= IPA_RM_RESOURCE_ODU_ADAPT_CONS;
|
||||
ipa_client_rm_map_tbl[IPA_CLIENT_ODU_TETH_CONS]= IPA_RM_RESOURCE_ODU_ADAPT_CONS;
|
||||
|
||||
/* Create the entries which IPACM wants to add dependencies on */
|
||||
ipa_rm_tbl[0].producer_rm1 = IPA_RM_RESOURCE_WLAN_PROD;
|
||||
ipa_rm_tbl[0].consumer_rm1 = IPA_RM_RESOURCE_Q6_CONS;
|
||||
ipa_rm_tbl[0].producer_rm2 = IPA_RM_RESOURCE_Q6_PROD;
|
||||
ipa_rm_tbl[0].consumer_rm2 = IPA_RM_RESOURCE_WLAN_CONS;
|
||||
|
||||
ipa_rm_tbl[1].producer_rm1 = IPA_RM_RESOURCE_USB_PROD;
|
||||
ipa_rm_tbl[1].consumer_rm1 = IPA_RM_RESOURCE_Q6_CONS;
|
||||
ipa_rm_tbl[1].producer_rm2 = IPA_RM_RESOURCE_Q6_PROD;
|
||||
ipa_rm_tbl[1].consumer_rm2 = IPA_RM_RESOURCE_USB_CONS;
|
||||
|
||||
ipa_rm_tbl[2].producer_rm1 = IPA_RM_RESOURCE_WLAN_PROD;
|
||||
ipa_rm_tbl[2].consumer_rm1 = IPA_RM_RESOURCE_USB_CONS;
|
||||
ipa_rm_tbl[2].producer_rm2 = IPA_RM_RESOURCE_USB_PROD;
|
||||
ipa_rm_tbl[2].consumer_rm2 = IPA_RM_RESOURCE_WLAN_CONS;
|
||||
|
||||
ipa_rm_tbl[3].producer_rm1 = IPA_RM_RESOURCE_ODU_ADAPT_PROD;
|
||||
ipa_rm_tbl[3].consumer_rm1 = IPA_RM_RESOURCE_Q6_CONS;
|
||||
ipa_rm_tbl[3].producer_rm2 = IPA_RM_RESOURCE_Q6_PROD;
|
||||
ipa_rm_tbl[3].consumer_rm2 = IPA_RM_RESOURCE_ODU_ADAPT_CONS;
|
||||
|
||||
ipa_rm_tbl[4].producer_rm1 = IPA_RM_RESOURCE_WLAN_PROD;
|
||||
ipa_rm_tbl[4].consumer_rm1 = IPA_RM_RESOURCE_ODU_ADAPT_CONS;
|
||||
ipa_rm_tbl[4].producer_rm2 = IPA_RM_RESOURCE_ODU_ADAPT_PROD;
|
||||
ipa_rm_tbl[4].consumer_rm2 = IPA_RM_RESOURCE_WLAN_CONS;
|
||||
|
||||
ipa_rm_tbl[5].producer_rm1 = IPA_RM_RESOURCE_ODU_ADAPT_PROD;
|
||||
ipa_rm_tbl[5].consumer_rm1 = IPA_RM_RESOURCE_USB_CONS;
|
||||
ipa_rm_tbl[5].producer_rm2 = IPA_RM_RESOURCE_USB_PROD;
|
||||
ipa_rm_tbl[5].consumer_rm2 = IPA_RM_RESOURCE_ODU_ADAPT_CONS;
|
||||
ipa_max_valid_rm_entry = 6; /* max is IPA_MAX_RM_ENTRY (6)*/
|
||||
|
||||
IPACMDBG_H(" depend MAP-0 rm index %d to rm index: %d \n", IPA_RM_RESOURCE_WLAN_PROD, IPA_RM_RESOURCE_Q6_CONS);
|
||||
IPACMDBG_H(" depend MAP-1 rm index %d to rm index: %d \n", IPA_RM_RESOURCE_USB_PROD, IPA_RM_RESOURCE_Q6_CONS);
|
||||
IPACMDBG_H(" depend MAP-2 rm index %d to rm index: %d \n", IPA_RM_RESOURCE_WLAN_PROD, IPA_RM_RESOURCE_USB_CONS);
|
||||
IPACMDBG_H(" depend MAP-3 rm index %d to rm index: %d \n", IPA_RM_RESOURCE_ODU_ADAPT_PROD, IPA_RM_RESOURCE_Q6_CONS);
|
||||
IPACMDBG_H(" depend MAP-4 rm index %d to rm index: %d \n", IPA_RM_RESOURCE_WLAN_PROD, IPA_RM_RESOURCE_ODU_ADAPT_CONS);
|
||||
IPACMDBG_H(" depend MAP-5 rm index %d to rm index: %d \n", IPA_RM_RESOURCE_ODU_ADAPT_PROD, IPA_RM_RESOURCE_USB_CONS);
|
||||
|
||||
fail:
|
||||
if (cfg != NULL)
|
||||
{
|
||||
free(cfg);
|
||||
cfg = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
IPACM_Config* IPACM_Config::GetInstance()
|
||||
{
|
||||
int res = IPACM_SUCCESS;
|
||||
|
||||
if (pInstance == NULL)
|
||||
{
|
||||
pInstance = new IPACM_Config();
|
||||
|
||||
res = pInstance->Init();
|
||||
if (res != IPACM_SUCCESS)
|
||||
{
|
||||
delete pInstance;
|
||||
IPACMERR("unable to initialize config instance\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
int IPACM_Config::GetAlgPorts(int nPorts, ipacm_alg *pAlgPorts)
|
||||
{
|
||||
if (nPorts <= 0 || pAlgPorts == NULL)
|
||||
{
|
||||
IPACMERR("Invalid input\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int cnt = 0; cnt < nPorts; cnt++)
|
||||
{
|
||||
pAlgPorts[cnt].protocol = alg_table[cnt].protocol;
|
||||
pAlgPorts[cnt].port = alg_table[cnt].port;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int IPACM_Config::GetNatIfaces(int nIfaces, NatIfaces *pIfaces)
|
||||
{
|
||||
if (nIfaces <= 0 || pIfaces == NULL)
|
||||
{
|
||||
IPACMERR("Invalid input\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int cnt=0; cnt<nIfaces; cnt++)
|
||||
{
|
||||
memcpy(pIfaces[cnt].iface_name,
|
||||
pNatIfaces[cnt].iface_name,
|
||||
sizeof(pIfaces[cnt].iface_name));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int IPACM_Config::AddNatIfaces(char *dev_name)
|
||||
{
|
||||
int i;
|
||||
/* Check if this iface already in NAT-iface*/
|
||||
for(i = 0; i < ipa_nat_iface_entries; i++)
|
||||
{
|
||||
if(strncmp(dev_name,
|
||||
pNatIfaces[i].iface_name,
|
||||
sizeof(pNatIfaces[i].iface_name)) == 0)
|
||||
{
|
||||
IPACMDBG("Interface (%s) is add to nat iface already\n", dev_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG_H("Add iface %s to NAT-ifaces, origin it has %d nat ifaces\n",
|
||||
dev_name, ipa_nat_iface_entries);
|
||||
ipa_nat_iface_entries++;
|
||||
|
||||
if (ipa_nat_iface_entries < ipa_num_ipa_interfaces)
|
||||
{
|
||||
memcpy(pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
|
||||
dev_name, IPA_IFACE_NAME_LEN);
|
||||
|
||||
IPACMDBG_H("Add Nat IfaceName: %s ,update nat-ifaces number: %d\n",
|
||||
pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
|
||||
ipa_nat_iface_entries);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int IPACM_Config::DelNatIfaces(char *dev_name)
|
||||
{
|
||||
int i = 0;
|
||||
IPACMDBG_H("Del iface %s from NAT-ifaces, origin it has %d nat ifaces\n",
|
||||
dev_name, ipa_nat_iface_entries);
|
||||
|
||||
for (i = 0; i < ipa_nat_iface_entries; i++)
|
||||
{
|
||||
if (strcmp(dev_name, pNatIfaces[i].iface_name) == 0)
|
||||
{
|
||||
IPACMDBG_H("Find Nat IfaceName: %s ,previous nat-ifaces number: %d\n",
|
||||
pNatIfaces[i].iface_name, ipa_nat_iface_entries);
|
||||
|
||||
/* Reset the matched entry */
|
||||
memset(pNatIfaces[i].iface_name, 0, IPA_IFACE_NAME_LEN);
|
||||
|
||||
for (; i < ipa_nat_iface_entries - 1; i++)
|
||||
{
|
||||
memcpy(pNatIfaces[i].iface_name,
|
||||
pNatIfaces[i + 1].iface_name, IPA_IFACE_NAME_LEN);
|
||||
|
||||
/* Reset the copied entry */
|
||||
memset(pNatIfaces[i + 1].iface_name, 0, IPA_IFACE_NAME_LEN);
|
||||
}
|
||||
ipa_nat_iface_entries--;
|
||||
IPACMDBG_H("Update nat-ifaces number: %d\n", ipa_nat_iface_entries);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG_H("Can't find Nat IfaceName: %s with total nat-ifaces number: %d\n",
|
||||
dev_name, ipa_nat_iface_entries);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* for IPACM resource manager dependency usage
|
||||
add either Tx or Rx ipa_rm_resource_name and
|
||||
also indicate that endpoint property if valid */
|
||||
void IPACM_Config::AddRmDepend(ipa_rm_resource_name rm1,bool rx_bypass_ipa)
|
||||
{
|
||||
int retval = 0;
|
||||
struct ipa_ioc_rm_dependency dep;
|
||||
|
||||
IPACMDBG_H(" Got rm add-depend index : %d \n", rm1);
|
||||
/* ipa_rm_a2_check: IPA_RM_RESOURCE_Q6_CONS*/
|
||||
if(rm1 == IPA_RM_RESOURCE_Q6_CONS)
|
||||
{
|
||||
ipa_rm_a2_check+=1;
|
||||
IPACMDBG_H("got %d times default RT routing from A2 \n", ipa_rm_a2_check);
|
||||
}
|
||||
|
||||
for(int i=0;i<ipa_max_valid_rm_entry;i++)
|
||||
{
|
||||
if(rm1 == ipa_rm_tbl[i].producer_rm1)
|
||||
{
|
||||
ipa_rm_tbl[i].producer1_up = true;
|
||||
/* entry1's producer actually dun have registered Rx-property */
|
||||
ipa_rm_tbl[i].rx_bypass_ipa = rx_bypass_ipa;
|
||||
IPACMDBG_H("Matched RM_table entry: %d's producer_rm1 with non_rx_prop: %d \n", i,ipa_rm_tbl[i].rx_bypass_ipa);
|
||||
|
||||
if(ipa_rm_tbl[i].consumer1_up == true && ipa_rm_tbl[i].rm_set == false)
|
||||
{
|
||||
IPACMDBG_H("SETUP RM_table entry %d's bi-direction dependency \n", i);
|
||||
/* add bi-directional dependency*/
|
||||
if(ipa_rm_tbl[i].rx_bypass_ipa)
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&dep, 0, sizeof(dep));
|
||||
dep.resource_name = ipa_rm_tbl[i].producer_rm1;
|
||||
dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
|
||||
retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
|
||||
IPACMDBG_H("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
|
||||
}
|
||||
}
|
||||
memset(&dep, 0, sizeof(dep));
|
||||
dep.resource_name = ipa_rm_tbl[i].producer_rm2;
|
||||
dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
|
||||
retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
|
||||
IPACMDBG_H("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
|
||||
}
|
||||
ipa_rm_tbl[i].rm_set = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
}
|
||||
|
||||
if(rm1 == ipa_rm_tbl[i].consumer_rm1)
|
||||
{
|
||||
ipa_rm_tbl[i].consumer1_up = true;
|
||||
IPACMDBG_H("Matched RM_table entry: %d's consumer_rm1 \n", i);
|
||||
|
||||
if(ipa_rm_tbl[i].producer1_up == true && ipa_rm_tbl[i].rm_set == false)
|
||||
{
|
||||
IPACMDBG_H("SETUP RM_table entry %d's bi-direction dependency \n", i);
|
||||
/* add bi-directional dependency*/
|
||||
if(ipa_rm_tbl[i].rx_bypass_ipa)
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&dep, 0, sizeof(dep));
|
||||
dep.resource_name = ipa_rm_tbl[i].producer_rm1;
|
||||
dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
|
||||
retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
|
||||
IPACMDBG_H("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
|
||||
}
|
||||
}
|
||||
|
||||
memset(&dep, 0, sizeof(dep));
|
||||
dep.resource_name = ipa_rm_tbl[i].producer_rm2;
|
||||
dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
|
||||
retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
|
||||
IPACMDBG_H("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
|
||||
}
|
||||
ipa_rm_tbl[i].rm_set = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
/* for IPACM resource manager dependency usage
|
||||
delete either Tx or Rx ipa_rm_resource_name */
|
||||
|
||||
void IPACM_Config::DelRmDepend(ipa_rm_resource_name rm1)
|
||||
{
|
||||
int retval = 0;
|
||||
struct ipa_ioc_rm_dependency dep;
|
||||
|
||||
IPACMDBG_H(" Got rm del-depend index : %d \n", rm1);
|
||||
/* ipa_rm_a2_check: IPA_RM_RESOURCE_Q6_CONS*/
|
||||
if(rm1 == IPA_RM_RESOURCE_Q6_CONS)
|
||||
{
|
||||
ipa_rm_a2_check-=1;
|
||||
IPACMDBG_H("Left %d times default RT routing from A2 \n", ipa_rm_a2_check);
|
||||
}
|
||||
|
||||
for(int i=0;i<ipa_max_valid_rm_entry;i++)
|
||||
{
|
||||
|
||||
if(rm1 == ipa_rm_tbl[i].producer_rm1)
|
||||
{
|
||||
if(ipa_rm_tbl[i].rm_set == true)
|
||||
{
|
||||
IPACMDBG_H("Matched RM_table entry: %d's producer_rm1 and dependency is up \n", i);
|
||||
ipa_rm_tbl[i].rm_set = false;
|
||||
|
||||
/* delete bi-directional dependency*/
|
||||
if(ipa_rm_tbl[i].rx_bypass_ipa)
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&dep, 0, sizeof(dep));
|
||||
dep.resource_name = ipa_rm_tbl[i].producer_rm1;
|
||||
dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
|
||||
retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
|
||||
IPACMDBG_H("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
|
||||
}
|
||||
}
|
||||
memset(&dep, 0, sizeof(dep));
|
||||
dep.resource_name = ipa_rm_tbl[i].producer_rm2;
|
||||
dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
|
||||
retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
|
||||
IPACMDBG_H("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
|
||||
}
|
||||
}
|
||||
ipa_rm_tbl[i].producer1_up = false;
|
||||
ipa_rm_tbl[i].rx_bypass_ipa = false;
|
||||
}
|
||||
if(rm1 == ipa_rm_tbl[i].consumer_rm1)
|
||||
{
|
||||
/* ipa_rm_a2_check: IPA_RM_RESOURCE_!6_CONS*/
|
||||
if(ipa_rm_tbl[i].consumer_rm1 == IPA_RM_RESOURCE_Q6_CONS && ipa_rm_a2_check == 1)
|
||||
{
|
||||
IPACMDBG_H(" still have %d default RT routing from A2 \n", ipa_rm_a2_check);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(ipa_rm_tbl[i].rm_set == true)
|
||||
{
|
||||
IPACMDBG_H("Matched RM_table entry: %d's consumer_rm1 and dependency is up \n", i);
|
||||
ipa_rm_tbl[i].rm_set = false;
|
||||
/* delete bi-directional dependency*/
|
||||
if(ipa_rm_tbl[i].rx_bypass_ipa)
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&dep, 0, sizeof(dep));
|
||||
dep.resource_name = ipa_rm_tbl[i].producer_rm1;
|
||||
dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
|
||||
retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
|
||||
IPACMDBG_H("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
|
||||
}
|
||||
}
|
||||
|
||||
memset(&dep, 0, sizeof(dep));
|
||||
dep.resource_name = ipa_rm_tbl[i].producer_rm2;
|
||||
dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
|
||||
retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
|
||||
IPACMDBG_H("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
|
||||
}
|
||||
}
|
||||
ipa_rm_tbl[i].consumer1_up = false;
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
int IPACM_Config::SetExtProp(ipa_ioc_query_intf_ext_props *prop)
|
||||
{
|
||||
int i, num;
|
||||
|
||||
if(prop == NULL || prop->num_ext_props <= 0)
|
||||
{
|
||||
IPACMERR("There is no extended property!\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
num = prop->num_ext_props;
|
||||
for(i=0; i<num; i++)
|
||||
{
|
||||
if(prop->ext[i].ip == IPA_IP_v4)
|
||||
{
|
||||
if(ext_prop_v4.num_ext_props >= MAX_NUM_EXT_PROPS)
|
||||
{
|
||||
IPACMERR("IPv4 extended property table is full!\n");
|
||||
continue;
|
||||
}
|
||||
memcpy(&ext_prop_v4.prop[ext_prop_v4.num_ext_props], &prop->ext[i], sizeof(struct ipa_ioc_ext_intf_prop));
|
||||
ext_prop_v4.num_ext_props++;
|
||||
}
|
||||
else if(prop->ext[i].ip == IPA_IP_v6)
|
||||
{
|
||||
if(ext_prop_v6.num_ext_props >= MAX_NUM_EXT_PROPS)
|
||||
{
|
||||
IPACMERR("IPv6 extended property table is full!\n");
|
||||
continue;
|
||||
}
|
||||
memcpy(&ext_prop_v6.prop[ext_prop_v6.num_ext_props], &prop->ext[i], sizeof(struct ipa_ioc_ext_intf_prop));
|
||||
ext_prop_v6.num_ext_props++;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR("The IP type is not expected!\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG_H("Set extended property succeeded.\n");
|
||||
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
ipacm_ext_prop* IPACM_Config::GetExtProp(ipa_ip_type ip_type)
|
||||
{
|
||||
if(ip_type == IPA_IP_v4)
|
||||
return &ext_prop_v4;
|
||||
else if(ip_type == IPA_IP_v6)
|
||||
return &ext_prop_v6;
|
||||
else
|
||||
{
|
||||
IPACMERR("Failed to get extended property: the IP version is neither IPv4 nor IPv6!\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int IPACM_Config::DelExtProp(ipa_ip_type ip_type)
|
||||
{
|
||||
if(ip_type != IPA_IP_v6)
|
||||
{
|
||||
memset(&ext_prop_v4, 0, sizeof(ext_prop_v4));
|
||||
}
|
||||
|
||||
if(ip_type != IPA_IP_v4)
|
||||
{
|
||||
memset(&ext_prop_v6, 0, sizeof(ext_prop_v6));
|
||||
}
|
||||
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
const char* IPACM_Config::getEventName(ipa_cm_event_id event_id)
|
||||
{
|
||||
if(event_id >= sizeof(ipacm_event_name)/sizeof(ipacm_event_name[0]))
|
||||
{
|
||||
IPACMERR("Event name array is not consistent with event array!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ipacm_event_name[event_id];
|
||||
}
|
||||
652
data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackClient.cpp
Normal file
652
data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackClient.cpp
Normal file
@@ -0,0 +1,652 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include "IPACM_Iface.h"
|
||||
#include "IPACM_ConntrackListener.h"
|
||||
#include "IPACM_ConntrackClient.h"
|
||||
#include "IPACM_Log.h"
|
||||
|
||||
#define LO_NAME "lo"
|
||||
|
||||
extern IPACM_EvtDispatcher cm_dis;
|
||||
extern void ParseCTMessage(struct nf_conntrack *ct);
|
||||
|
||||
IPACM_ConntrackClient *IPACM_ConntrackClient::pInstance = NULL;
|
||||
IPACM_ConntrackListener *CtList = NULL;
|
||||
|
||||
/* ================================
|
||||
Local Function Definitions
|
||||
=================================
|
||||
*/
|
||||
IPACM_ConntrackClient::IPACM_ConntrackClient()
|
||||
{
|
||||
IPACMDBG("\n");
|
||||
|
||||
tcp_hdl = NULL;
|
||||
udp_hdl = NULL;
|
||||
tcp_filter = NULL;
|
||||
udp_filter = NULL;
|
||||
}
|
||||
|
||||
IPACM_ConntrackClient* IPACM_ConntrackClient::GetInstance()
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
{
|
||||
pInstance = new IPACM_ConntrackClient();
|
||||
|
||||
pInstance->udp_filter = nfct_filter_create();
|
||||
if(pInstance->udp_filter == NULL)
|
||||
{
|
||||
IPACMERR("unable to create UDP filter\n");
|
||||
delete pInstance;
|
||||
return NULL;
|
||||
}
|
||||
IPACMDBG("Created UDP filter\n");
|
||||
|
||||
pInstance->tcp_filter = nfct_filter_create();
|
||||
if(pInstance->tcp_filter == NULL)
|
||||
{
|
||||
IPACMERR("unable to create TCP filter\n");
|
||||
delete pInstance;
|
||||
return NULL;
|
||||
}
|
||||
IPACMDBG("Created TCP filter\n");
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
int IPACM_ConntrackClient::IPAConntrackEventCB
|
||||
(
|
||||
enum nf_conntrack_msg_type type,
|
||||
struct nf_conntrack *ct,
|
||||
void *data
|
||||
)
|
||||
{
|
||||
ipacm_cmd_q_data evt_data;
|
||||
ipacm_ct_evt_data *ct_data;
|
||||
uint8_t ip_type = 0;
|
||||
|
||||
IPACMDBG("Event callback called with msgtype: %d\n",type);
|
||||
|
||||
/* Retrieve ip type */
|
||||
ip_type = nfct_get_attr_u8(ct, ATTR_REPL_L3PROTO);
|
||||
|
||||
#ifndef CT_OPT
|
||||
if(AF_INET6 == ip_type)
|
||||
{
|
||||
IPACMDBG("Ignoring ipv6(%d) connections\n", ip_type);
|
||||
goto IGNORE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ct_data = (ipacm_ct_evt_data *)malloc(sizeof(ipacm_ct_evt_data));
|
||||
if(ct_data == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory \n");
|
||||
goto IGNORE;
|
||||
}
|
||||
|
||||
ct_data->ct = ct;
|
||||
ct_data->type = type;
|
||||
|
||||
evt_data.event = IPA_PROCESS_CT_MESSAGE;
|
||||
evt_data.evt_data = (void *)ct_data;
|
||||
|
||||
#ifdef CT_OPT
|
||||
if(AF_INET6 == ip_type)
|
||||
{
|
||||
evt_data.event = IPA_PROCESS_CT_MESSAGE_V6;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(0 != IPACM_EvtDispatcher::PostEvt(&evt_data))
|
||||
{
|
||||
IPACMERR("Error sending Conntrack message to processing thread!\n");
|
||||
free(ct_data);
|
||||
goto IGNORE;
|
||||
}
|
||||
|
||||
/* NFCT_CB_STOLEN means that the conntrack object is not released after the
|
||||
callback That must be manually done later when the object is no longer needed. */
|
||||
return NFCT_CB_STOLEN;
|
||||
|
||||
IGNORE:
|
||||
nfct_destroy(ct);
|
||||
return NFCT_CB_STOLEN;
|
||||
|
||||
}
|
||||
|
||||
int IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Bridge_Addrs
|
||||
(
|
||||
struct nfct_filter *filter
|
||||
)
|
||||
{
|
||||
int fd;
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(fd < 0)
|
||||
{
|
||||
PERROR("unable to open socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret;
|
||||
uint32_t ipv4_addr;
|
||||
struct ifreq ifr;
|
||||
|
||||
/* retrieve bridge interface ipv4 address */
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
(void)strncpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name));
|
||||
IPACMDBG("bridge interface name (%s)\n", ifr.ifr_name);
|
||||
|
||||
ret = ioctl(fd, SIOCGIFADDR, &ifr);
|
||||
if (ret < 0)
|
||||
{
|
||||
IPACMERR("unable to retrieve (%s) interface address\n",ifr.ifr_name);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
IPACMDBG("Interface (%s) address %s\n", ifr.ifr_name, inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
|
||||
ipv4_addr = ntohl(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr);
|
||||
close(fd);
|
||||
|
||||
/* ignore whatever is destined to or originates from broadcast ip address */
|
||||
struct nfct_filter_ipv4 filter_ipv4;
|
||||
|
||||
filter_ipv4.addr = ipv4_addr;
|
||||
filter_ipv4.mask = 0xffffffff;
|
||||
|
||||
nfct_filter_set_logic(filter,
|
||||
NFCT_FILTER_DST_IPV4,
|
||||
NFCT_FILTER_LOGIC_NEGATIVE);
|
||||
|
||||
nfct_filter_add_attr(filter, NFCT_FILTER_DST_IPV4, &filter_ipv4);
|
||||
|
||||
nfct_filter_set_logic(filter,
|
||||
NFCT_FILTER_SRC_IPV4,
|
||||
NFCT_FILTER_LOGIC_NEGATIVE);
|
||||
|
||||
nfct_filter_add_attr(filter, NFCT_FILTER_SRC_IPV4, &filter_ipv4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Local_Iface
|
||||
(
|
||||
struct nfct_filter *filter,
|
||||
ipacm_event_iface_up *param
|
||||
)
|
||||
{
|
||||
struct nfct_filter_ipv4 filter_ipv4;
|
||||
|
||||
filter_ipv4.addr = param->ipv4_addr;
|
||||
filter_ipv4.mask = 0xffffffff;
|
||||
|
||||
/* ignore whatever is destined to local interfaces */
|
||||
IPACMDBG("Ignore connections destinated to interface %s", param->ifname);
|
||||
iptodot("with ipv4 address", param->ipv4_addr);
|
||||
nfct_filter_set_logic(filter,
|
||||
NFCT_FILTER_DST_IPV4,
|
||||
NFCT_FILTER_LOGIC_NEGATIVE);
|
||||
|
||||
nfct_filter_add_attr(filter, NFCT_FILTER_DST_IPV4, &filter_ipv4);
|
||||
|
||||
IPACMDBG("Ignore connections orignated from interface %s", param->ifname);
|
||||
iptodot("with ipv4 address", filter_ipv4.addr);
|
||||
nfct_filter_set_logic(filter,
|
||||
NFCT_FILTER_SRC_IPV4,
|
||||
NFCT_FILTER_LOGIC_NEGATIVE);
|
||||
|
||||
nfct_filter_add_attr(filter, NFCT_FILTER_SRC_IPV4, &filter_ipv4);
|
||||
|
||||
/* Retrieve broadcast address */
|
||||
/* Intialize with 255.255.255.255 */
|
||||
uint32_t bc_ip_addr = 0xFFFFFFFF;
|
||||
|
||||
/* calculate broadcast address from addr and addr_mask */
|
||||
bc_ip_addr = (bc_ip_addr & (~param->addr_mask));
|
||||
bc_ip_addr = (bc_ip_addr | (param->ipv4_addr & param->addr_mask));
|
||||
|
||||
/* netfitler expecting in host-byte order */
|
||||
filter_ipv4.addr = bc_ip_addr;
|
||||
filter_ipv4.mask = 0xffffffff;
|
||||
|
||||
iptodot("with broadcast address", filter_ipv4.addr);
|
||||
nfct_filter_set_logic(filter,
|
||||
NFCT_FILTER_DST_IPV4,
|
||||
NFCT_FILTER_LOGIC_NEGATIVE);
|
||||
|
||||
nfct_filter_add_attr(filter, NFCT_FILTER_DST_IPV4, &filter_ipv4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Function which sets up filters to ignore
|
||||
connections to and from local interfaces */
|
||||
int IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Local_Addrs
|
||||
(
|
||||
struct nfct_filter *filter
|
||||
)
|
||||
{
|
||||
struct nfct_filter_ipv4 filter_ipv4;
|
||||
|
||||
/* ignore whatever is destined to or originates from broadcast ip address */
|
||||
filter_ipv4.addr = 0xffffffff;
|
||||
filter_ipv4.mask = 0xffffffff;
|
||||
|
||||
nfct_filter_set_logic(filter,
|
||||
NFCT_FILTER_DST_IPV4,
|
||||
NFCT_FILTER_LOGIC_NEGATIVE);
|
||||
|
||||
nfct_filter_add_attr(filter, NFCT_FILTER_DST_IPV4, &filter_ipv4);
|
||||
|
||||
nfct_filter_set_logic(filter,
|
||||
NFCT_FILTER_SRC_IPV4,
|
||||
NFCT_FILTER_LOGIC_NEGATIVE);
|
||||
|
||||
nfct_filter_add_attr(filter, NFCT_FILTER_SRC_IPV4, &filter_ipv4);
|
||||
|
||||
return 0;
|
||||
} /* IPA_Conntrack_Filters_Ignore_Local_Addrs() */
|
||||
|
||||
/* Initialize TCP Filter */
|
||||
int IPACM_ConntrackClient::IPA_Conntrack_TCP_Filter_Init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
IPACM_ConntrackClient *pClient;
|
||||
|
||||
IPACMDBG("\n");
|
||||
|
||||
pClient = IPACM_ConntrackClient::GetInstance();
|
||||
if(pClient == NULL)
|
||||
{
|
||||
IPACMERR("unable to get conntrack client instance\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = nfct_filter_set_logic(pClient->tcp_filter,
|
||||
NFCT_FILTER_L4PROTO,
|
||||
NFCT_FILTER_LOGIC_POSITIVE);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMERR("Unable to set filter logic\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set protocol filters as tcp and udp */
|
||||
nfct_filter_add_attr_u32(pClient->tcp_filter, NFCT_FILTER_L4PROTO, IPPROTO_TCP);
|
||||
|
||||
|
||||
struct nfct_filter_proto tcp_proto_state;
|
||||
tcp_proto_state.proto = IPPROTO_TCP;
|
||||
tcp_proto_state.state = TCP_CONNTRACK_ESTABLISHED;
|
||||
|
||||
ret = nfct_filter_set_logic(pClient->tcp_filter,
|
||||
NFCT_FILTER_L4PROTO_STATE,
|
||||
NFCT_FILTER_LOGIC_POSITIVE);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMERR("unable to set filter logic\n");
|
||||
return -1;
|
||||
}
|
||||
nfct_filter_add_attr(pClient->tcp_filter,
|
||||
NFCT_FILTER_L4PROTO_STATE,
|
||||
&tcp_proto_state);
|
||||
|
||||
|
||||
tcp_proto_state.proto = IPPROTO_TCP;
|
||||
tcp_proto_state.state = TCP_CONNTRACK_FIN_WAIT;
|
||||
ret = nfct_filter_set_logic(pClient->tcp_filter,
|
||||
NFCT_FILTER_L4PROTO_STATE,
|
||||
NFCT_FILTER_LOGIC_POSITIVE);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMERR("unable to set filter logic\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
nfct_filter_add_attr(pClient->tcp_filter,
|
||||
NFCT_FILTER_L4PROTO_STATE,
|
||||
&tcp_proto_state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize UDP Filter */
|
||||
int IPACM_ConntrackClient::IPA_Conntrack_UDP_Filter_Init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
IPACM_ConntrackClient *pClient = IPACM_ConntrackClient::GetInstance();
|
||||
if(pClient == NULL)
|
||||
{
|
||||
IPACMERR("unable to get conntrack client instance\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = nfct_filter_set_logic(pClient->udp_filter,
|
||||
NFCT_FILTER_L4PROTO,
|
||||
NFCT_FILTER_LOGIC_POSITIVE);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMERR("unable to set filter logic\n");
|
||||
}
|
||||
/* set protocol filters as tcp and udp */
|
||||
nfct_filter_add_attr_u32(pClient->udp_filter, NFCT_FILTER_L4PROTO, IPPROTO_UDP);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* IPACM_ConntrackClient::UDPConnTimeoutUpdate(void *ptr)
|
||||
{
|
||||
|
||||
NatApp *nat_inst = NULL;
|
||||
#ifdef IPACM_DEBUG
|
||||
IPACMDBG("\n");
|
||||
#endif
|
||||
|
||||
nat_inst = NatApp::GetInstance();
|
||||
if(nat_inst == NULL)
|
||||
{
|
||||
IPACMERR("unable to create nat instance\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
nat_inst->UpdateUDPTimeStamp();
|
||||
sleep(UDP_TIMEOUT_UPDATE);
|
||||
} /* end of while(1) loop */
|
||||
|
||||
#ifdef IPACM_DEBUG
|
||||
IPACMDBG("Returning from %s() %d\n", __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Thread to initialize TCP Conntrack Filters*/
|
||||
void* IPACM_ConntrackClient::TCPRegisterWithConnTrack(void *)
|
||||
{
|
||||
int ret;
|
||||
IPACM_ConntrackClient *pClient;
|
||||
unsigned subscrips = 0;
|
||||
|
||||
IPACMDBG("\n");
|
||||
|
||||
pClient = IPACM_ConntrackClient::GetInstance();
|
||||
if(pClient == NULL)
|
||||
{
|
||||
IPACMERR("unable to get conntrack client instance\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
subscrips = (NF_NETLINK_CONNTRACK_UPDATE | NF_NETLINK_CONNTRACK_DESTROY);
|
||||
#ifdef CT_OPT
|
||||
subscrips |= NF_NETLINK_CONNTRACK_NEW;
|
||||
#endif
|
||||
|
||||
pClient->tcp_hdl = nfct_open(CONNTRACK, subscrips);
|
||||
if(pClient->tcp_hdl == NULL)
|
||||
{
|
||||
PERROR("nfct_open\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize the filter */
|
||||
ret = IPA_Conntrack_TCP_Filter_Init();
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMERR("Unable to initliaze TCP Filter\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Attach the filter to net filter handler */
|
||||
ret = nfct_filter_attach(nfct_fd(pClient->tcp_hdl), pClient->tcp_filter);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMDBG("unable to attach TCP filter\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Register callback with netfilter handler */
|
||||
IPACMDBG_H("tcp handle:%p, fd:%d\n", pClient->tcp_hdl, nfct_fd(pClient->tcp_hdl));
|
||||
#ifndef CT_OPT
|
||||
nfct_callback_register(pClient->tcp_hdl,
|
||||
(nf_conntrack_msg_type) (NFCT_T_UPDATE | NFCT_T_DESTROY | NFCT_T_NEW),
|
||||
IPAConntrackEventCB, NULL);
|
||||
#else
|
||||
nfct_callback_register(pClient->tcp_hdl, (nf_conntrack_msg_type) NFCT_T_ALL, IPAConntrackEventCB, NULL);
|
||||
#endif
|
||||
|
||||
/* Block to catch events from net filter connection track */
|
||||
/* nfct_catch() receives conntrack events from kernel-space, by default it
|
||||
blocks waiting for events. */
|
||||
IPACMDBG("Waiting for events\n");
|
||||
|
||||
ret = nfct_catch(pClient->tcp_hdl);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMERR("(%d)(%s)\n", ret, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IPACMDBG("Exit from tcp thread\n");
|
||||
|
||||
/* destroy the filter.. this will not detach the filter */
|
||||
nfct_filter_destroy(pClient->tcp_filter);
|
||||
pClient->tcp_filter = NULL;
|
||||
|
||||
/* de-register the callback */
|
||||
nfct_callback_unregister(pClient->tcp_hdl);
|
||||
/* close the handle */
|
||||
nfct_close(pClient->tcp_hdl);
|
||||
pClient->tcp_hdl = NULL;
|
||||
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Thread to initialize UDP Conntrack Filters*/
|
||||
void* IPACM_ConntrackClient::UDPRegisterWithConnTrack(void *)
|
||||
{
|
||||
int ret;
|
||||
IPACM_ConntrackClient *pClient = NULL;
|
||||
|
||||
IPACMDBG("\n");
|
||||
|
||||
pClient = IPACM_ConntrackClient::GetInstance();
|
||||
if(pClient == NULL)
|
||||
{
|
||||
IPACMERR("unable to retrieve instance of conntrack client\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pClient->udp_hdl = nfct_open(CONNTRACK,
|
||||
(NF_NETLINK_CONNTRACK_NEW | NF_NETLINK_CONNTRACK_DESTROY));
|
||||
if(pClient->udp_hdl == NULL)
|
||||
{
|
||||
PERROR("nfct_open\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize Filter */
|
||||
ret = IPA_Conntrack_UDP_Filter_Init();
|
||||
if(-1 == ret)
|
||||
{
|
||||
IPACMDBG("Unable to initalize udp filters\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Attach the filter to net filter handler */
|
||||
ret = nfct_filter_attach(nfct_fd(pClient->udp_hdl), pClient->udp_filter);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMDBG("unable to attach the filter\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Register callback with netfilter handler */
|
||||
IPACMDBG_H("udp handle:%p, fd:%d\n", pClient->udp_hdl, nfct_fd(pClient->udp_hdl));
|
||||
nfct_callback_register(pClient->udp_hdl,
|
||||
(nf_conntrack_msg_type)(NFCT_T_NEW | NFCT_T_DESTROY),
|
||||
IPAConntrackEventCB,
|
||||
NULL);
|
||||
|
||||
/* Block to catch events from net filter connection track */
|
||||
ctcatch:
|
||||
ret = nfct_catch(pClient->udp_hdl);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMDBG("(%d)(%s)\n", ret, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG("ctcatch ret:%d\n", ret);
|
||||
goto ctcatch;
|
||||
}
|
||||
|
||||
IPACMDBG("Exit from udp thread with ret: %d\n", ret);
|
||||
|
||||
/* destroy the filter.. this will not detach the filter */
|
||||
nfct_filter_destroy(pClient->udp_filter);
|
||||
pClient->udp_filter = NULL;
|
||||
|
||||
/* de-register the callback */
|
||||
nfct_callback_unregister(pClient->udp_hdl);
|
||||
/* close the handle */
|
||||
nfct_close(pClient->udp_hdl);
|
||||
pClient->udp_hdl = NULL;
|
||||
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void IPACM_ConntrackClient::UpdateUDPFilters(void *param, bool isWan)
|
||||
{
|
||||
static bool isIgnore = false;
|
||||
int ret = 0;
|
||||
IPACM_ConntrackClient *pClient = NULL;
|
||||
|
||||
pClient = IPACM_ConntrackClient::GetInstance();
|
||||
if(pClient == NULL)
|
||||
{
|
||||
IPACMERR("unable to retrieve conntrack client instance\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(pClient->udp_filter == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isWan)
|
||||
{
|
||||
IPA_Conntrack_Filters_Ignore_Local_Iface(pClient->udp_filter,
|
||||
(ipacm_event_iface_up *)param);
|
||||
|
||||
if(!isIgnore)
|
||||
{
|
||||
IPA_Conntrack_Filters_Ignore_Bridge_Addrs(pClient->udp_filter);
|
||||
IPA_Conntrack_Filters_Ignore_Local_Addrs(pClient->udp_filter);
|
||||
isIgnore = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Attach the filter to udp handle */
|
||||
if(pClient->udp_hdl != NULL)
|
||||
{
|
||||
IPACMDBG("attaching the filter to udp handle\n");
|
||||
ret = nfct_filter_attach(nfct_fd(pClient->udp_hdl), pClient->udp_filter);
|
||||
if(ret == -1)
|
||||
{
|
||||
PERROR("unable to attach the filter to udp handle\n");
|
||||
IPACMERR("udp handle:%p, fd:%d Error: %d\n",pClient->udp_hdl, nfct_fd(pClient->udp_hdl), ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void IPACM_ConntrackClient::UpdateTCPFilters(void *param, bool isWan)
|
||||
{
|
||||
static bool isIgnore = false;
|
||||
int ret = 0;
|
||||
IPACM_ConntrackClient *pClient = NULL;
|
||||
|
||||
pClient = IPACM_ConntrackClient::GetInstance();
|
||||
if(pClient == NULL)
|
||||
{
|
||||
IPACMERR("unable to retrieve conntrack client instance\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(pClient->tcp_filter == NULL)
|
||||
return;
|
||||
|
||||
if(!isWan)
|
||||
{
|
||||
IPA_Conntrack_Filters_Ignore_Local_Iface(pClient->tcp_filter,
|
||||
(ipacm_event_iface_up *)param);
|
||||
|
||||
if(!isIgnore)
|
||||
{
|
||||
IPA_Conntrack_Filters_Ignore_Bridge_Addrs(pClient->udp_filter);
|
||||
IPA_Conntrack_Filters_Ignore_Local_Addrs(pClient->udp_filter);
|
||||
isIgnore = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Attach the filter to tcp handle */
|
||||
if(pClient->tcp_hdl != NULL)
|
||||
{
|
||||
IPACMDBG("attaching the filter to tcp handle\n");
|
||||
ret = nfct_filter_attach(nfct_fd(pClient->tcp_hdl), pClient->tcp_filter);
|
||||
if(ret == -1)
|
||||
{
|
||||
PERROR("unable to attach the filter to tcp handle\n");
|
||||
IPACMERR("tcp handle:%p, fd:%d Error: %d\n",pClient->tcp_hdl, nfct_fd(pClient->tcp_hdl), ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
1200
data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackListener.cpp
Normal file
1200
data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackListener.cpp
Normal file
File diff suppressed because it is too large
Load Diff
969
data-ipa-cfg-mgr/ipacm/src/IPACM_Conntrack_NATApp.cpp
Normal file
969
data-ipa-cfg-mgr/ipacm/src/IPACM_Conntrack_NATApp.cpp
Normal file
@@ -0,0 +1,969 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "IPACM_Conntrack_NATApp.h"
|
||||
#include "IPACM_ConntrackClient.h"
|
||||
|
||||
#define INVALID_IP_ADDR 0x0
|
||||
|
||||
/* NatApp class Implementation */
|
||||
NatApp *NatApp::pInstance = NULL;
|
||||
NatApp::NatApp()
|
||||
{
|
||||
max_entries = 0;
|
||||
cache = NULL;
|
||||
|
||||
nat_table_hdl = 0;
|
||||
pub_ip_addr = 0;
|
||||
|
||||
curCnt = 0;
|
||||
|
||||
pALGPorts = NULL;
|
||||
nALGPort = 0;
|
||||
|
||||
ct = NULL;
|
||||
ct_hdl = NULL;
|
||||
|
||||
memset(temp, 0, sizeof(temp));
|
||||
}
|
||||
|
||||
int NatApp::Init(void)
|
||||
{
|
||||
IPACM_Config *pConfig;
|
||||
int size = 0;
|
||||
|
||||
pConfig = IPACM_Config::GetInstance();
|
||||
if(pConfig == NULL)
|
||||
{
|
||||
IPACMERR("Unable to get Config instance\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
max_entries = pConfig->GetNatMaxEntries();
|
||||
|
||||
size = (sizeof(nat_table_entry) * max_entries);
|
||||
cache = (nat_table_entry *)malloc(size);
|
||||
if(cache == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory for cache\n");
|
||||
goto fail;
|
||||
}
|
||||
IPACMDBG("Allocated %d bytes for config manager nat cache\n", size);
|
||||
memset(cache, 0, size);
|
||||
|
||||
nALGPort = pConfig->GetAlgPortCnt();
|
||||
if(nALGPort > 0)
|
||||
{
|
||||
pALGPorts = (ipacm_alg *)malloc(sizeof(ipacm_alg) * nALGPort);
|
||||
if(pALGPorts == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory for alg prots\n");
|
||||
goto fail;
|
||||
}
|
||||
memset(pALGPorts, 0, sizeof(ipacm_alg) * nALGPort);
|
||||
|
||||
if(pConfig->GetAlgPorts(nALGPort, pALGPorts) != 0)
|
||||
{
|
||||
IPACMERR("Unable to retrieve ALG prots\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
IPACMDBG("Printing %d alg ports information\n", nALGPort);
|
||||
for(int cnt=0; cnt<nALGPort; cnt++)
|
||||
{
|
||||
IPACMDBG("%d: Proto[%d], port[%d]\n", cnt, pALGPorts[cnt].protocol, pALGPorts[cnt].port);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
free(cache);
|
||||
free(pALGPorts);
|
||||
return -1;
|
||||
}
|
||||
|
||||
NatApp* NatApp::GetInstance()
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
{
|
||||
pInstance = new NatApp();
|
||||
|
||||
if(pInstance->Init())
|
||||
{
|
||||
delete pInstance;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
/* NAT APP related object function definitions */
|
||||
|
||||
int NatApp::AddTable(uint32_t pub_ip)
|
||||
{
|
||||
int ret;
|
||||
int cnt = 0;
|
||||
ipa_nat_ipv4_rule nat_rule;
|
||||
IPACMDBG_H("%s() %d\n", __FUNCTION__, __LINE__);
|
||||
|
||||
/* Not reset the cache wait it timeout by destroy event */
|
||||
#if 0
|
||||
if (pub_ip != pub_ip_addr_pre)
|
||||
{
|
||||
IPACMDBG("Reset the cache because NAT-ipv4 different\n");
|
||||
memset(cache, 0, sizeof(nat_table_entry) * max_entries);
|
||||
curCnt = 0;
|
||||
}
|
||||
#endif
|
||||
ret = ipa_nat_add_ipv4_tbl(pub_ip, max_entries, &nat_table_hdl);
|
||||
if(ret)
|
||||
{
|
||||
IPACMERR("unable to create nat table Error:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Add back the cached NAT-entry */
|
||||
if (pub_ip == pub_ip_addr_pre)
|
||||
{
|
||||
IPACMDBG("Restore the cache to ipa NAT-table\n");
|
||||
for(cnt = 0; cnt < max_entries; cnt++)
|
||||
{
|
||||
if(cache[cnt].private_ip !=0)
|
||||
{
|
||||
memset(&nat_rule, 0 , sizeof(nat_rule));
|
||||
nat_rule.private_ip = cache[cnt].private_ip;
|
||||
nat_rule.target_ip = cache[cnt].target_ip;
|
||||
nat_rule.target_port = cache[cnt].target_port;
|
||||
nat_rule.private_port = cache[cnt].private_port;
|
||||
nat_rule.public_port = cache[cnt].public_port;
|
||||
nat_rule.protocol = cache[cnt].protocol;
|
||||
|
||||
if(ipa_nat_add_ipv4_rule(nat_table_hdl, &nat_rule, &cache[cnt].rule_hdl) < 0)
|
||||
{
|
||||
IPACMERR("unable to add the rule delete from cache\n");
|
||||
memset(&cache[cnt], 0, sizeof(cache[cnt]));
|
||||
curCnt--;
|
||||
continue;
|
||||
}
|
||||
cache[cnt].enabled = true;
|
||||
|
||||
IPACMDBG("On wan-iface reset added below rule successfully\n");
|
||||
iptodot("Private IP", nat_rule.private_ip);
|
||||
iptodot("Target IP", nat_rule.target_ip);
|
||||
IPACMDBG("Private Port:%d \t Target Port: %d\t", nat_rule.private_port, nat_rule.target_port);
|
||||
IPACMDBG("Public Port:%d\n", nat_rule.public_port);
|
||||
IPACMDBG("protocol: %d\n", nat_rule.protocol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub_ip_addr = pub_ip;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NatApp::Reset()
|
||||
{
|
||||
int cnt = 0;
|
||||
|
||||
nat_table_hdl = 0;
|
||||
pub_ip_addr = 0;
|
||||
/* NAT tbl deleted, reset enabled bit */
|
||||
for(cnt = 0; cnt < max_entries; cnt++)
|
||||
{
|
||||
cache[cnt].enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
int NatApp::DeleteTable(uint32_t pub_ip)
|
||||
{
|
||||
int ret;
|
||||
IPACMDBG_H("%s() %d\n", __FUNCTION__, __LINE__);
|
||||
|
||||
CHK_TBL_HDL();
|
||||
|
||||
if(pub_ip_addr != pub_ip)
|
||||
{
|
||||
IPACMDBG("Public ip address is not matching\n");
|
||||
IPACMERR("unable to delete the nat table\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = ipa_nat_del_ipv4_tbl(nat_table_hdl);
|
||||
if(ret)
|
||||
{
|
||||
IPACMERR("unable to delete nat table Error: %d\n", ret);;
|
||||
return ret;
|
||||
}
|
||||
|
||||
pub_ip_addr_pre = pub_ip_addr;
|
||||
Reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check for duplicate entries */
|
||||
bool NatApp::ChkForDup(const nat_table_entry *rule)
|
||||
{
|
||||
int cnt = 0;
|
||||
IPACMDBG("%s() %d\n", __FUNCTION__, __LINE__);
|
||||
|
||||
for(; cnt < max_entries; cnt++)
|
||||
{
|
||||
if(cache[cnt].private_ip == rule->private_ip &&
|
||||
cache[cnt].target_ip == rule->target_ip &&
|
||||
cache[cnt].private_port == rule->private_port &&
|
||||
cache[cnt].target_port == rule->target_port &&
|
||||
cache[cnt].protocol == rule->protocol)
|
||||
{
|
||||
log_nat(rule->protocol,rule->private_ip,rule->target_ip,rule->private_port,\
|
||||
rule->target_port,"Duplicate Rule\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Delete the entry from Nat table on connection close */
|
||||
int NatApp::DeleteEntry(const nat_table_entry *rule)
|
||||
{
|
||||
int cnt = 0;
|
||||
IPACMDBG("%s() %d\n", __FUNCTION__, __LINE__);
|
||||
|
||||
log_nat(rule->protocol,rule->private_ip,rule->target_ip,rule->private_port,\
|
||||
rule->target_port,"for deletion\n");
|
||||
|
||||
|
||||
for(; cnt < max_entries; cnt++)
|
||||
{
|
||||
if(cache[cnt].private_ip == rule->private_ip &&
|
||||
cache[cnt].target_ip == rule->target_ip &&
|
||||
cache[cnt].private_port == rule->private_port &&
|
||||
cache[cnt].target_port == rule->target_port &&
|
||||
cache[cnt].protocol == rule->protocol)
|
||||
{
|
||||
|
||||
if(cache[cnt].enabled == true)
|
||||
{
|
||||
if(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)
|
||||
{
|
||||
IPACMERR("%s() %d deletion failed\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
IPACMDBG_H("Deleted Nat entry(%d) Successfully\n", cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_H("Deleted Nat entry(%d) only from cache\n", cnt);
|
||||
}
|
||||
|
||||
memset(&cache[cnt], 0, sizeof(cache[cnt]));
|
||||
curCnt--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add new entry to the nat table on new connection */
|
||||
int NatApp::AddEntry(const nat_table_entry *rule)
|
||||
{
|
||||
int cnt = 0;
|
||||
ipa_nat_ipv4_rule nat_rule;
|
||||
|
||||
IPACMDBG("%s() %d\n", __FUNCTION__, __LINE__);
|
||||
|
||||
CHK_TBL_HDL();
|
||||
log_nat(rule->protocol,rule->private_ip,rule->target_ip,rule->private_port,\
|
||||
rule->target_port,"for addition\n");
|
||||
if(isAlgPort(rule->protocol, rule->private_port) ||
|
||||
isAlgPort(rule->protocol, rule->target_port))
|
||||
{
|
||||
IPACMERR("connection using ALG Port, ignore\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(rule->private_ip == 0 ||
|
||||
rule->target_ip == 0 ||
|
||||
rule->private_port == 0 ||
|
||||
rule->target_port == 0 ||
|
||||
rule->protocol == 0)
|
||||
{
|
||||
IPACMERR("Invalid Connection, ignoring it\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!ChkForDup(rule))
|
||||
{
|
||||
for(; cnt < max_entries; cnt++)
|
||||
{
|
||||
if(cache[cnt].private_ip == 0 &&
|
||||
cache[cnt].target_ip == 0 &&
|
||||
cache[cnt].private_port == 0 &&
|
||||
cache[cnt].target_port == 0 &&
|
||||
cache[cnt].protocol == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(max_entries == cnt)
|
||||
{
|
||||
IPACMERR("Error: Unable to add, reached maximum rules\n");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nat_rule.private_ip = rule->private_ip;
|
||||
nat_rule.target_ip = rule->target_ip;
|
||||
nat_rule.target_port = rule->target_port;
|
||||
nat_rule.private_port = rule->private_port;
|
||||
nat_rule.public_port = rule->public_port;
|
||||
nat_rule.protocol = rule->protocol;
|
||||
|
||||
if(isPwrSaveIf(rule->private_ip) ||
|
||||
isPwrSaveIf(rule->target_ip))
|
||||
{
|
||||
IPACMDBG("Device is Power Save mode: Dont insert into nat table but cache\n");
|
||||
cache[cnt].enabled = false;
|
||||
cache[cnt].rule_hdl = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(ipa_nat_add_ipv4_rule(nat_table_hdl, &nat_rule, &cache[cnt].rule_hdl) < 0)
|
||||
{
|
||||
IPACMERR("unable to add the rule\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
cache[cnt].enabled = true;
|
||||
}
|
||||
|
||||
cache[cnt].private_ip = rule->private_ip;
|
||||
cache[cnt].target_ip = rule->target_ip;
|
||||
cache[cnt].target_port = rule->target_port;
|
||||
cache[cnt].private_port = rule->private_port;
|
||||
cache[cnt].protocol = rule->protocol;
|
||||
cache[cnt].timestamp = 0;
|
||||
cache[cnt].public_port = rule->public_port;
|
||||
cache[cnt].dst_nat = rule->dst_nat;
|
||||
curCnt++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR("Duplicate rule. Ignore it\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(cache[cnt].enabled == true)
|
||||
{
|
||||
IPACMDBG_H("Added rule(%d) successfully\n", cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_H("Cached rule(%d) successfully\n", cnt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NatApp::UpdateCTUdpTs(nat_table_entry *rule, uint32_t new_ts)
|
||||
{
|
||||
int ret;
|
||||
|
||||
iptodot("Private IP:", rule->private_ip);
|
||||
iptodot("Target IP:", rule->target_ip);
|
||||
IPACMDBG("Private Port: %d, Target Port: %d\n", rule->private_port, rule->target_port);
|
||||
|
||||
if(!ct_hdl)
|
||||
{
|
||||
ct_hdl = nfct_open(CONNTRACK, 0);
|
||||
if(!ct_hdl)
|
||||
{
|
||||
PERROR("nfct_open");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!ct)
|
||||
{
|
||||
ct = nfct_new();
|
||||
if(!ct)
|
||||
{
|
||||
PERROR("nfct_new");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET);
|
||||
if(rule->protocol == IPPROTO_UDP)
|
||||
{
|
||||
nfct_set_attr_u8(ct, ATTR_L4PROTO, rule->protocol);
|
||||
nfct_set_attr_u32(ct, ATTR_TIMEOUT, udp_timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
nfct_set_attr_u8(ct, ATTR_L4PROTO, rule->protocol);
|
||||
nfct_set_attr_u32(ct, ATTR_TIMEOUT, tcp_timeout);
|
||||
}
|
||||
|
||||
if(rule->dst_nat == false)
|
||||
{
|
||||
nfct_set_attr_u32(ct, ATTR_IPV4_SRC, htonl(rule->private_ip));
|
||||
nfct_set_attr_u16(ct, ATTR_PORT_SRC, htons(rule->private_port));
|
||||
|
||||
nfct_set_attr_u32(ct, ATTR_IPV4_DST, htonl(rule->target_ip));
|
||||
nfct_set_attr_u16(ct, ATTR_PORT_DST, htons(rule->target_port));
|
||||
|
||||
IPACMDBG("dst nat is not set\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
nfct_set_attr_u32(ct, ATTR_IPV4_SRC, htonl(rule->target_ip));
|
||||
nfct_set_attr_u16(ct, ATTR_PORT_SRC, htons(rule->target_port));
|
||||
|
||||
nfct_set_attr_u32(ct, ATTR_IPV4_DST, htonl(pub_ip_addr));
|
||||
nfct_set_attr_u16(ct, ATTR_PORT_DST, htons(rule->public_port));
|
||||
|
||||
IPACMDBG("dst nat is set\n");
|
||||
}
|
||||
|
||||
iptodot("Source IP:", nfct_get_attr_u32(ct, ATTR_IPV4_SRC));
|
||||
iptodot("Destination IP:", nfct_get_attr_u32(ct, ATTR_IPV4_DST));
|
||||
IPACMDBG("Source Port: %d, Destination Port: %d\n",
|
||||
nfct_get_attr_u16(ct, ATTR_PORT_SRC), nfct_get_attr_u16(ct, ATTR_PORT_DST));
|
||||
|
||||
IPACMDBG("updating %d connection with time: %d\n",
|
||||
rule->protocol, nfct_get_attr_u32(ct, ATTR_TIMEOUT));
|
||||
|
||||
ret = nfct_query(ct_hdl, NFCT_Q_UPDATE, ct);
|
||||
if(ret == -1)
|
||||
{
|
||||
IPACMERR("unable to update time stamp");
|
||||
DeleteEntry(rule);
|
||||
}
|
||||
else
|
||||
{
|
||||
rule->timestamp = new_ts;
|
||||
IPACMDBG("Updated time stamp successfully\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void NatApp::UpdateUDPTimeStamp()
|
||||
{
|
||||
int cnt;
|
||||
uint32_t ts;
|
||||
bool read_to = false;
|
||||
|
||||
for(cnt = 0; cnt < max_entries; cnt++)
|
||||
{
|
||||
ts = 0;
|
||||
if(cache[cnt].enabled == true &&
|
||||
(cache[cnt].private_ip != cache[cnt].public_ip))
|
||||
{
|
||||
IPACMDBG("\n");
|
||||
if(ipa_nat_query_timestamp(nat_table_hdl, cache[cnt].rule_hdl, &ts) < 0)
|
||||
{
|
||||
IPACMERR("unable to retrieve timeout for rule hanle: %d\n", cache[cnt].rule_hdl);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(cache[cnt].timestamp == ts)
|
||||
{
|
||||
IPACMDBG("No Change in Time Stamp: cahce:%d, ipahw:%d\n",
|
||||
cache[cnt].timestamp, ts);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (read_to == false) {
|
||||
read_to = true;
|
||||
Read_TcpUdp_Timeout();
|
||||
}
|
||||
|
||||
UpdateCTUdpTs(&cache[cnt], ts);
|
||||
} /* end of outer if */
|
||||
|
||||
} /* end of for loop */
|
||||
|
||||
}
|
||||
|
||||
bool NatApp::isAlgPort(uint8_t proto, uint16_t port)
|
||||
{
|
||||
int cnt;
|
||||
for(cnt = 0; cnt < nALGPort; cnt++)
|
||||
{
|
||||
if(proto == pALGPorts[cnt].protocol &&
|
||||
port == pALGPorts[cnt].port)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NatApp::isPwrSaveIf(uint32_t ip_addr)
|
||||
{
|
||||
int cnt;
|
||||
|
||||
for(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)
|
||||
{
|
||||
if(0 != PwrSaveIfs[cnt] &&
|
||||
ip_addr == PwrSaveIfs[cnt])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int NatApp::UpdatePwrSaveIf(uint32_t client_lan_ip)
|
||||
{
|
||||
int cnt;
|
||||
IPACMDBG_H("Received IP address: 0x%x\n", client_lan_ip);
|
||||
|
||||
if(client_lan_ip == INVALID_IP_ADDR)
|
||||
{
|
||||
IPACMERR("Invalid ip address received\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check for duplicate events */
|
||||
for(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)
|
||||
{
|
||||
if(PwrSaveIfs[cnt] == client_lan_ip)
|
||||
{
|
||||
IPACMDBG("The client 0x%x is already in power save\n", client_lan_ip);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
for(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)
|
||||
{
|
||||
if(PwrSaveIfs[cnt] == 0)
|
||||
{
|
||||
PwrSaveIfs[cnt] = client_lan_ip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(cnt = 0; cnt < max_entries; cnt++)
|
||||
{
|
||||
if(cache[cnt].private_ip == client_lan_ip &&
|
||||
cache[cnt].enabled == true)
|
||||
{
|
||||
if(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)
|
||||
{
|
||||
IPACMERR("unable to delete the rule\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
cache[cnt].enabled = false;
|
||||
cache[cnt].rule_hdl = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NatApp::ResetPwrSaveIf(uint32_t client_lan_ip)
|
||||
{
|
||||
int cnt;
|
||||
ipa_nat_ipv4_rule nat_rule;
|
||||
|
||||
IPACMDBG_H("Received ip address: 0x%x\n", client_lan_ip);
|
||||
|
||||
if(client_lan_ip == INVALID_IP_ADDR)
|
||||
{
|
||||
IPACMERR("Invalid ip address received\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)
|
||||
{
|
||||
if(PwrSaveIfs[cnt] == client_lan_ip)
|
||||
{
|
||||
PwrSaveIfs[cnt] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(cnt = 0; cnt < max_entries; cnt++)
|
||||
{
|
||||
IPACMDBG("cache (%d): enable %d, ip 0x%x\n", cnt, cache[cnt].enabled, cache[cnt].private_ip);
|
||||
|
||||
if(cache[cnt].private_ip == client_lan_ip &&
|
||||
cache[cnt].enabled == false)
|
||||
{
|
||||
memset(&nat_rule, 0 , sizeof(nat_rule));
|
||||
nat_rule.private_ip = cache[cnt].private_ip;
|
||||
nat_rule.target_ip = cache[cnt].target_ip;
|
||||
nat_rule.target_port = cache[cnt].target_port;
|
||||
nat_rule.private_port = cache[cnt].private_port;
|
||||
nat_rule.public_port = cache[cnt].public_port;
|
||||
nat_rule.protocol = cache[cnt].protocol;
|
||||
|
||||
if(ipa_nat_add_ipv4_rule(nat_table_hdl, &nat_rule, &cache[cnt].rule_hdl) < 0)
|
||||
{
|
||||
IPACMERR("unable to add the rule delete from cache\n");
|
||||
memset(&cache[cnt], 0, sizeof(cache[cnt]));
|
||||
curCnt--;
|
||||
continue;
|
||||
}
|
||||
cache[cnt].enabled = true;
|
||||
|
||||
IPACMDBG("On power reset added below rule successfully\n");
|
||||
iptodot("Private IP", nat_rule.private_ip);
|
||||
iptodot("Target IP", nat_rule.target_ip);
|
||||
IPACMDBG("Private Port:%d \t Target Port: %d\t", nat_rule.private_port, nat_rule.target_port);
|
||||
IPACMDBG("Public Port:%d\n", nat_rule.public_port);
|
||||
IPACMDBG("protocol: %d\n", nat_rule.protocol);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t NatApp::GetTableHdl(uint32_t in_ip_addr)
|
||||
{
|
||||
if(in_ip_addr == pub_ip_addr)
|
||||
{
|
||||
return nat_table_hdl;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void NatApp::AddTempEntry(const nat_table_entry *new_entry)
|
||||
{
|
||||
int cnt;
|
||||
|
||||
IPACMDBG("Received below Temp Nat entry\n");
|
||||
iptodot("Private IP", new_entry->private_ip);
|
||||
iptodot("Target IP", new_entry->target_ip);
|
||||
IPACMDBG("Private Port: %d\t Target Port: %d\t", new_entry->private_port, new_entry->target_port);
|
||||
IPACMDBG("protocolcol: %d\n", new_entry->protocol);
|
||||
|
||||
if(isAlgPort(new_entry->protocol, new_entry->private_port) ||
|
||||
isAlgPort(new_entry->protocol, new_entry->target_port))
|
||||
{
|
||||
IPACMDBG("connection using ALG Port. Dont insert into nat cache\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ChkForDup(new_entry))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(cnt=0; cnt<MAX_TEMP_ENTRIES; cnt++)
|
||||
{
|
||||
if(temp[cnt].private_ip == new_entry->private_ip &&
|
||||
temp[cnt].target_ip == new_entry->target_ip &&
|
||||
temp[cnt].private_port == new_entry->private_port &&
|
||||
temp[cnt].target_port == new_entry->target_port &&
|
||||
temp[cnt].protocol == new_entry->protocol)
|
||||
{
|
||||
IPACMDBG("Received duplicate Temp entry\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(cnt=0; cnt<MAX_TEMP_ENTRIES; cnt++)
|
||||
{
|
||||
if(temp[cnt].private_ip == 0 &&
|
||||
temp[cnt].target_ip == 0)
|
||||
{
|
||||
memcpy(&temp[cnt], new_entry, sizeof(nat_table_entry));
|
||||
IPACMDBG("Added Temp Entry\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG("Unable to add temp entry, cache full\n");
|
||||
return;
|
||||
}
|
||||
|
||||
void NatApp::DeleteTempEntry(const nat_table_entry *entry)
|
||||
{
|
||||
int cnt;
|
||||
|
||||
IPACMDBG("Received below nat entry\n");
|
||||
iptodot("Private IP", entry->private_ip);
|
||||
iptodot("Target IP", entry->target_ip);
|
||||
IPACMDBG("Private Port: %d\t Target Port: %d\n", entry->private_port, entry->target_port);
|
||||
IPACMDBG("protocol: %d\n", entry->protocol);
|
||||
|
||||
for(cnt=0; cnt<MAX_TEMP_ENTRIES; cnt++)
|
||||
{
|
||||
if(temp[cnt].private_ip == entry->private_ip &&
|
||||
temp[cnt].target_ip == entry->target_ip &&
|
||||
temp[cnt].private_port == entry->private_port &&
|
||||
temp[cnt].target_port == entry->target_port &&
|
||||
temp[cnt].protocol == entry->protocol)
|
||||
{
|
||||
memset(&temp[cnt], 0, sizeof(nat_table_entry));
|
||||
IPACMDBG("Delete Temp Entry\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG("No Such Temp Entry exists\n");
|
||||
return;
|
||||
}
|
||||
|
||||
void NatApp::FlushTempEntries(uint32_t ip_addr, bool isAdd,
|
||||
bool isDummy)
|
||||
{
|
||||
int cnt;
|
||||
int ret;
|
||||
|
||||
IPACMDBG_H("Received below with isAdd:%d ", isAdd);
|
||||
iptodot("IP Address: ", ip_addr);
|
||||
|
||||
for(cnt=0; cnt<MAX_TEMP_ENTRIES; cnt++)
|
||||
{
|
||||
if(temp[cnt].private_ip == ip_addr ||
|
||||
temp[cnt].target_ip == ip_addr)
|
||||
{
|
||||
if(isAdd)
|
||||
{
|
||||
if(temp[cnt].public_ip == pub_ip_addr)
|
||||
{
|
||||
if (isDummy) {
|
||||
/* To avoild DL expections for non IPA path */
|
||||
temp[cnt].private_ip = temp[cnt].public_ip;
|
||||
temp[cnt].private_port = temp[cnt].public_port;
|
||||
IPACMDBG("Flushing dummy temp rule");
|
||||
iptodot("Private IP", temp[cnt].private_ip);
|
||||
}
|
||||
|
||||
ret = AddEntry(&temp[cnt]);
|
||||
if(ret)
|
||||
{
|
||||
IPACMERR("unable to add temp entry: %d\n", ret);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
memset(&temp[cnt], 0, sizeof(nat_table_entry));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int NatApp::DelEntriesOnClntDiscon(uint32_t ip_addr)
|
||||
{
|
||||
int cnt, tmp = 0;
|
||||
IPACMDBG_H("Received IP address: 0x%x\n", ip_addr);
|
||||
|
||||
if(ip_addr == INVALID_IP_ADDR)
|
||||
{
|
||||
IPACMERR("Invalid ip address received\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)
|
||||
{
|
||||
if(PwrSaveIfs[cnt] == ip_addr)
|
||||
{
|
||||
PwrSaveIfs[cnt] = 0;
|
||||
IPACMDBG("Remove %d power save entry\n", cnt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(cnt = 0; cnt < max_entries; cnt++)
|
||||
{
|
||||
if(cache[cnt].private_ip == ip_addr)
|
||||
{
|
||||
if(cache[cnt].enabled == true)
|
||||
{
|
||||
if(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)
|
||||
{
|
||||
IPACMERR("unable to delete the rule\n");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG("won't delete the rule\n");
|
||||
cache[cnt].enabled = false;
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
IPACMDBG("won't delete the rule for entry %d, enabled %d\n",cnt, cache[cnt].enabled);
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG("Deleted (but cached) %d entries\n", tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NatApp::DelEntriesOnSTAClntDiscon(uint32_t ip_addr)
|
||||
{
|
||||
int cnt, tmp = curCnt;
|
||||
IPACMDBG_H("Received IP address: 0x%x\n", ip_addr);
|
||||
|
||||
if(ip_addr == INVALID_IP_ADDR)
|
||||
{
|
||||
IPACMERR("Invalid ip address received\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
for(cnt = 0; cnt < max_entries; cnt++)
|
||||
{
|
||||
if(cache[cnt].target_ip == ip_addr)
|
||||
{
|
||||
if(cache[cnt].enabled == true)
|
||||
{
|
||||
if(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)
|
||||
{
|
||||
IPACMERR("unable to delete the rule\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&cache[cnt], 0, sizeof(cache[cnt]));
|
||||
curCnt--;
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG("Deleted %d entries\n", (tmp - curCnt));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NatApp::CacheEntry(const nat_table_entry *rule)
|
||||
{
|
||||
int cnt;
|
||||
|
||||
if(rule->private_ip == 0 ||
|
||||
rule->target_ip == 0 ||
|
||||
rule->private_port == 0 ||
|
||||
rule->target_port == 0 ||
|
||||
rule->protocol == 0)
|
||||
{
|
||||
IPACMERR("Invalid Connection, ignoring it\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!ChkForDup(rule))
|
||||
{
|
||||
for(cnt=0; cnt < max_entries; cnt++)
|
||||
{
|
||||
if(cache[cnt].private_ip == 0 &&
|
||||
cache[cnt].target_ip == 0 &&
|
||||
cache[cnt].private_port == 0 &&
|
||||
cache[cnt].target_port == 0 &&
|
||||
cache[cnt].protocol == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(max_entries == cnt)
|
||||
{
|
||||
IPACMERR("Error: Unable to add, reached maximum rules\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache[cnt].enabled = false;
|
||||
cache[cnt].rule_hdl = 0;
|
||||
cache[cnt].private_ip = rule->private_ip;
|
||||
cache[cnt].target_ip = rule->target_ip;
|
||||
cache[cnt].target_port = rule->target_port;
|
||||
cache[cnt].private_port = rule->private_port;
|
||||
cache[cnt].protocol = rule->protocol;
|
||||
cache[cnt].timestamp = 0;
|
||||
cache[cnt].public_port = rule->public_port;
|
||||
cache[cnt].public_ip = rule->public_ip;
|
||||
cache[cnt].dst_nat = rule->dst_nat;
|
||||
curCnt++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR("Duplicate rule. Ignore it\n");
|
||||
return;
|
||||
}
|
||||
|
||||
IPACMDBG("Cached rule(%d) successfully\n", cnt);
|
||||
return;
|
||||
}
|
||||
|
||||
void NatApp::Read_TcpUdp_Timeout(void) {
|
||||
FILE *udp_fd = NULL, *tcp_fd = NULL;
|
||||
|
||||
/* Read UDP timeout value */
|
||||
udp_fd = fopen(IPACM_UDP_FULL_FILE_NAME, "r");
|
||||
if (udp_fd == NULL) {
|
||||
IPACMERR("unable to open %s\n", IPACM_UDP_FULL_FILE_NAME);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (fscanf(udp_fd, "%d", &udp_timeout) != 1) {
|
||||
IPACMERR("Error reading udp timeout\n");
|
||||
}
|
||||
IPACMDBG_H("udp timeout value: %d\n", udp_timeout);
|
||||
|
||||
|
||||
/* Read TCP timeout value */
|
||||
tcp_fd = fopen(IPACM_TCP_FULL_FILE_NAME, "r");
|
||||
if (tcp_fd == NULL) {
|
||||
IPACMERR("unable to open %s\n", IPACM_TCP_FULL_FILE_NAME);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (fscanf(tcp_fd, "%d", &tcp_timeout) != 1) {
|
||||
IPACMERR("Error reading tcp timeout\n");
|
||||
}
|
||||
IPACMDBG_H("tcp timeout value: %d\n", tcp_timeout);
|
||||
|
||||
fail:
|
||||
if (udp_fd) {
|
||||
fclose(udp_fd);
|
||||
}
|
||||
if (tcp_fd) {
|
||||
fclose(tcp_fd);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
214
data-ipa-cfg-mgr/ipacm/src/IPACM_EvtDispatcher.cpp
Normal file
214
data-ipa-cfg-mgr/ipacm/src/IPACM_EvtDispatcher.cpp
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_EvtDispatcher.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPAM event dispatcher functionality
|
||||
|
||||
@Author
|
||||
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <IPACM_EvtDispatcher.h>
|
||||
#include <IPACM_Neighbor.h>
|
||||
#include "IPACM_CmdQueue.h"
|
||||
#include "IPACM_Defs.h"
|
||||
|
||||
|
||||
extern pthread_mutex_t mutex;
|
||||
extern pthread_cond_t cond_var;
|
||||
|
||||
cmd_evts *IPACM_EvtDispatcher::head = NULL;
|
||||
extern uint32_t ipacm_event_stats[IPACM_EVENT_MAX];
|
||||
|
||||
int IPACM_EvtDispatcher::PostEvt
|
||||
(
|
||||
ipacm_cmd_q_data *data
|
||||
)
|
||||
{
|
||||
Message *item = NULL;
|
||||
MessageQueue *MsgQueue = NULL;
|
||||
|
||||
if(data->event < IPA_EXTERNAL_EVENT_MAX)
|
||||
{
|
||||
IPACMDBG("Insert event into external queue.\n");
|
||||
MsgQueue = MessageQueue::getInstanceExternal();
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG("Insert event into internal queue.\n");
|
||||
MsgQueue = MessageQueue::getInstanceInternal();
|
||||
}
|
||||
if(MsgQueue == NULL)
|
||||
{
|
||||
IPACMERR("unable to retrieve MsgQueue instance\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
item = new Message();
|
||||
if(item == NULL)
|
||||
{
|
||||
IPACMERR("unable to create new message item\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
item->evt.callback_ptr = IPACM_EvtDispatcher::ProcessEvt;
|
||||
memcpy(&item->evt.data, data, sizeof(ipacm_cmd_q_data));
|
||||
|
||||
if(pthread_mutex_lock(&mutex) != 0)
|
||||
{
|
||||
IPACMERR("unable to lock the mutex\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
IPACMDBG("Enqueing item\n");
|
||||
MsgQueue->enqueue(item);
|
||||
IPACMDBG("Enqueued item %p\n", item);
|
||||
|
||||
if(pthread_cond_signal(&cond_var) != 0)
|
||||
{
|
||||
IPACMDBG("unable to lock the mutex\n");
|
||||
/* Release the mutex before you return failure */
|
||||
if(pthread_mutex_unlock(&mutex) != 0)
|
||||
{
|
||||
IPACMERR("unable to unlock the mutex\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
if(pthread_mutex_unlock(&mutex) != 0)
|
||||
{
|
||||
IPACMERR("unable to unlock the mutex\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
void IPACM_EvtDispatcher::ProcessEvt(ipacm_cmd_q_data *data)
|
||||
{
|
||||
|
||||
cmd_evts *tmp = head, tmp1;
|
||||
|
||||
if(head == NULL)
|
||||
{
|
||||
IPACMDBG("Queue is empty\n");
|
||||
}
|
||||
|
||||
while(tmp != NULL)
|
||||
{
|
||||
memcpy(&tmp1, tmp, sizeof(tmp1));
|
||||
if(data->event == tmp1.event)
|
||||
{
|
||||
ipacm_event_stats[data->event]++;
|
||||
tmp1.obj->event_callback(data->event, data->evt_data);
|
||||
IPACMDBG(" Find matched registered events\n");
|
||||
}
|
||||
tmp = tmp1.next;
|
||||
}
|
||||
|
||||
IPACMDBG(" Finished process events\n");
|
||||
|
||||
if(data->evt_data != NULL)
|
||||
{
|
||||
IPACMDBG("free the event:%d data: %p\n", data->event, data->evt_data);
|
||||
free(data->evt_data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int IPACM_EvtDispatcher::registr(ipa_cm_event_id event, IPACM_Listener *obj)
|
||||
{
|
||||
cmd_evts *tmp = head,*nw;
|
||||
|
||||
nw = (cmd_evts *)malloc(sizeof(cmd_evts));
|
||||
if(nw != NULL)
|
||||
{
|
||||
nw->event = event;
|
||||
nw->obj = obj;
|
||||
nw->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
if(head == NULL)
|
||||
{
|
||||
head = nw;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(tmp->next)
|
||||
{
|
||||
tmp = tmp->next;
|
||||
}
|
||||
tmp->next = nw;
|
||||
}
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int IPACM_EvtDispatcher::deregistr(IPACM_Listener *param)
|
||||
{
|
||||
cmd_evts *tmp = head,*tmp1,*prev = head;
|
||||
|
||||
while(tmp != NULL)
|
||||
{
|
||||
if(tmp->obj == param)
|
||||
{
|
||||
tmp1 = tmp;
|
||||
if(tmp == head)
|
||||
{
|
||||
head = head->next;
|
||||
}
|
||||
else if(tmp->next == NULL)
|
||||
{
|
||||
prev->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev->next = tmp->next;
|
||||
}
|
||||
|
||||
tmp = tmp->next;
|
||||
free(tmp1);
|
||||
}
|
||||
else
|
||||
{
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
536
data-ipa-cfg-mgr/ipacm/src/IPACM_Filtering.cpp
Normal file
536
data-ipa-cfg-mgr/ipacm/src/IPACM_Filtering.cpp
Normal file
@@ -0,0 +1,536 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Filtering.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPACM filtering functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "IPACM_Filtering.h"
|
||||
#include <IPACM_Log.h>
|
||||
#include "IPACM_Defs.h"
|
||||
|
||||
|
||||
const char *IPACM_Filtering::DEVICE_NAME = "/dev/ipa";
|
||||
|
||||
IPACM_Filtering::IPACM_Filtering()
|
||||
{
|
||||
fd = open(DEVICE_NAME, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
IPACMERR("Failed opening %s.\n", DEVICE_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
IPACM_Filtering::~IPACM_Filtering()
|
||||
{
|
||||
close(fd);
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::DeviceNodeIsOpened()
|
||||
{
|
||||
return fd;
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::AddFilteringRule(struct ipa_ioc_add_flt_rule const *ruleTable)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
IPACMDBG("Printing filter add attributes\n");
|
||||
IPACMDBG("ip type: %d\n", ruleTable->ip);
|
||||
IPACMDBG("Number of rules: %d\n", ruleTable->num_rules);
|
||||
IPACMDBG("End point: %d and global value: %d\n", ruleTable->ep, ruleTable->global);
|
||||
IPACMDBG("commit value: %d\n", ruleTable->commit);
|
||||
for (int cnt=0; cnt<ruleTable->num_rules; cnt++)
|
||||
{
|
||||
IPACMDBG("Filter rule:%d attrib mask: 0x%x\n", cnt,
|
||||
ruleTable->rules[cnt].rule.attrib.attrib_mask);
|
||||
}
|
||||
|
||||
retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE, ruleTable);
|
||||
if (retval != 0)
|
||||
{
|
||||
IPACMERR("Failed adding Filtering rule %p\n", ruleTable);
|
||||
PERROR("unable to add filter rule:");
|
||||
|
||||
for (int cnt = 0; cnt < ruleTable->num_rules; cnt++)
|
||||
{
|
||||
if (ruleTable->rules[cnt].status != 0)
|
||||
{
|
||||
IPACMERR("Adding Filter rule:%d failed with status:%d\n",
|
||||
cnt, ruleTable->rules[cnt].status);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int cnt = 0; cnt<ruleTable->num_rules; cnt++)
|
||||
{
|
||||
if(ruleTable->rules[cnt].status != 0)
|
||||
{
|
||||
IPACMERR("Adding Filter rule:%d failed with status:%d\n",
|
||||
cnt, ruleTable->rules[cnt].status);
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG("Added Filtering rule %p\n", ruleTable);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::AddFilteringRuleAfter(struct ipa_ioc_add_flt_rule_after const *ruleTable)
|
||||
{
|
||||
#ifdef FEATURE_IPA_V3
|
||||
int retval = 0;
|
||||
|
||||
IPACMDBG("Printing filter add attributes\n");
|
||||
IPACMDBG("ip type: %d\n", ruleTable->ip);
|
||||
IPACMDBG("Number of rules: %d\n", ruleTable->num_rules);
|
||||
IPACMDBG("End point: %d\n", ruleTable->ep);
|
||||
IPACMDBG("commit value: %d\n", ruleTable->commit);
|
||||
|
||||
retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE_AFTER, ruleTable);
|
||||
|
||||
for (int cnt = 0; cnt<ruleTable->num_rules; cnt++)
|
||||
{
|
||||
if(ruleTable->rules[cnt].status != 0)
|
||||
{
|
||||
IPACMERR("Adding Filter rule:%d failed with status:%d\n",
|
||||
cnt, ruleTable->rules[cnt].status);
|
||||
}
|
||||
}
|
||||
|
||||
if (retval != 0)
|
||||
{
|
||||
IPACMERR("Failed adding Filtering rule %p\n", ruleTable);
|
||||
return false;
|
||||
}
|
||||
IPACMDBG("Added Filtering rule %p\n", ruleTable);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::DeleteFilteringRule(struct ipa_ioc_del_flt_rule *ruleTable)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
retval = ioctl(fd, IPA_IOC_DEL_FLT_RULE, ruleTable);
|
||||
if (retval != 0)
|
||||
{
|
||||
IPACMERR("Failed deleting Filtering rule %p\n", ruleTable);
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG("Deleted Filtering rule %p\n", ruleTable);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::Commit(enum ipa_ip_type ip)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
retval = ioctl(fd, IPA_IOC_COMMIT_FLT, ip);
|
||||
if (retval != 0)
|
||||
{
|
||||
IPACMERR("failed committing Filtering rules.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG("Committed Filtering rules to IPA HW.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::Reset(enum ipa_ip_type ip)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
retval = ioctl(fd, IPA_IOC_RESET_FLT, ip);
|
||||
retval |= ioctl(fd, IPA_IOC_COMMIT_FLT, ip);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("failed resetting Filtering block.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG("Reset command issued to IPA Filtering block.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::DeleteFilteringHdls
|
||||
(
|
||||
uint32_t *flt_rule_hdls,
|
||||
ipa_ip_type ip,
|
||||
uint8_t num_rules
|
||||
)
|
||||
{
|
||||
struct ipa_ioc_del_flt_rule *flt_rule;
|
||||
bool res = true;
|
||||
int len = 0, cnt = 0;
|
||||
const uint8_t UNIT_RULES = 1;
|
||||
|
||||
len = (sizeof(struct ipa_ioc_del_flt_rule)) + (UNIT_RULES * sizeof(struct ipa_flt_rule_del));
|
||||
flt_rule = (struct ipa_ioc_del_flt_rule *)malloc(len);
|
||||
if (flt_rule == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for del filter rule\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < num_rules; cnt++)
|
||||
{
|
||||
memset(flt_rule, 0, len);
|
||||
flt_rule->commit = 1;
|
||||
flt_rule->num_hdls = UNIT_RULES;
|
||||
flt_rule->ip = ip;
|
||||
|
||||
if (flt_rule_hdls[cnt] == 0)
|
||||
{
|
||||
IPACMERR("invalid filter handle passed, ignoring it: %d\n", cnt)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
flt_rule->hdl[0].status = -1;
|
||||
flt_rule->hdl[0].hdl = flt_rule_hdls[cnt];
|
||||
IPACMDBG("Deleting filter hdl:(0x%x) with ip type: %d\n", flt_rule_hdls[cnt], ip);
|
||||
|
||||
if (DeleteFilteringRule(flt_rule) == false)
|
||||
{
|
||||
PERROR("Filter rule deletion failed!\n");
|
||||
res = false;
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (flt_rule->hdl[0].status != 0)
|
||||
{
|
||||
IPACMERR("Filter rule hdl 0x%x deletion failed with error:%d\n",
|
||||
flt_rule->hdl[0].hdl, flt_rule->hdl[0].status);
|
||||
res = false;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fail:
|
||||
free(flt_rule);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool 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)
|
||||
{
|
||||
int ret = 0, cnt, num_rules = 0, pos = 0;
|
||||
ipa_install_fltr_rule_req_msg_v01 qmi_rule_msg;
|
||||
#ifdef FEATURE_IPA_V3
|
||||
ipa_install_fltr_rule_req_ex_msg_v01 qmi_rule_ex_msg;
|
||||
#endif
|
||||
|
||||
int fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR);
|
||||
if(fd_wwan_ioctl < 0)
|
||||
{
|
||||
IPACMERR("Failed to open %s.\n",WWAN_QMI_IOCTL_DEVICE_NAME);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(rule_table_v4 != NULL)
|
||||
{
|
||||
num_rules += rule_table_v4->num_rules;
|
||||
IPACMDBG_H("Get %d WAN DL IPv4 filtering rules.\n", rule_table_v4->num_rules);
|
||||
}
|
||||
if(rule_table_v6 != NULL)
|
||||
{
|
||||
num_rules += rule_table_v6->num_rules;
|
||||
IPACMDBG_H("Get %d WAN DL IPv6 filtering rules.\n", rule_table_v6->num_rules);
|
||||
}
|
||||
|
||||
/* if it is not IPA v3, use old QMI format */
|
||||
#ifndef FEATURE_IPA_V3
|
||||
if(num_rules > QMI_IPA_MAX_FILTERS_V01)
|
||||
{
|
||||
IPACMERR("The number of filtering rules exceed limit.\n");
|
||||
close(fd_wwan_ioctl);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&qmi_rule_msg, 0, sizeof(qmi_rule_msg));
|
||||
|
||||
if (num_rules > 0)
|
||||
{
|
||||
qmi_rule_msg.filter_spec_list_valid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qmi_rule_msg.filter_spec_list_valid = false;
|
||||
}
|
||||
|
||||
qmi_rule_msg.filter_spec_list_len = num_rules;
|
||||
qmi_rule_msg.source_pipe_index_valid = 0;
|
||||
|
||||
IPACMDBG_H("Get %d WAN DL filtering rules in total.\n", num_rules);
|
||||
|
||||
if(rule_table_v4 != NULL)
|
||||
{
|
||||
for(cnt = rule_table_v4->num_rules - 1; cnt >= 0; cnt--)
|
||||
{
|
||||
if (pos < QMI_IPA_MAX_FILTERS_V01)
|
||||
{
|
||||
qmi_rule_msg.filter_spec_list[pos].filter_spec_identifier = pos;
|
||||
qmi_rule_msg.filter_spec_list[pos].ip_type = QMI_IPA_IP_TYPE_V4_V01;
|
||||
qmi_rule_msg.filter_spec_list[pos].filter_action = GetQmiFilterAction(rule_table_v4->rules[cnt].rule.action);
|
||||
qmi_rule_msg.filter_spec_list[pos].is_routing_table_index_valid = 1;
|
||||
qmi_rule_msg.filter_spec_list[pos].route_table_index = rule_table_v4->rules[cnt].rule.rt_tbl_idx;
|
||||
qmi_rule_msg.filter_spec_list[pos].is_mux_id_valid = 1;
|
||||
qmi_rule_msg.filter_spec_list[pos].mux_id = mux_id;
|
||||
memcpy(&qmi_rule_msg.filter_spec_list[pos].filter_rule,
|
||||
&rule_table_v4->rules[cnt].rule.eq_attrib,
|
||||
sizeof(struct ipa_filter_rule_type_v01));
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_V01, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rule_table_v6 != NULL)
|
||||
{
|
||||
for(cnt = rule_table_v6->num_rules - 1; cnt >= 0; cnt--)
|
||||
{
|
||||
if (pos < QMI_IPA_MAX_FILTERS_V01)
|
||||
{
|
||||
qmi_rule_msg.filter_spec_list[pos].filter_spec_identifier = pos;
|
||||
qmi_rule_msg.filter_spec_list[pos].ip_type = QMI_IPA_IP_TYPE_V6_V01;
|
||||
qmi_rule_msg.filter_spec_list[pos].filter_action = GetQmiFilterAction(rule_table_v6->rules[cnt].rule.action);
|
||||
qmi_rule_msg.filter_spec_list[pos].is_routing_table_index_valid = 1;
|
||||
qmi_rule_msg.filter_spec_list[pos].route_table_index = rule_table_v6->rules[cnt].rule.rt_tbl_idx;
|
||||
qmi_rule_msg.filter_spec_list[pos].is_mux_id_valid = 1;
|
||||
qmi_rule_msg.filter_spec_list[pos].mux_id = mux_id;
|
||||
memcpy(&qmi_rule_msg.filter_spec_list[pos].filter_rule,
|
||||
&rule_table_v6->rules[cnt].rule.eq_attrib,
|
||||
sizeof(struct ipa_filter_rule_type_v01));
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_V01, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE, &qmi_rule_msg);
|
||||
if (ret != 0)
|
||||
{
|
||||
IPACMERR("Failed adding Filtering rule %p with ret %d\n ", &qmi_rule_msg, ret);
|
||||
close(fd_wwan_ioctl);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* if it is IPA v3, use new QMI format */
|
||||
#else
|
||||
if(num_rules > QMI_IPA_MAX_FILTERS_EX_V01)
|
||||
{
|
||||
IPACMERR("The number of filtering rules exceed limit.\n");
|
||||
close(fd_wwan_ioctl);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&qmi_rule_ex_msg, 0, sizeof(qmi_rule_ex_msg));
|
||||
|
||||
if (num_rules > 0)
|
||||
{
|
||||
qmi_rule_ex_msg.filter_spec_ex_list_valid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qmi_rule_ex_msg.filter_spec_ex_list_valid = false;
|
||||
}
|
||||
qmi_rule_ex_msg.filter_spec_ex_list_len = num_rules;
|
||||
qmi_rule_ex_msg.source_pipe_index_valid = 0;
|
||||
|
||||
IPACMDBG_H("Get %d WAN DL filtering rules in total.\n", num_rules);
|
||||
|
||||
if(rule_table_v4 != NULL)
|
||||
{
|
||||
for(cnt = rule_table_v4->num_rules - 1; cnt >= 0; cnt--)
|
||||
{
|
||||
if (pos < QMI_IPA_MAX_FILTERS_EX_V01)
|
||||
{
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].ip_type = QMI_IPA_IP_TYPE_V4_V01;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_action = GetQmiFilterAction(rule_table_v4->rules[cnt].rule.action);
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].is_routing_table_index_valid = 1;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].route_table_index = rule_table_v4->rules[cnt].rule.rt_tbl_idx;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].is_mux_id_valid = 1;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].mux_id = mux_id;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].rule_id = rule_table_v4->rules[cnt].rule.rule_id;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].is_rule_hashable = rule_table_v4->rules[cnt].rule.hashable;
|
||||
memcpy(&qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_rule,
|
||||
&rule_table_v4->rules[cnt].rule.eq_attrib,
|
||||
sizeof(struct ipa_filter_rule_type_v01));
|
||||
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rule_table_v6 != NULL)
|
||||
{
|
||||
for(cnt = rule_table_v6->num_rules - 1; cnt >= 0; cnt--)
|
||||
{
|
||||
if (pos < QMI_IPA_MAX_FILTERS_EX_V01)
|
||||
{
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].ip_type = QMI_IPA_IP_TYPE_V6_V01;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_action = GetQmiFilterAction(rule_table_v6->rules[cnt].rule.action);
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].is_routing_table_index_valid = 1;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].route_table_index = rule_table_v6->rules[cnt].rule.rt_tbl_idx;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].is_mux_id_valid = 1;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].mux_id = mux_id;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].rule_id = rule_table_v6->rules[cnt].rule.rule_id;
|
||||
qmi_rule_ex_msg.filter_spec_ex_list[pos].is_rule_hashable = rule_table_v6->rules[cnt].rule.hashable;
|
||||
memcpy(&qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_rule,
|
||||
&rule_table_v6->rules[cnt].rule.eq_attrib,
|
||||
sizeof(struct ipa_filter_rule_type_v01));
|
||||
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_EX, &qmi_rule_ex_msg);
|
||||
if (ret != 0)
|
||||
{
|
||||
IPACMERR("Failed adding Filtering rule %p with ret %d\n ", &qmi_rule_ex_msg, ret);
|
||||
close(fd_wwan_ioctl);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
close(fd_wwan_ioctl);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::SendFilteringRuleIndex(struct ipa_fltr_installed_notif_req_msg_v01* table)
|
||||
{
|
||||
int ret = 0;
|
||||
int fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR);
|
||||
if(fd_wwan_ioctl < 0)
|
||||
{
|
||||
IPACMERR("Failed to open %s.\n",WWAN_QMI_IOCTL_DEVICE_NAME);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_INDEX, table);
|
||||
if (ret != 0)
|
||||
{
|
||||
IPACMERR("Failed adding filtering rule index %p with ret %d\n", table, ret);
|
||||
close(fd_wwan_ioctl);
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG("Added Filtering rule index %p\n", table);
|
||||
close(fd_wwan_ioctl);
|
||||
return true;
|
||||
}
|
||||
|
||||
ipa_filter_action_enum_v01 IPACM_Filtering::GetQmiFilterAction(ipa_flt_action action)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case IPA_PASS_TO_ROUTING:
|
||||
return QMI_IPA_FILTER_ACTION_ROUTING_V01;
|
||||
|
||||
case IPA_PASS_TO_SRC_NAT:
|
||||
return QMI_IPA_FILTER_ACTION_SRC_NAT_V01;
|
||||
|
||||
case IPA_PASS_TO_DST_NAT:
|
||||
return QMI_IPA_FILTER_ACTION_DST_NAT_V01;
|
||||
|
||||
case IPA_PASS_TO_EXCEPTION:
|
||||
return QMI_IPA_FILTER_ACTION_EXCEPTION_V01;
|
||||
|
||||
default:
|
||||
return IPA_FILTER_ACTION_ENUM_MAX_ENUM_VAL_V01;
|
||||
}
|
||||
}
|
||||
|
||||
bool IPACM_Filtering::ModifyFilteringRule(struct ipa_ioc_mdfy_flt_rule* ruleTable)
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
IPACMDBG("Printing filtering add attributes\n");
|
||||
IPACMDBG("IP type: %d Number of rules: %d commit value: %d\n", ruleTable->ip, ruleTable->num_rules, ruleTable->commit);
|
||||
|
||||
for (i=0; i<ruleTable->num_rules; i++)
|
||||
{
|
||||
IPACMDBG("Filter rule:%d attrib mask: 0x%x\n", i, ruleTable->rules[i].rule.attrib.attrib_mask);
|
||||
}
|
||||
|
||||
ret = ioctl(fd, IPA_IOC_MDFY_FLT_RULE, ruleTable);
|
||||
if (ret != 0)
|
||||
{
|
||||
IPACMERR("Failed modifying filtering rule %p\n", ruleTable);
|
||||
|
||||
for (i = 0; i < ruleTable->num_rules; i++)
|
||||
{
|
||||
if (ruleTable->rules[i].status != 0)
|
||||
{
|
||||
IPACMERR("Modifying filter rule %d failed\n", i);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG("Modified filtering rule %p\n", ruleTable);
|
||||
return true;
|
||||
}
|
||||
|
||||
236
data-ipa-cfg-mgr/ipacm/src/IPACM_Header.cpp
Normal file
236
data-ipa-cfg-mgr/ipacm/src/IPACM_Header.cpp
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "IPACM_Header.h"
|
||||
#include "IPACM_Log.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//All interaction through the driver are made through this inode.
|
||||
static const char *DEVICE_NAME = "/dev/ipa";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IPACM_Header::IPACM_Header()
|
||||
{
|
||||
m_fd = open(DEVICE_NAME, O_RDWR);
|
||||
if (-1 == m_fd)
|
||||
{
|
||||
IPACMERR("Failed to open %s in IPACM_Header test application constructor.\n", DEVICE_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IPACM_Header::~IPACM_Header()
|
||||
{
|
||||
if (-1 != m_fd)
|
||||
{
|
||||
close(m_fd);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool IPACM_Header::DeviceNodeIsOpened()
|
||||
{
|
||||
return (-1 != m_fd);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool IPACM_Header::AddHeader(struct ipa_ioc_add_hdr *pHeaderTableToAdd)
|
||||
{
|
||||
int nRetVal = 0;
|
||||
//call the Driver ioctl in order to add header
|
||||
nRetVal = ioctl(m_fd, IPA_IOC_ADD_HDR, pHeaderTableToAdd);
|
||||
IPACMDBG("return value: %d\n", nRetVal);
|
||||
return (-1 != nRetVal);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool IPACM_Header::DeleteHeader(struct ipa_ioc_del_hdr *pHeaderTableToDelete)
|
||||
{
|
||||
int nRetVal = 0;
|
||||
//call the Driver ioctl in order to remove header
|
||||
nRetVal = ioctl(m_fd, IPA_IOC_DEL_HDR, pHeaderTableToDelete);
|
||||
IPACMDBG("return value: %d\n", nRetVal);
|
||||
return (-1 != nRetVal);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool IPACM_Header::Commit()
|
||||
{
|
||||
int nRetVal = 0;
|
||||
nRetVal = ioctl(m_fd, IPA_IOC_COMMIT_HDR);
|
||||
IPACMDBG("return value: %d\n", nRetVal);
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool IPACM_Header::Reset()
|
||||
{
|
||||
int nRetVal = 0;
|
||||
|
||||
nRetVal = ioctl(m_fd, IPA_IOC_RESET_HDR);
|
||||
nRetVal |= ioctl(m_fd, IPA_IOC_COMMIT_HDR);
|
||||
IPACMDBG("return value: %d\n", nRetVal);
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool IPACM_Header::GetHeaderHandle(struct ipa_ioc_get_hdr *pHeaderStruct)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!DeviceNodeIsOpened()) return false;
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_GET_HDR, pHeaderStruct);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("IPA_IOC_GET_HDR ioctl failed, routingTable =0x%p, retval=0x%x.\n", pHeaderStruct, retval);
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG("IPA_IOC_GET_HDR ioctl issued to IPA header insertion block.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool IPACM_Header::CopyHeader(struct ipa_ioc_copy_hdr *pCopyHeaderStruct)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!DeviceNodeIsOpened()) return false;
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_COPY_HDR, pCopyHeaderStruct);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("IPA_IOC_COPY_HDR ioctl failed, retval=0x%x.\n", retval);
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG("IPA_IOC_COPY_HDR ioctl issued to IPA header insertion block.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Header::DeleteHeaderHdl(uint32_t hdr_hdl)
|
||||
{
|
||||
const uint8_t NUM_HDLS = 1;
|
||||
struct ipa_ioc_del_hdr *pHeaderDescriptor = NULL;
|
||||
struct ipa_hdr_del *hd_rule_entry;
|
||||
int len = 0;
|
||||
bool res = true;
|
||||
|
||||
if (hdr_hdl == 0)
|
||||
{
|
||||
IPACMERR("Invalid header handle passed. Ignoring it\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
len = (sizeof(struct ipa_ioc_del_hdr)) + (NUM_HDLS * sizeof(struct ipa_hdr_del));
|
||||
pHeaderDescriptor = (struct ipa_ioc_del_hdr *)malloc(len);
|
||||
if (pHeaderDescriptor == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory for del header\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(pHeaderDescriptor, 0, len);
|
||||
pHeaderDescriptor->commit = true;
|
||||
pHeaderDescriptor->num_hdls = NUM_HDLS;
|
||||
hd_rule_entry = &pHeaderDescriptor->hdl[0];
|
||||
|
||||
hd_rule_entry->hdl = hdr_hdl;
|
||||
hd_rule_entry->status = -1;
|
||||
|
||||
IPACMDBG("Deleting Header hdl:(%x)\n", hd_rule_entry->hdl);
|
||||
if ((false == DeleteHeader(pHeaderDescriptor)) ||
|
||||
(hd_rule_entry->status))
|
||||
{
|
||||
IPACMERR("Header hdl:(%x) deletion failed! status: %d\n", hd_rule_entry->hdl,hd_rule_entry->status);
|
||||
res = false;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
IPACMDBG_H("Deleted Header hdl:(%x) successfully\n", hd_rule_entry->hdl);
|
||||
|
||||
fail:
|
||||
free(pHeaderDescriptor);
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
bool IPACM_Header::AddHeaderProcCtx(struct ipa_ioc_add_hdr_proc_ctx* pHeader)
|
||||
{
|
||||
int ret = 0;
|
||||
//call the Driver ioctl to add header processing context
|
||||
ret = ioctl(m_fd, IPA_IOC_ADD_HDR_PROC_CTX, pHeader);
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
bool IPACM_Header::DeleteHeaderProcCtx(uint32_t hdl)
|
||||
{
|
||||
int len, ret;
|
||||
struct ipa_ioc_del_hdr_proc_ctx* pHeaderTable = NULL;
|
||||
|
||||
len = sizeof(struct ipa_ioc_del_hdr_proc_ctx) + sizeof(struct ipa_hdr_proc_ctx_del);
|
||||
pHeaderTable = (struct ipa_ioc_del_hdr_proc_ctx*)malloc(len);
|
||||
if(pHeaderTable == NULL)
|
||||
{
|
||||
IPACMERR("Failed to allocate buffer.\n");
|
||||
return false;
|
||||
}
|
||||
memset(pHeaderTable, 0, len);
|
||||
|
||||
pHeaderTable->commit = 1;
|
||||
pHeaderTable->num_hdls = 1;
|
||||
pHeaderTable->hdl[0].hdl = hdl;
|
||||
|
||||
ret = ioctl(m_fd, IPA_IOC_DEL_HDR_PROC_CTX, pHeaderTable);
|
||||
if(ret != 0)
|
||||
{
|
||||
IPACMERR("Failed to delete hdr proc ctx: return value %d, status %d\n",
|
||||
ret, pHeaderTable->hdl[0].status);
|
||||
}
|
||||
free(pHeaderTable);
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
995
data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp
Normal file
995
data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp
Normal file
@@ -0,0 +1,995 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.Z
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Iface.cpp
|
||||
|
||||
@brief
|
||||
This file implements the basis Iface functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <IPACM_Netlink.h>
|
||||
#include <IPACM_Iface.h>
|
||||
#include <IPACM_Lan.h>
|
||||
#include <IPACM_Wan.h>
|
||||
#include <IPACM_Wlan.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <ifaddrs.h>
|
||||
}
|
||||
|
||||
|
||||
const char *IPACM_Iface::DEVICE_NAME = "/dev/ipa";
|
||||
IPACM_Routing IPACM_Iface::m_routing;
|
||||
IPACM_Filtering IPACM_Iface::m_filtering;
|
||||
IPACM_Header IPACM_Iface::m_header;
|
||||
|
||||
IPACM_Config *IPACM_Iface::ipacmcfg = IPACM_Config::GetInstance();
|
||||
|
||||
IPACM_Iface::IPACM_Iface(int iface_index)
|
||||
{
|
||||
ip_type = IPACM_IP_NULL; /* initially set invalid */
|
||||
num_dft_rt_v6 = 0;
|
||||
softwarerouting_act = false;
|
||||
ipa_if_num = iface_index;
|
||||
ipa_if_cate = IPACM_Iface::ipacmcfg->iface_table[iface_index].if_cat;
|
||||
|
||||
iface_query = NULL;
|
||||
tx_prop = NULL;
|
||||
rx_prop = NULL;
|
||||
|
||||
memcpy(dev_name,
|
||||
IPACM_Iface::ipacmcfg->iface_table[iface_index].iface_name,
|
||||
sizeof(IPACM_Iface::ipacmcfg->iface_table[iface_index].iface_name));
|
||||
|
||||
memset(dft_v4fl_rule_hdl, 0, sizeof(dft_v4fl_rule_hdl));
|
||||
memset(dft_v6fl_rule_hdl, 0, sizeof(dft_v6fl_rule_hdl));
|
||||
|
||||
memset(dft_rt_rule_hdl, 0, sizeof(dft_rt_rule_hdl));
|
||||
memset(software_routing_fl_rule_hdl, 0, sizeof(software_routing_fl_rule_hdl));
|
||||
memset(ipv6_addr, 0, sizeof(ipv6_addr));
|
||||
|
||||
query_iface_property();
|
||||
IPACMDBG_H(" create iface-index(%d) constructor\n", ipa_if_num);
|
||||
return;
|
||||
}
|
||||
|
||||
/* software routing enable */
|
||||
int IPACM_Iface::handle_software_routing_enable(void)
|
||||
{
|
||||
|
||||
int res = IPACM_SUCCESS;
|
||||
struct ipa_flt_rule_add flt_rule_entry;
|
||||
ipa_ioc_add_flt_rule *m_pFilteringTable;
|
||||
|
||||
IPACMDBG("\n");
|
||||
if (softwarerouting_act == true)
|
||||
{
|
||||
IPACMDBG("already setup software_routing rule for (%s)iface ip-family %d\n",
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ip_type);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
if(rx_prop == NULL)
|
||||
{
|
||||
IPACMDBG("No rx properties registered for iface %s\n", dev_name);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
m_pFilteringTable = (struct ipa_ioc_add_flt_rule *)
|
||||
calloc(1,
|
||||
sizeof(struct ipa_ioc_add_flt_rule) +
|
||||
1 * sizeof(struct ipa_flt_rule_add)
|
||||
);
|
||||
if (!m_pFilteringTable)
|
||||
{
|
||||
IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
m_pFilteringTable->commit = 1;
|
||||
m_pFilteringTable->ep = rx_prop->rx[0].src_pipe;
|
||||
m_pFilteringTable->global = false;
|
||||
m_pFilteringTable->num_rules = (uint8_t)1;
|
||||
|
||||
|
||||
/* Configuring Software-Routing Filtering Rule */
|
||||
memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
flt_rule_entry.at_rear = false;
|
||||
flt_rule_entry.flt_rule_hdl = -1;
|
||||
flt_rule_entry.status = -1;
|
||||
flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
|
||||
#ifdef FEATURE_IPA_V3
|
||||
flt_rule_entry.rule.hashable = true;
|
||||
#endif
|
||||
memcpy(&flt_rule_entry.rule.attrib,
|
||||
&rx_prop->rx[0].attrib,
|
||||
sizeof(flt_rule_entry.rule.attrib));
|
||||
|
||||
memcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
/* check iface is v4 or v6 or both*/
|
||||
// if (ip_type == IPA_IP_MAX)
|
||||
// {
|
||||
/* handle v4 */
|
||||
m_pFilteringTable->ip = IPA_IP_v4;
|
||||
if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
|
||||
{
|
||||
IPACMERR("Error Adding Filtering rule, aborting...\n");
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
else if (m_pFilteringTable->rules[0].status)
|
||||
{
|
||||
IPACMERR("adding flt rule failed status=0x%x\n", m_pFilteringTable->rules[0].status);
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, 1);
|
||||
IPACMDBG("soft-routing flt rule hdl0=0x%x\n", m_pFilteringTable->rules[0].flt_rule_hdl);
|
||||
/* copy filter hdls */
|
||||
software_routing_fl_rule_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;
|
||||
|
||||
|
||||
/* handle v6*/
|
||||
m_pFilteringTable->ip = IPA_IP_v6;
|
||||
if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
|
||||
{
|
||||
IPACMERR("Error Adding Filtering rule, aborting...\n");
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
else if (m_pFilteringTable->rules[0].status)
|
||||
{
|
||||
IPACMDBG("adding flt rule failed status=0x%x\n", m_pFilteringTable->rules[0].status);
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
|
||||
IPACMDBG("soft-routing flt rule hdl0=0x%x\n", m_pFilteringTable->rules[0].flt_rule_hdl);
|
||||
/* copy filter hdls */
|
||||
software_routing_fl_rule_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;
|
||||
softwarerouting_act = true;
|
||||
#if 0
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ip_type == IPA_IP_v4)
|
||||
{
|
||||
m_pFilteringTable->ip = IPA_IP_v4;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFilteringTable->ip = IPA_IP_v6;
|
||||
}
|
||||
|
||||
if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
|
||||
{
|
||||
IPACMERR("Error Adding Filtering rule, aborting...\n");
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
else if (m_pFilteringTable->rules[0].status)
|
||||
{
|
||||
IPACMERR("adding flt rule failed status=0x%x\n", m_pFilteringTable->rules[0].status);
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, ip_type, 1);
|
||||
IPACMDBG("soft-routing flt rule hdl0=0x%x\n", m_pFilteringTable->rules[0].flt_rule_hdl);
|
||||
/* copy filter hdls */
|
||||
if (ip_type == IPA_IP_v4)
|
||||
{
|
||||
software_routing_fl_rule_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;
|
||||
}
|
||||
else
|
||||
{
|
||||
software_routing_fl_rule_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;
|
||||
}
|
||||
softwarerouting_act = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
fail:
|
||||
free(m_pFilteringTable);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/* software routing disable */
|
||||
int IPACM_Iface::handle_software_routing_disable(void)
|
||||
{
|
||||
int res = IPACM_SUCCESS;
|
||||
ipa_ip_type ip;
|
||||
uint32_t flt_hdl;
|
||||
|
||||
if (rx_prop == NULL)
|
||||
{
|
||||
IPACMDBG("No rx properties registered for iface %s\n", dev_name);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
if (softwarerouting_act == false)
|
||||
{
|
||||
IPACMDBG("already delete software_routing rule for (%s)iface ip-family %d\n", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ip_type);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
// if (ip_type == IPA_IP_MAX)
|
||||
// {
|
||||
/* ipv4 case */
|
||||
if (m_filtering.DeleteFilteringHdls(&software_routing_fl_rule_hdl[0],
|
||||
IPA_IP_v4, 1) == false)
|
||||
{
|
||||
IPACMERR("Error Adding Filtering rule, aborting...\n");
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, 1);
|
||||
|
||||
/* ipv6 case */
|
||||
if (m_filtering.DeleteFilteringHdls(&software_routing_fl_rule_hdl[1],
|
||||
IPA_IP_v6, 1) == false)
|
||||
{
|
||||
IPACMERR("Error Adding Filtering rule, aborting...\n");
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
|
||||
softwarerouting_act = false;
|
||||
#if 0
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ip_type == IPA_IP_v4)
|
||||
{
|
||||
ip = IPA_IP_v4;
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = IPA_IP_v6;
|
||||
}
|
||||
|
||||
|
||||
if (ip_type == IPA_IP_v4)
|
||||
{
|
||||
flt_hdl = software_routing_fl_rule_hdl[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
flt_hdl = software_routing_fl_rule_hdl[1];
|
||||
}
|
||||
|
||||
if (m_filtering.DeleteFilteringHdls(&flt_hdl, ip, 1) == false)
|
||||
{
|
||||
IPACMERR("Error Adding Filtering rule, aborting...\n");
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, ip, 1);
|
||||
softwarerouting_act = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
fail:
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Query ipa_interface_index by given linux interface_index */
|
||||
int IPACM_Iface::iface_ipa_index_query
|
||||
(
|
||||
int interface_index
|
||||
)
|
||||
{
|
||||
int fd;
|
||||
int link = INVALID_IFACE;
|
||||
int i = 0;
|
||||
struct ifreq ifr;
|
||||
|
||||
|
||||
if(IPACM_Iface::ipacmcfg->iface_table == NULL)
|
||||
{
|
||||
IPACMERR("Iface table in IPACM_Config is not available.\n");
|
||||
return link;
|
||||
}
|
||||
|
||||
/* Search known linux interface-index and map to IPA interface-index*/
|
||||
for (i = 0; i < IPACM_Iface::ipacmcfg->ipa_num_ipa_interfaces; i++)
|
||||
{
|
||||
if (interface_index == IPACM_Iface::ipacmcfg->iface_table[i].netlink_interface_index)
|
||||
{
|
||||
link = i;
|
||||
IPACMDBG("Interface (%s) found: linux(%d) ipa(%d) \n",
|
||||
IPACM_Iface::ipacmcfg->iface_table[i].iface_name,
|
||||
IPACM_Iface::ipacmcfg->iface_table[i].netlink_interface_index,
|
||||
link);
|
||||
return link;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Search/Configure linux interface-index and map it to IPA interface-index */
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
PERROR("get interface name socket create failed");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
|
||||
ifr.ifr_ifindex = interface_index;
|
||||
IPACMDBG_H("Interface index %d\n", interface_index);
|
||||
|
||||
if (ioctl(fd, SIOCGIFNAME, &ifr) < 0)
|
||||
{
|
||||
PERROR("call_ioctl_on_dev: ioctl failed:");
|
||||
close(fd);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
IPACMDBG_H("Received interface name %s\n", ifr.ifr_name);
|
||||
for (i = 0; i < IPACM_Iface::ipacmcfg->ipa_num_ipa_interfaces; i++)
|
||||
{
|
||||
if (strncmp(ifr.ifr_name,
|
||||
IPACM_Iface::ipacmcfg->iface_table[i].iface_name,
|
||||
sizeof(IPACM_Iface::ipacmcfg->iface_table[i].iface_name)) == 0)
|
||||
{
|
||||
IPACMDBG_H("Interface (%s) linux(%d) mapped to ipa(%d) \n", ifr.ifr_name,
|
||||
IPACM_Iface::ipacmcfg->iface_table[i].netlink_interface_index, i);
|
||||
|
||||
link = i;
|
||||
IPACM_Iface::ipacmcfg->iface_table[i].netlink_interface_index = interface_index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
/* Query ipa_interface ipv4_addr by given linux interface_index */
|
||||
void IPACM_Iface::iface_addr_query
|
||||
(
|
||||
int interface_index
|
||||
)
|
||||
{
|
||||
int fd;
|
||||
struct ifreq ifr;
|
||||
struct ifaddrs *myaddrs, *ifa;
|
||||
ipacm_cmd_q_data evt_data;
|
||||
ipacm_event_data_addr *data_addr;
|
||||
struct in_addr iface_ipv4;
|
||||
|
||||
/* use linux interface-index to find interface name */
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
PERROR("get interface name socket create failed");
|
||||
return ;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
|
||||
ifr.ifr_ifindex = interface_index;
|
||||
IPACMDBG_H("Interface index %d\n", interface_index);
|
||||
|
||||
if (ioctl(fd, SIOCGIFNAME, &ifr) < 0)
|
||||
{
|
||||
PERROR("call_ioctl_on_dev: ioctl failed:");
|
||||
close(fd);
|
||||
return ;
|
||||
}
|
||||
IPACMDBG_H("Interface index %d name: %s\n", interface_index,ifr.ifr_name);
|
||||
close(fd);
|
||||
|
||||
/* query ipv4/v6 address */
|
||||
if(getifaddrs(&myaddrs) != 0)
|
||||
{
|
||||
IPACMERR("getifaddrs");
|
||||
return ;
|
||||
}
|
||||
|
||||
for (ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next)
|
||||
{
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue;
|
||||
if (!(ifa->ifa_flags & IFF_UP))
|
||||
continue;
|
||||
|
||||
if(strcmp(ifr.ifr_name,ifa->ifa_name) == 0) // find current iface
|
||||
{
|
||||
IPACMDBG_H("Internal post new_addr event for iface %s\n", ifa->ifa_name);
|
||||
switch (ifa->ifa_addr->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in *s4 = (struct sockaddr_in *)ifa->ifa_addr;
|
||||
IPACMDBG_H("ipv4 address %s\n",inet_ntoa(s4->sin_addr));
|
||||
iface_ipv4 = s4->sin_addr;
|
||||
/* post new_addr event to command queue */
|
||||
data_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));
|
||||
if(data_addr == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event data_addr\n");
|
||||
freeifaddrs(myaddrs);
|
||||
return ;
|
||||
}
|
||||
data_addr->iptype = IPA_IP_v4;
|
||||
data_addr->if_index = interface_index;
|
||||
data_addr->ipv4_addr = iface_ipv4.s_addr;
|
||||
data_addr->ipv4_addr = ntohl(data_addr->ipv4_addr);
|
||||
IPACMDBG_H("Posting IPA_ADDR_ADD_EVENT with if index:%d, ipv4 addr:0x%x\n",
|
||||
data_addr->if_index,
|
||||
data_addr->ipv4_addr);
|
||||
|
||||
evt_data.event = IPA_ADDR_ADD_EVENT;
|
||||
evt_data.evt_data = data_addr;
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
break;
|
||||
}
|
||||
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *s6 = (struct sockaddr_in6 *)ifa->ifa_addr;
|
||||
/* post new_addr event to command queue */
|
||||
data_addr = (ipacm_event_data_addr *)malloc(sizeof(ipacm_event_data_addr));
|
||||
if(data_addr == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event data_addr\n");
|
||||
freeifaddrs(myaddrs);
|
||||
return ;
|
||||
}
|
||||
data_addr->iptype = IPA_IP_v6;
|
||||
data_addr->if_index = interface_index;
|
||||
memcpy(data_addr->ipv6_addr,
|
||||
&s6->sin6_addr,
|
||||
sizeof(data_addr->ipv6_addr));
|
||||
data_addr->ipv6_addr[0] = ntohl(data_addr->ipv6_addr[0]);
|
||||
data_addr->ipv6_addr[1] = ntohl(data_addr->ipv6_addr[1]);
|
||||
data_addr->ipv6_addr[2] = ntohl(data_addr->ipv6_addr[2]);
|
||||
data_addr->ipv6_addr[3] = ntohl(data_addr->ipv6_addr[3]);
|
||||
IPACMDBG_H("Posting IPA_ADDR_ADD_EVENT with if index:%d, ipv6 addr:0x%x:%x:%x:%x\n",
|
||||
data_addr->if_index,
|
||||
data_addr->ipv6_addr[0], data_addr->ipv6_addr[1], data_addr->ipv6_addr[2], data_addr->ipv6_addr[3]);
|
||||
|
||||
evt_data.event = IPA_ADDR_ADD_EVENT;
|
||||
evt_data.evt_data = data_addr;
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
freeifaddrs(myaddrs);
|
||||
return ;
|
||||
}
|
||||
|
||||
/*Query the IPA endpoint property */
|
||||
int IPACM_Iface::query_iface_property(void)
|
||||
{
|
||||
int res = IPACM_SUCCESS, fd = 0;
|
||||
uint32_t cnt=0;
|
||||
|
||||
fd = open(DEVICE_NAME, O_RDWR);
|
||||
IPACMDBG("iface query-property \n");
|
||||
if (0 == fd)
|
||||
{
|
||||
IPACMERR("Failed opening %s.\n", DEVICE_NAME);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
iface_query = (struct ipa_ioc_query_intf *)
|
||||
calloc(1, sizeof(struct ipa_ioc_query_intf));
|
||||
if(iface_query == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate iface_query memory.\n");
|
||||
close(fd);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
IPACMDBG_H("iface name %s\n", dev_name);
|
||||
memcpy(iface_query->name, dev_name, sizeof(dev_name));
|
||||
|
||||
if (ioctl(fd, IPA_IOC_QUERY_INTF, iface_query) < 0)
|
||||
{
|
||||
PERROR("ioctl IPA_IOC_QUERY_INTF failed\n");
|
||||
/* iface_query memory will free when iface-down*/
|
||||
res = IPACM_FAILURE;
|
||||
}
|
||||
|
||||
if(iface_query->num_tx_props > 0)
|
||||
{
|
||||
tx_prop = (struct ipa_ioc_query_intf_tx_props *)
|
||||
calloc(1, sizeof(struct ipa_ioc_query_intf_tx_props) +
|
||||
iface_query->num_tx_props * sizeof(struct ipa_ioc_tx_intf_prop));
|
||||
if(tx_prop == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate tx_prop memory.\n");
|
||||
close(fd);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
memcpy(tx_prop->name, dev_name, sizeof(tx_prop->name));
|
||||
tx_prop->num_tx_props = iface_query->num_tx_props;
|
||||
|
||||
if (ioctl(fd, IPA_IOC_QUERY_INTF_TX_PROPS, tx_prop) < 0)
|
||||
{
|
||||
PERROR("ioctl IPA_IOC_QUERY_INTF_TX_PROPS failed\n");
|
||||
/* tx_prop memory will free when iface-down*/
|
||||
res = IPACM_FAILURE;
|
||||
}
|
||||
|
||||
if (res != IPACM_FAILURE)
|
||||
{
|
||||
for (cnt = 0; cnt < tx_prop->num_tx_props; cnt++)
|
||||
{
|
||||
IPACMDBG_H("Tx(%d):attrib-mask:0x%x, ip-type: %d, dst_pipe: %d, alt_dst_pipe: %d, header: %s\n",
|
||||
cnt, tx_prop->tx[cnt].attrib.attrib_mask,
|
||||
tx_prop->tx[cnt].ip, tx_prop->tx[cnt].dst_pipe,
|
||||
tx_prop->tx[cnt].alt_dst_pipe,
|
||||
tx_prop->tx[cnt].hdr_name);
|
||||
|
||||
if (tx_prop->tx[cnt].dst_pipe == 0)
|
||||
{
|
||||
IPACMERR("Tx(%d): wrong tx property: dst_pipe: 0.\n", cnt);
|
||||
close(fd);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
if (tx_prop->tx[cnt].alt_dst_pipe == 0 &&
|
||||
((memcmp(dev_name, "wlan0", sizeof("wlan0")) == 0) ||
|
||||
(memcmp(dev_name, "wlan1", sizeof("wlan1")) == 0)))
|
||||
{
|
||||
IPACMERR("Tx(%d): wrong tx property: alt_dst_pipe: 0. \n", cnt);
|
||||
close(fd);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (iface_query->num_rx_props > 0)
|
||||
{
|
||||
rx_prop = (struct ipa_ioc_query_intf_rx_props *)
|
||||
calloc(1, sizeof(struct ipa_ioc_query_intf_rx_props) +
|
||||
iface_query->num_rx_props * sizeof(struct ipa_ioc_rx_intf_prop));
|
||||
if(rx_prop == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate rx_prop memory.\n");
|
||||
close(fd);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
memcpy(rx_prop->name, dev_name,
|
||||
sizeof(rx_prop->name));
|
||||
rx_prop->num_rx_props = iface_query->num_rx_props;
|
||||
|
||||
if (ioctl(fd, IPA_IOC_QUERY_INTF_RX_PROPS, rx_prop) < 0)
|
||||
{
|
||||
PERROR("ioctl IPA_IOC_QUERY_INTF_RX_PROPS failed\n");
|
||||
/* rx_prop memory will free when iface-down*/
|
||||
res = IPACM_FAILURE;
|
||||
}
|
||||
|
||||
if (res != IPACM_FAILURE)
|
||||
{
|
||||
for (cnt = 0; cnt < rx_prop->num_rx_props; cnt++)
|
||||
{
|
||||
IPACMDBG_H("Rx(%d):attrib-mask:0x%x, ip-type: %d, src_pipe: %d\n",
|
||||
cnt, rx_prop->rx[cnt].attrib.attrib_mask, rx_prop->rx[cnt].ip, rx_prop->rx[cnt].src_pipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Add Natting iface to IPACM_Config if there is Rx/Tx property */
|
||||
if (rx_prop != NULL || tx_prop != NULL)
|
||||
{
|
||||
IPACMDBG_H(" Has rx/tx properties registered for iface %s, add for NATTING \n", dev_name);
|
||||
IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*Configure the initial filter rules */
|
||||
int IPACM_Iface::init_fl_rule(ipa_ip_type iptype)
|
||||
{
|
||||
|
||||
int res = IPACM_SUCCESS, len = 0;
|
||||
struct ipa_flt_rule_add flt_rule_entry;
|
||||
ipa_ioc_add_flt_rule *m_pFilteringTable;
|
||||
|
||||
/* Adding this hack because WLAN may not registered for Rx-endpoint, other ifaces will always have*/
|
||||
const char *dev_wlan0="wlan0";
|
||||
const char *dev_wlan1="wlan1";
|
||||
const char *dev_ecm0="ecm0";
|
||||
|
||||
/* ADD corresponding ipa_rm_resource_name of RX-endpoint before adding all IPV4V6 FT-rules */
|
||||
if((IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat== WAN_IF) || (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat== EMBMS_IF))
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(rx_prop != NULL)
|
||||
{
|
||||
IPACMDBG_H("dev %s add producer dependency\n", dev_name);
|
||||
IPACMDBG_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]);
|
||||
IPACM_Iface::ipacmcfg->AddRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe],false);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* only wlan may take software-path, not register Rx-property*/
|
||||
if(strcmp(dev_name,dev_wlan0) == 0 || strcmp(dev_name,dev_wlan1) == 0)
|
||||
{
|
||||
IPACMDBG_H("dev %s add producer dependency\n", dev_name);
|
||||
IPACMDBG_H("depend Got piperm index : %d \n", IPA_RM_RESOURCE_HSIC_PROD);
|
||||
IPACM_Iface::ipacmcfg->AddRmDepend(IPA_RM_RESOURCE_HSIC_PROD,true);
|
||||
}
|
||||
if(strcmp(dev_name,dev_ecm0) == 0)
|
||||
{
|
||||
IPACMDBG_H("dev %s add producer dependency\n", dev_name);
|
||||
IPACMDBG_H("depend Got piperm index : %d \n", IPA_RM_RESOURCE_USB_PROD);
|
||||
IPACM_Iface::ipacmcfg->AddRmDepend(IPA_RM_RESOURCE_USB_PROD,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rx_prop == NULL)
|
||||
{
|
||||
IPACMDBG_H("No rx properties registered for iface %s\n", dev_name);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
/* construct ipa_ioc_add_flt_rule with default filter rules */
|
||||
if (iptype == IPA_IP_v4)
|
||||
{
|
||||
len = sizeof(struct ipa_ioc_add_flt_rule) +
|
||||
(IPV4_DEFAULT_FILTERTING_RULES * sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
m_pFilteringTable = (struct ipa_ioc_add_flt_rule *)calloc(1, len);
|
||||
if (!m_pFilteringTable)
|
||||
{
|
||||
IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
m_pFilteringTable->commit = 1;
|
||||
m_pFilteringTable->ep = rx_prop->rx[0].src_pipe;
|
||||
m_pFilteringTable->global = false;
|
||||
m_pFilteringTable->ip = iptype;
|
||||
m_pFilteringTable->num_rules = (uint8_t)IPV4_DEFAULT_FILTERTING_RULES;
|
||||
|
||||
/* Configuring Fragment Filtering Rule */
|
||||
memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
flt_rule_entry.rule.retain_hdr = 1;
|
||||
flt_rule_entry.at_rear = true;
|
||||
flt_rule_entry.flt_rule_hdl = -1;
|
||||
flt_rule_entry.status = -1;
|
||||
flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
|
||||
#ifdef FEATURE_IPA_V3
|
||||
flt_rule_entry.at_rear = false;
|
||||
flt_rule_entry.rule.hashable = false;
|
||||
#endif
|
||||
IPACMDBG_H("rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask);
|
||||
memcpy(&flt_rule_entry.rule.attrib,
|
||||
&rx_prop->rx[0].attrib,
|
||||
sizeof(flt_rule_entry.rule.attrib));
|
||||
|
||||
flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_FRAGMENT;
|
||||
memcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
/* Configuring Multicast Filtering Rule */
|
||||
memcpy(&flt_rule_entry.rule.attrib,
|
||||
&rx_prop->rx[0].attrib,
|
||||
sizeof(flt_rule_entry.rule.attrib));
|
||||
flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
|
||||
flt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0xF0000000;
|
||||
flt_rule_entry.rule.attrib.u.v4.dst_addr = 0xE0000000;
|
||||
#ifdef FEATURE_IPA_V3
|
||||
flt_rule_entry.at_rear = true;
|
||||
flt_rule_entry.rule.hashable = true;
|
||||
#endif
|
||||
memcpy(&(m_pFilteringTable->rules[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
/* Configuring Broadcast Filtering Rule */
|
||||
flt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
|
||||
flt_rule_entry.rule.attrib.u.v4.dst_addr = 0xFFFFFFFF;
|
||||
#ifdef FEATURE_IPA_V3
|
||||
flt_rule_entry.at_rear = true;
|
||||
flt_rule_entry.rule.hashable = true;
|
||||
#endif
|
||||
memcpy(&(m_pFilteringTable->rules[2]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
|
||||
{
|
||||
IPACMERR("Error Adding Filtering rule, aborting...\n");
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, IPV4_DEFAULT_FILTERTING_RULES);
|
||||
/* copy filter hdls */
|
||||
for (int i = 0; i < IPV4_DEFAULT_FILTERTING_RULES; i++)
|
||||
{
|
||||
if (m_pFilteringTable->rules[i].status == 0)
|
||||
{
|
||||
dft_v4fl_rule_hdl[i] = m_pFilteringTable->rules[i].flt_rule_hdl;
|
||||
IPACMDBG_H("Default v4 filter Rule %d HDL:0x%x\n", i, dft_v4fl_rule_hdl[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR("Failed adding default v4 Filtering rule %d\n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = sizeof(struct ipa_ioc_add_flt_rule) +
|
||||
(IPV6_DEFAULT_FILTERTING_RULES * sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
m_pFilteringTable = (struct ipa_ioc_add_flt_rule *)calloc(1, len);
|
||||
if (!m_pFilteringTable)
|
||||
{
|
||||
IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
m_pFilteringTable->commit = 1;
|
||||
m_pFilteringTable->ep = rx_prop->rx[0].src_pipe;
|
||||
m_pFilteringTable->global = false;
|
||||
m_pFilteringTable->ip = iptype;
|
||||
m_pFilteringTable->num_rules = (uint8_t)IPV6_DEFAULT_FILTERTING_RULES;
|
||||
|
||||
memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
flt_rule_entry.rule.retain_hdr = 1;
|
||||
flt_rule_entry.at_rear = true;
|
||||
flt_rule_entry.flt_rule_hdl = -1;
|
||||
flt_rule_entry.status = -1;
|
||||
flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
|
||||
/* Configuring Multicast Filtering Rule */
|
||||
memcpy(&flt_rule_entry.rule.attrib,
|
||||
&rx_prop->rx[0].attrib,
|
||||
sizeof(flt_rule_entry.rule.attrib));
|
||||
flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFF000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0XFF000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;
|
||||
#ifdef FEATURE_IPA_V3
|
||||
flt_rule_entry.at_rear = true;
|
||||
flt_rule_entry.rule.hashable = true;
|
||||
#endif
|
||||
memcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
/* Configuring fe80::/10 Link-Scoped Unicast Filtering Rule */
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0XFFC00000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0xFE800000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;
|
||||
#ifdef FEATURE_IPA_V3
|
||||
flt_rule_entry.at_rear = true;
|
||||
flt_rule_entry.rule.hashable = true;
|
||||
#endif
|
||||
memcpy(&(m_pFilteringTable->rules[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
/* Configuring fec0::/10 Reserved by IETF Filtering Rule */
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0XFFC00000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = 0xFEC00000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000;
|
||||
flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000;
|
||||
#ifdef FEATURE_IPA_V3
|
||||
flt_rule_entry.at_rear = true;
|
||||
flt_rule_entry.rule.hashable = true;
|
||||
#endif
|
||||
memcpy(&(m_pFilteringTable->rules[2]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
IPACMDBG_H("Add TCP ctrl rules: total num %d\n", IPV6_DEFAULT_FILTERTING_RULES);
|
||||
memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
flt_rule_entry.at_rear = true;
|
||||
flt_rule_entry.flt_rule_hdl = -1;
|
||||
flt_rule_entry.status = -1;
|
||||
|
||||
flt_rule_entry.rule.retain_hdr = 1;
|
||||
flt_rule_entry.rule.to_uc = 0;
|
||||
flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
|
||||
flt_rule_entry.rule.eq_attrib_type = 1;
|
||||
flt_rule_entry.rule.eq_attrib.rule_eq_bitmap = 0;
|
||||
|
||||
if(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA)
|
||||
{
|
||||
flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<14);
|
||||
flt_rule_entry.rule.eq_attrib.metadata_meq32_present = 1;
|
||||
flt_rule_entry.rule.eq_attrib.metadata_meq32.offset = 0;
|
||||
flt_rule_entry.rule.eq_attrib.metadata_meq32.value = rx_prop->rx[0].attrib.meta_data;
|
||||
flt_rule_entry.rule.eq_attrib.metadata_meq32.mask = rx_prop->rx[0].attrib.meta_data_mask;
|
||||
}
|
||||
|
||||
flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<1);
|
||||
flt_rule_entry.rule.eq_attrib.protocol_eq_present = 1;
|
||||
flt_rule_entry.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;
|
||||
|
||||
flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<8);
|
||||
flt_rule_entry.rule.eq_attrib.num_ihl_offset_meq_32 = 1;
|
||||
flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;
|
||||
|
||||
/* add TCP FIN rule*/
|
||||
flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);
|
||||
flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);
|
||||
memcpy(&(m_pFilteringTable->rules[3]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
/* add TCP SYN rule*/
|
||||
flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);
|
||||
flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);
|
||||
memcpy(&(m_pFilteringTable->rules[4]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
|
||||
/* add TCP RST rule*/
|
||||
flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);
|
||||
flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);
|
||||
memcpy(&(m_pFilteringTable->rules[5]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
|
||||
#endif
|
||||
if (m_filtering.AddFilteringRule(m_pFilteringTable) == false)
|
||||
{
|
||||
IPACMERR("Error Adding Filtering rule, aborting...\n");
|
||||
res = IPACM_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, IPV6_DEFAULT_FILTERTING_RULES);
|
||||
/* copy filter hdls */
|
||||
for (int i = 0;
|
||||
i < IPV6_DEFAULT_FILTERTING_RULES;
|
||||
i++)
|
||||
{
|
||||
if (m_pFilteringTable->rules[i].status == 0)
|
||||
{
|
||||
dft_v6fl_rule_hdl[i] = m_pFilteringTable->rules[i].flt_rule_hdl;
|
||||
IPACMDBG_H("Default v6 Filter Rule %d HDL:0x%x\n", i, dft_v6fl_rule_hdl[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR("Failing adding v6 default IPV6 rule %d\n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fail:
|
||||
free(m_pFilteringTable);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/* get ipa interface name */
|
||||
int IPACM_Iface::ipa_get_if_index
|
||||
(
|
||||
char * if_name,
|
||||
int * if_index
|
||||
)
|
||||
{
|
||||
int fd;
|
||||
struct ifreq ifr;
|
||||
|
||||
if((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
IPACMERR("get interface index socket create failed \n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));
|
||||
IPACMDBG_H("interface name (%s)\n", if_name);
|
||||
|
||||
if (ioctl(fd,SIOCGIFINDEX , &ifr) < 0)
|
||||
{
|
||||
IPACMERR("call_ioctl_on_dev: ioctl failed, interface name (%s):\n", ifr.ifr_name);
|
||||
close(fd);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
*if_index = ifr.ifr_ifindex;
|
||||
IPACMDBG_H("Interface index %d\n", *if_index);
|
||||
close(fd);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
void IPACM_Iface::config_ip_type(ipa_ip_type iptype)
|
||||
{
|
||||
/* update the iface ip-type to be IPA_IP_v4, IPA_IP_v6 or both*/
|
||||
if (iptype == IPA_IP_v4)
|
||||
{
|
||||
if ((ip_type == IPA_IP_v4) || (ip_type == IPA_IP_MAX))
|
||||
{
|
||||
IPACMDBG_H(" interface(%s:%d) already in ip-type %d\n", dev_name, ipa_if_num, ip_type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ip_type == IPA_IP_v6)
|
||||
{
|
||||
ip_type = IPA_IP_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
ip_type = IPA_IP_v4;
|
||||
}
|
||||
IPACMDBG_H(" interface(%s:%d) now ip-type is %d\n", dev_name, ipa_if_num, ip_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ip_type == IPA_IP_v6) || (ip_type == IPA_IP_MAX))
|
||||
{
|
||||
IPACMDBG_H(" interface(%s:%d) already in ip-type %d\n", dev_name, ipa_if_num, ip_type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ip_type == IPA_IP_v4)
|
||||
{
|
||||
ip_type = IPA_IP_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
ip_type = IPA_IP_v6;
|
||||
}
|
||||
|
||||
IPACMDBG_H(" interface(%s:%d) now ip-type is %d\n", dev_name, ipa_if_num, ip_type);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
565
data-ipa-cfg-mgr/ipacm/src/IPACM_IfaceManager.cpp
Normal file
565
data-ipa-cfg-mgr/ipacm/src/IPACM_IfaceManager.cpp
Normal file
@@ -0,0 +1,565 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_IfaceManager.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPAM iface_manager functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <IPACM_IfaceManager.h>
|
||||
#include <IPACM_EvtDispatcher.h>
|
||||
#include <IPACM_Defs.h>
|
||||
#include <IPACM_Wlan.h>
|
||||
#include <IPACM_Lan.h>
|
||||
#include <IPACM_Wan.h>
|
||||
#include <IPACM_Iface.h>
|
||||
#include <IPACM_Log.h>
|
||||
|
||||
iface_instances *IPACM_IfaceManager::head = NULL;
|
||||
|
||||
IPACM_IfaceManager::IPACM_IfaceManager()
|
||||
{
|
||||
IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, this); // register for IPA_CFG_CHANGE event
|
||||
IPACM_EvtDispatcher::registr(IPA_LINK_UP_EVENT, this);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_AP_LINK_UP_EVENT, this); // register for wlan AP-iface
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_STA_LINK_UP_EVENT, this); // register for wlan STA-iface
|
||||
#ifndef FEATURE_IPA_ANDROID
|
||||
/* only MDM targets support device on bridge mode */
|
||||
IPACM_EvtDispatcher::registr(IPA_BRIDGE_LINK_UP_EVENT, this); // register for IPA_BRIDGE_LINK_UP_EVENT event
|
||||
#endif /* not defined(FEATURE_IPA_ANDROID)*/
|
||||
IPACM_EvtDispatcher::registr(IPA_USB_LINK_UP_EVENT, this); // register for USB-iface
|
||||
IPACM_EvtDispatcher::registr(IPA_WAN_EMBMS_LINK_UP_EVENT, this); // register for wan eMBMS-iface
|
||||
return;
|
||||
}
|
||||
|
||||
void IPACM_IfaceManager::event_callback(ipa_cm_event_id event, void *param)
|
||||
{
|
||||
int ipa_interface_index;
|
||||
ipacm_event_data_fid *evt_data = (ipacm_event_data_fid *)param;
|
||||
ipacm_event_data_mac *StaData = (ipacm_event_data_mac *)param;
|
||||
ipacm_event_data_all *data_all = (ipacm_event_data_all *)param;
|
||||
ipacm_ifacemgr_data ifmgr_data = {0};
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case IPA_CFG_CHANGE_EVENT:
|
||||
IPACMDBG_H(" RESET IPACM_cfg \n");
|
||||
IPACM_Iface::ipacmcfg->Init();
|
||||
break;
|
||||
case IPA_BRIDGE_LINK_UP_EVENT:
|
||||
IPACMDBG_H(" Save the bridge0 mac info in IPACM_cfg \n");
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("IPA_BRIDGE_LINK_UP_EVENT: not supported iface id: %d\n", data_all->if_index);
|
||||
break;
|
||||
}
|
||||
/* check if iface is bridge interface*/
|
||||
if (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) == 0)
|
||||
{
|
||||
IPACM_Iface::ipacmcfg->ipa_bridge_enable = true;
|
||||
memcpy(IPACM_Iface::ipacmcfg->bridge_mac,
|
||||
data_all->mac_addr,
|
||||
sizeof(IPACM_Iface::ipacmcfg->bridge_mac));
|
||||
IPACMDBG_H("cached bridge0 MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
IPACM_Iface::ipacmcfg->bridge_mac[0], IPACM_Iface::ipacmcfg->bridge_mac[1], IPACM_Iface::ipacmcfg->bridge_mac[2],
|
||||
IPACM_Iface::ipacmcfg->bridge_mac[3], IPACM_Iface::ipacmcfg->bridge_mac[4], IPACM_Iface::ipacmcfg->bridge_mac[5]);
|
||||
}
|
||||
break;
|
||||
case IPA_LINK_UP_EVENT:
|
||||
IPACMDBG_H("Recieved IPA_LINK_UP_EVENT event: link up %d: \n", evt_data->if_index);
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("IPA_LINK_UP_EVENT: not supported iface id: %d\n", evt_data->if_index);
|
||||
break;
|
||||
}
|
||||
/* LTE-backhaul */
|
||||
if(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == EMBMS_IF)
|
||||
{
|
||||
IPACMDBG("WAN-EMBMS (%s) link already up, iface: %d: \n", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);
|
||||
}
|
||||
else if(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == WAN_IF)
|
||||
{
|
||||
IPACMDBG_H("WAN-LTE (%s) link up, iface: %d: \n", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);
|
||||
ifmgr_data.if_index = evt_data->if_index;
|
||||
ifmgr_data.if_type = Q6_WAN;
|
||||
create_iface_instance(&ifmgr_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case IPA_USB_LINK_UP_EVENT:
|
||||
IPACMDBG_H("Recieved IPA_USB_LINK_UP_EVENT event: link up %d: \n", evt_data->if_index);
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("IPA_USB_LINK_UP_EVENT: not supported iface id: %d\n", evt_data->if_index);
|
||||
break;
|
||||
}
|
||||
/* check if it's WAN_IF */
|
||||
if(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == WAN_IF)
|
||||
{
|
||||
/* usb-backhaul using sta_mode ECM_WAN*/
|
||||
IPACMDBG_H("WAN-usb (%s) link up, iface: %d: \n", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name, evt_data->if_index);
|
||||
ifmgr_data.if_index = evt_data->if_index;
|
||||
ifmgr_data.if_type = ECM_WAN;
|
||||
create_iface_instance(&ifmgr_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
ifmgr_data.if_index = evt_data->if_index;
|
||||
ifmgr_data.if_type = Q6_WAN;
|
||||
create_iface_instance(&ifmgr_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case IPA_WLAN_AP_LINK_UP_EVENT:
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("IPA_WLAN_AP_LINK_UP_EVENT: not supported iface id: %d\n", evt_data->if_index);
|
||||
break;
|
||||
}
|
||||
/* change iface category from unknown to WLAN_IF */
|
||||
if(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == UNKNOWN_IF)
|
||||
{
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat = WLAN_IF;
|
||||
IPACMDBG_H("WLAN AP (%s) link up, iface: %d: \n", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);
|
||||
ifmgr_data.if_index = evt_data->if_index;
|
||||
ifmgr_data.if_type = Q6_WAN;
|
||||
create_iface_instance(&ifmgr_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
break;
|
||||
|
||||
case IPA_WLAN_STA_LINK_UP_EVENT:
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(StaData->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("IPA_WLAN_STA_LINK_UP_EVENT: not supported iface id: %d\n", StaData->if_index);
|
||||
break;
|
||||
}
|
||||
/* change iface category from unknown to WAN_IF */
|
||||
if(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == UNKNOWN_IF)
|
||||
{
|
||||
/* wlan-backhaul using sta_mode WLAN_WAN */
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat = WAN_IF;
|
||||
IPACMDBG_H("WLAN STA (%s) link up, iface: %d: \n",
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name, StaData->if_index);
|
||||
|
||||
ifmgr_data.if_index = StaData->if_index;
|
||||
ifmgr_data.if_type = WLAN_WAN;
|
||||
memcpy(ifmgr_data.mac_addr, StaData->mac_addr, sizeof(ifmgr_data.mac_addr));
|
||||
create_iface_instance(&ifmgr_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_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);
|
||||
}
|
||||
break;
|
||||
|
||||
/* Add new instance open for eMBMS iface and wan iface */
|
||||
case IPA_WAN_EMBMS_LINK_UP_EVENT:
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("IPA_WAN_EMBMS_LINK_UP_EVENT: not supported iface id: %d\n", evt_data->if_index);
|
||||
break;
|
||||
}
|
||||
/* change iface category from unknown to EMBMS_IF */
|
||||
if ((IPACM_Iface::ipacmcfg->ipacm_odu_enable == true) && (IPACM_Iface::ipacmcfg->ipacm_odu_embms_enable == true))
|
||||
{
|
||||
IPACMDBG(" ODU-mode enable or not (%d) \n",IPACM_Iface::ipacmcfg->ipacm_odu_enable);
|
||||
if(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == WAN_IF)
|
||||
{
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat=EMBMS_IF;
|
||||
IPACMDBG("WAN eMBMS (%s) link up, iface: %d: \n", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);
|
||||
ifmgr_data.if_index = StaData->if_index;
|
||||
ifmgr_data.if_type = Q6_WAN;
|
||||
create_iface_instance(&ifmgr_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG("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);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int IPACM_IfaceManager::create_iface_instance(ipacm_ifacemgr_data *param)
|
||||
{
|
||||
int if_index = param->if_index;
|
||||
ipacm_wan_iface_type is_sta_mode = param->if_type;
|
||||
|
||||
int ipa_interface_index;
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(if_index);
|
||||
|
||||
if(ipa_interface_index == INVALID_IFACE)
|
||||
{
|
||||
IPACMDBG_H("Unhandled interface received, fid: %d\n",if_index);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
/* check if duplicate instance*/
|
||||
if(SearchInstance(ipa_interface_index) == IPA_INSTANCE_NOT_FOUND)
|
||||
{
|
||||
/* IPA_INSTANCE_NOT_FOUND */
|
||||
switch(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat)
|
||||
{
|
||||
|
||||
case LAN_IF:
|
||||
{
|
||||
IPACMDBG_H("Creating Lan interface\n");
|
||||
IPACM_Lan *lan = new IPACM_Lan(ipa_interface_index);
|
||||
IPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, lan);
|
||||
//IPACM_EvtDispatcher::registr(IPA_ROUTE_ADD_EVENT, lan);
|
||||
//IPACM_EvtDispatcher::registr(IPA_ROUTE_DEL_EVENT, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, lan);
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_TETHER, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6_TETHER, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_TETHER, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6_TETHER, lan);
|
||||
#else
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, lan);
|
||||
#endif
|
||||
IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, lan); // register for IPA_CFG_CHANGE event
|
||||
IPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, lan); // register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
IPACM_EvtDispatcher::registr(IPA_TETHERING_STATS_UPDATE_EVENT, lan);
|
||||
#endif
|
||||
IPACM_EvtDispatcher::registr(IPA_CRADLE_WAN_MODE_SWITCH, lan);
|
||||
IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, lan);
|
||||
/* IPA_LAN_DELETE_SELF should be always last */
|
||||
IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, lan);
|
||||
IPACMDBG_H("ipa_LAN (%s):ipa_index (%d) instance open/registr ok\n", lan->dev_name, lan->ipa_if_num);
|
||||
registr(ipa_interface_index, lan);
|
||||
/* solve the new_addr comes earlier issue */
|
||||
IPACM_Iface::iface_addr_query(if_index);
|
||||
}
|
||||
break;
|
||||
|
||||
case ETH_IF:
|
||||
{
|
||||
IPACMDBG_H("Creating ETH interface in router mode\n");
|
||||
IPACM_Lan *ETH = new IPACM_Lan(ipa_interface_index);
|
||||
IPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_CRADLE_WAN_MODE_SWITCH, ETH);
|
||||
IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, ETH);
|
||||
/* IPA_LAN_DELETE_SELF should be always last */
|
||||
IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, ETH);
|
||||
IPACMDBG_H("ipa_LAN (%s):ipa_index (%d) instance open/registr ok\n", ETH->dev_name, ETH->ipa_if_num);
|
||||
registr(ipa_interface_index, ETH);
|
||||
/* solve the new_addr comes earlier issue */
|
||||
IPACM_Iface::iface_addr_query(if_index);
|
||||
}
|
||||
break;
|
||||
|
||||
case ODU_IF:
|
||||
{
|
||||
if(IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == true)
|
||||
{
|
||||
IPACMDBG_H("Creating ODU interface in router mode\n");
|
||||
IPACM_Lan *odu = new IPACM_Lan(ipa_interface_index);
|
||||
IPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_CRADLE_WAN_MODE_SWITCH, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, odu);
|
||||
/* IPA_LAN_DELETE_SELF should be always last */
|
||||
IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, odu);
|
||||
IPACMDBG_H("ipa_LAN (%s):ipa_index (%d) instance open/registr ok\n", odu->dev_name, odu->ipa_if_num);
|
||||
registr(ipa_interface_index, odu);
|
||||
/* solve the new_addr comes earlier issue */
|
||||
IPACM_Iface::iface_addr_query(if_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_H("Creating ODU interface in bridge mode\n");
|
||||
IPACM_Lan *odu = new IPACM_Lan(ipa_interface_index);
|
||||
IPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, odu);
|
||||
IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, odu);
|
||||
/* IPA_LAN_DELETE_SELF should be always last */
|
||||
IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, odu);
|
||||
IPACMDBG_H("ipa_LAN (%s):ipa_index (%d) instance open/registr ok\n", odu->dev_name, odu->ipa_if_num);
|
||||
registr(ipa_interface_index, odu);
|
||||
/* solve the new_addr comes earlier issue */
|
||||
IPACM_Iface::iface_addr_query(if_index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WLAN_IF:
|
||||
{
|
||||
IPACMDBG_H("Creating WLan interface\n");
|
||||
IPACM_Wlan *wl = new IPACM_Wlan(ipa_interface_index);
|
||||
IPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_ROUTE_DEL_EVENT, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_ADD_EVENT, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_ADD_EVENT_EX, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_DEL_EVENT, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_POWER_SAVE_EVENT, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_RECOVER_EVENT, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, wl);
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_TETHER, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6_TETHER, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_TETHER, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6_TETHER, wl);
|
||||
#else
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, wl);
|
||||
#endif
|
||||
IPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, wl); // register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event
|
||||
#ifdef FEATURE_ETH_BRIDGE_LE
|
||||
IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, wl);
|
||||
#endif
|
||||
IPACM_EvtDispatcher::registr(IPA_CRADLE_WAN_MODE_SWITCH, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, wl);
|
||||
#ifndef FEATURE_IPA_ANDROID
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_SWITCH_TO_SCC, wl);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_SWITCH_TO_MCC, wl);
|
||||
#else
|
||||
IPACM_EvtDispatcher::registr(IPA_TETHERING_STATS_UPDATE_EVENT, wl);
|
||||
#endif
|
||||
/* IPA_LAN_DELETE_SELF should be always last */
|
||||
IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, wl);
|
||||
IPACMDBG_H("ipa_WLAN (%s):ipa_index (%d) instance open/registr ok\n", wl->dev_name, wl->ipa_if_num);
|
||||
registr(ipa_interface_index, wl);
|
||||
/* solve the new_addr comes earlier issue */
|
||||
IPACM_Iface::iface_addr_query(if_index);
|
||||
}
|
||||
break;
|
||||
|
||||
case WAN_IF:
|
||||
{
|
||||
if((IPACM_Iface::ipacmcfg->ipacm_odu_enable == false) || (IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == true))
|
||||
{
|
||||
IPACMDBG_H("Creating Wan interface\n");
|
||||
IPACM_Wan *w;
|
||||
if(is_sta_mode == WLAN_WAN)
|
||||
{
|
||||
w = new IPACM_Wan(ipa_interface_index, is_sta_mode, param->mac_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
w = new IPACM_Wan(ipa_interface_index, is_sta_mode, NULL);
|
||||
}
|
||||
IPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, w);
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
IPACM_EvtDispatcher::registr(IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT, w);
|
||||
IPACM_EvtDispatcher::registr(IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, w);
|
||||
if(is_sta_mode == Q6_WAN)
|
||||
{
|
||||
IPACM_EvtDispatcher::registr(IPA_NETWORK_STATS_UPDATE_EVENT, w);
|
||||
};
|
||||
#else/* defined(FEATURE_IPA_ANDROID) */
|
||||
IPACM_EvtDispatcher::registr(IPA_ROUTE_ADD_EVENT, w);
|
||||
IPACM_EvtDispatcher::registr(IPA_ROUTE_DEL_EVENT, w);
|
||||
#endif /* not defined(FEATURE_IPA_ANDROID)*/
|
||||
IPACM_EvtDispatcher::registr(IPA_FIREWALL_CHANGE_EVENT, w);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, w);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, w);
|
||||
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, w);
|
||||
IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, w); // register for IPA_CFG_CHANGE event
|
||||
IPACM_EvtDispatcher::registr(IPA_WAN_XLAT_CONNECT_EVENT, w);
|
||||
if(is_sta_mode == WLAN_WAN)
|
||||
{
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, w); // for STA mode
|
||||
#ifndef FEATURE_IPA_ANDROID
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_SWITCH_TO_SCC, w);
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_SWITCH_TO_MCC, w);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, w);
|
||||
}
|
||||
|
||||
IPACMDBG_H("ipa_WAN (%s):ipa_index (%d) instance open/registr ok\n", w->dev_name, w->ipa_if_num);
|
||||
registr(ipa_interface_index, w);
|
||||
/* solve the new_addr comes earlier issue */
|
||||
IPACM_Iface::iface_addr_query(if_index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* WAN-eMBMS instance */
|
||||
case EMBMS_IF:
|
||||
{
|
||||
IPACMDBG("Creating Wan-eMBSM interface\n");
|
||||
IPACM_Wan *embms = new IPACM_Wan(ipa_interface_index, is_sta_mode, NULL);
|
||||
IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, embms);
|
||||
IPACMDBG("ipa_WAN (%s):ipa_index (%d) instance open/registr ok\n", embms->dev_name, embms->ipa_if_num);
|
||||
registr(ipa_interface_index, embms);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
IPACMDBG_H("Unhandled interface category received iface name: %s, category: %d\n",
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
}
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int IPACM_IfaceManager::registr(int ipa_if_index, IPACM_Listener *obj)
|
||||
{
|
||||
iface_instances *tmp = head,*nw;
|
||||
|
||||
nw = (iface_instances *)malloc(sizeof(iface_instances));
|
||||
if(nw != NULL)
|
||||
{
|
||||
nw->ipa_if_index = ipa_if_index;
|
||||
nw->obj = obj;
|
||||
nw->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
if(head == NULL)
|
||||
{
|
||||
head = nw;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(tmp->next)
|
||||
{
|
||||
tmp = tmp->next;
|
||||
}
|
||||
tmp->next = nw;
|
||||
}
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
int IPACM_IfaceManager::deregistr(IPACM_Listener *param)
|
||||
{
|
||||
iface_instances *tmp = head,*tmp1,*prev = head;
|
||||
|
||||
while(tmp != NULL)
|
||||
{
|
||||
if(tmp->obj == param)
|
||||
{
|
||||
tmp1 = tmp;
|
||||
if(tmp == head)
|
||||
{
|
||||
head = head->next;
|
||||
}
|
||||
else if(tmp->next == NULL)
|
||||
{
|
||||
prev->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev->next = tmp->next;
|
||||
}
|
||||
|
||||
tmp = tmp->next;
|
||||
free(tmp1);
|
||||
}
|
||||
else
|
||||
{
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int IPACM_IfaceManager::SearchInstance(int ipa_if_index)
|
||||
{
|
||||
|
||||
iface_instances *tmp = head;
|
||||
|
||||
while(tmp != NULL)
|
||||
{
|
||||
if(ipa_if_index == tmp->ipa_if_index)
|
||||
{
|
||||
IPACMDBG_H("Find existed iface-instance name: %s\n",
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_if_index].iface_name);
|
||||
return IPA_INSTANCE_FOUND;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
IPACMDBG_H("No existed iface-instance name: %s,\n",
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_if_index].iface_name);
|
||||
|
||||
return IPA_INSTANCE_NOT_FOUND;
|
||||
}
|
||||
4229
data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp
Normal file
4229
data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1262
data-ipa-cfg-mgr/ipacm/src/IPACM_LanToLan.cpp
Normal file
1262
data-ipa-cfg-mgr/ipacm/src/IPACM_LanToLan.cpp
Normal file
File diff suppressed because it is too large
Load Diff
107
data-ipa-cfg-mgr/ipacm/src/IPACM_Log.cpp
Normal file
107
data-ipa-cfg-mgr/ipacm/src/IPACM_Log.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_log.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPAM log functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#include "IPACM_Log.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <asm/types.h>
|
||||
#include <linux/if.h>
|
||||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
#include <IPACM_Defs.h>
|
||||
|
||||
void logmessage(int log_level)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* start IPACMDIAG socket*/
|
||||
int create_socket(unsigned int *sockfd)
|
||||
{
|
||||
|
||||
if ((*sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == IPACM_FAILURE)
|
||||
{
|
||||
perror("Error creating ipacm_log socket\n");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
if(fcntl(*sockfd, F_SETFD, FD_CLOEXEC) < 0)
|
||||
{
|
||||
perror("Couldn't set ipacm_log Close on Exec\n");
|
||||
}
|
||||
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
void ipacm_log_send( void * user_data)
|
||||
{
|
||||
ipacm_log_buffer_t ipacm_log_buffer;
|
||||
int numBytes=0, len;
|
||||
struct sockaddr_un ipacmlog_socket;
|
||||
static unsigned int ipacm_log_sockfd = 0;
|
||||
|
||||
if(ipacm_log_sockfd == 0)
|
||||
{
|
||||
/* start ipacm_log socket */
|
||||
if(create_socket(&ipacm_log_sockfd) < 0)
|
||||
{
|
||||
printf("unable to create ipacm_log socket\n");
|
||||
return;
|
||||
}
|
||||
printf("create ipacm_log socket successfully\n");
|
||||
}
|
||||
ipacmlog_socket.sun_family = AF_UNIX;
|
||||
strcpy(ipacmlog_socket.sun_path, IPACMLOG_FILE);
|
||||
len = strlen(ipacmlog_socket.sun_path) + sizeof(ipacmlog_socket.sun_family);
|
||||
|
||||
memcpy(ipacm_log_buffer.user_data, user_data, MAX_BUF_LEN);
|
||||
|
||||
//printf("send : %s\n", ipacm_log_buffer.user_data);
|
||||
if ((numBytes = sendto(ipacm_log_sockfd, (void *)&ipacm_log_buffer, sizeof(ipacm_log_buffer.user_data), 0,
|
||||
(struct sockaddr *)&ipacmlog_socket, len)) == -1)
|
||||
{
|
||||
printf("Send Failed(%d) %s \n",errno,strerror(errno));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
939
data-ipa-cfg-mgr/ipacm/src/IPACM_Main.cpp
Normal file
939
data-ipa-cfg-mgr/ipacm/src/IPACM_Main.cpp
Normal file
@@ -0,0 +1,939 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Main.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPAM functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
/******************************************************************************
|
||||
|
||||
IPCM_MAIN.C
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include "linux/ipa_qmi_service_v01.h"
|
||||
|
||||
#include "IPACM_CmdQueue.h"
|
||||
#include "IPACM_EvtDispatcher.h"
|
||||
#include "IPACM_Defs.h"
|
||||
#include "IPACM_Neighbor.h"
|
||||
#include "IPACM_IfaceManager.h"
|
||||
#include "IPACM_Log.h"
|
||||
|
||||
#include "IPACM_ConntrackListener.h"
|
||||
#include "IPACM_ConntrackClient.h"
|
||||
#include "IPACM_Netlink.h"
|
||||
|
||||
/* not defined(FEATURE_IPA_ANDROID)*/
|
||||
#ifndef FEATURE_IPA_ANDROID
|
||||
#include "IPACM_LanToLan.h"
|
||||
#endif
|
||||
|
||||
#define IPA_DRIVER "/dev/ipa"
|
||||
|
||||
#define IPACM_FIREWALL_FILE_NAME "mobileap_firewall.xml"
|
||||
#define IPACM_CFG_FILE_NAME "IPACM_cfg.xml"
|
||||
#ifdef FEATURE_IPA_ANDROID
|
||||
#define IPACM_PID_FILE "/data/misc/ipa/ipacm.pid"
|
||||
#define IPACM_DIR_NAME "/data"
|
||||
#else/* defined(FEATURE_IPA_ANDROID) */
|
||||
#define IPACM_PID_FILE "/etc/ipacm.pid"
|
||||
#define IPACM_DIR_NAME "/etc"
|
||||
#endif /* defined(NOT FEATURE_IPA_ANDROID)*/
|
||||
#define IPACM_NAME "ipacm"
|
||||
|
||||
#define INOTIFY_EVENT_SIZE (sizeof(struct inotify_event))
|
||||
#define INOTIFY_BUF_LEN (INOTIFY_EVENT_SIZE + 2*sizeof(IPACM_FIREWALL_FILE_NAME))
|
||||
|
||||
#define IPA_DRIVER_WLAN_EVENT_MAX_OF_ATTRIBS 3
|
||||
#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))
|
||||
#define IPA_DRIVER_PIPE_STATS_EVENT_SIZE (sizeof(struct ipa_get_data_stats_resp_msg_v01))
|
||||
#define IPA_DRIVER_WLAN_META_MSG (sizeof(struct ipa_msg_meta))
|
||||
#define IPA_DRIVER_WLAN_BUF_LEN (IPA_DRIVER_PIPE_STATS_EVENT_SIZE + IPA_DRIVER_WLAN_META_MSG)
|
||||
|
||||
uint32_t ipacm_event_stats[IPACM_EVENT_MAX];
|
||||
bool ipacm_logging = true;
|
||||
|
||||
void ipa_is_ipacm_running(void);
|
||||
int ipa_get_if_index(char *if_name, int *if_index);
|
||||
|
||||
/* start netlink socket monitor*/
|
||||
void* netlink_start(void *param)
|
||||
{
|
||||
ipa_nl_sk_fd_set_info_t sk_fdset;
|
||||
int ret_val = 0;
|
||||
memset(&sk_fdset, 0, sizeof(ipa_nl_sk_fd_set_info_t));
|
||||
IPACMDBG_H("netlink starter memset sk_fdset succeeds\n");
|
||||
ret_val = ipa_nl_listener_init(NETLINK_ROUTE, (RTMGRP_IPV4_ROUTE | RTMGRP_IPV6_ROUTE | RTMGRP_LINK |
|
||||
RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR | RTMGRP_NEIGH |
|
||||
RTNLGRP_IPV6_PREFIX),
|
||||
&sk_fdset, ipa_nl_recv_msg);
|
||||
|
||||
if (ret_val != IPACM_SUCCESS)
|
||||
{
|
||||
IPACMERR("Failed to initialize IPA netlink event listener\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* start firewall-rule monitor*/
|
||||
void* firewall_monitor(void *param)
|
||||
{
|
||||
int length;
|
||||
int wd;
|
||||
char buffer[INOTIFY_BUF_LEN];
|
||||
int inotify_fd;
|
||||
ipacm_cmd_q_data evt_data;
|
||||
uint32_t mask = IN_MODIFY | IN_MOVE;
|
||||
|
||||
inotify_fd = inotify_init();
|
||||
if (inotify_fd < 0)
|
||||
{
|
||||
PERROR("inotify_init");
|
||||
}
|
||||
|
||||
IPACMDBG_H("Waiting for nofications in dir %s with mask: 0x%x\n", IPACM_DIR_NAME, mask);
|
||||
|
||||
wd = inotify_add_watch(inotify_fd,
|
||||
IPACM_DIR_NAME,
|
||||
mask);
|
||||
|
||||
while (1)
|
||||
{
|
||||
length = read(inotify_fd, buffer, INOTIFY_BUF_LEN);
|
||||
if (length < 0)
|
||||
{
|
||||
IPACMERR("inotify read() error return length: %d and mask: 0x%x\n", length, mask);
|
||||
continue;
|
||||
}
|
||||
|
||||
struct inotify_event* event;
|
||||
event = (struct inotify_event*)malloc(length);
|
||||
if(event == NULL)
|
||||
{
|
||||
IPACMERR("Failed to allocate memory.\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(event, 0, length);
|
||||
memcpy(event, buffer, length);
|
||||
|
||||
if (event->len > 0)
|
||||
{
|
||||
if ( (event->mask & IN_MODIFY) || (event->mask & IN_MOVE))
|
||||
{
|
||||
if (event->mask & IN_ISDIR)
|
||||
{
|
||||
IPACMDBG_H("The directory %s was 0x%x\n", event->name, event->mask);
|
||||
}
|
||||
else if (!strncmp(event->name, IPACM_FIREWALL_FILE_NAME, event->len)) // firewall_rule change
|
||||
{
|
||||
IPACMDBG_H("File \"%s\" was 0x%x\n", event->name, event->mask);
|
||||
IPACMDBG_H("The interested file %s .\n", IPACM_FIREWALL_FILE_NAME);
|
||||
|
||||
evt_data.event = IPA_FIREWALL_CHANGE_EVENT;
|
||||
evt_data.evt_data = NULL;
|
||||
|
||||
/* Insert IPA_FIREWALL_CHANGE_EVENT to command queue */
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
}
|
||||
else if (!strncmp(event->name, IPACM_CFG_FILE_NAME, event->len)) // IPACM_configuration change
|
||||
{
|
||||
IPACMDBG_H("File \"%s\" was 0x%x\n", event->name, event->mask);
|
||||
IPACMDBG_H("The interested file %s .\n", IPACM_CFG_FILE_NAME);
|
||||
|
||||
evt_data.event = IPA_CFG_CHANGE_EVENT;
|
||||
evt_data.evt_data = NULL;
|
||||
|
||||
/* Insert IPA_FIREWALL_CHANGE_EVENT to command queue */
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
}
|
||||
}
|
||||
IPACMDBG_H("Received monitoring event %s.\n", event->name);
|
||||
}
|
||||
free(event);
|
||||
}
|
||||
|
||||
(void)inotify_rm_watch(inotify_fd, wd);
|
||||
(void)close(inotify_fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* start IPACM wan-driver notifier */
|
||||
void* ipa_driver_msg_notifier(void *param)
|
||||
{
|
||||
int length, fd, cnt;
|
||||
char buffer[IPA_DRIVER_WLAN_BUF_LEN];
|
||||
struct ipa_msg_meta event_hdr;
|
||||
struct ipa_ecm_msg event_ecm;
|
||||
struct ipa_wan_msg event_wan;
|
||||
struct ipa_wlan_msg_ex event_ex_o;
|
||||
struct ipa_wlan_msg *event_wlan=NULL;
|
||||
struct ipa_wlan_msg_ex *event_ex= NULL;
|
||||
struct ipa_get_data_stats_resp_msg_v01 event_data_stats;
|
||||
struct ipa_get_apn_data_stats_resp_msg_v01 event_network_stats;
|
||||
|
||||
ipacm_cmd_q_data evt_data;
|
||||
ipacm_event_data_mac *data = NULL;
|
||||
ipacm_event_data_fid *data_fid = NULL;
|
||||
ipacm_event_data_iptype *data_iptype = NULL;
|
||||
ipacm_event_data_wlan_ex *data_ex;
|
||||
ipa_get_data_stats_resp_msg_v01 *data_tethering_stats = NULL;
|
||||
ipa_get_apn_data_stats_resp_msg_v01 *data_network_stats = NULL;
|
||||
|
||||
ipacm_cmd_q_data new_neigh_evt;
|
||||
ipacm_event_data_all* new_neigh_data;
|
||||
|
||||
fd = open(IPA_DRIVER, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
IPACMERR("Failed opening %s.\n", IPA_DRIVER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
IPACMDBG_H("Waiting for nofications from IPA driver \n");
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
memset(&evt_data, 0, sizeof(evt_data));
|
||||
memset(&new_neigh_evt, 0, sizeof(ipacm_cmd_q_data));
|
||||
new_neigh_data = NULL;
|
||||
data = NULL;
|
||||
data_fid = NULL;
|
||||
data_tethering_stats = NULL;
|
||||
data_network_stats = NULL;
|
||||
|
||||
length = read(fd, buffer, IPA_DRIVER_WLAN_BUF_LEN);
|
||||
if (length < 0)
|
||||
{
|
||||
PERROR("didn't read IPA_driver correctly");
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(&event_hdr, buffer,sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Message type: %d\n", event_hdr.msg_type);
|
||||
IPACMDBG_H("Event header length received: %d\n",event_hdr.msg_len);
|
||||
|
||||
/* Insert WLAN_DRIVER_EVENT to command queue */
|
||||
switch (event_hdr.msg_type)
|
||||
{
|
||||
|
||||
case SW_ROUTING_ENABLE:
|
||||
IPACMDBG_H("Received SW_ROUTING_ENABLE\n");
|
||||
evt_data.event = IPA_SW_ROUTING_ENABLE;
|
||||
IPACMDBG_H("Not supported anymore\n");
|
||||
continue;
|
||||
|
||||
case SW_ROUTING_DISABLE:
|
||||
IPACMDBG_H("Received SW_ROUTING_DISABLE\n");
|
||||
evt_data.event = IPA_SW_ROUTING_DISABLE;
|
||||
IPACMDBG_H("Not supported anymore\n");
|
||||
continue;
|
||||
|
||||
case WLAN_AP_CONNECT:
|
||||
event_wlan = (struct ipa_wlan_msg *) (buffer + sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Received WLAN_AP_CONNECT name: %s\n",event_wlan->name);
|
||||
IPACMDBG_H("AP Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],
|
||||
event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);
|
||||
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_wlan data_fid\n");
|
||||
return NULL;
|
||||
}
|
||||
ipa_get_if_index(event_wlan->name, &(data_fid->if_index));
|
||||
evt_data.event = IPA_WLAN_AP_LINK_UP_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
break;
|
||||
|
||||
case WLAN_AP_DISCONNECT:
|
||||
event_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Received WLAN_AP_DISCONNECT name: %s\n",event_wlan->name);
|
||||
IPACMDBG_H("AP Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],
|
||||
event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);
|
||||
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_wlan data_fid\n");
|
||||
return NULL;
|
||||
}
|
||||
ipa_get_if_index(event_wlan->name, &(data_fid->if_index));
|
||||
evt_data.event = IPA_WLAN_LINK_DOWN_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
break;
|
||||
case WLAN_STA_CONNECT:
|
||||
event_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Received WLAN_STA_CONNECT name: %s\n",event_wlan->name);
|
||||
IPACMDBG_H("STA Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],
|
||||
event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);
|
||||
data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
|
||||
if(data == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_wlan data_fid\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(data->mac_addr,
|
||||
event_wlan->mac_addr,
|
||||
sizeof(event_wlan->mac_addr));
|
||||
ipa_get_if_index(event_wlan->name, &(data->if_index));
|
||||
evt_data.event = IPA_WLAN_STA_LINK_UP_EVENT;
|
||||
evt_data.evt_data = data;
|
||||
break;
|
||||
|
||||
case WLAN_STA_DISCONNECT:
|
||||
event_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Received WLAN_STA_DISCONNECT name: %s\n",event_wlan->name);
|
||||
IPACMDBG_H("STA Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],
|
||||
event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);
|
||||
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_wlan data_fid\n");
|
||||
return NULL;
|
||||
}
|
||||
ipa_get_if_index(event_wlan->name, &(data_fid->if_index));
|
||||
evt_data.event = IPA_WLAN_LINK_DOWN_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
break;
|
||||
|
||||
case WLAN_CLIENT_CONNECT:
|
||||
event_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Received WLAN_CLIENT_CONNECT\n");
|
||||
IPACMDBG_H("Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],
|
||||
event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);
|
||||
data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
|
||||
if (data == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_wlan data\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(data->mac_addr,
|
||||
event_wlan->mac_addr,
|
||||
sizeof(event_wlan->mac_addr));
|
||||
ipa_get_if_index(event_wlan->name, &(data->if_index));
|
||||
evt_data.event = IPA_WLAN_CLIENT_ADD_EVENT;
|
||||
evt_data.evt_data = data;
|
||||
break;
|
||||
|
||||
case WLAN_CLIENT_CONNECT_EX:
|
||||
IPACMDBG_H("Received WLAN_CLIENT_CONNECT_EX\n");
|
||||
|
||||
memcpy(&event_ex_o, buffer + sizeof(struct ipa_msg_meta),sizeof(struct ipa_wlan_msg_ex));
|
||||
if(event_ex_o.num_of_attribs > IPA_DRIVER_WLAN_EVENT_MAX_OF_ATTRIBS)
|
||||
{
|
||||
IPACMERR("buffer size overflow\n");
|
||||
return NULL;
|
||||
}
|
||||
length = sizeof(ipa_wlan_msg_ex)+ event_ex_o.num_of_attribs * sizeof(ipa_wlan_hdr_attrib_val);
|
||||
IPACMDBG_H("num_of_attribs %d, length %d\n", event_ex_o.num_of_attribs, length);
|
||||
event_ex = (ipa_wlan_msg_ex *)malloc(length);
|
||||
if(event_ex == NULL )
|
||||
{
|
||||
IPACMERR("Unable to allocate memory\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(event_ex, buffer + sizeof(struct ipa_msg_meta), length);
|
||||
data_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));
|
||||
if (data_ex == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event data\n");
|
||||
return NULL;
|
||||
}
|
||||
data_ex->num_of_attribs = event_ex->num_of_attribs;
|
||||
|
||||
memcpy(data_ex->attribs,
|
||||
event_ex->attribs,
|
||||
event_ex->num_of_attribs * sizeof(ipa_wlan_hdr_attrib_val));
|
||||
|
||||
ipa_get_if_index(event_ex->name, &(data_ex->if_index));
|
||||
evt_data.event = IPA_WLAN_CLIENT_ADD_EVENT_EX;
|
||||
evt_data.evt_data = data_ex;
|
||||
|
||||
/* Construct new_neighbor msg with netdev device internally */
|
||||
new_neigh_data = (ipacm_event_data_all*)malloc(sizeof(ipacm_event_data_all));
|
||||
if(new_neigh_data == NULL)
|
||||
{
|
||||
IPACMERR("Failed to allocate memory.\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(new_neigh_data, 0, sizeof(ipacm_event_data_all));
|
||||
new_neigh_data->iptype = IPA_IP_v6;
|
||||
for(cnt = 0; cnt < event_ex->num_of_attribs; cnt++)
|
||||
{
|
||||
if(event_ex->attribs[cnt].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)
|
||||
{
|
||||
memcpy(new_neigh_data->mac_addr, event_ex->attribs[cnt].u.mac_addr, sizeof(new_neigh_data->mac_addr));
|
||||
IPACMDBG_H("Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_ex->attribs[cnt].u.mac_addr[0], event_ex->attribs[cnt].u.mac_addr[1], event_ex->attribs[cnt].u.mac_addr[2],
|
||||
event_ex->attribs[cnt].u.mac_addr[3], event_ex->attribs[cnt].u.mac_addr[4], event_ex->attribs[cnt].u.mac_addr[5]);
|
||||
}
|
||||
else if(event_ex->attribs[cnt].attrib_type == WLAN_HDR_ATTRIB_STA_ID)
|
||||
{
|
||||
IPACMDBG_H("Wlan client id %d\n",event_ex->attribs[cnt].u.sta_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_H("Wlan message has unexpected type!\n");
|
||||
}
|
||||
}
|
||||
new_neigh_data->if_index = data_ex->if_index;
|
||||
new_neigh_evt.evt_data = (void*)new_neigh_data;
|
||||
new_neigh_evt.event = IPA_NEW_NEIGH_EVENT;
|
||||
free(event_ex);
|
||||
break;
|
||||
|
||||
case WLAN_CLIENT_DISCONNECT:
|
||||
IPACMDBG_H("Received WLAN_CLIENT_DISCONNECT\n");
|
||||
event_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],
|
||||
event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);
|
||||
data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
|
||||
if (data == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_wlan data\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(data->mac_addr,
|
||||
event_wlan->mac_addr,
|
||||
sizeof(event_wlan->mac_addr));
|
||||
ipa_get_if_index(event_wlan->name, &(data->if_index));
|
||||
evt_data.event = IPA_WLAN_CLIENT_DEL_EVENT;
|
||||
evt_data.evt_data = data;
|
||||
break;
|
||||
|
||||
case WLAN_CLIENT_POWER_SAVE_MODE:
|
||||
IPACMDBG_H("Received WLAN_CLIENT_POWER_SAVE_MODE\n");
|
||||
event_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],
|
||||
event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);
|
||||
data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
|
||||
if (data == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_wlan data\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(data->mac_addr,
|
||||
event_wlan->mac_addr,
|
||||
sizeof(event_wlan->mac_addr));
|
||||
ipa_get_if_index(event_wlan->name, &(data->if_index));
|
||||
evt_data.event = IPA_WLAN_CLIENT_POWER_SAVE_EVENT;
|
||||
evt_data.evt_data = data;
|
||||
break;
|
||||
|
||||
case WLAN_CLIENT_NORMAL_MODE:
|
||||
IPACMDBG_H("Received WLAN_CLIENT_NORMAL_MODE\n");
|
||||
event_wlan = (struct ipa_wlan_msg *)(buffer + sizeof(struct ipa_msg_meta));
|
||||
IPACMDBG_H("Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
event_wlan->mac_addr[0], event_wlan->mac_addr[1], event_wlan->mac_addr[2],
|
||||
event_wlan->mac_addr[3], event_wlan->mac_addr[4], event_wlan->mac_addr[5]);
|
||||
data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
|
||||
if (data == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_wlan data\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(data->mac_addr,
|
||||
event_wlan->mac_addr,
|
||||
sizeof(event_wlan->mac_addr));
|
||||
ipa_get_if_index(event_wlan->name, &(data->if_index));
|
||||
evt_data.evt_data = data;
|
||||
evt_data.event = IPA_WLAN_CLIENT_RECOVER_EVENT;
|
||||
break;
|
||||
|
||||
case ECM_CONNECT:
|
||||
memcpy(&event_ecm, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_ecm_msg));
|
||||
IPACMDBG_H("Received ECM_CONNECT name: %s\n",event_ecm.name);
|
||||
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_ecm data_fid\n");
|
||||
return NULL;
|
||||
}
|
||||
data_fid->if_index = event_ecm.ifindex;
|
||||
evt_data.event = IPA_USB_LINK_UP_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
break;
|
||||
|
||||
case ECM_DISCONNECT:
|
||||
memcpy(&event_ecm, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_ecm_msg));
|
||||
IPACMDBG_H("Received ECM_DISCONNECT name: %s\n",event_ecm.name);
|
||||
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_ecm data_fid\n");
|
||||
return NULL;
|
||||
}
|
||||
data_fid->if_index = event_ecm.ifindex;
|
||||
evt_data.event = IPA_LINK_DOWN_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
break;
|
||||
/* Add for 8994 Android case */
|
||||
case WAN_UPSTREAM_ROUTE_ADD:
|
||||
memcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_wan_msg));
|
||||
IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_ADD name: %s, tethered name: %s\n", event_wan.upstream_ifname, event_wan.tethered_ifname);
|
||||
data_iptype = (ipacm_event_data_iptype *)malloc(sizeof(ipacm_event_data_iptype));
|
||||
if(data_iptype == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_ecm data_iptype\n");
|
||||
return NULL;
|
||||
}
|
||||
ipa_get_if_index(event_wan.upstream_ifname, &(data_iptype->if_index));
|
||||
ipa_get_if_index(event_wan.tethered_ifname, &(data_iptype->if_index_tether));
|
||||
data_iptype->iptype = event_wan.ip;
|
||||
#ifdef IPA_WAN_MSG_IPv6_ADDR_GW_LEN
|
||||
data_iptype->ipv4_addr_gw = event_wan.ipv4_addr_gw;
|
||||
data_iptype->ipv6_addr_gw[0] = event_wan.ipv6_addr_gw[0];
|
||||
data_iptype->ipv6_addr_gw[1] = event_wan.ipv6_addr_gw[1];
|
||||
data_iptype->ipv6_addr_gw[2] = event_wan.ipv6_addr_gw[2];
|
||||
data_iptype->ipv6_addr_gw[3] = event_wan.ipv6_addr_gw[3];
|
||||
IPACMDBG_H("default gw ipv4 (%x)\n", data_iptype->ipv4_addr_gw);
|
||||
IPACMDBG_H("IPV6 gateway: %08x:%08x:%08x:%08x \n",
|
||||
data_iptype->ipv6_addr_gw[0], data_iptype->ipv6_addr_gw[1], data_iptype->ipv6_addr_gw[2], data_iptype->ipv6_addr_gw[3]);
|
||||
#endif
|
||||
IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_ADD: fid(%d) tether_fid(%d) ip-type(%d)\n", data_iptype->if_index,
|
||||
data_iptype->if_index_tether, data_iptype->iptype);
|
||||
evt_data.event = IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT;
|
||||
evt_data.evt_data = data_iptype;
|
||||
break;
|
||||
case WAN_UPSTREAM_ROUTE_DEL:
|
||||
memcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_wan_msg));
|
||||
IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_DEL name: %s, tethered name: %s\n", event_wan.upstream_ifname, event_wan.tethered_ifname);
|
||||
data_iptype = (ipacm_event_data_iptype *)malloc(sizeof(ipacm_event_data_iptype));
|
||||
if(data_iptype == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event_ecm data_iptype\n");
|
||||
return NULL;
|
||||
}
|
||||
ipa_get_if_index(event_wan.upstream_ifname, &(data_iptype->if_index));
|
||||
ipa_get_if_index(event_wan.tethered_ifname, &(data_iptype->if_index_tether));
|
||||
data_iptype->iptype = event_wan.ip;
|
||||
IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_DEL: fid(%d) ip-type(%d)\n", data_iptype->if_index, data_iptype->iptype);
|
||||
evt_data.event = IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT;
|
||||
evt_data.evt_data = data_iptype;
|
||||
break;
|
||||
/* End of adding for 8994 Android case */
|
||||
|
||||
/* Add for embms case */
|
||||
case WAN_EMBMS_CONNECT:
|
||||
memcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_wan_msg));
|
||||
IPACMDBG("Received WAN_EMBMS_CONNECT name: %s\n",event_wan.upstream_ifname);
|
||||
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event data_fid\n");
|
||||
return NULL;
|
||||
}
|
||||
ipa_get_if_index(event_wan.upstream_ifname, &(data_fid->if_index));
|
||||
evt_data.event = IPA_WAN_EMBMS_LINK_UP_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
break;
|
||||
|
||||
case WLAN_SWITCH_TO_SCC:
|
||||
IPACMDBG_H("Received WLAN_SWITCH_TO_SCC\n");
|
||||
case WLAN_WDI_ENABLE:
|
||||
IPACMDBG_H("Received WLAN_WDI_ENABLE\n");
|
||||
if (IPACM_Iface::ipacmcfg->isMCC_Mode == true)
|
||||
{
|
||||
IPACM_Iface::ipacmcfg->isMCC_Mode = false;
|
||||
evt_data.event = IPA_WLAN_SWITCH_TO_SCC;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
case WLAN_SWITCH_TO_MCC:
|
||||
IPACMDBG_H("Received WLAN_SWITCH_TO_MCC\n");
|
||||
case WLAN_WDI_DISABLE:
|
||||
IPACMDBG_H("Received WLAN_WDI_DISABLE\n");
|
||||
if (IPACM_Iface::ipacmcfg->isMCC_Mode == false)
|
||||
{
|
||||
IPACM_Iface::ipacmcfg->isMCC_Mode = true;
|
||||
evt_data.event = IPA_WLAN_SWITCH_TO_MCC;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
|
||||
case WAN_XLAT_CONNECT:
|
||||
memcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta),
|
||||
sizeof(struct ipa_wan_msg));
|
||||
IPACMDBG_H("Received WAN_XLAT_CONNECT name: %s\n",
|
||||
event_wan.upstream_ifname);
|
||||
|
||||
/* post IPA_LINK_UP_EVENT event
|
||||
* may be WAN interface is not up
|
||||
*/
|
||||
data_fid = (ipacm_event_data_fid *)calloc(1, sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for xlat event\n");
|
||||
return NULL;
|
||||
}
|
||||
ipa_get_if_index(event_wan.upstream_ifname, &(data_fid->if_index));
|
||||
evt_data.event = IPA_LINK_UP_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
IPACMDBG_H("Posting IPA_LINK_UP_EVENT event:%d\n", evt_data.event);
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
|
||||
/* post IPA_WAN_XLAT_CONNECT_EVENT event */
|
||||
memset(&evt_data, 0, sizeof(evt_data));
|
||||
data_fid = (ipacm_event_data_fid *)calloc(1, sizeof(ipacm_event_data_fid));
|
||||
if(data_fid == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for xlat event\n");
|
||||
return NULL;
|
||||
}
|
||||
ipa_get_if_index(event_wan.upstream_ifname, &(data_fid->if_index));
|
||||
evt_data.event = IPA_WAN_XLAT_CONNECT_EVENT;
|
||||
evt_data.evt_data = data_fid;
|
||||
IPACMDBG_H("Posting IPA_WAN_XLAT_CONNECT_EVENT event:%d\n", evt_data.event);
|
||||
break;
|
||||
|
||||
case IPA_TETHERING_STATS_UPDATE_STATS:
|
||||
memcpy(&event_data_stats, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_get_data_stats_resp_msg_v01));
|
||||
data_tethering_stats = (ipa_get_data_stats_resp_msg_v01 *)malloc(sizeof(struct ipa_get_data_stats_resp_msg_v01));
|
||||
if(data_tethering_stats == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event data_tethering_stats\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(data_tethering_stats,
|
||||
&event_data_stats,
|
||||
sizeof(struct ipa_get_data_stats_resp_msg_v01));
|
||||
IPACMDBG("Received IPA_TETHERING_STATS_UPDATE_STATS ipa_stats_type: %d\n",data_tethering_stats->ipa_stats_type);
|
||||
IPACMDBG("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);
|
||||
evt_data.event = IPA_TETHERING_STATS_UPDATE_EVENT;
|
||||
evt_data.evt_data = data_tethering_stats;
|
||||
break;
|
||||
|
||||
case IPA_TETHERING_STATS_UPDATE_NETWORK_STATS:
|
||||
memcpy(&event_network_stats, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_get_apn_data_stats_resp_msg_v01));
|
||||
data_network_stats = (ipa_get_apn_data_stats_resp_msg_v01 *)malloc(sizeof(ipa_get_apn_data_stats_resp_msg_v01));
|
||||
if(data_network_stats == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for event data_network_stats\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(data_network_stats,
|
||||
&event_network_stats,
|
||||
sizeof(struct ipa_get_apn_data_stats_resp_msg_v01));
|
||||
IPACMDBG("Received %d apn network stats \n", data_network_stats->apn_data_stats_list_len);
|
||||
evt_data.event = IPA_NETWORK_STATS_UPDATE_EVENT;
|
||||
evt_data.evt_data = data_network_stats;
|
||||
break;
|
||||
|
||||
default:
|
||||
IPACMDBG_H("Unhandled message type: %d\n", event_hdr.msg_type);
|
||||
continue;
|
||||
|
||||
}
|
||||
/* finish command queue */
|
||||
IPACMDBG_H("Posting event:%d\n", evt_data.event);
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
/* push new_neighbor with netdev device internally */
|
||||
if(new_neigh_data != NULL)
|
||||
{
|
||||
IPACMDBG_H("Internally post event IPA_NEW_NEIGH_EVENT\n");
|
||||
IPACM_EvtDispatcher::PostEvt(&new_neigh_evt);
|
||||
}
|
||||
}
|
||||
|
||||
(void)close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void IPACM_Sig_Handler(int sig)
|
||||
{
|
||||
int cnt;
|
||||
ipacm_cmd_q_data evt_data;
|
||||
|
||||
printf("Received Signal: %d\n", sig);
|
||||
memset(&evt_data, 0, sizeof(evt_data));
|
||||
|
||||
switch(sig)
|
||||
{
|
||||
case SIGUSR1:
|
||||
IPACMDBG_H("Received SW_ROUTING_ENABLE request \n");
|
||||
evt_data.event = IPA_SW_ROUTING_ENABLE;
|
||||
IPACM_Iface::ipacmcfg->ipa_sw_rt_enable = true;
|
||||
break;
|
||||
|
||||
case SIGUSR2:
|
||||
IPACMDBG_H("Received SW_ROUTING_DISABLE request \n");
|
||||
evt_data.event = IPA_SW_ROUTING_DISABLE;
|
||||
IPACM_Iface::ipacmcfg->ipa_sw_rt_enable = false;
|
||||
break;
|
||||
}
|
||||
/* finish command queue */
|
||||
IPACMDBG_H("Posting event:%d\n", evt_data.event);
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
return;
|
||||
}
|
||||
|
||||
void RegisterForSignals(void)
|
||||
{
|
||||
|
||||
signal(SIGUSR1, IPACM_Sig_Handler);
|
||||
signal(SIGUSR2, IPACM_Sig_Handler);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
pthread_t netlink_thread = 0, monitor_thread = 0, ipa_driver_thread = 0;
|
||||
pthread_t cmd_queue_thread = 0;
|
||||
|
||||
/* check if ipacm is already running or not */
|
||||
ipa_is_ipacm_running();
|
||||
|
||||
IPACMDBG_H("In main()\n");
|
||||
IPACM_Neighbor *neigh = new IPACM_Neighbor();
|
||||
IPACM_IfaceManager *ifacemgr = new IPACM_IfaceManager();
|
||||
|
||||
#ifdef FEATURE_ETH_BRIDGE_LE
|
||||
IPACM_LanToLan* lan2lan = new IPACM_LanToLan();
|
||||
#endif
|
||||
|
||||
IPACM_ConntrackClient *cc = IPACM_ConntrackClient::GetInstance();
|
||||
CtList = new IPACM_ConntrackListener();
|
||||
|
||||
IPACMDBG_H("Staring IPA main\n");
|
||||
IPACMDBG_H("ipa_cmdq_successful\n");
|
||||
|
||||
|
||||
RegisterForSignals();
|
||||
|
||||
if (IPACM_SUCCESS == cmd_queue_thread)
|
||||
{
|
||||
ret = pthread_create(&cmd_queue_thread, NULL, MessageQueue::Process, NULL);
|
||||
if (IPACM_SUCCESS != ret)
|
||||
{
|
||||
IPACMERR("unable to command queue thread\n");
|
||||
return ret;
|
||||
}
|
||||
IPACMDBG_H("created command queue thread\n");
|
||||
if(pthread_setname_np(cmd_queue_thread, "cmd queue process") != 0)
|
||||
{
|
||||
IPACMERR("unable to set thread name\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (IPACM_SUCCESS == netlink_thread)
|
||||
{
|
||||
ret = pthread_create(&netlink_thread, NULL, netlink_start, NULL);
|
||||
if (IPACM_SUCCESS != ret)
|
||||
{
|
||||
IPACMERR("unable to create netlink thread\n");
|
||||
return ret;
|
||||
}
|
||||
IPACMDBG_H("created netlink thread\n");
|
||||
if(pthread_setname_np(netlink_thread, "netlink socket") != 0)
|
||||
{
|
||||
IPACMERR("unable to set thread name\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable Firewall support only on MDM targets */
|
||||
#ifndef FEATURE_IPA_ANDROID
|
||||
if (IPACM_SUCCESS == monitor_thread)
|
||||
{
|
||||
ret = pthread_create(&monitor_thread, NULL, firewall_monitor, NULL);
|
||||
if (IPACM_SUCCESS != ret)
|
||||
{
|
||||
IPACMERR("unable to create monitor thread\n");
|
||||
return ret;
|
||||
}
|
||||
IPACMDBG_H("created firewall monitor thread\n");
|
||||
if(pthread_setname_np(monitor_thread, "firewall cfg process") != 0)
|
||||
{
|
||||
IPACMERR("unable to set thread name\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (IPACM_SUCCESS == ipa_driver_thread)
|
||||
{
|
||||
ret = pthread_create(&ipa_driver_thread, NULL, ipa_driver_msg_notifier, NULL);
|
||||
if (IPACM_SUCCESS != ret)
|
||||
{
|
||||
IPACMERR("unable to create ipa_driver_wlan thread\n");
|
||||
return ret;
|
||||
}
|
||||
IPACMDBG_H("created ipa_driver_wlan thread\n");
|
||||
if(pthread_setname_np(ipa_driver_thread, "ipa driver ntfy") != 0)
|
||||
{
|
||||
IPACMERR("unable to set thread name\n");
|
||||
}
|
||||
}
|
||||
|
||||
pthread_join(cmd_queue_thread, NULL);
|
||||
pthread_join(netlink_thread, NULL);
|
||||
pthread_join(monitor_thread, NULL);
|
||||
pthread_join(ipa_driver_thread, NULL);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION ipa_is_ipacm_running
|
||||
===========================================================================*/
|
||||
/*!
|
||||
@brief
|
||||
Determine whether there's already an IPACM process running, if so, terminate
|
||||
the current one
|
||||
|
||||
@return
|
||||
None
|
||||
|
||||
@note
|
||||
|
||||
- Dependencies
|
||||
- None
|
||||
|
||||
- Side Effects
|
||||
- None
|
||||
*/
|
||||
/*=========================================================================*/
|
||||
|
||||
void ipa_is_ipacm_running(void) {
|
||||
|
||||
int fd;
|
||||
struct flock lock;
|
||||
int retval;
|
||||
|
||||
fd = open(IPACM_PID_FILE, O_RDWR | O_CREAT, 0600);
|
||||
if ( fd <= 0 )
|
||||
{
|
||||
IPACMERR("Failed to open %s, error is %d - %s\n",
|
||||
IPACM_PID_FILE, errno, strerror(errno));
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Getting an exclusive Write lock on the file, if it fails,
|
||||
* it means that another instance of IPACM is running and it
|
||||
* got the lock before us.
|
||||
*/
|
||||
memset(&lock, 0, sizeof(lock));
|
||||
lock.l_type = F_WRLCK;
|
||||
retval = fcntl(fd, F_SETLK, &lock);
|
||||
|
||||
if (retval != 0)
|
||||
{
|
||||
retval = fcntl(fd, F_GETLK, &lock);
|
||||
if (retval == 0)
|
||||
{
|
||||
IPACMERR("Unable to get lock on file %s (my PID %d), PID %d already has it\n",
|
||||
IPACM_PID_FILE, getpid(), lock.l_pid);
|
||||
close(fd);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR("PID %d is IPACM main process\n", getpid());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION ipa_get_if_index
|
||||
===========================================================================*/
|
||||
/*!
|
||||
@brief
|
||||
get ipa interface index by given the interface name
|
||||
|
||||
@return
|
||||
IPACM_SUCCESS or IPA_FALUIRE
|
||||
|
||||
@note
|
||||
|
||||
- Dependencies
|
||||
- None
|
||||
|
||||
- Side Effects
|
||||
- None
|
||||
*/
|
||||
/*=========================================================================*/
|
||||
int ipa_get_if_index
|
||||
(
|
||||
char *if_name,
|
||||
int *if_index
|
||||
)
|
||||
{
|
||||
int fd;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
PERROR("get interface index socket create failed");
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
|
||||
(void)strlcpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));
|
||||
|
||||
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0)
|
||||
{
|
||||
IPACMERR("call_ioctl_on_dev: ioctl failed: can't find device %s",if_name);
|
||||
*if_index = -1;
|
||||
close(fd);
|
||||
return IPACM_FAILURE;
|
||||
}
|
||||
|
||||
*if_index = ifr.ifr_ifindex;
|
||||
close(fd);
|
||||
return IPACM_SUCCESS;
|
||||
}
|
||||
570
data-ipa-cfg-mgr/ipacm/src/IPACM_Neighbor.cpp
Normal file
570
data-ipa-cfg-mgr/ipacm/src/IPACM_Neighbor.cpp
Normal file
@@ -0,0 +1,570 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Neighbor.cpp
|
||||
|
||||
@brief
|
||||
This file implements the functionality of handling IPACM Neighbor events.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <IPACM_Neighbor.h>
|
||||
#include <IPACM_EvtDispatcher.h>
|
||||
#include "IPACM_Defs.h"
|
||||
#include "IPACM_Log.h"
|
||||
|
||||
|
||||
IPACM_Neighbor::IPACM_Neighbor()
|
||||
{
|
||||
num_neighbor_client = 0;
|
||||
circular_index = 0;
|
||||
memset(neighbor_client, 0, IPA_MAX_NUM_NEIGHBOR_CLIENTS * sizeof(ipa_neighbor_client));
|
||||
IPACM_EvtDispatcher::registr(IPA_WLAN_CLIENT_ADD_EVENT_EX, this);
|
||||
IPACM_EvtDispatcher::registr(IPA_NEW_NEIGH_EVENT, this);
|
||||
IPACM_EvtDispatcher::registr(IPA_DEL_NEIGH_EVENT, this);
|
||||
return;
|
||||
}
|
||||
|
||||
void IPACM_Neighbor::event_callback(ipa_cm_event_id event, void *param)
|
||||
{
|
||||
ipacm_event_data_all *data_all = NULL;
|
||||
int i, ipa_interface_index;
|
||||
ipacm_cmd_q_data evt_data;
|
||||
int num_neighbor_client_temp = num_neighbor_client;
|
||||
|
||||
IPACMDBG("Recieved event %d\n", event);
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case IPA_WLAN_CLIENT_ADD_EVENT_EX:
|
||||
{
|
||||
ipacm_event_data_wlan_ex *data = (ipacm_event_data_wlan_ex *)param;
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(data->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("IPA_WLAN_CLIENT_ADD_EVENT_EX: not supported iface id: %d\n", data->if_index);
|
||||
break;
|
||||
}
|
||||
uint8_t client_mac_addr[6];
|
||||
|
||||
IPACMDBG_H("Received IPA_WLAN_CLIENT_ADD_EVENT\n");
|
||||
for(i = 0; i < data->num_of_attribs; i++)
|
||||
{
|
||||
if(data->attribs[i].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)
|
||||
{
|
||||
memcpy(client_mac_addr,
|
||||
data->attribs[i].u.mac_addr,
|
||||
sizeof(client_mac_addr));
|
||||
IPACMDBG_H("AP Mac Address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
client_mac_addr[0], client_mac_addr[1], client_mac_addr[2],
|
||||
client_mac_addr[3], client_mac_addr[4], client_mac_addr[5]);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_H("The attribute type is not expected!\n");
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < num_neighbor_client_temp; i++)
|
||||
{
|
||||
/* find the client */
|
||||
if (memcmp(neighbor_client[i].mac_addr, client_mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)
|
||||
{
|
||||
/* check if iface is not bridge interface*/
|
||||
if (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) != 0)
|
||||
{
|
||||
/* use previous ipv4 first */
|
||||
if(data->if_index != neighbor_client[i].iface_index)
|
||||
{
|
||||
IPACMERR("update new kernel iface index \n");
|
||||
neighbor_client[i].iface_index = data->if_index;
|
||||
}
|
||||
|
||||
/* check if client associated with previous network interface */
|
||||
if(ipa_interface_index != neighbor_client[i].ipa_if_num)
|
||||
{
|
||||
IPACMERR("client associate to different AP \n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (neighbor_client[i].v4_addr != 0) /* not 0.0.0.0 */
|
||||
{
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;
|
||||
data_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));
|
||||
if (data_all == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory\n");
|
||||
return;
|
||||
}
|
||||
data_all->iptype = IPA_IP_v4;
|
||||
data_all->if_index = neighbor_client[i].iface_index;
|
||||
data_all->ipv4_addr = neighbor_client[i].v4_addr; //use previous ipv4 address
|
||||
memcpy(data_all->mac_addr,
|
||||
neighbor_client[i].mac_addr,
|
||||
sizeof(data_all->mac_addr));
|
||||
evt_data.evt_data = (void *)data_all;
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
/* ask for replaced iface name*/
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("not supported iface id: %d\n", data_all->if_index);
|
||||
} else {
|
||||
IPACMDBG_H("Posted event %d, with %s for ipv4 client re-connect\n",
|
||||
evt_data.event,
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
if (event == IPA_NEW_NEIGH_EVENT)
|
||||
{
|
||||
IPACMDBG_H("Received IPA_NEW_NEIGH_EVENT\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG_H("Received IPA_DEL_NEIGH_EVENT\n");
|
||||
}
|
||||
|
||||
ipacm_event_data_all *data = (ipacm_event_data_all *)param;
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(data->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("not supported iface id: %d\n", data->if_index);
|
||||
break;
|
||||
}
|
||||
if (data->iptype == IPA_IP_v4)
|
||||
{
|
||||
if (data->ipv4_addr != 0) /* not 0.0.0.0 */
|
||||
{
|
||||
IPACMDBG("Got Neighbor event with ipv4 address: 0x%x \n", data->ipv4_addr);
|
||||
/* check if ipv4 address is link local(169.254.xxx.xxx) */
|
||||
if ((data->ipv4_addr & IPV4_ADDR_LINKLOCAL_MASK) == IPV4_ADDR_LINKLOCAL)
|
||||
{
|
||||
IPACMDBG_H("This is link local ipv4 address: 0x%x : ignore this NEIGH_EVENT\n", data->ipv4_addr);
|
||||
return;
|
||||
}
|
||||
/* check if iface is bridge interface*/
|
||||
if (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) == 0)
|
||||
{
|
||||
/* searh if seen this client or not*/
|
||||
for (i = 0; i < num_neighbor_client_temp; i++)
|
||||
{
|
||||
if (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)
|
||||
{
|
||||
data->if_index = neighbor_client[i].iface_index;
|
||||
neighbor_client[i].v4_addr = data->ipv4_addr; // cache client's previous ipv4 address
|
||||
/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */
|
||||
if (event == IPA_NEW_NEIGH_EVENT)
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;
|
||||
else
|
||||
/* not to clean-up the client mac cache on bridge0 delneigh */
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;
|
||||
data_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));
|
||||
if (data_all == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory\n");
|
||||
return;
|
||||
}
|
||||
memcpy(data_all, data, sizeof(ipacm_event_data_all));
|
||||
evt_data.evt_data = (void *)data_all;
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
|
||||
/* ask for replaced iface name*/
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("not supported iface id: %d\n", data_all->if_index);
|
||||
} else {
|
||||
IPACMDBG_H("Posted event %d,\
|
||||
with %s for ipv4\n",
|
||||
evt_data.event,
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */
|
||||
if (event == IPA_NEW_NEIGH_EVENT)
|
||||
{
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;
|
||||
/* Also save to cache for ipv4 */
|
||||
/*searh if seen this client or not*/
|
||||
for (i = 0; i < num_neighbor_client_temp; i++)
|
||||
{
|
||||
/* find the client */
|
||||
if (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)
|
||||
{
|
||||
/* update the network interface client associated */
|
||||
neighbor_client[i].iface_index = data->if_index;
|
||||
neighbor_client[i].ipa_if_num = ipa_interface_index;
|
||||
neighbor_client[i].v4_addr = data->ipv4_addr; // cache client's previous ipv4 address
|
||||
IPACMDBG_H("update cache %d-entry, with %s iface, ipv4 address: 0x%x\n",
|
||||
i,
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,
|
||||
data->ipv4_addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* not find client */
|
||||
if (i == num_neighbor_client_temp)
|
||||
{
|
||||
if (num_neighbor_client_temp < IPA_MAX_NUM_NEIGHBOR_CLIENTS)
|
||||
{
|
||||
memcpy(neighbor_client[num_neighbor_client_temp].mac_addr,
|
||||
data->mac_addr,
|
||||
sizeof(data->mac_addr));
|
||||
neighbor_client[num_neighbor_client_temp].iface_index = data->if_index;
|
||||
/* cache the network interface client associated */
|
||||
neighbor_client[num_neighbor_client_temp].ipa_if_num = ipa_interface_index;
|
||||
neighbor_client[num_neighbor_client_temp].v4_addr = data->ipv4_addr;
|
||||
num_neighbor_client++;
|
||||
IPACMDBG_H("Cache client MAC %02x:%02x:%02x:%02x:%02x:%02x\n, total client: %d\n",
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[0],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[1],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[2],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[3],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[4],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[5],
|
||||
num_neighbor_client);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
IPACMERR("error: neighbor client oversize! recycle %d-st entry ! \n", circular_index);
|
||||
memcpy(neighbor_client[circular_index].mac_addr,
|
||||
data->mac_addr,
|
||||
sizeof(data->mac_addr));
|
||||
neighbor_client[circular_index].iface_index = data->if_index;
|
||||
/* cache the network interface client associated */
|
||||
neighbor_client[circular_index].ipa_if_num = ipa_interface_index;
|
||||
neighbor_client[circular_index].v4_addr = 0;
|
||||
IPACMDBG_H("Copy wlan-iface client MAC %02x:%02x:%02x:%02x:%02x:%02x\n, total client: %d, circular %d\n",
|
||||
neighbor_client[circular_index].mac_addr[0],
|
||||
neighbor_client[circular_index].mac_addr[1],
|
||||
neighbor_client[circular_index].mac_addr[2],
|
||||
neighbor_client[circular_index].mac_addr[3],
|
||||
neighbor_client[circular_index].mac_addr[4],
|
||||
neighbor_client[circular_index].mac_addr[5],
|
||||
num_neighbor_client,
|
||||
circular_index);
|
||||
circular_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;
|
||||
/*searh if seen this client or not*/
|
||||
for (i = 0; i < num_neighbor_client_temp; i++)
|
||||
{
|
||||
/* find the client */
|
||||
if (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)
|
||||
{
|
||||
IPACMDBG_H("Clean %d-st Cached client-MAC %02x:%02x:%02x:%02x:%02x:%02x\n, total client: %d\n",
|
||||
i,
|
||||
neighbor_client[i].mac_addr[0],
|
||||
neighbor_client[i].mac_addr[1],
|
||||
neighbor_client[i].mac_addr[2],
|
||||
neighbor_client[i].mac_addr[3],
|
||||
neighbor_client[i].mac_addr[4],
|
||||
neighbor_client[i].mac_addr[5],
|
||||
num_neighbor_client);
|
||||
|
||||
memset(neighbor_client[i].mac_addr, 0, sizeof(neighbor_client[i].mac_addr));
|
||||
neighbor_client[i].iface_index = 0;
|
||||
neighbor_client[i].v4_addr = 0;
|
||||
neighbor_client[i].ipa_if_num = 0;
|
||||
for (; i < num_neighbor_client_temp - 1; i++)
|
||||
{
|
||||
memcpy(neighbor_client[i].mac_addr,
|
||||
neighbor_client[i+1].mac_addr,
|
||||
sizeof(neighbor_client[i].mac_addr));
|
||||
neighbor_client[i].iface_index = neighbor_client[i+1].iface_index;
|
||||
neighbor_client[i].v4_addr = neighbor_client[i+1].v4_addr;
|
||||
neighbor_client[i].ipa_if_num = neighbor_client[i+1].ipa_if_num;
|
||||
}
|
||||
num_neighbor_client--;
|
||||
IPACMDBG_H(" total number of left cased clients: %d\n", num_neighbor_client);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* not find client, no need clean-up */
|
||||
}
|
||||
|
||||
data_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));
|
||||
if (data_all == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory\n");
|
||||
return;
|
||||
}
|
||||
memcpy(data_all, data, sizeof(ipacm_event_data_all));
|
||||
evt_data.evt_data = (void *)data_all;
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
IPACMDBG_H("Posted event %d with %s for ipv4\n",
|
||||
evt_data.event,
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //ipv6 starts
|
||||
|
||||
if ((data->ipv6_addr[0]) || (data->ipv6_addr[1]) || (data->ipv6_addr[2]) || (data->ipv6_addr[3]))
|
||||
{
|
||||
IPACMDBG("Got New_Neighbor event with ipv6 address \n");
|
||||
/* check if iface is bridge interface*/
|
||||
if (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) == 0)
|
||||
{
|
||||
/* searh if seen this client or not*/
|
||||
for (i = 0; i < num_neighbor_client_temp; i++)
|
||||
{
|
||||
if (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)
|
||||
{
|
||||
data->if_index = neighbor_client[i].iface_index;
|
||||
/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */
|
||||
if (event == IPA_NEW_NEIGH_EVENT) evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;
|
||||
else evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;
|
||||
data_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));
|
||||
if (data_all == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory\n");
|
||||
return;
|
||||
}
|
||||
memcpy(data_all, data, sizeof(ipacm_event_data_all));
|
||||
evt_data.evt_data = (void *)data_all;
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
/* ask for replaced iface name*/
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("not supported iface id: %d\n", data_all->if_index);
|
||||
} else {
|
||||
IPACMDBG_H("Posted event %d,\
|
||||
with %s for ipv6\n",
|
||||
evt_data.event,
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */
|
||||
if (event == IPA_NEW_NEIGH_EVENT)
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;
|
||||
else
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;
|
||||
data_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));
|
||||
if (data_all == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory\n");
|
||||
return;
|
||||
}
|
||||
memcpy(data_all, data, sizeof(ipacm_event_data_all));
|
||||
evt_data.evt_data = (void *)data_all;
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
IPACMDBG_H("Posted event %d with %s for ipv6\n",
|
||||
evt_data.event,
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMDBG(" Got Neighbor event with no ipv6/ipv4 address \n");
|
||||
/*no ipv6 in data searh if seen this client or not*/
|
||||
for (i = 0; i < num_neighbor_client_temp; i++)
|
||||
{
|
||||
/* find the client */
|
||||
if (memcmp(neighbor_client[i].mac_addr, data->mac_addr, sizeof(neighbor_client[i].mac_addr)) == 0)
|
||||
{
|
||||
IPACMDBG_H(" find %d-st client, MAC %02x:%02x:%02x:%02x:%02x:%02x\n, total client: %d\n",
|
||||
i,
|
||||
neighbor_client[i].mac_addr[0],
|
||||
neighbor_client[i].mac_addr[1],
|
||||
neighbor_client[i].mac_addr[2],
|
||||
neighbor_client[i].mac_addr[3],
|
||||
neighbor_client[i].mac_addr[4],
|
||||
neighbor_client[i].mac_addr[5],
|
||||
num_neighbor_client);
|
||||
/* check if iface is not bridge interface*/
|
||||
if (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) != 0)
|
||||
{
|
||||
/* use previous ipv4 first */
|
||||
if(data->if_index != neighbor_client[i].iface_index)
|
||||
{
|
||||
IPACMDBG_H("update new kernel iface index \n");
|
||||
neighbor_client[i].iface_index = data->if_index;
|
||||
}
|
||||
|
||||
/* check if client associated with previous network interface */
|
||||
if(ipa_interface_index != neighbor_client[i].ipa_if_num)
|
||||
{
|
||||
IPACMDBG_H("client associate to different AP \n");
|
||||
}
|
||||
|
||||
if (neighbor_client[i].v4_addr != 0) /* not 0.0.0.0 */
|
||||
{
|
||||
/* construct IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT command and insert to command-queue */
|
||||
if (event == IPA_NEW_NEIGH_EVENT)
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT;
|
||||
else
|
||||
evt_data.event = IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT;
|
||||
data_all = (ipacm_event_data_all *)malloc(sizeof(ipacm_event_data_all));
|
||||
if (data_all == NULL)
|
||||
{
|
||||
IPACMERR("Unable to allocate memory\n");
|
||||
return;
|
||||
}
|
||||
data_all->iptype = IPA_IP_v4;
|
||||
data_all->if_index = neighbor_client[i].iface_index;
|
||||
data_all->ipv4_addr = neighbor_client[i].v4_addr; //use previous ipv4 address
|
||||
memcpy(data_all->mac_addr,
|
||||
neighbor_client[i].mac_addr,
|
||||
sizeof(data_all->mac_addr));
|
||||
evt_data.evt_data = (void *)data_all;
|
||||
IPACM_EvtDispatcher::PostEvt(&evt_data);
|
||||
/* ask for replaced iface name*/
|
||||
ipa_interface_index = IPACM_Iface::iface_ipa_index_query(data_all->if_index);
|
||||
/* check for failure return */
|
||||
if (IPACM_FAILURE == ipa_interface_index) {
|
||||
IPACMERR("not supported iface id: %d\n", data_all->if_index);
|
||||
} else {
|
||||
IPACMDBG_H("Posted event %d,\
|
||||
with %s for ipv4 client re-connect\n",
|
||||
evt_data.event,
|
||||
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* delete cache neighbor entry */
|
||||
if (event == IPA_DEL_NEIGH_EVENT)
|
||||
{
|
||||
IPACMDBG_H("Clean %d-st Cached client-MAC %02x:%02x:%02x:%02x:%02x:%02x\n, total client: %d\n",
|
||||
i,
|
||||
neighbor_client[i].mac_addr[0],
|
||||
neighbor_client[i].mac_addr[1],
|
||||
neighbor_client[i].mac_addr[2],
|
||||
neighbor_client[i].mac_addr[3],
|
||||
neighbor_client[i].mac_addr[4],
|
||||
neighbor_client[i].mac_addr[5],
|
||||
num_neighbor_client);
|
||||
|
||||
memset(neighbor_client[i].mac_addr, 0, sizeof(neighbor_client[i].mac_addr));
|
||||
neighbor_client[i].iface_index = 0;
|
||||
neighbor_client[i].v4_addr = 0;
|
||||
neighbor_client[i].ipa_if_num = 0;
|
||||
for (; i < num_neighbor_client_temp - 1; i++)
|
||||
{
|
||||
memcpy(neighbor_client[i].mac_addr,
|
||||
neighbor_client[i+1].mac_addr,
|
||||
sizeof(neighbor_client[i].mac_addr));
|
||||
neighbor_client[i].iface_index = neighbor_client[i+1].iface_index;
|
||||
neighbor_client[i].v4_addr = neighbor_client[i+1].v4_addr;
|
||||
neighbor_client[i].ipa_if_num = neighbor_client[i+1].ipa_if_num;
|
||||
}
|
||||
num_neighbor_client--;
|
||||
IPACMDBG_H(" total number of left cased clients: %d\n", num_neighbor_client);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* not find client */
|
||||
if ((i == num_neighbor_client_temp) && (event == IPA_NEW_NEIGH_EVENT))
|
||||
{
|
||||
/* check if iface is not bridge interface*/
|
||||
if (strcmp(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name) != 0)
|
||||
{
|
||||
if (num_neighbor_client_temp < IPA_MAX_NUM_NEIGHBOR_CLIENTS)
|
||||
{
|
||||
memcpy(neighbor_client[num_neighbor_client_temp].mac_addr,
|
||||
data->mac_addr,
|
||||
sizeof(data->mac_addr));
|
||||
neighbor_client[num_neighbor_client_temp].iface_index = data->if_index;
|
||||
/* cache the network interface client associated */
|
||||
neighbor_client[num_neighbor_client_temp].ipa_if_num = ipa_interface_index;
|
||||
neighbor_client[num_neighbor_client_temp].v4_addr = 0;
|
||||
num_neighbor_client++;
|
||||
IPACMDBG_H("Copy client MAC %02x:%02x:%02x:%02x:%02x:%02x\n, total client: %d\n",
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[0],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[1],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[2],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[3],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[4],
|
||||
neighbor_client[num_neighbor_client_temp].mac_addr[5],
|
||||
num_neighbor_client);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPACMERR("error: neighbor client oversize! recycle %d-st entry ! \n", circular_index);
|
||||
memcpy(neighbor_client[circular_index].mac_addr,
|
||||
data->mac_addr,
|
||||
sizeof(data->mac_addr));
|
||||
neighbor_client[circular_index].iface_index = data->if_index;
|
||||
/* cache the network interface client associated */
|
||||
neighbor_client[circular_index].ipa_if_num = ipa_interface_index;
|
||||
neighbor_client[circular_index].v4_addr = 0;
|
||||
IPACMDBG_H("Copy wlan-iface client MAC %02x:%02x:%02x:%02x:%02x:%02x\n, total client: %d, circular %d\n",
|
||||
neighbor_client[circular_index].mac_addr[0],
|
||||
neighbor_client[circular_index].mac_addr[1],
|
||||
neighbor_client[circular_index].mac_addr[2],
|
||||
neighbor_client[circular_index].mac_addr[3],
|
||||
neighbor_client[circular_index].mac_addr[4],
|
||||
neighbor_client[circular_index].mac_addr[5],
|
||||
num_neighbor_client,
|
||||
circular_index);
|
||||
circular_index++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} //ipv6 ends
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
1773
data-ipa-cfg-mgr/ipacm/src/IPACM_Netlink.cpp
Normal file
1773
data-ipa-cfg-mgr/ipacm/src/IPACM_Netlink.cpp
Normal file
File diff suppressed because it is too large
Load Diff
276
data-ipa-cfg-mgr/ipacm/src/IPACM_Routing.cpp
Normal file
276
data-ipa-cfg-mgr/ipacm/src/IPACM_Routing.cpp
Normal file
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of The Linux Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*!
|
||||
@file
|
||||
IPACM_Routing.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPACM routing functionality.
|
||||
|
||||
@Author
|
||||
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "IPACM_Routing.h"
|
||||
#include <IPACM_Log.h>
|
||||
|
||||
const char *IPACM_Routing::DEVICE_NAME = "/dev/ipa";
|
||||
|
||||
IPACM_Routing::IPACM_Routing()
|
||||
{
|
||||
m_fd = open(DEVICE_NAME, O_RDWR);
|
||||
if (0 == m_fd)
|
||||
{
|
||||
IPACMERR("Failed opening %s.\n", DEVICE_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
IPACM_Routing::~IPACM_Routing()
|
||||
{
|
||||
close(m_fd);
|
||||
}
|
||||
|
||||
bool IPACM_Routing::DeviceNodeIsOpened()
|
||||
{
|
||||
int res = fcntl(m_fd, F_GETFL);
|
||||
|
||||
if (m_fd > 0 && res >= 0) return true;
|
||||
else return false;
|
||||
|
||||
}
|
||||
|
||||
bool IPACM_Routing::AddRoutingRule(struct ipa_ioc_add_rt_rule *ruleTable)
|
||||
{
|
||||
int retval = 0, cnt=0;
|
||||
bool isInvalid = false;
|
||||
|
||||
if (!DeviceNodeIsOpened())
|
||||
{
|
||||
IPACMERR("Device is not opened\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
for(cnt=0; cnt<ruleTable->num_rules; cnt++)
|
||||
{
|
||||
if(ruleTable->rules[cnt].rule.dst > IPA_CLIENT_MAX)
|
||||
{
|
||||
IPACMERR("Invalid dst pipe, Rule:%d dst_pipe:%d\n", cnt, ruleTable->rules[cnt].rule.dst);
|
||||
isInvalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(isInvalid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_ADD_RT_RULE, ruleTable);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed adding routing rule %p\n", ruleTable);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(cnt=0; cnt<ruleTable->num_rules; cnt++)
|
||||
{
|
||||
IPACMDBG("Rule:%d dst_pipe:%d\n", cnt, ruleTable->rules[cnt].rule.dst);
|
||||
}
|
||||
|
||||
IPACMDBG_H("Added routing rule %p\n", ruleTable);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Routing::DeleteRoutingRule(struct ipa_ioc_del_rt_rule *ruleTable)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!DeviceNodeIsOpened()) return false;
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_DEL_RT_RULE, ruleTable);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed deleting routing rule table %p\n", ruleTable);
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG_H("Deleted routing rule %p\n", ruleTable);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Routing::Commit(enum ipa_ip_type ip)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!DeviceNodeIsOpened()) return false;
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_COMMIT_RT, ip);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed commiting routing rules.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG_H("Commited routing rules to IPA HW.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Routing::Reset(enum ipa_ip_type ip)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!DeviceNodeIsOpened()) return false;
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_RESET_RT, ip);
|
||||
retval |= ioctl(m_fd, IPA_IOC_COMMIT_RT, ip);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed resetting routing block.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG_H("Reset command issued to IPA routing block.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Routing::GetRoutingTable(struct ipa_ioc_get_rt_tbl *routingTable)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!DeviceNodeIsOpened()) return false;
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_GET_RT_TBL, routingTable);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("IPA_IOCTL_GET_RT_TBL ioctl failed, routingTable =0x%p, retval=0x%x.\n", routingTable, retval);
|
||||
return false;
|
||||
}
|
||||
IPACMDBG_H("IPA_IOCTL_GET_RT_TBL ioctl issued to IPA routing block.\n");
|
||||
/* put routing table right after successfully get routing table */
|
||||
PutRoutingTable(routingTable->hdl);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Routing::PutRoutingTable(uint32_t routingTableHandle)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!DeviceNodeIsOpened()) return false;
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_PUT_RT_TBL, routingTableHandle);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("IPA_IOCTL_PUT_RT_TBL ioctl failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
IPACMDBG_H("IPA_IOCTL_PUT_RT_TBL ioctl issued to IPA routing block.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPACM_Routing::DeleteRoutingHdl(uint32_t rt_rule_hdl, ipa_ip_type ip)
|
||||
{
|
||||
const uint8_t NUM_RULES = 1;
|
||||
struct ipa_ioc_del_rt_rule *rt_rule;
|
||||
struct ipa_rt_rule_del *rt_rule_entry;
|
||||
bool res = true;
|
||||
int len = 0;
|
||||
|
||||
if (rt_rule_hdl == 0)
|
||||
{
|
||||
IPACMERR(" No route handle passed. Ignoring it\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
len = (sizeof(struct ipa_ioc_del_rt_rule)) + (NUM_RULES * sizeof(struct ipa_rt_rule_del));
|
||||
rt_rule = (struct ipa_ioc_del_rt_rule *)malloc(len);
|
||||
if (rt_rule == NULL)
|
||||
{
|
||||
IPACMERR("unable to allocate memory for del route rule\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(rt_rule, 0, len);
|
||||
rt_rule->commit = 1;
|
||||
rt_rule->num_hdls = NUM_RULES;
|
||||
rt_rule->ip = ip;
|
||||
|
||||
rt_rule_entry = &rt_rule->hdl[0];
|
||||
rt_rule_entry->status = -1;
|
||||
rt_rule_entry->hdl = rt_rule_hdl;
|
||||
|
||||
IPACMDBG_H("Deleting Route hdl:(0x%x) with ip type: %d\n", rt_rule_entry->hdl, ip);
|
||||
if ((false == DeleteRoutingRule(rt_rule)) ||
|
||||
(rt_rule_entry->status))
|
||||
{
|
||||
PERROR("Routing rule deletion failed!\n");
|
||||
goto fail;
|
||||
res = false;
|
||||
}
|
||||
|
||||
fail:
|
||||
free(rt_rule);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool IPACM_Routing::ModifyRoutingRule(struct ipa_ioc_mdfy_rt_rule *mdfyRules)
|
||||
{
|
||||
int retval = 0, cnt;
|
||||
|
||||
if (!DeviceNodeIsOpened())
|
||||
{
|
||||
IPACMERR("Device is not opened\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
retval = ioctl(m_fd, IPA_IOC_MDFY_RT_RULE, mdfyRules);
|
||||
if (retval)
|
||||
{
|
||||
IPACMERR("Failed modifying routing rules %p\n", mdfyRules);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(cnt=0; cnt<mdfyRules->num_rules; cnt++)
|
||||
{
|
||||
if(mdfyRules->rules[cnt].status != 0)
|
||||
{
|
||||
IPACMERR("Unable to modify rule: %d\n", cnt);
|
||||
}
|
||||
}
|
||||
|
||||
IPACMDBG_H("Modified routing rules %p\n", mdfyRules);
|
||||
return true;
|
||||
}
|
||||
6139
data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp
Normal file
6139
data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2036
data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp
Normal file
2036
data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1176
data-ipa-cfg-mgr/ipacm/src/IPACM_Xml.cpp
Normal file
1176
data-ipa-cfg-mgr/ipacm/src/IPACM_Xml.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user