Root/package/network/config/netifd/files/lib/netifd/dhcp.script

1#!/bin/sh
2[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
3
4. /lib/functions.sh
5. /lib/netifd/netifd-proto.sh
6
7set_classless_routes() {
8    local max=128
9    local type
10    while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
11        proto_add_ipv4_route "${1%%/*}" "${1##*/}" "$2"
12        max=$(($max-1))
13        shift 2
14    done
15}
16
17setup_interface () {
18    proto_init_update "*" 1
19    proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}"
20    # TODO: apply $broadcast
21
22    for i in $router; do
23        proto_add_ipv4_route 0.0.0.0 0 "$i"
24    done
25
26    # CIDR STATIC ROUTES (rfc3442)
27    [ -n "$staticroutes" ] && set_classless_routes $staticroutes
28    [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes
29
30    for dns in $dns; do
31        proto_add_dns_server "$dns"
32    done
33    for domain in $domain; do
34        proto_add_dns_search "$domain"
35    done
36    proto_send_update "$INTERFACE"
37
38    # TODO
39    # [ -n "$ntpsrv" ] && change_state network "$ifc" lease_ntpsrv "$ntpsrv"
40    # [ -n "$timesvr" ] && change_state network "$ifc" lease_timesrv "$timesvr"
41    # [ -n "$hostname" ] && change_state network "$ifc" lease_hostname "$hostname"
42    # [ -n "$timezone" ] && change_state network "$ifc" lease_timezone "$timezone"
43}
44
45deconfig_interface() {
46    proto_init_update "*" 0
47    proto_send_update "$INTERFACE"
48}
49
50case "$1" in
51    deconfig)
52        deconfig_interface
53    ;;
54    renew|bound)
55        setup_interface
56    ;;
57esac
58
59exit 0
60

Archive Download this file



interactive