2 * Copyright (c) 2014, 2015 Nicira, Inc.
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 implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 /* OpenFlow 1.3+ property support
21 * ==============================
23 * Several OpenFlow 1.3+ messages use properties that take the common form
24 * shown by "struct ofp_prop_header". This module provides support for
25 * serializing and deserializing properties in this format.
30 #include "ofp-errors.h"
31 #include "openvswitch/types.h"
35 /* Deserializing properties. */
36 enum ofperr ofpprop_pull__(struct ofpbuf *msg, struct ofpbuf *property,
37 unsigned int alignment, uint16_t *typep);
38 enum ofperr ofpprop_pull(struct ofpbuf *msg, struct ofpbuf *property,
41 /* Serializing properties. */
42 void ofpprop_put(struct ofpbuf *, uint16_t type,
43 const void *value, size_t len);
44 void ofpprop_put_bitmap(struct ofpbuf *, uint16_t type, uint64_t bitmap);
46 size_t ofpprop_start(struct ofpbuf *, uint16_t type);
47 void ofpprop_end(struct ofpbuf *, size_t start_ofs);
49 /* Logging errors while deserializing properties.
51 * The attitude that a piece of code should take when it deserializes an
52 * unknown property type depends on the code in question:
54 * - In a "loose" context (with LOOSE set to true), that is, where the code
55 * is parsing the property to find out about the state or the capabilities
56 * of some piece of the system, generally an unknown property type is not
57 * a big deal, because it only means that there is additional information
58 * that the receiver does not understand.
60 * - In a "strict" context (with LOOSE set to false), that is, where the
61 * code is parsing the property to change the state or configuration of a
62 * part of the system, generally an unknown property type is an error,
63 * because it means that the receiver is being asked to configure the
64 * system in some way it doesn't understand.
66 * Given LOOSE, this macro automatically logs chooses an appropriate log
68 #define OFPPROP_LOG(RL, LOOSE, ...) \
69 VLOG_RL(RL, (LOOSE) ? VLL_DBG : VLL_WARN, __VA_ARGS__)
71 #endif /* ofp-prop.h */