From: Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH 08/10] af_ieee802154: add support for WANT_ACK socket option
Date: Fri, 7 Aug 2009 16:58:43 +0400 [thread overview]
Message-ID: <1249649925-11996-9-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1249649925-11996-8-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
include/net/af_ieee802154.h | 5 +++
net/ieee802154/dgram.c | 58 ++++++++++++++++++++++++++++++++++++++++---
2 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/include/net/af_ieee802154.h b/include/net/af_ieee802154.h
index e9c70ea..75e64c7 100644
--- a/include/net/af_ieee802154.h
+++ b/include/net/af_ieee802154.h
@@ -54,4 +54,9 @@ struct sockaddr_ieee802154 {
struct ieee802154_addr addr;
};
+/* get/setsockopt */
+#define SOL_IEEE802154 0
+
+#define WPAN_WANTACK 0
+
#endif
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index 25018a9..77ae685 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -44,6 +44,7 @@ struct dgram_sock {
struct ieee802154_addr dst_addr;
unsigned bound:1;
+ unsigned want_ack:1;
};
static inline struct dgram_sock *dgram_sk(const struct sock *sk)
@@ -51,7 +52,6 @@ static inline struct dgram_sock *dgram_sk(const struct sock *sk)
return container_of(sk, struct dgram_sock, sk);
}
-
static void dgram_hash(struct sock *sk)
{
write_lock_bh(&dgram_lock);
@@ -74,6 +74,7 @@ static int dgram_init(struct sock *sk)
ro->dst_addr.addr_type = IEEE802154_ADDR_LONG;
ro->dst_addr.pan_id = 0xffff;
+ ro->want_ack = 1;
memset(&ro->dst_addr.hwaddr, 0xff, sizeof(ro->dst_addr.hwaddr));
return 0;
}
@@ -237,7 +238,10 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
skb_reset_network_header(skb);
- mac_cb(skb)->flags = IEEE802154_FC_TYPE_DATA | MAC_CB_FLAG_ACKREQ;
+ mac_cb(skb)->flags = IEEE802154_FC_TYPE_DATA;
+ if (ro->want_ack)
+ mac_cb(skb)->flags |= MAC_CB_FLAG_ACKREQ;
+
mac_cb(skb)->seq = ieee802154_mlme_ops(dev)->get_dsn(dev);
err = dev_hard_header(skb, dev, ETH_P_IEEE802154, &ro->dst_addr,
ro->bound ? &ro->src_addr : NULL, size);
@@ -382,13 +386,59 @@ int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb)
static int dgram_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen)
{
- return -EOPNOTSUPP;
+ struct dgram_sock *ro = dgram_sk(sk);
+
+ int val, len;
+
+ if (level != SOL_IEEE802154)
+ return -EOPNOTSUPP;
+
+ if (get_user(len, optlen))
+ return -EFAULT;
+
+ len = min_t(unsigned int, len, sizeof(int));
+
+ switch (optname) {
+ case WPAN_WANTACK:
+ val = ro->want_ack;
+ break;
+ default:
+ return -ENOPROTOOPT;
+ }
+
+ if (put_user(len, optlen))
+ return -EFAULT;
+ if (copy_to_user(optval, &val, len))
+ return -EFAULT;
+ return 0;
}
static int dgram_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user optlen)
{
- return -EOPNOTSUPP;
+ struct dgram_sock *ro = dgram_sk(sk);
+ int val;
+ int err = 0;
+
+ if (optlen < sizeof(int))
+ return -EINVAL;
+
+ if (get_user(val, (int __user *)optval))
+ return -EFAULT;
+
+ lock_sock(sk);
+
+ switch (optname) {
+ case WPAN_WANTACK:
+ ro->want_ack = !!val;
+ break;
+ default:
+ err = -ENOPROTOOPT;
+ break;
+ }
+
+ release_sock(sk);
+ return err;
}
struct proto ieee802154_dgram_prot = {
--
1.6.3.3
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
next prev parent reply other threads:[~2009-08-07 12:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-07 12:58 [NEXT][GIT PULL 0/10] Updates for the IEEE 802.15.4 stack Dmitry Eremin-Solenikov
2009-08-07 12:58 ` [PATCH 01/10] af_ieee802154: drop IEEE802154_SIOC_ADD_SLAVE declaration Dmitry Eremin-Solenikov
2009-08-07 12:58 ` [PATCH 02/10] af_ieee802154: fix ioctl processing Dmitry Eremin-Solenikov
2009-08-07 12:58 ` [PATCH 03/10] nl802154: make ieee802154_policy constant Dmitry Eremin-Solenikov
2009-08-07 12:58 ` [PATCH 04/10] documentation: fix wrt. headers rename Dmitry Eremin-Solenikov
[not found] ` <1249649925-11996-5-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-08-07 12:58 ` [PATCH 05/10] nl802154: add support for dumping WPAN interface information Dmitry Eremin-Solenikov
[not found] ` <1249649925-11996-6-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-08-07 12:58 ` [PATCH 06/10] af_ieee802154: provide dummy get/setsockopt Dmitry Eremin-Solenikov
[not found] ` <1249649925-11996-7-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-08-07 12:58 ` [PATCH 07/10] af_ieee802154: minor cleanup in dgram_bind Dmitry Eremin-Solenikov
[not found] ` <1249649925-11996-8-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-08-07 12:58 ` Dmitry Eremin-Solenikov [this message]
[not found] ` <1249649925-11996-9-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-08-07 12:58 ` [PATCH 09/10] nl802154: support START-CONFIRM primitive Dmitry Eremin-Solenikov
[not found] ` <1249649925-11996-10-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-08-07 12:58 ` [PATCH 10/10] fakehard: use START-CONFIRM primitive to report START failure Dmitry Eremin-Solenikov
2009-08-13 3:52 ` [PATCH 09/10] nl802154: support START-CONFIRM primitive David Miller
2009-08-13 3:53 ` David Miller
2009-08-13 3:52 ` [PATCH 08/10] af_ieee802154: add support for WANT_ACK socket option David Miller
2009-08-13 3:52 ` [PATCH 07/10] af_ieee802154: minor cleanup in dgram_bind David Miller
2009-08-13 3:52 ` [PATCH 06/10] af_ieee802154: provide dummy get/setsockopt David Miller
2009-08-13 3:52 ` [PATCH 05/10] nl802154: add support for dumping WPAN interface information David Miller
2009-08-13 3:52 ` [PATCH 04/10] documentation: fix wrt. headers rename David Miller
2009-08-13 3:52 ` [PATCH 03/10] nl802154: make ieee802154_policy constant David Miller
2009-08-13 3:51 ` [PATCH 02/10] af_ieee802154: fix ioctl processing David Miller
2009-08-13 3:50 ` [PATCH 01/10] af_ieee802154: drop IEEE802154_SIOC_ADD_SLAVE declaration David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1249649925-11996-9-git-send-email-dbaryshkov@gmail.com \
--to=dbaryshkov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).