mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-11-06 23:20:15 +00:00
This adds support for slightly less output than is normally provided by 'ip link show' and 'ip addr show'. This is a bit better when you have a host with lots of interfaces. Sample output: $ ip -br link show lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP> p2p1 UP 08:00:27:ee:0b:3b <BROADCAST,MULTICAST,UP,LOWER_UP> p7p1 UP 08:00:27:9d:62:9f <BROADCAST,MULTICAST,UP,LOWER_UP> p8p1 DOWN 08:00:27:dc:d8:ca <NO-CARRIER,BROADCAST,MULTICAST,UP> p9p1 UP 08:00:27:76:d9:75 <BROADCAST,MULTICAST,UP,LOWER_UP> p7p1.100@p7p1 UP 08:00:27:9d:62:9f <BROADCAST,MULTICAST,UP,LOWER_UP> $ ip -br -4 addr show lo UNKNOWN 127.0.0.1/8 p2p1 UP 192.168.56.2/24 p7p1 UP 70.0.0.1/24 p8p1 DOWN 80.0.0.1/24 p9p1 UP 10.0.5.15/24 p7p1.100@p7p1 UP 200.0.0.1/24 $ ip -br -6 addr show lo UNKNOWN ::1/128 p2p1 UP fe80::a00:27ff:feee:b3b/64 p7p1 UP 7000::1/8 fe80::a00:27ff:fe9d:629f/64 p8p1 DOWN 8000::1/8 p9p1 UP fe80::a00:27ff:fe76:d975/64 p7p1.100@p7p1 UP fe80::a00:27ff:fe9d:629f/64 $ ip -br addr show p7p1 p7p1 UP 70.0.0.1/24 7000::1/8 fe80::a00:27ff:fe9d:629f/64 v2: Now with color support! v3: Better field width estimation (except netdev names to keep output at a decent width) and whitespace fixup. Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
101 lines
3.6 KiB
C
101 lines
3.6 KiB
C
extern int get_operstate(const char *name);
|
|
extern int print_linkinfo(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n,
|
|
void *arg);
|
|
extern int print_linkinfo_brief(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n,
|
|
void *arg);
|
|
extern int print_addrinfo(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n,
|
|
void *arg);
|
|
extern int print_addrlabel(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_neigh(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_ntable(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int ipaddr_list(int argc, char **argv);
|
|
extern int ipaddr_list_link(int argc, char **argv);
|
|
void ipaddr_get_vf_rate(int, int *, int *, int);
|
|
extern int iproute_monitor(int argc, char **argv);
|
|
extern void iplink_usage(void) __attribute__((noreturn));
|
|
|
|
extern void iproute_reset_filter(int ifindex);
|
|
extern void ipmroute_reset_filter(int ifindex);
|
|
extern void ipaddr_reset_filter(int oneline, int ifindex);
|
|
extern void ipneigh_reset_filter(int ifindex);
|
|
extern void ipntable_reset_filter(void);
|
|
extern void ipnetconf_reset_filter(int ifindex);
|
|
|
|
extern int print_route(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_mroute(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_prefix(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_rule(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_netconf(const struct sockaddr_nl *who,
|
|
struct rtnl_ctrl_data *ctrl,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern void netns_map_init(void);
|
|
extern int print_nsid(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int do_ipaddr(int argc, char **argv);
|
|
extern int do_ipaddrlabel(int argc, char **argv);
|
|
extern int do_iproute(int argc, char **argv);
|
|
extern int do_iprule(int argc, char **argv);
|
|
extern int do_ipneigh(int argc, char **argv);
|
|
extern int do_ipntable(int argc, char **argv);
|
|
extern int do_iptunnel(int argc, char **argv);
|
|
extern int do_ip6tunnel(int argc, char **argv);
|
|
extern int do_iptuntap(int argc, char **argv);
|
|
extern int do_iplink(int argc, char **argv);
|
|
extern int do_ipmonitor(int argc, char **argv);
|
|
extern int do_multiaddr(int argc, char **argv);
|
|
extern int do_multiroute(int argc, char **argv);
|
|
extern int do_multirule(int argc, char **argv);
|
|
extern int do_netns(int argc, char **argv);
|
|
extern int do_xfrm(int argc, char **argv);
|
|
extern int do_ipl2tp(int argc, char **argv);
|
|
extern int do_ipfou(int argc, char **argv);
|
|
extern int do_tcp_metrics(int argc, char **argv);
|
|
extern int do_ipnetconf(int argc, char **argv);
|
|
extern int do_iptoken(int argc, char **argv);
|
|
extern int iplink_get(unsigned int flags, char *name, __u32 filt_mask);
|
|
|
|
static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb)
|
|
{
|
|
__u32 table = r->rtm_table;
|
|
if (tb[RTA_TABLE])
|
|
table = rta_getattr_u32(tb[RTA_TABLE]);
|
|
return table;
|
|
}
|
|
|
|
extern struct rtnl_handle rth;
|
|
|
|
#include <stdbool.h>
|
|
|
|
struct link_util
|
|
{
|
|
struct link_util *next;
|
|
const char *id;
|
|
int maxattr;
|
|
int (*parse_opt)(struct link_util *, int, char **,
|
|
struct nlmsghdr *);
|
|
void (*print_opt)(struct link_util *, FILE *,
|
|
struct rtattr *[]);
|
|
void (*print_xstats)(struct link_util *, FILE *,
|
|
struct rtattr *);
|
|
void (*print_help)(struct link_util *, int, char **,
|
|
FILE *);
|
|
bool slave;
|
|
};
|
|
|
|
struct link_util *get_link_kind(const char *kind);
|
|
struct link_util *get_link_slave_kind(const char *slave_kind);
|
|
|
|
#ifndef INFINITY_LIFE_TIME
|
|
#define INFINITY_LIFE_TIME 0xFFFFFFFFU
|
|
#endif
|