settings/ifupdown: adjust coding style for "nms-ifupdown-interface-parser"
This commit is contained in:
@@ -34,25 +34,25 @@
|
|||||||
|
|
||||||
if_block* first;
|
if_block* first;
|
||||||
if_block* last;
|
if_block* last;
|
||||||
|
|
||||||
if_data* last_data;
|
if_data* last_data;
|
||||||
|
|
||||||
void add_block(const char *type, const char* name)
|
void
|
||||||
|
add_block (const char *type, const char* name)
|
||||||
{
|
{
|
||||||
if_block *ret = g_slice_new0 (struct _if_block);
|
if_block *ret = g_slice_new0 (struct _if_block);
|
||||||
ret->name = g_strdup(name);
|
ret->name = g_strdup (name);
|
||||||
ret->type = g_strdup(type);
|
ret->type = g_strdup (type);
|
||||||
if (first == NULL)
|
if (first == NULL)
|
||||||
first = last = ret;
|
first = last = ret;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
last->next = ret;
|
last->next = ret;
|
||||||
last = ret;
|
last = ret;
|
||||||
}
|
}
|
||||||
last_data = NULL;
|
last_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_data(const char *key,const char *data)
|
void
|
||||||
|
add_data (const char *key, const char *data)
|
||||||
{
|
{
|
||||||
if_data *ret;
|
if_data *ret;
|
||||||
char *idx;
|
char *idx;
|
||||||
@@ -62,42 +62,40 @@ void add_data(const char *key,const char *data)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ret = g_slice_new0 (struct _if_data);
|
ret = g_slice_new0 (struct _if_data);
|
||||||
ret->key = g_strdup(key);
|
ret->key = g_strdup (key);
|
||||||
|
|
||||||
/* Normalize keys. Convert '_' to '-', as ifupdown accepts both variants.
|
/* Normalize keys. Convert '_' to '-', as ifupdown accepts both variants.
|
||||||
* When querying keys via ifparser_getkey(), use '-'. */
|
* When querying keys via ifparser_getkey(), use '-'. */
|
||||||
while ((idx = strrchr(ret->key, '_'))) {
|
while ((idx = strrchr (ret->key, '_'))) {
|
||||||
*idx = '-';
|
*idx = '-';
|
||||||
}
|
}
|
||||||
ret->data = g_strdup(data);
|
ret->data = g_strdup (data);
|
||||||
|
|
||||||
if (last->info == NULL)
|
if (last->info == NULL) {
|
||||||
{
|
|
||||||
last->info = ret;
|
last->info = ret;
|
||||||
last_data = ret;
|
last_data = ret;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
last_data->next = ret;
|
last_data->next = ret;
|
||||||
last_data = last_data->next;
|
last_data = last_data->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* join values in src with spaces into dst; dst needs to be large enough */
|
/* join values in src with spaces into dst; dst needs to be large enough */
|
||||||
static char *join_values_with_spaces(char *dst, char **src)
|
static char *
|
||||||
|
join_values_with_spaces (char *dst, char **src)
|
||||||
{
|
{
|
||||||
if (dst != NULL) {
|
if (dst != NULL) {
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
if (src != NULL && *src != NULL) {
|
if (src != NULL && *src != NULL) {
|
||||||
strcat(dst, *src);
|
strcat (dst, *src);
|
||||||
|
|
||||||
for (src++; *src != NULL; src++) {
|
for (src++; *src != NULL; src++) {
|
||||||
strcat(dst, " ");
|
strcat (dst, " ");
|
||||||
strcat(dst, *src);
|
strcat (dst, *src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(dst);
|
return (dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _ifparser_source (const char *path, const char *en_dir, int quiet, int dir);
|
static void _ifparser_source (const char *path, const char *en_dir, int quiet, int dir);
|
||||||
@@ -126,21 +124,20 @@ _recursive_ifparser (const char *eni_file, int quiet)
|
|||||||
if (!quiet)
|
if (!quiet)
|
||||||
nm_log_info (LOGD_SETTINGS, " interface-parser: parsing file %s\n", eni_file);
|
nm_log_info (LOGD_SETTINGS, " interface-parser: parsing file %s\n", eni_file);
|
||||||
|
|
||||||
while (!feof(inp))
|
while (!feof (inp)) {
|
||||||
{
|
|
||||||
char *token[128]; /* 255 chars can only be split into 127 tokens */
|
char *token[128]; /* 255 chars can only be split into 127 tokens */
|
||||||
char value[255]; /* large enough to join previously split tokens */
|
char value[255]; /* large enough to join previously split tokens */
|
||||||
char *safeptr;
|
char *safeptr;
|
||||||
int toknum;
|
int toknum;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
char *ptr = fgets(line+offs, 255-offs, inp);
|
char *ptr = fgets (line+offs, 255-offs, inp);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
len = strlen(line);
|
len = strlen (line);
|
||||||
/* skip over-long lines */
|
/* skip over-long lines */
|
||||||
if (!feof(inp) && len > 0 && line[len-1] != '\n') {
|
if (!feof (inp) && len > 0 && line[len-1] != '\n') {
|
||||||
if (!skip_long_line) {
|
if (!skip_long_line) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
nm_log_warn (LOGD_SETTINGS, "Skipping over-long-line '%s...'\n", line);
|
nm_log_warn (LOGD_SETTINGS, "Skipping over-long-line '%s...'\n", line);
|
||||||
@@ -170,9 +167,9 @@ _recursive_ifparser (const char *eni_file, int quiet)
|
|||||||
|
|
||||||
#define SPACES " \t"
|
#define SPACES " \t"
|
||||||
/* tokenize input; */
|
/* tokenize input; */
|
||||||
for (toknum = 0, token[toknum] = strtok_r(line, SPACES, &safeptr);
|
for (toknum = 0, token[toknum] = strtok_r (line, SPACES, &safeptr);
|
||||||
token[toknum] != NULL;
|
token[toknum] != NULL;
|
||||||
toknum++, token[toknum] = strtok_r(NULL, SPACES, &safeptr))
|
toknum++, token[toknum] = strtok_r (NULL, SPACES, &safeptr))
|
||||||
;
|
;
|
||||||
|
|
||||||
/* ignore comments and empty lines */
|
/* ignore comments and empty lines */
|
||||||
@@ -182,7 +179,7 @@ _recursive_ifparser (const char *eni_file, int quiet)
|
|||||||
if (toknum < 2) {
|
if (toknum < 2) {
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
nm_log_warn (LOGD_SETTINGS, "Can't parse interface line '%s'\n",
|
nm_log_warn (LOGD_SETTINGS, "Can't parse interface line '%s'\n",
|
||||||
join_values_with_spaces(value, token));
|
join_values_with_spaces (value, token));
|
||||||
}
|
}
|
||||||
skip_to_block = 1;
|
skip_to_block = 1;
|
||||||
continue;
|
continue;
|
||||||
@@ -193,36 +190,36 @@ _recursive_ifparser (const char *eni_file, int quiet)
|
|||||||
* Create a block for each of them except source and source-directory. */
|
* Create a block for each of them except source and source-directory. */
|
||||||
|
|
||||||
/* iface stanza takes at least 3 parameters */
|
/* iface stanza takes at least 3 parameters */
|
||||||
if (strcmp(token[0], "iface") == 0) {
|
if (strcmp (token[0], "iface") == 0) {
|
||||||
if (toknum < 4) {
|
if (toknum < 4) {
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
nm_log_warn (LOGD_SETTINGS, "Can't parse iface line '%s'\n",
|
nm_log_warn (LOGD_SETTINGS, "Can't parse iface line '%s'\n",
|
||||||
join_values_with_spaces(value, token));
|
join_values_with_spaces (value, token));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
add_block(token[0], token[1]);
|
add_block (token[0], token[1]);
|
||||||
skip_to_block = 0;
|
skip_to_block = 0;
|
||||||
add_data(token[2], join_values_with_spaces(value, token + 3));
|
add_data (token[2], join_values_with_spaces (value, token + 3));
|
||||||
}
|
}
|
||||||
/* auto and allow-auto stanzas are equivalent,
|
/* auto and allow-auto stanzas are equivalent,
|
||||||
* both can take multiple interfaces as parameters: add one block for each */
|
* both can take multiple interfaces as parameters: add one block for each */
|
||||||
else if (strcmp(token[0], "auto") == 0 ||
|
else if (strcmp (token[0], "auto") == 0 ||
|
||||||
strcmp(token[0], "allow-auto") == 0) {
|
strcmp (token[0], "allow-auto") == 0) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i < toknum; i++)
|
for (i = 1; i < toknum; i++)
|
||||||
add_block("auto", token[i]);
|
add_block ("auto", token[i]);
|
||||||
skip_to_block = 0;
|
skip_to_block = 0;
|
||||||
}
|
}
|
||||||
else if (strcmp(token[0], "mapping") == 0) {
|
else if (strcmp (token[0], "mapping") == 0) {
|
||||||
add_block(token[0], join_values_with_spaces(value, token + 1));
|
add_block (token[0], join_values_with_spaces (value, token + 1));
|
||||||
skip_to_block = 0;
|
skip_to_block = 0;
|
||||||
}
|
}
|
||||||
/* allow-* can take multiple interfaces as parameters: add one block for each */
|
/* allow-* can take multiple interfaces as parameters: add one block for each */
|
||||||
else if (strncmp(token[0],"allow-",6) == 0) {
|
else if (strncmp (token[0],"allow-",6) == 0) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i < toknum; i++)
|
for (i = 1; i < toknum; i++)
|
||||||
add_block(token[0], token[i]);
|
add_block (token[0], token[i]);
|
||||||
skip_to_block = 0;
|
skip_to_block = 0;
|
||||||
}
|
}
|
||||||
/* source and source-directory stanzas take one or more paths as parameters */
|
/* source and source-directory stanzas take one or more paths as parameters */
|
||||||
@@ -244,13 +241,13 @@ _recursive_ifparser (const char *eni_file, int quiet)
|
|||||||
if (skip_to_block) {
|
if (skip_to_block) {
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
nm_log_warn (LOGD_SETTINGS, "ignoring out-of-block data '%s'\n",
|
nm_log_warn (LOGD_SETTINGS, "ignoring out-of-block data '%s'\n",
|
||||||
join_values_with_spaces(value, token));
|
join_values_with_spaces (value, token));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
add_data(token[0], join_values_with_spaces(value, token + 1));
|
add_data (token[0], join_values_with_spaces (value, token + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(inp);
|
fclose (inp);
|
||||||
|
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
nm_log_info (LOGD_SETTINGS, " interface-parser: finished parsing file %s\n", eni_file);
|
nm_log_info (LOGD_SETTINGS, " interface-parser: finished parsing file %s\n", eni_file);
|
||||||
@@ -301,47 +298,51 @@ _ifparser_source (const char *path, const char *en_dir, int quiet, int dir)
|
|||||||
g_free (abs_path);
|
g_free (abs_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ifparser_init (const char *eni_file, int quiet)
|
void
|
||||||
|
ifparser_init (const char *eni_file, int quiet)
|
||||||
{
|
{
|
||||||
first = last = NULL;
|
first = last = NULL;
|
||||||
_recursive_ifparser (eni_file, quiet);
|
_recursive_ifparser (eni_file, quiet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _destroy_data(if_data *ifd)
|
void
|
||||||
|
_destroy_data (if_data *ifd)
|
||||||
{
|
{
|
||||||
if (ifd == NULL)
|
if (ifd == NULL)
|
||||||
return;
|
return;
|
||||||
_destroy_data(ifd->next);
|
_destroy_data (ifd->next);
|
||||||
g_free(ifd->key);
|
g_free (ifd->key);
|
||||||
g_free(ifd->data);
|
g_free (ifd->data);
|
||||||
g_slice_free(struct _if_data, ifd);
|
g_slice_free (struct _if_data, ifd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _destroy_block(if_block* ifb)
|
void
|
||||||
|
_destroy_block (if_block* ifb)
|
||||||
{
|
{
|
||||||
if (ifb == NULL)
|
if (ifb == NULL)
|
||||||
return;
|
return;
|
||||||
_destroy_block(ifb->next);
|
_destroy_block (ifb->next);
|
||||||
_destroy_data(ifb->info);
|
_destroy_data (ifb->info);
|
||||||
g_free(ifb->name);
|
g_free (ifb->name);
|
||||||
g_free(ifb->type);
|
g_free (ifb->type);
|
||||||
g_slice_free(struct _if_block, ifb);
|
g_slice_free (struct _if_block, ifb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ifparser_destroy(void)
|
void
|
||||||
|
ifparser_destroy (void)
|
||||||
{
|
{
|
||||||
_destroy_block(first);
|
_destroy_block (first);
|
||||||
first = last = NULL;
|
first = last = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if_block *ifparser_getfirst(void)
|
if_block *ifparser_getfirst (void)
|
||||||
{
|
{
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ifparser_get_num_blocks(void)
|
int ifparser_get_num_blocks (void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if_block *iter = first;
|
if_block *iter = first;
|
||||||
@@ -353,24 +354,24 @@ int ifparser_get_num_blocks(void)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if_block *ifparser_getif(const char* iface)
|
if_block *
|
||||||
|
ifparser_getif (const char* iface)
|
||||||
{
|
{
|
||||||
if_block *curr = first;
|
if_block *curr = first;
|
||||||
while(curr!=NULL)
|
while (curr != NULL) {
|
||||||
{
|
if (strcmp (curr->type,"iface")==0 && strcmp (curr->name,iface)==0)
|
||||||
if (strcmp(curr->type,"iface")==0 && strcmp(curr->name,iface)==0)
|
|
||||||
return curr;
|
return curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ifparser_getkey(if_block* iface, const char *key)
|
const char *
|
||||||
|
ifparser_getkey (if_block* iface, const char *key)
|
||||||
{
|
{
|
||||||
if_data *curr = iface->info;
|
if_data *curr = iface->info;
|
||||||
while(curr!=NULL)
|
while (curr != NULL) {
|
||||||
{
|
if (strcmp (curr->key,key)==0)
|
||||||
if (strcmp(curr->key,key)==0)
|
|
||||||
return curr->data;
|
return curr->data;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
@@ -378,7 +379,7 @@ const char *ifparser_getkey(if_block* iface, const char *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ifparser_haskey(if_block* iface, const char *key)
|
ifparser_haskey (if_block* iface, const char *key)
|
||||||
{
|
{
|
||||||
if_data *curr = iface->info;
|
if_data *curr = iface->info;
|
||||||
|
|
||||||
@@ -390,7 +391,8 @@ ifparser_haskey(if_block* iface, const char *key)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ifparser_get_num_info(if_block* iface)
|
int
|
||||||
|
ifparser_get_num_info (if_block* iface)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if_data *iter = iface->info;
|
if_data *iter = iface->info;
|
||||||
|
@@ -23,33 +23,32 @@
|
|||||||
#ifndef _INTERFACE_PARSER_H
|
#ifndef _INTERFACE_PARSER_H
|
||||||
#define _INTERFACE_PARSER_H
|
#define _INTERFACE_PARSER_H
|
||||||
|
|
||||||
typedef struct _if_data
|
typedef struct _if_data {
|
||||||
{
|
|
||||||
char *key;
|
char *key;
|
||||||
char *data;
|
char *data;
|
||||||
struct _if_data *next;
|
struct _if_data *next;
|
||||||
} if_data;
|
} if_data;
|
||||||
|
|
||||||
typedef struct _if_block
|
typedef struct _if_block {
|
||||||
{
|
|
||||||
char *type;
|
char *type;
|
||||||
char *name;
|
char *name;
|
||||||
if_data *info;
|
if_data *info;
|
||||||
struct _if_block *next;
|
struct _if_block *next;
|
||||||
} if_block;
|
} if_block;
|
||||||
|
|
||||||
void ifparser_init(const char *eni_file, int quiet);
|
void ifparser_init (const char *eni_file, int quiet);
|
||||||
void ifparser_destroy(void);
|
void ifparser_destroy (void);
|
||||||
|
|
||||||
if_block *ifparser_getif(const char* iface);
|
if_block *ifparser_getif (const char* iface);
|
||||||
if_block *ifparser_getfirst(void);
|
if_block *ifparser_getfirst (void);
|
||||||
const char *ifparser_getkey(if_block* iface, const char *key);
|
const char *ifparser_getkey (if_block* iface, const char *key);
|
||||||
gboolean ifparser_haskey(if_block* iface, const char *key);
|
gboolean ifparser_haskey (if_block* iface, const char *key);
|
||||||
int ifparser_get_num_blocks(void);
|
int ifparser_get_num_blocks (void);
|
||||||
int ifparser_get_num_info(if_block* iface);
|
int ifparser_get_num_info (if_block* iface);
|
||||||
|
|
||||||
|
void add_block (const char *type, const char* name);
|
||||||
|
void add_data (const char *key,const char *data);
|
||||||
|
void _destroy_data (if_data *ifd);
|
||||||
|
void _destroy_block (if_block* ifb);
|
||||||
|
|
||||||
void add_block(const char *type, const char* name);
|
|
||||||
void add_data(const char *key,const char *data);
|
|
||||||
void _destroy_data(if_data *ifd);
|
|
||||||
void _destroy_block(if_block* ifb);
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -42,20 +42,20 @@ _ifupdownplugin_guess_connection_type (if_block *block)
|
|||||||
{
|
{
|
||||||
if_data *curr = block->info;
|
if_data *curr = block->info;
|
||||||
const char* ret_type = NULL;
|
const char* ret_type = NULL;
|
||||||
const char* value = ifparser_getkey(block, "inet");
|
const char* value = ifparser_getkey (block, "inet");
|
||||||
if(value && !strcmp("ppp", value)) {
|
if (value && !strcmp ("ppp", value)) {
|
||||||
ret_type = NM_SETTING_PPP_SETTING_NAME;
|
ret_type = NM_SETTING_PPP_SETTING_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!ret_type && curr) {
|
while (!ret_type && curr) {
|
||||||
if(!strncmp("wireless-", curr->key, strlen("wireless-")) ||
|
if (!strncmp ("wireless-", curr->key, strlen ("wireless-")) ||
|
||||||
!strncmp("wpa-", curr->key, strlen("wpa-"))) {
|
!strncmp ("wpa-", curr->key, strlen ("wpa-"))) {
|
||||||
ret_type = NM_SETTING_WIRELESS_SETTING_NAME;
|
ret_type = NM_SETTING_WIRELESS_SETTING_NAME;
|
||||||
}
|
}
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ret_type)
|
if (!ret_type)
|
||||||
ret_type = NM_SETTING_WIRED_SETTING_NAME;
|
ret_type = NM_SETTING_WIRED_SETTING_NAME;
|
||||||
|
|
||||||
nm_log_info (LOGD_SETTINGS, "guessed connection type (%s) = %s", block->name, ret_type);
|
nm_log_info (LOGD_SETTINGS, "guessed connection type (%s) = %s", block->name, ret_type);
|
||||||
@@ -68,11 +68,11 @@ struct _Mapping {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
map_by_mapping(struct _Mapping *mapping, const char *key)
|
map_by_mapping (struct _Mapping *mapping, const char *key)
|
||||||
{
|
{
|
||||||
struct _Mapping *curr = mapping;
|
struct _Mapping *curr = mapping;
|
||||||
while(curr->domain) {
|
while (curr->domain) {
|
||||||
if(!strcmp(curr->domain, key))
|
if (!strcmp (curr->domain, key))
|
||||||
return curr->target;
|
return curr->target;
|
||||||
curr++;
|
curr++;
|
||||||
}
|
}
|
||||||
@@ -80,11 +80,11 @@ map_by_mapping(struct _Mapping *mapping, const char *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_wireless_setting_from_if_block(NMConnection *connection,
|
update_wireless_setting_from_if_block (NMConnection *connection,
|
||||||
if_block *block)
|
if_block *block)
|
||||||
{
|
{
|
||||||
int wpa_l= strlen("wpa-");
|
int wpa_l= strlen ("wpa-");
|
||||||
int wireless_l= strlen("wireless-");
|
int wireless_l= strlen ("wireless-");
|
||||||
|
|
||||||
if_data *curr = block->info;
|
if_data *curr = block->info;
|
||||||
const char* value = ifparser_getkey (block, "inet");
|
const char* value = ifparser_getkey (block, "inet");
|
||||||
@@ -97,27 +97,27 @@ update_wireless_setting_from_if_block(NMConnection *connection,
|
|||||||
|
|
||||||
NMSettingWireless *wireless_setting = NULL;
|
NMSettingWireless *wireless_setting = NULL;
|
||||||
|
|
||||||
if(value && !strcmp("ppp", value)) {
|
if (value && !strcmp ("ppp", value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_log_info (LOGD_SETTINGS, "update wireless settings (%s).", block->name);
|
nm_log_info (LOGD_SETTINGS, "update wireless settings (%s).", block->name);
|
||||||
wireless_setting = NM_SETTING_WIRELESS(nm_setting_wireless_new());
|
wireless_setting = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
||||||
|
|
||||||
while(curr) {
|
while (curr) {
|
||||||
if(strlen(curr->key) > wireless_l &&
|
if (strlen (curr->key) > wireless_l &&
|
||||||
!strncmp("wireless-", curr->key, wireless_l)) {
|
!strncmp ("wireless-", curr->key, wireless_l)) {
|
||||||
const char* newkey = map_by_mapping(mapping, curr->key+wireless_l);
|
const char* newkey = map_by_mapping (mapping, curr->key+wireless_l);
|
||||||
nm_log_info (LOGD_SETTINGS, "wireless setting key: %s='%s'", newkey, curr->data);
|
nm_log_info (LOGD_SETTINGS, "wireless setting key: %s='%s'", newkey, curr->data);
|
||||||
if(newkey && !strcmp("ssid", newkey)) {
|
if (newkey && !strcmp ("ssid", newkey)) {
|
||||||
GBytes *ssid;
|
GBytes *ssid;
|
||||||
int len = strlen(curr->data);
|
int len = strlen (curr->data);
|
||||||
|
|
||||||
ssid = g_bytes_new (curr->data, len);
|
ssid = g_bytes_new (curr->data, len);
|
||||||
g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
||||||
g_bytes_unref (ssid);
|
g_bytes_unref (ssid);
|
||||||
nm_log_info (LOGD_SETTINGS, "setting wireless ssid = %d", len);
|
nm_log_info (LOGD_SETTINGS, "setting wireless ssid = %d", len);
|
||||||
} else if(newkey && !strcmp("mode", newkey)) {
|
} else if (newkey && !strcmp ("mode", newkey)) {
|
||||||
if (!g_ascii_strcasecmp (curr->data, "Managed") || !g_ascii_strcasecmp (curr->data, "Auto"))
|
if (!g_ascii_strcasecmp (curr->data, "Managed") || !g_ascii_strcasecmp (curr->data, "Auto"))
|
||||||
g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA, NULL);
|
g_object_set (wireless_setting, NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA, NULL);
|
||||||
else if (!g_ascii_strcasecmp (curr->data, "Ad-Hoc"))
|
else if (!g_ascii_strcasecmp (curr->data, "Ad-Hoc"))
|
||||||
@@ -127,33 +127,33 @@ update_wireless_setting_from_if_block(NMConnection *connection,
|
|||||||
else
|
else
|
||||||
nm_log_warn (LOGD_SETTINGS, "Invalid mode '%s' (not 'Ad-Hoc', 'Ap', 'Managed', or 'Auto')", curr->data);
|
nm_log_warn (LOGD_SETTINGS, "Invalid mode '%s' (not 'Ad-Hoc', 'Ap', 'Managed', or 'Auto')", curr->data);
|
||||||
} else {
|
} else {
|
||||||
g_object_set(wireless_setting,
|
g_object_set (wireless_setting,
|
||||||
newkey, curr->data,
|
newkey, curr->data,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
} else if(strlen(curr->key) > wpa_l &&
|
} else if ( strlen (curr->key) > wpa_l
|
||||||
!strncmp("wpa-", curr->key, wpa_l)) {
|
&& !strncmp ("wpa-", curr->key, wpa_l)) {
|
||||||
const char* newkey = map_by_mapping(mapping, curr->key+wpa_l);
|
const char* newkey = map_by_mapping (mapping, curr->key+wpa_l);
|
||||||
|
|
||||||
if(newkey && !strcmp("ssid", newkey)) {
|
if (newkey && !strcmp ("ssid", newkey)) {
|
||||||
GBytes *ssid;
|
GBytes *ssid;
|
||||||
int len = strlen(curr->data);
|
int len = strlen (curr->data);
|
||||||
|
|
||||||
ssid = g_bytes_new (curr->data, len);
|
ssid = g_bytes_new (curr->data, len);
|
||||||
g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
||||||
g_bytes_unref (ssid);
|
g_bytes_unref (ssid);
|
||||||
nm_log_info (LOGD_SETTINGS, "setting wpa ssid = %d", len);
|
nm_log_info (LOGD_SETTINGS, "setting wpa ssid = %d", len);
|
||||||
} else if(newkey) {
|
} else if (newkey) {
|
||||||
|
|
||||||
g_object_set(wireless_setting,
|
g_object_set (wireless_setting,
|
||||||
newkey, curr->data,
|
newkey, curr->data,
|
||||||
NULL);
|
NULL);
|
||||||
nm_log_info (LOGD_SETTINGS, "setting wpa newkey(%s)=data(%s)", newkey, curr->data);
|
nm_log_info (LOGD_SETTINGS, "setting wpa newkey(%s)=data(%s)", newkey, curr->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
nm_connection_add_setting(connection, (NMSetting*) wireless_setting);
|
nm_connection_add_setting (connection, (NMSetting*) wireless_setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char* (*IfupdownStrDupeFunc) (gpointer value, gpointer data);
|
typedef char* (*IfupdownStrDupeFunc) (gpointer value, gpointer data);
|
||||||
@@ -177,7 +177,7 @@ normalize_dupe_wireless_key (gpointer value, gpointer data) {
|
|||||||
result_cur += next - delim;
|
result_cur += next - delim;
|
||||||
delim = next + 1;
|
delim = next + 1;
|
||||||
}
|
}
|
||||||
if (*delim && strlen (valuec) > GPOINTER_TO_UINT(delim - valuec)) {
|
if (*delim && strlen (valuec) > GPOINTER_TO_UINT (delim - valuec)) {
|
||||||
strncpy (result_cur, delim, endc - delim);
|
strncpy (result_cur, delim, endc - delim);
|
||||||
result_cur += endc - delim;
|
result_cur += endc - delim;
|
||||||
}
|
}
|
||||||
@@ -187,12 +187,12 @@ normalize_dupe_wireless_key (gpointer value, gpointer data) {
|
|||||||
|
|
||||||
static char*
|
static char*
|
||||||
normalize_dupe (gpointer value, gpointer data) {
|
normalize_dupe (gpointer value, gpointer data) {
|
||||||
return g_strdup(value);
|
return g_strdup (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char*
|
static char*
|
||||||
normalize_tolower (gpointer value, gpointer data) {
|
normalize_tolower (gpointer value, gpointer data) {
|
||||||
return g_ascii_strdown(value, -1);
|
return g_ascii_strdown (value, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *normalize_psk (gpointer value, gpointer data)
|
static char *normalize_psk (gpointer value, gpointer data)
|
||||||
@@ -203,25 +203,25 @@ static char *normalize_psk (gpointer value, gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
string_to_gpointerint(const char* data)
|
string_to_gpointerint (const char* data)
|
||||||
{
|
{
|
||||||
int result = (int) strtol (data, NULL, 10);
|
int result = (int) strtol (data, NULL, 10);
|
||||||
return GINT_TO_POINTER(result);
|
return GINT_TO_POINTER (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
string_to_glist_of_strings(const char* data)
|
string_to_glist_of_strings (const char* data)
|
||||||
{
|
{
|
||||||
GSList *ret = NULL;
|
GSList *ret = NULL;
|
||||||
char *string = (char*) data;
|
char *string = (char*) data;
|
||||||
while(string) {
|
while (string) {
|
||||||
char* next = NULL;
|
char* next = NULL;
|
||||||
if( (next = strchr(string, ' ')) ||
|
if ( (next = strchr (string, ' ')) ||
|
||||||
(next = strchr(string, '\t')) ||
|
(next = strchr (string, '\t')) ||
|
||||||
(next = strchr(string, '\0')) ) {
|
(next = strchr (string, '\0')) ) {
|
||||||
|
|
||||||
char *part = g_strndup(string, (next - string));
|
char *part = g_strndup (string, (next - string));
|
||||||
ret = g_slist_append(ret, part);
|
ret = g_slist_append (ret, part);
|
||||||
if (*next)
|
if (*next)
|
||||||
string = next+1;
|
string = next+1;
|
||||||
else
|
else
|
||||||
@@ -234,17 +234,17 @@ string_to_glist_of_strings(const char* data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
slist_free_all(gpointer slist)
|
slist_free_all (gpointer slist)
|
||||||
{
|
{
|
||||||
g_slist_free_full ((GSList *) slist, g_free);
|
g_slist_free_full ((GSList *) slist, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_wireless_security_setting_from_if_block(NMConnection *connection,
|
update_wireless_security_setting_from_if_block (NMConnection *connection,
|
||||||
if_block *block)
|
if_block *block)
|
||||||
{
|
{
|
||||||
int wpa_l= strlen("wpa-");
|
int wpa_l= strlen ("wpa-");
|
||||||
int wireless_l= strlen("wireless-");
|
int wireless_l= strlen ("wireless-");
|
||||||
if_data *curr = block->info;
|
if_data *curr = block->info;
|
||||||
const char* value = ifparser_getkey (block, "inet");
|
const char* value = ifparser_getkey (block, "inet");
|
||||||
struct _Mapping mapping[] = {
|
struct _Mapping mapping[] = {
|
||||||
@@ -302,28 +302,27 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
NMSettingWireless *s_wireless;
|
NMSettingWireless *s_wireless;
|
||||||
gboolean security = FALSE;
|
gboolean security = FALSE;
|
||||||
|
|
||||||
if(value && !strcmp("ppp", value)) {
|
if (value && !strcmp ("ppp", value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_wireless = nm_connection_get_setting_wireless(connection);
|
s_wireless = nm_connection_get_setting_wireless (connection);
|
||||||
g_return_if_fail(s_wireless);
|
g_return_if_fail (s_wireless);
|
||||||
|
|
||||||
nm_log_info (LOGD_SETTINGS, "update wireless security settings (%s).", block->name);
|
nm_log_info (LOGD_SETTINGS, "update wireless security settings (%s).", block->name);
|
||||||
wireless_security_setting =
|
wireless_security_setting = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ());
|
||||||
NM_SETTING_WIRELESS_SECURITY(nm_setting_wireless_security_new());
|
|
||||||
|
|
||||||
while(curr) {
|
while (curr) {
|
||||||
if(strlen(curr->key) > wireless_l &&
|
if ( strlen (curr->key) > wireless_l
|
||||||
!strncmp("wireless-", curr->key, wireless_l)) {
|
&& !strncmp ("wireless-", curr->key, wireless_l)) {
|
||||||
|
|
||||||
char *property_value = NULL;
|
char *property_value = NULL;
|
||||||
gpointer typed_property_value = NULL;
|
gpointer typed_property_value = NULL;
|
||||||
const char* newkey = map_by_mapping(mapping, curr->key+wireless_l);
|
const char* newkey = map_by_mapping (mapping, curr->key+wireless_l);
|
||||||
IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wireless_l);
|
IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wireless_l);
|
||||||
IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wireless_l);
|
IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wireless_l);
|
||||||
GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wireless_l);
|
GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wireless_l);
|
||||||
if(!newkey || !dupe_func)
|
if (!newkey || !dupe_func)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
property_value = (*dupe_func) (curr->data, connection);
|
property_value = (*dupe_func) (curr->data, connection);
|
||||||
@@ -333,30 +332,30 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
if (type_map_func) {
|
if (type_map_func) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
typed_property_value = (*type_map_func) (property_value);
|
typed_property_value = (*type_map_func) (property_value);
|
||||||
if(errno)
|
if (errno)
|
||||||
goto wireless_next;
|
goto wireless_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set(wireless_security_setting,
|
g_object_set (wireless_security_setting,
|
||||||
newkey, typed_property_value ?: property_value,
|
newkey, typed_property_value ?: property_value,
|
||||||
NULL);
|
NULL);
|
||||||
security = TRUE;
|
security = TRUE;
|
||||||
|
|
||||||
wireless_next:
|
wireless_next:
|
||||||
g_free(property_value);
|
g_free (property_value);
|
||||||
if (typed_property_value && free_func)
|
if (typed_property_value && free_func)
|
||||||
(*free_func) (typed_property_value);
|
(*free_func) (typed_property_value);
|
||||||
|
|
||||||
} else if(strlen(curr->key) > wpa_l &&
|
} else if ( strlen (curr->key) > wpa_l
|
||||||
!strncmp("wpa-", curr->key, wpa_l)) {
|
&& !strncmp ("wpa-", curr->key, wpa_l)) {
|
||||||
|
|
||||||
char *property_value = NULL;
|
char *property_value = NULL;
|
||||||
gpointer typed_property_value = NULL;
|
gpointer typed_property_value = NULL;
|
||||||
const char* newkey = map_by_mapping(mapping, curr->key+wpa_l);
|
const char* newkey = map_by_mapping (mapping, curr->key+wpa_l);
|
||||||
IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wpa_l);
|
IfupdownStrDupeFunc dupe_func = map_by_mapping (dupe_mapping, curr->key+wpa_l);
|
||||||
IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wpa_l);
|
IfupdownStrToTypeFunc type_map_func = map_by_mapping (type_mapping, curr->key+wpa_l);
|
||||||
GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wpa_l);
|
GFreeFunc free_func = map_by_mapping (free_type_mapping, curr->key+wpa_l);
|
||||||
if(!newkey || !dupe_func)
|
if (!newkey || !dupe_func)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
property_value = (*dupe_func) (curr->data, connection);
|
property_value = (*dupe_func) (curr->data, connection);
|
||||||
@@ -365,14 +364,14 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
#ifdef DEBUG_SECRETS
|
#ifdef DEBUG_SECRETS
|
||||||
property_value
|
property_value
|
||||||
#else /* DEBUG_SECRETS */
|
#else /* DEBUG_SECRETS */
|
||||||
!strcmp("key", newkey) ||
|
!strcmp ("key", newkey) ||
|
||||||
!strcmp("leap-password", newkey) ||
|
!strcmp ("leap-password", newkey) ||
|
||||||
!strcmp("pin", newkey) ||
|
!strcmp ("pin", newkey) ||
|
||||||
!strcmp("psk", newkey) ||
|
!strcmp ("psk", newkey) ||
|
||||||
!strcmp("wep-key0", newkey) ||
|
!strcmp ("wep-key0", newkey) ||
|
||||||
!strcmp("wep-key1", newkey) ||
|
!strcmp ("wep-key1", newkey) ||
|
||||||
!strcmp("wep-key2", newkey) ||
|
!strcmp ("wep-key2", newkey) ||
|
||||||
!strcmp("wep-key3", newkey) ||
|
!strcmp ("wep-key3", newkey) ||
|
||||||
NULL ?
|
NULL ?
|
||||||
"<omitted>" : property_value
|
"<omitted>" : property_value
|
||||||
#endif /* DEBUG_SECRETS */
|
#endif /* DEBUG_SECRETS */
|
||||||
@@ -381,17 +380,17 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
if (type_map_func) {
|
if (type_map_func) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
typed_property_value = (*type_map_func) (property_value);
|
typed_property_value = (*type_map_func) (property_value);
|
||||||
if(errno)
|
if (errno)
|
||||||
goto wpa_next;
|
goto wpa_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set(wireless_security_setting,
|
g_object_set (wireless_security_setting,
|
||||||
newkey, typed_property_value ?: property_value,
|
newkey, typed_property_value ?: property_value,
|
||||||
NULL);
|
NULL);
|
||||||
security = TRUE;
|
security = TRUE;
|
||||||
|
|
||||||
wpa_next:
|
wpa_next:
|
||||||
g_free(property_value);
|
g_free (property_value);
|
||||||
if (free_func && typed_property_value)
|
if (free_func && typed_property_value)
|
||||||
(*free_func) (typed_property_value);
|
(*free_func) (typed_property_value);
|
||||||
}
|
}
|
||||||
@@ -404,12 +403,12 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_wired_setting_from_if_block(NMConnection *connection,
|
update_wired_setting_from_if_block (NMConnection *connection,
|
||||||
if_block *block)
|
if_block *block)
|
||||||
{
|
{
|
||||||
NMSettingWired *s_wired = NULL;
|
NMSettingWired *s_wired = NULL;
|
||||||
s_wired = NM_SETTING_WIRED(nm_setting_wired_new());
|
s_wired = NM_SETTING_WIRED (nm_setting_wired_new ());
|
||||||
nm_connection_add_setting(connection, NM_SETTING(s_wired));
|
nm_connection_add_setting (connection, NM_SETTING (s_wired));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -438,14 +437,14 @@ ifupdown_ip4_add_dns (NMSettingIPConfig *s_ip4, const char *dns)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
update_ip4_setting_from_if_block(NMConnection *connection,
|
update_ip4_setting_from_if_block (NMConnection *connection,
|
||||||
if_block *block,
|
if_block *block,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
|
||||||
NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new());
|
NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new ());
|
||||||
const char *type = ifparser_getkey(block, "inet");
|
const char *type = ifparser_getkey (block, "inet");
|
||||||
gboolean is_static = type && !strcmp("static", type);
|
gboolean is_static = type && !strcmp ("static", type);
|
||||||
|
|
||||||
if (!is_static) {
|
if (!is_static) {
|
||||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
||||||
@@ -568,17 +567,18 @@ ifupdown_ip6_add_dns (NMSettingIPConfig *s_ip6, const char *dns)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
update_ip6_setting_from_if_block(NMConnection *connection,
|
update_ip6_setting_from_if_block (NMConnection *connection,
|
||||||
if_block *block,
|
if_block *block,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (nm_setting_ip6_config_new());
|
NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (nm_setting_ip6_config_new ());
|
||||||
const char *type = ifparser_getkey(block, "inet6");
|
const char *type = ifparser_getkey (block, "inet6");
|
||||||
gboolean is_static = type && (!strcmp("static", type) ||
|
gboolean is_static = type
|
||||||
!strcmp("v4tunnel", type));
|
&& ( !strcmp ("static", type)
|
||||||
|
|| !strcmp ("v4tunnel", type));
|
||||||
|
|
||||||
if (!is_static) {
|
if (!is_static) {
|
||||||
g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
|
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
|
||||||
} else {
|
} else {
|
||||||
NMIPAddress *addr;
|
NMIPAddress *addr;
|
||||||
const char *address_v;
|
const char *address_v;
|
||||||
@@ -591,7 +591,7 @@ update_ip6_setting_from_if_block(NMConnection *connection,
|
|||||||
char **list, **iter;
|
char **list, **iter;
|
||||||
|
|
||||||
/* Address */
|
/* Address */
|
||||||
address_v = ifparser_getkey(block, "address");
|
address_v = ifparser_getkey (block, "address");
|
||||||
if (!address_v) {
|
if (!address_v) {
|
||||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||||
"Missing IPv6 address");
|
"Missing IPv6 address");
|
||||||
@@ -599,7 +599,7 @@ update_ip6_setting_from_if_block(NMConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Prefix */
|
/* Prefix */
|
||||||
prefix_v = ifparser_getkey(block, "netmask");
|
prefix_v = ifparser_getkey (block, "netmask");
|
||||||
if (prefix_v)
|
if (prefix_v)
|
||||||
prefix_int = g_ascii_strtoll (prefix_v, NULL, 10);
|
prefix_int = g_ascii_strtoll (prefix_v, NULL, 10);
|
||||||
|
|
||||||
@@ -628,10 +628,10 @@ update_ip6_setting_from_if_block(NMConnection *connection,
|
|||||||
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, gateway_v, NULL);
|
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, gateway_v, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
nameserver_v = ifparser_getkey(block, "dns-nameserver");
|
nameserver_v = ifparser_getkey (block, "dns-nameserver");
|
||||||
ifupdown_ip6_add_dns (s_ip6, nameserver_v);
|
ifupdown_ip6_add_dns (s_ip6, nameserver_v);
|
||||||
|
|
||||||
nameservers_v = ifparser_getkey(block, "dns-nameservers");
|
nameservers_v = ifparser_getkey (block, "dns-nameservers");
|
||||||
ifupdown_ip6_add_dns (s_ip6, nameservers_v);
|
ifupdown_ip6_add_dns (s_ip6, nameservers_v);
|
||||||
|
|
||||||
if (!nm_setting_ip_config_get_num_dns (s_ip6))
|
if (!nm_setting_ip_config_get_num_dns (s_ip6))
|
||||||
@@ -677,8 +677,8 @@ ifupdown_update_connection_from_if_block (NMConnection *connection,
|
|||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
|
|
||||||
s_con = nm_connection_get_setting_connection (connection);
|
s_con = nm_connection_get_setting_connection (connection);
|
||||||
if(!s_con) {
|
if (!s_con) {
|
||||||
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new());
|
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
|
||||||
g_assert (s_con);
|
g_assert (s_con);
|
||||||
nm_connection_add_setting (connection, NM_SETTING (s_con));
|
nm_connection_add_setting (connection, NM_SETTING (s_con));
|
||||||
}
|
}
|
||||||
@@ -708,7 +708,7 @@ ifupdown_update_connection_from_if_block (NMConnection *connection,
|
|||||||
update_wireless_security_setting_from_if_block (connection, block);
|
update_wireless_security_setting_from_if_block (connection, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ifparser_haskey(block, "inet6"))
|
if (ifparser_haskey (block, "inet6"))
|
||||||
success = update_ip6_setting_from_if_block (connection, block, error);
|
success = update_ip6_setting_from_if_block (connection, block, error);
|
||||||
else
|
else
|
||||||
success = update_ip4_setting_from_if_block (connection, block, error);
|
success = update_ip4_setting_from_if_block (connection, block, error);
|
||||||
|
Reference in New Issue
Block a user