Main Page | Class List | File List | Class Members | File Members

libipq.h

Go to the documentation of this file.
00001 /*
00002  * libipq.h
00003  *
00004  * IPQ library for userspace.
00005  *
00006  * Author: James Morris <jmorris@intercode.com.au>
00007  *
00008  * Copyright (c) 2000-2001 Netfilter Core Team
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
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  /* DEBUG_LIBIPQ */
00047 
00048 /* FIXME: glibc sucks */
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  /* _LIBIPQ_H */
00088 

Generated on Sun May 14 13:36:52 2006 by  doxygen 1.4.2