1*05b00f60SXin Li /*
2*05b00f60SXin Li * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
3*05b00f60SXin Li * The Regents of the University of California. All rights reserved.
4*05b00f60SXin Li *
5*05b00f60SXin Li * Redistribution and use in source and binary forms, with or without
6*05b00f60SXin Li * modification, are permitted provided that: (1) source code distributions
7*05b00f60SXin Li * retain the above copyright notice and this paragraph in its entirety, (2)
8*05b00f60SXin Li * distributions including binary code include the above copyright notice and
9*05b00f60SXin Li * this paragraph in its entirety in the documentation or other materials
10*05b00f60SXin Li * provided with the distribution, and (3) all advertising materials mentioning
11*05b00f60SXin Li * features or use of this software display the following acknowledgement:
12*05b00f60SXin Li * ``This product includes software developed by the University of California,
13*05b00f60SXin Li * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14*05b00f60SXin Li * the University nor the names of its contributors may be used to endorse
15*05b00f60SXin Li * or promote products derived from this software without specific prior
16*05b00f60SXin Li * written permission.
17*05b00f60SXin Li * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18*05b00f60SXin Li * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19*05b00f60SXin Li * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20*05b00f60SXin Li */
21*05b00f60SXin Li
22*05b00f60SXin Li /* \summary: Symantec Enterprise Firewall printer */
23*05b00f60SXin Li
24*05b00f60SXin Li #ifdef HAVE_CONFIG_H
25*05b00f60SXin Li #include <config.h>
26*05b00f60SXin Li #endif
27*05b00f60SXin Li
28*05b00f60SXin Li #include "netdissect-stdinc.h"
29*05b00f60SXin Li
30*05b00f60SXin Li #define ND_LONGJMP_FROM_TCHECK
31*05b00f60SXin Li #include "netdissect.h"
32*05b00f60SXin Li #include "extract.h"
33*05b00f60SXin Li #include "ethertype.h"
34*05b00f60SXin Li
35*05b00f60SXin Li struct symantec_header {
36*05b00f60SXin Li nd_byte stuff1[6];
37*05b00f60SXin Li nd_uint16_t ether_type;
38*05b00f60SXin Li nd_byte stuff2[36];
39*05b00f60SXin Li };
40*05b00f60SXin Li
41*05b00f60SXin Li static void
symantec_hdr_print(netdissect_options * ndo,const u_char * bp,u_int length)42*05b00f60SXin Li symantec_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
43*05b00f60SXin Li {
44*05b00f60SXin Li const struct symantec_header *sp;
45*05b00f60SXin Li uint16_t etype;
46*05b00f60SXin Li
47*05b00f60SXin Li sp = (const struct symantec_header *)bp;
48*05b00f60SXin Li
49*05b00f60SXin Li etype = GET_BE_U_2(sp->ether_type);
50*05b00f60SXin Li if (!ndo->ndo_qflag) {
51*05b00f60SXin Li if (etype <= MAX_ETHERNET_LENGTH_VAL)
52*05b00f60SXin Li ND_PRINT("invalid ethertype %u", etype);
53*05b00f60SXin Li else
54*05b00f60SXin Li ND_PRINT("ethertype %s (0x%04x)",
55*05b00f60SXin Li tok2str(ethertype_values,"Unknown", etype),
56*05b00f60SXin Li etype);
57*05b00f60SXin Li } else {
58*05b00f60SXin Li if (etype <= MAX_ETHERNET_LENGTH_VAL)
59*05b00f60SXin Li ND_PRINT("invalid ethertype %u", etype);
60*05b00f60SXin Li else
61*05b00f60SXin Li ND_PRINT("%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype));
62*05b00f60SXin Li }
63*05b00f60SXin Li
64*05b00f60SXin Li ND_PRINT(", length %u: ", length);
65*05b00f60SXin Li }
66*05b00f60SXin Li
67*05b00f60SXin Li /*
68*05b00f60SXin Li * This is the top level routine of the printer. 'p' points
69*05b00f60SXin Li * to the ether header of the packet, 'h->ts' is the timestamp,
70*05b00f60SXin Li * 'h->len' is the length of the packet off the wire, and 'h->caplen'
71*05b00f60SXin Li * is the number of bytes actually captured.
72*05b00f60SXin Li */
73*05b00f60SXin Li void
symantec_if_print(netdissect_options * ndo,const struct pcap_pkthdr * h,const u_char * p)74*05b00f60SXin Li symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
75*05b00f60SXin Li {
76*05b00f60SXin Li u_int length = h->len;
77*05b00f60SXin Li u_int caplen = h->caplen;
78*05b00f60SXin Li const struct symantec_header *sp;
79*05b00f60SXin Li u_short ether_type;
80*05b00f60SXin Li
81*05b00f60SXin Li ndo->ndo_protocol = "symantec";
82*05b00f60SXin Li ND_TCHECK_LEN(p, sizeof(struct symantec_header));
83*05b00f60SXin Li
84*05b00f60SXin Li ndo->ndo_ll_hdr_len += sizeof (struct symantec_header);
85*05b00f60SXin Li if (ndo->ndo_eflag)
86*05b00f60SXin Li symantec_hdr_print(ndo, p, length);
87*05b00f60SXin Li
88*05b00f60SXin Li length -= sizeof (struct symantec_header);
89*05b00f60SXin Li caplen -= sizeof (struct symantec_header);
90*05b00f60SXin Li sp = (const struct symantec_header *)p;
91*05b00f60SXin Li p += sizeof (struct symantec_header);
92*05b00f60SXin Li
93*05b00f60SXin Li ether_type = GET_BE_U_2(sp->ether_type);
94*05b00f60SXin Li
95*05b00f60SXin Li if (ether_type <= MAX_ETHERNET_LENGTH_VAL) {
96*05b00f60SXin Li /* ether_type not known, print raw packet */
97*05b00f60SXin Li if (!ndo->ndo_eflag)
98*05b00f60SXin Li symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
99*05b00f60SXin Li
100*05b00f60SXin Li if (!ndo->ndo_suppress_default_print)
101*05b00f60SXin Li ND_DEFAULTPRINT(p, caplen);
102*05b00f60SXin Li } else if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) {
103*05b00f60SXin Li /* ether_type not known, print raw packet */
104*05b00f60SXin Li if (!ndo->ndo_eflag)
105*05b00f60SXin Li symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
106*05b00f60SXin Li
107*05b00f60SXin Li if (!ndo->ndo_suppress_default_print)
108*05b00f60SXin Li ND_DEFAULTPRINT(p, caplen);
109*05b00f60SXin Li }
110*05b00f60SXin Li }
111