<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

SqueezeOS networking

From SqueezeboxWiki

Jump to: navigation, search

Contents

SqueezeOS Networking Configuration

Interface Chipset and Names

Device Chipset Wired Wireless
SB Controller Marvell - eth0
SB Radio Atheros eth0 eth1
SB Touch Marvell eth0 wlan0

Tools and scripts (overview)

  • ifup / ifdown
  • udhcpc (DHCP client)
  • wpa_supplicant / wpa_cli (tools to configure wireless interface)
  • /etc/network/if_mapping
  • /etc/network/wpa_action
  • /etc/network/udhcpc_action
  • wpsapp (WPS application supplied by Marvell (only works with Marvell driver / hardware))

Configuration files (overview)

  • /etc/network/interfaces (wired and wireless interfaces configuration)
  • /etc/resolv.conf (DNS configuration)
  • /etc/wpa_supplicant.conf (wireless configuration file)
  • /etc/network/config (wireless region configuration, only needed with Marvell)

Tools and scripts for wired and wireless

ifup / ifdown

Note: Sample interface names for SB Touch

Wired or wireless interfaces are started / stopped via ifup / ifdown.

ifup eth0		# starts wired interface
ifdown eth0		# stops wired interface
ifup wlan0=<SSID>	# starts wireless interface
                       # (wlan driver must be loaded and wpa_supplicant running)
ifdown wlan0=<SSID>	# stops wireless interface

udhcpc

Note: Sample interface names for SB Touch

DHCP client needed once for each interface - automatically started and stopped by ifup / ifdown.

Called from busybox like this:

udhcpc -R -a -p /var/run/udhcpc.eth0.pid -b --syslog -i eth0
       -H SqueezeboxTouch -s /etc/network/udhcpc_action

Configuration files for wired and wireless

Configuration files needed for both, wired and wireless interfaces

/etc/network/interfaces

Note: Sample interface names for SB Touch

  • Contains info for each interface (i.e. DHCP or static IP)
  • Written by: squeezeplay_jive/share/jive/net/Networking.lua
  • Read by: /sbin/ifup - /sbin/ifdown
  • All Interfaces marked auto are started when a ifup -a is issued, which happens at boot time

Sample file (DHCP, auto-starting wired interface)

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
	script /etc/network/udhcpc_action

#auto wlan0=<SSID>
mapping wlan0
	script /etc/network/if_mapping
iface <SSID> inet dhcp
	script /etc/network/udhcpc_action

Sample file (static IP, auto-starting wired interface)

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	address 192.168.144.76
	netmask 255.255.255.0
	gateway 192.168.144.1

#auto wlan0=<SSID>
mapping wlan0
	script /etc/network/if_mapping
iface <SSID> inet static
	address 192.168.144.76
	netmask 255.255.255.0
	gateway 192.168.144.1

/etc/resolv.conf

  • Contains DNS information
  • Written by: /etc/network/udhcpc_action (dhcp) / Networking.lua (static)
  • Read by: squeezeplay/src/net/jive_dns.c
nameserver 192.168.144.1
nameserver 62.5.24.163

Tools and scripts for wireless only

The /etc/init.d/rcS script is executed at boot time and starts the wlan script which starts the wlan driver and wpa_supplicant.

wpa_supplicant

Note: Sample interface names for SB Touch

wpa_supplicant is running in the background and controlled via wpa_cli from Networking.lua

/usr/sbin/wpa_supplicant -B -Dmarvell -iwlan0 -c/etc/wpa_supplicant.conf

wpa_cli commands

  • SCAN: scan for wireless APs
  • STATUS: get info about AP currently associated to
  • SCAN_RESULTS: get a list of APs found
  • ADD_NETWORK: add a new network to the list
  • SET_NETWORK: set ssid and other parameters for that network
  • SELECT_NETWORK: disables all not used networks and only enables one
  • LIST_NETWORKS: show list of all configured networks
  • REMOVE_NETWORK: remove a network from the list
  • REASSOCIATE: force association to the one enabled network
  • DISCONNECT: disconnect from network (and wait for reassociate cmd)
  • SAVE_CONFIG: write config to wpa_supplicant.conf file

Use wpa_cli to find WPS capable APs

wpa_supplicant / wpa_cli can also be used to scan for WPS capable APs. Scan results include the WPS status. (7.4 r3873)

Sample output:

# wpa_cli scan_results
Selected interface 'wlan0'
bssid / frequency / signal level / flags / ssid
00:1b:2f:xx:xx:xx       2412    222     [WPA2-PSK-CCMP-preauth] No Support
00:18:4d:xx:xx:xx       2462    210     [WPA2-PSK-CCMP-preauth] No Device
00:21:29:xx:xx:xx       2437    211     [WPA2-PSK-CCMP][WPS]    No Internet

/etc/network/if_mapping

Note: Sample interface names for SB Touch

Replaces tabs and spaces in SSIDs with underscores (_)

#!/bin/sh

# replace all " \t" in the ssid.
# FIXME ssid's with \n are not supported.
SSID=`/usr/sbin/wpa_cli -iwlan0 status | grep ^ssid= | cut -f2- -d= | tr ' \t' _`
echo $SSID

/etc/network/wpa_action

When the wireless connects / disconnects this script is run. We use it to kick DHCP client to do a renewal.

