netdev-native-tnl: Introduce ip_build_header()
[cascardo/ovs.git] / lib / netdev-vport-private.h
1 /*
2  * Copyright (c) 2010, 2011, 2013, 2015 Nicira, Inc.
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 NETDEV_VPORT_PRIVATE_H
18 #define NETDEV_VPORT_PRAVITE_H 1
19
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include "compiler.h"
23 #include "ovs-thread.h"
24
25 struct netdev_vport {
26     struct netdev up;
27
28     /* Protects all members below. */
29     struct ovs_mutex mutex;
30
31     struct eth_addr etheraddr;
32     struct netdev_stats stats;
33
34     /* Tunnels. */
35     struct netdev_tunnel_config tnl_cfg;
36     char egress_iface[IFNAMSIZ];
37     bool carrier_status;
38
39     /* Patch Ports. */
40     char *peer;
41 };
42
43 int netdev_vport_construct(struct netdev *);
44
45 static bool
46 is_vport_class(const struct netdev_class *class)
47 {
48     return class->construct == netdev_vport_construct;
49 }
50
51 static inline struct netdev_vport *
52 netdev_vport_cast(const struct netdev *netdev)
53 {
54     ovs_assert(is_vport_class(netdev_get_class(netdev)));
55     return CONTAINER_OF(netdev, struct netdev_vport, up);
56 }
57
58 #endif