Skip to contentSkip to conversation

phy: sync cca handling with mainline

PATCH New Alexander Aring 1 participant 1 message Dec 11, 2014 IEEE 802.15.4

lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

PATCH 1/1 phy: sync cca handling with mainline

This patch updates the nl802154 header with current mainline and making changes according to cca current mainline handling.

---
 src/info.c     | 23 +++++++++++------
 src/nl802154.h | 78 ++++++++++++++++++++++++++++++++++++++++++++--------------
 src/phy.c      | 14 ++++++-----
 3 files changed, 84 insertions(+), 31 deletions(-)
src/info.c +16 -7
index 50a7bba..83f2e3e 100644
@@ -20,7 +20,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 	int64_t phy_id = -1;
 	bool print_name = true;
 	struct nlattr *nl_page;
-	unsigned long cca_mode;
+	enum nl802154_cca_modes cca_mode;
 
 	nla_parse(tb_msg, NL802154_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
 		  genlmsg_attrlen(gnlh, 0), NULL);
@@ -62,13 +62,22 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 		printf("current_channel: %d\n", nla_get_u8(tb_msg[NL802154_ATTR_CHANNEL]));
 
 	if (tb_msg[NL802154_ATTR_CCA_MODE]) {
-		cca_mode = nla_get_u8(tb_msg[NL802154_ATTR_CCA_MODE]);
+		cca_mode = nla_get_u32(tb_msg[NL802154_ATTR_CCA_MODE]);
 		printf("cca_mode: %d", cca_mode);
-		if (cca_mode == 3) {
-			if (nla_get_u8(tb_msg[NL802154_ATTR_CCA_MODE3_AND]))
-				printf(" AND ");
-			else
-				printf(" OR ");
+		if (cca_mode == NL802154_CCA_ENERGY_CARRIER) {
+			enum nl802154_cca_opts cca_opt;
+
+			cca_opt = nla_get_u32(tb_msg[NL802154_ATTR_CCA_OPT]);
+			switch (cca_opt) {
+			case NL802154_CCA_OPT_ENERGY_CARRIER_AND:
+				printf(" logical and ");
+				break;
+			case NL802154_CCA_OPT_ENERGY_CARRIER_OR:
+				printf(" logical or ");
+				break;
+			default:
+				printf(" logical op mode unkown ");
+			}
 		}
 		printf("\n");
 	}
src/nl802154.h +60 -18

103 lines not on this page · raw message

src/phy.c +8 -6
index 8379786..2e25013 100644
@@ -80,7 +80,7 @@ static int handle_cca_mode_set(struct nl802154_state *state,
 			       int argc, char **argv,
 			       enum id_input id)
 {
-	unsigned long cca_mode, cca_mode3_and;
+	enum nl802154_cca_modes cca_mode;
 	char *end;
 
 	if (argc < 1)
@@ -91,19 +91,21 @@ static int handle_cca_mode_set(struct nl802154_state *state,
 	if (*end != '\0')
 		return 1;
 
-	if (cca_mode == 3) {
+	if (cca_mode == NL802154_CCA_ENERGY_CARRIER) {
+		enum nl802154_cca_opts cca_opt;
+
 		if (argc < 2)
 			return 1;
 
-		/* CCA_MODE */
-		cca_mode3_and = strtoul(argv[1], &end, 10);
+		/* CCA_OPT */
+		cca_opt = strtoul(argv[1], &end, 10);
 		if (*end != '\0')
 			return 1;
 
-		NLA_PUT_U8(msg, NL802154_ATTR_CCA_MODE3_AND, cca_mode3_and);
+		NLA_PUT_U32(msg, NL802154_ATTR_CCA_OPT, cca_opt);
 	}
 
-	NLA_PUT_U8(msg, NL802154_ATTR_CCA_MODE, cca_mode);
+	NLA_PUT_U32(msg, NL802154_ATTR_CCA_MODE, cca_mode);
 
 	return 0;
 
Signature · 1 line
2.1.3