]> The Tcpdump Group git mirrors - tcpdump/blob - print-esp.c
07d192cb980967091bd9569b8a44c4b32958125e
[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
56 extern int packettype;
57
58
59 void
60 esp_print(register const u_char *bp, int length, register const u_char *bp2)
61 {
62 register const struct ip *ip;
63 register const u_char *cp, *nh;
64 u_short ahlen, authlen;
65 u_long spi, seqno;
66
67 ip = (struct ip *)bp2;
68
69 (void)printf("ESP %s > %s\n\t\t",
70 ipaddr_string(&ip->ip_src),
71 ipaddr_string(&ip->ip_dst));
72
73 if (length < 8) {
74 (void)printf(" [|esp] truncated-esp %d", length);
75 return;
76 }
77
78 spi = ntohl(*((u_long *)(bp)));
79 seqno = ntohl(*((u_long *)(bp+4)));
80
81 nh = bp+ahlen;
82
83 (void)printf("spi:%08x seqno:%d ciphertext: ", spi, seqno);
84 (void)default_print_unaligned(bp+8, length-8);
85
86 /* XXX it would be nice to decrypt! */
87 }