vserver 2.0-rc4
[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 /* context flags */
15
16 #define NXF_STATE_SETUP         (1ULL<<32)
17
18 #define NXF_STATE_HELPER        (1ULL<<36)
19
20 #define NXF_INIT_SET            (0)
21
22
23 #ifdef  __KERNEL__
24
25 #include <linux/list.h>
26 #include <linux/spinlock.h>
27 #include <linux/rcupdate.h>
28 #include <asm/atomic.h>
29
30
31 struct nx_info {
32         struct hlist_node nx_hlist;     /* linked list of nxinfos */
33         nid_t nx_id;                    /* vnet id */
34         atomic_t nx_usecnt;             /* usage count */
35         atomic_t nx_tasks;              /* tasks count */
36         int nx_state;                   /* context state */
37
38         uint64_t nx_flags;              /* network flag word */
39         uint64_t nx_ncaps;              /* network capabilities */
40
41         int nbipv4;
42         __u32 ipv4[NB_IPV4ROOT];        /* Process can only bind to these IPs */
43                                         /* The first one is used to connect */
44                                         /* and for bind any service */
45                                         /* The other must be used explicity */
46         __u32 mask[NB_IPV4ROOT];        /* Netmask for each ipv4 */
47                                         /* Used to select the proper source */
48                                         /* address for sockets */
49         __u32 v4_bcast;                 /* Broadcast address to receive UDP  */
50
51         char nx_name[65];               /* network context name */
52 };
53
54
55 /* status flags */
56
57 #define NXS_HASHED      0x0001
58 #define NXS_SHUTDOWN    0x0100
59 #define NXS_RELEASED    0x8000
60
61 extern struct nx_info *locate_nx_info(int);
62 extern struct nx_info *locate_or_create_nx_info(int);
63
64 extern int get_nid_list(int, unsigned int *, int);
65 extern int nid_is_hashed(nid_t);
66
67 extern int nx_migrate_task(struct task_struct *, struct nx_info *);
68
69 extern long vs_net_change(struct nx_info *, unsigned int);
70
71 struct in_ifaddr;
72 struct net_device;
73
74 int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
75 int dev_in_nx_info(struct net_device *, struct nx_info *);
76
77 struct sock;
78
79 int nx_addr_conflict(struct nx_info *, uint32_t, struct sock *);
80
81 #endif  /* __KERNEL__ */
82 #else   /* _VX_NETWORK_H */
83 #warning duplicate inclusion
84 #endif  /* _VX_NETWORK_H */