mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-02 23:35:23 +00:00
Make packet messages say where the packet came from and where it's going.
This commit is contained in:
48
dhcp.c
48
dhcp.c
@@ -87,10 +87,13 @@ void dhcpdiscover (packet)
|
|||||||
struct lease *lease = find_lease (packet, packet -> shared_network);
|
struct lease *lease = find_lease (packet, packet -> shared_network);
|
||||||
struct host_decl *hp;
|
struct host_decl *hp;
|
||||||
|
|
||||||
note ("DHCPDISCOVER from %s",
|
note ("DHCPDISCOVER from %s via %s",
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
/* Sourceless packets don't make sense here. */
|
/* Sourceless packets don't make sense here. */
|
||||||
if (!packet -> shared_network) {
|
if (!packet -> shared_network) {
|
||||||
@@ -165,11 +168,15 @@ void dhcprequest (packet)
|
|||||||
? subnet -> shared_network
|
? subnet -> shared_network
|
||||||
: (struct shared_network *)0));
|
: (struct shared_network *)0));
|
||||||
|
|
||||||
note ("DHCPREQUEST for %s from %s",
|
note ("DHCPREQUEST for %s from %s via %s",
|
||||||
piaddr (cip),
|
piaddr (cip),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
|
|
||||||
/* If a client on a given network wants to request a lease on
|
/* If a client on a given network wants to request a lease on
|
||||||
an address on a different network, NAK it. If the Requested
|
an address on a different network, NAK it. If the Requested
|
||||||
@@ -249,11 +256,15 @@ void dhcprelease (packet)
|
|||||||
{
|
{
|
||||||
struct lease *lease = find_lease (packet, packet -> shared_network);
|
struct lease *lease = find_lease (packet, packet -> shared_network);
|
||||||
|
|
||||||
note ("DHCPRELEASE of %s from %s",
|
note ("DHCPRELEASE of %s from %s via %s",
|
||||||
inet_ntoa (packet -> raw -> ciaddr),
|
inet_ntoa (packet -> raw -> ciaddr),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
|
|
||||||
/* If we found a lease, release it. */
|
/* If we found a lease, release it. */
|
||||||
if (lease) {
|
if (lease) {
|
||||||
@@ -276,11 +287,15 @@ void dhcpdecline (packet)
|
|||||||
cip.len = 0;
|
cip.len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
note ("DHCPDECLINE on %s from %s",
|
note ("DHCPDECLINE on %s from %s via %s",
|
||||||
piaddr (cip),
|
piaddr (cip),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
|
|
||||||
/* If we found a lease, mark it as unusable and complain. */
|
/* If we found a lease, mark it as unusable and complain. */
|
||||||
if (lease) {
|
if (lease) {
|
||||||
@@ -293,7 +308,6 @@ void dhcpinform (packet)
|
|||||||
{
|
{
|
||||||
note ("DHCPINFORM from %s",
|
note ("DHCPINFORM from %s",
|
||||||
inet_ntoa (packet -> raw -> ciaddr));
|
inet_ntoa (packet -> raw -> ciaddr));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nak_lease (packet, cip)
|
void nak_lease (packet, cip)
|
||||||
@@ -354,11 +368,16 @@ void nak_lease (packet, cip)
|
|||||||
raw.op = BOOTREPLY;
|
raw.op = BOOTREPLY;
|
||||||
|
|
||||||
/* Report what we're sending... */
|
/* Report what we're sending... */
|
||||||
note ("DHCPNAK on %s to %s",
|
note ("DHCPNAK on %s to %s via %s",
|
||||||
piaddr (*cip),
|
piaddr (*cip),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_PACKET
|
#ifdef DEBUG_PACKET
|
||||||
dump_packet (packet);
|
dump_packet (packet);
|
||||||
@@ -717,14 +736,17 @@ void ack_lease (packet, lease, offer, when)
|
|||||||
raw.op = BOOTREPLY;
|
raw.op = BOOTREPLY;
|
||||||
|
|
||||||
/* Say what we're doing... */
|
/* Say what we're doing... */
|
||||||
note ("%s on %s to %s",
|
note ("%s on %s to %s via %s",
|
||||||
(offer
|
(offer
|
||||||
? (offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
|
? (offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
|
||||||
: "BOOTREPLY"),
|
: "BOOTREPLY"),
|
||||||
piaddr (lease -> ip_addr),
|
piaddr (lease -> ip_addr),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
/* Set up the hardware address... */
|
/* Set up the hardware address... */
|
||||||
hto.htype = packet -> raw -> htype;
|
hto.htype = packet -> raw -> htype;
|
||||||
|
@@ -87,10 +87,13 @@ void dhcpdiscover (packet)
|
|||||||
struct lease *lease = find_lease (packet, packet -> shared_network);
|
struct lease *lease = find_lease (packet, packet -> shared_network);
|
||||||
struct host_decl *hp;
|
struct host_decl *hp;
|
||||||
|
|
||||||
note ("DHCPDISCOVER from %s",
|
note ("DHCPDISCOVER from %s via %s",
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
/* Sourceless packets don't make sense here. */
|
/* Sourceless packets don't make sense here. */
|
||||||
if (!packet -> shared_network) {
|
if (!packet -> shared_network) {
|
||||||
@@ -165,11 +168,15 @@ void dhcprequest (packet)
|
|||||||
? subnet -> shared_network
|
? subnet -> shared_network
|
||||||
: (struct shared_network *)0));
|
: (struct shared_network *)0));
|
||||||
|
|
||||||
note ("DHCPREQUEST for %s from %s",
|
note ("DHCPREQUEST for %s from %s via %s",
|
||||||
piaddr (cip),
|
piaddr (cip),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
|
|
||||||
/* If a client on a given network wants to request a lease on
|
/* If a client on a given network wants to request a lease on
|
||||||
an address on a different network, NAK it. If the Requested
|
an address on a different network, NAK it. If the Requested
|
||||||
@@ -249,11 +256,15 @@ void dhcprelease (packet)
|
|||||||
{
|
{
|
||||||
struct lease *lease = find_lease (packet, packet -> shared_network);
|
struct lease *lease = find_lease (packet, packet -> shared_network);
|
||||||
|
|
||||||
note ("DHCPRELEASE of %s from %s",
|
note ("DHCPRELEASE of %s from %s via %s",
|
||||||
inet_ntoa (packet -> raw -> ciaddr),
|
inet_ntoa (packet -> raw -> ciaddr),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
|
|
||||||
/* If we found a lease, release it. */
|
/* If we found a lease, release it. */
|
||||||
if (lease) {
|
if (lease) {
|
||||||
@@ -276,11 +287,15 @@ void dhcpdecline (packet)
|
|||||||
cip.len = 0;
|
cip.len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
note ("DHCPDECLINE on %s from %s",
|
note ("DHCPDECLINE on %s from %s via %s",
|
||||||
piaddr (cip),
|
piaddr (cip),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
|
|
||||||
/* If we found a lease, mark it as unusable and complain. */
|
/* If we found a lease, mark it as unusable and complain. */
|
||||||
if (lease) {
|
if (lease) {
|
||||||
@@ -293,7 +308,6 @@ void dhcpinform (packet)
|
|||||||
{
|
{
|
||||||
note ("DHCPINFORM from %s",
|
note ("DHCPINFORM from %s",
|
||||||
inet_ntoa (packet -> raw -> ciaddr));
|
inet_ntoa (packet -> raw -> ciaddr));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nak_lease (packet, cip)
|
void nak_lease (packet, cip)
|
||||||
@@ -354,11 +368,16 @@ void nak_lease (packet, cip)
|
|||||||
raw.op = BOOTREPLY;
|
raw.op = BOOTREPLY;
|
||||||
|
|
||||||
/* Report what we're sending... */
|
/* Report what we're sending... */
|
||||||
note ("DHCPNAK on %s to %s",
|
note ("DHCPNAK on %s to %s via %s",
|
||||||
piaddr (*cip),
|
piaddr (*cip),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_PACKET
|
#ifdef DEBUG_PACKET
|
||||||
dump_packet (packet);
|
dump_packet (packet);
|
||||||
@@ -717,14 +736,17 @@ void ack_lease (packet, lease, offer, when)
|
|||||||
raw.op = BOOTREPLY;
|
raw.op = BOOTREPLY;
|
||||||
|
|
||||||
/* Say what we're doing... */
|
/* Say what we're doing... */
|
||||||
note ("%s on %s to %s",
|
note ("%s on %s to %s via %s",
|
||||||
(offer
|
(offer
|
||||||
? (offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
|
? (offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
|
||||||
: "BOOTREPLY"),
|
: "BOOTREPLY"),
|
||||||
piaddr (lease -> ip_addr),
|
piaddr (lease -> ip_addr),
|
||||||
print_hw_addr (packet -> raw -> htype,
|
print_hw_addr (packet -> raw -> htype,
|
||||||
packet -> raw -> hlen,
|
packet -> raw -> hlen,
|
||||||
packet -> raw -> chaddr));
|
packet -> raw -> chaddr),
|
||||||
|
packet -> raw -> giaddr.s_addr
|
||||||
|
? inet_ntoa (packet -> raw -> giaddr)
|
||||||
|
: packet -> interface -> name);
|
||||||
|
|
||||||
/* Set up the hardware address... */
|
/* Set up the hardware address... */
|
||||||
hto.htype = packet -> raw -> htype;
|
hto.htype = packet -> raw -> htype;
|
||||||
|
Reference in New Issue
Block a user