Blame libipq/ipq_read.3

Packit Service d1fe03
.TH IPQ_READ 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual" 
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     Copyright (c) 2000-2001 Netfilter Core Team
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     This program is free software; you can redistribute it and/or modify
Packit Service d1fe03
.\"     it under the terms of the GNU General Public License as published by
Packit Service d1fe03
.\"     the Free Software Foundation; either version 2 of the License, or
Packit Service d1fe03
.\"     (at your option) any later version.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     This program is distributed in the hope that it will be useful,
Packit Service d1fe03
.\"     but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service d1fe03
.\"     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service d1fe03
.\"     GNU General Public License for more details.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     You should have received a copy of the GNU General Public License
Packit Service d1fe03
.\"     along with this program; if not, write to the Free Software
Packit Service d1fe03
.\"     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"
Packit Service d1fe03
.SH NAME
Packit Service d1fe03
ipq_read \(em read queue messages from ip_queue and read into supplied buffer
Packit Service d1fe03
.SH SYNOPSIS
Packit Service d1fe03
.B #include <linux/netfilter.h>
Packit Service d1fe03
.br
Packit Service d1fe03
.B #include <libipq.h>
Packit Service d1fe03
.sp
Packit Service d1fe03
.BI "ssize_t ipq_read(const struct ipq_handle *" h ", unsigned char *" buf ", size_t " len ", int " timeout ");"
Packit Service d1fe03
.SH DESCRIPTION
Packit Service d1fe03
The
Packit Service d1fe03
.B ipq_read
Packit Service d1fe03
function reads a queue message from the kernel and copies it to
Packit Service d1fe03
the memory pointed to by 
Packit Service d1fe03
.I buf
Packit Service d1fe03
to a maximum length of
Packit Service d1fe03
. IR len .
Packit Service d1fe03
.PP
Packit Service d1fe03
The
Packit Service d1fe03
.I h
Packit Service d1fe03
parameter is a context handle which must previously have been returned 
Packit Service d1fe03
successfully from a call to
Packit Service d1fe03
.BR ipq_create_handle .
Packit Service d1fe03
.PP
Packit Service d1fe03
The caller is responsible for ensuring that the memory pointed to by
Packit Service d1fe03
.I buf
Packit Service d1fe03
is large enough to contain
Packit Service d1fe03
.I len
Packit Service d1fe03
bytes.
Packit Service d1fe03
.PP
Packit Service d1fe03
The
Packit Service d1fe03
.I timeout
Packit Service d1fe03
parameter may be used to set a timeout for the operation, specified in microseconds.
Packit Service d1fe03
This is implemented internally by the library via the
Packit Service d1fe03
.BR select
Packit Service d1fe03
system call.  A value of zero provides normal, backwards-compatible blocking behaviour
Packit Service d1fe03
with no timeout.  A negative value causes the function to return immediately.
Packit Service d1fe03
.PP
Packit Service d1fe03
Data returned via
Packit Service d1fe03
.I buf
Packit Service d1fe03
should not be accessed directly.  Use the 
Packit Service d1fe03
.BR ipq_message_type ,
Packit Service d1fe03
.BR ipq_get_packet ", and"
Packit Service d1fe03
.BR ipq_get_msgerr
Packit Service d1fe03
functions to access the queue message in the buffer.
Packit Service d1fe03
.SH RETURN VALUE
Packit Service d1fe03
On failure, \-1 is returned.
Packit Service d1fe03
.br
Packit Service d1fe03
On success, a non-zero positive value is returned when no timeout
Packit Service d1fe03
value is specified.
Packit Service d1fe03
.br
Packit Service d1fe03
On success with a timeout value specified, zero is returned if no data
Packit Service d1fe03
was available to read, or if a non-blocked signal was caught.  In the
Packit Service d1fe03
latter case, the global
Packit Service d1fe03
.B errno
Packit Service d1fe03
value will be set to 
Packit Service d1fe03
.BR EINTR .
Packit Service d1fe03
.SH ERRORS
Packit Service d1fe03
On error, a descriptive error message will be available
Packit Service d1fe03
via the
Packit Service d1fe03
.B ipq_errstr
Packit Service d1fe03
function.
Packit Service d1fe03
.SH DIAGNOSTICS
Packit Service d1fe03
While the
Packit Service d1fe03
.B ipq_read
Packit Service d1fe03
function may return successfully, the queue message copied to the buffer
Packit Service d1fe03
may itself be an error message from a higher level kernel component.  Use
Packit Service d1fe03
.B ipq_message_type
Packit Service d1fe03
to determine if it is an error message, and
Packit Service d1fe03
.B ipq_get_msgerr
Packit Service d1fe03
to access the value of the message.
Packit Service d1fe03
.SH BUGS
Packit Service d1fe03
None known.
Packit Service d1fe03
.SH AUTHOR
Packit Service d1fe03
James Morris <jmorris@intercode.com.au>
Packit Service d1fe03
.SH COPYRIGHT
Packit Service d1fe03
Copyright (c) 2000-2001 Netfilter Core Team.
Packit Service d1fe03
.PP
Packit Service d1fe03
Distributed under the GNU General Public License.
Packit Service d1fe03
.SH CREDITS
Packit Service d1fe03
Joost Remijn implemented the timeout feature, which appeared in the 1.2.4 release of iptables.
Packit Service d1fe03
.SH SEE ALSO
Packit Service d1fe03
.BR iptables (8),
Packit Service d1fe03
.BR libipq (3),
Packit Service d1fe03
.BR select (2).
Packit Service d1fe03