00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _LIBIPQ_H
00022 #define _LIBIPQ_H
00023
00024 #include <errno.h>
00025 #include <unistd.h>
00026 #include <fcntl.h>
00027 #include <sys/types.h>
00028 #include <sys/socket.h>
00029 #include <sys/uio.h>
00030 #include <asm/types.h>
00031 #include <linux/netlink.h>
00032
00033 #include <linux/netfilter_ipv4/ip_queue.h>
00034 typedef unsigned long ipq_id_t;
00035
00036 #ifdef DEBUG_LIBIPQ
00037 #include <stdio.h>
00038 #define LDEBUG(x...) fprintf(stderr, ## x)
00039 #else
00040 #define LDEBUG(x...)
00041 #endif
00042
00043
00044 #ifndef MSG_TRUNC
00045 #define MSG_TRUNC 0x20
00046 #endif
00047
00048 struct ipq_handle
00049 {
00050 int fd;
00051 u_int8_t blocking;
00052 struct sockaddr_nl local;
00053 struct sockaddr_nl peer;
00054 };
00055
00056 struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol);
00057
00058 int ipq_destroy_handle(struct ipq_handle *h);
00059
00060 ssize_t ipq_read(const struct ipq_handle *h,
00061 unsigned char *buf, size_t len, int timeout);
00062
00063 int ipq_set_mode(const struct ipq_handle *h, u_int8_t mode, size_t len);
00064
00065 ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf);
00066
00067 int ipq_message_type(const unsigned char *buf);
00068
00069 int ipq_get_msgerr(const unsigned char *buf);
00070
00071 int ipq_set_verdict(const struct ipq_handle *h,
00072 ipq_id_t id,
00073 unsigned int verdict,
00074 size_t data_len,
00075 unsigned char *buf);
00076
00077 int ipq_ctl(const struct ipq_handle *h, int request, ...);
00078
00079 char *ipq_errstr(void);
00080 void ipq_perror(const char *s);
00081
00082 #endif
00083