11de50e9fSSam Leffler /*
21de50e9fSSam Leffler * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
31de50e9fSSam Leffler * The Regents of the University of California. All rights reserved.
41de50e9fSSam Leffler *
51de50e9fSSam Leffler * Redistribution and use in source and binary forms, with or without
61de50e9fSSam Leffler * modification, are permitted provided that: (1) source code distributions
71de50e9fSSam Leffler * retain the above copyright notice and this paragraph in its entirety, (2)
81de50e9fSSam Leffler * distributions including binary code include the above copyright notice and
91de50e9fSSam Leffler * this paragraph in its entirety in the documentation or other materials
101de50e9fSSam Leffler * provided with the distribution, and (3) all advertising materials mentioning
111de50e9fSSam Leffler * features or use of this software display the following acknowledgement:
121de50e9fSSam Leffler * ``This product includes software developed by the University of California,
131de50e9fSSam Leffler * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
141de50e9fSSam Leffler * the University nor the names of its contributors may be used to endorse
151de50e9fSSam Leffler * or promote products derived from this software without specific prior
161de50e9fSSam Leffler * written permission.
171de50e9fSSam Leffler * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
181de50e9fSSam Leffler * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
191de50e9fSSam Leffler * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
201de50e9fSSam Leffler */
211de50e9fSSam Leffler
223340d773SGleb Smirnoff /* \summary: Symantec Enterprise Firewall printer */
233340d773SGleb Smirnoff
24*ee67461eSJoseph Mingrone #include <config.h>
251de50e9fSSam Leffler
26*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h"
271de50e9fSSam Leffler
28*ee67461eSJoseph Mingrone #define ND_LONGJMP_FROM_TCHECK
293340d773SGleb Smirnoff #include "netdissect.h"
3027df3f5dSRui Paulo #include "extract.h"
311de50e9fSSam Leffler #include "ethertype.h"
321de50e9fSSam Leffler
331de50e9fSSam Leffler struct symantec_header {
34*ee67461eSJoseph Mingrone nd_byte stuff1[6];
35*ee67461eSJoseph Mingrone nd_uint16_t ether_type;
36*ee67461eSJoseph Mingrone nd_byte stuff2[36];
371de50e9fSSam Leffler };
381de50e9fSSam Leffler
39*ee67461eSJoseph Mingrone static void
symantec_hdr_print(netdissect_options * ndo,const u_char * bp,u_int length)40*ee67461eSJoseph Mingrone symantec_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
411de50e9fSSam Leffler {
42*ee67461eSJoseph Mingrone const struct symantec_header *sp;
433c602fabSXin LI uint16_t etype;
441de50e9fSSam Leffler
451de50e9fSSam Leffler sp = (const struct symantec_header *)bp;
461de50e9fSSam Leffler
47*ee67461eSJoseph Mingrone etype = GET_BE_U_2(sp->ether_type);
483c602fabSXin LI if (!ndo->ndo_qflag) {
49*ee67461eSJoseph Mingrone if (etype <= MAX_ETHERNET_LENGTH_VAL)
50*ee67461eSJoseph Mingrone ND_PRINT("invalid ethertype %u", etype);
511de50e9fSSam Leffler else
52*ee67461eSJoseph Mingrone ND_PRINT("ethertype %s (0x%04x)",
531de50e9fSSam Leffler tok2str(ethertype_values,"Unknown", etype),
54*ee67461eSJoseph Mingrone etype);
551de50e9fSSam Leffler } else {
56*ee67461eSJoseph Mingrone if (etype <= MAX_ETHERNET_LENGTH_VAL)
57*ee67461eSJoseph Mingrone ND_PRINT("invalid ethertype %u", etype);
581de50e9fSSam Leffler else
59*ee67461eSJoseph Mingrone ND_PRINT("%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype));
601de50e9fSSam Leffler }
611de50e9fSSam Leffler
62*ee67461eSJoseph Mingrone ND_PRINT(", length %u: ", length);
631de50e9fSSam Leffler }
641de50e9fSSam Leffler
651de50e9fSSam Leffler /*
661de50e9fSSam Leffler * This is the top level routine of the printer. 'p' points
671de50e9fSSam Leffler * to the ether header of the packet, 'h->ts' is the timestamp,
681de50e9fSSam Leffler * 'h->len' is the length of the packet off the wire, and 'h->caplen'
691de50e9fSSam Leffler * is the number of bytes actually captured.
701de50e9fSSam Leffler */
71*ee67461eSJoseph Mingrone void
symantec_if_print(netdissect_options * ndo,const struct pcap_pkthdr * h,const u_char * p)723c602fabSXin LI symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
731de50e9fSSam Leffler {
741de50e9fSSam Leffler u_int length = h->len;
751de50e9fSSam Leffler u_int caplen = h->caplen;
763340d773SGleb Smirnoff const struct symantec_header *sp;
771de50e9fSSam Leffler u_short ether_type;
781de50e9fSSam Leffler
79*ee67461eSJoseph Mingrone ndo->ndo_protocol = "symantec";
80*ee67461eSJoseph Mingrone ND_TCHECK_LEN(p, sizeof(struct symantec_header));
811de50e9fSSam Leffler
82*ee67461eSJoseph Mingrone ndo->ndo_ll_hdr_len += sizeof (struct symantec_header);
833c602fabSXin LI if (ndo->ndo_eflag)
843c602fabSXin LI symantec_hdr_print(ndo, p, length);
851de50e9fSSam Leffler
861de50e9fSSam Leffler length -= sizeof (struct symantec_header);
871de50e9fSSam Leffler caplen -= sizeof (struct symantec_header);
883340d773SGleb Smirnoff sp = (const struct symantec_header *)p;
891de50e9fSSam Leffler p += sizeof (struct symantec_header);
901de50e9fSSam Leffler
91*ee67461eSJoseph Mingrone ether_type = GET_BE_U_2(sp->ether_type);
921de50e9fSSam Leffler
93*ee67461eSJoseph Mingrone if (ether_type <= MAX_ETHERNET_LENGTH_VAL) {
941de50e9fSSam Leffler /* ether_type not known, print raw packet */
953c602fabSXin LI if (!ndo->ndo_eflag)
963340d773SGleb Smirnoff symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
971de50e9fSSam Leffler
983c602fabSXin LI if (!ndo->ndo_suppress_default_print)
993c602fabSXin LI ND_DEFAULTPRINT(p, caplen);
1003340d773SGleb Smirnoff } else if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) {
1011de50e9fSSam Leffler /* ether_type not known, print raw packet */
1023c602fabSXin LI if (!ndo->ndo_eflag)
1033340d773SGleb Smirnoff symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
1041de50e9fSSam Leffler
1053c602fabSXin LI if (!ndo->ndo_suppress_default_print)
1063c602fabSXin LI ND_DEFAULTPRINT(p, caplen);
1071de50e9fSSam Leffler }
1081de50e9fSSam Leffler }
109