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 #ifdef KERNEL_64_USERSPACE_32
00034 #include "ip_queue_64.h"
00035 typedef u_int64_t ipq_id_t;
00036 #else
00037 #include <linux/netfilter_ipv4/ip_queue.h>
00038 typedef unsigned long ipq_id_t;
00039 #endif
00040
00041 #ifdef DEBUG_LIBIPQ
00042 #include <stdio.h>
00043 #define LDEBUG(x...) fprintf(stderr, ## x)
00044 #else
00045 #define LDEBUG(x...)
00046 #endif
00047
00048
00049 #ifndef MSG_TRUNC
00050 #define MSG_TRUNC 0x20
00051 #endif
00052
00053 struct ipq_handle
00054 {
00055 int fd;
00056 u_int8_t blocking;
00057 struct sockaddr_nl local;
00058 struct sockaddr_nl peer;
00059 };
00060
00061 struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol);
00062
00063 int ipq_destroy_handle(struct ipq_handle *h);
00064
00065 ssize_t ipq_read(const struct ipq_handle *h,
00066 unsigned char *buf, size_t len, int timeout);
00067
00068 int ipq_set_mode(const struct ipq_handle *h, u_int8_t mode, size_t len);
00069
00070 ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf);
00071
00072 int ipq_message_type(const unsigned char *buf);
00073
00074 int ipq_get_msgerr(const unsigned char *buf);
00075
00076 int ipq_set_verdict(const struct ipq_handle *h,
00077 ipq_id_t id,
00078 unsigned int verdict,
00079 size_t data_len,
00080 unsigned char *buf);
00081
00082 int ipq_ctl(const struct ipq_handle *h, int request, ...);
00083
00084 char *ipq_errstr(void);
00085 void ipq_perror(const char *s);
00086
00087 #endif
00088