updated to vs1.90pre9
[util-vserver.git] / util-vserver / kernel / network.h
1 #ifndef _VX_NETWORK_H
2 #define _VX_NETWORK_H
3
4 #define MAX_N_CONTEXT   65535   /* Arbitrary limit */
5
6 #define IP_DYNAMIC_ID   ((uint32_t)-1)          /* id for dynamic context */
7
8 #define NB_IPV4ROOT     16
9
10 #ifdef  __KERNEL__
11
12 #include <linux/list.h>
13 #include <linux/spinlock.h>
14 #include <linux/utsname.h>
15 #include <asm/resource.h>
16 #include <asm/atomic.h>
17
18
19 struct nx_info {
20         struct list_head nx_list;       /* linked list of nxinfos */
21         nid_t nx_id;                    /* vnet id */
22         atomic_t nx_refcount;
23
24         uint64_t nx_flags;              /* network flag word */
25         uint64_t nx_ncaps;              /* network capabilities */
26
27         int nbipv4;
28         __u32 ipv4[NB_IPV4ROOT];        /* Process can only bind to these IPs */
29                                         /* The first one is used to connect */
30                                         /* and for bind any service */
31                                         /* The other must be used explicity */
32         __u32 mask[NB_IPV4ROOT];        /* Netmask for each ipv4 */
33                                         /* Used to select the proper source */
34                                         /* address for sockets */
35         __u32 v4_bcast;                 /* Broadcast address to receive UDP  */
36
37         char nx_name[65];               /* network context name */
38 };
39
40
41 extern spinlock_t iplist_lock;
42 extern struct list_head nx_infos;
43
44
45 void free_nx_info(struct nx_info *);
46 struct nx_info *create_nx_info(void);
47
48 extern struct nx_info *find_nx_info(int);
49 extern int nx_info_id_valid(int);
50
51 #endif  /* __KERNEL__ */
52
53 #include "switch.h"
54
55 /* vinfo commands */
56
57 #define VCMD_task_nid           VC_CMD(VINFO, 2, 0)
58
59 #ifdef  __KERNEL__
60 extern int vc_task_nid(uint32_t, void __user *);
61
62 #endif  /* __KERNEL__ */
63
64 #define VCMD_nx_info            VC_CMD(VINFO, 6, 0)
65
66 struct  vcmd_nx_info_v0 {
67         uint32_t nid;
68         /* more to come */      
69 };
70
71 #ifdef  __KERNEL__
72 extern int vc_nx_info(uint32_t, void __user *);
73
74 #endif  /* __KERNEL__ */
75
76 #define VCMD_net_create         VC_CMD(VNET, 1, 0)
77 #define VCMD_net_migrate        VC_CMD(NETMIG, 1, 0)
78
79 #define VCMD_net_add            VC_CMD(NETALT, 1, 0)
80 #define VCMD_net_remove         VC_CMD(NETALT, 2, 0)
81
82 struct  vcmd_net_nx_v0 {
83         uint16_t type;
84         uint16_t count;
85         uint32_t ip[4];
86         uint32_t mask[4];
87         /* more to come */      
88 };
89
90 //      IPN_TYPE_IPV4   
91
92
93 #ifdef  __KERNEL__
94 extern int vc_net_create(uint32_t, void __user *);
95 extern int vc_net_migrate(uint32_t, void __user *);
96
97 #endif  /* __KERNEL__ */
98
99 #define VCMD_get_nflags         VC_CMD(FLAGS, 5, 0)
100 #define VCMD_set_nflags         VC_CMD(FLAGS, 6, 0)
101
102 struct  vcmd_net_flags_v0 {
103         uint64_t flagword;
104         uint64_t mask;
105 };
106
107 #ifdef  __KERNEL__
108 extern int vc_get_nflags(uint32_t, void __user *);
109 extern int vc_set_nflags(uint32_t, void __user *);
110
111 #endif  /* __KERNEL__ */
112
113 #define IPF_STATE_SETUP         (1ULL<<32)
114
115
116 #define IPF_ONE_TIME            (0x0001ULL<<32)
117
118 #define VCMD_get_ncaps          VC_CMD(FLAGS, 7, 0)
119 #define VCMD_set_ncaps          VC_CMD(FLAGS, 8, 0)
120
121 struct  vcmd_net_caps_v0 {
122         uint64_t ncaps;
123         uint64_t cmask;
124 };
125
126 #ifdef  __KERNEL__
127 extern int vc_get_ncaps(uint32_t, void __user *);
128 extern int vc_set_ncaps(uint32_t, void __user *);
129
130 #endif  /* __KERNEL__ */
131
132 #define IPC_WOSSNAME            0x00000001
133
134
135 #endif  /* _VX_NETWORK_H */