Major cleanup of the base IPFilter:
[dragonfly.git] / contrib / ipfilter / man / ipl.4
1 .TH IPL 4
2 .SH NAME
3 ipl \- IP packet log device
4 .SH DESCRIPTION
5 The \fBipl\fP pseudo device's purpose is to provide an easy way to gather
6 packet headers of packets you wish to log.  If a packet header is to be
7 logged, the entire header is logged (including any IP options \- TCP/UDP
8 options are not included when it calculates header size) or not at all.
9 The packet contents are also logged after the header.  If the log reader
10 is busy or otherwise unable to read log records, up to IPLLOGSIZE (8192 is the
11 default) bytes of data are stored.
12 .PP
13 Prepending every packet header logged is a structure containing information
14 relevant to the packet following and why it was logged.  The structure's
15 format is as follows:
16 .LP
17 .nf
18 /*
19  * Log structure.  Each packet header logged is prepended by one of these.
20  * Following this in the log records read from the device will be an ipflog
21  * structure which is then followed by any packet data.
22  */
23 typedef struct iplog    {
24         u_long  ipl_sec;
25         u_long  ipl_usec;
26         u_int   ipl_len;
27         u_int   ipl_count;
28         size_t  ipl_dsize;
29         struct  iplog   *ipl_next;
30 } iplog_t;
31
32
33 typedef struct  ipflog  {
34 #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603))
35         u_char  fl_ifname[IFNAMSIZ];
36 #else
37         u_int   fl_unit;
38         u_char  fl_ifname[4];
39 #endif
40         u_char  fl_plen;        /* extra data after hlen */
41         u_char  fl_hlen;        /* length of IP headers saved */
42         u_short fl_rule;        /* assume never more than 64k rules, total */
43         u_32_t  fl_flags;
44 } ipflog_t;
45
46 .fi
47 .PP
48 When reading from the \fBipl\fP device, it is necessary to call read(2) with
49 a buffer big enough to hold at least 1 complete log record - reading of partial
50 log records is not supported.
51 .PP
52 If the packet contents are more than 128 bytes when \fBlog body\fP is used,
53 then only 128 bytes of the packet contents is logged.
54 .PP
55 Although it is only possible to read from the \fBipl\fP device, opening it
56 for writing is required when using an ioctl which changes any kernel data.
57 .PP
58 The ioctls which are loaded with this device can be found under \fBipf(4)\fP.
59 The ioctls which are for use with logging and don't affect the filter are:
60 .LP
61 .nf
62         ioctl(fd, SIOCIPFFB, int *)
63         ioctl(fd, FIONREAD, int *)
64 .fi
65 .PP
66 The SIOCIPFFB ioctl flushes the log buffer and returns the number of bytes
67 flushed.  FIONREAD returns the number of bytes currently used for storing
68 log data.  If IPFILTER_LOG is not defined when compiling, SIOCIPFFB is not
69 available and FIONREAD will return but not do anything.
70 .PP
71 There is currently no support for non-blocking IO with this device, meaning
72 all read operations should be considered blocking in nature (if there is no
73 data to read, it will sleep until some is made available).
74 .SH SEE ALSO
75 ipf(4)
76 .SH BUGS
77 Packet headers are dropped when the internal buffer (static size) fills.
78 .SH FILES
79 /dev/ipl