goto ERROR;
// Call any custom initialization
- if (port->ops.config_read) {
- r = port->ops.config_read(port);
+ if (NW_PORT_OPS(port)->config_read) {
+ r = NW_PORT_OPS(port)->config_read(port);
if (r)
goto ERROR;
}
// Set operations
switch (p->type) {
case NW_PORT_DUMMY:
- p->ops = nw_port_ops_dummy;
+ p->info = &nw_port_info_dummy;
break;
case NW_PORT_VLAN:
- p->ops = nw_port_ops_vlan;
+ p->info = &nw_port_info_vlan;
break;
}
int r;
// Call the custom handler
- if (port->ops.config_write) {
- r = port->ops.config_write(port);
+ if (NW_PORT_OPS(port)->config_write) {
+ r = NW_PORT_OPS(port)->config_write(port);
if (r)
goto ERROR;
}
nw_link* link = NULL;
// Do nothing if not implemented
- if (!port->ops.get_parent_port)
+ if (!NW_PORT_OPS(port)->get_parent_port)
goto ERROR;
// Fetch the parent
- parent = port->ops.get_parent_port(port);
+ parent = NW_PORT_OPS(port)->get_parent_port(port);
if (!parent)
goto ERROR;
goto ERROR;
// Run the custom setup
- if (port->ops.create_link) {
- r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, port->ops.kind);
+ if (NW_PORT_OPS(port)->create_link) {
+ r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, NW_PORT_INFO(port)->kind);
if (r < 0) {
ERROR("Could not open IFLA_INFO_DATA container: %s\n", strerror(-r));
goto ERROR;
}
- r = port->ops.create_link(port, m);
+ r = NW_PORT_OPS(port)->create_link(port, m);
if (r) {
ERROR("Could not create port %s: %m\n", port->name);
goto ERROR;
// Just set IFLA_INFO_KIND if there is no custom function
} else {
- r = sd_netlink_message_append_string(m, IFLA_INFO_KIND, port->ops.kind);
+ r = sd_netlink_message_append_string(m, IFLA_INFO_KIND, NW_PORT_INFO(port)->kind);
if (r < 0)
goto ERROR;
}
}
// If there is no link, we will try to create it
- if (!port->link) {
- r = nw_port_create_link(port);
- if (r)
- return r;
- }
+ if (!port->link)
+ return nw_port_create_link(port);
// XXX TODO