Skip to content

Commit

Permalink
[DCCP]: Implement SIOCINQ/FIONREAD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo authored and David S. Miller committed Oct 24, 2007
1 parent bada339 commit 6273172
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions net/dccp/proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6273172

Please sign in to comment.