summaryrefslogtreecommitdiff
path: root/gdhcp
diff options
context:
space:
mode:
authorGrant Erickson <marathon96@gmail.com>2012-02-13 17:56:08 (GMT)
committerSamuel Ortiz <sameo@linux.intel.com>2012-02-13 18:24:32 (GMT)
commitb540226ada933b5364ac0d44d345d8cc888e78e7 (patch)
tree03fee4c9f09fde13e996b53bb14d30f49f2f5780 /gdhcp
parentdf176bf9cdf59757b6ea10281ad19ae47f935234 (diff)
downloadconnman-b540226ada933b5364ac0d44d345d8cc888e78e7.zip
connman-b540226ada933b5364ac0d44d345d8cc888e78e7.tar.gz
connman-b540226ada933b5364ac0d44d345d8cc888e78e7.tar.bz2
gdhcp: Add RFC 1533- and 2132-compliant client-id option
This patch adds a function to add a RFC 1533- and 2132-compliant DHCP client-id option (61) to sent DHCPv4 packets.
Diffstat (limited to 'gdhcp')
-rw-r--r--gdhcp/client.c22
-rw-r--r--gdhcp/gdhcp.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index c11f019..a3b4b8a 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -2470,6 +2470,28 @@ static uint8_t *alloc_dhcp_string_option(int code, const char *str)
return alloc_dhcp_data_option(code, (const uint8_t *)str, strlen(str));
}
+GDHCPClientError g_dhcp_client_set_id(GDHCPClient *dhcp_client)
+{
+ const unsigned maclen = 6;
+ const unsigned idlen = maclen + 1;
+ const uint8_t option_code = G_DHCP_CLIENT_ID;
+ uint8_t idbuf[idlen];
+ uint8_t *data_option;
+
+ idbuf[0] = ARPHRD_ETHER;
+
+ memcpy(&idbuf[1], dhcp_client->mac_address, maclen);
+
+ data_option = alloc_dhcp_data_option(option_code, idbuf, idlen);
+ if (data_option == NULL)
+ return G_DHCP_CLIENT_ERROR_NOMEM;
+
+ g_hash_table_insert(dhcp_client->send_value_hash,
+ GINT_TO_POINTER((int) option_code), data_option);
+
+ return G_DHCP_CLIENT_ERROR_NONE;
+}
+
/* Now only support send hostname */
GDHCPClientError g_dhcp_client_set_send(GDHCPClient *dhcp_client,
unsigned char option_code, const char *option_value)
diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h
index edebc9e..4453b26 100644
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -74,6 +74,7 @@ typedef enum {
#define G_DHCP_DOMAIN_NAME 0x0f
#define G_DHCP_HOST_NAME 0x0c
#define G_DHCP_NTP_SERVER 0x2a
+#define G_DHCP_CLIENT_ID 0x3d
#define G_DHCPV6_CLIENTID 1
#define G_DHCPV6_SERVERID 2
@@ -121,6 +122,7 @@ GDHCPClientError g_dhcp_client_set_request(GDHCPClient *client,
unsigned int option_code);
void g_dhcp_client_clear_requests(GDHCPClient *dhcp_client);
void g_dhcp_client_clear_values(GDHCPClient *dhcp_client);
+GDHCPClientError g_dhcp_client_set_id(GDHCPClient *client);
GDHCPClientError g_dhcp_client_set_send(GDHCPClient *client,
unsigned char option_code,
const char *option_value);