wprobe: fix some endianness fail in the l2 filter code
[openwrt.git] / package / wprobe / src / kernel / wprobe-dummy.c
1 /*
2 * wprobe-core.c: Wireless probe interface dummy driver
3 * Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
4 *
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.
9 *
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.
14 */
15
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>
23
24 static const char local_addr[] = "\x00\x13\x37\xba\xbe\x00";
25
26 enum dummy_global_values {
27 DUMMY_GLOBAL_MEDIUM_BUSY
28 };
29 enum dummy_link_values {
30 DUMMY_LINK_SNR
31 };
32
33 struct wprobe_item dummy_perlink[] = {
34 [DUMMY_LINK_SNR] = {
35 .name = "snr",
36 .type = WPROBE_VAL_U8,
37 .flags = WPROBE_F_KEEPSTAT,
38 },
39 };
40
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,
46 }
47 };
48
49 int dummy_sync(struct wprobe_iface *dev, struct wprobe_link *l, struct wprobe_value *val, bool measure)
50 {
51 u8 intval = 0;
52
53 get_random_bytes(&intval, 1);
54 if (l) {
55 WPROBE_FILL_BEGIN(val, dummy_perlink);
56 WPROBE_SET(DUMMY_LINK_SNR, U8, (intval % 40));
57 WPROBE_FILL_END();
58 } else {
59 WPROBE_FILL_BEGIN(val, dummy_globals);
60 WPROBE_SET(DUMMY_GLOBAL_MEDIUM_BUSY, U8, (intval % 100));
61 WPROBE_FILL_END();
62 }
63 return 0;
64 }
65
66 static struct wprobe_iface dummy_dev = {
67 .name = "dummy",
68 .addr = local_addr,
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,
74 };
75
76 static struct wprobe_link dummy_link;
77
78 static int __init
79 wprobe_dummy_init(void)
80 {
81 wprobe_add_iface(&dummy_dev);
82 wprobe_add_link(&dummy_dev, &dummy_link, "\x00\x13\x37\xda\xda\x00");
83 return 0;
84 }
85
86 static void __exit
87 wprobe_dummy_exit(void)
88 {
89 wprobe_remove_link(&dummy_dev, &dummy_link);
90 wprobe_remove_iface(&dummy_dev);
91 }
92
93 module_init(wprobe_dummy_init);
94 module_exit(wprobe_dummy_exit);
95
96 MODULE_LICENSE("GPL");
This page took 0.054762 seconds and 5 git commands to generate.