const char *admin_state, *oper_state, *carrier_state, *address_state;
_cleanup_free_ char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
- Route *route;
Address *a;
int r;
/************************************************************/
- fputs("ROUTES=", f);
- space = false;
- SET_FOREACH(route, link->routes) {
- _cleanup_free_ char *route_str = NULL;
-
- r = in_addr_to_string(route->family, &route->dst, &route_str);
- if (r < 0)
- goto fail;
-
- fprintf(f, "%s%s/%hhu/%hhu/%"PRIu32"/%"PRIu32"/"USEC_FMT,
- space ? " " : "", route_str,
- route->dst_prefixlen, route->tos, route->priority, route->table, route->lifetime);
- space = true;
- }
-
- fputc('\n', f);
+ r = link_serialize_routes(link, f);
+ if (r < 0)
+ goto fail;
}
print_link_hashmap(f, "CARRIER_BOUND_TO=", link->bound_to_links);
return 1;
}
+int link_serialize_routes(Link *link, FILE *f) {
+ bool space = false;
+ Route *route;
+
+ assert(link);
+ assert(link->network);
+ assert(f);
+
+ fputs("ROUTES=", f);
+ SET_FOREACH(route, link->routes) {
+ _cleanup_free_ char *route_str = NULL;
+
+ if (in_addr_to_string(route->family, &route->dst, &route_str) < 0)
+ continue;
+
+ fprintf(f, "%s%s/%hhu/%hhu/%"PRIu32"/%"PRIu32"/"USEC_FMT,
+ space ? " " : "", route_str,
+ route->dst_prefixlen, route->tos, route->priority, route->table, route->lifetime);
+ space = true;
+ }
+ fputc('\n', f);
+
+ return 0;
+}
+
int link_deserialize_routes(Link *link, const char *routes) {
int r;
int link_set_routes(Link *link);
int link_drop_routes(Link *link);
int link_drop_foreign_routes(Link *link);
+int link_serialize_routes(Link *link, FILE *f);
int link_deserialize_routes(Link *link, const char *routes);
int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);