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