summaryrefslogtreecommitdiff
path: root/examples/netfilter/nf-queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/netfilter/nf-queue.c')
-rw-r--r--examples/netfilter/nf-queue.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/examples/netfilter/nf-queue.c b/examples/netfilter/nf-queue.c
index c66611f..957e365 100644
--- a/examples/netfilter/nf-queue.c
+++ b/examples/netfilter/nf-queue.c
@@ -9,11 +9,6 @@
#include <libmnl/libmnl.h>
#include <linux/netfilter.h>
#include <linux/netfilter/nfnetlink.h>
-
-#ifndef aligned_be64
-#define aligned_be64 u_int64_t __attribute__((aligned(8)))
-#endif
-
#include <linux/netfilter/nfnetlink_queue.h>
static int parse_attr_cb(const struct nlattr *attr, void *data)
@@ -39,14 +34,14 @@ static int parse_attr_cb(const struct nlattr *attr, void *data)
case NFQA_TIMESTAMP:
if (mnl_attr_validate2(attr, MNL_TYPE_UNSPEC,
sizeof(struct nfqnl_msg_packet_timestamp)) < 0) {
- perror("mnl_attr_validate");
+ perror("mnl_attr_validate2");
return MNL_CB_ERROR;
}
break;
case NFQA_HWADDR:
if (mnl_attr_validate2(attr, MNL_TYPE_UNSPEC,
sizeof(struct nfqnl_msg_packet_hw)) < 0) {
- perror("mnl_attr_validate");
+ perror("mnl_attr_validate2");
return MNL_CB_ERROR;
}
break;
@@ -67,9 +62,10 @@ static int queue_cb(const struct nlmsghdr *nlh, void *data)
if (tb[NFQA_PACKET_HDR]) {
ph = mnl_attr_get_payload(tb[NFQA_PACKET_HDR]);
id = ntohl(ph->packet_id);
+
+ printf("packet received (id=%u hw=0x%04x hook=%u)\n",
+ id, ntohs(ph->hw_protocol), ph->hook);
}
- printf("packet received (id=%u hw=0x%04x hook=%u)\n",
- id, ntohs(ph->hw_protocol), ph->hook);
return MNL_CB_OK + id;
}
@@ -188,28 +184,28 @@ int main(int argc, char *argv[])
nlh = nfq_build_cfg_pf_request(buf, NFQNL_CFG_CMD_PF_UNBIND);
if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
- perror("mnl_socket_send");
+ perror("mnl_socket_sendto");
exit(EXIT_FAILURE);
}
nlh = nfq_build_cfg_pf_request(buf, NFQNL_CFG_CMD_PF_BIND);
if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
- perror("mnl_socket_send");
+ perror("mnl_socket_sendto");
exit(EXIT_FAILURE);
}
nlh = nfq_build_cfg_request(buf, NFQNL_CFG_CMD_BIND, queue_num);
if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
- perror("mnl_socket_send");
+ perror("mnl_socket_sendto");
exit(EXIT_FAILURE);
}
nlh = nfq_build_cfg_params(buf, NFQNL_COPY_PACKET, 0xFFFF, queue_num);
if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
- perror("mnl_socket_send");
+ perror("mnl_socket_sendto");
exit(EXIT_FAILURE);
}
@@ -230,7 +226,7 @@ int main(int argc, char *argv[])
id = ret - MNL_CB_OK;
nlh = nfq_build_verdict(buf, id, queue_num, NF_ACCEPT);
if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
- perror("mnl_socket_send");
+ perror("mnl_socket_sendto");
exit(EXIT_FAILURE);
}