Lines Matching refs:sk

106 int nl_connect(struct nl_sock *sk, int protocol)  in nl_connect()  argument
111 sk->s_fd = socket(AF_NETLINK, SOCK_RAW, protocol); in nl_connect()
112 if (sk->s_fd < 0) { in nl_connect()
117 if (!(sk->s_flags & NL_SOCK_BUFSIZE_SET)) { in nl_connect()
118 err = nl_socket_set_buffer_size(sk, 0, 0); in nl_connect()
123 err = bind(sk->s_fd, (struct sockaddr*) &sk->s_local, in nl_connect()
124 sizeof(sk->s_local)); in nl_connect()
130 addrlen = sizeof(sk->s_local); in nl_connect()
131 err = getsockname(sk->s_fd, (struct sockaddr *) &sk->s_local, in nl_connect()
138 if (addrlen != sizeof(sk->s_local)) { in nl_connect()
143 if (sk->s_local.nl_family != AF_NETLINK) { in nl_connect()
148 sk->s_proto = protocol; in nl_connect()
152 close(sk->s_fd); in nl_connect()
153 sk->s_fd = -1; in nl_connect()
162 void nl_close(struct nl_sock *sk) in nl_close() argument
164 if (sk->s_fd >= 0) { in nl_close()
165 close(sk->s_fd); in nl_close()
166 sk->s_fd = -1; in nl_close()
169 sk->s_proto = 0; in nl_close()
186 int nl_sendto(struct nl_sock *sk, void *buf, size_t size) in nl_sendto() argument
190 ret = sendto(sk->s_fd, buf, size, 0, (struct sockaddr *) in nl_sendto()
191 &sk->s_peer, sizeof(sk->s_peer)); in nl_sendto()
205 int nl_sendmsg(struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr) in nl_sendmsg() argument
210 nlmsg_set_src(msg, &sk->s_local); in nl_sendmsg()
212 cb = sk->s_cb; in nl_sendmsg()
217 ret = sendmsg(sk->s_fd, hdr, 0); in nl_sendmsg()
235 int nl_send_iovec(struct nl_sock *sk, struct nl_msg *msg, struct iovec *iov, unsigned iovlen) in nl_send_iovec() argument
240 .msg_name = (void *) &sk->s_peer, in nl_send_iovec()
269 return nl_sendmsg(sk, msg, &hdr); in nl_send_iovec()
281 int nl_send(struct nl_sock *sk, struct nl_msg *msg) in nl_send() argument
288 return nl_send_iovec(sk, msg, &iov, 1); in nl_send()
291 void nl_auto_complete(struct nl_sock *sk, struct nl_msg *msg) in nl_auto_complete() argument
297 nlh->nlmsg_pid = sk->s_local.nl_pid; in nl_auto_complete()
300 nlh->nlmsg_seq = sk->s_seq_next++; in nl_auto_complete()
303 msg->nm_protocol = sk->s_proto; in nl_auto_complete()
307 if (!(sk->s_flags & NL_NO_AUTO_ACK)) in nl_auto_complete()
323 int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg) in nl_send_auto_complete() argument
325 struct nl_cb *cb = sk->s_cb; in nl_send_auto_complete()
327 nl_auto_complete(sk, msg); in nl_send_auto_complete()
330 return cb->cb_send_ow(sk, msg); in nl_send_auto_complete()
332 return nl_send(sk, msg); in nl_send_auto_complete()
349 int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf, in nl_send_simple() argument
366 err = nl_send_auto_complete(sk, msg); in nl_send_simple()
399 int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla, in nl_recv() argument
417 if (sk->s_flags & NL_MSG_PEEK) in nl_recv()
426 if (sk->s_flags & NL_SOCK_PASSCRED) { in nl_recv()
432 n = recvmsg(sk->s_fd, &msg, flags); in nl_recv()
506 static int recvmsgs(struct nl_sock *sk, struct nl_cb *cb) in recvmsgs() argument
516 NL_DBG(3, "Attempting to read from %p\n", sk); in recvmsgs()
518 n = cb->cb_recv_ow(sk, &nla, &buf, &creds); in recvmsgs()
520 n = nl_recv(sk, &nla, &buf, &creds); in recvmsgs()
525 NL_DBG(3, "recvmsgs(%p): Read %d bytes\n", sk, n); in recvmsgs()
529 NL_DBG(3, "recgmsgs(%p): Processing valid message...\n", sk); in recvmsgs()
538 nlmsg_set_proto(msg, sk->s_proto); in recvmsgs()
553 else if (hdr->nlmsg_seq != sk->s_seq_expect) { in recvmsgs()
568 sk->s_seq_expect++; in recvmsgs()
571 sk, sk->s_seq_expect); in recvmsgs()
701 int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb) in nl_recvmsgs() argument
704 return cb->cb_recvmsgs_ow(sk, cb); in nl_recvmsgs()
706 return recvmsgs(sk, cb); in nl_recvmsgs()
715 int nl_recvmsgs_default(struct nl_sock *sk) in nl_recvmsgs_default() argument
717 return nl_recvmsgs(sk, sk->s_cb); in nl_recvmsgs_default()
734 int nl_wait_for_ack(struct nl_sock *sk) in nl_wait_for_ack() argument
739 cb = nl_cb_clone(sk->s_cb); in nl_wait_for_ack()
744 err = nl_recvmsgs(sk, cb); in nl_wait_for_ack()