| File: | build-scan/../src/libsystemd/sd-network/sd-network.c |
| Warning: | line 313, column 9 Value stored to 'fd' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
| 2 | |
| 3 | #include <errno(*__errno_location ()).h> |
| 4 | #include <poll.h> |
| 5 | #include <string.h> |
| 6 | #include <sys/inotify.h> |
| 7 | |
| 8 | #include "sd-network.h" |
| 9 | |
| 10 | #include "alloc-util.h" |
| 11 | #include "fd-util.h" |
| 12 | #include "fileio.h" |
| 13 | #include "fs-util.h" |
| 14 | #include "macro.h" |
| 15 | #include "parse-util.h" |
| 16 | #include "stdio-util.h" |
| 17 | #include "string-util.h" |
| 18 | #include "strv.h" |
| 19 | #include "util.h" |
| 20 | |
| 21 | _public___attribute__ ((visibility("default"))) int sd_network_get_operational_state(char **state) { |
| 22 | _cleanup_free___attribute__((cleanup(freep))) char *s = NULL((void*)0); |
| 23 | int r; |
| 24 | |
| 25 | assert_return(state, -EINVAL)do { if (!(((__builtin_expect(!!(state),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("state"), "../src/libsystemd/sd-network/sd-network.c" , 25, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 26 | |
| 27 | r = parse_env_file(NULL((void*)0), "/run/systemd/netif/state", NEWLINE"\n\r", "OPER_STATE", &s, NULL((void*)0)); |
| 28 | if (r == -ENOENT2) |
| 29 | return -ENODATA61; |
| 30 | if (r < 0) |
| 31 | return r; |
| 32 | if (isempty(s)) |
| 33 | return -ENODATA61; |
| 34 | |
| 35 | *state = TAKE_PTR(s)({ typeof(s) _ptr_ = (s); (s) = ((void*)0); _ptr_; }); |
| 36 | |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | static int network_get_strv(const char *key, char ***ret) { |
| 41 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **a = NULL((void*)0); |
| 42 | _cleanup_free___attribute__((cleanup(freep))) char *s = NULL((void*)0); |
| 43 | int r; |
| 44 | |
| 45 | assert_return(ret, -EINVAL)do { if (!(((__builtin_expect(!!(ret),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("ret"), "../src/libsystemd/sd-network/sd-network.c" , 45, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 46 | |
| 47 | r = parse_env_file(NULL((void*)0), "/run/systemd/netif/state", NEWLINE"\n\r", key, &s, NULL((void*)0)); |
| 48 | if (r == -ENOENT2) |
| 49 | return -ENODATA61; |
| 50 | if (r < 0) |
| 51 | return r; |
| 52 | if (isempty(s)) { |
| 53 | *ret = NULL((void*)0); |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | a = strv_split(s, " "); |
| 58 | if (!a) |
| 59 | return -ENOMEM12; |
| 60 | |
| 61 | strv_uniq(a); |
| 62 | r = (int) strv_length(a); |
| 63 | |
| 64 | *ret = TAKE_PTR(a)({ typeof(a) _ptr_ = (a); (a) = ((void*)0); _ptr_; }); |
| 65 | |
| 66 | return r; |
| 67 | } |
| 68 | |
| 69 | _public___attribute__ ((visibility("default"))) int sd_network_get_dns(char ***ret) { |
| 70 | return network_get_strv("DNS", ret); |
| 71 | } |
| 72 | |
| 73 | _public___attribute__ ((visibility("default"))) int sd_network_get_ntp(char ***ret) { |
| 74 | return network_get_strv("NTP", ret); |
| 75 | } |
| 76 | |
| 77 | _public___attribute__ ((visibility("default"))) int sd_network_get_search_domains(char ***ret) { |
| 78 | return network_get_strv("DOMAINS", ret); |
| 79 | } |
| 80 | |
| 81 | _public___attribute__ ((visibility("default"))) int sd_network_get_route_domains(char ***ret) { |
| 82 | return network_get_strv("ROUTE_DOMAINS", ret); |
| 83 | } |
| 84 | |
| 85 | static int network_link_get_string(int ifindex, const char *field, char **ret) { |
| 86 | char path[STRLEN("/run/systemd/netif/links/")(sizeof("""/run/systemd/netif/links/""") - 1) + DECIMAL_STR_MAX(ifindex)(2+(sizeof(ifindex) <= 1 ? 3 : sizeof(ifindex) <= 2 ? 5 : sizeof(ifindex) <= 4 ? 10 : sizeof(ifindex) <= 8 ? 20 : sizeof(int[-2*(sizeof(ifindex) > 8)]))) + 1]; |
| 87 | _cleanup_free___attribute__((cleanup(freep))) char *s = NULL((void*)0); |
| 88 | int r; |
| 89 | |
| 90 | assert_return(ifindex > 0, -EINVAL)do { if (!(((__builtin_expect(!!(ifindex > 0),1))) ? (1) : (log_assert_failed_return_realm(LOG_REALM_SYSTEMD, ("ifindex > 0" ), "../src/libsystemd/sd-network/sd-network.c", 90, __PRETTY_FUNCTION__ ), 0))) return (-22); } while (0); |
| 91 | assert_return(ret, -EINVAL)do { if (!(((__builtin_expect(!!(ret),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("ret"), "../src/libsystemd/sd-network/sd-network.c" , 91, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 92 | |
| 93 | xsprintf(path, "/run/systemd/netif/links/%i", ifindex)do { if ((__builtin_expect(!!(!(((size_t) snprintf(path, __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p(typeof (path), typeof(&*(path))), sizeof(path)/sizeof((path)[0]) , ((void)0))), "/run/systemd/netif/links/%i", ifindex) < ( __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p (typeof(path), typeof(&*(path))), sizeof(path)/sizeof((path )[0]), ((void)0))))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("xsprintf: " "path" "[] must be big enough"), "../src/libsystemd/sd-network/sd-network.c" , 93, __PRETTY_FUNCTION__); } while (0); |
| 94 | |
| 95 | r = parse_env_file(NULL((void*)0), path, NEWLINE"\n\r", field, &s, NULL((void*)0)); |
| 96 | if (r == -ENOENT2) |
| 97 | return -ENODATA61; |
| 98 | if (r < 0) |
| 99 | return r; |
| 100 | if (isempty(s)) |
| 101 | return -ENODATA61; |
| 102 | |
| 103 | *ret = TAKE_PTR(s)({ typeof(s) _ptr_ = (s); (s) = ((void*)0); _ptr_; }); |
| 104 | |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | static int network_link_get_strv(int ifindex, const char *key, char ***ret) { |
| 109 | char path[STRLEN("/run/systemd/netif/links/")(sizeof("""/run/systemd/netif/links/""") - 1) + DECIMAL_STR_MAX(ifindex)(2+(sizeof(ifindex) <= 1 ? 3 : sizeof(ifindex) <= 2 ? 5 : sizeof(ifindex) <= 4 ? 10 : sizeof(ifindex) <= 8 ? 20 : sizeof(int[-2*(sizeof(ifindex) > 8)]))) + 1]; |
| 110 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **a = NULL((void*)0); |
| 111 | _cleanup_free___attribute__((cleanup(freep))) char *s = NULL((void*)0); |
| 112 | int r; |
| 113 | |
| 114 | assert_return(ifindex > 0, -EINVAL)do { if (!(((__builtin_expect(!!(ifindex > 0),1))) ? (1) : (log_assert_failed_return_realm(LOG_REALM_SYSTEMD, ("ifindex > 0" ), "../src/libsystemd/sd-network/sd-network.c", 114, __PRETTY_FUNCTION__ ), 0))) return (-22); } while (0); |
| 115 | assert_return(ret, -EINVAL)do { if (!(((__builtin_expect(!!(ret),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("ret"), "../src/libsystemd/sd-network/sd-network.c" , 115, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 116 | |
| 117 | xsprintf(path, "/run/systemd/netif/links/%i", ifindex)do { if ((__builtin_expect(!!(!(((size_t) snprintf(path, __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p(typeof (path), typeof(&*(path))), sizeof(path)/sizeof((path)[0]) , ((void)0))), "/run/systemd/netif/links/%i", ifindex) < ( __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p (typeof(path), typeof(&*(path))), sizeof(path)/sizeof((path )[0]), ((void)0))))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("xsprintf: " "path" "[] must be big enough"), "../src/libsystemd/sd-network/sd-network.c" , 117, __PRETTY_FUNCTION__); } while (0); |
| 118 | r = parse_env_file(NULL((void*)0), path, NEWLINE"\n\r", key, &s, NULL((void*)0)); |
| 119 | if (r == -ENOENT2) |
| 120 | return -ENODATA61; |
| 121 | if (r < 0) |
| 122 | return r; |
| 123 | if (isempty(s)) { |
| 124 | *ret = NULL((void*)0); |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | a = strv_split(s, " "); |
| 129 | if (!a) |
| 130 | return -ENOMEM12; |
| 131 | |
| 132 | strv_uniq(a); |
| 133 | r = (int) strv_length(a); |
| 134 | |
| 135 | *ret = TAKE_PTR(a)({ typeof(a) _ptr_ = (a); (a) = ((void*)0); _ptr_; }); |
| 136 | |
| 137 | return r; |
| 138 | } |
| 139 | |
| 140 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_setup_state(int ifindex, char **state) { |
| 141 | return network_link_get_string(ifindex, "ADMIN_STATE", state); |
| 142 | } |
| 143 | |
| 144 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_network_file(int ifindex, char **filename) { |
| 145 | return network_link_get_string(ifindex, "NETWORK_FILE", filename); |
| 146 | } |
| 147 | |
| 148 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_operational_state(int ifindex, char **state) { |
| 149 | return network_link_get_string(ifindex, "OPER_STATE", state); |
| 150 | } |
| 151 | |
| 152 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_required_for_online(int ifindex) { |
| 153 | _cleanup_free___attribute__((cleanup(freep))) char *s = NULL((void*)0); |
| 154 | int r; |
| 155 | |
| 156 | r = network_link_get_string(ifindex, "REQUIRED_FOR_ONLINE", &s); |
| 157 | if (r < 0) { |
| 158 | /* Handle -ENODATA as RequiredForOnline=yes, for compatibility */ |
| 159 | if (r == -ENODATA61) |
| 160 | return true1; |
| 161 | return r; |
| 162 | } |
| 163 | |
| 164 | return parse_boolean(s); |
| 165 | } |
| 166 | |
| 167 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_llmnr(int ifindex, char **llmnr) { |
| 168 | return network_link_get_string(ifindex, "LLMNR", llmnr); |
| 169 | } |
| 170 | |
| 171 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_mdns(int ifindex, char **mdns) { |
| 172 | return network_link_get_string(ifindex, "MDNS", mdns); |
| 173 | } |
| 174 | |
| 175 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_dns_over_tls(int ifindex, char **dns_over_tls) { |
| 176 | return network_link_get_string(ifindex, "DNS_OVER_TLS", dns_over_tls); |
| 177 | } |
| 178 | |
| 179 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_dnssec(int ifindex, char **dnssec) { |
| 180 | return network_link_get_string(ifindex, "DNSSEC", dnssec); |
| 181 | } |
| 182 | |
| 183 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_dnssec_negative_trust_anchors(int ifindex, char ***nta) { |
| 184 | return network_link_get_strv(ifindex, "DNSSEC_NTA", nta); |
| 185 | } |
| 186 | |
| 187 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_timezone(int ifindex, char **ret) { |
| 188 | return network_link_get_string(ifindex, "TIMEZONE", ret); |
| 189 | } |
| 190 | |
| 191 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_dns(int ifindex, char ***ret) { |
| 192 | return network_link_get_strv(ifindex, "DNS", ret); |
| 193 | } |
| 194 | |
| 195 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_ntp(int ifindex, char ***ret) { |
| 196 | return network_link_get_strv(ifindex, "NTP", ret); |
| 197 | } |
| 198 | |
| 199 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_search_domains(int ifindex, char ***ret) { |
| 200 | return network_link_get_strv(ifindex, "DOMAINS", ret); |
| 201 | } |
| 202 | |
| 203 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_route_domains(int ifindex, char ***ret) { |
| 204 | return network_link_get_strv(ifindex, "ROUTE_DOMAINS", ret); |
| 205 | } |
| 206 | |
| 207 | static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) { |
| 208 | char path[STRLEN("/run/systemd/netif/links/")(sizeof("""/run/systemd/netif/links/""") - 1) + DECIMAL_STR_MAX(ifindex)(2+(sizeof(ifindex) <= 1 ? 3 : sizeof(ifindex) <= 2 ? 5 : sizeof(ifindex) <= 4 ? 10 : sizeof(ifindex) <= 8 ? 20 : sizeof(int[-2*(sizeof(ifindex) > 8)]))) + 1]; |
| 209 | _cleanup_free___attribute__((cleanup(freep))) int *ifis = NULL((void*)0); |
| 210 | _cleanup_free___attribute__((cleanup(freep))) char *s = NULL((void*)0); |
| 211 | size_t allocated = 0, c = 0; |
| 212 | const char *x; |
| 213 | int r; |
| 214 | |
| 215 | assert_return(ifindex > 0, -EINVAL)do { if (!(((__builtin_expect(!!(ifindex > 0),1))) ? (1) : (log_assert_failed_return_realm(LOG_REALM_SYSTEMD, ("ifindex > 0" ), "../src/libsystemd/sd-network/sd-network.c", 215, __PRETTY_FUNCTION__ ), 0))) return (-22); } while (0); |
| 216 | assert_return(ret, -EINVAL)do { if (!(((__builtin_expect(!!(ret),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("ret"), "../src/libsystemd/sd-network/sd-network.c" , 216, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 217 | |
| 218 | xsprintf(path, "/run/systemd/netif/links/%i", ifindex)do { if ((__builtin_expect(!!(!(((size_t) snprintf(path, __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p(typeof (path), typeof(&*(path))), sizeof(path)/sizeof((path)[0]) , ((void)0))), "/run/systemd/netif/links/%i", ifindex) < ( __extension__ (__builtin_choose_expr( !__builtin_types_compatible_p (typeof(path), typeof(&*(path))), sizeof(path)/sizeof((path )[0]), ((void)0))))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("xsprintf: " "path" "[] must be big enough"), "../src/libsystemd/sd-network/sd-network.c" , 218, __PRETTY_FUNCTION__); } while (0); |
| 219 | r = parse_env_file(NULL((void*)0), path, NEWLINE"\n\r", key, &s, NULL((void*)0)); |
| 220 | if (r == -ENOENT2) |
| 221 | return -ENODATA61; |
| 222 | if (r < 0) |
| 223 | return r; |
| 224 | |
| 225 | for (x = s;;) { |
| 226 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0); |
| 227 | |
| 228 | r = extract_first_word(&x, &word, NULL((void*)0), 0); |
| 229 | if (r < 0) |
| 230 | return r; |
| 231 | if (r == 0) |
| 232 | break; |
| 233 | |
| 234 | r = parse_ifindex(word, &ifindex); |
| 235 | if (r < 0) |
| 236 | return r; |
| 237 | |
| 238 | if (!GREEDY_REALLOC(ifis, allocated, c + 2)greedy_realloc((void**) &(ifis), &(allocated), (c + 2 ), sizeof((ifis)[0]))) |
| 239 | return -ENOMEM12; |
| 240 | |
| 241 | ifis[c++] = ifindex; |
| 242 | } |
| 243 | |
| 244 | if (ifis) |
| 245 | ifis[c] = 0; /* Let's add a 0 ifindex to the end, to be nice */ |
| 246 | |
| 247 | *ret = TAKE_PTR(ifis)({ typeof(ifis) _ptr_ = (ifis); (ifis) = ((void*)0); _ptr_; } ); |
| 248 | |
| 249 | return c; |
| 250 | } |
| 251 | |
| 252 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_carrier_bound_to(int ifindex, int **ret) { |
| 253 | return network_link_get_ifindexes(ifindex, "CARRIER_BOUND_TO", ret); |
| 254 | } |
| 255 | |
| 256 | _public___attribute__ ((visibility("default"))) int sd_network_link_get_carrier_bound_by(int ifindex, int **ret) { |
| 257 | return network_link_get_ifindexes(ifindex, "CARRIER_BOUND_BY", ret); |
| 258 | } |
| 259 | |
| 260 | static inline int MONITOR_TO_FD(sd_network_monitor *m) { |
| 261 | return (int) (unsigned long) m - 1; |
| 262 | } |
| 263 | |
| 264 | static inline sd_network_monitor* FD_TO_MONITOR(int fd) { |
| 265 | return (sd_network_monitor*) (unsigned long) (fd + 1); |
| 266 | } |
| 267 | |
| 268 | static int monitor_add_inotify_watch(int fd) { |
| 269 | int k; |
| 270 | |
| 271 | k = inotify_add_watch(fd, "/run/systemd/netif/links/", IN_MOVED_TO0x00000080|IN_DELETE0x00000200); |
| 272 | if (k >= 0) |
| 273 | return 0; |
| 274 | else if (errno(*__errno_location ()) != ENOENT2) |
| 275 | return -errno(*__errno_location ()); |
| 276 | |
| 277 | k = inotify_add_watch(fd, "/run/systemd/netif/", IN_CREATE0x00000100|IN_ISDIR0x40000000); |
| 278 | if (k >= 0) |
| 279 | return 0; |
| 280 | else if (errno(*__errno_location ()) != ENOENT2) |
| 281 | return -errno(*__errno_location ()); |
| 282 | |
| 283 | k = inotify_add_watch(fd, "/run/systemd/", IN_CREATE0x00000100|IN_ISDIR0x40000000); |
| 284 | if (k < 0) |
| 285 | return -errno(*__errno_location ()); |
| 286 | |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | _public___attribute__ ((visibility("default"))) int sd_network_monitor_new(sd_network_monitor **m, const char *category) { |
| 291 | _cleanup_close___attribute__((cleanup(closep))) int fd = -1; |
| 292 | int k; |
| 293 | bool_Bool good = false0; |
| 294 | |
| 295 | assert_return(m, -EINVAL)do { if (!(((__builtin_expect(!!(m),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("m"), "../src/libsystemd/sd-network/sd-network.c" , 295, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 296 | |
| 297 | fd = inotify_init1(IN_NONBLOCKIN_NONBLOCK|IN_CLOEXECIN_CLOEXEC); |
| 298 | if (fd < 0) |
| 299 | return -errno(*__errno_location ()); |
| 300 | |
| 301 | if (!category || streq(category, "links")(strcmp((category),("links")) == 0)) { |
| 302 | k = monitor_add_inotify_watch(fd); |
| 303 | if (k < 0) |
| 304 | return k; |
| 305 | |
| 306 | good = true1; |
| 307 | } |
| 308 | |
| 309 | if (!good) |
| 310 | return -EINVAL22; |
| 311 | |
| 312 | *m = FD_TO_MONITOR(fd); |
| 313 | fd = -1; |
Value stored to 'fd' is never read | |
| 314 | |
| 315 | return 0; |
| 316 | } |
| 317 | |
| 318 | _public___attribute__ ((visibility("default"))) sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m) { |
| 319 | int fd; |
| 320 | |
| 321 | if (m) { |
| 322 | fd = MONITOR_TO_FD(m); |
| 323 | close_nointr(fd); |
| 324 | } |
| 325 | |
| 326 | return NULL((void*)0); |
| 327 | } |
| 328 | |
| 329 | _public___attribute__ ((visibility("default"))) int sd_network_monitor_flush(sd_network_monitor *m) { |
| 330 | union inotify_event_buffer buffer; |
| 331 | struct inotify_event *e; |
| 332 | ssize_t l; |
| 333 | int fd, k; |
| 334 | |
| 335 | assert_return(m, -EINVAL)do { if (!(((__builtin_expect(!!(m),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("m"), "../src/libsystemd/sd-network/sd-network.c" , 335, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 336 | |
| 337 | fd = MONITOR_TO_FD(m); |
| 338 | |
| 339 | l = read(fd, &buffer, sizeof(buffer)); |
| 340 | if (l < 0) { |
| 341 | if (IN_SET(errno, EAGAIN, EINTR)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){11, 4})/sizeof(int)]; switch((*__errno_location ())) { case 11: case 4: _found = 1; break; default: break; } _found; })) |
| 342 | return 0; |
| 343 | |
| 344 | return -errno(*__errno_location ()); |
| 345 | } |
| 346 | |
| 347 | FOREACH_INOTIFY_EVENT(e, buffer, l)for ((e) = &buffer.ev; (uint8_t*) (e) < (uint8_t*) (buffer .raw) + (l); (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof (struct inotify_event) + (e)->len)) { |
| 348 | if (e->mask & IN_ISDIR0x40000000) { |
| 349 | k = monitor_add_inotify_watch(fd); |
| 350 | if (k < 0) |
| 351 | return k; |
| 352 | |
| 353 | k = inotify_rm_watch(fd, e->wd); |
| 354 | if (k < 0) |
| 355 | return -errno(*__errno_location ()); |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | _public___attribute__ ((visibility("default"))) int sd_network_monitor_get_fd(sd_network_monitor *m) { |
| 363 | |
| 364 | assert_return(m, -EINVAL)do { if (!(((__builtin_expect(!!(m),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("m"), "../src/libsystemd/sd-network/sd-network.c" , 364, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 365 | |
| 366 | return MONITOR_TO_FD(m); |
| 367 | } |
| 368 | |
| 369 | _public___attribute__ ((visibility("default"))) int sd_network_monitor_get_events(sd_network_monitor *m) { |
| 370 | |
| 371 | assert_return(m, -EINVAL)do { if (!(((__builtin_expect(!!(m),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("m"), "../src/libsystemd/sd-network/sd-network.c" , 371, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 372 | |
| 373 | /* For now we will only return POLLIN here, since we don't |
| 374 | * need anything else ever for inotify. However, let's have |
| 375 | * this API to keep our options open should we later on need |
| 376 | * it. */ |
| 377 | return POLLIN0x001; |
| 378 | } |
| 379 | |
| 380 | _public___attribute__ ((visibility("default"))) int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec) { |
| 381 | |
| 382 | assert_return(m, -EINVAL)do { if (!(((__builtin_expect(!!(m),1))) ? (1) : (log_assert_failed_return_realm (LOG_REALM_SYSTEMD, ("m"), "../src/libsystemd/sd-network/sd-network.c" , 382, __PRETTY_FUNCTION__), 0))) return (-22); } while (0); |
| 383 | assert_return(timeout_usec, -EINVAL)do { if (!(((__builtin_expect(!!(timeout_usec),1))) ? (1) : ( log_assert_failed_return_realm(LOG_REALM_SYSTEMD, ("timeout_usec" ), "../src/libsystemd/sd-network/sd-network.c", 383, __PRETTY_FUNCTION__ ), 0))) return (-22); } while (0); |
| 384 | |
| 385 | /* For now we will only return (uint64_t) -1, since we don't |
| 386 | * need any timeout. However, let's have this API to keep our |
| 387 | * options open should we later on need it. */ |
| 388 | *timeout_usec = (uint64_t) -1; |
| 389 | return 0; |
| 390 | } |