#ifndef _VX_NETWORK_H
#define _VX_NETWORK_H
+#include <linux/types.h>
+
+
#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
-#define IP_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
+#define NX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
#define NB_IPV4ROOT 16
+
+/* network flags */
+
+#define NXF_INFO_PRIVATE 0x00000008
+
+#define NXF_STATE_SETUP (1ULL<<32)
+#define NXF_STATE_ADMIN (1ULL<<34)
+
+#define NXF_SC_HELPER (1ULL<<36)
+#define NXF_PERSISTENT (1ULL<<38)
+
+#define NXF_ONE_TIME (0x0005ULL<<32)
+
+#define NXF_INIT_SET (NXF_STATE_ADMIN)
+
+
+/* address types */
+
+#define NXA_TYPE_IPV4 1
+#define NXA_TYPE_IPV6 2
+
+#define NXA_MOD_BCAST (1<<8)
+
+#define NXA_TYPE_ANY ((uint16_t)-1)
+
+
#ifdef __KERNEL__
#include <linux/list.h>
#include <linux/spinlock.h>
-#include <linux/utsname.h>
-#include <asm/resource.h>
+#include <linux/rcupdate.h>
#include <asm/atomic.h>
struct nx_info {
- struct list_head nx_list; /* linked list of nxinfos */
+ struct hlist_node nx_hlist; /* linked list of nxinfos */
nid_t nx_id; /* vnet id */
- atomic_t nx_refcount;
+ atomic_t nx_usecnt; /* usage count */
+ atomic_t nx_tasks; /* tasks count */
+ int nx_state; /* context state */
uint64_t nx_flags; /* network flag word */
uint64_t nx_ncaps; /* network capabilities */
};
-extern spinlock_t nxlist_lock;
-extern struct list_head nx_infos;
-
-
-void free_nx_info(struct nx_info *);
-struct nx_info *create_nx_info(void);
-
-extern struct nx_info *find_nx_info(int);
-extern int nx_info_id_valid(int);
-
-struct in_ifaddr;
-struct net_device;
-
-int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
-int dev_in_nx_info(struct net_device *, struct nx_info *);
-
-
-#endif /* __KERNEL__ */
-
-#include "switch.h"
-
-/* vinfo commands */
-
-#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
-
-#ifdef __KERNEL__
-extern int vc_task_nid(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
-
-struct vcmd_nx_info_v0 {
- uint32_t nid;
- /* more to come */
-};
-
-#ifdef __KERNEL__
-extern int vc_nx_info(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
+/* status flags */
-#define VCMD_net_create VC_CMD(VNET, 1, 0)
-#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
+#define NXS_HASHED 0x0001
+#define NXS_SHUTDOWN 0x0100
+#define NXS_RELEASED 0x8000
-#define VCMD_net_add VC_CMD(NETALT, 1, 0)
-#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
+/* check conditions */
-struct vcmd_net_nx_v0 {
- uint16_t type;
- uint16_t count;
- uint32_t ip[4];
- uint32_t mask[4];
- /* more to come */
-};
+#define NX_ADMIN 0x0001
+#define NX_WATCH 0x0002
+#define NX_BLEND 0x0004
+#define NX_HOSTID 0x0008
-// IPN_TYPE_IPV4
+#define NX_IDENT 0x0010
+#define NX_EQUIV 0x0020
+#define NX_PARENT 0x0040
+#define NX_CHILD 0x0080
+#define NX_ARG_MASK 0x00F0
-#ifdef __KERNEL__
-extern int vc_net_create(uint32_t, void __user *);
-extern int vc_net_migrate(uint32_t, void __user *);
+#define NX_DYNAMIC 0x0100
+#define NX_STATIC 0x0200
-#endif /* __KERNEL__ */
+#define NX_ATR_MASK 0x0F00
-#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
-#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
-struct vcmd_net_flags_v0 {
- uint64_t flagword;
- uint64_t mask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_nflags(uint32_t, void __user *);
-extern int vc_set_nflags(uint32_t, void __user *);
+extern struct nx_info *lookup_nx_info(int);
-#endif /* __KERNEL__ */
+extern int get_nid_list(int, unsigned int *, int);
+extern int nid_is_hashed(nid_t);
-#define IPF_STATE_SETUP (1ULL<<32)
+extern int nx_migrate_task(struct task_struct *, struct nx_info *);
+extern long vs_net_change(struct nx_info *, unsigned int);
-#define IPF_ONE_TIME (0x0001ULL<<32)
-
-#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
-#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
+struct in_ifaddr;
+struct net_device;
-struct vcmd_net_caps_v0 {
- uint64_t ncaps;
- uint64_t cmask;
-};
+#ifdef CONFIG_INET
+int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
+int dev_in_nx_info(struct net_device *, struct nx_info *);
-#ifdef __KERNEL__
-extern int vc_get_ncaps(uint32_t, void __user *);
-extern int vc_set_ncaps(uint32_t, void __user *);
+#else /* CONFIG_INET */
+static inline
+int ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
+{
+ return 1;
+}
+
+static inline
+int dev_in_nx_info(struct net_device *d, struct nx_info *n)
+{
+ return 1;
+}
+#endif /* CONFIG_INET */
+
+struct sock;
+
+#ifdef CONFIG_INET
+int nx_addr_conflict(struct nx_info *, uint32_t, const struct sock *);
+#else /* CONFIG_INET */
+static inline
+int nx_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
+{
+ return 1;
+}
+#endif /* CONFIG_INET */
#endif /* __KERNEL__ */
-
-#define IPC_WOSSNAME 0x00000001
-
-
+#else /* _VX_NETWORK_H */
+#warning duplicate inclusion
#endif /* _VX_NETWORK_H */