dect
/
libnl
Archived
13
0
Fork 0

Add socket flag NL_NO_AUTO_ACK to allow disabling auto ACKS

This commit is contained in:
Thomas Graf 2008-10-20 13:02:38 +02:00
parent f42f195a80
commit 2bdee95a76
4 changed files with 35 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#define NL_SOCK_PASSCRED (1<<1)
#define NL_OWN_PORT (1<<2)
#define NL_MSG_PEEK (1<<3)
#define NL_NO_AUTO_ACK (1<<4)
#define NL_MSG_CRED_PRESENT 1

View File

@ -56,6 +56,8 @@ extern int nl_socket_recv_pktinfo(struct nl_sock *, int);
extern void nl_disable_sequence_check(struct nl_sock *);
extern unsigned int nl_socket_use_seq(struct nl_sock *);
extern void nl_socket_disable_auto_ack(struct nl_sock *);
extern void nl_socket_enable_auto_ack(struct nl_sock *);
extern int nl_socket_get_fd(struct nl_sock *);
extern int nl_socket_set_nonblocking(struct nl_sock *);

View File

@ -126,7 +126,7 @@
* // and message flags all the time. nl_send_auto_complete() automatically
* // extends your message header as needed with an appropriate sequence
* // number, the netlink pid stored in the netlink socket and the message
* // flags NLM_F_REQUEST and NLM_F_ACK
* // flags NLM_F_REQUEST and NLM_F_ACK (if not disabled in the socket)
* nl_send_auto_complete(sk, nlmsg_hdr(msg));
*
* // Simple protocols don't require the complex message construction interface
@ -385,7 +385,10 @@ int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
if (msg->nm_protocol == -1)
msg->nm_protocol = sk->s_proto;
nlh->nlmsg_flags |= (NLM_F_REQUEST | NLM_F_ACK);
nlh->nlmsg_flags |= NLM_F_REQUEST;
if (!(sk->s_flags & NL_NO_AUTO_ACK))
nlh->nlmsg_flags |= NLM_F_ACK;
if (cb->cb_send_ow)
return cb->cb_send_ow(sk, msg);

View File

@ -276,6 +276,33 @@ unsigned int nl_socket_use_seq(struct nl_sock *sk)
return sk->s_seq_next++;
}
/**
* Disable automatic request for ACK
* @arg sk Netlink socket.
*
* The default behaviour of a socket is to request an ACK for
* each message sent to allow for the caller to synchronize to
* the completion of the netlink operation. This function
* disables this behaviour and will result in requests being
* sent which will not have the NLM_F_ACK flag set automatically.
* However, it is still possible for the caller to set the
* NLM_F_ACK flag explicitely.
*/
void nl_socket_disable_auto_ack(struct nl_sock *sk)
{
sk->s_flags |= NL_NO_AUTO_ACK;
}
/**
* Enable automatic request for ACK (default)
* @arg sk Netlink socket.
* @see nl_socket_disable_auto_ack
*/
void nl_socket_enable_auto_ack(struct nl_sock *sk)
{
sk->s_flags &= ~NL_NO_AUTO_ACK;
}
/** @} */
/**