show channels and allow setting frequency by channel
diff --git a/phy.c b/phy.c
index 98de1fc..45d4e78 100644
--- a/phy.c
+++ b/phy.c
@@ -1,3 +1,4 @@
+#include <stdbool.h>
 #include <errno.h>
 #include <net/if.h>
 
@@ -25,8 +26,8 @@
 }
 COMMAND(set, name, "<new name>", NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_name);
 
-static int handle_freq(struct nl_cb *cb, struct nl_msg *msg,
-		       int argc, char **argv)
+static int handle_freqchan(struct nl_msg *msg, bool chan,
+			   int argc, char **argv)
 {
 	static const struct {
 		const char *name;
@@ -55,6 +56,8 @@
 	}
 
 	freq = strtoul(argv[0], NULL, 10);
+	if (chan)
+		freq = ieee80211_channel_to_frequency(freq);
 
 	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
 	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_SEC_CHAN_OFFSET, htval);
@@ -63,7 +66,23 @@
  nla_put_failure:
 	return -ENOBUFS;
 }
+
+static int handle_freq(struct nl_cb *cb, struct nl_msg *msg,
+		       int argc, char **argv)
+{
+	return handle_freqchan(msg, false, argc, argv);
+}
 COMMAND(set, freq, "<freq> [HT20|HT40+|HT40-]",
 	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_freq);
 COMMAND(set, freq, "<freq> [HT20|HT40+|HT40-]",
 	NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_freq);
+
+static int handle_chan(struct nl_cb *cb, struct nl_msg *msg,
+		       int argc, char **argv)
+{
+	return handle_freqchan(msg, true, argc, argv);
+}
+COMMAND(set, channel, "<channel> [HT20|HT40+|HT40-]",
+	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_chan);
+COMMAND(set, channel, "<channel> [HT20|HT40+|HT40-]",
+	NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_chan);