#!/bin/sh

IFNAME=$1
CMD=$2

/usr/bin/logger "wpa_action $IFNAME $CMD"

if [ "$CMD" = "CONNECTED" ]; then
        # Kick DHCP client to do a renewal
        kill -usr1 `cat /var/run/udhcpc.$IFNAME.pid`
fi

if [ "$CMD" = "DISCONNECTED" ]; then
        # TODO any actions still needed?
fi

(used by wpa_cli when run as daemon)

wpsapp (Marvell chipset only)

Note: Sample interface names for SB Touch

wpsapp (by Marvell) can be used to find WPS capable APs and to get the wireless configuration via WPS (either by pressing a button on the client and the AP or by providing a 8 digit pin.) Upon successful retrieving of wireless configuration data from the AP wpsapp writes a wps.conf file which contains a network section that can be used by wpa_supplicant.

wpsapp needs to be started from within the /usr/sbin/wps/ directory to work, i.e.

cd /usr/sbin/wps/
./wpsapp

Standard mode as provided by Marvell

wpsapp wlan0           # Interactive mode

Additional modes added by Logitech

wpsapp wlan0 scanall   # List all APs found (WPS and non WPS)
wpsapp wlan0 scanwps   # List only WPS capable APs
wpsapp wlan0 scanpbc   # List only APs which have its push button pressed (waiting for client)
wpsapp wlan0 scanpin   # List only APs which have a pin entered (waiting for client)
wpsapp wlan0 pbc       # Starts the push button configuration process
wpsapp wlan0 getpin    # Generates the client pin to be entered on the AP
wpsapp wlan0 pin <pin> # Starts the pin configuration process

Successful push button config log:

# ./wpsapp wlan0 pbc
Driver build with Wireless Extension 22
WPS Application build with Wireless Extension 22
Role : WPS_ENROLLEE

Start Active Scan ...

Scan Result : 0 entry in Scan List

Scan Result : 1 entry in Scan List
-----------------------------------------------------------------------
  # |  Mode | Chan# | WPA | WPS |       BSSID       |     SSID
-----------------------------------------------------------------------
 00 | Infra |  006  |  N  |  Y* | 00:21:29:xx:xx:xx | No Internet

Connecting .....

Connected to following BSS (or IBSS) :
SSID = [No Internet], BSSID = [00:21:29:c7:7a:6a]

WPS Registration Protocol Starting .....
Press [q/Q] to abort this program.

WPS Registration Protocol Completed Successfully !

#

Configuration files for wireless only

Configuration files only needed for wireless (wlan0) interface

/etc/wpa_supplicant.conf

  • Contains wireless configurations for different APs
  • Written, Read by: squeezeplay_jive/share/jive/net/Networking.lua (via requests to wpa_cli)
  • Read by: /usr/sbin/wpa_supplicant
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
	ssid="<SSID>"
	proto=RSN
	key_mgmt=WPA-PSK
	psk="98765432"
#	disabled=1
}

/etc/network/config

Note: Only needed for Marvell chipset. Atheros uses a world setting suitable everywhere.

  • Contains wireless region
  • Written, Read by: squeezeplay_jive/share/jive/net/Networking.lua
  • Read by: /etc/init.d/wlan (start / stop wlan script)
REGION=US
REGIONCODE=16

Autostart current connection after power-up / reset

The wired interface is auto-started using DHCP after a factory reset / reboot. This connects Touch to the network if and ethernet cable is plugged in. Setup could check for that and skip the wired / wireless selection screen (or tell the user that it found a connection and offer to use it or allow to manually switch to wireless).

Autostart wired

Note: Sample interface names for SB Touch

  • Add auto eth0 in /etc/network/interfaces ('ifup -a' in '/etc/init.d/rcS' will start it)
  • Remove auto wlan0=<SSID> in /etc/network/interfaces
  • Add disabled=1 to each wireless setting in /etc/wpa_supplicant.conf

Autostart wireless

Note: Sample interface names for SB Touch

  • Remove auto eth0 in /etc/network/interfaces
  • Add auto wlan0=<SSID> in /etc/network/interfaces ('ifup -a' in '/etc/init.d/rcS' will start it)
  • Only remove disabled=1 from the one wireless setting to start in /etc/wpa_supplicant.conf

Network Setup

Setup sequence during setup or via Settings - Advanced - Networking - Choose Network.

Ethernet

  • Stop wireless interface (and DHCP) via ifdown wlan0
  • Rewrite interfaces file with ethernet as auto interface
  • Start ethernet interface (and DHCP) via ifup eth0

Wireless

  • User selects wireless region (Marvell only)
  • Save wireless region
  • Scan for wireless networks and present list to user
  • User selects SSID
  • User enters password
  • Stop ethernet interface (and DHCP) via ifdown eth0
  • Write interfaces file with wireless as auto interface
  • Add new wireless network using wpa_cli (this writes into wpa_supplicant.conf)
  • Set additional parameter like password etc using wpa_cli (this writes into wpa_supplicant.conf)
  • Save Config
  • Select new wireless network using wpa_cli (this writes into wpa_supplicant.conf)
  • Reassociate to new wireless network using wpa_cli (this writes into wpa_supplicant.conf)
  • Start wireless interface (and DHCP) via ifup wlan0