Blame libipq/ipq_read.3

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