summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2010-03-26 10:35:59 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2010-03-26 10:35:59 +0100
commit1be15625d4d722557fbb4766290fb71a8f59cfe3 (patch)
tree33b3fd2282d90c4119876930cb0e0467ad722c98
parentc5a4f3d7738f8172de40112cf4a02fbd4b0a9902 (diff)
downloadlibmnl-1be15625d4d722557fbb4766290fb71a8f59cfe3.tar.gz
libmnl-1be15625d4d722557fbb4766290fb71a8f59cfe3.zip
fix mnl_cb_run() and mnl_cb_run2() return value logic
-rw-r--r--src/callback.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/callback.c b/src/callback.c
index 2f2da50..9212ba5 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -56,8 +56,12 @@ static mnl_cb_t default_cb_array[NLMSG_MIN_TYPE] = {
* callback handlers, in that case, the parameter cb_ctl_array_len is not
* checked.
*
- * This function returns -1 in case of error, 0 if we have received a
- * NLMSG_DONE message or the callback has explicitly returned MNL_CB_STOP.
+ * Your callback may return three possible values:
+ * - MNL_CB_ERROR (<=-1): an error has occurred. Stop callback runqueue.
+ * - MNL_CB_STOP (=0): stop callback runqueue.
+ * - MNL_CB_OK (>=1): no problems has occurred.
+ *
+ * This function propagates the callback return value.
*/
int mnl_cb_run2(const char *buf, int numbytes, unsigned int seq,
mnl_cb_t cb_data, void *data,
@@ -94,7 +98,7 @@ int mnl_cb_run2(const char *buf, int numbytes, unsigned int seq,
nlh = mnl_nlmsg_next(nlh, &numbytes);
}
out:
- return ret <= MNL_CB_ERROR ? -1 : 0;
+ return ret;
}
/**
@@ -108,8 +112,12 @@ out:
* This function is like mnl_cb_run2() but it does not allow you to set
* the control callback handlers.
*
- * This function returns -1 in case of error, 0 if we have received a
- * NLMSG_DONE message or the callback has explicitly returned MNL_CB_STOP.
+ * Your callback may return three possible values:
+ * - MNL_CB_ERROR (<=-1): an error has occurred. Stop callback runqueue.
+ * - MNL_CB_STOP (=0): stop callback runqueue.
+ * - MNL_CB_OK (>=1): no problems has occurred.
+ *
+ * This function propagates the callback return value.
*/
int mnl_cb_run(const char *buf, int numbytes, unsigned int seq,
mnl_cb_t cb_data, void *data)