Add dhcp3 and dhcdbd for Network Manager

git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1175 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
Ross Burton
2007-01-19 20:55:09 +00:00
parent 6564355fb7
commit 776490a40d
15 changed files with 541 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
DESCRIPTION="DBus-enabled dhcp client"
SECTION="net"
LICENSE="GPL"
HOMEPAGE="http://people.redhat.com/jvdias/dhcdbd/"
DEPENDS = "dbus"
RDEPENDS = "dhcp-client"
PR = "r0"
SRC_URI="http://people.redhat.com/dcantrel/dhcdbd/dhcdbd-${PV}.tar.bz2 \
file://no-ext-options.patch;patch=1 \
file://dhcdbd"
do_compile() {
CC=${TARGET_SYS}-gcc DESTDIR=${prefix} make
}
do_install() {
DESTDIR=${D} make install
install -d ${D}/etc/init.d
install -m 0755 ${WORKDIR}/dhcdbd ${D}/etc/init.d/
}
FILES_${PN} += "${sysconfdir} ${datadir}/dbus-1 ${base_sbindir}/*"

View File

@@ -0,0 +1,20 @@
--- /tmp/dbus_service.c 2006-08-24 22:09:14.000000000 +0200
+++ dhcdbd-1.14/dbus_service.c 2006-08-24 22:09:44.228306000 +0200
@@ -1412,7 +1412,7 @@
return ( cs );
give_up:
- dbus_connection_disconnect( connection );
+ dbus_connection_close( connection );
dbus_shutdown();
return ( 0L );
}
@@ -1456,7 +1456,7 @@
cs->roots=0L;
- dbus_connection_disconnect( cs->connection );
+ dbus_connection_close( cs->connection );
dbus_shutdown();
free( cs );
}

View File

@@ -0,0 +1,28 @@
#!/bin/sh
#
# DHCDBD startup script
. /etc/profile
case $1 in
'start')
echo -n "Starting dhcdbd daemon: dhcdbd"
/sbin/dhcdbd --system
echo "."
;;
'stop')
echo -n "Stopping dhcdbd: dhcdbd"
killall `ps |grep /sbin/dhcdbd | grep -v grep | cut "-d " -f2`
echo "."
;;
'restart')
$0 stop
$0 start
;;
*)
echo "Usage: $0 { start | stop | restart }"
;;
esac

View File

@@ -0,0 +1,26 @@
diff -Naur dhcdbd-1.14/Makefile dhcdbd-1.14-mod/Makefile
--- dhcdbd-1.14/Makefile 2006-01-17 22:23:51.000000000 +0100
+++ dhcdbd-1.14-mod/Makefile 2006-08-02 18:02:42.000000000 +0200
@@ -7,8 +7,8 @@
LDFLAGS ?= -g
DESTDIR ?= /
LIBDIR ?= lib
-DBUS_INCLUDES ?= -I/usr/$(LIBDIR)/dbus-1.0/include -I/usr/include/dbus-1.0
-DBUS_LIBS ?= -ldbus-1
+DBUS_INCLUDES ?= `pkg-config dbus-1 --cflags`
+DBUS_LIBS ?= `pkg-config dbus-1 --libs`
OBJS = dbus_service.o dhcdbd.o dhcp_options.o main.o
SRCS = dbus_service.c dhcdbd.c dhcp_options.c main.c
INCS = dbus_service.h dhcdbd.h dhcp_options.h includes.h
diff -Naur dhcdbd-1.14/tests/Makefile dhcdbd-1.14-mod/tests/Makefile
--- dhcdbd-1.14/tests/Makefile 2006-01-17 22:23:51.000000000 +0100
+++ dhcdbd-1.14-mod/tests/Makefile 2006-08-02 18:11:43.000000000 +0200
@@ -2,7 +2,7 @@
LD = ${CC}
CFLAGS ?= -g -Wall
LDFLAGS ?= -g
-DBUS_LIBS ?= -ldbus-1
+DBUS_LIBS ?= `pkg-config dbus-1 --libs`
all: test_dhcp_options test_dhcdbd_state test_subscriber test_subscriber_dbus test_prospective_subscriber

View File

@@ -0,0 +1,13 @@
Index: dhcdbd-2.0/include/dhcdbd.h
===================================================================
--- dhcdbd-2.0.orig/include/dhcdbd.h 2006-10-18 09:38:18.000000000 +0100
+++ dhcdbd-2.0/include/dhcdbd.h 2006-10-18 09:38:45.000000000 +0100
@@ -76,7 +76,7 @@
#endif
#ifndef DHCLIENT_EXTENDED_OPTION_ENVIRONMENT
-#define DHCLIENT_EXTENDED_OPTION_ENVIRONMENT 1
+#define DHCLIENT_EXTENDED_OPTION_ENVIRONMENT 0
#endif
#define DHCDBD_INTERFACE_TEXT "text"

View File

