blob: bc51ec72f34a48a987e3bbf1d72f678dbedfa3d1 [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001/*
2 * libipq.h
3 *
4 * IPQ library for userspace.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17#ifndef _LIBIPQ_H
18#define _LIBIPQ_H
19
20#include <errno.h>
21#include <unistd.h>
22#include <fcntl.h>
23#include <sys/types.h>
24#include <sys/socket.h>
25#include <sys/uio.h>
26#include <asm/types.h>
27#include <linux/netlink.h>
28
29#include <linux/netfilter_ipv4/ip_queue.h>
30
31#ifdef DEBUG_LIBIPQ
32#include <stdio.h>
33#define LDEBUG(x...) fprintf(stderr, ## x)
34#else
35#define LDEBUG(x...)
36#endif /* DEBUG_LIBIPQ */
37
38/* FIXME: glibc sucks */
39#ifndef MSG_TRUNC
40#define MSG_TRUNC 0x20
41#endif
42
43struct ipq_handle
44{
45 int fd;
46 u_int8_t blocking;
47 struct sockaddr_nl local;
48 struct sockaddr_nl peer;
49};
50
51struct ipq_handle *ipq_create_handle(u_int32_t flags);
52
53int ipq_destroy_handle(struct ipq_handle *h);
54
55ssize_t ipq_read(const struct ipq_handle *h,
56 unsigned char *buf, size_t len, int timeout);
57
58int ipq_set_mode(const struct ipq_handle *h, u_int8_t mode, size_t len);
59
60ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf);
61
62int ipq_message_type(const unsigned char *buf);
63
64int ipq_get_msgerr(const unsigned char *buf);
65
66int ipq_set_verdict(const struct ipq_handle *h,
67 unsigned long id,
68 unsigned int verdict,
69 size_t data_len,
70 unsigned char *buf);
71
72int ipq_ctl(const struct ipq_handle *h, int request, ...);
73
74void ipq_perror(const char *s);
75
76#endif /* _LIBIPQ_H */
77