fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / linux / vserver / network.h
1 #ifndef _VX_NETWORK_H
2 #define _VX_NETWORK_H
3
4 #include <linux/types.h>
5
6
7 #define MAX_N_CONTEXT   65535   /* Arbitrary limit */
8
9 #define NX_DYNAMIC_ID   ((uint32_t)-1)          /* id for dynamic context */
10
11 #define NB_IPV4ROOT     16
12
13
14 /* network flags */
15
16 #define NXF_INFO_PRIVATE        0x00000008
17
18 #define NXF_STATE_SETUP         (1ULL<<32)
19 #define NXF_STATE_ADMIN         (1ULL<<34)
20
21 #define NXF_SC_HELPER           (1ULL<<36)
22 #define NXF_PERSISTENT          (1ULL<<38)
23
24 #define NXF_ONE_TIME            (0x0005ULL<<32)
25
26 #define NXF_INIT_SET            (NXF_STATE_ADMIN)
27
28
29 /* address types */
30
31 #define NXA_TYPE_IPV4           1
32 #define NXA_TYPE_IPV6           2
33
34 #define NXA_MOD_BCAST           (1<<8)
35
36 #define NXA_TYPE_ANY            ((uint16_t)-1)
37
38
39 #ifdef  __KERNEL__
40
41 #include <linux/list.h>
42 #include <linux/spinlock.h>
43 #include <linux/rcupdate.h>
44 #include <asm/atomic.h>
45
46
47 struct nx_info {
48         struct hlist_node nx_hlist;     /* linked list of nxinfos */
49         nid_t nx_id;                    /* vnet id */
50         atomic_t nx_usecnt;             /* usage count */
51         atomic_t nx_tasks;              /* tasks count */
52         int nx_state;                   /* context state */
53
54         uint64_t nx_flags;              /* network flag word */
55         uint64_t nx_ncaps;              /* network capabilities */
56
57         int nbipv4;
58         __u32 ipv4[NB_IPV4ROOT];        /* Process can only bind to these IPs */
59                                         /* The first one is used to connect */
60                                         /* and for bind any service */
61                                         /* The other must be used explicity */
62         __u32 mask[NB_IPV4ROOT];        /* Netmask for each ipv4 */
63                                         /* Used to select the proper source */
64                                         /* address for sockets */
65         __u32 v4_bcast;                 /* Broadcast address to receive UDP  */
66
67         char nx_name[65];               /* network context name */
68 };
69
70
71 /* status flags */
72
73 #define NXS_HASHED      0x0001
74 #define NXS_SHUTDOWN    0x0100
75 #define NXS_RELEASED    0x8000
76
77 /* check conditions */
78
79 #define NX_ADMIN        0x0001
80 #define NX_WATCH        0x0002
81 #define NX_BLEND        0x0004
82 #define NX_HOSTID       0x0008
83
84 #define NX_IDENT        0x0010
85 #define NX_EQUIV        0x0020
86 #define NX_PARENT       0x0040
87 #define NX_CHILD        0x0080
88
89 #define NX_ARG_MASK     0x00F0
90
91 #define NX_DYNAMIC      0x0100
92 #define NX_STATIC       0x0200
93
94 #define NX_ATR_MASK     0x0F00
95
96
97 extern struct nx_info *lookup_nx_info(int);
98
99 extern int get_nid_list(int, unsigned int *, int);
100 extern int nid_is_hashed(nid_t);
101
102 extern int nx_migrate_task(struct task_struct *, struct nx_info *);
103
104 extern long vs_net_change(struct nx_info *, unsigned int);
105
106 struct in_ifaddr;
107 struct net_device;
108
109 #ifdef CONFIG_INET
110 int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
111 int dev_in_nx_info(struct net_device *, struct nx_info *);
112
113 #else /* CONFIG_INET */
114 static inline
115 int ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
116 {
117         return 1;
118 }
119
120 static inline
121 int dev_in_nx_info(struct net_device *d, struct nx_info *n)
122 {
123         return 1;
124 }
125 #endif /* CONFIG_INET */
126
127 struct sock;
128
129 #ifdef CONFIG_INET
130 int nx_addr_conflict(struct nx_info *, uint32_t, const struct sock *);
131 #else /* CONFIG_INET */
132 static inline
133 int nx_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
134 {
135         return 1;
136 }
137 #endif /* CONFIG_INET */
138
139 #endif  /* __KERNEL__ */
140 #else   /* _VX_NETWORK_H */
141 #warning duplicate inclusion
142 #endif  /* _VX_NETWORK_H */