1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/******************************************************************************
* arch/xen/drivers/netif/backend/control.c
*
* Routines for interfacing with the control plane.
*
* Copyright (c) 2004, Keir Fraser
*/
#include "common.h"
static void netif_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
{
DPRINTK("Received netif backend message, subtype=%d\n", msg->subtype);
switch ( msg->subtype )
{
case CMSG_NETIF_BE_CREATE:
netif_create((netif_be_create_t *)&msg->msg[0]);
break;
case CMSG_NETIF_BE_DESTROY:
netif_destroy((netif_be_destroy_t *)&msg->msg[0]);
break;
case CMSG_NETIF_BE_CREDITLIMIT:
netif_creditlimit((netif_be_creditlimit_t *)&msg->msg[0]);
break;
case CMSG_NETIF_BE_CONNECT:
netif_connect((netif_be_connect_t *)&msg->msg[0]);
break;
case CMSG_NETIF_BE_DISCONNECT:
if ( !netif_disconnect((netif_be_disconnect_t *)&msg->msg[0],msg->id) )
return; /* Sending the response is deferred until later. */
break;
default:
DPRINTK("Parse error while reading message subtype %d, len %d\n",
msg->subtype, msg->length);
msg->length = 0;
break;
}
ctrl_if_send_response(msg);
}
void netif_ctrlif_init(void)
{
ctrl_msg_t cmsg;
netif_be_driver_status_t st;
(void)ctrl_if_register_receiver(CMSG_NETIF_BE, netif_ctrlif_rx,
CALLBACK_IN_BLOCKING_CONTEXT);
/* Send a driver-UP notification to the domain controller. */
cmsg.type = CMSG_NETIF_BE;
cmsg.subtype = CMSG_NETIF_BE_DRIVER_STATUS;
cmsg.length = sizeof(netif_be_driver_status_t);
st.status = NETIF_DRIVER_STATUS_UP;
memcpy(cmsg.msg, &st, sizeof(st));
ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
}
|