Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


User-space keyed stream functionality (wrapper, example, file-based impl)
[palacios.git] / linux_usr / v3_net.c
1 /* 
2  * V3 Control utility for Palacios network services
3  * (c) Lei Xia, 2010
4  */
5
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <fcntl.h> 
10 #include <sys/ioctl.h> 
11 #include <sys/stat.h> 
12 #include <sys/types.h> 
13 #include <unistd.h> 
14 #include <string.h>
15  
16 #include "v3_ctrl.h"
17
18 struct v3_network {
19     unsigned char socket;
20     unsigned char packet;
21     unsigned char vnet;
22 };
23
24 int main(int argc, char* argv[]) {
25     int v3_fd = 0;
26     struct v3_network net;
27     int i;
28
29     if (argc <= 1) {
30         printf("Usage: ./v3_mem [socket] [packet] [vnet]\n");
31         return -1;
32     }
33
34     for (i = 1; i < argc; i++){
35         if(!strcasecmp (argv[i], "packet")){
36             net.packet = 1;
37         }else if(!strcasecmp (argv[i], "socket")){
38             net.socket = 1;
39         }else if(!strcasecmp (argv[i], "vnet")){
40             net.vnet = 1;
41         }else {
42             printf("unknown v3 network service: %s, ignored\n", argv[i]);
43         }
44     }
45
46     printf("Network service: socket: %d, packet: %d, vnet: %d\n", net.socket, net.packet, net.vnet);
47
48     v3_fd = open(v3_dev, O_RDONLY);
49
50     if (v3_fd == -1) {
51         printf("Error opening V3Vee control device\n");
52         return -1;
53     }
54
55     ioctl(v3_fd, V3_START_NETWORK, &net); 
56
57
58     /* Close the file descriptor.  */ 
59     close(v3_fd); 
60  
61
62     return 0; 
63
64