.filter = (struct sock_filter *) filter_instr,
};
- fd = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IP));
+ fd = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (fd < 0)
return -errno;
return 3600;
lease_seconds = get_be32(option);
- /* paranoia: must not be prone to overflows */
- lease_seconds &= 0x0fffffff;
+
if (lease_seconds < 10)
lease_seconds = 10;
switch_listening_mode(dhcp_client, L2);
send_request(dhcp_client);
- if (dhcp_client->t2_timeout> 0)
+ if (dhcp_client->t2_timeout> 0) {
g_source_remove(dhcp_client->t2_timeout);
+ dhcp_client->t2_timeout = 0;
+ }
/*recalculate remaining rebind time*/
dhcp_client->T2 >>= 1;
if (dhcp_client->type == G_DHCP_IPV6) {
re = dhcpv6_recv_l3_packet(&packet6, buf, sizeof(buf),
dhcp_client->listener_sockfd);
+ if (re < 0)
+ return TRUE;
pkt_len = re;
pkt = packet6;
xid = packet6->transaction_id[0] << 16 |
return TRUE;
}
- if (!message_type && !client_id)
- /* No message type / client id option, ignore package */
- return TRUE;
-
debug(dhcp_client, "received DHCP packet xid 0x%04x "
"(current state %d)", ntohl(xid), dhcp_client->state);
return G_DHCP_CLIENT_ERROR_NONE;
}
-/* Now only support send hostname */
+/* Now only support send hostname and vendor class ID */
GDHCPClientError g_dhcp_client_set_send(GDHCPClient *dhcp_client,
unsigned char option_code, const char *option_value)
{
uint8_t *binary_option;
- if (option_code == G_DHCP_HOST_NAME && option_value) {
+ if ((option_code == G_DHCP_HOST_NAME ||
+ option_code == G_DHCP_VENDOR_CLASS_ID) && option_value) {
binary_option = alloc_dhcp_string_option(option_code,
option_value);
if (!binary_option)