diff --git a/nanonote-TLWR11U/data/conf/config.minimal b/nanonote-TLWR11U/data/conf/config.minimal new file mode 100644 index 0000000..bf77d2b --- /dev/null +++ b/nanonote-TLWR11U/data/conf/config.minimal @@ -0,0 +1,59 @@ +# +# This file must be copied to .config in the OpenWrt root folder, +# then run: yes "" | make oldconfig > /dev/null +# + +CONFIG_TARGET_ar71xx=y +CONFIG_TARGET_ar71xx_generic=y +CONFIG_TARGET_ar71xx_generic_TLWR703=y + +CONFIG_TARGET_ROOTFS_TARGZ=y +CONFIG_TARGET_ROOTFS_JFFS2=y +CONFIG_TARGET_ROOTFS_SQUASHFS=y + +# CONFIG_BUILD_PATENTED is not set + +CONFIG_DEVEL=y +CONFIG_TOOLCHAINOPTS=y +CONFIG_GDB=y + +# CONFIG_SDK is not set + +# CONFIG_ALL is not set +# Enable this option only you want build ALL PAKCAGE in feeds.conf +# To skip broken module packages while compiling , run "make IGNORE_ERRORS=m" + +CONFIG_PACKAGE_block-mount=y + +CONFIG_PACKAGE_luci=y +CONFIG_PACKAGE_luci-mod-admin-core=y +CONFIG_PACKAGE_luci-mod-admin-full=y +CONFIG_PACKAGE_luci-mod-rpc=y + +CONFIG_PACKAGE_kmod-fs-ext4=y +CONFIG_PACKAGE_kmod-ipv6=m +CONFIG_PACKAGE_kmod-tun=m + +CONFIG_PACKAGE_kmod-usb-core=y +CONFIG_PACKAGE_kmod-usb-serial=m +CONFIG_PACKAGE_kmod-usb-serial-ftdi=m +CONFIG_PACKAGE_kmod-usb-serial-pl2303=m +CONFIG_PACKAGE_kmod-usb-storage=y +CONFIG_PACKAGE_kmod-usb2=y +CONFIG_PACKAGE_kmod-video-core=m +CONFIG_PACKAGE_kmod-video-uvc=m +CONFIG_PACKAGE_kmod-video-videobuf2=m +CONFIG_PACKAGE_kmod-at86rf230=m +CONFIG_PACKAGE_kmod-ieee802154=m +CONFIG_PACKAGE_kmod-mac802154=m +CONFIG_PACKAGE_kmod-spi_atusb=m + +CONFIG_PACKAGE_ip=m +CONFIG_PACKAGE_dirtpan=m +CONFIG_PACKAGE_lowpan-tools=m +CONFIG_PACKAGE_mjpg-streamer=m +CONFIG_PACKAGE_swap-utils=y +CONFIG_PACKAGE_mount-utils=m +CONFIG_PACKAGE_strace=m +CONFIG_PACKAGE_urjtag=m +CONFIG_PACKAGE_xburst-tools=m diff --git a/nanonote-TLWR11U/data/conf/feeds.conf b/nanonote-TLWR11U/data/conf/feeds.conf new file mode 100644 index 0000000..a5361a1 --- /dev/null +++ b/nanonote-TLWR11U/data/conf/feeds.conf @@ -0,0 +1,10 @@ +src-git qipackages git://projects.qi-hardware.com/openwrt-packages.git +src-svn packages svn://svn.openwrt.org/openwrt/packages +src-svn desktop svn://svn.openwrt.org/openwrt/feeds/desktop + +src-svn xwrt http://x-wrt.googlecode.com/svn/trunk/package +src-svn luci http://svn.luci.subsignal.org/luci/trunk/contrib/package +src-svn xorg svn://svn.openwrt.org/openwrt/feeds/xorg + +src-svn phone svn://svn.openwrt.org/openwrt/feeds/phone +src-svn efl svn://svn.openwrt.org/openwrt/feeds/efl diff --git a/nanonote-TLWR11U/files/etc/config/dhcp b/nanonote-TLWR11U/files/etc/config/dhcp new file mode 100644 index 0000000..1efde32 --- /dev/null +++ b/nanonote-TLWR11U/files/etc/config/dhcp @@ -0,0 +1,27 @@ + +config 'dnsmasq' + option 'domainneeded' '1' + option 'boguspriv' '1' + option 'filterwin2k' '0' + option 'localise_queries' '1' + option 'rebind_protection' '1' + option 'rebind_localhost' '1' + option 'local' '/lan/' + option 'domain' 'lan' + option 'expandhosts' '1' + option 'nonegcache' '0' + option 'authoritative' '1' + option 'readethers' '1' + option 'leasefile' '/tmp/dhcp.leases' + option 'resolvfile' '/tmp/resolv.conf.auto' + +config 'dhcp' 'lan' + option 'interface' 'lan' + option 'start' '100' + option 'leasetime' '12h' + option 'limit' '1' + +config 'dhcp' 'wan' + option 'interface' 'wan' + option 'ignore' '1' + diff --git a/nanonote-TLWR11U/files/etc/config/firewall b/nanonote-TLWR11U/files/etc/config/firewall new file mode 100644 index 0000000..0e69f87 --- /dev/null +++ b/nanonote-TLWR11U/files/etc/config/firewall @@ -0,0 +1,148 @@ + +config defaults + option syn_flood '1' + option input 'ACCEPT' + option output 'ACCEPT' + option forward 'REJECT' + +config zone + option name 'lan' + option input 'ACCEPT' + option output 'ACCEPT' + option forward 'REJECT' + option network 'lan USB' + +config zone + option name 'wan' + option input 'REJECT' + option output 'ACCEPT' + option forward 'REJECT' + option masq '1' + option mtu_fix '1' + option network 'wan wwan' + +config forwarding + option src 'lan' + option dest 'wan' + +config rule + option name 'Allow-DHCP-Renew' + option src 'wan' + option proto 'udp' + option dest_port '68' + option target 'ACCEPT' + option family 'ipv4' + +config rule + option name 'Allow-Ping' + option src 'wan' + option proto 'icmp' + option icmp_type 'echo-request' + option family 'ipv4' + option target 'ACCEPT' + +config rule + option name 'Allow-DHCPv6' + option src 'wan' + option proto 'udp' + option src_ip 'fe80::/10' + option src_port '547' + option dest_ip 'fe80::/10' + option dest_port '546' + option family 'ipv6' + option target 'ACCEPT' + +config rule + option name 'Allow-ICMPv6-Input' + option src 'wan' + option proto 'icmp' + list icmp_type 'echo-request' + list icmp_type 'destination-unreachable' + list icmp_type 'packet-too-big' + list icmp_type 'time-exceeded' + list icmp_type 'bad-header' + list icmp_type 'unknown-header-type' + list icmp_type 'router-solicitation' + list icmp_type 'neighbour-solicitation' + option limit '1000/sec' + option family 'ipv6' + option target 'ACCEPT' + +config rule + option name 'Allow-ICMPv6-Forward' + option src 'wan' + option dest '*' + option proto 'icmp' + list icmp_type 'echo-request' + list icmp_type 'destination-unreachable' + list icmp_type 'packet-too-big' + list icmp_type 'time-exceeded' + list icmp_type 'bad-header' + list icmp_type 'unknown-header-type' + option limit '1000/sec' + option family 'ipv6' + option target 'ACCEPT' + +config include + option path '/etc/firewall.user' + +config zone + option name 'newzone' + option input 'ACCEPT' + option forward 'REJECT' + option network ' ' + option output 'ACCEPT' + +config rule + option target 'ACCEPT' + option src 'wan' + option dest_port '22' + option name 'ssh' + option family 'ipv4' + option proto 'tcp udp' + +config rule + option target 'ACCEPT' + option src 'wan' + option dest_port '80' + option name 'web' + option family 'ipv4' + option proto 'tcp udp' + +config redirect + option target 'DNAT' + option src 'wan' + option dest 'lan' + option proto 'tcp udp' + option src_dport '4444' + option dest_ip '192.168.42.100' + option dest_port '4444' + option name 'osc' + +config redirect + option target 'DNAT' + option src 'wan' + option dest 'lan' + option proto 'tcp' + option src_dport '21' + option dest_ip '192.168.42.100' + option dest_port '21' + option name 'ftp' + +config redirect + option target 'DNAT' + option src 'wan' + option dest 'lan' + option proto 'tcp udp' + option src_dport '23' + option dest_ip '192.168.42.100' + option dest_port '23' + option name 'telnet' + +config rule + option target 'ACCEPT' + option src 'wan' + option proto 'tcp udp' + option dest_port '8080' + option name 'mjpg' + diff --git a/nanonote-TLWR11U/files/etc/config/fstab b/nanonote-TLWR11U/files/etc/config/fstab new file mode 100644 index 0000000..b2c8def --- /dev/null +++ b/nanonote-TLWR11U/files/etc/config/fstab @@ -0,0 +1,19 @@ +config global automount + option from_fstab 1 + option anon_mount 1 + +config global autoswap + option from_fstab 1 + option anon_swap 0 + +config mount + option target /overlay + option device /dev/sda1 + option fstype ext4 + option options rw,sync + option enabled 1 + option enabled_fsck 0 + +config swap + option device /dev/sda2 + option enabled 1 diff --git a/nanonote-TLWR11U/files/etc/config/network b/nanonote-TLWR11U/files/etc/config/network new file mode 100644 index 0000000..767bd37 --- /dev/null +++ b/nanonote-TLWR11U/files/etc/config/network @@ -0,0 +1,24 @@ + +config interface 'loopback' + option ifname 'lo' + option proto 'static' + option ipaddr '127.0.0.1' + option netmask '255.0.0.0' + +config interface 'lan' + option ifname 'eth0' + option type 'bridge' + option proto 'static' + option netmask '255.255.255.0' + option ipaddr '192.168.42.1' + +config interface 'wwan' + option proto 'dhcp' + +config interface 'USB' + option type 'bridge' + option proto 'static' + option ifname 'usb0' + option ipaddr '192.168.254.100' + option netmask '255.255.255.0' + diff --git a/nanonote-TLWR11U/files/etc/config/uhttpd b/nanonote-TLWR11U/files/etc/config/uhttpd new file mode 100644 index 0000000..08ca5e5 --- /dev/null +++ b/nanonote-TLWR11U/files/etc/config/uhttpd @@ -0,0 +1,84 @@ +# Server configuration +config uhttpd main + + # HTTP listen addresses, multiple allowed + list listen_http 0.0.0.0:80 +# list listen_http [::]:80 + + # HTTPS listen addresses, multiple allowed + list listen_https 0.0.0.0:443 +# list listen_https [::]:443 + + # Server document root + option home /www + + # Reject requests from RFC1918 IP addresses + # directed to the servers public IP(s). + # This is a DNS rebinding countermeasure. + option rfc1918_filter 1 + + # Certificate and private key for HTTPS. + # If no listen_https addresses are given, + # the key options are ignored. + option cert /etc/uhttpd.crt + option key /etc/uhttpd.key + + # CGI url prefix, will be searched in docroot. + # Default is /cgi-bin + option cgi_prefix /cgi-bin + + # List of extension->interpreter mappings. + # Files with an associated interpreter can + # be called outside of the CGI prefix and do + # not need to be executable. +# list interpreter ".php=/usr/bin/php-cgi" +# list interpreter ".cgi=/usr/bin/perl" + + # Lua url prefix and handler script. + # Lua support is disabled if no prefix given. +# option lua_prefix /luci +# option lua_handler /usr/lib/lua/luci/sgi/uhttpd.lua + + # CGI/Lua timeout, if the called script does not + # write data within the given amount of seconds, + # the server will terminate the request with + # 504 Gateway Timeout response. + option script_timeout 60 + + # Network timeout, if the current connection is + # blocked for the specified amount of seconds, + # the server will terminate the associated + # request process. + option network_timeout 30 + + # TCP Keep-Alive, send periodic keep-alive probes + # over established connections to detect dead peers. + # The value is given in seconds to specify the + # interval between subsequent probes. + # Setting this to 0 will disable TCP keep-alive. + option tcp_keepalive 1 + + # Basic auth realm, defaults to local hostname +# option realm OpenWrt + + # Configuration file in busybox httpd format +# option config /etc/httpd.conf + + +# Certificate defaults for px5g key generator +config cert px5g + + # Validity time + option days 730 + + # RSA key size + option bits 1024 + + # Location + option country DE + option state Berlin + option location Berlin + + # Common name + option commonname OpenWrt + diff --git a/nanonote-TLWR11U/files/opt/m1-wireless.lua b/nanonote-TLWR11U/files/opt/m1-wireless.lua new file mode 100755 index 0000000..e0b683b --- /dev/null +++ b/nanonote-TLWR11U/files/opt/m1-wireless.lua @@ -0,0 +1,96 @@ +#!/usr/bin/env lua + +local io = require "io" +local os = require "os" +local table = require "table" + +function trim (s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) +end + +function split(delim, text) + local list = {} + if string.len(text) <= 0 then + return list + end + delim = delim or "" + local pos = 1 + -- if delim matches empty string then it would give an endless loop + if string.find("", delim, 1) and delim ~= "" then + error("delim matches empty string!") + end + local first, last + while 1 do + if delim ~= "" then + first, last = string.find(text, delim, pos) + else + first, last = string.find(text, "%s+", pos) + if first == 1 then + pos = last+1 + first, last = string.find(text, "%s+", pos) + end + end + if first then -- found? + table.insert(list, string.sub(text, pos, first-1)) + pos = last+1 + else + table.insert(list, string.sub(text, pos)) + break + end + end + return list +end + +function exec(command) + local pp = io.popen(command) + local data = pp:read("*a") + pp:close() + + return data +end + +function iwscan(iface) + local siface = iface or "" + local cnt = exec("iwlist "..siface.." scan 2>/dev/null") + local iws = {} + + cnt = trim(cnt) + for i, l in pairs(split("\n Cell", cnt)) do + local ESSID = l:match("ESSID:\"(.-)\"") + if ESSID then + local Q = l:match("Quality[:=](.-)[ ]") + local A = l:match("Authentication Suites.- : (.-)\n") + local P = l:match("Pairwise Ciphers.- : (.-)\n") + + local enc + if not l:find("Encryption key:on") then + enc = "none" + else + local wpa = l:find("WPA Version 1") + local rsn = l:find("WPA2 Version 1") + if wpa and rsn then enc = "psk+psk2" + elseif rsn then enc = "psk2" + elseif wpa then enc = "psk" + else enc = "wep" end + end + + local a = Q:match("(%d-)/") + local b = Q:match("/(%d-)$") + Q = math.floor(tonumber(a)/tonumber(b)*100) + + local r = Q .. "%," .. ESSID .. "," .. enc + + table.insert(iws, r) + end + end + + return iws +end + +local t = iwscan("wlan0") +if t == {} then + print(); +else + for k,v in pairs(t) do print(v) end +end + diff --git a/nanonote-TLWR11U/files/opt/m1-wireless.sh b/nanonote-TLWR11U/files/opt/m1-wireless.sh new file mode 100755 index 0000000..76af51f --- /dev/null +++ b/nanonote-TLWR11U/files/opt/m1-wireless.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +if [ "$1" == "set" ] && [ "$#" == "4" ]; then + uci delete network.wwan + uci set network.wwan=interface + uci set network.wwan.proto=dhcp + + uci delete wireless.@wifi-iface[0] + uci set wireless.@wifi-device[0].disabled=0 + uci add wireless wifi-iface > /dev/null 2>&1 + uci set wireless.@wifi-iface[0].device='radio0' + uci set wireless.@wifi-iface[0].network='wwan' + uci set wireless.@wifi-iface[0].mode='sta' + + #none for an open network, + #wep for WEP, + #psk for WPA-PSK, or + #psk2 + + uci set wireless.@wifi-iface[0].ssid=$2 + uci set wireless.@wifi-iface[0].key=$3 + uci set wireless.@wifi-iface[0].encryption=$4 + + uci commit network + uci commit wireless + ifup wwan + sleep 2 + + exit 0 +fi + + +if [ "$1" == "get" ]; then + ifconfig -a | grep wlan0 > /dev/null 2>&1 + + if [ "$?" != "0" ]; then + iw phy phy0 interface add wlan0 type station + ifconfig wlan0 up + sleep 1 + fi + + /opt/m1-wireless.lua + + exit 0 +fi + +if [ "$1" == "status" ]; then + sleep 1 + IP=`ifconfig wlan0 2>/dev/null | grep "inet addr" | \ + sed -e 's/^ *//g' | cut -d":" -f2 | cut -d" " -f1` + if [ "$?" != 0 ] || [ "${IP}" == "" ]; then + echo "Disconnected" + echo "0.0.0.0" + exit 1 + fi + + ESSID=`iwconfig wlan0 2>/dev/null | grep ESSID | cut -d":" -f 2 | sed -e 's/\"//g'` + + echo "${ESSID}" + echo "${IP}" + + exit 0 +fi + +echo "Usage: $0 [get/set/status] PARAMS..." +exit 1