LinuxAP : add new plugin
authorChang.H.S <jhs@dev3>
Tue, 10 Apr 2012 10:36:44 +0000 (19:36 +0900)
committerChang.H.S <jhs@dev3>
Wed, 18 Apr 2012 11:12:33 +0000 (20:12 +0900)
configure.ac
lib/python/Plugins/SystemPlugins/Makefile.am
lib/python/Plugins/SystemPlugins/WirelessAccessPoint/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/WirelessAccessPoint/__init__.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/WirelessAccessPoint/_wirelessap.so [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/WirelessAccessPoint/hostapd.conf.orig [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/WirelessAccessPoint/meta/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/WirelessAccessPoint/meta/plugin_wirelessaccesspoint.xml [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/WirelessAccessPoint/plugin.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/WirelessAccessPoint/wirelessap.py [new file with mode: 0644]

index f11245a..4fd69df 100644 (file)
@@ -254,6 +254,8 @@ lib/python/Plugins/SystemPlugins/CrashReport/meta/Makefile
 lib/python/Plugins/SystemPlugins/3GModemManager/Makefile
 lib/python/Plugins/SystemPlugins/3GModemManager/meta/Makefile
 lib/python/Plugins/SystemPlugins/3GModemManager/script/Makefile
+lib/python/Plugins/SystemPlugins/WirelessAccessPoint/Makefile
+lib/python/Plugins/SystemPlugins/WirelessAccessPoint/meta/Makefile
 lib/python/Tools/Makefile
 lib/service/Makefile
 lib/components/Makefile
index 059673c..7e31a15 100755 (executable)
@@ -6,7 +6,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
        TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \
        Blindscan RemoteControlCode UI3DSetup UIPositionSetup HDMICEC LEDBrightnessSetup \
-       FirmwareUpgrade CrashReport 3GModemManager
+       FirmwareUpgrade CrashReport 3GModemManager WirelessAccessPoint
 
 install_PYTHON =       \
        __init__.py
diff --git a/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/Makefile.am b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/Makefile.am
new file mode 100755 (executable)
index 0000000..4790bfd
--- /dev/null
@@ -0,0 +1,10 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/WirelessAccessPoint
+
+SUBDIRS = meta
+
+install_PYTHON =  \
+       __init__.py \
+       plugin.py \
+       hostapd.conf.orig \
+       _wirelessap.so \
+       wirelessap.py
diff --git a/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/__init__.py b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/_wirelessap.so b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/_wirelessap.so
new file mode 100755 (executable)
index 0000000..8e0c085
Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/_wirelessap.so differ
diff --git a/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/hostapd.conf.orig b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/hostapd.conf.orig
new file mode 100644 (file)
index 0000000..807f263
--- /dev/null
@@ -0,0 +1,1016 @@
+##### hostapd configuration file ##############################################
+# Empty lines and lines starting with # are ignored
+
+# AP netdevice name (without 'ap' postfix, i.e., wlan0 uses wlan0ap for
+# management frames); ath0 for madwifi
+interface=wlan0
+
+# In case of madwifi, atheros, and nl80211 driver interfaces, an additional
+# configuration parameter, bridge, may be used to notify hostapd if the
+# interface is included in a bridge. This parameter is not used with Host AP
+# driver. If the bridge parameter is not set, the drivers will automatically
+# figure out the bridge interface (assuming sysfs is enabled and mounted to
+# /sys) and this parameter may not be needed.
+#
+# For nl80211, this parameter can be used to request the AP interface to be
+# added to the bridge automatically (brctl may refuse to do this before hostapd
+# has been started to change the interface mode). If needed, the bridge
+# interface is also created.
+bridge=br0
+
+# Driver interface type (hostap/wired/madwifi/test/none/nl80211/bsd);
+# default: hostap). nl80211 is used with all Linux mac80211 drivers.
+# Use driver=none if building hostapd as a standalone RADIUS server that does
+# not control any wireless/wired driver.
+driver=nl80211
+
+# hostapd event logger configuration
+#
+# Two output method: syslog and stdout (only usable if not forking to
+# background).
+#
+# Module bitfield (ORed bitfield of modules that will be logged; -1 = all
+# modules):
+# bit 0 (1) = IEEE 802.11
+# bit 1 (2) = IEEE 802.1X
+# bit 2 (4) = RADIUS
+# bit 3 (8) = WPA
+# bit 4 (16) = driver interface
+# bit 5 (32) = IAPP
+# bit 6 (64) = MLME
+#
+# Levels (minimum value for logged events):
+#  0 = verbose debugging
+#  1 = debugging
+#  2 = informational messages
+#  3 = notification
+#  4 = warning
+#
+logger_syslog=-1
+logger_syslog_level=2
+logger_stdout=-1
+logger_stdout_level=2
+
+# Dump file for state information (on SIGUSR1)
+dump_file=/tmp/hostapd.dump
+
+# Interface for separate control program. If this is specified, hostapd
+# will create this directory and a UNIX domain socket for listening to requests
+# from external programs (CLI/GUI, etc.) for status information and
+# configuration. The socket file will be named based on the interface name, so
+# multiple hostapd processes/interfaces can be run at the same time if more
+# than one interface is used.
+# /var/run/hostapd is the recommended directory for sockets and by default,
+# hostapd_cli will use it when trying to connect with hostapd.
+ctrl_interface=/var/run/hostapd
+
+# Access control for the control interface can be configured by setting the
+# directory to allow only members of a group to use sockets. This way, it is
+# possible to run hostapd as root (since it needs to change network
+# configuration and open raw sockets) and still allow GUI/CLI components to be
+# run as non-root users. However, since the control interface can be used to
+# change the network configuration, this access needs to be protected in many
+# cases. By default, hostapd is configured to use gid 0 (root). If you
+# want to allow non-root users to use the contron interface, add a new group
+# and change this value to match with that group. Add users that should have
+# control interface access to this group.
+#
+# This variable can be a group name or gid.
+#ctrl_interface_group=wheel
+ctrl_interface_group=0
+
+
+##### IEEE 802.11 related configuration #######################################
+
+# SSID to be used in IEEE 802.11 management frames
+ssid=vuplus_ap
+
+# Country code (ISO/IEC 3166-1). Used to set regulatory domain.
+# Set as needed to indicate country in which device is operating.
+# This can limit available channels and transmit power.
+#country_code=US
+
+# Enable IEEE 802.11d. This advertises the country_code and the set of allowed
+# channels and transmit power levels based on the regulatory limits. The
+# country_code setting must be configured with the correct country for
+# IEEE 802.11d functions.
+# (default: 0 = disabled)
+#ieee80211d=1
+
+# Operation mode (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g,
+# Default: IEEE 802.11b
+hw_mode=g
+
+# Channel number (IEEE 802.11)
+# (default: 0, i.e., not set)
+# Please note that some drivers (e.g., madwifi) do not use this value from
+# hostapd and the channel will need to be configuration separately with
+# iwconfig.
+channel=1
+
+# Beacon interval in kus (1.024 ms) (default: 100; range 15..65535)
+beacon_int=100
+
+# DTIM (delivery trafic information message) period (range 1..255):
+# number of beacons between DTIMs (1 = every beacon includes DTIM element)
+# (default: 2)
+dtim_period=2
+
+# Maximum number of stations allowed in station table. New stations will be
+# rejected after the station table is full. IEEE 802.11 has a limit of 2007
+# different association IDs, so this number should not be larger than that.
+# (default: 2007)
+max_num_sta=255
+
+# RTS/CTS threshold; 2347 = disabled (default); range 0..2347
+# If this field is not included in hostapd.conf, hostapd will not control
+# RTS threshold and 'iwconfig wlan# rts <val>' can be used to set it.
+rts_threshold=2347
+
+# Fragmentation threshold; 2346 = disabled (default); range 256..2346
+# If this field is not included in hostapd.conf, hostapd will not control
+# fragmentation threshold and 'iwconfig wlan# frag <val>' can be used to set
+# it.
+fragm_threshold=2346
+
+# Rate configuration
+# Default is to enable all rates supported by the hardware. This configuration
+# item allows this list be filtered so that only the listed rates will be left
+# in the list. If the list is empty, all rates are used. This list can have
+# entries that are not in the list of rates the hardware supports (such entries
+# are ignored). The entries in this list are in 100 kbps, i.e., 11 Mbps = 110.
+# If this item is present, at least one rate have to be matching with the rates
+# hardware supports.
+# default: use the most common supported rate setting for the selected
+# hw_mode (i.e., this line can be removed from configuration file in most
+# cases)
+#supported_rates=10 20 55 110 60 90 120 180 240 360 480 540
+
+# Basic rate set configuration
+# List of rates (in 100 kbps) that are included in the basic rate set.
+# If this item is not included, usually reasonable default set is used.
+#basic_rates=10 20
+#basic_rates=10 20 55 110
+#basic_rates=60 120 240
+
+# Short Preamble
+# This parameter can be used to enable optional use of short preamble for
+# frames sent at 2 Mbps, 5.5 Mbps, and 11 Mbps to improve network performance.
+# This applies only to IEEE 802.11b-compatible networks and this should only be
+# enabled if the local hardware supports use of short preamble. If any of the
+# associated STAs do not support short preamble, use of short preamble will be
+# disabled (and enabled when such STAs disassociate) dynamically.
+# 0 = do not allow use of short preamble (default)
+# 1 = allow use of short preamble
+#preamble=1
+
+# Station MAC address -based authentication
+# Please note that this kind of access control requires a driver that uses
+# hostapd to take care of management frame processing and as such, this can be
+# used with driver=hostap or driver=nl80211, but not with driver=madwifi.
+# 0 = accept unless in deny list
+# 1 = deny unless in accept list
+# 2 = use external RADIUS server (accept/deny lists are searched first)
+macaddr_acl=0
+
+# Accept/deny lists are read from separate files (containing list of
+# MAC addresses, one per line). Use absolute path name to make sure that the
+# files can be read on SIGHUP configuration reloads.
+#accept_mac_file=/etc/hostapd.accept
+#deny_mac_file=/etc/hostapd.deny
+
+# IEEE 802.11 specifies two authentication algorithms. hostapd can be
+# configured to allow both of these or only one. Open system authentication
+# should be used with IEEE 802.1X.
+# Bit fields of allowed authentication algorithms:
+# bit 0 = Open System Authentication
+# bit 1 = Shared Key Authentication (requires WEP)
+auth_algs=3
+
+# Send empty SSID in beacons and ignore probe request frames that do not
+# specify full SSID, i.e., require stations to know SSID.
+# default: disabled (0)
+# 1 = send empty (length=0) SSID in beacon and ignore probe request for
+#     broadcast SSID
+# 2 = clear SSID (ASCII 0), but keep the original length (this may be required
+#     with some clients that do not support empty SSID) and ignore probe
+#     requests for broadcast SSID
+ignore_broadcast_ssid=0
+
+# TX queue parameters (EDCF / bursting)
+# default for all these fields: not set, use hardware defaults
+# tx_queue_<queue name>_<param>
+# queues: data0, data1, data2, data3, after_beacon, beacon
+#              (data0 is the highest priority queue)
+# parameters:
+#   aifs: AIFS (default 2)
+#   cwmin: cwMin (1, 3, 7, 15, 31, 63, 127, 255, 511, 1023)
+#   cwmax: cwMax (1, 3, 7, 15, 31, 63, 127, 255, 511, 1023); cwMax >= cwMin
+#   burst: maximum length (in milliseconds with precision of up to 0.1 ms) for
+#          bursting
+#
+# Default WMM parameters (IEEE 802.11 draft; 11-03-0504-03-000e):
+# These parameters are used by the access point when transmitting frames
+# to the clients.
+#
+# Low priority / AC_BK = background
+#tx_queue_data3_aifs=7
+#tx_queue_data3_cwmin=15
+#tx_queue_data3_cwmax=1023
+#tx_queue_data3_burst=0
+# Note: for IEEE 802.11b mode: cWmin=31 cWmax=1023 burst=0
+#
+# Normal priority / AC_BE = best effort
+#tx_queue_data2_aifs=3
+#tx_queue_data2_cwmin=15
+#tx_queue_data2_cwmax=63
+#tx_queue_data2_burst=0
+# Note: for IEEE 802.11b mode: cWmin=31 cWmax=127 burst=0
+#
+# High priority / AC_VI = video
+#tx_queue_data1_aifs=1
+#tx_queue_data1_cwmin=7
+#tx_queue_data1_cwmax=15
+#tx_queue_data1_burst=3.0
+# Note: for IEEE 802.11b mode: cWmin=15 cWmax=31 burst=6.0
+#
+# Highest priority / AC_VO = voice
+#tx_queue_data0_aifs=1
+#tx_queue_data0_cwmin=3
+#tx_queue_data0_cwmax=7
+#tx_queue_data0_burst=1.5
+# Note: for IEEE 802.11b mode: cWmin=7 cWmax=15 burst=3.3
+#
+# Special queues; normally not user configurable
+#
+#tx_queue_after_beacon_aifs=2
+#tx_queue_after_beacon_cwmin=15
+#tx_queue_after_beacon_cwmax=1023
+#tx_queue_after_beacon_burst=0
+#
+#tx_queue_beacon_aifs=2
+#tx_queue_beacon_cwmin=3
+#tx_queue_beacon_cwmax=7
+#tx_queue_beacon_burst=1.5
+
+# 802.1D Tag (= UP) to AC mappings
+# WMM specifies following mapping of data frames to different ACs. This mapping
+# can be configured using Linux QoS/tc and sch_pktpri.o module.
+# 802.1D Tag   802.1D Designation      Access Category WMM Designation
+# 1            BK                      AC_BK           Background
+# 2            -                       AC_BK           Background
+# 0            BE                      AC_BE           Best Effort
+# 3            EE                      AC_BE           Best Effort
+# 4            CL                      AC_VI           Video
+# 5            VI                      AC_VI           Video
+# 6            VO                      AC_VO           Voice
+# 7            NC                      AC_VO           Voice
+# Data frames with no priority information: AC_BE
+# Management frames: AC_VO
+# PS-Poll frames: AC_BE
+
+# Default WMM parameters (IEEE 802.11 draft; 11-03-0504-03-000e):
+# for 802.11a or 802.11g networks
+# These parameters are sent to WMM clients when they associate.
+# The parameters will be used by WMM clients for frames transmitted to the
+# access point.
+#
+# note - txop_limit is in units of 32microseconds
+# note - acm is admission control mandatory flag. 0 = admission control not
+# required, 1 = mandatory
+# note - here cwMin and cmMax are in exponent form. the actual cw value used
+# will be (2^n)-1 where n is the value given here
+#
+wmm_enabled=1
+#
+# WMM-PS Unscheduled Automatic Power Save Delivery [U-APSD]
+# Enable this flag if U-APSD supported outside hostapd (eg., Firmware/driver)
+#uapsd_advertisement_enabled=1
+#
+# Low priority / AC_BK = background
+wmm_ac_bk_cwmin=4
+wmm_ac_bk_cwmax=10
+wmm_ac_bk_aifs=7
+wmm_ac_bk_txop_limit=0
+wmm_ac_bk_acm=0
+# Note: for IEEE 802.11b mode: cWmin=5 cWmax=10
+#
+# Normal priority / AC_BE = best effort
+wmm_ac_be_aifs=3
+wmm_ac_be_cwmin=4
+wmm_ac_be_cwmax=10
+wmm_ac_be_txop_limit=0
+wmm_ac_be_acm=0
+# Note: for IEEE 802.11b mode: cWmin=5 cWmax=7
+#
+# High priority / AC_VI = video
+wmm_ac_vi_aifs=2
+wmm_ac_vi_cwmin=3
+wmm_ac_vi_cwmax=4
+wmm_ac_vi_txop_limit=94
+wmm_ac_vi_acm=0
+# Note: for IEEE 802.11b mode: cWmin=4 cWmax=5 txop_limit=188
+#
+# Highest priority / AC_VO = voice
+wmm_ac_vo_aifs=2
+wmm_ac_vo_cwmin=2
+wmm_ac_vo_cwmax=3
+wmm_ac_vo_txop_limit=47
+wmm_ac_vo_acm=0
+# Note: for IEEE 802.11b mode: cWmin=3 cWmax=4 burst=102
+
+# Static WEP key configuration
+#
+# The key number to use when transmitting.
+# It must be between 0 and 3, and the corresponding key must be set.
+# default: not set
+#wep_default_key=0
+# The WEP keys to use.
+# A key may be a quoted string or unquoted hexadecimal digits.
+# The key length should be 5, 13, or 16 characters, or 10, 26, or 32
+# digits, depending on whether 40-bit (64-bit), 104-bit (128-bit), or
+# 128-bit (152-bit) WEP is used.
+# Only the default key must be supplied; the others are optional.
+# default: not set
+#wep_key0=123456789a
+#wep_key1="vwxyz"
+#wep_key2=0102030405060708090a0b0c0d
+#wep_key3=".2.4.6.8.0.23"
+
+# Station inactivity limit
+#
+# If a station does not send anything in ap_max_inactivity seconds, an
+# empty data frame is sent to it in order to verify whether it is
+# still in range. If this frame is not ACKed, the station will be
+# disassociated and then deauthenticated. This feature is used to
+# clear station table of old entries when the STAs move out of the
+# range.
+#
+# The station can associate again with the AP if it is still in range;
+# this inactivity poll is just used as a nicer way of verifying
+# inactivity; i.e., client will not report broken connection because
+# disassociation frame is not sent immediately without first polling
+# the STA with a data frame.
+# default: 300 (i.e., 5 minutes)
+#ap_max_inactivity=300
+
+# Maximum allowed Listen Interval (how many Beacon periods STAs are allowed to
+# remain asleep). Default: 65535 (no limit apart from field size)
+#max_listen_interval=100
+
+# WDS (4-address frame) mode with per-station virtual interfaces
+# (only supported with driver=nl80211)
+# This mode allows associated stations to use 4-address frames to allow layer 2
+# bridging to be used.
+#wds_sta=1
+
+##### IEEE 802.11n related configuration ######################################
+
+# ieee80211n: Whether IEEE 802.11n (HT) is enabled
+# 0 = disabled (default)
+# 1 = enabled
+# Note: You will also need to enable WMM for full HT functionality.
+#ieee80211n=1
+
+# ht_capab: HT capabilities (list of flags)
+# LDPC coding capability: [LDPC] = supported
+# Supported channel width set: [HT40-] = both 20 MHz and 40 MHz with secondary
+#      channel below the primary channel; [HT40+] = both 20 MHz and 40 MHz
+#      with secondary channel below the primary channel
+#      (20 MHz only if neither is set)
+#      Note: There are limits on which channels can be used with HT40- and
+#      HT40+. Following table shows the channels that may be available for
+#      HT40- and HT40+ use per IEEE 802.11n Annex J:
+#      freq            HT40-           HT40+
+#      2.4 GHz         5-13            1-7 (1-9 in Europe/Japan)
+#      5 GHz           40,48,56,64     36,44,52,60
+#      (depending on the location, not all of these channels may be available
+#      for use)
+#      Please note that 40 MHz channels may switch their primary and secondary
+#      channels if needed or creation of 40 MHz channel maybe rejected based
+#      on overlapping BSSes. These changes are done automatically when hostapd
+#      is setting up the 40 MHz channel.
+# Spatial Multiplexing (SM) Power Save: [SMPS-STATIC] or [SMPS-DYNAMIC]
+#      (SMPS disabled if neither is set)
+# HT-greenfield: [GF] (disabled if not set)
+# Short GI for 20 MHz: [SHORT-GI-20] (disabled if not set)
+# Short GI for 40 MHz: [SHORT-GI-40] (disabled if not set)
+# Tx STBC: [TX-STBC] (disabled if not set)
+# Rx STBC: [RX-STBC1] (one spatial stream), [RX-STBC12] (one or two spatial
+#      streams), or [RX-STBC123] (one, two, or three spatial streams); Rx STBC
+#      disabled if none of these set
+# HT-delayed Block Ack: [DELAYED-BA] (disabled if not set)
+# Maximum A-MSDU length: [MAX-AMSDU-7935] for 7935 octets (3839 octets if not
+#      set)
+# DSSS/CCK Mode in 40 MHz: [DSSS_CCK-40] = allowed (not allowed if not set)
+# PSMP support: [PSMP] (disabled if not set)
+# L-SIG TXOP protection support: [LSIG-TXOP-PROT] (disabled if not set)
+#ht_capab=[HT40-][SHORT-GI-20][SHORT-GI-40]
+
+##### IEEE 802.1X-2004 related configuration ##################################
+
+# Require IEEE 802.1X authorization
+#ieee8021x=1
+
+# IEEE 802.1X/EAPOL version
+# hostapd is implemented based on IEEE Std 802.1X-2004 which defines EAPOL
+# version 2. However, there are many client implementations that do not handle
+# the new version number correctly (they seem to drop the frames completely).
+# In order to make hostapd interoperate with these clients, the version number
+# can be set to the older version (1) with this configuration value.
+#eapol_version=2
+
+# Optional displayable message sent with EAP Request-Identity. The first \0
+# in this string will be converted to ASCII-0 (nul). This can be used to
+# separate network info (comma separated list of attribute=value pairs); see,
+# e.g., RFC 4284.
+#eap_message=hello
+#eap_message=hello\0networkid=netw,nasid=foo,portid=0,NAIRealms=example.com
+
+# WEP rekeying (disabled if key lengths are not set or are set to 0)
+# Key lengths for default/broadcast and individual/unicast keys:
+# 5 = 40-bit WEP (also known as 64-bit WEP with 40 secret bits)
+# 13 = 104-bit WEP (also known as 128-bit WEP with 104 secret bits)
+#wep_key_len_broadcast=5
+#wep_key_len_unicast=5
+# Rekeying period in seconds. 0 = do not rekey (i.e., set keys only once)
+#wep_rekey_period=300
+
+# EAPOL-Key index workaround (set bit7) for WinXP Supplicant (needed only if
+# only broadcast keys are used)
+eapol_key_index_workaround=0
+
+# EAP reauthentication period in seconds (default: 3600 seconds; 0 = disable
+# reauthentication).
+#eap_reauth_period=3600
+
+# Use PAE group address (01:80:c2:00:00:03) instead of individual target
+# address when sending EAPOL frames with driver=wired. This is the most common
+# mechanism used in wired authentication, but it also requires that the port
+# is only used by one station.
+#use_pae_group_addr=1
+
+##### Integrated EAP server ###################################################
+
+# Optionally, hostapd can be configured to use an integrated EAP server
+# to process EAP authentication locally without need for an external RADIUS
+# server. This functionality can be used both as a local authentication server
+# for IEEE 802.1X/EAPOL and as a RADIUS server for other devices.
+
+# Use integrated EAP server instead of external RADIUS authentication
+# server. This is also needed if hostapd is configured to act as a RADIUS
+# authentication server.
+eap_server=0
+
+# Path for EAP server user database
+#eap_user_file=/etc/hostapd.eap_user
+
+# CA certificate (PEM or DER file) for EAP-TLS/PEAP/TTLS
+#ca_cert=/etc/hostapd.ca.pem
+
+# Server certificate (PEM or DER file) for EAP-TLS/PEAP/TTLS
+#server_cert=/etc/hostapd.server.pem
+
+# Private key matching with the server certificate for EAP-TLS/PEAP/TTLS
+# This may point to the same file as server_cert if both certificate and key
+# are included in a single file. PKCS#12 (PFX) file (.p12/.pfx) can also be
+# used by commenting out server_cert and specifying the PFX file as the
+# private_key.
+#private_key=/etc/hostapd.server.prv
+
+# Passphrase for private key
+#private_key_passwd=secret passphrase
+
+# Enable CRL verification.
+# Note: hostapd does not yet support CRL downloading based on CDP. Thus, a
+# valid CRL signed by the CA is required to be included in the ca_cert file.
+# This can be done by using PEM format for CA certificate and CRL and
+# concatenating these into one file. Whenever CRL changes, hostapd needs to be
+# restarted to take the new CRL into use.
+# 0 = do not verify CRLs (default)
+# 1 = check the CRL of the user certificate
+# 2 = check all CRLs in the certificate path
+#check_crl=1
+
+# dh_file: File path to DH/DSA parameters file (in PEM format)
+# This is an optional configuration file for setting parameters for an
+# ephemeral DH key exchange. In most cases, the default RSA authentication does
+# not use this configuration. However, it is possible setup RSA to use
+# ephemeral DH key exchange. In addition, ciphers with DSA keys always use
+# ephemeral DH keys. This can be used to achieve forward secrecy. If the file
+# is in DSA parameters format, it will be automatically converted into DH
+# params. This parameter is required if anonymous EAP-FAST is used.
+# You can generate DH parameters file with OpenSSL, e.g.,
+# "openssl dhparam -out /etc/hostapd.dh.pem 1024"
+#dh_file=/etc/hostapd.dh.pem
+
+# Configuration data for EAP-SIM database/authentication gateway interface.
+# This is a text string in implementation specific format. The example
+# implementation in eap_sim_db.c uses this as the UNIX domain socket name for
+# the HLR/AuC gateway (e.g., hlr_auc_gw). In this case, the path uses "unix:"
+# prefix.
+#eap_sim_db=unix:/tmp/hlr_auc_gw.sock
+
+# Encryption key for EAP-FAST PAC-Opaque values. This key must be a secret,
+# random value. It is configured as a 16-octet value in hex format. It can be
+# generated, e.g., with the following command:
+# od -tx1 -v -N16 /dev/random | colrm 1 8 | tr -d ' '
+#pac_opaque_encr_key=000102030405060708090a0b0c0d0e0f
+
+# EAP-FAST authority identity (A-ID)
+# A-ID indicates the identity of the authority that issues PACs. The A-ID
+# should be unique across all issuing servers. In theory, this is a variable
+# length field, but due to some existing implementations requiring A-ID to be
+# 16 octets in length, it is strongly recommended to use that length for the
+# field to provid interoperability with deployed peer implementations. This
+# field is configured in hex format.
+#eap_fast_a_id=101112131415161718191a1b1c1d1e1f
+
+# EAP-FAST authority identifier information (A-ID-Info)
+# This is a user-friendly name for the A-ID. For example, the enterprise name
+# and server name in a human-readable format. This field is encoded as UTF-8.
+#eap_fast_a_id_info=test server
+
+# Enable/disable different EAP-FAST provisioning modes:
+#0 = provisioning disabled
+#1 = only anonymous provisioning allowed
+#2 = only authenticated provisioning allowed
+#3 = both provisioning modes allowed (default)
+#eap_fast_prov=3
+
+# EAP-FAST PAC-Key lifetime in seconds (hard limit)
+#pac_key_lifetime=604800
+
+# EAP-FAST PAC-Key refresh time in seconds (soft limit on remaining hard
+# limit). The server will generate a new PAC-Key when this number of seconds
+# (or fewer) of the lifetime remains.
+#pac_key_refresh_time=86400
+
+# EAP-SIM and EAP-AKA protected success/failure indication using AT_RESULT_IND
+# (default: 0 = disabled).
+#eap_sim_aka_result_ind=1
+
+# Trusted Network Connect (TNC)
+# If enabled, TNC validation will be required before the peer is allowed to
+# connect. Note: This is only used with EAP-TTLS and EAP-FAST. If any other
+# EAP method is enabled, the peer will be allowed to connect without TNC.
+#tnc=1
+
+
+##### IEEE 802.11f - Inter-Access Point Protocol (IAPP) #######################
+
+# Interface to be used for IAPP broadcast packets
+#iapp_interface=eth0
+
+
+##### RADIUS client configuration #############################################
+# for IEEE 802.1X with external Authentication Server, IEEE 802.11
+# authentication with external ACL for MAC addresses, and accounting
+
+# The own IP address of the access point (used as NAS-IP-Address)
+own_ip_addr=127.0.0.1
+
+# Optional NAS-Identifier string for RADIUS messages. When used, this should be
+# a unique to the NAS within the scope of the RADIUS server. For example, a
+# fully qualified domain name can be used here.
+# When using IEEE 802.11r, nas_identifier must be set and must be between 1 and
+# 48 octets long.
+#nas_identifier=ap.example.com
+
+# RADIUS authentication server
+#auth_server_addr=127.0.0.1
+#auth_server_port=1812
+#auth_server_shared_secret=secret
+
+# RADIUS accounting server
+#acct_server_addr=127.0.0.1
+#acct_server_port=1813
+#acct_server_shared_secret=secret
+
+# Secondary RADIUS servers; to be used if primary one does not reply to
+# RADIUS packets. These are optional and there can be more than one secondary
+# server listed.
+#auth_server_addr=127.0.0.2
+#auth_server_port=1812
+#auth_server_shared_secret=secret2
+#
+#acct_server_addr=127.0.0.2
+#acct_server_port=1813
+#acct_server_shared_secret=secret2
+
+# Retry interval for trying to return to the primary RADIUS server (in
+# seconds). RADIUS client code will automatically try to use the next server
+# when the current server is not replying to requests. If this interval is set,
+# primary server will be retried after configured amount of time even if the
+# currently used secondary server is still working.
+#radius_retry_primary_interval=600
+
+
+# Interim accounting update interval
+# If this is set (larger than 0) and acct_server is configured, hostapd will
+# send interim accounting updates every N seconds. Note: if set, this overrides
+# possible Acct-Interim-Interval attribute in Access-Accept message. Thus, this
+# value should not be configured in hostapd.conf, if RADIUS server is used to
+# control the interim interval.
+# This value should not be less 600 (10 minutes) and must not be less than
+# 60 (1 minute).
+#radius_acct_interim_interval=600
+
+# Dynamic VLAN mode; allow RADIUS authentication server to decide which VLAN
+# is used for the stations. This information is parsed from following RADIUS
+# attributes based on RFC 3580 and RFC 2868: Tunnel-Type (value 13 = VLAN),
+# Tunnel-Medium-Type (value 6 = IEEE 802), Tunnel-Private-Group-ID (value
+# VLANID as a string). vlan_file option below must be configured if dynamic
+# VLANs are used. Optionally, the local MAC ACL list (accept_mac_file) can be
+# used to set static client MAC address to VLAN ID mapping.
+# 0 = disabled (default)
+# 1 = option; use default interface if RADIUS server does not include VLAN ID
+# 2 = required; reject authentication if RADIUS server does not include VLAN ID
+#dynamic_vlan=0
+
+# VLAN interface list for dynamic VLAN mode is read from a separate text file.
+# This list is used to map VLAN ID from the RADIUS server to a network
+# interface. Each station is bound to one interface in the same way as with
+# multiple BSSIDs or SSIDs. Each line in this text file is defining a new
+# interface and the line must include VLAN ID and interface name separated by
+# white space (space or tab).
+#vlan_file=/etc/hostapd.vlan
+
+# Interface where 802.1q tagged packets should appear when a RADIUS server is
+# used to determine which VLAN a station is on.  hostapd creates a bridge for
+# each VLAN.  Then hostapd adds a VLAN interface (associated with the interface
+# indicated by 'vlan_tagged_interface') and the appropriate wireless interface
+# to the bridge.
+#vlan_tagged_interface=eth0
+
+
+##### RADIUS authentication server configuration ##############################
+
+# hostapd can be used as a RADIUS authentication server for other hosts. This
+# requires that the integrated EAP server is also enabled and both
+# authentication services are sharing the same configuration.
+
+# File name of the RADIUS clients configuration for the RADIUS server. If this
+# commented out, RADIUS server is disabled.
+#radius_server_clients=/etc/hostapd.radius_clients
+
+# The UDP port number for the RADIUS authentication server
+#radius_server_auth_port=1812
+
+# Use IPv6 with RADIUS server (IPv4 will also be supported using IPv6 API)
+#radius_server_ipv6=1
+
+
+##### WPA/IEEE 802.11i configuration ##########################################
+
+# Enable WPA. Setting this variable configures the AP to require WPA (either
+# WPA-PSK or WPA-RADIUS/EAP based on other configuration). For WPA-PSK, either
+# wpa_psk or wpa_passphrase must be set and wpa_key_mgmt must include WPA-PSK.
+# For WPA-RADIUS/EAP, ieee8021x must be set (but without dynamic WEP keys),
+# RADIUS authentication server must be configured, and WPA-EAP must be included
+# in wpa_key_mgmt.
+# This field is a bit field that can be used to enable WPA (IEEE 802.11i/D3.0)
+# and/or WPA2 (full IEEE 802.11i/RSN):
+# bit0 = WPA
+# bit1 = IEEE 802.11i/RSN (WPA2) (dot11RSNAEnabled)
+#wpa=1
+
+# WPA pre-shared keys for WPA-PSK. This can be either entered as a 256-bit
+# secret in hex format (64 hex digits), wpa_psk, or as an ASCII passphrase
+# (8..63 characters) that will be converted to PSK. This conversion uses SSID
+# so the PSK changes when ASCII passphrase is used and the SSID is changed.
+# wpa_psk (dot11RSNAConfigPSKValue)
+# wpa_passphrase (dot11RSNAConfigPSKPassPhrase)
+#wpa_psk=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
+#wpa_passphrase=secret passphrase
+
+# Optionally, WPA PSKs can be read from a separate text file (containing list
+# of (PSK,MAC address) pairs. This allows more than one PSK to be configured.
+# Use absolute path name to make sure that the files can be read on SIGHUP
+# configuration reloads.
+#wpa_psk_file=/etc/hostapd.wpa_psk
+
+# Set of accepted key management algorithms (WPA-PSK, WPA-EAP, or both). The
+# entries are separated with a space. WPA-PSK-SHA256 and WPA-EAP-SHA256 can be
+# added to enable SHA256-based stronger algorithms.
+# (dot11RSNAConfigAuthenticationSuitesTable)
+#wpa_key_mgmt=WPA-PSK WPA-EAP
+
+# Set of accepted cipher suites (encryption algorithms) for pairwise keys
+# (unicast packets). This is a space separated list of algorithms:
+# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]
+# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]
+# Group cipher suite (encryption algorithm for broadcast and multicast frames)
+# is automatically selected based on this configuration. If only CCMP is
+# allowed as the pairwise cipher, group cipher will also be CCMP. Otherwise,
+# TKIP will be used as the group cipher.
+# (dot11RSNAConfigPairwiseCiphersTable)
+# Pairwise cipher for WPA (v1) (default: TKIP)
+#wpa_pairwise=TKIP CCMP
+# Pairwise cipher for RSN/WPA2 (default: use wpa_pairwise value)
+#rsn_pairwise=CCMP
+
+# Time interval for rekeying GTK (broadcast/multicast encryption keys) in
+# seconds. (dot11RSNAConfigGroupRekeyTime)
+#wpa_group_rekey=600
+
+# Rekey GTK when any STA that possesses the current GTK is leaving the BSS.
+# (dot11RSNAConfigGroupRekeyStrict)
+#wpa_strict_rekey=1
+
+# Time interval for rekeying GMK (master key used internally to generate GTKs
+# (in seconds).
+#wpa_gmk_rekey=86400
+
+# Maximum lifetime for PTK in seconds. This can be used to enforce rekeying of
+# PTK to mitigate some attacks against TKIP deficiencies.
+#wpa_ptk_rekey=600
+
+# Enable IEEE 802.11i/RSN/WPA2 pre-authentication. This is used to speed up
+# roaming be pre-authenticating IEEE 802.1X/EAP part of the full RSN
+# authentication and key handshake before actually associating with a new AP.
+# (dot11RSNAPreauthenticationEnabled)
+#rsn_preauth=1
+#
+# Space separated list of interfaces from which pre-authentication frames are
+# accepted (e.g., 'eth0' or 'eth0 wlan0wds0'. This list should include all
+# interface that are used for connections to other APs. This could include
+# wired interfaces and WDS links. The normal wireless data interface towards
+# associated stations (e.g., wlan0) should not be added, since
+# pre-authentication is only used with APs other than the currently associated
+# one.
+#rsn_preauth_interfaces=eth0
+
+# peerkey: Whether PeerKey negotiation for direct links (IEEE 802.11e) is
+# allowed. This is only used with RSN/WPA2.
+# 0 = disabled (default)
+# 1 = enabled
+#peerkey=1
+
+# ieee80211w: Whether management frame protection (MFP) is enabled
+# 0 = disabled (default)
+# 1 = optional
+# 2 = required
+#ieee80211w=0
+
+# Association SA Query maximum timeout (in TU = 1.024 ms; for MFP)
+# (maximum time to wait for a SA Query response)
+# dot11AssociationSAQueryMaximumTimeout, 1...4294967295
+#assoc_sa_query_max_timeout=1000
+
+# Association SA Query retry timeout (in TU = 1.024 ms; for MFP)
+# (time between two subsequent SA Query requests)
+# dot11AssociationSAQueryRetryTimeout, 1...4294967295
+#assoc_sa_query_retry_timeout=201
+
+
+# okc: Opportunistic Key Caching (aka Proactive Key Caching)
+# Allow PMK cache to be shared opportunistically among configured interfaces
+# and BSSes (i.e., all configurations within a single hostapd process).
+# 0 = disabled (default)
+# 1 = enabled
+#okc=1
+
+
+##### IEEE 802.11r configuration ##############################################
+
+# Mobility Domain identifier (dot11FTMobilityDomainID, MDID)
+# MDID is used to indicate a group of APs (within an ESS, i.e., sharing the
+# same SSID) between which a STA can use Fast BSS Transition.
+# 2-octet identifier as a hex string.
+#mobility_domain=a1b2
+
+# PMK-R0 Key Holder identifier (dot11FTR0KeyHolderID)
+# 1 to 48 octet identifier.
+# This is configured with nas_identifier (see RADIUS client section above).
+
+# Default lifetime of the PMK-RO in minutes; range 1..65535
+# (dot11FTR0KeyLifetime)
+#r0_key_lifetime=10000
+
+# PMK-R1 Key Holder identifier (dot11FTR1KeyHolderID)
+# 6-octet identifier as a hex string.
+#r1_key_holder=000102030405
+
+# Reassociation deadline in time units (TUs / 1.024 ms; range 1000..65535)
+# (dot11FTReassociationDeadline)
+#reassociation_deadline=1000
+
+# List of R0KHs in the same Mobility Domain
+# format: <MAC address> <NAS Identifier> <128-bit key as hex string>
+# This list is used to map R0KH-ID (NAS Identifier) to a destination MAC
+# address when requesting PMK-R1 key from the R0KH that the STA used during the
+# Initial Mobility Domain Association.
+#r0kh=02:01:02:03:04:05 r0kh-1.example.com 000102030405060708090a0b0c0d0e0f
+#r0kh=02:01:02:03:04:06 r0kh-2.example.com 00112233445566778899aabbccddeeff
+# And so on.. One line per R0KH.
+
+# List of R1KHs in the same Mobility Domain
+# format: <MAC address> <R1KH-ID> <128-bit key as hex string>
+# This list is used to map R1KH-ID to a destination MAC address when sending
+# PMK-R1 key from the R0KH. This is also the list of authorized R1KHs in the MD
+# that can request PMK-R1 keys.
+#r1kh=02:01:02:03:04:05 02:11:22:33:44:55 000102030405060708090a0b0c0d0e0f
+#r1kh=02:01:02:03:04:06 02:11:22:33:44:66 00112233445566778899aabbccddeeff
+# And so on.. One line per R1KH.
+
+# Whether PMK-R1 push is enabled at R0KH
+# 0 = do not push PMK-R1 to all configured R1KHs (default)
+# 1 = push PMK-R1 to all configured R1KHs whenever a new PMK-R0 is derived
+#pmk_r1_push=1
+
+##### Neighbor table ##########################################################
+# Maximum number of entries kept in AP table (either for neigbor table or for
+# detecting Overlapping Legacy BSS Condition). The oldest entry will be
+# removed when adding a new entry that would make the list grow over this
+# limit. Note! WFA certification for IEEE 802.11g requires that OLBC is
+# enabled, so this field should not be set to 0 when using IEEE 802.11g.
+# default: 255
+#ap_table_max_size=255
+
+# Number of seconds of no frames received after which entries may be deleted
+# from the AP table. Since passive scanning is not usually performed frequently
+# this should not be set to very small value. In addition, there is no
+# guarantee that every scan cycle will receive beacon frames from the
+# neighboring APs.
+# default: 60
+#ap_table_expiration_time=3600
+
+
+##### Wi-Fi Protected Setup (WPS) #############################################
+
+# WPS state
+# 0 = WPS disabled (default)
+# 1 = WPS enabled, not configured
+# 2 = WPS enabled, configured
+#wps_state=2
+
+# AP can be configured into a locked state where new WPS Registrar are not
+# accepted, but previously authorized Registrars (including the internal one)
+# can continue to add new Enrollees.
+#ap_setup_locked=1
+
+# Universally Unique IDentifier (UUID; see RFC 4122) of the device
+# This value is used as the UUID for the internal WPS Registrar. If the AP
+# is also using UPnP, this value should be set to the device's UPnP UUID.
+# If not configured, UUID will be generated based on the local MAC address.
+#uuid=12345678-9abc-def0-1234-56789abcdef0
+
+# Note: If wpa_psk_file is set, WPS is used to generate random, per-device PSKs
+# that will be appended to the wpa_psk_file. If wpa_psk_file is not set, the
+# default PSK (wpa_psk/wpa_passphrase) will be delivered to Enrollees. Use of
+# per-device PSKs is recommended as the more secure option (i.e., make sure to
+# set wpa_psk_file when using WPS with WPA-PSK).
+
+# When an Enrollee requests access to the network with PIN method, the Enrollee
+# PIN will need to be entered for the Registrar. PIN request notifications are
+# sent to hostapd ctrl_iface monitor. In addition, they can be written to a
+# text file that could be used, e.g., to populate the AP administration UI with
+# pending PIN requests. If the following variable is set, the PIN requests will
+# be written to the configured file.
+#wps_pin_requests=/var/run/hostapd_wps_pin_requests
+
+# Device Name
+# User-friendly description of device; up to 32 octets encoded in UTF-8
+#device_name=Wireless AP
+
+# Manufacturer
+# The manufacturer of the device (up to 64 ASCII characters)
+#manufacturer=Company
+
+# Model Name
+# Model of the device (up to 32 ASCII characters)
+#model_name=WAP
+
+# Model Number
+# Additional device description (up to 32 ASCII characters)
+#model_number=123
+
+# Serial Number
+# Serial number of the device (up to 32 characters)
+#serial_number=12345
+
+# Primary Device Type
+# Used format: <categ>-<OUI>-<subcateg>
+# categ = Category as an integer value
+# OUI = OUI and type octet as a 4-octet hex-encoded value; 0050F204 for
+#       default WPS OUI
+# subcateg = OUI-specific Sub Category as an integer value
+# Examples:
+#   1-0050F204-1 (Computer / PC)
+#   1-0050F204-2 (Computer / Server)
+#   5-0050F204-1 (Storage / NAS)
+#   6-0050F204-1 (Network Infrastructure / AP)
+#device_type=6-0050F204-1
+
+# OS Version
+# 4-octet operating system version number (hex string)
+#os_version=01020300
+
+# Config Methods
+# List of the supported configuration methods
+# Available methods: usba ethernet label display ext_nfc_token int_nfc_token
+#      nfc_interface push_button keypad
+#config_methods=label display push_button keypad
+
+# Static access point PIN for initial configuration and adding Registrars
+# If not set, hostapd will not allow external WPS Registrars to control the
+# access point. The AP PIN can also be set at runtime with hostapd_cli
+# wps_ap_pin command. Use of temporary (enabled by user action) and random
+# AP PIN is much more secure than configuring a static AP PIN here. As such,
+# use of the ap_pin parameter is not recommended if the AP device has means for
+# displaying a random PIN.
+#ap_pin=12345670
+
+# Skip building of automatic WPS credential
+# This can be used to allow the automatically generated Credential attribute to
+# be replaced with pre-configured Credential(s).
+#skip_cred_build=1
+
+# Additional Credential attribute(s)
+# This option can be used to add pre-configured Credential attributes into M8
+# message when acting as a Registrar. If skip_cred_build=1, this data will also
+# be able to override the Credential attribute that would have otherwise been
+# automatically generated based on network configuration. This configuration
+# option points to an external file that much contain the WPS Credential
+# attribute(s) as binary data.
+#extra_cred=hostapd.cred
+
+# Credential processing
+#   0 = process received credentials internally (default)
+#   1 = do not process received credentials; just pass them over ctrl_iface to
+#      external program(s)
+#   2 = process received credentials internally and pass them over ctrl_iface
+#      to external program(s)
+# Note: With wps_cred_processing=1, skip_cred_build should be set to 1 and
+# extra_cred be used to provide the Credential data for Enrollees.
+#
+# wps_cred_processing=1 will disabled automatic updates of hostapd.conf file
+# both for Credential processing and for marking AP Setup Locked based on
+# validation failures of AP PIN. An external program is responsible on updating
+# the configuration appropriately in this case.
+#wps_cred_processing=0
+
+# AP Settings Attributes for M7
+# By default, hostapd generates the AP Settings Attributes for M7 based on the
+# current configuration. It is possible to override this by providing a file
+# with pre-configured attributes. This is similar to extra_cred file format,
+# but the AP Settings attributes are not encapsulated in a Credential
+# attribute.
+#ap_settings=hostapd.ap_settings
+
+# WPS UPnP interface
+# If set, support for external Registrars is enabled.
+#upnp_iface=br0
+
+# Friendly Name (required for UPnP)
+# Short description for end use. Should be less than 64 characters.
+#friendly_name=WPS Access Point
+
+# Manufacturer URL (optional for UPnP)
+#manufacturer_url=http://www.example.com/
+
+# Model Description (recommended for UPnP)
+# Long description for end user. Should be less than 128 characters.
+#model_description=Wireless Access Point
+
+# Model URL (optional for UPnP)
+#model_url=http://www.example.com/model/
+
+# Universal Product Code (optional for UPnP)
+# 12-digit, all-numeric code that identifies the consumer package.
+#upc=123456789012
+
+##### Multiple BSSID support ##################################################
+#
+# Above configuration is using the default interface (wlan#, or multi-SSID VLAN
+# interfaces). Other BSSIDs can be added by using separator 'bss' with
+# default interface name to be allocated for the data packets of the new BSS.
+#
+# hostapd will generate BSSID mask based on the BSSIDs that are
+# configured. hostapd will verify that dev_addr & MASK == dev_addr. If this is
+# not the case, the MAC address of the radio must be changed before starting
+# hostapd (ifconfig wlan0 hw ether <MAC addr>). If a BSSID is configured for
+# every secondary BSS, this limitation is not applied at hostapd and other
+# masks may be used if the driver supports them (e.g., swap the locally
+# administered bit)
+#
+# BSSIDs are assigned in order to each BSS, unless an explicit BSSID is
+# specified using the 'bssid' parameter.
+# If an explicit BSSID is specified, it must be chosen such that it:
+# - results in a valid MASK that covers it and the dev_addr
+# - is not the same as the MAC address of the radio
+# - is not the same as any other explicitly specified BSSID
+#
+# Please note that hostapd uses some of the values configured for the first BSS
+# as the defaults for the following BSSes. However, it is recommended that all
+# BSSes include explicit configuration of all relevant configuration items.
+#
+#bss=wlan0_0
+#ssid=test2
+# most of the above items can be used here (apart from radio interface specific
+# items, like channel)
+
+#bss=wlan0_1
+#bssid=00:13:10:95:fe:0b
+# ...
diff --git a/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..6369e8c
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_wirelessaccesspoint.xml
diff --git a/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/meta/plugin_wirelessaccesspoint.xml b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/meta/plugin_wirelessaccesspoint.xml
new file mode 100755 (executable)
index 0000000..cf53317
--- /dev/null
@@ -0,0 +1,17 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+                    <tag type="Network" />
+         </prerequisites>
+          <info>
+                    <author>hschang</author>
+                    <name>Wireless Access Point</name>
+                    <packagename>enigma2-plugin-systemplugins-wirelessaccesspoint</packagename>
+                    <shortdescription>Using a Wireless module as AP.</shortdescription>
+                    <description>Using a Wireless module as AP.\n(The Module should support master mode)</description>
+          </info>
+
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-systemplugins-wirelessaccesspoint" />
+       </files>
+</default>
diff --git a/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/plugin.py
new file mode 100755 (executable)
index 0000000..9635780
--- /dev/null
@@ -0,0 +1,589 @@
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen, ConfigList
+from Components.config import config, ConfigSubsection, getConfigListEntry, ConfigSelection, ConfigIP, ConfigInteger
+from Components.config import ConfigText, ConfigYesNo, NoSave, ConfigPassword, ConfigNothing, ConfigSequence
+from Components.ActionMap import ActionMap
+from Screens.MessageBox import MessageBox
+from Components.Sources.StaticText import StaticText
+from Plugins.Plugin import PluginDescriptor
+from Tools.Directories import fileExists
+from math import pow as math_pow
+from Components.Network import iNetwork
+from Components.PluginComponent import plugins
+from Components.Console import Console
+from os import path as os_path, system as os_system, listdir
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS
+from enigma import eTimer
+import wirelessap
+
+debug_msg_on = False
+def printDebugMsg(msg):
+       global debug_msg_on
+       if debug_msg_on:
+               print "[Wireless Access Point] ", msg
+
+class fixedValue:
+       def __init__(self, value = ""):
+               self.value = value
+
+apModeConfig = ConfigSubsection()
+apModeConfig.useap = ConfigYesNo(default = False)
+apModeConfig.setupmode = ConfigSelection(default = "simple", choices = [ ("simple", "Simple"), ("advanced", "Advanced") ] )
+#apModeConfig.wirelessdevice = fixedValue(value = "")
+apModeConfig.branch = fixedValue(value = "br0")
+apModeConfig.driver = fixedValue(value = "nl80211")
+apModeConfig.wirelessmode = ConfigSelection(default = "g", choices = [ ("b", "802.11b"), ("a", "802.11a"), ("g", "802.11g") ] )
+apModeConfig.channel = ConfigInteger(default = 1, limits = (1,13) )
+apModeConfig.ssid = ConfigText(default = "Input SSID", visible_width = 50, fixed_size = False)
+apModeConfig.beacon = ConfigInteger(default = 100, limits = (15,65535))
+apModeConfig.rts_threshold = ConfigInteger(default = 2347, limits = (0,2347) )
+apModeConfig.fragm_threshold = ConfigInteger(default = 2346, limits = (256,2346) )
+apModeConfig.preamble = ConfigSelection(default = "0", choices = [ ("0", "Long"), ("1", "Short") ] )
+apModeConfig.ignore_broadcast_ssid = ConfigSelection(default = "0", choices = [ ("0", _("disabled")), ("1", _("enabled")) ])
+
+apModeConfig.encrypt = ConfigYesNo(default = False)
+apModeConfig.method = ConfigSelection(default = "0", choices = [
+       ("0", _("WEP")), ("1", _("WPA")), ("2", _("WPA2")),("3", _("WPA/WPA2"))])
+apModeConfig.wep = ConfigYesNo(default = False)
+#apModeConfig.wep_default_key = ConfigSelection(default = "0", choices = [ ("0", "0"), ("1", "1"), ("2", "2"), ("3", "3") ] )
+apModeConfig.wep_default_key = fixedValue(value = "0")
+apModeConfig.wepType = ConfigSelection(default = "64", choices = [
+       ("64", _("Enable 64 bit (Input 10 hex keys)")), ("128", _("Enable 128 bit (Input 26 hex keys)"))])
+apModeConfig.wep_key0 = ConfigPassword(default = "", visible_width = 50, fixed_size = False)
+apModeConfig.wpa = ConfigSelection(default = "0", choices = [
+       ("0", _("not set")), ("1", _("WPA")), ("2", _("WPA2")),("3", _("WPA/WPA2"))])
+apModeConfig.wpa_passphrase = ConfigPassword(default = "", visible_width = 50, fixed_size = False)
+apModeConfig.wpagrouprekey = ConfigInteger(default = 600, limits = (0,3600))
+apModeConfig.wpa_key_mgmt = fixedValue(value = "WPA-PSK")
+apModeConfig.wpa_pairwise = fixedValue(value = "TKIP CCMP")
+apModeConfig.rsn_pairwise = fixedValue(value = "CCMP")
+
+apModeConfig.usedhcp = ConfigYesNo(default=True)
+apModeConfig.address = ConfigIP(default = [0,0,0,0])
+apModeConfig.netmask = ConfigIP(default = [255,0,0,0])
+apModeConfig.gateway = ConfigIP(default = [0,0,0,0])
+
+class WirelessAccessPoint(Screen,ConfigListScreen):
+       skin = """
+               <screen position="center,center" size="590,450" title="Wireless Access Point" >
+               <ePixmap pixmap="skin_default/buttons/red.png" position="20,0" size="140,40" alphatest="on" />
+               <ePixmap pixmap="skin_default/buttons/green.png" position="160,0" size="140,40" alphatest="on" />
+               <ePixmap pixmap="skin_default/buttons/yellow.png" position="300,0" size="140,40" alphatest="on" />
+               <ePixmap pixmap="skin_default/buttons/blue.png" position="440,0" size="140,40" alphatest="on" />
+
+               <widget source="key_red" render="Label" position="20,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#9f1313" transparent="1" />
+               <widget source="key_green" render="Label" position="160,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#1f771f" transparent="1" />
+               <widget source="key_yellow" render="Label" position="300,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#a08500" transparent="1" />
+               <widget source="key_blue" render="Label" position="440,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#18188b" transparent="1" />
+
+               <widget name="config" zPosition="2" position="10,70" size="580,270" scrollbarMode="showOnDemand" transparent="1" />
+               <widget source="current_settings" render="Label" position="10,340" size="570,20" font="Regular;19" halign="center" valign="center" transparent="1" />
+               <widget source="IPAddress_text" render="Label" position="130,370" size="190,21" font="Regular;19" transparent="1" />
+               <widget source="Netmask_text" render="Label" position="130,395" size="190,21" font="Regular;19" transparent="1" />
+               <widget source="Gateway_text" render="Label" position="130,420" size="190,21" font="Regular;19" transparent="1" />
+               <widget source="IPAddress" render="Label" position="340,370" size="240,21" font="Regular;19" transparent="1" />
+               <widget source="Netmask" render="Label" position="340,395" size="240,21" font="Regular;19" transparent="1" />
+               <widget source="Gateway" render="Label" position="340,420" size="240,21" font="Regular;19" transparent="1" />
+               </screen>"""
+
+       def __init__(self,session):
+               Screen.__init__(self,session)
+               self.session = session
+               self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
+               {
+                       "ok": self.doConfigMsg,
+                       "cancel": self.keyCancel,
+                       "red": self.keyCancel,
+                       "green": self.doConfigMsg,
+               }, -2)
+               self.list = []
+               ConfigListScreen.__init__(self, self.list,session = self.session)
+               self["key_red"] = StaticText(_("Cancel"))
+               self["key_green"] = StaticText(_("Ok"))
+               self["key_yellow"] = StaticText(_(" "))
+               self["key_blue"] = StaticText(_(" "))
+               self["current_settings"] = StaticText(_("Current settings (interface : br0)"))
+               self["IPAddress_text"] = StaticText(_("IP Address"))
+               self["Netmask_text"] = StaticText(_("Netmask"))
+               self["Gateway_text"] = StaticText(_("Gateway"))
+               self["IPAddress"] = StaticText(_("N/A"))
+               self["Netmask"] = StaticText(_("N/A"))
+               self["Gateway"] = StaticText(_("N/A"))
+               self.wirelessAP = wirelessap.wirelessAP()
+               self.checkRunHostapd()
+               self.checkWirelessDevices()
+               self.makeConfigList()
+               self.loadInterfacesConfig()
+               self.loadHostapConfig()
+               self.setupCurrentEncryption()
+               self.createConfigEntry()
+               self.createConfig()
+               self.onClose.append(self.__onClose)
+               self.onLayoutFinish.append(self.checkwlanDeviceList)
+               self.onLayoutFinish.append(self.currentNetworkSettings)
+               self.checkwlanDeviceListTimer = eTimer()
+               self.checkwlanDeviceListTimer.callback.append(self.WirelessDeviceNotDetectedMsg)
+
+       def checkwlanDeviceList(self):
+               if len(self.wlanDeviceList) == 0:
+                       self.checkwlanDeviceListTimer.start(100,True)
+
+       def WirelessDeviceNotDetectedMsg(self):
+               self.session.openWithCallback(self.close ,MessageBox, _("Wireless Lan Device is not detected."), MessageBox.TYPE_ERROR)
+
+       def currentNetworkSettings(self):
+               self["IPAddress"].setText(self.formatAddr(iNetwork.getAdapterAttribute("br0", "ip")))
+               self["Netmask"].setText(self.formatAddr(iNetwork.getAdapterAttribute("br0", "netmask")))
+               self["Gateway"].setText(self.formatAddr(iNetwork.getAdapterAttribute("br0", "gateway")))
+
+       def formatAddr(self, address = [0,0,0,0]):
+               if address is None:
+                       return "N/A"
+               return "%d:%d:%d:%d"%(address[0],address[1],address[2],address[3])
+
+       def checkRunHostapd(self):
+               global apModeConfig
+               if fileExists("/var/run/hostapd", 0):
+                       apModeConfig.useap.value = True
+
+       def makeConfigList(self):
+               global apModeConfig
+               self.hostapdConfigList = {}
+               self.hostapdConfigList["interface"] = apModeConfig.wirelessdevice
+               self.hostapdConfigList["bridge"] = apModeConfig.branch # "br0"
+               self.hostapdConfigList["driver"] = apModeConfig.driver # "nl80211"
+               self.hostapdConfigList["hw_mode"] = apModeConfig.wirelessmode
+               self.hostapdConfigList["channel"] = apModeConfig.channel
+               self.hostapdConfigList["ssid"] = apModeConfig.ssid
+               self.hostapdConfigList["beacon_int"] = apModeConfig.beacon
+               self.hostapdConfigList["rts_threshold"] = apModeConfig.rts_threshold
+               self.hostapdConfigList["fragm_threshold"] = apModeConfig.fragm_threshold
+               self.hostapdConfigList["preamble"] = apModeConfig.preamble
+#              self.hostapdConfigList["macaddr_acl"] = "" # fix to add Access Control List Editer
+#              self.hostapdConfigList["accept_mac_file"] = "" # fix to add Access Control List Editer
+#              self.hostapdConfigList["deny_mac_file"] = "" # fix to add Access Control List Editer
+               self.hostapdConfigList["ignore_broadcast_ssid"] = apModeConfig.ignore_broadcast_ssid
+#              self.hostapdConfigList["wmm_enabled"] = ""
+#              self.hostapdConfigList["ieee80211n"] = ""
+#              self.hostapdConfigList["ht_capab"] = ""
+               self.hostapdConfigList["wep_default_key"] = apModeConfig.wep_default_key
+               self.hostapdConfigList["wep_key0"] = apModeConfig.wep_key0
+               self.hostapdConfigList["wpa"] = apModeConfig.wpa
+               self.hostapdConfigList["wpa_passphrase"] = apModeConfig.wpa_passphrase
+               self.hostapdConfigList["wpa_key_mgmt"] = apModeConfig.wpa_key_mgmt # "WPA-PSK"
+               self.hostapdConfigList["wpa_pairwise"] = apModeConfig.wpa_pairwise # "TKIP CCMP"
+               self.hostapdConfigList["rsn_pairwise"] = apModeConfig.rsn_pairwise # "CCMP"
+               self.hostapdConfigList["wpa_group_rekey"] = apModeConfig.wpagrouprekey
+
+       def loadInterfacesConfig(self):
+               global apModeConfig
+               try:
+                       fp = file('/etc/network/interfaces', 'r')
+                       datas = fp.readlines()
+                       fp.close()
+               except:
+                       printDebugMsg("interfaces - file open failed")
+               # check br0 configuration
+               current_iface = ""
+               ifaceConf = {}
+               try:
+                       for line in datas:
+                               split = line.strip().split(' ')
+                               if (split[0] == "iface"):
+                                       current_iface = split[1]
+                                       if (current_iface == "br0") and (len(split) == 4 and split[3] == "dhcp"):
+                                               apModeConfig.usedhcp.value = True
+                                       else:
+                                               apModeConfig.usedhcp.value = False
+                               if (current_iface == "br0" or current_iface == "eth0"):
+                                       if (split[0] == "address"):
+                                               apModeConfig.address.value = map(int, split[1].split('.'))
+                                       if (split[0] == "netmask"):
+                                               apModeConfig.netmask.value = map(int, split[1].split('.'))
+                                       if (split[0] == "gateway"):
+                                               apModeConfig.gateway.value = map(int, split[1].split('.'))
+               except:
+                       printDebugMsg("configuration parsing error! - /etc/network/interfaces")
+
+       def loadHostapConfig(self):
+               hostapdConf = { }
+               ret = self.wirelessAP.loadHostapConfig(hostapdConf)
+               if ret != 0:
+                       printDebugMsg("configuration opening failed!!")
+                       return
+               for (key,value) in hostapdConf.items():
+                       if key == "config.wep":
+                               apModeConfig.wep.value = int(value)
+                       elif key in ["channel", "beacon_int", "rts_threshold", "fragm_threshold", "wpa_group_rekey"]:
+                               self.hostapdConfigList[key].value = int(value)
+                       elif key in self.hostapdConfigList.keys():
+                               self.hostapdConfigList[key].value = value
+                       if key == "channel" and value not in range(14):
+                               self.hostapdConfigList[key].value = 1
+
+#              for key in self.hostapdConfigList.keys():
+#                      printDebugMsg("[cofigList] key : %s, value : %s"%(key, str(self.hostapdConfigList[key].value)) )
+
+       def setupCurrentEncryption(self):
+               if apModeConfig.wpa.value is not "0" and apModeConfig.wpa_passphrase.value: # (1,WPA), (2,WPA2), (3,WPA/WPA2)
+                       apModeConfig.encrypt.value = True
+                       apModeConfig.method.value = apModeConfig.wpa.value
+               elif apModeConfig.wep.value and apModeConfig.wep_key0.value:
+                       apModeConfig.encrypt.value = True
+                       apModeConfig.method.value = "0"
+                       if len(apModeConfig.wep_key0.value) > 10:
+                               apModeConfig.wepType.value = "128"
+               else:
+                       apModeConfig.encrypt.value = False
+
+       def createConfigEntry(self):
+               global apModeConfig
+#hostap settings
+               self.useApEntry = getConfigListEntry(_("Use AP Mode"), apModeConfig.useap)
+               self.setupModeEntry = getConfigListEntry(_("Setup Mode"), apModeConfig.setupmode)
+               self.wirelessDeviceEntry = getConfigListEntry(_("AP Device"), apModeConfig.wirelessdevice)
+               self.wirelessModeEntry = getConfigListEntry(_("AP Mode"), apModeConfig.wirelessmode)
+               self.channelEntry = getConfigListEntry(_("Channel (1~13)"), apModeConfig.channel)
+               self.ssidEntry = getConfigListEntry(_("SSID (0~32 Characters)"), apModeConfig.ssid)
+               self.beaconEntry = getConfigListEntry(_("Beacon (15~65535)"), apModeConfig.beacon)
+               self.rtsThresholdEntry = getConfigListEntry(_("RTS Threshold (0~2347)"), apModeConfig.rts_threshold)
+               self.fragmThresholdEntry = getConfigListEntry(_("FRAGM Threshold (256~2346)"), apModeConfig.fragm_threshold)
+               self.prambleEntry = getConfigListEntry(_("Preamble"), apModeConfig.preamble)
+               self.ignoreBroadcastSsid = getConfigListEntry(_("Ignore Broadcast SSID"), apModeConfig.ignore_broadcast_ssid)
+# hostap encryption
+               self.encryptEntry = getConfigListEntry(_("Encrypt"), apModeConfig.encrypt)
+               self.methodEntry = getConfigListEntry(_("Method"), apModeConfig.method)
+               self.wepKeyTypeEntry = getConfigListEntry(_("KeyType"), apModeConfig.wepType)
+               self.wepKey0Entry = getConfigListEntry(_("WEP Key (HEX)"), apModeConfig.wep_key0)
+               self.wpaKeyEntry = getConfigListEntry(_("KEY (8~63 Characters)"), apModeConfig.wpa_passphrase)
+               self.groupRekeyEntry = getConfigListEntry(_("Group Rekey Interval"), apModeConfig.wpagrouprekey)
+# interface settings
+               self.usedhcpEntry = getConfigListEntry(_("Use DHCP"), apModeConfig.usedhcp)
+               self.ipEntry = getConfigListEntry(_("IP Address"), apModeConfig.address)
+               self.netmaskEntry = getConfigListEntry(_("NetMask"), apModeConfig.netmask)
+               self.gatewayEntry = getConfigListEntry(_("Gateway"), apModeConfig.gateway)
+
+       def createConfig(self):
+               global apModeConfig
+               self.configList = []
+               self.configList.append( self.useApEntry )
+               if apModeConfig.useap.value is True:
+                       self.configList.append( self.setupModeEntry )
+                       self.configList.append( self.wirelessDeviceEntry )
+                       self.configList.append( self.wirelessModeEntry )
+                       self.configList.append( self.channelEntry )
+                       self.configList.append( self.ssidEntry )
+                       if apModeConfig.setupmode.value  is "advanced":
+                               self.configList.append( self.beaconEntry )
+                               self.configList.append( self.rtsThresholdEntry )
+                               self.configList.append( self.fragmThresholdEntry )
+                               self.configList.append( self.prambleEntry )
+                               self.configList.append( self.ignoreBroadcastSsid )
+                       self.configList.append( self.encryptEntry )
+                       if apModeConfig.encrypt.value is True:
+                               self.configList.append( self.methodEntry )
+                               if apModeConfig.method.value is "0": # wep
+                                       self.configList.append( self.wepKeyTypeEntry )
+                                       self.configList.append( self.wepKey0Entry )
+                               else:
+                                       self.configList.append( self.wpaKeyEntry )
+                                       if apModeConfig.setupmode.value  is "advanced":
+                                               self.configList.append( self.groupRekeyEntry )
+##             set network interfaces
+                       self.configList.append( self.usedhcpEntry )
+                       if apModeConfig.usedhcp.value is False:
+                               self.configList.append( self.ipEntry )
+                               self.configList.append( self.netmaskEntry )
+                               self.configList.append( self.gatewayEntry )
+               self["config"].list = self.configList
+               self["config"].l.setList(self.configList)
+
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.newConfig()
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.newConfig()
+
+       def newConfig(self):
+               if self["config"].getCurrent() in [ self.encryptEntry, self.methodEntry, self.useApEntry, self.usedhcpEntry, self.setupModeEntry]:
+                       self.createConfig()
+
+       def doConfigMsg(self):
+               try:
+                       self.session.openWithCallback(self.doConfig, MessageBox, (_("Are you sure you want to setup your AP?\n\n") ) )
+               except:
+                       printDebugMsg("doConfig failed")
+
+       def doConfig(self, ret = False):
+               global apModeConfig
+               if ret is not True:
+                       return
+               if apModeConfig.useap.value is True and apModeConfig.encrypt.value is True:
+                       if not self.checkEncrypKey():
+                               return
+               if not self.checkConfig():
+                       return
+               self.configStartMsg = self.session.openWithCallback(self.ConfigFinishedMsg, MessageBox, _("Please wait for AP Configuration....\n") , type = MessageBox.TYPE_INFO, enable_input = False)
+               if apModeConfig.useap.value is True:
+                       self.networkRestart( nextFunc = self.makeConf )
+               else:
+                       self.networkRestart( nextFunc = self.removeConf )
+
+       def checkEncrypKey(self):
+               if apModeConfig.method.value == "0":
+                       if self.checkWep(apModeConfig.wep_key0.value) is False:
+                               self.session.open(MessageBox, _("Invalid WEP key\n\n"), type = MessageBox.TYPE_ERROR, timeout = 10 )
+                       else:
+                               return True
+               else:
+                       if not len(apModeConfig.wpa_passphrase.value) in range(8,65):
+                               self.session.open(MessageBox, _("Invalid WPA key\n\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
+                       else:
+                               return True
+               return False
+
+       def checkWep(self,  key):
+               length = len(key)
+               if length == 0:
+                       return False
+               elif apModeConfig.wepType.value == "64" and length == 10:
+                       return True
+               elif apModeConfig.wepType.value == "128" and length == 26:
+                       return True
+               else:
+                       return False
+
+       def checkConfig(self):
+               # ssid Check
+               if len(apModeConfig.ssid.value) == 0 or len(apModeConfig.ssid.value) > 32:
+                       self.session.open(MessageBox, _("Invalid SSID\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
+                       return False;
+               elif apModeConfig.channel.value not in range(1,14):
+                       self.session.open(MessageBox, _("Invalid channel\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
+                       return False;
+               elif apModeConfig.beacon.value < 15 or apModeConfig.beacon.value > 65535:
+                       self.session.open(MessageBox, _("Invalid beacon\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
+                       return False;
+               elif apModeConfig.rts_threshold.value < 0 or apModeConfig.rts_threshold.value > 2347:
+                       self.session.open(MessageBox, _("Invalid RTS Threshold\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
+                       return False;
+               elif apModeConfig.fragm_threshold.value < 256 or apModeConfig.fragm_threshold.value > 2346:
+                       self.session.open(MessageBox, _("Invalid Fragm Threshold\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
+                       return False;
+               elif apModeConfig.wpagrouprekey.value < 0 or apModeConfig.wpagrouprekey.value > 3600:
+                       self.session.open(MessageBox, _("Invalid wpagrouprekey\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
+                       return False;
+               return True;
+
+       def networkRestart(self, nextFunc = None ):
+               self.networkRestart_stop( nextFunc = nextFunc )
+
+       def networkRestart_stop(self, nextFunc = None ):
+               printDebugMsg("networkRestart_stop")
+               self.msgPlugins(False)
+               self.commands = [] # stop current network
+               self.networkRestartConsole = Console()
+               self.commands.append("/etc/init.d/avahi-daemon stop")
+               for iface in iNetwork.getAdapterList():
+                       if iface != 'eth0' or not iNetwork.onRemoteRootFS():
+                               self.commands.append("ifdown " + iface)
+                               self.commands.append("ip addr flush dev " + iface)
+               self.commands.append("/etc/init.d/hostapd stop")
+               self.commands.append("/etc/init.d/networking stop")
+               self.commands.append("killall -9 udhcpc")
+               self.commands.append("rm /var/run/udhcpc*")
+               self.networkRestartConsole.eBatch(self.commands, nextFunc, debug = True)
+
+       def makeConf(self,extra_args):
+               printDebugMsg("makeConf")
+               self.writeNetworkInterfaces()
+               result = self.writeHostapdConfig()
+               if result == -1:
+                       self.configStartMsg.close(False)
+                       return
+               self.setIpForward(1)
+               self.networkRestart_start()
+
+       def removeConf(self,extra_args):
+               printDebugMsg("removeConf")
+               if fileExists("/etc/hostapd.conf", 0):
+                       os_system("mv /etc/hostapd.conf /etc/hostapd.conf.linuxap.back")
+               fp = file("/etc/network/interfaces", 'w')
+               fp.write("# automatically generated by AP Setup Plugin\n# do NOT change manually!\n\n")
+               fp.write("auto lo\n")
+               fp.write("iface lo inet loopback\n\n")
+               # eth0 setup
+               fp.write("auto eth0\n")
+               if apModeConfig.usedhcp.value is True:
+                       fp.write("iface eth0 inet dhcp\n")
+               else:
+                       fp.write("iface eth0 inet static\n")
+                       fp.write("      address %d.%d.%d.%d\n" % tuple(apModeConfig.address.value) )
+                       fp.write("      netmask %d.%d.%d.%d\n" % tuple(apModeConfig.netmask.value) )
+                       fp.write("      gateway %d.%d.%d.%d\n" % tuple(apModeConfig.gateway.value) )
+               fp.close()
+               self.setIpForward(0)
+               self.networkRestart_start()
+
+       def networkRestart_start(self):
+               printDebugMsg("networkRestart_start")
+               self.restartConsole = Console()
+               self.commands = []
+               self.commands.append("/etc/init.d/networking start")
+               self.commands.append("/etc/init.d/avahi-daemon start")
+               self.commands.append("/etc/init.d/hostapd start")
+               self.restartConsole.eBatch(self.commands, self.networkRestartFinished, debug=True)
+
+       def networkRestartFinished(self, data):
+               printDebugMsg("networkRestartFinished")
+               iNetwork.removeAdapterAttribute('br0',"ip")
+               iNetwork.removeAdapterAttribute('br0',"netmask")
+               iNetwork.removeAdapterAttribute('br0',"gateway")
+               iNetwork.getInterfaces(self.getInterfacesDataAvail)
+
+       def getInterfacesDataAvail(self, data):
+               if data is True and self.configStartMsg is not None:
+                       self.configStartMsg.close(True)
+
+       def ConfigFinishedMsg(self, ret):
+               if ret is True:
+                       self.session.openWithCallback(self.ConfigFinishedMsgCallback ,MessageBox, _("Configuration your AP is finished"), type = MessageBox.TYPE_INFO, timeout = 5, default = False)
+               else:
+                       self.session.openWithCallback(self.close ,MessageBox, _("Invalid model or Image."), MessageBox.TYPE_ERROR)
+
+       def ConfigFinishedMsgCallback(self,data):
+               self.close()
+
+       def msgPlugins(self,reason = False):
+               for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKCONFIG_READ):
+                               p(reason=reason)
+
+       def writeNetworkInterfaces(self):
+               global apModeConfig
+               fp = file("/etc/network/interfaces", 'w')
+               fp.write("# automatically generated by AP Setup Plugin\n# do NOT change manually!\n\n")
+               fp.write("auto lo\n")
+               fp.write("iface lo inet loopback\n\n")
+               # eth0 setup
+               fp.write("auto eth0\n")
+               fp.write("iface eth0 inet manual\n")
+               fp.write("      up ip link set $IFACE up\n")
+               fp.write("      down ip link set $IFACE down\n\n")
+               # Wireless device setup
+               fp.write("auto %s\n" % apModeConfig.wirelessdevice.value)
+               fp.write("iface %s inet manual\n" % apModeConfig.wirelessdevice.value)
+               fp.write("      up ip link set $IFACE up\n")
+               fp.write("      down ip link set $IFACE down\n")
+               # branch setup
+               fp.write("auto br0\n")
+               if apModeConfig.usedhcp.value is True:
+                       fp.write("iface br0 inet dhcp\n")
+               else:
+                       fp.write("iface br0 inet static\n")
+                       fp.write("      address %d.%d.%d.%d\n" % tuple(apModeConfig.address.value) )
+                       fp.write("      netmask %d.%d.%d.%d\n" % tuple(apModeConfig.netmask.value) )
+                       fp.write("      gateway %d.%d.%d.%d\n" % tuple(apModeConfig.gateway.value) )
+               fp.write("      pre-up brctl addbr br0\n")
+               fp.write("      pre-up brctl addif br0 eth0\n")
+#              fp.write("      pre-up brctl addif br0 wlan0\n") // runned by hostpad
+               fp.write("      post-down brctl delif br0 eth0\n")
+#              fp.write("      post-down brctl delif br0 wlan0\n") // runned by hostpad
+               fp.write("      post-down brctl delbr br0\n\n")
+               fp.write("\n")
+               fp.close()
+
+       def writeHostapdConfig(self): #c++
+               global apModeConfig
+               configDict = {}
+               for key in self.hostapdConfigList.keys():
+                       configDict[key] = str(self.hostapdConfigList[key].value)
+               configDict["config.encrypt"] = str(int(apModeConfig.encrypt.value))
+               configDict["config.method"] = apModeConfig.method.value
+               ret = self.wirelessAP.writeHostapdConfig(configDict)
+               if(ret != 0):
+                       return -1
+               return 0
+
+       def setIpForward(self, setValue = 0):
+               ipForwardFilePath = "/proc/sys/net/ipv4/ip_forward"
+               if not fileExists(ipForwardFilePath):
+                       return -1
+               printDebugMsg("set %s to %d" % (ipForwardFilePath, setValue))
+               f = open(ipForwardFilePath, "w")
+               f.write("%d" % setValue)
+               f.close()
+               sysctlPath = "/etc/sysctl.conf"
+               sysctlLines = []
+               if fileExists(sysctlPath):
+                       fp = file(sysctlPath, "r")
+                       sysctlLines = fp.readlines()
+                       fp.close()
+               sysctlList = {}
+               for line in sysctlLines:
+                       line = line.strip()
+                       (key,value) = line.split("=")
+                       key=key.strip()
+                       value=value.strip()
+                       sysctlList[key] = value
+               sysctlList["net.ipv4.ip_forward"] = str(setValue)
+               fp = file(sysctlPath, "w")
+               for (key,value) in sysctlList.items():
+                       fp.write("%s=%s\n"%(key,value))
+               fp.close()
+               return 0
+
+       def checkWirelessDevices(self):
+               global apModeConfig
+               self.wlanDeviceList = []
+               wlanIfaces =[]
+               for x in iNetwork.getInstalledAdapters():
+                       if x.startswith('eth') or x.startswith('br') or x.startswith('mon'):
+                               continue
+                       wlanIfaces.append(x)
+                       description=self.getAdapterDescription(x)
+                       if description == "Unknown network adapter":
+                               self.wlanDeviceList.append((x, x))
+                       else:
+                               self.wlanDeviceList.append(( x, description + " (%s)"%x ))
+               apModeConfig.wirelessdevice = ConfigSelection( choices = self.wlanDeviceList )
+
+       def getAdapterDescription(self, iface):
+               classdir = "/sys/class/net/" + iface + "/device/"
+               driverdir = "/sys/class/net/" + iface + "/device/driver/"
+               if os_path.exists(classdir):
+                       files = listdir(classdir)
+                       if 'driver' in files:
+                               if os_path.realpath(driverdir).endswith('rtw_usb_drv'):
+                                       return _("Realtek")+ " " + _("WLAN adapter.")
+                               elif os_path.realpath(driverdir).endswith('ath_pci'):
+                                       return _("Atheros")+ " " + _("WLAN adapter.")
+                               elif os_path.realpath(driverdir).endswith('zd1211b'):
+                                       return _("Zydas")+ " " + _("WLAN adapter.")
+                               elif os_path.realpath(driverdir).endswith('rt73'):
+                                       return _("Ralink")+ " " + _("WLAN adapter.")
+                               elif os_path.realpath(driverdir).endswith('rt73usb'):
+                                       return _("Ralink")+ " " + _("WLAN adapter.")
+                               else:
+                                       return str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter")
+                       else:
+                               return _("Unknown network adapter")
+               else:
+                       return _("Unknown network adapter")
+
+       def __onClose(self):
+               for x in self["config"].list:
+                       x[1].cancel()
+               apModeConfig.wpa.value = "0"
+               apModeConfig.wep.value = False
+
+       def keyCancel(self):
+               self.close()
+
+def main(session, **kwargs):
+       session.open(WirelessAccessPoint)
+
+def Plugins(**kwargs):
+       return [PluginDescriptor(name=_("Wireless Access Point"), description="Using a Wireless module as access point.", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)]
+
diff --git a/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/wirelessap.py b/lib/python/Plugins/SystemPlugins/WirelessAccessPoint/wirelessap.py
new file mode 100644 (file)
index 0000000..56e85cb
--- /dev/null
@@ -0,0 +1,87 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 1.3.39
+#
+# Do not make changes to this file unless you know what you are doing--modify
+# the SWIG interface file instead.
+# This file is compatible with both classic and new-style classes.
+
+from sys import version_info
+if version_info >= (2,6,0):
+    def swig_import_helper():
+        from os.path import dirname
+        import imp
+        fp = None
+        try:
+            fp, pathname, description = imp.find_module('_wirelessap', [dirname(__file__)])
+        except ImportError:
+            import _wirelessap
+            return _wirelessap
+        if fp is not None:
+            try:
+                _mod = imp.load_module('_wirelessap', fp, pathname, description)
+            finally:
+                fp.close()
+                return _mod
+    _wirelessap = swig_import_helper()
+    del swig_import_helper
+else:
+    import _wirelessap
+del version_info
+try:
+    _swig_property = property
+except NameError:
+    pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+    if (name == "thisown"): return self.this.own(value)
+    if (name == "this"):
+        if type(value).__name__ == 'SwigPyObject':
+            self.__dict__[name] = value
+            return
+    method = class_type.__swig_setmethods__.get(name,None)
+    if method: return method(self,value)
+    if (not static) or hasattr(self,name):
+        self.__dict__[name] = value
+    else:
+        raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+    return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+    if (name == "thisown"): return self.this.own()
+    method = class_type.__swig_getmethods__.get(name,None)
+    if method: return method(self)
+    raise AttributeError(name)
+
+def _swig_repr(self):
+    try: strthis = "proxy of " + self.this.__repr__()
+    except: strthis = ""
+    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+try:
+    _object = object
+    _newclass = 1
+except AttributeError:
+    class _object : pass
+    _newclass = 0
+
+
+class wirelessAP(_object):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, wirelessAP, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, wirelessAP, name)
+    __repr__ = _swig_repr
+    def __init__(self): 
+        this = _wirelessap.new_wirelessAP()
+        try: self.this.append(this)
+        except: self.this = this
+    __swig_destroy__ = _wirelessap.delete_wirelessAP
+    __del__ = lambda self : None;
+    def loadHostapConfig(self, *args): return _wirelessap.wirelessAP_loadHostapConfig(self, *args)
+    def writeHostapdConfig(self, *args): return _wirelessap.wirelessAP_writeHostapdConfig(self, *args)
+wirelessAP_swigregister = _wirelessap.wirelessAP_swigregister
+wirelessAP_swigregister(wirelessAP)
+
+
+