Skip to contentSkip to conversation

Implement SIOCINQ/FIONREAD

PATCH Applied Arnaldo Carvalho de Melo 4 participants 4 messages Oct 23, 2007 – Oct 24, 2007 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Implement SIOCINQ/FIONREAD

Just like UDP.

net/dccp/proto.c +32 -3
index cc9bf1c..723c29e 100644
@@ -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>
@@ -377,9 +378,37 @@ unsigned int dccp_poll(struct file *file, struct socket *sock,
 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);
maintainer Applied
#3 lore raw
In reply to Arnaldo Carvalho de Melo

From: "£eandro_Sales" <[email protected]>
Date: Tue, 23 Oct 2007 21:25:36 -0300

Quoted 11 lines

Em 23/10/07, Ian McDonald<[email protected]> escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 5 lines

Just like UDP.

Applied, thanks everyone.