. /etc/sysconfig/rc
. $rc_functions
+. /etc/init.d/networking/functions.network
eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
fi
}
+# Called when dhcpcd relies on a third party to configure an IP address
+dhcpcd_3rdparty() {
+ local qmi_device="$(qmi_find_device "${interface}")"
+
+ if [ -n "${qmi_device}" ]; then
+ setup_qmi "${qmi_device}" || return $?
+ fi
+
+ return 0
+}
+
+setup_qmi() {
+ local device="${1}"
+
+ local address
+ local netmask
+ local gateway
+ local mtu=1500
+
+ local line
+ while read -r line; do
+ # Extract the value
+ value="${line#*: }"
+
+ case "${line}" in
+ *IPv4\ address:*)
+ address="${value}"
+ ;;
+ *IPv4\ subnet\ mask:*)
+ netmask="${value}"
+ ;;
+ *IPv4\ gateway\ address:*)
+ gateway="${value}"
+ ;;
+ *MTU:*)
+ mtu="${value}"
+ ;;
+ esac
+ done <<< "$(qmicli --device="${device}" --wds-get-current-settings)"
+
+ if [ -z "${address}" ] || [ -z "${netmask}" ] || [ -z "${gateway}" ]; then
+ logger -p "local0.info" -t "dhcpcd.exe[$$]" \
+ "Could not retrieve all information from the QMI interface"
+ return 1
+ fi
+
+ # Flush any previous configuration
+ ip addr flush dev "${interface}"
+
+ # Configure the IP address
+ ip addr add "${address}/${netmask}" dev "${interface}"
+
+ # Configure the default route
+ ip route add default via "${gateway}" #mtu "${mtu}"
+
+ return 0
+}
+
case "$reason" in
BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) dhcpcd_up;;
PREINIT|EXPIRE|FAIL|IPV4LL|NAK|RELEASE|STOP) dhcpcd_down;;
+3RDPARTY)
+ dhcpcd_3rdparty
+ ;;
*)
logger -p "local0.info" -t "dhcpcd.exe[$$]" "Unhandled DHCP event: ${reason}"
;;