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>
17 #include <linux/module.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 */
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
47 #define VLINKNLGRP_MAX (__VLINKNLGRP_MAX - 1)
50 VLINKNLCMD_ADD_DEVICE
,
52 VLINKNLCMD_START_HOOK_DEVICE
,
53 VLINKNLCMD_STOP_HOOK_DEVICE
,
56 /* Generic vlinkmsg header, private data can be appended after the header */
62 port
:16; /* Actually 8 Bit, but for alignment reasons */
63 uint8_t virt_name
[IFNAMSIZ
];
64 uint8_t real_name
[IFNAMSIZ
];
69 #define MAX_VLINK_SUBSYSTEMS 256
71 struct vlink_callback
{
73 int (*rx
)(struct vlinknlmsg
*vhdr
, struct nlmsghdr
*nlh
);
74 struct vlink_callback
*next
;
77 #define VLINK_CALLBACK_INIT(fct, prio) { \
87 struct rw_semaphore rwsem
;
88 struct vlink_callback
*head
;
91 #define VLINK_SUBSYS_INIT(varname, sysname, gtype) { \
94 .rwsem = __RWSEM_INITIALIZER((varname).rwsem), \
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
,
112 extern int vlink_rm_callback(struct vlink_subsys
*n
,
113 struct vlink_callback
*cb
);
115 #endif /* __KERNEL__ */
116 #endif /* XT_VLINK_H */