Blame libipq/ipq_message_type.3

Packit Service d1fe03
.TH IPQ_MESSAGE_TYPE 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual" 
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     Copyright (c) 2000-2001 Netfilter Core Team
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     This program is free software; you can redistribute it and/or modify
Packit Service d1fe03
.\"     it under the terms of the GNU General Public License as published by
Packit Service d1fe03
.\"     the Free Software Foundation; either version 2 of the License, or
Packit Service d1fe03
.\"     (at your option) any later version.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     This program is distributed in the hope that it will be useful,
Packit Service d1fe03
.\"     but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service d1fe03
.\"     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service d1fe03
.\"     GNU General Public License for more details.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"     You should have received a copy of the GNU General Public License
Packit Service d1fe03
.\"     along with this program; if not, write to the Free Software
Packit Service d1fe03
.\"     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit Service d1fe03
.\"
Packit Service d1fe03
.\"
Packit Service d1fe03
.SH NAME
Packit Service d1fe03
ipq_message_type, ipq_get_packet, ipq_getmsgerr \(em query queue messages
Packit Service d1fe03
.SH SYNOPSIS
Packit Service d1fe03
.B #include <linux/netfilter.h>
Packit Service d1fe03
.br
Packit Service d1fe03
.B #include <libipq.h>
Packit Service d1fe03
.sp
Packit Service d1fe03
.BI "int ipq_message_type(const unsigned char *" buf ");"
Packit Service d1fe03
.br
Packit Service d1fe03
.BI "ipq_packet_msg_t *ipq_get_packet(const unsigned char *" buf ");"
Packit Service d1fe03
.br
Packit Service d1fe03
.BI "int ipq_get_msgerr(const unsigned char *" buf ");"
Packit Service d1fe03
.SH DESCRIPTION
Packit Service d1fe03
The
Packit Service d1fe03
.B ipq_message_type
Packit Service d1fe03
function returns the type of queue message returned to userspace
Packit Service d1fe03
via
Packit Service d1fe03
.BR ipq_read .
Packit Service d1fe03
.PP
Packit Service d1fe03
.B ipq_message_type
Packit Service d1fe03
should always be called following a successful call to
Packit Service d1fe03
.B ipq_read
Packit Service d1fe03
to determine whether the message is a packet message or an
Packit Service d1fe03
error message. The
Packit Service d1fe03
.I buf
Packit Service d1fe03
parameter should be the same data obtained from
Packit Service d1fe03
the previous call to
Packit Service d1fe03
.BR ipq_read .
Packit Service d1fe03
.PP
Packit Service d1fe03
.B ipq_message_type
Packit Service d1fe03
will return one of the following values:
Packit Service d1fe03
.TP
Packit Service d1fe03
.B NLMSG_ERROR
Packit Service d1fe03
An error message generated by the Netlink transport.
Packit Service d1fe03
.PP
Packit Service d1fe03
.TP
Packit Service d1fe03
.B IPQM_PACKET
Packit Service d1fe03
A packet message containing packet metadata and optional packet payload data.
Packit Service d1fe03
.PP
Packit Service d1fe03
The
Packit Service d1fe03
.B ipq_get_packet
Packit Service d1fe03
function should be called if
Packit Service d1fe03
.B ipq_message_type
Packit Service d1fe03
returns
Packit Service d1fe03
.BR IPQM_PACKET .
Packit Service d1fe03
The
Packit Service d1fe03
.I buf
Packit Service d1fe03
parameter should point to the same data used for the call to
Packit Service d1fe03
.BR ipq_message_type .
Packit Service d1fe03
The pointer returned by
Packit Service d1fe03
.B ipq_get_packet
Packit Service d1fe03
points to a packet message, which is declared as follows:
Packit Service d1fe03
.PP
Packit Service d1fe03
.RS
Packit Service d1fe03
.nf
Packit Service d1fe03
typedef struct ipq_packet_msg {
Packit Service d1fe03
	unsigned long packet_id;        /* ID of queued packet */
Packit Service d1fe03
	unsigned long mark;             /* Netfilter mark value */
Packit Service d1fe03
	long timestamp_sec;             /* Packet arrival time (seconds) */
Packit Service d1fe03
	long timestamp_usec;            /* Packet arrvial time (+useconds) */
Packit Service d1fe03
	unsigned int hook;              /* Netfilter hook we rode in on */
Packit Service d1fe03
	char indev_name[IFNAMSIZ];      /* Name of incoming interface */
Packit Service d1fe03
	char outdev_name[IFNAMSIZ];     /* Name of outgoing interface */
Packit Service d1fe03
	unsigned short hw_protocol;     /* Hardware protocol (network order) */
Packit Service d1fe03
	unsigned short hw_type;         /* Hardware type */
Packit Service d1fe03
	unsigned char hw_addrlen;       /* Hardware address length */
Packit Service d1fe03
	unsigned char hw_addr[8];       /* Hardware address */
Packit Service d1fe03
	size_t data_len;                /* Length of packet data */
Packit Service d1fe03
	unsigned char payload[0];       /* Optional packet data */
Packit Service d1fe03
} ipq_packet_msg_t;
Packit Service d1fe03
.fi
Packit Service d1fe03
.RE
Packit Service d1fe03
.PP
Packit Service d1fe03
Each of these fields may be read by the application.  If the queue mode
Packit Service d1fe03
is
Packit Service d1fe03
.B IPQ_COPY_PACKET
Packit Service d1fe03
and the
Packit Service d1fe03
.I data_len
Packit Service d1fe03
value is greater than zero, the packet payload contents may be accessed
Packit Service d1fe03
in the memory following the
Packit Service d1fe03
.B ipq_packet_msg_t
Packit Service d1fe03
structure to a range of
Packit Service d1fe03
.I data_len.
Packit Service d1fe03
.PP
Packit Service d1fe03
The
Packit Service d1fe03
.I packet_id
Packit Service d1fe03
field contains a packet identifier to be used when calling
Packit Service d1fe03
.BR ipq_set_verdict .
Packit Service d1fe03
.PP
Packit Service d1fe03
The
Packit Service d1fe03
.B ipq_get_msgerr
Packit Service d1fe03
function should be called if
Packit Service d1fe03
.B ipq_message_type
Packit Service d1fe03
returns
Packit Service d1fe03
.BR NLMSG_ERROR.
Packit Service d1fe03
The
Packit Service d1fe03
.I buf
Packit Service d1fe03
parameter should point to the same data used for the call to
Packit Service d1fe03
.BR ipq_message_type .
Packit Service d1fe03
The value returned by
Packit Service d1fe03
.B ipq_get_msgerr
Packit Service d1fe03
is set by higher level kernel code and corresponds to standard
Packit Service d1fe03
.B errno
Packit Service d1fe03
values.
Packit Service d1fe03
.SH BUGS
Packit Service d1fe03
None known.
Packit Service d1fe03
.SH AUTHOR
Packit Service d1fe03
James Morris <jmorris@intercode.com.au>
Packit Service d1fe03
.SH COPYRIGHT
Packit Service d1fe03
Copyright (c) 2000-2001 Netfilter Core Team.
Packit Service d1fe03
.PP
Packit Service d1fe03
Distributed under the GNU General Public License.
Packit Service d1fe03
.SH SEE ALSO
Packit Service d1fe03
.BR iptables (8),
Packit Service d1fe03
.BR libipq (3).