2 * Copyright (c) 2010, 2011, 2013 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.
17 #ifndef OPENVSWITCH_TYPES_H
18 #define OPENVSWITCH_TYPES_H 1
20 #include <linux/types.h>
21 #include <sys/types.h>
25 #define OVS_BITWISE __attribute__((bitwise))
26 #define OVS_FORCE __attribute__((force))
32 /* The ovs_be<N> types indicate that an object is in big-endian, not
33 * native-endian, byte order. They are otherwise equivalent to uint<N>_t.
35 * We bootstrap these from the Linux __be<N> types. If we instead define our
36 * own independently then __be<N> and ovs_be<N> become mutually
38 typedef __be16 ovs_be16;
39 typedef __be32 ovs_be32;
40 typedef __be64 ovs_be64;
42 /* Netlink and OpenFlow both contain 64-bit values that are only guaranteed to
43 * be aligned on 32-bit boundaries. These types help.
45 * lib/unaligned.h has helper functions for accessing these. */
47 /* A 64-bit value, in host byte order, that is only aligned on a 32-bit
50 #ifdef WORDS_BIGENDIAN
57 /* A 64-bit value, in network byte order, that is only aligned on a 32-bit
63 /* ofp_port_t represents the port number of a OpenFlow switch.
64 * odp_port_t represents the port number on the datapath.
65 * ofp11_port_t represents the OpenFlow-1.1 port number. */
66 typedef uint16_t OVS_BITWISE ofp_port_t;
67 typedef uint32_t OVS_BITWISE odp_port_t;
68 typedef uint32_t OVS_BITWISE ofp11_port_t;
70 /* Macro functions that cast int types to ofp/odp/ofp11 types. */
71 #define OFP_PORT_C(X) ((OVS_FORCE ofp_port_t) (X))
72 #define ODP_PORT_C(X) ((OVS_FORCE odp_port_t) (X))
73 #define OFP11_PORT_C(X) ((OVS_FORCE ofp11_port_t) (X))
75 #endif /* openvswitch/types.h */