2 * wprobe-core.c: Wireless probe interface dummy driver
3 * Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <linux/kernel.h>
17 #include <linux/version.h>
18 #include <linux/module.h>
19 #include <linux/types.h>
20 #include <linux/spinlock.h>
21 #include <linux/random.h>
22 #include <linux/wprobe.h>
24 static const char local_addr[] = "\x00\x13\x37\xba\xbe\x00";
26 enum dummy_global_values {
27 DUMMY_GLOBAL_MEDIUM_BUSY
29 enum dummy_link_values {
33 struct wprobe_item dummy_perlink[] = {
36 .type = WPROBE_VAL_U8,
37 .flags = WPROBE_F_KEEPSTAT,
41 struct wprobe_item dummy_globals[] = {
42 [DUMMY_GLOBAL_MEDIUM_BUSY] = {
43 .name = "medium_busy",
44 .type = WPROBE_VAL_U8,
45 .flags = WPROBE_F_KEEPSTAT,
49 int dummy_sync(struct wprobe_iface *dev, struct wprobe_link *l, struct wprobe_value *val, bool measure)
53 get_random_bytes(&intval, 1);
55 WPROBE_FILL_BEGIN(val, dummy_perlink);
56 WPROBE_SET(DUMMY_LINK_SNR, U8, (intval % 40));
59 WPROBE_FILL_BEGIN(val, dummy_globals);
60 WPROBE_SET(DUMMY_GLOBAL_MEDIUM_BUSY, U8, (intval % 100));
66 static struct wprobe_iface dummy_dev = {
69 .link_items = dummy_perlink,
70 .n_link_items = ARRAY_SIZE(dummy_perlink),
71 .global_items = dummy_globals,
72 .n_global_items = ARRAY_SIZE(dummy_globals),
73 .sync_data = dummy_sync,
76 static struct wprobe_link dummy_link;
79 wprobe_dummy_init(void)
81 wprobe_add_iface(&dummy_dev);
82 wprobe_add_link(&dummy_dev, &dummy_link, "\x00\x13\x37\xda\xda\x00");
87 wprobe_dummy_exit(void)
89 wprobe_remove_link(&dummy_dev, &dummy_link);
90 wprobe_remove_iface(&dummy_dev);
93 module_init(wprobe_dummy_init);
94 module_exit(wprobe_dummy_exit);
96 MODULE_LICENSE("GPL");