| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: npf_show.c,v 1.11 2014/02/12 01:42:50 rmind Exp $ */ | | 1 | /* $NetBSD: npf_show.c,v 1.12 2014/02/19 01:43:16 rmind Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Mindaugas Rasiukevicius. | | 8 | * by Mindaugas Rasiukevicius. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * NPF configuration printing. | | 33 | * NPF configuration printing. |
34 | * | | 34 | * |
35 | * Each rule having BPF byte-code has a binary description. | | 35 | * Each rule having BPF byte-code has a binary description. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __RCSID("$NetBSD: npf_show.c,v 1.11 2014/02/12 01:42:50 rmind Exp $"); | | 39 | __RCSID("$NetBSD: npf_show.c,v 1.12 2014/02/19 01:43:16 rmind Exp $"); |
40 | | | 40 | |
41 | #include <sys/socket.h> | | 41 | #include <sys/socket.h> |
42 | #include <netinet/in.h> | | 42 | #include <netinet/in.h> |
43 | #include <netinet/tcp.h> | | 43 | #include <netinet/tcp.h> |
44 | #include <net/if.h> | | 44 | #include <net/if.h> |
45 | | | 45 | |
46 | #include <stdio.h> | | 46 | #include <stdio.h> |
47 | #include <stdlib.h> | | 47 | #include <stdlib.h> |
48 | #include <string.h> | | 48 | #include <string.h> |
49 | #include <stdbool.h> | | 49 | #include <stdbool.h> |
50 | #include <inttypes.h> | | 50 | #include <inttypes.h> |
51 | #include <errno.h> | | 51 | #include <errno.h> |
52 | #include <err.h> | | 52 | #include <err.h> |
| @@ -380,27 +380,27 @@ npfctl_print_nat(npf_conf_info_t *ctx, n | | | @@ -380,27 +380,27 @@ npfctl_print_nat(npf_conf_info_t *ctx, n |
380 | size_t alen; | | 380 | size_t alen; |
381 | u_int flags; | | 381 | u_int flags; |
382 | char *seg; | | 382 | char *seg; |
383 | | | 383 | |
384 | /* Get the interface. */ | | 384 | /* Get the interface. */ |
385 | ifname = npf_rule_getinterface(rl); | | 385 | ifname = npf_rule_getinterface(rl); |
386 | assert(ifname != NULL); | | 386 | assert(ifname != NULL); |
387 | | | 387 | |
388 | /* Get the translation address (and port, if used). */ | | 388 | /* Get the translation address (and port, if used). */ |
389 | npf_nat_getmap(nt, &addr, &alen, &port); | | 389 | npf_nat_getmap(nt, &addr, &alen, &port); |
390 | seg = npfctl_print_addrmask(alen, &addr, NPF_NO_NETMASK); | | 390 | seg = npfctl_print_addrmask(alen, &addr, NPF_NO_NETMASK); |
391 | if (port) { | | 391 | if (port) { |
392 | char *p; | | 392 | char *p; |
393 | easprintf(&p, "%s port %u", seg, port); | | 393 | easprintf(&p, "%s port %u", seg, ntohs(port)); |
394 | free(seg), seg = p; | | 394 | free(seg), seg = p; |
395 | } | | 395 | } |
396 | seg1 = seg2 = "any"; | | 396 | seg1 = seg2 = "any"; |
397 | | | 397 | |
398 | /* Get the NAT type and determine the translation segment. */ | | 398 | /* Get the NAT type and determine the translation segment. */ |
399 | switch (npf_nat_gettype(nt)) { | | 399 | switch (npf_nat_gettype(nt)) { |
400 | case NPF_NATIN: | | 400 | case NPF_NATIN: |
401 | arrow = "<-"; | | 401 | arrow = "<-"; |
402 | seg1 = seg; | | 402 | seg1 = seg; |
403 | break; | | 403 | break; |
404 | case NPF_NATOUT: | | 404 | case NPF_NATOUT: |
405 | arrow = "->"; | | 405 | arrow = "->"; |
406 | seg2 = seg; | | 406 | seg2 = seg; |