mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-01 14:55:30 +00:00
Use local_port and remote_port instead of server_port and server_port + 1
This commit is contained in:
4
bpf.c
4
bpf.c
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: bpf.c,v 1.14 1997/01/02 12:00:14 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: bpf.c,v 1.15 1997/02/18 14:30:12 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -211,7 +211,7 @@ void if_register_receive (info, interface)
|
|||||||
/* Patch the server port into the BPF program...
|
/* Patch the server port into the BPF program...
|
||||||
XXX changes to filter program may require changes
|
XXX changes to filter program may require changes
|
||||||
to the insn number(s) used below! XXX */
|
to the insn number(s) used below! XXX */
|
||||||
filter [8].k = ntohs (server_port);
|
filter [8].k = ntohs (local_port);
|
||||||
|
|
||||||
if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
|
if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
|
||||||
error ("Can't install packet filter program: %m");
|
error ("Can't install packet filter program: %m");
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: bpf.c,v 1.14 1997/01/02 12:00:14 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: bpf.c,v 1.15 1997/02/18 14:30:12 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -211,7 +211,7 @@ void if_register_receive (info, interface)
|
|||||||
/* Patch the server port into the BPF program...
|
/* Patch the server port into the BPF program...
|
||||||
XXX changes to filter program may require changes
|
XXX changes to filter program may require changes
|
||||||
to the insn number(s) used below! XXX */
|
to the insn number(s) used below! XXX */
|
||||||
filter [8].k = ntohs (server_port);
|
filter [8].k = ntohs (local_port);
|
||||||
|
|
||||||
if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
|
if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
|
||||||
error ("Can't install packet filter program: %m");
|
error ("Can't install packet filter program: %m");
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: nit.c,v 1.10 1997/01/02 12:00:17 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: nit.c,v 1.11 1997/02/18 14:30:12 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -212,7 +212,7 @@ void if_register_receive (info, interface)
|
|||||||
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND;
|
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND;
|
||||||
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 18;
|
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 18;
|
||||||
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
|
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
|
||||||
pf.Pf_Filter [pf.Pf_FilterLen++] = server_port;
|
pf.Pf_Filter [pf.Pf_FilterLen++] = local_port;
|
||||||
|
|
||||||
/* Install the filter... */
|
/* Install the filter... */
|
||||||
sio.ic_cmd = NIOCSETF;
|
sio.ic_cmd = NIOCSETF;
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: packet.c,v 1.11 1996/08/27 09:53:14 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: packet.c,v 1.12 1997/02/18 14:32:51 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -189,7 +189,7 @@ void assemble_udp_ip_header (interface, buf, bufix,
|
|||||||
*bufix += sizeof ip;
|
*bufix += sizeof ip;
|
||||||
|
|
||||||
/* Fill out the UDP header */
|
/* Fill out the UDP header */
|
||||||
udp.uh_sport = server_port; /* XXX */
|
udp.uh_sport = local_port; /* XXX */
|
||||||
udp.uh_dport = port; /* XXX */
|
udp.uh_dport = port; /* XXX */
|
||||||
udp.uh_ulen = htons(sizeof(udp) + len);
|
udp.uh_ulen = htons(sizeof(udp) + len);
|
||||||
memset (&udp.uh_sum, 0, sizeof udp.uh_sum);
|
memset (&udp.uh_sum, 0, sizeof udp.uh_sum);
|
||||||
@@ -264,7 +264,7 @@ size_t decode_udp_ip_header (interface, buf, bufix, from, data, len)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Is it to the port we're serving? */
|
/* Is it to the port we're serving? */
|
||||||
if (udp -> uh_dport != server_port)
|
if (udp -> uh_dport != local_port)
|
||||||
return -1;
|
return -1;
|
||||||
#endif /* USERLAND_FILTER */
|
#endif /* USERLAND_FILTER */
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: raw.c,v 1.8 1996/09/04 07:06:39 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: raw.c,v 1.9 1997/02/18 14:32:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -74,13 +74,13 @@ void if_register_send (info, interface)
|
|||||||
|
|
||||||
/* Set up the address we're going to connect to. */
|
/* Set up the address we're going to connect to. */
|
||||||
name.sin_family = AF_INET;
|
name.sin_family = AF_INET;
|
||||||
name.sin_port = server_port;
|
name.sin_port = local_port;
|
||||||
name.sin_addr.s_addr = htonl (INADDR_BROADCAST);
|
name.sin_addr.s_addr = htonl (INADDR_BROADCAST);
|
||||||
memset (name.sin_zero, 0, sizeof (name.sin_zero));
|
memset (name.sin_zero, 0, sizeof (name.sin_zero));
|
||||||
|
|
||||||
/* List addresses on which we're listening. */
|
/* List addresses on which we're listening. */
|
||||||
note ("Sending on %s, port %d",
|
note ("Sending on %s, port %d",
|
||||||
piaddr (info -> address), htons (server_port));
|
piaddr (info -> address), htons (local_port));
|
||||||
if ((sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
|
if ((sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
|
||||||
error ("Can't create dhcp socket: %m");
|
error ("Can't create dhcp socket: %m");
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: socket.c,v 1.17 1997/01/02 12:00:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: socket.c,v 1.18 1997/02/18 14:30:13 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -87,7 +87,7 @@ int if_register_socket (info, interface)
|
|||||||
|
|
||||||
/* Set up the address we're going to bind to. */
|
/* Set up the address we're going to bind to. */
|
||||||
name.sin_family = AF_INET;
|
name.sin_family = AF_INET;
|
||||||
name.sin_port = server_port;
|
name.sin_port = local_port;
|
||||||
name.sin_addr.s_addr = INADDR_ANY;
|
name.sin_addr.s_addr = INADDR_ANY;
|
||||||
memset (name.sin_zero, 0, sizeof (name.sin_zero));
|
memset (name.sin_zero, 0, sizeof (name.sin_zero));
|
||||||
|
|
||||||
|
18
dhcpd.c
18
dhcpd.c
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char ocopyright[] =
|
static char ocopyright[] =
|
||||||
"$Id: dhcpd.c,v 1.36 1996/09/12 09:28:13 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
"$Id: dhcpd.c,v 1.37 1997/02/18 14:30:11 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
@@ -64,7 +64,9 @@ int server_identifier_matched;
|
|||||||
struct interface_info fallback_interface;
|
struct interface_info fallback_interface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u_int16_t server_port;
|
u_int16_t local_port;
|
||||||
|
u_int16_t remote_port;
|
||||||
|
|
||||||
int log_priority;
|
int log_priority;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int log_perror = -1;
|
int log_perror = -1;
|
||||||
@@ -119,9 +121,9 @@ int main (argc, argv, envp)
|
|||||||
if (status < 1 || status > 65535)
|
if (status < 1 || status > 65535)
|
||||||
error ("%s: not a valid UDP port",
|
error ("%s: not a valid UDP port",
|
||||||
argv [i]);
|
argv [i]);
|
||||||
server_port = htons (status);
|
local_port = htons (status);
|
||||||
debug ("binding to user-specified port %d",
|
debug ("binding to user-specified port %d",
|
||||||
ntohs (server_port));
|
ntohs (local_port));
|
||||||
} else if (!strcmp (argv [i], "-f")) {
|
} else if (!strcmp (argv [i], "-f")) {
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
daemon = 0;
|
daemon = 0;
|
||||||
@@ -200,16 +202,18 @@ int main (argc, argv, envp)
|
|||||||
#endif /* !DEBUG */
|
#endif /* !DEBUG */
|
||||||
|
|
||||||
/* Default to the DHCP/BOOTP port. */
|
/* Default to the DHCP/BOOTP port. */
|
||||||
if (!server_port)
|
if (!local_port)
|
||||||
{
|
{
|
||||||
ent = getservbyname ("dhcp", "udp");
|
ent = getservbyname ("dhcp", "udp");
|
||||||
if (!ent)
|
if (!ent)
|
||||||
server_port = htons (67);
|
local_port = htons (67);
|
||||||
else
|
else
|
||||||
server_port = ent -> s_port;
|
local_port = ent -> s_port;
|
||||||
endservent ();
|
endservent ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remote_port = htons (ntohs (local_port) + 1);
|
||||||
|
|
||||||
/* Get the current time... */
|
/* Get the current time... */
|
||||||
GET_TIME (&cur_time);
|
GET_TIME (&cur_time);
|
||||||
|
|
||||||
|
4
nit.c
4
nit.c
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: nit.c,v 1.10 1997/01/02 12:00:17 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: nit.c,v 1.11 1997/02/18 14:30:12 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -212,7 +212,7 @@ void if_register_receive (info, interface)
|
|||||||
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND;
|
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND;
|
||||||
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 18;
|
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 18;
|
||||||
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
|
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
|
||||||
pf.Pf_Filter [pf.Pf_FilterLen++] = server_port;
|
pf.Pf_Filter [pf.Pf_FilterLen++] = local_port;
|
||||||
|
|
||||||
/* Install the filter... */
|
/* Install the filter... */
|
||||||
sio.ic_cmd = NIOCSETF;
|
sio.ic_cmd = NIOCSETF;
|
||||||
|
6
packet.c
6
packet.c
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: packet.c,v 1.11 1996/08/27 09:53:14 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: packet.c,v 1.12 1997/02/18 14:32:51 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -189,7 +189,7 @@ void assemble_udp_ip_header (interface, buf, bufix,
|
|||||||
*bufix += sizeof ip;
|
*bufix += sizeof ip;
|
||||||
|
|
||||||
/* Fill out the UDP header */
|
/* Fill out the UDP header */
|
||||||
udp.uh_sport = server_port; /* XXX */
|
udp.uh_sport = local_port; /* XXX */
|
||||||
udp.uh_dport = port; /* XXX */
|
udp.uh_dport = port; /* XXX */
|
||||||
udp.uh_ulen = htons(sizeof(udp) + len);
|
udp.uh_ulen = htons(sizeof(udp) + len);
|
||||||
memset (&udp.uh_sum, 0, sizeof udp.uh_sum);
|
memset (&udp.uh_sum, 0, sizeof udp.uh_sum);
|
||||||
@@ -264,7 +264,7 @@ size_t decode_udp_ip_header (interface, buf, bufix, from, data, len)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Is it to the port we're serving? */
|
/* Is it to the port we're serving? */
|
||||||
if (udp -> uh_dport != server_port)
|
if (udp -> uh_dport != local_port)
|
||||||
return -1;
|
return -1;
|
||||||
#endif /* USERLAND_FILTER */
|
#endif /* USERLAND_FILTER */
|
||||||
|
|
||||||
|
6
raw.c
6
raw.c
@@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: raw.c,v 1.8 1996/09/04 07:06:39 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: raw.c,v 1.9 1997/02/18 14:32:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -74,13 +74,13 @@ void if_register_send (info, interface)
|
|||||||
|
|
||||||
/* Set up the address we're going to connect to. */
|
/* Set up the address we're going to connect to. */
|
||||||
name.sin_family = AF_INET;
|
name.sin_family = AF_INET;
|
||||||
name.sin_port = server_port;
|
name.sin_port = local_port;
|
||||||
name.sin_addr.s_addr = htonl (INADDR_BROADCAST);
|
name.sin_addr.s_addr = htonl (INADDR_BROADCAST);
|
||||||
memset (name.sin_zero, 0, sizeof (name.sin_zero));
|
memset (name.sin_zero, 0, sizeof (name.sin_zero));
|
||||||
|
|
||||||
/* List addresses on which we're listening. */
|
/* List addresses on which we're listening. */
|
||||||
note ("Sending on %s, port %d",
|
note ("Sending on %s, port %d",
|
||||||
piaddr (info -> address), htons (server_port));
|
piaddr (info -> address), htons (local_port));
|
||||||
if ((sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
|
if ((sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
|
||||||
error ("Can't create dhcp socket: %m");
|
error ("Can't create dhcp socket: %m");
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char ocopyright[] =
|
static char ocopyright[] =
|
||||||
"$Id: dhcpd.c,v 1.36 1996/09/12 09:28:13 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
"$Id: dhcpd.c,v 1.37 1997/02/18 14:30:11 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
@@ -64,7 +64,9 @@ int server_identifier_matched;
|
|||||||
struct interface_info fallback_interface;
|
struct interface_info fallback_interface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u_int16_t server_port;
|
u_int16_t local_port;
|
||||||
|
u_int16_t remote_port;
|
||||||
|
|
||||||
int log_priority;
|
int log_priority;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int log_perror = -1;
|
int log_perror = -1;
|
||||||
@@ -119,9 +121,9 @@ int main (argc, argv, envp)
|
|||||||
if (status < 1 || status > 65535)
|
if (status < 1 || status > 65535)
|
||||||
error ("%s: not a valid UDP port",
|
error ("%s: not a valid UDP port",
|
||||||
argv [i]);
|
argv [i]);
|
||||||
server_port = htons (status);
|
local_port = htons (status);
|
||||||
debug ("binding to user-specified port %d",
|
debug ("binding to user-specified port %d",
|
||||||
ntohs (server_port));
|
ntohs (local_port));
|
||||||
} else if (!strcmp (argv [i], "-f")) {
|
} else if (!strcmp (argv [i], "-f")) {
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
daemon = 0;
|
daemon = 0;
|
||||||
@@ -200,16 +202,18 @@ int main (argc, argv, envp)
|
|||||||
#endif /* !DEBUG */
|
#endif /* !DEBUG */
|
||||||
|
|
||||||
/* Default to the DHCP/BOOTP port. */
|
/* Default to the DHCP/BOOTP port. */
|
||||||
if (!server_port)
|
if (!local_port)
|
||||||
{
|
{
|
||||||
ent = getservbyname ("dhcp", "udp");
|
ent = getservbyname ("dhcp", "udp");
|
||||||
if (!ent)
|
if (!ent)
|
||||||
server_port = htons (67);
|
local_port = htons (67);
|
||||||
else
|
else
|
||||||
server_port = ent -> s_port;
|
local_port = ent -> s_port;
|
||||||
endservent ();
|
endservent ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remote_port = htons (ntohs (local_port) + 1);
|
||||||
|
|
||||||
/* Get the current time... */
|
/* Get the current time... */
|
||||||
GET_TIME (&cur_time);
|
GET_TIME (&cur_time);
|
||||||
|
|
||||||
|
4
socket.c
4
socket.c
@@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: socket.c,v 1.17 1997/01/02 12:00:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: socket.c,v 1.18 1997/02/18 14:30:13 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -87,7 +87,7 @@ int if_register_socket (info, interface)
|
|||||||
|
|
||||||
/* Set up the address we're going to bind to. */
|
/* Set up the address we're going to bind to. */
|
||||||
name.sin_family = AF_INET;
|
name.sin_family = AF_INET;
|
||||||
name.sin_port = server_port;
|
name.sin_port = local_port;
|
||||||
name.sin_addr.s_addr = INADDR_ANY;
|
name.sin_addr.s_addr = INADDR_ANY;
|
||||||
memset (name.sin_zero, 0, sizeof (name.sin_zero));
|
memset (name.sin_zero, 0, sizeof (name.sin_zero));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user