aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-10-23 23:23:30 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-24 00:27:50 -0400
commit6273172e1772bf5ce8697bcae145f0f2954fd159 (patch)
tree2c521a8065621d641768d8fa52e6a073cd916929 /net
parentbada339ba24dee9e143bfb42e1dc61f146619846 (diff)
[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 @@
26#include <net/sock.h> 26#include <net/sock.h>
27#include <net/xfrm.h> 27#include <net/xfrm.h>
28 28
29#include <asm/ioctls.h>
29#include <asm/semaphore.h> 30#include <asm/semaphore.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
31#include <linux/timer.h> 32#include <linux/timer.h>
@@ -378,8 +379,36 @@ EXPORT_SYMBOL_GPL(dccp_poll);
378 379
379int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) 380int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg)
380{ 381{
381 dccp_pr_debug("entry\n"); 382 int rc = -ENOTCONN;
382 return -ENOIOCTLCMD; 383
384 lock_sock(sk);
385
386 if (sk->sk_state == DCCP_LISTEN)
387 goto out;
388
389 switch (cmd) {
390 case SIOCINQ: {
391 struct sk_buff *skb;
392 unsigned long amount = 0;
393
394 skb = skb_peek(&sk->sk_receive_queue);
395 if (skb != NULL) {
396 /*
397 * We will only return the amount of this packet since
398 * that is all that will be read.
399 */
400 amount = skb->len;
401 }
402 rc = put_user(amount, (int __user *)arg);
403 }
404 break;
405 default:
406 rc = -ENOIOCTLCMD;
407 break;
408 }
409out:
410 release_sock(sk);
411 return rc;
383} 412}
384 413
385EXPORT_SYMBOL_GPL(dccp_ioctl); 414EXPORT_SYMBOL_GPL(dccp_ioctl);