ipq95xx: drop ATH12.3 support

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2025-03-24 08:11:43 +01:00
parent 76d112144f
commit d250f91bb3
1677 changed files with 0 additions and 451059 deletions

View File

@@ -1,37 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ath11k-firmware
PKG_SOURCE_PROTO:=git
PKG_BRANCH:=main
PKG_SOURCE_URL:=https://github.com/quic/upstream-wifi-fw.git
PKG_MIRROR_HASH:=557505744764b0442c887be3f5bb0ce924323d785b6d207899f19fad992a6020
PKG_SOURCE_VERSION:=3417bb86645c5ff4c58258db7cc33e43260b4222
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
include $(INCLUDE_DIR)/package.mk
define Package/ath11k-firmware-default
SECTION:=firmware
CATEGORY:=Firmware
URL:=$(PKG_SOURCE_URL)
DEPENDS:=
endef
define Package/ath11k-firmware-ipq95xx
$(Package/ath11k-firmware-default)
TITLE:=ath11k firmware for IPQ95xx devices
DEPENDS:=@TARGET_ipq95xx
endef
define Build/Compile
endef
define Package/ath11k-firmware-ipq95xx/install
$(INSTALL_DIR) $(1)/lib/firmware/IPQ9574/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/ath11k-firmware/IPQ9574/hw1.0/2.9.0.1/WLAN.HK.2.9.0.1-01890-QCAHKSWPL_SILICONZ-1/* \
$(1)/lib/firmware/IPQ9574/
endef
$(eval $(call BuildPackage,ath11k-firmware-ipq95xx))

View File

@@ -1,36 +0,0 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/version.mk
PKG_NAME:=ath11k-wifi
PKG_RELEASE:=1
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/package.mk
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile
endef
define Package/ath11k-wifi-default
SUBMENU:=ath11k Board-Specific Overrides
SECTION:=firmware
CATEGORY:=Firmware
DEPENDS:=@TARGET_ipq95xx
TITLE:=Custom Board
endef
define Package/ath11k-wifi-qcom-ipq95xx
$(call Package/ath11k-wifi-default)
TITLE:=board-2.bin for QCOM IPQ9574 eval kits
endef
define Package/ath11k-wifi-qcom-ipq95xx/install
$(INSTALL_DIR) $(1)/lib/firmware/ath11k/IPQ9574/hw1.0/
$(INSTALL_DATA) ./board-2.bin.IPQ9574 $(1)/lib/firmware/ath11k/IPQ9574/hw1.0/board-2.bin
endef
$(eval $(call BuildPackage,ath11k-wifi-qcom-ipq95xx))

View File

@@ -1,76 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ath12k-firmware
PKG_MIRROR_HASH:=a325f86b1d613f713d2e015abca4a9ff86c8448d4cd540fa022866da2c5aa042
PKG_SOURCE_PROTO:=git
PKG_BRANCH:=main
PKG_SOURCE_URL:=https://github.com/quic/upstream-wifi-fw.git
PKG_SOURCE_VERSION:=e90d32aaa149800ea79760639cb5ac9ddcfc8281
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
include $(INCLUDE_DIR)/package.mk
define Package/ath12k-firmware-default
SECTION:=firmware
CATEGORY:=Firmware
URL:=$(PKG_SOURCE_URL)
DEPENDS:=
endef
define Package/ath12k-firmware-qcn92xx-split-phy
$(Package/ath12k-firmware-default)
TITLE:=ath12k firmware for qcn92xx split phy devices
DEPENDS:=@(TARGET_ipq95xx||TARGET_ipq53xx)
endef
define Package/ath12k-firmware-qcn92xx
$(Package/ath12k-firmware-default)
TITLE:=ath12k firmware for qcn92xx devices
DEPENDS:=@(TARGET_ipq95xx||TARGET_ipq53xx)
endef
define Package/ath12k-firmware-ipq53xx
$(Package/ath12k-firmware-default)
TITLE:=ath12k firmware for ipq53xx devices
DEPENDS:=@TARGET_ipq53xx
endef
define Package/ath12k-firmware-ipq53xx-wk-wk
$(Package/ath12k-firmware-default)
TITLE:=ath12k firmware for ipq53xx + wk + wk devices
DEPENDS:=@TARGET_ipq53xx
endef
define Build/Compile
endef
define Package/ath12k-firmware-qcn92xx-split-phy/install
$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN92XX/hw1.0
$(CP) $(PKG_BUILD_DIR)/ath12k-firmware/QCN9274/hw2.0_split_phy/1.2.1/WLAN.WBE.1.2.1-00148-QCAHKSWPL_SILICONZ-1/* \
$(1)/lib/firmware/ath12k/QCN92XX/hw1.0
endef
define Package/ath12k-firmware-qcn92xx/install
$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN92XX/hw1.0
$(CP) $(PKG_BUILD_DIR)/ath12k-firmware/QCN9274/hw2.0/1.2.1/WLAN.WBE.1.2.1-00201-QCAHKSWPL_SILICONZ-1/* \
$(1)/lib/firmware/ath12k/QCN92XX/hw1.0
endef
define Package/ath12k-firmware-ipq53xx/install
$(INSTALL_DIR) $(1)/lib/firmware/IPQ5332/
$(CP) $(PKG_BUILD_DIR)/ath12k-firmware//IPQ5322/hw1.0/1.2.1/WLAN.WBE.1.2.1-00201-QCAHKSWPL_SILICONZ-1/* \
$(1)/lib/firmware/IPQ5332/
endef
define Package/ath12k-firmware-ipq53xx-wk-wk/install
$(INSTALL_DIR) $(1)/lib/firmware/IPQ5332/
$(CP) $(PKG_BUILD_DIR)/ath12k-firmware/IPQ5322_QCN6432_QCN6432/hw1.0/testing/1.3/WLAN.WBE.1.3-02907-QCAHKSWPL_SILICONZ-1/* \
$(1)/lib/firmware/IPQ5332/
endef
$(eval $(call BuildPackage,ath12k-firmware-qcn92xx))
$(eval $(call BuildPackage,ath12k-firmware-qcn92xx-split-phy))
$(eval $(call BuildPackage,ath12k-firmware-ipq53xx))
$(eval $(call BuildPackage,ath12k-firmware-ipq53xx-wk-wk))

View File

@@ -1,78 +0,0 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/version.mk
PKG_NAME:=ath12k-wifi
PKG_RELEASE:=1
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/package.mk
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile
endef
define Package/ath12k-wifi-default
SUBMENU:=ath12k Board-Specific Overrides
SECTION:=firmware
CATEGORY:=Firmware
DEPENDS:=@(TARGET_qcn9274||TARGET_ipq53xx)
TITLE:=Custom Board
endef
define Package/ath12k-wifi-qcom-qcn9274
$(call Package/ath12k-wifi-default)
TITLE:=board-2.bin for QCOM QCN9274 eval kits
endef
define Package/ath12k-wifi-qcom-qcn9274/install
$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN9274/hw1.0/
$(INSTALL_DATA) ./board-2.bin.QCN9274 $(1)/lib/firmware/ath12k/QCN9274/hw1.0/board-2.bin
endef
define Package/ath12k-wifi-cig-wf189
$(call Package/ath12k-wifi-default)
TITLE:=board.bin for CIG WF189
endef
define Package/ath12k-wifi-edgecore-eap105
$(call Package/ath12k-wifi-default)
TITLE:=board.bin for Edgecore EAP105
endef
define Package/ath12k-wifi-sercomm-ap72tip
$(call Package/ath12k-wifi-default)
TITLE:=board.bin for Sercomm WIFI-7
endef
define Package/ath12k-wifi-cig-wf189/install
$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN92XX/hw1.0 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0
$(INSTALL_DATA) ./regdb.bin $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/
$(INSTALL_DATA) ./board-cig-wf189.bin.qcn9224 $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/board.bin
$(INSTALL_DATA) ./regdb.bin $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/
$(INSTALL_DATA) ./board-cig-wf189.bin.ipq53xx $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board.bin
endef
define Package/ath12k-wifi-edgecore-eap105/install
$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN92XX/hw1.0 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0
$(INSTALL_DATA) ./regdb.bin $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/
$(INSTALL_DATA) ./board-edgecore-eap105.bin.qcn9224 $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/board.bin
$(INSTALL_DATA) ./regdb.bin $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/
$(INSTALL_DATA) ./board-edgecore-eap105.bin.ipq53xx $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board.bin
endef
define Package/ath12k-wifi-sercomm-ap72tip/install
$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN92XX/hw1.0 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0
$(INSTALL_DATA) ./regdb.bin $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/
$(INSTALL_DATA) ./board-sercomm-ap72tip.bin.qcn9224 $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/board.bin
$(INSTALL_DATA) ./regdb.bin $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/
$(INSTALL_DATA) ./board-sercomm-ap72tip.bin.ipq53xx $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board.bin
endef
$(eval $(call BuildPackage,ath12k-wifi-qcom-qcn9274))
$(eval $(call BuildPackage,ath12k-wifi-cig-wf189))
$(eval $(call BuildPackage,ath12k-wifi-edgecore-eap105))
$(eval $(call BuildPackage,ath12k-wifi-sercomm-ap72tip))

Binary file not shown.

View File

@@ -1,88 +0,0 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2007-2019 B.A.T.M.A.N. contributors:
#
# Marek Lindner, Simon Wunderlich
#
# B.A.T.M.A.N meshing protocol
#
config BATMAN_ADV_BATMAN_V
bool "B.A.T.M.A.N. V protocol"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables the B.A.T.M.A.N. V protocol, the successor
of the currently used B.A.T.M.A.N. IV protocol. The main
changes include splitting of the OGM protocol into a neighbor
discovery protocol (Echo Location Protocol, ELP) and a new OGM
Protocol OGMv2 for flooding protocol information through the
network, as well as a throughput based metric.
B.A.T.M.A.N. V is currently considered experimental and not
compatible to B.A.T.M.A.N. IV networks.
config BATMAN_ADV_BLA
bool "Bridge Loop Avoidance"
depends on PACKAGE_kmod-batman-adv
select PACKAGE_kmod-lib-crc16
default y
help
This option enables BLA (Bridge Loop Avoidance), a mechanism
to avoid Ethernet frames looping when mesh nodes are connected
to both the same LAN and the same mesh. If you will never use
more than one mesh node in the same LAN, you can safely remove
this feature and save some space.
config BATMAN_ADV_DAT
bool "Distributed ARP Table"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables DAT (Distributed ARP Table), a DHT based
mechanism that increases ARP reliability on sparse wireless
mesh networks. If you think that your network does not need
this option you can safely remove it and save some space.
config BATMAN_ADV_NC
bool "Network Coding"
depends on PACKAGE_kmod-batman-adv
help
This option enables network coding, a mechanism that aims to
increase the overall network throughput by fusing multiple
packets in one transmission.
Note that interfaces controlled by batman-adv must be manually
configured to have promiscuous mode enabled in order to make
network coding work.
If you think that your network does not need this feature you
can safely disable it and save some space.
config BATMAN_ADV_MCAST
bool "Multicast optimisation"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables the multicast optimisation which aims to
reduce the air overhead while improving the reliability of
multicast messages.
config BATMAN_ADV_DEBUG
bool "B.A.T.M.A.N. debugging"
depends on PACKAGE_kmod-batman-adv
help
This is an option for use by developers; most people should
say N here. This enables compilation of support for
outputting debugging information to the debugfs log or tracing
buffer. The output is controlled via the batadv netdev specific
log_level setting.
config BATMAN_ADV_TRACING
bool "B.A.T.M.A.N. tracing support"
depends on PACKAGE_kmod-batman-adv
select KERNEL_FTRACE
select KERNEL_ENABLE_DEFAULT_TRACERS
help
This is an option for use by developers; most people should
say N here. Select this option to gather traces like the debug
messages using the generic tracing infrastructure of the kernel.
BATMAN_ADV_DEBUG must also be selected to get trace events for
batadv_dbg.

View File

@@ -1,101 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-only
include $(TOPDIR)/rules.mk
PKG_NAME:=batman-adv
PKG_VERSION:=2022.0
PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_HASH:=49338705bc207709ac84d766688e702571009c827c0a320788ea51fb887714aa
PKG_EXTMOD_SUBDIRS:=net/batman-adv
PKG_MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
PKG_LICENSE:=GPL-2.0-only MIT
PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT
PKG_BUILD_PARALLEL:=1
STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
PKG_CONFIG_DEPENDS += \
CONFIG_BATMAN_ADV_BATMAN_V \
CONFIG_BATMAN_ADV_BLA \
CONFIG_BATMAN_ADV_DAT \
CONFIG_BATMAN_ADV_NC \
CONFIG_BATMAN_ADV_MCAST \
CONFIG_BATMAN_ADV_DEBUG \
CONFIG_BATMAN_ADV_TRACING
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk
define KernelPackage/batman-adv
SUBMENU:=Network Support
TITLE:=B.A.T.M.A.N. Adv
URL:=https://www.open-mesh.org/
DEPENDS:=+BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211 +batctl
FILES:=$(PKG_BUILD_DIR)/net/batman-adv/batman-adv.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoProbe,batman-adv)
endef
define KernelPackage/batman-adv/description
B.A.T.M.A.N. (better approach to mobile ad-hoc networking) is
a routing protocol for multi-hop ad-hoc mesh networks. The
networks may be wired or wireless. See
https://www.open-mesh.org/ for more information and user space
tools. This package builds version $(PKG_VERSION) of the kernel
module.
endef
define KernelPackage/batman-adv/config
source "$(SOURCE)/Config.in"
endef
define Package/kmod-batman-adv/conffiles
/etc/config/batman-adv
endef
PKG_EXTRA_KCONFIG:= \
CONFIG_BATMAN_ADV=m \
CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_BATMAN_ADV_DEBUG),y,n) \
CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_BATMAN_ADV_BLA),y,n) \
CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_BATMAN_ADV_DAT),y,n) \
CONFIG_BATMAN_ADV_MCAST=$(if $(CONFIG_BATMAN_ADV_MCAST),y,n) \
CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_BATMAN_ADV_NC),y,n) \
CONFIG_BATMAN_ADV_BATMAN_V=$(if $(CONFIG_BATMAN_ADV_BATMAN_V),y,n) \
CONFIG_BATMAN_ADV_TRACING=$(if $(CONFIG_BATMAN_ADV_TRACING),y,n) \
PKG_EXTRA_CFLAGS:= \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(PKG_EXTRA_KCONFIG)))) \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(PKG_EXTRA_KCONFIG)))) \
NOSTDINC_FLAGS = \
$(KERNEL_NOSTDINC_FLAGS) \
-I$(PKG_BUILD_DIR)/net/batman-adv \
-I$(STAGING_DIR)/usr/include/mac80211-backport \
-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
-I$(STAGING_DIR)/usr/include/mac80211 \
-I$(STAGING_DIR)/usr/include/mac80211/uapi \
-I$(PKG_BUILD_DIR)/include/ \
-include backport/autoconf.h \
-include backport/backport.h \
-include $(PKG_BUILD_DIR)/compat-hacks.h \
-DBATADV_SOURCE_VERSION=\\\"$(PKG_VERSION)-openwrt-$(PKG_RELEASE)\\\"
define Build/Compile
$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
$(KERNEL_MAKE_FLAGS) \
M="$(PKG_BUILD_DIR)/net/batman-adv" \
$(PKG_EXTRA_KCONFIG) \
EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS)" \
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
modules
endef
define KernelPackage/batman-adv/install
$(CP) ./files/. $(1)/
endef
$(eval $(call KernelPackage,batman-adv))

View File

@@ -1,97 +0,0 @@
#!/bin/sh
# This UCI-Defaults script will split the batadv proto network interfaces
# in batadv_hardif and batadv proto. The configuration options from
# /etc/config/batman-adv will be moved to the latter.
. /lib/functions.sh
proto_batadv_to_batadv_hardif() {
local section="$1"
local proto
local mesh
local routing_algo
config_get proto "${section}" proto
config_get mesh "${section}" mesh
config_get routing_algo "${section}" routing_algo
if [ -z "$mesh" -o "${proto}" != "batadv" ]; then
continue
fi
uci set network."${section}".proto="batadv_hardif"
uci rename network."${section}".mesh="master"
uci delete network."${section}".routing_algo
# create new section or adjust existing one
uci set network."${mesh}"=interface
uci set network."${mesh}".proto=batadv
[ -n "${routing_algo}" ] && uci set network."${mesh}".routing_algo="${routing_algo}"
}
mv_batadv_config_section() {
local section="$1"
local aggregated_ogms
local ap_isolation
local bonding
local bridge_loop_avoidance
local distributed_arp_table
local fragmentation
local gw_bandwidth
local gw_mode
local gw_sel_class
local hop_penalty
local isolation_mark
local log_level
local multicast_mode
local network_coding
local orig_interval
config_get aggregated_ogms "${section}" aggregated_ogms
config_get ap_isolation "${section}" ap_isolation
config_get bonding "${section}" bonding
config_get bridge_loop_avoidance "${section}" bridge_loop_avoidance
config_get distributed_arp_table "${section}" distributed_arp_table
config_get fragmentation "${section}" fragmentation
config_get gw_bandwidth "${section}" gw_bandwidth
config_get gw_mode "${section}" gw_mode
config_get gw_sel_class "${section}" gw_sel_class
config_get hop_penalty "${section}" hop_penalty
config_get isolation_mark "${section}" isolation_mark
config_get log_level "${section}" log_level
config_get multicast_mode "${section}" multicast_mode
config_get network_coding "${section}" network_coding
config_get orig_interval "${section}" orig_interval
# update section in case it exists
[ -n "${aggregated_ogms}" ] && uci set network."${section}".aggregated_ogms="${aggregated_ogms}"
[ -n "${ap_isolation}" ] && uci set network."${section}".ap_isolation="${ap_isolation}"
[ -n "${bonding}" ] && uci set network."${section}".bonding="${bonding}"
[ -n "${bridge_loop_avoidance}" ] && uci set network."${section}".bridge_loop_avoidance="${bridge_loop_avoidance}"
[ -n "${distributed_arp_table}" ] && uci set network."${section}".distributed_arp_table="${distributed_arp_table}"
[ -n "${fragmentation}" ] && uci set network."${section}".fragmentation="${fragmentation}"
[ -n "${gw_bandwidth}" ] && uci set network."${section}".gw_bandwidth="${gw_bandwidth}"
[ -n "${gw_mode}" ] && uci set network."${section}".gw_mode="${gw_mode}"
[ -n "${gw_sel_class}" ] && uci set network."${section}".gw_sel_class="${gw_sel_class}"
[ -n "${hop_penalty}" ] && uci set network."${section}".hop_penalty="${hop_penalty}"
[ -n "${isolation_mark}" ] && uci set network."${section}".isolation_mark="${isolation_mark}"
[ -n "${log_level}" ] && uci set network."${section}".log_level="${log_level}"
[ -n "${multicast_mode}" ] && uci set network."${section}".multicast_mode="${multicast_mode}"
[ -n "${network_coding}" ] && uci set network."${section}".network_coding="${network_coding}"
[ -n "${orig_interval}" ] && uci set network."${section}".orig_interval="${orig_interval}"
}
if [ -f /etc/config/batman-adv ]; then
config_load network
config_foreach proto_batadv_to_batadv_hardif 'interface'
uci commit network
config_load batman-adv
config_foreach mv_batadv_config_section 'mesh'
uci commit network
rm -f /etc/config/batman-adv
fi
exit 0

View File

@@ -1,123 +0,0 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
proto_batadv_init_config() {
no_device=1
available=1
proto_config_add_boolean 'aggregated_ogms:bool'
proto_config_add_boolean 'ap_isolation:bool'
proto_config_add_boolean 'bonding:bool'
proto_config_add_boolean 'bridge_loop_avoidance:bool'
proto_config_add_boolean 'distributed_arp_table:bool'
proto_config_add_boolean 'fragmentation:bool'
proto_config_add_string 'gw_bandwidth'
proto_config_add_string 'gw_mode'
proto_config_add_int 'gw_sel_class'
proto_config_add_int 'hop_penalty'
proto_config_add_string 'isolation_mark'
proto_config_add_string 'log_level'
proto_config_add_int 'multicast_fanout'
proto_config_add_boolean 'multicast_mode:bool'
proto_config_add_boolean 'network_coding:bool'
proto_config_add_int 'orig_interval'
proto_config_add_string 'routing_algo'
}
proto_batadv_setup() {
local config="$1"
local iface="$config"
local aggregated_ogms
local ap_isolation
local bonding
local bridge_loop_avoidance
local distributed_arp_table
local fragmentation
local gw_bandwidth
local gw_mode
local gw_sel_class
local hop_penalty
local isolation_mark
local log_level
local multicast_fanout
local multicast_mode
local network_coding
local orig_interval
local routing_algo
json_get_vars aggregated_ogms
json_get_vars ap_isolation
json_get_vars bonding
json_get_vars bridge_loop_avoidance
json_get_vars distributed_arp_table
json_get_vars fragmentation
json_get_vars gw_bandwidth
json_get_vars gw_mode
json_get_vars gw_sel_class
json_get_vars hop_penalty
json_get_vars isolation_mark
json_get_vars log_level
json_get_vars multicast_fanout
json_get_vars multicast_mode
json_get_vars network_coding
json_get_vars orig_interval
json_get_vars routing_algo
set_default routing_algo 'BATMAN_IV'
batctl routing_algo "$routing_algo"
batctl meshif "$iface" interface create
[ -n "$aggregated_ogms" ] && batctl meshif "$iface" aggregation "$aggregated_ogms"
[ -n "$ap_isolation" ] && batctl meshif "$iface" ap_isolation "$ap_isolation"
[ -n "$bonding" ] && batctl meshif "$iface" bonding "$bonding"
[ -n "$bridge_loop_avoidance" ] && batctl meshif "$iface" bridge_loop_avoidance "$bridge_loop_avoidance" 2>&-
[ -n "$distributed_arp_table" ] && batctl meshif "$iface" distributed_arp_table "$distributed_arp_table" 2>&-
[ -n "$fragmentation" ] && batctl meshif "$iface" fragmentation "$fragmentation"
case "$gw_mode" in
server)
if [ -n "$gw_bandwidth" ]; then
batctl meshif "$iface" gw_mode "server" "$gw_bandwidth"
else
batctl meshif "$iface" gw_mode "server"
fi
;;
client)
if [ -n "$gw_sel_class" ]; then
batctl meshif "$iface" gw_mode "client" "$gw_sel_class"
else
batctl meshif "$iface" gw_mode "client"
fi
;;
*)
batctl meshif "$iface" gw_mode "off"
;;
esac
[ -n "$hop_penalty" ] && batctl meshif "$iface" hop_penalty "$hop_penalty"
[ -n "$isolation_mark" ] && batctl meshif "$iface" isolation_mark "$isolation_mark"
[ -n "$multicast_fanout" ] && batctl meshif "$iface" multicast_fanout "$multicast_fanout"
[ -n "$multicast_mode" ] && batctl meshif "$iface" multicast_mode "$multicast_mode" 2>&-
[ -n "$network_coding" ] && batctl meshif "$iface" network_coding "$network_coding" 2>&-
[ -n "$log_level" ] && batctl meshif "$iface" loglevel "$log_level" 2>&-
[ -n "$orig_interval" ] && batctl meshif "$iface" orig_interval "$orig_interval"
proto_init_update "$iface" 1
proto_send_update "$config"
}
proto_batadv_teardown() {
local config="$1"
local iface="$config"
batctl meshif "$iface" interface destroy
}
add_protocol batadv

View File

@@ -1,53 +0,0 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
proto_batadv_hardif_init_config() {
proto_config_add_int 'elp_interval'
proto_config_add_int 'hop_penalty'
proto_config_add_string "master"
proto_config_add_string 'throughput_override'
}
proto_batadv_hardif_setup() {
local config="$1"
local iface="$2"
local elp_interval
local hop_penalty
local master
local throughput_override
json_get_vars elp_interval
json_get_vars hop_penalty
json_get_vars master
json_get_vars throughput_override
( proto_add_host_dependency "$config" '' "$master" )
batctl meshif "$master" interface -M add "$iface"
[ -n "$elp_interval" ] && batctl hardif "$iface" elp_interval "$elp_interval"
[ -n "$hop_penalty" ] && batctl hardif "$iface" hop_penalty "$hop_penalty"
[ -n "$throughput_override" ] && batctl hardif "$iface" throughput_override "$throughput_override"
proto_init_update "$iface" 1
proto_send_update "$config"
}
proto_batadv_hardif_teardown() {
local config="$1"
local iface="$2"
local master
json_get_vars master
batctl meshif "$master" interface -M del "$iface" || true
}
add_protocol batadv_hardif

View File

@@ -1,25 +0,0 @@
#!/bin/sh
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
proto_batadv_vlan_init_config() {
proto_config_add_boolean 'ap_isolation:bool'
}
proto_batadv_vlan_setup() {
local config="$1"
local iface="$2"
# batadv_vlan options
local ap_isolation
json_get_vars ap_isolation
[ -n "$ap_isolation" ] && batctl vlan "$iface" ap_isolation "$ap_isolation"
proto_init_update "$iface" 1
proto_send_update "$config"
}
add_protocol batadv_vlan

View File

@@ -1,128 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 24 Oct 2020 22:51:23 +0200
Subject: Revert "batman-adv: genetlink: move to smaller ops wherever possible"
The netlink genl_ops interface was splitted into two parts for Linux 5.10.
The batman-adv code changed to the new one because it doesn't use the more
complex policy handling of genl_ops. But the backports-5.8-1 version in
OpenWrt doesn't yet support the new genl_small_ops.
This patch must be dropped directly when OpenWrt switches to backports-5.10
or newer - otherwise it will not work as expected.
This reverts commit 725b4ef5be840cfcd0ca33b9393c14dee40c10f7.
--- a/compat-include/net/genetlink.h
+++ b/compat-include/net/genetlink.h
@@ -31,17 +31,15 @@ void batadv_genl_dump_check_consistent(s
#endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */
-#if LINUX_VERSION_IS_LESS(5, 10, 0)
-
#if LINUX_VERSION_IS_LESS(5, 2, 0)
+
enum genl_validate_flags {
GENL_DONT_VALIDATE_STRICT = BIT(0),
GENL_DONT_VALIDATE_DUMP = BIT(1),
GENL_DONT_VALIDATE_DUMP_STRICT = BIT(2),
};
-#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
-struct batadv_genl_small_ops {
+struct batadv_genl_ops {
int (*doit)(struct sk_buff *skb,
struct genl_info *info);
int (*dumpit)(struct sk_buff *skb,
@@ -70,9 +68,9 @@ struct batadv_genl_family {
struct genl_info *info);
void (*post_doit)(const struct genl_ops *ops, struct sk_buff *skb,
struct genl_info *info);
- const struct batadv_genl_small_ops *small_ops;
+ const struct batadv_genl_ops *ops;
const struct genl_multicast_group *mcgrps;
- unsigned int n_small_ops;
+ unsigned int n_ops;
unsigned int n_mcgrps;
struct module *module;
@@ -96,32 +94,24 @@ static inline int batadv_genl_register_f
family->family.pre_doit = family->pre_doit;
family->family.post_doit = family->post_doit;
family->family.mcgrps = family->mcgrps;
- family->family.n_ops = family->n_small_ops;
+ family->family.n_ops = family->n_ops;
family->family.n_mcgrps = family->n_mcgrps;
family->family.module = family->module;
- ops = kzalloc(sizeof(*ops) * family->n_small_ops, GFP_KERNEL);
+ ops = kzalloc(sizeof(*ops) * family->n_ops, GFP_KERNEL);
if (!ops)
return -ENOMEM;
for (i = 0; i < family->family.n_ops; i++) {
- ops[i].doit = family->small_ops[i].doit;
- ops[i].dumpit = family->small_ops[i].dumpit;
- ops[i].done = family->small_ops[i].done;
- ops[i].cmd = family->small_ops[i].cmd;
- ops[i].internal_flags = family->small_ops[i].internal_flags;
- ops[i].flags = family->small_ops[i].flags;
-#if LINUX_VERSION_IS_GEQ(5, 2, 0)
- ops[i].validate = family->small_ops[i].validate;
-#else
+ ops[i].doit = family->ops[i].doit;
+ ops[i].dumpit = family->ops[i].dumpit;
+ ops[i].done = family->ops[i].done;
+ ops[i].cmd = family->ops[i].cmd;
+ ops[i].internal_flags = family->ops[i].internal_flags;
+ ops[i].flags = family->ops[i].flags;
ops[i].policy = family->policy;
-#endif
}
-#if LINUX_VERSION_IS_GEQ(5, 2, 0)
- family->family.policy = family->policy;
-#endif
-
family->family.ops = ops;
family->copy_ops = ops;
@@ -136,7 +126,7 @@ typedef struct genl_ops batadv_genl_ops_
#define batadv_post_doit(__x, __y, __z) \
batadv_post_doit(const batadv_genl_ops_old *ops, __y, __z)
-#define genl_small_ops batadv_genl_small_ops
+#define genl_ops batadv_genl_ops
#define genl_family batadv_genl_family
#define genl_register_family(family) \
@@ -160,6 +150,6 @@ batadv_genl_unregister_family(struct bat
genlmsg_multicast_netns(&(_family)->family, _net, _skb, _portid, \
_group, _flags)
-#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */
+#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -1357,7 +1357,7 @@ static void batadv_post_doit(const struc
}
}
-static const struct genl_small_ops batadv_netlink_ops[] = {
+static const struct genl_ops batadv_netlink_ops[] = {
{
.cmd = BATADV_CMD_GET_MESH,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -1491,8 +1491,8 @@ struct genl_family batadv_netlink_family
.pre_doit = batadv_pre_doit,
.post_doit = batadv_post_doit,
.module = THIS_MODULE,
- .small_ops = batadv_netlink_ops,
- .n_small_ops = ARRAY_SIZE(batadv_netlink_ops),
+ .ops = batadv_netlink_ops,
+ .n_ops = ARRAY_SIZE(batadv_netlink_ops),
.mcgrps = batadv_netlink_mcgrps,
.n_mcgrps = ARRAY_SIZE(batadv_netlink_mcgrps),
};

View File

@@ -1,116 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 28 Jan 2021 21:06:51 +0100
Subject: Revert "batman-adv: Add new include for min/max helpers"
The OpenWrt kernel sources and backports sources are currently missing this
header.
This reverts commit 1810de05310d5c5e9140f870ac21052f38bc06b8.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
--- a/compat-include/linux/minmax.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) B.A.T.M.A.N. contributors:
- *
- * Marek Lindner, Simon Wunderlich
- *
- * This file contains macros for maintaining compatibility with older versions
- * of the Linux kernel.
- */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_MINMAX_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_MINMAX_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(5, 10, 0)
-#include_next <linux/minmax.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_MINMAX_H_ */
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -15,7 +15,6 @@
#include <linux/jiffies.h>
#include <linux/kref.h>
#include <linux/list.h>
-#include <linux/minmax.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/rculist.h>
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -18,7 +18,6 @@
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/kref.h>
-#include <linux/minmax.h>
#include <linux/netdevice.h>
#include <linux/nl80211.h>
#include <linux/prandom.h>
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -18,7 +18,6 @@
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
-#include <linux/minmax.h>
#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/prandom.h>
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -14,8 +14,8 @@
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/lockdep.h>
-#include <linux/minmax.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -17,7 +17,6 @@
#include <linux/kref.h>
#include <linux/limits.h>
#include <linux/list.h>
-#include <linux/minmax.h>
#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/printk.h>
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -23,7 +23,6 @@
#include <linux/kobject.h>
#include <linux/kref.h>
#include <linux/list.h>
-#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/printk.h>
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -23,7 +23,6 @@
#include <linux/kernel.h>
#include <linux/limits.h>
#include <linux/list.h>
-#include <linux/minmax.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/printk.h>
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -23,7 +23,6 @@
#include <linux/kthread.h>
#include <linux/limits.h>
#include <linux/list.h>
-#include <linux/minmax.h>
#include <linux/netdevice.h>
#include <linux/param.h>
#include <linux/printk.h>

View File

@@ -1,34 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 14 May 2021 19:34:35 +0200
Subject: batman-adv: Fix build of multicast code against Linux < 5.13
Fixes: 007b4c4b031f ("batman-adv: convert ifmcaddr6 to RCU")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -422,9 +422,14 @@ batadv_mcast_mla_softif_get_ipv6(struct
return 0;
}
+#if LINUX_VERSION_IS_LESS(5, 13, 0)
+ read_lock_bh(&in6_dev->lock);
+ for (pmc6 = in6_dev->mc_list; pmc6; pmc6 = pmc6->next) {
+#else
for (pmc6 = rcu_dereference(in6_dev->mc_list);
pmc6;
pmc6 = rcu_dereference(pmc6->next)) {
+#endif
if (IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) <
IPV6_ADDR_SCOPE_LINKLOCAL)
continue;
@@ -453,6 +458,9 @@ batadv_mcast_mla_softif_get_ipv6(struct
hlist_add_head(&new->list, mcast_list);
ret++;
}
+#if LINUX_VERSION_IS_LESS(5, 13, 0)
+ read_unlock_bh(&in6_dev->lock);
+#endif
rcu_read_unlock();
return ret;

View File

@@ -1,19 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Tue, 14 Sep 2021 21:02:10 +0200
Subject: Revert "batman-adv: Switch to kstrtox.h for kstrtou64"
This header is only available after Linux 5.14
This reverts commit c9a69cb4048ebef3a4d91835669011a26d9b7dab.
--- a/net/batman-adv/gateway_common.c
+++ b/net/batman-adv/gateway_common.c
@@ -10,7 +10,7 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
#include <linux/errno.h>
-#include <linux/kstrtox.h>
+#include <linux/kernel.h>
#include <linux/limits.h>
#include <linux/math64.h>
#include <linux/netdevice.h>

View File

@@ -1,19 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Tue, 14 Sep 2021 21:07:34 +0200
Subject: Revert "batman-adv: use Linux's stdarg.h"
This header is only available since Linux 5.15
This reverts commit 36d059797a14f0e373fdc3c79df7b467435925ad.
--- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c
@@ -7,7 +7,7 @@
#include "log.h"
#include "main.h"
-#include <linux/stdarg.h>
+#include <stdarg.h>
#include "trace.h"

View File

@@ -1,27 +0,0 @@
From: Eric Dumazet <edumazet@google.com>
Date: Wed, 2 Mar 2022 20:05:13 +0100
Subject: batman-adv: make mc_forwarding atomic
This fixes minor data-races in ip6_mc_input() and
batadv_mcast_mla_rtr_flags_softif_get_ipv6()
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[sven@narfation.org: Add ugly hack to get it building with old kernels]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/56db7c0540e733a1f063ccd6bab1b537a80857eb
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -134,7 +134,11 @@ static u8 batadv_mcast_mla_rtr_flags_sof
{
struct inet6_dev *in6_dev = __in6_dev_get(dev);
+#if LINUX_VERSION_IS_GEQ(5, 18, 0) // UGLY_HACK_NEW
+ if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding))
+#else // UGLY_HACK_OLD
if (in6_dev && in6_dev->cnf.mc_forwarding)
+#endif // UGLY_HACK_STOP
return BATADV_NO_FLAGS;
else
return BATADV_MCAST_WANT_NO_RTR6;

View File

@@ -1,23 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 15 Apr 2022 15:12:45 +0200
Subject: batman-adv: compat: Add atomic mc_fowarding support for stable kernels
Fixes: 56db7c0540e7 ("batman-adv: make mc_forwarding atomic")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/350adcaec82fbaa358a2406343b6130ac8dad126
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -134,7 +134,11 @@ static u8 batadv_mcast_mla_rtr_flags_sof
{
struct inet6_dev *in6_dev = __in6_dev_get(dev);
-#if LINUX_VERSION_IS_GEQ(5, 18, 0) // UGLY_HACK_NEW
+#if (LINUX_VERSION_IS_GEQ(5, 4, 189) && LINUX_VERSION_IS_LESS(5, 5, 0)) || /* UGLY_HACK */ \
+ (LINUX_VERSION_IS_GEQ(5, 10, 111) && LINUX_VERSION_IS_LESS(5, 11, 0)) || /* UGLY_HACK */ \
+ (LINUX_VERSION_IS_GEQ(5, 15, 34) && LINUX_VERSION_IS_LESS(5, 16, 0)) || /* UGLY_HACK */ \
+ (LINUX_VERSION_IS_GEQ(5, 16, 20) && LINUX_VERSION_IS_LESS(5, 17, 0)) || /* UGLY_HACK */ \
+ LINUX_VERSION_IS_GEQ(5, 17, 3) // UGLY_HACK_NEW
if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding))
#else // UGLY_HACK_OLD
if (in6_dev && in6_dev->cnf.mc_forwarding)

View File

@@ -1,44 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Wed, 2 Mar 2022 19:49:44 +0100
Subject: batman-adv: Request iflink once in batadv-on-batadv check
There is no need to call dev_get_iflink multiple times for the same
net_device in batadv_is_on_batman_iface. And since some of the
.ndo_get_iflink callbacks are dynamic (for example via RCUs like in
vxcan_get_iflink), it could easily happen that the returned values are not
stable. The pre-checks before __dev_get_by_index are then of course bogus.
Fixes: 3d48811b27f5 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/f6c0c45356fe3ab9c5e01b81d060f8a436658037
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -148,22 +148,23 @@ static bool batadv_is_on_batman_iface(co
struct net *net = dev_net(net_dev);
struct net_device *parent_dev;
struct net *parent_net;
+ int iflink;
bool ret;
/* check if this is a batman-adv mesh interface */
if (batadv_softif_is_valid(net_dev))
return true;
+ iflink = dev_get_iflink(net_dev);
+
/* no more parents..stop recursion */
- if (dev_get_iflink(net_dev) == 0 ||
- dev_get_iflink(net_dev) == net_dev->ifindex)
+ if (iflink == 0 || iflink == net_dev->ifindex)
return false;
parent_net = batadv_getlink_net(net_dev, net);
/* recurse over the parent device */
- parent_dev = __dev_get_by_index((struct net *)parent_net,
- dev_get_iflink(net_dev));
+ parent_dev = __dev_get_by_index((struct net *)parent_net, iflink);
/* if we got a NULL parent_dev there is something broken.. */
if (!parent_dev) {
pr_err("Cannot find parent device\n");

View File

@@ -1,46 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Wed, 2 Mar 2022 19:49:45 +0100
Subject: batman-adv: Request iflink once in batadv_get_real_netdevice
There is no need to call dev_get_iflink multiple times for the same
net_device in batadv_get_real_netdevice. And since some of the
ndo_get_iflink callbacks are dynamic (for example via RCUs like in
vxcan_get_iflink), it could easily happen that the returned values are not
stable. The pre-checks before __dev_get_by_index are then of course bogus.
Fixes: 2b45bb6c3aad ("batman-adv: additional checks for virtual interfaces on top of WiFi")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/445f477ec3e805425186f5fbe8ed0fe89cc226b6
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -214,14 +214,16 @@ static struct net_device *batadv_get_rea
struct net_device *real_netdev = NULL;
struct net *real_net;
struct net *net;
- int ifindex;
+ int iflink;
ASSERT_RTNL();
if (!netdev)
return NULL;
- if (netdev->ifindex == dev_get_iflink(netdev)) {
+ iflink = dev_get_iflink(netdev);
+
+ if (netdev->ifindex == iflink) {
dev_hold(netdev);
return netdev;
}
@@ -231,9 +233,8 @@ static struct net_device *batadv_get_rea
goto out;
net = dev_net(hard_iface->soft_iface);
- ifindex = dev_get_iflink(netdev);
real_net = batadv_getlink_net(netdev, net);
- real_netdev = dev_get_by_index(real_net, ifindex);
+ real_netdev = dev_get_by_index(real_net, iflink);
out:
batadv_hardif_put(hard_iface);

View File

@@ -1,86 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Wed, 2 Mar 2022 19:49:46 +0100
Subject: batman-adv: Don't expect inter-netns unique iflink indices
The ifindex doesn't have to be unique for multiple network namespaces on
the same machine.
$ ip netns add test1
$ ip -net test1 link add dummy1 type dummy
$ ip netns add test2
$ ip -net test2 link add dummy2 type dummy
$ ip -net test1 link show dev dummy1
6: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 96:81:55:1e:dd:85 brd ff:ff:ff:ff:ff:ff
$ ip -net test2 link show dev dummy2
6: dummy2: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 5a:3c:af:35:07:c3 brd ff:ff:ff:ff:ff:ff
But the batman-adv code to walk through the various layers of virtual
interfaces uses this assumption because dev_get_iflink handles it
internally and doesn't return the actual netns of the iflink. And
dev_get_iflink only documents the situation where ifindex == iflink for
physical devices.
But only checking for dev->netdev_ops->ndo_get_iflink is also not an option
because ipoib_get_iflink implements it even when it sometimes returns an
iflink != ifindex and sometimes iflink == ifindex. The caller must
therefore make sure itself to check both netns and iflink + ifindex for
equality. Only when they are equal, a "physical" interface was detected
which should stop the traversal. On the other hand, vxcan_get_iflink can
also return 0 in case there was currently no valid peer. In this case, it
is still necessary to stop.
Fixes: 3d48811b27f5 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
Fixes: 2b45bb6c3aad ("batman-adv: additional checks for virtual interfaces on top of WiFi")
Reported-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/0aac7a9fbbbeec25f2f54a9e6d53ea91217ba720
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -156,13 +156,15 @@ static bool batadv_is_on_batman_iface(co
return true;
iflink = dev_get_iflink(net_dev);
-
- /* no more parents..stop recursion */
- if (iflink == 0 || iflink == net_dev->ifindex)
+ if (iflink == 0)
return false;
parent_net = batadv_getlink_net(net_dev, net);
+ /* iflink to itself, most likely physical device */
+ if (net == parent_net && iflink == net_dev->ifindex)
+ return false;
+
/* recurse over the parent device */
parent_dev = __dev_get_by_index((struct net *)parent_net, iflink);
/* if we got a NULL parent_dev there is something broken.. */
@@ -222,8 +224,7 @@ static struct net_device *batadv_get_rea
return NULL;
iflink = dev_get_iflink(netdev);
-
- if (netdev->ifindex == iflink) {
+ if (iflink == 0) {
dev_hold(netdev);
return netdev;
}
@@ -234,6 +235,14 @@ static struct net_device *batadv_get_rea
net = dev_net(hard_iface->soft_iface);
real_net = batadv_getlink_net(netdev, net);
+
+ /* iflink to itself, most likely physical device */
+ if (net == real_net && netdev->ifindex == iflink) {
+ real_netdev = netdev;
+ dev_hold(real_netdev);
+ goto out;
+ }
+
real_netdev = dev_get_by_index(real_net, iflink);
out:

View File

@@ -1,46 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 16 Apr 2022 14:24:34 +0200
Subject: batman-adv: Don't skb_split skbuffs with frag_list
The receiving interface might have used GRO to receive more fragments than
MAX_SKB_FRAGS fragments. In this case, these will not be stored in
skb_shinfo(skb)->frags but merged into the frag list.
batman-adv relies on the function skb_split to split packets up into
multiple smaller packets which are not larger than the MTU on the outgoing
interface. But this function cannot handle frag_list entries and is only
operating on skb_shinfo(skb)->frags. If it is still trying to split such an
skb and xmit'ing it on an interface without support for NETIF_F_FRAGLIST,
then validate_xmit_skb() will try to linearize it. But this fails due to
inconsistent information. And __pskb_pull_tail will trigger a BUG_ON after
skb_copy_bits() returns an error.
In case of entries in frag_list, just linearize the skb before operating on
it with skb_split().
Reported-by: Felix Kaechele <felix@kaechele.ca>
Tested-by: Felix Kaechele <felix@kaechele.ca>
Fixes: 9de347143505 ("batman-adv: layer2 unicast packet fragmentation")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d467720acaf1b22b0cee58144eeaf9ef6c5e285c
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -475,6 +475,17 @@ int batadv_frag_send_packet(struct sk_bu
goto free_skb;
}
+ /* GRO might have added fragments to the fragment list instead of
+ * frags[]. But this is not handled by skb_split and must be
+ * linearized to avoid incorrect length information after all
+ * batman-adv fragments were created and submitted to the
+ * hard-interface
+ */
+ if (skb_has_frag_list(skb) && __skb_linearize(skb)) {
+ ret = -ENOMEM;
+ goto free_skb;
+ }
+
/* Create one header to be copied to all fragments */
frag_header.packet_type = BATADV_UNICAST_FRAG;
frag_header.version = BATADV_COMPAT_VERSION;

View File

@@ -1,179 +0,0 @@
/* Please avoid adding hacks here - instead add it to mac80211/backports.git */
#undef CONFIG_MODULE_STRIPPED
#include <linux/version.h> /* LINUX_VERSION_CODE */
#include <linux/types.h>
#if LINUX_VERSION_IS_LESS(5, 10, 0)
#include <linux/if_bridge.h>
struct batadv_br_ip {
union {
__be32 ip4;
#if IS_ENABLED(CONFIG_IPV6)
struct in6_addr ip6;
#endif
} dst;
__be16 proto;
__u16 vid;
};
struct batadv_br_ip_list {
struct list_head list;
struct batadv_br_ip addr;
};
#if 0
/* "static" dropped to force compiler to evaluate it as part of multicast.c
* might need to be added again and then called in some kind of dummy
* compat.c in case this header is included in multiple files.
*/
inline void __batadv_br_ip_list_check(void)
{
BUILD_BUG_ON(sizeof(struct batadv_br_ip_list) != sizeof(struct br_ip_list));
BUILD_BUG_ON(offsetof(struct batadv_br_ip_list, list) != offsetof(struct br_ip_list, list));
BUILD_BUG_ON(offsetof(struct batadv_br_ip_list, addr) != offsetof(struct br_ip_list, addr));
BUILD_BUG_ON(sizeof(struct batadv_br_ip) != sizeof(struct br_ip));
BUILD_BUG_ON(offsetof(struct batadv_br_ip, dst.ip4) != offsetof(struct br_ip, u.ip4));
BUILD_BUG_ON(offsetof(struct batadv_br_ip, dst.ip6) != offsetof(struct br_ip, u.ip6));
BUILD_BUG_ON(offsetof(struct batadv_br_ip, proto) != offsetof(struct br_ip, proto));
BUILD_BUG_ON(offsetof(struct batadv_br_ip, vid) != offsetof(struct br_ip, vid));
}
#endif
#define br_ip batadv_br_ip
#define br_ip_list batadv_br_ip_list
#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */
#if LINUX_VERSION_IS_LESS(5, 14, 0)
#include <linux/if_bridge.h>
#include <net/addrconf.h>
#if IS_ENABLED(CONFIG_IPV6)
static inline bool
br_multicast_has_router_adjacent(struct net_device *dev, int proto)
{
struct list_head bridge_mcast_list = LIST_HEAD_INIT(bridge_mcast_list);
struct br_ip_list *br_ip_entry, *tmp;
int ret;
if (proto != ETH_P_IPV6)
return true;
ret = br_multicast_list_adjacent(dev, &bridge_mcast_list);
if (ret < 0)
return true;
ret = false;
list_for_each_entry_safe(br_ip_entry, tmp, &bridge_mcast_list, list) {
if (br_ip_entry->addr.proto == htons(ETH_P_IPV6) &&
ipv6_addr_is_ll_all_routers(&br_ip_entry->addr.dst.ip6))
ret = true;
list_del(&br_ip_entry->list);
kfree(br_ip_entry);
}
return ret;
}
#else
static inline bool
br_multicast_has_router_adjacent(struct net_device *dev, int proto)
{
return true;
}
#endif
#endif /* LINUX_VERSION_IS_LESS(5, 14, 0) */
#if LINUX_VERSION_IS_LESS(5, 15, 0)
static inline void batadv_eth_hw_addr_set(struct net_device *dev,
const u8 *addr)
{
ether_addr_copy(dev->dev_addr, addr);
}
#define eth_hw_addr_set batadv_eth_hw_addr_set
#endif /* LINUX_VERSION_IS_LESS(5, 15, 0) */
/* <DECLARE_EWMA> */
#include <linux/version.h>
#include_next <linux/average.h>
#include <linux/bug.h>
#ifdef DECLARE_EWMA
#undef DECLARE_EWMA
#endif /* DECLARE_EWMA */
/*
* Exponentially weighted moving average (EWMA)
*
* This implements a fixed-precision EWMA algorithm, with both the
* precision and fall-off coefficient determined at compile-time
* and built into the generated helper funtions.
*
* The first argument to the macro is the name that will be used
* for the struct and helper functions.
*
* The second argument, the precision, expresses how many bits are
* used for the fractional part of the fixed-precision values.
*
* The third argument, the weight reciprocal, determines how the
* new values will be weighed vs. the old state, new values will
* get weight 1/weight_rcp and old values 1-1/weight_rcp. Note
* that this parameter must be a power of two for efficiency.
*/
#define DECLARE_EWMA(name, _precision, _weight_rcp) \
struct ewma_##name { \
unsigned long internal; \
}; \
static inline void ewma_##name##_init(struct ewma_##name *e) \
{ \
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
/* \
* Even if you want to feed it just 0/1 you should have \
* some bits for the non-fractional part... \
*/ \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
e->internal = 0; \
} \
static inline unsigned long \
ewma_##name##_read(struct ewma_##name *e) \
{ \
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
return e->internal >> (_precision); \
} \
static inline void ewma_##name##_add(struct ewma_##name *e, \
unsigned long val) \
{ \
unsigned long internal = READ_ONCE(e->internal); \
unsigned long weight_rcp = ilog2(_weight_rcp); \
unsigned long precision = _precision; \
\
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
\
WRITE_ONCE(e->internal, internal ? \
(((internal << weight_rcp) - internal) + \
(val << precision)) >> weight_rcp : \
(val << precision)); \
}
/* </DECLARE_EWMA> */

View File

@@ -1,82 +0,0 @@
include $(TOPDIR)/rules.mk
PKG:=ftm
PKG_NAME:=$(PKG)
PKG_RELEASE:=1
LOCAL_SRC:=$(TOPDIR)/qca/src/common-tools/ftm
PKG_VERSION:=12.3
#PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG)
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=QCA
CATEGORY:=QTI software
URL:=http://www.qca.qualcomm.com
MAINTAINER:=Qualcomm Atheros
TITLE:= QCA ftm utils
DEPENDS:= @TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64||TARGET_ipq807x||TARGET_ipq50xx||TARGET_ipq60xx||TARGET_ipq95xx||TARGET_ipq53xx +libnl +libtcmd +qca-diag +librt +kmod-diag-char
endef
define Package/$(PKG_NAME)/description/Default
FTM Package Support for QCA WIFI 11 drivers
endef
TARGET_CFLAGS += -DCONFIG_FTM_WLAN -DDEBUG -DFTM_DEBUG -DWIN_AP_HOST
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/qca-diag
TARGET_CFLAGS += -MMD -O2 -Wall -g
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
TARGET_CFLAGS += -fpie
TARGET_LDFLAGS += -ldiag -lnl-3 -lnl-genl-3 -lrt -ltcmd
TARGET_CSRCS := ftm_main.c ftm_wlan.c ftm_write_to_flash.c
TARGET_LDFLAGS += -pie
ifeq ($(CONFIG_FEATURE_IPQ_PROVISION_SUPPORT),y)
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/qti-mfg-provision
TARGET_CFLAGS += -DWIN_AP_AFC
TARGET_LDFLAGS += -lprovision
endif
ifneq ($(CONFIG_PACKAGE_kmod-mac80211),)
TARGET_CFLAGS+=-DWIN_AP_HOST_OPEN=1
endif
ifeq ($(CONFIG_FEATURE_QCA_IOT),y)
TARGET_CFLAGS += -DIPQ_AP_HOST_IOT -DIPQ_AP_HOST_IOT_QCA402X -ggdb3 -DCONFIG_DAEMON_MODE
TARGET_CSRCS += ftm_iot.c
TARGET_LDFLAGS += -lpthread
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/qca-iot
TARGET_LDFLAGS += -ldiag_demo
endif
ifeq ($(CONFIG_FEATURE_IPQ_IOT_SUPPORT),y)
TARGET_CFLAGS += -DIPQ_AP_HOST_IOT -DIPQ_AP_HOST_IOT_IPQ -ggdb3 -I$(STAGING_DIR)/usr/include/btdaemon
TARGET_CSRCS += ftm_iot.c
TARGET_LDFLAGS += -lpthread -lbtdaemon
endif
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
CSRCS="$(TARGET_CSRCS)"
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ftm $(1)/usr/sbin/
$(INSTALL_BIN) ./files/ftm.init $(1)/etc/init.d/ftm
$(INSTALL_DIR) $(1)/lib/wifi
$(INSTALL_BIN) ./files/compress_vart.sh $(1)/lib/compress_vart.sh
ifneq (, $(findstring ipq95xx, $(CONFIG_TARGET_BOARD)))
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) ./files/ftm_qcc710_start.sh $(1)/sbin/ftm_qcc710_start
endif
endef
$(eval $(call BuildPackage,ftm))

View File

@@ -1,75 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2020 Qualcomm Technologies, Inc.
#
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.
#
#
[ -e /lib/functions.sh ] && . /lib/functions.sh
[ -e /lib/ipq806x.sh ] && . /lib/ipq806x.sh
[ -e /lib/functions/boot.sh ] && . /lib/functions/boot.sh
low_mem_compress_art()
{
local mtdblock=$(find_mtd_part 0:ART)
if [ -z "$mtdblock" ]; then
# read from mmc
mtdblock=$(find_mmc_part 0:ART)
fi
[ -n "$mtdblock" ] || return
local apmp="/tmp"
lzma -zvfk -4 ${apmp}/virtual_art.bin 2> /dev/null || {
echo "Error Compressing Virtual ART" > /dev/console
return
}
dd if=${apmp}/virtual_art.bin.lzma of=${mtdblock}
echo "Success compressing Virtual ART(${mtdblock})" > /dev/console
return
}
normal_art()
{
local mtdblock=$(find_mtd_part 0:ART)
if [ -z "$mtdblock" ]; then
# read from mmc
mtdblock=$(find_mmc_part 0:ART)
fi
[ -n "$mtdblock" ] || return
local apmp="/tmp"
dd if=${apmp}/virtual_art.bin of=${mtdblock}
echo "Success writing to ART(${mtdblock})" > /dev/console
return
}
write_caldata()
{
local board
[ -f /tmp/sysinfo/board_name ] && {
board=ap$(cat /tmp/sysinfo/board_name | awk -F 'ap' '{print$2}')
}
if [ -e /sys/firmware/devicetree/base/compressed_art ]
then
echo "Compressed ART Supported Platform $board " > /dev/console
low_mem_compress_art
else
echo "Non Compressed ART Platform $board " > /dev/console
normal_art
fi
}
if [ "$1" = "write_caldata" ]
then
write_caldata
fi

View File

@@ -1,99 +0,0 @@
#!/bin/sh /etc/rc.common
#
# Copyright (c) 2013, 2017, 2020 Qualcomm Technologies, Inc.
#
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.
#
# 2013 Qualcomm Atheros, Inc.
#
# All Rights Reserved.
# Qualcomm Atheros Confidential and Proprietary
#
[ -e /lib/functions.sh ] && . /lib/functions.sh
[ -e /lib/ipq806x.sh ] && . /lib/ipq806x.sh
[ -e /lib/functions/boot.sh ] && . /lib/functions/boot.sh
START=97
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
MTD_ART_PART_NAME="art"
compressed_art_read() {
local mtdblock=$(find_mtd_part 0:ART)
if [ -z "$mtdblock" ]; then
#read from mmc
mtdblock=$(find_mmc_part 0:ART)
fi
[ -n "$mtdblock" ] || return
local apmp="/tmp"
dd if=${mtdblock} of=${apmp}/virtual_art.bin.lzma
lzma -fdv --single-stream ${apmp}/virtual_art.bin.lzma || {
# Create dummy virtual_art.bin file of size 512K
dd if=/dev/zero of=${apmp}/virtual_art.bin bs=1024 count=512
}
echo "Uncompressed and Copied ART content from ${mtdblock} to /tmp/virtual_art.bin" > /dev/console
}
raw_art_read() {
local mtdblock=$(find_mtd_part 0:ART)
if [ -z "$mtdblock" ]; then
#read from mmc
mtdblock=$(find_mmc_part 0:ART)
fi
[ -n "$mtdblock" ] || return
local apmp="/tmp"
dd if=${mtdblock} of=${apmp}/virtual_art.bin
echo "Copy ART caldata from ${mtdblock} to /tmp/virtual_art.bin" > /dev/console
}
retrieve_caldata() {
local board
[ -f /tmp/sysinfo/board_name ] && {
board=ap$(cat /tmp/sysinfo/board_name | awk -F 'ap' '{print$2}')
}
echo "**** Platform Name: $board *****" > /dev/console
if [ -e /sys/firmware/devicetree/base/compressed_art ]
then
compressed_art_read
else
raw_art_read
fi
}
start() {
local emmc_flash=""
local nor_flash=""
emmc_flash=$(find_mmc_part 0:ART 2> /dev/null)
mtd_name=$(grep -i -w ${MTD_ART_PART_NAME} /proc/mtd | cut -f1 -d:)
nor_flash=`find /sys/bus/spi/devices/*/mtd -name ${mtd_name} 2> /dev/null`
if [ -n "$emmc_flash" ]; then
[ -L /dev/caldata ] || \
ln -s $emmc_flash /dev/caldata
elif [ -n "$nor_flash" ]; then
[ -L /dev/caldata ] || \
ln -s /dev/${mtd_name//mtd/mtdblock} /dev/caldata
elif [ -n "$mtd_name" ]; then
[ -L /dev/caldata ] || \
ln -s /dev/${mtd_name//mtd/mtdblock} /dev/caldata
fi
retrieve_caldata
}
stop() {
[ -L /dev/caldata ] && rm /dev/caldata
}

View File

@@ -1,86 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2021 Qualcomm Technologies, Inc.
#
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.
#
#
# QCC710 v1.0 reset for BT bringup
qcc710_reset() {
reset_gpio_pin=$(cat /proc/device-tree/soc/pinctrl@1000000/QCC710_pins/QCC710_reset/pins | sed s/"gpio"//)
[[ -z $reset_gpio_pin ]] && return
gpio_base=$(cat /sys/class/gpio/gpiochip*/base | head -n1)
gpio_reset=$(( gpio_base + reset_gpio_pin ))
if [[ ! -e /sys/class/gpio/gpio$gpio_reset ]]; then
[ -z ${SLEEP} ] && echo -e "Enter sleep value for reset. Options:\n10 \n1" && read -p "Enter : " SLEEP
[ -z ${SLEEP} ] && SLEEP=10
echo $gpio_reset > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio$gpio_reset/direction
echo "Performing QCC710 reset ...." > /dev/console
{ echo 1 > /sys/class/gpio/gpio$gpio_reset/value ; \
sleep $SLEEP; \
echo 0 > /sys/class/gpio/gpio$gpio_reset/value; \
echo "QCC710 reset complete ...." > /dev/console; }
fi
}
while [ -n "$1" ]; do
case "$1" in
-h|--help) HELP=1; break;;
-a|--ipaddr) SERVERIP="$2";shift;;
-s|--sleep) SLEEP="$2";shift;;
-r|--baud-rate) BAUDRATE="$2";shift;;
-*)
echo "Invalid option: $1"
ERROR=1;
break
;;
*)break;;
esac
shift
done
[ -n "$HELP" -o -n "$ERROR" ] && {
cat <<EOF
Usage: $0 [-h] [-a SERVERIP] [-r baud-rate] [-s sleep]
ftm_qcc710_start options:
-h print this help
-a ipaddr of the server for diag connection
-r baudrate
-s sleep
Example:
ftm_qcc710_start -a <serverip> -r <baud-rate> -s <sleep>
version 1 : ./sbin/ftm_qcc710_start -a 192.168.1.121 -r 2000000 -s 10
version 2 : ./sbin/ftm_qcc710_start -a 192.168.1.121 -r 115200 -s 1
EOF
# If we requested the help flag, then exit normally.
# Else, it's probably an error so report it as such.
[ -n "$HELP" ] && exit 0
exit 1
}
[ -z ${SERVERIP} ] && SERVERIP=$(grep -oh "serverip.*#" /proc/cmdline | awk -F '#' '{print $2}')
[ -z ${SERVERIP} ] && read -p "No serverip in cmdline, please enter the serverip : " SERVERIP
[ -z ${BAUDRATE} ] && echo -e "Enter baudrate for stack bringup. Options:\n2000000\n115200" && read -p "Enter : " BAUDRATE
[ -z ${BAUDRATE} ] && BAUDRATE=2000000
qcc710_reset
DIAG_PID=$(ps | grep diag_socket_app | grep -v grep | awk '{print $1}')
while [ -n "$DIAG_PID" ]
do
kill -s SIGTERM $DIAG_PID
DIAG_PID=$(ps | grep diag_socket_app | grep -v grep | awk '{print $1}')
done
echo "Stopped previous instances of diag_socket_app process"
[ -z "$DIAG_PID" ] && /usr/sbin/diag_socket_app -a $SERVERIP -p 2500 &
FTM_PID=$(ps | grep "ftm " | grep -v grep | awk '{print $1}')
while [ -n "$FTM_PID" ]
do
kill -s SIGTERM $FTM_PID
FTM_PID=$(ps | grep "ftm " | grep -v grep | awk '{print $1}')
done
echo "Stopped previous instances ftm process"
[ -z "$FTM_PID" ] && /usr/sbin/ftm -n -dd -r $BAUDRATE

View File

@@ -1,133 +0,0 @@
ifeq ($(call is-vendor-board-platform,QCOM),true)
# Build only if board has BT/FM/WLAN
ifeq ($(findstring true, $(BOARD_HAVE_QCOM_FM) $(BOARD_HAVE_BLUETOOTH) $(BOARD_HAS_ATH_WLAN_AR6320)),true)
LOCAL_PATH:= $(call my-dir)
BDROID_DIR:= system/bt
ifeq ($(TARGET_SUPPORTS_WEARABLES),true)
QTI_DIR := hardware/qcom/bt/msm8909/libbt-vendor
else
QTI_DIR := hardware/qcom/bt/libbt-vendor
endif
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(TARGET_OUT_HEADERS)/diag/include \
LOCAL_C_INCLUDES += vendor/qcom/proprietary/diag/src \
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc \
LOCAL_C_INCLUDES += vendor/qcom/proprietary/bt/hci_qcomm_init \
LOCAL_C_INCLUDES += vendor/qcom/opensource/fm/helium \
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \
LOCAL_C_INCLUDES += $(BDROID_DIR)/hci/include \
LOCAL_C_INCLUDES += $(QTI_DIR)/include
ifeq ($(TARGET_SUPPORTS_WEARABLES),true)
LOCAL_C_INCLUDES += device/qcom/msm8909w/opensource/bluetooth/tools/hidl_client/inc
else
LOCAL_C_INCLUDES += vendor/qcom/opensource/bluetooth/tools/hidl_client/inc
endif
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_CFLAGS:= \
-DANDROID \
-DDEBUG
#LOCAL_CFLAGS += -include bionic/libc/include/sys/socket.h
#LOCAL_CFLAGS += -include bionic/libc/include/netinet/in.h
ifneq ($(DISABLE_BT_FTM),true)
LOCAL_CFLAGS += -DCONFIG_FTM_BT
endif
ifeq ($(BOARD_HAVE_QCOM_FM),true)
LOCAL_CFLAGS += -DCONFIG_FTM_FM
endif
ifeq ($(BOARD_HAS_QCA_FM_SOC), "cherokee")
LOCAL_CFLAGS += -DFM_SOC_TYPE_CHEROKEE
endif
ifneq ($(BOARD_ANT_WIRELESS_DEVICE), )
LOCAL_CFLAGS += -DCONFIG_FTM_ANT
endif
LOCAL_CFLAGS += -DCONFIG_FTM_NFC
ifeq ($(BOARD_HAVE_BLUETOOTH_BLUEZ), true)
LOCAL_CFLAGS += -DHAS_BLUEZ_BUILDCFG
endif # BOARD_HAVE_BLUETOOTH_BLUEZ
LOCAL_SRC_FILES:= \
ftm_main.c \
ftm_nfc.c \
ftm_nfcnq.c \
ftm_nfcqti.c \
ftm_nfcnq_fwdl.c \
ftm_nfcnq_test.c
ifneq ($(DISABLE_BT_FTM),true)
LOCAL_SRC_FILES += \
ftm_bt.c \
ftm_bt_power_pfal_linux.c \
ftm_bt_hci_pfal_linux.c \
ftm_bt_persist.cpp
endif
ifeq ($(call is-platform-sdk-version-at-least,23),true)
LOCAL_CFLAGS += -DANDROID_M
endif
ifeq ($(BOARD_HAVE_QCOM_FM),true)
ifeq ($(BOARD_HAS_QCA_FM_SOC), "cherokee")
LOCAL_SRC_FILES += ftm_fm.c ftm_fm_pfal_linux_3990.c
else
LOCAL_SRC_FILES += ftm_fm.c ftm_fm_pfal_linux.c
endif
endif
ifneq ($(BOARD_ANT_WIRELESS_DEVICE), )
LOCAL_SRC_FILES += ftm_ant.c
endif
ifeq ($(findstring true, $(BOARD_HAS_ATH_WLAN) $(BOARD_HAS_ATH_WLAN_AR6320)),true)
LOCAL_CFLAGS += -DBOARD_HAS_ATH_WLAN_AR6320
LOCAL_CFLAGS += -DCONFIG_FTM_WLAN
LOCAL_CFLAGS += -DCONFIG_FTM_WLAN_AUTOLOAD
LOCAL_STATIC_LIBRARIES += libtcmd
LOCAL_SHARED_LIBRARIES += libnl
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libtcmd
LOCAL_SRC_FILES += ftm_wlan.c
endif
LOCAL_SHARED_LIBRARIES += libdl
ifneq ($(DISABLE_BT_FTM),true)
LOCAL_SHARED_LIBRARIES += libbt-hidlclient
endif
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES)
LOCAL_MODULE:= ftmdaemon
LOCAL_CLANG := true
ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
LOCAL_PROPRIETARY_MODULE := true
endif
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES += libdiag
LOCAL_SHARED_LIBRARIES += libcutils liblog libhardware
ifneq ($(DISABLE_BT_FTM),true)
LOCAL_SHARED_LIBRARIES += libbtnv
endif
# By default NV persist gets used
LOCAL_CFLAGS += -DBT_NV_SUPPORT
LDFLAGS += -ldl
include $(BUILD_EXECUTABLE)
include $(call all-makefiles-under,$(LOCAL_PATH))
endif # filter
endif # is-vendor-board-platform

View File

@@ -1,181 +0,0 @@
This text file is provided to comply with the attribution requirements of
the licenses herein, but see NOTICE for license terms of this software.
The Apache 2.0 license can be found at
http://www.apache.org/licenses/LICENSE-2.0.html
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@@ -1,12 +0,0 @@
#CC := $(ATH_CROSS_COMPILE_TYPE)gcc
TARGET_TYPE ?= AR9888
TARGET_VERS ?= v2
#Sources to compile
CSRCS := ftm_main.c ftm_wlan.c ftm_write_to_flash.c
all:
$(CC) $(CFLAGS) $(LDFLAGS) -g3 -Wall \
$(CSRCS) -o ftm
clean:
rm -f ftm

View File

@@ -1,86 +0,0 @@
AM_CFLAGS = -Wall \
-g -O0 \
$(DIAG_CFLAGS)
AM_CPPFLAGS = -Wall \
-g -O0 \
$(DIAG_CFLAGS)
AM_CFLAGS += -I${WORKSPACE}/system/bt/hci/include
AM_CFLAGS += -I${WORKSPACE}/vendor/qcom/proprietary/bt/hci_qcomm_init/
AM_CPPFLAGS += -I${WORKSPACE}/system/bt/hci/include
AM_CPPFLAGS += -I${WORKSPACE}/vendor/qcom/proprietary/bt/hci_qcomm_init/
if DEBUG
AM_CFLAGS += -DDEBUG
AM_CPPFLAGS += -DDEBUG
endif
requiredlibs = -lrt $(DIAG_LIBS)
if USE_GLIB
AM_CFLAGS += -DUSE_GLIB $(GLIB_CFLAGS)
AM_CPPFLAGS += -DUSE_GLIB $(GLIB_CFLAGS)
requiredlibs += $(GLIB_LIBS)
endif
#By default build for MDM_LE
AM_CFLAGS += -DMDM_LE
AM_CPPFLAGS += -DMDM_LE
if MDM_ROME
AM_CFLAGS += -DBT_SOC_TYPE_ROME
AM_CPPFLAGS += -DBT_SOC_TYPE_ROME
else
if MDM_PRONTO
AM_CFLAGS += -DHCI_USE_MCT
AM_CPPFLAGS += -DHCI_USE_MCT
endif
endif
c_sources = ftm_main.c
if CONFIG_FTM_BT
AM_CFLAGS += -DCONFIG_FTM_BT -DBT_NV_SUPPORT
AM_CPPFLAGS += -DCONFIG_FTM_BT -DBT_NV_SUPPORT
c_sources += ftm_bt.c
c_sources += ftm_bt_power_pfal_linux.c
c_sources += ftm_bt_hci_pfal_linux.c
c_sources += ftm_bt_persist.cpp
endif
if CONFIG_FTM_FM
AM_CFLAGS += -DCONFIG_FTM_FM
c_sources += ftm_fm.c
c_sources += ftm_fm_pfal_linux.c
endif
if CONFIG_FTM_ANT
AM_CFLAGS += -DCONFIG_FTM_ANT
c_sources += ftm_ant.c
endif
if CONFIG_FTM_NFC
AM_CFLAGS += -DCONFIG_FTM_NFC
c_sources += ftm_nfc.c
c_sources += ftm_nfcnq.c
c_sources += ftm_nfcqti.c
c_sources += ftm_nfcnq_fwdl.c
c_sources += ftm_nfcnq_test.c
endif
if CONFIG_FTM_WLAN
AM_CFLAGS += -DCONFIG_FTM_WLAN -DCONFIG_FTM_WLAN_AUTOLOAD
AM_CFLAGS += $(LIBNL_CFLAGS) $(ATH6KL_UTILS_CFLAGS)
AM_CPPFLAGS += $(LIBNL_CFLAGS) $(ATH6KL_UTILS_CFLAGS)
requiredlibs += $(ATH6KL_UTILS_LIBS) $(LIBNL_LIBS)
c_sources += ftm_wlan.c
endif
ftmdaemon_SOURCES = $(c_sources)
ftmdaemon_LDADD = -ldl $(requiredlibs) -lbtnv
bin_PROGRAMS = ftmdaemon

View File

@@ -1,72 +0,0 @@
This NOTICE file contains certain notices of software components included
with the software that Qualcomm Technologies, Inc. ("Qualcomm Technologies")
is required to provide you. Notwithstanding anything in the notices in this
file, your use of these software components together with the
Qualcomm Technologies software (Qualcomm Technologies software hereinafter
referred to as "Software") is subject to the terms of your license from
Qualcomm Technologies. Compliance with all copyright laws and software
license agreements included in the notice section of this file are the
responsibility of the user. Except as may be granted by separate express
written agreement, this file provides no license to any patents,
trademarks, copyrights, or other intellectual property.
Copyright (c) 2016 Qualcomm Technologies, Inc.
All rights reserved.
Qualcomm is a registered trademark and registered service mark of
QUALCOMM Incorporated. All other trademarks and service marks are the
property of their respective owners.
________________________________________
NOTICES
________________________________________
Copyright (C) 2010 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.
________________________________________
Copyright (C) 2015 NXP Semiconductors
The original Work has been changed by NXP Semiconductors.
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.
________________________________________
Copyright (C) 2015 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.
________________________________________
Note: Any files for which the above Apache License notices are required
to be provided are not contributions.
A copy of the Apache 2.0 license is included in the file LICENSE
for attribution purposes only.

View File

@@ -1,149 +0,0 @@
# -*- Autoconf -*-
# configure.ac -- Autoconf script for ftm.
#
# Process this file with autoconf to produce a configure script
# Requires autoconf tool later than 2.61
AC_PREREQ(2.61)
# Initialize the ftm package version 1.0.0
AC_INIT([ftm],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign])
# Disables auto rebuilding of configure, Makefile.ins
AM_MAINTAINER_MODE
# defines some macros variable to be included by source
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AM_PROG_CC_C_O
AC_PROG_LIBTOOL
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
# Checks for libraries.
PKG_CHECK_MODULES([DIAG], [diag])
AC_SUBST([DIAG_CFLAGS])
AC_SUBST([DIAG_LIBS])
has_libnl_ver=0
# libnl-2 provides only libnl-2.0.pc file, so we check for separate libnl-genl-3.0.pc
# pkg-config file just for libnl-3.0 case.
#
PKG_CHECK_MODULES([LIBNL], [libnl-3.0 >= 3.0 libnl-genl-3.0 >= 3.0], [has_libnl_ver=3], [
PKG_CHECK_MODULES([LIBNL], [libnl-2.0 >= 2.0], [has_libnl_ver=2], [
PKG_CHECK_MODULES([LIBNL], [libnl-1], [has_libnl_ver=1], [has_libnl_ver=0])])])
if (test "$has_libnl_ver" -eq 0); then
AC_MSG_ERROR(libnl and libnl-genl are required but were not found)
fi
if (test "$has_libnl_ver" -gt 1); then
AC_DEFINE([HAVE_LIBNL20], [1], [Define if you have libnl-2.0 or higher])
fi
AC_SUBST([LIBNL_CFLAGS])
AC_SUBST([LIBNL_LIBS])
PKG_CHECK_MODULES([ATH6KL_UTILS], [ath6kl-utils])
AC_SUBST([ATH6KL_UTILS_CFLAGS])
AC_SUBST([ATH6KL_UTILS_LIBS])
AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, building FTM Daemon which use glib]))
if (test "x${with_glib}" = "xyes"); then
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")
AC_ARG_ENABLE([debug],
[ --enable-debug Turn on debugging],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],[debug=false])
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
AC_ARG_ENABLE([all],
[ --enable-all Enable all FTM functionality],
[case "${enableval}" in
yes) all=true ;;
no) all=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-all]) ;;
esac],[all=false])
AM_CONDITIONAL([CONFIG_FTM_BT], [test x$all = xtrue])
AM_CONDITIONAL([CONFIG_FTM_FM], [test x$all = xtrue])
AM_CONDITIONAL([CONFIG_FTM_ANT], [test x$all = xtrue])
AM_CONDITIONAL([CONFIG_FTM_NFC], [test x$all = xtrue])
AC_ARG_ENABLE([wlan],
[ --enable-wlan Enable WLAN FTM functionality],
[case "${enableval}" in
yes) wlan=true ;;
no) wlan=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-wlan]) ;;
esac],[wlan=false])
AM_CONDITIONAL([CONFIG_FTM_WLAN], [test x$wlan = xtrue -o x$all = xtrue])
AC_ARG_ENABLE([bt],
[ --enable-bt Enable BT FTM functionality],
[case "${enableval}" in
yes) bt=true ;;
no) bt=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-bt]) ;;
esac],[bt=false])
AM_CONDITIONAL([CONFIG_FTM_BT], [test x$bt = xtrue -o x$all = xtrue])
AC_ARG_ENABLE(target,
[AS_HELP_STRING([--enable-target=TARGET], [Specify the target product to build])],
[TARGET=$enableval],
[TARGET=none]
)
AM_CONDITIONAL([MDM_ROME], [test "x$TARGET" = "xmdm9607" -o "x$TARGET" = "xmdm9635" -o "x$TARGET" = "xmdm9640" -o "x$TARGET" = "xmdmcalifornium"])
AM_CONDITIONAL([MDM_PRONTO], [test "x$TARGET" = "xapq8009" -o "x$TARGET" = "xapq8017" -o "x$TARGET" = "xapq8053"])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_HEADER_STDC
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_CONFIG_FILES([ \
Makefile \
])
AC_OUTPUT

View File

@@ -1,585 +0,0 @@
/*==========================================================================
FTM ANT Source File
Description
FTM platform independent processing of packet data
# Copyright (c) 2010-2012 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
05/16/12 ankurn Adding support for ANT commands
11/28/12 c_ssugas implements efficent method for Ant cmd transfer
and implements Rx thread for event handling.
===========================================================================*/
#include "event.h"
#include "msg.h"
#include "log.h"
#include "diag_lsm.h"
#include "diagpkt.h"
#include "diagcmd.h"
#include "diag.h"
#include "termios.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <pthread.h>
#include <stdio.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "bt_vendor_qcom.h"
#include "ftm_ant_common.h"
#include "ftm_bt.h"
#include <string.h>
#include "hidl_client.h"
#ifdef ANDROID
#include <cutils/properties.h>
#endif
#ifdef ANDROID
extern int soc_type;
#endif
#define ANT_CTRL_PACKET_TYPE 0x0c
#define ANT_DATA_PACKET_TYPE 0x0e
#define UNUSED(x) (void)(x)
int init_transport_ant(int on);
// The following functions are dummy implementations of the callbacks required by libbt-vendor.
static void vendor_fwcfg_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void vendor_scocfg_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void vendor_lpm_vnd_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void vendor_audio_state_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void* vendor_alloc(int size) {
UNUSED(size);
return NULL;
}
static void vendor_dealloc(void *p_buf) {
UNUSED(p_buf);
}
static uint8_t vendor_xmit_cb(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback) {
UNUSED(opcode);
UNUSED(p_buf);
UNUSED(p_cback);
return 0;
}
static void vendor_epilog_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void vendor_a2dp_offload_cb(bt_vendor_op_result_t result, bt_vendor_opcode_t op, unsigned char handle) {
UNUSED(result);
UNUSED(op);
UNUSED(handle);
}
// This struct is used to regsiter the dummy callbacks with libbt-vendor
static bt_vendor_interface_t *vendor_interface=NULL;
static const bt_vendor_callbacks_t vendor_callbacks = {
sizeof(bt_vendor_callbacks_t),
vendor_fwcfg_cb,
vendor_scocfg_cb,
vendor_lpm_vnd_cb,
vendor_audio_state_cb,
vendor_alloc,
vendor_dealloc,
vendor_xmit_cb,
vendor_epilog_cb,
vendor_a2dp_offload_cb
};
/* Transport file descriptor */
int fd_transport_ant_cmd;
extern int first_ant_command;
/* Reader thread handle */
pthread_t ant_cmd_thread_hdl;
/* Pipe file descriptors for cancelling read operation */
int ant_pipefd[2];
/* Enable FTM_DEBUG to turn on Debug messages */
//#define FTM_DEBUG
/*===========================================================================
FUNCTION ftm_ant_readerthread
DESCRIPTION
Thread Routine to perfom asynchrounous handling of events coming on Smd
descriptor. It invokes a callback to the FTM ANT layer to intiate a request
to read event bytes.
DEPENDENCIES
The LifeTime of ReaderThraad is dependent on the status returned by the
call to ftm_ant_qcomm_handle_event
RETURN VALUE
RETURN NULL
SIDE EFFECTS
None
===========================================================================*/
void *ftm_ant_readerthread(void *ptr)
{
boolean status = FALSE;
int retval;
fd_set readfds;
int buf;
UNUSED(ptr);
#ifdef FTM_DEBUG
printf("ftm_ant_readerthread --> \n");
#endif
do
{
FD_ZERO(&readfds);
FD_SET(fd_transport_ant_cmd, &readfds);
FD_SET(ant_pipefd[0],&readfds);
retval = select((fd_transport_ant_cmd>ant_pipefd[0]?fd_transport_ant_cmd
:ant_pipefd[0]) + 1, &readfds, NULL, NULL, NULL);
if(retval == -1)
{
printf("select failed\n");
break;
}
if(FD_ISSET(ant_pipefd[0],&readfds))
{
#ifdef FTM_DEBUG
printf("Pipe descriptor set\n");
#endif
read(ant_pipefd[0],&buf,1);
if(buf == 1)
break;
}
if(FD_ISSET(fd_transport_ant_cmd,&readfds))
{
#ifdef FTM_DEBUG
printf("Read descriptor set\n");
#endif
status = ftm_ant_qcomm_handle_event();
if(TRUE != status)
break;
}
}
while(1);
#ifdef FTM_DEBUG
printf("\nReader thread exited\n");
#endif
return 0;
}
/*===========================================================================
FUNCTION ftm_ant_open_channel
DESCRIPTION
Open the SMD transport associated with ANT
DEPENDENCIES
NIL
RETURN VALUE
int value indicating success or failure
SIDE EFFECTS
NONE
===========================================================================*/
static bool ftm_ant_open_channel()
{
struct termios term_port;
int opts;
printf("%s: \n",__func__ );
switch (soc_type)
{
case BT_SOC_ROME:
case BT_SOC_CHEROKEE:
case BT_SOC_NAPIER:
//Use hidl_client_initialize for chip initialization
if (hidl_client_initialize(MODE_ANT,&fd_transport_ant_cmd) == false) {
printf("%s: HIDL client initialization failed, opening port with init_transpor_ant\n", __func__);
//Use libbt-vendor for chip initialization
fd_transport_ant_cmd = init_transport_ant(TRUE);
if (fd_transport_ant_cmd == -1) {
printf("%s: ANT Device open Failed, fd:%d: \n", __func__, fd_transport_ant_cmd);
return false;
}
}
break;
case BT_SOC_AR3K:
case BT_SOC_SMD:
#ifdef FTM_DEBUG
printf("ftm_ant_open_channel --> \n");
#endif
fd_transport_ant_cmd = open(APPS_RIVA_ANT_CMD_CH, (O_RDWR));
if (fd_transport_ant_cmd == -1) {
printf("Ant Device open Failed= %d\n ", fd_transport_ant_cmd);
return false;
}
// Blocking Read
opts = fcntl(fd_transport_ant_cmd, F_GETFL);
if (opts < 0) {
perror("fcntl(F_GETFL)");
exit(EXIT_FAILURE);
}
opts = opts & (~O_NONBLOCK);
if (fcntl(fd_transport_ant_cmd, F_SETFL, opts) < 0) {
perror("fcntl(F_SETFL)");
exit(EXIT_FAILURE);
}
if (tcgetattr(fd_transport_ant_cmd, &term_port) < 0)
close(fd_transport_ant_cmd);
cfmakeraw(&term_port);
if (tcsetattr(fd_transport_ant_cmd, TCSANOW, &term_port) < 0) {
printf("\n Error while setting attributes\n");
return false;
}
tcflush(fd_transport_ant_cmd, TCIFLUSH);
#ifdef FTM_DEBUG
printf("ftm_ant_open_channel success \n");
#endif
break;
default:
ALOGE("%s:Unknown soc type.",__func__);
return false;
}
if (pipe(ant_pipefd) == -1)
{
printf("pipe create error");
return STATUS_FAIL;
}
/* Creating read thread which listens for various masks & pkt requests */
pthread_create( &ant_cmd_thread_hdl, NULL, ftm_ant_readerthread, NULL);
return true;
}
int init_transport_ant(int on) {
void *so_handle;
unsigned char bdaddr[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
int fd[CH_MAX], powerstate, ret = -1;
char ref_count[PROPERTY_VALUE_MAX];
int value;
if (on) {
so_handle = dlopen("libbt-vendor.so", RTLD_NOW);
if (!so_handle)
{
ALOGE("Failed to load vendor component");
return -1;
}
vendor_interface = (bt_vendor_interface_t *) dlsym(so_handle, "BLUETOOTH_VENDOR_LIB_INTERFACE");
if (!vendor_interface)
{
ALOGE("Failed to accesst bt vendor interface");
return -1;
}
vendor_interface->init(&vendor_callbacks, bdaddr);
ALOGI("Turn On BT power");
powerstate = BT_VND_PWR_ON;
ret = vendor_interface->op(BT_VND_OP_POWER_CTRL, &powerstate);
if (ret < 0)
{
ALOGE("Failed to turn on power from bt vendor interface");
return -1;
}
for (int i = 0; i < CH_MAX; i++)
fd[i] = -1;
#ifdef ANDROID
if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE || soc_type == BT_SOC_NAPIER) {
/*call ANT_USERIAL_OPEN to get ANT handle*/
ret = vendor_interface->op((bt_vendor_opcode_t)BT_VND_OP_ANT_USERIAL_OPEN, fd);
}
#else
#ifdef BT_SOC_TYPE_ROME
/*call ANT_USERIAL_OPEN to get ANT handle*/
ret = vendor_interface->op((bt_vendor_opcode_t)BT_VND_OP_ANT_USERIAL_OPEN, fd);
#endif
#endif
ALOGE("ret value: %d", ret);
if (ret != 1)
{
ALOGE("Failed to get fd from bt vendor interface");
return -1;
} else {
ALOGE("FD: %x", fd[0]);
return fd[0];
}
} else {
if (vendor_interface) {
ALOGE("Close and cleanup the interfaces");
#ifdef ANDROID
if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE || soc_type == BT_SOC_NAPIER) {
int ret = vendor_interface->op((bt_vendor_opcode_t)BT_VND_OP_ANT_USERIAL_CLOSE, NULL);
}
#else
#ifdef BT_SOC_TYPE_ROME
int ret = vendor_interface->op((bt_vendor_opcode_t)BT_VND_OP_ANT_USERIAL_CLOSE, NULL);
#endif
#endif
ALOGE("ret value: %d", ret);
ALOGI("Turn off BT power");
powerstate = BT_VND_PWR_OFF;
ret = vendor_interface->op(BT_VND_OP_POWER_CTRL, &powerstate);
if (ret < 0)
{
ALOGE("Failed to turn off power from bt vendor interface");
return -1;
}
vendor_interface->cleanup();
vendor_interface = NULL;
return 0;
} else {
ALOGE("Not able to find vendor interface handle");
return -1;
}
}
}
/*===========================================================================
FUNCTION ftm_log_send_msg
DESCRIPTION
Processes the buffer sent and sends it to the libdiag for sending the Cmd
response
DEPENDENCIES
NIL
RETURN VALUE
NIL
SIDE EFFECTS
None
===========================================================================*/
void ftm_ant_log_send_msg(const uint8 *pEventBuf,int event_bytes)
{
int result = log_status(LOG_FTM_VER_2_C);
ftm_ant_log_pkt_type* ftm_ant_log_pkt_ptr = NULL;
if((pEventBuf == NULL) || (event_bytes == 0))
return;
#ifdef FTM_DEBUG
printf("ftm_ant_log_send_msg --> \n");
#endif
if(result == 1)
{
ftm_ant_log_pkt_ptr = (ftm_ant_log_pkt_type *)log_alloc(LOG_FTM_VER_2_C,
FTM_ANT_LOG_HEADER_SIZE + (event_bytes-1));
if(ftm_ant_log_pkt_ptr != NULL)
{
/* FTM ANT Log PacketID */
ftm_ant_log_pkt_ptr->ftm_log_id = FTM_ANT_LOG_PKT_ID;
memcpy((void *)ftm_ant_log_pkt_ptr->data,(void *)pEventBuf,event_bytes);
log_commit( ftm_ant_log_pkt_ptr );
}
}
}
/*===========================================================================
FUNCTION ftm_ant_dispatch
DESCRIPTION
Dispatch routine for the various FM Rx/Tx commands. Copies the data into
a global union data structure before calling the processing routine
DEPENDENCIES
NIL
RETURN VALUE
A Packed structre pointer including the response to the FTM FM packet
SIDE EFFECTS
None
===========================================================================*/
void * ftm_ant_dispatch(ftm_ant_pkt_type *ant_ftm_pkt, uint16 pkt_len)
{
ftm_ant_generic_sudo_res *rsp;
int err = 0, i;
int data_len = ant_ftm_pkt->cmd_data_len;
bool resp = false;
unsigned char *pdata = NULL, *ptemp;
#ifdef FTM_DEBUG
printf("ftm_ant_dispatch --> \n");
#endif
UNUSED(pkt_len);
if (first_ant_command == 0) {
first_ant_command = 1;
ftm_ant_open_channel();
}
rsp = (ftm_ant_generic_sudo_res*)diagpkt_subsys_alloc( DIAG_SUBSYS_FTM
, FTM_ANT_CMD_CODE
, sizeof(ftm_ant_generic_sudo_res)
);
if(rsp == NULL)
{
printf("%s Failed to allocate resource",__func__);
return NULL;
}
switch (soc_type) {
//Rome shares the same UART transport for ANT and BT. Hence, to differenciate the
//packets by controller, adding one extra byte for ANT data and control packets
case BT_SOC_ROME:
case BT_SOC_CHEROKEE:
case BT_SOC_NAPIER:
data_len = data_len + 1;
pdata = (unsigned char *) malloc(data_len);
if (pdata == NULL) {
ALOGE("Failed to allocate the memory for ANT command packet");
rsp->result = FTM_ANT_FAIL;
return (void *) rsp;
}
//To be compatible with Legacy, SMD based PLs, send all the packets
//with cmd opcode 0x0c
pdata[0] = 0x0c;
memcpy(pdata+1, ant_ftm_pkt->data, data_len-1);
err = write(fd_transport_ant_cmd, pdata, data_len);
ptemp = pdata;
break;
case BT_SOC_AR3K:
case BT_SOC_SMD:
/* Send the packet to controller and send a dummy response back to host*/
err = write(fd_transport_ant_cmd, ant_ftm_pkt->data, data_len);
ptemp = ant_ftm_pkt->data;
break;
default:
ALOGE("%s:Unknown soc type", __func__);
break;
}
if (err == data_len) {
rsp->result = FTM_ANT_SUCCESS;
printf("ANT CMD: ");
for (i = 1; i<data_len; i++) {
printf("%02X ", ptemp[i]);
}
printf("\n");
} else {
rsp->result = FTM_ANT_FAIL;
printf("FTM ANT write fail len: %d\n", err);
}
if (pdata)
free(pdata);
return (void *)rsp;
}
/*===========================================================================
FUNCTION ftm_bt_hci_qcomm_handle_event
DESCRIPTION
Routine called by the HAL layer reader thread to process the HCI events
The post conditions of each event is covered in a state machine pattern
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_ant_qcomm_handle_event ()
{
boolean status = TRUE;
int nbytes,i,len =0;
int event_type;
ftm_ant_generic_res *res = (ftm_ant_generic_res *)diagpkt_subsys_alloc(
DIAG_SUBSYS_FTM
, FTM_ANT_CMD_CODE
, sizeof(ftm_ant_generic_res)
);
if(res == NULL)
{
printf("%s Failed to allocate res",__func__);
tcflush(fd_transport_ant_cmd, TCIFLUSH);
return FALSE;
}
#ifdef FTM_DEBUG
printf("ftm_ant_hci_qcomm_handle_event --> \n");
#endif
/* Read length and event type of Ant Resp event*/
nbytes = read(fd_transport_ant_cmd, (void *)res->evt, 2);
if(nbytes <= 0) {
status = FALSE;
printf("ftm_ant_qcomm_handle_event read fail len=%d\n", nbytes);
return status;
}
event_type = res->evt[0];
len = res->evt[1];
#ifdef FTM_DEBUG
printf(" event type =%d\n",event_type);
printf("length of event =%d\n",len);
#endif
/* Read out the Ant Resp event*/
if (len <= (int)sizeof(res->evt))
{
nbytes = read(fd_transport_ant_cmd, (void *)res->evt, len);
if (nbytes != len) {
res->result = FTM_ANT_FAIL;
status = FALSE;
printf("ftm_ant_qcomm_handle_event read fail len=%d\n", nbytes);
}
else {
res->result = FTM_ANT_SUCCESS;
printf("ANT EVT: ");
for (i=0; i<nbytes; i++) {
printf("%02X ", res->evt[i]);
}
printf("\n");
ftm_ant_log_send_msg(res->evt, nbytes);
tcflush(fd_transport_ant_cmd, TCIOFLUSH);
}
}
else
{
res->result = FTM_ANT_FAIL;
status = FALSE;
printf("ftm_ant_qcomm_handle_event read fail len=%d is more than sizeof(res->evt)=%d\n", len, (int)sizeof(res->evt));
}
return status;
}

View File

@@ -1,124 +0,0 @@
/*==========================================================================
FTM FM Common Header File
Description
Global Data declarations of the ftm ant component.
# Copyright (c) 2012,2014 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
05/16/2012 ankurn Adding support for ANT+
11/28/12 c_ssugas Adds data structures and macro for ant log event support.
===========================================================================*/
#ifdef CONFIG_FTM_ANT
#include "diagpkt.h"
#include "log.h"
#include "ftm_bt_common.h"
#include <sys/types.h>
#define APPS_RIVA_ANT_CMD_CH "/dev/smd5"
#define APPS_RIVA_ANT_DATA_CH "/dev/smd6"
#define FTM_ANT_CMD_CODE 94
#define OPCODE_OFFSET 5
#define FTM_ANT_LOG_HEADER_SIZE (sizeof(ftm_ant_log_pkt_type) - 1)
#define FTM_ANT_LOG_PKT_ID 0x0D
/* FTM Log Packet - Used to send back the event of a ANT Command */
typedef PACKED struct
{
log_hdr_type hdr;
word ftm_log_id; /* FTM log id */
byte data[1]; /* Variable length payload,
look at FTM log id for contents */
} ftm_ant_log_pkt_type;
/* Generic result, used for any command that only returns an error code */
typedef enum {
FTM_ANT_FAIL,
FTM_ANT_SUCCESS,
} ftm_ant_api_result_type;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
} ftm_ant_generic_sudo_res;
/* Generic Response */
typedef PACKED struct
{
diagpkt_subsys_header_type header; /*Diag header*/
uint8 evt[18]; /*allocates memory to hold longest valid event */
char result; /* result */
}__attribute__((packed)) ftm_ant_generic_res;
/* FTM ANT request type */
typedef PACKED struct
{
diagpkt_cmd_code_type cmd_code;
diagpkt_subsys_id_type subsys_id;
diagpkt_subsys_cmd_code_type subsys_cmd_code;
uint8 cmd_id; /* command id (required) */
uint8 cmd_data_len;
byte data[1];
}__attribute__((packed))ftm_ant_pkt_type;
/*===========================================================================
FUNCTION ftm_ant_dispatch
DESCRIPTION
Dispatch routine for the various ANT commands. Copies the data into
a global union data structure before calling the processing routine
DEPENDENCIES
NIL
RETURN VALUE
A Packed structre pointer including the response to the FTM ANT packet
SIDE EFFECTS
None
===========================================================================*/
void * ftm_ant_dispatch(ftm_ant_pkt_type *ftm_ant_pkt, uint16 length );
/*===========================================================================
FUNCTION ftm_ant_qcomm_handle_event
DESCRIPTION
Handler for the various ANT Events received. Sends data as log packets
using diag to upper layers.
DEPENDENCIES
NIL
RETURN VALUE
Status value TRUE if event received successfuly
otherwise returns status value FALSE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_ant_qcomm_handle_event ();
#endif /* CONFIG_FTM_ANT */

File diff suppressed because it is too large Load Diff

View File

@@ -1,289 +0,0 @@
/*==========================================================================
FTM BT Task Header File
Description
Global Data declarations of the ftm bt component.
# Copyright (c) 2010-2011, 2013-2014 by Qualcomm Technologies, Inc.
# All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
09/28/11 rrr Moved peristent NV item related APIs to CPP,
for having BD address being programmed twice if previous
BD address was random generated.
09/03/11 agaja Added support for NV_READ and NV_WRITE Commands to write
onto Persist File system
02/08/11 braghave Changes to read the HCI commands from a binary file for
non-Android case
06/18/10 rakeshk Created a header file to hold the definitons for ftm bt
task
===========================================================================*/
#ifdef CONFIG_FTM_BT
#include "diagpkt.h"
#include <sys/types.h>
#ifdef USE_LIBSOCCFG
#include "btqsocnvm.h"
#include "btqsocnvmutils.h"
#endif
/* -------------------------------------------------------------------------
** Definitions and Declarations
** ------------------------------------------------------------------------- */
#define FTM_BT_CMD_CODE 4 /* BT FTM Command code */
#define FTM_FM_CMD_CODE 28 /* FM FTM Command code */
#define HCI_EVT_HDR_SIZE 3
#define HCI_ACL_HDR_SIZE 5
#define PROTOCOL_BYTE_SIZE 1
#define HC_VS_MAX_CMD_EVENT 260
#define HC_VS_MAX_ACL 1200
#define FTM_BT_HCI_USER_CMD 0
#define BT_FTM_CMD_RSP_LEN 1100
#define FTM_BT_DRV_START_TEST 0xA
/* MACROS for pin connectivty test*/
#define BT_CMD_SLIM_TEST 0xBFAC
#define LOOP_BACK_EVT_OGF 0x02
#define LOOP_BACK_EVT_OCF 0x18
#define LOOP_BACK_EVT_STATUS 0x00
#define LOOP_BACK_EVT_OGF_BIT 0x04
#define LOOP_BACK_EVT_OCF_BIT 0x05
#define LOOP_BACK_EVT_STATUS_BIT 0x06
#define FTM_BT_LOG_HEADER_SIZE (sizeof(ftm_bt_log_pkt_type) - 1)
/* Vendor Specific command codes */
#define BT_QSOC_EDL_CMD_OPCODE (0xFC00)
#define BT_QSOC_NVM_ACCESS_OPCODE (0xFC0B)
#define BT_QSOC_EDL_CMD_CODE (0x00)
#define BT_QSOC_NVM_ACCESS_CODE (0x0B)
#define BT_QSOC_VS_EDL_APPVER_RESP (0x02)
#ifndef HC_VS_MAX_CMD_EVENT
#define HC_VS_MAX_CMD_EVENT 260
#endif /* HC_VS_MAX_CMD_EVENT */
#define BT_QSOC_MAX_NVM_CMD_SIZE 0x64 /* Maximum size config (NVM) cmd */
#define BT_QSOC_MAX_BD_ADDRESS_SIZE 0x06 /**< Length of BT Address */
#ifndef HCI_CMD_HDR_SIZE
#define HCI_CMD_HDR_SIZE 4
#endif /* HCI_CMD_HDR_SIZE */
#ifndef HCI_EVT_HDR_SIZE
#define HCI_EVT_HDR_SIZE 3
#endif /* HCI_EVT_HDR_SIZE */
#define FTM_BT_LOG_PKT_ID 0x01
#define BT_HCI_CMD_PKT 0x01
#define BT_HCI_ACL_PKT 0x02
#define BT_HCI_EVT_PKT 0x04
#define BT_HCI_CMD_CMPLT_EVT 0x0E
#define FM_HCI_EVT_PKT 0x14
#define FM_HCI_CMD_PKT 0x11
extern int boardtype;
/* VS command structure */
typedef struct
{
uint8 vs_cmd_len;
uint8 vs_cmd_data[BT_QSOC_MAX_NVM_CMD_SIZE];
} bt_qsoc_cfg_tbl_struct_type;
/* First Commamd structure - Used to store the First command for later
* processing
*/
struct first_cmd
{
uint8 *cmd_buf;
int cmd_len;
};
/* FTM Global State - Enum defines the various states of the FTM
* module
*/
typedef enum ftm_state
{
FTM_SOC_NOT_INITIALISED,
FTM_SOC_READ_APP_VER,
FTM_SOC_READ_HW_VER,
FTM_SOC_POKE8_TBL_INIT,
FTM_SOC_DOWNLOAD_NVM,
FTM_SOC_DOWNLOAD_NVM_EFS,
FTM_SOC_SLEEP_DISABLE,
FTM_SOC_RESET,
FTM_SOC_INITIALISED
}ftm_state;
/* FTM CMD status */
typedef enum ftm_log_packet_type
{
FTM_USER_CMD_PASS,
FTM_USER_CMD_FAIL,
FTM_HCI_EVENT
}ftm_log_packet_type;
/* FTM Log Packet - Used to send back the event of a HCI Command */
typedef PACKED struct
{
log_hdr_type hdr;
byte data[1]; /* Variable length payload,
look at FTM log id for contents */
} ftm_bt_log_pkt_type;
/* FTM (BT) PKT Header */
typedef PACKED struct
{
word cmd_id; /* command id (required) */
word cmd_data_len; /* request pkt data length, excluding the diag and ftm headers
(optional, set to 0 if not used)*/
word cmd_rsp_pkt_size; /* rsp pkt size, size of response pkt if different then req pkt
(optional, set to 0 if not used)*/
} ftm_bt_cmd_header_type;
/* Bluetooth FTM packet */
typedef PACKED struct
{
diagpkt_subsys_header_type diag_hdr;
ftm_bt_cmd_header_type ftm_hdr;
byte data[1];
} ftm_bt_pkt_type;
/* SoC Cfg open Struct*/
#ifdef USE_LIBSOCCFG
typedef struct
{
bt_qsoc_config_params_struct_type run_time_params;
bt_qsoc_enum_nvm_mode nvm_mode;
bt_qsoc_enum_type soc_type;
}ftm_bt_soc_runtime_cfg_type;
#endif
/*===========================================================================
FUNCTION ftm_bt_err_timedout
DESCRIPTION
This routine triggers the shutdown of the HCI and Power resources in case
a HCI command previously sent times out.
DEPENDENCIES
NIL
RETURN VALUE
RETURN NIL
SIDE EFFECTS
NONE
===========================================================================*/
void ftm_bt_err_timedout();
/*===========================================================================
FUNCTION ftm_bt_dispatch
DESCRIPTION
Processes the BT FTM packet and dispatches the command to FTM HCI driver
DEPENDENCIES
NIL
RETURN VALUE
NIL,The error in the Command Processing is sent to the DIAG App on PC via
log packets
SIDE EFFECTS
None
===========================================================================*/
void ftm_bt_dispatch(void *ftm_bt_pkt ,int cmd_len );
/*===========================================================================
FUNCTION bt_hci_send_ftm_cmd
DESCRIPTION
Helper Routine to process the HCI cmd and invokes the sub routines to intialise
the SoC if needed based on the state of the FTM module
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_send_cmd
(
uint8 * cmd_buf, /* pointer to Cmd */
uint16 cmd_len /* Cmd length */
);
/*===========================================================================
FUNCTION bt_hci_hal_vs_sendcmd
DESCRIPTION
Helper Routine to process the VS HCI cmd and constucts the HCI packet before
calling bt_hci_send_ftm_cmd routine
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_hal_vs_sendcmd
(
uint16 opcode, /* Opcode */
uint8 *pCmdBuffer, /* Pointer to Payload*/
uint8 nSize /* Cmd Size */
);
/*===========================================================================
FUNCTION isLatestTarget
DESCRIPTION
For all the target/solution which has Bluedroid as stack and libbt-vendor as
vendor initialization component considered as latest target
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean isLatestTarget();
char *get_current_time(void);
#endif /* CONFIG_FTM_BT */

View File

@@ -1,115 +0,0 @@
/*==========================================================================
FTM BT Commom Header File
Description
The header file includes helper enums for request_status and bt_power_state.
# Copyright (c) 2010-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
09/28/11 rrr Common utility API abstracted,
06/18/10 rakeshk Created a header file to hold the helper enums for
request_status and bt_power_state
========================================================================*/
#ifdef CONFIG_FTM_BT
#include "event.h"
#include "msg.h"
#include "log.h"
#include "diag_lsm.h"
#include <sys/types.h>
#ifndef __FTM_BT_COMMON_H__
#define __FTM_BT_COMMON_H__
#define TRUE 1
#define FALSE 0
/* request_status - enum to encapuslate the status of a HAL request*/
typedef enum request_status
{
STATUS_SUCCESS,
STATUS_FAIL,
STATUS_NO_RESOURCES,
STATUS_SHORT_WRITE,
STATUS_SHORT_READ
}request_status;
/* request_status - enum to encapuslate the possible statea of BT power*/
typedef enum bt_power_state
{
BT_OFF = 0x30, /* Its the value 0 to be input to rfkill driver */
BT_ON = 0x31 /* ASCII value for '1'*/
}bt_power_state;
typedef enum
{
FTM_BT_DRV_NO_ERR = 0,
FTM_BT_DRV_CONN_TEST_FAILS,
FTM_BT_DRV_QSOC_POWERUP_FAILS,
FTM_BT_DRV_RX_PKT_TYPE_NOT_SUPPORTED,
FTM_BT_DRV_SIO_OPEN_FAILS,
FTM_BT_DRV_NO_SOC_RSP_TOUT,
FTM_BT_DRV_BAD_NVM,
#ifdef BT_NV_SUPPORT
FTM_BT_NV_READ_FAIL,
FTM_BT_NV_WRITE_FAIL,
#endif
FTM_BT_DRV_UNKNOWN_ERR
} ftm_bt_drv_err_state_type;
/*===========================================================================
FUNCTION ftm_bt_hci_qcomm_handle_event
DESCRIPTION
Routine called by the HAL layer reader thread to process the HCI events
The post conditions of each event is covered in a state machine pattern
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_qcomm_handle_event();
/*===========================================================================
FUNCTION ftm_log_send_msg
DESCRIPTION
Processes the buffer sent and sends it to the libdiag for sending the Cmd
response
DEPENDENCIES
NIL
RETURN VALUE
NIL
SIDE EFFECTS
None
===========================================================================*/
void ftm_log_send_msg(const uint8 *pEventBuf,int event_bytes);
#endif //__FTM_BT_COMMON_H__
#endif /* CONFIG_FTM_BT */

View File

@@ -1,161 +0,0 @@
/*==========================================================================
FTM BT HCI PFAL Header File
Description
Warpper API definitions of the ftm bt hci hal component.
# Copyright (c) 2010 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
06/18/10 rakeshk Created a header file to hold the wrapper HAL
definitions for HCI UART control
===========================================================================*/
#include "ftm_bt_common.h"
#include "ftm_bt_hci_pfal.h"
/*===========================================================================
FUNCTION ftm_bt_hci_hal_set_transport
DESCRIPTION
sets the type of transport based on the msm type
DEPENDENCIES
NIL
RETURN VALUE
returns the type of transport
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_hal_set_transport()
{
return ftm_bt_hci_pfal_set_transport();
}
/*===========================================================================
FUNCTION ftm_bt_hci_hal_deinit_transport
DESCRIPTION
Platform independent wrapper API which intiatea a De-intialise of UART/SMD
resources with PFAL layer and returns the status of the PFAL operation
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_hal_deinit_transport()
{
return ftm_bt_hci_pfal_deinit_transport();
}
/*===========================================================================
FUNCTION ftm_bt_hci_hal_init_transport
DESCRIPTION
Platform independent wrapper API which intiatea a intialise of UART/SMD
resources with PFAL layer and returns the status of the PFAL operation
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_hal_init_transport (int mode)
{
return ftm_bt_hci_pfal_init_transport(mode);
}
/*===========================================================================
FUNCTION ftm_bt_hci_hal_nwrite
DESCRIPTION
Platform independent wrapper API which intiates a write operation
with the PFAL layer and returns the status of the PFAL operation.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_hal_nwrite(uint8 *buf, int size)
{
return ftm_bt_hci_pfal_nwrite(buf,size);
}
/*===========================================================================
FUNCTION ftm_bt_hci_hal_nread
DESCRIPTION
Platform independent wrapper API which intiates a read operation
with the PFAL layer and returns the status of the PFAL operation.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_hal_nread(uint8 *buf, int size)
{
return ftm_bt_hci_pfal_nread(buf,size);
}
/*===========================================================================
FUNCTION ftm_bt_hci_hal_changebaudrate
DESCRIPTION
Platform independent wrapper API which intiatea a UART baud rate change
with the PFAL layer and returns the status of the PFAL request.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
TRUE if SUCCESS, else FAIL
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_hal_changebaudrate (uint32 new_baud)
{
return ftm_bt_hci_pfal_changebaudrate(new_baud);
}

View File

@@ -1,177 +0,0 @@
/*==========================================================================
FTM BT HCI PFAL Header File
Description
PFAL API declarations of the ftm bt hci pfal component.
# Copyright (c) 2010 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
06/18/10 rakeshk Created a header file to hold the PFAL declarations for
HCI UART programming
===========================================================================*/
#include "ftm_bt_common.h"
#ifndef __FTM_BT_HCI_PFAL_H__
#define __FTM_BT_HCI_PFAL_H__
#define PIN_CON_CMD_OGF 0xFC
#define PIN_CON_CMD_OCF 0x0C
#define PIN_CON_CMD_SUB_OP 0x38
#define PIN_CON_INTERFACE_ID 0x01
#define PIN_CON_EVENT_LEN 0x06
#define EXT_PIN_CON_LEN 0x02
#define PIN_CON_CMD_OCF_BIT 0x01
#define PIN_CON_CMD_OGF_BIT 0x02
#define PIN_CON_CMD_SUBOP_BIT 0x04
#define PIN_CON_CMD_INTER_BIT 0x05
#define PIN_CON_EVT_OGF_BIT 0x05
#define PIN_CON_EVT_OCF_BIT 0x04
#define PIN_CON_EVT_SUB_OP_BIT 0x07
#define PIN_CON_INTERFACE_ID_EVT_BIT 0x08
#define PIN_CON_EVENT_LEN_BIT 0x02
#define PIN_CON_EVT_STATUS_BIT 0x06
#define LOG_TAG "ftmdaemon"
#define PRI_INFO " I"
#define PRI_WARN " W"
#define PRI_ERROR " E"
#define PRI_DEBUG " D"
#define PRI_VERB " V"
#define ALOG(pri, tag, fmt, arg...) fprintf(stderr, tag pri ": " fmt"\n", ##arg)
#define ALOGV(fmt, arg...) ALOG(PRI_VERB, LOG_TAG, fmt, ##arg)
#define ALOGD(fmt, arg...) ALOG(PRI_DEBUG, LOG_TAG, fmt, ##arg)
#define ALOGI(fmt, arg...) ALOG(PRI_INFO, LOG_TAG, fmt, ##arg)
#define ALOGW(fmt, arg...) ALOG(PRI_WARN, LOG_TAG, fmt, ##arg)
#define ALOGE(fmt, arg...) ALOG(PRI_ERROR, LOG_TAG, fmt, ##arg)
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_set_transport
DESCRIPTION
sets the type of transport based on the msm type
DEPENDENCIES
NIL
RETURN VALUE
returns the type of transport
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_pfal_set_transport(void);
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_deinit_transport
DESCRIPTION
Platform specific routine to de-intialise the UART/SMD resource.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_pfal_deinit_transport();
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_init_transport
DESCRIPTION
Platform specific routine to intialise the UART/SMD resources.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_pfal_init_transport ();
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_nwrite
DESCRIPTION
Platform specific routine to write the data in the argument to the UART/SMD
port intialised.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_pfal_nwrite(uint8 *buf, int size);
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_nread
DESCRIPTION
Platform specific routine to read data from the UART/SMD port intialised into
the buffer passed in argument.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_pfal_nread(uint8 *buf, int size);
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_changebaudrate
DESCRIPTION
Platform specific routine to intiate a change in baud rate
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
TRUE if SUCCESS, else FALSE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_pfal_changebaudrate (uint32 new_baud);
#endif //__FTM_BT_HCI_PFAL_H__

View File

@@ -1,674 +0,0 @@
/*==========================================================================
FTM Platform specfic HCI UART/SMD File
Description
Platform specific routines to program the UART/SMD descriptors
# Copyright (c) 2010-2011, 2013 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
06/07/11 bneti Add support smd support for msm8960
06/18/10 rakeshk Created a source file to implement platform specific
routines for UART
07/07/10 rakeshk Removed the conversion of 3.2 Mbps baud rate
01/07/10 rakeshk Added support for verbose logging of Cmd and events
===========================================================================*/
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <sys/select.h>
#include <termios.h>
#include <pthread.h>
#include <stdio.h>
#include <dlfcn.h>
#include "bt_vendor_lib.h"
#include "ftm_bt_hci_pfal.h"
#include "ftm_common.h"
#include <string.h>
#include "log.h"
#include <cutils/properties.h>
#include "hidl_client.h"
#ifdef ANDROID
#define VENDOR_LIB "libbt-vendor.so"
#else
#define VENDOR_LIB "libbt-vendor.so.0"
#endif
uint8_t is_slim_bus_test = 0;
#define UNUSED(x) (void)(x)
/*identify the transport type*/
static char *transport_dev;
typedef enum {
BT_SOC_DEFAULT = 0,
BT_SOC_SMD = BT_SOC_DEFAULT,
BT_SOC_AR3K,
BT_SOC_ROME,
BT_SOC_CHEROKEE,
BT_SOC_NAPIER,
/* Add chipset type here */
BT_SOC_RESERVED
} bt_soc_type;
static void vendor_fwcfg_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void vendor_scocfg_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void vendor_lpm_vnd_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void vendor_audio_state_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void* vendor_alloc(int size) {
UNUSED(size);
return NULL;
}
static void vendor_dealloc(void *p_buf) {
UNUSED(p_buf);
}
static uint8_t vendor_xmit_cb(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback) {
UNUSED(opcode);
UNUSED(p_buf);
UNUSED(p_cback);
return 0;
}
static void vendor_epilog_cb(bt_vendor_op_result_t result) {
UNUSED(result);
}
static void vendor_a2dp_offload_cb(bt_vendor_op_result_t result, bt_vendor_opcode_t op, unsigned char handle) {
UNUSED(result);
UNUSED(op);
UNUSED(handle);
}
bt_vendor_interface_t *vendor_interface=NULL;
static const bt_vendor_callbacks_t vendor_callbacks = {
sizeof(bt_vendor_callbacks_t),
vendor_fwcfg_cb,
vendor_scocfg_cb,
vendor_lpm_vnd_cb,
vendor_audio_state_cb,
vendor_alloc,
vendor_dealloc,
vendor_xmit_cb,
vendor_epilog_cb,
vendor_a2dp_offload_cb
};
/*BT HS UART TTY DEVICE */
#define BT_HS_UART_DEVICE "/dev/ttyHS0"
/*BT RIVA-SMD CHANNELS */
#define APPS_RIVA_BT_ACL_CH "/dev/smd2"
#define APPS_RIVA_BT_CMD_CH "/dev/smd3"
/* Variables to identify the platform */
char transport_type[PROPERTY_VALUE_MAX];
static boolean is_transportSMD;
extern int soc_type;
/* Reader thread handle */
pthread_t hci_cmd_thread_hdl;
/* Pipe file descriptors for cancelling read operation */
int pipefd[2];
/* Transport file descriptor */
int fd_transport;
/* Starting baud rate to init the tty device */
int starting_baud = 115200;
/* Verbose output monitoring variable */
int verbose = 1;
/* Defintion to convert integer baud rate to the
* Data type understood by tty device
*/
#define BAUDCLAUS(i) case (i): return ( B##i )
/*===========================================================================
FUNCTION convert_baud
DESCRIPTION
Routine to convert the integer baud rate to type speed_t
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
Converted Baud rate, else default 0
SIDE EFFECTS
None
===========================================================================*/
static speed_t convert_baud(uint32 baud_rate)
{
switch (baud_rate)
{
BAUDCLAUS(50);
BAUDCLAUS(75);
BAUDCLAUS(110);
BAUDCLAUS(134);
BAUDCLAUS(150);
BAUDCLAUS(200);
BAUDCLAUS(300);
BAUDCLAUS(600);
BAUDCLAUS(1200);
BAUDCLAUS(1800);
BAUDCLAUS(2400);
BAUDCLAUS(4800);
BAUDCLAUS(9600);
BAUDCLAUS(19200);
BAUDCLAUS(38400);
BAUDCLAUS(57600);
BAUDCLAUS(115200);
BAUDCLAUS(230400);
BAUDCLAUS(460800);
BAUDCLAUS(500000);
BAUDCLAUS(576000);
BAUDCLAUS(921600);
BAUDCLAUS(1000000);
BAUDCLAUS(1152000);
BAUDCLAUS(1500000);
BAUDCLAUS(2000000);
BAUDCLAUS(2500000);
BAUDCLAUS(3000000);
BAUDCLAUS(3500000);
BAUDCLAUS(4000000);
default: return 0;
}
}
/*===========================================================================
FUNCTION ftm_readerthread
DESCRIPTION
Thread Routine to perfom asynchrounous handling of events coming on Uart/Smd
descriptor. It invokes a callback to the FTM BT layer to intiate a request
to read event bytes.
DEPENDENCIES
The LifeTime of ReaderThraad is dependent on the status returned by the
call to ftm_bt_hci_qcomm_handle_event
RETURN VALUE
RETURN NIL
SIDE EFFECTS
None
===========================================================================*/
void *ftm_readerthread(void *ptr)
{
UNUSED(ptr);
boolean status = FALSE;
int retval;
fd_set readfds;
int buf;
do
{
FD_ZERO(&readfds);
FD_SET(fd_transport, &readfds);
FD_SET(pipefd[0],&readfds);
retval = select((pipefd[0] > fd_transport? pipefd[0] : fd_transport) + 1,
&readfds, NULL, NULL, NULL);
if(retval == -1)
{
printf("select failed\n");
break;
}
if(FD_ISSET(pipefd[0],&readfds))
{
#ifdef FTM_DEBUG
printf("Pipe descriptor set\n");
#endif
read(pipefd[0],&buf,1);
if(buf == 1)
break;
}
if(FD_ISSET(fd_transport,&readfds))
{
#ifdef FTM_DEBUG
printf("Read descriptor set\n");
#endif
status = ftm_bt_hci_qcomm_handle_event();
if(TRUE != status)
break;
}
}
while(1);
#ifdef FTM_DEBUG
printf("\nReader thread exited\n");
#endif
return 0;
}
/*===========================================================================
FUNCTION ftm_bt_pfal_set_transport
DESCRIPTION
sets the type of transport based on the msm type
DEPENDENCIES
NIL
RETURN VALUE
returns the type of transport
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_pfal_set_transport(void)
{
if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE || soc_type == BT_SOC_NAPIER) {
strlcpy(transport_type, "uart", sizeof(transport_type));
printf("[%s]: Transport type is: %s\n", __FUNCTION__, transport_type);
is_transportSMD = 0;
transport_dev = BT_HS_UART_DEVICE;
} else {
strlcpy(transport_type, "smd", sizeof(transport_type));
printf("[%s]: Transport type is: %s\n", __FUNCTION__, transport_type);
is_transportSMD = 1;
transport_dev = APPS_RIVA_BT_CMD_CH;
}
return is_transportSMD;
}
int init_transport_bdroid(boolean on) {
void *so_handle;
unsigned char bdaddr[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
request_status st;
int fd[CH_MAX], powerstate, ret;
if (on) {
so_handle = dlopen(VENDOR_LIB, RTLD_NOW);
if (!so_handle)
{
ALOGE("Failed to load vendor component %s", dlerror());
return -1;
}
vendor_interface = (bt_vendor_interface_t *) dlsym(so_handle, "BLUETOOTH_VENDOR_LIB_INTERFACE");
if (!vendor_interface)
{
ALOGE("Failed to accesst bt vendor interface");
return -1;
}
vendor_interface->init(&vendor_callbacks, bdaddr);
ALOGI("Turn On BT power");
powerstate = BT_VND_PWR_ON;
ret = vendor_interface->op(BT_VND_OP_POWER_CTRL, &powerstate);
if (ret < 0)
{
ALOGE("Failed to turn on power from bt vendor interface");
return -1;
}
ret = vendor_interface->op(BT_VND_OP_USERIAL_OPEN, fd);
ALOGE("ret value: %d", ret);
/* This is just a hack; needs to be removed */
ret = 1;
ALOGE("setting ret value to 1 manually");
if (ret != 1)
{
ALOGE("Failed to get fd from bt vendor interface");
return -1;
} else {
ALOGE("FD: %x", fd[0]);
return fd[0];
}
} else {
if (vendor_interface) {
ALOGE("Close and cleanup the interfaces");
int ret = vendor_interface->op(BT_VND_OP_USERIAL_CLOSE, NULL);
ALOGE("ret value: %d", ret);
vendor_interface->cleanup();
return 0;
} else {
ALOGE("Not able to find vendor interface handle");
return -1;
}
}
}
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_deinit_transport
DESCRIPTION
Platform specific routine to de-intialise the UART/SMD resource.
PLATFORM SPECIFIC DESCRIPTION
Closes the TTY/SMD file descriptor and sets the descriptor value to -1
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
The Close of the descriptor will trigger a failure in the Reader Thread
and hence cause a Deinit of the ReaderThread
===========================================================================*/
request_status ftm_bt_hci_pfal_deinit_transport()
{
int buf = 1;
write(pipefd[1],&buf,1);
if(!isLatestTarget())
{
close(fd_transport);
fd_transport = -1;
}
else
{
//Use libbt-vendor for chip de-initialization
init_transport_bdroid(FALSE);
}
return STATUS_SUCCESS;
}
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_init_uart
DESCRIPTION
Platform specific routine to intialise the UART/SMD resources.
PLATFORM SPECIFIC DESCRIPTION
Opens the TTY/SMD device file descriptor, congiures the TTY/SMD device for CTS/RTS
flow control,sets 115200 for TTY as the default baudrate and starts the Reader
Thread
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_pfal_init_transport(int mode)
{
struct termios term;
if(isLatestTarget())
{
printf("%s: ",__func__ );
//Use hidl_client_initialize for chip initialization
if (hidl_client_initialize(mode, &fd_transport) == false) {
printf("%s: HIDL client initialization failed \n", __func__);
return STATUS_NO_RESOURCES;
}
printf("%s: , fd:%d: ", __func__, fd_transport);
}
else
{
fd_transport = open(transport_dev, (O_RDWR | O_NOCTTY));
if (-1 == fd_transport)
{
return STATUS_NO_RESOURCES;
}
if (tcflush(fd_transport, TCIOFLUSH) < 0)
{
close(fd_transport);
return STATUS_FAIL;
}
if (tcgetattr(fd_transport, &term) < 0)
{
close(fd_transport);
return STATUS_FAIL;
}
cfmakeraw(&term);
/* Set RTS/CTS HW Flow Control*/
term.c_cflag |= (CRTSCTS | CLOCAL);
if (tcsetattr(fd_transport, TCSANOW, &term) < 0)
{
close(fd_transport);
return STATUS_FAIL;
}
/* Configure the /dev/ttyHS0 device to operate at 115200.
no need for msm8960 as it is using smd as transport
*/
if (!is_transportSMD)
if (ftm_bt_hci_pfal_changebaudrate(starting_baud) == FALSE)
{
close(fd_transport);
return STATUS_FAIL;
}
}
if (pipe(pipefd) == -1)
{
printf("pipe create error");
return STATUS_FAIL;
}
if(mode != MODE_FM) {
/* Creating read thread which listens for various masks & pkt requests */
pthread_create( &hci_cmd_thread_hdl, NULL, ftm_readerthread, NULL);
}
return STATUS_SUCCESS;
}
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_nwrite
DESCRIPTION
Platform specific routine to write the data in the argument to the UART/SMD
port intialised.
PLATFORM SPECIFIC DESCRIPTION
Write the buffer to the tty device and ensure it is completely written
In case of short write report error to the BT FTM layer.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_pfal_nwrite(uint8 *buf, int size)
{
int tx_bytes = 0, nwrite;
int i = 0, buf_size = size;
uint8 loop_back_cmd[6] = {0x1, 0x02, 0x18, 0x01, 0x01};
/*hci packet is not required to carry the Packet indicator (for UART interfaces) for msm8960
as it is using share memory interface */
int hci_uart_pkt_ind = 0;
if(fd_transport < 0)
return STATUS_NO_RESOURCES;
if ( buf[PIN_CON_CMD_OGF_BIT] == PIN_CON_CMD_OGF &&
buf[PIN_CON_CMD_OCF_BIT] == PIN_CON_CMD_OCF &&
(size > PIN_CON_CMD_SUBOP_BIT) &&
buf[PIN_CON_CMD_SUBOP_BIT] == PIN_CON_CMD_SUB_OP &&
(size > PIN_CON_CMD_INTER_BIT) &&
buf[PIN_CON_CMD_INTER_BIT] == PIN_CON_INTERFACE_ID)
{
is_slim_bus_test = 1;
printf("\nPinConnectivityTest: Sending loopback command to SOC before initiasing slimbus\n");
strlcpy(buf, loop_back_cmd, size);
}
do
{
nwrite = write(fd_transport, (buf + hci_uart_pkt_ind + tx_bytes), (size - hci_uart_pkt_ind - tx_bytes));
if (nwrite < 0)
{
printf("Error while writing ->\n");
return STATUS_SHORT_WRITE;
}
if (nwrite == 0)
{
printf("ftm_bt_hci_pfal_nwrite: zero-length write\n");
return STATUS_SHORT_WRITE;
}
tx_bytes += nwrite;
size -= nwrite;
} while (tx_bytes < size - hci_uart_pkt_ind);
if (verbose == 1)
{
printf("[%s] %s: CMD:", get_current_time(), __FUNCTION__);
for (i = 0; i < buf_size; i++)
{
printf(" %02X", buf[i]);
}
printf("\n");
}
return STATUS_SUCCESS;
}
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_nread
DESCRIPTION
Platform specific routine to read data from the UART/SMD port intialised into
the buffer passed in argument.
PLATFORM SPECIFIC DESCRIPTION
Read from the tty device into the buffer and ensure the read request is
completed, in case of short read report error to the BT FTM layer.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_hci_pfal_nread(uint8 *buf, int size)
{
int rx_bytes = 0, nread;
if(fd_transport < 0)
return STATUS_NO_RESOURCES;
do
{
nread = read(fd_transport, (buf + rx_bytes), (size - rx_bytes));
if (nread < 0)
{
printf("Error while reading ->\n");
return STATUS_SHORT_READ;
}
rx_bytes += nread;
} while (rx_bytes < size);
return STATUS_SUCCESS;
}
/*===========================================================================
FUNCTION ftm_bt_hci_pfal_changebaudrate
DESCRIPTION
Platform specific routine to intiate a change in baud rate
PLATFORM SPECIFIC DESCRIPTION
Convert the Baud rate passed to the speed_t type and program the
Baud rate change after ensuring all transmit is drained at the
current baud rate
DEPENDENCIES
It is expected that the Upper layer will intiate a Flow Off to the
BT SoC, to signal the stop of receive if the baud rate change is
initiated while SoC init is in progress
RETURN VALUE
RETURN VALUE
TRUE if SUCCESS, else FALSE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_hci_pfal_changebaudrate (uint32 new_baud)
{
struct termios term;
boolean status = TRUE;
speed_t baud_code;
speed_t actual_baud_code;
if (tcgetattr(fd_transport, &term) < 0)
{
printf("Can't get port settings\n");
status = FALSE;
}
else
{
baud_code = convert_baud(new_baud);
(void) cfsetospeed(&term, baud_code);
if (tcsetattr(fd_transport, TCSADRAIN, &term) < 0) /* don't change speed until last write done */
{
printf("bt_hci_qcomm_pfal_changebaudrate: tcsetattr:\n");
status = FALSE;
}
/* make sure that we reportedly got the speed we tried to set */
if (1 < verbose)
{
if (tcgetattr(fd_transport, &term) < 0)
{
printf("bt_hci_qcomm_pfal_changebaudrate: tcgetattr:\n");
status = FALSE;
}
if (baud_code != (actual_baud_code = cfgetospeed(&term)))
{
printf("bt_hci_qcomm_pfal_changebaudrate: new baud %u FAILED, got 0x%x\n", new_baud, actual_baud_code);
}
else
{
printf("bt_hci_qcomm_pfal_changebaudrate: new baud %u SUCCESS, got 0x%x\n", new_baud, actual_baud_code);
}
}
}
return status;
}

View File

@@ -1,278 +0,0 @@
/*==========================================================================
BT persist NV items access source file
Description
Read/Write APIs for retreiving NV items from persist memory.
# Copyright (c) 2011-12 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
05/25/12 jav Added FTM log that will display bt address while testing.
09/27/11 rrr Moved persist related API for c/c++ compatibility, needed
for random BD address to be persistent across target
reboots.
==========================================================================*/
#include "ftm_bt_persist.h"
#include <semaphore.h>
#ifdef BT_NV_SUPPORT
#include "bt_nv.h"
/* Semaphore shared by the Event handler and main thread */
extern sem_t semaphore_cmd_complete;
/*Flag to manage the verbose output */
extern int verbose;
/*===========================================================================
FUNCTION ftm_bt_send_nv_read_cmd
DESCRIPTION
Helper Routine to process the nv read command
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_send_nv_read_cmd
(
uint8 * cmd_buf, /* pointer to Cmd */
uint16 cmd_len /* Cmd length */
)
{
nv_persist_item_type my_nv_item;
nv_persist_stat_enum_type cmd_result;
boolean result = TRUE;
if(cmd_len >1)
{
switch(*(cmd_buf+1))
{
case NV_BD_ADDR_I:
cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BD_ADDR_I, &my_nv_item);
if (NV_SUCCESS != cmd_result)
{
if (verbose > 0)
{
fprintf (stderr, "nv_cmd_remote failed to get BD_ADDR from NV, code %d\n", cmd_result);
}
/* Send fail response */
result = FALSE;
}
else
{
/* copy bytes */
event_buf_nv_read_response[0] = FTM_BT_CMD_NV_READ;
event_buf_nv_read_response[1] = NV_BD_ADDR_I;
event_buf_nv_read_response[7] = my_nv_item.bd_addr[5];
event_buf_nv_read_response[6] = my_nv_item.bd_addr[4];
event_buf_nv_read_response[5] = my_nv_item.bd_addr[3];
event_buf_nv_read_response[4] = my_nv_item.bd_addr[2];
event_buf_nv_read_response[3] = my_nv_item.bd_addr[1];
event_buf_nv_read_response[2] = my_nv_item.bd_addr[0];
/* send BD_ADDR in the response */
fprintf (stderr, "nv_cmd_remote got NV_BD_ADDR_I from NV: %x:%x:%x:%x:%x:%x\n",
(unsigned int) my_nv_item.bd_addr[5], (unsigned int) my_nv_item.bd_addr[4],
(unsigned int) my_nv_item.bd_addr[3], (unsigned int) my_nv_item.bd_addr[2],
(unsigned int) my_nv_item.bd_addr[1], (unsigned int) my_nv_item.bd_addr[0]);
ftm_log_send_msg((const uint8 *)event_buf_nv_read_response,nv_read_response_size);
result = TRUE;
}
break;
case NV_BT_SOC_REFCLOCK_TYPE_I:
cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BT_SOC_REFCLOCK_TYPE_I, &my_nv_item);
if (NV_SUCCESS != cmd_result)
{
if (verbose > 0)
{
fprintf (stderr, "nv_cmd_remote failed to get BD_ADDR from NV, code %d\n", cmd_result);
}
/* Send fail response */
result = FALSE;
}
else
{
event_buf_nv_read_response[0] = FTM_BT_CMD_NV_READ;
event_buf_nv_read_response[1] = NV_BT_SOC_REFCLOCK_TYPE_I;
event_buf_nv_read_response[2] = (uint8) my_nv_item.bt_soc_refclock_type ;
event_buf_nv_read_response[7] = 0x0;
event_buf_nv_read_response[6] = 0x0;
event_buf_nv_read_response[5] = 0x0;
event_buf_nv_read_response[4] = 0x0;
event_buf_nv_read_response[3] = 0x0;
fprintf (stderr, "nv_cmd_remote got NV_BT_SOC_REFCLOCK_TYPE_I from NV: 0x%x\n",
(unsigned int) my_nv_item.bt_soc_refclock_type);
ftm_log_send_msg((const uint8 *)event_buf_nv_read_response,nv_read_response_size);
result = TRUE;
}
break;
case NV_BT_SOC_CLK_SHARING_TYPE_I:
cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BT_SOC_CLK_SHARING_TYPE_I, &my_nv_item);
if (NV_SUCCESS != cmd_result)
{
if (verbose > 0)
{
fprintf (stderr, "nv_cmd_remote failed to get CLK_SHARING from NV, code %d\n", cmd_result);
}
/* Send fail response */
result = FALSE;
}
else
{
event_buf_nv_read_response[0] = FTM_BT_CMD_NV_READ;
event_buf_nv_read_response[1] = NV_BT_SOC_CLK_SHARING_TYPE_I;
event_buf_nv_read_response[2] = (uint8) my_nv_item.bt_soc_clk_sharing_type ;
event_buf_nv_read_response[7] = 0x0;
event_buf_nv_read_response[6] = 0x0;
event_buf_nv_read_response[5] = 0x0;
event_buf_nv_read_response[4] = 0x0;
event_buf_nv_read_response[3] = 0x0;
fprintf (stderr, "nv_cmd_remote got NV_BT_SOC_CLK_SHARING_TYPE_I from NV: 0x%x\n",
(unsigned int) my_nv_item.bt_soc_refclock_type);
ftm_log_send_msg((const uint8 *)event_buf_nv_read_response,nv_read_response_size);
result = TRUE;
}
break;
}
if(result == FALSE)
ftm_log_send_msg(event_buf_nv_read_response_fail,nv_read_response_size_fail);
sem_post(&semaphore_cmd_complete);
return result;
}
return TRUE;
}
/*===========================================================================
FUNCTION ftm_bt_send_nv_write_cmd
DESCRIPTION
Helper Routine to process the nv write command
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_send_nv_write_cmd
(
uint8 * cmd_buf, /* pointer to Cmd */
uint16 cmd_len /* Cmd length */
)
{
nv_persist_item_type my_nv_item;
nv_persist_stat_enum_type cmd_result;
boolean result = TRUE;
if(cmd_len >1)
{
switch(*(cmd_buf+1))
{
case NV_BD_ADDR_I:
memcpy(&my_nv_item.bd_addr, (cmd_buf+2), NV_BD_ADDR_SIZE);
cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_WRITE_F, NV_BD_ADDR_I, &my_nv_item);
if (NV_SUCCESS != cmd_result)
{
if (verbose > 0)
{
fprintf (stderr, "nv_cmd_remote failed to get BD_ADDR from NV, code %d\n", cmd_result);
}
/* Send fail response */
result = FALSE;
}
else
{
result = TRUE;
}
break;
case NV_BT_SOC_REFCLOCK_TYPE_I:
switch (*(cmd_buf+2))
{
case NV_PS_BT_SOC_REFCLOCK_32MHZ:
case NV_PS_BT_SOC_REFCLOCK_19P2MHZ:
my_nv_item.bt_soc_refclock_type = (nv_ps_bt_soc_refclock_enum_type)(*(cmd_buf+2)) ;
break;
default:
fprintf (stderr, "Invalid Ref Clock option\n");
result = FALSE;
}
if (result != FALSE)
{
cmd_result= (nv_persist_stat_enum_type)bt_nv_cmd(NV_WRITE_F, NV_BT_SOC_REFCLOCK_TYPE_I, &my_nv_item);
if (NV_SUCCESS != cmd_result)
{
fprintf (stderr, "nv_cmd_remote failed to write SOC_REFCLOCK_TYPE to NV, code %d\n", cmd_result);
result = FALSE;
}
else
{
result = TRUE;
}
break;
}
case NV_BT_SOC_CLK_SHARING_TYPE_I:
switch (*(cmd_buf+2))
{
case NV_PS_BT_SOC_CLOCK_SHARING_ENABLED:
case NV_PS_BT_SOC_CLOCK_SHARING_DISABLED:
my_nv_item.bt_soc_clk_sharing_type = (nv_ps_bt_soc_clock_sharing_enum_type)(*(cmd_buf+2)) ;
break;
default:
fprintf (stderr, "Invalid Clock Sharing option\n");
result = FALSE;
}
if (result != FALSE)
{
cmd_result= (nv_persist_stat_enum_type)bt_nv_cmd(NV_WRITE_F, NV_BT_SOC_CLK_SHARING_TYPE_I, &my_nv_item);
if (NV_SUCCESS != cmd_result)
{
fprintf (stderr, "nv_cmd_remote failed to write SOC_CLK_SHARING_TYPE to NV, code %d\n", cmd_result);
result = FALSE;
}
else
{
result = TRUE;
}
break;
}
}
if(result == FALSE)
{
ftm_log_send_msg(event_buf_bt_nv_write_fail,nv_write_response_size);
sem_post(&semaphore_cmd_complete);
}
else
{
ftm_log_send_msg((const uint8 *)event_buf_bt_nv_write_pass,nv_write_response_size);
sem_post(&semaphore_cmd_complete);
}
return result;
}
return TRUE;
}
#endif /* End of BT_NV_SUPPORT */

View File

@@ -1,113 +0,0 @@
#ifndef _FTM_BT_PERSIST_H_
#define _FTM_BT_PERSIST_H_
/*==========================================================================
BT persist NV items access source file
Description
Read/Write APIs for retreiving NV items from persist memory.
# Copyright (c) 2011 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
09/27/11 rrr Moved persist related API for c/c++ compatibility, needed
for random BD address to be persistent across target
reboots.
==========================================================================*/
#ifdef __cplusplus
extern "C"
{
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include "ftm_bt_common.h"
#include <string.h>
#ifdef BT_NV_SUPPORT
#define FTM_BT_CMD_NV_READ 0xB
#define FTM_BT_CMD_NV_WRITE 0xC
const uint8 nv_read_response_size = 8;
const uint8 nv_read_response_size_fail = 2;
const uint8 nv_write_response_size = 2;
/* NV Write Responses */
const uint8 event_buf_bt_nv_write_pass[2] = { FTM_BT_CMD_NV_WRITE, FTM_BT_DRV_NO_ERR};
const uint8 event_buf_bt_nv_write_fail[2] = { FTM_BT_CMD_NV_WRITE, FTM_BT_NV_WRITE_FAIL};
/* NV Read Responses */
const uint8 event_buf_nv_read_response_fail[8] =
{
FTM_BT_CMD_NV_READ, FTM_BT_NV_READ_FAIL, 0x0, 0x0,0x0,0x0,0x0,0x0
};
uint8 event_buf_nv_read_response[8];
#endif /* BT_NV_SUPPORT */
/*===========================================================================
FUNCTION ftm_bt_send_nv_read_cmd
DESCRIPTION
Helper Routine to process the nv read command
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_send_nv_read_cmd
(
uint8 * cmd_buf, /* pointer to Cmd */
uint16 cmd_len /* Cmd length */
);
/*===========================================================================
FUNCTION ftm_bt_send_nv_write_cmd
DESCRIPTION
Helper Routine to process the nv write command
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
boolean ftm_bt_send_nv_write_cmd
(
uint8 * cmd_buf, /* pointer to Cmd */
uint16 cmd_len /* Cmd length */
);
#ifdef __cplusplus
}
#endif
#endif /* _FTM_BT_PERSIST_H_ */

View File

@@ -1,76 +0,0 @@
/*==========================================================================
FTM BT POWER HAL Header File
Description
Wrapper API definitions of the ftm bt power hal component.
# Copyright (c) 2010 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
06/18/10 rakeshk Created a header file to include the wrapper API
definitions for BT power control
07/07/10 rakeshk Modified the function name of BT power set HAL routine
===========================================================================*/
#include "ftm_bt_common.h"
#include "ftm_bt_power_pfal.h"
#ifndef __FTM_BT_POWER_HAL_H__
#define __FTM_BT_POWER_HAL_H__
/*===========================================================================
FUNCTION ftm_bt_power_hal_set
DESCRIPTION
Platform independent wrapper API which sets a BT power from PFAL
layer and returns the status of the PFAL operation.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_power_hal_set(bt_power_state state)
{
return ftm_bt_power_pfal_set(state);
}
/*===========================================================================
FtUNCTION ftm_bt_power_hal_check
DESCRIPTION
Platform independent wrapper API which gets the BT power from PFAL
layer and returns the current state of the BT HW.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
Current BT power state
SIDE EFFECTS
None
===========================================================================*/
bt_power_state ftm_bt_power_hal_check()
{
return ftm_bt_power_pfal_check();
}
#endif //__FTM_BT_POWER_HAL_H__

View File

@@ -1,71 +0,0 @@
/*==========================================================================
FTM BT POWER PFAL Header File
Description
PFAL API declarations of the ftm bt power pfal component.
# Copyright (c) 2010 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
06/18/10 rakeshk Created a header file to hold the PFAL declarations for
BT power programming
07/07/10 rakeshk Modified the function name of BT power set PFAL routine
===========================================================================*/
#include "ftm_bt_common.h"
#ifndef __FTM_BT_POWER_PFAL_H__
#define __FTM_BT_POWER_PFAL_H__
/*===========================================================================
FUNCTION ftm_bt_power_pfal_set
DESCRIPTION
Platform dependent interface API which sets the BT power
and returns the status of the toggle operation.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_power_pfal_set(bt_power_state state);
/*===========================================================================
FUNCTION ftm_bt_power_pfal_check
DESCRIPTION
Platform dependent interface API which intiates a BT power read/check
and returns the current state of the BT HW.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
Current BT power state
SIDE EFFECTS
None
===========================================================================*/
bt_power_state ftm_bt_power_pfal_check();
#endif

View File

@@ -1,197 +0,0 @@
/*==========================================================================
FTM Platform specfic BT power File
Description
Platform specific routines to toggle/read the BT power state
# Copyright (c) 2010-2011 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
06/18/10 rakeshk Created a source file to implement platform specific
routines for BT power.
07/07/10 rakeshk Added routine to find the sysfs entry for bluetooth in
runtime
07/07/10 rakeshk Added call to init the rfkill state path in case of first
read
===========================================================================*/
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include "ftm_bt_power_pfal.h"
#include <string.h>
/* Bluetooth Rfkill Entry for Android */
static char *rfkill_state_path = NULL;
/*===========================================================================
FUNCTION init_rfkill_path
DESCRIPTION
Opens the sysfs entry for different types of rfkill and finds the one
which matches Bluetooth by iterating through the rfkill entries
and checking for bluetooth
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
TRUE if SUCCESS, else FALSE
SIDE EFFECTS
None
===========================================================================*/
boolean init_rfkill_path()
{
int fd;
int readsize;
int rfkillid;
char rfkill_path[64];
char buf[16];
for (rfkillid = 0; ; rfkillid++)
{
/* Open the different rfkill type entries and check if type macthes bluetooth */
snprintf(rfkill_path, sizeof(rfkill_path), "/sys/class/rfkill/rfkill%d/type", rfkillid);
fd = open(rfkill_path, O_RDONLY);
if (fd < 0)
{
printf("open(%s) failed: \n", rfkill_path);
return FALSE;
}
readsize = read(fd, &buf, sizeof(buf));
close(fd);
if (memcmp(buf, "bluetooth", 9) == 0)
{
break;
}
}
asprintf(&rfkill_state_path, "/sys/class/rfkill/rfkill%d/state", rfkillid);
return TRUE;
}
/*===========================================================================
FUNCTION ftm_bt_power_pfal_set
DESCRIPTION
Platform dependent interface API which sets the BT power state
and returns the status of the toggle operation.
PLATFORM SPECIFIC DESCRIPTION
Opens the rfkill entry for Bleutooth and initiates a write of the value
passed as argument.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
STATUS_SUCCESS if SUCCESS, else other reasons
SIDE EFFECTS
None
===========================================================================*/
request_status ftm_bt_power_pfal_set(bt_power_state state)
{
int sz;
int fd = -1;
request_status ret = STATUS_FAIL;
const char buffer = state;
if(rfkill_state_path == NULL)
{
if(init_rfkill_path() != TRUE)
goto out;
}
fd = open(rfkill_state_path, O_WRONLY);
if (fd < 0)
{
ret = STATUS_NO_RESOURCES;
goto out;
}
sz = write(fd, &buffer, 1);
if (sz < 0)
{
goto out;
}
ret = STATUS_SUCCESS;
out:
if (fd >= 0)
close(fd);
return ret;
}
/*===========================================================================
FUNCTION ftm_bt_power_pfal_check
DESCRIPTION
Platform dependent interface API which intiates a BT power read/check
and returns the current state of the BT HW.
PLATFORM SPECIFIC DESCRIPTION
Opens the rfkill entry for Bleutooth and initiates a read on the rfkill
descriptor.
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
Current BT power state
SIDE EFFECTS
None
===========================================================================*/
bt_power_state ftm_bt_power_pfal_check()
{
int sz;
bt_power_state state= BT_OFF;
int fd = -1;
char buffer = '0';
if(rfkill_state_path == NULL)
{
if(init_rfkill_path() != TRUE)
goto out;
}
fd = open(rfkill_state_path, O_RDONLY);
if (fd < 0)
{
goto out;
}
sz = read(fd, &buffer, 1);
if (sz < 0)
{
goto out;
}
out:
if (fd >= 0)
close(fd);
state = (bt_power_state)buffer;
return state;
}

View File

@@ -1,141 +0,0 @@
/*==========================================================================
FTM BT HCI PFAL Header File
Description
Queue insert/delete routines and data structures
# Copyright (c) 2010-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
06/18/10 rakeshk Created
11/09/10 rakeshk Added two APIs to perform read/write of BT Top level
I2C registers
===========================================================================*/
#if defined(CONFIG_FTM_BT) || defined(CONFIG_FTM_FM)
#include <ftm_bt_common.h>
#include "ftm_bt.h"
#include <semaphore.h>
#include <pthread.h>
/* Semaphore shared by the Event handler and main thread */
extern sem_t semaphore_cmd_complete;
/* Structure used by the FTM BT/FM component to
* queue the FTM packet contents
*/
pthread_mutex_t fm_event_lock;
pthread_cond_t fm_event_cond;
extern int fm_passthrough;
typedef struct cmdQ
{
int command_id;/*Command id */
void *data; /* Command data */
boolean bt_command; /* whether BT or FM command */
int cmd_len; /* Command length */
struct cmdQ *next; /* pointer to next CmdQ item */
}cmdQ;
/* Callback declaration for BT FTM packet processing */
void *bt_ftm_diag_dispatch(void *req_pkt, uint16 pkt_len);
/*===========================================================================
FUNCTION qinsert_cmd
DESCRIPTION
Command Queue insert routine. Add the FTM BT packet to the Queue
DEPENDENCIES
NIL
RETURN VALUE
RETURNS FALSE without adding queue entry in failure
to allocate a new Queue item
else returns TRUE
SIDE EFFECTS
increments the number of commands queued
===========================================================================*/
boolean qinsert_cmd(ftm_bt_pkt_type *ftm_bt_pkt);
/*===========================================================================
FUNCTION dequeue_send
DESCRIPTION
Command Queue delete and calls HCI send routine. Dequeues the HCI data from
the queue and sends it to HCI HAL layer.
DEPENDENCIES
NIL
RETURN VALUE
RETURN NIL
SIDE EFFECTS
decrements the number of command queued
===========================================================================*/
void dequeue_send();
/*===========================================================================
FUNCTION i2c_write
DESCRIPTION
Helper function to construct the I@C request to be sent to the FM I2C
driver
DEPENDENCIES
NIL
RETURN VALUE
-1 in failure,positive or zero in success
SIDE EFFECTS
None
===========================================================================*/
int i2c_write
(
int fd,
unsigned char offset,
const unsigned char* buf,
unsigned char len,
unsigned int slave_addr
);
/*===========================================================================
FUNCTION i2c_read
DESCRIPTION
Helper function to construct the I2C request to read data from the FM I2C
driver
DEPENDENCIES
NIL
RETURN VALUE
-1 in failure,positive or zero in success
SIDE EFFECTS
None
===========================================================================*/
int i2c_read
(
int fd,
unsigned char offset,
const unsigned char* buf,
unsigned char len,
unsigned int slave_addr
);
#endif

View File

@@ -1,43 +0,0 @@
/*==========================================================================
FTM WLAN Source File
# Copyright (c) 2013-2014 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
#ifndef _FTM_DBG_H_
#define _FTM_DBG_H_
#include <stdint.h>
#define FTM_DBG_ERROR 0x00000001
#define FTM_DBG_INFO 0x00000002
#define FTM_DBG_TRACE 0x00000004
#define FTM_DBG_DEFAULT (FTM_DBG_ERROR)
extern unsigned int g_dbg_level;
struct ftm_config
{
int total_num_slots;
uint32_t slot_id[4];
uint32_t slot_size[4];
};
extern struct ftm_config ftm_cfg;
#ifdef DEBUG
void current_time();
#define DPRINTF(_level, _x...)\
do {\
if (g_dbg_level & (_level))\
{\
fprintf(stderr, _x);\
}\
} while (0);
#else
#define DPRINTF(_level, x...) do { } while (0);
#endif
#endif /* _FTM_DBG_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,993 +0,0 @@
/*==========================================================================
FTM FM Common Header File
Description
Global Data declarations of the ftm fm component.
# Copyright (c) 2010-2012, 2014 by Qualcomm Technologies, Inc. All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
08/03/2011 uppalas Adding support for new ftm commands
06/18/10 rakeshk Created a header file to hold the definitons for ftm fm
task
07/06/10 rakeshk Clean roomed the data structures and defined data
structures to be passed to the PFAL layers
01/11/11 rakeshk Added support for new FTM APIS
02/09/11 rakeshk Added support for BLER FTM APIs
04/03/11 ananthk Added support for FM FTM Transmit APIs
===========================================================================*/
#ifdef CONFIG_FTM_FM
#include "diagpkt.h"
#include "log.h"
#include <sys/types.h>
#define FTM_FM_LOG_PKT_ID 65
#define FTM_FM_CMD_CODE 28
#define LOG_FTM_FM_C ((uint16) 0x14CC)
#define FEATURE_FTM_FM_DEBUG
#define DEFAULT_DATA_SIZE 249
/* FM6500 A0 chip version.
**/
#define FM6500_A0_VERSION (0x01010013)
/**
* * FM6500 2.0 chip version.
**/
#define FMQSOCCOM_FM6500_20_VERSION (0x01010010)
/**
* * FM6500 2.1 chip version.
**/
#define FMQSOCCOM_FM6500_21_VERSION (0x02010204)
/**
* WCN 2243 1.0's FM chip version.
*/
#define FMQSOCCOM_FM6500_WCN2243_10_VERSION (0x0302010A)
/**
* WCN 2243 2.0's FM chip version.
*/
#define FMQSOCCOM_FM6500_WCN2243_20_VERSION (0x04020205)
extern int chipVersion;
/* RDS Group processing parameters */
#define FM_RX_RDS_GRP_RT_EBL 1
#define FM_RX_RDS_GRP_PS_EBL 2
#define FM_RX_RDS_GRP_AF_EBL 4
#ifdef FM_SOC_TYPE_CHEROKEE
#define FM_RX_RDS_GRP_PS_SIMPLE_EBL 8
#define FM_RX_RDS_GRP_ECC_EBL 32
#define FM_RX_RDS_GRP_PTYN_EBL 64
#define FM_RX_RDS_GRP_RT_PLUS_EBL 128
#else
#define FM_RX_RDS_GRP_PS_SIMPLE_EBL 16
#endif
/* lower and upper band limits of regions */
#define REGION_US_EU_BAND_LOW 87500
#define REGION_US_EU_BAND_HIGH 107900
#define REGION_JAPAN_STANDARD_BAND_LOW 76000
#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
#define REGION_JAPAN_WIDE_BAND_LOW 90000
#define REGION_JAPAN_WIDE_BAND_HIGH 108000
#define V4L2_CID_PRIVATE_BASE 0x08000000
#define MAX_RDS_PS_LENGTH 108
#define MAX_RDS_RT_LENGTH 64
#define V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS_EXT 0x08000042
typedef enum {
V4L2_CID_PRIVATE_IRIS_HLSI = (V4L2_CID_PRIVATE_BASE + 0x1d),
V4L2_CID_PRIVATE_IRIS_SOFT_MUTE,
V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR,
V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN,
V4L2_CID_PRIVATE_IRIS_RIVA_PEEK,
V4L2_CID_PRIVATE_IRIS_RIVA_POKE,
V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR,
V4L2_CID_PRIVATE_IRIS_SSBI_PEEK,
V4L2_CID_PRIVATE_IRIS_SSBI_POKE,
V4L2_CID_PRIVATE_IRIS_TX_TONE,
V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS,
V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER,
V4L2_CID_PRIVATE_IRIS_AGC_CTRL = 0x08000043,
V4L2_CID_PRIVATE_IRIS_AGC_STATE,
V4L2_CID_PRIVATE_IRIS_READ_DEFAULT = 0x00980928,//using private CIDs under userclass
V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT,
}v4l2_cid_private_iris_t_copy;
typedef enum
{
/* Total no. of PS names that can be transmitted : 12
Width of each transmitted PS name is : 8
Total no. of PS characters that can be transmitted : (12*8 = 96)
*/
MAX_TX_PS_LEN = 96,
MAX_TX_PS_RPT_CNT = 15,
}FmTxPSFeatures;
/* FTM FM command IDs */
typedef enum
{
#ifdef FEATURE_FTM_FM_DEBUG
FTM_FM_RX_SET_POWER_MODE = 13,
FTM_FM_RX_SET_SIGNAL_THRESHOLD = 14,
FTM_FM_RX_GET_RSSI_LIMIT = 16,
FTM_FM_RX_GET_PS_INFO = 17,
FTM_FM_RX_GET_RT_INFO = 18,
FTM_FM_RX_GET_AF_INFO = 19,
FTM_FM_RX_SEARCH_STATIONS = 20,
FTM_FM_RX_SEARCH_RDS_STATIONS = 21,
FTM_FM_RX_SEARCH_STATIONS_LIST = 22,
FTM_FM_RX_CANCEL_SEARCH = 23,
FTM_FM_RX_RDS_GROUP_PROC_OPTIONS = 25,
FTM_FM_RX_RDS_PI_MATCH_OPTIONS = 26,
FTM_FM_TX_GET_PS_FEATURES = 36,
FTM_FM_TX_TX_PS_INFO = 38,
FTM_FM_TX_STOP_PS_INFO_TX = 39,
FTM_FM_TX_TX_RT_INFO = 40,
FTM_FM_TX_STOP_RT_INFO_TX = 41,
FTM_FM_RX_GET_SIGNAL_THRESHOLD = 46,
FTM_FM_FMWAN_REG_RD = 51,
FTM_FM_RX_GET_DEFAULTS = 62,
FTM_FM_RX_SET_DEFAULTS = 63,
FTM_FM_RX_GET_SINR_SAMPLES = 64,
FTM_FM_RX_SET_SINR_SAMPLES = 65,
FTM_FM_RX_GET_SINR_THRESHOLD = 66,
FTM_FM_RX_SET_SINR_THRESHOLD = 67,
FTM_FM_RX_GET_ONCHANNEL_TH = 68,
FTM_FM_RX_SET_ONCHANNEL_TH = 69,
FTM_FM_RX_GET_OFFCHANNEL_TH = 70,
FTM_FM_RX_SET_OFFCHANNEL_TH = 71,
FTM_FM_TX_PWR_LVL_CFG = 72,
#endif /* FEATURE_FTM_FM_DEBUG */
FTM_FM_RX_ENABLE_RECEIVER = 7,
FTM_FM_RX_DISABLE_RECEIVER = 8,
FTM_FM_RX_CONFIGURE_RECEIVER = 9,
FTM_FM_RX_SET_MUTE_MODE = 10,
FTM_FM_RX_SET_STEREO_MODE = 11,
FTM_FM_RX_SET_STATION = 12,
FTM_FM_RX_GET_STATION_PARAMETERS = 15,
FTM_FM_RX_RDS_GROUP_OPTIONS = 24,
FTM_FM_TX_ENABLE_TRANSMITTER = 33,
FTM_FM_TX_DISABLE_TRANSMITTER = 34,
FTM_FM_TX_CONFIGURE_TRANSMITTER = 35,
FTM_FM_TX_SET_STATION = 37,
FTM_FM_TX_TX_RDS_GROUPS = 42,
FTM_FM_TX_TX_CONT_RDS_GROUPS = 43,
FTM_FM_TX_TX_RDS_CTRL = 44,
FTM_FM_TX_GET_RDS_GROUP_BUF_SIZE = 45,
FTM_FM_BUS_WRITE = 47,
FTM_FM_BUS_READ = 48,
FTM_FM_NOTIFY_WAN = 49,
FTM_FM_NOTIFY_FM = 50,
FTM_FM_ROUTE_AUDIO = 52,
FTM_FM_RX_SET_AF_THRESHOLD = 53,
FTM_FM_RX_SET_RSSI_CHECK_TIMER = 54,
FTM_FM_RX_SET_RDS_PI_TIMER = 55,
FTM_FM_RX_GET_AF_THRESHOLD = 56,
FTM_FM_RX_GET_RSSI_CHECK_TIMER = 57,
FTM_FM_RX_GET_RDS_PI_TIMER = 58,
FTM_FM_RX_GET_RDS_ERR_COUNT = 59,
FTM_FM_RX_RESET_RDS_ERR_COUNT = 60,
FTM_FM_TX_SEARCH_STATIONS = 61,
FTM_FM_SET_HLSI = 100,
FTM_FM_SET_SOFT_MUTE = 101,
FTM_FM_SET_ANTENNA = 102,
FTM_FM_SET_NOTCH_FILTER = 103,
FTM_FM_READ_RDS_GRP_CNTRS = 104,
FTM_FM_SET_TONE_GENERATION = 105,
FTM_FM_PEEK_SSBI = 106,
FTM_FM_POKE_SSBI = 107,
FTM_FM_PEEK_RIVA_WORD = 108,
FTM_FM_POKE_RIVA_WORD = 109,
FTM_FM_ENABLE_AUDIO = 111,
FTM_FM_DISABLE_AUDIO = 112,
FTM_FM_VOLUME_SETTING = 113,
FTM_FM_READ_RDS_GRP_CNTRS_EXT = 114,
FTM_FM_SET_GET_RESET_AGC = 115,
FTM_FM_MAX
} ftm_fm_sub_cmd_type;
#define XFR_CTRL_OFFSET 0x1F
/* Wait time for ensuring XFR is generated */
#define WAIT_ON_ISR_DELAY 15000 //15 ms
#define AFTH_OFFSET 0x2E
#define CHCOND_OFFSET 0x22
#define RDSTIMEOUT_OFFSET 0x25
#define FM_SLAVE_ADDR 0x2A
#define RDSERR_OFFSET 0x24
#define RDSRESET_OFFSET 0x20
#define BLOCKS_PER_GROUP 0x04
#define FTM_FM_RDS_COUNT 0x11
#define MAX_RIVA_DATA_LEN 245
#define MAX_RIVA_PEEK_RSP_SIZE 251
#define SSBI_PEEK_DATA_SIZE 1
#define IRIS_BUF_PEEK 6
#define IRIS_BUF_SSBI_PEEK IRIS_BUF_PEEK+1
#define IRIS_BUF_RDS_CNTRS IRIS_BUF_SSBI_PEEK+1
#define IRIS_BUF_RD_DEFAULT IRIS_BUF_RDS_CNTRS+1
#ifdef FM_SOC_TYPE_CHEROKEE
#define RDS_GRP_CNTRS_SIZE 48
#else
#define RDS_GRP_CNTRS_SIZE 36
#endif
/* Generic result, used for any command that only returns an error code */
typedef enum
{
FTM_FM_SUCCESS,
FTM_FAIL,
FTM_FILE_DOES_NOT_EXIST,
FTM_MMC_ERROR,
FTM_FM_UNRECOGNIZED_CMD,
FTM_NO_RESOURCES,
FTM_FM_PENDING,
FTM_INVALID_PARAM,
FTM_FM_DISALLOWED,
FTM_TEST_NOT_IMPLEMENTED,
FTM_CUST_HW_ID_UNKNOWN,
FTM_FM_BUS_WRITE_ERROR,
FTM_FM_BUS_READ_ERROR,
FTM_FM_CLIENT_MAX,
} ftm_fm_api_result_type;
/* FM power state enum */
typedef enum
{
FM_POWER_OFF,
FM_POWER_TRANSITION,
FM_RX_ON,
FM_TX_ON
}fm_power_state;
/* FM command status enum */
typedef enum
{
FM_CMD_SUCCESS,
FM_CMD_PENDING,
FM_CMD_NO_RESOURCES,
FM_CMD_INVALID_PARAM,
FM_CMD_DISALLOWED,
FM_CMD_UNRECOGNIZED_CMD,
FM_CMD_FAILURE
}fm_cmd_status_type;
/**
* FM event result.
*/
typedef enum
{
FM_EV_SUCCESS = 0,
/**< Event indicates success. */
FM_EV_FAILURE = 1,
/**< Event is a response to a command that failed */
FM_EV_CMD_DISALLOWED = 2,
/**< Event is a response to a command that was disallowed. */
FM_EV_CMD_INVALID_PARAM = 3
/**< Event is a response to a command that contained an invalid parameter. */
} FmEvResultType;
/**
* FM Receiver event names.
*/
typedef enum
{
/* -----------------------------------------------
1 -> FM Receiver initialization events
----------------------------------------------- */
FM_RX_EV_ENABLE_RECEIVER = 0,
FM_RX_EV_DISABLE_RECEIVER,
FM_RX_EV_CFG_RECEIVER,
/* -----------------------------------------------
2 -> FM receiver control events
----------------------------------------------- */
FM_RX_EV_MUTE_MODE_SET,
FM_RX_EV_STEREO_MODE_SET,
FM_RX_EV_RADIO_STATION_SET,
FM_RX_EV_PWR_MODE_SET,
FM_RX_EV_SET_SIGNAL_THRESHOLD,
/* -----------------------------------------------
3 -> FM receiver status events
----------------------------------------------- */
FM_RX_EV_RADIO_TUNE_STATUS,
FM_RX_EV_STATION_PARAMETERS,
FM_RX_EV_RDS_LOCK_STATUS,
FM_RX_EV_STEREO_STATUS,
FM_RX_EV_SERVICE_AVAILABLE,
FM_RX_EV_GET_SIGNAL_THRESHOLD,
/* -----------------------------------------------
4 -> FM search status events
----------------------------------------------- */
FM_RX_EV_SEARCH_IN_PROGRESS,
FM_RX_EV_SEARCH_RDS_IN_PROGRESS,
FM_RX_EV_SEARCH_LIST_IN_PROGRESS,
FM_RX_EV_SEARCH_COMPLETE,
FM_RX_EV_SEARCH_RDS_COMPLETE,
FM_RX_EV_SEARCH_LIST_COMPLETE,
FM_RX_EV_SEARCH_CANCELLED,
/* -----------------------------------------------
5 -> FM RDS status events
----------------------------------------------- */
FM_RX_EV_RDS_GROUP_DATA,
FM_RX_EV_RDS_PS_INFO,
FM_RX_EV_RDS_RT_INFO,
FM_RX_EV_RDS_AF_INFO,
FM_RX_EV_RDS_PI_MATCH_AVAILABLE,
/* -----------------------------------------------
6 -> FM RDS control events
----------------------------------------------- */
FM_RX_EV_RDS_GROUP_OPTIONS_SET,
FM_RX_EV_RDS_PROC_REG_DONE,
FM_RX_EV_RDS_PI_MATCH_REG_DONE,
FM_RX_EV_MAX_EVENT
} FmRxEventType;
typedef enum radio_band_type
{
FM_US_EU = 0x0,
FM_JAPAN_STANDARD = 0x1,
FM_JAPAN_WIDE = 0x2,
FM_USER_DEFINED = 0x4
}radio_band_type;
typedef enum emphasis_type
{
FM_RX_EMP75 = 0x0,
FM_RX_EMP50 = 0x1
}emphasis_type;
typedef enum channel_space_type
{
FM_RX_SPACE_200KHZ = 0x0,
FM_RX_SPACE_100KHZ = 0x1,
FM_RX_SPACE_50KHZ = 0x2
}channel_space_type;
typedef enum rds_system_type
{
FM_RX_RDBS_SYSTEM = 0x0,
FM_RX_RDS_SYSTEM = 0x1,
FM_RX_NO_RDS_SYSTEM = 0x2
}rds_sytem_type;
typedef struct band_limit_freq
{
uint32 lower_limit;
uint32 upper_limit;
}band_limit_freq;
typedef enum rds_sync_type
{
FM_RDS_NOT_SYNCED = 0x0,
FM_RDS_SYNCED = 0x1
}rds_sync_type;
typedef enum stereo_type
{
FM_RX_MONO = 0x0,
FM_RX_STEREO = 0x1
}stereo_type;
typedef enum fm_service_available
{
FM_SERVICE_NOT_AVAILABLE = 0x0,
FM_SERVICE_AVAILABLE = 0x1
}fm_service_available;
typedef enum mute_type
{
FM_RX_NO_MUTE = 0x00,
FM_RX_MUTE_RIGHT = 0x01,
FM_RX_MUTE_LEFT = 0x02,
FM_RX_MUTE_BOTH = 0x03
}mute_type;
typedef enum antenna_type
{
WIRED_HS,
PWB_ANT
}antenna_type;
typedef enum audio_output
{
HEADSET,
SPEAKER,
} audio_output;
/**
* RDS/RBDS Program Type type.
*/
typedef uint8 fm_prgm_type;
/**
* RDS/RBDS Program Identification type.
*/
typedef uint16 fm_prgmid_type;
/**
* RDS/RBDS Program Services type.
*/
typedef char fm_prm_services;
/**
* RDS/RBDS Radio Text type.
*/
/*
* FM RX RIVA peek request
*/
typedef struct fm_riva_peek_word
{
uint8 subOpcode;
uint32 startaddress;
uint8 payload_length;/*In Bytes*/
uint8 data[MAX_RIVA_DATA_LEN];
}__attribute__((packed))fm_riva_peek_word;
/*
* FM RX RIVA poke request
*/
typedef struct fm_riva_poke_word
{
uint8 subOpcode;
uint32 startaddress;
uint8 payload_length;/*In Bytes*/
uint8 data[MAX_RIVA_DATA_LEN];
}__attribute__((packed))fm_riva_poke_word ;
/*
* FM RX SSBI peek/poke request
*/
typedef struct fm_ssbi_poke_reg
{
uint16 startaddress;
uint8 data;
}__attribute__((packed))fm_ssbi_poke_reg;
/*
* fm Set Get Reset AGC request
*/
typedef struct fm_set_get_reset_agc_req
{
uint8 ucCtrl;
uint8 ucGainState;
}__attribute__((packed))fm_set_get_reset_agc_req;
typedef struct fm_set_get_reset_agc_params
{
uint8 ucCurrentGainState;
uint8 ucGainStateChange1;
uint8 ucGainStateChange2;
uint8 ucGainStateChange3;
}__attribute__((packed))fm_set_get_reset_agc_params;
typedef PACKED struct
{
uint8 status ;
uint8 data_length ;
uint8 data[DEFAULT_DATA_SIZE];
}__attribute__((packed)) readDefaults_data;
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
uint8 status ;
uint8 data_length ;
uint8 data[DEFAULT_DATA_SIZE];
}__attribute__((packed)) default_read_rsp;
/*RDS Group counters*/
typedef struct fm_rds_grp_cntrsparams
{
uint32 totalRdsSBlockErrors;
uint32 totalRdsGroups;
uint32 totalRdsGroup0;
uint32 totalRdsGroup2;
uint32 totalRdsBlockB;
uint32 totalRdsProcessedGroup0;
uint32 totalRdsProcessedGroup2;
uint32 totalRdsGroupFiltered;
uint32 totalRdsChangeFiltered;
}__attribute__((packed)) fm_rds_grp_cntrsparams;
/*RDS Group counters extended */
typedef struct fm_rds_grpcntrs_extendedparams
{
uint32 totalRdsSyncLoss;
uint32 totalRdsNotSync;
uint32 totalRdsSyncInt;
}__attribute__((packed)) fm_rds_grpcntrs_extendedparams;
typedef char fm_radiotext_info;
/**
* FM Global Paramaters struct.
*/
typedef struct
{
uint32 current_station_freq;/*a frequency in kHz the band range*/
uint8 service_available;
uint8 rssi; /* rssi range from 0-100*/
uint8 stype;
uint8 rds_sync_status;
uint8 mute_status;
uint8 ssbi_peek_data;
fm_prgmid_type pgm_id; /* Program Id */
fm_prgm_type pgm_type; /* Program type */
fm_prm_services pgm_services[MAX_RDS_PS_LENGTH];
fm_radiotext_info radio_text[MAX_RDS_RT_LENGTH];/* RT maximum is 64 bytes */
fm_riva_poke_word riva_data_access_params;
fm_set_get_reset_agc_params set_get_reset_agc_params;
fm_rds_grp_cntrsparams rds_group_counters;
fm_rds_grpcntrs_extendedparams rds_group_counters_extended;
readDefaults_data default_read_data;
uint8 fm_ps_length;
uint8 fm_rt_length;
uint8 sinr_samples;
char sinr_threshold;
uint8 On_channel_threshold;
uint8 Off_channel_threshold;
}fm_station_params_available;
/**
* FM Config Request structure.
*/
typedef struct fm_config_data
{
uint8 band;
uint8 emphasis;
uint8 spacing;
uint8 rds_system;
band_limit_freq bandlimits;
uint8 is_fm_tx_on;
}fm_config_data;
/*
* FM RDS Options Config Request
*/
typedef struct fm_rds_options
{
uint32 rds_group_mask;
uint32 rds_group_buffer_size;
uint8 rds_change_filter;
}fm_rds_options;
/*
* FM RX Search stations request
*/
typedef struct fm_search_stations
{
uint8 search_mode;
uint8 dwell_period;
uint8 search_dir;
}fm_search_stations;
/*
* FM RX Search DDS stations request
*/
typedef struct fm_search_rds_stations
{
uint8 search_mode;
uint8 dwell_period;
uint8 search_dir;
uint8 program_type;
uint16 program_id;
}fm_search_rds_stations;
/*
* FM RX Search station lists request
*/
typedef struct fm_search_list_stations
{
uint8 search_mode;
uint8 search_dir;
uint32 srch_list_max;
/**< Maximum number of stations that can be returned from a search. */
uint8 program_type;
}fm_search_list_stations;
/*
* FM RX I2C request
*/
typedef struct fm_i2c_params
{
uint8 slaveaddress;
uint8 offset;
uint8 payload_length;
uint8 data[64];
}fm_i2c_params;
/* Structure containing the RDS PS Info to be transmitted */
typedef struct _tsFtmFmRdsTxPsType
{
uint32 ulPSStrLen;
/**< The size of the cTxPSStrPtr buffer.
*/
uint32 ucTxPSRptCnt;
/**< The number of times each 8 character string is repeated before the next
string is transmitted.
*/
uint16 tusTxPi;
/**< RDS/RBDS Program Identification to use for Program Service transmissions.
*/
uint8 tucTxPSPty;
/**< The RDS/RBDS Program Type to transmit.
*/
const char cTxPSStrPtr[108];
/**< A pointer to a buffer containing the Program Service string to transmit
(must be null terminated).
*/
} tsFtmFmRdsTxPsType;
typedef struct _tsFtmFmRdsTxRtType
{
uint32 ulRTStrLen;
/**< The size of the cTxRTStrPtr buffer.
*/
uint16 tusTxPi;
/**< RDS/RBDS Program Identification to use for RadioText transmissions.
*/
uint8 tucTxRTPty;
/**< The RDS/RBDS Program Type to transmit.
*/
const char cTxRTStrPtr[65];
/**< A pointer to a buffer containing the RadioText string to transmit
(must be null terminated).
*/
} tsFtmFmRdsTxRtType;
typedef struct _ftm_def_data_rd_req
{
uint8 mode;
uint8 length;
uint8 param_len;
uint8 param;
} __attribute__((packed))ftm_fm_def_data_rd_req;
typedef struct _ftm_def_data_wr_req
{
uint8 mode;
uint8 length;
uint8 data[DEFAULT_DATA_SIZE];
} __attribute__((packed))ftm_fm_def_data_wr_req;
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint8 length; /*RDS PS string length*/
uint8 string[MAX_RDS_PS_LENGTH]; /* RDS string */
}__attribute__((packed)) fmrdsps_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint8 length; /*RDS PS string length*/
uint8 string[MAX_RDS_RT_LENGTH]; /* RDS string */
}__attribute__((packed)) fmrdsrt_response;
/**
* FM All Request Union type.
*/
typedef union fm_cfg_request
{
fm_config_data cfg_param;
uint8 mute_param;
uint8 stereo_param;
uint32 freq;
fm_rds_options rds_options;
uint8 power_mode;
uint8 signal_threshold;
fm_search_stations search_stations_options;
fm_search_rds_stations search_rds_stations_options;
fm_search_list_stations search_list_stations_options;
fm_i2c_params i2c_params;
uint32 rds_group_options;
uint16 rx_af_threshold;
uint8 rx_rssi_checktimer;
uint rx_rds_pi_timer;
tsFtmFmRdsTxPsType tuFmPSParams;
tsFtmFmRdsTxRtType tuFmRTParams;
uint8 soft_mute_param;
uint8 antenna_type;
uint8 tx_tone_param;
uint8 rds_grp_counters;
uint8 rds_grp_counters_ext;
uint8 hlsi;
uint8 sinr_samples;
char sinr_threshold;
uint8 On_channel_threshold;
uint8 Off_channel_threshold;
uint8 notch;
fm_riva_peek_word riva_peek_params;
fm_riva_poke_word riva_data_access_params;
fm_ssbi_poke_reg ssbi_access_params;
fm_set_get_reset_agc_req set_get_agc_req_parameters;
ftm_fm_def_data_rd_req rd_default;
ftm_fm_def_data_wr_req wr_default;
uint8 tx_pwr_cfg;
uint8 audio_output;
uint8 audio_vlm;
}fm_cfg_request;
/* FTM FM request type */
typedef PACKED struct
{
diagpkt_cmd_code_type cmd_code;
diagpkt_subsys_id_type subsys_id;
diagpkt_subsys_cmd_code_type subsys_cmd_code;
uint16 cmd_id; /* command id (required) */
uint16 cmd_data_len;
uint16 cmd_rsp_pkt_size;
byte data[1];
}__attribute__((packed))ftm_fm_pkt_type;
/* Set MuteMode Response */
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint8 mutemode;
}__attribute__((packed)) mutemode_response;
/* Set StereoMode Response */
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint8 stereomode;
}__attribute__((packed)) stereomode_response;
/* I2C Response */
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint32 length; /*length of data read */
uint8 data[64]; /* I2C read dat buffer */
}__attribute__((packed)) fmbusread_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint8 sub_opcode;
uint32 start_address;
uint8 length; /*length of data read */
uint8 data[MAX_RIVA_DATA_LEN]; /* read dat buffer */
}__attribute__((packed)) rivaData_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint8 data;
}__attribute__((packed)) ssbiPeek_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint8 uccurrentgainstate;
uint8 ucgainstatechange1;
uint8 ucgainstatechange2;
uint8 ucgainstatechange3;
}__attribute__((packed)) set_get_reset_agc_response;
/*Read RDS Group counters responce*/
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
fm_rds_grp_cntrsparams read_rds_cntrs;
}__attribute__((packed)) ReadRDSCntrs_responce;
/*Read RDS Group counters response*/
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
fm_rds_grpcntrs_extendedparams read_rds_cntrs_ext;
}__attribute__((packed)) ReadRDSCntrs_ext_response;
/* Generic Response */
typedef PACKED struct
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
}__attribute__((packed)) generic_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
uint16 afthreshold;
} fmrxsetafthreshold_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
uint8 sinr_sample;
} getsinrsamples_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
char sinr_threshold;
} getsinrthreshold_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
uint8 sinr_on_th;
} getonchannelthreshold_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
uint8 sinr_off_th;
} getoffchannelthreshold_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
uint8 rssitimer;
} fmrxsetrssichecktimer_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
uint8 rdspitimer;
} fmrxsetrdspitimer_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
uint8 threshold;
} threshold_response;
typedef PACKED struct
{
diagpkt_subsys_header_type header ;
char result ;
uint32 rdserrcount;
uint32 numofblocks;
} rds_err_count_response;
/* Custom response for Get station parameters request */
struct fm_rx_get_station_parameters_response_t
{
diagpkt_subsys_header_type header ; /*Diag header*/
char result ;/* result */
uint32 stationFreq;
/* The currently tuned frequency in kHz (Example: 96500 -> 96.5Mhz)*/
uint8 servAvble;
/* The current service available indicator for the current station */
uint8 rssi;
/* The current signal strength level (0-100 range). */
uint8 stereoProgram;
/* The current mono/stereo indicator for this station */
uint8 rdsSyncStatus;
/* The current RDS/RBDS synchronization status */
uint8 muteMode;
/* The current FM mute mode */
}__attribute__((packed));
/* FTM Log Packet - Used to send back the event of a HCI Command */
typedef PACKED struct
{
log_hdr_type hdr;
byte EvName;
/* Event ID indicates which event is being returned. */
byte EvResult;
byte data[1]; /* Variable length payload,
look at FTM log id for contents */
} ftm_fm_log_pkt_type;
#define FTM_FM_LOG_HEADER_SIZE (sizeof (ftm_fm_log_pkt_type) - 1)
typedef struct fm_rx_get_station_parameters_response_t fm_rx_get_station_parameters_response;
/*===========================================================================
FUNCTION ftm_fm_dispatch
DESCRIPTION
Dispatch routine for the various FM Rx/Tx commands. Copies the data into
a global union data structure before calling the processing routine
DEPENDENCIES
NIL
RETURN VALUE
A Packed structre pointer including the response to the FTM FM packet
SIDE EFFECTS
None
===========================================================================*/
void * ftm_fm_dispatch(ftm_fm_pkt_type *ftm_fm_pkt, uint16 length );
/*===========================================================================
FUNCTION ftm_fm_enable_audio
DESCRIPTION
This function is used to take the audio output mode from QRCT.
DEPENDENCIES
none
===========================================================================*/
PACKED void* ftm_fm_enable_audio( void );
PACKED void* ftm_fm_disable_audio( void );
PACKED void* ftm_fm_setting_volume(void);
#endif /* CONFIG_FTM_FM */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,549 +0,0 @@
/*
*Copyright (c) 2018-2020, 2022 Qualcomm Technologies, Inc.
*
*All Rights Reserved.
*Confidential and Proprietary - Qualcomm Technologies, Inc.
*/
/* IPQ-QCA402X specific file */
#ifdef IPQ_AP_HOST_IOT
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <mtd/mtd-user.h>
#include "comdef.h"
#include "diagcmd.h"
#include "ftm_wlan.h"
#include "ftm_dbg.h"
#include "ftm_iot.h"
#ifdef IPQ_AP_HOST_IOT_QCA402X
#include "diag_api.h"
#endif /* IPQ_AP_HOST_IOT_QCA402X */
#ifdef IPQ_AP_HOST_IOT_IPQ
#include "btdaemon.h"
#endif /* IPQ50XX, IPQ95XX */
#define NHDLC_TERM 126
#define NHDLC_VERSION 1
#define NHDLC_TERM_SIZE 1
#define FLASH_CMD_ID_POS 1
#define MAX_BUF_SIZE 2048
#define WAIT_TIME_MS 100
#define SUBSYS_CMD_ID_POS 2
#define RESERVED_CMD_ID 0
#define DUT_INTERFACE_SELECT 1
#define DUT_INTERFACE_ID_POS 4
#define DUT_INTERFACE_SELECT_POS 10
#define DIAG_HDR_LEN (sizeof(diag_nonhdlc_hdr_t) + NHDLC_TERM_SIZE)
#define FTM_IOT_LOG_HEADER_SIZE sizeof(ftm_iot_log_pkt_type)
#define MEMSET_RESET_VALUE 0
#define DIAG_HEADER_SIZE 12
extern void diagpkt_free(void *pkt);
void print_array(uint8_t *addr, int len)
{
int i;
int line = 1;
for (i = 0; i < len; i++) {
if (i == (line * 80)) {
DPRINTF(FTM_DBG_TRACE, "\n");
line++;
}
DPRINTF(FTM_DBG_TRACE, "%02X ", addr[i]);
}
DPRINTF(FTM_DBG_TRACE, "\n");
}
#ifdef IPQ_AP_HOST_IOT_QCA402X
/*===========================================================================
FUNCTION iot_thr_func_qca402x
DESCRIPTION
Continously polls QCA402X for asynchronous data responses and
logs receievd asynchronous data responses to Diag module using
log-submit()
DEPENDENCIES
NIL
RETURN VALUE
Returns NULL on failure. Function also exits with NULL return value
when main indicates that this thread should be stopped
SIDE EFFECTS
NONE
===========================================================================*/
void *iot_thr_func_qca402x(void *hdl)
{
int bytes = 0;
void *rsp2 = NULL;
int diag_hdr_len = DIAG_HDR_LEN ;
void *new_iot_ftm_rsp2_pkt = NULL;
if (!hdl) {
DPRINTF(FTM_DBG_ERROR, "Invalid iotd handle\n");
return NULL;
}
new_iot_ftm_rsp2_pkt = malloc(MAX_BUF_SIZE);
if (!new_iot_ftm_rsp2_pkt) {
DPRINTF(FTM_DBG_ERROR, "Could not allocate response packet \n");
return NULL;
}
while(1) {
if (thread_stop == 1) {
DPRINTF(FTM_DBG_TRACE, "FTMd: Exiting thread.\n");
break;
}
memset(new_iot_ftm_rsp2_pkt, MEMSET_RESET_VALUE, MAX_BUF_SIZE);
sem_wait(&iot_sem);
/*If we recieve a response from QCA402X, allocate a buffer using diag alloc with correct
subsystem code and length */
while ((bytes = diag_recv(hdl, (uint8_t *)new_iot_ftm_rsp2_pkt,
MAX_BUF_SIZE,
WAIT_TIME_MS)) >= 0) {
if (bytes > MAX_BUF_SIZE || bytes <= diag_hdr_len) {
DPRINTF(FTM_DBG_ERROR, "Could not allocate async log response packet\n");
free (new_iot_ftm_rsp2_pkt);
return NULL;
}
rsp2 = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, (bytes - diag_hdr_len));
if (!rsp2) {
DPRINTF(FTM_DBG_ERROR, "Could not allocate async log response packet\n");
free (new_iot_ftm_rsp2_pkt);
return NULL;
}
/* Remove NHDLC header from recieved packet and store contents in
buffer allocated above */
memcpy(rsp2, (new_iot_ftm_rsp2_pkt + diag_hdr_len - NHDLC_TERM_SIZE),
(bytes - diag_hdr_len));
DPRINTF(FTM_DBG_TRACE, "FTMd: Asynchronous Data response has been sent.\n");
print_array((uint8_t *)rsp2, (bytes - diag_hdr_len) );
/*Remove an additional 4 bytes of header and log packet to diag module
asynchronously for further processing*/
log_submit(rsp2 + diag_hdr_len - NHDLC_TERM_SIZE);
diagpkt_free (rsp2);
memset(new_iot_ftm_rsp2_pkt, MEMSET_RESET_VALUE, MAX_BUF_SIZE);
}
sem_post(&iot_sem_async);
}
free (new_iot_ftm_rsp2_pkt);
diagpkt_free (rsp2);
pthread_exit(NULL);
}
/*===========================================================================
FUNCTION ftm_iot_dispatch_qca402x
DESCRIPTION
Function processes WIN IOT specific requests and relays to
QCA402x FTM layer for further processing. Recieves response
buffer from QCA402x and returns buffer meant for diag call back
This function handles NHDLC to HDLC translation and vice-versa
before sending and receivng buffers to QCA402X FTM layer
DEPENDENCIES
NIL
RETURN VALUE
Returns back buffer that is meant for diag callback
SIDE EFFECTS
NONE
===========================================================================*/
void *ftm_iot_dispatch_qca402x(void *iot_ftm_pkt, int pkt_len, void *hdl)
{
int diag_hdr_len = DIAG_HDR_LEN;
int ret = 0;
byte *payload_ptr = NULL;
void *rsp1 = NULL;
ftm_iot_req_pkt_type *new_iot_ftm_pkt = NULL;
void *new_iot_ftm_rsp_pkt = NULL;
char command[50] = {'\0'};
uint16_t *ftm_iot_flash_ptr = NULL;
uint16 ftm_iot_flash_cmd_code = 0;
/* The new packet length will be length of original request packet
+ size of NHDLC header + 1 byte of termination character */
int new_pkt_len = pkt_len + diag_hdr_len;
if (!iot_ftm_pkt || !pkt_len || !hdl) {
DPRINTF(FTM_DBG_ERROR, "Invalid ftm iot request packet or iotd handle\n");
return NULL;
}
new_iot_ftm_pkt = malloc(sizeof(ftm_iot_req_pkt_type) + pkt_len + NHDLC_TERM_SIZE);
if (!new_iot_ftm_pkt) {
DPRINTF(FTM_DBG_ERROR, "Could not create new ftm iot request packet\n");
return NULL;
}
memset(new_iot_ftm_pkt, MEMSET_RESET_VALUE, (sizeof(ftm_iot_req_pkt_type) + pkt_len + NHDLC_TERM_SIZE));
new_iot_ftm_rsp_pkt = malloc(MAX_BUF_SIZE);
if (!new_iot_ftm_rsp_pkt) {
DPRINTF(FTM_DBG_ERROR, "Could not create new ftm iot response packet\n");
free (new_iot_ftm_pkt);
return NULL;
}
memset(new_iot_ftm_rsp_pkt, MEMSET_RESET_VALUE, MAX_BUF_SIZE);
/* Add Non-HDLC header to request packet
and populate NHDLC header*/
new_iot_ftm_pkt->hdr.start = NHDLC_TERM;
new_iot_ftm_pkt->hdr.version = NHDLC_VERSION;
new_iot_ftm_pkt->hdr.length = pkt_len;
memcpy(&(new_iot_ftm_pkt->payload), iot_ftm_pkt, pkt_len);
payload_ptr = (byte *) &(new_iot_ftm_pkt->payload);
*( payload_ptr + pkt_len) = NHDLC_TERM;
ftm_iot_cmd_code = *(payload_ptr + SUBSYS_CMD_ID_POS);
ftm_iot_dut_interface_code = *(payload_ptr + DUT_INTERFACE_ID_POS);
ftm_iot_reserved_code = *(payload_ptr + SUBSYS_CMD_ID_POS + 1);
ftm_iot_flash_ptr = (uint16_t *) &(new_iot_ftm_pkt->payload);
ftm_iot_flash_cmd_code = *(ftm_iot_flash_ptr + FLASH_CMD_ID_POS);
/*Print packet after adding headers */
DPRINTF(FTM_DBG_TRACE, "FTMd: Request Packet of size %d bytes sent:\n", new_pkt_len);
print_array((uint8_t *)new_iot_ftm_pkt, new_pkt_len);
/*If the request packet it a DUT interface selection command,
update interface number and return a response packet that
is an encho of the request packet. ( In the case of multiple
QCA402x DUT attaches on IPQ platforms) */
if (((ftm_iot_cmd_code == MFG_CMD_ID_BLE_HCI) || (ftm_iot_cmd_code == MFG_CMD_ID_I15P4_HMI))
&& (ftm_iot_dut_interface_code == DUT_INTERFACE_SELECT)
&& (ftm_iot_reserved_code == RESERVED_CMD_ID)){
interface = *(payload_ptr + DUT_INTERFACE_SELECT_POS) - 1;
if (interface < 0) {
DPRINTF(FTM_DBG_ERROR, "Invalid DUT interface selection command\n");
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
return NULL;
}
rsp1 = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, pkt_len);
if (!rsp1){
DPRINTF(FTM_DBG_ERROR, "Could not allocate response packet for interface selection\n");
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
return NULL;
}
memcpy(rsp1, iot_ftm_pkt, pkt_len);
DPRINTF(FTM_DBG_TRACE, "FTMd: The DUT interface selected is %d \n",interface);
DPRINTF(FTM_DBG_TRACE, "FTMd: DUT interface resp packet of size %d bytes sent:\n",pkt_len);
print_array((uint8_t *)rsp1, pkt_len);
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
/*This resp pointer will be freed by diag later*/
return rsp1;
}
/*If the request packet is a MFG PROG command,
launch flash script and return a response packet that indicates
flashing mode of QCA402x is enabled or disabled */
if ((ftm_iot_flash_cmd_code == MFG_CMD_ID_MISC_PROG_MODE)){
if (ftm_iot_dut_interface_code == MFG_FLASH_ON){
strlcpy(command, "/usr/bin/qca402x_flash.sh flash on", sizeof(command));
}
if (ftm_iot_dut_interface_code == MFG_FLASH_OFF){
strlcpy(command, "/usr/bin/qca402x_flash.sh flash off", sizeof(command));
}
if (ftm_iot_dut_interface_code == MFG_USB_OFF){
strlcpy(command, "/usr/bin/qca402x_flash.sh usb-select off", sizeof(command));
}
if (ftm_iot_dut_interface_code == MFG_USB_ON){
strlcpy(command, "/usr/bin/qca402x_flash.sh usb-select on", sizeof(command));
}
if (ftm_iot_dut_interface_code == MFG_EDL_OFF){
strlcpy(command, "/usr/bin/qca402x_flash.sh edl off", sizeof(command));
}
if (ftm_iot_dut_interface_code == MFG_EDL_ON){
strlcpy(command, "/usr/bin/qca402x_flash.sh edl on", sizeof(command));
}
/*Return with NULL if string is empty or packet length is less than
10 for a DUT interface selection command to make sure there will be
no out of bound access */
if ( (command[0] == '\0') || (pkt_len <= DUT_INTERFACE_ID_POS) ) {
DPRINTF(FTM_DBG_ERROR, "Error: Invalid MFG Program command\n");
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
return NULL;
}
system(command);
DPRINTF(FTM_DBG_TRACE, "\n FTMd: Sent system command: %s \n", command);
/* Check of size for packet pointed to by payload_ptr has been done above
using pkt_len to make sure there is no out of bound access */
*(payload_ptr + DUT_INTERFACE_ID_POS) = MFG_PROG_RESP;
rsp1 = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, pkt_len);
if (!rsp1){
DPRINTF(FTM_DBG_ERROR, "Could not allocate response packet for MFG flash commands\n");
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
return NULL;
}
memcpy(rsp1, payload_ptr, pkt_len);
DPRINTF(FTM_DBG_TRACE, "FTMd: MFG Flash resp packet of size %d bytes sent:\n",pkt_len);
print_array((uint8_t *)rsp1, pkt_len);
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
/*This resp pointer will be freed by diag later*/
return rsp1;
}
sem_wait(&iot_sem_async);
/* Call IPQ-QCA402x diag APIs */
ret = diag_send(hdl, interface, (uint8_t *)new_iot_ftm_pkt, new_pkt_len);
if ((ret < 0) || (ret > MAX_BUF_SIZE)) {
DPRINTF(FTM_DBG_ERROR, "Could not send the request packet to QCA402x \n");
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
return NULL;
}
ret = diag_recv(hdl, (uint8_t *)new_iot_ftm_rsp_pkt, MAX_BUF_SIZE, WAIT_TIME_MS);
if ((ret < 0) || (ret > MAX_BUF_SIZE) || (ret <= diag_hdr_len)) {
DPRINTF(FTM_DBG_ERROR, "Could not recieve packet from QCA402x\n");
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
return NULL;
}
DPRINTF(FTM_DBG_TRACE,"Received Command Response of %d bytes\n",ret);
print_array((uint8_t *)new_iot_ftm_rsp_pkt, ret);
rsp1 = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, (ret - diag_hdr_len));
if (!rsp1){
DPRINTF(FTM_DBG_ERROR, "Could not allocate response packet\n");
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
return NULL;
}
memcpy(rsp1, (new_iot_ftm_rsp_pkt + diag_hdr_len - NHDLC_TERM_SIZE), (ret - diag_hdr_len));
free (new_iot_ftm_pkt);
free (new_iot_ftm_rsp_pkt);
sem_post(&iot_sem);
/*This resp pointer will be freed by diag module later*/
return (void *)rsp1;
}
#endif /* IPQ_AP_HOST_IOT_QCA402X */
#ifdef IPQ_AP_HOST_IOT_IPQ
/*===========================================================================
FUNCTION iot_thr_func_ipq
DESCRIPTION
Continously polls IPQ BTSS for asynchronous data responses and
logs received asynchronous data responses to Diag module using
log-submit()
DEPENDENCIES
NIL
RETURN VALUE
Returns NULL on failure. Function also exits with NULL return value
when main indicates that this thread should be stopped
SIDE EFFECTS
NONE
===========================================================================*/
void *iot_thr_func_ipq(void *hdl)
{
int bytes_read = 0, handle = 0;
void *buffer = NULL;
void *rsp = NULL;
struct timespec ts;
ftm_bt_rsp_pkt_type *ftm_async_pkt;
buffer = malloc(MAX_BUF_SIZE);
if (!buffer)
{
DPRINTF(FTM_DBG_ERROR, "Could not allocate memory to the buffer \n");
return NULL;
}
memset(buffer, MEMSET_RESET_VALUE, MAX_BUF_SIZE);
if(hdl == NULL || *((int*)hdl) < 0)
{
DPRINTF(FTM_DBG_ERROR, "\n Invalid Handle received from BTSS \n");
free(buffer);
return NULL;
}
handle = *((int*)hdl);
while(1)
{
if (thread_stop == 1) {
DPRINTF(FTM_DBG_TRACE, "FTMd: Exiting thread.\n");
break;
}
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
{
DPRINTF(FTM_DBG_ERROR, "clock_gettime");
free(buffer);
return NULL;
}
ts.tv_sec += user_sem_wait_timeout;
sem_timedwait(&iot_sem, &ts);
while((bytes_read = bt_daemon_receive(handle, &buffer)) > 0)
{
/*
* Checking for log status on the packets received
* ignore the received packets incase of disabled logging
*/
if(log_status(LOG_BT_HCI_EV_C))
{
rsp = log_alloc(LOG_BT_HCI_EV_C, (DIAG_HEADER_SIZE + bytes_read));
if (!rsp)
{
DPRINTF(FTM_DBG_ERROR, "Could not allocate rsp packet \n");
free(buffer);
return NULL;
}
ftm_async_pkt = (ftm_bt_rsp_pkt_type*)rsp;
memcpy(ftm_async_pkt->buf, buffer, bytes_read);
DPRINTF(FTM_DBG_TRACE, "\n Printing the Async Packet sent to QDART\n");
print_array((uint8_t *)rsp, (DIAG_HEADER_SIZE + bytes_read));
log_submit(rsp);
log_free(rsp);
memset(buffer, MEMSET_RESET_VALUE, MAX_BUF_SIZE);
}
}
sem_post(&iot_sem_async);
}
free(buffer);
pthread_exit(NULL);
}
/*===========================================================================
FUNCTION ftm_iot_dispatch_ipq
DESCRIPTION
Function processes WIN IOT specific requests and relays to
BTSS for further processing. Constructs response packet
and returns buffer meant for callback.
DEPENDENCIES
NIL
RETURN VALUE
Returns back buffer that is meant for diag callback
SIDE EFFECTS
NONE
===========================================================================*/
void *ftm_iot_dispatch_ipq(void *iot_ftm_pkt, int pkt_len, int *hdl)
{
void *rsp = NULL;
struct timespec ts;
int bytes_sent = -1;
if(hdl == NULL || *hdl < 0)
{
DPRINTF(FTM_DBG_ERROR, "\n Invalid Handle received from BTSS \n");
return NULL;
}
if (!iot_ftm_pkt)
{
DPRINTF(FTM_DBG_ERROR, "Invalid iot_ftm_pkt received \n");
return NULL;
}
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
{
perror("clock_gettime");
return NULL;
}
ts.tv_sec += user_sem_wait_timeout;
sem_timedwait(&iot_sem_async, &ts);
DPRINTF(FTM_DBG_TRACE, "\n Request Packet received for IPQ BT\n");
print_array((uint8_t *)iot_ftm_pkt, pkt_len);
bytes_sent = bt_daemon_send(*hdl, iot_ftm_pkt);
if(bytes_sent < 0)
{
perror("Unable to send Request Packet to IPQ BT");
return NULL;
}
/* Constructing ACK Packet */
rsp = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, pkt_len);
if (!rsp)
{
DPRINTF(FTM_DBG_ERROR, "\n Unable to allocate diag response packet \n");
return NULL;
}
memcpy(rsp, iot_ftm_pkt, pkt_len);
DPRINTF(FTM_DBG_TRACE, "\n ACK Packet constructed in FTM layer\n");
print_array((uint8_t *)rsp, pkt_len);
sem_post(&iot_sem);
/*This rsp pointer will be freed by diag later */
return rsp;
}
#endif /* IPQ50XX, IPQ95XX */
void *ftm_iot_dispatch(void *iot_ftm_pkt, int pkt_len, void *hdl)
{
void* retValue = NULL;
#ifdef IPQ_AP_HOST_IOT_QCA402X
retValue = ftm_iot_dispatch_qca402x(iot_ftm_pkt, pkt_len ,hdl);
#endif
#ifdef IPQ_AP_HOST_IOT_IPQ
retValue = ftm_iot_dispatch_ipq(iot_ftm_pkt, pkt_len ,(int *)hdl);
#endif /* IPQ50XX, IPQ95XX */
return retValue;
}
#endif /*ifdef IPQ_AP_HOST_IOT*/

View File

@@ -1,132 +0,0 @@
/*
*Copyright (c) 2018-2020, 2022 Qualcomm Technologies, Inc.
*
*All Rights Reserved.
*Confidential and Proprietary - Qualcomm Technologies, Inc.
*/
/* IPQ-QCA402X specific file */
#ifdef IPQ_AP_HOST_IOT
#include <semaphore.h>
#include <time.h>
#include "diagpkt.h"
#include "log.h"
#define MFG_CMD_ID_BLE_HCI 4
#define MFG_CMD_ID_I15P4_HMI 5
#define MFG_CMD_ID_OTP_INVALID 256
#define MFG_CMD_ID_OTP_SET_BITS 257
#define MFG_CMD_ID_OTP_WRITE_BYTE 258
#define MFG_CMD_ID_OTP_READ_BYTE 259
#define MFG_CMD_ID_OTP_TLV_INIT 260
#define MFG_CMD_ID_OTP_TLV_READ 261
#define MFG_CMD_ID_OTP_TLV_WRITE 262
#define MFG_CMD_ID_OTP_TLV_STATUS 263
#define MFG_CMD_ID_OTP_TLV_DELETE 264
#define MFG_CMD_ID_RAWFLASH_INVALID 288
#define MFG_CMD_ID_RAWFLASH_CLEAR_BITS 289
#define MFG_CMD_ID_RAWFLASH_WRITE 290
#define MFG_CMD_ID_RAWFLASH_READ 291
#define MFG_CMD_ID_RAWFLASH_ERASE 292
#define MFG_CMD_ID_RAWFLASH_DISABLE_MFG 293
#define MFG_CMD_ID_FS_INVALID 304
#define MFG_CMD_ID_FS_READ 305
#define MFG_CMD_ID_FS_WRITE 306
#define MFG_CMD_ID_FS_DELETE 307
#define MFG_CMD_ID_FS_LIST_SETUP 308
#define MFG_CMD_ID_FS_LIST_NEXT 309
#define MFG_CMD_ID_FS_MOUNT 310
#define MFG_CMD_ID_FS_UNMOUNT 311
/* Add more MFG tool commands for QCA402x. These
command are interpreted internally within QCA402x */
#define MFG_CMD_ID_MISC_REBOOT 352
#define MFG_CMD_ID_MISC_ADDR_READ 353
#define MFG_CMD_ID_MISC_ADDR_WRITE 354
#define MFG_CMD_ID_MISC_HWSS_DONE 355
#define MFG_CMD_ID_MISC_XTAL_CAP_SET 356
#define MFG_CMD_ID_MISC_PART_SZ_GET 357
/* Add MFG tool command to enable flashing of QCA402x
by putting QCA402x in EDL mode and selecting USB mux
select option to tie USB port 81 on IPQ402x to QCA402x */
#define MFG_CMD_ID_MISC_PROG_MODE 358
/*Command to invalidate specified QCA402x Imageset */
#define MFG_CMD_ID_MISC_FWUP 359
/* Add MFG tool PROG_MODE subcommands to enable flashing
of QCA402x on IPQ807x. Interpretation of sub-commands is as
follows:
MFG_FLASH_ON - Put QCA402x into reset state, Put QCA402x in
EDL mode and enable USB port to be tied to QCA402x
MFG_FLASH_OFF - Pull QCA402x out of EDL mode and Pull QCA402x
out of reset
MFG_EDL_ON - Put QCA402x in EDL mode
MFG_FLASH_OFF - Pull QCA402x out of EDL mode
MFG_USB_ON - Enable USB port to be tied to QCA402x
MFG_USB_OFF - Enable USB port to be tied to IPQ807x
MFG_PROG_RESP - Expected response field
*/
enum flash_state {
MFG_PROG_RESP,
MFG_FLASH_ON,
MFG_FLASH_OFF,
MFG_EDL_ON,
MFG_EDL_OFF,
MFG_USB_ON,
MFG_USB_OFF
};
typedef struct
{
uint8 start;
uint8 version;
uint16 length;
} PACKED_STRUCT diag_nonhdlc_hdr_t;
typedef struct
{
diag_nonhdlc_hdr_t hdr;
byte payload[0];
} PACKED_STRUCT ftm_iot_req_pkt_type;
typedef struct
{
log_hdr_type hdr;
byte buf[1];
} PACKED_STRUCT ftm_bt_rsp_pkt_type;
/* Two semaphores are used to handle sequencing of requests, ack responses
and multiple asynchronous data responses from QCA402x */
sem_t iot_sem;
sem_t iot_sem_async;
int ftm_iot_cmd_code;
int ftm_iot_dut_interface_code;
int ftm_iot_reserved_code;
int interface;
int thread_stop;
extern int user_sem_wait_timeout;
void *ftm_iot_dispatch(void *iot_ftm_pkt, int pkt_len, void *hdl);
#ifdef IPQ_AP_HOST_IOT_QCA402X
void *ftm_iot_dispatch_qca402x(void *iot_ftm_pkt, int pkt_len, void *hdl);
void *iot_thr_func_qca402x(void *hdl);
#endif
#ifdef IPQ_AP_HOST_IOT_IPQ
void *ftm_iot_dispatch_ipq(void *iot_ftm_pkt, int pkt_len, int *hdl);
void *iot_thr_func_ipq(void *hdl);
#endif /* IPQ50XX, IPQ95XX */
#endif /*ifdef IPQ_AP_HOST_IOT*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,108 +0,0 @@
/*=========================================================================
NFC FTM C File
Description
This file contains the definitions of the function used to check
which chip is present on the device.
Copyright (c) 2013-2015 Qualcomm Technologies, Inc.
All Rights Reserved.
Confidential and Proprietary - Qualcomm Technologies, Inc.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
===========================================================================*/
#include "ftm_nfc.h"
CHIP_TYPE chipType = UNDEFINED_CHIP_TYPE;
/*=========================================================================
FUNCTION checkChip
DESCRIPTION
Checks whether it can open the NQ Kernel, if not, it means
the device has a QTI chip.
PARAMETERS
None
RETURN VALUE
void
===========================================================================*/
void checkChip( void )
{
int ret = 0;
ret = ftm_nq_nfc_open( ); // can you open the NQ Kernel?
if( ret > 0 ) // yes
{
printf( "%s: NQ CHIP \n", __func__ );
chipType = NQ_CHIP; // so it's an NQ Chip
ret = ftm_nq_nfc_close( ); // close the handle
if( ret != 0 ) // not successful?
{
printf( "%s: Could not close the File Handle for NQ Chip \n", __func__ );
chipType = CHIP_ERROR; // something is wrong
}
}
else
{
printf( "%s: QTI CHIP \n", __func__ );
chipType = QTI_CHIP;
}
}
/*=========================================================================
FUNCTION ftm_nfc_dispatch
DESCRIPTION
Dispatches QRCT commands and Chip Replies/Notifications/Data
to the required FTM NFC Chip Handler
PARAMETERS
ftm_nfc_pkt_type *nfc_ftm_pkt - FTM Packet
uint16 pkt_len - FTM Packet Length
RETURN VALUE
void *
===========================================================================*/
void* ftm_nfc_dispatch( ftm_nfc_pkt_type *nfc_ftm_pkt, uint16 pkt_len )
{
ftm_nfc_pkt_type *reply = NULL;
if( UNDEFINED_CHIP_TYPE == chipType )
{
printf( "%s: Checking Chip Type \n", __func__ );
checkChip( );
}
switch( chipType )
{
case NQ_CHIP:
if( nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_REQ_CHIP_TYPE )
reply = PrepareRsp( nfc_ftm_pkt );
else
reply = ftm_nfc_dispatch_nq( nfc_ftm_pkt, pkt_len );
break;
case QTI_CHIP:
if( nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_REQ_CHIP_TYPE )
reply = PrepareRsp( nfc_ftm_pkt );
else
reply = ftm_nfc_dispatch_qti( nfc_ftm_pkt, pkt_len );
break;
default:
printf( "%s: ERROR - THIS SHOULD HAVE NEVER BEEN REACHED, CHIP TYPE %d", __func__, chipType );
break;
}
return reply;
}

View File

@@ -1,37 +0,0 @@
/*=========================================================================
NFC FTM HEADER File
Description
This file contains the definitions of the function used to check
which chip is present on the device.
Copyright (c) 2013-2016 Qualcomm Technologies, Inc.
All Rights Reserved.
Confidential and Proprietary - Qualcomm Technologies, Inc.
===========================================================================*/
#ifndef _FTM_NFC
#define _FTM_NFC
#include "ftm_nfcnq.h"
#define NFC_QCA1990 // Defnition to enable the NFC FTM inclusion
typedef enum _CHIP_TYPE{
UNDEFINED_CHIP_TYPE = 0,
QTI_CHIP = 1,
NQ_CHIP = 2,
CHIP_ERROR = 3,
MAXIMUM_CHIP_TYPE = 4,
} CHIP_TYPE;
extern CHIP_TYPE chipType;
void* ftm_nfc_dispatch(ftm_nfc_pkt_type *ftm_nfc_pkt, uint16 pkt_len);
void* ftm_nfc_dispatch_qti(ftm_nfc_pkt_type *ftm_nfc_pkt, uint16 pkt_len);
void ftm_nfc_dispatch_nq_fwdl();
void ftm_nfc_dispatch_nq_test(int argc, char **argv);
#endif // _FTM_NFC

View File

@@ -1,807 +0,0 @@
/*=========================================================================
NQ NFC FTM C File
Description
This file contains the definitions of the functions
used to communicate with the NQ Chip.
Copyright (c) 2015-2016 Qualcomm Technologies, Inc.
All Rights Reserved.
Confidential and Proprietary - Qualcomm Technologies, Inc.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
===========================================================================*/
#include "ftm_nfcnq.h"
#include "ftm_nfc.h"
#include "ftm_nfcnq_fwdl.h"
/* Global variables */
pthread_t clientThread;
PNCI_MESSAGE pNCIMessage;
sem_t sRspReady;
int fdNfc = 0;
uint8_t nciReplyMessage[ 255 ] = { 0 };
NQ_CHIP_TYPE whatNQChip = UNKNOWN_NQ_CHIP_TYPE;
uint8_t RFdeactivateCmd[ ] = { 0x21, 0x06, 0x01, 0x03};
uint8_t EseDataRsp[ ] = { 0x03, 0x00, 0x21, 0x99, 0x50, 0xFE};
/*=========================================================================
FUNCTION ftm_nq_nfc_close
DESCRIPTION
Close the kernel driver for the NQ Chip
PARAMETERS
None
RETURN VALUE
int
===========================================================================*/
int ftm_nq_nfc_close( void )
{
fdNfc = close( fdNfc ); // close the file descriptor
LOG_MESSAGE( "%s : Exit with fdNfc = %d \n", __func__, fdNfc );
return fdNfc; // return the result
}
/*=========================================================================
FUNCTION ftm_nq_nfc_open
DESCRIPTION
Open the kernel driver for the NQ Chip
PARAMETERS
None
RETURN VALUE
int
===========================================================================*/
int ftm_nq_nfc_open( void )
{
fdNfc = open( "/dev/nq-nci", // try to open /dev/nq-nci
O_RDWR );
LOG_MESSAGE( "%s : Exit with fdNfc = %d \n", __func__, fdNfc );
return fdNfc; // return the result
}
/*=========================================================================
FUNCTION ftm_nfc_hw_reset
DESCRIPTION
Resets the NQ Chip
PARAMETERS
None
RETURN VALUE
int
===========================================================================*/
int ftm_nfc_hw_reset( void )
{
int ret = -1; // return value
do
{
if( fdNfc < 0 ) // fdNfc valid?
break;
ret = ioctl( fdNfc, NFC_SET_PWR, POWER_ON ); // turn the chip on
if( ret != 0 ) // successful?
{
LOG_ERROR( "%s ioctl( fdNfc, NFC_SET_PWR, POWER_ON ) returned %d", __func__, ret );
ret = -2;
break;
}
usleep( 1000 ); // wait
ret = ioctl( fdNfc, NFC_SET_PWR, POWER_OFF ); // turn the chip off
if( ret != 0 ) // successful?
{
LOG_ERROR( "%s ioctl( fdNfc, NFC_SET_PWR, POWER_OFF ) returned %d", __func__, ret );
ret = -3;
break;
}
usleep( 1000 ); // wait
ret = ioctl( fdNfc, NFC_SET_PWR, POWER_ON ); // turn the chip back on
if( ret != 0 ) // successful?
{
LOG_ERROR( "%s ioctl( fdNfc, NFC_SET_PWR, POWER_ON ) returned %d", __func__, ret );
ret = -4;
break;
}
}while( 0 );
return ret;
}
/*=========================================================================
FUNCTION PrintBytes
DESCRIPTION
Print bytes from an array
PARAMETERS
uint8_t *buf - Byte array to print
uint8_t len - Length of the array
RETURN VALUE
void
===========================================================================*/
void PrintBytes( uint8_t *buf, uint8_t len)
{
#ifdef NFC_FTM_DEBUG
int idx;
LOG_INFORMATION( "%s: Length: %d bytes \n", __func__, len ); // print the number of bytes
for( idx = 0; idx < len; idx++ ) // print every byte
{
LOG_INFORMATION( "%02x ", buf[idx] );
}
LOG_INFORMATION( "\n" );
#else
UNUSED_PARAMETER( buf );
UNUSED_PARAMETER( len );
#endif
}
/*=========================================================================
FUNCTION ftm_nfc_send
DESCRIPTION
Sends a message to the chip
PARAMETERS
uint8_t *buf - buffer to be sent
int len - the length of the buffer
RETURN VALUE
int ret - Status
===========================================================================*/
int ftm_nfc_send( uint8_t* buf )
{
int ret = -1; // return value
int retries = 15; // number of retries
int i;
uint16_t nciSendMessageLength;
PNCI_MESSAGE pMessageToSend = ( PNCI_MESSAGE ) buf;
pfirmware_download_packet_t pFirmwarePacketsToSend =
( pfirmware_download_packet_t ) buf;
do
{
if( fdNfc < 0 ) // fdNfc valid?
break;
if( NULL == buf ) // is the buffer valid?
{
ret = -2;
LOG_ERROR( "%s: buf == NULL Invalid Buffer", __func__ );
break;
}
if( ( pFirmwarePacketsToSend->fFragmentedPacket == FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_NONE ) ||
( pFirmwarePacketsToSend->fFragmentedPacket == FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_SET ) )
nciSendMessageLength = pFirmwarePacketsToSend->payloadLen +
FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN +
FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN;
else
nciSendMessageLength = pMessageToSend->len + offsetof( NCI_MESSAGE, buf );
PrintBytes( buf, nciSendMessageLength );
do
{
retries--; // retries left
ret = write( fdNfc,
buf,
nciSendMessageLength ); // try to write
if( ret < nciSendMessageLength ) // did you write the length?
{
LOG_MESSAGE( "%s: %d = write( fdNfc, buf, nciSendMessageLength ), errno = %d, tries left = %d \n", __func__, ret, errno, retries );
continue; // try again
}
else
break; // done
} while( retries > 0 );
} while( 0 );
return ret;
}
/*=========================================================================
FUNCTION ProcessCommand
DESCRIPTION
Processes a Command for the NQ Chip
PARAMETERS
uint8_t *nci_data - NCI Data to send
RETURN VALUE
int ret - 0 if successfully received a reply
===========================================================================*/
int ProcessCommand( uint8_t *nci_data )
{
int ret = -1; // return value
struct timespec time_sec;
do
{
LOG_MESSAGE( "%s: FTM_NFC_SEND_DATA \n", __func__ );
ret = ftm_nfc_send( nci_data ); // send the message
LOG_MESSAGE( "%s: Wait for response \n", __func__ );
ret = clock_gettime( CLOCK_REALTIME, &time_sec );
if( ret == -1 )
{ // didn't get the time?
LOG_ERROR( "%s: clock_gettime for nci_data error \n", __func__ );
break;
}
time_sec.tv_sec += FTM_NFC_CMD_CMPL_TIMEOUT; // maximum wait
ret = sem_timedwait( &sRspReady, // start waiting
&time_sec );
if( ret == -1 ) // wait finished, not signalled?
{
if(!ese_dwp_test)
LOG_ERROR( "%s: nfc ftm command timed out \n", __func__ );
break;
}
} while( 0 );
return ret;
}
/*=========================================================================
FUNCTION ftm_nfc_read
DESCRIPTION
Reads a message from the chip
PARAMETERS
int len - the length of the buffer
RETURN VALUE
int ret - Number of bytes read
===========================================================================*/
int ftm_nfc_read( uint8_t* buf, int len )
{
int ret = -1;
do
{
if( fdNfc < 0 ) // fdNfc valid?
break;
ret = read( fdNfc, buf, len ); // try to read
} while( 0 );
return ret;
}
/*==========================================================================
FUNCTION
CommitLog
DESCRIPTION
This commits the log to Diag
PARAMETERS
NCI_MESSAGE pReadNCIMessage - Pointer to the read NCI Message
RETURN VALUE
void
==========================================================================*/
void CommitLog( PNCI_MESSAGE pReadNCIMessage )
{
pftm_nfc_log_pkt_type pLogBuff;
do
{
pLogBuff = ( ftm_nfc_log_pkt_type * ) log_alloc( LOG_NFC_FTM, // allocate a buffer for the log
pReadNCIMessage->len + offsetof( NCI_MESSAGE, buf ) + LOG_HEADER_LENGTH );
if( NULL == pLogBuff )
{
LOG_ERROR( "%s: log_alloc returned NULL \n", __func__ );
break;
}
memcpy( pLogBuff->data, // fill the buffer
pReadNCIMessage,
pReadNCIMessage->len + offsetof( NCI_MESSAGE, buf ) );
log_commit( pLogBuff ); // commit the log
} while ( 0 );
}
/*=============================================================================
FUNCTION
ProcessReturnedMessage
DESCRIPTION
Routine that processes an NCI Message that was returned and
will decide if the message is a notification or a response.
PARAMETERS
PNCI_MESSAGE pReadNCIMessage - Pointer to the read message
RETURN VALUE
void
==============================================================================*/
void ProcessReturnedMessage( PNCI_MESSAGE pReadNCIMessage )
{
switch( pReadNCIMessage->gid & NCIMT_NTF ) // check the first byte
{
case NCIMT_RSP: // reply?
sem_post( &sRspReady ); // notify the dispatch function
break;
case NCIMT_NTF: // notification?
if (pReadNCIMessage->oid == 0x05)
{
LOG_INFORMATION("\n << ...TAG DETECTED... >> \n");
printTecnologyDetails(pReadNCIMessage->buf[3],pReadNCIMessage->buf[2]);
sem_post( &sRfNtf );
ProcessCommand( RFdeactivateCmd );
}
case NCIMT_DATA: // data?
if (ese_dwp_test)
{
if( memcmp( EseDataRsp, nciReplyMessage, sizeof( EseDataRsp ) ) == 0 )
{
LOG_INFORMATION("\n << ESE detected over DWP >> \n\n");
}
}
if( log_status( LOG_NFC_FTM ) ) // logging enabled?
{
CommitLog( pReadNCIMessage );
}
break;
default:
LOG_ERROR( "%s: ERROR - SHOULD NOT HAVE REACHED THIS POINT", __func__ );
break;
}
}
/*=========================================================================
FUNCTION nfc_read_thread
DESCRIPTION
Thread that constantly looks for messages from the chip
PARAMETERS
void
RETURN VALUE
void
===========================================================================*/
void *nfc_read_thread( void *arg )
{
uint8_t readLength = 0;
int i;
uint8_t readNCIUpToLength = offsetof( NCI_MESSAGE, buf );
UNUSED_PARAMETER( arg );
for( ; ; ) // keep reading
{
readLength = ftm_nfc_read( nciReplyMessage, readNCIUpToLength ); // read the first 3 bytes
if( readLength == readNCIUpToLength ) // read the message up to NCI Len?
{
readLength = ftm_nfc_read( pNCIMessage->buf, // go and get the rest
pNCIMessage->len );
if( readLength == pNCIMessage->len ) // successful?
{
PrintBytes( nciReplyMessage, pNCIMessage->len + readNCIUpToLength );
ProcessReturnedMessage( pNCIMessage ); // Process the read message
}
}
}
}
/*==========================================================================
FUNCTION PrepareRsp
DESCRIPTION
Routine to prepare a response for diag.
PARAMETERS
ftm_nfc_pkt_type *nfc_ftm_pkt - FTM Packet
RETURN VALUE
void *
==========================================================================*/
void *PrepareRsp( ftm_nfc_pkt_type *nfc_ftm_pkt )
{
void *response = NULL;
switch( nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id )
{
case FTM_NFC_NFCC_COMMAND:
{
ftm_nfc_pkt_type *nfc_nci_rsp = ( ftm_nfc_pkt_type* ) diagpkt_subsys_alloc( DIAG_SUBSYS_FTM,
FTM_NFC_CMD_CODE,
sizeof( ftm_nfc_pkt_type ) ); // get a Response Buffer for NFCC Command
if( NULL == nfc_nci_rsp )
{
LOG_ERROR( "%s: diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, FTM_NFC_CMD_CODE, sizeof( ftm_nfc_pkt_type ) ) returned NULL \n", __func__ );
}
else
{
nfc_nci_rsp->ftm_nfc_hdr.nfc_cmd_id = FTM_NFC_NFCC_COMMAND;
nfc_nci_rsp->ftm_nfc_hdr.nfc_cmd_len = offsetof( ftm_nfc_cmd_header, nfc_cmd_len ) + offsetof( NCI_MESSAGE, buf ) + pNCIMessage->len ;
nfc_nci_rsp->nfc_nci_pkt_len = offsetof( NCI_MESSAGE, buf ) + pNCIMessage->len;
memcpy( nfc_nci_rsp->nci_data,
pNCIMessage,
nfc_nci_rsp->nfc_nci_pkt_len );
response = ( void* ) nfc_nci_rsp;
}
break;
}
case FTM_NFC_REQ_CHIP_TYPE:
{
// change from a NCI packet type to a request chip type packet type
ftm_nfc_chip_type_pkt_type *nfc_chip_type_rsp = ( ftm_nfc_chip_type_pkt_type* ) diagpkt_subsys_alloc( DIAG_SUBSYS_FTM,
FTM_NFC_CMD_CODE,
sizeof( ftm_nfc_chip_type_pkt_type ) ); // get a Response Buffer for Request Chip Type Command
if( NULL == nfc_chip_type_rsp )
{
LOG_ERROR( "%s: diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, FTM_NFC_CMD_CODE, sizeof( ftm_nfc_chip_type_pkt_type ) ) returned NULL \n", __func__ );
}
else
{
nfc_chip_type_rsp->nfc_chip_type_cmd_id = FTM_NFC_REQ_CHIP_TYPE;
nfc_chip_type_rsp->nfc_chip_type_pkt_len = 1; // only 1 byte for response packet data
if( chipType == 1 ) // 1 for QTI, 2 for NQ
nfc_chip_type_rsp->nfc_chip_type_pkt_data = FTM_NFC_QTI_CHIP;
else
nfc_chip_type_rsp->nfc_chip_type_pkt_data = FTM_NFC_NQ_CHIP;
response = ( void* ) nfc_chip_type_rsp;
}
break;
}
case FTM_NFC_FWPIN_CTRL:
{
// change from a NCI packet type to a firmware download packet type
ftm_nfc_fwdl_pkt_type *nfc_fwdl_rsp = ( ftm_nfc_fwdl_pkt_type* ) diagpkt_subsys_alloc( DIAG_SUBSYS_FTM,
FTM_NFC_CMD_CODE,
sizeof( ftm_nfc_fwdl_pkt_type ) ); // get a Response Buffer for Firmware Download Pin Command
if( NULL == nfc_fwdl_rsp )
{
LOG_ERROR( "%s: diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, FTM_NFC_CMD_CODE, sizeof( ftm_nfc_fwdl_pkt_type ) ) returned NULL \n", __func__ );
}
else
{
nfc_fwdl_rsp->nfc_fwdl_cmd_id = FTM_NFC_FWPIN_CTRL;
nfc_fwdl_rsp->nfc_fwdl_pkt_len = 1; // only 1 byte for response packet data
nfc_fwdl_rsp->nfc_fwdl_pkt_data = FTM_NFC_FWDL_SUCCESS; // 0 for fail, 1 for success
response = ( void* ) nfc_fwdl_rsp;
}
break;
}
default :
LOG_ERROR( "%s: ERROR - SHOULD NOT HAVE ENDED UP HERE: default case \n", __func__ );
break;
}
return response;
}
/*=========================================================================
FUNCTION ftm_nfc_nq_vs_nxp
DESCRIPTION
Check whether the chip is an NQ Chip
PARAMETERS
None
RETURN VALUE
int
===========================================================================*/
int ftm_nfc_nq_vs_nxp( void )
{
int ret = 0;
uint8_t coreResetCmd[ ] = { 0x20, 0x00, 0x01, 0x00 };
uint8_t coreResetRsp[ ] = { 0x40, 0x00, 0x03, 0x00, 0x11, 0x00 };
uint8_t coreInitCmd[ ] = { 0x20, 0x01, 0x00 };
do
{
ret = ProcessCommand( coreResetCmd ); // send a Core Reset CMD
if( ret == -1 ) // wait finished, not signalled?
{
LOG_ERROR( "%s: ProcessCommand( coreResetCmd ) error %d \n", __func__, ret );
break;
}
if( memcmp( coreResetRsp, nciReplyMessage, sizeof( coreResetRsp ) ) )
{ // not a good reply?
coreResetRsp[4] = 0x10;
if( memcmp( coreResetRsp, nciReplyMessage, sizeof( coreResetRsp ) ) )
{ // check if NCI version is 1.0
ret = -1;
LOG_ERROR( "%s: bad reply for coreResetRsp", __func__ );
break;
}
}
ret = ProcessCommand( coreInitCmd ); // send the message
if( ret == -1 ) // wait finished, not signalled?
{
LOG_ERROR( "%s: ProcessCommand( coreInitCmd ) error %d \n", __func__, ret );
break;
}
switch( nciReplyMessage[ CHIP_ID ] ) // what type of chip is it?
{
case 0x48:
whatNQChip = NQ_210;
LOG_INFORMATION( "Connected to NQ210 \n" );
break;
case 0x58:
whatNQChip = NQ_220;
LOG_INFORMATION( "Connected to NQ220 \n" );
break;
case 0x40:
case 0x41:
whatNQChip = NQ_310;
LOG_INFORMATION( "Connected to NQ310 \n" );
break;
case 0x50:
case 0x51:
whatNQChip = NQ_330;
LOG_INFORMATION( "Connected to NQ330 \n" );
break;
default:
whatNQChip = UNKNOWN_NQ_CHIP_TYPE;
ret = -1;
LOG_INFORMATION( "ERROR Connected to an unknown NQ Chip \n" );
break;
}
}while( 0 );
return ret;
}
/*=========================================================================
FUNCTION ftm_nfc_set_fwdl_pin
DESCRIPTION
Sets or resets the firmware download pin high or low
PARAMETERS
ftm_nfc_pkt_type *nfc_ftm_pkt - FTM Packet
RETURN VALUE
void
===========================================================================*/
void ftm_nfc_set_fwdl_pin( ftm_nfc_pkt_type *nfc_ftm_pkt )
{
int ret = 0;
// change from a NCI packet type to a firmware download packet type
pftm_nfc_fwdl_pkt_type pnfc_fwdl_pkt = ( pftm_nfc_fwdl_pkt_type ) nfc_ftm_pkt;
switch ( pnfc_fwdl_pkt->nfc_fwdl_pkt_data )
{
case 0:
ret = ftm_nfc_hw_reset( ); // Can you reset the hardware?
if( ret < 0 ) // successful?
{
LOG_ERROR( "%s: ftm_nfc_hw_reset() failed with ret = %d \n", __func__, ret );
break;
}
LOG_MESSAGE( "%s: Firmware download pin set LOW\n", __func__ );
break;
case 1:
ret = ioctl( fdNfc, NFC_SET_PWR, FIRMWARE_MODE );
if( ret != 0 ) // successful?
{
LOG_ERROR( "%s ioctl( fdNfc, NFC_SET_PWR, FIRMWARE_MODE ) returned %d", __func__, ret );
break;
}
LOG_MESSAGE( "%s: Firmware download pin set HIGH\n", __func__ );
break;
default :
LOG_ERROR( "%s: ERROR - SHOULD NOT HAVE ENDED UP HERE: default case \n", __func__ );
break;
}
ret = ftm_nq_nfc_close( ); // close the handle
if( ret != 0 ) // not successful?
{
LOG_ERROR( "\n\t %s: ftm_nq_nfc_close() failed with ret = %d \n", __func__, ret );
}
ret = ftm_nq_nfc_open( ); // open the kernel driver
if( ret < 0 ) // successful?
{
LOG_ERROR( "\n\t %s: ftm_nq_nfc_open() failed with ret = %d \n", __func__, ret );
}
}
/*=========================================================================
FUNCTION ftm_nfc_dispatch_nq
DESCRIPTION
Dispatches QRCT commands and Chip Replies/Notifications/Data
PARAMETERS
ftm_nfc_pkt_type *nfc_ftm_pkt - FTM Packet
uint16 pkt_len - FTM Packet Length
RETURN VALUE
void *
===========================================================================*/
void* ftm_nfc_dispatch_nq( ftm_nfc_pkt_type *nfc_ftm_pkt, uint16 pkt_len )
{
int ret = 0;
int len = 0;
struct timespec time_sec;
char *SkipNQHardwareCheck = NULL;
void *rsp = NULL;
UNUSED_PARAMETER( pkt_len );
do
{
if( !fdNfc ) // Already initialized?
{
ret = ftm_nq_nfc_open( ); // open the kernel driver
if( ret < 0 ) // successful?
{
LOG_ERROR( "\n\t %s: ftm_nq_nfc_open() failed with ret = %d \n", __func__, ret );
break;
}
ret = ftm_nfc_hw_reset( ); // Can you reset the hardware?
if( ret < 0 ) // successful?
{
LOG_ERROR( "%s: ftm_nfc_hw_reset() failed with ret = %d \n", __func__, ret );
break;
}
pNCIMessage = ( PNCI_MESSAGE ) nciReplyMessage;
ret = pthread_create( &clientThread, // Start the Read Thread
NULL,
&nfc_read_thread,
NULL );
if( ret != 0 ) // successful?
{
LOG_MESSAGE( "%s: pthread_create( nfc_read_thread ) failed with ret = %d \n", __func__, ret );
break;
}
SkipNQHardwareCheck = getenv( SKIP_NQ_HARDWARE_CHECK );
LOG_MESSAGE( "%s: SkipNQHardwareCheck = %s \n", __func__, SkipNQHardwareCheck );
if( NULL == SkipNQHardwareCheck ) // no value so check for NQ Chip?
{
ret = ftm_nfc_nq_vs_nxp( );
if( ret < 0 ) // Not an NQ Chip?
{
LOG_ERROR( "ERROR NOT A KNOWN NQ Chip \n" );
break;
}
}
else
{
LOG_INFORMATION( " Skipping NQ Chip Check \n" );
whatNQChip = SKIP_CHIP_CHECK;
}
LOG_INFORMATION( "FTM for NFC SUCCESSFULLY STARTED \n" );
}
if( UNKNOWN_NQ_CHIP_TYPE == whatNQChip )
{
LOG_ERROR( "ERROR This version of the chip is not accepted" );
break;
}
if( NULL == nfc_ftm_pkt ) // valid packet?
{
LOG_ERROR( "%s: Error : nfc_ftm_pkt is NULL \n", __func__ );
break;
}
if( offsetof( ftm_nfc_pkt_type, ftm_nfc_hdr ) < MIN_CMD_PKT_LEN )
{ // packet contains anything?
LOG_ERROR( "%s: Error : Invalid FTM Packet \n", __func__ );
break;
}
switch( nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id ) // what type of packet is it?
{
case FTM_NFC_NFCC_COMMAND: // NFC Command?
case FTM_NFC_SEND_DATA: // NFC Data?
ret = ProcessCommand( nfc_ftm_pkt->nci_data );
if( ret == -1 ) // wait finished, not signalled?
{
LOG_ERROR( "%s: ProcessCommand( nfc_ftm_pkt->nci_data ) error %d \n", __func__, ret );
break;
}
rsp = PrepareRsp( nfc_ftm_pkt ); // Prepare the response for Diag
break;
case FTM_NFC_REQ_CHIP_TYPE:
case FTM_NFC_FWPIN_CTRL:
ftm_nfc_set_fwdl_pin( nfc_ftm_pkt );
rsp = PrepareRsp( nfc_ftm_pkt ); // Prepare the response for Diag
break;
default :
LOG_ERROR( "%s: ERROR - SHOULD NOT HAVE ENDED UP HERE: default case \n", __func__ );
break;
}
} while( 0 );
return rsp;
}

View File

@@ -1,168 +0,0 @@
/*=========================================================================
NQ NFC FTM Header File
Description
This file contains the declarations of the functions
used to communicate with the NQ Chip and various definitions.
Copyright (c) 2015-2017 Qualcomm Technologies, Inc.
All Rights Reserved.
Confidential and Proprietary - Qualcomm Technologies, Inc.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
===========================================================================*/
#ifndef _FTM_NFCNQ
#define _FTM_NFCNQ
#include "msg.h"
#include "diagpkt.h"
#include "diagcmd.h"
#include "errno.h"
#include <linux/ioctl.h>
#include <pthread.h>
#include <semaphore.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "log.h"
#define LOG_ERROR( ... ) printf( __VA_ARGS__ )
#define LOG_INFORMATION( ... ) printf( __VA_ARGS__ )
#ifdef NFC_FTM_DEBUG
#define LOG_MESSAGE( ... ) printf( __VA_ARGS__ )
#else
#define LOG_MESSAGE( ... ) do{ } while ( FALSE )
#endif
typedef PACKED struct _ftm_nfc_cmd_header{
uint16 nfc_cmd_id;
uint16 nfc_cmd_len;
} ftm_nfc_cmd_header, *pftm_nfc_cmd_header;
typedef PACKED struct{
diagpkt_subsys_header_type diag_hdr;
ftm_nfc_cmd_header ftm_nfc_hdr;
uint16 nfc_nci_pkt_len;
byte nci_data[258];
}ftm_nfc_pkt_type, *pftm_nfc_pkt_type;
typedef PACKED struct{
diagpkt_subsys_header_type diag_hdr;
uint16 nfc_fwdl_cmd_id;
byte nfc_fwdl_pkt_len;
byte nfc_fwdl_pkt_data;
}ftm_nfc_fwdl_pkt_type, *pftm_nfc_fwdl_pkt_type;
typedef PACKED struct{
diagpkt_subsys_header_type diag_hdr;
uint16 nfc_chip_type_cmd_id;
byte nfc_chip_type_pkt_len;
byte nfc_chip_type_pkt_data;
}ftm_nfc_chip_type_pkt_type, *pftm_nfc_chip_type_pkt_type;
typedef PACKED struct{
log_hdr_type hdr;
byte data[1];
} ftm_nfc_log_pkt_type, *pftm_nfc_log_pkt_type;
typedef PACKED struct _NCI_MESSAGE
{
byte gid; // Group ID
byte oid; // Operation ID
byte len; // payload length in bytes
byte buf[ 252 ]; // Payload Buffer
} NCI_MESSAGE, *PNCI_MESSAGE;
typedef enum
{
NCIMT_DATA = 0x00, /**< DATA packet. */
NCIMT_CMD = 0x20, /**< Control packet - Command. */
NCIMT_RSP = 0x40, /**< Control packet - Response. */
NCIMT_NTF = 0x60, /**< Control packet - Notification. */
NCIMT_INVALID_VALUE = 0xFF, /**< Invalid packet type. */
NCIMT_BITMASK = 0xE0, /**< Most significant three bits. */
NCIMT_BITSHIFT = 5
} NCIMT;
typedef enum
{
UNKNOWN_NQ_CHIP_TYPE = 0,
SKIP_CHIP_CHECK = 1,
NQ_110 = 11,
NQ_120 = 12,
NQ_210 = 21,
NQ_220 = 22,
NQ_310 = 31,
NQ_330 = 33,
MAXIMUM_NQ_CHIP_TYPE
} NQ_CHIP_TYPE;
struct nqx_devinfo
{
unsigned char chip_type;
unsigned char rom_version;
unsigned char fw_major;
unsigned char fw_minor;
};
union nqx_uinfo
{
unsigned int i;
struct nqx_devinfo info;
};
int ftm_nq_nfc_open( void );
int ftm_nq_nfc_close( void );
int ftm_nfc_hw_reset( void );
int ProcessCommand( uint8_t *nci_data );
void *PrepareRsp( ftm_nfc_pkt_type *nfc_ftm_pkt );
void *ftm_nfc_dispatch_nq( ftm_nfc_pkt_type *nfc_ftm_pkt, uint16 pkt_len);
void *nfc_read_thread( void *arg );
extern sem_t sRfNtf;
extern int ese_dwp_test;
extern void printTecnologyDetails(char technology, char protocol);
#define FTM_NFC_CMD_CODE 55
#define FTM_NFC_NFCC_COMMAND 0x02
#define FTM_NFC_SEND_DATA 0x03
#define FTM_NFC_REQ_CHIP_TYPE 0x04
#define FTM_NFC_FWPIN_CTRL 0x05
#define FTM_NFC_CMD_CMPL_TIMEOUT 3
#define FTM_NFC_QTI_CHIP 0x00
#define FTM_NFC_NQ_CHIP 0x01
#define FTM_NFC_FWDL_SUCCESS 0x01
#define MIN_CMD_PKT_LEN 4 // Minimum length for a valid FTM packet, 2 bytes for Diag header, 2 bytes for command ID
#define LOG_NFC_FTM 0x1802
#define LOG_HEADER_LENGTH 12
#define NFC_SET_PWR _IOW(0xE9, 0x01, unsigned int)
#define NFCC_GET_INFO _IOW(0xE9, 0x09, unsigned int)
#define POWER_OFF 0
#define POWER_ON 1
#define FIRMWARE_MODE 2
#define EXPECTED_CORE_INIT_RSP_LEN 29
#define CHIP_ID 24
#define SKIP_NQ_HARDWARE_CHECK "SkipNQHardwareCheck"
#define HARDWARE_TYPE_TIMEOUT 2
#define UNUSED_PARAMETER( x ) ( void )( x )
#endif // _FTM_NFCNQ

View File

@@ -1,664 +0,0 @@
/*
* Copyright (c) 2016-2017 Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*
* Not a Contribution.
* Apache license notifications and license are retained
* for attribution purposes only.
*/
/*
* Copyright (C) 2015 NXP Semiconductors
* The original Work has been changed by NXP Semiconductors.
*
* Copyright (C) 2010 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.
*/
/*=========================================================================
FTM NFC NQ Firmware Download Source File
Description
This file contains the definitions of the functions
used to download firmware onto the NQ Chip.
===========================================================================*/
#include "ftm_nfcnq_fwdl.h"
#include "ftm_nfcnq.h"
unsigned int chip_version = 0x00;
/* lookup table for CRC-16-CCITT calculation */
static uint16_t const crcTable[ 256 ] =
{ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad,
0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b,
0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7,
0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5,
0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a,
0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e,
0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae,
0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32,
0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca,
0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235,
0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3,
0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d,
0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f,
0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d,
0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0,
0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64,
0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 };
/*==========================================================================================================
FUNCTION
load_firmware_from_library
DESCRIPTION
gets a pointer to the firmware image and the length of the image
PARAMETERS
const char *pathToLib - path to the firmware image library
uint8_t **ppFirmwareImage - pointer to the pointer to the firmware image
uint16_t *pFirmwareImageLen - pointer to the firmware image length
RETURN VALUE
void
==========================================================================================================*/
static void load_firmware_from_library( const char *pathToLib, uint8_t **ppFirmwareImage,
uint16_t *pFirmwareImageLen )
{
void *pFirmwareLibHandle = NULL;
void *pTempFirmwareImage = NULL;
void *pTempFirmwareImageLen = NULL;
int status = -1;
do
{
if( NULL == pathToLib )
{
if(chip_version == 0x51 || chip_version == 0x50 || chip_version == 0x41 || chip_version == 0x40 )
pathToLib = "/system/vendor/firmware/libpn553_fw.so"; // set the path to pn553 firmware library
else
pathToLib = "/system/vendor/firmware/libpn548ad_fw.so"; // set the default path to pn548ad firmware library
}
if( NULL != pFirmwareLibHandle )
{
status = dlclose( pFirmwareLibHandle ); // if the firmware library handle is not NULL, release the handle
pFirmwareLibHandle = NULL;
dlerror( ); // clear existing errors
if( 0 != status )
{
LOG_ERROR( "%s: dlclose() failed with status = %d \n", __FUNCTION__, status );
break;
}
}
pFirmwareLibHandle = dlopen( pathToLib, RTLD_LAZY ); // get a handle to firmware library
LOG_MESSAGE( "Opening library handle from %s\n", pathToLib );
if( NULL == pFirmwareLibHandle )
{
LOG_ERROR( "%s: dlopen() failed \n", __FUNCTION__ );
break;
}
dlerror( ); // clear existing errors
pTempFirmwareImage = ( void * )dlsym( pFirmwareLibHandle, "gphDnldNfc_DlSeq" ); // get a pointer to the firmware library
if( dlerror( ) || ( NULL == pTempFirmwareImage ) )
{
LOG_ERROR( "%s: dlsym() failed, failed to load gphDnldNfc_DlSeq symbol \n", __FUNCTION__ );
break;
}
*ppFirmwareImage = *( uint8_t ** )pTempFirmwareImage; // the returned pointer is a pointer to an uint8_t array
pTempFirmwareImageLen = ( void * ) dlsym( pFirmwareLibHandle, "gphDnldNfc_DlSeqSz" ); // get a pointer to the firmware library length
if( dlerror( ) || ( NULL == pTempFirmwareImageLen ) )
{
LOG_ERROR( "%s: dlsym() failed, failed to load gphDnldNfc_DlSeqSz symbol \n", __FUNCTION__ );
break;
}
*pFirmwareImageLen = ( uint16_t )( *( ( uint16_t * )pTempFirmwareImageLen ) ); // the returned pointer is a pointer to the length of the image
} while( FALSE );
}
/*==========================================================================================================
FUNCTION
send_packet_packet_to_chip
DESCRIPTION
sends the constructed packets to the NFC chip by calling ProcessCommand() from ftm_nfcnq.c
PARAMETERS
pfirmware_download_context_t pDownloadContext - pointer to structure containing all the
information required
RETURN VALUE
void
==========================================================================================================*/
static void send_packet_packet_to_chip( pfirmware_download_context_t pDownloadContext )
{
int status = -1;
status = ProcessCommand( &pDownloadContext->packetToSend ); // call ProcessCommand() from ftm_nfcnq.c
if( 0 != status )
{
LOG_ERROR( "%s: ProcessCommand() failed with status = %d \n", __FUNCTION__, status );
}
}
/*==========================================================================================================
FUNCTION
calculate_crc16
DESCRIPTION
calculates CRC-16-CCITT of a given buffer with a given length with seed value of 0xffff(Hex)
PARAMETERS
uint8_t *pBuff - buffer for CRC-16-CCITT calculation
uint16_t buffLen - length of buffer for CRC-16-CCITT calculation
RETURN VALUE
uint16_t - calculated CRC-16-CCITT value of buffer
==========================================================================================================*/
static uint16_t calculate_crc16( uint8_t *pBuff, uint16_t buffLen )
{
uint16_t temp = 0;
uint16_t value = 0;
uint16_t crc = 0xffff; // seed value
uint32_t i = 0;
if ( ( NULL == pBuff ) || ( 0 == buffLen ) )
{
LOG_ERROR( "%s: Invalid parameters \n", __FUNCTION__ );
}
else
{
for( i = 0; i < buffLen; i++ )
{
value = 0x00ffU & ( uint16_t )pBuff[ i ];
temp = ( crc >> 8U ) ^ value;
crc = ( crc << 8U ) ^ crcTable[ temp ];
}
}
return crc;
}
/*==========================================================================================================
FUNCTION
insert_crc16
DESCRIPTION
inserts the calculated CRC-16-CCITT value into the end of the buffer
PARAMETERS
pfirmware_download_context_t pDownloadContext - pointer to structure containing all the
information required
RETURN VALUE
void
==========================================================================================================*/
static void insert_crc16( pfirmware_download_context_t pDownloadContext )
{
uint16_t crcValueToWrite = 0;
uint8_t *crcValueInBytes = NULL;
/* get CRC-16-CCITT value of packet and convert it into 2 bytes */
crcValueToWrite = calculate_crc16( &pDownloadContext->packetToSend,
pDownloadContext->headerPlusPayloadLen );
crcValueInBytes = ( uint8_t * )&crcValueToWrite;
/* insert crc value into last 2 bytes of the packet */
if( pDownloadContext->packetToSend.payloadLen < ( FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN - 1 ))
{
pDownloadContext->packetToSend.payloadBuff[ pDownloadContext->packetToSend.payloadLen ] = crcValueInBytes[ 1 ];
pDownloadContext->packetToSend.payloadBuff[ pDownloadContext->packetToSend.payloadLen + 1 ] = crcValueInBytes[ 0 ];
}
else
{
LOG_ERROR( "%s: Packet to send payloadLen more than maximum payloadBuff size \n", __FUNCTION__ );
}
}
/*==========================================================================================================
FUNCTION
read_response_from_chip
DESCRIPTION
reader thread that constantly checks for responses from NFC chip, checks the integrity of the
response packets by matching the CRC-16-CCITT values and signals the semaphore held by
the call to ProcessCommand()
PARAMETERS
pfirmware_download_context_t pDownloadContext - pointer to structure containing all the
information required
RETURN VALUE
void
==========================================================================================================*/
static void read_response_from_chip( pfirmware_download_context_t pDownloadContext )
{
uint8_t lenRead = 0;
uint8_t *pPacketReceived = NULL;
uint16_t calculatedCrcValue = 0;
uint16_t crcValueFromResponse = 0;
do
{
if( fdNfc < 0 )
{
LOG_ERROR( "%s: Invalid handle \n", __FUNCTION__ );
break;
}
lenRead = read( fdNfc, &pDownloadContext->packetReceived, // get the response packet header
FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN );
if( 0 == lenRead )
{
LOG_ERROR( "%s: Error reading response packet header \n", __FUNCTION__ );
break;
}
else
{
pDownloadContext->totalPacketLen = lenRead;
}
lenRead = read( fdNfc, &pDownloadContext->packetReceived.payloadBuff, // get the rest fo the response packet
( pDownloadContext->packetReceived.payloadLen +
FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN ) );
if( 0 == lenRead )
{
LOG_ERROR( "%s: Error reading response packet payload \n", __FUNCTION__ );
break;
}
else
{
pDownloadContext->totalPacketLen += lenRead; // update the total length of the received packet
}
calculatedCrcValue = calculate_crc16( &pDownloadContext->packetReceived, // calculate the CRC-16-CCITT value of the received packet
( pDownloadContext->packetReceived.payloadLen +
FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN ) );
/* convert crc value from the response packet to an uint16_t */
if( pDownloadContext->packetReceived.payloadLen < ( FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN - 1 ))
{
crcValueFromResponse = pDownloadContext->packetReceived.payloadBuff[ pDownloadContext->packetReceived.payloadLen ];
crcValueFromResponse <<= 8;
crcValueFromResponse |= pDownloadContext->packetReceived.payloadBuff[ pDownloadContext->packetReceived.payloadLen + 1 ];
}
else
{
LOG_ERROR( "%s: Packet received payloadLen more than maximum payloadBuff size \n", __FUNCTION__ );
}
if( calculatedCrcValue != crcValueFromResponse ) // compare the CRC-16-CCITT values
{
LOG_ERROR( "%s: CRC-16-CCITT values do not match, discarding packet \n", __FUNCTION__ );
break;
}
else
{
sem_post( &sRspReady ); // signal the semaphore for subsequent packets to be sent
}
} while( FALSE == pDownloadContext->fExitReadThread ); // exit only when the flag is set
}
/*==========================================================================================================
FUNCTION
get_device_firmware_version
DESCRIPTION
sends the get-firmware-version command (0xF1) to the device and outputs the firmware version of
the device
PARAMETERS
pfirmware_download_context_t pDownloadContext - pointer to structure containing all the
information required
RETURN VALUE
void
==========================================================================================================*/
static void get_device_firmware_version( pfirmware_download_context_t pDownloadContext )
{
uint8_t getFirmwareVersionCommand[ ] = { 0x00, 0x04, 0xF1, 0x00, 0x00, 0x00 }; // command to get firmware version on device
uint8_t firmwareMajorVersion = 0;
uint8_t firmwareMinorVersion = 0;
pDownloadContext->headerPlusPayloadLen =
sizeof( getFirmwareVersionCommand ) / sizeof( getFirmwareVersionCommand[ 0 ] );
memcpy( &pDownloadContext->packetToSend, &getFirmwareVersionCommand, // construct the command packet
( pDownloadContext->headerPlusPayloadLen ) );
insert_crc16( pDownloadContext ); // insert the CRC-16-CCITT value
send_packet_packet_to_chip( pDownloadContext ); // send the command packet to NFC chip
/* continues from here once the reader thread reads the response and flags the semaphore,
the last 2 bytes of the get version response payload contains the firmware version currently on the device */
firmwareMajorVersion = pDownloadContext->packetReceived.payloadBuff[ pDownloadContext->packetReceived.payloadLen - 1 ];
firmwareMinorVersion = pDownloadContext->packetReceived.payloadBuff[ pDownloadContext->packetReceived.payloadLen - 2 ];
if(chip_version == 0x51 || chip_version == 0x50 || chip_version == 0x41 || chip_version == 0x40 )
LOG_INFORMATION( "Firmware version: 11.%02X.%02X\n", firmwareMajorVersion, firmwareMinorVersion );
else
LOG_INFORMATION( "Firmware version: 10.%02X.%02X\n", firmwareMajorVersion, firmwareMinorVersion );
}
/*==========================================================================================================
FUNCTION
build_first_packet
DESCRIPTION
constructs the first packet to be sent to the NFC chip
PARAMETERS
pfirmware_download_context_t pDownloadContext - pointer to structure containing all the
information required
RETURN VALUE
void
==========================================================================================================*/
static void build_first_packet( pfirmware_download_context_t pDownloadContext )
{
memset( pDownloadContext->packetToSend.payloadBuff, 0, // initialise the payload buffer to zero
FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN );
memcpy( &pDownloadContext->packetToSend, // copy the first chunk from the firmware library to the packet
pDownloadContext->pFirmwareImage,
pDownloadContext->headerPlusPayloadLen );
insert_crc16( pDownloadContext ); // insert the CRC-16-CCITT value
}
/*==========================================================================================================
FUNCTION
build_next_packet
DESCRIPTION
constructs subsequent packets required to be sent to the NFC chip
PARAMETERS
pfirmware_download_context_t pDownloadContext - pointer to structure containing all the
information required
RETURN VALUE
void
==========================================================================================================*/
static void build_next_packet( pfirmware_download_context_t pDownloadContext )
{
/* for chunks from library that are larger than 256 bytes, the packets have to be fragmented */
if( pDownloadContext->bytesLeftToSend > FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN )
{
pDownloadContext->headerPlusPayloadLen = FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN + // length of header plus the payload for CRC-16-CCITT calculation
FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN;
pDownloadContext->totalPacketLen = FIRMWARE_DOWNLOAD_MAX_PACKET_LEN; // length of the entire packet to be sent
pDownloadContext->packetToSend.fFragmentedPacket = FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_SET; // set the fragment flag as the first byte
pDownloadContext->packetToSend.payloadLen = FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN; // insert the payload length in the second byte
memcpy( ( &pDownloadContext->packetToSend.payloadBuff ), // copy payload from firmware library
&pDownloadContext->pFirmwareImage[ pDownloadContext->readIndexFromLib ],
FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN );
pDownloadContext->readIndexFromLib += FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN; // update the buffer index used to read from firmware library
pDownloadContext->bytesLeftToSend -= FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN; // update the number of bytes left to send from the chunk
}
/* for chunks from library that are smaller than 256 bytes, no fragmentation needed */
else
{
pDownloadContext->headerPlusPayloadLen = pDownloadContext->bytesLeftToSend + // length of header plus the payload for CRC-16-CCITT calculation
FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN;
pDownloadContext->totalPacketLen = pDownloadContext->bytesLeftToSend + // length of the entire packet to be sent
FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN +
FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN;
pDownloadContext->packetToSend.fFragmentedPacket = FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_NONE; // set the fragment flag to none as the first byte
pDownloadContext->packetToSend.payloadLen = pDownloadContext->bytesLeftToSend; // insert the payload length in the second byte
memcpy( ( &pDownloadContext->packetToSend.payloadBuff ), // copy payload from firmware library
&pDownloadContext->pFirmwareImage[ pDownloadContext->readIndexFromLib ],
pDownloadContext->bytesLeftToSend );
pDownloadContext->readIndexFromLib += pDownloadContext->bytesLeftToSend; // update the buffer index used to read from firmware library
pDownloadContext->bytesLeftToSend = 0; // most likely the last fragment from the chunk
}
insert_crc16( pDownloadContext );
}
/*==========================================================================================================
FUNCTION
process_packets_to_send
DESCRIPTION
determines if the incoming packet is the first one or any subsequent ones and process them
accordingly
PARAMETERS
pfirmware_download_context_t pDownloadContext - pointer to structure containing all the
information required
RETURN VALUE
void
==========================================================================================================*/
static void process_packets_to_send( pfirmware_download_context_t pDownloadContext )
{
uint8_t firstChunkLenFromLib = 0;
uint16_t nextChunkLenFromLib = 0;
uint16_t buffIndex = pDownloadContext->readIndexFromLib;
if( TRUE == pDownloadContext->fFirstPacket )
{
pDownloadContext->fFirstPacket = FALSE; // indicates that the first packet has been processed
firstChunkLenFromLib = pDownloadContext->pFirmwareImage[ 1 ] + // length of the first chunk read from firmware library
FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN;
pDownloadContext->totalPacketLen = firstChunkLenFromLib + // length of the entire packet to send
FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN;
pDownloadContext->readIndexFromLib += firstChunkLenFromLib; // update the buffer index used to read from firmware library
pDownloadContext->headerPlusPayloadLen = firstChunkLenFromLib; // length of header plus the payload for CRC-16-CCITT calculation
build_first_packet( pDownloadContext ); // build the first packet
send_packet_packet_to_chip( pDownloadContext ); // send the packet to the NFC chip
}
else if( FALSE == pDownloadContext->fFirstPacket )
{
nextChunkLenFromLib = pDownloadContext->pFirmwareImage[ buffIndex ]; // length of next chunk read from the firmware library
/* length of next chunk is stored in 2 bytes in the firmware library */
nextChunkLenFromLib <<= 8;
nextChunkLenFromLib |= pDownloadContext->pFirmwareImage[ buffIndex + 1 ];
buffIndex += 2; // add 2 bytes to the buffer index after length of next chunk is read
pDownloadContext->readIndexFromLib = buffIndex; // update the buffer index used to read from firmware library
pDownloadContext->bytesLeftToSend = nextChunkLenFromLib; // number of bytes left on the chunk to be sent to the chip
while( pDownloadContext->bytesLeftToSend > 0 ) // constructs and sends packets as long as there are bytes left in the chunk
{
build_next_packet( pDownloadContext );
send_packet_packet_to_chip( pDownloadContext );
}
}
else
{
LOG_ERROR( "%s: Should not reach this point \n", __FUNCTION__ );
}
}
/*==========================================================================================================
FUNCTION
ftm_nfc_dispatch_nq_fwdl
DESCRIPTION
called by main() in ftm_main.c to start the firmware download routine
PARAMETERS
none
RETURN VALUE
void
==========================================================================================================*/
void ftm_nfc_dispatch_nq_fwdl( void )
{
int status = 0;
char *pathToLib = NULL;
uint8_t *pFirmwareImage = NULL;
uint16_t firmwareImageLen = 0;
uint8_t *pNextChunkFromLib = NULL;
uint16_t nextChunkLenFromLib = 0;
uint16_t totalBytesReadFromLib = 0;
uint16_t readIndexFromLib = 0;
union nqx_uinfo nqx_info;
pthread_t readerThread;
firmware_download_context_t downloadContext = { 0 };
pfirmware_download_context_t pDownloadContext = &downloadContext;
pDownloadContext->fFirstPacket = TRUE;
do
{
if( !fdNfc )
{
status = ftm_nq_nfc_open( ); // get a handle to the kernel driver
if( status < 0 )
{
LOG_ERROR( "\n%s: ftm_nq_nfc_open() failed with status = %d \n", __FUNCTION__, status );
break;
}
status = ftm_nfc_hw_reset( ); // reset NFC hardware
if( status < 0 )
{
LOG_ERROR( "%s: ftm_nq_nfc_reset() failed with status = %d \n", __FUNCTION__, status );
break;
}
nqx_info.i = ioctl( fdNfc, NFCC_GET_INFO, 0 );
if( nqx_info.i < 0 )
{
LOG_ERROR( "%s: nqnfcinfo not enabled, info = %d \n", __FUNCTION__, nqx_info.i );
}
chip_version = nqx_info.info.chip_type;
LOG_INFORMATION( "\n NQ Chip ID : %x\n", chip_version);
}
status = pthread_create( &readerThread, NULL, // create a reader thread
&read_response_from_chip, pDownloadContext );
if( 0 != status )
{
LOG_ERROR( "%s: pthread_create() failed with status = %d \n", __FUNCTION__, status );
break;
}
load_firmware_from_library( pathToLib, &pFirmwareImage, &firmwareImageLen ); // get a pointer to firmware library image and get its length
if( ( NULL == pFirmwareImage ) || ( 0 == firmwareImageLen ) )
{
LOG_ERROR( "%s: Firmware library image extraction failed\n", __FUNCTION__ );
break;
}
LOG_MESSAGE( "Firmware major version number: %02X\n", pFirmwareImage[ 5 ] );
LOG_MESSAGE( "Firmware minor version number: %02X\n", pFirmwareImage[ 4 ] );
LOG_MESSAGE( "Firmware library image length: %d\n", firmwareImageLen );
LOG_MESSAGE( "Firmware library image pointer: %X\n", ( uintptr_t )pFirmwareImage );
pDownloadContext->pFirmwareImage = pFirmwareImage;
pDownloadContext->firmwareImageLen = firmwareImageLen;
status = ioctl( fdNfc, NFC_SET_PWR, FIRMWARE_MODE ); // set NFCC to firmware download mode
if( 0 != status )
{
LOG_ERROR( "%s: Failed to set firmware pin high.\n", __FUNCTION__ );
break;
}
LOG_INFORMATION( "\nBefore firmware update...\n" );
get_device_firmware_version( pDownloadContext ); // get device version before loading firmware
LOG_INFORMATION( "\nSending firmware packets... Please wait\n" );
while( pDownloadContext->readIndexFromLib < pDownloadContext->firmwareImageLen )
{
process_packets_to_send( pDownloadContext ); // build and send download packets with payload from the firmware library image
}
LOG_INFORMATION( "All packets sent!\n\n" );
pDownloadContext->fExitReadThread = TRUE; // set flag to indicate that reader thread is safe to exit
LOG_INFORMATION( "After firmware update...\n" );
get_device_firmware_version( pDownloadContext ); // get device version number after loading firmware
LOG_MESSAGE( "Waiting for reader thread to terminate...\n" );
pthread_join( readerThread, NULL ); // wait for reader thread to terminate
LOG_MESSAGE( "Reader thread terminated!\n" );
LOG_MESSAGE( "Resetting NFCC...\n" );
status = ftm_nfc_hw_reset( ); // reset the NFC hardware which resets the firmware pin as well
if( status < 0 )
{
LOG_ERROR( "%s: ftm_nfc_hw_reset() failed with status = %d \n", __FUNCTION__, status );
break;
}
status = ftm_nq_nfc_close( ); // release the handle to the kernel driver
if( 0 != status )
{
LOG_ERROR( "%s: ftm_nq_nfc_close() failed with status = %d \n", __FUNCTION__, status );
}
LOG_INFORMATION( "All done!\n\n" );
} while( FALSE );
}

View File

@@ -1,111 +0,0 @@
/*
* Copyright (c) 2016 Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*
* Not a Contribution.
* Apache license notifications and license are retained
* for attribution purposes only.
*/
/*
* Copyright (C) 2015 NXP Semiconductors
* The original Work has been changed by NXP Semiconductors.
*
* Copyright (C) 2010 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.
*/
/*=========================================================================
FTM NFC NQ Firmware Download Header File
Description
This file contains the declarations of the functions and various
definitions used to download firmware onto the NQ Chip.
===========================================================================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <semaphore.h>
#include <pthread.h>
#define FALSE ( 0 )
#define TRUE ( !FALSE )
#define FIRMWARE_DOWNLOAD_MAX_PACKET_LEN ( 0x100U ) // maximum length for a download packet
#define FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN ( 0x02U ) // length of the header
#define FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN ( 0x02U ) // length of CRC-16-CCITT value
#define FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN FIRMWARE_DOWNLOAD_MAX_PACKET_LEN - \
FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN - \
FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN
/* Values for the first byte of each packet, indicates if the packet is fragmented */
#define FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_NONE ( 0x00U ) // not fragmented
#define FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_SET ( 0x04U ) // fragmented packet, next packet is a part of this one
extern sem_t sRspReady; // semaphore used by reader thread
extern int fdNfc; // a handle to the kernel driver
typedef uint8_t bool_t;
/* structure of the packet to be sent or received */
typedef struct firmware_download_packet
{
uint8_t fFragmentedPacket; // flag to indicate if the packet is fragmented
uint8_t payloadLen; // length of payload
uint8_t payloadBuff[ FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN +
FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN ]; // buffer containing the payload and CRC-16-CCITT value
} firmware_download_packet_t, *pfirmware_download_packet_t;
/* structure that contains all the other information about the packets */
typedef struct firmware_download_context
{
const uint8_t *pFirmwareImage; // pointer to the firmware image library
uint16_t firmwareImageLen; // length of the firmware image
uint8_t headerPlusPayloadLen; // header and payload length of a packet for CRC calculation
uint16_t readIndexFromLib; // index used to read from the firmware library
uint16_t bytesLeftToSend; // number of bytes left to send when the chunk read is fragmented
uint16_t totalPacketLen; // total length of packet to be sent or received
bool_t fFirstPacket; // flag to indicate if it is the first packet
bool_t fExitReadThread; // flag to indicate if reader thread is safe to exit
firmware_download_packet_t packetToSend; // contains information about packet to be sent
firmware_download_packet_t packetReceived; // contains information about packet from response received
} firmware_download_context_t, *pfirmware_download_context_t;
/**
Firmware download packet format
-----------------------------------------------------------------------------------------------------
| Header | Payload | CRC-16-CCITT value |
-----------------------------------------------------------------------------------------------------
| Fragment flag | Payload length | Command/Response | Data | CRC-16-CCITT value |
-----------------------------------------------------------------------------------------------------
| 1 byte | 1 byte | 1 byte | n bytes | 2 bytes |
-----------------------------------------------------------------------------------------------------
Firmware library image format
--------------------------------------------------------------------------------- ----------------------------------
| 0x00 | First chunk length | First chunk | Next chunk length | Next chunk | ... | Last chunk length | Last chunk |
--------------------------------------------------------------------------------- ----------------------------------
| 1 byte | 1 byte | n bytes | 2 bytes | n bytes | ... | 2 bytes | n bytes |
--------------------------------------------------------------------------------- ----------------------------------
*/

View File

@@ -1,461 +0,0 @@
/*
* Copyright (c) 2017 Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*/
#include <libgen.h>
#include "ftm_nfcnq.h"
#include "ftm_nfcnq_test.h"
/* Global variables */
pthread_t clientThread;
PNCI_MESSAGE pNCIMessage;
char *progname;
/*==============================================================================
FUNCTION
eseSpiTest
DESCRIPTION
Send APDU for eSE SPI HLOS test
PARAMETERS
int argc - argument count
char **argv - argument vector
RETURN VALUE
void
=============================================================================*/
void eseSpiTest(int argc, char **argv )
{
int ret = 0;
int test_mode = 0;
unsigned char i = 0;
int fp = 0;
int choice = 0;
unsigned char send_APDU[] = {0x5A,0x00,0x05,0x00,0xA4,0x04,0x00,0x00,0xA5};
int size_APDU = 0;
unsigned char recv_response[259] = {0};
progname = basename(argv[2]);
test_mode = getopt(argc, argv, "01");
size_APDU = sizeof(send_APDU);
LOG_INFORMATION("\n### eSE SPI test ###\n");
if(test_mode == '0')
{
choice = 0;
LOG_INFORMATION("\nInterrupt Mode test\n");
}
else
{
choice = 1;
LOG_INFORMATION("\nPoll Mode test(default)\n");
}
do
{
//open module
if ((ret = (fp = open("/dev/ese", O_RDWR))) < 0)
{
LOG_INFORMATION("eSE open error retcode = %d, errno = %d\n", ret, errno);
LOG_INFORMATION("\n... eSE SPI Test requires modified boot and TZ image ...");
break;
}
LOG_INFORMATION("eSE open : Ret = %2d\n", ret);
//enable the logs
ioctl(fp, ESE_SET_DBG, 1);
//hardware reset
ioctl(fp, ESE_SET_PWR, 1);
ioctl(fp, ESE_SET_MODE, choice);
//write one APDU
ret = write(fp, send_APDU, sizeof(send_APDU));
if (ret < 0)
{
LOG_INFORMATION("ese write error retcode = %d, errno = %d\n", ret, errno);
break;
}
LOG_INFORMATION("ese Write : Ret = %.2X \n", ret);
LOG_INFORMATION("APDU sent to eSE: ");
for (i=0; i<size_APDU; i++)
{
LOG_INFORMATION("%.2X ", send_APDU[i]);
}
sleep(1);
if ((ret = (read(fp, &recv_response[0], READ_SAMPLE_SIZE)), 0) < 0)
{
LOG_INFORMATION("\neSE read error retcode = %d, errno = %d", ret, errno);
}
else
{
LOG_INFORMATION("\nResponse from eSE: ");
for (i=0;i<(recv_response[2]+1);i++)
{
LOG_INFORMATION("%.2X ", recv_response[i]);
}
LOG_INFORMATION("\n");
}
} while(0);
close(fp);
}
/*==============================================================================
FUNCTION
eseDwpTest
DESCRIPTION
Send NCI commands to NFCC for eSE DWP detection
PARAMETERS
RETURN VALUE
void
=============================================================================*/
void eseDwpTest()
{
int cmds;
cmds = sizeof(NQ330_ESE_DWP) / sizeof(NQ330_ESE_DWP[0]);
LOG_INFORMATION( "\n### ese DWP Test ###\n" );
if(whatNQChip == NQ_220 || whatNQChip == NQ_330)
sendcmds(NQ330_ESE_DWP, cmds);
else
LOG_INFORMATION( "\nNQ Chipset in use doesn't support eSE\n" );
}
/*==============================================================================
FUNCTION
printTecnologyDetails
DESCRIPTION
Print the technology supported and protocols details
PARAMETERS
char technology - technology supported identifier
char protocol - protocol identifier
RETURN VALUE
void
=============================================================================*/
void printTecnologyDetails(char technology, char protocol)
{
switch (protocol)
{
case NFC_PROTOCOL_ISO_DEP:
LOG_INFORMATION( "ISO-DEP Protocol");
break;
case NFC_PROTOCOL_NFC_DEP:
LOG_INFORMATION( "NFC-DEP Protocol");
break;
case NFC_PROTOCOL_T1T:
LOG_INFORMATION( "T1T Protocol");
break;
case NFC_PROTOCOL_T2T:
LOG_INFORMATION( "T2T Protocol");
break;
case NFC_PROTOCOL_T3T:
LOG_INFORMATION( "T3T Protocol");
break;
case NFC_PROTOCOL_UNKNOWN:
LOG_INFORMATION( "unknown Protocol");
break;
default:
break;
}
switch (technology)
{
case NFC_NFCA_Poll:
LOG_INFORMATION("\nNFC A POLL MODE TECHNOLOGY\n");
break;
case NFC_NFCB_Poll:
LOG_INFORMATION("\nNFC B POLL MODE TECHNOLOGY\n");
break;
case NFC_NFCF_Poll:
LOG_INFORMATION("\nNFC F POLL MODE TECHNOLOGY\n");
break;
case NFC_NFCA_Listen:
LOG_INFORMATION("\nNFC A LISTEN MODE TECHNOLOGY\n");
break;
case NFC_NFCB_Listen:
LOG_INFORMATION("\nNFC B LISTEN MODE TECHNOLOGY\n");
break;
case NFC_NFCF_Listen:
LOG_INFORMATION("\nNFC F LISTEN MODE TECHNOLOGY\n");
break;
case NFC_NFCISO15693_Poll:
LOG_INFORMATION("\nNFC ISO15693 POLL MODE TECHNOLOGY\n");
break;
default:
LOG_INFORMATION("\nother TECHNOLOGY\n");
break;
}
}
/*==============================================================================
FUNCTION
sendcmds
DESCRIPTION
Send sequence of commands to NFCC
PARAMETERS
uint8_t buffer[] - Command buffer array
int no_of_cmds - Number of commands to be sent
RETURN VALUE
void
=============================================================================*/
void sendcmds(uint8_t buffer[][MAX_CMD_LEN], int no_of_cmds)
{
int rows=0,payloadlen=0;
int ret = 0;
ftm_nfc_pkt_type *nfc_pkt = (ftm_nfc_pkt_type *)malloc(no_of_cmds*255);
LOG_INFORMATION("\nTotal cmds to be sent = %d\n",no_of_cmds);
LOG_INFORMATION("Wait for Commands to be sent... \n\n");
for(rows = 0; rows < no_of_cmds; rows++)
{
#ifdef NFC_FTM_DEBUG
LOG_INFORMATION ("Number of cmds sent = %d \n",rows+1);
#endif
payloadlen = 0;
payloadlen = 3 + buffer[rows][2];
memset(nfc_pkt->nci_data, -1, MAX_CMD_LEN);
memcpy(nfc_pkt->nci_data, &buffer[rows], payloadlen);
ret = ProcessCommand( nfc_pkt->nci_data );
if( ret == -1 ) // wait finished, not signalled?
{
LOG_ERROR( "Waited for NCI NTF/DATA timeout\n" );
}
}
}
/*==============================================================================
FUNCTION
usage
DESCRIPTION
Print usage information for test
PARAMETERS
RETURN VALUE
void
=============================================================================*/
void usage()
{
LOG_INFORMATION("\nUsage:");
LOG_INFORMATION(" %s [-n] [-e] [-d] [h] \n", progname);
LOG_INFORMATION(" %s -n ..for NFC test only\n", progname);
LOG_INFORMATION(" %s -e ..for eSE SPI test only\n \t-0 ..Interrupt Mode\n \t-1 ..Poll Mode\n", progname);
LOG_INFORMATION(" %s -d ..for eSE DWP test only\n", progname);
LOG_INFORMATION(" %s -h HELP\n", progname);
LOG_INFORMATION(" %s default NFC test only\n", progname);
}
/*==============================================================================
FUNCTION
nfc_ese_pwr
DESCRIPTION
Set ESE power using NFC driver
PARAMETERS
RETURN VALUE
void
=============================================================================*/
void nfc_ese_pwr()
{
int ret;
ret = ioctl( fdNfc, NFC_ESE_SET_PWR, POWER_ON ); // turn the chip on
if( ret != 0 )
{
LOG_INFORMATION("Can't find ESE GPIO in NFC driver: ");
LOG_INFORMATION("ret=%d\n",ret);
}
}
/*==============================================================================
FUNCTION
ftm_nfc_dispatch_nq_test
DESCRIPTION
called by main() in ftm_main.c to start the nfc test routine
PARAMETERS
int argc - argument count
char **argv - argument vector
RETURN VALUE
void
=============================================================================*/
void ftm_nfc_dispatch_nq_test( int argc, char **argv )
{
int cmds = 0;
unsigned int chip_version = 0x00;
unsigned int major_version = 0x00;
unsigned int minor_version = 0x00;
unsigned int rom_version = 0x00;
char firmware_version[10];
struct timespec time_sec;
int type_of_test = 0;
int default_test = 0;
int status = 0;
union nqx_uinfo nqx_info;
pthread_t readerThread;
do
{
if( !fdNfc )
{
status = ftm_nq_nfc_open( ); // get a handle to the kernel driver
if( status < 0 )
{
LOG_ERROR( "\n%s: ftm_nq_nfc_open() failed with status = %d \n", __FUNCTION__, status );
break;
}
status = ftm_nfc_hw_reset( ); // reset NFC hardware
if( status < 0 )
{
LOG_ERROR( "%s: ftm_nq_nfc_reset() failed with status = %d \n", __FUNCTION__, status );
break;
}
nqx_info.i = ioctl( fdNfc, NFCC_GET_INFO, 0 );
if( nqx_info.i < 0 )
{
LOG_ERROR( "%s: nqnfcinfo not enabled, info = %d \n", __FUNCTION__, nqx_info.i );
}
chip_version = nqx_info.info.chip_type;
rom_version = nqx_info.info.rom_version;
major_version = nqx_info.info.fw_major;
minor_version = nqx_info.info.fw_minor;
LOG_INFORMATION( "\n NQ Chip ID : %x\n", chip_version);
snprintf(firmware_version, 10, "%02x.%02x.%02x", rom_version, major_version, minor_version);
LOG_INFORMATION(" Firmware version : %s\n\n", firmware_version);
if(sem_init(&sRspReady, 0, 0) != 0)
{
LOG_ERROR("NFC FTM :semaphore_halcmd_complete creation failed \n");
break;
}
if(sem_init(&sRfNtf, 0, 0) != 0)
{
LOG_ERROR("NFC FTM :semaphore_halcmd_complete creation failed \n");
break;
}
pNCIMessage = ( PNCI_MESSAGE ) nciReplyMessage;
status = pthread_create( &clientThread, NULL, &nfc_read_thread, NULL ); // Start the Read Thread
if( status != 0 ) // successful?
{
LOG_ERROR("nqnfc %s: pthread_create( nfc_read_thread ) failed with ret = %d \n", __func__, status );
break;
}
status = ftm_nfc_nq_vs_nxp( );
if( status < 0 ) // Not an NQ Chip?
{
LOG_ERROR("ERROR NOT A KNOWN NQ Chip \n" );
}
}
progname = basename(argv[1]);
type_of_test = getopt(argc, argv, "nedhf");
switch (type_of_test) {
case 'n':
LOG_INFORMATION("NFC test only\n");
break;
case 'e':
LOG_INFORMATION("eSE SPI test only\n");
nfc_ese_pwr();
ese_spi_test = 1;
eseSpiTest(argc, argv);
break;
case 'd':
LOG_INFORMATION("eSE DWP test only\n");
ese_dwp_test = 1;
eseDwpTest();
break;
case 'h':
usage();
break;
default:
usage();
default_test = 1;
LOG_INFORMATION("\nDefault NFC test only\n");
}
if(ese_dwp_test || ese_spi_test)
break;
if(type_of_test == 'n' || default_test)
{
switch(whatNQChip)
{
case NQ_210:
case NQ_220:
cmds = sizeof(NQ220_cmds) / sizeof(NQ220_cmds[0]);
sendcmds(NQ220_cmds, cmds);
break;
case NQ_310:
case NQ_330:
cmds = sizeof(NQ330_cmds) / sizeof(NQ330_cmds[0]);
sendcmds(NQ330_cmds, cmds);
break;
default:
LOG_INFORMATION( "Chip not supported, taking NQ330 as default\n ");
cmds = sizeof(NQ330_cmds) / sizeof(NQ330_cmds[0]);
sendcmds(NQ330_cmds, cmds);
break;
}
LOG_INFORMATION("\n<<>> Waiting for TAG detect or 20sec timeout <<>> ...\n");
status = clock_gettime( CLOCK_REALTIME, &time_sec );
time_sec.tv_sec += NFC_NTF_TIMEOUT;
status = sem_timedwait( &sRfNtf, &time_sec ); //start waiting
if (status <0) {
LOG_INFORMATION("\n No NFC Tag detected, continue ...\n");
}
}
status = ftm_nq_nfc_close( ); // release the handle to the kernel driver
if( 0 != status )
{
LOG_ERROR( "%s: ftm_nq_nfc_close() failed with status = %d \n", __FUNCTION__, status );
}
} while( FALSE );
}

View File

@@ -1,202 +0,0 @@
/*
* Copyright (c) 2017 Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*
* Not a Contribution.
* Apache license notifications and license are retained
* for attribution purposes only.
*
* Copyright (C) 2015 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.
*/
#define ESE_MAGIC 0xEA
#define ESE_SET_PWR _IOW(ESE_MAGIC, 0x01, unsigned int)
#define ESE_SET_DBG _IOW(ESE_MAGIC, 0x02, unsigned int)
#define ESE_SET_MODE _IOW(ESE_MAGIC, 0x03, unsigned int)
#define NFC_ESE_SET_PWR _IOW(0xE9, 0x02, unsigned int)
#define NFC_ESE_GET_PWR _IOR(0xE9, 0x03, unsigned int)
#define NFC_NTF_TIMEOUT 20
/* Supported Protocols */
#define NFC_PROTOCOL_UNKNOWN 0x00 /* Unknown */
#define NFC_PROTOCOL_T1T 0x01 /* Type1Tag - NFC-A */
#define NFC_PROTOCOL_T2T 0x02 /* Type2Tag - NFC-A */
#define NFC_PROTOCOL_T3T 0x03 /* Type3Tag - NFC-F */
#define NFC_PROTOCOL_ISO_DEP 0x04 /* Type 4A,4B - NFC-A or NFC-B */
#define NFC_PROTOCOL_NFC_DEP 0x05 /* NFCDEP/LLCP - NFC-A or NFC-F */
#define MAX_CMD_LEN 255
#define READ_SAMPLE_SIZE 258
extern int fdNfc; // a handle to the kernel driver
extern uint8_t nciReplyMessage[ 255 ];
extern NQ_CHIP_TYPE whatNQChip;
extern sem_t sRspReady;
extern int ftm_nfc_nq_vs_nxp( void );
int ese_dwp_test = 0;
int ese_spi_test = 0;
void sendcmds(uint8_t buffer[][255], int no_of_cmds);
void printTecnologyDetails(char technology, char protocol);
sem_t sRfNtf;
struct ese_spi_platform_data
{
unsigned int use_pwr_req;
unsigned int pwr_req;
unsigned int ese_intr;
};
/*
* Enum definition contains RF technology modes supported.
* This information is a part of RF_DISCOVER_NTF or RF_INTF_ACTIVATED_NTF.
*/
typedef enum
{
NFC_NFCA_Poll = 0x00, /* Nfc A Technology in Poll Mode */
NFC_NFCB_Poll = 0x01, /* Nfc B Technology in Poll Mode */
NFC_NFCF_Poll = 0x02, /* Nfc F Technology in Poll Mode */
NFC_NFCA_Active_Poll = 0x03, /* Nfc A Technology in Active Poll Mode */
NFC_NFCF_Active_Poll = 0x05, /* Nfc F Technology in Active Poll Mode */
NFC_NFCISO15693_Poll = 0x06, /* Nfc ISO15693 Technology in Poll Mode */
NFC_NxpProp_NFCHID_Poll = 0x70, /* Nfc Hid Technology in Poll Mode */
NFC_NxpProp_NFCEPFGEN2_Poll = 0x71, /* Nfc EpcGen2 Technology in Poll Mode */
NFC_NxpProp_NFCKOVIO_Poll = 0x72, /* Nfc Kovio Technology in Poll Mode */
NFC_NFCA_Listen = 0x80, /* Nfc A Technology in Listen Mode */
NFC_NFCB_Listen = 0x81, /* Nfc B Technology in Listen Mode */
NFC_NFCF_Listen = 0x82, /* Nfc F Technology in Listen Mode */
NFC_NFCA_Active_Listen = 0x83, /* Nfc A Technology in Active Listen Mode */
NFC_NFCF_Active_Listen = 0x85, /* Nfc F Technology in Active Listen Mode */
NFC_NFCISO15693_Active_Listen = 0x86 /* Nfc ISO15693 Technology in Listen Mode */
} NFC_RfTechMode_t;
uint8_t NQ330_cmds[][255] =
{
{ 0x20,0x00,0x01,0x00 },
{ 0x20,0x01,0x00},
{ 0x2F,0x02,0x00 },
{ 0x20,0x03,0x03,0x01,0xA0,0x0F },
{ 0x20,0x03,0x03,0x01,0xA0,0xFC },
{ 0x20,0x03,0x03,0x01,0xA0,0xF2 },
{ 0x20,0x03,0x03,0x01,0xA0,0xD7 },
{ 0x20,0x03,0x07,0x03,0xA0,0x02,0xA0,0x03,0xA0,0x04 },
{ 0x20,0x02,0x09,0x02,0xA0,0x03,0x01,0x01,0xA0,0x04,0x01,0x06 },
{ 0x20,0x02,0x0F,0x01,0xA0,0x0E,0x0B,0x11,0x01,0xC2,0xB2,0x00,0xB2,0x1E,0x1F,0x00,0xD0,0x0C },
{ 0x20,0x02,0x05,0x01,0xA0,0xF2,0x01,0x01 },
{ 0x20,0x03,0x03,0x01,0xA0,0xEC },
{ 0x20,0x03,0x03,0x01,0xA0,0xD4 },
{ 0x20,0x03,0x03,0x01,0xA0,0x14 },
{ 0x20,0x02,0x2E,0x0E,0x28,0x01,0x00,0x21,0x01,0x00,0x30,0x01,0x08,0x31,0x01,0x03,0x32,0x01,0x60,0x38,0x01,0x01,0x33,0x04,0x01,0x02,0x03,0x04,0x54,0x01,0x06,0x50,0x01,0x02,0x5B,0x01,0x00,0x80,0x01,0x01,0x81,0x01,0x01,0x82,0x01,0x0E,0x18,0x01,0x01 },
{ 0x20,0x02,0x05,0x01,0xA0,0x62,0x01,0x01 },
{ 0x20,0x02,0x06,0x01,0xA0,0xF3,0x02,0x10,0x27 },
{ 0x20,0x03,0x03,0x01,0xA0,0x85 },
{ 0x21,0x01,0x07,0x00,0x01,0x01,0x03,0x00,0x01,0x05 },
{ 0x20,0x02,0x05,0x01,0xA0,0xF1,0x01,0x00 },
{ 0x20,0x03,0x03,0x01,0xA0,0x0F },
{ 0x20,0x03,0x03,0x01,0xA0,0xEB },
{ 0x20,0x00,0x01,0x00 },
{ 0x20,0x01,0x00},
{ 0x20,0x03,0x02,0x01,0x00 },
{ 0x20,0x03,0x02,0x01,0x29 },
{ 0x20,0x03,0x02,0x01,0x61 },
{ 0x20,0x03,0x02,0x01,0x60 },
{ 0x20,0x02,0x0F,0x01,0xA0,0x0E,0x0B,0x11,0x01,0xC2,0xB2,0x00,0xB2,0x1E,0x1F,0x00,0xD0,0x0C },
{ 0x21,0x00,0x0D,0x04,0x04,0x03,0x02,0x05,0x03,0x03,0x03,0x02,0x01,0x80,0x01,0x80 },
{ 0x20,0x03,0x07,0x03,0xA0,0xEC,0xA0,0xED,0xA0,0xD4 },
{ 0x20,0x03,0x03,0x01,0xA0,0xEB },
{ 0x20,0x03,0x03,0x01,0xA0,0xF0 },
{ 0x22,0x01,0x02,0xC0,0x01 },
{ 0x22,0x03,0x02,0xC0,0x00 },
{ 0x20,0x03,0x03,0x01,0xA0,0x14 },
{ 0x20,0x03,0x03,0x01,0xA0,0xEB },
{ 0x20,0x03,0x03,0x01,0xA0,0x07 },
{ 0x20,0x03,0x02,0x01,0x52 },
{ 0x2F,0x15,0x01,0x02 },
{ 0x21,0x03,0x07,0x03,0x80,0x01,0x81,0x01,0x82,0x01 },
{ 0x21,0x06,0x01,0x00 },
{ 0x2F,0x15,0x01,0x00 },
{ 0x20,0x02,0x07,0x02,0x32,0x01,0x60,0x38,0x01,0x01 },
{ 0x21,0x01,0x1B,0x00,0x05,0x01,0x03,0x00,0x01,0x03,0x01,0x03,0x00,0x41,0x04,0x01,0x03,0x00,0x41,0xA0,0x01,0x03,0x00,0x01,0x05,0x00,0x03,0xC0,0xC3,0x02 },
{ 0x20,0x02,0x07,0x02,0x32,0x01,0x60,0x38,0x01,0x01},
{ 0x21,0x03,0x19,0x0C,0x00,0x01,0x01,0x01,0x02,0x01,0x03,0x01,0x05,0x01,0x80,0x01,0x81,0x01,0x82,0x01,0x83,0x01,0x85,0x01,0x06,0x01,0x70,0x01}
};
uint8_t NQ330_ESE_DWP[][255] =
{
{ 0x20,0x00,0x01,0x00 },
{ 0x20,0x01,0x00},
{ 0x20,0x02,0x05,0x01,0xA0,0xF2,0x01,0x01 },
{ 0x22,0x00,0x01,0x01 },
{ 0x22,0x01,0x2,0x01,0x01 },
{ 0x20,0x04,0x06,0x03,0x01,0x01,0x02,0x01,0x01 },
{ 0x03,0x00,0x03,0x81,0x02,0x01 },
{ 0x03,0x00,0x03,0x81,0x02,0x04 },
{ 0x03,0x00,0x03,0x81,0x02,0x07 },
{ 0x21,0x01,0x1B,0x00,0x05,0x01,0x03,0x00,0x01,0x03,0x01,0x03,0x00,0x41,0x04,0x01,0x03,0x00,0x41,0xA0,0x01,0x03,0x00,0x01,0x05,0x00,0x03,0xC0,0xC3,0x02 },
{ 0x21,0x03,0x19,0x0C,0x00,0x01,0x01,0x01,0x02,0x01,0x03,0x01,0x05,0x01,0x80,0x01,0x81,0x01,0x82,0x01,0x83,0x01,0x85,0x01,0x06,0x01,0x70,0x01},
{ 0x03,0x00,0x07,0x99,0x50,0x00,0x70,0x00,0x00,0x01},
{ 0x03,0x00,0x09,0x99,0x50,0x80,0xCA,0x00,0xFE,0x02,0xDF,0x21 }
};
uint8_t NQ220_cmds[][255] =
{
{ 0x20,0x00,0x01,0x00 },
{ 0x20,0x01,0x00 },
{ 0x2F,0x02,0x00 },
{ 0x20,0x03,0x03,0x01,0xA0,0x0F },
{ 0x20,0x03,0x07,0x03,0xA0,0x02,0xA0,0x03,0xA0,0x04 },
{ 0x20,0x02,0x05,0x01,0xA0,0x44,0x01,0x00 },
{ 0x20,0x02,0x0B,0x02,0xA0,0x66,0x01,0x00,0xA0,0x0E,0x03,0x02,0x09,0x00 },
{ 0x20,0x02,0x26,0x09,0xA0,0xEC,0x01,0x01,0xA0,0xED,0x01,0x03,0xA0,0x5E,0x01,0x01,0xA0,0x12,0x01,0x02,0xA0,0x40,0x01,0x01,0xA0,0xDD,0x01,0x2D,0xA0,0xF2,0x01,0x01,0xA0,0x96,0x01,0x01,0xA0,0x9F,0x02,0x08,0x08 },
{ 0x20,0x03,0x03,0x01,0xA0,0xEC },
{ 0x20,0x03,0x03,0x01,0xA0,0x14 },
{ 0x20,0x02,0x2E,0x0E,0x28,0x01,0x00,0x21,0x01,0x00,0x30,0x01,0x08,0x31,0x01,0x03,0x32,0x01,0x60,0x38,0x01,0x01,0x33,0x04,0x01,0x02,0x03,0x04,0x54,0x01,0x06,0x50,0x01,0x02,0x5B,0x01,0x00,0x80,0x01,0x01,0x81,0x01,0x01,0x82,0x01,0x0E,0x18,0x01,0x01 },
{ 0x20,0x02,0x05,0x01,0xA0,0x62,0x01,0x01 },
{ 0x20,0x02,0x06,0x01,0xA0,0xF3,0x02,0x10,0x27 },
{ 0x20,0x03,0x03,0x01,0xA0,0x85 },
{ 0x21,0x01,0x07,0x00,0x01,0x01,0x03,0x00,0x01,0x05 },
{ 0x20,0x02,0x05,0x01,0xA0,0xF1,0x01,0x00 },
{ 0x20,0x02,0x05,0x01,0xA0,0x91,0x01,0x01 },
{ 0x20,0x03,0x03,0x01,0xA0,0x0F },
{ 0x20,0x03,0x03,0x01,0xA0,0xEB },
{ 0x20,0x00,0x01,0x00 },
{ 0x20,0x01,0x00 },
{ 0x20,0x03,0x02,0x01,0x00 },
{ 0x20,0x03,0x02,0x01,0x29 },
{ 0x20,0x03,0x02,0x01,0x61 },
{ 0x20,0x03,0x02,0x01,0x60 },
{ 0x21,0x00,0x0D,0x04,0x04,0x03,0x02,0x05,0x03,0x03,0x03,0x02,0x01,0x80,0x01,0x80 },
{ 0x22,0x00,0x01,0x01 },
{ 0x20,0x04,0x06,0x03,0x01,0x01,0x02,0x01,0x01 },
{ 0x03,0x00,0x05,0x81,0x01,0x03,0x02,0xC0 },
{ 0x03,0x00,0x05,0x81,0x01,0x06,0x01,0x00 },
{ 0x03,0x00,0x03,0x81,0x02,0x01 },
{ 0x03,0x00,0x03,0x81,0x02,0x04 },
{ 0x20,0x03,0x05,0x02,0xA0,0xEC,0xA0,0xED },
{ 0x20,0x03,0x03,0x01,0xA0,0xEB },
{ 0x20,0x03,0x03,0x01,0xA0,0xF0 },
{ 0x20,0x03,0x05,0x02,0xA0,0xEC,0xA0,0xED },
{ 0x20,0x03,0x03,0x01,0xA0,0x14 },
{ 0x20,0x03,0x03,0x01,0xA0,0xEB },
{ 0x20,0x03,0x03,0x01,0xA0,0x07 },
{ 0x20,0x02,0x05,0x01,0xA0,0x07,0x01,0x03 },
{ 0x20,0x03,0x02,0x01,0x52 },
{ 0x21,0x01,0x16,0x00,0x04,0x01,0x03,0x00,0x01,0x03,0x01,0x03,0x00,0x41,0x04,0x01,0x03,0x00,0x41,0xA0,0x01,0x03,0x00,0x01,0x05 },
{ 0x20,0x02,0x0A,0x03,0x32,0x01,0x20,0x38,0x01,0x01,0x50,0x01,0x00 },
{ 0x21,0x03,0x07,0x03,0x80,0x01,0x81,0x01,0x82,0x01 },
{ 0x21,0x06,0x01,0x00 },
{ 0x20,0x02,0x17,0x01,0x61,0x14,0x46,0x66,0x6D,0x01,0x01,0x12,0x02,0x02,0x07,0xFF,0x03,0x02,0x00,0x13,0x04,0x01,0x64,0x07,0x01,0x03 },
{ 0x20,0x02,0x0A,0x03,0x32,0x01,0x60,0x38,0x01,0x01,0x50,0x01,0x02 },
{ 0x21,0x03,0x19,0x0C,0x00,0x01,0x01,0x01,0x02,0x01,0x03,0x01,0x05,0x01,0x80,0x01,0x81,0x01,0x82,0x01,0x83,0x01,0x85,0x01,0x06,0x01,0x70,0x01 }
};

View File

@@ -1,724 +0,0 @@
/*=========================================================================
NFC FTM Source File
Description
This file contains the routines to communicate with the NFCC in FTM mode.
Copyright (c) 2015 Qualcomm Technologies, Inc.
All Rights Reserved.
Confidential and Proprietary - Qualcomm Technologies, Inc.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
===========================================================================*/
/*==========================================================================*
* INCLUDE FILES *
*==========================================================================*/
#include "ftm_nfcqti.h"
#define UNUSED(x) (void)(x)
/*=========================================================================*
* file scope local defnitions *
*==========================================================================*/
const hw_module_t* hw_module = NULL;
nfc_nci_device_t* dev = NULL;
uint8 hal_state = NCI_HAL_INIT, nfc_ftmthread = FALSE;
uint8 *nfc_cmd_buff = NULL, len = 0;
uint16 res_len = 0, async_msg_cnt = 0;
uint8 *response_buff = NULL;
static uint8 hal_opened = FALSE, wait_rsp = FALSE;
static uint8 async_msg_available = FALSE, ftm_data_rsp_pending = FALSE;
asyncdata *buff = NULL;
asyncdata *start = NULL;
/*I2C read/write*/
static uint8 i2c_cmd_cnt = 0;
uint8 i2c_status=0,i2c_req_write = FALSE, i2c_req_read = FALSE;
uint8 i2c_num_of_reg_to_read = 0, i2c_reg_read_data[40]={0}, ii = 0;
pthread_mutex_t nfcftm_mutex = PTHREAD_MUTEX_INITIALIZER;
/*===================================================================================*
* Function Defnitions *
*===================================================================================*/
/*====================================================================================
FUNCTION nfc_ftm_hal_cback
DESCRIPTION
This is the call back function which will indicate if the nfc hal open is successful
or failed.
DEPENDENCIES
NIL
RETURN VALUE
none
SIDE EFFECTS
NONE
=====================================================================================*/
static void nfc_ftm_cback(uint8 event, uint8 status)
{
switch(event)
{
case HAL_NFC_OPEN_CPLT_EVT:
if(status == HAL_NFC_STATUS_OK)
{
/* Release semaphore to indicate that hal open is done
and change the state to write.*/
hal_state = NCI_HAL_WRITE;
hal_opened = TRUE;
printf("HAL Open Success..state changed to Write \n");
}
else
{
printf("HAL Open Failed \n");
hal_state = NCI_HAL_ERROR;
hal_opened = FALSE;
}
sem_post(&semaphore_halcmd_complete);
break;
case HAL_NFC_CLOSE_CPLT_EVT:
printf("HAL_NFC_CLOSE_CPLT_EVT recieved..\n");
break;
default:
printf ("nfc_ftm_hal_cback unhandled event %x \n", event);
break;
}
}
/*==========================================================================================
FUNCTION fill_async_data
DESCRIPTION
This function will store all the incoming async msgs( like ntfs and data from QCA1990)
in to a list to be committed further.
DEPENDENCIES
NIL
RETURN VALUE
NONE
SIDE EFFECTS
NONE
==============================================================================================*/
void fill_async_data(uint16 data_len, uint8 *p_data)
{
uint16 i = 0;
asyncdata *next_node = NULL;
printf("fill_async_data() function \n");
/* Initialize a list which will store all async message untill they are sent*/
if(buff == NULL)
{
/* first node creation*/
buff = (asyncdata*)malloc(sizeof(asyncdata));
if(buff)
{
start = buff;
buff->response_buff = (uint8*)malloc(data_len);
if(buff->response_buff)
{
memcpy(buff->response_buff, p_data, data_len);
buff->async_datalen = data_len;
buff->next = NULL;
async_msg_cnt = 0;
async_msg_cnt++;
}
else
{
printf("mem allocation failed while storing asysnc msg \n");
}
}
else
{
printf("mem allocation failed while trying to make the async list \n");
}
}
else
{
/* this is the case when some data is already present in the list which has not been sent yet*/
next_node = (asyncdata*)malloc(sizeof(asyncdata));
if(next_node)
{
next_node->response_buff = (uint8*)malloc(data_len);
if(next_node->response_buff)
{
memcpy(next_node->response_buff, p_data,data_len);
next_node->async_datalen = data_len;
next_node->next = NULL;
async_msg_cnt++;
while(buff->next != NULL)
{
buff = buff->next;
}
buff->next = next_node;
}
else
{
printf("mem allocation failed while storing asysnc msg \n");
}
}
else
{
printf("mem allocation failed while trying to make the async list \n");
}
}
}
/*======================================================================================================
FUNCTION nfc_ftm_data_cback
DESCRIPTION
This is the call back function which will provide back incoming data from the QCA1990
to nfc ftm.
DEPENDENCIES
NIL
RETURN VALUE
NONE
SIDE EFFECTS
NONE
========================================================================================================*/
static void nfc_ftm_data_cback(uint16 data_len, uint8 *p_data)
{
uint8 i = 0;
if(hal_opened == FALSE)
{
/* Reject data call backs untill HAL in initialized */
return;
}
if((data_len == 0x00) || (p_data == NULL))
{
printf("Error case : wrong data lentgh or buffer revcieved \n");
return;
}
if((i2c_req_write == TRUE) || (i2c_req_read == TRUE))
{
if(i2c_req_write)
{
/*check the incoming status*/
if(p_data[0] != 0x00) /* 0x00 = Command executed successfully*/
{
/* some error has occured in I2C write.Send the status code back now to pc app*/
i2c_status = p_data[0];
printf("Error occured in I2C write .. reporting to application..Error Code = %X \n", i2c_status);
hal_state = NCI_HAL_READ;
sem_post(&semaphore_halcmd_complete);
}
else
{
/*status is fine. Complete further requests as ftmdaemon is writing one by one*/
if(len)
{
/*send further addr and value pair*/
printf("I2C write status correct..sending next..\n");
hal_state = NCI_HAL_WRITE;
}
else
{
/*All I2C write completed .Send final status to app*/
i2c_status = p_data[0];
printf(" All I2C write completed i2c_status = %X \n", i2c_status);
hal_state = NCI_HAL_READ;
}
sem_post(&semaphore_halcmd_complete);
}
}
else
{
/*I2C read rsp arrived . fill it in buffer if correct or report error if wrong*/
if(p_data[0] != 0x00)
{
/* some error has occured in I2C read.Send the status code to app*/
i2c_status = p_data[0];
printf("Error occured in I2C read .. reporting to application..Error Code = %X \n", i2c_status);
hal_state = NCI_HAL_READ;
memset(nfc_cmd_buff, 0, len);
sem_post(&semaphore_halcmd_complete);
}
else
{
if(len)
{
/*send further addr to read*/
i2c_status = p_data[0];
i2c_reg_read_data[ii++] = p_data[1];
hal_state = NCI_HAL_WRITE;
}
else
{
/*All I2C read completed .Send the read data back to pc app*/
i2c_status = p_data[0];
i2c_reg_read_data[ii++] = p_data[1];
hal_state = NCI_HAL_READ;
ii = 0;
}
sem_post(&semaphore_halcmd_complete);
}
}
}
else
{
if(((p_data[0] & 0xF0) == 0x60 /*ntf packets*/) || ((p_data[0] & 0xF0) == 0x00)/*data packet rsps*/)
{
async_msg_available = TRUE;
pthread_mutex_lock(&nfcftm_mutex);
fill_async_data(data_len, p_data);
pthread_mutex_unlock(&nfcftm_mutex);
if(ftm_data_rsp_pending == TRUE)
{
printf("Sending data rsp \n");
hal_state = NCI_HAL_READ;
sem_post(&semaphore_halcmd_complete);
ftm_data_rsp_pending = FALSE;
}
else
{
if((wait_rsp == FALSE) || ((p_data[0] == 0x60) && (p_data[1] == 0x00)))
{
/*This is the case when ntf receieved after rsp is logged to pc app*/
printf("Sending async msg to logging subsystem \n");
hal_state = NCI_HAL_ASYNC_LOG;
sem_post(&semaphore_halcmd_complete);
}
}
}
else
{
if(response_buff || res_len)
{
printf("nfc_ftm_data_cback : response_buff = %p, res_len = %d", response_buff, res_len);
return;
}
response_buff = (uint8*)malloc(data_len);
if(response_buff)
{
memcpy(response_buff, p_data, data_len);
res_len = data_len;
printf("nfc_ftm_data_cback: res_len=%d data_len=%d response_buff= %X %X %X %X %X %X \n", res_len,data_len, \
response_buff[0],response_buff[1],response_buff[2],response_buff[3],response_buff[4],response_buff[5]);
hal_state = NCI_HAL_READ;
sem_post(&semaphore_halcmd_complete);
}
else
{
printf("Mem allocation failed in nfc_ftm_data_cback \n");
}
}
}
}
/*===========================================================================
FUNCTION ftm_nfc_hal_open
DESCRIPTION
This function will open the nfc hal for ftm nfc command processing.
DEPENDENCIES
NIL
RETURN VALUE
void
SIDE EFFECTS
NONE
===============================================================================*/
uint8 ftm_nfc_hal_open(void)
{
uint8 ret = 0;
ret = hw_get_module(NFC_NCI_HARDWARE_MODULE, &hw_module);
if(ret == 0)
{
dev = (nfc_nci_device_t*)malloc(sizeof(nfc_nci_device_t));
if(!dev)
{
printf("NFC FTM : mem allocation failed \n");
return FALSE;
}
else
{
ret = nfc_nci_open (hw_module, &dev);
if(ret != 0)
{
printf("NFC FTM : nfc_nci_open fail \n");
free(dev);
return FALSE;
}
else
{
printf("NFC FTM : opening NCI HAL \n");
dev->common.reserved[0] = FTM_MODE;
dev->open (dev, nfc_ftm_cback, nfc_ftm_data_cback);
sem_wait(&semaphore_halcmd_complete);
}
}
}
else
{
printf("NFC FTM : hw_get_module() call failed \n");
return FALSE;
}
return TRUE;
}
/*=================================================================================================
FUNCTION ftm_nfc_log_send_msg
DESCRIPTION
This function will log the asynchronous messages(NTFs and data packets) to the logging subsystem
of DIAG.
DEPENDENCIES
RETURN VALUE
TRUE if data logged successfully and FALSE if failed.
SIDE EFFECTS
None
==================================================================================================*/
int ftm_nfc_log_send_msg(void)
{
uint16 i = 0;
ftm_nfc_log_pkt_type* ftm_nfc_log_pkt_ptr = NULL;
asyncdata* node = NULL;
uint8 arr[1]= {'\n'};
if(log_status(LOG_NFC_FTM))
{
buff = start;
if(buff != NULL)
{
do{
printf("buff->async_datalen : %d \n", buff->async_datalen);
ftm_nfc_log_pkt_ptr = (ftm_nfc_log_pkt_type *)log_alloc(LOG_NFC_FTM, (FTM_NFC_LOG_HEADER_SIZE + (buff->async_datalen)));
if(ftm_nfc_log_pkt_ptr)
{
memcpy((void *)ftm_nfc_log_pkt_ptr->data, (void *)buff->response_buff, buff->async_datalen);
printf("Async msg is = ");
for(i=0; i<buff->async_datalen; i++)
{
printf("%X ", ftm_nfc_log_pkt_ptr->data[i]);
}
printf("%c",arr[0]);
node = buff;
buff = buff->next;
free(node);
printf("Commiting the log message(async msg) \n");
log_commit(ftm_nfc_log_pkt_ptr);
}
else
{
printf("\nmem alloc failed in log_alloc \n");
return FALSE;
}
}while(buff != NULL);
printf("all msgs committed \n");
async_msg_available = FALSE;
return TRUE;
}
else
{
printf("No async message left to be logged \n");
}
}
else
{
printf("LOG_NFC_FTM code is not enabled in logging subsystem \n");
}
return FALSE;
}
/*===========================================================================
FUNCTION nfc_ftm_readerthread
DESCRIPTION
Thread Routine to perfom asynchrounous handling of events coming from
NFCC. It will perform read and write for all type of commands/data.
DEPENDENCIES
RETURN VALUE
RETURN NIL
SIDE EFFECTS
None
===========================================================================*/
void* nfc_ftm_thread(void *ptr)
{
uint8 i2c_buff[3] = {0};
UNUSED(ptr);
while(1)
{
printf("Waiting for Cmd/Rsp \n");
sem_wait (&semaphore_halcmd_complete);
switch(hal_state)
{
case NCI_HAL_INIT:
printf("NFC FTM : HAL Open request recieved..\n");
if(ftm_nfc_hal_open() == FALSE)
{
hal_state = NCI_HAL_ERROR;
hal_opened = FALSE;
}
else
{
break;
}
case NCI_HAL_ERROR:
/* HAL open failed.Post sem and handle error case*/
sem_post(&semaphore_nfcftmcmd_complete);
break;
case NCI_HAL_WRITE:
if(dev != NULL)
{
printf("NFC FTM : Cmd recieved for nfc ftm..sending.\n");
if((!i2c_req_write) && (!i2c_req_read))
{
/* send data to the NFCC*/
if(nfc_cmd_buff[0] == 0x00 /*data req*/)
{
printf("Data send request arrived \n");
ftm_data_rsp_pending = TRUE;
}
else
{
printf("cmd request arrived \n");
wait_rsp = TRUE;
}
dev->write(dev, len, nfc_cmd_buff);
}
else
{
if(i2c_req_write)
{
i2c_buff[0] = 0xFF;
i2c_buff[1] = nfc_cmd_buff[i2c_cmd_cnt++]; /* addr*/
i2c_buff[2] = nfc_cmd_buff[i2c_cmd_cnt++]; /*value*/
len -=2;
dev->write(dev, 3, i2c_buff);
}
else
{
/* I2c Read req*/
i2c_buff[0] = 0xFF;
i2c_buff[1] = nfc_cmd_buff[i2c_cmd_cnt++]; /* I2C addr to read*/
i2c_reg_read_data[ii++] = i2c_buff[1]; /* store address to send in response.*/
len -= 1;
dev->write(dev, 2, i2c_buff);
}
}
}
else
{
printf("dev is null \n");
}
break;
case NCI_HAL_READ:
/* indicate to ftm that response is avilable now*/
sem_post(&semaphore_nfcftmcmd_complete);
printf("NFC FTM : State changed to READ i2c_req_read: %d\n",i2c_req_read);
break;
case NCI_HAL_ASYNC_LOG:
/* indicate to ftm that response is avilable now*/
printf("NFC FTM : State changed to NCI_HAL_ASYNC_LOG.Logging aysnc message \n");
pthread_mutex_lock(&nfcftm_mutex);
if(ftm_nfc_log_send_msg())
{
printf("async msgs commited to the log system..changing HAL state to write \n");
}
else
{
printf("async msgs commit failed..changing HAL state to write \n");
}
hal_state = NCI_HAL_WRITE;
pthread_mutex_unlock(&nfcftm_mutex);
break;
default:
break;
}
}
}
/*===========================================================================
FUNCTION ftm_nfc_dispatch
DESCRIPTION
This is the function which will be called by the NFC FTM layer callback function
registered with the DIAG service./
DEPENDENCIES
RETURN VALUE
RETURN rsp pointer(containing the NFCC rsp packets) to the callback function
(subsequently for DIAG service)
SIDE EFFECTS
None
===========================================================================*/
void* ftm_nfc_dispatch_qti(ftm_nfc_pkt_type *nfc_ftm_pkt, uint16 pkt_len)
{
ftm_nfc_i2c_write_rsp_pkt_type *i2c_write_rsp = NULL;
ftm_nfc_i2c_read_rsp_pkt_type *i2c_read_rsp = NULL;
ftm_nfc_pkt_type *rsp = NULL;
ftm_nfc_data_rsp_pkt_type *nfc_data_rsp = NULL;
struct timespec time_sec;
int sem_status;
UNUSED(pkt_len);
printf("NFC FTM : nfc ftm mode requested \n");
if(nfc_ftm_pkt == NULL)
{
printf("Error : NULL packet recieved from DIAG \n");
goto error_case;
}
/* Start nfc_ftm_thread which will process all requests as per
state machine flow. By Default First state will be NCI_HAL_INIT*/
if(!nfc_ftmthread)
{
if(sem_init(&semaphore_halcmd_complete, 0, 1) != 0)
{
printf("NFC FTM :semaphore_halcmd_complete creation failed \n");
goto error_case;
}
if(sem_init(&semaphore_nfcftmcmd_complete, 0, 0) != 0)
{
printf("NFC FTM :semaphore_nfcftmcmd_complete creation failed \n");
goto error_case;
}
printf("NFC FTM : nfc ftm thread is being started \n");
pthread_create(&nfc_thread_handle, NULL, nfc_ftm_thread, NULL);
nfc_ftmthread = TRUE;
}
/* parse the diag packet to identify the NFC FTM command which needs to be sent
to QCA 1990*/
if(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_len > 2)
{
len = nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_len-2;
}
else
{
/*Wrong nfc ftm packet*/
goto error_case;
}
switch(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id)
{
case FTM_NFC_I2C_SLAVE_WRITE:
i2c_req_write = TRUE;
break;
case FTM_NFC_I2C_SLAVE_READ:
i2c_num_of_reg_to_read = len;
i2c_req_read = TRUE;
break;
case FTM_NFC_NFCC_COMMAND:
case FTM_NFC_SEND_DATA:
break;
default :
goto error_case;
break;
}
/*copy command to send it further to QCA1990*/
nfc_cmd_buff = (uint8 *)malloc(len+1);
if(nfc_cmd_buff)
{
memcpy(nfc_cmd_buff, nfc_ftm_pkt->nci_data, len);
}
else
{
printf("Mem allocation failed for cmd storage");
goto error_case;
}
/*send the command */
sem_post(&semaphore_halcmd_complete);
printf("\nwaiting for nfc ftm response \n");
if (clock_gettime(CLOCK_REALTIME, &time_sec) == -1)
{
printf("get clock_gettime error");
}
time_sec.tv_sec += FTM_NFC_CMD_CMPL_TIMEOUT;
sem_status = sem_timedwait(&semaphore_nfcftmcmd_complete,&time_sec);
if(sem_status == -1)
{
printf("nfc ftm command timed out\n");
goto error_case;
}
if(!hal_opened)
{
/*Hal open is failed */
free(nfc_cmd_buff);
hal_state = NCI_HAL_INIT;
goto error_case;
}
printf("\n\n *****Framing the response to send back to Diag service******** \n\n");
/* Frame the response as per the cmd request*/
switch(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id)
{
case FTM_NFC_I2C_SLAVE_WRITE:
printf("Framing the response for FTM_NFC_I2C_SLAVE_WRITE cmd \n");
i2c_write_rsp = (ftm_nfc_i2c_write_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM,
FTM_NFC_CMD_CODE,
sizeof(ftm_nfc_i2c_write_rsp_pkt_type));
if(i2c_write_rsp)
{
i2c_write_rsp->nfc_i2c_slave_status = i2c_status;
i2c_status = 0;
i2c_cmd_cnt = 0;
i2c_req_write = FALSE;
}
break;
case FTM_NFC_I2C_SLAVE_READ:
printf("Framing the response for FTM_NFC_I2C_SLAVE_READ cmd \n");
i2c_read_rsp = (ftm_nfc_i2c_read_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM,
FTM_NFC_CMD_CODE,
sizeof(ftm_nfc_i2c_read_rsp_pkt_type));
if(i2c_read_rsp)
{
i2c_read_rsp->ftm_nfc_hdr.nfc_cmd_id = FTM_NFC_I2C_SLAVE_READ;
i2c_read_rsp->ftm_nfc_hdr.nfc_cmd_len = 2+(2*i2c_num_of_reg_to_read);
i2c_read_rsp->nfc_i2c_slave_status = i2c_status;
if(i2c_status == 0x00)
{
i2c_read_rsp->nfc_nb_reg_reads = i2c_num_of_reg_to_read;
}
else
{
i2c_read_rsp->nfc_nb_reg_reads = 0x00; // error case so return num of read as 0x00.
}
memcpy(i2c_read_rsp->i2c_reg_read_rsp, i2c_reg_read_data, (i2c_num_of_reg_to_read*2));
i2c_cmd_cnt = 0;
}
break;
case FTM_NFC_NFCC_COMMAND:
printf("Framing the response for FTM_NFC_NFCC_COMMAND cmd \n");
if(response_buff && res_len)
{
rsp = (ftm_nfc_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM,
FTM_NFC_CMD_CODE,
sizeof(ftm_nfc_pkt_type));
if(rsp)
{
rsp->ftm_nfc_hdr.nfc_cmd_id = FTM_NFC_NFCC_COMMAND;
rsp->ftm_nfc_hdr.nfc_cmd_len = 2+res_len;
rsp->nfc_nci_pkt_len = res_len;
memcpy(rsp->nci_data, response_buff, res_len);
free(response_buff);
response_buff = 0;
res_len = 0;
}
}
else
printf("ftm_nfc_dispatch : response_buff = %p, res_len = %d", response_buff, res_len);
break;
case FTM_NFC_SEND_DATA:
printf("Framing the response for FTM_NFC_SEND_DATA cmd \n");
nfc_data_rsp = (ftm_nfc_data_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM,
FTM_NFC_CMD_CODE,
sizeof(ftm_nfc_data_rsp_pkt_type));
if(nfc_data_rsp)
{
nfc_data_rsp->ftm_nfc_hdr.nfc_cmd_id = FTM_NFC_SEND_DATA;
nfc_data_rsp->ftm_nfc_hdr.nfc_cmd_len = 0;/*Rsp as per the NFC FTM data rsp req*/
}
break;
default:
goto error_case;
break;
}
free(nfc_cmd_buff);
hal_state = NCI_HAL_WRITE;
if(async_msg_available)
{
printf(" Some async message available.. committing now.\n");
hal_state = NCI_HAL_ASYNC_LOG;
sem_post(&semaphore_halcmd_complete);
}
wait_rsp = FALSE;
if(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_I2C_SLAVE_WRITE)
{
return(void*)i2c_write_rsp;
}
else if(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_I2C_SLAVE_READ)
{
i2c_req_read = FALSE;
return(void*)i2c_read_rsp;
}
else if(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_NFCC_COMMAND)
{
return(void*)rsp;
}
else
{
return(void*)nfc_data_rsp;
}
error_case:
return NULL;
}

View File

@@ -1,141 +0,0 @@
#ifndef FTM_NFCQTI_H_
#define FTM_NFCQTI_H_
/*==========================================================================
nfc FTM header File
Description
This file contains the decalarations used by ftm_nfc.c
Copyright (c) 2015 Qualcomm Technologies, Inc.
All Rights Reserved.
Confidential and Proprietary - Qualcomm Technologies, Inc.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
08/06/13 NFC FTM layer
===========================================================================*/
#ifdef CONFIG_FTM_NFC
#include "stdio.h"
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#include <sys/types.h>
#include <hardware/nfc.h>
#include <hardware/hardware.h>
#include <malloc.h>
#include <string.h>
#include "msg.h"
#include "log.h"
#include "diag_lsm.h"
#include "diagpkt.h"
#include "diagcmd.h"
#include "diag.h"
#include "termios.h"
/*==========================================================================*
* Defnitions *
*==========================================================================*/
#define FTM_MODE 1
#define TRUE 1
#define FALSE 0
#define FTM_MODE 1
#define FTM_NFC_CMD_CODE 55
#define LOG_NFC_FTM 0x1802
#define FTM_NFC_LOG_HEADER_SIZE 12
#define FTM_NFC_I2C_SLAVE_WRITE 0x00
#define FTM_NFC_I2C_SLAVE_READ 0x01
#define FTM_NFC_NFCC_COMMAND 0x02
#define FTM_NFC_SEND_DATA 0x03
#define FTM_NFC_CMD_CMPL_TIMEOUT 15
#ifdef ANDROID_M
#define NFC_NCI_HARDWARE_MODULE "nfc_nci.qc199x"
#else
#define NFC_NCI_HARDWARE_MODULE "nfc_nci"
#endif
enum
{
NCI_HAL_INIT,
NCI_HAL_WRITE,
NCI_HAL_READ,
NCI_HAL_DEINIT,
NCI_HAL_ASYNC_LOG,
NCI_HAL_ERROR
};
/*==========================================================================*
* Declarations *
*==========================================================================*/
/* Reader thread handle */
pthread_t nfc_thread_handle;
sem_t semaphore_halcmd_complete;
sem_t semaphore_nfcftmcmd_complete;
/* structure that contains nfc cmd id and len
part of the packet recieved from DIAG*/
PACKED struct ftm_nfc_cmd_header_type{
uint16 nfc_cmd_id;
uint16 nfc_cmd_len;
};
/* nfc FTM packet(for NCI cmd/rsp messages)*/
typedef PACKED struct{
diagpkt_subsys_header_type diag_hdr;
struct ftm_nfc_cmd_header_type ftm_nfc_hdr;
uint16 nfc_nci_pkt_len;
byte nci_data[258];
}ftm_nfc_pkt_type;
/* nfc FTM packet (for I2C write messgaes)*/
typedef PACKED struct{
diagpkt_subsys_header_type diag_hdr;
uint8 nfc_i2c_slave_status;
}ftm_nfc_i2c_write_rsp_pkt_type;
/* nfc FTM packet (for I2C read messgaes)*/
typedef PACKED struct{
diagpkt_subsys_header_type diag_hdr;
struct ftm_nfc_cmd_header_type ftm_nfc_hdr;
uint8 nfc_i2c_slave_status;
uint8 nfc_nb_reg_reads;
byte i2c_reg_read_rsp[30];
}ftm_nfc_i2c_read_rsp_pkt_type;
typedef PACKED struct{
diagpkt_subsys_header_type diag_hdr;
struct ftm_nfc_cmd_header_type ftm_nfc_hdr;
}ftm_nfc_data_rsp_pkt_type;
typedef PACKED struct{
log_hdr_type hdr;
byte data[1];
}ftm_nfc_log_pkt_type;
/*Data buffer linked list*/
typedef struct asyncdata {
uint8 *response_buff;
uint8 async_datalen;
struct asyncdata *next;
}asyncdata;
typedef void (tHAL_NFC_CBACK) (uint8 event, uint8 status);
typedef void (tHAL_NFC_DATA_CBACK) (uint16 data_len, uint8 *p_data);
void* ftm_nfc_dispatch_qti(ftm_nfc_pkt_type *ftm_nfc_pkt, uint16 pkt_len);
#endif /* CONFIG_FTM_NFC */
#endif /* FTM_NFCQTI_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,235 +0,0 @@
/*==========================================================================
FTM WLAN Header File
Description
The header file includes enums, struct definitions for WLAN FTM packets
# Copyright (c) 2010-2011, 2014 by Qualcomm Technologies, Inc.
# All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
Edit History
when who what, where, why
-------- --- ----------------------------------------------------------
07/11/11 karthikm Created header file to include enums, struct for WLAN FTM
for Atheros support
========================================================================*/
#ifndef FTM_WLAN_H_
#define FTM_WLAN_H_
#ifdef CONFIG_FTM_WLAN
#include "diagpkt.h"
#include <sys/types.h>
#define FTM_WLAN_CMD_CODE 22
/* TODO: For LE platforms only - need to extend it for BE platform too*/
#define cpu32_to_le32(buf, val) \
do { \
buf[0] = val & 0xff; \
buf[1] = (val >> 8) & 0xff; \
buf[2] = (val >> 16) & 0xff; \
buf[3] = (val >> 24) & 0xff; \
} while(0)
/* TODO: For LE platforms only - need to extend it for BE platform too*/
#define le_to_cpu16(buf, uint16_val) \
do { \
uint16_val = (buf[0] | buf[1] << 8); \
} while(0)
/* TODO: For LE platforms only - need to extend it for BE platform too*/
#define le_to_cpu32(buf, uint32_val) \
do { \
uint32_val = (buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24); \
} while(0)
extern char g_ifname[];
/* Various ERROR CODES supported by the FTM WLAN module*/
typedef enum {
FTM_ERR_CODE_PASS = 0,
FTM_ERR_CODE_IOCTL_FAIL,
FTM_ERR_CODE_SOCK_FAIL,
FTM_ERR_CODE_UNRECOG_FTM
}FTM_WLAN_LOAD_ERROR_CODES;
#define CONFIG_HOST_TCMD_SUPPORT 1
#define AR6000_IOCTL_SUPPORTED 1
#define ATH_MAC_LEN 6
#define FTM_WLAN_SSP_SUCCESS 0
#define FTM_WLAN_SSP_FAIL 1
typedef enum {
FTM_WLAN_COMMON_OP,
FTM_WLAN_BDF_GET_MAX_TRANSFER_SIZE,
FTM_WLAN_BDF_READ,
FTM_WLAN_BDF_WRITE,
FTM_WLAN_BDF_GET_FNAMEPATH,
FTM_WLAN_BDF_SET_FNAMEPATH,
#ifdef WIN_AP_AFC
FTM_WLAN_SSP_GET_ID = 16,
FTM_WLAN_SSP_STR_SSP = 17,
FTM_WLAN_SSP_STR_LOC = 18,
FTM_WLAN_SSP_STR_CFG = 19
#endif /* WIN_AP_AFC */
}FTM_WLAN_CMD;
typedef enum {
WLAN_BDF_READ_SUCCESS,
WLAN_BDF_READ_FAILED,
WLAN_BDF_WRITE_SUCCESS,
WLAN_BDF_WRITE_FAILED,
WLAN_BDF_INVALID_SIZE = 5,
WLAN_BDF_BAD_OFFSET,
WLAN_BDF_FILE_OPEN_FAIL,
WLAN_BDF_FILE_SEEK_FAIL,
WLAN_BDF_FILE_STAT_FAIL,
WLAN_BDF_PATH_GET_SUCCESS,
WLAN_BDF_PATH_GET_FAILED,
WLAN_BDF_PATH_SET_SUCCESS,
WLAN_BDF_PATH_SET_FAILED
}FTM_WLAN_ERROR_CODES;
#ifdef WIN_AP_HOST
#define PACKED_STRUCT __attribute__((__packed__))
#else
#define PACKED_STRUCT __attribute__((packed))
#endif
/*FTM WLAN request type*/
typedef struct
{
diagpkt_cmd_code_type cmd_code;
diagpkt_subsys_id_type subsys_id;
diagpkt_subsys_cmd_code_type subsys_cmd_code;
uint16 cmd_id; /* command id (required) */
uint16 cmd_data_len;
uint16 cmd_rsp_pkt_size;
union {
struct {
uint16 rsvd;
byte rsvd1;
byte rsvd2;
byte wlanslotno;
byte wlandeviceno;
byte data[0];
}PACKED_STRUCT common_ops;
struct {
byte rsvd[6];
byte data[0];
}PACKED_STRUCT get_max_transfer_size;
struct {
uint32 offset;
byte rsvd[2];
byte data[0];
}PACKED_STRUCT read_file;
struct {
uint16 size;
uint8 append_flag;
byte rsvd[3];
byte data[0];
}PACKED_STRUCT write_file;
struct {
byte rsvd[6];
byte data[0];
}PACKED_STRUCT get_fname;
struct {
byte rsvd[6];
byte data[0];
}PACKED_STRUCT set_fname;
}cmd;
}PACKED_STRUCT ftm_wlan_req_pkt_type;
/*FTM WLAM response type */
typedef struct
{
struct {
diagpkt_subsys_header_type header; /*diag header*/
uint16 cmd_id; /* command id (required) */
uint16 cmd_data_len;
uint16 cmd_rsp_pkt_size;
}PACKED_STRUCT common_header;
union {
struct {
uint16 rsvd;
uint32 result ;/* error_code */
union {
struct {
byte data[0]; /*rxReport*/
}rxReport;
struct {
byte data[0]; /*ThermValReport*/
}thermval_report;
}rx_and_therm;
}PACKED_STRUCT common_ops;
struct {
uint16 result; /*error_code*/
byte rsvd[4];
uint16 max_size;
}PACKED_STRUCT get_max_transfer_size;
struct {
byte result; /*error_code*/
uint16 size;
byte bytes_remaining[3];
byte data[0];
}PACKED_STRUCT read_file;
struct {
byte result;
byte rsvd[5];
byte data[0];
}PACKED_STRUCT write_file;
struct {
byte result;
byte rsvd[5];
byte data[0];
}PACKED_STRUCT get_fname;
struct {
byte result;
byte rsvd[5];
byte data[0];
}PACKED_STRUCT set_fname;
struct {
uint16 win_cmd_specific;
uint16 data_len;
uint8 rsvd;
uint8 wlandeviceno;
byte data[0];
}PACKED_STRUCT win_resp;
struct {
uint16 result;
uint32 serial;
byte data[0];
}PACKED_STRUCT ssp;
}cmd;
}PACKED_STRUCT ftm_wlan_rsp_pkt_type;
void* ftm_wlan_dispatch(ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len);
#ifdef WIN_AP_HOST
void setBoardDataCaptureFlag (int flag);
void setDeviceId(int id);
extern ftm_wlan_rsp_pkt_type *win_bt_mac_flash_write(
ftm_wlan_req_pkt_type *wlan_ftm_pkt,
int pkt_len);
extern void win_host_handle_fw_resp (ftm_wlan_rsp_pkt_type *rsp, void *data, uint32_t data_len);
extern ftm_wlan_rsp_pkt_type *win_host_handle_bdf_req(
ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len);
#endif
#endif /* CONFIG_FTM_WLAN */
#endif /* FTM_WLAN_H_ */

View File

@@ -1,196 +0,0 @@
/*
*Copyright (c) 2017-2019 Qualcomm Technologies, Inc.
*
*All Rights Reserved.
*Confidential and Proprietary - Qualcomm Technologies, Inc.
*/
#ifndef __FTM_WLAN_WIN_H
#define __FTM_WLAN_WIN_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <mtd/mtd-user.h>
#include "comdef.h"
#include "diagcmd.h"
#include "ftm_wlan.h"
#include "ftm_dbg.h"
#define MAC_XTAL_LENGTH 7
#define MAC_LENGTH_POS 103
#define MAC_POS 105
#define BT_TLV1_RESP_LEN 84
#define BT_RESP_LEN 100
#define FLASH_SECTOR_SIZE 0x10000
#define BD_LEN_EXPECTED 500
#define BD_SIZE_REQ_ID 106
#define BD_SIZE_REQ_POS 28
#define BD_SIZE_VAL 60
/* Identifier for first segment of
* Board data response
*/
#define FIRST_SEG 48
/* Identifier for second segment of
* board data response
*/
#define SECOND_SEG 49
#define THIRD_SEG 50
#define NO_ERROR 0
/* header length for first segment of
* board data response
*/
#define FIRST_SEG_TLV_HDR 84
#define SECOND_SEG_TLV_HDR 28
#define THIRD_SEG_TLV_HDR 28
#define SEQUENCE_ID_POS 24
/* Position at which first parameter of
* TLV request is located
*/
#define TLV_PAYLOAD_PARAM_1 80
/* Position at which second paramter of
* TLV request is located
*/
#define TLV_PAYLOAD_PARAM_2 96
/* Parameter 1 value if request is for
* board data capture
*/
#define BD_CAPTURE_REQ 101
/* Parameter 1 value if flash write request */
#define FLASH_WRITE_REQ 102
/* Parameter 1 value for device identify request */
#define DEVICE_IDENTIFY 103
/* Parameter 2 value for swift device identify */
#define QC9887_DEVICE_ID 0x50
#define QC9888_DEVICE_ID 0x3c
#define QC99xx_DEVICE_ID 0x46
#define QCN9000_DEVICE_ID 0x1104
#define TLV1_CMD_RESP_SIZE 118
#define TLV1_RESP_LEN 102
/* Offset at which BT_mac is to be stored in flash */
#define BT_MAC_OFFSET 0x40
#define FLASH_BASE_CALDATA_OFFSET_SOC_0 0x1000
#define FLASH_BASE_CALDATA_OFFSET_SOC_1 0x33000
#define MAX_ART_SLOTS 3
#define REQ_SEG_SIZE 4096
#define CALDATA_SEG_SIZE (150 * 1024)
#define FLASH_BASE_CALDATA_OFFSET_PCI_1 (REQ_SEG_SIZE + CALDATA_SEG_SIZE)
#define FLASH_BASE_CALDATA_OFFSET_PCI_2 (FLASH_BASE_CALDATA_OFFSET_PCI_1 + CALDATA_SEG_SIZE)
#define DIAG_HDR_LEN 16
#define FLASH_PARTITION "/dev/caldata"
#define VIRTUAL_FLASH_PARTITION "/tmp/virtual_art.bin"
#define WRITE_ART "/lib/compress_vart.sh write_caldata"
/* (0x33000-0x1000)=0x32000, Max available BDF size */
#define MAX_BDF_SIZE 200*1024
#define QC98XX_BLOCK_SIZE 512
#define BD_BLOCK_SIZE 256
/* Position of block size for the data */
#define QC98XX_BLOCK_SIZE_VAL 164
/* Position of block size for the data (radio != qc98XX) */
#define LEGACY_BLOCK_SIZE_VAL 100
#define M_EEEPROM_BLOCK_READ_ID_QC98XX 0xC8
#define M_EEEPROM_BLOCK_READ_ID_LEGACY 0xE9
/* Position where block data starts */
#define QC98XX_BLOCK_START_POS 200
#define LEGACY_BLOCK_START_POS 104
#define BD_READ_CMD_ID_POS 48
#define BD_READ_RESP_PARAM_POS 88
#define BD_READ_RESP_PARAM 0x7
/* Use of this parameter is not known */
#define LEGACY_RADIO_PARAM_POS 103
#define LEGACY_RADIO_PARAM_THRESHOLD 0x30
/* Valid caldata in each segment from FW */
#define CALDATA_SIZE_FIRST_SEG 1480
#define CALDATA_SIZE_SECOND_SEG 1536
#define CALDATA_SIZE_THIRD_SEG 1080
uint16_t TLV2_Specific_byte;
unsigned char BDbuffer[MAX_BDF_SIZE];
uint32_t BDbuffer_offset;
uint32_t resp_counter;
uint32_t bd_size;
uint8_t start_capture;
/* Deviceno is the instance id sent from
* Qdart for the radio.
*/
int deviceno;
/* Device id received in the radio's
* radio flash write requests, defaults to 0
*/
int deviceid = 0;
/* This is the remainder after whole 4096 size responses are sent */
uint32_t remaining_bytes ;
uint32_t total_4K_responses;
unsigned char BTsetmacResponse[] = {
0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x38, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xC6, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* Response sent for BDcapture and Flash write Requests */
unsigned char ftm_wlan_tlvRespMsg[] = {
0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x4A, 0x00, 0x00, 0x00,
0x72, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xEA, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x2F
};
#endif /* __FTM_WLAN_WIN_H */

View File

@@ -1,534 +0,0 @@
/*
*Copyright (c) 2017-2019 Qualcomm Technologies, Inc.
*
*All Rights Reserved.
*Confidential and Proprietary - Qualcomm Technologies, Inc.
*/
#include "ftm_dbg.h"
#ifdef WIN_AP_HOST
#include "ftm_wlan_win.h"
#include <string.h>
/*===========================================================================
FUNCTION bt_setmac_flash_write
DESCRIPTION
Write MAC and XTAL to flash region
DEPENDENCIES
NIL
RETURN VALUE
Returns status success or failure
SIDE EFFECTS
NONE
===========================================================================*/
int bt_setmac_flash_write(uint8_t *mac, unsigned int len)
{
int fd;
int offset;
int i;
uint8_t *flashdata;
fd = open(VIRTUAL_FLASH_PARTITION, O_RDWR);
if (fd < 0) {
perror("Could not open flash. Returning without write\n");
return -1;
}
DPRINTF(FTM_DBG_TRACE,"\nNumber of bytes = %d\n",len);
offset = BT_MAC_OFFSET;
lseek(fd, offset, SEEK_SET);
if (write(fd, mac, len) < 1) {
DPRINTF(FTM_DBG_TRACE,"flash write error. Returning\n");
close(fd);
return -1;
}
DPRINTF(FTM_DBG_TRACE,
"BT mac written successfully to flash @ offset %X size %X\n",
offset, len);
flashdata = (uint8_t *)malloc(len);
if (!flashdata){
DPRINTF(FTM_DBG_TRACE, "Write verification failed. Unable to allocate memory.\n");
close(fd);
return -1;
}
lseek(fd, offset, SEEK_SET);
if (read(fd, flashdata, len) < 1){
DPRINTF(FTM_DBG_TRACE, "Flashdata read failed\n");
free(flashdata);
return -1;
}
for(i = 0; i < len; i++){
DPRINTF(FTM_DBG_TRACE, "input mac = 0x%x, flashdata = 0x%x\n", mac[i], flashdata[i]);
}
free(flashdata);
close(fd);
return 1;
}
/*===========================================================================
FUNCTION win_bt_mac_flash_write
DESCRIPTION
Call bt_setmac_flash_write function and populate response to Qdart
DEPENDENCIES
NIL
RETURN VALUE
Returns resp to qdart
SIDE EFFECTS
NONE
===========================================================================*/
ftm_wlan_rsp_pkt_type *win_bt_mac_flash_write(ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len)
{
int i;
int status;
ftm_wlan_rsp_pkt_type *rsp;
unsigned char BtDiagMAC[MAC_XTAL_LENGTH];
unsigned int dataLen = 0;
uint8_t *input_msg = (uint8_t*)wlan_ftm_pkt;
TLV2_Specific_byte = wlan_ftm_pkt->cmd.common_ops.rsvd;
dataLen = input_msg[MAC_LENGTH_POS];
for(i=0; i<dataLen; i++)
BtDiagMAC[i]= input_msg[MAC_POS + i];
rsp = (ftm_wlan_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM,
FTM_WLAN_CMD_CODE,
(sizeof(rsp->common_header) +
sizeof(rsp->cmd.common_ops)+
BT_TLV1_RESP_LEN ));
if (!rsp)
return rsp;
rsp->common_header.cmd_rsp_pkt_size = BT_RESP_LEN;
rsp->common_header.cmd_data_len = 0;
rsp->cmd.win_resp.data_len = BT_TLV1_RESP_LEN;
rsp->cmd.win_resp.win_cmd_specific = TLV2_Specific_byte;
status = bt_setmac_flash_write(BtDiagMAC, dataLen);
if (status > 0) {
memcpy(rsp->cmd.win_resp.data, BTsetmacResponse, BT_TLV1_RESP_LEN);
DPRINTF(FTM_DBG_TRACE,"Response sent to Qdart\n");
/*print_uchar_array((uint8_t*)(rsp->cmd.win_resp.data), BT_TLV1_RESP_LEN);*/
return rsp;
}
else
return rsp;
}
/*===========================================================================
FUNCTION win_host_handle_bdf_req
DESCRIPTION
Function to process WIN specific bdf requests.
This handles the requests related to device identify,
boarddata capture and flash write requests, and sends
the response to QDART.
DEPENDENCIES
NIL
RETURN VALUE
Returns back buffer that is meant for diag callback
SIDE EFFECTS
NONE
===========================================================================*/
ftm_wlan_rsp_pkt_type *win_host_handle_bdf_req(ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len)
{
uint8_t *input_msg = (uint8_t*)wlan_ftm_pkt;
int error = 0;
int fd;
int file_offset = 0;
int art_slot_id;
ftm_wlan_rsp_pkt_type *rsp;
deviceno = wlan_ftm_pkt->cmd.common_ops.wlandeviceno;
art_slot_id = wlan_ftm_pkt->cmd.common_ops.wlanslotno;
TLV2_Specific_byte = wlan_ftm_pkt->cmd.common_ops.rsvd;
rsp = (ftm_wlan_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM,
FTM_WLAN_CMD_CODE,
(sizeof(rsp->common_header) +
sizeof(rsp->cmd.common_ops)+
TLV1_RESP_LEN));
if (rsp == NULL) {
DPRINTF(FTM_DBG_ERROR, "Failed to allocate Diag packet: %p\n", rsp);
return rsp;
}
rsp->cmd.win_resp.win_cmd_specific = htole16(TLV2_Specific_byte);
rsp->common_header.cmd_rsp_pkt_size = htole16(TLV1_CMD_RESP_SIZE);
rsp->common_header.cmd_data_len = 0;
rsp->cmd.win_resp.data_len = htole16(TLV1_RESP_LEN);
rsp->cmd.win_resp.rsvd = 0;
rsp->cmd.win_resp.wlandeviceno = deviceno;
DPRINTF(FTM_DBG_TRACE, "Received FTM daemon specific TLV\n");
/* Byte 80 in request signifies type of request, 101 is used for BD capture*/
if(input_msg[TLV_PAYLOAD_PARAM_1] == BD_CAPTURE_REQ) {
DPRINTF(FTM_DBG_TRACE, "BOARD_DATA_CAPTURE\n");
if (input_msg[TLV_PAYLOAD_PARAM_2] == 1) {
setBoardDataCaptureFlag(1);
} else if (input_msg[TLV_PAYLOAD_PARAM_2] == 0) {
setBoardDataCaptureFlag(0);
}
} else if (input_msg[TLV_PAYLOAD_PARAM_1] == FLASH_WRITE_REQ) {
fd = open(VIRTUAL_FLASH_PARTITION, O_RDWR);
if (fd < 0) {
DPRINTF(FTM_DBG_TRACE, "FILE OPEN FAILED\n");
error = WLAN_BDF_FILE_OPEN_FAIL;
} else {
DPRINTF(FTM_DBG_TRACE, "FILE OPEN SUCCESSFULL\n");
if (access("/tmp/ftm.conf", F_OK) == 0) {
if (art_slot_id == 0) {
file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_0;
} else if (art_slot_id == 1) {
file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_0 + (ftm_cfg.slot_size[0] * 1024);
} else if (art_slot_id == 2) {
file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_0 +
((ftm_cfg.slot_size[0] + ftm_cfg.slot_size[1]) * 1024);
} else if (art_slot_id == 3) {
file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_0 +
((ftm_cfg.slot_size[0] + ftm_cfg.slot_size[1] +
ftm_cfg.slot_size[2]) * 1024);
}
} else if (!deviceid) {
if (art_slot_id > MAX_ART_SLOTS) {
close(fd);
return rsp;
}
file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_0 +
(art_slot_id * CALDATA_SEG_SIZE);
} else if (deviceid == QC9887_DEVICE_ID ||
deviceid == QC9888_DEVICE_ID) {
file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_1;
} else if (deviceid == QC99xx_DEVICE_ID) {
file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_1;
} else if (deviceid == QCN9000_DEVICE_ID) {
if (art_slot_id == 1)
file_offset = FLASH_BASE_CALDATA_OFFSET_PCI_1;
else if (art_slot_id == 2)
file_offset = FLASH_BASE_CALDATA_OFFSET_PCI_2;
else {
close(fd);
return rsp;
}
} else {
DPRINTF(FTM_DBG_TRACE, "%s:%d - Invalid Device ID %d\n",
__func__, __LINE__, deviceid);
close(fd);
return rsp;
}
lseek(fd, file_offset, SEEK_SET);
if (write(fd, BDbuffer , BDbuffer_offset) < 1) {
DPRINTF(FTM_DBG_TRACE, "%s:%d - Flash write error\n",
__func__, __LINE__);
error = WLAN_BDF_WRITE_FAILED;
close(fd);
} else {
fsync(fd);
close(fd);
system(WRITE_ART);
DPRINTF(FTM_DBG_INFO,
"Flash commit success @ offset %0x Size %d\n",
file_offset, BDbuffer_offset);
}
}
} else if (input_msg[TLV_PAYLOAD_PARAM_1] == DEVICE_IDENTIFY) {
DPRINTF(FTM_DBG_TRACE, "Device Identify \n");
setDeviceId(input_msg[TLV_PAYLOAD_PARAM_2]);
}
if (error!=NO_ERROR)
/* These commands will not go to firmware */
return rsp;
else {
memcpy(rsp->cmd.win_resp.data, ftm_wlan_tlvRespMsg, TLV1_RESP_LEN);
return rsp;
}
}
/*===========================================================================
FUNCTION setBordDataCaptureFlag
DESCRIPTION
Sets the BDCapture variable
DEPENDENCIES
NIL
RETURN VALUE
NONE
SIDE EFFECTS
NONE
===========================================================================*/
void setBoardDataCaptureFlag (int flag)
{
DPRINTF(FTM_DBG_TRACE, "Setting BDCapture flag to %d\n", flag);
if (flag == 1) {
BDbuffer_offset = 0;
resp_counter = 0;
start_capture = 1;
}
// when board data capture is turned off, set the device id to 0
if (flag == 0){
start_capture = 0;
setDeviceId(0);
}
}
/*===========================================================================
FUNCTION setDeviceId
DESCRIPTION
Sets the global variable device id, upon requests
according to the parameter 2 of the TLV command
DEPENDENCIES
NIL
RETURN VALUE
NONE
SIDE EFFECTS
NONE
============================================================================*/
void setDeviceId(int id)
{
DPRINTF(FTM_DBG_TRACE, "Setting Device id to %d\n", id);
deviceid = id;
}
#define BD_SIZE_SIGNATURE_POS 32
#define BD_SIZE_SIGNATURE 1147011573
uint8_t ftm_check_bdf_sizereq_signature(uint8_t *data)
{
uint8_t ret = 0;
uint32_t signature = 0;
le_to_cpu32(((uint8_t *)data + BD_SIZE_SIGNATURE_POS), signature);
if (signature == BD_SIZE_SIGNATURE)
ret = 1;
return ret;
}
/*===========================================================================
FUNCTION win_host_handle_fw_resp
DESCRIPTION
WIN specific handler for responses from FW.
FW responses for board data are snooped here
and stored in a global buffer which is then
accessed by the WIN request handler for flash
write requests.
DEPENDENCIES
NIL
RETURN VALUE
0 on success
1 on failure
SIDE EFFECTS
NONE
===========================================================================*/
void win_host_handle_fw_resp (ftm_wlan_rsp_pkt_type *rsp, void *data, uint32_t data_len)
{
uint32_t sequence_id;
int legacy_dataSize;
if (!rsp || !data || !data_len) {
DPRINTF(FTM_DBG_ERROR, "rsp/data is NULL\n");
rsp = NULL;
return;
}
rsp->cmd.win_resp.win_cmd_specific = htole16(TLV2_Specific_byte);
rsp->common_header.cmd_rsp_pkt_size = htole16(data_len + DIAG_HDR_LEN);
rsp->cmd.win_resp.data_len = htole16(data_len);
rsp->cmd.win_resp.wlandeviceno = deviceno;
rsp->cmd.win_resp.rsvd = 0;
memcpy(rsp->cmd.win_resp.data, data, data_len);
/*TODO: Need better identification method for BDF responses*/
/* Check if the deviceid is set */
switch (deviceid) {
/* DeviceId is 0 for HK and lithium family targets */
case 0:
{ /* Check if request is for BD_get size. */
if (((uint8_t *)data)[BD_SIZE_REQ_POS] == BD_SIZE_REQ_ID &&
ftm_check_bdf_sizereq_signature(data)) {
bd_size = 0 ;
BDbuffer_offset = 0;
resp_counter = 0;
le_to_cpu32(((uint8_t *)data + BD_SIZE_VAL), bd_size);
DPRINTF(FTM_DBG_INFO, "bd_size = %d \n", bd_size);
total_4K_responses = bd_size / REQ_SEG_SIZE;
remaining_bytes = bd_size % REQ_SEG_SIZE;
DPRINTF(FTM_DBG_INFO, "Total_responses= %d \n",
total_4K_responses);
DPRINTF(FTM_DBG_INFO, "Remaining_bytes = %d \n",
remaining_bytes);
}
if (data_len > BD_LEN_EXPECTED && start_capture == 1) {
sequence_id = ((uint8_t *)data)[SEQUENCE_ID_POS];
DPRINTF(FTM_DBG_INFO, "Sequence_ID= %d\n", sequence_id);
if (sequence_id == FIRST_SEG)
resp_counter ++;
DPRINTF(FTM_DBG_INFO, "Response counter == %d\n",
resp_counter);
DPRINTF(FTM_DBG_INFO, "Buffer offset == %d\n",
BDbuffer_offset);
if (resp_counter < total_4K_responses + 1) {
/* Handle 3 segments of BDF resonses
* 1st segment - BDF is from offset 84
* 2nd segment - BDF is from offset 28
* 3rd segment - BDF is from offset 28
*/
switch (sequence_id) {
case FIRST_SEG:
memcpy(BDbuffer + BDbuffer_offset,
(void *)((uint8_t*)data + FIRST_SEG_TLV_HDR),
data_len - FIRST_SEG_TLV_HDR);
BDbuffer_offset += (data_len - FIRST_SEG_TLV_HDR);
break;
case SECOND_SEG:
memcpy(BDbuffer + BDbuffer_offset,
(void *)((uint8_t *)data + SECOND_SEG_TLV_HDR),
data_len - SECOND_SEG_TLV_HDR);
BDbuffer_offset += (data_len - SECOND_SEG_TLV_HDR);
break;
case THIRD_SEG:
memcpy(BDbuffer + BDbuffer_offset,
(void *)((uint8_t*)data + THIRD_SEG_TLV_HDR),
data_len - THIRD_SEG_TLV_HDR);
BDbuffer_offset += (data_len - THIRD_SEG_TLV_HDR);
break;
default:
/* error */
break;
}
/* In case of total bdf data size not being a multiple
* of 4k, extra remaining bdf data is handled based on
* which segment of 4k it belongs to.
*/
} else {
switch (sequence_id) {
case FIRST_SEG:
if (remaining_bytes < CALDATA_SIZE_FIRST_SEG) {
memcpy(BDbuffer + BDbuffer_offset,
data + FIRST_SEG_TLV_HDR,
remaining_bytes);
BDbuffer_offset += remaining_bytes;
} else {
memcpy(BDbuffer + BDbuffer_offset,
data + FIRST_SEG_TLV_HDR,
data_len - FIRST_SEG_TLV_HDR);
BDbuffer_offset += (data_len - FIRST_SEG_TLV_HDR);
remaining_bytes -= CALDATA_SIZE_FIRST_SEG;
}
break;
case SECOND_SEG:
if (remaining_bytes < CALDATA_SIZE_SECOND_SEG) {
memcpy(BDbuffer + BDbuffer_offset,
data + SECOND_SEG_TLV_HDR,
remaining_bytes);
BDbuffer_offset += remaining_bytes;
} else {
memcpy(BDbuffer + BDbuffer_offset,
data + SECOND_SEG_TLV_HDR,
data_len - SECOND_SEG_TLV_HDR);
BDbuffer_offset += (data_len - SECOND_SEG_TLV_HDR);
remaining_bytes -= CALDATA_SIZE_SECOND_SEG;
}
break;
case THIRD_SEG:
memcpy(BDbuffer + BDbuffer_offset,
(void *)((uint8_t*)data + THIRD_SEG_TLV_HDR),
remaining_bytes);
BDbuffer_offset += remaining_bytes;
break;
}
}
}
break;
}
case QC9887_DEVICE_ID:
case QC9888_DEVICE_ID:
{
if ((((uint8_t *)data)[BD_READ_CMD_ID_POS] == M_EEEPROM_BLOCK_READ_ID_QC98XX) &&
(((uint8_t *)data)[BD_READ_RESP_PARAM_POS] == BD_READ_RESP_PARAM)){
le_to_cpu32(((uint8_t *)data + QC98XX_BLOCK_SIZE_VAL),
legacy_dataSize);
DPRINTF(FTM_DBG_TRACE,
"Capturing Caldata for QC98xx by FTM :: Size %d\n",
legacy_dataSize);
DPRINTF(FTM_DBG_TRACE,
"BDbuffer Offset : %d \n",
(resp_counter * QC98XX_BLOCK_SIZE));
memcpy(BDbuffer + BDbuffer_offset, (void *)((uint8_t *)data +
QC98XX_BLOCK_START_POS),
legacy_dataSize);
resp_counter = resp_counter + 1;
BDbuffer_offset += legacy_dataSize;
}
break;
}
case QC99xx_DEVICE_ID:
{
if ((((uint8_t *)data)[BD_READ_CMD_ID_POS] == M_EEEPROM_BLOCK_READ_ID_LEGACY) &&
(((uint8_t *)data)[BD_READ_RESP_PARAM_POS] == BD_READ_RESP_PARAM) &&
((uint8_t *)data)[LEGACY_RADIO_PARAM_POS] < LEGACY_RADIO_PARAM_THRESHOLD) {
le_to_cpu16(((uint8_t *)data + LEGACY_BLOCK_SIZE_VAL), legacy_dataSize);
DPRINTF(FTM_DBG_TRACE,
"Capturing Caldata by FTM :: Size %d\n",
legacy_dataSize);
DPRINTF(FTM_DBG_TRACE,
"BDbuffer Offset : %d \n",
(resp_counter * BD_BLOCK_SIZE));
memcpy(BDbuffer + BDbuffer_offset,
(void *)((uint8_t *)data + LEGACY_BLOCK_START_POS),
legacy_dataSize);
resp_counter = resp_counter + 1;
BDbuffer_offset+=legacy_dataSize;
}
break;
}
}
}
#endif

View File

@@ -1,159 +0,0 @@
/*==========================================================================
TCMD header File
# Copyright (c) 2011, 2013-2014 by Qualcomm Technologies, Inc.
# All Rights Reserved.
# Qualcomm Technologies Proprietary and Confidential.
===========================================================================*/
/*===========================================================================
*/
/*
* Copyright (c) 2006 Atheros Communications Inc.
* All rights reserved.
*
*
// The software source and binaries included in this development package are
// licensed, not sold. You, or your company, received the package under one
// or more license agreements. The rights granted to you are specifically
// listed in these license agreement(s). All other rights remain with Atheros
// Communications, Inc., its subsidiaries, or the respective owner including
// those listed on the included copyright notices. Distribution of any
// portion of this package must be in strict compliance with the license
// agreement(s) terms.
// </copyright>
//
//
*
*/
#ifndef TESTCMD_H_
#define TESTCMD_H_
#include <stdint.h>
#ifdef AR6002_REV2
#define TCMD_MAX_RATES 12
#else
#define TCMD_MAX_RATES 28
#endif
#define PREPACK
#define POSTPACK __attribute__ ((packed))
#define ATH_MAC_LEN 6
#define TC_CMDS_SIZE_MAX 256
/* Continuous Rx
act: TCMD_CONT_RX_PROMIS - promiscuous mode (accept all incoming frames)
TCMD_CONT_RX_FILTER - filter mode (accept only frames with dest
address equal specified
mac address (set via act =3)
TCMD_CONT_RX_REPORT off mode (disable cont rx mode and get the
report from the last cont
Rx test)
TCMD_CONT_RX_SETMAC - set MacAddr mode (sets the MAC address for the
target. This Overrides
the default MAC address.)
*/
typedef enum {
TCMD_CONT_RX_PROMIS = 0,
TCMD_CONT_RX_FILTER,
TCMD_CONT_RX_REPORT,
TCMD_CONT_RX_SETMAC,
TCMD_CONT_RX_SET_ANT_SWITCH_TABLE,
TC_CMD_RESP,
TCMD_CONT_RX_GETMAC,
} TCMD_CONT_RX_ACT;
typedef PREPACK struct {
uint32_t testCmdId;
uint32_t act;
uint32_t enANI;
PREPACK union {
struct PREPACK TCMD_CONT_RX_PARA {
uint32_t freq;
uint32_t antenna;
uint32_t wlanMode;
} POSTPACK para;
struct PREPACK TCMD_CONT_RX_REPORT {
uint32_t totalPkt;
int32_t rssiInDBm;
uint32_t crcErrPkt;
uint32_t secErrPkt;
uint16_t rateCnt[TCMD_MAX_RATES];
uint16_t rateCntShortGuard[TCMD_MAX_RATES];
} POSTPACK report;
struct PREPACK TCMD_CONT_RX_MAC {
char addr[ATH_MAC_LEN];
char btaddr[ATH_MAC_LEN];
uint16_t regDmn[2];
uint32_t otpWriteFlag;
} POSTPACK mac;
struct PREPACK TCMD_CONT_RX_ANT_SWITCH_TABLE {
uint32_t antswitch1;
uint32_t antswitch2;
} POSTPACK antswitchtable;
} POSTPACK u;
} POSTPACK TCMD_CONT_RX;
typedef enum {
TC_CMDS_TS =0,
TC_CMDS_CAL,
TC_CMDS_TPCCAL = TC_CMDS_CAL,
TC_CMDS_TPCCAL_WITH_OTPWRITE,
TC_CMDS_OTPDUMP,
TC_CMDS_OTPSTREAMWRITE,
TC_CMDS_EFUSEDUMP,
TC_CMDS_EFUSEWRITE,
TC_CMDS_READTHERMAL,
} TC_CMDS_ACT;
typedef PREPACK struct {
uint32_t testCmdId;
uint32_t act;
PREPACK union {
uint32_t enANI; // to be identical to CONT_RX struct
struct PREPACK {
uint16_t length;
uint8_t version;
uint8_t bufLen;
} POSTPACK parm;
} POSTPACK u;
} POSTPACK TC_CMDS_HDR;
typedef PREPACK struct {
TC_CMDS_HDR hdr;
char buf[TC_CMDS_SIZE_MAX];
} POSTPACK TC_CMDS;
typedef enum {
TCMD_CONT_TX_ID,
TCMD_CONT_RX_ID,
TCMD_PM_ID,
TC_CMDS_ID,
TCMD_SET_REG_ID,
TC_CMD_TLV_ID,
OP_GENERIC_NART_CMD = 8,
/*For synergy purpose we added the following tcmd id but these
tcmd's will not go to the firmware instead we will write values
to the NV area */
TCMD_NIC_MAC = 100,
TCMD_CAL_FILE_INDEX = 101,
TCMD_LOAD_DRIVER = 102,
TCMD_SET_MAC_ADDR = 198,
} TCMD_ID;
#ifdef __cplusplus
}
#endif
#endif /* TESTCMD_H_ */

View File

@@ -1,45 +0,0 @@
ifeq ($(call is-vendor-board-platform,QCOM),true)
ifeq ($(findstring true, $(BOARD_HAVE_QCOM_FM) $(BOARD_HAVE_BLUETOOTH)),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
BDROID_DIR:= system/bt
ifeq ($(TARGET_SUPPORTS_WEARABLES),true)
QTI_DIR := hardware/qcom/bt/msm8909/libbt-vendor
else
QTI_DIR := hardware/qcom/bt/libbt-vendor
endif
LOCAL_C_INCLUDES := $(TARGET_OUT_HEADERS)/common/inc
LOCAL_C_INCLUDES += $(BDROID_DIR)/hci/include
LOCAL_C_INCLUDES += $(QTI_DIR)/include
ifeq ($(TARGET_SUPPORTS_WEARABLES),true)
LOCAL_C_INCLUDES += device/qcom/msm8909w/opensource/bluetooth/tools/hidl_client/inc
else
LOCAL_C_INCLUDES += vendor/qcom/opensource/bluetooth/tools/hidl_client/inc
endif
LOCAL_CFLAGS := -DANDROID
ifneq ($(BOARD_ANT_WIRELESS_DEVICE), )
LOCAL_CFLAGS += -DCONFIG_ANT
endif
LOCAL_SRC_FILES := wds_main.c
LOCAL_SRC_FILES += wds_hci_pfal_linux.c
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES)
LOCAL_MODULE := wdsdaemon
ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
LOCAL_PROPRIETARY_MODULE := true
endif
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libdiag
LOCAL_SHARED_LIBRARIES += libcutils \
libdl \
libbt-hidlclient
include $(BUILD_EXECUTABLE)
endif # filter
endif # is-vendor-board-platform

View File

@@ -1,170 +0,0 @@
/*
* Copyright (c) 2016 Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*
* Copyright (c) 2012 by Qualcomm Atheros, Inc..
* All Rights Reserved.
* Qualcomm Atheros Confidential and Proprietary.
*/
#ifndef DEBUG
#define DEBUG printf
#endif
#ifndef ERROR
#define ERROR printf
#endif
#include "bt_vendor_qcom.h"
/* error codes */
enum {
STATUS_SUCCESS,
STATUS_ERROR,
STATUS_INVALID_LENGTH,
STATUS_NO_MEMORY,
STATUS_NULL_POINTER,
STATUS_CLIENT_ERROR,
};
enum {
RX_ERROR = -1,
RX_BT_EVT_IND = 1,
RX_BT_HDR,
RX_BT_DATA,
RX_ANT_HDR,
RX_ANT_DATA,
RX_FM_EVT_IND,
RX_FM_HDR,
RX_FM_DATA,
RX_PKT_IND
};
enum pkt_type {
BT_PKT_TYPE = 1,
FM_PKT_TYPE,
ANT_PKT_TYPE
};
/* device to communicate between PC and DUT */
#define BT_HS_NMEA_DEVICE "/dev/ttyGS0"
#define BT_HSLITE_UART_DEVICE "/dev/ttyHSL0"
/* interface between PC-DUT */
typedef struct pc_uart_interafce {
unsigned char *intf;
int uart_fd;
} pc_uart_interface;
typedef union pc_interface {
pc_uart_interface uart;
} pc_interface;
/* device to communicate between DUT and BTSOC */
#define APPS_RIVA_FM_CMD_CH "/dev/smd1"
#define APPS_RIVA_BT_ACL_CH "/dev/smd2"
#define APPS_RIVA_BT_CMD_CH "/dev/smd3"
#define APPS_RIVA_ANT_CMD "/dev/smd5"
#define APPS_RIVA_ANT_DATA "/dev/smd6"
#define BT_HS_UART_DEVICE "/dev/ttyHS0"
/* SMD interface between DUT-SOC */
typedef struct soc_smd_interface {
unsigned char *fm_cmd;
unsigned char *bt_acl;
unsigned char *bt_cmd;
unsigned char *ant_cmd;
unsigned char *ant_data;
int fm_cmd_fd;
int bt_acl_fd;
int bt_cmd_fd;
int ant_cmd_fd;
int ant_data_fd;
} soc_smd_interface;
/* UART interface between DUT-SOC */
typedef struct soc_uart_interface {
unsigned char *intf;
int uart_fd;
} soc_uart_interface;
typedef union soc_interface {
soc_smd_interface smd;
soc_uart_interface uart;
} soc_interface;
/* context for wdsdaemon */
typedef struct wdsdaemon {
int mode;
int soc_type;
bool pcinit_mask;
pc_interface pc_if;
soc_interface soc_if;
bool is_server_enabled;
int server_socket_fd;
pthread_t soc_rthread;
} wdsdaemon;
/* packet types */
#define PACKET_TYPE_INVALID (0)
#define PACKET_TYPE_BT_CMD (1)
#define PACKET_TYPE_FM_CMD (2)
#define PACKET_TYPE_BT_ACL (3)
#define PACKET_TYPE_ANT_CMD (4)
#define PACKET_TYPE_ANT_DATA (5)
/* operation modes for wdsdaemon */
#define MODE_BT_SMD (0)
#define MODE_FM_SMD (1)
#define MODE_ANT_SMD (2)
#define MODE_ALL_SMD (3)
#define MODE_BT_UART (4)
#define MODE_ANT_UART (5)
#define MODE_FM_UART (6)
/* Bluetooth Header */
#define BT_CMD_PKT_HDR_LEN (2)
#define BT_EVT_PKT_HDR_LEN (2)
#define BT_FM_PKT_UART_HDR_LEN (4)
#define BT_ACL_PKT_HDR_LEN (4)
#define BT_ACL_PKT_UART_HDR_LEN (5)
/* FM Header */
#define FM_CMD_PKT_HDR_LEN (3) //Opcode(2byte) + Param len(1 byte)
#define FM_EVT_PKT_HDR_LEN (2) //Opcode(1 byte) + Param len(1 byte)
/* ANT Header */
#define ANT_CMD_PKT_HDR_LEN (1)
#define ANT_DATA_PKT_HDR_LEN (1)
#define ANT_CMD_DATA_PKT_UART_HDR_LEN (2)
#define BT_EVT_PKT_HDR_LEN_UART (BT_CMD_PKT_HDR_LEN+1)
#define BT_ACL_PKT_HDR_LEN_UART (BT_ACL_PKT_HDR_LEN+1)
/* ANT data packet type */
#define ANT_DATA_TYPE_BROADCAST (0x4E)
#define ANT_DATA_TYPE_ACKNOWLEDGED (0x4F)
#define ANT_DATA_TYPE_BURST (0x50)
#define ANT_DATA_TYPE_ADV_BURST (0x72)
/*Packet Identifiers */
#define BT_CMD_PKT_ID 0x01
#define FM_CMD_PKT_ID 0x11
#define BT_EVT_PKT_ID 0x04
#define FM_EVT_PKT_ID 0x14
#define ANT_CMD_PKT_ID 0x0C
#define ANT_EVT_PKT_ID 0x0C
#define ANT_DATA_PKT_ID 0x0E
#define BT_ACL_DATA_PKT_ID 0x02
#define SMD_BUF_SIZE (9000)
#define UART_BUF_SIZE (9000)
#define PC_TO_SOC (1)
#define SOC_TO_PC (2)
int get_acl_pkt_length(unsigned char, unsigned char);
unsigned short get_pkt_data_len(unsigned char type, unsigned char *buf);
int init_pc_interface(wdsdaemon *wds);
int init_soc_interface(wdsdaemon *wds);
int establish_server_socket(wdsdaemon *wds);

View File

@@ -1,720 +0,0 @@
/*
* Copyright (c) 2016 Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*
* Copyright (c) 2012 by Qualcomm Atheros, Inc..
* All Rights Reserved.
* Qualcomm Atheros Confidential and Proprietary.
*/
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <cutils/sockets.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <sys/select.h>
#include <termios.h>
#include <pthread.h>
#include <stdio.h>
#include "wds_hci_pfal.h"
#include <math.h>
#include <dlfcn.h>
#include <unistd.h>
#include <string.h>
#include "hidl_client.h"
#ifdef ANDROID
#include "bt_vendor_lib.h"
#else
#ifdef BT_SOC_TYPE_ROME
#include "bt_vendor_lib.h"
#endif
#endif
#define SOCKET_NAME "wdssock"
typedef unsigned char uint8;
extern int process_packet_type(wdsdaemon *wds, unsigned char pkt_id,
int *dst_fd, int *len, int dir);
#ifdef ANDROID
extern int soc_type;
#endif
static int find_max(int *arr, int len)
{
int max = arr[0];
int i;
for (i = 1; i < len; i++) {
if (arr[i] > max)
max = arr[i];
}
return max;
}
unsigned short get_pkt_data_len(unsigned char type,
unsigned char *buf)
{
unsigned short len = 0;
switch (type) {
case BT_EVT_PKT_ID:
/* Event packet: 1 byte length */
len = buf[BT_EVT_PKT_HDR_LEN_UART - 1];
break;
case BT_ACL_DATA_PKT_ID:
/* ACL packet: 2 byte length */
len =
(((unsigned short) buf[BT_ACL_PKT_HDR_LEN_UART - 1] << 8) &
0xFF00) | (((unsigned short) buf[BT_ACL_PKT_HDR_LEN_UART - 2])
& 0x00FF);
break;
case BT_CMD_PKT_ID:
len = buf[BT_EVT_PKT_HDR_LEN_UART];
break;
case FM_CMD_PKT_ID:
/* FM Cmd packet param len: 1 byte length */
len = buf[FM_CMD_PKT_HDR_LEN];
break;
case FM_EVT_PKT_ID:
/* FM Evt packet param len: 1 byte length */
len = buf[FM_EVT_PKT_HDR_LEN];
break;
}
return len;
}
static int process_soc_data_to_pc(wdsdaemon *wds, unsigned char *buf_in,
int src_fd)
{
int retval = STATUS_SUCCESS;
ssize_t n_bytes = 0, n_total = 0;
int len = 1, dst_fd = 0, i;
int state = RX_PKT_IND, offset = 0;
unsigned char pkt_ind_to_read = 1;
/* In case of Pronto, we have different channels for CMD and ACL,
* so we don't get packet indicator from SoC.
* Below condition will skip reading packet indicator byte in
* case of Pronto.
*/
if (wds->mode != MODE_BT_UART && wds->mode != MODE_ANT_UART &&
wds->mode != MODE_FM_UART) {
pkt_ind_to_read = 0;
offset++;
}
do {
while (len) {
if (pkt_ind_to_read == 0)
goto dont_read_pkt_ind;
if ((n_bytes = read(src_fd,
(unsigned char *)(&buf_in[offset + n_total]),
len)) > 0) {
n_total += n_bytes;
len -= n_bytes;
if (len)
continue;
dont_read_pkt_ind:
switch(state) {
case RX_PKT_IND:
pkt_ind_to_read = 1;
state = process_packet_type(wds, buf_in[0], &dst_fd, &len,
SOC_TO_PC);
break;
case RX_BT_HDR:
len = get_pkt_data_len(buf_in[0], buf_in);
state = RX_BT_DATA;
break;
case RX_BT_DATA:
len = 0;
break;
case RX_ANT_HDR:
pkt_ind_to_read = 1;
len = buf_in[n_total];
state = RX_ANT_DATA;
break;
case RX_ANT_DATA:
if (buf_in[2] ==
ANT_DATA_TYPE_BROADCAST ||
buf_in[2] ==
ANT_DATA_TYPE_ACKNOWLEDGED ||
buf_in[2] == ANT_DATA_TYPE_BURST ||
buf_in[2] == ANT_DATA_TYPE_ADV_BURST)
buf_in[0] = ANT_DATA_PKT_ID;
else
buf_in[0] = ANT_EVT_PKT_ID;
retval = STATUS_SUCCESS;
break;
case RX_FM_HDR:
len = get_pkt_data_len(buf_in[0], buf_in);
state = RX_FM_DATA;
break;
case RX_FM_DATA:
len = 0;
break;
default:
retval = STATUS_ERROR;
break;
}
} else {
ERROR("%s Failed To read from SoC fd = %d\n",__func__, src_fd);
break;
}
}
if (retval)
break;
n_total += offset;
len = 0;
DEBUG("evt:\t");
for (i = 0; i < n_total; i++)
DEBUG("0x%x\t", buf_in[i]);
DEBUG("\n");
while (n_total) {
if((n_bytes = write(dst_fd, buf_in + len, n_total)) >= 0) {
len += n_bytes;
n_total -= n_bytes;
}
else {
if (wds->is_server_enabled) {
retval = STATUS_CLIENT_ERROR;
ERROR("%s: unable to write to client socket, fd = %d err = %s\n", __func__, dst_fd, strerror(errno));
}
else {
retval = STATUS_ERROR;
ERROR("%s: unable to write to pc_if fd = %d err = %s\n", __func__, dst_fd, strerror(errno));
}
break;
}
}
} while (0);
return retval;
}
static void *process_soc_data(void *arg)
{
int retval = STATUS_ERROR;
fd_set readfds, saved_readfds;
wdsdaemon *wds = (wdsdaemon *) arg;
int max, src_fd = 0, dst_fd = 0;
size_t sz = 0;
unsigned char *buf_in = NULL;
int arr[5], num = 0;
FD_ZERO(&readfds);
FD_ZERO(&saved_readfds);
if (wds->mode == MODE_BT_UART || wds->mode == MODE_ANT_UART ||
wds->mode == MODE_FM_UART) {
FD_SET(wds->soc_if.uart.uart_fd, &saved_readfds);
max = wds->soc_if.uart.uart_fd;
sz = UART_BUF_SIZE * sizeof(unsigned char);
} else {
if (wds->mode == MODE_BT_SMD || wds->mode == MODE_ALL_SMD) {
FD_SET((arr[num] = wds->soc_if.smd.bt_acl_fd), &saved_readfds);num++;
FD_SET((arr[num] = wds->soc_if.smd.bt_cmd_fd), &saved_readfds);num++;
}
if (wds->mode == MODE_ANT_SMD || wds->mode == MODE_ALL_SMD) {
FD_SET((arr[num] = wds->soc_if.smd.ant_cmd_fd), &saved_readfds);num++;
FD_SET((arr[num] = wds->soc_if.smd.ant_data_fd), &saved_readfds);num++;
}
if (wds->mode == MODE_FM_SMD || wds->mode == MODE_ALL_SMD)
FD_SET((arr[num] = wds->soc_if.smd.fm_cmd_fd), &saved_readfds);num++;
max = find_max(arr, num);
sz = SMD_BUF_SIZE * sizeof(unsigned char);
}
buf_in = (unsigned char *) calloc(sz, 1);
if (!buf_in) {
ERROR("Insufficient Memory");
retval = STATUS_NO_MEMORY;
goto failed;
}
do {
readfds = saved_readfds;
retval = select(max + 1, &readfds, NULL, NULL, NULL);
if (retval == -1) {
ERROR("select failed, Error: %s (%d)\n", strerror(errno),
errno);
break;
}
switch (wds->mode) {
case MODE_BT_UART:
case MODE_FM_UART:
case MODE_ANT_UART:
src_fd = wds->soc_if.uart.uart_fd;
if (FD_ISSET(src_fd,&readfds))
retval = process_soc_data_to_pc(wds, buf_in, src_fd);
break;
case MODE_ALL_SMD:
case MODE_BT_SMD:
src_fd = wds->soc_if.smd.bt_cmd_fd;
if (FD_ISSET(src_fd ,&readfds)) {
buf_in[0] = BT_EVT_PKT_ID;
retval = process_soc_data_to_pc(wds, buf_in,src_fd);
}
src_fd = wds->soc_if.smd.bt_acl_fd;
if (FD_ISSET(src_fd ,&readfds)) {
buf_in[0] = BT_ACL_DATA_PKT_ID;
retval = process_soc_data_to_pc(wds, buf_in, src_fd);
}
if (wds->mode == MODE_BT_SMD)
break;
case MODE_FM_SMD:
src_fd = wds->soc_if.smd.fm_cmd_fd;
if (FD_ISSET(src_fd ,&readfds)) {
buf_in[0] = FM_EVT_PKT_ID;
retval = process_soc_data_to_pc(wds, buf_in, src_fd);
}
if (wds->mode == MODE_FM_SMD)
break;
break;
case MODE_ANT_SMD:
src_fd = wds->soc_if.smd.ant_cmd_fd;
if (FD_ISSET(src_fd, &readfds)) {
buf_in[0] = ANT_EVT_PKT_ID;
retval = process_soc_data_to_pc(wds, buf_in, src_fd);
}
src_fd = wds->soc_if.smd.ant_data_fd;
if (FD_ISSET(src_fd ,&readfds)) {
buf_in[0] = ANT_DATA_PKT_ID;
retval = process_soc_data_to_pc(wds, buf_in, src_fd);
}
break;
}
if (STATUS_SUCCESS != retval) {
if (retval == STATUS_CLIENT_ERROR) {
ERROR("Write to client failed\n");
continue;
}
ERROR("Failed to process SOC data\n");
break;
}
} while(1);
failed:
ERROR("\nReader thread exited\n");
if (buf_in) {
free(buf_in);
buf_in = NULL;
}
return 0;
}
static int set_port_raw_mode(int fd)
{
struct termios term;
int ret = STATUS_SUCCESS;
if (tcgetattr(fd, &term) < 0) {
ERROR("Failed to get attributes");
ERROR("Error: %s (%d)", strerror(errno), errno);
return STATUS_ERROR;
}
cfmakeraw(&term);
if (tcsetattr(fd, TCSANOW, &term) < 0) {
ERROR("Failed to set attributes");
ERROR("Error: %s (%d)", strerror(errno), errno);
return STATUS_ERROR;
}
if (tcflush(fd, TCIFLUSH) < 0) {
ERROR("Failed to flush port");
ERROR("Error: %s (%d)", strerror(errno), errno);
return STATUS_ERROR;
}
return ret;
}
/*===========================================================================
FUNCTION port_init_libbt
DESCRIPTION
Initilize port and open the file through libbt-vendor
DEPENDENCIES
NIL
RETURN VALUE
RETURN fd handle
SIDE EFFECTS
None
===========================================================================*/
#ifndef BT_BLUEZ
static int port_init_libbt(uint8 option)
{
int fd_array[CH_MAX];
bt_vendor_callbacks_t cb;
uint8_t init_bd_addr[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
bt_vendor_interface_t * p_btf = NULL;
bt_vendor_opcode_t opCmd1, opCmd2;
int iState;
void* vendor_handle = dlopen("libbt-vendor.so", RTLD_NOW);
if(!vendor_handle){
ERROR("Error open libbt-vendor \n");
return -1;
}
p_btf = (bt_vendor_interface_t *)dlsym(vendor_handle,
"BLUETOOTH_VENDOR_LIB_INTERFACE");
if(!p_btf){
ERROR("Failed obtain the address of libbt-vendor \n");
return -1;
}
if (p_btf->init(&cb, &init_bd_addr[0]) < 0){
ERROR("bt vendor init failed \n");
return -1;
}
switch (option) {
case MODE_BT_UART:
opCmd1 = BT_VND_OP_POWER_CTRL;
opCmd2 = BT_VND_OP_USERIAL_OPEN;
break;
case MODE_FM_UART:
opCmd1 = FM_VND_OP_POWER_CTRL;
opCmd2 = BT_VND_OP_FM_USERIAL_OPEN;
break;
case MODE_ANT_UART:
opCmd1 = BT_VND_OP_POWER_CTRL;
opCmd2 = BT_VND_OP_USERIAL_OPEN;
break;
default:
printf("Invalid option\n");
return -1;
}
iState = BT_VND_PWR_ON;
if (p_btf->op(opCmd1, &iState) < 0){
ERROR("Power on failed \n");
return -1;
}
if (p_btf->op(opCmd2, (void*)fd_array) < 0){
ERROR("op(VND_OP_USERIAL_OPEN) failed \n");
return -1;
}
return fd_array[0];
}
#endif
static int change_baud(int fd, speed_t baud)
{
struct termios term;
int ret = STATUS_SUCCESS; /* assume success */
do {
if (tcgetattr(fd, &term) < 0) {
ERROR("Failed to get attributes");
ret = STATUS_ERROR;
break;
}
cfsetospeed(&term, baud);
/* don't change speed until last write done */
if (tcsetattr(fd, TCSADRAIN, &term) < 0) {
ERROR("Failed to set attribute");
ERROR("Error: %s (%d)", strerror(errno), errno);
ret = STATUS_ERROR;
break;
}
} while(0);
return 0;
}
int init_soc_interface(wdsdaemon *wds)
{
int ret = STATUS_ERROR;
int fd = 0;
struct termios term;
if (!wds) {
ret = STATUS_NULL_POINTER;
ERROR("Invalid input argument\n");
return ret;
}
switch (wds->mode) {
case MODE_FM_UART:
if(hidl_client_initialize(MODE_FM,&fd) == false)
{
ERROR("HIDL client initialization failed");
exit(1);
}
wds->soc_if.uart.uart_fd = fd;
ret = STATUS_SUCCESS;
break;
case MODE_BT_UART:
#ifdef BT_BLUEZ
fd = open(wds->soc_if.uart.intf,
O_RDWR | O_NONBLOCK | O_NOCTTY);
if (-1 == fd) {
ERROR("Failed to open port: %s\n",
wds->soc_if.uart.intf);
ERROR("Error: %s (%d)", strerror(errno), errno);
break;
}
if (tcflush(fd, TCIOFLUSH) < 0) {
ERROR("Failed to flush port: %s\n",
wds->soc_if.uart.intf);
ERROR("Error: %s (%d)", strerror(errno), errno);
close(fd);
break;
}
if (tcgetattr(fd, &term) < 0) {
ERROR("Failed to get attributes for port: %s\n",
wds->soc_if.uart.intf);
ERROR("Error: %s (%d)", strerror(errno), errno);
close(fd);
break;
}
cfmakeraw(&term);
/* enable flow control */
term.c_cflag |= (CRTSCTS | CLOCAL);
if (tcsetattr(fd, TCSANOW, &term) < 0) {
ERROR("Failed to set attributes for port: %s\n",
wds->soc_if.uart.intf);
ERROR("Error: %s (%d)", strerror(errno), errno);
close(fd);
break;
}
if (STATUS_SUCCESS != change_baud(fd, B3000000)) { //TODO:set baud rate
ERROR("Failed to change baud rate\n");
close(fd);
break;
}
#else
if(hidl_client_initialize(MODE_BT,&fd) == false)
{
ERROR("HIDL client initialization failed");
exit(1);
}
#endif
/* everything okay */
wds->soc_if.uart.uart_fd = fd;
ret = STATUS_SUCCESS;
break;
case MODE_ANT_UART:
#ifndef BT_BLUEZ
if(hidl_client_initialize(MODE_ANT,&fd) == true){
wds->soc_if.uart.uart_fd = fd;
}
else {
ERROR("HIDL client initialization failed, opening port with port_init_libbt\n");
wds->soc_if.uart.uart_fd = port_init_libbt(wds->mode);
}
ret = STATUS_SUCCESS;
#endif
break;
case MODE_ALL_SMD:
case MODE_ANT_SMD:
/* ANT commdnas */
fd = open(wds->soc_if.smd.ant_cmd,
O_RDWR | O_NONBLOCK | O_NOCTTY);
if (-1 == fd) {
ERROR("Failed to open port: %s\n",
wds->soc_if.smd.ant_cmd);
ERROR("Error: %s (%d)\n", strerror(errno),
errno);
break;
}
set_port_raw_mode(fd);
wds->soc_if.smd.ant_cmd_fd = fd;
/* ANT data */
fd = open(wds->soc_if.smd.ant_data,
O_RDWR | O_NONBLOCK | O_NOCTTY);
if (-1 == fd) {
ERROR("Failed to open port: %s\n",
wds->soc_if.smd.ant_data);
ERROR("Error: %s (%d)", strerror(errno),
errno);
break;
}
set_port_raw_mode(fd);
wds->soc_if.smd.ant_data_fd = fd;
if (wds->mode == MODE_ANT_SMD) {
ret = STATUS_SUCCESS;
break;
}
/* fallthrough intentional for MODE_ALL_SMD */
case MODE_BT_SMD:
/* BT commdnas */
fd = open(wds->soc_if.smd.bt_cmd,
O_RDWR | O_NONBLOCK | O_NOCTTY);
if (-1 == fd) {
ERROR("Failed to open port: %s\n",
wds->soc_if.smd.bt_cmd_fd);
ERROR("Error: %s (%d)\n",
strerror(errno), errno);
break;
}
set_port_raw_mode(fd);
wds->soc_if.smd.bt_cmd_fd = fd;
/* BT ACL */
fd = open(wds->soc_if.smd.bt_acl,
O_RDWR | O_NONBLOCK | O_NOCTTY);
if (-1 == fd) {
ERROR("Failed to open port: %s\n",
wds->soc_if.smd.bt_acl);
ERROR("Error: %s (%d)\n",
strerror(errno), errno);
break;
}
set_port_raw_mode(fd);
wds->soc_if.smd.bt_acl_fd = fd;
if (wds->mode == MODE_BT_SMD) {
ret = STATUS_SUCCESS;
break;
}
/* fallthrough intentional for MODE_ALL_SMD */
case MODE_FM_SMD:
/* FM commdnas */
fd = open(wds->soc_if.smd.fm_cmd, O_RDWR | O_NONBLOCK | O_NOCTTY);
if (-1 == fd) {
ERROR("Failed to open port: %s\n",
wds->soc_if.smd.fm_cmd_fd);
ERROR("Error: %s (%d)\n",
strerror(errno), errno);
break;
}
set_port_raw_mode(fd);
wds->soc_if.smd.fm_cmd_fd = fd;
ret = STATUS_SUCCESS;
break;
}
if (ret == STATUS_SUCCESS)
if (pthread_create(&wds->soc_rthread, NULL, process_soc_data,
wds) != 0) {
ERROR("%s:Unable to create pthread err = %s\n", __func__,
strerror(errno));
close(fd);
ret = STATUS_ERROR;
}
failed:
return ret;
}
int init_pc_interface(wdsdaemon *wds)
{
int fd = 0;
int ret = STATUS_ERROR;
struct termios term;
if (!wds) {
ret = STATUS_NULL_POINTER;
ERROR("Invalid input argument");
return ret;
}
do {
fd = open(wds->pc_if.uart.intf, O_RDWR);
if (-1 == fd) {
ERROR("Unable to open port: %s", wds->pc_if.uart.intf);
ERROR("Error: %s (%d)", strerror(errno), errno);
ret = STATUS_ERROR;
break;
}
/* set terminal properties */
if (tcgetattr(fd, &term) < 0) {
ERROR("Failed to get attributes of port: %s",
wds->pc_if.uart.intf);
ERROR("Error: %s (%d)", strerror(errno), errno);
close(fd);
ret = STATUS_ERROR;
break;
}
cfmakeraw(&term);
term.c_lflag = term.c_lflag & ((tcflag_t)(~ECHO));
/* TODO: Make baud rate command line argument */
cfsetospeed(&term, B115200);
cfsetispeed(&term, B115200);
if (tcsetattr(fd, TCSANOW, &term) < 0) {
ERROR("Failed to set attributes of port: %s",
wds->pc_if.uart.intf);
ERROR("Error: %s (%d)", strerror(errno), errno);
close(fd);
ret = STATUS_ERROR;
break;
}
tcflush(fd, TCIOFLUSH);
/* everything okay, set success */
wds->pc_if.uart.uart_fd = fd;
ret = STATUS_SUCCESS;
} while(0);
return ret;
}
int establish_server_socket(wdsdaemon *wds)
{
int fd = -1;
struct sockaddr_un client_address;
socklen_t clen;
int sock_id, ret = STATUS_ERROR;
DEBUG("%s(%s) Entry \n", __func__, SOCKET_NAME);
if (!wds) {
ret = STATUS_NULL_POINTER;
ERROR("Invalid input argument\n");
return ret;
}
sock_id = socket(AF_LOCAL, SOCK_STREAM, 0);
if (sock_id < 0) {
ERROR("%s: server Socket creation failure\n", __func__);
return ret;
}
DEBUG("convert name to android abstract name:%s %d\n", SOCKET_NAME, sock_id);
if (socket_local_server_bind(sock_id,
SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_ABSTRACT) >= 0) {
if (listen(sock_id, 5) == 0) {
DEBUG("listen to local socket:%s, fd:%d\n", SOCKET_NAME, sock_id);
} else {
ERROR("listen to local socket:failed\n");
close(sock_id);
return ret;
}
} else {
close(sock_id);
ERROR("%s: server bind failed for socket : %s\n", __func__, SOCKET_NAME);
return ret;
}
clen = sizeof(client_address);
DEBUG("%s: before accept_server_socket\n", SOCKET_NAME);
fd = accept(sock_id, (struct sockaddr *)&client_address, &clen);
if (fd > 0) {
DEBUG("%s accepted fd:%d for server fd:%d\n", SOCKET_NAME, fd, sock_id);
close(sock_id);
wds->server_socket_fd = fd;
return STATUS_SUCCESS;
} else {
ERROR("Accept failed fd:%d sock d:%d error %s\n", fd, sock_id, strerror(errno));
close(sock_id);
return ret;
}
}

View File

@@ -1,568 +0,0 @@
/*
* Copyright (c) 2016 Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*
* Copyright (c) 2012 by Qualcomm Atheros, Inc..
* All Rights Reserved.
* Qualcomm Atheros Confidential and Proprietary.
*/
/*
* Description:
* Added wdsdaemon to enable testing of Host Controller Interface (HCI)
* communication with stack layers bypassed.
* 1. Acts as a communication bridge between PC to DUT over UART (/dev/ttyHSL0)
* and also UART transport between DUT and BTSOC (/dev/ttyHS0).
* 2. Used to test exchange of BT-FM HCI commands, events and ACL data packets
* between host and controller.
**/
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdbool.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <cutils/sockets.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <stdlib.h>
#include <sys/time.h>
#include <getopt.h>
#include <strings.h>
#include <termios.h>
#include <math.h>
#include <string.h>
#include <signal.h>
#include "wds_hci_pfal.h"
#include "hidl_client.h"
#ifdef ANDROID
#include <cutils/properties.h>
#endif
/*===========================================================================
FUNCTION get_pkt_type
DESCRIPTION
Routine to get the packet type from the data bytes received
DEPENDENCIES
NIL
RETURN VALUE
Packet type for the data bytes received
SIDE EFFECTS
None
===========================================================================*/
static int get_packet_type(unsigned char id)
{
int type;
switch (id) {
case BT_CMD_PKT_ID:
type = PACKET_TYPE_BT_CMD;
break;
case FM_CMD_PKT_ID:
type = PACKET_TYPE_FM_CMD;
break;
case BT_ACL_DATA_PKT_ID:
type = PACKET_TYPE_BT_ACL;
break;
case ANT_CMD_PKT_ID:
type = PACKET_TYPE_ANT_CMD;
break;
case ANT_DATA_PKT_ID:
type = PACKET_TYPE_ANT_DATA;
break;
default:
type = PACKET_TYPE_INVALID;
}
return type;
}
#ifdef ANDROID
int soc_type;
/** Get Bluetooth SoC type from system setting */
static int get_bt_soc_type()
{
int ret = 0;
char bt_soc_type[PROPERTY_VALUE_MAX];
DEBUG("bt-hci: get_bt_soc_type\n");
ret = property_get("qcom.bluetooth.soc", bt_soc_type, NULL);
if (ret != 0) {
DEBUG("qcom.bluetooth.soc set to %s\n", bt_soc_type);
if (!strncasecmp(bt_soc_type, "rome", sizeof("rome"))) {
return BT_SOC_ROME;
}
else if (!strncasecmp(bt_soc_type, "cherokee", sizeof("cherokee"))) {
return BT_SOC_CHEROKEE;
}
else if (!strncasecmp(bt_soc_type, "ath3k", sizeof("ath3k"))) {
return BT_SOC_AR3K;
}
else if (!strncasecmp(bt_soc_type, "napier", sizeof("napier"))) {
return BT_SOC_NAPIER;
}
else {
DEBUG("qcom.bluetooth.soc not set, so using default.\n");
return BT_SOC_DEFAULT;
}
}
else {
DEBUG("%s: Failed to get soc type\n", __FUNCTION__);
ret = BT_SOC_DEFAULT;
}
return ret;
}
#endif
static int parse_options(wdsdaemon *wds, int argc, char *argv[])
{
int ret = STATUS_SUCCESS;
int opt;
if (argc > 2) {
ERROR("Invalid number of arguments\n");
ret = STATUS_INVALID_LENGTH;
ERROR("Usage %s [-abfunht]", argv[0]);
return ret;
}
if (argc == 1) {
wds->mode = MODE_ALL_SMD;
return ret;
}
while ((opt = getopt(argc, argv, "abfunhstm")) != -1) {
switch (opt) {
case 'a':
DEBUG("Opening ANT SMD channels\n");
wds->mode = MODE_ANT_SMD;
break;
case 'b':
DEBUG("Opening BT SMD channels\n");
wds->mode = MODE_BT_SMD;
break;
case 'f':
DEBUG("Opening FM SMD channels\n");
wds->mode = MODE_FM_SMD;
break;
case 't':
ERROR("Setting mask for pc initialization\n");
wds->pcinit_mask = true;
break;
case 's':
ERROR("Opening WDS server socket\n");
wds->is_server_enabled = true;
wds->pcinit_mask = true;
break;
#ifdef ANDROID
if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE) {
case 'u':
DEBUG("Opening UART BT Channel\n");
wds->mode = MODE_BT_UART;
break;
}
if (soc_type == BT_SOC_CHEROKEE) {
case 'm':
DEBUG("Opening UART FM Channel\n");
wds->mode = MODE_FM_UART;
break;
}
#else
#ifdef BT_SOC_TYPE_ROME
case 'u':
DEBUG("Opening UART BT Channel\n");
wds->mode = MODE_BT_UART;
break;
#endif
#endif
#ifdef CONFIG_ANT
case 'n':
ERROR("Opening ANT UART channels\n");
wds->mode = MODE_ANT_UART;
break;
#endif
case 'h':
DEBUG("By Default, it will open all SMD channels\n");
DEBUG("Use -a for opening only ANT Channels\n");
DEBUG("Use -b for opening only BT Channels\n");
DEBUG("Use -f for opening only FM Channels\n");
#ifdef ANDROID
if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE) {
DEBUG("Use -u for opening only UART Channel for BT (ROME)\n");
}
if (soc_type == BT_SOC_CHEROKEE) {
DEBUG("Use -m for opening only UART Channel for FM\n");
}
#else
#ifdef BT_SOC_TYPE_ROME
DEBUG("Use -u for opening only UART Channel for BT (ROME)\n");
#endif
#endif
#ifdef CONFIG_ANT
DEBUG("Use -n for opening ANT UART channels only\n");
#endif
DEBUG("Use -t for masking pc initialization\n");
DEBUG("Use -s for setting communication via server socket\n");
DEBUG("Use -h to print help\n");
ret = STATUS_ERROR;
break;
default:
DEBUG("Usage %s [-abfunhmst]\n", argv[0]);
ret = STATUS_ERROR;
break;
}
}
return ret;
}
static void wdsdaemon_init(wdsdaemon *wds)
{
/* PC-DUT interface */
#ifdef BT_BLUEZ
wds->pc_if.uart.intf = (unsigned char *)BT_HSLITE_UART_DEVICE;
#else
wds->pc_if.uart.intf = (unsigned char *)BT_HS_NMEA_DEVICE;
#endif
/* DUT-BTSOC interface */
switch (wds->mode) {
case MODE_ALL_SMD:
wds->soc_if.smd.fm_cmd = (unsigned char *)APPS_RIVA_FM_CMD_CH;
wds->soc_if.smd.bt_acl = (unsigned char*)APPS_RIVA_BT_ACL_CH;
wds->soc_if.smd.bt_cmd = (unsigned char *)APPS_RIVA_BT_CMD_CH;
wds->soc_if.smd.ant_cmd = (unsigned char *)APPS_RIVA_ANT_CMD;
wds->soc_if.smd.ant_data = (unsigned char *)APPS_RIVA_ANT_DATA;
break;
case MODE_ANT_SMD:
wds->soc_if.smd.ant_cmd = (unsigned char *)APPS_RIVA_ANT_CMD;
wds->soc_if.smd.ant_data = (unsigned char *)APPS_RIVA_ANT_DATA;
break;
case MODE_BT_SMD:
wds->soc_if.smd.bt_acl = (unsigned char *)APPS_RIVA_BT_ACL_CH;
wds->soc_if.smd.bt_cmd = (unsigned char *)APPS_RIVA_BT_CMD_CH;
break;
case MODE_FM_SMD:
wds->soc_if.smd.fm_cmd = (unsigned char *)APPS_RIVA_FM_CMD_CH;
break;
case MODE_BT_UART:
case MODE_ANT_UART:
wds->soc_if.uart.intf = (unsigned char *)BT_HS_UART_DEVICE;
break;
}
}
int process_packet_type(wdsdaemon *wds, unsigned char pkt_id,
int *dst_fd, int *len, int dir)
{
int state;
switch(pkt_id) {
case BT_CMD_PKT_ID:
*len = BT_EVT_PKT_HDR_LEN_UART;
case BT_EVT_PKT_ID:
case BT_ACL_DATA_PKT_ID:
state = RX_BT_HDR;
if (wds->mode == MODE_BT_UART)
*dst_fd = wds->soc_if.uart.uart_fd;
else
if (pkt_id == BT_CMD_PKT_ID)
*dst_fd = wds->soc_if.smd.bt_cmd_fd;
else
*dst_fd = wds->soc_if.smd.bt_acl_fd;
if (pkt_id == BT_ACL_DATA_PKT_ID)
*len = BT_ACL_PKT_HDR_LEN;
else if (pkt_id == BT_EVT_PKT_ID)
*len = BT_EVT_PKT_HDR_LEN;
break;
case FM_CMD_PKT_ID:
if (wds-> mode == MODE_FM_UART)
*dst_fd = wds->soc_if.uart.uart_fd;
else
*dst_fd = wds->soc_if.smd.fm_cmd_fd;
case FM_EVT_PKT_ID:
state = RX_FM_HDR;
if (pkt_id == FM_CMD_PKT_ID)
*len = FM_CMD_PKT_HDR_LEN;
else if (pkt_id == FM_EVT_PKT_ID)
*len = FM_EVT_PKT_HDR_LEN;
break;
case ANT_CMD_PKT_ID:
case ANT_DATA_PKT_ID:
state = RX_ANT_HDR;
if (wds->mode == MODE_ANT_UART)
*dst_fd = wds->soc_if.uart.uart_fd;
else
if (pkt_id == ANT_CMD_PKT_ID)
*dst_fd = wds->soc_if.smd.ant_cmd_fd;
else
*dst_fd = wds->soc_if.smd.ant_data_fd;
break;
default:
state = RX_ERROR;
break;
}
if (dir == SOC_TO_PC) {
if (wds->is_server_enabled)
*dst_fd = wds->server_socket_fd;
else
*dst_fd = wds->pc_if.uart.uart_fd;
}
return state;
}
static int process_pc_data_to_soc(wdsdaemon *wds, unsigned char *buf, int src_fd)
{
int retval = STATUS_SUCCESS;
int len = 1, n_bytes = 0, n_total = 0;
int pkt_id = 0, dst_fd = 0;
int state = RX_PKT_IND, i;
do {
if ((n_bytes = read(src_fd, (unsigned char *)&buf[n_total], len)) > 0) {
n_total += n_bytes;
len -= n_bytes;
if (len)
continue;
switch(state) {
case RX_PKT_IND:
pkt_id = buf[0];
state = process_packet_type(wds, pkt_id, &dst_fd, &len,
PC_TO_SOC);
break;
case RX_BT_HDR:
len = get_pkt_data_len(pkt_id, buf);
state = RX_BT_DATA;
break;
case RX_ANT_HDR:
len = buf[0];
state = RX_ANT_DATA;
break;
case RX_FM_HDR:
len = get_pkt_data_len(pkt_id, buf);
state = RX_FM_DATA;
break;
case RX_BT_DATA:
case RX_ANT_DATA:
case RX_FM_DATA:
len = 0;
break;
default:
retval = STATUS_ERROR;
break;
}
} else {
ERROR("%s: error while reading from fd = %d err = %s\n",
__func__, src_fd, strerror(errno));
if (n_bytes < 0)
ERROR("%s:read returns err: %d\n", __func__,n_bytes);
if (n_bytes == 0)
ERROR("%s: This indicates the close of other end\n", __func__);
retval = STATUS_ERROR;
break;
}
} while (len);
if(retval)
goto fail;
/* In case of Pronto, for BT, we have different channels for CMD and ACL,
* so we don't send packet indicator to SoC.
* Below condition will skip the packet indicator byte to Soc in\
* case of Pronto.
*/
if (wds->mode != MODE_BT_UART && wds->mode != MODE_ANT_UART &&
wds->mode != MODE_FM_UART) {
n_total -= 1;
len = 1;
}
while(n_total) {
if((n_bytes = write(dst_fd, buf + len, n_total)) > 0) {
len += n_bytes;
n_total -= n_bytes;
} else
ERROR("%s :Error while writeto fd = %d err = %s\n",
__func__, dst_fd, strerror(errno));
break;
}
DEBUG("cmd:\t");
for (i = 0; i < len; i++)
DEBUG("0x%x\t", buf[i]);
DEBUG("\n");
if (n_total)
retval = STATUS_ERROR;
fail:
return retval;
}
static void thread_exit_handler(int signo){
DEBUG("%s: %d",__func__,signo);
}
int server_create(wdsdaemon *wds,int *src_fd) {
int retval = establish_server_socket(wds);
if (STATUS_SUCCESS == retval)
*src_fd = wds->server_socket_fd;
else
ERROR("Failed to init server socket\n");
return retval;
}
int main(int argc, char *argv[])
{
int retval = STATUS_ERROR, src_fd = 0;
fd_set readfds;
wdsdaemon wds;
unsigned char *buf = NULL;
size_t size = UART_BUF_SIZE;
struct sigaction action;
sigset_t sigmask, emptymask;
sigemptyset(&sigmask);
sigaddset(&sigmask, SIGINT);
sigaddset(&sigmask, SIGPIPE);
if (sigprocmask(SIG_BLOCK, &sigmask, NULL) == -1) {
ERROR("failed to sigprocmask");
}
memset(&action, 0, sizeof(struct sigaction));
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
action.sa_handler = thread_exit_handler;
sigemptyset(&emptymask);
if (sigaction(SIGINT, &action, NULL) < 0) {
ERROR("%s:sigaction failed\n", __func__);
}
memset(&wds, 0, sizeof(wdsdaemon));
#ifdef ANDROID
soc_type = get_bt_soc_type();
#endif
/* parse options */
retval = parse_options(&wds, argc, argv);
if (STATUS_SUCCESS != retval) {
goto fail;
}
wdsdaemon_init(&wds);
if(!(wds.pcinit_mask))
{
retval = init_pc_interface(&wds);
if (STATUS_SUCCESS != retval) {
ERROR("Failed to init DUT-PC interface\n");
goto fail;
}
src_fd = wds.pc_if.uart.uart_fd;
}
retval = init_soc_interface(&wds);
if (STATUS_SUCCESS != retval) {
ERROR("Failed to init DUT-BTSOC interface\n");
goto fail;
}
#ifdef BT_BLUEZ
fflush(stdout);
fflush(stderr);
#endif
buf = (unsigned char *)calloc(size, 1);
if (!buf) {
ERROR("%s:Unable to allocate memory\n", __func__);
goto fail;
}
if( wds.is_server_enabled && ( server_create(&wds, &src_fd)!= STATUS_SUCCESS ))
goto fail;
do {
FD_ZERO(&readfds);
FD_SET(src_fd, &readfds);
DEBUG("Waiting for data:\n");
if ((retval = select(src_fd + 1, &readfds, NULL, NULL, NULL)) == -1) {
ERROR("%s:select failed\n", __func__);
if (wds.is_server_enabled)
{
ERROR("%s:closing the server socket and reopening\n", __func__);
close(src_fd);
if(server_create(&wds, &src_fd)== STATUS_SUCCESS)
continue;
}
break;
}
if (FD_ISSET(src_fd, &readfds)) {
retval = process_pc_data_to_soc(&wds, buf, src_fd);
} else
ERROR("%s:src_fd port not set\n",__func__);
if (retval != STATUS_SUCCESS) {
ERROR("%s: Error while processing Data to SoC err = %d\n", __func__, retval);
if (wds.is_server_enabled)
{
ERROR("%s:closing the server socket and reopening\n", __func__);
close(src_fd);
if(server_create(&wds, &src_fd)== STATUS_SUCCESS)
continue;
}
break;
}
}while(1);
fail:
if (buf)
free(buf);
shutdown(src_fd, SHUT_RDWR);
switch (wds.mode) {
case MODE_BT_UART:
case MODE_FM_UART:
case MODE_ANT_UART:
shutdown(wds.soc_if.uart.uart_fd, SHUT_RDWR);
break;
case MODE_ALL_SMD:
case MODE_BT_SMD:
shutdown(wds.soc_if.smd.bt_cmd_fd, SHUT_RDWR);
shutdown(wds.soc_if.smd.bt_acl_fd, SHUT_RDWR);
if(wds.mode == MODE_BT_SMD)
break;
case MODE_FM_SMD:
shutdown(wds.soc_if.smd.fm_cmd_fd, SHUT_RDWR);
if (wds.mode == MODE_FM_SMD)
break;
case MODE_ANT_SMD:
shutdown(wds.soc_if.smd.ant_cmd_fd, SHUT_RDWR);
shutdown(wds.soc_if.smd.ant_data_fd, SHUT_RDWR);
break;
}
pthread_join(wds.soc_rthread, NULL);
hidl_client_close();
return retval;
}

View File

@@ -1,52 +0,0 @@
# wpa_supplicant config
config WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
bool "Disable timestamp check"
depends on PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mesh || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini || PACAKGE_wpad-mesh
default n
help
This disables the timestamp check for certificates in wpa_supplicant
Useful for devices without RTC that cannot reliably get the real date/time
choice
prompt "Choose TLS provider"
default WPA_SUPPLICANT_INTERNAL
depends on PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mesh || PACKAGE_wpad || PACKAGE_wpad-mesh
config WPA_SUPPLICANT_INTERNAL
bool "internal"
depends on PACKAGE_wpa-supplicant || PACKAGE_wpad
config WPA_SUPPLICANT_OPENSSL
bool "openssl"
select PACKAGE_libopenssl
endchoice
config WPA_RFKILL_SUPPORT
bool "Add rfkill support"
depends on PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mesh || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini || PACKAGE_wpad-mesh
default n
config WPA_MSG_MIN_PRIORITY
int "Minimum debug message priority"
default 3
help
Useful values are:
0 = all messages
1 = raw message dumps
2 = most debugging messages
3 = info messages
4 = warnings
5 = errors
config DRIVER_WEXT_SUPPORT
bool
default n
config DRIVER_11N_SUPPORT
bool
default n
config DRIVER_11W_SUPPORT
bool
default n

View File

@@ -1,511 +0,0 @@
# Copyright (C) 2006-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
PKG_VERSION:=2021-12-13
PKG_RELEASE:=1
PKG_REV:=b26f5c0fe3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://w1.fi/hostap.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_PROTO:=git
PKG_MIRROR_MD5SUM:=skip
PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
PKG_LICENSE:=BSD-3-Clause
PKG_BUILD_PARALLEL:=1
PKG_CONFIG_DEPENDS:= \
CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK \
CONFIG_PACKAGE_kmod-ath9k \
CONFIG_PACKAGE_kmod-cfg80211 \
CONFIG_PACKAGE_hostapd \
CONFIG_PACKAGE_hostapd-mini \
CONFIG_PACKAGE_kmod-hostap \
CONFIG_WPA_RFKILL_SUPPORT \
CONFIG_DRIVER_WEXT_SUPPORT \
CONFIG_DRIVER_11N_SUPPORT
LOCAL_TYPE=$(strip \
$(if $(findstring wpad,$(BUILD_VARIANT)),wpad, \
$(if $(findstring supplicant,$(BUILD_VARIANT)),supplicant, \
hostapd \
)))
LOCAL_VARIANT=$(patsubst wpad-%,%,$(patsubst supplicant-%,%,$(BUILD_VARIANT)))
ifeq ($(LOCAL_TYPE),supplicant)
ifeq ($(LOCAL_VARIANT),full)
PKG_CONFIG_DEPENDS += \
CONFIG_WPA_SUPPLICANT_INTERNAL \
CONFIG_WPA_SUPPLICANT_OPENSSL
endif
ifeq ($(LOCAL_VARIANT),mesh)
PKG_CONFIG_DEPENDS += \
CONFIG_WPA_SUPPLICANT_OPENSSL
endif
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
TARGET_LDFLAGS_C:=$(TARGET_LDFLAGS)
STAMP_CONFIGURED:=$(STAMP_CONFIGURED)_$(CONFIG_WPA_MSG_MIN_PRIORITY)
ifneq ($(CONFIG_DRIVER_11N_SUPPORT),)
HOSTAPD_IEEE80211N:=y
endif
DRIVER_MAKEOPTS= \
CONFIG_ACS=$(CONFIG_PACKAGE_kmod-cfg80211) \
CONFIG_DRIVER_NL80211=$(CONFIG_PACKAGE_kmod-cfg80211) \
CONFIG_DRIVER_HOSTAP=$(CONFIG_PACKAGE_kmod-hostap) \
CONFIG_IEEE80211N=$(HOSTAPD_IEEE80211N) \
CONFIG_DRIVER_WEXT=$(CONFIG_DRIVER_WEXT_SUPPORT) \
ifeq ($(LOCAL_VARIANT),full)
DRIVER_MAKEOPTS += CONFIG_IEEE80211W=$(CONFIG_DRIVER_11W_SUPPORT)
endif
ifneq ($(LOCAL_TYPE),hostapd)
ifdef CONFIG_WPA_SUPPLICANT_OPENSSL
ifeq ($(LOCAL_VARIANT),full)
DRIVER_MAKEOPTS += CONFIG_TLS=openssl
TARGET_LDFLAGS += -lcrypto -lssl
endif
endif
ifeq ($(LOCAL_VARIANT),mesh)
DRIVER_MAKEOPTS += CONFIG_TLS=openssl
TARGET_LDFLAGS += -lcrypto -lssl
endif
ifdef CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
TARGET_CFLAGS += -DNO_TIMESTAMP_CHECK
endif
ifdef CONFIG_WPA_RFKILL_SUPPORT
DRIVER_MAKEOPTS += NEED_RFKILL=y
endif
DRIVER_MAKEOPTS += \
CONFIG_DRIVER_ROBOSWITCH=$(CONFIG_PACKAGE_kmod-switch)
endif
ifdef CONFIG_USE_GLIBC
TARGET_LDFLAGS += -lrt
TARGET_LDFLAGS_C += -lrt
endif
DRV_DEPENDS:=+PACKAGE_kmod-cfg80211:libnl
define Package/hostapd/Default
SECTION:=net
CATEGORY:=Network
TITLE:=IEEE 802.1x Authenticator
URL:=http://hostap.epitest.fi/
DEPENDS:=$(DRV_DEPENDS) +hostapd-common +libubus +libnl
endef
define Package/hostapd
$(call Package/hostapd/Default)
TITLE+= (full)
VARIANT:=full
CONFLICTS:=wpad wpad-mini wpad-mesh
endef
define Package/hostapd/description
This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
Authenticator.
endef
define Package/hostapd-macsec
$(call Package/hostapd/Default)
TITLE+= (macsec)
DEPENDS+= @TARGET_ipq||TARGET_ipq50xx||TARGET_ipq60xx||TARGET_ipq95xx +kmod-qca-nss-macsec +libopenssl
VARIANT:=macsec
endef
define Package/hostapd-macsec/description
This package is Hostapd Authenticator for macsec support.
endef
define Package/hostapd-mini
$(call Package/hostapd/Default)
TITLE+= (WPA-PSK only)
VARIANT:=mini
CONFLICTS:=wpad wpad-mini wpad-mesh
endef
define Package/hostapd-mini/description
This package contains a minimal IEEE 802.1x/WPA Authenticator (WPA-PSK only).
endef
define Package/hostapd-utils
$(call Package/hostapd/Default)
TITLE+= (utils)
DEPENDS:=@PACKAGE_hostapd||PACKAGE_hostapd-mini||PACKAGE_wpad||PACKAGE_wpad-mesh||PACKAGE_wpad-mini
endef
define Package/hostapd-utils/description
This package contains a command line utility to control the
IEEE 802.1x/WPA/EAP/RADIUS Authenticator.
endef
define Package/wpad/Default
SECTION:=net
CATEGORY:=Network
TITLE:=IEEE 802.1x Authenticator/Supplicant
DEPENDS:=$(DRV_DEPENDS) +hostapd-common +libubus
URL:=http://hostap.epitest.fi/
endef
define Package/wpad
$(call Package/wpad/Default)
TITLE+= (full)
DEPENDS+=+WPA_SUPPLICANT_OPENSSL:libopenssl +libnl
VARIANT:=wpad-full
endef
define Package/wpad/description
This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
Authenticator and Supplicant
endef
define Package/wpad-mini
$(call Package/wpad/Default)
TITLE+= (WPA-PSK only)
DEPENDS:=$(DRV_DEPENDS) +libnl
VARIANT:=wpad-mini
endef
define Package/wpad-mini/description
This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (WPA-PSK only).
endef
define Package/wpad-mesh
$(call Package/wpad/Default)
TITLE+= (with 802.11s mesh and SAE support)
DEPENDS:=$(DRV_DEPENDS) +libubus +libopenssl +@CONFIG_WPA_SUPPLICANT_OPENSSL @(!TARGET_uml||BROKEN)
CONFLICTS:=@WPA_SUPPLICANT_INTERNAL
VARIANT:=wpad-mesh
endef
define Package/wpad-mesh/description
This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (with 802.11s mesh and SAE support).
endef
define Package/wpa-supplicant
SECTION:=net
CATEGORY:=Network
TITLE:=WPA Supplicant
URL:=http://hostap.epitest.fi/wpa_supplicant/
DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
CONFLICTS:=wpad wpad-mini wpad-mesh
VARIANT:=supplicant-full
endef
define Package/wpa-supplicant/Description
WPA Supplicant
endef
define Package/wpa-supplicant/config
source "$(SOURCE)/Config.in"
endef
define Package/wpa-supplicant-macsec
$(call Package/wpa-supplicant)
TITLE:=WPA Supplicant (MACSEC)
DEPENDS+= @TARGET_ipq||TARGET_ipq50xx||TARGET_ipq60xx||TARGET_ipq95xx +kmod-qca-nss-macsec
CONFLICTS:=
VARIANT:=supplicant-macsec
endef
define Package/wpa-supplicant-macsec/Description
WPA Supplicant with MACSEC support.
endef
define Package/wpa-supplicant-p2p
$(Package/wpa-supplicant)
TITLE:=WPA Supplicant (with Wi-Fi P2P support)
DEPENDS:=$(DRV_DEPENDS)
CONFLICTS:=wpad wpad-mini wpad-mesh
VARIANT:=supplicant-p2p
endef
define Package/wpa-supplicant-p2p/Description
WPA Supplicant (with Wi-Fi P2P support)
endef
define Package/wpa-supplicant-mesh
$(Package/wpa-supplicant)
TITLE:=WPA Supplicant (with 802.11s and SAE)
DEPENDS:=$(DRV_DEPENDS) @(!TARGET_uml||BROKEN)
CONFLICTS:=wpad wpad-mini wpad-mesh
VARIANT:=supplicant-mesh
endef
define Package/wpa-supplicant-mesh/Description
WPA Supplicant (variant with 802.11s and SAE support)
endef
define Package/wpa-supplicant-mini
$(Package/wpa-supplicant)
TITLE:=WPA Supplicant (minimal version)
DEPENDS:=$(DRV_DEPENDS)
CONFLICTS:=wpad wpad-mini wpad-mesh
VARIANT:=supplicant-mini
endef
define Package/wpa-supplicant-mini/Description
WPA Supplicant (minimal version)
endef
define Package/wpa-cli
SECTION:=net
CATEGORY:=Network
DEPENDS:=@PACKAGE_wpa-supplicant||PACKAGE_wpa-supplicant-p2p||PACKAGE_wpad-mini||PACKAGE_wpad||PACKAGE_wpad-mesh
TITLE:=WPA Supplicant command line interface
endef
define Package/wpa-cli/Description
WPA Supplicant control utility
endef
define Package/hostapd-common
TITLE:=hostapd/wpa_supplicant common support files
SECTION:=net
CATEGORY:=Network
endef
define Package/hostapd-common-old
TITLE:=hostapd/wpa_supplicant common support files (legacy drivers)
SECTION:=net
CATEGORY:=Network
endef
define Package/eapol-test
TITLE:=802.1x authentication test utility
SECTION:=net
CATEGORY:=Network
VARIANT:=supplicant-full
DEPENDS:=$(DRV_DEPENDS)
endef
ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
define Build/Configure/rebuild
$(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.a | $(XARGS) rm -f
rm -f $(PKG_BUILD_DIR)/hostapd/hostapd
rm -f $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant
rm -f $(PKG_BUILD_DIR)/.config_*
touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
endef
endif
define Build/Configure
$(Build/Configure/rebuild)
$(if $(wildcard ./files/hostapd-$(LOCAL_VARIANT).config), \
$(CP) ./files/hostapd-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/hostapd/.config \
)
$(CP) ./files/wpa_supplicant-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/wpa_supplicant/.config
endef
TARGET_CPPFLAGS := \
-I$(STAGING_DIR)/usr/include/libnl3 \
-I$(PKG_BUILD_DIR)/src/crypto \
$(TARGET_CPPFLAGS) \
-D_GNU_SOURCE \
$(if $(CONFIG_WPA_MSG_MIN_PRIORITY),-DCONFIG_MSG_MIN_PRIORITY=$(CONFIG_WPA_MSG_MIN_PRIORITY))
TARGET_CFLAGS += -ffunction-sections -fdata-sections -Wall -Werror -Wno-pointer-sign
TARGET_LDFLAGS += -Wl,--gc-sections
ifeq ($(findstring supplicant,$(BUILD_VARIANT)),)
TARGET_LDFLAGS += -lubox -lubus
endif
ifdef CONFIG_PACKAGE_kmod-cfg80211
TARGET_LDFLAGS += -lm -lnl-3 -lnl-genl-3 -lnl-route-3
endif
ifeq ($(LOCAL_VARIANT),macsec)
TARGET_LDFLAGS += -lcrypto -lssl -lfal -L$(STAGING_DIR)/usr/lib
TARGET_CPPFLAGS += \
-I$(STAGING_DIR)/usr/include/qca-nss-macsec
endif
define Build/RunMake
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(1) \
$(TARGET_CONFIGURE_OPTS) \
$(DRIVER_MAKEOPTS) \
LIBS="$(TARGET_LDFLAGS)" \
LIBS_c="$(TARGET_LDFLAGS_C)" \
BCHECK= \
$(2)
endef
define Build/Compile/wpad
echo ` \
$(call Build/RunMake,hostapd,-s MULTICALL=1 dump_cflags); \
$(call Build/RunMake,wpa_supplicant,-s MULTICALL=1 dump_cflags) | \
sed -e 's,-n ,,g' -e 's^$(TARGET_CFLAGS)^^' \
` > $(PKG_BUILD_DIR)/.cflags
+$(call Build/RunMake,hostapd, \
CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
MULTICALL=1 \
hostapd_cli hostapd_multi.a \
)
+$(call Build/RunMake,wpa_supplicant, \
CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
MULTICALL=1 \
wpa_cli wpa_supplicant_multi.a \
libwpa_client.so \
)
$(TARGET_CC) -o $(PKG_BUILD_DIR)/wpad \
$(TARGET_CFLAGS) \
./files/multicall.c \
$(PKG_BUILD_DIR)/hostapd/hostapd_multi.a \
$(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant_multi.a \
$(TARGET_LDFLAGS)
endef
define Build/Compile/hostapd
$(call Build/RunMake,hostapd, \
hostapd hostapd_cli \
)
endef
define Build/Compile/supplicant
$(call Build/RunMake,wpa_supplicant, \
wpa_cli wpa_supplicant \
)
endef
define Build/Compile/supplicant-full
$(call Build/RunMake,wpa_supplicant, \
eapol_test \
)
endef
define Build/Compile
$(Build/Compile/$(LOCAL_TYPE))
$(Build/Compile/$(BUILD_VARIANT))
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/src/common/wpa_ctrl.h $(1)/usr/include
ifneq ($(CONFIG_PACKAGE_hostapd-utils),)
ifneq ($(LOCAL_VARIANT),macsec)
$(CP) $(PKG_BUILD_DIR)/wpa_supplicant/libwpa_client.so $(1)/usr/lib
endif
endif
endef
define Install/hostapd
$(INSTALL_DIR) $(1)/usr/sbin
endef
define Install/supplicant
$(INSTALL_DIR) $(1)/usr/sbin
endef
define Package/hostapd-common/install
$(INSTALL_DIR) $(1)/lib/netifd
$(INSTALL_DATA) ./files/netifd.sh $(1)/lib/netifd/hostapd.sh
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/wpad.init $(1)/etc/init.d/wpad
endef
define Package/hostapd-common-old/install
$(INSTALL_DIR) $(1)/lib/wifi
$(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/wifi/hostapd.sh
$(INSTALL_DATA) ./files/wpa_supplicant.sh $(1)/lib/wifi/wpa_supplicant.sh
endef
define Package/hostapd/install
$(call Install/hostapd,$(1))
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd $(1)/usr/sbin/
endef
define Package/hostapd-macsec/install
$(call Install/hostapd,$(1))
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd $(1)/usr/sbin/hostapd-macsec
endef
Package/hostapd-mini/install = $(Package/hostapd/install)
ifneq ($(LOCAL_TYPE),supplicant)
ifneq ($(LOCAL_VARIANT),macsec)
define Package/hostapd-utils/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/rc.button
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_cli $(1)/usr/sbin/
$(INSTALL_BIN) ./files/wps-hotplug.sh $(1)/etc/rc.button/wps
endef
endif
endif
define Package/wpad/install
$(call Install/hostapd,$(1))
$(call Install/supplicant,$(1))
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_BIN) $(PKG_BUILD_DIR)/wpad $(1)/usr/sbin/
$(LN) wpad $(1)/usr/sbin/hostapd
$(LN) wpad $(1)/usr/sbin/wpa_supplicant
$(INSTALL_DATA) $(PKG_BUILD_DIR)/wpa_supplicant/libwpa_client.so $(1)/usr/lib/
endef
Package/wpad-mini/install = $(Package/wpad/install)
Package/wpad-mesh/install = $(Package/wpad/install)
define Package/wpa-supplicant/install
$(call Install/supplicant,$(1))
$(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant $(1)/usr/sbin/
endef
define Package/wpa-supplicant-macsec/install
$(call Install/supplicant,$(1))
$(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant $(1)/usr/sbin/wpa_supplicant-macsec
endef
Package/wpa-supplicant-mini/install = $(Package/wpa-supplicant/install)
Package/wpa-supplicant-p2p/install = $(Package/wpa-supplicant/install)
ifneq ($(LOCAL_TYPE),hostapd)
ifneq ($(LOCAL_VARIANT),macsec)
define Package/wpa-cli/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_cli $(1)/usr/sbin/
endef
endif
endif
ifeq ($(BUILD_VARIANT),supplicant-full)
define Package/eapol-test/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_BUILD_DIR)/wpa_supplicant/eapol_test $(1)/usr/sbin/
endef
endif
$(eval $(call BuildPackage,hostapd))
$(eval $(call BuildPackage,hostapd-mini))
$(eval $(call BuildPackage,hostapd-macsec))
$(eval $(call BuildPackage,wpad))
$(eval $(call BuildPackage,wpad-mesh))
$(eval $(call BuildPackage,wpad-mini))
$(eval $(call BuildPackage,wpa-supplicant))
$(eval $(call BuildPackage,wpa-supplicant-macsec))
$(eval $(call BuildPackage,wpa-supplicant-mesh))
$(eval $(call BuildPackage,wpa-supplicant-mini))
$(eval $(call BuildPackage,wpa-supplicant-p2p))
$(eval $(call BuildPackage,wpa-cli))
$(eval $(call BuildPackage,hostapd-utils))
$(eval $(call BuildPackage,hostapd-common))
$(eval $(call BuildPackage,hostapd-common-old))
$(eval $(call BuildPackage,eapol-test))

View File

@@ -1,176 +0,0 @@
# Example hostapd build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cass, these lines should use += in order not
# to override previous values of the variables.
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for wired authenticator
CONFIG_DRIVER_WIRED=y
# Driver interface for Prism54 driver
#CONFIG_DRIVER_PRISM54=y
# Driver interface for drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
# shipped with your distribution yet. If that is the case, you need to build
# newer libnl version and point the hostapd build to use it.
#LIBNL=/usr/src/libnl
#CFLAGS += -I$(LIBNL)/include
#LIBS += -L$(LIBNL)/lib
# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
#CONFIG_DRIVER_BSD=y
#CFLAGS += -I/usr/local/include
#LIBS += -L/usr/local/lib
# Driver interface for no driver (e.g., RADIUS server only)
#CONFIG_DRIVER_NONE=y
# IEEE 802.11F/IAPP
CONFIG_IAPP=y
# WPA2/IEEE 802.11i RSN pre-authentication
CONFIG_RSN_PREAUTH=y
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
CONFIG_PEERKEY=y
# IEEE 802.11w (management frame protection)
# This version is an experimental implementation based on IEEE 802.11w/D1.0
# draft and is subject to change since the standard has not yet been finalized.
# Driver support is also needed for IEEE 802.11w.
#CONFIG_IEEE80211W=y
# Integrated EAP server
CONFIG_EAP=y
# EAP-MD5 for the integrated EAP server
CONFIG_EAP_MD5=y
# EAP-TLS for the integrated EAP server
CONFIG_EAP_TLS=y
# EAP-MSCHAPv2 for the integrated EAP server
CONFIG_EAP_MSCHAPV2=y
# EAP-PEAP for the integrated EAP server
CONFIG_EAP_PEAP=y
# EAP-GTC for the integrated EAP server
CONFIG_EAP_GTC=y
# EAP-TTLS for the integrated EAP server
CONFIG_EAP_TTLS=y
# EAP-SIM for the integrated EAP server
#CONFIG_EAP_SIM=y
# EAP-AKA for the integrated EAP server
#CONFIG_EAP_AKA=y
# EAP-AKA' for the integrated EAP server
# This requires CONFIG_EAP_AKA to be enabled, too.
#CONFIG_EAP_AKA_PRIME=y
# EAP-PAX for the integrated EAP server
#CONFIG_EAP_PAX=y
# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
#CONFIG_EAP_PSK=y
# EAP-SAKE for the integrated EAP server
#CONFIG_EAP_SAKE=y
# EAP-GPSK for the integrated EAP server
#CONFIG_EAP_GPSK=y
# Include support for optional SHA256 cipher suite in EAP-GPSK
#CONFIG_EAP_GPSK_SHA256=y
# EAP-FAST for the integrated EAP server
# Note: Default OpenSSL package does not include support for all the
# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
# to add the needed functions.
#CONFIG_EAP_FAST=y
# Wi-Fi Protected Setup (WPS)
CONFIG_WPS=y
CONFIG_WPS2=y
# Enable UPnP support for external WPS Registrars
CONFIG_WPS_UPNP=y
# EAP-IKEv2
#CONFIG_EAP_IKEV2=y
# Trusted Network Connect (EAP-TNC)
#CONFIG_EAP_TNC=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
CONFIG_PKCS12=y
# RADIUS authentication server. This provides access to the integrated EAP
# server from external hosts using RADIUS.
#CONFIG_RADIUS_SERVER=y
# Build IPv6 support for RADIUS operations
CONFIG_IPV6=y
# IEEE Std 802.11r-2008 (Fast BSS Transition)
CONFIG_IEEE80211R=y
# Use the hostapd's IEEE 802.11 authentication (ACL), but without
# the IEEE 802.11 Management capability (e.g. FreeBSD/net80211)
#CONFIG_DRIVER_RADIUS_ACL=y
# IEEE 802.11n (High Throughput) support
CONFIG_IEEE80211N=y
# IEEE 802.11ac (Very High Throughput) support
CONFIG_IEEE80211AC=y
# Remove debugging code that is printing out debug messages to stdout.
# This can be used to reduce the size of the hostapd considerably if debugging
# code is not needed.
#CONFIG_NO_STDOUT_DEBUG=y
# Remove support for RADIUS accounting
#CONFIG_NO_ACCOUNTING=y
# Remove support for RADIUS
#CONFIG_NO_RADIUS=y
# Remove support for VLANs
#CONFIG_NO_VLAN=y
CONFIG_TLS=internal
CONFIG_INTERNAL_LIBTOMMATH=y
CONFIG_INTERNAL_AES=y
NEED_AES_DEC=y
CONFIG_NO_RANDOM_POOL=y
CONFIG_NO_DUMP_STATE=y
CONFIG_WPS=y
CONFIG_FULL_DYNAMIC_VLAN=y
CONFIG_UBUS=y
CONFIG_HS20=y
CONFIG_P2P_MANAGER=y
CONFIG_INTERWORKING=y
CONFIG_WNM=y
CONFIG_PROXYARP=y
CONFIG_LIBNL32=y
CONFIG_LIBNL3_ROUTE=y
CONFIG_AIRTIME_POLICY=y
CONFIG_FILS=y

View File

@@ -1,111 +0,0 @@
# Example hostapd build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cass, these lines should use += in order not
# to override previous values of the variables.
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for wired authenticator
CONFIG_DRIVER_WIRED=y
# Driver interface for Prism54 driver
#CONFIG_DRIVER_PRISM54=y
# Driver interface for drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# IEEE 802.11F/IAPP
CONFIG_IAPP=y
# WPA2/IEEE 802.11i RSN pre-authentication
CONFIG_RSN_PREAUTH=y
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
CONFIG_PEERKEY=y
# Integrated EAP server
CONFIG_EAP=y
# EAP-MD5 for the integrated EAP server
CONFIG_EAP_MD5=y
# EAP-TLS for the integrated EAP server
CONFIG_EAP_TLS=y
# EAP-MSCHAPv2 for the integrated EAP server
CONFIG_EAP_MSCHAPV2=y
# EAP-PEAP for the integrated EAP server
CONFIG_EAP_PEAP=y
# EAP-GTC for the integrated EAP server
CONFIG_EAP_GTC=y
# EAP-TTLS for the integrated EAP server
CONFIG_EAP_TTLS=y
# Wi-Fi Protected Setup (WPS)
CONFIG_WPS=y
CONFIG_WPS2=y
# Enable UPnP support for external WPS Registrars
CONFIG_WPS_UPNP=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
CONFIG_PKCS12=y
# Build IPv6 support for RADIUS operations
CONFIG_IPV6=y
# IEEE Std 802.11r-2008 (Fast BSS Transition)
CONFIG_IEEE80211R=y
# IEEE 802.11n (High Throughput) support
CONFIG_IEEE80211N=y
# IEEE 802.11ac (Very High Throughput) support
CONFIG_IEEE80211AC=y
# IEEE 802.11ax (HE Throughput) support
CONFIG_IEEE80211AX=y
# IEEE 802.11be (EHT Throughput) support
CONFIG_IEEE80211BE=y
CONFIG_TLS=openssl
CONFIG_INTERNAL_LIBTOMMATH=y
NEED_AES_DEC=y
CONFIG_NO_RANDOM_POOL=y
CONFIG_NO_DUMP_STATE=y
CONFIG_WPS=y
CONFIG_FULL_DYNAMIC_VLAN=y
CONFIG_UBUS=y
CONFIG_HS20=y
CONFIG_P2P_MANAGER=y
CONFIG_INTERWORKING=y
CONFIG_WNM=y
CONFIG_PROXYARP=y
CONFIG_LIBNL32=y
CONFIG_LIBNL3_ROUTE=y
CONFIG_AIRTIME_POLICY=y
CONFIG_FILS=y
CONFIG_CTRL_IFACE_MIB=y
CONFIG_SAE=y
CONFIG_OWE=y
# Driver interface for MACsec (Only for wired network)
CONFIG_DRIVER_MACSEC_QCA=y
# Enable MACsec support for hostapd
CONFIG_MACSEC=y

View File

@@ -1,195 +0,0 @@
# Example hostapd build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cass, these lines should use += in order not
# to override previous values of the variables.
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for wired authenticator
CONFIG_DRIVER_WIRED=y
# Driver interface for Prism54 driver
#CONFIG_DRIVER_PRISM54=y
# Driver interface for drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
# shipped with your distribution yet. If that is the case, you need to build
# newer libnl version and point the hostapd build to use it.
#LIBNL=/usr/src/libnl
#CFLAGS += -I$(LIBNL)/include
#LIBS += -L$(LIBNL)/lib
# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
#CONFIG_DRIVER_BSD=y
#CFLAGS += -I/usr/local/include
#LIBS += -L/usr/local/lib
# Driver interface for no driver (e.g., RADIUS server only)
#CONFIG_DRIVER_NONE=y
# IEEE 802.11F/IAPP
CONFIG_IAPP=y
# WPA2/IEEE 802.11i RSN pre-authentication
CONFIG_RSN_PREAUTH=y
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
CONFIG_PEERKEY=y
# IEEE 802.11w (management frame protection)
# This version is an experimental implementation based on IEEE 802.11w/D1.0
# draft and is subject to change since the standard has not yet been finalized.
# Driver support is also needed for IEEE 802.11w.
CONFIG_IEEE80211W=y
# Integrated EAP server
CONFIG_EAP=y
# EAP-MD5 for the integrated EAP server
CONFIG_EAP_MD5=y
# EAP-TLS for the integrated EAP server
CONFIG_EAP_TLS=y
# EAP-MSCHAPv2 for the integrated EAP server
CONFIG_EAP_MSCHAPV2=y
# EAP-PEAP for the integrated EAP server
CONFIG_EAP_PEAP=y
# EAP-GTC for the integrated EAP server
CONFIG_EAP_GTC=y
# EAP-TTLS for the integrated EAP server
CONFIG_EAP_TTLS=y
# EAP-SIM for the integrated EAP server
#CONFIG_EAP_SIM=y
# EAP-AKA for the integrated EAP server
#CONFIG_EAP_AKA=y
# EAP-AKA' for the integrated EAP server
# This requires CONFIG_EAP_AKA to be enabled, too.
#CONFIG_EAP_AKA_PRIME=y
# EAP-PAX for the integrated EAP server
#CONFIG_EAP_PAX=y
# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
#CONFIG_EAP_PSK=y
# EAP-SAKE for the integrated EAP server
#CONFIG_EAP_SAKE=y
# EAP-GPSK for the integrated EAP server
#CONFIG_EAP_GPSK=y
# Include support for optional SHA256 cipher suite in EAP-GPSK
#CONFIG_EAP_GPSK_SHA256=y
# EAP-FAST for the integrated EAP server
# Note: Default OpenSSL package does not include support for all the
# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
# to add the needed functions.
#CONFIG_EAP_FAST=y
# Wi-Fi Protected Setup (WPS)
CONFIG_WPS=y
CONFIG_WPS2=y
# Enable UPnP support for external WPS Registrars
CONFIG_WPS_UPNP=y
# EAP-IKEv2
#CONFIG_EAP_IKEV2=y
# Trusted Network Connect (EAP-TNC)
#CONFIG_EAP_TNC=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
CONFIG_PKCS12=y
# RADIUS authentication server. This provides access to the integrated EAP
# server from external hosts using RADIUS.
#CONFIG_RADIUS_SERVER=y
# Build IPv6 support for RADIUS operations
CONFIG_IPV6=y
# IEEE Std 802.11r-2008 (Fast BSS Transition)
CONFIG_IEEE80211R=y
# Use the hostapd's IEEE 802.11 authentication (ACL), but without
# the IEEE 802.11 Management capability (e.g. FreeBSD/net80211)
#CONFIG_DRIVER_RADIUS_ACL=y
# IEEE 802.11n (High Throughput) support
CONFIG_IEEE80211N=y
# IEEE 802.11ac (Very High Throughput) support
CONFIG_IEEE80211AC=y
# IEEE 802.11ax (HE Throughput) support
CONFIG_IEEE80211AX=y
# IEEE 802.11be (EHT Throughput) support
CONFIG_IEEE80211BE=y
# Multiband Operation support
# These extentions facilitate efficient use of multiple frequency bands
# available to the AP and the devices that may associate with it.
CONFIG_MBO=y
# Remove debugging code that is printing out debug messages to stdout.
# This can be used to reduce the size of the hostapd considerably if debugging
# code is not needed.
#CONFIG_NO_STDOUT_DEBUG=y
# Remove support for RADIUS accounting
#CONFIG_NO_ACCOUNTING=y
# Remove support for RADIUS
#CONFIG_NO_RADIUS=y
# Remove support for VLANs
#CONFIG_NO_VLAN=y
CONFIG_TLS=internal
CONFIG_INTERNAL_LIBTOMMATH=y
CONFIG_INTERNAL_AES=y
NEED_AES_DEC=y
CONFIG_NO_RANDOM_POOL=y
CONFIG_NO_DUMP_STATE=y
CONFIG_WPS=y
CONFIG_FULL_DYNAMIC_VLAN=y
CONFIG_UBUS=y
CONFIG_HS20=y
CONFIG_P2P_MANAGER=y
CONFIG_INTERWORKING=y
CONFIG_WNM=y
CONFIG_PROXYARP=y
CONFIG_LIBNL32=y
CONFIG_LIBNL3_ROUTE=y
CONFIG_ACS=y
CONFIG_CTRL_IFACE_MIB=y
CONFIG_RX_PROBE_REQ_EVENT=y
CONFIG_SAE=y
CONFIG_OWE=y
CONFIG_SUITEB192=y
CONFIG_SUITEB=y
NEED_DH_GROUPS_ALL=y
CONFIG_AIRTIME_POLICY=y
CONFIG_FILS=y

View File

@@ -1,159 +0,0 @@
# Example hostapd build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cass, these lines should use += in order not
# to override previous values of the variables.
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for wired authenticator
CONFIG_DRIVER_WIRED=y
# Driver interface for Prism54 driver
#CONFIG_DRIVER_PRISM54=y
# Driver interface for drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
# shipped with your distribution yet. If that is the case, you need to build
# newer libnl version and point the hostapd build to use it.
#LIBNL=/usr/src/libnl
#CFLAGS += -I$(LIBNL)/include
#LIBS += -L$(LIBNL)/lib
# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
#CONFIG_DRIVER_BSD=y
#CFLAGS += -I/usr/local/include
#LIBS += -L/usr/local/lib
# Driver interface for no driver (e.g., RADIUS server only)
#CONFIG_DRIVER_NONE=y
# IEEE 802.11F/IAPP
# CONFIG_IAPP=y
# WPA2/IEEE 802.11i RSN pre-authentication
CONFIG_RSN_PREAUTH=y
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
CONFIG_PEERKEY=y
# IEEE 802.11w (management frame protection)
# This version is an experimental implementation based on IEEE 802.11w/D1.0
# draft and is subject to change since the standard has not yet been finalized.
# Driver support is also needed for IEEE 802.11w.
#CONFIG_IEEE80211W=y
# Integrated EAP server
#CONFIG_EAP=y
# EAP-MD5 for the integrated EAP server
#CONFIG_EAP_MD5=y
# EAP-TLS for the integrated EAP server
#CONFIG_EAP_TLS=y
# EAP-MSCHAPv2 for the integrated EAP server
#CONFIG_EAP_MSCHAPV2=y
# EAP-PEAP for the integrated EAP server
#CONFIG_EAP_PEAP=y
# EAP-GTC for the integrated EAP server
#CONFIG_EAP_GTC=y
# EAP-TTLS for the integrated EAP server
#CONFIG_EAP_TTLS=y
# EAP-SIM for the integrated EAP server
#CONFIG_EAP_SIM=y
# EAP-AKA for the integrated EAP server
#CONFIG_EAP_AKA=y
# EAP-AKA' for the integrated EAP server
# This requires CONFIG_EAP_AKA to be enabled, too.
#CONFIG_EAP_AKA_PRIME=y
# EAP-PAX for the integrated EAP server
#CONFIG_EAP_PAX=y
# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
#CONFIG_EAP_PSK=y
# EAP-SAKE for the integrated EAP server
#CONFIG_EAP_SAKE=y
# EAP-GPSK for the integrated EAP server
#CONFIG_EAP_GPSK=y
# Include support for optional SHA256 cipher suite in EAP-GPSK
#CONFIG_EAP_GPSK_SHA256=y
# EAP-FAST for the integrated EAP server
# Note: Default OpenSSL package does not include support for all the
# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
# to add the needed functions.
#CONFIG_EAP_FAST=y
# Wi-Fi Protected Setup (WPS)
#CONFIG_WPS=y
# Enable UPnP support for external WPS Registrars
#CONFIG_WPS_UPNP=y
# EAP-IKEv2
#CONFIG_EAP_IKEV2=y
# Trusted Network Connect (EAP-TNC)
#CONFIG_EAP_TNC=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
#CONFIG_PKCS12=y
# RADIUS authentication server. This provides access to the integrated EAP
# server from external hosts using RADIUS.
#CONFIG_RADIUS_SERVER=y
# Build IPv6 support for RADIUS operations
#CONFIG_IPV6=y
# IEEE Std 802.11r-2008 (Fast BSS Transition)
#CONFIG_IEEE80211R=y
# Use the hostapd's IEEE 802.11 authentication (ACL), but without
# the IEEE 802.11 Management capability (e.g. FreeBSD/net80211)
#CONFIG_DRIVER_RADIUS_ACL=y
# IEEE 802.11n (High Throughput) support
CONFIG_IEEE80211N=y
# IEEE 802.11ac (Very High Throughput) support
CONFIG_IEEE80211AC=y
# Remove debugging code that is printing out debug messages to stdout.
# This can be used to reduce the size of the hostapd considerably if debugging
# code is not needed.
#CONFIG_NO_STDOUT_DEBUG=y
# Remove support for RADIUS accounting
CONFIG_NO_ACCOUNTING=y
# Remove support for RADIUS
CONFIG_NO_RADIUS=y
# Remove support for VLANs
#CONFIG_NO_VLAN=y
CONFIG_TLS=internal
CONFIG_NO_RANDOM_POOL=y
CONFIG_NO_DUMP_STATE=y
CONFIG_UBUS=y

View File

@@ -1,394 +0,0 @@
hostapd_set_bss_options() {
local var="$1"
local vif="$2"
local enc wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wps_possible wpa_key_mgmt
config_get enc "$vif" encryption "none"
config_get wep_rekey "$vif" wep_rekey # 300
config_get wpa_group_rekey "$vif" wpa_group_rekey # 300
config_get wpa_pair_rekey "$vif" wpa_pair_rekey # 300
config_get wpa_master_rekey "$vif" wpa_master_rekey # 640
config_get_bool ap_isolate "$vif" isolate 0
config_get_bool disassoc_low_ack "$vif" disassoc_low_ack 1
config_get max_num_sta "$vif" max_num_sta 0
config_get max_inactivity "$vif" max_inactivity 0
config_get_bool preamble "$vif" short_preamble 1
config_get device "$vif" device
config_get hwmode "$device" hwmode
config_get phy "$device" phy
append "$var" "ctrl_interface=/var/run/hostapd-$phy" "$N"
if [ "$ap_isolate" -gt 0 ]; then
append "$var" "ap_isolate=$ap_isolate" "$N"
fi
if [ "$max_num_sta" -gt 0 ]; then
append "$var" "max_num_sta=$max_num_sta" "$N"
fi
if [ "$max_inactivity" -gt 0 ]; then
append "$var" "ap_max_inactivity=$max_inactivity" "$N"
fi
append "$var" "disassoc_low_ack=$disassoc_low_ack" "$N"
if [ "$preamble" -gt 0 ]; then
append "$var" "preamble=$preamble" "$N"
fi
# Examples:
# psk-mixed/tkip => WPA1+2 PSK, TKIP
# wpa-psk2/tkip+aes => WPA2 PSK, CCMP+TKIP
# wpa2/tkip+aes => WPA2 RADIUS, CCMP+TKIP
# ...
# TODO: move this parsing function somewhere generic, so that
# later it can be reused by drivers that don't use hostapd
# crypto defaults: WPA2 vs WPA1
case "$enc" in
wpa2*|*psk2*)
wpa=2
crypto="CCMP"
;;
*mixed*)
wpa=3
crypto="CCMP TKIP"
;;
*)
wpa=1
crypto="TKIP"
;;
esac
# explicit override for crypto setting
case "$enc" in
*tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip) crypto="CCMP TKIP";;
*aes|*ccmp) crypto="CCMP";;
*tkip) crypto="TKIP";;
esac
# enforce CCMP for 11ng and 11na
case "$hwmode:$crypto" in
*ng:TKIP|*na:TKIP) crypto="CCMP TKIP";;
esac
# use crypto/auth settings for building the hostapd config
case "$enc" in
none)
wps_possible=1
wpa=0
crypto=
# Here we make the assumption that if we're in open mode
# with WPS enabled, we got to be in unconfigured state.
wps_not_configured=1
;;
*psk*)
config_get psk "$vif" key
if [ ${#psk} -eq 64 ]; then
append "$var" "wpa_psk=$psk" "$N"
else
append "$var" "wpa_passphrase=$psk" "$N"
fi
wps_possible=1
[ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
[ -n "$wpa_pair_rekey" ] && append "$var" "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
[ -n "$wpa_master_rekey" ] && append "$var" "wpa_gmk_rekey=$wpa_master_rekey" "$N"
append wpa_key_mgmt "WPA-PSK"
;;
*wpa*|*8021x*)
# required fields? formats?
# hostapd is particular, maybe a default configuration for failures
config_get auth_server "$vif" auth_server
[ -z "$auth_server" ] && config_get auth_server "$vif" server
append "$var" "auth_server_addr=$auth_server" "$N"
config_get auth_port "$vif" auth_port
[ -z "$auth_port" ] && config_get auth_port "$vif" port
auth_port=${auth_port:-1812}
append "$var" "auth_server_port=$auth_port" "$N"
config_get auth_secret "$vif" auth_secret
[ -z "$auth_secret" ] && config_get auth_secret "$vif" key
append "$var" "auth_server_shared_secret=$auth_secret" "$N"
# You don't really want to enable this unless you are doing
# some corner case testing or are using OpenWrt as a work around
# for some systematic issues.
config_get_bool auth_cache "$vif" auth_cache 0
config_get rsn_preauth "$vif" rsn_preauth
[ "$auth_cache" -gt 0 ] || [[ "$rsn_preauth" = 1 ]] || append "$var" "disable_pmksa_caching=1" "$N"
[ "$auth_cache" -gt 0 ] || [[ "$rsn_preauth" = 1 ]] || append "$var" "okc=0" "$N"
config_get acct_server "$vif" acct_server
[ -n "$acct_server" ] && append "$var" "acct_server_addr=$acct_server" "$N"
config_get acct_port "$vif" acct_port
[ -n "$acct_port" ] && acct_port=${acct_port:-1813}
[ -n "$acct_port" ] && append "$var" "acct_server_port=$acct_port" "$N"
config_get acct_secret "$vif" acct_secret
[ -n "$acct_secret" ] && append "$var" "acct_server_shared_secret=$acct_secret" "$N"
config_get eap_reauth_period "$vif" eap_reauth_period
[ -n "$eap_reauth_period" ] && append "$var" "eap_reauth_period=$eap_reauth_period" "$N"
config_get dae_client "$vif" dae_client
config_get dae_secret "$vif" dae_secret
[ -n "$dae_client" -a -n "$dae_secret" ] && {
config_get dae_port "$vif" dae_port
append "$var" "radius_das_port=${dae_port:-3799}" "$N"
append "$var" "radius_das_client=$dae_client $dae_secret" "$N"
}
config_get ownip "$vif" ownip
append "$var" "own_ip_addr=$ownip" "$N"
append "$var" "eapol_key_index_workaround=1" "$N"
append "$var" "ieee8021x=1" "$N"
append wpa_key_mgmt "WPA-EAP"
[ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
[ -n "$wpa_pair_rekey" ] && append "$var" "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
[ -n "$wpa_master_rekey" ] && append "$var" "wpa_gmk_rekey=$wpa_master_rekey" "$N"
;;
*wep*)
config_get key "$vif" key
key="${key:-1}"
case "$key" in
[1234])
for idx in 1 2 3 4; do
local zidx
zidx=$(($idx - 1))
config_get ckey "$vif" "key${idx}"
[ -n "$ckey" ] && \
append "$var" "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N"
done
append "$var" "wep_default_key=$((key - 1))" "$N"
;;
*)
append "$var" "wep_key0=$(prepare_key_wep "$key")" "$N"
append "$var" "wep_default_key=0" "$N"
[ -n "$wep_rekey" ] && append "$var" "wep_rekey_period=$wep_rekey" "$N"
;;
esac
case "$enc" in
*shared*)
auth_algs=2
;;
*mixed*)
auth_algs=3
;;
esac
wpa=0
crypto=
;;
*)
wpa=0
crypto=
;;
esac
append "$var" "auth_algs=${auth_algs:-1}" "$N"
append "$var" "wpa=$wpa" "$N"
[ -n "$crypto" ] && append "$var" "wpa_pairwise=$crypto" "$N"
[ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
config_get ssid "$vif" ssid
config_get bridge "$vif" bridge
config_get ieee80211d "$vif" ieee80211d
config_get iapp_interface "$vif" iapp_interface
config_get_bool wps_pbc "$vif" wps_pushbutton 0
config_get_bool wps_label "$vif" wps_label 0
config_get config_methods "$vif" wps_config
[ "$wps_pbc" -gt 0 ] && append config_methods push_button
[ -n "$wps_possible" -a -n "$config_methods" ] && {
config_get device_type "$vif" wps_device_type "6-0050F204-1"
config_get device_name "$vif" wps_device_name "OpenWrt AP"
config_get manufacturer "$vif" wps_manufacturer "openwrt.org"
config_get wps_pin "$vif" wps_pin
config_get_bool ext_registrar "$vif" ext_registrar 0
[ "$ext_registrar" -gt 0 -a -n "$bridge" ] && append "$var" "upnp_iface=$bridge" "$N"
append "$var" "eap_server=1" "$N"
[ -n "$wps_pin" ] && append "$var" "ap_pin=$wps_pin" "$N"
append "$var" "wps_state=${wps_not_configured:-2}" "$N"
append "$var" "ap_setup_locked=0" "$N"
append "$var" "device_type=$device_type" "$N"
append "$var" "device_name=$device_name" "$N"
append "$var" "manufacturer=$manufacturer" "$N"
append "$var" "config_methods=$config_methods" "$N"
}
append "$var" "ssid=$ssid" "$N"
[ -n "$bridge" ] && append "$var" "bridge=$bridge" "$N"
[ -n "$ieee80211d" ] && append "$var" "ieee80211d=$ieee80211d" "$N"
[ -n "$iapp_interface" ] && append "$var" iapp_interface=$(uci_get_state network "$iapp_interface" ifname "$iapp_interface") "$N"
if [ "$wpa" -ge "1" ]
then
config_get nasid "$vif" nasid
[ -n "$nasid" ] && append "$var" "nas_identifier=$nasid" "$N"
config_get_bool ieee80211r "$vif" ieee80211r 0
if [ "$ieee80211r" -gt 0 ]
then
config_get mobility_domain "$vif" mobility_domain "4f57"
config_get r0_key_lifetime "$vif" r0_key_lifetime "10000"
config_get r1_key_holder "$vif" r1_key_holder "00004f577274"
config_get reassociation_deadline "$vif" reassociation_deadline "1000"
config_get r0kh "$vif" r0kh
config_get r1kh "$vif" r1kh
config_get_bool pmk_r1_push "$vif" pmk_r1_push 0
append "$var" "mobility_domain=$mobility_domain" "$N"
append "$var" "r0_key_lifetime=$r0_key_lifetime" "$N"
append "$var" "r1_key_holder=$r1_key_holder" "$N"
append "$var" "reassociation_deadline=$reassociation_deadline" "$N"
append "$var" "pmk_r1_push=$pmk_r1_push" "$N"
for kh in $r0kh; do
"$var" "r0kh=${kh//,/ }" "$N"
done
for kh in $r1kh; do
"$var" "r1kh=${kh//,/ }" "$N"
done
[ "$wpa_key_mgmt" != "${wpa_key_mgmt/EAP/}" ] && append wpa_key_mgmt "FT-EAP"
[ "$wpa_key_mgmt" != "${wpa_key_mgmt/PSK/}" ] && append wpa_key_mgmt "FT-PSK"
fi
[ -n "wpa_key_mgmt" ] && append "$var" "wpa_key_mgmt=$wpa_key_mgmt"
fi
if [ "$wpa" -ge "2" ]
then
# RSN -> allow preauthentication. You have two
# options, rsn_preauth for production or rsn_preauth_testing
# for validation / testing.
if [ -n "$bridge" -a "$rsn_preauth" = 1 ]
then
append "$var" "rsn_preauth=1" "$N"
append "$var" "rsn_preauth_interfaces=$bridge" "$N"
append "$var" "okc=1" "$N"
else
# RSN preauthentication testings hould disable
# Opportunistic Key Caching (okc) as otherwise the PMKSA
# entry for a test could come from the Opportunistic Key Caching
config_get rsn_preauth_testing "$vif" rsn_preauth_testing
if [ -n "$bridge" -a "$rsn_preauth_testing" = 1 ]
then
append "$var" "rsn_preauth=1" "$N"
append "$var" "rsn_preauth_interfaces=$bridge" "$N"
append "$var" "okc=0" "$N"
fi
fi
# RSN -> allow management frame protection
config_get ieee80211w "$vif" ieee80211w
case "$ieee80211w" in
[012])
append "$var" "ieee80211w=$ieee80211w" "$N"
[ "$ieee80211w" -gt "0" ] && {
config_get ieee80211w_max_timeout "$vif" ieee80211w_max_timeout
config_get ieee80211w_retry_timeout "$vif" ieee80211w_retry_timeout
[ -n "$ieee80211w_max_timeout" ] && \
append "$var" "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
[ -n "$ieee80211w_retry_timeout" ] && \
append "$var" "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
}
;;
esac
fi
config_get macfile "$vif" macfile
config_get maclist "$vif" maclist
if [ -z "$macfile" ]
then
# if no macfile has been specified, fallback to the default name
# and truncate file to avoid aggregating entries over time
macfile="/var/run/hostapd-$ifname.maclist"
echo "" > "$macfile"
else
if [ -n "$maclist" ]
then
# to avoid to overwrite the original file, make a copy
# before appending the entries specified by the maclist
# option
cp $macfile $macfile.maclist
macfile=$macfile.maclist
fi
fi
if [ -n "$maclist" ]
then
for mac in $maclist; do
echo "$mac" >> $macfile
done
fi
config_get macfilter "$vif" macfilter
case "$macfilter" in
allow)
append "$var" "macaddr_acl=1" "$N"
append "$var" "accept_mac_file=$macfile" "$N"
;;
deny)
append "$var" "macaddr_acl=0" "$N"
append "$var" "deny_mac_file=$macfile" "$N"
;;
esac
}
hostapd_set_log_options() {
local var="$1"
local cfg="$2"
local log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
config_get log_level "$cfg" log_level 2
config_get_bool log_80211 "$cfg" log_80211 1
config_get_bool log_8021x "$cfg" log_8021x 1
config_get_bool log_radius "$cfg" log_radius 1
config_get_bool log_wpa "$cfg" log_wpa 1
config_get_bool log_driver "$cfg" log_driver 1
config_get_bool log_iapp "$cfg" log_iapp 1
config_get_bool log_mlme "$cfg" log_mlme 1
local log_mask=$(( \
($log_80211 << 0) | \
($log_8021x << 1) | \
($log_radius << 2) | \
($log_wpa << 3) | \
($log_driver << 4) | \
($log_iapp << 5) | \
($log_mlme << 6) \
))
append "$var" "logger_syslog=$log_mask" "$N"
append "$var" "logger_syslog_level=$log_level" "$N"
append "$var" "logger_stdout=$log_mask" "$N"
append "$var" "logger_stdout_level=$log_level" "$N"
}
hostapd_setup_vif() {
local vif="$1"
local driver="$2"
local ifname device channel hwmode
hostapd_cfg=
config_get ifname "$vif" ifname
config_get device "$vif" device
config_get channel "$device" channel
config_get hwmode "$device" hwmode
hostapd_set_log_options hostapd_cfg "$device"
hostapd_set_bss_options hostapd_cfg "$vif"
case "$hwmode" in
*bg|*gdt|*gst|*fh) hwmode=g;;
*adt|*ast) hwmode=a;;
esac
[ "$channel" = auto ] && channel=
[ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
cat > /var/run/hostapd-$ifname.conf <<EOF
driver=$driver
interface=$ifname
${hwmode:+hw_mode=${hwmode#11}}
${channel:+channel=$channel}
$hostapd_cfg
EOF
hostapd -P /var/run/wifi-$ifname.pid -B /var/run/hostapd-$ifname.conf
}

View File

@@ -1,28 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
extern int hostapd_main(int argc, char **argv);
extern int wpa_supplicant_main(int argc, char **argv);
int main(int argc, char **argv)
{
bool restart = false;
const char *prog = argv[0];
restart:
if (strstr(argv[0], "hostapd"))
return hostapd_main(argc, argv);
else if (strstr(argv[0], "wpa_supplicant"))
return wpa_supplicant_main(argc, argv);
if (!restart && argc > 1) {
argv++;
argc--;
restart = true;
goto restart;
}
fprintf(stderr, "Invalid command.\nUsage: %s wpa_supplicant|hostapd [<arguments>]\n", prog);
return 255;
}

View File

@@ -1,903 +0,0 @@
wpa_supplicant_add_rate() {
local var="$1"
local val="$(($2 / 1000))"
local sub="$((($2 / 100) % 10))"
append $var "$val" ","
[ $sub -gt 0 ] && append $var "."
}
hostapd_add_rate() {
local var="$1"
local val="$(($2 / 100))"
append $var "$val" " "
}
hostapd_append_wep_key() {
local var="$1"
wep_keyidx=0
set_default key 1
case "$key" in
[1234])
for idx in 1 2 3 4; do
local zidx
zidx=$(($idx - 1))
json_get_var ckey "key${idx}"
[ -n "$ckey" ] && \
append $var "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T"
done
wep_keyidx=$((key - 1))
;;
*)
append $var "wep_key0=$(prepare_key_wep "$key")" "$N$T"
;;
esac
}
hostapd_add_log_config() {
config_add_boolean \
log_80211 \
log_8021x \
log_radius \
log_wpa \
log_driver \
log_iapp \
log_mlme
config_add_int log_level
}
hostapd_common_add_device_config() {
config_add_array basic_rate
config_add_array supported_rates
config_add_string country
config_add_boolean country_ie doth
config_add_string require_mode
config_add_int pwr_constraint
config_add_boolean spectrum_mgmt
hostapd_add_log_config
}
hostapd_prepare_device_config() {
local config="$1"
local driver="$2"
local base="${config%%.conf}"
local base_cfg=
json_get_vars country country_ie beacon_int doth require_mode \
pwr_constraint spectrum_mgmt
airtime_mode=
json_get_vars airtime_mode airtime_update_interval
hostapd_set_log_options base_cfg
set_default country_ie 1
set_default doth 1
set_default airtime_update_interval 200
[ -n "$country" ] && {
append base_cfg "country_code=$country" "$N"
[ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N"
[ "$hwmode" = "a" -a "$doth" -gt 0 ] && append base_cfg "ieee80211h=1" "$N"
[ "$country_ie" -gt 0 -a -n "$pwr_constraint" ] && append base_cfg "local_pwr_constraint=$pwr_constraint" "$N"
[ "$country_ie" -gt 0 -a -n "$pwr_constraint" -a -n "$spectrum_mgmt" ] && append base_cfg "spectrum_mgmt_required=$spectrum_mgmt" "$N"
}
[ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N"
local brlist= br
json_get_values basic_rate_list basic_rate
for br in $basic_rate_list; do
hostapd_add_rate brlist "$br"
done
case "$require_mode" in
g) brlist="60 120 240" ;;
n) append base_cfg "require_ht=1" "$N";;
ac) append base_cfg "require_vht=1" "$N";;
esac
local rlist= r
json_get_values rate_list supported_rates
for r in $rate_list; do
hostapd_add_rate rlist "$r"
done
[ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
[ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
[ -n "$beacon_int" ] && append base_cfg "beacon_int=$beacon_int" "$N"
case "$airtime_mode" in
static) append base_cfg "airtime_mode=1" "$N" ;;
dynamic) append base_cfg "airtime_mode=2" "$N" ;;
limited) append base_cfg "airtime_mode=3" "$N" ;;
esac
if [ -n "$airtime_mode" ]; then
append base_cfg "airtime_update_interval=$airtime_update_interval" "$N"
fi
cat > "$config" <<EOF
driver=$driver
$base_cfg
EOF
}
hostapd_common_add_bss_config() {
config_add_string 'bssid:macaddr' 'ssid:string'
config_add_boolean wds wmm uapsd rnr
config_add_int maxassoc max_inactivity hidden
config_add_boolean disassoc_low_ack isolate short_preamble
config_add_int \
wep_rekey eap_reauth_period \
wpa_group_rekey wpa_pair_rekey wpa_master_rekey
config_add_string wps_config
config_add_boolean rsn_preauth auth_cache
config_add_int ieee80211w sae_pwe
config_add_string sae_password
config_add_string 'auth_server:host' 'server:host'
config_add_string auth_secret
config_add_int 'auth_port:port' 'port:port'
config_add_string acct_server
config_add_string acct_secret
config_add_int acct_port
config_add_string dae_client
config_add_string dae_secret
config_add_int dae_port
config_add_string nasid
config_add_string ownip
config_add_string iapp_interface
config_add_string eap_type ca_cert client_cert identity auth priv_key priv_key_pwd
config_add_int dynamic_vlan vlan_naming
config_add_string vlan_tagged_interface vlan_bridge
config_add_string 'key1:wepkey' 'key2:wepkey' 'key3:wepkey' 'key4:wepkey' 'password:wpakey'
config_add_string wpa_psk_file
config_add_boolean wps_pushbutton wps_label ext_registrar wps_pbc_in_m1
config_add_string wps_device_type wps_device_name wps_manufacturer wps_pin
config_add_boolean ieee80211r pmk_r1_push
config_add_int r0_key_lifetime reassociation_deadline
config_add_string mobility_domain r1_key_holder
config_add_array r0kh r1kh
config_add_int ieee80211w_max_timeout ieee80211w_retry_timeout
config_add_string macfilter 'macfile:file'
config_add_array 'maclist:list(macaddr)'
config_add_array bssid_blacklist
config_add_array bssid_whitelist
config_add_int mcast_rate
config_add_array basic_rate
config_add_array supported_rates
config_add_int obss_interval
config_add_string vendor_elements
config_add_int bss_load_update_period
config_add_boolean rrm wnm wnm_sleep
config_add_int chan_util_avg_period
config_add_int airtime_bss_weight
config_add_boolean airtime_bss_limit
config_add_array airtime_sta_weight
}
hostapd_set_bss_options() {
local var="$1"
local phy="$2"
local vif="$3"
wireless_vif_parse_encryption
local bss_conf
local wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_key_mgmt
local wps_config
json_get_vars \
wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey \
maxassoc max_inactivity disassoc_low_ack isolate auth_cache \
wps_pushbutton wps_label ext_registrar wps_pbc_in_m1 \
wps_device_type wps_config wps_device_name wps_manufacturer wps_pin \
wps_model_name wps_model_number wps_serial_number \
macfilter ssid wmm uapsd hidden short_preamble rsn_preauth \
iapp_interface obss_interval vendor_elements \
bss_load_update_period rrm wnm wnm_sleep chan_util_avg_period \
rnr
json_get_vars airtime_bss_weight airtime_bss_limit
json_get_values airtime_sta_weight_list airtime_sta_weight
set_default isolate 0
set_default maxassoc 256
set_default max_inactivity 0
set_default short_preamble 1
set_default disassoc_low_ack 0
set_default hidden 0
set_default wmm 1
set_default uapsd 1
set_default obss_interval 0
set_default airtime_bss_weight 0
set_default airtime_bss_limit 0
set_default rnr 0
append bss_conf "ctrl_interface=/var/run/hostapd"
if [ "$isolate" -gt 0 ]; then
append bss_conf "ap_isolate=$isolate" "$N"
fi
if [ "$maxassoc" -gt 0 ]; then
append bss_conf "max_num_sta=$maxassoc" "$N"
fi
if [ "$max_inactivity" -gt 0 ]; then
append bss_conf "ap_max_inactivity=$max_inactivity" "$N"
fi
if [ "$obss_interval" -gt 0 ]; then
append bss_conf "obss_interval=$obss_interval" "$N"
fi
append bss_conf "disassoc_low_ack=$disassoc_low_ack" "$N"
append bss_conf "preamble=$short_preamble" "$N"
append bss_conf "wmm_enabled=$wmm" "$N"
append bss_conf "ignore_broadcast_ssid=$hidden" "$N"
append bss_conf "uapsd_advertisement_enabled=$uapsd" "$N"
[ $rnr -gt 0 ] && append bss_conf "rnr=$rnr" "$N"
[ "$wpa" -gt 0 ] && {
[ -n "$wpa_group_rekey" ] && append bss_conf "wpa_group_rekey=$wpa_group_rekey" "$N"
[ -n "$wpa_pair_rekey" ] && append bss_conf "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
[ -n "$wpa_master_rekey" ] && append bss_conf "wpa_gmk_rekey=$wpa_master_rekey" "$N"
}
case "$auth_type" in
none)
wps_possible=1
# Here we make the assumption that if we're in open mode
# with WPS enabled, we got to be in unconfigured state.
wps_not_configured=1
;;
psk|sae*)
json_get_vars key wpa_psk_file
json_get_var ieee80211w ieee80211w
if [ ${#key} -lt 8 ]; then
wireless_setup_vif_failed INVALID_WPA_PSK
return 1
elif [ ${#key} -eq 64 ]; then
append bss_conf "wpa_psk=$key" "$N"
else
append bss_conf "wpa_passphrase=$key" "$N"
fi
[ -n "$wpa_psk_file" ] && {
[ -e "$wpa_psk_file" ] || touch "$wpa_psk_file"
append bss_conf "wpa_psk_file=$wpa_psk_file" "$N"
}
wps_possible=1
if [ $ieee80211w -eq 2 ] || [ $ieee80211w -eq 1 ]; then
append wpa_key_mgmt "WPA-PSK WPA-PSK-SHA256"
else
append wpa_key_mgmt "WPA-PSK"
fi
;;
eap)
json_get_vars \
auth_server auth_secret auth_port \
acct_server acct_secret acct_port \
dae_client dae_secret dae_port \
ownip \
eap_reauth_period dynamic_vlan \
vlan_naming vlan_tagged_interface \
vlan_bridge
json_get_var ieee80211w ieee80211w
# legacy compatibility
[ -n "$auth_server" ] || json_get_var auth_server server
[ -n "$auth_port" ] || json_get_var auth_port port
[ -n "$auth_secret" ] || json_get_var auth_secret key
set_default auth_port 1812
set_default acct_port 1813
set_default dae_port 3799
set_default vlan_naming 1
append bss_conf "auth_server_addr=$auth_server" "$N"
append bss_conf "auth_server_port=$auth_port" "$N"
append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
[ -n "$acct_server" ] && {
append bss_conf "acct_server_addr=$acct_server" "$N"
append bss_conf "acct_server_port=$acct_port" "$N"
[ -n "$acct_secret" ] && \
append bss_conf "acct_server_shared_secret=$acct_secret" "$N"
}
[ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N"
[ -n "$dae_client" -a -n "$dae_secret" ] && {
append bss_conf "radius_das_port=$dae_port" "$N"
append bss_conf "radius_das_client=$dae_client $dae_secret" "$N"
}
[ -n "$ownip" ] && append bss_conf "own_ip_addr=$ownip" "$N"
append bss_conf "eapol_key_index_workaround=1" "$N"
append bss_conf "ieee8021x=1" "$N"
if [ $ieee80211w -eq 2 ]; then
append wpa_key_mgmt "WPA-EAP-SHA256"
elif [ $ieee80211w -eq 1 ]; then
append wpa_key_mgmt "WPA-EAP WPA-EAP-SHA256"
else
append wpa_key_mgmt "WPA-EAP"
fi
[ -n "$dynamic_vlan" ] && {
append bss_conf "dynamic_vlan=$dynamic_vlan" "$N"
append bss_conf "vlan_naming=$vlan_naming" "$N"
[ -n "$vlan_bridge" ] && \
append bss_conf "vlan_bridge=$vlan_bridge" "$N"
[ -n "$vlan_tagged_interface" ] && \
append bss_conf "vlan_tagged_interface=$vlan_tagged_interface" "$N"
}
;;
wep)
local wep_keyidx=0
json_get_vars key
hostapd_append_wep_key bss_conf
append bss_conf "wep_default_key=$wep_keyidx" "$N"
[ -n "$wep_rekey" ] && append bss_conf "wep_rekey_period=$wep_rekey" "$N"
;;
esac
case "$auth_type" in
sae)
append bss_conf "ieee80211w=2" "$N"
wpa_key_mgmt="SAE"
json_get_var sae_pwe sae_pwe
[ -n "$sae_pwe" ] && append bss_conf "sae_pwe=$sae_pwe" "$N"
;;
sae-mixed)
append bss_conf "ieee80211w=1" "$N"
append bss_conf "sae_require_mfp=1" "$N"
append wpa_key_mgmt "SAE"
json_get_vars sae_password
[ -n "$sae_password" ] && append bss_conf "sae_password=$sae_password" "$N"
;;
owe)
append wpa_key_mgmt "OWE"
json_get_var ieee80211w ieee80211w
[ -n "$ieee80211w" ] && append bss_conf "ieee80211w=$ieee80211w" "$N"
;;
esac
local auth_algs=$((($auth_mode_shared << 1) | $auth_mode_open))
append bss_conf "auth_algs=${auth_algs:-1}" "$N"
append bss_conf "wpa=$wpa" "$N"
[ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
set_default wps_pushbutton 0
set_default wps_label 0
set_default wps_pbc_in_m1 0
config_methods=$wps_config
[ "$wps_pushbutton" -gt 0 ] && append config_methods push_button
[ "$wps_label" -gt 0 ] && append config_methods label
[ -n "$wps_possible" -a -n "$config_methods" ] && {
set_default ext_registrar 0
set_default wps_device_type "6-0050F204-1"
set_default wps_device_name "OpenWrt AP"
set_default wps_manufacturer "openwrt.org"
set_default wps_model_name "WAP"
set_default wps_model_number "123"
set_default wps_serial_number "12345"
set_default wps_pin "12345670"
wps_state=2
[ -n "$wps_configured" ] && wps_state=1
[ "$ext_registrar" -gt 0 -a -n "$network_bridge" ] && append bss_conf "upnp_iface=$network_bridge" "$N"
append bss_conf "eap_server=1" "$N"
[ -n "$wps_pin" ] && append bss_conf "ap_pin=$wps_pin" "$N"
append bss_conf "wps_state=$wps_state" "$N"
append bss_conf "ap_setup_locked=0" "$N"
append bss_conf "device_type=$wps_device_type" "$N"
append bss_conf "device_name=$wps_device_name" "$N"
append bss_conf "manufacturer=$wps_manufacturer" "$N"
append bss_conf "model_name=$wps_model_name" "$N"
append bss_conf "model_number=$wps_model_number" "$N"
append bss_conf "serial_number=$wps_serial_number" "$N"
append bss_conf "config_methods=$config_methods" "$N"
[ "$wps_pbc_in_m1" -gt 0 ] && append bss_conf "pbc_in_m1=$wps_pbc_in_m1" "$N"
}
append bss_conf "ssid=$ssid" "$N"
[ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge" "$N"
[ -n "$iapp_interface" ] && {
iapp_interface="$(uci_get_state network "$iapp_interface" ifname "$iapp_interface")"
[ -n "$iapp_interface" ] && append bss_conf "iapp_interface=$iapp_interface" "$N"
}
if [ "$wpa" -ge "1" ]; then
json_get_vars nasid ieee80211r
set_default ieee80211r 0
[ -n "$nasid" ] && append bss_conf "nas_identifier=$nasid" "$N"
if [ "$ieee80211r" -gt "0" ]; then
json_get_vars mobility_domain r0_key_lifetime r1_key_holder \
reassociation_deadline pmk_r1_push
json_get_values r0kh r0kh
json_get_values r1kh r1kh
set_default mobility_domain "4f57"
set_default r0_key_lifetime 10000
set_default r1_key_holder "00004f577274"
set_default reassociation_deadline 1000
set_default pmk_r1_push 0
append bss_conf "mobility_domain=$mobility_domain" "$N"
append bss_conf "r0_key_lifetime=$r0_key_lifetime" "$N"
append bss_conf "r1_key_holder=$r1_key_holder" "$N"
append bss_conf "reassociation_deadline=$reassociation_deadline" "$N"
append bss_conf "pmk_r1_push=$pmk_r1_push" "$N"
for kh in $r0kh; do
append bss_conf "r0kh=${kh//,/ }" "$N"
done
for kh in $r1kh; do
append bss_conf "r1kh=${kh//,/ }" "$N"
done
[ "$wpa_key_mgmt" != "${wpa_key_mgmt/EAP/}" ] && append wpa_key_mgmt "FT-EAP"
[ "$wpa_key_mgmt" != "${wpa_key_mgmt/PSK/}" ] && append wpa_key_mgmt "FT-PSK"
fi
[ -n "$wpa_key_mgmt" ] && append bss_conf "wpa_key_mgmt=$wpa_key_mgmt" "$N"
fi
if [ "$wpa" -ge "2" ]; then
if [ -n "$network_bridge" -a "$rsn_preauth" = 1 ]; then
set_default auth_cache 1
append bss_conf "rsn_preauth=1" "$N"
append bss_conf "rsn_preauth_interfaces=$network_bridge" "$N"
else
set_default auth_cache 0
fi
append bss_conf "okc=$auth_cache" "$N"
# RSN -> allow management frame protection
json_get_var ieee80211w ieee80211w
case "$ieee80211w" in
[012])
json_get_vars ieee80211w_max_timeout ieee80211w_retry_timeout
append bss_conf "ieee80211w=$ieee80211w" "$N"
[ "$ieee80211w" -gt "0" ] && {
[ -n "$ieee80211w_max_timeout" ] && \
append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
[ -n "$ieee80211w_retry_timeout" ] && \
append bss_conf "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
}
;;
esac
fi
_macfile="/var/run/hostapd-$ifname.maclist"
case "$macfilter" in
allow)
append bss_conf "macaddr_acl=1" "$N"
append bss_conf "accept_mac_file=$_macfile" "$N"
;;
deny)
append bss_conf "macaddr_acl=0" "$N"
append bss_conf "deny_mac_file=$_macfile" "$N"
;;
*)
_macfile=""
;;
esac
[ -n "$_macfile" ] && {
json_get_vars macfile
json_get_values maclist maclist
rm -f "$_macfile"
(
for mac in $maclist; do
echo "$mac"
done
[ -n "$macfile" -a -f "$macfile" ] && cat "$macfile"
) > "$_macfile"
}
[ -n "$vendor_elements" ] && append bss_conf "vendor_elements=$vendor_elements" "$N"
[ -n "$bss_load_update_period" ] && append bss_conf "bss_load_update_period=$bss_load_update_period" "$N"
[ -n "$chan_util_avg_period" ] && append bss_conf "chan_util_avg_period=$chan_util_avg_period" "$N"
[ -n "$wnm" ] && append bss_conf "bss_transition=$wnm" "$N"
[ -n "$wnm_sleep" ] && append bss_conf "wnm_sleep_mode=$wnm_sleep" "$N"
[ -n "$rrm" ] && {
append bss_conf "rrm_beacon_report=1" "$N"
append bss_conf "rrm_neighbor_report=1" "$N"
}
case "$airtime_mode" in
static)
[ -n "$airtime_sta_weight_list" ] && {
for _airtime_sta_weight in $airtime_sta_weight_list
do
# replace "-" to space between mac addr and airtime weight
append bss_conf "airtime_sta_weight=${_airtime_sta_weight/-/ }" "$N"
done
}
;;
dynamic)
if [ $airtime_bss_weight -gt 0 ]; then
append bss_conf "airtime_bss_weight=$airtime_bss_weight" "$N"
fi
;;
limited)
if [ $airtime_bss_weight -gt 0 ]; then
append bss_conf "airtime_bss_weight=$airtime_bss_weight" "$N"
fi
if [ $airtime_bss_limit -ge 0 ]; then
append bss_conf "airtime_bss_limit=$airtime_bss_limit" "$N"
fi
;;
esac
append "$var" "$bss_conf" "$N"
return 0
}
hostapd_set_log_options() {
local var="$1"
local log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
json_get_vars log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
set_default log_level 2
set_default log_80211 1
set_default log_8021x 1
set_default log_radius 1
set_default log_wpa 1
set_default log_driver 1
set_default log_iapp 1
set_default log_mlme 1
local log_mask=$(( \
($log_80211 << 0) | \
($log_8021x << 1) | \
($log_radius << 2) | \
($log_wpa << 3) | \
($log_driver << 4) | \
($log_iapp << 5) | \
($log_mlme << 6) \
))
append "$var" "logger_syslog=$log_mask" "$N"
append "$var" "logger_syslog_level=$log_level" "$N"
append "$var" "logger_stdout=$log_mask" "$N"
append "$var" "logger_stdout_level=$log_level" "$N"
return 0
}
_wpa_supplicant_common() {
local ifname="$1"
_rpath="/var/run/wpa_supplicant"
_config="${_rpath}-$ifname.conf"
}
wpa_supplicant_teardown_interface() {
_wpa_supplicant_common "$1"
rm -rf "$_rpath/$1" "$_config"
}
wpa_supplicant_prepare_interface() {
local ifname="$1"
_w_driver="$2"
_wpa_supplicant_common "$1"
json_get_vars mode wds extsta
[ -n "$network_bridge" ] && {
fail=
case "$mode" in
adhoc)
fail=1
;;
sta)
[ "$wds" = 1 ] || [ "$extsta" = 1 ] || fail=1
;;
esac
[ -n "$fail" ] && {
wireless_setup_vif_failed BRIDGE_NOT_ALLOWED
return 1
}
}
local ap_scan=
_w_mode="$mode"
_w_modestr=
[[ "$mode" = adhoc ]] && {
ap_scan="ap_scan=2"
_w_modestr="mode=1"
}
[[ "$mode" = mesh ]] && {
user_mpm="user_mpm=1"
mesh_ctrl_interface="ctrl_interface=$_rpath"
[ -n "$country" ] && {
country_code="country=$country"
}
}
wpa_supplicant_teardown_interface "$ifname"
cat > "$_config" <<EOF
$ap_scan
EOF
return 0
}
wpa_supplicant_add_network() {
local ifname="$1"
local noscan="$4"
local htmode="$3"
local disable_40mhz_scan=0
local enable_160mhz_bw=0
local enable_320mhz_bw=0
local ru_punct_bitmap=$5
local disable_csa_dfs=$6
_wpa_supplicant_common "$1"
wireless_vif_parse_encryption
json_get_vars \
ssid bssid key basic_rate mcast_rate ieee80211w \
wps_device_type wps_device_name wps_manufacturer \
wps_config wps_model_name wps_model_number \
wps_serial_number
local key_mgmt='NONE'
local enc_str=
local ru_punct_str=${ru_punct_bitmap:+ru_punct_bitmap=$ru_punct_bitmap}
local network_data=
local T=" "
local wpa_key_mgmt="WPA-PSK"
local scan_ssid="scan_ssid=1"
local freq
[[ "$_w_mode" = "adhoc" ]] && {
append network_data "mode=1" "$N$T"
[ -n "$channel" ] && {
freq="$(get_freq "$phy" "$channel")"
append network_data "fixed_freq=1" "$N$T"
append network_data "frequency=$freq" "$N$T"
}
scan_ssid="scan_ssid=0"
[ "$_w_driver" = "nl80211" ] || wpa_key_mgmt="WPA-NONE"
}
[[ "$_w_mode" = "mesh" ]] && {
append network_data "mode=5" "$N$T"
[ -n "$channel" ] && {
freq="$(get_freq "$phy" "$channel")"
append network_data "frequency=$freq" "$N$T"
}
wpa_key_mgmt="SAE"
scan_ssid=""
[ -n "$noscan" ] && {
disable_40mhz_scan=$noscan
}
[[ "$htmode" = "HE160" || "$htmode" == "EHT160" || "$htmode" == "VHT160" ]] && {
enable_160mhz_bw=1
}
[[ "$htmode" == "EHT320" ]] && {
enable_320mhz_bw=1
enable_160mhz_bw=1
}
[ -n "$disable_csa_dfs" ] && {
disable_csa_dfs="disable_csa_dfs=$disable_csa_dfs"
}
}
[[ "$_w_mode" = "adhoc" -o "$_w_mode" = "mesh" ]] && append network_data "$_w_modestr" "$N$T"
case "$auth_type" in
none) ;;
wep)
local wep_keyidx=0
hostapd_append_wep_key network_data
append network_data "wep_tx_keyidx=$wep_keyidx" "$N$T"
;;
psk)
local passphrase
key_mgmt="$wpa_key_mgmt"
if [ ${#key} -eq 64 ]; then
passphrase="psk=${key}"
else
passphrase="psk=\"${key}\""
fi
append network_data "$passphrase" "$N$T"
;;
eap)
key_mgmt='WPA-EAP'
json_get_vars eap_type identity ca_cert
[ -n "$ca_cert" ] && append network_data "ca_cert=\"$ca_cert\"" "$N$T"
[ -n "$identity" ] && append network_data "identity=\"$identity\"" "$N$T"
case "$eap_type" in
tls)
json_get_vars client_cert priv_key priv_key_pwd
append network_data "client_cert=\"$client_cert\"" "$N$T"
append network_data "private_key=\"$priv_key\"" "$N$T"
append network_data "private_key_passwd=\"$priv_key_pwd\"" "$N$T"
;;
peap|ttls)
json_get_vars auth password
set_default auth MSCHAPV2
append network_data "phase2=\"$auth\"" "$N$T"
append network_data "password=\"$password\"" "$N$T"
;;
esac
append network_data "eap=$(echo $eap_type | tr 'a-z' 'A-Z')" "$N$T"
;;
sae)
local passphrase
key_mgmt="SAE"
if [ ${#key} -eq 64 ]; then
passphrase="psk=${key}"
else
passphrase="psk=\"${key}\""
fi
append network_data "$passphrase" "$N$T"
append network_data "ieee80211w=2" "$N$T"
;;
esac
[ "$mode" = mesh ] || {
case "$wpa" in
1)
append network_data "proto=WPA" "$N$T"
;;
2)
append network_data "proto=RSN" "$N$T"
;;
esac
case "$ieee80211w" in
[012])
[ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
;;
esac
}
local beacon_int brates mrate
[ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
[ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
local bssid_blacklist bssid_whitelist saepwe
json_get_values bssid_blacklist bssid_blacklist
json_get_values bssid_whitelist bssid_whitelist
json_get_var sae_pwe sae_pwe
[ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
[ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
[ -n "$sae_pwe" ] && append saepwe "sae_pwe=$sae_pwe" "$N$T"
[ -n "$basic_rate" ] && {
local br rate_list=
for br in $basic_rate; do
wpa_supplicant_add_rate rate_list "$br"
done
[ -n "$rate_list" ] && append network_data "rates=$rate_list" "$N$T"
}
[ -n "$mcast_rate" ] && {
local mc_rate=
wpa_supplicant_add_rate mc_rate "$mcast_rate"
append network_data "mcast_rate=$mc_rate" "$N$T"
}
local ht_str
[[ "$_w_mode" = adhoc ]] || ibss_htmode=
[ -n "$ibss_htmode" ] && append network_data "htmode=$ibss_htmode" "$N$T"
config_methods=$wps_config
[ -n "$config_methods" ] && {
set_default wps_device_type "6-0050F204-1"
set_default wps_device_name "Wireless Client"
set_default wps_manufacturer "openwrt.org"
set_default wps_model_name "cmodel"
set_default wps_model_number "123"
set_default wps_serial_number "12345"
device_type="device_type=$wps_device_type"
device_name="device_name=$wps_device_name"
manufacturer="manufacturer=$wps_manufacturer"
model_name="model_name=$wps_model_name"
model_number="model_number=$wps_model_number"
serial_number="serial_number=$wps_serial_number"
config_methods="config_methods=$config_methods"
}
cat >> "$_config" <<EOF
$mesh_ctrl_interface
$user_mpm
$country_code
$device_type
$device_name
$manufacturer
$model_name
$model_number
$serial_number
$config_methods
$saepwe
$disable_csa_dfs
network={
$scan_ssid
ssid="$ssid"
key_mgmt=$key_mgmt
$network_data
disable_40mhz_scan=$disable_40mhz_scan
enable_160mhz_bw=$enable_160mhz_bw
enable_320mhz_bw=$enable_320mhz_bw
$ru_punct_str
}
EOF
return 0
}
wpa_supplicant_run() {
local ifname="$1"; shift
_wpa_supplicant_common "$ifname"
/usr/sbin/wpa_supplicant -B \
${network_bridge:+-b $network_bridge} \
-P "/var/run/wpa_supplicant-${ifname}.pid" \
-D ${_w_driver:-wext} \
-i "$ifname" \
-c "$_config" \
-C "$_rpath" \
"$@"
ret="$?"
wireless_add_process "$(cat "/var/run/wpa_supplicant-${ifname}.pid")" /usr/sbin/wpa_supplicant 1
[ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED
return $ret
}
hostapd_common_cleanup() {
killall hostapd wpa_supplicant meshd-nl80211
}

View File

@@ -1,408 +0,0 @@
# Example wpa_supplicant build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cases, these lines should use += in order not
# to override previous values of the variables.
# Uncomment following two lines and fix the paths if you have installed OpenSSL
# or GnuTLS in non-default location
#CFLAGS += -I/usr/local/openssl/include
#LIBS += -L/usr/local/openssl/lib
# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
# the kerberos files are not in the default include path. Following line can be
# used to fix build issues on such systems (krb5.h not found).
#CFLAGS += -I/usr/include/kerberos
# Example configuration for various cross-compilation platforms
#### sveasoft (e.g., for Linksys WRT54G) ######################################
#CC=mipsel-uclibc-gcc
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
###############################################################################
#### openwrt (e.g., for Linksys WRT54G) #######################################
#CC=mipsel-uclibc-gcc
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
# -I../WRT54GS/release/src/include
#LIBS = -lssl
###############################################################################
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for Agere driver
#CONFIG_DRIVER_HERMES=y
# Change include directories to match with the local setup
#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
#CFLAGS += -I../../include/wireless
# Driver interface for ndiswrapper
# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
#CONFIG_DRIVER_NDISWRAPPER=y
# Driver interface for Atmel driver
# CONFIG_DRIVER_ATMEL=y
# Driver interface for old Broadcom driver
# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
# Linux wireless extensions and does not need (or even work) with the old
# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
#CONFIG_DRIVER_BROADCOM=y
# Example path for wlioctl.h; change to match your configuration
#CFLAGS += -I/opt/WRT54GS/release/src/include
# Driver interface for Intel ipw2100/2200 driver
# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
#CONFIG_DRIVER_IPW=y
# Driver interface for Ralink driver
#CONFIG_DRIVER_RALINK=y
# Driver interface for generic Linux wireless extensions
CONFIG_DRIVER_WEXT=y
# Driver interface for Linux drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
#CONFIG_DRIVER_BSD=y
#CFLAGS += -I/usr/local/include
#LIBS += -L/usr/local/lib
#LIBS_p += -L/usr/local/lib
#LIBS_c += -L/usr/local/lib
# Driver interface for Windows NDIS
#CONFIG_DRIVER_NDIS=y
#CFLAGS += -I/usr/include/w32api/ddk
#LIBS += -L/usr/local/lib
# For native build using mingw
#CONFIG_NATIVE_WINDOWS=y
# Additional directories for cross-compilation on Linux host for mingw target
#CFLAGS += -I/opt/mingw/mingw32/include/ddk
#LIBS += -L/opt/mingw/mingw32/lib
#CC=mingw32-gcc
# By default, driver_ndis uses WinPcap for low-level operations. This can be
# replaced with the following option which replaces WinPcap calls with NDISUIO.
# However, this requires that WZC is disabled (net stop wzcsvc) before starting
# wpa_supplicant.
# CONFIG_USE_NDISUIO=y
# Driver interface for development testing
#CONFIG_DRIVER_TEST=y
# Include client MLME (management frame processing) for test driver
# This can be used to test MLME operations in hostapd with the test interface.
# space.
#CONFIG_CLIENT_MLME=y
# Driver interface for wired Ethernet drivers
CONFIG_DRIVER_WIRED=y
# Driver interface for the Broadcom RoboSwitch family
#CONFIG_DRIVER_ROBOSWITCH=y
# Driver interface for no driver (e.g., WPS ER only)
#CONFIG_DRIVER_NONE=y
# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
# included)
CONFIG_IEEE8021X_EAPOL=y
# EAP-MD5
CONFIG_EAP_MD5=y
# EAP-MSCHAPv2
CONFIG_EAP_MSCHAPV2=y
# EAP-TLS
CONFIG_EAP_TLS=y
# EAL-PEAP
CONFIG_EAP_PEAP=y
# EAP-TTLS
CONFIG_EAP_TTLS=y
# EAP-FAST
# Note: Default OpenSSL package does not include support for all the
# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
# the OpenSSL library must be patched (openssl-0.9.8d-tls-extensions.patch)
# to add the needed functions.
#CONFIG_EAP_FAST=y
# EAP-GTC
CONFIG_EAP_GTC=y
# EAP-OTP
CONFIG_EAP_OTP=y
# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
#CONFIG_EAP_SIM=y
# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
#CONFIG_EAP_PSK=y
# EAP-PAX
#CONFIG_EAP_PAX=y
# LEAP
CONFIG_EAP_LEAP=y
# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
#CONFIG_EAP_AKA=y
# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
# This requires CONFIG_EAP_AKA to be enabled, too.
#CONFIG_EAP_AKA_PRIME=y
# Enable USIM simulator (Milenage) for EAP-AKA
#CONFIG_USIM_SIMULATOR=y
# EAP-SAKE
#CONFIG_EAP_SAKE=y
# EAP-GPSK
#CONFIG_EAP_GPSK=y
# Include support for optional SHA256 cipher suite in EAP-GPSK
#CONFIG_EAP_GPSK_SHA256=y
# EAP-TNC and related Trusted Network Connect support (experimental)
#CONFIG_EAP_TNC=y
# Wi-Fi Protected Setup (WPS)
CONFIG_WPS=y
# WPS external registrar (ER)
CONFIG_WPS_ER=y
# EAP-IKEv2
#CONFIG_EAP_IKEV2=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
CONFIG_PKCS12=y
# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
# engine.
CONFIG_SMARTCARD=y
# PC/SC interface for smartcards (USIM, GSM SIM)
# Enable this if EAP-SIM or EAP-AKA is included
#CONFIG_PCSC=y
# Development testing
#CONFIG_EAPOL_TEST=y
# Select control interface backend for external programs, e.g, wpa_cli:
# unix = UNIX domain sockets (default for Linux/*BSD)
# udp = UDP sockets using localhost (127.0.0.1)
# named_pipe = Windows Named Pipe (default for Windows)
# y = use default (backwards compatibility)
# If this option is commented out, control interface is not included in the
# build.
CONFIG_CTRL_IFACE=y
# Include support for GNU Readline and History Libraries in wpa_cli.
# When building a wpa_cli binary for distribution, please note that these
# libraries are licensed under GPL and as such, BSD license may not apply for
# the resulting binary.
#CONFIG_READLINE=y
# Remove debugging code that is printing out debug message to stdout.
# This can be used to reduce the size of the wpa_supplicant considerably
# if debugging code is not needed. The size reduction can be around 35%
# (e.g., 90 kB).
#CONFIG_NO_STDOUT_DEBUG=y
# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
# 35-50 kB in code size.
#CONFIG_NO_WPA=y
# Remove WPA2 support. This allows WPA to be used, but removes WPA2 code to
# save about 1 kB in code size when building only WPA-Personal (no EAP support)
# or 6 kB if building for WPA-Enterprise.
#CONFIG_NO_WPA2=y
# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
# This option can be used to reduce code size by removing support for
# converting ASCII passphrases into PSK. If this functionality is removed, the
# PSK can only be configured as the 64-octet hexstring (e.g., from
# wpa_passphrase). This saves about 0.5 kB in code size.
#CONFIG_NO_WPA_PASSPHRASE=y
# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
# This can be used if ap_scan=1 mode is never enabled.
#CONFIG_NO_SCAN_PROCESSING=y
# Select configuration backend:
# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
# path is given on command line, not here; this option is just used to
# select the backend that allows configuration files to be used)
# winreg = Windows registry (see win_example.reg for an example)
CONFIG_BACKEND=file
# Remove configuration write functionality (i.e., to allow the configuration
# file to be updated based on runtime configuration changes). The runtime
# configuration can still be changed, the changes are just not going to be
# persistent over restarts. This option can be used to reduce code size by
# about 3.5 kB.
#CONFIG_NO_CONFIG_WRITE=y
# Remove support for configuration blobs to reduce code size by about 1.5 kB.
#CONFIG_NO_CONFIG_BLOBS=y
# Select program entry point implementation:
# main = UNIX/POSIX like main() function (default)
# main_winsvc = Windows service (read parameters from registry)
# main_none = Very basic example (development use only)
#CONFIG_MAIN=main
# Select wrapper for operatins system and C library specific functions
# unix = UNIX/POSIX like systems (default)
# win32 = Windows systems
# none = Empty template
#CONFIG_OS=unix
# Select event loop implementation
# eloop = select() loop (default)
# eloop_win = Windows events and WaitForMultipleObject() loop
# eloop_none = Empty template
#CONFIG_ELOOP=eloop
# Select layer 2 packet implementation
# linux = Linux packet socket (default)
# pcap = libpcap/libdnet/WinPcap
# freebsd = FreeBSD libpcap
# winpcap = WinPcap with receive thread
# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
# none = Empty template
#CONFIG_L2_PACKET=linux
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
CONFIG_PEERKEY=y
# IEEE 802.11w (management frame protection)
# This version is an experimental implementation based on IEEE 802.11w/D1.0
# draft and is subject to change since the standard has not yet been finalized.
# Driver support is also needed for IEEE 802.11w.
CONFIG_IEEE80211W=y
# Select TLS implementation
# openssl = OpenSSL (default)
# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
# internal = Internal TLSv1 implementation (experimental)
# none = Empty template
CONFIG_TLS=internal
# Whether to enable TLS/IA support, which is required for EAP-TTLSv1.
# You need CONFIG_TLS=gnutls for this to have any effect. Please note that
# even though the core GnuTLS library is released under LGPL, this extra
# library uses GPL and as such, the terms of GPL apply to the combination
# of wpa_supplicant and GnuTLS if this option is enabled. BSD license may not
# apply for distribution of the resulting binary.
#CONFIG_GNUTLS_EXTRA=y
# If CONFIG_TLS=internal is used, additional library and include paths are
# needed for LibTomMath. Alternatively, an integrated, minimal version of
# LibTomMath can be used. See beginning of libtommath.c for details on benefits
# and drawbacks of this option.
CONFIG_INTERNAL_LIBTOMMATH=y
#ifndef CONFIG_INTERNAL_LIBTOMMATH
#LTM_PATH=/usr/src/libtommath-0.39
#CFLAGS += -I$(LTM_PATH)
#LIBS += -L$(LTM_PATH)
#LIBS_p += -L$(LTM_PATH)
#endif
# At the cost of about 4 kB of additional binary size, the internal LibTomMath
# can be configured to include faster routines for exptmod, sqr, and div to
# speed up DH and RSA calculation considerably
CONFIG_INTERNAL_LIBTOMMATH_FAST=y
# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
# This is only for Windows builds and requires WMI-related header files and
# WbemUuid.Lib from Platform SDK even when building with MinGW.
#CONFIG_NDIS_EVENTS_INTEGRATED=y
#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
# Add support for old DBus control interface
# (fi.epitest.hostap.WPASupplicant)
#CONFIG_CTRL_IFACE_DBUS=y
# Add support for new DBus control interface
# (fi.w1.hostap.wpa_supplicant1)
#CONFIG_CTRL_IFACE_DBUS_NEW=y
# Add introspection support for new DBus control interface
#CONFIG_CTRL_IFACE_DBUS_INTRO=y
# Add support for loading EAP methods dynamically as shared libraries.
# When this option is enabled, each EAP method can be either included
# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
# be loaded in the beginning of the wpa_supplicant configuration file
# (see load_dynamic_eap parameter in the example file) before being used in
# the network blocks.
#
# Note that some shared parts of EAP methods are included in the main program
# and in order to be able to use dynamic EAP methods using these parts, the
# main program must have been build with the EAP method enabled (=y or =dyn).
# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
# unless at least one of them was included in the main build to force inclusion
# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
# in the main build to be able to load these methods dynamically.
#
# Please also note that using dynamic libraries will increase the total binary
# size. Thus, it may not be the best option for targets that have limited
# amount of memory/flash.
#CONFIG_DYNAMIC_EAP_METHODS=y
# IEEE Std 802.11r-2008 (Fast BSS Transition)
#CONFIG_IEEE80211R=y
# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
#CONFIG_DEBUG_FILE=y
# Enable privilege separation (see README 'Privilege separation' for details)
#CONFIG_PRIVSEP=y
# Enable mitigation against certain attacks against TKIP by delaying Michael
# MIC error reports by a random amount of time between 0 and 60 seconds
#CONFIG_DELAYED_MIC_ERROR_REPORT=y
# Enable tracing code for developer debugging
# This tracks use of memory allocations and other registrations and reports
# incorrect use with a backtrace of call (or allocation) location.
#CONFIG_WPA_TRACE=y
# For BSD, comment out these.
#LIBS += -lexecinfo
#LIBS_p += -lexecinfo
#LIBS_c += -lexecinfo
# Use libbfd to get more details for developer debugging
# This enables use of libbfd to get more detailed symbols for the backtraces
# generated by CONFIG_WPA_TRACE=y.
#CONFIG_WPA_TRACE_BFD=y
# For BSD, comment out these.
#LIBS += -lbfd -liberty -lz
#LIBS_p += -lbfd -liberty -lz
#LIBS_c += -lbfd -liberty -lz
CONFIG_NO_RANDOM_POOL=y
NEED_80211_COMMON=y
CONFIG_IBSS_RSN=y
CONFIG_LIBNL32=y
CONFIG_LIBNL3_ROUTE=y

View File

@@ -1,121 +0,0 @@
# Example wpa_supplicant build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cases, these lines should use += in order not
# to override previous values of the variables.
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for generic Linux wireless extensions
CONFIG_DRIVER_WEXT=y
# Driver interface for Linux drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# Driver interface for wired Ethernet drivers
CONFIG_DRIVER_WIRED=y
# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
# included)
CONFIG_IEEE8021X_EAPOL=y
# EAP-MD5
CONFIG_EAP_MD5=y
# EAP-MSCHAPv2
CONFIG_EAP_MSCHAPV2=y
# EAP-TLS
CONFIG_EAP_TLS=y
# EAL-PEAP
CONFIG_EAP_PEAP=y
# EAP-TTLS
CONFIG_EAP_TTLS=y
# EAP-GTC
CONFIG_EAP_GTC=y
# EAP-OTP
CONFIG_EAP_OTP=y
# LEAP
CONFIG_EAP_LEAP=y
# Wi-Fi Protected Setup (WPS)
CONFIG_WPS=y
# WPS external registrar (ER)
CONFIG_WPS_ER=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
CONFIG_PKCS12=y
# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
# engine.
CONFIG_SMARTCARD=y
# Select control interface backend for external programs, e.g, wpa_cli:
# unix = UNIX domain sockets (default for Linux/*BSD)
# udp = UDP sockets using localhost (127.0.0.1)
# named_pipe = Windows Named Pipe (default for Windows)
# y = use default (backwards compatibility)
# If this option is commented out, control interface is not included in the
# build.
CONFIG_CTRL_IFACE=y
# Select configuration backend:
# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
# path is given on command line, not here; this option is just used to
# select the backend that allows configuration files to be used)
# winreg = Windows registry (see win_example.reg for an example)
CONFIG_BACKEND=file
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
CONFIG_PEERKEY=y
# IEEE 802.11w (management frame protection)
# This version is an experimental implementation based on IEEE 802.11w/D1.0
# draft and is subject to change since the standard has not yet been finalized.
# Driver support is also needed for IEEE 802.11w.
CONFIG_IEEE80211W=y
# Select TLS implementation
# openssl = OpenSSL (default)
# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
# internal = Internal TLSv1 implementation (experimental)
# none = Empty template
CONFIG_TLS=openssl
# If CONFIG_TLS=internal is used, additional library and include paths are
# needed for LibTomMath. Alternatively, an integrated, minimal version of
# LibTomMath can be used. See beginning of libtommath.c for details on benefits
# and drawbacks of this option.
CONFIG_INTERNAL_LIBTOMMATH=y
# At the cost of about 4 kB of additional binary size, the internal LibTomMath
# can be configured to include faster routines for exptmod, sqr, and div to
# speed up DH and RSA calculation considerably
CONFIG_INTERNAL_LIBTOMMATH_FAST=y
CONFIG_NO_RANDOM_POOL=y
NEED_80211_COMMON=y
CONFIG_IBSS_RSN=y
CONFIG_LIBNL32=y
CONFIG_LIBNL3_ROUTE=y
# Driver interface for MACsec (Only for wired network)
CONFIG_DRIVER_MACSEC_QCA=y
# Enable MACsec support for wpa_supplicant
CONFIG_MACSEC=y

View File

@@ -1,415 +0,0 @@
# Example wpa_supplicant build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cases, these lines should use += in order not
# to override previous values of the variables.
# Uncomment following two lines and fix the paths if you have installed OpenSSL
# or GnuTLS in non-default location
#CFLAGS += -I/usr/local/openssl/include
#LIBS += -L/usr/local/openssl/lib
# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
# the kerberos files are not in the default include path. Following line can be
# used to fix build issues on such systems (krb5.h not found).
#CFLAGS += -I/usr/include/kerberos
# Example configuration for various cross-compilation platforms
#### sveasoft (e.g., for Linksys WRT54G) ######################################
#CC=mipsel-uclibc-gcc
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
###############################################################################
#### openwrt (e.g., for Linksys WRT54G) #######################################
#CC=mipsel-uclibc-gcc
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
# -I../WRT54GS/release/src/include
#LIBS = -lssl
###############################################################################
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for Agere driver
#CONFIG_DRIVER_HERMES=y
# Change include directories to match with the local setup
#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
#CFLAGS += -I../../include/wireless
# Driver interface for ndiswrapper
# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
#CONFIG_DRIVER_NDISWRAPPER=y
# Driver interface for Atmel driver
# CONFIG_DRIVER_ATMEL=y
# Driver interface for old Broadcom driver
# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
# Linux wireless extensions and does not need (or even work) with the old
# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
#CONFIG_DRIVER_BROADCOM=y
# Example path for wlioctl.h; change to match your configuration
#CFLAGS += -I/opt/WRT54GS/release/src/include
# Driver interface for Intel ipw2100/2200 driver
# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
#CONFIG_DRIVER_IPW=y
# Driver interface for Ralink driver
#CONFIG_DRIVER_RALINK=y
# Driver interface for generic Linux wireless extensions
CONFIG_DRIVER_WEXT=y
# Driver interface for Linux drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
#CONFIG_DRIVER_BSD=y
#CFLAGS += -I/usr/local/include
#LIBS += -L/usr/local/lib
#LIBS_p += -L/usr/local/lib
#LIBS_c += -L/usr/local/lib
# Driver interface for Windows NDIS
#CONFIG_DRIVER_NDIS=y
#CFLAGS += -I/usr/include/w32api/ddk
#LIBS += -L/usr/local/lib
# For native build using mingw
#CONFIG_NATIVE_WINDOWS=y
# Additional directories for cross-compilation on Linux host for mingw target
#CFLAGS += -I/opt/mingw/mingw32/include/ddk
#LIBS += -L/opt/mingw/mingw32/lib
#CC=mingw32-gcc
# By default, driver_ndis uses WinPcap for low-level operations. This can be
# replaced with the following option which replaces WinPcap calls with NDISUIO.
# However, this requires that WZC is disabled (net stop wzcsvc) before starting
# wpa_supplicant.
# CONFIG_USE_NDISUIO=y
# Driver interface for development testing
#CONFIG_DRIVER_TEST=y
# Include client MLME (management frame processing) for test driver
# This can be used to test MLME operations in hostapd with the test interface.
# space.
#CONFIG_CLIENT_MLME=y
# Driver interface for wired Ethernet drivers
CONFIG_DRIVER_WIRED=y
# Driver interface for the Broadcom RoboSwitch family
#CONFIG_DRIVER_ROBOSWITCH=y
# Driver interface for no driver (e.g., WPS ER only)
#CONFIG_DRIVER_NONE=y
# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
# included)
CONFIG_IEEE8021X_EAPOL=y
# EAP-MD5
CONFIG_EAP_MD5=y
# EAP-MSCHAPv2
CONFIG_EAP_MSCHAPV2=y
# EAP-TLS
CONFIG_EAP_TLS=y
# EAL-PEAP
CONFIG_EAP_PEAP=y
# EAP-TTLS
CONFIG_EAP_TTLS=y
# EAP-FAST
# Note: Default OpenSSL package does not include support for all the
# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
# the OpenSSL library must be patched (openssl-0.9.8d-tls-extensions.patch)
# to add the needed functions.
#CONFIG_EAP_FAST=y
# EAP-GTC
CONFIG_EAP_GTC=y
# EAP-OTP
CONFIG_EAP_OTP=y
# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
#CONFIG_EAP_SIM=y
# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
#CONFIG_EAP_PSK=y
# EAP-PAX
#CONFIG_EAP_PAX=y
# LEAP
CONFIG_EAP_LEAP=y
# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
#CONFIG_EAP_AKA=y
# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
# This requires CONFIG_EAP_AKA to be enabled, too.
#CONFIG_EAP_AKA_PRIME=y
# Enable USIM simulator (Milenage) for EAP-AKA
#CONFIG_USIM_SIMULATOR=y
# EAP-SAKE
#CONFIG_EAP_SAKE=y
# EAP-GPSK
#CONFIG_EAP_GPSK=y
# Include support for optional SHA256 cipher suite in EAP-GPSK
#CONFIG_EAP_GPSK_SHA256=y
# EAP-TNC and related Trusted Network Connect support (experimental)
#CONFIG_EAP_TNC=y
# Wi-Fi Protected Setup (WPS)
CONFIG_WPS=y
# EAP-IKEv2
#CONFIG_EAP_IKEV2=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
CONFIG_PKCS12=y
# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
# engine.
CONFIG_SMARTCARD=y
# PC/SC interface for smartcards (USIM, GSM SIM)
# Enable this if EAP-SIM or EAP-AKA is included
#CONFIG_PCSC=y
# Development testing
#CONFIG_EAPOL_TEST=y
# Select control interface backend for external programs, e.g, wpa_cli:
# unix = UNIX domain sockets (default for Linux/*BSD)
# udp = UDP sockets using localhost (127.0.0.1)
# named_pipe = Windows Named Pipe (default for Windows)
# y = use default (backwards compatibility)
# If this option is commented out, control interface is not included in the
# build.
CONFIG_CTRL_IFACE=y
# Include support for GNU Readline and History Libraries in wpa_cli.
# When building a wpa_cli binary for distribution, please note that these
# libraries are licensed under GPL and as such, BSD license may not apply for
# the resulting binary.
#CONFIG_READLINE=y
# Remove debugging code that is printing out debug message to stdout.
# This can be used to reduce the size of the wpa_supplicant considerably
# if debugging code is not needed. The size reduction can be around 35%
# (e.g., 90 kB).
#CONFIG_NO_STDOUT_DEBUG=y
# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
# 35-50 kB in code size.
#CONFIG_NO_WPA=y
# Remove WPA2 support. This allows WPA to be used, but removes WPA2 code to
# save about 1 kB in code size when building only WPA-Personal (no EAP support)
# or 6 kB if building for WPA-Enterprise.
#CONFIG_NO_WPA2=y
# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
# This option can be used to reduce code size by removing support for
# converting ASCII passphrases into PSK. If this functionality is removed, the
# PSK can only be configured as the 64-octet hexstring (e.g., from
# wpa_passphrase). This saves about 0.5 kB in code size.
#CONFIG_NO_WPA_PASSPHRASE=y
# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
# This can be used if ap_scan=1 mode is never enabled.
#CONFIG_NO_SCAN_PROCESSING=y
# Select configuration backend:
# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
# path is given on command line, not here; this option is just used to
# select the backend that allows configuration files to be used)
# winreg = Windows registry (see win_example.reg for an example)
CONFIG_BACKEND=file
# Remove configuration write functionality (i.e., to allow the configuration
# file to be updated based on runtime configuration changes). The runtime
# configuration can still be changed, the changes are just not going to be
# persistent over restarts. This option can be used to reduce code size by
# about 3.5 kB.
#CONFIG_NO_CONFIG_WRITE=y
# Remove support for configuration blobs to reduce code size by about 1.5 kB.
#CONFIG_NO_CONFIG_BLOBS=y
# Select program entry point implementation:
# main = UNIX/POSIX like main() function (default)
# main_winsvc = Windows service (read parameters from registry)
# main_none = Very basic example (development use only)
#CONFIG_MAIN=main
# Select wrapper for operatins system and C library specific functions
# unix = UNIX/POSIX like systems (default)
# win32 = Windows systems
# none = Empty template
#CONFIG_OS=unix
# Select event loop implementation
# eloop = select() loop (default)
# eloop_win = Windows events and WaitForMultipleObject() loop
# eloop_none = Empty template
#CONFIG_ELOOP=eloop
# Select layer 2 packet implementation
# linux = Linux packet socket (default)
# pcap = libpcap/libdnet/WinPcap
# freebsd = FreeBSD libpcap
# winpcap = WinPcap with receive thread
# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
# none = Empty template
#CONFIG_L2_PACKET=linux
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
CONFIG_PEERKEY=y
# IEEE 802.11w (management frame protection)
# This version is an experimental implementation based on IEEE 802.11w/D1.0
# draft and is subject to change since the standard has not yet been finalized.
# Driver support is also needed for IEEE 802.11w.
CONFIG_IEEE80211W=y
# Select TLS implementation
# openssl = OpenSSL (default)
# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
# internal = Internal TLSv1 implementation (experimental)
# none = Empty template
CONFIG_TLS=internal
# Whether to enable TLS/IA support, which is required for EAP-TTLSv1.
# You need CONFIG_TLS=gnutls for this to have any effect. Please note that
# even though the core GnuTLS library is released under LGPL, this extra
# library uses GPL and as such, the terms of GPL apply to the combination
# of wpa_supplicant and GnuTLS if this option is enabled. BSD license may not
# apply for distribution of the resulting binary.
#CONFIG_GNUTLS_EXTRA=y
# If CONFIG_TLS=internal is used, additional library and include paths are
# needed for LibTomMath. Alternatively, an integrated, minimal version of
# LibTomMath can be used. See beginning of libtommath.c for details on benefits
# and drawbacks of this option.
CONFIG_INTERNAL_LIBTOMMATH=y
#ifndef CONFIG_INTERNAL_LIBTOMMATH
#LTM_PATH=/usr/src/libtommath-0.39
#CFLAGS += -I$(LTM_PATH)
#LIBS += -L$(LTM_PATH)
#LIBS_p += -L$(LTM_PATH)
#endif
# At the cost of about 4 kB of additional binary size, the internal LibTomMath
# can be configured to include faster routines for exptmod, sqr, and div to
# speed up DH and RSA calculation considerably
CONFIG_INTERNAL_LIBTOMMATH_FAST=y
# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
# This is only for Windows builds and requires WMI-related header files and
# WbemUuid.Lib from Platform SDK even when building with MinGW.
#CONFIG_NDIS_EVENTS_INTEGRATED=y
#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
# Add support for old DBus control interface
# (fi.epitest.hostap.WPASupplicant)
#CONFIG_CTRL_IFACE_DBUS=y
# Add support for new DBus control interface
# (fi.w1.hostap.wpa_supplicant1)
#CONFIG_CTRL_IFACE_DBUS_NEW=y
# Add introspection support for new DBus control interface
#CONFIG_CTRL_IFACE_DBUS_INTRO=y
# Add support for loading EAP methods dynamically as shared libraries.
# When this option is enabled, each EAP method can be either included
# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
# be loaded in the beginning of the wpa_supplicant configuration file
# (see load_dynamic_eap parameter in the example file) before being used in
# the network blocks.
#
# Note that some shared parts of EAP methods are included in the main program
# and in order to be able to use dynamic EAP methods using these parts, the
# main program must have been build with the EAP method enabled (=y or =dyn).
# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
# unless at least one of them was included in the main build to force inclusion
# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
# in the main build to be able to load these methods dynamically.
#
# Please also note that using dynamic libraries will increase the total binary
# size. Thus, it may not be the best option for targets that have limited
# amount of memory/flash.
#CONFIG_DYNAMIC_EAP_METHODS=y
# IEEE Std 802.11r-2008 (Fast BSS Transition)
#CONFIG_IEEE80211R=y
# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
#CONFIG_DEBUG_FILE=y
# Enable privilege separation (see README 'Privilege separation' for details)
#CONFIG_PRIVSEP=y
# Enable mitigation against certain attacks against TKIP by delaying Michael
# MIC error reports by a random amount of time between 0 and 60 seconds
#CONFIG_DELAYED_MIC_ERROR_REPORT=y
# Enable tracing code for developer debugging
# This tracks use of memory allocations and other registrations and reports
# incorrect use with a backtrace of call (or allocation) location.
#CONFIG_WPA_TRACE=y
# For BSD, comment out these.
#LIBS += -lexecinfo
#LIBS_p += -lexecinfo
#LIBS_c += -lexecinfo
# Use libbfd to get more details for developer debugging
# This enables use of libbfd to get more detailed symbols for the backtraces
# generated by CONFIG_WPA_TRACE=y.
#CONFIG_WPA_TRACE_BFD=y
# For BSD, comment out these.
#LIBS += -lbfd -liberty -lz
#LIBS_p += -lbfd -liberty -lz
#LIBS_c += -lbfd -liberty -lz
CONFIG_NO_RANDOM_POOL=y
NEED_80211_COMMON=y
CONFIG_MESH=y
CONFIG_SAE=y
CONFIG_AP=y
CONFIG_IEEE80211AC=y
CONFIG_IEEE80211N=y
CONFIG_LIBNL32=y
CONFIG_LIBNL3_ROUTE=y
CONFIG_TDLS=y
CONFIG_BUILD_WPA_CLIENT_SO=y
NEED_DH_GROUPS_ALL=y
CONFIG_HE_OVERRIDES=y

View File

@@ -1,401 +0,0 @@
# Example wpa_supplicant build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cases, these lines should use += in order not
# to override previous values of the variables.
# Uncomment following two lines and fix the paths if you have installed OpenSSL
# or GnuTLS in non-default location
#CFLAGS += -I/usr/local/openssl/include
#LIBS += -L/usr/local/openssl/lib
# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
# the kerberos files are not in the default include path. Following line can be
# used to fix build issues on such systems (krb5.h not found).
#CFLAGS += -I/usr/include/kerberos
# Example configuration for various cross-compilation platforms
#### sveasoft (e.g., for Linksys WRT54G) ######################################
#CC=mipsel-uclibc-gcc
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
###############################################################################
#### openwrt (e.g., for Linksys WRT54G) #######################################
#CC=mipsel-uclibc-gcc
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
# -I../WRT54GS/release/src/include
#LIBS = -lssl
###############################################################################
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for Agere driver
#CONFIG_DRIVER_HERMES=y
# Change include directories to match with the local setup
#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
#CFLAGS += -I../../include/wireless
# Driver interface for ndiswrapper
# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
#CONFIG_DRIVER_NDISWRAPPER=y
# Driver interface for Atmel driver
# CONFIG_DRIVER_ATMEL=y
# Driver interface for old Broadcom driver
# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
# Linux wireless extensions and does not need (or even work) with the old
# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
#CONFIG_DRIVER_BROADCOM=y
# Example path for wlioctl.h; change to match your configuration
#CFLAGS += -I/opt/WRT54GS/release/src/include
# Driver interface for Intel ipw2100/2200 driver
# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
#CONFIG_DRIVER_IPW=y
# Driver interface for Ralink driver
#CONFIG_DRIVER_RALINK=y
# Driver interface for generic Linux wireless extensions
CONFIG_DRIVER_WEXT=y
# Driver interface for Linux drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
#CONFIG_DRIVER_BSD=y
#CFLAGS += -I/usr/local/include
#LIBS += -L/usr/local/lib
#LIBS_p += -L/usr/local/lib
#LIBS_c += -L/usr/local/lib
# Driver interface for Windows NDIS
#CONFIG_DRIVER_NDIS=y
#CFLAGS += -I/usr/include/w32api/ddk
#LIBS += -L/usr/local/lib
# For native build using mingw
#CONFIG_NATIVE_WINDOWS=y
# Additional directories for cross-compilation on Linux host for mingw target
#CFLAGS += -I/opt/mingw/mingw32/include/ddk
#LIBS += -L/opt/mingw/mingw32/lib
#CC=mingw32-gcc
# By default, driver_ndis uses WinPcap for low-level operations. This can be
# replaced with the following option which replaces WinPcap calls with NDISUIO.
# However, this requires that WZC is disabled (net stop wzcsvc) before starting
# wpa_supplicant.
# CONFIG_USE_NDISUIO=y
# Driver interface for development testing
#CONFIG_DRIVER_TEST=y
# Include client MLME (management frame processing) for test driver
# This can be used to test MLME operations in hostapd with the test interface.
# space.
#CONFIG_CLIENT_MLME=y
# Driver interface for wired Ethernet drivers
CONFIG_DRIVER_WIRED=y
# Driver interface for the Broadcom RoboSwitch family
#CONFIG_DRIVER_ROBOSWITCH=y
# Driver interface for no driver (e.g., WPS ER only)
#CONFIG_DRIVER_NONE=y
# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
# included)
# CONFIG_IEEE8021X_EAPOL=y
# EAP-MD5
# CONFIG_EAP_MD5=y
# EAP-MSCHAPv2
# CONFIG_EAP_MSCHAPV2=y
# EAP-TLS
# CONFIG_EAP_TLS=y
# EAL-PEAP
# CONFIG_EAP_PEAP=y
# EAP-TTLS
# CONFIG_EAP_TTLS=y
# EAP-FAST
# Note: Default OpenSSL package does not include support for all the
# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
# the OpenSSL library must be patched (openssl-0.9.8d-tls-extensions.patch)
# to add the needed functions.
#CONFIG_EAP_FAST=y
# EAP-GTC
# CONFIG_EAP_GTC=y
# EAP-OTP
# CONFIG_EAP_OTP=y
# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
#CONFIG_EAP_SIM=y
# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
#CONFIG_EAP_PSK=y
# EAP-PAX
#CONFIG_EAP_PAX=y
# LEAP
# CONFIG_EAP_LEAP=y
# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
#CONFIG_EAP_AKA=y
# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
# This requires CONFIG_EAP_AKA to be enabled, too.
#CONFIG_EAP_AKA_PRIME=y
# Enable USIM simulator (Milenage) for EAP-AKA
#CONFIG_USIM_SIMULATOR=y
# EAP-SAKE
#CONFIG_EAP_SAKE=y
# EAP-GPSK
#CONFIG_EAP_GPSK=y
# Include support for optional SHA256 cipher suite in EAP-GPSK
#CONFIG_EAP_GPSK_SHA256=y
# EAP-TNC and related Trusted Network Connect support (experimental)
#CONFIG_EAP_TNC=y
# Wi-Fi Protected Setup (WPS)
#CONFIG_WPS=y
# EAP-IKEv2
#CONFIG_EAP_IKEV2=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
# CONFIG_PKCS12=y
# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
# engine.
# CONFIG_SMARTCARD=y
# PC/SC interface for smartcards (USIM, GSM SIM)
# Enable this if EAP-SIM or EAP-AKA is included
#CONFIG_PCSC=y
# Development testing
#CONFIG_EAPOL_TEST=y
# Select control interface backend for external programs, e.g, wpa_cli:
# unix = UNIX domain sockets (default for Linux/*BSD)
# udp = UDP sockets using localhost (127.0.0.1)
# named_pipe = Windows Named Pipe (default for Windows)
# y = use default (backwards compatibility)
# If this option is commented out, control interface is not included in the
# build.
CONFIG_CTRL_IFACE=y
# Include support for GNU Readline and History Libraries in wpa_cli.
# When building a wpa_cli binary for distribution, please note that these
# libraries are licensed under GPL and as such, BSD license may not apply for
# the resulting binary.
#CONFIG_READLINE=y
# Remove debugging code that is printing out debug message to stdout.
# This can be used to reduce the size of the wpa_supplicant considerably
# if debugging code is not needed. The size reduction can be around 35%
# (e.g., 90 kB).
#CONFIG_NO_STDOUT_DEBUG=y
# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
# 35-50 kB in code size.
#CONFIG_NO_WPA=y
# Remove WPA2 support. This allows WPA to be used, but removes WPA2 code to
# save about 1 kB in code size when building only WPA-Personal (no EAP support)
# or 6 kB if building for WPA-Enterprise.
#CONFIG_NO_WPA2=y
# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
# This option can be used to reduce code size by removing support for
# converting ASCII passphrases into PSK. If this functionality is removed, the
# PSK can only be configured as the 64-octet hexstring (e.g., from
# wpa_passphrase). This saves about 0.5 kB in code size.
#CONFIG_NO_WPA_PASSPHRASE=y
# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
# This can be used if ap_scan=1 mode is never enabled.
#CONFIG_NO_SCAN_PROCESSING=y
# Select configuration backend:
# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
# path is given on command line, not here; this option is just used to
# select the backend that allows configuration files to be used)
# winreg = Windows registry (see win_example.reg for an example)
CONFIG_BACKEND=file
# Remove configuration write functionality (i.e., to allow the configuration
# file to be updated based on runtime configuration changes). The runtime
# configuration can still be changed, the changes are just not going to be
# persistent over restarts. This option can be used to reduce code size by
# about 3.5 kB.
#CONFIG_NO_CONFIG_WRITE=y
# Remove support for configuration blobs to reduce code size by about 1.5 kB.
#CONFIG_NO_CONFIG_BLOBS=y
# Select program entry point implementation:
# main = UNIX/POSIX like main() function (default)
# main_winsvc = Windows service (read parameters from registry)
# main_none = Very basic example (development use only)
#CONFIG_MAIN=main
# Select wrapper for operatins system and C library specific functions
# unix = UNIX/POSIX like systems (default)
# win32 = Windows systems
# none = Empty template
#CONFIG_OS=unix
# Select event loop implementation
# eloop = select() loop (default)
# eloop_win = Windows events and WaitForMultipleObject() loop
# eloop_none = Empty template
#CONFIG_ELOOP=eloop
# Select layer 2 packet implementation
# linux = Linux packet socket (default)
# pcap = libpcap/libdnet/WinPcap
# freebsd = FreeBSD libpcap
# winpcap = WinPcap with receive thread
# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
# none = Empty template
#CONFIG_L2_PACKET=linux
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
# CONFIG_PEERKEY=y
# IEEE 802.11w (management frame protection)
# This version is an experimental implementation based on IEEE 802.11w/D1.0
# draft and is subject to change since the standard has not yet been finalized.
# Driver support is also needed for IEEE 802.11w.
#CONFIG_IEEE80211W=y
# Select TLS implementation
# openssl = OpenSSL (default)
# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
# internal = Internal TLSv1 implementation (experimental)
# none = Empty template
CONFIG_TLS=internal
# Whether to enable TLS/IA support, which is required for EAP-TTLSv1.
# You need CONFIG_TLS=gnutls for this to have any effect. Please note that
# even though the core GnuTLS library is released under LGPL, this extra
# library uses GPL and as such, the terms of GPL apply to the combination
# of wpa_supplicant and GnuTLS if this option is enabled. BSD license may not
# apply for distribution of the resulting binary.
#CONFIG_GNUTLS_EXTRA=y
# If CONFIG_TLS=internal is used, additional library and include paths are
# needed for LibTomMath. Alternatively, an integrated, minimal version of
# LibTomMath can be used. See beginning of libtommath.c for details on benefits
# and drawbacks of this option.
#CONFIG_INTERNAL_LIBTOMMATH=y
#ifndef CONFIG_INTERNAL_LIBTOMMATH
#LTM_PATH=/usr/src/libtommath-0.39
#CFLAGS += -I$(LTM_PATH)
#LIBS += -L$(LTM_PATH)
#LIBS_p += -L$(LTM_PATH)
#endif
# At the cost of about 4 kB of additional binary size, the internal LibTomMath
# can be configured to include faster routines for exptmod, sqr, and div to
# speed up DH and RSA calculation considerably
#CONFIG_INTERNAL_LIBTOMMATH_FAST=y
# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
# This is only for Windows builds and requires WMI-related header files and
# WbemUuid.Lib from Platform SDK even when building with MinGW.
#CONFIG_NDIS_EVENTS_INTEGRATED=y
#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
# Add support for old DBus control interface
# (fi.epitest.hostap.WPASupplicant)
#CONFIG_CTRL_IFACE_DBUS=y
# Add support for new DBus control interface
# (fi.w1.hostap.wpa_supplicant1)
#CONFIG_CTRL_IFACE_DBUS_NEW=y
# Add introspection support for new DBus control interface
#CONFIG_CTRL_IFACE_DBUS_INTRO=y
# Add support for loading EAP methods dynamically as shared libraries.
# When this option is enabled, each EAP method can be either included
# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
# be loaded in the beginning of the wpa_supplicant configuration file
# (see load_dynamic_eap parameter in the example file) before being used in
# the network blocks.
#
# Note that some shared parts of EAP methods are included in the main program
# and in order to be able to use dynamic EAP methods using these parts, the
# main program must have been build with the EAP method enabled (=y or =dyn).
# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
# unless at least one of them was included in the main build to force inclusion
# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
# in the main build to be able to load these methods dynamically.
#
# Please also note that using dynamic libraries will increase the total binary
# size. Thus, it may not be the best option for targets that have limited
# amount of memory/flash.
#CONFIG_DYNAMIC_EAP_METHODS=y
# IEEE Std 802.11r-2008 (Fast BSS Transition)
#CONFIG_IEEE80211R=y
# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
#CONFIG_DEBUG_FILE=y
# Enable privilege separation (see README 'Privilege separation' for details)
#CONFIG_PRIVSEP=y
# Enable mitigation against certain attacks against TKIP by delaying Michael
# MIC error reports by a random amount of time between 0 and 60 seconds
#CONFIG_DELAYED_MIC_ERROR_REPORT=y
# Enable tracing code for developer debugging
# This tracks use of memory allocations and other registrations and reports
# incorrect use with a backtrace of call (or allocation) location.
#CONFIG_WPA_TRACE=y
# For BSD, comment out these.
#LIBS += -lexecinfo
#LIBS_p += -lexecinfo
#LIBS_c += -lexecinfo
# Use libbfd to get more details for developer debugging
# This enables use of libbfd to get more detailed symbols for the backtraces
# generated by CONFIG_WPA_TRACE=y.
#CONFIG_WPA_TRACE_BFD=y
# For BSD, comment out these.
#LIBS += -lbfd -liberty -lz
#LIBS_p += -lbfd -liberty -lz
#LIBS_c += -lbfd -liberty -lz
CONFIG_NO_RANDOM_POOL=y
NEED_80211_COMMON=y

View File

@@ -1,411 +0,0 @@
# Example wpa_supplicant build time configuration
#
# This file lists the configuration options that are used when building the
# hostapd binary. All lines starting with # are ignored. Configuration option
# lines must be commented out complete, if they are not to be included, i.e.,
# just setting VARIABLE=n is not disabling that variable.
#
# This file is included in Makefile, so variables like CFLAGS and LIBS can also
# be modified from here. In most cases, these lines should use += in order not
# to override previous values of the variables.
# Uncomment following two lines and fix the paths if you have installed OpenSSL
# or GnuTLS in non-default location
#CFLAGS += -I/usr/local/openssl/include
#LIBS += -L/usr/local/openssl/lib
# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
# the kerberos files are not in the default include path. Following line can be
# used to fix build issues on such systems (krb5.h not found).
#CFLAGS += -I/usr/include/kerberos
# Example configuration for various cross-compilation platforms
#### sveasoft (e.g., for Linksys WRT54G) ######################################
#CC=mipsel-uclibc-gcc
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
###############################################################################
#### openwrt (e.g., for Linksys WRT54G) #######################################
#CC=mipsel-uclibc-gcc
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
# -I../WRT54GS/release/src/include
#LIBS = -lssl
###############################################################################
# Driver interface for Host AP driver
CONFIG_DRIVER_HOSTAP=y
# Driver interface for Agere driver
#CONFIG_DRIVER_HERMES=y
# Change include directories to match with the local setup
#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
#CFLAGS += -I../../include/wireless
# Driver interface for ndiswrapper
# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
#CONFIG_DRIVER_NDISWRAPPER=y
# Driver interface for Atmel driver
# CONFIG_DRIVER_ATMEL=y
# Driver interface for old Broadcom driver
# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
# Linux wireless extensions and does not need (or even work) with the old
# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
#CONFIG_DRIVER_BROADCOM=y
# Example path for wlioctl.h; change to match your configuration
#CFLAGS += -I/opt/WRT54GS/release/src/include
# Driver interface for Intel ipw2100/2200 driver
# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
#CONFIG_DRIVER_IPW=y
# Driver interface for Ralink driver
#CONFIG_DRIVER_RALINK=y
# Driver interface for generic Linux wireless extensions
CONFIG_DRIVER_WEXT=y
# Driver interface for Linux drivers using the nl80211 kernel interface
CONFIG_DRIVER_NL80211=y
# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
#CONFIG_DRIVER_BSD=y
#CFLAGS += -I/usr/local/include
#LIBS += -L/usr/local/lib
#LIBS_p += -L/usr/local/lib
#LIBS_c += -L/usr/local/lib
# Driver interface for Windows NDIS
#CONFIG_DRIVER_NDIS=y
#CFLAGS += -I/usr/include/w32api/ddk
#LIBS += -L/usr/local/lib
# For native build using mingw
#CONFIG_NATIVE_WINDOWS=y
# Additional directories for cross-compilation on Linux host for mingw target
#CFLAGS += -I/opt/mingw/mingw32/include/ddk
#LIBS += -L/opt/mingw/mingw32/lib
#CC=mingw32-gcc
# By default, driver_ndis uses WinPcap for low-level operations. This can be
# replaced with the following option which replaces WinPcap calls with NDISUIO.
# However, this requires that WZC is disabled (net stop wzcsvc) before starting
# wpa_supplicant.
# CONFIG_USE_NDISUIO=y
# Driver interface for development testing
#CONFIG_DRIVER_TEST=y
# Include client MLME (management frame processing) for test driver
# This can be used to test MLME operations in hostapd with the test interface.
# space.
#CONFIG_CLIENT_MLME=y
# Driver interface for wired Ethernet drivers
CONFIG_DRIVER_WIRED=y
# Driver interface for the Broadcom RoboSwitch family
#CONFIG_DRIVER_ROBOSWITCH=y
# Driver interface for no driver (e.g., WPS ER only)
#CONFIG_DRIVER_NONE=y
# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
# included)
CONFIG_IEEE8021X_EAPOL=y
# EAP-MD5
CONFIG_EAP_MD5=y
# EAP-MSCHAPv2
CONFIG_EAP_MSCHAPV2=y
# EAP-TLS
CONFIG_EAP_TLS=y
# EAL-PEAP
CONFIG_EAP_PEAP=y
# EAP-TTLS
CONFIG_EAP_TTLS=y
# EAP-FAST
# Note: Default OpenSSL package does not include support for all the
# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
# the OpenSSL library must be patched (openssl-0.9.8d-tls-extensions.patch)
# to add the needed functions.
#CONFIG_EAP_FAST=y
# EAP-GTC
CONFIG_EAP_GTC=y
# EAP-OTP
CONFIG_EAP_OTP=y
# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
#CONFIG_EAP_SIM=y
# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
#CONFIG_EAP_PSK=y
# EAP-PAX
#CONFIG_EAP_PAX=y
# LEAP
CONFIG_EAP_LEAP=y
# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
#CONFIG_EAP_AKA=y
# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
# This requires CONFIG_EAP_AKA to be enabled, too.
#CONFIG_EAP_AKA_PRIME=y
# Enable USIM simulator (Milenage) for EAP-AKA
#CONFIG_USIM_SIMULATOR=y
# EAP-SAKE
#CONFIG_EAP_SAKE=y
# EAP-GPSK
#CONFIG_EAP_GPSK=y
# Include support for optional SHA256 cipher suite in EAP-GPSK
#CONFIG_EAP_GPSK_SHA256=y
# EAP-TNC and related Trusted Network Connect support (experimental)
#CONFIG_EAP_TNC=y
# Wi-Fi Protected Setup (WPS)
CONFIG_WPS=y
# WPS external registrar (ER)
CONFIG_WPS_ER=y
# EAP-IKEv2
#CONFIG_EAP_IKEV2=y
# PKCS#12 (PFX) support (used to read private key and certificate file from
# a file that usually has extension .p12 or .pfx)
CONFIG_PKCS12=y
# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
# engine.
CONFIG_SMARTCARD=y
# PC/SC interface for smartcards (USIM, GSM SIM)
# Enable this if EAP-SIM or EAP-AKA is included
#CONFIG_PCSC=y
# Development testing
#CONFIG_EAPOL_TEST=y
# Select control interface backend for external programs, e.g, wpa_cli:
# unix = UNIX domain sockets (default for Linux/*BSD)
# udp = UDP sockets using localhost (127.0.0.1)
# named_pipe = Windows Named Pipe (default for Windows)
# y = use default (backwards compatibility)
# If this option is commented out, control interface is not included in the
# build.
CONFIG_CTRL_IFACE=y
# Include support for GNU Readline and History Libraries in wpa_cli.
# When building a wpa_cli binary for distribution, please note that these
# libraries are licensed under GPL and as such, BSD license may not apply for
# the resulting binary.
#CONFIG_READLINE=y
# Remove debugging code that is printing out debug message to stdout.
# This can be used to reduce the size of the wpa_supplicant considerably
# if debugging code is not needed. The size reduction can be around 35%
# (e.g., 90 kB).
#CONFIG_NO_STDOUT_DEBUG=y
# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
# 35-50 kB in code size.
#CONFIG_NO_WPA=y
# Remove WPA2 support. This allows WPA to be used, but removes WPA2 code to
# save about 1 kB in code size when building only WPA-Personal (no EAP support)
# or 6 kB if building for WPA-Enterprise.
#CONFIG_NO_WPA2=y
# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
# This option can be used to reduce code size by removing support for
# converting ASCII passphrases into PSK. If this functionality is removed, the
# PSK can only be configured as the 64-octet hexstring (e.g., from
# wpa_passphrase). This saves about 0.5 kB in code size.
#CONFIG_NO_WPA_PASSPHRASE=y
# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
# This can be used if ap_scan=1 mode is never enabled.
#CONFIG_NO_SCAN_PROCESSING=y
# Select configuration backend:
# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
# path is given on command line, not here; this option is just used to
# select the backend that allows configuration files to be used)
# winreg = Windows registry (see win_example.reg for an example)
CONFIG_BACKEND=file
# Remove configuration write functionality (i.e., to allow the configuration
# file to be updated based on runtime configuration changes). The runtime
# configuration can still be changed, the changes are just not going to be
# persistent over restarts. This option can be used to reduce code size by
# about 3.5 kB.
#CONFIG_NO_CONFIG_WRITE=y
# Remove support for configuration blobs to reduce code size by about 1.5 kB.
#CONFIG_NO_CONFIG_BLOBS=y
# Select program entry point implementation:
# main = UNIX/POSIX like main() function (default)
# main_winsvc = Windows service (read parameters from registry)
# main_none = Very basic example (development use only)
#CONFIG_MAIN=main
# Select wrapper for operatins system and C library specific functions
# unix = UNIX/POSIX like systems (default)
# win32 = Windows systems
# none = Empty template
#CONFIG_OS=unix
# Select event loop implementation
# eloop = select() loop (default)
# eloop_win = Windows events and WaitForMultipleObject() loop
# eloop_none = Empty template
#CONFIG_ELOOP=eloop
# Select layer 2 packet implementation
# linux = Linux packet socket (default)
# pcap = libpcap/libdnet/WinPcap
# freebsd = FreeBSD libpcap
# winpcap = WinPcap with receive thread
# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
# none = Empty template
#CONFIG_L2_PACKET=linux
# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
CONFIG_PEERKEY=y
# IEEE 802.11w (management frame protection)
# This version is an experimental implementation based on IEEE 802.11w/D1.0
# draft and is subject to change since the standard has not yet been finalized.
# Driver support is also needed for IEEE 802.11w.
CONFIG_IEEE80211W=y
# Select TLS implementation
# openssl = OpenSSL (default)
# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
# internal = Internal TLSv1 implementation (experimental)
# none = Empty template
CONFIG_TLS=internal
# Whether to enable TLS/IA support, which is required for EAP-TTLSv1.
# You need CONFIG_TLS=gnutls for this to have any effect. Please note that
# even though the core GnuTLS library is released under LGPL, this extra
# library uses GPL and as such, the terms of GPL apply to the combination
# of wpa_supplicant and GnuTLS if this option is enabled. BSD license may not
# apply for distribution of the resulting binary.
#CONFIG_GNUTLS_EXTRA=y
# If CONFIG_TLS=internal is used, additional library and include paths are
# needed for LibTomMath. Alternatively, an integrated, minimal version of
# LibTomMath can be used. See beginning of libtommath.c for details on benefits
# and drawbacks of this option.
CONFIG_INTERNAL_LIBTOMMATH=y
#ifndef CONFIG_INTERNAL_LIBTOMMATH
#LTM_PATH=/usr/src/libtommath-0.39
#CFLAGS += -I$(LTM_PATH)
#LIBS += -L$(LTM_PATH)
#LIBS_p += -L$(LTM_PATH)
#endif
# At the cost of about 4 kB of additional binary size, the internal LibTomMath
# can be configured to include faster routines for exptmod, sqr, and div to
# speed up DH and RSA calculation considerably
CONFIG_INTERNAL_LIBTOMMATH_FAST=y
# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
# This is only for Windows builds and requires WMI-related header files and
# WbemUuid.Lib from Platform SDK even when building with MinGW.
#CONFIG_NDIS_EVENTS_INTEGRATED=y
#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
# Add support for old DBus control interface
# (fi.epitest.hostap.WPASupplicant)
#CONFIG_CTRL_IFACE_DBUS=y
# Add support for new DBus control interface
# (fi.w1.hostap.wpa_supplicant1)
#CONFIG_CTRL_IFACE_DBUS_NEW=y
# Add introspection support for new DBus control interface
#CONFIG_CTRL_IFACE_DBUS_INTRO=y
# Add support for loading EAP methods dynamically as shared libraries.
# When this option is enabled, each EAP method can be either included
# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
# be loaded in the beginning of the wpa_supplicant configuration file
# (see load_dynamic_eap parameter in the example file) before being used in
# the network blocks.
#
# Note that some shared parts of EAP methods are included in the main program
# and in order to be able to use dynamic EAP methods using these parts, the
# main program must have been build with the EAP method enabled (=y or =dyn).
# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
# unless at least one of them was included in the main build to force inclusion
# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
# in the main build to be able to load these methods dynamically.
#
# Please also note that using dynamic libraries will increase the total binary
# size. Thus, it may not be the best option for targets that have limited
# amount of memory/flash.
#CONFIG_DYNAMIC_EAP_METHODS=y
# IEEE Std 802.11r-2008 (Fast BSS Transition)
#CONFIG_IEEE80211R=y
# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
#CONFIG_DEBUG_FILE=y
# Enable privilege separation (see README 'Privilege separation' for details)
#CONFIG_PRIVSEP=y
# Enable mitigation against certain attacks against TKIP by delaying Michael
# MIC error reports by a random amount of time between 0 and 60 seconds
#CONFIG_DELAYED_MIC_ERROR_REPORT=y
# Enable tracing code for developer debugging
# This tracks use of memory allocations and other registrations and reports
# incorrect use with a backtrace of call (or allocation) location.
#CONFIG_WPA_TRACE=y
# For BSD, comment out these.
#LIBS += -lexecinfo
#LIBS_p += -lexecinfo
#LIBS_c += -lexecinfo
# Use libbfd to get more details for developer debugging
# This enables use of libbfd to get more detailed symbols for the backtraces
# generated by CONFIG_WPA_TRACE=y.
#CONFIG_WPA_TRACE_BFD=y
# For BSD, comment out these.
#LIBS += -lbfd -liberty -lz
#LIBS_p += -lbfd -liberty -lz
#LIBS_c += -lbfd -liberty -lz
CONFIG_NO_RANDOM_POOL=y
NEED_80211_COMMON=y
CONFIG_IBSS_RSN=y
CONFIG_P2P=y
CONFIG_AP=y
CONFIG_LIBNL32=y
CONFIG_LIBNL3_ROUTE=y

View File

@@ -1,194 +0,0 @@
wpa_supplicant_setup_vif() {
local vif="$1"
local driver="$2"
local key="$key"
local options="$3"
local freq=""
local ht="$5"
local ap_scan=""
local scan_ssid="1"
[ -n "$4" ] && freq="frequency=$4"
config_get enc "$vif" encryption
config_get key "$vif" key
local net_cfg bridge
config_get bridge "$vif" bridge
[ -z "$bridge" ] && {
net_cfg="$(find_net_config "$vif")"
[ -z "$net_cfg" ] || bridge="$(bridge_interface "$net_cfg")"
config_set "$vif" bridge "$bridge"
}
local mode ifname wds modestr=""
config_get mode "$vif" mode
config_get ifname "$vif" ifname
config_get_bool wds "$vif" wds 0
[ -z "$bridge" ] || [ "$mode" = ap ] || [ "$mode" = sta -a $wds -eq 1 ] || {
echo "wpa_supplicant_setup_vif($ifname): Refusing to bridge $mode mode interface"
return 1
}
[ "$mode" = "adhoc" ] && {
modestr="mode=1"
scan_ssid="0"
ap_scan="ap_scan=2"
}
key_mgmt='NONE'
case "$enc" in
*none*) ;;
*wep*)
config_get key "$vif" key
key="${key:-1}"
case "$key" in
[1234])
for idx in 1 2 3 4; do
local zidx
zidx=$(($idx - 1))
config_get ckey "$vif" "key${idx}"
[ -n "$ckey" ] && \
append "wep_key${zidx}" "wep_key${zidx}=$(prepare_key_wep "$ckey")"
done
wep_tx_keyidx="wep_tx_keyidx=$((key - 1))"
;;
*)
wep_key0="wep_key0=$(prepare_key_wep "$key")"
wep_tx_keyidx="wep_tx_keyidx=0"
;;
esac
;;
*psk*)
key_mgmt='WPA-PSK'
# if you want to use PSK with a non-nl80211 driver you
# have to use WPA-NONE and wext driver for wpa_s
[ "$mode" = "adhoc" -a "$driver" != "nl80211" ] && {
key_mgmt='WPA-NONE'
driver='wext'
}
if [ ${#key} -eq 64 ]; then
passphrase="psk=${key}"
else
passphrase="psk=\"${key}\""
fi
case "$enc" in
*psk2*)
proto='proto=RSN'
config_get ieee80211w "$vif" ieee80211w
;;
*psk*)
proto='proto=WPA'
;;
esac
;;
*wpa*|*8021x*)
proto='proto=WPA2'
key_mgmt='WPA-EAP'
config_get ieee80211w "$vif" ieee80211w
config_get ca_cert "$vif" ca_cert
config_get eap_type "$vif" eap_type
ca_cert=${ca_cert:+"ca_cert=\"$ca_cert\""}
case "$eap_type" in
tls)
pairwise='pairwise=CCMP'
group='group=CCMP'
config_get identity "$vif" identity
config_get client_cert "$vif" client_cert
config_get priv_key "$vif" priv_key
config_get priv_key_pwd "$vif" priv_key_pwd
identity="identity=\"$identity\""
client_cert="client_cert=\"$client_cert\""
priv_key="private_key=\"$priv_key\""
priv_key_pwd="private_key_passwd=\"$priv_key_pwd\""
;;
peap|ttls)
config_get auth "$vif" auth
config_get identity "$vif" identity
config_get password "$vif" password
phase2="phase2=\"auth=${auth:-MSCHAPV2}\""
identity="identity=\"$identity\""
password="${password:+password=\"$password\"}"
;;
esac
eap_type="eap=$(echo $eap_type | tr 'a-z' 'A-Z')"
;;
esac
case "$ieee80211w" in
[012])
ieee80211w="ieee80211w=$ieee80211w"
;;
esac
local fixed_freq bssid1 beacon_int brates mrate
config_get ifname "$vif" ifname
config_get bridge "$vif" bridge
config_get ssid "$vif" ssid
config_get bssid "$vif" bssid
bssid1=${bssid:+"bssid=$bssid"}
beacon_int=${beacon_int:+"beacon_int=$beacon_int"}
local br brval brsub brstr
[ -n "$basic_rate_list" ] && {
for br in $basic_rate_list; do
brval="$(($br / 1000))"
brsub="$((($br / 100) % 10))"
[ "$brsub" -gt 0 ] && brval="$brval.$brsub"
[ -n "$brstr" ] && brstr="$brstr,"
brstr="$brstr$brval"
done
brates=${basic_rate_list:+"rates=$brstr"}
}
local mcval=""
[ -n "$mcast_rate" ] && {
mcval="$(($mcast_rate / 1000))"
mcsub="$(( ($mcast_rate / 100) % 10 ))"
[ "$mcsub" -gt 0 ] && mcval="$mcval.$mcsub"
mrate=${mcast_rate:+"mcast_rate=$mcval"}
}
local ht_str
[ -n "$ht" ] && ht_str="htmode=$ht"
rm -rf /var/run/wpa_supplicant-$ifname
cat > /var/run/wpa_supplicant-$ifname.conf <<EOF
ctrl_interface=/var/run/wpa_supplicant-$ifname
$ap_scan
network={
$modestr
scan_ssid=$scan_ssid
ssid="$ssid"
$bssid1
key_mgmt=$key_mgmt
$proto
$freq
${fixed:+"fixed_freq=1"}
$beacon_int
$brates
$mrate
$ht_str
$ieee80211w
$passphrase
$pairwise
$group
$eap_type
$ca_cert
$client_cert
$priv_key
$priv_key_pwd
$phase2
$identity
$password
$wep_key0
$wep_key1
$wep_key2
$wep_key3
$wep_tx_keyidx
}
EOF
if [ -n "$proto" -o "$key_mgmt" = "NONE" ]; then
wpa_supplicant ${bridge:+ -b $bridge} -B -P "/var/run/wifi-${ifname}.pid" -D ${driver:-wext} -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf $options
else
return 0
fi
}

View File

@@ -1,25 +0,0 @@
#!/bin/sh /etc/rc.common
START=19
STOP=21
USE_PROCD=1
NAME=wpad
start_service() {
if [ -x "/usr/sbin/hostapd" ]; then
mkdir -p /var/run/hostapd
procd_open_instance hostapd
procd_set_param command /usr/sbin/hostapd -g /var/run/hostapd/global
procd_set_param respawn ${timeout:-1} ${retry:-0}
procd_close_instance
fi
if [ -x "/usr/sbin/wpa_supplicant" ]; then
mkdir -p /var/run/wpa_supplicant
procd_open_instance supplicant
procd_set_param command /usr/sbin/wpa_supplicant -g /var/run/wpa_supplicant/global
procd_set_param respawn ${timeout:-1} ${retry:-0}
procd_close_instance
fi
}

Some files were not shown because too many files have changed in this diff Show More