Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NetworkManager-l2tp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CeRiAl
NetworkManager-l2tp
Commits
5915afe8
Commit
5915afe8
authored
Mar 10, 2012
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a g_string for the route string construction (export)
parent
721e8943
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
22 deletions
+15
-22
import-export.c
properties/import-export.c
+15
-22
No files found.
properties/import-export.c
View file @
5915afe8
...
@@ -287,37 +287,30 @@ export_ip4(NMSettingIP4Config *s_ip4, GKeyFile *keyfile, GError **error)
...
@@ -287,37 +287,30 @@ export_ip4(NMSettingIP4Config *s_ip4, GKeyFile *keyfile, GError **error)
for
(
i
=
0
;
i
<
num_routes
;
i
++
){
for
(
i
=
0
;
i
<
num_routes
;
i
++
){
guint32
dest
,
prefix
,
nhop
,
metric
;
guint32
dest
,
prefix
,
nhop
,
metric
;
GString
*
route_s
;
route
=
nm_setting_ip4_config_get_route
(
s_ip4
,
i
);
route
=
nm_setting_ip4_config_get_route
(
s_ip4
,
i
);
dest
=
nm_ip4_route_get_dest
(
route
);
dest
=
nm_ip4_route_get_dest
(
route
);
prefix
=
nm_ip4_route_get_prefix
(
route
);
prefix
=
nm_ip4_route_get_prefix
(
route
);
nhop
=
nm_ip4_route_get_next_hop
(
route
);
nhop
=
nm_ip4_route_get_next_hop
(
route
);
metric
=
nm_ip4_route_get_metric
(
route
);
metric
=
nm_ip4_route_get_metric
(
route
);
if
(
dest
){
/* dest and prefix are required */
g_return_val_if_fail
(
dest
,
FALSE
);
g_return_val_if_fail
(
prefix
,
FALSE
);
route_s
=
g_string_new
(
""
);
addr
.
s_addr
=
dest
;
addr
.
s_addr
=
dest
;
dest_addr
=
g_strdup
(
inet_ntoa
(
addr
)
);
g_string_append_printf
(
route_s
,
"%s/%d"
,
inet_ntoa
(
addr
),
prefix
);
}
if
(
nhop
){
if
(
nhop
){
addr
.
s_addr
=
nhop
;
addr
.
s_addr
=
nhop
;
nhop_addr
=
g_strdup
(
inet_ntoa
(
addr
));
g_string_append_printf
(
route_s
,
" via %s"
,
inet_ntoa
(
addr
));
}
if
(
dest
&&
prefix
&&
nhop
&&
metric
){
routes
[
i
]
=
g_strdup_printf
(
"%s/%d via %s metric %d"
,
dest_addr
,
prefix
,
nhop_addr
,
metric
);
}
else
if
(
dest
&&
prefix
&&
nhop
){
routes
[
i
]
=
g_strdup_printf
(
"%s/%d via %s"
,
dest_addr
,
prefix
,
nhop_addr
);
}
else
if
(
dest
&&
prefix
&&
metric
){
routes
[
i
]
=
g_strdup_printf
(
"%s/%d metric %d"
,
dest_addr
,
prefix
,
metric
);
}
else
if
(
dest
&&
prefix
){
routes
[
i
]
=
g_strdup_printf
(
"%s/%d"
,
dest_addr
,
prefix
);
}
}
if
(
dest
)
if
(
metric
)
g_free
(
dest_addr
);
g_string_append_printf
(
route_s
,
" metric %d"
,
metric
);
if
(
nhop
)
routes
[
i
]
=
g_string_free
(
route_s
,
FALSE
);
g_free
(
nhop_addr
);
g_message
(
"export route #%d of %d: %s"
,
i
,
num_routes
,
routes
[
i
]);
g_message
(
"export route #%d of %d: %s"
,
i
,
num_routes
,
routes
[
i
]);
}
}
g_key_file_set_string_list
(
keyfile
,
IP4_SECTION
,
NM_SETTING_IP4_CONFIG_ROUTES
,
g_key_file_set_string_list
(
keyfile
,
IP4_SECTION
,
NM_SETTING_IP4_CONFIG_ROUTES
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment