sock: Introduce the SO_PEEK_OFF sock option
[linux-2.6.git] / net / core / sock.c
index 02f8dfe..19942d4 100644 (file)
@@ -793,6 +793,12 @@ set_rcvbuf:
                sock_valbool_flag(sk, SOCK_WIFI_STATUS, valbool);
                break;
 
+       case SO_PEEK_OFF:
+               if (sock->ops->set_peek_off)
+                       sock->ops->set_peek_off(sk, val);
+               else
+                       ret = -EOPNOTSUPP;
+               break;
        default:
                ret = -ENOPROTOOPT;
                break;
@@ -1018,6 +1024,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                v.val = !!sock_flag(sk, SOCK_WIFI_STATUS);
                break;
 
+       case SO_PEEK_OFF:
+               if (!sock->ops->set_peek_off)
+                       return -EOPNOTSUPP;
+
+               v.val = sk->sk_peek_off;
+               break;
        default:
                return -ENOPROTOOPT;
        }
@@ -2092,6 +2104,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
 
        sk->sk_sndmsg_page      =       NULL;
        sk->sk_sndmsg_off       =       0;
+       sk->sk_peek_off         =       -1;
 
        sk->sk_peer_pid         =       NULL;
        sk->sk_peer_cred        =       NULL;