ofp-errors: Rename "OF" to "OF1.0+", "NX" to "NX1.0+".
[cascardo/ovs.git] / lib / ofp-errors.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks.
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 implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef OFP_ERRORS_H
18 #define OFP_ERRORS_H 1
19
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include <stdint.h>
23
24 struct ds;
25 struct ofp_header;
26
27 /* Error codes.
28  *
29  * We embed system errno values and OpenFlow standard and vendor extension
30  * error codes into the positive range of "int":
31  *
32  *   - Errno values are assumed to use the range 1 through 2**30 - 1.
33  *
34  *     (C and POSIX say that errno values are positive.  We assume that they
35  *     are less than 2**29.  They are actually less than 65536 on at least
36  *     Linux, FreeBSD, OpenBSD, and Windows.)
37  *
38  *   - OpenFlow standard and vendor extension error codes use the range
39  *     starting at 2**30 (OFPERR_OFS).
40  *
41  * Zero and negative values are not used.
42  */
43
44 #define OFPERR_OFS (1 << 30)
45
46 enum ofperr {
47 /* ## ------------------ ## */
48 /* ## OFPET_HELLO_FAILED ## */
49 /* ## ------------------ ## */
50
51     /* OF1.0+(0).  Hello protocol failed. */
52     OFPERR_OFPET_HELLO_FAILED = OFPERR_OFS,
53
54     /* OF1.0+(0,0).  No compatible version. */
55     OFPERR_OFPHFC_INCOMPATIBLE,
56
57     /* OF1.0+(0,1).  Permissions error. */
58     OFPERR_OFPHFC_EPERM,
59
60 /* ## ----------------- ## */
61 /* ## OFPET_BAD_REQUEST ## */
62 /* ## ----------------- ## */
63
64     /* OF1.0+(1).  Request was not understood. */
65     OFPERR_OFPET_BAD_REQUEST,
66
67     /* OF1.0+(1,0).  ofp_header.version not supported. */
68     OFPERR_OFPBRC_BAD_VERSION,
69
70     /* OF1.0+(1,1).  ofp_header.type not supported. */
71     OFPERR_OFPBRC_BAD_TYPE,
72
73     /* OF1.0+(1,2).  ofp_stats_msg.type not supported. */
74     OFPERR_OFPBRC_BAD_STAT,
75
76     /* OF1.0+(1,3).  Vendor not supported (in ofp_vendor_header or
77      * ofp_stats_msg). */
78     OFPERR_OFPBRC_BAD_VENDOR,
79
80     /* OF1.0+(1,4).  Vendor subtype not supported. */
81     OFPERR_OFPBRC_BAD_SUBTYPE,
82
83     /* OF1.0+(1,5).  Permissions error. */
84     OFPERR_OFPBRC_EPERM,
85
86     /* OF1.0+(1,6).  Wrong request length for type. */
87     OFPERR_OFPBRC_BAD_LEN,
88
89     /* OF1.0+(1,7).  Specified buffer has already been used. */
90     OFPERR_OFPBRC_BUFFER_EMPTY,
91
92     /* OF1.0+(1,8).  Specified buffer does not exist. */
93     OFPERR_OFPBRC_BUFFER_UNKNOWN,
94
95     /* OF1.1(1,9).  Specified table-id invalid or does not exist. */
96     OFPERR_OFPBRC_BAD_TABLE_ID,
97
98     /* NX1.0+(1,256).  Invalid NXM flow match. */
99     OFPERR_NXBRC_NXM_INVALID,
100
101     /* NX1.0+(1,257).  The nxm_type, or nxm_type taken in combination with
102      * nxm_hasmask or nxm_length or both, is invalid or not implemented. */
103     OFPERR_NXBRC_NXM_BAD_TYPE,
104
105     /* NX1.0+(1,258).  Invalid nxm_value. */
106     OFPERR_NXBRC_NXM_BAD_VALUE,
107
108     /* NX1.0+(1,259).  Invalid nxm_mask. */
109     OFPERR_NXBRC_NXM_BAD_MASK,
110
111     /* NX1.0+(1,260).  A prerequisite was not met. */
112     OFPERR_NXBRC_NXM_BAD_PREREQ,
113
114     /* NX1.0+(1,261).  A given nxm_type was specified more than once. */
115     OFPERR_NXBRC_NXM_DUP_TYPE,
116
117     /* NX1.0+(1,512).  A request specified a nonexistent table ID. */
118     OFPERR_NXBRC_BAD_TABLE_ID,
119
120     /* NX1.0+(1,513).  NXT_ROLE_REQUEST specified an invalid role. */
121     OFPERR_NXBRC_BAD_ROLE,
122
123     /* NX1.0+(1,514).  The in_port in an ofp_packet_out request is invalid. */
124     OFPERR_NXBRC_BAD_IN_PORT,
125
126     /* NX1.0+(1,515).  Must-be-zero field had nonzero value. */
127     OFPERR_NXBRC_MUST_BE_ZERO,
128
129     /* NX1.0+(1,516).  The reason in an ofp_port_status message is not
130      * valid. */
131     OFPERR_NXBRC_BAD_REASON,
132
133 /* ## ---------------- ## */
134 /* ## OFPET_BAD_ACTION ## */
135 /* ## ---------------- ## */
136
137     /* OF1.0+(2).  Error in action description. */
138     OFPERR_OFPET_BAD_ACTION,
139
140     /* OF1.0+(2,0).  Unknown action type. */
141     OFPERR_OFPBAC_BAD_TYPE,
142
143     /* OF1.0+(2,1).  Length problem in actions. */
144     OFPERR_OFPBAC_BAD_LEN,
145
146     /* OF1.0+(2,2).  Unknown experimenter id specified. */
147     OFPERR_OFPBAC_BAD_VENDOR,
148
149     /* OF1.0+(2,3).  Unknown action type for experimenter id. */
150     OFPERR_OFPBAC_BAD_VENDOR_TYPE,
151
152     /* OF1.0+(2,4).  Problem validating output port. */
153     OFPERR_OFPBAC_BAD_OUT_PORT,
154
155     /* OF1.0+(2,5).  Bad action argument. */
156     OFPERR_OFPBAC_BAD_ARGUMENT,
157
158     /* OF1.0+(2,6).  Permissions error. */
159     OFPERR_OFPBAC_EPERM,
160
161     /* OF1.0+(2,7).  Can't handle this many actions. */
162     OFPERR_OFPBAC_TOO_MANY,
163
164     /* OF1.0+(2,8).  Problem validating output queue. */
165     OFPERR_OFPBAC_BAD_QUEUE,
166
167     /* OF1.1(2,9).  Invalid group id in forward action. */
168     OFPERR_OFPBAC_BAD_OUT_GROUP,
169
170     /* OF1.1(2,10).  Action can't apply for this match. */
171     OFPERR_OFPBAC_MATCH_INCONSISTENT,
172
173     /* OF1.1(2,11).  Action order is unsupported for the action list in an
174      * Apply-Actions instruction */
175     OFPERR_OFPBAC_UNSUPPORTED_ORDER,
176
177     /* OF1.1(2,12).  Actions uses an unsupported tag/encap. */
178     OFPERR_OFPBAC_BAD_TAG,
179
180     /* NX1.0+(2,256).  Must-be-zero action argument had nonzero value. */
181     OFPERR_NXBAC_MUST_BE_ZERO,
182
183 /* ## --------------------- ## */
184 /* ## OFPET_BAD_INSTRUCTION ## */
185 /* ## --------------------- ## */
186
187     /* OF1.1(3).  Error in instruction list. */
188     OFPERR_OFPET_BAD_INSTRUCTION,
189
190     /* OF1.1(3,0).  Unknown instruction. */
191     OFPERR_OFPBIC_UNKNOWN_INST,
192
193     /* OF1.1(3,1).  Switch or table does not support the instruction. */
194     OFPERR_OFPBIC_UNSUP_INST,
195
196     /* OF1.1(3,2).  Invalid Table-ID specified. */
197     OFPERR_OFPBIC_BAD_TABLE_ID,
198
199     /* OF1.1(3,3).  Metadata value unsupported by datapath. */
200     OFPERR_OFPBIC_UNSUP_METADATA,
201
202     /* OF1.1(3,4).  Metadata mask value unsupported by datapath. */
203     OFPERR_OFPBIC_UNSUP_METADATA_MASK,
204
205     /* OF1.1(3,5).  Specific experimenter instruction unsupported. */
206     OFPERR_OFPBIC_UNSUP_EXP_INST,
207
208 /* ## --------------- ## */
209 /* ## OFPET_BAD_MATCH ## */
210 /* ## --------------- ## */
211
212     /* OF1.1(4).  Error in match. */
213     OFPERR_OFPET_BAD_MATCH,
214
215     /* OF1.1(4,0).  Unsupported match type specified by the match */
216     OFPERR_OFPBMC_BAD_TYPE,
217
218     /* OF1.1(4,1).  Length problem in match. */
219     OFPERR_OFPBMC_BAD_LEN,
220
221     /* OF1.1(4,2).  Match uses an unsupported tag/encap. */
222     OFPERR_OFPBMC_BAD_TAG,
223
224     /* OF1.1(4,3).  Unsupported datalink addr mask - switch does not support
225      * arbitrary datalink address mask. */
226     OFPERR_OFPBMC_BAD_DL_ADDR_MASK,
227
228     /* OF1.1(4,4).  Unsupported network addr mask - switch does not support
229      * arbitrary network address mask. */
230     OFPERR_OFPBMC_BAD_NW_ADDR_MASK,
231
232     /* OF1.1(4,5).  Unsupported wildcard specified in the match. */
233     OFPERR_OFPBMC_BAD_WILDCARDS,
234
235     /* OF1.1(4,6).  Unsupported field in the match. */
236     OFPERR_OFPBMC_BAD_FIELD,
237
238     /* OF1.1(4,7).  Unsupported value in a match field. */
239     OFPERR_OFPBMC_BAD_VALUE,
240
241 /* ## --------------------- ## */
242 /* ## OFPET_FLOW_MOD_FAILED ## */
243 /* ## --------------------- ## */
244
245     /* OF1.0(3), OF1.1(5).  Problem modifying flow entry. */
246     OFPERR_OFPET_FLOW_MOD_FAILED,
247
248     /* OF1.1(5,0).  Unspecified error. */
249     OFPERR_OFPFMFC_UNKNOWN,
250
251     /* OF1.0(3,0).  Flow not added because of full tables. */
252     OFPERR_OFPFMFC_ALL_TABLES_FULL,
253
254     /* OF1.1(5,1).  Flow not added because table was full. */
255     OFPERR_OFPFMFC_TABLE_FULL,
256
257     /* OF1.1(5,2).  Table does not exist */
258     OFPERR_OFPFMFC_BAD_TABLE_ID,
259
260     /* OF1.0(3,1), OF1.1(5,3).  Attempted to add overlapping flow with
261      * CHECK_OVERLAP flag set. */
262     OFPERR_OFPFMFC_OVERLAP,
263
264     /* OF1.0(3,2), OF1.1(5,4).  Permissions error. */
265     OFPERR_OFPFMFC_EPERM,
266
267     /* OF1.1(5,5).  Flow not added because of unsupported idle/hard timeout. */
268     OFPERR_OFPFMFC_BAD_TIMEOUT,
269
270     /* OF1.0(3,3).  Flow not added because of non-zero idle/hard timeout. */
271     OFPERR_OFPFMFC_BAD_EMERG_TIMEOUT,
272
273     /* OF1.0(3,4), OF1.1(5,6).  Unsupported or unknown command. */
274     OFPERR_OFPFMFC_BAD_COMMAND,
275
276     /* OF1.0(3,5).  Unsupported action list - cannot process in the order
277      * specified. */
278     OFPERR_OFPFMFC_UNSUPPORTED,
279
280     /* NX1.0(3,256), NX1.1(5,256).  Generic hardware error. */
281     OFPERR_NXFMFC_HARDWARE,
282
283     /* NX1.0(3,257), NX1.1(5,257).  A nonexistent table ID was specified in the
284      * "command" field of struct ofp_flow_mod, when the nxt_flow_mod_table_id
285      * extension is enabled. */
286     OFPERR_NXFMFC_BAD_TABLE_ID,
287
288 /* ## ---------------------- ## */
289 /* ## OFPET_GROUP_MOD_FAILED ## */
290 /* ## ---------------------- ## */
291
292     /* OF1.1(6).  Problem modifying group entry. */
293     OFPERR_OFPET_GROUP_MOD_FAILED,
294
295     /* OF1.1(6,0).  Group not added because a group ADD attempted to replace an
296      * already-present group. */
297     OFPERR_OFPGMFC_GROUP_EXISTS,
298
299     /* OF1.1(6,1).  Group not added because Group specified is invalid. */
300     OFPERR_OFPGMFC_INVALID_GROUP,
301
302     /* OF1.1(6,2).  Switch does not support unequal load sharing with select
303      * groups. */
304     OFPERR_OFPGMFC_WEIGHT_UNSUPPORTED,
305
306     /* OF1.1(6,3).  The group table is full. */
307     OFPERR_OFPGMFC_OUT_OF_GROUPS,
308
309     /* OF1.1(6,4).  The maximum number of action buckets for a group has been
310      * exceeded. */
311     OFPERR_OFPGMFC_OUT_OF_BUCKETS,
312
313     /* OF1.1(6,5).  Switch does not support groups that forward to groups. */
314     OFPERR_OFPGMFC_CHAINING_UNSUPPORTED,
315
316     /* OF1.1(6,6).  This group cannot watch the watch_port or watch_group
317      * specified. */
318     OFPERR_OFPGMFC_WATCH_UNSUPPORTED,
319
320     /* OF1.1(6,7).  Group entry would cause a loop. */
321     OFPERR_OFPGMFC_LOOP,
322
323     /* OF1.1(6,8).  Group not modified because a group MODIFY attempted to
324      * modify a non-existent group. */
325     OFPERR_OFPGMFC_UNKNOWN_GROUP,
326
327 /* ## --------------------- ## */
328 /* ## OFPET_PORT_MOD_FAILED ## */
329 /* ## --------------------- ## */
330
331     /* OF1.0(4), OF1.1(7).  OFPT_PORT_MOD failed. */
332     OFPERR_OFPET_PORT_MOD_FAILED,
333
334     /* OF1.0(4,0), OF1.1(7,0).  Specified port does not exist. */
335     OFPERR_OFPPMFC_BAD_PORT,
336
337     /* OF1.0(4,1), OF1.1(7,1).  Specified hardware address does not match the
338      * port number. */
339     OFPERR_OFPPMFC_BAD_HW_ADDR,
340
341     /* OF1.1(7,2).  Specified config is invalid. */
342     OFPERR_OFPPMFC_BAD_CONFIG,
343
344     /* OF1.1(7,3).  Specified advertise is invalid. */
345     OFPERR_OFPPMFC_BAD_ADVERTISE,
346
347 /* ## ---------------------- ## */
348 /* ## OFPET_TABLE_MOD_FAILED ## */
349 /* ## ---------------------- ## */
350
351     /* OF1.1(8).  Table mod request failed. */
352     OFPERR_OFPET_TABLE_MOD_FAILED,
353
354     /* OF1.1(8,0).  Specified table does not exist. */
355     OFPERR_OFPTMFC_BAD_TABLE,
356
357     /* OF1.1(8,1).  Specified config is invalid. */
358     OFPERR_OFPTMFC_BAD_CONFIG,
359
360 /* ## --------------------- ## */
361 /* ## OFPET_QUEUE_OP_FAILED ## */
362 /* ## --------------------- ## */
363
364     /* OF1.0(5), OF1.1(9).  Queue operation failed. */
365     OFPERR_OFPET_QUEUE_OP_FAILED,
366
367     /* OF1.0(5,0), OF1.1(9,0).  Invalid port (or port does not exist). */
368     OFPERR_OFPQOFC_BAD_PORT,
369
370     /* OF1.0(5,1), OF1.1(9,1).  Queue does not exist. */
371     OFPERR_OFPQOFC_BAD_QUEUE,
372
373     /* OF1.0(5,2), OF1.1(9,2).  Permissions error. */
374     OFPERR_OFPQOFC_EPERM,
375
376 /* ## -------------------------- ## */
377 /* ## OFPET_SWITCH_CONFIG_FAILED ## */
378 /* ## -------------------------- ## */
379
380     /* OF1.1(10).  Switch config request failed. */
381     OFPERR_OFPET_SWITCH_CONFIG_FAILED,
382
383     /* OF1.1(10,0).  Specified flags is invalid. */
384     OFPERR_OFPSCFC_BAD_FLAGS,
385
386     /* OF1.1(10,1).  Specified len is invalid. */
387     OFPERR_OFPSCFC_BAD_LEN,
388 };
389
390 extern const struct ofperr_domain ofperr_of10;
391 extern const struct ofperr_domain ofperr_of11;
392
393 const struct ofperr_domain *ofperr_domain_from_version(uint8_t version);
394
395 bool ofperr_is_valid(enum ofperr);
396 bool ofperr_is_category(enum ofperr);
397 bool ofperr_is_nx_extension(enum ofperr);
398 bool ofperr_is_encodable(enum ofperr, const struct ofperr_domain *);
399
400 enum ofperr ofperr_decode(const struct ofperr_domain *,
401                           uint16_t type, uint16_t code);
402 enum ofperr ofperr_decode_type(const struct ofperr_domain *, uint16_t type);
403
404 enum ofperr ofperr_decode_msg(const struct ofp_header *, size_t *payload_ofs);
405 struct ofpbuf *ofperr_encode_reply(enum ofperr, const struct ofp_header *);
406 struct ofpbuf *ofperr_encode_hello(enum ofperr, const struct ofperr_domain *,
407                                    const char *);
408
409 const char *ofperr_get_name(enum ofperr);
410 const char *ofperr_get_description(enum ofperr);
411
412 void ofperr_format(struct ds *, enum ofperr);
413 const char *ofperr_to_string(enum ofperr);
414
415 #endif /* ofp-errors.h */