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