blob: 127e1fc9cc621314c7ca2548f0364ab5108f0f94 [file] [log] [blame]
Rich Laneb1f347d2013-05-16 16:39:12 -07001-- binary
Andreas Wundsamf10ed082013-09-23 14:49:54 -0700201 0e # version, type
300 70 # length
412 34 56 78 # xid
5
6#### ofp_flow_mod
700 30 00 e2 # wild cards=(OFPFW_DL_VLAN|OFPFW_NW_PROTO|OFPFW_TP_SRC|OFPFW_TP_DST|OFPFW_DL_VLAN_PCP|OFPFW_NW_TOS)
800 03 # in_port
901 23 45 67 89 ab # eth_src
10cd ef 01 23 45 67 # eth_dst
1100 00 # dl_vlan
1200 00 # dl_pcp, pad
1308 00 # dl_type
1400 00 00 00 # nw_tos, nw_proto, pad[2]
15c0 a8 03 7f # nw_src
16ff ff ff ff # nw_dst
1700 00 00 00 # tcp_src, tcp_dst
18
1900 00 00 00 00 00 00 00 # cookie
2000 00 # command
2100 05 # idle_timeout
2200 00 # hard_timeout
2300 00 # priority
2400 00 00 00 # buffer_id
2500 00 #out_port
2600 02 # flags (CHECK_OVERLAP)
27
28#list(ofp_action)
2900 00 00 08 # type=OUTPUT, len=8
30ff fb # port=FLOOD
3100 00 # maxLen=0
32ff ff 00 10 # type=VENDOR, len=16
3300 00 23 20 # vendor = Nicira
3400 12 # subtype=dec_ttl
3500 00 00 00 00 00 # pad(6)
36ff ff 00 10 # type=VENDOR, len=16
3700 5c 16 c7 # vendor = BSN
3800 00 00 02 # subype = set_tunnel_dst
3900 00 00 00 # tunnel dst ip
Rich Laneb1f347d2013-05-16 16:39:12 -070040-- python
41ofp.message.flow_add(
42 xid=0x12345678,
43 match=ofp.match(
Andreas Wundsamf10ed082013-09-23 14:49:54 -070044 wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_NW_PROTO|ofp.OFPFW_TP_SRC|ofp.OFPFW_TP_DST|ofp.OFPFW_DL_VLAN_PCP|ofp.OFPFW_NW_TOS,
Rich Laneb1f347d2013-05-16 16:39:12 -070045 in_port=3,
Andreas Wundsamf10ed082013-09-23 14:49:54 -070046 eth_type=0x800,
Rich Laneb1f347d2013-05-16 16:39:12 -070047 ipv4_src=0xc0a8037f,
48 ipv4_dst=0xffffffff,
49 eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
50 eth_dst=[0xcd, 0xef, 0x01, 0x23, 0x45, 0x67]),
51 idle_timeout=5,
52 flags=ofp.OFPFF_CHECK_OVERLAP,
53 actions=[
54 ofp.action.output(port=ofp.OFPP_FLOOD),
55 ofp.action.nicira_dec_ttl(),
56 ofp.action.bsn_set_tunnel_dst()])
57-- python pretty-printer
58flow_add {
59 xid = 0x12345678,
60 match = match_v1 {
Andreas Wundsamf10ed082013-09-23 14:49:54 -070061 wildcards = OFPFW_DL_VLAN|OFPFW_NW_PROTO|OFPFW_TP_SRC|OFPFW_TP_DST|OFPFW_DL_VLAN_PCP|OFPFW_NW_TOS,
Rich Laneb1f347d2013-05-16 16:39:12 -070062 in_port = 3,
63 eth_src = 01:23:45:67:89:ab,
64 eth_dst = cd:ef:01:23:45:67,
65 vlan_vid = 0x0,
66 vlan_pcp = 0x0,
Andreas Wundsamf10ed082013-09-23 14:49:54 -070067 eth_type = 0x800,
Rich Laneb1f347d2013-05-16 16:39:12 -070068 ip_dscp = 0x0,
69 ip_proto = 0x0,
Rich Laneb1f347d2013-05-16 16:39:12 -070070 ipv4_src = 192.168.3.127,
71 ipv4_dst = 255.255.255.255,
72 tcp_src = 0x0,
73 tcp_dst = 0x0
74 },
75 cookie = 0x0,
76 idle_timeout = 0x5,
77 hard_timeout = 0x0,
78 priority = 0x0,
79 buffer_id = 0x0,
80 out_port = 0,
81 flags = 0x2,
82 actions = [
83 output { port = OFPP_FLOOD, max_len = 0x0 },
84 nicira_dec_ttl { },
85 bsn_set_tunnel_dst { dst = 0x0 }
86 ]
87}
Rich Laneccae0312013-07-21 23:34:13 -070088-- c
89obj = of_flow_add_new(OF_VERSION_1_0);
90of_flow_add_xid_set(obj, 0x12345678);
91of_flow_add_idle_timeout_set(obj, 5);
92of_flow_add_flags_set(obj, 2);
93{
94 of_match_t match = { OF_VERSION_1_0 };
95 match.fields.in_port = 3;
96 match.fields.eth_src = (of_mac_addr_t) { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } };
97 match.fields.eth_dst = (of_mac_addr_t) { { 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67 } };
Andreas Wundsamf10ed082013-09-23 14:49:54 -070098 match.fields.eth_type = 0x800;
Rich Laneccae0312013-07-21 23:34:13 -070099 match.fields.ipv4_src = 0xc0a8037f;
100 match.fields.ipv4_dst = 0xffffffff;
101 OF_MATCH_MASK_IN_PORT_EXACT_SET(&match);
102 OF_MATCH_MASK_ETH_SRC_EXACT_SET(&match);
103 OF_MATCH_MASK_ETH_DST_EXACT_SET(&match);
Andreas Wundsamf10ed082013-09-23 14:49:54 -0700104 OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
Rich Laneccae0312013-07-21 23:34:13 -0700105 //OF_MATCH_MASK_VLAN_VID_EXACT_SET(&match);
106 //OF_MATCH_MASK_VLAN_PCP_EXACT_SET(&match);
107 OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
Andreas Wundsamf10ed082013-09-23 14:49:54 -0700108 //OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match);
109 //OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match);
Rich Laneccae0312013-07-21 23:34:13 -0700110 OF_MATCH_MASK_IPV4_SRC_EXACT_SET(&match);
111 OF_MATCH_MASK_IPV4_DST_EXACT_SET(&match);
Andreas Wundsamf10ed082013-09-23 14:49:54 -0700112 //OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match);
113 //OF_MATCH_MASK_TCP_DST_EXACT_SET(&match);
Rich Laneccae0312013-07-21 23:34:13 -0700114 of_flow_add_match_set(obj, &match);
115}
116{
117 of_list_action_t actions;
118 of_flow_add_actions_bind(obj, &actions);
119 {
120 of_action_t action;
121 of_action_output_init(&action.output, OF_VERSION_1_0, -1, 1);
122 of_list_action_append_bind(&actions, &action);
123 of_action_output_port_set(&action.output, OF_PORT_DEST_FLOOD);
124 }
125 {
126 of_action_t action;
127 of_action_nicira_dec_ttl_init(&action.nicira_dec_ttl, OF_VERSION_1_0, -1, 1);
128 of_list_action_append_bind(&actions, &action);
129 }
130 {
131 of_action_t action;
132 of_action_bsn_set_tunnel_dst_init(&action.bsn_set_tunnel_dst, OF_VERSION_1_0, -1, 1);
133 of_list_action_append_bind(&actions, &action);
134 }
135}
Andreas Wundsamf10ed082013-09-23 14:49:54 -0700136-- java
137builder.setXid(0x12345678)
138 .setMatch(
139 factory.buildMatch()
140 .setExact(MatchField.IN_PORT, OFPort.of(3))
141 .setExact(MatchField.ETH_TYPE, EthType.IPv4)
142 .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
143 .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
144 .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
145 .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
146 .build()
147 )
148 .setIdleTimeout(5)
149 .setFlags(Sets.immutableEnumSet(OFFlowModFlags.CHECK_OVERLAP))
Rob Vaterlausfbd5b6b2013-09-24 15:55:47 -0700150 .setBufferId(OFBufferId.of(0))
Andreas Wundsamf10ed082013-09-23 14:49:54 -0700151 .setActions(
152 ImmutableList.of(
153 factory.actions().output(OFPort.FLOOD, 0),
154 factory.actions().niciraDecTtl(),
155 factory.actions().bsnSetTunnelDst(0)
156 )
157 );