1 | #include <machine/rtems-bsd-user-space.h> |
---|
2 | |
---|
3 | /* $OpenBSD: print-enc.c,v 1.7 2002/02/19 19:39:40 millert Exp $ */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 |
---|
7 | * The Regents of the University of California. All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that: (1) source code distributions |
---|
11 | * retain the above copyright notice and this paragraph in its entirety, (2) |
---|
12 | * distributions including binary code include the above copyright notice and |
---|
13 | * this paragraph in its entirety in the documentation or other materials |
---|
14 | * provided with the distribution, and (3) all advertising materials mentioning |
---|
15 | * features or use of this software display the following acknowledgement: |
---|
16 | * ``This product includes software developed by the University of California, |
---|
17 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of |
---|
18 | * the University nor the names of its contributors may be used to endorse |
---|
19 | * or promote products derived from this software without specific prior |
---|
20 | * written permission. |
---|
21 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
---|
22 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
---|
23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
24 | */ |
---|
25 | |
---|
26 | #ifndef lint |
---|
27 | static const char rcsid[] _U_ = |
---|
28 | "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.6 2008-11-18 07:35:32 guy Exp $ (LBL)"; |
---|
29 | #endif |
---|
30 | |
---|
31 | #ifdef HAVE_CONFIG_H |
---|
32 | #include "config.h" |
---|
33 | #endif |
---|
34 | |
---|
35 | #include <tcpdump-stdinc.h> |
---|
36 | |
---|
37 | #include <pcap.h> |
---|
38 | |
---|
39 | #include "interface.h" |
---|
40 | #include "extract.h" |
---|
41 | #include "addrtoname.h" |
---|
42 | |
---|
43 | #include "enc.h" |
---|
44 | |
---|
45 | #define ENC_PRINT_TYPE(wh, xf, nam) \ |
---|
46 | if ((wh) & (xf)) { \ |
---|
47 | printf("%s%s", nam, (wh) == (xf) ? "): " : ","); \ |
---|
48 | (wh) &= ~(xf); \ |
---|
49 | } |
---|
50 | |
---|
51 | u_int |
---|
52 | enc_if_print(const struct pcap_pkthdr *h, register const u_char *p) |
---|
53 | { |
---|
54 | register u_int length = h->len; |
---|
55 | register u_int caplen = h->caplen; |
---|
56 | int flags; |
---|
57 | const struct enchdr *hdr; |
---|
58 | |
---|
59 | if (caplen < ENC_HDRLEN) { |
---|
60 | printf("[|enc]"); |
---|
61 | goto out; |
---|
62 | } |
---|
63 | |
---|
64 | hdr = (struct enchdr *)p; |
---|
65 | flags = hdr->flags; |
---|
66 | if (flags == 0) |
---|
67 | printf("(unprotected): "); |
---|
68 | else |
---|
69 | printf("("); |
---|
70 | ENC_PRINT_TYPE(flags, M_AUTH, "authentic"); |
---|
71 | ENC_PRINT_TYPE(flags, M_CONF, "confidential"); |
---|
72 | /* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */ |
---|
73 | printf("SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi)); |
---|
74 | |
---|
75 | length -= ENC_HDRLEN; |
---|
76 | caplen -= ENC_HDRLEN; |
---|
77 | p += ENC_HDRLEN; |
---|
78 | |
---|
79 | switch (hdr->af) { |
---|
80 | case AF_INET: |
---|
81 | ip_print(gndo, p, length); |
---|
82 | break; |
---|
83 | #ifdef INET6 |
---|
84 | case AF_INET6: |
---|
85 | ip6_print(gndo, p, length); |
---|
86 | break; |
---|
87 | #endif /*INET6*/ |
---|
88 | } |
---|
89 | |
---|
90 | out: |
---|
91 | return (ENC_HDRLEN); |
---|
92 | } |
---|
93 | |
---|
94 | |
---|
95 | /* |
---|
96 | * Local Variables: |
---|
97 | * c-style: whitesmith |
---|
98 | * c-basic-offset: 8 |
---|
99 | * End: |
---|
100 | */ |
---|