22 #define pr_fmt(fmt) "cn_test: " fmt
24 #include <linux/kernel.h>
25 #include <linux/module.h>
28 #include <linux/slab.h>
31 #include <linux/connector.h>
34 static char cn_test_name[] =
"cn_test";
35 static struct sock *nls;
40 pr_info(
"%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n",
41 __func__, jiffies, msg->
id.idx, msg->
id.val,
43 msg->
len ? (
char *)msg->
data :
"");
52 static int cn_test_want_notify(
void)
54 struct cn_ctl_msg *
ctl;
55 struct cn_notify_req *
req;
62 size0 =
sizeof(*msg) +
sizeof(*ctl) + 3 *
sizeof(*req);
68 pr_err(
"failed to allocate new skb with size=%u\n", size);
72 nlh = nlmsg_put(skb, 0, 0x123,
NLMSG_DONE, size -
sizeof(*nlh), 0);
78 msg = nlmsg_data(nlh);
86 msg->
len = size0 -
sizeof(*msg);
88 ctl = (
struct cn_ctl_msg *)(msg + 1);
90 ctl->idx_notify_num = 1;
91 ctl->val_notify_num = 2;
93 ctl->len = msg->len -
sizeof(*ctl);
95 req = (
struct cn_notify_req *)(ctl + 1);
100 req->first = cn_test_id.
idx;
107 req->first = cn_test_id.
val;
114 req->first = cn_test_id.
val + 20;
121 pr_info(
"request was sent: group=0x%x\n", ctl->group);
127 static u32 cn_test_timer_counter;
128 static void cn_test_timer_func(
unsigned long __data)
133 pr_debug(
"%s: timer fired with data %lu\n", __func__, __data);
135 m = kzalloc(
sizeof(*m) +
sizeof(data),
GFP_ATOMIC);
139 m->
seq = cn_test_timer_counter;
143 scnprintf(data,
sizeof(data),
"counter = %u",
144 cn_test_timer_counter) + 1;
152 cn_test_timer_counter++;
157 static int cn_test_init(
void)
171 setup_timer(&cn_test_timer, cn_test_timer_func, 0);
174 pr_info(
"initialized with id={%u.%u}\n",
175 cn_test_id.
idx, cn_test_id.
val);
186 static void cn_test_fini(
void)