blob: 5d967376bf1979ba27fd020cfef680adf5aba11a [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001.TH IPQ_READ 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual"
2.\"
3.\" $Id: ipq_read.3,v 1.2 2001/10/16 14:41:02 jamesm Exp $
4.\"
5.\" Copyright (c) 2000-2001 Netfilter Core Team
6.\"
7.\" This program is free software; you can redistribute it and/or modify
8.\" it under the terms of the GNU General Public License as published by
9.\" the Free Software Foundation; either version 2 of the License, or
10.\" (at your option) any later version.
11.\"
12.\" This program is distributed in the hope that it will be useful,
13.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
14.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15.\" GNU General Public License for more details.
16.\"
17.\" You should have received a copy of the GNU General Public License
18.\" along with this program; if not, write to the Free Software
19.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20.\"
21.\"
22.SH NAME
23ipq_read - read queue messages from ip_queue and read into supplied buffer
24.SH SYNOPSIS
25.B #include <linux/netfilter.h>
26.br
27.B #include <libipq.h>
28.sp
29.BI "ssize_t ipq_read(const struct ipq_handle *" h ", unsigned char *" buf ", size_t " len ", int " timeout ");"
30.SH DESCRIPTION
31The
32.B ipq_read
33function reads a queue message from the kernel and copies it to
34the memory pointed to by
35.I buf
36to a maximum length of
37. IR len .
38.PP
39The
40.I h
41parameter is a context handle which must previously have been returned
42successfully from a call to
43.BR ipq_create_handle .
44.PP
45The caller is responsible for ensuring that the memory pointed to by
46.I buf
47is large enough to contain
48.I len
49bytes.
50.PP
51The
52.I timeout
53parameter may be used to set a timeout for the operation, specified in microseconds.
54This is implemented internally by the library via the
55.BR select
56system call. A value of zero provides normal, backwards-compatible blocking behaviour
57with no timeout. A negative value causes the function to return immediately.
58.PP
59Data returned via
60.I buf
61should not be accessed directly. Use the
62.BR ipq_message_type ,
63.BR ipq_get_packet ", and"
64.BR ipq_get_msgerr
65functions to access the queue message in the buffer.
66.SH RETURN VALUE
67On failure, -1 is returned.
68.br
69On success, a non-zero positive value is returned when no timeout
70value is specified.
71.br
72On success with a timeout value specified, zero is returned if no data
73was available to read, or if a non-blocked signal was caught. In the
74latter case, the global
75.B errno
76value will be set to
77.BR EINTR .
78.SH ERRORS
79On error, a descriptive error message will be available
80via the
81.B ipq_errstr
82function.
83.SH DIAGNOSTICS
84While the
85.B ipq_read
86function may return successfully, the queue message copied to the buffer
87may itself be an error message from a higher level kernel component. Use
88.B ipq_message_type
89to determine if it is an error message, and
90.B ipq_get_msgerr
91to access the value of the message.
92.SH BUGS
93None known.
94.SH AUTHOR
95James Morris <jmorris@intercode.com.au>
96.SH COPYRIGHT
97Copyright (c) 2000-2001 Netfilter Core Team.
98.PP
99Distributed under the GNU General Public License.
100.SH CREDITS
101Joost Remijn implemented the timeout feature, which appeared in the 1.2.4 release of iptables.
102.SH SEE ALSO
103.BR iptables (8),
104.BR libipq (3),
105.BR select (2).
106