Skip to contentSkip to conversation

treewide: shorten commands

PATCH In review Alexander Aring 2 participants 6 messages Jan 20, 2015 IEEE 802.15.4

lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

PATCH 1/2 treewide: shorten commands

This patch shorten all commands. I had the idea to make a similarity from PIB/MIB values according the 802.15.4 names convention but this is bad for fast shell hacking. Mainly I remove the underscore and some additional information which are not necessary like "_addr" in "short_addr" and "extended_addr" and such things.

---
 src/info.c      | 10 +++++-----
 src/interface.c | 20 ++++++++++----------
 src/mac.c       | 10 +++++-----
 src/phy.c       |  6 +++---
 4 files changed, 23 insertions(+), 23 deletions(-)
src/info.c +5 -5
index 83f2e3e..6ce4715 100644
@@ -31,7 +31,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 		phy_id = nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]);
 	}
 	if (print_name && tb_msg[NL802154_ATTR_WPAN_PHY_NAME])
-		printf("wpan_phy %s\n", nla_get_string(tb_msg[NL802154_ATTR_WPAN_PHY_NAME]));
+		printf("WPANphy %s\n", nla_get_string(tb_msg[NL802154_ATTR_WPAN_PHY_NAME]));
 
 	if (tb_msg[NL802154_ATTR_CHANNELS_SUPPORTED]) {
 		unsigned char page = 0;
@@ -56,14 +56,14 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 	}
 
 	if (tb_msg[NL802154_ATTR_PAGE])
-		printf("current_page: %d\n", nla_get_u8(tb_msg[NL802154_ATTR_PAGE]));
+		printf("page: %d\n", nla_get_u8(tb_msg[NL802154_ATTR_PAGE]));
 
 	if (tb_msg[NL802154_ATTR_CHANNEL])
-		printf("current_channel: %d\n", nla_get_u8(tb_msg[NL802154_ATTR_CHANNEL]));
+		printf("channel: %d\n", nla_get_u8(tb_msg[NL802154_ATTR_CHANNEL]));
 
 	if (tb_msg[NL802154_ATTR_CCA_MODE]) {
 		cca_mode = nla_get_u32(tb_msg[NL802154_ATTR_CCA_MODE]);
-		printf("cca_mode: %d", cca_mode);
+		printf("cca: %d", cca_mode);
 		if (cca_mode == NL802154_CCA_ENERGY_CARRIER) {
 			enum nl802154_cca_opts cca_opt;
 
@@ -83,7 +83,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 	}
 
 	if (tb_msg[NL802154_ATTR_TX_POWER])
-		printf("tx_power: %d\n", nla_get_s8(tb_msg[NL802154_ATTR_TX_POWER]));
+		printf("txpower: %d\n", nla_get_s8(tb_msg[NL802154_ATTR_TX_POWER]));
 
 	return 0;
 }
src/interface.c +10 -10
index 095753b..9e59f15 100644
@@ -187,7 +187,7 @@ static int print_iface_handler(struct nl_msg *msg, void *arg)
 		unsigned int thiswpan_phy = nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]);
 		indent = "\t";
 		if (*wpan_phy != thiswpan_phy)
-			printf("phy#%d\n", thiswpan_phy);
+			printf("WPANphy#%d\n", thiswpan_phy);
 		*wpan_phy = thiswpan_phy;
 	}
 
@@ -199,29 +199,29 @@ static int print_iface_handler(struct nl_msg *msg, void *arg)
 	if (tb_msg[NL802154_ATTR_IFINDEX])
 		printf("%s\tifindex %d\n", indent, nla_get_u32(tb_msg[NL802154_ATTR_IFINDEX]));
 	if (tb_msg[NL802154_ATTR_WPAN_DEV])
