Removed backlog path, assumption for kernelpanic is that in sk_receive_skb mutex...
[ana-net.git] / src / xt_vlink.h
blob77a025ac9085ca305f66b1e739ef2df485682f2f
1 /*
2 * Lightweight Autonomic Network Architecture
4 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL.
7 */
9 #ifndef XT_VLINK_H
10 #define XT_VLINK_H
12 #ifdef __KERNEL__
14 #include <linux/types.h>
15 #include <linux/rwsem.h>
16 #include <linux/netlink.h>
17 #include <linux/module.h>
18 #include <linux/if.h>
20 #define NETLINK_VLINK_RX_OK 0 /* Receive went okay, notify next */
21 #define NETLINK_VLINK_RX_NXT 1 /* Receive is not for us, notify next */
22 #define NETLINK_VLINK_RX_BAD 2 /* Receive failed, notify next */
23 #define NETLINK_VLINK_RX_EMERG 3 /* Receive failed, do not notify next */
24 #define NETLINK_VLINK_RX_STOP 4 /* Receive went okay, but still stop */
26 #define NETLINK_VLINK_PRIO_LOW 0 /* Low priority callbacks */
27 #define NETLINK_VLINK_PRIO_NORM 1 /* Normal priority callbacks */
28 #define NETLINK_VLINK_PRIO_HIGH 2 /* High priority callbacks */
30 #endif /* __KERNEL__ */
32 #define NETLINK_VLINK 23 /* Netlink hook type */
34 enum vlink_groups {
35 VLINKNLGRP_NONE = NLMSG_MIN_TYPE, /* Reserved */
36 #define VLINKNLGRP_NONE VLINKNLGRP_NONE
37 VLINKNLGRP_ETHERNET, /* To vlink Ethernet type */
38 #define VLINKNLGRP_ETHERNET VLINKNLGRP_ETHERNET
39 VLINKNLGRP_BLUETOOTH, /* To vlink Bluetooth type */
40 #define VLINKNLGRP_BLUETOOTH VLINKNLGRP_BLUETOOTH
41 VLINKNLGRP_INFINIBAND, /* To vlink InfiniBand type */
42 #define VLINKNLGRP_INFINIBAND VLINKNLGRP_INFINIBAND
43 VLINKNLGRP_I2C, /* To vlink I^2C type */
44 #define VLINKNLGRP_I2C VLINKNLGRP_I2C
45 __VLINKNLGRP_MAX
47 #define VLINKNLGRP_MAX (__VLINKNLGRP_MAX - 1)
49 enum vlink_cmd {
50 VLINKNLCMD_ADD_DEVICE,
51 VLINKNLCMD_RM_DEVICE,
52 VLINKNLCMD_START_HOOK_DEVICE,
53 VLINKNLCMD_STOP_HOOK_DEVICE,
56 /* Generic vlinkmsg header, private data can be appended after the header */
57 struct vlinknlmsg {
58 uint32_t cmd:8,
59 flags:16,
60 reserved:8;
61 uint32_t type:16,
62 port:16; /* Actually 8 Bit, but for alignment reasons */
63 uint8_t virt_name[IFNAMSIZ];
64 uint8_t real_name[IFNAMSIZ];
67 #ifdef __KERNEL__
69 #define MAX_VLINK_SUBSYSTEMS 256
71 struct vlink_callback {
72 int priority;
73 int (*rx)(struct vlinknlmsg *vhdr, struct nlmsghdr *nlh);
74 struct vlink_callback *next;
77 #define VLINK_CALLBACK_INIT(fct, prio) { \
78 .rx = (fct), \
79 .priority = (prio), \
80 .next = NULL, }
82 struct vlink_subsys {
83 char *name;
84 u32 type:16,
85 id:16;
86 struct module *owner;
87 struct rw_semaphore rwsem;
88 struct vlink_callback *head;
91 #define VLINK_SUBSYS_INIT(varname, sysname, gtype) { \
92 .name = (sysname), \
93 .type = (gtype), \
94 .rwsem = __RWSEM_INITIALIZER((varname).rwsem), \
95 .head = NULL, }
97 extern int init_vlink_system(void);
98 extern void cleanup_vlink_system(void);
99 extern void vlink_lock(void);
100 extern void vlink_unlock(void);
101 extern int vlink_subsys_register(struct vlink_subsys *n);
102 extern void vlink_subsys_unregister(struct vlink_subsys *n);
103 extern void vlink_subsys_unregister_batch(struct vlink_subsys *n);
104 extern struct vlink_subsys *vlink_subsys_find(u16 type);
105 extern int vlink_add_callback(struct vlink_subsys *n,
106 struct vlink_callback *cb);
107 extern int vlink_add_callbacks(struct vlink_subsys *n,
108 struct vlink_callback *cb, ...);
109 extern int vlink_add_callbacks_va(struct vlink_subsys *n,
110 struct vlink_callback *cb,
111 va_list ap);
112 extern int vlink_rm_callback(struct vlink_subsys *n,
113 struct vlink_callback *cb);
115 #endif /* __KERNEL__ */
116 #endif /* XT_VLINK_H */