Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_tlsv12/sys/src/cmd/ip/snoopy/eapol_key.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <ip.h>
4
#include "dat.h"
5
#include "protos.h"
6
 
7
typedef struct Hdr
8
{
9
	uchar	desc;
10
} Hdr;
11
 
12
typedef struct Rc4KeyDesc
13
{
14
	uchar	ln[2];
15
	uchar	replay[8];
16
	uchar	iv[16];
17
	uchar	idx;
18
	uchar	md[16];
19
} Rc4KeyDesc;
20
 
21
enum
22
{
23
	HDR=	1,		/* sizeof(Hdr) */
24
	RC4KEYDESC=	43,	/* sizeof(Rc4KeyDesc) */
25
 
26
	DescTpRC4= 1,
27
};
28
 
29
enum
30
{
31
	Odesc,
32
};
33
 
34
static Mux p_mux[] =
35
{
36
	{ "rc4keydesc", DescTpRC4, },
37
	{ 0 }
38
};
39
 
40
static Mux p_muxrc4[] =
41
{
42
	{ "dump", 0, },
43
	{ 0 }
44
};
45
 
46
static void
47
p_compile(Filter *f)
48
{
49
	Mux *m;
50
 
51
	for(m = p_mux; m->name != nil; m++)
52
		if(strcmp(f->s, m->name) == 0){
53
			f->pr = m->pr;
54
			f->ulv = m->val;
55
			f->subop = Odesc;
56
			return;
57
		}
58
	sysfatal("unknown eap_key field or type: %s", f->s);
59
}
60
 
61
static int
62
p_filter(Filter *f, Msg *m)
63
{
64
	Hdr *h;
65
 
66
	if(m->pe - m->ps < HDR)
67
		return 0;
68
 
69
	h = (Hdr*)m->ps;
70
	m->ps += HDR;
71
 
72
	switch(f->subop){
73
	case Odesc:
74
		return h->desc == f->ulv;
75
	}
76
	return 0;
77
}
78
 
79
static char*
80
op(int i)
81
{
82
	static char x[20];
83
 
84
	switch(i){
85
	case DescTpRC4:
86
		return "RC4KeyDesc";
87
	default:
88
		sprint(x, "%1d", i);
89
		return x;
90
	}
91
}
92
 
93
static int
94
p_seprint(Msg *m)
95
{
96
	Hdr *h;
97
 
98
	if(m->pe - m->ps < HDR)
99
		return -1;
100
 
101
	h = (Hdr*)m->ps;
102
	m->ps += HDR;
103
 
104
	/* next protocol  depending on type*/
105
	demux(p_mux, h->desc, h->desc, m, &dump);
106
 
107
	m->p = seprint(m->p, m->e, "desc=%s", op(h->desc));
108
	return 0;
109
}
110
 
111
static int
112
p_seprintrc4(Msg *m)
113
{
114
	Rc4KeyDesc *h;
115
	int len;
116
 
117
	if(m->pe - m->ps < RC4KEYDESC)
118
		return -1;
119
 
120
	h = (Rc4KeyDesc*)m->ps;
121
	m->ps += RC4KEYDESC;
122
	m->pr = nil;
123
	len = m->pe - m->ps;
124
 
125
	m->p = seprint(m->p, m->e, "keylen=%1d replay=%1d iv=%1d idx=%1d md=%1d",
126
			NetS(h->ln), NetS(h->replay), NetS(h->iv), h->idx, NetS(h->md));
127
	m->p = seprint(m->p, m->e, " dataln=%d", len);
128
	if (len > 0)
129
		m->p = seprint(m->p, m->e, " data=%.*H", len, m->ps);
130
	return 0;
131
}
132
 
133
Proto eapol_key =
134
{
135
	"eapol_key",
136
	p_compile,
137
	p_filter,
138
	p_seprint,
139
	p_mux,
140
	"%lud",
141
	nil,
142
	defaultframer,
143
};
144
 
145
Proto rc4keydesc =
146
{
147
	"rc4keydesc",
148
	p_compile,
149
	nil,
150
	p_seprintrc4,
151
	nil,
152
	nil,
153
	nil,
154
	defaultframer,
155
};