-		printf("%s\twpan_dev 0x%llx\n", indent,
+		printf("%s\tWPANdev 0x%llx\n", indent,
 		       (unsigned long long)nla_get_u64(tb_msg[NL802154_ATTR_WPAN_DEV]));
 	if (tb_msg[NL802154_ATTR_EXTENDED_ADDR])
-		printf("%s\textended_addr 0x%016llx\n", indent,
+		printf("%s\textended 0x%016llx\n", indent,
 		       le64toh(nla_get_u64(tb_msg[NL802154_ATTR_EXTENDED_ADDR])));
 	if (tb_msg[NL802154_ATTR_SHORT_ADDR])
-		printf("%s\tshort_addr 0x%04x\n", indent,
+		printf("%s\tshort 0x%04x\n", indent,
 		       le16toh(nla_get_u16(tb_msg[NL802154_ATTR_SHORT_ADDR])));
 	if (tb_msg[NL802154_ATTR_PAN_ID])
-		printf("%s\tpan_id 0x%04x\n", indent,
+		printf("%s\tpan 0x%04x\n", indent,
 		       le16toh(nla_get_u16(tb_msg[NL802154_ATTR_PAN_ID])));
 	if (tb_msg[NL802154_ATTR_IFTYPE])
 		printf("%s\ttype %s\n", indent, iftype_name(nla_get_u32(tb_msg[NL802154_ATTR_IFTYPE])));
 	if (!wpan_phy && tb_msg[NL802154_ATTR_WPAN_PHY])
-		printf("%s\twpan_phy %d\n", indent, nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]));
+		printf("%s\tWPANphy %d\n", indent, nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]));
 	if (tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES])
-		printf("%s\tmax_frame_retries %d\n", indent, nla_get_s8(tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES]));
+		printf("%s\tframeretries %d\n", indent, nla_get_s8(tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES]));
 	if (tb_msg[NL802154_ATTR_MIN_BE])
