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_interface_statistics_block). |
16 |
|
-export([parse/2]). |
17 |
|
|
18 |
|
-spec parse(binary(), fun((binary()) -> integer())) -> map(). |
19 |
|
parse(Body, I) -> |
20 |
6 |
<< |
21 |
|
InterfaceID:32/bits, |
22 |
|
TimestampHigh:32/bits, |
23 |
|
TimestampLow:32/bits, |
24 |
|
Options/binary |
25 |
|
>> = Body, |
26 |
6 |
#{type => interface_statistics, |
27 |
|
interface_id => InterfaceID, |
28 |
|
timestamp_high => TimestampHigh, |
29 |
|
timestamp_low => TimestampLow, |
30 |
|
options => pcapng_options:parse(Options, I, mapping(I)) |
31 |
|
}. |
32 |
|
|
33 |
|
|
34 |
|
mapping(I) -> |
35 |
6 |
#{2 => isb_start_time, |
36 |
|
3 => isb_end_time, |
37 |
|
4 => {isb_if_recv, I}, |
38 |
|
5 => {isb_if_drop, I}, |
39 |
|
6 => isb_filter_accept, |
40 |
|
7 => isb_os_drop, |
41 |
|
8 => is_usr_deliv |
42 |
|
}. |