Changeset 26998 for packages


Ignore:
Timestamp:
2011-05-24T12:01:23+02:00 (5 years ago)
Author:
jow
Message:

[PATCH] add interface and hosts parsing from uci dhcp config to ISC dhcpd (fix bridges)
This allows people to use the luci interface to specify to dhcpd which
interfaces it should listen to, and which static MAC->IP host mappings
should it define
For the interface, this has to be done in the initscript, via
commandline when the server is started
For the static hosts, the initscript makes a file called
/tmp/dhcpd.hosts which you can include in your dhcpd.config to use the
webgui defined hosts
Fix: 7.5.2011. Now works properly on interfaces which are in a bridge

Signed-off-by: Rajko Stojadinovic <admin@…>

Location:
packages/net/dhcp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • packages/net/dhcp/Makefile

    r26068 r26998  
    11# 
    2 # Copyright (C) 2006-2008 OpenWrt.org 
     2# Copyright (C) 2006-2011 OpenWrt.org 
    33# 
    44# This is free software, licensed under the GNU General Public License v2. 
     
    1010PKG_NAME:=dhcp 
    1111PKG_VERSION:=3.1.0 
    12 PKG_RELEASE:=2 
     12PKG_RELEASE:=3 
    1313 
    1414PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 
  • packages/net/dhcp/files/dhcpd.init

    r20814 r26998  
    55config_file=/etc/dhcpd.conf 
    66pid_file=/var/run/dhcpd.pid 
     7hosts_file=/tmp/dhcpd.hosts 
     8dhcp_ifs="" 
     9 
     10append_interface() { 
     11        local ifname=$(uci_get_state network "$1" device) 
     12        if [ "$(uci_get_state network "$1" type)" = "bridge" ]; then 
     13                ifname=$(uci_get_state network "$1" ifname); fi 
     14 
     15        if [ -z "$dhcp_ifs" ]; then 
     16                dhcp_ifs="$ifname" 
     17        else 
     18                dhcp_ifs="$dhcp_ifs $ifname" 
     19        fi 
     20} 
     21 
     22parse_dhcp() { 
     23        local cfg="$1" 
     24        config_get net "$cfg" interface 
     25        [ -n "$net" ] || return 0 
     26 
     27        config_get_bool ignore "$1" ignore 0 
     28        if [ "$ignore" -eq 1 ]; then return 0; fi 
     29 
     30        append_interface $net 
     31} 
     32 
     33parse_host_entry() { 
     34                local cfg="$1" 
     35 
     36                config_get name "$cfg" name 
     37 
     38                config_get ip "$cfg" ip 
     39                [ -n "$ip" ] || return 0 
     40 
     41        local i=0 
     42                config_get mac "$cfg" mac 
     43                for m in $mac; do 
     44                local hostid="$name" 
     45                if [ $i -ne 0 ]; then hostid="$name"_"$i"; fi 
     46 
     47                echo "host $hostid {" >> "$hosts_file" 
     48                echo "hardware ethernet $m;" >> "$hosts_file" 
     49                echo "fixed-address $ip;" >> "$hosts_file" 
     50                echo "}" >> $hosts_file 
     51 
     52                i=$((i+1)) 
     53        done 
     54} 
     55 
     56init_config() { 
     57        echo " #Automatically generated by dhcpd initscript, any modifications will be overwritten" > "$hosts_file" 
     58 
     59        include /lib/network 
     60        scan_interfaces 
     61        config_load dhcp 
     62 
     63        config_foreach parse_host_entry host 
     64        config_foreach parse_dhcp dhcp 
     65} 
    766 
    867start() { 
Note: See TracChangeset for help on using the changeset viewer.