-
Notifications
You must be signed in to change notification settings - Fork 4
/
secdump.c
82 lines (74 loc) · 1.43 KB
/
secdump.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* Security packet tracing
* Copyright 1993 Phil Karn, KA9Q
*/
#include "top.h"
#include "global.h"
#include "mbuf.h"
#include "netuser.h"
#include "trace.h"
#include "ipsec.h"
#include "photuris.h"
void
esp_dump(fp,bpp,source,dest,check)
kFILE *fp;
struct mbuf **bpp;
int32 source,dest;
int check;
{
int32 spi;
spi = pull32(bpp);
kfprintf(fp,"ESP: SPI %lx\n",spi);
}
void
ah_dump(fp,bpp,source,dest,check)
kFILE *fp;
struct mbuf **bpp;
int32 source,dest;
int check;
{
int32 spi;
int protocol,authlen,i;
uint8 *auth;
protocol = PULLCHAR(bpp);
authlen = sizeof(int32) * PULLCHAR(bpp);
pull16(bpp);
spi = pull32(bpp);
kfprintf(fp,"AH: SPI %lx",spi);
if(authlen != 0){
kfprintf(fp," auth ");
auth = mallocw(authlen);
pullup(bpp,auth,authlen);
for(i=0;i<authlen;i++)
kfprintf(fp,"%02x",auth[i]);
}
switch(protocol){
case IP4_PTCL:
case IP_PTCL:
kfprintf(fp," prot IP\n");
ip_dump(fp,bpp,check);
break;
case TCP_PTCL:
kfprintf(fp," prot TCP\n");
tcp_dump(fp,bpp,source,dest,check);
break;
case UDP_PTCL:
kfprintf(fp," prot UDP\n");
udp_dump(fp,bpp,source,dest,check);
break;
case ICMP_PTCL:
kfprintf(fp," prot ICMP\n");
icmp_dump(fp,bpp,source,dest,check);
break;
case ESP_PTCL:
kfprintf(fp," prot ESP\n");
esp_dump(fp,bpp,source,dest,check);
break;
case AH_PTCL:
kfprintf(fp," prot AH\n");
ah_dump(fp,bpp,source,dest,check);
break;
default:
kfprintf(fp," prot %u\n",protocol);
break;
}
}