network: tunnel: introduce TUNNEL() helper function

This commit is contained in:
Yu Watanabe
2021-12-08 01:54:01 +09:00
parent 9e29133085
commit fbe0139f1a
2 changed files with 38 additions and 38 deletions
+30
View File
@@ -74,6 +74,36 @@ DEFINE_NETDEV_CAST(VTI, Tunnel);
DEFINE_NETDEV_CAST(VTI6, Tunnel);
DEFINE_NETDEV_CAST(IP6TNL, Tunnel);
DEFINE_NETDEV_CAST(ERSPAN, Tunnel);
static inline Tunnel* TUNNEL(NetDev *netdev) {
assert(netdev);
switch (netdev->kind) {
case NETDEV_KIND_IPIP:
return IPIP(netdev);
case NETDEV_KIND_SIT:
return SIT(netdev);
case NETDEV_KIND_GRE:
return GRE(netdev);
case NETDEV_KIND_GRETAP:
return GRETAP(netdev);
case NETDEV_KIND_IP6GRE:
return IP6GRE(netdev);
case NETDEV_KIND_IP6GRETAP:
return IP6GRETAP(netdev);
case NETDEV_KIND_VTI:
return VTI(netdev);
case NETDEV_KIND_VTI6:
return VTI6(netdev);
case NETDEV_KIND_IP6TNL:
return IP6TNL(netdev);
case NETDEV_KIND_ERSPAN:
return ERSPAN(netdev);
default:
return NULL;
}
}
extern const NetDevVTable ipip_vtable;
extern const NetDevVTable sit_vtable;
extern const NetDevVTable vti_vtable;