1999-02-07 19:46:13 +00:00
|
|
|
--- client/dhcpc.c.orig Fri Jan 1 05:20:08 1999
|
2000-01-20 22:08:54 +00:00
|
|
|
+++ client/dhcpc.c Thu Jan 20 13:21:05 2000
|
1999-02-07 19:46:13 +00:00
|
|
|
@@ -88,6 +88,7 @@
|
1997-04-04 02:20:28 +00:00
|
|
|
struct dhcp_reqspec reqspec;
|
|
|
|
struct if_info intface;
|
|
|
|
struct dhcp_param *param_list;
|
|
|
|
+int f_resolv, f_hostname;
|
1998-05-02 15:15:28 +00:00
|
|
|
char pid_filename[MAXPATHLEN];
|
1999-02-07 19:46:13 +00:00
|
|
|
char cache_filename[MAXPATHLEN];
|
1997-04-04 02:20:28 +00:00
|
|
|
|
1999-02-07 19:46:13 +00:00
|
|
|
@@ -256,6 +257,14 @@
|
|
|
|
if (config_if(&intface, &addr, &mask, &brdaddr) == 0) {
|
|
|
|
set_route(paramp);
|
1997-04-04 02:20:28 +00:00
|
|
|
}
|
|
|
|
+#ifdef __FreeBSD__
|
|
|
|
+ if (f_resolv) {
|
1998-05-02 15:15:28 +00:00
|
|
|
+ set_resolv(param_list);
|
1997-04-04 02:20:28 +00:00
|
|
|
+ }
|
|
|
|
+ if (f_hostname) {
|
1998-05-02 15:15:28 +00:00
|
|
|
+ set_hostname(param_list);
|
1997-04-04 02:20:28 +00:00
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return;
|
1999-02-07 19:46:13 +00:00
|
|
|
@@ -293,7 +302,7 @@
|
1997-04-04 02:20:28 +00:00
|
|
|
/*
|
|
|
|
* split conditions into pieces for debugging
|
|
|
|
*/
|
|
|
|
-#ifndef sun
|
1999-02-07 19:46:13 +00:00
|
|
|
+#if !defined(sun) && !defined(__FreeBSD__)
|
|
|
|
if (ntohs(rcv.ip->ip_len) < MINDHCPLEN + UDPHL + IPHL)
|
1997-04-04 02:20:28 +00:00
|
|
|
return(0);
|
1999-02-07 19:46:13 +00:00
|
|
|
if (ntohs(rcv.udp->uh_ulen) < MINDHCPLEN + UDPHL)
|
|
|
|
@@ -350,7 +359,7 @@
|
1997-04-04 02:20:28 +00:00
|
|
|
/*
|
|
|
|
* split conditions into pieces for debugging
|
|
|
|
*/
|
|
|
|
-#ifndef sun
|
1999-02-07 19:46:13 +00:00
|
|
|
+#if !defined(sun) && !defined(__FreeBSD__)
|
|
|
|
if (ntohs(rcv.ip->ip_len) < MINDHCPLEN + UDPHL + IPHL)
|
1997-04-04 02:20:28 +00:00
|
|
|
return(0);
|
1999-02-07 19:46:13 +00:00
|
|
|
if (ntohs(rcv.udp->uh_ulen) < MINDHCPLEN + UDPHL)
|
2000-01-20 22:08:54 +00:00
|
|
|
@@ -398,11 +407,14 @@
|
|
|
|
|
|
|
|
bzero(&tmp_reqspec, sizeof(tmp_reqspec));
|
|
|
|
bzero(errmsg, sizeof(errmsg));
|
|
|
|
- bzero(&newsigmask, sizeof(newsigmask));
|
|
|
|
- bzero(&oldsigmask, sizeof(oldsigmask));
|
|
|
|
|
|
|
|
- newsigmask = sigmask(SIGUSR1) | sigmask(SIGALRM);
|
|
|
|
- oldsigmask = sigblock(newsigmask); /* begin critical */
|
|
|
|
+ sigemptyset(&newsigmask);
|
|
|
|
+
|
|
|
|
+ sigprocmask(0, NULL, &oldsigmask);
|
|
|
|
+ memcpy(&newsigmask, &oldsigmask, sizeof(sigset_t));
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR1);
|
|
|
|
+ sigaddset(&newsigmask, SIGALRM);
|
|
|
|
+ sigprocmask(SIG_SETMASK, &newsigmask, NULL);
|
|
|
|
|
|
|
|
switch (curr_state) {
|
|
|
|
case BOUND:
|
|
|
|
@@ -423,7 +435,7 @@
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
- sigsetmask(oldsigmask); /* end critical */
|
|
|
|
+ sigprocmask(SIG_SETMASK, &oldsigmask, NULL); /* end critical */
|
|
|
|
|
|
|
|
unlink(pid_filename);
|
|
|
|
|
|
|
|
@@ -1157,8 +1169,8 @@
|
|
|
|
struct dhcp_param tmpparam;
|
|
|
|
|
|
|
|
bzero(errmsg, sizeof(errmsg));
|
|
|
|
- bzero(&newsigmask, sizeof(newsigmask));
|
|
|
|
- bzero(&oldsigmask, sizeof(oldsigmask));
|
|
|
|
+ sigemptyset(&newsigmask);
|
|
|
|
+ sigemptyset(&oldsigmask);
|
|
|
|
bzero(&tmpparam, sizeof(tmpparam));
|
|
|
|
|
|
|
|
if (prev_state != RENEWING) {
|
|
|
|
@@ -1247,12 +1259,15 @@
|
|
|
|
errmsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
- newsigmask = sigmask(SIGUSR1) | sigmask(SIGUSR2);
|
|
|
|
- oldsigmask = sigblock(newsigmask); /* begin critical */
|
|
|
|
+ sigprocmask(0, NULL, &oldsigmask); /* begin critical */
|
|
|
|
+ memcpy(&newsigmask, &oldsigmask, sizeof(sigset_t));
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR1);
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR2);
|
|
|
|
+ sigprocmask(SIG_SETMASK, &newsigmask, NULL);
|
|
|
|
clean_param(param_list);
|
|
|
|
free(param_list);
|
|
|
|
param_list = NULL;
|
|
|
|
- sigsetmask(oldsigmask); /* end critical */
|
|
|
|
+ sigprocmask(SIG_SETMASK, &oldsigmask, NULL); /* end critical */
|
|
|
|
|
|
|
|
return(INIT); /* Next state is INIT */
|
|
|
|
}
|
|
|
|
@@ -1260,13 +1275,16 @@
|
|
|
|
dhcp_msgtoparam(rcv.dhcp, DHCPLEN(rcv.udp),
|
|
|
|
&tmpparam) == OK) {
|
|
|
|
|
|
|
|
- newsigmask = sigmask(SIGUSR1) | sigmask(SIGUSR2);
|
|
|
|
- oldsigmask = sigblock(newsigmask); /* begin critical */
|
|
|
|
+ sigprocmask(0, NULL, &oldsigmask);
|
|
|
|
+ memcpy(&newsigmask, &oldsigmask, sizeof(sigset_t));
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR1);
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR2);
|
|
|
|
+ sigprocmask(SIG_SETMASK, &newsigmask, NULL); /* begin critical */
|
|
|
|
merge_param(param_list, &tmpparam);
|
|
|
|
*param_list = tmpparam;
|
|
|
|
param_list->lease_origin = send_epoch;
|
|
|
|
param_list->next = NULL;
|
|
|
|
- sigsetmask(oldsigmask); /* end critical */
|
|
|
|
+ sigprocmask(SIG_SETMASK, &oldsigmask, NULL); /* end critical */
|
|
|
|
|
|
|
|
syslog(LOG_INFO, "Got DHCPACK (IP = %s, duration = %d secs)",
|
|
|
|
inet_ntoa(param_list->yiaddr), param_list->lease_duration);
|
|
|
|
@@ -1316,8 +1334,8 @@
|
|
|
|
struct dhcp_param tmpparam;
|
|
|
|
|
|
|
|
bzero(errmsg, sizeof(errmsg));
|
|
|
|
- bzero(&newsigmask, sizeof(newsigmask));
|
|
|
|
- bzero(&oldsigmask, sizeof(oldsigmask));
|
|
|
|
+ sigemptyset(&newsigmask);
|
|
|
|
+ sigemptyset(&oldsigmask);
|
|
|
|
bzero(&tmpparam, sizeof(tmpparam));
|
|
|
|
|
|
|
|
if (time(&curr_epoch) == -1) {
|
|
|
|
@@ -1386,12 +1404,15 @@
|
|
|
|
errmsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
- newsigmask = sigmask(SIGUSR1) | sigmask(SIGUSR2);
|
|
|
|
- oldsigmask = sigblock(newsigmask); /* begin critical */
|
|
|
|
+ sigprocmask(0, NULL, &oldsigmask);
|
|
|
|
+ memcpy(&newsigmask, &oldsigmask, sizeof(sigset_t));
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR1);
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR2);
|
|
|
|
+ sigprocmask(SIG_SETMASK, &newsigmask, NULL); /* begin critical */
|
|
|
|
clean_param(param_list);
|
|
|
|
free(param_list);
|
|
|
|
param_list = NULL;
|
|
|
|
- sigsetmask(oldsigmask); /* end critical */
|
|
|
|
+ sigprocmask(SIG_SETMASK, &oldsigmask, NULL); /* end critical */
|
|
|
|
|
|
|
|
return(INIT); /* Next state is INIT */
|
|
|
|
}
|
|
|
|
@@ -1399,13 +1420,16 @@
|
|
|
|
dhcp_msgtoparam(rcv.dhcp, DHCPLEN(rcv.udp),
|
|
|
|
&tmpparam) == OK) {
|
|
|
|
|
|
|
|
- newsigmask = sigmask(SIGUSR1) | sigmask(SIGUSR2);
|
|
|
|
- oldsigmask = sigblock(newsigmask); /* begin critical */
|
|
|
|
+ sigprocmask(0, NULL, &oldsigmask);
|
|
|
|
+ memcpy(&newsigmask, &oldsigmask, sizeof(sigset_t));
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR1);
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR2);
|
|
|
|
+ sigprocmask(SIG_SETMASK, &newsigmask, NULL); /* begin critical */
|
|
|
|
merge_param(param_list, &tmpparam);
|
|
|
|
*param_list = tmpparam;
|
|
|
|
param_list->lease_origin = send_epoch;
|
|
|
|
param_list->next = NULL;
|
|
|
|
- sigsetmask(oldsigmask); /* end critical */
|
|
|
|
+ sigprocmask(SIG_SETMASK, &oldsigmask, NULL); /* end critical */
|
|
|
|
|
|
|
|
syslog(LOG_INFO, "Got DHCPACK (IP = %s, duration = %d secs)",
|
|
|
|
inet_ntoa(param_list->yiaddr), param_list->lease_duration);
|
|
|
|
@@ -1577,8 +1601,8 @@
|
|
|
|
struct dhcp_reqspec tmp_reqspec;
|
|
|
|
|
|
|
|
bzero(errmsg, sizeof(errmsg));
|
|
|
|
- bzero(&newsigmask, sizeof(newsigmask));
|
|
|
|
- bzero(&oldsigmask, sizeof(oldsigmask));
|
|
|
|
+ sigemptyset(&newsigmask);
|
|
|
|
+ sigemptyset(&oldsigmask);
|
|
|
|
bzero(&tmpparam, sizeof(tmpparam));
|
|
|
|
bzero(&tmp_reqspec, sizeof(tmp_reqspec));
|
|
|
|
|
|
|
|
@@ -1666,12 +1690,15 @@
|
|
|
|
errmsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
- newsigmask = sigmask(SIGUSR1) | sigmask(SIGUSR2);
|
|
|
|
- oldsigmask = sigblock(newsigmask); /* begin critical */
|
|
|
|
+ sigprocmask(0, NULL, &oldsigmask);
|
|
|
|
+ memcpy(&newsigmask, &oldsigmask, sizeof(sigset_t));
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR1);
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR2);
|
|
|
|
+ sigprocmask(SIG_SETMASK, &newsigmask, NULL); /* begin critical */
|
|
|
|
clean_param(param_list);
|
|
|
|
free(param_list);
|
|
|
|
param_list = NULL;
|
|
|
|
- sigsetmask(oldsigmask); /* end critical */
|
|
|
|
+ sigprocmask(SIG_SETMASK, &oldsigmask, NULL); /* end critical */
|
|
|
|
|
|
|
|
return(INIT); /* Next state is INIT */
|
|
|
|
}
|
|
|
|
@@ -1679,13 +1706,16 @@
|
|
|
|
dhcp_msgtoparam(rcv.dhcp, DHCPLEN(rcv.udp),
|
|
|
|
&tmpparam) == OK) {
|
|
|
|
if ((arpans = arp_check(&tmpparam.yiaddr, &arpif)) == OK) {
|
|
|
|
- newsigmask = sigmask(SIGUSR1) | sigmask(SIGUSR2);
|
|
|
|
- oldsigmask = sigblock(newsigmask); /* begin critical */
|
|
|
|
+ sigprocmask(0, NULL, &oldsigmask);
|
|
|
|
+ memcpy(&newsigmask, &oldsigmask, sizeof(sigset_t));
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR1);
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR2);
|
|
|
|
+ sigprocmask(SIG_SETMASK, &newsigmask, NULL); /* begin critical */
|
|
|
|
merge_param(param_list, &tmpparam);
|
|
|
|
*param_list = tmpparam;
|
|
|
|
param_list->lease_origin = init_epoch;
|
|
|
|
param_list->next = NULL;
|
|
|
|
- sigsetmask(oldsigmask); /* end critical */
|
|
|
|
+ sigprocmask(SIG_SETMASK, &oldsigmask, NULL); /* end critical */
|
|
|
|
|
|
|
|
syslog(LOG_INFO, "Got DHCPACK (IP = %s, duration = %d secs)",
|
|
|
|
inet_ntoa(param_list->yiaddr), param_list->lease_duration);
|
|
|
|
@@ -1697,12 +1727,15 @@
|
|
|
|
set_declinfo(&tmp_reqspec, param_list, errmsg, arpans);
|
|
|
|
dhcp_decline(&tmp_reqspec);
|
|
|
|
|
|
|
|
- newsigmask = sigmask(SIGUSR1) | sigmask(SIGUSR2);
|
|
|
|
- oldsigmask = sigblock(newsigmask); /* begin critical */
|
|
|
|
+ sigprocmask(0, NULL, &oldsigmask);
|
|
|
|
+ memcpy(&newsigmask, &oldsigmask, sizeof(sigset_t));
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR1);
|
|
|
|
+ sigaddset(&newsigmask, SIGUSR2);
|
|
|
|
+ sigprocmask(SIG_SETMASK, &newsigmask, NULL); /* begin critical */
|
|
|
|
clean_param(param_list);
|
|
|
|
free(param_list);
|
|
|
|
param_list = NULL;
|
|
|
|
- sigsetmask(oldsigmask); /* end critical */
|
|
|
|
+ sigprocmask(SIG_SETMASK, &oldsigmask, NULL); /* end critical */
|
|
|
|
|
|
|
|
syslog(LOG_NOTICE,
|
|
|
|
"Got non-preferable DHCPACK, so go into INIT state");
|
|
|
|
@@ -1789,7 +1822,11 @@
|
1997-04-04 02:20:28 +00:00
|
|
|
void
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
- fprintf(stderr, "Usage: dhcpc [-d] if_name\n");
|
|
|
|
+#ifdef __FreeBSD__
|
|
|
|
+ fprintf(stderr, "Usage: dhcpc [-v] [-drn] if_name\n");
|
|
|
|
+#else
|
|
|
|
+ fprintf(stderr, "Usage: dhcpc [-v] [-d] if_name\n");
|
|
|
|
+#endif
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2000-01-20 22:08:54 +00:00
|
|
|
@@ -1809,26 +1846,39 @@
|
1996-05-04 02:43:35 +00:00
|
|
|
{
|
|
|
|
int debug = 0;
|
|
|
|
int n = 0;
|
1997-04-04 02:20:28 +00:00
|
|
|
+ int count;
|
1996-05-04 02:43:35 +00:00
|
|
|
struct if_info ifinfo;
|
|
|
|
|
|
|
|
bzero(&reqspec, sizeof(reqspec));
|
1997-04-04 02:20:28 +00:00
|
|
|
bzero(&ifinfo, sizeof(ifinfo));
|
1998-05-02 15:15:28 +00:00
|
|
|
|
|
|
|
- while (*++argv && argv[0][0] == '-') {
|
|
|
|
- switch (argv[0][1]) {
|
|
|
|
- case 'v':
|
|
|
|
- version();
|
|
|
|
- break;
|
|
|
|
- case 'd':
|
|
|
|
- debug = 1;
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- usage();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (argv[0] == NULL) usage();
|
1999-02-07 19:46:13 +00:00
|
|
|
+#ifdef __FreeBSD__
|
|
|
|
+#define COM_OPTS "vdrn"
|
|
|
|
+#else
|
|
|
|
+#define COM_OPTS "vd"
|
|
|
|
+#endif
|
|
|
|
|
1997-04-04 02:20:28 +00:00
|
|
|
+ while ((count = getopt(argc, argv, COM_OPTS)) != EOF) {
|
|
|
|
+ switch (count) {
|
|
|
|
+ case 'v':
|
|
|
|
+ version();
|
|
|
|
+ case 'd':
|
|
|
|
+ debug = 1;
|
|
|
|
+ break;
|
|
|
|
+#ifdef __FreeBSD__
|
|
|
|
+ case 'r':
|
|
|
|
+ f_resolv = 1;
|
|
|
|
+ break;
|
|
|
|
+ case 'n':
|
|
|
|
+ f_hostname = 1;
|
|
|
|
+ break;
|
|
|
|
+#endif
|
|
|
|
+ }
|
1998-05-02 15:15:28 +00:00
|
|
|
+ }
|
1997-04-04 02:20:28 +00:00
|
|
|
+ argc -= optind;
|
|
|
|
+ argv += optind;
|
1998-05-02 15:15:28 +00:00
|
|
|
+
|
|
|
|
+ if (argc < 1) usage();
|
1997-04-04 02:20:28 +00:00
|
|
|
strcpy(ifinfo.name, argv[0]);
|
1996-05-04 02:43:35 +00:00
|
|
|
|
|
|
|
/*
|
2000-01-20 22:08:54 +00:00
|
|
|
@@ -1859,6 +1909,11 @@
|
1997-04-04 02:20:28 +00:00
|
|
|
reqspec.reqlist.list[reqspec.reqlist.len++] = SUBNET_MASK;
|
|
|
|
reqspec.reqlist.list[reqspec.reqlist.len++] = ROUTER;
|
|
|
|
reqspec.reqlist.list[reqspec.reqlist.len++] = BRDCAST_ADDR;
|
|
|
|
+#ifdef __FreeBSD__
|
|
|
|
+ reqspec.reqlist.list[reqspec.reqlist.len++] = DNS_DOMAIN;
|
|
|
|
+ reqspec.reqlist.list[reqspec.reqlist.len++] = DNS_SERVER;
|
|
|
|
+ reqspec.reqlist.list[reqspec.reqlist.len++] = HOSTNAME;
|
|
|
|
+#endif
|
|
|
|
|
1998-05-02 15:15:28 +00:00
|
|
|
n = dhcp_client(&ifinfo);
|
|
|
|
unlink(pid_filename);
|