Reverting dhcp for rawhide to 3.1.0 for the time being. 4.0.0 is still in
the works.
This commit is contained in:
parent
c987ce551e
commit
6a2e4a260b
192
README.ldap
192
README.ldap
@ -1,192 +0,0 @@
|
||||
LDAP Support in DHCP
|
||||
Brian Masney <masneyb@ntelos.net>
|
||||
Last updated 3/23/2003
|
||||
|
||||
This document describes setting up the DHCP server to read it's configuration
|
||||
from LDAP. This work is based on the IETF document
|
||||
draft-ietf-dhc-ldap-schema-01.txt included in the doc directory. For the
|
||||
latest version of this document, please see http://home.ntelos.net/~masneyb.
|
||||
|
||||
First question on most people's mind is "Why do I want to store my
|
||||
configuration in LDAP?" If you run a small DHCP server, and the configuration
|
||||
on it rarely changes, then you won't need to store your configuration in LDAP.
|
||||
But, if you have several DHCP servers, and you want an easy way to manage your
|
||||
configuration, this can be a solution.
|
||||
|
||||
The first step will be to setup your LDAP server. I am using OpenLDAP from
|
||||
www.openldap.org. Building and installing OpenLDAP is beyond the scope of
|
||||
this document. There is plenty of documentation out there about this. Once
|
||||
you have OpenLDAP installed, you will have to edit your slapd.conf file. I
|
||||
added the following 2 lines to my configuration file:
|
||||
|
||||
include /etc/ldap/schema/dhcp.schema
|
||||
index dhcpHWAddress eq
|
||||
index dhcpClassData eq
|
||||
|
||||
The first line tells it to include the dhcp schema file. You will find this
|
||||
file under the contrib directory in this distribution. You will need to copy
|
||||
this file to where your other schema files are (maybe
|
||||
/usr/local/openldap/etc/openldap/schema/). The second line sets up an index
|
||||
for the dhcpHWAddress parameter. The third parameter is for reading subclasses
|
||||
from LDAP every time a DHCP request comes in. Make sure you run the slapindex
|
||||
command and restart slapd to have these changes to into effect.
|
||||
|
||||
Now that you have LDAP setup, you should be able to use gq
|
||||
(http://biot.com/gq/) to verify that the dhcp schema file is loaded into LDAP.
|
||||
Pull up gq, and click on the Schema tab. Go under objectClasses, and you
|
||||
should see at least the following object classes listed: dhcpClass, dhcpGroup,
|
||||
dhcpHost, dhcpOptions, dhcpPool, dhcpServer, dhcpService, dhcpSharedNetwork,
|
||||
dhcpSubClass, and dhcpSubnet. If you do not see these, you need to check over
|
||||
your LDAP configuration before you go any further.
|
||||
|
||||
You should now be ready to build DHCP. If you would like to enable LDAP over
|
||||
SSL, you will need to perform the following steps:
|
||||
|
||||
* Edit the includes/site.h file and uncomment the USE_SSL line
|
||||
or specify "-DUSE_SSL" via CFLAGS.
|
||||
* Edit the dst/Makefile.dist file and remove md5_dgst.c and md5_dgst.o
|
||||
from the SRC= and OBJ= lines (around line 24)
|
||||
* Now run configure in the base source directory. If you chose to enable
|
||||
LDAP over SSL, you must append -lcrypto -lssl to the LIBS= line in the
|
||||
file work.os/server/Makefile (replace os with your operating system,
|
||||
linux-2.2 on my machine). You should now be able to type make to build
|
||||
your DHCP server.
|
||||
|
||||
If you choose to not enable LDAP over SSL, then you only need to run configure
|
||||
and make in the toplevel source directory.
|
||||
|
||||
Once you have DHCP installed, you will need to setup your initial plaintext
|
||||
config file. In my /etc/dhcpd.conf file, I have:
|
||||
|
||||
ldap-server "localhost";
|
||||
ldap-port 389;
|
||||
ldap-username "cn=DHCP User, dc=ntelos, dc=net";
|
||||
ldap-password "blah";
|
||||
ldap-base-dn "dc=ntelos, dc=net";
|
||||
ldap-method dynamic;
|
||||
ldap-debug-file "/var/log/dhcp-ldap-startup.log";
|
||||
|
||||
If SSL has been enabled at compile time using the USE_SSL flag, the dhcp
|
||||
server trys to use TLS if possible, but continues without TLS if not.
|
||||
|
||||
You can modify this behaviour using following option in /etc/dhcpd.conf:
|
||||
|
||||
ldap-ssl <off | ldaps | start_tls | on>
|
||||
off: disables TLS/LDAPS.
|
||||
ldaps: enables LDAPS -- don't forget to set ldap-port to 636.
|
||||
start_tls: enables TLS using START_TLS command
|
||||
on: enables LDAPS if ldap-port is set to 636 or TLS in
|
||||
other cases.
|
||||
|
||||
See also "man 5 ldap.conf" for description the following TLS related
|
||||
options:
|
||||
ldap-tls-reqcert, ldap-tls-ca-file, ldap-tls-ca-dir, ldap-tls-cert
|
||||
ldap-tls-key, ldap-tls-crlcheck, ldap-tls-ciphers, ldap-tls-randfile
|
||||
|
||||
All of these parameters should be self explanatory except for the ldap-method.
|
||||
You can set this to static or dynamic. If you set it to static, the
|
||||
configuration is read once on startup, and LDAP isn't used anymore. But, if
|
||||
you set this to dynamic, the configuration is read once on startup, and the
|
||||
hosts that are stored in LDAP are looked up every time a DHCP request comes
|
||||
in.
|
||||
|
||||
When the optional statement ldap-debug-file is specified, on startup the DHCP
|
||||
server will write out the configuration that it generated from LDAP. If you
|
||||
are getting errors about your LDAP configuration, this is a good place to
|
||||
start looking.
|
||||
|
||||
The next step is to set up your LDAP tree. Here is an example config that will
|
||||
give a 10.100.0.x address to machines that have a host entry in LDAP.
|
||||
Otherwise, it will give a 10.200.0.x address to them. (NOTE: replace
|
||||
dc=ntelos, dc=net with your base dn). If you would like to convert your
|
||||
existing dhcpd.conf file to LDIF format, there is a script
|
||||
contrib/dhcpd-conf-to-ldap.pl that will convert it for you. Type
|
||||
dhcpd-conf-to-ldap.pl --help to see the usage information for this script.
|
||||
|
||||
# You must specify the server's host name in LDAP that you are going to run
|
||||
# DHCP on and point it to which config tree you want to use. Whenever DHCP
|
||||
# first starts up, it will do a search for this entry to find out which
|
||||
# config to use
|
||||
dn: cn=brian.ntelos.net, dc=ntelos, dc=net
|
||||
objectClass: top
|
||||
objectClass: dhcpServer
|
||||
cn: brian.ntelos.net
|
||||
dhcpServiceDN: cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
|
||||
# Here is the config tree that brian.ntelos.net points to.
|
||||
dn: cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: DHCP Service Config
|
||||
objectClass: top
|
||||
objectClass: dhcpService
|
||||
dhcpPrimaryDN: dc=ntelos, dc=net
|
||||
dhcpStatements: ddns-update-style none
|
||||
dhcpStatements: default-lease-time 600
|
||||
dhcpStatements: max-lease-time 7200
|
||||
|
||||
# Set up a shared network segment
|
||||
dn: cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: WV
|
||||
objectClass: top
|
||||
objectClass: dhcpSharedNetwork
|
||||
|
||||
# Set up a subnet declaration with a pool statement. Also note that we have
|
||||
# a dhcpOptions object with this entry
|
||||
dn: cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: 10.100.0.0
|
||||
objectClass: top
|
||||
objectClass: dhcpSubnet
|
||||
objectClass: dhcpOptions
|
||||
dhcpOption: domain-name-servers 10.100.0.2
|
||||
dhcpOption: routers 10.100.0.1
|
||||
dhcpOption: subnet-mask 255.255.255.0
|
||||
dhcpOption: broadcast-address 10.100.0.255
|
||||
dhcpNetMask: 24
|
||||
|
||||
# Set up a pool for this subnet. Only known hosts will get these IPs
|
||||
dn: cn=Known Pool, cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: Known Pool
|
||||
objectClass: top
|
||||
objectClass: dhcpPool
|
||||
dhcpRange: 10.100.0.3 10.100.0.254
|
||||
dhcpPermitList: deny unknown-clients
|
||||
|
||||
# Set up another subnet declaration with a pool statement
|
||||
dn: cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: 10.200.0.0
|
||||
objectClass: top
|
||||
objectClass: dhcpSubnet
|
||||
objectClass: dhcpOptions
|
||||
dhcpOption: domain-name-servers 10.200.0.2
|
||||
dhcpOption: routers 10.200.0.1
|
||||
dhcpOption: subnet-mask 255.255.255.0
|
||||
dhcpOption: broadcast-address 10.200.0.255
|
||||
dhcpNetMask: 24
|
||||
|
||||
# Set up a pool for this subnet. Only unknown hosts will get these IPs
|
||||
dn: cn=Known Pool, cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
cn: Known Pool
|
||||
objectClass: top
|
||||
objectClass: dhcpPool
|
||||
dhcpRange: 10.200.0.3 10.200.0.254
|
||||
dhcpPermitList: deny known clients
|
||||
|
||||
# Set aside a group for all of our known MAC addresses
|
||||
dn: cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
objectClass: top
|
||||
objectClass: dhcpGroup
|
||||
cn: Customers
|
||||
|
||||
# Host entry for my laptop
|
||||
dn: cn=brianlaptop, cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
|
||||
objectClass: top
|
||||
objectClass: dhcpHost
|
||||
cn: brianlaptop
|
||||
dhcpHWAddress: ethernet 00:00:00:00:00:00
|
||||
|
||||
You can use the command slapadd to load all of these entries into your LDAP
|
||||
server. After you load this, you should be able to start up DHCP. If you run
|
||||
into problems reading the configuration, try running dhcpd with the -d flag.
|
||||
If you still have problems, edit the site.conf file in the DHCP source and
|
||||
add the line: COPTS= -DDEBUG_LDAP and recompile DHCP. (make sure you run make
|
||||
clean and rerun configure before you rebuild).
|
||||
|
@ -1,58 +0,0 @@
|
||||
--- dhcp-3.0.5/client/dhclient.c.decline 2007-03-30 15:29:58.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2007-03-30 15:50:25.000000000 -0400
|
||||
@@ -934,6 +934,7 @@
|
||||
void *cpp;
|
||||
{
|
||||
struct client_state *client = cpp;
|
||||
+ enum dhcp_state init_state = client->state;
|
||||
|
||||
ASSERT_STATE(state, S_INIT);
|
||||
|
||||
@@ -946,9 +947,16 @@
|
||||
client -> first_sending = cur_time;
|
||||
client -> interval = client -> config -> initial_interval;
|
||||
|
||||
- /* Add an immediate timeout to cause the first DHCPDISCOVER packet
|
||||
- to go out. */
|
||||
- send_discover (client);
|
||||
+ if (init_state != S_DECLINED) {
|
||||
+ /* Add an immediate timeout to cause the first DHCPDISCOVER packet
|
||||
+ to go out. */
|
||||
+ send_discover(client);
|
||||
+ } else {
|
||||
+ /* We've received an OFFER and it has been DECLINEd by dhclient-script.
|
||||
+ * wait for a random time between 1 and backoff_cutoff seconds before
|
||||
+ * trying again. */
|
||||
+ add_timeout(cur_time + ((1 + (random() >> 2)) % client->config->backoff_cutoff), send_discover, client, 0, 0);
|
||||
+ }
|
||||
}
|
||||
|
||||
/* state_selecting is called when one or more DHCPOFFER packets have been
|
||||
@@ -1215,6 +1223,7 @@
|
||||
send_decline (client);
|
||||
destroy_client_lease (client -> new);
|
||||
client -> new = (struct client_lease *)0;
|
||||
+ client -> state = S_DECLINED;
|
||||
state_init (client);
|
||||
return;
|
||||
}
|
||||
@@ -3183,6 +3192,7 @@
|
||||
case S_INIT:
|
||||
case S_REBINDING:
|
||||
case S_STOPPED:
|
||||
+ case S_DECLINED:
|
||||
break;
|
||||
}
|
||||
client -> state = S_INIT;
|
||||
--- dhcp-3.0.5/includes/dhcpd.h.decline 2007-03-30 15:30:14.000000000 -0400
|
||||
+++ dhcp-3.0.5/includes/dhcpd.h 2007-03-30 15:50:53.000000000 -0400
|
||||
@@ -704,7 +704,8 @@
|
||||
S_BOUND = 5,
|
||||
S_RENEWING = 6,
|
||||
S_REBINDING = 7,
|
||||
- S_STOPPED = 8
|
||||
+ S_STOPPED = 8,
|
||||
+ S_DECLINED = 9
|
||||
};
|
||||
|
||||
/* Authentication and BOOTP policy possibilities (not all values work
|
@ -1,15 +0,0 @@
|
||||
--- dhcp-3.0.5/common/dispatch.c.ecat 2006-02-22 17:43:27.000000000 -0500
|
||||
+++ dhcp-3.0.5/common/dispatch.c 2007-03-30 15:54:15.000000000 -0400
|
||||
@@ -195,7 +195,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
-#if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
|
||||
void cancel_all_timeouts ()
|
||||
{
|
||||
struct timeout *t, *n;
|
||||
@@ -216,4 +215,3 @@
|
||||
dfree (t, MDL);
|
||||
}
|
||||
}
|
||||
-#endif
|
@ -1,29 +0,0 @@
|
||||
--- dhcp-3.0.5/omapip/errwarn.c.message 2007-03-29 15:03:12.000000000 -0400
|
||||
+++ dhcp-3.0.5/omapip/errwarn.c 2007-03-29 15:08:50.000000000 -0400
|
||||
@@ -80,20 +80,13 @@
|
||||
|
||||
#if !defined (NOMINUM)
|
||||
log_error ("%s", "");
|
||||
- log_error ("If you did not get this software from ftp.isc.org, please");
|
||||
- log_error ("get the latest from ftp.isc.org and install that before");
|
||||
- log_error ("requesting help.");
|
||||
+ log_error ("This version of ISC DHCP is based on the release available");
|
||||
+ log_error ("on ftp.isc.org. Features have been added and other changes");
|
||||
+ log_error ("have been made to the base software release in order to make");
|
||||
+ log_error ("it work better with this distribution.");
|
||||
log_error ("%s", "");
|
||||
- log_error ("If you did get this software from ftp.isc.org and have not");
|
||||
- log_error ("yet read the README, please read it before requesting help.");
|
||||
- log_error ("If you intend to request help from the dhcp-server@isc.org");
|
||||
- log_error ("mailing list, please read the section on the README about");
|
||||
- log_error ("submitting bug reports and requests for help.");
|
||||
- log_error ("%s", "");
|
||||
- log_error ("Please do not under any circumstances send requests for");
|
||||
- log_error ("help directly to the authors of this software - please");
|
||||
- log_error ("send them to the appropriate mailing list as described in");
|
||||
- log_error ("the README file.");
|
||||
+ log_error ("Please report for this software via the Red Hat Bugzilla site:");
|
||||
+ log_error (" http://bugzilla.redhat.com");
|
||||
log_error ("%s", "");
|
||||
log_error ("exiting.");
|
||||
#endif
|
@ -1,22 +0,0 @@
|
||||
--- dhcp-3.0.5/server/confpars.c.failover 2007-03-30 16:28:08.000000000 -0400
|
||||
+++ dhcp-3.0.5/server/confpars.c 2007-03-30 16:32:39.000000000 -0400
|
||||
@@ -998,10 +998,17 @@
|
||||
parse_warn (cfile, "peer address may not be omitted");
|
||||
|
||||
/* XXX - when/if we get a port number assigned, just set as default */
|
||||
+ /* See Red Hat Bugzilla 167292:
|
||||
+ * we do now: dhcp-failover 647/tcp
|
||||
+ * dhcp-failover 647/udp
|
||||
+ * dhcp-failover 847/tcp
|
||||
+ * dhcp-failover 847/udp
|
||||
+ * IANA registration by Bernard Volz <volz@cisco.com>
|
||||
+ */
|
||||
if (!peer -> me.port)
|
||||
- parse_warn (cfile, "local port may not be omitted");
|
||||
+ peer -> me.port = 647;
|
||||
if (!peer -> partner.port)
|
||||
- parse_warn (cfile, "peer port may not be omitted");
|
||||
+ peer -> partner.port = 847;
|
||||
|
||||
if (peer -> i_am == primary) {
|
||||
if (!peer -> hba) {
|
@ -1,84 +0,0 @@
|
||||
--- dhcp-3.0.5/client/dhclient.c.release 2007-03-30 15:30:14.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2007-03-30 15:29:58.000000000 -0400
|
||||
@@ -366,9 +366,81 @@
|
||||
}
|
||||
}
|
||||
fclose(pidfd);
|
||||
+ } else {
|
||||
+ /* handle release for interfaces requested with Red Hat
|
||||
+ * /sbin/ifup - pidfile will be /var/run/dhclient-$interface.pid
|
||||
+ */
|
||||
+
|
||||
+ if ((path_dhclient_pid == NULL) || (*path_dhclient_pid == '\0'))
|
||||
+ path_dhclient_pid = "/var/run/dhclient.pid";
|
||||
+
|
||||
+ char *new_path_dhclient_pid;
|
||||
+ struct interface_info *ip;
|
||||
+ int pdp_len = strlen(path_dhclient_pid), pfx, dpfx;
|
||||
+
|
||||
+ /* find append point: beginning of any trailing '.pid'
|
||||
+ * or '-$IF.pid' */
|
||||
+ for (pfx=pdp_len; (pfx >= 0) && (path_dhclient_pid[pfx] != '.') && (path_dhclient_pid[pfx] != '/'); pfx--);
|
||||
+ if (pfx == -1)
|
||||
+ pfx = pdp_len;
|
||||
+
|
||||
+ if (path_dhclient_pid[pfx] == '/')
|
||||
+ pfx += 1;
|
||||
+
|
||||
+ for (dpfx=pfx; (dpfx >= 0) && (path_dhclient_pid[dpfx] != '-') && (path_dhclient_pid[dpfx] != '/'); dpfx--);
|
||||
+ if ((dpfx > -1) && (path_dhclient_pid[dpfx] != '/'))
|
||||
+ pfx = dpfx;
|
||||
+
|
||||
+ for (ip = interfaces; ip; ip = ip->next) {
|
||||
+ if (interfaces_requested && (ip->flags & (INTERFACE_REQUESTED)) && (ip->name != NULL)) {
|
||||
+ int n_len = strlen(ip->name);
|
||||
+
|
||||
+ new_path_dhclient_pid = (char*) malloc(pfx + n_len + 6);
|
||||
+ strncpy(new_path_dhclient_pid, path_dhclient_pid, pfx);
|
||||
+ sprintf(new_path_dhclient_pid + pfx, "-%s.pid", ip->name);
|
||||
+
|
||||
+ if ((pidfd = fopen(new_path_dhclient_pid, "r")) != NULL) {
|
||||
+ e = fscanf(pidfd, "%ld\n", &temp);
|
||||
+ oldpid = (pid_t)temp;
|
||||
+
|
||||
+ if (e != 0 && e != EOF) {
|
||||
+ if (oldpid) {
|
||||
+ if (kill(oldpid, SIGTERM) == 0)
|
||||
+ unlink(path_dhclient_pid);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ fclose(pidfd);
|
||||
+ }
|
||||
+
|
||||
+ free(new_path_dhclient_pid);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ FILE *pidfp = NULL;
|
||||
+ long temp = 0;
|
||||
+ pid_t dhcpid = 0;
|
||||
+ int dhc_running = 0;
|
||||
+ char procfn[256] = "";
|
||||
+
|
||||
+ if ((pidfp = fopen(path_dhclient_pid, "r")) != NULL) {
|
||||
+ if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
|
||||
+ snprintf(procfn,256,"/proc/%u",dhcpid);
|
||||
+ dhc_running = (access(procfn, F_OK) == 0);
|
||||
+ }
|
||||
+
|
||||
+ fclose(pidfp);
|
||||
+ }
|
||||
+
|
||||
+ if (dhc_running) {
|
||||
+ log_fatal("dhclient(%u) is already running - exiting. ", dhcpid);
|
||||
+ return(1);
|
||||
}
|
||||
}
|
||||
|
||||
+ write_client_pid_file();
|
||||
+
|
||||
if (!quiet) {
|
||||
log_info ("%s %s", message, DHCP_VERSION);
|
||||
log_info (copyright);
|
@ -1,11 +0,0 @@
|
||||
--- dhcp-3.0.5/client/dhclient.c.selinux 2007-03-30 16:11:54.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2007-03-30 16:12:27.000000000 -0400
|
||||
@@ -3009,6 +3009,8 @@
|
||||
wstatus = 0;
|
||||
}
|
||||
} else {
|
||||
+ if (leaseFile)
|
||||
+ fclose(leaseFile);
|
||||
execve (scriptName, argv, envp);
|
||||
log_error ("execve (%s, ...): %m", scriptName);
|
||||
exit (0);
|
@ -1,97 +0,0 @@
|
||||
--- dhcp-3.0.5/server/bootp.c.unicast 2005-05-18 15:54:17.000000000 -0400
|
||||
+++ dhcp-3.0.5/server/bootp.c 2007-03-30 16:16:00.000000000 -0400
|
||||
@@ -62,6 +62,7 @@
|
||||
char msgbuf [1024];
|
||||
int ignorep;
|
||||
int peer_has_leases = 0;
|
||||
+ int norelay = 0;
|
||||
|
||||
if (packet -> raw -> op != BOOTREQUEST)
|
||||
return;
|
||||
@@ -77,7 +78,7 @@
|
||||
? inet_ntoa (packet -> raw -> giaddr)
|
||||
: packet -> interface -> name);
|
||||
|
||||
- if (!locate_network (packet)) {
|
||||
+ if ((norelay = locate_network (packet)) == 0) {
|
||||
log_info ("%s: network unknown", msgbuf);
|
||||
return;
|
||||
}
|
||||
@@ -357,6 +358,13 @@
|
||||
from, &to, &hto);
|
||||
goto out;
|
||||
}
|
||||
+ } else if (norelay == 2) {
|
||||
+ to.sin_addr = raw.ciaddr;
|
||||
+ to.sin_port = remote_port;
|
||||
+ if (fallback_interface) {
|
||||
+ result = send_packet (fallback_interface, (struct packet *)0, &raw, outgoing.packet_length, from, &to, &hto);
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
/* If it comes from a client that already knows its address
|
||||
and is not requesting a broadcast response, and we can
|
||||
--- dhcp-3.0.5/server/dhcp.c.unicast 2007-03-30 16:13:36.000000000 -0400
|
||||
+++ dhcp-3.0.5/server/dhcp.c 2007-03-30 16:19:35.000000000 -0400
|
||||
@@ -3817,6 +3817,7 @@
|
||||
struct data_string data;
|
||||
struct subnet *subnet = (struct subnet *)0;
|
||||
struct option_cache *oc;
|
||||
+ int norelay = 0;
|
||||
|
||||
/* See if there's a subnet selection option. */
|
||||
oc = lookup_option (&dhcp_universe, packet -> options,
|
||||
@@ -3826,12 +3827,24 @@
|
||||
from the interface, if there is one. If not, fail. */
|
||||
if (!oc && !packet -> raw -> giaddr.s_addr) {
|
||||
if (packet -> interface -> shared_network) {
|
||||
- shared_network_reference
|
||||
- (&packet -> shared_network,
|
||||
- packet -> interface -> shared_network, MDL);
|
||||
- return 1;
|
||||
+ struct in_addr any_addr;
|
||||
+ any_addr.s_addr = INADDR_ANY;
|
||||
+
|
||||
+ if (!packet -> packet_type && memcmp(&packet -> raw -> ciaddr, &any_addr, 4)) {
|
||||
+ struct iaddr cip;
|
||||
+ memcpy(cip.iabuf, &packet -> raw -> ciaddr, 4);
|
||||
+ cip.len = 4;
|
||||
+ if (!find_grouped_subnet(&subnet, packet->interface->shared_network, cip, MDL))
|
||||
+ norelay = 2;
|
||||
+ }
|
||||
+
|
||||
+ if (!norelay) {
|
||||
+ shared_network_reference(&packet -> shared_network, packet -> interface -> shared_network, MDL);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ return 0;
|
||||
}
|
||||
- return 0;
|
||||
}
|
||||
|
||||
/* If there's an SSO, and it's valid, use it to figure out the
|
||||
@@ -3853,7 +3866,10 @@
|
||||
data_string_forget (&data, MDL);
|
||||
} else {
|
||||
ia.len = 4;
|
||||
- memcpy (ia.iabuf, &packet -> raw -> giaddr, 4);
|
||||
+ if (norelay)
|
||||
+ memcpy (ia.iabuf, &packet->raw->ciaddr, 4);
|
||||
+ else
|
||||
+ memcpy (ia.iabuf, &packet->raw->giaddr, 4);
|
||||
}
|
||||
|
||||
/* If we know the subnet on which the IP address lives, use it. */
|
||||
@@ -3861,7 +3877,10 @@
|
||||
shared_network_reference (&packet -> shared_network,
|
||||
subnet -> shared_network, MDL);
|
||||
subnet_dereference (&subnet, MDL);
|
||||
- return 1;
|
||||
+ if (norelay)
|
||||
+ return norelay;
|
||||
+ else
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
/* Otherwise, fail. */
|
@ -1,37 +0,0 @@
|
||||
diff -up dhcp-3.0.6/minires/ns_name.c.memory dhcp-3.0.6/minires/ns_name.c
|
||||
--- dhcp-3.0.6/minires/ns_name.c.memory 2004-06-10 13:59:40.000000000 -0400
|
||||
+++ dhcp-3.0.6/minires/ns_name.c 2007-07-10 11:43:29.000000000 -0400
|
||||
@@ -71,6 +71,11 @@ ns_name_ntop(const u_char *src, char *ds
|
||||
dn = dst;
|
||||
eom = dst + dstsiz;
|
||||
|
||||
+ if (dn >= eom) {
|
||||
+ errno = EMSGSIZE;
|
||||
+ return (-1);
|
||||
+ }
|
||||
+
|
||||
while ((n = *cp++) != 0) {
|
||||
if ((n & NS_CMPRSFLGS) != 0) {
|
||||
/* Some kind of compression pointer. */
|
||||
diff -up dhcp-3.0.6/common/packet.c.memory dhcp-3.0.6/common/packet.c
|
||||
--- dhcp-3.0.6/common/packet.c.memory 2007-05-01 16:42:55.000000000 -0400
|
||||
+++ dhcp-3.0.6/common/packet.c 2007-07-10 11:43:29.000000000 -0400
|
||||
@@ -140,6 +140,7 @@ void assemble_udp_ip_header (interface,
|
||||
struct ip ip;
|
||||
struct udphdr udp;
|
||||
|
||||
+ memset( &ip, '\0', sizeof ip);
|
||||
/* Fill out the IP header */
|
||||
IP_V_SET (&ip, 4);
|
||||
IP_HL_SET (&ip, 20);
|
||||
diff -up dhcp-3.0.6/common/lpf.c.memory dhcp-3.0.6/common/lpf.c
|
||||
--- dhcp-3.0.6/common/lpf.c.memory 2007-07-10 11:43:29.000000000 -0400
|
||||
+++ dhcp-3.0.6/common/lpf.c 2007-07-10 11:43:29.000000000 -0400
|
||||
@@ -246,6 +246,7 @@ static void lpf_tr_filter_setup (info)
|
||||
struct interface_info *info;
|
||||
{
|
||||
struct sock_fprog p;
|
||||
+ memset(&p,'\0', sizeof(struct sock_fprog));
|
||||
|
||||
/* Set up the bpf filter program structure. This is defined in
|
||||
bpf.c */
|
@ -1,34 +0,0 @@
|
||||
diff -up dhcp-4.0.0/client/clparse.c.dho dhcp-4.0.0/client/clparse.c
|
||||
--- dhcp-4.0.0/client/clparse.c.dho 2007-12-29 06:32:16.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/clparse.c 2007-12-29 06:35:41.000000000 -1000
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
struct client_config top_level_config;
|
||||
|
||||
-#define NUM_DEFAULT_REQUESTED_OPTS 9
|
||||
+#define NUM_DEFAULT_REQUESTED_OPTS 12
|
||||
struct option *default_requested_options[NUM_DEFAULT_REQUESTED_OPTS + 1];
|
||||
|
||||
static void parse_client_default_duid(struct parse *cfile);
|
||||
@@ -107,6 +107,21 @@ isc_result_t read_client_conf ()
|
||||
option_code_hash_lookup(&default_requested_options[8],
|
||||
dhcpv6_universe.code_hash, &code, 0, MDL);
|
||||
|
||||
+ /* 10 */
|
||||
+ code = DHO_NIS_DOMAIN;
|
||||
+ option_code_hash_lookup(&default_requested_options[9],
|
||||
+ dhcp_universe.code_hash, &code, 0, MDL);
|
||||
+
|
||||
+ /* 11 */
|
||||
+ code = DHO_NIS_SERVERS;
|
||||
+ option_code_hash_lookup(&default_requested_options[10],
|
||||
+ dhcp_universe.code_hash, &code, 0, MDL);
|
||||
+
|
||||
+ /* 12 */
|
||||
+ code = DHO_NTP_SERVERS;
|
||||
+ option_code_hash_lookup(&default_requested_options[11],
|
||||
+ dhcp_universe.code_hash, &code, 0, MDL);
|
||||
+
|
||||
for (code = 0 ; code < NUM_DEFAULT_REQUESTED_OPTS ; code++) {
|
||||
if (default_requested_options[code] == NULL)
|
||||
log_fatal("Unable to find option definition for "
|
@ -1,70 +0,0 @@
|
||||
diff -up dhcp-4.0.0/common/lpf.c.anycast dhcp-4.0.0/common/lpf.c
|
||||
--- dhcp-4.0.0/common/lpf.c.anycast 2007-12-29 06:44:46.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/lpf.c 2007-12-29 10:40:11.000000000 -1000
|
||||
@@ -331,6 +331,9 @@ ssize_t send_packet (interface, packet,
|
||||
return send_fallback (interface, packet, raw,
|
||||
len, from, to, hto);
|
||||
|
||||
+ if (hto == NULL && interface->anycast_mac_addr.hlen)
|
||||
+ hto = &interface->anycast_mac_addr;
|
||||
+
|
||||
/* Assemble the headers... */
|
||||
assemble_hw_header (interface, (unsigned char *)hh, &hbufp, hto);
|
||||
fudge = hbufp % 4; /* IP header must be word-aligned. */
|
||||
diff -up dhcp-4.0.0/common/conflex.c.anycast dhcp-4.0.0/common/conflex.c
|
||||
--- dhcp-4.0.0/common/conflex.c.anycast 2007-12-29 06:44:46.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/conflex.c 2007-12-29 10:39:30.000000000 -1000
|
||||
@@ -715,6 +715,8 @@ intern(char *atom, enum dhcp_token dfv)
|
||||
}
|
||||
if (!strcasecmp (atom + 1, "nd"))
|
||||
return AND;
|
||||
+ if (!strcasecmp (atom + 1, "nycast-mac"))
|
||||
+ return ANYCAST_MAC;
|
||||
if (!strcasecmp (atom + 1, "ppend"))
|
||||
return APPEND;
|
||||
if (!strcasecmp (atom + 1, "llow"))
|
||||
diff -up dhcp-4.0.0/includes/dhcpd.h.anycast dhcp-4.0.0/includes/dhcpd.h
|
||||
--- dhcp-4.0.0/includes/dhcpd.h.anycast 2007-12-29 06:44:46.000000000 -1000
|
||||
+++ dhcp-4.0.0/includes/dhcpd.h 2007-12-29 10:42:56.000000000 -1000
|
||||
@@ -1188,6 +1188,7 @@ struct interface_info {
|
||||
int dlpi_sap_length;
|
||||
struct hardware dlpi_broadcast_addr;
|
||||
# endif /* DLPI_SEND || DLPI_RECEIVE */
|
||||
+ struct hardware anycast_mac_addr;
|
||||
};
|
||||
|
||||
struct hardware_link {
|
||||
diff -up dhcp-4.0.0/includes/dhctoken.h.anycast dhcp-4.0.0/includes/dhctoken.h
|
||||
--- dhcp-4.0.0/includes/dhctoken.h.anycast 2007-12-29 06:44:46.000000000 -1000
|
||||
+++ dhcp-4.0.0/includes/dhctoken.h 2007-12-29 10:44:00.000000000 -1000
|
||||
@@ -346,7 +346,8 @@ enum dhcp_token {
|
||||
WHITESPACE = 649,
|
||||
TOKEN_ALSO = 650,
|
||||
AFTER = 651,
|
||||
- BOOTP_BROADCAST_ALWAYS = 652
|
||||
+ BOOTP_BROADCAST_ALWAYS = 652,
|
||||
+ ANYCAST_MAC = 653
|
||||
};
|
||||
|
||||
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|
||||
diff -up dhcp-4.0.0/client/clparse.c.anycast dhcp-4.0.0/client/clparse.c
|
||||
--- dhcp-4.0.0/client/clparse.c.anycast 2007-12-29 06:44:46.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/clparse.c 2007-12-29 10:38:55.000000000 -1000
|
||||
@@ -550,6 +550,17 @@ void parse_client_statement (cfile, ip,
|
||||
}
|
||||
return;
|
||||
|
||||
+ case ANYCAST_MAC:
|
||||
+ token = next_token (&val, (unsigned *)0, cfile);
|
||||
+ if (ip) {
|
||||
+ parse_hardware_param (cfile, &ip -> anycast_mac_addr);
|
||||
+ } else {
|
||||
+ parse_warn (cfile, "anycast mac address parameter %s",
|
||||
+ "not allowed here.");
|
||||
+ skip_to_semi (cfile);
|
||||
+ }
|
||||
+ return;
|
||||
+
|
||||
case REQUEST:
|
||||
token = next_token (&val, (unsigned *)0, cfile);
|
||||
if (config -> requested_options == default_requested_options)
|
@ -1,43 +0,0 @@
|
||||
diff -up dhcp-4.0.0/client/dhclient.c.usage dhcp-4.0.0/client/dhclient.c
|
||||
--- dhcp-4.0.0/client/dhclient.c.usage 2007-12-31 18:05:29.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/dhclient.c 2007-12-31 18:05:43.000000000 -1000
|
||||
@@ -893,21 +893,30 @@ main(int argc, char **argv) {
|
||||
|
||||
static void usage ()
|
||||
{
|
||||
- log_info ("%s %s", message, PACKAGE_VERSION);
|
||||
- log_info (copyright);
|
||||
- log_info (arr);
|
||||
- log_info (url);
|
||||
+ printf ("%s %s", message, PACKAGE_VERSION);
|
||||
+ printf (copyright);
|
||||
+ printf ("\n");
|
||||
+ printf (arr);
|
||||
+ printf ("\n");
|
||||
+ printf (url);
|
||||
+ printf ("\n");
|
||||
|
||||
- log_error ("Usage: dhclient %s %s",
|
||||
+ printf ("Usage: dhclient %s %s",
|
||||
#ifdef DHCPv6
|
||||
"[-4|-6] [-1dvrx] [-nw] [-p <port>]",
|
||||
#else /* DHCPv6 */
|
||||
"[-1dvrx] [-nw] [-p <port>]",
|
||||
#endif /* DHCPv6 */
|
||||
- "[-s server]");
|
||||
- log_error (" [-cf config-file] [-lf lease-file]%s",
|
||||
- "[-pf pid-file] [-e VAR=val]");
|
||||
- log_fatal (" [-sf script-file] [interface]");
|
||||
+ "[-s server]\n");
|
||||
+ printf (" [-cf config-file] [-lf lease-file]%s",
|
||||
+ "[-pf pid-file] [-e VAR=val]\n");
|
||||
+ printf (" [ -I <dhcp-client-identifier> ] [-B]\n");
|
||||
+ printf (" [ -H <host-name> | -F <fqdn.fqdn> ] [ -T <timeout> ]\n");
|
||||
+ printf (" [ -V <vendor-class-identifier> ]\n");
|
||||
+ printf (" [ -R <request option list> ]\n");
|
||||
+ printf (" [-sf script-file] [interface]\n");
|
||||
+
|
||||
+ exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
isc_result_t find_class (struct class **c,
|
@ -1,15 +0,0 @@
|
||||
diff -up dhcp-4.0.0/client/dhclient.c.fast dhcp-4.0.0/client/dhclient.c
|
||||
--- dhcp-4.0.0/client/dhclient.c.fast 2007-12-29 06:07:14.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/dhclient.c 2007-12-29 06:08:07.000000000 -1000
|
||||
@@ -3624,10 +3624,7 @@ isc_result_t dhclient_interface_startup_
|
||||
ip -> flags |= INTERFACE_RUNNING;
|
||||
for (client = ip -> client; client; client = client -> next) {
|
||||
client -> state = S_INIT;
|
||||
- /* Set up a timeout to start the initialization
|
||||
- process. */
|
||||
- add_timeout (cur_time + random () % 5,
|
||||
- state_reboot, client, 0, 0);
|
||||
+ add_timeout (cur_time, state_reboot, client, 0, 0);
|
||||
}
|
||||
}
|
||||
return ISC_R_SUCCESS;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,533 +0,0 @@
|
||||
diff -up dhcp-4.0.0/server/dhcpd.conf.5.manpages dhcp-4.0.0/server/dhcpd.conf.5
|
||||
--- dhcp-4.0.0/server/dhcpd.conf.5.manpages 2007-11-20 08:34:37.000000000 -1000
|
||||
+++ dhcp-4.0.0/server/dhcpd.conf.5 2008-01-02 11:26:38.000000000 -1000
|
||||
@@ -513,6 +513,9 @@ pool {
|
||||
};
|
||||
.fi
|
||||
.PP
|
||||
+Dynamic BOOTP leases are not compatible with failover, and, as such,
|
||||
+you need to disallow BOOTP in pools that you are using failover for.
|
||||
+.PP
|
||||
The server currently does very little sanity checking, so if you
|
||||
configure it wrong, it will just fail in odd ways. I would recommend
|
||||
therefore that you either do failover or don't do failover, but don't
|
||||
@@ -527,9 +530,9 @@ primary server might look like this:
|
||||
failover peer "foo" {
|
||||
primary;
|
||||
address anthrax.rc.vix.com;
|
||||
- port 519;
|
||||
+ port 647;
|
||||
peer address trantor.rc.vix.com;
|
||||
- peer port 520;
|
||||
+ peer port 847;
|
||||
max-response-delay 60;
|
||||
max-unacked-updates 10;
|
||||
mclt 3600;
|
||||
@@ -588,9 +591,7 @@ statement
|
||||
.B port \fIport-number\fR\fB;\fR
|
||||
.PP
|
||||
The \fBport\fR statement declares the TCP port on which the server
|
||||
-should listen for connections from its failover peer. This statement
|
||||
-may not currently be omitted, because the failover protocol does not
|
||||
-yet have a reserved TCP port number.
|
||||
+should listen for connections from its failover peer.
|
||||
.RE
|
||||
.PP
|
||||
The
|
||||
@@ -602,10 +603,8 @@ statement
|
||||
.PP
|
||||
The \fBpeer port\fR statement declares the TCP port to which the
|
||||
server should connect to reach its failover peer for failover
|
||||
-messages. This statement may not be omitted because the failover
|
||||
-protocol does not yet have a reserved TCP port number. The port
|
||||
-number declared in the \fBpeer port\fR statement may be the same as
|
||||
-the port number declared in the \fBport\fR statement.
|
||||
+messages. The port number declared in the \fBpeer port\fR statement
|
||||
+may be the same as the port number declared in the \fBport\fR statement.
|
||||
.RE
|
||||
.PP
|
||||
The
|
||||
@@ -1272,7 +1271,7 @@ the zone containing PTR records - for IS
|
||||
.PP
|
||||
.nf
|
||||
key DHCP_UPDATER {
|
||||
- algorithm HMAC-MD5.SIG-ALG.REG.INT;
|
||||
+ algorithm hmac-md5;
|
||||
secret pRP5FapFoJ95JEL06sv4PQ==;
|
||||
};
|
||||
|
||||
@@ -1295,7 +1294,7 @@ dhcpd.conf file:
|
||||
.PP
|
||||
.nf
|
||||
key DHCP_UPDATER {
|
||||
- algorithm HMAC-MD5.SIG-ALG.REG.INT;
|
||||
+ algorithm hmac-md5;
|
||||
secret pRP5FapFoJ95JEL06sv4PQ==;
|
||||
};
|
||||
|
||||
@@ -2433,7 +2432,8 @@ statement
|
||||
The \fInext-server\fR statement is used to specify the host address of
|
||||
the server from which the initial boot file (specified in the
|
||||
\fIfilename\fR statement) is to be loaded. \fIServer-name\fR should
|
||||
-be a numeric IP address or a domain name.
|
||||
+be a numeric IP address or a domain name. If no \fInext-server\fR statement
|
||||
+applies to a given client, the address 0.0.0.0 is used.
|
||||
.RE
|
||||
.PP
|
||||
The
|
||||
diff -up dhcp-4.0.0/common/dhcp-options.5.manpages dhcp-4.0.0/common/dhcp-options.5
|
||||
--- dhcp-4.0.0/common/dhcp-options.5.manpages 2007-09-17 07:52:01.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/dhcp-options.5 2008-01-02 11:26:38.000000000 -1000
|
||||
@@ -896,6 +896,21 @@ classless IP routing - it does not inclu
|
||||
classless IP routing is now the most widely deployed routing standard,
|
||||
this option is virtually useless, and is not implemented by any of the
|
||||
popular DHCP clients, for example the Microsoft DHCP client.
|
||||
+.PP
|
||||
+NOTE to @PRODUCTNAME@ dhclient users:
|
||||
+.br
|
||||
+dhclient-script interprets trailing 0 octets of the target as indicating
|
||||
+the subnet class of the route, so for the following static-routes value:
|
||||
+.br
|
||||
+ option static-routes 172.0.0.0 172.16.2.254,
|
||||
+.br
|
||||
+ 192.168.0.0 192.168.2.254;
|
||||
+.br
|
||||
+dhclient-script will create routes:
|
||||
+.br
|
||||
+ 172/8 via 172.16.2.254 dev $interface
|
||||
+.br
|
||||
+ 192.168/16 via 192.168.2.254 dev $interface
|
||||
.RE
|
||||
.PP
|
||||
.nf
|
||||
diff -up dhcp-4.0.0/client/dhclient-script.8.manpages dhcp-4.0.0/client/dhclient-script.8
|
||||
--- dhcp-4.0.0/client/dhclient-script.8.manpages 2006-02-24 13:16:27.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/dhclient-script.8 2008-01-02 11:26:38.000000000 -1000
|
||||
@@ -47,7 +47,7 @@ customizations are needed, they should b
|
||||
exit hooks provided (see HOOKS for details). These hooks will allow the
|
||||
user to override the default behaviour of the client in creating a
|
||||
.B /etc/resolv.conf
|
||||
-file.
|
||||
+file, and to handle DHCP options not handled by default.
|
||||
.PP
|
||||
No standard client script exists for some operating systems, even though
|
||||
the actual client may work, so a pioneering user may well need to create
|
||||
@@ -91,6 +91,26 @@ present. The
|
||||
.B ETCDIR/dhclient-exit-hooks
|
||||
script can modify the valid of exit_status to change the exit status
|
||||
of dhclient-script.
|
||||
+.PP
|
||||
+Immediately after dhclient brings an interface UP with a new IP address,
|
||||
+subnet mask, and routes, in the REBOOT/BOUND states, it will check for the
|
||||
+existence of an executable
|
||||
+.B ETCDIR/dhclient-up-hooks
|
||||
+script, and source it if found. This script can handle DHCP options in
|
||||
+the environment that are not handled by default. A per-interface.
|
||||
+.B ETCDIR/dhclient-${IF}-up-hooks
|
||||
+script will override the generic script and be sourced when interface
|
||||
+$IF has been brought up.
|
||||
+.PP
|
||||
+Immediately before dhclient brings an interface DOWN, removing its IP
|
||||
+address, subnet mask, and routes, in the STOP/RELEASE states, it will
|
||||
+check for the existence of an executable
|
||||
+.B ETCDIR/dhclient-down-hooks
|
||||
+script, and source it if found. This script can handle DHCP options in
|
||||
+the environment that are not handled by default. A per-interface
|
||||
+.B ETCDIR/dhclient-${IF}-down-hooks
|
||||
+script will override the generic script and be sourced when interface
|
||||
+$IF is about to be brought down.
|
||||
.SH OPERATION
|
||||
When dhclient needs to invoke the client configuration script, it
|
||||
defines a set of variables in the environment, and then invokes
|
||||
diff -up dhcp-4.0.0/client/dhclient.conf.5.manpages dhcp-4.0.0/client/dhclient.conf.5
|
||||
--- dhcp-4.0.0/client/dhclient.conf.5.manpages 2007-08-23 06:06:08.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/dhclient.conf.5 2008-01-02 11:26:38.000000000 -1000
|
||||
@@ -186,9 +186,9 @@ responding to the client send the client
|
||||
options. Only the option names should be specified in the request
|
||||
statement - not option parameters. By default, the DHCP server
|
||||
requests the subnet-mask, broadcast-address, time-offset, routers,
|
||||
-domain-name, domain-name-servers and host-name options. Note that if
|
||||
-you enter a 'request' statement, you over-ride this default and these
|
||||
-options will not be requested.
|
||||
+domain-name, domain-name-servers host-name, nis-domain, nis-servers,
|
||||
+and ntp-servers options. Note that if you enter a 'request' statement,
|
||||
+you over-ride this default and these options will not be requested.
|
||||
.PP
|
||||
In some cases, it may be desirable to send no parameter request list
|
||||
at all. To do this, simply write the request statement but specify
|
||||
@@ -626,6 +626,18 @@ database and will record the media type
|
||||
Whenever the client tries to renew the lease, it will use that same
|
||||
media type. The lease must expire before the client will go back to
|
||||
cycling through media types.
|
||||
+.PP
|
||||
+ \fBbootp-broadcast-always;\fR
|
||||
+.PP
|
||||
+The
|
||||
+.B bootp-broadcast-always
|
||||
+statement instructs dhclient to always set the bootp broadcast flag in
|
||||
+request packets, so that servers will always broadcast replies.
|
||||
+This is equivalent to supplying the dhclient -B argument, and has
|
||||
+the same effect as specifying 'always-broadcast' in the server's dhcpd.conf.
|
||||
+This option is provided as an extension to enable dhclient to work
|
||||
+on IBM s390 Linux guests.
|
||||
+.PP
|
||||
.SH SAMPLE
|
||||
The following configuration file is used on a laptop running NetBSD
|
||||
1.3. The laptop has an IP alias of 192.5.5.213, and has one
|
||||
diff -up dhcp-4.0.0/client/dhclient.8.manpages dhcp-4.0.0/client/dhclient.8
|
||||
--- dhcp-4.0.0/client/dhclient.8.manpages 2007-10-04 07:13:25.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/dhclient.8 2008-01-02 11:26:38.000000000 -1000
|
||||
@@ -91,6 +91,33 @@ relay
|
||||
.B -w
|
||||
]
|
||||
[
|
||||
+.B -B
|
||||
+]
|
||||
+[
|
||||
+.B -I
|
||||
+.I dhcp-client-identifier
|
||||
+]
|
||||
+[
|
||||
+.B -H
|
||||
+.I host-name
|
||||
+]
|
||||
+[
|
||||
+.B -F
|
||||
+.I fqdn.fqdn
|
||||
+]
|
||||
+[
|
||||
+.B -V
|
||||
+.I vendor-class-identifier
|
||||
+]
|
||||
+[
|
||||
+.B -R
|
||||
+.I request-option-list
|
||||
+]
|
||||
+[
|
||||
+.B -T
|
||||
+.I timeout
|
||||
+]
|
||||
+[
|
||||
.B -v
|
||||
]
|
||||
[
|
||||
@@ -118,16 +145,6 @@ important details about the network to w
|
||||
the location of a default router, the location of a name server, and
|
||||
so on.
|
||||
.PP
|
||||
-If given the -4 command line argument (default), dhclient will use the
|
||||
-DHCPv4 protocol to obtain an IPv4 address and configuration parameters.
|
||||
-.PP
|
||||
-If given the -6 command line argument, dhclient will use the DHCPv6
|
||||
-protocol to obtain whatever IPv6 addresses are available along with
|
||||
-configuration parameters. Information-request is not yet supported.
|
||||
-.PP
|
||||
-If given the --version command line argument, dhclient will print its
|
||||
-version number and exit.
|
||||
-.PP
|
||||
On startup, dhclient reads the
|
||||
.IR dhclient.conf
|
||||
for configuration instructions. It then gets a list of all the
|
||||
@@ -181,67 +198,183 @@ file. If interfaces are specified in t
|
||||
only configure interfaces that are either specified in the
|
||||
configuration file or on the command line, and will ignore all other
|
||||
interfaces.
|
||||
-.PP
|
||||
-If the DHCP client should listen and transmit on a port other than the
|
||||
-standard (port 68), the
|
||||
-.B -p
|
||||
-flag may used. It should be followed by the udp port number that
|
||||
-dhclient should use. This is mostly useful for debugging purposes.
|
||||
-If a different port is specified for the client to listen on and
|
||||
-transmit on, the client will also use a different destination port -
|
||||
-one greater than the specified destination port.
|
||||
-.PP
|
||||
-The DHCP client normally transmits any protocol messages it sends
|
||||
-before acquiring an IP address to, 255.255.255.255, the IP limited
|
||||
-broadcast address. For debugging purposes, it may be useful to have
|
||||
-the server transmit these messages to some other address. This can
|
||||
-be specified with the
|
||||
-.B -s
|
||||
-flag, followed by the IP address or domain name of the destination.
|
||||
-.PP
|
||||
-For testing purposes, the giaddr field of all packets that the client
|
||||
-sends can be set using the
|
||||
-.B -g
|
||||
-flag, followed by the IP address to send. This is only useful for testing,
|
||||
-and should not be expected to work in any consistent or useful way.
|
||||
-.PP
|
||||
-The DHCP client will normally run in the foreground until it has
|
||||
-configured an interface, and then will revert to running in the
|
||||
-background. To run force dhclient to always run as a foreground
|
||||
-process, the
|
||||
-.B -d
|
||||
-flag should be specified. This is useful when running the client
|
||||
-under a debugger, or when running it out of inittab on System V
|
||||
-systems.
|
||||
-.PP
|
||||
-The dhclient daemon creates its own environment when executing the
|
||||
-dhclient-script to do the grunt work of interface configuration.
|
||||
-To define extra environment variables and their values, use the
|
||||
-.B -e
|
||||
-flag, followed by the environment variable name and value assignment,
|
||||
-just as one would assign a variable in a shell. Eg:
|
||||
-.B -e
|
||||
-.I IF_METRIC=1
|
||||
-.PP
|
||||
-The client normally prints no output during its startup sequence. It
|
||||
-can be made to emit verbose messages displaying the startup sequence events
|
||||
-until it has acquired an address by supplying the
|
||||
-.B -v
|
||||
-command line argument. In either case, the client logs messages using
|
||||
-the
|
||||
-.B syslog (3)
|
||||
-facility. A
|
||||
-.B -q
|
||||
-command line argument is provided for backwards compatibility, but since
|
||||
-dhclient is quiet by default, it has no effect.
|
||||
-.PP
|
||||
-The client normally doesn't release the current lease as it is not
|
||||
-required by the DHCP protocol. Some cable ISPs require their clients
|
||||
-to notify the server if they wish to release an assigned IP address.
|
||||
+.SH OPTIONS
|
||||
+.TP
|
||||
+.BI \-4
|
||||
+Use the DHCPv4 protocol to obtain an IPv4 address and configuration
|
||||
+parameters.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-6
|
||||
+Use the DHCPv6 protocol to obtain whatever IPv6 addresses are available
|
||||
+along with configuration parameters. Information-request is not yet
|
||||
+supported.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-p\ <port\ number>
|
||||
+The UDP port number the DHCP client should listen and transmit on. If
|
||||
+unspecified,
|
||||
+.B dhclient
|
||||
+uses the default port 68. This option is mostly useful for debugging
|
||||
+purposes. If a different port is specified for the client to listen and
|
||||
+transmit on, the client will also use a different destination port - one
|
||||
+greater than the specified destination port.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-d
|
||||
+Force
|
||||
+.B dhclient
|
||||
+to run as a foreground process. This is useful when running the client
|
||||
+under a debugger, or when running it out of inittab on System V systems.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-e\ VAR=value
|
||||
+Define additional environment variables for the environment where
|
||||
+dhclient-script executes. You may specify multiple
|
||||
+.B \-e
|
||||
+options on the command line.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-q
|
||||
+Suppress all terminal and log output except error messages.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-1
|
||||
+Try one to get a lease. On failure, exit with code 2.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-r
|
||||
+Tell
|
||||
+.B dhclient
|
||||
+to release the current lease it has from the server. This is not required
|
||||
+by the DHCP protocol, but some ISPs require their clients to notify the
|
||||
+server if they wish to release an assigned IP address.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-lf\ <lease-file>
|
||||
+Path to the lease database file. If unspecified, the default
|
||||
+.B DBDIR/dhclient.leases
|
||||
+is used.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-pf\ <pid-file>
|
||||
+Path to the process ID file. If unspecified, the default
|
||||
+.B RUNDIR/dhclient.pid
|
||||
+is used.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-cf\ <config-file>
|
||||
+Path to the client configuration file. If unspecified, the default
|
||||
+.B ETCDIR/dhclient.conf
|
||||
+is used.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-sf\ <script-file>
|
||||
+Path to the network configuration script invoked by
|
||||
+.B dhclient
|
||||
+when it gets a lease. If unspecified, the default
|
||||
+.B CLIENTBINDIR/dhclient-script
|
||||
+is used.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-s\ <server>
|
||||
+Specifiy the server IP address or fully qualified domain name to transmit
|
||||
+DHCP protocol messages to. Normally,
|
||||
+.B dhclient
|
||||
+transmits these messages to 255.255.255.255 (the IP limited broadcast
|
||||
+address). Overriding this is mostly useful for debugging purposes.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-g\ <relay>
|
||||
+Only for debugging. Set the giaddr field of all packets the client
|
||||
+sends to the IP address specified. This should not be expected to work
|
||||
+in any consistent or useful way.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-n
|
||||
+Do not configure any interfaces. Most useful combined with the
|
||||
+.B -w
|
||||
+option.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-nw
|
||||
+Become a daemon process immediately (nowait) rather than waiting until an IP
|
||||
+address has been acquired.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-w
|
||||
+Keep running even if no network interfaces are found. The
|
||||
+.B omshell
|
||||
+program can be used to notify the client when a network interface has been
|
||||
+added or removed so it can attempt to configure an IP address on that
|
||||
+interface.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-B
|
||||
+Set the BOOTP broadcast flag in request packets so servers will always
|
||||
+broadcast replies.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-I\ <dhcp-client-identifier>
|
||||
+Specify the dhcp-client-identifier option to send to the DHCP server.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-H\ <host-name>
|
||||
+Specify the host-name option to send to the DHCP server. The host-name
|
||||
+string only contains the client's hostname prefix, to which the server will
|
||||
+append the ddns-domainname or domain-name options, if any, to derive the
|
||||
+fully qualified domain name of the client. The
|
||||
+.B -H
|
||||
+option cannot be used with the
|
||||
+.B -F
|
||||
+option.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-F\ <fqdn.fqdn>
|
||||
+Specify the fqdn.fqdn option to send to the DHCP server. This option cannot
|
||||
+be used with the
|
||||
+.B -H
|
||||
+option. The fqdn.fqdn option must specify the complete domain name of the
|
||||
+client host, which the server may use for dynamic DNS updates.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-V\ <vendor-class-identifier>
|
||||
+Specify the vendor-class-identifier option to send to the DHCP server.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-R\ <option>[,<option>...]
|
||||
+Specify the list of options the client is to request from the server. The
|
||||
+option list must be a single string consisting of option names separated
|
||||
+by at least one command and optional space characters. The default option
|
||||
+list is:
|
||||
+
|
||||
+.BR
|
||||
+ subnet-mask, broadcast-address, time-offset, routers,
|
||||
+.BR
|
||||
+ domain-name, domain-name-servers, host-name, nis-domain,
|
||||
+.BR
|
||||
+ nis-servers, ntp-servers
|
||||
+
|
||||
The
|
||||
-.B -r
|
||||
-flag explicitly releases the current lease, and once the lease has been
|
||||
-released, the client exits.
|
||||
+.B -R
|
||||
+option does not append options to the default request, it overrides the
|
||||
+default request list. Keep this in mind if you want to request an
|
||||
+additional option besides the default request list. You will have to
|
||||
+specify all option names for the
|
||||
+.B -R
|
||||
+parameter.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-T\ <timeout>
|
||||
+Specify the time after which
|
||||
+.B dhclient
|
||||
+will decide that no DHCP servers can be contacted when no responses have been
|
||||
+received.
|
||||
+
|
||||
+.TP
|
||||
+.BI \-v
|
||||
+Enable verbose log messages.
|
||||
+
|
||||
.PP
|
||||
If the client is killed by a signal (for example at shutdown or reboot)
|
||||
it won't execute the
|
||||
@@ -253,57 +386,7 @@ or
|
||||
it will execute
|
||||
.B dhclient-script (8)
|
||||
at shutdown with the specific reason for calling the script set.
|
||||
-.PP
|
||||
-The
|
||||
-.B -1
|
||||
-flag will cause dhclient to try once to get a lease. If it fails, dhclient
|
||||
-exits with exit code two.
|
||||
-.PP
|
||||
-The DHCP client normally gets its configuration information from
|
||||
-.B ETCDIR/dhclient.conf,
|
||||
-its lease database from
|
||||
-.B DBDIR/dhclient.leases,
|
||||
-stores its process ID in a file called
|
||||
-.B RUNDIR/dhclient.pid,
|
||||
-and configures the network interface using
|
||||
-.B CLIENTBINDIR/dhclient-script
|
||||
-To specify different names and/or locations for these files, use the
|
||||
-.B -cf,
|
||||
-.B -lf,
|
||||
-.B -pf
|
||||
-and
|
||||
-.B -sf
|
||||
-flags, respectively, followed by the name of the file. This can be
|
||||
-particularly useful if, for example,
|
||||
-.B DBDIR
|
||||
-or
|
||||
-.B RUNDIR
|
||||
-has not yet been mounted when the DHCP client is started.
|
||||
-.PP
|
||||
-The DHCP client normally exits if it isn't able to identify any
|
||||
-network interfaces to configure. On laptop computers and other
|
||||
-computers with hot-swappable I/O buses, it is possible that a
|
||||
-broadcast interface may be added after system startup. The
|
||||
-.B -w
|
||||
-flag can be used to cause the client not to exit when it doesn't find
|
||||
-any such interfaces. The
|
||||
-.B omshell (1)
|
||||
-program can then be used to notify the client when a network interface
|
||||
-has been added or removed, so that the client can attempt to configure an IP
|
||||
-address on that interface.
|
||||
-.PP
|
||||
-The DHCP client can be directed not to attempt to configure any interfaces
|
||||
-using the
|
||||
-.B -n
|
||||
-flag. This is most likely to be useful in combination with the
|
||||
-.B -w
|
||||
-flag.
|
||||
-.PP
|
||||
-The client can also be instructed to become a daemon immediately, rather
|
||||
-than waiting until it has acquired an IP address. This can be done by
|
||||
-supplying the
|
||||
-.B -nw
|
||||
-flag.
|
||||
+
|
||||
.SH CONFIGURATION
|
||||
The syntax of the dhclient.conf(5) file is discussed separately.
|
||||
.SH OMAPI
|
@ -1,401 +0,0 @@
|
||||
diff -up dhcp-4.0.0/common/conflex.c.options dhcp-4.0.0/common/conflex.c
|
||||
--- dhcp-4.0.0/common/conflex.c.options 2007-12-29 11:13:51.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/conflex.c 2007-12-29 11:13:51.000000000 -1000
|
||||
@@ -769,6 +769,8 @@ intern(char *atom, enum dhcp_token dfv)
|
||||
return BALANCE;
|
||||
if (!strcasecmp (atom + 1, "ound"))
|
||||
return BOUND;
|
||||
+ if (!strcasecmp (atom + 1, "ootp-broadcast-always"))
|
||||
+ return BOOTP_BROADCAST_ALWAYS;
|
||||
break;
|
||||
case 'c':
|
||||
if (!strcasecmp (atom + 1, "ase"))
|
||||
diff -up dhcp-4.0.0/includes/dhcpd.h.options dhcp-4.0.0/includes/dhcpd.h
|
||||
--- dhcp-4.0.0/includes/dhcpd.h.options 2007-12-29 11:13:51.000000000 -1000
|
||||
+++ dhcp-4.0.0/includes/dhcpd.h 2007-12-29 11:13:51.000000000 -1000
|
||||
@@ -1055,6 +1055,9 @@ struct client_config {
|
||||
int do_forward_update; /* If nonzero, and if we have the
|
||||
information we need, update the
|
||||
A record for the address we get. */
|
||||
+
|
||||
+ int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST
|
||||
+ flag in requests */
|
||||
};
|
||||
|
||||
/* Per-interface state used in the dhcp client... */
|
||||
diff -up dhcp-4.0.0/includes/dhctoken.h.options dhcp-4.0.0/includes/dhctoken.h
|
||||
--- dhcp-4.0.0/includes/dhctoken.h.options 2007-10-31 09:13:33.000000000 -1000
|
||||
+++ dhcp-4.0.0/includes/dhctoken.h 2007-12-29 11:13:51.000000000 -1000
|
||||
@@ -345,7 +345,8 @@ enum dhcp_token {
|
||||
RANGE6 = 648,
|
||||
WHITESPACE = 649,
|
||||
TOKEN_ALSO = 650,
|
||||
- AFTER = 651
|
||||
+ AFTER = 651,
|
||||
+ BOOTP_BROADCAST_ALWAYS = 652
|
||||
};
|
||||
|
||||
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|
||||
diff -up dhcp-4.0.0/client/dhclient.c.options dhcp-4.0.0/client/dhclient.c
|
||||
--- dhcp-4.0.0/client/dhclient.c.options 2007-11-30 11:51:42.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/dhclient.c 2007-12-29 11:14:15.000000000 -1000
|
||||
@@ -37,6 +37,12 @@
|
||||
#include <sys/wait.h>
|
||||
#include <limits.h>
|
||||
|
||||
+/*
|
||||
+ * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define
|
||||
+ * that when building ISC code.
|
||||
+ */
|
||||
+extern int asprintf(char **strp, const char *fmt, ...);
|
||||
+
|
||||
TIME default_lease_time = 43200; /* 12 hours... */
|
||||
TIME max_lease_time = 86400; /* 24 hours... */
|
||||
|
||||
@@ -75,6 +81,9 @@ int onetry=0;
|
||||
int quiet=1;
|
||||
int nowait=0;
|
||||
char *mockup_relay = NULL;
|
||||
+int bootp_broadcast_always = 0;
|
||||
+
|
||||
+extern u_int32_t default_requested_options[];
|
||||
|
||||
static void usage PROTO ((void));
|
||||
|
||||
@@ -100,6 +109,15 @@ main(int argc, char **argv) {
|
||||
int no_dhclient_script = 0;
|
||||
int local_family_set = 0;
|
||||
char *s;
|
||||
+ char *dhcp_client_identifier_arg = NULL;
|
||||
+ char *dhcp_host_name_arg = NULL;
|
||||
+ char *dhcp_fqdn_arg = NULL;
|
||||
+ char *dhcp_vendor_class_identifier_arg = NULL;
|
||||
+ char *dhclient_request_options = NULL;
|
||||
+
|
||||
+ int timeout_arg = 0;
|
||||
+ char *arg_conf = NULL;
|
||||
+ int arg_conf_len = 0;
|
||||
|
||||
/* Initialize client globals. */
|
||||
memset(&default_duid, 0, sizeof(default_duid));
|
||||
@@ -224,6 +242,88 @@ main(int argc, char **argv) {
|
||||
} else if (!strcmp (argv [i], "--version")) {
|
||||
log_info ("isc-dhclient-%s", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
+ } else if (!strcmp (argv [i], "-I")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
|
||||
+ log_error("-I option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ dhcp_client_identifier_arg = argv[i];
|
||||
+ } else if (!strcmp (argv [i], "-B")) {
|
||||
+ bootp_broadcast_always = 1;
|
||||
+ } else if (!strcmp (argv [i], "-H")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
|
||||
+ log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ if (dhcp_host_name_arg != NULL) {
|
||||
+ log_error("The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ dhcp_host_name_arg = argv[i];
|
||||
+ } else if (!strcmp (argv [i], "-F")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
|
||||
+ log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ if (dhcp_fqdn_arg != NULL) {
|
||||
+ log_error("Only one -F <fqdn> argument can be specified");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ if (dhcp_host_name_arg != NULL) {
|
||||
+ log_error("The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ dhcp_fqdn_arg = argv[i];
|
||||
+ } else if (!strcmp (argv [i], "-T")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if ((timeout_arg = atoi(argv[i])) <= 0) {
|
||||
+ log_error("-T timeout option must be > 0 - bad value: %s",argv[i]);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ } else if (!strcmp (argv [i], "-V")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
|
||||
+ log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ dhcp_vendor_class_identifier_arg = argv[i];
|
||||
+ } else if (!strcmp (argv [i], "-R")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ dhclient_request_options=argv[i];
|
||||
} else if (argv [i][0] == '-') {
|
||||
usage ();
|
||||
} else {
|
||||
@@ -370,6 +470,166 @@ main(int argc, char **argv) {
|
||||
/* Parse the dhclient.conf file. */
|
||||
read_client_conf ();
|
||||
|
||||
+ /* Parse any extra command line configuration arguments: */
|
||||
+ if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -I option dhcp-client-identifier");
|
||||
+ }
|
||||
+
|
||||
+ if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -H option host-name");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf( &arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -H option host-name");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -F option fqdn.fqdn");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf( &arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -F option fqdn.fqdn");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (timeout_arg) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "timeout %d;", timeout_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to process -T timeout argument");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf( &arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len == 0))
|
||||
+ log_fatal("Unable to process -T timeout argument");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -V option vendor-class-identifier");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -V option vendor-class-identifier");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (dhclient_request_options != NULL) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "request %s;", dhclient_request_options);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to parse -R <request options list> argument");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to parse -R <request options list> argument");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (arg_conf) {
|
||||
+ if (arg_conf_len == 0)
|
||||
+ if ((arg_conf_len = strlen(arg_conf)) == 0)
|
||||
+ /* huh ? cannot happen ! */
|
||||
+ log_fatal("Unable to process -I/-H/-F/-T/-V/-R configuration arguments");
|
||||
+
|
||||
+ /* parse the extra dhclient.conf configuration arguments
|
||||
+ * into top level config: */
|
||||
+ struct parse *cfile = (struct parse *)0;
|
||||
+ const char *val = NULL;
|
||||
+ int token;
|
||||
+
|
||||
+ status = new_parse (&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -I/-H/-F/-T/-V/-R configuration arguments", 0);
|
||||
+
|
||||
+ if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred))
|
||||
+ log_fatal("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !");
|
||||
+ /* more detailed parse failures will be logged */
|
||||
+
|
||||
+ do {
|
||||
+ token = peek_token (&val, (unsigned *)0, cfile);
|
||||
+ if (token == END_OF_FILE)
|
||||
+ break;
|
||||
+
|
||||
+ parse_client_statement (cfile, (struct interface_info *)0, &top_level_config);
|
||||
+ } while (1);
|
||||
+
|
||||
+ if (cfile -> warnings_occurred)
|
||||
+ log_fatal ("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !");
|
||||
+ end_parse (&cfile);
|
||||
+
|
||||
+ if (timeout_arg) {
|
||||
+ /* we just set the toplevel timeout, but per-client
|
||||
+ * timeouts may still be at defaults. Also, it makes no
|
||||
+ * sense having the reboot_timeout or backoff_cutoff
|
||||
+ * greater than the timeout:
|
||||
+ */
|
||||
+ if ((top_level_config.backoff_cutoff == 15) && (top_level_config.backoff_cutoff > (timeout_arg / 2)))
|
||||
+ top_level_config.backoff_cutoff = (((unsigned long)(timeout_arg / 2)) == 0) ? timeout_arg : (unsigned long)(timeout_arg / 2);
|
||||
+
|
||||
+ for (ip = interfaces; ip; ip = ip -> next) {
|
||||
+ if (ip->client->config->timeout == 60)
|
||||
+ ip->client->config->timeout = timeout_arg;
|
||||
+
|
||||
+ if ((ip->client->config->reboot_timeout == 10) && (ip->client->config->reboot_timeout > ip->client->config->timeout))
|
||||
+ ip->client->config->reboot_timeout = ip->client->config->timeout;
|
||||
+ if ((ip->client->config->backoff_cutoff == 15) && (ip->client->config->backoff_cutoff > top_level_config.backoff_cutoff))
|
||||
+ ip->client->config->backoff_cutoff = top_level_config.backoff_cutoff;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) {
|
||||
+ for (ip = interfaces; ip; ip = ip -> next) {
|
||||
+ if (ip->client->config->requested_options == default_requested_options)
|
||||
+ ip->client->config->requested_options = top_level_config.requested_options;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ free(arg_conf);
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = 0;
|
||||
+ }
|
||||
+
|
||||
/* Parse the lease database. */
|
||||
read_client_leases ();
|
||||
|
||||
@@ -2105,7 +2365,8 @@ void make_discover (client, lease)
|
||||
client -> packet.xid = random ();
|
||||
client -> packet.secs = 0; /* filled in by send_discover. */
|
||||
|
||||
- if (can_receive_unicast_unconfigured (client -> interface))
|
||||
+ if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always))
|
||||
+ && can_receive_unicast_unconfigured(client->interface))
|
||||
client -> packet.flags = 0;
|
||||
else
|
||||
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||||
@@ -2189,7 +2450,9 @@ void make_request (client, lease)
|
||||
} else {
|
||||
memset (&client -> packet.ciaddr, 0,
|
||||
sizeof client -> packet.ciaddr);
|
||||
- if (can_receive_unicast_unconfigured (client -> interface))
|
||||
+ if ((!(bootp_broadcast_always ||
|
||||
+ client ->config->bootp_broadcast_always)) &&
|
||||
+ can_receive_unicast_unconfigured (client -> interface))
|
||||
client -> packet.flags = 0;
|
||||
else
|
||||
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||||
@@ -2248,7 +2511,8 @@ void make_decline (client, lease)
|
||||
client -> packet.hops = 0;
|
||||
client -> packet.xid = client -> xid;
|
||||
client -> packet.secs = 0; /* Filled in by send_request. */
|
||||
- if (can_receive_unicast_unconfigured (client -> interface))
|
||||
+ if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always))
|
||||
+ && can_receive_unicast_unconfigured (client->interface))
|
||||
client -> packet.flags = 0;
|
||||
else
|
||||
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||||
diff -up dhcp-4.0.0/client/clparse.c.options dhcp-4.0.0/client/clparse.c
|
||||
--- dhcp-4.0.0/client/clparse.c.options 2007-12-08 09:36:00.000000000 -1000
|
||||
+++ dhcp-4.0.0/client/clparse.c 2007-12-29 11:13:51.000000000 -1000
|
||||
@@ -132,6 +132,7 @@ isc_result_t read_client_conf ()
|
||||
/* Requested lease time, used by DHCPv6 (DHCPv4 uses the option cache)
|
||||
*/
|
||||
top_level_config.requested_lease = 7200;
|
||||
+ top_level_config.bootp_broadcast_always = 0;
|
||||
|
||||
group_allocate (&top_level_config.on_receipt, MDL);
|
||||
if (!top_level_config.on_receipt)
|
||||
@@ -295,7 +296,8 @@ void read_client_leases ()
|
||||
interface-declaration |
|
||||
LEASE client-lease-statement |
|
||||
ALIAS client-lease-statement |
|
||||
- KEY key-definition */
|
||||
+ KEY key-definition |
|
||||
+ BOOTP_BROADCAST_ALWAYS */
|
||||
|
||||
void parse_client_statement (cfile, ip, config)
|
||||
struct parse *cfile;
|
||||
@@ -685,6 +687,12 @@ void parse_client_statement (cfile, ip,
|
||||
parse_reject_statement (cfile, config);
|
||||
return;
|
||||
|
||||
+ case BOOTP_BROADCAST_ALWAYS:
|
||||
+ token = next_token(&val, (unsigned*)0, cfile);
|
||||
+ config -> bootp_broadcast_always = 1;
|
||||
+ parse_semi (cfile);
|
||||
+ return;
|
||||
+
|
||||
default:
|
||||
lose = 0;
|
||||
stmt = (struct executable_statement *)0;
|
@ -1,31 +0,0 @@
|
||||
diff -up dhcp-4.0.0/includes/dhcpd.h.paths dhcp-4.0.0/includes/dhcpd.h
|
||||
--- dhcp-4.0.0/includes/dhcpd.h.paths 2008-01-01 15:09:21.000000000 -1000
|
||||
+++ dhcp-4.0.0/includes/dhcpd.h 2008-01-01 15:10:55.000000000 -1000
|
||||
@@ -1306,11 +1306,11 @@ typedef unsigned char option_mask [16];
|
||||
#endif /* DEBUG */
|
||||
|
||||
#ifndef _PATH_DHCPD_DB
|
||||
-#define _PATH_DHCPD_DB LOCALSTATEDIR"/db/dhcpd.leases"
|
||||
+#define _PATH_DHCPD_DB LOCALSTATEDIR"/dhcpd/dhcpd.leases"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DHCPD6_DB
|
||||
-#define _PATH_DHCPD6_DB LOCALSTATEDIR"/db/dhcpd6.leases"
|
||||
+#define _PATH_DHCPD6_DB LOCALSTATEDIR"/dhcpd/dhcpd6.leases"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DHCPD_PID
|
||||
@@ -1340,11 +1340,11 @@ typedef unsigned char option_mask [16];
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DHCLIENT_DB
|
||||
-#define _PATH_DHCLIENT_DB LOCALSTATEDIR"/db/dhclient.leases"
|
||||
+#define _PATH_DHCLIENT_DB LOCALSTATEDIR"/dhclient/dhclient.leases"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DHCLIENT6_DB
|
||||
-#define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/db/dhclient6.leases"
|
||||
+#define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/dhclient/dhclient6.leases"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_RESOLV_CONF
|
@ -1,245 +0,0 @@
|
||||
diff -up dhcp-4.0.0/common/nit.c.xen dhcp-4.0.0/common/nit.c
|
||||
--- dhcp-4.0.0/common/nit.c.xen 2007-09-05 07:32:10.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/nit.c 2007-12-29 06:39:16.000000000 -1000
|
||||
@@ -366,7 +366,7 @@ ssize_t receive_packet (interface, buf,
|
||||
|
||||
/* Decode the IP and UDP headers... */
|
||||
offset = decode_udp_ip_header (interface, ibuf, bufix,
|
||||
- from, length, &paylen);
|
||||
+ from, length, &paylen, 0);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0)
|
||||
diff -up dhcp-4.0.0/common/dlpi.c.xen dhcp-4.0.0/common/dlpi.c
|
||||
--- dhcp-4.0.0/common/dlpi.c.xen 2007-10-08 04:27:53.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/dlpi.c 2007-12-29 06:39:13.000000000 -1000
|
||||
@@ -689,7 +689,7 @@ ssize_t receive_packet (interface, buf,
|
||||
length -= offset;
|
||||
#endif
|
||||
offset = decode_udp_ip_header (interface, dbuf, bufix,
|
||||
- from, length, &paylen);
|
||||
+ from, length, &paylen, 0);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0) {
|
||||
diff -up dhcp-4.0.0/common/upf.c.xen dhcp-4.0.0/common/upf.c
|
||||
--- dhcp-4.0.0/common/upf.c.xen 2007-07-12 20:43:42.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/upf.c 2007-12-29 06:39:24.000000000 -1000
|
||||
@@ -317,7 +317,7 @@ ssize_t receive_packet (interface, buf,
|
||||
|
||||
/* Decode the IP and UDP headers... */
|
||||
offset = decode_udp_ip_header (interface, ibuf, bufix,
|
||||
- from, length, &paylen);
|
||||
+ from, length, &paylen, 0);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0)
|
||||
diff -up dhcp-4.0.0/common/lpf.c.xen dhcp-4.0.0/common/lpf.c
|
||||
--- dhcp-4.0.0/common/lpf.c.xen 2007-12-29 06:37:53.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/lpf.c 2007-12-29 06:43:08.000000000 -1000
|
||||
@@ -29,18 +29,33 @@
|
||||
#include "dhcpd.h"
|
||||
#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
|
||||
#include <sys/ioctl.h>
|
||||
+#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <asm/types.h>
|
||||
#include <linux/filter.h>
|
||||
#include <linux/if_ether.h>
|
||||
+#include <linux/if_packet.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include "includes/netinet/ip.h"
|
||||
#include "includes/netinet/udp.h"
|
||||
#include "includes/netinet/if_ether.h"
|
||||
#include <net/if.h>
|
||||
|
||||
+#ifndef PACKET_AUXDATA
|
||||
+#define PACKET_AUXDATA 8
|
||||
+
|
||||
+struct tpacket_auxdata
|
||||
+{
|
||||
+ __u32 tp_status;
|
||||
+ __u32 tp_len;
|
||||
+ __u32 tp_snaplen;
|
||||
+ __u16 tp_mac;
|
||||
+ __u16 tp_net;
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
/* Reinitializes the specified interface after an address change. This
|
||||
is not required for packet-filter APIs. */
|
||||
|
||||
@@ -66,10 +81,14 @@ int if_register_lpf (info)
|
||||
struct interface_info *info;
|
||||
{
|
||||
int sock;
|
||||
- struct sockaddr sa;
|
||||
+ union {
|
||||
+ struct sockaddr_ll ll;
|
||||
+ struct sockaddr common;
|
||||
+ } sa;
|
||||
+ struct ifreq ifr;
|
||||
|
||||
/* Make an LPF socket. */
|
||||
- if ((sock = socket(PF_PACKET, SOCK_PACKET,
|
||||
+ if ((sock = socket(PF_PACKET, SOCK_RAW,
|
||||
htons((short)ETH_P_ALL))) < 0) {
|
||||
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
|
||||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
|
||||
@@ -84,11 +103,16 @@ int if_register_lpf (info)
|
||||
log_fatal ("Open a socket for LPF: %m");
|
||||
}
|
||||
|
||||
+ memset (&ifr, 0, sizeof ifr);
|
||||
+ strncpy (ifr.ifr_name, (const char *)info -> ifp, sizeof ifr.ifr_name);
|
||||
+ if (ioctl (sock, SIOCGIFINDEX, &ifr))
|
||||
+ log_fatal ("Failed to get interface index: %m");
|
||||
+
|
||||
/* Bind to the interface name */
|
||||
memset (&sa, 0, sizeof sa);
|
||||
- sa.sa_family = AF_PACKET;
|
||||
- strncpy (sa.sa_data, (const char *)info -> ifp, sizeof sa.sa_data);
|
||||
- if (bind (sock, &sa, sizeof sa)) {
|
||||
+ sa.ll.sll_family = AF_PACKET;
|
||||
+ sa.ll.sll_ifindex = ifr.ifr_ifindex;
|
||||
+ if (bind (sock, &sa.common, sizeof sa)) {
|
||||
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
|
||||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
|
||||
errno == EAFNOSUPPORT || errno == EINVAL) {
|
||||
@@ -170,9 +194,18 @@ static void lpf_gen_filter_setup (struct
|
||||
void if_register_receive (info)
|
||||
struct interface_info *info;
|
||||
{
|
||||
+ int val;
|
||||
+
|
||||
/* Open a LPF device and hang it on this interface... */
|
||||
info -> rfdesc = if_register_lpf (info);
|
||||
|
||||
+ val = 1;
|
||||
+ if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, &val,
|
||||
+ sizeof val) < 0) {
|
||||
+ if (errno != ENOPROTOOPT)
|
||||
+ log_fatal ("Failed to set auxiliary packet data: %m");
|
||||
+ }
|
||||
+
|
||||
#if defined (HAVE_TR_SUPPORT)
|
||||
if (info -> hw_address.hbuf [0] == HTYPE_IEEE802)
|
||||
lpf_tr_filter_setup (info);
|
||||
@@ -291,7 +324,6 @@ ssize_t send_packet (interface, packet,
|
||||
double hh [16];
|
||||
double ih [1536 / sizeof (double)];
|
||||
unsigned char *buf = (unsigned char *)ih;
|
||||
- struct sockaddr sa;
|
||||
int result;
|
||||
int fudge;
|
||||
|
||||
@@ -309,15 +341,7 @@ ssize_t send_packet (interface, packet,
|
||||
(unsigned char *)raw, len);
|
||||
memcpy (buf + ibufp, raw, len);
|
||||
|
||||
- /* For some reason, SOCK_PACKET sockets can't be connected,
|
||||
- so we have to do a sentdo every time. */
|
||||
- memset (&sa, 0, sizeof sa);
|
||||
- sa.sa_family = AF_PACKET;
|
||||
- strncpy (sa.sa_data,
|
||||
- (const char *)interface -> ifp, sizeof sa.sa_data);
|
||||
-
|
||||
- result = sendto (interface -> wfdesc,
|
||||
- buf + fudge, ibufp + len - fudge, 0, &sa, sizeof sa);
|
||||
+ result = write (interface -> wfdesc, buf + fudge, ibufp + len - fudge);
|
||||
if (result < 0)
|
||||
log_error ("send_packet: %m");
|
||||
return result;
|
||||
@@ -334,14 +358,35 @@ ssize_t receive_packet (interface, buf,
|
||||
{
|
||||
int length = 0;
|
||||
int offset = 0;
|
||||
+ int nocsum = 0;
|
||||
unsigned char ibuf [1536];
|
||||
unsigned bufix = 0;
|
||||
unsigned paylen;
|
||||
+ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
|
||||
+ struct iovec iov = {
|
||||
+ .iov_base = ibuf,
|
||||
+ .iov_len = sizeof ibuf,
|
||||
+ };
|
||||
+ struct msghdr msg = {
|
||||
+ .msg_iov = &iov,
|
||||
+ .msg_iovlen = 1,
|
||||
+ .msg_control = cmsgbuf,
|
||||
+ .msg_controllen = sizeof(cmsgbuf),
|
||||
+ };
|
||||
+ struct cmsghdr *cmsg;
|
||||
|
||||
- length = read (interface -> rfdesc, ibuf, sizeof ibuf);
|
||||
+ length = recvmsg (interface -> rfdesc, &msg, 0);
|
||||
if (length <= 0)
|
||||
return length;
|
||||
|
||||
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||
+ if (cmsg->cmsg_level == SOL_PACKET &&
|
||||
+ cmsg->cmsg_type == PACKET_AUXDATA) {
|
||||
+ struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg);
|
||||
+ nocsum = aux->tp_status & TP_STATUS_CSUMNOTREADY;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
bufix = 0;
|
||||
/* Decode the physical header... */
|
||||
offset = decode_hw_header (interface, ibuf, bufix, hfrom);
|
||||
@@ -358,7 +403,7 @@ ssize_t receive_packet (interface, buf,
|
||||
|
||||
/* Decode the IP and UDP headers... */
|
||||
offset = decode_udp_ip_header (interface, ibuf, bufix, from,
|
||||
- (unsigned)length, &paylen);
|
||||
+ (unsigned)length, &paylen, nocsum);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0)
|
||||
diff -up dhcp-4.0.0/common/bpf.c.xen dhcp-4.0.0/common/bpf.c
|
||||
--- dhcp-4.0.0/common/bpf.c.xen 2007-08-22 23:49:51.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/bpf.c 2007-12-29 06:39:09.000000000 -1000
|
||||
@@ -482,7 +482,7 @@ ssize_t receive_packet (interface, buf,
|
||||
offset = decode_udp_ip_header (interface,
|
||||
interface -> rbuf,
|
||||
interface -> rbuf_offset,
|
||||
- from, hdr.bh_caplen, &paylen);
|
||||
+ from, hdr.bh_caplen, &paylen, 0);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0) {
|
||||
diff -up dhcp-4.0.0/common/packet.c.xen dhcp-4.0.0/common/packet.c
|
||||
--- dhcp-4.0.0/common/packet.c.xen 2007-12-29 06:37:53.000000000 -1000
|
||||
+++ dhcp-4.0.0/common/packet.c 2007-12-29 06:39:20.000000000 -1000
|
||||
@@ -210,7 +210,7 @@ ssize_t
|
||||
decode_udp_ip_header(struct interface_info *interface,
|
||||
unsigned char *buf, unsigned bufix,
|
||||
struct sockaddr_in *from, unsigned buflen,
|
||||
- unsigned *rbuflen)
|
||||
+ unsigned *rbuflen, int nocsum)
|
||||
{
|
||||
unsigned char *data;
|
||||
struct ip ip;
|
||||
@@ -321,7 +321,7 @@ decode_udp_ip_header(struct interface_in
|
||||
8, IPPROTO_UDP + ulen))));
|
||||
|
||||
udp_packets_seen++;
|
||||
- if (usum && usum != sum) {
|
||||
+ if (!nocsum && usum && usum != sum) {
|
||||
udp_packets_bad_checksum++;
|
||||
if (udp_packets_seen > 4 &&
|
||||
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
|
||||
diff -up dhcp-4.0.0/includes/dhcpd.h.xen dhcp-4.0.0/includes/dhcpd.h
|
||||
--- dhcp-4.0.0/includes/dhcpd.h.xen 2007-12-29 06:37:53.000000000 -1000
|
||||
+++ dhcp-4.0.0/includes/dhcpd.h 2007-12-29 06:39:27.000000000 -1000
|
||||
@@ -2561,7 +2561,7 @@ ssize_t decode_hw_header PROTO ((struct
|
||||
unsigned, struct hardware *));
|
||||
ssize_t decode_udp_ip_header PROTO ((struct interface_info *, unsigned char *,
|
||||
unsigned, struct sockaddr_in *,
|
||||
- unsigned, unsigned *));
|
||||
+ unsigned, unsigned *, int));
|
||||
|
||||
/* ethernet.c */
|
||||
void assemble_ethernet_header PROTO ((struct interface_info *, unsigned char *,
|
462
dhcp.schema
462
dhcp.schema
@ -1,462 +0,0 @@
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.1
|
||||
NAME 'dhcpPrimaryDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The DN of the dhcpServer which is the primary server for the configuration.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.2
|
||||
NAME 'dhcpSecondaryDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The DN of dhcpServer(s) which provide backup service for the configuration.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.3
|
||||
NAME 'dhcpStatements'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Flexible storage for specific data depending on what object this exists in. Like conditional statements, server parameters, etc. This allows the standard to evolve without needing to adjust the schema.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.4
|
||||
NAME 'dhcpRange'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'The starting & ending IP Addresses in the range (inclusive), separated by a hyphen; if the range only contains one address, then just the address can be specified with no hyphen. Each range is defined as a separate value.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.5
|
||||
NAME 'dhcpPermitList'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'This attribute contains the permit lists associated with a pool. Each permit list is defined as a separate value.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.6
|
||||
NAME 'dhcpNetMask'
|
||||
EQUALITY integerMatch
|
||||
DESC 'The subnet mask length for the subnet. The mask can be easily computed from this length.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.7
|
||||
NAME 'dhcpOption'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Encoded option values to be sent to clients. Each value represents a single option and contains (OptionTag, Length, OptionValue) encoded in the format used by DHCP.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.8
|
||||
NAME 'dhcpClassData'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Encoded text string or list of bytes expressed in hexadecimal, separated by colons. Clients match subclasses based on matching the class data with the results of match or spawn with statements in the class name declarations.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.9
|
||||
NAME 'dhcpOptionsDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name(s) of the dhcpOption objects containing the configuration options provided by the server.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.10
|
||||
NAME 'dhcpHostDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'the distinguished name(s) of the dhcpHost objects.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.11
|
||||
NAME 'dhcpPoolDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name(s) of pools.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.12
|
||||
NAME 'dhcpGroupDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name(s) of the groups.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.13
|
||||
NAME 'dhcpSubnetDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name(s) of the subnets.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.14
|
||||
NAME 'dhcpLeaseDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name of a client address.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE)
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.15
|
||||
NAME 'dhcpLeasesDN'
|
||||
DESC 'The distinguished name(s) client addresses.'
|
||||
EQUALITY distinguishedNameMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.16
|
||||
NAME 'dhcpClassesDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name(s) of a class(es) in a subclass.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.17
|
||||
NAME 'dhcpSubclassesDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name(s) of subclass(es).'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.18
|
||||
NAME 'dhcpSharedNetworkDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name(s) of sharedNetworks.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.19
|
||||
NAME 'dhcpServiceDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The DN of dhcpService object(s)which contain the configuration information. Each dhcpServer object has this attribute identifying the DHCP configuration(s) that the server is associated with.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.20
|
||||
NAME 'dhcpVersion'
|
||||
DESC 'The version attribute of this object.'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.21
|
||||
NAME 'dhcpImplementation'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Description of the DHCP Server implementation e.g. DHCP Servers vendor.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.22
|
||||
NAME 'dhcpAddressState'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'This stores information about the current binding-status of an address. For dynamic addresses managed by DHCP, the values should be restricted to the following: "FREE", "ACTIVE", "EXPIRED", "RELEASED", "RESET", "ABANDONED", "BACKUP". For other addresses, it SHOULD be one of the following: "UNKNOWN", "RESERVED" (an address that is managed by DHCP that is reserved for a specific client), "RESERVED-ACTIVE" (same as reserved, but address is currently in use), "ASSIGNED" (assigned manually or by some other mechanism), "UNASSIGNED", "NOTASSIGNABLE".'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.23
|
||||
NAME 'dhcpExpirationTime'
|
||||
EQUALITY generalizedTimeMatch
|
||||
DESC 'This is the time the current lease for an address expires.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.24
|
||||
NAME 'dhcpStartTimeOfState'
|
||||
EQUALITY generalizedTimeMatch
|
||||
DESC 'This is the time of the last state change for a leased address.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.25
|
||||
NAME 'dhcpLastTransactionTime'
|
||||
EQUALITY generalizedTimeMatch
|
||||
DESC 'This is the last time a valid DHCP packet was received from the client.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.26
|
||||
NAME 'dhcpBootpFlag'
|
||||
EQUALITY booleanMatch
|
||||
DESC 'This indicates whether the address was assigned via BOOTP.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.27
|
||||
NAME 'dhcpDomainName'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'This is the name of the domain sent to the client by the server. It is essentially the same as the value for DHCP option 15 sent to the client, and represents only the domain - not the full FQDN. To obtain the full FQDN assigned to the client you must prepend the "dhcpAssignedHostName" to this value with a ".".'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.28
|
||||
NAME 'dhcpDnsStatus'
|
||||
EQUALITY integerMatch
|
||||
DESC 'This indicates the status of updating DNS resource records on behalf of the client by the DHCP server for this address. The value is a 16-bit bitmask.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.29
|
||||
NAME 'dhcpRequestedHostName'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'This is the hostname that was requested by the client.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.30
|
||||
NAME 'dhcpAssignedHostName'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'This is the actual hostname that was assigned to a client. It may not be the name that was requested by the client. The fully qualified domain name can be determined by appending the value of "dhcpDomainName" (with a dot separator) to this name.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.31
|
||||
NAME 'dhcpReservedForClient'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The distinguished name of a "dhcpClient" that an address is reserved for. This may not be the same as the "dhcpAssignedToClient" attribute if the address is being reassigned but the current lease has not yet expired.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.32
|
||||
NAME 'dhcpAssignedToClient'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'This is the distinguished name of a "dhcpClient" that an address is currently assigned to. This attribute is only present in the class when the address is leased.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.33
|
||||
NAME 'dhcpRelayAgentInfo'
|
||||
EQUALITY octetStringMatch
|
||||
DESC 'If the client request was received via a relay agent, this contains information about the relay agent that was available from the DHCP request. This is a hex-encoded option value.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.34
|
||||
NAME 'dhcpHWAddress'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'The clients hardware address that requested this IP address.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.35
|
||||
NAME 'dhcpHashBucketAssignment'
|
||||
EQUALITY octetStringMatch
|
||||
DESC 'HashBucketAssignment bit map for the DHCP Server, as defined in DHC Load Balancing Algorithm [RFC 3074].'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.36
|
||||
NAME 'dhcpDelayedServiceParameter'
|
||||
EQUALITY integerMatch
|
||||
DESC 'Delay in seconds corresponding to Delayed Service Parameter configuration, as defined in DHC Load Balancing Algorithm [RFC 3074]. '
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.37
|
||||
NAME 'dhcpMaxClientLeadTime'
|
||||
EQUALITY integerMatch
|
||||
DESC 'Maximum Client Lead Time configuration in seconds, as defined in DHCP Failover Protocol [FAILOVR]'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.38
|
||||
NAME 'dhcpFailOverEndpointState'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Server (Failover Endpoint) state, as defined in DHCP Failover Protocol [FAILOVR]'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.39
|
||||
NAME 'dhcpErrorLog'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Generic error log attribute that allows logging error conditions within a dhcpService or a dhcpSubnet, like no IP addresses available for lease.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.40
|
||||
NAME 'dhcpLocatorDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The DN of dhcpLocator object which contain the DNs of all DHCP configuration objects. There will be a single dhcpLocator object in the tree with links to all the DHCP objects in the tree'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.41
|
||||
NAME 'dhcpKeyAlgorithm'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Algorithm to generate TSIG Key'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.42
|
||||
NAME 'dhcpKeySecret'
|
||||
EQUALITY octetStringMatch
|
||||
DESC 'Secret to generate TSIG Key' SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.43
|
||||
NAME 'dhcpDnsZoneServer'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Master server of the DNS Zone'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.44
|
||||
NAME 'dhcpKeyDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The DNs of TSIG Key to use in secure dynamic updates. In case of locator object, this will be list of TSIG keys. In case of DHCP Service, Shared Network, Subnet and DNS Zone, it will be a single key.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12)
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.45
|
||||
NAME 'dhcpZoneDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The DNs of DNS Zone. In case of locator object, this will be list of DNS Zones in the tree. In case of DHCP Service, Shared Network and Subnet, it will be a single DNS Zone.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12)
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.46
|
||||
NAME 'dhcpFailOverPrimaryServer'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'IP address or DNS name of the server playing primary role in DHC Load Balancing and Fail over.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.47
|
||||
NAME 'dhcpFailOverSecondaryServer'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'IP address or DNS name of the server playing secondary role in DHC Load Balancing and Fail over.'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.48
|
||||
NAME 'dhcpFailOverPrimaryPort'
|
||||
EQUALITY integerMatch
|
||||
DESC 'Port on which primary server listens for connections from its fail over peer (secondary server)'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.49
|
||||
NAME 'dhcpFailOverSecondaryPort'
|
||||
EQUALITY integerMatch
|
||||
DESC 'Port on which secondary server listens for connections from its fail over peer (primary server)'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.50
|
||||
NAME 'dhcpFailOverResponseDelay'
|
||||
EQUALITY integerMatch
|
||||
DESC 'Maximum response time in seconds, before Server assumes that connection to fail over peer has failed'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.51
|
||||
NAME 'dhcpFailOverUnackedUpdates'
|
||||
EQUALITY integerMatch
|
||||
DESC 'Number of BNDUPD messages that server can send before it receives BNDACK from its fail over peer'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.52
|
||||
NAME 'dhcpFailOverSplit'
|
||||
EQUALITY integerMatch
|
||||
DESC 'Split between the primary and secondary servers for fail over purpose'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.53
|
||||
NAME 'dhcpFailOverLoadBalanceTime'
|
||||
EQUALITY integerMatch
|
||||
DESC 'Cutoff time in seconds, after which load balance is disabled'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.54
|
||||
NAME 'dhcpFailOverPeerDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'The DNs of Fail over peers. In case of locator object, this will be list of fail over peers in the tree. In case of Subnet and pool, it will be a single Fail Over Peer'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
#List of all servers in the tree
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.55
|
||||
NAME 'dhcpServerDN'
|
||||
EQUALITY distinguishedNameMatch
|
||||
DESC 'List of all DHCP Servers in the tree. Used by dhcpLocatorObject'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
|
||||
|
||||
attributetype ( 2.16.840.1.113719.1.203.4.56
|
||||
NAME 'dhcpComments'
|
||||
EQUALITY caseIgnoreIA5Match
|
||||
DESC 'Generic attribute that allows coments within any DHCP object'
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
|
||||
|
||||
# Classes
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.1
|
||||
NAME 'dhcpService'
|
||||
DESC 'Service object that represents the actual DHCP Service configuration. This is a container object.'
|
||||
SUP top
|
||||
MUST (cn)
|
||||
MAY ( dhcpPrimaryDN $ dhcpSecondaryDN $ dhcpServerDN $ dhcpSharedNetworkDN $ dhcpSubnetDN $ dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpKeyDN $ dhcpFailOverPeerDN $ dhcpStatements $dhcpComments $ dhcpOption) )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.2
|
||||
NAME 'dhcpSharedNetwork'
|
||||
DESC 'This stores configuration information for a shared network.'
|
||||
SUP top
|
||||
MUST cn
|
||||
MAY ( dhcpSubnetDN $ dhcpPoolDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpStatements $dhcpComments $ dhcpOption) X-NDS_CONTAINMENT ('dhcpService' ) )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.3
|
||||
NAME 'dhcpSubnet'
|
||||
DESC 'This class defines a subnet. This is a container object.'
|
||||
SUP top
|
||||
MUST ( cn $ dhcpNetMask )
|
||||
MAY ( dhcpRange $ dhcpPoolDN $ dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $ dhcpLeasesDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpKeyDN $ dhcpFailOverPeerDN $ dhcpStatements $ dhcpComments $ dhcpOption ) X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork') )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.4
|
||||
NAME 'dhcpPool'
|
||||
DESC 'This stores configuration information about a pool.'
|
||||
SUP top
|
||||
MUST ( cn $ dhcpRange )
|
||||
MAY ( dhcpClassesDN $ dhcpPermitList $ dhcpLeasesDN $ dhcpOptionsDN $ dhcpZoneDN $dhcpKeyDN $ dhcpStatements $ dhcpComments $ dhcpOption )
|
||||
X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpSharedNetwork') )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.5
|
||||
NAME 'dhcpGroup'
|
||||
DESC 'Group object that lists host DNs and parameters. This is a container object.'
|
||||
SUP top
|
||||
MUST cn
|
||||
MAY ( dhcpHostDN $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption )
|
||||
X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpService' ) )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.6
|
||||
NAME 'dhcpHost'
|
||||
DESC 'This represents information about a particular client'
|
||||
SUP top
|
||||
MUST cn
|
||||
MAY (dhcpLeaseDN $ dhcpHWAddress $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption)
|
||||
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSubnet' 'dhcpGroup') )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.7
|
||||
NAME 'dhcpClass'
|
||||
DESC 'Represents information about a collection of related clients.'
|
||||
SUP top
|
||||
MUST cn
|
||||
MAY (dhcpSubClassesDN $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption)
|
||||
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSubnet' ) )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.8
|
||||
NAME 'dhcpSubClass'
|
||||
DESC 'Represents information about a collection of related classes.'
|
||||
SUP top
|
||||
MUST cn
|
||||
MAY (dhcpClassData $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption) X-NDS_CONTAINMENT 'dhcpClass' )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.9
|
||||
NAME 'dhcpOptions'
|
||||
DESC 'Represents information about a collection of options defined.'
|
||||
SUP top AUXILIARY
|
||||
MUST cn
|
||||
MAY ( dhcpOption $ dhcpComments )
|
||||
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet' 'dhcpPool' 'dhcpGroup' 'dhcpHost' 'dhcpClass' ) )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.10
|
||||
NAME 'dhcpLeases'
|
||||
DESC 'This class represents an IP Address, which may or may not have been leased.'
|
||||
SUP top
|
||||
MUST ( cn $ dhcpAddressState )
|
||||
MAY ( dhcpExpirationTime $ dhcpStartTimeOfState $ dhcpLastTransactionTime $ dhcpBootpFlag $ dhcpDomainName $ dhcpDnsStatus $ dhcpRequestedHostName $ dhcpAssignedHostName $ dhcpReservedForClient $ dhcpAssignedToClient $ dhcpRelayAgentInfo $ dhcpHWAddress )
|
||||
X-NDS_CONTAINMENT ( 'dhcpService' 'dhcpSubnet' 'dhcpPool') )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.11
|
||||
NAME 'dhcpLog'
|
||||
DESC 'This is the object that holds past information about the IP address. The cn is the time/date stamp when the address was assigned or released, the address state at the time, if the address was assigned or released.'
|
||||
SUP top
|
||||
MUST ( cn )
|
||||
MAY ( dhcpAddressState $ dhcpExpirationTime $ dhcpStartTimeOfState $ dhcpLastTransactionTime $ dhcpBootpFlag $ dhcpDomainName $ dhcpDnsStatus $ dhcpRequestedHostName $ dhcpAssignedHostName $ dhcpReservedForClient $ dhcpAssignedToClient $ dhcpRelayAgentInfo $ dhcpHWAddress $ dhcpErrorLog)
|
||||
X-NDS_CONTAINMENT ('dhcpLeases' 'dhcpPool' 'dhcpSubnet' 'dhcpSharedNetwork' 'dhcpService' ) )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.12
|
||||
NAME 'dhcpServer'
|
||||
DESC 'DHCP Server Object'
|
||||
SUP top
|
||||
MUST ( cn )
|
||||
MAY (dhcpServiceDN $ dhcpLocatorDN $ dhcpVersion $ dhcpImplementation $ dhcpHashBucketAssignment $ dhcpDelayedServiceParameter $ dhcpMaxClientLeadTime $ dhcpFailOverEndpointState $ dhcpStatements $ dhcpComments $ dhcpOption)
|
||||
X-NDS_CONTAINMENT ('organization' 'organizationalunit' 'domain') )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.13
|
||||
NAME 'dhcpTSigKey'
|
||||
DESC 'TSIG key for secure dynamic updates'
|
||||
SUP top
|
||||
MUST (cn $ dhcpKeyAlgorithm $ dhcpKeySecret )
|
||||
MAY ( dhcpComments )
|
||||
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.14
|
||||
NAME 'dhcpDnsZone'
|
||||
DESC 'DNS Zone for updating leases'
|
||||
SUP top
|
||||
MUST (cn $ dhcpDnsZoneServer )
|
||||
MAY (dhcpKeyDN $ dhcpComments)
|
||||
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.15
|
||||
NAME 'dhcpFailOverPeer'
|
||||
DESC 'This class defines the Fail over peer'
|
||||
SUP top
|
||||
MUST ( cn $ dhcpFailOverPrimaryServer $ dhcpFailOverSecondaryServer $ dhcpFailoverPrimaryPort $ dhcpFailOverSecondaryPort) MAY (dhcpFailOverResponseDelay $ dhcpFailOverUnackedUpdates $ dhcpMaxClientLeadTime $ dhcpFailOverSplit $ dhcpHashBucketAssignment $ dhcpFailOverLoadBalanceTime $ dhcpComments )
|
||||
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
|
||||
|
||||
objectclass ( 2.16.840.1.113719.1.203.6.16
|
||||
NAME 'dhcpLocator'
|
||||
DESC 'Locator object for DHCP configuration in the tree. There will be a single dhcpLocator object in the tree with links to all the DHCP objects in the tree'
|
||||
SUP top
|
||||
MUST ( cn )
|
||||
MAY ( dhcpServiceDN $dhcpServerDN $ dhcpSharedNetworkDN $ dhcpSubnetDN $ dhcpPoolDN $ dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $ dhcpKeyDN $ dhcpZoneDN $ dhcpFailOverPeerDN $ dhcpOption $ dhcpComments)
|
||||
X-NDS_CONTAINMENT ('organization' 'organizationalunit' 'domain') )
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
/* dhcp4client.h
|
||||
*
|
||||
* Interface to the ISC dhcp IPv4 client libdhcp4client library.
|
||||
*
|
||||
* Copyright (C) 2006 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions of
|
||||
* the GNU General Public License v.2, or (at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY expressed or implied, including the implied warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details. You should have received a copy of the
|
||||
* GNU General Public License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
||||
* source code or documentation are not subject to the GNU General Public
|
||||
* License and may only be used or replicated with the express permission of
|
||||
* Red Hat, Inc.
|
||||
*
|
||||
* Red Hat Author(s): Jason Vas Dias
|
||||
* David Cantrell <dcantrell@redhat.com>
|
||||
*/
|
||||
|
||||
/* include libdhcp_control.h or libdhcp.h for this */
|
||||
extern struct libdhcp_control_s;
|
||||
|
||||
/* The ISC IPv4 DHCP client main() function */
|
||||
extern int dhcpv4_client(struct libdhcp_control_s *dhc_ctl,
|
||||
int argc, char **argv, char **envp);
|
@ -1,760 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# Brian Masney <masneyb@ntelos.net>
|
||||
# To use this script, set your base DN below. Then run
|
||||
# ./dhcpd-conf-to-ldap.pl < /path-to-dhcpd-conf/dhcpd.conf > output-file
|
||||
# The output of this script will generate entries in LDIF format. You can use
|
||||
# the slapadd command to add these entries into your LDAP server. You will
|
||||
# definately want to double check that your LDAP entries are correct before
|
||||
# you load them into LDAP.
|
||||
|
||||
# This script does not do much error checking. Make sure before you run this
|
||||
# that the DHCP server doesn't give any errors about your config file
|
||||
|
||||
# FailOver notes:
|
||||
# Failover is disabled by default, since it may need manually intervention.
|
||||
# You can try the '--use=failover' option to see what happens :-)
|
||||
#
|
||||
# If enabled, the failover pool references will be written to LDIF output.
|
||||
# The failover configs itself will be added to the dhcpServer statements
|
||||
# and not to the dhcpService object (since this script uses only one and
|
||||
# it may be usefull to have multiple service containers in failover mode).
|
||||
# Further, this script does not check if primary or secondary makes sense,
|
||||
# it simply converts what it gets...
|
||||
|
||||
use Net::Domain qw(hostname hostfqdn hostdomain);
|
||||
use Getopt::Long;
|
||||
|
||||
my $domain = hostdomain(); # your.domain
|
||||
my $basedn = "dc=".$domain;
|
||||
$basedn =~ s/\./,dc=/g; # dc=your,dc=domain
|
||||
my $server = hostname(); # hostname (nodename)
|
||||
my $dhcpcn = 'DHCP Config'; # CN of DHCP config tree
|
||||
my $dhcpdn = "cn=$dhcpcn, $basedn"; # DHCP config tree DN
|
||||
my $second = ''; # secondary server DN / hostname
|
||||
my $i_conf = ''; # dhcp.conf file to read or stdin
|
||||
my $o_ldif = ''; # output ldif file name or stdout
|
||||
my @use = (); # extended flags (failover)
|
||||
|
||||
sub usage($;$)
|
||||
{
|
||||
my $rc = shift;
|
||||
my $err= shift;
|
||||
|
||||
print STDERR "Error: $err\n\n" if(defined $err);
|
||||
print STDERR <<__EOF_USAGE__;
|
||||
usage:
|
||||
$0 [options] < dhcpd.conf > dhcpd.ldif
|
||||
|
||||
options:
|
||||
|
||||
--basedn "dc=your,dc=domain" ("$basedn")
|
||||
|
||||
--dhcpdn "dhcp config DN" ("$dhcpdn")
|
||||
|
||||
--server "dhcp server name" ("$server")
|
||||
|
||||
--second "secondary server or DN" ("$second")
|
||||
|
||||
--conf "/path/to/dhcpd.conf" (default is stdin)
|
||||
--ldif "/path/to/output.ldif" (default is stdout)
|
||||
|
||||
--use "extended features" (see source comments)
|
||||
__EOF_USAGE__
|
||||
exit($rc);
|
||||
}
|
||||
|
||||
|
||||
sub next_token
|
||||
{
|
||||
local ($lowercase) = @_;
|
||||
local ($token, $newline);
|
||||
|
||||
do
|
||||
{
|
||||
if (!defined ($line) || length ($line) == 0)
|
||||
{
|
||||
$line = <>;
|
||||
return undef if !defined ($line);
|
||||
chop $line;
|
||||
$line_number++;
|
||||
$token_number = 0;
|
||||
}
|
||||
|
||||
$line =~ s/#.*//;
|
||||
$line =~ s/^\s+//;
|
||||
$line =~ s/\s+$//;
|
||||
}
|
||||
while (length ($line) == 0);
|
||||
|
||||
if (($token, $newline) = $line =~ /^(.*?)\s+(.*)/)
|
||||
{
|
||||
if ($token =~ /^"/) {
|
||||
#handle quoted token
|
||||
if ($token !~ /"\s*$/)
|
||||
{
|
||||
($tok, $newline) = $newline =~ /([^"]+")(.*)/;
|
||||
$token .= " $tok";
|
||||
}
|
||||
}
|
||||
$line = $newline;
|
||||
}
|
||||
else
|
||||
{
|
||||
$token = $line;
|
||||
$line = '';
|
||||
}
|
||||
$token_number++;
|
||||
|
||||
$token =~ y/[A-Z]/[a-z]/ if $lowercase;
|
||||
|
||||
return ($token);
|
||||
}
|
||||
|
||||
|
||||
sub remaining_line
|
||||
{
|
||||
local ($block) = shift || 0;
|
||||
local ($tmp, $str);
|
||||
|
||||
$str = "";
|
||||
while (defined($tmp = next_token (0)))
|
||||
{
|
||||
$str .= ' ' if !($str eq "");
|
||||
$str .= $tmp;
|
||||
last if $tmp =~ /;\s*$/;
|
||||
last if($block and $tmp =~ /\s*[}{]\s*$/);
|
||||
}
|
||||
|
||||
$str =~ s/;$//;
|
||||
return ($str);
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
add_dn_to_stack
|
||||
{
|
||||
local ($dn) = @_;
|
||||
|
||||
$current_dn = "$dn, $current_dn";
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
remove_dn_from_stack
|
||||
{
|
||||
$current_dn =~ s/^.*?,\s*//;
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
parse_error
|
||||
{
|
||||
print "Parse error on line number $line_number at token number $token_number\n";
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
print_entry
|
||||
{
|
||||
return if (scalar keys %curentry == 0);
|
||||
|
||||
if (!defined ($curentry{'type'}))
|
||||
{
|
||||
$hostdn = "cn=$server, $basedn";
|
||||
print "dn: $hostdn\n";
|
||||
print "cn: $server\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpServer\n";
|
||||
print "dhcpServiceDN: $current_dn\n";
|
||||
if(grep(/FaIlOvEr/i, @use))
|
||||
{
|
||||
foreach my $fo_peer (keys %failover)
|
||||
{
|
||||
next if(scalar(@{$failover{$fo_peer}}) <= 1);
|
||||
print "dhcpStatements: failover peer $fo_peer { ",
|
||||
join('; ', @{$failover{$fo_peer}}), "; }\n";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: $dhcpcn\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpService\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
print "dhcpPrimaryDN: $hostdn\n";
|
||||
if(grep(/FaIlOvEr/i, @use) and ($second ne ''))
|
||||
{
|
||||
print "dhcpSecondaryDN: $second\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'subnet')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'ip'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpSubnet\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
|
||||
print "dhcpNetMask: " . $curentry{'netmask'} . "\n";
|
||||
if (defined ($curentry{'ranges'}))
|
||||
{
|
||||
foreach $statement (@{$curentry{'ranges'}})
|
||||
{
|
||||
print "dhcpRange: $statement\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'shared-network')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'descr'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpSharedNetwork\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'group')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: group", $curentry{'idx'}, "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpGroup\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'host')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'host'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpHost\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
|
||||
if (defined ($curentry{'hwaddress'}))
|
||||
{
|
||||
$curentry{'hwaddress'} =~ y/[A-Z]/[a-z]/;
|
||||
print "dhcpHWAddress: " . $curentry{'hwaddress'} . "\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'pool')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: pool", $curentry{'idx'}, "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpPool\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
|
||||
if (defined ($curentry{'ranges'}))
|
||||
{
|
||||
foreach $statement (@{$curentry{'ranges'}})
|
||||
{
|
||||
print "dhcpRange: $statement\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'class')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'class'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpClass\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'subclass')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'subclass'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpSubClass\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
print "dhcpClassData: " . $curentry{'class'} . "\n";
|
||||
}
|
||||
|
||||
if (defined ($curentry{'statements'}))
|
||||
{
|
||||
foreach $statement (@{$curentry{'statements'}})
|
||||
{
|
||||
print "dhcpStatements: $statement\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
foreach $statement (@{$curentry{'options'}})
|
||||
{
|
||||
print "dhcpOption: $statement\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
undef (%curentry);
|
||||
}
|
||||
|
||||
|
||||
sub parse_netmask
|
||||
{
|
||||
local ($netmask) = @_;
|
||||
local ($i);
|
||||
|
||||
if ((($a, $b, $c, $d) = $netmask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) != 4)
|
||||
{
|
||||
parse_error ();
|
||||
}
|
||||
|
||||
$num = (($a & 0xff) << 24) |
|
||||
(($b & 0xff) << 16) |
|
||||
(($c & 0xff) << 8) |
|
||||
($d & 0xff);
|
||||
|
||||
for ($i=1; $i<=32 && $num & (1 << (32 - $i)); $i++)
|
||||
{
|
||||
}
|
||||
$i--;
|
||||
|
||||
return ($i);
|
||||
}
|
||||
|
||||
|
||||
sub parse_subnet
|
||||
{
|
||||
local ($ip, $tmp, $netmask);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$ip = next_token (0);
|
||||
parse_error () if !defined ($ip);
|
||||
|
||||
$tmp = next_token (1);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq 'netmask');
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
$netmask = parse_netmask ($tmp);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
add_dn_to_stack ("cn=$ip");
|
||||
$curentry{'type'} = 'subnet';
|
||||
$curentry{'ip'} = $ip;
|
||||
$curentry{'netmask'} = $netmask;
|
||||
$cursubnet = $ip;
|
||||
$curcounter{$ip} = { pool => 0, group => 0 };
|
||||
}
|
||||
|
||||
|
||||
sub parse_shared_network
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$descr = next_token (0);
|
||||
parse_error () if !defined ($descr);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
add_dn_to_stack ("cn=$descr");
|
||||
$curentry{'type'} = 'shared-network';
|
||||
$curentry{'descr'} = $descr;
|
||||
}
|
||||
|
||||
|
||||
sub parse_host
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$host = next_token (0);
|
||||
parse_error () if !defined ($host);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
add_dn_to_stack ("cn=$host");
|
||||
$curentry{'type'} = 'host';
|
||||
$curentry{'host'} = $host;
|
||||
}
|
||||
|
||||
|
||||
sub parse_group
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
my $idx;
|
||||
if(exists($curcounter{$cursubnet})) {
|
||||
$idx = ++$curcounter{$cursubnet}->{'group'};
|
||||
} else {
|
||||
$idx = ++$curcounter{''}->{'group'};
|
||||
}
|
||||
|
||||
add_dn_to_stack ("cn=group".$idx);
|
||||
$curentry{'type'} = 'group';
|
||||
$curentry{'idx'} = $idx;
|
||||
}
|
||||
|
||||
|
||||
sub parse_pool
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
my $idx;
|
||||
if(exists($curcounter{$cursubnet})) {
|
||||
$idx = ++$curcounter{$cursubnet}->{'pool'};
|
||||
} else {
|
||||
$idx = ++$curcounter{''}->{'pool'};
|
||||
}
|
||||
|
||||
add_dn_to_stack ("cn=pool".$idx);
|
||||
$curentry{'type'} = 'pool';
|
||||
$curentry{'idx'} = $idx;
|
||||
}
|
||||
|
||||
|
||||
sub parse_class
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$class = next_token (0);
|
||||
parse_error () if !defined ($class);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
$class =~ s/\"//g;
|
||||
add_dn_to_stack ("cn=$class");
|
||||
$curentry{'type'} = 'class';
|
||||
$curentry{'class'} = $class;
|
||||
}
|
||||
|
||||
|
||||
sub parse_subclass
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$class = next_token (0);
|
||||
parse_error () if !defined ($class);
|
||||
|
||||
$subclass = next_token (0);
|
||||
parse_error () if !defined ($subclass);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
add_dn_to_stack ("cn=$subclass");
|
||||
$curentry{'type'} = 'subclass';
|
||||
$curentry{'class'} = $class;
|
||||
$curentry{'subclass'} = $subclass;
|
||||
}
|
||||
|
||||
|
||||
sub parse_hwaddress
|
||||
{
|
||||
local ($type, $hw, $tmp);
|
||||
|
||||
$type = next_token (1);
|
||||
parse_error () if !defined ($type);
|
||||
|
||||
$hw = next_token (1);
|
||||
parse_error () if !defined ($hw);
|
||||
$hw =~ s/;$//;
|
||||
|
||||
$curentry{'hwaddress'} = "$type $hw";
|
||||
}
|
||||
|
||||
|
||||
sub parse_range
|
||||
{
|
||||
local ($tmp, $str);
|
||||
|
||||
$str = remaining_line ();
|
||||
|
||||
if (!($str eq ''))
|
||||
{
|
||||
$str =~ s/;$//;
|
||||
push (@{$curentry{'ranges'}}, $str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub parse_statement
|
||||
{
|
||||
local ($token) = shift;
|
||||
local ($str);
|
||||
|
||||
if ($token eq 'option')
|
||||
{
|
||||
$str = remaining_line ();
|
||||
push (@{$curentry{'options'}}, $str);
|
||||
}
|
||||
elsif($token eq 'failover')
|
||||
{
|
||||
$str = remaining_line (1); # take care on block
|
||||
if($str =~ /[{]/)
|
||||
{
|
||||
my ($peername, @statements);
|
||||
|
||||
parse_error() if($str !~ /^\s*peer\s+(.+?)\s+[{]\s*$/);
|
||||
parse_error() if(($peername = $1) !~ /^\"?[^\"]+\"?$/);
|
||||
|
||||
#
|
||||
# failover config block found:
|
||||
# e.g. 'failover peer "some-name" {'
|
||||
#
|
||||
if(not grep(/FaIlOvEr/i, @use))
|
||||
{
|
||||
print STDERR "Warning: Failover config 'peer $peername' found!\n";
|
||||
print STDERR " Skipping it, since failover disabled!\n";
|
||||
print STDERR " You may try out --use=failover option.\n";
|
||||
}
|
||||
|
||||
until($str =~ /[}]/ or $str eq "")
|
||||
{
|
||||
$str = remaining_line (1);
|
||||
# collect all statements, except ending '}'
|
||||
push(@statements, $str) if($str !~ /[}]/);
|
||||
}
|
||||
$failover{$peername} = [@statements];
|
||||
}
|
||||
else
|
||||
{
|
||||
#
|
||||
# pool reference to failover config is fine
|
||||
# e.g. 'failover peer "some-name";'
|
||||
#
|
||||
if(not grep(/FaIlOvEr/i, @use))
|
||||
{
|
||||
print STDERR "Warning: Failover reference '$str' found!\n";
|
||||
print STDERR " Skipping it, since failover disabled!\n";
|
||||
print STDERR " You may try out --use=failover option.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
push (@{$curentry{'statements'}}, $token. " " . $str);
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($token eq 'zone')
|
||||
{
|
||||
$str = $token;
|
||||
while($str !~ /}$/) {
|
||||
$str .= ' ' . next_token (0);
|
||||
}
|
||||
push (@{$curentry{'statements'}}, $str);
|
||||
}
|
||||
elsif($token =~ /^(authoritative)[;]*$/)
|
||||
{
|
||||
push (@{$curentry{'statements'}}, $1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $token . " " . remaining_line ();
|
||||
push (@{$curentry{'statements'}}, $str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $ok = GetOptions(
|
||||
'basedn=s' => \$basedn,
|
||||
'dhcpdn=s' => \$dhcpdn,
|
||||
'server=s' => \$server,
|
||||
'second=s' => \$second,
|
||||
'conf=s' => \$i_conf,
|
||||
'ldif=s' => \$o_ldif,
|
||||
'use=s' => \@use,
|
||||
'h|help|usage' => sub { usage(0); },
|
||||
);
|
||||
|
||||
unless($server =~ /^\w+/)
|
||||
{
|
||||
usage(1, "invalid server name '$server'");
|
||||
}
|
||||
unless($basedn =~ /^\w+=[^,]+/)
|
||||
{
|
||||
usage(1, "invalid base dn '$basedn'");
|
||||
}
|
||||
|
||||
if($dhcpdn =~ /^cn=([^,]+)/i)
|
||||
{
|
||||
$dhcpcn = "$1";
|
||||
}
|
||||
$second = '' if not defined $second;
|
||||
unless($second eq '' or $second =~ /^cn=[^,]+\s*,\s*\w+=[^,]+/i)
|
||||
{
|
||||
if($second =~ /^cn=[^,]+$/i)
|
||||
{
|
||||
# relative DN 'cn=name'
|
||||
$second = "$second, $basedn";
|
||||
}
|
||||
elsif($second =~ /^\w+/)
|
||||
{
|
||||
# assume hostname only
|
||||
$second = "cn=$second, $basedn";
|
||||
}
|
||||
else
|
||||
{
|
||||
usage(1, "invalid secondary '$second'")
|
||||
}
|
||||
}
|
||||
|
||||
usage(1) unless($ok);
|
||||
|
||||
if($i_conf ne "" and -f $i_conf)
|
||||
{
|
||||
if(not open(STDIN, '<', $i_conf))
|
||||
{
|
||||
print STDERR "Error: can't open conf file '$i_conf': $!\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if($o_ldif ne "")
|
||||
{
|
||||
if(-e $o_ldif)
|
||||
{
|
||||
print STDERR "Error: output ldif name '$o_ldif' already exists!\n";
|
||||
exit(1);
|
||||
}
|
||||
if(not open(STDOUT, '>', $o_ldif))
|
||||
{
|
||||
print STDERR "Error: can't open ldif file '$o_ldif': $!\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print STDERR "Creating LDAP Configuration with the following options:\n";
|
||||
print STDERR "\tBase DN: $basedn\n";
|
||||
print STDERR "\tDHCP DN: $dhcpdn\n";
|
||||
print STDERR "\tServer DN: cn=$server, $basedn\n";
|
||||
print STDERR "\tSecondary DN: $second\n"
|
||||
if(grep(/FaIlOvEr/i, @use) and $second ne '');
|
||||
print STDERR "\n";
|
||||
|
||||
my $token;
|
||||
my $token_number = 0;
|
||||
my $line_number = 0;
|
||||
my %curentry;
|
||||
my $cursubnet = '';
|
||||
my %curcounter = ( '' => { pool => 0, group => 0 } );
|
||||
|
||||
$current_dn = "$dhcpdn";
|
||||
$curentry{'descr'} = $dhcpcn;
|
||||
$line = '';
|
||||
%failover = ();
|
||||
|
||||
while (($token = next_token (1)))
|
||||
{
|
||||
if ($token eq '}')
|
||||
{
|
||||
print_entry () if %curentry;
|
||||
if($current_dn =~ /.+?,\s*${dhcpdn}$/) {
|
||||
# don't go below dhcpdn ...
|
||||
remove_dn_from_stack ();
|
||||
}
|
||||
}
|
||||
elsif ($token eq 'subnet')
|
||||
{
|
||||
parse_subnet ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'shared-network')
|
||||
{
|
||||
parse_shared_network ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'class')
|
||||
{
|
||||
parse_class ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'subclass')
|
||||
{
|
||||
parse_subclass ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'pool')
|
||||
{
|
||||
parse_pool ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'group')
|
||||
{
|
||||
parse_group ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'host')
|
||||
{
|
||||
parse_host ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'hardware')
|
||||
{
|
||||
parse_hwaddress ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'range')
|
||||
{
|
||||
parse_range ();
|
||||
next;
|
||||
}
|
||||
else
|
||||
{
|
||||
parse_statement ($token);
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
close(STDIN) if($i_conf);
|
||||
close(STDOUT) if($o_ldif);
|
||||
|
||||
print STDERR "Done.\n";
|
||||
|
142
dhcpd.init
142
dhcpd.init
@ -1,142 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: dhcpd
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Should-Start:
|
||||
# Required-Start: $network
|
||||
# Required-Stop:
|
||||
# Short-Description: Start and stop the DHCP server
|
||||
# Description: dhcpd provides the Dynamic Host Configuration Protocol (DHCP)
|
||||
# server.
|
||||
### END INIT INFO
|
||||
#
|
||||
# The fields below are left around for legacy tools (will remove later).
|
||||
#
|
||||
# chkconfig: - 65 35
|
||||
# description: dhcpd provides the Dynamic Host Configuration Protocol (DHCP) \
|
||||
# server
|
||||
# processname: dhcpd
|
||||
# config: /etc/dhcpd.conf
|
||||
# config: /var/lib/dhcpd/dhcpd.leases
|
||||
# pidfile: /var/run/dhcpd.pid
|
||||
|
||||
. /etc/init.d/functions
|
||||
|
||||
RETVAL=0
|
||||
|
||||
prog=dhcpd
|
||||
dhcpd=/usr/sbin/dhcpd
|
||||
lockfile=/var/lock/subsys/dhcpd
|
||||
pidfile=/var/run/dhcpd.pid
|
||||
statedir=/var/lib/dhcpd
|
||||
|
||||
[ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd
|
||||
|
||||
# if the user specified a different config file, make sure we reference it
|
||||
findConfig() {
|
||||
for arg in $DHCPDARGS ; do
|
||||
if [ "$found" = 1 ]; then
|
||||
[ -f "$arg" ] && echo "$arg"
|
||||
return
|
||||
fi
|
||||
if [ "$arg" = "-cf" ]; then
|
||||
found=1
|
||||
continue
|
||||
fi
|
||||
done
|
||||
echo "/etc/dhcpd.conf"
|
||||
}
|
||||
|
||||
conf="$(findConfig "$DHCPDARGS")"
|
||||
|
||||
if [ ! -f $statedir/dhcpd.leases ] ; then
|
||||
mkdir -p $statedir
|
||||
touch $statedir/dhcpd.leases
|
||||
[ -x /sbin/restorecon ] && [ -d /selinux ] && /sbin/restorecon $statedir/dhcpd.leases >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
configtest() {
|
||||
[ -x $dhcpd ] || return 5
|
||||
[ -f $conf ] || return 6
|
||||
$dhcpd -q -t -cf $conf
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
start() {
|
||||
[ -x $dhcpd ] || return 5
|
||||
[ -f $conf ] || return 6
|
||||
|
||||
pidofproc $prog >/dev/null 2>&1
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && return $RETVAL
|
||||
|
||||
echo -n $"Starting $prog: "
|
||||
daemon $dhcpd $DHCPDARGS 2>/dev/null
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL = 0 ] && touch $lockfile
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
pidofproc $prog >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
RETVAL=7
|
||||
return $RETVAL
|
||||
fi
|
||||
|
||||
echo -n $"Shutting down $prog: "
|
||||
killproc $prog
|
||||
RETVAL=$?
|
||||
|
||||
[ $RETVAL = 0 ] && success || failure
|
||||
echo
|
||||
[ $RETVAL = 0 ] && rm -f $lockfile
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
RETVAL=2
|
||||
exit $RETVAL
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart|force-reload)
|
||||
stop ; start
|
||||
RETVAL=$?
|
||||
;;
|
||||
try-restart|reload)
|
||||
RETVAL=3
|
||||
;;
|
||||
condrestart)
|
||||
if [ -f $lockfile ]; then
|
||||
stop ; start
|
||||
RETVAL=$?
|
||||
fi
|
||||
;;
|
||||
configtest)
|
||||
configtest
|
||||
RETVAL=$?
|
||||
;;
|
||||
status)
|
||||
status $dhcpd
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}"
|
||||
RETVAL=3
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
125
dhcrelay.init
125
dhcrelay.init
@ -1,125 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: dhcrelay
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Should-Start:
|
||||
# Required-Start: $network
|
||||
# Required-Stop:
|
||||
# Short-Description: Start and stop the DHCP relay server
|
||||
# Description: dhcrelay provides the Dynamic Host Configuration Protocol (DHCP)
|
||||
# relay server. This is required when your DHCP server is on
|
||||
# another network segment from the clients.
|
||||
### END INIT INFO
|
||||
#
|
||||
# The fields below are left around for legacy tools (will remove later).
|
||||
#
|
||||
# chkconfig: - 65 35
|
||||
# description: dhcrelay provides a relay for Dynamic Host Control Protocol.
|
||||
# processname: dhcrelay
|
||||
# # pidfile: /var/run/dhcrelay.pid
|
||||
|
||||
. /etc/init.d/functions
|
||||
|
||||
RETVAL=0
|
||||
|
||||
prog=dhcrelay
|
||||
dhcrelay=/usr/sbin/dhcrelay
|
||||
lockfile=/var/lock/subsys/dhcrelay
|
||||
pidfile=/var/run/dhcrelay.pid
|
||||
conf=/etc/sysconfig/dhcrelay
|
||||
|
||||
# The dhcrelay daemon uses the sysconfig file for configuration information.
|
||||
# There is no native configuration file for this program and you must specify
|
||||
# its settings on the command line.
|
||||
[ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay
|
||||
|
||||
configtest() {
|
||||
[ -x $dhcrelay ] || exit 5
|
||||
[ -f $conf ] || exit 6
|
||||
[ -z "$DHCPSERVERS" ] && exit 6
|
||||
RETVAL=0
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
start() {
|
||||
[ -x $dhcrelay ] || exit 5
|
||||
[ -f $conf ] || exit 6
|
||||
|
||||
pidofproc $prog >/dev/null 2>&1
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && return $RETVAL
|
||||
|
||||
echo -n $"Starting $prog: "
|
||||
daemon $dhcrelay $([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) $DHCPSERVERS 2>/dev/null
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch $lockfile
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
pidofproc $prog >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
RETVAL=7
|
||||
return $RETVAL
|
||||
fi
|
||||
|
||||
echo -n $"Shutting down $prog: "
|
||||
killproc $prog -TERM
|
||||
RETVAL=$?
|
||||
|
||||
[ $RETVAL = 0 ] && success || failure
|
||||
echo
|
||||
[ $RETVAL = 0 ] && rm -f $lockfile
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
if [ ! -x $dhcrelay ]; then
|
||||
RETVAL=5
|
||||
exit $RETVAL
|
||||
fi
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
RETVAL=2
|
||||
exit $RETVAL
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart|force-reload)
|
||||
stop && start
|
||||
RETVAL=$?
|
||||
;;
|
||||
try-restart|reload)
|
||||
RETVAL=3
|
||||
;;
|
||||
condrestart)
|
||||
if [ -f $lockfile ]; then
|
||||
stop && start
|
||||
RETVAL=$?
|
||||
fi
|
||||
;;
|
||||
configtest)
|
||||
configtest
|
||||
RETVAL=$?
|
||||
;;
|
||||
status)
|
||||
status $prog
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}"
|
||||
RETVAL=3
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Fetch latest version of LDAP patch. The patch is downloaded and split in
|
||||
# the ldap/ subdirectory. It is up to the packager to merge the updates with
|
||||
# the RPM.
|
||||
#
|
||||
# Upstream: http://home.ntelos.net/~masneyb/
|
||||
#
|
||||
# David Cantrell <dcantrell@redhat.com>
|
||||
#
|
||||
|
||||
CWD=$(pwd)
|
||||
|
||||
rm -f masneyb.html-$$
|
||||
wget -O masneyb.html-$$ http://home.ntelos.net/~masneyb
|
||||
p="$(grep "ldap-patch" masneyb.html-$$ | cut -d '>' -f 3 | cut -d '<' -f 1)"
|
||||
rm -f masneyb.html-$$
|
||||
|
||||
rm -rf ldap/
|
||||
mkdir -p ldap/
|
||||
cd ldap/
|
||||
wget -N http://home.ntelos.net/~masneyb/$p
|
||||
splitdiff -a -d $p
|
||||
rm -f $p
|
||||
|
||||
rm -f *_debian_*
|
@ -1,5 +0,0 @@
|
||||
Name: libdhcp4client
|
||||
Description: ISC DHCP IPv4 client library
|
||||
Version: @DHCP_VERSION@
|
||||
Libs: -ldhcp4client
|
||||
Cflags: -I/usr/include/dhcp4client
|
@ -1,132 +0,0 @@
|
||||
/* libdhcp_control.h
|
||||
*
|
||||
* DHCP client control API for libdhcp, a minimal interface to the
|
||||
* ISC dhcp IPv4 client libdhcp4client library,
|
||||
* and to the dhcpv6 DHCPv6 client libdhcp6client library.
|
||||
*
|
||||
* Each DHCP client library must include this file to be controlled
|
||||
* by libdhcp.
|
||||
*
|
||||
* Copyright (C) 2006 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions of
|
||||
* the GNU General Public License v.2, or (at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY expressed or implied, including the implied warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details. You should have received a copy of the
|
||||
* GNU General Public License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
||||
* source code or documentation are not subject to the GNU General Public
|
||||
* License and may only be used or replicated with the express permission of
|
||||
* Red Hat, Inc.
|
||||
*
|
||||
* Red Hat Author(s): Jason Vas Dias
|
||||
* David Cantrell <dcantrell@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef LIBDHCP_CONTROL_H
|
||||
#define LIBDHCP_CONTROL_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define LOG_FATAL 8
|
||||
|
||||
typedef enum dhcp_state_e {
|
||||
/* DHCPv4 client states
|
||||
* third callback arg will be a 'struct client_state *'
|
||||
*/
|
||||
DHC4_NBI, /* failed: no broadcast interfaces found */
|
||||
DHC4_PREINIT, /* configuration started - bring the interface "UP" */
|
||||
DHC4_BOUND, /* lease obtained */
|
||||
DHC4_RENEW, /* lease renewed */
|
||||
DHC4_REBOOT, /* have valid lease, but now obtained a different one */
|
||||
DHC4_REBIND, /* new, different lease */
|
||||
DHC4_STOP, /* remove old lease */
|
||||
DHC4_MEDIUM, /* media selection begun */
|
||||
DHC4_TIMEOUT, /* timed out contacting DHCP server */
|
||||
DHC4_FAIL, /* all attempts to contact server timed out, sleeping */
|
||||
DHC4_EXPIRE, /* lease has expired, renewing */
|
||||
DHC4_RELEASE, /* releasing lease */
|
||||
|
||||
/* This state raised by both clients: */
|
||||
DHC_TIMEDOUT, /* libdhcp_control timeout has been exceeded */
|
||||
|
||||
/* DHCPv6 client states: */
|
||||
DHC6_BOUND, /* new lease obtained - arg is optinfo * */
|
||||
DHC6_REBIND, /* existing expired lease rebound - arg is optinfo * */
|
||||
DHC6_RELEASE /* existing lease expired - arg is dhcp6_iaidaddr*/
|
||||
} DHCP_State;
|
||||
|
||||
struct libdhcp_control_s;
|
||||
|
||||
/* ala syslog(3): LOG_EMERG=0 - LOG_DEBUG=7 (+ LOG_FATAL=8 : finished -> 1) */
|
||||
typedef int (*LIBDHCP_Error_Handler) (struct libdhcp_control_s *ctl,
|
||||
int priority, const char *fmt,
|
||||
va_list ap);
|
||||
|
||||
/* The DHCP clients will call the users' callback on important state change
|
||||
* events, with the second arg set to the client DHCP_State, and the third
|
||||
* arg set to a client specific pointer as described below. */
|
||||
typedef int (*LIBDHCP_Callback) (struct libdhcp_control_s *control,
|
||||
enum dhcp_state_e, void*);
|
||||
|
||||
typedef struct libdhcp_control_s {
|
||||
/* the DHCP clients' main loop calls this on state changes */
|
||||
LIBDHCP_Callback callback;
|
||||
|
||||
/* LIBDHCP_Capability bits to enable */
|
||||
uint16_t capability;
|
||||
|
||||
/* set to one to make clients exit their main loop */
|
||||
uint8_t finished;
|
||||
|
||||
/* set to one to decline the lease (DHCPv4 only) */
|
||||
uint8_t decline;
|
||||
|
||||
/* (timeout+now) == time after which clients MUST return */
|
||||
time_t timeout;
|
||||
|
||||
/* clients set this to time(0) on entering main loop */
|
||||
time_t now;
|
||||
|
||||
/* user data pointer */
|
||||
void *arg;
|
||||
LIBDHCP_Error_Handler eh;
|
||||
} LIBDHCP_Control;
|
||||
|
||||
/* DHCP client "capabilities" */
|
||||
typedef enum libdhcp_capability_e {
|
||||
/* use / do not use persistent lease database files */
|
||||
DHCP_USE_LEASE_DATABASE = 1,
|
||||
|
||||
/* use / do not use pid file */
|
||||
DHCP_USE_PID_FILE = 2,
|
||||
|
||||
/*
|
||||
* DHCPv6 supports these capabilities in process,
|
||||
* while the DHCPv4 client will fork and exec the dhclient-script to
|
||||
* implement them if these bits are set - otherwise, if no bits are set,
|
||||
* the callback is called and the script is not run.
|
||||
*/
|
||||
/* configure interfaces UP/DOWN as required */
|
||||
DHCP_CONFIGURE_INTERFACES = 4,
|
||||
|
||||
/* configure interface addresses as required */
|
||||
DHCP_CONFIGURE_ADDRESSES = 8,
|
||||
|
||||
/* configure routes as required */
|
||||
DHCP_CONFIGURE_ROUTES = 16,
|
||||
|
||||
/* configure resolv.conf as required */
|
||||
DHCP_CONFIGURE_RESOLVER = 32,
|
||||
|
||||
/* DHCPv6 only: */
|
||||
/* configure radvd.conf & restart radvd as required */
|
||||
DHCP_CONFIGURE_RADVD = 64,
|
||||
} LIBDHCP_Capability;
|
||||
|
||||
#endif
|
557
linux
557
linux
@ -1,557 +0,0 @@
|
||||
#!/bin/bash
|
||||
# dhclient-script for Linux. Dan Halbert, March, 1997.
|
||||
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
|
||||
# No guarantees about this. I'm a novice at the details of Linux
|
||||
# networking.
|
||||
#
|
||||
# Modified by David Cantrell <dcantrell@redhat.com> for Fedora and RHEL
|
||||
|
||||
# Notes:
|
||||
|
||||
# 0. This script is based on the netbsd script supplied with dhcp-970306.
|
||||
|
||||
# 1. ifconfig down apparently deletes all relevant routes and flushes
|
||||
# the arp cache, so this doesn't need to be done explicitly.
|
||||
|
||||
# 2. The alias address handling here has not been tested AT ALL.
|
||||
# I'm just going by the doc of modern Linux ip aliasing, which uses
|
||||
# notations like eth0:0, eth0:1, for each alias.
|
||||
|
||||
# 3. I have to calculate the network address, and calculate the broadcast
|
||||
# address if it is not supplied. This might be much more easily done
|
||||
# by the dhclient C code, and passed on.
|
||||
|
||||
PATH=/bin:/usr/bin
|
||||
|
||||
function save_previous() {
|
||||
if [ -e $1 ]; then
|
||||
mv $1 $1.predhclient
|
||||
else
|
||||
echo ''> $1.predhclient
|
||||
fi
|
||||
}
|
||||
|
||||
make_resolv_conf() {
|
||||
if [ "${PEERDNS}" == "no" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ x$reason == xRENEW ] &&
|
||||
[ "$new_domain_name" == "$old_domain_name" ] &&
|
||||
[ "$new_domain_name_servers" == "$old_domain_name_servers" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -n "$new_domain_name" ] || [ -n "$new_domain_name_servers" ]; then
|
||||
cp -fp /etc/resolv.conf /etc/resolv.conf.predhclient
|
||||
rscf=`mktemp /tmp/XXXXXX`;
|
||||
echo '; generated by /sbin/dhclient-script' > $rscf
|
||||
|
||||
if [ -n "$SEARCH" ]; then
|
||||
echo search $SEARCH >> $rscf
|
||||
else
|
||||
if [ -n "$new_domain_name" ]; then
|
||||
echo search $new_domain_name >> $rscf
|
||||
fi
|
||||
fi
|
||||
|
||||
for nameserver in $new_domain_name_servers; do
|
||||
echo nameserver $nameserver >> $rscf
|
||||
done
|
||||
|
||||
change_resolv_conf $rscf
|
||||
rm -f $rscf
|
||||
fi
|
||||
}
|
||||
|
||||
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
|
||||
exit_with_hooks() {
|
||||
exit_status=$1
|
||||
|
||||
if [ -f /etc/dhclient-exit-hooks ]; then
|
||||
. /etc/dhclient-exit-hooks
|
||||
fi
|
||||
|
||||
# probably should do something with exit status of the local script
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
# Invoke the local dhcp client enter hooks, if they exist.
|
||||
if [ -f /etc/dhclient-enter-hooks ]; then
|
||||
exit_status=0
|
||||
. /etc/dhclient-enter-hooks
|
||||
# allow the local script to abort processing of this state
|
||||
# local script must set exit_status variable to nonzero.
|
||||
if [ $exit_status -ne 0 ]; then
|
||||
exit $exit_status
|
||||
fi
|
||||
fi
|
||||
|
||||
# Import Red Hat Linux configuration
|
||||
cd /etc/sysconfig/network-scripts;
|
||||
. /etc/sysconfig/network-scripts/network-functions
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
[ -f ../network ] && . ../network
|
||||
[ -f ../networking/network ] && . ../networking/network
|
||||
|
||||
CONFIG=$interface
|
||||
|
||||
need_config ${CONFIG}
|
||||
|
||||
if [ -f "${CONFIG}" ]; then
|
||||
source_config
|
||||
else
|
||||
echo $"$0: configuration for $interface not found. Continuing with defaults." >&2
|
||||
fi
|
||||
|
||||
source_config
|
||||
|
||||
release=$(uname -r)
|
||||
relmajor=$(echo $release | cut -f1 -d'.')
|
||||
relminor=$(echo $release | cut -f2 -d'.')
|
||||
|
||||
# simple IP arithmetic functions:
|
||||
function quad2num() {
|
||||
if [ $# -eq 4 ]; then
|
||||
let n="$1<<24|$2<<16|$3<<8|$4"
|
||||
echo $n
|
||||
return 0
|
||||
fi
|
||||
echo '0'
|
||||
return 1
|
||||
}
|
||||
|
||||
function ip2num() {
|
||||
IFS='.' quad2num $1
|
||||
}
|
||||
|
||||
function num2ip() {
|
||||
let n="$1"
|
||||
let o1='(n>>24)&0xff'
|
||||
let o2='(n>>16)&0xff'
|
||||
let o3='(n>>8)&0xff'
|
||||
let o4='n & 0xff'
|
||||
echo $o1.$o2.$o3.$o4
|
||||
}
|
||||
|
||||
function mask() {
|
||||
ip=$1
|
||||
m=$2
|
||||
let ip=$(IFS='.' ip2num $ip)
|
||||
let m=$(IFS='.' ip2num $m)
|
||||
let n='ip&m'
|
||||
num2ip $n
|
||||
}
|
||||
|
||||
function mask_bits() {
|
||||
ip=$1
|
||||
let ip=$(IFS='.' ip2num $ip)
|
||||
let bits=0
|
||||
for ((bit=1; '((ip&bit)==0) && (bits < 32)'; 'bit<<=1')) do
|
||||
let bits+=1
|
||||
done
|
||||
let n_bits=32-bits
|
||||
echo $n_bits
|
||||
}
|
||||
|
||||
function class_bits() {
|
||||
let ip=$(IFS='.' ip2num $1)
|
||||
let bits=32
|
||||
let mask='255'
|
||||
for ((i=0; i <= 3; i++, 'mask<<=8')); do
|
||||
let v='ip&mask'
|
||||
if [ "$v" -eq 0 ] ; then
|
||||
let bits-=8
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo $bits
|
||||
}
|
||||
|
||||
function routerReachable() {
|
||||
# Handle silly DHCP servers that give us a router not on our subnet:
|
||||
router=$1
|
||||
routerSubnet=$(mask $router $new_subnet_mask)
|
||||
mySubnet=$(mask $new_ip_address $new_subnet_mask)
|
||||
unreachable=0
|
||||
if [ "$routerSubnet" != "$mySubnet" ]; then
|
||||
unreachable=1
|
||||
if /sbin/arping -f -q -I $interface -w2 $router; then
|
||||
/sbin/ip route add ${router}/32 dev $interface
|
||||
if [ $? -eq 0 ]; then
|
||||
unreachable=0
|
||||
else
|
||||
/usr/bin/logger -p local7.notice -t "NET" "dhclient: failed to create host route for unreachable router $router not on subnet $mySubnet";
|
||||
fi
|
||||
else
|
||||
unreachable=1
|
||||
if [ -x /usr/bin/logger ]; then
|
||||
/usr/bin/logger -p local7.notice -t "NET" "dhclient: DHCP router $router is unreachable on DHCP subnet $mySubnet router subnet $routerSubnet";
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
return $unreachable
|
||||
}
|
||||
|
||||
function add_default_gateway() {
|
||||
router=$1
|
||||
metric=''
|
||||
if [ $# -gt 1 ] && [ "$2" -gt 0 ]; then
|
||||
metric="metric $2"
|
||||
fi
|
||||
if routerReachable $router ; then
|
||||
/sbin/ip route replace default via $router dev $interface $metric
|
||||
if [ $? -ne 0 ]; then
|
||||
/usr/bin/logger -p local7.notice -t "NET" 'dhclient: failed to create default route: '$router dev $interface $metric
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function dhconfig() {
|
||||
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && [ x$alias_ip_address != x$old_ip_address ]; then
|
||||
# Possible new alias. Remove old alias.
|
||||
ifconfig $interface:0- inet 0
|
||||
fi
|
||||
|
||||
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
|
||||
# IP address changed. Bringing down the interface will delete all
|
||||
# routes, and clear the ARP cache.
|
||||
ifconfig $interface inet 0 down
|
||||
fi
|
||||
|
||||
if [ x$reason = xBOUND ] || [ x$reason = xREBOOT ] ||
|
||||
[ x$old_ip_address != x$new_ip_address ] ||
|
||||
[ x$old_subnet_mask != x$new_subnet_mask ] ||
|
||||
[ x$new_network_number != x$new_network_number ] ||
|
||||
[ x$old_broadcast_address != x$new_broadcast_address ] ||
|
||||
[ "x$old_routers" != "x$new_routers" ] ||
|
||||
[ x$old_interface_mtu != x$new_interface_mtu ] ; then
|
||||
ifconfig $interface inet $new_ip_address $new_subnet_arg $new_broadcast_arg
|
||||
if [ -n "$new_interface_mtu" ]; then
|
||||
/sbin/ip link set $interface mtu $new_interface_mtu
|
||||
fi
|
||||
|
||||
if [ -x /etc/dhclient-${interface}-up-hooks ]; then
|
||||
. /etc/dhclient-${interface}-up-hooks
|
||||
elif [ -x /etc/dhclient-up-hooks ]; then
|
||||
. /etc/dhclient-up-hooks
|
||||
fi
|
||||
|
||||
prefix_bits=$(mask_bits $new_subnet_mask)
|
||||
# Add a network route to the computed network address.
|
||||
if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
|
||||
/sbin/ip route replace ${new_network_number}/${prefix_bits} dev $interface
|
||||
if [ $added_old_broadcast_route -eq 1 ]; then
|
||||
/sbin/ip route del default
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ (( -z "$GATEWAYDEV" ) || ( "$GATEWAYDEV" = "$interface" )) && (( -z "$GATEWAY" ) || (( -n "$DHCLIENT_IGNORE_GATEWAY" ) && ( "$DHCLIENT_IGNORE_GATEWAY" = [Yy]* ))) ]]; then
|
||||
metric=${METRIC:-''}
|
||||
let i=${METRIC:-0}
|
||||
default_routers=()
|
||||
|
||||
for router in $new_routers; do
|
||||
added_router=0
|
||||
|
||||
for r in ${default_routers[@]}; do
|
||||
if [ "$r" == "$router" ]; then
|
||||
added_router=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$router" ] || [ "$added_router" -eq 1 ] || [ $(IFS=. ip2num $router) -le 0 ] || [[ ( "$router" = "$new_broadcast_address" ) && ( "$new_subnet_mask" != "255.255.255.255" ) ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
default_routers=(${default_routers[@]} $router)
|
||||
add_default_gateway $router $metric
|
||||
let i=i+1
|
||||
metric=$i
|
||||
done
|
||||
elif [[ (( -z "$GATEWAYDEV" ) || ( "$GATEWAYDEV" = "$interface" )) && ( -n "$GATEWAY" ) ]]; then
|
||||
routerSubnet=$(mask $GATEWAY $new_subnet_mask)
|
||||
mySubnet=$(mask $new_ip_address $new_subnet_mask)
|
||||
|
||||
if [ "$routerSubnet" = "$mySubnet" ]; then
|
||||
/sbin/ip route replace default via $GATEWAY dev $interface
|
||||
fi
|
||||
fi
|
||||
|
||||
# static routes
|
||||
if [ "x$new_static_routes" != x ]; then
|
||||
IFS=', ' static_routes=($new_static_routes)
|
||||
route_targets=()
|
||||
|
||||
for((i=0; i<${#static_routes[@]}; i+=2)); do
|
||||
target=${static_routes[$i]}
|
||||
gateway=${static_routes[$i+1]}
|
||||
metric=''
|
||||
|
||||
for t in ${route_targets[@]}; do
|
||||
if [ $t == $target ]; then
|
||||
if [ -z "$metric" ]; then
|
||||
metric=1
|
||||
else
|
||||
((metric=metric+1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$metric" ]; then
|
||||
metric="metric $metric"
|
||||
fi
|
||||
|
||||
if routerReachable $gateway; then
|
||||
/sbin/ip route replace ${target}/$(class_bits $target) via ${gateway} dev $interface ${metric}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
/usr/bin/logger -p local7.notice -t 'NET' 'dhclient: failed to create static route:' ${target}/`class_bits $target` via ${gateway} dev $interface ${metric}
|
||||
else
|
||||
route_targets=(${route_targets[@]} $target)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; then
|
||||
ifconfig $interface:0- inet 0
|
||||
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
/sbin/ip route replace ${alias_ip_address}/32 dev $interface:0
|
||||
fi
|
||||
|
||||
make_resolv_conf
|
||||
|
||||
if [ -n "$new_host_name" ] && need_hostname; then
|
||||
hostname $new_host_name
|
||||
fi
|
||||
|
||||
if [ "${PEERNIS}" = no ]; then
|
||||
:
|
||||
elif [ -n "$new_nis_domain" ]; then
|
||||
domainname "$new_nis_domain"
|
||||
save_previous /etc/yp.conf
|
||||
let contents=0
|
||||
echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
|
||||
|
||||
if [ -n "$new_nis_servers" ]; then
|
||||
for I in $new_nis_servers; do
|
||||
echo "domain $new_nis_domain server $I" >> /etc/yp.conf
|
||||
let contents=contents+1
|
||||
done
|
||||
else
|
||||
echo "domain $new_nis_domain broadcast" >> /etc/yp.conf
|
||||
let contents=contents+1
|
||||
fi
|
||||
|
||||
if [ $contents -gt 0 ] && [ -r /var/run/ypbind.pid ] && yppid=$(cat /var/run/ypbind.pid) && [ -d /proc/${yppid} ] && [ "$(if [ -x /usr/bin/readlink ]; then readlink /proc/${yppid}/exe; else echo /sbin/ypbind; fi)" = "/sbin/ypbind" ]; then
|
||||
kill -HUP $yppid
|
||||
fi
|
||||
elif [ -n "$new_nis_servers" ]; then
|
||||
save_previous /etc/yp.conf
|
||||
echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
|
||||
let contents=0
|
||||
|
||||
for I in $new_nis_servers; do
|
||||
echo "ypserver $I" >> /etc/yp.conf
|
||||
let contents=contents+1
|
||||
done
|
||||
|
||||
if [ $contents -gt 0 ] && [ -r /var/run/ypbind.pid ] && yppid=$(cat /var/run/ypbind.pid) && [ -d /proc/${yppid} ] && [ "$(if [ -x /usr/bin/readlink ]; then readlink /proc/${yppid}/exe; else echo /sbin/ypbind; fi)" = "/sbin/ypbind" ]; then
|
||||
kill -HUP $yppid
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$DHCP_TIME_OFFSET_SETS_TIMEZONE" ] && [[ "$DHCP_TIME_OFFSET_SETS_TIMEZONE" = [yY1]* ]]; then
|
||||
if [ -n "$new_time_offset" ]; then
|
||||
# DHCP option "time-offset" is requested by default and should be
|
||||
# handled. The geographical zone abbreviation cannot be determined
|
||||
# from the GMT offset, but the $ZONEINFO/Etc/GMT$offset file can be
|
||||
# used - note: this disables DST.
|
||||
((z=new_time_offset/3600))
|
||||
((hoursWest=$(printf '%+d' $z)))
|
||||
|
||||
if (( $hoursWest < 0 )); then
|
||||
# tzdata treats negative 'hours west' as positive 'gmtoff'!
|
||||
((hoursWest*=-1))
|
||||
fi
|
||||
|
||||
tzfile=/usr/share/zoneinfo/Etc/GMT$(printf '%+d' $hoursWest)
|
||||
if [ -e $tzfile ]; then
|
||||
/bin/mv -f /etc/localtime /etc/localtime.predhclient
|
||||
/bin/cp -fp $tzfile /etc/localtime
|
||||
/bin/touch /etc/localtime
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${PEERNTP}" = no ]; then
|
||||
:
|
||||
elif [ -n "$new_ntp_servers" ] && [ -e /etc/ntp.conf ]; then
|
||||
save_previous /etc/ntp.conf
|
||||
/bin/egrep -v '^server .* # added by /sbin/dhclient-script$'< /etc/ntp.conf.predhclient > /etc/ntp.conf
|
||||
|
||||
for s in $new_ntp_servers; do
|
||||
echo "server $s # added by /sbin/dhclient-script" >> /etc/ntp.conf
|
||||
done
|
||||
|
||||
if [ -x /usr/bin/diff ] && /usr/bin/diff -q /etc/ntp.conf /etc/ntp.conf.predhclient >/dev/null 2>&1; then
|
||||
:
|
||||
else
|
||||
/sbin/service ntpd condrestart >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ x$new_broadcast_address != x ] && [ x$new_subnet_mask != x ] && [ "$new_subnet_mask" != "255.255.255.255" ]; then
|
||||
new_broadcast_arg="broadcast $new_broadcast_address"
|
||||
fi
|
||||
|
||||
if [ x$old_broadcast_address != x ]; then
|
||||
old_broadcast_arg="broadcast $old_broadcast_address"
|
||||
fi
|
||||
|
||||
if [ x$new_subnet_mask != x ]; then
|
||||
new_subnet_arg="netmask $new_subnet_mask"
|
||||
fi
|
||||
|
||||
if [ x$old_subnet_mask != x ]; then
|
||||
old_subnet_arg="netmask $old_subnet_mask"
|
||||
fi
|
||||
|
||||
if [ x$alias_subnet_mask != x ]; then
|
||||
alias_subnet_arg="netmask $alias_subnet_mask"
|
||||
fi
|
||||
|
||||
if [ x$reason = xMEDIUM ]; then
|
||||
# Linux doesn't do mediums (ok, ok, media).
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
added_old_broadcast_route=0
|
||||
if [ x$reason = xPREINIT ]; then
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
# Bring down alias interface. Its routes will disappear too.
|
||||
ifconfig $interface:0- inet 0
|
||||
fi
|
||||
|
||||
if [ x$keep_old_ip = xyes ]; then
|
||||
ifconfig $interface up
|
||||
elif [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ) then
|
||||
ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up
|
||||
# Add route to make broadcast work. Do not omit netmask.
|
||||
/sbin/ip route replace default dev $interface && added_old_broadcast_route=1
|
||||
else
|
||||
ifconfig $interface 0 up
|
||||
fi
|
||||
|
||||
# We need to give the kernel some time to get the interface up.
|
||||
# sleep 1
|
||||
# I don't think this is necessary with modern kernels - no problems found
|
||||
# during testing - JVD, 2005-06-17
|
||||
# but just in case:
|
||||
if [ -n "$DHCLIENT_DELAY" ] && [ "$DHCLIENT_DELAY" -gt 0 ] ; then
|
||||
sleep $DHCLIENT_DELAY
|
||||
fi
|
||||
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
|
||||
if [ -z "$new_ip_address" ] || [ -z "$interface" ] || /sbin/arping -q -f -c 2 -w 3 -D -I ${interface} ${new_ip_address}; then
|
||||
exit_with_hooks 0
|
||||
else
|
||||
exit_with_hooks 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
||||
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
|
||||
dhconfig
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|
||||
|| [ x$reason = xSTOP ]; then
|
||||
if [ -f /etc/resolv.conf.predhclient ]; then
|
||||
change_resolv_conf /etc/resolv.conf.predhclient
|
||||
rm -f /etc/resolv.conf.predhclient
|
||||
fi
|
||||
|
||||
if [ -n "$DHCP_TIME_OFFSET_SETS_TIMEZONE" ] && [[ "$DHCP_TIME_OFFSET_SETS_TIMEZONE" = [yY1]* ]]; then
|
||||
if [ -e /etc/localtime.predhclient ]; then
|
||||
/bin/rm -f /etc/localtime
|
||||
/bin/mv -f /etc/localtime.predhclient /etc/localtime
|
||||
/bin/touch /etc/localtime
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f /etc/ntp.conf.predhclient ]; then
|
||||
/bin/rm -f /etc/ntp.conf
|
||||
/bin/mv -f /etc/ntp.conf.predhclient /etc/ntp.conf
|
||||
service ntpd condrestart >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ -f /etc/yp.conf.predhclient ]; then
|
||||
/bin/rm -f /etc/yp.conf
|
||||
/bin/mv -f /etc/yp.conf.predhclient /etc/yp.conf
|
||||
|
||||
if [ -r /var/run/ypbind.pid ] && yppid=$(cat /var/run/ypbind.pid) && [ -d /proc/${yppid} ] && [ "$(if [ -x /usr/bin/readlink ]; then readlink /proc/${yppid}/exe; else echo /sbin/ypbind; fi)" = "/sbin/ypbind" ]; then
|
||||
kill -HUP $yppid
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -x /etc/dhclient-${interface}-down-hooks ]; then
|
||||
. /etc/dhclient-${interface}-down-hooks
|
||||
elif [ -x /etc/dhclient-down-hooks ]; then
|
||||
. /etc/dhclient-down-hooks
|
||||
fi
|
||||
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
# Turn off alias interface.
|
||||
ifconfig $interface:0- inet 0
|
||||
fi
|
||||
|
||||
if [ x$old_ip_address != x ]; then
|
||||
# Shut down interface, which will delete routes and clear arp cache.
|
||||
ifconfig $interface inet 0 down
|
||||
fi
|
||||
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
/sbin/ip route replace ${alias_ip_address}/32 $interface:0
|
||||
fi
|
||||
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
if [ x$reason = xTIMEOUT ] && [ "x$new_routers" != 'x' ]; then
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
ifconfig $interface:0- inet 0
|
||||
fi
|
||||
|
||||
ifconfig $interface inet $new_ip_address $new_subnet_arg $new_broadcast_arg
|
||||
set $new_routers
|
||||
|
||||
if ping -q -c 1 -w 10 -I $interface $1; then
|
||||
dhconfig
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
|
||||
ifconfig $interface inet 0 down
|
||||
fi
|
||||
|
||||
exit_with_hooks 1
|
||||
elif [ x$reason = xTIMEOUT ]; then
|
||||
exit_with_hooks 1
|
||||
fi
|
||||
|
||||
exit_with_hooks 0
|
Loading…
Reference in New Issue
Block a user