]> The Tcpdump Group git mirrors - tcpdump/blob - print-esp.c
97ab366e2a80ba73e39a86f0595623685a3076ca
[tcpdump] / print-esp.c
1 /* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
2
3 /*
4 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 */
23
24 #ifndef lint
25 static char rcsid[] =
26 "@(#) Header: print-ah.c,v 1.37 94/06/10 17:01:42 mccanne Exp (LBL)";
27 #endif
28
29 #include <sys/param.h>
30 #include <sys/time.h>
31 #include <sys/types.h>
32 #include <sys/socket.h>
33
34 #include <netinet/in.h>
35 #include <netinet/in_systm.h>
36 #include <netinet/ip.h>
37 #include <netinet/ip_var.h>
38 #include <netinet/udp.h>
39 #include <netinet/udp_var.h>
40
41 #undef NOERROR /* Solaris sucks */
42 #include <arpa/nameser.h>
43 #include <arpa/tftp.h>
44
45 #ifdef SOLARIS
46 #include <tiuser.h>
47 #endif
48 #include <rpc/rpc.h>
49
50 #include <errno.h>
51 #include <stdio.h>
52
53 #include "interface.h"
54 #include "addrtoname.h"
55 #include "appletalk.h"
56
57 #include "nfs.h"
58 #include "bootp.h"
59
60 extern int packettype;
61
62
63 void
64 esp_print(register const u_char *bp, int length, register const u_char *bp2)
65 {
66 register const struct ip *ip;
67 register const u_char *cp, *nh;
68 u_short ahlen, authlen;
69 u_long spi, seqno;
70
71 ip = (struct ip *)bp2;
72
73 (void)printf("ESP %s > %s\n\t\t",
74 ipaddr_string(&ip->ip_src),
75 ipaddr_string(&ip->ip_dst));
76
77 if (length < 8) {
78 (void)printf(" [|esp] truncated-esp %d", length);
79 return;
80 }
81
82 spi = ntohl(*((u_long *)(bp)));
83 seqno = ntohl(*((u_long *)(bp+4)));
84
85 nh = bp+ahlen;
86
87 (void)printf("spi:%08x seqno:%d ciphertext: ", spi, seqno);
88 (void)default_print_unaligned(bp+8, length-8);
89
90 /* XXX it would be nice to decrypt! */
91 }