_site/cover/pcapng_ip_tcp.COVER.html

1 %% Copyright (c) 2015 Peter Morgan <peter.james.morgan@gmail.com>
2 %%
3 %% Licensed under the Apache License, Version 2.0 (the "License");
4 %% you may not use this file except in compliance with the License.
5 %% You may obtain a copy of the License at
6 %%
7 %% http://www.apache.org/licenses/LICENSE-2.0
8 %%
9 %% Unless required by applicable law or agreed to in writing, software
10 %% distributed under the License is distributed on an "AS IS" BASIS,
11 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 %% See the License for the specific language governing permissions and
13 %% limitations under the License.
14
15 -module(pcapng_ip_tcp).
16 -export([decode/1]).
17
18
19 decode(<<
20 Source:16,
21 Destination:16,
22 Sequence:32,
23 Acknowledgement:32,
24 DataOffset:4,
25 0:3,
26 NS:1,
27 CWR:1,
28 ECE:1,
29 URG:1,
30 ACK:1,
31 PSH:1,
32 RST:1,
33 SYN:1,
34 FIN:1,
35 WindowSize:16,
36 Checksum:16,
37 _/binary
38 >> = Packet) ->
39 821 <<_:DataOffset/unit:32, Data/bytes>> = Packet,
40
41 821 #{source => Source,
42 destination => Destination,
43 sequence => Sequence,
44 acknowledgement => Acknowledgement,
45 data_offset => DataOffset,
46 flags => #{ns => b(NS),
47 cwr => b(CWR),
48 ece => b(ECE),
49 urg => b(URG),
50 ack => b(ACK),
51 psh => b(PSH),
52 rst => b(RST),
53 syn => b(SYN),
54 fin => b(FIN)},
55 window_size => WindowSize,
56 checksum => Checksum,
57 data => Data}.
58
59 6411 b(0) -> false;
60 978 b(1) -> true.
61
Line Hits Source