source: rtems-libbsd/freebsd/contrib/tcpdump/print-ppi.c @ 084d4db

4.11
Last change on this file since 084d4db was 8440506, checked in by Chris Johns <chrisj@…>, on 06/15/15 at 07:42:23

Add tcpdump and libpcap.

  • Update the file builder generator to handle generator specific cflags and includes. The tcpdump and libpcap have localised headers and need specific headers paths to see them. There are also module specific flags and these need to be passed to the lex and yacc generators.
  • Add the tcpdump support.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1#include <machine/rtems-bsd-user-space.h>
2
3/*
4 * Oracle
5 */
6#ifdef HAVE_CONFIG_H
7#include "config.h"
8#endif
9
10#include <tcpdump-stdinc.h>
11
12#include <stdio.h>
13#include <pcap.h>
14
15#include "netdissect.h"
16#include "interface.h"
17#include "extract.h"
18#include "ppi.h"
19
20#ifdef DLT_PPI
21
22static inline void
23ppi_header_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
24{
25        const ppi_header_t *hdr;
26        u_int32_t dlt;
27        u_int16_t len;
28
29        hdr = (const ppi_header_t *)bp;
30
31        len = EXTRACT_16BITS(&hdr->ppi_len);
32        dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
33
34        if (!ndo->ndo_qflag) {
35                ND_PRINT((ndo,", V.%d DLT %s (%d) len %d", hdr->ppi_ver,
36                          pcap_datalink_val_to_name(dlt), dlt,
37                          len));
38        } else {
39                ND_PRINT((ndo,", %s", pcap_datalink_val_to_name(dlt)));
40        }
41
42        ND_PRINT((ndo, ", length %u: ", length));
43}
44
45static void
46ppi_print(struct netdissect_options *ndo,
47               const struct pcap_pkthdr *h, const u_char *p)
48{
49        if_ndo_printer ndo_printer;
50        if_printer printer;
51        ppi_header_t *hdr;
52        u_int caplen = h->caplen;
53        u_int length = h->len;
54        u_int32_t dlt;
55
56        if (caplen < sizeof(ppi_header_t)) {
57                ND_PRINT((ndo, "[|ppi]"));
58                return;
59        }
60        hdr = (ppi_header_t *)p;
61        dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
62
63        if (ndo->ndo_eflag)
64                ppi_header_print(ndo, p, length);
65
66        length -= sizeof(ppi_header_t);
67        caplen -= sizeof(ppi_header_t);
68        p += sizeof(ppi_header_t);
69
70        if ((printer = lookup_printer(dlt)) != NULL) {
71                printer(h, p);
72        } else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
73                ndo_printer(ndo, h, p);
74        } else {
75                if (!ndo->ndo_eflag)
76                        ppi_header_print(ndo, (u_char *)hdr,
77                                        length + sizeof(ppi_header_t));
78
79                if (!ndo->ndo_suppress_default_print)
80                        ndo->ndo_default_print(ndo, p, caplen);
81        }
82}
83
84/*
85 * This is the top level routine of the printer.  'p' points
86 * to the ether header of the packet, 'h->ts' is the timestamp,
87 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
88 * is the number of bytes actually captured.
89 */
90u_int
91ppi_if_print(struct netdissect_options *ndo,
92               const struct pcap_pkthdr *h, const u_char *p)
93{
94        ppi_print(ndo, h, p);
95
96        return (sizeof(ppi_header_t));
97}
98
99/*
100 * Local Variables:
101 * c-style: whitesmith
102 * c-basic-offset: 8
103 * End:
104 */
105
106#endif /* DLT_PPI */
Note: See TracBrowser for help on using the repository browser.