@@ -0,0 +1,50 @@
SECTION = "console/network"
DESCRIPTION = "Internet Software Consortium DHCP package"
HOMEPAGE = "http://www.isc.org/"
LICENSE = "BSD"
PR = "r4"
SRC_URI = "ftp://ftp.isc.org/isc/dhcp/dhcp-3.0-history/dhcp-${PV}.tar.gz \
file://noattrmode.patch;patch=1 \
file://fixincludes.patch;patch=1 \
file://dhcp-3.0.3-dhclient-dbus.patch;patch=1;pnum=0 \
file://init-relay file://default-relay \
file://init-server file://default-server \
file://dhclient.conf file://dhcpd.conf"
do_configure() {
./configure
}
do_compile() {
make RANLIB=${RANLIB} PREDEFINES='-D_PATH_DHCPD_DB=\"/var/lib/dhcp/dhcpd.leases\" \
-D_PATH_DHCLIENT_DB=\"/var/lib/dhcp/dhclient.leases\" \
-D_PATH_DHCLIENT_SCRIPT=\"/sbin/dhclient-script\" \
-D_PATH_DHCPD_CONF=\"/etc/dhcp/dhcpd.conf\" \
-D_PATH_DHCLIENT_CONF=\"/etc/dhcp/dhclient.conf\"'
}
do_install() {
make -e DESTDIR=${D} USRMANDIR=${mandir}/man1 ADMMANDIR=${mandir}/man8 FFMANDIR=${mandir}/man5 LIBMANDIR=${mandir}/man3 LIBDIR=${libdir} INCDIR=${includedir} install
install -d ${D}${sysconfdir}/init.d
install -d ${D}${sysconfdir}/default
install -d ${D}${sysconfdir}/dhcp
install -m 0755 ${WORKDIR}/init-relay ${D}${sysconfdir}/init.d/dhcp-relay
install -m 0644 ${WORKDIR}/default-relay ${D}${sysconfdir}/default/dhcp-relay
install -m 0755 ${WORKDIR}/init-server ${D}${sysconfdir}/init.d/dhcp-server
install -m 0644 ${WORKDIR}/default-server ${D}${sysconfdir}/default/dhcp-server
install -m 0644 ${WORKDIR}/dhclient.conf ${D}${sysconfdir}/dhcp/dhclient.conf
install -m 0644 ${WORKDIR}/dhcpd.conf ${D}${sysconfdir}/dhcp/dhcpd.conf
}
PACKAGES =+ "dhcp-server dhcp-client dhcp-relay dhcp-omshell"
FILES_dhcp-server = "${sbindir}/dhcpd /etc/init.d/dhcp-server /etc/default/dhcp-server /etc/dhcp/dhcpd.conf"
FILES_dhcp-relay = "${sbindir}/dhcrelay /etc/init.d/dhcp-relay /etc/default/dhcp-relay"
FILES_dhcp-client = "/sbin/ /etc/dhcp/dhclient.conf"
#RDEPENDS_dhcp-client = "bash"
FILES_dhcp-omshell = "${bindir}/omshell"
CONFFILES_dhcp-server_nylon = "/etc/dhcp/dhcpd.conf"
CONFFILES_dhcp-relay_nylon = "/etc/default/dhcp-relay"
CONFFILES_dhcp-client_nylon = "/etc/dhcp/dhclient.conf"

View File

@@ -0,0 +1,12 @@
# Defaults for dhcp-relay initscript
# sourced by /etc/init.d/dhcp-relay
# What servers should the DHCP relay forward requests to?
# e.g: SERVERS="192.168.0.1"
SERVERS=""
# On what interfaces should the DHCP relay (dhrelay) serve DHCP requests?
INTERFACES=""
# Additional options that are passed to the DHCP relay daemon?
OPTIONS=""

View File

@@ -0,0 +1,7 @@
# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp-server
# installed at /etc/default/dhcp-server by the maintainer scripts
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES=""

View File

@@ -0,0 +1,50 @@
# Configuration file for /sbin/dhclient, which is included in Debian's
# dhcp3-client package.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then
# few changes must be made to this file, if any.
#
#send host-name "andare.fugue.com";
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhcp3/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;
#alias {
# interface "eth0";
# fixed-address 192.5.5.213;
# option subnet-mask 255.255.255.255;
#}
#lease {
# interface "eth0";
# fixed-address 192.33.137.200;
# medium "link0 link1";
# option host-name "andare.swiftmedia.com";
# option subnet-mask 255.255.255.0;
# option broadcast-address 192.33.137.255;
# option routers 192.33.137.250;
# option domain-name-servers 127.0.0.1;
# renew 2 2000/1/12 00:00:01;
# rebind 2 2000/1/12 00:00:01;
# expire 2 2000/1/12 00:00:01;
#}

View File

