1127668Sbms/* $OpenBSD: print-enc.c,v 1.7 2002/02/19 19:39:40 millert Exp $ */ 2127668Sbms 3127668Sbms/* 4127668Sbms * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 5127668Sbms * The Regents of the University of California. All rights reserved. 6127668Sbms * 7127668Sbms * Redistribution and use in source and binary forms, with or without 8127668Sbms * modification, are permitted provided that: (1) source code distributions 9127668Sbms * retain the above copyright notice and this paragraph in its entirety, (2) 10127668Sbms * distributions including binary code include the above copyright notice and 11127668Sbms * this paragraph in its entirety in the documentation or other materials 12127668Sbms * provided with the distribution, and (3) all advertising materials mentioning 13127668Sbms * features or use of this software display the following acknowledgement: 14127668Sbms * ``This product includes software developed by the University of California, 15127668Sbms * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 16127668Sbms * the University nor the names of its contributors may be used to endorse 17127668Sbms * or promote products derived from this software without specific prior 18127668Sbms * written permission. 19127668Sbms * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 20127668Sbms * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 21127668Sbms * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22127668Sbms */ 23127668Sbms 24127668Sbms#ifndef lint 25127668Sbmsstatic const char rcsid[] _U_ = 26214478Srpaulo "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.6 2008-11-18 07:35:32 guy Exp $ (LBL)"; 27127668Sbms#endif 28127668Sbms 29127668Sbms#ifdef HAVE_CONFIG_H 30127668Sbms#include "config.h" 31127668Sbms#endif 32127668Sbms 33127668Sbms#include <tcpdump-stdinc.h> 34127668Sbms 35127668Sbms#include <pcap.h> 36127668Sbms 37127668Sbms#include "interface.h" 38214478Srpaulo#include "extract.h" 39127668Sbms#include "addrtoname.h" 40127668Sbms 41127668Sbms#include "enc.h" 42127668Sbms 43127668Sbms#define ENC_PRINT_TYPE(wh, xf, nam) \ 44127668Sbms if ((wh) & (xf)) { \ 45127668Sbms printf("%s%s", nam, (wh) == (xf) ? "): " : ","); \ 46127668Sbms (wh) &= ~(xf); \ 47127668Sbms } 48127668Sbms 49127668Sbmsu_int 50127668Sbmsenc_if_print(const struct pcap_pkthdr *h, register const u_char *p) 51127668Sbms{ 52127668Sbms register u_int length = h->len; 53127668Sbms register u_int caplen = h->caplen; 54127668Sbms int flags; 55127668Sbms const struct enchdr *hdr; 56127668Sbms 57127668Sbms if (caplen < ENC_HDRLEN) { 58127668Sbms printf("[|enc]"); 59127668Sbms goto out; 60127668Sbms } 61127668Sbms 62127668Sbms hdr = (struct enchdr *)p; 63127668Sbms flags = hdr->flags; 64127668Sbms if (flags == 0) 65127668Sbms printf("(unprotected): "); 66127668Sbms else 67127668Sbms printf("("); 68127668Sbms ENC_PRINT_TYPE(flags, M_AUTH, "authentic"); 69127668Sbms ENC_PRINT_TYPE(flags, M_CONF, "confidential"); 70127668Sbms /* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */ 71214478Srpaulo printf("SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi)); 72127668Sbms 73127668Sbms length -= ENC_HDRLEN; 74190207Srpaulo caplen -= ENC_HDRLEN; 75190207Srpaulo p += ENC_HDRLEN; 76190207Srpaulo 77190207Srpaulo switch (hdr->af) { 78190207Srpaulo case AF_INET: 79190207Srpaulo ip_print(gndo, p, length); 80190207Srpaulo break; 81190221Srpaulo#ifdef INET6 82190207Srpaulo case AF_INET6: 83235530Sdelphij ip6_print(gndo, p, length); 84190207Srpaulo break; 85214478Srpaulo#endif /*INET6*/ 86190207Srpaulo } 87127668Sbms 88127668Sbmsout: 89127668Sbms return (ENC_HDRLEN); 90127668Sbms} 91146773Ssam 92146773Ssam 93146773Ssam/* 94146773Ssam * Local Variables: 95146773Ssam * c-style: whitesmith 96146773Ssam * c-basic-offset: 8 97146773Ssam * End: 98146773Ssam */ 99