-		printf("%s\tmin_be %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MIN_BE]));
+		printf("%s\tminBE %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MIN_BE]));
 	if (tb_msg[NL802154_ATTR_MAX_BE])
-		printf("%s\tmax_be %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MAX_BE]));
+		printf("%s\tmaxBE %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MAX_BE]));
 	if (tb_msg[NL802154_ATTR_MAX_CSMA_BACKOFFS])
-		printf("%s\tmax_csma_backoffs %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MAX_CSMA_BACKOFFS]));
+		printf("%s\tcsmabackoffs %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MAX_CSMA_BACKOFFS]));
 	if (tb_msg[NL802154_ATTR_LBT_MODE])
 		printf("%s\tlbt %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_LBT_MODE]));
 
src/mac.c +5 -5
index 703d09f..79d088b 100644
@@ -37,7 +37,7 @@ static int handle_pan_id_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, pan_id, "<pan_id>",
+COMMAND(set, pan, "<panid>",
 	NL802154_CMD_SET_PAN_ID, 0, CIB_NETDEV, handle_pan_id_set, NULL);
 
 static int handle_short_addr_set(struct nl802154_state *state,
@@ -64,7 +64,7 @@ static int handle_short_addr_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, short_addr, "<short_addr>",
+COMMAND(set, short, "<addr>",
 	NL802154_CMD_SET_SHORT_ADDR, 0, CIB_NETDEV, handle_short_addr_set, NULL);
 
 static int handle_max_frame_retries_set(struct nl802154_state *state,
@@ -91,7 +91,7 @@ static int handle_max_frame_retries_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, max_frame_retries, "<retries>",
+COMMAND(set, frameretries, "<retries>",
 	NL802154_CMD_SET_MAX_FRAME_RETRIES, 0, CIB_NETDEV,
 	handle_max_frame_retries_set, NULL);
 
@@ -126,7 +126,7 @@ static int handle_backoff_exponent(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, backoff_exponents, "<min_be> <max_be>",
+COMMAND(set, backoffexponents, "<minBE> <maxBE>",
 	NL802154_CMD_SET_BACKOFF_EXPONENT, 0, CIB_NETDEV,
 	handle_backoff_exponent, NULL);
 
@@ -154,7 +154,7 @@ static int handle_max_csma_backoffs(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, max_csma_backoffs, "<backoffs>",
+COMMAND(set, csmabackoffs, "<backoffs>",
 	NL802154_CMD_SET_MAX_CSMA_BACKOFFS, 0, CIB_NETDEV,
 	handle_max_csma_backoffs, NULL);
 
src/phy.c +3 -3
index 2e25013..994841f 100644
@@ -71,7 +71,7 @@ static int handle_tx_power_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, tx_power, "<dBm>",
+COMMAND(set, txpower, "<dBm>",
 	NL802154_CMD_SET_TX_POWER, 0, CIB_PHY, handle_tx_power_set, NULL);
 
 static int handle_cca_mode_set(struct nl802154_state *state,
@@ -112,7 +112,7 @@ static int handle_cca_mode_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, cca_mode, "<mode|3 <1|0>>",
+COMMAND(set, cca, "<mode|3 <1|0>>",
 	NL802154_CMD_SET_CCA_MODE, 0, CIB_PHY, handle_cca_mode_set, NULL);
 
 static int handle_cca_ed_level(struct nl802154_state *state,
@@ -139,5 +139,5 @@ static int handle_cca_ed_level(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, cca_ed_level, "<level>",
+COMMAND(set, edlevel, "<level>",
 	NL802154_CMD_SET_CCA_ED_LEVEL, 0, CIB_PHY, handle_cca_ed_level, NULL);
Signature · 1 line
2.2.2
author maintainer
#1 lore raw

PATCH 2/2 interface: remove twice phy information

The phy information is already shown in a previous printout and this code seems that it was never be functional.

---
 src/interface.c | 2 --
 1 file changed, 2 deletions(-)
src/interface.c +0 -2
index 9e59f15..559a104 100644
@@ -212,8 +212,6 @@ static int print_iface_handler(struct nl_msg *msg, void *arg)
 		       le16toh(nla_get_u16(tb_msg[NL802154_ATTR_PAN_ID])));
 	if (tb_msg[NL802154_ATTR_IFTYPE])
 		printf("%s\ttype %s\n", indent, iftype_name(nla_get_u32(tb_msg[NL802154_ATTR_IFTYPE])));
-	if (!wpan_phy && tb_msg[NL802154_ATTR_WPAN_PHY])
-		printf("%s\tWPANphy %d\n", indent, nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]));
 	if (tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES])
 		printf("%s\tframeretries %d\n", indent, nla_get_s8(tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES]));
 	if (tb_msg[NL802154_ATTR_MIN_BE])
Signature · 1 line
2.2.2
#2 lore raw
In reply to Alexander Aring

Hello.

Quoted 6 lines · Alexander Aring

This patch shorten all commands. I had the idea to make a similarity from PIB/MIB values according the 802.15.4 names convention but this is bad for fast shell hacking. Mainly I remove the underscore and some additional information which are not necessary like "_addr" in "short_addr" and "extended_addr" and such things.

Quoted 7 lines
---
  src/info.c      | 10 +++++-----
  src/interface.c | 20 ++++++++++----------
  src/mac.c       | 10 +++++-----
  src/phy.c       |  6 +++---
  4 files changed, 23 insertions(+), 23 deletions(-)

Hmm, it feels like you are going overboard with shorting things here. Why is the reason behind it? Just less typing? Shell auto completion would handle this. :)

I mean it is up to you but with this you might break scripts that are already out there and I think the current commands are quite fine. Cutting out the underscores makes some of these hard to read imho.

regards
Stefan Schmidt

author maintainer
#3 lore raw
Quoted 17 lines · Stefan Schmidt

Hello.

Quoted 6 lines · Alexander Aring

This patch shorten all commands. I had the idea to make a similarity from PIB/MIB values according the 802.15.4 names convention but this is bad for fast shell hacking. Mainly I remove the underscore and some additional information which are not necessary like "_addr" in "short_addr" and "extended_addr" and such things.

Quoted 7 lines
---
 src/info.c      | 10 +++++-----
 src/interface.c | 20 ++++++++++----------
 src/mac.c       | 10 +++++-----
 src/phy.c       |  6 +++---
 4 files changed, 23 insertions(+), 23 deletions(-)
Quoted 4 lines

Hmm, it feels like you are going overboard with shorting things here. Why is the reason behind it? Just less typing? Shell auto completion would handle this. :)

it's just less typing and I notice that the original iw command doesn't have an underscore in their commands.

The first time when I hacked it, then I just took the same naming convention in kernel implementation which use the naming convention from 802.15.4 standard (without the beginning "MAC" and "PHY" keywords). Now I am too lazy to always type pan_id short_addr, etc...

Do you like to implement some completion stuff which can be shipped out optionally with the wpan-tools? :-)

Quoted 4 lines

I mean it is up to you but with this you might break scripts that are already out there and I think the current commands are quite fine. Cutting out the underscores makes some of these hard to read imho.

mhhh, I am unsure also about this and just gave it a try if somebody screams I would maybe reconsider this patch. :-)

- Alex

author maintainer
#4 lore raw
Quoted 34 lines · Alexander Aring
Quoted 17 lines · Stefan Schmidt

Hello.

Quoted 6 lines · Alexander Aring

This patch shorten all commands. I had the idea to make a similarity from PIB/MIB values according the 802.15.4 names convention but this is bad for fast shell hacking. Mainly I remove the underscore and some additional information which are not necessary like "_addr" in "short_addr" and "extended_addr" and such things.

Quoted 7 lines
---
 src/info.c      | 10 +++++-----
 src/interface.c | 20 ++++++++++----------
 src/mac.c       | 10 +++++-----
 src/phy.c       |  6 +++---
 4 files changed, 23 insertions(+), 23 deletions(-)
Quoted 4 lines

Hmm, it feels like you are going overboard with shorting things here. Why is the reason behind it? Just less typing? Shell auto completion would handle this. :)

it's just less typing and I notice that the original iw command doesn't have an underscore in their commands.

The first time when I hacked it, then I just took the same naming convention in kernel implementation which use the naming convention from 802.15.4 standard (without the beginning "MAC" and "PHY" keywords). Now I am too lazy to always type pan_id short_addr, etc...

Do you like to implement some completion stuff which can be shipped out optionally with the wpan-tools? :-)

Quoted 8 lines
Quoted 4 lines

I mean it is up to you but with this you might break scripts that are already out there and I think the current commands are quite fine. Cutting out the underscores makes some of these hard to read imho.

mhhh, I am unsure also about this and just gave it a try if somebody screams I would maybe reconsider this patch. :-)

ok. I will drop this patch. Will resend the second patch later.

- Alex

#5 lore raw
In reply to Alexander Aring

Hello.

Quoted 24 lines · Alexander Aring
Quoted 17 lines · Stefan Schmidt

Hello.

Quoted 6 lines · Alexander Aring

This patch shorten all commands. I had the idea to make a similarity from PIB/MIB values according the 802.15.4 names convention but this is bad for fast shell hacking. Mainly I remove the underscore and some additional information which are not necessary like "_addr" in "short_addr" and "extended_addr" and such things.

Quoted 7 lines
---
  src/info.c      | 10 +++++-----
  src/interface.c | 20 ++++++++++----------
  src/mac.c       | 10 +++++-----
  src/phy.c       |  6 +++---
  4 files changed, 23 insertions(+), 23 deletions(-)
Quoted 5 lines

Hmm, it feels like you are going overboard with shorting things here. Why is
the reason behind it? Just less typing? Shell auto completion would handle this. :)

Quoted 6 lines

it's just less typing and I notice that the original iw command doesn't have an underscore in their commands.

The first time when I hacked it, then I just took the same naming convention in kernel implementation which use the naming convention from 802.15.4 standard (without the beginning "MAC" and "PHY" keywords).

Having the naming the same in specs, kernel and the config util is actually good thing. This helps newcomers to understand them more easily.

Quoted 1 line

Now I am too lazy to always type pan_id short_addr, etc...

If the primary goal would be less typing the the binary should be named "i" and the options a, b, c, d :)

Quoted 2 lines

Do you like to implement some completion stuff which can be shipped out optionally with the wpan-tools? :-)

Here is a start:
_iwpan()

{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="--debug --version phy dev set channel tx_power cca_mode 

cca_ed_level pan_id short_addr max_frame_retries backoff_exponents max_csma_backoffs lbt info list interface add"

    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    return 0
}

complete -F _iwpan iwpan

Just drop this in a file called iwpan in /etc/bash_completion.d/ and a simple command completion would work with bash. zsh user might want to do their own.

This has no fancy things like completing available wpan interfaces, etc but it completes all commands which was what you complained about for typing. :)

regards
Stefan Schmidt