1 .\" $OpenBSD: pf.4,v 1.62 2008/09/10 14:57:37 jmc Exp $
3 .\" Copyright (C) 2001, Kjell Wooding. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
13 .\" 3. Neither the name of the project nor the names of its contributors
14 .\" may be used to endorse or promote products derived from this software
15 .\" without specific prior written permission.
17 .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 .Cd "options PF_DEFAULT_TO_DROP"
41 Packet filtering takes place in the kernel.
44 allows userland processes to control the
45 behavior of the packet filter through an
48 There are commands to enable and disable the filter, load rulesets,
49 add and remove individual rules or state table entries,
50 and retrieve statistics.
51 The most commonly used functions are covered by
54 Manipulations like loading a ruleset that involve more than a single
56 call require a so-called
58 which prevents the occurrence of
59 multiple concurrent manipulations.
63 parameter structures that refer to packet data (like
64 addresses and ports) are generally expected in network byte-order.
66 Rules and address tables are contained in so-called
70 request, if the anchor field of the argument structure is empty,
71 the kernel will use the default anchor (i.e., the main ruleset)
73 Anchors are specified by name and may be nested, with components
76 characters, similar to how file system hierarchies are laid out.
77 The final component of the anchor path is the anchor under which
78 operations will be performed.
79 .Sh SYSCTL VARIABLES AND LOADER TUNABLES
82 tunables are available.
83 .Bl -tag -width indent
84 .It Va net.pf.states_hashsize
85 Size of hash tables that store states.
87 Default value is 32768.
88 .It Va net.pf.source_nodes_hashsize
89 Size of hash table that store source nodes.
91 Default value is 8192.
96 variables with matching names are provided to obtain current values
99 The following options in the kernel configuration file are related to
103 .Bl -tag -width ".Dv PF_DEFAULT_TO_DROP" -compact
104 .It Dv PF_DEFAULT_TO_DROP
105 Change default policy to drop by default
109 supports the following
111 commands, available through
113 .Bl -tag -width xxxxxx
115 Start the packet filter.
117 Stop the packet filter.
119 Start the ALTQ bandwidth control system (see
122 Stop the ALTQ bandwidth control system.
123 .It Dv DIOCBEGINADDRS Fa "struct pfioc_pooladdr *pp"
125 struct pfioc_pooladdr {
133 char anchor[MAXPATHLEN];
134 struct pf_pooladdr addr;
138 Clear the buffer address pool and get a
146 .It Dv DIOCADDADDR Fa "struct pfioc_pooladdr *pp"
150 to the buffer address pool to be used in the following
155 All other members of the structure are ignored.
156 .It Dv DIOCADDRULE Fa "struct pfioc_rule *pr"
161 u_int32_t pool_ticket;
163 char anchor[MAXPATHLEN];
164 char anchor_call[MAXPATHLEN];
171 at the end of the inactive ruleset.
174 obtained through a preceding
182 must also be called if any pool addresses are required.
185 name indicates the anchor in which to append the rule.
190 .It Dv DIOCADDALTQ Fa "struct pfioc_altq *pa"
191 Add an ALTQ discipline or queue.
200 .It Dv DIOCGETRULES Fa "struct pfioc_rule *pr"
207 of rules in the active ruleset.
208 .It Dv DIOCGETRULE Fa "struct pfioc_rule *pr"
215 obtained through a preceding
221 .Dv PF_GET_CLR_CNTR ,
222 the per-rule statistics on the requested rule are cleared.
223 .It Dv DIOCGETADDRS Fa "struct pfioc_pooladdr *pp"
230 of pool addresses in the rule specified with
235 .It Dv DIOCGETADDR Fa "struct pfioc_pooladdr *pp"
240 from the rule specified with
247 obtained through a preceding
250 .It Dv DIOCGETALTQS Fa "struct pfioc_altq *pa"
257 of queues in the active list.
258 .It Dv DIOCGETALTQ Fa "struct pfioc_altq *pa"
259 Get the queueing discipline
265 obtained through a preceding
268 .It Dv DIOCGETQSTATS Fa "struct pfioc_qstats *pq"
269 Get the statistics on a queue.
271 struct pfioc_qstats {
280 This call fills in a pointer to the buffer of statistics
284 for the queue specified by
286 .It Dv DIOCGETRULESETS Fa "struct pfioc_ruleset *pr"
288 struct pfioc_ruleset {
290 char path[MAXPATHLEN];
291 char name[PF_ANCHOR_NAME_SIZE];
297 of rulesets (i.e., anchors) directly attached to the anchor named by
299 for use in subsequent
302 Nested anchors, since they are not directly attached to the given
303 anchor, will not be included.
306 if the given anchor does not exist.
307 .It Dv DIOCGETRULESET Fa "struct pfioc_ruleset *pr"
308 Get a ruleset (i.e., an anchor)
312 from the given anchor
314 the maximum number of which can be obtained from a preceding
319 if the given anchor does not exist or
321 if another process is concurrently updating a ruleset.
322 .It Dv DIOCADDSTATE Fa "struct pfioc_state *ps"
326 struct pfsync_state state;
329 .It Dv DIOCGETSTATE Fa "struct pfioc_state *ps"
330 Extract the entry identified by the
336 structure from the state table.
337 .It Dv DIOCKILLSTATES Fa "struct pfioc_state_kill *psk"
338 Remove matching entries from the state table.
339 This ioctl returns the number of killed states in
342 struct pfioc_state_kill {
343 struct pf_state_cmp psk_pfcmp;
346 struct pf_rule_addr psk_src;
347 struct pf_rule_addr psk_dst;
348 char psk_ifname[IFNAMSIZ];
349 char psk_label[PF_RULE_LABEL_SIZE];
353 .It Dv DIOCCLRSTATES Fa "struct pfioc_state_kill *psk"
366 .It Dv DIOCSETSTATUSIF Fa "struct pfioc_if *pi"
367 Specify the interface for which statistics are accumulated.
370 char ifname[IFNAMSIZ];
373 .It Dv DIOCGETSTATUS Fa "struct pf_status *s"
374 Get the internal packet filter statistics.
377 u_int64_t counters[PFRES_MAX];
378 u_int64_t lcounters[LCNT_MAX];
379 u_int64_t fcounters[FCNT_MAX];
380 u_int64_t scounters[SCNT_MAX];
381 u_int64_t pcounters[2][2][3];
382 u_int64_t bcounters[2][2];
389 char ifname[IFNAMSIZ];
390 u_int8_t pf_chksum[MD5_DIGEST_LENGTH];
394 Clear the internal packet filter statistics.
395 .It Dv DIOCNATLOOK Fa "struct pfioc_natlook *pnl"
396 Look up a state table entry by source and destination addresses and ports.
398 struct pfioc_natlook {
399 struct pf_addr saddr;
400 struct pf_addr daddr;
401 struct pf_addr rsaddr;
402 struct pf_addr rdaddr;
412 .It Dv DIOCSETDEBUG Fa "u_int32_t *level"
415 enum { PF_DEBUG_NONE, PF_DEBUG_URGENT, PF_DEBUG_MISC,
418 .It Dv DIOCGETSTATES Fa "struct pfioc_states *ps"
419 Get state table entries.
421 struct pfioc_states {
425 struct pf_state *psu_states;
427 #define ps_buf ps_u.psu_buf
428 #define ps_states ps_u.psu_states
434 is non-zero on entry, as many states as possible that can fit into this
435 size will be copied into the supplied buffer
439 is always set to the total size required to hold all state table entries
441 .Li sizeof(struct pf_state) * nr ) .
442 .It Dv DIOCCHANGERULE Fa "struct pfioc_rule *pcr"
445 in the ruleset specified by
448 The type of operation to be performed is indicated by
450 which can be any of the following:
452 enum { PF_CHANGE_NONE, PF_CHANGE_ADD_HEAD, PF_CHANGE_ADD_TAIL,
453 PF_CHANGE_ADD_BEFORE, PF_CHANGE_ADD_AFTER,
454 PF_CHANGE_REMOVE, PF_CHANGE_GET_TICKET };
458 must be set to the value obtained with
459 .Dv PF_CHANGE_GET_TICKET
460 for all actions except
461 .Dv PF_CHANGE_GET_TICKET .
463 must be set to the value obtained with the
465 call for all actions except
468 .Dv PF_CHANGE_GET_TICKET .
470 indicates to which anchor the operation applies.
472 indicates the rule number against which
473 .Dv PF_CHANGE_ADD_BEFORE ,
474 .Dv PF_CHANGE_ADD_AFTER ,
478 .\" It Dv DIOCCHANGEALTQ Fa "struct pfioc_altq *pcr"
479 .It Dv DIOCCHANGEADDR Fa "struct pfioc_pooladdr *pca"
480 Add or remove the pool address
482 from the rule specified by
487 .It Dv DIOCSETTIMEOUT Fa "struct pfioc_tm *pt"
495 Set the state timeout of
499 The old value will be placed into
501 For possible values of
507 .It Dv DIOCGETTIMEOUT Fa "struct pfioc_tm *pt"
508 Get the state timeout of
510 The value will be placed into the
513 .It Dv DIOCCLRRULECTRS
514 Clear per-rule statistics.
515 .It Dv DIOCSETLIMIT Fa "struct pfioc_limit *pl"
516 Set the hard limits on the memory pools used by the packet filter.
523 enum { PF_LIMIT_STATES, PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS,
524 PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_MAX };
526 .It Dv DIOCGETLIMIT Fa "struct pfioc_limit *pl"
529 for the memory pool indicated by
531 .It Dv DIOCRCLRTABLES Fa "struct pfioc_table *io"
533 All the ioctls that manipulate radix tables
534 use the same structure described below.
538 contains on exit the number of tables deleted.
541 struct pfr_table pfrio_table;
550 u_int32_t pfrio_ticket;
552 #define pfrio_exists pfrio_nadd
553 #define pfrio_nzero pfrio_nadd
554 #define pfrio_nmatch pfrio_nadd
555 #define pfrio_naddr pfrio_size2
556 #define pfrio_setflag pfrio_size2
557 #define pfrio_clrflag pfrio_nadd
559 .It Dv DIOCRADDTABLES Fa "struct pfioc_table *io"
560 Create one or more tables.
563 must point to an array of
570 .Vt struct pfr_table .
573 contains the number of tables effectively created.
576 char pfrt_anchor[MAXPATHLEN];
577 char pfrt_name[PF_TABLE_NAME_SIZE];
578 u_int32_t pfrt_flags;
582 .It Dv DIOCRDELTABLES Fa "struct pfioc_table *io"
583 Delete one or more tables.
586 must point to an array of
593 .Vt struct pfr_table .
596 contains the number of tables effectively deleted.
597 .It Dv DIOCRGETTABLES Fa "struct pfioc_table *io"
598 Get the list of all tables.
600 .Va pfrio_buffer[pfrio_size]
601 contains a valid writeable buffer for
606 contains the number of tables written into the buffer.
607 If the buffer is too small, the kernel does not store anything but just
608 returns the required buffer size, without error.
609 .It Dv DIOCRGETTSTATS Fa "struct pfioc_table *io"
612 but is used to get an array of
617 struct pfr_table pfrts_t;
618 u_int64_t pfrts_packets
619 [PFR_DIR_MAX][PFR_OP_TABLE_MAX];
620 u_int64_t pfrts_bytes
621 [PFR_DIR_MAX][PFR_OP_TABLE_MAX];
622 u_int64_t pfrts_match;
623 u_int64_t pfrts_nomatch;
626 int pfrts_refcnt[PFR_REFCNT_MAX];
628 #define pfrts_name pfrts_t.pfrt_name
629 #define pfrts_flags pfrts_t.pfrt_flags
631 .It Dv DIOCRCLRTSTATS Fa "struct pfioc_table *io"
632 Clear the statistics of one or more tables.
635 must point to an array of
642 .Vt struct pfr_table .
645 contains the number of tables effectively cleared.
646 .It Dv DIOCRCLRADDRS Fa "struct pfioc_table *io"
647 Clear all addresses in a table.
650 contains the table to clear.
653 contains the number of addresses removed.
654 .It Dv DIOCRADDADDRS Fa "struct pfioc_table *io"
655 Add one or more addresses to a table.
658 contains the table ID and
660 must point to an array of
664 elements to add to the table.
667 .Vt struct pfr_addr .
670 contains the number of addresses effectively added.
674 struct in_addr _pfra_ip4addr;
675 struct in6_addr _pfra_ip6addr;
682 #define pfra_ip4addr pfra_u._pfra_ip4addr
683 #define pfra_ip6addr pfra_u._pfra_ip6addr
685 .It Dv DIOCRDELADDRS Fa "struct pfioc_table *io"
686 Delete one or more addresses from a table.
689 contains the table ID and
691 must point to an array of
695 elements to delete from the table.
698 .Vt struct pfr_addr .
701 contains the number of addresses effectively deleted.
702 .It Dv DIOCRSETADDRS Fa "struct pfioc_table *io"
703 Replace the content of a table by a new address list.
704 This is the most complicated command, which uses all the structure members.
708 contains the table ID and
710 must point to an array of
714 elements which become the new contents of the table.
717 .Vt struct pfr_addr .
721 .Va pfrio_buffer[pfrio_size..pfrio_size2]
722 must be a writeable buffer, into which the kernel can copy the
723 addresses that have been deleted during the replace operation.
729 contain the number of addresses deleted, added, and changed by the
735 will point to the size of the buffer used, exactly like
737 .It Dv DIOCRGETADDRS Fa "struct pfioc_table *io"
738 Get all the addresses of a table.
741 contains the table ID and
742 .Va pfrio_buffer[pfrio_size]
743 contains a valid writeable buffer for
748 contains the number of addresses written into the buffer.
749 If the buffer was too small, the kernel does not store anything but just
750 returns the required buffer size, without returning an error.
751 .It Dv DIOCRGETASTATS Fa "struct pfioc_table *io"
754 but is used to get an array of
759 struct pfr_addr pfras_a;
760 u_int64_t pfras_packets
761 [PFR_DIR_MAX][PFR_OP_ADDR_MAX];
762 u_int64_t pfras_bytes
763 [PFR_DIR_MAX][PFR_OP_ADDR_MAX];
767 .It Dv DIOCRCLRASTATS Fa "struct pfioc_table *io"
768 Clear the statistics of one or more addresses.
771 contains the table ID and
773 must point to an array of
777 elements to be cleared from the table.
780 .Vt struct pfr_addr .
783 contains the number of addresses effectively cleared.
784 .It Dv DIOCRTSTADDRS Fa "struct pfioc_table *io"
785 Test if the given addresses match a table.
788 contains the table ID and
790 must point to an array of
794 elements, each of which will be tested for a match in the table.
797 .Vt struct pfr_addr .
798 On exit, the kernel updates the
802 member appropriately.
803 .It Dv DIOCRSETTFLAGS Fa "struct pfioc_table *io"
807 .Dv PFR_TFLAG_PERSIST
811 must point to an array of
818 .Vt struct pfr_table .
820 must contain the flags to add, while
822 must contain the flags to remove.
827 contain the number of tables altered or deleted by the kernel.
828 Yes, tables can be deleted if one removes the
829 .Dv PFR_TFLAG_PERSIST
830 flag of an unreferenced table.
831 .It Dv DIOCRINADEFINE Fa "struct pfioc_table *io"
832 Defines a table in the inactive set.
835 contains the table ID and
836 .Va pfrio_buffer[pfrio_size]
839 structures to put in the table.
840 A valid ticket must also be supplied to
844 contains 0 if the table was already defined in the inactive list
845 or 1 if a new table has been created.
847 contains the number of addresses effectively put in the table.
848 .It Dv DIOCXBEGIN Fa "struct pfioc_trans *io"
851 int size; /* number of elements */
852 int esize; /* size of each element in bytes */
853 struct pfioc_trans_e {
855 char anchor[MAXPATHLEN];
861 Clear all the inactive rulesets specified in the
864 For each ruleset, a ticket is returned for subsequent "add rule" ioctls,
871 Ruleset types, identified by
873 include the following:
875 .Bl -tag -width PF_RULESET_FILTER -offset ind -compact
876 .It Dv PF_RULESET_SCRUB
877 Scrub (packet normalization) rules.
878 .It Dv PF_RULESET_FILTER
880 .It Dv PF_RULESET_NAT
881 NAT (Network Address Translation) rules.
882 .It Dv PF_RULESET_BINAT
883 Bidirectional NAT rules.
884 .It Dv PF_RULESET_RDR
886 .It Dv PF_RULESET_ALTQ
888 .It Dv PF_RULESET_TABLE
891 .It Dv DIOCXCOMMIT Fa "struct pfioc_trans *io"
892 Atomically switch a vector of inactive rulesets to the active rulesets.
893 This call is implemented as a standard two-phase commit, which will either
894 fail for all rulesets or completely succeed.
895 All tickets need to be valid.
898 if another process is concurrently updating some of the same rulesets.
899 .It Dv DIOCXROLLBACK Fa "struct pfioc_trans *io"
900 Clean up the kernel by undoing all changes that have taken place on the
901 inactive rulesets since the last
904 will silently ignore rulesets for which the ticket is invalid.
905 .It Dv DIOCSETHOSTID Fa "u_int32_t *hostid"
906 Set the host ID, which is used by
908 to identify which host created state table entries.
910 Flush the passive OS fingerprint table.
911 .It Dv DIOCOSFPADD Fa "struct pf_osfp_ioctl *io"
913 struct pf_osfp_ioctl {
914 struct pf_osfp_entry {
915 SLIST_ENTRY(pf_osfp_entry) fp_entry;
917 char fp_class_nm[PF_OSFP_LEN];
918 char fp_version_nm[PF_OSFP_LEN];
919 char fp_subtype_nm[PF_OSFP_LEN];
921 pf_tcpopts_t fp_tcpopts;
933 Add a passive OS fingerprint to the table.
936 to the packed fingerprint,
937 .Va fp_os.fp_class_nm
938 to the name of the class (Linux, Windows, etc),
939 .Va fp_os.fp_version_nm
940 to the name of the version (NT, 95, 98), and
941 .Va fp_os.fp_subtype_nm
942 to the name of the subtype or patchlevel.
951 are set to the TCP MSS, the TCP window size, the IP length, the IP TTL,
952 the number of TCP options, and the TCP window scaling constant of the
953 TCP SYN packet, respectively.
957 member is filled according to the
964 member contains packed TCP options.
966 .Dv PF_OSFP_TCPOPT_BITS
967 bits in the packed value.
968 Options include any of
969 .Dv PF_OSFP_TCPOPT_NOP ,
970 .Dv PF_OSFP_TCPOPT_SACK ,
971 .Dv PF_OSFP_TCPOPT_WSCALE ,
972 .Dv PF_OSFP_TCPOPT_MSS ,
974 .Dv PF_OSFP_TCPOPT_TS .
978 member is not used with this ioctl.
980 The structure's slack space must be zeroed for correct operation;
982 the whole structure to zero before filling and sending to the kernel.
983 .It Dv DIOCOSFPGET Fa "struct pf_osfp_ioctl *io"
984 Get the passive OS fingerprint number
986 from the kernel's fingerprint list.
987 The rest of the structure members will come back filled.
988 Get the whole list by repeatedly incrementing the
990 number until the ioctl returns
992 .It Dv DIOCGETSRCNODES Fa "struct pfioc_src_nodes *psn"
994 struct pfioc_src_nodes {
998 struct pf_src_node *psu_src_nodes;
1000 #define psn_buf psn_u.psu_buf
1001 #define psn_src_nodes psn_u.psu_src_nodes
1005 Get the list of source nodes kept by sticky addresses and source
1007 The ioctl must be called once with
1010 If the ioctl returns without error,
1012 will be set to the size of the buffer required to hold all the
1014 structures held in the table.
1015 A buffer of this size should then be allocated, and a pointer to this buffer
1018 The ioctl must then be called again to fill this buffer with the actual
1022 will be set to the length of the buffer actually used.
1023 .It Dv DIOCCLRSRCNODES
1024 Clear the tree of source tracking nodes.
1025 .It Dv DIOCIGETIFACES Fa "struct pfioc_iface *io"
1026 Get the list of interfaces and interface drivers known to
1028 All the ioctls that manipulate interfaces
1029 use the same structure described below:
1031 struct pfioc_iface {
1032 char pfiio_name[IFNAMSIZ];
1043 can be used to restrict the search to a specific interface or driver.
1044 .Va pfiio_buffer[pfiio_size]
1045 is the user-supplied buffer for returning the data.
1048 contains the number of
1050 entries that can fit into the buffer.
1051 The kernel will replace this value by the real number of entries it wants
1055 .Li sizeof(struct pfi_kif) .
1057 The data is returned in the
1059 structure described below:
1062 RB_ENTRY(pfi_kif) pfik_tree;
1063 char pfik_name[IFNAMSIZ];
1064 u_int64_t pfik_packets[2][2][2];
1065 u_int64_t pfik_bytes[2][2][2];
1066 u_int32_t pfik_tzero;
1068 struct pf_state_tree_lan_ext pfik_lan_ext;
1069 struct pf_state_tree_ext_gwy pfik_ext_gwy;
1070 TAILQ_ENTRY(pfi_kif) pfik_w_states;
1071 void *pfik_ah_cookie;
1072 struct ifnet *pfik_ifp;
1073 struct ifg_group *pfik_group;
1076 TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs;
1079 .It Dv DIOCSETIFFLAG Fa "struct pfioc_iface *io"
1080 Set the user setable flags (described above) of the
1082 internal interface description.
1083 The filtering process is the same as for
1084 .Dv DIOCIGETIFACES .
1086 #define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */
1088 .It Dv DIOCCLRIFFLAG Fa "struct pfioc_iface *io"
1091 above but clears the flags.
1092 .It Dv DIOCKILLSRCNODES Fa "struct pfioc_iface *io"
1093 Explicitly remove source tracking nodes.
1096 .Bl -tag -width /dev/pf -compact
1098 packet filtering device.
1101 The following example demonstrates how to use the
1103 command to find the internal host/port of a NATed connection:
1105 #include <sys/types.h>
1106 #include <sys/socket.h>
1107 #include <sys/ioctl.h>
1108 #include <sys/fcntl.h>
1110 #include <netinet/in.h>
1111 #include <net/pfvar.h>
1117 read_address(const char *s)
1121 sscanf(s, "%i.%i.%i.%i", &a, &b, &c, &d);
1122 return htonl(a << 24 | b << 16 | c << 8 | d);
1126 print_address(u_int32_t a)
1129 printf("%d.%d.%d.%d", a >> 24 & 255, a >> 16 & 255,
1130 a >> 8 & 255, a & 255);
1134 main(int argc, char *argv[])
1136 struct pfioc_natlook nl;
1140 printf("%s <gwy addr> <gwy port> <ext addr> <ext port>\\n",
1145 dev = open("/dev/pf", O_RDWR);
1147 err(1, "open(\\"/dev/pf\\") failed");
1149 memset(&nl, 0, sizeof(struct pfioc_natlook));
1150 nl.saddr.v4.s_addr = read_address(argv[1]);
1151 nl.sport = htons(atoi(argv[2]));
1152 nl.daddr.v4.s_addr = read_address(argv[3]);
1153 nl.dport = htons(atoi(argv[4]));
1155 nl.proto = IPPROTO_TCP;
1156 nl.direction = PF_IN;
1158 if (ioctl(dev, DIOCNATLOOK, &nl))
1159 err(1, "DIOCNATLOOK");
1161 printf("internal host ");
1162 print_address(nl.rsaddr.v4.s_addr);
1163 printf(":%u\\n", ntohs(nl.rsport));
1179 packet filtering mechanism first appeared in
1184 This implementation is derived from
1186 It has been heavily modified to be capable of running in multithreaded
1188 kernel and scale its performance on multiple CPUs.