1 %% Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
2 %% Copyright (C) 2013 YAMAMOTO Takashi <yamamoto at valinux co jp>
4 %% Licensed under the Apache License, Version 2.0 (the "License");
5 %% you may not use this file except in compliance with the License.
6 %% You may obtain a copy of the License at
8 %% http://www.apache.org/licenses/LICENSE-2.0
10 %% Unless required by applicable law or agreed to in writing, software
11 %% distributed under the License is distributed on an "AS IS" BASIS,
12 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 %% See the License for the specific language governing permissions and
15 %% limitations under the License.
21 ofp_version_string(Vers) ->
22 ["of", integer_to_list(9 + Vers)].
24 do(skip, {OFPVersion, N}) ->
26 do(Body, {OFPVersion, N}) ->
27 Mod = case OFPVersion of
33 atom_to_list(element(1, B));
37 io:format("processing ~B ~B ~s~n", [OFPVersion, N, Name]),
38 Msg = Mod:message(OFPVersion, 0, Body),
39 case Mod:encode(Msg) of
41 {error, Error} -> io:format("~p ~p~n", [Error, Msg]), BinMsg = hoge
43 {ok, F} = file:open(["../packet_data/",
44 ofp_version_string(OFPVersion), "/", integer_to_list(OFPVersion), "-",
45 integer_to_list(N), "-", Name, ".packet"], [write, binary]),
48 % this is fragile because of order of flags.
49 % ofp flags are unorderd but of_protocol keeps them in a list.
50 {ok, Msg2, <<>>} = Mod:decode(BinMsg),
51 {OFPVersion, 0, Body2} = Mod:message_extract(Msg2),
53 false -> io:format("~p~n", [Body]), io:format("~p~n", [Body2]);
58 ok = file:write(F, BinMsg),
63 lists:map(fun(Mod) -> Mod:x() end, [x1, x3, x4, x5]).