int r;
assert(netdev);
+ assert(m);
if (netdev->kind == NETDEV_KIND_IPIP)
t = IPIP(netdev);
else
t = SIT(netdev);
- assert(m);
assert(t);
if (link || t->assign_to_loopback) {
int r;
assert(netdev);
+ assert(m);
if (netdev->kind == NETDEV_KIND_IP6GRE)
t = IP6GRE(netdev);
t = IP6GRETAP(netdev);
assert(t);
- assert(m);
if (link || t->assign_to_loopback) {
r = sd_netlink_message_append_u32(m, IFLA_GRE_LINK, link ? link->ifindex : LOOPBACK_IFINDEX);
}
static int netdev_ip6tnl_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
- Tunnel *t = IP6TNL(netdev);
uint8_t proto;
+ Tunnel *t;
int r;
assert(netdev);
assert(m);
+
+ t = IP6TNL(netdev);
+
assert(t);
if (link || t->assign_to_loopback) {
}
static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
- Tunnel *t = NULL;
+ Tunnel *t;
assert(netdev);
assert(filename);
- switch (netdev->kind) {
- case NETDEV_KIND_IPIP:
- t = IPIP(netdev);
- break;
- case NETDEV_KIND_SIT:
- t = SIT(netdev);
- break;
- case NETDEV_KIND_GRE:
- t = GRE(netdev);
- break;
- case NETDEV_KIND_GRETAP:
- t = GRETAP(netdev);
- break;
- case NETDEV_KIND_IP6GRE:
- t = IP6GRE(netdev);
- break;
- case NETDEV_KIND_IP6GRETAP:
- t = IP6GRETAP(netdev);
- break;
- case NETDEV_KIND_VTI:
- t = VTI(netdev);
- break;
- case NETDEV_KIND_VTI6:
- t = VTI6(netdev);
- break;
- case NETDEV_KIND_IP6TNL:
- t = IP6TNL(netdev);
- break;
- case NETDEV_KIND_ERSPAN:
- t = ERSPAN(netdev);
- break;
- default:
- assert_not_reached();
- }
+ t = TUNNEL(netdev);
assert(t);
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;