uint64_t id;
int r;
+ assert(bus);
+
r = bus_get_property_trivial(bus, bus_network_mgr, "NamespaceId", &error, 't', &id);
if (r < 0) {
log_debug_errno(r, "Failed to query network namespace of networkd, ignoring: %s", bus_error_message(&error, r));
const char *text;
int r;
+ assert(bus);
+ assert(ret);
+
r = bus_call_method(bus, bus_network_mgr, "Describe", &error, &reply, NULL);
if (r < 0)
return log_error_errno(r, "Failed to get description: %s", bus_error_message(&error, r));
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
int r;
+ assert(bus);
+
r = get_description(bus, &v);
if (r < 0)
return r;
return 0;
}
-static int dump_link_description(sd_bus *bus, char **patterns) {
+static int dump_link_description(sd_bus *bus, char * const *patterns) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_free_ bool *matched_patterns = NULL;
JsonVariant *i;
size_t c = 0;
int r;
+ assert(bus);
+ assert(patterns);
+
r = get_description(bus, &v);
if (r < 0)
return r;
return 0;
}
-static void operational_state_to_color(const char *name, const char *state, const char **on, const char **off) {
+static void operational_state_to_color(
+ const char *name,
+ const char *state,
+ const char **on,
+ const char **off) {
+
if (STRPTR_IN_SET(state, "routable", "enslaved") ||
(streq_ptr(name, "lo") && streq_ptr(state, "carrier"))) {
if (on)
return 0;
}
-static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, bool matched_patterns[]) {
+static int decode_link(
+ sd_netlink_message *m,
+ LinkInfo *info,
+ char * const *patterns,
+ bool matched_patterns[]) {
+
_cleanup_strv_free_ char **altnames = NULL;
const char *name, *qdisc;
int ifindex, r;
char ifindex_str[DECIMAL_STR_MAX(int)];
int r;
+ assert(bus);
+ assert(link);
+ assert(link->ifindex >= 0);
+ assert(error);
+ assert(reply);
+ assert(iface);
+ assert(propname);
+
xsprintf(ifindex_str, "%i", link->ifindex);
r = sd_bus_path_encode("/org/freedesktop/network1/link", ifindex_str, &path);
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
+ assert(bus);
+ assert(link);
+
r = link_get_property(bus, link, &error, &reply, "org.freedesktop.network1.Link", "BitRates");
if (r < 0) {
bool quiet = sd_bus_error_has_names(&error, SD_BUS_ERROR_UNKNOWN_PROPERTY,
}
static void acquire_ether_link_info(int *fd, LinkInfo *link) {
- if (ethtool_get_link_info(fd, link->name,
+ assert(fd);
+ assert(link);
+
+ if (ethtool_get_link_info(fd,
+ link->name,
&link->autonegotiation,
&link->speed,
&link->duplex,
const char *type = NULL;
int r, k = 0;
+ assert(link);
+
if (link->sd_device)
(void) sd_device_get_devtype(link->sd_device, &type);
if (!streq_ptr(type, "wlan"))
link->has_wlan_link_info = r > 0 || k > 0;
}
-static int acquire_link_info(sd_bus *bus, sd_netlink *rtnl, char **patterns, LinkInfo **ret) {
+static int acquire_link_info(sd_bus *bus, sd_netlink *rtnl, char * const *patterns, LinkInfo **ret) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL;
_cleanup_(link_info_array_freep) LinkInfo *links = NULL;
_cleanup_free_ bool *matched_patterns = NULL;
static int dump_list(Table *table, const char *prefix, char * const *l) {
int r;
+ assert(table);
+
if (strv_isempty(l))
return 0;
_cleanup_fclose_ FILE *f = NULL;
char p[STRLEN("/run/systemd/netif/lldp/") + DECIMAL_STR_MAX(int)];
+ assert(ifindex >= 0);
+ assert(ret);
+
xsprintf(p, "/run/systemd/netif/lldp/%i", ifindex);
f = fopen(p, "re");
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
+ assert(table);
+ assert(prefix);
+ assert(bus);
+ assert(link);
+
r = link_get_property(bus, link, &error, &reply, "org.freedesktop.network1.DHCPServer", "Leases");
if (r < 0) {
bool quiet = sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_PROPERTY);
static int dump_ifindexes(Table *table, const char *prefix, const int *ifindexes) {
int r;
+ assert(table);
assert(prefix);
if (!ifindexes || ifindexes[0] <= 0)
static int dump_statistics(Table *table, const LinkInfo *info) {
int r;
+ assert(table);
+ assert(info);
+
if (!arg_stats)
return 0;
TableCell *cell;
int r;
+ assert(bus);
assert(rtnl);
assert(info);
int r;
assert(rtnl);
+ assert(index >= 0);
r = sd_rtnl_message_new_link(rtnl, &req, RTM_DELLINK, index);
if (r < 0)
int r;
assert(rtnl);
+ assert(index >= 0);
r = sd_rtnl_message_new_link(rtnl, &req, RTM_SETLINK, index);
if (r < 0)
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
+ assert(bus);
+ assert(index >= 0);
+ assert(name);
+
r = bus_call_method(bus, bus_network_mgr, "RenewLink", &error, NULL, "i", index);
if (r < 0)
return log_error_errno(r, "Failed to renew dynamic configuration of interface %s: %s",
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
+ assert(bus);
+ assert(index >= 0);
+ assert(name);
+
r = bus_call_method(bus, bus_network_mgr, "ForceRenewLink", &error, NULL, "i", index);
if (r < 0)
return log_error_errno(r, "Failed to force renew dynamic configuration of interface %s: %s",
}
static int parse_argv(int argc, char *argv[]) {
-
enum {
ARG_VERSION = 0x100,
ARG_NO_PAGER,