@@ -0,0 +1,84 @@
--- client/scripts/bsdos
+++ client/scripts/bsdos
@@ -47,6 +47,11 @@
. /etc/dhcp/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
+ dbus-send --system --dest=com.redhat.dhcp \
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
+ fi
exit $exit_status
}
--- client/scripts/freebsd
+++ client/scripts/freebsd
@@ -57,6 +57,11 @@
. /etc/dhcp/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
+ dbus-send --system --dest=com.redhat.dhcp \
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
+ fi
exit $exit_status
}
--- client/scripts/linux
+++ client/scripts/linux
@@ -69,6 +69,11 @@
. /etc/dhcp/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
+ dbus-send --system --dest=com.redhat.dhcp \
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
+ fi
exit $exit_status
}
--- client/scripts/netbsd
+++ client/scripts/netbsd
@@ -47,6 +47,11 @@
. /etc/dhcp/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
+ dbus-send --system --dest=com.redhat.dhcp \
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
+ fi
exit $exit_status
}
--- client/scripts/openbsd
+++ client/scripts/openbsd
@@ -47,6 +47,11 @@
. /etc/dhcp/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
+ dbus-send --system --dest=com.redhat.dhcp \
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
+ fi
exit $exit_status
}
--- client/scripts/solaris
+++ client/scripts/solaris
@@ -47,6 +47,11 @@
. /etc/dhcp/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
+ dbus-send --system --dest=com.redhat.dhcp \
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
+ fi
exit $exit_status
}

View File

@@ -0,0 +1,108 @@
#
# Sample configuration file for ISC dhcpd for Debian
#
# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
#
# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
#subnet 10.152.187.0 netmask 255.255.255.0 {
#}
# This is a very basic subnet declaration.
#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}
# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
#class "foo" {
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}
#shared-network 224-29 {
# subnet 10.17.224.0 netmask 255.255.255.0 {
# option routers rtr-224.example.org;
# }
# subnet 10.0.29.0 netmask 255.255.255.0 {
# option routers rtr-29.example.org;
# }
# pool {
# allow members of "foo";
# range 10.17.224.10 10.17.224.250;
# }
# pool {
# deny members of "foo";
# range 10.0.29.10 10.0.29.230;
# }
#}

View File

@@ -0,0 +1,10 @@
--- dhcp-3.0.2/common/tr.c~compile 2005-10-13 14:23:37.000000000 +0200
+++ dhcp-3.0.2/common/tr.c 2005-10-13 14:23:45.000000000 +0200
@@ -39,6 +39,7 @@
#include "includes/netinet/udp.h"
#include "includes/netinet/if_ether.h"
#include "netinet/if_tr.h"
+#include <asm/types.h>
#include <sys/time.h>
/*

View File

@@ -0,0 +1,44 @@
#!/bin/sh
#
# $Id: dhcp3-relay,v 1.1 2004/04/16 15:41:08 ml Exp $
#
# It is not safe to start if we don't have a default configuration...
if [ ! -f /etc/default/dhcp-relay ]; then
echo "/etc/default/dhcp-relay does not exist! - Aborting..."
echo "create this file to fix the problem."
exit 1
fi
# Read init script configuration (interfaces the daemon should listen on
# and the DHCP server we should forward requests to.)
. /etc/default/dhcp-relay
# Build command line for interfaces (will be passed to dhrelay below.)
IFCMD=""
if test "$INTERFACES" != ""; then
for I in $INTERFACES; do
IFCMD=${IFCMD}"-i "${I}" "
done
fi
DHCRELAYPID=/var/run/dhcrelay.pid
case "$1" in
start)
start-stop-daemon -S -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS
;;
stop)
start-stop-daemon -K -x /usr/sbin/dhcrelay
;;
restart | force-reload)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: /etc/init.d/dhcp-relay {start|stop|restart|force-reload}"
exit 1
esac
exit 0

View File

@@ -0,0 +1,44 @@
#!/bin/sh
#
# $Id: dhcp3-server.init.d,v 1.4 2003/07/13 19:12:41 mdz Exp $
#
test -f /usr/sbin/dhcpd || exit 0
# It is not safe to start if we don't have a default configuration...
if [ ! -f /etc/default/dhcp-server ]; then
echo "/etc/default/dhcp-server does not exist! - Aborting..."
exit 0
fi
# Read init script configuration (so far only interfaces the daemon
# should listen on.)
. /etc/default/dhcp-server
case "$1" in
start)
echo -n "Starting DHCP server: "
test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/
test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases
start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $INTERFACES
echo "."
;;
stop)
echo -n "Stopping DHCP server: dhcpd3"
start-stop-daemon -K -x /usr/sbin/dhcpd
echo "."
;;
restart | force-reload)
$0 stop
sleep 2
$0 start
if [ "$?" != "0" ]; then
exit 1
fi
;;
*)
echo "Usage: /etc/init.d/dhcp-server {start|stop|restart|force-reload}"
exit 1
esac
exit 0

View File

@@ -0,0 +1,20 @@
#
# Patch managed by http://www.holgerschurig.de/patcher.html
#
--- dhcp-3.0.1/includes/dhcpd.h~compile
+++ dhcp-3.0.1/includes/dhcpd.h
@@ -306,9 +306,9 @@
# define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
UNICAST_BROADCAST_HACK)
- binding_state_t __attribute__ ((mode (__byte__))) binding_state;
- binding_state_t __attribute__ ((mode (__byte__))) next_binding_state;
- binding_state_t __attribute__ ((mode (__byte__))) desired_binding_state;
+ binding_state_t binding_state;
+ binding_state_t next_binding_state;
+ binding_state_t desired_binding_state;
struct lease_state *state;