• Home
  • Raw
  • Download

Lines Matching refs:sk

183 	struct nl_sock *sk;  in __alloc_socket()  local
185 sk = calloc(1, sizeof(*sk)); in __alloc_socket()
186 if (!sk) in __alloc_socket()
189 sk->s_fd = -1; in __alloc_socket()
190 sk->s_cb = nl_cb_get(cb); in __alloc_socket()
191 sk->s_local.nl_family = AF_NETLINK; in __alloc_socket()
192 sk->s_peer.nl_family = AF_NETLINK; in __alloc_socket()
193 sk->s_seq_expect = sk->s_seq_next = time(0); in __alloc_socket()
196 sk->s_flags = NL_OWN_PORT; in __alloc_socket()
198 return sk; in __alloc_socket()
209 struct nl_sock *sk; in nl_socket_alloc() local
216 sk = __alloc_socket(cb); in nl_socket_alloc()
220 return sk; in nl_socket_alloc()
244 void nl_socket_free(struct nl_sock *sk) in nl_socket_free() argument
246 if (!sk) in nl_socket_free()
249 if (sk->s_fd >= 0) in nl_socket_free()
250 close(sk->s_fd); in nl_socket_free()
252 if (!(sk->s_flags & NL_OWN_PORT)) in nl_socket_free()
253 release_local_port(sk->s_local.nl_pid); in nl_socket_free()
255 nl_cb_put(sk->s_cb); in nl_socket_free()
256 free(sk); in nl_socket_free()
283 void nl_socket_disable_seq_check(struct nl_sock *sk) in nl_socket_disable_seq_check() argument
285 nl_cb_set(sk->s_cb, NL_CB_SEQ_CHECK, in nl_socket_disable_seq_check()
298 unsigned int nl_socket_use_seq(struct nl_sock *sk) in nl_socket_use_seq() argument
300 return sk->s_seq_next++; in nl_socket_use_seq()
315 void nl_socket_disable_auto_ack(struct nl_sock *sk) in nl_socket_disable_auto_ack() argument
317 sk->s_flags |= NL_NO_AUTO_ACK; in nl_socket_disable_auto_ack()
325 void nl_socket_enable_auto_ack(struct nl_sock *sk) in nl_socket_enable_auto_ack() argument
327 sk->s_flags &= ~NL_NO_AUTO_ACK; in nl_socket_enable_auto_ack()
333 int _nl_socket_is_local_port_unspecified(struct nl_sock *sk) in _nl_socket_is_local_port_unspecified() argument
335 return (sk->s_local.nl_pid == 0); in _nl_socket_is_local_port_unspecified()
338 uint32_t _nl_socket_generate_local_port_no_release(struct nl_sock *sk) in _nl_socket_generate_local_port_no_release() argument
346 sk->s_flags &= ~NL_OWN_PORT; in _nl_socket_generate_local_port_no_release()
347 sk->s_local.nl_pid = port; in _nl_socket_generate_local_port_no_release()
357 uint32_t nl_socket_get_local_port(const struct nl_sock *sk) in nl_socket_get_local_port() argument
359 if (sk->s_local.nl_pid == 0) { in nl_socket_get_local_port()
369 return _nl_socket_generate_local_port_no_release((struct nl_sock *) sk); in nl_socket_get_local_port()
371 return sk->s_local.nl_pid; in nl_socket_get_local_port()
386 void nl_socket_set_local_port(struct nl_sock *sk, uint32_t port) in nl_socket_set_local_port() argument
388 if (!(sk->s_flags & NL_OWN_PORT)) in nl_socket_set_local_port()
389 release_local_port(sk->s_local.nl_pid); in nl_socket_set_local_port()
390 sk->s_flags |= NL_OWN_PORT; in nl_socket_set_local_port()
391 sk->s_local.nl_pid = port; in nl_socket_set_local_port()
417 int nl_socket_add_memberships(struct nl_sock *sk, int group, ...) in nl_socket_add_memberships() argument
422 if (sk->s_fd == -1) in nl_socket_add_memberships()
433 err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, in nl_socket_add_memberships()
448 int nl_socket_add_membership(struct nl_sock *sk, int group) in nl_socket_add_membership() argument
450 return nl_socket_add_memberships(sk, group, 0); in nl_socket_add_membership()
465 int nl_socket_drop_memberships(struct nl_sock *sk, int group, ...) in nl_socket_drop_memberships() argument
470 if (sk->s_fd == -1) in nl_socket_drop_memberships()
481 err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP, in nl_socket_drop_memberships()
496 int nl_socket_drop_membership(struct nl_sock *sk, int group) in nl_socket_drop_membership() argument
498 return nl_socket_drop_memberships(sk, group, 0); in nl_socket_drop_membership()
511 void nl_join_groups(struct nl_sock *sk, int groups) in nl_join_groups() argument
513 sk->s_local.nl_groups |= groups; in nl_join_groups()
524 uint32_t nl_socket_get_peer_port(const struct nl_sock *sk) in nl_socket_get_peer_port() argument
526 return sk->s_peer.nl_pid; in nl_socket_get_peer_port()
529 void nl_socket_set_peer_port(struct nl_sock *sk, uint32_t port) in nl_socket_set_peer_port() argument
531 sk->s_peer.nl_pid = port; in nl_socket_set_peer_port()
534 uint32_t nl_socket_get_peer_groups(const struct nl_sock *sk) in nl_socket_get_peer_groups() argument
536 return sk->s_peer.nl_groups; in nl_socket_get_peer_groups()
539 void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups) in nl_socket_set_peer_groups() argument
541 sk->s_peer.nl_groups = groups; in nl_socket_set_peer_groups()
562 int nl_socket_get_fd(const struct nl_sock *sk) in nl_socket_get_fd() argument
564 return sk->s_fd; in nl_socket_get_fd()
573 int nl_socket_set_nonblocking(const struct nl_sock *sk) in nl_socket_set_nonblocking() argument
575 if (sk->s_fd == -1) in nl_socket_set_nonblocking()
578 if (fcntl(sk->s_fd, F_SETFL, O_NONBLOCK) < 0) in nl_socket_set_nonblocking()
588 void nl_socket_enable_msg_peek(struct nl_sock *sk) in nl_socket_enable_msg_peek() argument
590 sk->s_flags |= NL_MSG_PEEK; in nl_socket_enable_msg_peek()
597 void nl_socket_disable_msg_peek(struct nl_sock *sk) in nl_socket_disable_msg_peek() argument
599 sk->s_flags &= ~NL_MSG_PEEK; in nl_socket_disable_msg_peek()
609 struct nl_cb *nl_socket_get_cb(const struct nl_sock *sk) in nl_socket_get_cb() argument
611 return nl_cb_get(sk->s_cb); in nl_socket_get_cb()
614 void nl_socket_set_cb(struct nl_sock *sk, struct nl_cb *cb) in nl_socket_set_cb() argument
619 nl_cb_put(sk->s_cb); in nl_socket_set_cb()
620 sk->s_cb = nl_cb_get(cb); in nl_socket_set_cb()
633 int nl_socket_modify_cb(struct nl_sock *sk, enum nl_cb_type type, in nl_socket_modify_cb() argument
637 return nl_cb_set(sk->s_cb, type, kind, func, arg); in nl_socket_modify_cb()
649 int nl_socket_modify_err_cb(struct nl_sock *sk, enum nl_cb_kind kind, in nl_socket_modify_err_cb() argument
652 return nl_cb_err(sk->s_cb, kind, func, arg); in nl_socket_modify_err_cb()
675 int nl_socket_set_buffer_size(struct nl_sock *sk, int rxbuf, int txbuf) in nl_socket_set_buffer_size() argument
685 if (sk->s_fd == -1) in nl_socket_set_buffer_size()
688 err = setsockopt(sk->s_fd, SOL_SOCKET, SO_SNDBUF, in nl_socket_set_buffer_size()
693 err = setsockopt(sk->s_fd, SOL_SOCKET, SO_RCVBUF, in nl_socket_set_buffer_size()
698 sk->s_flags |= NL_SOCK_BUFSIZE_SET; in nl_socket_set_buffer_size()
715 int nl_socket_set_msg_buf_size(struct nl_sock *sk, size_t bufsize) in nl_socket_set_msg_buf_size() argument
717 sk->s_bufsize = bufsize; in nl_socket_set_msg_buf_size()
728 size_t nl_socket_get_msg_buf_size(struct nl_sock *sk) in nl_socket_get_msg_buf_size() argument
730 return sk->s_bufsize; in nl_socket_get_msg_buf_size()
740 int nl_socket_set_passcred(struct nl_sock *sk, int state) in nl_socket_set_passcred() argument
744 if (sk->s_fd == -1) in nl_socket_set_passcred()
747 err = setsockopt(sk->s_fd, SOL_SOCKET, SO_PASSCRED, in nl_socket_set_passcred()
753 sk->s_flags |= NL_SOCK_PASSCRED; in nl_socket_set_passcred()
755 sk->s_flags &= ~NL_SOCK_PASSCRED; in nl_socket_set_passcred()
767 int nl_socket_recv_pktinfo(struct nl_sock *sk, int state) in nl_socket_recv_pktinfo() argument
771 if (sk->s_fd == -1) in nl_socket_recv_pktinfo()
774 err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_PKTINFO, in nl_socket_recv_pktinfo()