2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 22:35:25 +00:00

Fixups for haddr/htype->hbuf

This commit is contained in:
Ted Lemon
2000-01-25 01:07:41 +00:00
parent f6a30e8d93
commit d4feef6509
3 changed files with 44 additions and 40 deletions

View File

@@ -70,7 +70,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: dlpi.c,v 1.16 1999/10/14 17:44:02 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; "$Id: dlpi.c,v 1.17 2000/01/25 01:05:01 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -211,14 +211,14 @@ int if_register_dlpi (info)
switch (dlp -> info_ack.dl_mac_type) { switch (dlp -> info_ack.dl_mac_type) {
case DL_CSMACD: /* IEEE 802.3 */ case DL_CSMACD: /* IEEE 802.3 */
case DL_ETHER: case DL_ETHER:
info -> hw_address.htype = HTYPE_ETHER; info -> hw_address.hbuf [0] = HTYPE_ETHER;
break; break;
/* adding token ring 5/1999 - mayer@ping.at */ /* adding token ring 5/1999 - mayer@ping.at */
case DL_TPR: case DL_TPR:
info -> hw_address.htype = HTYPE_IEEE802; info -> hw_address.hbuf [0] = HTYPE_IEEE802;
break; break;
case DL_FDDI: case DL_FDDI:
info -> hw_address.htype = HTYPE_FDDI; info -> hw_address.hbuf [0] = HTYPE_FDDI;
break; break;
default: default:
log_fatal ("%s: unknown DLPI MAC type %ld", log_fatal ("%s: unknown DLPI MAC type %ld",
@@ -259,8 +259,8 @@ int if_register_dlpi (info)
info -> name); info -> name);
} }
info -> hw_address.hlen = dlp -> physaddr_ack.dl_addr_length; info -> hw_address.hlen = dlp -> physaddr_ack.dl_addr_length + 1;
memcpy (info -> hw_address.haddr, memcpy (&info -> hw_address.hbuf [1],
(char *)buf + dlp -> physaddr_ack.dl_addr_offset, (char *)buf + dlp -> physaddr_ack.dl_addr_offset,
dlp -> physaddr_ack.dl_addr_length); dlp -> physaddr_ack.dl_addr_length);
@@ -341,9 +341,9 @@ void if_register_send (info)
if (!quiet_interface_discovery) if (!quiet_interface_discovery)
log_info ("Sending on DLPI/%s/%s%s%s", log_info ("Sending on DLPI/%s/%s%s%s",
info -> name, info -> name,
print_hw_addr (info -> hw_address.htype, print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen, info -> hw_address.hlen - 1,
info -> hw_address.haddr), &info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""), (info -> shared_network ? "/" : ""),
(info -> shared_network ? (info -> shared_network ?
info -> shared_network -> name : "")); info -> shared_network -> name : ""));
@@ -424,9 +424,9 @@ void if_register_receive (info)
if (!quiet_interface_discovery) if (!quiet_interface_discovery)
log_info ("Listening on DLPI/%s/%s%s%s", log_info ("Listening on DLPI/%s/%s%s%s",
info -> name, info -> name,
print_hw_addr (info -> hw_address.htype, print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen, info -> hw_address.hlen - 1,
info -> hw_address.haddr), &info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""), (info -> shared_network ? "/" : ""),
(info -> shared_network ? (info -> shared_network ?
info -> shared_network -> name : "")); info -> shared_network -> name : ""));
@@ -489,7 +489,8 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
/* Setup the destination address */ /* Setup the destination address */
if (hto && hto -> hlen == interface -> hw_address.hlen) { if (hto && hto -> hlen == interface -> hw_address.hlen) {
dlpi_makeaddr (hto -> haddr, hto -> hlen, sap, saplen, dstaddr); dlpi_makeaddr (&hto -> hbuf [1],
hto -> hlen - 1, sap, saplen, dstaddr);
} else { } else {
/* XXX: Assumes broadcast addr is all ones */ /* XXX: Assumes broadcast addr is all ones */
/* Really should get the broadcast address as part of the /* Really should get the broadcast address as part of the
@@ -497,11 +498,12 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
*/ */
unsigned char bcast_ether [DLPI_MAXDLADDR]; unsigned char bcast_ether [DLPI_MAXDLADDR];
memset ((char *)bcast_ether, 0xFF, interface -> hw_address.hlen); memset ((char *)bcast_ether, 0xFF,
dlpi_makeaddr (bcast_ether, interface -> hw_address.hlen, interface -> hw_address.hlen - 1);
sap, saplen, dstaddr); dlpi_makeaddr (bcast_ether, interface -> hw_address.hlen - 1,
sap, saplen, dstaddr);
} }
addrlen = interface -> hw_address.hlen + ABS (saplen); addrlen = interface -> hw_address.hlen - 1 + ABS (saplen);
/* Send the packet down the wire... */ /* Send the packet down the wire... */
result = dlpiunitdatareq (interface -> wfdesc, dstaddr, addrlen, result = dlpiunitdatareq (interface -> wfdesc, dstaddr, addrlen,
@@ -548,13 +550,14 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
/* Copy sender info */ /* Copy sender info */
/* XXX: Assumes ethernet, where SAP comes at end of haddr */ /* XXX: Assumes ethernet, where SAP comes at end of haddr */
saplen = -2; saplen = -2;
if (hfrom && srcaddrlen == ABS(saplen) + interface -> hw_address.hlen) { if (hfrom && (srcaddrlen ==
hfrom -> htype = interface -> hw_address.htype; ABS (saplen) + interface -> hw_address.hlen - 1)) {
hfrom -> hlen = interface -> hw_address.hlen; hfrom -> hbuf [0] = interface -> hw_address.hbuf [0];
dlpi_parseaddr (srcaddr, hfrom -> haddr, hfrom -> hlen = interface -> hw_address.hlen;
interface -> hw_address.hlen, sap, saplen); dlpi_parseaddr (srcaddr, &hfrom -> hbuf [1],
interface -> hw_address.hlen - 1, sap, saplen);
} else if (hfrom) { } else if (hfrom) {
memset ((char *)hfrom, '\0', sizeof (*hfrom)); memset (hfrom, '\0', sizeof *hfrom);
} }
#endif #endif

View File

@@ -23,7 +23,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: lpf.c,v 1.18 1999/10/21 12:31:53 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; "$Id: lpf.c,v 1.19 2000/01/25 01:07:19 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -113,9 +113,9 @@ void if_register_send (info)
if (!quiet_interface_discovery) if (!quiet_interface_discovery)
log_info ("Sending on LPF/%s/%s%s%s", log_info ("Sending on LPF/%s/%s%s%s",
info -> name, info -> name,
print_hw_addr (info -> hw_address.htype, print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen, info -> hw_address.hlen - 1,
info -> hw_address.haddr), &info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""), (info -> shared_network ? "/" : ""),
(info -> shared_network ? (info -> shared_network ?
info -> shared_network -> name : "")); info -> shared_network -> name : ""));
@@ -147,9 +147,9 @@ void if_register_receive (info)
if (!quiet_interface_discovery) if (!quiet_interface_discovery)
log_info ("Listening on LPF/%s/%s%s%s", log_info ("Listening on LPF/%s/%s%s%s",
info -> name, info -> name,
print_hw_addr (info -> hw_address.htype, print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen, info -> hw_address.hlen - 1,
info -> hw_address.haddr), &info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""), (info -> shared_network ? "/" : ""),
(info -> shared_network ? (info -> shared_network ?
info -> shared_network -> name : "")); info -> shared_network -> name : ""));

