fix a header guard
[libof.git] / of10.h
blob6830548b841542f5bd36ea8fdf8b8ce0f499a681
1 /*
2 * Copyright (c) 2015 Mohamed Aslan <maslan@sce.carleton.ca>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef of10_H
18 #define of10_H
20 #include <stdint.h>
21 #include "libof.h"
23 #define OFPT10_HELLO 0
24 #define OFPT10_OFPT_ERROR 1
25 #define OFPT10_ECHO_REQUEST 2
26 #define OFPT10_ECHO_REPLY 3
27 #define OFPT10_VENDOR 4
28 #define OFPT10_FEATURES_REQUEST 5
29 #define OFPT10_FEATURES_REPLY 6
30 #define OFPT10_GET_CONFIG_REQUEST 7
31 #define OFPT10_GET_CONFIG_REPLY 8
32 #define OFPT10_SET_CONFIG 9
33 #define OFPT10_PACKET_IN 10
34 #define OFPT10_FLOW_REMOVED 11
35 #define OFPT10_PORT_STATUS 12
36 #define OFPT10_PACKET_OUT 13
37 #define OFPT10_FLOW_MOD 14
38 #define OFPT10_PORT_MOD 15
39 #define OFPT10_STATS_REQUEST 16
40 #define OFPT10_STATS_REPLY 17
41 #define OFPT10_BARRIER_REQUEST 18
42 #define OFPT10_BARRIER_REPLY 19
43 #define OFPT10_QUEUE_GET_CONFIG_REQUEST 20
44 #define OFPT10_QUEUE_GET_CONFIG_REPLY 21
46 #define OFP10_ETH_ALEN 6
47 #define OFP10_MAX_PORT_NAME_LEN 16
49 /* packet_in reason */
50 #define OFPR10_NO_MATCH 0
51 #define OFPR10_ACTION 1
53 /* action type */
54 #define OFPAT10_OUTPUT 0
55 #define OFPAT10_SET_VLAN_VID 1
56 #define OFPAT10_SET_VLAN_PCP 2
57 #define OFPAT10_STRIP_VLAN 3
58 #define OFPAT10_SET_DL_SRC 4
59 #define OFPAT10_SET_DL_DST 5
60 #define OFPAT10_SET_NW_SRC 6
61 #define OFPAT10_SET_NW_DST 7
62 #define OFPAT10_SET_NW_TOS 8
63 #define OFPAT10_SET_TP_SRC 9
64 #define OFPAT10_SET_TP_DST 10
65 #define OFPAT10_ENQUEUE 11
66 #define OFPAT10_VENDOR 0xffff
68 /* flow mod command */
69 #define OFPFC10_ADD 0
70 #define OFPFC10_MODIFY 1
71 #define OFPFC10_MODIFY_STRICT 2
72 #define OFPFC10_DELETE 3
73 #define OFPFC10_DELETE_STRICT 4
75 /* port */
76 #define OFPP10_IN_PORT 0xfff8
77 #define OFPP10_NORMAL 0xfffa
78 #define OFPP10_FLOOD 0xfffb
79 #define OFPP10_ALL 0xfffc
80 #define OFPP10_CONTROLLER 0xfffd
81 #define OFPP10_NONE 0xffff
83 /* flow wildcards */
84 #define OFPFW10_IN_PORT 1 << 0
85 #define OFPFW10_DL_VLAN 1 << 1
86 #define OFPFW10_DL_SRC 1 << 2
87 #define OFPFW10_DL_DST 1 << 3
88 #define OFPFW10_DL_TYPE 1 << 4
89 #define OFPFW10_NW_PROTO 1 << 5
90 #define OFPFW10_TP_SRC 1 << 6
91 #define OFPFW10_TP_DST 1 << 7
92 #define OFPFW10_ALL ((1 << 22) - 1)
94 /* flow mod flags */
95 #define OFPFF_SEND_FLOW_REM 1 << 0
96 #define OFPFF_CHECK_OVERLAP 1 << 1
97 #define OFPFF_EMERG 1 << 2
99 /* stats types */
100 #define OFPST10_DESC 0
101 #define OFPST10_FLOW 1
102 #define OFPST10_AGGREGATE 2
103 #define OFPST10_TABLE 3
104 #define OFPST10_PORT 4
105 #define OFPST10_QUEUE 5
106 #define OFPST10_VENDOR 0xffff
109 struct of10_phy_port
111 uint16_t port_no;
112 uint8_t hw_addr[OFP10_ETH_ALEN];
113 char name[OFP10_MAX_PORT_NAME_LEN];
114 uint32_t config;
115 uint32_t state;
116 uint32_t curr;
117 uint32_t advertised;
118 uint32_t supported;
119 uint32_t peer;
120 }__attribute__((packed));
122 struct of10_switch_features
124 struct ofp_header hdr;
125 uint64_t datapath_id;
126 uint32_t n_buffers;
127 uint8_t n_tables;
128 uint8_t pad[3];
129 uint32_t capabilities;
130 uint32_t actions;
131 struct of10_phy_port ports[0]; /* XXX: won't be considered by sizeof */
132 }__attribute__((packed));
134 struct of10_packet_in
136 struct ofp_header hdr;
137 uint32_t buffer_id;
138 uint16_t total_len;
139 uint16_t in_port;
140 uint8_t reason;
141 uint8_t pad;
142 uint8_t data[0]; /* XXX: won't be considered by sizeof */
143 }__attribute__((packed));
145 struct of10_action_header
147 uint16_t type;
148 uint16_t len;
149 uint8_t pad[4];
150 }__attribute__((packed));
152 struct of10_action_output
154 uint16_t type;
155 uint16_t len;
156 uint16_t port;
157 uint16_t max_len;
158 }__attribute__((packed));
160 struct of10_action_dl_addr
162 uint16_t type;
163 uint16_t len;
164 uint8_t dl_addr[OFP10_ETH_ALEN];
165 uint8_t pad[6];
166 }__attribute__((packed));
168 struct of10_action_nw_addr
170 uint16_t type;
171 uint16_t len;
172 uint32_t nw_addr;
173 }__attribute__((packed));
175 struct of10_packet_out
177 struct ofp_header hdr;
178 uint32_t buffer_id;
179 uint16_t in_port;
180 uint16_t actions_len;
181 struct of10_action_header actions[0]; /* XXX: won't be considered by sizeof */
182 }__attribute__((packed));
184 struct of10_match {
185 uint32_t wildcards;
186 uint16_t in_port;
187 uint8_t dl_src[OFP10_ETH_ALEN];
188 uint8_t dl_dst[OFP10_ETH_ALEN];
189 uint16_t dl_vlan;
190 uint8_t dl_vlan_pcp;
191 uint8_t pad1[1];
192 uint16_t dl_type;
193 uint8_t nw_tos;
194 uint8_t nw_proto;
195 uint8_t pad2[2];
196 uint32_t nw_src;
197 uint32_t nw_dst;
198 uint16_t tp_src;
199 uint16_t tp_dst;
200 }__attribute__((packed));
202 struct of10_flow_mod
204 struct ofp_header hdr;
205 struct of10_match match;
206 uint64_t cookie;
207 uint16_t command;
208 uint16_t idle_timeout;
209 uint16_t hard_timeout;
210 uint16_t priority;
211 uint32_t buffer_id;
212 uint16_t out_port;
213 uint16_t flags;
214 struct of10_action_header actions[0]; /* XXX: won't be considered by sizeof */
215 }__attribute__((packed));
218 struct of10_stats_request {
219 struct ofp_header hdr;
220 uint16_t type;
221 uint16_t flags;
222 uint8_t body[0]; /* XXX: won't be considered by sizeof */
223 }__attribute__((packed));
225 struct of10_stats_reply {
226 struct ofp_header hdr;
227 uint16_t type;
228 uint16_t flags;
229 uint8_t body[0]; /* XXX: won't be considered by sizeof */
230 }__attribute__((packed));
232 struct of10_flow_stats_request
234 struct of10_match match;
235 uint8_t table_id;
236 uint8_t pad;
237 uint16_t out_port;
238 }__attribute__((packed));
240 struct of10_flow_stats
242 uint16_t length;
243 uint8_t table_id;
244 uint8_t pad;
245 struct of10_match match;
246 uint32_t duration_sec;
247 uint32_t duration_nsec;
248 uint16_t priority;
249 uint16_t idle_timeout;
250 uint16_t hard_timeout;
251 uint8_t pad2[6];
252 uint64_t cookie;
253 uint64_t packet_count;
254 uint64_t byte_count;
255 struct of10_action_header actions[0]; /* XXX: won't be considered by sizeof */
256 }__attribute__((packed));
258 struct of10_port_stats_request
260 uint16_t port_no;
261 uint8_t pad[6];
262 }__attribute__((packed));
264 struct of10_port_stats
266 uint16_t port_no;
267 uint8_t pad[6];
268 uint64_t rx_packets;
269 uint64_t tx_packets;
270 uint64_t rx_bytes;
271 uint64_t tx_bytes;
272 uint64_t rx_dropped;
273 uint64_t tx_dropped;
274 uint64_t rx_errors;
275 uint64_t tx_errors;
276 uint64_t rx_frame_err;
277 uint64_t rx_over_err;
278 uint64_t rx_crc_err;
279 uint64_t collisions;
280 }__attribute__((packed));
282 const struct of_protocol *of10_protocol();
284 #endif