1e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* 2e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * libipq.h 3e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * 4e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * IPQ library for userspace. 5e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * 6ef798b9b7e005209deb457d1ffccab3d2bcdba96James Morris * Author: James Morris <jmorris@intercode.com.au> 7ef798b9b7e005209deb457d1ffccab3d2bcdba96James Morris * 8ef798b9b7e005209deb457d1ffccab3d2bcdba96James Morris * Copyright (c) 2000-2001 Netfilter Core Team 9ef798b9b7e005209deb457d1ffccab3d2bcdba96James Morris * 10e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * This program is free software; you can redistribute it and/or modify 11e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * it under the terms of the GNU General Public License as published by 12e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * the Free Software Foundation; either version 2 of the License, or 13e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * (at your option) any later version. 14e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * 15e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * This program is distributed in the hope that it will be useful, 16e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * but WITHOUT ANY WARRANTY; without even the implied warranty of 17e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * GNU General Public License for more details. 19e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher * 20e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher */ 21e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#ifndef _LIBIPQ_H 22e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#define _LIBIPQ_H 23e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 24e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <errno.h> 25e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <unistd.h> 26e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <fcntl.h> 27e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <sys/types.h> 28e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <sys/socket.h> 29e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <sys/uio.h> 30e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <asm/types.h> 31e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <linux/netlink.h> 32e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 33e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <linux/netfilter_ipv4/ip_queue.h> 34b0dbafaa0c9b01346d49f97acdccfb1c94def080Ryan Veetytypedef unsigned long ipq_id_t; 35e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 36e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#ifdef DEBUG_LIBIPQ 37e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#include <stdio.h> 38e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#define LDEBUG(x...) fprintf(stderr, ## x) 39e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#else 40e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#define LDEBUG(x...) 41e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#endif /* DEBUG_LIBIPQ */ 42e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 43e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher/* FIXME: glibc sucks */ 44e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#ifndef MSG_TRUNC 45e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#define MSG_TRUNC 0x20 46e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#endif 47e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 48e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherstruct ipq_handle 49e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher{ 50e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher int fd; 51e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher u_int8_t blocking; 52e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct sockaddr_nl local; 53e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher struct sockaddr_nl peer; 54e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher}; 55e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 56ffe96c5a701396fd666228034ff694ffdcd1ad10James Morrisstruct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol); 57e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 58e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherint ipq_destroy_handle(struct ipq_handle *h); 59e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 60e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherssize_t ipq_read(const struct ipq_handle *h, 61e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher unsigned char *buf, size_t len, int timeout); 62e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 63e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherint ipq_set_mode(const struct ipq_handle *h, u_int8_t mode, size_t len); 64e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 65e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucheripq_packet_msg_t *ipq_get_packet(const unsigned char *buf); 66e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 67e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherint ipq_message_type(const unsigned char *buf); 68e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 69e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherint ipq_get_msgerr(const unsigned char *buf); 70e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 71e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherint ipq_set_verdict(const struct ipq_handle *h, 72803f33c0e9cb458cf7989f3826e9baba8da19e2fRusty Russell ipq_id_t id, 73e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher unsigned int verdict, 74e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher size_t data_len, 75e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher unsigned char *buf); 76e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 77e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucherint ipq_ctl(const struct ipq_handle *h, int request, ...); 78e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 79b1e0b99aff57351419c24c618ccb00ae0fb142f9James Morrischar *ipq_errstr(void); 80e6869a8f59d779ff4d5a0984c86d80db7078496Marc Bouchervoid ipq_perror(const char *s); 81e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 82e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher#endif /* _LIBIPQ_H */ 83e6869a8f59d779ff4d5a0984c86d80db7078496Marc Boucher 84