Commit 633cd472 authored by Dan Williams's avatar Dan Williams
Browse files

2005-02-10 Dan Williams <dcbw@redhat.com>

	* dhcpcd/buildmsg.c
		- (fill_host_and_class_id): only fill in client and class IDs if
			they are set by callers.

	* dhcpcd/client.c
		- (class_id_setup): don't autogenerate a class ID, only use one
			we're given, if any.
		- (client_id_setup): don't autogenerate a client ID, only use one
			we're given, if any.

	* dhcpcd/dhcpcd.c
		- (dhcp_interface_init): ensure that client options are correctly
			NULL terminated

	* src/NetworkManagerDHCP.c
		- (nm_device_dhcp_request): pass hostname to dhcp library


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@429 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 02bcf5aa
2005-02-10 Dan Williams <dcbw@redhat.com>
* dhcpcd/buildmsg.c
- (fill_host_and_class_id): only fill in client and class IDs if
they are set by callers.
* dhcpcd/client.c
- (class_id_setup): don't autogenerate a class ID, only use one
we're given, if any.
- (client_id_setup): don't autogenerate a client ID, only use one
we're given, if any.
* dhcpcd/dhcpcd.c
- (dhcp_interface_init): ensure that client options are correctly
NULL terminated
* src/NetworkManagerDHCP.c
- (nm_device_dhcp_request): pass hostname to dhcp library
2005-02-10 Dan Williams <dcbw@redhat.com>
* dhcpcd/client.c
......
......@@ -61,22 +61,29 @@ unsigned char *fill_host_and_class_id (dhcp_interface *iface, unsigned char *p)
const char *host_name = iface->client_options->host_name;
int host_name_len = strlen (host_name);
if ( host_name_len )
if (host_name_len)
{
*p++ = hostName;
*p++ = host_name_len;
memcpy (p, host_name, host_name_len);
p += host_name_len;
}
*p++ = dhcpClassIdentifier;
*p++ = iface->cls_id_len;
memcpy (p, iface->cls_id, iface->cls_id_len);
p += iface->cls_id_len;
*p++ = dhcpClientIdentifier;
*p++ = iface->cli_id_len;
memcpy (p, iface->cli_id, iface->cli_id_len);
p += iface->cli_id_len;
if (iface->cls_id_len)
{
*p++ = dhcpClassIdentifier;
*p++ = iface->cls_id_len;
memcpy (p, iface->cls_id, iface->cls_id_len);
p += iface->cls_id_len;
}
if (iface->cli_id_len)
{
*p++ = dhcpClientIdentifier;
*p++ = iface->cli_id_len;
memcpy (p, iface->cli_id, iface->cli_id_len);
p += iface->cli_id_len;
}
return p;
}
......
......@@ -286,6 +286,7 @@ void class_id_setup (dhcp_interface *iface, const char *g_cls_id)
if (!iface) return;
iface->cls_id_len = 0;
memset (iface->cls_id, 0, DHCP_CLASS_ID_MAX_LEN);
if (g_cls_id)
......@@ -296,14 +297,6 @@ void class_id_setup (dhcp_interface *iface, const char *g_cls_id)
memcpy (iface->cls_id, g_cls_id, g_cls_id_len);
iface->cls_id_len = g_cls_id_len;
}
else
{
struct utsname sname;
if ( uname(&sname) )
syslog (LOG_ERR,"class_id_setup(): uname returned an error: %m\n");
snprintf (iface->cls_id, DHCP_CLASS_ID_MAX_LEN, "%s", sname.sysname);
iface->cls_id_len = strlen (iface->cls_id);
}
}
/*****************************************************************************/
void client_id_setup (dhcp_interface *iface, const char *g_cli_id)
......@@ -313,6 +306,7 @@ void client_id_setup (dhcp_interface *iface, const char *g_cli_id)
if (!iface) return;
iface->cli_id_len = 0;
memset (iface->cli_id, 0, DHCP_CLIENT_ID_MAX_LEN);
c = iface->cli_id;
......@@ -325,12 +319,6 @@ void client_id_setup (dhcp_interface *iface, const char *g_cli_id)
memcpy (c, g_cli_id, g_cli_id_len);
iface->cli_id_len = g_cli_id_len + 1;
}
else
{
*c++ = ARPHRD_ETHER; /* type: Ethernet address */
memcpy (c, iface->chaddr, ETH_ALEN);
iface->cli_id_len = ETH_ALEN + 1;
}
}
/*****************************************************************************/
void release_dhcp_options (dhcp_interface *iface)
......
......@@ -72,11 +72,16 @@ dhcp_interface *dhcp_interface_init (const char *if_name, dhcp_client_options *i
iface->sk = -1;
iface->foo_sk = -1;
/* Copy in client-specific options */
if (!(opts = calloc (1, sizeof (dhcp_client_options))))
goto err_out;
memcpy (opts, in_opts, sizeof (dhcp_client_options));
opts->host_name[DHCP_HOSTNAME_MAX_LEN - 1] = '\0';
opts->class_id[DHCP_CLASS_ID_MAX_LEN - 1] = '\0';
opts->client_id[DHCP_CLIENT_ID_MAX_LEN - 1] = '\0';
iface->client_options = opts;
/* Grab a control socket for the device */
memset (&ifr, 0, sizeof(struct ifreq));
memcpy (ifr.ifr_name, iface->iface, strlen (iface->iface));
iface->sk = socket (AF_PACKET, SOCK_PACKET, htons(ETH_P_ALL));
......
......@@ -208,7 +208,8 @@ int nm_device_dhcp_request (NMDevice *dev)
}
memset (&opts, 0, sizeof (dhcp_client_options));
opts.base_timeout = 30;
gethostname (&(opts.host_name[0]), DHCP_HOSTNAME_MAX_LEN);
opts.base_timeout = 30;
if (!(dev->dhcp_iface = dhcp_interface_init (nm_device_get_iface (dev), &opts)))
return RET_DHCP_ERROR;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment