add S300AI

Change-Id: Ice89434e8dc7b3be506380729d716f50aa75df14
diff --git a/lynq/S300AI/ap/app/Script/Makefile b/lynq/S300AI/ap/app/Script/Makefile
new file mode 100755
index 0000000..4f0fb1a
--- /dev/null
+++ b/lynq/S300AI/ap/app/Script/Makefile
@@ -0,0 +1,71 @@
+

+############################################################################

+#

+# Makefile --  Build for rootfs makefile.

+#

+# Copyright (c) 2001-2004, SnapGear (www.snapgear.com)

+# Copyright (c) 2001, Lineo

+#

+# Add by zhouwei 2010-08-06 for freescale imx28 platform

+# 

+############################################################################

+CP        = cp

+ROMFS_DIR = $(ROMFSDIR)

+$(warning  CONFIG_WIFI_MODULE=$(CONFIG_WIFI_MODULE))

+.PHONY: romfs wifi

+

+ifneq ($(CONFIG_WIFI_MODULE), )

+CPWIFI=wifi

+endif

+

+$(warning  CPWIFI=$(CPWIFI))

+all:

+

+romfs: $(CPWIFI)

+	chmod +x ./scripts/*.sh

+	$(CP) -f ./scripts/*.sh $(ROMFS_DIR)/sbin/

+	#$(CP) -f ./scripts/*.txt $(ROMFS_DIR)/sbin/

+	mkdir -p $(ROMFS_DIR)/etc_ro/ 

+	$(CP) -f ./etc/*.conf $(ROMFS_DIR)/etc_ro/

+	$(CP) -f ./etc/options.auth $(ROMFS_DIR)/etc_ro/

+	$(CP) -f ./etc/options.noauth $(ROMFS_DIR)/etc_ro/

+	$(CP) -f ./etc/initchat $(ROMFS_DIR)/etc_ro/

+ifneq ($(CONFIG_USE_WEBUI_SECURITY),yes)

+	$(CP) -f ./etc/pap-secrets $(ROMFS_DIR)/etc_ro/

+	$(CP) -f ./etc/chap-secrets $(ROMFS_DIR)/etc_ro/

+endif

+ifeq ($(USE_FOTA),yes)

+	mkdir -p $(ROMFS_DIR)/recovery/sbin

+	$(CP) -f ./scripts/to_mnt_ubifs.sh $(ROMFS_DIR)/recovery/sbin/

+endif

+wifi:

+	@echo "copying wifi script"

+

+	$(CP) -rf ./wifi_script/realtek/zte_qrcode_create.sh  $(ROMFS_DIR)/sbin/

+ifeq ($(CONFIG_WIFI_MODULE), realtek)

+	@echo "copying wifi realtek script"

+	mkdir -p $(ROMFS_DIR)/etc_ro/ 

+	$(CP) -rf ./wifi/*  $(ROMFS_DIR)/etc_ro/

+ifeq ($(CONFIG_WIFI_RTL_WPA2),yes)

+	chmod +x  ./wifi_script/realtek_wpa2/*

+	$(CP) -rf ./wifi_script/realtek_wpa2/*  $(ROMFS_DIR)/sbin/

+

+else ifeq ($(CONFIG_WIFI_RTL_SDK24_3),yes)

+	chmod +x  ./wifi_script/realtek_wpa2/*

+	$(CP) -rf ./wifi_script/realtek_wpa2/*  $(ROMFS_DIR)/sbin/

+else

+	chmod +x  ./wifi_script/realtek/*

+	$(CP) -rf ./wifi_script/realtek/*  $(ROMFS_DIR)/sbin/

+endif

+else

+	chmod +x  ./wifi_script/realtek/*

+ifeq ($(CONFIG_MIN_8M_VERSION), n)

+	$(CP) -rf ./wifi_script/realtek/zte_qrcode_create.sh  $(ROMFS_DIR)/sbin/

+else

+ifeq ($(CONFIG_MMI_LCD),yes)

+	$(CP) -rf ./wifi_script/realtek/zte_qrcode_create.sh  $(ROMFS_DIR)/sbin/

+endif

+endif

+endif

+

+

diff --git a/lynq/S300AI/ap/app/Script/scripts/lan.sh b/lynq/S300AI/ap/app/Script/scripts/lan.sh
new file mode 100755
index 0000000..b4915a7
--- /dev/null
+++ b/lynq/S300AI/ap/app/Script/scripts/lan.sh
@@ -0,0 +1,153 @@
+#!/bin/sh
+#
+# $Id: lan.sh
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+br_set()
+{
+    br_name=$lan_if
+
+    #ÉèÖÃÍøÇÅ
+    killall -9 udhcpd
+    echo "ifconfig $br_name down...................."
+    ifconfig $br_name down
+
+    echo "brctl delbr $br_name......................"
+    brctl delbr $br_name
+
+    echo "brctl addbr $br_name......................"
+    brctl addbr $br_name 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: brctl addbr $br_name failed." >> $test_log
+    fi
+    echo "brctl setfd $br_name 0.1.................."
+    brctl setfd $br_name 0.1 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: brctl setfd $br_name 0.1 failed." >> $test_log
+    fi
+    echo "ifconfig lo up......................."
+    ifconfig lo up 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig lo up failed." >> $test_log
+    fi
+    echo "ifconfig $br_name up......................"
+    ifconfig $br_name up 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $br_name up failed." >> $test_log
+    fi
+
+    #´ò¿ªÍøÇŵØÖ·¸Ä±ä֪ͨµÄ¿ª¹Ø
+    echo 1 > /proc/sys/net/ipv4/conf/$br_name/arp_notify
+    
+    br_node=`nv get br_node`
+
+    #analysis br_node ex: usb0+wifi0+¡­
+    IFS_OLD=$IFS
+    IFS="+"
+    for device in $br_node
+    do
+        # youchen@2024-09-07 temp fix choke when boot without eth phy, begin
+        if [ "$device" == "eth0" ]; then
+	    eth_state=`cat /sys/gmac/gmacconfig/eth_phy_state`
+	    if [ "$eth_state" != "1" ]; then
+                continue
+	    fi
+	fi
+        # youchen@2024-09-07 temp fix choke when boot without eth phy, end
+        ifconfig $device up
+        
+        brctl addif $br_name $device 2>>$test_log
+        if [ $? -ne 0 ];then
+            echo "Error: brctl addif $br_name $device failed." >> $test_log
+        fi
+    done
+    IFS=$IFS_OLD
+    
+}
+
+lan_set()
+{
+    ip=`nv get lan_ipaddr`
+    nm=`nv get lan_netmask`
+    ifconfig $lan_if $ip netmask $nm 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $lan_if $ip netmask $nm failed." >> $test_log
+    fi
+
+    webv6_enable=`nv get webv6_enable`
+    ipv6=`nv get lan_ipv6addr`
+    if [ "x$webv6_enable" == "x1" ]; then
+        ifconfig $lan_if $ipv6
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $lan_if $ipv6 failed." >> $test_log
+    fi
+    fi
+}
+
+#½âÎöÄÚÍøµØÖ·¡¢Íø¹ØµØÖ·Í¨¹ýproc»úÖÆ¶¯Ì¬´«µÝ¸øÄںˣ¬ÒÔ±ãÄÚºËʵÏÖ·ÀÖ¹ÄÚÍøµØÖ·Ð¹Â¶¹¦ÄÜ
+lanip_proc()
+{
+    #ipµØÖ·»»Ëã³É4×Ö½ÚÕûÐÍÊÇÍøÂç×Ö½ÚÐò£¬Òªµßµ¹ÏÂ
+    #uclinux²»Ö§³Ö×óÒÆ×Ö·û
+	ip_value=`echo "$ip" | awk -F '.' '{printf $1 + 256* $2 + 256*256* $3 + 256*256*256* $4}'`
+	nm_value=`echo "$nm" | awk -F '.' '{printf $1 + 256* $2 + 256*256* $3 + 256*256*256* $4}'`
+
+    echo $ip_value > /sys/module/lanip_filter_ipv4/parameters/lan_ipaddr
+    echo $nm_value > /sys/module/lanip_filter_ipv4/parameters/lan_netmask
+}
+
+main()
+{
+    lan_enable=`nv get LanEnable`
+    if [ "x$lan_enable" == "x0" ]; then
+        exit 0
+    fi
+
+    echo "Info: lan.sh start" >> $test_log
+
+    if [ "x$lan_enable" == "x1" ]; then
+        br_set
+    fi
+	
+	if [ "x$lan_if" != "x" ]; then
+        lan_set
+    fi
+    
+    #vlanÅäÖã¬ÔÝʱ·ÅÓÚ´Ë´¦£¬1 ¿ª»úµÄʱºò²»ÐèÒª½«sw¼ÓÈëµ½ÍøÇÅÏ 
+    #2 ´Ë´¦±ØÐ뽫sw upÆðÀ´£¬Èç¹û²»upµÄ»°½«²»»áÓÐrj45ÈȲå°Îʼþ
+    sw_name=`nv get swvlan`
+    ifconfig $sw_name up
+    natenable=`nv get natenable`
+    dosenable=`nv get dosenable`
+    if [[ "x$natenable" != "x0" || "x$dosenable" != "x0" ]]; then
+        lanip_proc
+    fi
+    if [ "x$dosenable" != "x0" ]; then
+        echo 1 > /sys/module/fast_common/parameters/lan_dos_enable
+    fi
+
+
+
+
+    echo "" > $path_conf/udhcpd.leases
+
+    . $path_sh/user-config-udhcpd.sh
+        
+    dhcp=`nv get dhcpEnabled`
+    if [ "$dhcp" == "1" ]; then
+        echo "Info: config-udhcpd.sh lan -r 1 start" >> $test_log
+        . $path_sh/config-udhcpd.sh "lan" -r 1
+    fi
+
+    dnsmasq -i $lan_if -r $path_conf/resolv.conf &
+    . $path_sh/upnp.sh
+    
+	#»ñÈ¡br0µÄipv6µØÖ·
+    ipv6lanipaddrcmd="ifconfig $br_name | grep Scope:Link | sed 's/^.*addr: //g' | sed 's/\/.*$//g'"
+    ipv6lanipaddr=`eval $ipv6lanipaddrcmd`
+    nv set ipv6_lan_ipaddr=$ipv6lanipaddr
+}
+
+main