mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-27 07:00:40 +01:00
dhcp: merge branch 'th/bgo726278_div_refact_dhcp'
https://bugzilla.gnome.org/show_bug.cgi?id=726278 Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
commit
542832eeb3
10 changed files with 122 additions and 150 deletions
|
|
@ -2774,14 +2774,10 @@ dhcp4_start (NMDevice *self,
|
|||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMSettingIP4Config *s_ip4;
|
||||
guint8 *anycast = NULL;
|
||||
GByteArray *tmp = NULL;
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
|
||||
if (priv->dhcp_anycast_address)
|
||||
anycast = priv->dhcp_anycast_address->data;
|
||||
|
||||
/* Clear old exported DHCP options */
|
||||
if (priv->dhcp4_config)
|
||||
g_object_unref (priv->dhcp4_config);
|
||||
|
|
@ -2800,7 +2796,7 @@ dhcp4_start (NMDevice *self,
|
|||
nm_connection_get_uuid (connection),
|
||||
s_ip4,
|
||||
priv->dhcp_timeout,
|
||||
anycast);
|
||||
priv->dhcp_anycast_address);
|
||||
|
||||
if (tmp)
|
||||
g_byte_array_free (tmp, TRUE);
|
||||
|
|
@ -2811,11 +2807,11 @@ dhcp4_start (NMDevice *self,
|
|||
}
|
||||
|
||||
priv->dhcp4_state_sigid = g_signal_connect (priv->dhcp4_client,
|
||||
"state-changed",
|
||||
NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED,
|
||||
G_CALLBACK (dhcp4_state_changed),
|
||||
self);
|
||||
priv->dhcp4_timeout_sigid = g_signal_connect (priv->dhcp4_client,
|
||||
"timeout",
|
||||
NM_DHCP_CLIENT_SIGNAL_TIMEOUT,
|
||||
G_CALLBACK (dhcp4_timeout),
|
||||
self);
|
||||
|
||||
|
|
@ -3206,7 +3202,6 @@ dhcp6_start (NMDevice *self,
|
|||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||
guint8 *anycast = NULL;
|
||||
GByteArray *tmp = NULL;
|
||||
|
||||
if (!connection) {
|
||||
|
|
@ -3216,9 +3211,6 @@ dhcp6_start (NMDevice *self,
|
|||
|
||||
/* Begin a DHCP transaction on the interface */
|
||||
|
||||
if (priv->dhcp_anycast_address)
|
||||
anycast = priv->dhcp_anycast_address->data;
|
||||
|
||||
/* Clear old exported DHCP options */
|
||||
if (priv->dhcp6_config)
|
||||
g_object_unref (priv->dhcp6_config);
|
||||
|
|
@ -3241,18 +3233,18 @@ dhcp6_start (NMDevice *self,
|
|||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_setting_ip6_config (connection),
|
||||
priv->dhcp_timeout,
|
||||
anycast,
|
||||
priv->dhcp_anycast_address,
|
||||
(dhcp_opt == NM_RDISC_DHCP_LEVEL_OTHERCONF) ? TRUE : FALSE);
|
||||
if (tmp)
|
||||
g_byte_array_free (tmp, TRUE);
|
||||
|
||||
if (priv->dhcp6_client) {
|
||||
priv->dhcp6_state_sigid = g_signal_connect (priv->dhcp6_client,
|
||||
"state-changed",
|
||||
NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED,
|
||||
G_CALLBACK (dhcp6_state_changed),
|
||||
self);
|
||||
priv->dhcp6_timeout_sigid = g_signal_connect (priv->dhcp6_client,
|
||||
"timeout",
|
||||
NM_DHCP_CLIENT_SIGNAL_TIMEOUT,
|
||||
G_CALLBACK (dhcp6_timeout),
|
||||
self);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ typedef struct {
|
|||
G_DEFINE_TYPE_EXTENDED (NMDHCPClient, nm_dhcp_client, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT, {})
|
||||
|
||||
enum {
|
||||
STATE_CHANGED,
|
||||
TIMEOUT,
|
||||
REMOVE,
|
||||
SIGNAL_STATE_CHANGED,
|
||||
SIGNAL_TIMEOUT,
|
||||
SIGNAL_REMOVE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ daemon_timeout (gpointer user_data)
|
|||
} else {
|
||||
nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 request timed out.", priv->iface);
|
||||
}
|
||||
g_signal_emit (G_OBJECT (self), signals[TIMEOUT], 0);
|
||||
g_signal_emit (G_OBJECT (self), signals[SIGNAL_TIMEOUT], 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ signal_remove (gpointer user_data)
|
|||
NMDHCPClient *self = NM_DHCP_CLIENT (user_data);
|
||||
|
||||
NM_DHCP_CLIENT_GET_PRIVATE (self)->remove_id = 0;
|
||||
g_signal_emit (G_OBJECT (self), signals[REMOVE], 0);
|
||||
g_signal_emit (G_OBJECT (self), signals[SIGNAL_REMOVE], 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -234,12 +234,12 @@ dhcp_client_set_state (NMDHCPClient *self,
|
|||
priv->state = state;
|
||||
|
||||
if (emit_state)
|
||||
g_signal_emit (G_OBJECT (self), signals[STATE_CHANGED], 0, priv->state);
|
||||
g_signal_emit (G_OBJECT (self), signals[SIGNAL_STATE_CHANGED], 0, priv->state);
|
||||
|
||||
if (state == DHC_END || state == DHC_ABEND) {
|
||||
/* Start the remove signal timer */
|
||||
if (remove_now) {
|
||||
g_signal_emit (G_OBJECT (self), signals[REMOVE], 0);
|
||||
g_signal_emit (G_OBJECT (self), signals[SIGNAL_REMOVE], 0);
|
||||
} else {
|
||||
if (!priv->remove_id)
|
||||
priv->remove_id = g_timeout_add_seconds (5, signal_remove, self);
|
||||
|
|
@ -295,8 +295,8 @@ start_monitor (NMDHCPClient *self)
|
|||
|
||||
gboolean
|
||||
nm_dhcp_client_start_ip4 (NMDHCPClient *self,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname)
|
||||
{
|
||||
NMDHCPClientPrivate *priv;
|
||||
|
|
@ -311,7 +311,7 @@ nm_dhcp_client_start_ip4 (NMDHCPClient *self,
|
|||
nm_log_info (LOGD_DHCP, "Activation (%s) Beginning DHCPv4 transaction (timeout in %d seconds)",
|
||||
priv->iface, priv->timeout);
|
||||
|
||||
priv->pid = NM_DHCP_CLIENT_GET_CLASS (self)->ip4_start (self, s_ip4, dhcp_anycast_addr, hostname);
|
||||
priv->pid = NM_DHCP_CLIENT_GET_CLASS (self)->ip4_start (self, dhcp_client_id, dhcp_anycast_addr, hostname);
|
||||
if (priv->pid)
|
||||
start_monitor (self);
|
||||
|
||||
|
|
@ -449,8 +449,7 @@ get_duid (NMDHCPClient *self)
|
|||
|
||||
gboolean
|
||||
nm_dhcp_client_start_ip6 (NMDHCPClient *self,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only)
|
||||
{
|
||||
|
|
@ -482,7 +481,6 @@ nm_dhcp_client_start_ip6 (NMDHCPClient *self,
|
|||
priv->iface, priv->timeout);
|
||||
|
||||
priv->pid = NM_DHCP_CLIENT_GET_CLASS (self)->ip6_start (self,
|
||||
s_ip6,
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
info_only,
|
||||
|
|
@ -577,63 +575,54 @@ state_is_bound (guint32 state)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
NMDHCPState state;
|
||||
const char *name;
|
||||
} DhcState;
|
||||
|
||||
#define STATE_TABLE_SIZE (sizeof (state_table) / sizeof (state_table[0]))
|
||||
|
||||
static DhcState state_table[] = {
|
||||
{ DHC_NBI, "nbi" },
|
||||
{ DHC_PREINIT, "preinit" },
|
||||
{ DHC_PREINIT6,"preinit6" },
|
||||
{ DHC_BOUND4, "bound" },
|
||||
{ DHC_BOUND6, "bound6" },
|
||||
{ DHC_IPV4LL, "ipv4ll" },
|
||||
{ DHC_RENEW4, "renew" },
|
||||
{ DHC_RENEW6, "renew6" },
|
||||
{ DHC_REBOOT, "reboot" },
|
||||
{ DHC_REBIND4, "rebind" },
|
||||
{ DHC_REBIND6, "rebind6" },
|
||||
{ DHC_STOP, "stop" },
|
||||
{ DHC_STOP6, "stop6" },
|
||||
{ DHC_MEDIUM, "medium" },
|
||||
{ DHC_TIMEOUT, "timeout" },
|
||||
{ DHC_FAIL, "fail" },
|
||||
{ DHC_EXPIRE, "expire" },
|
||||
{ DHC_EXPIRE6, "expire6" },
|
||||
{ DHC_RELEASE, "release" },
|
||||
{ DHC_RELEASE6,"release6" },
|
||||
{ DHC_START, "start" },
|
||||
{ DHC_ABEND, "abend" },
|
||||
{ DHC_END, "end" },
|
||||
{ DHC_DEPREF6, "depref6" },
|
||||
static const char *state_table[] = {
|
||||
[DHC_NBI] = "nbi",
|
||||
[DHC_PREINIT] = "preinit",
|
||||
[DHC_PREINIT6] = "preinit6",
|
||||
[DHC_BOUND4] = "bound",
|
||||
[DHC_BOUND6] = "bound6",
|
||||
[DHC_IPV4LL] = "ipv4ll",
|
||||
[DHC_RENEW4] = "renew",
|
||||
[DHC_RENEW6] = "renew6",
|
||||
[DHC_REBOOT] = "reboot",
|
||||
[DHC_REBIND4] = "rebind",
|
||||
[DHC_REBIND6] = "rebind6",
|
||||
[DHC_DEPREF6] = "depref6",
|
||||
[DHC_STOP] = "stop",
|
||||
[DHC_STOP6] = "stop6",
|
||||
[DHC_MEDIUM] = "medium",
|
||||
[DHC_TIMEOUT] = "timeout",
|
||||
[DHC_FAIL] = "fail",
|
||||
[DHC_EXPIRE] = "expire",
|
||||
[DHC_EXPIRE6] = "expire6",
|
||||
[DHC_RELEASE] = "release",
|
||||
[DHC_RELEASE6] = "release6",
|
||||
[DHC_START] = "start",
|
||||
[DHC_ABEND] = "abend",
|
||||
[DHC_END] = "end",
|
||||
};
|
||||
|
||||
static inline const char *
|
||||
state_to_string (guint32 state)
|
||||
static const char *
|
||||
state_to_string (NMDHCPState state)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < STATE_TABLE_SIZE; i++) {
|
||||
if (state == state_table[i].state)
|
||||
return state_table[i].name;
|
||||
}
|
||||
|
||||
if (state >= 0 && state < G_N_ELEMENTS (state_table))
|
||||
return state_table[state];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline NMDHCPState
|
||||
static NMDHCPState
|
||||
string_to_state (const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < STATE_TABLE_SIZE; i++) {
|
||||
if (!strcasecmp (name, state_table[i].name))
|
||||
return state_table[i].state;
|
||||
}
|
||||
if (name) {
|
||||
for (i = 0; i < G_N_ELEMENTS (state_table); i++) {
|
||||
const char *n = state_table[i];
|
||||
|
||||
if (n && !strcasecmp (name, n))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 255;
|
||||
}
|
||||
|
||||
|
|
@ -1636,8 +1625,8 @@ nm_dhcp_client_class_init (NMDHCPClientClass *client_class)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/* signals */
|
||||
signals[STATE_CHANGED] =
|
||||
g_signal_new ("state-changed",
|
||||
signals[SIGNAL_STATE_CHANGED] =
|
||||
g_signal_new (NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMDHCPClientClass, state_changed),
|
||||
|
|
@ -1645,8 +1634,8 @@ nm_dhcp_client_class_init (NMDHCPClientClass *client_class)
|
|||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE, 1, G_TYPE_UINT);
|
||||
|
||||
signals[TIMEOUT] =
|
||||
g_signal_new ("timeout",
|
||||
signals[SIGNAL_TIMEOUT] =
|
||||
g_signal_new (NM_DHCP_CLIENT_SIGNAL_TIMEOUT,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMDHCPClientClass, timeout),
|
||||
|
|
@ -1654,8 +1643,8 @@ nm_dhcp_client_class_init (NMDHCPClientClass *client_class)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[REMOVE] =
|
||||
g_signal_new ("remove",
|
||||
signals[SIGNAL_REMOVE] =
|
||||
g_signal_new (NM_DHCP_CLIENT_SIGNAL_REMOVE,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMDHCPClientClass, remove),
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@
|
|||
#define NM_DHCP_CLIENT_UUID "uuid"
|
||||
#define NM_DHCP_CLIENT_TIMEOUT "timeout"
|
||||
|
||||
#define NM_DHCP_CLIENT_SIGNAL_TIMEOUT "timeout"
|
||||
#define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed"
|
||||
#define NM_DHCP_CLIENT_SIGNAL_REMOVE "remove"
|
||||
|
||||
typedef enum {
|
||||
DHC_NBI = 0, /* no broadcast interfaces found */
|
||||
DHC_PREINIT, /* configuration started */
|
||||
|
|
@ -78,13 +82,12 @@ typedef struct {
|
|||
/* Methods */
|
||||
|
||||
GPid (*ip4_start) (NMDHCPClient *self,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
guint8 *anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *anycast_addr,
|
||||
const char *hostname);
|
||||
|
||||
GPid (*ip6_start) (NMDHCPClient *self,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *anycast_addr,
|
||||
GByteArray *anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
const GByteArray *duid);
|
||||
|
|
@ -121,13 +124,12 @@ gboolean nm_dhcp_client_get_ipv6 (NMDHCPClient *self);
|
|||
const char *nm_dhcp_client_get_uuid (NMDHCPClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_start_ip4 (NMDHCPClient *self,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname);
|
||||
|
||||
gboolean nm_dhcp_client_start_ip6 (NMDHCPClient *self,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,21 +70,18 @@ add_hostname (GString *str, const char *format, const char *hostname)
|
|||
}
|
||||
|
||||
static void
|
||||
add_ip4_config (GString *str, NMSettingIP4Config *s_ip4, const char *hostname)
|
||||
add_ip4_config (GString *str, const char *dhcp_client_id, const char *hostname)
|
||||
{
|
||||
const char *tmp;
|
||||
|
||||
tmp = nm_setting_ip4_config_get_dhcp_client_id (s_ip4);
|
||||
if (tmp) {
|
||||
if (dhcp_client_id) {
|
||||
gboolean is_octets = TRUE;
|
||||
int i = 0;
|
||||
|
||||
while (tmp[i]) {
|
||||
if ((i % 3) != 2 && !g_ascii_isxdigit (tmp[i])) {
|
||||
while (dhcp_client_id[i]) {
|
||||
if ((i % 3) != 2 && !g_ascii_isxdigit (dhcp_client_id[i])) {
|
||||
is_octets = FALSE;
|
||||
break;
|
||||
}
|
||||
if ((i % 3) == 2 && tmp[i] != ':') {
|
||||
if ((i % 3) == 2 && dhcp_client_id[i] != ':') {
|
||||
is_octets = FALSE;
|
||||
break;
|
||||
}
|
||||
|
|
@ -96,9 +93,9 @@ add_ip4_config (GString *str, NMSettingIP4Config *s_ip4, const char *hostname)
|
|||
* array formated as hex octets separated by :
|
||||
*/
|
||||
if (is_octets)
|
||||
g_string_append_printf (str, CLIENTID_FORMAT_OCTETS "\n", tmp);
|
||||
g_string_append_printf (str, CLIENTID_FORMAT_OCTETS "\n", dhcp_client_id);
|
||||
else
|
||||
g_string_append_printf (str, CLIENTID_FORMAT "\n", tmp);
|
||||
g_string_append_printf (str, CLIENTID_FORMAT "\n", dhcp_client_id);
|
||||
}
|
||||
|
||||
add_hostname (str, HOSTNAME4_FORMAT "\n", hostname);
|
||||
|
|
@ -117,7 +114,7 @@ add_ip4_config (GString *str, NMSettingIP4Config *s_ip4, const char *hostname)
|
|||
}
|
||||
|
||||
static void
|
||||
add_ip6_config (GString *str, NMSettingIP6Config *s_ip6, const char *hostname)
|
||||
add_ip6_config (GString *str, const char *hostname)
|
||||
{
|
||||
add_hostname (str, HOSTNAME6_FORMAT "\n", hostname);
|
||||
g_string_append (str,
|
||||
|
|
@ -129,9 +126,8 @@ add_ip6_config (GString *str, NMSettingIP6Config *s_ip6, const char *hostname)
|
|||
char *
|
||||
nm_dhcp_dhclient_create_config (const char *interface,
|
||||
gboolean is_ip6,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *anycast_addr,
|
||||
const char *hostname,
|
||||
const char *orig_path,
|
||||
const char *orig_contents)
|
||||
|
|
@ -159,8 +155,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
/* Override config file "dhcp-client-id" and use one from the
|
||||
* connection.
|
||||
*/
|
||||
if ( nm_setting_ip4_config_get_dhcp_client_id (s_ip4)
|
||||
&& !strncmp (p, CLIENTID_TAG, strlen (CLIENTID_TAG)))
|
||||
if (dhcp_client_id && !strncmp (p, CLIENTID_TAG, strlen (CLIENTID_TAG)))
|
||||
continue;
|
||||
|
||||
/* Override config file hostname and use one from the connection */
|
||||
|
|
@ -225,13 +220,13 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
g_string_append_c (new_contents, '\n');
|
||||
|
||||
if (is_ip6) {
|
||||
add_ip6_config (new_contents, s_ip6, hostname);
|
||||
add_ip6_config (new_contents, hostname);
|
||||
add_also_request (alsoreq, "dhcp6.name-servers");
|
||||
add_also_request (alsoreq, "dhcp6.domain-search");
|
||||
add_also_request (alsoreq, "dhcp6.client-id");
|
||||
add_also_request (alsoreq, "dhcp6.server-id");
|
||||
} else {
|
||||
add_ip4_config (new_contents, s_ip4, hostname);
|
||||
add_ip4_config (new_contents, dhcp_client_id, hostname);
|
||||
add_also_request (alsoreq, "rfc3442-classless-static-routes");
|
||||
add_also_request (alsoreq, "ms-classless-static-routes");
|
||||
add_also_request (alsoreq, "static-routes");
|
||||
|
|
@ -250,17 +245,22 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
|
||||
g_string_append_c (new_contents, '\n');
|
||||
|
||||
if (anycast_addr) {
|
||||
if (anycast_addr && anycast_addr->len == 6) {
|
||||
const guint8 *p_anycast_addr = anycast_addr->data;
|
||||
|
||||
g_string_append_printf (new_contents, "interface \"%s\" {\n"
|
||||
" initial-interval 1; \n"
|
||||
" anycast-mac ethernet %02x:%02x:%02x:%02x:%02x:%02x;\n"
|
||||
"}\n",
|
||||
interface,
|
||||
anycast_addr[0], anycast_addr[1],
|
||||
anycast_addr[2], anycast_addr[3],
|
||||
anycast_addr[4], anycast_addr[5]);
|
||||
p_anycast_addr[0], p_anycast_addr[1],
|
||||
p_anycast_addr[2], p_anycast_addr[3],
|
||||
p_anycast_addr[4], p_anycast_addr[5]);
|
||||
}
|
||||
|
||||
/* Finally, assert that anycast_addr was unset or a 48 bit mac address. */
|
||||
g_return_val_if_fail (!anycast_addr || anycast_addr->len == 6, g_string_free (new_contents, FALSE));
|
||||
|
||||
return g_string_free (new_contents, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@
|
|||
|
||||
char *nm_dhcp_dhclient_create_config (const char *interface,
|
||||
gboolean is_ip6,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *anycast_addr,
|
||||
const char *hostname,
|
||||
const char *orig_path,
|
||||
const char *orig_contents);
|
||||
|
|
|
|||
|
|
@ -165,9 +165,8 @@ static gboolean
|
|||
merge_dhclient_config (const char *iface,
|
||||
const char *conf_file,
|
||||
gboolean is_ip6,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *anycast_addr,
|
||||
const char *hostname,
|
||||
const char *orig_path,
|
||||
GError **error)
|
||||
|
|
@ -188,7 +187,7 @@ merge_dhclient_config (const char *iface,
|
|||
}
|
||||
}
|
||||
|
||||
new = nm_dhcp_dhclient_create_config (iface, is_ip6, s_ip4, s_ip6, anycast_addr, hostname, orig_path, orig);
|
||||
new = nm_dhcp_dhclient_create_config (iface, is_ip6, dhcp_client_id, anycast_addr, hostname, orig_path, orig);
|
||||
g_assert (new);
|
||||
success = g_file_set_contents (conf_file, new, -1, error);
|
||||
g_free (new);
|
||||
|
|
@ -272,9 +271,8 @@ static char *
|
|||
create_dhclient_config (const char *iface,
|
||||
gboolean is_ip6,
|
||||
const char *uuid,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname)
|
||||
{
|
||||
char *orig = NULL, *new = NULL;
|
||||
|
|
@ -300,7 +298,7 @@ create_dhclient_config (const char *iface,
|
|||
}
|
||||
|
||||
error = NULL;
|
||||
success = merge_dhclient_config (iface, new, is_ip6, s_ip4, s_ip6, dhcp_anycast_addr, hostname, orig, &error);
|
||||
success = merge_dhclient_config (iface, new, is_ip6, dhcp_client_id, dhcp_anycast_addr, hostname, orig, &error);
|
||||
if (!success) {
|
||||
nm_log_warn (LOGD_DHCP, "(%s): error creating dhclient%s configuration: %s",
|
||||
iface, is_ip6 ? "6" : "", error->message);
|
||||
|
|
@ -475,8 +473,8 @@ dhclient_start (NMDHCPClient *client,
|
|||
|
||||
static GPid
|
||||
ip4_start (NMDHCPClient *client,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname)
|
||||
{
|
||||
NMDHCPDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (client);
|
||||
|
|
@ -485,7 +483,7 @@ ip4_start (NMDHCPClient *client,
|
|||
iface = nm_dhcp_client_get_iface (client);
|
||||
uuid = nm_dhcp_client_get_uuid (client);
|
||||
|
||||
priv->conf_file = create_dhclient_config (iface, FALSE, uuid, s_ip4, NULL, dhcp_anycast_addr, hostname);
|
||||
priv->conf_file = create_dhclient_config (iface, FALSE, uuid, dhcp_client_id, dhcp_anycast_addr, hostname);
|
||||
if (!priv->conf_file) {
|
||||
nm_log_warn (LOGD_DHCP4, "(%s): error creating dhclient configuration file.", iface);
|
||||
return -1;
|
||||
|
|
@ -496,8 +494,7 @@ ip4_start (NMDHCPClient *client,
|
|||
|
||||
static GPid
|
||||
ip6_start (NMDHCPClient *client,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
const GByteArray *duid)
|
||||
|
|
@ -508,7 +505,7 @@ ip6_start (NMDHCPClient *client,
|
|||
iface = nm_dhcp_client_get_iface (client);
|
||||
uuid = nm_dhcp_client_get_uuid (client);
|
||||
|
||||
priv->conf_file = create_dhclient_config (iface, TRUE, uuid, NULL, s_ip6, dhcp_anycast_addr, hostname);
|
||||
priv->conf_file = create_dhclient_config (iface, TRUE, uuid, NULL, dhcp_anycast_addr, hostname);
|
||||
if (!priv->conf_file) {
|
||||
nm_log_warn (LOGD_DHCP6, "(%s): error creating dhclient6 configuration file.", iface);
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ dhcpcd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
|
||||
static GPid
|
||||
ip4_start (NMDHCPClient *client,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname)
|
||||
{
|
||||
NMDHCPDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (client);
|
||||
|
|
@ -167,8 +167,7 @@ ip4_start (NMDHCPClient *client,
|
|||
|
||||
static GPid
|
||||
ip6_start (NMDHCPClient *client,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
const GByteArray *duid)
|
||||
|
|
|
|||
|
|
@ -438,10 +438,10 @@ add_client (NMDHCPManager *self, NMDHCPClient *client)
|
|||
NMDHCPManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
|
||||
guint id;
|
||||
|
||||
id = g_signal_connect_swapped (client, "remove", G_CALLBACK (remove_client), self);
|
||||
id = g_signal_connect_swapped (client, NM_DHCP_CLIENT_SIGNAL_REMOVE, G_CALLBACK (remove_client), self);
|
||||
g_object_set_data (G_OBJECT (client), REMOVE_ID_TAG, GUINT_TO_POINTER (id));
|
||||
|
||||
id = g_signal_connect_swapped (client, "timeout", G_CALLBACK (remove_client), self);
|
||||
id = g_signal_connect_swapped (client, NM_DHCP_CLIENT_SIGNAL_TIMEOUT, G_CALLBACK (remove_client), self);
|
||||
g_object_set_data (G_OBJECT (client), TIMEOUT_ID_TAG, GUINT_TO_POINTER (id));
|
||||
|
||||
g_hash_table_insert (priv->clients, client, g_object_ref (client));
|
||||
|
|
@ -453,10 +453,9 @@ client_start (NMDHCPManager *self,
|
|||
const GByteArray *hwaddr,
|
||||
const char *uuid,
|
||||
gboolean ipv6,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
const char *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only)
|
||||
{
|
||||
|
|
@ -493,9 +492,9 @@ client_start (NMDHCPManager *self,
|
|||
add_client (self, client);
|
||||
|
||||
if (ipv6)
|
||||
success = nm_dhcp_client_start_ip6 (client, s_ip6, dhcp_anycast_addr, hostname, info_only);
|
||||
success = nm_dhcp_client_start_ip6 (client, dhcp_anycast_addr, hostname, info_only);
|
||||
else
|
||||
success = nm_dhcp_client_start_ip4 (client, s_ip4, dhcp_anycast_addr, hostname);
|
||||
success = nm_dhcp_client_start_ip4 (client, dhcp_client_id, dhcp_anycast_addr, hostname);
|
||||
|
||||
if (!success) {
|
||||
remove_client (self, client);
|
||||
|
|
@ -514,7 +513,7 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self,
|
|||
const char *uuid,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
guint32 timeout,
|
||||
guint8 *dhcp_anycast_addr)
|
||||
GByteArray *dhcp_anycast_addr)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv;
|
||||
const char *hostname, *method;
|
||||
|
|
@ -547,7 +546,7 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self,
|
|||
} else
|
||||
hostname = NULL;
|
||||
|
||||
return client_start (self, iface, hwaddr, uuid, FALSE, s_ip4, NULL, timeout, dhcp_anycast_addr, hostname, FALSE);
|
||||
return client_start (self, iface, hwaddr, uuid, FALSE, nm_setting_ip4_config_get_dhcp_client_id (s_ip4), timeout, dhcp_anycast_addr, hostname, FALSE);
|
||||
}
|
||||
|
||||
/* Caller owns a reference to the NMDHCPClient on return */
|
||||
|
|
@ -558,7 +557,7 @@ nm_dhcp_manager_start_ip6 (NMDHCPManager *self,
|
|||
const char *uuid,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint32 timeout,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
gboolean info_only)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv;
|
||||
|
|
@ -577,7 +576,7 @@ nm_dhcp_manager_start_ip6 (NMDHCPManager *self,
|
|||
hostname = NULL;
|
||||
}
|
||||
|
||||
return client_start (self, iface, hwaddr, uuid, TRUE, NULL, s_ip6, timeout, dhcp_anycast_addr, hostname, info_only);
|
||||
return client_start (self, iface, hwaddr, uuid, TRUE, NULL, timeout, dhcp_anycast_addr, hostname, info_only);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ NMDHCPClient * nm_dhcp_manager_start_ip4 (NMDHCPManager *manager,
|
|||
const char *uuid,
|
||||
NMSettingIP4Config *s_ip4,
|
||||
guint32 timeout,
|
||||
guint8 *dhcp_anycast_addr);
|
||||
GByteArray *dhcp_anycast_addr);
|
||||
|
||||
NMDHCPClient * nm_dhcp_manager_start_ip6 (NMDHCPManager *manager,
|
||||
const char *iface,
|
||||
|
|
@ -79,7 +79,7 @@ NMDHCPClient * nm_dhcp_manager_start_ip6 (NMDHCPManager *manager,
|
|||
const char *uuid,
|
||||
NMSettingIP6Config *s_ip6,
|
||||
guint32 timeout,
|
||||
guint8 *dhcp_anycast_addr,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
gboolean info_only);
|
||||
|
||||
GSList * nm_dhcp_manager_get_lease_ip_configs (NMDHCPManager *self,
|
||||
|
|
|
|||
|
|
@ -34,18 +34,13 @@ test_config (const char *orig,
|
|||
const char *hostname,
|
||||
const char *dhcp_client_id,
|
||||
const char *iface,
|
||||
guint8 *anycast_addr)
|
||||
GByteArray *anycast_addr)
|
||||
{
|
||||
NMSettingIP4Config *s_ip4;
|
||||
char *new;
|
||||
|
||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, dhcp_client_id, NULL);
|
||||
|
||||
new = nm_dhcp_dhclient_create_config (iface,
|
||||
FALSE,
|
||||
s_ip4,
|
||||
NULL,
|
||||
dhcp_client_id,
|
||||
anycast_addr,
|
||||
hostname,
|
||||
"/path/to/dhclient.conf",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue