dhcp: relocate type field

The type field is a DHCP-specific parameter. Relocate the parameter so
there is a clearer separation between DHCP and BOOTP parameters.
This commit is contained in:
Colin Foster
2025-06-11 05:50:20 -05:00
committed by Yu Watanabe
parent 984ae058dc
commit be40a31f5c
5 changed files with 8 additions and 8 deletions

View File

@@ -17,10 +17,10 @@ int dhcp_message_init(
DHCPMessage *message,
uint8_t op,
uint32_t xid,
uint8_t type,
uint16_t arp_type,
uint8_t hlen,
const uint8_t *chaddr,
uint8_t type,
size_t optlen,
size_t *optoffset) {

View File

@@ -8,10 +8,10 @@ int dhcp_message_init(
DHCPMessage *message,
uint8_t op,
uint32_t xid,
uint8_t type,
uint16_t arp_type,
uint8_t hlen,
const uint8_t *chaddr,
uint8_t type,
size_t optlen,
size_t *optoffset);

View File

@@ -789,9 +789,9 @@ static int client_message_init(
if (!packet)
return -ENOMEM;
r = dhcp_message_init(&packet->dhcp, BOOTREQUEST, client->xid, type,
r = dhcp_message_init(&packet->dhcp, BOOTREQUEST, client->xid,
client->arp_type, client->hw_addr.length, client->hw_addr.bytes,
optlen, &optoffset);
type, optlen, &optoffset);
if (r < 0)
return r;

View File

@@ -518,9 +518,9 @@ static int server_message_init(
return -ENOMEM;
r = dhcp_message_init(&packet->dhcp, BOOTREPLY,
be32toh(req->message->xid), type,
be32toh(req->message->xid),
req->message->htype, req->message->hlen, req->message->chaddr,
req->max_optlen, &optoffset);
type, req->max_optlen, &optoffset);
if (r < 0)
return r;
@@ -713,7 +713,7 @@ static int server_send_forcerenew(
return -ENOMEM;
r = dhcp_message_init(&packet->dhcp, BOOTREPLY, 0,
DHCP_FORCERENEW, htype, hlen, chaddr,
htype, hlen, chaddr, DHCP_FORCERENEW,
DHCP_MIN_OPTIONS_SIZE, &optoffset);
if (r < 0)
return r;

View File

@@ -87,7 +87,7 @@ static void test_message_init(void) {
message = malloc0(len);
assert_se(dhcp_message_init(message, BOOTREQUEST, 0x12345678,
DHCP_DISCOVER, ARPHRD_ETHER, ETH_ALEN, (uint8_t[16]){},
ARPHRD_ETHER, ETH_ALEN, (uint8_t[16]){}, DHCP_DISCOVER,
optlen, &optoffset) >= 0);
assert_se(message->xid == htobe32(0x12345678));