diff options
Diffstat (limited to 'net/dccp/proto.c')
-rw-r--r-- | net/dccp/proto.c | 33 |
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 | ||
379 | int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) | 380 | int 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 | } | ||
409 | out: | ||
410 | release_sock(sk); | ||
411 | return rc; | ||
383 | } | 412 | } |
384 | 413 | ||
385 | EXPORT_SYMBOL_GPL(dccp_ioctl); | 414 | EXPORT_SYMBOL_GPL(dccp_ioctl); |