From: Ted Lemon Date: Tue, 18 Feb 1997 14:32:51 +0000 (+0000) Subject: Use local_port and remote_port instead of server_port and server_port + 1 X-Git-Tag: DHCP_970222~60 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a60076f94d2add3af9000aa3be378c1a680b6092;p=thirdparty%2Fdhcp.git Use local_port and remote_port instead of server_port and server_port + 1 --- diff --git a/bpf.c b/bpf.c index c0d802b8d..f59806d00 100644 --- a/bpf.c +++ b/bpf.c @@ -42,7 +42,7 @@ #ifndef lint 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 */ #include "dhcpd.h" @@ -211,7 +211,7 @@ void if_register_receive (info, interface) /* Patch the server port into the BPF program... XXX changes to filter program may require changes 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) error ("Can't install packet filter program: %m"); diff --git a/common/bpf.c b/common/bpf.c index c0d802b8d..f59806d00 100644 --- a/common/bpf.c +++ b/common/bpf.c @@ -42,7 +42,7 @@ #ifndef lint 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 */ #include "dhcpd.h" @@ -211,7 +211,7 @@ void if_register_receive (info, interface) /* Patch the server port into the BPF program... XXX changes to filter program may require changes 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) error ("Can't install packet filter program: %m"); diff --git a/common/nit.c b/common/nit.c index 0de8d62bc..9b1dc06f4 100644 --- a/common/nit.c +++ b/common/nit.c @@ -42,7 +42,7 @@ #ifndef lint 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 */ #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_PUSHWORD + 18; 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... */ sio.ic_cmd = NIOCSETF; diff --git a/common/packet.c b/common/packet.c index 2d6238b41..1fc9a0bbe 100644 --- a/common/packet.c +++ b/common/packet.c @@ -42,7 +42,7 @@ #ifndef lint 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 */ #include "dhcpd.h" @@ -189,7 +189,7 @@ void assemble_udp_ip_header (interface, buf, bufix, *bufix += sizeof ip; /* Fill out the UDP header */ - udp.uh_sport = server_port; /* XXX */ + udp.uh_sport = local_port; /* XXX */ udp.uh_dport = port; /* XXX */ udp.uh_ulen = htons(sizeof(udp) + len); 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; /* Is it to the port we're serving? */ - if (udp -> uh_dport != server_port) + if (udp -> uh_dport != local_port) return -1; #endif /* USERLAND_FILTER */ diff --git a/common/raw.c b/common/raw.c index b49d4d94f..148408e02 100644 --- a/common/raw.c +++ b/common/raw.c @@ -54,7 +54,7 @@ #ifndef lint 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 */ #include "dhcpd.h" @@ -74,13 +74,13 @@ void if_register_send (info, interface) /* Set up the address we're going to connect to. */ name.sin_family = AF_INET; - name.sin_port = server_port; + name.sin_port = local_port; name.sin_addr.s_addr = htonl (INADDR_BROADCAST); memset (name.sin_zero, 0, sizeof (name.sin_zero)); /* List addresses on which we're listening. */ 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) error ("Can't create dhcp socket: %m"); diff --git a/common/socket.c b/common/socket.c index 7e7bc912a..3e3121b5e 100644 --- a/common/socket.c +++ b/common/socket.c @@ -50,7 +50,7 @@ #ifndef lint 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 */ #include "dhcpd.h" @@ -87,7 +87,7 @@ int if_register_socket (info, interface) /* Set up the address we're going to bind to. */ name.sin_family = AF_INET; - name.sin_port = server_port; + name.sin_port = local_port; name.sin_addr.s_addr = INADDR_ANY; memset (name.sin_zero, 0, sizeof (name.sin_zero)); diff --git a/dhcpd.c b/dhcpd.c index b46b74bb5..941c4bb0c 100644 --- a/dhcpd.c +++ b/dhcpd.c @@ -42,7 +42,7 @@ #ifndef lint 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 static char copyright[] = @@ -64,7 +64,9 @@ int server_identifier_matched; struct interface_info fallback_interface; #endif -u_int16_t server_port; +u_int16_t local_port; +u_int16_t remote_port; + int log_priority; #ifdef DEBUG int log_perror = -1; @@ -119,9 +121,9 @@ int main (argc, argv, envp) if (status < 1 || status > 65535) error ("%s: not a valid UDP port", argv [i]); - server_port = htons (status); + local_port = htons (status); debug ("binding to user-specified port %d", - ntohs (server_port)); + ntohs (local_port)); } else if (!strcmp (argv [i], "-f")) { #ifndef DEBUG daemon = 0; @@ -200,16 +202,18 @@ int main (argc, argv, envp) #endif /* !DEBUG */ /* Default to the DHCP/BOOTP port. */ - if (!server_port) + if (!local_port) { ent = getservbyname ("dhcp", "udp"); if (!ent) - server_port = htons (67); + local_port = htons (67); else - server_port = ent -> s_port; + local_port = ent -> s_port; endservent (); } + remote_port = htons (ntohs (local_port) + 1); + /* Get the current time... */ GET_TIME (&cur_time); diff --git a/nit.c b/nit.c index 0de8d62bc..9b1dc06f4 100644 --- a/nit.c +++ b/nit.c @@ -42,7 +42,7 @@ #ifndef lint 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 */ #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_PUSHWORD + 18; 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... */ sio.ic_cmd = NIOCSETF; diff --git a/packet.c b/packet.c index 2d6238b41..1fc9a0bbe 100644 --- a/packet.c +++ b/packet.c @@ -42,7 +42,7 @@ #ifndef lint 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 */ #include "dhcpd.h" @@ -189,7 +189,7 @@ void assemble_udp_ip_header (interface, buf, bufix, *bufix += sizeof ip; /* Fill out the UDP header */ - udp.uh_sport = server_port; /* XXX */ + udp.uh_sport = local_port; /* XXX */ udp.uh_dport = port; /* XXX */ udp.uh_ulen = htons(sizeof(udp) + len); 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; /* Is it to the port we're serving? */ - if (udp -> uh_dport != server_port) + if (udp -> uh_dport != local_port) return -1; #endif /* USERLAND_FILTER */ diff --git a/raw.c b/raw.c index b49d4d94f..148408e02 100644 --- a/raw.c +++ b/raw.c @@ -54,7 +54,7 @@ #ifndef lint 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 */ #include "dhcpd.h" @@ -74,13 +74,13 @@ void if_register_send (info, interface) /* Set up the address we're going to connect to. */ name.sin_family = AF_INET; - name.sin_port = server_port; + name.sin_port = local_port; name.sin_addr.s_addr = htonl (INADDR_BROADCAST); memset (name.sin_zero, 0, sizeof (name.sin_zero)); /* List addresses on which we're listening. */ 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) error ("Can't create dhcp socket: %m"); diff --git a/server/dhcpd.c b/server/dhcpd.c index b46b74bb5..941c4bb0c 100644 --- a/server/dhcpd.c +++ b/server/dhcpd.c @@ -42,7 +42,7 @@ #ifndef lint 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 static char copyright[] = @@ -64,7 +64,9 @@ int server_identifier_matched; struct interface_info fallback_interface; #endif -u_int16_t server_port; +u_int16_t local_port; +u_int16_t remote_port; + int log_priority; #ifdef DEBUG int log_perror = -1; @@ -119,9 +121,9 @@ int main (argc, argv, envp) if (status < 1 || status > 65535) error ("%s: not a valid UDP port", argv [i]); - server_port = htons (status); + local_port = htons (status); debug ("binding to user-specified port %d", - ntohs (server_port)); + ntohs (local_port)); } else if (!strcmp (argv [i], "-f")) { #ifndef DEBUG daemon = 0; @@ -200,16 +202,18 @@ int main (argc, argv, envp) #endif /* !DEBUG */ /* Default to the DHCP/BOOTP port. */ - if (!server_port) + if (!local_port) { ent = getservbyname ("dhcp", "udp"); if (!ent) - server_port = htons (67); + local_port = htons (67); else - server_port = ent -> s_port; + local_port = ent -> s_port; endservent (); } + remote_port = htons (ntohs (local_port) + 1); + /* Get the current time... */ GET_TIME (&cur_time); diff --git a/socket.c b/socket.c index 7e7bc912a..3e3121b5e 100644 --- a/socket.c +++ b/socket.c @@ -50,7 +50,7 @@ #ifndef lint 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 */ #include "dhcpd.h" @@ -87,7 +87,7 @@ int if_register_socket (info, interface) /* Set up the address we're going to bind to. */ name.sin_family = AF_INET; - name.sin_port = server_port; + name.sin_port = local_port; name.sin_addr.s_addr = INADDR_ANY; memset (name.sin_zero, 0, sizeof (name.sin_zero));