network: configure and start a dedicated dhcpd server bound to configured CDC and RNDIS interfaces
This commit is contained in:
parent
8740e2a830
commit
dccee1c9dd
@ -59,45 +59,86 @@ _EOF
|
|||||||
|
|
||||||
function cdc_usb() {
|
function cdc_usb() {
|
||||||
local CDC_IPADDR=10.99.99.1
|
local CDC_IPADDR=10.99.99.1
|
||||||
|
local CDC_SUBNET=10.99.99.0
|
||||||
|
local CDC_RANGE_FROM=10.99.99.100
|
||||||
|
local CDC_RANGE_TO=10.99.99.199
|
||||||
|
local CDC_NETMASK=255.255.255.0
|
||||||
|
|
||||||
ifconfig usb0 &>/dev/null && {
|
ifconfig usb0 &>/dev/null && {
|
||||||
|
[ "$NETWORK_CDC_NETMASK" ] && CDC_NETMASK=$NETWORK_CDC_NETMASK
|
||||||
[ -e $network_devices/ifcng-usb0 ] || {
|
[ -e $network_devices/ifcng-usb0 ] || {
|
||||||
[ "$NETWORK_CDC_IPADDR" ] && CDC_IPADDR=$NETWORK_CDC_IPADDR
|
[ "$NETWORK_CDC_IPADDR" ] && CDC_IPADDR=$NETWORK_CDC_IPADDR
|
||||||
cat > $network_devices/ifcfg-usb0 << _EOF
|
cat > $network_devices/ifcfg-usb0 << _EOF
|
||||||
DEVICE=usb0
|
DEVICE=usb0
|
||||||
BOOTPROTO=none
|
BOOTPROTO=none
|
||||||
IPADDR=$CDC_IPADDR
|
IPADDR=$CDC_IPADDR
|
||||||
|
NETMASK=$CDC_NETMASK
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
NM_CONTROLLED=no
|
NM_CONTROLLED=no
|
||||||
_EOF
|
_EOF
|
||||||
}
|
}
|
||||||
|
[ -e /etc/dhcpd-usb0.conf ] || {
|
||||||
|
[ "$NETWORK_CDC_SUBNET" ] && CDC_SUBNET=$NETWORK_CDC_SUBNET
|
||||||
|
[ "$NETWORK_CDC_RANGE_FROM" ] && CDC_RANGE_FROM=$NETWORK_CDC_RANGE_FROM
|
||||||
|
[ "$NETWORK_CDC_RANGE_TO" ] && CDC_RANGE_TO=$NETWORK_CDC_RANGE_TO
|
||||||
|
cat > /etc/dhcpd-usb0.conf << _EOF
|
||||||
|
# Created by postplug
|
||||||
|
subnet $NETWORK_CDC_SUBNET netmask $NETWORK_CDC_NETMASK {
|
||||||
|
range dynamic-bootp $NETWORK_CDC_RANGE_FROM $NETWORK_CDC_RANGE_TO;
|
||||||
|
}
|
||||||
|
_EOF
|
||||||
|
}
|
||||||
|
ifup usb0
|
||||||
|
touch /var/lib/dhcp/dhcpd-usb0.leases
|
||||||
|
/sbin/dhcpd -q usb0 -pf /run/dhcpd-usb0.pid -cf /etc/dhcpd-usb0.conf -lf /var/lib/dhcp/dhcpd-usb0.leases
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function android_usb() {
|
function android_usb() {
|
||||||
local ANDROID_IPADDR=10.99.99.1
|
local ANDROID_IPADDR=10.99.99.1
|
||||||
local ANDROID_ETHADDR=80:00:60:0F:E8:00
|
local ANDROID_ETHADDR=80:00:60:0F:E8:00
|
||||||
|
local ANDROID_SUBNET=10.99.99.0
|
||||||
|
local ANDROID_RANGE_FROM=10.99.99.100
|
||||||
|
local ANDROID_RANGE_TO=10.99.99.199
|
||||||
|
local ANDROID_NETMASK=255.255.255.0
|
||||||
|
|
||||||
# FIXME: hardcoded values
|
# FIXME: hardcoded values
|
||||||
if [ -e /sys/class/android_usb/android0 ]; then
|
if [ -e /sys/class/android_usb/android0 ]; then
|
||||||
[ "$NETWORK_ANDROID_ETHADDR" ] && ANDROID_ETHADDR=$NETWORK_ANDROID_ETHADDR
|
[ "$NETWORK_ANDROID_ETHADDR" ] && ANDROID_ETHADDR=$NETWORK_ANDROID_ETHADDR
|
||||||
|
[ "$NETWORK_ANDORID_NETMASK" ] && ANDORID_NETMASK=$NETWORK_ANDORID_NETMASK
|
||||||
echo 0 > /sys/class/android_usb/android0/enable
|
echo 0 > /sys/class/android_usb/android0/enable
|
||||||
echo rndis,acm > /sys/class/android_usb/android0/functions
|
echo rndis,acm > /sys/class/android_usb/android0/functions
|
||||||
echo 2 > /sys/class/android_usb/android0/f_acm/instances
|
echo 2 > /sys/class/android_usb/android0/f_acm/instances
|
||||||
echo $ANDROID_ETHADDR > /sys/class/android_usb/android0/f_rndis/ethaddr
|
echo $ANDROID_ETHADDR > /sys/class/android_usb/android0/f_rndis/ethaddr
|
||||||
echo 2d01 > /sys/class/android_usb/android0/idProduct
|
echo 2d01 > /sys/class/android_usb/android0/idProduct
|
||||||
echo 1 > /sys/class/android_usb/android0/enable
|
echo 1 > /sys/class/android_usb/android0/enable
|
||||||
fi
|
|
||||||
[ -e $network_devices/ifcfg-rndis0 ] || {
|
[ -e $network_devices/ifcfg-rndis0 ] || {
|
||||||
[ "$NETWORK_ANDROID_IPADDR" ] && ANDROID_IPADDR=$NETWORK_ANDROID_IPADDR
|
[ "$NETWORK_ANDROID_IPADDR" ] && ANDROID_IPADDR=$NETWORK_ANDROID_IPADDR
|
||||||
cat > $network_devices/ifcfg-rndis0 << _EOF
|
cat > $network_devices/ifcfg-rndis0 << _EOF
|
||||||
DEVICE=rndis0
|
DEVICE=rndis0
|
||||||
BOOTPROTO=none
|
BOOTPROTO=none
|
||||||
IPADDR=$ANDROID_IPADDR
|
IPADDR=$ANDROID_IPADDR
|
||||||
|
NETMASK=$ANDROID_NETMASK
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
NM_CONTROLLED=no
|
NM_CONTROLLED=no
|
||||||
_EOF
|
_EOF
|
||||||
}
|
}
|
||||||
|
[ -e /etc/dhcpd-rndis0.conf ] || {
|
||||||
|
[ "$NETWORK_ANDROID_SUBNET" ] && ANDROID_SUBNET=$NETWORK_ANDROID_SUBNET
|
||||||
|
[ "$NETWORK_ANDROID_RANGE_FROM" ] && ANDORID_RANGE_FROM=$NETWORK_ANDROID_RANGE_FROM
|
||||||
|
[ "$NETWORK_ANDROID_RANGE_TO" ] && ANDROID_RANGE_TO=$NETWORK_ANDROID_RANGE_TO
|
||||||
|
cat > /etc/dhcpd-rndis0.conf << _EOF
|
||||||
|
# Created by postplug
|
||||||
|
subnet $ANDROID_SUBNET netmask $ANDROID_NETMASK {
|
||||||
|
range dynamic-bootp $ANDROID_RANGE_FROM $ANDROID_RANGE_TO;
|
||||||
|
}
|
||||||
|
_EOF
|
||||||
|
}
|
||||||
|
ifup rndis0
|
||||||
|
touch /var/lib/dhcp/dhcpd-rndis0.leases
|
||||||
|
/sbin/dhcpd -q rndis0 -pf /run/dhcpd-rndis0.pid -cf /etc/dhcpd-rndis0.conf -lf /var/lib/dhcp/dhcpd-rndis0.leases
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$NETWORK_CDC_DISABLE" = "1" ] || cdc_usb
|
[ "$NETWORK_CDC_DISABLE" = "1" ] || cdc_usb
|
||||||
|
@ -31,13 +31,23 @@ FS_NO_DEV_REMOVE=yes
|
|||||||
NETWORK_NEWDEVICE=off
|
NETWORK_NEWDEVICE=off
|
||||||
|
|
||||||
# network parameters for CDC ethernet interface
|
# network parameters for CDC ethernet interface
|
||||||
|
# (default: enabled)
|
||||||
#NETWORK_CDC_DISABLE=1
|
#NETWORK_CDC_DISABLE=1
|
||||||
#NETWORK_CDC_IPADDR=10.99.99.1
|
#NETWORK_CDC_IPADDR=10.99.99.1
|
||||||
|
#NETWORK_CDC_SUBNET=10.99.99.0
|
||||||
|
#NETWORK_CDC_RANGE_FROM=10.99.99.100
|
||||||
|
#NETWORK_CDC_RANGE_TO=10.99.99.199
|
||||||
|
#NETWORK_CDC_NETMASK=255.255.255.0
|
||||||
|
|
||||||
# network parameters for Android rndis ethernet interface
|
# network parameters for Android rndis ethernet interface
|
||||||
|
# (default: enabled)
|
||||||
#NETWORK_ANDROID_DISABLE=1
|
#NETWORK_ANDROID_DISABLE=1
|
||||||
#NETWORK_ANDROID_IPADDR=10.99.99.1
|
#NETWORK_ANDROID_IPADDR=10.99.99.1
|
||||||
#NETWOKR_ANDROID_ETHADDR=01:02:03:04:05:06
|
#NETWOKR_ANDROID_ETHADDR=01:02:03:04:05:06
|
||||||
|
#NETWORK_ANDROID_SUBNET=10.99.99.0
|
||||||
|
#NETWORK_ANDROID_RANGE_FROM=10.99.99.100
|
||||||
|
#NETWORK_ANDROID_RANGE_TO=10.99.99.199
|
||||||
|
#NETWORK_ANDROID_NETMASK=255.255.255.0
|
||||||
|
|
||||||
# xorg server: automatically add DRI section
|
# xorg server: automatically add DRI section
|
||||||
# (on/off, default: on)
|
# (on/off, default: on)
|
||||||
|
Loading…
Reference in New Issue
Block a user