hub.c (cebea510579ed43724156cc596a8ff14ba208740) | hub.c (f394b2e20d9a666fb194fb692179a0eeaca5daea) |
---|---|
1/* 2 * Hub net client 3 * 4 * Copyright IBM, Corp. 2012 5 * 6 * Authors: 7 * Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> 8 * Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> --- 117 unchanged lines hidden (view full) --- 126static void net_hub_port_cleanup(NetClientState *nc) 127{ 128 NetHubPort *port = DO_UPCAST(NetHubPort, nc, nc); 129 130 QLIST_REMOVE(port, next); 131} 132 133static NetClientInfo net_hub_port_info = { | 1/* 2 * Hub net client 3 * 4 * Copyright IBM, Corp. 2012 5 * 6 * Authors: 7 * Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> 8 * Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> --- 117 unchanged lines hidden (view full) --- 126static void net_hub_port_cleanup(NetClientState *nc) 127{ 128 NetHubPort *port = DO_UPCAST(NetHubPort, nc, nc); 129 130 QLIST_REMOVE(port, next); 131} 132 133static NetClientInfo net_hub_port_info = { |
134 .type = NET_CLIENT_OPTIONS_KIND_HUBPORT, | 134 .type = NET_CLIENT_DRIVER_HUBPORT, |
135 .size = sizeof(NetHubPort), 136 .can_receive = net_hub_port_can_receive, 137 .receive = net_hub_port_receive, 138 .receive_iov = net_hub_port_receive_iov, 139 .cleanup = net_hub_port_cleanup, 140}; 141 142static NetHubPort *net_hub_port_new(NetHub *hub, const char *name) --- 118 unchanged lines hidden (view full) --- 261 * Get the hub id that a client is connected to 262 * 263 * @id: Pointer for hub id output, may be NULL 264 */ 265int net_hub_id_for_client(NetClientState *nc, int *id) 266{ 267 NetHubPort *port; 268 | 135 .size = sizeof(NetHubPort), 136 .can_receive = net_hub_port_can_receive, 137 .receive = net_hub_port_receive, 138 .receive_iov = net_hub_port_receive_iov, 139 .cleanup = net_hub_port_cleanup, 140}; 141 142static NetHubPort *net_hub_port_new(NetHub *hub, const char *name) --- 118 unchanged lines hidden (view full) --- 261 * Get the hub id that a client is connected to 262 * 263 * @id: Pointer for hub id output, may be NULL 264 */ 265int net_hub_id_for_client(NetClientState *nc, int *id) 266{ 267 NetHubPort *port; 268 |
269 if (nc->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) { | 269 if (nc->info->type == NET_CLIENT_DRIVER_HUBPORT) { |
270 port = DO_UPCAST(NetHubPort, nc, nc); 271 } else if (nc->peer != NULL && nc->peer->info->type == | 270 port = DO_UPCAST(NetHubPort, nc, nc); 271 } else if (nc->peer != NULL && nc->peer->info->type == |
272 NET_CLIENT_OPTIONS_KIND_HUBPORT) { | 272 NET_CLIENT_DRIVER_HUBPORT) { |
273 port = DO_UPCAST(NetHubPort, nc, nc->peer); 274 } else { 275 return -ENOENT; 276 } 277 278 if (id) { 279 *id = port->hub->id; 280 } 281 return 0; 282} 283 284int net_init_hubport(const Netdev *netdev, const char *name, 285 NetClientState *peer, Error **errp) 286{ 287 const NetdevHubPortOptions *hubport; 288 | 273 port = DO_UPCAST(NetHubPort, nc, nc->peer); 274 } else { 275 return -ENOENT; 276 } 277 278 if (id) { 279 *id = port->hub->id; 280 } 281 return 0; 282} 283 284int net_init_hubport(const Netdev *netdev, const char *name, 285 NetClientState *peer, Error **errp) 286{ 287 const NetdevHubPortOptions *hubport; 288 |
289 assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT); | 289 assert(netdev->type == NET_CLIENT_DRIVER_HUBPORT); |
290 assert(!peer); | 290 assert(!peer); |
291 hubport = netdev->opts->u.hubport.data; | 291 hubport = &netdev->u.hubport; |
292 293 net_hub_add_port(hubport->hubid, name); 294 return 0; 295} 296 297/** 298 * Warn if hub configurations are likely wrong 299 */ --- 10 unchanged lines hidden (view full) --- 310 peer = port->nc.peer; 311 if (!peer) { 312 fprintf(stderr, "Warning: hub port %s has no peer\n", 313 port->nc.name); 314 continue; 315 } 316 317 switch (peer->info->type) { | 292 293 net_hub_add_port(hubport->hubid, name); 294 return 0; 295} 296 297/** 298 * Warn if hub configurations are likely wrong 299 */ --- 10 unchanged lines hidden (view full) --- 310 peer = port->nc.peer; 311 if (!peer) { 312 fprintf(stderr, "Warning: hub port %s has no peer\n", 313 port->nc.name); 314 continue; 315 } 316 317 switch (peer->info->type) { |
318 case NET_CLIENT_OPTIONS_KIND_NIC: | 318 case NET_CLIENT_DRIVER_NIC: |
319 has_nic = 1; 320 break; | 319 has_nic = 1; 320 break; |
321 case NET_CLIENT_OPTIONS_KIND_USER: 322 case NET_CLIENT_OPTIONS_KIND_TAP: 323 case NET_CLIENT_OPTIONS_KIND_SOCKET: 324 case NET_CLIENT_OPTIONS_KIND_VDE: 325 case NET_CLIENT_OPTIONS_KIND_VHOST_USER: | 321 case NET_CLIENT_DRIVER_USER: 322 case NET_CLIENT_DRIVER_TAP: 323 case NET_CLIENT_DRIVER_SOCKET: 324 case NET_CLIENT_DRIVER_VDE: 325 case NET_CLIENT_DRIVER_VHOST_USER: |
326 has_host_dev = 1; 327 break; 328 default: 329 break; 330 } 331 } 332 if (has_host_dev && !has_nic) { 333 fprintf(stderr, "Warning: vlan %d with no nics\n", hub->id); --- 22 unchanged lines hidden --- | 326 has_host_dev = 1; 327 break; 328 default: 329 break; 330 } 331 } 332 if (has_host_dev && !has_nic) { 333 fprintf(stderr, "Warning: vlan %d with no nics\n", hub->id); --- 22 unchanged lines hidden --- |