diff options
author | Hangbin Liu <liuhangbin@gmail.com> | 2019-06-12 17:21:15 +0800 |
---|---|---|
committer | David Ahern <dsahern@gmail.com> | 2019-06-18 08:37:47 -0700 |
commit | ca697cee4cfcb8b0f82b328a8b51ca94ffad0103 (patch) | |
tree | 9763e982f74e7438f49738604dae685f79ab51cf /misc/ss.c | |
parent | e92d221022b56ad78a831d360c6db8faaec10d30 (diff) | |
download | iproute2-ca697cee4cfcb8b0f82b328a8b51ca94ffad0103.tar.gz |
ip: add a new parameter -Numeric
Add a new parameter '-Numeric' to show the number of protocol, scope,
dsfield, etc directly instead of converting it to human readable name.
Do the same on tc and ss.
This patch is based on David Ahern's previous patch.
Suggested-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Diffstat (limited to 'misc/ss.c')
-rw-r--r-- | misc/ss.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -106,7 +106,6 @@ static int security_get_initial_context(char *name, char **context) } #endif -static int resolve_services = 1; int preferred_family = AF_UNSPEC; static int show_options; int show_details; @@ -121,6 +120,7 @@ static int follow_events; static int sctp_ino; static int show_tipcinfo; static int show_tos; +int numeric; int oneline; enum col_id { @@ -1553,7 +1553,7 @@ static const char *resolve_service(int port) return buf; } - if (!resolve_services) + if (numeric) goto do_numeric; if (dg_proto == RAW_PROTO) @@ -4296,14 +4296,11 @@ static int netlink_show_one(struct filter *f, sock_state_print(&st); - if (resolve_services) - prot_name = nl_proto_n2a(prot, prot_buf, sizeof(prot_buf)); - else - prot_name = int_to_str(prot, prot_buf); + prot_name = nl_proto_n2a(prot, prot_buf, sizeof(prot_buf)); if (pid == -1) { procname[0] = '*'; - } else if (resolve_services) { + } else if (!numeric) { int done = 0; if (!pid) { @@ -5050,7 +5047,7 @@ int main(int argc, char *argv[]) long_opts, NULL)) != EOF) { switch (ch) { case 'n': - resolve_services = 0; + numeric = 1; break; case 'r': resolve_hosts = 1; @@ -5268,7 +5265,7 @@ int main(int argc, char *argv[]) filter_states_set(¤t_filter, state_filter); filter_merge_defaults(¤t_filter); - if (resolve_services && resolve_hosts && + if (!numeric && resolve_hosts && (current_filter.dbs & (UNIX_DBM|INET_L4_DBM))) init_service_resolver(); |