James Morris | 460c747 | 2001-10-16 14:41:02 +0000 | [diff] [blame] | 1 | .TH IPQ_MESSAGE_TYPE 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_message_type, ipq_get_packet, ipq_getmsgerr \(em query queue messages |
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 "int ipq_message_type(const unsigned char *" buf ");" |
| 28 | .br |
| 29 | .BI "ipq_packet_msg_t *ipq_get_packet(const unsigned char *" buf ");" |
| 30 | .br |
| 31 | .BI "int ipq_get_msgerr(const unsigned char *" buf ");" |
| 32 | .SH DESCRIPTION |
| 33 | The |
| 34 | .B ipq_message_type |
| 35 | function returns the type of queue message returned to userspace |
| 36 | via |
| 37 | .BR ipq_read . |
| 38 | .PP |
| 39 | .B ipq_message_type |
| 40 | should always be called following a successful call to |
| 41 | .B ipq_read |
| 42 | to determine whether the message is a packet message or an |
| 43 | error message. The |
| 44 | .I buf |
| 45 | parameter should be the same data obtained from |
| 46 | the previous call to |
| 47 | .BR ipq_read . |
| 48 | .PP |
| 49 | .B ipq_message_type |
| 50 | will return one of the following values: |
| 51 | .TP |
| 52 | .B NLMSG_ERROR |
| 53 | An error message generated by the Netlink transport. |
| 54 | .PP |
| 55 | .TP |
| 56 | .B IPQM_PACKET |
| 57 | A packet message containing packet metadata and optional packet payload data. |
| 58 | .PP |
| 59 | The |
| 60 | .B ipq_get_packet |
| 61 | function should be called if |
| 62 | .B ipq_message_type |
| 63 | returns |
| 64 | .BR IPQM_PACKET . |
| 65 | The |
| 66 | .I buf |
| 67 | parameter should point to the same data used for the call to |
| 68 | .BR ipq_message_type . |
| 69 | The pointer returned by |
| 70 | .B ipq_get_packet |
| 71 | points to a packet message, which is declared as follows: |
| 72 | .PP |
| 73 | .RS |
| 74 | .nf |
| 75 | typedef struct ipq_packet_msg { |
| 76 | unsigned long packet_id; /* ID of queued packet */ |
| 77 | unsigned long mark; /* Netfilter mark value */ |
| 78 | long timestamp_sec; /* Packet arrival time (seconds) */ |
| 79 | long timestamp_usec; /* Packet arrvial time (+useconds) */ |
| 80 | unsigned int hook; /* Netfilter hook we rode in on */ |
| 81 | char indev_name[IFNAMSIZ]; /* Name of incoming interface */ |
| 82 | char outdev_name[IFNAMSIZ]; /* Name of outgoing interface */ |
| 83 | unsigned short hw_protocol; /* Hardware protocol (network order) */ |
| 84 | unsigned short hw_type; /* Hardware type */ |
| 85 | unsigned char hw_addrlen; /* Hardware address length */ |
| 86 | unsigned char hw_addr[8]; /* Hardware address */ |
| 87 | size_t data_len; /* Length of packet data */ |
| 88 | unsigned char payload[0]; /* Optional packet data */ |
| 89 | } ipq_packet_msg_t; |
| 90 | .fi |
| 91 | .RE |
| 92 | .PP |
| 93 | Each of these fields may be read by the application. If the queue mode |
| 94 | is |
| 95 | .B IPQ_COPY_PACKET |
| 96 | and the |
| 97 | .I data_len |
| 98 | value is greater than zero, the packet payload contents may be accessed |
| 99 | in the memory following the |
| 100 | .B ipq_packet_msg_t |
| 101 | structure to a range of |
| 102 | .I data_len. |
| 103 | .PP |
| 104 | The |
| 105 | .I packet_id |
| 106 | field contains a packet identifier to be used when calling |
| 107 | .BR ipq_set_verdict . |
| 108 | .PP |
| 109 | The |
| 110 | .B ipq_get_msgerr |
| 111 | function should be called if |
| 112 | .B ipq_message_type |
| 113 | returns |
| 114 | .BR NLMSG_ERROR. |
| 115 | The |
| 116 | .I buf |
| 117 | parameter should point to the same data used for the call to |
| 118 | .BR ipq_message_type . |
| 119 | The value returned by |
| 120 | .B ipq_get_msgerr |
| 121 | is set by higher level kernel code and corresponds to standard |
| 122 | .B errno |
| 123 | values. |
| 124 | .SH BUGS |
| 125 | None known. |
| 126 | .SH AUTHOR |
| 127 | James Morris <jmorris@intercode.com.au> |
| 128 | .SH COPYRIGHT |
James Morris | 460c747 | 2001-10-16 14:41:02 +0000 | [diff] [blame] | 129 | Copyright (c) 2000-2001 Netfilter Core Team. |
James Morris | 949810c | 2000-11-20 14:13:31 +0000 | [diff] [blame] | 130 | .PP |
| 131 | Distributed under the GNU General Public License. |
| 132 | .SH SEE ALSO |
| 133 | .BR iptables (8), |
| 134 | .BR libipq (3). |