2 * Lightweight Autonomic Network Architecture
4 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
14 #include <linux/types.h>
15 #include <linux/rwsem.h>
16 #include <linux/netlink.h>
19 #define NETLINK_VLINK_RX_OK 0 /* Receive went okay, notify next */
20 #define NETLINK_VLINK_RX_NXT 1 /* Receive is not for us, notify next */
21 #define NETLINK_VLINK_RX_BAD 2 /* Receive failed, notify next */
22 #define NETLINK_VLINK_RX_EMERG 3 /* Receive failed, do not notify next */
23 #define NETLINK_VLINK_RX_STOP 4 /* Receive went okay, but still stop */
25 #define NETLINK_VLINK_PRIO_LOW 0 /* Low priority callbacks */
26 #define NETLINK_VLINK_PRIO_NORM 1 /* Normal priority callbacks */
27 #define NETLINK_VLINK_PRIO_HIGH 2 /* High priority callbacks */
29 #endif /* __KERNEL__ */
31 #define NETLINK_VLINK 23 /* Netlink hook type */
34 VLINKNLGRP_NONE
= NLMSG_MIN_TYPE
, /* Reserved */
35 #define VLINKNLGRP_NONE VLINKNLGRP_NONE
36 VLINKNLGRP_ETHERNET
, /* To vlink Ethernet type */
37 #define VLINKNLGRP_ETHERNET VLINKNLGRP_ETHERNET
38 VLINKNLGRP_BLUETOOTH
, /* To vlink Bluetooth type */
39 #define VLINKNLGRP_BLUETOOTH VLINKNLGRP_BLUETOOTH
40 VLINKNLGRP_INFINIBAND
, /* To vlink InfiniBand type */
41 #define VLINKNLGRP_INFINIBAND VLINKNLGRP_INFINIBAND
42 VLINKNLGRP_I2C
, /* To vlink I^2C type */
43 #define VLINKNLGRP_I2C VLINKNLGRP_I2C
46 #define VLINKNLGRP_MAX (__VLINKNLGRP_MAX - 1)
49 VLINKNLCMD_ADD_DEVICE
,
51 VLINKNLCMD_START_HOOK_DEVICE
,
52 VLINKNLCMD_STOP_HOOK_DEVICE
,
55 /* Generic vlinkmsg header, private data can be appended after the header */
61 port
:16; /* Actually 8 Bit, but for alignment reasons */
62 uint8_t virt_name
[IFNAMSIZ
];
63 uint8_t real_name
[IFNAMSIZ
];
68 #define MAX_VLINK_SUBSYSTEMS 256
70 struct vlink_callback
{
72 int (*rx
)(struct vlinknlmsg
*vhdr
, struct nlmsghdr
*nlh
);
73 struct vlink_callback
*next
;
76 #define VLINK_CALLBACK_INIT(fct, prio) { \
85 struct rw_semaphore rwsem
;
86 struct vlink_callback
*head
;
89 #define VLINK_SUBSYS_INIT(varname, sysname, gtype) { \
92 .rwsem = __RWSEM_INITIALIZER((varname).rwsem), \
95 extern int init_vlink_system(void);
96 extern void cleanup_vlink_system(void);
97 extern void vlink_lock(void);
98 extern void vlink_unlock(void);
99 extern int vlink_subsys_register(struct vlink_subsys
*n
);
100 extern void vlink_subsys_unregister(struct vlink_subsys
*n
);
101 extern void vlink_subsys_unregister_batch(struct vlink_subsys
*n
);
102 extern struct vlink_subsys
*vlink_subsys_find(u16 type
);
103 extern int vlink_add_callback(struct vlink_subsys
*n
,
104 struct vlink_callback
*cb
);
105 extern int vlink_add_callbacks(struct vlink_subsys
*n
,
106 struct vlink_callback
*cb
, ...);
107 extern int vlink_add_callbacks_va(struct vlink_subsys
*n
,
108 struct vlink_callback
*cb
,
110 extern int vlink_rm_callback(struct vlink_subsys
*n
,
111 struct vlink_callback
*cb
);
113 #endif /* __KERNEL__ */
114 #endif /* XT_VLINK_H */