26 #include <linux/slab.h>
27 #include <linux/errno.h>
28 #include <linux/module.h>
29 #include <linux/device.h>
30 #include <linux/random.h>
59 int uwb_rc_dev_addr_mgmt(
struct uwb_rc *
rc,
75 switch (bmOperationType >> 1) {
76 case 0: size = 2;
break;
77 case 1: size = 6;
break;
85 &cmd->
rccb,
sizeof(*cmd),
86 &reply->
rceb,
sizeof(*reply));
89 if (result <
sizeof(*reply)) {
91 "DEV-ADDR-MGMT: not enough data replied: "
92 "%d vs %zu bytes needed\n", result,
sizeof(*reply));
96 "DEV-ADDR-MGMT: command execution failed: %s (%d)\n",
124 static int uwb_rc_addr_set(
struct uwb_rc *
rc,
137 baAddr = dev_addr->
data;
140 baAddr = mac_addr->
data;
141 bmOperationType |= 0x2;
146 return uwb_rc_dev_addr_mgmt(rc, bmOperationType, baAddr, &reply);
162 static int uwb_rc_addr_get(
struct uwb_rc *rc,
166 u8 bmOperationType = 0x0;
175 baAddr = dev_addr->
data;
178 bmOperationType |= 0x2;
179 baAddr = mac_addr->
data;
184 result = uwb_rc_dev_addr_mgmt(rc, bmOperationType, baAddr, &
evt);
189 sizeof(dev_addr->
data));
193 sizeof(mac_addr->
data));
248 if (!uwb_mac_addr_cmp(addr, &uwb_dev->
mac_addr))
258 if (!uwb_dev_addr_cmp(addr, &uwb_dev->
dev_addr))
283 }
while (new_addr.
data[0] == 0x00 || new_addr.
data[0] == 0xff
284 || __uwb_dev_addr_assigned(rc, &new_addr));
321 buf[result++] =
'\n';
332 const char *buf,
size_t size)
339 result =
sscanf(buf,
"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n",
346 if (is_multicast_ether_addr(
addr.data)) {
348 "MAC address %s\n", buf);
356 return result < 0 ? result :
size;
366 result =
scnprintf(buf, buf_size,
"%pM", addr);
368 result =
scnprintf(buf, buf_size,
"%02x:%02x",