print-enc.c revision 146773
155714Skris/*	$OpenBSD: print-enc.c,v 1.7 2002/02/19 19:39:40 millert Exp $	*/
255714Skris
355714Skris/*
455714Skris * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
555714Skris *	The Regents of the University of California.  All rights reserved.
655714Skris *
755714Skris * Redistribution and use in source and binary forms, with or without
855714Skris * modification, are permitted provided that: (1) source code distributions
955714Skris * retain the above copyright notice and this paragraph in its entirety, (2)
1055714Skris * distributions including binary code include the above copyright notice and
1155714Skris * this paragraph in its entirety in the documentation or other materials
1255714Skris * provided with the distribution, and (3) all advertising materials mentioning
1355714Skris * features or use of this software display the following acknowledgement:
1455714Skris * ``This product includes software developed by the University of California,
1555714Skris * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1655714Skris * the University nor the names of its contributors may be used to endorse
17109998Smarkm * or promote products derived from this software without specific prior
1855714Skris * written permission.
1955714Skris * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
2055714Skris * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
2155714Skris * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2255714Skris */
2355714Skris
2455714Skris#ifndef lint
25109998Smarkmstatic const char rcsid[] _U_ =
2655714Skris    "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.4 2005/04/06 21:32:39 mcr Exp $ (LBL)";
2755714Skris#endif
2855714Skris
29109998Smarkm#ifdef HAVE_CONFIG_H
3055714Skris#include "config.h"
3155714Skris#endif
3255714Skris
3355714Skris#include <tcpdump-stdinc.h>
34109998Smarkm
35109998Smarkm#include <pcap.h>
36109998Smarkm
37109998Smarkm#include "interface.h"
38109998Smarkm#include "addrtoname.h"
39109998Smarkm
40109998Smarkm#include "enc.h"
4155714Skris
4255714Skris#define ENC_PRINT_TYPE(wh, xf, nam) \
4355714Skris	if ((wh) & (xf)) { \
4455714Skris		printf("%s%s", nam, (wh) == (xf) ? "): " : ","); \
4555714Skris		(wh) &= ~(xf); \
4655714Skris	}
4755714Skris
48109998Smarkmu_int
4955714Skrisenc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
5055714Skris{
5155714Skris	register u_int length = h->len;
52109998Smarkm	register u_int caplen = h->caplen;
5355714Skris	int flags;
5455714Skris	const struct enchdr *hdr;
5555714Skris
5655714Skris	if (caplen < ENC_HDRLEN) {
5755714Skris		printf("[|enc]");
5855714Skris		goto out;
5955714Skris	}
6055714Skris
6155714Skris	hdr = (struct enchdr *)p;
6255714Skris	flags = hdr->flags;
6355714Skris	if (flags == 0)
6455714Skris		printf("(unprotected): ");
6555714Skris	else
6655714Skris		printf("(");
6755714Skris	ENC_PRINT_TYPE(flags, M_AUTH, "authentic");
6855714Skris	ENC_PRINT_TYPE(flags, M_CONF, "confidential");
6955714Skris	/* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */
70109998Smarkm	printf("SPI 0x%08x: ", (u_int32_t)ntohl(hdr->spi));
7155714Skris
7255714Skris	length -= ENC_HDRLEN;
7355714Skris	/* XXX - use the address family */
7455714Skris	ip_print(gndo, p + ENC_HDRLEN, length);
7555714Skris
7655714Skrisout:
77109998Smarkm	return (ENC_HDRLEN);
7855714Skris}
7955714Skris
8055714Skris
8155714Skris/*
8255714Skris * Local Variables:
8355714Skris * c-style: whitesmith
8455714Skris * c-basic-offset: 8
8555714Skris * End:
8655714Skris */
8755714Skris