24 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
28 #include <linux/export.h>
32 static void rawsock_write_queue_purge(
struct sock *
sk)
42 static void rawsock_report_error(
struct sock *
sk,
int err)
50 rawsock_write_queue_purge(sk);
53 static int rawsock_release(
struct socket *
sock)
55 struct sock *sk = sock->
sk;
57 pr_debug(
"sock=%p sk=%p\n", sock, sk);
68 static int rawsock_connect(
struct socket *sock,
struct sockaddr *_addr,
71 struct sock *sk = sock->
sk;
76 pr_debug(
"sock=%p sk=%p flags=%d\n", sock, sk, flags);
82 pr_debug(
"addr dev_idx=%u target_idx=%u protocol=%u\n",
124 static int rawsock_add_header(
struct sk_buff *
skb)
134 struct sock *sk = (
struct sock *) context;
138 pr_debug(
"sk=%p err=%d\n", sk, err);
143 err = rawsock_add_header(skb);
162 rawsock_report_error(sk, err);
174 pr_debug(
"sk=%p target_idx=%u\n", sk, target_idx);
177 rawsock_write_queue_purge(sk);
185 rawsock_data_exchange_complete, sk);
187 rawsock_report_error(sk, rc);
195 struct sock *sk = sock->
sk;
200 pr_debug(
"sock=%p sk=%p len=%zu\n", sock, sk, len);
229 static int rawsock_recvmsg(
struct kiocb *iocb,
struct socket *sock,
230 struct msghdr *msg,
size_t len,
int flags)
233 struct sock *sk = sock->
sk;
238 pr_debug(
"sock=%p sk=%p len=%zu flags=%d\n", sock, sk, len, flags);
256 return rc ? : copied;
260 static const struct proto_ops rawsock_ops = {
263 .release = rawsock_release,
265 .connect = rawsock_connect,
275 .sendmsg = rawsock_sendmsg,
276 .recvmsg = rawsock_recvmsg,
280 static void rawsock_destruct(
struct sock *sk)
293 pr_err(
"Freeing alive NFC raw socket %p\n", sk);
298 static int rawsock_create(
struct net *
net,
struct socket *sock,
308 sock->
ops = &rawsock_ops;
325 static struct proto rawsock_proto = {
333 .proto = &rawsock_proto,
335 .create = rawsock_create