Scripts placed on scripts directory
[vsorcdistro/.git] / ryu / ryu / tests / packet_data_generator / src / x1.erl
1 %% Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
2 %% Copyright (C) 2013 YAMAMOTO Takashi <yamamoto at valinux co jp>
3 %%
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
7 %%
8 %%    http://www.apache.org/licenses/LICENSE-2.0
9 %%
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
13 %% implied.
14 %% See the License for the specific language governing permissions and
15 %% limitations under the License.
16
17 -module(x1).
18 -export([x/0]).
19
20 -include_lib("flower/include/flower_packet.hrl").
21
22 cookie(Bin) ->
23     <<Int:64>> = Bin,
24     Int.
25
26 x() ->
27     List = [
28         skip,
29         #ofp_packet_out{
30             buffer_id = ?OFP_NO_BUFFER,in_port = controller,
31             actions = 
32                 [#ofp_action_output{port = all,max_len = 65535}],
33             data = 
34                 <<242,11,164,208,63,112,242,11,164,125,248,234,8,0,69,0,
35                   0,84,248,26,0,0,255,1,175,139,10,0,0,1,10,0,0,2,8,0,2,
36                   8,247,96,0,0,49,214,2,0,0,0,0,0,171,141,45,49,0,0,0,0,
37                   16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,
38                   34,35,36,37,38,39,40,41,42,43,44,45,46,47,0,0,0,0,0,0,
39                   0,0>>},
40         #ofp_flow_mod{
41             cookie = cookie(<<0,0,0,0,0,0,0,0>>),
42             command = add,idle_timeout = 0,
43             hard_timeout = 0,priority = 123,buffer_id = 65535,
44             out_port = all,flags = [],
45             match =
46                 #ofp_match{
47                     wildcards = 16#3ffff7,
48                     dl_dst = <<"\362\v\244}\370\352">>,
49                     % XXX ryu and flower have different defaults for the
50                     % followin fields.
51                     in_port = 0,
52                     dl_src = <<0:6/unit:8>>
53                 },
54             actions = [#ofp_action_output{port = 6,max_len = 65535}]},
55         skip,
56         #ofp_packet_in{
57             buffer_id = 2,total_len=42,reason = action,in_port = 99,
58             data =
59                 <<255,255,255,255,255,255,242,11,164,125,248,234,8,6,0,
60                   1,8,0,6,4,0,1,242,11,164,125,248,234,10,0,0,1,0,0,0,0,
61                   0,0,10,0,0,3>>},
62
63         features_request,
64         #ofp_switch_features{  % features_reply
65             datapath_id = 16#ff12345678,n_buffers = 0,n_tables = 255,
66             capabilities = 
67                 [arp_match_ip,ip_reasm,stp,flow_stats],
68             actions =
69                 [enqueue,set_nw_src,set_vlan_vid,output],
70             ports = 
71                 [#ofp_phy_port{
72                      port_no = 7,hw_addr = <<"\362\v\244\320?p">>,
73                      name = <<"Port7">>,
74                      config = [],
75                      state = [stp_block],
76                      curr = [autoneg,copper,'100mb_fd'],
77                      advertised = [autoneg,copper],
78                      supported = [autoneg,copper,'100mb_fd'],
79                      peer = [autoneg,copper,'100mb_fd']},
80                  #ofp_phy_port{
81                      port_no = 6,hw_addr = <<"\362\v\244}\370\352">>,
82                      name = <<"Port6">>,
83                      config = [],
84                      state = [stp_listen],
85                      curr = [autoneg,copper,'100mb_fd'],
86                      advertised = [autoneg,copper],
87                      supported = [autoneg,copper,'100mb_fd'],
88                      peer = [autoneg,copper,'100mb_fd']}]}
89     ],
90     lists:foldl(fun x:do/2, {1, 0}, List).