forked from msantos/pkt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkt_linux_cooked_tests.erl
32 lines (27 loc) · 989 Bytes
/
pkt_linux_cooked_tests.erl
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
-module(pkt_linux_cooked_tests).
-include_lib("pkt/include/pkt.hrl").
-include_lib("eunit/include/eunit.hrl").
codec_test_() ->
[
decode(),
encode()
].
packet() ->
<<0,0,0,1,0,6,0,22,182,181,62,198,0,0,8,0,69,0,0,52,3,46,64,0,54,6,
168,8,108,168,151,6,192,168,213,54,0,80,137,182,95,193,153,133,
143,44,160,100,128,16,0,126,82,76,0,0,1,1,8,10,222,215,19,81,29,
225,199,124>>.
decode() ->
{Header, Payload} = pkt:linux_cooked(packet()),
?_assertEqual(
{{linux_cooked,0,1,6,<<0,22,182,181,62,198,0,0>>,2048},
<<69,0,0,52,3,46,64,0,54,6,168,8,108,168,151,6,192,168,
213,54,0,80,137,182,95,193,153,133,143,44,160,100,128,
16,0,126,82,76,0,0,1,1,8,10,222,215,19,81,29,225,199,
124>>},
{Header, Payload}
).
encode() ->
Packet = packet(),
{Header, Payload} = pkt:linux_cooked(Packet),
?_assertEqual(Packet, <<(pkt:linux_cooked(Header))/binary, Payload/binary>>).