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