View File

@@ -23,7 +23,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: nit.c,v 1.25 1999/10/07 06:47:50 mellon Exp $ Copyright (c) 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; "$Id: nit.c,v 1.26 2000/01/25 01:07:41 mellon Exp $ Copyright (c) 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -97,9 +97,10 @@ int if_register_nit (info)
info -> name); info -> name);
/* XXX code below assumes ethernet interface! */ /* XXX code below assumes ethernet interface! */
info -> hw_address.hlen = 6; info -> hw_address.hlen = 7;
info -> hw_address.htype = ARPHRD_ETHER; info -> hw_address.hbuf [0] = ARPHRD_ETHER;
memcpy (info -> hw_address.haddr, ifr.ifr_ifru.ifru_addr.sa_data, 6); memcpy (&info -> hw_address.jbuf [1],
ifr.ifr_ifru.ifru_addr.sa_data, 6);
if (ioctl (sock, I_PUSH, "pf") < 0) if (ioctl (sock, I_PUSH, "pf") < 0)
log_fatal ("Can't push packet filter onto NIT for %s: %m", log_fatal ("Can't push packet filter onto NIT for %s: %m",
@@ -137,9 +138,9 @@ void if_register_send (info)
#endif #endif
if (!quiet_interface_discovery) if (!quiet_interface_discovery)
log_info ("Sending on NIT/%s%s%s", log_info ("Sending on NIT/%s%s%s",
print_hw_addr (info -> hw_address.htype, print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen, info -> hw_address.hlen - 1,
info -> hw_address.haddr), &info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""), (info -> shared_network ? "/" : ""),
(info -> shared_network ? (info -> shared_network ?
info -> shared_network -> name : "")); info -> shared_network -> name : ""));
@@ -221,9 +222,9 @@ void if_register_receive (info)
if (!quiet_interface_discovery) if (!quiet_interface_discovery)
log_info ("Listening on NIT/%s%s%s", log_info ("Listening on NIT/%s%s%s",
print_hw_addr (info -> hw_address.htype, print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen, info -> hw_address.hlen - 1,
info -> hw_address.haddr), &info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""), (info -> shared_network ? "/" : ""),
(info -> shared_network ? (info -> shared_network ?
info -> shared_network -> name : "")); info -> shared_network -> name : ""));