summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-02-24 13:36:14 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-02-24 13:36:14 +0000
commitdf2a40f47a64d1a3e597f5fc972659c2b1ab4059 (patch)
treeeef759c0a2870e2ff2e5d4c0bc349a699fa16569 /sbin/dhclient
parentefb6daabf2d48a06d4610b8ad9c00819cee90eea (diff)
remove dynamic port gunk
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/bpf.c4
-rw-r--r--sbin/dhclient/dhclient.c19
-rw-r--r--sbin/dhclient/dhcpd.h6
-rw-r--r--sbin/dhclient/packet.c4
4 files changed, 11 insertions, 22 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index 2b586a314bf..4ee46810bed 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.7 2004/02/24 13:08:26 henning Exp $ */
+/* $OpenBSD: bpf.c,v 1.8 2004/02/24 13:36:13 henning Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -209,7 +209,7 @@ if_register_receive(struct interface_info *info)
* XXX: changes to filter program may require changes to the
* insn number(s) used below!
*/
- dhcp_bpf_filter[8].k = ntohs(local_port);
+ dhcp_bpf_filter[8].k = LOCAL_PORT;
if (ioctl(info->rfdesc, BIOCSETF, &p) < 0)
error("Can't install packet filter program: %m");
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 6e7ab784eb2..1b70e7d4140 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.15 2004/02/24 13:21:32 henning Exp $ */
+/* $OpenBSD: dhclient.c,v 1.16 2004/02/24 13:36:13 henning Exp $ */
/* DHCP Client. */
@@ -97,8 +97,6 @@ struct sockaddr_in sockaddr_broadcast;
#define TIME_MAX 2147483647
#endif
-u_int16_t local_port;
-u_int16_t remote_port;
int log_priority;
int no_daemon;
int save_scripts;
@@ -215,7 +213,6 @@ int
main(int argc, char *argv[])
{
extern char *__progname;
- struct servent *ent;
struct interface_info *ip = NULL;
int ch, fd, seed, quiet = 0;
@@ -263,22 +260,12 @@ main(int argc, char *argv[])
if (quiet)
log_perror = 0;
- /* Default to the DHCP/BOOTP port. */
- if (!local_port) {
- ent = getservbyname("dhcpc", "udp");
- if (!ent)
- local_port = htons(68);
- else
- local_port = ent->s_port;
- }
- remote_port = htons(ntohs(local_port) - 1); /* XXX */
-
/* Get the current time... */
time(&cur_time);
memset(&sockaddr_broadcast, 0, sizeof(sockaddr_broadcast));
sockaddr_broadcast.sin_family = AF_INET;
- sockaddr_broadcast.sin_port = remote_port;
+ sockaddr_broadcast.sin_port = htons(REMOTE_PORT);
sockaddr_broadcast.sin_addr.s_addr = INADDR_BROADCAST;
sockaddr_broadcast.sin_len = sizeof(sockaddr_broadcast);
inaddr_any.s_addr = INADDR_ANY;
@@ -1324,7 +1311,7 @@ cancel:
memcpy(&destination.sin_addr.s_addr,
ip->client->destination.iabuf,
sizeof(destination.sin_addr.s_addr));
- destination.sin_port = remote_port;
+ destination.sin_port = htons(REMOTE_PORT);
destination.sin_family = AF_INET;
destination.sin_len = sizeof(destination);
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 79c6f463bbb..4120eb706f3 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.13 2004/02/24 13:21:32 henning Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.14 2004/02/24 13:36:13 henning Exp $ */
/* Definitions for dhcpd... */
@@ -78,6 +78,9 @@
#include "hash.h"
#include "inet.h"
+#define LOCAL_PORT 68
+#define REMOTE_PORT 67
+
struct option_data {
int len;
u_int8_t *data;
@@ -619,7 +622,6 @@ char *piaddr(struct iaddr);
extern char *path_dhclient_conf;
extern char *path_dhclient_db;
extern time_t cur_time;
-extern u_int16_t local_port;
extern int log_priority;
extern int log_perror;
diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c
index 5a096051cd2..7a188d4ff4d 100644
--- a/sbin/dhclient/packet.c
+++ b/sbin/dhclient/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.6 2004/02/24 00:34:40 henning Exp $ */
+/* $OpenBSD: packet.c,v 1.7 2004/02/24 13:36:13 henning Exp $ */
/* Packet assembly code, originally contributed by Archie Cobbs. */
@@ -126,7 +126,7 @@ assemble_udp_ip_header(struct interface_info *interface, unsigned char *buf,
*bufix += sizeof(ip);
/* Fill out the UDP header */
- udp.uh_sport = local_port; /* XXX */
+ udp.uh_sport = htons(LOCAL_PORT); /* XXX */
udp.uh_dport = port; /* XXX */
udp.uh_ulen = htons(sizeof(udp) + len);
memset(&udp.uh_sum, 0, sizeof(udp.uh_sum));