VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[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 struct rcu_head;
45
46 extern void rcu_free_nx_info(struct rcu_head *);
47 extern void unhash_nx_info(struct nx_info *);
48
49 extern struct nx_info *locate_nx_info(int);
50 extern struct nx_info *locate_or_create_nx_info(int);
51
52 extern int get_nid_list(int, unsigned int *, int);
53 extern int nx_info_is_hashed(nid_t);
54
55 extern int nx_migrate_task(struct task_struct *, struct nx_info *);
56
57 struct in_ifaddr;
58 struct net_device;
59
60 int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
61 int dev_in_nx_info(struct net_device *, struct nx_info *);
62
63
64 #endif  /* __KERNEL__ */
65
66 #include "switch.h"
67
68 /* vinfo commands */
69
70 #define VCMD_task_nid           VC_CMD(VINFO, 2, 0)
71
72 #ifdef  __KERNEL__
73 extern int vc_task_nid(uint32_t, void __user *);
74
75 #endif  /* __KERNEL__ */
76
77 #define VCMD_nx_info            VC_CMD(VINFO, 6, 0)
78
79 struct  vcmd_nx_info_v0 {
80         uint32_t nid;
81         /* more to come */      
82 };
83
84 #ifdef  __KERNEL__
85 extern int vc_nx_info(uint32_t, void __user *);
86
87 #endif  /* __KERNEL__ */
88
89 #define VCMD_net_create         VC_CMD(VNET, 1, 0)
90 #define VCMD_net_migrate        VC_CMD(NETMIG, 1, 0)
91
92 #define VCMD_net_add            VC_CMD(NETALT, 1, 0)
93 #define VCMD_net_remove         VC_CMD(NETALT, 2, 0)
94
95 struct  vcmd_net_nx_v0 {
96         uint16_t type;
97         uint16_t count;
98         uint32_t ip[4];
99         uint32_t mask[4];
100         /* more to come */      
101 };
102
103 //      IPN_TYPE_IPV4   
104
105
106 #ifdef  __KERNEL__
107 extern int vc_net_create(uint32_t, void __user *);
108 extern int vc_net_migrate(uint32_t, void __user *);
109
110 #endif  /* __KERNEL__ */
111
112 #define VCMD_get_nflags         VC_CMD(FLAGS, 5, 0)
113 #define VCMD_set_nflags         VC_CMD(FLAGS, 6, 0)
114
115 struct  vcmd_net_flags_v0 {
116         uint64_t flagword;
117         uint64_t mask;
118 };
119
120 #ifdef  __KERNEL__
121 extern int vc_get_nflags(uint32_t, void __user *);
122 extern int vc_set_nflags(uint32_t, void __user *);
123
124 #endif  /* __KERNEL__ */
125
126 #define IPF_STATE_SETUP         (1ULL<<32)
127
128
129 #define IPF_ONE_TIME            (0x0001ULL<<32)
130
131 #define VCMD_get_ncaps          VC_CMD(FLAGS, 7, 0)
132 #define VCMD_set_ncaps          VC_CMD(FLAGS, 8, 0)
133
134 struct  vcmd_net_caps_v0 {
135         uint64_t ncaps;
136         uint64_t cmask;
137 };
138
139 #ifdef  __KERNEL__
140 extern int vc_get_ncaps(uint32_t, void __user *);
141 extern int vc_set_ncaps(uint32_t, void __user *);
142
143 #endif  /* __KERNEL__ */
144
145 #define IPC_WOSSNAME            0x00000001
146
147
148 #endif  /* _VX_NETWORK_H */