Copyright (c) 2000-2001 Netfilter Core Team
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <libipq.h> "int ipq_set_mode(const struct ipq_handle *" h ", u_int8_t " mode ", size_t " range );
The h parameter is a context handle which must previously have been returned successfully from a call to ipq_create_handle .
The mode parameter must be one of:
IPQ_COPY_META Copy only packet metadata to userspace.
IPQ_COPY_PACKET Copy packet metadata and packet payloads to userspace.
The range parameter is used to specify how many bytes of the payload to copy to userspace. It is only valid for IPQ_COPY_PACKET mode and is otherwise ignored. The maximum useful value for range is 65535 (greater values will be clamped to this by ip_queue).
ipq_set_mode is usually used immediately following ipq_create_handle to enable the flow of packets to userspace.
Note that as the underlying Netlink messaging transport is connectionless, the ip_queue module does not know that a userspace application is ready to communicate until it receives a message such as this.
On success, a non-zero positive value is returned.
status = ipq_set_mode(h, IPQ_COPY_META, 0); if (status < 0) { ipq_perror("myapp"); ipq_destroy_handle(h); exit(1); }
would generate the following output:
myapp: Failed to send netlink message: Connection refused
Distributed under the GNU General Public License.