aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-10-23 20:23:30 -0700
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-23 21:27:50 -0700
commit6273172e1772bf5ce8697bcae145f0f2954fd159 (patch)
tree2c521a8065621d641768d8fa52e6a073cd916929 /net
parent[NET]: Validate device addr prior to interface-up (diff)
downloadlinux-dev-6273172e1772bf5ce8697bcae145f0f2954fd159.tar.xz
linux-dev-6273172e1772bf5ce8697bcae145f0f2954fd159.zip
[DCCP]: Implement SIOCINQ/FIONREAD
Just like UDP. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Leandro Melo de Sales <leandroal@gmail.com> Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/dccp/proto.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index cc9bf1cb2646..d84973928033 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -26,6 +26,7 @@
#include <net/sock.h>
#include <net/xfrm.h>
+#include <asm/ioctls.h>
#include <asm/semaphore.h>
#include <linux/spinlock.h>
#include <linux/timer.h>
@@ -378,8 +379,36 @@ EXPORT_SYMBOL_GPL(dccp_poll);
int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg)
{
- dccp_pr_debug("entry\n");
- return -ENOIOCTLCMD;
+ int rc = -ENOTCONN;
+
+ lock_sock(sk);
+
+ if (sk->sk_state == DCCP_LISTEN)
+ goto out;
+
+ switch (cmd) {
+ case SIOCINQ: {
+ struct sk_buff *skb;
+ unsigned long amount = 0;
+
+ skb = skb_peek(&sk->sk_receive_queue);
+ if (skb != NULL) {
+ /*
+ * We will only return the amount of this packet since
+ * that is all that will be read.
+ */
+ amount = skb->len;
+ }
+ rc = put_user(amount, (int __user *)arg);
+ }
+ break;
+ default:
+ rc = -ENOIOCTLCMD;
+ break;
+ }
+out:
+ release_sock(sk);
+ return rc;
}
EXPORT_SYMBOL_GPL(dccp_ioctl);