static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg)
{
- return cb->cb_set[type](msg, cb->cb_args[type]);
+ int ret;
+
+ cb->cb_active = type;
+ ret = cb->cb_set[type](msg, cb->cb_args[type]);
+ cb->cb_active = __NL_CB_TYPE_MAX;
+ return ret;
}
#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
{
nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1];
void * cb_args[NL_CB_TYPE_MAX+1];
-
+
nl_recvmsg_err_cb_t cb_err;
void * cb_err_arg;
struct nl_msg *);
int cb_refcnt;
+ /** indicates the callback that is currently active */
+ enum nl_cb_type cb_active;
};
struct nl_sock
uint32_t l_txqlen;
uint32_t l_weight;
uint32_t l_master;
- struct nl_addr * l_addr;
+ struct nl_addr * l_addr;
struct nl_addr * l_bcast;
char l_qdisc[IFQDISCSIZ];
struct rtnl_link_map l_map;
uint32_t n_ifindex;
uint16_t n_state;
uint8_t n_flags;
- uint8_t n_type;
+ uint8_t n_type;
struct nl_addr *n_lladdr;
- struct nl_addr *n_dst;
+ struct nl_addr *n_dst;
uint32_t n_probes;
struct rtnl_ncacheinfo n_cacheinfo;
uint32_t n_state_mask;
uint8_t a_scope;
uint32_t a_ifindex;
- struct nl_addr *a_peer;
+ struct nl_addr *a_peer;
struct nl_addr *a_local;
struct nl_addr *a_bcast;
struct nl_addr *a_anycast;
struct nl_addr *a_multicast;
struct rtnl_addr_cacheinfo a_cacheinfo;
-
+
char a_label[IFNAMSIZ];
uint32_t a_flag_mask;
struct rtnl_link *a_link;
* Queue length for the delayed proxy arp requests.
*/
uint32_t ntp_proxy_qlen;
-
+
/**
* Mask of available parameter attributes
*/
{
char flags[128];
char type[32];
-
+
fprintf(ofd, "type=%s length=%u flags=<%s> sequence-nr=%u pid=%u",
nl_nlmsgtype2str(n->nlmsg_type, type, sizeof(type)),
n->nlmsg_len, nl_nlmsg_flags2str(n->nlmsg_flags, flags,
fprintf(ofd, "-- Error: Netlink Overrun: ");
print_header_content(ofd, nlmsg_hdr(msg));
fprintf(ofd, "\n");
-
+
return NL_STOP;
}
fprintf(ofd, "-- Debug: End of multipart message block: ");
print_header_content(ofd, nlmsg_hdr(msg));
fprintf(ofd, "\n");
-
+
return NL_STOP;
}
fprintf(ofd, "-- Debug: Received Message:\n");
nl_msg_dump(msg, ofd);
-
+
return NL_OK;
}
return NULL;
cb->cb_refcnt = 1;
+ cb->cb_active = NL_CB_TYPE_MAX + 1;
for (i = 0; i <= NL_CB_TYPE_MAX; i++)
nl_cb_set(cb, i, kind, NULL, NULL);
struct nl_cb *nl_cb_clone(struct nl_cb *orig)
{
struct nl_cb *cb;
-
+
cb = nl_cb_alloc(NL_CB_DEFAULT);
if (!cb)
return NULL;
free(cb);
}
+/**
+ * Obtain type of current active callback
+ * @arg cb callback to query
+ *
+ * @return type or __NL_CB_TYPE_MAX if none active
+ */
+enum nl_cb_type nl_cb_active_type(struct nl_cb *cb)
+{
+ return cb->cb_active;
+}
+
/** @} */
/**
*/
/**
- * Set up a callback
+ * Set up a callback
* @arg cb callback set
* @arg type callback to modify
* @arg kind kind of implementation