lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190128161306.27805-10-ben.whitten@lairdtech.com>
Date:   Mon, 28 Jan 2019 16:13:03 +0000
From:   Ben Whitten <ben.whitten@...il.com>
To:     afaerber@...e.de
Cc:     linux-lpwan@...ts.infradead.org,
        Ben Whitten <ben.whitten@...rdtech.com>,
        "David S. Miller" <davem@...emloft.net>,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH lora-next 09/11] net: lora: introduce lora socket addressing for metadata

Information such as spreading factor, coding rate and power are on a per
transmission basis so we can encode this information in the lora socket
address.
In future we may have a different format for receive with additional
fields which get populated.

Signed-off-by: Ben Whitten <ben.whitten@...rdtech.com>
---
 include/linux/lora/skb.h  |  9 ++++++++
 include/uapi/linux/lora.h | 14 ++++++++++++
 net/lora/dgram.c          | 45 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)

diff --git a/include/linux/lora/skb.h b/include/linux/lora/skb.h
index 8806741464d0..6abeb39b8b7f 100644
--- a/include/linux/lora/skb.h
+++ b/include/linux/lora/skb.h
@@ -12,6 +12,15 @@
 
 struct lora_skb_priv {
 	int ifindex;
+
+	u64 freq;
+	u8 sf;
+	u8 cr;
+	u16 bw;
+
+	u8 sync;
+
+	s8 power;
 };
 
 static inline struct lora_skb_priv *lora_skb_prv(struct sk_buff *skb)
diff --git a/include/uapi/linux/lora.h b/include/uapi/linux/lora.h
index 4ff00b9c3c20..4c458ee3ed9a 100644
--- a/include/uapi/linux/lora.h
+++ b/include/uapi/linux/lora.h
@@ -10,6 +10,18 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 
+/* TX addressing definition */
+struct tx_addr {
+	__u64 freq;
+	__u8 sf;
+	__u8 cr;
+	__u16 bw;
+
+	__u8 sync;
+
+	__s8 power;
+};
+
 /* particular protocols of the protocol family PF_LORA */
 #define LORA_PROTO_DATAGRAM	0
 #define LORA_NPROTO		1
@@ -17,7 +29,9 @@
 struct sockaddr_lora {
 	__kernel_sa_family_t lora_family;
 	int lora_ifindex;
+	__u8 lora_protocol;
 	union {
+		struct tx_addr	tx;
 	} lora_addr;
 };
 
diff --git a/net/lora/dgram.c b/net/lora/dgram.c
index 4d931fd3778a..1556ad0f8835 100644
--- a/net/lora/dgram.c
+++ b/net/lora/dgram.c
@@ -20,6 +20,15 @@ struct dgram_sock {
 	int ifindex;
 	bool bound;
 	struct notifier_block notifier;
+
+	u64 freq;
+	u8 sf;
+	u8 cr;
+	u16 bw;
+
+	u8 sync;
+
+	s8 power;
 };
 
 static inline struct dgram_sock *dgram_sk(const struct sock *sk)
@@ -69,6 +78,12 @@ static int dgram_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 		ifindex = 0;
 
 	dgram->ifindex = ifindex;
+	dgram->freq = addr->lora_addr.tx.freq;
+	dgram->sf = addr->lora_addr.tx.sf;
+	dgram->cr = addr->lora_addr.tx.cr;
+	dgram->bw = addr->lora_addr.tx.bw;
+	dgram->sync = addr->lora_addr.tx.sync;
+	dgram->power = addr->lora_addr.tx.power;
 	dgram->bound = true;
 
 out:
@@ -118,6 +133,12 @@ static int dgram_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 
 	lora_skb_reserve(skb);
 	lora_skb_prv(skb)->ifindex = netdev->ifindex;
+	lora_skb_prv(skb)->freq = dgram->freq;
+	lora_skb_prv(skb)->sf = dgram->sf;
+	lora_skb_prv(skb)->cr = dgram->cr;
+	lora_skb_prv(skb)->bw = dgram->bw;
+	lora_skb_prv(skb)->sync = dgram->sync;
+	lora_skb_prv(skb)->power = dgram->power;
 
 	ret = memcpy_from_msg(skb_put(skb, size), msg, size);
 	if (ret < 0)
@@ -172,6 +193,12 @@ static int dgram_getname(struct socket *sock, struct sockaddr *uaddr,
 	memset(addr, 0, sizeof(*addr));
 	addr->lora_family = AF_LORA;
 	addr->lora_ifindex = dgram->ifindex;
+	addr->lora_addr.tx.freq = dgram->freq;
+	addr->lora_addr.tx.sf = dgram->sf;
+	addr->lora_addr.tx.cr = dgram->cr;
+	addr->lora_addr.tx.bw = dgram->bw;
+	addr->lora_addr.tx.sync = dgram->sync;
+	addr->lora_addr.tx.power = dgram->power;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
 	return sizeof(*addr);
@@ -198,6 +225,12 @@ static int dgram_release(struct socket *sock)
 	lock_sock(sk);
 
 	dgram->ifindex = 0;
+	dgram->freq = 0;
+	dgram->sf = 0;
+	dgram->cr = 0;
+	dgram->bw = 0;
+	dgram->sync = 0;
+	dgram->power = 0;
 	dgram->bound = false;
 
 	sock_orphan(sk);
@@ -251,6 +284,12 @@ static int dgram_notifier(struct notifier_block *nb, unsigned long msg, void *pt
 		lock_sock(sk);
 
 		dgram->ifindex = 0;
+		dgram->freq = 0;
+		dgram->sf = 0;
+		dgram->cr = 0;
+		dgram->bw = 0;
+		dgram->sync = 0;
+		dgram->power = 0;
 		dgram->bound = false;
 
 		release_sock(sk);
@@ -277,6 +316,12 @@ static int dgram_init(struct sock *sk)
 	pr_debug("lora: %s\n", __func__);
 
 	dgram->bound = false;
+	dgram->freq = 0;
+	dgram->sf = 0;
+	dgram->cr = 0;
+	dgram->bw = 0;
+	dgram->sync = 0;
+	dgram->power = 0;
 	dgram->ifindex = 0;
 
 	dgram->notifier.notifier_call = dgram_notifier;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