ipq_read.3 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. .TH IPQ_READ 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual"
  2. .\"
  3. .\" Copyright (c) 2000-2001 Netfilter Core Team
  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
  21. ipq_read \(em read queue messages from ip_queue and read into supplied buffer
  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
  31. function reads a queue message from the kernel and copies it to
  32. the memory pointed to by
  33. .I buf
  34. to a maximum length of
  35. . IR len .
  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
  41. .BR ipq_create_handle .
  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
  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.
  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
  65. On failure, \-1 is returned.
  66. .br
  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 .
  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.
  90. .SH BUGS
  91. None known.
  92. .SH AUTHOR
  93. James Morris <jmorris@intercode.com.au>
  94. .SH COPYRIGHT
  95. Copyright (c) 2000-2001 Netfilter Core Team.
  96. .PP
  97. Distributed under the GNU General Public License.
  98. .SH CREDITS
  99. Joost Remijn implemented the timeout feature, which appeared in the 1.2.4 release of iptables.
  100. .SH SEE ALSO
  101. .BR iptables (8),
  102. .BR libipq (3),
  103. .BR select (2).