2 * Lightweight Autonomic Network Architecture
4 * Builds Functional Block objects requested by its type. Holds global
5 * reference to all registered functional blocks. Invoked from userspace
8 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
9 * Swiss federal institute of technology (ETH Zurich)
13 #include <linux/kernel.h>
14 #include <linux/module.h>
16 #include "xt_critbit.h"
17 #include "xt_builder.h"
18 #include "xt_fblock.h"
20 static struct critbit_tree fbmap
;
22 int register_fblock_type(struct fblock_factory
*fops
)
24 return critbit_insert(&fbmap
, fops
->type
);
26 EXPORT_SYMBOL_GPL(register_fblock_type
);
28 void unregister_fblock_type(struct fblock_factory
*fops
)
30 critbit_delete(&fbmap
, fops
->type
);
32 EXPORT_SYMBOL_GPL(unregister_fblock_type
);
34 struct fblock
*build_fblock_object(char *type
, char *name
)
37 struct fblock_factory
*factory
= struct_of(critbit_get(&fbmap
, type
),
38 struct fblock_factory
);
40 printk(KERN_ERR
"[lana] So such type available!\n");
43 fb
= factory
->ctor(name
);
46 fb
->factory
= factory
;
49 EXPORT_SYMBOL(build_fblock_object
);
51 int init_fblock_builder(void)
54 critbit_init_tree(&fbmap
);
57 EXPORT_SYMBOL_GPL(init_fblock_builder
);
59 void cleanup_fblock_builder(void)
63 EXPORT_SYMBOL_GPL(cleanup_fblock_builder
);