2 This file is part of systemd.
4 Copyright 2014 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "sd-device.h"
27 #include "sd-netlink.h"
28 #include "sd-network.h"
30 #include "alloc-util.h"
31 #include "arphrd-list.h"
32 #include "device-util.h"
33 #include "ether-addr-util.h"
35 #include "hwdb-util.h"
37 #include "local-addresses.h"
38 #include "locale-util.h"
39 #include "netlink-util.h"
41 #include "parse-util.h"
42 #include "socket-util.h"
43 #include "sparse-endian.h"
44 #include "stdio-util.h"
45 #include "string-table.h"
46 #include "string-util.h"
48 #include "terminal-util.h"
52 static bool arg_no_pager
= false;
53 static bool arg_legend
= true;
54 static bool arg_all
= false;
56 static void pager_open_if_enabled(void) {
64 static int link_get_type_string(unsigned short iftype
, sd_device
*d
, char **ret
) {
70 if (iftype
== ARPHRD_ETHER
&& d
) {
71 const char *devtype
= NULL
, *id
= NULL
;
72 /* WLANs have iftype ARPHRD_ETHER, but we want
73 * to show a more useful type string for
76 (void) sd_device_get_devtype(d
, &devtype
);
78 if (streq_ptr(devtype
, "wlan"))
80 else if (streq_ptr(devtype
, "wwan"))
93 t
= arphrd_to_name(iftype
);
109 static void operational_state_to_color(const char *state
, const char **on
, const char **off
) {
113 if (streq_ptr(state
, "routable")) {
114 *on
= ansi_highlight_green();
115 *off
= ansi_normal();
116 } else if (streq_ptr(state
, "degraded")) {
117 *on
= ansi_highlight_yellow();
118 *off
= ansi_normal();
123 static void setup_state_to_color(const char *state
, const char **on
, const char **off
) {
127 if (streq_ptr(state
, "configured")) {
128 *on
= ansi_highlight_green();
129 *off
= ansi_normal();
130 } else if (streq_ptr(state
, "configuring")) {
131 *on
= ansi_highlight_yellow();
132 *off
= ansi_normal();
133 } else if (streq_ptr(state
, "failed") || streq_ptr(state
, "linger")) {
134 *on
= ansi_highlight_red();
135 *off
= ansi_normal();
140 typedef struct LinkInfo
{
141 char name
[IFNAMSIZ
+1];
143 unsigned short iftype
;
144 struct ether_addr mac_address
;
147 bool has_mac_address
:1;
151 static int link_info_compare(const void *a
, const void *b
) {
152 const LinkInfo
*x
= a
, *y
= b
;
154 return x
->ifindex
- y
->ifindex
;
157 static int decode_link(sd_netlink_message
*m
, LinkInfo
*info
) {
158 static const struct ether_addr null_address
= {};
166 r
= sd_netlink_message_get_type(m
, &type
);
170 if (type
!= RTM_NEWLINK
)
173 r
= sd_rtnl_message_link_get_ifindex(m
, &info
->ifindex
);
177 r
= sd_netlink_message_read_string(m
, IFLA_IFNAME
, &name
);
181 r
= sd_rtnl_message_link_get_type(m
, &info
->iftype
);
185 strncpy(info
->name
, name
, sizeof(info
->name
));
187 info
->has_mac_address
=
188 sd_netlink_message_read_ether_addr(m
, IFLA_ADDRESS
, &info
->mac_address
) >= 0 &&
189 memcmp(&info
->mac_address
, &null_address
, sizeof(struct ether_addr
)) != 0;
192 sd_netlink_message_read_u32(m
, IFLA_MTU
, &info
->mtu
) &&
198 static int acquire_link_info_strv(sd_netlink
*rtnl
, char **l
, LinkInfo
**ret
) {
199 _cleanup_free_ LinkInfo
*links
= NULL
;
207 links
= new(LinkInfo
, strv_length(l
));
212 _cleanup_(sd_netlink_message_unrefp
) sd_netlink_message
*req
= NULL
, *reply
= NULL
;
215 if (parse_ifindex(*i
, &ifindex
) >= 0)
216 r
= sd_rtnl_message_new_link(rtnl
, &req
, RTM_GETLINK
, ifindex
);
218 r
= sd_rtnl_message_new_link(rtnl
, &req
, RTM_GETLINK
, 0);
220 return rtnl_log_create_error(r
);
222 r
= sd_netlink_message_append_string(req
, IFLA_IFNAME
, *i
);
225 return rtnl_log_create_error(r
);
227 r
= sd_netlink_call(rtnl
, req
, 0, &reply
);
229 return log_error_errno(r
, "Failed to request link: %m");
231 r
= decode_link(reply
, links
+ c
);
238 qsort_safe(links
, c
, sizeof(LinkInfo
), link_info_compare
);
246 static int acquire_link_info_all(sd_netlink
*rtnl
, LinkInfo
**ret
) {
247 _cleanup_(sd_netlink_message_unrefp
) sd_netlink_message
*req
= NULL
, *reply
= NULL
;
248 _cleanup_free_ LinkInfo
*links
= NULL
;
249 size_t allocated
= 0, c
= 0;
250 sd_netlink_message
*i
;
256 r
= sd_rtnl_message_new_link(rtnl
, &req
, RTM_GETLINK
, 0);
258 return rtnl_log_create_error(r
);
260 r
= sd_netlink_message_request_dump(req
, true);
262 return rtnl_log_create_error(r
);
264 r
= sd_netlink_call(rtnl
, req
, 0, &reply
);
266 return log_error_errno(r
, "Failed to enumerate links: %m");
268 for (i
= reply
; i
; i
= sd_netlink_message_next(i
)) {
269 if (!GREEDY_REALLOC(links
, allocated
, c
+1))
272 r
= decode_link(i
, links
+ c
);
279 qsort_safe(links
, c
, sizeof(LinkInfo
), link_info_compare
);
287 static int list_links(int argc
, char *argv
[], void *userdata
) {
288 _cleanup_(sd_netlink_unrefp
) sd_netlink
*rtnl
= NULL
;
289 _cleanup_free_ LinkInfo
*links
= NULL
;
292 r
= sd_netlink_open(&rtnl
);
294 return log_error_errno(r
, "Failed to connect to netlink: %m");
297 c
= acquire_link_info_strv(rtnl
, argv
+ 1, &links
);
299 c
= acquire_link_info_all(rtnl
, &links
);
303 pager_open_if_enabled();
306 printf("%3s %-16s %-18s %-11s %-10s\n",
313 for (i
= 0; i
< c
; i
++) {
314 _cleanup_free_
char *setup_state
= NULL
, *operational_state
= NULL
;
315 _cleanup_(sd_device_unrefp
) sd_device
*d
= NULL
;
316 const char *on_color_operational
, *off_color_operational
,
317 *on_color_setup
, *off_color_setup
;
318 char devid
[2 + DECIMAL_STR_MAX(int)];
319 _cleanup_free_
char *t
= NULL
;
321 sd_network_link_get_operational_state(links
[i
].ifindex
, &operational_state
);
322 operational_state_to_color(operational_state
, &on_color_operational
, &off_color_operational
);
324 sd_network_link_get_setup_state(links
[i
].ifindex
, &setup_state
);
325 setup_state_to_color(setup_state
, &on_color_setup
, &off_color_setup
);
327 xsprintf(devid
, "n%i", links
[i
].ifindex
);
328 (void) sd_device_new_from_device_id(&d
, devid
);
330 link_get_type_string(links
[i
].iftype
, d
, &t
);
332 printf("%3i %-16s %-18s %s%-11s%s %s%-10s%s\n",
333 links
[i
].ifindex
, links
[i
].name
, strna(t
),
334 on_color_operational
, strna(operational_state
), off_color_operational
,
335 on_color_setup
, strna(setup_state
), off_color_setup
);
339 printf("\n%i links listed.\n", c
);
344 /* IEEE Organizationally Unique Identifier vendor string */
345 static int ieee_oui(sd_hwdb
*hwdb
, const struct ether_addr
*mac
, char **ret
) {
346 const char *description
;
347 char modalias
[strlen("OUI:XXYYXXYYXXYY") + 1], *desc
;
358 /* skip commonly misused 00:00:00 (Xerox) prefix */
359 if (memcmp(mac
, "\0\0\0", 3) == 0)
362 xsprintf(modalias
, "OUI:" ETHER_ADDR_FORMAT_STR
,
363 ETHER_ADDR_FORMAT_VAL(*mac
));
365 r
= sd_hwdb_get(hwdb
, modalias
, "ID_OUI_FROM_DATABASE", &description
);
369 desc
= strdup(description
);
378 static int get_gateway_description(
383 union in_addr_union
*gateway
,
384 char **gateway_description
) {
385 _cleanup_(sd_netlink_message_unrefp
) sd_netlink_message
*req
= NULL
, *reply
= NULL
;
386 sd_netlink_message
*m
;
390 assert(ifindex
>= 0);
391 assert(family
== AF_INET
|| family
== AF_INET6
);
393 assert(gateway_description
);
395 r
= sd_rtnl_message_new_neigh(rtnl
, &req
, RTM_GETNEIGH
, ifindex
, family
);
399 r
= sd_netlink_message_request_dump(req
, true);
403 r
= sd_netlink_call(rtnl
, req
, 0, &reply
);
407 for (m
= reply
; m
; m
= sd_netlink_message_next(m
)) {
408 union in_addr_union gw
= {};
409 struct ether_addr mac
= {};
413 r
= sd_netlink_message_get_errno(m
);
415 log_error_errno(r
, "got error: %m");
419 r
= sd_netlink_message_get_type(m
, &type
);
421 log_error_errno(r
, "could not get type: %m");
425 if (type
!= RTM_NEWNEIGH
) {
426 log_error("type is not RTM_NEWNEIGH");
430 r
= sd_rtnl_message_neigh_get_family(m
, &fam
);
432 log_error_errno(r
, "could not get family: %m");
437 log_error("family is not correct");
441 r
= sd_rtnl_message_neigh_get_ifindex(m
, &ifi
);
443 log_error_errno(r
, "could not get ifindex: %m");
447 if (ifindex
> 0 && ifi
!= ifindex
)
452 r
= sd_netlink_message_read_in_addr(m
, NDA_DST
, &gw
.in
);
458 r
= sd_netlink_message_read_in6_addr(m
, NDA_DST
, &gw
.in6
);
467 if (!in_addr_equal(fam
, &gw
, gateway
))
470 r
= sd_netlink_message_read_ether_addr(m
, NDA_LLADDR
, &mac
);
474 r
= ieee_oui(hwdb
, &mac
, gateway_description
);
484 static int dump_gateways(
489 _cleanup_free_
struct local_address
*local
= NULL
;
492 n
= local_gateways(rtnl
, ifindex
, AF_UNSPEC
, &local
);
496 for (i
= 0; i
< n
; i
++) {
497 _cleanup_free_
char *gateway
= NULL
, *description
= NULL
;
499 r
= in_addr_to_string(local
[i
].family
, &local
[i
].address
, &gateway
);
503 r
= get_gateway_description(rtnl
, hwdb
, local
[i
].ifindex
, local
[i
].family
, &local
[i
].address
, &description
);
505 log_debug_errno(r
, "Could not get description of gateway: %m");
508 (int) strlen(prefix
),
509 i
== 0 ? prefix
: "",
513 printf(" (%s)", description
);
515 /* Show interface name for the entry if we show
516 * entries for all interfaces */
518 char name
[IF_NAMESIZE
+1];
520 if (if_indextoname(local
[i
].ifindex
, name
)) {
521 fputs(" on ", stdout
);
524 printf(" on %%%i", local
[i
].ifindex
);
533 static int dump_addresses(
538 _cleanup_free_
struct local_address
*local
= NULL
;
541 n
= local_addresses(rtnl
, ifindex
, AF_UNSPEC
, &local
);
545 for (i
= 0; i
< n
; i
++) {
546 _cleanup_free_
char *pretty
= NULL
;
548 r
= in_addr_to_string(local
[i
].family
, &local
[i
].address
, &pretty
);
553 (int) strlen(prefix
),
554 i
== 0 ? prefix
: "",
558 char name
[IF_NAMESIZE
+1];
560 if (if_indextoname(local
[i
].ifindex
, name
)) {
561 fputs(" on ", stdout
);
564 printf(" on %%%i", local
[i
].ifindex
);
573 static void dump_list(const char *prefix
, char **l
) {
581 (int) strlen(prefix
),
582 i
== l
? prefix
: "",
587 static int link_status_one(
590 const LinkInfo
*info
) {
592 _cleanup_strv_free_
char **dns
= NULL
, **ntp
= NULL
, **search_domains
= NULL
, **route_domains
= NULL
;
593 _cleanup_free_
char *setup_state
= NULL
, *operational_state
= NULL
, *tz
= NULL
;
594 _cleanup_(sd_device_unrefp
) sd_device
*d
= NULL
;
595 char devid
[2 + DECIMAL_STR_MAX(int)];
596 _cleanup_free_
char *t
= NULL
, *network
= NULL
;
597 const char *driver
= NULL
, *path
= NULL
, *vendor
= NULL
, *model
= NULL
, *link
= NULL
;
598 const char *on_color_operational
, *off_color_operational
,
599 *on_color_setup
, *off_color_setup
;
600 _cleanup_strv_free_
char **carrier_bound_to
= NULL
;
601 _cleanup_strv_free_
char **carrier_bound_by
= NULL
;
607 (void) sd_network_link_get_operational_state(info
->ifindex
, &operational_state
);
608 operational_state_to_color(operational_state
, &on_color_operational
, &off_color_operational
);
610 (void) sd_network_link_get_setup_state(info
->ifindex
, &setup_state
);
611 setup_state_to_color(setup_state
, &on_color_setup
, &off_color_setup
);
613 (void) sd_network_link_get_dns(info
->ifindex
, &dns
);
614 (void) sd_network_link_get_search_domains(info
->ifindex
, &search_domains
);
615 (void) sd_network_link_get_route_domains(info
->ifindex
, &route_domains
);
616 (void) sd_network_link_get_ntp(info
->ifindex
, &ntp
);
618 xsprintf(devid
, "n%i", info
->ifindex
);
620 (void) sd_device_new_from_device_id(&d
, devid
);
623 (void) sd_device_get_property_value(d
, "ID_NET_LINK_FILE", &link
);
624 (void) sd_device_get_property_value(d
, "ID_NET_DRIVER", &driver
);
625 (void) sd_device_get_property_value(d
, "ID_PATH", &path
);
627 r
= sd_device_get_property_value(d
, "ID_VENDOR_FROM_DATABASE", &vendor
);
629 (void) sd_device_get_property_value(d
, "ID_VENDOR", &vendor
);
631 r
= sd_device_get_property_value(d
, "ID_MODEL_FROM_DATABASE", &model
);
633 (void) sd_device_get_property_value(d
, "ID_MODEL", &model
);
636 link_get_type_string(info
->iftype
, d
, &t
);
638 sd_network_link_get_network_file(info
->ifindex
, &network
);
640 sd_network_link_get_carrier_bound_to(info
->ifindex
, &carrier_bound_to
);
641 sd_network_link_get_carrier_bound_by(info
->ifindex
, &carrier_bound_by
);
643 printf("%s%s%s %i: %s\n", on_color_operational
, draw_special_char(DRAW_BLACK_CIRCLE
), off_color_operational
, info
->ifindex
, info
->name
);
645 printf(" Link File: %s\n"
646 " Network File: %s\n"
648 " State: %s%s%s (%s%s%s)\n",
652 on_color_operational
, strna(operational_state
), off_color_operational
,
653 on_color_setup
, strna(setup_state
), off_color_setup
);
656 printf(" Path: %s\n", path
);
658 printf(" Driver: %s\n", driver
);
660 printf(" Vendor: %s\n", vendor
);
662 printf(" Model: %s\n", model
);
664 if (info
->has_mac_address
) {
665 _cleanup_free_
char *description
= NULL
;
666 char ea
[ETHER_ADDR_TO_STRING_MAX
];
668 ieee_oui(hwdb
, &info
->mac_address
, &description
);
671 printf(" HW Address: %s (%s)\n", ether_addr_to_string(&info
->mac_address
, ea
), description
);
673 printf(" HW Address: %s\n", ether_addr_to_string(&info
->mac_address
, ea
));
677 printf(" MTU: %u\n", info
->mtu
);
679 dump_addresses(rtnl
, " Address: ", info
->ifindex
);
680 dump_gateways(rtnl
, hwdb
, " Gateway: ", info
->ifindex
);
682 dump_list(" DNS: ", dns
);
683 dump_list(" Search Domains: ", search_domains
);
684 dump_list(" Route Domains: ", route_domains
);
686 dump_list(" NTP: ", ntp
);
688 dump_list("Carrier Bound To: ", carrier_bound_to
);
689 dump_list("Carrier Bound By: ", carrier_bound_by
);
691 (void) sd_network_link_get_timezone(info
->ifindex
, &tz
);
693 printf(" Time Zone: %s", tz
);
698 static int system_status(sd_netlink
*rtnl
, sd_hwdb
*hwdb
) {
699 _cleanup_free_
char *operational_state
= NULL
;
700 _cleanup_strv_free_
char **dns
= NULL
, **ntp
= NULL
, **search_domains
= NULL
, **route_domains
= NULL
;
701 const char *on_color_operational
, *off_color_operational
;
705 sd_network_get_operational_state(&operational_state
);
706 operational_state_to_color(operational_state
, &on_color_operational
, &off_color_operational
);
708 printf("%s%s%s State: %s%s%s\n",
709 on_color_operational
, draw_special_char(DRAW_BLACK_CIRCLE
), off_color_operational
,
710 on_color_operational
, strna(operational_state
), off_color_operational
);
712 dump_addresses(rtnl
, " Address: ", 0);
713 dump_gateways(rtnl
, hwdb
, " Gateway: ", 0);
715 sd_network_get_dns(&dns
);
716 dump_list(" DNS: ", dns
);
718 sd_network_get_search_domains(&search_domains
);
719 dump_list("Search Domains: ", search_domains
);
721 sd_network_get_route_domains(&route_domains
);
722 dump_list(" Route Domains: ", route_domains
);
724 sd_network_get_ntp(&ntp
);
725 dump_list(" NTP: ", ntp
);
730 static int link_status(int argc
, char *argv
[], void *userdata
) {
731 _cleanup_(sd_netlink_unrefp
) sd_netlink
*rtnl
= NULL
;
732 _cleanup_(sd_hwdb_unrefp
) sd_hwdb
*hwdb
= NULL
;
733 _cleanup_free_ LinkInfo
*links
= NULL
;
736 pager_open_if_enabled();
738 r
= sd_netlink_open(&rtnl
);
740 return log_error_errno(r
, "Failed to connect to netlink: %m");
742 r
= sd_hwdb_new(&hwdb
);
744 log_debug_errno(r
, "Failed to open hardware database: %m");
747 c
= acquire_link_info_all(rtnl
, &links
);
749 return system_status(rtnl
, hwdb
);
751 c
= acquire_link_info_strv(rtnl
, argv
+ 1, &links
);
755 for (i
= 0; i
< c
; i
++) {
759 link_status_one(rtnl
, hwdb
, links
+ i
);
765 static char *lldp_capabilities_to_string(uint16_t x
) {
766 static const char characters
[] = {
767 'o', 'p', 'b', 'w', 'r', 't', 'd', 'a', 'c', 's', 'm',
772 ret
= new(char, ELEMENTSOF(characters
) + 1);
776 for (i
= 0; i
< ELEMENTSOF(characters
); i
++)
777 ret
[i
] = (x
& (1U << i
)) ? characters
[i
] : '.';
783 static int link_lldp_status(int argc
, char *argv
[], void *userdata
) {
784 _cleanup_(sd_netlink_unrefp
) sd_netlink
*rtnl
= NULL
;
785 _cleanup_free_ LinkInfo
*links
= NULL
;
788 r
= sd_netlink_open(&rtnl
);
790 return log_error_errno(r
, "Failed to connect to netlink: %m");
793 c
= acquire_link_info_strv(rtnl
, argv
+ 1, &links
);
795 c
= acquire_link_info_all(rtnl
, &links
);
799 pager_open_if_enabled();
802 printf("%-16s %-17s %-16s %-11s %-17s %-16s\n",
810 for (i
= 0; i
< c
; i
++) {
811 _cleanup_fclose_
FILE *f
= NULL
;
812 _cleanup_free_
char *p
= NULL
;
814 if (asprintf(&p
, "/run/systemd/netif/lldp/%i", links
[i
].ifindex
) < 0)
822 log_warning_errno(errno
, "Failed to open %s, ignoring: %m", p
);
827 const char *chassis_id
= NULL
, *port_id
= NULL
, *system_name
= NULL
, *port_description
= NULL
, *capabilities
= NULL
;
828 _cleanup_(sd_lldp_neighbor_unrefp
) sd_lldp_neighbor
*n
= NULL
;
829 _cleanup_free_
void *raw
= NULL
;
834 l
= fread(&u
, 1, sizeof(u
), f
);
835 if (l
== 0 && feof(f
)) /* EOF */
837 if (l
!= sizeof(u
)) {
838 log_warning("Premature end of file, ignoring.");
842 raw
= new(uint8_t, le64toh(u
));
846 if (fread(raw
, 1, le64toh(u
), f
) != le64toh(u
)) {
847 log_warning("Premature end of file, ignoring.");
851 r
= sd_lldp_neighbor_from_raw(&n
, raw
, le64toh(u
));
853 log_warning_errno(r
, "Failed to parse LLDP data, ignoring: %m");
857 (void) sd_lldp_neighbor_get_chassis_id_as_string(n
, &chassis_id
);
858 (void) sd_lldp_neighbor_get_port_id_as_string(n
, &port_id
);
859 (void) sd_lldp_neighbor_get_system_name(n
, &system_name
);
860 (void) sd_lldp_neighbor_get_port_description(n
, &port_description
);
862 if (sd_lldp_neighbor_get_enabled_capabilities(n
, &cc
) >= 0)
863 capabilities
= lldp_capabilities_to_string(cc
);
865 printf("%-16s %-17s %-16s %-11s %-17s %-16s\n",
871 strna(port_description
));
878 printf("\nCapability Flags:\n"
879 "o - Other; p - Repeater; b - Bridge; w - WLAN Access Point; r - Router;\n"
880 "t - Telephone; d - DOCSIS cable device; a - Station; c - Customer VLAN;\n"
881 "s - Service VLAN, m - Two-port MAC Relay (TPMR)\n\n"
882 "%i neighbors listed.\n", m
);
887 static void help(void) {
888 printf("%s [OPTIONS...]\n\n"
889 "Query and control the networking subsystem.\n\n"
890 " -h --help Show this help\n"
891 " --version Show package version\n"
892 " --no-pager Do not pipe output into a pager\n"
893 " --no-legend Do not show the headers and footers\n"
894 " -a --all Show status for all links\n\n"
896 " list [LINK...] List links\n"
897 " status [LINK...] Show link status\n"
898 " lldp [LINK...] Show lldp neighbors\n"
899 , program_invocation_short_name
);
902 static int parse_argv(int argc
, char *argv
[]) {
910 static const struct option options
[] = {
911 { "help", no_argument
, NULL
, 'h' },
912 { "version", no_argument
, NULL
, ARG_VERSION
},
913 { "no-pager", no_argument
, NULL
, ARG_NO_PAGER
},
914 { "no-legend", no_argument
, NULL
, ARG_NO_LEGEND
},
915 { "all", no_argument
, NULL
, 'a' },
924 while ((c
= getopt_long(argc
, argv
, "ha", options
, NULL
)) >= 0) {
951 assert_not_reached("Unhandled option");
958 static int networkctl_main(int argc
, char *argv
[]) {
959 const Verb verbs
[] = {
960 { "list", VERB_ANY
, VERB_ANY
, VERB_DEFAULT
, list_links
},
961 { "status", VERB_ANY
, VERB_ANY
, 0, link_status
},
962 { "lldp", VERB_ANY
, VERB_ANY
, 0, link_lldp_status
},
966 return dispatch_verb(argc
, argv
, verbs
, NULL
);
969 int main(int argc
, char* argv
[]) {
972 log_parse_environment();
975 r
= parse_argv(argc
, argv
);
979 r
= networkctl_main(argc
, argv
);
984 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;