dhcp: move definition of sd_dhcp_route and related functions to dhcp-route.[ch]
This also renames arguments for storing results. No functional change, just refactoring and preparation for later commits.
This commit is contained in:
@@ -12,12 +12,6 @@
|
||||
#include "sd-forward.h"
|
||||
#include "list.h"
|
||||
|
||||
struct sd_dhcp_route {
|
||||
struct in_addr dst_addr;
|
||||
struct in_addr gw_addr;
|
||||
unsigned char dst_prefixlen;
|
||||
};
|
||||
|
||||
struct sd_dhcp_raw_option {
|
||||
LIST_FIELDS(struct sd_dhcp_raw_option, options);
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-dhcp-lease.h"
|
||||
|
||||
#include "dhcp-route.h" /* IWYU pragma: keep */
|
||||
|
||||
int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *ret) {
|
||||
assert_return(route, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
*ret = route->dst_addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *ret) {
|
||||
assert_return(route, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
*ret = route->dst_prefixlen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *ret) {
|
||||
assert_return(route, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
*ret = route->gw_addr;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-forward.h"
|
||||
|
||||
#include "in-addr-util.h" /* IWYU pragma: keep */
|
||||
|
||||
struct sd_dhcp_route {
|
||||
struct in_addr dst_addr;
|
||||
struct in_addr gw_addr;
|
||||
uint8_t dst_prefixlen;
|
||||
};
|
||||
@@ -8,6 +8,7 @@ libsystemd_network_sources = files(
|
||||
'dhcp-option.c',
|
||||
'dhcp-packet.c',
|
||||
'dhcp-protocol.c',
|
||||
'dhcp-route.c',
|
||||
'dhcp6-network.c',
|
||||
'dhcp6-option.c',
|
||||
'dhcp6-protocol.c',
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sd-dhcp-lease.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dhcp-lease-internal.h"
|
||||
#include "dhcp-route.h"
|
||||
#include "dns-resolver-internal.h"
|
||||
#include "extract-word.h"
|
||||
#include "hexdecoct.h"
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "dhcp-lease-internal.h"
|
||||
#include "dhcp-option.h"
|
||||
#include "dhcp-route.h"
|
||||
#include "dns-def.h"
|
||||
#include "dns-domain.h"
|
||||
#include "dns-resolver-internal.h"
|
||||
@@ -1802,27 +1803,3 @@ int sd_dhcp_lease_get_timezone(sd_dhcp_lease *lease, const char **ret) {
|
||||
*ret = lease->timezone;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *destination) {
|
||||
assert_return(route, -EINVAL);
|
||||
assert_return(destination, -EINVAL);
|
||||
|
||||
*destination = route->dst_addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *length) {
|
||||
assert_return(route, -EINVAL);
|
||||
assert_return(length, -EINVAL);
|
||||
|
||||
*length = route->dst_prefixlen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *gateway) {
|
||||
assert_return(route, -EINVAL);
|
||||
assert_return(gateway, -EINVAL);
|
||||
|
||||
*gateway = route->gw_addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dhcp-lease-internal.h"
|
||||
#include "dhcp-route.h"
|
||||
#include "hashmap.h"
|
||||
#include "hostname-setup.h"
|
||||
#include "network-internal.h"
|
||||
|
||||
@@ -86,9 +86,9 @@ int sd_dhcp_lease_get_6rd(
|
||||
size_t *ret_n_br_addresses);
|
||||
int sd_dhcp_lease_has_6rd(sd_dhcp_lease *lease);
|
||||
|
||||
int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *destination);
|
||||
int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *length);
|
||||
int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *gateway);
|
||||
int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *ret);
|
||||
int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *ret);
|
||||
int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *ret);
|
||||
|
||||
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_lease, sd_dhcp_lease_unref);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user