network: added support for configuration of CDC-Ethernet and Android RNDIS network interfaces

This commit is contained in:
Silvan Calarco 2013-07-31 13:28:01 +02:00
parent b011e2aa40
commit 8740e2a830
2 changed files with 54 additions and 2 deletions

View File

@ -57,8 +57,51 @@ _EOF
}
# FIXME
DEST_GATEWAY_ZONE=local
function cdc_usb() {
local CDC_IPADDR=10.99.99.1
ifconfig usb0 &>/dev/null && {
[ -e $network_devices/ifcng-usb0 ] || {
[ "$NETWORK_CDC_IPADDR" ] && CDC_IPADDR=$NETWORK_CDC_IPADDR
cat > $network_devices/ifcfg-usb0 << _EOF
DEVICE=usb0
BOOTPROTO=none
IPADDR=$CDC_IPADDR
ONBOOT=yes
NM_CONTROLLED=no
_EOF
}
}
}
function android_usb() {
local ANDROID_IPADDR=10.99.99.1
local ANDROID_ETHADDR=80:00:60:0F:E8:00
# FIXME: hardcoded values
if [ -e /sys/class/android_usb/android0 ]; then
[ "$NETWORK_ANDROID_ETHADDR" ] && ANDROID_ETHADDR=$NETWORK_ANDROID_ETHADDR
echo 0 > /sys/class/android_usb/android0/enable
echo rndis,acm > /sys/class/android_usb/android0/functions
echo 2 > /sys/class/android_usb/android0/f_acm/instances
echo $ANDROID_ETHADDR > /sys/class/android_usb/android0/f_rndis/ethaddr
echo 2d01 > /sys/class/android_usb/android0/idProduct
echo 1 > /sys/class/android_usb/android0/enable
fi
[ -e $network_devices/ifcfg-rndis0 ] || {
[ "$NETWORK_ANDROID_IPADDR" ] && ANDROID_IPADDR=$NETWORK_ANDROID_IPADDR
cat > $network_devices/ifcfg-rndis0 << _EOF
DEVICE=rndis0
BOOTPROTO=none
IPADDR=$ANDROID_IPADDR
ONBOOT=yes
NM_CONTROLLED=no
_EOF
}
}
[ "$NETWORK_CDC_DISABLE" = "1" ] || cdc_usb
[ "$NETWORK_ANDROID_DISABLE" = "1" ] || android_usb
wlan_ints=()
for wlan_int in $(cat /proc/net/wireless 2>/dev/null | sed -n '/[a-z]*[0-9]*:/{s,:.*,,;p}'); do

View File

@ -30,6 +30,15 @@ FS_NO_DEV_REMOVE=yes
# (dialog/auto/off, default: off)
NETWORK_NEWDEVICE=off
# network parameters for CDC ethernet interface
#NETWORK_CDC_DISABLE=1
#NETWORK_CDC_IPADDR=10.99.99.1
# network parameters for Android rndis ethernet interface
#NETWORK_ANDROID_DISABLE=1
#NETWORK_ANDROID_IPADDR=10.99.99.1
#NETWOKR_ANDROID_ETHADDR=01:02:03:04:05:06
# xorg server: automatically add DRI section
# (on/off, default: on)
XORG_ENABLE_DRI=on