summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>2006-01-26 16:14:57 +0000
committer/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>2006-01-26 16:14:57 +0000
commitbff350fad76eb03fc395be33a7208b7b179406fb (patch)
tree1fedbe0ffa6c4d81fb17afee0504e8b729f72757
parent5d187be963d41cea37624a2f24067801ca28286f (diff)
add support for instance-local and global sequence counters
-rw-r--r--include/libnetfilter_log/libnetfilter_log.h3
-rw-r--r--include/libnetfilter_log/linux_nfnetlink_log.h6
-rw-r--r--src/libnetfilter_log.c30
3 files changed, 39 insertions, 0 deletions
diff --git a/include/libnetfilter_log/libnetfilter_log.h b/include/libnetfilter_log/libnetfilter_log.h
index d0145f4..5615daf 100644
--- a/include/libnetfilter_log/libnetfilter_log.h
+++ b/include/libnetfilter_log/libnetfilter_log.h
@@ -38,6 +38,7 @@ extern int nflog_unbind_group(struct nflog_g_handle *gh);
extern int nflog_set_mode(struct nflog_g_handle *gh,
u_int8_t mode, unsigned int len);
extern int nflog_set_timeout(struct nflog_g_handle *gh, u_int32_t timeout);
+extern int nflog_set_flags(struct nflog_g_handle *gh, u_int16_t flags);
extern int nflog_set_qthresh(struct nflog_g_handle *gh, u_int32_t qthresh);
extern int nflog_set_nlbufsiz(struct nflog_g_handle *gh, u_int32_t nlbufsiz);
@@ -57,5 +58,7 @@ extern struct nfulnl_msg_packet_hw *nflog_get_packet_hw(struct nflog_data *nfad)
extern int nflog_get_payload(struct nflog_data *nfad, char **data);
extern char *nflog_get_prefix(struct nflog_data *nfad);
extern int nflog_get_uid(struct nflog_data *nfad, u_int32_t *uid);
+extern int nflog_get_seq(struct nflog_data *nfad, u_int32_t *seq);
+extern int nflog_get_seq_global(struct nflog_data *nfad, u_int32_t *seq);
#endif /* __LIBNETFILTER_LOG_H */
diff --git a/include/libnetfilter_log/linux_nfnetlink_log.h b/include/libnetfilter_log/linux_nfnetlink_log.h
index 4b32211..12787e7 100644
--- a/include/libnetfilter_log/linux_nfnetlink_log.h
+++ b/include/libnetfilter_log/linux_nfnetlink_log.h
@@ -51,6 +51,8 @@ enum nfulnl_attr_type {
NFULA_PAYLOAD, /* opaque data payload */
NFULA_PREFIX, /* string prefix */
NFULA_UID, /* user id of socket */
+ NFULA_SEQ, /* instance-local sequence number */
+ NFULA_SEQ_GLOBAL, /* global sequence number */
__NFULA_MAX
};
@@ -81,6 +83,7 @@ enum nfulnl_attr_config {
NFULA_CFG_NLBUFSIZ, /* u_int32_t buffer size */
NFULA_CFG_TIMEOUT, /* u_int32_t in 1/100 s */
NFULA_CFG_QTHRESH, /* u_int32_t */
+ NFULA_CFG_FLAGS, /* u_int16_t */
__NFULA_CFG_MAX
};
#define NFULA_CFG_MAX (__NFULA_CFG_MAX -1)
@@ -89,4 +92,7 @@ enum nfulnl_attr_config {
#define NFULNL_COPY_META 0x01
#define NFULNL_COPY_PACKET 0x02
+#define NFULNL_CFG_F_SEQ 0x0001
+#define NFULNL_CFG_F_SEQ_GLOBAL 0x0002
+
#endif /* _NFNETLINK_LOG_H */
diff --git a/src/libnetfilter_log.c b/src/libnetfilter_log.c
index 4685738..95537d8 100644
--- a/src/libnetfilter_log.c
+++ b/src/libnetfilter_log.c
@@ -353,6 +353,19 @@ int nflog_set_nlbufsiz(struct nflog_g_handle *gh, u_int32_t nlbufsiz)
return status;
}
+int nflog_set_flags(struct nflog_g_handle *gh, u_int16_t flags)
+{
+ char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int16_t))];
+ struct nlmsghdr *nmh = (struct nlmsghdr *) buf;
+
+ nfnl_fill_hdr(gh->h->nfnlssh, nmh, 0, AF_UNSPEC, gh->id,
+ NFULNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK);
+
+ nfnl_addattr16(nmh, sizeof(buf), NFULA_CFG_FLAGS, htons(flags));
+
+ return nfnl_talk(gh->h->nfnlh, nmh, 0, 0, NULL, NULL, NULL);
+}
+
struct nfulnl_msg_packet_hdr *nflog_get_msg_packet_hdr(struct nflog_data *nfad)
{
@@ -429,3 +442,20 @@ int nflog_get_uid(struct nflog_data *nfad, u_int32_t *uid)
return 0;
}
+int nflog_get_seq(struct nflog_data *nfad, u_int32_t *seq)
+{
+ if (!nfnl_attr_present(nfad->nfa, NFULA_SEQ))
+ return -1;
+
+ *seq = ntohl(nfnl_get_data(nfad->nfa, NFULA_SEQ, u_int32_t));
+ return 0;
+}
+
+int nflog_get_seq_global(struct nflog_data *nfad, u_int32_t *seq)
+{
+ if (!nfnl_attr_present(nfad->nfa, NFULA_SEQ_GLOBAL))
+ return -1;
+
+ *seq = ntohl(nfnl_get_data(nfad->nfa, NFULA_SEQ_GLOBAL, u_int32_t));
+ return 0;
+}